@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/client.cjs.map +1 -1
- package/dist/client.d.cts +11 -5
- package/dist/client.d.mts +11 -5
- package/dist/client.mjs.map +1 -1
- package/dist/generated/mapi/_internal.gen.d.cts +1 -171
- package/dist/generated/mapi/_internal.gen.d.mts +1 -171
- package/dist/generated/mapi/types-aliased.gen.d.cts +171 -1
- package/dist/generated/mapi/types-aliased.gen.d.mts +171 -1
- package/dist/generated/types/block.d.cts +27 -8
- package/dist/generated/types/block.d.mts +27 -8
- package/dist/generated/types/field.d.cts +24 -12
- package/dist/generated/types/field.d.mts +24 -12
- package/dist/index.d.cts +3 -4
- package/dist/index.d.mts +3 -4
- package/dist/resources/components.cjs.map +1 -1
- package/dist/resources/components.d.cts +17 -17
- package/dist/resources/components.d.mts +17 -17
- package/dist/resources/components.mjs.map +1 -1
- package/package.json +1 -1
- package/playground/integration-tests/test/specs/mapi-round-trip.spec.e2e.ts +30 -40
- package/playground/integration-tests/test/types/components.test-d.ts +7 -46
- package/playground/integration-tests/test/types/resources.test-d.ts +0 -152
- package/playground/integration-tests/test/types/stories.test-d.ts +9 -42
- package/test/GUIDE.md +2 -2
|
@@ -141,6 +141,176 @@ type Component = {
|
|
|
141
141
|
[key: string]: unknown;
|
|
142
142
|
} | null;
|
|
143
143
|
};
|
|
144
|
+
type ComponentCreate = {
|
|
145
|
+
/**
|
|
146
|
+
* Name of the component
|
|
147
|
+
*/
|
|
148
|
+
name: string;
|
|
149
|
+
/**
|
|
150
|
+
* Human-readable display name
|
|
151
|
+
*/
|
|
152
|
+
display_name?: string;
|
|
153
|
+
/**
|
|
154
|
+
* Component description
|
|
155
|
+
*/
|
|
156
|
+
description?: string;
|
|
157
|
+
/**
|
|
158
|
+
* Preview template HTML
|
|
159
|
+
*/
|
|
160
|
+
preview_tmpl?: string;
|
|
161
|
+
/**
|
|
162
|
+
* Component image URL
|
|
163
|
+
*/
|
|
164
|
+
image?: string;
|
|
165
|
+
/**
|
|
166
|
+
* Field used for preview
|
|
167
|
+
*/
|
|
168
|
+
preview_field?: string;
|
|
169
|
+
/**
|
|
170
|
+
* Whether this component can be used as a root component
|
|
171
|
+
*/
|
|
172
|
+
is_root?: boolean;
|
|
173
|
+
/**
|
|
174
|
+
* Whether this component can be nested inside other components
|
|
175
|
+
*/
|
|
176
|
+
is_nestable?: boolean;
|
|
177
|
+
/**
|
|
178
|
+
* Default preset ID
|
|
179
|
+
*/
|
|
180
|
+
preset_id?: number;
|
|
181
|
+
/**
|
|
182
|
+
* UUID
|
|
183
|
+
*/
|
|
184
|
+
component_group_uuid?: string;
|
|
185
|
+
/**
|
|
186
|
+
* Component color for UI display
|
|
187
|
+
*/
|
|
188
|
+
color?: string;
|
|
189
|
+
/**
|
|
190
|
+
* Component icon name
|
|
191
|
+
*/
|
|
192
|
+
icon?: string;
|
|
193
|
+
/**
|
|
194
|
+
* Asset preview URL for content type
|
|
195
|
+
*/
|
|
196
|
+
content_type_asset_preview?: string;
|
|
197
|
+
/**
|
|
198
|
+
* List of internal tag IDs
|
|
199
|
+
*/
|
|
200
|
+
internal_tag_ids?: Array<number>;
|
|
201
|
+
/**
|
|
202
|
+
* Component field schema definition
|
|
203
|
+
*/
|
|
204
|
+
schema?: {
|
|
205
|
+
[key: string]: {
|
|
206
|
+
type?: 'bloks' | 'text' | 'textarea' | 'richtext' | 'markdown' | 'number' | 'datetime' | 'boolean' | 'options' | 'option' | 'asset' | 'multiasset' | 'multilink' | 'table' | 'section' | 'commerce' | 'custom' | 'image' | 'file' | 'tab' | 'link' | 'group';
|
|
207
|
+
/**
|
|
208
|
+
* Human-readable field name
|
|
209
|
+
*/
|
|
210
|
+
display_name?: string;
|
|
211
|
+
/**
|
|
212
|
+
* Whether this field is required
|
|
213
|
+
*/
|
|
214
|
+
required?: boolean;
|
|
215
|
+
/**
|
|
216
|
+
* Whether this field is translatable
|
|
217
|
+
*/
|
|
218
|
+
translatable?: boolean;
|
|
219
|
+
[key: string]: unknown | 'bloks' | 'text' | 'textarea' | 'richtext' | 'markdown' | 'number' | 'datetime' | 'boolean' | 'options' | 'option' | 'asset' | 'multiasset' | 'multilink' | 'table' | 'section' | 'commerce' | 'custom' | 'image' | 'file' | 'tab' | 'link' | 'group' | string | boolean | undefined;
|
|
220
|
+
};
|
|
221
|
+
};
|
|
222
|
+
/**
|
|
223
|
+
* Component metadata
|
|
224
|
+
*/
|
|
225
|
+
metadata?: {
|
|
226
|
+
[key: string]: unknown;
|
|
227
|
+
};
|
|
228
|
+
};
|
|
229
|
+
type ComponentUpdate = {
|
|
230
|
+
/**
|
|
231
|
+
* Name of the component
|
|
232
|
+
*/
|
|
233
|
+
name?: string;
|
|
234
|
+
/**
|
|
235
|
+
* Human-readable display name
|
|
236
|
+
*/
|
|
237
|
+
display_name?: string;
|
|
238
|
+
/**
|
|
239
|
+
* Component description
|
|
240
|
+
*/
|
|
241
|
+
description?: string;
|
|
242
|
+
/**
|
|
243
|
+
* Preview template HTML
|
|
244
|
+
*/
|
|
245
|
+
preview_tmpl?: string;
|
|
246
|
+
/**
|
|
247
|
+
* Component image URL
|
|
248
|
+
*/
|
|
249
|
+
image?: string;
|
|
250
|
+
/**
|
|
251
|
+
* Field used for preview
|
|
252
|
+
*/
|
|
253
|
+
preview_field?: string;
|
|
254
|
+
/**
|
|
255
|
+
* Whether this component can be used as a root component
|
|
256
|
+
*/
|
|
257
|
+
is_root?: boolean;
|
|
258
|
+
/**
|
|
259
|
+
* Whether this component can be nested inside other components
|
|
260
|
+
*/
|
|
261
|
+
is_nestable?: boolean;
|
|
262
|
+
/**
|
|
263
|
+
* Default preset ID
|
|
264
|
+
*/
|
|
265
|
+
preset_id?: number;
|
|
266
|
+
/**
|
|
267
|
+
* UUID
|
|
268
|
+
*/
|
|
269
|
+
component_group_uuid?: string;
|
|
270
|
+
/**
|
|
271
|
+
* Component color for UI display
|
|
272
|
+
*/
|
|
273
|
+
color?: string;
|
|
274
|
+
/**
|
|
275
|
+
* Component icon name
|
|
276
|
+
*/
|
|
277
|
+
icon?: string;
|
|
278
|
+
/**
|
|
279
|
+
* Asset preview URL for content type
|
|
280
|
+
*/
|
|
281
|
+
content_type_asset_preview?: string;
|
|
282
|
+
/**
|
|
283
|
+
* List of internal tag IDs
|
|
284
|
+
*/
|
|
285
|
+
internal_tag_ids?: Array<number>;
|
|
286
|
+
/**
|
|
287
|
+
* Component field schema definition
|
|
288
|
+
*/
|
|
289
|
+
schema?: {
|
|
290
|
+
[key: string]: {
|
|
291
|
+
type?: 'bloks' | 'text' | 'textarea' | 'richtext' | 'markdown' | 'number' | 'datetime' | 'boolean' | 'options' | 'option' | 'asset' | 'multiasset' | 'multilink' | 'table' | 'section' | 'commerce' | 'custom' | 'image' | 'file' | 'tab' | 'link' | 'group';
|
|
292
|
+
/**
|
|
293
|
+
* Human-readable field name
|
|
294
|
+
*/
|
|
295
|
+
display_name?: string;
|
|
296
|
+
/**
|
|
297
|
+
* Whether this field is required
|
|
298
|
+
*/
|
|
299
|
+
required?: boolean;
|
|
300
|
+
/**
|
|
301
|
+
* Whether this field is translatable
|
|
302
|
+
*/
|
|
303
|
+
translatable?: boolean;
|
|
304
|
+
[key: string]: unknown | 'bloks' | 'text' | 'textarea' | 'richtext' | 'markdown' | 'number' | 'datetime' | 'boolean' | 'options' | 'option' | 'asset' | 'multiasset' | 'multilink' | 'table' | 'section' | 'commerce' | 'custom' | 'image' | 'file' | 'tab' | 'link' | 'group' | string | boolean | undefined;
|
|
305
|
+
};
|
|
306
|
+
};
|
|
307
|
+
/**
|
|
308
|
+
* Component metadata
|
|
309
|
+
*/
|
|
310
|
+
metadata?: {
|
|
311
|
+
[key: string]: unknown;
|
|
312
|
+
};
|
|
313
|
+
};
|
|
144
314
|
type Asset = {
|
|
145
315
|
/**
|
|
146
316
|
* Id of the asset.
|
|
@@ -1424,5 +1594,5 @@ type SpaceRole = {
|
|
|
1424
1594
|
blocked_asset_folder_ids: Array<number>;
|
|
1425
1595
|
};
|
|
1426
1596
|
//#endregion
|
|
1427
|
-
export { Asset, AssetCreate, AssetFolder, AssetFolderCreate, AssetFolderUpdate, AssetUpdate, Component, ComponentFolder, ComponentFolderCreate, ComponentFolderUpdate, DatasourceCreate, DatasourceUpdate, InternalTag, InternalTagCreate, InternalTagUpdate, MapiDatasource, MapiDatasourceEntry, Preset, PresetCreate, PresetUpdate, Space, SpaceCreate, SpaceUpdate, StoryLocalizedPath, StoryTranslatedSlug, User, UserUpdate };
|
|
1597
|
+
export { 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 };
|
|
1428
1598
|
//# sourceMappingURL=types-aliased.gen.d.cts.map
|
|
@@ -141,6 +141,176 @@ type Component = {
|
|
|
141
141
|
[key: string]: unknown;
|
|
142
142
|
} | null;
|
|
143
143
|
};
|
|
144
|
+
type ComponentCreate = {
|
|
145
|
+
/**
|
|
146
|
+
* Name of the component
|
|
147
|
+
*/
|
|
148
|
+
name: string;
|
|
149
|
+
/**
|
|
150
|
+
* Human-readable display name
|
|
151
|
+
*/
|
|
152
|
+
display_name?: string;
|
|
153
|
+
/**
|
|
154
|
+
* Component description
|
|
155
|
+
*/
|
|
156
|
+
description?: string;
|
|
157
|
+
/**
|
|
158
|
+
* Preview template HTML
|
|
159
|
+
*/
|
|
160
|
+
preview_tmpl?: string;
|
|
161
|
+
/**
|
|
162
|
+
* Component image URL
|
|
163
|
+
*/
|
|
164
|
+
image?: string;
|
|
165
|
+
/**
|
|
166
|
+
* Field used for preview
|
|
167
|
+
*/
|
|
168
|
+
preview_field?: string;
|
|
169
|
+
/**
|
|
170
|
+
* Whether this component can be used as a root component
|
|
171
|
+
*/
|
|
172
|
+
is_root?: boolean;
|
|
173
|
+
/**
|
|
174
|
+
* Whether this component can be nested inside other components
|
|
175
|
+
*/
|
|
176
|
+
is_nestable?: boolean;
|
|
177
|
+
/**
|
|
178
|
+
* Default preset ID
|
|
179
|
+
*/
|
|
180
|
+
preset_id?: number;
|
|
181
|
+
/**
|
|
182
|
+
* UUID
|
|
183
|
+
*/
|
|
184
|
+
component_group_uuid?: string;
|
|
185
|
+
/**
|
|
186
|
+
* Component color for UI display
|
|
187
|
+
*/
|
|
188
|
+
color?: string;
|
|
189
|
+
/**
|
|
190
|
+
* Component icon name
|
|
191
|
+
*/
|
|
192
|
+
icon?: string;
|
|
193
|
+
/**
|
|
194
|
+
* Asset preview URL for content type
|
|
195
|
+
*/
|
|
196
|
+
content_type_asset_preview?: string;
|
|
197
|
+
/**
|
|
198
|
+
* List of internal tag IDs
|
|
199
|
+
*/
|
|
200
|
+
internal_tag_ids?: Array<number>;
|
|
201
|
+
/**
|
|
202
|
+
* Component field schema definition
|
|
203
|
+
*/
|
|
204
|
+
schema?: {
|
|
205
|
+
[key: string]: {
|
|
206
|
+
type?: 'bloks' | 'text' | 'textarea' | 'richtext' | 'markdown' | 'number' | 'datetime' | 'boolean' | 'options' | 'option' | 'asset' | 'multiasset' | 'multilink' | 'table' | 'section' | 'commerce' | 'custom' | 'image' | 'file' | 'tab' | 'link' | 'group';
|
|
207
|
+
/**
|
|
208
|
+
* Human-readable field name
|
|
209
|
+
*/
|
|
210
|
+
display_name?: string;
|
|
211
|
+
/**
|
|
212
|
+
* Whether this field is required
|
|
213
|
+
*/
|
|
214
|
+
required?: boolean;
|
|
215
|
+
/**
|
|
216
|
+
* Whether this field is translatable
|
|
217
|
+
*/
|
|
218
|
+
translatable?: boolean;
|
|
219
|
+
[key: string]: unknown | 'bloks' | 'text' | 'textarea' | 'richtext' | 'markdown' | 'number' | 'datetime' | 'boolean' | 'options' | 'option' | 'asset' | 'multiasset' | 'multilink' | 'table' | 'section' | 'commerce' | 'custom' | 'image' | 'file' | 'tab' | 'link' | 'group' | string | boolean | undefined;
|
|
220
|
+
};
|
|
221
|
+
};
|
|
222
|
+
/**
|
|
223
|
+
* Component metadata
|
|
224
|
+
*/
|
|
225
|
+
metadata?: {
|
|
226
|
+
[key: string]: unknown;
|
|
227
|
+
};
|
|
228
|
+
};
|
|
229
|
+
type ComponentUpdate = {
|
|
230
|
+
/**
|
|
231
|
+
* Name of the component
|
|
232
|
+
*/
|
|
233
|
+
name?: string;
|
|
234
|
+
/**
|
|
235
|
+
* Human-readable display name
|
|
236
|
+
*/
|
|
237
|
+
display_name?: string;
|
|
238
|
+
/**
|
|
239
|
+
* Component description
|
|
240
|
+
*/
|
|
241
|
+
description?: string;
|
|
242
|
+
/**
|
|
243
|
+
* Preview template HTML
|
|
244
|
+
*/
|
|
245
|
+
preview_tmpl?: string;
|
|
246
|
+
/**
|
|
247
|
+
* Component image URL
|
|
248
|
+
*/
|
|
249
|
+
image?: string;
|
|
250
|
+
/**
|
|
251
|
+
* Field used for preview
|
|
252
|
+
*/
|
|
253
|
+
preview_field?: string;
|
|
254
|
+
/**
|
|
255
|
+
* Whether this component can be used as a root component
|
|
256
|
+
*/
|
|
257
|
+
is_root?: boolean;
|
|
258
|
+
/**
|
|
259
|
+
* Whether this component can be nested inside other components
|
|
260
|
+
*/
|
|
261
|
+
is_nestable?: boolean;
|
|
262
|
+
/**
|
|
263
|
+
* Default preset ID
|
|
264
|
+
*/
|
|
265
|
+
preset_id?: number;
|
|
266
|
+
/**
|
|
267
|
+
* UUID
|
|
268
|
+
*/
|
|
269
|
+
component_group_uuid?: string;
|
|
270
|
+
/**
|
|
271
|
+
* Component color for UI display
|
|
272
|
+
*/
|
|
273
|
+
color?: string;
|
|
274
|
+
/**
|
|
275
|
+
* Component icon name
|
|
276
|
+
*/
|
|
277
|
+
icon?: string;
|
|
278
|
+
/**
|
|
279
|
+
* Asset preview URL for content type
|
|
280
|
+
*/
|
|
281
|
+
content_type_asset_preview?: string;
|
|
282
|
+
/**
|
|
283
|
+
* List of internal tag IDs
|
|
284
|
+
*/
|
|
285
|
+
internal_tag_ids?: Array<number>;
|
|
286
|
+
/**
|
|
287
|
+
* Component field schema definition
|
|
288
|
+
*/
|
|
289
|
+
schema?: {
|
|
290
|
+
[key: string]: {
|
|
291
|
+
type?: 'bloks' | 'text' | 'textarea' | 'richtext' | 'markdown' | 'number' | 'datetime' | 'boolean' | 'options' | 'option' | 'asset' | 'multiasset' | 'multilink' | 'table' | 'section' | 'commerce' | 'custom' | 'image' | 'file' | 'tab' | 'link' | 'group';
|
|
292
|
+
/**
|
|
293
|
+
* Human-readable field name
|
|
294
|
+
*/
|
|
295
|
+
display_name?: string;
|
|
296
|
+
/**
|
|
297
|
+
* Whether this field is required
|
|
298
|
+
*/
|
|
299
|
+
required?: boolean;
|
|
300
|
+
/**
|
|
301
|
+
* Whether this field is translatable
|
|
302
|
+
*/
|
|
303
|
+
translatable?: boolean;
|
|
304
|
+
[key: string]: unknown | 'bloks' | 'text' | 'textarea' | 'richtext' | 'markdown' | 'number' | 'datetime' | 'boolean' | 'options' | 'option' | 'asset' | 'multiasset' | 'multilink' | 'table' | 'section' | 'commerce' | 'custom' | 'image' | 'file' | 'tab' | 'link' | 'group' | string | boolean | undefined;
|
|
305
|
+
};
|
|
306
|
+
};
|
|
307
|
+
/**
|
|
308
|
+
* Component metadata
|
|
309
|
+
*/
|
|
310
|
+
metadata?: {
|
|
311
|
+
[key: string]: unknown;
|
|
312
|
+
};
|
|
313
|
+
};
|
|
144
314
|
type Asset = {
|
|
145
315
|
/**
|
|
146
316
|
* Id of the asset.
|
|
@@ -1424,5 +1594,5 @@ type SpaceRole = {
|
|
|
1424
1594
|
blocked_asset_folder_ids: Array<number>;
|
|
1425
1595
|
};
|
|
1426
1596
|
//#endregion
|
|
1427
|
-
export { Asset, AssetCreate, AssetFolder, AssetFolderCreate, AssetFolderUpdate, AssetUpdate, Component, ComponentFolder, ComponentFolderCreate, ComponentFolderUpdate, DatasourceCreate, DatasourceUpdate, InternalTag, InternalTagCreate, InternalTagUpdate, MapiDatasource, MapiDatasourceEntry, Preset, PresetCreate, PresetUpdate, Space, SpaceCreate, SpaceUpdate, StoryLocalizedPath, StoryTranslatedSlug, User, UserUpdate };
|
|
1597
|
+
export { 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 };
|
|
1428
1598
|
//# sourceMappingURL=types-aliased.gen.d.mts.map
|
|
@@ -1,20 +1,39 @@
|
|
|
1
1
|
import { Component } from "../mapi/types-aliased.gen.cjs";
|
|
2
|
-
import { ComponentCreate, ComponentUpdate } from "../mapi/_internal.gen.cjs";
|
|
3
2
|
import { Field } from "../overlay/_internal.gen.cjs";
|
|
4
3
|
import { Override } from "./_utils.cjs";
|
|
5
4
|
|
|
6
5
|
//#region src/generated/types/block.d.ts
|
|
7
|
-
/**
|
|
8
|
-
|
|
6
|
+
/**
|
|
7
|
+
* Ordered array of named fields — the content-shape DSL form `defineBlock`
|
|
8
|
+
* accepts and returns. A field's position in the array sets the order it appears
|
|
9
|
+
* in the editor (mapped to the wire `pos` on push).
|
|
10
|
+
*/
|
|
11
|
+
type BlockFields = ReadonlyArray<Field & {
|
|
12
|
+
name: string;
|
|
13
|
+
pos?: number;
|
|
9
14
|
required?: boolean;
|
|
10
15
|
}>;
|
|
11
|
-
/**
|
|
12
|
-
|
|
16
|
+
/**
|
|
17
|
+
* A Storyblok block: a named, ordered set of content fields. Uses the
|
|
18
|
+
* content-shape DSL `fields` array rather than the MAPI wire `schema` record.
|
|
19
|
+
*/
|
|
20
|
+
type Block<TName extends string = string, TFields extends BlockFields = BlockFields, TIsRoot extends boolean = boolean, TIsNestable extends boolean = boolean> = Override<Omit<Component, 'schema' | 'component_group_uuid'>, {
|
|
13
21
|
name: TName;
|
|
14
|
-
|
|
22
|
+
fields: TFields;
|
|
15
23
|
is_root?: TIsRoot;
|
|
16
24
|
is_nestable?: TIsNestable;
|
|
17
|
-
|
|
25
|
+
/**
|
|
26
|
+
* Escape hatch for pinning this block to a Storyblok UI-managed component
|
|
27
|
+
* group by UUID. Component groups are normally maintained in code via the
|
|
28
|
+
* schema directory layout; set this only if you intentionally manage groups
|
|
29
|
+
* in the Storyblok UI, and fill in the group UUID yourself. When set,
|
|
30
|
+
* `schema push` diffs it and sends it to the Management API; when omitted,
|
|
31
|
+
* the block's remote group is left untouched.
|
|
32
|
+
*
|
|
33
|
+
* @deprecated Prefer maintaining component groups in code through the
|
|
34
|
+
* directory layout.
|
|
35
|
+
*/
|
|
36
|
+
component_group_uuid?: string | null;
|
|
18
37
|
}>;
|
|
19
38
|
/**
|
|
20
39
|
* A root {@link Block} (`is_root: true`). Given a union of blocks, narrows to
|
|
@@ -26,5 +45,5 @@ type RootBlock<T extends Block = Block & {
|
|
|
26
45
|
is_root: true;
|
|
27
46
|
}>;
|
|
28
47
|
//#endregion
|
|
29
|
-
export { Block, RootBlock };
|
|
48
|
+
export { Block, BlockFields, RootBlock };
|
|
30
49
|
//# sourceMappingURL=block.d.cts.map
|
|
@@ -1,20 +1,39 @@
|
|
|
1
1
|
import { Component } from "../mapi/types-aliased.gen.mjs";
|
|
2
|
-
import { ComponentCreate, ComponentUpdate } from "../mapi/_internal.gen.mjs";
|
|
3
2
|
import { Field } from "../overlay/_internal.gen.mjs";
|
|
4
3
|
import { Override } from "./_utils.mjs";
|
|
5
4
|
|
|
6
5
|
//#region src/generated/types/block.d.ts
|
|
7
|
-
/**
|
|
8
|
-
|
|
6
|
+
/**
|
|
7
|
+
* Ordered array of named fields — the content-shape DSL form `defineBlock`
|
|
8
|
+
* accepts and returns. A field's position in the array sets the order it appears
|
|
9
|
+
* in the editor (mapped to the wire `pos` on push).
|
|
10
|
+
*/
|
|
11
|
+
type BlockFields = ReadonlyArray<Field & {
|
|
12
|
+
name: string;
|
|
13
|
+
pos?: number;
|
|
9
14
|
required?: boolean;
|
|
10
15
|
}>;
|
|
11
|
-
/**
|
|
12
|
-
|
|
16
|
+
/**
|
|
17
|
+
* A Storyblok block: a named, ordered set of content fields. Uses the
|
|
18
|
+
* content-shape DSL `fields` array rather than the MAPI wire `schema` record.
|
|
19
|
+
*/
|
|
20
|
+
type Block<TName extends string = string, TFields extends BlockFields = BlockFields, TIsRoot extends boolean = boolean, TIsNestable extends boolean = boolean> = Override<Omit<Component, 'schema' | 'component_group_uuid'>, {
|
|
13
21
|
name: TName;
|
|
14
|
-
|
|
22
|
+
fields: TFields;
|
|
15
23
|
is_root?: TIsRoot;
|
|
16
24
|
is_nestable?: TIsNestable;
|
|
17
|
-
|
|
25
|
+
/**
|
|
26
|
+
* Escape hatch for pinning this block to a Storyblok UI-managed component
|
|
27
|
+
* group by UUID. Component groups are normally maintained in code via the
|
|
28
|
+
* schema directory layout; set this only if you intentionally manage groups
|
|
29
|
+
* in the Storyblok UI, and fill in the group UUID yourself. When set,
|
|
30
|
+
* `schema push` diffs it and sends it to the Management API; when omitted,
|
|
31
|
+
* the block's remote group is left untouched.
|
|
32
|
+
*
|
|
33
|
+
* @deprecated Prefer maintaining component groups in code through the
|
|
34
|
+
* directory layout.
|
|
35
|
+
*/
|
|
36
|
+
component_group_uuid?: string | null;
|
|
18
37
|
}>;
|
|
19
38
|
/**
|
|
20
39
|
* A root {@link Block} (`is_root: true`). Given a union of blocks, narrows to
|
|
@@ -26,5 +45,5 @@ type RootBlock<T extends Block = Block & {
|
|
|
26
45
|
is_root: true;
|
|
27
46
|
}>;
|
|
28
47
|
//#endregion
|
|
29
|
-
export { Block, RootBlock };
|
|
48
|
+
export { Block, BlockFields, RootBlock };
|
|
30
49
|
//# sourceMappingURL=block.d.mts.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AssetFieldValue, BlockContentBase, BlockContentInputBase, Field, MultilinkFieldValue, PluginFieldValue, RichtextFieldValue, TableFieldValue } from "../overlay/_internal.gen.cjs";
|
|
2
2
|
import { Prettify } from "./_utils.cjs";
|
|
3
|
-
import { Block } from "./block.cjs";
|
|
3
|
+
import { Block, BlockFields } from "./block.cjs";
|
|
4
4
|
|
|
5
5
|
//#region src/generated/types/field.d.ts
|
|
6
6
|
/**
|
|
@@ -11,27 +11,39 @@ import { Block } from "./block.cjs";
|
|
|
11
11
|
type NoBlocks = false;
|
|
12
12
|
/** True when `T` is the un-narrowed base `Block` (i.e. no specific block was supplied). */
|
|
13
13
|
type IsBaseBlock<T> = [Block] extends [T] ? true : false;
|
|
14
|
-
|
|
14
|
+
/**
|
|
15
|
+
* Maps a block's ordered `fields` array to its read content object, splitting
|
|
16
|
+
* required (`required: true`) from optional fields. Each `F` is a member of the
|
|
17
|
+
* field union, so it provably satisfies `FieldValue`'s `Field` constraint.
|
|
18
|
+
*/
|
|
19
|
+
type ContentFields<TFields extends BlockFields, TBlocks> = Prettify<{ [F in TFields[number] as F extends {
|
|
20
|
+
required: true;
|
|
21
|
+
} ? F['name'] : never]: FieldValue<F, TBlocks> } & { [F in TFields[number] as F extends {
|
|
22
|
+
required: true;
|
|
23
|
+
} ? never : F['name']]?: FieldValue<F, TBlocks> | null }>;
|
|
24
|
+
/** Input (write) variant of {@link ContentFields}, resolving each field via {@link FieldValueInput}. */
|
|
25
|
+
type ContentFieldsInput<TFields extends BlockFields, TBlocks> = Prettify<{ [F in TFields[number] as F extends {
|
|
26
|
+
required: true;
|
|
27
|
+
} ? F['name'] : never]: FieldValueInput<F, TBlocks> } & { [F in TFields[number] as F extends {
|
|
15
28
|
required: true;
|
|
16
|
-
} ?
|
|
17
|
-
type OptionalFieldKeys<T> = Exclude<keyof T, RequiredFieldKeys<T>>;
|
|
29
|
+
} ? never : F['name']]?: FieldValueInput<F, TBlocks> | null }>;
|
|
18
30
|
/**
|
|
19
31
|
* Content object for a single block instance as returned by the Storyblok
|
|
20
32
|
* Content Delivery API. Without a `TBlock` argument, this is the loose
|
|
21
33
|
* runtime shape (any block, `_editable` optional). With a schema-typed
|
|
22
|
-
* `TBlock`, fields are narrowed per the block's
|
|
34
|
+
* `TBlock`, fields are narrowed per the block's `fields`.
|
|
23
35
|
*/
|
|
24
36
|
type BlockContent<TBlock extends Block = Block, TBlocks = NoBlocks> = IsBaseBlock<TBlock> extends true ? BlockContentBase : TBlock extends any ? Prettify<{
|
|
25
37
|
_uid: string;
|
|
26
38
|
component: TBlock['name'];
|
|
27
39
|
_editable?: string;
|
|
28
|
-
} &
|
|
40
|
+
} & ContentFields<TBlock['fields'], TBlocks>> : never;
|
|
29
41
|
/** Input variant of {@link BlockContent} for write operations (creating/updating stories via the MAPI). `_uid` is optional. */
|
|
30
42
|
type BlockContentInput<TBlock extends Block = Block, TBlocks = NoBlocks> = IsBaseBlock<TBlock> extends true ? BlockContentInputBase : TBlock extends any ? Prettify<{
|
|
31
43
|
_uid?: string;
|
|
32
44
|
component: TBlock['name'];
|
|
33
45
|
_editable?: string;
|
|
34
|
-
} &
|
|
46
|
+
} & ContentFieldsInput<TBlock['fields'], TBlocks>> : never;
|
|
35
47
|
type BlocksFieldValue<TBlock extends Block = Block, TBlocks = NoBlocks> = BlockContent<TBlock, TBlocks>[];
|
|
36
48
|
interface FieldTypeValueMap {
|
|
37
49
|
text: string;
|
|
@@ -57,19 +69,19 @@ type IsNestable<T> = T extends {
|
|
|
57
69
|
} ? false : T extends {
|
|
58
70
|
is_nestable: true;
|
|
59
71
|
} ? true : true;
|
|
60
|
-
type
|
|
61
|
-
|
|
72
|
+
type ApplyAllow<TField, TBlocks> = TField extends {
|
|
73
|
+
allow: ReadonlyArray<infer TAllowed extends string>;
|
|
62
74
|
} ? Extract<TBlocks, {
|
|
63
|
-
name:
|
|
75
|
+
name: TAllowed;
|
|
64
76
|
}> : TBlocks extends any ? IsNestable<TBlocks> extends true ? TBlocks : never : never;
|
|
65
77
|
/** Resolves a field definition to its runtime content value type (read). */
|
|
66
78
|
type FieldValue<TField extends Field = Field, TBlocks = NoBlocks> = Prettify<TField extends {
|
|
67
79
|
type: 'bloks';
|
|
68
|
-
} ? [TBlocks] extends [never] ? BlockContentBase[] : [TBlocks] extends [Block] ? BlockContent<
|
|
80
|
+
} ? [TBlocks] extends [never] ? BlockContentBase[] : [TBlocks] extends [Block] ? BlockContent<ApplyAllow<TField, TBlocks>, TBlocks>[] : BlockContentBase[] : FieldTypeValueMap[TField['type']]>;
|
|
69
81
|
/** Resolves a field definition to its input value type (write). */
|
|
70
82
|
type FieldValueInput<TField extends Field = Field, TBlocks = NoBlocks> = Prettify<TField extends {
|
|
71
83
|
type: 'bloks';
|
|
72
|
-
} ? [TBlocks] extends [never] ? BlockContentInputBase[] : [TBlocks] extends [Block] ? BlockContentInput<
|
|
84
|
+
} ? [TBlocks] extends [never] ? BlockContentInputBase[] : [TBlocks] extends [Block] ? BlockContentInput<ApplyAllow<TField, TBlocks>, TBlocks>[] : BlockContentInputBase[] : FieldTypeValueMap[TField['type']]>;
|
|
73
85
|
//#endregion
|
|
74
86
|
export { BlockContent, BlockContentInput, BlocksFieldValue };
|
|
75
87
|
//# sourceMappingURL=field.d.cts.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AssetFieldValue, BlockContentBase, BlockContentInputBase, Field, MultilinkFieldValue, PluginFieldValue, RichtextFieldValue, TableFieldValue } from "../overlay/_internal.gen.mjs";
|
|
2
2
|
import { Prettify } from "./_utils.mjs";
|
|
3
|
-
import { Block } from "./block.mjs";
|
|
3
|
+
import { Block, BlockFields } from "./block.mjs";
|
|
4
4
|
|
|
5
5
|
//#region src/generated/types/field.d.ts
|
|
6
6
|
/**
|
|
@@ -11,27 +11,39 @@ import { Block } from "./block.mjs";
|
|
|
11
11
|
type NoBlocks = false;
|
|
12
12
|
/** True when `T` is the un-narrowed base `Block` (i.e. no specific block was supplied). */
|
|
13
13
|
type IsBaseBlock<T> = [Block] extends [T] ? true : false;
|
|
14
|
-
|
|
14
|
+
/**
|
|
15
|
+
* Maps a block's ordered `fields` array to its read content object, splitting
|
|
16
|
+
* required (`required: true`) from optional fields. Each `F` is a member of the
|
|
17
|
+
* field union, so it provably satisfies `FieldValue`'s `Field` constraint.
|
|
18
|
+
*/
|
|
19
|
+
type ContentFields<TFields extends BlockFields, TBlocks> = Prettify<{ [F in TFields[number] as F extends {
|
|
20
|
+
required: true;
|
|
21
|
+
} ? F['name'] : never]: FieldValue<F, TBlocks> } & { [F in TFields[number] as F extends {
|
|
22
|
+
required: true;
|
|
23
|
+
} ? never : F['name']]?: FieldValue<F, TBlocks> | null }>;
|
|
24
|
+
/** Input (write) variant of {@link ContentFields}, resolving each field via {@link FieldValueInput}. */
|
|
25
|
+
type ContentFieldsInput<TFields extends BlockFields, TBlocks> = Prettify<{ [F in TFields[number] as F extends {
|
|
26
|
+
required: true;
|
|
27
|
+
} ? F['name'] : never]: FieldValueInput<F, TBlocks> } & { [F in TFields[number] as F extends {
|
|
15
28
|
required: true;
|
|
16
|
-
} ?
|
|
17
|
-
type OptionalFieldKeys<T> = Exclude<keyof T, RequiredFieldKeys<T>>;
|
|
29
|
+
} ? never : F['name']]?: FieldValueInput<F, TBlocks> | null }>;
|
|
18
30
|
/**
|
|
19
31
|
* Content object for a single block instance as returned by the Storyblok
|
|
20
32
|
* Content Delivery API. Without a `TBlock` argument, this is the loose
|
|
21
33
|
* runtime shape (any block, `_editable` optional). With a schema-typed
|
|
22
|
-
* `TBlock`, fields are narrowed per the block's
|
|
34
|
+
* `TBlock`, fields are narrowed per the block's `fields`.
|
|
23
35
|
*/
|
|
24
36
|
type BlockContent<TBlock extends Block = Block, TBlocks = NoBlocks> = IsBaseBlock<TBlock> extends true ? BlockContentBase : TBlock extends any ? Prettify<{
|
|
25
37
|
_uid: string;
|
|
26
38
|
component: TBlock['name'];
|
|
27
39
|
_editable?: string;
|
|
28
|
-
} &
|
|
40
|
+
} & ContentFields<TBlock['fields'], TBlocks>> : never;
|
|
29
41
|
/** Input variant of {@link BlockContent} for write operations (creating/updating stories via the MAPI). `_uid` is optional. */
|
|
30
42
|
type BlockContentInput<TBlock extends Block = Block, TBlocks = NoBlocks> = IsBaseBlock<TBlock> extends true ? BlockContentInputBase : TBlock extends any ? Prettify<{
|
|
31
43
|
_uid?: string;
|
|
32
44
|
component: TBlock['name'];
|
|
33
45
|
_editable?: string;
|
|
34
|
-
} &
|
|
46
|
+
} & ContentFieldsInput<TBlock['fields'], TBlocks>> : never;
|
|
35
47
|
type BlocksFieldValue<TBlock extends Block = Block, TBlocks = NoBlocks> = BlockContent<TBlock, TBlocks>[];
|
|
36
48
|
interface FieldTypeValueMap {
|
|
37
49
|
text: string;
|
|
@@ -57,19 +69,19 @@ type IsNestable<T> = T extends {
|
|
|
57
69
|
} ? false : T extends {
|
|
58
70
|
is_nestable: true;
|
|
59
71
|
} ? true : true;
|
|
60
|
-
type
|
|
61
|
-
|
|
72
|
+
type ApplyAllow<TField, TBlocks> = TField extends {
|
|
73
|
+
allow: ReadonlyArray<infer TAllowed extends string>;
|
|
62
74
|
} ? Extract<TBlocks, {
|
|
63
|
-
name:
|
|
75
|
+
name: TAllowed;
|
|
64
76
|
}> : TBlocks extends any ? IsNestable<TBlocks> extends true ? TBlocks : never : never;
|
|
65
77
|
/** Resolves a field definition to its runtime content value type (read). */
|
|
66
78
|
type FieldValue<TField extends Field = Field, TBlocks = NoBlocks> = Prettify<TField extends {
|
|
67
79
|
type: 'bloks';
|
|
68
|
-
} ? [TBlocks] extends [never] ? BlockContentBase[] : [TBlocks] extends [Block] ? BlockContent<
|
|
80
|
+
} ? [TBlocks] extends [never] ? BlockContentBase[] : [TBlocks] extends [Block] ? BlockContent<ApplyAllow<TField, TBlocks>, TBlocks>[] : BlockContentBase[] : FieldTypeValueMap[TField['type']]>;
|
|
69
81
|
/** Resolves a field definition to its input value type (write). */
|
|
70
82
|
type FieldValueInput<TField extends Field = Field, TBlocks = NoBlocks> = Prettify<TField extends {
|
|
71
83
|
type: 'bloks';
|
|
72
|
-
} ? [TBlocks] extends [never] ? BlockContentInputBase[] : [TBlocks] extends [Block] ? BlockContentInput<
|
|
84
|
+
} ? [TBlocks] extends [never] ? BlockContentInputBase[] : [TBlocks] extends [Block] ? BlockContentInput<ApplyAllow<TField, TBlocks>, TBlocks>[] : BlockContentInputBase[] : FieldTypeValueMap[TField['type']]>;
|
|
73
85
|
//#endregion
|
|
74
86
|
export { BlockContent, BlockContentInput, BlocksFieldValue };
|
|
75
87
|
//# sourceMappingURL=field.d.mts.map
|
package/dist/index.d.cts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { AssetUpdateRequest, CreateAsset, SpaceDetail } from "./generated/mapi/types.gen.cjs";
|
|
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.cjs";
|
|
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.cjs";
|
|
3
3
|
import { AssetCreate as AssetCreate$1, AssetListQuery } from "./resources/assets.cjs";
|
|
4
|
-
import { ComponentCreate, ComponentUpdate } from "./generated/mapi/_internal.gen.cjs";
|
|
5
4
|
import { AssetFieldValue, Field, MultilinkFieldValue, PluginFieldValue, RichtextFieldValue, TableFieldValue } from "./generated/overlay/_internal.gen.cjs";
|
|
6
|
-
import {
|
|
5
|
+
import { RootBlock } from "./generated/types/block.cjs";
|
|
7
6
|
import { ApiErrorBody, ClientError } from "./error.cjs";
|
|
8
7
|
import { RateLimitConfig } from "./utils/rate-limit.cjs";
|
|
9
8
|
import { BlockContent, BlockContentInput, BlocksFieldValue } from "./generated/types/field.cjs";
|
|
@@ -12,4 +11,4 @@ import { StoryListQuery } from "./resources/stories.cjs";
|
|
|
12
11
|
import { ApiResponse, FetchOptions, HttpRequestOptions, ManagementApiClient, ManagementApiClientConfig, MapiResourceDeps, RequestConfigOverrides, createManagementApiClient } from "./client.cjs";
|
|
13
12
|
import { SpaceCreateQuery } from "./resources/spaces.cjs";
|
|
14
13
|
import { normalizeAssetUrl } from "./utils/normalize-asset-url.cjs";
|
|
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
|
|
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 };
|