@stndrds/schema 1.0.0-alpha.95 → 1.0.0-alpha.97

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.
Files changed (137) hide show
  1. package/dist/attributes-C-bhC0k5.d.ts +673 -0
  2. package/dist/attributes-DB76JqXm.d.mts +673 -0
  3. package/dist/chunk-2TEWGEUI.js +212 -0
  4. package/dist/chunk-4RGFTMQR.mjs +8 -0
  5. package/dist/chunk-5TLM4QXO.mjs +8 -0
  6. package/dist/chunk-67PQMHQA.mjs +199 -0
  7. package/dist/chunk-6HHSX6LP.js +64 -0
  8. package/dist/chunk-AHPXNPJC.js +105 -0
  9. package/dist/chunk-BEN6TE7Y.js +11 -0
  10. package/dist/chunk-BH3RPSC5.js +22 -0
  11. package/dist/chunk-BIQ35DLC.mjs +78 -0
  12. package/dist/chunk-CKZHFJQT.js +16 -0
  13. package/dist/chunk-E6XO2STS.js +11 -11
  14. package/dist/chunk-EIWGW2ML.mjs +99 -0
  15. package/dist/chunk-EKG35CSO.mjs +1 -0
  16. package/dist/chunk-IMEPIVTR.js +217 -0
  17. package/dist/chunk-J4ORNCAH.js +10 -0
  18. package/dist/chunk-KC4F3HB7.js +32 -0
  19. package/dist/chunk-LHXE7LLD.js +28 -0
  20. package/dist/chunk-MD6XGXTU.mjs +18 -0
  21. package/dist/chunk-N47XKY4R.js +14 -0
  22. package/dist/chunk-NXXSNUDI.mjs +8 -0
  23. package/dist/chunk-PKG3E5MW.mjs +18 -0
  24. package/dist/chunk-PZT3CIHD.mjs +192 -0
  25. package/dist/chunk-QL3UGPUG.mjs +60 -0
  26. package/dist/chunk-QY65ZSBL.js +16 -0
  27. package/dist/chunk-R6JFUC32.js +2 -0
  28. package/dist/chunk-RDXQ4CYT.mjs +9 -0
  29. package/dist/chunk-S5VJ2FZE.js +12 -0
  30. package/dist/chunk-SVII65W7.mjs +14 -0
  31. package/dist/chunk-U7VN3RUE.mjs +25 -0
  32. package/dist/chunk-VCPYYLCS.js +83 -0
  33. package/dist/chunk-VD3P2A6Q.js +10 -0
  34. package/dist/chunk-VPEV3W34.mjs +10 -0
  35. package/dist/chunk-WGFQMQMV.mjs +14 -0
  36. package/dist/chunk-X6VDDXG7.mjs +12 -0
  37. package/dist/chunk-XAORXFAX.mjs +1 -10
  38. package/dist/chunk-XEOG24K6.mjs +8 -0
  39. package/dist/chunk-XK6XC3V4.js +10 -0
  40. package/dist/chunk-XZ5B5MTG.js +20 -0
  41. package/dist/chunk-YKHC2AW6.js +10 -0
  42. package/dist/chunk-Z2T7ONKU.js +20 -0
  43. package/dist/chunk-ZFL7DXAE.mjs +28 -0
  44. package/dist/chunk-ZM7W2ZCF.mjs +20 -0
  45. package/dist/{validators-5XMwJOlV.d.ts → index-Bt-0XNSh.d.ts} +14 -1499
  46. package/dist/{validators-BCw4Sn01.d.mts → index-C9tOwUbK.d.mts} +14 -1499
  47. package/dist/index.d.mts +1267 -976
  48. package/dist/index.d.ts +1267 -976
  49. package/dist/index.js +1293 -1001
  50. package/dist/index.mjs +529 -785
  51. package/dist/types-B7nS2D1A.d.ts +39 -0
  52. package/dist/types-CjXbGsy8.d.mts +39 -0
  53. package/dist/utils.js +38 -20
  54. package/dist/utils.mjs +1 -20
  55. package/dist/validation/all.d.mts +23 -0
  56. package/dist/validation/all.d.ts +23 -0
  57. package/dist/validation/all.js +265 -0
  58. package/dist/validation/all.mjs +20 -0
  59. package/dist/validation/complex/currency.d.mts +15 -0
  60. package/dist/validation/complex/currency.d.ts +15 -0
  61. package/dist/validation/complex/currency.js +12 -0
  62. package/dist/validation/complex/currency.mjs +3 -0
  63. package/dist/validation/complex/file.d.mts +13 -0
  64. package/dist/validation/complex/file.d.ts +13 -0
  65. package/dist/validation/complex/file.js +12 -0
  66. package/dist/validation/complex/file.mjs +3 -0
  67. package/dist/validation/complex/location.d.mts +22 -0
  68. package/dist/validation/complex/location.d.ts +22 -0
  69. package/dist/validation/complex/location.js +12 -0
  70. package/dist/validation/complex/location.mjs +3 -0
  71. package/dist/validation/complex/phone.d.mts +22 -0
  72. package/dist/validation/complex/phone.d.ts +22 -0
  73. package/dist/validation/complex/phone.js +12 -0
  74. package/dist/validation/complex/phone.mjs +3 -0
  75. package/dist/validation/complex/relation.d.mts +25 -0
  76. package/dist/validation/complex/relation.d.ts +25 -0
  77. package/dist/validation/complex/relation.js +20 -0
  78. package/dist/validation/complex/relation.mjs +3 -0
  79. package/dist/validation/complex/richtext.d.mts +13 -0
  80. package/dist/validation/complex/richtext.d.ts +13 -0
  81. package/dist/validation/complex/richtext.js +12 -0
  82. package/dist/validation/complex/richtext.mjs +3 -0
  83. package/dist/validation/complex/select.d.mts +20 -0
  84. package/dist/validation/complex/select.d.ts +20 -0
  85. package/dist/validation/complex/select.js +20 -0
  86. package/dist/validation/complex/select.mjs +3 -0
  87. package/dist/validation/complex/user.d.mts +13 -0
  88. package/dist/validation/complex/user.d.ts +13 -0
  89. package/dist/validation/complex/user.js +12 -0
  90. package/dist/validation/complex/user.mjs +3 -0
  91. package/dist/validation/computed/formula.d.mts +14 -0
  92. package/dist/validation/computed/formula.d.ts +14 -0
  93. package/dist/validation/computed/formula.js +12 -0
  94. package/dist/validation/computed/formula.mjs +3 -0
  95. package/dist/validation/computed/rollup.d.mts +14 -0
  96. package/dist/validation/computed/rollup.d.ts +14 -0
  97. package/dist/validation/computed/rollup.js +12 -0
  98. package/dist/validation/computed/rollup.mjs +3 -0
  99. package/dist/validation/config/index.d.mts +421 -0
  100. package/dist/validation/config/index.d.ts +421 -0
  101. package/dist/validation/config/index.js +103 -0
  102. package/dist/validation/config/index.mjs +2 -0
  103. package/dist/validation/core/index.d.mts +85 -0
  104. package/dist/validation/core/index.d.ts +85 -0
  105. package/dist/validation/core/index.js +27 -0
  106. package/dist/validation/core/index.mjs +2 -0
  107. package/dist/validation/object/index.d.mts +6 -0
  108. package/dist/validation/object/index.d.ts +6 -0
  109. package/dist/validation/object/index.js +71 -0
  110. package/dist/validation/object/index.mjs +18 -0
  111. package/dist/validation/primitives/checkbox.d.mts +12 -0
  112. package/dist/validation/primitives/checkbox.d.ts +12 -0
  113. package/dist/validation/primitives/checkbox.js +12 -0
  114. package/dist/validation/primitives/checkbox.mjs +3 -0
  115. package/dist/validation/primitives/date.d.mts +12 -0
  116. package/dist/validation/primitives/date.d.ts +12 -0
  117. package/dist/validation/primitives/date.js +12 -0
  118. package/dist/validation/primitives/date.mjs +3 -0
  119. package/dist/validation/primitives/number.d.mts +12 -0
  120. package/dist/validation/primitives/number.d.ts +12 -0
  121. package/dist/validation/primitives/number.js +12 -0
  122. package/dist/validation/primitives/number.mjs +3 -0
  123. package/dist/validation/primitives/rating.d.mts +12 -0
  124. package/dist/validation/primitives/rating.d.ts +12 -0
  125. package/dist/validation/primitives/rating.js +12 -0
  126. package/dist/validation/primitives/rating.mjs +3 -0
  127. package/dist/validation/primitives/text.d.mts +17 -0
  128. package/dist/validation/primitives/text.d.ts +17 -0
  129. package/dist/validation/primitives/text.js +16 -0
  130. package/dist/validation/primitives/text.mjs +3 -0
  131. package/dist/validation/validators.d.mts +21 -2
  132. package/dist/validation/validators.d.ts +21 -2
  133. package/dist/validation/validators.js +265 -120
  134. package/dist/validation/validators.mjs +20 -120
  135. package/package.json +108 -5
  136. package/dist/chunk-4362R5F2.mjs +0 -780
  137. package/dist/chunk-7QUI6TSO.js +0 -780
package/dist/index.mjs CHANGED
@@ -1,77 +1,29 @@
1
- import {
2
- asTenantId,
3
- asUserId,
4
- deepEqual,
5
- generateId,
6
- generatePrefixedId,
7
- generateTemplateName,
8
- indexBy,
9
- slugify
10
- } from "./chunk-XAORXFAX.mjs";
11
- import {
12
- DEFAULT_VALIDATION_MESSAGES,
13
- attributeConfigSchemas,
14
- checkboxConfigSchema,
15
- computeRecordStatus,
16
- createAttributeValidator,
17
- createCheckboxValidator,
18
- createCurrencyValidator,
19
- createDateValidator,
20
- createDraftValidator,
21
- createFileValidator,
22
- createFormAttributeValidator,
23
- createFormulaValidator,
24
- createLocationValidator,
25
- createMultiRelationValidator,
26
- createMultiselectValidator,
27
- createNumberValidator,
28
- createObjectValidator,
29
- createPhoneValidator,
30
- createRatingValidator,
31
- createRelationValidator,
32
- createRichtextValidator,
33
- createRollupValidator,
34
- createSelectValidator,
35
- createSingleRelationValidator,
36
- createStatusValidator,
37
- createTextAreaValidator,
38
- createTextValidator,
39
- createUserValidator,
40
- currencyConfigSchema,
41
- dateConfigSchema,
42
- documentConfigSchema,
43
- fileConfigSchema,
44
- formatPhoneForDisplay,
45
- formatZodErrors,
46
- formulaConfigSchema,
47
- getAttributeConfigSchema,
48
- getMissingRequiredAttributes,
49
- isRecordComplete,
50
- locationConfigSchema,
51
- multiselectConfigSchema,
52
- normalizePhoneNumber,
53
- numberConfigSchema,
54
- parseAttributeConfig,
55
- parseRawPhoneInput,
56
- phoneConfigSchema,
57
- ratingConfigSchema,
58
- relationConfigSchema,
59
- richtextConfigSchema,
60
- rollupConfigSchema,
61
- safeParseAttributeConfig,
62
- selectConfigSchema,
63
- statusConfigSchema,
64
- textConfigSchema,
65
- textareaConfigSchema,
66
- userConfigSchema,
67
- validateAttribute,
68
- validateAttributeConfig,
69
- validateDraft,
70
- validateDraftOrThrow,
71
- validateObject,
72
- validateObjectOrThrow,
73
- validatePhoneNumber
74
- } from "./chunk-4362R5F2.mjs";
1
+ import { generateId } from './chunk-XAORXFAX.mjs';
2
+ export { asTenantId, asUserId, deepEqual, generateId, generatePrefixedId, generateTemplateName, indexBy, slugify } from './chunk-XAORXFAX.mjs';
3
+ import './chunk-EKG35CSO.mjs';
4
+ import { createObjectValidator, createAttributeValidator } from './chunk-67PQMHQA.mjs';
5
+ export { computeRecordStatus, createAttributeValidator, createDraftValidator, createFormAttributeValidator, createObjectValidator, getMissingRequiredAttributes, isRecordComplete, validateAttribute, validateDraft, validateDraftOrThrow, validateObject, validateObjectOrThrow } from './chunk-67PQMHQA.mjs';
6
+ export { createCheckboxValidator } from './chunk-5TLM4QXO.mjs';
7
+ export { createDateValidator } from './chunk-XEOG24K6.mjs';
8
+ export { createNumberValidator } from './chunk-PKG3E5MW.mjs';
9
+ export { createRatingValidator } from './chunk-X6VDDXG7.mjs';
10
+ export { createTextAreaValidator, createTextValidator } from './chunk-U7VN3RUE.mjs';
11
+ export { createMultiRelationValidator, createRelationValidator, createSingleRelationValidator } from './chunk-QL3UGPUG.mjs';
12
+ export { createRichtextValidator } from './chunk-VPEV3W34.mjs';
13
+ export { createMultiselectValidator, createSelectValidator, createStatusValidator } from './chunk-ZFL7DXAE.mjs';
14
+ export { createUserValidator } from './chunk-WGFQMQMV.mjs';
15
+ export { createFormulaValidator } from './chunk-4RGFTMQR.mjs';
16
+ export { createRollupValidator } from './chunk-NXXSNUDI.mjs';
17
+ export { attributeConfigSchemas, checkboxConfigSchema, currencyConfigSchema, dateConfigSchema, documentConfigSchema, fileConfigSchema, formulaConfigSchema, getAttributeConfigSchema, locationConfigSchema, multiselectConfigSchema, numberConfigSchema, parseAttributeConfig, phoneConfigSchema, ratingConfigSchema, relationConfigSchema, richtextConfigSchema, rollupConfigSchema, safeParseAttributeConfig, selectConfigSchema, statusConfigSchema, textConfigSchema, textareaConfigSchema, userConfigSchema, validateAttributeConfig } from './chunk-PZT3CIHD.mjs';
18
+ export { createCurrencyValidator } from './chunk-SVII65W7.mjs';
19
+ export { createFileValidator } from './chunk-MD6XGXTU.mjs';
20
+ export { createLocationValidator } from './chunk-ZM7W2ZCF.mjs';
21
+ import { formatPhoneForDisplay } from './chunk-EIWGW2ML.mjs';
22
+ export { createPhoneValidator, formatPhoneForDisplay, normalizePhoneNumber, parseRawPhoneInput, validatePhoneNumber } from './chunk-EIWGW2ML.mjs';
23
+ export { DEFAULT_VALIDATION_MESSAGES, createRegexCache, getCachedRegex } from './chunk-BIQ35DLC.mjs';
24
+ export { formatZodErrors } from './chunk-RDXQ4CYT.mjs';
25
+ import z3, { z } from 'zod';
26
+ import { ICONS, getCountryDisplayNameByIso3 } from '@stndrds/constants';
75
27
 
76
28
  // src/types/attribute-protection.ts
77
29
  var IDENTITY_PROPERTIES = ["name", "type"];
@@ -564,26 +516,45 @@ function isFormNode(node) {
564
516
  function isConditionNode(node) {
565
517
  return node.type === "condition";
566
518
  }
567
- function isAssignNode(node) {
568
- return node.type === "assign";
569
- }
570
- function isAINode(node) {
571
- return node.type === "ai";
572
- }
573
519
  function isEndNode(node) {
574
520
  return node.type === "end";
575
521
  }
576
522
 
577
- // src/types/workflows/node-types/start.node-type.ts
578
- var startNodeType = {
579
- type: "start",
580
- isLinear: true,
581
- structural: true,
523
+ // src/types/workflows/node-types/condition.node-type.ts
524
+ var conditionNodeType = {
525
+ type: "condition",
526
+ isLinear: false,
527
+ structural: false,
582
528
  getOutputs(node) {
583
- return node.next ? [node.next] : [];
529
+ return [node.onTrue, node.onFalse].filter((n) => !!n);
584
530
  },
585
- setNext(node, targetId) {
586
- return { ...node, next: targetId };
531
+ setNext() {
532
+ throw new Error(
533
+ "[NodeTypeRegistry] ConditionNode does not support setNext. Use onTrue/onFalse directly."
534
+ );
535
+ },
536
+ getSlotIds() {
537
+ return [];
538
+ },
539
+ validate(node) {
540
+ const errors = [];
541
+ if (!node.condition) {
542
+ errors.push("ConditionNode must have a 'condition'");
543
+ }
544
+ return errors;
545
+ }
546
+ };
547
+
548
+ // src/types/workflows/node-types/end.node-type.ts
549
+ var endNodeType = {
550
+ type: "end",
551
+ isLinear: false,
552
+ structural: true,
553
+ getOutputs() {
554
+ return [];
555
+ },
556
+ setNext() {
557
+ throw new Error("[NodeTypeRegistry] EndNode does not support setNext.");
587
558
  },
588
559
  getSlotIds() {
589
560
  return [];
@@ -592,7 +563,6 @@ var startNodeType = {
592
563
  return [];
593
564
  }
594
565
  };
595
- nodeTypeRegistry.register(startNodeType);
596
566
 
597
567
  // src/types/workflows/node-types/form.node-type.ts
598
568
  var formNodeType = {
@@ -637,121 +607,18 @@ var formNodeType = {
637
607
  return errors;
638
608
  }
639
609
  };
640
- nodeTypeRegistry.register(formNodeType);
641
610
 
642
- // src/types/workflows/node-types/condition.node-type.ts
643
- var conditionNodeType = {
644
- type: "condition",
645
- isLinear: false,
646
- structural: false,
647
- getOutputs(node) {
648
- return [node.onTrue, node.onFalse].filter((n) => !!n);
649
- },
650
- setNext() {
651
- throw new Error(
652
- "[NodeTypeRegistry] ConditionNode does not support setNext. Use onTrue/onFalse directly."
653
- );
654
- },
655
- getSlotIds() {
656
- return [];
657
- },
658
- validate(node) {
659
- const errors = [];
660
- if (!node.condition) {
661
- errors.push("ConditionNode must have a 'condition'");
662
- }
663
- return errors;
664
- }
665
- };
666
- nodeTypeRegistry.register(conditionNodeType);
667
-
668
- // src/types/workflows/node-types/assign.node-type.ts
669
- var assignNodeType = {
670
- type: "assign",
671
- isLinear: true,
672
- structural: false,
673
- getOutputs(node) {
674
- return node.next ? [node.next] : [];
675
- },
676
- setNext(node, targetId) {
677
- return { ...node, next: targetId };
678
- },
679
- getSlotIds(node) {
680
- const slotIds = /* @__PURE__ */ new Set();
681
- if (node.targetSlotId) {
682
- slotIds.add(node.targetSlotId);
683
- }
684
- for (const assignment of node.assignments ?? []) {
685
- const src = assignment.source;
686
- if (src.type === "slot-ref") {
687
- slotIds.add(src.slotId);
688
- } else if (src.type === "expression") {
689
- const matches = src.template.matchAll(/\{\{\s*([\w]+)\.\w+/g);
690
- for (const match of matches) {
691
- slotIds.add(match[1]);
692
- }
693
- }
694
- }
695
- return [...slotIds];
696
- },
697
- validate(node) {
698
- const errors = [];
699
- if (!node.targetSlotId) {
700
- errors.push("AssignNode must have a target slot");
701
- }
702
- if (!node.assignments?.length) {
703
- errors.push("AssignNode must have at least one assignment");
704
- }
705
- if (!node.next) {
706
- errors.push("AssignNode must have a 'next' target");
707
- }
708
- return errors;
709
- }
710
- };
711
- nodeTypeRegistry.register(assignNodeType);
712
-
713
- // src/types/workflows/node-types/ai.node-type.ts
714
- var aiNodeType = {
715
- type: "ai",
611
+ // src/types/workflows/node-types/start.node-type.ts
612
+ var startNodeType = {
613
+ type: "start",
716
614
  isLinear: true,
717
- structural: false,
615
+ structural: true,
718
616
  getOutputs(node) {
719
617
  return node.next ? [node.next] : [];
720
618
  },
721
619
  setNext(node, targetId) {
722
620
  return { ...node, next: targetId };
723
621
  },
724
- getSlotIds(node) {
725
- const slotIds = /* @__PURE__ */ new Set();
726
- for (const id of node.inputSlotIds ?? []) slotIds.add(id);
727
- for (const id of node.targetSlotIds ?? []) slotIds.add(id);
728
- return [...slotIds];
729
- },
730
- validate(node) {
731
- const errors = [];
732
- if (!node.label) errors.push("AINode must have a label");
733
- if (!node.mode) errors.push("AINode must have a mode (sync or async)");
734
- if (!node.next) errors.push("AINode must have a 'next' target");
735
- const hasAgentSource = !!node.definitionId || !!node.systemPrompt;
736
- if (!hasAgentSource) {
737
- errors.push("AINode must have either a definitionId or a systemPrompt");
738
- }
739
- return errors;
740
- }
741
- };
742
- nodeTypeRegistry.register(aiNodeType);
743
-
744
- // src/types/workflows/node-types/end.node-type.ts
745
- var endNodeType = {
746
- type: "end",
747
- isLinear: false,
748
- structural: true,
749
- getOutputs() {
750
- return [];
751
- },
752
- setNext() {
753
- throw new Error("[NodeTypeRegistry] EndNode does not support setNext.");
754
- },
755
622
  getSlotIds() {
756
623
  return [];
757
624
  },
@@ -759,7 +626,18 @@ var endNodeType = {
759
626
  return [];
760
627
  }
761
628
  };
762
- nodeTypeRegistry.register(endNodeType);
629
+
630
+ // src/types/workflows/node-types/index.ts
631
+ var registered = false;
632
+ function registerBuiltInNodeTypes() {
633
+ if (registered) return;
634
+ registered = true;
635
+ nodeTypeRegistry.register(startNodeType);
636
+ nodeTypeRegistry.register(formNodeType);
637
+ nodeTypeRegistry.register(conditionNodeType);
638
+ nodeTypeRegistry.register(endNodeType);
639
+ }
640
+ registerBuiltInNodeTypes();
763
641
 
764
642
  // src/types/workflows/conditions.ts
765
643
  function isConditionRule(item) {
@@ -954,15 +832,13 @@ function isInvitationOrGrantEvent(event) {
954
832
  var ZONE_ORDER = ["collect", "actions"];
955
833
  var ZONE_CONFIG = {
956
834
  collect: { allowedNodeTypes: ["form", "condition"] },
957
- actions: { allowedNodeTypes: ["condition", "assign", "ai"] }
835
+ actions: { allowedNodeTypes: ["condition"] }
958
836
  };
959
837
  var TERMINAL_NODE_TYPES = /* @__PURE__ */ new Set(["start", "end"]);
960
838
  var NODE_TYPE_ZONE = {
961
839
  form: "collect",
962
- condition: "collect",
840
+ condition: "collect"
963
841
  // default — overridden by assignNodeZones logic
964
- assign: "actions",
965
- ai: "actions"
966
842
  };
967
843
  function assignNodeZones(orderedNodes) {
968
844
  const result = /* @__PURE__ */ new Map();
@@ -1013,9 +889,7 @@ function groupNodesByZone(orderedNodes) {
1013
889
  function getZoneAllowedTypes(zone) {
1014
890
  return ZONE_CONFIG[zone].allowedNodeTypes;
1015
891
  }
1016
-
1017
- // src/types/workflows/validation.ts
1018
- import { z } from "zod";
892
+ registerBuiltInNodeTypes();
1019
893
  var ConditionOperatorSchema = z.enum([
1020
894
  "eq",
1021
895
  "neq",
@@ -1036,12 +910,12 @@ var ConditionRuleSchema = z.object({
1036
910
  operator: ConditionOperatorSchema,
1037
911
  value: z.unknown()
1038
912
  });
1039
- var ConditionGroupSchema = z.lazy(
1040
- () => z.object({
1041
- operator: z.enum(["and", "or"]),
1042
- rules: z.array(z.union([ConditionRuleSchema, ConditionGroupSchema])).min(1)
1043
- })
1044
- );
913
+ var ConditionGroupSchema = z.object({
914
+ operator: z.enum(["and", "or"]),
915
+ get rules() {
916
+ return z.array(z.union([ConditionRuleSchema, ConditionGroupSchema])).min(1);
917
+ }
918
+ });
1045
919
  var StartNodeSchema = z.object({
1046
920
  type: z.literal("start"),
1047
921
  id: z.string().min(1),
@@ -1122,45 +996,6 @@ var ConditionNodeSchema = z.object({
1122
996
  onTrue: z.string().nullish(),
1123
997
  onFalse: z.string().nullish()
1124
998
  });
1125
- var AssignmentSourceSchema = z.discriminatedUnion("type", [
1126
- z.object({ type: z.literal("expression"), template: z.string().min(1) }),
1127
- z.object({
1128
- type: z.literal("slot-ref"),
1129
- slotId: z.string().min(1),
1130
- properties: z.record(z.string(), z.unknown()).optional()
1131
- }),
1132
- z.object({ type: z.literal("static"), value: z.unknown() })
1133
- ]);
1134
- var AssignmentMappingSchema = z.object({
1135
- targetAttribute: z.string().min(1),
1136
- source: AssignmentSourceSchema
1137
- });
1138
- var AssignNodeSchema = z.object({
1139
- type: z.literal("assign"),
1140
- id: z.string().min(1),
1141
- label: z.string().min(1),
1142
- description: z.string().nullish(),
1143
- targetSlotId: z.string().min(1, "Target slot is required"),
1144
- assignments: z.array(AssignmentMappingSchema).min(1),
1145
- next: z.string().nullish()
1146
- });
1147
- var AINodeSchema = z.object({
1148
- type: z.literal("ai"),
1149
- id: z.string().min(1),
1150
- label: z.string().min(1),
1151
- description: z.string().nullish(),
1152
- mode: z.enum(["sync", "async"]),
1153
- definitionId: z.string().optional(),
1154
- systemPrompt: z.string().optional(),
1155
- model: z.string().optional(),
1156
- tools: z.array(z.string()).optional(),
1157
- maxIterations: z.number().positive().optional(),
1158
- instructions: z.string().optional(),
1159
- inputSlotIds: z.array(z.string()).optional(),
1160
- targetSlotIds: z.array(z.string()).optional(),
1161
- timeoutMs: z.number().positive().optional(),
1162
- next: z.string().nullish()
1163
- });
1164
999
  var EndNodeSchema = z.object({
1165
1000
  type: z.literal("end"),
1166
1001
  id: z.string().min(1),
@@ -1171,8 +1006,6 @@ var WorkflowNodeSchema = z.discriminatedUnion("type", [
1171
1006
  StartNodeSchema,
1172
1007
  FormNodeSchema,
1173
1008
  ConditionNodeSchema,
1174
- AssignNodeSchema,
1175
- AINodeSchema,
1176
1009
  EndNodeSchema
1177
1010
  ]);
1178
1011
  var SlotModeSchema = z.enum(["create", "select", "optional"]);
@@ -1187,9 +1020,9 @@ var WorkflowSlotSchema = z.object({
1187
1020
  var AuthMethodSchema = z.enum(["signed_link", "pin_code"]);
1188
1021
  var ShareStatusSchema = z.enum(["pending", "active", "expired", "revoked"]);
1189
1022
  var WorkflowShareSchema = z.object({
1190
- id: z.string().uuid(),
1191
- instanceId: z.string().uuid(),
1192
- email: z.string().email(),
1023
+ id: z.uuid(),
1024
+ instanceId: z.uuid(),
1025
+ email: z.email(),
1193
1026
  name: z.string().optional(),
1194
1027
  phone: z.string().optional(),
1195
1028
  authMethod: AuthMethodSchema,
@@ -1204,8 +1037,8 @@ var WorkflowShareSchema = z.object({
1204
1037
  lastAccessAt: z.coerce.date().optional()
1205
1038
  });
1206
1039
  var CreateShareInputSchema = z.object({
1207
- instanceId: z.string().uuid(),
1208
- email: z.string().email(),
1040
+ instanceId: z.uuid(),
1041
+ email: z.email(),
1209
1042
  name: z.string().optional(),
1210
1043
  phone: z.string().optional(),
1211
1044
  authMethod: AuthMethodSchema,
@@ -1235,7 +1068,7 @@ var ThemeColorsSchema = z.object({
1235
1068
  accent: z.string().optional()
1236
1069
  });
1237
1070
  var ThemeLogoSchema = z.object({
1238
- url: z.string().url(),
1071
+ url: z.url(),
1239
1072
  alt: z.string().optional(),
1240
1073
  maxHeight: z.number().positive().optional()
1241
1074
  });
@@ -1307,6 +1140,9 @@ var WorkflowDefinitionSchema = z.object({
1307
1140
  }
1308
1141
  );
1309
1142
 
1143
+ // src/types/workflows/index.ts
1144
+ registerBuiltInNodeTypes();
1145
+
1310
1146
  // src/types/migrations.ts
1311
1147
  var DEFAULT_RETENTION_POLICY = {
1312
1148
  attributeData: 30,
@@ -1334,9 +1170,6 @@ function toUndefinedIfEmpty(obj) {
1334
1170
  function hasProperties(obj) {
1335
1171
  return isNotEmpty2(obj);
1336
1172
  }
1337
-
1338
- // src/format.ts
1339
- import { getCountryDisplayNameByIso3 } from "@stndrds/constants";
1340
1173
  var EMPTY_VALUE_PLACEHOLDER = "\u2014";
1341
1174
  function formatText(value) {
1342
1175
  return String(value);
@@ -1465,7 +1298,7 @@ function formatAttributeValue(value, attribute) {
1465
1298
  case "number":
1466
1299
  return formatNumber(value, attribute);
1467
1300
  case "currency":
1468
- return formatCurrency(value, attribute);
1301
+ return formatCurrency(value);
1469
1302
  case "date":
1470
1303
  return formatDate(value);
1471
1304
  case "phone":
@@ -1495,8 +1328,46 @@ function formatAttributeValue(value, attribute) {
1495
1328
  }
1496
1329
  }
1497
1330
  }
1498
-
1499
- // src/lib/template.ts
1331
+ var SIMPLE_PIPES = ["UPPER", "LOWER", "capitalize", "trim"];
1332
+ var PIPES_WITH_ARGS = ["prefix", "suffix", "wrap", "default"];
1333
+ var ALL_PIPES = [...SIMPLE_PIPES, ...PIPES_WITH_ARGS];
1334
+ var labelExpressionSchema = z.string().min(1, "labelExpression cannot be empty").refine((val) => isLabelExpression(val), {
1335
+ message: "labelExpression must contain at least one {{ attribute }} interpolation"
1336
+ }).refine(
1337
+ (val) => {
1338
+ const emptyCheck = /\{\{\s*\}\}/;
1339
+ return !emptyCheck.test(val);
1340
+ },
1341
+ { message: "labelExpression contains empty {{ }} interpolation" }
1342
+ ).refine(
1343
+ (val) => {
1344
+ const pipePattern = /(?<!\|)\|(?!\|)\s*(\w+)(?::[^|}]*)?/g;
1345
+ let match;
1346
+ while ((match = pipePattern.exec(val)) !== null) {
1347
+ const pipeName = match[1];
1348
+ if (!ALL_PIPES.includes(pipeName)) {
1349
+ return false;
1350
+ }
1351
+ }
1352
+ return true;
1353
+ },
1354
+ {
1355
+ message: `Invalid pipe name. Valid pipes: ${ALL_PIPES.join(", ")}`
1356
+ }
1357
+ );
1358
+ function validateLabelExpression(expression) {
1359
+ const result = labelExpressionSchema.safeParse(expression);
1360
+ if (!result.success) {
1361
+ return {
1362
+ success: false,
1363
+ error: result.error.issues[0]?.message ?? "Invalid labelExpression"
1364
+ };
1365
+ }
1366
+ return {
1367
+ success: true,
1368
+ attributes: extractAttributeNames(expression)
1369
+ };
1370
+ }
1500
1371
  var simplePipes = {
1501
1372
  /** Convert to uppercase */
1502
1373
  UPPER: (v) => String(v).toUpperCase(),
@@ -1682,6 +1553,7 @@ var SchemaErrorCode = {
1682
1553
  USER_PROFILE_NOT_FOUND: "SCHEMA_USER_PROFILE_NOT_FOUND",
1683
1554
  FILE_NOT_FOUND: "SCHEMA_FILE_NOT_FOUND",
1684
1555
  ROLE_NOT_FOUND: "SCHEMA_ROLE_NOT_FOUND",
1556
+ MEMORY_NOT_FOUND: "SCHEMA_MEMORY_NOT_FOUND",
1685
1557
  // Validation
1686
1558
  VALIDATION_FAILED: "SCHEMA_VALIDATION_FAILED",
1687
1559
  INVALID_ATTRIBUTE_NAME: "SCHEMA_INVALID_ATTRIBUTE_NAME",
@@ -1693,6 +1565,7 @@ var SchemaErrorCode = {
1693
1565
  PROTECTED_ROLE: "SCHEMA_PROTECTED_ROLE",
1694
1566
  // Permissions
1695
1567
  FORBIDDEN: "SCHEMA_FORBIDDEN",
1568
+ ACCESS_DENIED: "SCHEMA_ACCESS_DENIED",
1696
1569
  // Sync
1697
1570
  SYNC_FAILED: "SCHEMA_SYNC_FAILED",
1698
1571
  NOT_SYSTEM_OBJECT: "SCHEMA_NOT_SYSTEM_OBJECT",
@@ -1700,7 +1573,19 @@ var SchemaErrorCode = {
1700
1573
  DUPLICATE_OBJECT: "SCHEMA_DUPLICATE_OBJECT",
1701
1574
  DUPLICATE_ATTRIBUTE: "SCHEMA_DUPLICATE_ATTRIBUTE",
1702
1575
  // Concurrency
1703
- CONFLICT: "SCHEMA_CONFLICT"
1576
+ CONFLICT: "SCHEMA_CONFLICT",
1577
+ // Storage
1578
+ STORAGE_UPLOAD_FAILED: "SCHEMA_STORAGE_UPLOAD_FAILED",
1579
+ STORAGE_DOWNLOAD_FAILED: "SCHEMA_STORAGE_DOWNLOAD_FAILED",
1580
+ STORAGE_DELETE_FAILED: "SCHEMA_STORAGE_DELETE_FAILED",
1581
+ STORAGE_URL_FAILED: "SCHEMA_STORAGE_URL_FAILED",
1582
+ // Repository Operations
1583
+ REPOSITORY_CREATE_FAILED: "SCHEMA_REPOSITORY_CREATE_FAILED",
1584
+ REPOSITORY_UPDATE_FAILED: "SCHEMA_REPOSITORY_UPDATE_FAILED",
1585
+ REPOSITORY_DELETE_FAILED: "SCHEMA_REPOSITORY_DELETE_FAILED",
1586
+ REPOSITORY_QUERY_FAILED: "SCHEMA_REPOSITORY_QUERY_FAILED",
1587
+ // Not Implemented
1588
+ NOT_IMPLEMENTED: "SCHEMA_NOT_IMPLEMENTED"
1704
1589
  };
1705
1590
  var SchemaError = class extends Error {
1706
1591
  constructor(message, code = SchemaErrorCode.UNKNOWN, details) {
@@ -1881,9 +1766,101 @@ var ConcurrentModificationError = class extends SchemaError {
1881
1766
  );
1882
1767
  }
1883
1768
  };
1769
+ var StorageError = class extends SchemaError {
1770
+ constructor(operation, message, path, cause) {
1771
+ const code = operation === "upload" ? SchemaErrorCode.STORAGE_UPLOAD_FAILED : operation === "download" ? SchemaErrorCode.STORAGE_DOWNLOAD_FAILED : operation === "delete" ? SchemaErrorCode.STORAGE_DELETE_FAILED : SchemaErrorCode.STORAGE_URL_FAILED;
1772
+ super(`Storage ${operation} failed: ${message}`, code, {
1773
+ operation,
1774
+ path,
1775
+ cause
1776
+ });
1777
+ this.name = "StorageError";
1778
+ this.operation = operation;
1779
+ this.path = path;
1780
+ this.cause = cause;
1781
+ }
1782
+ };
1783
+ function isStorageError(error) {
1784
+ return error instanceof StorageError;
1785
+ }
1786
+ var AccessDeniedError = class extends SchemaError {
1787
+ constructor(resource, reason) {
1788
+ super(reason ?? `Access denied to resource: ${resource}`, SchemaErrorCode.ACCESS_DENIED, {
1789
+ resource,
1790
+ reason
1791
+ });
1792
+ this.name = "AccessDeniedError";
1793
+ this.resource = resource;
1794
+ this.reason = reason;
1795
+ }
1796
+ };
1797
+ function isAccessDeniedError(error) {
1798
+ return error instanceof AccessDeniedError;
1799
+ }
1800
+ var RepositoryError = class extends SchemaError {
1801
+ constructor(operation, entity, message, cause) {
1802
+ const code = operation === "create" ? SchemaErrorCode.REPOSITORY_CREATE_FAILED : operation === "update" ? SchemaErrorCode.REPOSITORY_UPDATE_FAILED : operation === "delete" ? SchemaErrorCode.REPOSITORY_DELETE_FAILED : SchemaErrorCode.REPOSITORY_QUERY_FAILED;
1803
+ super(`Failed to ${operation} ${entity}: ${message}`, code, {
1804
+ operation,
1805
+ entity,
1806
+ cause
1807
+ });
1808
+ this.name = "RepositoryError";
1809
+ this.operation = operation;
1810
+ this.entity = entity;
1811
+ this.cause = cause;
1812
+ }
1813
+ };
1814
+ function isRepositoryError(error) {
1815
+ return error instanceof RepositoryError;
1816
+ }
1817
+ var NotImplementedError = class extends SchemaError {
1818
+ constructor(feature, milestone) {
1819
+ const message = milestone ? `${feature}: not implemented (${milestone})` : `${feature}: not implemented`;
1820
+ super(message, SchemaErrorCode.NOT_IMPLEMENTED, {
1821
+ feature,
1822
+ milestone
1823
+ });
1824
+ this.name = "NotImplementedError";
1825
+ this.feature = feature;
1826
+ this.milestone = milestone;
1827
+ }
1828
+ };
1829
+ function isNotImplementedError(error) {
1830
+ return error instanceof NotImplementedError;
1831
+ }
1832
+ var MemoryNotFoundError = class extends NotFoundError {
1833
+ constructor(memoryId) {
1834
+ super("Memory", memoryId, SchemaErrorCode.MEMORY_NOT_FOUND);
1835
+ this.name = "MemoryNotFoundError";
1836
+ }
1837
+ };
1884
1838
 
1885
- // src/builders/attribute-validators.ts
1886
- import { ICONS } from "@stndrds/constants";
1839
+ // src/standard-schema.ts
1840
+ var STANDARD_SCHEMA_VENDOR = "@stndrds/schema";
1841
+ function createStandardSchemaProps(zodSchema) {
1842
+ return {
1843
+ version: 1,
1844
+ vendor: STANDARD_SCHEMA_VENDOR,
1845
+ validate: (value) => {
1846
+ const result = zodSchema.safeParse(value);
1847
+ if (result.success) {
1848
+ return { value: result.data };
1849
+ }
1850
+ return {
1851
+ issues: result.error.issues.map((issue) => ({
1852
+ message: issue.message,
1853
+ // Zod path segments are string | number which are valid PropertyKey
1854
+ // for Standard Schema v1 (no conversion needed)
1855
+ path: issue.path
1856
+ }))
1857
+ };
1858
+ }
1859
+ };
1860
+ }
1861
+ function isStandardSchema(obj) {
1862
+ return typeof obj === "object" && obj !== null && "~standard" in obj && typeof obj["~standard"] === "object" && obj["~standard"].version === 1;
1863
+ }
1887
1864
  var VALID_ICONS = new Set(ICONS);
1888
1865
  var ATTRIBUTE_NAME_REGEX = /^[a-zA-Z_][a-zA-Z0-9_]*$/;
1889
1866
  var MAX_NAME_LENGTH = 63;
@@ -1980,7 +1957,22 @@ function validateOptions(options, attributeName) {
1980
1957
  }
1981
1958
 
1982
1959
  // src/builders/attribute-builders.ts
1960
+ function asMutableArray(arr) {
1961
+ return arr;
1962
+ }
1983
1963
  var BaseAttributeBuilder = class {
1964
+ /**
1965
+ * Standard Schema v1 interface implementation.
1966
+ *
1967
+ * This property enables interoperability with libraries that support
1968
+ * Standard Schema (React Hook Form, tRPC, etc.).
1969
+ *
1970
+ * @see https://standardschema.dev/
1971
+ */
1972
+ get "~standard"() {
1973
+ const zodSchema = createAttributeValidator(this.build());
1974
+ return createStandardSchemaProps(zodSchema);
1975
+ }
1984
1976
  constructor(type, name, label) {
1985
1977
  validateAttributeName(name);
1986
1978
  validateLabel(label);
@@ -1994,6 +1986,41 @@ var BaseAttributeBuilder = class {
1994
1986
  setRequired(value) {
1995
1987
  this.attr.required = value;
1996
1988
  }
1989
+ /**
1990
+ * Type-safe method to return this builder with a different TRequired phantom type.
1991
+ *
1992
+ * This method centralizes the type assertion needed when transitioning between
1993
+ * required states. The assertion is safe because:
1994
+ * 1. The runtime representation is unchanged (same instance)
1995
+ * 2. Only the phantom _types.required property differs
1996
+ * 3. The class structure and all methods remain identical
1997
+ *
1998
+ * Using a single protected method for this pattern:
1999
+ * - Reduces scattered unsafe casts throughout the codebase
2000
+ * - Documents the safety reasoning in one place
2001
+ * - Makes the type transition explicit and auditable
2002
+ *
2003
+ * @internal
2004
+ */
2005
+ asRequiredState() {
2006
+ return this;
2007
+ }
2008
+ /**
2009
+ * Type-safe method to return this builder with different phantom type parameters.
2010
+ *
2011
+ * Used by builders with additional type parameters (like TOptions in Status/Select/Multiselect)
2012
+ * when those parameters need to change while preserving the builder instance.
2013
+ *
2014
+ * The assertion is safe because:
2015
+ * 1. The runtime representation is unchanged (same instance)
2016
+ * 2. Only phantom type parameters differ
2017
+ * 3. The class structure and all methods remain identical
2018
+ *
2019
+ * @internal
2020
+ */
2021
+ asPhantomState() {
2022
+ return this;
2023
+ }
1997
2024
  system() {
1998
2025
  this.attr.system = true;
1999
2026
  return this;
@@ -2081,11 +2108,11 @@ var TextAttributeBuilder = class extends BaseAttributeBuilder {
2081
2108
  }
2082
2109
  required() {
2083
2110
  this.setRequired(true);
2084
- return this;
2111
+ return this.asRequiredState();
2085
2112
  }
2086
2113
  optional() {
2087
2114
  this.setRequired(false);
2088
- return this;
2115
+ return this.asRequiredState();
2089
2116
  }
2090
2117
  /**
2091
2118
  * Set email validation pattern
@@ -2118,11 +2145,11 @@ var TextAreaAttributeBuilder = class extends BaseAttributeBuilder {
2118
2145
  }
2119
2146
  required() {
2120
2147
  this.setRequired(true);
2121
- return this;
2148
+ return this.asRequiredState();
2122
2149
  }
2123
2150
  optional() {
2124
2151
  this.setRequired(false);
2125
- return this;
2152
+ return this.asRequiredState();
2126
2153
  }
2127
2154
  };
2128
2155
  function textarea(config) {
@@ -2150,11 +2177,11 @@ var RichtextAttributeBuilder = class extends BaseAttributeBuilder {
2150
2177
  }
2151
2178
  required() {
2152
2179
  this.setRequired(true);
2153
- return this;
2180
+ return this.asRequiredState();
2154
2181
  }
2155
2182
  optional() {
2156
2183
  this.setRequired(false);
2157
- return this;
2184
+ return this.asRequiredState();
2158
2185
  }
2159
2186
  };
2160
2187
  function richtext(config) {
@@ -2188,11 +2215,11 @@ var NumberAttributeBuilder = class extends BaseAttributeBuilder {
2188
2215
  }
2189
2216
  required() {
2190
2217
  this.setRequired(true);
2191
- return this;
2218
+ return this.asRequiredState();
2192
2219
  }
2193
2220
  optional() {
2194
2221
  this.setRequired(false);
2195
- return this;
2222
+ return this.asRequiredState();
2196
2223
  }
2197
2224
  };
2198
2225
  function number(config) {
@@ -2204,11 +2231,11 @@ var CheckboxAttributeBuilder = class extends BaseAttributeBuilder {
2204
2231
  }
2205
2232
  required() {
2206
2233
  this.setRequired(true);
2207
- return this;
2234
+ return this.asRequiredState();
2208
2235
  }
2209
2236
  optional() {
2210
2237
  this.setRequired(false);
2211
- return this;
2238
+ return this.asRequiredState();
2212
2239
  }
2213
2240
  };
2214
2241
  function checkbox(config) {
@@ -2232,11 +2259,11 @@ var DateAttributeBuilder = class extends BaseAttributeBuilder {
2232
2259
  }
2233
2260
  required() {
2234
2261
  this.setRequired(true);
2235
- return this;
2262
+ return this.asRequiredState();
2236
2263
  }
2237
2264
  optional() {
2238
2265
  this.setRequired(false);
2239
- return this;
2266
+ return this.asRequiredState();
2240
2267
  }
2241
2268
  };
2242
2269
  function date(config) {
@@ -2252,11 +2279,11 @@ var PhoneAttributeBuilder = class extends BaseAttributeBuilder {
2252
2279
  }
2253
2280
  required() {
2254
2281
  this.setRequired(true);
2255
- return this;
2282
+ return this.asRequiredState();
2256
2283
  }
2257
2284
  optional() {
2258
2285
  this.setRequired(false);
2259
- return this;
2286
+ return this.asRequiredState();
2260
2287
  }
2261
2288
  };
2262
2289
  function phone(config) {
@@ -2276,11 +2303,11 @@ var CurrencyAttributeBuilder = class extends BaseAttributeBuilder {
2276
2303
  }
2277
2304
  required() {
2278
2305
  this.setRequired(true);
2279
- return this;
2306
+ return this.asRequiredState();
2280
2307
  }
2281
2308
  optional() {
2282
2309
  this.setRequired(false);
2283
- return this;
2310
+ return this.asRequiredState();
2284
2311
  }
2285
2312
  };
2286
2313
  function currency(config) {
@@ -2294,9 +2321,10 @@ var StatusAttributeBuilder = class extends BaseAttributeBuilder {
2294
2321
  * Set all options at once (preserves literal types for values)
2295
2322
  */
2296
2323
  options(value) {
2297
- validateOptions(value, this.attr.name ?? "unknown");
2298
- this.attr.options = value;
2299
- return this;
2324
+ const mutableOptions = asMutableArray(value);
2325
+ validateOptions(mutableOptions, this.attr.name ?? "unknown");
2326
+ this.attr.options = mutableOptions;
2327
+ return this.asPhantomState();
2300
2328
  }
2301
2329
  option(config) {
2302
2330
  if (!this.attr.options) {
@@ -2309,11 +2337,11 @@ var StatusAttributeBuilder = class extends BaseAttributeBuilder {
2309
2337
  }
2310
2338
  required() {
2311
2339
  this.setRequired(true);
2312
- return this;
2340
+ return this.asRequiredState();
2313
2341
  }
2314
2342
  optional() {
2315
2343
  this.setRequired(false);
2316
- return this;
2344
+ return this.asRequiredState();
2317
2345
  }
2318
2346
  };
2319
2347
  function status(config) {
@@ -2327,9 +2355,10 @@ var SelectAttributeBuilder = class extends BaseAttributeBuilder {
2327
2355
  * Set all options at once (preserves literal types for values)
2328
2356
  */
2329
2357
  options(value) {
2330
- validateOptions(value, this.attr.name ?? "unknown");
2331
- this.attr.options = value;
2332
- return this;
2358
+ const mutableOptions = asMutableArray(value);
2359
+ validateOptions(mutableOptions, this.attr.name ?? "unknown");
2360
+ this.attr.options = mutableOptions;
2361
+ return this.asPhantomState();
2333
2362
  }
2334
2363
  option(config) {
2335
2364
  if (!this.attr.options) {
@@ -2342,11 +2371,11 @@ var SelectAttributeBuilder = class extends BaseAttributeBuilder {
2342
2371
  }
2343
2372
  required() {
2344
2373
  this.setRequired(true);
2345
- return this;
2374
+ return this.asRequiredState();
2346
2375
  }
2347
2376
  optional() {
2348
2377
  this.setRequired(false);
2349
- return this;
2378
+ return this.asRequiredState();
2350
2379
  }
2351
2380
  };
2352
2381
  function select(config) {
@@ -2360,9 +2389,10 @@ var MultiselectAttributeBuilder = class extends BaseAttributeBuilder {
2360
2389
  * Set all options at once (preserves literal types for values)
2361
2390
  */
2362
2391
  options(value) {
2363
- validateOptions(value, this.attr.name ?? "unknown");
2364
- this.attr.options = value;
2365
- return this;
2392
+ const mutableOptions = asMutableArray(value);
2393
+ validateOptions(mutableOptions, this.attr.name ?? "unknown");
2394
+ this.attr.options = mutableOptions;
2395
+ return this.asPhantomState();
2366
2396
  }
2367
2397
  option(config) {
2368
2398
  if (!this.attr.options) {
@@ -2375,11 +2405,11 @@ var MultiselectAttributeBuilder = class extends BaseAttributeBuilder {
2375
2405
  }
2376
2406
  required() {
2377
2407
  this.setRequired(true);
2378
- return this;
2408
+ return this.asRequiredState();
2379
2409
  }
2380
2410
  optional() {
2381
2411
  this.setRequired(false);
2382
- return this;
2412
+ return this.asRequiredState();
2383
2413
  }
2384
2414
  };
2385
2415
  function multiselect(config) {
@@ -2415,11 +2445,11 @@ var LocationAttributeBuilder = class extends BaseAttributeBuilder {
2415
2445
  }
2416
2446
  required() {
2417
2447
  this.setRequired(true);
2418
- return this;
2448
+ return this.asRequiredState();
2419
2449
  }
2420
2450
  optional() {
2421
2451
  this.setRequired(false);
2422
- return this;
2452
+ return this.asRequiredState();
2423
2453
  }
2424
2454
  };
2425
2455
  function location(config) {
@@ -2438,7 +2468,7 @@ var FileAttributeBuilder = class extends BaseAttributeBuilder {
2438
2468
  return this;
2439
2469
  }
2440
2470
  allowedTypes(types) {
2441
- this.attr.allowedTypes = types;
2471
+ this.attr.allowedTypes = asMutableArray(types);
2442
2472
  return this;
2443
2473
  }
2444
2474
  /**
@@ -2450,11 +2480,11 @@ var FileAttributeBuilder = class extends BaseAttributeBuilder {
2450
2480
  }
2451
2481
  required() {
2452
2482
  this.setRequired(true);
2453
- return this;
2483
+ return this.asRequiredState();
2454
2484
  }
2455
2485
  optional() {
2456
2486
  this.setRequired(false);
2457
- return this;
2487
+ return this.asRequiredState();
2458
2488
  }
2459
2489
  };
2460
2490
  function file(config) {
@@ -2477,11 +2507,11 @@ var UserAttributeBuilder = class extends BaseAttributeBuilder {
2477
2507
  }
2478
2508
  required() {
2479
2509
  this.setRequired(true);
2480
- return this;
2510
+ return this.asRequiredState();
2481
2511
  }
2482
2512
  optional() {
2483
2513
  this.setRequired(false);
2484
- return this;
2514
+ return this.asRequiredState();
2485
2515
  }
2486
2516
  };
2487
2517
  function user(config) {
@@ -2599,11 +2629,11 @@ var SingleRelationAttributeBuilder = class extends BaseRelationAttributeBuilder
2599
2629
  }
2600
2630
  required() {
2601
2631
  this.setRequired(true);
2602
- return this;
2632
+ return this.asRequiredState();
2603
2633
  }
2604
2634
  optional() {
2605
2635
  this.setRequired(false);
2606
- return this;
2636
+ return this.asRequiredState();
2607
2637
  }
2608
2638
  };
2609
2639
  var MultiRelationAttributeBuilder = class extends BaseRelationAttributeBuilder {
@@ -2632,11 +2662,11 @@ var MultiRelationAttributeBuilder = class extends BaseRelationAttributeBuilder {
2632
2662
  }
2633
2663
  required() {
2634
2664
  this.setRequired(true);
2635
- return this;
2665
+ return this.asRequiredState();
2636
2666
  }
2637
2667
  optional() {
2638
2668
  this.setRequired(false);
2639
- return this;
2669
+ return this.asRequiredState();
2640
2670
  }
2641
2671
  };
2642
2672
  function relation(config) {
@@ -2656,11 +2686,11 @@ var RatingAttributeBuilder = class extends BaseAttributeBuilder {
2656
2686
  }
2657
2687
  required() {
2658
2688
  this.setRequired(true);
2659
- return this;
2689
+ return this.asRequiredState();
2660
2690
  }
2661
2691
  optional() {
2662
2692
  this.setRequired(false);
2663
- return this;
2693
+ return this.asRequiredState();
2664
2694
  }
2665
2695
  };
2666
2696
  function rating(config) {
@@ -2805,8 +2835,7 @@ var DocumentAttributeBuilder = class extends BaseAttributeBuilder {
2805
2835
  return this;
2806
2836
  }
2807
2837
  /**
2808
- * Automatically trigger processing on upload.
2809
- * Processing is defined by the template's autoProcessing config.
2838
+ * Automatically trigger agent-compatible processing on upload.
2810
2839
  */
2811
2840
  autoProcess() {
2812
2841
  this.attr.autoProcess = true;
@@ -2817,23 +2846,20 @@ var DocumentAttributeBuilder = class extends BaseAttributeBuilder {
2817
2846
  */
2818
2847
  required() {
2819
2848
  this.setRequired(true);
2820
- return this;
2849
+ return this.asRequiredState();
2821
2850
  }
2822
2851
  /**
2823
2852
  * Mark this attribute as optional (undo required).
2824
2853
  */
2825
2854
  optional() {
2826
2855
  this.setRequired(false);
2827
- return this;
2856
+ return this.asRequiredState();
2828
2857
  }
2829
2858
  };
2830
2859
  function document(config) {
2831
2860
  return new DocumentAttributeBuilder(config.name, config.label);
2832
2861
  }
2833
2862
 
2834
- // src/builders/object-builder.ts
2835
- import z2 from "zod";
2836
-
2837
2863
  // src/builders/migration-builder.ts
2838
2864
  function resolveBuiltInTransform(targetType) {
2839
2865
  const map = {
@@ -2981,6 +3007,18 @@ var ObjectBuilder = class {
2981
3007
  system: false
2982
3008
  };
2983
3009
  }
3010
+ /**
3011
+ * Standard Schema v1 interface implementation.
3012
+ *
3013
+ * This property enables interoperability with libraries that support
3014
+ * Standard Schema (React Hook Form, tRPC, etc.).
3015
+ *
3016
+ * @see https://standardschema.dev/
3017
+ */
3018
+ get "~standard"() {
3019
+ const zodSchema = createObjectValidator(this.build());
3020
+ return createStandardSchemaProps(zodSchema);
3021
+ }
2984
3022
  /**
2985
3023
  * Set object description
2986
3024
  */
@@ -3119,6 +3157,13 @@ The labelExpression defines how records are displayed in lists and relations.
3119
3157
  \u2705 Example: .labelExpression("{{ firstName }} {{ lastName }}")`
3120
3158
  );
3121
3159
  }
3160
+ const labelResult = labelExpressionSchema.safeParse(this._labelExpression);
3161
+ if (!labelResult.success) {
3162
+ const errorMsg = labelResult.error.issues[0]?.message ?? "Invalid labelExpression";
3163
+ throw new Error(
3164
+ `[ObjectBuilder] Invalid labelExpression for "${this.obj.name}": ${errorMsg}`
3165
+ );
3166
+ }
3122
3167
  const sortedVersions = [...this._migrations].sort((a, b) => a.version - b.version);
3123
3168
  for (let i = 0; i < sortedVersions.length; i++) {
3124
3169
  const expected = i + 2;
@@ -3146,13 +3191,13 @@ The labelExpression defines how records are displayed in lists and relations.
3146
3191
  if (name === void 0) {
3147
3192
  return;
3148
3193
  }
3149
- const objectNameSchema = z2.string().min(1, "Object name cannot be empty").max(63, "Object name is too long (max 63 characters)").regex(/^[a-z][a-z0-9-]*$/, {
3194
+ const objectNameSchema = z3.string().min(1, "Object name cannot be empty").max(63, "Object name is too long (max 63 characters)").regex(/^[a-z][a-z0-9-]*$/, {
3150
3195
  message: "Invalid object name format.\nName must be in kebab-case (slug format):\n \u2705 Valid: 'products', 'user-profiles', 'order-items'\n \u274C Invalid: 'Products', 'userProfiles', 'user_profiles'"
3151
3196
  });
3152
3197
  try {
3153
3198
  objectNameSchema.parse(name);
3154
3199
  } catch (error) {
3155
- if (error instanceof z2.ZodError) {
3200
+ if (error instanceof z3.ZodError) {
3156
3201
  throw new Error(`[ObjectBuilder] ${error.issues[0].message}`);
3157
3202
  }
3158
3203
  throw error;
@@ -3162,9 +3207,6 @@ The labelExpression defines how records are displayed in lists and relations.
3162
3207
  function object(config) {
3163
3208
  return new ObjectBuilder(config);
3164
3209
  }
3165
-
3166
- // src/builders/view-builder.ts
3167
- import { z as z3 } from "zod";
3168
3210
  var GroupBuilder = class {
3169
3211
  constructor(id, label) {
3170
3212
  this.data = { fields: [] };
@@ -3955,13 +3997,13 @@ var DetailViewBuilder = class {
3955
3997
  * Validate view name format (kebab-case)
3956
3998
  */
3957
3999
  validateName(name) {
3958
- const viewNameSchema = z3.string().min(1, "View name cannot be empty").max(63, "View name is too long (max 63 characters)").regex(/^[a-z][a-z0-9-]*$/, {
4000
+ const viewNameSchema = z.string().min(1, "View name cannot be empty").max(63, "View name is too long (max 63 characters)").regex(/^[a-z][a-z0-9-]*$/, {
3959
4001
  message: "Invalid view name format.\nName must be in kebab-case:\n \u2705 Valid: 'detail', 'list-view', 'company-detail'\n \u274C Invalid: 'Detail', 'listView', 'list_view'"
3960
4002
  });
3961
4003
  try {
3962
4004
  viewNameSchema.parse(name);
3963
4005
  } catch (error) {
3964
- if (error instanceof z3.ZodError) {
4006
+ if (error instanceof z.ZodError) {
3965
4007
  throw new Error(`[DetailViewBuilder] ${error.issues[0].message}`);
3966
4008
  }
3967
4009
  throw error;
@@ -4135,13 +4177,13 @@ var ListViewBuilder = class {
4135
4177
  * Validate view name format (kebab-case)
4136
4178
  */
4137
4179
  validateName(name) {
4138
- const viewNameSchema = z3.string().min(1, "View name cannot be empty").max(63, "View name is too long (max 63 characters)").regex(/^[a-z][a-z0-9-]*$/, {
4180
+ const viewNameSchema = z.string().min(1, "View name cannot be empty").max(63, "View name is too long (max 63 characters)").regex(/^[a-z][a-z0-9-]*$/, {
4139
4181
  message: "Invalid view name format.\nName must be in kebab-case:\n \u2705 Valid: 'default', 'list-view', 'active-contacts'\n \u274C Invalid: 'Default', 'listView', 'list_view'"
4140
4182
  });
4141
4183
  try {
4142
4184
  viewNameSchema.parse(name);
4143
4185
  } catch (error) {
4144
- if (error instanceof z3.ZodError) {
4186
+ if (error instanceof z.ZodError) {
4145
4187
  throw new Error(`[ListViewBuilder] ${error.issues[0].message}`);
4146
4188
  }
4147
4189
  throw error;
@@ -4319,9 +4361,7 @@ function group(id, label) {
4319
4361
  function relationGroup(id, label, attribute) {
4320
4362
  return new RelationGroupBuilder(id, label, attribute);
4321
4363
  }
4322
-
4323
- // src/builders/workflow-builder.ts
4324
- import { z as z4 } from "zod";
4364
+ registerBuiltInNodeTypes();
4325
4365
  var WorkflowFormRowBuilder = class {
4326
4366
  /** @internal */
4327
4367
  constructor(formBuilder, rowId, order) {
@@ -4645,132 +4685,6 @@ var WorkflowConditionBuilder = class {
4645
4685
  };
4646
4686
  }
4647
4687
  };
4648
- var WorkflowAssignBuilder = class {
4649
- /** @internal */
4650
- constructor(workflowBuilder, nodeId, label, targetSlotId) {
4651
- this.assignments = [];
4652
- this.workflowBuilder = workflowBuilder;
4653
- this.nodeId = nodeId;
4654
- this.label = label;
4655
- this.targetSlotId = targetSlotId;
4656
- }
4657
- /**
4658
- * Set an attribute using an expression template.
4659
- * Uses mustache syntax: `{{ slotId.attribute }}`.
4660
- */
4661
- expression(targetAttribute, template) {
4662
- this.assignments.push({
4663
- targetAttribute,
4664
- source: { type: "expression", template }
4665
- });
4666
- return this;
4667
- }
4668
- /**
4669
- * Link a relation attribute to a slot's record.
4670
- * Optionally include qualified relation properties.
4671
- */
4672
- slotRef(targetAttribute, slotId, properties) {
4673
- this.assignments.push({
4674
- targetAttribute,
4675
- source: { type: "slot-ref", slotId, properties }
4676
- });
4677
- return this;
4678
- }
4679
- /**
4680
- * Set a static value on an attribute
4681
- */
4682
- setValue(targetAttribute, value) {
4683
- this.assignments.push({
4684
- targetAttribute,
4685
- source: { type: "static", value }
4686
- });
4687
- return this;
4688
- }
4689
- /**
4690
- * Set the description for this assign node
4691
- */
4692
- describe(description) {
4693
- this.nodeDescription = description;
4694
- return this;
4695
- }
4696
- /**
4697
- * Set the next node and complete the assign definition
4698
- */
4699
- next(nodeId) {
4700
- if (this.assignments.length === 0) {
4701
- throw new Error(
4702
- `[WorkflowBuilder] Assign "${this.nodeId}" must have at least one assignment. Use .expression(), .slotRef() or .setValue() first.`
4703
- );
4704
- }
4705
- return this.workflowBuilder._addNode({
4706
- type: "assign",
4707
- id: this.nodeId,
4708
- label: this.label,
4709
- description: this.nodeDescription,
4710
- targetSlotId: this.targetSlotId,
4711
- assignments: this.assignments,
4712
- next: nodeId
4713
- });
4714
- }
4715
- };
4716
- var WorkflowAIBuilder = class {
4717
- /** @internal */
4718
- constructor(workflowBuilder, nodeId, label) {
4719
- this.agentConfig = null;
4720
- this.workflowBuilder = workflowBuilder;
4721
- this.nodeId = nodeId;
4722
- this.label = label;
4723
- }
4724
- describe(description) {
4725
- this.nodeDescription = description;
4726
- return this;
4727
- }
4728
- timeout(ms) {
4729
- this.nodeTimeoutMs = ms;
4730
- return this;
4731
- }
4732
- /**
4733
- * Configure the agent for this node.
4734
- *
4735
- * @param definitionIdOrConfig - Either an existing agent definition ID (string),
4736
- * or an inline agent config object.
4737
- * @param options - Additional options merged on top (only used when first arg is a string)
4738
- */
4739
- agent(definitionIdOrConfig, options) {
4740
- if (typeof definitionIdOrConfig === "string") {
4741
- this.agentConfig = {
4742
- // Default to async when referencing a definition by ID
4743
- mode: options?.mode ?? "async",
4744
- definitionId: definitionIdOrConfig,
4745
- instructions: options?.instructions,
4746
- inputSlotIds: options?.inputSlotIds,
4747
- targetSlotIds: options?.targetSlotIds
4748
- };
4749
- } else {
4750
- this.agentConfig = definitionIdOrConfig;
4751
- }
4752
- return this;
4753
- }
4754
- /**
4755
- * Set the next node and complete the AI node definition
4756
- */
4757
- next(nodeId) {
4758
- if (!this.agentConfig) {
4759
- throw new Error(
4760
- `[WorkflowBuilder] AI node "${this.nodeId}" must have an agent config. Call .agent() first.`
4761
- );
4762
- }
4763
- return this.workflowBuilder._addNode({
4764
- type: "ai",
4765
- id: this.nodeId,
4766
- label: this.label,
4767
- description: this.nodeDescription,
4768
- timeoutMs: this.nodeTimeoutMs,
4769
- next: nodeId,
4770
- ...this.agentConfig
4771
- });
4772
- }
4773
- };
4774
4688
  var WorkflowEndBuilder = class {
4775
4689
  /** @internal */
4776
4690
  constructor(workflowBuilder, nodeId) {
@@ -4936,16 +4850,6 @@ var WorkflowBuilder = class {
4936
4850
  condition(id, label) {
4937
4851
  return new WorkflowConditionBuilder(this, id, label);
4938
4852
  }
4939
- /**
4940
- * Define an assign node (set values on a target slot)
4941
- */
4942
- assign(id, label, targetSlotId) {
4943
- return new WorkflowAssignBuilder(this, id, label, targetSlotId);
4944
- }
4945
- /** Define an AI agent node (sync or async, inline or referenced from a definition) */
4946
- ai(id, label) {
4947
- return new WorkflowAIBuilder(this, id, label);
4948
- }
4949
4853
  /**
4950
4854
  * Define an end node
4951
4855
  */
@@ -4991,13 +4895,13 @@ var WorkflowBuilder = class {
4991
4895
  // VALIDATION
4992
4896
  // ============================================================================
4993
4897
  validateName(name) {
4994
- const schema = z4.string().min(1, "Workflow name cannot be empty").max(63, "Workflow name is too long (max 63 characters)").regex(/^[a-z][a-z0-9-]*$/, {
4898
+ const schema = z.string().min(1, "Workflow name cannot be empty").max(63, "Workflow name is too long (max 63 characters)").regex(/^[a-z][a-z0-9-]*$/, {
4995
4899
  message: "Invalid workflow name format.\nName must be in kebab-case:\n \u2705 Valid: 'client-onboarding', 'contract-signature'\n \u274C Invalid: 'ClientOnboarding', 'contract_signature'"
4996
4900
  });
4997
4901
  try {
4998
4902
  schema.parse(name);
4999
4903
  } catch (error) {
5000
- if (error instanceof z4.ZodError) {
4904
+ if (error instanceof z.ZodError) {
5001
4905
  throw new Error(`[WorkflowBuilder] ${error.issues[0].message}`);
5002
4906
  }
5003
4907
  throw error;
@@ -6228,321 +6132,161 @@ function isViewCustomized(view2, object2) {
6228
6132
  }
6229
6133
  return true;
6230
6134
  }
6231
- export {
6232
- AINodeSchema,
6233
- ALL_ACTIONS,
6234
- ALL_SYSTEM_RESOURCES,
6235
- ActivityTabConfig,
6236
- AssignNodeSchema,
6237
- AssignmentMappingSchema,
6238
- AssignmentSourceSchema,
6239
- AttributeInUseError,
6240
- AttributeNotFoundError,
6241
- AuthMethodSchema,
6242
- BEHAVIOR_PROPERTIES,
6243
- ConcurrentModificationError,
6244
- ConditionGroupSchema,
6245
- ConditionNodeSchema,
6246
- ConditionOperatorSchema,
6247
- ConditionRuleSchema,
6248
- CreateShareInputSchema,
6249
- CustomTabConfig,
6250
- DEFAULT_LABEL_FALLBACK,
6251
- DEFAULT_RETENTION_POLICY,
6252
- DEFAULT_ROLES,
6253
- DEFAULT_ROLE_DESCRIPTIONS,
6254
- DEFAULT_ROLE_FOR_NEW_USERS,
6255
- DEFAULT_ROLE_LABELS,
6256
- DEFAULT_ROLE_PERMISSIONS,
6257
- DEFAULT_THEME,
6258
- DEFAULT_VALIDATION_MESSAGES,
6259
- DetailViewBuilder,
6260
- DocumentsTabConfig,
6261
- DuplicateError,
6262
- EMPTY_VALUE_PLACEHOLDER,
6263
- EndNodeSchema,
6264
- FORBIDDEN_PROPERTY_TYPES,
6265
- FileNotFoundError,
6266
- FlagRegistry,
6267
- FlagService,
6268
- FlowRowFieldSchema,
6269
- FlowRowSchema,
6270
- FlowsTabConfig,
6271
- ForbiddenError,
6272
- FormFieldRefSchema,
6273
- FormNodeSchema,
6274
- GroupBuilder,
6275
- IDENTITY_PROPERTIES,
6276
- ListViewBuilder,
6277
- ListViewTabConfigBuilder,
6278
- NON_SORTABLE_TYPES,
6279
- NO_VALUE_OPERATORS,
6280
- NodePositionSchema,
6281
- NoopGeocodingAdapter,
6282
- NotFoundError,
6283
- NotSystemObjectError,
6284
- OPERATORS_BY_TYPE,
6285
- ObjectBuilder,
6286
- ObjectNotFoundError,
6287
- ObjectReferencedError,
6288
- PRESENTATION_PROPERTIES,
6289
- PolicyViolationError,
6290
- ProtectedResourceError,
6291
- ProtectedRoleError,
6292
- RELATION_TARGET_ANY,
6293
- RESERVED_ATTRIBUTE_NAMES,
6294
- RecordNotFoundError,
6295
- RecordReferencedError,
6296
- RelationGroupBuilder,
6297
- RichtextTabConfig,
6298
- RoleNotFoundError,
6299
- SYSTEM_ATTRIBUTES,
6300
- SYSTEM_FIELD_NAMES,
6301
- SYSTEM_RESOURCES,
6302
- SYSTEM_RESOURCE_LABELS,
6303
- SchemaError,
6304
- SchemaErrorCode,
6305
- ShareStatusSchema,
6306
- SlotModeSchema,
6307
- StartNodeSchema,
6308
- SyncError,
6309
- TabBuilder,
6310
- TableTabConfig,
6311
- ThemeColorsSchema,
6312
- ThemeLogoSchema,
6313
- USER_STATUSES,
6314
- UserProfileNotFoundError,
6315
- ValidationError,
6316
- ViewBuilder,
6317
- ViewportSchema,
6318
- WorkflowAIBuilder,
6319
- WorkflowAssignBuilder,
6320
- WorkflowBuilder,
6321
- WorkflowConditionBuilder,
6322
- WorkflowConfigSchema,
6323
- WorkflowDefinitionSchema,
6324
- WorkflowEndBuilder,
6325
- WorkflowFormBuilder,
6326
- WorkflowFormRowBuilder,
6327
- WorkflowLayoutSchema,
6328
- WorkflowNodeSchema,
6329
- WorkflowShareSchema,
6330
- WorkflowSimpleFormBuilder,
6331
- WorkflowSlotSchema,
6332
- WorkflowStartBuilder,
6333
- WorkflowStatusSchema,
6334
- WorkflowThemeSchema,
6335
- ZONE_CONFIG,
6336
- ZONE_ORDER,
6337
- accessLevelToActions,
6338
- actionsToAccessLevel,
6339
- and,
6340
- applyRelationProps,
6341
- asTenantId,
6342
- asUserId,
6343
- assignNodeZones,
6344
- attributeConfigSchemas,
6345
- booleanFlag,
6346
- canAccessNode,
6347
- canResumeInstance,
6348
- checkbox,
6349
- checkboxConfigSchema,
6350
- computeRecordStatus,
6351
- createAttributeValidator,
6352
- createCheckboxValidator,
6353
- createCurrencyValidator,
6354
- createDateValidator,
6355
- createDraftValidator,
6356
- createEmptyContext,
6357
- createFileValidator,
6358
- createFlagRegistry,
6359
- createFlagService,
6360
- createFormAttributeValidator,
6361
- createFormulaValidator,
6362
- createLocationValidator,
6363
- createMultiRelationValidator,
6364
- createMultiselectValidator,
6365
- createNumberValidator,
6366
- createObjectValidator,
6367
- createPhoneValidator,
6368
- createRatingValidator,
6369
- createRelationValidator,
6370
- createRichtextValidator,
6371
- createRollupValidator,
6372
- createSelectValidator,
6373
- createSingleRelationValidator,
6374
- createStartTransition,
6375
- createStatusValidator,
6376
- createTextAreaValidator,
6377
- createTextValidator,
6378
- createUserValidator,
6379
- currency,
6380
- currencyConfigSchema,
6381
- date,
6382
- dateConfigSchema,
6383
- deepEqual,
6384
- detailView,
6385
- document,
6386
- documentConfigSchema,
6387
- eq,
6388
- extractAttributeNames,
6389
- file,
6390
- fileConfigSchema,
6391
- flagRegistry,
6392
- formatAttributeValue,
6393
- formatPhoneForDisplay,
6394
- formatZodErrors,
6395
- formula,
6396
- formulaConfigSchema,
6397
- generateCssVariables,
6398
- generateDefaultDetailView,
6399
- generateDefaultListView,
6400
- generateFallbackView,
6401
- generateId,
6402
- generatePrefixedId,
6403
- generateTemplateName,
6404
- getActiveTab,
6405
- getAttributeConfigSchema,
6406
- getContextValue,
6407
- getErrorMessage,
6408
- getFormFieldRefs,
6409
- getMissingRequiredAttributes,
6410
- getNodeOutputs,
6411
- getNodeSlotIds,
6412
- getRollupFilterOperators,
6413
- getSystemAttributeList,
6414
- getZoneAllowedTypes,
6415
- group,
6416
- groupNodesByZone,
6417
- hasOptions,
6418
- hasProperties,
6419
- inValues,
6420
- indexBy,
6421
- inferInverseCardinality,
6422
- isAINode,
6423
- isActivityTab,
6424
- isAdvancedFormNode,
6425
- isAssignNode,
6426
- isAttributeSortable,
6427
- isBehaviorProperty,
6428
- isBilateralRelation,
6429
- isCalendarView,
6430
- isConditionGroup,
6431
- isConditionNode,
6432
- isConditionRule,
6433
- isCustomTab,
6434
- isDefaultRole,
6435
- isDetailView,
6436
- isDocumentsTab,
6437
- isEmpty2 as isEmpty,
6438
- isEndNode,
6439
- isFieldGroup,
6440
- isFlowDefinition,
6441
- isFlowFieldsRow,
6442
- isFlowPublished,
6443
- isFlowRelationListRow,
6444
- isFlowsTab,
6445
- isForbiddenError,
6446
- isFormFieldsRow,
6447
- isFormNode,
6448
- isFormTab,
6449
- isGalleryView,
6450
- isGrantExpired,
6451
- isGrantRevoked,
6452
- isGrantValid,
6453
- isIdentityProperty,
6454
- isInstanceEvent,
6455
- isInstanceTerminal,
6456
- isInstanceWaiting,
6457
- isInverseSourceTab,
6458
- isInvitationAccepted,
6459
- isInvitationExpired,
6460
- isInvitationOrGrantEvent,
6461
- isInvitationValid,
6462
- isLabelExpression,
6463
- isLayoutRow,
6464
- isListView,
6465
- isNoValueOperator,
6466
- isNodeEvent,
6467
- isNotEmpty2 as isNotEmpty,
6468
- isNotFoundError,
6469
- isPresentationProperty,
6470
- isProtectedResourceError,
6471
- isRecordComplete,
6472
- isRelationGroup,
6473
- isRelationSourceTab,
6474
- isRichtextTab,
6475
- isSchemaError,
6476
- isSimpleFormNode,
6477
- isStartNode,
6478
- isSystemAttribute,
6479
- isSystemAttributeObject,
6480
- isSystemFlow,
6481
- isSystemWorkflow,
6482
- isTableTab,
6483
- isTimelineView,
6484
- isTokenRevoked,
6485
- isUniversalRelation,
6486
- isValidationError,
6487
- isViewCustomized,
6488
- isWorkflowDefinition,
6489
- isWorkflowPublished,
6490
- jsonFlag,
6491
- listView,
6492
- location,
6493
- locationConfigSchema,
6494
- mergeWithDefaults,
6495
- multiselect,
6496
- multiselectConfigSchema,
6497
- neq,
6498
- nodeTypeRegistry,
6499
- normalizePhoneNumber,
6500
- number,
6501
- numberConfigSchema,
6502
- numberFlag,
6503
- object,
6504
- or,
6505
- parseAttributeConfig,
6506
- parseRawPhoneInput,
6507
- phone,
6508
- phoneConfigSchema,
6509
- rating,
6510
- ratingConfigSchema,
6511
- registry,
6512
- relation,
6513
- relationConfigSchema,
6514
- relationGroup,
6515
- renderLabelExpression,
6516
- resetViewToDefault,
6517
- richtext,
6518
- richtextConfigSchema,
6519
- rollup,
6520
- rollupConfigSchema,
6521
- safeParseAttributeConfig,
6522
- select,
6523
- selectConfigSchema,
6524
- setContextValue,
6525
- setNodeNext,
6526
- slugify,
6527
- status,
6528
- statusConfigSchema,
6529
- stringFlag,
6530
- text,
6531
- textConfigSchema,
6532
- textarea,
6533
- textareaConfigSchema,
6534
- toUndefinedIfEmpty,
6535
- user,
6536
- userConfigSchema,
6537
- validateAttribute,
6538
- validateAttributeConfig,
6539
- validateDraft,
6540
- validateDraftOrThrow,
6541
- validateNode,
6542
- validateObject,
6543
- validateObjectOrThrow,
6544
- validatePhoneNumber,
6545
- view,
6546
- viewRegistry,
6547
- workflow
6548
- };
6135
+ function objectToJSONSchema(objectDef) {
6136
+ const properties = {};
6137
+ const required = [];
6138
+ for (const attr of objectDef.attributes) {
6139
+ properties[attr.name] = attributeToJSONSchema(attr);
6140
+ if (attr.required) {
6141
+ required.push(attr.name);
6142
+ }
6143
+ }
6144
+ return {
6145
+ type: "object",
6146
+ title: objectDef.label,
6147
+ properties,
6148
+ required
6149
+ };
6150
+ }
6151
+ function attributeToJSONSchema(attr) {
6152
+ const base = {
6153
+ type: "string",
6154
+ title: attr.label
6155
+ };
6156
+ if (attr.description) {
6157
+ base.description = attr.description;
6158
+ }
6159
+ if (attr.placeholder) {
6160
+ base.examples = [attr.placeholder];
6161
+ }
6162
+ switch (attr.type) {
6163
+ case "text":
6164
+ case "textarea":
6165
+ base.type = "string";
6166
+ if ("minLength" in attr && attr.minLength !== void 0) {
6167
+ base.minLength = attr.minLength;
6168
+ }
6169
+ if ("maxLength" in attr && attr.maxLength !== void 0) {
6170
+ base.maxLength = attr.maxLength;
6171
+ }
6172
+ if ("pattern" in attr && attr.pattern) {
6173
+ base.pattern = attr.pattern;
6174
+ }
6175
+ break;
6176
+ case "richtext":
6177
+ base.type = "string";
6178
+ base.format = "html";
6179
+ break;
6180
+ case "number":
6181
+ case "rating":
6182
+ base.type = "number";
6183
+ if ("min" in attr && attr.min !== void 0) {
6184
+ base.minimum = attr.min;
6185
+ }
6186
+ if ("max" in attr && attr.max !== void 0) {
6187
+ base.maximum = attr.max;
6188
+ }
6189
+ break;
6190
+ case "checkbox":
6191
+ base.type = "boolean";
6192
+ break;
6193
+ case "date":
6194
+ base.type = "string";
6195
+ base.format = "date-time";
6196
+ break;
6197
+ case "phone":
6198
+ base.type = "object";
6199
+ break;
6200
+ case "currency":
6201
+ base.type = "object";
6202
+ break;
6203
+ case "select":
6204
+ case "status":
6205
+ base.type = "string";
6206
+ if ("options" in attr && Array.isArray(attr.options)) {
6207
+ base.enum = attr.options.map((opt) => opt.value);
6208
+ }
6209
+ break;
6210
+ case "multiselect":
6211
+ base.type = "array";
6212
+ if ("options" in attr && Array.isArray(attr.options)) {
6213
+ base.items = {
6214
+ type: "string",
6215
+ enum: attr.options.map((opt) => opt.value)
6216
+ };
6217
+ }
6218
+ break;
6219
+ case "file":
6220
+ if ("multiple" in attr && attr.multiple) {
6221
+ base.type = "array";
6222
+ base.items = { type: "string", format: "uuid" };
6223
+ } else {
6224
+ base.type = "string";
6225
+ base.format = "uuid";
6226
+ }
6227
+ break;
6228
+ case "user":
6229
+ if ("multiple" in attr && attr.multiple) {
6230
+ base.type = "array";
6231
+ base.items = { type: "string", format: "uuid" };
6232
+ } else {
6233
+ base.type = "string";
6234
+ base.format = "uuid";
6235
+ }
6236
+ break;
6237
+ case "relation":
6238
+ if ("cardinality" in attr && attr.cardinality === "many") {
6239
+ base.type = "array";
6240
+ if ("targets" in attr && Array.isArray(attr.targets) && attr.targets.length > 0) {
6241
+ base.description ?? (base.description = `References to ${attr.targets[0].object}`);
6242
+ }
6243
+ base.items = { type: "string", format: "uuid" };
6244
+ } else {
6245
+ base.type = "string";
6246
+ base.format = "uuid";
6247
+ if ("targets" in attr && Array.isArray(attr.targets) && attr.targets.length > 0) {
6248
+ base.description ?? (base.description = `Reference to ${attr.targets[0].object}`);
6249
+ }
6250
+ }
6251
+ break;
6252
+ case "location":
6253
+ base.type = "object";
6254
+ break;
6255
+ case "formula":
6256
+ case "rollup":
6257
+ base.type = "string";
6258
+ if ("returnType" in attr) {
6259
+ switch (attr.returnType) {
6260
+ case "number":
6261
+ base.type = "number";
6262
+ break;
6263
+ case "boolean":
6264
+ base.type = "boolean";
6265
+ break;
6266
+ case "date":
6267
+ base.type = "string";
6268
+ base.format = "date-time";
6269
+ break;
6270
+ }
6271
+ }
6272
+ break;
6273
+ case "document":
6274
+ if ("multiple" in attr && attr.multiple) {
6275
+ base.type = "array";
6276
+ base.items = { type: "string", format: "uuid" };
6277
+ } else {
6278
+ base.type = "string";
6279
+ base.format = "uuid";
6280
+ }
6281
+ break;
6282
+ default:
6283
+ base.type = "string";
6284
+ }
6285
+ return base;
6286
+ }
6287
+ function objectValidatorToJSONSchema(objectDef) {
6288
+ const validator = createObjectValidator(objectDef);
6289
+ return z.toJSONSchema(validator);
6290
+ }
6291
+
6292
+ export { ALL_ACTIONS, ALL_PIPES, ALL_SYSTEM_RESOURCES, AccessDeniedError, ActivityTabConfig, AttributeInUseError, AttributeNotFoundError, AuthMethodSchema, BEHAVIOR_PROPERTIES, ConcurrentModificationError, ConditionGroupSchema, ConditionNodeSchema, ConditionOperatorSchema, ConditionRuleSchema, CreateShareInputSchema, CustomTabConfig, DEFAULT_LABEL_FALLBACK, DEFAULT_RETENTION_POLICY, DEFAULT_ROLES, DEFAULT_ROLE_DESCRIPTIONS, DEFAULT_ROLE_FOR_NEW_USERS, DEFAULT_ROLE_LABELS, DEFAULT_ROLE_PERMISSIONS, DEFAULT_THEME, DetailViewBuilder, DocumentsTabConfig, DuplicateError, EMPTY_VALUE_PLACEHOLDER, EndNodeSchema, FORBIDDEN_PROPERTY_TYPES, FileNotFoundError, FlagRegistry, FlagService, FlowRowFieldSchema, FlowRowSchema, FlowsTabConfig, ForbiddenError, FormFieldRefSchema, FormNodeSchema, GroupBuilder, IDENTITY_PROPERTIES, ListViewBuilder, ListViewTabConfigBuilder, MemoryNotFoundError, NON_SORTABLE_TYPES, NO_VALUE_OPERATORS, NodePositionSchema, NoopGeocodingAdapter, NotFoundError, NotImplementedError, NotSystemObjectError, OPERATORS_BY_TYPE, ObjectBuilder, ObjectNotFoundError, ObjectReferencedError, PIPES_WITH_ARGS, PRESENTATION_PROPERTIES, PolicyViolationError, ProtectedResourceError, ProtectedRoleError, RELATION_TARGET_ANY, RESERVED_ATTRIBUTE_NAMES, RecordNotFoundError, RecordReferencedError, RelationGroupBuilder, RepositoryError, RichtextTabConfig, RoleNotFoundError, SIMPLE_PIPES, STANDARD_SCHEMA_VENDOR, SYSTEM_ATTRIBUTES, SYSTEM_FIELD_NAMES, SYSTEM_RESOURCES, SYSTEM_RESOURCE_LABELS, SchemaError, SchemaErrorCode, ShareStatusSchema, SlotModeSchema, StartNodeSchema, StorageError, SyncError, TabBuilder, TableTabConfig, ThemeColorsSchema, ThemeLogoSchema, USER_STATUSES, UserProfileNotFoundError, ValidationError, ViewBuilder, ViewportSchema, WorkflowBuilder, WorkflowConditionBuilder, WorkflowConfigSchema, WorkflowDefinitionSchema, WorkflowEndBuilder, WorkflowFormBuilder, WorkflowFormRowBuilder, WorkflowLayoutSchema, WorkflowNodeSchema, WorkflowShareSchema, WorkflowSimpleFormBuilder, WorkflowSlotSchema, WorkflowStartBuilder, WorkflowStatusSchema, WorkflowThemeSchema, ZONE_CONFIG, ZONE_ORDER, accessLevelToActions, actionsToAccessLevel, and, applyRelationProps, assignNodeZones, booleanFlag, canAccessNode, canResumeInstance, checkbox, createEmptyContext, createFlagRegistry, createFlagService, createStandardSchemaProps, createStartTransition, currency, date, detailView, document, eq, extractAttributeNames, file, flagRegistry, formatAttributeValue, formula, generateCssVariables, generateDefaultDetailView, generateDefaultListView, generateFallbackView, getActiveTab, getContextValue, getErrorMessage, getFormFieldRefs, getNodeOutputs, getNodeSlotIds, getRollupFilterOperators, getSystemAttributeList, getZoneAllowedTypes, group, groupNodesByZone, hasOptions, hasProperties, inValues, inferInverseCardinality, isAccessDeniedError, isActivityTab, isAdvancedFormNode, isAttributeSortable, isBehaviorProperty, isBilateralRelation, isCalendarView, isConditionGroup, isConditionNode, isConditionRule, isCustomTab, isDefaultRole, isDetailView, isDocumentsTab, isEmpty2 as isEmpty, isEndNode, isFieldGroup, isFlowDefinition, isFlowFieldsRow, isFlowPublished, isFlowRelationListRow, isFlowsTab, isForbiddenError, isFormFieldsRow, isFormNode, isFormTab, isGalleryView, isGrantExpired, isGrantRevoked, isGrantValid, isIdentityProperty, isInstanceEvent, isInstanceTerminal, isInstanceWaiting, isInverseSourceTab, isInvitationAccepted, isInvitationExpired, isInvitationOrGrantEvent, isInvitationValid, isLabelExpression, isLayoutRow, isListView, isNoValueOperator, isNodeEvent, isNotEmpty2 as isNotEmpty, isNotFoundError, isNotImplementedError, isPresentationProperty, isProtectedResourceError, isRelationGroup, isRelationSourceTab, isRepositoryError, isRichtextTab, isSchemaError, isSimpleFormNode, isStandardSchema, isStartNode, isStorageError, isSystemAttribute, isSystemAttributeObject, isSystemFlow, isSystemWorkflow, isTableTab, isTimelineView, isTokenRevoked, isUniversalRelation, isValidationError, isViewCustomized, isWorkflowDefinition, isWorkflowPublished, jsonFlag, labelExpressionSchema, listView, location, mergeWithDefaults, multiselect, neq, nodeTypeRegistry, number, numberFlag, object, objectToJSONSchema, objectValidatorToJSONSchema, or, phone, rating, registerBuiltInNodeTypes, registry, relation, relationGroup, renderLabelExpression, resetViewToDefault, richtext, rollup, select, setContextValue, setNodeNext, status, stringFlag, text, textarea, toUndefinedIfEmpty, user, validateLabelExpression, validateNode, view, viewRegistry, workflow };