@zintrust/core 0.4.83 → 0.4.84
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/package.json +1 -1
- package/src/index.js +3 -3
- package/src/orm/adapters/MySQLProxyAdapter.d.ts.map +1 -1
- package/src/orm/adapters/MySQLProxyAdapter.js +62 -1
- package/src/proxy/d1/ZintrustD1Proxy.d.ts.map +1 -1
- package/src/proxy/d1/ZintrustD1Proxy.js +6 -6
- package/src/proxy/kv/ZintrustKvProxy.js +7 -7
- package/src/trace/SystemTraceWorkerBridge.d.ts +7 -0
- package/src/trace/SystemTraceWorkerBridge.d.ts.map +1 -0
- package/src/trace/SystemTraceWorkerBridge.js +35 -0
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @zintrust/core v0.4.
|
|
2
|
+
* @zintrust/core v0.4.84
|
|
3
3
|
*
|
|
4
4
|
* ZinTrust Framework - Production-Grade TypeScript Backend
|
|
5
5
|
* Built for performance, type safety, and exceptional developer experience
|
|
6
6
|
*
|
|
7
7
|
* Build Information:
|
|
8
|
-
* Built: 2026-04-08T17:
|
|
8
|
+
* Built: 2026-04-08T17:43:03.695Z
|
|
9
9
|
* Node: >=20.0.0
|
|
10
10
|
* License: MIT
|
|
11
11
|
*
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
* Available at runtime for debugging and health checks
|
|
22
22
|
*/
|
|
23
23
|
export const ZINTRUST_VERSION = '0.1.41';
|
|
24
|
-
export const ZINTRUST_BUILD_DATE = '2026-04-08T17:
|
|
24
|
+
export const ZINTRUST_BUILD_DATE = '2026-04-08T17:43:03.659Z'; // Replaced during build
|
|
25
25
|
export { Application } from './boot/Application.js';
|
|
26
26
|
export { AwsSigV4 } from './common/index.js';
|
|
27
27
|
export { SignedRequest } from './security/SignedRequest.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MySQLProxyAdapter.d.ts","sourceRoot":"","sources":["../../../../src/orm/adapters/MySQLProxyAdapter.ts"],"names":[],"mappings":"AACA;;;;GAIG;AAgBH,OAAO,KAAK,EAAE,cAAc,EAAE,gBAAgB,EAAe,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"MySQLProxyAdapter.d.ts","sourceRoot":"","sources":["../../../../src/orm/adapters/MySQLProxyAdapter.ts"],"names":[],"mappings":"AACA;;;;GAIG;AAgBH,OAAO,KAAK,EAAE,cAAc,EAAE,gBAAgB,EAAe,MAAM,sBAAsB,CAAC;AAkU1F,eAAO,MAAM,iBAAiB;oBACZ,cAAc,GAAG,gBAAgB;EAcjD,CAAC;AAEH,eAAe,iBAAiB,CAAC"}
|
|
@@ -33,18 +33,79 @@ const buildSignedProxyConfig = (settings) => {
|
|
|
33
33
|
};
|
|
34
34
|
const isQueryResponse = (value) => isRecord(value) && Array.isArray(value['rows']) && typeof value['rowCount'] === 'number';
|
|
35
35
|
const isQueryOneResponse = (value) => isRecord(value) && 'row' in value;
|
|
36
|
+
const hasText = (value) => typeof value === 'string' && value.trim() !== '';
|
|
37
|
+
const describeErrorBody = (body) => {
|
|
38
|
+
const bodyCode = hasText(body['code']) ? body['code'].trim() : '';
|
|
39
|
+
const bodyMessage = hasText(body['message']) ? body['message'].trim() : '';
|
|
40
|
+
if (bodyCode !== '' && bodyMessage !== '')
|
|
41
|
+
return `${bodyCode}: ${bodyMessage}`;
|
|
42
|
+
if (bodyCode !== '')
|
|
43
|
+
return bodyCode;
|
|
44
|
+
if (bodyMessage !== '')
|
|
45
|
+
return bodyMessage;
|
|
46
|
+
return undefined;
|
|
47
|
+
};
|
|
48
|
+
const describeErrorRecord = (record) => {
|
|
49
|
+
const body = record['body'];
|
|
50
|
+
if (isRecord(body)) {
|
|
51
|
+
const describedBody = describeErrorBody(body);
|
|
52
|
+
if (describedBody !== undefined)
|
|
53
|
+
return describedBody;
|
|
54
|
+
}
|
|
55
|
+
const nestedDetails = describeErrorDetails(record['details']);
|
|
56
|
+
if (nestedDetails !== undefined)
|
|
57
|
+
return nestedDetails;
|
|
58
|
+
if (hasText(record['message']))
|
|
59
|
+
return record['message'].trim();
|
|
60
|
+
if (hasText(record['code']))
|
|
61
|
+
return record['code'].trim();
|
|
62
|
+
return undefined;
|
|
63
|
+
};
|
|
64
|
+
const describeErrorDetails = (details) => {
|
|
65
|
+
if (hasText(details))
|
|
66
|
+
return details.trim();
|
|
67
|
+
if (!isRecord(details))
|
|
68
|
+
return undefined;
|
|
69
|
+
return describeErrorRecord(details);
|
|
70
|
+
};
|
|
71
|
+
const withMaybeProperty = (target, key, value) => {
|
|
72
|
+
if (value === undefined)
|
|
73
|
+
return target;
|
|
74
|
+
return { ...target, [key]: value };
|
|
75
|
+
};
|
|
76
|
+
const toLoggedError = (error) => {
|
|
77
|
+
if (!(error instanceof Error)) {
|
|
78
|
+
return { message: String(error) };
|
|
79
|
+
}
|
|
80
|
+
const maybeError = error;
|
|
81
|
+
const detailSummary = describeErrorDetails(maybeError.details);
|
|
82
|
+
const message = detailSummary !== undefined && !error.message.includes(detailSummary)
|
|
83
|
+
? `${error.message} (${detailSummary})`
|
|
84
|
+
: error.message;
|
|
85
|
+
let loggedError = {
|
|
86
|
+
message,
|
|
87
|
+
};
|
|
88
|
+
loggedError = withMaybeProperty(loggedError, 'code', hasText(maybeError.code) ? maybeError.code : undefined);
|
|
89
|
+
loggedError = withMaybeProperty(loggedError, 'statusCode', typeof maybeError.statusCode === 'number' ? maybeError.statusCode : undefined);
|
|
90
|
+
loggedError = withMaybeProperty(loggedError, 'details', maybeError.details);
|
|
91
|
+
return loggedError;
|
|
92
|
+
};
|
|
36
93
|
const requestProxy = async (state, path, payload) => {
|
|
37
94
|
try {
|
|
38
95
|
return await SqlProxyHttpAdapterShared.requestProxy(state.signed, path, payload);
|
|
39
96
|
}
|
|
40
97
|
catch (error) {
|
|
98
|
+
const loggedError = toLoggedError(error);
|
|
41
99
|
Logger.error('[MySQLProxyAdapter] Proxy request failed', {
|
|
42
100
|
path,
|
|
43
101
|
baseUrl: state.settings.baseUrl,
|
|
44
102
|
timeoutMs: state.settings.timeoutMs,
|
|
45
103
|
hasKeyId: (state.settings.keyId ?? '').trim() !== '',
|
|
46
104
|
hasSecret: (state.settings.secret ?? '').trim() !== '',
|
|
47
|
-
error:
|
|
105
|
+
error: loggedError.message,
|
|
106
|
+
...withMaybeProperty({}, 'errorCode', loggedError.code),
|
|
107
|
+
...withMaybeProperty({}, 'errorStatusCode', loggedError.statusCode),
|
|
108
|
+
...withMaybeProperty({}, 'errorDetails', loggedError.details),
|
|
48
109
|
});
|
|
49
110
|
throw error;
|
|
50
111
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ZintrustD1Proxy.d.ts","sourceRoot":"","sources":["../../../../src/proxy/d1/ZintrustD1Proxy.ts"],"names":[],"mappings":"AAUA,KAAK,SAAS,GAAG,MAAM,GAAG,MAAM,GAAG,aAAa,CAAC;AAEjD,KAAK,qBAAqB,GAAG;IAC3B,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF,KAAK,WAAW,GAAG;IACjB,GAAG,EAAE;QACH,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;QACtC,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC,CAAC;QACrE,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,aAAa,GAAG,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC;QAChE,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,WAAW,GAAG,MAAM,GAAG,IAAI,CAAC,CAAC;KAChG,CAAC;IACF,GAAG,EAAE,CAA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ChD,KAAK,EAAE,CAAC,CAAC,GAAG,OAAO,OAAO,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;IAC5C,GAAG,EAAE,MAAM,OAAO,CAAC,WAAW,CAAC,CAAC;CACjC,CAAC;AAEF,KAAK,UAAU,GAAG;IAChB,OAAO,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,mBAAmB,CAAC;CAC/C,CAAC;AAEF,KAAK,KAAK,GAAG;IACX,EAAE,CAAC,EAAE,UAAU,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,0BAA0B,CAAC,EAAE,MAAM,CAAC;IACpC,SAAS,CAAC,EAAE,WAAW,CAAC;IACxB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,qBAAqB,CAAC,EAAE,MAAM,CAAC;CAChC,CAAC;AAiTF,eAAO,MAAM,eAAe;;;mBAGL,OAAO,OAAO,KAAK,GAAG,OAAO,CAAC,QAAQ,CAAC;EAqB5D,CAAC;AAEH,eAAe,eAAe,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SystemTraceWorkerBridge } from '../../trace/SystemTraceWorkerBridge.js';
|
|
2
2
|
import { getEnvInt, json, normalizeBindingName, readAndVerifyJson, toErrorResponse, } from '../CloudflareProxyShared.js';
|
|
3
3
|
import { RequestValidator } from '../RequestValidator.js';
|
|
4
4
|
const DEFAULT_SIGNING_WINDOW_MS = 60_000;
|
|
@@ -149,7 +149,7 @@ const handleQuery = async (request, env) => {
|
|
|
149
149
|
.prepare(resolved.sql)
|
|
150
150
|
.bind(...resolved.params)
|
|
151
151
|
.all();
|
|
152
|
-
|
|
152
|
+
SystemTraceWorkerBridge.emitQuery(resolved.sql, resolved.params, Date.now() - startedAt, 'd1-proxy');
|
|
153
153
|
const rows = result.results ?? [];
|
|
154
154
|
return json(200, { rows, rowCount: rows.length });
|
|
155
155
|
}
|
|
@@ -168,7 +168,7 @@ const handleQueryOne = async (request, env) => {
|
|
|
168
168
|
.prepare(resolved.sql)
|
|
169
169
|
.bind(...resolved.params)
|
|
170
170
|
.first();
|
|
171
|
-
|
|
171
|
+
SystemTraceWorkerBridge.emitQuery(resolved.sql, resolved.params, Date.now() - startedAt, 'd1-proxy');
|
|
172
172
|
return json(200, { row: row ?? null });
|
|
173
173
|
}
|
|
174
174
|
catch (error) {
|
|
@@ -186,7 +186,7 @@ const handleExec = async (request, env) => {
|
|
|
186
186
|
.prepare(resolved.sql)
|
|
187
187
|
.bind(...resolved.params)
|
|
188
188
|
.run();
|
|
189
|
-
|
|
189
|
+
SystemTraceWorkerBridge.emitQuery(resolved.sql, resolved.params, Date.now() - startedAt, 'd1-proxy');
|
|
190
190
|
return json(200, { ok: true, meta: out.meta });
|
|
191
191
|
}
|
|
192
192
|
catch (error) {
|
|
@@ -230,14 +230,14 @@ const handleStatement = async (request, env) => {
|
|
|
230
230
|
.prepare(sql)
|
|
231
231
|
.bind(...parsed.params)
|
|
232
232
|
.run();
|
|
233
|
-
|
|
233
|
+
SystemTraceWorkerBridge.emitQuery(sql, parsed.params, Date.now() - startedAt, 'd1-proxy');
|
|
234
234
|
return json(200, { ok: true, meta: out.meta });
|
|
235
235
|
}
|
|
236
236
|
const out = await resolved.db
|
|
237
237
|
.prepare(sql)
|
|
238
238
|
.bind(...parsed.params)
|
|
239
239
|
.all();
|
|
240
|
-
|
|
240
|
+
SystemTraceWorkerBridge.emitQuery(sql, parsed.params, Date.now() - startedAt, 'd1-proxy');
|
|
241
241
|
const rows = out.results ?? [];
|
|
242
242
|
return json(200, { rows, rowCount: rows.length });
|
|
243
243
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SystemTraceWorkerBridge } from '../../trace/SystemTraceWorkerBridge.js';
|
|
2
2
|
import { isObject, isString } from '../../helper/index.js';
|
|
3
3
|
import { getEnvInt, json, normalizeBindingName, readAndVerifyJson, toErrorResponse, } from '../CloudflareProxyShared.js';
|
|
4
4
|
import { RequestValidator } from '../RequestValidator.js';
|
|
@@ -72,16 +72,16 @@ const handleGet = async (request, env) => {
|
|
|
72
72
|
const startedAt = Date.now();
|
|
73
73
|
if (parsed.type === 'json') {
|
|
74
74
|
const value = await resolved.cache.get(storageKey, 'json');
|
|
75
|
-
|
|
75
|
+
SystemTraceWorkerBridge.emitCache('get', storageKey, Date.now() - startedAt, value !== null, value, 'kv-proxy');
|
|
76
76
|
return json(200, { value: value ?? null });
|
|
77
77
|
}
|
|
78
78
|
if (parsed.type === 'arrayBuffer') {
|
|
79
79
|
const value = await resolved.cache.get(storageKey, 'arrayBuffer');
|
|
80
|
-
|
|
80
|
+
SystemTraceWorkerBridge.emitCache('get', storageKey, Date.now() - startedAt, value !== null, value, 'kv-proxy');
|
|
81
81
|
return json(200, { value: value ?? null });
|
|
82
82
|
}
|
|
83
83
|
const value = await resolved.cache.get(storageKey);
|
|
84
|
-
|
|
84
|
+
SystemTraceWorkerBridge.emitCache('get', storageKey, Date.now() - startedAt, value !== null, value, 'kv-proxy');
|
|
85
85
|
return json(200, { value: value ?? null });
|
|
86
86
|
};
|
|
87
87
|
const parsePutPayload = (payload) => {
|
|
@@ -119,7 +119,7 @@ const handlePut = async (request, env) => {
|
|
|
119
119
|
options.expirationTtl = Math.floor(parsed.ttlSeconds);
|
|
120
120
|
}
|
|
121
121
|
await resolved.cache.put(storageKey, value, options);
|
|
122
|
-
|
|
122
|
+
SystemTraceWorkerBridge.emitCache('set', storageKey, Date.now() - startedAt, undefined, parsed.value, 'kv-proxy', parsed.ttlSeconds);
|
|
123
123
|
return json(200, { ok: true });
|
|
124
124
|
};
|
|
125
125
|
const parseDeletePayload = (payload) => {
|
|
@@ -142,7 +142,7 @@ const handleDelete = async (request, env) => {
|
|
|
142
142
|
const storageKey = buildStorageKey(env, { namespace: parsed.namespace, key: parsed.key });
|
|
143
143
|
const startedAt = Date.now();
|
|
144
144
|
await resolved.cache.delete(storageKey);
|
|
145
|
-
|
|
145
|
+
SystemTraceWorkerBridge.emitCache('delete', storageKey, Date.now() - startedAt, undefined, undefined, 'kv-proxy');
|
|
146
146
|
return json(200, { ok: true });
|
|
147
147
|
};
|
|
148
148
|
const parseListPayload = (payload) => {
|
|
@@ -177,7 +177,7 @@ const handleList = async (request, env) => {
|
|
|
177
177
|
limit,
|
|
178
178
|
cursor: parsed.params.cursor,
|
|
179
179
|
});
|
|
180
|
-
|
|
180
|
+
SystemTraceWorkerBridge.emitEvent('kv-proxy.list', 1, {
|
|
181
181
|
prefix: fullPrefix,
|
|
182
182
|
limit,
|
|
183
183
|
cursor: parsed.params.cursor,
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const SystemTraceWorkerBridge: Readonly<{
|
|
2
|
+
emitCache: (operation: "get" | "set" | "delete" | "clear" | "has", key: string, duration: number, hit?: boolean, payload?: unknown, store?: string, ttl?: number) => void;
|
|
3
|
+
emitEvent: (name: string, listenerCount: number, payload?: unknown) => void;
|
|
4
|
+
emitQuery: (query: string, params: unknown[], duration: number, connection?: string) => void;
|
|
5
|
+
}>;
|
|
6
|
+
export default SystemTraceWorkerBridge;
|
|
7
|
+
//# sourceMappingURL=SystemTraceWorkerBridge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SystemTraceWorkerBridge.d.ts","sourceRoot":"","sources":["../../../src/trace/SystemTraceWorkerBridge.ts"],"names":[],"mappings":"AAgEA,eAAO,MAAM,uBAAuB;2BA9BvB,KAAK,GAAG,KAAK,GAAG,QAAQ,GAAG,OAAO,GAAG,KAAK,OAChD,MAAM,YACD,MAAM,QACV,OAAO,YACH,OAAO,UACT,MAAM,QACR,MAAM,KACX,IAAI;sBAMkB,MAAM,iBAAiB,MAAM,YAAY,OAAO,KAAG,IAAI;uBAOvE,MAAM,UACL,OAAO,EAAE,YACP,MAAM,eACH,MAAM,KAClB,IAAI;EAUL,CAAC;AAEH,eAAe,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
const getWorkerTraceModule = () => {
|
|
2
|
+
return globalThis.__zintrust_worker_trace_bridge__;
|
|
3
|
+
};
|
|
4
|
+
const withWorkerTraceModule = (run) => {
|
|
5
|
+
const module = getWorkerTraceModule();
|
|
6
|
+
if (module === undefined)
|
|
7
|
+
return;
|
|
8
|
+
try {
|
|
9
|
+
run(module);
|
|
10
|
+
}
|
|
11
|
+
catch {
|
|
12
|
+
// Ignore optional trace failures so Worker proxy behavior is unaffected.
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
const emitCache = (operation, key, duration, hit, payload, store, ttl) => {
|
|
16
|
+
withWorkerTraceModule((module) => {
|
|
17
|
+
module.emitCache?.(operation, key, duration, hit, payload, store, ttl);
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
const emitEvent = (name, listenerCount, payload) => {
|
|
21
|
+
withWorkerTraceModule((module) => {
|
|
22
|
+
module.emitEvent?.(name, listenerCount, payload);
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
const emitQuery = (query, params, duration, connection) => {
|
|
26
|
+
withWorkerTraceModule((module) => {
|
|
27
|
+
module.emitQuery?.(query, params, duration, connection);
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
export const SystemTraceWorkerBridge = Object.freeze({
|
|
31
|
+
emitCache,
|
|
32
|
+
emitEvent,
|
|
33
|
+
emitQuery,
|
|
34
|
+
});
|
|
35
|
+
export default SystemTraceWorkerBridge;
|