@stndrds/schema 1.0.0-alpha.265 → 1.0.0-alpha.266
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/all--B2_3ksI.d.ts +465 -0
- package/dist/all-D5zeUllO.d.mts +465 -0
- package/dist/chunk-6ZDH3EJA.js +1261 -0
- package/dist/chunk-F6ATLCIR.mjs +1214 -0
- package/dist/{chunk-ZBQEMIAV.js → chunk-FDIAOFHS.js} +11 -8
- package/dist/{chunk-UXCJ3NI4.mjs → chunk-KDHDC7E6.mjs} +150 -9
- package/dist/{chunk-U36ZIBEM.mjs → chunk-O73ROMWQ.mjs} +15 -6
- package/dist/{chunk-QIWADKYA.mjs → chunk-POULKEJM.mjs} +11 -9
- package/dist/{chunk-EBGRZUIH.js → chunk-Q4SZAMJT.js} +5 -0
- package/dist/{chunk-NGGU6BSN.mjs → chunk-QMLO7V5E.mjs} +6 -6
- package/dist/{chunk-L4U5QEQL.js → chunk-QN2N3IJZ.js} +158 -8
- package/dist/{chunk-JUKLL5RJ.mjs → chunk-R5LAJCBU.mjs} +5 -2
- package/dist/{chunk-NI3HCSYH.js → chunk-V6Q7HCA7.js} +11 -11
- package/dist/{chunk-QAF3HNKQ.js → chunk-ZPFOKBIN.js} +16 -5
- package/dist/exceptions.d.mts +21 -8
- package/dist/exceptions.d.ts +21 -8
- package/dist/exceptions.js +42 -38
- package/dist/exceptions.mjs +1 -1
- package/dist/helpers-C1VVEAOO.d.mts +76 -0
- package/dist/helpers-vQ6kp8ET.d.ts +76 -0
- package/dist/index-Bq1KrQkR.d.ts +2413 -0
- package/dist/index-DtxtOBYT.d.mts +2413 -0
- package/dist/index.d.mts +1489 -2222
- package/dist/index.d.ts +1489 -2222
- package/dist/index.js +1274 -1038
- package/dist/index.mjs +894 -905
- package/dist/{helpers-eyrnPJEF.d.ts → objects-A1ED9af-.d.ts} +32 -77
- package/dist/{helpers-uKLet0kF.d.mts → objects-BCaBw2ef.d.mts} +32 -77
- package/dist/validation/all.d.mts +4 -2
- package/dist/validation/all.d.ts +4 -2
- package/dist/validation/all.js +88 -16
- package/dist/validation/all.mjs +9 -9
- package/dist/validation/complex/phone.js +2 -2
- package/dist/validation/complex/phone.mjs +1 -1
- package/dist/validation/config/index.d.mts +5 -18
- package/dist/validation/config/index.d.ts +5 -18
- package/dist/validation/config/index.js +34 -4
- package/dist/validation/config/index.mjs +7 -1
- package/dist/validation/object/index.d.mts +2 -2
- package/dist/validation/object/index.d.ts +2 -2
- package/dist/validation/object/index.js +19 -19
- package/dist/validation/object/index.mjs +7 -7
- package/dist/validation/primitives/text.js +2 -2
- package/dist/validation/primitives/text.mjs +1 -1
- package/package.json +2 -2
- package/dist/chunk-PGERPYDR.js +0 -2
- package/dist/chunk-SP3PNHYF.mjs +0 -1
|
@@ -10,6 +10,7 @@ var SchemaErrorCode = {
|
|
|
10
10
|
RECORD_NOT_FOUND: "SCHEMA_RECORD_NOT_FOUND",
|
|
11
11
|
ROLE_NOT_FOUND: "SCHEMA_ROLE_NOT_FOUND",
|
|
12
12
|
MEMORY_NOT_FOUND: "SCHEMA_MEMORY_NOT_FOUND",
|
|
13
|
+
SCHEMA_PLAN_NOT_FOUND: "SCHEMA_PLAN_NOT_FOUND",
|
|
13
14
|
// Validation
|
|
14
15
|
VALIDATION_FAILED: "SCHEMA_VALIDATION_FAILED",
|
|
15
16
|
INVALID_ATTRIBUTE_NAME: "SCHEMA_INVALID_ATTRIBUTE_NAME",
|
|
@@ -180,6 +181,12 @@ var RecordNotFoundError = class extends NotFoundError {
|
|
|
180
181
|
this.name = "RecordNotFoundError";
|
|
181
182
|
}
|
|
182
183
|
};
|
|
184
|
+
var SchemaPlanNotFoundError = class extends NotFoundError {
|
|
185
|
+
constructor(planId) {
|
|
186
|
+
super("Schema plan", planId, SchemaErrorCode.SCHEMA_PLAN_NOT_FOUND);
|
|
187
|
+
this.name = "SchemaPlanNotFoundError";
|
|
188
|
+
}
|
|
189
|
+
};
|
|
183
190
|
var ValidationError = class _ValidationError extends SchemaError {
|
|
184
191
|
constructor(message, errors) {
|
|
185
192
|
super(message, SchemaErrorCode.VALIDATION_FAILED, { errors });
|
|
@@ -280,19 +287,14 @@ var OrphanSystemAttributeError = class extends SchemaError {
|
|
|
280
287
|
var DestructiveSyncNotAllowedError = class extends SchemaError {
|
|
281
288
|
constructor(operations) {
|
|
282
289
|
const summary = operations.map((op) => {
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
}
|
|
286
|
-
if (op.type === "remove_object") {
|
|
287
|
-
return "- remove_object";
|
|
288
|
-
}
|
|
289
|
-
return `- ${op.type}`;
|
|
290
|
+
const named = op;
|
|
291
|
+
return named.name ? `- ${op.type} "${named.name}"` : `- ${op.type}`;
|
|
290
292
|
}).join("\n");
|
|
291
293
|
super(
|
|
292
294
|
`Destructive schema operations detected (data will be lost):
|
|
293
295
|
${summary}
|
|
294
296
|
|
|
295
|
-
To
|
|
297
|
+
These are applied only under an explicit opt-in; without it boot demotes the object to runtime and keeps its rows. To let Standards apply them automatically, set the environment variable:
|
|
296
298
|
STANDARDS_ALLOW_DESTRUCTIVE_SYNC=1
|
|
297
299
|
|
|
298
300
|
Otherwise, revert your code changes or back up the data first.`,
|
|
@@ -531,6 +533,7 @@ exports.RepositoryError = RepositoryError;
|
|
|
531
533
|
exports.RoleNotFoundError = RoleNotFoundError;
|
|
532
534
|
exports.SchemaError = SchemaError;
|
|
533
535
|
exports.SchemaErrorCode = SchemaErrorCode;
|
|
536
|
+
exports.SchemaPlanNotFoundError = SchemaPlanNotFoundError;
|
|
534
537
|
exports.SearchBackendError = SearchBackendError;
|
|
535
538
|
exports.StorageError = StorageError;
|
|
536
539
|
exports.SyncCascadeError = SyncCascadeError;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { ValidationError } from './chunk-POULKEJM.mjs';
|
|
1
2
|
import { z } from 'zod';
|
|
2
|
-
|
|
3
|
-
// src/validation/config/schemas.ts
|
|
3
|
+
import { ICONS, COLORS } from '@stndrds/constants';
|
|
4
4
|
|
|
5
5
|
// src/computed/parser.ts
|
|
6
6
|
var ComputedFormulaParseError = class extends Error {
|
|
@@ -306,6 +306,39 @@ function getOperatorPrecedence(operator) {
|
|
|
306
306
|
}
|
|
307
307
|
}
|
|
308
308
|
|
|
309
|
+
// src/validation/limits.ts
|
|
310
|
+
var SCHEMA_LIMITS = {
|
|
311
|
+
attributesPerObject: 300,
|
|
312
|
+
tabsPerView: 24,
|
|
313
|
+
groupsPerFormTab: 12,
|
|
314
|
+
fieldsPerGroup: 60,
|
|
315
|
+
fieldsPerFormTab: 150,
|
|
316
|
+
columnsPerTab: 50,
|
|
317
|
+
optionsPerAttribute: 200,
|
|
318
|
+
sidePanelAttributes: 100,
|
|
319
|
+
filterRulesPerTab: 50,
|
|
320
|
+
sortsPerTab: 20,
|
|
321
|
+
emailAttributesPerTab: 30,
|
|
322
|
+
objectsPerPlan: 20,
|
|
323
|
+
mutationsPerPlan: 500,
|
|
324
|
+
planBytes: 512 * 1024,
|
|
325
|
+
historyDefault: 20,
|
|
326
|
+
historyMax: 50,
|
|
327
|
+
iconQueries: 5,
|
|
328
|
+
iconResults: 20
|
|
329
|
+
};
|
|
330
|
+
var COLOR_IDS = Object.keys(COLORS);
|
|
331
|
+
var ICON_NAMES = new Set(ICONS);
|
|
332
|
+
var colorIdSchema = z.enum(COLOR_IDS);
|
|
333
|
+
var iconNameSchema = z.string().superRefine((value, ctx) => {
|
|
334
|
+
if (!ICON_NAMES.has(value)) {
|
|
335
|
+
ctx.addIssue({
|
|
336
|
+
code: "custom",
|
|
337
|
+
message: "Invalid icon name"
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
}).transform((value) => value);
|
|
341
|
+
|
|
309
342
|
// src/validation/config/schemas.ts
|
|
310
343
|
var baseConfigSchema = z.object({
|
|
311
344
|
placeholder: z.string().optional(),
|
|
@@ -318,14 +351,25 @@ var baseConfigSchema = z.object({
|
|
|
318
351
|
deprecated: z.boolean().optional(),
|
|
319
352
|
metadata: z.record(z.string(), z.unknown()).optional()
|
|
320
353
|
});
|
|
321
|
-
var
|
|
354
|
+
var optionBaseSchema = z.object({
|
|
322
355
|
value: z.string().min(1),
|
|
323
356
|
label: z.string().min(1),
|
|
324
|
-
color: z.string().optional(),
|
|
325
357
|
description: z.string().optional(),
|
|
326
|
-
group: z.enum(["idle", "in_progress", "finished"]).optional(),
|
|
327
358
|
inverse: z.string().optional(),
|
|
328
359
|
archived: z.boolean().optional()
|
|
360
|
+
});
|
|
361
|
+
var statusGroupSchema = z.enum(["idle", "in_progress", "finished"]);
|
|
362
|
+
var selectOptionWriteSchema = optionBaseSchema.extend({
|
|
363
|
+
color: colorIdSchema
|
|
364
|
+
}).strict();
|
|
365
|
+
var multiselectOptionWriteSchema = selectOptionWriteSchema;
|
|
366
|
+
var statusOptionWriteSchema = optionBaseSchema.extend({
|
|
367
|
+
color: colorIdSchema,
|
|
368
|
+
group: statusGroupSchema
|
|
369
|
+
}).strict();
|
|
370
|
+
var optionSchema = optionBaseSchema.extend({
|
|
371
|
+
color: z.string().optional(),
|
|
372
|
+
group: statusGroupSchema.optional()
|
|
329
373
|
}).strict();
|
|
330
374
|
var optionsArraySchema = z.array(optionSchema).min(1).refine(
|
|
331
375
|
(options) => {
|
|
@@ -334,6 +378,18 @@ var optionsArraySchema = z.array(optionSchema).min(1).refine(
|
|
|
334
378
|
},
|
|
335
379
|
{ message: "Duplicate option values are not allowed" }
|
|
336
380
|
);
|
|
381
|
+
function writeOptionsArraySchema(option) {
|
|
382
|
+
return z.array(option).min(1).max(SCHEMA_LIMITS.optionsPerAttribute).refine(
|
|
383
|
+
(options) => {
|
|
384
|
+
const values = options.map((candidate) => candidate.value);
|
|
385
|
+
return new Set(values).size === values.length;
|
|
386
|
+
},
|
|
387
|
+
{ message: "Duplicate option values are not allowed" }
|
|
388
|
+
);
|
|
389
|
+
}
|
|
390
|
+
var selectOptionsWriteSchema = writeOptionsArraySchema(selectOptionWriteSchema);
|
|
391
|
+
var multiselectOptionsWriteSchema = writeOptionsArraySchema(multiselectOptionWriteSchema);
|
|
392
|
+
var statusOptionsWriteSchema = writeOptionsArraySchema(statusOptionWriteSchema);
|
|
337
393
|
var relationTargetSchema = z.object({
|
|
338
394
|
object: z.string().min(1),
|
|
339
395
|
displayTemplate: z.string().optional(),
|
|
@@ -369,7 +425,10 @@ var checkboxConfigSchema = baseConfigSchema;
|
|
|
369
425
|
var dateConfigSchema = baseConfigSchema.extend({
|
|
370
426
|
dateFormat: z.enum(["short", "long", "full", "relative"]).optional(),
|
|
371
427
|
minDate: z.string().optional(),
|
|
372
|
-
maxDate: z.string().optional()
|
|
428
|
+
maxDate: z.string().optional(),
|
|
429
|
+
includeTime: z.boolean().optional(),
|
|
430
|
+
endDate: z.boolean().optional(),
|
|
431
|
+
timeFormat: z.enum(["12h", "24h"]).optional()
|
|
373
432
|
});
|
|
374
433
|
var phoneConfigSchema = baseConfigSchema.extend({
|
|
375
434
|
defaultCountryCode: z.string().length(3).optional()
|
|
@@ -388,10 +447,12 @@ var locationConfigSchema = baseConfigSchema.extend({
|
|
|
388
447
|
allowedCountries: z.array(z.string().length(3)).optional()
|
|
389
448
|
});
|
|
390
449
|
var selectConfigSchema = baseConfigSchema.extend({
|
|
391
|
-
options: optionsArraySchema
|
|
450
|
+
options: optionsArraySchema,
|
|
451
|
+
renderAs: z.literal("badges").optional()
|
|
392
452
|
});
|
|
393
453
|
var multiselectConfigSchema = baseConfigSchema.extend({
|
|
394
|
-
options: optionsArraySchema
|
|
454
|
+
options: optionsArraySchema,
|
|
455
|
+
renderAs: z.literal("badges").optional()
|
|
395
456
|
});
|
|
396
457
|
var userConfigSchema = baseConfigSchema.extend({
|
|
397
458
|
types: z.array(z.enum(["user", "agent"])).min(1).optional(),
|
|
@@ -492,5 +553,85 @@ function parseAttributeConfig(type, config) {
|
|
|
492
553
|
const schema = getAttributeConfigSchema(type);
|
|
493
554
|
return schema.strip().parse(config);
|
|
494
555
|
}
|
|
556
|
+
function getAttributeConfigWriteSchema(type) {
|
|
557
|
+
const schema = getAttributeConfigSchema(type).extend({
|
|
558
|
+
icon: iconNameSchema.optional()
|
|
559
|
+
});
|
|
560
|
+
switch (type) {
|
|
561
|
+
case "select":
|
|
562
|
+
return schema.extend({ options: selectOptionsWriteSchema });
|
|
563
|
+
case "multiselect":
|
|
564
|
+
return schema.extend({ options: multiselectOptionsWriteSchema });
|
|
565
|
+
case "status":
|
|
566
|
+
return schema.extend({ options: statusOptionsWriteSchema });
|
|
567
|
+
default:
|
|
568
|
+
return schema;
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
function validationErrorFromIssues(issues) {
|
|
572
|
+
return ValidationError.fromZodErrors(
|
|
573
|
+
issues.map((issue) => ({
|
|
574
|
+
path: issue.path.map((segment) => typeof segment === "symbol" ? String(segment) : segment),
|
|
575
|
+
message: issue.message
|
|
576
|
+
}))
|
|
577
|
+
);
|
|
578
|
+
}
|
|
579
|
+
function parseWriteSchema(type, input) {
|
|
580
|
+
const result = getAttributeConfigWriteSchema(type).strip().safeParse(input);
|
|
581
|
+
if (!result.success) {
|
|
582
|
+
throw validationErrorFromIssues(result.error.issues);
|
|
583
|
+
}
|
|
584
|
+
return result.data;
|
|
585
|
+
}
|
|
586
|
+
function parseAttributeConfigForCreate(type, input) {
|
|
587
|
+
return parseWriteSchema(type, input);
|
|
588
|
+
}
|
|
589
|
+
function validatePatchedIcon(patch) {
|
|
590
|
+
if (!Object.prototype.hasOwnProperty.call(patch, "icon")) {
|
|
591
|
+
return;
|
|
592
|
+
}
|
|
593
|
+
const result = iconNameSchema.optional().safeParse(patch.icon);
|
|
594
|
+
if (!result.success) {
|
|
595
|
+
throw ValidationError.fromZodErrors(
|
|
596
|
+
result.error.issues.map((issue) => ({
|
|
597
|
+
path: [
|
|
598
|
+
"icon",
|
|
599
|
+
...issue.path.map((segment) => typeof segment === "symbol" ? String(segment) : segment)
|
|
600
|
+
],
|
|
601
|
+
message: issue.message
|
|
602
|
+
}))
|
|
603
|
+
);
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
function isSelectLike(type) {
|
|
607
|
+
return type === "select" || type === "multiselect" || type === "status";
|
|
608
|
+
}
|
|
609
|
+
function parseAttributeConfigForUpdate(stored, patch) {
|
|
610
|
+
const ownsOptions = Object.prototype.hasOwnProperty.call(patch, "options");
|
|
611
|
+
const ownsIcon = Object.prototype.hasOwnProperty.call(patch, "icon");
|
|
612
|
+
const input = { ...stored, ...patch };
|
|
613
|
+
validatePatchedIcon(patch);
|
|
614
|
+
if (ownsOptions) {
|
|
615
|
+
const { icon: storedIcon, ...inputWithoutStoredIcon } = input;
|
|
616
|
+
const parsed2 = parseWriteSchema(stored.type, ownsIcon ? input : inputWithoutStoredIcon);
|
|
617
|
+
if (!ownsIcon && storedIcon !== void 0) {
|
|
618
|
+
parsed2.icon = storedIcon;
|
|
619
|
+
}
|
|
620
|
+
return parsed2;
|
|
621
|
+
}
|
|
622
|
+
const storedOptions = stored.options;
|
|
623
|
+
if (isSelectLike(stored.type)) {
|
|
624
|
+
input.options = [{ value: "__legacy__", label: "__legacy__" }];
|
|
625
|
+
}
|
|
626
|
+
const result = getAttributeConfigSchema(stored.type).strip().safeParse(input);
|
|
627
|
+
if (!result.success) {
|
|
628
|
+
throw validationErrorFromIssues(result.error.issues);
|
|
629
|
+
}
|
|
630
|
+
const parsed = result.data;
|
|
631
|
+
if (isSelectLike(stored.type)) {
|
|
632
|
+
parsed.options = storedOptions;
|
|
633
|
+
}
|
|
634
|
+
return parsed;
|
|
635
|
+
}
|
|
495
636
|
|
|
496
|
-
export { ComputedFormulaParseError, attributeConfigSchemas, getAttributeConfigSchema, parseAttributeConfig, parseComputedFormula };
|
|
637
|
+
export { ComputedFormulaParseError, SCHEMA_LIMITS, attributeConfigSchemas, colorIdSchema, getAttributeConfigSchema, iconNameSchema, multiselectOptionWriteSchema, parseAttributeConfig, parseAttributeConfigForCreate, parseAttributeConfigForUpdate, parseComputedFormula, selectOptionWriteSchema, statusGroupSchema, statusOptionWriteSchema };
|
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
import { DEFAULT_VALIDATION_MESSAGES } from './chunk-HRQEZUAA.mjs';
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
|
|
4
|
+
// src/lib/text-format.ts
|
|
5
|
+
var TEXT_FORMAT_PATTERNS = {
|
|
6
|
+
email: "^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$",
|
|
7
|
+
url: "^https?:\\/\\/[\\w\\-]+(\\.[\\w\\-]+)+[/#?]?.*$",
|
|
8
|
+
slug: "^[a-z0-9]+(?:-[a-z0-9]+)*$"
|
|
9
|
+
};
|
|
10
|
+
function resolveTextPattern(attr) {
|
|
11
|
+
if (attr.pattern) return attr.pattern;
|
|
12
|
+
return attr.format ? TEXT_FORMAT_PATTERNS[attr.format] : void 0;
|
|
13
|
+
}
|
|
14
|
+
|
|
4
15
|
// src/lib/lru-cache.ts
|
|
5
16
|
var LRUCache = class {
|
|
6
17
|
constructor(capacity) {
|
|
@@ -64,13 +75,11 @@ function createTextValidator(attr, messages = DEFAULT_VALIDATION_MESSAGES) {
|
|
|
64
75
|
if (attr.maxLength !== void 0) {
|
|
65
76
|
schema = schema.max(attr.maxLength, messages.maxLength(attr, attr.maxLength));
|
|
66
77
|
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
messages.invalidPattern(attr)
|
|
71
|
-
);
|
|
78
|
+
const pattern = resolveTextPattern(attr);
|
|
79
|
+
if (pattern) {
|
|
80
|
+
schema = schema.regex(getCachedRegex(textRegexCache, pattern), messages.invalidPattern(attr));
|
|
72
81
|
}
|
|
73
82
|
return schema;
|
|
74
83
|
}
|
|
75
84
|
|
|
76
|
-
export { createTextValidator };
|
|
85
|
+
export { TEXT_FORMAT_PATTERNS, createTextValidator, resolveTextPattern };
|
|
@@ -8,6 +8,7 @@ var SchemaErrorCode = {
|
|
|
8
8
|
RECORD_NOT_FOUND: "SCHEMA_RECORD_NOT_FOUND",
|
|
9
9
|
ROLE_NOT_FOUND: "SCHEMA_ROLE_NOT_FOUND",
|
|
10
10
|
MEMORY_NOT_FOUND: "SCHEMA_MEMORY_NOT_FOUND",
|
|
11
|
+
SCHEMA_PLAN_NOT_FOUND: "SCHEMA_PLAN_NOT_FOUND",
|
|
11
12
|
// Validation
|
|
12
13
|
VALIDATION_FAILED: "SCHEMA_VALIDATION_FAILED",
|
|
13
14
|
INVALID_ATTRIBUTE_NAME: "SCHEMA_INVALID_ATTRIBUTE_NAME",
|
|
@@ -178,6 +179,12 @@ var RecordNotFoundError = class extends NotFoundError {
|
|
|
178
179
|
this.name = "RecordNotFoundError";
|
|
179
180
|
}
|
|
180
181
|
};
|
|
182
|
+
var SchemaPlanNotFoundError = class extends NotFoundError {
|
|
183
|
+
constructor(planId) {
|
|
184
|
+
super("Schema plan", planId, SchemaErrorCode.SCHEMA_PLAN_NOT_FOUND);
|
|
185
|
+
this.name = "SchemaPlanNotFoundError";
|
|
186
|
+
}
|
|
187
|
+
};
|
|
181
188
|
var ValidationError = class _ValidationError extends SchemaError {
|
|
182
189
|
constructor(message, errors) {
|
|
183
190
|
super(message, SchemaErrorCode.VALIDATION_FAILED, { errors });
|
|
@@ -278,19 +285,14 @@ var OrphanSystemAttributeError = class extends SchemaError {
|
|
|
278
285
|
var DestructiveSyncNotAllowedError = class extends SchemaError {
|
|
279
286
|
constructor(operations) {
|
|
280
287
|
const summary = operations.map((op) => {
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
}
|
|
284
|
-
if (op.type === "remove_object") {
|
|
285
|
-
return "- remove_object";
|
|
286
|
-
}
|
|
287
|
-
return `- ${op.type}`;
|
|
288
|
+
const named = op;
|
|
289
|
+
return named.name ? `- ${op.type} "${named.name}"` : `- ${op.type}`;
|
|
288
290
|
}).join("\n");
|
|
289
291
|
super(
|
|
290
292
|
`Destructive schema operations detected (data will be lost):
|
|
291
293
|
${summary}
|
|
292
294
|
|
|
293
|
-
To
|
|
295
|
+
These are applied only under an explicit opt-in; without it boot demotes the object to runtime and keeps its rows. To let Standards apply them automatically, set the environment variable:
|
|
294
296
|
STANDARDS_ALLOW_DESTRUCTIVE_SYNC=1
|
|
295
297
|
|
|
296
298
|
Otherwise, revert your code changes or back up the data first.`,
|
|
@@ -506,4 +508,4 @@ function isObjectReferencedError(error) {
|
|
|
506
508
|
return error instanceof ObjectReferencedError;
|
|
507
509
|
}
|
|
508
510
|
|
|
509
|
-
export { AccessDeniedError, AttributeInUseError, AttributeNotFoundError, ChangeTypeNotSupportedError, ConcurrentModificationError, DestructiveSyncNotAllowedError, DuplicateError, ForbiddenError, MemoryNotFoundError, MigrationTimeoutError, NotFoundError, NotImplementedError, ObjectNotFoundError, ObjectReferencedError, OrphanSystemAttributeError, ProtectedResourceError, ProtectedRoleError, RecordNotFoundError, RecordReferencedError, RepositoryError, RoleNotFoundError, SchemaError, SchemaErrorCode, SearchBackendError, StorageError, SyncCascadeError, SyncConflictError, SyncError, SystemEntityImmutableError, ValidationError, isAttributeInUseError, isNotFoundError, isObjectReferencedError, isProtectedResourceError, isRecordReferencedError, isSchemaError, isValidationError };
|
|
511
|
+
export { AccessDeniedError, AttributeInUseError, AttributeNotFoundError, ChangeTypeNotSupportedError, ConcurrentModificationError, DestructiveSyncNotAllowedError, DuplicateError, ForbiddenError, MemoryNotFoundError, MigrationTimeoutError, NotFoundError, NotImplementedError, ObjectNotFoundError, ObjectReferencedError, OrphanSystemAttributeError, ProtectedResourceError, ProtectedRoleError, RecordNotFoundError, RecordReferencedError, RepositoryError, RoleNotFoundError, SchemaError, SchemaErrorCode, SchemaPlanNotFoundError, SearchBackendError, StorageError, SyncCascadeError, SyncConflictError, SyncError, SystemEntityImmutableError, ValidationError, isAttributeInUseError, isNotFoundError, isObjectReferencedError, isProtectedResourceError, isRecordReferencedError, isSchemaError, isValidationError };
|
|
@@ -8,6 +8,9 @@ var libphonenumberJs = require('libphonenumber-js');
|
|
|
8
8
|
function digitsOnly(input) {
|
|
9
9
|
return input.replace(/\D/g, "");
|
|
10
10
|
}
|
|
11
|
+
function normalizeCountrylessPhoneNumber(phoneNumber) {
|
|
12
|
+
return digitsOnly(phoneNumber);
|
|
13
|
+
}
|
|
11
14
|
function getIso2(iso3) {
|
|
12
15
|
const country = constants.getCountryByIso3(iso3);
|
|
13
16
|
return country?.iso2;
|
|
@@ -65,3 +68,5 @@ function createPhoneValidator(attr, messages = chunkYKWSHBT5_js.DEFAULT_VALIDATI
|
|
|
65
68
|
|
|
66
69
|
exports.createPhoneValidator = createPhoneValidator;
|
|
67
70
|
exports.formatPhoneForDisplay = formatPhoneForDisplay;
|
|
71
|
+
exports.normalizeCountrylessPhoneNumber = normalizeCountrylessPhoneNumber;
|
|
72
|
+
exports.normalizePhoneNumber = normalizePhoneNumber;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { createCheckboxValidator } from './chunk-OSSGN43B.mjs';
|
|
2
|
-
import { createDateValidator } from './chunk-Q44QKLN4.mjs';
|
|
3
|
-
import { createNumberValidator } from './chunk-UANQJ2GH.mjs';
|
|
4
|
-
import { createTextValidator } from './chunk-U36ZIBEM.mjs';
|
|
5
1
|
import { createRichtextValidator } from './chunk-QVLQPW3O.mjs';
|
|
6
2
|
import { createMultiselectValidator, createSelectValidator, createStatusValidator } from './chunk-ZDQ5AP26.mjs';
|
|
7
3
|
import { createUserValidator } from './chunk-LV3FEUKU.mjs';
|
|
8
4
|
import { createFormulaValidator } from './chunk-UXAHLSWC.mjs';
|
|
9
5
|
import { createRollupValidator } from './chunk-NS63SPNN.mjs';
|
|
10
|
-
import {
|
|
6
|
+
import { createCheckboxValidator } from './chunk-OSSGN43B.mjs';
|
|
7
|
+
import { createDateValidator } from './chunk-Q44QKLN4.mjs';
|
|
8
|
+
import { createNumberValidator } from './chunk-UANQJ2GH.mjs';
|
|
9
|
+
import { createTextValidator } from './chunk-O73ROMWQ.mjs';
|
|
10
|
+
import { ValidationError } from './chunk-POULKEJM.mjs';
|
|
11
11
|
import { createCurrencyValidator } from './chunk-AYVHMVKQ.mjs';
|
|
12
12
|
import { createLocationValidator } from './chunk-YUFTHPOE.mjs';
|
|
13
|
-
import { createPhoneValidator } from './chunk-
|
|
13
|
+
import { createPhoneValidator } from './chunk-R5LAJCBU.mjs';
|
|
14
14
|
import { createRelationValidator } from './chunk-GO6LQADH.mjs';
|
|
15
15
|
import { DEFAULT_VALIDATION_MESSAGES, formatZodErrors } from './chunk-HRQEZUAA.mjs';
|
|
16
16
|
import { z } from 'zod';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var chunkFDIAOFHS_js = require('./chunk-FDIAOFHS.js');
|
|
3
4
|
var zod = require('zod');
|
|
4
|
-
|
|
5
|
-
// src/validation/config/schemas.ts
|
|
5
|
+
var constants = require('@stndrds/constants');
|
|
6
6
|
|
|
7
7
|
// src/computed/parser.ts
|
|
8
8
|
var ComputedFormulaParseError = class extends Error {
|
|
@@ -308,6 +308,39 @@ function getOperatorPrecedence(operator) {
|
|
|
308
308
|
}
|
|
309
309
|
}
|
|
310
310
|
|
|
311
|
+
// src/validation/limits.ts
|
|
312
|
+
var SCHEMA_LIMITS = {
|
|
313
|
+
attributesPerObject: 300,
|
|
314
|
+
tabsPerView: 24,
|
|
315
|
+
groupsPerFormTab: 12,
|
|
316
|
+
fieldsPerGroup: 60,
|
|
317
|
+
fieldsPerFormTab: 150,
|
|
318
|
+
columnsPerTab: 50,
|
|
319
|
+
optionsPerAttribute: 200,
|
|
320
|
+
sidePanelAttributes: 100,
|
|
321
|
+
filterRulesPerTab: 50,
|
|
322
|
+
sortsPerTab: 20,
|
|
323
|
+
emailAttributesPerTab: 30,
|
|
324
|
+
objectsPerPlan: 20,
|
|
325
|
+
mutationsPerPlan: 500,
|
|
326
|
+
planBytes: 512 * 1024,
|
|
327
|
+
historyDefault: 20,
|
|
328
|
+
historyMax: 50,
|
|
329
|
+
iconQueries: 5,
|
|
330
|
+
iconResults: 20
|
|
331
|
+
};
|
|
332
|
+
var COLOR_IDS = Object.keys(constants.COLORS);
|
|
333
|
+
var ICON_NAMES = new Set(constants.ICONS);
|
|
334
|
+
var colorIdSchema = zod.z.enum(COLOR_IDS);
|
|
335
|
+
var iconNameSchema = zod.z.string().superRefine((value, ctx) => {
|
|
336
|
+
if (!ICON_NAMES.has(value)) {
|
|
337
|
+
ctx.addIssue({
|
|
338
|
+
code: "custom",
|
|
339
|
+
message: "Invalid icon name"
|
|
340
|
+
});
|
|
341
|
+
}
|
|
342
|
+
}).transform((value) => value);
|
|
343
|
+
|
|
311
344
|
// src/validation/config/schemas.ts
|
|
312
345
|
var baseConfigSchema = zod.z.object({
|
|
313
346
|
placeholder: zod.z.string().optional(),
|
|
@@ -320,14 +353,25 @@ var baseConfigSchema = zod.z.object({
|
|
|
320
353
|
deprecated: zod.z.boolean().optional(),
|
|
321
354
|
metadata: zod.z.record(zod.z.string(), zod.z.unknown()).optional()
|
|
322
355
|
});
|
|
323
|
-
var
|
|
356
|
+
var optionBaseSchema = zod.z.object({
|
|
324
357
|
value: zod.z.string().min(1),
|
|
325
358
|
label: zod.z.string().min(1),
|
|
326
|
-
color: zod.z.string().optional(),
|
|
327
359
|
description: zod.z.string().optional(),
|
|
328
|
-
group: zod.z.enum(["idle", "in_progress", "finished"]).optional(),
|
|
329
360
|
inverse: zod.z.string().optional(),
|
|
330
361
|
archived: zod.z.boolean().optional()
|
|
362
|
+
});
|
|
363
|
+
var statusGroupSchema = zod.z.enum(["idle", "in_progress", "finished"]);
|
|
364
|
+
var selectOptionWriteSchema = optionBaseSchema.extend({
|
|
365
|
+
color: colorIdSchema
|
|
366
|
+
}).strict();
|
|
367
|
+
var multiselectOptionWriteSchema = selectOptionWriteSchema;
|
|
368
|
+
var statusOptionWriteSchema = optionBaseSchema.extend({
|
|
369
|
+
color: colorIdSchema,
|
|
370
|
+
group: statusGroupSchema
|
|
371
|
+
}).strict();
|
|
372
|
+
var optionSchema = optionBaseSchema.extend({
|
|
373
|
+
color: zod.z.string().optional(),
|
|
374
|
+
group: statusGroupSchema.optional()
|
|
331
375
|
}).strict();
|
|
332
376
|
var optionsArraySchema = zod.z.array(optionSchema).min(1).refine(
|
|
333
377
|
(options) => {
|
|
@@ -336,6 +380,18 @@ var optionsArraySchema = zod.z.array(optionSchema).min(1).refine(
|
|
|
336
380
|
},
|
|
337
381
|
{ message: "Duplicate option values are not allowed" }
|
|
338
382
|
);
|
|
383
|
+
function writeOptionsArraySchema(option) {
|
|
384
|
+
return zod.z.array(option).min(1).max(SCHEMA_LIMITS.optionsPerAttribute).refine(
|
|
385
|
+
(options) => {
|
|
386
|
+
const values = options.map((candidate) => candidate.value);
|
|
387
|
+
return new Set(values).size === values.length;
|
|
388
|
+
},
|
|
389
|
+
{ message: "Duplicate option values are not allowed" }
|
|
390
|
+
);
|
|
391
|
+
}
|
|
392
|
+
var selectOptionsWriteSchema = writeOptionsArraySchema(selectOptionWriteSchema);
|
|
393
|
+
var multiselectOptionsWriteSchema = writeOptionsArraySchema(multiselectOptionWriteSchema);
|
|
394
|
+
var statusOptionsWriteSchema = writeOptionsArraySchema(statusOptionWriteSchema);
|
|
339
395
|
var relationTargetSchema = zod.z.object({
|
|
340
396
|
object: zod.z.string().min(1),
|
|
341
397
|
displayTemplate: zod.z.string().optional(),
|
|
@@ -371,7 +427,10 @@ var checkboxConfigSchema = baseConfigSchema;
|
|
|
371
427
|
var dateConfigSchema = baseConfigSchema.extend({
|
|
372
428
|
dateFormat: zod.z.enum(["short", "long", "full", "relative"]).optional(),
|
|
373
429
|
minDate: zod.z.string().optional(),
|
|
374
|
-
maxDate: zod.z.string().optional()
|
|
430
|
+
maxDate: zod.z.string().optional(),
|
|
431
|
+
includeTime: zod.z.boolean().optional(),
|
|
432
|
+
endDate: zod.z.boolean().optional(),
|
|
433
|
+
timeFormat: zod.z.enum(["12h", "24h"]).optional()
|
|
375
434
|
});
|
|
376
435
|
var phoneConfigSchema = baseConfigSchema.extend({
|
|
377
436
|
defaultCountryCode: zod.z.string().length(3).optional()
|
|
@@ -390,10 +449,12 @@ var locationConfigSchema = baseConfigSchema.extend({
|
|
|
390
449
|
allowedCountries: zod.z.array(zod.z.string().length(3)).optional()
|
|
391
450
|
});
|
|
392
451
|
var selectConfigSchema = baseConfigSchema.extend({
|
|
393
|
-
options: optionsArraySchema
|
|
452
|
+
options: optionsArraySchema,
|
|
453
|
+
renderAs: zod.z.literal("badges").optional()
|
|
394
454
|
});
|
|
395
455
|
var multiselectConfigSchema = baseConfigSchema.extend({
|
|
396
|
-
options: optionsArraySchema
|
|
456
|
+
options: optionsArraySchema,
|
|
457
|
+
renderAs: zod.z.literal("badges").optional()
|
|
397
458
|
});
|
|
398
459
|
var userConfigSchema = baseConfigSchema.extend({
|
|
399
460
|
types: zod.z.array(zod.z.enum(["user", "agent"])).min(1).optional(),
|
|
@@ -494,9 +555,98 @@ function parseAttributeConfig(type, config) {
|
|
|
494
555
|
const schema = getAttributeConfigSchema(type);
|
|
495
556
|
return schema.strip().parse(config);
|
|
496
557
|
}
|
|
558
|
+
function getAttributeConfigWriteSchema(type) {
|
|
559
|
+
const schema = getAttributeConfigSchema(type).extend({
|
|
560
|
+
icon: iconNameSchema.optional()
|
|
561
|
+
});
|
|
562
|
+
switch (type) {
|
|
563
|
+
case "select":
|
|
564
|
+
return schema.extend({ options: selectOptionsWriteSchema });
|
|
565
|
+
case "multiselect":
|
|
566
|
+
return schema.extend({ options: multiselectOptionsWriteSchema });
|
|
567
|
+
case "status":
|
|
568
|
+
return schema.extend({ options: statusOptionsWriteSchema });
|
|
569
|
+
default:
|
|
570
|
+
return schema;
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
function validationErrorFromIssues(issues) {
|
|
574
|
+
return chunkFDIAOFHS_js.ValidationError.fromZodErrors(
|
|
575
|
+
issues.map((issue) => ({
|
|
576
|
+
path: issue.path.map((segment) => typeof segment === "symbol" ? String(segment) : segment),
|
|
577
|
+
message: issue.message
|
|
578
|
+
}))
|
|
579
|
+
);
|
|
580
|
+
}
|
|
581
|
+
function parseWriteSchema(type, input) {
|
|
582
|
+
const result = getAttributeConfigWriteSchema(type).strip().safeParse(input);
|
|
583
|
+
if (!result.success) {
|
|
584
|
+
throw validationErrorFromIssues(result.error.issues);
|
|
585
|
+
}
|
|
586
|
+
return result.data;
|
|
587
|
+
}
|
|
588
|
+
function parseAttributeConfigForCreate(type, input) {
|
|
589
|
+
return parseWriteSchema(type, input);
|
|
590
|
+
}
|
|
591
|
+
function validatePatchedIcon(patch) {
|
|
592
|
+
if (!Object.prototype.hasOwnProperty.call(patch, "icon")) {
|
|
593
|
+
return;
|
|
594
|
+
}
|
|
595
|
+
const result = iconNameSchema.optional().safeParse(patch.icon);
|
|
596
|
+
if (!result.success) {
|
|
597
|
+
throw chunkFDIAOFHS_js.ValidationError.fromZodErrors(
|
|
598
|
+
result.error.issues.map((issue) => ({
|
|
599
|
+
path: [
|
|
600
|
+
"icon",
|
|
601
|
+
...issue.path.map((segment) => typeof segment === "symbol" ? String(segment) : segment)
|
|
602
|
+
],
|
|
603
|
+
message: issue.message
|
|
604
|
+
}))
|
|
605
|
+
);
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
function isSelectLike(type) {
|
|
609
|
+
return type === "select" || type === "multiselect" || type === "status";
|
|
610
|
+
}
|
|
611
|
+
function parseAttributeConfigForUpdate(stored, patch) {
|
|
612
|
+
const ownsOptions = Object.prototype.hasOwnProperty.call(patch, "options");
|
|
613
|
+
const ownsIcon = Object.prototype.hasOwnProperty.call(patch, "icon");
|
|
614
|
+
const input = { ...stored, ...patch };
|
|
615
|
+
validatePatchedIcon(patch);
|
|
616
|
+
if (ownsOptions) {
|
|
617
|
+
const { icon: storedIcon, ...inputWithoutStoredIcon } = input;
|
|
618
|
+
const parsed2 = parseWriteSchema(stored.type, ownsIcon ? input : inputWithoutStoredIcon);
|
|
619
|
+
if (!ownsIcon && storedIcon !== void 0) {
|
|
620
|
+
parsed2.icon = storedIcon;
|
|
621
|
+
}
|
|
622
|
+
return parsed2;
|
|
623
|
+
}
|
|
624
|
+
const storedOptions = stored.options;
|
|
625
|
+
if (isSelectLike(stored.type)) {
|
|
626
|
+
input.options = [{ value: "__legacy__", label: "__legacy__" }];
|
|
627
|
+
}
|
|
628
|
+
const result = getAttributeConfigSchema(stored.type).strip().safeParse(input);
|
|
629
|
+
if (!result.success) {
|
|
630
|
+
throw validationErrorFromIssues(result.error.issues);
|
|
631
|
+
}
|
|
632
|
+
const parsed = result.data;
|
|
633
|
+
if (isSelectLike(stored.type)) {
|
|
634
|
+
parsed.options = storedOptions;
|
|
635
|
+
}
|
|
636
|
+
return parsed;
|
|
637
|
+
}
|
|
497
638
|
|
|
498
639
|
exports.ComputedFormulaParseError = ComputedFormulaParseError;
|
|
640
|
+
exports.SCHEMA_LIMITS = SCHEMA_LIMITS;
|
|
499
641
|
exports.attributeConfigSchemas = attributeConfigSchemas;
|
|
642
|
+
exports.colorIdSchema = colorIdSchema;
|
|
500
643
|
exports.getAttributeConfigSchema = getAttributeConfigSchema;
|
|
644
|
+
exports.iconNameSchema = iconNameSchema;
|
|
645
|
+
exports.multiselectOptionWriteSchema = multiselectOptionWriteSchema;
|
|
501
646
|
exports.parseAttributeConfig = parseAttributeConfig;
|
|
647
|
+
exports.parseAttributeConfigForCreate = parseAttributeConfigForCreate;
|
|
648
|
+
exports.parseAttributeConfigForUpdate = parseAttributeConfigForUpdate;
|
|
502
649
|
exports.parseComputedFormula = parseComputedFormula;
|
|
650
|
+
exports.selectOptionWriteSchema = selectOptionWriteSchema;
|
|
651
|
+
exports.statusGroupSchema = statusGroupSchema;
|
|
652
|
+
exports.statusOptionWriteSchema = statusOptionWriteSchema;
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { DEFAULT_VALIDATION_MESSAGES } from './chunk-HRQEZUAA.mjs';
|
|
2
|
-
import { getCountryByIso3,
|
|
2
|
+
import { getCountryByIso3, stripTrunkPrefix, isValidIso3 } from '@stndrds/constants';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
import { parsePhoneNumberFromString } from 'libphonenumber-js';
|
|
5
5
|
|
|
6
6
|
function digitsOnly(input) {
|
|
7
7
|
return input.replace(/\D/g, "");
|
|
8
8
|
}
|
|
9
|
+
function normalizeCountrylessPhoneNumber(phoneNumber) {
|
|
10
|
+
return digitsOnly(phoneNumber);
|
|
11
|
+
}
|
|
9
12
|
function getIso2(iso3) {
|
|
10
13
|
const country = getCountryByIso3(iso3);
|
|
11
14
|
return country?.iso2;
|
|
@@ -61,4 +64,4 @@ function createPhoneValidator(attr, messages = DEFAULT_VALIDATION_MESSAGES) {
|
|
|
61
64
|
}));
|
|
62
65
|
}
|
|
63
66
|
|
|
64
|
-
export { createPhoneValidator, formatPhoneForDisplay };
|
|
67
|
+
export { createPhoneValidator, formatPhoneForDisplay, normalizeCountrylessPhoneNumber, normalizePhoneNumber };
|