@cntrl-site/sdk 1.22.19-alpha.0 → 1.22.21-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.
@@ -8,7 +8,7 @@ export declare class Client {
8
8
  private url;
9
9
  constructor(APIUrl: string, fetchImpl?: FetchImpl);
10
10
  private static getPageMeta;
11
- getPageData(pageSlug: string): Promise<CntrlPageData>;
11
+ getPageData(pageSlug: string, buildMode?: 'default' | 'self-hosted'): Promise<CntrlPageData>;
12
12
  getProjectPagesPaths(): Promise<string[]>;
13
13
  getLayouts(): Promise<Layout[]>;
14
14
  private fetchProject;
@@ -39,12 +39,12 @@ class Client {
39
39
  favicon: (_e = projectMeta.favicon) !== null && _e !== void 0 ? _e : ''
40
40
  } : projectMeta;
41
41
  }
42
- getPageData(pageSlug) {
43
- return __awaiter(this, void 0, void 0, function* () {
42
+ getPageData(pageSlug_1) {
43
+ return __awaiter(this, arguments, void 0, function* (pageSlug, buildMode = 'default') {
44
44
  try {
45
- const project = yield this.fetchProject();
45
+ const project = yield this.fetchProject(buildMode);
46
46
  const articleId = this.findArticleIdByPageSlug(pageSlug, project.pages);
47
- const { article, keyframes } = yield this.fetchArticle(articleId);
47
+ const { article, keyframes } = yield this.fetchArticle(articleId, buildMode);
48
48
  const page = project.pages.find(page => page.slug === pageSlug);
49
49
  const meta = Client.getPageMeta(project.meta, page === null || page === void 0 ? void 0 : page.meta);
50
50
  return {
@@ -82,9 +82,9 @@ class Client {
82
82
  });
83
83
  }
84
84
  fetchProject() {
85
- return __awaiter(this, void 0, void 0, function* () {
85
+ return __awaiter(this, arguments, void 0, function* (buildMode = 'default') {
86
86
  const { username: projectId, password: apiKey, origin } = this.url;
87
- const url = new url_1.URL(`/projects/${projectId}`, origin);
87
+ const url = new url_1.URL(`/projects/${projectId}?buildMode=${buildMode}`, origin);
88
88
  const response = yield this.fetchImpl(url.href, {
89
89
  headers: {
90
90
  Authorization: `Bearer ${apiKey}`
@@ -98,10 +98,10 @@ class Client {
98
98
  return project;
99
99
  });
100
100
  }
101
- fetchArticle(articleId) {
102
- return __awaiter(this, void 0, void 0, function* () {
101
+ fetchArticle(articleId_1) {
102
+ return __awaiter(this, arguments, void 0, function* (articleId, buildMode = 'default') {
103
103
  const { username: projectId, password: apiKey, origin } = this.url;
104
- const url = new url_1.URL(`/projects/${projectId}/articles/${articleId}`, origin);
104
+ const url = new url_1.URL(`/projects/${projectId}/articles/${articleId}?buildMode=${buildMode}`, origin);
105
105
  const response = yield this.fetchImpl(url.href, {
106
106
  headers: {
107
107
  Authorization: `Bearer ${apiKey}`
package/dist/index.js CHANGED
@@ -321,10 +321,7 @@ const VideoItemSchema = ItemBaseSchema.extend({
321
321
  strokeWidth: zod.z.number(),
322
322
  strokeColor: zod.z.string(),
323
323
  blur: zod.z.number(),
324
- isDraggable: zod.z.boolean().optional(),
325
- play: zod.z.enum(["on-hover", "on-click", "auto"]),
326
- muted: zod.z.boolean(),
327
- controls: zod.z.boolean()
324
+ isDraggable: zod.z.boolean().optional()
328
325
  })
329
326
  ),
330
327
  state: zod.z.record(MediaStateParamsSchema)
@@ -375,6 +372,11 @@ const CustomItemSchema = ItemBaseSchema.extend({
375
372
  const VimeoEmbedItemSchema = ItemBaseSchema.extend({
376
373
  type: zod.z.literal(ArticleItemType.VimeoEmbed),
377
374
  commonParams: zod.z.object({
375
+ play: zod.z.union([zod.z.literal("on-hover"), zod.z.literal("on-click"), zod.z.literal("auto")]),
376
+ controls: zod.z.boolean(),
377
+ loop: zod.z.boolean(),
378
+ muted: zod.z.boolean(),
379
+ pictureInPicture: zod.z.boolean(),
378
380
  url: zod.z.string().min(1),
379
381
  coverUrl: zod.z.string().nullable(),
380
382
  ratioLock: zod.z.boolean(),
@@ -390,12 +392,7 @@ const VimeoEmbedItemSchema = ItemBaseSchema.extend({
390
392
  zod.z.object({
391
393
  radius: zod.z.number(),
392
394
  blur: zod.z.number(),
393
- opacity: zod.z.number().nonnegative(),
394
- play: zod.z.union([zod.z.literal("on-hover"), zod.z.literal("on-click"), zod.z.literal("auto")]),
395
- controls: zod.z.boolean(),
396
- loop: zod.z.boolean(),
397
- muted: zod.z.boolean(),
398
- pictureInPicture: zod.z.boolean()
395
+ opacity: zod.z.number().nonnegative()
399
396
  })
400
397
  ),
401
398
  state: zod.z.record(EmbedStateParamsSchema)
@@ -403,6 +400,9 @@ const VimeoEmbedItemSchema = ItemBaseSchema.extend({
403
400
  const YoutubeEmbedItemSchema = ItemBaseSchema.extend({
404
401
  type: zod.z.literal(ArticleItemType.YoutubeEmbed),
405
402
  commonParams: zod.z.object({
403
+ play: zod.z.enum(["on-hover", "on-click", "auto"]),
404
+ controls: zod.z.boolean(),
405
+ loop: zod.z.boolean(),
406
406
  url: zod.z.string().min(1),
407
407
  coverUrl: zod.z.string().nullable(),
408
408
  pointerEvents
@@ -417,10 +417,7 @@ const YoutubeEmbedItemSchema = ItemBaseSchema.extend({
417
417
  zod.z.object({
418
418
  radius: zod.z.number(),
419
419
  blur: zod.z.number(),
420
- opacity: zod.z.number().nonnegative(),
421
- play: zod.z.enum(["on-hover", "on-click", "auto"]),
422
- controls: zod.z.boolean(),
423
- loop: zod.z.boolean()
420
+ opacity: zod.z.number().nonnegative()
424
421
  })
425
422
  ),
426
423
  state: zod.z.record(EmbedStateParamsSchema)
@@ -786,11 +783,11 @@ class Client {
786
783
  favicon: projectMeta.favicon ?? ""
787
784
  } : projectMeta;
788
785
  }
789
- async getPageData(pageSlug) {
786
+ async getPageData(pageSlug, buildMode = "default") {
790
787
  try {
791
- const project = await this.fetchProject();
788
+ const project = await this.fetchProject(buildMode);
792
789
  const articleId = this.findArticleIdByPageSlug(pageSlug, project.pages);
793
- const { article, keyframes } = await this.fetchArticle(articleId);
790
+ const { article, keyframes } = await this.fetchArticle(articleId, buildMode);
794
791
  const page = project.pages.find((page2) => page2.slug === pageSlug);
795
792
  const meta = Client.getPageMeta(project.meta, page == null ? void 0 : page.meta);
796
793
  return {
@@ -819,9 +816,9 @@ class Client {
819
816
  throw e;
820
817
  }
821
818
  }
822
- async fetchProject() {
819
+ async fetchProject(buildMode = "default") {
823
820
  const { username: projectId, password: apiKey, origin } = this.url;
824
- const url$1 = new url.URL(`/projects/${projectId}`, origin);
821
+ const url$1 = new url.URL(`/projects/${projectId}?buildMode=${buildMode}`, origin);
825
822
  const response = await this.fetchImpl(url$1.href, {
826
823
  headers: {
827
824
  Authorization: `Bearer ${apiKey}`
@@ -834,9 +831,9 @@ class Client {
834
831
  const project = ProjectSchema.parse(data);
835
832
  return project;
836
833
  }
837
- async fetchArticle(articleId) {
834
+ async fetchArticle(articleId, buildMode = "default") {
838
835
  const { username: projectId, password: apiKey, origin } = this.url;
839
- const url$1 = new url.URL(`/projects/${projectId}/articles/${articleId}`, origin);
836
+ const url$1 = new url.URL(`/projects/${projectId}/articles/${articleId}?buildMode=${buildMode}`, origin);
840
837
  const response = await this.fetchImpl(url$1.href, {
841
838
  headers: {
842
839
  Authorization: `Bearer ${apiKey}`
package/dist/index.mjs CHANGED
@@ -302,10 +302,7 @@ const VideoItemSchema = ItemBaseSchema.extend({
302
302
  strokeWidth: z.number(),
303
303
  strokeColor: z.string(),
304
304
  blur: z.number(),
305
- isDraggable: z.boolean().optional(),
306
- play: z.enum(["on-hover", "on-click", "auto"]),
307
- muted: z.boolean(),
308
- controls: z.boolean()
305
+ isDraggable: z.boolean().optional()
309
306
  })
310
307
  ),
311
308
  state: z.record(MediaStateParamsSchema)
@@ -356,6 +353,11 @@ const CustomItemSchema = ItemBaseSchema.extend({
356
353
  const VimeoEmbedItemSchema = ItemBaseSchema.extend({
357
354
  type: z.literal(ArticleItemType.VimeoEmbed),
358
355
  commonParams: z.object({
356
+ play: z.union([z.literal("on-hover"), z.literal("on-click"), z.literal("auto")]),
357
+ controls: z.boolean(),
358
+ loop: z.boolean(),
359
+ muted: z.boolean(),
360
+ pictureInPicture: z.boolean(),
359
361
  url: z.string().min(1),
360
362
  coverUrl: z.string().nullable(),
361
363
  ratioLock: z.boolean(),
@@ -371,12 +373,7 @@ const VimeoEmbedItemSchema = ItemBaseSchema.extend({
371
373
  z.object({
372
374
  radius: z.number(),
373
375
  blur: z.number(),
374
- opacity: z.number().nonnegative(),
375
- play: z.union([z.literal("on-hover"), z.literal("on-click"), z.literal("auto")]),
376
- controls: z.boolean(),
377
- loop: z.boolean(),
378
- muted: z.boolean(),
379
- pictureInPicture: z.boolean()
376
+ opacity: z.number().nonnegative()
380
377
  })
381
378
  ),
382
379
  state: z.record(EmbedStateParamsSchema)
@@ -384,6 +381,9 @@ const VimeoEmbedItemSchema = ItemBaseSchema.extend({
384
381
  const YoutubeEmbedItemSchema = ItemBaseSchema.extend({
385
382
  type: z.literal(ArticleItemType.YoutubeEmbed),
386
383
  commonParams: z.object({
384
+ play: z.enum(["on-hover", "on-click", "auto"]),
385
+ controls: z.boolean(),
386
+ loop: z.boolean(),
387
387
  url: z.string().min(1),
388
388
  coverUrl: z.string().nullable(),
389
389
  pointerEvents
@@ -398,10 +398,7 @@ const YoutubeEmbedItemSchema = ItemBaseSchema.extend({
398
398
  z.object({
399
399
  radius: z.number(),
400
400
  blur: z.number(),
401
- opacity: z.number().nonnegative(),
402
- play: z.enum(["on-hover", "on-click", "auto"]),
403
- controls: z.boolean(),
404
- loop: z.boolean()
401
+ opacity: z.number().nonnegative()
405
402
  })
406
403
  ),
407
404
  state: z.record(EmbedStateParamsSchema)
@@ -767,11 +764,11 @@ class Client {
767
764
  favicon: projectMeta.favicon ?? ""
768
765
  } : projectMeta;
769
766
  }
770
- async getPageData(pageSlug) {
767
+ async getPageData(pageSlug, buildMode = "default") {
771
768
  try {
772
- const project = await this.fetchProject();
769
+ const project = await this.fetchProject(buildMode);
773
770
  const articleId = this.findArticleIdByPageSlug(pageSlug, project.pages);
774
- const { article, keyframes } = await this.fetchArticle(articleId);
771
+ const { article, keyframes } = await this.fetchArticle(articleId, buildMode);
775
772
  const page = project.pages.find((page2) => page2.slug === pageSlug);
776
773
  const meta = Client.getPageMeta(project.meta, page == null ? void 0 : page.meta);
777
774
  return {
@@ -800,9 +797,9 @@ class Client {
800
797
  throw e;
801
798
  }
802
799
  }
803
- async fetchProject() {
800
+ async fetchProject(buildMode = "default") {
804
801
  const { username: projectId, password: apiKey, origin } = this.url;
805
- const url = new URL(`/projects/${projectId}`, origin);
802
+ const url = new URL(`/projects/${projectId}?buildMode=${buildMode}`, origin);
806
803
  const response = await this.fetchImpl(url.href, {
807
804
  headers: {
808
805
  Authorization: `Bearer ${apiKey}`
@@ -815,9 +812,9 @@ class Client {
815
812
  const project = ProjectSchema.parse(data);
816
813
  return project;
817
814
  }
818
- async fetchArticle(articleId) {
815
+ async fetchArticle(articleId, buildMode = "default") {
819
816
  const { username: projectId, password: apiKey, origin } = this.url;
820
- const url = new URL(`/projects/${projectId}/articles/${articleId}`, origin);
817
+ const url = new URL(`/projects/${projectId}/articles/${articleId}?buildMode=${buildMode}`, origin);
821
818
  const response = await this.fetchImpl(url.href, {
822
819
  headers: {
823
820
  Authorization: `Bearer ${apiKey}`
@@ -31,16 +31,16 @@ export declare const ArticleSchema: z.ZodObject<{
31
31
  offsetX: z.ZodNullable<z.ZodNumber>;
32
32
  }, "strip", z.ZodTypeAny, {
33
33
  url: string;
34
- coverUrl: string | null;
35
34
  play: "on-click" | "auto";
35
+ coverUrl: string | null;
36
36
  position: string;
37
37
  type: "video";
38
38
  size: string;
39
39
  offsetX: number | null;
40
40
  }, {
41
41
  url: string;
42
- coverUrl: string | null;
43
42
  play: "on-click" | "auto";
43
+ coverUrl: string | null;
44
44
  position: string;
45
45
  type: "video";
46
46
  size: string;
@@ -78,8 +78,8 @@ export declare const ArticleSchema: z.ZodObject<{
78
78
  name?: string | undefined;
79
79
  media?: Record<string, {
80
80
  url: string;
81
- coverUrl: string | null;
82
81
  play: "on-click" | "auto";
82
+ coverUrl: string | null;
83
83
  position: string;
84
84
  type: "video";
85
85
  size: string;
@@ -105,8 +105,8 @@ export declare const ArticleSchema: z.ZodObject<{
105
105
  name?: string | undefined;
106
106
  media?: Record<string, {
107
107
  url: string;
108
- coverUrl: string | null;
109
108
  play: "on-click" | "auto";
109
+ coverUrl: string | null;
110
110
  position: string;
111
111
  type: "video";
112
112
  size: string;
@@ -212,8 +212,8 @@ export declare const ArticleSchema: z.ZodObject<{
212
212
  name?: string | undefined;
213
213
  media?: Record<string, {
214
214
  url: string;
215
- coverUrl: string | null;
216
215
  play: "on-click" | "auto";
216
+ coverUrl: string | null;
217
217
  position: string;
218
218
  type: "video";
219
219
  size: string;
@@ -259,8 +259,8 @@ export declare const ArticleSchema: z.ZodObject<{
259
259
  name?: string | undefined;
260
260
  media?: Record<string, {
261
261
  url: string;
262
- coverUrl: string | null;
263
262
  play: "on-click" | "auto";
263
+ coverUrl: string | null;
264
264
  position: string;
265
265
  type: "video";
266
266
  size: string;
@@ -71,10 +71,7 @@ const VideoItemSchema = ItemBase_schema_1.ItemBaseSchema.extend({
71
71
  strokeWidth: zod_1.z.number(),
72
72
  strokeColor: zod_1.z.string(),
73
73
  blur: zod_1.z.number(),
74
- isDraggable: zod_1.z.boolean().optional(),
75
- play: zod_1.z.enum(['on-hover', 'on-click', 'auto']),
76
- muted: zod_1.z.boolean(),
77
- controls: zod_1.z.boolean(),
74
+ isDraggable: zod_1.z.boolean().optional()
78
75
  })),
79
76
  state: zod_1.z.record(ItemState_schema_1.MediaStateParamsSchema)
80
77
  });
@@ -118,6 +115,11 @@ const CustomItemSchema = ItemBase_schema_1.ItemBaseSchema.extend({
118
115
  const VimeoEmbedItemSchema = ItemBase_schema_1.ItemBaseSchema.extend({
119
116
  type: zod_1.z.literal(ArticleItemType_1.ArticleItemType.VimeoEmbed),
120
117
  commonParams: zod_1.z.object({
118
+ play: zod_1.z.union([zod_1.z.literal('on-hover'), zod_1.z.literal('on-click'), zod_1.z.literal('auto')]),
119
+ controls: zod_1.z.boolean(),
120
+ loop: zod_1.z.boolean(),
121
+ muted: zod_1.z.boolean(),
122
+ pictureInPicture: zod_1.z.boolean(),
121
123
  url: zod_1.z.string().min(1),
122
124
  coverUrl: zod_1.z.string().nullable(),
123
125
  ratioLock: zod_1.z.boolean(),
@@ -130,18 +132,16 @@ const VimeoEmbedItemSchema = ItemBase_schema_1.ItemBaseSchema.extend({
130
132
  layoutParams: zod_1.z.record(zod_1.z.object({
131
133
  radius: zod_1.z.number(),
132
134
  blur: zod_1.z.number(),
133
- opacity: zod_1.z.number().nonnegative(),
134
- play: zod_1.z.union([zod_1.z.literal('on-hover'), zod_1.z.literal('on-click'), zod_1.z.literal('auto')]),
135
- controls: zod_1.z.boolean(),
136
- loop: zod_1.z.boolean(),
137
- muted: zod_1.z.boolean(),
138
- pictureInPicture: zod_1.z.boolean()
135
+ opacity: zod_1.z.number().nonnegative()
139
136
  })),
140
137
  state: zod_1.z.record(ItemState_schema_1.EmbedStateParamsSchema)
141
138
  });
142
139
  const YoutubeEmbedItemSchema = ItemBase_schema_1.ItemBaseSchema.extend({
143
140
  type: zod_1.z.literal(ArticleItemType_1.ArticleItemType.YoutubeEmbed),
144
141
  commonParams: zod_1.z.object({
142
+ play: zod_1.z.enum(['on-hover', 'on-click', 'auto']),
143
+ controls: zod_1.z.boolean(),
144
+ loop: zod_1.z.boolean(),
145
145
  url: zod_1.z.string().min(1),
146
146
  coverUrl: zod_1.z.string().nullable(),
147
147
  pointerEvents
@@ -153,10 +153,7 @@ const YoutubeEmbedItemSchema = ItemBase_schema_1.ItemBaseSchema.extend({
153
153
  layoutParams: zod_1.z.record(zod_1.z.object({
154
154
  radius: zod_1.z.number(),
155
155
  blur: zod_1.z.number(),
156
- opacity: zod_1.z.number().nonnegative(),
157
- play: zod_1.z.enum(['on-hover', 'on-click', 'auto']),
158
- controls: zod_1.z.boolean(),
159
- loop: zod_1.z.boolean(),
156
+ opacity: zod_1.z.number().nonnegative()
160
157
  })),
161
158
  state: zod_1.z.record(ItemState_schema_1.EmbedStateParamsSchema)
162
159
  });
@@ -23,16 +23,16 @@ export declare const SectionMediaSchema: z.ZodDiscriminatedUnion<"type", [z.ZodO
23
23
  offsetX: z.ZodNullable<z.ZodNumber>;
24
24
  }, "strip", z.ZodTypeAny, {
25
25
  url: string;
26
- coverUrl: string | null;
27
26
  play: "on-click" | "auto";
27
+ coverUrl: string | null;
28
28
  position: string;
29
29
  type: "video";
30
30
  size: string;
31
31
  offsetX: number | null;
32
32
  }, {
33
33
  url: string;
34
- coverUrl: string | null;
35
34
  play: "on-click" | "auto";
35
+ coverUrl: string | null;
36
36
  position: string;
37
37
  type: "video";
38
38
  size: string;
@@ -86,16 +86,16 @@ export declare const SectionSchema: z.ZodObject<{
86
86
  offsetX: z.ZodNullable<z.ZodNumber>;
87
87
  }, "strip", z.ZodTypeAny, {
88
88
  url: string;
89
- coverUrl: string | null;
90
89
  play: "on-click" | "auto";
90
+ coverUrl: string | null;
91
91
  position: string;
92
92
  type: "video";
93
93
  size: string;
94
94
  offsetX: number | null;
95
95
  }, {
96
96
  url: string;
97
- coverUrl: string | null;
98
97
  play: "on-click" | "auto";
98
+ coverUrl: string | null;
99
99
  position: string;
100
100
  type: "video";
101
101
  size: string;
@@ -133,8 +133,8 @@ export declare const SectionSchema: z.ZodObject<{
133
133
  name?: string | undefined;
134
134
  media?: Record<string, {
135
135
  url: string;
136
- coverUrl: string | null;
137
136
  play: "on-click" | "auto";
137
+ coverUrl: string | null;
138
138
  position: string;
139
139
  type: "video";
140
140
  size: string;
@@ -160,8 +160,8 @@ export declare const SectionSchema: z.ZodObject<{
160
160
  name?: string | undefined;
161
161
  media?: Record<string, {
162
162
  url: string;
163
- coverUrl: string | null;
164
163
  play: "on-click" | "auto";
164
+ coverUrl: string | null;
165
165
  position: string;
166
166
  type: "video";
167
167
  size: string;
@@ -79,10 +79,18 @@ interface CodeEmbedCommonParams extends CommonParamsBase {
79
79
  iframe: boolean;
80
80
  }
81
81
  interface VimeoEmbedCommonParams extends CommonParamsBase {
82
+ play: 'on-hover' | 'on-click' | 'auto';
83
+ controls: boolean;
84
+ loop: boolean;
85
+ muted: boolean;
86
+ pictureInPicture: boolean;
82
87
  url: string;
83
88
  coverUrl: string | null;
84
89
  }
85
90
  interface YoutubeEmbedCommonParams extends CommonParamsBase {
91
+ play: 'on-hover' | 'on-click' | 'auto';
92
+ controls: boolean;
93
+ loop: boolean;
86
94
  url: string;
87
95
  coverUrl: string | null;
88
96
  }
@@ -117,19 +125,11 @@ interface CodeEmbedLayoutParams {
117
125
  isDraggable?: boolean;
118
126
  }
119
127
  interface VimeoEmbedLayoutParams {
120
- play: 'on-hover' | 'on-click' | 'auto';
121
- controls: boolean;
122
- loop: boolean;
123
- muted: boolean;
124
- pictureInPicture: boolean;
125
128
  radius: number;
126
129
  blur: number;
127
130
  opacity: number;
128
131
  }
129
132
  interface YoutubeEmbedLayoutParams {
130
- play: 'on-hover' | 'on-click' | 'auto';
131
- controls: boolean;
132
- loop: boolean;
133
133
  radius: number;
134
134
  blur: number;
135
135
  opacity: number;
@@ -137,9 +137,7 @@ interface YoutubeEmbedLayoutParams {
137
137
  interface ImageLayoutParams extends MediaLayoutParams {
138
138
  }
139
139
  interface VideoLayoutParams extends MediaLayoutParams {
140
- play: 'on-hover' | 'on-click' | 'auto';
141
- muted: boolean;
142
- controls: boolean;
140
+ autoplay: boolean;
143
141
  scrollPlayback: ScrollPlaybackParams | null;
144
142
  }
145
143
  interface RichTextLayoutParams {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cntrl-site/sdk",
3
- "version": "1.22.19-alpha.0",
3
+ "version": "1.22.21-alpha.0",
4
4
  "description": "Generic SDK for use in public websites.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",