dominus-sdk-nodejs 1.0.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.
Files changed (63) hide show
  1. package/LLM-GUIDE.md +537 -0
  2. package/README.md +408 -0
  3. package/dist/index.d.ts +114 -0
  4. package/dist/index.d.ts.map +1 -0
  5. package/dist/index.js +129 -0
  6. package/dist/index.js.map +1 -0
  7. package/dist/lib/client.d.ts +32 -0
  8. package/dist/lib/client.d.ts.map +1 -0
  9. package/dist/lib/client.js +374 -0
  10. package/dist/lib/client.js.map +1 -0
  11. package/dist/lib/config.d.ts +20 -0
  12. package/dist/lib/config.d.ts.map +1 -0
  13. package/dist/lib/config.js +35 -0
  14. package/dist/lib/config.js.map +1 -0
  15. package/dist/lib/errors.d.ts +77 -0
  16. package/dist/lib/errors.d.ts.map +1 -0
  17. package/dist/lib/errors.js +134 -0
  18. package/dist/lib/errors.js.map +1 -0
  19. package/dist/namespaces/auth.d.ts +65 -0
  20. package/dist/namespaces/auth.d.ts.map +1 -0
  21. package/dist/namespaces/auth.js +266 -0
  22. package/dist/namespaces/auth.js.map +1 -0
  23. package/dist/namespaces/courier.d.ts +67 -0
  24. package/dist/namespaces/courier.d.ts.map +1 -0
  25. package/dist/namespaces/courier.js +90 -0
  26. package/dist/namespaces/courier.js.map +1 -0
  27. package/dist/namespaces/db.d.ts +117 -0
  28. package/dist/namespaces/db.d.ts.map +1 -0
  29. package/dist/namespaces/db.js +149 -0
  30. package/dist/namespaces/db.js.map +1 -0
  31. package/dist/namespaces/ddl.d.ts +84 -0
  32. package/dist/namespaces/ddl.d.ts.map +1 -0
  33. package/dist/namespaces/ddl.js +211 -0
  34. package/dist/namespaces/ddl.js.map +1 -0
  35. package/dist/namespaces/files.d.ts +107 -0
  36. package/dist/namespaces/files.d.ts.map +1 -0
  37. package/dist/namespaces/files.js +161 -0
  38. package/dist/namespaces/files.js.map +1 -0
  39. package/dist/namespaces/health.d.ts +30 -0
  40. package/dist/namespaces/health.d.ts.map +1 -0
  41. package/dist/namespaces/health.js +66 -0
  42. package/dist/namespaces/health.js.map +1 -0
  43. package/dist/namespaces/logs.d.ts +97 -0
  44. package/dist/namespaces/logs.d.ts.map +1 -0
  45. package/dist/namespaces/logs.js +194 -0
  46. package/dist/namespaces/logs.js.map +1 -0
  47. package/dist/namespaces/open.d.ts +27 -0
  48. package/dist/namespaces/open.d.ts.map +1 -0
  49. package/dist/namespaces/open.js +46 -0
  50. package/dist/namespaces/open.js.map +1 -0
  51. package/dist/namespaces/portal.d.ts +124 -0
  52. package/dist/namespaces/portal.d.ts.map +1 -0
  53. package/dist/namespaces/portal.js +270 -0
  54. package/dist/namespaces/portal.js.map +1 -0
  55. package/dist/namespaces/redis.d.ts +144 -0
  56. package/dist/namespaces/redis.d.ts.map +1 -0
  57. package/dist/namespaces/redis.js +218 -0
  58. package/dist/namespaces/redis.js.map +1 -0
  59. package/dist/namespaces/secrets.d.ts +50 -0
  60. package/dist/namespaces/secrets.d.ts.map +1 -0
  61. package/dist/namespaces/secrets.js +93 -0
  62. package/dist/namespaces/secrets.js.map +1 -0
  63. package/package.json +45 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/lib/client.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAYH,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,QAAQ,CAAC;IAC3C,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAChC;AAkRD;;GAEG;AACH,qBAAa,aAAa;IACxB,OAAO,CAAC,KAAK,CAAgB;IAC7B,OAAO,CAAC,OAAO,CAAS;gBAEZ,cAAc,CAAC,EAAE,MAAM;IAKnC;;OAEG;YACW,QAAQ;IAuBtB;;OAEG;IACG,OAAO,CAAC,CAAC,GAAG,OAAO,EAAE,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,CAAC,CAAC;IAkJ/D;;OAEG;IACG,WAAW,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAGtD;AAKD,wBAAgB,SAAS,CAAC,cAAc,CAAC,EAAE,MAAM,GAAG,aAAa,CAKhE"}
@@ -0,0 +1,374 @@
1
+ /**
2
+ * Core HTTP Client for Dominus SDK
3
+ *
4
+ * Handles JWT management, base64 encoding/decoding, retries, and circuit breaker.
5
+ */
6
+ import { BASE_URL, resolveToken } from './config.js';
7
+ import { DominusError, AuthenticationError, raiseForStatus, ConnectionError, TimeoutError, } from './errors.js';
8
+ // Constants
9
+ const MAX_RETRIES = 3;
10
+ const REQUEST_TIMEOUT = 30000; // 30 seconds
11
+ // State
12
+ let cachedJwt = null;
13
+ let validated = false;
14
+ // Circuit breaker state
15
+ let circuitState = 'closed';
16
+ let failureCount = 0;
17
+ let lastFailureTime = 0;
18
+ const CIRCUIT_THRESHOLD = 5;
19
+ const CIRCUIT_TIMEOUT = 30000; // 30 seconds
20
+ /**
21
+ * Base64 encode a JSON object to string
22
+ */
23
+ function b64Encode(data) {
24
+ const json = JSON.stringify(data);
25
+ return Buffer.from(json).toString('base64');
26
+ }
27
+ /**
28
+ * Base64 decode a string to JSON object
29
+ */
30
+ function b64Decode(encoded) {
31
+ const decoded = Buffer.from(encoded, 'base64').toString('utf-8');
32
+ return JSON.parse(decoded);
33
+ }
34
+ /**
35
+ * Decode JWT payload without verification (for exp checks only)
36
+ */
37
+ function decodeJwtPayload(jwt) {
38
+ const parts = jwt.split('.');
39
+ if (parts.length !== 3) {
40
+ throw new Error('Invalid JWT format');
41
+ }
42
+ // Base64url decode
43
+ let payload = parts[1];
44
+ payload = payload.replace(/-/g, '+').replace(/_/g, '/');
45
+ const padding = 4 - (payload.length % 4);
46
+ if (padding !== 4) {
47
+ payload += '='.repeat(padding);
48
+ }
49
+ const decoded = Buffer.from(payload, 'base64').toString('utf-8');
50
+ return JSON.parse(decoded);
51
+ }
52
+ /**
53
+ * Calculate exponential backoff with jitter
54
+ */
55
+ function backoffWithJitter(attempt, baseDelay = 1000, maxDelay = 15000) {
56
+ const delay = Math.min(baseDelay * Math.pow(2, attempt), maxDelay);
57
+ const jitter = delay * 0.5 * Math.random();
58
+ return delay + jitter;
59
+ }
60
+ /**
61
+ * Check if circuit breaker allows execution
62
+ */
63
+ function canExecute() {
64
+ if (circuitState === 'closed')
65
+ return true;
66
+ if (circuitState === 'open') {
67
+ if (Date.now() - lastFailureTime > CIRCUIT_TIMEOUT) {
68
+ circuitState = 'half-open';
69
+ return true;
70
+ }
71
+ return false;
72
+ }
73
+ // half-open
74
+ return true;
75
+ }
76
+ /**
77
+ * Record success for circuit breaker
78
+ */
79
+ function recordSuccess() {
80
+ failureCount = 0;
81
+ circuitState = 'closed';
82
+ }
83
+ /**
84
+ * Record failure for circuit breaker
85
+ */
86
+ function recordFailure() {
87
+ failureCount++;
88
+ lastFailureTime = Date.now();
89
+ if (failureCount >= CIRCUIT_THRESHOLD) {
90
+ circuitState = 'open';
91
+ }
92
+ }
93
+ /**
94
+ * Get service JWT by calling /newapi/auth with PSK
95
+ */
96
+ async function getServiceJwt(pskToken) {
97
+ if (!canExecute()) {
98
+ throw new AuthenticationError('Circuit breaker OPEN - too many recent failures. Will retry after recovery timeout.');
99
+ }
100
+ const headers = {
101
+ Authorization: `Bearer ${pskToken}`,
102
+ 'Content-Type': 'text/plain',
103
+ };
104
+ const body = b64Encode({ method: 'auth.self', params: {} });
105
+ try {
106
+ const controller = new AbortController();
107
+ const timeoutId = setTimeout(() => controller.abort(), REQUEST_TIMEOUT);
108
+ const response = await fetch(`${BASE_URL}/newapi/auth`, {
109
+ method: 'POST',
110
+ headers,
111
+ body,
112
+ signal: controller.signal,
113
+ });
114
+ clearTimeout(timeoutId);
115
+ if (!response.ok) {
116
+ recordFailure();
117
+ throw new AuthenticationError(`Auth failed with status ${response.status}`);
118
+ }
119
+ const text = await response.text();
120
+ const result = b64Decode(text);
121
+ if (!result.success) {
122
+ recordFailure();
123
+ throw new AuthenticationError(result.error || 'Unknown auth error');
124
+ }
125
+ const jwt = result.data?.access_token || result.data?.token;
126
+ if (!jwt) {
127
+ recordFailure();
128
+ throw new AuthenticationError('No JWT token in auth response');
129
+ }
130
+ recordSuccess();
131
+ return jwt;
132
+ }
133
+ catch (error) {
134
+ if (error instanceof DominusError)
135
+ throw error;
136
+ recordFailure();
137
+ if (error instanceof Error && error.name === 'AbortError') {
138
+ throw new TimeoutError('JWT request timed out');
139
+ }
140
+ throw new ConnectionError(`Failed to get JWT: ${error}`);
141
+ }
142
+ }
143
+ /**
144
+ * Ensure we have a valid JWT, fetching and caching if needed
145
+ */
146
+ async function ensureValidJwt(pskToken) {
147
+ // Check cached JWT
148
+ if (cachedJwt) {
149
+ try {
150
+ const payload = decodeJwtPayload(cachedJwt);
151
+ const exp = payload.exp || 0;
152
+ const currentTime = Math.floor(Date.now() / 1000);
153
+ // Refresh if <60 seconds remain
154
+ if (exp - currentTime > 60) {
155
+ return cachedJwt;
156
+ }
157
+ }
158
+ catch {
159
+ // If decode fails, fetch new JWT
160
+ }
161
+ }
162
+ // Fetch new JWT
163
+ const jwt = await getServiceJwt(pskToken);
164
+ cachedJwt = jwt;
165
+ return jwt;
166
+ }
167
+ /**
168
+ * Verify token with server
169
+ */
170
+ async function verifyTokenWithServer(token) {
171
+ const controller = new AbortController();
172
+ const timeoutId = setTimeout(() => controller.abort(), 5000);
173
+ try {
174
+ const response = await fetch(`${BASE_URL}/verify`, {
175
+ method: 'POST',
176
+ headers: { 'Content-Type': 'application/json' },
177
+ body: JSON.stringify({ token }),
178
+ signal: controller.signal,
179
+ });
180
+ clearTimeout(timeoutId);
181
+ if (!response.ok) {
182
+ throw new AuthenticationError(`Token verification failed: ${response.status}`);
183
+ }
184
+ const result = (await response.json());
185
+ if (!result.valid) {
186
+ throw new AuthenticationError(result.error || 'Invalid token');
187
+ }
188
+ return true;
189
+ }
190
+ catch (error) {
191
+ clearTimeout(timeoutId);
192
+ if (error instanceof DominusError)
193
+ throw error;
194
+ throw new ConnectionError(`Token verification failed: ${error}`);
195
+ }
196
+ }
197
+ /**
198
+ * Health check
199
+ */
200
+ async function healthCheck() {
201
+ const controller = new AbortController();
202
+ const timeoutId = setTimeout(() => controller.abort(), 5000);
203
+ const start = Date.now();
204
+ try {
205
+ const response = await fetch(`${BASE_URL}/newapi/health`, {
206
+ signal: controller.signal,
207
+ });
208
+ clearTimeout(timeoutId);
209
+ const latency = Date.now() - start;
210
+ if (!response.ok) {
211
+ return {
212
+ status: 'unhealthy',
213
+ error: `HTTP ${response.status}`,
214
+ latency_ms: latency,
215
+ };
216
+ }
217
+ const data = (await response.json());
218
+ return {
219
+ status: data.status || 'healthy',
220
+ latency_ms: latency,
221
+ ...data,
222
+ };
223
+ }
224
+ catch (error) {
225
+ clearTimeout(timeoutId);
226
+ return {
227
+ status: 'unhealthy',
228
+ error: String(error),
229
+ };
230
+ }
231
+ }
232
+ /**
233
+ * Main Dominus client class
234
+ */
235
+ export class DominusClient {
236
+ token;
237
+ baseUrl;
238
+ constructor(hardcodedToken) {
239
+ this.token = resolveToken(hardcodedToken);
240
+ this.baseUrl = BASE_URL;
241
+ }
242
+ /**
243
+ * Validate token on first use
244
+ */
245
+ async validate() {
246
+ if (validated)
247
+ return;
248
+ if (!this.token) {
249
+ throw new AuthenticationError('DOMINUS_TOKEN not found.\n\n' +
250
+ 'Production:\n export DOMINUS_TOKEN=your_token\n\n' +
251
+ 'Development:\n Pass token to createDominus({ token: "..." })');
252
+ }
253
+ // Verify token
254
+ await verifyTokenWithServer(this.token);
255
+ // Health check
256
+ const health = await healthCheck();
257
+ if (health.status !== 'healthy') {
258
+ throw new DominusError(`Services unhealthy: ${JSON.stringify(health)}`);
259
+ }
260
+ validated = true;
261
+ }
262
+ /**
263
+ * Make an authenticated request to the orchestrator
264
+ */
265
+ async request(options) {
266
+ await this.validate();
267
+ const { endpoint, method = 'POST', body = {} } = options;
268
+ // Get JWT
269
+ const jwt = await ensureValidJwt(this.token);
270
+ // Prepare request
271
+ const headers = {
272
+ Authorization: `Bearer ${jwt}`,
273
+ 'Content-Type': 'text/plain',
274
+ };
275
+ const encodedBody = b64Encode(body);
276
+ // Retry loop
277
+ for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
278
+ try {
279
+ const controller = new AbortController();
280
+ const timeoutId = setTimeout(() => controller.abort(), REQUEST_TIMEOUT);
281
+ let response;
282
+ if (method === 'GET') {
283
+ // For GET requests, we don't send body
284
+ response = await fetch(`${this.baseUrl}${endpoint}`, {
285
+ method: 'GET',
286
+ headers: {
287
+ Authorization: `Bearer ${jwt}`,
288
+ },
289
+ signal: controller.signal,
290
+ });
291
+ }
292
+ else {
293
+ response = await fetch(`${this.baseUrl}${endpoint}`, {
294
+ method,
295
+ headers,
296
+ body: encodedBody,
297
+ signal: controller.signal,
298
+ });
299
+ }
300
+ clearTimeout(timeoutId);
301
+ if (!response.ok) {
302
+ // Try to decode error response
303
+ let errorMessage = `HTTP ${response.status}`;
304
+ let errorDetails = {};
305
+ try {
306
+ const errorText = await response.text();
307
+ const decoded = b64Decode(errorText);
308
+ errorMessage =
309
+ decoded.error ||
310
+ decoded.detail ||
311
+ errorMessage;
312
+ errorDetails = decoded;
313
+ }
314
+ catch {
315
+ // Use default error message
316
+ }
317
+ // Don't retry 4xx errors
318
+ if (response.status >= 400 && response.status < 500) {
319
+ raiseForStatus(response.status, errorMessage, errorDetails, endpoint);
320
+ }
321
+ // Retry 5xx errors
322
+ if (attempt === MAX_RETRIES - 1) {
323
+ raiseForStatus(response.status, errorMessage, errorDetails, endpoint);
324
+ }
325
+ const delay = backoffWithJitter(attempt);
326
+ await new Promise((resolve) => setTimeout(resolve, delay));
327
+ continue;
328
+ }
329
+ // Decode successful response
330
+ const text = await response.text();
331
+ const result = b64Decode(text);
332
+ // Handle wrapped response format
333
+ if ('success' in result && result.success === false) {
334
+ throw new DominusError(result.error || 'Unknown error', undefined, undefined, endpoint);
335
+ }
336
+ // Return data field if present, otherwise the whole result
337
+ if ('data' in result && result.data !== undefined) {
338
+ return result.data;
339
+ }
340
+ return result;
341
+ }
342
+ catch (error) {
343
+ if (error instanceof DominusError)
344
+ throw error;
345
+ if (error instanceof Error && error.name === 'AbortError') {
346
+ if (attempt === MAX_RETRIES - 1) {
347
+ throw new TimeoutError('Request timed out', undefined, undefined, endpoint);
348
+ }
349
+ }
350
+ if (attempt === MAX_RETRIES - 1) {
351
+ throw new ConnectionError(`Request failed after ${MAX_RETRIES} retries: ${error}`, undefined, undefined, endpoint);
352
+ }
353
+ const delay = backoffWithJitter(attempt);
354
+ await new Promise((resolve) => setTimeout(resolve, delay));
355
+ }
356
+ }
357
+ throw new ConnectionError(`Request failed after ${MAX_RETRIES} retries`, undefined, undefined, endpoint);
358
+ }
359
+ /**
360
+ * Health check endpoint
361
+ */
362
+ async healthCheck() {
363
+ return healthCheck();
364
+ }
365
+ }
366
+ // Export singleton factory
367
+ let clientInstance = null;
368
+ export function getClient(hardcodedToken) {
369
+ if (!clientInstance) {
370
+ clientInstance = new DominusClient(hardcodedToken);
371
+ }
372
+ return clientInstance;
373
+ }
374
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/lib/client.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EACL,YAAY,EACZ,mBAAmB,EACnB,cAAc,EACd,eAAe,EACf,YAAY,GACb,MAAM,aAAa,CAAC;AAcrB,YAAY;AACZ,MAAM,WAAW,GAAG,CAAC,CAAC;AACtB,MAAM,eAAe,GAAG,KAAK,CAAC,CAAC,aAAa;AAE5C,QAAQ;AACR,IAAI,SAAS,GAAkB,IAAI,CAAC;AACpC,IAAI,SAAS,GAAG,KAAK,CAAC;AAEtB,wBAAwB;AACxB,IAAI,Y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,EACT,SAAS,EACT,QAAQ,CACT,CAAC;gBACJ,CAAC;gBAED,MAAM,KAAK,GAAG,iBAAiB,CAAC,OAAO,CAAC,CAAC;gBACzC,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC;YAC7D,CAAC;QACH,CAAC;QAED,MAAM,IAAI,eAAe,CACvB,wBAAwB,WAAW,UAAU,EAC7C,SAAS,EACT,SAAS,EACT,QAAQ,CACT,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,WAAW;QACf,OAAO,WAAW,EAAE,CAAC;IACvB,CAAC;CACF;AAED,2BAA2B;AAC3B,IAAI,cAAc,GAAyB,IAAI,CAAC;AAEhD,MAAM,UAAU,SAAS,CAAC,cAAuB;IAC/C,IAAI,CAAC,cAAc,EAAE,CAAC;QACpB,cAAc,GAAG,IAAI,aAAa,CAAC,cAAc,CAAC,CAAC;IACrD,CAAC;IACD,OAAO,cAAc,CAAC;AACxB,CAAC"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Dominus Orchestrator Configuration
3
+ *
4
+ * Single backend URL for all services. The SDK targets dominus-orchestrator
5
+ * which consolidates all service functionality.
6
+ */
7
+ export declare const BASE_URL = "https://dominus-orchestrator-production-775398158805.us-east4.run.app";
8
+ /**
9
+ * Get the dominus-orchestrator base URL.
10
+ */
11
+ export declare function getBaseUrl(): string;
12
+ /**
13
+ * Resolve authentication token.
14
+ *
15
+ * Priority:
16
+ * 1. Environment variable: DOMINUS_TOKEN
17
+ * 2. Hardcoded fallback (if provided)
18
+ */
19
+ export declare function resolveToken(hardcodedToken?: string): string | null;
20
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/lib/config.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAOH,eAAO,MAAM,QAAQ,0EAAgF,CAAC;AAEtG;;GAEG;AACH,wBAAgB,UAAU,IAAI,MAAM,CAEnC;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,cAAc,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CASnE"}
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Dominus Orchestrator Configuration
3
+ *
4
+ * Single backend URL for all services. The SDK targets dominus-orchestrator
5
+ * which consolidates all service functionality.
6
+ */
7
+ // Cloud Run configuration
8
+ const PROJECT_NUMBER = '775398158805';
9
+ const REGION = 'us-east4';
10
+ // Single orchestrator URL - all services consolidated here
11
+ export const BASE_URL = `https://dominus-orchestrator-production-${PROJECT_NUMBER}.${REGION}.run.app`;
12
+ /**
13
+ * Get the dominus-orchestrator base URL.
14
+ */
15
+ export function getBaseUrl() {
16
+ return BASE_URL;
17
+ }
18
+ /**
19
+ * Resolve authentication token.
20
+ *
21
+ * Priority:
22
+ * 1. Environment variable: DOMINUS_TOKEN
23
+ * 2. Hardcoded fallback (if provided)
24
+ */
25
+ export function resolveToken(hardcodedToken) {
26
+ const token = process.env.DOMINUS_TOKEN;
27
+ if (token) {
28
+ return token;
29
+ }
30
+ if (hardcodedToken) {
31
+ return hardcodedToken;
32
+ }
33
+ return null;
34
+ }
35
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/lib/config.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,0BAA0B;AAC1B,MAAM,cAAc,GAAG,cAAc,CAAC;AACtC,MAAM,MAAM,GAAG,UAAU,CAAC;AAE1B,2DAA2D;AAC3D,MAAM,CAAC,MAAM,QAAQ,GAAG,2CAA2C,cAAc,IAAI,MAAM,UAAU,CAAC;AAEtG;;GAEG;AACH,MAAM,UAAU,UAAU;IACxB,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,YAAY,CAAC,cAAuB;IAClD,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC;IACxC,IAAI,KAAK,EAAE,CAAC;QACV,OAAO,KAAK,CAAC;IACf,CAAC;IACD,IAAI,cAAc,EAAE,CAAC;QACnB,OAAO,cAAc,CAAC;IACxB,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -0,0 +1,77 @@
1
+ /**
2
+ * Dominus SDK Error Classes
3
+ *
4
+ * Custom exceptions for the Dominus SDK with structured error information.
5
+ */
6
+ export interface ErrorDetails {
7
+ [key: string]: unknown;
8
+ }
9
+ /**
10
+ * Base exception for all Dominus SDK errors.
11
+ */
12
+ export declare class DominusError extends Error {
13
+ readonly statusCode?: number;
14
+ readonly details: ErrorDetails;
15
+ readonly endpoint?: string;
16
+ constructor(message: string, statusCode?: number, details?: ErrorDetails, endpoint?: string);
17
+ toString(): string;
18
+ }
19
+ /**
20
+ * Raised when authentication fails (invalid token, expired JWT, etc.).
21
+ */
22
+ export declare class AuthenticationError extends DominusError {
23
+ constructor(message?: string, statusCode?: number, details?: ErrorDetails, endpoint?: string);
24
+ }
25
+ /**
26
+ * Raised when authorization fails (insufficient permissions).
27
+ */
28
+ export declare class AuthorizationError extends DominusError {
29
+ constructor(message?: string, statusCode?: number, details?: ErrorDetails, endpoint?: string);
30
+ }
31
+ /**
32
+ * Raised when a requested resource is not found.
33
+ */
34
+ export declare class NotFoundError extends DominusError {
35
+ constructor(message?: string, statusCode?: number, details?: ErrorDetails, endpoint?: string);
36
+ }
37
+ /**
38
+ * Raised when request validation fails.
39
+ */
40
+ export declare class ValidationError extends DominusError {
41
+ constructor(message?: string, statusCode?: number, details?: ErrorDetails, endpoint?: string);
42
+ }
43
+ /**
44
+ * Raised when there's a conflict (duplicate key, version mismatch, etc.).
45
+ */
46
+ export declare class ConflictError extends DominusError {
47
+ constructor(message?: string, statusCode?: number, details?: ErrorDetails, endpoint?: string);
48
+ }
49
+ /**
50
+ * Raised when a backend service error occurs.
51
+ */
52
+ export declare class ServiceError extends DominusError {
53
+ constructor(message?: string, statusCode?: number, details?: ErrorDetails, endpoint?: string);
54
+ }
55
+ /**
56
+ * Raised when connection to the backend fails.
57
+ */
58
+ export declare class ConnectionError extends DominusError {
59
+ constructor(message?: string, statusCode?: number, details?: ErrorDetails, endpoint?: string);
60
+ }
61
+ /**
62
+ * Raised when a request times out.
63
+ */
64
+ export declare class TimeoutError extends DominusError {
65
+ constructor(message?: string, statusCode?: number, details?: ErrorDetails, endpoint?: string);
66
+ }
67
+ /**
68
+ * Raised when accessing a secure table without providing a reason.
69
+ */
70
+ export declare class SecureTableError extends DominusError {
71
+ constructor(message?: string, statusCode?: number, details?: ErrorDetails, endpoint?: string);
72
+ }
73
+ /**
74
+ * Raise appropriate DominusError subclass based on status code.
75
+ */
76
+ export declare function raiseForStatus(statusCode: number, message: string, details?: ErrorDetails, endpoint?: string): never;
77
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/lib/errors.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,WAAW,YAAY;IAC3B,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED;;GAEG;AACH,qBAAa,YAAa,SAAQ,KAAK;IACrC,SAAgB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpC,SAAgB,OAAO,EAAE,YAAY,CAAC;IACtC,SAAgB,QAAQ,CAAC,EAAE,MAAM,CAAC;gBAGhC,OAAO,EAAE,MAAM,EACf,UAAU,CAAC,EAAE,MAAM,EACnB,OAAO,CAAC,EAAE,YAAY,EACtB,QAAQ,CAAC,EAAE,MAAM;IAcnB,QAAQ,IAAI,MAAM;CAUnB;AAED;;GAEG;AACH,qBAAa,mBAAoB,SAAQ,YAAY;gBAEjD,OAAO,SAA0B,EACjC,UAAU,SAAM,EAChB,OAAO,CAAC,EAAE,YAAY,EACtB,QAAQ,CAAC,EAAE,MAAM;CAKpB;AAED;;GAEG;AAC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pB;AAED;;GAEG;AACH,wBAAgB,cAAc,CAC5B,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,YAAY,EACtB,QAAQ,CAAC,EAAE,MAAM,GAChB,KAAK,CAeP"}
@@ -0,0 +1,134 @@
1
+ /**
2
+ * Dominus SDK Error Classes
3
+ *
4
+ * Custom exceptions for the Dominus SDK with structured error information.
5
+ */
6
+ /**
7
+ * Base exception for all Dominus SDK errors.
8
+ */
9
+ export class DominusError extends Error {
10
+ statusCode;
11
+ details;
12
+ endpoint;
13
+ constructor(message, statusCode, details, endpoint) {
14
+ super(message);
15
+ this.name = 'DominusError';
16
+ this.statusCode = statusCode;
17
+ this.details = details || {};
18
+ this.endpoint = endpoint;
19
+ // Maintains proper stack trace for where error was thrown
20
+ if (Error.captureStackTrace) {
21
+ Error.captureStackTrace(this, this.constructor);
22
+ }
23
+ }
24
+ toString() {
25
+ const parts = [this.message];
26
+ if (this.statusCode) {
27
+ parts.push(`(status ${this.statusCode})`);
28
+ }
29
+ if (this.endpoint) {
30
+ parts.push(`at ${this.endpoint}`);
31
+ }
32
+ return parts.join(' ');
33
+ }
34
+ }
35
+ /**
36
+ * Raised when authentication fails (invalid token, expired JWT, etc.).
37
+ */
38
+ export class AuthenticationError extends DominusError {
39
+ constructor(message = 'Authentication failed', statusCode = 401, details, endpoint) {
40
+ super(message, statusCode, details, endpoint);
41
+ this.name = 'AuthenticationError';
42
+ }
43
+ }
44
+ /**
45
+ * Raised when authorization fails (insufficient permissions).
46
+ */
47
+ export class AuthorizationError extends DominusError {
48
+ constructor(message = 'Permission denied', statusCode = 403, details, endpoint) {
49
+ super(message, statusCode, details, endpoint);
50
+ this.name = 'AuthorizationError';
51
+ }
52
+ }
53
+ /**
54
+ * Raised when a requested resource is not found.
55
+ */
56
+ export class NotFoundError extends DominusError {
57
+ constructor(message = 'Resource not found', statusCode = 404, details, endpoint) {
58
+ super(message, statusCode, details, endpoint);
59
+ this.name = 'NotFoundError';
60
+ }
61
+ }
62
+ /**
63
+ * Raised when request validation fails.
64
+ */
65
+ export class ValidationError extends DominusError {
66
+ constructor(message = 'Validation failed', statusCode = 400, details, endpoint) {
67
+ super(message, statusCode, details, endpoint);
68
+ this.name = 'ValidationError';
69
+ }
70
+ }
71
+ /**
72
+ * Raised when there's a conflict (duplicate key, version mismatch, etc.).
73
+ */
74
+ export class ConflictError extends DominusError {
75
+ constructor(message = 'Conflict', statusCode = 409, details, endpoint) {
76
+ super(message, statusCode, details, endpoint);
77
+ this.name = 'ConflictError';
78
+ }
79
+ }
80
+ /**
81
+ * Raised when a backend service error occurs.
82
+ */
83
+ export class ServiceError extends DominusError {
84
+ constructor(message = 'Service error', statusCode = 500, details, endpoint) {
85
+ super(message, statusCode, details, endpoint);
86
+ this.name = 'ServiceError';
87
+ }
88
+ }
89
+ /**
90
+ * Raised when connection to the backend fails.
91
+ */
92
+ export class ConnectionError extends DominusError {
93
+ constructor(message = 'Connection failed', statusCode, details, endpoint) {
94
+ super(message, statusCode, details, endpoint);
95
+ this.name = 'ConnectionError';
96
+ }
97
+ }
98
+ /**
99
+ * Raised when a request times out.
100
+ */
101
+ export class TimeoutError extends DominusError {
102
+ constructor(message = 'Request timed out', statusCode, details, endpoint) {
103
+ super(message, statusCode, details, endpoint);
104
+ this.name = 'TimeoutError';
105
+ }
106
+ }
107
+ /**
108
+ * Raised when accessing a secure table without providing a reason.
109
+ */
110
+ export class SecureTableError extends DominusError {
111
+ constructor(message = "Access to secure table requires 'reason' parameter", statusCode = 403, details, endpoint) {
112
+ super(message, statusCode, details, endpoint);
113
+ this.name = 'SecureTableError';
114
+ }
115
+ }
116
+ /**
117
+ * Raise appropriate DominusError subclass based on status code.
118
+ */
119
+ export function raiseForStatus(statusCode, message, details, endpoint) {
120
+ const errorClasses = {
121
+ 400: ValidationError,
122
+ 401: AuthenticationError,
123
+ 403: AuthorizationError,
124
+ 404: NotFoundError,
125
+ 409: ConflictError,
126
+ 500: ServiceError,
127
+ 502: ServiceError,
128
+ 503: ServiceError,
129
+ 504: TimeoutError,
130
+ };
131
+ const ErrorClass = errorClasses[statusCode] || DominusError;
132
+ throw new ErrorClass(message, statusCode, details, endpoint);
133
+ }
134
+ //# sourceMappingURL=errors.js.map