@zintrust/core 2.9.0 → 3.0.1

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": "2.9.0",
3
+ "version": "3.0.1",
4
4
  "description": "Production-grade TypeScript backend framework for JavaScript",
5
5
  "homepage": "https://zintrust.com",
6
6
  "repository": {
@@ -224,8 +224,8 @@
224
224
  "jsonwebtoken": "^9.0.3",
225
225
  "mysql2": "^3.22.5",
226
226
  "pg": "^8.22.0",
227
- "redis": "^6.1.0",
228
- "tsx": "^4.22.5"
227
+ "redis": "^6.0.1",
228
+ "tsx": "^4.22.4"
229
229
  },
230
230
  "overrides": {
231
231
  "ajv": "^8.18.0",
@@ -1 +1 @@
1
- {"version":3,"file":"queue.d.ts","sourceRoot":"","sources":["../../../src/config/queue.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAcH,OAAO,KAAK,EACV,sBAAsB,EACtB,eAAe,EACf,kBAAkB,EAKnB,MAAM,cAAc,CAAC;AAyCtB,MAAM,MAAM,oBAAoB,GAAG,OAAO,CAAC;IACzC,OAAO,EAAE,eAAe,CAAC;IACzB,OAAO,EAAE,OAAO,CAAC,kBAAkB,CAAC,CAAC;IACrC,MAAM,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;IAC5C,UAAU,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;IACnF,OAAO,EAAE;QACP,OAAO,EAAE,OAAO,CAAC;QACjB,QAAQ,EAAE,MAAM,CAAC;QACjB,UAAU,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;QAClC,WAAW,EAAE,OAAO,CAAC;QACrB,iBAAiB,EAA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MAAM,MAAM,WAAW,GAAG,UAAU,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAkB/D,eAAO,MAAM,WAAW,EAAE,WAYxB,CAAC"}
@@ -83,6 +83,12 @@ const createSqsQueueDriver = () => ({
83
83
  region: Env.AWS_REGION,
84
84
  queueUrl: Env.get('AWS_SQS_QUEUE_URL'),
85
85
  });
86
+ const resolveDefaultQueueDriver = () => {
87
+ const connection = Env.get('QUEUE_CONNECTION', '').trim();
88
+ if (connection !== '')
89
+ return connection;
90
+ return Env.get('QUEUE_DRIVER', 'sync');
91
+ };
86
92
  /**
87
93
  * Helper: Create base driver configurations from environment
88
94
  */
@@ -138,7 +144,7 @@ const createBaseMonitor = () => {
138
144
  };
139
145
  const createQueueConfig = () => {
140
146
  const overrides = StartupConfigFileRegistry.get(StartupConfigFile.Queue) ?? {};
141
- const baseDefault = Env.get('QUEUE_DRIVER', 'sync');
147
+ const baseDefault = resolveDefaultQueueDriver();
142
148
  const baseDrivers = createBaseDrivers();
143
149
  const baseFailed = {
144
150
  database: Env.get('FAILED_JOBS_DB_CONNECTION', 'default'),
package/src/index.js CHANGED
@@ -1,11 +1,11 @@
1
1
  /**
2
- * @zintrust/core v2.9.0
2
+ * @zintrust/core v3.0.1
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-02T15:52:01.052Z
8
+ * Built: 2026-07-13T15:20:14.904Z
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-02T15:52:01.021Z'; // Replaced during build
24
+ export const ZINTRUST_BUILD_DATE = '2026-07-13T15:20:14.868Z'; // 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":"OfficialPlugins.d.ts","sourceRoot":"","sources":["../../../src/runtime/OfficialPlugins.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,uBAAuB,GAAG,MAAM,GAAG,QAAQ,CAAC;AAuKxD,eAAO,MAAM,eAAe;;;;;uBAKR,uBAAuB,GAAY,aAAa,CAAC,MAAM,CAAC;0BAGrD,uBAAuB,GAAY,aAAa,CAAC,MAAM,CAAC;EAG7E,CAAC"}
1
+ {"version":3,"file":"OfficialPlugins.d.ts","sourceRoot":"","sources":["../../../src/runtime/OfficialPlugins.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,uBAAuB,GAAG,MAAM,GAAG,QAAQ,CAAC;AAyKxD,eAAO,MAAM,eAAe;;;;;uBAKR,uBAAuB,GAAY,aAAa,CAAC,MAAM,CAAC;0BAGrD,uBAAuB,GAAY,aAAa,CAAC,MAAM,CAAC;EAG7E,CAAC"}
@@ -12,6 +12,7 @@ const isSelected = (keys, expected) => {
12
12
  const value = readEnvString(...keys);
13
13
  return value !== '' && expected.includes(value);
14
14
  };
15
+ const isQueueSelected = (expected) => isSelected(['QUEUE_CONNECTION', 'QUEUE_DRIVER'], expected);
15
16
  const looksLikeSqlitePath = () => {
16
17
  const raw = readEnvString('DB_PATH', 'DB_DATABASE');
17
18
  if (raw === '')
@@ -52,28 +53,28 @@ const baseRegistrations = Object.freeze([
52
53
  isEnabled: () => readEnvBool('USE_ZEDGI') ||
53
54
  isSelected(['DB_CONNECTION'], ['mysql-zedgi', 'postgres-zedgi', 'pg-zedgi']) ||
54
55
  isSelected(['CACHE_CONNECTION', 'CACHE_DRIVER'], ['redis-zedgi']) ||
55
- isSelected(['QUEUE_DRIVER'], ['queue-zedgi']),
56
+ isQueueSelected(['queue-zedgi']),
56
57
  },
57
58
  {
58
59
  packageName: '@zintrust/queue-redis',
59
60
  specifier: '@zintrust/queue-redis/register',
60
- isEnabled: () => isSelected(['QUEUE_DRIVER'], ['redis']) ||
61
+ isEnabled: () => isQueueSelected(['redis']) ||
61
62
  isSelected(['BROADCAST_CONNECTION', 'BROADCAST_DRIVER'], ['redis', 'redishttps']),
62
63
  },
63
64
  {
64
65
  packageName: '@zintrust/queue-rabbitmq',
65
66
  specifier: '@zintrust/queue-rabbitmq/register',
66
- isEnabled: () => isSelected(['QUEUE_DRIVER'], ['rabbitmq']),
67
+ isEnabled: () => isQueueSelected(['rabbitmq']),
67
68
  },
68
69
  {
69
70
  packageName: '@zintrust/queue-sqs',
70
71
  specifier: '@zintrust/queue-sqs/register',
71
- isEnabled: () => isSelected(['QUEUE_DRIVER'], ['sqs']),
72
+ isEnabled: () => isQueueSelected(['sqs']),
72
73
  },
73
74
  {
74
75
  packageName: '@zintrust/queue-cloudflare',
75
76
  specifier: '@zintrust/queue-cloudflare/register',
76
- isEnabled: () => isSelected(['QUEUE_DRIVER'], ['cloudflare', 'cloudflare-queues', 'cf-queues']),
77
+ isEnabled: () => isQueueSelected(['cloudflare', 'cloudflare-queues', 'cf-queues']),
77
78
  },
78
79
  {
79
80
  packageName: '@zintrust/cache-redis',
@@ -1 +1 @@
1
- {"version":3,"file":"rpc-client.d.ts","sourceRoot":"","sources":["../../../src/worker-runtime/rpc-client.ts"],"names":[],"mappings":"AAiBA,MAAM,MAAM,SAAS,GAAG;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAOF,eAAO,MAAM,oBAAoB,QAAO,OAAkC,CAAC;AA6B3E,wFAAwF;AACxF,eAAO,MAAM,OAAO,GAClB,WAAW,MAAM,EACjB,qBAAqB,MAAM,KAC1B,OAAO,CAAC,SAAS,GAAG,SAAS,CAM/B,CAAC;AAEF,mCAAmC;AACnC,eAAO,MAAM,MAAM,GACjB,WAAW,MAAM,EACjB,OAAO,MA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AU,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,CAG9D,CAAC"}
@@ -11,6 +11,26 @@ import { ErrorFactory } from '../exceptions/ZintrustError.js';
11
11
  const getBaseUrl = () => Env.get('REDIS_RPC_URL', '').trim();
12
12
  const getSecret = () => Env.get('REDIS_RPC_SECRET', Env.get('REDIS_PROXY_SECRET', Env.get('APP_KEY', ''))).trim();
13
13
  export const isRedisRpcConfigured = () => getBaseUrl().length > 0;
14
+ /**
15
+ * Resolve the target Redis database index from env
16
+ * (REDIS_QUEUE_DB → REDIS_DB → undefined).
17
+ * Returns undefined when no explicit DB is configured,
18
+ * which means the RPC backend uses its own server default.
19
+ */
20
+ const getQueueDb = () => {
21
+ const queueDb = Env.getInt('REDIS_QUEUE_DB', -1);
22
+ if (queueDb >= 0)
23
+ return queueDb;
24
+ const redisDb = Env.getInt('REDIS_DB', -1);
25
+ if (redisDb >= 0)
26
+ return redisDb;
27
+ return undefined;
28
+ };
29
+ /** Merge target DB into any queue RPC payload when configured. */
30
+ const queuePayload = (extra) => {
31
+ const db = getQueueDb();
32
+ return db === undefined ? extra : { db, ...extra };
33
+ };
14
34
  const call = async (service, method, payload = {}) => {
15
35
  const baseUrl = getBaseUrl();
16
36
  if (baseUrl.length === 0) {
@@ -33,20 +53,20 @@ const call = async (service, method, payload = {}) => {
33
53
  };
34
54
  /** Atomically claim and pull the next waiting job for a queue, or undefined if none. */
35
55
  export const pullJob = async (queueName, visibilityTimeoutMs) => {
36
- const result = await call('queue', 'dequeue', {
56
+ const result = await call('queue', 'dequeue', queuePayload({
37
57
  queueName,
38
58
  visibilityTimeoutMs,
39
- });
59
+ }));
40
60
  return result ?? undefined;
41
61
  };
42
62
  /** Mark a pulled job completed. */
43
63
  export const ackJob = async (queueName, jobId, returnValue) => {
44
- await call('queue', 'ack', { queueName, jobId, returnValue });
64
+ await call('queue', 'ack', queuePayload({ queueName, jobId, returnValue }));
45
65
  };
46
66
  /** Mark a pulled job failed. */
47
67
  export const failJob = async (queueName, jobId, reason) => {
48
68
  try {
49
- await call('queue', 'fail', { queueName, jobId, reason });
69
+ await call('queue', 'fail', queuePayload({ queueName, jobId, reason }));
50
70
  }
51
71
  catch (error) {
52
72
  Logger.warn('[worker-runtime] failJob RPC failed', { queueName, jobId, error });
@@ -1,7 +1,10 @@
1
1
  /**
2
- * Auto-generated fallback module.
3
- * This file is created by scripts/ensure-worker-plugins.mjs when missing.
4
- * It allows optional runtime plugin imports to resolve in CI/scaffolded setups.
2
+ * ZinTrust plugin auto-imports
3
+ *
4
+ * In real projects, this file is managed by `zin plugin install` and contains
5
+ * side-effect imports (e.g. `@zintrust/db-sqlite/register`) that register
6
+ * optional adapters/drivers into core registries.
7
+ *
5
8
  */
6
9
  export type {};
7
10
  export declare const __zintrustGeneratedPluginStub = "zintrust.plugins.ts";
@@ -1 +1 @@
1
- {"version":3,"file":"zintrust.plugins.d.ts","sourceRoot":"","sources":["../../src/zintrust.plugins.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,YAAY,EAAE,CAAC;AAgBf,eAAO,MAAM,6BAA6B,wBAAwB,CAAC;;AACnE,wBAAkB"}
1
+ {"version":3,"file":"zintrust.plugins.d.ts","sourceRoot":"","sources":["../../src/zintrust.plugins.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,YAAY,EAAE,CAAC;AAgBf,eAAO,MAAM,6BAA6B,wBAAwB,CAAC;;AACnE,wBAAkB"}
@@ -1,7 +1,10 @@
1
1
  /**
2
- * Auto-generated fallback module.
3
- * This file is created by scripts/ensure-worker-plugins.mjs when missing.
4
- * It allows optional runtime plugin imports to resolve in CI/scaffolded setups.
2
+ * ZinTrust plugin auto-imports
3
+ *
4
+ * In real projects, this file is managed by `zin plugin install` and contains
5
+ * side-effect imports (e.g. `@zintrust/db-sqlite/register`) that register
6
+ * optional adapters/drivers into core registries.
7
+ *
5
8
  */
6
9
  import * as TraceRuntime from './runtime/plugins/trace-runtime.js';
7
10
  globalThis.__zintrust_system_trace_plugin_requested__ = true;