@storyblok/schema 0.1.0-alpha.0
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/LICENSE +8 -0
- package/README.md +74 -0
- package/dist/generated/capi/_internal.gen.d.cts +120 -0
- package/dist/generated/capi/_internal.gen.d.mts +120 -0
- package/dist/generated/capi/types.gen.d.cts +181 -0
- package/dist/generated/capi/types.gen.d.mts +181 -0
- package/dist/generated/mapi/_internal.gen.d.cts +683 -0
- package/dist/generated/mapi/_internal.gen.d.mts +683 -0
- package/dist/generated/mapi/types.gen.d.cts +1272 -0
- package/dist/generated/mapi/types.gen.d.mts +1272 -0
- package/dist/generated/overlay/_internal.gen.d.cts +850 -0
- package/dist/generated/overlay/_internal.gen.d.mts +850 -0
- package/dist/generated/types/_utils.d.cts +7 -0
- package/dist/generated/types/_utils.d.mts +7 -0
- package/dist/generated/types/block.d.cts +46 -0
- package/dist/generated/types/block.d.mts +46 -0
- package/dist/generated/types/field.d.cts +74 -0
- package/dist/generated/types/field.d.mts +74 -0
- package/dist/generated/types/mapi-story.d.cts +29 -0
- package/dist/generated/types/mapi-story.d.mts +29 -0
- package/dist/generated/types/story.d.cts +19 -0
- package/dist/generated/types/story.d.mts +19 -0
- package/dist/helpers/create-story-helpers.cjs +42 -0
- package/dist/helpers/create-story-helpers.cjs.map +1 -0
- package/dist/helpers/create-story-helpers.d.cts +50 -0
- package/dist/helpers/create-story-helpers.d.mts +50 -0
- package/dist/helpers/create-story-helpers.mjs +42 -0
- package/dist/helpers/create-story-helpers.mjs.map +1 -0
- package/dist/helpers/define-asset-folder.cjs +46 -0
- package/dist/helpers/define-asset-folder.cjs.map +1 -0
- package/dist/helpers/define-asset-folder.d.cts +33 -0
- package/dist/helpers/define-asset-folder.d.mts +33 -0
- package/dist/helpers/define-asset-folder.mjs +43 -0
- package/dist/helpers/define-asset-folder.mjs.map +1 -0
- package/dist/helpers/define-asset.cjs +60 -0
- package/dist/helpers/define-asset.cjs.map +1 -0
- package/dist/helpers/define-asset.d.cts +32 -0
- package/dist/helpers/define-asset.d.mts +32 -0
- package/dist/helpers/define-asset.mjs +57 -0
- package/dist/helpers/define-asset.mjs.map +1 -0
- package/dist/helpers/define-block-folder.cjs +44 -0
- package/dist/helpers/define-block-folder.cjs.map +1 -0
- package/dist/helpers/define-block-folder.d.cts +34 -0
- package/dist/helpers/define-block-folder.d.mts +34 -0
- package/dist/helpers/define-block-folder.mjs +41 -0
- package/dist/helpers/define-block-folder.mjs.map +1 -0
- package/dist/helpers/define-block.cjs +51 -0
- package/dist/helpers/define-block.cjs.map +1 -0
- package/dist/helpers/define-block.d.cts +62 -0
- package/dist/helpers/define-block.d.mts +62 -0
- package/dist/helpers/define-block.mjs +48 -0
- package/dist/helpers/define-block.mjs.map +1 -0
- package/dist/helpers/define-datasource-entry.cjs +47 -0
- package/dist/helpers/define-datasource-entry.cjs.map +1 -0
- package/dist/helpers/define-datasource-entry.d.cts +49 -0
- package/dist/helpers/define-datasource-entry.d.mts +49 -0
- package/dist/helpers/define-datasource-entry.mjs +43 -0
- package/dist/helpers/define-datasource-entry.mjs.map +1 -0
- package/dist/helpers/define-datasource.cjs +34 -0
- package/dist/helpers/define-datasource.cjs.map +1 -0
- package/dist/helpers/define-datasource.d.cts +42 -0
- package/dist/helpers/define-datasource.d.mts +42 -0
- package/dist/helpers/define-datasource.mjs +31 -0
- package/dist/helpers/define-datasource.mjs.map +1 -0
- package/dist/helpers/define-field.cjs +17 -0
- package/dist/helpers/define-field.cjs.map +1 -0
- package/dist/helpers/define-field.d.cts +99 -0
- package/dist/helpers/define-field.d.mts +99 -0
- package/dist/helpers/define-field.mjs +16 -0
- package/dist/helpers/define-field.mjs.map +1 -0
- package/dist/helpers/define-internal-tag.cjs +41 -0
- package/dist/helpers/define-internal-tag.cjs.map +1 -0
- package/dist/helpers/define-internal-tag.d.cts +34 -0
- package/dist/helpers/define-internal-tag.d.mts +34 -0
- package/dist/helpers/define-internal-tag.mjs +38 -0
- package/dist/helpers/define-internal-tag.mjs.map +1 -0
- package/dist/helpers/define-link.cjs +23 -0
- package/dist/helpers/define-link.cjs.map +1 -0
- package/dist/helpers/define-link.d.cts +32 -0
- package/dist/helpers/define-link.d.mts +32 -0
- package/dist/helpers/define-link.mjs +22 -0
- package/dist/helpers/define-link.mjs.map +1 -0
- package/dist/helpers/define-preset.cjs +44 -0
- package/dist/helpers/define-preset.cjs.map +1 -0
- package/dist/helpers/define-preset.d.cts +35 -0
- package/dist/helpers/define-preset.d.mts +35 -0
- package/dist/helpers/define-preset.mjs +41 -0
- package/dist/helpers/define-preset.mjs.map +1 -0
- package/dist/helpers/define-space.cjs +47 -0
- package/dist/helpers/define-space.cjs.map +1 -0
- package/dist/helpers/define-space.d.cts +31 -0
- package/dist/helpers/define-space.d.mts +31 -0
- package/dist/helpers/define-space.mjs +44 -0
- package/dist/helpers/define-space.mjs.map +1 -0
- package/dist/helpers/define-story.cjs +122 -0
- package/dist/helpers/define-story.cjs.map +1 -0
- package/dist/helpers/define-story.d.cts +135 -0
- package/dist/helpers/define-story.d.mts +135 -0
- package/dist/helpers/define-story.mjs +118 -0
- package/dist/helpers/define-story.mjs.map +1 -0
- package/dist/helpers/define-tag.cjs +13 -0
- package/dist/helpers/define-tag.cjs.map +1 -0
- package/dist/helpers/define-tag.d.cts +23 -0
- package/dist/helpers/define-tag.d.mts +23 -0
- package/dist/helpers/define-tag.mjs +12 -0
- package/dist/helpers/define-tag.mjs.map +1 -0
- package/dist/helpers/define-user.cjs +50 -0
- package/dist/helpers/define-user.cjs.map +1 -0
- package/dist/helpers/define-user.d.cts +26 -0
- package/dist/helpers/define-user.d.mts +26 -0
- package/dist/helpers/define-user.mjs +48 -0
- package/dist/helpers/define-user.mjs.map +1 -0
- package/dist/helpers/schema-type.d.cts +40 -0
- package/dist/helpers/schema-type.d.mts +40 -0
- package/dist/index.cjs +55 -0
- package/dist/index.d.cts +23 -0
- package/dist/index.d.mts +23 -0
- package/dist/index.mjs +17 -0
- package/dist/utils/prettify.d.cts +9 -0
- package/dist/utils/prettify.d.mts +9 -0
- package/package.json +78 -0
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { AssetFieldValue, Field, MultilinkFieldValue, PluginFieldValue, RichtextFieldValue, TableFieldValue } from "../generated/overlay/_internal.gen.mjs";
|
|
2
|
+
import { Block } from "../generated/types/block.mjs";
|
|
3
|
+
import { Prettify } from "../utils/prettify.mjs";
|
|
4
|
+
|
|
5
|
+
//#region src/helpers/define-field.d.ts
|
|
6
|
+
/** Loose variant of the generated `BlokContent` with `_uid` optional — used as the fallback for write operations when no block union is provided. */
|
|
7
|
+
type BlokContentLoose = {
|
|
8
|
+
_uid?: string;
|
|
9
|
+
component: string;
|
|
10
|
+
_editable?: string | undefined;
|
|
11
|
+
} & {
|
|
12
|
+
[key: string]: string | number | boolean | Array<string | AssetFieldValue | BlokContentLoose> | AssetFieldValue | MultilinkFieldValue | TableFieldValue | RichtextFieldValue | PluginFieldValue | undefined;
|
|
13
|
+
};
|
|
14
|
+
/** Keys in a schema record that have `required: true`. */
|
|
15
|
+
type RequiredFieldKeys<T> = { [K in keyof T]: T[K] extends {
|
|
16
|
+
required: true;
|
|
17
|
+
} ? K : never }[keyof T];
|
|
18
|
+
/** Keys in a schema record that do NOT have `required: true`. */
|
|
19
|
+
type OptionalFieldKeys<T> = Exclude<keyof T, RequiredFieldKeys<T>>;
|
|
20
|
+
/**
|
|
21
|
+
* Builds the content object for a single block instance as returned by the
|
|
22
|
+
* Storyblok Content Delivery API. Includes `_uid` (always present in API
|
|
23
|
+
* responses) and respects required/optional field semantics.
|
|
24
|
+
*
|
|
25
|
+
* For write operations (creating/updating stories), use {@link BlockContentInput}
|
|
26
|
+
* instead, which omits `_uid` since Storyblok generates it automatically.
|
|
27
|
+
*/
|
|
28
|
+
type BlockContent<TBlock extends Block = Block, TBlocks = false> = TBlock extends any ? {
|
|
29
|
+
_uid: string;
|
|
30
|
+
component: TBlock['name'];
|
|
31
|
+
} & { [K in RequiredFieldKeys<TBlock['schema']>]: FieldValue<NonNullable<TBlock['schema'][K]>, TBlocks> } & { [K in OptionalFieldKeys<TBlock['schema']>]?: FieldValue<NonNullable<TBlock['schema'][K]>, TBlocks> | null } : never;
|
|
32
|
+
/**
|
|
33
|
+
* Input variant of {@link BlockContent} for write operations (creating/updating
|
|
34
|
+
* stories via the MAPI). `_uid` is optional — Storyblok generates it
|
|
35
|
+
* automatically when omitted. Nested bloks fields also use this input variant
|
|
36
|
+
* so that deeply nested blocks do not require `_uid` either.
|
|
37
|
+
*/
|
|
38
|
+
type BlockContentInput<TBlock extends Block = Block, TBlocks = false> = TBlock extends any ? {
|
|
39
|
+
_uid?: string;
|
|
40
|
+
component: TBlock['name'];
|
|
41
|
+
} & { [K in RequiredFieldKeys<TBlock['schema']>]: FieldValueInput<NonNullable<TBlock['schema'][K]>, TBlocks> } & { [K in OptionalFieldKeys<TBlock['schema']>]?: FieldValueInput<NonNullable<TBlock['schema'][K]>, TBlocks> | null } : never;
|
|
42
|
+
type BlocksFieldValue<TBlock extends Block = Block, TBlocks = false> = BlockContent<TBlock, TBlocks>[];
|
|
43
|
+
/** Union of all valid Storyblok field type discriminants (e.g., `text`, `bloks`). */
|
|
44
|
+
type FieldType = Field['type'];
|
|
45
|
+
/** Maps each field type discriminant to its runtime content value type. */
|
|
46
|
+
interface FieldTypeValueMap {
|
|
47
|
+
text: string;
|
|
48
|
+
textarea: string;
|
|
49
|
+
richtext: RichtextFieldValue;
|
|
50
|
+
markdown: string;
|
|
51
|
+
number: number;
|
|
52
|
+
datetime: string;
|
|
53
|
+
boolean: boolean;
|
|
54
|
+
option: string;
|
|
55
|
+
options: string[];
|
|
56
|
+
asset: AssetFieldValue;
|
|
57
|
+
multiasset: AssetFieldValue[];
|
|
58
|
+
multilink: MultilinkFieldValue;
|
|
59
|
+
bloks: BlockContent[];
|
|
60
|
+
table: TableFieldValue;
|
|
61
|
+
section: never;
|
|
62
|
+
tab: never;
|
|
63
|
+
custom: PluginFieldValue;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Checks whether a block is nestable, defaulting to `true` when
|
|
67
|
+
* `is_nestable` is absent or undefined.
|
|
68
|
+
*/
|
|
69
|
+
type IsNestable<T> = T extends {
|
|
70
|
+
is_nestable: false;
|
|
71
|
+
} ? false : T extends {
|
|
72
|
+
is_nestable: true;
|
|
73
|
+
} ? true : true;
|
|
74
|
+
type ApplyWhitelist<TField, TBlocks> = TField extends {
|
|
75
|
+
component_whitelist: ReadonlyArray<infer TWhitelisted extends string>;
|
|
76
|
+
} ? TBlocks extends {
|
|
77
|
+
name: TWhitelisted;
|
|
78
|
+
} ? TBlocks : never : TBlocks extends any ? IsNestable<TBlocks> extends true ? TBlocks : never : never;
|
|
79
|
+
/** Resolves a field definition to its runtime content value type (read). */
|
|
80
|
+
type FieldValue<TField extends Field = Field, TBlocks = false> = Prettify<TField extends {
|
|
81
|
+
type: 'bloks';
|
|
82
|
+
} ? [TBlocks] extends [never] ? BlockContent[] : [TBlocks] extends [Block] ? BlockContent<ApplyWhitelist<TField, TBlocks>, TBlocks>[] : BlockContent[] : FieldTypeValueMap[TField['type']]>;
|
|
83
|
+
/** Resolves a field definition to its input value type (write). Nested bloks use {@link BlockContentInput}. */
|
|
84
|
+
type FieldValueInput<TField extends Field = Field, TBlocks = false> = Prettify<TField extends {
|
|
85
|
+
type: 'bloks';
|
|
86
|
+
} ? [TBlocks] extends [never] ? BlokContentLoose[] : [TBlocks] extends [Block] ? BlockContentInput<ApplyWhitelist<TField, TBlocks>, TBlocks>[] : BlokContentLoose[] : FieldTypeValueMap[TField['type']]>;
|
|
87
|
+
/**
|
|
88
|
+
* Returns a {@link Field} stamped with the given `name`. Use inside a
|
|
89
|
+
* {@link defineBlock} `schema` array — `pos` is inferred from array index.
|
|
90
|
+
*
|
|
91
|
+
* @example
|
|
92
|
+
* defineField('headline', { type: 'text', max_length: 100, required: true });
|
|
93
|
+
*/
|
|
94
|
+
declare const defineField: <const TName extends string, const TField extends Field>(name: TName, field: TField) => Omit<TField, "name"> & {
|
|
95
|
+
name: TName;
|
|
96
|
+
};
|
|
97
|
+
//#endregion
|
|
98
|
+
export { BlockContent, BlockContentInput, BlocksFieldValue, FieldType, FieldValue, FieldValueInput, defineField };
|
|
99
|
+
//# sourceMappingURL=define-field.d.mts.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
//#region src/helpers/define-field.ts
|
|
2
|
+
/**
|
|
3
|
+
* Returns a {@link Field} stamped with the given `name`. Use inside a
|
|
4
|
+
* {@link defineBlock} `schema` array — `pos` is inferred from array index.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* defineField('headline', { type: 'text', max_length: 100, required: true });
|
|
8
|
+
*/
|
|
9
|
+
const defineField = (name, field) => ({
|
|
10
|
+
...field,
|
|
11
|
+
name
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
//#endregion
|
|
15
|
+
export { defineField };
|
|
16
|
+
//# sourceMappingURL=define-field.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"define-field.mjs","names":[],"sources":["../../src/helpers/define-field.ts"],"sourcesContent":["import type {\n AssetFieldValue,\n Field,\n MultilinkFieldValue,\n PluginFieldValue,\n RichtextFieldValue,\n TableFieldValue,\n} from '../generated/types/field';\nimport type { Block } from './define-block';\nimport type { Prettify } from '../utils/prettify';\n\nexport type { Field };\n\n/** Loose variant of the generated `BlokContent` with `_uid` optional — used as the fallback for write operations when no block union is provided. */\ntype BlokContentLoose = {\n _uid?: string;\n component: string;\n _editable?: string | undefined;\n} & {\n [key: string]:\n | string\n | number\n | boolean\n | Array<string | AssetFieldValue | BlokContentLoose>\n | AssetFieldValue\n | MultilinkFieldValue\n | TableFieldValue\n | RichtextFieldValue\n | PluginFieldValue\n | undefined;\n};\n\n/** Keys in a schema record that have `required: true`. */\ntype RequiredFieldKeys<T> = {\n [K in keyof T]: T[K] extends { required: true } ? K : never\n}[keyof T];\n\n/** Keys in a schema record that do NOT have `required: true`. */\ntype OptionalFieldKeys<T> = Exclude<keyof T, RequiredFieldKeys<T>>;\n\n/**\n * Builds the content object for a single block instance as returned by the\n * Storyblok Content Delivery API. Includes `_uid` (always present in API\n * responses) and respects required/optional field semantics.\n *\n * For write operations (creating/updating stories), use {@link BlockContentInput}\n * instead, which omits `_uid` since Storyblok generates it automatically.\n */\nexport type BlockContent<TBlock extends Block = Block, TBlocks = false> = TBlock extends any\n ? { _uid: string; component: TBlock['name'] }\n & {\n [K in RequiredFieldKeys<TBlock['schema']>]: FieldValue<NonNullable<TBlock['schema'][K]>, TBlocks>\n }\n & {\n [K in OptionalFieldKeys<TBlock['schema']>]?: FieldValue<NonNullable<TBlock['schema'][K]>, TBlocks> | null\n }\n : never;\n\n/**\n * Input variant of {@link BlockContent} for write operations (creating/updating\n * stories via the MAPI). `_uid` is optional — Storyblok generates it\n * automatically when omitted. Nested bloks fields also use this input variant\n * so that deeply nested blocks do not require `_uid` either.\n */\nexport type BlockContentInput<TBlock extends Block = Block, TBlocks = false> = TBlock extends any\n ? { _uid?: string; component: TBlock['name'] }\n & {\n [K in RequiredFieldKeys<TBlock['schema']>]: FieldValueInput<NonNullable<TBlock['schema'][K]>, TBlocks>\n }\n & {\n [K in OptionalFieldKeys<TBlock['schema']>]?: FieldValueInput<NonNullable<TBlock['schema'][K]>, TBlocks> | null\n }\n : never;\n\nexport type BlocksFieldValue<\n TBlock extends Block = Block,\n TBlocks = false,\n> = BlockContent<TBlock, TBlocks>[];\n\nexport type { AssetFieldValue, MultilinkFieldValue, PluginFieldValue, RichtextFieldValue, TableFieldValue };\n\n/** Union of all valid Storyblok field type discriminants (e.g., `text`, `bloks`). */\nexport type FieldType = Field['type'];\n\n/** Maps each field type discriminant to its runtime content value type. */\ninterface FieldTypeValueMap {\n text: string;\n textarea: string;\n richtext: RichtextFieldValue;\n markdown: string;\n number: number;\n datetime: string;\n boolean: boolean;\n option: string;\n options: string[];\n asset: AssetFieldValue;\n multiasset: AssetFieldValue[];\n multilink: MultilinkFieldValue;\n bloks: BlockContent[];\n table: TableFieldValue;\n section: never;\n tab: never;\n custom: PluginFieldValue;\n}\n\n/**\n * Checks whether a block is nestable, defaulting to `true` when\n * `is_nestable` is absent or undefined.\n */\ntype IsNestable<T> =\n T extends { is_nestable: false } ? false\n : T extends { is_nestable: true } ? true\n : true; // default: nestable when is_nestable is not specified\n\ntype ApplyWhitelist<TField, TBlocks> = TField extends { component_whitelist: ReadonlyArray<infer TWhitelisted extends string> }\n // With whitelist: filter by block name (distributive over TBlocks)\n ? TBlocks extends { name: TWhitelisted } ? TBlocks : never\n // No whitelist: filter by nestability (distributive over TBlocks)\n : TBlocks extends any\n ? IsNestable<TBlocks> extends true ? TBlocks : never\n : never;\n\n/** Resolves a field definition to its runtime content value type (read). */\nexport type FieldValue<\n TField extends Field = Field,\n TBlocks = false,\n> = Prettify<\n TField extends { type: 'bloks' }\n // Bloks field — guard against `never` first (it satisfies `[never] extends [X]`\n // for all X, which would incorrectly enter the typed path with empty results).\n ? [TBlocks] extends [never]\n ? BlockContent[]\n : [TBlocks] extends [Block]\n ? BlockContent<ApplyWhitelist<TField, TBlocks>, TBlocks>[]\n : BlockContent[]\n // No bloks field\n : FieldTypeValueMap[TField['type']]\n>;\n\n/** Resolves a field definition to its input value type (write). Nested bloks use {@link BlockContentInput}. */\nexport type FieldValueInput<\n TField extends Field = Field,\n TBlocks = false,\n> = Prettify<\n TField extends { type: 'bloks' }\n ? [TBlocks] extends [never]\n ? BlokContentLoose[]\n : [TBlocks] extends [Block]\n ? BlockContentInput<ApplyWhitelist<TField, TBlocks>, TBlocks>[]\n : BlokContentLoose[]\n : FieldTypeValueMap[TField['type']]\n>;\n\n/**\n * Returns a {@link Field} stamped with the given `name`. Use inside a\n * {@link defineBlock} `schema` array — `pos` is inferred from array index.\n *\n * @example\n * defineField('headline', { type: 'text', max_length: 100, required: true });\n */\nexport const defineField = <\n const TName extends string,\n const TField extends Field,\n>(\n name: TName,\n field: TField,\n): Omit<TField, 'name'> & { name: TName } => ({ ...field, name });\n"],"mappings":";;;;;;;;AAgKA,MAAa,eAIX,MACA,WAC4C;CAAE,GAAG;CAAO;CAAM"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/helpers/define-internal-tag.ts
|
|
3
|
+
const INTERNAL_TAG_DEFAULTS = {
|
|
4
|
+
id: 1,
|
|
5
|
+
object_type: "asset"
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Defines an internal tag for the MAPI.
|
|
9
|
+
* API-assigned fields (`id`) are optional and filled with safe defaults.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* import { defineInternalTag } from '@storyblok/schema';
|
|
13
|
+
* const tag = defineInternalTag({ name: 'hero' });
|
|
14
|
+
*/
|
|
15
|
+
const defineInternalTag = (internalTag) => ({
|
|
16
|
+
...INTERNAL_TAG_DEFAULTS,
|
|
17
|
+
...internalTag,
|
|
18
|
+
object_type: internalTag.object_type ?? INTERNAL_TAG_DEFAULTS.object_type
|
|
19
|
+
});
|
|
20
|
+
/**
|
|
21
|
+
* Defines an internal tag creation payload for the MAPI.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* import { defineInternalTagCreate } from '@storyblok/schema';
|
|
25
|
+
* const payload = defineInternalTagCreate({ name: 'hero', object_type: 'asset' });
|
|
26
|
+
*/
|
|
27
|
+
const defineInternalTagCreate = (internalTag) => internalTag;
|
|
28
|
+
/**
|
|
29
|
+
* Defines an internal tag update payload for the MAPI.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* import { defineInternalTagUpdate } from '@storyblok/schema';
|
|
33
|
+
* const payload = defineInternalTagUpdate({ name: 'hero-image' });
|
|
34
|
+
*/
|
|
35
|
+
const defineInternalTagUpdate = (internalTag) => internalTag;
|
|
36
|
+
|
|
37
|
+
//#endregion
|
|
38
|
+
exports.defineInternalTag = defineInternalTag;
|
|
39
|
+
exports.defineInternalTagCreate = defineInternalTagCreate;
|
|
40
|
+
exports.defineInternalTagUpdate = defineInternalTagUpdate;
|
|
41
|
+
//# sourceMappingURL=define-internal-tag.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"define-internal-tag.cjs","names":[],"sources":["../../src/helpers/define-internal-tag.ts"],"sourcesContent":["import type { InternalTag, InternalTagCreate, InternalTagUpdate } from '../generated/mapi/types.gen';\n\nexport type { InternalTag, InternalTagCreate, InternalTagUpdate };\n\nconst INTERNAL_TAG_DEFAULTS = {\n id: 1,\n object_type: 'asset' as const,\n};\n\ntype InternalTagInput = { name: string } & Partial<Omit<InternalTag, 'name'>>;\n\n/**\n * Defines an internal tag for the MAPI.\n * API-assigned fields (`id`) are optional and filled with safe defaults.\n *\n * @example\n * import { defineInternalTag } from '@storyblok/schema';\n * const tag = defineInternalTag({ name: 'hero' });\n */\nexport const defineInternalTag = (internalTag: InternalTagInput): InternalTag => ({\n ...INTERNAL_TAG_DEFAULTS,\n ...internalTag,\n object_type: internalTag.object_type ?? INTERNAL_TAG_DEFAULTS.object_type,\n});\n\n/**\n * Defines an internal tag creation payload for the MAPI.\n *\n * @example\n * import { defineInternalTagCreate } from '@storyblok/schema';\n * const payload = defineInternalTagCreate({ name: 'hero', object_type: 'asset' });\n */\nexport const defineInternalTagCreate = (internalTag: InternalTagCreate): InternalTagCreate => internalTag;\n\n/**\n * Defines an internal tag update payload for the MAPI.\n *\n * @example\n * import { defineInternalTagUpdate } from '@storyblok/schema';\n * const payload = defineInternalTagUpdate({ name: 'hero-image' });\n */\nexport const defineInternalTagUpdate = (internalTag: InternalTagUpdate): InternalTagUpdate => internalTag;\n"],"mappings":";;AAIA,MAAM,wBAAwB;CAC5B,IAAI;CACJ,aAAa;CACd;;;;;;;;;AAYD,MAAa,qBAAqB,iBAAgD;CAChF,GAAG;CACH,GAAG;CACH,aAAa,YAAY,eAAe,sBAAsB;CAC/D;;;;;;;;AASD,MAAa,2BAA2B,gBAAsD;;;;;;;;AAS9F,MAAa,2BAA2B,gBAAsD"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { InternalTag, InternalTagCreate, InternalTagUpdate } from "../generated/mapi/types.gen.cjs";
|
|
2
|
+
|
|
3
|
+
//#region src/helpers/define-internal-tag.d.ts
|
|
4
|
+
type InternalTagInput = {
|
|
5
|
+
name: string;
|
|
6
|
+
} & Partial<Omit<InternalTag, 'name'>>;
|
|
7
|
+
/**
|
|
8
|
+
* Defines an internal tag for the MAPI.
|
|
9
|
+
* API-assigned fields (`id`) are optional and filled with safe defaults.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* import { defineInternalTag } from '@storyblok/schema';
|
|
13
|
+
* const tag = defineInternalTag({ name: 'hero' });
|
|
14
|
+
*/
|
|
15
|
+
declare const defineInternalTag: (internalTag: InternalTagInput) => InternalTag;
|
|
16
|
+
/**
|
|
17
|
+
* Defines an internal tag creation payload for the MAPI.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* import { defineInternalTagCreate } from '@storyblok/schema';
|
|
21
|
+
* const payload = defineInternalTagCreate({ name: 'hero', object_type: 'asset' });
|
|
22
|
+
*/
|
|
23
|
+
declare const defineInternalTagCreate: (internalTag: InternalTagCreate) => InternalTagCreate;
|
|
24
|
+
/**
|
|
25
|
+
* Defines an internal tag update payload for the MAPI.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* import { defineInternalTagUpdate } from '@storyblok/schema';
|
|
29
|
+
* const payload = defineInternalTagUpdate({ name: 'hero-image' });
|
|
30
|
+
*/
|
|
31
|
+
declare const defineInternalTagUpdate: (internalTag: InternalTagUpdate) => InternalTagUpdate;
|
|
32
|
+
//#endregion
|
|
33
|
+
export { defineInternalTag, defineInternalTagCreate, defineInternalTagUpdate };
|
|
34
|
+
//# sourceMappingURL=define-internal-tag.d.cts.map
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { InternalTag, InternalTagCreate, InternalTagUpdate } from "../generated/mapi/types.gen.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/helpers/define-internal-tag.d.ts
|
|
4
|
+
type InternalTagInput = {
|
|
5
|
+
name: string;
|
|
6
|
+
} & Partial<Omit<InternalTag, 'name'>>;
|
|
7
|
+
/**
|
|
8
|
+
* Defines an internal tag for the MAPI.
|
|
9
|
+
* API-assigned fields (`id`) are optional and filled with safe defaults.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* import { defineInternalTag } from '@storyblok/schema';
|
|
13
|
+
* const tag = defineInternalTag({ name: 'hero' });
|
|
14
|
+
*/
|
|
15
|
+
declare const defineInternalTag: (internalTag: InternalTagInput) => InternalTag;
|
|
16
|
+
/**
|
|
17
|
+
* Defines an internal tag creation payload for the MAPI.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* import { defineInternalTagCreate } from '@storyblok/schema';
|
|
21
|
+
* const payload = defineInternalTagCreate({ name: 'hero', object_type: 'asset' });
|
|
22
|
+
*/
|
|
23
|
+
declare const defineInternalTagCreate: (internalTag: InternalTagCreate) => InternalTagCreate;
|
|
24
|
+
/**
|
|
25
|
+
* Defines an internal tag update payload for the MAPI.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* import { defineInternalTagUpdate } from '@storyblok/schema';
|
|
29
|
+
* const payload = defineInternalTagUpdate({ name: 'hero-image' });
|
|
30
|
+
*/
|
|
31
|
+
declare const defineInternalTagUpdate: (internalTag: InternalTagUpdate) => InternalTagUpdate;
|
|
32
|
+
//#endregion
|
|
33
|
+
export { defineInternalTag, defineInternalTagCreate, defineInternalTagUpdate };
|
|
34
|
+
//# sourceMappingURL=define-internal-tag.d.mts.map
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
//#region src/helpers/define-internal-tag.ts
|
|
2
|
+
const INTERNAL_TAG_DEFAULTS = {
|
|
3
|
+
id: 1,
|
|
4
|
+
object_type: "asset"
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* Defines an internal tag for the MAPI.
|
|
8
|
+
* API-assigned fields (`id`) are optional and filled with safe defaults.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* import { defineInternalTag } from '@storyblok/schema';
|
|
12
|
+
* const tag = defineInternalTag({ name: 'hero' });
|
|
13
|
+
*/
|
|
14
|
+
const defineInternalTag = (internalTag) => ({
|
|
15
|
+
...INTERNAL_TAG_DEFAULTS,
|
|
16
|
+
...internalTag,
|
|
17
|
+
object_type: internalTag.object_type ?? INTERNAL_TAG_DEFAULTS.object_type
|
|
18
|
+
});
|
|
19
|
+
/**
|
|
20
|
+
* Defines an internal tag creation payload for the MAPI.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* import { defineInternalTagCreate } from '@storyblok/schema';
|
|
24
|
+
* const payload = defineInternalTagCreate({ name: 'hero', object_type: 'asset' });
|
|
25
|
+
*/
|
|
26
|
+
const defineInternalTagCreate = (internalTag) => internalTag;
|
|
27
|
+
/**
|
|
28
|
+
* Defines an internal tag update payload for the MAPI.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* import { defineInternalTagUpdate } from '@storyblok/schema';
|
|
32
|
+
* const payload = defineInternalTagUpdate({ name: 'hero-image' });
|
|
33
|
+
*/
|
|
34
|
+
const defineInternalTagUpdate = (internalTag) => internalTag;
|
|
35
|
+
|
|
36
|
+
//#endregion
|
|
37
|
+
export { defineInternalTag, defineInternalTagCreate, defineInternalTagUpdate };
|
|
38
|
+
//# sourceMappingURL=define-internal-tag.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"define-internal-tag.mjs","names":[],"sources":["../../src/helpers/define-internal-tag.ts"],"sourcesContent":["import type { InternalTag, InternalTagCreate, InternalTagUpdate } from '../generated/mapi/types.gen';\n\nexport type { InternalTag, InternalTagCreate, InternalTagUpdate };\n\nconst INTERNAL_TAG_DEFAULTS = {\n id: 1,\n object_type: 'asset' as const,\n};\n\ntype InternalTagInput = { name: string } & Partial<Omit<InternalTag, 'name'>>;\n\n/**\n * Defines an internal tag for the MAPI.\n * API-assigned fields (`id`) are optional and filled with safe defaults.\n *\n * @example\n * import { defineInternalTag } from '@storyblok/schema';\n * const tag = defineInternalTag({ name: 'hero' });\n */\nexport const defineInternalTag = (internalTag: InternalTagInput): InternalTag => ({\n ...INTERNAL_TAG_DEFAULTS,\n ...internalTag,\n object_type: internalTag.object_type ?? INTERNAL_TAG_DEFAULTS.object_type,\n});\n\n/**\n * Defines an internal tag creation payload for the MAPI.\n *\n * @example\n * import { defineInternalTagCreate } from '@storyblok/schema';\n * const payload = defineInternalTagCreate({ name: 'hero', object_type: 'asset' });\n */\nexport const defineInternalTagCreate = (internalTag: InternalTagCreate): InternalTagCreate => internalTag;\n\n/**\n * Defines an internal tag update payload for the MAPI.\n *\n * @example\n * import { defineInternalTagUpdate } from '@storyblok/schema';\n * const payload = defineInternalTagUpdate({ name: 'hero-image' });\n */\nexport const defineInternalTagUpdate = (internalTag: InternalTagUpdate): InternalTagUpdate => internalTag;\n"],"mappings":";AAIA,MAAM,wBAAwB;CAC5B,IAAI;CACJ,aAAa;CACd;;;;;;;;;AAYD,MAAa,qBAAqB,iBAAgD;CAChF,GAAG;CACH,GAAG;CACH,aAAa,YAAY,eAAe,sBAAsB;CAC/D;;;;;;;;AASD,MAAa,2BAA2B,gBAAsD;;;;;;;;AAS9F,MAAa,2BAA2B,gBAAsD"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/helpers/define-link.ts
|
|
3
|
+
const LINK_DEFAULTS = {
|
|
4
|
+
id: 1,
|
|
5
|
+
uuid: "",
|
|
6
|
+
path: null,
|
|
7
|
+
real_path: "",
|
|
8
|
+
is_folder: false,
|
|
9
|
+
published: false,
|
|
10
|
+
parent_id: 0,
|
|
11
|
+
is_startpage: false,
|
|
12
|
+
position: 0
|
|
13
|
+
};
|
|
14
|
+
function defineLink(link) {
|
|
15
|
+
return {
|
|
16
|
+
...LINK_DEFAULTS,
|
|
17
|
+
...link
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
//#endregion
|
|
22
|
+
exports.defineLink = defineLink;
|
|
23
|
+
//# sourceMappingURL=define-link.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"define-link.cjs","names":[],"sources":["../../src/helpers/define-link.ts"],"sourcesContent":["import type { Link } from '../generated/capi/types.gen';\nimport type { Prettify } from '../utils/prettify';\n\nconst LINK_DEFAULTS = {\n id: 1,\n uuid: '',\n path: null,\n real_path: '',\n is_folder: false,\n published: false,\n parent_id: 0,\n is_startpage: false,\n position: 0,\n};\n\nexport type { Link };\n\n/** Fields that have safe defaults and may be omitted from link input. */\ntype LinkOptional = keyof typeof LINK_DEFAULTS;\n\ntype LinkInput = Prettify<Omit<Link, LinkOptional> & Partial<Pick<Link, LinkOptional>>>;\n\n/**\n * Returns a full {@link Link} with all fields populated. API-assigned\n * fields are optional and default to safe values.\n *\n * @example\n * const link = defineLink({\n * name: 'Home',\n * slug: 'home',\n * });\n */\n// Overload: provides the strict public signature for callers.\nexport function defineLink(link: LinkInput): Link;\n\n// Implementation signature: uses a loose parameter type because\n// TypeScript requires the implementation signature to be assignable\n// to all overloads. Not visible to callers.\nexport function defineLink(link: any) {\n return { ...LINK_DEFAULTS, ...link };\n}\n"],"mappings":";;AAGA,MAAM,gBAAgB;CACpB,IAAI;CACJ,MAAM;CACN,MAAM;CACN,WAAW;CACX,WAAW;CACX,WAAW;CACX,WAAW;CACX,cAAc;CACd,UAAU;CACX;AAyBD,SAAgB,WAAW,MAAW;AACpC,QAAO;EAAE,GAAG;EAAe,GAAG;EAAM"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Prettify } from "../utils/prettify.cjs";
|
|
2
|
+
import { Link } from "../generated/capi/types.gen.cjs";
|
|
3
|
+
|
|
4
|
+
//#region src/helpers/define-link.d.ts
|
|
5
|
+
declare const LINK_DEFAULTS: {
|
|
6
|
+
id: number;
|
|
7
|
+
uuid: string;
|
|
8
|
+
path: null;
|
|
9
|
+
real_path: string;
|
|
10
|
+
is_folder: boolean;
|
|
11
|
+
published: boolean;
|
|
12
|
+
parent_id: number;
|
|
13
|
+
is_startpage: boolean;
|
|
14
|
+
position: number;
|
|
15
|
+
};
|
|
16
|
+
/** Fields that have safe defaults and may be omitted from link input. */
|
|
17
|
+
type LinkOptional = keyof typeof LINK_DEFAULTS;
|
|
18
|
+
type LinkInput = Prettify<Omit<Link, LinkOptional> & Partial<Pick<Link, LinkOptional>>>;
|
|
19
|
+
/**
|
|
20
|
+
* Returns a full {@link Link} with all fields populated. API-assigned
|
|
21
|
+
* fields are optional and default to safe values.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* const link = defineLink({
|
|
25
|
+
* name: 'Home',
|
|
26
|
+
* slug: 'home',
|
|
27
|
+
* });
|
|
28
|
+
*/
|
|
29
|
+
declare function defineLink(link: LinkInput): Link;
|
|
30
|
+
//#endregion
|
|
31
|
+
export { defineLink };
|
|
32
|
+
//# sourceMappingURL=define-link.d.cts.map
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Prettify } from "../utils/prettify.mjs";
|
|
2
|
+
import { Link } from "../generated/capi/types.gen.mjs";
|
|
3
|
+
|
|
4
|
+
//#region src/helpers/define-link.d.ts
|
|
5
|
+
declare const LINK_DEFAULTS: {
|
|
6
|
+
id: number;
|
|
7
|
+
uuid: string;
|
|
8
|
+
path: null;
|
|
9
|
+
real_path: string;
|
|
10
|
+
is_folder: boolean;
|
|
11
|
+
published: boolean;
|
|
12
|
+
parent_id: number;
|
|
13
|
+
is_startpage: boolean;
|
|
14
|
+
position: number;
|
|
15
|
+
};
|
|
16
|
+
/** Fields that have safe defaults and may be omitted from link input. */
|
|
17
|
+
type LinkOptional = keyof typeof LINK_DEFAULTS;
|
|
18
|
+
type LinkInput = Prettify<Omit<Link, LinkOptional> & Partial<Pick<Link, LinkOptional>>>;
|
|
19
|
+
/**
|
|
20
|
+
* Returns a full {@link Link} with all fields populated. API-assigned
|
|
21
|
+
* fields are optional and default to safe values.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* const link = defineLink({
|
|
25
|
+
* name: 'Home',
|
|
26
|
+
* slug: 'home',
|
|
27
|
+
* });
|
|
28
|
+
*/
|
|
29
|
+
declare function defineLink(link: LinkInput): Link;
|
|
30
|
+
//#endregion
|
|
31
|
+
export { defineLink };
|
|
32
|
+
//# sourceMappingURL=define-link.d.mts.map
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
//#region src/helpers/define-link.ts
|
|
2
|
+
const LINK_DEFAULTS = {
|
|
3
|
+
id: 1,
|
|
4
|
+
uuid: "",
|
|
5
|
+
path: null,
|
|
6
|
+
real_path: "",
|
|
7
|
+
is_folder: false,
|
|
8
|
+
published: false,
|
|
9
|
+
parent_id: 0,
|
|
10
|
+
is_startpage: false,
|
|
11
|
+
position: 0
|
|
12
|
+
};
|
|
13
|
+
function defineLink(link) {
|
|
14
|
+
return {
|
|
15
|
+
...LINK_DEFAULTS,
|
|
16
|
+
...link
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
//#endregion
|
|
21
|
+
export { defineLink };
|
|
22
|
+
//# sourceMappingURL=define-link.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"define-link.mjs","names":[],"sources":["../../src/helpers/define-link.ts"],"sourcesContent":["import type { Link } from '../generated/capi/types.gen';\nimport type { Prettify } from '../utils/prettify';\n\nconst LINK_DEFAULTS = {\n id: 1,\n uuid: '',\n path: null,\n real_path: '',\n is_folder: false,\n published: false,\n parent_id: 0,\n is_startpage: false,\n position: 0,\n};\n\nexport type { Link };\n\n/** Fields that have safe defaults and may be omitted from link input. */\ntype LinkOptional = keyof typeof LINK_DEFAULTS;\n\ntype LinkInput = Prettify<Omit<Link, LinkOptional> & Partial<Pick<Link, LinkOptional>>>;\n\n/**\n * Returns a full {@link Link} with all fields populated. API-assigned\n * fields are optional and default to safe values.\n *\n * @example\n * const link = defineLink({\n * name: 'Home',\n * slug: 'home',\n * });\n */\n// Overload: provides the strict public signature for callers.\nexport function defineLink(link: LinkInput): Link;\n\n// Implementation signature: uses a loose parameter type because\n// TypeScript requires the implementation signature to be assignable\n// to all overloads. Not visible to callers.\nexport function defineLink(link: any) {\n return { ...LINK_DEFAULTS, ...link };\n}\n"],"mappings":";AAGA,MAAM,gBAAgB;CACpB,IAAI;CACJ,MAAM;CACN,MAAM;CACN,WAAW;CACX,WAAW;CACX,WAAW;CACX,WAAW;CACX,cAAc;CACd,UAAU;CACX;AAyBD,SAAgB,WAAW,MAAW;AACpC,QAAO;EAAE,GAAG;EAAe,GAAG;EAAM"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/helpers/define-preset.ts
|
|
3
|
+
const PRESET_DEFAULTS = {
|
|
4
|
+
id: 1,
|
|
5
|
+
space_id: 1,
|
|
6
|
+
preset: null,
|
|
7
|
+
created_at: "",
|
|
8
|
+
updated_at: ""
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Defines a preset for the MAPI.
|
|
12
|
+
* API-assigned fields (`id`) are optional and filled with safe defaults.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* import { definePreset } from '@storyblok/schema';
|
|
16
|
+
* const preset = definePreset({ name: 'Hero Dark', component_id: 42 });
|
|
17
|
+
*/
|
|
18
|
+
const definePreset = (preset) => ({
|
|
19
|
+
...PRESET_DEFAULTS,
|
|
20
|
+
...preset,
|
|
21
|
+
preset: preset.preset ?? PRESET_DEFAULTS.preset
|
|
22
|
+
});
|
|
23
|
+
/**
|
|
24
|
+
* Defines a preset creation payload for the MAPI.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* import { definePresetCreate } from '@storyblok/schema';
|
|
28
|
+
* const payload = definePresetCreate({ name: 'Hero Dark', component_id: 42 });
|
|
29
|
+
*/
|
|
30
|
+
const definePresetCreate = (preset) => preset;
|
|
31
|
+
/**
|
|
32
|
+
* Defines a preset update payload for the MAPI.
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* import { definePresetUpdate } from '@storyblok/schema';
|
|
36
|
+
* const payload = definePresetUpdate({ name: 'Hero Light' });
|
|
37
|
+
*/
|
|
38
|
+
const definePresetUpdate = (preset) => preset;
|
|
39
|
+
|
|
40
|
+
//#endregion
|
|
41
|
+
exports.definePreset = definePreset;
|
|
42
|
+
exports.definePresetCreate = definePresetCreate;
|
|
43
|
+
exports.definePresetUpdate = definePresetUpdate;
|
|
44
|
+
//# sourceMappingURL=define-preset.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"define-preset.cjs","names":[],"sources":["../../src/helpers/define-preset.ts"],"sourcesContent":["import type { Preset, PresetCreate, PresetUpdate } from '../generated/mapi/types.gen';\n\nexport type { Preset, PresetCreate, PresetUpdate };\n\nconst PRESET_DEFAULTS = {\n id: 1,\n space_id: 1,\n preset: null,\n created_at: '',\n updated_at: '',\n};\n\ntype PresetInput = { name: string; component_id: number } & Partial<Omit<Preset, 'name' | 'component_id'>>;\n\n/**\n * Defines a preset for the MAPI.\n * API-assigned fields (`id`) are optional and filled with safe defaults.\n *\n * @example\n * import { definePreset } from '@storyblok/schema';\n * const preset = definePreset({ name: 'Hero Dark', component_id: 42 });\n */\nexport const definePreset = (preset: PresetInput): Preset => ({\n ...PRESET_DEFAULTS,\n ...preset,\n preset: preset.preset ?? PRESET_DEFAULTS.preset,\n});\n\n/**\n * Defines a preset creation payload for the MAPI.\n *\n * @example\n * import { definePresetCreate } from '@storyblok/schema';\n * const payload = definePresetCreate({ name: 'Hero Dark', component_id: 42 });\n */\nexport const definePresetCreate = (preset: PresetCreate): PresetCreate => preset;\n\n/**\n * Defines a preset update payload for the MAPI.\n *\n * @example\n * import { definePresetUpdate } from '@storyblok/schema';\n * const payload = definePresetUpdate({ name: 'Hero Light' });\n */\nexport const definePresetUpdate = (preset: PresetUpdate): PresetUpdate => preset;\n"],"mappings":";;AAIA,MAAM,kBAAkB;CACtB,IAAI;CACJ,UAAU;CACV,QAAQ;CACR,YAAY;CACZ,YAAY;CACb;;;;;;;;;AAYD,MAAa,gBAAgB,YAAiC;CAC5D,GAAG;CACH,GAAG;CACH,QAAQ,OAAO,UAAU,gBAAgB;CAC1C;;;;;;;;AASD,MAAa,sBAAsB,WAAuC;;;;;;;;AAS1E,MAAa,sBAAsB,WAAuC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Preset, PresetCreate, PresetUpdate } from "../generated/mapi/types.gen.cjs";
|
|
2
|
+
|
|
3
|
+
//#region src/helpers/define-preset.d.ts
|
|
4
|
+
type PresetInput = {
|
|
5
|
+
name: string;
|
|
6
|
+
component_id: number;
|
|
7
|
+
} & Partial<Omit<Preset, 'name' | 'component_id'>>;
|
|
8
|
+
/**
|
|
9
|
+
* Defines a preset for the MAPI.
|
|
10
|
+
* API-assigned fields (`id`) are optional and filled with safe defaults.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* import { definePreset } from '@storyblok/schema';
|
|
14
|
+
* const preset = definePreset({ name: 'Hero Dark', component_id: 42 });
|
|
15
|
+
*/
|
|
16
|
+
declare const definePreset: (preset: PresetInput) => Preset;
|
|
17
|
+
/**
|
|
18
|
+
* Defines a preset creation payload for the MAPI.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* import { definePresetCreate } from '@storyblok/schema';
|
|
22
|
+
* const payload = definePresetCreate({ name: 'Hero Dark', component_id: 42 });
|
|
23
|
+
*/
|
|
24
|
+
declare const definePresetCreate: (preset: PresetCreate) => PresetCreate;
|
|
25
|
+
/**
|
|
26
|
+
* Defines a preset update payload for the MAPI.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* import { definePresetUpdate } from '@storyblok/schema';
|
|
30
|
+
* const payload = definePresetUpdate({ name: 'Hero Light' });
|
|
31
|
+
*/
|
|
32
|
+
declare const definePresetUpdate: (preset: PresetUpdate) => PresetUpdate;
|
|
33
|
+
//#endregion
|
|
34
|
+
export { definePreset, definePresetCreate, definePresetUpdate };
|
|
35
|
+
//# sourceMappingURL=define-preset.d.cts.map
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Preset, PresetCreate, PresetUpdate } from "../generated/mapi/types.gen.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/helpers/define-preset.d.ts
|
|
4
|
+
type PresetInput = {
|
|
5
|
+
name: string;
|
|
6
|
+
component_id: number;
|
|
7
|
+
} & Partial<Omit<Preset, 'name' | 'component_id'>>;
|
|
8
|
+
/**
|
|
9
|
+
* Defines a preset for the MAPI.
|
|
10
|
+
* API-assigned fields (`id`) are optional and filled with safe defaults.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* import { definePreset } from '@storyblok/schema';
|
|
14
|
+
* const preset = definePreset({ name: 'Hero Dark', component_id: 42 });
|
|
15
|
+
*/
|
|
16
|
+
declare const definePreset: (preset: PresetInput) => Preset;
|
|
17
|
+
/**
|
|
18
|
+
* Defines a preset creation payload for the MAPI.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* import { definePresetCreate } from '@storyblok/schema';
|
|
22
|
+
* const payload = definePresetCreate({ name: 'Hero Dark', component_id: 42 });
|
|
23
|
+
*/
|
|
24
|
+
declare const definePresetCreate: (preset: PresetCreate) => PresetCreate;
|
|
25
|
+
/**
|
|
26
|
+
* Defines a preset update payload for the MAPI.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* import { definePresetUpdate } from '@storyblok/schema';
|
|
30
|
+
* const payload = definePresetUpdate({ name: 'Hero Light' });
|
|
31
|
+
*/
|
|
32
|
+
declare const definePresetUpdate: (preset: PresetUpdate) => PresetUpdate;
|
|
33
|
+
//#endregion
|
|
34
|
+
export { definePreset, definePresetCreate, definePresetUpdate };
|
|
35
|
+
//# sourceMappingURL=define-preset.d.mts.map
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
//#region src/helpers/define-preset.ts
|
|
2
|
+
const PRESET_DEFAULTS = {
|
|
3
|
+
id: 1,
|
|
4
|
+
space_id: 1,
|
|
5
|
+
preset: null,
|
|
6
|
+
created_at: "",
|
|
7
|
+
updated_at: ""
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Defines a preset for the MAPI.
|
|
11
|
+
* API-assigned fields (`id`) are optional and filled with safe defaults.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* import { definePreset } from '@storyblok/schema';
|
|
15
|
+
* const preset = definePreset({ name: 'Hero Dark', component_id: 42 });
|
|
16
|
+
*/
|
|
17
|
+
const definePreset = (preset) => ({
|
|
18
|
+
...PRESET_DEFAULTS,
|
|
19
|
+
...preset,
|
|
20
|
+
preset: preset.preset ?? PRESET_DEFAULTS.preset
|
|
21
|
+
});
|
|
22
|
+
/**
|
|
23
|
+
* Defines a preset creation payload for the MAPI.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* import { definePresetCreate } from '@storyblok/schema';
|
|
27
|
+
* const payload = definePresetCreate({ name: 'Hero Dark', component_id: 42 });
|
|
28
|
+
*/
|
|
29
|
+
const definePresetCreate = (preset) => preset;
|
|
30
|
+
/**
|
|
31
|
+
* Defines a preset update payload for the MAPI.
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* import { definePresetUpdate } from '@storyblok/schema';
|
|
35
|
+
* const payload = definePresetUpdate({ name: 'Hero Light' });
|
|
36
|
+
*/
|
|
37
|
+
const definePresetUpdate = (preset) => preset;
|
|
38
|
+
|
|
39
|
+
//#endregion
|
|
40
|
+
export { definePreset, definePresetCreate, definePresetUpdate };
|
|
41
|
+
//# sourceMappingURL=define-preset.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"define-preset.mjs","names":[],"sources":["../../src/helpers/define-preset.ts"],"sourcesContent":["import type { Preset, PresetCreate, PresetUpdate } from '../generated/mapi/types.gen';\n\nexport type { Preset, PresetCreate, PresetUpdate };\n\nconst PRESET_DEFAULTS = {\n id: 1,\n space_id: 1,\n preset: null,\n created_at: '',\n updated_at: '',\n};\n\ntype PresetInput = { name: string; component_id: number } & Partial<Omit<Preset, 'name' | 'component_id'>>;\n\n/**\n * Defines a preset for the MAPI.\n * API-assigned fields (`id`) are optional and filled with safe defaults.\n *\n * @example\n * import { definePreset } from '@storyblok/schema';\n * const preset = definePreset({ name: 'Hero Dark', component_id: 42 });\n */\nexport const definePreset = (preset: PresetInput): Preset => ({\n ...PRESET_DEFAULTS,\n ...preset,\n preset: preset.preset ?? PRESET_DEFAULTS.preset,\n});\n\n/**\n * Defines a preset creation payload for the MAPI.\n *\n * @example\n * import { definePresetCreate } from '@storyblok/schema';\n * const payload = definePresetCreate({ name: 'Hero Dark', component_id: 42 });\n */\nexport const definePresetCreate = (preset: PresetCreate): PresetCreate => preset;\n\n/**\n * Defines a preset update payload for the MAPI.\n *\n * @example\n * import { definePresetUpdate } from '@storyblok/schema';\n * const payload = definePresetUpdate({ name: 'Hero Light' });\n */\nexport const definePresetUpdate = (preset: PresetUpdate): PresetUpdate => preset;\n"],"mappings":";AAIA,MAAM,kBAAkB;CACtB,IAAI;CACJ,UAAU;CACV,QAAQ;CACR,YAAY;CACZ,YAAY;CACb;;;;;;;;;AAYD,MAAa,gBAAgB,YAAiC;CAC5D,GAAG;CACH,GAAG;CACH,QAAQ,OAAO,UAAU,gBAAgB;CAC1C;;;;;;;;AASD,MAAa,sBAAsB,WAAuC;;;;;;;;AAS1E,MAAa,sBAAsB,WAAuC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/helpers/define-space.ts
|
|
3
|
+
const SPACE_DEFAULTS = {
|
|
4
|
+
id: 1,
|
|
5
|
+
region: "",
|
|
6
|
+
owner_id: 1,
|
|
7
|
+
updated_at: "",
|
|
8
|
+
created_at: "",
|
|
9
|
+
plan: "",
|
|
10
|
+
plan_level: 0,
|
|
11
|
+
trial: false,
|
|
12
|
+
requires_2fa: false,
|
|
13
|
+
org_requires_2fa: false,
|
|
14
|
+
development_mode: false,
|
|
15
|
+
feature_limit_exceeded_flags: {}
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Defines a space for the MAPI.
|
|
19
|
+
* `name` is required; API-assigned fields (`id`) default to safe values.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* const space = defineSpace({ name: 'My Space' });
|
|
23
|
+
*/
|
|
24
|
+
const defineSpace = (space) => ({
|
|
25
|
+
...SPACE_DEFAULTS,
|
|
26
|
+
...space
|
|
27
|
+
});
|
|
28
|
+
/**
|
|
29
|
+
* Defines a space creation payload for the MAPI.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* const payload = defineSpaceCreate({ name: 'My New Space' });
|
|
33
|
+
*/
|
|
34
|
+
const defineSpaceCreate = (space) => space;
|
|
35
|
+
/**
|
|
36
|
+
* Defines a space update payload for the MAPI.
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* const payload = defineSpaceUpdate({ name: 'Updated Space Name' });
|
|
40
|
+
*/
|
|
41
|
+
const defineSpaceUpdate = (space) => space;
|
|
42
|
+
|
|
43
|
+
//#endregion
|
|
44
|
+
exports.defineSpace = defineSpace;
|
|
45
|
+
exports.defineSpaceCreate = defineSpaceCreate;
|
|
46
|
+
exports.defineSpaceUpdate = defineSpaceUpdate;
|
|
47
|
+
//# sourceMappingURL=define-space.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"define-space.cjs","names":[],"sources":["../../src/helpers/define-space.ts"],"sourcesContent":["import type { Space, SpaceCreate, SpaceUpdate } from '../generated/mapi/types.gen';\n\nexport type { Space, SpaceCreate, SpaceUpdate };\n\nconst SPACE_DEFAULTS = {\n id: 1,\n region: '',\n owner_id: 1,\n updated_at: '',\n created_at: '',\n plan: '',\n plan_level: 0,\n trial: false,\n requires_2fa: false,\n org_requires_2fa: false,\n development_mode: false,\n feature_limit_exceeded_flags: {},\n};\n\ntype SpaceInput = { name: string } & Partial<Omit<Space, 'name'>>;\n\n/**\n * Defines a space for the MAPI.\n * `name` is required; API-assigned fields (`id`) default to safe values.\n *\n * @example\n * const space = defineSpace({ name: 'My Space' });\n */\nexport const defineSpace = (space: SpaceInput): Space => ({ ...SPACE_DEFAULTS, ...space });\n\n/**\n * Defines a space creation payload for the MAPI.\n *\n * @example\n * const payload = defineSpaceCreate({ name: 'My New Space' });\n */\nexport const defineSpaceCreate = (space: SpaceCreate): SpaceCreate => space;\n\n/**\n * Defines a space update payload for the MAPI.\n *\n * @example\n * const payload = defineSpaceUpdate({ name: 'Updated Space Name' });\n */\nexport const defineSpaceUpdate = (space: SpaceUpdate): SpaceUpdate => space;\n"],"mappings":";;AAIA,MAAM,iBAAiB;CACrB,IAAI;CACJ,QAAQ;CACR,UAAU;CACV,YAAY;CACZ,YAAY;CACZ,MAAM;CACN,YAAY;CACZ,OAAO;CACP,cAAc;CACd,kBAAkB;CAClB,kBAAkB;CAClB,8BAA8B,EAAE;CACjC;;;;;;;;AAWD,MAAa,eAAe,WAA8B;CAAE,GAAG;CAAgB,GAAG;CAAO;;;;;;;AAQzF,MAAa,qBAAqB,UAAoC;;;;;;;AAQtE,MAAa,qBAAqB,UAAoC"}
|