@standards/schema 0.0.0-stage → 1.0.0-alpha.382

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 (133) hide show
  1. package/LICENSE +111 -0
  2. package/README.md +8 -2
  3. package/dist/all-BgYwavNm.d.mts +2956 -0
  4. package/dist/all-DjdKldjX.d.ts +2956 -0
  5. package/dist/api/index.d.mts +11838 -0
  6. package/dist/api/index.d.ts +11838 -0
  7. package/dist/api/index.js +2 -0
  8. package/dist/api/index.mjs +2 -0
  9. package/dist/attribute-validators-DRqhAt2t.mjs +11 -0
  10. package/dist/attribute-validators-WAoJbap5.js +11 -0
  11. package/dist/attributes-aTeqx6cK.d.mts +557 -0
  12. package/dist/attributes-kAhQzg8-.d.ts +557 -0
  13. package/dist/checkbox-BZvZOraX.d.mts +11 -0
  14. package/dist/checkbox-n0YV1O13.d.ts +11 -0
  15. package/dist/config-BIxnbUN8.mjs +2 -0
  16. package/dist/config-DdjlHdPg.js +2 -0
  17. package/dist/core-397tQy5q.js +2 -0
  18. package/dist/core-BLHhNykL.mjs +2 -0
  19. package/dist/date-CxqDOhA0.d.mts +24 -0
  20. package/dist/date-D007KyTI.d.ts +24 -0
  21. package/dist/exceptions-DjPVyS-Q.d.mts +761 -0
  22. package/dist/exceptions-DjPVyS-Q.d.ts +761 -0
  23. package/dist/exceptions.d.mts +3 -0
  24. package/dist/exceptions.d.ts +3 -0
  25. package/dist/exceptions.js +2 -0
  26. package/dist/exceptions.mjs +2 -0
  27. package/dist/index-3HZjBOpj.d.mts +53 -0
  28. package/dist/index-BmNMneu3.d.mts +278 -0
  29. package/dist/index-Bu9xF5Nq.d.ts +278 -0
  30. package/dist/index-CiTBL4gH.d.ts +101 -0
  31. package/dist/index-D7TEaPqX.d.ts +16519 -0
  32. package/dist/index-DLO8JpnY.d.ts +53 -0
  33. package/dist/index-DPO5w-fC.d.mts +101 -0
  34. package/dist/index-DwQWBzYJ.d.mts +16519 -0
  35. package/dist/index.d.mts +15 -0
  36. package/dist/index.d.ts +15 -0
  37. package/dist/index.js +2 -0
  38. package/dist/index.mjs +2 -0
  39. package/dist/number-CgBxEbjI.d.mts +11 -0
  40. package/dist/number-DncH-WRO.d.ts +11 -0
  41. package/dist/object-DcgxLvip.js +4 -0
  42. package/dist/object-Dzl7sfq8.mjs +4 -0
  43. package/dist/objects-B4DgFZ82.d.ts +398 -0
  44. package/dist/objects-C9f6hFW_.d.mts +398 -0
  45. package/dist/phone-BB-tzcSr.js +2 -0
  46. package/dist/phone-Bca_xiOX.mjs +2 -0
  47. package/dist/record-aggregates-CzG86pUS.mjs +2 -0
  48. package/dist/record-aggregates-DwpIJ2Dv.js +2 -0
  49. package/dist/record-operation-BSXczk7v.js +2 -0
  50. package/dist/record-operation-C9oXHmfF.mjs +2 -0
  51. package/dist/text-A9AJ1wUO.js +2 -0
  52. package/dist/text-C8Lb-NFo.mjs +2 -0
  53. package/dist/text-DDoY_LcQ.d.ts +11 -0
  54. package/dist/text-DeUqCFp9.d.mts +11 -0
  55. package/dist/utils-B7Dlrtnx.d.ts +163 -0
  56. package/dist/utils-DbRMK8NI.d.mts +163 -0
  57. package/dist/utils-fXIvFFl6.mjs +2 -0
  58. package/dist/utils-gY3d9Dwp.js +2 -0
  59. package/dist/utils.d.mts +3 -0
  60. package/dist/utils.d.ts +3 -0
  61. package/dist/utils.js +2 -0
  62. package/dist/utils.mjs +2 -0
  63. package/dist/validation/all.d.mts +6 -0
  64. package/dist/validation/all.d.ts +6 -0
  65. package/dist/validation/all.js +2 -0
  66. package/dist/validation/all.mjs +2 -0
  67. package/dist/validation/complex/currency.d.mts +13 -0
  68. package/dist/validation/complex/currency.d.ts +13 -0
  69. package/dist/validation/complex/currency.js +2 -0
  70. package/dist/validation/complex/currency.mjs +2 -0
  71. package/dist/validation/complex/location.d.mts +20 -0
  72. package/dist/validation/complex/location.d.ts +20 -0
  73. package/dist/validation/complex/location.js +2 -0
  74. package/dist/validation/complex/location.mjs +2 -0
  75. package/dist/validation/complex/phone.d.mts +20 -0
  76. package/dist/validation/complex/phone.d.ts +20 -0
  77. package/dist/validation/complex/phone.js +2 -0
  78. package/dist/validation/complex/phone.mjs +2 -0
  79. package/dist/validation/complex/relation.d.mts +23 -0
  80. package/dist/validation/complex/relation.d.ts +23 -0
  81. package/dist/validation/complex/relation.js +2 -0
  82. package/dist/validation/complex/relation.mjs +2 -0
  83. package/dist/validation/complex/richtext.d.mts +11 -0
  84. package/dist/validation/complex/richtext.d.ts +11 -0
  85. package/dist/validation/complex/richtext.js +2 -0
  86. package/dist/validation/complex/richtext.mjs +2 -0
  87. package/dist/validation/complex/select.d.mts +18 -0
  88. package/dist/validation/complex/select.d.ts +18 -0
  89. package/dist/validation/complex/select.js +2 -0
  90. package/dist/validation/complex/select.mjs +2 -0
  91. package/dist/validation/complex/user.d.mts +11 -0
  92. package/dist/validation/complex/user.d.ts +11 -0
  93. package/dist/validation/complex/user.js +2 -0
  94. package/dist/validation/complex/user.mjs +2 -0
  95. package/dist/validation/computed/formula.d.mts +12 -0
  96. package/dist/validation/computed/formula.d.ts +12 -0
  97. package/dist/validation/computed/formula.js +2 -0
  98. package/dist/validation/computed/formula.mjs +2 -0
  99. package/dist/validation/computed/rollup.d.mts +12 -0
  100. package/dist/validation/computed/rollup.d.ts +12 -0
  101. package/dist/validation/computed/rollup.js +2 -0
  102. package/dist/validation/computed/rollup.mjs +2 -0
  103. package/dist/validation/config/index.d.mts +3 -0
  104. package/dist/validation/config/index.d.ts +3 -0
  105. package/dist/validation/config/index.js +2 -0
  106. package/dist/validation/config/index.mjs +2 -0
  107. package/dist/validation/core/index.d.mts +3 -0
  108. package/dist/validation/core/index.d.ts +3 -0
  109. package/dist/validation/core/index.js +2 -0
  110. package/dist/validation/core/index.mjs +2 -0
  111. package/dist/validation/object/index.d.mts +3 -0
  112. package/dist/validation/object/index.d.ts +3 -0
  113. package/dist/validation/object/index.js +2 -0
  114. package/dist/validation/object/index.mjs +2 -0
  115. package/dist/validation/primitives/checkbox.d.mts +3 -0
  116. package/dist/validation/primitives/checkbox.d.ts +3 -0
  117. package/dist/validation/primitives/checkbox.js +2 -0
  118. package/dist/validation/primitives/checkbox.mjs +2 -0
  119. package/dist/validation/primitives/date.d.mts +3 -0
  120. package/dist/validation/primitives/date.d.ts +3 -0
  121. package/dist/validation/primitives/date.js +2 -0
  122. package/dist/validation/primitives/date.mjs +2 -0
  123. package/dist/validation/primitives/number.d.mts +3 -0
  124. package/dist/validation/primitives/number.d.ts +3 -0
  125. package/dist/validation/primitives/number.js +2 -0
  126. package/dist/validation/primitives/number.mjs +2 -0
  127. package/dist/validation/primitives/text.d.mts +3 -0
  128. package/dist/validation/primitives/text.d.ts +3 -0
  129. package/dist/validation/primitives/text.js +2 -0
  130. package/dist/validation/primitives/text.mjs +2 -0
  131. package/dist/view-config.schema-BQ9tU_9G.js +2 -0
  132. package/dist/view-config.schema-BmjCQJ51.mjs +2 -0
  133. package/package.json +279 -3
@@ -0,0 +1,53 @@
1
+
2
+ import { n as Attribute } from "./attributes-kAhQzg8-.js";
3
+ import { z as z$1 } from "zod";
4
+ //#region src/validation/core/types.d.ts
5
+ /**
6
+ * Validation messages for Zod validators.
7
+ * All functions receive the full Attribute to access label, type, etc.
8
+ * Can be customized for i18n support.
9
+ */
10
+ interface ValidationMessages {
11
+ required: (attr: Attribute) => string;
12
+ invalidType: (attr: Attribute, expected: string) => string;
13
+ minLength: (attr: Attribute, min: number) => string;
14
+ maxLength: (attr: Attribute, max: number) => string;
15
+ invalidPattern: (attr: Attribute) => string;
16
+ minValue: (attr: Attribute, min: number) => string;
17
+ maxValue: (attr: Attribute, max: number) => string;
18
+ mustBeInteger: (attr: Attribute) => string;
19
+ invalidDate: (attr: Attribute) => string;
20
+ invalidOption: (attr: Attribute, options: string[]) => string;
21
+ invalidId: (attr: Attribute) => string;
22
+ maxItems: (attr: Attribute, max: number) => string;
23
+ invalidRichtext: (attr: Attribute) => string;
24
+ invalidPhone: (attr: Attribute) => string;
25
+ invalidCurrency: (attr: Attribute) => string;
26
+ invalidLocation: (attr: Attribute) => string;
27
+ }
28
+ /**
29
+ * Validation result
30
+ */
31
+ interface ValidationResult {
32
+ success: boolean;
33
+ data?: Record<string, unknown>;
34
+ errors?: Array<{
35
+ path: string[];
36
+ message: string;
37
+ }>;
38
+ }
39
+ //#endregion
40
+ //#region src/validation/core/messages.d.ts
41
+ declare const DEFAULT_VALIDATION_MESSAGES: ValidationMessages;
42
+ //#endregion
43
+ //#region src/validation/core/errors.d.ts
44
+ /**
45
+ * Format Zod validation errors into a consistent structure.
46
+ * This eliminates code duplication across multiple validation functions.
47
+ */
48
+ declare function formatZodErrors(error: z$1.ZodError): Array<{
49
+ path: string[];
50
+ message: string;
51
+ }>;
52
+ //#endregion
53
+ export { ValidationResult as i, DEFAULT_VALIDATION_MESSAGES as n, ValidationMessages as r, formatZodErrors as t };
@@ -0,0 +1,101 @@
1
+
2
+ import { i as ObjectDefinition } from "./objects-C9f6hFW_.mjs";
3
+ import { n as Attribute } from "./attributes-aTeqx6cK.mjs";
4
+ import { i as ValidationResult, r as ValidationMessages } from "./index-3HZjBOpj.mjs";
5
+ import { z as z$1 } from "zod";
6
+ //#region src/validation/object/attribute-factory.d.ts
7
+ /**
8
+ * Create a Zod schema for any attribute type.
9
+ * Returns a strict validator that does NOT handle optional fields.
10
+ * Use createFormAttributeValidator for form validation with optional support.
11
+ *
12
+ * @param attr - The attribute to create a validator for
13
+ * @param messages - Custom validation messages for i18n support
14
+ */
15
+ declare function createAttributeValidator(attr: Attribute, messages?: ValidationMessages): z$1.ZodTypeAny;
16
+ /**
17
+ * Create a Zod schema for form validation.
18
+ * - Normalizes empty values (empty strings, empty objects) to null for optional fields
19
+ * - Accepts custom messages for i18n support
20
+ *
21
+ * Use this in UI forms where optional fields may have null/undefined values.
22
+ *
23
+ * @param attr - The attribute to create a validator for
24
+ * @param messages - Custom validation messages for i18n support
25
+ */
26
+ declare function createFormAttributeValidator(attr: Attribute, messages?: ValidationMessages): z$1.ZodTypeAny;
27
+ //#endregion
28
+ //#region src/validation/object/object-validator.d.ts
29
+ /**
30
+ * Create a Zod schema for an entire object
31
+ *
32
+ * Uses passthrough mode to allow computed fields (formula, rollup) that may be
33
+ * present in record data but are not part of the mutable schema.
34
+ *
35
+ * Result is cached per ObjectDefinition instance — safe because ObjectDefinitions
36
+ * are stable after module load and never mutated at runtime.
37
+ */
38
+ declare function createObjectValidator(objectDef: ObjectDefinition): z$1.ZodType<Record<string, unknown>>;
39
+ /**
40
+ * Create a Zod schema for draft validation.
41
+ * All attributes become optional, but provided values are still validated.
42
+ *
43
+ * Uses passthrough mode to allow computed fields (formula, rollup) that may be
44
+ * present in record data but are not part of the mutable schema.
45
+ *
46
+ * Result is cached per ObjectDefinition instance — safe because ObjectDefinitions
47
+ * are stable after module load and never mutated at runtime.
48
+ */
49
+ declare function createDraftValidator(objectDef: ObjectDefinition): z$1.ZodType<Record<string, unknown>>;
50
+ //#endregion
51
+ //#region src/validation/object/helpers.d.ts
52
+ /**
53
+ * Validate data against an attribute schema
54
+ */
55
+ declare function validateAttribute(attr: Attribute, value: unknown): ValidationResult;
56
+ /**
57
+ * Validate data against an object schema
58
+ */
59
+ declare function validateObject(objectDef: ObjectDefinition, data: Record<string, unknown>): ValidationResult;
60
+ /**
61
+ * Validate and throw if invalid.
62
+ *
63
+ * Throws `ValidationError` (code `SCHEMA_VALIDATION_FAILED`) on failure so HTTP
64
+ * adapters can map it to 400. Generic `Error` would bubble up to a 500.
65
+ */
66
+ declare function validateObjectOrThrow(objectDef: ObjectDefinition, data: Record<string, unknown>): Record<string, unknown>;
67
+ /**
68
+ * Validate data in draft mode.
69
+ * - All attributes are treated as optional (no required validation)
70
+ * - Provided values are still validated for format/type correctness
71
+ */
72
+ declare function validateDraft(objectDef: ObjectDefinition, data: Record<string, unknown>): ValidationResult;
73
+ /**
74
+ * Validate draft data and throw if format validation fails.
75
+ *
76
+ * Same contract as `validateObjectOrThrow` but skips `required()` checks.
77
+ * Throws `ValidationError` so HTTP adapters map it to 400.
78
+ */
79
+ declare function validateDraftOrThrow(objectDef: ObjectDefinition, data: Record<string, unknown>): Record<string, unknown>;
80
+ /**
81
+ * Throw a `ValidationError` when `data` contains keys that do not correspond
82
+ * to any attribute declared on `objectDef`.
83
+ *
84
+ * Call this on **client-supplied input** before Zod validation so the error
85
+ * message clearly names every offending key. Do NOT call on merged data that
86
+ * includes existing record values — older records may legitimately carry stale
87
+ * keys that predate this guard (see issue #658).
88
+ *
89
+ * Maps to HTTP 400 via `SchemaExceptionFilter` (code SCHEMA_VALIDATION_FAILED).
90
+ */
91
+ declare function rejectUnknownAttributesOrThrow(objectDef: ObjectDefinition, data: Record<string, unknown>): void;
92
+ /**
93
+ * Get the list of required attributes that are missing values.
94
+ */
95
+ declare function getMissingRequiredAttributes(objectDef: ObjectDefinition, data: Record<string, unknown>): Attribute[];
96
+ /**
97
+ * Check if a record is complete (all required attributes have valid values).
98
+ */
99
+ declare function isRecordComplete(objectDef: ObjectDefinition, data: Record<string, unknown>): boolean;
100
+ //#endregion
101
+ export { validateDraft as a, validateObjectOrThrow as c, createAttributeValidator as d, createFormAttributeValidator as f, validateAttribute as i, createDraftValidator as l, isRecordComplete as n, validateDraftOrThrow as o, rejectUnknownAttributesOrThrow as r, validateObject as s, getMissingRequiredAttributes as t, createObjectValidator as u };