@cntrl-site/sdk 1.27.0 → 1.28.0-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.
@@ -0,0 +1,115 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.StructuredBlockSchema = exports.StructuredBlockLayoutParamsSchema = exports.StructuredBlockCommonParamsSchema = exports.StructuredBlockImageLayoutParamsSchema = exports.StructuredBlockRichTextLayoutParamsSchema = exports.StructuredBlockImageCommonParamsSchema = exports.StructuredBlockRichTextCommonParamsSchema = exports.StructuredBlockComponentCommonParamsSchema = exports.StructuredBlockAreaSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ const RichTextItem_schema_1 = require("./RichTextItem.schema");
6
+ const Item_schema_1 = require("./Item.schema");
7
+ const FillLayer_schema_1 = require("./FillLayer.schema");
8
+ const StructuredBlockType_1 = require("../../types/article/StructuredBlockType");
9
+ const ItemState_schema_1 = require("./ItemState.schema");
10
+ exports.StructuredBlockAreaSchema = zod_1.z.object({
11
+ width: zod_1.z.number().nonnegative().optional(),
12
+ height: zod_1.z.number().nonnegative().optional(),
13
+ paddingTop: zod_1.z.number().optional(),
14
+ zIndex: zod_1.z.number()
15
+ });
16
+ exports.StructuredBlockComponentCommonParamsSchema = zod_1.z.object({
17
+ componentId: zod_1.z.string(),
18
+ content: zod_1.z.any().optional(),
19
+ parameters: zod_1.z.record(zod_1.z.any()).optional()
20
+ });
21
+ exports.StructuredBlockRichTextCommonParamsSchema = zod_1.z.object({
22
+ text: zod_1.z.string(),
23
+ preset: zod_1.z.string(),
24
+ blocks: zod_1.z.array(RichTextItem_schema_1.RichTextBlockSchema)
25
+ });
26
+ const pointerEvents = zod_1.z.enum(['never', 'when_visible', 'always']).optional();
27
+ const FXParamsSchema = zod_1.z.object({
28
+ hasGLEffect: zod_1.z.boolean(),
29
+ fragmentShader: zod_1.z.string().nullable(),
30
+ shaderName: zod_1.z.string().nullable(),
31
+ FXControls: zod_1.z.array(Item_schema_1.FXControlSchema)
32
+ });
33
+ exports.StructuredBlockImageCommonParamsSchema = zod_1.z.object({
34
+ url: zod_1.z.string().min(1),
35
+ ratioLock: zod_1.z.boolean(),
36
+ isPlaceholder: zod_1.z.boolean().optional(),
37
+ altText: zod_1.z.string(),
38
+ caption: zod_1.z.string().optional(),
39
+ pointerEvents
40
+ }).merge(FXParamsSchema);
41
+ exports.StructuredBlockRichTextLayoutParamsSchema = zod_1.z.object({
42
+ rangeStyles: zod_1.z.array(RichTextItem_schema_1.RichTextStyleSchema)
43
+ });
44
+ exports.StructuredBlockImageLayoutParamsSchema = zod_1.z.object({
45
+ opacity: zod_1.z.number().nonnegative(),
46
+ radius: zod_1.z.number(),
47
+ strokeWidth: zod_1.z.number(),
48
+ strokeFill: zod_1.z.array(FillLayer_schema_1.FillLayerSchema),
49
+ blur: zod_1.z.number(),
50
+ isDraggable: zod_1.z.boolean().optional(),
51
+ blendMode: zod_1.z.string().optional()
52
+ });
53
+ const StructuredBlockBaseSchema = zod_1.z.object({
54
+ id: zod_1.z.string().min(1),
55
+ label: zod_1.z.string().optional().nullable(),
56
+ area: zod_1.z.record(exports.StructuredBlockAreaSchema),
57
+ hidden: zod_1.z.record(zod_1.z.boolean()).optional()
58
+ });
59
+ const ComponentStructuredBlockSchema = StructuredBlockBaseSchema.extend({
60
+ type: zod_1.z.literal(StructuredBlockType_1.StructuredBlockType.Component),
61
+ commonParams: exports.StructuredBlockComponentCommonParamsSchema,
62
+ layoutParams: zod_1.z.record(Item_schema_1.ComponentItemLayoutParamsSchema),
63
+ state: zod_1.z.record(ItemState_schema_1.ComponentBlockStateParamsSchema)
64
+ });
65
+ const RichTextStructuredBlockSchema = StructuredBlockBaseSchema.extend({
66
+ type: zod_1.z.literal(StructuredBlockType_1.StructuredBlockType.RichText),
67
+ commonParams: exports.StructuredBlockRichTextCommonParamsSchema,
68
+ layoutParams: zod_1.z.record(exports.StructuredBlockRichTextLayoutParamsSchema),
69
+ state: zod_1.z.record(ItemState_schema_1.RichTextBlockStateParamsSchema)
70
+ });
71
+ const ImageStructuredBlockSchema = StructuredBlockBaseSchema.extend({
72
+ type: zod_1.z.literal(StructuredBlockType_1.StructuredBlockType.Image),
73
+ commonParams: exports.StructuredBlockImageCommonParamsSchema,
74
+ layoutParams: zod_1.z.record(exports.StructuredBlockImageLayoutParamsSchema),
75
+ state: zod_1.z.record(ItemState_schema_1.MediaBlockStateParamsSchema)
76
+ });
77
+ const VimeoEmbedStructuredBlockSchema = StructuredBlockBaseSchema.extend({
78
+ type: zod_1.z.literal(StructuredBlockType_1.StructuredBlockType.VimeoEmbed),
79
+ commonParams: zod_1.z.object({
80
+ url: zod_1.z.string().min(1),
81
+ coverUrl: zod_1.z.string().nullable(),
82
+ ratioLock: zod_1.z.boolean(),
83
+ pointerEvents
84
+ }),
85
+ layoutParams: zod_1.z.record(Item_schema_1.VimeoEmbedLayoutParamsSchema),
86
+ state: zod_1.z.record(ItemState_schema_1.VideoEmbedBlockStateParamsSchema)
87
+ });
88
+ const YoutubeEmbedStructuredBlockSchema = StructuredBlockBaseSchema.extend({
89
+ type: zod_1.z.literal(StructuredBlockType_1.StructuredBlockType.YoutubeEmbed),
90
+ commonParams: zod_1.z.object({
91
+ url: zod_1.z.string().min(1),
92
+ coverUrl: zod_1.z.string().nullable(),
93
+ ratioLock: zod_1.z.boolean(),
94
+ pointerEvents
95
+ }),
96
+ layoutParams: zod_1.z.record(Item_schema_1.YoutubeEmbedLayoutParamsSchema),
97
+ state: zod_1.z.record(ItemState_schema_1.VideoEmbedBlockStateParamsSchema)
98
+ });
99
+ exports.StructuredBlockCommonParamsSchema = zod_1.z.union([
100
+ exports.StructuredBlockComponentCommonParamsSchema,
101
+ exports.StructuredBlockRichTextCommonParamsSchema,
102
+ exports.StructuredBlockImageCommonParamsSchema
103
+ ]);
104
+ exports.StructuredBlockLayoutParamsSchema = zod_1.z.union([
105
+ Item_schema_1.ComponentItemLayoutParamsSchema,
106
+ exports.StructuredBlockRichTextLayoutParamsSchema,
107
+ exports.StructuredBlockImageLayoutParamsSchema
108
+ ]);
109
+ exports.StructuredBlockSchema = zod_1.z.discriminatedUnion('type', [
110
+ ComponentStructuredBlockSchema,
111
+ RichTextStructuredBlockSchema,
112
+ ImageStructuredBlockSchema,
113
+ VimeoEmbedStructuredBlockSchema,
114
+ YoutubeEmbedStructuredBlockSchema
115
+ ]);
@@ -76,6 +76,7 @@ export declare const ProjectSchema: z.ZodObject<{
76
76
  id: z.ZodString;
77
77
  isPublished: z.ZodOptional<z.ZodBoolean>;
78
78
  isAuthProtected: z.ZodOptional<z.ZodBoolean>;
79
+ lastModified: z.ZodOptional<z.ZodString>;
79
80
  }, "strip", z.ZodTypeAny, {
80
81
  id: string;
81
82
  title: string;
@@ -90,6 +91,7 @@ export declare const ProjectSchema: z.ZodObject<{
90
91
  } | undefined;
91
92
  isPublished?: boolean | undefined;
92
93
  isAuthProtected?: boolean | undefined;
94
+ lastModified?: string | undefined;
93
95
  }, {
94
96
  id: string;
95
97
  title: string;
@@ -104,6 +106,7 @@ export declare const ProjectSchema: z.ZodObject<{
104
106
  } | undefined;
105
107
  isPublished?: boolean | undefined;
106
108
  isAuthProtected?: boolean | undefined;
109
+ lastModified?: string | undefined;
107
110
  }>, "many">;
108
111
  fonts: z.ZodObject<{
109
112
  google: z.ZodString;
@@ -199,6 +202,7 @@ export declare const ProjectSchema: z.ZodObject<{
199
202
  } | undefined;
200
203
  isPublished?: boolean | undefined;
201
204
  isAuthProtected?: boolean | undefined;
205
+ lastModified?: string | undefined;
202
206
  }[];
203
207
  fonts: {
204
208
  custom: {
@@ -248,6 +252,7 @@ export declare const ProjectSchema: z.ZodObject<{
248
252
  } | undefined;
249
253
  isPublished?: boolean | undefined;
250
254
  isAuthProtected?: boolean | undefined;
255
+ lastModified?: string | undefined;
251
256
  }[];
252
257
  fonts: {
253
258
  custom: {
@@ -32,7 +32,8 @@ exports.ProjectSchema = zod_1.z.object({
32
32
  }).optional(),
33
33
  id: zod_1.z.string().min(1),
34
34
  isPublished: zod_1.z.boolean().optional(),
35
- isAuthProtected: zod_1.z.boolean().optional()
35
+ isAuthProtected: zod_1.z.boolean().optional(),
36
+ lastModified: zod_1.z.string().optional()
36
37
  })),
37
38
  fonts: zod_1.z.object({
38
39
  google: zod_1.z.string(),
@@ -47,7 +47,7 @@ export interface ItemLayoutParamsMap {
47
47
  interface CommonParamsBase {
48
48
  pointerEvents?: 'never' | 'when_visible' | 'always';
49
49
  }
50
- interface MediaCommonParams extends CommonParamsBase {
50
+ export interface MediaCommonParams extends CommonParamsBase {
51
51
  url: string;
52
52
  hasGLEffect?: boolean;
53
53
  fragmentShader: string | null;
@@ -80,11 +80,11 @@ interface CodeEmbedCommonParams extends CommonParamsBase {
80
80
  scale: boolean;
81
81
  iframe: boolean;
82
82
  }
83
- interface VimeoEmbedCommonParams extends CommonParamsBase {
83
+ export interface VimeoEmbedCommonParams extends CommonParamsBase {
84
84
  url: string;
85
85
  coverUrl: string | null;
86
86
  }
87
- interface YoutubeEmbedCommonParams extends CommonParamsBase {
87
+ export interface YoutubeEmbedCommonParams extends CommonParamsBase {
88
88
  url: string;
89
89
  coverUrl: string | null;
90
90
  }
@@ -93,7 +93,7 @@ interface ComponentCommonParams extends CommonParamsBase {
93
93
  content?: any;
94
94
  parameters?: Record<string, any>;
95
95
  }
96
- interface MediaLayoutParams {
96
+ export interface MediaLayoutParams {
97
97
  opacity: number;
98
98
  radius: number;
99
99
  strokeWidth: number;
@@ -124,7 +124,7 @@ interface CodeEmbedLayoutParams {
124
124
  isDraggable?: boolean;
125
125
  blendMode?: string;
126
126
  }
127
- interface VimeoEmbedLayoutParams {
127
+ export interface VimeoEmbedLayoutParams {
128
128
  play: 'on-hover' | 'on-click' | 'auto';
129
129
  controls: boolean;
130
130
  loop: boolean;
@@ -135,7 +135,7 @@ interface VimeoEmbedLayoutParams {
135
135
  opacity: number;
136
136
  blendMode?: string;
137
137
  }
138
- interface YoutubeEmbedLayoutParams {
138
+ export interface YoutubeEmbedLayoutParams {
139
139
  play: 'on-hover' | 'on-click' | 'auto';
140
140
  controls: boolean;
141
141
  loop: boolean;
@@ -246,7 +246,7 @@ export interface Link {
246
246
  target: string;
247
247
  }
248
248
  type LayoutIdentifier = string;
249
- interface ComponentLayoutParams {
249
+ export interface ComponentLayoutParams {
250
250
  parameters?: any;
251
251
  opacity: number;
252
252
  blur: number;
@@ -1,8 +1,9 @@
1
1
  import { ArticleItemType } from './ArticleItemType';
2
2
  import { FillLayer } from './Item';
3
+ import { StructuredBlockType } from './StructuredBlockType';
3
4
  type StateId = string;
4
- export type ItemState<T extends ArticleItemType> = Record<StateId, ItemStatesMap[T]>;
5
- export type ItemStateParams = ItemStatesMap[ArticleItemType];
5
+ export type ItemState<T extends ArticleItemType | StructuredBlockType> = Record<StateId, ItemStatesMap[T]>;
6
+ export type ItemStateParams = ItemStatesMap[ArticleItemType] | ItemStatesMap[StructuredBlockType];
6
7
  export interface ItemStatesMap {
7
8
  [ArticleItemType.Image]: MediaStateParams;
8
9
  [ArticleItemType.Video]: MediaStateParams;
@@ -15,6 +16,11 @@ export interface ItemStatesMap {
15
16
  [ArticleItemType.CodeEmbed]: CodeEmbedStateParams;
16
17
  [ArticleItemType.Compound]: CompoundStateParams;
17
18
  [ArticleItemType.Component]: ComponentStateParams;
19
+ [StructuredBlockType.Component]: ComponentBlockStateParams;
20
+ [StructuredBlockType.RichText]: RichTextBlockStateParams;
21
+ [StructuredBlockType.Image]: MediaBlockStateParams;
22
+ [StructuredBlockType.VimeoEmbed]: VideoEmbedBlockStateParams;
23
+ [StructuredBlockType.YoutubeEmbed]: VideoEmbedBlockStateParams;
18
24
  }
19
25
  export interface StateParams<T> {
20
26
  value: T;
@@ -38,6 +44,24 @@ interface ItemStatesBaseMap {
38
44
  scale?: StateParams<number>;
39
45
  blur?: StateParams<number>;
40
46
  }
47
+ export interface ComponentBlockStateParams {
48
+ opacity?: StateParams<number>;
49
+ }
50
+ export interface RichTextBlockStateParams {
51
+ color?: StateParams<string>;
52
+ letterSpacing?: StateParams<number>;
53
+ wordSpacing?: StateParams<number>;
54
+ }
55
+ export interface MediaBlockStateParams {
56
+ opacity?: StateParams<number>;
57
+ radius?: StateParams<number>;
58
+ strokeWidth?: StateParams<number>;
59
+ strokeFill?: StateParams<FillLayer[]>;
60
+ }
61
+ export interface VideoEmbedBlockStateParams {
62
+ opacity?: StateParams<number>;
63
+ radius?: StateParams<number>;
64
+ }
41
65
  export interface MediaStateParams extends ItemStatesBaseMap {
42
66
  opacity?: StateParams<number>;
43
67
  radius?: StateParams<number>;
@@ -1,3 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const ArticleItemType_1 = require("./ArticleItemType");
4
+ const StructuredBlockType_1 = require("./StructuredBlockType");
@@ -1,4 +1,5 @@
1
1
  import { ItemAny } from './Item';
2
+ import { StructuredBlockAny } from './StructuredBlock';
2
3
  export declare enum SectionHeightMode {
3
4
  ControlUnits = "control-units",
4
5
  ViewportHeightUnits = "viewport-height-units"
@@ -24,14 +25,38 @@ export type SectionImage = {
24
25
  position: string;
25
26
  offsetX: number | null;
26
27
  };
28
+ interface ContentBasedSectionSettings {
29
+ defaultWidth: Record<string, number>;
30
+ paddingBottom: Record<string, number>;
31
+ }
32
+ interface ComponentBasedSectionSettings {
33
+ paddingBottom: Record<string, number>;
34
+ }
27
35
  export type SectionMedia = SectionVideo | SectionImage;
28
- export interface Section {
36
+ type SectionBase = {
29
37
  id: string;
30
38
  name?: string;
31
- height: Record<string, SectionHeight>;
32
- hidden: Record<string, boolean>;
33
39
  items: ItemAny[];
34
40
  position: Record<string, number>;
35
41
  color: Record<string, string | null>;
36
42
  media?: Record<string, SectionMedia>;
37
- }
43
+ hidden: Record<string, boolean>;
44
+ };
45
+ export type FreehandSection = SectionBase & {
46
+ type: 'freehand';
47
+ height: Record<string, SectionHeight>;
48
+ };
49
+ export type ComponentBasedSection = SectionBase & {
50
+ type: 'component-based';
51
+ minHeight: Record<string, SectionHeight>;
52
+ structuredContent: StructuredBlockAny[];
53
+ structuredContentSettings: ComponentBasedSectionSettings;
54
+ };
55
+ export type ContentBasedSection = SectionBase & {
56
+ type: 'content-based';
57
+ minHeight: Record<string, SectionHeight>;
58
+ structuredContent: StructuredBlockAny[];
59
+ structuredContentSettings: ContentBasedSectionSettings;
60
+ };
61
+ export type Section = FreehandSection | ComponentBasedSection | ContentBasedSection;
62
+ export {};
@@ -0,0 +1,58 @@
1
+ import { RichTextBlock, RichTextStyle } from './RichText';
2
+ import { ItemState } from './ItemState';
3
+ import { StructuredBlockType } from './StructuredBlockType';
4
+ import { ComponentLayoutParams, MediaCommonParams, MediaLayoutParams, VimeoEmbedCommonParams, VimeoEmbedLayoutParams, YoutubeEmbedCommonParams, YoutubeEmbedLayoutParams } from './Item';
5
+ type LayoutIdentifier = string;
6
+ export interface StructuredBlockArea {
7
+ width?: number;
8
+ height?: number;
9
+ paddingTop?: number;
10
+ zIndex: number;
11
+ }
12
+ export interface StructuredBlockComponentCommonParams {
13
+ componentId: string;
14
+ content?: any;
15
+ parameters?: Record<string, any>;
16
+ }
17
+ export interface StructuredBlockRichTextCommonParams {
18
+ text: string;
19
+ blocks?: RichTextBlock[];
20
+ }
21
+ export interface StructuredBlockRichTextLayoutParams {
22
+ rangeStyles: RichTextStyle[];
23
+ }
24
+ export interface StructuredBlockImageCommonParams extends MediaCommonParams {
25
+ altText: string;
26
+ caption?: string;
27
+ }
28
+ export interface StructuredBlockLayoutParamsMap {
29
+ [StructuredBlockType.Component]: ComponentLayoutParams;
30
+ [StructuredBlockType.RichText]: StructuredBlockRichTextLayoutParams;
31
+ [StructuredBlockType.Image]: MediaLayoutParams;
32
+ [StructuredBlockType.VimeoEmbed]: VimeoEmbedLayoutParams;
33
+ [StructuredBlockType.YoutubeEmbed]: YoutubeEmbedLayoutParams;
34
+ }
35
+ export interface StructuredBlockCommonParamsMap {
36
+ [StructuredBlockType.Component]: StructuredBlockComponentCommonParams;
37
+ [StructuredBlockType.RichText]: StructuredBlockRichTextCommonParams;
38
+ [StructuredBlockType.Image]: StructuredBlockImageCommonParams;
39
+ [StructuredBlockType.VimeoEmbed]: VimeoEmbedCommonParams;
40
+ [StructuredBlockType.YoutubeEmbed]: YoutubeEmbedCommonParams;
41
+ }
42
+ export interface StructuredBlock<T extends StructuredBlockType> {
43
+ id: string;
44
+ type: T;
45
+ label?: string | null;
46
+ area: Record<LayoutIdentifier, StructuredBlockArea>;
47
+ layoutParams: Record<LayoutIdentifier, StructuredBlockLayoutParamsMap[T]>;
48
+ commonParams: StructuredBlockCommonParamsMap[T];
49
+ hidden?: Record<LayoutIdentifier, boolean>;
50
+ state: ItemState<T>;
51
+ }
52
+ export type StructuredBlockAny = StructuredBlock<StructuredBlockType>;
53
+ export type ComponentStructuredBlock = StructuredBlock<StructuredBlockType.Component>;
54
+ export type RichTextStructuredBlock = StructuredBlock<StructuredBlockType.RichText>;
55
+ export type ImageStructuredBlock = StructuredBlock<StructuredBlockType.Image>;
56
+ export type VimeoEmbedStructuredBlock = StructuredBlock<StructuredBlockType.VimeoEmbed>;
57
+ export type YoutubeEmbedStructuredBlock = StructuredBlock<StructuredBlockType.YoutubeEmbed>;
58
+ export {};
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const StructuredBlockType_1 = require("./StructuredBlockType");
@@ -0,0 +1,7 @@
1
+ export declare enum StructuredBlockType {
2
+ Component = "component-block",
3
+ RichText = "rich-text-block",
4
+ Image = "image-block",
5
+ VimeoEmbed = "vimeo-embed-block",
6
+ YoutubeEmbed = "youtube-embed-block"
7
+ }
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.StructuredBlockType = void 0;
4
+ var StructuredBlockType;
5
+ (function (StructuredBlockType) {
6
+ StructuredBlockType["Component"] = "component-block";
7
+ StructuredBlockType["RichText"] = "rich-text-block";
8
+ StructuredBlockType["Image"] = "image-block";
9
+ StructuredBlockType["VimeoEmbed"] = "vimeo-embed-block";
10
+ StructuredBlockType["YoutubeEmbed"] = "youtube-embed-block";
11
+ })(StructuredBlockType || (exports.StructuredBlockType = StructuredBlockType = {}));
@@ -10,4 +10,5 @@ export interface Page {
10
10
  meta?: PageMeta;
11
11
  isPublished?: boolean;
12
12
  isAuthProtected?: boolean;
13
+ lastModified?: string;
13
14
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cntrl-site/sdk",
3
- "version": "1.27.0",
3
+ "version": "1.28.0-0",
4
4
  "description": "Generic SDK for use in public websites.",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",