@zintrust/core 0.1.23 → 0.1.24
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/DbSeedCommand.d.ts.map +1 -1
- package/src/cli/commands/DbSeedCommand.js +6 -38
- package/src/cli/commands/MigrateCommand.d.ts.map +1 -1
- package/src/cli/commands/MigrateCommand.js +12 -55
- package/src/cli/commands/MigrateWorkerCommand.d.ts.map +1 -1
- package/src/cli/commands/MigrateWorkerCommand.js +8 -54
- package/src/cli/commands/NewCommand.d.ts.map +1 -1
- package/src/cli/commands/NewCommand.js +1 -13
- package/src/cli/commands/StartCommand.d.ts.map +1 -1
- package/src/cli/commands/StartCommand.js +1 -13
- package/src/cli/utils/DatabaseCliUtils.d.ts +20 -0
- package/src/cli/utils/DatabaseCliUtils.d.ts.map +1 -0
- package/src/cli/utils/DatabaseCliUtils.js +54 -0
- package/src/index.js +3 -3
- package/src/runtime/PluginAutoImports.d.ts.map +1 -1
- package/src/runtime/PluginAutoImports.js +1 -13
- package/src/runtime/PluginManager.d.ts.map +1 -1
- package/src/runtime/PluginManager.js +1 -13
- package/src/toolkit/Secrets/providers/AwsSecretsManager.d.ts.map +1 -1
- package/src/toolkit/Secrets/providers/AwsSecretsManager.js +1 -13
- package/src/toolkit/Secrets/providers/CloudflareKv.d.ts.map +1 -1
- package/src/toolkit/Secrets/providers/CloudflareKv.js +4 -16
- package/src/tools/storage/drivers/S3.d.ts.map +1 -1
- package/src/tools/storage/drivers/S3.js +4 -16
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DbSeedCommand.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/DbSeedCommand.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAkB,YAAY,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"DbSeedCommand.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/DbSeedCommand.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAkB,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAkKrE,eAAO,MAAM,aAAa;cACd,YAAY;EAUtB,CAAC"}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import { SeederDiscovery } from '../../seeders/SeederDiscovery.js';
|
|
6
6
|
import { SeederLoader } from '../../seeders/SeederLoader.js';
|
|
7
7
|
import { BaseCommand } from '../BaseCommand.js';
|
|
8
|
-
import {
|
|
8
|
+
import { confirmProductionRun, mapConnectionToOrmConfig } from '../utils/DatabaseCliUtils.js';
|
|
9
9
|
import { databaseConfig } from '../../config/database.js';
|
|
10
10
|
import { Env } from '../../config/env.js';
|
|
11
11
|
import { ErrorFactory } from '../../exceptions/ZintrustError.js';
|
|
@@ -23,42 +23,6 @@ const ensureNonD1Driver = (driver) => {
|
|
|
23
23
|
throw ErrorFactory.createCliError('This project is configured for D1. Seeding via `zin db:seed` is not supported yet.');
|
|
24
24
|
}
|
|
25
25
|
};
|
|
26
|
-
const mapConnectionToOrmConfig = (conn) => {
|
|
27
|
-
switch (conn.driver) {
|
|
28
|
-
case 'sqlite':
|
|
29
|
-
return { driver: 'sqlite', database: conn.database };
|
|
30
|
-
case 'postgresql':
|
|
31
|
-
return {
|
|
32
|
-
driver: 'postgresql',
|
|
33
|
-
host: conn.host,
|
|
34
|
-
port: conn.port,
|
|
35
|
-
database: conn.database,
|
|
36
|
-
username: conn.username,
|
|
37
|
-
password: conn.password,
|
|
38
|
-
};
|
|
39
|
-
case 'mysql':
|
|
40
|
-
return {
|
|
41
|
-
driver: 'mysql',
|
|
42
|
-
host: conn.host,
|
|
43
|
-
port: conn.port,
|
|
44
|
-
database: conn.database,
|
|
45
|
-
username: conn.username,
|
|
46
|
-
password: conn.password,
|
|
47
|
-
};
|
|
48
|
-
default:
|
|
49
|
-
return { driver: 'sqlite', database: ':memory:' };
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
const confirmProductionRun = async (cmd, interactive) => {
|
|
53
|
-
if (Env.NODE_ENV !== 'production')
|
|
54
|
-
return true;
|
|
55
|
-
const confirmed = await PromptHelper.confirm('NODE_ENV=production. Continue running seeders?', false, interactive);
|
|
56
|
-
if (!confirmed) {
|
|
57
|
-
cmd.warn('Cancelled.');
|
|
58
|
-
return false;
|
|
59
|
-
}
|
|
60
|
-
return true;
|
|
61
|
-
};
|
|
62
26
|
const getServiceArgs = (options) => {
|
|
63
27
|
let serviceArg;
|
|
64
28
|
if (typeof options['onlyService'] === 'string') {
|
|
@@ -105,7 +69,11 @@ const selectSeederFiles = (files, seederName) => {
|
|
|
105
69
|
};
|
|
106
70
|
const executeSeed = async (options, cmd) => {
|
|
107
71
|
const interactive = getInteractive(options);
|
|
108
|
-
const okToProceed = await confirmProductionRun(
|
|
72
|
+
const okToProceed = await confirmProductionRun({
|
|
73
|
+
cmd,
|
|
74
|
+
interactive,
|
|
75
|
+
message: 'NODE_ENV=production. Continue running seeders?',
|
|
76
|
+
});
|
|
109
77
|
if (!okToProceed)
|
|
110
78
|
return;
|
|
111
79
|
const conn = databaseConfig.getConnection();
|
|
@@ -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;AA4ZrE;;GAEG;AACH,eAAO,MAAM,cAAc;IACzB;;OAEG;cACO,YAAY;EAUtB,CAAC"}
|
|
@@ -7,8 +7,9 @@ import { D1SqlMigrations } from '../d1/D1SqlMigrations.js';
|
|
|
7
7
|
import { WranglerConfig } from '../d1/WranglerConfig.js';
|
|
8
8
|
import { WranglerD1 } from '../d1/WranglerD1.js';
|
|
9
9
|
import { PromptHelper } from '../PromptHelper.js';
|
|
10
|
+
import { confirmProductionRun, mapConnectionToOrmConfig, parseRollbackSteps, } from '../utils/DatabaseCliUtils.js';
|
|
11
|
+
import { readEnvString } from '../../common/ExternalServiceUtils.js';
|
|
10
12
|
import { databaseConfig } from '../../config/database.js';
|
|
11
|
-
import { Env } from '../../config/env.js';
|
|
12
13
|
import { ErrorFactory } from '../../exceptions/ZintrustError.js';
|
|
13
14
|
import { Migrator } from '../../migrations/Migrator.js';
|
|
14
15
|
import * as path from '../../node-singletons/path.js';
|
|
@@ -32,9 +33,10 @@ const addMigrateOptions = (command) => {
|
|
|
32
33
|
};
|
|
33
34
|
const getInteractive = (options) => options['interactive'] !== false;
|
|
34
35
|
const getMigrationDirs = () => {
|
|
35
|
-
const globalDir =
|
|
36
|
+
const globalDir = readEnvString('MIGRATIONS_GLOBAL_DIR', databaseConfig.migrations.directory);
|
|
36
37
|
const extension = databaseConfig.migrations.extension;
|
|
37
|
-
const
|
|
38
|
+
const separateTrackingRaw = readEnvString('MIGRATIONS_SEPARATE_TRACKING', '').trim();
|
|
39
|
+
const separateTracking = separateTrackingRaw === '1' || separateTrackingRaw.toLowerCase() === 'true';
|
|
38
40
|
return { globalDir, extension, separateTracking };
|
|
39
41
|
};
|
|
40
42
|
const getServiceArgs = (options) => {
|
|
@@ -64,53 +66,6 @@ const describeTargetDatabase = (conn) => {
|
|
|
64
66
|
return `${conn.driver}`;
|
|
65
67
|
}
|
|
66
68
|
};
|
|
67
|
-
const mapConnectionToOrmConfig = (conn) => {
|
|
68
|
-
switch (conn.driver) {
|
|
69
|
-
case 'sqlite':
|
|
70
|
-
return { driver: 'sqlite', database: conn.database };
|
|
71
|
-
case 'postgresql':
|
|
72
|
-
return {
|
|
73
|
-
driver: 'postgresql',
|
|
74
|
-
host: conn.host,
|
|
75
|
-
port: conn.port,
|
|
76
|
-
database: conn.database,
|
|
77
|
-
username: conn.username,
|
|
78
|
-
password: conn.password,
|
|
79
|
-
};
|
|
80
|
-
case 'mysql':
|
|
81
|
-
return {
|
|
82
|
-
driver: 'mysql',
|
|
83
|
-
host: conn.host,
|
|
84
|
-
port: conn.port,
|
|
85
|
-
database: conn.database,
|
|
86
|
-
username: conn.username,
|
|
87
|
-
password: conn.password,
|
|
88
|
-
};
|
|
89
|
-
case 'sqlserver':
|
|
90
|
-
return {
|
|
91
|
-
driver: 'sqlserver',
|
|
92
|
-
host: conn.host,
|
|
93
|
-
port: conn.port,
|
|
94
|
-
database: conn.database,
|
|
95
|
-
username: conn.username,
|
|
96
|
-
password: conn.password,
|
|
97
|
-
};
|
|
98
|
-
default:
|
|
99
|
-
return { driver: 'sqlite', database: ':memory:' };
|
|
100
|
-
}
|
|
101
|
-
};
|
|
102
|
-
const confirmProductionRun = async (cmd, interactive, destructive, force) => {
|
|
103
|
-
if (Env.NODE_ENV !== 'production')
|
|
104
|
-
return true;
|
|
105
|
-
if (force)
|
|
106
|
-
return true;
|
|
107
|
-
const confirmed = await PromptHelper.confirm(`NODE_ENV=production. Continue running migrations${destructive ? ' (destructive)' : ''}?`, false, interactive);
|
|
108
|
-
if (!confirmed) {
|
|
109
|
-
cmd.warn('Cancelled.');
|
|
110
|
-
return false;
|
|
111
|
-
}
|
|
112
|
-
return true;
|
|
113
|
-
};
|
|
114
69
|
const printStatus = (cmd, rows) => {
|
|
115
70
|
if (rows.length === 0) {
|
|
116
71
|
cmd.info('No migrations found.');
|
|
@@ -133,10 +88,6 @@ const logAppliedMigrations = (cmd, appliedNames) => {
|
|
|
133
88
|
cmd.info(`✓ ${name}`);
|
|
134
89
|
}
|
|
135
90
|
};
|
|
136
|
-
const parseRollbackSteps = (options) => {
|
|
137
|
-
const stepRaw = typeof options['step'] === 'string' ? options['step'] : '1';
|
|
138
|
-
return Math.max(1, Number.parseInt(stepRaw, 10) || 1);
|
|
139
|
-
};
|
|
140
91
|
const handleStatusAction = async (migrator, cmd, driver) => {
|
|
141
92
|
cmd.info(`Adapter: ${driver}`);
|
|
142
93
|
const rows = await migrator.status();
|
|
@@ -267,7 +218,13 @@ const processConnection = async (conn, options, cmd, interactive) => {
|
|
|
267
218
|
const ormConfig = mapConnectionToOrmConfig(conn);
|
|
268
219
|
const destructive = isDestructiveAction(options);
|
|
269
220
|
const force = options['force'] === true;
|
|
270
|
-
const okToProceed = await confirmProductionRun(
|
|
221
|
+
const okToProceed = await confirmProductionRun({
|
|
222
|
+
cmd,
|
|
223
|
+
interactive,
|
|
224
|
+
destructive,
|
|
225
|
+
force,
|
|
226
|
+
message: 'NODE_ENV=production. Continue running migrations?',
|
|
227
|
+
});
|
|
271
228
|
if (!okToProceed)
|
|
272
229
|
return;
|
|
273
230
|
cmd.info(`[i] Target database: ${describeTargetDatabase(conn)}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MigrateWorkerCommand.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/MigrateWorkerCommand.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAkB,YAAY,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"MigrateWorkerCommand.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/MigrateWorkerCommand.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAkB,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAmKrE,eAAO,MAAM,oBAAoB;cACrB,YAAY;EAUtB,CAAC"}
|
|
@@ -3,9 +3,8 @@
|
|
|
3
3
|
* Run worker package migrations
|
|
4
4
|
*/
|
|
5
5
|
import { BaseCommand } from '../BaseCommand.js';
|
|
6
|
-
import {
|
|
6
|
+
import { confirmProductionRun, mapConnectionToOrmConfig, parseRollbackSteps, } from '../utils/DatabaseCliUtils.js';
|
|
7
7
|
import { databaseConfig } from '../../config/database.js';
|
|
8
|
-
import { Env } from '../../config/env.js';
|
|
9
8
|
import { Migrator } from '../../migrations/Migrator.js';
|
|
10
9
|
import * as path from '../../node-singletons/path.js';
|
|
11
10
|
import { Database } from '../../orm/Database.js';
|
|
@@ -22,58 +21,7 @@ const addOptions = (command) => {
|
|
|
22
21
|
.option('--no-interactive', 'Disable interactive prompts (useful for CI/CD)');
|
|
23
22
|
};
|
|
24
23
|
const getInteractive = (options) => options['interactive'] !== false;
|
|
25
|
-
const mapConnectionToOrmConfig = (conn) => {
|
|
26
|
-
switch (conn.driver) {
|
|
27
|
-
case 'sqlite':
|
|
28
|
-
return { driver: 'sqlite', database: conn.database };
|
|
29
|
-
case 'postgresql':
|
|
30
|
-
return {
|
|
31
|
-
driver: 'postgresql',
|
|
32
|
-
host: conn.host,
|
|
33
|
-
port: conn.port,
|
|
34
|
-
database: conn.database,
|
|
35
|
-
username: conn.username,
|
|
36
|
-
password: conn.password,
|
|
37
|
-
};
|
|
38
|
-
case 'mysql':
|
|
39
|
-
return {
|
|
40
|
-
driver: 'mysql',
|
|
41
|
-
host: conn.host,
|
|
42
|
-
port: conn.port,
|
|
43
|
-
database: conn.database,
|
|
44
|
-
username: conn.username,
|
|
45
|
-
password: conn.password,
|
|
46
|
-
};
|
|
47
|
-
case 'sqlserver':
|
|
48
|
-
return {
|
|
49
|
-
driver: 'sqlserver',
|
|
50
|
-
host: conn.host,
|
|
51
|
-
port: conn.port,
|
|
52
|
-
database: conn.database,
|
|
53
|
-
username: conn.username,
|
|
54
|
-
password: conn.password,
|
|
55
|
-
};
|
|
56
|
-
default:
|
|
57
|
-
return { driver: 'sqlite', database: ':memory:' };
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
24
|
const isDestructiveAction = (options) => options['fresh'] === true || options['reset'] === true || options['rollback'] === true;
|
|
61
|
-
const parseRollbackSteps = (options) => {
|
|
62
|
-
const stepRaw = typeof options['step'] === 'string' ? options['step'] : '1';
|
|
63
|
-
return Math.max(1, Number.parseInt(stepRaw, 10) || 1);
|
|
64
|
-
};
|
|
65
|
-
const confirmProductionRun = async (cmd, interactive, destructive, force) => {
|
|
66
|
-
if (Env.NODE_ENV !== 'production')
|
|
67
|
-
return true;
|
|
68
|
-
if (force)
|
|
69
|
-
return true;
|
|
70
|
-
const confirmed = await PromptHelper.confirm(`NODE_ENV=production. Continue running worker migrations${destructive ? ' (destructive)' : ''}?`, false, interactive);
|
|
71
|
-
if (!confirmed) {
|
|
72
|
-
cmd.warn('Cancelled.');
|
|
73
|
-
return false;
|
|
74
|
-
}
|
|
75
|
-
return true;
|
|
76
|
-
};
|
|
77
25
|
const printStatus = async (migrator, cmd) => {
|
|
78
26
|
const rows = await migrator.status();
|
|
79
27
|
if (rows.length === 0) {
|
|
@@ -123,7 +71,13 @@ const runActions = async (migrator, options, cmd, driver) => {
|
|
|
123
71
|
};
|
|
124
72
|
const runForConnection = async (conn, options, cmd, interactive) => {
|
|
125
73
|
const destructive = isDestructiveAction(options);
|
|
126
|
-
const proceed = await confirmProductionRun(
|
|
74
|
+
const proceed = await confirmProductionRun({
|
|
75
|
+
cmd,
|
|
76
|
+
interactive,
|
|
77
|
+
destructive,
|
|
78
|
+
force: options['force'] === true,
|
|
79
|
+
message: 'NODE_ENV=production. Continue running worker migrations?',
|
|
80
|
+
});
|
|
127
81
|
if (!proceed)
|
|
128
82
|
return;
|
|
129
83
|
if (!DatabaseAdapterRegistry.has(conn.driver)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NewCommand.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/NewCommand.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAerE,KAAK,YAAY,GAAG,OAAO,GAAG,KAAK,GAAG,cAAc,GAAG,WAAW,CAAC;AACnE,KAAK,YAAY,GAAG,QAAQ,GAAG,OAAO,GAAG,YAAY,GAAG,SAAS,GAAG,WAAW,CAAC;AAYhF,UAAU,sBAAsB;IAC9B,QAAQ,EAAE,YAAY,CAAC;IACvB,QAAQ,EAAE,YAAY,CAAC;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,KAAK,gBAAgB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"NewCommand.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/NewCommand.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAerE,KAAK,YAAY,GAAG,OAAO,GAAG,KAAK,GAAG,cAAc,GAAG,WAAW,CAAC;AACnE,KAAK,YAAY,GAAG,QAAQ,GAAG,OAAO,GAAG,YAAY,GAAG,SAAS,GAAG,WAAW,CAAC;AAYhF,UAAU,sBAAsB;IAC9B,QAAQ,EAAE,YAAY,CAAC;IACvB,QAAQ,EAAE,YAAY,CAAC;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,KAAK,gBAAgB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAwPhD,UAAU,WAAY,SAAQ,YAAY;IACxC,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAC;IACxF,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAC;IACzF,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,sBAAsB,GAAG,gBAAgB,EAAE,CAAC;IACjF,UAAU,IAAI,MAAM,CAAC,UAAU,CAAC;IAChC,YAAY,IAAI,MAAM,CAAC;IACvB,cAAc,CACZ,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,sBAAsB,EAC9B,SAAS,CAAC,EAAE,OAAO,GAClB,OAAO,CAAC,OAAO,CAAC,CAAC;IACpB,aAAa,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IACzC,uBAAuB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;CACpE;AAwOD;;;GAGG;AACH,eAAO,MAAM,UAAU;IACrB;;OAEG;cACO,WAAW;EAGrB,CAAC"}
|
|
@@ -3,9 +3,9 @@ import { PromptHelper } from '../PromptHelper.js';
|
|
|
3
3
|
import { GovernanceScaffolder } from '../scaffolding/GovernanceScaffolder.js';
|
|
4
4
|
import { ProjectScaffolder } from '../scaffolding/ProjectScaffolder.js';
|
|
5
5
|
import { SpawnUtil } from '../utils/spawn.js';
|
|
6
|
+
import { readEnvString } from '../../common/ExternalServiceUtils.js';
|
|
6
7
|
import { extractErrorMessage, resolvePackageManager } from '../../common/index.js';
|
|
7
8
|
import { appConfig } from '../../config/app.js';
|
|
8
|
-
import { Env } from '../../config/env.js';
|
|
9
9
|
import { ErrorFactory } from '../../exceptions/ZintrustError.js';
|
|
10
10
|
import { execFileSync } from '../../node-singletons/child-process.js';
|
|
11
11
|
import * as path from '../../node-singletons/path.js';
|
|
@@ -193,18 +193,6 @@ const promptForPackageManager = async (defaultPm) => {
|
|
|
193
193
|
};
|
|
194
194
|
const installDependencies = async (projectPath, log, packageManager, force = false) => {
|
|
195
195
|
// Respect CI by default — avoid network installs in CI unless explicitly allowed
|
|
196
|
-
const readEnvString = (key) => {
|
|
197
|
-
const anyEnv = Env;
|
|
198
|
-
const fromEnv = typeof anyEnv.get === 'function' ? anyEnv.get(key, '') : '';
|
|
199
|
-
if (typeof fromEnv === 'string' && fromEnv.trim() !== '')
|
|
200
|
-
return fromEnv;
|
|
201
|
-
if (typeof process !== 'undefined') {
|
|
202
|
-
const raw = process.env?.[key];
|
|
203
|
-
if (typeof raw === 'string')
|
|
204
|
-
return raw;
|
|
205
|
-
}
|
|
206
|
-
return fromEnv ?? '';
|
|
207
|
-
};
|
|
208
196
|
const ciRaw = readEnvString('CI').trim().toLowerCase();
|
|
209
197
|
const isCi = ciRaw !== '' && ciRaw !== '0' && ciRaw !== 'false';
|
|
210
198
|
const allowAuto = readEnvString('ZINTRUST_ALLOW_AUTO_INSTALL') === '1' || force;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StartCommand.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/StartCommand.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoC,KAAK,YAAY,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"StartCommand.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/StartCommand.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoC,KAAK,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAyZvF,eAAO,MAAM,YAAY;cACb,YAAY;EAyBtB,CAAC"}
|
|
@@ -2,8 +2,8 @@ import { BaseCommand } from '../BaseCommand.js';
|
|
|
2
2
|
import { DENO_RUNNER_SOURCE, LAMBDA_RUNNER_SOURCE } from '../commands/runner/index.js';
|
|
3
3
|
import { EnvFileLoader } from '../utils/EnvFileLoader.js';
|
|
4
4
|
import { SpawnUtil } from '../utils/spawn.js';
|
|
5
|
+
import { readEnvString } from '../../common/ExternalServiceUtils.js';
|
|
5
6
|
import { resolveNpmPath } from '../../common/index.js';
|
|
6
|
-
import { Env } from '../../config/env.js';
|
|
7
7
|
import { ErrorFactory } from '../../exceptions/ZintrustError.js';
|
|
8
8
|
import { existsSync, mkdirSync, readFileSync, writeFileSync } from '../../node-singletons/fs.js';
|
|
9
9
|
import * as path from '../../node-singletons/path.js';
|
|
@@ -20,18 +20,6 @@ const normalizeMode = (value) => {
|
|
|
20
20
|
return 'testing';
|
|
21
21
|
return 'development';
|
|
22
22
|
};
|
|
23
|
-
const readEnvString = (key) => {
|
|
24
|
-
const anyEnv = Env;
|
|
25
|
-
const fromEnv = typeof anyEnv.get === 'function' ? anyEnv.get(key, '') : '';
|
|
26
|
-
if (typeof fromEnv === 'string' && fromEnv.trim() !== '')
|
|
27
|
-
return fromEnv;
|
|
28
|
-
if (typeof process !== 'undefined') {
|
|
29
|
-
const raw = process.env?.[key];
|
|
30
|
-
if (typeof raw === 'string')
|
|
31
|
-
return raw;
|
|
32
|
-
}
|
|
33
|
-
return fromEnv ?? '';
|
|
34
|
-
};
|
|
35
23
|
const resolveModeFromAppMode = () => {
|
|
36
24
|
const raw = readEnvString('APP_MODE').trim();
|
|
37
25
|
const normalized = raw.toLowerCase();
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { CommandOptions, IBaseCommand } from '../BaseCommand';
|
|
2
|
+
import type { DatabaseConfig as OrmDatabaseConfig } from '../../orm/DatabaseAdapter';
|
|
3
|
+
export type ConnectionConfig = {
|
|
4
|
+
driver: string;
|
|
5
|
+
host?: string;
|
|
6
|
+
port?: number;
|
|
7
|
+
database?: string;
|
|
8
|
+
username?: string;
|
|
9
|
+
password?: string;
|
|
10
|
+
};
|
|
11
|
+
export declare const mapConnectionToOrmConfig: (conn: ConnectionConfig) => OrmDatabaseConfig;
|
|
12
|
+
export declare const parseRollbackSteps: (options: CommandOptions) => number;
|
|
13
|
+
export declare const confirmProductionRun: (params: {
|
|
14
|
+
cmd: IBaseCommand;
|
|
15
|
+
interactive: boolean;
|
|
16
|
+
message: string;
|
|
17
|
+
destructive?: boolean;
|
|
18
|
+
force?: boolean;
|
|
19
|
+
}) => Promise<boolean>;
|
|
20
|
+
//# sourceMappingURL=DatabaseCliUtils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DatabaseCliUtils.d.ts","sourceRoot":"","sources":["../../../../src/cli/utils/DatabaseCliUtils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAGrE,OAAO,KAAK,EAAE,cAAc,IAAI,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEhF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,eAAO,MAAM,wBAAwB,GAAI,MAAM,gBAAgB,KAAG,iBAkCjE,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAAI,SAAS,cAAc,KAAG,MAG5D,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAAU,QAAQ;IACjD,GAAG,EAAE,YAAY,CAAC;IAClB,WAAW,EAAE,OAAO,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB,KAAG,OAAO,CAAC,OAAO,CAalB,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { PromptHelper } from '../PromptHelper.js';
|
|
2
|
+
import { Env } from '../../config/env.js';
|
|
3
|
+
export const mapConnectionToOrmConfig = (conn) => {
|
|
4
|
+
switch (conn.driver) {
|
|
5
|
+
case 'sqlite':
|
|
6
|
+
return { driver: 'sqlite', database: conn.database ?? ':memory:' };
|
|
7
|
+
case 'postgresql':
|
|
8
|
+
return {
|
|
9
|
+
driver: 'postgresql',
|
|
10
|
+
host: conn.host,
|
|
11
|
+
port: conn.port,
|
|
12
|
+
database: conn.database,
|
|
13
|
+
username: conn.username,
|
|
14
|
+
password: conn.password,
|
|
15
|
+
};
|
|
16
|
+
case 'mysql':
|
|
17
|
+
return {
|
|
18
|
+
driver: 'mysql',
|
|
19
|
+
host: conn.host,
|
|
20
|
+
port: conn.port,
|
|
21
|
+
database: conn.database,
|
|
22
|
+
username: conn.username,
|
|
23
|
+
password: conn.password,
|
|
24
|
+
};
|
|
25
|
+
case 'sqlserver':
|
|
26
|
+
return {
|
|
27
|
+
driver: 'sqlserver',
|
|
28
|
+
host: conn.host,
|
|
29
|
+
port: conn.port,
|
|
30
|
+
database: conn.database,
|
|
31
|
+
username: conn.username,
|
|
32
|
+
password: conn.password,
|
|
33
|
+
};
|
|
34
|
+
default:
|
|
35
|
+
return { driver: 'sqlite', database: ':memory:' };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
export const parseRollbackSteps = (options) => {
|
|
39
|
+
const stepRaw = typeof options['step'] === 'string' ? options['step'] : '1';
|
|
40
|
+
return Math.max(1, Number.parseInt(stepRaw, 10) || 1);
|
|
41
|
+
};
|
|
42
|
+
export const confirmProductionRun = async (params) => {
|
|
43
|
+
if (Env.NODE_ENV !== 'production')
|
|
44
|
+
return true;
|
|
45
|
+
if (params.force === true)
|
|
46
|
+
return true;
|
|
47
|
+
const prompt = params.destructive === true ? `${params.message} (destructive)` : params.message;
|
|
48
|
+
const confirmed = await PromptHelper.confirm(prompt, false, params.interactive);
|
|
49
|
+
if (!confirmed) {
|
|
50
|
+
params.cmd.warn('Cancelled.');
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
return true;
|
|
54
|
+
};
|
package/src/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @zintrust/core v0.1.
|
|
2
|
+
* @zintrust/core v0.1.24
|
|
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-01-
|
|
8
|
+
* Built: 2026-01-21T15:09:58.669Z
|
|
9
9
|
* Node: >=20.0.0
|
|
10
10
|
* License: MIT
|
|
11
11
|
*
|
|
@@ -199,7 +199,7 @@ export { randomBytes } from './node-singletons/crypto.js';
|
|
|
199
199
|
* Available at runtime for debugging and health checks
|
|
200
200
|
*/
|
|
201
201
|
export const ZINTRUST_VERSION = '0.1.23';
|
|
202
|
-
export const ZINTRUST_BUILD_DATE = '2026-01-
|
|
202
|
+
export const ZINTRUST_BUILD_DATE = '2026-01-21T15:09:58.638Z'; // Replaced during build
|
|
203
203
|
export { createRedisConnection, workersConfig } from './config/workers.js';
|
|
204
204
|
// NOTE: Node-only exports (like FileLogWriter, process) are intentionally not
|
|
205
205
|
// exported from this root entrypoint. Use the '@zintrust/core/node' subpath.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PluginAutoImports.d.ts","sourceRoot":"","sources":["../../../src/runtime/PluginAutoImports.ts"],"names":[],"mappings":"AAOA,KAAK,YAAY,GACb;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,GAChC;IACE,EAAE,EAAE,KAAK,CAAC;IACV,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,WAAW,GAAG,eAAe,CAAC;IACtC,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;
|
|
1
|
+
{"version":3,"file":"PluginAutoImports.d.ts","sourceRoot":"","sources":["../../../src/runtime/PluginAutoImports.ts"],"names":[],"mappings":"AAOA,KAAK,YAAY,GACb;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,GAChC;IACE,EAAE,EAAE,KAAK,CAAC;IACV,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,WAAW,GAAG,eAAe,CAAC;IACtC,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAwBN,eAAO,MAAM,iBAAiB;IAC5B;;;;;;OAMG;mCACkC,OAAO,CAAC,YAAY,CAAC;EAgC1D,CAAC"}
|
|
@@ -1,21 +1,9 @@
|
|
|
1
1
|
import { pathToFileURL } from '../node-singletons/url.js';
|
|
2
|
-
import {
|
|
2
|
+
import { readEnvString } from '../common/ExternalServiceUtils.js';
|
|
3
3
|
import { Logger } from '../config/logger.js';
|
|
4
4
|
import { ErrorFactory } from '../exceptions/ZintrustError.js';
|
|
5
5
|
import { existsSync } from '../node-singletons/fs.js';
|
|
6
6
|
import * as path from '../node-singletons/path.js';
|
|
7
|
-
const readEnvString = (key) => {
|
|
8
|
-
const anyEnv = Env;
|
|
9
|
-
const fromEnv = typeof anyEnv.get === 'function' ? anyEnv.get(key, '') : '';
|
|
10
|
-
if (typeof fromEnv === 'string' && fromEnv.trim() !== '')
|
|
11
|
-
return fromEnv;
|
|
12
|
-
if (typeof process !== 'undefined') {
|
|
13
|
-
const raw = process.env?.[key];
|
|
14
|
-
if (typeof raw === 'string')
|
|
15
|
-
return raw;
|
|
16
|
-
}
|
|
17
|
-
return fromEnv ?? '';
|
|
18
|
-
};
|
|
19
7
|
const getProjectCwd = () => process.cwd();
|
|
20
8
|
const getProjectRootEnv = () => readEnvString('ZINTRUST_PROJECT_ROOT');
|
|
21
9
|
const resolveProjectRoot = () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PluginManager.d.ts","sourceRoot":"","sources":["../../../src/runtime/PluginManager.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"PluginManager.d.ts","sourceRoot":"","sources":["../../../src/runtime/PluginManager.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAgShE,eAAO,MAAM,aAAa;IACxB;;OAEG;YACK,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC;IAIxC;;OAEG;yBACkB,MAAM,GAAG,MAAM,GAAG,IAAI;IAW3C;;OAEG;0BACyB,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IA0DrD;;OAEG;sBACqB,MAAM,YAAY;QAAE,cAAc,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IA8BrF;;;;OAIG;wBACuB,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;EA2ChD,CAAC"}
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { execSync } from '../node-singletons/child-process.js';
|
|
7
7
|
import { SpawnUtil } from '../cli/utils/spawn.js';
|
|
8
|
+
import { readEnvString } from '../common/ExternalServiceUtils.js';
|
|
8
9
|
import { esmDirname, resolvePackageManager } from '../common/index.js';
|
|
9
|
-
import { Env } from '../config/env.js';
|
|
10
10
|
import { Logger } from '../config/logger.js';
|
|
11
11
|
import { ErrorFactory } from '../exceptions/ZintrustError.js';
|
|
12
12
|
import { existsSync, fsPromises as fs } from '../node-singletons/fs.js';
|
|
@@ -27,18 +27,6 @@ function findPackageRoot(startDir) {
|
|
|
27
27
|
// Fallback to a reasonable default if package.json isn't found.
|
|
28
28
|
return path.resolve(startDir, '../..');
|
|
29
29
|
}
|
|
30
|
-
const readEnvString = (key) => {
|
|
31
|
-
const anyEnv = Env;
|
|
32
|
-
const fromEnv = typeof anyEnv.get === 'function' ? anyEnv.get(key, '') : '';
|
|
33
|
-
if (typeof fromEnv === 'string' && fromEnv.trim() !== '')
|
|
34
|
-
return fromEnv;
|
|
35
|
-
if (typeof process !== 'undefined') {
|
|
36
|
-
const raw = process.env?.[key];
|
|
37
|
-
if (typeof raw === 'string')
|
|
38
|
-
return raw;
|
|
39
|
-
}
|
|
40
|
-
return fromEnv ?? '';
|
|
41
|
-
};
|
|
42
30
|
const getProjectCwd = () => process.cwd();
|
|
43
31
|
const getProjectRootEnv = () => readEnvString('ZINTRUST_PROJECT_ROOT');
|
|
44
32
|
const getAllowPostInstallEnv = () => readEnvString('ZINTRUST_ALLOW_POSTINSTALL').trim();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AwsSecretsManager.d.ts","sourceRoot":"","sources":["../../../../../src/toolkit/Secrets/providers/AwsSecretsManager.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,cAAc,GAAG;IAC3B,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,MAAM,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;
|
|
1
|
+
{"version":3,"file":"AwsSecretsManager.d.ts","sourceRoot":"","sources":["../../../../../src/toolkit/Secrets/providers/AwsSecretsManager.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,cAAc,GAAG;IAC3B,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,MAAM,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AA0GF,eAAO,MAAM,iBAAiB;qBACX;QACf,QAAQ,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;QACzE,QAAQ,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;KAC9D;iBAsDY,MAAM,EAAE;EAcrB,CAAC;AAEH,eAAe,iBAAiB,CAAC"}
|
|
@@ -1,19 +1,7 @@
|
|
|
1
|
+
import { readEnvString } from '../../../common/ExternalServiceUtils.js';
|
|
1
2
|
import { AwsSigV4 } from '../../../common/index.js';
|
|
2
|
-
import { Env } from '../../../config/env.js';
|
|
3
3
|
import { ErrorFactory } from '../../../exceptions/ZintrustError.js';
|
|
4
4
|
const sha256Hex = (data) => AwsSigV4.sha256Hex(data);
|
|
5
|
-
const readEnvString = (key) => {
|
|
6
|
-
const anyEnv = Env;
|
|
7
|
-
const fromEnv = typeof anyEnv.get === 'function' ? anyEnv.get(key, '') : '';
|
|
8
|
-
if (typeof fromEnv === 'string' && fromEnv.trim() !== '')
|
|
9
|
-
return fromEnv;
|
|
10
|
-
if (typeof process !== 'undefined') {
|
|
11
|
-
const raw = process.env?.[key];
|
|
12
|
-
if (typeof raw === 'string')
|
|
13
|
-
return raw;
|
|
14
|
-
}
|
|
15
|
-
return fromEnv ?? '';
|
|
16
|
-
};
|
|
17
5
|
const buildAuthorization = (params) => {
|
|
18
6
|
const canonicalUri = '/';
|
|
19
7
|
const canonicalQueryString = '';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CloudflareKv.d.ts","sourceRoot":"","sources":["../../../../../src/toolkit/Secrets/providers/CloudflareKv.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,YAAY;qBACN;QACf,QAAQ,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;QACxE,QAAQ,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;KAC/E;
|
|
1
|
+
{"version":3,"file":"CloudflareKv.d.ts","sourceRoot":"","sources":["../../../../../src/toolkit/Secrets/providers/CloudflareKv.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,YAAY;qBACN;QACf,QAAQ,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;QACxE,QAAQ,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;KAC/E;iBAsEY,MAAM,EAAE;EAcrB,CAAC;AAEH,eAAe,YAAY,CAAC"}
|
|
@@ -1,19 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { readEnvString } from '../../../common/ExternalServiceUtils.js';
|
|
2
2
|
import { ErrorFactory } from '../../../exceptions/ZintrustError.js';
|
|
3
3
|
export const CloudflareKv = Object.freeze({
|
|
4
4
|
createFromEnv() {
|
|
5
|
-
const readEnvString = (key) => {
|
|
6
|
-
const anyEnv = Env;
|
|
7
|
-
const fromEnv = typeof anyEnv.get === 'function' ? anyEnv.get(key, '') : '';
|
|
8
|
-
if (typeof fromEnv === 'string' && fromEnv.trim() !== '')
|
|
9
|
-
return fromEnv;
|
|
10
|
-
if (typeof process !== 'undefined') {
|
|
11
|
-
const raw = process.env?.[key];
|
|
12
|
-
if (typeof raw === 'string')
|
|
13
|
-
return raw;
|
|
14
|
-
}
|
|
15
|
-
return fromEnv ?? '';
|
|
16
|
-
};
|
|
17
5
|
const accountId = readEnvString('CLOUDFLARE_ACCOUNT_ID');
|
|
18
6
|
const apiToken = readEnvString('CLOUDFLARE_API_TOKEN');
|
|
19
7
|
const defaultNamespaceId = readEnvString('CLOUDFLARE_KV_NAMESPACE_ID');
|
|
@@ -71,13 +59,13 @@ export const CloudflareKv = Object.freeze({
|
|
|
71
59
|
},
|
|
72
60
|
doctorEnv() {
|
|
73
61
|
const missing = [];
|
|
74
|
-
const accountId = (
|
|
62
|
+
const accountId = readEnvString('CLOUDFLARE_ACCOUNT_ID').trim();
|
|
75
63
|
if (accountId === '')
|
|
76
64
|
missing.push('CLOUDFLARE_ACCOUNT_ID');
|
|
77
|
-
const apiToken = (
|
|
65
|
+
const apiToken = readEnvString('CLOUDFLARE_API_TOKEN').trim();
|
|
78
66
|
if (apiToken === '')
|
|
79
67
|
missing.push('CLOUDFLARE_API_TOKEN');
|
|
80
|
-
const namespaceId = (
|
|
68
|
+
const namespaceId = readEnvString('CLOUDFLARE_KV_NAMESPACE_ID').trim();
|
|
81
69
|
if (namespaceId === '')
|
|
82
70
|
missing.push('CLOUDFLARE_KV_NAMESPACE_ID');
|
|
83
71
|
return missing;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"S3.d.ts","sourceRoot":"","sources":["../../../../../src/tools/storage/drivers/S3.ts"],"names":[],"mappings":"AAKA,MAAM,MAAM,QAAQ,GAAG;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,OAAO,GAAG;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,MAAM,CAAC;IACxB,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC;CAClC,CAAC;
|
|
1
|
+
{"version":3,"file":"S3.d.ts","sourceRoot":"","sources":["../../../../../src/tools/storage/drivers/S3.ts"],"names":[],"mappings":"AAKA,MAAM,MAAM,QAAQ,GAAG;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,OAAO,GAAG;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,MAAM,CAAC;IACxB,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC;CAClC,CAAC;AAwGF,eAAO,MAAM,QAAQ;gBACD,QAAQ,OAAO,MAAM,WAAW,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;gBA8CjE,QAAQ,OAAO,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;mBA0CpC,QAAQ,OAAO,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;mBAkCxC,QAAQ,OAAO,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;gBAoC9C,QAAQ,OAAO,MAAM,GAAG,MAAM;oBAOhC,QAAQ,OACX,MAAM,YACD;QAAE,SAAS,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,KAAK,GAAG,KAAK,CAAA;KAAE,GACvD,MAAM;EAqDT,CAAC;AAEH,eAAe,QAAQ,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { readEnvString } from '../../../common/ExternalServiceUtils.js';
|
|
1
2
|
import { AwsSigV4 } from '../../../common/index.js';
|
|
2
|
-
import { Env } from '../../../config/env.js';
|
|
3
3
|
import { ErrorFactory } from '../../../exceptions/ZintrustError.js';
|
|
4
4
|
import { createHash, createHmac } from '../../../node-singletons/crypto.js';
|
|
5
5
|
const sha256Hex = (data) => createHash('sha256').update(data).digest('hex');
|
|
@@ -52,21 +52,9 @@ const buildCanonicalQueryString = (params) => {
|
|
|
52
52
|
return entries.map(([k, v]) => `${k}=${v}`).join('&');
|
|
53
53
|
};
|
|
54
54
|
const getCredentials = (config) => {
|
|
55
|
-
const
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
if (typeof fromEnv === 'string' && fromEnv.trim() !== '')
|
|
59
|
-
return fromEnv;
|
|
60
|
-
if (typeof process !== 'undefined') {
|
|
61
|
-
const raw = process.env?.[key];
|
|
62
|
-
if (typeof raw === 'string')
|
|
63
|
-
return raw;
|
|
64
|
-
}
|
|
65
|
-
return fromEnv ?? '';
|
|
66
|
-
};
|
|
67
|
-
const accessKeyId = config.accessKeyId || readEnvString('AWS_ACCESS_KEY_ID') || Env.AWS_ACCESS_KEY_ID;
|
|
68
|
-
const secretAccessKey = config.secretAccessKey || readEnvString('AWS_SECRET_ACCESS_KEY') || Env.AWS_SECRET_ACCESS_KEY;
|
|
69
|
-
const sessionToken = readEnvString('AWS_SESSION_TOKEN') || Env.AWS_SESSION_TOKEN || undefined;
|
|
55
|
+
const accessKeyId = config.accessKeyId || readEnvString('AWS_ACCESS_KEY_ID');
|
|
56
|
+
const secretAccessKey = config.secretAccessKey || readEnvString('AWS_SECRET_ACCESS_KEY');
|
|
57
|
+
const sessionToken = readEnvString('AWS_SESSION_TOKEN') || undefined;
|
|
70
58
|
if (accessKeyId.trim() === '' || secretAccessKey.trim() === '') {
|
|
71
59
|
throw ErrorFactory.createConfigError('S3: missing AWS credentials');
|
|
72
60
|
}
|