@storyblok/schema 0.1.0-alpha.0 → 0.1.0-alpha.2
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/_virtual/_rolldown/runtime.cjs +29 -0
- package/dist/field-plugins/index.cjs +4 -0
- package/dist/field-plugins/index.d.cts +2 -0
- package/dist/field-plugins/index.d.mts +2 -0
- package/dist/field-plugins/index.mjs +3 -0
- package/dist/field-plugins/storyblok-color-field.cjs +32 -0
- package/dist/field-plugins/storyblok-color-field.cjs.map +1 -0
- package/dist/field-plugins/storyblok-color-field.d.cts +16 -0
- package/dist/field-plugins/storyblok-color-field.d.mts +16 -0
- package/dist/field-plugins/storyblok-color-field.mjs +32 -0
- package/dist/field-plugins/storyblok-color-field.mjs.map +1 -0
- package/dist/generated/capi/types.gen.d.cts +1 -126
- package/dist/generated/capi/types.gen.d.mts +1 -126
- package/dist/generated/mapi/_internal.gen.d.cts +1 -171
- package/dist/generated/mapi/_internal.gen.d.mts +1 -171
- package/dist/generated/overlay/zod.gen.cjs +407 -0
- package/dist/generated/overlay/zod.gen.cjs.map +1 -0
- package/dist/generated/overlay/zod.gen.mjs +402 -0
- package/dist/generated/overlay/zod.gen.mjs.map +1 -0
- package/dist/generated/types/block.d.cts +27 -14
- package/dist/generated/types/block.d.mts +27 -14
- package/dist/generated/types/field.d.cts +48 -17
- package/dist/generated/types/field.d.mts +48 -17
- package/dist/generated/types/mapi-story.d.cts +6 -10
- package/dist/generated/types/mapi-story.d.mts +6 -10
- package/dist/generated/types/story.d.cts +3 -3
- package/dist/generated/types/story.d.mts +3 -3
- package/dist/helpers/define-block.cjs +10 -28
- package/dist/helpers/define-block.cjs.map +1 -1
- package/dist/helpers/define-block.d.cts +14 -31
- package/dist/helpers/define-block.d.mts +14 -31
- package/dist/helpers/define-block.mjs +11 -27
- package/dist/helpers/define-block.mjs.map +1 -1
- package/dist/helpers/define-datasource.cjs +0 -16
- package/dist/helpers/define-datasource.cjs.map +1 -1
- package/dist/helpers/define-datasource.d.cts +14 -23
- package/dist/helpers/define-datasource.d.mts +14 -23
- package/dist/helpers/define-datasource.mjs +1 -15
- package/dist/helpers/define-datasource.mjs.map +1 -1
- package/dist/helpers/define-field-plugin.cjs +21 -0
- package/dist/helpers/define-field-plugin.cjs.map +1 -0
- package/dist/helpers/define-field-plugin.d.cts +33 -0
- package/dist/helpers/define-field-plugin.d.mts +33 -0
- package/dist/helpers/define-field-plugin.mjs +20 -0
- package/dist/helpers/define-field-plugin.mjs.map +1 -0
- package/dist/helpers/define-field.cjs +11 -11
- package/dist/helpers/define-field.cjs.map +1 -1
- package/dist/helpers/define-field.d.cts +46 -85
- package/dist/helpers/define-field.d.mts +46 -85
- package/dist/helpers/define-field.mjs +12 -11
- package/dist/helpers/define-field.mjs.map +1 -1
- package/dist/helpers/define-schema.cjs +22 -0
- package/dist/helpers/define-schema.cjs.map +1 -0
- package/dist/helpers/define-schema.d.cts +28 -0
- package/dist/helpers/define-schema.d.mts +28 -0
- package/dist/helpers/define-schema.mjs +21 -0
- package/dist/helpers/define-schema.mjs.map +1 -0
- package/dist/helpers/schema-type.d.cts +21 -17
- package/dist/helpers/schema-type.d.mts +21 -17
- package/dist/index.cjs +10 -47
- package/dist/index.d.cts +13 -20
- package/dist/index.d.mts +13 -20
- package/dist/index.mjs +8 -15
- package/dist/utils/is-record.cjs +10 -0
- package/dist/utils/is-record.cjs.map +1 -0
- package/dist/utils/is-record.mjs +9 -0
- package/dist/utils/is-record.mjs.map +1 -0
- package/dist/validators/create-story-validator.cjs +37 -0
- package/dist/validators/create-story-validator.cjs.map +1 -0
- package/dist/validators/create-story-validator.d.cts +18 -0
- package/dist/validators/create-story-validator.d.mts +18 -0
- package/dist/validators/create-story-validator.mjs +37 -0
- package/dist/validators/create-story-validator.mjs.map +1 -0
- package/dist/validators/internal-schemas.cjs +1 -0
- package/dist/validators/internal-schemas.mjs +3 -0
- package/dist/validators/shapes.cjs +12 -0
- package/dist/validators/shapes.cjs.map +1 -0
- package/dist/validators/shapes.d.cts +71 -0
- package/dist/validators/shapes.d.mts +71 -0
- package/dist/validators/shapes.mjs +12 -0
- package/dist/validators/shapes.mjs.map +1 -0
- package/dist/validators/types.d.cts +25 -0
- package/dist/validators/types.d.mts +25 -0
- package/dist/validators/validate-schema.cjs +145 -0
- package/dist/validators/validate-schema.cjs.map +1 -0
- package/dist/validators/validate-schema.d.cts +19 -0
- package/dist/validators/validate-schema.d.mts +19 -0
- package/dist/validators/validate-schema.mjs +145 -0
- package/dist/validators/validate-schema.mjs.map +1 -0
- package/dist/validators/validate-story.cjs +285 -0
- package/dist/validators/validate-story.cjs.map +1 -0
- package/dist/validators/validate-story.d.cts +17 -0
- package/dist/validators/validate-story.d.mts +17 -0
- package/dist/validators/validate-story.mjs +284 -0
- package/dist/validators/validate-story.mjs.map +1 -0
- package/package.json +17 -2
- package/dist/generated/mapi/types.gen.d.cts +0 -1272
- package/dist/generated/mapi/types.gen.d.mts +0 -1272
- package/dist/helpers/create-story-helpers.cjs +0 -42
- package/dist/helpers/create-story-helpers.cjs.map +0 -1
- package/dist/helpers/create-story-helpers.d.cts +0 -50
- package/dist/helpers/create-story-helpers.d.mts +0 -50
- package/dist/helpers/create-story-helpers.mjs +0 -42
- package/dist/helpers/create-story-helpers.mjs.map +0 -1
- package/dist/helpers/define-asset-folder.cjs +0 -46
- package/dist/helpers/define-asset-folder.cjs.map +0 -1
- package/dist/helpers/define-asset-folder.d.cts +0 -33
- package/dist/helpers/define-asset-folder.d.mts +0 -33
- package/dist/helpers/define-asset-folder.mjs +0 -43
- package/dist/helpers/define-asset-folder.mjs.map +0 -1
- package/dist/helpers/define-asset.cjs +0 -60
- package/dist/helpers/define-asset.cjs.map +0 -1
- package/dist/helpers/define-asset.d.cts +0 -32
- package/dist/helpers/define-asset.d.mts +0 -32
- package/dist/helpers/define-asset.mjs +0 -57
- package/dist/helpers/define-asset.mjs.map +0 -1
- package/dist/helpers/define-block-folder.cjs +0 -44
- package/dist/helpers/define-block-folder.cjs.map +0 -1
- package/dist/helpers/define-block-folder.d.cts +0 -34
- package/dist/helpers/define-block-folder.d.mts +0 -34
- package/dist/helpers/define-block-folder.mjs +0 -41
- package/dist/helpers/define-block-folder.mjs.map +0 -1
- package/dist/helpers/define-datasource-entry.cjs +0 -47
- package/dist/helpers/define-datasource-entry.cjs.map +0 -1
- package/dist/helpers/define-datasource-entry.d.cts +0 -49
- package/dist/helpers/define-datasource-entry.d.mts +0 -49
- package/dist/helpers/define-datasource-entry.mjs +0 -43
- package/dist/helpers/define-datasource-entry.mjs.map +0 -1
- package/dist/helpers/define-internal-tag.cjs +0 -41
- package/dist/helpers/define-internal-tag.cjs.map +0 -1
- package/dist/helpers/define-internal-tag.d.cts +0 -34
- package/dist/helpers/define-internal-tag.d.mts +0 -34
- package/dist/helpers/define-internal-tag.mjs +0 -38
- package/dist/helpers/define-internal-tag.mjs.map +0 -1
- package/dist/helpers/define-link.cjs +0 -23
- package/dist/helpers/define-link.cjs.map +0 -1
- package/dist/helpers/define-link.d.cts +0 -32
- package/dist/helpers/define-link.d.mts +0 -32
- package/dist/helpers/define-link.mjs +0 -22
- package/dist/helpers/define-link.mjs.map +0 -1
- package/dist/helpers/define-preset.cjs +0 -44
- package/dist/helpers/define-preset.cjs.map +0 -1
- package/dist/helpers/define-preset.d.cts +0 -35
- package/dist/helpers/define-preset.d.mts +0 -35
- package/dist/helpers/define-preset.mjs +0 -41
- package/dist/helpers/define-preset.mjs.map +0 -1
- package/dist/helpers/define-space.cjs +0 -47
- package/dist/helpers/define-space.cjs.map +0 -1
- package/dist/helpers/define-space.d.cts +0 -31
- package/dist/helpers/define-space.d.mts +0 -31
- package/dist/helpers/define-space.mjs +0 -44
- package/dist/helpers/define-space.mjs.map +0 -1
- package/dist/helpers/define-story.cjs +0 -122
- package/dist/helpers/define-story.cjs.map +0 -1
- package/dist/helpers/define-story.d.cts +0 -135
- package/dist/helpers/define-story.d.mts +0 -135
- package/dist/helpers/define-story.mjs +0 -118
- package/dist/helpers/define-story.mjs.map +0 -1
- package/dist/helpers/define-tag.cjs +0 -13
- package/dist/helpers/define-tag.cjs.map +0 -1
- package/dist/helpers/define-tag.d.cts +0 -23
- package/dist/helpers/define-tag.d.mts +0 -23
- package/dist/helpers/define-tag.mjs +0 -12
- package/dist/helpers/define-tag.mjs.map +0 -1
- package/dist/helpers/define-user.cjs +0 -50
- package/dist/helpers/define-user.cjs.map +0 -1
- package/dist/helpers/define-user.d.cts +0 -26
- package/dist/helpers/define-user.d.mts +0 -26
- package/dist/helpers/define-user.mjs +0 -48
- package/dist/helpers/define-user.mjs.map +0 -1
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
import { Block, RootBlock } from "../generated/types/block.mjs";
|
|
2
|
-
import { Prettify } from "../utils/prettify.mjs";
|
|
3
|
-
import { StoryAlternate } from "../generated/capi/types.gen.mjs";
|
|
4
|
-
import { StoryLocalizedPath, StoryTranslatedSlug } from "../generated/mapi/types.gen.mjs";
|
|
5
|
-
import { MapiStory, StoryCreate, StoryUpdate } from "../generated/types/mapi-story.mjs";
|
|
6
|
-
import { Story } from "../generated/types/story.mjs";
|
|
7
|
-
import { BlockContentInput } from "./define-field.mjs";
|
|
8
|
-
|
|
9
|
-
//#region src/helpers/define-story.d.ts
|
|
10
|
-
declare const CAPI_STORY_DEFAULTS: {
|
|
11
|
-
id: number;
|
|
12
|
-
uuid: string;
|
|
13
|
-
created_at: string;
|
|
14
|
-
updated_at: string;
|
|
15
|
-
published_at: null;
|
|
16
|
-
first_published_at: null;
|
|
17
|
-
full_slug: string;
|
|
18
|
-
group_id: string;
|
|
19
|
-
alternates: never[];
|
|
20
|
-
default_full_slug: null;
|
|
21
|
-
release_id: null;
|
|
22
|
-
lang: string;
|
|
23
|
-
slug: string;
|
|
24
|
-
parent_id: number;
|
|
25
|
-
path: null;
|
|
26
|
-
is_startpage: boolean;
|
|
27
|
-
sort_by_date: null;
|
|
28
|
-
tag_list: never[];
|
|
29
|
-
meta_data: null;
|
|
30
|
-
translated_slugs: null;
|
|
31
|
-
position: number;
|
|
32
|
-
};
|
|
33
|
-
declare const MAPI_STORY_DEFAULTS: {
|
|
34
|
-
id: number;
|
|
35
|
-
uuid: string;
|
|
36
|
-
created_at: string;
|
|
37
|
-
updated_at: string;
|
|
38
|
-
published_at: null;
|
|
39
|
-
first_published_at: null;
|
|
40
|
-
full_slug: string;
|
|
41
|
-
group_id: string;
|
|
42
|
-
alternates: never[];
|
|
43
|
-
slug: string;
|
|
44
|
-
parent_id: null;
|
|
45
|
-
parent: null;
|
|
46
|
-
path: null;
|
|
47
|
-
is_folder: boolean;
|
|
48
|
-
is_startpage: boolean;
|
|
49
|
-
sort_by_date: null;
|
|
50
|
-
tag_list: never[];
|
|
51
|
-
meta_data: null;
|
|
52
|
-
translated_slugs: never[];
|
|
53
|
-
translated_stories: never[];
|
|
54
|
-
localized_paths: never[];
|
|
55
|
-
position: number;
|
|
56
|
-
deleted_at: null;
|
|
57
|
-
published: null;
|
|
58
|
-
default_root: null;
|
|
59
|
-
disble_fe_editor: boolean;
|
|
60
|
-
disable_fe_editor: boolean;
|
|
61
|
-
unpublished_changes: null;
|
|
62
|
-
imported_at: null;
|
|
63
|
-
preview_token: {
|
|
64
|
-
token: string;
|
|
65
|
-
timestamp: string;
|
|
66
|
-
};
|
|
67
|
-
pinned: boolean;
|
|
68
|
-
breadcrumbs: never[];
|
|
69
|
-
publish_at: null;
|
|
70
|
-
expire_at: null;
|
|
71
|
-
last_author: null;
|
|
72
|
-
last_author_id: null;
|
|
73
|
-
user_ids: never[];
|
|
74
|
-
space_role_ids: never[];
|
|
75
|
-
can_not_view: null;
|
|
76
|
-
is_scheduled: null;
|
|
77
|
-
scheduled_dates: null;
|
|
78
|
-
ideas: never[];
|
|
79
|
-
favourite_for_user_ids: never[];
|
|
80
|
-
};
|
|
81
|
-
type CapiStoryOptional = keyof typeof CAPI_STORY_DEFAULTS;
|
|
82
|
-
type CapiStoryInput<TBlock extends RootBlock = RootBlock, TBlocks extends Block = never> = Prettify<Omit<Story<TBlock, TBlocks>, CapiStoryOptional | 'content'> & Partial<Pick<Story<TBlock, TBlocks>, CapiStoryOptional>> & {
|
|
83
|
-
content: Omit<BlockContentInput<TBlock, TBlocks>, 'component'>;
|
|
84
|
-
}>;
|
|
85
|
-
/**
|
|
86
|
-
* Returns a full CDN {@link Story} with all fields populated.
|
|
87
|
-
*
|
|
88
|
-
* @example
|
|
89
|
-
* const myStory = defineStory(pageComponent, {
|
|
90
|
-
* name: 'Home',
|
|
91
|
-
* content: { headline: 'Hello World!' },
|
|
92
|
-
* });
|
|
93
|
-
*/
|
|
94
|
-
declare function defineStory<TBlock extends RootBlock, TBlocks extends Block>(component: TBlock, story: CapiStoryInput<TBlock, TBlocks>): Story<TBlock, TBlocks>;
|
|
95
|
-
type MapiStoryOptional = keyof typeof MAPI_STORY_DEFAULTS;
|
|
96
|
-
type MakeMapiStoryInput<TStory extends MapiStory | StoryCreate | StoryUpdate, TBlock extends RootBlock = RootBlock, TBlocks extends Block = never> = Prettify<Omit<TStory, MapiStoryOptional | 'content'> & Partial<Pick<TStory, Extract<MapiStoryOptional, keyof TStory>>> & {
|
|
97
|
-
content: Omit<BlockContentInput<TBlock, TBlocks>, 'component'>;
|
|
98
|
-
}>;
|
|
99
|
-
type MapiStoryInput<TBlock extends RootBlock = RootBlock, TBlocks extends Block = never> = MakeMapiStoryInput<MapiStory, TBlock, TBlocks>;
|
|
100
|
-
type StoryCreateInput<TBlock extends RootBlock = RootBlock, TBlocks extends Block = never> = MakeMapiStoryInput<StoryCreate, TBlock, TBlocks>;
|
|
101
|
-
type StoryUpdateInput<TBlock extends RootBlock = RootBlock, TBlocks extends Block = never> = Prettify<Omit<MakeMapiStoryInput<StoryUpdate, TBlock, TBlocks>, 'content'> & {
|
|
102
|
-
content: Partial<Omit<BlockContentInput<TBlock, TBlocks>, 'component'>>;
|
|
103
|
-
}>;
|
|
104
|
-
/**
|
|
105
|
-
* Returns a full MAPI {@link MapiStory} with all fields populated.
|
|
106
|
-
*
|
|
107
|
-
* @example
|
|
108
|
-
* const myStory = defineMapiStory(pageComponent, {
|
|
109
|
-
* name: 'My Page',
|
|
110
|
-
* content: { headline: 'Hello World!' },
|
|
111
|
-
* });
|
|
112
|
-
*/
|
|
113
|
-
declare function defineMapiStory<const TBlock extends RootBlock, const TBlocks extends Block = never>(component: TBlock, story: MapiStoryInput<TBlock, TBlocks>): MapiStory<TBlock, TBlocks>;
|
|
114
|
-
/**
|
|
115
|
-
* Defines a story creation payload for the MAPI.
|
|
116
|
-
*
|
|
117
|
-
* @example
|
|
118
|
-
* const payload = defineStoryCreate(pageComponent, {
|
|
119
|
-
* name: 'My Page',
|
|
120
|
-
* content: { headline: 'Hello World!' },
|
|
121
|
-
* });
|
|
122
|
-
*/
|
|
123
|
-
declare function defineStoryCreate<const TBlock extends RootBlock, const TBlocks extends Block = never>(component: TBlock, story: StoryCreateInput<TBlock, TBlocks>): StoryCreate<TBlock, TBlocks>;
|
|
124
|
-
/**
|
|
125
|
-
* Defines a story update payload for the MAPI.
|
|
126
|
-
*
|
|
127
|
-
* @example
|
|
128
|
-
* const payload = defineStoryUpdate(pageComponent, {
|
|
129
|
-
* content: { headline: 'Updated!' },
|
|
130
|
-
* });
|
|
131
|
-
*/
|
|
132
|
-
declare function defineStoryUpdate<const TBlock extends RootBlock, const TBlocks extends Block = never>(component: TBlock, story: StoryUpdateInput<TBlock, TBlocks>): StoryUpdate<TBlock, TBlocks>;
|
|
133
|
-
//#endregion
|
|
134
|
-
export { defineMapiStory, defineStory, defineStoryCreate, defineStoryUpdate };
|
|
135
|
-
//# sourceMappingURL=define-story.d.mts.map
|
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
//#region src/helpers/define-story.ts
|
|
2
|
-
const CAPI_STORY_DEFAULTS = {
|
|
3
|
-
id: 1,
|
|
4
|
-
uuid: "",
|
|
5
|
-
created_at: "",
|
|
6
|
-
updated_at: "",
|
|
7
|
-
published_at: null,
|
|
8
|
-
first_published_at: null,
|
|
9
|
-
full_slug: "",
|
|
10
|
-
group_id: "",
|
|
11
|
-
alternates: [],
|
|
12
|
-
default_full_slug: null,
|
|
13
|
-
release_id: null,
|
|
14
|
-
lang: "default",
|
|
15
|
-
slug: "",
|
|
16
|
-
parent_id: 0,
|
|
17
|
-
path: null,
|
|
18
|
-
is_startpage: false,
|
|
19
|
-
sort_by_date: null,
|
|
20
|
-
tag_list: [],
|
|
21
|
-
meta_data: null,
|
|
22
|
-
translated_slugs: null,
|
|
23
|
-
position: 0
|
|
24
|
-
};
|
|
25
|
-
const MAPI_STORY_DEFAULTS = {
|
|
26
|
-
id: 1,
|
|
27
|
-
uuid: "",
|
|
28
|
-
created_at: "",
|
|
29
|
-
updated_at: "",
|
|
30
|
-
published_at: null,
|
|
31
|
-
first_published_at: null,
|
|
32
|
-
full_slug: "",
|
|
33
|
-
group_id: "",
|
|
34
|
-
alternates: [],
|
|
35
|
-
slug: "",
|
|
36
|
-
parent_id: null,
|
|
37
|
-
parent: null,
|
|
38
|
-
path: null,
|
|
39
|
-
is_folder: false,
|
|
40
|
-
is_startpage: false,
|
|
41
|
-
sort_by_date: null,
|
|
42
|
-
tag_list: [],
|
|
43
|
-
meta_data: null,
|
|
44
|
-
translated_slugs: [],
|
|
45
|
-
translated_stories: [],
|
|
46
|
-
localized_paths: [],
|
|
47
|
-
position: 0,
|
|
48
|
-
deleted_at: null,
|
|
49
|
-
published: null,
|
|
50
|
-
default_root: null,
|
|
51
|
-
disble_fe_editor: false,
|
|
52
|
-
disable_fe_editor: false,
|
|
53
|
-
unpublished_changes: null,
|
|
54
|
-
imported_at: null,
|
|
55
|
-
preview_token: {
|
|
56
|
-
token: "",
|
|
57
|
-
timestamp: ""
|
|
58
|
-
},
|
|
59
|
-
pinned: false,
|
|
60
|
-
breadcrumbs: [],
|
|
61
|
-
publish_at: null,
|
|
62
|
-
expire_at: null,
|
|
63
|
-
last_author: null,
|
|
64
|
-
last_author_id: null,
|
|
65
|
-
user_ids: [],
|
|
66
|
-
space_role_ids: [],
|
|
67
|
-
can_not_view: null,
|
|
68
|
-
is_scheduled: null,
|
|
69
|
-
scheduled_dates: null,
|
|
70
|
-
ideas: [],
|
|
71
|
-
favourite_for_user_ids: []
|
|
72
|
-
};
|
|
73
|
-
function defineStory(component, story) {
|
|
74
|
-
const { content, ...rest } = story;
|
|
75
|
-
return {
|
|
76
|
-
...CAPI_STORY_DEFAULTS,
|
|
77
|
-
...rest,
|
|
78
|
-
content: {
|
|
79
|
-
...content,
|
|
80
|
-
component: component.name
|
|
81
|
-
}
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
function defineMapiStory(component, story) {
|
|
85
|
-
const { content, ...rest } = story;
|
|
86
|
-
return {
|
|
87
|
-
...MAPI_STORY_DEFAULTS,
|
|
88
|
-
...rest,
|
|
89
|
-
content: {
|
|
90
|
-
...content,
|
|
91
|
-
component: component.name
|
|
92
|
-
}
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
|
-
function defineStoryCreate(component, story) {
|
|
96
|
-
const { content, ...rest } = story;
|
|
97
|
-
return {
|
|
98
|
-
...rest,
|
|
99
|
-
content: {
|
|
100
|
-
...content,
|
|
101
|
-
component: component.name
|
|
102
|
-
}
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
|
-
function defineStoryUpdate(component, story) {
|
|
106
|
-
const { content, ...rest } = story;
|
|
107
|
-
return {
|
|
108
|
-
...rest,
|
|
109
|
-
...content && { content: {
|
|
110
|
-
...content,
|
|
111
|
-
component: component.name
|
|
112
|
-
} }
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
//#endregion
|
|
117
|
-
export { defineMapiStory, defineStory, defineStoryCreate, defineStoryUpdate };
|
|
118
|
-
//# sourceMappingURL=define-story.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"define-story.mjs","names":[],"sources":["../../src/helpers/define-story.ts"],"sourcesContent":["import type { StoryAlternate } from '../generated/capi/types.gen';\nimport type { StoryLocalizedPath, StoryTranslatedSlug } from '../generated/mapi/types.gen';\nimport type { MapiStory, StoryCreate, StoryUpdate } from '../generated/types/mapi-story';\nimport type { Story } from '../generated/types/story';\nimport type { Block, RootBlock } from './define-block';\nimport type { BlockContentInput } from './define-field';\nimport type { Prettify } from '../utils/prettify';\n\nconst CAPI_STORY_DEFAULTS = {\n id: 1,\n uuid: '',\n created_at: '',\n updated_at: '',\n published_at: null,\n first_published_at: null,\n full_slug: '',\n group_id: '',\n alternates: [],\n default_full_slug: null,\n release_id: null,\n lang: 'default',\n slug: '',\n parent_id: 0,\n path: null,\n is_startpage: false,\n sort_by_date: null,\n tag_list: [],\n meta_data: null,\n translated_slugs: null,\n position: 0,\n};\n\nconst MAPI_STORY_DEFAULTS = {\n id: 1,\n uuid: '',\n created_at: '',\n updated_at: '',\n published_at: null,\n first_published_at: null,\n full_slug: '',\n group_id: '',\n alternates: [],\n slug: '',\n parent_id: null,\n parent: null,\n path: null,\n is_folder: false,\n is_startpage: false,\n sort_by_date: null,\n tag_list: [],\n meta_data: null,\n translated_slugs: [],\n translated_stories: [],\n localized_paths: [],\n position: 0,\n deleted_at: null,\n published: null,\n default_root: null,\n // Legacy upstream typo field; keep it alongside `disable_fe_editor`.\n disble_fe_editor: false,\n disable_fe_editor: false,\n unpublished_changes: null,\n imported_at: null,\n preview_token: { token: '', timestamp: '' },\n pinned: false,\n breadcrumbs: [],\n publish_at: null,\n expire_at: null,\n last_author: null,\n last_author_id: null,\n user_ids: [],\n space_role_ids: [],\n can_not_view: null,\n is_scheduled: null,\n scheduled_dates: null,\n ideas: [],\n favourite_for_user_ids: [],\n};\n\nexport type { MapiStory, Story, StoryCreate, StoryUpdate };\nexport type { StoryAlternate, StoryLocalizedPath, StoryTranslatedSlug };\n\ntype CapiStoryOptional = keyof typeof CAPI_STORY_DEFAULTS;\n\ntype CapiStoryInput<\n TBlock extends RootBlock = RootBlock,\n TBlocks extends Block = never,\n> = Prettify<\n Omit<Story<TBlock, TBlocks>, CapiStoryOptional | 'content'>\n & Partial<Pick<Story<TBlock, TBlocks>, CapiStoryOptional>>\n & {\n content: Omit<BlockContentInput<TBlock, TBlocks>, 'component'>;\n }\n>;\n\n/**\n * Returns a full CDN {@link Story} with all fields populated.\n *\n * @example\n * const myStory = defineStory(pageComponent, {\n * name: 'Home',\n * content: { headline: 'Hello World!' },\n * });\n */\nexport function defineStory<\n TBlock extends RootBlock,\n TBlocks extends Block,\n>(component: TBlock, story: CapiStoryInput<TBlock, TBlocks>): Story<TBlock, TBlocks>;\n\nexport function defineStory(component: RootBlock, story: any) {\n const { content, ...rest } = story;\n return {\n ...CAPI_STORY_DEFAULTS,\n ...rest,\n content: { ...content, component: component.name },\n };\n}\n\n// ---------------------------------------------------------------------------\n// MAPI Story helpers\n// ---------------------------------------------------------------------------\n\ntype MapiStoryOptional = keyof typeof MAPI_STORY_DEFAULTS;\n\ntype MakeMapiStoryInput<\n TStory extends MapiStory | StoryCreate | StoryUpdate,\n TBlock extends RootBlock = RootBlock,\n TBlocks extends Block = never,\n> = Prettify<\n Omit<TStory, MapiStoryOptional | 'content'>\n & Partial<Pick<TStory, Extract<MapiStoryOptional, keyof TStory>>>\n & {\n content: Omit<BlockContentInput<TBlock, TBlocks>, 'component'>;\n }\n>;\n\ntype MapiStoryInput<\n TBlock extends RootBlock = RootBlock,\n TBlocks extends Block = never,\n> = MakeMapiStoryInput<MapiStory, TBlock, TBlocks>;\n\ntype StoryCreateInput<\n TBlock extends RootBlock = RootBlock,\n TBlocks extends Block = never,\n> = MakeMapiStoryInput<StoryCreate, TBlock, TBlocks>;\n\ntype StoryUpdateInput<\n TBlock extends RootBlock = RootBlock,\n TBlocks extends Block = never,\n> = Prettify<\n Omit<MakeMapiStoryInput<StoryUpdate, TBlock, TBlocks>, 'content'>\n & {\n content: Partial<Omit<BlockContentInput<TBlock, TBlocks>, 'component'>>;\n }\n>;\n\n/**\n * Returns a full MAPI {@link MapiStory} with all fields populated.\n *\n * @example\n * const myStory = defineMapiStory(pageComponent, {\n * name: 'My Page',\n * content: { headline: 'Hello World!' },\n * });\n */\nexport function defineMapiStory<\n const TBlock extends RootBlock,\n const TBlocks extends Block = never,\n>(component: TBlock, story: MapiStoryInput<TBlock, TBlocks>): MapiStory<TBlock, TBlocks>;\n\nexport function defineMapiStory(component: RootBlock, story: any) {\n const { content, ...rest } = story;\n return {\n ...MAPI_STORY_DEFAULTS,\n ...rest,\n content: { ...content, component: component.name },\n };\n}\n\n/**\n * Defines a story creation payload for the MAPI.\n *\n * @example\n * const payload = defineStoryCreate(pageComponent, {\n * name: 'My Page',\n * content: { headline: 'Hello World!' },\n * });\n */\nexport function defineStoryCreate<\n const TBlock extends RootBlock,\n const TBlocks extends Block = never,\n>(component: TBlock, story: StoryCreateInput<TBlock, TBlocks>): StoryCreate<TBlock, TBlocks>;\n\nexport function defineStoryCreate(component: RootBlock, story: any) {\n const { content, ...rest } = story;\n return {\n ...rest,\n content: { ...content, component: component.name },\n };\n}\n\n/**\n * Defines a story update payload for the MAPI.\n *\n * @example\n * const payload = defineStoryUpdate(pageComponent, {\n * content: { headline: 'Updated!' },\n * });\n */\nexport function defineStoryUpdate<\n const TBlock extends RootBlock,\n const TBlocks extends Block = never,\n>(component: TBlock, story: StoryUpdateInput<TBlock, TBlocks>): StoryUpdate<TBlock, TBlocks>;\n\nexport function defineStoryUpdate(component: RootBlock, story: any) {\n const { content, ...rest } = story;\n return {\n ...rest,\n ...(content && {\n content: { ...content, component: component.name },\n }),\n };\n}\n"],"mappings":";AAQA,MAAM,sBAAsB;CAC1B,IAAI;CACJ,MAAM;CACN,YAAY;CACZ,YAAY;CACZ,cAAc;CACd,oBAAoB;CACpB,WAAW;CACX,UAAU;CACV,YAAY,EAAE;CACd,mBAAmB;CACnB,YAAY;CACZ,MAAM;CACN,MAAM;CACN,WAAW;CACX,MAAM;CACN,cAAc;CACd,cAAc;CACd,UAAU,EAAE;CACZ,WAAW;CACX,kBAAkB;CAClB,UAAU;CACX;AAED,MAAM,sBAAsB;CAC1B,IAAI;CACJ,MAAM;CACN,YAAY;CACZ,YAAY;CACZ,cAAc;CACd,oBAAoB;CACpB,WAAW;CACX,UAAU;CACV,YAAY,EAAE;CACd,MAAM;CACN,WAAW;CACX,QAAQ;CACR,MAAM;CACN,WAAW;CACX,cAAc;CACd,cAAc;CACd,UAAU,EAAE;CACZ,WAAW;CACX,kBAAkB,EAAE;CACpB,oBAAoB,EAAE;CACtB,iBAAiB,EAAE;CACnB,UAAU;CACV,YAAY;CACZ,WAAW;CACX,cAAc;CAEd,kBAAkB;CAClB,mBAAmB;CACnB,qBAAqB;CACrB,aAAa;CACb,eAAe;EAAE,OAAO;EAAI,WAAW;EAAI;CAC3C,QAAQ;CACR,aAAa,EAAE;CACf,YAAY;CACZ,WAAW;CACX,aAAa;CACb,gBAAgB;CAChB,UAAU,EAAE;CACZ,gBAAgB,EAAE;CAClB,cAAc;CACd,cAAc;CACd,iBAAiB;CACjB,OAAO,EAAE;CACT,wBAAwB,EAAE;CAC3B;AAgCD,SAAgB,YAAY,WAAsB,OAAY;CAC5D,MAAM,EAAE,SAAS,GAAG,SAAS;AAC7B,QAAO;EACL,GAAG;EACH,GAAG;EACH,SAAS;GAAE,GAAG;GAAS,WAAW,UAAU;GAAM;EACnD;;AAuDH,SAAgB,gBAAgB,WAAsB,OAAY;CAChE,MAAM,EAAE,SAAS,GAAG,SAAS;AAC7B,QAAO;EACL,GAAG;EACH,GAAG;EACH,SAAS;GAAE,GAAG;GAAS,WAAW,UAAU;GAAM;EACnD;;AAiBH,SAAgB,kBAAkB,WAAsB,OAAY;CAClE,MAAM,EAAE,SAAS,GAAG,SAAS;AAC7B,QAAO;EACL,GAAG;EACH,SAAS;GAAE,GAAG;GAAS,WAAW,UAAU;GAAM;EACnD;;AAgBH,SAAgB,kBAAkB,WAAsB,OAAY;CAClE,MAAM,EAAE,SAAS,GAAG,SAAS;AAC7B,QAAO;EACL,GAAG;EACH,GAAI,WAAW,EACb,SAAS;GAAE,GAAG;GAAS,WAAW,UAAU;GAAM,EACnD;EACF"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
//#region src/helpers/define-tag.ts
|
|
3
|
-
const TAG_DEFAULTS = { taggings_count: 0 };
|
|
4
|
-
function defineTag(tag) {
|
|
5
|
-
return {
|
|
6
|
-
...TAG_DEFAULTS,
|
|
7
|
-
...tag
|
|
8
|
-
};
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
//#endregion
|
|
12
|
-
exports.defineTag = defineTag;
|
|
13
|
-
//# sourceMappingURL=define-tag.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"define-tag.cjs","names":[],"sources":["../../src/helpers/define-tag.ts"],"sourcesContent":["import type { Tag } from '../generated/capi/types.gen';\nimport type { Prettify } from '../utils/prettify';\n\nconst TAG_DEFAULTS = {\n taggings_count: 0,\n};\n\nexport type { Tag };\n\n/** Fields that have safe defaults and may be omitted from tag input. */\ntype TagOptional = keyof typeof TAG_DEFAULTS;\n\ntype TagInput = Prettify<Omit<Tag, TagOptional> & Partial<Pick<Tag, TagOptional>>>;\n\n/**\n * Returns a full {@link Tag} with all fields populated. API-assigned\n * fields are optional and default to safe values.\n *\n * @example\n * const tag = defineTag({\n * name: 'featured',\n * });\n */\n// Overload: provides the strict public signature for callers.\nexport function defineTag(tag: TagInput): Tag;\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 defineTag(tag: any) {\n return { ...TAG_DEFAULTS, ...tag };\n}\n"],"mappings":";;AAGA,MAAM,eAAe,EACnB,gBAAgB,GACjB;AAwBD,SAAgB,UAAU,KAAU;AAClC,QAAO;EAAE,GAAG;EAAc,GAAG;EAAK"}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { Prettify } from "../utils/prettify.cjs";
|
|
2
|
-
import { Tag } from "../generated/capi/types.gen.cjs";
|
|
3
|
-
|
|
4
|
-
//#region src/helpers/define-tag.d.ts
|
|
5
|
-
declare const TAG_DEFAULTS: {
|
|
6
|
-
taggings_count: number;
|
|
7
|
-
};
|
|
8
|
-
/** Fields that have safe defaults and may be omitted from tag input. */
|
|
9
|
-
type TagOptional = keyof typeof TAG_DEFAULTS;
|
|
10
|
-
type TagInput = Prettify<Omit<Tag, TagOptional> & Partial<Pick<Tag, TagOptional>>>;
|
|
11
|
-
/**
|
|
12
|
-
* Returns a full {@link Tag} with all fields populated. API-assigned
|
|
13
|
-
* fields are optional and default to safe values.
|
|
14
|
-
*
|
|
15
|
-
* @example
|
|
16
|
-
* const tag = defineTag({
|
|
17
|
-
* name: 'featured',
|
|
18
|
-
* });
|
|
19
|
-
*/
|
|
20
|
-
declare function defineTag(tag: TagInput): Tag;
|
|
21
|
-
//#endregion
|
|
22
|
-
export { defineTag };
|
|
23
|
-
//# sourceMappingURL=define-tag.d.cts.map
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { Prettify } from "../utils/prettify.mjs";
|
|
2
|
-
import { Tag } from "../generated/capi/types.gen.mjs";
|
|
3
|
-
|
|
4
|
-
//#region src/helpers/define-tag.d.ts
|
|
5
|
-
declare const TAG_DEFAULTS: {
|
|
6
|
-
taggings_count: number;
|
|
7
|
-
};
|
|
8
|
-
/** Fields that have safe defaults and may be omitted from tag input. */
|
|
9
|
-
type TagOptional = keyof typeof TAG_DEFAULTS;
|
|
10
|
-
type TagInput = Prettify<Omit<Tag, TagOptional> & Partial<Pick<Tag, TagOptional>>>;
|
|
11
|
-
/**
|
|
12
|
-
* Returns a full {@link Tag} with all fields populated. API-assigned
|
|
13
|
-
* fields are optional and default to safe values.
|
|
14
|
-
*
|
|
15
|
-
* @example
|
|
16
|
-
* const tag = defineTag({
|
|
17
|
-
* name: 'featured',
|
|
18
|
-
* });
|
|
19
|
-
*/
|
|
20
|
-
declare function defineTag(tag: TagInput): Tag;
|
|
21
|
-
//#endregion
|
|
22
|
-
export { defineTag };
|
|
23
|
-
//# sourceMappingURL=define-tag.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"define-tag.mjs","names":[],"sources":["../../src/helpers/define-tag.ts"],"sourcesContent":["import type { Tag } from '../generated/capi/types.gen';\nimport type { Prettify } from '../utils/prettify';\n\nconst TAG_DEFAULTS = {\n taggings_count: 0,\n};\n\nexport type { Tag };\n\n/** Fields that have safe defaults and may be omitted from tag input. */\ntype TagOptional = keyof typeof TAG_DEFAULTS;\n\ntype TagInput = Prettify<Omit<Tag, TagOptional> & Partial<Pick<Tag, TagOptional>>>;\n\n/**\n * Returns a full {@link Tag} with all fields populated. API-assigned\n * fields are optional and default to safe values.\n *\n * @example\n * const tag = defineTag({\n * name: 'featured',\n * });\n */\n// Overload: provides the strict public signature for callers.\nexport function defineTag(tag: TagInput): Tag;\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 defineTag(tag: any) {\n return { ...TAG_DEFAULTS, ...tag };\n}\n"],"mappings":";AAGA,MAAM,eAAe,EACnB,gBAAgB,GACjB;AAwBD,SAAgB,UAAU,KAAU;AAClC,QAAO;EAAE,GAAG;EAAc,GAAG;EAAK"}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
//#region src/helpers/define-user.ts
|
|
3
|
-
const USER_DEFAULTS = {
|
|
4
|
-
id: 1,
|
|
5
|
-
userid: "",
|
|
6
|
-
created_at: "",
|
|
7
|
-
use_username: false,
|
|
8
|
-
login_strategy: "password",
|
|
9
|
-
has_org: false,
|
|
10
|
-
has_partner: false,
|
|
11
|
-
org: {},
|
|
12
|
-
friendly_name: "",
|
|
13
|
-
notified: [],
|
|
14
|
-
favourite_spaces: [],
|
|
15
|
-
favourite_ideas: [],
|
|
16
|
-
beta_user: false,
|
|
17
|
-
track_statistics: true,
|
|
18
|
-
ui_theme: {},
|
|
19
|
-
totp_factor_verified: false,
|
|
20
|
-
configured_2fa_options: [],
|
|
21
|
-
disclaimer_ids: [],
|
|
22
|
-
live_chat_enabled: false,
|
|
23
|
-
confirmed: false
|
|
24
|
-
};
|
|
25
|
-
/**
|
|
26
|
-
* Defines a user object for the MAPI.
|
|
27
|
-
* API-assigned fields (`id`, `created_at`, `updated_at`) are optional and filled with safe defaults.
|
|
28
|
-
*
|
|
29
|
-
* @example
|
|
30
|
-
* import { defineUser } from '@storyblok/schema';
|
|
31
|
-
* const user = defineUser({ email: 'dev@example.com' });
|
|
32
|
-
*/
|
|
33
|
-
const defineUser = (user) => ({
|
|
34
|
-
...USER_DEFAULTS,
|
|
35
|
-
...user,
|
|
36
|
-
userid: user.userid ?? USER_DEFAULTS.userid
|
|
37
|
-
});
|
|
38
|
-
/**
|
|
39
|
-
* Defines a user update payload for the MAPI (updateMe endpoint).
|
|
40
|
-
*
|
|
41
|
-
* @example
|
|
42
|
-
* import { defineUserUpdate } from '@storyblok/schema';
|
|
43
|
-
* const payload = defineUserUpdate({ firstname: 'Jane', lastname: 'Doe' });
|
|
44
|
-
*/
|
|
45
|
-
const defineUserUpdate = (user) => user;
|
|
46
|
-
|
|
47
|
-
//#endregion
|
|
48
|
-
exports.defineUser = defineUser;
|
|
49
|
-
exports.defineUserUpdate = defineUserUpdate;
|
|
50
|
-
//# sourceMappingURL=define-user.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"define-user.cjs","names":[],"sources":["../../src/helpers/define-user.ts"],"sourcesContent":["import type { User, UserUpdate } from '../generated/mapi/types.gen';\n\nexport type { User, UserUpdate };\n\nconst USER_DEFAULTS = {\n id: 1,\n userid: '',\n created_at: '',\n use_username: false,\n login_strategy: 'password' as const,\n has_org: false,\n has_partner: false,\n org: {},\n friendly_name: '',\n notified: [],\n favourite_spaces: [],\n favourite_ideas: [],\n beta_user: false,\n track_statistics: true,\n ui_theme: {},\n totp_factor_verified: false,\n configured_2fa_options: [],\n disclaimer_ids: [],\n live_chat_enabled: false,\n confirmed: false,\n};\n\ntype UserInput = { email: string } & Partial<Omit<User, 'email'>>;\n\n/**\n * Defines a user object for the MAPI.\n * API-assigned fields (`id`, `created_at`, `updated_at`) are optional and filled with safe defaults.\n *\n * @example\n * import { defineUser } from '@storyblok/schema';\n * const user = defineUser({ email: 'dev@example.com' });\n */\nexport const defineUser = (user: UserInput): User => ({\n ...USER_DEFAULTS,\n ...user,\n userid: user.userid ?? USER_DEFAULTS.userid,\n});\n\n/**\n * Defines a user update payload for the MAPI (updateMe endpoint).\n *\n * @example\n * import { defineUserUpdate } from '@storyblok/schema';\n * const payload = defineUserUpdate({ firstname: 'Jane', lastname: 'Doe' });\n */\nexport const defineUserUpdate = (user: UserUpdate): UserUpdate => user;\n"],"mappings":";;AAIA,MAAM,gBAAgB;CACpB,IAAI;CACJ,QAAQ;CACR,YAAY;CACZ,cAAc;CACd,gBAAgB;CAChB,SAAS;CACT,aAAa;CACb,KAAK,EAAE;CACP,eAAe;CACf,UAAU,EAAE;CACZ,kBAAkB,EAAE;CACpB,iBAAiB,EAAE;CACnB,WAAW;CACX,kBAAkB;CAClB,UAAU,EAAE;CACZ,sBAAsB;CACtB,wBAAwB,EAAE;CAC1B,gBAAgB,EAAE;CAClB,mBAAmB;CACnB,WAAW;CACZ;;;;;;;;;AAYD,MAAa,cAAc,UAA2B;CACpD,GAAG;CACH,GAAG;CACH,QAAQ,KAAK,UAAU,cAAc;CACtC;;;;;;;;AASD,MAAa,oBAAoB,SAAiC"}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { User, UserUpdate } from "../generated/mapi/types.gen.cjs";
|
|
2
|
-
|
|
3
|
-
//#region src/helpers/define-user.d.ts
|
|
4
|
-
type UserInput = {
|
|
5
|
-
email: string;
|
|
6
|
-
} & Partial<Omit<User, 'email'>>;
|
|
7
|
-
/**
|
|
8
|
-
* Defines a user object for the MAPI.
|
|
9
|
-
* API-assigned fields (`id`, `created_at`, `updated_at`) are optional and filled with safe defaults.
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* import { defineUser } from '@storyblok/schema';
|
|
13
|
-
* const user = defineUser({ email: 'dev@example.com' });
|
|
14
|
-
*/
|
|
15
|
-
declare const defineUser: (user: UserInput) => User;
|
|
16
|
-
/**
|
|
17
|
-
* Defines a user update payload for the MAPI (updateMe endpoint).
|
|
18
|
-
*
|
|
19
|
-
* @example
|
|
20
|
-
* import { defineUserUpdate } from '@storyblok/schema';
|
|
21
|
-
* const payload = defineUserUpdate({ firstname: 'Jane', lastname: 'Doe' });
|
|
22
|
-
*/
|
|
23
|
-
declare const defineUserUpdate: (user: UserUpdate) => UserUpdate;
|
|
24
|
-
//#endregion
|
|
25
|
-
export { defineUser, defineUserUpdate };
|
|
26
|
-
//# sourceMappingURL=define-user.d.cts.map
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { User, UserUpdate } from "../generated/mapi/types.gen.mjs";
|
|
2
|
-
|
|
3
|
-
//#region src/helpers/define-user.d.ts
|
|
4
|
-
type UserInput = {
|
|
5
|
-
email: string;
|
|
6
|
-
} & Partial<Omit<User, 'email'>>;
|
|
7
|
-
/**
|
|
8
|
-
* Defines a user object for the MAPI.
|
|
9
|
-
* API-assigned fields (`id`, `created_at`, `updated_at`) are optional and filled with safe defaults.
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* import { defineUser } from '@storyblok/schema';
|
|
13
|
-
* const user = defineUser({ email: 'dev@example.com' });
|
|
14
|
-
*/
|
|
15
|
-
declare const defineUser: (user: UserInput) => User;
|
|
16
|
-
/**
|
|
17
|
-
* Defines a user update payload for the MAPI (updateMe endpoint).
|
|
18
|
-
*
|
|
19
|
-
* @example
|
|
20
|
-
* import { defineUserUpdate } from '@storyblok/schema';
|
|
21
|
-
* const payload = defineUserUpdate({ firstname: 'Jane', lastname: 'Doe' });
|
|
22
|
-
*/
|
|
23
|
-
declare const defineUserUpdate: (user: UserUpdate) => UserUpdate;
|
|
24
|
-
//#endregion
|
|
25
|
-
export { defineUser, defineUserUpdate };
|
|
26
|
-
//# sourceMappingURL=define-user.d.mts.map
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
//#region src/helpers/define-user.ts
|
|
2
|
-
const USER_DEFAULTS = {
|
|
3
|
-
id: 1,
|
|
4
|
-
userid: "",
|
|
5
|
-
created_at: "",
|
|
6
|
-
use_username: false,
|
|
7
|
-
login_strategy: "password",
|
|
8
|
-
has_org: false,
|
|
9
|
-
has_partner: false,
|
|
10
|
-
org: {},
|
|
11
|
-
friendly_name: "",
|
|
12
|
-
notified: [],
|
|
13
|
-
favourite_spaces: [],
|
|
14
|
-
favourite_ideas: [],
|
|
15
|
-
beta_user: false,
|
|
16
|
-
track_statistics: true,
|
|
17
|
-
ui_theme: {},
|
|
18
|
-
totp_factor_verified: false,
|
|
19
|
-
configured_2fa_options: [],
|
|
20
|
-
disclaimer_ids: [],
|
|
21
|
-
live_chat_enabled: false,
|
|
22
|
-
confirmed: false
|
|
23
|
-
};
|
|
24
|
-
/**
|
|
25
|
-
* Defines a user object for the MAPI.
|
|
26
|
-
* API-assigned fields (`id`, `created_at`, `updated_at`) are optional and filled with safe defaults.
|
|
27
|
-
*
|
|
28
|
-
* @example
|
|
29
|
-
* import { defineUser } from '@storyblok/schema';
|
|
30
|
-
* const user = defineUser({ email: 'dev@example.com' });
|
|
31
|
-
*/
|
|
32
|
-
const defineUser = (user) => ({
|
|
33
|
-
...USER_DEFAULTS,
|
|
34
|
-
...user,
|
|
35
|
-
userid: user.userid ?? USER_DEFAULTS.userid
|
|
36
|
-
});
|
|
37
|
-
/**
|
|
38
|
-
* Defines a user update payload for the MAPI (updateMe endpoint).
|
|
39
|
-
*
|
|
40
|
-
* @example
|
|
41
|
-
* import { defineUserUpdate } from '@storyblok/schema';
|
|
42
|
-
* const payload = defineUserUpdate({ firstname: 'Jane', lastname: 'Doe' });
|
|
43
|
-
*/
|
|
44
|
-
const defineUserUpdate = (user) => user;
|
|
45
|
-
|
|
46
|
-
//#endregion
|
|
47
|
-
export { defineUser, defineUserUpdate };
|
|
48
|
-
//# sourceMappingURL=define-user.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"define-user.mjs","names":[],"sources":["../../src/helpers/define-user.ts"],"sourcesContent":["import type { User, UserUpdate } from '../generated/mapi/types.gen';\n\nexport type { User, UserUpdate };\n\nconst USER_DEFAULTS = {\n id: 1,\n userid: '',\n created_at: '',\n use_username: false,\n login_strategy: 'password' as const,\n has_org: false,\n has_partner: false,\n org: {},\n friendly_name: '',\n notified: [],\n favourite_spaces: [],\n favourite_ideas: [],\n beta_user: false,\n track_statistics: true,\n ui_theme: {},\n totp_factor_verified: false,\n configured_2fa_options: [],\n disclaimer_ids: [],\n live_chat_enabled: false,\n confirmed: false,\n};\n\ntype UserInput = { email: string } & Partial<Omit<User, 'email'>>;\n\n/**\n * Defines a user object for the MAPI.\n * API-assigned fields (`id`, `created_at`, `updated_at`) are optional and filled with safe defaults.\n *\n * @example\n * import { defineUser } from '@storyblok/schema';\n * const user = defineUser({ email: 'dev@example.com' });\n */\nexport const defineUser = (user: UserInput): User => ({\n ...USER_DEFAULTS,\n ...user,\n userid: user.userid ?? USER_DEFAULTS.userid,\n});\n\n/**\n * Defines a user update payload for the MAPI (updateMe endpoint).\n *\n * @example\n * import { defineUserUpdate } from '@storyblok/schema';\n * const payload = defineUserUpdate({ firstname: 'Jane', lastname: 'Doe' });\n */\nexport const defineUserUpdate = (user: UserUpdate): UserUpdate => user;\n"],"mappings":";AAIA,MAAM,gBAAgB;CACpB,IAAI;CACJ,QAAQ;CACR,YAAY;CACZ,cAAc;CACd,gBAAgB;CAChB,SAAS;CACT,aAAa;CACb,KAAK,EAAE;CACP,eAAe;CACf,UAAU,EAAE;CACZ,kBAAkB,EAAE;CACpB,iBAAiB,EAAE;CACnB,WAAW;CACX,kBAAkB;CAClB,UAAU,EAAE;CACZ,sBAAsB;CACtB,wBAAwB,EAAE;CAC1B,gBAAgB,EAAE;CAClB,mBAAmB;CACnB,WAAW;CACZ;;;;;;;;;AAYD,MAAa,cAAc,UAA2B;CACpD,GAAG;CACH,GAAG;CACH,QAAQ,KAAK,UAAU,cAAc;CACtC;;;;;;;;AASD,MAAa,oBAAoB,SAAiC"}
|