desen-core 1.0.0-draft.2 → 1.0.0-draft.21

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.
@@ -1,5 +1,5 @@
1
1
 
2
2
  
3
- > desen-core@1.0.0-draft.2 build /Users/selmanay/Desktop/desen/packages/core
3
+ > desen-core@1.0.0-draft.20 build /Users/selmanay/Desktop/desen/packages/core
4
4
  > tsc
5
5
 
@@ -1,41 +1,41 @@
1
1
  import { z } from "zod";
2
- export declare const bindingSourceEnum: z.ZodEnum<["session", "backend", "local", "feature_flag"]>;
2
+ export declare const bindingSourceEnum: z.ZodEnum<["session", "backend", "local", "feature_flag", "sensor"]>;
3
3
  export declare const bindingSpec: z.ZodObject<{
4
- source: z.ZodEnum<["session", "backend", "local", "feature_flag"]>;
4
+ source: z.ZodEnum<["session", "backend", "local", "feature_flag", "sensor"]>;
5
5
  path: z.ZodString;
6
6
  fallback: z.ZodOptional<z.ZodAny>;
7
7
  }, "strip", z.ZodTypeAny, {
8
- source: "session" | "backend" | "local" | "feature_flag";
8
+ source: "session" | "backend" | "local" | "feature_flag" | "sensor";
9
9
  path: string;
10
10
  fallback?: any;
11
11
  }, {
12
- source: "session" | "backend" | "local" | "feature_flag";
12
+ source: "session" | "backend" | "local" | "feature_flag" | "sensor";
13
13
  path: string;
14
14
  fallback?: any;
15
15
  }>;
16
16
  export declare const bindWrapper: z.ZodObject<{
17
17
  bind: z.ZodObject<{
18
- source: z.ZodEnum<["session", "backend", "local", "feature_flag"]>;
18
+ source: z.ZodEnum<["session", "backend", "local", "feature_flag", "sensor"]>;
19
19
  path: z.ZodString;
20
20
  fallback: z.ZodOptional<z.ZodAny>;
21
21
  }, "strip", z.ZodTypeAny, {
22
- source: "session" | "backend" | "local" | "feature_flag";
22
+ source: "session" | "backend" | "local" | "feature_flag" | "sensor";
23
23
  path: string;
24
24
  fallback?: any;
25
25
  }, {
26
- source: "session" | "backend" | "local" | "feature_flag";
26
+ source: "session" | "backend" | "local" | "feature_flag" | "sensor";
27
27
  path: string;
28
28
  fallback?: any;
29
29
  }>;
30
30
  }, "strip", z.ZodTypeAny, {
31
31
  bind: {
32
- source: "session" | "backend" | "local" | "feature_flag";
32
+ source: "session" | "backend" | "local" | "feature_flag" | "sensor";
33
33
  path: string;
34
34
  fallback?: any;
35
35
  };
36
36
  }, {
37
37
  bind: {
38
- source: "session" | "backend" | "local" | "feature_flag";
38
+ source: "session" | "backend" | "local" | "feature_flag" | "sensor";
39
39
  path: string;
40
40
  fallback?: any;
41
41
  };
@@ -43,27 +43,27 @@ export declare const bindWrapper: z.ZodObject<{
43
43
  export declare const modifiersSpec: z.ZodObject<{
44
44
  visible: z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodObject<{
45
45
  bind: z.ZodObject<{
46
- source: z.ZodEnum<["session", "backend", "local", "feature_flag"]>;
46
+ source: z.ZodEnum<["session", "backend", "local", "feature_flag", "sensor"]>;
47
47
  path: z.ZodString;
48
48
  fallback: z.ZodOptional<z.ZodAny>;
49
49
  }, "strip", z.ZodTypeAny, {
50
- source: "session" | "backend" | "local" | "feature_flag";
50
+ source: "session" | "backend" | "local" | "feature_flag" | "sensor";
51
51
  path: string;
52
52
  fallback?: any;
53
53
  }, {
54
- source: "session" | "backend" | "local" | "feature_flag";
54
+ source: "session" | "backend" | "local" | "feature_flag" | "sensor";
55
55
  path: string;
56
56
  fallback?: any;
57
57
  }>;
58
58
  }, "strip", z.ZodTypeAny, {
59
59
  bind: {
60
- source: "session" | "backend" | "local" | "feature_flag";
60
+ source: "session" | "backend" | "local" | "feature_flag" | "sensor";
61
61
  path: string;
62
62
  fallback?: any;
63
63
  };
64
64
  }, {
65
65
  bind: {
66
- source: "session" | "backend" | "local" | "feature_flag";
66
+ source: "session" | "backend" | "local" | "feature_flag" | "sensor";
67
67
  path: string;
68
68
  fallback?: any;
69
69
  };
@@ -71,7 +71,7 @@ export declare const modifiersSpec: z.ZodObject<{
71
71
  }, "strip", z.ZodTypeAny, {
72
72
  visible?: boolean | {
73
73
  bind: {
74
- source: "session" | "backend" | "local" | "feature_flag";
74
+ source: "session" | "backend" | "local" | "feature_flag" | "sensor";
75
75
  path: string;
76
76
  fallback?: any;
77
77
  };
@@ -79,7 +79,7 @@ export declare const modifiersSpec: z.ZodObject<{
79
79
  }, {
80
80
  visible?: boolean | {
81
81
  bind: {
82
- source: "session" | "backend" | "local" | "feature_flag";
82
+ source: "session" | "backend" | "local" | "feature_flag" | "sensor";
83
83
  path: string;
84
84
  fallback?: any;
85
85
  };
@@ -10,6 +10,7 @@ exports.bindingSourceEnum = zod_1.z.enum([
10
10
  "backend",
11
11
  "local",
12
12
  "feature_flag",
13
+ "sensor",
13
14
  ]);
14
15
  // ─── bindingSpec ─────────────────────────────────────────────────
15
16
  // SPEC.md §2.7: { source, path } required; fallback optional
@@ -16,6 +16,26 @@ export declare const layoutSpec: z.ZodObject<{
16
16
  gap: z.ZodOptional<z.ZodNumber>;
17
17
  columns: z.ZodOptional<z.ZodNumber>;
18
18
  align: z.ZodOptional<z.ZodEnum<["start", "center", "end", "stretch"]>>;
19
+ align_content: z.ZodOptional<z.ZodEnum<["start", "center", "end", "space-between", "space-around", "stretch"]>>;
20
+ align_items: z.ZodOptional<z.ZodEnum<["start", "center", "end", "stretch"]>>;
21
+ padding: z.ZodOptional<z.ZodObject<{
22
+ top: z.ZodOptional<z.ZodNumber>;
23
+ right: z.ZodOptional<z.ZodNumber>;
24
+ bottom: z.ZodOptional<z.ZodNumber>;
25
+ left: z.ZodOptional<z.ZodNumber>;
26
+ }, "strict", z.ZodTypeAny, {
27
+ top?: number | undefined;
28
+ right?: number | undefined;
29
+ bottom?: number | undefined;
30
+ left?: number | undefined;
31
+ }, {
32
+ top?: number | undefined;
33
+ right?: number | undefined;
34
+ bottom?: number | undefined;
35
+ left?: number | undefined;
36
+ }>>;
37
+ sizing_h: z.ZodOptional<z.ZodEnum<["hug", "fill", "fixed"]>>;
38
+ sizing_v: z.ZodOptional<z.ZodEnum<["hug", "fill", "fixed"]>>;
19
39
  positioning: z.ZodOptional<z.ZodObject<{
20
40
  type: z.ZodEnum<["relative", "sticky", "absolute"]>;
21
41
  }, "strip", z.ZodTypeAny, {
@@ -23,21 +43,41 @@ export declare const layoutSpec: z.ZodObject<{
23
43
  }, {
24
44
  type: "relative" | "sticky" | "absolute";
25
45
  }>>;
26
- }, "strip", z.ZodTypeAny, {
46
+ }, "strict", z.ZodTypeAny, {
27
47
  kind: "stack" | "grid";
48
+ padding?: {
49
+ top?: number | undefined;
50
+ right?: number | undefined;
51
+ bottom?: number | undefined;
52
+ left?: number | undefined;
53
+ } | undefined;
28
54
  direction?: "vertical" | "horizontal" | undefined;
29
55
  gap?: number | undefined;
30
56
  columns?: number | undefined;
31
57
  align?: "start" | "center" | "end" | "stretch" | undefined;
58
+ align_content?: "start" | "center" | "end" | "stretch" | "space-between" | "space-around" | undefined;
59
+ align_items?: "start" | "center" | "end" | "stretch" | undefined;
60
+ sizing_h?: "fill" | "hug" | "fixed" | undefined;
61
+ sizing_v?: "fill" | "hug" | "fixed" | undefined;
32
62
  positioning?: {
33
63
  type: "relative" | "sticky" | "absolute";
34
64
  } | undefined;
35
65
  }, {
36
66
  kind: "stack" | "grid";
67
+ padding?: {
68
+ top?: number | undefined;
69
+ right?: number | undefined;
70
+ bottom?: number | undefined;
71
+ left?: number | undefined;
72
+ } | undefined;
37
73
  direction?: "vertical" | "horizontal" | undefined;
38
74
  gap?: number | undefined;
39
75
  columns?: number | undefined;
40
76
  align?: "start" | "center" | "end" | "stretch" | undefined;
77
+ align_content?: "start" | "center" | "end" | "stretch" | "space-between" | "space-around" | undefined;
78
+ align_items?: "start" | "center" | "end" | "stretch" | undefined;
79
+ sizing_h?: "fill" | "hug" | "fixed" | undefined;
80
+ sizing_v?: "fill" | "hug" | "fixed" | undefined;
41
81
  positioning?: {
42
82
  type: "relative" | "sticky" | "absolute";
43
83
  } | undefined;
@@ -14,11 +14,21 @@ exports.positioningSpec = zod_1.z.object({
14
14
  exports.layoutSpec = zod_1.z.object({
15
15
  kind: zod_1.z.enum(["stack", "grid"]),
16
16
  direction: zod_1.z.enum(["vertical", "horizontal"]).optional(),
17
- gap: zod_1.z.number().min(0).optional(),
17
+ gap: zod_1.z.number().optional(),
18
18
  columns: zod_1.z.number().int().min(1).optional(),
19
19
  align: zod_1.z.enum(["start", "center", "end", "stretch"]).optional(),
20
+ align_content: zod_1.z.enum(["start", "center", "end", "space-between", "space-around", "stretch"]).optional(),
21
+ align_items: zod_1.z.enum(["start", "center", "end", "stretch"]).optional(),
22
+ padding: zod_1.z.object({
23
+ top: zod_1.z.number().optional(),
24
+ right: zod_1.z.number().optional(),
25
+ bottom: zod_1.z.number().optional(),
26
+ left: zod_1.z.number().optional()
27
+ }).strict().optional(),
28
+ sizing_h: zod_1.z.enum(["hug", "fill", "fixed"]).optional(),
29
+ sizing_v: zod_1.z.enum(["hug", "fill", "fixed"]).optional(),
20
30
  positioning: exports.positioningSpec.optional(),
21
- });
31
+ }).strict();
22
32
  // ─── Composition types ───────────────────────────────────────────
23
33
  const compositionTypeEnum = zod_1.z.enum(["Card", "Stack", "Grid", "Header", "Footer"]);
24
34
  const compositionTypes = new Set(["Card", "Stack", "Grid", "Header", "Footer"]);
@@ -38,10 +48,13 @@ const constraintsSpec = zod_1.z.object({
38
48
  // we use a custom z.lazy() that checks the `type` field to
39
49
  // dispatch to the correct schema — avoiding exponential backtracking.
40
50
  exports.nodeSpec = zod_1.z.lazy(() => zod_1.z.any().superRefine((val, ctx) => {
51
+ if (typeof val === "object" && val !== null && typeof val.$ref === "string") {
52
+ return; // Allow remote and local file refs
53
+ }
41
54
  if (typeof val !== "object" || val === null || typeof val.type !== "string") {
42
55
  ctx.addIssue({
43
56
  code: zod_1.z.ZodIssueCode.custom,
44
- message: "Node must be an object with a 'type' string property.",
57
+ message: "Node must be an object with a 'type' string property or a valid '$ref' object.",
45
58
  });
46
59
  return;
47
60
  }
@@ -66,6 +79,7 @@ exports.nodeSpec = zod_1.z.lazy(() => zod_1.z.any().superRefine((val, ctx) => {
66
79
  const elementSpecInternal = zod_1.z.object({
67
80
  type: zod_1.z.string().min(1),
68
81
  id: zod_1.z.string().min(1),
82
+ name: zod_1.z.string().optional(),
69
83
  props: zod_1.z.record(zod_1.z.any()),
70
84
  constraints: constraintsSpec,
71
85
  modifiers: binding_1.modifiersSpec.optional(),
@@ -78,22 +92,25 @@ const elementSpecInternal = zod_1.z.object({
78
92
  exports.compositionSpec = zod_1.z.lazy(() => zod_1.z.object({
79
93
  type: compositionTypeEnum,
80
94
  id: zod_1.z.string().min(1).regex(/^[A-Za-z][A-Za-z0-9_.:-]{0,127}$/),
95
+ name: zod_1.z.string().optional(),
81
96
  layout: exports.layoutSpec,
97
+ style: zod_1.z.record(zod_1.z.any()).optional(),
82
98
  children: zod_1.z.array(exports.nodeSpec).min(0),
83
99
  constraints: constraintsSpec,
84
100
  modifiers: binding_1.modifiersSpec.optional(),
85
101
  telemetry: telemetry_1.telemetrySpec,
86
- }).passthrough());
102
+ }).strict());
87
103
  // ─── RepeaterSpec ────────────────────────────────────────────────
88
104
  // SPEC.md §2.5: type MUST be "Repeater", data.bind REQUIRED,
89
105
  // template MUST be a valid nodeSpec, telemetry REQUIRED.
90
106
  exports.repeaterSpec = zod_1.z.lazy(() => zod_1.z.object({
91
107
  type: zod_1.z.literal("Repeater"),
92
108
  id: zod_1.z.string().min(1),
109
+ name: zod_1.z.string().optional(),
93
110
  data: zod_1.z.object({
94
111
  bind: binding_1.bindingSpec,
95
112
  }),
96
113
  template: exports.nodeSpec,
97
114
  modifiers: binding_1.modifiersSpec.optional(),
98
115
  telemetry: telemetry_1.telemetrySpec,
99
- }).passthrough());
116
+ }).strict());
@@ -2,6 +2,7 @@ import { z } from "zod";
2
2
  export declare const elementSpec: z.ZodEffects<z.ZodEffects<z.ZodObject<{
3
3
  type: z.ZodString;
4
4
  id: z.ZodString;
5
+ name: z.ZodOptional<z.ZodString>;
5
6
  props: z.ZodRecord<z.ZodString, z.ZodAny>;
6
7
  constraints: z.ZodOptional<z.ZodObject<{
7
8
  a11y: z.ZodOptional<z.ZodObject<{
@@ -58,27 +59,27 @@ export declare const elementSpec: z.ZodEffects<z.ZodEffects<z.ZodObject<{
58
59
  modifiers: z.ZodOptional<z.ZodObject<{
59
60
  visible: z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodObject<{
60
61
  bind: z.ZodObject<{
61
- source: z.ZodEnum<["session", "backend", "local", "feature_flag"]>;
62
+ source: z.ZodEnum<["session", "backend", "local", "feature_flag", "sensor"]>;
62
63
  path: z.ZodString;
63
64
  fallback: z.ZodOptional<z.ZodAny>;
64
65
  }, "strip", z.ZodTypeAny, {
65
- source: "session" | "backend" | "local" | "feature_flag";
66
+ source: "session" | "backend" | "local" | "feature_flag" | "sensor";
66
67
  path: string;
67
68
  fallback?: any;
68
69
  }, {
69
- source: "session" | "backend" | "local" | "feature_flag";
70
+ source: "session" | "backend" | "local" | "feature_flag" | "sensor";
70
71
  path: string;
71
72
  fallback?: any;
72
73
  }>;
73
74
  }, "strip", z.ZodTypeAny, {
74
75
  bind: {
75
- source: "session" | "backend" | "local" | "feature_flag";
76
+ source: "session" | "backend" | "local" | "feature_flag" | "sensor";
76
77
  path: string;
77
78
  fallback?: any;
78
79
  };
79
80
  }, {
80
81
  bind: {
81
- source: "session" | "backend" | "local" | "feature_flag";
82
+ source: "session" | "backend" | "local" | "feature_flag" | "sensor";
82
83
  path: string;
83
84
  fallback?: any;
84
85
  };
@@ -86,7 +87,7 @@ export declare const elementSpec: z.ZodEffects<z.ZodEffects<z.ZodObject<{
86
87
  }, "strip", z.ZodTypeAny, {
87
88
  visible?: boolean | {
88
89
  bind: {
89
- source: "session" | "backend" | "local" | "feature_flag";
90
+ source: "session" | "backend" | "local" | "feature_flag" | "sensor";
90
91
  path: string;
91
92
  fallback?: any;
92
93
  };
@@ -94,7 +95,7 @@ export declare const elementSpec: z.ZodEffects<z.ZodEffects<z.ZodObject<{
94
95
  }, {
95
96
  visible?: boolean | {
96
97
  bind: {
97
- source: "session" | "backend" | "local" | "feature_flag";
98
+ source: "session" | "backend" | "local" | "feature_flag" | "sensor";
98
99
  path: string;
99
100
  fallback?: any;
100
101
  };
@@ -110,6 +111,7 @@ export declare const elementSpec: z.ZodEffects<z.ZodEffects<z.ZodObject<{
110
111
  }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
111
112
  type: z.ZodString;
112
113
  id: z.ZodString;
114
+ name: z.ZodOptional<z.ZodString>;
113
115
  props: z.ZodRecord<z.ZodString, z.ZodAny>;
114
116
  constraints: z.ZodOptional<z.ZodObject<{
115
117
  a11y: z.ZodOptional<z.ZodObject<{
@@ -166,27 +168,27 @@ export declare const elementSpec: z.ZodEffects<z.ZodEffects<z.ZodObject<{
166
168
  modifiers: z.ZodOptional<z.ZodObject<{
167
169
  visible: z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodObject<{
168
170
  bind: z.ZodObject<{
169
- source: z.ZodEnum<["session", "backend", "local", "feature_flag"]>;
171
+ source: z.ZodEnum<["session", "backend", "local", "feature_flag", "sensor"]>;
170
172
  path: z.ZodString;
171
173
  fallback: z.ZodOptional<z.ZodAny>;
172
174
  }, "strip", z.ZodTypeAny, {
173
- source: "session" | "backend" | "local" | "feature_flag";
175
+ source: "session" | "backend" | "local" | "feature_flag" | "sensor";
174
176
  path: string;
175
177
  fallback?: any;
176
178
  }, {
177
- source: "session" | "backend" | "local" | "feature_flag";
179
+ source: "session" | "backend" | "local" | "feature_flag" | "sensor";
178
180
  path: string;
179
181
  fallback?: any;
180
182
  }>;
181
183
  }, "strip", z.ZodTypeAny, {
182
184
  bind: {
183
- source: "session" | "backend" | "local" | "feature_flag";
185
+ source: "session" | "backend" | "local" | "feature_flag" | "sensor";
184
186
  path: string;
185
187
  fallback?: any;
186
188
  };
187
189
  }, {
188
190
  bind: {
189
- source: "session" | "backend" | "local" | "feature_flag";
191
+ source: "session" | "backend" | "local" | "feature_flag" | "sensor";
190
192
  path: string;
191
193
  fallback?: any;
192
194
  };
@@ -194,7 +196,7 @@ export declare const elementSpec: z.ZodEffects<z.ZodEffects<z.ZodObject<{
194
196
  }, "strip", z.ZodTypeAny, {
195
197
  visible?: boolean | {
196
198
  bind: {
197
- source: "session" | "backend" | "local" | "feature_flag";
199
+ source: "session" | "backend" | "local" | "feature_flag" | "sensor";
198
200
  path: string;
199
201
  fallback?: any;
200
202
  };
@@ -202,7 +204,7 @@ export declare const elementSpec: z.ZodEffects<z.ZodEffects<z.ZodObject<{
202
204
  }, {
203
205
  visible?: boolean | {
204
206
  bind: {
205
- source: "session" | "backend" | "local" | "feature_flag";
207
+ source: "session" | "backend" | "local" | "feature_flag" | "sensor";
206
208
  path: string;
207
209
  fallback?: any;
208
210
  };
@@ -218,6 +220,7 @@ export declare const elementSpec: z.ZodEffects<z.ZodEffects<z.ZodObject<{
218
220
  }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
219
221
  type: z.ZodString;
220
222
  id: z.ZodString;
223
+ name: z.ZodOptional<z.ZodString>;
221
224
  props: z.ZodRecord<z.ZodString, z.ZodAny>;
222
225
  constraints: z.ZodOptional<z.ZodObject<{
223
226
  a11y: z.ZodOptional<z.ZodObject<{
@@ -274,27 +277,27 @@ export declare const elementSpec: z.ZodEffects<z.ZodEffects<z.ZodObject<{
274
277
  modifiers: z.ZodOptional<z.ZodObject<{
275
278
  visible: z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodObject<{
276
279
  bind: z.ZodObject<{
277
- source: z.ZodEnum<["session", "backend", "local", "feature_flag"]>;
280
+ source: z.ZodEnum<["session", "backend", "local", "feature_flag", "sensor"]>;
278
281
  path: z.ZodString;
279
282
  fallback: z.ZodOptional<z.ZodAny>;
280
283
  }, "strip", z.ZodTypeAny, {
281
- source: "session" | "backend" | "local" | "feature_flag";
284
+ source: "session" | "backend" | "local" | "feature_flag" | "sensor";
282
285
  path: string;
283
286
  fallback?: any;
284
287
  }, {
285
- source: "session" | "backend" | "local" | "feature_flag";
288
+ source: "session" | "backend" | "local" | "feature_flag" | "sensor";
286
289
  path: string;
287
290
  fallback?: any;
288
291
  }>;
289
292
  }, "strip", z.ZodTypeAny, {
290
293
  bind: {
291
- source: "session" | "backend" | "local" | "feature_flag";
294
+ source: "session" | "backend" | "local" | "feature_flag" | "sensor";
292
295
  path: string;
293
296
  fallback?: any;
294
297
  };
295
298
  }, {
296
299
  bind: {
297
- source: "session" | "backend" | "local" | "feature_flag";
300
+ source: "session" | "backend" | "local" | "feature_flag" | "sensor";
298
301
  path: string;
299
302
  fallback?: any;
300
303
  };
@@ -302,7 +305,7 @@ export declare const elementSpec: z.ZodEffects<z.ZodEffects<z.ZodObject<{
302
305
  }, "strip", z.ZodTypeAny, {
303
306
  visible?: boolean | {
304
307
  bind: {
305
- source: "session" | "backend" | "local" | "feature_flag";
308
+ source: "session" | "backend" | "local" | "feature_flag" | "sensor";
306
309
  path: string;
307
310
  fallback?: any;
308
311
  };
@@ -310,7 +313,7 @@ export declare const elementSpec: z.ZodEffects<z.ZodEffects<z.ZodObject<{
310
313
  }, {
311
314
  visible?: boolean | {
312
315
  bind: {
313
- source: "session" | "backend" | "local" | "feature_flag";
316
+ source: "session" | "backend" | "local" | "feature_flag" | "sensor";
314
317
  path: string;
315
318
  fallback?: any;
316
319
  };
@@ -326,6 +329,7 @@ export declare const elementSpec: z.ZodEffects<z.ZodEffects<z.ZodObject<{
326
329
  }, z.ZodTypeAny, "passthrough">>, z.objectOutputType<{
327
330
  type: z.ZodString;
328
331
  id: z.ZodString;
332
+ name: z.ZodOptional<z.ZodString>;
329
333
  props: z.ZodRecord<z.ZodString, z.ZodAny>;
330
334
  constraints: z.ZodOptional<z.ZodObject<{
331
335
  a11y: z.ZodOptional<z.ZodObject<{
@@ -382,27 +386,27 @@ export declare const elementSpec: z.ZodEffects<z.ZodEffects<z.ZodObject<{
382
386
  modifiers: z.ZodOptional<z.ZodObject<{
383
387
  visible: z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodObject<{
384
388
  bind: z.ZodObject<{
385
- source: z.ZodEnum<["session", "backend", "local", "feature_flag"]>;
389
+ source: z.ZodEnum<["session", "backend", "local", "feature_flag", "sensor"]>;
386
390
  path: z.ZodString;
387
391
  fallback: z.ZodOptional<z.ZodAny>;
388
392
  }, "strip", z.ZodTypeAny, {
389
- source: "session" | "backend" | "local" | "feature_flag";
393
+ source: "session" | "backend" | "local" | "feature_flag" | "sensor";
390
394
  path: string;
391
395
  fallback?: any;
392
396
  }, {
393
- source: "session" | "backend" | "local" | "feature_flag";
397
+ source: "session" | "backend" | "local" | "feature_flag" | "sensor";
394
398
  path: string;
395
399
  fallback?: any;
396
400
  }>;
397
401
  }, "strip", z.ZodTypeAny, {
398
402
  bind: {
399
- source: "session" | "backend" | "local" | "feature_flag";
403
+ source: "session" | "backend" | "local" | "feature_flag" | "sensor";
400
404
  path: string;
401
405
  fallback?: any;
402
406
  };
403
407
  }, {
404
408
  bind: {
405
- source: "session" | "backend" | "local" | "feature_flag";
409
+ source: "session" | "backend" | "local" | "feature_flag" | "sensor";
406
410
  path: string;
407
411
  fallback?: any;
408
412
  };
@@ -410,7 +414,7 @@ export declare const elementSpec: z.ZodEffects<z.ZodEffects<z.ZodObject<{
410
414
  }, "strip", z.ZodTypeAny, {
411
415
  visible?: boolean | {
412
416
  bind: {
413
- source: "session" | "backend" | "local" | "feature_flag";
417
+ source: "session" | "backend" | "local" | "feature_flag" | "sensor";
414
418
  path: string;
415
419
  fallback?: any;
416
420
  };
@@ -418,7 +422,7 @@ export declare const elementSpec: z.ZodEffects<z.ZodEffects<z.ZodObject<{
418
422
  }, {
419
423
  visible?: boolean | {
420
424
  bind: {
421
- source: "session" | "backend" | "local" | "feature_flag";
425
+ source: "session" | "backend" | "local" | "feature_flag" | "sensor";
422
426
  path: string;
423
427
  fallback?: any;
424
428
  };
@@ -434,6 +438,7 @@ export declare const elementSpec: z.ZodEffects<z.ZodEffects<z.ZodObject<{
434
438
  }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
435
439
  type: z.ZodString;
436
440
  id: z.ZodString;
441
+ name: z.ZodOptional<z.ZodString>;
437
442
  props: z.ZodRecord<z.ZodString, z.ZodAny>;
438
443
  constraints: z.ZodOptional<z.ZodObject<{
439
444
  a11y: z.ZodOptional<z.ZodObject<{
@@ -490,27 +495,27 @@ export declare const elementSpec: z.ZodEffects<z.ZodEffects<z.ZodObject<{
490
495
  modifiers: z.ZodOptional<z.ZodObject<{
491
496
  visible: z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodObject<{
492
497
  bind: z.ZodObject<{
493
- source: z.ZodEnum<["session", "backend", "local", "feature_flag"]>;
498
+ source: z.ZodEnum<["session", "backend", "local", "feature_flag", "sensor"]>;
494
499
  path: z.ZodString;
495
500
  fallback: z.ZodOptional<z.ZodAny>;
496
501
  }, "strip", z.ZodTypeAny, {
497
- source: "session" | "backend" | "local" | "feature_flag";
502
+ source: "session" | "backend" | "local" | "feature_flag" | "sensor";
498
503
  path: string;
499
504
  fallback?: any;
500
505
  }, {
501
- source: "session" | "backend" | "local" | "feature_flag";
506
+ source: "session" | "backend" | "local" | "feature_flag" | "sensor";
502
507
  path: string;
503
508
  fallback?: any;
504
509
  }>;
505
510
  }, "strip", z.ZodTypeAny, {
506
511
  bind: {
507
- source: "session" | "backend" | "local" | "feature_flag";
512
+ source: "session" | "backend" | "local" | "feature_flag" | "sensor";
508
513
  path: string;
509
514
  fallback?: any;
510
515
  };
511
516
  }, {
512
517
  bind: {
513
- source: "session" | "backend" | "local" | "feature_flag";
518
+ source: "session" | "backend" | "local" | "feature_flag" | "sensor";
514
519
  path: string;
515
520
  fallback?: any;
516
521
  };
@@ -518,7 +523,7 @@ export declare const elementSpec: z.ZodEffects<z.ZodEffects<z.ZodObject<{
518
523
  }, "strip", z.ZodTypeAny, {
519
524
  visible?: boolean | {
520
525
  bind: {
521
- source: "session" | "backend" | "local" | "feature_flag";
526
+ source: "session" | "backend" | "local" | "feature_flag" | "sensor";
522
527
  path: string;
523
528
  fallback?: any;
524
529
  };
@@ -526,7 +531,7 @@ export declare const elementSpec: z.ZodEffects<z.ZodEffects<z.ZodObject<{
526
531
  }, {
527
532
  visible?: boolean | {
528
533
  bind: {
529
- source: "session" | "backend" | "local" | "feature_flag";
534
+ source: "session" | "backend" | "local" | "feature_flag" | "sensor";
530
535
  path: string;
531
536
  fallback?: any;
532
537
  };
@@ -542,6 +547,7 @@ export declare const elementSpec: z.ZodEffects<z.ZodEffects<z.ZodObject<{
542
547
  }, z.ZodTypeAny, "passthrough">>, z.objectOutputType<{
543
548
  type: z.ZodString;
544
549
  id: z.ZodString;
550
+ name: z.ZodOptional<z.ZodString>;
545
551
  props: z.ZodRecord<z.ZodString, z.ZodAny>;
546
552
  constraints: z.ZodOptional<z.ZodObject<{
547
553
  a11y: z.ZodOptional<z.ZodObject<{
@@ -598,27 +604,27 @@ export declare const elementSpec: z.ZodEffects<z.ZodEffects<z.ZodObject<{
598
604
  modifiers: z.ZodOptional<z.ZodObject<{
599
605
  visible: z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodObject<{
600
606
  bind: z.ZodObject<{
601
- source: z.ZodEnum<["session", "backend", "local", "feature_flag"]>;
607
+ source: z.ZodEnum<["session", "backend", "local", "feature_flag", "sensor"]>;
602
608
  path: z.ZodString;
603
609
  fallback: z.ZodOptional<z.ZodAny>;
604
610
  }, "strip", z.ZodTypeAny, {
605
- source: "session" | "backend" | "local" | "feature_flag";
611
+ source: "session" | "backend" | "local" | "feature_flag" | "sensor";
606
612
  path: string;
607
613
  fallback?: any;
608
614
  }, {
609
- source: "session" | "backend" | "local" | "feature_flag";
615
+ source: "session" | "backend" | "local" | "feature_flag" | "sensor";
610
616
  path: string;
611
617
  fallback?: any;
612
618
  }>;
613
619
  }, "strip", z.ZodTypeAny, {
614
620
  bind: {
615
- source: "session" | "backend" | "local" | "feature_flag";
621
+ source: "session" | "backend" | "local" | "feature_flag" | "sensor";
616
622
  path: string;
617
623
  fallback?: any;
618
624
  };
619
625
  }, {
620
626
  bind: {
621
- source: "session" | "backend" | "local" | "feature_flag";
627
+ source: "session" | "backend" | "local" | "feature_flag" | "sensor";
622
628
  path: string;
623
629
  fallback?: any;
624
630
  };
@@ -626,7 +632,7 @@ export declare const elementSpec: z.ZodEffects<z.ZodEffects<z.ZodObject<{
626
632
  }, "strip", z.ZodTypeAny, {
627
633
  visible?: boolean | {
628
634
  bind: {
629
- source: "session" | "backend" | "local" | "feature_flag";
635
+ source: "session" | "backend" | "local" | "feature_flag" | "sensor";
630
636
  path: string;
631
637
  fallback?: any;
632
638
  };
@@ -634,7 +640,7 @@ export declare const elementSpec: z.ZodEffects<z.ZodEffects<z.ZodObject<{
634
640
  }, {
635
641
  visible?: boolean | {
636
642
  bind: {
637
- source: "session" | "backend" | "local" | "feature_flag";
643
+ source: "session" | "backend" | "local" | "feature_flag" | "sensor";
638
644
  path: string;
639
645
  fallback?: any;
640
646
  };
@@ -650,6 +656,7 @@ export declare const elementSpec: z.ZodEffects<z.ZodEffects<z.ZodObject<{
650
656
  }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
651
657
  type: z.ZodString;
652
658
  id: z.ZodString;
659
+ name: z.ZodOptional<z.ZodString>;
653
660
  props: z.ZodRecord<z.ZodString, z.ZodAny>;
654
661
  constraints: z.ZodOptional<z.ZodObject<{
655
662
  a11y: z.ZodOptional<z.ZodObject<{
@@ -706,27 +713,27 @@ export declare const elementSpec: z.ZodEffects<z.ZodEffects<z.ZodObject<{
706
713
  modifiers: z.ZodOptional<z.ZodObject<{
707
714
  visible: z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodObject<{
708
715
  bind: z.ZodObject<{
709
- source: z.ZodEnum<["session", "backend", "local", "feature_flag"]>;
716
+ source: z.ZodEnum<["session", "backend", "local", "feature_flag", "sensor"]>;
710
717
  path: z.ZodString;
711
718
  fallback: z.ZodOptional<z.ZodAny>;
712
719
  }, "strip", z.ZodTypeAny, {
713
- source: "session" | "backend" | "local" | "feature_flag";
720
+ source: "session" | "backend" | "local" | "feature_flag" | "sensor";
714
721
  path: string;
715
722
  fallback?: any;
716
723
  }, {
717
- source: "session" | "backend" | "local" | "feature_flag";
724
+ source: "session" | "backend" | "local" | "feature_flag" | "sensor";
718
725
  path: string;
719
726
  fallback?: any;
720
727
  }>;
721
728
  }, "strip", z.ZodTypeAny, {
722
729
  bind: {
723
- source: "session" | "backend" | "local" | "feature_flag";
730
+ source: "session" | "backend" | "local" | "feature_flag" | "sensor";
724
731
  path: string;
725
732
  fallback?: any;
726
733
  };
727
734
  }, {
728
735
  bind: {
729
- source: "session" | "backend" | "local" | "feature_flag";
736
+ source: "session" | "backend" | "local" | "feature_flag" | "sensor";
730
737
  path: string;
731
738
  fallback?: any;
732
739
  };
@@ -734,7 +741,7 @@ export declare const elementSpec: z.ZodEffects<z.ZodEffects<z.ZodObject<{
734
741
  }, "strip", z.ZodTypeAny, {
735
742
  visible?: boolean | {
736
743
  bind: {
737
- source: "session" | "backend" | "local" | "feature_flag";
744
+ source: "session" | "backend" | "local" | "feature_flag" | "sensor";
738
745
  path: string;
739
746
  fallback?: any;
740
747
  };
@@ -742,7 +749,7 @@ export declare const elementSpec: z.ZodEffects<z.ZodEffects<z.ZodObject<{
742
749
  }, {
743
750
  visible?: boolean | {
744
751
  bind: {
745
- source: "session" | "backend" | "local" | "feature_flag";
752
+ source: "session" | "backend" | "local" | "feature_flag" | "sensor";
746
753
  path: string;
747
754
  fallback?: any;
748
755
  };
@@ -13,6 +13,7 @@ const telemetry_1 = require("./telemetry");
13
13
  exports.elementSpec = zod_1.z.object({
14
14
  type: zod_1.z.string().min(1),
15
15
  id: zod_1.z.string().min(1),
16
+ name: zod_1.z.string().optional(),
16
17
  props: zod_1.z.record(zod_1.z.any()),
17
18
  constraints: zod_1.z.object({
18
19
  a11y: zod_1.z.object({
@@ -1,6 +1,7 @@
1
1
  import { z } from "zod";
2
2
  export declare const surfaceSpec: z.ZodObject<{
3
3
  id: z.ZodString;
4
+ name: z.ZodOptional<z.ZodString>;
4
5
  root: z.ZodType<any, z.ZodTypeDef, any>;
5
6
  telemetry: z.ZodObject<{
6
7
  emit: z.ZodArray<z.ZodString, "many">;
@@ -11,29 +12,23 @@ export declare const surfaceSpec: z.ZodObject<{
11
12
  }>;
12
13
  metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
13
14
  environment: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
14
- }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
15
- id: z.ZodString;
16
- root: z.ZodType<any, z.ZodTypeDef, any>;
17
- telemetry: z.ZodObject<{
18
- emit: z.ZodArray<z.ZodString, "many">;
19
- }, "strip", z.ZodTypeAny, {
20
- emit: string[];
21
- }, {
22
- emit: string[];
23
- }>;
24
- metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
25
- environment: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
26
- }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
27
- id: z.ZodString;
28
- root: z.ZodType<any, z.ZodTypeDef, any>;
29
- telemetry: z.ZodObject<{
30
- emit: z.ZodArray<z.ZodString, "many">;
31
- }, "strip", z.ZodTypeAny, {
15
+ }, "strict", z.ZodTypeAny, {
16
+ id: string;
17
+ telemetry: {
32
18
  emit: string[];
33
- }, {
19
+ };
20
+ name?: string | undefined;
21
+ root?: any;
22
+ metadata?: Record<string, any> | undefined;
23
+ environment?: Record<string, any> | undefined;
24
+ }, {
25
+ id: string;
26
+ telemetry: {
34
27
  emit: string[];
35
- }>;
36
- metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
37
- environment: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
38
- }, z.ZodTypeAny, "passthrough">>;
28
+ };
29
+ name?: string | undefined;
30
+ root?: any;
31
+ metadata?: Record<string, any> | undefined;
32
+ environment?: Record<string, any> | undefined;
33
+ }>;
39
34
  export type SurfaceSpec = z.infer<typeof surfaceSpec>;
@@ -12,8 +12,9 @@ const telemetry_1 = require("./telemetry");
12
12
  // root level; it must be contained within a Composition.
13
13
  exports.surfaceSpec = zod_1.z.object({
14
14
  id: zod_1.z.string().min(1).regex(/^[A-Za-z][A-Za-z0-9_.:-]{0,127}$/),
15
+ name: zod_1.z.string().optional(),
15
16
  root: composition_1.compositionSpec,
16
17
  telemetry: telemetry_1.telemetrySpec,
17
18
  metadata: zod_1.z.record(zod_1.z.any()).optional(),
18
19
  environment: zod_1.z.record(zod_1.z.any()).optional(),
19
- }).passthrough();
20
+ }).strict();
package/package.json CHANGED
@@ -1,17 +1,17 @@
1
1
  {
2
- "name": "desen-core",
3
- "version": "1.0.0-draft.2",
4
- "main": "dist/index.js",
5
- "types": "dist/index.d.ts",
6
- "dependencies": {
7
- "zod": "^3.22.4"
8
- },
9
- "devDependencies": {
10
- "typescript": "^5.0.0"
11
- },
12
- "scripts": {
13
- "build": "tsc",
14
- "dev": "tsc -w",
15
- "clean": "rm -rf dist"
16
- }
17
- }
2
+ "name": "desen-core",
3
+ "version": "1.0.0-draft.21",
4
+ "main": "dist/index.js",
5
+ "types": "dist/index.d.ts",
6
+ "scripts": {
7
+ "build": "tsc",
8
+ "dev": "tsc -w",
9
+ "clean": "rm -rf dist"
10
+ },
11
+ "dependencies": {
12
+ "zod": "^3.22.4"
13
+ },
14
+ "devDependencies": {
15
+ "typescript": "^5.0.0"
16
+ }
17
+ }
@@ -8,6 +8,7 @@ export const bindingSourceEnum = z.enum([
8
8
  "backend",
9
9
  "local",
10
10
  "feature_flag",
11
+ "sensor",
11
12
  ]);
12
13
 
13
14
  // ─── bindingSpec ─────────────────────────────────────────────────
@@ -22,11 +22,21 @@ export const positioningSpec = z.object({
22
22
  export const layoutSpec = z.object({
23
23
  kind: z.enum(["stack", "grid"]),
24
24
  direction: z.enum(["vertical", "horizontal"]).optional(),
25
- gap: z.number().min(0).optional(),
25
+ gap: z.number().optional(),
26
26
  columns: z.number().int().min(1).optional(),
27
27
  align: z.enum(["start", "center", "end", "stretch"]).optional(),
28
+ align_content: z.enum(["start", "center", "end", "space-between", "space-around", "stretch"]).optional(),
29
+ align_items: z.enum(["start", "center", "end", "stretch"]).optional(),
30
+ padding: z.object({
31
+ top: z.number().optional(),
32
+ right: z.number().optional(),
33
+ bottom: z.number().optional(),
34
+ left: z.number().optional()
35
+ }).strict().optional(),
36
+ sizing_h: z.enum(["hug", "fill", "fixed"]).optional(),
37
+ sizing_v: z.enum(["hug", "fill", "fixed"]).optional(),
28
38
  positioning: positioningSpec.optional(),
29
- });
39
+ }).strict();
30
40
 
31
41
  // ─── Composition types ───────────────────────────────────────────
32
42
  const compositionTypeEnum = z.enum(["Card", "Stack", "Grid", "Header", "Footer"]);
@@ -50,10 +60,14 @@ const constraintsSpec = z.object({
50
60
  // dispatch to the correct schema — avoiding exponential backtracking.
51
61
  export const nodeSpec: z.ZodType<NodeSpec> = z.lazy(() =>
52
62
  z.any().superRefine((val, ctx) => {
63
+ if (typeof val === "object" && val !== null && typeof val.$ref === "string") {
64
+ return; // Allow remote and local file refs
65
+ }
66
+
53
67
  if (typeof val !== "object" || val === null || typeof val.type !== "string") {
54
68
  ctx.addIssue({
55
69
  code: z.ZodIssueCode.custom,
56
- message: "Node must be an object with a 'type' string property.",
70
+ message: "Node must be an object with a 'type' string property or a valid '$ref' object.",
57
71
  });
58
72
  return;
59
73
  }
@@ -80,6 +94,7 @@ export const nodeSpec: z.ZodType<NodeSpec> = z.lazy(() =>
80
94
  const elementSpecInternal = z.object({
81
95
  type: z.string().min(1),
82
96
  id: z.string().min(1),
97
+ name: z.string().optional(),
83
98
  props: z.record(z.any()),
84
99
  constraints: constraintsSpec,
85
100
  modifiers: modifiersSpec.optional(),
@@ -100,12 +115,14 @@ export const compositionSpec: z.ZodType<any> = z.lazy(() =>
100
115
  z.object({
101
116
  type: compositionTypeEnum,
102
117
  id: z.string().min(1).regex(/^[A-Za-z][A-Za-z0-9_.:-]{0,127}$/),
118
+ name: z.string().optional(),
103
119
  layout: layoutSpec,
120
+ style: z.record(z.any()).optional(),
104
121
  children: z.array(nodeSpec).min(0),
105
122
  constraints: constraintsSpec,
106
123
  modifiers: modifiersSpec.optional(),
107
124
  telemetry: telemetrySpec,
108
- }).passthrough()
125
+ }).strict()
109
126
  );
110
127
 
111
128
  // ─── RepeaterSpec ────────────────────────────────────────────────
@@ -115,13 +132,14 @@ export const repeaterSpec: z.ZodType<any> = z.lazy(() =>
115
132
  z.object({
116
133
  type: z.literal("Repeater"),
117
134
  id: z.string().min(1),
135
+ name: z.string().optional(),
118
136
  data: z.object({
119
137
  bind: bindingSpec,
120
138
  }),
121
139
  template: nodeSpec,
122
140
  modifiers: modifiersSpec.optional(),
123
141
  telemetry: telemetrySpec,
124
- }).passthrough()
142
+ }).strict()
125
143
  );
126
144
 
127
145
  // ─── Types ───────────────────────────────────────────────────────
@@ -11,6 +11,7 @@ import { telemetrySpec } from "./telemetry";
11
11
  export const elementSpec = z.object({
12
12
  type: z.string().min(1),
13
13
  id: z.string().min(1),
14
+ name: z.string().optional(),
14
15
  props: z.record(z.any()),
15
16
  constraints: z.object({
16
17
  a11y: z.object({
@@ -10,11 +10,12 @@ import { telemetrySpec } from "./telemetry";
10
10
  // root level; it must be contained within a Composition.
11
11
  export const surfaceSpec = z.object({
12
12
  id: z.string().min(1).regex(/^[A-Za-z][A-Za-z0-9_.:-]{0,127}$/),
13
+ name: z.string().optional(),
13
14
  root: compositionSpec,
14
15
  telemetry: telemetrySpec,
15
16
  metadata: z.record(z.any()).optional(),
16
17
  environment: z.record(z.any()).optional(),
17
- }).passthrough();
18
+ }).strict();
18
19
 
19
20
  // ─── Types ───────────────────────────────────────────────────────
20
21
  export type SurfaceSpec = z.infer<typeof surfaceSpec>;