@stndrds/schema 1.0.0-alpha.329 → 1.0.0-alpha.331

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