@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
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var chunk5WATIVCA_js = require('./chunk-5WATIVCA.js');
|
|
4
|
-
var chunkSI34M4IC_js = require('./chunk-SI34M4IC.js');
|
|
5
|
-
var chunkYIP5FJ5H_js = require('./chunk-YIP5FJ5H.js');
|
|
6
|
-
var chunkQAF3HNKQ_js = require('./chunk-QAF3HNKQ.js');
|
|
7
3
|
var chunkEW5XR2X3_js = require('./chunk-EW5XR2X3.js');
|
|
8
4
|
var chunkQWKLQRBX_js = require('./chunk-QWKLQRBX.js');
|
|
9
5
|
var chunkKNGWHQLR_js = require('./chunk-KNGWHQLR.js');
|
|
10
6
|
var chunkHTSTPTNZ_js = require('./chunk-HTSTPTNZ.js');
|
|
11
7
|
var chunkV2UA2D4E_js = require('./chunk-V2UA2D4E.js');
|
|
12
|
-
var
|
|
8
|
+
var chunk5WATIVCA_js = require('./chunk-5WATIVCA.js');
|
|
9
|
+
var chunkSI34M4IC_js = require('./chunk-SI34M4IC.js');
|
|
10
|
+
var chunkYIP5FJ5H_js = require('./chunk-YIP5FJ5H.js');
|
|
11
|
+
var chunkZPFOKBIN_js = require('./chunk-ZPFOKBIN.js');
|
|
12
|
+
var chunkFDIAOFHS_js = require('./chunk-FDIAOFHS.js');
|
|
13
13
|
var chunkACKMC6FL_js = require('./chunk-ACKMC6FL.js');
|
|
14
14
|
var chunkE6JUYGJX_js = require('./chunk-E6JUYGJX.js');
|
|
15
|
-
var
|
|
15
|
+
var chunkQ4SZAMJT_js = require('./chunk-Q4SZAMJT.js');
|
|
16
16
|
var chunkEEH4XQ7W_js = require('./chunk-EEH4XQ7W.js');
|
|
17
17
|
var chunkYKWSHBT5_js = require('./chunk-YKWSHBT5.js');
|
|
18
18
|
var zod = require('zod');
|
|
@@ -36,7 +36,7 @@ function withEmptyToNull(validator) {
|
|
|
36
36
|
function createAttributeValidator(attr, messages = chunkYKWSHBT5_js.DEFAULT_VALIDATION_MESSAGES) {
|
|
37
37
|
switch (attr.type) {
|
|
38
38
|
case "text":
|
|
39
|
-
return
|
|
39
|
+
return chunkZPFOKBIN_js.createTextValidator(attr, messages);
|
|
40
40
|
case "richtext":
|
|
41
41
|
return chunkEW5XR2X3_js.createRichtextValidator(attr, messages);
|
|
42
42
|
case "number":
|
|
@@ -46,7 +46,7 @@ function createAttributeValidator(attr, messages = chunkYKWSHBT5_js.DEFAULT_VALI
|
|
|
46
46
|
case "date":
|
|
47
47
|
return chunkSI34M4IC_js.createDateValidator(attr, messages);
|
|
48
48
|
case "phone":
|
|
49
|
-
return
|
|
49
|
+
return chunkQ4SZAMJT_js.createPhoneValidator(attr, messages);
|
|
50
50
|
case "currency":
|
|
51
51
|
return chunkACKMC6FL_js.createCurrencyValidator(attr, messages);
|
|
52
52
|
case "status":
|
|
@@ -143,7 +143,7 @@ function validateObjectOrThrow(objectDef, data) {
|
|
|
143
143
|
if (!result.success) {
|
|
144
144
|
const errors = result.errors ?? [];
|
|
145
145
|
const detail = errors.map((err) => `${err.path.join(".")}: ${err.message}`).join("\n") || "Unknown validation error";
|
|
146
|
-
throw new
|
|
146
|
+
throw new chunkFDIAOFHS_js.ValidationError(
|
|
147
147
|
`Validation failed for ${objectDef.label}:
|
|
148
148
|
${detail}`,
|
|
149
149
|
errors.map((err) => ({ path: err.path, message: err.message }))
|
|
@@ -170,7 +170,7 @@ function validateDraftOrThrow(objectDef, data) {
|
|
|
170
170
|
if (!result.success) {
|
|
171
171
|
const errors = result.errors ?? [];
|
|
172
172
|
const detail = errors.map((err) => `${err.path.join(".")}: ${err.message}`).join("\n") || "Unknown validation error";
|
|
173
|
-
throw new
|
|
173
|
+
throw new chunkFDIAOFHS_js.ValidationError(
|
|
174
174
|
`Draft validation failed for ${objectDef.label}:
|
|
175
175
|
${detail}`,
|
|
176
176
|
errors.map((err) => ({ path: err.path, message: err.message }))
|
|
@@ -182,7 +182,7 @@ function rejectUnknownAttributesOrThrow(objectDef, data) {
|
|
|
182
182
|
const knownNames = new Set(objectDef.attributes.map((a) => a.name));
|
|
183
183
|
const unknownKeys = Object.keys(data).filter((key) => !knownNames.has(key));
|
|
184
184
|
if (unknownKeys.length > 0) {
|
|
185
|
-
throw new
|
|
185
|
+
throw new chunkFDIAOFHS_js.ValidationError(
|
|
186
186
|
`Unknown attribute${unknownKeys.length > 1 ? "s" : ""} for ${objectDef.label}: ${unknownKeys.join(", ")}`,
|
|
187
187
|
unknownKeys.map((key) => ({ path: [key], message: "Unknown attribute" }))
|
|
188
188
|
);
|
|
@@ -3,6 +3,17 @@
|
|
|
3
3
|
var chunkYKWSHBT5_js = require('./chunk-YKWSHBT5.js');
|
|
4
4
|
var zod = require('zod');
|
|
5
5
|
|
|
6
|
+
// src/lib/text-format.ts
|
|
7
|
+
var TEXT_FORMAT_PATTERNS = {
|
|
8
|
+
email: "^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$",
|
|
9
|
+
url: "^https?:\\/\\/[\\w\\-]+(\\.[\\w\\-]+)+[/#?]?.*$",
|
|
10
|
+
slug: "^[a-z0-9]+(?:-[a-z0-9]+)*$"
|
|
11
|
+
};
|
|
12
|
+
function resolveTextPattern(attr) {
|
|
13
|
+
if (attr.pattern) return attr.pattern;
|
|
14
|
+
return attr.format ? TEXT_FORMAT_PATTERNS[attr.format] : void 0;
|
|
15
|
+
}
|
|
16
|
+
|
|
6
17
|
// src/lib/lru-cache.ts
|
|
7
18
|
var LRUCache = class {
|
|
8
19
|
constructor(capacity) {
|
|
@@ -66,13 +77,13 @@ function createTextValidator(attr, messages = chunkYKWSHBT5_js.DEFAULT_VALIDATIO
|
|
|
66
77
|
if (attr.maxLength !== void 0) {
|
|
67
78
|
schema = schema.max(attr.maxLength, messages.maxLength(attr, attr.maxLength));
|
|
68
79
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
messages.invalidPattern(attr)
|
|
73
|
-
);
|
|
80
|
+
const pattern = resolveTextPattern(attr);
|
|
81
|
+
if (pattern) {
|
|
82
|
+
schema = schema.regex(getCachedRegex(textRegexCache, pattern), messages.invalidPattern(attr));
|
|
74
83
|
}
|
|
75
84
|
return schema;
|
|
76
85
|
}
|
|
77
86
|
|
|
87
|
+
exports.TEXT_FORMAT_PATTERNS = TEXT_FORMAT_PATTERNS;
|
|
78
88
|
exports.createTextValidator = createTextValidator;
|
|
89
|
+
exports.resolveTextPattern = resolveTextPattern;
|
package/dist/exceptions.d.mts
CHANGED
|
@@ -13,6 +13,7 @@ declare const SchemaErrorCode: {
|
|
|
13
13
|
readonly RECORD_NOT_FOUND: "SCHEMA_RECORD_NOT_FOUND";
|
|
14
14
|
readonly ROLE_NOT_FOUND: "SCHEMA_ROLE_NOT_FOUND";
|
|
15
15
|
readonly MEMORY_NOT_FOUND: "SCHEMA_MEMORY_NOT_FOUND";
|
|
16
|
+
readonly SCHEMA_PLAN_NOT_FOUND: "SCHEMA_PLAN_NOT_FOUND";
|
|
16
17
|
readonly VALIDATION_FAILED: "SCHEMA_VALIDATION_FAILED";
|
|
17
18
|
readonly INVALID_ATTRIBUTE_NAME: "SCHEMA_INVALID_ATTRIBUTE_NAME";
|
|
18
19
|
readonly INVALID_OBJECT_NAME: "SCHEMA_INVALID_OBJECT_NAME";
|
|
@@ -147,6 +148,14 @@ declare class AttributeNotFoundError extends NotFoundError {
|
|
|
147
148
|
declare class RecordNotFoundError extends NotFoundError {
|
|
148
149
|
constructor(recordId: string);
|
|
149
150
|
}
|
|
151
|
+
/**
|
|
152
|
+
* Schema plan not found error — raised when a `planId` sent by an approver
|
|
153
|
+
* (who never receives the plan payload itself, only its id) does not match
|
|
154
|
+
* any stored plan.
|
|
155
|
+
*/
|
|
156
|
+
declare class SchemaPlanNotFoundError extends NotFoundError {
|
|
157
|
+
constructor(planId: string);
|
|
158
|
+
}
|
|
150
159
|
/**
|
|
151
160
|
* Validation error with field-level details
|
|
152
161
|
*/
|
|
@@ -233,15 +242,19 @@ declare class OrphanSystemAttributeError extends SchemaError {
|
|
|
233
242
|
constructor(objectName: string, attributeName: string);
|
|
234
243
|
}
|
|
235
244
|
/**
|
|
236
|
-
* Thrown
|
|
237
|
-
*
|
|
245
|
+
* Thrown when a destructive operation is detected without the explicit
|
|
246
|
+
* STANDARDS_ALLOW_DESTRUCTIVE_SYNC=1 opt-in.
|
|
238
247
|
* HTTP status: 500 (boot fail, should never surface to HTTP).
|
|
239
248
|
*
|
|
240
|
-
*
|
|
241
|
-
*
|
|
242
|
-
*
|
|
243
|
-
*
|
|
244
|
-
*
|
|
249
|
+
* Which operations the opt-in governs is decided in one place —
|
|
250
|
+
* `requiresDestructiveSyncOptIn` in the runtime's sync classifier. Today that
|
|
251
|
+
* is object removal only: attribute removal is unconditional at boot, because a
|
|
252
|
+
* system attribute is code-controlled and its disappearance from the builder is
|
|
253
|
+
* an unambiguous drop.
|
|
254
|
+
*
|
|
255
|
+
* NOTE — Wiring status: defined but not thrown by the current sync.ts, which
|
|
256
|
+
* demotes instead. Reserved for the `standards diff` CLI gate, which will throw
|
|
257
|
+
* it when CI detects an unauthorized destructive deployment.
|
|
245
258
|
*/
|
|
246
259
|
declare class DestructiveSyncNotAllowedError extends SchemaError {
|
|
247
260
|
readonly operations: SchemaOperation[];
|
|
@@ -455,4 +468,4 @@ declare function isAttributeInUseError(error: unknown): error is AttributeInUseE
|
|
|
455
468
|
*/
|
|
456
469
|
declare function isObjectReferencedError(error: unknown): error is ObjectReferencedError;
|
|
457
470
|
|
|
458
|
-
export { AccessDeniedError, AttributeInUseError, AttributeNotFoundError, type AttributeUsage, ChangeTypeNotSupportedError, ConcurrentModificationError, DestructiveSyncNotAllowedError, DuplicateError, ForbiddenError, MemoryNotFoundError, MigrationTimeoutError, NotFoundError, NotImplementedError, ObjectNotFoundError, ObjectReferencedError, OrphanSystemAttributeError, ProtectedResourceError, ProtectedRoleError, RecordNotFoundError, type RecordReference, RecordReferencedError, RepositoryError, type RepositoryOperation, RoleNotFoundError, SchemaError, SchemaErrorCode, SearchBackendError, StorageError, type StorageOperation, SyncCascadeError, SyncConflictError, SyncError, SystemEntityImmutableError, ValidationError, type ValidationErrorDetail, isAttributeInUseError, isNotFoundError, isObjectReferencedError, isProtectedResourceError, isRecordReferencedError, isSchemaError, isValidationError };
|
|
471
|
+
export { AccessDeniedError, AttributeInUseError, AttributeNotFoundError, type AttributeUsage, ChangeTypeNotSupportedError, ConcurrentModificationError, DestructiveSyncNotAllowedError, DuplicateError, ForbiddenError, MemoryNotFoundError, MigrationTimeoutError, NotFoundError, NotImplementedError, ObjectNotFoundError, ObjectReferencedError, OrphanSystemAttributeError, ProtectedResourceError, ProtectedRoleError, RecordNotFoundError, type RecordReference, RecordReferencedError, RepositoryError, type RepositoryOperation, RoleNotFoundError, SchemaError, SchemaErrorCode, SchemaPlanNotFoundError, SearchBackendError, StorageError, type StorageOperation, SyncCascadeError, SyncConflictError, SyncError, SystemEntityImmutableError, ValidationError, type ValidationErrorDetail, isAttributeInUseError, isNotFoundError, isObjectReferencedError, isProtectedResourceError, isRecordReferencedError, isSchemaError, isValidationError };
|
package/dist/exceptions.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ declare const SchemaErrorCode: {
|
|
|
13
13
|
readonly RECORD_NOT_FOUND: "SCHEMA_RECORD_NOT_FOUND";
|
|
14
14
|
readonly ROLE_NOT_FOUND: "SCHEMA_ROLE_NOT_FOUND";
|
|
15
15
|
readonly MEMORY_NOT_FOUND: "SCHEMA_MEMORY_NOT_FOUND";
|
|
16
|
+
readonly SCHEMA_PLAN_NOT_FOUND: "SCHEMA_PLAN_NOT_FOUND";
|
|
16
17
|
readonly VALIDATION_FAILED: "SCHEMA_VALIDATION_FAILED";
|
|
17
18
|
readonly INVALID_ATTRIBUTE_NAME: "SCHEMA_INVALID_ATTRIBUTE_NAME";
|
|
18
19
|
readonly INVALID_OBJECT_NAME: "SCHEMA_INVALID_OBJECT_NAME";
|
|
@@ -147,6 +148,14 @@ declare class AttributeNotFoundError extends NotFoundError {
|
|
|
147
148
|
declare class RecordNotFoundError extends NotFoundError {
|
|
148
149
|
constructor(recordId: string);
|
|
149
150
|
}
|
|
151
|
+
/**
|
|
152
|
+
* Schema plan not found error — raised when a `planId` sent by an approver
|
|
153
|
+
* (who never receives the plan payload itself, only its id) does not match
|
|
154
|
+
* any stored plan.
|
|
155
|
+
*/
|
|
156
|
+
declare class SchemaPlanNotFoundError extends NotFoundError {
|
|
157
|
+
constructor(planId: string);
|
|
158
|
+
}
|
|
150
159
|
/**
|
|
151
160
|
* Validation error with field-level details
|
|
152
161
|
*/
|
|
@@ -233,15 +242,19 @@ declare class OrphanSystemAttributeError extends SchemaError {
|
|
|
233
242
|
constructor(objectName: string, attributeName: string);
|
|
234
243
|
}
|
|
235
244
|
/**
|
|
236
|
-
* Thrown
|
|
237
|
-
*
|
|
245
|
+
* Thrown when a destructive operation is detected without the explicit
|
|
246
|
+
* STANDARDS_ALLOW_DESTRUCTIVE_SYNC=1 opt-in.
|
|
238
247
|
* HTTP status: 500 (boot fail, should never surface to HTTP).
|
|
239
248
|
*
|
|
240
|
-
*
|
|
241
|
-
*
|
|
242
|
-
*
|
|
243
|
-
*
|
|
244
|
-
*
|
|
249
|
+
* Which operations the opt-in governs is decided in one place —
|
|
250
|
+
* `requiresDestructiveSyncOptIn` in the runtime's sync classifier. Today that
|
|
251
|
+
* is object removal only: attribute removal is unconditional at boot, because a
|
|
252
|
+
* system attribute is code-controlled and its disappearance from the builder is
|
|
253
|
+
* an unambiguous drop.
|
|
254
|
+
*
|
|
255
|
+
* NOTE — Wiring status: defined but not thrown by the current sync.ts, which
|
|
256
|
+
* demotes instead. Reserved for the `standards diff` CLI gate, which will throw
|
|
257
|
+
* it when CI detects an unauthorized destructive deployment.
|
|
245
258
|
*/
|
|
246
259
|
declare class DestructiveSyncNotAllowedError extends SchemaError {
|
|
247
260
|
readonly operations: SchemaOperation[];
|
|
@@ -455,4 +468,4 @@ declare function isAttributeInUseError(error: unknown): error is AttributeInUseE
|
|
|
455
468
|
*/
|
|
456
469
|
declare function isObjectReferencedError(error: unknown): error is ObjectReferencedError;
|
|
457
470
|
|
|
458
|
-
export { AccessDeniedError, AttributeInUseError, AttributeNotFoundError, type AttributeUsage, ChangeTypeNotSupportedError, ConcurrentModificationError, DestructiveSyncNotAllowedError, DuplicateError, ForbiddenError, MemoryNotFoundError, MigrationTimeoutError, NotFoundError, NotImplementedError, ObjectNotFoundError, ObjectReferencedError, OrphanSystemAttributeError, ProtectedResourceError, ProtectedRoleError, RecordNotFoundError, type RecordReference, RecordReferencedError, RepositoryError, type RepositoryOperation, RoleNotFoundError, SchemaError, SchemaErrorCode, SearchBackendError, StorageError, type StorageOperation, SyncCascadeError, SyncConflictError, SyncError, SystemEntityImmutableError, ValidationError, type ValidationErrorDetail, isAttributeInUseError, isNotFoundError, isObjectReferencedError, isProtectedResourceError, isRecordReferencedError, isSchemaError, isValidationError };
|
|
471
|
+
export { AccessDeniedError, AttributeInUseError, AttributeNotFoundError, type AttributeUsage, ChangeTypeNotSupportedError, ConcurrentModificationError, DestructiveSyncNotAllowedError, DuplicateError, ForbiddenError, MemoryNotFoundError, MigrationTimeoutError, NotFoundError, NotImplementedError, ObjectNotFoundError, ObjectReferencedError, OrphanSystemAttributeError, ProtectedResourceError, ProtectedRoleError, RecordNotFoundError, type RecordReference, RecordReferencedError, RepositoryError, type RepositoryOperation, RoleNotFoundError, SchemaError, SchemaErrorCode, SchemaPlanNotFoundError, SearchBackendError, StorageError, type StorageOperation, SyncCascadeError, SyncConflictError, SyncError, SystemEntityImmutableError, ValidationError, type ValidationErrorDetail, isAttributeInUseError, isNotFoundError, isObjectReferencedError, isProtectedResourceError, isRecordReferencedError, isSchemaError, isValidationError };
|
package/dist/exceptions.js
CHANGED
|
@@ -1,154 +1,158 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkFDIAOFHS_js = require('./chunk-FDIAOFHS.js');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
Object.defineProperty(exports, "AccessDeniedError", {
|
|
8
8
|
enumerable: true,
|
|
9
|
-
get: function () { return
|
|
9
|
+
get: function () { return chunkFDIAOFHS_js.AccessDeniedError; }
|
|
10
10
|
});
|
|
11
11
|
Object.defineProperty(exports, "AttributeInUseError", {
|
|
12
12
|
enumerable: true,
|
|
13
|
-
get: function () { return
|
|
13
|
+
get: function () { return chunkFDIAOFHS_js.AttributeInUseError; }
|
|
14
14
|
});
|
|
15
15
|
Object.defineProperty(exports, "AttributeNotFoundError", {
|
|
16
16
|
enumerable: true,
|
|
17
|
-
get: function () { return
|
|
17
|
+
get: function () { return chunkFDIAOFHS_js.AttributeNotFoundError; }
|
|
18
18
|
});
|
|
19
19
|
Object.defineProperty(exports, "ChangeTypeNotSupportedError", {
|
|
20
20
|
enumerable: true,
|
|
21
|
-
get: function () { return
|
|
21
|
+
get: function () { return chunkFDIAOFHS_js.ChangeTypeNotSupportedError; }
|
|
22
22
|
});
|
|
23
23
|
Object.defineProperty(exports, "ConcurrentModificationError", {
|
|
24
24
|
enumerable: true,
|
|
25
|
-
get: function () { return
|
|
25
|
+
get: function () { return chunkFDIAOFHS_js.ConcurrentModificationError; }
|
|
26
26
|
});
|
|
27
27
|
Object.defineProperty(exports, "DestructiveSyncNotAllowedError", {
|
|
28
28
|
enumerable: true,
|
|
29
|
-
get: function () { return
|
|
29
|
+
get: function () { return chunkFDIAOFHS_js.DestructiveSyncNotAllowedError; }
|
|
30
30
|
});
|
|
31
31
|
Object.defineProperty(exports, "DuplicateError", {
|
|
32
32
|
enumerable: true,
|
|
33
|
-
get: function () { return
|
|
33
|
+
get: function () { return chunkFDIAOFHS_js.DuplicateError; }
|
|
34
34
|
});
|
|
35
35
|
Object.defineProperty(exports, "ForbiddenError", {
|
|
36
36
|
enumerable: true,
|
|
37
|
-
get: function () { return
|
|
37
|
+
get: function () { return chunkFDIAOFHS_js.ForbiddenError; }
|
|
38
38
|
});
|
|
39
39
|
Object.defineProperty(exports, "MemoryNotFoundError", {
|
|
40
40
|
enumerable: true,
|
|
41
|
-
get: function () { return
|
|
41
|
+
get: function () { return chunkFDIAOFHS_js.MemoryNotFoundError; }
|
|
42
42
|
});
|
|
43
43
|
Object.defineProperty(exports, "MigrationTimeoutError", {
|
|
44
44
|
enumerable: true,
|
|
45
|
-
get: function () { return
|
|
45
|
+
get: function () { return chunkFDIAOFHS_js.MigrationTimeoutError; }
|
|
46
46
|
});
|
|
47
47
|
Object.defineProperty(exports, "NotFoundError", {
|
|
48
48
|
enumerable: true,
|
|
49
|
-
get: function () { return
|
|
49
|
+
get: function () { return chunkFDIAOFHS_js.NotFoundError; }
|
|
50
50
|
});
|
|
51
51
|
Object.defineProperty(exports, "NotImplementedError", {
|
|
52
52
|
enumerable: true,
|
|
53
|
-
get: function () { return
|
|
53
|
+
get: function () { return chunkFDIAOFHS_js.NotImplementedError; }
|
|
54
54
|
});
|
|
55
55
|
Object.defineProperty(exports, "ObjectNotFoundError", {
|
|
56
56
|
enumerable: true,
|
|
57
|
-
get: function () { return
|
|
57
|
+
get: function () { return chunkFDIAOFHS_js.ObjectNotFoundError; }
|
|
58
58
|
});
|
|
59
59
|
Object.defineProperty(exports, "ObjectReferencedError", {
|
|
60
60
|
enumerable: true,
|
|
61
|
-
get: function () { return
|
|
61
|
+
get: function () { return chunkFDIAOFHS_js.ObjectReferencedError; }
|
|
62
62
|
});
|
|
63
63
|
Object.defineProperty(exports, "OrphanSystemAttributeError", {
|
|
64
64
|
enumerable: true,
|
|
65
|
-
get: function () { return
|
|
65
|
+
get: function () { return chunkFDIAOFHS_js.OrphanSystemAttributeError; }
|
|
66
66
|
});
|
|
67
67
|
Object.defineProperty(exports, "ProtectedResourceError", {
|
|
68
68
|
enumerable: true,
|
|
69
|
-
get: function () { return
|
|
69
|
+
get: function () { return chunkFDIAOFHS_js.ProtectedResourceError; }
|
|
70
70
|
});
|
|
71
71
|
Object.defineProperty(exports, "ProtectedRoleError", {
|
|
72
72
|
enumerable: true,
|
|
73
|
-
get: function () { return
|
|
73
|
+
get: function () { return chunkFDIAOFHS_js.ProtectedRoleError; }
|
|
74
74
|
});
|
|
75
75
|
Object.defineProperty(exports, "RecordNotFoundError", {
|
|
76
76
|
enumerable: true,
|
|
77
|
-
get: function () { return
|
|
77
|
+
get: function () { return chunkFDIAOFHS_js.RecordNotFoundError; }
|
|
78
78
|
});
|
|
79
79
|
Object.defineProperty(exports, "RecordReferencedError", {
|
|
80
80
|
enumerable: true,
|
|
81
|
-
get: function () { return
|
|
81
|
+
get: function () { return chunkFDIAOFHS_js.RecordReferencedError; }
|
|
82
82
|
});
|
|
83
83
|
Object.defineProperty(exports, "RepositoryError", {
|
|
84
84
|
enumerable: true,
|
|
85
|
-
get: function () { return
|
|
85
|
+
get: function () { return chunkFDIAOFHS_js.RepositoryError; }
|
|
86
86
|
});
|
|
87
87
|
Object.defineProperty(exports, "RoleNotFoundError", {
|
|
88
88
|
enumerable: true,
|
|
89
|
-
get: function () { return
|
|
89
|
+
get: function () { return chunkFDIAOFHS_js.RoleNotFoundError; }
|
|
90
90
|
});
|
|
91
91
|
Object.defineProperty(exports, "SchemaError", {
|
|
92
92
|
enumerable: true,
|
|
93
|
-
get: function () { return
|
|
93
|
+
get: function () { return chunkFDIAOFHS_js.SchemaError; }
|
|
94
94
|
});
|
|
95
95
|
Object.defineProperty(exports, "SchemaErrorCode", {
|
|
96
96
|
enumerable: true,
|
|
97
|
-
get: function () { return
|
|
97
|
+
get: function () { return chunkFDIAOFHS_js.SchemaErrorCode; }
|
|
98
|
+
});
|
|
99
|
+
Object.defineProperty(exports, "SchemaPlanNotFoundError", {
|
|
100
|
+
enumerable: true,
|
|
101
|
+
get: function () { return chunkFDIAOFHS_js.SchemaPlanNotFoundError; }
|
|
98
102
|
});
|
|
99
103
|
Object.defineProperty(exports, "SearchBackendError", {
|
|
100
104
|
enumerable: true,
|
|
101
|
-
get: function () { return
|
|
105
|
+
get: function () { return chunkFDIAOFHS_js.SearchBackendError; }
|
|
102
106
|
});
|
|
103
107
|
Object.defineProperty(exports, "StorageError", {
|
|
104
108
|
enumerable: true,
|
|
105
|
-
get: function () { return
|
|
109
|
+
get: function () { return chunkFDIAOFHS_js.StorageError; }
|
|
106
110
|
});
|
|
107
111
|
Object.defineProperty(exports, "SyncCascadeError", {
|
|
108
112
|
enumerable: true,
|
|
109
|
-
get: function () { return
|
|
113
|
+
get: function () { return chunkFDIAOFHS_js.SyncCascadeError; }
|
|
110
114
|
});
|
|
111
115
|
Object.defineProperty(exports, "SyncConflictError", {
|
|
112
116
|
enumerable: true,
|
|
113
|
-
get: function () { return
|
|
117
|
+
get: function () { return chunkFDIAOFHS_js.SyncConflictError; }
|
|
114
118
|
});
|
|
115
119
|
Object.defineProperty(exports, "SyncError", {
|
|
116
120
|
enumerable: true,
|
|
117
|
-
get: function () { return
|
|
121
|
+
get: function () { return chunkFDIAOFHS_js.SyncError; }
|
|
118
122
|
});
|
|
119
123
|
Object.defineProperty(exports, "SystemEntityImmutableError", {
|
|
120
124
|
enumerable: true,
|
|
121
|
-
get: function () { return
|
|
125
|
+
get: function () { return chunkFDIAOFHS_js.SystemEntityImmutableError; }
|
|
122
126
|
});
|
|
123
127
|
Object.defineProperty(exports, "ValidationError", {
|
|
124
128
|
enumerable: true,
|
|
125
|
-
get: function () { return
|
|
129
|
+
get: function () { return chunkFDIAOFHS_js.ValidationError; }
|
|
126
130
|
});
|
|
127
131
|
Object.defineProperty(exports, "isAttributeInUseError", {
|
|
128
132
|
enumerable: true,
|
|
129
|
-
get: function () { return
|
|
133
|
+
get: function () { return chunkFDIAOFHS_js.isAttributeInUseError; }
|
|
130
134
|
});
|
|
131
135
|
Object.defineProperty(exports, "isNotFoundError", {
|
|
132
136
|
enumerable: true,
|
|
133
|
-
get: function () { return
|
|
137
|
+
get: function () { return chunkFDIAOFHS_js.isNotFoundError; }
|
|
134
138
|
});
|
|
135
139
|
Object.defineProperty(exports, "isObjectReferencedError", {
|
|
136
140
|
enumerable: true,
|
|
137
|
-
get: function () { return
|
|
141
|
+
get: function () { return chunkFDIAOFHS_js.isObjectReferencedError; }
|
|
138
142
|
});
|
|
139
143
|
Object.defineProperty(exports, "isProtectedResourceError", {
|
|
140
144
|
enumerable: true,
|
|
141
|
-
get: function () { return
|
|
145
|
+
get: function () { return chunkFDIAOFHS_js.isProtectedResourceError; }
|
|
142
146
|
});
|
|
143
147
|
Object.defineProperty(exports, "isRecordReferencedError", {
|
|
144
148
|
enumerable: true,
|
|
145
|
-
get: function () { return
|
|
149
|
+
get: function () { return chunkFDIAOFHS_js.isRecordReferencedError; }
|
|
146
150
|
});
|
|
147
151
|
Object.defineProperty(exports, "isSchemaError", {
|
|
148
152
|
enumerable: true,
|
|
149
|
-
get: function () { return
|
|
153
|
+
get: function () { return chunkFDIAOFHS_js.isSchemaError; }
|
|
150
154
|
});
|
|
151
155
|
Object.defineProperty(exports, "isValidationError", {
|
|
152
156
|
enumerable: true,
|
|
153
|
-
get: function () { return
|
|
157
|
+
get: function () { return chunkFDIAOFHS_js.isValidationError; }
|
|
154
158
|
});
|
package/dist/exceptions.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
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 } from './chunk-
|
|
1
|
+
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 } from './chunk-POULKEJM.mjs';
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { A as Attribute } from './attributes-lBLiOIY3.mjs';
|
|
3
|
+
import { V as ValidationMessages, a as ValidationResult } from './types-DNz3ITS-.mjs';
|
|
4
|
+
import { O as ObjectDefinition } from './objects-BCaBw2ef.mjs';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Create a Zod schema for any attribute type.
|
|
8
|
+
* Returns a strict validator that does NOT handle optional fields.
|
|
9
|
+
* Use createFormAttributeValidator for form validation with optional support.
|
|
10
|
+
*
|
|
11
|
+
* @param attr - The attribute to create a validator for
|
|
12
|
+
* @param messages - Custom validation messages for i18n support
|
|
13
|
+
*/
|
|
14
|
+
declare function createAttributeValidator(attr: Attribute, messages?: ValidationMessages): z.ZodTypeAny;
|
|
15
|
+
/**
|
|
16
|
+
* Create a Zod schema for form validation.
|
|
17
|
+
* - Normalizes empty values (empty strings, empty objects) to null for optional fields
|
|
18
|
+
* - Accepts custom messages for i18n support
|
|
19
|
+
*
|
|
20
|
+
* Use this in UI forms where optional fields may have null/undefined values.
|
|
21
|
+
*
|
|
22
|
+
* @param attr - The attribute to create a validator for
|
|
23
|
+
* @param messages - Custom validation messages for i18n support
|
|
24
|
+
*/
|
|
25
|
+
declare function createFormAttributeValidator(attr: Attribute, messages?: ValidationMessages): z.ZodTypeAny;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Validate data against an attribute schema
|
|
29
|
+
*/
|
|
30
|
+
declare function validateAttribute(attr: Attribute, value: unknown): ValidationResult;
|
|
31
|
+
/**
|
|
32
|
+
* Validate data against an object schema
|
|
33
|
+
*/
|
|
34
|
+
declare function validateObject(objectDef: ObjectDefinition, data: Record<string, unknown>): ValidationResult;
|
|
35
|
+
/**
|
|
36
|
+
* Validate and throw if invalid.
|
|
37
|
+
*
|
|
38
|
+
* Throws `ValidationError` (code `SCHEMA_VALIDATION_FAILED`) on failure so HTTP
|
|
39
|
+
* adapters can map it to 400. Generic `Error` would bubble up to a 500.
|
|
40
|
+
*/
|
|
41
|
+
declare function validateObjectOrThrow(objectDef: ObjectDefinition, data: Record<string, unknown>): Record<string, unknown>;
|
|
42
|
+
/**
|
|
43
|
+
* Validate data in draft mode.
|
|
44
|
+
* - All attributes are treated as optional (no required validation)
|
|
45
|
+
* - Provided values are still validated for format/type correctness
|
|
46
|
+
*/
|
|
47
|
+
declare function validateDraft(objectDef: ObjectDefinition, data: Record<string, unknown>): ValidationResult;
|
|
48
|
+
/**
|
|
49
|
+
* Validate draft data and throw if format validation fails.
|
|
50
|
+
*
|
|
51
|
+
* Same contract as `validateObjectOrThrow` but skips `required()` checks.
|
|
52
|
+
* Throws `ValidationError` so HTTP adapters map it to 400.
|
|
53
|
+
*/
|
|
54
|
+
declare function validateDraftOrThrow(objectDef: ObjectDefinition, data: Record<string, unknown>): Record<string, unknown>;
|
|
55
|
+
/**
|
|
56
|
+
* Throw a `ValidationError` when `data` contains keys that do not correspond
|
|
57
|
+
* to any attribute declared on `objectDef`.
|
|
58
|
+
*
|
|
59
|
+
* Call this on **client-supplied input** before Zod validation so the error
|
|
60
|
+
* message clearly names every offending key. Do NOT call on merged data that
|
|
61
|
+
* includes existing record values — older records may legitimately carry stale
|
|
62
|
+
* keys that predate this guard (see issue #658).
|
|
63
|
+
*
|
|
64
|
+
* Maps to HTTP 400 via `SchemaExceptionFilter` (code SCHEMA_VALIDATION_FAILED).
|
|
65
|
+
*/
|
|
66
|
+
declare function rejectUnknownAttributesOrThrow(objectDef: ObjectDefinition, data: Record<string, unknown>): void;
|
|
67
|
+
/**
|
|
68
|
+
* Get the list of required attributes that are missing values.
|
|
69
|
+
*/
|
|
70
|
+
declare function getMissingRequiredAttributes(objectDef: ObjectDefinition, data: Record<string, unknown>): Attribute[];
|
|
71
|
+
/**
|
|
72
|
+
* Check if a record is complete (all required attributes have valid values).
|
|
73
|
+
*/
|
|
74
|
+
declare function isRecordComplete(objectDef: ObjectDefinition, data: Record<string, unknown>): boolean;
|
|
75
|
+
|
|
76
|
+
export { createFormAttributeValidator as a, validateDraft as b, createAttributeValidator as c, validateDraftOrThrow as d, validateObject as e, validateObjectOrThrow as f, getMissingRequiredAttributes as g, isRecordComplete as i, rejectUnknownAttributesOrThrow as r, validateAttribute as v };
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { A as Attribute } from './attributes-_b3Db8vT.js';
|
|
3
|
+
import { V as ValidationMessages, a as ValidationResult } from './types-DqLi1tx1.js';
|
|
4
|
+
import { O as ObjectDefinition } from './objects-A1ED9af-.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Create a Zod schema for any attribute type.
|
|
8
|
+
* Returns a strict validator that does NOT handle optional fields.
|
|
9
|
+
* Use createFormAttributeValidator for form validation with optional support.
|
|
10
|
+
*
|
|
11
|
+
* @param attr - The attribute to create a validator for
|
|
12
|
+
* @param messages - Custom validation messages for i18n support
|
|
13
|
+
*/
|
|
14
|
+
declare function createAttributeValidator(attr: Attribute, messages?: ValidationMessages): z.ZodTypeAny;
|
|
15
|
+
/**
|
|
16
|
+
* Create a Zod schema for form validation.
|
|
17
|
+
* - Normalizes empty values (empty strings, empty objects) to null for optional fields
|
|
18
|
+
* - Accepts custom messages for i18n support
|
|
19
|
+
*
|
|
20
|
+
* Use this in UI forms where optional fields may have null/undefined values.
|
|
21
|
+
*
|
|
22
|
+
* @param attr - The attribute to create a validator for
|
|
23
|
+
* @param messages - Custom validation messages for i18n support
|
|
24
|
+
*/
|
|
25
|
+
declare function createFormAttributeValidator(attr: Attribute, messages?: ValidationMessages): z.ZodTypeAny;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Validate data against an attribute schema
|
|
29
|
+
*/
|
|
30
|
+
declare function validateAttribute(attr: Attribute, value: unknown): ValidationResult;
|
|
31
|
+
/**
|
|
32
|
+
* Validate data against an object schema
|
|
33
|
+
*/
|
|
34
|
+
declare function validateObject(objectDef: ObjectDefinition, data: Record<string, unknown>): ValidationResult;
|
|
35
|
+
/**
|
|
36
|
+
* Validate and throw if invalid.
|
|
37
|
+
*
|
|
38
|
+
* Throws `ValidationError` (code `SCHEMA_VALIDATION_FAILED`) on failure so HTTP
|
|
39
|
+
* adapters can map it to 400. Generic `Error` would bubble up to a 500.
|
|
40
|
+
*/
|
|
41
|
+
declare function validateObjectOrThrow(objectDef: ObjectDefinition, data: Record<string, unknown>): Record<string, unknown>;
|
|
42
|
+
/**
|
|
43
|
+
* Validate data in draft mode.
|
|
44
|
+
* - All attributes are treated as optional (no required validation)
|
|
45
|
+
* - Provided values are still validated for format/type correctness
|
|
46
|
+
*/
|
|
47
|
+
declare function validateDraft(objectDef: ObjectDefinition, data: Record<string, unknown>): ValidationResult;
|
|
48
|
+
/**
|
|
49
|
+
* Validate draft data and throw if format validation fails.
|
|
50
|
+
*
|
|
51
|
+
* Same contract as `validateObjectOrThrow` but skips `required()` checks.
|
|
52
|
+
* Throws `ValidationError` so HTTP adapters map it to 400.
|
|
53
|
+
*/
|
|
54
|
+
declare function validateDraftOrThrow(objectDef: ObjectDefinition, data: Record<string, unknown>): Record<string, unknown>;
|
|
55
|
+
/**
|
|
56
|
+
* Throw a `ValidationError` when `data` contains keys that do not correspond
|
|
57
|
+
* to any attribute declared on `objectDef`.
|
|
58
|
+
*
|
|
59
|
+
* Call this on **client-supplied input** before Zod validation so the error
|
|
60
|
+
* message clearly names every offending key. Do NOT call on merged data that
|
|
61
|
+
* includes existing record values — older records may legitimately carry stale
|
|
62
|
+
* keys that predate this guard (see issue #658).
|
|
63
|
+
*
|
|
64
|
+
* Maps to HTTP 400 via `SchemaExceptionFilter` (code SCHEMA_VALIDATION_FAILED).
|
|
65
|
+
*/
|
|
66
|
+
declare function rejectUnknownAttributesOrThrow(objectDef: ObjectDefinition, data: Record<string, unknown>): void;
|
|
67
|
+
/**
|
|
68
|
+
* Get the list of required attributes that are missing values.
|
|
69
|
+
*/
|
|
70
|
+
declare function getMissingRequiredAttributes(objectDef: ObjectDefinition, data: Record<string, unknown>): Attribute[];
|
|
71
|
+
/**
|
|
72
|
+
* Check if a record is complete (all required attributes have valid values).
|
|
73
|
+
*/
|
|
74
|
+
declare function isRecordComplete(objectDef: ObjectDefinition, data: Record<string, unknown>): boolean;
|
|
75
|
+
|
|
76
|
+
export { createFormAttributeValidator as a, validateDraft as b, createAttributeValidator as c, validateDraftOrThrow as d, validateObject as e, validateObjectOrThrow as f, getMissingRequiredAttributes as g, isRecordComplete as i, rejectUnknownAttributesOrThrow as r, validateAttribute as v };
|