/*
 * Copyright (c) 2023-2025 Datalayer, Inc.
 * Distributed under the terms of the Modified BSD License.
 */
/**
 * Items API functions for the Datalayer platform.
 *
 * Provides functions for managing items in spaces.
 *
 * @module api/spacer/items
 */
import { requestDatalayerAPI } from '../DatalayerApi.js';
import { API_BASE_PATHS, DEFAULT_SERVICE_URLS } from '../constants.js';
/**
 * Get the items of a space.
 * @param token - Authentication token
 * @param spaceId - The space ID
 * @param baseUrl - Base URL for the API (defaults to production)
 * @returns Promise resolving to the items response
 */
export const getSpaceItems = async (token, spaceId, baseUrl = DEFAULT_SERVICE_URLS.SPACER) => {
    return requestDatalayerAPI({
        url: `${baseUrl}${API_BASE_PATHS.SPACER}/spaces/${spaceId}/items`,
        method: 'GET',
        token,
    });
};
/**
 * Get a single item from a space.
 * @param token - Authentication token
 * @param id - The item ID to retrieve
 * @param baseUrl - Base URL for the API (defaults to production)
 * @returns Promise resolving to the item response
 */
export const getItem = async (token, id, baseUrl = DEFAULT_SERVICE_URLS.SPACER) => {
    return requestDatalayerAPI({
        url: `${baseUrl}${API_BASE_PATHS.SPACER}/spaces/items/${id}`,
        method: 'GET',
        token,
    });
};
/**
 * Delete an item from a space.
 * @param token - Authentication token
 * @param id - The item ID to delete
 * @param baseUrl - Base URL for the API (defaults to production)
 * @returns Promise resolving when deletion is complete
 */
export const deleteItem = async (token, id, baseUrl = DEFAULT_SERVICE_URLS.SPACER) => {
    return requestDatalayerAPI({
        url: `${baseUrl}${API_BASE_PATHS.SPACER}/spaces/items/${id}`,
        method: 'DELETE',
        token,
    });
};
