@stndrds/schema 1.0.0-alpha.100 → 1.0.0-alpha.103
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{attributes-CH89Z_J-.d.mts → attributes-D7yQuTJK.d.mts} +1 -11
- package/dist/{attributes-dw-jLtYS.d.ts → attributes-DcbQC-4b.d.ts} +1 -11
- package/dist/chunk-3JINFUN3.js +81 -0
- package/dist/{chunk-BZTLI773.mjs → chunk-4KRLCWJM.mjs} +1 -1
- package/dist/{chunk-ERG77ADK.mjs → chunk-4TC27SMF.mjs} +1 -1
- package/dist/{chunk-OO2LJ6GP.js → chunk-56QI6UTK.js} +4 -4
- package/dist/{chunk-P4NGPF5L.mjs → chunk-5XL3JP73.mjs} +3 -19
- package/dist/{chunk-ZJNX6UXB.mjs → chunk-7HFZ7MVR.mjs} +1 -1
- package/dist/{chunk-6IFD5732.js → chunk-ACQ3TUFK.js} +2 -2
- package/dist/{chunk-PGHTIMRD.mjs → chunk-AGOMDWP5.mjs} +28 -19
- package/dist/{chunk-FKPYFM6G.mjs → chunk-AYCSVKI2.mjs} +1 -1
- package/dist/{chunk-ALV6GETG.mjs → chunk-BLXQGQLK.mjs} +1 -1
- package/dist/{chunk-STKN6A5M.js → chunk-D7WFIGXW.js} +2 -2
- package/dist/{chunk-E6XO2STS.js → chunk-FRCDMQER.js} +0 -14
- package/dist/{chunk-QPDXDX7A.js → chunk-GCRHSPZN.js} +2 -2
- package/dist/{chunk-TV4G2KMD.mjs → chunk-IRTRJH37.mjs} +1 -1
- package/dist/{chunk-3RFFA4EV.mjs → chunk-ITTQ4FGR.mjs} +1 -1
- package/dist/{chunk-FKETRWAF.js → chunk-J5HRK3WD.js} +2 -2
- package/dist/{chunk-CE25ADK5.js → chunk-J7TJ2DK2.js} +51 -42
- package/dist/{chunk-6MXQAQBB.mjs → chunk-KNYZH2WD.mjs} +1 -1
- package/dist/chunk-KWVCGQ7N.mjs +78 -0
- package/dist/chunk-MAKSIK3P.js +10 -0
- package/dist/{chunk-H3VBSMVW.js → chunk-N7T66JVY.js} +2 -21
- package/dist/{chunk-UPEQEX2D.js → chunk-OAQWRMTP.js} +2 -2
- package/dist/{chunk-VC4E3OSZ.mjs → chunk-OLJLCVNY.mjs} +1 -1
- package/dist/{chunk-ANP6HGMJ.js → chunk-P2BE2A2G.js} +4 -4
- package/dist/{chunk-HJNLL34O.js → chunk-QWZHR2OO.js} +2 -2
- package/dist/{chunk-XAORXFAX.mjs → chunk-QY6QFRRV.mjs} +1 -12
- package/dist/{chunk-XPFWKISJ.mjs → chunk-R4CJHCC4.mjs} +1 -1
- package/dist/{chunk-5CBTJS7J.js → chunk-RJ4LOX7P.js} +2 -2
- package/dist/{chunk-C7KW4NAD.js → chunk-ROAZLZA2.js} +2 -2
- package/dist/{chunk-4IVCBFJA.mjs → chunk-RUYUFXNW.mjs} +1 -1
- package/dist/{chunk-PZT3CIHD.mjs → chunk-SS2NR6DH.mjs} +2 -18
- package/dist/{chunk-5SQEKHPW.js → chunk-T225DB55.js} +7 -52
- package/dist/{chunk-ATA4XHB4.js → chunk-TKN73433.js} +2 -2
- package/dist/{chunk-2LUHLHLE.mjs → chunk-TMYBEXBT.mjs} +1 -1
- package/dist/{chunk-JEDANRCG.mjs → chunk-UQVW4KPP.mjs} +7 -51
- package/dist/{chunk-IMEPIVTR.js → chunk-V6DE3MXC.js} +1 -38
- package/dist/{chunk-KC2FFNL4.js → chunk-VXOTYFEW.js} +2 -2
- package/dist/{chunk-RDGBQM3N.mjs → chunk-WV4V64D5.mjs} +1 -1
- package/dist/helpers-DD6JzYfI.d.mts +860 -0
- package/dist/helpers-kMS5R7KX.d.ts +860 -0
- package/dist/index.d.mts +718 -2804
- package/dist/index.d.ts +718 -2804
- package/dist/index.js +2055 -3922
- package/dist/index.mjs +2467 -3985
- package/dist/{types-Ms3HtAmo.d.mts → types-BAPgWlpX.d.mts} +1 -1
- package/dist/{types-D-0QbsA9.d.ts → types-mZPUEZl0.d.ts} +1 -1
- package/dist/utils.d.mts +1 -55
- package/dist/utils.d.ts +1 -55
- package/dist/utils.js +6 -18
- package/dist/utils.mjs +1 -1
- package/dist/validation/all.d.mts +5 -20
- package/dist/validation/all.d.ts +5 -20
- package/dist/validation/all.js +27 -236
- package/dist/validation/all.mjs +19 -20
- package/dist/validation/complex/currency.d.mts +2 -2
- package/dist/validation/complex/currency.d.ts +2 -2
- package/dist/validation/complex/currency.js +3 -4
- package/dist/validation/complex/currency.mjs +2 -3
- package/dist/validation/complex/file.d.mts +2 -2
- package/dist/validation/complex/file.d.ts +2 -2
- package/dist/validation/complex/file.js +3 -4
- package/dist/validation/complex/file.mjs +2 -3
- package/dist/validation/complex/location.d.mts +2 -2
- package/dist/validation/complex/location.d.ts +2 -2
- package/dist/validation/complex/location.js +3 -4
- package/dist/validation/complex/location.mjs +2 -3
- package/dist/validation/complex/phone.d.mts +2 -2
- package/dist/validation/complex/phone.d.ts +2 -2
- package/dist/validation/complex/phone.js +3 -4
- package/dist/validation/complex/phone.mjs +2 -3
- package/dist/validation/complex/relation.d.mts +2 -2
- package/dist/validation/complex/relation.d.ts +2 -2
- package/dist/validation/complex/relation.js +5 -6
- package/dist/validation/complex/relation.mjs +2 -3
- package/dist/validation/complex/richtext.d.mts +2 -2
- package/dist/validation/complex/richtext.d.ts +2 -2
- package/dist/validation/complex/richtext.js +3 -4
- package/dist/validation/complex/richtext.mjs +2 -3
- package/dist/validation/complex/select.d.mts +2 -2
- package/dist/validation/complex/select.d.ts +2 -2
- package/dist/validation/complex/select.js +5 -6
- package/dist/validation/complex/select.mjs +2 -3
- package/dist/validation/complex/user.d.mts +2 -2
- package/dist/validation/complex/user.d.ts +2 -2
- package/dist/validation/complex/user.js +3 -4
- package/dist/validation/complex/user.mjs +2 -3
- package/dist/validation/computed/formula.d.mts +2 -2
- package/dist/validation/computed/formula.d.ts +2 -2
- package/dist/validation/computed/formula.js +3 -4
- package/dist/validation/computed/formula.mjs +2 -3
- package/dist/validation/computed/rollup.d.mts +2 -2
- package/dist/validation/computed/rollup.d.ts +2 -2
- package/dist/validation/computed/rollup.js +3 -4
- package/dist/validation/computed/rollup.mjs +2 -3
- package/dist/validation/config/index.d.mts +2 -403
- package/dist/validation/config/index.d.ts +2 -403
- package/dist/validation/config/index.js +4 -89
- package/dist/validation/config/index.mjs +1 -2
- package/dist/validation/core/index.d.mts +4 -53
- package/dist/validation/core/index.d.ts +4 -53
- package/dist/validation/core/index.js +3 -12
- package/dist/validation/core/index.mjs +1 -2
- package/dist/validation/object/index.d.mts +29 -4
- package/dist/validation/object/index.d.ts +29 -4
- package/dist/validation/object/index.js +29 -30
- package/dist/validation/object/index.mjs +17 -18
- package/dist/validation/primitives/checkbox.d.mts +2 -2
- package/dist/validation/primitives/checkbox.d.ts +2 -2
- package/dist/validation/primitives/checkbox.js +3 -4
- package/dist/validation/primitives/checkbox.mjs +2 -3
- package/dist/validation/primitives/date.d.mts +2 -2
- package/dist/validation/primitives/date.d.ts +2 -2
- package/dist/validation/primitives/date.js +3 -4
- package/dist/validation/primitives/date.mjs +2 -3
- package/dist/validation/primitives/number.d.mts +2 -2
- package/dist/validation/primitives/number.d.ts +2 -2
- package/dist/validation/primitives/number.js +3 -4
- package/dist/validation/primitives/number.mjs +2 -3
- package/dist/validation/primitives/rating.d.mts +2 -2
- package/dist/validation/primitives/rating.d.ts +2 -2
- package/dist/validation/primitives/rating.js +3 -4
- package/dist/validation/primitives/rating.mjs +2 -3
- package/dist/validation/primitives/text.d.mts +2 -2
- package/dist/validation/primitives/text.d.ts +2 -2
- package/dist/validation/primitives/text.js +4 -5
- package/dist/validation/primitives/text.mjs +2 -3
- package/package.json +2 -3
- package/dist/chunk-4DMDOSFN.js +0 -10
- package/dist/chunk-7FSIBNRH.mjs +0 -25
- package/dist/chunk-BEN6TE7Y.js +0 -11
- package/dist/chunk-RDXQ4CYT.mjs +0 -9
- package/dist/chunk-ZWMMEQI7.js +0 -28
- package/dist/index-CftmKoRP.d.mts +0 -2053
- package/dist/index-Dh_XiNFt.d.ts +0 -2053
- package/dist/validation/validators.d.mts +0 -23
- package/dist/validation/validators.d.ts +0 -23
- package/dist/validation/validators.js +0 -265
- package/dist/validation/validators.mjs +0 -20
- /package/dist/{chunk-R6JFUC32.js → chunk-PGERPYDR.js} +0 -0
- /package/dist/{chunk-EKG35CSO.mjs → chunk-SP3PNHYF.mjs} +0 -0
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { DEFAULT_VALIDATION_MESSAGES } from './chunk-UQVW4KPP.mjs';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
|
|
4
|
+
// src/lib/lru-cache.ts
|
|
5
|
+
var LRUCache = class {
|
|
6
|
+
constructor(capacity) {
|
|
7
|
+
if (capacity <= 0) {
|
|
8
|
+
throw new Error("LRU cache capacity must be greater than 0");
|
|
9
|
+
}
|
|
10
|
+
this.capacity = capacity;
|
|
11
|
+
this.cache = /* @__PURE__ */ new Map();
|
|
12
|
+
}
|
|
13
|
+
get(key) {
|
|
14
|
+
const value = this.cache.get(key);
|
|
15
|
+
if (value !== void 0) {
|
|
16
|
+
this.cache.delete(key);
|
|
17
|
+
this.cache.set(key, value);
|
|
18
|
+
}
|
|
19
|
+
return value;
|
|
20
|
+
}
|
|
21
|
+
set(key, value) {
|
|
22
|
+
if (this.cache.has(key)) {
|
|
23
|
+
this.cache.delete(key);
|
|
24
|
+
} else if (this.cache.size >= this.capacity) {
|
|
25
|
+
const firstKey = this.cache.keys().next().value;
|
|
26
|
+
if (firstKey !== void 0) {
|
|
27
|
+
this.cache.delete(firstKey);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
this.cache.set(key, value);
|
|
31
|
+
}
|
|
32
|
+
has(key) {
|
|
33
|
+
return this.cache.has(key);
|
|
34
|
+
}
|
|
35
|
+
clear() {
|
|
36
|
+
this.cache.clear();
|
|
37
|
+
}
|
|
38
|
+
get size() {
|
|
39
|
+
return this.cache.size;
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
// src/validation/core/regex-cache.ts
|
|
44
|
+
function createRegexCache(capacity = 100) {
|
|
45
|
+
return new LRUCache(capacity);
|
|
46
|
+
}
|
|
47
|
+
function getCachedRegex(cache, pattern) {
|
|
48
|
+
let cached = cache.get(pattern);
|
|
49
|
+
if (!cached) {
|
|
50
|
+
cached = new RegExp(pattern);
|
|
51
|
+
cache.set(pattern, cached);
|
|
52
|
+
}
|
|
53
|
+
return cached;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// src/validation/primitives/text.ts
|
|
57
|
+
var textRegexCache = createRegexCache();
|
|
58
|
+
function createTextValidator(attr, messages = DEFAULT_VALIDATION_MESSAGES) {
|
|
59
|
+
let schema = z.string();
|
|
60
|
+
if (attr.minLength !== void 0) {
|
|
61
|
+
schema = schema.min(attr.minLength, messages.minLength(attr, attr.minLength));
|
|
62
|
+
}
|
|
63
|
+
if (attr.maxLength !== void 0) {
|
|
64
|
+
schema = schema.max(attr.maxLength, messages.maxLength(attr, attr.maxLength));
|
|
65
|
+
}
|
|
66
|
+
if (attr.pattern) {
|
|
67
|
+
schema = schema.regex(
|
|
68
|
+
getCachedRegex(textRegexCache, attr.pattern),
|
|
69
|
+
messages.invalidPattern(attr)
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
return schema;
|
|
73
|
+
}
|
|
74
|
+
function createTextAreaValidator(_attr, _messages = DEFAULT_VALIDATION_MESSAGES) {
|
|
75
|
+
return z.string();
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export { createTextAreaValidator, createTextValidator };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkT225DB55_js = require('./chunk-T225DB55.js');
|
|
4
|
+
var zod = require('zod');
|
|
5
|
+
|
|
6
|
+
function createCheckboxValidator(_attr, _messages = chunkT225DB55_js.DEFAULT_VALIDATION_MESSAGES) {
|
|
7
|
+
return zod.z.boolean();
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
exports.createCheckboxValidator = createCheckboxValidator;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkT225DB55_js = require('./chunk-T225DB55.js');
|
|
4
4
|
var constants = require('@stndrds/constants');
|
|
5
5
|
var zod = require('zod');
|
|
6
6
|
var libphonenumberJs = require('libphonenumber-js');
|
|
@@ -63,25 +63,9 @@ function formatPhoneForDisplay(phone) {
|
|
|
63
63
|
}
|
|
64
64
|
return `${dial} ${phone.phoneNumber}`.trim();
|
|
65
65
|
}
|
|
66
|
-
function parseRawPhoneInput(rawInput, countryIso3) {
|
|
67
|
-
if (!rawInput || rawInput.trim() === "") {
|
|
68
|
-
return { success: false, error: "Phone number is empty" };
|
|
69
|
-
}
|
|
70
|
-
const normalized = normalizePhoneNumber(rawInput, countryIso3);
|
|
71
|
-
if (!normalized) {
|
|
72
|
-
return { success: false, error: "Could not extract digits from input" };
|
|
73
|
-
}
|
|
74
|
-
if (!validatePhoneNumber(normalized, countryIso3)) {
|
|
75
|
-
return { success: false, error: "Invalid phone number for country" };
|
|
76
|
-
}
|
|
77
|
-
return {
|
|
78
|
-
success: true,
|
|
79
|
-
phone: { countryCode: countryIso3, phoneNumber: normalized }
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
66
|
|
|
83
67
|
// src/validation/complex/phone.ts
|
|
84
|
-
function createPhoneValidator(attr, messages =
|
|
68
|
+
function createPhoneValidator(attr, messages = chunkT225DB55_js.DEFAULT_VALIDATION_MESSAGES) {
|
|
85
69
|
return zod.z.object(
|
|
86
70
|
{
|
|
87
71
|
countryCode: zod.z.string().length(3),
|
|
@@ -100,6 +84,3 @@ function createPhoneValidator(attr, messages = chunk5SQEKHPW_js.DEFAULT_VALIDATI
|
|
|
100
84
|
|
|
101
85
|
exports.createPhoneValidator = createPhoneValidator;
|
|
102
86
|
exports.formatPhoneForDisplay = formatPhoneForDisplay;
|
|
103
|
-
exports.normalizePhoneNumber = normalizePhoneNumber;
|
|
104
|
-
exports.parseRawPhoneInput = parseRawPhoneInput;
|
|
105
|
-
exports.validatePhoneNumber = validatePhoneNumber;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkT225DB55_js = require('./chunk-T225DB55.js');
|
|
4
4
|
var zod = require('zod');
|
|
5
5
|
|
|
6
|
-
function createFormulaValidator(_attr, _messages =
|
|
6
|
+
function createFormulaValidator(_attr, _messages = chunkT225DB55_js.DEFAULT_VALIDATION_MESSAGES) {
|
|
7
7
|
return zod.z.unknown();
|
|
8
8
|
}
|
|
9
9
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkT225DB55_js = require('./chunk-T225DB55.js');
|
|
4
4
|
var zod = require('zod');
|
|
5
5
|
|
|
6
6
|
function extractRelationId(item) {
|
|
@@ -9,7 +9,7 @@ function extractRelationId(item) {
|
|
|
9
9
|
}
|
|
10
10
|
return item;
|
|
11
11
|
}
|
|
12
|
-
function createSingleRelationValidator(attr, messages =
|
|
12
|
+
function createSingleRelationValidator(attr, messages = chunkT225DB55_js.DEFAULT_VALIDATION_MESSAGES) {
|
|
13
13
|
const uuidSchema = zod.z.uuid({
|
|
14
14
|
message: messages.invalidId(attr)
|
|
15
15
|
});
|
|
@@ -23,7 +23,7 @@ function createSingleRelationValidator(attr, messages = chunk5SQEKHPW_js.DEFAULT
|
|
|
23
23
|
// Allow additional properties (bilateral relations may have extra metadata)
|
|
24
24
|
]);
|
|
25
25
|
}
|
|
26
|
-
function createMultiRelationValidator(attr, messages =
|
|
26
|
+
function createMultiRelationValidator(attr, messages = chunkT225DB55_js.DEFAULT_VALIDATION_MESSAGES) {
|
|
27
27
|
const uuidSchema = zod.z.uuid({
|
|
28
28
|
message: messages.invalidId(attr)
|
|
29
29
|
});
|
|
@@ -52,7 +52,7 @@ function createMultiRelationValidator(attr, messages = chunk5SQEKHPW_js.DEFAULT_
|
|
|
52
52
|
{ message: messages.invalidId(attr) }
|
|
53
53
|
);
|
|
54
54
|
}
|
|
55
|
-
function createRelationValidator(attr, messages =
|
|
55
|
+
function createRelationValidator(attr, messages = chunkT225DB55_js.DEFAULT_VALIDATION_MESSAGES) {
|
|
56
56
|
if (attr.cardinality === "many") {
|
|
57
57
|
return createMultiRelationValidator(attr, messages);
|
|
58
58
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkT225DB55_js = require('./chunk-T225DB55.js');
|
|
4
4
|
var zod = require('zod');
|
|
5
5
|
|
|
6
|
-
function createRichtextValidator(attr, messages =
|
|
6
|
+
function createRichtextValidator(attr, messages = chunkT225DB55_js.DEFAULT_VALIDATION_MESSAGES) {
|
|
7
7
|
return zod.z.string({
|
|
8
8
|
message: messages.invalidRichtext(attr)
|
|
9
9
|
});
|
|
@@ -15,17 +15,6 @@ function generateId() {
|
|
|
15
15
|
return v.toString(16);
|
|
16
16
|
});
|
|
17
17
|
}
|
|
18
|
-
function generatePrefixedId(prefix) {
|
|
19
|
-
return `${prefix}_${generateId()}`;
|
|
20
|
-
}
|
|
21
|
-
function slugify(input) {
|
|
22
|
-
return input.normalize("NFD").replace(/\p{M}/gu, "").toLowerCase().replace(/[^a-z0-9\s_-]/g, "").trim().replace(/\s+/g, "-").replace(/-+/g, "-");
|
|
23
|
-
}
|
|
24
|
-
function generateTemplateName(label) {
|
|
25
|
-
const slug = slugify(label) || "template";
|
|
26
|
-
const suffix = generateId().slice(0, 8);
|
|
27
|
-
return `${slug}-${suffix}`;
|
|
28
|
-
}
|
|
29
18
|
function indexBy(items, keyFn) {
|
|
30
19
|
return new Map(items.map((item) => [keyFn(item), item]));
|
|
31
20
|
}
|
|
@@ -49,4 +38,4 @@ function deepEqual(a, b) {
|
|
|
49
38
|
return false;
|
|
50
39
|
}
|
|
51
40
|
|
|
52
|
-
export { asTenantId, asUserId, deepEqual, generateId,
|
|
41
|
+
export { asTenantId, asUserId, deepEqual, generateId, indexBy };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkT225DB55_js = require('./chunk-T225DB55.js');
|
|
4
4
|
var zod = require('zod');
|
|
5
5
|
|
|
6
|
-
function createLocationValidator(attr, messages =
|
|
6
|
+
function createLocationValidator(attr, messages = chunkT225DB55_js.DEFAULT_VALIDATION_MESSAGES) {
|
|
7
7
|
return zod.z.object(
|
|
8
8
|
{
|
|
9
9
|
address: zod.z.string().optional(),
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkT225DB55_js = require('./chunk-T225DB55.js');
|
|
4
4
|
var zod = require('zod');
|
|
5
5
|
|
|
6
|
-
function createFileValidator(attr, messages =
|
|
6
|
+
function createFileValidator(attr, messages = chunkT225DB55_js.DEFAULT_VALIDATION_MESSAGES) {
|
|
7
7
|
const uuidSchema = zod.z.uuid({
|
|
8
8
|
message: messages.invalidId(attr)
|
|
9
9
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { formatZodErrors } from './chunk-RDXQ4CYT.mjs';
|
|
2
1
|
import { z } from 'zod';
|
|
3
2
|
|
|
3
|
+
// src/validation/config/schemas.ts
|
|
4
4
|
var baseConfigSchema = z.object({
|
|
5
5
|
disabled: z.boolean().optional(),
|
|
6
6
|
placeholder: z.string().optional(),
|
|
@@ -168,25 +168,9 @@ var attributeConfigSchemas = {
|
|
|
168
168
|
function getAttributeConfigSchema(type) {
|
|
169
169
|
return attributeConfigSchemas[type];
|
|
170
170
|
}
|
|
171
|
-
function validateAttributeConfig(type, config) {
|
|
172
|
-
const schema = getAttributeConfigSchema(type);
|
|
173
|
-
const result = schema.safeParse(config);
|
|
174
|
-
if (result.success) {
|
|
175
|
-
return { success: true, data: result.data };
|
|
176
|
-
}
|
|
177
|
-
return {
|
|
178
|
-
success: false,
|
|
179
|
-
errors: formatZodErrors(result.error).map((err) => `${err.path.join(".")}: ${err.message}`)
|
|
180
|
-
};
|
|
181
|
-
}
|
|
182
171
|
function parseAttributeConfig(type, config) {
|
|
183
172
|
const schema = getAttributeConfigSchema(type);
|
|
184
173
|
return schema.strip().parse(config);
|
|
185
174
|
}
|
|
186
|
-
function safeParseAttributeConfig(type, config) {
|
|
187
|
-
const schema = getAttributeConfigSchema(type);
|
|
188
|
-
const result = schema.strip().safeParse(config);
|
|
189
|
-
return result.success ? result.data : void 0;
|
|
190
|
-
}
|
|
191
175
|
|
|
192
|
-
export { attributeConfigSchemas,
|
|
176
|
+
export { attributeConfigSchemas, getAttributeConfigSchema, parseAttributeConfig };
|
|
@@ -21,58 +21,13 @@ var DEFAULT_VALIDATION_MESSAGES = {
|
|
|
21
21
|
invalidLocation: (attr) => `${attr.label} must be a valid location`
|
|
22
22
|
};
|
|
23
23
|
|
|
24
|
-
// src/
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
this.capacity = capacity;
|
|
31
|
-
this.cache = /* @__PURE__ */ new Map();
|
|
32
|
-
}
|
|
33
|
-
get(key) {
|
|
34
|
-
const value = this.cache.get(key);
|
|
35
|
-
if (value !== void 0) {
|
|
36
|
-
this.cache.delete(key);
|
|
37
|
-
this.cache.set(key, value);
|
|
38
|
-
}
|
|
39
|
-
return value;
|
|
40
|
-
}
|
|
41
|
-
set(key, value) {
|
|
42
|
-
if (this.cache.has(key)) {
|
|
43
|
-
this.cache.delete(key);
|
|
44
|
-
} else if (this.cache.size >= this.capacity) {
|
|
45
|
-
const firstKey = this.cache.keys().next().value;
|
|
46
|
-
if (firstKey !== void 0) {
|
|
47
|
-
this.cache.delete(firstKey);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
this.cache.set(key, value);
|
|
51
|
-
}
|
|
52
|
-
has(key) {
|
|
53
|
-
return this.cache.has(key);
|
|
54
|
-
}
|
|
55
|
-
clear() {
|
|
56
|
-
this.cache.clear();
|
|
57
|
-
}
|
|
58
|
-
get size() {
|
|
59
|
-
return this.cache.size;
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
// src/validation/core/regex-cache.ts
|
|
64
|
-
function createRegexCache(capacity = 100) {
|
|
65
|
-
return new LRUCache(capacity);
|
|
66
|
-
}
|
|
67
|
-
function getCachedRegex(cache, pattern) {
|
|
68
|
-
let cached = cache.get(pattern);
|
|
69
|
-
if (!cached) {
|
|
70
|
-
cached = new RegExp(pattern);
|
|
71
|
-
cache.set(pattern, cached);
|
|
72
|
-
}
|
|
73
|
-
return cached;
|
|
24
|
+
// src/validation/core/errors.ts
|
|
25
|
+
function formatZodErrors(error) {
|
|
26
|
+
return error.issues.map((err) => ({
|
|
27
|
+
path: err.path.map(String),
|
|
28
|
+
message: err.message
|
|
29
|
+
}));
|
|
74
30
|
}
|
|
75
31
|
|
|
76
32
|
exports.DEFAULT_VALIDATION_MESSAGES = DEFAULT_VALIDATION_MESSAGES;
|
|
77
|
-
exports.
|
|
78
|
-
exports.getCachedRegex = getCachedRegex;
|
|
33
|
+
exports.formatZodErrors = formatZodErrors;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkT225DB55_js = require('./chunk-T225DB55.js');
|
|
4
4
|
var zod = require('zod');
|
|
5
5
|
|
|
6
|
-
function createNumberValidator(attr, messages =
|
|
6
|
+
function createNumberValidator(attr, messages = chunkT225DB55_js.DEFAULT_VALIDATION_MESSAGES) {
|
|
7
7
|
let schema = zod.z.number();
|
|
8
8
|
if (attr.min !== void 0) {
|
|
9
9
|
schema = schema.min(attr.min, messages.minValue(attr, attr.min));
|
|
@@ -19,56 +19,12 @@ var DEFAULT_VALIDATION_MESSAGES = {
|
|
|
19
19
|
invalidLocation: (attr) => `${attr.label} must be a valid location`
|
|
20
20
|
};
|
|
21
21
|
|
|
22
|
-
// src/
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
this.capacity = capacity;
|
|
29
|
-
this.cache = /* @__PURE__ */ new Map();
|
|
30
|
-
}
|
|
31
|
-
get(key) {
|
|
32
|
-
const value = this.cache.get(key);
|
|
33
|
-
if (value !== void 0) {
|
|
34
|
-
this.cache.delete(key);
|
|
35
|
-
this.cache.set(key, value);
|
|
36
|
-
}
|
|
37
|
-
return value;
|
|
38
|
-
}
|
|
39
|
-
set(key, value) {
|
|
40
|
-
if (this.cache.has(key)) {
|
|
41
|
-
this.cache.delete(key);
|
|
42
|
-
} else if (this.cache.size >= this.capacity) {
|
|
43
|
-
const firstKey = this.cache.keys().next().value;
|
|
44
|
-
if (firstKey !== void 0) {
|
|
45
|
-
this.cache.delete(firstKey);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
this.cache.set(key, value);
|
|
49
|
-
}
|
|
50
|
-
has(key) {
|
|
51
|
-
return this.cache.has(key);
|
|
52
|
-
}
|
|
53
|
-
clear() {
|
|
54
|
-
this.cache.clear();
|
|
55
|
-
}
|
|
56
|
-
get size() {
|
|
57
|
-
return this.cache.size;
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
// src/validation/core/regex-cache.ts
|
|
62
|
-
function createRegexCache(capacity = 100) {
|
|
63
|
-
return new LRUCache(capacity);
|
|
64
|
-
}
|
|
65
|
-
function getCachedRegex(cache, pattern) {
|
|
66
|
-
let cached = cache.get(pattern);
|
|
67
|
-
if (!cached) {
|
|
68
|
-
cached = new RegExp(pattern);
|
|
69
|
-
cache.set(pattern, cached);
|
|
70
|
-
}
|
|
71
|
-
return cached;
|
|
22
|
+
// src/validation/core/errors.ts
|
|
23
|
+
function formatZodErrors(error) {
|
|
24
|
+
return error.issues.map((err) => ({
|
|
25
|
+
path: err.path.map(String),
|
|
26
|
+
message: err.message
|
|
27
|
+
}));
|
|
72
28
|
}
|
|
73
29
|
|
|
74
|
-
export { DEFAULT_VALIDATION_MESSAGES,
|
|
30
|
+
export { DEFAULT_VALIDATION_MESSAGES, formatZodErrors };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var chunkBEN6TE7Y_js = require('./chunk-BEN6TE7Y.js');
|
|
4
3
|
var zod = require('zod');
|
|
5
4
|
|
|
5
|
+
// src/validation/config/schemas.ts
|
|
6
6
|
var baseConfigSchema = zod.z.object({
|
|
7
7
|
disabled: zod.z.boolean().optional(),
|
|
8
8
|
placeholder: zod.z.string().optional(),
|
|
@@ -170,48 +170,11 @@ var attributeConfigSchemas = {
|
|
|
170
170
|
function getAttributeConfigSchema(type) {
|
|
171
171
|
return attributeConfigSchemas[type];
|
|
172
172
|
}
|
|
173
|
-
function validateAttributeConfig(type, config) {
|
|
174
|
-
const schema = getAttributeConfigSchema(type);
|
|
175
|
-
const result = schema.safeParse(config);
|
|
176
|
-
if (result.success) {
|
|
177
|
-
return { success: true, data: result.data };
|
|
178
|
-
}
|
|
179
|
-
return {
|
|
180
|
-
success: false,
|
|
181
|
-
errors: chunkBEN6TE7Y_js.formatZodErrors(result.error).map((err) => `${err.path.join(".")}: ${err.message}`)
|
|
182
|
-
};
|
|
183
|
-
}
|
|
184
173
|
function parseAttributeConfig(type, config) {
|
|
185
174
|
const schema = getAttributeConfigSchema(type);
|
|
186
175
|
return schema.strip().parse(config);
|
|
187
176
|
}
|
|
188
|
-
function safeParseAttributeConfig(type, config) {
|
|
189
|
-
const schema = getAttributeConfigSchema(type);
|
|
190
|
-
const result = schema.strip().safeParse(config);
|
|
191
|
-
return result.success ? result.data : void 0;
|
|
192
|
-
}
|
|
193
177
|
|
|
194
178
|
exports.attributeConfigSchemas = attributeConfigSchemas;
|
|
195
|
-
exports.checkboxConfigSchema = checkboxConfigSchema;
|
|
196
|
-
exports.currencyConfigSchema = currencyConfigSchema;
|
|
197
|
-
exports.dateConfigSchema = dateConfigSchema;
|
|
198
|
-
exports.documentConfigSchema = documentConfigSchema;
|
|
199
|
-
exports.fileConfigSchema = fileConfigSchema;
|
|
200
|
-
exports.formulaConfigSchema = formulaConfigSchema;
|
|
201
179
|
exports.getAttributeConfigSchema = getAttributeConfigSchema;
|
|
202
|
-
exports.locationConfigSchema = locationConfigSchema;
|
|
203
|
-
exports.multiselectConfigSchema = multiselectConfigSchema;
|
|
204
|
-
exports.numberConfigSchema = numberConfigSchema;
|
|
205
180
|
exports.parseAttributeConfig = parseAttributeConfig;
|
|
206
|
-
exports.phoneConfigSchema = phoneConfigSchema;
|
|
207
|
-
exports.ratingConfigSchema = ratingConfigSchema;
|
|
208
|
-
exports.relationConfigSchema = relationConfigSchema;
|
|
209
|
-
exports.richtextConfigSchema = richtextConfigSchema;
|
|
210
|
-
exports.rollupConfigSchema = rollupConfigSchema;
|
|
211
|
-
exports.safeParseAttributeConfig = safeParseAttributeConfig;
|
|
212
|
-
exports.selectConfigSchema = selectConfigSchema;
|
|
213
|
-
exports.statusConfigSchema = statusConfigSchema;
|
|
214
|
-
exports.textConfigSchema = textConfigSchema;
|
|
215
|
-
exports.textareaConfigSchema = textareaConfigSchema;
|
|
216
|
-
exports.userConfigSchema = userConfigSchema;
|
|
217
|
-
exports.validateAttributeConfig = validateAttributeConfig;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkT225DB55_js = require('./chunk-T225DB55.js');
|
|
4
4
|
var zod = require('zod');
|
|
5
5
|
|
|
6
|
-
function createUserValidator(attr, messages =
|
|
6
|
+
function createUserValidator(attr, messages = chunkT225DB55_js.DEFAULT_VALIDATION_MESSAGES) {
|
|
7
7
|
const uuidSchema = zod.z.uuid({
|
|
8
8
|
message: messages.invalidId(attr)
|
|
9
9
|
});
|