@zintrust/core 0.4.5 → 0.4.6
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/cli/commands/D1MigrateCommand.d.ts.map +1 -1
- package/src/cli/commands/D1MigrateCommand.js +8 -1
- package/src/cli/commands/MigrateCommand.d.ts.map +1 -1
- package/src/cli/commands/MigrateCommand.js +13 -3
- package/src/cli/d1/LocalD1Resolver.d.ts +2 -1
- package/src/cli/d1/LocalD1Resolver.d.ts.map +1 -1
- package/src/cli/d1/LocalD1Resolver.js +52 -19
- package/src/cli/d1/WranglerConfig.d.ts +21 -0
- package/src/cli/d1/WranglerConfig.d.ts.map +1 -1
- package/src/cli/d1/WranglerConfig.js +98 -8
- package/src/index.js +3 -3
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"D1MigrateCommand.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/D1MigrateCommand.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAkB,YAAY,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"D1MigrateCommand.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/D1MigrateCommand.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAkB,YAAY,EAAE,MAAM,kBAAkB,CAAC;AA2HrE;;;GAGG;AAEH;;GAEG;AACH,eAAO,MAAM,gBAAgB;IAC3B;;OAEG;cACO,YAAY;EAyBtB,CAAC"}
|
|
@@ -21,7 +21,14 @@ const getDbName = (projectRoot, options) => {
|
|
|
21
21
|
const value = options['database'];
|
|
22
22
|
if (typeof value === 'string' && value.trim() !== '')
|
|
23
23
|
return value.trim();
|
|
24
|
-
|
|
24
|
+
const resolution = WranglerConfig.resolveD1Database(projectRoot);
|
|
25
|
+
if (resolution.status === 'resolved') {
|
|
26
|
+
return WranglerConfig.getDefaultD1DatabaseName(projectRoot) ?? 'zintrust_db';
|
|
27
|
+
}
|
|
28
|
+
if (resolution.status === 'ambiguous') {
|
|
29
|
+
throw ErrorFactory.createCliError('Multiple D1 targets are configured. Re-run with --database <database_name|binding> to choose the intended Wrangler D1 target.');
|
|
30
|
+
}
|
|
31
|
+
return 'zintrust_db';
|
|
25
32
|
};
|
|
26
33
|
const buildExecutionContext = (options) => {
|
|
27
34
|
const isWorkerCommand = process.argv.includes('d1:migrate:worker');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MigrateCommand.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/MigrateCommand.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAkB,YAAY,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"MigrateCommand.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/MigrateCommand.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAkB,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAmfrE;;GAEG;AACH,eAAO,MAAM,cAAc;IACzB;;OAEG;cACO,YAAY;EAUtB,CAAC"}
|
|
@@ -169,9 +169,19 @@ const runD1Actions = async (params) => {
|
|
|
169
169
|
cmd.warn('Note: MIGRATIONS_SEPARATE_TRACKING is ignored for D1 (Wrangler owns tracking).');
|
|
170
170
|
}
|
|
171
171
|
const isLocal = options['local'] === true || options['remote'] !== true;
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
172
|
+
let dbName = 'zintrust_db';
|
|
173
|
+
if (typeof options['database'] === 'string' && options['database'].trim() !== '') {
|
|
174
|
+
dbName = options['database'].trim();
|
|
175
|
+
}
|
|
176
|
+
else {
|
|
177
|
+
const resolution = WranglerConfig.resolveD1Database(projectRoot);
|
|
178
|
+
if (resolution.status === 'resolved') {
|
|
179
|
+
dbName = WranglerConfig.getDefaultD1DatabaseName(projectRoot) ?? 'zintrust_db';
|
|
180
|
+
}
|
|
181
|
+
else if (resolution.status === 'ambiguous') {
|
|
182
|
+
throw ErrorFactory.createCliError('Multiple D1 targets are configured. Re-run with --database <database_name|binding> to choose the intended Wrangler D1 target.');
|
|
183
|
+
}
|
|
184
|
+
}
|
|
175
185
|
const migrationsRelDir = WranglerConfig.getD1MigrationsDir(projectRoot, dbName);
|
|
176
186
|
const outputDir = path.join(projectRoot, migrationsRelDir);
|
|
177
187
|
cmd.info(`Generating D1 SQL migrations into ${migrationsRelDir}...`);
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { type WranglerD1DatabaseConfig } from '../d1/WranglerConfig';
|
|
1
|
+
import { type WranglerD1DatabaseConfig, type WranglerD1ResolutionMatch } from '../d1/WranglerConfig';
|
|
2
2
|
type ResolvedD1Target = {
|
|
3
3
|
config: WranglerD1DatabaseConfig;
|
|
4
4
|
databaseName: string;
|
|
5
|
+
matchedBy: WranglerD1ResolutionMatch;
|
|
5
6
|
};
|
|
6
7
|
export declare const LocalD1Resolver: Readonly<{
|
|
7
8
|
resolveD1Binding(projectRoot: string, target?: string): ResolvedD1Target;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LocalD1Resolver.d.ts","sourceRoot":"","sources":["../../../../src/cli/d1/LocalD1Resolver.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"LocalD1Resolver.d.ts","sourceRoot":"","sources":["../../../../src/cli/d1/LocalD1Resolver.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,wBAAwB,EAE7B,KAAK,yBAAyB,EAC/B,MAAM,wBAAwB,CAAC;AAYhC,KAAK,gBAAgB,GAAG;IACtB,MAAM,EAAE,wBAAwB,CAAC;IACjC,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,yBAAyB,CAAC;CACtC,CAAC;AAyHF,eAAO,MAAM,eAAe;kCACI,MAAM,WAAW,MAAM,GAAG,gBAAgB;oCAIxC,MAAM,WAAW,MAAM,GAAG,gBAAgB;0CAoB9B,MAAM,WAAW,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;EAoCrF,CAAC"}
|
|
@@ -1,41 +1,70 @@
|
|
|
1
|
+
import { WranglerConfig, } from '../d1/WranglerConfig.js';
|
|
2
|
+
import { WranglerD1 } from '../d1/WranglerD1.js';
|
|
1
3
|
import { Logger } from '../../config/logger.js';
|
|
2
4
|
import { ErrorFactory } from '../../exceptions/ZintrustError.js';
|
|
3
|
-
import { WranglerConfig } from '../d1/WranglerConfig.js';
|
|
4
|
-
import { WranglerD1 } from '../d1/WranglerD1.js';
|
|
5
5
|
import { isNonEmptyString } from '../../helper/index.js';
|
|
6
6
|
import { randomUUID } from '../../node-singletons/crypto.js';
|
|
7
7
|
import fs from '../../node-singletons/fs.js';
|
|
8
8
|
import * as path from '../../node-singletons/path.js';
|
|
9
9
|
import { SQLiteAdapter } from '../../orm/adapters/SQLiteAdapter.js';
|
|
10
10
|
const PROBE_TABLE = '__zintrust_d1_probe';
|
|
11
|
-
const
|
|
12
|
-
const
|
|
11
|
+
const describeTarget = (database) => {
|
|
12
|
+
const parts = [];
|
|
13
|
+
if (isNonEmptyString(database.database_name)) {
|
|
14
|
+
parts.push(`database_name=${database.database_name.trim()}`);
|
|
15
|
+
}
|
|
16
|
+
if (isNonEmptyString(database.binding)) {
|
|
17
|
+
parts.push(`binding=${database.binding.trim()}`);
|
|
18
|
+
}
|
|
19
|
+
return parts.length > 0 ? parts.join(', ') : 'unnamed-d1-entry';
|
|
20
|
+
};
|
|
21
|
+
const describeTargets = (configured) => {
|
|
22
|
+
const rendered = configured
|
|
13
23
|
.map((database) => {
|
|
14
|
-
|
|
15
|
-
if (isNonEmptyString(database.database_name)) {
|
|
16
|
-
parts.push(`database_name=${database.database_name.trim()}`);
|
|
17
|
-
}
|
|
18
|
-
if (isNonEmptyString(database.binding)) {
|
|
19
|
-
parts.push(`binding=${database.binding.trim()}`);
|
|
20
|
-
}
|
|
21
|
-
return parts.length > 0 ? parts.join(', ') : 'unnamed-d1-entry';
|
|
24
|
+
return describeTarget(database);
|
|
22
25
|
})
|
|
23
26
|
.filter((entry) => entry.length > 0);
|
|
24
|
-
return
|
|
27
|
+
return rendered.length > 0 ? rendered.join(' | ') : 'none';
|
|
28
|
+
};
|
|
29
|
+
const getSelectionHint = (matchedBy) => {
|
|
30
|
+
if (matchedBy === 'database_name')
|
|
31
|
+
return 'database_name';
|
|
32
|
+
if (matchedBy === 'binding')
|
|
33
|
+
return 'binding';
|
|
34
|
+
return 'configured D1 entry';
|
|
35
|
+
};
|
|
36
|
+
const createResolutionError = (resolution) => {
|
|
37
|
+
const configuredTargets = describeTargets(resolution.configured);
|
|
38
|
+
const targetLabel = resolution.target ?? '';
|
|
39
|
+
if (resolution.status === 'ambiguous') {
|
|
40
|
+
if (resolution.matchedBy === 'multiple-configured') {
|
|
41
|
+
return ErrorFactory.createConfigError(`Multiple D1 targets are configured in wrangler.jsonc. Specify a target by database_name or binding. Configured D1 targets: ${configuredTargets}`);
|
|
42
|
+
}
|
|
43
|
+
return ErrorFactory.createConfigError(`D1 target "${targetLabel}" is ambiguous by ${getSelectionHint(resolution.matchedBy)}. Matching entries: ${describeTargets(resolution.matches)}. Configured D1 targets: ${configuredTargets}`);
|
|
44
|
+
}
|
|
45
|
+
if (resolution.target === undefined) {
|
|
46
|
+
return ErrorFactory.createConfigError(`Unable to resolve a default D1 target from wrangler.jsonc. Configured D1 targets: ${configuredTargets}`);
|
|
47
|
+
}
|
|
48
|
+
return ErrorFactory.createConfigError(`Unable to resolve D1 target "${targetLabel}" from wrangler.jsonc. Tried database_name first, then binding. Configured D1 targets: ${configuredTargets}`);
|
|
25
49
|
};
|
|
26
50
|
const resolveTarget = (projectRoot, target) => {
|
|
27
|
-
const
|
|
51
|
+
const resolution = WranglerConfig.resolveD1Database(projectRoot, target);
|
|
52
|
+
if (resolution.status !== 'resolved') {
|
|
53
|
+
throw createResolutionError(resolution);
|
|
54
|
+
}
|
|
55
|
+
const config = resolution.config;
|
|
28
56
|
const configuredDatabaseName = config?.database_name?.trim();
|
|
29
57
|
const configuredBindingName = config?.binding?.trim();
|
|
30
58
|
const databaseName = configuredDatabaseName ??
|
|
31
59
|
(isNonEmptyString(configuredBindingName) ? configuredBindingName : undefined);
|
|
32
|
-
if (
|
|
33
|
-
throw ErrorFactory.createConfigError(`
|
|
60
|
+
if (!isNonEmptyString(databaseName)) {
|
|
61
|
+
throw ErrorFactory.createConfigError(`Resolved D1 target is missing both database_name and binding. Configured D1 targets: ${describeTargets(WranglerConfig.getD1Databases(projectRoot))}`);
|
|
34
62
|
}
|
|
35
|
-
return { config, databaseName };
|
|
63
|
+
return { config, databaseName, matchedBy: resolution.matchedBy };
|
|
36
64
|
};
|
|
65
|
+
const getLocalStateDir = (projectRoot) => path.join(projectRoot, '.wrangler', 'state', 'v3', 'd1', 'miniflare-D1DatabaseObject');
|
|
37
66
|
const listCandidateSqliteFiles = (projectRoot) => {
|
|
38
|
-
const candidateDir =
|
|
67
|
+
const candidateDir = getLocalStateDir(projectRoot);
|
|
39
68
|
if (!fs.existsSync(candidateDir))
|
|
40
69
|
return [];
|
|
41
70
|
return fs
|
|
@@ -66,6 +95,10 @@ export const LocalD1Resolver = Object.freeze({
|
|
|
66
95
|
},
|
|
67
96
|
ensureLocalD1Ready(projectRoot, target) {
|
|
68
97
|
const resolved = resolveTarget(projectRoot, target);
|
|
98
|
+
Logger.info(`[LocalD1Resolver] Resolved D1 target (${resolved.matchedBy}): ${describeTarget(resolved.config)}`);
|
|
99
|
+
if (listCandidateSqliteFiles(projectRoot).length === 0) {
|
|
100
|
+
Logger.info(`[LocalD1Resolver] Local D1 state missing, bootstrapping with Wrangler for ${resolved.databaseName}`);
|
|
101
|
+
}
|
|
69
102
|
WranglerD1.executeSql({
|
|
70
103
|
dbName: resolved.databaseName,
|
|
71
104
|
isLocal: true,
|
|
@@ -103,6 +136,6 @@ export const LocalD1Resolver = Object.freeze({
|
|
|
103
136
|
Logger.warn(`[LocalD1Resolver] Failed to remove D1 probe token: ${String(error)}`);
|
|
104
137
|
}
|
|
105
138
|
}
|
|
106
|
-
throw ErrorFactory.createConfigError(`Unable to resolve actual local D1 SQLite file for target "${resolved.databaseName}" under .
|
|
139
|
+
throw ErrorFactory.createConfigError(`Unable to resolve actual local D1 SQLite file for target "${resolved.databaseName}" under ${getLocalStateDir(projectRoot)}. Resolved D1 target: ${describeTarget(resolved.config)}`);
|
|
107
140
|
},
|
|
108
141
|
});
|
|
@@ -4,9 +4,30 @@ export type WranglerD1DatabaseConfig = {
|
|
|
4
4
|
database_id?: string;
|
|
5
5
|
migrations_dir?: string;
|
|
6
6
|
};
|
|
7
|
+
export type WranglerD1ResolutionMatch = 'database_name' | 'binding' | 'single-configured';
|
|
8
|
+
export type WranglerD1DatabaseResolution = {
|
|
9
|
+
status: 'resolved';
|
|
10
|
+
target?: string;
|
|
11
|
+
config: WranglerD1DatabaseConfig;
|
|
12
|
+
matchedBy: WranglerD1ResolutionMatch;
|
|
13
|
+
configured: WranglerD1DatabaseConfig[];
|
|
14
|
+
matches: WranglerD1DatabaseConfig[];
|
|
15
|
+
} | {
|
|
16
|
+
status: 'ambiguous';
|
|
17
|
+
target?: string;
|
|
18
|
+
matchedBy: 'database_name' | 'binding' | 'multiple-configured';
|
|
19
|
+
configured: WranglerD1DatabaseConfig[];
|
|
20
|
+
matches: WranglerD1DatabaseConfig[];
|
|
21
|
+
} | {
|
|
22
|
+
status: 'missing';
|
|
23
|
+
target?: string;
|
|
24
|
+
configured: WranglerD1DatabaseConfig[];
|
|
25
|
+
matches: WranglerD1DatabaseConfig[];
|
|
26
|
+
};
|
|
7
27
|
export declare const WranglerConfig: Readonly<{
|
|
8
28
|
getD1Databases(projectRoot: string): WranglerD1DatabaseConfig[];
|
|
9
29
|
getD1Database(projectRoot: string, target?: string): WranglerD1DatabaseConfig | undefined;
|
|
30
|
+
resolveD1Database(projectRoot: string, target?: string): WranglerD1DatabaseResolution;
|
|
10
31
|
getDefaultD1Database(projectRoot: string): WranglerD1DatabaseConfig | undefined;
|
|
11
32
|
getDefaultD1DatabaseName(projectRoot: string): string | undefined;
|
|
12
33
|
getD1MigrationsDir(projectRoot: string, dbName?: string): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WranglerConfig.d.ts","sourceRoot":"","sources":["../../../../src/cli/d1/WranglerConfig.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,wBAAwB,GAAG;IACrC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,CAAC;
|
|
1
|
+
{"version":3,"file":"WranglerConfig.d.ts","sourceRoot":"","sources":["../../../../src/cli/d1/WranglerConfig.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,wBAAwB,GAAG;IACrC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,yBAAyB,GAAG,eAAe,GAAG,SAAS,GAAG,mBAAmB,CAAC;AAE1F,MAAM,MAAM,4BAA4B,GACpC;IACE,MAAM,EAAE,UAAU,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,wBAAwB,CAAC;IACjC,SAAS,EAAE,yBAAyB,CAAC;IACrC,UAAU,EAAE,wBAAwB,EAAE,CAAC;IACvC,OAAO,EAAE,wBAAwB,EAAE,CAAC;CACrC,GACD;IACE,MAAM,EAAE,WAAW,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,eAAe,GAAG,SAAS,GAAG,qBAAqB,CAAC;IAC/D,UAAU,EAAE,wBAAwB,EAAE,CAAC;IACvC,OAAO,EAAE,wBAAwB,EAAE,CAAC;CACrC,GACD;IACE,MAAM,EAAE,SAAS,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,wBAAwB,EAAE,CAAC;IACvC,OAAO,EAAE,wBAAwB,EAAE,CAAC;CACrC,CAAC;AA8TN,eAAO,MAAM,cAAc;gCACG,MAAM,GAAG,wBAAwB,EAAE;+BAIpC,MAAM,WAAW,MAAM,GAAG,wBAAwB,GAAG,SAAS;mCAI1D,MAAM,WAAW,MAAM,GAAG,4BAA4B;sCAInD,MAAM,GAAG,wBAAwB,GAAG,SAAS;0CAIzC,MAAM,GAAG,MAAM,GAAG,SAAS;oCAIjC,MAAM,WAAW,MAAM,GAAG,MAAM;EAIhE,CAAC"}
|
|
@@ -158,19 +158,106 @@ const getResolvedD1Name = (config) => {
|
|
|
158
158
|
return config.binding.trim();
|
|
159
159
|
return undefined;
|
|
160
160
|
};
|
|
161
|
+
const getBindingName = (config) => {
|
|
162
|
+
if (config === undefined || !isNonEmptyString(config.binding))
|
|
163
|
+
return undefined;
|
|
164
|
+
return config.binding.trim();
|
|
165
|
+
};
|
|
166
|
+
const getDatabaseName = (config) => {
|
|
167
|
+
if (config === undefined || !isNonEmptyString(config.database_name))
|
|
168
|
+
return undefined;
|
|
169
|
+
return config.database_name.trim();
|
|
170
|
+
};
|
|
161
171
|
const getD1Databases = (projectRoot) => {
|
|
162
172
|
const parsed = readWranglerConfig(projectRoot);
|
|
163
173
|
return Array.isArray(parsed?.d1_databases) ? parsed.d1_databases : [];
|
|
164
174
|
};
|
|
165
|
-
const
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
175
|
+
const resolveImplicitD1Database = (configured, target) => {
|
|
176
|
+
if (configured.length === 1 && configured[0] !== undefined) {
|
|
177
|
+
return {
|
|
178
|
+
status: 'resolved',
|
|
179
|
+
target,
|
|
180
|
+
config: configured[0],
|
|
181
|
+
matchedBy: 'single-configured',
|
|
182
|
+
configured,
|
|
183
|
+
matches: [configured[0]],
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
return {
|
|
187
|
+
status: 'ambiguous',
|
|
188
|
+
target,
|
|
189
|
+
matchedBy: 'multiple-configured',
|
|
190
|
+
configured,
|
|
191
|
+
matches: configured,
|
|
192
|
+
};
|
|
193
|
+
};
|
|
194
|
+
const resolveTargetedD1Database = (configured, target) => {
|
|
195
|
+
const databaseNameMatches = configured.filter((database) => getDatabaseName(database) === target);
|
|
196
|
+
if (databaseNameMatches.length === 1 && databaseNameMatches[0] !== undefined) {
|
|
197
|
+
return {
|
|
198
|
+
status: 'resolved',
|
|
199
|
+
target,
|
|
200
|
+
config: databaseNameMatches[0],
|
|
201
|
+
matchedBy: 'database_name',
|
|
202
|
+
configured,
|
|
203
|
+
matches: databaseNameMatches,
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
if (databaseNameMatches.length > 1) {
|
|
207
|
+
return {
|
|
208
|
+
status: 'ambiguous',
|
|
209
|
+
target,
|
|
210
|
+
matchedBy: 'database_name',
|
|
211
|
+
configured,
|
|
212
|
+
matches: databaseNameMatches,
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
const bindingMatches = configured.filter((database) => getBindingName(database) === target);
|
|
216
|
+
if (bindingMatches.length === 1 && bindingMatches[0] !== undefined) {
|
|
217
|
+
return {
|
|
218
|
+
status: 'resolved',
|
|
219
|
+
target,
|
|
220
|
+
config: bindingMatches[0],
|
|
221
|
+
matchedBy: 'binding',
|
|
222
|
+
configured,
|
|
223
|
+
matches: bindingMatches,
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
if (bindingMatches.length > 1) {
|
|
227
|
+
return {
|
|
228
|
+
status: 'ambiguous',
|
|
229
|
+
target,
|
|
230
|
+
matchedBy: 'binding',
|
|
231
|
+
configured,
|
|
232
|
+
matches: bindingMatches,
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
return {
|
|
236
|
+
status: 'missing',
|
|
237
|
+
target,
|
|
238
|
+
configured,
|
|
239
|
+
matches: [],
|
|
240
|
+
};
|
|
241
|
+
};
|
|
242
|
+
const resolveD1Database = (projectRoot, target) => {
|
|
243
|
+
const configured = getD1Databases(projectRoot);
|
|
169
244
|
const normalizedTarget = normalizeTarget(target);
|
|
170
|
-
if (
|
|
171
|
-
return
|
|
172
|
-
|
|
173
|
-
|
|
245
|
+
if (configured.length === 0) {
|
|
246
|
+
return {
|
|
247
|
+
status: 'missing',
|
|
248
|
+
target: normalizedTarget,
|
|
249
|
+
configured,
|
|
250
|
+
matches: [],
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
if (normalizedTarget === undefined) {
|
|
254
|
+
return resolveImplicitD1Database(configured, normalizedTarget);
|
|
255
|
+
}
|
|
256
|
+
return resolveTargetedD1Database(configured, normalizedTarget);
|
|
257
|
+
};
|
|
258
|
+
const getD1Database = (projectRoot, target) => {
|
|
259
|
+
const resolution = resolveD1Database(projectRoot, target);
|
|
260
|
+
return resolution.status === 'resolved' ? resolution.config : undefined;
|
|
174
261
|
};
|
|
175
262
|
export const WranglerConfig = Object.freeze({
|
|
176
263
|
getD1Databases(projectRoot) {
|
|
@@ -179,6 +266,9 @@ export const WranglerConfig = Object.freeze({
|
|
|
179
266
|
getD1Database(projectRoot, target) {
|
|
180
267
|
return getD1Database(projectRoot, target);
|
|
181
268
|
},
|
|
269
|
+
resolveD1Database(projectRoot, target) {
|
|
270
|
+
return resolveD1Database(projectRoot, target);
|
|
271
|
+
},
|
|
182
272
|
getDefaultD1Database(projectRoot) {
|
|
183
273
|
return getD1Database(projectRoot);
|
|
184
274
|
},
|
package/src/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @zintrust/core v0.4.
|
|
2
|
+
* @zintrust/core v0.4.6
|
|
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-03-
|
|
8
|
+
* Built: 2026-03-21T13:48:56.018Z
|
|
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-03-
|
|
24
|
+
export const ZINTRUST_BUILD_DATE = '2026-03-21T13:48:55.987Z'; // 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';
|