@cntrl-site/sdk 1.5.2 → 1.5.3

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.
Binary file
@@ -128,22 +128,7 @@ const YoutubeEmbedItemSchema = ItemBase_schema_1.ItemBaseSchema.extend({
128
128
  hover: zod_1.z.record(ItemState_schema_1.EmbedHoverStateParamsSchema)
129
129
  })
130
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
- });
146
- exports.ItemSchema = zod_1.z.discriminatedUnion('type', [
131
+ exports.ItemSchema = zod_1.z.lazy(() => zod_1.z.discriminatedUnion('type', [
147
132
  ImageItemSchema,
148
133
  VideoItemSchema,
149
134
  RectangleItemSchema,
@@ -151,5 +136,19 @@ exports.ItemSchema = zod_1.z.discriminatedUnion('type', [
151
136
  RichTextItem_schema_1.RichTextItemSchema,
152
137
  VimeoEmbedItemSchema,
153
138
  YoutubeEmbedItemSchema,
154
- GroupItemSchema
155
- ]);
139
+ ItemBase_schema_1.ItemBaseSchema.extend({
140
+ type: zod_1.z.literal(ArticleItemType_1.ArticleItemType.Group),
141
+ commonParams: zod_1.z.object({}),
142
+ items: zod_1.z.array(exports.ItemSchema),
143
+ sticky: zod_1.z.record(zod_1.z.object({
144
+ from: zod_1.z.number(),
145
+ to: zod_1.z.number().optional()
146
+ }).nullable()),
147
+ layoutParams: zod_1.z.record(zod_1.z.object({
148
+ opacity: zod_1.z.number().nonnegative()
149
+ })),
150
+ state: zod_1.z.object({
151
+ hover: zod_1.z.record(ItemState_schema_1.GroupHoverStateParamsSchema)
152
+ })
153
+ })
154
+ ]));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cntrl-site/sdk",
3
- "version": "1.5.2",
3
+ "version": "1.5.3",
4
4
  "description": "Generic SDK for use in public websites.",
5
5
  "main": "lib/index.js",
6
6
  "types": "src/index.ts",
@@ -1,7 +1,9 @@
1
1
  import { z, ZodType } from 'zod';
2
2
  import {
3
- CustomItem, GroupItem,
3
+ CustomItem,
4
+ GroupItem,
4
5
  ImageItem,
6
+ ItemAny,
5
7
  RectangleItem,
6
8
  VideoItem,
7
9
  VimeoEmbedItem,
@@ -166,27 +168,7 @@ const YoutubeEmbedItemSchema = ItemBaseSchema.extend({
166
168
  })
167
169
  }) satisfies ZodType<YoutubeEmbedItem>;
168
170
 
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
-
189
- export const ItemSchema = z.discriminatedUnion('type', [
171
+ export const ItemSchema: ZodType<ItemAny> = z.lazy(() => z.discriminatedUnion('type', [
190
172
  ImageItemSchema,
191
173
  VideoItemSchema,
192
174
  RectangleItemSchema,
@@ -194,5 +176,23 @@ export const ItemSchema = z.discriminatedUnion('type', [
194
176
  RichTextItemSchema,
195
177
  VimeoEmbedItemSchema,
196
178
  YoutubeEmbedItemSchema,
197
- GroupItemSchema
198
- ]);
179
+ ItemBaseSchema.extend({
180
+ type: z.literal(ArticleItemType.Group),
181
+ commonParams: z.object({}),
182
+ items: z.array(ItemSchema),
183
+ sticky: z.record(
184
+ z.object({
185
+ from: z.number(),
186
+ to: z.number().optional()
187
+ }).nullable(),
188
+ ),
189
+ layoutParams: z.record(
190
+ z.object({
191
+ opacity: z.number().nonnegative()
192
+ })
193
+ ),
194
+ state: z.object({
195
+ hover: z.record(GroupHoverStateParamsSchema)
196
+ })
197
+ })
198
+ ]));