@stndrds/schema 1.0.0-alpha.188 → 1.0.0-alpha.190
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/chunk-FQ2ZYOVS.js +688 -0
- package/dist/chunk-LTHSU4NF.mjs +639 -0
- package/dist/{helpers-BjuFhbQQ.d.mts → helpers-HrKmSkLi.d.mts} +7 -1
- package/dist/{helpers-CSuoa3kj.d.ts → helpers-Y9rNQ6sz.d.ts} +7 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +160 -475
- package/dist/index.mjs +3 -426
- package/dist/validation/all.d.mts +1 -1
- package/dist/validation/all.d.ts +1 -1
- package/dist/validation/all.js +7 -7
- package/dist/validation/all.mjs +1 -1
- package/dist/validation/object/index.d.mts +1 -1
- package/dist/validation/object/index.d.ts +1 -1
- package/dist/validation/object/index.js +13 -13
- package/dist/validation/object/index.mjs +1 -1
- package/package.json +2 -2
- package/dist/chunk-64R5X3DF.js +0 -221
- package/dist/chunk-6JEQE4IP.mjs +0 -208
package/dist/index.mjs
CHANGED
|
@@ -2,8 +2,8 @@ import { generateId } from './chunk-QY6QFRRV.mjs';
|
|
|
2
2
|
export { asTenantId, asUserId, deepEqual, generateId, indexBy } from './chunk-QY6QFRRV.mjs';
|
|
3
3
|
import './chunk-SP3PNHYF.mjs';
|
|
4
4
|
export { parseAttributeConfig } from './chunk-U4JC7P6D.mjs';
|
|
5
|
-
import { createObjectValidator, createAttributeValidator } from './chunk-
|
|
6
|
-
export { computeRecordStatus, createFormAttributeValidator, validateDraft, validateDraftOrThrow, validateObject, validateObjectOrThrow } from './chunk-
|
|
5
|
+
import { createObjectValidator, ValidationError, createAttributeValidator } from './chunk-LTHSU4NF.mjs';
|
|
6
|
+
export { AccessDeniedError, AttributeInUseError, AttributeNotFoundError, ChangeTypeNotSupportedError, ConcurrentModificationError, DestructiveSyncNotAllowedError, DuplicateError, ForbiddenError, MemoryNotFoundError, MigrationTimeoutError, NotFoundError, NotImplementedError, ObjectNotFoundError, ObjectReferencedError, OrphanSystemAttributeError, ProtectedResourceError, ProtectedRoleError, RecordNotFoundError, RecordReferencedError, RepositoryError, RoleNotFoundError, SchemaError, SchemaErrorCode, StorageError, SyncCascadeError, SyncConflictError, SyncError, SystemEntityImmutableError, ValidationError, computeRecordStatus, createFormAttributeValidator, isAttributeInUseError, isNotFoundError, isObjectReferencedError, isProtectedResourceError, isRecordReferencedError, isSchemaError, isValidationError, validateDraft, validateDraftOrThrow, validateObject, validateObjectOrThrow } from './chunk-LTHSU4NF.mjs';
|
|
7
7
|
import './chunk-TMYBEXBT.mjs';
|
|
8
8
|
import './chunk-4KRLCWJM.mjs';
|
|
9
9
|
import './chunk-KNYZH2WD.mjs';
|
|
@@ -69,429 +69,6 @@ var MAX_PRESET_DEPTH = 5;
|
|
|
69
69
|
// src/types/documents.ts
|
|
70
70
|
var DEFAULT_DOCUMENT_SLOT = { name: "file" };
|
|
71
71
|
|
|
72
|
-
// src/exceptions.ts
|
|
73
|
-
var SchemaErrorCode = {
|
|
74
|
-
// Generic
|
|
75
|
-
UNKNOWN: "SCHEMA_UNKNOWN_ERROR",
|
|
76
|
-
// Not Found
|
|
77
|
-
OBJECT_NOT_FOUND: "SCHEMA_OBJECT_NOT_FOUND",
|
|
78
|
-
ATTRIBUTE_NOT_FOUND: "SCHEMA_ATTRIBUTE_NOT_FOUND",
|
|
79
|
-
RECORD_NOT_FOUND: "SCHEMA_RECORD_NOT_FOUND",
|
|
80
|
-
ROLE_NOT_FOUND: "SCHEMA_ROLE_NOT_FOUND",
|
|
81
|
-
MEMORY_NOT_FOUND: "SCHEMA_MEMORY_NOT_FOUND",
|
|
82
|
-
// Validation
|
|
83
|
-
VALIDATION_FAILED: "SCHEMA_VALIDATION_FAILED",
|
|
84
|
-
INVALID_ATTRIBUTE_NAME: "SCHEMA_INVALID_ATTRIBUTE_NAME",
|
|
85
|
-
INVALID_OBJECT_NAME: "SCHEMA_INVALID_OBJECT_NAME",
|
|
86
|
-
// Protected Resources
|
|
87
|
-
PROTECTED_OBJECT: "SCHEMA_PROTECTED_OBJECT",
|
|
88
|
-
PROTECTED_ATTRIBUTE: "SCHEMA_PROTECTED_ATTRIBUTE",
|
|
89
|
-
PROTECTED_VIEW: "SCHEMA_PROTECTED_VIEW",
|
|
90
|
-
PROTECTED_ROLE: "SCHEMA_PROTECTED_ROLE",
|
|
91
|
-
// Permissions
|
|
92
|
-
FORBIDDEN: "SCHEMA_FORBIDDEN",
|
|
93
|
-
ACCESS_DENIED: "SCHEMA_ACCESS_DENIED",
|
|
94
|
-
// Sync
|
|
95
|
-
SYNC_FAILED: "SCHEMA_SYNC_FAILED",
|
|
96
|
-
SYNC_CONFLICT: "SCHEMA_SYNC_CONFLICT",
|
|
97
|
-
SYNC_CASCADE: "SCHEMA_SYNC_CASCADE",
|
|
98
|
-
ORPHAN_SYSTEM_ATTRIBUTE: "SCHEMA_ORPHAN_SYSTEM_ATTRIBUTE",
|
|
99
|
-
// System Entity Immutability
|
|
100
|
-
SYSTEM_ENTITY_IMMUTABLE: "SCHEMA_SYSTEM_ENTITY_IMMUTABLE",
|
|
101
|
-
// L2 — migration system simplification (2026-05-17)
|
|
102
|
-
DESTRUCTIVE_NOT_ALLOWED: "SCHEMA_DESTRUCTIVE_NOT_ALLOWED",
|
|
103
|
-
MIGRATION_TIMEOUT: "SCHEMA_MIGRATION_TIMEOUT",
|
|
104
|
-
CHANGE_TYPE_NOT_SUPPORTED: "SCHEMA_CHANGE_TYPE_NOT_SUPPORTED",
|
|
105
|
-
// Duplicates
|
|
106
|
-
DUPLICATE_OBJECT: "SCHEMA_DUPLICATE_OBJECT",
|
|
107
|
-
DUPLICATE_ATTRIBUTE: "SCHEMA_DUPLICATE_ATTRIBUTE",
|
|
108
|
-
// Concurrency
|
|
109
|
-
CONFLICT: "SCHEMA_CONFLICT",
|
|
110
|
-
// Storage
|
|
111
|
-
STORAGE_UPLOAD_FAILED: "SCHEMA_STORAGE_UPLOAD_FAILED",
|
|
112
|
-
STORAGE_DOWNLOAD_FAILED: "SCHEMA_STORAGE_DOWNLOAD_FAILED",
|
|
113
|
-
STORAGE_DELETE_FAILED: "SCHEMA_STORAGE_DELETE_FAILED",
|
|
114
|
-
STORAGE_URL_FAILED: "SCHEMA_STORAGE_URL_FAILED",
|
|
115
|
-
// Repository Operations
|
|
116
|
-
REPOSITORY_CREATE_FAILED: "SCHEMA_REPOSITORY_CREATE_FAILED",
|
|
117
|
-
REPOSITORY_UPDATE_FAILED: "SCHEMA_REPOSITORY_UPDATE_FAILED",
|
|
118
|
-
REPOSITORY_DELETE_FAILED: "SCHEMA_REPOSITORY_DELETE_FAILED",
|
|
119
|
-
REPOSITORY_QUERY_FAILED: "SCHEMA_REPOSITORY_QUERY_FAILED",
|
|
120
|
-
// Not Implemented
|
|
121
|
-
NOT_IMPLEMENTED: "SCHEMA_NOT_IMPLEMENTED",
|
|
122
|
-
// Timeout
|
|
123
|
-
TIMEOUT: "SCHEMA_TIMEOUT",
|
|
124
|
-
// Schema Integrity
|
|
125
|
-
RECORD_REFERENCED: "SCHEMA_RECORD_REFERENCED",
|
|
126
|
-
ATTRIBUTE_IN_USE: "SCHEMA_ATTRIBUTE_IN_USE",
|
|
127
|
-
OBJECT_REFERENCED: "SCHEMA_OBJECT_REFERENCED"
|
|
128
|
-
};
|
|
129
|
-
var SchemaError = class extends Error {
|
|
130
|
-
constructor(message, code = SchemaErrorCode.UNKNOWN, details) {
|
|
131
|
-
super(message);
|
|
132
|
-
this.name = "SchemaError";
|
|
133
|
-
this.code = code;
|
|
134
|
-
this.details = details;
|
|
135
|
-
Object.setPrototypeOf(this, new.target.prototype);
|
|
136
|
-
}
|
|
137
|
-
toJSON() {
|
|
138
|
-
return {
|
|
139
|
-
name: this.name,
|
|
140
|
-
code: this.code,
|
|
141
|
-
message: this.message,
|
|
142
|
-
details: this.details
|
|
143
|
-
};
|
|
144
|
-
}
|
|
145
|
-
};
|
|
146
|
-
var NotFoundError = class extends SchemaError {
|
|
147
|
-
constructor(resourceType, resourceId, code = SchemaErrorCode.RECORD_NOT_FOUND) {
|
|
148
|
-
super(`${resourceType} with id "${resourceId}" not found`, code, {
|
|
149
|
-
resourceType,
|
|
150
|
-
resourceId
|
|
151
|
-
});
|
|
152
|
-
this.name = "NotFoundError";
|
|
153
|
-
this.resourceType = resourceType;
|
|
154
|
-
this.resourceId = resourceId;
|
|
155
|
-
}
|
|
156
|
-
};
|
|
157
|
-
var ObjectNotFoundError = class extends NotFoundError {
|
|
158
|
-
constructor(objectId) {
|
|
159
|
-
super("Object", objectId, SchemaErrorCode.OBJECT_NOT_FOUND);
|
|
160
|
-
this.name = "ObjectNotFoundError";
|
|
161
|
-
}
|
|
162
|
-
};
|
|
163
|
-
var AttributeNotFoundError = class extends NotFoundError {
|
|
164
|
-
constructor(attributeId) {
|
|
165
|
-
super("Attribute", attributeId, SchemaErrorCode.ATTRIBUTE_NOT_FOUND);
|
|
166
|
-
this.name = "AttributeNotFoundError";
|
|
167
|
-
}
|
|
168
|
-
};
|
|
169
|
-
var RecordNotFoundError = class extends NotFoundError {
|
|
170
|
-
constructor(recordId) {
|
|
171
|
-
super("Record", recordId, SchemaErrorCode.RECORD_NOT_FOUND);
|
|
172
|
-
this.name = "RecordNotFoundError";
|
|
173
|
-
}
|
|
174
|
-
};
|
|
175
|
-
var ValidationError = class _ValidationError extends SchemaError {
|
|
176
|
-
constructor(message, errors) {
|
|
177
|
-
super(message, SchemaErrorCode.VALIDATION_FAILED, { errors });
|
|
178
|
-
this.name = "ValidationError";
|
|
179
|
-
this.errors = errors;
|
|
180
|
-
}
|
|
181
|
-
/**
|
|
182
|
-
* Create a validation error from Zod-style errors
|
|
183
|
-
*/
|
|
184
|
-
static fromZodErrors(errors) {
|
|
185
|
-
const details = errors.map((err) => ({
|
|
186
|
-
path: err.path.map(String),
|
|
187
|
-
message: err.message
|
|
188
|
-
}));
|
|
189
|
-
const message = `Validation failed: ${details.map((d) => `${d.path.join(".")}: ${d.message}`).join(", ")}`;
|
|
190
|
-
return new _ValidationError(message, details);
|
|
191
|
-
}
|
|
192
|
-
};
|
|
193
|
-
var ProtectedResourceError = class extends SchemaError {
|
|
194
|
-
constructor(resourceType, resourceName, operation) {
|
|
195
|
-
const code = resourceType === "object" ? SchemaErrorCode.PROTECTED_OBJECT : resourceType === "view" ? SchemaErrorCode.PROTECTED_VIEW : SchemaErrorCode.PROTECTED_ATTRIBUTE;
|
|
196
|
-
super(`Cannot ${operation} system ${resourceType} "${resourceName}"`, code, {
|
|
197
|
-
resourceType,
|
|
198
|
-
resourceName,
|
|
199
|
-
operation
|
|
200
|
-
});
|
|
201
|
-
this.name = "ProtectedResourceError";
|
|
202
|
-
this.resourceType = resourceType;
|
|
203
|
-
this.resourceName = resourceName;
|
|
204
|
-
this.operation = operation;
|
|
205
|
-
}
|
|
206
|
-
};
|
|
207
|
-
var SyncError = class extends SchemaError {
|
|
208
|
-
constructor(objectName, message, cause) {
|
|
209
|
-
super(`Failed to sync object "${objectName}": ${message}`, SchemaErrorCode.SYNC_FAILED, {
|
|
210
|
-
objectName,
|
|
211
|
-
cause: cause?.message
|
|
212
|
-
});
|
|
213
|
-
this.name = "SyncError";
|
|
214
|
-
this.objectName = objectName;
|
|
215
|
-
this.cause = cause;
|
|
216
|
-
}
|
|
217
|
-
};
|
|
218
|
-
var SystemEntityImmutableError = class extends SchemaError {
|
|
219
|
-
constructor(entityType, entityName) {
|
|
220
|
-
super(
|
|
221
|
-
`Cannot mutate system ${entityType} "${entityName}". System entities are declared in code and immutable at runtime.`,
|
|
222
|
-
SchemaErrorCode.SYSTEM_ENTITY_IMMUTABLE,
|
|
223
|
-
{ entityType, entityName }
|
|
224
|
-
);
|
|
225
|
-
this.name = "SystemEntityImmutableError";
|
|
226
|
-
this.entityType = entityType;
|
|
227
|
-
this.entityName = entityName;
|
|
228
|
-
}
|
|
229
|
-
};
|
|
230
|
-
var SyncConflictError = class extends SchemaError {
|
|
231
|
-
constructor(params) {
|
|
232
|
-
const target = params.attributeName ? `"${params.objectName}.${params.attributeName}"` : `"${params.objectName}"`;
|
|
233
|
-
super(
|
|
234
|
-
`Cannot promote runtime entity ${target}: ${params.reason}. Resolve via: (1) relax the code constraint, (2) migrate runtime values manually, or (3) rename the code declaration.`,
|
|
235
|
-
SchemaErrorCode.SYNC_CONFLICT,
|
|
236
|
-
{
|
|
237
|
-
objectName: params.objectName,
|
|
238
|
-
attributeName: params.attributeName,
|
|
239
|
-
reason: params.reason
|
|
240
|
-
}
|
|
241
|
-
);
|
|
242
|
-
this.name = "SyncConflictError";
|
|
243
|
-
this.objectName = params.objectName;
|
|
244
|
-
this.attributeName = params.attributeName;
|
|
245
|
-
this.reason = params.reason;
|
|
246
|
-
}
|
|
247
|
-
};
|
|
248
|
-
var SyncCascadeError = class extends SchemaError {
|
|
249
|
-
constructor(objectName, conflictingAttributes) {
|
|
250
|
-
super(
|
|
251
|
-
`Cannot demote object "${objectName}": attributes ${conflictingAttributes.join(", ")} are still declared in code. Remove them from code first, or restore the object.`,
|
|
252
|
-
SchemaErrorCode.SYNC_CASCADE,
|
|
253
|
-
{ objectName, conflictingAttributes }
|
|
254
|
-
);
|
|
255
|
-
this.name = "SyncCascadeError";
|
|
256
|
-
this.objectName = objectName;
|
|
257
|
-
this.conflictingAttributes = conflictingAttributes;
|
|
258
|
-
}
|
|
259
|
-
};
|
|
260
|
-
var OrphanSystemAttributeError = class extends SchemaError {
|
|
261
|
-
constructor(objectName, attributeName) {
|
|
262
|
-
super(
|
|
263
|
-
`Attribute "${objectName}.${attributeName}" is system:true but its object parent is system:false. This is an invariant violation.`,
|
|
264
|
-
SchemaErrorCode.ORPHAN_SYSTEM_ATTRIBUTE,
|
|
265
|
-
{ objectName, attributeName }
|
|
266
|
-
);
|
|
267
|
-
this.name = "OrphanSystemAttributeError";
|
|
268
|
-
this.objectName = objectName;
|
|
269
|
-
this.attributeName = attributeName;
|
|
270
|
-
}
|
|
271
|
-
};
|
|
272
|
-
var DestructiveSyncNotAllowedError = class extends SchemaError {
|
|
273
|
-
constructor(operations) {
|
|
274
|
-
const summary = operations.map((op) => {
|
|
275
|
-
if (op.type === "remove_attribute") {
|
|
276
|
-
return `- remove_attribute "${op.objectName ?? "?"}.${op.name}"`;
|
|
277
|
-
}
|
|
278
|
-
if (op.type === "remove_object") {
|
|
279
|
-
return "- remove_object";
|
|
280
|
-
}
|
|
281
|
-
return `- ${op.type}`;
|
|
282
|
-
}).join("\n");
|
|
283
|
-
super(
|
|
284
|
-
`Destructive schema operations detected (data will be lost):
|
|
285
|
-
${summary}
|
|
286
|
-
|
|
287
|
-
To allow Standards to apply these automatically, set the environment variable:
|
|
288
|
-
STANDARDS_ALLOW_DESTRUCTIVE_SYNC=1
|
|
289
|
-
|
|
290
|
-
Otherwise, revert your code changes or back up the data first.`,
|
|
291
|
-
SchemaErrorCode.DESTRUCTIVE_NOT_ALLOWED,
|
|
292
|
-
{ operations }
|
|
293
|
-
);
|
|
294
|
-
this.name = "DestructiveSyncNotAllowedError";
|
|
295
|
-
this.operations = operations;
|
|
296
|
-
}
|
|
297
|
-
};
|
|
298
|
-
var MigrationTimeoutError = class extends SchemaError {
|
|
299
|
-
constructor(objectName, migrated, total, maxDurationMs) {
|
|
300
|
-
super(
|
|
301
|
-
`Migration for "${objectName}" exceeded the maximum duration (${maxDurationMs}ms). Migrated ${migrated}/${total} records before timeout. Increase STANDARDS_MIGRATION_MAX_DURATION_MS or split the migration into smaller batches.`,
|
|
302
|
-
SchemaErrorCode.MIGRATION_TIMEOUT,
|
|
303
|
-
{ objectName, migrated, total, maxDurationMs }
|
|
304
|
-
);
|
|
305
|
-
this.name = "MigrationTimeoutError";
|
|
306
|
-
this.objectName = objectName;
|
|
307
|
-
this.migrated = migrated;
|
|
308
|
-
this.total = total;
|
|
309
|
-
this.maxDurationMs = maxDurationMs;
|
|
310
|
-
}
|
|
311
|
-
};
|
|
312
|
-
var ChangeTypeNotSupportedError = class extends SchemaError {
|
|
313
|
-
constructor(objectName, attributeName) {
|
|
314
|
-
super(
|
|
315
|
-
`Cannot change type of attribute "${objectName}.${attributeName}" via runtime API. Declare a migration in your schema code:
|
|
316
|
-
object("${objectName}").migration(N, (m) =>
|
|
317
|
-
m.changeType("${attributeName}", from, to, { transform: (v) => ... })
|
|
318
|
-
)`,
|
|
319
|
-
SchemaErrorCode.CHANGE_TYPE_NOT_SUPPORTED,
|
|
320
|
-
{ objectName, attributeName }
|
|
321
|
-
);
|
|
322
|
-
this.name = "ChangeTypeNotSupportedError";
|
|
323
|
-
this.objectName = objectName;
|
|
324
|
-
this.attributeName = attributeName;
|
|
325
|
-
}
|
|
326
|
-
};
|
|
327
|
-
var DuplicateError = class extends SchemaError {
|
|
328
|
-
constructor(resourceType, resourceName) {
|
|
329
|
-
const code = resourceType === "object" ? SchemaErrorCode.DUPLICATE_OBJECT : SchemaErrorCode.DUPLICATE_ATTRIBUTE;
|
|
330
|
-
super(
|
|
331
|
-
`${resourceType === "object" ? "Object" : "Attribute"} "${resourceName}" already exists`,
|
|
332
|
-
code,
|
|
333
|
-
{ resourceType, resourceName }
|
|
334
|
-
);
|
|
335
|
-
this.name = "DuplicateError";
|
|
336
|
-
this.resourceType = resourceType;
|
|
337
|
-
this.resourceName = resourceName;
|
|
338
|
-
}
|
|
339
|
-
};
|
|
340
|
-
function isSchemaError(error) {
|
|
341
|
-
return error instanceof SchemaError;
|
|
342
|
-
}
|
|
343
|
-
function isNotFoundError(error) {
|
|
344
|
-
return error instanceof NotFoundError;
|
|
345
|
-
}
|
|
346
|
-
function isValidationError(error) {
|
|
347
|
-
return error instanceof ValidationError;
|
|
348
|
-
}
|
|
349
|
-
function isProtectedResourceError(error) {
|
|
350
|
-
return error instanceof ProtectedResourceError;
|
|
351
|
-
}
|
|
352
|
-
var ForbiddenError = class extends SchemaError {
|
|
353
|
-
constructor(objectName, action, userId) {
|
|
354
|
-
super(`No ${action} permission on object "${objectName}"`, SchemaErrorCode.FORBIDDEN, {
|
|
355
|
-
objectName,
|
|
356
|
-
action,
|
|
357
|
-
userId
|
|
358
|
-
});
|
|
359
|
-
this.name = "ForbiddenError";
|
|
360
|
-
this.objectName = objectName;
|
|
361
|
-
this.action = action;
|
|
362
|
-
this.userId = userId;
|
|
363
|
-
}
|
|
364
|
-
};
|
|
365
|
-
var ProtectedRoleError = class extends SchemaError {
|
|
366
|
-
constructor(roleName, operation) {
|
|
367
|
-
super(`Cannot ${operation} system role "${roleName}"`, SchemaErrorCode.PROTECTED_ROLE, {
|
|
368
|
-
roleName,
|
|
369
|
-
operation
|
|
370
|
-
});
|
|
371
|
-
this.name = "ProtectedRoleError";
|
|
372
|
-
this.roleName = roleName;
|
|
373
|
-
this.operation = operation;
|
|
374
|
-
}
|
|
375
|
-
};
|
|
376
|
-
var RoleNotFoundError = class extends NotFoundError {
|
|
377
|
-
constructor(roleId) {
|
|
378
|
-
super("Role", roleId, SchemaErrorCode.ROLE_NOT_FOUND);
|
|
379
|
-
this.name = "RoleNotFoundError";
|
|
380
|
-
}
|
|
381
|
-
};
|
|
382
|
-
var ConcurrentModificationError = class extends SchemaError {
|
|
383
|
-
constructor(recordId) {
|
|
384
|
-
super(
|
|
385
|
-
`Record ${recordId} was modified by another request. Please refresh and try again.`,
|
|
386
|
-
SchemaErrorCode.CONFLICT,
|
|
387
|
-
{ recordId }
|
|
388
|
-
);
|
|
389
|
-
}
|
|
390
|
-
};
|
|
391
|
-
var StorageError = class extends SchemaError {
|
|
392
|
-
constructor(operation, message, path, cause) {
|
|
393
|
-
const code = operation === "upload" ? SchemaErrorCode.STORAGE_UPLOAD_FAILED : operation === "download" ? SchemaErrorCode.STORAGE_DOWNLOAD_FAILED : operation === "delete" ? SchemaErrorCode.STORAGE_DELETE_FAILED : SchemaErrorCode.STORAGE_URL_FAILED;
|
|
394
|
-
super(`Storage ${operation} failed: ${message}`, code, {
|
|
395
|
-
operation,
|
|
396
|
-
path,
|
|
397
|
-
cause
|
|
398
|
-
});
|
|
399
|
-
this.name = "StorageError";
|
|
400
|
-
this.operation = operation;
|
|
401
|
-
this.path = path;
|
|
402
|
-
this.cause = cause;
|
|
403
|
-
}
|
|
404
|
-
};
|
|
405
|
-
var AccessDeniedError = class extends SchemaError {
|
|
406
|
-
constructor(resource, reason) {
|
|
407
|
-
super(reason ?? `Access denied to resource: ${resource}`, SchemaErrorCode.ACCESS_DENIED, {
|
|
408
|
-
resource,
|
|
409
|
-
reason
|
|
410
|
-
});
|
|
411
|
-
this.name = "AccessDeniedError";
|
|
412
|
-
this.resource = resource;
|
|
413
|
-
this.reason = reason;
|
|
414
|
-
}
|
|
415
|
-
};
|
|
416
|
-
var RepositoryError = class extends SchemaError {
|
|
417
|
-
constructor(operation, entity, message, cause) {
|
|
418
|
-
const code = operation === "create" ? SchemaErrorCode.REPOSITORY_CREATE_FAILED : operation === "update" ? SchemaErrorCode.REPOSITORY_UPDATE_FAILED : operation === "delete" ? SchemaErrorCode.REPOSITORY_DELETE_FAILED : SchemaErrorCode.REPOSITORY_QUERY_FAILED;
|
|
419
|
-
super(`Failed to ${operation} ${entity}: ${message}`, code, {
|
|
420
|
-
operation,
|
|
421
|
-
entity,
|
|
422
|
-
cause
|
|
423
|
-
});
|
|
424
|
-
this.name = "RepositoryError";
|
|
425
|
-
this.operation = operation;
|
|
426
|
-
this.entity = entity;
|
|
427
|
-
this.cause = cause;
|
|
428
|
-
}
|
|
429
|
-
};
|
|
430
|
-
var NotImplementedError = class extends SchemaError {
|
|
431
|
-
constructor(feature, milestone) {
|
|
432
|
-
const message = milestone ? `${feature}: not implemented (${milestone})` : `${feature}: not implemented`;
|
|
433
|
-
super(message, SchemaErrorCode.NOT_IMPLEMENTED, {
|
|
434
|
-
feature,
|
|
435
|
-
milestone
|
|
436
|
-
});
|
|
437
|
-
this.name = "NotImplementedError";
|
|
438
|
-
this.feature = feature;
|
|
439
|
-
this.milestone = milestone;
|
|
440
|
-
}
|
|
441
|
-
};
|
|
442
|
-
var MemoryNotFoundError = class extends NotFoundError {
|
|
443
|
-
constructor(memoryId) {
|
|
444
|
-
super("Memory", memoryId, SchemaErrorCode.MEMORY_NOT_FOUND);
|
|
445
|
-
this.name = "MemoryNotFoundError";
|
|
446
|
-
}
|
|
447
|
-
};
|
|
448
|
-
var RecordReferencedError = class extends SchemaError {
|
|
449
|
-
constructor(recordId, references) {
|
|
450
|
-
const total = references.reduce((sum, r) => sum + r.count, 0);
|
|
451
|
-
super(
|
|
452
|
-
`Cannot delete record: referenced by ${total} record${total > 1 ? "s" : ""}`,
|
|
453
|
-
SchemaErrorCode.RECORD_REFERENCED,
|
|
454
|
-
{ recordId, references }
|
|
455
|
-
);
|
|
456
|
-
this.name = "RecordReferencedError";
|
|
457
|
-
this.recordId = recordId;
|
|
458
|
-
this.references = references;
|
|
459
|
-
}
|
|
460
|
-
};
|
|
461
|
-
var AttributeInUseError = class extends SchemaError {
|
|
462
|
-
constructor(attributeName, usage) {
|
|
463
|
-
super(
|
|
464
|
-
`Cannot delete attribute "${attributeName}": used in ${usage}`,
|
|
465
|
-
SchemaErrorCode.ATTRIBUTE_IN_USE,
|
|
466
|
-
{ attributeName, usage }
|
|
467
|
-
);
|
|
468
|
-
this.name = "AttributeInUseError";
|
|
469
|
-
this.attributeName = attributeName;
|
|
470
|
-
this.usage = usage;
|
|
471
|
-
}
|
|
472
|
-
};
|
|
473
|
-
var ObjectReferencedError = class extends SchemaError {
|
|
474
|
-
constructor(objectName, referencingObjects) {
|
|
475
|
-
super(
|
|
476
|
-
`Cannot delete object "${objectName}": target of relations in ${referencingObjects.join(", ")}`,
|
|
477
|
-
SchemaErrorCode.OBJECT_REFERENCED,
|
|
478
|
-
{ objectName, referencingObjects }
|
|
479
|
-
);
|
|
480
|
-
this.name = "ObjectReferencedError";
|
|
481
|
-
this.objectName = objectName;
|
|
482
|
-
this.referencingObjects = referencingObjects;
|
|
483
|
-
}
|
|
484
|
-
};
|
|
485
|
-
function isRecordReferencedError(error) {
|
|
486
|
-
return error instanceof RecordReferencedError;
|
|
487
|
-
}
|
|
488
|
-
function isAttributeInUseError(error) {
|
|
489
|
-
return error instanceof AttributeInUseError;
|
|
490
|
-
}
|
|
491
|
-
function isObjectReferencedError(error) {
|
|
492
|
-
return error instanceof ObjectReferencedError;
|
|
493
|
-
}
|
|
494
|
-
|
|
495
72
|
// src/types/errors.ts
|
|
496
73
|
function getErrorMessage(error) {
|
|
497
74
|
if (error instanceof Error) return error.message;
|
|
@@ -5869,4 +5446,4 @@ function validateQualifiedRule(rule, context) {
|
|
|
5869
5446
|
assertOperatorForType(rule.operator, propDef.type, "property");
|
|
5870
5447
|
}
|
|
5871
5448
|
|
|
5872
|
-
export { ALLOWED_PROPERTY_TYPES, ALL_ACTIONS, ALL_SYSTEM_RESOURCES,
|
|
5449
|
+
export { ALLOWED_PROPERTY_TYPES, ALL_ACTIONS, ALL_SYSTEM_RESOURCES, ActivityTabConfig, BEHAVIOR_PROPERTIES, CustomTabConfig, DB_COLUMN_FIELDS, DEFAULT_DOCUMENT_SLOT, DEFAULT_ROLES, DEFAULT_ROLE_DESCRIPTIONS, DEFAULT_ROLE_LABELS, DEFAULT_ROLE_PERMISSIONS, DOCUMENT_SYSTEM_ATTRIBUTES, DetailViewBuilder, DocumentSlotValidationError, DocumentsTabConfig, EMPTY_VALUE_PLACEHOLDER, FORM_FORBIDDEN_ATTRIBUTE_TYPES, FlagRegistry, FlagService, FormBuilder, FormRegistry, FormRowBuilder, FormStepBuilder, GroupBuilder, IDENTITY_PROPERTIES, InvalidPathError, ListViewBuilder, ListViewTabConfigBuilder, MAX_PRESET_DEPTH, MaxDepthExceededError, NO_VALUE_OPERATORS, NoopGeocodingAdapter, OPERATORS_BY_TYPE, OPERATOR_SPECS, ObjectBuilder, PRESENTATION_PROPERTIES, QUALIFIED_SEPARATOR, RELATION_TARGET_ANY, RESERVED_ATTRIBUTE_NAMES, RelationGroupBuilder, RichtextTabConfig, STANDARD_SCHEMA_VENDOR, SYSTEM_ATTRIBUTES, SYSTEM_ATTRIBUTE_I18N_KEYS, SYSTEM_FIELD_NAMES, SYSTEM_RESOURCES, SYSTEM_RESOURCE_LABELS, TabBuilder, TableTabConfig, USER_STATUSES, accessLevelToActions, actionsToAccessLevel, applyPipes, booleanFlag, buildPropertySchema, buildQualifiedAttribute, checkbox, createFlagRegistry, createFlagService, createStandardSchemaProps, currency, date, detailView, document, evaluateFilterState, evaluateFormula, evaluateFormulaAttribute, evaluateFormulaWithResult, extractAttributeNames, extractFormulaVariables, extractRelationNames, extractRelationReferences, file, flagRegistry, flattenRelationsForEval, form, formRegistry, formatAttributeValue, formatFormulaResult, formula, generateDefaultDetailView, generateDefaultListView, getActiveTab, getErrorMessage, getOperatorPolarity, getPathDepth, getRelationPath, getRollupFilterOperators, getSystemAttributeI18nKey, getSystemAttributeList, getTargetAttributeName, group, hasOptions, hasRelationReferences, inferInverseCardinality, isAttributeSortable, isBilateralRelation, isDefaultRole, isDetailView, isDocumentAttribute, isEmptyObject, isFieldGroup, isFormDefinition, isFormFieldsRow, isFormFreeFieldRef, isFormHeadingRow, isFormSeparatorRow, isFormSlotFieldRef, isFormTextRow, isLabelExpression, isListView, isNoValueOperator, isNotEmpty, isRelationGroup, isStandardSchema, isUniversalRelation, jsonFlag, listView, location, matchesMime, multiselect, normaliseDocumentSlots, normalizeForEdgeRpc, number, numberFlag, object, parsePath, parseQualifiedAttribute, pathHasManyCardinality, phone, rating, registry, relation, relationGroup, renderLabelExpression, resetViewToDefault, richtext, rollup, select, status, stringFlag, text, textarea, toUndefinedIfEmpty, user, validateAttributeName, validateFormulaExpression, validatePath, validateQualifiedRule, validateSlotAgainstConfig, viewRegistry };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { V as ValidationMessages } from '../types-C5DittlR.mjs';
|
|
2
2
|
export { DEFAULT_VALIDATION_MESSAGES, formatZodErrors } from './core/index.mjs';
|
|
3
3
|
export { parseAttributeConfig } from './config/index.mjs';
|
|
4
|
-
export { c as computeRecordStatus, a as createFormAttributeValidator, v as validateDraft, b as validateDraftOrThrow, d as validateObject, e as validateObjectOrThrow } from '../helpers-
|
|
4
|
+
export { c as computeRecordStatus, a as createFormAttributeValidator, v as validateDraft, b as validateDraftOrThrow, d as validateObject, e as validateObjectOrThrow } from '../helpers-HrKmSkLi.mjs';
|
|
5
5
|
import '../filters-HDG4kLoo.mjs';
|
|
6
6
|
import '@stndrds/constants';
|
|
7
7
|
import '../utils.mjs';
|
package/dist/validation/all.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { V as ValidationMessages } from '../types-Bdlhgrf7.js';
|
|
2
2
|
export { DEFAULT_VALIDATION_MESSAGES, formatZodErrors } from './core/index.js';
|
|
3
3
|
export { parseAttributeConfig } from './config/index.js';
|
|
4
|
-
export { c as computeRecordStatus, a as createFormAttributeValidator, v as validateDraft, b as validateDraftOrThrow, d as validateObject, e as validateObjectOrThrow } from '../helpers-
|
|
4
|
+
export { c as computeRecordStatus, a as createFormAttributeValidator, v as validateDraft, b as validateDraftOrThrow, d as validateObject, e as validateObjectOrThrow } from '../helpers-Y9rNQ6sz.js';
|
|
5
5
|
import '../filters-DVBn5tov.js';
|
|
6
6
|
import '@stndrds/constants';
|
|
7
7
|
import '../utils.js';
|
package/dist/validation/all.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
require('../chunk-PGERPYDR.js');
|
|
4
4
|
var chunkYQROI4IE_js = require('../chunk-YQROI4IE.js');
|
|
5
|
-
var
|
|
5
|
+
var chunkFQ2ZYOVS_js = require('../chunk-FQ2ZYOVS.js');
|
|
6
6
|
require('../chunk-MAKSIK3P.js');
|
|
7
7
|
require('../chunk-J5HRK3WD.js');
|
|
8
8
|
require('../chunk-TKN73433.js');
|
|
@@ -28,27 +28,27 @@ Object.defineProperty(exports, "parseAttributeConfig", {
|
|
|
28
28
|
});
|
|
29
29
|
Object.defineProperty(exports, "computeRecordStatus", {
|
|
30
30
|
enumerable: true,
|
|
31
|
-
get: function () { return
|
|
31
|
+
get: function () { return chunkFQ2ZYOVS_js.computeRecordStatus; }
|
|
32
32
|
});
|
|
33
33
|
Object.defineProperty(exports, "createFormAttributeValidator", {
|
|
34
34
|
enumerable: true,
|
|
35
|
-
get: function () { return
|
|
35
|
+
get: function () { return chunkFQ2ZYOVS_js.createFormAttributeValidator; }
|
|
36
36
|
});
|
|
37
37
|
Object.defineProperty(exports, "validateDraft", {
|
|
38
38
|
enumerable: true,
|
|
39
|
-
get: function () { return
|
|
39
|
+
get: function () { return chunkFQ2ZYOVS_js.validateDraft; }
|
|
40
40
|
});
|
|
41
41
|
Object.defineProperty(exports, "validateDraftOrThrow", {
|
|
42
42
|
enumerable: true,
|
|
43
|
-
get: function () { return
|
|
43
|
+
get: function () { return chunkFQ2ZYOVS_js.validateDraftOrThrow; }
|
|
44
44
|
});
|
|
45
45
|
Object.defineProperty(exports, "validateObject", {
|
|
46
46
|
enumerable: true,
|
|
47
|
-
get: function () { return
|
|
47
|
+
get: function () { return chunkFQ2ZYOVS_js.validateObject; }
|
|
48
48
|
});
|
|
49
49
|
Object.defineProperty(exports, "validateObjectOrThrow", {
|
|
50
50
|
enumerable: true,
|
|
51
|
-
get: function () { return
|
|
51
|
+
get: function () { return chunkFQ2ZYOVS_js.validateObjectOrThrow; }
|
|
52
52
|
});
|
|
53
53
|
Object.defineProperty(exports, "DEFAULT_VALIDATION_MESSAGES", {
|
|
54
54
|
enumerable: true,
|
package/dist/validation/all.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import '../chunk-SP3PNHYF.mjs';
|
|
2
2
|
export { parseAttributeConfig } from '../chunk-U4JC7P6D.mjs';
|
|
3
|
-
export { computeRecordStatus, createFormAttributeValidator, validateDraft, validateDraftOrThrow, validateObject, validateObjectOrThrow } from '../chunk-
|
|
3
|
+
export { computeRecordStatus, createFormAttributeValidator, validateDraft, validateDraftOrThrow, validateObject, validateObjectOrThrow } from '../chunk-LTHSU4NF.mjs';
|
|
4
4
|
import '../chunk-TMYBEXBT.mjs';
|
|
5
5
|
import '../chunk-4KRLCWJM.mjs';
|
|
6
6
|
import '../chunk-KNYZH2WD.mjs';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { c as computeRecordStatus, f as createAttributeValidator, a as createFormAttributeValidator, g as getMissingRequiredAttributes, i as isRecordComplete, h as validateAttribute, v as validateDraft, b as validateDraftOrThrow, d as validateObject, e as validateObjectOrThrow } from '../../helpers-
|
|
1
|
+
export { c as computeRecordStatus, f as createAttributeValidator, a as createFormAttributeValidator, g as getMissingRequiredAttributes, i as isRecordComplete, h as validateAttribute, v as validateDraft, b as validateDraftOrThrow, d as validateObject, e as validateObjectOrThrow } from '../../helpers-HrKmSkLi.mjs';
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
import { O as ObjectDefinition } from '../../filters-HDG4kLoo.mjs';
|
|
4
4
|
import '../../types-C5DittlR.mjs';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { c as computeRecordStatus, f as createAttributeValidator, a as createFormAttributeValidator, g as getMissingRequiredAttributes, i as isRecordComplete, h as validateAttribute, v as validateDraft, b as validateDraftOrThrow, d as validateObject, e as validateObjectOrThrow } from '../../helpers-
|
|
1
|
+
export { c as computeRecordStatus, f as createAttributeValidator, a as createFormAttributeValidator, g as getMissingRequiredAttributes, i as isRecordComplete, h as validateAttribute, v as validateDraft, b as validateDraftOrThrow, d as validateObject, e as validateObjectOrThrow } from '../../helpers-Y9rNQ6sz.js';
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
import { O as ObjectDefinition } from '../../filters-DVBn5tov.js';
|
|
4
4
|
import '../../types-Bdlhgrf7.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkFQ2ZYOVS_js = require('../../chunk-FQ2ZYOVS.js');
|
|
4
4
|
require('../../chunk-MAKSIK3P.js');
|
|
5
5
|
require('../../chunk-J5HRK3WD.js');
|
|
6
6
|
require('../../chunk-TKN73433.js');
|
|
@@ -22,49 +22,49 @@ require('../../chunk-T225DB55.js');
|
|
|
22
22
|
|
|
23
23
|
Object.defineProperty(exports, "computeRecordStatus", {
|
|
24
24
|
enumerable: true,
|
|
25
|
-
get: function () { return
|
|
25
|
+
get: function () { return chunkFQ2ZYOVS_js.computeRecordStatus; }
|
|
26
26
|
});
|
|
27
27
|
Object.defineProperty(exports, "createAttributeValidator", {
|
|
28
28
|
enumerable: true,
|
|
29
|
-
get: function () { return
|
|
29
|
+
get: function () { return chunkFQ2ZYOVS_js.createAttributeValidator; }
|
|
30
30
|
});
|
|
31
31
|
Object.defineProperty(exports, "createDraftValidator", {
|
|
32
32
|
enumerable: true,
|
|
33
|
-
get: function () { return
|
|
33
|
+
get: function () { return chunkFQ2ZYOVS_js.createDraftValidator; }
|
|
34
34
|
});
|
|
35
35
|
Object.defineProperty(exports, "createFormAttributeValidator", {
|
|
36
36
|
enumerable: true,
|
|
37
|
-
get: function () { return
|
|
37
|
+
get: function () { return chunkFQ2ZYOVS_js.createFormAttributeValidator; }
|
|
38
38
|
});
|
|
39
39
|
Object.defineProperty(exports, "createObjectValidator", {
|
|
40
40
|
enumerable: true,
|
|
41
|
-
get: function () { return
|
|
41
|
+
get: function () { return chunkFQ2ZYOVS_js.createObjectValidator; }
|
|
42
42
|
});
|
|
43
43
|
Object.defineProperty(exports, "getMissingRequiredAttributes", {
|
|
44
44
|
enumerable: true,
|
|
45
|
-
get: function () { return
|
|
45
|
+
get: function () { return chunkFQ2ZYOVS_js.getMissingRequiredAttributes; }
|
|
46
46
|
});
|
|
47
47
|
Object.defineProperty(exports, "isRecordComplete", {
|
|
48
48
|
enumerable: true,
|
|
49
|
-
get: function () { return
|
|
49
|
+
get: function () { return chunkFQ2ZYOVS_js.isRecordComplete; }
|
|
50
50
|
});
|
|
51
51
|
Object.defineProperty(exports, "validateAttribute", {
|
|
52
52
|
enumerable: true,
|
|
53
|
-
get: function () { return
|
|
53
|
+
get: function () { return chunkFQ2ZYOVS_js.validateAttribute; }
|
|
54
54
|
});
|
|
55
55
|
Object.defineProperty(exports, "validateDraft", {
|
|
56
56
|
enumerable: true,
|
|
57
|
-
get: function () { return
|
|
57
|
+
get: function () { return chunkFQ2ZYOVS_js.validateDraft; }
|
|
58
58
|
});
|
|
59
59
|
Object.defineProperty(exports, "validateDraftOrThrow", {
|
|
60
60
|
enumerable: true,
|
|
61
|
-
get: function () { return
|
|
61
|
+
get: function () { return chunkFQ2ZYOVS_js.validateDraftOrThrow; }
|
|
62
62
|
});
|
|
63
63
|
Object.defineProperty(exports, "validateObject", {
|
|
64
64
|
enumerable: true,
|
|
65
|
-
get: function () { return
|
|
65
|
+
get: function () { return chunkFQ2ZYOVS_js.validateObject; }
|
|
66
66
|
});
|
|
67
67
|
Object.defineProperty(exports, "validateObjectOrThrow", {
|
|
68
68
|
enumerable: true,
|
|
69
|
-
get: function () { return
|
|
69
|
+
get: function () { return chunkFQ2ZYOVS_js.validateObjectOrThrow; }
|
|
70
70
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { computeRecordStatus, createAttributeValidator, createDraftValidator, createFormAttributeValidator, createObjectValidator, getMissingRequiredAttributes, isRecordComplete, validateAttribute, validateDraft, validateDraftOrThrow, validateObject, validateObjectOrThrow } from '../../chunk-
|
|
1
|
+
export { computeRecordStatus, createAttributeValidator, createDraftValidator, createFormAttributeValidator, createObjectValidator, getMissingRequiredAttributes, isRecordComplete, validateAttribute, validateDraft, validateDraftOrThrow, validateObject, validateObjectOrThrow } from '../../chunk-LTHSU4NF.mjs';
|
|
2
2
|
import '../../chunk-TMYBEXBT.mjs';
|
|
3
3
|
import '../../chunk-4KRLCWJM.mjs';
|
|
4
4
|
import '../../chunk-KNYZH2WD.mjs';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stndrds/schema",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.190",
|
|
4
4
|
"description": "Standard schema definitions and utilities",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -131,7 +131,7 @@
|
|
|
131
131
|
"expr-eval": "^2.0.2",
|
|
132
132
|
"libphonenumber-js": "^1.12.31",
|
|
133
133
|
"zod": "^4.2.1",
|
|
134
|
-
"@stndrds/constants": "1.0.0-alpha.
|
|
134
|
+
"@stndrds/constants": "1.0.0-alpha.190"
|
|
135
135
|
},
|
|
136
136
|
"devDependencies": {
|
|
137
137
|
"@types/node": "^25.0.3",
|