@zintrust/core 0.1.41 → 0.1.42
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 +17 -1
- package/src/boot/bootstrap.js +27 -11
- package/src/boot/registry/runtime.d.ts.map +1 -1
- package/src/boot/registry/runtime.js +11 -0
- package/src/cli/CLI.d.ts.map +1 -1
- package/src/cli/CLI.js +12 -0
- package/src/cli/commands/ConfigCommand.d.ts.map +1 -1
- package/src/cli/commands/ConfigCommand.js +3 -5
- package/src/cli/commands/D1LearnCommand.d.ts +9 -0
- package/src/cli/commands/D1LearnCommand.d.ts.map +1 -0
- package/src/cli/commands/D1LearnCommand.js +143 -0
- package/src/cli/commands/D1MigrateCommand.d.ts.map +1 -1
- package/src/cli/commands/D1MigrateCommand.js +55 -16
- package/src/cli/commands/InitContainerCommand.d.ts.map +1 -1
- package/src/cli/commands/InitContainerCommand.js +21 -6
- package/src/cli/commands/InitEcosystemCommand.d.ts +6 -0
- package/src/cli/commands/InitEcosystemCommand.d.ts.map +1 -0
- package/src/cli/commands/InitEcosystemCommand.js +51 -0
- package/src/cli/commands/MigrateCommand.d.ts.map +1 -1
- package/src/cli/commands/MigrateCommand.js +78 -36
- package/src/cli/commands/MigrateWorkerCommand.d.ts.map +1 -1
- package/src/cli/commands/MigrateWorkerCommand.js +36 -2
- package/src/cli/commands/PutCommand.d.ts +6 -0
- package/src/cli/commands/PutCommand.d.ts.map +1 -0
- package/src/cli/commands/PutCommand.js +173 -0
- package/src/cli/commands/QueueRecoveryCommand.d.ts.map +1 -1
- package/src/cli/commands/QueueRecoveryCommand.js +113 -14
- package/src/cli/commands/ScheduleListCommand.d.ts +6 -0
- package/src/cli/commands/ScheduleListCommand.d.ts.map +1 -0
- package/src/cli/commands/ScheduleListCommand.js +62 -0
- package/src/cli/commands/ScheduleRunCommand.d.ts +6 -0
- package/src/cli/commands/ScheduleRunCommand.d.ts.map +1 -0
- package/src/cli/commands/ScheduleRunCommand.js +32 -0
- package/src/cli/commands/ScheduleStartCommand.d.ts +6 -0
- package/src/cli/commands/ScheduleStartCommand.d.ts.map +1 -0
- package/src/cli/commands/ScheduleStartCommand.js +40 -0
- package/src/cli/commands/SecretsCommand.d.ts.map +1 -1
- package/src/cli/commands/SecretsCommand.js +2 -2
- package/src/cli/commands/schedule/ScheduleCliSupport.d.ts +6 -0
- package/src/cli/commands/schedule/ScheduleCliSupport.d.ts.map +1 -0
- package/src/cli/commands/schedule/ScheduleCliSupport.js +55 -0
- package/src/cli/config/ConfigManager.d.ts.map +1 -1
- package/src/cli/config/ConfigManager.js +8 -1
- package/src/cli/d1/D1SqlMigrations.d.ts.map +1 -1
- package/src/cli/d1/D1SqlMigrations.js +11 -1
- package/src/cli/d1/WranglerConfig.d.ts.map +1 -1
- package/src/cli/d1/WranglerConfig.js +34 -2
- package/src/cli/services/VersionChecker.d.ts.map +1 -1
- package/src/cli/services/VersionChecker.js +5 -1
- package/src/cli/utils/DatabaseCliUtils.d.ts.map +1 -1
- package/src/cli/utils/DatabaseCliUtils.js +6 -1
- package/src/cli/utils/EnvFileLoader.d.ts.map +1 -1
- package/src/cli/utils/EnvFileLoader.js +33 -14
- package/src/cli.d.ts +5 -0
- package/src/cli.d.ts.map +1 -0
- package/src/cli.js +4 -0
- package/src/collections/index.d.ts +2 -2
- package/src/collections/index.d.ts.map +1 -1
- package/src/collections/index.js +1 -1
- package/src/common/RemoteSignedJson.d.ts.map +1 -1
- package/src/common/RemoteSignedJson.js +49 -23
- package/src/common/utility.d.ts.map +1 -1
- package/src/common/utility.js +2 -6
- package/src/config/cloudflare.d.ts.map +1 -1
- package/src/config/cloudflare.js +19 -8
- package/src/config/env.js +2 -2
- package/src/helper/index.d.ts +225 -0
- package/src/helper/index.d.ts.map +1 -0
- package/src/helper/index.js +347 -0
- package/src/index.d.ts +3 -6
- package/src/index.d.ts.map +1 -1
- package/src/index.js +7 -9
- package/src/migrations/MigrationDiscovery.d.ts.map +1 -1
- package/src/migrations/MigrationDiscovery.js +2 -1
- package/src/orm/DatabaseAdapter.d.ts +1 -0
- package/src/orm/DatabaseAdapter.d.ts.map +1 -1
- package/src/orm/SchemaStatemenWriter.d.ts +15 -0
- package/src/orm/SchemaStatemenWriter.d.ts.map +1 -0
- package/src/orm/SchemaStatemenWriter.js +78 -0
- package/src/orm/adapters/D1Adapter.d.ts.map +1 -1
- package/src/orm/adapters/D1Adapter.js +52 -2
- package/src/orm/adapters/D1RemoteAdapter.d.ts.map +1 -1
- package/src/orm/adapters/D1RemoteAdapter.js +137 -89
- package/src/orm/adapters/MySQLProxyAdapter.d.ts.map +1 -1
- package/src/orm/adapters/MySQLProxyAdapter.js +100 -81
- package/src/orm/adapters/PostgreSQLProxyAdapter.d.ts.map +1 -1
- package/src/orm/adapters/PostgreSQLProxyAdapter.js +26 -10
- package/src/orm/adapters/SqlProxyAdapterUtils.d.ts.map +1 -1
- package/src/orm/adapters/SqlProxyAdapterUtils.js +2 -1
- package/src/orm/adapters/SqlProxyRegistryMode.d.ts +12 -0
- package/src/orm/adapters/SqlProxyRegistryMode.d.ts.map +1 -0
- package/src/orm/adapters/SqlProxyRegistryMode.js +24 -0
- package/src/orm/adapters/SqlServerProxyAdapter.d.ts +3 -0
- package/src/orm/adapters/SqlServerProxyAdapter.d.ts.map +1 -1
- package/src/orm/adapters/SqlServerProxyAdapter.js +125 -117
- package/src/orm/migrations/MigrationStore.js +1 -1
- package/src/proxy/ProxyRequestParsing.d.ts +9 -0
- package/src/proxy/ProxyRequestParsing.d.ts.map +1 -0
- package/src/proxy/ProxyRequestParsing.js +16 -0
- package/src/proxy/RequestValidator.d.ts.map +1 -1
- package/src/proxy/RequestValidator.js +2 -1
- package/src/proxy/SigningService.js +2 -2
- package/src/proxy/SqlProxyDbOverrides.d.ts +17 -0
- package/src/proxy/SqlProxyDbOverrides.d.ts.map +1 -0
- package/src/proxy/SqlProxyDbOverrides.js +1 -0
- package/src/proxy/SqlProxyServerDeps.d.ts +12 -0
- package/src/proxy/SqlProxyServerDeps.d.ts.map +1 -0
- package/src/proxy/SqlProxyServerDeps.js +9 -0
- package/src/proxy/StatementPayloadValidator.d.ts +13 -0
- package/src/proxy/StatementPayloadValidator.d.ts.map +1 -0
- package/src/proxy/StatementPayloadValidator.js +18 -0
- package/src/proxy/StatementRegistryLoader.d.ts +2 -0
- package/src/proxy/StatementRegistryLoader.d.ts.map +1 -0
- package/src/proxy/StatementRegistryLoader.js +36 -0
- package/src/proxy/StatementRegistryResolver.d.ts +15 -0
- package/src/proxy/StatementRegistryResolver.d.ts.map +1 -0
- package/src/proxy/StatementRegistryResolver.js +34 -0
- package/src/proxy/d1/ZintrustD1Proxy.d.ts +2 -1
- package/src/proxy/d1/ZintrustD1Proxy.d.ts.map +1 -1
- package/src/proxy/d1/ZintrustD1Proxy.js +2 -1
- package/src/proxy/isMutatingSql.d.ts +2 -0
- package/src/proxy/isMutatingSql.d.ts.map +1 -0
- package/src/proxy/isMutatingSql.js +12 -0
- package/src/proxy/kv/ZintrustKvProxy.d.ts +2 -1
- package/src/proxy/kv/ZintrustKvProxy.d.ts.map +1 -1
- package/src/proxy/kv/ZintrustKvProxy.js +2 -1
- package/src/proxy/mysql/MySqlProxyServer.d.ts +2 -8
- package/src/proxy/mysql/MySqlProxyServer.d.ts.map +1 -1
- package/src/proxy/mysql/MySqlProxyServer.js +84 -51
- package/src/proxy/postgres/PostgresProxyServer.d.ts +2 -8
- package/src/proxy/postgres/PostgresProxyServer.d.ts.map +1 -1
- package/src/proxy/postgres/PostgresProxyServer.js +86 -48
- package/src/proxy/smtp/SmtpProxyServer.d.ts.map +1 -1
- package/src/proxy/smtp/SmtpProxyServer.js +6 -5
- package/src/proxy/sqlserver/SqlServerProxyServer.d.ts +2 -8
- package/src/proxy/sqlserver/SqlServerProxyServer.d.ts.map +1 -1
- package/src/proxy/sqlserver/SqlServerProxyServer.js +84 -49
- package/src/proxy.d.ts +4 -0
- package/src/proxy.d.ts.map +1 -0
- package/src/proxy.js +3 -0
- package/src/scheduler/Schedule.d.ts +36 -0
- package/src/scheduler/Schedule.d.ts.map +1 -0
- package/src/scheduler/Schedule.js +197 -0
- package/src/scheduler/ScheduleHttpGateway.d.ts +8 -0
- package/src/scheduler/ScheduleHttpGateway.d.ts.map +1 -0
- package/src/scheduler/ScheduleHttpGateway.js +196 -0
- package/src/scheduler/ScheduleRunner.d.ts +6 -0
- package/src/scheduler/ScheduleRunner.d.ts.map +1 -1
- package/src/scheduler/ScheduleRunner.js +166 -29
- package/src/scheduler/SchedulerRuntime.d.ts +15 -0
- package/src/scheduler/SchedulerRuntime.d.ts.map +1 -0
- package/src/scheduler/SchedulerRuntime.js +79 -0
- package/src/scheduler/cron/Cron.d.ts +19 -0
- package/src/scheduler/cron/Cron.d.ts.map +1 -0
- package/src/scheduler/cron/Cron.js +200 -0
- package/src/scheduler/leader/SchedulerLeader.d.ts +14 -0
- package/src/scheduler/leader/SchedulerLeader.d.ts.map +1 -0
- package/src/scheduler/leader/SchedulerLeader.js +187 -0
- package/src/scheduler/state/ScheduleStateStore.d.ts +27 -0
- package/src/scheduler/state/ScheduleStateStore.d.ts.map +1 -0
- package/src/scheduler/state/ScheduleStateStore.js +27 -0
- package/src/scheduler/types.d.ts +10 -0
- package/src/scheduler/types.d.ts.map +1 -1
- package/src/schedules/index.d.ts +1 -0
- package/src/schedules/index.d.ts.map +1 -1
- package/src/schedules/index.js +1 -0
- package/src/schedules/job-tracking-cleanup.d.ts +4 -0
- package/src/schedules/job-tracking-cleanup.d.ts.map +1 -0
- package/src/schedules/job-tracking-cleanup.js +116 -0
- package/src/schedules/log-cleanup.d.ts +1 -2
- package/src/schedules/log-cleanup.d.ts.map +1 -1
- package/src/schedules/log-cleanup.js +12 -15
- package/src/security/Sanitizer.d.ts.map +1 -1
- package/src/security/Sanitizer.js +1 -9
- package/src/security/SignedRequest.d.ts.map +1 -1
- package/src/security/SignedRequest.js +2 -2
- package/src/templates/docker/docker-compose.ecosystem.yml.tpl +301 -0
- package/src/templates/docker/docker-compose.schedules.yml.tpl +84 -0
- package/src/templates/project/basic/app/Schedules/index.ts.tpl +0 -0
- package/src/templates/project/basic/config/database.ts.tpl +1 -1
- package/src/toolkit/Secrets/Manifest.d.ts.map +1 -1
- package/src/toolkit/Secrets/Manifest.js +5 -7
- package/src/tools/mail/drivers/Smtp.d.ts.map +1 -1
- package/src/tools/mail/drivers/Smtp.js +7 -1
- package/src/tools/queue/JobReconciliationRunner.d.ts.map +1 -1
- package/src/tools/queue/JobReconciliationRunner.js +7 -39
- package/src/tools/queue/JobRecoveryDaemon.d.ts.map +1 -1
- package/src/tools/queue/JobRecoveryDaemon.js +116 -18
- package/src/tools/queue/JobStateTracker.d.ts +10 -1
- package/src/tools/queue/JobStateTracker.d.ts.map +1 -1
- package/src/tools/queue/JobStateTracker.js +24 -2
- package/src/tools/queue/JobStateTrackerDbPersistence.d.ts.map +1 -1
- package/src/tools/queue/JobStateTrackerDbPersistence.js +93 -2
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export const isMutatingSql = (sql) => {
|
|
2
|
+
const s = sql.trimStart().toLowerCase();
|
|
3
|
+
return (s.startsWith('insert') ||
|
|
4
|
+
s.startsWith('update') ||
|
|
5
|
+
s.startsWith('delete') ||
|
|
6
|
+
s.startsWith('merge') ||
|
|
7
|
+
s.startsWith('create') ||
|
|
8
|
+
s.startsWith('drop') ||
|
|
9
|
+
s.startsWith('alter') ||
|
|
10
|
+
s.startsWith('replace') ||
|
|
11
|
+
s.startsWith('truncate'));
|
|
12
|
+
};
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { ZintrustKvProxy } from '../../../packages/cloudflare-kv-proxy/src/index.js';
|
|
2
|
+
export { default } from '../../../packages/cloudflare-kv-proxy/src/index.js';
|
|
2
3
|
//# sourceMappingURL=ZintrustKvProxy.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ZintrustKvProxy.d.ts","sourceRoot":"","sources":["../../../../src/proxy/kv/ZintrustKvProxy.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"ZintrustKvProxy.d.ts","sourceRoot":"","sources":["../../../../src/proxy/kv/ZintrustKvProxy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAEhE,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC"}
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { ZintrustKvProxy } from '../../../packages/cloudflare-kv-proxy/src/index.js';
|
|
2
|
+
export { default } from '../../../packages/cloudflare-kv-proxy/src/index.js';
|
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
import { type BaseProxyOverrides } from '../ProxyServerUtils';
|
|
2
|
-
type
|
|
3
|
-
|
|
4
|
-
dbPort: number;
|
|
5
|
-
dbName: string;
|
|
6
|
-
dbUser: string;
|
|
7
|
-
dbPass: string;
|
|
8
|
-
connectionLimit: number;
|
|
9
|
-
}>;
|
|
2
|
+
import type { SqlProxyDatabaseOverrides } from '../SqlProxyDbOverrides';
|
|
3
|
+
type ProxyOverrides = BaseProxyOverrides & SqlProxyDatabaseOverrides;
|
|
10
4
|
export declare const MySqlProxyServer: Readonly<{
|
|
11
5
|
start(overrides?: ProxyOverrides): Promise<void>;
|
|
12
6
|
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MySqlProxyServer.d.ts","sourceRoot":"","sources":["../../../../src/proxy/mysql/MySqlProxyServer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"MySqlProxyServer.d.ts","sourceRoot":"","sources":["../../../../src/proxy/mysql/MySqlProxyServer.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,4BAA4B,CAAC;AAa5E,KAAK,cAAc,GAAG,kBAAkB,GAAG,yBAAyB,CAAC;AAkNrE,eAAO,MAAM,gBAAgB;sBACJ,cAAc,GAAQ,OAAO,CAAC,IAAI,CAAC;EA4C1D,CAAC;AAEH,eAAe,gBAAgB,CAAC"}
|
|
@@ -1,25 +1,19 @@
|
|
|
1
|
-
import { Env } from '../../config/env.js';
|
|
2
|
-
import { Logger } from '../../config/logger.js';
|
|
3
1
|
import { ErrorFactory } from '../../exceptions/ZintrustError.js';
|
|
4
|
-
import
|
|
5
|
-
import { createProxyServer } from '../ProxyServer.js';
|
|
6
|
-
import { resolveBaseConfig, resolveBaseSigningConfig, verifyRequestSignature, } from '../ProxyServerUtils.js';
|
|
7
|
-
import { RequestValidator } from '../RequestValidator.js';
|
|
8
|
-
import { validateSqlPayload } from '../SqlPayloadValidator.js';
|
|
2
|
+
import * as Deps from '../SqlProxyServerDeps.js';
|
|
9
3
|
import { createPool } from 'mysql2/promise';
|
|
10
4
|
const resolveDatabaseConfig = (overrides = {}) => {
|
|
11
|
-
const dbHost = overrides.dbHost ?? Env.get('MYSQL_DB_HOST', Env.get('DB_HOST', '127.0.0.1'));
|
|
12
|
-
const dbPort = overrides.dbPort ?? Env.getInt('MYSQL_DB_PORT', Env.getInt('DB_PORT', 3306));
|
|
13
|
-
const dbName = overrides.dbName ?? Env.get('MYSQL_DB_DATABASE', Env.get('DB_DATABASE', 'zintrust'));
|
|
14
|
-
const dbUser = overrides.dbUser ?? Env.get('MYSQL_DB_USERNAME', Env.get('DB_USERNAME', 'root'));
|
|
15
|
-
const dbPass = overrides.dbPass ?? Env.get('MYSQL_DB_PASSWORD', Env.get('DB_PASSWORD', 'pass'));
|
|
16
|
-
const connectionLimit = overrides.connectionLimit ?? Env.MYSQL_PROXY_POOL_LIMIT;
|
|
5
|
+
const dbHost = overrides.dbHost ?? Deps.Env.get('MYSQL_DB_HOST', Deps.Env.get('DB_HOST', '127.0.0.1'));
|
|
6
|
+
const dbPort = overrides.dbPort ?? Deps.Env.getInt('MYSQL_DB_PORT', Deps.Env.getInt('DB_PORT', 3306));
|
|
7
|
+
const dbName = overrides.dbName ?? Deps.Env.get('MYSQL_DB_DATABASE', Deps.Env.get('DB_DATABASE', 'zintrust'));
|
|
8
|
+
const dbUser = overrides.dbUser ?? Deps.Env.get('MYSQL_DB_USERNAME', Deps.Env.get('DB_USERNAME', 'root'));
|
|
9
|
+
const dbPass = overrides.dbPass ?? Deps.Env.get('MYSQL_DB_PASSWORD', Deps.Env.get('DB_PASSWORD', 'pass'));
|
|
10
|
+
const connectionLimit = overrides.connectionLimit ?? Deps.Env.MYSQL_PROXY_POOL_LIMIT;
|
|
17
11
|
return { dbHost, dbPort, dbName, dbUser, dbPass, connectionLimit };
|
|
18
12
|
};
|
|
19
13
|
const resolveConfig = (overrides = {}) => {
|
|
20
|
-
const proxyConfig = resolveBaseConfig(overrides, 'MYSQL');
|
|
14
|
+
const proxyConfig = Deps.resolveBaseConfig(overrides, 'MYSQL');
|
|
21
15
|
const dbConfig = resolveDatabaseConfig(overrides);
|
|
22
|
-
const signingConfig = resolveBaseSigningConfig(overrides, 'MYSQL');
|
|
16
|
+
const signingConfig = Deps.resolveBaseSigningConfig(overrides, 'MYSQL');
|
|
23
17
|
const poolOptions = {
|
|
24
18
|
host: dbConfig.dbHost,
|
|
25
19
|
port: dbConfig.dbPort,
|
|
@@ -44,6 +38,7 @@ const resolveConfig = (overrides = {}) => {
|
|
|
44
38
|
require: signingConfig.requireSigning,
|
|
45
39
|
windowMs: signingConfig.signingWindowMs,
|
|
46
40
|
},
|
|
41
|
+
statements: Deps.loadStatementRegistry('MYSQL'),
|
|
47
42
|
};
|
|
48
43
|
};
|
|
49
44
|
const normalizeResult = (rows) => {
|
|
@@ -81,40 +76,78 @@ const handleEndpoint = (path, rows) => {
|
|
|
81
76
|
},
|
|
82
77
|
};
|
|
83
78
|
}
|
|
84
|
-
return ErrorHandler.toProxyError(404, 'NOT_FOUND', 'Unknown endpoint');
|
|
79
|
+
return Deps.ErrorHandler.toProxyError(404, 'NOT_FOUND', 'Unknown endpoint');
|
|
85
80
|
};
|
|
86
|
-
const
|
|
81
|
+
const handleStatementRequest = async (params) => {
|
|
82
|
+
const resolved = Deps.resolveStatementOrError(params.statements, params.payload);
|
|
83
|
+
if (!resolved.ok)
|
|
84
|
+
return resolved.response;
|
|
85
|
+
try {
|
|
86
|
+
const [rows] = await params.pool.query(resolved.value.sql, resolved.value.params);
|
|
87
|
+
const normalized = normalizeResult(rows);
|
|
88
|
+
if (!resolved.value.mutating) {
|
|
89
|
+
return { status: 200, body: { rows: normalized.rows, rowCount: normalized.rowCount } };
|
|
90
|
+
}
|
|
91
|
+
return {
|
|
92
|
+
status: 200,
|
|
93
|
+
body: {
|
|
94
|
+
ok: true,
|
|
95
|
+
meta: { changes: normalized.rowCount, lastRowId: normalized.lastInsertId },
|
|
96
|
+
},
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
catch (error) {
|
|
100
|
+
Deps.Logger.error('[MySQLProxyServer] Statement execution failed', {
|
|
101
|
+
path: params.request.path,
|
|
102
|
+
statementId: resolved.value.statementId,
|
|
103
|
+
mutating: resolved.value.mutating,
|
|
104
|
+
paramsCount: resolved.value.params.length,
|
|
105
|
+
error: error instanceof Error ? error.message : String(error),
|
|
106
|
+
});
|
|
107
|
+
return Deps.ErrorHandler.toProxyError(500, 'MYSQL_ERROR', String(error));
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
const handleSqlRequest = async (params) => {
|
|
111
|
+
const sqlValidation = Deps.validateSqlPayload(params.payload);
|
|
112
|
+
if (!sqlValidation.valid) {
|
|
113
|
+
const error = sqlValidation.error ?? {
|
|
114
|
+
code: 'VALIDATION_ERROR',
|
|
115
|
+
message: 'Invalid SQL payload',
|
|
116
|
+
};
|
|
117
|
+
return Deps.ErrorHandler.toProxyError(400, error.code, error.message);
|
|
118
|
+
}
|
|
119
|
+
try {
|
|
120
|
+
const [rows] = await params.pool.query(sqlValidation.sql ?? '', sqlValidation.params ?? []);
|
|
121
|
+
return handleEndpoint(params.request.path, rows);
|
|
122
|
+
}
|
|
123
|
+
catch (error) {
|
|
124
|
+
Deps.Logger.error('[MySQLProxyServer] Query execution failed', {
|
|
125
|
+
path: params.request.path,
|
|
126
|
+
sqlPreview: String(sqlValidation.sql ?? '').slice(0, 160),
|
|
127
|
+
paramsCount: Array.isArray(sqlValidation.params) ? sqlValidation.params.length : 0,
|
|
128
|
+
error: error instanceof Error ? error.message : String(error),
|
|
129
|
+
});
|
|
130
|
+
return Deps.ErrorHandler.toProxyError(500, 'MYSQL_ERROR', String(error));
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
const createBackend = (pool, statements) => ({
|
|
87
134
|
name: 'mysql',
|
|
88
135
|
async handle(request) {
|
|
89
|
-
const
|
|
90
|
-
if (
|
|
91
|
-
return
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
message: 'Invalid SQL payload',
|
|
102
|
-
};
|
|
103
|
-
return ErrorHandler.toProxyError(400, error.code, error.message);
|
|
104
|
-
}
|
|
105
|
-
try {
|
|
106
|
-
const [rows] = await pool.query(sqlValidation.sql ?? '', sqlValidation.params ?? []);
|
|
107
|
-
return handleEndpoint(request.path, rows);
|
|
108
|
-
}
|
|
109
|
-
catch (error) {
|
|
110
|
-
Logger.error('[MySQLProxyServer] Query execution failed', {
|
|
111
|
-
path: request.path,
|
|
112
|
-
sqlPreview: String(sqlValidation.sql ?? '').slice(0, 160),
|
|
113
|
-
paramsCount: Array.isArray(sqlValidation.params) ? sqlValidation.params.length : 0,
|
|
114
|
-
error: error instanceof Error ? error.message : String(error),
|
|
136
|
+
const validationError = Deps.validateProxyRequest(request);
|
|
137
|
+
if (validationError !== null)
|
|
138
|
+
return validationError;
|
|
139
|
+
const parsed = Deps.parseJsonBody(request.body);
|
|
140
|
+
if ('status' in parsed)
|
|
141
|
+
return parsed;
|
|
142
|
+
if (request.path === '/zin/mysql/statement') {
|
|
143
|
+
return handleStatementRequest({
|
|
144
|
+
pool,
|
|
145
|
+
statements,
|
|
146
|
+
request,
|
|
147
|
+
payload: parsed.value,
|
|
115
148
|
});
|
|
116
|
-
return ErrorHandler.toProxyError(500, 'MYSQL_ERROR', String(error));
|
|
117
149
|
}
|
|
150
|
+
return handleSqlRequest({ pool, request, payload: parsed.value });
|
|
118
151
|
},
|
|
119
152
|
async health() {
|
|
120
153
|
try {
|
|
@@ -122,10 +155,10 @@ const createBackend = (pool) => ({
|
|
|
122
155
|
return { status: 200, body: { status: 'healthy' } };
|
|
123
156
|
}
|
|
124
157
|
catch (error) {
|
|
125
|
-
Logger.error('[MySQLProxyServer] Health check failed', {
|
|
158
|
+
Deps.Logger.error('[MySQLProxyServer] Health check failed', {
|
|
126
159
|
error: error instanceof Error ? error.message : String(error),
|
|
127
160
|
});
|
|
128
|
-
return ErrorHandler.toProxyError(503, 'UNHEALTHY', String(error));
|
|
161
|
+
return Deps.ErrorHandler.toProxyError(503, 'UNHEALTHY', String(error));
|
|
129
162
|
}
|
|
130
163
|
},
|
|
131
164
|
});
|
|
@@ -142,20 +175,20 @@ export const MySqlProxyServer = Object.freeze({
|
|
|
142
175
|
}
|
|
143
176
|
// Debug: surface resolved config so we can compare watch vs non-watch runs
|
|
144
177
|
try {
|
|
145
|
-
Logger.info(`MySQL proxy config: proxyHost=${config.host} proxyPort=${config.port} dbHost=${String(config.poolOptions.host)} dbPort=${String(config.poolOptions.port)} dbName=${String(config.poolOptions.database)} dbUser=${String(config.poolOptions.user)} requireSigning=${String(config.signing.require)} keyId=${config.signing.keyId} hasSecret=${String(config.signing.secret.trim() !== '')} signingWindowMs=${String(config.signing.windowMs)}`);
|
|
178
|
+
Deps.Logger.info(`MySQL proxy config: proxyHost=${config.host} proxyPort=${config.port} dbHost=${String(config.poolOptions.host)} dbPort=${String(config.poolOptions.port)} dbName=${String(config.poolOptions.database)} dbUser=${String(config.poolOptions.user)} requireSigning=${String(config.signing.require)} keyId=${config.signing.keyId} hasSecret=${String(config.signing.secret.trim() !== '')} signingWindowMs=${String(config.signing.windowMs)}`);
|
|
146
179
|
}
|
|
147
180
|
catch {
|
|
148
181
|
// noop - logging must not block startup
|
|
149
182
|
}
|
|
150
183
|
const pool = createPool(config.poolOptions);
|
|
151
|
-
const backend = createBackend(pool);
|
|
152
|
-
const proxy = createProxyServer({
|
|
184
|
+
const backend = createBackend(pool, config.statements);
|
|
185
|
+
const proxy = Deps.createProxyServer({
|
|
153
186
|
host: config.host,
|
|
154
187
|
port: config.port,
|
|
155
188
|
maxBodyBytes: config.maxBodyBytes,
|
|
156
189
|
backend,
|
|
157
190
|
verify: async (req, body) => {
|
|
158
|
-
const verified = await verifyRequestSignature(req, body, config, 'MySQLProxyServer');
|
|
191
|
+
const verified = await Deps.verifyRequestSignature(req, body, config, 'MySQLProxyServer');
|
|
159
192
|
if (!verified.ok && verified.error) {
|
|
160
193
|
return { ok: false, status: verified.error.status, message: verified.error.message };
|
|
161
194
|
}
|
|
@@ -163,7 +196,7 @@ export const MySqlProxyServer = Object.freeze({
|
|
|
163
196
|
},
|
|
164
197
|
});
|
|
165
198
|
await proxy.start();
|
|
166
|
-
Logger.info(`MySQL proxy listening on http://${config.host}:${config.port}`);
|
|
199
|
+
Deps.Logger.info(`MySQL proxy listening on http://${config.host}:${config.port}`);
|
|
167
200
|
},
|
|
168
201
|
});
|
|
169
202
|
export default MySqlProxyServer;
|
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
import { type BaseProxyOverrides } from '../ProxyServerUtils';
|
|
2
|
-
type
|
|
3
|
-
|
|
4
|
-
dbPort: number;
|
|
5
|
-
dbName: string;
|
|
6
|
-
dbUser: string;
|
|
7
|
-
dbPass: string;
|
|
8
|
-
connectionLimit: number;
|
|
9
|
-
}>;
|
|
2
|
+
import type { SqlProxyDatabaseOverrides } from '../SqlProxyDbOverrides';
|
|
3
|
+
type ProxyOverrides = BaseProxyOverrides & SqlProxyDatabaseOverrides;
|
|
10
4
|
export declare const PostgresProxyServer: Readonly<{
|
|
11
5
|
start(overrides?: ProxyOverrides): Promise<void>;
|
|
12
6
|
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PostgresProxyServer.d.ts","sourceRoot":"","sources":["../../../../src/proxy/postgres/PostgresProxyServer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"PostgresProxyServer.d.ts","sourceRoot":"","sources":["../../../../src/proxy/postgres/PostgresProxyServer.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,4BAA4B,CAAC;AAoB5E,KAAK,cAAc,GAAG,kBAAkB,GAAG,yBAAyB,CAAC;AA2LrE,eAAO,MAAM,mBAAmB;sBACP,cAAc,GAAQ,OAAO,CAAC,IAAI,CAAC;EAyC1D,CAAC;AAEH,eAAe,mBAAmB,CAAC"}
|
|
@@ -1,24 +1,18 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { Logger } from '../../config/logger.js';
|
|
3
|
-
import { ErrorHandler } from '../ErrorHandler.js';
|
|
4
|
-
import { createProxyServer } from '../ProxyServer.js';
|
|
5
|
-
import { resolveBaseConfig, resolveBaseSigningConfig, verifyRequestSignature, } from '../ProxyServerUtils.js';
|
|
6
|
-
import { RequestValidator } from '../RequestValidator.js';
|
|
7
|
-
import { validateSqlPayload } from '../SqlPayloadValidator.js';
|
|
1
|
+
import * as Deps from '../SqlProxyServerDeps.js';
|
|
8
2
|
import { Pool } from 'pg';
|
|
9
3
|
const resolveDatabaseConfig = (overrides = {}) => {
|
|
10
|
-
const dbHost = overrides.dbHost ?? Env.DB_HOST ?? '127.0.0.1';
|
|
11
|
-
const dbPort = overrides.dbPort ?? Env.DB_PORT_POSTGRESQL ?? 5432;
|
|
12
|
-
const dbName = overrides.dbName ?? Env.DB_DATABASE_POSTGRESQL ?? 'postgres';
|
|
13
|
-
const dbUser = overrides.dbUser ?? Env.DB_USERNAME_POSTGRESQL ?? 'postgres';
|
|
14
|
-
const dbPass = overrides.dbPass ?? Env.DB_PASSWORD_POSTGRESQL ?? '';
|
|
15
|
-
const connectionLimit = overrides.connectionLimit ?? Env.POSTGRES_PROXY_POOL_LIMIT;
|
|
4
|
+
const dbHost = overrides.dbHost ?? Deps.Env.DB_HOST ?? '127.0.0.1';
|
|
5
|
+
const dbPort = overrides.dbPort ?? Deps.Env.DB_PORT_POSTGRESQL ?? 5432;
|
|
6
|
+
const dbName = overrides.dbName ?? Deps.Env.DB_DATABASE_POSTGRESQL ?? 'postgres';
|
|
7
|
+
const dbUser = overrides.dbUser ?? Deps.Env.DB_USERNAME_POSTGRESQL ?? 'postgres';
|
|
8
|
+
const dbPass = overrides.dbPass ?? Deps.Env.DB_PASSWORD_POSTGRESQL ?? '';
|
|
9
|
+
const connectionLimit = overrides.connectionLimit ?? Deps.Env.POSTGRES_PROXY_POOL_LIMIT;
|
|
16
10
|
return { dbHost, dbPort, dbName, dbUser, dbPass, connectionLimit };
|
|
17
11
|
};
|
|
18
12
|
const resolveConfig = (overrides = {}) => {
|
|
19
|
-
const proxyConfig = resolveBaseConfig(overrides, 'POSTGRES');
|
|
13
|
+
const proxyConfig = Deps.resolveBaseConfig(overrides, 'POSTGRES');
|
|
20
14
|
const dbConfig = resolveDatabaseConfig(overrides);
|
|
21
|
-
const signingConfig = resolveBaseSigningConfig(overrides, 'POSTGRES');
|
|
15
|
+
const signingConfig = Deps.resolveBaseSigningConfig(overrides, 'POSTGRES');
|
|
22
16
|
const poolOptions = {
|
|
23
17
|
host: dbConfig.dbHost,
|
|
24
18
|
port: dbConfig.dbPort,
|
|
@@ -38,6 +32,7 @@ const resolveConfig = (overrides = {}) => {
|
|
|
38
32
|
require: signingConfig.requireSigning,
|
|
39
33
|
windowMs: signingConfig.signingWindowMs,
|
|
40
34
|
},
|
|
35
|
+
statements: Deps.loadStatementRegistry('POSTGRES'),
|
|
41
36
|
};
|
|
42
37
|
};
|
|
43
38
|
const normalizeSql = (sql) => {
|
|
@@ -66,38 +61,81 @@ const handleEndpoint = (path, result) => {
|
|
|
66
61
|
},
|
|
67
62
|
};
|
|
68
63
|
}
|
|
69
|
-
|
|
64
|
+
if (path === '/zin/postgres/statement') {
|
|
65
|
+
return { status: 200, body: { rows: result.rows, rowCount: result.rowCount } };
|
|
66
|
+
}
|
|
67
|
+
return Deps.ErrorHandler.toProxyError(404, 'NOT_FOUND', 'Unknown endpoint');
|
|
68
|
+
};
|
|
69
|
+
const handleStatementRequest = async (params) => {
|
|
70
|
+
const resolved = Deps.resolveStatementOrError(params.statements, params.payload);
|
|
71
|
+
if (!resolved.ok)
|
|
72
|
+
return resolved.response;
|
|
73
|
+
try {
|
|
74
|
+
const normalizedSql = normalizeSql(resolved.value.sql);
|
|
75
|
+
const result = await params.pool.query(normalizedSql, resolved.value.params);
|
|
76
|
+
const rows = (result.rows ?? []);
|
|
77
|
+
const rowCount = result.rowCount ?? rows.length ?? 0;
|
|
78
|
+
if (!resolved.value.mutating) {
|
|
79
|
+
return handleEndpoint('/zin/postgres/statement', { rows, rowCount });
|
|
80
|
+
}
|
|
81
|
+
return {
|
|
82
|
+
status: 200,
|
|
83
|
+
body: {
|
|
84
|
+
ok: true,
|
|
85
|
+
meta: { changes: rowCount },
|
|
86
|
+
},
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
catch (error) {
|
|
90
|
+
Deps.Logger.error('[PostgresProxyServer] Statement execution failed', {
|
|
91
|
+
path: params.request.path,
|
|
92
|
+
statementId: resolved.value.statementId,
|
|
93
|
+
mutating: resolved.value.mutating,
|
|
94
|
+
paramsCount: resolved.value.params.length,
|
|
95
|
+
error: error instanceof Error ? error.message : String(error),
|
|
96
|
+
});
|
|
97
|
+
return Deps.ErrorHandler.toProxyError(500, 'POSTGRES_ERROR', String(error));
|
|
98
|
+
}
|
|
70
99
|
};
|
|
71
|
-
const
|
|
100
|
+
const handleSqlRequest = async (params) => {
|
|
101
|
+
const sqlValidation = Deps.validateSqlPayload(params.payload);
|
|
102
|
+
if (!sqlValidation.valid) {
|
|
103
|
+
const error = sqlValidation.error ?? {
|
|
104
|
+
code: 'VALIDATION_ERROR',
|
|
105
|
+
message: 'Invalid SQL payload',
|
|
106
|
+
};
|
|
107
|
+
return Deps.ErrorHandler.toProxyError(400, error.code, error.message);
|
|
108
|
+
}
|
|
109
|
+
try {
|
|
110
|
+
const sql = normalizeSql(sqlValidation.sql ?? '');
|
|
111
|
+
const result = await params.pool.query(sql, sqlValidation.params ?? []);
|
|
112
|
+
return handleEndpoint(params.request.path, {
|
|
113
|
+
rows: (result.rows ?? []),
|
|
114
|
+
rowCount: result.rowCount ?? result.rows?.length ?? 0,
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
catch (error) {
|
|
118
|
+
return Deps.ErrorHandler.toProxyError(500, 'POSTGRES_ERROR', String(error));
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
const createBackend = (pool, statements) => ({
|
|
72
122
|
name: 'postgres',
|
|
73
123
|
async handle(request) {
|
|
74
|
-
const
|
|
75
|
-
if (
|
|
76
|
-
return
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
message: 'Invalid SQL payload',
|
|
87
|
-
};
|
|
88
|
-
return ErrorHandler.toProxyError(400, error.code, error.message);
|
|
89
|
-
}
|
|
90
|
-
try {
|
|
91
|
-
const sql = normalizeSql(sqlValidation.sql ?? '');
|
|
92
|
-
const result = await pool.query(sql, sqlValidation.params ?? []);
|
|
93
|
-
return handleEndpoint(request.path, {
|
|
94
|
-
rows: (result.rows ?? []),
|
|
95
|
-
rowCount: result.rowCount ?? result.rows?.length ?? 0,
|
|
124
|
+
const validationError = Deps.validateProxyRequest(request);
|
|
125
|
+
if (validationError !== null)
|
|
126
|
+
return validationError;
|
|
127
|
+
const parsed = Deps.parseJsonBody(request.body);
|
|
128
|
+
if ('status' in parsed)
|
|
129
|
+
return parsed;
|
|
130
|
+
if (request.path === '/zin/postgres/statement') {
|
|
131
|
+
return handleStatementRequest({
|
|
132
|
+
pool,
|
|
133
|
+
statements,
|
|
134
|
+
request,
|
|
135
|
+
payload: parsed.value,
|
|
96
136
|
});
|
|
97
137
|
}
|
|
98
|
-
|
|
99
|
-
return ErrorHandler.toProxyError(500, 'POSTGRES_ERROR', String(error));
|
|
100
|
-
}
|
|
138
|
+
return handleSqlRequest({ pool, request, payload: parsed.value });
|
|
101
139
|
},
|
|
102
140
|
async health() {
|
|
103
141
|
try {
|
|
@@ -105,7 +143,7 @@ const createBackend = (pool) => ({
|
|
|
105
143
|
return { status: 200, body: { status: 'healthy' } };
|
|
106
144
|
}
|
|
107
145
|
catch (error) {
|
|
108
|
-
return ErrorHandler.toProxyError(503, 'UNHEALTHY', String(error));
|
|
146
|
+
return Deps.ErrorHandler.toProxyError(503, 'UNHEALTHY', String(error));
|
|
109
147
|
}
|
|
110
148
|
},
|
|
111
149
|
});
|
|
@@ -113,20 +151,20 @@ export const PostgresProxyServer = Object.freeze({
|
|
|
113
151
|
async start(overrides = {}) {
|
|
114
152
|
const config = resolveConfig(overrides);
|
|
115
153
|
try {
|
|
116
|
-
Logger.info(`Postgres proxy config: proxyHost=${config.host} proxyPort=${config.port} dbHost=${String(config.poolOptions.host)} dbPort=${String(config.poolOptions.port)} dbName=${String(config.poolOptions.database)} dbUser=${String(config.poolOptions.user)}`);
|
|
154
|
+
Deps.Logger.info(`Postgres proxy config: proxyHost=${config.host} proxyPort=${config.port} dbHost=${String(config.poolOptions.host)} dbPort=${String(config.poolOptions.port)} dbName=${String(config.poolOptions.database)} dbUser=${String(config.poolOptions.user)}`);
|
|
117
155
|
}
|
|
118
156
|
catch {
|
|
119
157
|
// noop - logging must not block startup
|
|
120
158
|
}
|
|
121
159
|
const pool = new Pool(config.poolOptions);
|
|
122
|
-
const backend = createBackend(pool);
|
|
123
|
-
const proxy = createProxyServer({
|
|
160
|
+
const backend = createBackend(pool, config.statements);
|
|
161
|
+
const proxy = Deps.createProxyServer({
|
|
124
162
|
host: config.host,
|
|
125
163
|
port: config.port,
|
|
126
164
|
maxBodyBytes: config.maxBodyBytes,
|
|
127
165
|
backend,
|
|
128
166
|
verify: async (req, body) => {
|
|
129
|
-
const verified = await verifyRequestSignature(req, body, config, 'PostgresProxyServer');
|
|
167
|
+
const verified = await Deps.verifyRequestSignature(req, body, config, 'PostgresProxyServer');
|
|
130
168
|
if (!verified.ok && verified.error) {
|
|
131
169
|
return { ok: false, status: verified.error.status, message: verified.error.message };
|
|
132
170
|
}
|
|
@@ -134,7 +172,7 @@ export const PostgresProxyServer = Object.freeze({
|
|
|
134
172
|
},
|
|
135
173
|
});
|
|
136
174
|
await proxy.start();
|
|
137
|
-
Logger.info(`Postgres proxy listening on http://${config.host}:${config.port}`);
|
|
175
|
+
Deps.Logger.info(`Postgres proxy listening on http://${config.host}:${config.port}`);
|
|
138
176
|
},
|
|
139
177
|
});
|
|
140
178
|
export default PostgresProxyServer;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SmtpProxyServer.d.ts","sourceRoot":"","sources":["../../../../src/proxy/smtp/SmtpProxyServer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"SmtpProxyServer.d.ts","sourceRoot":"","sources":["../../../../src/proxy/smtp/SmtpProxyServer.ts"],"names":[],"mappings":"AA4BA,KAAK,cAAc,GAAG,OAAO,CAAC;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,OAAO,GAAG,MAAM,CAAC;IAC7B,cAAc,EAAE,OAAO,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,eAAe,EAAE,MAAM,CAAC;CACzB,CAAC,CAAC;AAoUH,eAAO,MAAM,eAAe;sBACH,cAAc,GAAQ,OAAO,CAAC,IAAI,CAAC;EA2B1D,CAAC;AAEH,eAAe,eAAe,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Env } from '../../config/env.js';
|
|
2
2
|
import { Logger } from '../../config/logger.js';
|
|
3
3
|
import { ErrorFactory } from '../../exceptions/ZintrustError.js';
|
|
4
|
+
import { isNonEmptyString, isObject } from '../../helper/index.js';
|
|
4
5
|
import { SmtpDriver, } from '../../tools/mail/drivers/Smtp.js';
|
|
5
6
|
import { ErrorHandler } from '../ErrorHandler.js';
|
|
6
7
|
import { createProxyServer } from '../ProxyServer.js';
|
|
@@ -102,7 +103,7 @@ const verifySignatureIfNeeded = async (req, body, config) => {
|
|
|
102
103
|
}
|
|
103
104
|
return { ok: true };
|
|
104
105
|
};
|
|
105
|
-
const isRecord = (value) =>
|
|
106
|
+
const isRecord = (value) => isObject(value);
|
|
106
107
|
const parseAttachment = (value) => {
|
|
107
108
|
if (!isRecord(value)) {
|
|
108
109
|
return {
|
|
@@ -112,13 +113,13 @@ const parseAttachment = (value) => {
|
|
|
112
113
|
}
|
|
113
114
|
const filename = value['filename'];
|
|
114
115
|
const contentBase64 = value['contentBase64'];
|
|
115
|
-
if (
|
|
116
|
+
if (!isNonEmptyString(filename)) {
|
|
116
117
|
return {
|
|
117
118
|
ok: false,
|
|
118
119
|
error: { code: 'VALIDATION_ERROR', message: 'attachment filename is required' },
|
|
119
120
|
};
|
|
120
121
|
}
|
|
121
|
-
if (
|
|
122
|
+
if (!isNonEmptyString(contentBase64)) {
|
|
122
123
|
return {
|
|
123
124
|
ok: false,
|
|
124
125
|
error: { code: 'VALIDATION_ERROR', message: 'attachment contentBase64 is required' },
|
|
@@ -142,14 +143,14 @@ const parseFrom = (value) => {
|
|
|
142
143
|
}
|
|
143
144
|
const email = value['email'];
|
|
144
145
|
const name = value['name'];
|
|
145
|
-
if (
|
|
146
|
+
if (!isNonEmptyString(email)) {
|
|
146
147
|
return { ok: false, error: { code: 'VALIDATION_ERROR', message: 'from.email is required' } };
|
|
147
148
|
}
|
|
148
149
|
return {
|
|
149
150
|
ok: true,
|
|
150
151
|
value: {
|
|
151
152
|
email,
|
|
152
|
-
name:
|
|
153
|
+
name: isNonEmptyString(name) ? name : undefined,
|
|
153
154
|
},
|
|
154
155
|
};
|
|
155
156
|
};
|
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
import { type BaseProxyOverrides } from '../ProxyServerUtils';
|
|
2
|
-
type
|
|
3
|
-
|
|
4
|
-
dbPort: number;
|
|
5
|
-
dbName: string;
|
|
6
|
-
dbUser: string;
|
|
7
|
-
dbPass: string;
|
|
8
|
-
connectionLimit: number;
|
|
9
|
-
}>;
|
|
2
|
+
import type { SqlProxyDatabaseOverrides } from '../SqlProxyDbOverrides';
|
|
3
|
+
type ProxyOverrides = BaseProxyOverrides & SqlProxyDatabaseOverrides;
|
|
10
4
|
export declare const SqlServerProxyServer: Readonly<{
|
|
11
5
|
start(overrides?: ProxyOverrides): Promise<void>;
|
|
12
6
|
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SqlServerProxyServer.d.ts","sourceRoot":"","sources":["../../../../src/proxy/sqlserver/SqlServerProxyServer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"SqlServerProxyServer.d.ts","sourceRoot":"","sources":["../../../../src/proxy/sqlserver/SqlServerProxyServer.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,KAAK,EAA0B,yBAAyB,EAAE,MAAM,4BAA4B,CAAC;AAepG,KAAK,cAAc,GAAG,kBAAkB,GAAG,yBAAyB,CAAC;AAmOrE,eAAO,MAAM,oBAAoB;sBACR,cAAc,GAAQ,OAAO,CAAC,IAAI,CAAC;EAwC1D,CAAC"}
|