@nicia-ai/typegraph 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +23 -0
- package/dist/{ast-BVyihVbP.d.cts → ast-CXFx6bF6.d.ts} +45 -165
- package/dist/{ast-BVyihVbP.d.ts → ast-D-3bOanX.d.cts} +45 -165
- package/dist/backend/drizzle/index.cjs +20 -20
- package/dist/backend/drizzle/index.d.cts +6 -5
- package/dist/backend/drizzle/index.d.ts +6 -5
- package/dist/backend/drizzle/index.js +8 -8
- package/dist/backend/drizzle/postgres.cjs +9 -9
- package/dist/backend/drizzle/postgres.d.cts +9 -11
- package/dist/backend/drizzle/postgres.d.ts +9 -11
- package/dist/backend/drizzle/postgres.js +6 -6
- package/dist/backend/drizzle/schema/postgres.cjs +10 -10
- package/dist/backend/drizzle/schema/postgres.d.cts +6 -5
- package/dist/backend/drizzle/schema/postgres.d.ts +6 -5
- package/dist/backend/drizzle/schema/postgres.js +3 -3
- package/dist/backend/drizzle/schema/sqlite.cjs +10 -10
- package/dist/backend/drizzle/schema/sqlite.d.cts +6 -5
- package/dist/backend/drizzle/schema/sqlite.d.ts +6 -5
- package/dist/backend/drizzle/schema/sqlite.js +3 -3
- package/dist/backend/drizzle/sqlite.cjs +9 -9
- package/dist/backend/drizzle/sqlite.d.cts +17 -18
- package/dist/backend/drizzle/sqlite.d.ts +17 -18
- package/dist/backend/drizzle/sqlite.js +6 -6
- package/dist/backend/postgres/index.cjs +21 -17
- package/dist/backend/postgres/index.d.cts +8 -7
- package/dist/backend/postgres/index.d.ts +8 -7
- package/dist/backend/postgres/index.js +8 -8
- package/dist/backend/sqlite/index.cjs +27 -21
- package/dist/backend/sqlite/index.cjs.map +1 -1
- package/dist/backend/sqlite/index.d.cts +7 -6
- package/dist/backend/sqlite/index.d.ts +7 -6
- package/dist/backend/sqlite/index.js +18 -12
- package/dist/backend/sqlite/index.js.map +1 -1
- package/dist/{chunk-YM5AL65Y.cjs → chunk-2WVFEIHR.cjs} +29 -3
- package/dist/chunk-2WVFEIHR.cjs.map +1 -0
- package/dist/{chunk-4PIEL2VO.js → chunk-3PURVEA4.js} +36 -5
- package/dist/chunk-3PURVEA4.js.map +1 -0
- package/dist/chunk-4HARSV2G.js +1448 -0
- package/dist/chunk-4HARSV2G.js.map +1 -0
- package/dist/{chunk-IIAT36MI.js → chunk-54WJF3DW.js} +29 -3
- package/dist/chunk-54WJF3DW.js.map +1 -0
- package/dist/chunk-CMHFS34N.cjs +390 -0
- package/dist/chunk-CMHFS34N.cjs.map +1 -0
- package/dist/chunk-DD6ONEBN.cjs +1264 -0
- package/dist/chunk-DD6ONEBN.cjs.map +1 -0
- package/dist/chunk-F2BZSEFE.js +388 -0
- package/dist/chunk-F2BZSEFE.js.map +1 -0
- package/dist/{chunk-DDM2FZRJ.cjs → chunk-JQDWEX6V.cjs} +24 -24
- package/dist/{chunk-DDM2FZRJ.cjs.map → chunk-JQDWEX6V.cjs.map} +1 -1
- package/dist/chunk-NP4G4ZKM.js +1228 -0
- package/dist/chunk-NP4G4ZKM.js.map +1 -0
- package/dist/{chunk-UJAGXJDG.cjs → chunk-NU2XNMVI.cjs} +38 -7
- package/dist/chunk-NU2XNMVI.cjs.map +1 -0
- package/dist/{chunk-JKTO7TW3.js → chunk-O5XPCJLF.js} +25 -3
- package/dist/chunk-O5XPCJLF.js.map +1 -0
- package/dist/{chunk-2QHQ2C4P.js → chunk-OGGLFYFA.js} +36 -5
- package/dist/chunk-OGGLFYFA.js.map +1 -0
- package/dist/{chunk-SV5H3XM5.cjs → chunk-OYL2SGBD.cjs} +26 -2
- package/dist/chunk-OYL2SGBD.cjs.map +1 -0
- package/dist/chunk-SFY2PPOY.cjs +1469 -0
- package/dist/chunk-SFY2PPOY.cjs.map +1 -0
- package/dist/{chunk-JDAET5LO.js → chunk-SMLIWLS7.js} +9 -9
- package/dist/chunk-SMLIWLS7.js.map +1 -0
- package/dist/{chunk-VXRVGFCI.js → chunk-U3452TEU.js} +17 -17
- package/dist/{chunk-VXRVGFCI.js.map → chunk-U3452TEU.js.map} +1 -1
- package/dist/{chunk-MNO33ASC.cjs → chunk-UYMT4LO2.cjs} +9 -8
- package/dist/chunk-UYMT4LO2.cjs.map +1 -0
- package/dist/chunk-V7CS2MDB.cjs +289 -0
- package/dist/chunk-V7CS2MDB.cjs.map +1 -0
- package/dist/chunk-WE5BKYNB.js +287 -0
- package/dist/chunk-WE5BKYNB.js.map +1 -0
- package/dist/{chunk-L642L24T.js → chunk-XDTYTNYL.js} +14 -21
- package/dist/chunk-XDTYTNYL.js.map +1 -0
- package/dist/{chunk-N4AOJ3VF.cjs → chunk-XZL6MCZJ.cjs} +38 -7
- package/dist/chunk-XZL6MCZJ.cjs.map +1 -0
- package/dist/{chunk-DBFCKELK.cjs → chunk-ZJHQZZT2.cjs} +18 -27
- package/dist/chunk-ZJHQZZT2.cjs.map +1 -0
- package/dist/index-Dkicw49A.d.cts +373 -0
- package/dist/index-Dkicw49A.d.ts +373 -0
- package/dist/index.cjs +5915 -3377
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +24 -664
- package/dist/index.d.ts +24 -664
- package/dist/index.js +5781 -3223
- package/dist/index.js.map +1 -1
- package/dist/indexes/index.cjs +16 -16
- package/dist/indexes/index.d.cts +5 -4
- package/dist/indexes/index.d.ts +5 -4
- package/dist/indexes/index.js +2 -2
- package/dist/interchange/index.cjs +9 -9
- package/dist/interchange/index.cjs.map +1 -1
- package/dist/interchange/index.d.cts +5 -3
- package/dist/interchange/index.d.ts +5 -3
- package/dist/interchange/index.js +8 -8
- package/dist/interchange/index.js.map +1 -1
- package/dist/manager-Jc5Btay9.d.cts +493 -0
- package/dist/manager-e9LXthrx.d.ts +493 -0
- package/dist/profiler/index.cjs +2 -8
- package/dist/profiler/index.cjs.map +1 -1
- package/dist/profiler/index.d.cts +9 -161
- package/dist/profiler/index.d.ts +9 -161
- package/dist/profiler/index.js +4 -4
- package/dist/profiler/index.js.map +1 -1
- package/dist/schema/index.cjs +145 -0
- package/dist/schema/index.cjs.map +1 -0
- package/dist/schema/index.d.cts +237 -0
- package/dist/schema/index.d.ts +237 -0
- package/dist/schema/index.js +72 -0
- package/dist/schema/index.js.map +1 -0
- package/dist/{store-BPhjw5S8.d.ts → store-DM3Tk3Pw.d.ts} +874 -1283
- package/dist/{store-DNOOQEm8.d.cts → store-nbBybLWP.d.cts} +874 -1283
- package/dist/{test-helpers-BjyRYJZX.d.ts → test-helpers-CIq1Hhj1.d.ts} +5 -1
- package/dist/{test-helpers-NoQXhleQ.d.cts → test-helpers-DPRFVky4.d.cts} +5 -1
- package/dist/{types-D_3mEv2y.d.ts → types-BL1GyVku.d.cts} +2 -2
- package/dist/{types-DsRfx0yk.d.ts → types-Cdbi4hcx.d.ts} +228 -4
- package/dist/{types-BrSfFSpW.d.cts → types-DCGa53O2.d.ts} +2 -2
- package/dist/{types-aapj0GLz.d.cts → types-DDP0MGBF.d.cts} +228 -4
- package/dist/{types-CX4cLd7M.d.ts → types-DHRsi6j9.d.cts} +4 -3
- package/dist/types-DTJEu_-h.d.cts +158 -0
- package/dist/types-DTJEu_-h.d.ts +158 -0
- package/dist/{types-a5rAxC92.d.cts → types-ZT5mlism.d.ts} +4 -3
- package/package.json +17 -2
- package/dist/chunk-2FURVVAX.cjs +0 -350
- package/dist/chunk-2FURVVAX.cjs.map +0 -1
- package/dist/chunk-2QHQ2C4P.js.map +0 -1
- package/dist/chunk-4PIEL2VO.js.map +0 -1
- package/dist/chunk-DBFCKELK.cjs.map +0 -1
- package/dist/chunk-H7THXVH6.cjs +0 -314
- package/dist/chunk-H7THXVH6.cjs.map +0 -1
- package/dist/chunk-HXAPXPZH.cjs +0 -680
- package/dist/chunk-HXAPXPZH.cjs.map +0 -1
- package/dist/chunk-IIAT36MI.js.map +0 -1
- package/dist/chunk-JDAET5LO.js.map +0 -1
- package/dist/chunk-JKTO7TW3.js.map +0 -1
- package/dist/chunk-L642L24T.js.map +0 -1
- package/dist/chunk-MNO33ASC.cjs.map +0 -1
- package/dist/chunk-N4AOJ3VF.cjs.map +0 -1
- package/dist/chunk-QB3WBMDT.js +0 -646
- package/dist/chunk-QB3WBMDT.js.map +0 -1
- package/dist/chunk-SV5H3XM5.cjs.map +0 -1
- package/dist/chunk-UJAGXJDG.cjs.map +0 -1
- package/dist/chunk-X4EVMBON.js +0 -312
- package/dist/chunk-X4EVMBON.js.map +0 -1
- package/dist/chunk-XZL4NLV6.js +0 -348
- package/dist/chunk-XZL4NLV6.js.map +0 -1
- package/dist/chunk-YM5AL65Y.cjs.map +0 -1
|
@@ -0,0 +1,373 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TypeGraph Error Hierarchy
|
|
3
|
+
*
|
|
4
|
+
* All errors extend TypeGraphError with:
|
|
5
|
+
* - `code`: Machine-readable error code for programmatic handling
|
|
6
|
+
* - `category`: Classification for error handling strategies
|
|
7
|
+
* - `suggestion`: Optional recovery guidance for users
|
|
8
|
+
* - `details`: Structured context about the error
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* try {
|
|
13
|
+
* await store.nodes.Person.create({ name: "" });
|
|
14
|
+
* } catch (error) {
|
|
15
|
+
* if (isTypeGraphError(error)) {
|
|
16
|
+
* console.error(error.toUserMessage());
|
|
17
|
+
* if (isUserRecoverable(error)) {
|
|
18
|
+
* // Show to user for correction
|
|
19
|
+
* }
|
|
20
|
+
* }
|
|
21
|
+
* }
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
/**
|
|
25
|
+
* Error category for programmatic handling.
|
|
26
|
+
*
|
|
27
|
+
* - `user`: Caused by invalid input or incorrect usage. Recoverable by fixing input.
|
|
28
|
+
* - `constraint`: Business rule or schema constraint violation. Recoverable by changing data.
|
|
29
|
+
* - `system`: Internal error or infrastructure issue. May require investigation or retry.
|
|
30
|
+
*/
|
|
31
|
+
type ErrorCategory = "user" | "constraint" | "system";
|
|
32
|
+
/**
|
|
33
|
+
* Options for TypeGraphError constructor.
|
|
34
|
+
*/
|
|
35
|
+
type TypeGraphErrorOptions = Readonly<{
|
|
36
|
+
/** Structured context about the error */
|
|
37
|
+
details?: Record<string, unknown>;
|
|
38
|
+
/** Error category for handling strategies */
|
|
39
|
+
category: ErrorCategory;
|
|
40
|
+
/** Recovery guidance for users */
|
|
41
|
+
suggestion?: string;
|
|
42
|
+
/** Underlying cause of the error */
|
|
43
|
+
cause?: unknown;
|
|
44
|
+
}>;
|
|
45
|
+
/**
|
|
46
|
+
* Base error class for all TypeGraph errors.
|
|
47
|
+
*
|
|
48
|
+
* Provides structured error information for both programmatic handling
|
|
49
|
+
* and user-friendly messages.
|
|
50
|
+
*/
|
|
51
|
+
declare class TypeGraphError extends Error {
|
|
52
|
+
/** Machine-readable error code (e.g., "VALIDATION_ERROR") */
|
|
53
|
+
readonly code: string;
|
|
54
|
+
/** Error category for handling strategies */
|
|
55
|
+
readonly category: ErrorCategory;
|
|
56
|
+
/** Structured context about the error */
|
|
57
|
+
readonly details: Readonly<Record<string, unknown>>;
|
|
58
|
+
/** Recovery guidance for users */
|
|
59
|
+
readonly suggestion?: string;
|
|
60
|
+
constructor(message: string, code: string, options: TypeGraphErrorOptions);
|
|
61
|
+
/**
|
|
62
|
+
* Returns a user-friendly error message with suggestion if available.
|
|
63
|
+
*/
|
|
64
|
+
toUserMessage(): string;
|
|
65
|
+
/**
|
|
66
|
+
* Returns a detailed string representation for logging.
|
|
67
|
+
*/
|
|
68
|
+
toLogString(): string;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Validation issue from Zod or custom validation.
|
|
72
|
+
*/
|
|
73
|
+
type ValidationIssue = Readonly<{
|
|
74
|
+
/** Path to the invalid field (e.g., "address.city") */
|
|
75
|
+
path: string;
|
|
76
|
+
/** Human-readable error message */
|
|
77
|
+
message: string;
|
|
78
|
+
/** Zod error code if from Zod validation */
|
|
79
|
+
code?: string;
|
|
80
|
+
}>;
|
|
81
|
+
/**
|
|
82
|
+
* Details for ValidationError.
|
|
83
|
+
*/
|
|
84
|
+
type ValidationErrorDetails = Readonly<{
|
|
85
|
+
/** Type of entity being validated */
|
|
86
|
+
entityType?: "node" | "edge";
|
|
87
|
+
/** Kind/type name of the entity */
|
|
88
|
+
kind?: string;
|
|
89
|
+
/** Operation being performed */
|
|
90
|
+
operation?: "create" | "update";
|
|
91
|
+
/** Entity ID if updating */
|
|
92
|
+
id?: string;
|
|
93
|
+
/** Individual validation issues */
|
|
94
|
+
issues: readonly ValidationIssue[];
|
|
95
|
+
}>;
|
|
96
|
+
/**
|
|
97
|
+
* Thrown when schema validation fails during node or edge operations.
|
|
98
|
+
*
|
|
99
|
+
* @example
|
|
100
|
+
* ```typescript
|
|
101
|
+
* try {
|
|
102
|
+
* await store.nodes.Person.create({ email: "invalid" });
|
|
103
|
+
* } catch (error) {
|
|
104
|
+
* if (error instanceof ValidationError) {
|
|
105
|
+
* console.log(error.details.issues);
|
|
106
|
+
* // [{ path: "email", message: "Invalid email" }]
|
|
107
|
+
* }
|
|
108
|
+
* }
|
|
109
|
+
* ```
|
|
110
|
+
*/
|
|
111
|
+
declare class ValidationError extends TypeGraphError {
|
|
112
|
+
readonly details: ValidationErrorDetails;
|
|
113
|
+
constructor(message: string, details: ValidationErrorDetails, options?: {
|
|
114
|
+
cause?: unknown;
|
|
115
|
+
suggestion?: string;
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Thrown when a node is not found.
|
|
120
|
+
*
|
|
121
|
+
* @example
|
|
122
|
+
* ```typescript
|
|
123
|
+
* try {
|
|
124
|
+
* await store.nodes.Person.get("nonexistent-id");
|
|
125
|
+
* } catch (error) {
|
|
126
|
+
* if (error instanceof NodeNotFoundError) {
|
|
127
|
+
* console.log(error.details.kind, error.details.id);
|
|
128
|
+
* }
|
|
129
|
+
* }
|
|
130
|
+
* ```
|
|
131
|
+
*/
|
|
132
|
+
declare class NodeNotFoundError extends TypeGraphError {
|
|
133
|
+
constructor(kind: string, id: string, options?: {
|
|
134
|
+
cause?: unknown;
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Thrown when an edge is not found.
|
|
139
|
+
*/
|
|
140
|
+
declare class EdgeNotFoundError extends TypeGraphError {
|
|
141
|
+
constructor(kind: string, id: string, options?: {
|
|
142
|
+
cause?: unknown;
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Thrown when a kind is not found in the graph registry.
|
|
147
|
+
*/
|
|
148
|
+
declare class KindNotFoundError extends TypeGraphError {
|
|
149
|
+
constructor(kind: string, type: "node" | "edge", options?: {
|
|
150
|
+
cause?: unknown;
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Thrown when edge endpoint node does not exist or is deleted.
|
|
155
|
+
*/
|
|
156
|
+
declare class EndpointNotFoundError extends TypeGraphError {
|
|
157
|
+
constructor(details: Readonly<{
|
|
158
|
+
edgeKind: string;
|
|
159
|
+
endpoint: "from" | "to";
|
|
160
|
+
nodeKind: string;
|
|
161
|
+
nodeId: string;
|
|
162
|
+
}>, options?: {
|
|
163
|
+
cause?: unknown;
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Thrown when edge endpoint has wrong node type.
|
|
168
|
+
*/
|
|
169
|
+
declare class EndpointError extends TypeGraphError {
|
|
170
|
+
constructor(details: Readonly<{
|
|
171
|
+
edgeKind: string;
|
|
172
|
+
endpoint: "from" | "to";
|
|
173
|
+
actualKind: string;
|
|
174
|
+
expectedKinds: readonly string[];
|
|
175
|
+
}>, options?: {
|
|
176
|
+
cause?: unknown;
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Thrown when uniqueness constraint is violated.
|
|
181
|
+
*/
|
|
182
|
+
declare class UniquenessError extends TypeGraphError {
|
|
183
|
+
constructor(details: Readonly<{
|
|
184
|
+
constraintName: string;
|
|
185
|
+
kind: string;
|
|
186
|
+
existingId: string;
|
|
187
|
+
newId: string;
|
|
188
|
+
fields: readonly string[];
|
|
189
|
+
}>, options?: {
|
|
190
|
+
cause?: unknown;
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Thrown when cardinality constraint is violated.
|
|
195
|
+
*/
|
|
196
|
+
declare class CardinalityError extends TypeGraphError {
|
|
197
|
+
constructor(details: Readonly<{
|
|
198
|
+
edgeKind: string;
|
|
199
|
+
fromKind: string;
|
|
200
|
+
fromId: string;
|
|
201
|
+
cardinality: string;
|
|
202
|
+
existingCount: number;
|
|
203
|
+
}>, options?: {
|
|
204
|
+
cause?: unknown;
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Thrown when disjointness constraint is violated.
|
|
209
|
+
*
|
|
210
|
+
* Disjoint types cannot share the same ID - a node cannot be both
|
|
211
|
+
* a Person and an Organization if they are declared disjoint.
|
|
212
|
+
*/
|
|
213
|
+
declare class DisjointError extends TypeGraphError {
|
|
214
|
+
constructor(details: Readonly<{
|
|
215
|
+
nodeId: string;
|
|
216
|
+
attemptedKind: string;
|
|
217
|
+
conflictingKind: string;
|
|
218
|
+
}>, options?: {
|
|
219
|
+
cause?: unknown;
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Thrown when deletion is blocked due to existing edges (restrict behavior).
|
|
224
|
+
*/
|
|
225
|
+
declare class RestrictedDeleteError extends TypeGraphError {
|
|
226
|
+
constructor(details: Readonly<{
|
|
227
|
+
nodeKind: string;
|
|
228
|
+
nodeId: string;
|
|
229
|
+
edgeCount: number;
|
|
230
|
+
edgeKinds: readonly string[];
|
|
231
|
+
}>, options?: {
|
|
232
|
+
cause?: unknown;
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Thrown when optimistic locking detects a concurrent modification.
|
|
237
|
+
*
|
|
238
|
+
* This occurs when two operations try to update the same entity simultaneously.
|
|
239
|
+
* The operation with the stale version fails.
|
|
240
|
+
*/
|
|
241
|
+
declare class VersionConflictError extends TypeGraphError {
|
|
242
|
+
constructor(details: Readonly<{
|
|
243
|
+
kind: string;
|
|
244
|
+
id: string;
|
|
245
|
+
expectedVersion: number;
|
|
246
|
+
actualVersion: number;
|
|
247
|
+
}>, options?: {
|
|
248
|
+
cause?: unknown;
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* Thrown when the schema in code doesn't match the schema in the database.
|
|
253
|
+
*/
|
|
254
|
+
declare class SchemaMismatchError extends TypeGraphError {
|
|
255
|
+
constructor(details: Readonly<{
|
|
256
|
+
graphId: string;
|
|
257
|
+
expectedHash: string;
|
|
258
|
+
actualHash: string;
|
|
259
|
+
}>, options?: {
|
|
260
|
+
cause?: unknown;
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Thrown when schema migration fails.
|
|
265
|
+
*/
|
|
266
|
+
declare class MigrationError extends TypeGraphError {
|
|
267
|
+
constructor(message: string, details: Readonly<{
|
|
268
|
+
graphId: string;
|
|
269
|
+
fromVersion: number;
|
|
270
|
+
toVersion: number;
|
|
271
|
+
reason?: string;
|
|
272
|
+
}>, options?: {
|
|
273
|
+
cause?: unknown;
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* Thrown when graph configuration is invalid.
|
|
278
|
+
*
|
|
279
|
+
* This includes invalid schema definitions, ontology conflicts,
|
|
280
|
+
* and other configuration issues detected at graph creation time.
|
|
281
|
+
*/
|
|
282
|
+
declare class ConfigurationError extends TypeGraphError {
|
|
283
|
+
constructor(message: string, details?: Record<string, unknown>, options?: {
|
|
284
|
+
cause?: unknown;
|
|
285
|
+
suggestion?: string;
|
|
286
|
+
});
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* Thrown when a database operation fails unexpectedly.
|
|
290
|
+
*
|
|
291
|
+
* This indicates a system-level failure in the database backend,
|
|
292
|
+
* not a user-recoverable error.
|
|
293
|
+
*/
|
|
294
|
+
declare class DatabaseOperationError extends TypeGraphError {
|
|
295
|
+
constructor(message: string, details: Readonly<{
|
|
296
|
+
operation: string;
|
|
297
|
+
entity: string;
|
|
298
|
+
}>, options?: {
|
|
299
|
+
cause?: unknown;
|
|
300
|
+
});
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* Thrown when a query predicate cannot be compiled for the target database.
|
|
304
|
+
*/
|
|
305
|
+
declare class UnsupportedPredicateError extends TypeGraphError {
|
|
306
|
+
constructor(message: string, details?: Readonly<Record<string, unknown>>, options?: {
|
|
307
|
+
cause?: unknown;
|
|
308
|
+
suggestion?: string;
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* Thrown when a compiler invariant is violated.
|
|
313
|
+
*
|
|
314
|
+
* This indicates a bug in the query compiler — the compiler reached
|
|
315
|
+
* a state that should be unreachable. These errors are not user-recoverable.
|
|
316
|
+
*/
|
|
317
|
+
declare class CompilerInvariantError extends TypeGraphError {
|
|
318
|
+
constructor(message: string, details?: Readonly<Record<string, unknown>>, options?: {
|
|
319
|
+
cause?: unknown;
|
|
320
|
+
});
|
|
321
|
+
}
|
|
322
|
+
/**
|
|
323
|
+
* Type guard for TypeGraphError.
|
|
324
|
+
*
|
|
325
|
+
* @example
|
|
326
|
+
* ```typescript
|
|
327
|
+
* try {
|
|
328
|
+
* await store.nodes.Person.create({});
|
|
329
|
+
* } catch (error) {
|
|
330
|
+
* if (isTypeGraphError(error)) {
|
|
331
|
+
* console.log(error.code, error.category);
|
|
332
|
+
* }
|
|
333
|
+
* }
|
|
334
|
+
* ```
|
|
335
|
+
*/
|
|
336
|
+
declare function isTypeGraphError(error: unknown): error is TypeGraphError;
|
|
337
|
+
/**
|
|
338
|
+
* Check if error is recoverable by user action (user or constraint error).
|
|
339
|
+
*
|
|
340
|
+
* User-recoverable errors can typically be resolved by:
|
|
341
|
+
* - Fixing invalid input data
|
|
342
|
+
* - Using different IDs or values
|
|
343
|
+
* - Deleting conflicting data first
|
|
344
|
+
*
|
|
345
|
+
* @example
|
|
346
|
+
* ```typescript
|
|
347
|
+
* if (isUserRecoverable(error)) {
|
|
348
|
+
* showErrorToUser(error.toUserMessage());
|
|
349
|
+
* } else {
|
|
350
|
+
* logAndAlertOps(error);
|
|
351
|
+
* }
|
|
352
|
+
* ```
|
|
353
|
+
*/
|
|
354
|
+
declare function isUserRecoverable(error: unknown): boolean;
|
|
355
|
+
/**
|
|
356
|
+
* Check if error indicates a system/infrastructure issue.
|
|
357
|
+
*
|
|
358
|
+
* System errors typically require:
|
|
359
|
+
* - Retry logic (for transient failures)
|
|
360
|
+
* - Investigation (for persistent failures)
|
|
361
|
+
* - Ops team notification
|
|
362
|
+
*/
|
|
363
|
+
declare function isSystemError(error: unknown): boolean;
|
|
364
|
+
/**
|
|
365
|
+
* Check if error is a constraint violation.
|
|
366
|
+
*/
|
|
367
|
+
declare function isConstraintError(error: unknown): boolean;
|
|
368
|
+
/**
|
|
369
|
+
* Extract suggestion from error if available.
|
|
370
|
+
*/
|
|
371
|
+
declare function getErrorSuggestion(error: unknown): string | undefined;
|
|
372
|
+
|
|
373
|
+
export { CardinalityError as C, DatabaseOperationError as D, EdgeNotFoundError as E, KindNotFoundError as K, MigrationError as M, NodeNotFoundError as N, RestrictedDeleteError as R, SchemaMismatchError as S, TypeGraphError as T, UniquenessError as U, type ValidationIssue as V, ValidationError as a, CompilerInvariantError as b, ConfigurationError as c, DisjointError as d, EndpointError as e, EndpointNotFoundError as f, type ErrorCategory as g, type TypeGraphErrorOptions as h, UnsupportedPredicateError as i, type ValidationErrorDetails as j, VersionConflictError as k, getErrorSuggestion as l, isConstraintError as m, isSystemError as n, isTypeGraphError as o, isUserRecoverable as p };
|