@stndrds/schema 1.0.0-alpha.294 → 1.0.0-alpha.295

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 (127) hide show
  1. package/LICENSE +111 -0
  2. package/README.md +7 -0
  3. package/dist/capabilities.js +2 -77
  4. package/dist/capabilities.mjs +2 -70
  5. package/dist/chunk-23KPS33D.js +2 -0
  6. package/dist/chunk-257HAQVV.mjs +6 -0
  7. package/dist/chunk-47KVYDKG.js +2 -0
  8. package/dist/chunk-4OTKOCGB.mjs +2 -0
  9. package/dist/chunk-4VCADZK4.mjs +2 -0
  10. package/dist/chunk-7SDHYJX4.mjs +2 -0
  11. package/dist/chunk-DPD6ZWL2.js +2 -0
  12. package/dist/chunk-EREGHAGI.js +2 -0
  13. package/dist/chunk-GKXTXH4Y.mjs +2 -0
  14. package/dist/chunk-GXSNLYRR.js +2 -0
  15. package/dist/chunk-HTY3NECU.mjs +2 -0
  16. package/dist/chunk-JFSQ24XR.js +2 -0
  17. package/dist/chunk-JOJ4LF2I.js +2 -0
  18. package/dist/chunk-JOS2XMXY.js +2 -0
  19. package/dist/chunk-JVLH3DVZ.js +2 -0
  20. package/dist/chunk-KG2ADZG6.mjs +2 -0
  21. package/dist/chunk-KLR22JMC.js +2 -0
  22. package/dist/chunk-KSPJP74K.mjs +2 -0
  23. package/dist/chunk-KYPEBOPW.mjs +2 -0
  24. package/dist/chunk-LB4TNMZU.mjs +2 -0
  25. package/dist/chunk-LSCBR4VS.js +2 -0
  26. package/dist/chunk-LWSOKXPF.js +2 -0
  27. package/dist/chunk-O34B5KOW.mjs +2 -0
  28. package/dist/chunk-OCAMDRO3.mjs +4 -0
  29. package/dist/chunk-PFO7NWQW.mjs +2 -0
  30. package/dist/chunk-Q7TQCRSD.mjs +2 -0
  31. package/dist/chunk-SLYRQ72J.js +2 -0
  32. package/dist/chunk-TKABCIEO.js +12 -0
  33. package/dist/chunk-TP63U7PL.js +4 -0
  34. package/dist/chunk-UXISKZ5Y.js +2 -0
  35. package/dist/chunk-VKFLXFPP.mjs +2 -0
  36. package/dist/chunk-WMQRTFOP.mjs +2 -0
  37. package/dist/chunk-XHEBV2HE.js +2 -0
  38. package/dist/chunk-XMQV2WFY.mjs +2 -0
  39. package/dist/chunk-XPF6CGAW.js +6 -0
  40. package/dist/chunk-XRDP2Y4J.mjs +2 -0
  41. package/dist/chunk-XUAP7KWK.js +2 -0
  42. package/dist/chunk-XXTKNIBK.js +2 -0
  43. package/dist/chunk-YBDR5ZMH.mjs +12 -0
  44. package/dist/chunk-YIXNAWH6.mjs +2 -0
  45. package/dist/exceptions.d.mts +5 -0
  46. package/dist/exceptions.d.ts +5 -0
  47. package/dist/exceptions.js +1 -158
  48. package/dist/exceptions.mjs +1 -1
  49. package/dist/index.d.mts +415 -116
  50. package/dist/index.d.ts +415 -116
  51. package/dist/index.js +30 -10514
  52. package/dist/index.mjs +30 -9626
  53. package/dist/utils.js +1 -31
  54. package/dist/utils.mjs +1 -2
  55. package/dist/validation/all.js +1 -131
  56. package/dist/validation/all.mjs +1 -18
  57. package/dist/validation/complex/currency.js +1 -11
  58. package/dist/validation/complex/currency.mjs +1 -2
  59. package/dist/validation/complex/location.js +1 -11
  60. package/dist/validation/complex/location.mjs +1 -2
  61. package/dist/validation/complex/phone.js +1 -11
  62. package/dist/validation/complex/phone.mjs +1 -2
  63. package/dist/validation/complex/relation.js +1 -19
  64. package/dist/validation/complex/relation.mjs +1 -2
  65. package/dist/validation/complex/richtext.js +1 -11
  66. package/dist/validation/complex/richtext.mjs +1 -2
  67. package/dist/validation/complex/select.js +1 -19
  68. package/dist/validation/complex/select.mjs +1 -2
  69. package/dist/validation/complex/user.js +1 -11
  70. package/dist/validation/complex/user.mjs +1 -2
  71. package/dist/validation/computed/formula.js +1 -11
  72. package/dist/validation/computed/formula.mjs +1 -2
  73. package/dist/validation/computed/rollup.js +1 -11
  74. package/dist/validation/computed/rollup.mjs +1 -2
  75. package/dist/validation/config/index.js +1 -52
  76. package/dist/validation/config/index.mjs +1 -7
  77. package/dist/validation/core/index.js +1 -14
  78. package/dist/validation/core/index.mjs +1 -1
  79. package/dist/validation/object/index.js +1 -69
  80. package/dist/validation/object/index.mjs +1 -16
  81. package/dist/validation/primitives/checkbox.js +1 -11
  82. package/dist/validation/primitives/checkbox.mjs +1 -2
  83. package/dist/validation/primitives/date.js +1 -11
  84. package/dist/validation/primitives/date.mjs +1 -2
  85. package/dist/validation/primitives/number.js +1 -11
  86. package/dist/validation/primitives/number.mjs +1 -2
  87. package/dist/validation/primitives/text.js +1 -11
  88. package/dist/validation/primitives/text.mjs +1 -2
  89. package/package.json +7 -5
  90. package/dist/chunk-2WWGHULM.mjs +0 -226
  91. package/dist/chunk-4KMUATDG.js +0 -609
  92. package/dist/chunk-5WATIVCA.js +0 -10
  93. package/dist/chunk-ACKMC6FL.js +0 -17
  94. package/dist/chunk-AYVHMVKQ.mjs +0 -15
  95. package/dist/chunk-CLZORRMS.mjs +0 -570
  96. package/dist/chunk-DVXGSTWJ.js +0 -81
  97. package/dist/chunk-E6JUYGJX.js +0 -22
  98. package/dist/chunk-EEH4XQ7W.js +0 -61
  99. package/dist/chunk-EW5XR2X3.js +0 -12
  100. package/dist/chunk-GO6LQADH.mjs +0 -57
  101. package/dist/chunk-HRQEZUAA.mjs +0 -29
  102. package/dist/chunk-HTSTPTNZ.js +0 -10
  103. package/dist/chunk-HURC6CW3.js +0 -241
  104. package/dist/chunk-JZNR4HKQ.mjs +0 -1432
  105. package/dist/chunk-KAWYU7TE.js +0 -657
  106. package/dist/chunk-KNGWHQLR.js +0 -16
  107. package/dist/chunk-LV3FEUKU.mjs +0 -14
  108. package/dist/chunk-NS63SPNN.mjs +0 -8
  109. package/dist/chunk-O73ROMWQ.mjs +0 -85
  110. package/dist/chunk-OSSGN43B.mjs +0 -8
  111. package/dist/chunk-Q44QKLN4.mjs +0 -43
  112. package/dist/chunk-Q4SZAMJT.js +0 -72
  113. package/dist/chunk-QT35SI3K.mjs +0 -641
  114. package/dist/chunk-QVLQPW3O.mjs +0 -10
  115. package/dist/chunk-QWKLQRBX.js +0 -35
  116. package/dist/chunk-R2DAEDRF.mjs +0 -74
  117. package/dist/chunk-R5LAJCBU.mjs +0 -67
  118. package/dist/chunk-SI34M4IC.js +0 -45
  119. package/dist/chunk-T5PM73EF.js +0 -1504
  120. package/dist/chunk-UANQJ2GH.mjs +0 -25
  121. package/dist/chunk-UXAHLSWC.mjs +0 -8
  122. package/dist/chunk-V2UA2D4E.js +0 -10
  123. package/dist/chunk-YIP5FJ5H.js +0 -27
  124. package/dist/chunk-YKWSHBT5.js +0 -32
  125. package/dist/chunk-YUFTHPOE.mjs +0 -20
  126. package/dist/chunk-ZDQ5AP26.mjs +0 -31
  127. package/dist/chunk-ZPFOKBIN.js +0 -89
@@ -1,2 +1 @@
1
- export { createNumberValidator } from '../../chunk-UANQJ2GH.mjs';
2
- import '../../chunk-HRQEZUAA.mjs';
1
+ export{a as createNumberValidator}from'../../chunk-KG2ADZG6.mjs';import'../../chunk-4OTKOCGB.mjs';import'../../chunk-KSPJP74K.mjs';
@@ -1,11 +1 @@
1
- 'use strict';
2
-
3
- var chunkZPFOKBIN_js = require('../../chunk-ZPFOKBIN.js');
4
- require('../../chunk-YKWSHBT5.js');
5
-
6
-
7
-
8
- Object.defineProperty(exports, "createTextValidator", {
9
- enumerable: true,
10
- get: function () { return chunkZPFOKBIN_js.createTextValidator; }
11
- });
1
+ 'use strict';var chunkXHEBV2HE_js=require('../../chunk-XHEBV2HE.js');require('../../chunk-JFSQ24XR.js'),require('../../chunk-DPD6ZWL2.js');Object.defineProperty(exports,"createTextValidator",{enumerable:true,get:function(){return chunkXHEBV2HE_js.c}});
@@ -1,2 +1 @@
1
- export { createTextValidator } from '../../chunk-O73ROMWQ.mjs';
2
- import '../../chunk-HRQEZUAA.mjs';
1
+ export{c as createTextValidator}from'../../chunk-O34B5KOW.mjs';import'../../chunk-4OTKOCGB.mjs';import'../../chunk-KSPJP74K.mjs';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stndrds/schema",
3
- "version": "1.0.0-alpha.294",
3
+ "version": "1.0.0-alpha.295",
4
4
  "description": "Standard schema definitions and utilities",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -119,13 +119,15 @@
119
119
  }
120
120
  },
121
121
  "files": [
122
- "dist"
122
+ "dist",
123
+ "LICENSE",
124
+ "README.md"
123
125
  ],
124
126
  "dependencies": {
125
127
  "@standard-schema/spec": "^1.1.0",
126
128
  "libphonenumber-js": "^1.12.31",
127
129
  "zod": "^4.2.1",
128
- "@stndrds/constants": "1.0.0-alpha.294"
130
+ "@stndrds/constants": "1.0.0-alpha.295"
129
131
  },
130
132
  "devDependencies": {
131
133
  "@types/node": "^25.0.3",
@@ -136,7 +138,7 @@
136
138
  "vitest": "^4.1.11"
137
139
  },
138
140
  "publishConfig": {
139
- "access": "restricted",
141
+ "access": "public",
140
142
  "registry": "https://registry.npmjs.org/"
141
143
  },
142
144
  "repository": {
@@ -144,7 +146,7 @@
144
146
  "url": "https://github.com/andyoucreate/standards.git",
145
147
  "directory": "packages/schema"
146
148
  },
147
- "license": "MIT",
149
+ "license": "SEE LICENSE IN LICENSE",
148
150
  "author": "AndYouCreate",
149
151
  "bugs": {
150
152
  "url": "https://github.com/andyoucreate/standards/issues"
@@ -1,226 +0,0 @@
1
- import { createRelationValidator } from './chunk-GO6LQADH.mjs';
2
- import { createRichtextValidator } from './chunk-QVLQPW3O.mjs';
3
- import { createMultiselectValidator, createSelectValidator, createStatusValidator } from './chunk-ZDQ5AP26.mjs';
4
- import { createUserValidator } from './chunk-LV3FEUKU.mjs';
5
- import { createFormulaValidator } from './chunk-UXAHLSWC.mjs';
6
- import { createRollupValidator } from './chunk-NS63SPNN.mjs';
7
- import { createCheckboxValidator } from './chunk-OSSGN43B.mjs';
8
- import { createDateValidator } from './chunk-Q44QKLN4.mjs';
9
- import { createNumberValidator } from './chunk-UANQJ2GH.mjs';
10
- import { createTextValidator } from './chunk-O73ROMWQ.mjs';
11
- import { ValidationError } from './chunk-CLZORRMS.mjs';
12
- import { createCurrencyValidator } from './chunk-AYVHMVKQ.mjs';
13
- import { createLocationValidator } from './chunk-YUFTHPOE.mjs';
14
- import { createPhoneValidator } from './chunk-R5LAJCBU.mjs';
15
- import { DEFAULT_VALIDATION_MESSAGES, formatZodErrors } from './chunk-HRQEZUAA.mjs';
16
- import { z } from 'zod';
17
-
18
- function isEmptyValue(value) {
19
- if (value === null || value === void 0) return true;
20
- if (typeof value === "string" && value.trim() === "") return true;
21
- if (value instanceof Date) return false;
22
- if (typeof value === "object" && !Array.isArray(value)) {
23
- return Object.values(value).every(
24
- (v) => v === null || v === void 0 || typeof v === "string" && v.trim() === ""
25
- );
26
- }
27
- return false;
28
- }
29
- function withEmptyToNull(validator) {
30
- return z.preprocess((val) => isEmptyValue(val) ? null : val, validator.nullish());
31
- }
32
-
33
- // src/validation/object/attribute-factory.ts
34
- function createAttributeValidator(attr, messages = DEFAULT_VALIDATION_MESSAGES) {
35
- switch (attr.type) {
36
- case "text":
37
- return createTextValidator(attr, messages);
38
- case "richtext":
39
- return createRichtextValidator(attr, messages);
40
- case "number":
41
- return createNumberValidator(attr, messages);
42
- case "checkbox":
43
- return createCheckboxValidator(attr, messages);
44
- case "date":
45
- return createDateValidator(attr, messages);
46
- case "phone":
47
- return createPhoneValidator(attr, messages);
48
- case "currency":
49
- return createCurrencyValidator(attr, messages);
50
- case "status":
51
- return createStatusValidator(attr, messages);
52
- case "location":
53
- return createLocationValidator(attr, messages);
54
- case "select":
55
- return createSelectValidator(attr, messages);
56
- case "multiselect":
57
- return createMultiselectValidator(attr, messages);
58
- case "user":
59
- return createUserValidator(attr, messages);
60
- case "relation":
61
- return createRelationValidator(attr, messages);
62
- case "formula":
63
- return createFormulaValidator(attr, messages);
64
- case "rollup":
65
- return createRollupValidator(attr, messages);
66
- default:
67
- return z.unknown();
68
- }
69
- }
70
- function createFormAttributeValidator(attr, messages = DEFAULT_VALIDATION_MESSAGES) {
71
- const validator = createAttributeValidator(attr, messages);
72
- if (!attr.required) {
73
- return withEmptyToNull(validator);
74
- }
75
- return validator;
76
- }
77
-
78
- // src/lib/empty.ts
79
- function isNullishOrEmptyString(value) {
80
- return value === null || value === void 0 || value === "";
81
- }
82
- function isValuePresent(value) {
83
- if (value === null || value === void 0) return false;
84
- if (typeof value === "string") return value.trim() !== "";
85
- if (Array.isArray(value)) return value.length > 0;
86
- return true;
87
- }
88
-
89
- // src/validation/object/object-validator.ts
90
- var objectValidatorCache = /* @__PURE__ */ new WeakMap();
91
- var draftValidatorCache = /* @__PURE__ */ new WeakMap();
92
- function createObjectValidator(objectDef) {
93
- const cached = objectValidatorCache.get(objectDef);
94
- if (cached) return cached;
95
- const shape = {};
96
- for (const attr of objectDef.attributes) {
97
- const validator = createAttributeValidator(attr);
98
- if (attr.required) {
99
- shape[attr.name] = validator.refine(isValuePresent, {
100
- message: DEFAULT_VALIDATION_MESSAGES.required(attr)
101
- });
102
- } else {
103
- shape[attr.name] = withEmptyToNull(validator);
104
- }
105
- }
106
- const schema = z.object(shape).passthrough();
107
- objectValidatorCache.set(objectDef, schema);
108
- return schema;
109
- }
110
- function createDraftValidator(objectDef) {
111
- const cached = draftValidatorCache.get(objectDef);
112
- if (cached) return cached;
113
- const shape = {};
114
- for (const attr of objectDef.attributes) {
115
- const validator = createAttributeValidator(attr);
116
- shape[attr.name] = withEmptyToNull(validator);
117
- }
118
- const schema = z.object(shape).passthrough();
119
- draftValidatorCache.set(objectDef, schema);
120
- return schema;
121
- }
122
-
123
- // src/validation/object/helpers.ts
124
- function validateAttribute(attr, value) {
125
- const validator = createAttributeValidator(attr);
126
- if (!attr.required && (value === void 0 || value === null)) {
127
- return { success: true, data: { [attr.name]: value } };
128
- }
129
- const result = validator.safeParse(value);
130
- if (result.success) {
131
- return {
132
- success: true,
133
- data: { [attr.name]: result.data }
134
- };
135
- }
136
- return {
137
- success: false,
138
- errors: formatZodErrors(result.error).map((err) => ({
139
- path: [attr.name, ...err.path],
140
- message: err.message
141
- }))
142
- };
143
- }
144
- function validateObject(objectDef, data) {
145
- const validator = createObjectValidator(objectDef);
146
- const result = validator.safeParse(data);
147
- if (result.success) {
148
- return {
149
- success: true,
150
- data: result.data
151
- };
152
- }
153
- return {
154
- success: false,
155
- errors: formatZodErrors(result.error)
156
- };
157
- }
158
- function validateObjectOrThrow(objectDef, data) {
159
- const result = validateObject(objectDef, data);
160
- if (!result.success) {
161
- const errors = result.errors ?? [];
162
- const detail = errors.map((err) => `${err.path.join(".")}: ${err.message}`).join("\n") || "Unknown validation error";
163
- throw new ValidationError(
164
- `Validation failed for ${objectDef.label}:
165
- ${detail}`,
166
- errors.map((err) => ({ path: err.path, message: err.message }))
167
- );
168
- }
169
- return result.data;
170
- }
171
- function validateDraft(objectDef, data) {
172
- const validator = createDraftValidator(objectDef);
173
- const result = validator.safeParse(data);
174
- if (result.success) {
175
- return {
176
- success: true,
177
- data: result.data
178
- };
179
- }
180
- return {
181
- success: false,
182
- errors: formatZodErrors(result.error)
183
- };
184
- }
185
- function validateDraftOrThrow(objectDef, data) {
186
- const result = validateDraft(objectDef, data);
187
- if (!result.success) {
188
- const errors = result.errors ?? [];
189
- const detail = errors.map((err) => `${err.path.join(".")}: ${err.message}`).join("\n") || "Unknown validation error";
190
- throw new ValidationError(
191
- `Draft validation failed for ${objectDef.label}:
192
- ${detail}`,
193
- errors.map((err) => ({ path: err.path, message: err.message }))
194
- );
195
- }
196
- return result.data;
197
- }
198
- function rejectUnknownAttributesOrThrow(objectDef, data) {
199
- const knownNames = new Set(objectDef.attributes.map((a) => a.name));
200
- const unknownKeys = Object.keys(data).filter((key) => !knownNames.has(key));
201
- if (unknownKeys.length > 0) {
202
- throw new ValidationError(
203
- `Unknown attribute${unknownKeys.length > 1 ? "s" : ""} for ${objectDef.label}: ${unknownKeys.join(", ")}`,
204
- unknownKeys.map((key) => ({ path: [key], message: "Unknown attribute" }))
205
- );
206
- }
207
- }
208
- function getMissingRequiredAttributes(objectDef, data) {
209
- const missing = [];
210
- for (const attr of objectDef.attributes) {
211
- if (attr.required && !isValuePresent(data[attr.name])) {
212
- missing.push(attr);
213
- }
214
- }
215
- return missing;
216
- }
217
- function isRecordComplete(objectDef, data) {
218
- const missing = getMissingRequiredAttributes(objectDef, data);
219
- if (missing.length > 0) {
220
- return false;
221
- }
222
- const validation = validateObject(objectDef, data);
223
- return validation.success;
224
- }
225
-
226
- export { createAttributeValidator, createDraftValidator, createFormAttributeValidator, createObjectValidator, getMissingRequiredAttributes, isNullishOrEmptyString, isRecordComplete, isValuePresent, rejectUnknownAttributesOrThrow, validateAttribute, validateDraft, validateDraftOrThrow, validateObject, validateObjectOrThrow };