@storyblok/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.d.cts
CHANGED
|
@@ -304,7 +304,7 @@ declare const createApiClientBase: <ThrowOnError extends boolean = false, Inline
|
|
|
304
304
|
published: string | null;
|
|
305
305
|
}[] | null;
|
|
306
306
|
content: {
|
|
307
|
-
[x: string]: string | number | boolean | string[] |
|
|
307
|
+
[x: string]: string | number | boolean | string[] | {
|
|
308
308
|
type: "doc";
|
|
309
309
|
content?: Array<{
|
|
310
310
|
[key: string]: unknown;
|
|
@@ -323,7 +323,7 @@ declare const createApiClientBase: <ThrowOnError extends boolean = false, Inline
|
|
|
323
323
|
[key: string]: unknown;
|
|
324
324
|
} | undefined;
|
|
325
325
|
is_external_url?: boolean | undefined;
|
|
326
|
-
} | {
|
|
326
|
+
} | AssetFieldValueRoot[] | {
|
|
327
327
|
fieldtype: "multilink";
|
|
328
328
|
id: string;
|
|
329
329
|
url: string;
|
|
@@ -482,7 +482,7 @@ declare const createApiClientBase: <ThrowOnError extends boolean = false, Inline
|
|
|
482
482
|
published: string | null;
|
|
483
483
|
}[] | null;
|
|
484
484
|
content: {
|
|
485
|
-
[x: string]: string | number | boolean | string[] |
|
|
485
|
+
[x: string]: string | number | boolean | string[] | {
|
|
486
486
|
type: "doc";
|
|
487
487
|
content?: Array<{
|
|
488
488
|
[key: string]: unknown;
|
|
@@ -501,7 +501,7 @@ declare const createApiClientBase: <ThrowOnError extends boolean = false, Inline
|
|
|
501
501
|
[key: string]: unknown;
|
|
502
502
|
} | undefined;
|
|
503
503
|
is_external_url?: boolean | undefined;
|
|
504
|
-
} | {
|
|
504
|
+
} | AssetFieldValueRoot[] | {
|
|
505
505
|
fieldtype: "multilink";
|
|
506
506
|
id: string;
|
|
507
507
|
url: string;
|
package/dist/client.d.mts
CHANGED
|
@@ -304,7 +304,7 @@ declare const createApiClientBase: <ThrowOnError extends boolean = false, Inline
|
|
|
304
304
|
published: string | null;
|
|
305
305
|
}[] | null;
|
|
306
306
|
content: {
|
|
307
|
-
[x: string]: string | number | boolean | string[] |
|
|
307
|
+
[x: string]: string | number | boolean | string[] | {
|
|
308
308
|
type: "doc";
|
|
309
309
|
content?: Array<{
|
|
310
310
|
[key: string]: unknown;
|
|
@@ -323,7 +323,7 @@ declare const createApiClientBase: <ThrowOnError extends boolean = false, Inline
|
|
|
323
323
|
[key: string]: unknown;
|
|
324
324
|
} | undefined;
|
|
325
325
|
is_external_url?: boolean | undefined;
|
|
326
|
-
} | {
|
|
326
|
+
} | AssetFieldValueRoot[] | {
|
|
327
327
|
fieldtype: "multilink";
|
|
328
328
|
id: string;
|
|
329
329
|
url: string;
|
|
@@ -482,7 +482,7 @@ declare const createApiClientBase: <ThrowOnError extends boolean = false, Inline
|
|
|
482
482
|
published: string | null;
|
|
483
483
|
}[] | null;
|
|
484
484
|
content: {
|
|
485
|
-
[x: string]: string | number | boolean | string[] |
|
|
485
|
+
[x: string]: string | number | boolean | string[] | {
|
|
486
486
|
type: "doc";
|
|
487
487
|
content?: Array<{
|
|
488
488
|
[key: string]: unknown;
|
|
@@ -501,7 +501,7 @@ declare const createApiClientBase: <ThrowOnError extends boolean = false, Inline
|
|
|
501
501
|
[key: string]: unknown;
|
|
502
502
|
} | undefined;
|
|
503
503
|
is_external_url?: boolean | undefined;
|
|
504
|
-
} | {
|
|
504
|
+
} | AssetFieldValueRoot[] | {
|
|
505
505
|
fieldtype: "multilink";
|
|
506
506
|
id: string;
|
|
507
507
|
url: string;
|
|
@@ -3,17 +3,37 @@ import { Component } from "../mapi/_internal.gen.cjs";
|
|
|
3
3
|
import { Override } from "./_utils.cjs";
|
|
4
4
|
|
|
5
5
|
//#region src/generated/types/block.d.ts
|
|
6
|
-
/**
|
|
7
|
-
|
|
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;
|
|
8
14
|
required?: boolean;
|
|
9
15
|
}>;
|
|
10
|
-
/**
|
|
11
|
-
|
|
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'>, {
|
|
12
21
|
name: TName;
|
|
13
|
-
|
|
22
|
+
fields: TFields;
|
|
14
23
|
is_root?: TIsRoot;
|
|
15
24
|
is_nestable?: TIsNestable;
|
|
16
|
-
|
|
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;
|
|
17
37
|
}>;
|
|
18
38
|
/**
|
|
19
39
|
* A root {@link Block} (`is_root: true`). Given a union of blocks, narrows to
|
|
@@ -25,5 +45,5 @@ type RootBlock<T extends Block = Block & {
|
|
|
25
45
|
is_root: true;
|
|
26
46
|
}>;
|
|
27
47
|
//#endregion
|
|
28
|
-
export { Block, RootBlock };
|
|
48
|
+
export { Block, BlockFields, RootBlock };
|
|
29
49
|
//# sourceMappingURL=block.d.cts.map
|
|
@@ -3,17 +3,37 @@ import { Component } from "../mapi/_internal.gen.mjs";
|
|
|
3
3
|
import { Override } from "./_utils.mjs";
|
|
4
4
|
|
|
5
5
|
//#region src/generated/types/block.d.ts
|
|
6
|
-
/**
|
|
7
|
-
|
|
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;
|
|
8
14
|
required?: boolean;
|
|
9
15
|
}>;
|
|
10
|
-
/**
|
|
11
|
-
|
|
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'>, {
|
|
12
21
|
name: TName;
|
|
13
|
-
|
|
22
|
+
fields: TFields;
|
|
14
23
|
is_root?: TIsRoot;
|
|
15
24
|
is_nestable?: TIsNestable;
|
|
16
|
-
|
|
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;
|
|
17
37
|
}>;
|
|
18
38
|
/**
|
|
19
39
|
* A root {@link Block} (`is_root: true`). Given a union of blocks, narrows to
|
|
@@ -25,5 +45,5 @@ type RootBlock<T extends Block = Block & {
|
|
|
25
45
|
is_root: true;
|
|
26
46
|
}>;
|
|
27
47
|
//#endregion
|
|
28
|
-
export { Block, RootBlock };
|
|
48
|
+
export { Block, BlockFields, RootBlock };
|
|
29
49
|
//# sourceMappingURL=block.d.mts.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AssetFieldValue, BlockContentBase, 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,21 +11,28 @@ 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 {
|
|
15
22
|
required: true;
|
|
16
|
-
} ?
|
|
17
|
-
|
|
23
|
+
} ? never : F['name']]?: FieldValue<F, TBlocks> | null }>;
|
|
24
|
+
/** Input (write) variant of {@link ContentFields}, resolving each field via {@link FieldValueInput}. */
|
|
18
25
|
/**
|
|
19
26
|
* Content object for a single block instance as returned by the Storyblok
|
|
20
27
|
* Content Delivery API. Without a `TBlock` argument, this is the loose
|
|
21
28
|
* runtime shape (any block, `_editable` optional). With a schema-typed
|
|
22
|
-
* `TBlock`, fields are narrowed per the block's
|
|
29
|
+
* `TBlock`, fields are narrowed per the block's `fields`.
|
|
23
30
|
*/
|
|
24
31
|
type BlockContent<TBlock extends Block = Block, TBlocks = NoBlocks> = IsBaseBlock<TBlock> extends true ? BlockContentBase : TBlock extends any ? Prettify<{
|
|
25
32
|
_uid: string;
|
|
26
33
|
component: TBlock['name'];
|
|
27
34
|
_editable?: string;
|
|
28
|
-
} &
|
|
35
|
+
} & ContentFields<TBlock['fields'], TBlocks>> : never;
|
|
29
36
|
interface FieldTypeValueMap {
|
|
30
37
|
text: string;
|
|
31
38
|
textarea: string;
|
|
@@ -50,15 +57,15 @@ type IsNestable<T> = T extends {
|
|
|
50
57
|
} ? false : T extends {
|
|
51
58
|
is_nestable: true;
|
|
52
59
|
} ? true : true;
|
|
53
|
-
type
|
|
54
|
-
|
|
60
|
+
type ApplyAllow<TField, TBlocks> = TField extends {
|
|
61
|
+
allow: ReadonlyArray<infer TAllowed extends string>;
|
|
55
62
|
} ? Extract<TBlocks, {
|
|
56
|
-
name:
|
|
63
|
+
name: TAllowed;
|
|
57
64
|
}> : TBlocks extends any ? IsNestable<TBlocks> extends true ? TBlocks : never : never;
|
|
58
65
|
/** Resolves a field definition to its runtime content value type (read). */
|
|
59
66
|
type FieldValue<TField extends Field = Field, TBlocks = NoBlocks> = Prettify<TField extends {
|
|
60
67
|
type: 'bloks';
|
|
61
|
-
} ? [TBlocks] extends [never] ? BlockContentBase[] : [TBlocks] extends [Block] ? BlockContent<
|
|
68
|
+
} ? [TBlocks] extends [never] ? BlockContentBase[] : [TBlocks] extends [Block] ? BlockContent<ApplyAllow<TField, TBlocks>, TBlocks>[] : BlockContentBase[] : FieldTypeValueMap[TField['type']]>;
|
|
62
69
|
//#endregion
|
|
63
70
|
export { BlockContent };
|
|
64
71
|
//# sourceMappingURL=field.d.cts.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AssetFieldValue, BlockContentBase, 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,21 +11,28 @@ 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 {
|
|
15
22
|
required: true;
|
|
16
|
-
} ?
|
|
17
|
-
|
|
23
|
+
} ? never : F['name']]?: FieldValue<F, TBlocks> | null }>;
|
|
24
|
+
/** Input (write) variant of {@link ContentFields}, resolving each field via {@link FieldValueInput}. */
|
|
18
25
|
/**
|
|
19
26
|
* Content object for a single block instance as returned by the Storyblok
|
|
20
27
|
* Content Delivery API. Without a `TBlock` argument, this is the loose
|
|
21
28
|
* runtime shape (any block, `_editable` optional). With a schema-typed
|
|
22
|
-
* `TBlock`, fields are narrowed per the block's
|
|
29
|
+
* `TBlock`, fields are narrowed per the block's `fields`.
|
|
23
30
|
*/
|
|
24
31
|
type BlockContent<TBlock extends Block = Block, TBlocks = NoBlocks> = IsBaseBlock<TBlock> extends true ? BlockContentBase : TBlock extends any ? Prettify<{
|
|
25
32
|
_uid: string;
|
|
26
33
|
component: TBlock['name'];
|
|
27
34
|
_editable?: string;
|
|
28
|
-
} &
|
|
35
|
+
} & ContentFields<TBlock['fields'], TBlocks>> : never;
|
|
29
36
|
interface FieldTypeValueMap {
|
|
30
37
|
text: string;
|
|
31
38
|
textarea: string;
|
|
@@ -50,15 +57,15 @@ type IsNestable<T> = T extends {
|
|
|
50
57
|
} ? false : T extends {
|
|
51
58
|
is_nestable: true;
|
|
52
59
|
} ? true : true;
|
|
53
|
-
type
|
|
54
|
-
|
|
60
|
+
type ApplyAllow<TField, TBlocks> = TField extends {
|
|
61
|
+
allow: ReadonlyArray<infer TAllowed extends string>;
|
|
55
62
|
} ? Extract<TBlocks, {
|
|
56
|
-
name:
|
|
63
|
+
name: TAllowed;
|
|
57
64
|
}> : TBlocks extends any ? IsNestable<TBlocks> extends true ? TBlocks : never : never;
|
|
58
65
|
/** Resolves a field definition to its runtime content value type (read). */
|
|
59
66
|
type FieldValue<TField extends Field = Field, TBlocks = NoBlocks> = Prettify<TField extends {
|
|
60
67
|
type: 'bloks';
|
|
61
|
-
} ? [TBlocks] extends [never] ? BlockContentBase[] : [TBlocks] extends [Block] ? BlockContent<
|
|
68
|
+
} ? [TBlocks] extends [never] ? BlockContentBase[] : [TBlocks] extends [Block] ? BlockContent<ApplyAllow<TField, TBlocks>, TBlocks>[] : BlockContentBase[] : FieldTypeValueMap[TField['type']]>;
|
|
62
69
|
//#endregion
|
|
63
70
|
export { BlockContent };
|
|
64
71
|
//# sourceMappingURL=field.d.mts.map
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storyblok/api-client",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.0.0-alpha.
|
|
4
|
+
"version": "1.0.0-alpha.3",
|
|
5
5
|
"private": false,
|
|
6
6
|
"description": "Storyblok Content Delivery API Client",
|
|
7
7
|
"author": "",
|
|
@@ -41,8 +41,8 @@
|
|
|
41
41
|
"tsdown": "^0.20.3",
|
|
42
42
|
"tsx": "^4.21.0",
|
|
43
43
|
"vitest": "^4.1.3",
|
|
44
|
-
"@storyblok/management-api-client": "1.0.0-alpha.2",
|
|
45
44
|
"@storyblok/eslint-config": "0.5.1",
|
|
45
|
+
"@storyblok/management-api-client": "1.0.0-alpha.3",
|
|
46
46
|
"@storyblok/openapi-codegen": "0.0.1"
|
|
47
47
|
},
|
|
48
48
|
"nx": {
|