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
package/README.md ADDED
@@ -0,0 +1,408 @@
1
+ # CB Dominus SDK for Node.js
2
+
3
+ **TypeScript SDK for the Dominus Orchestrator Platform**
4
+
5
+ A unified, async-first TypeScript SDK providing seamless access to all Dominus backend services including secrets management, database operations, caching, file storage, authentication, schema management, and structured logging.
6
+
7
+ ## Features
8
+
9
+ - **Namespace-based API** - Intuitive access via `dominus.db`, `dominus.redis`, `dominus.files`, etc.
10
+ - **Async/Await** - Built for modern async TypeScript/JavaScript applications
11
+ - **Automatic JWT Management** - Token minting, caching, and refresh handled transparently
12
+ - **Resilience Built-in** - Circuit breaker, exponential backoff, and retry logic
13
+ - **Typed Errors** - Specific error classes for different failure modes
14
+ - **Secure by Default** - Client-side password hashing, audit trail support
15
+ - **Server-Side Only** - Designed for Next.js API routes, Express, and other Node.js backends
16
+
17
+ ## Quick Start
18
+
19
+ ```typescript
20
+ import { dominus } from 'dominus-sdk-nodejs';
21
+
22
+ // Set your token (or use DOMINUS_TOKEN environment variable)
23
+ process.env.DOMINUS_TOKEN = "your-psk-token";
24
+
25
+ // Secrets
26
+ const dbUrl = await dominus.secrets.get("DATABASE_URL");
27
+
28
+ // Database queries
29
+ const users = await dominus.db.query("users", { filters: { status: "active" } });
30
+
31
+ // Redis caching
32
+ await dominus.redis.set("session:123", { user: "john" }, { ttl: 3600 });
33
+
34
+ // File storage
35
+ const result = await dominus.files.upload(buffer, "report.pdf", { category: "reports" });
36
+
37
+ // Structured logging
38
+ await dominus.logs.info("User logged in", { user_id: "123" });
39
+ ```
40
+
41
+ ## Installation
42
+
43
+ ```bash
44
+ npm install dominus-sdk-nodejs
45
+ ```
46
+
47
+ Or add directly from GitHub:
48
+
49
+ ```bash
50
+ npm install github:carebridgesystems/cb-dominus-sdk-nodejs
51
+ ```
52
+
53
+ ## Requirements
54
+
55
+ - Node.js 18+ (uses native fetch)
56
+ - TypeScript 5.0+ (optional, but recommended)
57
+
58
+ ## Namespaces
59
+
60
+ | Namespace | Service | Purpose |
61
+ |-----------|---------|---------|
62
+ | `dominus.secrets` | Warden | Secrets management |
63
+ | `dominus.db` | Scribe | Database CRUD operations |
64
+ | `dominus.redis` | Whisperer | Redis caching |
65
+ | `dominus.files` | Archivist | Object storage (B2) |
66
+ | `dominus.auth` | Guardian | Authentication & authorization |
67
+ | `dominus.ddl` | Smith | Schema DDL & migrations |
68
+ | `dominus.logs` | Herald | Structured logging |
69
+ | `dominus.portal` | Portal | User auth & sessions |
70
+ | `dominus.courier` | Courier | Email delivery (Postmark) |
71
+ | `dominus.open` | Scribe | Direct database access |
72
+ | `dominus.health` | Health | Service health checks |
73
+
74
+ ## Usage Examples
75
+
76
+ ### Secrets Management
77
+
78
+ ```typescript
79
+ // Get a secret
80
+ const value = await dominus.secrets.get("API_KEY");
81
+
82
+ // Create or update
83
+ await dominus.secrets.upsert("API_KEY", "new-value", "Updated API key");
84
+
85
+ // List secrets with prefix
86
+ const secrets = await dominus.secrets.list("DB_");
87
+
88
+ // Delete
89
+ await dominus.secrets.delete("OLD_KEY");
90
+
91
+ // Root-level shortcuts
92
+ const dbUrl = await dominus.get("DATABASE_URL");
93
+ await dominus.upsert("KEY", "value");
94
+ ```
95
+
96
+ ### Database Operations
97
+
98
+ ```typescript
99
+ // List tables
100
+ const tables = await dominus.db.tables();
101
+ const tenantTables = await dominus.db.tables("tenant_acme");
102
+
103
+ // Query with filters and pagination
104
+ const users = await dominus.db.query("users", {
105
+ filters: { status: "active", role: ["admin", "manager"] },
106
+ sortBy: "created_at",
107
+ sortOrder: "DESC",
108
+ limit: 50,
109
+ offset: 0
110
+ });
111
+
112
+ // Insert
113
+ const user = await dominus.db.insert("users", {
114
+ email: "john@example.com",
115
+ name: "John Doe"
116
+ });
117
+
118
+ // Update
119
+ await dominus.db.update("users", { status: "inactive" }, { id: userId });
120
+
121
+ // Delete
122
+ await dominus.db.delete("users", { id: userId });
123
+
124
+ // Secure table access (requires audit reason)
125
+ const patients = await dominus.db.query("patients", {
126
+ schema: "tenant_acme",
127
+ reason: "Reviewing records for appointment #123",
128
+ actor: "dr.smith"
129
+ });
130
+ ```
131
+
132
+ ### Redis Caching
133
+
134
+ ```typescript
135
+ // Key-value operations
136
+ await dominus.redis.set("user:123", { name: "John" }, { ttl: 3600 });
137
+ const value = await dominus.redis.get("user:123");
138
+
139
+ // Distributed locks
140
+ const acquired = await dominus.redis.setnx("lock:job", "worker-1", { ttl: 60 });
141
+ if (acquired) {
142
+ try {
143
+ // Do exclusive work
144
+ } finally {
145
+ await dominus.redis.delete("lock:job");
146
+ }
147
+ }
148
+
149
+ // Counters
150
+ await dominus.redis.incr("page:views", 1);
151
+
152
+ // Hash operations
153
+ await dominus.redis.hset("user:123", "email", "john@example.com", { ttl: 3600 });
154
+ const email = await dominus.redis.hget("user:123", "email");
155
+ ```
156
+
157
+ ### File Storage
158
+
159
+ ```typescript
160
+ import { readFileSync } from 'fs';
161
+
162
+ // Upload file
163
+ const data = readFileSync("report.pdf");
164
+ const result = await dominus.files.upload(data, "report.pdf", {
165
+ category: "reports",
166
+ contentType: "application/pdf"
167
+ });
168
+
169
+ // Get download URL
170
+ const download = await dominus.files.download({ id: result.id });
171
+ console.log(download.download_url);
172
+
173
+ // List files
174
+ const files = await dominus.files.list({ category: "reports", prefix: "2025/" });
175
+
176
+ // Delete file
177
+ await dominus.files.delete({ id: result.id });
178
+ ```
179
+
180
+ ### Structured Logging
181
+
182
+ ```typescript
183
+ // Simple logging (auto-captures file and function)
184
+ await dominus.logs.info("User logged in", { user_id: "123" });
185
+ await dominus.logs.error("Payment failed", { order_id: "456" });
186
+
187
+ // With category
188
+ await dominus.logs.info("Cache hit", { key: "user:123" }, "cache");
189
+
190
+ // With exception
191
+ try {
192
+ riskyOperation();
193
+ } catch (error) {
194
+ await dominus.logs.error("Operation failed", {}, { exception: error as Error });
195
+ }
196
+
197
+ // Query logs
198
+ const errors = await dominus.logs.query({ level: "error", limit: 100 });
199
+ ```
200
+
201
+ ### Authentication
202
+
203
+ ```typescript
204
+ // User management
205
+ const user = await dominus.auth.addUser({
206
+ username: "john",
207
+ password: "secure-password",
208
+ email: "john@example.com"
209
+ });
210
+
211
+ // Role management
212
+ const role = await dominus.auth.addRole({
213
+ name: "Editor",
214
+ scopeSlugs: ["read", "write", "publish"]
215
+ });
216
+
217
+ // List users
218
+ const users = await dominus.auth.listUsers();
219
+ ```
220
+
221
+ ### Schema Management (DDL)
222
+
223
+ ```typescript
224
+ // Create table
225
+ await dominus.ddl.createTable("orders", [
226
+ { name: "id", type: "UUID", constraints: ["PRIMARY KEY"] },
227
+ { name: "user_id", type: "UUID", constraints: ["NOT NULL"] },
228
+ { name: "total", type: "DECIMAL(10,2)" },
229
+ { name: "created_at", type: "TIMESTAMPTZ", default: "NOW()" }
230
+ ]);
231
+
232
+ // Add column
233
+ await dominus.ddl.addColumn("orders", {
234
+ name: "status",
235
+ type: "VARCHAR(50)",
236
+ default: "'pending'"
237
+ });
238
+
239
+ // Provision tenant schema
240
+ await dominus.ddl.provisionTenantFromCategory("customer_acme", "healthcare");
241
+ ```
242
+
243
+ ### User Authentication (Portal)
244
+
245
+ ```typescript
246
+ // User login
247
+ const session = await dominus.portal.login(
248
+ "john@example.com",
249
+ "secret123",
250
+ "tenant-uuid"
251
+ );
252
+
253
+ // Get current user
254
+ const me = await dominus.portal.me();
255
+
256
+ // Get navigation (access-filtered)
257
+ const nav = await dominus.portal.getNavigation();
258
+
259
+ // Profile & preferences
260
+ await dominus.portal.updatePreferences({
261
+ theme: "dark",
262
+ timezone: "America/New_York"
263
+ });
264
+
265
+ // Logout
266
+ await dominus.portal.logout();
267
+ ```
268
+
269
+ ### Email Delivery (Courier)
270
+
271
+ ```typescript
272
+ // Send email via Postmark template
273
+ const result = await dominus.courier.send(
274
+ "welcome",
275
+ "user@example.com",
276
+ "noreply@myapp.com",
277
+ { name: "John", product_name: "My App" }
278
+ );
279
+
280
+ // Convenience methods
281
+ await dominus.courier.sendPasswordReset(
282
+ "user@example.com",
283
+ "noreply@myapp.com",
284
+ {
285
+ name: "John",
286
+ resetUrl: "https://myapp.com/reset?token=abc",
287
+ productName: "My App"
288
+ }
289
+ );
290
+ ```
291
+
292
+ ## Error Handling
293
+
294
+ ```typescript
295
+ import {
296
+ dominus,
297
+ DominusError,
298
+ AuthenticationError,
299
+ AuthorizationError,
300
+ NotFoundError,
301
+ ValidationError,
302
+ SecureTableError,
303
+ } from '@carebridge/dominus-sdk';
304
+
305
+ try {
306
+ const user = await dominus.auth.getUser("invalid-id");
307
+ } catch (error) {
308
+ if (error instanceof NotFoundError) {
309
+ console.log(`User not found: ${error.message}`);
310
+ } else if (error instanceof SecureTableError) {
311
+ console.log("Secure table requires 'reason' and 'actor' parameters");
312
+ } else if (error instanceof DominusError) {
313
+ console.log(`Error ${error.statusCode}: ${error.message}`);
314
+ if (error.details) {
315
+ console.log(`Details: ${JSON.stringify(error.details)}`);
316
+ }
317
+ }
318
+ }
319
+ ```
320
+
321
+ ### Error Types
322
+
323
+ | Error | Status | Description |
324
+ |-------|--------|-------------|
325
+ | `AuthenticationError` | 401 | Invalid or missing token |
326
+ | `AuthorizationError` | 403 | Insufficient permissions |
327
+ | `NotFoundError` | 404 | Resource not found |
328
+ | `ValidationError` | 400 | Invalid request data |
329
+ | `ConflictError` | 409 | Duplicate or version conflict |
330
+ | `ServiceError` | 5xx | Backend service error |
331
+ | `SecureTableError` | 403 | Missing reason for secure table |
332
+ | `ConnectionError` | - | Network connection failed |
333
+ | `TimeoutError` | 504 | Request timed out |
334
+
335
+ ## Configuration
336
+
337
+ ### Environment Variables
338
+
339
+ ```bash
340
+ # Required: PSK token for authentication
341
+ export DOMINUS_TOKEN="your-psk-token"
342
+ ```
343
+
344
+ ### Token Resolution
345
+
346
+ The SDK resolves the authentication token from the `DOMINUS_TOKEN` environment variable.
347
+
348
+ ## Architecture
349
+
350
+ ```
351
+ ┌─────────────────┐
352
+ │ Your App │
353
+ │ (Next.js API) │
354
+ └────────┬────────┘
355
+ │ await dominus.db.query(...)
356
+
357
+ ┌─────────────────┐
358
+ │ Dominus SDK │ ← JWT caching, circuit breaker, retries
359
+ │ (this package) │
360
+ └────────┬────────┘
361
+ │ HTTPS (base64-encoded JSON)
362
+
363
+ ┌─────────────────────────────────┐
364
+ │ Dominus Orchestrator │
365
+ │ (Cloud Run FastAPI backend) │
366
+ │ │
367
+ │ ┌─────────┬─────────┬────────┐ │
368
+ │ │ Warden │Guardian │Archivist│ │
369
+ │ │ Scribe │ Smith │Whisperer│ │
370
+ │ │ Herald │ Portal │ Courier │ │
371
+ │ └─────────┴─────────┴────────┘ │
372
+ └─────────────────────────────────┘
373
+ ```
374
+
375
+ ## Next.js Integration
376
+
377
+ ```typescript
378
+ // app/api/users/route.ts
379
+ import { dominus } from 'dominus-sdk-nodejs';
380
+ import { NextRequest, NextResponse } from 'next/server';
381
+
382
+ export async function GET(request: NextRequest) {
383
+ try {
384
+ const users = await dominus.db.query("users", {
385
+ filters: { status: "active" },
386
+ limit: 50
387
+ });
388
+ return NextResponse.json(users);
389
+ } catch (error) {
390
+ return NextResponse.json(
391
+ { error: "Failed to fetch users" },
392
+ { status: 500 }
393
+ );
394
+ }
395
+ }
396
+ ```
397
+
398
+ ## Dependencies
399
+
400
+ - `bcryptjs` - Password hashing
401
+
402
+ ## Version
403
+
404
+ **v1.0.0** - Initial release with full namespace API
405
+
406
+ ## License
407
+
408
+ Proprietary - CareBridge Systems
@@ -0,0 +1,114 @@
1
+ /**
2
+ * CB Dominus SDK for Node.js
3
+ *
4
+ * Ultra-flat async SDK for CareBridge Services.
5
+ *
6
+ * Usage:
7
+ * import { dominus } from 'dominus-sdk-nodejs';
8
+ *
9
+ * // Secrets
10
+ * const value = await dominus.secrets.get("DB_URL");
11
+ * await dominus.secrets.upsert("KEY", "value");
12
+ *
13
+ * // Database
14
+ * const tables = await dominus.db.tables();
15
+ * const users = await dominus.db.query("users", { filters: { status: "active" } });
16
+ * await dominus.db.insert("users", { name: "John" });
17
+ *
18
+ * // Redis
19
+ * await dominus.redis.set("key", "value", { ttl: 3600 });
20
+ * const cached = await dominus.redis.get("key");
21
+ *
22
+ * // Files
23
+ * const result = await dominus.files.upload(buffer, "report.pdf", { category: "reports" });
24
+ * const download = await dominus.files.download({ id: result.id });
25
+ *
26
+ * // Auth
27
+ * const users = await dominus.auth.listUsers();
28
+ * await dominus.auth.addUser({ username: "john", password: "secret" });
29
+ *
30
+ * // DDL
31
+ * await dominus.ddl.createTable("orders", [{ name: "id", type: "UUID" }]);
32
+ *
33
+ * // Logs
34
+ * await dominus.logs.info("User logged in", { user_id: "123" });
35
+ *
36
+ * // Portal
37
+ * const session = await dominus.portal.login("user@example.com", "password", "tenant-id");
38
+ *
39
+ * // Courier
40
+ * await dominus.courier.sendWelcome("user@example.com", "noreply@app.com", { name: "John", productName: "MyApp" });
41
+ *
42
+ * // Open
43
+ * const dsn = await dominus.open.dsn();
44
+ *
45
+ * // Health
46
+ * const status = await dominus.health.check();
47
+ *
48
+ * Configuration:
49
+ * Set DOMINUS_TOKEN environment variable with your PSK token.
50
+ */
51
+ import { SecretsNamespace } from './namespaces/secrets.js';
52
+ import { DbNamespace } from './namespaces/db.js';
53
+ import { RedisNamespace } from './namespaces/redis.js';
54
+ import { FilesNamespace } from './namespaces/files.js';
55
+ import { AuthNamespace } from './namespaces/auth.js';
56
+ import { DdlNamespace } from './namespaces/ddl.js';
57
+ import { LogsNamespace } from './namespaces/logs.js';
58
+ import { PortalNamespace } from './namespaces/portal.js';
59
+ import { CourierNamespace } from './namespaces/courier.js';
60
+ import { OpenNamespace } from './namespaces/open.js';
61
+ import { HealthNamespace } from './namespaces/health.js';
62
+ export { DominusError, AuthenticationError, AuthorizationError, NotFoundError, ValidationError, ConflictError, ServiceError, ConnectionError, TimeoutError, SecureTableError, } from './lib/errors.js';
63
+ export type { DominusClient } from './lib/client.js';
64
+ export type { Secret, UpsertResult } from './namespaces/secrets.js';
65
+ export type { QueryOptions, QueryResult, TableInfo, ColumnInfo } from './namespaces/db.js';
66
+ export type { SetResult, GetResult, ListResult as RedisListResult, SetnxResult, IncrResult, HsetResult, HgetallResult } from './namespaces/redis.js';
67
+ export type { UploadResult, DownloadResult, FetchResult, ListResult, FileInfo } from './namespaces/files.js';
68
+ export type { ColumnDefinition } from './namespaces/ddl.js';
69
+ export type { LogContext, LogEntry, BatchResult } from './namespaces/logs.js';
70
+ export type { Session } from './namespaces/portal.js';
71
+ export type { SendResult } from './namespaces/courier.js';
72
+ export type { HealthStatus } from './namespaces/health.js';
73
+ /**
74
+ * Main Dominus SDK class.
75
+ *
76
+ * Provides namespace-based access to all Dominus services.
77
+ */
78
+ export declare class Dominus {
79
+ private _client;
80
+ /** Secrets management (Warden) */
81
+ readonly secrets: SecretsNamespace;
82
+ /** Database CRUD operations (Scribe) */
83
+ readonly db: DbNamespace;
84
+ /** Redis caching operations (Whisperer) */
85
+ readonly redis: RedisNamespace;
86
+ /** File storage operations (Archivist) */
87
+ readonly files: FilesNamespace;
88
+ /** Authentication & authorization (Guardian) */
89
+ readonly auth: AuthNamespace;
90
+ /** Schema DDL & migrations (Smith) */
91
+ readonly ddl: DdlNamespace;
92
+ /** Structured logging (Herald) */
93
+ readonly logs: LogsNamespace;
94
+ /** User authentication & sessions (Portal) */
95
+ readonly portal: PortalNamespace;
96
+ /** Email delivery (Courier) */
97
+ readonly courier: CourierNamespace;
98
+ /** Direct database access (Scribe Open) */
99
+ readonly open: OpenNamespace;
100
+ /** Health checks */
101
+ readonly health: HealthNamespace;
102
+ constructor();
103
+ /**
104
+ * Get a secret value (shortcut for dominus.secrets.get).
105
+ */
106
+ get(key: string): Promise<unknown>;
107
+ /**
108
+ * Create or update a secret (shortcut for dominus.secrets.upsert).
109
+ */
110
+ upsert(key: string, value: string, comment?: string): Promise<import("./namespaces/secrets.js").UpsertResult>;
111
+ }
112
+ export declare const dominus: Dominus;
113
+ export default dominus;
114
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AAGH,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,M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C;IAEtC,0CAA0C;IAC1C,SAAgB,KAAK,EAAE,cAAc,CAAC;IAEtC,gDAAgD;IAChD,SAAgB,IAAI,EAAE,aAAa,CAAC;IAEpC,sCAAsC;IACtC,SAAgB,GAAG,EAAE,YAAY,CAAC;IAElC,kCAAkC;IAClC,SAAgB,IAAI,EAAE,aAAa,CAAC;IAEpC,8CAA8C;IAC9C,SAAgB,MAAM,EAAE,eAAe,CAAC;IAExC,+BAA+B;IAC/B,SAAgB,OAAO,EAAE,gBAAgB,CAAC;IAE1C,2CAA2C;IAC3C,SAAgB,IAAI,EAAE,aAAa,CAAC;IAEpC,oBAAoB;IACpB,SAAgB,MAAM,EAAE,eAAe,CAAC;;IAuBxC;;OAEG;IACG,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAIxC;;OAEG;IACG,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM;CAG1D;AAGD,eAAO,MAAM,OAAO,SAAgB,CAAC;AAGrC,eAAe,OAAO,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,129 @@
1
+ /**
2
+ * CB Dominus SDK for Node.js
3
+ *
4
+ * Ultra-flat async SDK for CareBridge Services.
5
+ *
6
+ * Usage:
7
+ * import { dominus } from 'dominus-sdk-nodejs';
8
+ *
9
+ * // Secrets
10
+ * const value = await dominus.secrets.get("DB_URL");
11
+ * await dominus.secrets.upsert("KEY", "value");
12
+ *
13
+ * // Database
14
+ * const tables = await dominus.db.tables();
15
+ * const users = await dominus.db.query("users", { filters: { status: "active" } });
16
+ * await dominus.db.insert("users", { name: "John" });
17
+ *
18
+ * // Redis
19
+ * await dominus.redis.set("key", "value", { ttl: 3600 });
20
+ * const cached = await dominus.redis.get("key");
21
+ *
22
+ * // Files
23
+ * const result = await dominus.files.upload(buffer, "report.pdf", { category: "reports" });
24
+ * const download = await dominus.files.download({ id: result.id });
25
+ *
26
+ * // Auth
27
+ * const users = await dominus.auth.listUsers();
28
+ * await dominus.auth.addUser({ username: "john", password: "secret" });
29
+ *
30
+ * // DDL
31
+ * await dominus.ddl.createTable("orders", [{ name: "id", type: "UUID" }]);
32
+ *
33
+ * // Logs
34
+ * await dominus.logs.info("User logged in", { user_id: "123" });
35
+ *
36
+ * // Portal
37
+ * const session = await dominus.portal.login("user@example.com", "password", "tenant-id");
38
+ *
39
+ * // Courier
40
+ * await dominus.courier.sendWelcome("user@example.com", "noreply@app.com", { name: "John", productName: "MyApp" });
41
+ *
42
+ * // Open
43
+ * const dsn = await dominus.open.dsn();
44
+ *
45
+ * // Health
46
+ * const status = await dominus.health.check();
47
+ *
48
+ * Configuration:
49
+ * Set DOMINUS_TOKEN environment variable with your PSK token.
50
+ */
51
+ import { getClient } from './lib/client.js';
52
+ import { SecretsNamespace } from './namespaces/secrets.js';
53
+ import { DbNamespace } from './namespaces/db.js';
54
+ import { RedisNamespace } from './namespaces/redis.js';
55
+ import { FilesNamespace } from './namespaces/files.js';
56
+ import { AuthNamespace } from './namespaces/auth.js';
57
+ import { DdlNamespace } from './namespaces/ddl.js';
58
+ import { LogsNamespace } from './namespaces/logs.js';
59
+ import { PortalNamespace } from './namespaces/portal.js';
60
+ import { CourierNamespace } from './namespaces/courier.js';
61
+ import { OpenNamespace } from './namespaces/open.js';
62
+ import { HealthNamespace } from './namespaces/health.js';
63
+ // Re-export errors for consumers
64
+ export { DominusError, AuthenticationError, AuthorizationError, NotFoundError, ValidationError, ConflictError, ServiceError, ConnectionError, TimeoutError, SecureTableError, } from './lib/errors.js';
65
+ /**
66
+ * Main Dominus SDK class.
67
+ *
68
+ * Provides namespace-based access to all Dominus services.
69
+ */
70
+ export class Dominus {
71
+ _client;
72
+ /** Secrets management (Warden) */
73
+ secrets;
74
+ /** Database CRUD operations (Scribe) */
75
+ db;
76
+ /** Redis caching operations (Whisperer) */
77
+ redis;
78
+ /** File storage operations (Archivist) */
79
+ files;
80
+ /** Authentication & authorization (Guardian) */
81
+ auth;
82
+ /** Schema DDL & migrations (Smith) */
83
+ ddl;
84
+ /** Structured logging (Herald) */
85
+ logs;
86
+ /** User authentication & sessions (Portal) */
87
+ portal;
88
+ /** Email delivery (Courier) */
89
+ courier;
90
+ /** Direct database access (Scribe Open) */
91
+ open;
92
+ /** Health checks */
93
+ health;
94
+ constructor() {
95
+ this._client = getClient();
96
+ // Initialize all namespaces
97
+ this.secrets = new SecretsNamespace(this._client);
98
+ this.db = new DbNamespace(this._client);
99
+ this.redis = new RedisNamespace(this._client);
100
+ this.files = new FilesNamespace(this._client);
101
+ this.auth = new AuthNamespace(this._client);
102
+ this.ddl = new DdlNamespace(this._client);
103
+ this.logs = new LogsNamespace(this._client);
104
+ this.portal = new PortalNamespace(this._client);
105
+ this.courier = new CourierNamespace(this._client);
106
+ this.open = new OpenNamespace(this._client);
107
+ this.health = new HealthNamespace(this._client);
108
+ }
109
+ // ========================================
110
+ // ROOT-LEVEL SHORTCUTS (convenience)
111
+ // ========================================
112
+ /**
113
+ * Get a secret value (shortcut for dominus.secrets.get).
114
+ */
115
+ async get(key) {
116
+ return this.secrets.get(key);
117
+ }
118
+ /**
119
+ * Create or update a secret (shortcut for dominus.secrets.upsert).
120
+ */
121
+ async upsert(key, value, comment) {
122
+ return this.secrets.upsert(key, value, comment);
123
+ }
124
+ }
125
+ // Create and export singleton instance
126
+ export const dominus = new Dominus();
127
+ // Default export for ESM compatibility
128
+ export default dominus;
129
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AAEH,OAAO,EAAE,SAAS,EAAiB,MAAM,iBAAiB,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAA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AuC;AACvC,eAAe,OAAO,CAAC"}
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Core HTTP Client for Dominus SDK
3
+ *
4
+ * Handles JWT management, base64 encoding/decoding, retries, and circuit breaker.
5
+ */
6
+ export interface RequestOptions {
7
+ endpoint: string;
8
+ method?: 'GET' | 'POST' | 'PUT' | 'DELETE';
9
+ body?: Record<string, unknown>;
10
+ }
11
+ /**
12
+ * Main Dominus client class
13
+ */
14
+ export declare class DominusClient {
15
+ private token;
16
+ private baseUrl;
17
+ constructor(hardcodedToken?: string);
18
+ /**
19
+ * Validate token on first use
20
+ */
21
+ private validate;
22
+ /**
23
+ * Make an authenticated request to the orchestrator
24
+ */
25
+ request<T = unknown>(options: RequestOptions): Promise<T>;
26
+ /**
27
+ * Health check endpoint
28
+ */
29
+ healthCheck(): Promise<Record<string, unknown>>;
30
+ }
31
+ export declare function getClient(hardcodedToken?: string): DominusClient;
32
+ //# sourceMappingURL=client.d.ts.map