@nativemason/contracts 0.0.0-stage → 0.3.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,304 @@
1
+ import { z } from 'zod';
2
+ /** Each nested Figma node is validated independently by the bounded importer. */
3
+ export declare const FigmaNodeSchema: z.ZodObject<{
4
+ id: z.ZodString;
5
+ type: z.ZodString;
6
+ name: z.ZodOptional<z.ZodString>;
7
+ absoluteBoundingBox: z.ZodOptional<z.ZodObject<{
8
+ x: z.ZodNumber;
9
+ y: z.ZodNumber;
10
+ width: z.ZodNumber;
11
+ height: z.ZodNumber;
12
+ }, z.core.$strict>>;
13
+ layoutMode: z.ZodOptional<z.ZodEnum<{
14
+ NONE: "NONE";
15
+ HORIZONTAL: "HORIZONTAL";
16
+ VERTICAL: "VERTICAL";
17
+ }>>;
18
+ itemSpacing: z.ZodOptional<z.ZodNumber>;
19
+ counterAxisAlignItems: z.ZodOptional<z.ZodEnum<{
20
+ MIN: "MIN";
21
+ CENTER: "CENTER";
22
+ MAX: "MAX";
23
+ BASELINE: "BASELINE";
24
+ }>>;
25
+ children: z.ZodOptional<z.ZodArray<z.ZodUnknown>>;
26
+ }, z.core.$loose>;
27
+ export type FigmaNode = z.infer<typeof FigmaNodeSchema>;
28
+ export declare const DesignIntentSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
29
+ kind: z.ZodLiteral<"figma-auto-layout">;
30
+ frame: z.ZodObject<{
31
+ id: z.ZodString;
32
+ type: z.ZodString;
33
+ name: z.ZodOptional<z.ZodString>;
34
+ absoluteBoundingBox: z.ZodOptional<z.ZodObject<{
35
+ x: z.ZodNumber;
36
+ y: z.ZodNumber;
37
+ width: z.ZodNumber;
38
+ height: z.ZodNumber;
39
+ }, z.core.$strict>>;
40
+ layoutMode: z.ZodOptional<z.ZodEnum<{
41
+ NONE: "NONE";
42
+ HORIZONTAL: "HORIZONTAL";
43
+ VERTICAL: "VERTICAL";
44
+ }>>;
45
+ itemSpacing: z.ZodOptional<z.ZodNumber>;
46
+ counterAxisAlignItems: z.ZodOptional<z.ZodEnum<{
47
+ MIN: "MIN";
48
+ CENTER: "CENTER";
49
+ MAX: "MAX";
50
+ BASELINE: "BASELINE";
51
+ }>>;
52
+ children: z.ZodOptional<z.ZodArray<z.ZodUnknown>>;
53
+ }, z.core.$loose>;
54
+ elementMap: z.ZodRecord<z.ZodString, z.ZodString>;
55
+ logicalUnitsPerDesignUnit: z.ZodDefault<z.ZodNumber>;
56
+ scenarioId: z.ZodString;
57
+ profile: z.ZodObject<{
58
+ window: z.ZodObject<{
59
+ width: z.ZodNumber;
60
+ height: z.ZodNumber;
61
+ }, z.core.$strict>;
62
+ pixelRatio: z.ZodNumber;
63
+ fontScale: z.ZodNumber;
64
+ insets: z.ZodObject<{
65
+ top: z.ZodNumber;
66
+ right: z.ZodNumber;
67
+ bottom: z.ZodNumber;
68
+ left: z.ZodNumber;
69
+ }, z.core.$strict>;
70
+ root: z.ZodObject<{
71
+ x: z.ZodNumber;
72
+ y: z.ZodNumber;
73
+ width: z.ZodNumber;
74
+ height: z.ZodNumber;
75
+ }, z.core.$strict>;
76
+ orientation: z.ZodEnum<{
77
+ portrait: "portrait";
78
+ landscape: "landscape";
79
+ }>;
80
+ }, z.core.$strict>;
81
+ tolerance: z.ZodDefault<z.ZodNumber>;
82
+ }, z.core.$strict>, z.ZodObject<{
83
+ kind: z.ZodLiteral<"reference-annotations">;
84
+ image: z.ZodObject<{
85
+ sha256: z.ZodString;
86
+ width: z.ZodNumber;
87
+ height: z.ZodNumber;
88
+ }, z.core.$strict>;
89
+ appRootPixels: z.ZodObject<{
90
+ x: z.ZodNumber;
91
+ y: z.ZodNumber;
92
+ width: z.ZodNumber;
93
+ height: z.ZodNumber;
94
+ }, z.core.$strict>;
95
+ pixelsPerLogicalUnit: z.ZodNumber;
96
+ annotations: z.ZodArray<z.ZodObject<{
97
+ elementId: z.ZodString;
98
+ rectPixels: z.ZodObject<{
99
+ x: z.ZodNumber;
100
+ y: z.ZodNumber;
101
+ width: z.ZodNumber;
102
+ height: z.ZodNumber;
103
+ }, z.core.$strict>;
104
+ }, z.core.$strict>>;
105
+ assertions: z.ZodDefault<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
106
+ type: z.ZodLiteral<"textFits">;
107
+ elementId: z.ZodString;
108
+ id: z.ZodString;
109
+ tolerance: z.ZodDefault<z.ZodNumber>;
110
+ pixelAware: z.ZodOptional<z.ZodBoolean>;
111
+ }, z.core.$strict>, z.ZodObject<{
112
+ type: z.ZodLiteral<"rect">;
113
+ elementId: z.ZodString;
114
+ target: z.ZodObject<{
115
+ x: z.ZodNumber;
116
+ y: z.ZodNumber;
117
+ width: z.ZodNumber;
118
+ height: z.ZodNumber;
119
+ }, z.core.$strict>;
120
+ id: z.ZodString;
121
+ tolerance: z.ZodDefault<z.ZodNumber>;
122
+ pixelAware: z.ZodOptional<z.ZodBoolean>;
123
+ }, z.core.$strict>, z.ZodObject<{
124
+ type: z.ZodLiteral<"minTouchTarget">;
125
+ elementId: z.ZodString;
126
+ width: z.ZodDefault<z.ZodNumber>;
127
+ height: z.ZodDefault<z.ZodNumber>;
128
+ id: z.ZodString;
129
+ tolerance: z.ZodDefault<z.ZodNumber>;
130
+ pixelAware: z.ZodOptional<z.ZodBoolean>;
131
+ }, z.core.$strict>, z.ZodObject<{
132
+ type: z.ZodLiteral<"align">;
133
+ elementIds: z.ZodArray<z.ZodString>;
134
+ axis: z.ZodEnum<{
135
+ x: "x";
136
+ y: "y";
137
+ }>;
138
+ edge: z.ZodEnum<{
139
+ start: "start";
140
+ center: "center";
141
+ end: "end";
142
+ }>;
143
+ id: z.ZodString;
144
+ tolerance: z.ZodDefault<z.ZodNumber>;
145
+ pixelAware: z.ZodOptional<z.ZodBoolean>;
146
+ }, z.core.$strict>, z.ZodObject<{
147
+ type: z.ZodLiteral<"gap">;
148
+ first: z.ZodString;
149
+ second: z.ZodString;
150
+ axis: z.ZodEnum<{
151
+ x: "x";
152
+ y: "y";
153
+ }>;
154
+ value: z.ZodNumber;
155
+ id: z.ZodString;
156
+ tolerance: z.ZodDefault<z.ZodNumber>;
157
+ pixelAware: z.ZodOptional<z.ZodBoolean>;
158
+ }, z.core.$strict>, z.ZodObject<{
159
+ type: z.ZodLiteral<"insideSafeArea">;
160
+ elementId: z.ZodString;
161
+ id: z.ZodString;
162
+ tolerance: z.ZodDefault<z.ZodNumber>;
163
+ pixelAware: z.ZodOptional<z.ZodBoolean>;
164
+ }, z.core.$strict>, z.ZodObject<{
165
+ type: z.ZodLiteral<"disjoint">;
166
+ first: z.ZodString;
167
+ second: z.ZodString;
168
+ id: z.ZodString;
169
+ tolerance: z.ZodDefault<z.ZodNumber>;
170
+ pixelAware: z.ZodOptional<z.ZodBoolean>;
171
+ }, z.core.$strict>], "type">>>;
172
+ scenarioId: z.ZodString;
173
+ profile: z.ZodObject<{
174
+ window: z.ZodObject<{
175
+ width: z.ZodNumber;
176
+ height: z.ZodNumber;
177
+ }, z.core.$strict>;
178
+ pixelRatio: z.ZodNumber;
179
+ fontScale: z.ZodNumber;
180
+ insets: z.ZodObject<{
181
+ top: z.ZodNumber;
182
+ right: z.ZodNumber;
183
+ bottom: z.ZodNumber;
184
+ left: z.ZodNumber;
185
+ }, z.core.$strict>;
186
+ root: z.ZodObject<{
187
+ x: z.ZodNumber;
188
+ y: z.ZodNumber;
189
+ width: z.ZodNumber;
190
+ height: z.ZodNumber;
191
+ }, z.core.$strict>;
192
+ orientation: z.ZodEnum<{
193
+ portrait: "portrait";
194
+ landscape: "landscape";
195
+ }>;
196
+ }, z.core.$strict>;
197
+ tolerance: z.ZodDefault<z.ZodNumber>;
198
+ }, z.core.$strict>], "kind">;
199
+ export type DesignIntent = z.infer<typeof DesignIntentSchema>;
200
+ export declare const DesignIntentResultSchema: z.ZodObject<{
201
+ spec: z.ZodObject<{
202
+ schemaVersion: z.ZodLiteral<1>;
203
+ scenarioId: z.ZodString;
204
+ profile: z.ZodObject<{
205
+ window: z.ZodObject<{
206
+ width: z.ZodNumber;
207
+ height: z.ZodNumber;
208
+ }, z.core.$strict>;
209
+ pixelRatio: z.ZodNumber;
210
+ fontScale: z.ZodNumber;
211
+ insets: z.ZodObject<{
212
+ top: z.ZodNumber;
213
+ right: z.ZodNumber;
214
+ bottom: z.ZodNumber;
215
+ left: z.ZodNumber;
216
+ }, z.core.$strict>;
217
+ root: z.ZodObject<{
218
+ x: z.ZodNumber;
219
+ y: z.ZodNumber;
220
+ width: z.ZodNumber;
221
+ height: z.ZodNumber;
222
+ }, z.core.$strict>;
223
+ orientation: z.ZodEnum<{
224
+ portrait: "portrait";
225
+ landscape: "landscape";
226
+ }>;
227
+ }, z.core.$strict>;
228
+ requiredElementIds: z.ZodArray<z.ZodString>;
229
+ constraints: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
230
+ type: z.ZodLiteral<"textFits">;
231
+ elementId: z.ZodString;
232
+ id: z.ZodString;
233
+ tolerance: z.ZodDefault<z.ZodNumber>;
234
+ pixelAware: z.ZodOptional<z.ZodBoolean>;
235
+ }, z.core.$strict>, z.ZodObject<{
236
+ type: z.ZodLiteral<"rect">;
237
+ elementId: z.ZodString;
238
+ target: z.ZodObject<{
239
+ x: z.ZodNumber;
240
+ y: z.ZodNumber;
241
+ width: z.ZodNumber;
242
+ height: z.ZodNumber;
243
+ }, z.core.$strict>;
244
+ id: z.ZodString;
245
+ tolerance: z.ZodDefault<z.ZodNumber>;
246
+ pixelAware: z.ZodOptional<z.ZodBoolean>;
247
+ }, z.core.$strict>, z.ZodObject<{
248
+ type: z.ZodLiteral<"minTouchTarget">;
249
+ elementId: z.ZodString;
250
+ width: z.ZodDefault<z.ZodNumber>;
251
+ height: z.ZodDefault<z.ZodNumber>;
252
+ id: z.ZodString;
253
+ tolerance: z.ZodDefault<z.ZodNumber>;
254
+ pixelAware: z.ZodOptional<z.ZodBoolean>;
255
+ }, z.core.$strict>, z.ZodObject<{
256
+ type: z.ZodLiteral<"align">;
257
+ elementIds: z.ZodArray<z.ZodString>;
258
+ axis: z.ZodEnum<{
259
+ x: "x";
260
+ y: "y";
261
+ }>;
262
+ edge: z.ZodEnum<{
263
+ start: "start";
264
+ center: "center";
265
+ end: "end";
266
+ }>;
267
+ id: z.ZodString;
268
+ tolerance: z.ZodDefault<z.ZodNumber>;
269
+ pixelAware: z.ZodOptional<z.ZodBoolean>;
270
+ }, z.core.$strict>, z.ZodObject<{
271
+ type: z.ZodLiteral<"gap">;
272
+ first: z.ZodString;
273
+ second: z.ZodString;
274
+ axis: z.ZodEnum<{
275
+ x: "x";
276
+ y: "y";
277
+ }>;
278
+ value: z.ZodNumber;
279
+ id: z.ZodString;
280
+ tolerance: z.ZodDefault<z.ZodNumber>;
281
+ pixelAware: z.ZodOptional<z.ZodBoolean>;
282
+ }, z.core.$strict>, z.ZodObject<{
283
+ type: z.ZodLiteral<"insideSafeArea">;
284
+ elementId: z.ZodString;
285
+ id: z.ZodString;
286
+ tolerance: z.ZodDefault<z.ZodNumber>;
287
+ pixelAware: z.ZodOptional<z.ZodBoolean>;
288
+ }, z.core.$strict>, z.ZodObject<{
289
+ type: z.ZodLiteral<"disjoint">;
290
+ first: z.ZodString;
291
+ second: z.ZodString;
292
+ id: z.ZodString;
293
+ tolerance: z.ZodDefault<z.ZodNumber>;
294
+ pixelAware: z.ZodOptional<z.ZodBoolean>;
295
+ }, z.core.$strict>], "type">>;
296
+ }, z.core.$strict>;
297
+ reviewRequired: z.ZodLiteral<true>;
298
+ source: z.ZodEnum<{
299
+ "figma-auto-layout": "figma-auto-layout";
300
+ "reference-annotations": "reference-annotations";
301
+ }>;
302
+ notes: z.ZodArray<z.ZodString>;
303
+ }, z.core.$strict>;
304
+ export type DesignIntentResult = z.infer<typeof DesignIntentResultSchema>;
package/dist/design.js ADDED
@@ -0,0 +1,29 @@
1
+ import { z } from 'zod';
2
+ import { DeviceProfileSchema, RectSchema } from './geometry.js';
3
+ import { ConstraintSchema, WireframeSpecSchema } from './constraints.js';
4
+ /** Each nested Figma node is validated independently by the bounded importer. */
5
+ export const FigmaNodeSchema = z.object({
6
+ id: z.string().min(1), type: z.string(), name: z.string().optional(),
7
+ absoluteBoundingBox: RectSchema.optional(),
8
+ layoutMode: z.enum(['NONE', 'HORIZONTAL', 'VERTICAL']).optional(),
9
+ itemSpacing: z.number().finite().optional(),
10
+ counterAxisAlignItems: z.enum(['MIN', 'CENTER', 'MAX', 'BASELINE']).optional(),
11
+ children: z.array(z.unknown()).max(10000).optional(),
12
+ }).passthrough();
13
+ const common = { scenarioId: z.string().min(1), profile: DeviceProfileSchema, tolerance: z.number().finite().nonnegative().default(2) };
14
+ export const DesignIntentSchema = z.discriminatedUnion('kind', [
15
+ z.object({ ...common, kind: z.literal('figma-auto-layout'), frame: FigmaNodeSchema,
16
+ elementMap: z.record(z.string(), z.string().min(1)),
17
+ logicalUnitsPerDesignUnit: z.number().finite().positive().default(1),
18
+ }).strict(),
19
+ z.object({ ...common, kind: z.literal('reference-annotations'),
20
+ image: z.object({ sha256: z.string().regex(/^[a-f0-9]{64}$/), width: z.number().finite().positive(), height: z.number().finite().positive() }).strict(),
21
+ appRootPixels: RectSchema, pixelsPerLogicalUnit: z.number().finite().positive(),
22
+ annotations: z.array(z.object({ elementId: z.string().min(1), rectPixels: RectSchema }).strict()).min(1).max(10000),
23
+ assertions: z.array(ConstraintSchema).default([]),
24
+ }).strict(),
25
+ ]);
26
+ export const DesignIntentResultSchema = z.object({
27
+ spec: WireframeSpecSchema, reviewRequired: z.literal(true),
28
+ source: z.enum(['figma-auto-layout', 'reference-annotations']), notes: z.array(z.string()),
29
+ }).strict();