lkd-web-kit 0.4.3 → 0.4.5

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 (138) hide show
  1. package/dist/hooks/useZodConfig.cjs +21 -0
  2. package/dist/hooks/useZodConfig.js +17 -0
  3. package/dist/index.cjs +2 -0
  4. package/dist/index.d.ts +4 -3
  5. package/dist/index.js +1 -0
  6. package/dist/node_modules/@tanstack/virtual-core/dist/esm/index.cjs +38 -33
  7. package/dist/node_modules/@tanstack/virtual-core/dist/esm/index.js +38 -33
  8. package/dist/node_modules/@tanstack/virtual-core/dist/esm/utils.cjs +1 -1
  9. package/dist/node_modules/@tanstack/virtual-core/dist/esm/utils.js +1 -1
  10. package/dist/node_modules/zod/v4/classic/coerce.cjs +28 -0
  11. package/dist/node_modules/zod/v4/classic/coerce.js +20 -0
  12. package/dist/node_modules/zod/v4/classic/compat.cjs +37 -0
  13. package/dist/node_modules/zod/v4/classic/compat.js +30 -0
  14. package/dist/node_modules/zod/v4/classic/errors.cjs +49 -0
  15. package/dist/node_modules/zod/v4/classic/errors.js +44 -0
  16. package/dist/node_modules/zod/v4/classic/external.cjs +231 -0
  17. package/dist/node_modules/zod/v4/classic/external.js +28 -0
  18. package/dist/node_modules/zod/v4/classic/index.cjs +10 -0
  19. package/dist/node_modules/zod/v4/classic/index.js +5 -0
  20. package/dist/node_modules/zod/v4/classic/iso.cjs +46 -0
  21. package/dist/node_modules/zod/v4/classic/iso.js +35 -0
  22. package/dist/node_modules/zod/v4/classic/parse.cjs +16 -0
  23. package/dist/node_modules/zod/v4/classic/parse.js +9 -0
  24. package/dist/node_modules/zod/v4/classic/schemas.cjs +1155 -0
  25. package/dist/node_modules/zod/v4/classic/schemas.js +1006 -0
  26. package/dist/node_modules/zod/v4/core/api.cjs +1016 -0
  27. package/dist/node_modules/zod/v4/core/api.js +903 -0
  28. package/dist/node_modules/zod/v4/core/checks.cjs +587 -0
  29. package/dist/node_modules/zod/v4/core/checks.js +562 -0
  30. package/dist/node_modules/zod/v4/core/core.cjs +72 -0
  31. package/dist/node_modules/zod/v4/core/core.js +63 -0
  32. package/dist/node_modules/zod/v4/core/doc.cjs +41 -0
  33. package/dist/node_modules/zod/v4/core/doc.js +37 -0
  34. package/dist/node_modules/zod/v4/core/errors.cjs +204 -0
  35. package/dist/node_modules/zod/v4/core/errors.js +194 -0
  36. package/dist/node_modules/zod/v4/core/function.cjs +81 -0
  37. package/dist/node_modules/zod/v4/core/function.js +76 -0
  38. package/dist/node_modules/zod/v4/core/index.cjs +261 -0
  39. package/dist/node_modules/zod/v4/core/index.js +20 -0
  40. package/dist/node_modules/zod/v4/core/json-schema.cjs +2 -0
  41. package/dist/node_modules/zod/v4/core/json-schema.js +1 -0
  42. package/dist/node_modules/zod/v4/core/parse.cjs +71 -0
  43. package/dist/node_modules/zod/v4/core/parse.js +60 -0
  44. package/dist/node_modules/zod/v4/core/regexes.cjs +139 -0
  45. package/dist/node_modules/zod/v4/core/regexes.js +95 -0
  46. package/dist/node_modules/zod/v4/core/registries.cjs +52 -0
  47. package/dist/node_modules/zod/v4/core/registries.js +44 -0
  48. package/dist/node_modules/zod/v4/core/schemas.cjs +1793 -0
  49. package/dist/node_modules/zod/v4/core/schemas.js +1720 -0
  50. package/dist/node_modules/zod/v4/core/to-json-schema.cjs +823 -0
  51. package/dist/node_modules/zod/v4/core/to-json-schema.js +818 -0
  52. package/dist/node_modules/zod/v4/core/util.cjs +543 -0
  53. package/dist/node_modules/zod/v4/core/util.js +491 -0
  54. package/dist/node_modules/zod/v4/core/versions.cjs +11 -0
  55. package/dist/node_modules/zod/v4/core/versions.js +7 -0
  56. package/dist/node_modules/zod/v4/index.cjs +10 -0
  57. package/dist/node_modules/zod/v4/index.js +5 -0
  58. package/dist/node_modules/zod/v4/locales/ar.cjs +121 -0
  59. package/dist/node_modules/zod/v4/locales/ar.js +119 -0
  60. package/dist/node_modules/zod/v4/locales/az.cjs +120 -0
  61. package/dist/node_modules/zod/v4/locales/az.js +118 -0
  62. package/dist/node_modules/zod/v4/locales/be.cjs +169 -0
  63. package/dist/node_modules/zod/v4/locales/be.js +167 -0
  64. package/dist/node_modules/zod/v4/locales/ca.cjs +123 -0
  65. package/dist/node_modules/zod/v4/locales/ca.js +121 -0
  66. package/dist/node_modules/zod/v4/locales/cs.cjs +140 -0
  67. package/dist/node_modules/zod/v4/locales/cs.js +138 -0
  68. package/dist/node_modules/zod/v4/locales/de.cjs +121 -0
  69. package/dist/node_modules/zod/v4/locales/de.js +119 -0
  70. package/dist/node_modules/zod/v4/locales/en.cjs +125 -0
  71. package/dist/node_modules/zod/v4/locales/en.js +120 -0
  72. package/dist/node_modules/zod/v4/locales/eo.cjs +124 -0
  73. package/dist/node_modules/zod/v4/locales/eo.js +119 -0
  74. package/dist/node_modules/zod/v4/locales/es.cjs +122 -0
  75. package/dist/node_modules/zod/v4/locales/es.js +120 -0
  76. package/dist/node_modules/zod/v4/locales/fa.cjs +127 -0
  77. package/dist/node_modules/zod/v4/locales/fa.js +125 -0
  78. package/dist/node_modules/zod/v4/locales/fi.cjs +127 -0
  79. package/dist/node_modules/zod/v4/locales/fi.js +125 -0
  80. package/dist/node_modules/zod/v4/locales/fr-CA.cjs +122 -0
  81. package/dist/node_modules/zod/v4/locales/fr-CA.js +120 -0
  82. package/dist/node_modules/zod/v4/locales/fr.cjs +121 -0
  83. package/dist/node_modules/zod/v4/locales/fr.js +119 -0
  84. package/dist/node_modules/zod/v4/locales/he.cjs +122 -0
  85. package/dist/node_modules/zod/v4/locales/he.js +120 -0
  86. package/dist/node_modules/zod/v4/locales/hu.cjs +122 -0
  87. package/dist/node_modules/zod/v4/locales/hu.js +120 -0
  88. package/dist/node_modules/zod/v4/locales/id.cjs +121 -0
  89. package/dist/node_modules/zod/v4/locales/id.js +119 -0
  90. package/dist/node_modules/zod/v4/locales/index.cjs +85 -0
  91. package/dist/node_modules/zod/v4/locales/index.js +39 -0
  92. package/dist/node_modules/zod/v4/locales/it.cjs +122 -0
  93. package/dist/node_modules/zod/v4/locales/it.js +120 -0
  94. package/dist/node_modules/zod/v4/locales/ja.cjs +120 -0
  95. package/dist/node_modules/zod/v4/locales/ja.js +118 -0
  96. package/dist/node_modules/zod/v4/locales/kh.cjs +122 -0
  97. package/dist/node_modules/zod/v4/locales/kh.js +120 -0
  98. package/dist/node_modules/zod/v4/locales/ko.cjs +126 -0
  99. package/dist/node_modules/zod/v4/locales/ko.js +124 -0
  100. package/dist/node_modules/zod/v4/locales/mk.cjs +123 -0
  101. package/dist/node_modules/zod/v4/locales/mk.js +121 -0
  102. package/dist/node_modules/zod/v4/locales/ms.cjs +121 -0
  103. package/dist/node_modules/zod/v4/locales/ms.js +119 -0
  104. package/dist/node_modules/zod/v4/locales/nl.cjs +122 -0
  105. package/dist/node_modules/zod/v4/locales/nl.js +120 -0
  106. package/dist/node_modules/zod/v4/locales/no.cjs +121 -0
  107. package/dist/node_modules/zod/v4/locales/no.js +119 -0
  108. package/dist/node_modules/zod/v4/locales/ota.cjs +122 -0
  109. package/dist/node_modules/zod/v4/locales/ota.js +120 -0
  110. package/dist/node_modules/zod/v4/locales/pl.cjs +122 -0
  111. package/dist/node_modules/zod/v4/locales/pl.js +120 -0
  112. package/dist/node_modules/zod/v4/locales/ps.cjs +127 -0
  113. package/dist/node_modules/zod/v4/locales/ps.js +125 -0
  114. package/dist/node_modules/zod/v4/locales/pt.cjs +121 -0
  115. package/dist/node_modules/zod/v4/locales/pt.js +119 -0
  116. package/dist/node_modules/zod/v4/locales/ru.cjs +169 -0
  117. package/dist/node_modules/zod/v4/locales/ru.js +167 -0
  118. package/dist/node_modules/zod/v4/locales/sl.cjs +122 -0
  119. package/dist/node_modules/zod/v4/locales/sl.js +120 -0
  120. package/dist/node_modules/zod/v4/locales/sv.cjs +123 -0
  121. package/dist/node_modules/zod/v4/locales/sv.js +121 -0
  122. package/dist/node_modules/zod/v4/locales/ta.cjs +122 -0
  123. package/dist/node_modules/zod/v4/locales/ta.js +120 -0
  124. package/dist/node_modules/zod/v4/locales/th.cjs +122 -0
  125. package/dist/node_modules/zod/v4/locales/th.js +120 -0
  126. package/dist/node_modules/zod/v4/locales/tr.cjs +123 -0
  127. package/dist/node_modules/zod/v4/locales/tr.js +118 -0
  128. package/dist/node_modules/zod/v4/locales/ua.cjs +122 -0
  129. package/dist/node_modules/zod/v4/locales/ua.js +120 -0
  130. package/dist/node_modules/zod/v4/locales/ur.cjs +122 -0
  131. package/dist/node_modules/zod/v4/locales/ur.js +120 -0
  132. package/dist/node_modules/zod/v4/locales/vi.cjs +121 -0
  133. package/dist/node_modules/zod/v4/locales/vi.js +119 -0
  134. package/dist/node_modules/zod/v4/locales/zh-CN.cjs +121 -0
  135. package/dist/node_modules/zod/v4/locales/zh-CN.js +119 -0
  136. package/dist/node_modules/zod/v4/locales/zh-TW.cjs +122 -0
  137. package/dist/node_modules/zod/v4/locales/zh-TW.js +120 -0
  138. package/package.json +1 -1
@@ -0,0 +1,491 @@
1
+ // functions
2
+ function assertEqual(val) {
3
+ return val;
4
+ }
5
+ function assertNotEqual(val) {
6
+ return val;
7
+ }
8
+ function assertIs(_arg) { }
9
+ function assertNever(_x) {
10
+ throw new Error();
11
+ }
12
+ function assert(_) { }
13
+ function getEnumValues(entries) {
14
+ const numericValues = Object.values(entries).filter((v) => typeof v === "number");
15
+ const values = Object.entries(entries)
16
+ .filter(([k, _]) => numericValues.indexOf(+k) === -1)
17
+ .map(([_, v]) => v);
18
+ return values;
19
+ }
20
+ function joinValues(array, separator = "|") {
21
+ return array.map((val) => stringifyPrimitive(val)).join(separator);
22
+ }
23
+ function jsonStringifyReplacer(_, value) {
24
+ if (typeof value === "bigint")
25
+ return value.toString();
26
+ return value;
27
+ }
28
+ function cached(getter) {
29
+ return {
30
+ get value() {
31
+ {
32
+ const value = getter();
33
+ Object.defineProperty(this, "value", { value });
34
+ return value;
35
+ }
36
+ },
37
+ };
38
+ }
39
+ function nullish(input) {
40
+ return input === null || input === undefined;
41
+ }
42
+ function cleanRegex(source) {
43
+ const start = source.startsWith("^") ? 1 : 0;
44
+ const end = source.endsWith("$") ? source.length - 1 : source.length;
45
+ return source.slice(start, end);
46
+ }
47
+ function floatSafeRemainder(val, step) {
48
+ const valDecCount = (val.toString().split(".")[1] || "").length;
49
+ const stepDecCount = (step.toString().split(".")[1] || "").length;
50
+ const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount;
51
+ const valInt = Number.parseInt(val.toFixed(decCount).replace(".", ""));
52
+ const stepInt = Number.parseInt(step.toFixed(decCount).replace(".", ""));
53
+ return (valInt % stepInt) / 10 ** decCount;
54
+ }
55
+ function defineLazy(object, key, getter) {
56
+ Object.defineProperty(object, key, {
57
+ get() {
58
+ {
59
+ const value = getter();
60
+ object[key] = value;
61
+ return value;
62
+ }
63
+ },
64
+ set(v) {
65
+ Object.defineProperty(object, key, {
66
+ value: v,
67
+ // configurable: true,
68
+ });
69
+ // object[key] = v;
70
+ },
71
+ configurable: true,
72
+ });
73
+ }
74
+ function assignProp(target, prop, value) {
75
+ Object.defineProperty(target, prop, {
76
+ value,
77
+ writable: true,
78
+ enumerable: true,
79
+ configurable: true,
80
+ });
81
+ }
82
+ function getElementAtPath(obj, path) {
83
+ if (!path)
84
+ return obj;
85
+ return path.reduce((acc, key) => acc?.[key], obj);
86
+ }
87
+ function promiseAllObject(promisesObj) {
88
+ const keys = Object.keys(promisesObj);
89
+ const promises = keys.map((key) => promisesObj[key]);
90
+ return Promise.all(promises).then((results) => {
91
+ const resolvedObj = {};
92
+ for (let i = 0; i < keys.length; i++) {
93
+ resolvedObj[keys[i]] = results[i];
94
+ }
95
+ return resolvedObj;
96
+ });
97
+ }
98
+ function randomString(length = 10) {
99
+ const chars = "abcdefghijklmnopqrstuvwxyz";
100
+ let str = "";
101
+ for (let i = 0; i < length; i++) {
102
+ str += chars[Math.floor(Math.random() * chars.length)];
103
+ }
104
+ return str;
105
+ }
106
+ function esc(str) {
107
+ return JSON.stringify(str);
108
+ }
109
+ const captureStackTrace = Error.captureStackTrace
110
+ ? Error.captureStackTrace
111
+ : (..._args) => { };
112
+ function isObject(data) {
113
+ return typeof data === "object" && data !== null && !Array.isArray(data);
114
+ }
115
+ const allowsEval = cached(() => {
116
+ if (typeof navigator !== "undefined" && navigator?.userAgent?.includes("Cloudflare")) {
117
+ return false;
118
+ }
119
+ try {
120
+ const F = Function;
121
+ new F("");
122
+ return true;
123
+ }
124
+ catch (_) {
125
+ return false;
126
+ }
127
+ });
128
+ function isPlainObject(o) {
129
+ if (isObject(o) === false)
130
+ return false;
131
+ // modified constructor
132
+ const ctor = o.constructor;
133
+ if (ctor === undefined)
134
+ return true;
135
+ // modified prototype
136
+ const prot = ctor.prototype;
137
+ if (isObject(prot) === false)
138
+ return false;
139
+ // ctor doesn't have static `isPrototypeOf`
140
+ if (Object.prototype.hasOwnProperty.call(prot, "isPrototypeOf") === false) {
141
+ return false;
142
+ }
143
+ return true;
144
+ }
145
+ function numKeys(data) {
146
+ let keyCount = 0;
147
+ for (const key in data) {
148
+ if (Object.prototype.hasOwnProperty.call(data, key)) {
149
+ keyCount++;
150
+ }
151
+ }
152
+ return keyCount;
153
+ }
154
+ const getParsedType = (data) => {
155
+ const t = typeof data;
156
+ switch (t) {
157
+ case "undefined":
158
+ return "undefined";
159
+ case "string":
160
+ return "string";
161
+ case "number":
162
+ return Number.isNaN(data) ? "nan" : "number";
163
+ case "boolean":
164
+ return "boolean";
165
+ case "function":
166
+ return "function";
167
+ case "bigint":
168
+ return "bigint";
169
+ case "symbol":
170
+ return "symbol";
171
+ case "object":
172
+ if (Array.isArray(data)) {
173
+ return "array";
174
+ }
175
+ if (data === null) {
176
+ return "null";
177
+ }
178
+ if (data.then && typeof data.then === "function" && data.catch && typeof data.catch === "function") {
179
+ return "promise";
180
+ }
181
+ if (typeof Map !== "undefined" && data instanceof Map) {
182
+ return "map";
183
+ }
184
+ if (typeof Set !== "undefined" && data instanceof Set) {
185
+ return "set";
186
+ }
187
+ if (typeof Date !== "undefined" && data instanceof Date) {
188
+ return "date";
189
+ }
190
+ if (typeof File !== "undefined" && data instanceof File) {
191
+ return "file";
192
+ }
193
+ return "object";
194
+ default:
195
+ throw new Error(`Unknown data type: ${t}`);
196
+ }
197
+ };
198
+ const propertyKeyTypes = new Set(["string", "number", "symbol"]);
199
+ const primitiveTypes = new Set(["string", "number", "bigint", "boolean", "symbol", "undefined"]);
200
+ function escapeRegex(str) {
201
+ return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
202
+ }
203
+ // zod-specific utils
204
+ function clone(inst, def, params) {
205
+ const cl = new inst._zod.constr(def ?? inst._zod.def);
206
+ if (!def || params?.parent)
207
+ cl._zod.parent = inst;
208
+ return cl;
209
+ }
210
+ function normalizeParams(_params) {
211
+ const params = _params;
212
+ if (!params)
213
+ return {};
214
+ if (typeof params === "string")
215
+ return { error: () => params };
216
+ if (params?.message !== undefined) {
217
+ if (params?.error !== undefined)
218
+ throw new Error("Cannot specify both `message` and `error` params");
219
+ params.error = params.message;
220
+ }
221
+ delete params.message;
222
+ if (typeof params.error === "string")
223
+ return { ...params, error: () => params.error };
224
+ return params;
225
+ }
226
+ function createTransparentProxy(getter) {
227
+ let target;
228
+ return new Proxy({}, {
229
+ get(_, prop, receiver) {
230
+ target ?? (target = getter());
231
+ return Reflect.get(target, prop, receiver);
232
+ },
233
+ set(_, prop, value, receiver) {
234
+ target ?? (target = getter());
235
+ return Reflect.set(target, prop, value, receiver);
236
+ },
237
+ has(_, prop) {
238
+ target ?? (target = getter());
239
+ return Reflect.has(target, prop);
240
+ },
241
+ deleteProperty(_, prop) {
242
+ target ?? (target = getter());
243
+ return Reflect.deleteProperty(target, prop);
244
+ },
245
+ ownKeys(_) {
246
+ target ?? (target = getter());
247
+ return Reflect.ownKeys(target);
248
+ },
249
+ getOwnPropertyDescriptor(_, prop) {
250
+ target ?? (target = getter());
251
+ return Reflect.getOwnPropertyDescriptor(target, prop);
252
+ },
253
+ defineProperty(_, prop, descriptor) {
254
+ target ?? (target = getter());
255
+ return Reflect.defineProperty(target, prop, descriptor);
256
+ },
257
+ });
258
+ }
259
+ function stringifyPrimitive(value) {
260
+ if (typeof value === "bigint")
261
+ return value.toString() + "n";
262
+ if (typeof value === "string")
263
+ return `"${value}"`;
264
+ return `${value}`;
265
+ }
266
+ function optionalKeys(shape) {
267
+ return Object.keys(shape).filter((k) => {
268
+ return shape[k]._zod.optin === "optional" && shape[k]._zod.optout === "optional";
269
+ });
270
+ }
271
+ const NUMBER_FORMAT_RANGES = {
272
+ safeint: [Number.MIN_SAFE_INTEGER, Number.MAX_SAFE_INTEGER],
273
+ int32: [-2147483648, 2147483647],
274
+ uint32: [0, 4294967295],
275
+ float32: [-34028234663852886e22, 3.4028234663852886e38],
276
+ float64: [-Number.MAX_VALUE, Number.MAX_VALUE],
277
+ };
278
+ const BIGINT_FORMAT_RANGES = {
279
+ int64: [/* @__PURE__*/ BigInt("-9223372036854775808"), /* @__PURE__*/ BigInt("9223372036854775807")],
280
+ uint64: [/* @__PURE__*/ BigInt(0), /* @__PURE__*/ BigInt("18446744073709551615")],
281
+ };
282
+ function pick(schema, mask) {
283
+ const newShape = {};
284
+ const currDef = schema._zod.def; //.shape;
285
+ for (const key in mask) {
286
+ if (!(key in currDef.shape)) {
287
+ throw new Error(`Unrecognized key: "${key}"`);
288
+ }
289
+ if (!mask[key])
290
+ continue;
291
+ // pick key
292
+ newShape[key] = currDef.shape[key];
293
+ }
294
+ return clone(schema, {
295
+ ...schema._zod.def,
296
+ shape: newShape,
297
+ checks: [],
298
+ });
299
+ }
300
+ function omit(schema, mask) {
301
+ const newShape = { ...schema._zod.def.shape };
302
+ const currDef = schema._zod.def; //.shape;
303
+ for (const key in mask) {
304
+ if (!(key in currDef.shape)) {
305
+ throw new Error(`Unrecognized key: "${key}"`);
306
+ }
307
+ if (!mask[key])
308
+ continue;
309
+ delete newShape[key];
310
+ }
311
+ return clone(schema, {
312
+ ...schema._zod.def,
313
+ shape: newShape,
314
+ checks: [],
315
+ });
316
+ }
317
+ function extend(schema, shape) {
318
+ if (!isPlainObject(shape)) {
319
+ throw new Error("Invalid input to extend: expected a plain object");
320
+ }
321
+ const def = {
322
+ ...schema._zod.def,
323
+ get shape() {
324
+ const _shape = { ...schema._zod.def.shape, ...shape };
325
+ assignProp(this, "shape", _shape); // self-caching
326
+ return _shape;
327
+ },
328
+ checks: [], // delete existing checks
329
+ };
330
+ return clone(schema, def);
331
+ }
332
+ function merge(a, b) {
333
+ return clone(a, {
334
+ ...a._zod.def,
335
+ get shape() {
336
+ const _shape = { ...a._zod.def.shape, ...b._zod.def.shape };
337
+ assignProp(this, "shape", _shape); // self-caching
338
+ return _shape;
339
+ },
340
+ catchall: b._zod.def.catchall,
341
+ checks: [], // delete existing checks
342
+ });
343
+ }
344
+ function partial(Class, schema, mask) {
345
+ const oldShape = schema._zod.def.shape;
346
+ const shape = { ...oldShape };
347
+ if (mask) {
348
+ for (const key in mask) {
349
+ if (!(key in oldShape)) {
350
+ throw new Error(`Unrecognized key: "${key}"`);
351
+ }
352
+ if (!mask[key])
353
+ continue;
354
+ // if (oldShape[key]!._zod.optin === "optional") continue;
355
+ shape[key] = Class
356
+ ? new Class({
357
+ type: "optional",
358
+ innerType: oldShape[key],
359
+ })
360
+ : oldShape[key];
361
+ }
362
+ }
363
+ else {
364
+ for (const key in oldShape) {
365
+ // if (oldShape[key]!._zod.optin === "optional") continue;
366
+ shape[key] = Class
367
+ ? new Class({
368
+ type: "optional",
369
+ innerType: oldShape[key],
370
+ })
371
+ : oldShape[key];
372
+ }
373
+ }
374
+ return clone(schema, {
375
+ ...schema._zod.def,
376
+ shape,
377
+ checks: [],
378
+ });
379
+ }
380
+ function required(Class, schema, mask) {
381
+ const oldShape = schema._zod.def.shape;
382
+ const shape = { ...oldShape };
383
+ if (mask) {
384
+ for (const key in mask) {
385
+ if (!(key in shape)) {
386
+ throw new Error(`Unrecognized key: "${key}"`);
387
+ }
388
+ if (!mask[key])
389
+ continue;
390
+ // overwrite with non-optional
391
+ shape[key] = new Class({
392
+ type: "nonoptional",
393
+ innerType: oldShape[key],
394
+ });
395
+ }
396
+ }
397
+ else {
398
+ for (const key in oldShape) {
399
+ // overwrite with non-optional
400
+ shape[key] = new Class({
401
+ type: "nonoptional",
402
+ innerType: oldShape[key],
403
+ });
404
+ }
405
+ }
406
+ return clone(schema, {
407
+ ...schema._zod.def,
408
+ shape,
409
+ // optional: [],
410
+ checks: [],
411
+ });
412
+ }
413
+ function aborted(x, startIndex = 0) {
414
+ for (let i = startIndex; i < x.issues.length; i++) {
415
+ if (x.issues[i]?.continue !== true)
416
+ return true;
417
+ }
418
+ return false;
419
+ }
420
+ function prefixIssues(path, issues) {
421
+ return issues.map((iss) => {
422
+ var _a;
423
+ (_a = iss).path ?? (_a.path = []);
424
+ iss.path.unshift(path);
425
+ return iss;
426
+ });
427
+ }
428
+ function unwrapMessage(message) {
429
+ return typeof message === "string" ? message : message?.message;
430
+ }
431
+ function finalizeIssue(iss, ctx, config) {
432
+ const full = { ...iss, path: iss.path ?? [] };
433
+ // for backwards compatibility
434
+ if (!iss.message) {
435
+ const message = unwrapMessage(iss.inst?._zod.def?.error?.(iss)) ??
436
+ unwrapMessage(ctx?.error?.(iss)) ??
437
+ unwrapMessage(config.customError?.(iss)) ??
438
+ unwrapMessage(config.localeError?.(iss)) ??
439
+ "Invalid input";
440
+ full.message = message;
441
+ }
442
+ // delete (full as any).def;
443
+ delete full.inst;
444
+ delete full.continue;
445
+ if (!ctx?.reportInput) {
446
+ delete full.input;
447
+ }
448
+ return full;
449
+ }
450
+ function getSizableOrigin(input) {
451
+ if (input instanceof Set)
452
+ return "set";
453
+ if (input instanceof Map)
454
+ return "map";
455
+ if (input instanceof File)
456
+ return "file";
457
+ return "unknown";
458
+ }
459
+ function getLengthableOrigin(input) {
460
+ if (Array.isArray(input))
461
+ return "array";
462
+ if (typeof input === "string")
463
+ return "string";
464
+ return "unknown";
465
+ }
466
+ function issue(...args) {
467
+ const [iss, input, inst] = args;
468
+ if (typeof iss === "string") {
469
+ return {
470
+ message: iss,
471
+ code: "custom",
472
+ input,
473
+ inst,
474
+ };
475
+ }
476
+ return { ...iss };
477
+ }
478
+ function cleanEnum(obj) {
479
+ return Object.entries(obj)
480
+ .filter(([k, _]) => {
481
+ // return true if NaN, meaning it's not a number, thus a string key
482
+ return Number.isNaN(Number.parseInt(k, 10));
483
+ })
484
+ .map((el) => el[1]);
485
+ }
486
+ // instanceof
487
+ class Class {
488
+ constructor(..._args) { }
489
+ }
490
+
491
+ export { BIGINT_FORMAT_RANGES, Class, NUMBER_FORMAT_RANGES, aborted, allowsEval, assert, assertEqual, assertIs, assertNever, assertNotEqual, assignProp, cached, captureStackTrace, cleanEnum, cleanRegex, clone, createTransparentProxy, defineLazy, esc, escapeRegex, extend, finalizeIssue, floatSafeRemainder, getElementAtPath, getEnumValues, getLengthableOrigin, getParsedType, getSizableOrigin, isObject, isPlainObject, issue, joinValues, jsonStringifyReplacer, merge, normalizeParams, nullish, numKeys, omit, optionalKeys, partial, pick, prefixIssues, primitiveTypes, promiseAllObject, propertyKeyTypes, randomString, required, stringifyPrimitive, unwrapMessage };
@@ -0,0 +1,11 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
+
5
+ const version = {
6
+ major: 4,
7
+ minor: 0,
8
+ patch: 0,
9
+ };
10
+
11
+ exports.version = version;
@@ -0,0 +1,7 @@
1
+ const version = {
2
+ major: 4,
3
+ minor: 0,
4
+ patch: 0,
5
+ };
6
+
7
+ export { version };
@@ -0,0 +1,10 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
4
+
5
+ const external = require('./classic/external.cjs');
6
+
7
+
8
+
9
+ exports.default = external;
10
+ exports.z = external;
@@ -0,0 +1,5 @@
1
+ import * as external from './classic/external.js';
2
+
3
+
4
+
5
+ export { external as default, external as z };
@@ -0,0 +1,121 @@
1
+ 'use strict';
2
+
3
+ const util = require('../core/util.cjs');
4
+
5
+ const error = () => {
6
+ const Sizable = {
7
+ string: { unit: "حرف", verb: "أن يحوي" },
8
+ file: { unit: "بايت", verb: "أن يحوي" },
9
+ array: { unit: "عنصر", verb: "أن يحوي" },
10
+ set: { unit: "عنصر", verb: "أن يحوي" },
11
+ };
12
+ function getSizing(origin) {
13
+ return Sizable[origin] ?? null;
14
+ }
15
+ const parsedType = (data) => {
16
+ const t = typeof data;
17
+ switch (t) {
18
+ case "number": {
19
+ return Number.isNaN(data) ? "NaN" : "number";
20
+ }
21
+ case "object": {
22
+ if (Array.isArray(data)) {
23
+ return "array";
24
+ }
25
+ if (data === null) {
26
+ return "null";
27
+ }
28
+ if (Object.getPrototypeOf(data) !== Object.prototype && data.constructor) {
29
+ return data.constructor.name;
30
+ }
31
+ }
32
+ }
33
+ return t;
34
+ };
35
+ const Nouns = {
36
+ regex: "مدخل",
37
+ email: "بريد إلكتروني",
38
+ url: "رابط",
39
+ emoji: "إيموجي",
40
+ uuid: "UUID",
41
+ uuidv4: "UUIDv4",
42
+ uuidv6: "UUIDv6",
43
+ nanoid: "nanoid",
44
+ guid: "GUID",
45
+ cuid: "cuid",
46
+ cuid2: "cuid2",
47
+ ulid: "ULID",
48
+ xid: "XID",
49
+ ksuid: "KSUID",
50
+ datetime: "تاريخ ووقت بمعيار ISO",
51
+ date: "تاريخ بمعيار ISO",
52
+ time: "وقت بمعيار ISO",
53
+ duration: "مدة بمعيار ISO",
54
+ ipv4: "عنوان IPv4",
55
+ ipv6: "عنوان IPv6",
56
+ cidrv4: "مدى عناوين بصيغة IPv4",
57
+ cidrv6: "مدى عناوين بصيغة IPv6",
58
+ base64: "نَص بترميز base64-encoded",
59
+ base64url: "نَص بترميز base64url-encoded",
60
+ json_string: "نَص على هيئة JSON",
61
+ e164: "رقم هاتف بمعيار E.164",
62
+ jwt: "JWT",
63
+ template_literal: "مدخل",
64
+ };
65
+ return (issue) => {
66
+ switch (issue.code) {
67
+ case "invalid_type":
68
+ return `مدخلات غير مقبولة: يفترض إدخال ${issue.expected}، ولكن تم إدخال ${parsedType(issue.input)}`;
69
+ case "invalid_value":
70
+ if (issue.values.length === 1)
71
+ return `مدخلات غير مقبولة: يفترض إدخال ${util.stringifyPrimitive(issue.values[0])}`;
72
+ return `اختيار غير مقبول: يتوقع انتقاء أحد هذه الخيارات: ${util.joinValues(issue.values, "|")}`;
73
+ case "too_big": {
74
+ const adj = issue.inclusive ? "<=" : "<";
75
+ const sizing = getSizing(issue.origin);
76
+ if (sizing)
77
+ return ` أكبر من اللازم: يفترض أن تكون ${issue.origin ?? "القيمة"} ${adj} ${issue.maximum.toString()} ${sizing.unit ?? "عنصر"}`;
78
+ return `أكبر من اللازم: يفترض أن تكون ${issue.origin ?? "القيمة"} ${adj} ${issue.maximum.toString()}`;
79
+ }
80
+ case "too_small": {
81
+ const adj = issue.inclusive ? ">=" : ">";
82
+ const sizing = getSizing(issue.origin);
83
+ if (sizing) {
84
+ return `أصغر من اللازم: يفترض لـ ${issue.origin} أن يكون ${adj} ${issue.minimum.toString()} ${sizing.unit}`;
85
+ }
86
+ return `أصغر من اللازم: يفترض لـ ${issue.origin} أن يكون ${adj} ${issue.minimum.toString()}`;
87
+ }
88
+ case "invalid_format": {
89
+ const _issue = issue;
90
+ if (_issue.format === "starts_with")
91
+ return `نَص غير مقبول: يجب أن يبدأ بـ "${issue.prefix}"`;
92
+ if (_issue.format === "ends_with")
93
+ return `نَص غير مقبول: يجب أن ينتهي بـ "${_issue.suffix}"`;
94
+ if (_issue.format === "includes")
95
+ return `نَص غير مقبول: يجب أن يتضمَّن "${_issue.includes}"`;
96
+ if (_issue.format === "regex")
97
+ return `نَص غير مقبول: يجب أن يطابق النمط ${_issue.pattern}`;
98
+ return `${Nouns[_issue.format] ?? issue.format} غير مقبول`;
99
+ }
100
+ case "not_multiple_of":
101
+ return `رقم غير مقبول: يجب أن يكون من مضاعفات ${issue.divisor}`;
102
+ case "unrecognized_keys":
103
+ return `معرف${issue.keys.length > 1 ? "ات" : ""} غريب${issue.keys.length > 1 ? "ة" : ""}: ${util.joinValues(issue.keys, "، ")}`;
104
+ case "invalid_key":
105
+ return `معرف غير مقبول في ${issue.origin}`;
106
+ case "invalid_union":
107
+ return "مدخل غير مقبول";
108
+ case "invalid_element":
109
+ return `مدخل غير مقبول في ${issue.origin}`;
110
+ default:
111
+ return "مدخل غير مقبول";
112
+ }
113
+ };
114
+ };
115
+ function ar () {
116
+ return {
117
+ localeError: error(),
118
+ };
119
+ }
120
+
121
+ module.exports = ar;