UNPKG

@datocms/cma-client

Version:
373 lines (372 loc) 17.2 kB
import * as Utils from '@datocms/rest-client-utils'; import BaseResource from '../../BaseResource'; import type { ItemTypeDefinition } from '../../utilities/itemDefinition'; import type * as ApiTypes from '../ApiTypes'; import type * as RawApiTypes from '../RawApiTypes'; type NoInfer<T> = [T][T extends any ? 0 : never]; export default class Item extends BaseResource { static readonly TYPE: "item"; /** * List all records * * Read more: https://www.datocms.com/docs/content-management-api/resources/item/instances * * @throws {ApiError} * @throws {TimeoutError} */ list<D extends ItemTypeDefinition = ItemTypeDefinition>(queryParams: ApiTypes.ItemInstancesHrefSchema<D> & { nested: true; }): Promise<ApiTypes.ItemInstancesTargetSchema<NoInfer<D>, true>>; list<D extends ItemTypeDefinition = ItemTypeDefinition>(queryParams?: ApiTypes.ItemInstancesHrefSchema<D> & { nested?: false | undefined; }): Promise<ApiTypes.ItemInstancesTargetSchema<NoInfer<D>, false>>; /** * List all records * * Read more: https://www.datocms.com/docs/content-management-api/resources/item/instances * * @throws {ApiError} * @throws {TimeoutError} */ rawList<D extends ItemTypeDefinition = ItemTypeDefinition>(queryParams: RawApiTypes.ItemInstancesHrefSchema<D> & { nested: true; }): Promise<RawApiTypes.ItemInstancesTargetSchema<NoInfer<D>, true>>; rawList<D extends ItemTypeDefinition = ItemTypeDefinition>(queryParams?: RawApiTypes.ItemInstancesHrefSchema<D> & { nested?: false | undefined; }): Promise<RawApiTypes.ItemInstancesTargetSchema<NoInfer<D>, false>>; rawList<D extends ItemTypeDefinition = ItemTypeDefinition>(queryParams?: RawApiTypes.ItemInstancesHrefSchema<D>): Promise<RawApiTypes.ItemInstancesTargetSchema<NoInfer<D>, true>>; /** * Async iterator to auto-paginate over elements returned by list() * * Read more: https://www.datocms.com/docs/content-management-api/resources/item/instances * * @throws {ApiError} * @throws {TimeoutError} */ listPagedIterator<D extends ItemTypeDefinition = ItemTypeDefinition>(queryParams: Utils.OmitFromKnownKeys<ApiTypes.ItemInstancesHrefSchema<D> & { nested: true; }, 'page'>, iteratorOptions?: Utils.IteratorOptions): AsyncGenerator<ApiTypes.ItemInstancesTargetSchema<NoInfer<D>, true>[0]>; listPagedIterator<D extends ItemTypeDefinition = ItemTypeDefinition>(queryParams?: Utils.OmitFromKnownKeys<ApiTypes.ItemInstancesHrefSchema<D> & { nested?: false | undefined; }, 'page'>, iteratorOptions?: Utils.IteratorOptions): AsyncGenerator<ApiTypes.ItemInstancesTargetSchema<NoInfer<D>, false>[0]>; /** * Async iterator to auto-paginate over elements returned by rawList() * * Read more: https://www.datocms.com/docs/content-management-api/resources/item/instances * * @throws {ApiError} * @throws {TimeoutError} */ rawListPagedIterator<D extends ItemTypeDefinition = ItemTypeDefinition>(queryParams: Utils.OmitFromKnownKeys<RawApiTypes.ItemInstancesHrefSchema<D> & { nested: true; }, 'page'>, iteratorOptions?: Utils.IteratorOptions): AsyncGenerator<RawApiTypes.ItemInstancesTargetSchema<NoInfer<D>, true>['data'][0]>; rawListPagedIterator<D extends ItemTypeDefinition = ItemTypeDefinition>(queryParams?: Utils.OmitFromKnownKeys<RawApiTypes.ItemInstancesHrefSchema<D> & { nested?: false | undefined; }, 'page'>, iteratorOptions?: Utils.IteratorOptions): AsyncGenerator<RawApiTypes.ItemInstancesTargetSchema<NoInfer<D>, false>['data'][0]>; rawListPagedIterator<D extends ItemTypeDefinition = ItemTypeDefinition>(queryParams?: Utils.OmitFromKnownKeys<RawApiTypes.ItemInstancesHrefSchema<D>, 'page'>, iteratorOptions?: Utils.IteratorOptions): AsyncGenerator<RawApiTypes.ItemInstancesTargetSchema<NoInfer<D>, true>['data'][0]>; /** * Validates an existing record field * * Read more: https://www.datocms.com/docs/content-management-api/resources/item/validate_existing * * @throws {ApiError} * @throws {TimeoutError} * * @deprecated This API call is to be considered private and might change without notice */ validateExisting<D extends ItemTypeDefinition = ItemTypeDefinition>(itemId: string | ApiTypes.ItemData, body: ApiTypes.ItemValidateExistingSchema<NoInfer<D>>): Promise<void>; /** * Validates an existing record field * * Read more: https://www.datocms.com/docs/content-management-api/resources/item/validate_existing * * @throws {ApiError} * @throws {TimeoutError} * * @deprecated This API call is to be considered private and might change without notice */ rawValidateExisting<D extends ItemTypeDefinition = ItemTypeDefinition>(itemId: string, body: RawApiTypes.ItemValidateExistingSchema<NoInfer<D>>): Promise<void>; /** * Validates a record field * * Read more: https://www.datocms.com/docs/content-management-api/resources/item/validate_new * * @throws {ApiError} * @throws {TimeoutError} * * @deprecated This API call is to be considered private and might change without notice */ validateNew<D extends ItemTypeDefinition = ItemTypeDefinition>(body: ApiTypes.ItemValidateNewSchema<NoInfer<D>>): Promise<void>; /** * Validates a record field * * Read more: https://www.datocms.com/docs/content-management-api/resources/item/validate_new * * @throws {ApiError} * @throws {TimeoutError} * * @deprecated This API call is to be considered private and might change without notice */ rawValidateNew<D extends ItemTypeDefinition = ItemTypeDefinition>(body: RawApiTypes.ItemValidateNewSchema<NoInfer<D>>): Promise<void>; /** * Create a new record * * Read more: https://www.datocms.com/docs/content-management-api/resources/item/create * * @throws {ApiError} * @throws {TimeoutError} */ create<D extends ItemTypeDefinition = ItemTypeDefinition>(body: ApiTypes.ItemCreateSchema<NoInfer<D>>): Promise<ApiTypes.Item<NoInfer<D>>>; /** * Create a new record * * Read more: https://www.datocms.com/docs/content-management-api/resources/item/create * * @throws {ApiError} * @throws {TimeoutError} */ rawCreate<D extends ItemTypeDefinition = ItemTypeDefinition>(body: RawApiTypes.ItemCreateSchema<NoInfer<D>>): Promise<RawApiTypes.ItemCreateTargetSchema<NoInfer<D>, true>>; /** * Duplicate a record * * Read more: https://www.datocms.com/docs/content-management-api/resources/item/duplicate * * @throws {ApiError} * @throws {TimeoutError} */ duplicate<D extends ItemTypeDefinition = ItemTypeDefinition>(itemId: string | ApiTypes.ItemData): Promise<ApiTypes.Item<NoInfer<D>>>; /** * Duplicate a record * * Read more: https://www.datocms.com/docs/content-management-api/resources/item/duplicate * * @throws {ApiError} * @throws {TimeoutError} */ rawDuplicate<D extends ItemTypeDefinition = ItemTypeDefinition>(itemId: string): Promise<RawApiTypes.ItemDuplicateJobSchema<NoInfer<D>, true>>; /** * Update a record * * Read more: https://www.datocms.com/docs/content-management-api/resources/item/update * * @throws {ApiError} * @throws {TimeoutError} */ update<D extends ItemTypeDefinition = ItemTypeDefinition>(itemId: string | ApiTypes.ItemData, body: ApiTypes.ItemUpdateSchema<NoInfer<D>>): Promise<ApiTypes.Item<NoInfer<D>>>; /** * Update a record * * Read more: https://www.datocms.com/docs/content-management-api/resources/item/update * * @throws {ApiError} * @throws {TimeoutError} */ rawUpdate<D extends ItemTypeDefinition = ItemTypeDefinition>(itemId: string, body: RawApiTypes.ItemUpdateSchema<NoInfer<D>>): Promise<RawApiTypes.ItemUpdateTargetSchema<NoInfer<D>, true>>; /** * Referenced records * * Read more: https://www.datocms.com/docs/content-management-api/resources/item/references * * @throws {ApiError} * @throws {TimeoutError} */ references<D extends ItemTypeDefinition = ItemTypeDefinition>(itemId: string | ApiTypes.ItemData, queryParams: ApiTypes.ItemReferencesHrefSchema & { nested: true; }): Promise<ApiTypes.ItemReferencesTargetSchema<NoInfer<D>, true>>; references<D extends ItemTypeDefinition = ItemTypeDefinition>(itemId: string | ApiTypes.ItemData, queryParams?: ApiTypes.ItemReferencesHrefSchema & { nested?: false | undefined; }): Promise<ApiTypes.ItemReferencesTargetSchema<NoInfer<D>, false>>; /** * Referenced records * * Read more: https://www.datocms.com/docs/content-management-api/resources/item/references * * @throws {ApiError} * @throws {TimeoutError} */ rawReferences<D extends ItemTypeDefinition = ItemTypeDefinition>(itemId: string, queryParams: RawApiTypes.ItemReferencesHrefSchema & { nested: true; }): Promise<RawApiTypes.ItemReferencesTargetSchema<NoInfer<D>, true>>; rawReferences<D extends ItemTypeDefinition = ItemTypeDefinition>(itemId: string, queryParams?: RawApiTypes.ItemReferencesHrefSchema & { nested?: false | undefined; }): Promise<RawApiTypes.ItemReferencesTargetSchema<NoInfer<D>, false>>; rawReferences<D extends ItemTypeDefinition = ItemTypeDefinition>(itemId: string, queryParams?: RawApiTypes.ItemReferencesHrefSchema): Promise<RawApiTypes.ItemReferencesTargetSchema<NoInfer<D>, true>>; /** * Retrieve a record * * Read more: https://www.datocms.com/docs/content-management-api/resources/item/self * * @throws {ApiError} * @throws {TimeoutError} */ find<D extends ItemTypeDefinition = ItemTypeDefinition>(itemId: string | ApiTypes.ItemData, queryParams: ApiTypes.ItemSelfHrefSchema & { nested: true; }): Promise<ApiTypes.ItemSelfTargetSchema<NoInfer<D>, true>>; find<D extends ItemTypeDefinition = ItemTypeDefinition>(itemId: string | ApiTypes.ItemData, queryParams?: ApiTypes.ItemSelfHrefSchema & { nested?: false | undefined; }): Promise<ApiTypes.ItemSelfTargetSchema<NoInfer<D>, false>>; /** * Retrieve a record * * Read more: https://www.datocms.com/docs/content-management-api/resources/item/self * * @throws {ApiError} * @throws {TimeoutError} */ rawFind<D extends ItemTypeDefinition = ItemTypeDefinition>(itemId: string, queryParams: RawApiTypes.ItemSelfHrefSchema & { nested: true; }): Promise<RawApiTypes.ItemSelfTargetSchema<NoInfer<D>, true>>; rawFind<D extends ItemTypeDefinition = ItemTypeDefinition>(itemId: string, queryParams?: RawApiTypes.ItemSelfHrefSchema & { nested?: false | undefined; }): Promise<RawApiTypes.ItemSelfTargetSchema<NoInfer<D>, false>>; rawFind<D extends ItemTypeDefinition = ItemTypeDefinition>(itemId: string, queryParams?: RawApiTypes.ItemSelfHrefSchema): Promise<RawApiTypes.ItemSelfTargetSchema<NoInfer<D>, true>>; /** * Retrieve information regarding changes between current and published versions of the record * * Read more: https://www.datocms.com/docs/content-management-api/resources/item/current_vs_published_state * * @throws {ApiError} * @throws {TimeoutError} * * @deprecated This API call is to be considered private and might change without notice */ currentVsPublishedState(itemId: string | ApiTypes.ItemData): Promise<ApiTypes.ItemCurrentVsPublishedState>; /** * Retrieve information regarding changes between current and published versions of the record * * Read more: https://www.datocms.com/docs/content-management-api/resources/item/current_vs_published_state * * @throws {ApiError} * @throws {TimeoutError} * * @deprecated This API call is to be considered private and might change without notice */ rawCurrentVsPublishedState(itemId: string): Promise<RawApiTypes.ItemCurrentVsPublishedStateTargetSchema>; /** * Delete a record * * Read more: https://www.datocms.com/docs/content-management-api/resources/item/destroy * * @throws {ApiError} * @throws {TimeoutError} */ destroy<D extends ItemTypeDefinition = ItemTypeDefinition>(itemId: string | ApiTypes.ItemData): Promise<ApiTypes.Item<NoInfer<D>>>; /** * Delete a record * * Read more: https://www.datocms.com/docs/content-management-api/resources/item/destroy * * @throws {ApiError} * @throws {TimeoutError} */ rawDestroy<D extends ItemTypeDefinition = ItemTypeDefinition>(itemId: string): Promise<RawApiTypes.ItemDestroyJobSchema<NoInfer<D>, true>>; /** * Publish a record * * Read more: https://www.datocms.com/docs/content-management-api/resources/item/publish * * @throws {ApiError} * @throws {TimeoutError} */ publish<D extends ItemTypeDefinition = ItemTypeDefinition>(itemId: string | ApiTypes.ItemData, body?: ApiTypes.ItemPublishSchema, queryParams?: ApiTypes.ItemPublishHrefSchema): Promise<ApiTypes.Item<NoInfer<D>>>; /** * Publish a record * * Read more: https://www.datocms.com/docs/content-management-api/resources/item/publish * * @throws {ApiError} * @throws {TimeoutError} */ rawPublish<D extends ItemTypeDefinition = ItemTypeDefinition>(itemId: string, body?: RawApiTypes.ItemPublishSchema, queryParams?: RawApiTypes.ItemPublishHrefSchema): Promise<RawApiTypes.ItemPublishTargetSchema<NoInfer<D>, true>>; /** * Unpublish a record * * Read more: https://www.datocms.com/docs/content-management-api/resources/item/unpublish * * @throws {ApiError} * @throws {TimeoutError} */ unpublish<D extends ItemTypeDefinition = ItemTypeDefinition>(itemId: string | ApiTypes.ItemData, body?: ApiTypes.ItemUnpublishSchema, queryParams?: ApiTypes.ItemUnpublishHrefSchema): Promise<ApiTypes.Item<NoInfer<D>>>; /** * Unpublish a record * * Read more: https://www.datocms.com/docs/content-management-api/resources/item/unpublish * * @throws {ApiError} * @throws {TimeoutError} */ rawUnpublish<D extends ItemTypeDefinition = ItemTypeDefinition>(itemId: string, body?: RawApiTypes.ItemUnpublishSchema, queryParams?: RawApiTypes.ItemUnpublishHrefSchema): Promise<RawApiTypes.ItemUnpublishTargetSchema<NoInfer<D>, true>>; /** * Publish items in bulk * * Read more: https://www.datocms.com/docs/content-management-api/resources/item/bulk_publish * * @throws {ApiError} * @throws {TimeoutError} */ bulkPublish(body: ApiTypes.ItemBulkPublishSchema): Promise<ApiTypes.ItemBulkPublishJobSchema>; /** * Publish items in bulk * * Read more: https://www.datocms.com/docs/content-management-api/resources/item/bulk_publish * * @throws {ApiError} * @throws {TimeoutError} */ rawBulkPublish(body: RawApiTypes.ItemBulkPublishSchema): Promise<RawApiTypes.ItemBulkPublishJobSchema>; /** * Unpublish items in bulk * * Read more: https://www.datocms.com/docs/content-management-api/resources/item/bulk_unpublish * * @throws {ApiError} * @throws {TimeoutError} */ bulkUnpublish(body: ApiTypes.ItemBulkUnpublishSchema): Promise<ApiTypes.ItemBulkUnpublishJobSchema>; /** * Unpublish items in bulk * * Read more: https://www.datocms.com/docs/content-management-api/resources/item/bulk_unpublish * * @throws {ApiError} * @throws {TimeoutError} */ rawBulkUnpublish(body: RawApiTypes.ItemBulkUnpublishSchema): Promise<RawApiTypes.ItemBulkUnpublishJobSchema>; /** * Destroy items in bulk * * Read more: https://www.datocms.com/docs/content-management-api/resources/item/bulk_destroy * * @throws {ApiError} * @throws {TimeoutError} */ bulkDestroy(body: ApiTypes.ItemBulkDestroySchema): Promise<ApiTypes.ItemBulkDestroyJobSchema>; /** * Destroy items in bulk * * Read more: https://www.datocms.com/docs/content-management-api/resources/item/bulk_destroy * * @throws {ApiError} * @throws {TimeoutError} */ rawBulkDestroy(body: RawApiTypes.ItemBulkDestroySchema): Promise<RawApiTypes.ItemBulkDestroyJobSchema>; /** * Move items to stage in bulk * * Read more: https://www.datocms.com/docs/content-management-api/resources/item/bulk_move_to_stage * * @throws {ApiError} * @throws {TimeoutError} */ bulkMoveToStage(body: ApiTypes.ItemBulkMoveToStageSchema): Promise<ApiTypes.ItemBulkMoveToStageJobSchema>; /** * Move items to stage in bulk * * Read more: https://www.datocms.com/docs/content-management-api/resources/item/bulk_move_to_stage * * @throws {ApiError} * @throws {TimeoutError} */ rawBulkMoveToStage(body: RawApiTypes.ItemBulkMoveToStageSchema): Promise<RawApiTypes.ItemBulkMoveToStageJobSchema>; } export {};