@zintrust/core 3.0.4 → 3.0.5
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
CHANGED
package/src/http/Kernel.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Kernel.d.ts","sourceRoot":"","sources":["../../../src/http/Kernel.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAErE,OAAO,KAAK,EAAE,OAAO,EAAc,MAAM,qBAAqB,CAAC;AAE/D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAG9C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhD,OAAO,KAAK,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAEhF,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAK7E,OAAO,KAAK,EAAE,SAAS,EAAmB,MAAM,mBAAmB,CAAC;AAgBpE,MAAM,WAAW,OAAO;IACtB,MAAM,CAAC,GAAG,EAAE,eAAe,EAAE,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACjE,aAAa,CAAC,GAAG,EAAE,QAAQ,EAAE,GAAG,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5D,SAAS,CAAC,GAAG,EAAE,QAAQ,EAAE,GAAG,EAAE,SAAS,GAAG,IAAI,CAAC;IAC/C,wBAAwB,CAAC,GAAG,UAAU,EAAE,UAAU,EAAE,GAAG,IAAI,CAAC;IAC5D,uBAAuB,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,GAAG,IAAI,CAAC;IACpE,SAAS,IAAI,OAAO,CAAC;IACrB,YAAY,IAAI,iBAAiB,CAAC;IAClC,kBAAkB,IA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AAI,OAAO,CAAC;IACrB,YAAY,IAAI,iBAAiB,CAAC;IAClC,kBAAkB,IAAI,gBAAgB,CAAC;IAGvC,gBAAgB,CAAC,QAAQ,EAAE,SAAS,GAAG,IAAI,CAAC;IAC5C,cAAc,IAAI,IAAI,CAAC;IACvB,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/B,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9C;AA8ZD,eAAO,MAAM,MAAM;qBAvEK,OAAO,aAAa,iBAAiB,KAAG,OAAO;EAyErE,CAAC;AAEH,eAAe,MAAM,CAAC"}
|
package/src/http/Kernel.js
CHANGED
|
@@ -111,41 +111,39 @@ const maybeSetKernelTraceRoute = (traceSpan, method, routeLabel) => {
|
|
|
111
111
|
return;
|
|
112
112
|
OpenTelemetry.setHttpRoute(traceSpan.span, method, routeLabel);
|
|
113
113
|
};
|
|
114
|
-
const
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
// Safe type guard to ensure route.routePath is a non-empty string before calling .trim()
|
|
124
|
-
const hasNonEmptyRoutePath = (r) => {
|
|
125
|
-
if (typeof r !== 'object' || r === null)
|
|
126
|
-
return false;
|
|
127
|
-
const rp = r.routePath;
|
|
128
|
-
return typeof rp === 'string' && rp.trim() !== '';
|
|
114
|
+
const runMiddlewareChain = async (middleware, req, res, terminal) => {
|
|
115
|
+
let index = 0;
|
|
116
|
+
const next = async () => {
|
|
117
|
+
if (index < middleware.length) {
|
|
118
|
+
const mw = middleware[index++];
|
|
119
|
+
await mw(req, res, next);
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
await terminal();
|
|
129
123
|
};
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
124
|
+
await next();
|
|
125
|
+
};
|
|
126
|
+
// Safe type guard to ensure route.routePath is a non-empty string before calling .trim()
|
|
127
|
+
const hasNonEmptyRoutePath = (r) => {
|
|
128
|
+
if (typeof r !== 'object' || r === null)
|
|
129
|
+
return false;
|
|
130
|
+
const rp = r.routePath;
|
|
131
|
+
return typeof rp === 'string' && rp.trim() !== '';
|
|
132
|
+
};
|
|
133
|
+
const coerceRouteParams = (params) => {
|
|
136
134
|
const safeParams = {};
|
|
137
|
-
if (typeof
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
135
|
+
if (typeof params !== 'object' || params === null)
|
|
136
|
+
return safeParams;
|
|
137
|
+
for (const [k, v] of Object.entries(params)) {
|
|
138
|
+
if (v === undefined || v === null)
|
|
139
|
+
continue;
|
|
140
|
+
safeParams[k] = typeof v === 'string' ? v : String(v);
|
|
143
141
|
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
142
|
+
return safeParams;
|
|
143
|
+
};
|
|
144
|
+
const resolveWrappedRouteMiddleware = (routeMiddlewareNames, routeMiddleware) => {
|
|
147
145
|
const traceMiddlewareEmitter = getTraceMiddlewareEmitter();
|
|
148
|
-
|
|
146
|
+
return routeMiddlewareNames
|
|
149
147
|
.map((name) => ({ name, middleware: routeMiddleware[name] }))
|
|
150
148
|
.filter((entry) => typeof entry.middleware === 'function')
|
|
151
149
|
.map(({ name, middleware }) => {
|
|
@@ -163,17 +161,37 @@ const runKernelPipeline = async (router, globalMiddleware, routeMiddleware, req,
|
|
|
163
161
|
};
|
|
164
162
|
return wrapped;
|
|
165
163
|
});
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
164
|
+
};
|
|
165
|
+
const runNotFoundPipeline = async (globalMiddleware, req, res, context, traceSpan) => {
|
|
166
|
+
// Run global middleware (including HttpWatcher) so routing 404s are still observed.
|
|
167
|
+
// Route middleware is intentionally skipped — there is no matched route.
|
|
168
|
+
const routeLabel = 'not_found';
|
|
169
|
+
maybeSetKernelTraceRoute(traceSpan, context.method, routeLabel);
|
|
170
|
+
req.context['traceRouteMiddleware'] = [];
|
|
171
|
+
const handleNotFound = ErrorRouting.handleNotFound;
|
|
172
|
+
await runMiddlewareChain(globalMiddleware, req, res, async () => {
|
|
173
|
+
await handleNotFound(req, res, context.requestId);
|
|
174
|
+
});
|
|
175
|
+
return routeLabel;
|
|
176
|
+
};
|
|
177
|
+
const runKernelPipeline = async (router, globalMiddleware, routeMiddleware, req, res, context, traceSpan) => {
|
|
178
|
+
const route = resolveRouteWithPreflightFallback(router, req.getMethod(), req.getPath());
|
|
179
|
+
if (route === null) {
|
|
180
|
+
return runNotFoundPipeline(globalMiddleware, req, res, context, traceSpan);
|
|
181
|
+
}
|
|
182
|
+
const matchedRoute = route;
|
|
183
|
+
const routeLabel = hasNonEmptyRoutePath(matchedRoute) ? matchedRoute.routePath : req.getPath();
|
|
184
|
+
maybeSetKernelTraceRoute(traceSpan, context.method, routeLabel);
|
|
185
|
+
req.setParams(coerceRouteParams(matchedRoute.params));
|
|
186
|
+
const routeMiddlewareNames = getRouteMiddlewareNames(matchedRoute);
|
|
187
|
+
req.context['traceRouteMiddleware'] = routeMiddlewareNames;
|
|
188
|
+
const middlewareToRun = [
|
|
189
|
+
...globalMiddleware,
|
|
190
|
+
...resolveWrappedRouteMiddleware(routeMiddlewareNames, routeMiddleware),
|
|
191
|
+
];
|
|
192
|
+
await runMiddlewareChain(middlewareToRun, req, res, async () => {
|
|
174
193
|
await matchedRoute.handler(req, res);
|
|
175
|
-
};
|
|
176
|
-
await next();
|
|
194
|
+
});
|
|
177
195
|
return routeLabel;
|
|
178
196
|
};
|
|
179
197
|
const finalizeKernelObservability = (context, res, routeLabel, thrown, traceSpan) => {
|
package/src/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @zintrust/core v3.0.
|
|
2
|
+
* @zintrust/core v3.0.5
|
|
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-07-
|
|
8
|
+
* Built: 2026-07-16T10:25:51.056Z
|
|
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-07-
|
|
24
|
+
export const ZINTRUST_BUILD_DATE = '2026-07-16T10:25:51.018Z'; // 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":"rpc-client.d.ts","sourceRoot":"","sources":["../../../src/worker-runtime/rpc-client.ts"],"names":[],"mappings":"AAkBA,MAAM,MAAM,SAAS,GAAG;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAWF,eAAO,MAAM,oBAAoB,QAAO,OAAkC,CAAC;AAE3E,eAAO,MAAM,4BAA4B,QAAO,MAI/C,CAAC;AAOF,eAAO,MAAM,8BAA8B,QAAO,OAC0B,CAAC;
|
|
1
|
+
{"version":3,"file":"rpc-client.d.ts","sourceRoot":"","sources":["../../../src/worker-runtime/rpc-client.ts"],"names":[],"mappings":"AAkBA,MAAM,MAAM,SAAS,GAAG;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAWF,eAAO,MAAM,oBAAoB,QAAO,OAAkC,CAAC;AAE3E,eAAO,MAAM,4BAA4B,QAAO,MAI/C,CAAC;AAOF,eAAO,MAAM,8BAA8B,QAAO,OAC0B,CAAC;AAkO7E,wFAAwF;AACxF,eAAO,MAAM,OAAO,GAClB,WAAW,MAAM,EACjB,qBAAqB,MAAM,KAC1B,OAAO,CAAC,SAAS,GAAG,SAAS,CAkB/B,CAAC;AAEF,mCAAmC;AACnC,eAAO,MAAM,MAAM,GACjB,WAAW,MAAM,EACjB,OAAO,MAAM,EACb,cAAc,OAAO,KACpB,OAAO,CAAC,IAAI,CAOd,CAAC;AAEF,gCAAgC;AAChC,eAAO,MAAM,OAAO,GAAU,WAAW,MAAM,EAAE,OAAO,MAAM,EAAE,QAAQ,MAAM,KAAG,OAAO,CAAC,IAAI,CAW5F,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,gFAAgF;AAChF,eAAO,MAAM,WAAW,QAAa,OAAO,CAAC,gBAAgB,EAAE,CAO9D,CAAC"}
|
|
@@ -44,6 +44,8 @@ const queuePayload = (extra) => {
|
|
|
44
44
|
return db === undefined ? extra : { db, ...extra };
|
|
45
45
|
};
|
|
46
46
|
const hasOwn = (value, key) => Object.prototype.hasOwnProperty.call(value, key);
|
|
47
|
+
const isPullJobId = (value) => (typeof value === 'string' && value.trim() !== '') ||
|
|
48
|
+
(typeof value === 'number' && Number.isFinite(value));
|
|
47
49
|
const parseHeaderEnv = (key) => {
|
|
48
50
|
const raw = Env.get(key, '').trim();
|
|
49
51
|
if (raw === '')
|
|
@@ -145,6 +147,24 @@ const call = async (service, method, payload = {}) => {
|
|
|
145
147
|
}
|
|
146
148
|
return parsed.result;
|
|
147
149
|
};
|
|
150
|
+
const resolvePulledJobPayload = (record) => {
|
|
151
|
+
if (hasOwn(record, 'payload'))
|
|
152
|
+
return record['payload'];
|
|
153
|
+
if (hasOwn(record, 'data'))
|
|
154
|
+
return record['data'];
|
|
155
|
+
throw ErrorFactory.createConfigError('Worker queue pull returned a job without payload/data');
|
|
156
|
+
};
|
|
157
|
+
const resolvePulledJobAttempts = (record) => {
|
|
158
|
+
const rawAttempts = hasOwn(record, 'attempts') ? record['attempts'] : record['attemptsMade'];
|
|
159
|
+
return typeof rawAttempts === 'number' && Number.isFinite(rawAttempts)
|
|
160
|
+
? Math.max(0, Math.floor(rawAttempts))
|
|
161
|
+
: 0;
|
|
162
|
+
};
|
|
163
|
+
const resolvePulledJobName = (record) => {
|
|
164
|
+
return typeof record['name'] === 'string' && record['name'].trim() !== ''
|
|
165
|
+
? record['name'].trim()
|
|
166
|
+
: 'default';
|
|
167
|
+
};
|
|
148
168
|
const normalizePulledJob = (raw) => {
|
|
149
169
|
if (raw === null || raw === undefined)
|
|
150
170
|
return undefined;
|
|
@@ -153,27 +173,14 @@ const normalizePulledJob = (raw) => {
|
|
|
153
173
|
}
|
|
154
174
|
const record = raw;
|
|
155
175
|
const rawId = record['id'];
|
|
156
|
-
if (!(
|
|
157
|
-
(typeof rawId === 'number' && Number.isFinite(rawId)))) {
|
|
176
|
+
if (!isPullJobId(rawId)) {
|
|
158
177
|
throw ErrorFactory.createConfigError('Worker queue pull returned a job without an id');
|
|
159
178
|
}
|
|
160
|
-
const hasPayload = hasOwn(record, 'payload');
|
|
161
|
-
const hasData = hasOwn(record, 'data');
|
|
162
|
-
if (!hasPayload && !hasData) {
|
|
163
|
-
throw ErrorFactory.createConfigError('Worker queue pull returned a job without payload/data');
|
|
164
|
-
}
|
|
165
|
-
const rawAttempts = hasOwn(record, 'attempts') ? record['attempts'] : record['attemptsMade'];
|
|
166
|
-
const attempts = typeof rawAttempts === 'number' && Number.isFinite(rawAttempts)
|
|
167
|
-
? Math.max(0, Math.floor(rawAttempts))
|
|
168
|
-
: 0;
|
|
169
|
-
const name = typeof record['name'] === 'string' && record['name'].trim() !== ''
|
|
170
|
-
? record['name'].trim()
|
|
171
|
-
: 'default';
|
|
172
179
|
return {
|
|
173
180
|
id: String(rawId),
|
|
174
|
-
name,
|
|
175
|
-
payload:
|
|
176
|
-
attempts,
|
|
181
|
+
name: resolvePulledJobName(record),
|
|
182
|
+
payload: resolvePulledJobPayload(record),
|
|
183
|
+
attempts: resolvePulledJobAttempts(record),
|
|
177
184
|
};
|
|
178
185
|
};
|
|
179
186
|
const createZedgiBullMqError = (method, error) => {
|