@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.
Files changed (121) hide show
  1. package/LICENSE +8 -0
  2. package/README.md +74 -0
  3. package/dist/generated/capi/_internal.gen.d.cts +120 -0
  4. package/dist/generated/capi/_internal.gen.d.mts +120 -0
  5. package/dist/generated/capi/types.gen.d.cts +181 -0
  6. package/dist/generated/capi/types.gen.d.mts +181 -0
  7. package/dist/generated/mapi/_internal.gen.d.cts +683 -0
  8. package/dist/generated/mapi/_internal.gen.d.mts +683 -0
  9. package/dist/generated/mapi/types.gen.d.cts +1272 -0
  10. package/dist/generated/mapi/types.gen.d.mts +1272 -0
  11. package/dist/generated/overlay/_internal.gen.d.cts +850 -0
  12. package/dist/generated/overlay/_internal.gen.d.mts +850 -0
  13. package/dist/generated/types/_utils.d.cts +7 -0
  14. package/dist/generated/types/_utils.d.mts +7 -0
  15. package/dist/generated/types/block.d.cts +46 -0
  16. package/dist/generated/types/block.d.mts +46 -0
  17. package/dist/generated/types/field.d.cts +74 -0
  18. package/dist/generated/types/field.d.mts +74 -0
  19. package/dist/generated/types/mapi-story.d.cts +29 -0
  20. package/dist/generated/types/mapi-story.d.mts +29 -0
  21. package/dist/generated/types/story.d.cts +19 -0
  22. package/dist/generated/types/story.d.mts +19 -0
  23. package/dist/helpers/create-story-helpers.cjs +42 -0
  24. package/dist/helpers/create-story-helpers.cjs.map +1 -0
  25. package/dist/helpers/create-story-helpers.d.cts +50 -0
  26. package/dist/helpers/create-story-helpers.d.mts +50 -0
  27. package/dist/helpers/create-story-helpers.mjs +42 -0
  28. package/dist/helpers/create-story-helpers.mjs.map +1 -0
  29. package/dist/helpers/define-asset-folder.cjs +46 -0
  30. package/dist/helpers/define-asset-folder.cjs.map +1 -0
  31. package/dist/helpers/define-asset-folder.d.cts +33 -0
  32. package/dist/helpers/define-asset-folder.d.mts +33 -0
  33. package/dist/helpers/define-asset-folder.mjs +43 -0
  34. package/dist/helpers/define-asset-folder.mjs.map +1 -0
  35. package/dist/helpers/define-asset.cjs +60 -0
  36. package/dist/helpers/define-asset.cjs.map +1 -0
  37. package/dist/helpers/define-asset.d.cts +32 -0
  38. package/dist/helpers/define-asset.d.mts +32 -0
  39. package/dist/helpers/define-asset.mjs +57 -0
  40. package/dist/helpers/define-asset.mjs.map +1 -0
  41. package/dist/helpers/define-block-folder.cjs +44 -0
  42. package/dist/helpers/define-block-folder.cjs.map +1 -0
  43. package/dist/helpers/define-block-folder.d.cts +34 -0
  44. package/dist/helpers/define-block-folder.d.mts +34 -0
  45. package/dist/helpers/define-block-folder.mjs +41 -0
  46. package/dist/helpers/define-block-folder.mjs.map +1 -0
  47. package/dist/helpers/define-block.cjs +51 -0
  48. package/dist/helpers/define-block.cjs.map +1 -0
  49. package/dist/helpers/define-block.d.cts +62 -0
  50. package/dist/helpers/define-block.d.mts +62 -0
  51. package/dist/helpers/define-block.mjs +48 -0
  52. package/dist/helpers/define-block.mjs.map +1 -0
  53. package/dist/helpers/define-datasource-entry.cjs +47 -0
  54. package/dist/helpers/define-datasource-entry.cjs.map +1 -0
  55. package/dist/helpers/define-datasource-entry.d.cts +49 -0
  56. package/dist/helpers/define-datasource-entry.d.mts +49 -0
  57. package/dist/helpers/define-datasource-entry.mjs +43 -0
  58. package/dist/helpers/define-datasource-entry.mjs.map +1 -0
  59. package/dist/helpers/define-datasource.cjs +34 -0
  60. package/dist/helpers/define-datasource.cjs.map +1 -0
  61. package/dist/helpers/define-datasource.d.cts +42 -0
  62. package/dist/helpers/define-datasource.d.mts +42 -0
  63. package/dist/helpers/define-datasource.mjs +31 -0
  64. package/dist/helpers/define-datasource.mjs.map +1 -0
  65. package/dist/helpers/define-field.cjs +17 -0
  66. package/dist/helpers/define-field.cjs.map +1 -0
  67. package/dist/helpers/define-field.d.cts +99 -0
  68. package/dist/helpers/define-field.d.mts +99 -0
  69. package/dist/helpers/define-field.mjs +16 -0
  70. package/dist/helpers/define-field.mjs.map +1 -0
  71. package/dist/helpers/define-internal-tag.cjs +41 -0
  72. package/dist/helpers/define-internal-tag.cjs.map +1 -0
  73. package/dist/helpers/define-internal-tag.d.cts +34 -0
  74. package/dist/helpers/define-internal-tag.d.mts +34 -0
  75. package/dist/helpers/define-internal-tag.mjs +38 -0
  76. package/dist/helpers/define-internal-tag.mjs.map +1 -0
  77. package/dist/helpers/define-link.cjs +23 -0
  78. package/dist/helpers/define-link.cjs.map +1 -0
  79. package/dist/helpers/define-link.d.cts +32 -0
  80. package/dist/helpers/define-link.d.mts +32 -0
  81. package/dist/helpers/define-link.mjs +22 -0
  82. package/dist/helpers/define-link.mjs.map +1 -0
  83. package/dist/helpers/define-preset.cjs +44 -0
  84. package/dist/helpers/define-preset.cjs.map +1 -0
  85. package/dist/helpers/define-preset.d.cts +35 -0
  86. package/dist/helpers/define-preset.d.mts +35 -0
  87. package/dist/helpers/define-preset.mjs +41 -0
  88. package/dist/helpers/define-preset.mjs.map +1 -0
  89. package/dist/helpers/define-space.cjs +47 -0
  90. package/dist/helpers/define-space.cjs.map +1 -0
  91. package/dist/helpers/define-space.d.cts +31 -0
  92. package/dist/helpers/define-space.d.mts +31 -0
  93. package/dist/helpers/define-space.mjs +44 -0
  94. package/dist/helpers/define-space.mjs.map +1 -0
  95. package/dist/helpers/define-story.cjs +122 -0
  96. package/dist/helpers/define-story.cjs.map +1 -0
  97. package/dist/helpers/define-story.d.cts +135 -0
  98. package/dist/helpers/define-story.d.mts +135 -0
  99. package/dist/helpers/define-story.mjs +118 -0
  100. package/dist/helpers/define-story.mjs.map +1 -0
  101. package/dist/helpers/define-tag.cjs +13 -0
  102. package/dist/helpers/define-tag.cjs.map +1 -0
  103. package/dist/helpers/define-tag.d.cts +23 -0
  104. package/dist/helpers/define-tag.d.mts +23 -0
  105. package/dist/helpers/define-tag.mjs +12 -0
  106. package/dist/helpers/define-tag.mjs.map +1 -0
  107. package/dist/helpers/define-user.cjs +50 -0
  108. package/dist/helpers/define-user.cjs.map +1 -0
  109. package/dist/helpers/define-user.d.cts +26 -0
  110. package/dist/helpers/define-user.d.mts +26 -0
  111. package/dist/helpers/define-user.mjs +48 -0
  112. package/dist/helpers/define-user.mjs.map +1 -0
  113. package/dist/helpers/schema-type.d.cts +40 -0
  114. package/dist/helpers/schema-type.d.mts +40 -0
  115. package/dist/index.cjs +55 -0
  116. package/dist/index.d.cts +23 -0
  117. package/dist/index.d.mts +23 -0
  118. package/dist/index.mjs +17 -0
  119. package/dist/utils/prettify.d.cts +9 -0
  120. package/dist/utils/prettify.d.mts +9 -0
  121. package/package.json +78 -0
@@ -0,0 +1,31 @@
1
+ import { Space, SpaceCreate, SpaceUpdate } from "../generated/mapi/types.gen.cjs";
2
+
3
+ //#region src/helpers/define-space.d.ts
4
+ type SpaceInput = {
5
+ name: string;
6
+ } & Partial<Omit<Space, 'name'>>;
7
+ /**
8
+ * Defines a space for the MAPI.
9
+ * `name` is required; API-assigned fields (`id`) default to safe values.
10
+ *
11
+ * @example
12
+ * const space = defineSpace({ name: 'My Space' });
13
+ */
14
+ declare const defineSpace: (space: SpaceInput) => Space;
15
+ /**
16
+ * Defines a space creation payload for the MAPI.
17
+ *
18
+ * @example
19
+ * const payload = defineSpaceCreate({ name: 'My New Space' });
20
+ */
21
+ declare const defineSpaceCreate: (space: SpaceCreate) => SpaceCreate;
22
+ /**
23
+ * Defines a space update payload for the MAPI.
24
+ *
25
+ * @example
26
+ * const payload = defineSpaceUpdate({ name: 'Updated Space Name' });
27
+ */
28
+ declare const defineSpaceUpdate: (space: SpaceUpdate) => SpaceUpdate;
29
+ //#endregion
30
+ export { defineSpace, defineSpaceCreate, defineSpaceUpdate };
31
+ //# sourceMappingURL=define-space.d.cts.map
@@ -0,0 +1,31 @@
1
+ import { Space, SpaceCreate, SpaceUpdate } from "../generated/mapi/types.gen.mjs";
2
+
3
+ //#region src/helpers/define-space.d.ts
4
+ type SpaceInput = {
5
+ name: string;
6
+ } & Partial<Omit<Space, 'name'>>;
7
+ /**
8
+ * Defines a space for the MAPI.
9
+ * `name` is required; API-assigned fields (`id`) default to safe values.
10
+ *
11
+ * @example
12
+ * const space = defineSpace({ name: 'My Space' });
13
+ */
14
+ declare const defineSpace: (space: SpaceInput) => Space;
15
+ /**
16
+ * Defines a space creation payload for the MAPI.
17
+ *
18
+ * @example
19
+ * const payload = defineSpaceCreate({ name: 'My New Space' });
20
+ */
21
+ declare const defineSpaceCreate: (space: SpaceCreate) => SpaceCreate;
22
+ /**
23
+ * Defines a space update payload for the MAPI.
24
+ *
25
+ * @example
26
+ * const payload = defineSpaceUpdate({ name: 'Updated Space Name' });
27
+ */
28
+ declare const defineSpaceUpdate: (space: SpaceUpdate) => SpaceUpdate;
29
+ //#endregion
30
+ export { defineSpace, defineSpaceCreate, defineSpaceUpdate };
31
+ //# sourceMappingURL=define-space.d.mts.map
@@ -0,0 +1,44 @@
1
+ //#region src/helpers/define-space.ts
2
+ const SPACE_DEFAULTS = {
3
+ id: 1,
4
+ region: "",
5
+ owner_id: 1,
6
+ updated_at: "",
7
+ created_at: "",
8
+ plan: "",
9
+ plan_level: 0,
10
+ trial: false,
11
+ requires_2fa: false,
12
+ org_requires_2fa: false,
13
+ development_mode: false,
14
+ feature_limit_exceeded_flags: {}
15
+ };
16
+ /**
17
+ * Defines a space for the MAPI.
18
+ * `name` is required; API-assigned fields (`id`) default to safe values.
19
+ *
20
+ * @example
21
+ * const space = defineSpace({ name: 'My Space' });
22
+ */
23
+ const defineSpace = (space) => ({
24
+ ...SPACE_DEFAULTS,
25
+ ...space
26
+ });
27
+ /**
28
+ * Defines a space creation payload for the MAPI.
29
+ *
30
+ * @example
31
+ * const payload = defineSpaceCreate({ name: 'My New Space' });
32
+ */
33
+ const defineSpaceCreate = (space) => space;
34
+ /**
35
+ * Defines a space update payload for the MAPI.
36
+ *
37
+ * @example
38
+ * const payload = defineSpaceUpdate({ name: 'Updated Space Name' });
39
+ */
40
+ const defineSpaceUpdate = (space) => space;
41
+
42
+ //#endregion
43
+ export { defineSpace, defineSpaceCreate, defineSpaceUpdate };
44
+ //# sourceMappingURL=define-space.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"define-space.mjs","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"}
@@ -0,0 +1,122 @@
1
+
2
+ //#region src/helpers/define-story.ts
3
+ const CAPI_STORY_DEFAULTS = {
4
+ id: 1,
5
+ uuid: "",
6
+ created_at: "",
7
+ updated_at: "",
8
+ published_at: null,
9
+ first_published_at: null,
10
+ full_slug: "",
11
+ group_id: "",
12
+ alternates: [],
13
+ default_full_slug: null,
14
+ release_id: null,
15
+ lang: "default",
16
+ slug: "",
17
+ parent_id: 0,
18
+ path: null,
19
+ is_startpage: false,
20
+ sort_by_date: null,
21
+ tag_list: [],
22
+ meta_data: null,
23
+ translated_slugs: null,
24
+ position: 0
25
+ };
26
+ const MAPI_STORY_DEFAULTS = {
27
+ id: 1,
28
+ uuid: "",
29
+ created_at: "",
30
+ updated_at: "",
31
+ published_at: null,
32
+ first_published_at: null,
33
+ full_slug: "",
34
+ group_id: "",
35
+ alternates: [],
36
+ slug: "",
37
+ parent_id: null,
38
+ parent: null,
39
+ path: null,
40
+ is_folder: false,
41
+ is_startpage: false,
42
+ sort_by_date: null,
43
+ tag_list: [],
44
+ meta_data: null,
45
+ translated_slugs: [],
46
+ translated_stories: [],
47
+ localized_paths: [],
48
+ position: 0,
49
+ deleted_at: null,
50
+ published: null,
51
+ default_root: null,
52
+ disble_fe_editor: false,
53
+ disable_fe_editor: false,
54
+ unpublished_changes: null,
55
+ imported_at: null,
56
+ preview_token: {
57
+ token: "",
58
+ timestamp: ""
59
+ },
60
+ pinned: false,
61
+ breadcrumbs: [],
62
+ publish_at: null,
63
+ expire_at: null,
64
+ last_author: null,
65
+ last_author_id: null,
66
+ user_ids: [],
67
+ space_role_ids: [],
68
+ can_not_view: null,
69
+ is_scheduled: null,
70
+ scheduled_dates: null,
71
+ ideas: [],
72
+ favourite_for_user_ids: []
73
+ };
74
+ function defineStory(component, story) {
75
+ const { content, ...rest } = story;
76
+ return {
77
+ ...CAPI_STORY_DEFAULTS,
78
+ ...rest,
79
+ content: {
80
+ ...content,
81
+ component: component.name
82
+ }
83
+ };
84
+ }
85
+ function defineMapiStory(component, story) {
86
+ const { content, ...rest } = story;
87
+ return {
88
+ ...MAPI_STORY_DEFAULTS,
89
+ ...rest,
90
+ content: {
91
+ ...content,
92
+ component: component.name
93
+ }
94
+ };
95
+ }
96
+ function defineStoryCreate(component, story) {
97
+ const { content, ...rest } = story;
98
+ return {
99
+ ...rest,
100
+ content: {
101
+ ...content,
102
+ component: component.name
103
+ }
104
+ };
105
+ }
106
+ function defineStoryUpdate(component, story) {
107
+ const { content, ...rest } = story;
108
+ return {
109
+ ...rest,
110
+ ...content && { content: {
111
+ ...content,
112
+ component: component.name
113
+ } }
114
+ };
115
+ }
116
+
117
+ //#endregion
118
+ exports.defineMapiStory = defineMapiStory;
119
+ exports.defineStory = defineStory;
120
+ exports.defineStoryCreate = defineStoryCreate;
121
+ exports.defineStoryUpdate = defineStoryUpdate;
122
+ //# sourceMappingURL=define-story.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"define-story.cjs","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"}
@@ -0,0 +1,135 @@
1
+ import { Block, RootBlock } from "../generated/types/block.cjs";
2
+ import { Prettify } from "../utils/prettify.cjs";
3
+ import { StoryAlternate } from "../generated/capi/types.gen.cjs";
4
+ import { StoryLocalizedPath, StoryTranslatedSlug } from "../generated/mapi/types.gen.cjs";
5
+ import { MapiStory, StoryCreate, StoryUpdate } from "../generated/types/mapi-story.cjs";
6
+ import { Story } from "../generated/types/story.cjs";
7
+ import { BlockContentInput } from "./define-field.cjs";
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.cts.map
@@ -0,0 +1,135 @@
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
@@ -0,0 +1,118 @@
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
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,13 @@
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
@@ -0,0 +1 @@
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"}