@cntrl-site/sdk 1.4.0 → 1.5.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.
@@ -9,7 +9,9 @@ const ArticleItemType_1 = require("../../types/article/ArticleItemType");
9
9
  const ImageItemSchema = ItemBase_schema_1.ItemBaseSchema.extend({
10
10
  type: zod_1.z.literal(ArticleItemType_1.ArticleItemType.Image),
11
11
  commonParams: zod_1.z.object({
12
- url: zod_1.z.string().min(1)
12
+ url: zod_1.z.string().min(1),
13
+ hasGLEffect: zod_1.z.boolean().optional(),
14
+ fragmentShader: zod_1.z.string().optional()
13
15
  }),
14
16
  sticky: zod_1.z.record(zod_1.z.object({
15
17
  from: zod_1.z.number(),
@@ -126,6 +128,21 @@ const YoutubeEmbedItemSchema = ItemBase_schema_1.ItemBaseSchema.extend({
126
128
  hover: zod_1.z.record(ItemState_schema_1.EmbedHoverStateParamsSchema)
127
129
  })
128
130
  });
131
+ const GroupItemSchema = ItemBase_schema_1.ItemBaseSchema.extend({
132
+ type: zod_1.z.literal(ArticleItemType_1.ArticleItemType.Group),
133
+ commonParams: zod_1.z.object({}),
134
+ itemsIds: zod_1.z.array(zod_1.z.string()),
135
+ sticky: zod_1.z.record(zod_1.z.object({
136
+ from: zod_1.z.number(),
137
+ to: zod_1.z.number().optional()
138
+ }).nullable()),
139
+ layoutParams: zod_1.z.record(zod_1.z.object({
140
+ opacity: zod_1.z.number().nonnegative()
141
+ })),
142
+ state: zod_1.z.object({
143
+ hover: zod_1.z.record(ItemState_schema_1.GroupHoverStateParamsSchema)
144
+ })
145
+ });
129
146
  exports.ItemSchema = zod_1.z.discriminatedUnion('type', [
130
147
  ImageItemSchema,
131
148
  VideoItemSchema,
@@ -133,5 +150,6 @@ exports.ItemSchema = zod_1.z.discriminatedUnion('type', [
133
150
  CustomItemSchema,
134
151
  RichTextItem_schema_1.RichTextItemSchema,
135
152
  VimeoEmbedItemSchema,
136
- YoutubeEmbedItemSchema
153
+ YoutubeEmbedItemSchema,
154
+ GroupItemSchema
137
155
  ]);
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
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;
3
+ exports.ItemHoverStateParamsSchema = exports.GroupHoverStateParamsSchema = exports.RichTextHoverStateParamsSchema = exports.EmbedHoverStateParamsSchema = exports.CustomItemHoverStateParamsSchema = exports.RectangleHoverStateParamsSchema = exports.MediaHoverStateParamsSchema = exports.ItemHoverStateBaseSchema = exports.getHoverParamsSchema = void 0;
4
4
  const zod_1 = require("zod");
5
5
  const getHoverParamsSchema = (schema) => {
6
6
  return zod_1.z.object({
@@ -43,10 +43,14 @@ exports.RichTextHoverStateParamsSchema = zod_1.z.object({
43
43
  letterSpacing: (0, exports.getHoverParamsSchema)(zod_1.z.number()),
44
44
  wordSpacing: (0, exports.getHoverParamsSchema)(zod_1.z.number())
45
45
  }).merge(exports.ItemHoverStateBaseSchema);
46
+ exports.GroupHoverStateParamsSchema = zod_1.z.object({
47
+ opacity: (0, exports.getHoverParamsSchema)(zod_1.z.number().nonnegative())
48
+ }).merge(exports.ItemHoverStateBaseSchema);
46
49
  exports.ItemHoverStateParamsSchema = zod_1.z.union([
47
50
  exports.EmbedHoverStateParamsSchema,
48
51
  exports.MediaHoverStateParamsSchema,
49
52
  exports.RectangleHoverStateParamsSchema,
50
53
  exports.RichTextHoverStateParamsSchema,
51
- exports.CustomItemHoverStateParamsSchema
54
+ exports.CustomItemHoverStateParamsSchema,
55
+ exports.GroupHoverStateParamsSchema
52
56
  ]);
@@ -10,4 +10,5 @@ var ArticleItemType;
10
10
  ArticleItemType["VimeoEmbed"] = "vimeo-embed";
11
11
  ArticleItemType["YoutubeEmbed"] = "youtube-embed";
12
12
  ArticleItemType["Custom"] = "custom";
13
+ ArticleItemType["Group"] = "group";
13
14
  })(ArticleItemType = exports.ArticleItemType || (exports.ArticleItemType = {}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cntrl-site/sdk",
3
- "version": "1.4.0",
3
+ "version": "1.5.0",
4
4
  "description": "Generic SDK for use in public websites.",
5
5
  "main": "lib/index.js",
6
6
  "types": "src/index.ts",
@@ -1,6 +1,6 @@
1
1
  import { z, ZodType } from 'zod';
2
2
  import {
3
- CustomItem,
3
+ CustomItem, GroupItem,
4
4
  ImageItem,
5
5
  RectangleItem,
6
6
  VideoItem,
@@ -9,7 +9,7 @@ import {
9
9
  } from '../../types/article/Item';
10
10
  import {
11
11
  CustomItemHoverStateParamsSchema,
12
- EmbedHoverStateParamsSchema, MediaHoverStateParamsSchema,
12
+ EmbedHoverStateParamsSchema, GroupHoverStateParamsSchema, MediaHoverStateParamsSchema,
13
13
  RectangleHoverStateParamsSchema
14
14
  } from './ItemState.schema';
15
15
  import { RichTextItemSchema } from './RichTextItem.schema';
@@ -19,7 +19,9 @@ import { ArticleItemType } from '../../types/article/ArticleItemType';
19
19
  const ImageItemSchema = ItemBaseSchema.extend({
20
20
  type: z.literal(ArticleItemType.Image),
21
21
  commonParams: z.object({
22
- url: z.string().min(1)
22
+ url: z.string().min(1),
23
+ hasGLEffect: z.boolean().optional(),
24
+ fragmentShader: z.string().optional()
23
25
  }),
24
26
  sticky: z.record(
25
27
  z.object({
@@ -164,6 +166,26 @@ const YoutubeEmbedItemSchema = ItemBaseSchema.extend({
164
166
  })
165
167
  }) satisfies ZodType<YoutubeEmbedItem>;
166
168
 
169
+ const GroupItemSchema = ItemBaseSchema.extend({
170
+ type: z.literal(ArticleItemType.Group),
171
+ commonParams: z.object({}),
172
+ itemsIds: z.array(z.string()),
173
+ sticky: z.record(
174
+ z.object({
175
+ from: z.number(),
176
+ to: z.number().optional()
177
+ }).nullable(),
178
+ ),
179
+ layoutParams: z.record(
180
+ z.object({
181
+ opacity: z.number().nonnegative()
182
+ })
183
+ ),
184
+ state: z.object({
185
+ hover: z.record(GroupHoverStateParamsSchema)
186
+ })
187
+ }) satisfies ZodType<GroupItem>;
188
+
167
189
  export const ItemSchema = z.discriminatedUnion('type', [
168
190
  ImageItemSchema,
169
191
  VideoItemSchema,
@@ -171,5 +193,6 @@ export const ItemSchema = z.discriminatedUnion('type', [
171
193
  CustomItemSchema,
172
194
  RichTextItemSchema,
173
195
  VimeoEmbedItemSchema,
174
- YoutubeEmbedItemSchema
196
+ YoutubeEmbedItemSchema,
197
+ GroupItemSchema
175
198
  ]);
@@ -1,6 +1,6 @@
1
1
  import { z, ZodType } from 'zod';
2
2
  import {
3
- CustomHoverStateParams, EmbedHoverStateParams,
3
+ CustomHoverStateParams, EmbedHoverStateParams, GroupHoverStateParams,
4
4
  MediaHoverStateParams,
5
5
  RectangleHoverStateParams, RichTextHoverStateParams
6
6
  } from '../../types/article/ItemState';
@@ -53,10 +53,15 @@ export const RichTextHoverStateParamsSchema = z.object({
53
53
  wordSpacing: getHoverParamsSchema(z.number())
54
54
  }).merge(ItemHoverStateBaseSchema) satisfies ZodType<RichTextHoverStateParams>;
55
55
 
56
+ export const GroupHoverStateParamsSchema = z.object({
57
+ opacity: getHoverParamsSchema(z.number().nonnegative())
58
+ }).merge(ItemHoverStateBaseSchema) satisfies ZodType<GroupHoverStateParams>;
59
+
56
60
  export const ItemHoverStateParamsSchema = z.union([
57
61
  EmbedHoverStateParamsSchema,
58
62
  MediaHoverStateParamsSchema,
59
63
  RectangleHoverStateParamsSchema,
60
64
  RichTextHoverStateParamsSchema,
61
- CustomItemHoverStateParamsSchema
65
+ CustomItemHoverStateParamsSchema,
66
+ GroupHoverStateParamsSchema
62
67
  ]);
@@ -5,5 +5,6 @@ export enum ArticleItemType {
5
5
  Rectangle = 'rectangle',
6
6
  VimeoEmbed = 'vimeo-embed',
7
7
  YoutubeEmbed = 'youtube-embed',
8
- Custom = 'custom'
8
+ Custom = 'custom',
9
+ Group = 'group'
9
10
  }
@@ -11,6 +11,7 @@ export interface Item<T extends ArticleItemType> {
11
11
  area: Record<LayoutIdentifier, ItemArea>;
12
12
  hidden: Record<LayoutIdentifier, boolean>;
13
13
  link?: Link;
14
+ itemsIds?: T extends ArticleItemType.Group ? string[] : never;
14
15
  sticky: Record<LayoutIdentifier, StickyParams | null>;
15
16
  commonParams: ItemCommonParamsMap[T];
16
17
  state: ItemState<T>;
@@ -25,6 +26,7 @@ export interface ItemCommonParamsMap {
25
26
  [ArticleItemType.VimeoEmbed]: VimeoEmbedCommonParams;
26
27
  [ArticleItemType.YoutubeEmbed]: YoutubeEmbedCommonParams;
27
28
  [ArticleItemType.Custom]: CustomCommonParams;
29
+ [ArticleItemType.Group]: GroupCommonParams;
28
30
  }
29
31
 
30
32
  export interface ItemLayoutParamsMap {
@@ -35,6 +37,7 @@ export interface ItemLayoutParamsMap {
35
37
  [ArticleItemType.VimeoEmbed]: VimeoEmbedLayoutParams;
36
38
  [ArticleItemType.YoutubeEmbed]: YoutubeEmbedLayoutParams;
37
39
  [ArticleItemType.Custom]: CustomLayoutParams;
40
+ [ArticleItemType.Group]: GroupLayoutParams;
38
41
  }
39
42
 
40
43
  interface MediaCommonParams {
@@ -43,7 +46,10 @@ interface MediaCommonParams {
43
46
 
44
47
  interface VideoCommonParams extends MediaCommonParams {}
45
48
 
46
- interface ImageCommonParams extends MediaCommonParams {}
49
+ interface ImageCommonParams extends MediaCommonParams {
50
+ hasGLEffect?: boolean;
51
+ fragmentShader?: string;
52
+ }
47
53
 
48
54
  interface RichTextCommonParams {
49
55
  text: string;
@@ -58,6 +64,8 @@ interface CustomCommonParams {
58
64
  name: string;
59
65
  }
60
66
 
67
+ interface GroupCommonParams {}
68
+
61
69
  interface VimeoEmbedCommonParams {
62
70
  play: 'on-hover' | 'on-click' | 'auto';
63
71
  controls: boolean;
@@ -84,6 +92,10 @@ interface MediaLayoutParams {
84
92
 
85
93
  interface CustomLayoutParams {}
86
94
 
95
+ interface GroupLayoutParams {
96
+ opacity: number;
97
+ }
98
+
87
99
  interface VimeoEmbedLayoutParams {
88
100
  radius: number;
89
101
  blur: number;
@@ -148,3 +160,4 @@ export type RichTextItem = Item<ArticleItemType.RichText>;
148
160
  export type VimeoEmbedItem = Item<ArticleItemType.VimeoEmbed>;
149
161
  export type YoutubeEmbedItem = Item<ArticleItemType.YoutubeEmbed>;
150
162
  export type CustomItem = Item<ArticleItemType.Custom>;
163
+ export type GroupItem = Item<ArticleItemType.Group>;
@@ -16,6 +16,7 @@ export interface ItemHoverStatesMap {
16
16
  [ArticleItemType.VimeoEmbed]: EmbedHoverStateParams;
17
17
  [ArticleItemType.YoutubeEmbed]: EmbedHoverStateParams;
18
18
  [ArticleItemType.Custom]: CustomHoverStateParams;
19
+ [ArticleItemType.Group]: GroupHoverStateParams;
19
20
  }
20
21
 
21
22
  export interface HoverParams<T> {
@@ -62,3 +63,7 @@ export interface EmbedHoverStateParams extends ItemHoversBaseMap {
62
63
  }
63
64
 
64
65
  export interface CustomHoverStateParams extends ItemHoversBaseMap {}
66
+
67
+ export interface GroupHoverStateParams extends ItemHoversBaseMap {
68
+ opacity?: HoverParams<number>;
69
+ }