@zintrust/core 0.4.42 → 0.4.43

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": "0.4.42",
3
+ "version": "0.4.43",
4
4
  "description": "Production-grade TypeScript backend framework for JavaScript",
5
5
  "homepage": "https://zintrust.com",
6
6
  "repository": {
@@ -58,7 +58,7 @@
58
58
  },
59
59
  "dependencies": {
60
60
  "@cloudflare/containers": "^0.2.0",
61
- "@zintrust/workers": "^0.4.42",
61
+ "@zintrust/workers": "^0.4.43",
62
62
  "bcryptjs": "^3.0.3",
63
63
  "bullmq": "^5.71.1",
64
64
  "chalk": "^5.6.2",
@@ -1 +1 @@
1
- {"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../../../src/boot/registry/runtime.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAOvD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AA+N9C,eAAO,MAAM,8BAA8B,GAAI,iBAAiB,gBAAgB,KAAG,IA4BlF,CAAC;AA6RF,eAAO,MAAM,eAAe,GAAI,QAAQ;IACtC,WAAW,EAAE,MAAM,CAAC;IACpB,gBAAgB,EAAE,MAAM,CAAC;IACzB,MAAM,EAAE,OAAO,CAAC;IAChB,eAAe,EAAE,gBAAgB,CAAC;IAClC,SAAS,EAAE,MAAM,OAAO,CAAC;IACzB,SAAS,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;CACrC,KAAG;IAAE,IAAI,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAAC,QAAQ,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;CA8E7D,CAAC"}
1
+ {"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../../../src/boot/registry/runtime.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAOvD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AA+N9C,eAAO,MAAM,8BAA8B,GAAI,iBAAiB,gBAAgB,KAAG,IA4BlF,CAAC;AAiSF,eAAO,MAAM,eAAe,GAAI,QAAQ;IACtC,WAAW,EAAE,MAAM,CAAC;IACpB,gBAAgB,EAAE,MAAM,CAAC;IACzB,MAAM,EAAE,OAAO,CAAC;IAChB,eAAe,EAAE,gBAAgB,CAAC;IAClC,SAAS,EAAE,MAAM,OAAO,CAAC;IACzB,SAAS,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;CACrC,KAAG;IAAE,IAAI,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAAC,QAAQ,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;CA8E7D,CAAC"}
@@ -373,11 +373,13 @@ const resolveDebuggerMiddleware = () => {
373
373
  };
374
374
  const resolveDebuggerConnectionName = (configuredConnection) => {
375
375
  const explicitConnection = configuredConnection?.trim();
376
- if (explicitConnection !== undefined && explicitConnection !== '')
377
- return explicitConnection;
376
+ const runtimeDefault = String(databaseConfig.default ?? '').trim() || 'default';
377
+ if (explicitConnection !== undefined && explicitConnection !== '') {
378
+ return explicitConnection === 'default' ? runtimeDefault : explicitConnection;
379
+ }
378
380
  const defaultConnection = readEnvString('DB_CONNECTION').trim();
379
- if (defaultConnection === '')
380
- return 'default';
381
+ if (defaultConnection === '' || defaultConnection === 'default')
382
+ return runtimeDefault;
381
383
  return defaultConnection;
382
384
  };
383
385
  const hasDebuggerRouteRegistered = (router, basePath) => {
@@ -1 +1 @@
1
- {"version":3,"file":"DebuggerCommands.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/DebuggerCommands.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAkB,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAqBrE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAqhBzC,eAAO,MAAM,gBAAgB;sCACK,YAAY;sCAQZ,YAAY;uCAaX,YAAY;wCAgBX,YAAY;;cA7C5B,MAAM;oBAAc,MAAM,OAAO;;;cAAjC,MAAM;oBAAc,MAAM,OAAO;;;cAAjC,MAAM;oBAAc,MAAM,OAAO;;;cAAjC,MAAM;oBAAc,MAAM,OAAO;;EAoEnD,CAAC"}
1
+ {"version":3,"file":"DebuggerCommands.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/DebuggerCommands.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAkB,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAqBrE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAslBzC,eAAO,MAAM,gBAAgB;sCACK,YAAY;sCAQZ,YAAY;uCAaX,YAAY;wCAgBX,YAAY;;cA7C5B,MAAM;oBAAc,MAAM,OAAO;;;cAAjC,MAAM;oBAAc,MAAM,OAAO;;;cAAjC,MAAM;oBAAc,MAAM,OAAO;;;cAAjC,MAAM;oBAAc,MAAM,OAAO;;EAoEnD,CAAC"}
@@ -82,11 +82,40 @@ const getD1DatabaseName = (options) => {
82
82
  return 'zintrust_db';
83
83
  };
84
84
  const getInteractive = (options) => options['interactive'] !== false;
85
+ const resolveRuntimeDefaultConnectionName = () => {
86
+ const configuredDefault = String(databaseConfig.default ?? '').trim();
87
+ return configuredDefault === '' ? 'default' : configuredDefault;
88
+ };
89
+ const normalizeConnectionName = (value) => {
90
+ const normalized = value.trim();
91
+ if (normalized === '' || normalized === 'default') {
92
+ return resolveRuntimeDefaultConnectionName();
93
+ }
94
+ return normalized;
95
+ };
85
96
  const resolveDebuggerConnectionName = (options) => {
86
97
  if (isNonEmptyString(options['connection'])) {
87
- return String(options['connection']).trim();
98
+ return normalizeConnectionName(String(options['connection']));
88
99
  }
89
- return readEnvString('DEBUGGER_DB_CONNECTION').trim() || 'default';
100
+ return normalizeConnectionName(readEnvString('DEBUGGER_DB_CONNECTION').trim());
101
+ };
102
+ const withConfiguredDebuggerConnection = (options, configuredConnection) => {
103
+ if (isNonEmptyString(options['connection'])) {
104
+ return {
105
+ ...options,
106
+ connection: resolveDebuggerConnectionName(options),
107
+ };
108
+ }
109
+ if (isNonEmptyString(configuredConnection)) {
110
+ return {
111
+ ...options,
112
+ connection: normalizeConnectionName(configuredConnection),
113
+ };
114
+ }
115
+ return {
116
+ ...options,
117
+ connection: resolveDebuggerConnectionName(options),
118
+ };
90
119
  };
91
120
  const resolveDebuggerConnectionConfig = (options) => {
92
121
  const selected = resolveDebuggerConnectionName(options);
@@ -97,9 +126,24 @@ const isD1ConnectionDriver = (driver) => driver === 'd1' || driver === 'd1-remot
97
126
  const resolveD1ExecutionMode = (options) => {
98
127
  return options['local'] === true || options['remote'] !== true;
99
128
  };
100
- const ANSI_ESCAPE_PATTERN = new RegExp(String.raw `\u001b\[[0-9;]*m`, 'g');
129
+ const ANSI_ESCAPE = String.fromCodePoint(27);
101
130
  const stripAnsi = (value) => {
102
- return value.replaceAll(ANSI_ESCAPE_PATTERN, '');
131
+ let output = '';
132
+ for (let index = 0; index < value.length; index += 1) {
133
+ const char = value[index];
134
+ if (char !== ANSI_ESCAPE) {
135
+ output += char;
136
+ continue;
137
+ }
138
+ if (value[index + 1] !== '[') {
139
+ continue;
140
+ }
141
+ index += 2;
142
+ while (index < value.length && value[index] !== 'm') {
143
+ index += 1;
144
+ }
145
+ }
146
+ return output;
103
147
  };
104
148
  const extractWranglerJson = (output) => {
105
149
  const normalized = stripAnsi(output);
@@ -131,6 +175,26 @@ const parseWranglerTable = (output) => {
131
175
  return Object.fromEntries(headers.map((header, index) => [header, cells[index] ?? '']));
132
176
  });
133
177
  };
178
+ const buildStatsFromJsonPayload = (payload) => {
179
+ const stats = {};
180
+ for (const row of payload[0]?.results ?? []) {
181
+ if (typeof row.type === 'string') {
182
+ stats[row.type] = typeof row.cnt === 'number' ? row.cnt : 0;
183
+ }
184
+ }
185
+ return stats;
186
+ };
187
+ const buildStatsFromTableRows = (rows) => {
188
+ const stats = {};
189
+ for (const row of rows) {
190
+ const key = row['type'] ?? '';
191
+ const count = Number.parseInt(row['cnt'] ?? '0', 10);
192
+ if (key !== '') {
193
+ stats[key] = Number.isNaN(count) ? 0 : count;
194
+ }
195
+ }
196
+ return stats;
197
+ };
134
198
  const withSqlDebuggerStorage = async (options, callback) => {
135
199
  const { DebuggerStorage } = await loadDebuggerModule();
136
200
  const conn = resolveDebuggerConnectionConfig(options);
@@ -152,24 +216,9 @@ const executeD1Stats = (options) => {
152
216
  });
153
217
  const payload = extractWranglerJson(output);
154
218
  if (payload !== null) {
155
- const stats = {};
156
- for (const row of payload[0]?.results ?? []) {
157
- if (typeof row.type === 'string') {
158
- stats[row.type] = typeof row.cnt === 'number' ? row.cnt : 0;
159
- }
160
- }
161
- return stats;
219
+ return buildStatsFromJsonPayload(payload);
162
220
  }
163
- const rows = parseWranglerTable(output);
164
- const stats = {};
165
- for (const row of rows) {
166
- const key = row['type'] ?? '';
167
- const count = Number.parseInt(row['cnt'] ?? '0', 10);
168
- if (key !== '') {
169
- stats[key] = Number.isNaN(count) ? 0 : count;
170
- }
171
- }
172
- return stats;
221
+ return buildStatsFromTableRows(parseWranglerTable(output));
173
222
  };
174
223
  const executeD1Delete = (options, sql) => {
175
224
  const output = WranglerD1.executeSql({
@@ -196,49 +245,46 @@ const isDestructiveAction = (options) => options['fresh'] === true || options['r
196
245
  const executePrune = async (options) => {
197
246
  const { DebuggerConfig } = await loadDebuggerModule();
198
247
  const config = DebuggerConfig.merge();
248
+ const resolvedOptions = withConfiguredDebuggerConnection(options, config.connection);
199
249
  const hours = typeof options['hours'] === 'string' && options['hours'] !== ''
200
250
  ? Number.parseInt(options['hours'], 10)
201
251
  : config.pruneAfterHours;
202
252
  const olderThanMs = hours * 60 * 60 * 1000;
203
253
  const keepExceptions = options['keepExceptions'] === true;
204
- const conn = resolveDebuggerConnectionConfig({
205
- ...options,
206
- connection: config.connection ?? 'default',
207
- });
254
+ const conn = resolveDebuggerConnectionConfig(resolvedOptions);
208
255
  const threshold = Date.now() - olderThanMs;
209
256
  const pruneSql = keepExceptions
210
257
  ? `DELETE FROM zin_debugger_entries WHERE created_at < ${String(threshold)} AND type != 'exception'`
211
258
  : `DELETE FROM zin_debugger_entries WHERE created_at < ${String(threshold)}`;
212
259
  Logger.info(`Pruning debugger entries older than ${hours}h...`);
213
260
  const deleted = isD1ConnectionDriver(conn.driver)
214
- ? await executeD1Delete(options, pruneSql)
215
- : await withSqlDebuggerStorage({ ...options, connection: config.connection ?? 'default' }, async (storage) => storage.prune(olderThanMs, keepExceptions));
261
+ ? executeD1Delete(options, pruneSql)
262
+ : await withSqlDebuggerStorage(resolvedOptions, async (storage) => storage.prune(olderThanMs, keepExceptions));
216
263
  Logger.info(`Done - removed ${deleted} entries.`);
217
264
  };
218
265
  const executeClear = async (options) => {
219
266
  const { DebuggerConfig } = await loadDebuggerModule();
220
267
  const config = DebuggerConfig.merge();
221
- const conn = resolveDebuggerConnectionConfig({
222
- ...options,
223
- connection: config.connection ?? 'default',
224
- });
268
+ const resolvedOptions = withConfiguredDebuggerConnection(options, config.connection);
269
+ const conn = resolveDebuggerConnectionConfig(resolvedOptions);
225
270
  Logger.info('Clearing all debugger entries...');
226
271
  if (isD1ConnectionDriver(conn.driver)) {
227
- await executeD1Delete(options, 'DELETE FROM zin_debugger_entries');
272
+ executeD1Delete(options, 'DELETE FROM zin_debugger_entries');
228
273
  }
229
274
  else {
230
- await withSqlDebuggerStorage({ ...options, connection: config.connection ?? 'default' }, async (storage) => storage.clear());
275
+ await withSqlDebuggerStorage(resolvedOptions, async (storage) => storage.clear());
231
276
  }
232
277
  Logger.info('Done - all entries cleared.');
233
278
  };
234
279
  const executeStatus = async (options, cmd) => {
235
280
  const { DebuggerConfig } = await loadDebuggerModule();
236
281
  const config = DebuggerConfig.merge();
237
- const connection = config.connection ?? 'default';
238
- const conn = resolveDebuggerConnectionConfig({ ...options, connection });
282
+ const resolvedOptions = withConfiguredDebuggerConnection(options, config.connection);
283
+ const connection = resolveDebuggerConnectionName(resolvedOptions);
284
+ const conn = resolveDebuggerConnectionConfig(resolvedOptions);
239
285
  const stats = isD1ConnectionDriver(conn.driver)
240
- ? await executeD1Stats(options)
241
- : await withSqlDebuggerStorage({ ...options, connection }, async (storage) => storage.stats());
286
+ ? executeD1Stats(options)
287
+ : await withSqlDebuggerStorage(resolvedOptions, async (storage) => storage.stats());
242
288
  cmd.info(`Debugger enabled via env: ${readEnvString('DEBUGGER_ENABLED').trim() || 'false'}`);
243
289
  cmd.info(`Connection: ${connection}`);
244
290
  cmd.info(`Prune after hours: ${String(config.pruneAfterHours)}`);
@@ -1 +1 @@
1
- {"version":3,"file":"database.d.ts","sourceRoot":"","sources":["../../../src/config/database.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EACV,mBAAmB,EACnB,wBAAwB,EACxB,mBAAmB,EACpB,MAAM,cAAc,CAAC;AAItB,MAAM,MAAM,uBAAuB,GAAG,OAAO,CAAC;IAC5C,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,mBAAmB,CAAC;IACjC,OAAO,EAAE;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;IAC7C,UAAU,EAAE;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC;IACrD,OAAO,EAAE;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC;CAChC,CAAC,CAAC;AAuQH,QAAA,MAAM,oBAAoB,QAAO;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,mBAAmB,CAAC;IACjC,aAAa,EAAE,CAAC,IAAI,EAAE,mBAAmB,KAAK,wBAAwB,CAAC;IACvE,OAAO,EAAE;QAAE,O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rD,OAAO,EAAE;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC;CAyEhC,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG,UAAU,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAqBrE,eAAO,MAAM,cAAc,EAAE,cAY3B,CAAC"}
@@ -152,15 +152,21 @@ const normalizeReadHosts = (primaryHost, hosts) => {
152
152
  const filtered = hosts.filter((host) => host !== '' && host !== primary);
153
153
  return filtered.length > 0 ? filtered : undefined;
154
154
  };
155
+ const resolveImplicitDefaultConnection = (connections) => {
156
+ return hasOwn(connections, 'sqlite') ? 'sqlite' : (Object.keys(connections)[0] ?? 'sqlite');
157
+ };
155
158
  const getDefaultConnection = (connections) => {
156
159
  const envSelectedRaw = Env.get('DB_CONNECTION', '');
157
160
  const value = String(envSelectedRaw ?? '').trim();
158
161
  if (value.length > 0 && hasOwn(connections, value))
159
162
  return value;
163
+ if (value === 'default') {
164
+ return resolveImplicitDefaultConnection(connections);
165
+ }
160
166
  if (envSelectedRaw.trim().length > 0) {
161
167
  throw ErrorFactory.createConfigError(`Database connection not configured: ${value}`);
162
168
  }
163
- return hasOwn(connections, 'sqlite') ? 'sqlite' : (Object.keys(connections)[0] ?? 'sqlite');
169
+ return resolveImplicitDefaultConnection(connections);
164
170
  };
165
171
  const getDatabaseConnection = (config) => {
166
172
  const connName = config.default;
@@ -1 +1 @@
1
- {"version":3,"file":"cloudflare.d.ts","sourceRoot":"","sources":["../../../src/functions/cloudflare.ts"],"names":[],"mappings":";mBAqPuB,OAAO,QAAQ,OAAO,QAAQ,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC;;AADhF,wBAwCE"}
1
+ {"version":3,"file":"cloudflare.d.ts","sourceRoot":"","sources":["../../../src/functions/cloudflare.ts"],"names":[],"mappings":";mBAgOuB,OAAO,QAAQ,OAAO,QAAQ,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC;;AADhF,wBAmCE"}
@@ -1,8 +1,5 @@
1
- import { appConfig } from '../config/index.js';
2
- import { Application } from '../boot/Application.js';
3
1
  import { Logger } from '../config/logger.js';
4
2
  import { clearMiddlewareConfigCache } from '../config/middleware.js';
5
- import { Kernel } from '../http/Kernel.js';
6
3
  import { CloudflareAdapter } from '../runtime/adapters/CloudflareAdapter.js';
7
4
  import mergeOverrideValues from '../runtime/OverrideValueMerge.js';
8
5
  import { ProjectRuntime } from '../runtime/ProjectRuntime.js';
@@ -174,17 +171,6 @@ const ensureStartupConfigOverridesLoaded = async () => {
174
171
  startupConfigOverridesPromise ??= applyStartupConfigOverrides();
175
172
  await startupConfigOverridesPromise;
176
173
  };
177
- const resolveRequestKernel = async () => {
178
- if (!appConfig.isDevelopment()) {
179
- return { kernel: await getKernel() };
180
- }
181
- const app = Application.create();
182
- await app.boot();
183
- return {
184
- kernel: Kernel.create(app.getRouter(), app.getContainer()),
185
- shutdown: app.shutdown,
186
- };
187
- };
188
174
  export default {
189
175
  async fetch(request, _env, _ctx) {
190
176
  try {
@@ -199,19 +185,14 @@ export default {
199
185
  await ensureStartupConfigOverridesLoaded();
200
186
  await WorkerAdapterImports.ready; // NOSONAR - Ensure adapter imports are ready before handling requests.
201
187
  await injectIoredisModule();
202
- const runtimeKernel = await resolveRequestKernel();
203
- try {
204
- const adapter = CloudflareAdapter.create({
205
- handler: async (req, res) => {
206
- await runtimeKernel.kernel.handle(req, res);
207
- },
208
- });
209
- const platformResponse = await adapter.handle(request);
210
- return adapter.formatResponse(platformResponse);
211
- }
212
- finally {
213
- await runtimeKernel.shutdown?.();
214
- }
188
+ const kernel = await getKernel();
189
+ const adapter = CloudflareAdapter.create({
190
+ handler: async (req, res) => {
191
+ await kernel.handle(req, res);
192
+ },
193
+ });
194
+ const platformResponse = await adapter.handle(request);
195
+ return adapter.formatResponse(platformResponse);
215
196
  }
216
197
  catch (error) {
217
198
  const err = error;
package/src/index.js CHANGED
@@ -1,11 +1,11 @@
1
1
  /**
2
- * @zintrust/core v0.4.42
2
+ * @zintrust/core v0.4.43
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-01T13:54:49.809Z
8
+ * Built: 2026-04-01T18:01:04.910Z
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-01T13:54:49.771Z'; // Replaced during build
24
+ export const ZINTRUST_BUILD_DATE = '2026-04-01T18:01:04.872Z'; // 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';
@@ -35,5 +35,6 @@ export declare const Database: Readonly<{
35
35
  }>;
36
36
  export declare const useEnsureDbConnected: (config?: DatabaseConfig | undefined, connectionName?: string) => Promise<ReturnType<typeof useDatabase>>;
37
37
  export declare function useDatabase(config?: DatabaseConfig, connection?: string): IDatabase;
38
+ export declare function aliasDatabaseConnection(alias: string, targetConnection: string): IDatabase;
38
39
  export declare function resetDatabase(): Promise<void>;
39
40
  //# sourceMappingURL=Database.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Database.d.ts","sourceRoot":"","sources":["../../../src/orm/Database.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAYxD,OAAO,KAAK,EAAE,cAAc,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAE1F,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAGvD,MAAM,MAAM,QAAQ,GAAG;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAEzC,MAAM,WAAW,SAAS;IACxB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,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c,GAAG,SAAS;EAI1C,CAAC;AAIH,eAAO,MAAM,oBAAoB,GAC/B,SAAQ,cAAc,GAAG,SAAqB,EAC9C,uBAA0B,KACzB,OAAO,CAAC,UAAU,CAAC,OAAO,WAAW,CAAC,CAMxC,CAAC;AAEF,wBAAgB,WAAW,CAAC,MAAM,CAAC,EAAE,cAAc,EAAE,UAAU,SAAY,GAAG,SAAS,CAsBtF;AAED,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,GAAG,SAAS,CAQ1F;AAED,wBAAsB,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC,CAanD"}
@@ -12,13 +12,13 @@ import { D1Adapter } from './adapters/D1Adapter.js';
12
12
  import { D1RemoteAdapter } from './adapters/D1RemoteAdapter.js';
13
13
  import { MySQLAdapter } from './adapters/MySQLAdapter.js';
14
14
  import { MySQLProxyAdapter } from './adapters/MySQLProxyAdapter.js';
15
- import { DatabaseConnectionRegistry } from './DatabaseConnectionRegistry.js';
16
15
  import { PostgreSQLAdapter } from './adapters/PostgreSQLAdapter.js';
17
16
  import { PostgreSQLProxyAdapter } from './adapters/PostgreSQLProxyAdapter.js';
18
17
  import { SQLiteAdapter } from './adapters/SQLiteAdapter.js';
19
18
  import { SQLServerAdapter } from './adapters/SQLServerAdapter.js';
20
19
  import { createSqlServerProxyAdapter } from './adapters/SqlServerProxyAdapter.js';
21
20
  import { DatabaseAdapterRegistry } from './DatabaseAdapterRegistry.js';
21
+ import { DatabaseConnectionRegistry } from './DatabaseConnectionRegistry.js';
22
22
  import { QueryBuilder } from './QueryBuilder.js';
23
23
  /**
24
24
  * Database Manager
@@ -435,8 +435,17 @@ export function useDatabase(config, connection = 'default') {
435
435
  }
436
436
  return instance;
437
437
  }
438
+ export function aliasDatabaseConnection(alias, targetConnection) {
439
+ if (alias === targetConnection) {
440
+ return useDatabase(undefined, targetConnection);
441
+ }
442
+ const target = useDatabase(undefined, targetConnection);
443
+ databaseInstances.set(alias, target);
444
+ return target;
445
+ }
438
446
  export async function resetDatabase() {
439
- const promises = Array.from(databaseInstances.values()).map(async (instance) => {
447
+ const uniqueInstances = Array.from(new Set(databaseInstances.values()));
448
+ const promises = uniqueInstances.map(async (instance) => {
440
449
  try {
441
450
  await instance.disconnect();
442
451
  instance.dispose();
@@ -1 +1 @@
1
- {"version":3,"file":"DatabaseRuntimeRegistration.d.ts","sourceRoot":"","sources":["../../../src/orm/DatabaseRuntimeRegistration.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EACV,mBAAmB,EAGpB,MAAM,cAAc,CAAC;AA4DtB;;;;;;;GAOG;AACH,wBAAgB,kCAAkC,CAAC,MAAM,EAAE,mBAAmB,GAAG,IAAI,CAapF"}
1
+ {"version":3,"file":"DatabaseRuntimeRegistration.d.ts","sourceRoot":"","sources":["../../../src/orm/DatabaseRuntimeRegistration.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EACV,mBAAmB,EAGpB,MAAM,cAAc,CAAC;AA4DtB;;;;;;;GAOG;AACH,wBAAgB,kCAAkC,CAAC,MAAM,EAAE,mBAAmB,GAAG,IAAI,CAsBpF"}
@@ -5,8 +5,8 @@
5
5
  * instances that can be selected via `useDatabase(undefined, name)`.
6
6
  */
7
7
  import { ErrorFactory } from '../exceptions/ZintrustError.js';
8
+ import { aliasDatabaseConnection, useDatabase } from './Database.js';
8
9
  import { DatabaseConnectionRegistry } from './DatabaseConnectionRegistry.js';
9
- import { useDatabase } from './Database.js';
10
10
  const toOrmConfig = (cfg) => {
11
11
  switch (cfg.driver) {
12
12
  case 'sqlite':
@@ -71,7 +71,13 @@ export function registerDatabasesFromRuntimeConfig(config) {
71
71
  if (defaultCfg === undefined) {
72
72
  throw ErrorFactory.createConfigError(`Database default connection not configured: ${String(config.default ?? '')}`);
73
73
  }
74
+ const defaultOrmConfig = toOrmConfig(defaultCfg);
75
+ DatabaseConnectionRegistry.set('default', defaultOrmConfig);
74
76
  Logger.info(`✓ Registering default database connection: ${config.default}`);
75
- useDatabase(toOrmConfig(defaultCfg), config.default);
76
- useDatabase(toOrmConfig(defaultCfg), 'default');
77
+ useDatabase(defaultOrmConfig, config.default);
78
+ if (config.default !== 'default') {
79
+ aliasDatabaseConnection('default', config.default);
80
+ return;
81
+ }
82
+ useDatabase(defaultOrmConfig, 'default');
77
83
  }
@@ -1 +1 @@
1
- {"version":3,"file":"system-debugger-runtime.d.ts","sourceRoot":"","sources":["../../../../src/runtime/plugins/system-debugger-runtime.ts"],"names":[],"mappings":"AAAA,KAAK,iBAAiB,GAAG;IACvB,KAAK,CAAC,SAAS,CAAC,EAAE,OAAO,GAAG;QAAE,OAAO,CAAC,EAAE,OAAO,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CACxE,CAAC;AAEF,KAAK,kBAAkB,GAAG;IACxB,cAAc,CAAC,EAAE,EAAE,OAAO,GAAG,OAAO,CAAC;CACtC,CAAC;AAgCF,eAAO,MAAM,WAAW,QAAO,OAA6C,CAAC;AAE7E,eAAO,MAAM,cAAc,EAAE,iBACmC,CAAC;AAEjE,eAAO,MAAM,eAAe,EAAE,kBACoC,CAAC;AAEnE,eAAO,MAAM,sBAAsB,WAlCvB,OAAO,WACN,OAAO,YACN;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAA;CAAE,KAChE,IAgCyE,CAAC;AAEjF,eAAO,MAAM,8BAA8B,QAAa,OAAO,CAAC,IAAI,CAGnE,CAAC"}
1
+ {"version":3,"file":"system-debugger-runtime.d.ts","sourceRoot":"","sources":["../../../../src/runtime/plugins/system-debugger-runtime.ts"],"names":[],"mappings":"AAAA,KAAK,iBAAiB,GAAG;IACvB,KAAK,CAAC,SAAS,CAAC,EAAE,OAAO,GAAG;QAAE,OAAO,CAAC,EAAE,OAAO,CAAC;QAAC,UAAU,CAAC,EAAE,MAA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