@cntrl-site/sdk 1.2.2 → 1.3.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 (61) hide show
  1. package/lib/Client/Client.js +7 -32
  2. package/lib/index.js +18 -16
  3. package/lib/schemas/article/Article.schema.js +9 -0
  4. package/lib/schemas/article/Item.schema.js +137 -0
  5. package/lib/schemas/article/ItemArea.schema.js +16 -0
  6. package/lib/schemas/article/ItemBase.schema.js +20 -0
  7. package/lib/schemas/article/ItemState.schema.js +52 -0
  8. package/lib/schemas/article/RichTextItem.schema.js +60 -0
  9. package/lib/schemas/article/Section.schema.js +20 -0
  10. package/lib/schemas/keyframe/Keyframes.schema.js +114 -0
  11. package/lib/schemas/project/Layout.schema.js +10 -0
  12. package/lib/schemas/project/Project.schema.js +48 -0
  13. package/lib/types/article/Article.js +2 -0
  14. package/lib/types/article/ArticleItemType.js +13 -0
  15. package/lib/types/article/Item.js +3 -0
  16. package/lib/types/article/ItemArea.js +21 -0
  17. package/lib/types/article/ItemState.js +3 -0
  18. package/lib/types/article/RichText.js +27 -0
  19. package/lib/types/article/Section.js +8 -0
  20. package/lib/types/keyframe/Keyframe.js +20 -0
  21. package/lib/types/project/Fonts.js +11 -0
  22. package/lib/types/project/Layout.js +2 -0
  23. package/lib/types/project/Meta.js +2 -0
  24. package/lib/types/project/Page.js +2 -0
  25. package/lib/types/project/Project.js +2 -0
  26. package/lib/utils.js +15 -1
  27. package/package.json +3 -3
  28. package/src/Client/Client.test.ts +1 -5
  29. package/src/Client/Client.ts +18 -51
  30. package/src/Client/__mock__/articleMock.ts +2 -2
  31. package/src/Client/__mock__/keyframesMock.ts +2 -3
  32. package/src/Client/__mock__/projectMock.ts +2 -7
  33. package/src/FontFaceGenerator/FontFaceGenerator.test.ts +2 -4
  34. package/src/FontFaceGenerator/FontFaceGenerator.ts +2 -2
  35. package/src/cli.ts +2 -2
  36. package/src/index.ts +25 -2
  37. package/src/schemas/article/Article.schema.ts +7 -0
  38. package/src/schemas/article/Item.schema.ts +175 -0
  39. package/src/schemas/article/ItemArea.schema.ts +14 -0
  40. package/src/schemas/article/ItemBase.schema.ts +20 -0
  41. package/src/schemas/article/ItemState.schema.ts +62 -0
  42. package/src/schemas/article/RichTextItem.schema.ts +68 -0
  43. package/src/schemas/article/Section.schema.ts +19 -0
  44. package/src/schemas/keyframe/Keyframes.schema.ts +128 -0
  45. package/src/schemas/project/Layout.schema.ts +8 -0
  46. package/src/schemas/project/Project.schema.ts +48 -0
  47. package/src/types/article/Article.ts +6 -0
  48. package/src/types/article/ArticleItemType.ts +9 -0
  49. package/src/types/article/Item.ts +150 -0
  50. package/src/types/article/ItemArea.ts +29 -0
  51. package/src/types/article/ItemState.ts +64 -0
  52. package/src/types/article/RichText.ts +46 -0
  53. package/src/types/article/Section.ts +22 -0
  54. package/src/types/keyframe/Keyframe.ts +102 -0
  55. package/src/types/project/Fonts.ts +25 -0
  56. package/src/types/project/Layout.ts +6 -0
  57. package/src/types/project/Meta.ts +10 -0
  58. package/src/types/project/Page.ts +13 -0
  59. package/src/types/project/Project.ts +19 -0
  60. package/src/utils.ts +16 -2
  61. package/src/Client/__mock__/typePresetsMock.ts +0 -6
@@ -13,9 +13,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.Client = void 0;
16
- const core_1 = require("@cntrl-site/core");
17
16
  const isomorphic_fetch_1 = __importDefault(require("isomorphic-fetch"));
18
17
  const url_1 = require("url");
18
+ const Article_schema_1 = require("../schemas/article/Article.schema");
19
+ const Project_schema_1 = require("../schemas/project/Project.schema");
20
+ const Keyframes_schema_1 = require("../schemas/keyframe/Keyframes.schema");
19
21
  class Client {
20
22
  constructor(APIUrl, fetchImpl = isomorphic_fetch_1.default) {
21
23
  this.fetchImpl = fetchImpl;
@@ -42,15 +44,11 @@ class Client {
42
44
  try {
43
45
  const project = yield this.fetchProject();
44
46
  const articleId = this.findArticleIdByPageSlug(pageSlug, project.pages);
45
- const [{ article, keyframes }, typePresets] = yield Promise.all([
46
- this.fetchArticle(articleId),
47
- this.fetchTypePresets()
48
- ]);
47
+ const { article, keyframes } = yield this.fetchArticle(articleId);
49
48
  const page = project.pages.find(page => page.slug === pageSlug);
50
49
  const meta = Client.getPageMeta(project.meta, page === null || page === void 0 ? void 0 : page.meta);
51
50
  return {
52
51
  project,
53
- typePresets,
54
52
  article,
55
53
  keyframes,
56
54
  meta
@@ -83,12 +81,6 @@ class Client {
83
81
  }
84
82
  });
85
83
  }
86
- getTypePresets() {
87
- return __awaiter(this, void 0, void 0, function* () {
88
- const response = yield this.fetchTypePresets();
89
- return response;
90
- });
91
- }
92
84
  fetchProject() {
93
85
  return __awaiter(this, void 0, void 0, function* () {
94
86
  const { username: projectId, password: apiKey, origin } = this.url;
@@ -102,7 +94,7 @@ class Client {
102
94
  throw new Error(`Failed to fetch project with id #${projectId}: ${response.statusText}`);
103
95
  }
104
96
  const data = yield response.json();
105
- const project = core_1.ProjectSchema.parse(data);
97
+ const project = Project_schema_1.ProjectSchema.parse(data);
106
98
  return project;
107
99
  });
108
100
  }
@@ -119,28 +111,11 @@ class Client {
119
111
  throw new Error(`Failed to fetch article with id #${articleId}: ${response.statusText}`);
120
112
  }
121
113
  const data = yield response.json();
122
- const article = core_1.ArticleSchema.parse(data.article);
123
- const keyframes = core_1.KeyframesSchema.parse(data.keyframes);
114
+ const article = Article_schema_1.ArticleSchema.parse(data.article);
115
+ const keyframes = Keyframes_schema_1.KeyframesSchema.parse(data.keyframes);
124
116
  return { article, keyframes };
125
117
  });
126
118
  }
127
- fetchTypePresets() {
128
- return __awaiter(this, void 0, void 0, function* () {
129
- const { username: projectId, password: apiKey, origin } = this.url;
130
- const url = new url_1.URL(`/projects/${projectId}/type-presets`, origin);
131
- const response = yield this.fetchImpl(url.href, {
132
- headers: {
133
- Authorization: `Bearer ${apiKey}`
134
- }
135
- });
136
- if (!response.ok) {
137
- throw new Error(`Failed to fetch type presets for the project with id #${projectId}: ${response.statusText}`);
138
- }
139
- const data = yield response.json();
140
- const typePresets = core_1.TypePresetsSchema.parse(data);
141
- return typePresets;
142
- });
143
- }
144
119
  findArticleIdByPageSlug(slug, pages) {
145
120
  const { username: projectId } = this.url;
146
121
  const page = pages.find((page) => page.slug === slug);
package/lib/index.js CHANGED
@@ -1,24 +1,26 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
2
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.getLayoutStyles = exports.FontFaceGenerator = exports.CntrlClient = void 0;
3
+ exports.KeyframeType = exports.AnchorSide = exports.ScaleAnchor = exports.ArticleItemType = exports.VerticalAlign = exports.TextTransform = exports.TextDecoration = exports.TextAlign = exports.SectionHeightMode = exports.getLayoutMediaQuery = exports.getLayoutStyles = exports.FontFaceGenerator = exports.CntrlClient = void 0;
4
+ // logic
18
5
  var Client_1 = require("./Client/Client");
19
6
  Object.defineProperty(exports, "CntrlClient", { enumerable: true, get: function () { return Client_1.Client; } });
20
7
  var FontFaceGenerator_1 = require("./FontFaceGenerator/FontFaceGenerator");
21
8
  Object.defineProperty(exports, "FontFaceGenerator", { enumerable: true, get: function () { return FontFaceGenerator_1.FontFaceGenerator; } });
22
9
  var utils_1 = require("./utils");
23
10
  Object.defineProperty(exports, "getLayoutStyles", { enumerable: true, get: function () { return utils_1.getLayoutStyles; } });
24
- __exportStar(require("@cntrl-site/core"), exports);
11
+ Object.defineProperty(exports, "getLayoutMediaQuery", { enumerable: true, get: function () { return utils_1.getLayoutMediaQuery; } });
12
+ // enums
13
+ var Section_1 = require("./types/article/Section");
14
+ Object.defineProperty(exports, "SectionHeightMode", { enumerable: true, get: function () { return Section_1.SectionHeightMode; } });
15
+ var RichText_1 = require("./types/article/RichText");
16
+ Object.defineProperty(exports, "TextAlign", { enumerable: true, get: function () { return RichText_1.TextAlign; } });
17
+ Object.defineProperty(exports, "TextDecoration", { enumerable: true, get: function () { return RichText_1.TextDecoration; } });
18
+ Object.defineProperty(exports, "TextTransform", { enumerable: true, get: function () { return RichText_1.TextTransform; } });
19
+ Object.defineProperty(exports, "VerticalAlign", { enumerable: true, get: function () { return RichText_1.VerticalAlign; } });
20
+ var ArticleItemType_1 = require("./types/article/ArticleItemType");
21
+ Object.defineProperty(exports, "ArticleItemType", { enumerable: true, get: function () { return ArticleItemType_1.ArticleItemType; } });
22
+ var ItemArea_1 = require("./types/article/ItemArea");
23
+ Object.defineProperty(exports, "ScaleAnchor", { enumerable: true, get: function () { return ItemArea_1.ScaleAnchor; } });
24
+ Object.defineProperty(exports, "AnchorSide", { enumerable: true, get: function () { return ItemArea_1.AnchorSide; } });
25
+ var Keyframe_1 = require("./types/keyframe/Keyframe");
26
+ Object.defineProperty(exports, "KeyframeType", { enumerable: true, get: function () { return Keyframe_1.KeyframeType; } });
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ArticleSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ const Section_schema_1 = require("./Section.schema");
6
+ exports.ArticleSchema = zod_1.z.object({
7
+ id: zod_1.z.string().min(1),
8
+ sections: zod_1.z.array(Section_schema_1.SectionSchema)
9
+ });
@@ -0,0 +1,137 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ItemSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ const ItemState_schema_1 = require("./ItemState.schema");
6
+ const RichTextItem_schema_1 = require("./RichTextItem.schema");
7
+ const ItemBase_schema_1 = require("./ItemBase.schema");
8
+ const ArticleItemType_1 = require("../../types/article/ArticleItemType");
9
+ const ImageItemSchema = ItemBase_schema_1.ItemBaseSchema.extend({
10
+ type: zod_1.z.literal(ArticleItemType_1.ArticleItemType.Image),
11
+ commonParams: zod_1.z.object({
12
+ url: zod_1.z.string().min(1)
13
+ }),
14
+ sticky: zod_1.z.record(zod_1.z.object({
15
+ from: zod_1.z.number(),
16
+ to: zod_1.z.number().optional()
17
+ }).nullable()),
18
+ layoutParams: zod_1.z.record(zod_1.z.object({
19
+ opacity: zod_1.z.number().nonnegative(),
20
+ radius: zod_1.z.number(),
21
+ strokeWidth: zod_1.z.number(),
22
+ strokeColor: zod_1.z.string(),
23
+ blur: zod_1.z.number()
24
+ })),
25
+ state: zod_1.z.object({
26
+ hover: zod_1.z.record(ItemState_schema_1.MediaHoverStateParamsSchema)
27
+ })
28
+ });
29
+ const VideoItemSchema = ItemBase_schema_1.ItemBaseSchema.extend({
30
+ type: zod_1.z.literal(ArticleItemType_1.ArticleItemType.Video),
31
+ commonParams: zod_1.z.object({
32
+ url: zod_1.z.string().min(1)
33
+ }),
34
+ sticky: zod_1.z.record(zod_1.z.object({
35
+ from: zod_1.z.number(),
36
+ to: zod_1.z.number().optional()
37
+ }).nullable()),
38
+ layoutParams: zod_1.z.record(zod_1.z.object({
39
+ autoplay: zod_1.z.boolean(),
40
+ opacity: zod_1.z.number().nonnegative(),
41
+ radius: zod_1.z.number(),
42
+ strokeWidth: zod_1.z.number(),
43
+ strokeColor: zod_1.z.string(),
44
+ blur: zod_1.z.number()
45
+ })),
46
+ state: zod_1.z.object({
47
+ hover: zod_1.z.record(ItemState_schema_1.MediaHoverStateParamsSchema)
48
+ })
49
+ });
50
+ const RectangleItemSchema = ItemBase_schema_1.ItemBaseSchema.extend({
51
+ type: zod_1.z.literal(ArticleItemType_1.ArticleItemType.Rectangle),
52
+ commonParams: zod_1.z.object({
53
+ ratioLock: zod_1.z.boolean()
54
+ }),
55
+ sticky: zod_1.z.record(zod_1.z.object({
56
+ from: zod_1.z.number(),
57
+ to: zod_1.z.number().optional()
58
+ }).nullable()),
59
+ layoutParams: zod_1.z.record(zod_1.z.object({
60
+ radius: zod_1.z.number(),
61
+ strokeWidth: zod_1.z.number(),
62
+ fillColor: zod_1.z.string().min(1),
63
+ strokeColor: zod_1.z.string().min(1),
64
+ blur: zod_1.z.number(),
65
+ backdropBlur: zod_1.z.number(),
66
+ blurMode: zod_1.z.enum(['default', 'backdrop'])
67
+ })),
68
+ state: zod_1.z.object({
69
+ hover: zod_1.z.record(ItemState_schema_1.RectangleHoverStateParamsSchema)
70
+ })
71
+ });
72
+ const CustomItemSchema = ItemBase_schema_1.ItemBaseSchema.extend({
73
+ type: zod_1.z.literal(ArticleItemType_1.ArticleItemType.Custom),
74
+ commonParams: zod_1.z.object({
75
+ name: zod_1.z.string()
76
+ }),
77
+ sticky: zod_1.z.record(zod_1.z.object({
78
+ from: zod_1.z.number(),
79
+ to: zod_1.z.number().optional()
80
+ }).nullable()),
81
+ layoutParams: zod_1.z.record(zod_1.z.object({})),
82
+ state: zod_1.z.object({
83
+ hover: zod_1.z.record(ItemState_schema_1.CustomItemHoverStateParamsSchema)
84
+ })
85
+ });
86
+ const VimeoEmbedItemSchema = ItemBase_schema_1.ItemBaseSchema.extend({
87
+ type: zod_1.z.literal(ArticleItemType_1.ArticleItemType.VimeoEmbed),
88
+ commonParams: zod_1.z.object({
89
+ play: zod_1.z.union([zod_1.z.literal('on-hover'), zod_1.z.literal('on-click'), zod_1.z.literal('auto')]),
90
+ controls: zod_1.z.boolean(),
91
+ loop: zod_1.z.boolean(),
92
+ muted: zod_1.z.boolean(),
93
+ pictureInPicture: zod_1.z.boolean(),
94
+ url: zod_1.z.string().min(1),
95
+ ratioLock: zod_1.z.boolean()
96
+ }),
97
+ sticky: zod_1.z.record(zod_1.z.object({
98
+ from: zod_1.z.number(),
99
+ to: zod_1.z.number().optional()
100
+ }).nullable()),
101
+ layoutParams: zod_1.z.record(zod_1.z.object({
102
+ radius: zod_1.z.number(),
103
+ blur: zod_1.z.number()
104
+ })),
105
+ state: zod_1.z.object({
106
+ hover: zod_1.z.record(ItemState_schema_1.EmbedHoverStateParamsSchema)
107
+ })
108
+ });
109
+ const YoutubeEmbedItemSchema = ItemBase_schema_1.ItemBaseSchema.extend({
110
+ type: zod_1.z.literal(ArticleItemType_1.ArticleItemType.YoutubeEmbed),
111
+ commonParams: zod_1.z.object({
112
+ play: zod_1.z.enum(['on-hover', 'on-click', 'auto']),
113
+ controls: zod_1.z.boolean(),
114
+ loop: zod_1.z.boolean(),
115
+ url: zod_1.z.string().min(1)
116
+ }),
117
+ sticky: zod_1.z.record(zod_1.z.object({
118
+ from: zod_1.z.number(),
119
+ to: zod_1.z.number().optional()
120
+ }).nullable()),
121
+ layoutParams: zod_1.z.record(zod_1.z.object({
122
+ radius: zod_1.z.number(),
123
+ blur: zod_1.z.number()
124
+ })),
125
+ state: zod_1.z.object({
126
+ hover: zod_1.z.record(ItemState_schema_1.EmbedHoverStateParamsSchema)
127
+ })
128
+ });
129
+ exports.ItemSchema = zod_1.z.discriminatedUnion('type', [
130
+ ImageItemSchema,
131
+ VideoItemSchema,
132
+ RectangleItemSchema,
133
+ CustomItemSchema,
134
+ RichTextItem_schema_1.RichTextItemSchema,
135
+ VimeoEmbedItemSchema,
136
+ YoutubeEmbedItemSchema
137
+ ]);
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ItemAreaSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ const ItemArea_1 = require("../../types/article/ItemArea");
6
+ exports.ItemAreaSchema = zod_1.z.object({
7
+ top: zod_1.z.number(),
8
+ left: zod_1.z.number(),
9
+ width: zod_1.z.number(),
10
+ height: zod_1.z.number(),
11
+ zIndex: zod_1.z.number(),
12
+ angle: zod_1.z.number(),
13
+ anchorSide: zod_1.z.nativeEnum(ItemArea_1.AnchorSide).optional(),
14
+ scale: zod_1.z.number().nonnegative(),
15
+ scaleAnchor: zod_1.z.nativeEnum(ItemArea_1.ScaleAnchor)
16
+ });
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ItemBaseSchema = exports.Link = void 0;
4
+ const zod_1 = require("zod");
5
+ const ItemArea_schema_1 = require("./ItemArea.schema");
6
+ exports.Link = zod_1.z.object({
7
+ url: zod_1.z.string().min(1),
8
+ target: zod_1.z.string().min(1)
9
+ });
10
+ const CommonParamsBase = zod_1.z.object({
11
+ sizing: zod_1.z.string().min(1)
12
+ });
13
+ exports.ItemBaseSchema = zod_1.z.object({
14
+ id: zod_1.z.string().min(1),
15
+ area: zod_1.z.record(ItemArea_schema_1.ItemAreaSchema),
16
+ hidden: zod_1.z.record(zod_1.z.boolean()),
17
+ link: exports.Link.optional(),
18
+ commonParams: CommonParamsBase,
19
+ layoutParams: zod_1.z.record(zod_1.z.any()).optional()
20
+ });
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ItemHoverStateParamsSchema = exports.RichTextHoverStateParamsSchema = exports.EmbedHoverStateParamsSchema = exports.CustomItemHoverStateParamsSchema = exports.RectangleHoverStateParamsSchema = exports.MediaHoverStateParamsSchema = exports.ItemHoverStateBaseSchema = exports.getHoverParamsSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ const getHoverParamsSchema = (schema) => {
6
+ return zod_1.z.object({
7
+ timing: zod_1.z.string(),
8
+ duration: zod_1.z.number(),
9
+ delay: zod_1.z.number(),
10
+ value: schema
11
+ }).optional();
12
+ };
13
+ exports.getHoverParamsSchema = getHoverParamsSchema;
14
+ exports.ItemHoverStateBaseSchema = zod_1.z.object({
15
+ width: (0, exports.getHoverParamsSchema)(zod_1.z.number()),
16
+ height: (0, exports.getHoverParamsSchema)(zod_1.z.number()),
17
+ angle: (0, exports.getHoverParamsSchema)(zod_1.z.number()),
18
+ top: (0, exports.getHoverParamsSchema)(zod_1.z.number()),
19
+ left: (0, exports.getHoverParamsSchema)(zod_1.z.number()),
20
+ scale: (0, exports.getHoverParamsSchema)(zod_1.z.number()),
21
+ blur: (0, exports.getHoverParamsSchema)(zod_1.z.number())
22
+ });
23
+ exports.MediaHoverStateParamsSchema = zod_1.z.object({
24
+ opacity: (0, exports.getHoverParamsSchema)(zod_1.z.number()),
25
+ radius: (0, exports.getHoverParamsSchema)(zod_1.z.number()),
26
+ strokeWidth: (0, exports.getHoverParamsSchema)(zod_1.z.number()),
27
+ strokeColor: (0, exports.getHoverParamsSchema)(zod_1.z.string())
28
+ })
29
+ .merge(exports.ItemHoverStateBaseSchema);
30
+ exports.RectangleHoverStateParamsSchema = zod_1.z.object({
31
+ strokeWidth: (0, exports.getHoverParamsSchema)(zod_1.z.number()),
32
+ radius: (0, exports.getHoverParamsSchema)(zod_1.z.number()),
33
+ fillColor: (0, exports.getHoverParamsSchema)(zod_1.z.string()),
34
+ strokeColor: (0, exports.getHoverParamsSchema)(zod_1.z.string()),
35
+ backdropBlur: (0, exports.getHoverParamsSchema)(zod_1.z.number())
36
+ }).merge(exports.ItemHoverStateBaseSchema);
37
+ exports.CustomItemHoverStateParamsSchema = exports.ItemHoverStateBaseSchema;
38
+ exports.EmbedHoverStateParamsSchema = zod_1.z.object({
39
+ radius: (0, exports.getHoverParamsSchema)(zod_1.z.number())
40
+ }).merge(exports.ItemHoverStateBaseSchema);
41
+ exports.RichTextHoverStateParamsSchema = zod_1.z.object({
42
+ color: (0, exports.getHoverParamsSchema)(zod_1.z.string()),
43
+ letterSpacing: (0, exports.getHoverParamsSchema)(zod_1.z.number()),
44
+ wordSpacing: (0, exports.getHoverParamsSchema)(zod_1.z.number())
45
+ }).merge(exports.ItemHoverStateBaseSchema);
46
+ exports.ItemHoverStateParamsSchema = zod_1.z.union([
47
+ exports.EmbedHoverStateParamsSchema,
48
+ exports.MediaHoverStateParamsSchema,
49
+ exports.RectangleHoverStateParamsSchema,
50
+ exports.RichTextHoverStateParamsSchema,
51
+ exports.CustomItemHoverStateParamsSchema
52
+ ]);
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RichTextItemSchema = exports.RichTextBlockSchema = exports.RichTextStyleSchema = exports.RichTextEntitySchema = void 0;
4
+ const zod_1 = require("zod");
5
+ const RichText_1 = require("../../types/article/RichText");
6
+ const ItemBase_schema_1 = require("./ItemBase.schema");
7
+ const ArticleItemType_1 = require("../../types/article/ArticleItemType");
8
+ const ItemState_schema_1 = require("./ItemState.schema");
9
+ exports.RichTextEntitySchema = zod_1.z.object({
10
+ start: zod_1.z.number().nonnegative(),
11
+ end: zod_1.z.number().nonnegative(),
12
+ type: zod_1.z.string(),
13
+ data: zod_1.z.any().optional()
14
+ });
15
+ exports.RichTextStyleSchema = zod_1.z.object({
16
+ start: zod_1.z.number().nonnegative(),
17
+ end: zod_1.z.number().nonnegative(),
18
+ style: zod_1.z.string().min(1),
19
+ value: zod_1.z.string().optional()
20
+ });
21
+ exports.RichTextBlockSchema = zod_1.z.lazy(() => (zod_1.z.object({
22
+ start: zod_1.z.number().nonnegative(),
23
+ end: zod_1.z.number().nonnegative(),
24
+ type: zod_1.z.string().min(1),
25
+ entities: zod_1.z.array(exports.RichTextEntitySchema).optional(),
26
+ children: zod_1.z.array(exports.RichTextBlockSchema).optional(),
27
+ data: zod_1.z.any().optional()
28
+ })));
29
+ exports.RichTextItemSchema = ItemBase_schema_1.ItemBaseSchema.extend({
30
+ type: zod_1.z.literal(ArticleItemType_1.ArticleItemType.RichText),
31
+ commonParams: zod_1.z.object({
32
+ text: zod_1.z.string(),
33
+ blocks: zod_1.z.array(exports.RichTextBlockSchema).optional()
34
+ }),
35
+ sticky: zod_1.z.record(zod_1.z.object({
36
+ from: zod_1.z.number(),
37
+ to: zod_1.z.number().optional()
38
+ }).nullable()),
39
+ layoutParams: zod_1.z.record(zod_1.z.object({
40
+ rangeStyles: zod_1.z.array(exports.RichTextStyleSchema).optional(),
41
+ textAlign: zod_1.z.nativeEnum(RichText_1.TextAlign),
42
+ sizing: zod_1.z.string(),
43
+ blur: zod_1.z.number(),
44
+ fontSize: zod_1.z.number(),
45
+ lineHeight: zod_1.z.number(),
46
+ letterSpacing: zod_1.z.number(),
47
+ wordSpacing: zod_1.z.number(),
48
+ textTransform: zod_1.z.nativeEnum(RichText_1.TextTransform),
49
+ verticalAlign: zod_1.z.nativeEnum(RichText_1.VerticalAlign),
50
+ color: zod_1.z.string(),
51
+ typeFace: zod_1.z.string(),
52
+ fontStyle: zod_1.z.string(),
53
+ fontWeight: zod_1.z.number(),
54
+ fontVariant: zod_1.z.string(),
55
+ textDecoration: zod_1.z.nativeEnum(RichText_1.TextDecoration),
56
+ })),
57
+ state: zod_1.z.object({
58
+ hover: zod_1.z.record(ItemState_schema_1.RichTextHoverStateParamsSchema)
59
+ })
60
+ });
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SectionSchema = exports.SectionHeightSchema = void 0;
4
+ const Section_1 = require("../../types/article/Section");
5
+ const zod_1 = require("zod");
6
+ const Item_schema_1 = require("./Item.schema");
7
+ exports.SectionHeightSchema = zod_1.z.object({
8
+ mode: zod_1.z.nativeEnum(Section_1.SectionHeightMode),
9
+ units: zod_1.z.number().nonnegative(),
10
+ vhUnits: zod_1.z.number().nonnegative().optional()
11
+ });
12
+ exports.SectionSchema = zod_1.z.object({
13
+ id: zod_1.z.string().min(1),
14
+ items: zod_1.z.array(Item_schema_1.ItemSchema),
15
+ name: zod_1.z.string().optional(),
16
+ height: zod_1.z.record(exports.SectionHeightSchema),
17
+ position: zod_1.z.record(zod_1.z.number()),
18
+ hidden: zod_1.z.record(zod_1.z.boolean()),
19
+ color: zod_1.z.record(zod_1.z.nullable(zod_1.z.string()))
20
+ });
@@ -0,0 +1,114 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.KeyframesSchema = exports.KeyframeSchema = void 0;
4
+ const Keyframe_1 = require("../../types/keyframe/Keyframe");
5
+ const zod_1 = require("zod");
6
+ const KeyframesBaseSchema = zod_1.z.object({
7
+ id: zod_1.z.string().min(1),
8
+ layoutId: zod_1.z.string().min(1),
9
+ itemId: zod_1.z.string().min(1),
10
+ position: zod_1.z.number()
11
+ });
12
+ const DimensionsKeyframeSchema = KeyframesBaseSchema.extend({
13
+ type: zod_1.z.literal(Keyframe_1.KeyframeType.Dimensions),
14
+ value: zod_1.z.object({
15
+ width: zod_1.z.number().nonnegative(),
16
+ height: zod_1.z.number().nonnegative()
17
+ })
18
+ });
19
+ const PositionKeyframeSchema = KeyframesBaseSchema.extend({
20
+ type: zod_1.z.literal(Keyframe_1.KeyframeType.Position),
21
+ value: zod_1.z.object({
22
+ top: zod_1.z.number(),
23
+ left: zod_1.z.number()
24
+ })
25
+ });
26
+ const RotationKeyframeSchema = KeyframesBaseSchema.extend({
27
+ type: zod_1.z.literal(Keyframe_1.KeyframeType.Rotation),
28
+ value: zod_1.z.object({
29
+ angle: zod_1.z.number()
30
+ })
31
+ });
32
+ const BorderRadiusKeyframeSchema = KeyframesBaseSchema.extend({
33
+ type: zod_1.z.literal(Keyframe_1.KeyframeType.BorderRadius),
34
+ value: zod_1.z.object({
35
+ radius: zod_1.z.number().nonnegative()
36
+ })
37
+ });
38
+ const BorderWidthKeyframeSchema = KeyframesBaseSchema.extend({
39
+ type: zod_1.z.literal(Keyframe_1.KeyframeType.BorderWidth),
40
+ value: zod_1.z.object({
41
+ borderWidth: zod_1.z.number().nonnegative()
42
+ })
43
+ });
44
+ const ColorKeyframeSchema = KeyframesBaseSchema.extend({
45
+ type: zod_1.z.literal(Keyframe_1.KeyframeType.Color),
46
+ value: zod_1.z.object({
47
+ color: zod_1.z.string()
48
+ })
49
+ });
50
+ const BorderColorKeyframeSchema = KeyframesBaseSchema.extend({
51
+ type: zod_1.z.literal(Keyframe_1.KeyframeType.BorderColor),
52
+ value: zod_1.z.object({
53
+ color: zod_1.z.string()
54
+ })
55
+ });
56
+ const OpacityKeyframeSchema = KeyframesBaseSchema.extend({
57
+ type: zod_1.z.literal(Keyframe_1.KeyframeType.Opacity),
58
+ value: zod_1.z.object({
59
+ opacity: zod_1.z.number().nonnegative()
60
+ })
61
+ });
62
+ const ScaleKeyframeSchema = KeyframesBaseSchema.extend({
63
+ type: zod_1.z.literal(Keyframe_1.KeyframeType.Scale),
64
+ value: zod_1.z.object({
65
+ scale: zod_1.z.number().nonnegative()
66
+ })
67
+ });
68
+ const BlurKeyframeSchema = KeyframesBaseSchema.extend({
69
+ type: zod_1.z.literal(Keyframe_1.KeyframeType.Blur),
70
+ value: zod_1.z.object({
71
+ blur: zod_1.z.number()
72
+ })
73
+ });
74
+ const BackdropBlurKeyframeSchema = KeyframesBaseSchema.extend({
75
+ type: zod_1.z.literal(Keyframe_1.KeyframeType.BackdropBlur),
76
+ value: zod_1.z.object({
77
+ backdropBlur: zod_1.z.number()
78
+ })
79
+ });
80
+ const TextColorKeyframeSchema = KeyframesBaseSchema.extend({
81
+ type: zod_1.z.literal(Keyframe_1.KeyframeType.TextColor),
82
+ value: zod_1.z.object({
83
+ color: zod_1.z.string()
84
+ })
85
+ });
86
+ const LetterSpacingKeyframeSchema = KeyframesBaseSchema.extend({
87
+ type: zod_1.z.literal(Keyframe_1.KeyframeType.LetterSpacing),
88
+ value: zod_1.z.object({
89
+ letterSpacing: zod_1.z.number()
90
+ })
91
+ });
92
+ const WordSpacingKeyframeSchema = KeyframesBaseSchema.extend({
93
+ type: zod_1.z.literal(Keyframe_1.KeyframeType.WordSpacing),
94
+ value: zod_1.z.object({
95
+ wordSpacing: zod_1.z.number()
96
+ })
97
+ });
98
+ exports.KeyframeSchema = zod_1.z.discriminatedUnion('type', [
99
+ DimensionsKeyframeSchema,
100
+ PositionKeyframeSchema,
101
+ RotationKeyframeSchema,
102
+ BorderRadiusKeyframeSchema,
103
+ BorderWidthKeyframeSchema,
104
+ ColorKeyframeSchema,
105
+ BorderColorKeyframeSchema,
106
+ OpacityKeyframeSchema,
107
+ ScaleKeyframeSchema,
108
+ BlurKeyframeSchema,
109
+ BackdropBlurKeyframeSchema,
110
+ TextColorKeyframeSchema,
111
+ LetterSpacingKeyframeSchema,
112
+ WordSpacingKeyframeSchema
113
+ ]);
114
+ exports.KeyframesSchema = zod_1.z.array(exports.KeyframeSchema);
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LayoutSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ exports.LayoutSchema = zod_1.z.object({
6
+ id: zod_1.z.string(),
7
+ title: zod_1.z.string(),
8
+ startsWith: zod_1.z.number().nonnegative(),
9
+ exemplary: zod_1.z.number().positive()
10
+ });
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ProjectSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ const Layout_schema_1 = require("./Layout.schema");
6
+ const Fonts_1 = require("../../types/project/Fonts");
7
+ exports.ProjectSchema = zod_1.z.object({
8
+ id: zod_1.z.string().min(1),
9
+ html: zod_1.z.object({
10
+ head: zod_1.z.string(),
11
+ afterBodyOpen: zod_1.z.string(),
12
+ beforeBodyClose: zod_1.z.string()
13
+ }),
14
+ meta: zod_1.z.object({
15
+ title: zod_1.z.string().optional(),
16
+ description: zod_1.z.string().optional(),
17
+ opengraphThumbnail: zod_1.z.string().optional(),
18
+ keywords: zod_1.z.string().optional(),
19
+ favicon: zod_1.z.string().optional()
20
+ }),
21
+ layouts: zod_1.z.array(Layout_schema_1.LayoutSchema),
22
+ pages: zod_1.z.array(zod_1.z.object({
23
+ title: zod_1.z.string(),
24
+ articleId: zod_1.z.string().min(1),
25
+ slug: zod_1.z.string(),
26
+ meta: zod_1.z.object({
27
+ title: zod_1.z.string().optional(),
28
+ description: zod_1.z.string().optional(),
29
+ opengraphThumbnail: zod_1.z.string().optional(),
30
+ keywords: zod_1.z.string().optional(),
31
+ enabled: zod_1.z.boolean()
32
+ }).optional(),
33
+ id: zod_1.z.string().min(1)
34
+ })),
35
+ fonts: zod_1.z.object({
36
+ google: zod_1.z.string(),
37
+ adobe: zod_1.z.string(),
38
+ custom: zod_1.z.array(zod_1.z.object({
39
+ name: zod_1.z.string().min(1),
40
+ style: zod_1.z.string().min(1),
41
+ weight: zod_1.z.number(),
42
+ files: zod_1.z.array(zod_1.z.object({
43
+ type: zod_1.z.nativeEnum(Fonts_1.FontFileTypes),
44
+ url: zod_1.z.string().url()
45
+ }))
46
+ }))
47
+ })
48
+ });
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ArticleItemType = void 0;
4
+ var ArticleItemType;
5
+ (function (ArticleItemType) {
6
+ ArticleItemType["Image"] = "image";
7
+ ArticleItemType["RichText"] = "richtext";
8
+ ArticleItemType["Video"] = "video";
9
+ ArticleItemType["Rectangle"] = "rectangle";
10
+ ArticleItemType["VimeoEmbed"] = "vimeo-embed";
11
+ ArticleItemType["YoutubeEmbed"] = "youtube-embed";
12
+ ArticleItemType["Custom"] = "custom";
13
+ })(ArticleItemType = exports.ArticleItemType || (exports.ArticleItemType = {}));
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const ArticleItemType_1 = require("./ArticleItemType");
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ScaleAnchor = exports.AnchorSide = void 0;
4
+ var AnchorSide;
5
+ (function (AnchorSide) {
6
+ AnchorSide["Top"] = "top";
7
+ AnchorSide["Bottom"] = "bottom";
8
+ AnchorSide["Center"] = "center";
9
+ })(AnchorSide = exports.AnchorSide || (exports.AnchorSide = {}));
10
+ var ScaleAnchor;
11
+ (function (ScaleAnchor) {
12
+ ScaleAnchor["TopLeft"] = "top-left";
13
+ ScaleAnchor["TopCenter"] = "top-center";
14
+ ScaleAnchor["TopRight"] = "top-right";
15
+ ScaleAnchor["MiddleLeft"] = "middle-left";
16
+ ScaleAnchor["MiddleCenter"] = "middle-center";
17
+ ScaleAnchor["MiddleRight"] = "middle-right";
18
+ ScaleAnchor["BottomLeft"] = "bottom-left";
19
+ ScaleAnchor["BottomCenter"] = "bottom-center";
20
+ ScaleAnchor["BottomRight"] = "bottom-right";
21
+ })(ScaleAnchor = exports.ScaleAnchor || (exports.ScaleAnchor = {}));