@getstrata/core 1.1.9 → 2.0.0
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/CHANGELOG.md +15 -0
- package/dist/core/database/transaction.d.ts +2 -1
- package/dist/core/database/transactionControl.d.ts +5 -0
- package/dist/core/http/loginThrottleMiddleware.d.ts +3 -0
- package/dist/core/http/metricsMiddleware.d.ts +1 -2
- package/dist/core/http/requestMetaContext.d.ts +2 -0
- package/dist/core/http/throttleMiddleware.d.ts +11 -2
- package/dist/core/metrics/prometheus.d.ts +11 -1
- package/dist/core/queue/jobRunner.d.ts +3 -1
- package/dist/core/queue/redisQueue.d.ts +20 -3
- package/dist/core/tenant/databaseTenantContext.d.ts +5 -1
- package/dist/entries/audit/exportAuditLogs.js +522 -62
- package/dist/entries/auth/basicAuthGuard.js +245 -219
- package/dist/entries/auth/oauth/samlProvider.js +185 -161
- package/dist/entries/auth/oneTimeToken.js +130 -127
- package/dist/entries/auth/passwordLogin.js +185 -180
- package/dist/entries/auth/saml/samlServiceProvider.js +185 -161
- package/dist/entries/auth/scimAuthMiddleware.js +525 -11
- package/dist/entries/database/migrations.js +132 -129
- package/dist/entries/database/schema.js +58 -39
- package/dist/entries/http/metricsMiddleware.js +124 -27
- package/dist/entries/http/response.js +107 -0
- package/dist/entries/http/routeMiddleware.js +40 -0
- package/dist/entries/http/throttleMiddleware.js +124 -11
- package/dist/entries/jobs/exportAuditLogsJob.js +522 -62
- package/dist/entries/metrics/prometheus.js +71 -11
- package/dist/entries/queue/createAppQueue.js +215 -21
- package/dist/entries/queue/jobRunner.js +3 -2
- package/dist/entries/queue/publicQueue.js +215 -21
- package/dist/entries/queue/queueMetrics.js +215 -21
- package/dist/entries/queue/redisQueue.js +223 -22
- package/dist/entries/tenant/databaseTenantContext.js +477 -16
- package/dist/entries/tenant/tenantDatabaseScope.js +523 -9
- package/dist/framework/public-api.d.ts +2 -2
- package/dist/index.js +954 -457
- package/package.json +1 -1
|
@@ -11,6 +11,25 @@ var __esm = (fn, res, err) => () => {
|
|
|
11
11
|
return res;
|
|
12
12
|
};
|
|
13
13
|
|
|
14
|
+
// ../../src/core/database/boundConnection.ts
|
|
15
|
+
function boundConnectionState() {
|
|
16
|
+
const globalRecord = globalThis;
|
|
17
|
+
const existing = globalRecord[BOUND_CONNECTION_KEY];
|
|
18
|
+
if (existing) {
|
|
19
|
+
return existing;
|
|
20
|
+
}
|
|
21
|
+
const created = { connection: null };
|
|
22
|
+
globalRecord[BOUND_CONNECTION_KEY] = created;
|
|
23
|
+
return created;
|
|
24
|
+
}
|
|
25
|
+
function getBoundDatabaseConnection() {
|
|
26
|
+
return boundConnectionState().connection;
|
|
27
|
+
}
|
|
28
|
+
var BOUND_CONNECTION_KEY;
|
|
29
|
+
var init_boundConnection = __esm(() => {
|
|
30
|
+
BOUND_CONNECTION_KEY = Symbol.for("@getstrata/boundDatabaseConnection");
|
|
31
|
+
});
|
|
32
|
+
|
|
14
33
|
// ../../src/core/runtime/asyncContextStore.ts
|
|
15
34
|
import { AsyncLocalStorage } from "async_hooks";
|
|
16
35
|
function createAsyncContextStore(key) {
|
|
@@ -42,6 +61,227 @@ var init_connectionContext = __esm(() => {
|
|
|
42
61
|
activeConnection = createAsyncContextStore("@getstrata/databaseConnectionContext");
|
|
43
62
|
});
|
|
44
63
|
|
|
64
|
+
// ../../src/core/database/queryProxy.ts
|
|
65
|
+
var POOL_CONNECTION_METHODS;
|
|
66
|
+
var init_queryProxy = __esm(() => {
|
|
67
|
+
init_connectionContext();
|
|
68
|
+
POOL_CONNECTION_METHODS = new Set(["begin", "close", "connect"]);
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
// ../../src/core/database/defaultConnection.ts
|
|
72
|
+
function defaultConnectionState() {
|
|
73
|
+
const globalRecord = globalThis;
|
|
74
|
+
const existing = globalRecord[DEFAULT_CONNECTION_KEY];
|
|
75
|
+
if (existing) {
|
|
76
|
+
return existing;
|
|
77
|
+
}
|
|
78
|
+
const created = { pool: null, query: null };
|
|
79
|
+
globalRecord[DEFAULT_CONNECTION_KEY] = created;
|
|
80
|
+
return created;
|
|
81
|
+
}
|
|
82
|
+
function getDefaultDatabasePool() {
|
|
83
|
+
const pool = defaultConnectionState().pool;
|
|
84
|
+
if (!pool) {
|
|
85
|
+
throw new Error("Default database pool is not registered. Call registerDefaultDatabasePool() during app bootstrap.");
|
|
86
|
+
}
|
|
87
|
+
return pool;
|
|
88
|
+
}
|
|
89
|
+
function getDefaultDatabaseQuery() {
|
|
90
|
+
const query = defaultConnectionState().query;
|
|
91
|
+
if (!query) {
|
|
92
|
+
throw new Error("Default database query handle is not registered. Call registerDefaultDatabasePool() during app bootstrap.");
|
|
93
|
+
}
|
|
94
|
+
return query;
|
|
95
|
+
}
|
|
96
|
+
var DEFAULT_CONNECTION_KEY;
|
|
97
|
+
var init_defaultConnection = __esm(() => {
|
|
98
|
+
init_queryProxy();
|
|
99
|
+
DEFAULT_CONNECTION_KEY = Symbol.for("@getstrata/defaultDatabaseConnection");
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
// ../../src/core/database/schema/driver.ts
|
|
103
|
+
function normalizeConnectionName(connection) {
|
|
104
|
+
const normalized = connection.trim().toLowerCase();
|
|
105
|
+
if (normalized === "pgsql" || normalized === "postgres" || normalized === "postgresql") {
|
|
106
|
+
return "pgsql";
|
|
107
|
+
}
|
|
108
|
+
if (normalized === "mysql" || normalized === "mariadb") {
|
|
109
|
+
return "mysql";
|
|
110
|
+
}
|
|
111
|
+
if (normalized === "sqlite") {
|
|
112
|
+
return "sqlite";
|
|
113
|
+
}
|
|
114
|
+
throw new Error(`Unsupported DB_CONNECTION: ${connection}`);
|
|
115
|
+
}
|
|
116
|
+
function resolveDriverFromUrl(url) {
|
|
117
|
+
const normalized = url.trim().toLowerCase();
|
|
118
|
+
if (normalized.startsWith("postgres://") || normalized.startsWith("postgresql://") || normalized.startsWith("postgres:")) {
|
|
119
|
+
return "pgsql";
|
|
120
|
+
}
|
|
121
|
+
if (normalized.startsWith("mysql://") || normalized.startsWith("mysql:")) {
|
|
122
|
+
return "mysql";
|
|
123
|
+
}
|
|
124
|
+
if (normalized.startsWith("sqlite:")) {
|
|
125
|
+
return "sqlite";
|
|
126
|
+
}
|
|
127
|
+
return null;
|
|
128
|
+
}
|
|
129
|
+
function resolveDatabaseDriver(options = {}) {
|
|
130
|
+
const connection = options.connection ?? process.env.DB_CONNECTION;
|
|
131
|
+
if (connection) {
|
|
132
|
+
return normalizeConnectionName(connection);
|
|
133
|
+
}
|
|
134
|
+
const url = options.url ?? process.env.DATABASE_URL ?? "";
|
|
135
|
+
const fromUrl = resolveDriverFromUrl(url);
|
|
136
|
+
if (fromUrl) {
|
|
137
|
+
return fromUrl;
|
|
138
|
+
}
|
|
139
|
+
return "pgsql";
|
|
140
|
+
}
|
|
141
|
+
var init_driver = () => {};
|
|
142
|
+
|
|
143
|
+
// ../../src/core/database/dialect.ts
|
|
144
|
+
function assertSafeIdentifier(identifier) {
|
|
145
|
+
if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(identifier)) {
|
|
146
|
+
throw new Error(`Invalid SQL identifier: ${identifier}`);
|
|
147
|
+
}
|
|
148
|
+
return identifier;
|
|
149
|
+
}
|
|
150
|
+
function quoteIdentifierFor(dialect, column) {
|
|
151
|
+
return dialect.quoteIdentifier(column);
|
|
152
|
+
}
|
|
153
|
+
function dialectFor(driver) {
|
|
154
|
+
return dialects[driver];
|
|
155
|
+
}
|
|
156
|
+
function currentSqlDialect() {
|
|
157
|
+
return dialectContext.getStore() ?? dialectOverride ?? dialectFor(resolveDatabaseDriver());
|
|
158
|
+
}
|
|
159
|
+
var postgresDialect, mysqlDialect, sqliteDialect, dialects, dialectContext, dialectOverride = null;
|
|
160
|
+
var init_dialect = __esm(() => {
|
|
161
|
+
init_asyncContextStore();
|
|
162
|
+
init_driver();
|
|
163
|
+
postgresDialect = {
|
|
164
|
+
driver: "pgsql",
|
|
165
|
+
placeholder(index) {
|
|
166
|
+
return `$${index}`;
|
|
167
|
+
},
|
|
168
|
+
quoteIdentifier(identifier) {
|
|
169
|
+
return `"${assertSafeIdentifier(identifier)}"`;
|
|
170
|
+
},
|
|
171
|
+
nowExpression() {
|
|
172
|
+
return "NOW()";
|
|
173
|
+
},
|
|
174
|
+
timestampValue(value) {
|
|
175
|
+
return value.toISOString();
|
|
176
|
+
},
|
|
177
|
+
returningClause(columns) {
|
|
178
|
+
return ` RETURNING ${columns}`;
|
|
179
|
+
},
|
|
180
|
+
ilikeOperator() {
|
|
181
|
+
return "ILIKE";
|
|
182
|
+
},
|
|
183
|
+
nullsLastSuffix() {
|
|
184
|
+
return " NULLS LAST";
|
|
185
|
+
},
|
|
186
|
+
castToText(expression) {
|
|
187
|
+
return `${expression}::text`;
|
|
188
|
+
},
|
|
189
|
+
upsertSuffix(conflictColumns, updateColumns) {
|
|
190
|
+
const target = conflictColumns.map((column) => quoteIdentifierFor(this, column)).join(", ");
|
|
191
|
+
if (updateColumns.length === 0) {
|
|
192
|
+
return ` ON CONFLICT (${target}) DO NOTHING`;
|
|
193
|
+
}
|
|
194
|
+
const assignments = updateColumns.map((column) => {
|
|
195
|
+
const quoted = quoteIdentifierFor(this, column);
|
|
196
|
+
return `${quoted} = excluded.${quoted}`;
|
|
197
|
+
}).join(", ");
|
|
198
|
+
return ` ON CONFLICT (${target}) DO UPDATE SET ${assignments}`;
|
|
199
|
+
}
|
|
200
|
+
};
|
|
201
|
+
mysqlDialect = {
|
|
202
|
+
driver: "mysql",
|
|
203
|
+
placeholder() {
|
|
204
|
+
return "?";
|
|
205
|
+
},
|
|
206
|
+
quoteIdentifier(identifier) {
|
|
207
|
+
return `\`${assertSafeIdentifier(identifier)}\``;
|
|
208
|
+
},
|
|
209
|
+
nowExpression() {
|
|
210
|
+
return "CURRENT_TIMESTAMP";
|
|
211
|
+
},
|
|
212
|
+
timestampValue(value) {
|
|
213
|
+
return value.toISOString().slice(0, 19).replace("T", " ");
|
|
214
|
+
},
|
|
215
|
+
returningClause() {
|
|
216
|
+
return "";
|
|
217
|
+
},
|
|
218
|
+
ilikeOperator() {
|
|
219
|
+
return "LIKE";
|
|
220
|
+
},
|
|
221
|
+
nullsLastSuffix() {
|
|
222
|
+
return "";
|
|
223
|
+
},
|
|
224
|
+
castToText(expression) {
|
|
225
|
+
return `CAST(${expression} AS CHAR)`;
|
|
226
|
+
},
|
|
227
|
+
upsertSuffix(conflictColumns, updateColumns) {
|
|
228
|
+
if (updateColumns.length === 0) {
|
|
229
|
+
const anchor = quoteIdentifierFor(this, conflictColumns[0] ?? "");
|
|
230
|
+
return ` ON DUPLICATE KEY UPDATE ${anchor} = ${anchor}`;
|
|
231
|
+
}
|
|
232
|
+
const assignments = updateColumns.map((column) => {
|
|
233
|
+
const quoted = quoteIdentifierFor(this, column);
|
|
234
|
+
return `${quoted} = VALUES(${quoted})`;
|
|
235
|
+
}).join(", ");
|
|
236
|
+
return ` ON DUPLICATE KEY UPDATE ${assignments}`;
|
|
237
|
+
}
|
|
238
|
+
};
|
|
239
|
+
sqliteDialect = {
|
|
240
|
+
driver: "sqlite",
|
|
241
|
+
placeholder() {
|
|
242
|
+
return "?";
|
|
243
|
+
},
|
|
244
|
+
quoteIdentifier(identifier) {
|
|
245
|
+
return `"${assertSafeIdentifier(identifier)}"`;
|
|
246
|
+
},
|
|
247
|
+
nowExpression() {
|
|
248
|
+
return "strftime('%Y-%m-%dT%H:%M:%fZ', 'now')";
|
|
249
|
+
},
|
|
250
|
+
timestampValue(value) {
|
|
251
|
+
return value.toISOString();
|
|
252
|
+
},
|
|
253
|
+
returningClause(columns) {
|
|
254
|
+
return ` RETURNING ${columns}`;
|
|
255
|
+
},
|
|
256
|
+
ilikeOperator() {
|
|
257
|
+
return "LIKE";
|
|
258
|
+
},
|
|
259
|
+
nullsLastSuffix() {
|
|
260
|
+
return "";
|
|
261
|
+
},
|
|
262
|
+
castToText(expression) {
|
|
263
|
+
return `CAST(${expression} AS TEXT)`;
|
|
264
|
+
},
|
|
265
|
+
upsertSuffix(conflictColumns, updateColumns) {
|
|
266
|
+
const target = conflictColumns.map((column) => quoteIdentifierFor(this, column)).join(", ");
|
|
267
|
+
if (updateColumns.length === 0) {
|
|
268
|
+
return ` ON CONFLICT (${target}) DO NOTHING`;
|
|
269
|
+
}
|
|
270
|
+
const assignments = updateColumns.map((column) => {
|
|
271
|
+
const quoted = quoteIdentifierFor(this, column);
|
|
272
|
+
return `${quoted} = excluded.${quoted}`;
|
|
273
|
+
}).join(", ");
|
|
274
|
+
return ` ON CONFLICT (${target}) DO UPDATE SET ${assignments}`;
|
|
275
|
+
}
|
|
276
|
+
};
|
|
277
|
+
dialects = {
|
|
278
|
+
pgsql: postgresDialect,
|
|
279
|
+
mysql: mysqlDialect,
|
|
280
|
+
sqlite: sqliteDialect
|
|
281
|
+
};
|
|
282
|
+
dialectContext = createAsyncContextStore("@getstrata/sqlDialect");
|
|
283
|
+
});
|
|
284
|
+
|
|
45
285
|
// ../../src/core/contracts/serviceTokens.ts
|
|
46
286
|
var CORE_CONFIG_TOKEN = "core.config";
|
|
47
287
|
var CORE_CACHE_TOKEN = "core.cache";
|
|
@@ -87,45 +327,9 @@ function resolveAuthUserDirectory(container) {
|
|
|
87
327
|
return null;
|
|
88
328
|
}
|
|
89
329
|
|
|
90
|
-
// ../../src/core/
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
const globalRecord = globalThis;
|
|
94
|
-
const existing = globalRecord[BOUND_CONNECTION_KEY];
|
|
95
|
-
if (existing) {
|
|
96
|
-
return existing;
|
|
97
|
-
}
|
|
98
|
-
const created = { connection: null };
|
|
99
|
-
globalRecord[BOUND_CONNECTION_KEY] = created;
|
|
100
|
-
return created;
|
|
101
|
-
}
|
|
102
|
-
function getBoundDatabaseConnection() {
|
|
103
|
-
return boundConnectionState().connection;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
// ../../src/core/database/queryProxy.ts
|
|
107
|
-
init_connectionContext();
|
|
108
|
-
var POOL_CONNECTION_METHODS = new Set(["begin", "close", "connect"]);
|
|
109
|
-
|
|
110
|
-
// ../../src/core/database/defaultConnection.ts
|
|
111
|
-
var DEFAULT_CONNECTION_KEY = Symbol.for("@getstrata/defaultDatabaseConnection");
|
|
112
|
-
function defaultConnectionState() {
|
|
113
|
-
const globalRecord = globalThis;
|
|
114
|
-
const existing = globalRecord[DEFAULT_CONNECTION_KEY];
|
|
115
|
-
if (existing) {
|
|
116
|
-
return existing;
|
|
117
|
-
}
|
|
118
|
-
const created = { pool: null, query: null };
|
|
119
|
-
globalRecord[DEFAULT_CONNECTION_KEY] = created;
|
|
120
|
-
return created;
|
|
121
|
-
}
|
|
122
|
-
function getDefaultDatabasePool() {
|
|
123
|
-
const pool = defaultConnectionState().pool;
|
|
124
|
-
if (!pool) {
|
|
125
|
-
throw new Error("Default database pool is not registered. Call registerDefaultDatabasePool() during app bootstrap.");
|
|
126
|
-
}
|
|
127
|
-
return pool;
|
|
128
|
-
}
|
|
330
|
+
// ../../src/core/auth/basicAuthGuard.ts
|
|
331
|
+
init_boundConnection();
|
|
332
|
+
init_defaultConnection();
|
|
129
333
|
|
|
130
334
|
// ../../src/core/http/statelessAuth.ts
|
|
131
335
|
function authorizationScheme(request) {
|
|
@@ -307,186 +511,8 @@ function revealMfaSecret(stored) {
|
|
|
307
511
|
return decryptField(stored, key);
|
|
308
512
|
}
|
|
309
513
|
|
|
310
|
-
// ../../src/core/
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
// ../../src/core/database/schema/driver.ts
|
|
314
|
-
function normalizeConnectionName(connection) {
|
|
315
|
-
const normalized = connection.trim().toLowerCase();
|
|
316
|
-
if (normalized === "pgsql" || normalized === "postgres" || normalized === "postgresql") {
|
|
317
|
-
return "pgsql";
|
|
318
|
-
}
|
|
319
|
-
if (normalized === "mysql" || normalized === "mariadb") {
|
|
320
|
-
return "mysql";
|
|
321
|
-
}
|
|
322
|
-
if (normalized === "sqlite") {
|
|
323
|
-
return "sqlite";
|
|
324
|
-
}
|
|
325
|
-
throw new Error(`Unsupported DB_CONNECTION: ${connection}`);
|
|
326
|
-
}
|
|
327
|
-
function resolveDriverFromUrl(url) {
|
|
328
|
-
const normalized = url.trim().toLowerCase();
|
|
329
|
-
if (normalized.startsWith("postgres://") || normalized.startsWith("postgresql://") || normalized.startsWith("postgres:")) {
|
|
330
|
-
return "pgsql";
|
|
331
|
-
}
|
|
332
|
-
if (normalized.startsWith("mysql://") || normalized.startsWith("mysql:")) {
|
|
333
|
-
return "mysql";
|
|
334
|
-
}
|
|
335
|
-
if (normalized.startsWith("sqlite:")) {
|
|
336
|
-
return "sqlite";
|
|
337
|
-
}
|
|
338
|
-
return null;
|
|
339
|
-
}
|
|
340
|
-
function resolveDatabaseDriver(options = {}) {
|
|
341
|
-
const connection = options.connection ?? process.env.DB_CONNECTION;
|
|
342
|
-
if (connection) {
|
|
343
|
-
return normalizeConnectionName(connection);
|
|
344
|
-
}
|
|
345
|
-
const url = options.url ?? process.env.DATABASE_URL ?? "";
|
|
346
|
-
const fromUrl = resolveDriverFromUrl(url);
|
|
347
|
-
if (fromUrl) {
|
|
348
|
-
return fromUrl;
|
|
349
|
-
}
|
|
350
|
-
return "pgsql";
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
// ../../src/core/database/dialect.ts
|
|
354
|
-
function assertSafeIdentifier(identifier) {
|
|
355
|
-
if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(identifier)) {
|
|
356
|
-
throw new Error(`Invalid SQL identifier: ${identifier}`);
|
|
357
|
-
}
|
|
358
|
-
return identifier;
|
|
359
|
-
}
|
|
360
|
-
function quoteIdentifierFor(dialect, column) {
|
|
361
|
-
return dialect.quoteIdentifier(column);
|
|
362
|
-
}
|
|
363
|
-
var postgresDialect = {
|
|
364
|
-
driver: "pgsql",
|
|
365
|
-
placeholder(index) {
|
|
366
|
-
return `$${index}`;
|
|
367
|
-
},
|
|
368
|
-
quoteIdentifier(identifier) {
|
|
369
|
-
return `"${assertSafeIdentifier(identifier)}"`;
|
|
370
|
-
},
|
|
371
|
-
nowExpression() {
|
|
372
|
-
return "NOW()";
|
|
373
|
-
},
|
|
374
|
-
timestampValue(value) {
|
|
375
|
-
return value.toISOString();
|
|
376
|
-
},
|
|
377
|
-
returningClause(columns) {
|
|
378
|
-
return ` RETURNING ${columns}`;
|
|
379
|
-
},
|
|
380
|
-
ilikeOperator() {
|
|
381
|
-
return "ILIKE";
|
|
382
|
-
},
|
|
383
|
-
nullsLastSuffix() {
|
|
384
|
-
return " NULLS LAST";
|
|
385
|
-
},
|
|
386
|
-
castToText(expression) {
|
|
387
|
-
return `${expression}::text`;
|
|
388
|
-
},
|
|
389
|
-
upsertSuffix(conflictColumns, updateColumns) {
|
|
390
|
-
const target = conflictColumns.map((column) => quoteIdentifierFor(this, column)).join(", ");
|
|
391
|
-
if (updateColumns.length === 0) {
|
|
392
|
-
return ` ON CONFLICT (${target}) DO NOTHING`;
|
|
393
|
-
}
|
|
394
|
-
const assignments = updateColumns.map((column) => {
|
|
395
|
-
const quoted = quoteIdentifierFor(this, column);
|
|
396
|
-
return `${quoted} = excluded.${quoted}`;
|
|
397
|
-
}).join(", ");
|
|
398
|
-
return ` ON CONFLICT (${target}) DO UPDATE SET ${assignments}`;
|
|
399
|
-
}
|
|
400
|
-
};
|
|
401
|
-
var mysqlDialect = {
|
|
402
|
-
driver: "mysql",
|
|
403
|
-
placeholder() {
|
|
404
|
-
return "?";
|
|
405
|
-
},
|
|
406
|
-
quoteIdentifier(identifier) {
|
|
407
|
-
return `\`${assertSafeIdentifier(identifier)}\``;
|
|
408
|
-
},
|
|
409
|
-
nowExpression() {
|
|
410
|
-
return "CURRENT_TIMESTAMP";
|
|
411
|
-
},
|
|
412
|
-
timestampValue(value) {
|
|
413
|
-
return value.toISOString().slice(0, 19).replace("T", " ");
|
|
414
|
-
},
|
|
415
|
-
returningClause() {
|
|
416
|
-
return "";
|
|
417
|
-
},
|
|
418
|
-
ilikeOperator() {
|
|
419
|
-
return "LIKE";
|
|
420
|
-
},
|
|
421
|
-
nullsLastSuffix() {
|
|
422
|
-
return "";
|
|
423
|
-
},
|
|
424
|
-
castToText(expression) {
|
|
425
|
-
return `CAST(${expression} AS CHAR)`;
|
|
426
|
-
},
|
|
427
|
-
upsertSuffix(conflictColumns, updateColumns) {
|
|
428
|
-
if (updateColumns.length === 0) {
|
|
429
|
-
const anchor = quoteIdentifierFor(this, conflictColumns[0] ?? "");
|
|
430
|
-
return ` ON DUPLICATE KEY UPDATE ${anchor} = ${anchor}`;
|
|
431
|
-
}
|
|
432
|
-
const assignments = updateColumns.map((column) => {
|
|
433
|
-
const quoted = quoteIdentifierFor(this, column);
|
|
434
|
-
return `${quoted} = VALUES(${quoted})`;
|
|
435
|
-
}).join(", ");
|
|
436
|
-
return ` ON DUPLICATE KEY UPDATE ${assignments}`;
|
|
437
|
-
}
|
|
438
|
-
};
|
|
439
|
-
var sqliteDialect = {
|
|
440
|
-
driver: "sqlite",
|
|
441
|
-
placeholder() {
|
|
442
|
-
return "?";
|
|
443
|
-
},
|
|
444
|
-
quoteIdentifier(identifier) {
|
|
445
|
-
return `"${assertSafeIdentifier(identifier)}"`;
|
|
446
|
-
},
|
|
447
|
-
nowExpression() {
|
|
448
|
-
return "strftime('%Y-%m-%dT%H:%M:%fZ', 'now')";
|
|
449
|
-
},
|
|
450
|
-
timestampValue(value) {
|
|
451
|
-
return value.toISOString();
|
|
452
|
-
},
|
|
453
|
-
returningClause(columns) {
|
|
454
|
-
return ` RETURNING ${columns}`;
|
|
455
|
-
},
|
|
456
|
-
ilikeOperator() {
|
|
457
|
-
return "LIKE";
|
|
458
|
-
},
|
|
459
|
-
nullsLastSuffix() {
|
|
460
|
-
return "";
|
|
461
|
-
},
|
|
462
|
-
castToText(expression) {
|
|
463
|
-
return `CAST(${expression} AS TEXT)`;
|
|
464
|
-
},
|
|
465
|
-
upsertSuffix(conflictColumns, updateColumns) {
|
|
466
|
-
const target = conflictColumns.map((column) => quoteIdentifierFor(this, column)).join(", ");
|
|
467
|
-
if (updateColumns.length === 0) {
|
|
468
|
-
return ` ON CONFLICT (${target}) DO NOTHING`;
|
|
469
|
-
}
|
|
470
|
-
const assignments = updateColumns.map((column) => {
|
|
471
|
-
const quoted = quoteIdentifierFor(this, column);
|
|
472
|
-
return `${quoted} = excluded.${quoted}`;
|
|
473
|
-
}).join(", ");
|
|
474
|
-
return ` ON CONFLICT (${target}) DO UPDATE SET ${assignments}`;
|
|
475
|
-
}
|
|
476
|
-
};
|
|
477
|
-
var dialects = {
|
|
478
|
-
pgsql: postgresDialect,
|
|
479
|
-
mysql: mysqlDialect,
|
|
480
|
-
sqlite: sqliteDialect
|
|
481
|
-
};
|
|
482
|
-
var dialectContext = createAsyncContextStore("@getstrata/sqlDialect");
|
|
483
|
-
var dialectOverride = null;
|
|
484
|
-
function dialectFor(driver) {
|
|
485
|
-
return dialects[driver];
|
|
486
|
-
}
|
|
487
|
-
function currentSqlDialect() {
|
|
488
|
-
return dialectContext.getStore() ?? dialectOverride ?? dialectFor(resolveDatabaseDriver());
|
|
489
|
-
}
|
|
514
|
+
// ../../src/core/auth/passwordLogin.ts
|
|
515
|
+
init_dialect();
|
|
490
516
|
|
|
491
517
|
// ../../src/core/security/recoveryCodes.ts
|
|
492
518
|
import { randomBytes as randomBytes2 } from "crypto";
|