@stndrds/schema 1.0.0-alpha.302 → 1.0.0-alpha.303

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/dist/{all-CarWsKlE.d.ts → all-BV7tFgtR.d.ts} +3 -3
  2. package/dist/{all-CNJlNEG2.d.mts → all-EX5romwn.d.mts} +3 -3
  3. package/dist/attributes-CJNqalP0.d.mts +1350 -0
  4. package/dist/attributes-CJNqalP0.d.ts +1350 -0
  5. package/dist/chunk-CCB4E55H.mjs +2 -0
  6. package/dist/chunk-JKGRSRRX.js +2 -0
  7. package/dist/exceptions.d.mts +1 -536
  8. package/dist/exceptions.d.ts +1 -536
  9. package/dist/{helpers-MEZ69ERH.d.mts → helpers-BnyKRb4x.d.mts} +3 -3
  10. package/dist/{helpers-BQ524PQe.d.ts → helpers-DIWzq1cf.d.ts} +3 -3
  11. package/dist/{index-DL0rfjzZ.d.ts → index-B36J5GDI.d.ts} +2 -2
  12. package/dist/{index-Kd4QZ13G.d.mts → index-DcXCAPHR.d.mts} +2 -2
  13. package/dist/index.d.mts +91 -16
  14. package/dist/index.d.ts +91 -16
  15. package/dist/index.js +17 -17
  16. package/dist/index.mjs +17 -17
  17. package/dist/{objects-D8tojUPV.d.ts → objects-CfJvQbZc.d.ts} +1 -3
  18. package/dist/{objects-DvZ79fW2.d.mts → objects-DglxOigU.d.mts} +1 -3
  19. package/dist/{types-R2f1GdCB.d.ts → types-CEwRsyh0.d.ts} +1 -1
  20. package/dist/{types-M5L07ItN.d.mts → types-Co8cq3dM.d.mts} +1 -1
  21. package/dist/utils.d.mts +2 -134
  22. package/dist/utils.d.ts +2 -134
  23. package/dist/utils.js +1 -1
  24. package/dist/utils.mjs +1 -1
  25. package/dist/validation/all.d.mts +6 -8
  26. package/dist/validation/all.d.ts +6 -8
  27. package/dist/validation/complex/currency.d.mts +2 -3
  28. package/dist/validation/complex/currency.d.ts +2 -3
  29. package/dist/validation/complex/location.d.mts +2 -3
  30. package/dist/validation/complex/location.d.ts +2 -3
  31. package/dist/validation/complex/phone.d.mts +2 -3
  32. package/dist/validation/complex/phone.d.ts +2 -3
  33. package/dist/validation/complex/relation.d.mts +2 -3
  34. package/dist/validation/complex/relation.d.ts +2 -3
  35. package/dist/validation/complex/richtext.d.mts +2 -3
  36. package/dist/validation/complex/richtext.d.ts +2 -3
  37. package/dist/validation/complex/select.d.mts +2 -3
  38. package/dist/validation/complex/select.d.ts +2 -3
  39. package/dist/validation/complex/user.d.mts +2 -3
  40. package/dist/validation/complex/user.d.ts +2 -3
  41. package/dist/validation/computed/formula.d.mts +2 -3
  42. package/dist/validation/computed/formula.d.ts +2 -3
  43. package/dist/validation/computed/rollup.d.mts +2 -3
  44. package/dist/validation/computed/rollup.d.ts +2 -3
  45. package/dist/validation/config/index.d.mts +3 -5
  46. package/dist/validation/config/index.d.ts +3 -5
  47. package/dist/validation/core/index.d.mts +3 -4
  48. package/dist/validation/core/index.d.ts +3 -4
  49. package/dist/validation/object/index.d.mts +4 -6
  50. package/dist/validation/object/index.d.ts +4 -6
  51. package/dist/validation/primitives/checkbox.d.mts +2 -3
  52. package/dist/validation/primitives/checkbox.d.ts +2 -3
  53. package/dist/validation/primitives/date.d.mts +2 -3
  54. package/dist/validation/primitives/date.d.ts +2 -3
  55. package/dist/validation/primitives/number.d.mts +2 -3
  56. package/dist/validation/primitives/number.d.ts +2 -3
  57. package/dist/validation/primitives/text.d.mts +2 -3
  58. package/dist/validation/primitives/text.d.ts +2 -3
  59. package/package.json +2 -2
  60. package/dist/attributes-DfhBu4HT.d.ts +0 -590
  61. package/dist/attributes-Zw-DDGE7.d.mts +0 -590
  62. package/dist/chunk-64F3CCLD.mjs +0 -2
  63. package/dist/chunk-ZMDMQAV5.js +0 -2
  64. package/dist/migrations-B1Wl_3RY.d.ts +0 -39
  65. package/dist/migrations-BG2mNaJn.d.mts +0 -39
@@ -0,0 +1,1350 @@
1
+ import { IconName, CountryIso3, CurrencyCode, ColorId } from '@stndrds/constants';
2
+
3
+ type ComputedFormulaAstNode = ComputedFormulaLiteralNode | ComputedFormulaPathNode | ComputedFormulaCallNode | ComputedFormulaBinaryNode;
4
+ interface ComputedFormulaLiteralNode {
5
+ kind: "literal";
6
+ value: string | number | boolean | null;
7
+ }
8
+ interface ComputedFormulaPathNode {
9
+ kind: "path";
10
+ parts: string[];
11
+ }
12
+ interface ComputedFormulaCallNode {
13
+ kind: "call";
14
+ functionName: string;
15
+ args: ComputedFormulaAstNode[];
16
+ }
17
+ interface ComputedFormulaBinaryNode {
18
+ kind: "binary";
19
+ operator: ComputedFormulaBinaryOperator;
20
+ left: ComputedFormulaAstNode;
21
+ right: ComputedFormulaAstNode;
22
+ }
23
+ type ComputedFormulaBinaryOperator = ">" | "<" | ">=" | "<=" | "==" | "!=" | "+" | "-" | "*" | "/";
24
+ declare class ComputedFormulaParseError extends Error {
25
+ constructor(message: string);
26
+ }
27
+ declare function parseComputedFormula(expression: string): ComputedFormulaAstNode;
28
+
29
+ type ComputedReturnType = "text" | "number" | "boolean" | "date" | "select" | "multiselect";
30
+ type ComputedFieldKind = "formula" | "rollup";
31
+ type ComputedValueType = {
32
+ kind: "scalar";
33
+ type: Exclude<ComputedReturnType, "multiselect">;
34
+ } | {
35
+ kind: "collection";
36
+ itemType: "text" | "number" | "boolean" | "date" | "select";
37
+ };
38
+ interface ComputedOptionsSource {
39
+ objectName: string;
40
+ attributeName: string;
41
+ attributeId?: string;
42
+ }
43
+ type ComputedDependency = {
44
+ kind: "local";
45
+ attributeName: string;
46
+ } | {
47
+ kind: "relation";
48
+ relationName: string;
49
+ targetAttributeName?: string;
50
+ cardinality?: "one" | "many";
51
+ } | {
52
+ kind: "computed";
53
+ attributeName: string;
54
+ } | {
55
+ kind: "options";
56
+ source: ComputedOptionsSource;
57
+ };
58
+ interface ComputedPlan {
59
+ kind: ComputedFieldKind;
60
+ attributeName: string;
61
+ expression: string;
62
+ returnType: ComputedReturnType;
63
+ valueType: ComputedValueType;
64
+ dependencies: ComputedDependency[];
65
+ optionsSource?: ComputedOptionsSource;
66
+ targetAttributeType?: AttributeType;
67
+ dependenciesHash: string;
68
+ ast?: ComputedFormulaAstNode;
69
+ }
70
+
71
+ type BuiltInTransform = "toString" | "toNumber" | "toDate" | "toBoolean" | "toISOString";
72
+ type SchemaOperation = {
73
+ type: "add_attribute";
74
+ attribute: Attribute;
75
+ } | {
76
+ type: "remove_attribute";
77
+ name: string;
78
+ backup_config: Attribute;
79
+ } | {
80
+ type: "rename_attribute";
81
+ from: string;
82
+ to: string;
83
+ } | {
84
+ type: "change_type";
85
+ name: string;
86
+ from: AttributeType;
87
+ to: AttributeType;
88
+ transform?: BuiltInTransform;
89
+ } | {
90
+ type: "update_config";
91
+ name: string;
92
+ from: Partial<Record<string, unknown>>;
93
+ to: Partial<Record<string, unknown>>;
94
+ } | {
95
+ type: "remove_object";
96
+ backup: Record<string, unknown>;
97
+ } | {
98
+ type: "rename_object";
99
+ from: string;
100
+ to: string;
101
+ };
102
+ interface MigrationDefinition {
103
+ version: number;
104
+ operations: SchemaOperation[];
105
+ }
106
+
107
+ /**
108
+ * Error codes for schema exceptions
109
+ */
110
+ declare const SchemaErrorCode: {
111
+ readonly UNKNOWN: "SCHEMA_UNKNOWN_ERROR";
112
+ readonly OBJECT_NOT_FOUND: "SCHEMA_OBJECT_NOT_FOUND";
113
+ readonly ATTRIBUTE_NOT_FOUND: "SCHEMA_ATTRIBUTE_NOT_FOUND";
114
+ readonly RECORD_NOT_FOUND: "SCHEMA_RECORD_NOT_FOUND";
115
+ readonly SOURCE_NOT_FOUND: "SCHEMA_SOURCE_NOT_FOUND";
116
+ readonly ROLE_NOT_FOUND: "SCHEMA_ROLE_NOT_FOUND";
117
+ readonly MEMORY_NOT_FOUND: "SCHEMA_MEMORY_NOT_FOUND";
118
+ readonly SCHEMA_PLAN_NOT_FOUND: "SCHEMA_PLAN_NOT_FOUND";
119
+ readonly VALIDATION_FAILED: "SCHEMA_VALIDATION_FAILED";
120
+ readonly INVALID_ATTRIBUTE_NAME: "SCHEMA_INVALID_ATTRIBUTE_NAME";
121
+ readonly INVALID_OBJECT_NAME: "SCHEMA_INVALID_OBJECT_NAME";
122
+ /** A consumer declared, registered, bundled or sourced an object under a framework-native name (#3450). */
123
+ readonly RESERVED_OBJECT_NAME: "SCHEMA_RESERVED_OBJECT_NAME";
124
+ readonly PROTECTED_OBJECT: "SCHEMA_PROTECTED_OBJECT";
125
+ readonly PROTECTED_ATTRIBUTE: "SCHEMA_PROTECTED_ATTRIBUTE";
126
+ readonly PROTECTED_VIEW: "SCHEMA_PROTECTED_VIEW";
127
+ readonly PROTECTED_ROLE: "SCHEMA_PROTECTED_ROLE";
128
+ readonly FORBIDDEN: "SCHEMA_FORBIDDEN";
129
+ readonly ACCESS_DENIED: "SCHEMA_ACCESS_DENIED";
130
+ /**
131
+ * A workspace RULE refuses the write — the last owner cannot be removed.
132
+ *
133
+ * Not `INVARIANT_VIOLATION`, despite the name: that one is an internal
134
+ * "should never happen" assertion, a bug signal nobody outside the codebase
135
+ * can act on. This is the opposite — a rule the caller can act on, reached
136
+ * by a request that was entirely well-formed, whose message tells them how.
137
+ */
138
+ readonly WORKSPACE_INVARIANT: "SCHEMA_WORKSPACE_INVARIANT";
139
+ /** The resource's own state refuses the operation — a disarmed reflex run. */
140
+ readonly STATE_GATE: "SCHEMA_STATE_GATE";
141
+ /** The operation needs an actor and the request carried none. */
142
+ readonly ACTOR_CONTEXT_REQUIRED: "SCHEMA_ACTOR_CONTEXT_REQUIRED";
143
+ readonly CONNECTOR_AUTH_FAILED: "SCHEMA_CONNECTOR_AUTH_FAILED";
144
+ readonly CONNECTOR_INVALID_STATE: "SCHEMA_CONNECTOR_INVALID_STATE";
145
+ /**
146
+ * The provider issued tokens and the flow failed AFTER that — resolving the
147
+ * connected address. Distinct from CONNECTOR_AUTH_FAILED because the user is
148
+ * left holding a real grant: consent happened, and it may still be live on the
149
+ * provider side even though no connection row exists here.
150
+ */
151
+ readonly CONNECTOR_GRANT_ORPHANED: "SCHEMA_CONNECTOR_GRANT_ORPHANED";
152
+ readonly SYNC_FAILED: "SCHEMA_SYNC_FAILED";
153
+ readonly SYNC_CONFLICT: "SCHEMA_SYNC_CONFLICT";
154
+ readonly SYNC_CASCADE: "SCHEMA_SYNC_CASCADE";
155
+ readonly ORPHAN_SYSTEM_ATTRIBUTE: "SCHEMA_ORPHAN_SYSTEM_ATTRIBUTE";
156
+ readonly SYSTEM_ENTITY_IMMUTABLE: "SCHEMA_SYSTEM_ENTITY_IMMUTABLE";
157
+ readonly DESTRUCTIVE_NOT_ALLOWED: "SCHEMA_DESTRUCTIVE_NOT_ALLOWED";
158
+ readonly MIGRATION_TIMEOUT: "SCHEMA_MIGRATION_TIMEOUT";
159
+ readonly CHANGE_TYPE_NOT_SUPPORTED: "SCHEMA_CHANGE_TYPE_NOT_SUPPORTED";
160
+ readonly DUPLICATE: "SCHEMA_DUPLICATE";
161
+ readonly DUPLICATE_OBJECT: "SCHEMA_DUPLICATE_OBJECT";
162
+ readonly DUPLICATE_ATTRIBUTE: "SCHEMA_DUPLICATE_ATTRIBUTE";
163
+ readonly CONFLICT: "SCHEMA_CONFLICT";
164
+ readonly STORAGE_UPLOAD_FAILED: "SCHEMA_STORAGE_UPLOAD_FAILED";
165
+ readonly STORAGE_DOWNLOAD_FAILED: "SCHEMA_STORAGE_DOWNLOAD_FAILED";
166
+ readonly STORAGE_DELETE_FAILED: "SCHEMA_STORAGE_DELETE_FAILED";
167
+ readonly STORAGE_URL_FAILED: "SCHEMA_STORAGE_URL_FAILED";
168
+ readonly REPOSITORY_CREATE_FAILED: "SCHEMA_REPOSITORY_CREATE_FAILED";
169
+ readonly REPOSITORY_UPDATE_FAILED: "SCHEMA_REPOSITORY_UPDATE_FAILED";
170
+ readonly REPOSITORY_DELETE_FAILED: "SCHEMA_REPOSITORY_DELETE_FAILED";
171
+ readonly REPOSITORY_QUERY_FAILED: "SCHEMA_REPOSITORY_QUERY_FAILED";
172
+ readonly NOT_IMPLEMENTED: "SCHEMA_NOT_IMPLEMENTED";
173
+ readonly TIMEOUT: "SCHEMA_TIMEOUT";
174
+ readonly RECORD_REFERENCED: "SCHEMA_RECORD_REFERENCED";
175
+ readonly ATTRIBUTE_IN_USE: "SCHEMA_ATTRIBUTE_IN_USE";
176
+ readonly OBJECT_REFERENCED: "SCHEMA_OBJECT_REFERENCED";
177
+ readonly CONFIGURATION_REQUIRED: "CONFIGURATION_REQUIRED";
178
+ readonly SEARCH_ADAPTER_REQUIRED: "SEARCH_ADAPTER_REQUIRED";
179
+ readonly CRON_REGISTRATION_FAILED: "CRON_REGISTRATION_FAILED";
180
+ readonly SEARCH_BACKEND_FAILED: "SEARCH_BACKEND_FAILED";
181
+ readonly INVARIANT_VIOLATION: "INVARIANT_VIOLATION";
182
+ readonly TENANT_CONTEXT_MISSING: "TENANT_CONTEXT_MISSING";
183
+ readonly FEATURE_FLAGS_CONTEXT: "FEATURE_FLAGS_CONTEXT";
184
+ readonly REALTIME_RATE_LIMITED: "REALTIME_RATE_LIMITED";
185
+ readonly REALTIME_DELIVERY_FAILED: "REALTIME_DELIVERY_FAILED";
186
+ readonly REALTIME_SUBSCRIPTION_FAILED: "REALTIME_SUBSCRIPTION_FAILED";
187
+ readonly AGENT_UNKNOWN: "AGENT_UNKNOWN";
188
+ readonly AGENT_DEPTH_EXCEEDED: "AGENT_DEPTH_EXCEEDED";
189
+ readonly AGENT_COST_LIMIT_EXCEEDED: "AGENT_COST_LIMIT_EXCEEDED";
190
+ readonly AGENT_TREE_COST_LIMIT_EXCEEDED: "AGENT_TREE_COST_LIMIT_EXCEEDED";
191
+ readonly CREDITS_EXHAUSTED: "CREDITS_EXHAUSTED";
192
+ readonly QUOTA_EXCEEDED: "QUOTA_EXCEEDED";
193
+ readonly AGENT_SESSION_NOT_FOUND: "AGENT_SESSION_NOT_FOUND";
194
+ readonly AGENT_DEFINITION_NOT_FOUND: "AGENT_DEFINITION_NOT_FOUND";
195
+ readonly AGENT_RUN_CONFIG: "AGENT_RUN_CONFIG";
196
+ readonly AGENT_STREAMING: "AGENT_STREAMING";
197
+ readonly AGENT_MISSING_ACTOR: "AGENT_MISSING_ACTOR";
198
+ readonly AGENT_INVALID_STATE: "AGENT_INVALID_STATE";
199
+ readonly AGENT_COMPACTION_IMPOSSIBLE: "AGENT_COMPACTION_IMPOSSIBLE";
200
+ readonly AGENT_COMPACTION_TIMEOUT: "AGENT_COMPACTION_TIMEOUT";
201
+ readonly AGENT_LEASE_HELD: "AGENT_LEASE_HELD";
202
+ readonly AGENT_WORK_MODE_REQUIRED: "AGENT_WORK_MODE_REQUIRED";
203
+ readonly AGENT_MESSAGE_NOT_FOUND: "AGENT_MESSAGE_NOT_FOUND";
204
+ readonly AGENT_MESSAGE_NOT_EDITABLE: "AGENT_MESSAGE_NOT_EDITABLE";
205
+ readonly DEVICE_NOT_FOUND: "DEVICE_NOT_FOUND";
206
+ readonly DEVICE_OFFLINE: "DEVICE_OFFLINE";
207
+ readonly AI_UNKNOWN: "AI_UNKNOWN";
208
+ readonly AI_USAGE_LIMIT_EXCEEDED: "AI_USAGE_LIMIT_EXCEEDED";
209
+ readonly AI_INVALID_USAGE: "AI_INVALID_USAGE";
210
+ readonly AI_INVALID_MODEL: "AI_INVALID_MODEL";
211
+ readonly AI_INVALID_MODEL_INPUT: "AI_INVALID_MODEL_INPUT";
212
+ readonly AI_REPOSITORY_ERROR: "AI_REPOSITORY_ERROR";
213
+ readonly AI_GENERATION_FAILED: "AI_GENERATION_FAILED";
214
+ readonly AI_IMAGE_USAGE_PENDING: "AI_IMAGE_USAGE_PENDING";
215
+ readonly AI_IMAGE_GENERATION_INDETERMINATE: "AI_IMAGE_GENERATION_INDETERMINATE";
216
+ readonly AI_IMAGE_PUBLICATION_FAILED: "AI_IMAGE_PUBLICATION_FAILED";
217
+ readonly DOCUMENT_MIME_NOT_ACCEPTED: "DOCUMENT_MIME_NOT_ACCEPTED";
218
+ readonly DOCUMENT_MULTIPLE_NOT_ALLOWED: "DOCUMENT_MULTIPLE_NOT_ALLOWED";
219
+ readonly DOCUMENT_NOT_FOUND_FOR_OPERATION: "DOCUMENT_NOT_FOUND_FOR_OPERATION";
220
+ readonly DOCUMENT_STORAGE_FAILED: "DOCUMENT_STORAGE_FAILED";
221
+ readonly DOCUMENT_SIZE_EXCEEDED: "DOCUMENT_SIZE_EXCEEDED";
222
+ readonly DOCUMENT_OCR_FAILED: "DOCUMENT_OCR_FAILED";
223
+ readonly DOCUMENT_BLOB_EMPTY: "DOCUMENT_BLOB_EMPTY";
224
+ readonly DOCUMENT_FILE_TOO_LARGE: "DOCUMENT_FILE_TOO_LARGE";
225
+ readonly DOCUMENT_FILE_NOT_FOUND: "DOCUMENT_FILE_NOT_FOUND";
226
+ readonly DOCUMENT_FILE_ALREADY_PACKED: "DOCUMENT_FILE_ALREADY_PACKED";
227
+ readonly DOCUMENT_RECORD_NOT_FOUND: "DOCUMENT_RECORD_NOT_FOUND";
228
+ readonly DOCUMENT_RECORD_OBJECT_MISMATCH: "DOCUMENT_RECORD_OBJECT_MISMATCH";
229
+ readonly DOCUMENT_FOLDER_SERVICE_UNAVAILABLE: "DOCUMENT_FOLDER_SERVICE_UNAVAILABLE";
230
+ readonly DOCUMENT_FOLDER_PATH_NOT_FOUND: "DOCUMENT_FOLDER_PATH_NOT_FOUND";
231
+ readonly EMAIL_PROVIDER_API_FAILED: "EMAIL_PROVIDER_API_FAILED";
232
+ readonly EMAIL_BATCH_ITEM_FAILED: "EMAIL_BATCH_ITEM_FAILED";
233
+ readonly CALENDAR_PROVIDER_API_FAILED: "CALENDAR_PROVIDER_API_FAILED";
234
+ readonly REFLEX_INVALID_TRANSITION: "REFLEX_INVALID_TRANSITION";
235
+ readonly REFLEX_INVALID_TOKEN: "REFLEX_INVALID_TOKEN";
236
+ readonly REFLEX_CAPABILITY_DENIED: "REFLEX_CAPABILITY_DENIED";
237
+ readonly REFLEX_GATEWAY_UNAVAILABLE: "REFLEX_GATEWAY_UNAVAILABLE";
238
+ readonly REFLEX_BUNDLE_FAILED: "REFLEX_BUNDLE_FAILED";
239
+ readonly REFLEX_EGRESS_DENIED: "REFLEX_EGRESS_DENIED";
240
+ readonly REFLEX_PROTOCOL_VIOLATION: "REFLEX_PROTOCOL_VIOLATION";
241
+ readonly REFLEX_RUN_FAILED: "REFLEX_RUN_FAILED";
242
+ readonly REFLEX_RUN_TIMEOUT: "REFLEX_RUN_TIMEOUT";
243
+ readonly REFLEX_DEPENDENCY_DRIFT: "REFLEX_DEPENDENCY_DRIFT";
244
+ readonly REFLEX_NOT_READY: "REFLEX_NOT_READY";
245
+ readonly REFLEX_INVARIANT_VIOLATION: "REFLEX_INVARIANT_VIOLATION";
246
+ /** The embeddings feature is enabled but no Gateway credential is configured. */
247
+ readonly EMBEDDING_MODEL_UNAVAILABLE: "EMBEDDING_MODEL_UNAVAILABLE";
248
+ /** The provider returned vectors whose length differs from the configured dimensions. */
249
+ readonly EMBEDDING_DIMENSION_MISMATCH: "EMBEDDING_DIMENSION_MISMATCH";
250
+ };
251
+ type SchemaErrorCode = (typeof SchemaErrorCode)[keyof typeof SchemaErrorCode];
252
+ /**
253
+ * Base error class for all schema-related errors
254
+ */
255
+ declare class SchemaError extends Error {
256
+ readonly code: SchemaErrorCode;
257
+ readonly details?: Record<string, unknown>;
258
+ constructor(message: string, code?: SchemaErrorCode, details?: Record<string, unknown>);
259
+ toJSON(): {
260
+ name: string;
261
+ code: SchemaErrorCode;
262
+ message: string;
263
+ details: Record<string, unknown> | undefined;
264
+ };
265
+ }
266
+ /**
267
+ * Base class for "not found" errors
268
+ */
269
+ declare class NotFoundError extends SchemaError {
270
+ /** Literal discriminator for `Effect.catchTag`; a widened `string` breaks narrowing. */
271
+ readonly _tag = "NotFoundError";
272
+ readonly resourceType: string;
273
+ readonly resourceId: string;
274
+ constructor(resourceType: string, resourceId: string, code?: SchemaErrorCode, message?: string);
275
+ }
276
+ /**
277
+ * Object not found error
278
+ */
279
+ declare class ObjectNotFoundError extends NotFoundError {
280
+ constructor(objectId: string);
281
+ }
282
+ /**
283
+ * Attribute not found error
284
+ */
285
+ declare class AttributeNotFoundError extends NotFoundError {
286
+ constructor(attributeId: string);
287
+ }
288
+ /**
289
+ * Record not found error
290
+ */
291
+ declare class RecordNotFoundError extends NotFoundError {
292
+ constructor(recordId: string);
293
+ }
294
+ /**
295
+ * Schema plan not found error — raised when a `planId` sent by an approver
296
+ * (who never receives the plan payload itself, only its id) does not match
297
+ * any stored plan.
298
+ */
299
+ declare class SchemaPlanNotFoundError extends NotFoundError {
300
+ constructor(planId: string);
301
+ }
302
+ /**
303
+ * Validation error with field-level details
304
+ */
305
+ interface ValidationErrorDetail {
306
+ path: string[];
307
+ message: string;
308
+ code?: string;
309
+ }
310
+ /**
311
+ * Validation error thrown when data fails schema validation
312
+ */
313
+ declare class ValidationError extends SchemaError {
314
+ /** Literal discriminator for `Effect.catchTag`; a widened `string` breaks narrowing. */
315
+ readonly _tag = "ValidationError";
316
+ readonly errors: ValidationErrorDetail[];
317
+ constructor(message: string, errors: ValidationErrorDetail[]);
318
+ /**
319
+ * Create a validation error from Zod-style errors
320
+ */
321
+ static fromZodErrors(errors: Array<{
322
+ path: (string | number)[];
323
+ message: string;
324
+ }>): ValidationError;
325
+ }
326
+ /**
327
+ * Error thrown when attempting to modify a protected (system) resource
328
+ */
329
+ declare class ProtectedResourceError extends SchemaError {
330
+ readonly resourceType: "object" | "attribute" | "view";
331
+ readonly resourceName: string;
332
+ readonly operation: "delete" | "modify";
333
+ constructor(resourceType: "object" | "attribute" | "view", resourceName: string, operation: "delete" | "modify");
334
+ }
335
+ /**
336
+ * Error thrown during native object synchronization
337
+ */
338
+ declare class SyncError extends SchemaError {
339
+ readonly objectName: string;
340
+ readonly cause?: Error;
341
+ constructor(objectName: string, message: string, cause?: Error);
342
+ }
343
+ /**
344
+ * Thrown when code tries to mutate a system entity at runtime.
345
+ * System entities are declared in code and immutable at runtime.
346
+ * HTTP status: 403 Forbidden.
347
+ */
348
+ declare class SystemEntityImmutableError extends SchemaError {
349
+ readonly entityType: string;
350
+ readonly entityName: string;
351
+ constructor(entityType: string, entityName: string);
352
+ }
353
+ interface SyncConflictParams {
354
+ objectName: string;
355
+ attributeName?: string;
356
+ reason: string;
357
+ }
358
+ /**
359
+ * Thrown at boot when an auto-promote cannot proceed due to incompatible types
360
+ * or constraints. The dev must resolve manually (relax constraints, migrate
361
+ * values, or rename).
362
+ */
363
+ declare class SyncConflictError extends SchemaError {
364
+ readonly objectName: string;
365
+ readonly attributeName?: string;
366
+ readonly reason: string;
367
+ constructor(params: SyncConflictParams);
368
+ }
369
+ /**
370
+ * Thrown at boot when an object is being demoted but still has system attributes
371
+ * declared in code. The dev forgot to remove those attributes too, or kept the
372
+ * object inconsistently.
373
+ */
374
+ declare class SyncCascadeError extends SchemaError {
375
+ readonly objectName: string;
376
+ readonly conflictingAttributes: string[];
377
+ constructor(objectName: string, conflictingAttributes: string[]);
378
+ }
379
+ /**
380
+ * Thrown at boot when an attribute is system:true but its object parent is
381
+ * system:false. This invariant should never be violated — if seen, it's a bug
382
+ * in the boot reconciliation logic or in a manual DB mutation.
383
+ */
384
+ declare class OrphanSystemAttributeError extends SchemaError {
385
+ readonly objectName: string;
386
+ readonly attributeName: string;
387
+ constructor(objectName: string, attributeName: string);
388
+ }
389
+ /**
390
+ * Thrown when a destructive operation is detected without the explicit
391
+ * STANDARDS_ALLOW_DESTRUCTIVE_SYNC=1 opt-in.
392
+ * HTTP status: 500 (boot fail, should never surface to HTTP).
393
+ *
394
+ * Which operations the opt-in governs is decided in one place —
395
+ * `requiresDestructiveSyncOptIn` in the runtime's sync classifier. Today that
396
+ * is object removal only: attribute removal is unconditional at boot, because a
397
+ * system attribute is code-controlled and its disappearance from the builder is
398
+ * an unambiguous drop.
399
+ *
400
+ * NOTE — Wiring status: defined but not thrown by the current sync.ts, which
401
+ * demotes instead. Reserved for the `standards diff` CLI gate, which will throw
402
+ * it when CI detects an unauthorized destructive deployment.
403
+ */
404
+ declare class DestructiveSyncNotAllowedError extends SchemaError {
405
+ readonly operations: SchemaOperation[];
406
+ constructor(operations: SchemaOperation[]);
407
+ }
408
+ /**
409
+ * Thrown at boot when applying a migration in batches exceeds the maximum
410
+ * allowed duration (default 5 min, configurable via STANDARDS_MIGRATION_MAX_DURATION_MS).
411
+ * HTTP status: 500 (boot fail).
412
+ */
413
+ declare class MigrationTimeoutError extends SchemaError {
414
+ readonly objectName: string;
415
+ readonly migrated: number;
416
+ readonly total: number;
417
+ readonly maxDurationMs: number;
418
+ constructor(objectName: string, migrated: number, total: number, maxDurationMs: number);
419
+ }
420
+ /**
421
+ * Thrown when the runtime admin API is called to change an attribute's type.
422
+ * Type changes must be declared in code via `.migration(N, m => m.changeType(...))`.
423
+ * HTTP status: 400 Bad Request.
424
+ */
425
+ declare class ChangeTypeNotSupportedError extends SchemaError {
426
+ readonly objectName: string;
427
+ readonly attributeName: string;
428
+ constructor(objectName: string, attributeName: string);
429
+ }
430
+ /**
431
+ * Error thrown when attempting to create a duplicate resource.
432
+ *
433
+ * `resourceType` is free-form: pass `"object"`/`"attribute"` for schema
434
+ * resources (a specific code is selected automatically), or any domain label
435
+ * (`"tool"`, `"background job handler"`, …) for runtime registries, which fall
436
+ * back to the generic `DUPLICATE` code. The default message is
437
+ * `'<ResourceType> "<name>" already exists'`; pass a custom message when the
438
+ * domain reads better with different wording (e.g. "already registered for
439
+ * type X").
440
+ */
441
+ declare class DuplicateError extends SchemaError {
442
+ readonly resourceType: string;
443
+ readonly resourceName: string;
444
+ constructor(resourceType: string, resourceName: string, message?: string);
445
+ }
446
+ /**
447
+ * A consumer tried to build, register, bundle or source an object under a name
448
+ * the framework owns (`skill`, `memory`, `drives`, `artifact`, `meeting`).
449
+ * Raised at declaration time so the collision fails in the consumer's own
450
+ * tests, never at boot: the platform's `wealth-manager` bundle once shipped
451
+ * `meeting` and hid the native calendar object from every tenant for three
452
+ * days (#3450).
453
+ */
454
+ declare const RESERVED_NAME_CONTEXTS: {
455
+ readonly builder: "cannot be built by a consumer";
456
+ readonly registry: "cannot be registered by a consumer";
457
+ readonly bundle: "cannot be claimed by a bundle";
458
+ readonly source: "cannot be declared by a schema source";
459
+ };
460
+ declare class ReservedObjectNameError extends SchemaError {
461
+ readonly objectName: string;
462
+ constructor(objectName: string, context: keyof typeof RESERVED_NAME_CONTEXTS);
463
+ }
464
+ /**
465
+ * Check if an error is a SchemaError
466
+ */
467
+ declare function isSchemaError(error: unknown): error is SchemaError;
468
+ /**
469
+ * Check if an error is a NotFoundError
470
+ */
471
+ declare function isNotFoundError(error: unknown): error is NotFoundError;
472
+ /**
473
+ * Check if an error is a ValidationError
474
+ */
475
+ declare function isValidationError(error: unknown): error is ValidationError;
476
+ /**
477
+ * Check if an error is a ProtectedResourceError
478
+ */
479
+ declare function isProtectedResourceError(error: unknown): error is ProtectedResourceError;
480
+ /**
481
+ * Error thrown when a user lacks permission to perform an action.
482
+ *
483
+ * That, and nothing else (#2681) — its message is redacted, so it must not
484
+ * carry a refusal a permission grant would not lift: use `WORKSPACE_INVARIANT`,
485
+ * `STATE_GATE`, `ACTOR_CONTEXT_REQUIRED` or `SYSTEM_ENTITY_IMMUTABLE` instead.
486
+ */
487
+ declare class ForbiddenError extends SchemaError {
488
+ readonly objectName: string;
489
+ readonly action: string;
490
+ readonly userId?: string;
491
+ constructor(objectName: string, action: string, userId?: string);
492
+ }
493
+ /**
494
+ * Error thrown when trying to modify a protected role
495
+ */
496
+ declare class ProtectedRoleError extends SchemaError {
497
+ readonly roleName: string;
498
+ readonly operation: "delete" | "modify";
499
+ constructor(roleName: string, operation: "delete" | "modify");
500
+ }
501
+ /**
502
+ * Role not found error
503
+ */
504
+ declare class RoleNotFoundError extends NotFoundError {
505
+ constructor(roleId: string);
506
+ }
507
+ /**
508
+ * Thrown when a record has been modified by another request between read and write.
509
+ * Clients should retry the operation with fresh data.
510
+ * Maps to HTTP 409 Conflict.
511
+ */
512
+ declare class ConcurrentModificationError extends SchemaError {
513
+ constructor(recordId: string);
514
+ }
515
+ /**
516
+ * Storage operation type for error context
517
+ */
518
+ type StorageOperation = "upload" | "download" | "delete" | "signedUrl";
519
+ /**
520
+ * Error thrown when a storage operation fails
521
+ */
522
+ declare class StorageError extends SchemaError {
523
+ readonly operation: StorageOperation;
524
+ readonly path?: string;
525
+ readonly cause?: string;
526
+ constructor(operation: StorageOperation, message: string, path?: string, cause?: string);
527
+ }
528
+ /**
529
+ * Error thrown when access to a resource is denied (e.g., tenant path mismatch)
530
+ */
531
+ declare class AccessDeniedError extends SchemaError {
532
+ readonly resource: string;
533
+ readonly reason?: string;
534
+ constructor(resource: string, reason?: string);
535
+ }
536
+ /**
537
+ * Repository operation type for error context
538
+ */
539
+ type RepositoryOperation = "create" | "update" | "delete" | "query";
540
+ /**
541
+ * Error thrown when a repository operation fails
542
+ */
543
+ declare class RepositoryError extends SchemaError {
544
+ readonly operation: RepositoryOperation;
545
+ readonly entity: string;
546
+ readonly cause?: string;
547
+ constructor(operation: RepositoryOperation, entity: string, message: string, cause?: string);
548
+ }
549
+ /**
550
+ * Error thrown when a search read call fails at the transport level — e.g. the
551
+ * Meili client received a non-JSON body (`JSON.parse` SyntaxError) or a network
552
+ * failure. Translates an otherwise un-fingerprintable bare exception into a
553
+ * typed error with a stable `code` and a user-safe message. The original
554
+ * failure text is preserved in `cause`/`details`, never in the message.
555
+ */
556
+ declare class SearchBackendError extends SchemaError {
557
+ readonly scope: string;
558
+ readonly cause?: string;
559
+ constructor(scope: string, cause?: string);
560
+ }
561
+ /**
562
+ * Error thrown when a feature or method is not yet implemented
563
+ */
564
+ declare class NotImplementedError extends SchemaError {
565
+ readonly feature: string;
566
+ readonly milestone?: string;
567
+ constructor(feature: string, milestone?: string);
568
+ }
569
+ /**
570
+ * Memory entry not found error
571
+ */
572
+ declare class MemoryNotFoundError extends NotFoundError {
573
+ constructor(memoryId: string);
574
+ }
575
+ /**
576
+ * Reference information for a record that is blocking deletion.
577
+ */
578
+ interface RecordReference {
579
+ /** Technical name of the object (e.g., "contacts") */
580
+ objectName: string;
581
+ /** Display label of the object (e.g., "Contacts") */
582
+ objectLabel: string;
583
+ /** Number of records referencing the target */
584
+ count: number;
585
+ }
586
+ /**
587
+ * Thrown when attempting to delete a record that is referenced by other records.
588
+ *
589
+ * This implements the "Restrict" behavior: deletion is blocked and the user
590
+ * must first remove or update the referencing records.
591
+ */
592
+ declare class RecordReferencedError extends SchemaError {
593
+ readonly recordId: string;
594
+ readonly references: RecordReference[];
595
+ constructor(recordId: string, references: RecordReference[]);
596
+ }
597
+ /**
598
+ * Usage context where an attribute is being used.
599
+ */
600
+ type AttributeUsage = "labelExpression" | "embeddingExpression" | "view" | "filter";
601
+ /**
602
+ * Thrown when attempting to delete an attribute that is in use.
603
+ *
604
+ * Attributes cannot be deleted if they are referenced in:
605
+ * - The object's labelExpression template
606
+ * - A saved view's column configuration
607
+ * - A saved filter condition
608
+ */
609
+ declare class AttributeInUseError extends SchemaError {
610
+ readonly attributeName: string;
611
+ readonly usage: AttributeUsage;
612
+ constructor(attributeName: string, usage: AttributeUsage);
613
+ }
614
+ /**
615
+ * Thrown when attempting to delete an object that is a relation target.
616
+ *
617
+ * Objects cannot be deleted if other objects have relation attributes
618
+ * pointing to them as a target.
619
+ */
620
+ declare class ObjectReferencedError extends SchemaError {
621
+ readonly objectName: string;
622
+ readonly referencingObjects: string[];
623
+ constructor(objectName: string, referencingObjects: string[]);
624
+ }
625
+ /**
626
+ * Check if an error is a RecordReferencedError
627
+ */
628
+ declare function isRecordReferencedError(error: unknown): error is RecordReferencedError;
629
+ /**
630
+ * Check if an error is an AttributeInUseError
631
+ */
632
+ declare function isAttributeInUseError(error: unknown): error is AttributeInUseError;
633
+ /**
634
+ * Check if an error is an ObjectReferencedError
635
+ */
636
+ declare function isObjectReferencedError(error: unknown): error is ObjectReferencedError;
637
+
638
+ /**
639
+ * The one stable JSON traversal: object keys sorted, array order preserved,
640
+ * `undefined` object entries omitted, no whitespace.
641
+ *
642
+ * There used to be two. The runtime's copy was written because `sameValue()`
643
+ * used `JSON.stringify`, which is key-order sensitive: Postgres jsonb
644
+ * round-trips a config with a different key order than the blueprint that
645
+ * produced it, so system-agent sync saw perpetual false drift and
646
+ * unregistered/re-registered every cron on each boot. Merging the two back was
647
+ * blocked for a year on one question — does a canonical hash omit an
648
+ * `undefined` object entry, or refuse it? — answered in #2750: it omits it,
649
+ * exactly as `JSON.stringify` and jsonb storage both do.
650
+ *
651
+ * What remains is not one strictness but three, because three callers ask three
652
+ * different questions of the same walk:
653
+ *
654
+ * | | `canonicalStringify` | `serializeCanonicalJson` | `serializeStableJson` |
655
+ * |---|---|---|---|
656
+ * | asks | "what is this value, publicly?" | "what is this value's identity?" | "are these two the same?" |
657
+ * | `undefined` entry | omit | omit | omit |
658
+ * | top-level / array `undefined`, `NaN` | `null` | refuse | `null` |
659
+ * | `function` / `symbol` / `bigint` | refuse | refuse | coerce to its string |
660
+ * | `Date`, `Map`, class instance | own entries (see #3406) | refuse | own entries |
661
+ * | enumerable accessor | read it | refuse | skip it |
662
+ * | error raised | `ValidationError` | `NonJsonValueError` | `NonJsonValueError` |
663
+ *
664
+ * A content hash must refuse what it cannot represent, or two different values
665
+ * hash alike. A drift comparison must tolerate: it runs at boot against data
666
+ * that already exists, and refusing there turns a cosmetic false-drift into a
667
+ * server that will not start. The public traversal is the older contract, kept
668
+ * byte-for-byte because `@stndrds/client` and `@stndrds/reflex` hash with it.
669
+ *
670
+ * On genuinely JSON-compatible input all three emit the same bytes, so every
671
+ * stored hash still matches — with one measured exception against
672
+ * `JSON.stringify`-based predecessors: an object with integer-like keys.
673
+ * Rebuilding it to sort assigns those keys in ascending numeric order, where
674
+ * this traversal orders them lexicographically (`{"2":…,"10":…}` vs
675
+ * `{"10":…,"2":…}`). No caller passes such a key.
676
+ */
677
+
678
+ declare class NonJsonValueError extends SchemaError {
679
+ constructor();
680
+ }
681
+ /**
682
+ * Serializes a value into deterministic JSON: object keys are sorted
683
+ * recursively, array order is preserved, `undefined` object entries are
684
+ * omitted, and no whitespace is emitted.
685
+ *
686
+ * The canonicalization hashed across the runtime boot seed, the server, the CLI
687
+ * and `@stndrds/reflex` — the output must stay byte-identical for equivalent
688
+ * inputs regardless of key insertion order or jsonb storage round-trips.
689
+ *
690
+ * @throws {ValidationError} On circular references or unsupported value types
691
+ * (functions, symbols, bigint).
692
+ */
693
+ declare function canonicalStringify(value: unknown): string;
694
+ /**
695
+ * Key-sorted JSON for comparing values that round-trip through jsonb. Coerces
696
+ * what JSON cannot express rather than refusing — the caller is asking "are
697
+ * these the same?", not "is this valid?".
698
+ */
699
+ declare function serializeStableJson(value: unknown): string;
700
+ /**
701
+ * Key-sorted JSON for content identity. Throws {@link NonJsonValueError} on
702
+ * anything JSON cannot represent, so two different values never hash alike.
703
+ */
704
+ declare function serializeCanonicalJson(value: unknown): string;
705
+ /**
706
+ * Order-insensitive deep equality over {@link serializeStableJson}.
707
+ *
708
+ * Not `deepEqual` from `../utils`: that one compares in place without
709
+ * allocating, and answers differently for `NaN`, for an explicitly-`undefined`
710
+ * entry, and for a cycle. Reach for this when the bytes are the point.
711
+ */
712
+ declare function sameStableValue(left: unknown, right: unknown): boolean;
713
+
714
+ /**
715
+ * Brand symbol for nominal typing.
716
+ * This ensures type-safety by making IDs non-interchangeable.
717
+ */
718
+ declare const __brand: unique symbol;
719
+ /**
720
+ * Creates a branded type from a base type.
721
+ * Branded types are structurally identical but nominally different.
722
+ */
723
+ type Brand<T, B> = T & {
724
+ readonly [__brand]: B;
725
+ };
726
+ /**
727
+ * UUID string type for all identifiers
728
+ */
729
+ type Uuid = string;
730
+ /**
731
+ * Tenant identifier for multi-tenant isolation.
732
+ * Branded type to prevent accidental mixing with other string IDs.
733
+ *
734
+ * @example
735
+ * ```typescript
736
+ * const tenantId: TenantId = asTenantId('tenant-123');
737
+ * const userId: UserId = asUserId('user-456');
738
+ *
739
+ * // Type error: cannot assign UserId to TenantId
740
+ * const wrong: TenantId = userId;
741
+ * ```
742
+ */
743
+ type TenantId = Brand<string, "TenantId">;
744
+ /**
745
+ * User identifier for audit trails and permissions.
746
+ * Branded type to prevent accidental mixing with other string IDs.
747
+ */
748
+ type UserId = Brand<string, "UserId">;
749
+ /**
750
+ * Convert a string to a TenantId.
751
+ * Use this when receiving tenant IDs from external sources (JWT, headers).
752
+ *
753
+ * @param id - The string to convert
754
+ * @returns A branded TenantId
755
+ *
756
+ * @example
757
+ * ```typescript
758
+ * const tenantId = asTenantId(request.headers['x-tenant-id']);
759
+ * ```
760
+ */
761
+ declare function asTenantId(id: string): TenantId;
762
+ /**
763
+ * Convert a string to a UserId.
764
+ * Use this when receiving user IDs from external sources (JWT, auth).
765
+ *
766
+ * @param id - The string to convert
767
+ * @returns A branded UserId
768
+ *
769
+ * @example
770
+ * ```typescript
771
+ * const userId = asUserId(jwtPayload.sub);
772
+ * ```
773
+ */
774
+ declare function asUserId(id: string): UserId;
775
+ /**
776
+ * Generate a unique UUID v4
777
+ * Uses crypto.randomUUID() when available (Node.js 19+, modern browsers)
778
+ * Falls back to a manual implementation for older environments
779
+ *
780
+ * @returns A UUID v4 string
781
+ *
782
+ * @example
783
+ * ```typescript
784
+ * const id = generateId();
785
+ * // "a1b2c3d4-e5f6-4a7b-8c9d-0e1f2a3b4c5d"
786
+ * ```
787
+ */
788
+ declare function generateId(): Uuid;
789
+ /**
790
+ * Create a Map indexed by a key extracted from each item.
791
+ * This eliminates the repeated pattern: new Map(items.map(item => [keyFn(item), item]))
792
+ *
793
+ * Time complexity: O(n)
794
+ * Space complexity: O(n)
795
+ *
796
+ * @param items - Array of items to index
797
+ * @param keyFn - Function to extract the key from each item
798
+ * @returns Map indexed by the extracted key
799
+ *
800
+ * @example
801
+ * ```typescript
802
+ * const attributes = [{ name: "title", type: "text" }, { name: "status", type: "select" }];
803
+ *
804
+ * // Before:
805
+ * const attrMap = new Map(attributes.map(a => [a.name, a]));
806
+ *
807
+ * // After:
808
+ * const attrMap = indexBy(attributes, a => a.name);
809
+ * ```
810
+ */
811
+ declare function indexBy<T, K extends PropertyKey>(items: T[], keyFn: (item: T) => K): Map<K, T>;
812
+ /**
813
+ * Deep equality comparison for plain objects and arrays.
814
+ * Handles nested structures, arrays, primitives, null, and undefined.
815
+ *
816
+ * Time complexity: O(n) where n is total number of properties
817
+ *
818
+ * @param a - First value to compare
819
+ * @param b - Second value to compare
820
+ * @returns true if values are deeply equal
821
+ *
822
+ * @example
823
+ * ```typescript
824
+ * deepEqual({ a: 1, b: { c: 2 } }, { a: 1, b: { c: 2 } }); // true
825
+ * deepEqual({ a: 1, b: 2 }, { b: 2, a: 1 }); // true (order-independent)
826
+ * deepEqual([1, 2, 3], [1, 2, 3]); // true
827
+ * deepEqual([1, 2], [2, 1]); // false (arrays preserve order)
828
+ * ```
829
+ */
830
+ declare function deepEqual(a: unknown, b: unknown): boolean;
831
+
832
+ /**
833
+ * Allowed attribute types in .qualifyWith()
834
+ *
835
+ * IMPORTANT: Complex types (formula, rollup, relation, file, user, document, richtext)
836
+ * are NOT supported to avoid duplicating backend behavior.
837
+ */
838
+ type PropertyType = "text" | "number" | "checkbox" | "date" | "phone" | "currency" | "status" | "select" | "multiselect" | "location";
839
+ /**
840
+ * Union of attribute types allowed as qualified relation properties.
841
+ *
842
+ * These are the same Attribute types used for object attributes,
843
+ * restricted to simple types that don't require complex backend duplication.
844
+ */
845
+ type PropertyAttribute = TextAttribute | NumberAttribute | CheckboxAttribute | DateAttribute | PhoneAttribute | CurrencyAttribute | StatusAttribute | SelectAttribute | MultiselectAttribute | LocationAttribute;
846
+ /**
847
+ * Schema defining properties for a qualified relation.
848
+ *
849
+ * Uses the same Attribute types as object attributes, enabling DRY builders:
850
+ *
851
+ * @example
852
+ * ```typescript
853
+ * relation({ name: "companies", label: "Companies" })
854
+ * .to("companies").many()
855
+ * .qualifyWith(
856
+ * select({ name: "role", label: "Role" }).options([...]).required(),
857
+ * number({ name: "shares", label: "Shares" }).min(0),
858
+ * )
859
+ * ```
860
+ */
861
+ interface PropertySchema {
862
+ definitions: PropertyAttribute[];
863
+ }
864
+ /**
865
+ * Normalizes an attribute's `properties` field to a flat list of
866
+ * {@link PropertyAttribute}. Handles both the production {@link PropertySchema}
867
+ * shape (`{ definitions: [...] }`) and the raw-array shape used in test
868
+ * fixtures (`PropertyAttribute[]`).
869
+ */
870
+ declare function resolvePropertyDefinitions(attr: unknown): PropertyAttribute[];
871
+ /**
872
+ * Property attribute types that have an `options` array.
873
+ */
874
+ type OptionPropertyAttribute = SelectAttribute | StatusAttribute | MultiselectAttribute;
875
+ /**
876
+ * Type guard to check if a property attribute has options.
877
+ *
878
+ * @param attr - The property attribute to check
879
+ * @returns true if the attribute is a select, status, or multiselect type with options
880
+ *
881
+ * @example
882
+ * ```typescript
883
+ * for (const def of definitions) {
884
+ * if (hasOptions(def)) {
885
+ * // TypeScript knows def.options exists and is Option[]
886
+ * for (const option of def.options) {
887
+ * console.log(option.value);
888
+ * }
889
+ * }
890
+ * }
891
+ * ```
892
+ */
893
+ declare function hasOptions(attr: PropertyAttribute): attr is OptionPropertyAttribute;
894
+
895
+ declare const ATTRIBUTE_TYPES: readonly ["text", "richtext", "number", "checkbox", "date", "phone", "currency", "status", "location", "select", "multiselect", "user", "relation", "formula", "rollup", "document"];
896
+ type AttributeType = (typeof ATTRIBUTE_TYPES)[number];
897
+ /**
898
+ * Status group categorization
899
+ */
900
+ type StatusGroup = "idle" | "in_progress" | "finished";
901
+ /**
902
+ * Unified option type for select-like fields
903
+ */
904
+ interface Option {
905
+ value: string;
906
+ label: string;
907
+ color?: ColorId;
908
+ description?: string;
909
+ group?: StatusGroup;
910
+ /** Value of the inverse option for bilateral relations (e.g. "parent" → "child") */
911
+ inverse?: string;
912
+ archived?: boolean;
913
+ }
914
+ /**
915
+ * Attribute grouping for UI organization
916
+ */
917
+ interface AttributeGroup {
918
+ id: string;
919
+ label: string;
920
+ description?: string;
921
+ attributeIds: string[];
922
+ collapsible?: boolean;
923
+ collapsed?: boolean;
924
+ order?: number;
925
+ }
926
+ interface BaseAttribute<DefaultValueType = unknown> {
927
+ id?: Uuid;
928
+ objectId?: Uuid;
929
+ name: string;
930
+ label: string;
931
+ type: AttributeType;
932
+ required?: boolean;
933
+ placeholder?: string;
934
+ description?: string;
935
+ defaultValue?: DefaultValueType;
936
+ icon?: IconName;
937
+ order?: number;
938
+ hidden?: boolean;
939
+ archived?: boolean;
940
+ deprecated?: boolean;
941
+ system?: boolean;
942
+ unique?: boolean;
943
+ metadata?: Record<string, unknown>;
944
+ }
945
+ interface TextAttribute extends BaseAttribute<string> {
946
+ type: "text";
947
+ multiline?: boolean;
948
+ minLength?: number;
949
+ maxLength?: number;
950
+ pattern?: string;
951
+ format?: "email" | "url" | "slug";
952
+ }
953
+ type NumberUnit = "integer" | "decimal" | "percentage";
954
+ interface NumberAttribute extends BaseAttribute<number> {
955
+ type: "number";
956
+ min?: number;
957
+ max?: number;
958
+ unit?: NumberUnit;
959
+ decimals?: number;
960
+ renderAs?: "number" | "rating";
961
+ }
962
+ interface CheckboxAttribute extends BaseAttribute<boolean> {
963
+ type: "checkbox";
964
+ }
965
+ type DateFormat = "short" | "long" | "full" | "relative";
966
+ type DateValue = string | "today";
967
+ type TimeFormat = "12h" | "24h";
968
+ /** Stored value of a date attribute configured with `.endDate()`. */
969
+ interface DateRangeValue {
970
+ start: string;
971
+ end: string | null;
972
+ }
973
+ interface DateAttribute extends BaseAttribute<string | DateRangeValue> {
974
+ type: "date";
975
+ dateFormat?: DateFormat;
976
+ minDate?: DateValue;
977
+ maxDate?: DateValue;
978
+ /** Values carry a time component; stored as full ISO UTC datetimes. */
979
+ includeTime?: boolean;
980
+ /** Values are ranges stored as { start, end } objects. */
981
+ endDate?: boolean;
982
+ /** Display format for the time component. Defaults to "24h". */
983
+ timeFormat?: TimeFormat;
984
+ }
985
+ interface Phone {
986
+ countryCode: CountryIso3;
987
+ phoneNumber: string;
988
+ }
989
+ interface PhoneAttribute extends BaseAttribute<Phone> {
990
+ type: "phone";
991
+ defaultCountryCode?: CountryIso3;
992
+ }
993
+ interface Currency {
994
+ code: CurrencyCode;
995
+ value: number;
996
+ }
997
+ interface CurrencyAttribute extends BaseAttribute<Currency> {
998
+ type: "currency";
999
+ defaultCurrency?: CurrencyCode;
1000
+ allowedCurrencies?: CurrencyCode[];
1001
+ /** Allow negative currency values (e.g. refunds, credits). Defaults to false. */
1002
+ allowNegative?: boolean;
1003
+ }
1004
+ /**
1005
+ * StatusAttribute - For workflow states with semantic grouping (idle/in_progress/finished)
1006
+ * Use this for: Task status, Order status, Project phases, Process states
1007
+ * Use SelectAttribute for: Categories, Types, simple choices without workflow
1008
+ */
1009
+ interface StatusAttribute extends BaseAttribute<string> {
1010
+ type: "status";
1011
+ options: Option[];
1012
+ }
1013
+ interface Location {
1014
+ address?: string;
1015
+ address2?: string;
1016
+ city?: string;
1017
+ state?: string;
1018
+ postalCode?: string;
1019
+ country?: CountryIso3;
1020
+ latitude?: number;
1021
+ longitude?: number;
1022
+ }
1023
+ type LocationGranularity = "full" | "address" | "city" | "state" | "country" | "coordinates";
1024
+ interface LocationAttribute extends BaseAttribute<Location> {
1025
+ type: "location";
1026
+ granularity?: LocationGranularity;
1027
+ defaultCountry?: CountryIso3;
1028
+ allowedCountries?: CountryIso3[];
1029
+ }
1030
+ /**
1031
+ * SelectAttribute - For simple single-choice selection
1032
+ * Use this for: Categories, Document types, Departments, Priorities
1033
+ * Options can be grouped (e.g., countries by continent) but no workflow logic
1034
+ */
1035
+ interface SelectAttribute extends BaseAttribute<string> {
1036
+ type: "select";
1037
+ options: Option[];
1038
+ renderAs?: "badges";
1039
+ }
1040
+ interface MultiselectAttribute extends BaseAttribute<string[]> {
1041
+ type: "multiselect";
1042
+ options: Option[];
1043
+ renderAs?: "badges";
1044
+ }
1045
+ type UserReferenceType = "user" | "agent";
1046
+ interface UserAttribute extends BaseAttribute<string | string[]> {
1047
+ type: "user";
1048
+ types?: UserReferenceType[];
1049
+ multiple?: boolean;
1050
+ }
1051
+ /**
1052
+ * Wildcard marker for universal relations (can link to any object)
1053
+ * Use with `.toAny()` builder method
1054
+ */
1055
+ declare const RELATION_TARGET_ANY: "*";
1056
+ /**
1057
+ * Configuration for bilateral synchronization (bidirectional relations)
1058
+ */
1059
+ interface BilateralConfig {
1060
+ /** Target object containing the inverse attribute */
1061
+ object: string;
1062
+ /** Name of the inverse attribute */
1063
+ attribute: string;
1064
+ /** Optional cardinality override (inferred by default) */
1065
+ cardinality?: "one" | "many";
1066
+ /** When true, this side owns the storage direction for qualified properties.
1067
+ * Set to false on the inverse side (enriched at read time). */
1068
+ storageOwner?: boolean;
1069
+ }
1070
+ /**
1071
+ * Target object for a relation - defines which objects can be linked
1072
+ */
1073
+ interface RelationTarget {
1074
+ /** Object name (e.g., "companies", "contacts") or "*" for any object */
1075
+ object: string;
1076
+ /**
1077
+ * Display template for the label using mustache-like syntax
1078
+ * @example "{name}" or "{firstName} {lastName} — {email}"
1079
+ */
1080
+ displayTemplate?: string;
1081
+ /**
1082
+ * Optional filter to restrict available records
1083
+ * @example { status: "active" }
1084
+ */
1085
+ filter?: Record<string, unknown>;
1086
+ }
1087
+ /**
1088
+ * Base properties shared by both single and multi relation attributes
1089
+ *
1090
+ * Note: Deletion behavior is always "restrict" - if a record is referenced
1091
+ * by other records, it cannot be deleted until those references are removed.
1092
+ * This is enforced by RecordService.deleteRecord() which throws
1093
+ * RecordReferencedError when attempting to delete a referenced record.
1094
+ */
1095
+ interface RelationAttributeBase extends Omit<BaseAttribute<unknown>, "defaultValue"> {
1096
+ type: "relation";
1097
+ /** Target objects that can be linked */
1098
+ targets: RelationTarget[];
1099
+ /** Optional properties schema for qualified relations */
1100
+ properties?: PropertySchema;
1101
+ /** Configuration for bilateral synchronization (opt-in) */
1102
+ bilateral?: BilateralConfig;
1103
+ }
1104
+ /**
1105
+ * Single relation attribute (one-to-one or many-to-one)
1106
+ * Stores a single record ID or null
1107
+ */
1108
+ interface SingleRelationAttribute extends RelationAttributeBase {
1109
+ cardinality: "one";
1110
+ defaultValue?: string | null;
1111
+ }
1112
+ /**
1113
+ * Multi relation attribute (one-to-many or many-to-many)
1114
+ * Stores an array of record IDs
1115
+ */
1116
+ interface MultiRelationAttribute extends RelationAttributeBase {
1117
+ cardinality: "many";
1118
+ defaultValue?: string[];
1119
+ /** Maximum number of relations allowed */
1120
+ maxItems?: number;
1121
+ }
1122
+ /**
1123
+ * RelationAttribute links to other objects/records
1124
+ * Discriminated union by cardinality for type-safe value handling
1125
+ *
1126
+ * @example Single relation (many-to-one)
1127
+ * ```typescript
1128
+ * relation({ name: "company", label: "Company" })
1129
+ * .to("companies")
1130
+ * .required()
1131
+ * // → Value: "rec-uuid-123" | null
1132
+ * ```
1133
+ *
1134
+ * @example Multi relation (many-to-many)
1135
+ * ```typescript
1136
+ * relation({ name: "contacts", label: "Contacts" })
1137
+ * .to("contacts", { displayTemplate: "{firstName} {lastName}" })
1138
+ * .many()
1139
+ * .maxItems(5)
1140
+ * // → Value: ["rec-1", "rec-2", ...]
1141
+ * ```
1142
+ *
1143
+ * @example Polymorphic relation (multiple target objects)
1144
+ * ```typescript
1145
+ * relation({ name: "linked", label: "Linked Items" })
1146
+ * .to("companies")
1147
+ * .to("contacts")
1148
+ * .to("deals")
1149
+ * .many()
1150
+ * // → Can link to records from any of these objects
1151
+ * ```
1152
+ */
1153
+ type RelationAttribute = SingleRelationAttribute | MultiRelationAttribute;
1154
+ /**
1155
+ * Check if a relation attribute is universal (can link to any object)
1156
+ * Universal relations have `targets: [{ object: "*" }]`
1157
+ */
1158
+ /**
1159
+ * The object names a relation attribute can point at, universal marker
1160
+ * stripped. Any other attribute type — and a relation row whose config lost
1161
+ * its `targets` — yields no names.
1162
+ */
1163
+ declare function relationTargetsOf(attribute: Attribute): string[];
1164
+ declare function isUniversalRelation(attr: RelationAttribute): boolean;
1165
+ /**
1166
+ * Check if a relation attribute has bilateral synchronization enabled
1167
+ */
1168
+ declare function isBilateralRelation(attr: RelationAttribute): attr is RelationAttribute & {
1169
+ bilateral: BilateralConfig;
1170
+ };
1171
+ /**
1172
+ * Infer the cardinality of the inverse relation
1173
+ * - one → many (contact.company ↔ company.contacts)
1174
+ * - many → many (contact.tags ↔ tag.contacts)
1175
+ */
1176
+ declare function inferInverseCardinality(cardinality: "one" | "many"): "one" | "many";
1177
+ /**
1178
+ * RichtextAttribute - Rich text content using semantic markdown
1179
+ *
1180
+ * Stores content as semantic markdown string (with directives like :::callout).
1181
+ * Parsed at runtime to Tiptap JSON for editing.
1182
+ * Use this for: Notes, articles, descriptions, long-form content.
1183
+ *
1184
+ * @example
1185
+ * ```typescript
1186
+ * richtext({ name: "content", label: "Content" }).required()
1187
+ * ```
1188
+ */
1189
+ interface RichtextAttribute extends BaseAttribute<string> {
1190
+ type: "richtext";
1191
+ }
1192
+ type RichTextAttribute = RichtextAttribute;
1193
+ /**
1194
+ * Return type for formula expressions
1195
+ */
1196
+ type FormulaReturnType = ComputedReturnType;
1197
+ /**
1198
+ * FormulaAttribute - Computed value based on other attributes
1199
+ *
1200
+ * Formulas are calculated at read-time and are always read-only.
1201
+ * Users cannot directly edit formula values.
1202
+ *
1203
+ * @example Simple calculation
1204
+ * ```typescript
1205
+ * formula({ name: "total", label: "Total" })
1206
+ * .expression("price * quantity")
1207
+ * .returns("number")
1208
+ * .decimals(2)
1209
+ * ```
1210
+ *
1211
+ * @example With functions
1212
+ * ```typescript
1213
+ * formula({ name: "fullName", label: "Full Name" })
1214
+ * .expression("CONCAT(firstName, ' ', lastName)")
1215
+ * .returns("text")
1216
+ * ```
1217
+ */
1218
+ interface FormulaAttribute extends Omit<BaseAttribute<never>, "defaultValue" | "required"> {
1219
+ type: "formula";
1220
+ /** Expression to evaluate (e.g., "price * quantity") */
1221
+ expression: string;
1222
+ /** Expected return type for formatting */
1223
+ returnType: FormulaReturnType;
1224
+ /** Decimal places for number results */
1225
+ decimals?: number;
1226
+ /** Source attribute for select-like computed options */
1227
+ optionsSource?: ComputedOptionsSource;
1228
+ /** Whether to allow relation references in the expression (e.g., "company.name") */
1229
+ allowRelations?: boolean;
1230
+ /** Formula is always not required (read-only) */
1231
+ required: false;
1232
+ }
1233
+ /**
1234
+ * Aggregation functions for rollup attributes
1235
+ *
1236
+ * Categories:
1237
+ * - Numeric (sum, avg): Only for number and currency types
1238
+ * - Date (earliest, latest): Only for date type
1239
+ * - Count (count, countValues, countUniqueValues, countEmpty): Universal
1240
+ * - Percent (percentEmpty, percentNotEmpty): Universal
1241
+ * - Lookup (original): Returns all values as array, rendered as target type
1242
+ */
1243
+ type RollupFunction = "sum" | "avg" | "earliest" | "latest" | "count" | "countValues" | "countUniqueValues" | "countEmpty" | "percentEmpty" | "percentNotEmpty" | "original";
1244
+ /**
1245
+ * RollupAttribute - Aggregates values from related records
1246
+ *
1247
+ * Rollups are calculated and stored (denormalized) for performance.
1248
+ * They are automatically recalculated when related records change.
1249
+ * Users cannot directly edit rollup values.
1250
+ *
1251
+ * @example Sum of related amounts
1252
+ * ```typescript
1253
+ * rollup({ name: "totalOrders", label: "Total Orders" })
1254
+ * .from("orders") // relation attribute name
1255
+ * .aggregate("amount") // target attribute to sum
1256
+ * .using("sum")
1257
+ * .decimals(2)
1258
+ * ```
1259
+ *
1260
+ * @example Count of related records
1261
+ * ```typescript
1262
+ * rollup({ name: "orderCount", label: "Number of Orders" })
1263
+ * .from("orders")
1264
+ * .using("count")
1265
+ * ```
1266
+ */
1267
+ interface RollupAttribute extends Omit<BaseAttribute<never>, "defaultValue" | "required"> {
1268
+ type: "rollup";
1269
+ /** Name of the relation attribute on this object */
1270
+ relationAttribute: string;
1271
+ /**
1272
+ * Dot notation path for multi-level traversal (Phase 4+)
1273
+ * @example "orders.items" - traverse through orders to items
1274
+ */
1275
+ relationPath?: string;
1276
+ /** Attribute name on the target object to aggregate */
1277
+ targetAttribute: string;
1278
+ /** Aggregation function to apply */
1279
+ function: RollupFunction;
1280
+ /** Decimal places for numeric results */
1281
+ decimals?: number;
1282
+ /** Rollup is always not required (read-only) */
1283
+ required: false;
1284
+ /**
1285
+ * Cached type of the target attribute for display purposes
1286
+ * Used when function="original" to render values as the target type
1287
+ */
1288
+ targetAttributeType?: AttributeType;
1289
+ /**
1290
+ * Cached currency code of a currency target, from its `defaultCurrency`
1291
+ * (#2644). The stored rollup value stays a bare number; this is the
1292
+ * schema-derived channel that lets a single-code sum/avg render with its
1293
+ * symbol. Absent → the value renders bare, exactly as before.
1294
+ *
1295
+ * Named for what it holds — an ISO 4217 CODE — rather than the siblings'
1296
+ * `targetAttribute*` prefix: `targetAttributeCurrency` would read as a
1297
+ * `Currency` value, which this deliberately is not.
1298
+ */
1299
+ targetCurrencyCode?: CurrencyCode;
1300
+ /**
1301
+ * Cached options from target attribute (for select/status/multiselect display)
1302
+ * Required when function="original" and target is a select-like type
1303
+ */
1304
+ targetAttributeOptions?: Option[];
1305
+ /** Source attribute for select-like computed options */
1306
+ optionsSource?: ComputedOptionsSource;
1307
+ }
1308
+ /**
1309
+ * DocumentAttribute - References structured documents.
1310
+ *
1311
+ * A DocumentAttribute references packs of anonymous files with typed edge
1312
+ * properties.
1313
+ *
1314
+ * Every document attribute is multi by construction — the underlying storage
1315
+ * (documents + files) supports 1 Doc → N files uniformly.
1316
+ *
1317
+ * @example
1318
+ * ```typescript
1319
+ * document({ name: "contracts", label: "Contrats" })
1320
+ * .accepts(["application/pdf"])
1321
+ * ```
1322
+ */
1323
+ interface DocumentAttribute extends BaseAttribute<string[]> {
1324
+ type: "document";
1325
+ /**
1326
+ * Schema for typed properties on the record→document edge.
1327
+ * Symmetric with `RelationAttribute.properties`; populated by `.qualifyWith(...)`.
1328
+ * Stored on `record_reference_edges.properties`, not on the document itself.
1329
+ */
1330
+ properties?: PropertySchema;
1331
+ /** MIME prefixes/globs (e.g. "image/*", "application/pdf") applied to every file of the pack. */
1332
+ accepts?: string[];
1333
+ /** Hard ceiling in bytes applied to every file of the pack. */
1334
+ maxFileSize?: number;
1335
+ }
1336
+ /**
1337
+ * Union of every attribute definition supported by Standards objects.
1338
+ *
1339
+ * Use this type when code needs to inspect or render attributes generically
1340
+ * across primitive, relation, computed, user, and document fields.
1341
+ */
1342
+ type Attribute = TextAttribute | RichtextAttribute | NumberAttribute | CheckboxAttribute | DateAttribute | PhoneAttribute | CurrencyAttribute | StatusAttribute | LocationAttribute | SelectAttribute | MultiselectAttribute | UserAttribute | RelationAttribute | FormulaAttribute | RollupAttribute | DocumentAttribute;
1343
+ /**
1344
+ * Check if an attribute supports sorting based on its type.
1345
+ */
1346
+ declare function isAttributeSortable(attr: {
1347
+ type: AttributeType;
1348
+ }): boolean;
1349
+
1350
+ export { type ComputedFieldKind as $, type Attribute as A, type BilateralConfig as B, type CheckboxAttribute as C, type DateAttribute as D, type RelationTarget as E, type FormulaAttribute as F, type RollupFunction as G, type UserReferenceType as H, ATTRIBUTE_TYPES as I, AccessDeniedError as J, type AttributeGroup as K, type LocationAttribute as L, type MultiselectAttribute as M, type NumberAttribute as N, type Option as O, type PhoneAttribute as P, AttributeInUseError as Q, type RichtextAttribute as R, type SelectAttribute as S, type TextAttribute as T, type UserAttribute as U, ValidationError as V, AttributeNotFoundError as W, type AttributeUsage as X, type BaseAttribute as Y, type BuiltInTransform as Z, ChangeTypeNotSupportedError as _, type CurrencyAttribute as a, isSchemaError as a$, type ComputedFormulaBinaryNode as a0, type ComputedFormulaBinaryOperator as a1, type ComputedFormulaCallNode as a2, type ComputedFormulaLiteralNode as a3, ComputedFormulaParseError as a4, type ComputedFormulaPathNode as a5, ConcurrentModificationError as a6, type DateFormat as a7, type DateValue as a8, DestructiveSyncNotAllowedError as a9, type SchemaOperation as aA, SchemaPlanNotFoundError as aB, SearchBackendError as aC, type StatusGroup as aD, StorageError as aE, type StorageOperation as aF, SyncCascadeError as aG, SyncConflictError as aH, SyncError as aI, SystemEntityImmutableError as aJ, type UserId as aK, type ValidationErrorDetail as aL, asTenantId as aM, asUserId as aN, canonicalStringify as aO, deepEqual as aP, generateId as aQ, hasOptions as aR, indexBy as aS, inferInverseCardinality as aT, isAttributeInUseError as aU, isAttributeSortable as aV, isBilateralRelation as aW, isNotFoundError as aX, isObjectReferencedError as aY, isProtectedResourceError as aZ, isRecordReferencedError as a_, DuplicateError as aa, ForbiddenError as ab, MemoryNotFoundError as ac, MigrationTimeoutError as ad, NonJsonValueError as ae, NotFoundError as af, NotImplementedError as ag, type NumberUnit as ah, ObjectNotFoundError as ai, ObjectReferencedError as aj, type OptionPropertyAttribute as ak, OrphanSystemAttributeError as al, type PropertyType as am, ProtectedResourceError as an, ProtectedRoleError as ao, RELATION_TARGET_ANY as ap, RecordNotFoundError as aq, type RecordReference as ar, RecordReferencedError as as, RepositoryError as at, type RepositoryOperation as au, ReservedObjectNameError as av, type RichTextAttribute as aw, RoleNotFoundError as ax, SchemaError as ay, SchemaErrorCode as az, type StatusAttribute as b, isUniversalRelation as b0, isValidationError as b1, parseComputedFormula as b2, relationTargetsOf as b3, resolvePropertyDefinitions as b4, sameStableValue as b5, serializeCanonicalJson as b6, serializeStableJson as b7, type MultiRelationAttribute as c, type RelationAttribute as d, type SingleRelationAttribute as e, type RollupAttribute as f, type Uuid as g, type MigrationDefinition as h, type ComputedValueType as i, type ComputedReturnType as j, type AttributeType as k, type ComputedOptionsSource as l, type ComputedDependency as m, type ComputedPlan as n, type ComputedFormulaAstNode as o, type TenantId as p, type LocationGranularity as q, type Location as r, type DateRangeValue as s, type DocumentAttribute as t, type Phone as u, type Currency as v, type PropertySchema as w, type TimeFormat as x, type PropertyAttribute as y, type FormulaReturnType as z };