@json-render/core 0.1.0 → 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.
- package/LICENSE +201 -0
- package/dist/index.d.mts +54 -228
- package/dist/index.d.ts +54 -228
- package/dist/index.js +68 -24
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +68 -24
- package/dist/index.mjs.map +1 -1
- package/package.json +11 -11
package/dist/index.d.ts
CHANGED
|
@@ -21,34 +21,18 @@ type DynamicBoolean = DynamicValue<boolean>;
|
|
|
21
21
|
/**
|
|
22
22
|
* Zod schema for dynamic values
|
|
23
23
|
*/
|
|
24
|
-
declare const DynamicValueSchema: z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodObject<{
|
|
24
|
+
declare const DynamicValueSchema: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodObject<{
|
|
25
25
|
path: z.ZodString;
|
|
26
|
-
},
|
|
27
|
-
|
|
28
|
-
}, {
|
|
29
|
-
path: string;
|
|
30
|
-
}>]>;
|
|
31
|
-
declare const DynamicStringSchema: z.ZodUnion<[z.ZodString, z.ZodObject<{
|
|
26
|
+
}, z.core.$strip>]>;
|
|
27
|
+
declare const DynamicStringSchema: z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
32
28
|
path: z.ZodString;
|
|
33
|
-
},
|
|
34
|
-
|
|
35
|
-
}, {
|
|
36
|
-
path: string;
|
|
37
|
-
}>]>;
|
|
38
|
-
declare const DynamicNumberSchema: z.ZodUnion<[z.ZodNumber, z.ZodObject<{
|
|
29
|
+
}, z.core.$strip>]>;
|
|
30
|
+
declare const DynamicNumberSchema: z.ZodUnion<readonly [z.ZodNumber, z.ZodObject<{
|
|
39
31
|
path: z.ZodString;
|
|
40
|
-
},
|
|
41
|
-
|
|
42
|
-
}, {
|
|
43
|
-
path: string;
|
|
44
|
-
}>]>;
|
|
45
|
-
declare const DynamicBooleanSchema: z.ZodUnion<[z.ZodBoolean, z.ZodObject<{
|
|
32
|
+
}, z.core.$strip>]>;
|
|
33
|
+
declare const DynamicBooleanSchema: z.ZodUnion<readonly [z.ZodBoolean, z.ZodObject<{
|
|
46
34
|
path: z.ZodString;
|
|
47
|
-
},
|
|
48
|
-
path: string;
|
|
49
|
-
}, {
|
|
50
|
-
path: string;
|
|
51
|
-
}>]>;
|
|
35
|
+
}, z.core.$strip>]>;
|
|
52
36
|
/**
|
|
53
37
|
* Base UI element structure for v2
|
|
54
38
|
*/
|
|
@@ -72,7 +56,7 @@ interface UIElement<T extends string = string, P = Record<string, unknown>> {
|
|
|
72
56
|
type VisibilityCondition = boolean | {
|
|
73
57
|
path: string;
|
|
74
58
|
} | {
|
|
75
|
-
auth:
|
|
59
|
+
auth: "signedIn" | "signedOut";
|
|
76
60
|
} | LogicExpression;
|
|
77
61
|
/**
|
|
78
62
|
* Logic expression for complex conditions
|
|
@@ -125,11 +109,11 @@ type ComponentSchema = z.ZodType<Record<string, unknown>>;
|
|
|
125
109
|
/**
|
|
126
110
|
* Validation mode for catalog validation
|
|
127
111
|
*/
|
|
128
|
-
type ValidationMode =
|
|
112
|
+
type ValidationMode = "strict" | "warn" | "ignore";
|
|
129
113
|
/**
|
|
130
114
|
* JSON patch operation types
|
|
131
115
|
*/
|
|
132
|
-
type PatchOp =
|
|
116
|
+
type PatchOp = "add" | "remove" | "replace" | "set";
|
|
133
117
|
/**
|
|
134
118
|
* JSON patch operation
|
|
135
119
|
*/
|
|
@@ -221,7 +205,7 @@ interface ActionConfirm {
|
|
|
221
205
|
message: string;
|
|
222
206
|
confirmLabel?: string;
|
|
223
207
|
cancelLabel?: string;
|
|
224
|
-
variant?:
|
|
208
|
+
variant?: "default" | "danger";
|
|
225
209
|
}
|
|
226
210
|
/**
|
|
227
211
|
* Action success handler
|
|
@@ -264,170 +248,60 @@ declare const ActionConfirmSchema: z.ZodObject<{
|
|
|
264
248
|
message: z.ZodString;
|
|
265
249
|
confirmLabel: z.ZodOptional<z.ZodString>;
|
|
266
250
|
cancelLabel: z.ZodOptional<z.ZodString>;
|
|
267
|
-
variant: z.ZodOptional<z.ZodEnum<
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
cancelLabel?: string | undefined;
|
|
273
|
-
variant?: "default" | "danger" | undefined;
|
|
274
|
-
}, {
|
|
275
|
-
message: string;
|
|
276
|
-
title: string;
|
|
277
|
-
confirmLabel?: string | undefined;
|
|
278
|
-
cancelLabel?: string | undefined;
|
|
279
|
-
variant?: "default" | "danger" | undefined;
|
|
280
|
-
}>;
|
|
251
|
+
variant: z.ZodOptional<z.ZodEnum<{
|
|
252
|
+
default: "default";
|
|
253
|
+
danger: "danger";
|
|
254
|
+
}>>;
|
|
255
|
+
}, z.core.$strip>;
|
|
281
256
|
/**
|
|
282
257
|
* Schema for success handlers
|
|
283
258
|
*/
|
|
284
|
-
declare const ActionOnSuccessSchema: z.ZodUnion<[z.ZodObject<{
|
|
259
|
+
declare const ActionOnSuccessSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
285
260
|
navigate: z.ZodString;
|
|
286
|
-
},
|
|
287
|
-
navigate: string;
|
|
288
|
-
}, {
|
|
289
|
-
navigate: string;
|
|
290
|
-
}>, z.ZodObject<{
|
|
261
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
291
262
|
set: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
292
|
-
},
|
|
293
|
-
set: Record<string, unknown>;
|
|
294
|
-
}, {
|
|
295
|
-
set: Record<string, unknown>;
|
|
296
|
-
}>, z.ZodObject<{
|
|
263
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
297
264
|
action: z.ZodString;
|
|
298
|
-
},
|
|
299
|
-
action: string;
|
|
300
|
-
}, {
|
|
301
|
-
action: string;
|
|
302
|
-
}>]>;
|
|
265
|
+
}, z.core.$strip>]>;
|
|
303
266
|
/**
|
|
304
267
|
* Schema for error handlers
|
|
305
268
|
*/
|
|
306
|
-
declare const ActionOnErrorSchema: z.ZodUnion<[z.ZodObject<{
|
|
269
|
+
declare const ActionOnErrorSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
307
270
|
set: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
308
|
-
},
|
|
309
|
-
set: Record<string, unknown>;
|
|
310
|
-
}, {
|
|
311
|
-
set: Record<string, unknown>;
|
|
312
|
-
}>, z.ZodObject<{
|
|
271
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
313
272
|
action: z.ZodString;
|
|
314
|
-
},
|
|
315
|
-
action: string;
|
|
316
|
-
}, {
|
|
317
|
-
action: string;
|
|
318
|
-
}>]>;
|
|
273
|
+
}, z.core.$strip>]>;
|
|
319
274
|
/**
|
|
320
275
|
* Full action schema
|
|
321
276
|
*/
|
|
322
277
|
declare const ActionSchema: z.ZodObject<{
|
|
323
278
|
name: z.ZodString;
|
|
324
|
-
params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodObject<{
|
|
279
|
+
params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodObject<{
|
|
325
280
|
path: z.ZodString;
|
|
326
|
-
},
|
|
327
|
-
path: string;
|
|
328
|
-
}, {
|
|
329
|
-
path: string;
|
|
330
|
-
}>]>>>;
|
|
281
|
+
}, z.core.$strip>]>>>;
|
|
331
282
|
confirm: z.ZodOptional<z.ZodObject<{
|
|
332
283
|
title: z.ZodString;
|
|
333
284
|
message: z.ZodString;
|
|
334
285
|
confirmLabel: z.ZodOptional<z.ZodString>;
|
|
335
286
|
cancelLabel: z.ZodOptional<z.ZodString>;
|
|
336
|
-
variant: z.ZodOptional<z.ZodEnum<
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
variant?: "default" | "danger" | undefined;
|
|
343
|
-
}, {
|
|
344
|
-
message: string;
|
|
345
|
-
title: string;
|
|
346
|
-
confirmLabel?: string | undefined;
|
|
347
|
-
cancelLabel?: string | undefined;
|
|
348
|
-
variant?: "default" | "danger" | undefined;
|
|
349
|
-
}>>;
|
|
350
|
-
onSuccess: z.ZodOptional<z.ZodUnion<[z.ZodObject<{
|
|
287
|
+
variant: z.ZodOptional<z.ZodEnum<{
|
|
288
|
+
default: "default";
|
|
289
|
+
danger: "danger";
|
|
290
|
+
}>>;
|
|
291
|
+
}, z.core.$strip>>;
|
|
292
|
+
onSuccess: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
351
293
|
navigate: z.ZodString;
|
|
352
|
-
},
|
|
353
|
-
navigate: string;
|
|
354
|
-
}, {
|
|
355
|
-
navigate: string;
|
|
356
|
-
}>, z.ZodObject<{
|
|
294
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
357
295
|
set: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
358
|
-
},
|
|
359
|
-
set: Record<string, unknown>;
|
|
360
|
-
}, {
|
|
361
|
-
set: Record<string, unknown>;
|
|
362
|
-
}>, z.ZodObject<{
|
|
296
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
363
297
|
action: z.ZodString;
|
|
364
|
-
},
|
|
365
|
-
|
|
366
|
-
}, {
|
|
367
|
-
action: string;
|
|
368
|
-
}>]>>;
|
|
369
|
-
onError: z.ZodOptional<z.ZodUnion<[z.ZodObject<{
|
|
298
|
+
}, z.core.$strip>]>>;
|
|
299
|
+
onError: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
370
300
|
set: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
371
|
-
},
|
|
372
|
-
set: Record<string, unknown>;
|
|
373
|
-
}, {
|
|
374
|
-
set: Record<string, unknown>;
|
|
375
|
-
}>, z.ZodObject<{
|
|
301
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
376
302
|
action: z.ZodString;
|
|
377
|
-
},
|
|
378
|
-
|
|
379
|
-
}, {
|
|
380
|
-
action: string;
|
|
381
|
-
}>]>>;
|
|
382
|
-
}, "strip", z.ZodTypeAny, {
|
|
383
|
-
name: string;
|
|
384
|
-
params?: Record<string, string | number | boolean | {
|
|
385
|
-
path: string;
|
|
386
|
-
} | null> | undefined;
|
|
387
|
-
confirm?: {
|
|
388
|
-
message: string;
|
|
389
|
-
title: string;
|
|
390
|
-
confirmLabel?: string | undefined;
|
|
391
|
-
cancelLabel?: string | undefined;
|
|
392
|
-
variant?: "default" | "danger" | undefined;
|
|
393
|
-
} | undefined;
|
|
394
|
-
onSuccess?: {
|
|
395
|
-
navigate: string;
|
|
396
|
-
} | {
|
|
397
|
-
set: Record<string, unknown>;
|
|
398
|
-
} | {
|
|
399
|
-
action: string;
|
|
400
|
-
} | undefined;
|
|
401
|
-
onError?: {
|
|
402
|
-
set: Record<string, unknown>;
|
|
403
|
-
} | {
|
|
404
|
-
action: string;
|
|
405
|
-
} | undefined;
|
|
406
|
-
}, {
|
|
407
|
-
name: string;
|
|
408
|
-
params?: Record<string, string | number | boolean | {
|
|
409
|
-
path: string;
|
|
410
|
-
} | null> | undefined;
|
|
411
|
-
confirm?: {
|
|
412
|
-
message: string;
|
|
413
|
-
title: string;
|
|
414
|
-
confirmLabel?: string | undefined;
|
|
415
|
-
cancelLabel?: string | undefined;
|
|
416
|
-
variant?: "default" | "danger" | undefined;
|
|
417
|
-
} | undefined;
|
|
418
|
-
onSuccess?: {
|
|
419
|
-
navigate: string;
|
|
420
|
-
} | {
|
|
421
|
-
set: Record<string, unknown>;
|
|
422
|
-
} | {
|
|
423
|
-
action: string;
|
|
424
|
-
} | undefined;
|
|
425
|
-
onError?: {
|
|
426
|
-
set: Record<string, unknown>;
|
|
427
|
-
} | {
|
|
428
|
-
action: string;
|
|
429
|
-
} | undefined;
|
|
430
|
-
}>;
|
|
303
|
+
}, z.core.$strip>]>>;
|
|
304
|
+
}, z.core.$strip>;
|
|
431
305
|
/**
|
|
432
306
|
* Action handler function signature
|
|
433
307
|
*/
|
|
@@ -508,7 +382,7 @@ interface ValidationConfig {
|
|
|
508
382
|
/** Array of checks to run */
|
|
509
383
|
checks?: ValidationCheck[];
|
|
510
384
|
/** When to run validation */
|
|
511
|
-
validateOn?:
|
|
385
|
+
validateOn?: "change" | "blur" | "submit";
|
|
512
386
|
/** Condition for when validation is enabled */
|
|
513
387
|
enabled?: LogicExpression;
|
|
514
388
|
}
|
|
@@ -517,77 +391,29 @@ interface ValidationConfig {
|
|
|
517
391
|
*/
|
|
518
392
|
declare const ValidationCheckSchema: z.ZodObject<{
|
|
519
393
|
fn: z.ZodString;
|
|
520
|
-
args: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodObject<{
|
|
394
|
+
args: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodObject<{
|
|
521
395
|
path: z.ZodString;
|
|
522
|
-
},
|
|
523
|
-
path: string;
|
|
524
|
-
}, {
|
|
525
|
-
path: string;
|
|
526
|
-
}>]>>>;
|
|
396
|
+
}, z.core.$strip>]>>>;
|
|
527
397
|
message: z.ZodString;
|
|
528
|
-
},
|
|
529
|
-
message: string;
|
|
530
|
-
fn: string;
|
|
531
|
-
args?: Record<string, string | number | boolean | {
|
|
532
|
-
path: string;
|
|
533
|
-
} | null> | undefined;
|
|
534
|
-
}, {
|
|
535
|
-
message: string;
|
|
536
|
-
fn: string;
|
|
537
|
-
args?: Record<string, string | number | boolean | {
|
|
538
|
-
path: string;
|
|
539
|
-
} | null> | undefined;
|
|
540
|
-
}>;
|
|
398
|
+
}, z.core.$strip>;
|
|
541
399
|
/**
|
|
542
400
|
* Schema for validation config
|
|
543
401
|
*/
|
|
544
402
|
declare const ValidationConfigSchema: z.ZodObject<{
|
|
545
403
|
checks: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
546
404
|
fn: z.ZodString;
|
|
547
|
-
args: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodObject<{
|
|
405
|
+
args: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodObject<{
|
|
548
406
|
path: z.ZodString;
|
|
549
|
-
},
|
|
550
|
-
path: string;
|
|
551
|
-
}, {
|
|
552
|
-
path: string;
|
|
553
|
-
}>]>>>;
|
|
407
|
+
}, z.core.$strip>]>>>;
|
|
554
408
|
message: z.ZodString;
|
|
555
|
-
},
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
fn: string;
|
|
564
|
-
args?: Record<string, string | number | boolean | {
|
|
565
|
-
path: string;
|
|
566
|
-
} | null> | undefined;
|
|
567
|
-
}>, "many">>;
|
|
568
|
-
validateOn: z.ZodOptional<z.ZodEnum<["change", "blur", "submit"]>>;
|
|
569
|
-
enabled: z.ZodOptional<z.ZodType<LogicExpression, z.ZodTypeDef, LogicExpression>>;
|
|
570
|
-
}, "strip", z.ZodTypeAny, {
|
|
571
|
-
checks?: {
|
|
572
|
-
message: string;
|
|
573
|
-
fn: string;
|
|
574
|
-
args?: Record<string, string | number | boolean | {
|
|
575
|
-
path: string;
|
|
576
|
-
} | null> | undefined;
|
|
577
|
-
}[] | undefined;
|
|
578
|
-
validateOn?: "change" | "blur" | "submit" | undefined;
|
|
579
|
-
enabled?: LogicExpression | undefined;
|
|
580
|
-
}, {
|
|
581
|
-
checks?: {
|
|
582
|
-
message: string;
|
|
583
|
-
fn: string;
|
|
584
|
-
args?: Record<string, string | number | boolean | {
|
|
585
|
-
path: string;
|
|
586
|
-
} | null> | undefined;
|
|
587
|
-
}[] | undefined;
|
|
588
|
-
validateOn?: "change" | "blur" | "submit" | undefined;
|
|
589
|
-
enabled?: LogicExpression | undefined;
|
|
590
|
-
}>;
|
|
409
|
+
}, z.core.$strip>>>;
|
|
410
|
+
validateOn: z.ZodOptional<z.ZodEnum<{
|
|
411
|
+
change: "change";
|
|
412
|
+
blur: "blur";
|
|
413
|
+
submit: "submit";
|
|
414
|
+
}>>;
|
|
415
|
+
enabled: z.ZodOptional<z.ZodType<LogicExpression, unknown, z.core.$ZodTypeInternals<LogicExpression, unknown>>>;
|
|
416
|
+
}, z.core.$strip>;
|
|
591
417
|
/**
|
|
592
418
|
* Validation function signature
|
|
593
419
|
*/
|
|
@@ -740,7 +566,7 @@ declare function generateCatalogPrompt<TComponents extends Record<string, Compon
|
|
|
740
566
|
* Type helper to infer component props from catalog
|
|
741
567
|
*/
|
|
742
568
|
type InferCatalogComponentProps<C extends Catalog<Record<string, ComponentDefinition>>> = {
|
|
743
|
-
[K in keyof C[
|
|
569
|
+
[K in keyof C["components"]]: z.infer<C["components"][K]["props"]>;
|
|
744
570
|
};
|
|
745
571
|
|
|
746
572
|
export { type Action, type ActionConfirm, ActionConfirmSchema, type ActionDefinition, type ActionExecutionContext, type ActionHandler, type ActionOnError, ActionOnErrorSchema, type ActionOnSuccess, ActionOnSuccessSchema, ActionSchema, type AuthState, type Catalog, type CatalogConfig, type ComponentDefinition, type ComponentSchema, type DataModel, type DynamicBoolean, DynamicBooleanSchema, type DynamicNumber, DynamicNumberSchema, type DynamicString, DynamicStringSchema, type DynamicValue, DynamicValueSchema, type InferCatalogComponentProps, type JsonPatch, type LogicExpression, LogicExpressionSchema, type PatchOp, type ResolvedAction, type UIElement, type UITree, type ValidationCheck, type ValidationCheckResult, ValidationCheckSchema, type ValidationConfig, ValidationConfigSchema, type ValidationContext, type ValidationFunction, type ValidationFunctionDefinition, type ValidationMode, type ValidationResult, type VisibilityCondition, VisibilityConditionSchema, type VisibilityContext, action, builtInValidationFunctions, check, createCatalog, evaluateLogicExpression, evaluateVisibility, executeAction, generateCatalogPrompt, getByPath, interpolateString, resolveAction, resolveDynamicValue, runValidation, runValidationCheck, setByPath, visibility };
|
package/dist/index.js
CHANGED
|
@@ -128,10 +128,18 @@ var LogicExpressionSchema = import_zod2.z.lazy(
|
|
|
128
128
|
import_zod2.z.object({ path: import_zod2.z.string() }),
|
|
129
129
|
import_zod2.z.object({ eq: import_zod2.z.tuple([DynamicValueSchema, DynamicValueSchema]) }),
|
|
130
130
|
import_zod2.z.object({ neq: import_zod2.z.tuple([DynamicValueSchema, DynamicValueSchema]) }),
|
|
131
|
-
import_zod2.z.object({
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
import_zod2.z.object({
|
|
131
|
+
import_zod2.z.object({
|
|
132
|
+
gt: import_zod2.z.tuple([DynamicNumberValueSchema, DynamicNumberValueSchema])
|
|
133
|
+
}),
|
|
134
|
+
import_zod2.z.object({
|
|
135
|
+
gte: import_zod2.z.tuple([DynamicNumberValueSchema, DynamicNumberValueSchema])
|
|
136
|
+
}),
|
|
137
|
+
import_zod2.z.object({
|
|
138
|
+
lt: import_zod2.z.tuple([DynamicNumberValueSchema, DynamicNumberValueSchema])
|
|
139
|
+
}),
|
|
140
|
+
import_zod2.z.object({
|
|
141
|
+
lte: import_zod2.z.tuple([DynamicNumberValueSchema, DynamicNumberValueSchema])
|
|
142
|
+
})
|
|
135
143
|
])
|
|
136
144
|
);
|
|
137
145
|
var VisibilityConditionSchema = import_zod2.z.union([
|
|
@@ -169,8 +177,14 @@ function evaluateLogicExpression(expr, ctx) {
|
|
|
169
177
|
}
|
|
170
178
|
if ("gt" in expr) {
|
|
171
179
|
const [left, right] = expr.gt;
|
|
172
|
-
const leftValue = resolveDynamicValue(
|
|
173
|
-
|
|
180
|
+
const leftValue = resolveDynamicValue(
|
|
181
|
+
left,
|
|
182
|
+
dataModel
|
|
183
|
+
);
|
|
184
|
+
const rightValue = resolveDynamicValue(
|
|
185
|
+
right,
|
|
186
|
+
dataModel
|
|
187
|
+
);
|
|
174
188
|
if (typeof leftValue === "number" && typeof rightValue === "number") {
|
|
175
189
|
return leftValue > rightValue;
|
|
176
190
|
}
|
|
@@ -178,8 +192,14 @@ function evaluateLogicExpression(expr, ctx) {
|
|
|
178
192
|
}
|
|
179
193
|
if ("gte" in expr) {
|
|
180
194
|
const [left, right] = expr.gte;
|
|
181
|
-
const leftValue = resolveDynamicValue(
|
|
182
|
-
|
|
195
|
+
const leftValue = resolveDynamicValue(
|
|
196
|
+
left,
|
|
197
|
+
dataModel
|
|
198
|
+
);
|
|
199
|
+
const rightValue = resolveDynamicValue(
|
|
200
|
+
right,
|
|
201
|
+
dataModel
|
|
202
|
+
);
|
|
183
203
|
if (typeof leftValue === "number" && typeof rightValue === "number") {
|
|
184
204
|
return leftValue >= rightValue;
|
|
185
205
|
}
|
|
@@ -187,8 +207,14 @@ function evaluateLogicExpression(expr, ctx) {
|
|
|
187
207
|
}
|
|
188
208
|
if ("lt" in expr) {
|
|
189
209
|
const [left, right] = expr.lt;
|
|
190
|
-
const leftValue = resolveDynamicValue(
|
|
191
|
-
|
|
210
|
+
const leftValue = resolveDynamicValue(
|
|
211
|
+
left,
|
|
212
|
+
dataModel
|
|
213
|
+
);
|
|
214
|
+
const rightValue = resolveDynamicValue(
|
|
215
|
+
right,
|
|
216
|
+
dataModel
|
|
217
|
+
);
|
|
192
218
|
if (typeof leftValue === "number" && typeof rightValue === "number") {
|
|
193
219
|
return leftValue < rightValue;
|
|
194
220
|
}
|
|
@@ -196,8 +222,14 @@ function evaluateLogicExpression(expr, ctx) {
|
|
|
196
222
|
}
|
|
197
223
|
if ("lte" in expr) {
|
|
198
224
|
const [left, right] = expr.lte;
|
|
199
|
-
const leftValue = resolveDynamicValue(
|
|
200
|
-
|
|
225
|
+
const leftValue = resolveDynamicValue(
|
|
226
|
+
left,
|
|
227
|
+
dataModel
|
|
228
|
+
);
|
|
229
|
+
const rightValue = resolveDynamicValue(
|
|
230
|
+
right,
|
|
231
|
+
dataModel
|
|
232
|
+
);
|
|
201
233
|
if (typeof leftValue === "number" && typeof rightValue === "number") {
|
|
202
234
|
return leftValue <= rightValue;
|
|
203
235
|
}
|
|
@@ -240,15 +272,23 @@ var visibility = {
|
|
|
240
272
|
/** Visible when signed out */
|
|
241
273
|
signedOut: { auth: "signedOut" },
|
|
242
274
|
/** AND multiple conditions */
|
|
243
|
-
and: (...conditions) => ({
|
|
275
|
+
and: (...conditions) => ({
|
|
276
|
+
and: conditions
|
|
277
|
+
}),
|
|
244
278
|
/** OR multiple conditions */
|
|
245
|
-
or: (...conditions) => ({
|
|
279
|
+
or: (...conditions) => ({
|
|
280
|
+
or: conditions
|
|
281
|
+
}),
|
|
246
282
|
/** NOT a condition */
|
|
247
283
|
not: (condition) => ({ not: condition }),
|
|
248
284
|
/** Equality check */
|
|
249
|
-
eq: (left, right) => ({
|
|
285
|
+
eq: (left, right) => ({
|
|
286
|
+
eq: [left, right]
|
|
287
|
+
}),
|
|
250
288
|
/** Not equal check */
|
|
251
|
-
neq: (left, right) => ({
|
|
289
|
+
neq: (left, right) => ({
|
|
290
|
+
neq: [left, right]
|
|
291
|
+
}),
|
|
252
292
|
/** Greater than */
|
|
253
293
|
gt: (left, right) => ({ gt: [left, right] }),
|
|
254
294
|
/** Greater than or equal */
|
|
@@ -270,16 +310,16 @@ var ActionConfirmSchema = import_zod3.z.object({
|
|
|
270
310
|
});
|
|
271
311
|
var ActionOnSuccessSchema = import_zod3.z.union([
|
|
272
312
|
import_zod3.z.object({ navigate: import_zod3.z.string() }),
|
|
273
|
-
import_zod3.z.object({ set: import_zod3.z.record(import_zod3.z.unknown()) }),
|
|
313
|
+
import_zod3.z.object({ set: import_zod3.z.record(import_zod3.z.string(), import_zod3.z.unknown()) }),
|
|
274
314
|
import_zod3.z.object({ action: import_zod3.z.string() })
|
|
275
315
|
]);
|
|
276
316
|
var ActionOnErrorSchema = import_zod3.z.union([
|
|
277
|
-
import_zod3.z.object({ set: import_zod3.z.record(import_zod3.z.unknown()) }),
|
|
317
|
+
import_zod3.z.object({ set: import_zod3.z.record(import_zod3.z.string(), import_zod3.z.unknown()) }),
|
|
278
318
|
import_zod3.z.object({ action: import_zod3.z.string() })
|
|
279
319
|
]);
|
|
280
320
|
var ActionSchema = import_zod3.z.object({
|
|
281
321
|
name: import_zod3.z.string(),
|
|
282
|
-
params: import_zod3.z.record(DynamicValueSchema).optional(),
|
|
322
|
+
params: import_zod3.z.record(import_zod3.z.string(), DynamicValueSchema).optional(),
|
|
283
323
|
confirm: ActionConfirmSchema.optional(),
|
|
284
324
|
onSuccess: ActionOnSuccessSchema.optional(),
|
|
285
325
|
onError: ActionOnErrorSchema.optional()
|
|
@@ -367,7 +407,7 @@ var action = {
|
|
|
367
407
|
var import_zod4 = require("zod");
|
|
368
408
|
var ValidationCheckSchema = import_zod4.z.object({
|
|
369
409
|
fn: import_zod4.z.string(),
|
|
370
|
-
args: import_zod4.z.record(DynamicValueSchema).optional(),
|
|
410
|
+
args: import_zod4.z.record(import_zod4.z.string(), DynamicValueSchema).optional(),
|
|
371
411
|
message: import_zod4.z.string()
|
|
372
412
|
});
|
|
373
413
|
var ValidationConfigSchema = import_zod4.z.object({
|
|
@@ -595,7 +635,7 @@ function createCatalog(config) {
|
|
|
595
635
|
elementSchema = import_zod5.z.object({
|
|
596
636
|
key: import_zod5.z.string(),
|
|
597
637
|
type: import_zod5.z.string(),
|
|
598
|
-
props: import_zod5.z.record(import_zod5.z.unknown()),
|
|
638
|
+
props: import_zod5.z.record(import_zod5.z.string(), import_zod5.z.unknown()),
|
|
599
639
|
children: import_zod5.z.array(import_zod5.z.string()).optional(),
|
|
600
640
|
parentKey: import_zod5.z.string().nullable().optional(),
|
|
601
641
|
visible: VisibilityConditionSchema.optional()
|
|
@@ -611,7 +651,7 @@ function createCatalog(config) {
|
|
|
611
651
|
}
|
|
612
652
|
const treeSchema = import_zod5.z.object({
|
|
613
653
|
root: import_zod5.z.string(),
|
|
614
|
-
elements: import_zod5.z.record(elementSchema)
|
|
654
|
+
elements: import_zod5.z.record(import_zod5.z.string(), elementSchema)
|
|
615
655
|
});
|
|
616
656
|
return {
|
|
617
657
|
name,
|
|
@@ -669,7 +709,9 @@ function generateCatalogPrompt(catalog) {
|
|
|
669
709
|
lines.push("");
|
|
670
710
|
for (const name of catalog.actionNames) {
|
|
671
711
|
const def = catalog.actions[name];
|
|
672
|
-
lines.push(
|
|
712
|
+
lines.push(
|
|
713
|
+
`- \`${String(name)}\`${def.description ? `: ${def.description}` : ""}`
|
|
714
|
+
);
|
|
673
715
|
}
|
|
674
716
|
lines.push("");
|
|
675
717
|
}
|
|
@@ -686,7 +728,9 @@ function generateCatalogPrompt(catalog) {
|
|
|
686
728
|
lines.push("");
|
|
687
729
|
lines.push("## Validation Functions");
|
|
688
730
|
lines.push("");
|
|
689
|
-
lines.push(
|
|
731
|
+
lines.push(
|
|
732
|
+
"Built-in: `required`, `email`, `minLength`, `maxLength`, `pattern`, `min`, `max`, `url`"
|
|
733
|
+
);
|
|
690
734
|
if (catalog.functionNames.length > 0) {
|
|
691
735
|
lines.push(`Custom: ${catalog.functionNames.map(String).join(", ")}`);
|
|
692
736
|
}
|