@zintrust/core 3.0.3 → 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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zintrust/core",
3
- "version": "3.0.3",
3
+ "version": "3.0.5",
4
4
  "description": "Production-grade TypeScript backend framework for JavaScript",
5
5
  "homepage": "https://zintrust.com",
6
6
  "repository": {
@@ -213,19 +213,19 @@
213
213
  "./package.json": "./package.json"
214
214
  },
215
215
  "dependencies": {
216
- "@zedgi/zedgi-client": "^1.0.3",
216
+ "@zedgi/zedgi-client": "^1.0.6",
217
217
  "@cloudflare/containers": "^0.3.7",
218
218
  "bcryptjs": "^3.0.3",
219
- "bullmq": "^5.79.2",
219
+ "bullmq": "^5.80.2",
220
220
  "chalk": "^5.6.2",
221
221
  "commander": "^15.0.0",
222
222
  "inquirer": "^14.0.2",
223
223
  "ioredis": "^5.11.1",
224
224
  "jsonwebtoken": "^9.0.3",
225
- "mysql2": "^3.22.5",
225
+ "mysql2": "^3.22.6",
226
226
  "pg": "^8.22.0",
227
- "redis": "^6.0.1",
228
- "tsx": "^4.22.4"
227
+ "redis": "^6.1.0",
228
+ "tsx": "^4.23.1"
229
229
  },
230
230
  "overrides": {
231
231
  "ajv": "^8.18.0",
@@ -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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111
  return;
112
112
  OpenTelemetry.setHttpRoute(traceSpan.span, method, routeLabel);
113
113
  };
114
- const runKernelPipeline = async (router, globalMiddleware, routeMiddleware, req, res, context, traceSpan) => {
115
- const route = resolveRouteWithPreflightFallback(router, req.getMethod(), req.getPath());
116
- if (route === null) {
117
- const routeLabel = 'not_found';
118
- maybeSetKernelTraceRoute(traceSpan, context.method, routeLabel);
119
- const handleNotFound = ErrorRouting.handleNotFound;
120
- await handleNotFound(req, res, context.requestId);
121
- return routeLabel;
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
- const routeLabel = hasNonEmptyRoutePath(route) ? route.routePath : req.getPath();
131
- maybeSetKernelTraceRoute(traceSpan, context.method, routeLabel);
132
- // Use a typed view of the matched route to avoid unsafe member access
133
- const matchedRoute = route;
134
- // Coerce route params (which may be undefined or non-string) into the
135
- // expected Record<string, string> shape required by Request.setParams.
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 matchedRoute.params === 'object' && matchedRoute.params !== null) {
138
- for (const [k, v] of Object.entries(matchedRoute.params)) {
139
- if (v === undefined || v === null)
140
- continue;
141
- safeParams[k] = typeof v === 'string' ? v : String(v);
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
- req.setParams(safeParams);
145
- const routeMiddlewareNames = getRouteMiddlewareNames(matchedRoute);
146
- req.context['traceRouteMiddleware'] = routeMiddlewareNames;
142
+ return safeParams;
143
+ };
144
+ const resolveWrappedRouteMiddleware = (routeMiddlewareNames, routeMiddleware) => {
147
145
  const traceMiddlewareEmitter = getTraceMiddlewareEmitter();
148
- const resolvedRouteMiddleware = routeMiddlewareNames
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
- const middlewareToRun = [...globalMiddleware, ...resolvedRouteMiddleware];
167
- let index = 0;
168
- const next = async () => {
169
- if (index < middlewareToRun.length) {
170
- const mw = middlewareToRun[index++];
171
- await mw(req, res, next);
172
- return;
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.3
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-13T16:43:31.757Z
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-13T16:43:31.715Z'; // Replaced during build
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,E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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 (!((typeof rawId === 'string' && rawId.trim() !== '') ||
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: hasPayload ? record['payload'] : record['data'],
176
- attempts,
181
+ name: resolvePulledJobName(record),
182
+ payload: resolvePulledJobPayload(record),
183
+ attempts: resolvePulledJobAttempts(record),
177
184
  };
178
185
  };
179
186
  const createZedgiBullMqError = (method, error) => {