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.
- package/LLM-GUIDE.md +537 -0
- package/README.md +408 -0
- package/dist/index.d.ts +114 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +129 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/client.d.ts +32 -0
- package/dist/lib/client.d.ts.map +1 -0
- package/dist/lib/client.js +374 -0
- package/dist/lib/client.js.map +1 -0
- package/dist/lib/config.d.ts +20 -0
- package/dist/lib/config.d.ts.map +1 -0
- package/dist/lib/config.js +35 -0
- package/dist/lib/config.js.map +1 -0
- package/dist/lib/errors.d.ts +77 -0
- package/dist/lib/errors.d.ts.map +1 -0
- package/dist/lib/errors.js +134 -0
- package/dist/lib/errors.js.map +1 -0
- package/dist/namespaces/auth.d.ts +65 -0
- package/dist/namespaces/auth.d.ts.map +1 -0
- package/dist/namespaces/auth.js +266 -0
- package/dist/namespaces/auth.js.map +1 -0
- package/dist/namespaces/courier.d.ts +67 -0
- package/dist/namespaces/courier.d.ts.map +1 -0
- package/dist/namespaces/courier.js +90 -0
- package/dist/namespaces/courier.js.map +1 -0
- package/dist/namespaces/db.d.ts +117 -0
- package/dist/namespaces/db.d.ts.map +1 -0
- package/dist/namespaces/db.js +149 -0
- package/dist/namespaces/db.js.map +1 -0
- package/dist/namespaces/ddl.d.ts +84 -0
- package/dist/namespaces/ddl.d.ts.map +1 -0
- package/dist/namespaces/ddl.js +211 -0
- package/dist/namespaces/ddl.js.map +1 -0
- package/dist/namespaces/files.d.ts +107 -0
- package/dist/namespaces/files.d.ts.map +1 -0
- package/dist/namespaces/files.js +161 -0
- package/dist/namespaces/files.js.map +1 -0
- package/dist/namespaces/health.d.ts +30 -0
- package/dist/namespaces/health.d.ts.map +1 -0
- package/dist/namespaces/health.js +66 -0
- package/dist/namespaces/health.js.map +1 -0
- package/dist/namespaces/logs.d.ts +97 -0
- package/dist/namespaces/logs.d.ts.map +1 -0
- package/dist/namespaces/logs.js +194 -0
- package/dist/namespaces/logs.js.map +1 -0
- package/dist/namespaces/open.d.ts +27 -0
- package/dist/namespaces/open.d.ts.map +1 -0
- package/dist/namespaces/open.js +46 -0
- package/dist/namespaces/open.js.map +1 -0
- package/dist/namespaces/portal.d.ts +124 -0
- package/dist/namespaces/portal.d.ts.map +1 -0
- package/dist/namespaces/portal.js +270 -0
- package/dist/namespaces/portal.js.map +1 -0
- package/dist/namespaces/redis.d.ts +144 -0
- package/dist/namespaces/redis.d.ts.map +1 -0
- package/dist/namespaces/redis.js +218 -0
- package/dist/namespaces/redis.js.map +1 -0
- package/dist/namespaces/secrets.d.ts +50 -0
- package/dist/namespaces/secrets.d.ts.map +1 -0
- package/dist/namespaces/secrets.js +93 -0
- package/dist/namespaces/secrets.js.map +1 -0
- package/package.json +45 -0
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Files Namespace - Archivist object storage operations.
|
|
3
|
+
*
|
|
4
|
+
* Provides file upload, download, and management via B2 object storage.
|
|
5
|
+
*/
|
|
6
|
+
export class FilesNamespace {
|
|
7
|
+
client;
|
|
8
|
+
constructor(client) {
|
|
9
|
+
this.client = client;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Upload a file to object storage.
|
|
13
|
+
*
|
|
14
|
+
* @param data - File content as Buffer
|
|
15
|
+
* @param filename - Original filename
|
|
16
|
+
* @param options - Upload options
|
|
17
|
+
*/
|
|
18
|
+
async upload(data, filename, options = {}) {
|
|
19
|
+
const { contentType, category = 'general', path, tags, compliance = false, actor, retentionDays = 90, } = options;
|
|
20
|
+
const fileB64 = data.toString('base64');
|
|
21
|
+
const body = {
|
|
22
|
+
file_content: fileB64,
|
|
23
|
+
filename,
|
|
24
|
+
category,
|
|
25
|
+
logical_path: path || filename,
|
|
26
|
+
};
|
|
27
|
+
if (contentType)
|
|
28
|
+
body.content_type = contentType;
|
|
29
|
+
if (tags)
|
|
30
|
+
body.tags = tags;
|
|
31
|
+
if (compliance) {
|
|
32
|
+
body.is_compliance = true;
|
|
33
|
+
body.retention_days = retentionDays;
|
|
34
|
+
if (actor)
|
|
35
|
+
body.owner_user_id = actor;
|
|
36
|
+
}
|
|
37
|
+
return this.client.request({
|
|
38
|
+
endpoint: '/api/archivist/upload',
|
|
39
|
+
body,
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Get a presigned download URL for a file.
|
|
44
|
+
*
|
|
45
|
+
* @param options - File identifier and options
|
|
46
|
+
*/
|
|
47
|
+
async download(options) {
|
|
48
|
+
const { id, category, path, actor, expiresSeconds = 3600 } = options;
|
|
49
|
+
const body = { expires_seconds: expiresSeconds };
|
|
50
|
+
if (id)
|
|
51
|
+
body.id = id;
|
|
52
|
+
if (category)
|
|
53
|
+
body.category = category;
|
|
54
|
+
if (path)
|
|
55
|
+
body.logical_path = path;
|
|
56
|
+
if (actor)
|
|
57
|
+
body.actor_user_id = actor;
|
|
58
|
+
return this.client.request({
|
|
59
|
+
endpoint: '/api/archivist/download',
|
|
60
|
+
body,
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Fetch file content directly.
|
|
65
|
+
*
|
|
66
|
+
* @param options - File identifier
|
|
67
|
+
*/
|
|
68
|
+
async fetch(options) {
|
|
69
|
+
const { id, category, path, actor } = options;
|
|
70
|
+
const body = {};
|
|
71
|
+
if (id)
|
|
72
|
+
body.id = id;
|
|
73
|
+
if (category)
|
|
74
|
+
body.category = category;
|
|
75
|
+
if (path)
|
|
76
|
+
body.logical_path = path;
|
|
77
|
+
if (actor)
|
|
78
|
+
body.actor_user_id = actor;
|
|
79
|
+
return this.client.request({
|
|
80
|
+
endpoint: '/api/archivist/fetch',
|
|
81
|
+
body,
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* List files with optional filtering.
|
|
86
|
+
*
|
|
87
|
+
* @param options - List options
|
|
88
|
+
*/
|
|
89
|
+
async list(options = {}) {
|
|
90
|
+
const { category, prefix, limit = 100, cursor } = options;
|
|
91
|
+
const body = { limit };
|
|
92
|
+
if (category)
|
|
93
|
+
body.category = category;
|
|
94
|
+
if (prefix)
|
|
95
|
+
body.prefix = prefix;
|
|
96
|
+
if (cursor)
|
|
97
|
+
body.cursor = cursor;
|
|
98
|
+
return this.client.request({
|
|
99
|
+
endpoint: '/api/archivist/list',
|
|
100
|
+
body,
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Delete a file.
|
|
105
|
+
*
|
|
106
|
+
* @param options - File identifier
|
|
107
|
+
*/
|
|
108
|
+
async delete(options) {
|
|
109
|
+
const { id, category, path, actor } = options;
|
|
110
|
+
const body = {};
|
|
111
|
+
if (id)
|
|
112
|
+
body.id = id;
|
|
113
|
+
if (category)
|
|
114
|
+
body.category = category;
|
|
115
|
+
if (path)
|
|
116
|
+
body.logical_path = path;
|
|
117
|
+
if (actor)
|
|
118
|
+
body.actor_user_id = actor;
|
|
119
|
+
return this.client.request({
|
|
120
|
+
endpoint: '/api/archivist/delete',
|
|
121
|
+
body,
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Move or rename a file.
|
|
126
|
+
*
|
|
127
|
+
* @param fileId - File UUID
|
|
128
|
+
* @param options - New category and/or path
|
|
129
|
+
*/
|
|
130
|
+
async move(fileId, options) {
|
|
131
|
+
const { newCategory, newPath } = options;
|
|
132
|
+
const body = { id: fileId };
|
|
133
|
+
if (newCategory)
|
|
134
|
+
body.new_category = newCategory;
|
|
135
|
+
if (newPath)
|
|
136
|
+
body.new_logical_path = newPath;
|
|
137
|
+
return this.client.request({
|
|
138
|
+
endpoint: '/api/archivist/move',
|
|
139
|
+
body,
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Update file metadata.
|
|
144
|
+
*
|
|
145
|
+
* @param fileId - File UUID
|
|
146
|
+
* @param options - New metadata
|
|
147
|
+
*/
|
|
148
|
+
async updateMeta(fileId, options) {
|
|
149
|
+
const { tags, description } = options;
|
|
150
|
+
const body = { id: fileId };
|
|
151
|
+
if (tags !== undefined)
|
|
152
|
+
body.tags = tags;
|
|
153
|
+
if (description !== undefined)
|
|
154
|
+
body.description = description;
|
|
155
|
+
return this.client.request({
|
|
156
|
+
endpoint: '/api/archivist/update',
|
|
157
|
+
body,
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
//# sourceMappingURL=files.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"files.js","sourceRoot":"","sources":["../../src/namespaces/files.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAoCH,MAAM,OAAO,cAAc;IACL;IAApB,YAAoB,MAAqB;QAArB,WAAM,GAAN,MAAM,CAAe;IAAG,CAAC;IAE7C;;;;;;OAMG;IACH,KAAK,CAAC,MAAM,CACV,IAAY,EACZ,QAAgB,EAChB,UAQI,EAAE;QAEN,MAAM,EACJ,WAAW,EACX,QAAQ,GAAG,SAAS,EACpB,IAAI,EACJ,IAAI,EACJ,UAAU,GAAG,KAAK,EAClB,KAAK,EACL,aAAa,GAAG,EAAE,GACnB,GAAG,OAAO,CAAC;QAEZ,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;QAExC,MAAM,IAAI,GAA4B;YACpC,YAAY,EAAE,OAAO;YACrB,QAAQ;YACR,QAAQ;YACR,YAAY,EAAE,IAAI,IAAI,QAAQ;SAC/B,CAAC;QAEF,IAAI,WAAW;YAAE,IAAI,CAAC,YAAY,GAAG,WAAW,CAAC;QACjD,IAAI,IAAI;YAAE,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QAE3B,IAAI,UAAU,EAAE,CAAC;YACf,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC;YAC1B,IAAI,CAAC,cAAc,GAAG,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,EAAE,GAAG,OAAO,CAAC;QAEzC,MAAM,IAAI,GAA4B,EAAE,EAAE,EAAE,MAAM,EAAE,CAAC;QAErD,IAAI,WAAW;YAAE,IAAI,CAAC,YAAY,GAAG,WAAW,CAAC;QACjD,IAAI,OAAO;YAAE,IAAI,CAAC,gBAAgB,GAAG,OAAO,CAAC;QAE7C,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC;YACzB,QAAQ,EAAE,qBAAqB;YAC/B,IAAI;SACL,CAAC,CAAC;IACL,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,UAAU,CACd,MAAc,EACd,OAAgE;QAEhE,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC;QAEtC,MAAM,IAAI,GAA4B,EAAE,EAAE,EAAE,MAAM,EAAE,CAAC;QAErD,IAAI,IAAI,KAAK,SAAS;YAAE,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACzC,IAAI,WAAW,KAAK,SAAS;YAAE,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAE9D,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC;YACzB,QAAQ,EAAE,uBAAuB;YACjC,IAAI;SACL,CAAC,CAAC;IACL,CAAC;CACF"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Health Namespace - Service health check operations.
|
|
3
|
+
*
|
|
4
|
+
* Provides health check endpoints for the orchestrator service.
|
|
5
|
+
*/
|
|
6
|
+
import type { DominusClient } from '../lib/client.js';
|
|
7
|
+
export interface HealthStatus {
|
|
8
|
+
status: string;
|
|
9
|
+
latency_ms?: number;
|
|
10
|
+
[key: string]: unknown;
|
|
11
|
+
}
|
|
12
|
+
export declare class HealthNamespace {
|
|
13
|
+
private client;
|
|
14
|
+
constructor(client: DominusClient);
|
|
15
|
+
/**
|
|
16
|
+
* Perform comprehensive health check of orchestrator and dependencies.
|
|
17
|
+
*/
|
|
18
|
+
check(): Promise<HealthStatus>;
|
|
19
|
+
/**
|
|
20
|
+
* Simple ping check (fastest response).
|
|
21
|
+
*/
|
|
22
|
+
ping(): Promise<{
|
|
23
|
+
status: string;
|
|
24
|
+
}>;
|
|
25
|
+
/**
|
|
26
|
+
* Warmup request (triggers cold start if needed).
|
|
27
|
+
*/
|
|
28
|
+
warmup(): Promise<Record<string, unknown>>;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=health.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"health.d.ts","sourceRoot":"","sources":["../../src/namespaces/health.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAGtD,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,qBAAa,eAAe;IACd,OAAO,CAAC,MAAM;gBAAN,MAAM,EAAE,aAAa;IAEzC;;OAEG;IACG,KAAK,IAAI,OAAO,CAAC,YAAY,CAAC;IAoCpC;;OAEG;IACG,IAAI,IAAI,OAAO,CAAC;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IAOzC;;OAEG;IACG,MAAM,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAMjD"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Health Namespace - Service health check operations.
|
|
3
|
+
*
|
|
4
|
+
* Provides health check endpoints for the orchestrator service.
|
|
5
|
+
*/
|
|
6
|
+
import { BASE_URL } from '../lib/config.js';
|
|
7
|
+
export class HealthNamespace {
|
|
8
|
+
client;
|
|
9
|
+
constructor(client) {
|
|
10
|
+
this.client = client;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Perform comprehensive health check of orchestrator and dependencies.
|
|
14
|
+
*/
|
|
15
|
+
async check() {
|
|
16
|
+
const start = Date.now();
|
|
17
|
+
try {
|
|
18
|
+
const response = await fetch(`${BASE_URL}/api/health`, {
|
|
19
|
+
method: 'GET',
|
|
20
|
+
headers: {
|
|
21
|
+
'Accept': 'application/json',
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
const latencyMs = Date.now() - start;
|
|
25
|
+
if (!response.ok) {
|
|
26
|
+
return {
|
|
27
|
+
status: 'unhealthy',
|
|
28
|
+
latency_ms: latencyMs,
|
|
29
|
+
error: `HTTP ${response.status}`,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
const data = await response.json();
|
|
33
|
+
return {
|
|
34
|
+
status: data.status || 'healthy',
|
|
35
|
+
...data,
|
|
36
|
+
latency_ms: latencyMs,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
catch (error) {
|
|
40
|
+
return {
|
|
41
|
+
status: 'unhealthy',
|
|
42
|
+
latency_ms: Date.now() - start,
|
|
43
|
+
error: error instanceof Error ? error.message : 'Connection failed',
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Simple ping check (fastest response).
|
|
49
|
+
*/
|
|
50
|
+
async ping() {
|
|
51
|
+
return this.client.request({
|
|
52
|
+
endpoint: '/api/health/ping',
|
|
53
|
+
method: 'GET',
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Warmup request (triggers cold start if needed).
|
|
58
|
+
*/
|
|
59
|
+
async warmup() {
|
|
60
|
+
return this.client.request({
|
|
61
|
+
endpoint: '/api/health/warmup',
|
|
62
|
+
method: 'GET',
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=health.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"health.js","sourceRoot":"","sources":["../../src/namespaces/health.ts"],"names":[],"mappings":"AAA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AE,kBAAkB;YAC5B,MAAM,EAAE,KAAK;SACd,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,MAAM;QACV,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC;YACzB,QAAQ,EAAE,oBAAoB;YAC9B,MAAM,EAAE,KAAK;SACd,CAAC,CAAC;IACL,CAAC;CACF"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Logs Namespace - Herald structured logging operations.
|
|
3
|
+
*
|
|
4
|
+
* Provides zero-friction logging to BetterStack via Herald service.
|
|
5
|
+
* SDK automatically captures callsite (file, function) - users just call:
|
|
6
|
+
* await dominus.logs.info("message", { key: "value" })
|
|
7
|
+
*/
|
|
8
|
+
import type { DominusClient } from '../lib/client.js';
|
|
9
|
+
export interface LogContext {
|
|
10
|
+
[key: string]: unknown;
|
|
11
|
+
}
|
|
12
|
+
export interface LogEntry {
|
|
13
|
+
level: string;
|
|
14
|
+
message: string;
|
|
15
|
+
context?: LogContext;
|
|
16
|
+
category?: string;
|
|
17
|
+
file?: string;
|
|
18
|
+
function?: string;
|
|
19
|
+
dt?: string;
|
|
20
|
+
[key: string]: unknown;
|
|
21
|
+
}
|
|
22
|
+
export interface BatchResult {
|
|
23
|
+
total: number;
|
|
24
|
+
stored: number;
|
|
25
|
+
failed: number;
|
|
26
|
+
}
|
|
27
|
+
export declare class LogsNamespace {
|
|
28
|
+
private client;
|
|
29
|
+
constructor(client: DominusClient);
|
|
30
|
+
/**
|
|
31
|
+
* Capture callsite information from the call stack.
|
|
32
|
+
*/
|
|
33
|
+
private captureCallsite;
|
|
34
|
+
/**
|
|
35
|
+
* Fallback log to stderr when backend unavailable.
|
|
36
|
+
*/
|
|
37
|
+
private fallbackLog;
|
|
38
|
+
/**
|
|
39
|
+
* Internal log method with callsite capture.
|
|
40
|
+
*/
|
|
41
|
+
private _log;
|
|
42
|
+
/**
|
|
43
|
+
* Log debug message.
|
|
44
|
+
*/
|
|
45
|
+
debug(message: string, context?: LogContext, category?: string): Promise<boolean>;
|
|
46
|
+
/**
|
|
47
|
+
* Log info message.
|
|
48
|
+
*/
|
|
49
|
+
info(message: string, context?: LogContext, category?: string): Promise<boolean>;
|
|
50
|
+
/**
|
|
51
|
+
* Log notice message.
|
|
52
|
+
*/
|
|
53
|
+
notice(message: string, context?: LogContext, category?: string): Promise<boolean>;
|
|
54
|
+
/**
|
|
55
|
+
* Log warning message.
|
|
56
|
+
*/
|
|
57
|
+
warn(message: string, context?: LogContext, category?: string): Promise<boolean>;
|
|
58
|
+
/**
|
|
59
|
+
* Log error message.
|
|
60
|
+
*/
|
|
61
|
+
error(message: string, context?: LogContext, options?: {
|
|
62
|
+
category?: string;
|
|
63
|
+
exception?: Error;
|
|
64
|
+
}): Promise<boolean>;
|
|
65
|
+
/**
|
|
66
|
+
* Log critical message.
|
|
67
|
+
*/
|
|
68
|
+
critical(message: string, context?: LogContext, options?: {
|
|
69
|
+
category?: string;
|
|
70
|
+
exception?: Error;
|
|
71
|
+
}): Promise<boolean>;
|
|
72
|
+
/**
|
|
73
|
+
* Query logs from Herald.
|
|
74
|
+
*/
|
|
75
|
+
query(options?: {
|
|
76
|
+
level?: string;
|
|
77
|
+
category?: string;
|
|
78
|
+
startTime?: string;
|
|
79
|
+
endTime?: string;
|
|
80
|
+
file?: string;
|
|
81
|
+
function?: string;
|
|
82
|
+
search?: string;
|
|
83
|
+
limit?: number;
|
|
84
|
+
project?: string;
|
|
85
|
+
environment?: string;
|
|
86
|
+
}): Promise<LogEntry[]>;
|
|
87
|
+
/**
|
|
88
|
+
* Send multiple log events in one request.
|
|
89
|
+
*/
|
|
90
|
+
batch(events: Array<{
|
|
91
|
+
level: string;
|
|
92
|
+
message: string;
|
|
93
|
+
context?: LogContext;
|
|
94
|
+
category?: string;
|
|
95
|
+
}>): Promise<BatchResult>;
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=logs.d.ts.map
|
|
@@ -0,0 +1 @@
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GAAG,OAAO,CAAC,WAAW,CAAC;CAuB1B"}
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Logs Namespace - Herald structured logging operations.
|
|
3
|
+
*
|
|
4
|
+
* Provides zero-friction logging to BetterStack via Herald service.
|
|
5
|
+
* SDK automatically captures callsite (file, function) - users just call:
|
|
6
|
+
* await dominus.logs.info("message", { key: "value" })
|
|
7
|
+
*/
|
|
8
|
+
export class LogsNamespace {
|
|
9
|
+
client;
|
|
10
|
+
constructor(client) {
|
|
11
|
+
this.client = client;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Capture callsite information from the call stack.
|
|
15
|
+
*/
|
|
16
|
+
captureCallsite() {
|
|
17
|
+
try {
|
|
18
|
+
const err = new Error();
|
|
19
|
+
const stack = err.stack?.split('\n') || [];
|
|
20
|
+
// Skip: Error, captureCallsite, _log, public method, caller
|
|
21
|
+
const callerLine = stack[4] || stack[3] || '';
|
|
22
|
+
// Parse stack line like "at functionName (file:line:col)" or "at file:line:col"
|
|
23
|
+
const match = callerLine.match(/at\s+(?:(.+?)\s+\()?(.+?)(?::\d+:\d+)?\)?$/);
|
|
24
|
+
if (match) {
|
|
25
|
+
let filepath = match[2] || '';
|
|
26
|
+
const func = match[1];
|
|
27
|
+
// Normalize filepath - keep last 3 path components
|
|
28
|
+
const parts = filepath.split(/[/\\]/);
|
|
29
|
+
if (parts.length > 3) {
|
|
30
|
+
filepath = parts.slice(-3).join('/');
|
|
31
|
+
}
|
|
32
|
+
return { file: filepath || undefined, func: func || undefined };
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
catch {
|
|
36
|
+
// Ignore callsite capture errors
|
|
37
|
+
}
|
|
38
|
+
return {};
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Fallback log to stderr when backend unavailable.
|
|
42
|
+
*/
|
|
43
|
+
fallbackLog(level, message, context) {
|
|
44
|
+
try {
|
|
45
|
+
const entry = {
|
|
46
|
+
dt: new Date().toISOString(),
|
|
47
|
+
level: level.toUpperCase(),
|
|
48
|
+
message,
|
|
49
|
+
_fallback: true,
|
|
50
|
+
};
|
|
51
|
+
if (context) {
|
|
52
|
+
entry.context = context;
|
|
53
|
+
}
|
|
54
|
+
console.error(JSON.stringify(entry));
|
|
55
|
+
}
|
|
56
|
+
catch {
|
|
57
|
+
// Ignore
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Internal log method with callsite capture.
|
|
62
|
+
*/
|
|
63
|
+
async _log(level, message, context, category, exception) {
|
|
64
|
+
const { file, func } = this.captureCallsite();
|
|
65
|
+
const body = {
|
|
66
|
+
level,
|
|
67
|
+
message,
|
|
68
|
+
};
|
|
69
|
+
if (context)
|
|
70
|
+
body.context = context;
|
|
71
|
+
if (category)
|
|
72
|
+
body.category = category;
|
|
73
|
+
if (file)
|
|
74
|
+
body.file = file;
|
|
75
|
+
if (func)
|
|
76
|
+
body.function = func;
|
|
77
|
+
if (exception) {
|
|
78
|
+
body.context = {
|
|
79
|
+
...(body.context || {}),
|
|
80
|
+
exception: {
|
|
81
|
+
type: exception.name,
|
|
82
|
+
message: exception.message,
|
|
83
|
+
},
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
try {
|
|
87
|
+
const result = await this.client.request({
|
|
88
|
+
endpoint: '/api/herald/log',
|
|
89
|
+
body,
|
|
90
|
+
});
|
|
91
|
+
return result.stored ?? false;
|
|
92
|
+
}
|
|
93
|
+
catch {
|
|
94
|
+
// Never raise - fallback to local
|
|
95
|
+
this.fallbackLog(level, message, context);
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Log debug message.
|
|
101
|
+
*/
|
|
102
|
+
async debug(message, context, category) {
|
|
103
|
+
return this._log('debug', message, context, category);
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Log info message.
|
|
107
|
+
*/
|
|
108
|
+
async info(message, context, category) {
|
|
109
|
+
return this._log('info', message, context, category);
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Log notice message.
|
|
113
|
+
*/
|
|
114
|
+
async notice(message, context, category) {
|
|
115
|
+
return this._log('notice', message, context, category);
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Log warning message.
|
|
119
|
+
*/
|
|
120
|
+
async warn(message, context, category) {
|
|
121
|
+
return this._log('warn', message, context, category);
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Log error message.
|
|
125
|
+
*/
|
|
126
|
+
async error(message, context, options) {
|
|
127
|
+
return this._log('error', message, context, options?.category, options?.exception);
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Log critical message.
|
|
131
|
+
*/
|
|
132
|
+
async critical(message, context, options) {
|
|
133
|
+
return this._log('critical', message, context, options?.category, options?.exception);
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Query logs from Herald.
|
|
137
|
+
*/
|
|
138
|
+
async query(options = {}) {
|
|
139
|
+
const { level, category, startTime, endTime, file, function: func, search, limit = 100, project, environment, } = options;
|
|
140
|
+
const body = { limit };
|
|
141
|
+
if (level)
|
|
142
|
+
body.level = level;
|
|
143
|
+
if (category)
|
|
144
|
+
body.category = category;
|
|
145
|
+
if (startTime)
|
|
146
|
+
body.start_time = startTime;
|
|
147
|
+
if (endTime)
|
|
148
|
+
body.end_time = endTime;
|
|
149
|
+
if (file)
|
|
150
|
+
body.file = file;
|
|
151
|
+
if (func)
|
|
152
|
+
body.function = func;
|
|
153
|
+
if (search)
|
|
154
|
+
body.search = search;
|
|
155
|
+
if (project)
|
|
156
|
+
body.project = project;
|
|
157
|
+
if (environment)
|
|
158
|
+
body.environment = environment;
|
|
159
|
+
try {
|
|
160
|
+
const result = await this.client.request({
|
|
161
|
+
endpoint: '/api/herald/query',
|
|
162
|
+
body,
|
|
163
|
+
});
|
|
164
|
+
return result.logs ?? [];
|
|
165
|
+
}
|
|
166
|
+
catch {
|
|
167
|
+
return [];
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Send multiple log events in one request.
|
|
172
|
+
*/
|
|
173
|
+
async batch(events) {
|
|
174
|
+
try {
|
|
175
|
+
const result = await this.client.request({
|
|
176
|
+
endpoint: '/api/herald/batch',
|
|
177
|
+
body: { events: events.slice(0, 100) },
|
|
178
|
+
});
|
|
179
|
+
return result;
|
|
180
|
+
}
|
|
181
|
+
catch {
|
|
182
|
+
// Fallback - log each locally
|
|
183
|
+
for (const event of events) {
|
|
184
|
+
this.fallbackLog(event.level || 'info', event.message || '', event.context);
|
|
185
|
+
}
|
|
186
|
+
return {
|
|
187
|
+
total: events.length,
|
|
188
|
+
stored: 0,
|
|
189
|
+
failed: events.length,
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
//# sourceMappingURL=logs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logs.js","sourceRoot":"","sources":["../../src/namespaces/logs.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAyBH,MAAM,OAAO,aAAa;IACJ;IAApB,YAAoB,MAAqB;QAArB,WAAM,GAAN,MAAM,CAAe;IAAG,CAAC;IAE7C;;OAEG;IACK,eAAe;QACrB,IAAI,CAAC;YACH,MAAM,GAAG,GAAG,IAAI,KAAK,EAAE,CAAC;YACxB,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;YAC3C,4DAA4D;YAC5D,MAAM,UAAU,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;YAE9C,gFAAgF;YAChF,MAAM,KAAK,GAAG,UAAU,CAAC,KAAK,CAAC,4CAA4C,CAAC,CAAC;YAE7E,IAAI,KAAK,EAAE,CAAC;gBACV,IAAI,QAAQ,GAA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AAC;gBACT,MAAM,EAAE,MAAM,CAAC,MAAM;aACtB,CAAC;QACJ,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Open Namespace - Direct database access operations.
|
|
3
|
+
*
|
|
4
|
+
* Provides DSN retrieval and raw SQL execution for advanced use cases.
|
|
5
|
+
*/
|
|
6
|
+
import type { DominusClient } from '../lib/client.js';
|
|
7
|
+
export declare class OpenNamespace {
|
|
8
|
+
private client;
|
|
9
|
+
constructor(client: DominusClient);
|
|
10
|
+
/**
|
|
11
|
+
* Get the PostgreSQL connection DSN.
|
|
12
|
+
*
|
|
13
|
+
* Returns the complete PostgreSQL connection URI that can be
|
|
14
|
+
* used directly by clients to connect to the database.
|
|
15
|
+
*/
|
|
16
|
+
dsn(): Promise<string>;
|
|
17
|
+
/**
|
|
18
|
+
* Execute raw SQL query.
|
|
19
|
+
*
|
|
20
|
+
* Use with caution - this bypasses most safety checks.
|
|
21
|
+
*
|
|
22
|
+
* @param sql - SQL query string
|
|
23
|
+
* @param params - Optional parameter dictionary
|
|
24
|
+
*/
|
|
25
|
+
execute(sql: string, params?: Record<string, unknown>): Promise<Record<string, unknown>>;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=open.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"open.d.ts","sourceRoot":"","sources":["../../src/namespaces/open.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEtD,qBAAa,aAAa;IACZ,OAAO,CAAC,MAAM;gBAAN,MAAM,EAAE,aAAa;IAEzC;;;;;OAKG;IACG,GAAG,IAAI,OAAO,CAAC,MAAM,CAAC;IAY5B;;;;;;;OAOG;IACG,OAAO,CACX,GAAG,EAAE,MAAM,EACX,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC/B,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAWpC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Open Namespace - Direct database access operations.
|
|
3
|
+
*
|
|
4
|
+
* Provides DSN retrieval and raw SQL execution for advanced use cases.
|
|
5
|
+
*/
|
|
6
|
+
export class OpenNamespace {
|
|
7
|
+
client;
|
|
8
|
+
constructor(client) {
|
|
9
|
+
this.client = client;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Get the PostgreSQL connection DSN.
|
|
13
|
+
*
|
|
14
|
+
* Returns the complete PostgreSQL connection URI that can be
|
|
15
|
+
* used directly by clients to connect to the database.
|
|
16
|
+
*/
|
|
17
|
+
async dsn() {
|
|
18
|
+
const result = await this.client.request({
|
|
19
|
+
endpoint: '/api/scribe/open/dsn',
|
|
20
|
+
method: 'GET',
|
|
21
|
+
});
|
|
22
|
+
if (typeof result === 'string') {
|
|
23
|
+
return result;
|
|
24
|
+
}
|
|
25
|
+
return result.dsn || result.connection_string || '';
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Execute raw SQL query.
|
|
29
|
+
*
|
|
30
|
+
* Use with caution - this bypasses most safety checks.
|
|
31
|
+
*
|
|
32
|
+
* @param sql - SQL query string
|
|
33
|
+
* @param params - Optional parameter dictionary
|
|
34
|
+
*/
|
|
35
|
+
async execute(sql, params) {
|
|
36
|
+
const body = { sql };
|
|
37
|
+
if (params) {
|
|
38
|
+
body.params = params;
|
|
39
|
+
}
|
|
40
|
+
return this.client.request({
|
|
41
|
+
endpoint: '/api/scribe/open/execute',
|
|
42
|
+
body,
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=open.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"open.js","sourceRoot":"","sources":["../../src/namespaces/open.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,MAAM,OAAO,aAAa;IACJ;IAApB,YAAoB,MAAqB;QAArB,WAAM,GAAN,MAAM,CAAe;IAAG,CAAC;IAE7C;;;;;OAKG;IACH,KAAK,CAAC,GAAG;QACP,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,CAAwD;YAC9F,QAAQ,EAAE,sBAAsB;YAChC,MAAM,EAAE,KAAK;SACd,CAAC,CAAC;QAEH,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;YAC/B,OAAO,MAAM,CAAC;QAChB,CAAC;QACD,OAAO,MAAM,CAAC,GAAG,IAAI,MAAM,CAAC,iBAAiB,IAAI,EAAE,CAAC;IACtD,CAAC;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,OAAO,CACX,GAAW,EACX,MAAgC;QAEhC,MAAM,IAAI,GAA4B,EAAE,GAAG,EAAE,CAAC;QAC9C,IAAI,MAAM,EAAE,CAAC;YACX,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACvB,CAAC;QAED,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC;YACzB,QAAQ,EAAE,0BAA0B;YACpC,IAAI;SACL,CAAC,CAAC;IACL,CAAC;CACF"}
|