@storyblok/management-api-client 1.0.0-alpha.2 → 1.0.0-alpha.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -1,9 +1,8 @@
1
1
  import { AssetUpdateRequest, CreateAsset, SpaceDetail } from "./generated/mapi/types.gen.mjs";
2
- import { Asset, AssetCreate, AssetFolder, AssetFolderCreate, AssetFolderUpdate, AssetUpdate, ComponentFolder, ComponentFolderCreate, ComponentFolderUpdate, DatasourceCreate, DatasourceUpdate, InternalTag, InternalTagCreate, InternalTagUpdate, MapiDatasource, MapiDatasourceEntry, Preset, PresetCreate, PresetUpdate, Space, SpaceCreate, SpaceUpdate, StoryLocalizedPath, StoryTranslatedSlug, User, UserUpdate } from "./generated/mapi/types-aliased.gen.mjs";
2
+ import { Asset, AssetCreate, AssetFolder, AssetFolderCreate, AssetFolderUpdate, AssetUpdate, Component, ComponentCreate, ComponentFolder, ComponentFolderCreate, ComponentFolderUpdate, ComponentUpdate, DatasourceCreate, DatasourceUpdate, InternalTag, InternalTagCreate, InternalTagUpdate, MapiDatasource, MapiDatasourceEntry, Preset, PresetCreate, PresetUpdate, Space, SpaceCreate, SpaceUpdate, StoryLocalizedPath, StoryTranslatedSlug, User, UserUpdate } from "./generated/mapi/types-aliased.gen.mjs";
3
3
  import { AssetCreate as AssetCreate$1, AssetListQuery } from "./resources/assets.mjs";
4
- import { ComponentCreate, ComponentUpdate } from "./generated/mapi/_internal.gen.mjs";
5
4
  import { AssetFieldValue, Field, MultilinkFieldValue, PluginFieldValue, RichtextFieldValue, TableFieldValue } from "./generated/overlay/_internal.gen.mjs";
6
- import { Block, RootBlock } from "./generated/types/block.mjs";
5
+ import { RootBlock } from "./generated/types/block.mjs";
7
6
  import { ApiErrorBody, ClientError } from "./error.mjs";
8
7
  import { RateLimitConfig } from "./utils/rate-limit.mjs";
9
8
  import { BlockContent, BlockContentInput, BlocksFieldValue } from "./generated/types/field.mjs";
@@ -12,4 +11,4 @@ import { StoryListQuery } from "./resources/stories.mjs";
12
11
  import { ApiResponse, FetchOptions, HttpRequestOptions, ManagementApiClient, ManagementApiClientConfig, MapiResourceDeps, RequestConfigOverrides, createManagementApiClient } from "./client.mjs";
13
12
  import { SpaceCreateQuery } from "./resources/spaces.mjs";
14
13
  import { normalizeAssetUrl } from "./utils/normalize-asset-url.mjs";
15
- export { type ApiErrorBody, type ApiResponse, type Asset, type AssetCreate, type AssetFieldValue, type AssetFolder, type AssetFolderCreate, type AssetFolderUpdate, type AssetListQuery, type AssetUpdate, type AssetUpdateRequest, type AssetCreate$1 as AssetUploadRequest, type BlockContent as BlokContent, type BlockContentInput as BlokContentInput, type BlocksFieldValue as BloksFieldValue, ClientError, type Block as Component, type ComponentCreate, type ComponentFolder, type ComponentFolderCreate, type ComponentFolderUpdate, type ComponentUpdate, type MapiDatasource as Datasource, type DatasourceCreate, type MapiDatasourceEntry as DatasourceEntry, type DatasourceUpdate, type FetchOptions, type Field, type HttpRequestOptions, type InternalTag, type InternalTagCreate, type InternalTagUpdate, type ManagementApiClient, type ManagementApiClientConfig, type MapiResourceDeps, type MultilinkFieldValue, type PluginFieldValue, type Preset, type PresetCreate, type PresetUpdate, type RateLimitConfig, type RequestConfigOverrides, type RichtextFieldValue, type RootBlock as RootComponents, type CreateAsset as SignedResponseObject, type Space, type SpaceCreate, type SpaceCreateQuery, type SpaceDetail, type SpaceUpdate, type MapiStory as Story, type StoryCreate, type StoryListQuery, type StoryLocalizedPath, type StoryTranslatedSlug, type StoryUpdate, type TableFieldValue, type User, type UserUpdate, createManagementApiClient, normalizeAssetUrl };
14
+ export { type ApiErrorBody, type ApiResponse, type Asset, type AssetCreate, type AssetFieldValue, type AssetFolder, type AssetFolderCreate, type AssetFolderUpdate, type AssetListQuery, type AssetUpdate, type AssetUpdateRequest, type AssetCreate$1 as AssetUploadRequest, type BlockContent as BlokContent, type BlockContentInput as BlokContentInput, type BlocksFieldValue as BloksFieldValue, ClientError, type Component, type ComponentCreate, type ComponentFolder, type ComponentFolderCreate, type ComponentFolderUpdate, type ComponentUpdate, type MapiDatasource as Datasource, type DatasourceCreate, type MapiDatasourceEntry as DatasourceEntry, type DatasourceUpdate, type FetchOptions, type Field, type HttpRequestOptions, type InternalTag, type InternalTagCreate, type InternalTagUpdate, type ManagementApiClient, type ManagementApiClientConfig, type MapiResourceDeps, type MultilinkFieldValue, type PluginFieldValue, type Preset, type PresetCreate, type PresetUpdate, type RateLimitConfig, type RequestConfigOverrides, type RichtextFieldValue, type RootBlock as RootComponents, type CreateAsset as SignedResponseObject, type Space, type SpaceCreate, type SpaceCreateQuery, type SpaceDetail, type SpaceUpdate, type MapiStory as Story, type StoryCreate, type StoryListQuery, type StoryLocalizedPath, type StoryTranslatedSlug, type StoryUpdate, type TableFieldValue, type User, type UserUpdate, createManagementApiClient, normalizeAssetUrl };
@@ -1 +1 @@
1
- {"version":3,"file":"components.cjs","names":["resolveSpaceId"],"sources":["../../src/resources/components.ts"],"sourcesContent":["import * as mapi from '../generated/mapi/sdk.gen';\nimport type {\n CreateComponentData,\n CreateComponentResponses,\n DeleteComponentResponses,\n GetComponentResponses,\n GetComponentVersionData,\n GetComponentVersionResponses,\n ListManagementComponentsData,\n ListManagementComponentsResponses,\n ListVersionsData,\n ListVersionsResponses,\n RestoreComponentResponses,\n RestoreVersionData,\n RestoreVersionResponses,\n UpdateComponentData,\n UpdateComponentResponses,\n} from '../generated/mapi/types.gen';\nimport type { Block as Component } from '../generated/types/block';\nimport type { ApiResponse, FetchOptions, MapiResourceDeps } from '../client';\nimport { resolveSpaceId, type SpaceIdPathOverride } from './shared';\n\n// Surface the wrapper `Component` (= `Block`) on responses instead of the raw\n// generated component, so consumers get the schema-aware public type. Narrowed\n// to `TComponents` when the client is parameterised via `.withTypes()`.\ntype ListComponentsResult<TComponents extends Component> = Omit<ListManagementComponentsResponses[200], 'components'> & { components: TComponents[] };\ntype GetComponentResult<TComponents extends Component> = Omit<GetComponentResponses[200], 'component'> & { component: TComponents };\ntype CreateComponentResult<TComponents extends Component> = Omit<CreateComponentResponses[201], 'component'> & { component: TComponents };\ntype UpdateComponentResult<TComponents extends Component> = Omit<UpdateComponentResponses[200], 'component'> & { component: TComponents };\ntype RestoreComponentResult<TComponents extends Component> = Omit<RestoreComponentResponses[200], 'component'> & { component: TComponents };\n\nexport function createComponentsResource<\n TComponents extends Component = Component,\n DefaultThrowOnError extends boolean = false,\n>(deps: MapiResourceDeps<DefaultThrowOnError>) {\n const { client, spaceId, wrapRequest } = deps;\n const getSpaceId = (path?: SpaceIdPathOverride['path']) => resolveSpaceId(spaceId, path);\n\n return {\n list<ThrowOnError extends boolean = DefaultThrowOnError>(options: { query?: ListManagementComponentsData['query']; signal?: AbortSignal; throwOnError?: ThrowOnError; fetchOptions?: FetchOptions } & SpaceIdPathOverride = {}): Promise<ApiResponse<ListComponentsResult<TComponents>, ThrowOnError>> {\n const { query, signal, path, throwOnError, fetchOptions } = options;\n const resolvedSpaceId = getSpaceId(path);\n return wrapRequest<ListComponentsResult<TComponents>, ThrowOnError>(() =>\n mapi.listManagementComponents({ client, path: { space_id: resolvedSpaceId }, query, signal, ...(throwOnError === undefined ? {} : { throwOnError }), ...(fetchOptions ? { kyOptions: { ...client.getConfig().kyOptions, ...fetchOptions } } : {}) }), throwOnError);\n },\n get<ThrowOnError extends boolean = DefaultThrowOnError>(componentId: number, options: { signal?: AbortSignal; throwOnError?: ThrowOnError; fetchOptions?: FetchOptions } & SpaceIdPathOverride = {}): Promise<ApiResponse<GetComponentResult<TComponents>, ThrowOnError>> {\n const { signal, path, throwOnError, fetchOptions } = options;\n const resolvedSpaceId = getSpaceId(path);\n return wrapRequest<GetComponentResult<TComponents>, ThrowOnError>(() =>\n mapi.getComponent({ client, path: { space_id: resolvedSpaceId, id: String(componentId) }, signal, ...(throwOnError === undefined ? {} : { throwOnError }), ...(fetchOptions ? { kyOptions: { ...client.getConfig().kyOptions, ...fetchOptions } } : {}) }), throwOnError);\n },\n create<ThrowOnError extends boolean = DefaultThrowOnError>(options: { body: CreateComponentData['body']; signal?: AbortSignal; throwOnError?: ThrowOnError; fetchOptions?: FetchOptions } & SpaceIdPathOverride): Promise<ApiResponse<CreateComponentResult<TComponents>, ThrowOnError>> {\n const { body, signal, path, throwOnError, fetchOptions } = options;\n const resolvedSpaceId = getSpaceId(path);\n return wrapRequest<CreateComponentResult<TComponents>, ThrowOnError>(() =>\n mapi.createComponent({ client, path: { space_id: resolvedSpaceId }, body, signal, ...(throwOnError === undefined ? {} : { throwOnError }), ...(fetchOptions ? { kyOptions: { ...client.getConfig().kyOptions, ...fetchOptions } } : {}) }), throwOnError);\n },\n update<ThrowOnError extends boolean = DefaultThrowOnError>(\n componentId: number,\n options: { body: UpdateComponentData['body']; signal?: AbortSignal; throwOnError?: ThrowOnError; fetchOptions?: FetchOptions } & SpaceIdPathOverride,\n ): Promise<ApiResponse<UpdateComponentResult<TComponents>, ThrowOnError>> {\n const { body, signal, path, throwOnError, fetchOptions } = options;\n const resolvedSpaceId = getSpaceId(path);\n return wrapRequest<UpdateComponentResult<TComponents>, ThrowOnError>(() =>\n mapi.updateComponent({ client, path: { space_id: resolvedSpaceId, id: String(componentId) }, body, signal, ...(throwOnError === undefined ? {} : { throwOnError }), ...(fetchOptions ? { kyOptions: { ...client.getConfig().kyOptions, ...fetchOptions } } : {}) }), throwOnError);\n },\n delete<ThrowOnError extends boolean = DefaultThrowOnError>(componentId: number, options: { signal?: AbortSignal; throwOnError?: ThrowOnError; fetchOptions?: FetchOptions } & SpaceIdPathOverride = {}): Promise<ApiResponse<DeleteComponentResponses[200], ThrowOnError>> {\n const { signal, path, throwOnError, fetchOptions } = options;\n const resolvedSpaceId = getSpaceId(path);\n return wrapRequest<DeleteComponentResponses[200], ThrowOnError>(() =>\n mapi.deleteComponent({ client, path: { space_id: resolvedSpaceId, id: String(componentId) }, signal, ...(throwOnError === undefined ? {} : { throwOnError }), ...(fetchOptions ? { kyOptions: { ...client.getConfig().kyOptions, ...fetchOptions } } : {}) }), throwOnError);\n },\n restore<ThrowOnError extends boolean = DefaultThrowOnError>(componentId: number, options: { signal?: AbortSignal; throwOnError?: ThrowOnError; fetchOptions?: FetchOptions } & SpaceIdPathOverride = {}): Promise<ApiResponse<RestoreComponentResult<TComponents>, ThrowOnError>> {\n const { signal, path, throwOnError, fetchOptions } = options;\n const resolvedSpaceId = getSpaceId(path);\n return wrapRequest<RestoreComponentResult<TComponents>, ThrowOnError>(() =>\n mapi.restoreComponent({ client, path: { space_id: resolvedSpaceId, id: componentId }, signal, ...(throwOnError === undefined ? {} : { throwOnError }), ...(fetchOptions ? { kyOptions: { ...client.getConfig().kyOptions, ...fetchOptions } } : {}) }), throwOnError);\n },\n versions<ThrowOnError extends boolean = DefaultThrowOnError>(\n componentId: number,\n options: { query?: Omit<ListVersionsData['query'], 'model' | 'model_id'>; signal?: AbortSignal; throwOnError?: ThrowOnError; fetchOptions?: FetchOptions } & SpaceIdPathOverride = {},\n ): Promise<ApiResponse<ListVersionsResponses[200], ThrowOnError>> {\n const { query, signal, path, throwOnError, fetchOptions } = options;\n const resolvedSpaceId = getSpaceId(path);\n return wrapRequest<ListVersionsResponses[200], ThrowOnError>(() =>\n mapi.listVersions({ client, path: { space_id: resolvedSpaceId }, query: { ...query, model: 'components', model_id: componentId }, signal, ...(throwOnError === undefined ? {} : { throwOnError }), ...(fetchOptions ? { kyOptions: { ...client.getConfig().kyOptions, ...fetchOptions } } : {}) }), throwOnError);\n },\n version<ThrowOnError extends boolean = DefaultThrowOnError>(\n componentId: number,\n versionId: GetComponentVersionData['path']['id'],\n options: { signal?: AbortSignal; throwOnError?: ThrowOnError; fetchOptions?: FetchOptions } & SpaceIdPathOverride = {},\n ): Promise<ApiResponse<GetComponentVersionResponses[200], ThrowOnError>> {\n const { signal, path, throwOnError, fetchOptions } = options;\n const resolvedSpaceId = getSpaceId(path);\n return wrapRequest<GetComponentVersionResponses[200], ThrowOnError>(() =>\n mapi.getComponentVersion({\n client,\n path: { space_id: resolvedSpaceId, component_id: componentId, id: versionId },\n signal,\n ...(throwOnError === undefined ? {} : { throwOnError }),\n ...(fetchOptions ? { kyOptions: { ...client.getConfig().kyOptions, ...fetchOptions } } : {}),\n }), throwOnError);\n },\n restoreVersion<ThrowOnError extends boolean = DefaultThrowOnError>(\n componentId: number,\n versionId: RestoreVersionData['path']['id'],\n options: { query?: Omit<RestoreVersionData['query'], 'model' | 'model_id'>; signal?: AbortSignal; throwOnError?: ThrowOnError; fetchOptions?: FetchOptions } & SpaceIdPathOverride = {},\n ): Promise<ApiResponse<RestoreVersionResponses[204], ThrowOnError>> {\n const { query, signal, path, throwOnError, fetchOptions } = options;\n const resolvedSpaceId = getSpaceId(path);\n return wrapRequest<RestoreVersionResponses[204], ThrowOnError>(() =>\n mapi.restoreVersion({ client, path: { space_id: resolvedSpaceId, id: versionId }, query: { ...query, model: 'components', model_id: componentId }, signal, ...(throwOnError === undefined ? {} : { throwOnError }), ...(fetchOptions ? { kyOptions: { ...client.getConfig().kyOptions, ...fetchOptions } } : {}) }), throwOnError);\n },\n };\n}\n"],"mappings":";;;;AA+BA,SAAgB,yBAGd,MAA6C;CAC7C,MAAM,EAAE,QAAQ,SAAS,gBAAgB;CACzC,MAAM,cAAc,SAAuCA,8BAAe,SAAS,KAAK;AAExF,QAAO;EACL,KAAyD,UAAmK,EAAE,EAAyE;GACrS,MAAM,EAAE,OAAO,QAAQ,MAAM,cAAc,iBAAiB;GAC5D,MAAM,kBAAkB,WAAW,KAAK;AACxC,UAAO,2DACyB;IAAE;IAAQ,MAAM,EAAE,UAAU,iBAAiB;IAAE;IAAO;IAAQ,GAAI,iBAAiB,SAAY,EAAE,GAAG,EAAE,cAAc;IAAG,GAAI,eAAe,EAAE,WAAW;KAAE,GAAG,OAAO,WAAW,CAAC;KAAW,GAAG;KAAc,EAAE,GAAG,EAAE;IAAG,CAAC,EAAE,aAAa;;EAEvQ,IAAwD,aAAqB,UAAoH,EAAE,EAAu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Y,EAAE,GAAG,EAAE,cAAc;IACtD,GAAI,eAAe,EAAE,WAAW;KAAE,GAAG,OAAO,WAAW,CAAC;KAAW,GAAG;KAAc,EAAE,GAAG,EAAE;IAC5F,CAAC,EAAE,aAAa;;EAErB,eACE,aACA,WACA,UAAqL,EAAE,EACrH;GAClE,MAAM,EAAE,OAAO,QAAQ,MAAM,cAAc,iBAAiB;GAC5D,MAAM,kBAAkB,WAAW,KAAK;AACxC,UAAO,iDACe;IAAE;IAAQ,MAAM;KAAE,UAAU;KAAiB,IAAI;KAAW;IAAE,OAAO;KAAE,GAAG;KAAO,OAAO;KAAc,UAAU;KAAa;IAAE;IAAQ,GAAI,iBAAiB,SAAY,EAAE,GAAG,EAAE,cAAc;IAAG,GAAI,eAAe,EAAE,WAAW;KAAE,GAAG,OAAO,WAAW,CAAC;KAAW,GAAG;KAAc,EAAE,GAAG,EAAE;IAAG,CAAC,EAAE,aAAa;;EAEvU"}
1
+ {"version":3,"file":"components.cjs","names":["resolveSpaceId"],"sources":["../../src/resources/components.ts"],"sourcesContent":["import * as mapi from '../generated/mapi/sdk.gen';\nimport type {\n CreateComponentData,\n CreateComponentResponses,\n DeleteComponentResponses,\n GetComponentResponses,\n GetComponentVersionData,\n GetComponentVersionResponses,\n ListManagementComponentsData,\n ListManagementComponentsResponses,\n ListVersionsData,\n ListVersionsResponses,\n RestoreComponentResponses,\n RestoreVersionData,\n RestoreVersionResponses,\n UpdateComponentData,\n UpdateComponentResponses,\n} from '../generated/mapi/types.gen';\nimport type { Component } from '../generated/mapi/types-aliased.gen';\nimport type { ApiResponse, FetchOptions, MapiResourceDeps } from '../client';\nimport { resolveSpaceId, type SpaceIdPathOverride } from './shared';\n\n// Component definitions are MAPI wire shapes (a `schema` record), surfaced as the\n// public `Component`. This is distinct from the DSL `fields` blocks used to narrow\n// story content via `.withTypes()` — definitions are not parameterised by the block\n// registry.\ntype ListComponentsResult = Omit<ListManagementComponentsResponses[200], 'components'> & { components: Component[] };\ntype GetComponentResult = Omit<GetComponentResponses[200], 'component'> & { component: Component };\ntype CreateComponentResult = Omit<CreateComponentResponses[201], 'component'> & { component: Component };\ntype UpdateComponentResult = Omit<UpdateComponentResponses[200], 'component'> & { component: Component };\ntype RestoreComponentResult = Omit<RestoreComponentResponses[200], 'component'> & { component: Component };\n\nexport function createComponentsResource<\n DefaultThrowOnError extends boolean = false,\n>(deps: MapiResourceDeps<DefaultThrowOnError>) {\n const { client, spaceId, wrapRequest } = deps;\n const getSpaceId = (path?: SpaceIdPathOverride['path']) => resolveSpaceId(spaceId, path);\n\n return {\n list<ThrowOnError extends boolean = DefaultThrowOnError>(options: { query?: ListManagementComponentsData['query']; signal?: AbortSignal; throwOnError?: ThrowOnError; fetchOptions?: FetchOptions } & SpaceIdPathOverride = {}): Promise<ApiResponse<ListComponentsResult, ThrowOnError>> {\n const { query, signal, path, throwOnError, fetchOptions } = options;\n const resolvedSpaceId = getSpaceId(path);\n return wrapRequest<ListComponentsResult, ThrowOnError>(() =>\n mapi.listManagementComponents({ client, path: { space_id: resolvedSpaceId }, query, signal, ...(throwOnError === undefined ? {} : { throwOnError }), ...(fetchOptions ? { kyOptions: { ...client.getConfig().kyOptions, ...fetchOptions } } : {}) }), throwOnError);\n },\n get<ThrowOnError extends boolean = DefaultThrowOnError>(componentId: number, options: { signal?: AbortSignal; throwOnError?: ThrowOnError; fetchOptions?: FetchOptions } & SpaceIdPathOverride = {}): Promise<ApiResponse<GetComponentResult, ThrowOnError>> {\n const { signal, path, throwOnError, fetchOptions } = options;\n const resolvedSpaceId = getSpaceId(path);\n return wrapRequest<GetComponentResult, ThrowOnError>(() =>\n mapi.getComponent({ client, path: { space_id: resolvedSpaceId, id: String(componentId) }, signal, ...(throwOnError === undefined ? {} : { throwOnError }), ...(fetchOptions ? { kyOptions: { ...client.getConfig().kyOptions, ...fetchOptions } } : {}) }), throwOnError);\n },\n create<ThrowOnError extends boolean = DefaultThrowOnError>(options: { body: CreateComponentData['body']; signal?: AbortSignal; throwOnError?: ThrowOnError; fetchOptions?: FetchOptions } & SpaceIdPathOverride): Promise<ApiResponse<CreateComponentResult, ThrowOnError>> {\n const { body, signal, path, throwOnError, fetchOptions } = options;\n const resolvedSpaceId = getSpaceId(path);\n return wrapRequest<CreateComponentResult, ThrowOnError>(() =>\n mapi.createComponent({ client, path: { space_id: resolvedSpaceId }, body, signal, ...(throwOnError === undefined ? {} : { throwOnError }), ...(fetchOptions ? { kyOptions: { ...client.getConfig().kyOptions, ...fetchOptions } } : {}) }), throwOnError);\n },\n update<ThrowOnError extends boolean = DefaultThrowOnError>(\n componentId: number,\n options: { body: UpdateComponentData['body']; signal?: AbortSignal; throwOnError?: ThrowOnError; fetchOptions?: FetchOptions } & SpaceIdPathOverride,\n ): Promise<ApiResponse<UpdateComponentResult, ThrowOnError>> {\n const { body, signal, path, throwOnError, fetchOptions } = options;\n const resolvedSpaceId = getSpaceId(path);\n return wrapRequest<UpdateComponentResult, ThrowOnError>(() =>\n mapi.updateComponent({ client, path: { space_id: resolvedSpaceId, id: String(componentId) }, body, signal, ...(throwOnError === undefined ? {} : { throwOnError }), ...(fetchOptions ? { kyOptions: { ...client.getConfig().kyOptions, ...fetchOptions } } : {}) }), throwOnError);\n },\n delete<ThrowOnError extends boolean = DefaultThrowOnError>(componentId: number, options: { signal?: AbortSignal; throwOnError?: ThrowOnError; fetchOptions?: FetchOptions } & SpaceIdPathOverride = {}): Promise<ApiResponse<DeleteComponentResponses[200], ThrowOnError>> {\n const { signal, path, throwOnError, fetchOptions } = options;\n const resolvedSpaceId = getSpaceId(path);\n return wrapRequest<DeleteComponentResponses[200], ThrowOnError>(() =>\n mapi.deleteComponent({ client, path: { space_id: resolvedSpaceId, id: String(componentId) }, signal, ...(throwOnError === undefined ? {} : { throwOnError }), ...(fetchOptions ? { kyOptions: { ...client.getConfig().kyOptions, ...fetchOptions } } : {}) }), throwOnError);\n },\n restore<ThrowOnError extends boolean = DefaultThrowOnError>(componentId: number, options: { signal?: AbortSignal; throwOnError?: ThrowOnError; fetchOptions?: FetchOptions } & SpaceIdPathOverride = {}): Promise<ApiResponse<RestoreComponentResult, ThrowOnError>> {\n const { signal, path, throwOnError, fetchOptions } = options;\n const resolvedSpaceId = getSpaceId(path);\n return wrapRequest<RestoreComponentResult, ThrowOnError>(() =>\n mapi.restoreComponent({ client, path: { space_id: resolvedSpaceId, id: componentId }, signal, ...(throwOnError === undefined ? {} : { throwOnError }), ...(fetchOptions ? { kyOptions: { ...client.getConfig().kyOptions, ...fetchOptions } } : {}) }), throwOnError);\n },\n versions<ThrowOnError extends boolean = DefaultThrowOnError>(\n componentId: number,\n options: { query?: Omit<ListVersionsData['query'], 'model' | 'model_id'>; signal?: AbortSignal; throwOnError?: ThrowOnError; fetchOptions?: FetchOptions } & SpaceIdPathOverride = {},\n ): Promise<ApiResponse<ListVersionsResponses[200], ThrowOnError>> {\n const { query, signal, path, throwOnError, fetchOptions } = options;\n const resolvedSpaceId = getSpaceId(path);\n return wrapRequest<ListVersionsResponses[200], ThrowOnError>(() =>\n mapi.listVersions({ client, path: { space_id: resolvedSpaceId }, query: { ...query, model: 'components', model_id: componentId }, signal, ...(throwOnError === undefined ? {} : { throwOnError }), ...(fetchOptions ? { kyOptions: { ...client.getConfig().kyOptions, ...fetchOptions } } : {}) }), throwOnError);\n },\n version<ThrowOnError extends boolean = DefaultThrowOnError>(\n componentId: number,\n versionId: GetComponentVersionData['path']['id'],\n options: { signal?: AbortSignal; throwOnError?: ThrowOnError; fetchOptions?: FetchOptions } & SpaceIdPathOverride = {},\n ): Promise<ApiResponse<GetComponentVersionResponses[200], ThrowOnError>> {\n const { signal, path, throwOnError, fetchOptions } = options;\n const resolvedSpaceId = getSpaceId(path);\n return wrapRequest<GetComponentVersionResponses[200], ThrowOnError>(() =>\n mapi.getComponentVersion({\n client,\n path: { space_id: resolvedSpaceId, component_id: componentId, id: versionId },\n signal,\n ...(throwOnError === undefined ? {} : { throwOnError }),\n ...(fetchOptions ? { kyOptions: { ...client.getConfig().kyOptions, ...fetchOptions } } : {}),\n }), throwOnError);\n },\n restoreVersion<ThrowOnError extends boolean = DefaultThrowOnError>(\n componentId: number,\n versionId: RestoreVersionData['path']['id'],\n options: { query?: Omit<RestoreVersionData['query'], 'model' | 'model_id'>; signal?: AbortSignal; throwOnError?: ThrowOnError; fetchOptions?: FetchOptions } & SpaceIdPathOverride = {},\n ): Promise<ApiResponse<RestoreVersionResponses[204], ThrowOnError>> {\n const { query, signal, path, throwOnError, fetchOptions } = options;\n const resolvedSpaceId = getSpaceId(path);\n return wrapRequest<RestoreVersionResponses[204], ThrowOnError>(() =>\n mapi.restoreVersion({ client, path: { space_id: resolvedSpaceId, id: versionId }, query: { ...query, model: 'components', model_id: componentId }, signal, ...(throwOnError === undefined ? {} : { throwOnError }), ...(fetchOptions ? { kyOptions: { ...client.getConfig().kyOptions, ...fetchOptions } } : {}) }), throwOnError);\n },\n };\n}\n"],"mappings":";;;;AAgCA,SAAgB,yBAEd,MAA6C;CAC7C,MAAM,EAAE,QAAQ,SAAS,gBAAgB;CACzC,MAAM,cAAc,SAAuCA,8BAAe,SAAS,KAAK;AAExF,QAAO;EACL,KAAyD,UAAmK,EAAE,EAA4D;GACxR,MAAM,EAAE,OAAO,QAAQ,MAAM,cAAc,iBAAiB;GAC5D,MAAM,kBAAkB,WAAW,KAAK;AACxC,UAAO,2DACyB;IAAE;IAAQ,MAAM,EAAE,UAAU,iBAAiB;IAAE;IAAO;IAAQ,GAAI,iBAAiB,SAAY,EAAE,GAAG,EAAE,cAAc;IAAG,GAAI,eAAe,EAAE,WAAW;KAAE,GAAG,OAAO,WAAW,CAAC;KAAW,GAAG;KAAc,EAAE,GAAG,EAAE;IAAG,CAAC,EAAE,aAAa;;EAEvQ,IAAwD,aAAqB,UAAoH,EAAE,EAA0D;GAC3P,MAAM,EAAE,QAAQ,MAAM,cAAc,iBAAiB;GACrD,MAAM,kBAAkB,WAAW,KAAK;AACxC,UAAO,+CACa;IAAE;IAAQ,MAAM;KAA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EAAE;IAC5F,CAAC,EAAE,aAAa;;EAErB,eACE,aACA,WACA,UAAqL,EAAE,EACrH;GAClE,MAAM,EAAE,OAAO,QAAQ,MAAM,cAAc,iBAAiB;GAC5D,MAAM,kBAAkB,WAAW,KAAK;AACxC,UAAO,iDACe;IAAE;IAAQ,MAAM;KAAE,UAAU;KAAiB,IAAI;KAAW;IAAE,OAAO;KAAE,GAAG;KAAO,OAAO;KAAc,UAAU;KAAa;IAAE;IAAQ,GAAI,iBAAiB,SAAY,EAAE,GAAG,EAAE,cAAc;IAAG,GAAI,eAAe,EAAE,WAAW;KAAE,GAAG,OAAO,WAAW,CAAC;KAAW,GAAG;KAAc,EAAE,GAAG,EAAE;IAAG,CAAC,EAAE,aAAa;;EAEvU"}
@@ -1,48 +1,48 @@
1
1
  import { CreateComponentData, CreateComponentResponses, DeleteComponentResponses, GetComponentResponses, GetComponentVersionData, GetComponentVersionResponses, ListManagementComponentsData, ListManagementComponentsResponses, ListVersionsData, ListVersionsResponses, RestoreComponentResponses, RestoreVersionData, RestoreVersionResponses, UpdateComponentData, UpdateComponentResponses } from "../generated/mapi/types.gen.cjs";
2
2
  import { SpaceIdPathOverride } from "./shared.cjs";
3
- import { Block } from "../generated/types/block.cjs";
3
+ import { Component } from "../generated/mapi/types-aliased.gen.cjs";
4
4
  import { ApiResponse, FetchOptions, MapiResourceDeps } from "../client.cjs";
5
5
 
6
6
  //#region src/resources/components.d.ts
7
- type ListComponentsResult<TComponents extends Block> = Omit<ListManagementComponentsResponses[200], 'components'> & {
8
- components: TComponents[];
7
+ type ListComponentsResult = Omit<ListManagementComponentsResponses[200], 'components'> & {
8
+ components: Component[];
9
9
  };
10
- type GetComponentResult<TComponents extends Block> = Omit<GetComponentResponses[200], 'component'> & {
11
- component: TComponents;
10
+ type GetComponentResult = Omit<GetComponentResponses[200], 'component'> & {
11
+ component: Component;
12
12
  };
13
- type CreateComponentResult<TComponents extends Block> = Omit<CreateComponentResponses[201], 'component'> & {
14
- component: TComponents;
13
+ type CreateComponentResult = Omit<CreateComponentResponses[201], 'component'> & {
14
+ component: Component;
15
15
  };
16
- type UpdateComponentResult<TComponents extends Block> = Omit<UpdateComponentResponses[200], 'component'> & {
17
- component: TComponents;
16
+ type UpdateComponentResult = Omit<UpdateComponentResponses[200], 'component'> & {
17
+ component: Component;
18
18
  };
19
- type RestoreComponentResult<TComponents extends Block> = Omit<RestoreComponentResponses[200], 'component'> & {
20
- component: TComponents;
19
+ type RestoreComponentResult = Omit<RestoreComponentResponses[200], 'component'> & {
20
+ component: Component;
21
21
  };
22
- declare function createComponentsResource<TComponents extends Block = Block, DefaultThrowOnError extends boolean = false>(deps: MapiResourceDeps<DefaultThrowOnError>): {
22
+ declare function createComponentsResource<DefaultThrowOnError extends boolean = false>(deps: MapiResourceDeps<DefaultThrowOnError>): {
23
23
  list<ThrowOnError extends boolean = DefaultThrowOnError>(options?: {
24
24
  query?: ListManagementComponentsData["query"];
25
25
  signal?: AbortSignal;
26
26
  throwOnError?: ThrowOnError;
27
27
  fetchOptions?: FetchOptions;
28
- } & SpaceIdPathOverride): Promise<ApiResponse<ListComponentsResult<TComponents>, ThrowOnError>>;
28
+ } & SpaceIdPathOverride): Promise<ApiResponse<ListComponentsResult, ThrowOnError>>;
29
29
  get<ThrowOnError extends boolean = DefaultThrowOnError>(componentId: number, options?: {
30
30
  signal?: AbortSignal;
31
31
  throwOnError?: ThrowOnError;
32
32
  fetchOptions?: FetchOptions;
33
- } & SpaceIdPathOverride): Promise<ApiResponse<GetComponentResult<TComponents>, ThrowOnError>>;
33
+ } & SpaceIdPathOverride): Promise<ApiResponse<GetComponentResult, ThrowOnError>>;
34
34
  create<ThrowOnError extends boolean = DefaultThrowOnError>(options: {
35
35
  body: CreateComponentData["body"];
36
36
  signal?: AbortSignal;
37
37
  throwOnError?: ThrowOnError;
38
38
  fetchOptions?: FetchOptions;
39
- } & SpaceIdPathOverride): Promise<ApiResponse<CreateComponentResult<TComponents>, ThrowOnError>>;
39
+ } & SpaceIdPathOverride): Promise<ApiResponse<CreateComponentResult, ThrowOnError>>;
40
40
  update<ThrowOnError extends boolean = DefaultThrowOnError>(componentId: number, options: {
41
41
  body: UpdateComponentData["body"];
42
42
  signal?: AbortSignal;
43
43
  throwOnError?: ThrowOnError;
44
44
  fetchOptions?: FetchOptions;
45
- } & SpaceIdPathOverride): Promise<ApiResponse<UpdateComponentResult<TComponents>, ThrowOnError>>;
45
+ } & SpaceIdPathOverride): Promise<ApiResponse<UpdateComponentResult, ThrowOnError>>;
46
46
  delete<ThrowOnError extends boolean = DefaultThrowOnError>(componentId: number, options?: {
47
47
  signal?: AbortSignal;
48
48
  throwOnError?: ThrowOnError;
@@ -52,7 +52,7 @@ declare function createComponentsResource<TComponents extends Block = Block, Def
52
52
  signal?: AbortSignal;
53
53
  throwOnError?: ThrowOnError;
54
54
  fetchOptions?: FetchOptions;
55
- } & SpaceIdPathOverride): Promise<ApiResponse<RestoreComponentResult<TComponents>, ThrowOnError>>;
55
+ } & SpaceIdPathOverride): Promise<ApiResponse<RestoreComponentResult, ThrowOnError>>;
56
56
  versions<ThrowOnError extends boolean = DefaultThrowOnError>(componentId: number, options?: {
57
57
  query?: Omit<ListVersionsData["query"], "model" | "model_id">;
58
58
  signal?: AbortSignal;
@@ -1,48 +1,48 @@
1
1
  import { CreateComponentData, CreateComponentResponses, DeleteComponentResponses, GetComponentResponses, GetComponentVersionData, GetComponentVersionResponses, ListManagementComponentsData, ListManagementComponentsResponses, ListVersionsData, ListVersionsResponses, RestoreComponentResponses, RestoreVersionData, RestoreVersionResponses, UpdateComponentData, UpdateComponentResponses } from "../generated/mapi/types.gen.mjs";
2
2
  import { SpaceIdPathOverride } from "./shared.mjs";
3
- import { Block } from "../generated/types/block.mjs";
3
+ import { Component } from "../generated/mapi/types-aliased.gen.mjs";
4
4
  import { ApiResponse, FetchOptions, MapiResourceDeps } from "../client.mjs";
5
5
 
6
6
  //#region src/resources/components.d.ts
7
- type ListComponentsResult<TComponents extends Block> = Omit<ListManagementComponentsResponses[200], 'components'> & {
8
- components: TComponents[];
7
+ type ListComponentsResult = Omit<ListManagementComponentsResponses[200], 'components'> & {
8
+ components: Component[];
9
9
  };
10
- type GetComponentResult<TComponents extends Block> = Omit<GetComponentResponses[200], 'component'> & {
11
- component: TComponents;
10
+ type GetComponentResult = Omit<GetComponentResponses[200], 'component'> & {
11
+ component: Component;
12
12
  };
13
- type CreateComponentResult<TComponents extends Block> = Omit<CreateComponentResponses[201], 'component'> & {
14
- component: TComponents;
13
+ type CreateComponentResult = Omit<CreateComponentResponses[201], 'component'> & {
14
+ component: Component;
15
15
  };
16
- type UpdateComponentResult<TComponents extends Block> = Omit<UpdateComponentResponses[200], 'component'> & {
17
- component: TComponents;
16
+ type UpdateComponentResult = Omit<UpdateComponentResponses[200], 'component'> & {
17
+ component: Component;
18
18
  };
19
- type RestoreComponentResult<TComponents extends Block> = Omit<RestoreComponentResponses[200], 'component'> & {
20
- component: TComponents;
19
+ type RestoreComponentResult = Omit<RestoreComponentResponses[200], 'component'> & {
20
+ component: Component;
21
21
  };
22
- declare function createComponentsResource<TComponents extends Block = Block, DefaultThrowOnError extends boolean = false>(deps: MapiResourceDeps<DefaultThrowOnError>): {
22
+ declare function createComponentsResource<DefaultThrowOnError extends boolean = false>(deps: MapiResourceDeps<DefaultThrowOnError>): {
23
23
  list<ThrowOnError extends boolean = DefaultThrowOnError>(options?: {
24
24
  query?: ListManagementComponentsData["query"];
25
25
  signal?: AbortSignal;
26
26
  throwOnError?: ThrowOnError;
27
27
  fetchOptions?: FetchOptions;
28
- } & SpaceIdPathOverride): Promise<ApiResponse<ListComponentsResult<TComponents>, ThrowOnError>>;
28
+ } & SpaceIdPathOverride): Promise<ApiResponse<ListComponentsResult, ThrowOnError>>;
29
29
  get<ThrowOnError extends boolean = DefaultThrowOnError>(componentId: number, options?: {
30
30
  signal?: AbortSignal;
31
31
  throwOnError?: ThrowOnError;
32
32
  fetchOptions?: FetchOptions;
33
- } & SpaceIdPathOverride): Promise<ApiResponse<GetComponentResult<TComponents>, ThrowOnError>>;
33
+ } & SpaceIdPathOverride): Promise<ApiResponse<GetComponentResult, ThrowOnError>>;
34
34
  create<ThrowOnError extends boolean = DefaultThrowOnError>(options: {
35
35
  body: CreateComponentData["body"];
36
36
  signal?: AbortSignal;
37
37
  throwOnError?: ThrowOnError;
38
38
  fetchOptions?: FetchOptions;
39
- } & SpaceIdPathOverride): Promise<ApiResponse<CreateComponentResult<TComponents>, ThrowOnError>>;
39
+ } & SpaceIdPathOverride): Promise<ApiResponse<CreateComponentResult, ThrowOnError>>;
40
40
  update<ThrowOnError extends boolean = DefaultThrowOnError>(componentId: number, options: {
41
41
  body: UpdateComponentData["body"];
42
42
  signal?: AbortSignal;
43
43
  throwOnError?: ThrowOnError;
44
44
  fetchOptions?: FetchOptions;
45
- } & SpaceIdPathOverride): Promise<ApiResponse<UpdateComponentResult<TComponents>, ThrowOnError>>;
45
+ } & SpaceIdPathOverride): Promise<ApiResponse<UpdateComponentResult, ThrowOnError>>;
46
46
  delete<ThrowOnError extends boolean = DefaultThrowOnError>(componentId: number, options?: {
47
47
  signal?: AbortSignal;
48
48
  throwOnError?: ThrowOnError;
@@ -52,7 +52,7 @@ declare function createComponentsResource<TComponents extends Block = Block, Def
52
52
  signal?: AbortSignal;
53
53
  throwOnError?: ThrowOnError;
54
54
  fetchOptions?: FetchOptions;
55
- } & SpaceIdPathOverride): Promise<ApiResponse<RestoreComponentResult<TComponents>, ThrowOnError>>;
55
+ } & SpaceIdPathOverride): Promise<ApiResponse<RestoreComponentResult, ThrowOnError>>;
56
56
  versions<ThrowOnError extends boolean = DefaultThrowOnError>(componentId: number, options?: {
57
57
  query?: Omit<ListVersionsData["query"], "model" | "model_id">;
58
58
  signal?: AbortSignal;
@@ -1 +1 @@
1
- {"version":3,"file":"components.mjs","names":["mapi.listManagementComponents","mapi.getComponent","mapi.createComponent","mapi.updateComponent","mapi.deleteComponent","mapi.restoreComponent","mapi.listVersions","mapi.getComponentVersion","mapi.restoreVersion"],"sources":["../../src/resources/components.ts"],"sourcesContent":["import * as mapi from '../generated/mapi/sdk.gen';\nimport type {\n CreateComponentData,\n CreateComponentResponses,\n DeleteComponentResponses,\n GetComponentResponses,\n GetComponentVersionData,\n GetComponentVersionResponses,\n ListManagementComponentsData,\n ListManagementComponentsResponses,\n ListVersionsData,\n ListVersionsResponses,\n RestoreComponentResponses,\n RestoreVersionData,\n RestoreVersionResponses,\n UpdateComponentData,\n UpdateComponentResponses,\n} from '../generated/mapi/types.gen';\nimport type { Block as Component } from '../generated/types/block';\nimport type { ApiResponse, FetchOptions, MapiResourceDeps } from '../client';\nimport { resolveSpaceId, type SpaceIdPathOverride } from './shared';\n\n// Surface the wrapper `Component` (= `Block`) on responses instead of the raw\n// generated component, so consumers get the schema-aware public type. Narrowed\n// to `TComponents` when the client is parameterised via `.withTypes()`.\ntype ListComponentsResult<TComponents extends Component> = Omit<ListManagementComponentsResponses[200], 'components'> & { components: TComponents[] };\ntype GetComponentResult<TComponents extends Component> = Omit<GetComponentResponses[200], 'component'> & { component: TComponents };\ntype CreateComponentResult<TComponents extends Component> = Omit<CreateComponentResponses[201], 'component'> & { component: TComponents };\ntype UpdateComponentResult<TComponents extends Component> = Omit<UpdateComponentResponses[200], 'component'> & { component: TComponents };\ntype RestoreComponentResult<TComponents extends Component> = Omit<RestoreComponentResponses[200], 'component'> & { component: TComponents };\n\nexport function createComponentsResource<\n TComponents extends Component = Component,\n DefaultThrowOnError extends boolean = false,\n>(deps: MapiResourceDeps<DefaultThrowOnError>) {\n const { client, spaceId, wrapRequest } = deps;\n const getSpaceId = (path?: SpaceIdPathOverride['path']) => resolveSpaceId(spaceId, path);\n\n return {\n list<ThrowOnError extends boolean = DefaultThrowOnError>(options: { query?: ListManagementComponentsData['query']; signal?: AbortSignal; throwOnError?: ThrowOnError; fetchOptions?: FetchOptions } & SpaceIdPathOverride = {}): Promise<ApiResponse<ListComponentsResult<TComponents>, ThrowOnError>> {\n const { query, signal, path, throwOnError, fetchOptions } = options;\n const resolvedSpaceId = getSpaceId(path);\n return wrapRequest<ListComponentsResult<TComponents>, ThrowOnError>(() =>\n mapi.listManagementComponents({ client, path: { space_id: resolvedSpaceId }, query, signal, ...(throwOnError === undefined ? {} : { throwOnError }), ...(fetchOptions ? { kyOptions: { ...client.getConfig().kyOptions, ...fetchOptions } } : {}) }), throwOnError);\n },\n get<ThrowOnError extends boolean = DefaultThrowOnError>(componentId: number, options: { signal?: AbortSignal; throwOnError?: ThrowOnError; fetchOptions?: FetchOptions } & SpaceIdPathOverride = {}): Promise<ApiResponse<GetComponentResult<TComponents>, ThrowOnError>> {\n const { signal, path, throwOnError, fetchOptions } = options;\n const resolvedSpaceId = getSpaceId(path);\n return wrapRequest<GetComponentResult<TComponents>, ThrowOnError>(() =>\n mapi.getComponent({ client, path: { space_id: resolvedSpaceId, id: String(componentId) }, signal, ...(throwOnError === undefined ? {} : { throwOnError }), ...(fetchOptions ? { kyOptions: { ...client.getConfig().kyOptions, ...fetchOptions } } : {}) }), throwOnError);\n },\n create<ThrowOnError extends boolean = DefaultThrowOnError>(options: { body: CreateComponentData['body']; signal?: AbortSignal; throwOnError?: ThrowOnError; fetchOptions?: FetchOptions } & SpaceIdPathOverride): Promise<ApiResponse<CreateComponentResult<TComponents>, ThrowOnError>> {\n const { body, signal, path, throwOnError, fetchOptions } = options;\n const resolvedSpaceId = getSpaceId(path);\n return wrapRequest<CreateComponentResult<TComponents>, ThrowOnError>(() =>\n mapi.createComponent({ client, path: { space_id: resolvedSpaceId }, body, signal, ...(throwOnError === undefined ? {} : { throwOnError }), ...(fetchOptions ? { kyOptions: { ...client.getConfig().kyOptions, ...fetchOptions } } : {}) }), throwOnError);\n },\n update<ThrowOnError extends boolean = DefaultThrowOnError>(\n componentId: number,\n options: { body: UpdateComponentData['body']; signal?: AbortSignal; throwOnError?: ThrowOnError; fetchOptions?: FetchOptions } & SpaceIdPathOverride,\n ): Promise<ApiResponse<UpdateComponentResult<TComponents>, ThrowOnError>> {\n const { body, signal, path, throwOnError, fetchOptions } = options;\n const resolvedSpaceId = getSpaceId(path);\n return wrapRequest<UpdateComponentResult<TComponents>, ThrowOnError>(() =>\n mapi.updateComponent({ client, path: { space_id: resolvedSpaceId, id: String(componentId) }, body, signal, ...(throwOnError === undefined ? {} : { throwOnError }), ...(fetchOptions ? { kyOptions: { ...client.getConfig().kyOptions, ...fetchOptions } } : {}) }), throwOnError);\n },\n delete<ThrowOnError extends boolean = DefaultThrowOnError>(componentId: number, options: { signal?: AbortSignal; throwOnError?: ThrowOnError; fetchOptions?: FetchOptions } & SpaceIdPathOverride = {}): Promise<ApiResponse<DeleteComponentResponses[200], ThrowOnError>> {\n const { signal, path, throwOnError, fetchOptions } = options;\n const resolvedSpaceId = getSpaceId(path);\n return wrapRequest<DeleteComponentResponses[200], ThrowOnError>(() =>\n mapi.deleteComponent({ client, path: { space_id: resolvedSpaceId, id: String(componentId) }, signal, ...(throwOnError === undefined ? {} : { throwOnError }), ...(fetchOptions ? { kyOptions: { ...client.getConfig().kyOptions, ...fetchOptions } } : {}) }), throwOnError);\n },\n restore<ThrowOnError extends boolean = DefaultThrowOnError>(componentId: number, options: { signal?: AbortSignal; throwOnError?: ThrowOnError; fetchOptions?: FetchOptions } & SpaceIdPathOverride = {}): Promise<ApiResponse<RestoreComponentResult<TComponents>, ThrowOnError>> {\n const { signal, path, throwOnError, fetchOptions } = options;\n const resolvedSpaceId = getSpaceId(path);\n return wrapRequest<RestoreComponentResult<TComponents>, ThrowOnError>(() =>\n mapi.restoreComponent({ client, path: { space_id: resolvedSpaceId, id: componentId }, signal, ...(throwOnError === undefined ? {} : { throwOnError }), ...(fetchOptions ? { kyOptions: { ...client.getConfig().kyOptions, ...fetchOptions } } : {}) }), throwOnError);\n },\n versions<ThrowOnError extends boolean = DefaultThrowOnError>(\n componentId: number,\n options: { query?: Omit<ListVersionsData['query'], 'model' | 'model_id'>; signal?: AbortSignal; throwOnError?: ThrowOnError; fetchOptions?: FetchOptions } & SpaceIdPathOverride = {},\n ): Promise<ApiResponse<ListVersionsResponses[200], ThrowOnError>> {\n const { query, signal, path, throwOnError, fetchOptions } = options;\n const resolvedSpaceId = getSpaceId(path);\n return wrapRequest<ListVersionsResponses[200], ThrowOnError>(() =>\n mapi.listVersions({ client, path: { space_id: resolvedSpaceId }, query: { ...query, model: 'components', model_id: componentId }, signal, ...(throwOnError === undefined ? {} : { throwOnError }), ...(fetchOptions ? { kyOptions: { ...client.getConfig().kyOptions, ...fetchOptions } } : {}) }), throwOnError);\n },\n version<ThrowOnError extends boolean = DefaultThrowOnError>(\n componentId: number,\n versionId: GetComponentVersionData['path']['id'],\n options: { signal?: AbortSignal; throwOnError?: ThrowOnError; fetchOptions?: FetchOptions } & SpaceIdPathOverride = {},\n ): Promise<ApiResponse<GetComponentVersionResponses[200], ThrowOnError>> {\n const { signal, path, throwOnError, fetchOptions } = options;\n const resolvedSpaceId = getSpaceId(path);\n return wrapRequest<GetComponentVersionResponses[200], ThrowOnError>(() =>\n mapi.getComponentVersion({\n client,\n path: { space_id: resolvedSpaceId, component_id: componentId, id: versionId },\n signal,\n ...(throwOnError === undefined ? {} : { throwOnError }),\n ...(fetchOptions ? { kyOptions: { ...client.getConfig().kyOptions, ...fetchOptions } } : {}),\n }), throwOnError);\n },\n restoreVersion<ThrowOnError extends boolean = DefaultThrowOnError>(\n componentId: number,\n versionId: RestoreVersionData['path']['id'],\n options: { query?: Omit<RestoreVersionData['query'], 'model' | 'model_id'>; signal?: AbortSignal; throwOnError?: ThrowOnError; fetchOptions?: FetchOptions } & SpaceIdPathOverride = {},\n ): Promise<ApiResponse<RestoreVersionResponses[204], ThrowOnError>> {\n const { query, signal, path, throwOnError, fetchOptions } = options;\n const resolvedSpaceId = getSpaceId(path);\n return wrapRequest<RestoreVersionResponses[204], ThrowOnError>(() =>\n mapi.restoreVersion({ client, path: { space_id: resolvedSpaceId, id: versionId }, query: { ...query, model: 'components', model_id: componentId }, signal, ...(throwO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AC;KAAW,GAAG;KAAc,EAAE,GAAG,EAAE;IAAG,CAAC,EAAE,aAAa;;EAEvU"}
1
+ {"version":3,"file":"components.mjs","names":["mapi.listManagementComponents","mapi.getComponent","mapi.createComponent","mapi.updateComponent","mapi.deleteComponent","mapi.restoreComponent","mapi.listVersions","mapi.getComponentVersion","mapi.restoreVersion"],"sources":["../../src/resources/components.ts"],"sourcesContent":["import * as mapi from '../generated/mapi/sdk.gen';\nimport type {\n CreateComponentData,\n CreateComponentResponses,\n DeleteComponentResponses,\n GetComponentResponses,\n GetComponentVersionData,\n GetComponentVersionResponses,\n ListManagementComponentsData,\n ListManagementComponentsResponses,\n ListVersionsData,\n ListVersionsResponses,\n RestoreComponentResponses,\n RestoreVersionData,\n RestoreVersionResponses,\n UpdateComponentData,\n UpdateComponentResponses,\n} from '../generated/mapi/types.gen';\nimport type { Component } from '../generated/mapi/types-aliased.gen';\nimport type { ApiResponse, FetchOptions, MapiResourceDeps } from '../client';\nimport { resolveSpaceId, type SpaceIdPathOverride } from './shared';\n\n// Component definitions are MAPI wire shapes (a `schema` record), surfaced as the\n// public `Component`. This is distinct from the DSL `fields` blocks used to narrow\n// story content via `.withTypes()` — definitions are not parameterised by the block\n// registry.\ntype ListComponentsResult = Omit<ListManagementComponentsResponses[200], 'components'> & { components: Component[] };\ntype GetComponentResult = Omit<GetComponentResponses[200], 'component'> & { component: Component };\ntype CreateComponentResult = Omit<CreateComponentResponses[201], 'component'> & { component: Component };\ntype UpdateComponentResult = Omit<UpdateComponentResponses[200], 'component'> & { component: Component };\ntype RestoreComponentResult = Omit<RestoreComponentResponses[200], 'component'> & { component: Component };\n\nexport function createComponentsResource<\n DefaultThrowOnError extends boolean = false,\n>(deps: MapiResourceDeps<DefaultThrowOnError>) {\n const { client, spaceId, wrapRequest } = deps;\n const getSpaceId = (path?: SpaceIdPathOverride['path']) => resolveSpaceId(spaceId, path);\n\n return {\n list<ThrowOnError extends boolean = DefaultThrowOnError>(options: { query?: ListManagementComponentsData['query']; signal?: AbortSignal; throwOnError?: ThrowOnError; fetchOptions?: FetchOptions } & SpaceIdPathOverride = {}): Promise<ApiResponse<ListComponentsResult, ThrowOnError>> {\n const { query, signal, path, throwOnError, fetchOptions } = options;\n const resolvedSpaceId = getSpaceId(path);\n return wrapRequest<ListComponentsResult, ThrowOnError>(() =>\n mapi.listManagementComponents({ client, path: { space_id: resolvedSpaceId }, query, signal, ...(throwOnError === undefined ? {} : { throwOnError }), ...(fetchOptions ? { kyOptions: { ...client.getConfig().kyOptions, ...fetchOptions } } : {}) }), throwOnError);\n },\n get<ThrowOnError extends boolean = DefaultThrowOnError>(componentId: number, options: { signal?: AbortSignal; throwOnError?: ThrowOnError; fetchOptions?: FetchOptions } & SpaceIdPathOverride = {}): Promise<ApiResponse<GetComponentResult, ThrowOnError>> {\n const { signal, path, throwOnError, fetchOptions } = options;\n const resolvedSpaceId = getSpaceId(path);\n return wrapRequest<GetComponentResult, ThrowOnError>(() =>\n mapi.getComponent({ client, path: { space_id: resolvedSpaceId, id: String(componentId) }, signal, ...(throwOnError === undefined ? {} : { throwOnError }), ...(fetchOptions ? { kyOptions: { ...client.getConfig().kyOptions, ...fetchOptions } } : {}) }), throwOnError);\n },\n create<ThrowOnError extends boolean = DefaultThrowOnError>(options: { body: CreateComponentData['body']; signal?: AbortSignal; throwOnError?: ThrowOnError; fetchOptions?: FetchOptions } & SpaceIdPathOverride): Promise<ApiResponse<CreateComponentResult, ThrowOnError>> {\n const { body, signal, path, throwOnError, fetchOptions } = options;\n const resolvedSpaceId = getSpaceId(path);\n return wrapRequest<CreateComponentResult, ThrowOnError>(() =>\n mapi.createComponent({ client, path: { space_id: resolvedSpaceId }, body, signal, ...(throwOnError === undefined ? {} : { throwOnError }), ...(fetchOptions ? { kyOptions: { ...client.getConfig().kyOptions, ...fetchOptions } } : {}) }), throwOnError);\n },\n update<ThrowOnError extends boolean = DefaultThrowOnError>(\n componentId: number,\n options: { body: UpdateComponentData['body']; signal?: AbortSignal; throwOnError?: ThrowOnError; fetchOptions?: FetchOptions } & SpaceIdPathOverride,\n ): Promise<ApiResponse<UpdateComponentResult, ThrowOnError>> {\n const { body, signal, path, throwOnError, fetchOptions } = options;\n const resolvedSpaceId = getSpaceId(path);\n return wrapRequest<UpdateComponentResult, ThrowOnError>(() =>\n mapi.updateComponent({ client, path: { space_id: resolvedSpaceId, id: String(componentId) }, body, signal, ...(throwOnError === undefined ? {} : { throwOnError }), ...(fetchOptions ? { kyOptions: { ...client.getConfig().kyOptions, ...fetchOptions } } : {}) }), throwOnError);\n },\n delete<ThrowOnError extends boolean = DefaultThrowOnError>(componentId: number, options: { signal?: AbortSignal; throwOnError?: ThrowOnError; fetchOptions?: FetchOptions } & SpaceIdPathOverride = {}): Promise<ApiResponse<DeleteComponentResponses[200], ThrowOnError>> {\n const { signal, path, throwOnError, fetchOptions } = options;\n const resolvedSpaceId = getSpaceId(path);\n return wrapRequest<DeleteComponentResponses[200], ThrowOnError>(() =>\n mapi.deleteComponent({ client, path: { space_id: resolvedSpaceId, id: String(componentId) }, signal, ...(throwOnError === undefined ? {} : { throwOnError }), ...(fetchOptions ? { kyOptions: { ...client.getConfig().kyOptions, ...fetchOptions } } : {}) }), throwOnError);\n },\n restore<ThrowOnError extends boolean = DefaultThrowOnError>(componentId: number, options: { signal?: AbortSignal; throwOnError?: ThrowOnError; fetchOptions?: FetchOptions } & SpaceIdPathOverride = {}): Promise<ApiResponse<RestoreComponentResult, ThrowOnError>> {\n const { signal, path, throwOnError, fetchOptions } = options;\n const resolvedSpaceId = getSpaceId(path);\n return wrapRequest<RestoreComponentResult, ThrowOnError>(() =>\n mapi.restoreComponent({ client, path: { space_id: resolvedSpaceId, id: componentId }, signal, ...(throwOnError === undefined ? {} : { throwOnError }), ...(fetchOptions ? { kyOptions: { ...client.getConfig().kyOptions, ...fetchOptions } } : {}) }), throwOnError);\n },\n versions<ThrowOnError extends boolean = DefaultThrowOnError>(\n componentId: number,\n options: { query?: Omit<ListVersionsData['query'], 'model' | 'model_id'>; signal?: AbortSignal; throwOnError?: ThrowOnError; fetchOptions?: FetchOptions } & SpaceIdPathOverride = {},\n ): Promise<ApiResponse<ListVersionsResponses[200], ThrowOnError>> {\n const { query, signal, path, throwOnError, fetchOptions } = options;\n const resolvedSpaceId = getSpaceId(path);\n return wrapRequest<ListVersionsResponses[200], ThrowOnError>(() =>\n mapi.listVersions({ client, path: { space_id: resolvedSpaceId }, query: { ...query, model: 'components', model_id: componentId }, signal, ...(throwOnError === undefined ? {} : { throwOnError }), ...(fetchOptions ? { kyOptions: { ...client.getConfig().kyOptions, ...fetchOptions } } : {}) }), throwOnError);\n },\n version<ThrowOnError extends boolean = DefaultThrowOnError>(\n componentId: number,\n versionId: GetComponentVersionData['path']['id'],\n options: { signal?: AbortSignal; throwOnError?: ThrowOnError; fetchOptions?: FetchOptions } & SpaceIdPathOverride = {},\n ): Promise<ApiResponse<GetComponentVersionResponses[200], ThrowOnError>> {\n const { signal, path, throwOnError, fetchOptions } = options;\n const resolvedSpaceId = getSpaceId(path);\n return wrapRequest<GetComponentVersionResponses[200], ThrowOnError>(() =>\n mapi.getComponentVersion({\n client,\n path: { space_id: resolvedSpaceId, component_id: componentId, id: versionId },\n signal,\n ...(throwOnError === undefined ? {} : { throwOnError }),\n ...(fetchOptions ? { kyOptions: { ...client.getConfig().kyOptions, ...fetchOptions } } : {}),\n }), throwOnError);\n },\n restoreVersion<ThrowOnError extends boolean = DefaultThrowOnError>(\n componentId: number,\n versionId: RestoreVersionData['path']['id'],\n options: { query?: Omit<RestoreVersionData['query'], 'model' | 'model_id'>; signal?: AbortSignal; throwOnError?: ThrowOnError; fetchOptions?: FetchOptions } & SpaceIdPathOverride = {},\n ): Promise<ApiResponse<RestoreVersionResponses[204], ThrowOnError>> {\n const { query, signal, path, throwOnError, fetchOptions } = options;\n const resolvedSpaceId = getSpaceId(path);\n return wrapRequest<RestoreVersionResponses[204], ThrowOnError>(() =>\n mapi.restoreVersion({ client, path: { space_id: resolvedSpaceId, id: versionId }, query: { ...query, model: 'components', model_id: componentId }, signal, ...(throwOnError === undefined ? {} : { throwOnError }), ...(fetchOptions ? { kyOptions: { ...client.getConfig().kyOptions, ...fetchOptions } } : {}) }), throwOnError);\n },\n };\n}\n"],"mappings":";;;;AAgCA,SAAgB,yBAEd,MAA6C;CAC7C,MAAM,EAAE,QAAQ,SAAS,gBAAgB;CACzC,MAAM,cAAc,SAAuC,eAAe,SAAS,KAAK;AAExF,QAAO;EACL,KAAyD,UAAmK,EAAE,EAA4D;GACxR,MAAM,EAAE,OAAO,QAAQ,MAAM,cAAc,iBAAiB;GAC5D,MAAM,kBAAkB,WAAW,KAAK;AACxC,UAAO,kBACLA,yBAA8B;IAAE;IAAQ,MAAM,EAAE,UAAU,iBAAiB;IAAE;IAAO;IAAQ,GAAI,iBAAiB,SAAY,EAAE,GAAG,EAAE,cAAc;IAAG,GAAI,eAAe,EAAE,WAAW;KAAE,GAAG,OAAO,WAAW,CAAC;KAAW,GAAG;KAAc,EAAE,GAAG,EAAE;IAAG,CAAC,EAAE,aAAa;;EAEvQ,IAAwD,aAAqB,UAAoH,EAAE,EAA0D;GAC3P,MAAM,EAAE,QAAQ,MAAM,cAAc,iBAAiB;GACrD,MAAM,kBAAkB,WAAW,KAAK;AACxC,UAAO,kBACLC,aAAkB;IAAE;IAAQ,MAAM;KAAE,UAAU;KAAiB,IAAI,OAAO,YAAY;KAAE;IAAE;IAAQ,GAAI,iBAAiB,SAAY,EAAE,GAAG,EAAE,cAAc;IAAG,GAAI,eAAe,EAAE,WAAW;KAAE,GAAG,OAAO,WAAW,CAAC;KAAW,GAAG;KAAc,EAAE,GAAG,EAAE;IAAG,CAAC,EAAE,aAAa;;EAE7Q,OAA2D,SAAiN;GAC1Q,MAAM,EAAE,MAAM,QAAQ,MAAM,cAAc,iBAAiB;GAC3D,MAAM,kBAAkB,WAAW,KAAK;AACxC,UAAO,kBACLC,gBAAqB;IAAE;IAAQ,MAAM,EAAE,UAAU,iBAAi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c;IAAG,GAAI,eAAe,EAAE,WAAW;KAAE,GAAG,OAAO,WAAW,CAAC;KAAW,GAAG;KAAc,EAAE,GAAG,EAAE;IAAG,CAAC,EAAE,aAAa;;EAEvU"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@storyblok/management-api-client",
3
3
  "type": "module",
4
- "version": "1.0.0-alpha.2",
4
+ "version": "1.0.0-alpha.3",
5
5
  "private": false,
6
6
  "description": "Storyblok Management API Client",
7
7
  "author": "",
@@ -18,16 +18,10 @@
18
18
 
19
19
  import { afterAll, beforeAll, describe, expect, it } from 'vitest';
20
20
  import { createManagementApiClient } from '@storyblok/management-api-client';
21
+ import type { StoryCreate, StoryUpdate } from '@storyblok/management-api-client';
21
22
  import {
22
- createStoryHelpers,
23
23
  defineBlock,
24
- defineBlockCreate,
25
- defineBlockFolderCreate,
26
- defineDatasourceCreate,
27
- defineDatasourceEntryCreate,
28
24
  defineField,
29
- defineInternalTagCreate,
30
- definePresetCreate,
31
25
  } from '@storyblok/schema';
32
26
 
33
27
  const token = process.env.STORYBLOK_TOKEN!;
@@ -43,7 +37,7 @@ const STORY_SLUG = `${STORY_SLUG_PREFIX}test-page`;
43
37
 
44
38
  const teaserComponent = defineBlock({
45
39
  name: `${PREFIX}teaser`,
46
- schema: [
40
+ fields: [
47
41
  defineField('title', { type: 'text', required: true }),
48
42
  defineField('image', { type: 'asset' }),
49
43
  ],
@@ -51,21 +45,21 @@ const teaserComponent = defineBlock({
51
45
  // Level-2 container: holds teasers in its `items` bloks field (level 3)
52
46
  const sectionComponent = defineBlock({
53
47
  name: `${PREFIX}section`,
54
- schema: [
48
+ fields: [
55
49
  defineField('title', { type: 'text' }),
56
- defineField('items', { type: 'bloks', component_whitelist: [teaserComponent.name], required: true }),
50
+ defineField('items', { type: 'bloks', allow: [teaserComponent.name], required: true }),
57
51
  ],
58
52
  });
59
53
  const pageComponent = defineBlock({
60
54
  name: `${PREFIX}page`,
61
55
  is_root: true,
62
- schema: [
56
+ fields: [
63
57
  defineField('headline', { type: 'text', required: true }),
64
58
  defineField('rating', { type: 'number' }),
65
59
  defineField('is_featured', { type: 'boolean' }),
66
60
  defineField('description', { type: 'richtext' }),
67
- defineField('body', { type: 'bloks', component_whitelist: [teaserComponent.name, sectionComponent.name], required: true }),
68
- defineField('category', { type: 'option', source: 'internal', datasource_slug: DATASOURCE_SLUG }),
61
+ defineField('body', { type: 'bloks', allow: [teaserComponent.name, sectionComponent.name], required: true }),
62
+ defineField('category', { type: 'option', source: 'internal', datasource: DATASOURCE_SLUG }),
69
63
  defineField('any_blocks', { type: 'bloks', required: true }),
70
64
  ],
71
65
  });
@@ -74,7 +68,7 @@ interface StoryblokTypes {
74
68
  components: typeof pageComponent | typeof teaserComponent | typeof sectionComponent;
75
69
  }
76
70
 
77
- const { defineStoryCreate, defineStoryUpdate } = createStoryHelpers().withTypes<StoryblokTypes>();
71
+ type Blocks = StoryblokTypes['components'];
78
72
 
79
73
  const client = createManagementApiClient({
80
74
  personalAccessToken: token,
@@ -155,53 +149,50 @@ describe('schema + mapi-client MAPI round-trip', () => {
155
149
 
156
150
  // 1. Datasource + entries first — the page component schema references the datasource slug,
157
151
  // and the MAPI validates that the datasource exists at component creation time.
158
- const datasourcePayload = defineDatasourceCreate({
152
+ // Create payloads are plain MAPI wire objects validated by the typed client.
153
+ const dsRes = await client.datasources.create({ body: { datasource: {
159
154
  name: DATASOURCE_NAME,
160
155
  slug: DATASOURCE_SLUG,
161
- });
162
- const dsRes = await client.datasources.create({ body: { datasource: datasourcePayload } });
156
+ } } });
163
157
  datasourceId = dsRes.data!.datasource!.id!;
164
158
 
165
159
  for (const entry of [
166
- defineDatasourceEntryCreate({ name: 'Technology', value: 'tech', datasource_id: datasourceId }),
167
- defineDatasourceEntryCreate({ name: 'Design', value: 'design', datasource_id: datasourceId }),
168
- defineDatasourceEntryCreate({ name: 'Business', value: 'business', datasource_id: datasourceId }),
160
+ { name: 'Technology', value: 'tech', datasource_id: datasourceId },
161
+ { name: 'Design', value: 'design', datasource_id: datasourceId },
162
+ { name: 'Business', value: 'business', datasource_id: datasourceId },
169
163
  ]) {
170
164
  await client.datasourceEntries.create({ body: { datasource_entry: entry } });
171
165
  }
172
166
 
173
167
  // 2. Component folder
174
- const folderPayload = defineBlockFolderCreate({ name: `${PREFIX}folder` });
175
- const folderRes = await client.componentFolders.create({ body: { component_group: folderPayload } });
168
+ const folderRes = await client.componentFolders.create({ body: { component_group: { name: `${PREFIX}folder` } } });
176
169
  componentFolderId = folderRes.data!.component_group!.id!;
177
170
  const folderUuid = folderRes.data!.component_group!.uuid;
178
171
 
179
172
  // 3. Teaser component (innermost — whitelisted by section)
180
- const teaserPayload = defineBlockCreate({
173
+ const teaserRes = await client.components.create({ body: { component: {
181
174
  name: teaserComponent.name,
182
175
  schema: {
183
176
  title: { type: 'text', required: true, pos: 0 },
184
177
  image: { type: 'asset', pos: 1 },
185
178
  },
186
179
  component_group_uuid: folderUuid,
187
- });
188
- const teaserRes = await client.components.create({ body: { component: teaserPayload } });
180
+ } } });
189
181
  teaserComponentId = teaserRes.data!.component!.id!;
190
182
 
191
183
  // 4. Section component (level 2 — whitelists teaser, whitelisted by page)
192
- const sectionPayload = defineBlockCreate({
184
+ const sectionRes = await client.components.create({ body: { component: {
193
185
  name: sectionComponent.name,
194
186
  schema: {
195
187
  title: { type: 'text', pos: 0 },
196
188
  items: { type: 'bloks', component_whitelist: [teaserComponent.name], pos: 1 },
197
189
  },
198
190
  component_group_uuid: folderUuid,
199
- });
200
- const sectionRes = await client.components.create({ body: { component: sectionPayload } });
191
+ } } });
201
192
  sectionComponentId = sectionRes.data!.component!.id!;
202
193
 
203
194
  // 5. Page component (level 1 — whitelists both teaser and section in body)
204
- const pagePayload = defineBlockCreate({
195
+ const pageRes = await client.components.create({ body: { component: {
205
196
  name: pageComponent.name,
206
197
  schema: {
207
198
  headline: { type: 'text', required: true, pos: 0 },
@@ -214,30 +205,28 @@ describe('schema + mapi-client MAPI round-trip', () => {
214
205
  },
215
206
  component_group_uuid: folderUuid,
216
207
  is_root: true,
217
- });
218
- const pageRes = await client.components.create({ body: { component: pagePayload } });
208
+ } } });
219
209
  pageComponentId = pageRes.data!.component!.id!;
220
210
 
221
211
  // 5. Internal tag
222
- const tagPayload = defineInternalTagCreate({ name: `${PREFIX}tag`, object_type: 'component' });
223
- const tagRes = await client.internalTags.create({ body: { internal_tag: tagPayload } });
212
+ const tagRes = await client.internalTags.create({ body: { internal_tag: { name: `${PREFIX}tag`, object_type: 'component' } } });
224
213
  internalTagId = tagRes.data!.internal_tag!.id!;
225
214
 
226
215
  // 6. Preset for page component
227
- const presetPayload = definePresetCreate({
216
+ const presetRes = await client.presets.create({ body: { preset: {
228
217
  name: `${PREFIX}default_page`,
229
218
  component_id: pageComponentId,
230
219
  preset: { headline: 'Default Headline', rating: 0, is_featured: false },
231
220
  description: `Default preset for ${pageComponent.name}`,
232
- });
233
- const presetRes = await client.presets.create({ body: { preset: presetPayload } });
221
+ } } });
234
222
  presetId = presetRes.data!.preset!.id!;
235
223
 
236
224
  // 8. Story: body[0]=teaser (level 2), body[1]=section{items:[teaser]} (levels 2+3)
237
- const storyPayload = defineStoryCreate(pageComponent, {
225
+ const storyPayload: StoryCreate<Blocks> = {
238
226
  name: STORY_NAME,
239
227
  slug: STORY_SLUG,
240
228
  content: {
229
+ component: pageComponent.name,
241
230
  headline: 'Hello from e2e',
242
231
  rating: 42,
243
232
  is_featured: true,
@@ -269,7 +258,7 @@ describe('schema + mapi-client MAPI round-trip', () => {
269
258
  },
270
259
  ],
271
260
  },
272
- });
261
+ };
273
262
  const storyRes = await client.stories.create({ body: { story: storyPayload } });
274
263
  storyId = storyRes.data!.story!.id!;
275
264
  });
@@ -485,10 +474,11 @@ describe('schema + mapi-client MAPI round-trip', () => {
485
474
  });
486
475
 
487
476
  it('should round-trip story update correctly', async () => {
488
- const updatedPayload = defineStoryUpdate(pageComponent, {
477
+ const updatedPayload: StoryUpdate<Blocks> = {
489
478
  name: `${STORY_NAME} (Updated)`,
490
479
  slug: STORY_SLUG,
491
480
  content: {
481
+ component: pageComponent.name,
492
482
  headline: 'Updated headline',
493
483
  rating: 100,
494
484
  is_featured: false,
@@ -500,7 +490,7 @@ describe('schema + mapi-client MAPI round-trip', () => {
500
490
  category: 'design',
501
491
  any_blocks: [],
502
492
  },
503
- });
493
+ };
504
494
 
505
495
  await client.stories.update(storyId, { body: { story: updatedPayload } });
506
496
 
@@ -1,11 +1,11 @@
1
- import { defineBlock, defineBlockCreate, defineBlockUpdate, defineField } from '@storyblok/schema';
1
+ import { defineBlock, defineField } from '@storyblok/schema';
2
2
  import { type Component as ComponentMapi, createManagementApiClient } from '@storyblok/management-api-client';
3
3
  import { describe, expectTypeOf, it } from 'vitest';
4
4
 
5
5
  // Nestable block — not a root story type
6
6
  const teaserComponent = defineBlock({
7
7
  name: 'teaser',
8
- schema: [
8
+ fields: [
9
9
  defineField('text', { type: 'text' }),
10
10
  defineField('image', { type: 'asset' }),
11
11
  ],
@@ -16,49 +16,23 @@ const _pageComponent = defineBlock({
16
16
  name: 'page',
17
17
  is_root: true,
18
18
  is_nestable: false,
19
- schema: [
19
+ fields: [
20
20
  defineField('headline', { type: 'text', required: true }),
21
21
  defineField('body', { type: 'richtext' }),
22
- defineField('teasers', { type: 'bloks', component_whitelist: [teaserComponent.name] }),
22
+ defineField('teasers', { type: 'bloks', allow: [teaserComponent.name] }),
23
23
  ],
24
24
  });
25
25
 
26
26
  const CLIENT_CONFIG = { personalAccessToken: 'test-token', spaceId: 12345 };
27
27
 
28
- describe('components.create body type compatibility', () => {
29
- it('should produce a defineBlockCreate result assignable to components.create body', () => {
30
- const createPayload = defineBlockCreate({
31
- name: 'article',
32
- schema: {
33
- title: { type: 'text', pos: 1 },
34
- },
35
- });
36
-
37
- type CreateBody = Parameters<ReturnType<typeof createManagementApiClient>['components']['create']>[0]['body'];
38
- type ComponentCreateInput = NonNullable<CreateBody['component']>;
39
-
40
- expectTypeOf(createPayload).toExtend<ComponentCreateInput>();
41
- });
42
-
43
- it('should produce a defineBlockUpdate result assignable to components.update body', () => {
44
- const updatePayload = defineBlockUpdate({
45
- display_name: 'Article',
46
- });
47
-
48
- type UpdateBody = Parameters<ReturnType<typeof createManagementApiClient>['components']['update']>[1]['body'];
49
- type ComponentUpdateInput = NonNullable<UpdateBody['component']>;
50
-
51
- expectTypeOf(updatePayload).toExtend<ComponentUpdateInput>();
52
- });
53
- });
54
-
55
28
  describe('components.get response shape', () => {
56
- it('should return a Component from components.get matching the wire shape', async () => {
29
+ it('should return the wire Component (a `schema` record) from components.get', async () => {
57
30
  const client = createManagementApiClient(CLIENT_CONFIG);
58
31
  const result = await client.components.get(123);
59
32
 
60
33
  if (result.data?.component) {
61
- // components.get() returns the wrapper Component (= Block), matching the wire shape
34
+ // components.get() returns the wire-shaped Component definition (a `schema`
35
+ // record), not the DSL `fields` block.
62
36
  expectTypeOf(result.data.component.id).toEqualTypeOf<ComponentMapi['id']>();
63
37
  expectTypeOf(result.data.component.name).toEqualTypeOf<ComponentMapi['name']>();
64
38
  expectTypeOf(result.data.component).toHaveProperty('schema');
@@ -66,19 +40,6 @@ describe('components.get response shape', () => {
66
40
  });
67
41
  });
68
42
 
69
- describe('components.create body type rejection', () => {
70
- it('should reject a component create payload with wrong schema field type', () => {
71
- const createPayload = defineBlockCreate({
72
- name: 'article',
73
- schema: {
74
- // @ts-expect-error: schema value must be a field definition, not a string
75
- title: 'invalid',
76
- },
77
- });
78
- void createPayload;
79
- });
80
- });
81
-
82
43
  describe('defineBlock result used in .withTypes() interface', () => {
83
44
  interface StoryblokTypes {
84
45
  components: typeof _pageComponent | typeof teaserComponent;