@getstrata/core 2.2.57 → 2.2.59
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/model.d.ts +5 -1
- package/dist/core/database/schema/blueprint.d.ts +2 -0
- package/dist/core/database/schema/columnDefinition.d.ts +1 -1
- package/dist/core/http/parseFormBody.d.ts +26 -4
- package/dist/core/http/webFormRequest.d.ts +3 -0
- package/dist/core/tenant/postgresAppRole.d.ts +1 -1
- package/dist/entries/auth/accountStateMigration.js +13 -0
- package/dist/entries/database/migrations.js +4 -1
- package/dist/entries/database/schema.js +13 -0
- package/dist/entries/facades.js +3 -1
- package/dist/entries/http/parseFormBody.js +14 -3
- package/dist/entries/http/webFormRequest.js +20 -5
- package/dist/entries/mail/mailer.js +3 -1
- package/dist/entries/tenant/enableTenantRls.js +8 -4
- package/dist/index.js +39 -6
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @getstrata/core changelog
|
|
2
2
|
|
|
3
|
+
## 2.2.59
|
|
4
|
+
|
|
5
|
+
- Reject unsupported SQLite column-level uniqueness during ADD COLUMN compilation, before any statement in a Schema.run plan executes. Use the existing nullable column plus table.unique() API; populated rows, duplicate rejection, CREATE behavior and PostgreSQL/MySQL SQL are preserved. #371
|
|
6
|
+
- Retain defineModel's declared record/key as repository() generic defaults, preserving explicit generics, inherited/custom-key models and legacy overrides. Runtime upsert and Model.repository behavior are unchanged. #372
|
|
7
|
+
- Initialize the default mailer on first successful access so custom MailDriver instances can load without configuring unused SMTP. Actual SMTP use still validates configuration; successful singleton identity, failure propagation and cancellation remain intact. #373
|
|
8
|
+
- Read existing migration history without DDL from getMigrationStatus(). Missing or inaccessible history now reports the native database error; explicit migration operations still initialize history. #374
|
|
9
|
+
|
|
10
|
+
## 2.2.58
|
|
11
|
+
|
|
12
|
+
PostgreSQL runtime privilege fix: Replace broad table/sequence grants with explicit CRUD and sequence usage/read permissions. Repair legacy helper-managed grants that allowed TRUNCATE across RLS tenant boundaries. Preserve provisioning locks and transactional rollback. Resolves #364 through #370.
|
|
13
|
+
UUID schema columns: Add table.uuid() with PostgreSQL native UUID, MySQL CHAR(36) and SQLite TEXT. Supports explicit constraints and application-supplied identifiers; existing schemas remain unchanged. #365
|
|
14
|
+
Model and view generators: Add make:model for declarative models with automatic repositories, and make:view for escaped Eta templates. Support nested names and explicit model metadata, with path validation and overwrite protection. Migrations remain explicit and separate. #368
|
|
15
|
+
Repeated form values: Add opt-in { preserveRepeated: true } parsing through core form helpers and WebFormRequest, retaining repeated text and files in order. Existing parsing defaults remain unchanged; applications retain responsibility for duplicate validation. #366
|
|
16
|
+
Mail extension documentation and coverage: Qualify existing injected MailDriver integrations, including HTTPS providers, cancellation, deadlines, error propagation and provider-controlled idempotency. This adds tests and guidance without changing stock mail transports. #367
|
|
17
|
+
|
|
3
18
|
## 2.2.57
|
|
4
19
|
|
|
5
20
|
Add opt-in CsrfOptions.targetOrigin with strict request Host/URL authority and source-origin validation while retaining signed cookie/token checks and existing defaults. Preserve native Request identity and ignore forwarding claims. Fall back safely to JSON error formatting for malformed native URL metadata.
|
|
@@ -14,8 +14,12 @@ interface ModelConstructor<TEntity extends object, PrimaryKey extends keyof TEnt
|
|
|
14
14
|
new (attributes: TEntity, repository: BaseRepository<TEntity, PrimaryKey>, exists?: boolean): TModel;
|
|
15
15
|
}
|
|
16
16
|
type RelatedRef<TRelated extends object, RelatedKey extends keyof TRelated & string> = RelatedModelClass<TRelated, RelatedKey> | string | (() => RelatedModelClass<TRelated, RelatedKey>);
|
|
17
|
+
/** Retain the declared table as repository() defaults without narrowing legacy explicit calls. */
|
|
18
|
+
type DefinedModel<TEntity extends object, PrimaryKey extends keyof TEntity & string> = {
|
|
19
|
+
repository<TRecord extends object = TEntity, TKey extends keyof TRecord & string = PrimaryKey & keyof TRecord & string>(this: object): BaseRepository<TRecord, TKey>;
|
|
20
|
+
} & typeof Model<TEntity, PrimaryKey>;
|
|
17
21
|
/** Typed model base with a lazily created framework repository and active connection. */
|
|
18
|
-
declare function defineModel<TEntity extends object, PrimaryKey extends keyof TEntity & string>(table: TableDefinition<TEntity, PrimaryKey>):
|
|
22
|
+
declare function defineModel<TEntity extends object, PrimaryKey extends keyof TEntity & string>(table: TableDefinition<TEntity, PrimaryKey>): DefinedModel<TEntity, PrimaryKey>;
|
|
19
23
|
/** Register all relationship names before initializing any model's boot hooks. */
|
|
20
24
|
declare function bootModels(models: readonly object[]): void;
|
|
21
25
|
declare class Model<TEntity extends object, PrimaryKey extends keyof TEntity & string> {
|
|
@@ -33,6 +33,8 @@ declare class Blueprint {
|
|
|
33
33
|
/** Generated 64-bit primary key; does not change existing id() migrations. */
|
|
34
34
|
bigId(name?: string): ColumnDefinition;
|
|
35
35
|
string(name: string, length?: number): ColumnDefinition;
|
|
36
|
+
/** Application-supplied UUID: native PostgreSQL UUID, MySQL CHAR(36), SQLite TEXT. */
|
|
37
|
+
uuid(name: string): ColumnDefinition;
|
|
36
38
|
text(name: string): ColumnDefinition;
|
|
37
39
|
boolean(name: string): ColumnDefinition;
|
|
38
40
|
integer(name: string): ColumnDefinition;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
type ColumnKind = "id" | "bigId" | "string" | "text" | "boolean" | "integer" | "bigInteger" | "timestamp" | "json" | "jsonb" | "foreignId";
|
|
1
|
+
type ColumnKind = "id" | "bigId" | "uuid" | "string" | "text" | "boolean" | "integer" | "bigInteger" | "timestamp" | "json" | "jsonb" | "foreignId";
|
|
2
2
|
interface ForeignKeyOptions {
|
|
3
3
|
referencesTable: string;
|
|
4
4
|
referencesColumn: string;
|
|
@@ -1,6 +1,28 @@
|
|
|
1
|
-
interface FormDataLike {
|
|
2
|
-
entries(): Iterable<[string,
|
|
1
|
+
interface FormDataLike<T = unknown> {
|
|
2
|
+
entries(): Iterable<[string, T]>;
|
|
3
3
|
}
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
interface FormBodyOptions {
|
|
5
|
+
/** Preserve every entry as an array, including single text fields and File entries. */
|
|
6
|
+
preserveRepeated?: boolean;
|
|
7
|
+
}
|
|
8
|
+
type PreservedFormValues = Record<string, (string | File)[]>;
|
|
9
|
+
declare function parseFormBody(request: Request, options: {
|
|
10
|
+
preserveRepeated: true;
|
|
11
|
+
}): Promise<PreservedFormValues>;
|
|
12
|
+
declare function parseFormBody(request: Request, options?: {
|
|
13
|
+
preserveRepeated?: false;
|
|
14
|
+
}): Promise<Record<string, string>>;
|
|
15
|
+
declare function parseFormBody(request: Request, options: FormBodyOptions): Promise<Record<string, string> | PreservedFormValues>;
|
|
16
|
+
declare function formDataToRecord(formData: FormData, options: {
|
|
17
|
+
preserveRepeated: true;
|
|
18
|
+
}): PreservedFormValues;
|
|
19
|
+
declare function formDataToRecord<T>(formData: FormDataLike<T>, options: {
|
|
20
|
+
preserveRepeated: true;
|
|
21
|
+
}): Record<string, T[]>;
|
|
22
|
+
declare function formDataToRecord(formData: FormDataLike, options?: {
|
|
23
|
+
preserveRepeated?: false;
|
|
24
|
+
}): Record<string, string>;
|
|
25
|
+
declare function formDataToRecord(formData: FormData, options: FormBodyOptions): Record<string, string> | PreservedFormValues;
|
|
26
|
+
declare function formDataToRecord<T>(formData: FormDataLike<T>, options: FormBodyOptions): Record<string, string> | Record<string, T[]>;
|
|
27
|
+
export type { FormBodyOptions, PreservedFormValues };
|
|
6
28
|
export { formDataToRecord, parseFormBody };
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
import { type FormBodyOptions } from "./parseFormBody";
|
|
1
2
|
declare abstract class WebFormRequest<TOutput> {
|
|
3
|
+
#private;
|
|
4
|
+
constructor(options?: FormBodyOptions);
|
|
2
5
|
authorize(_request: Request): boolean | Promise<boolean>;
|
|
3
6
|
protected abstract parse(payload: unknown): TOutput;
|
|
4
7
|
validatePayload(payload: unknown): TOutput;
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* existing volumes get the role and table GRANTs after migrate:fresh. Production
|
|
11
11
|
* runtime processes only connect through the already-provisioned restricted role.
|
|
12
12
|
*
|
|
13
|
-
* Admin DDL (
|
|
13
|
+
* Admin DDL (table grants, CREATE TABLE, DROP TABLE) must run on the
|
|
14
14
|
* application database. postgres/template1 are only for CREATE DATABASE.
|
|
15
15
|
*/
|
|
16
16
|
declare const POSTGRES_APP_ROLE = "strata_app";
|
|
@@ -365,6 +365,12 @@ class Blueprint {
|
|
|
365
365
|
this.columns.push(column);
|
|
366
366
|
return column;
|
|
367
367
|
}
|
|
368
|
+
uuid(name) {
|
|
369
|
+
const column = new ColumnDefinition(name, "uuid");
|
|
370
|
+
column.notNullable();
|
|
371
|
+
this.columns.push(column);
|
|
372
|
+
return column;
|
|
373
|
+
}
|
|
368
374
|
text(name) {
|
|
369
375
|
const column = new ColumnDefinition(name, "text");
|
|
370
376
|
column.notNullable();
|
|
@@ -507,6 +513,10 @@ function compileColumnType(driver, column) {
|
|
|
507
513
|
return compileIdType(driver);
|
|
508
514
|
case "string":
|
|
509
515
|
return compileStringType(driver, column.length);
|
|
516
|
+
case "uuid":
|
|
517
|
+
if (column.autoIncrement)
|
|
518
|
+
throw new UnsupportedSchemaFeatureError("auto-increment UUID columns", driver);
|
|
519
|
+
return driver === "pgsql" ? "UUID" : driver === "mysql" ? "CHAR(36)" : "TEXT";
|
|
510
520
|
case "text":
|
|
511
521
|
return compileTextType(driver);
|
|
512
522
|
case "boolean":
|
|
@@ -696,6 +706,9 @@ function compileDropTable(driver, tableName) {
|
|
|
696
706
|
return [`DROP TABLE IF EXISTS ${quoteIdentifier(tableName)}${cascade}`];
|
|
697
707
|
}
|
|
698
708
|
function compileColumn(driver, column, mode) {
|
|
709
|
+
if (driver === "sqlite" && mode === "alter" && column.isUnique) {
|
|
710
|
+
throw new UnsupportedSchemaFeatureError("column-level unique() in ADD COLUMN (add the column without unique() and use table.unique(columnName) in the same schema.table callback instead)", driver);
|
|
711
|
+
}
|
|
699
712
|
const quoteIdentifier = dialectFor(driver).quoteIdentifier;
|
|
700
713
|
const parts = [quoteIdentifier(column.name), compileColumnType(driver, column)];
|
|
701
714
|
if (column.autoIncrement && driver === "mysql") {
|
|
@@ -330,6 +330,9 @@ async function recordAppliedMigration(db, name, batch) {
|
|
|
330
330
|
}
|
|
331
331
|
async function getAppliedMigrations(db) {
|
|
332
332
|
await ensureMigrationsTable(db);
|
|
333
|
+
return readAppliedMigrations(db);
|
|
334
|
+
}
|
|
335
|
+
async function readAppliedMigrations(db) {
|
|
333
336
|
return await db.unsafe(`
|
|
334
337
|
SELECT name, batch
|
|
335
338
|
FROM ${MIGRATIONS_TABLE}
|
|
@@ -349,7 +352,7 @@ async function loadMigrationsFromDirectory(directory) {
|
|
|
349
352
|
}
|
|
350
353
|
async function getMigrationStatus(db, migrations) {
|
|
351
354
|
validateMigrations(migrations);
|
|
352
|
-
const applied = await
|
|
355
|
+
const applied = await readAppliedMigrations(db);
|
|
353
356
|
const appliedByName = new Map(applied.map(({ name, batch }) => [name, Number(batch)]));
|
|
354
357
|
return migrations.map(({ name }) => ({
|
|
355
358
|
name,
|
|
@@ -357,6 +357,12 @@ class Blueprint {
|
|
|
357
357
|
this.columns.push(column);
|
|
358
358
|
return column;
|
|
359
359
|
}
|
|
360
|
+
uuid(name) {
|
|
361
|
+
const column = new ColumnDefinition(name, "uuid");
|
|
362
|
+
column.notNullable();
|
|
363
|
+
this.columns.push(column);
|
|
364
|
+
return column;
|
|
365
|
+
}
|
|
360
366
|
text(name) {
|
|
361
367
|
const column = new ColumnDefinition(name, "text");
|
|
362
368
|
column.notNullable();
|
|
@@ -499,6 +505,10 @@ function compileColumnType(driver, column) {
|
|
|
499
505
|
return compileIdType(driver);
|
|
500
506
|
case "string":
|
|
501
507
|
return compileStringType(driver, column.length);
|
|
508
|
+
case "uuid":
|
|
509
|
+
if (column.autoIncrement)
|
|
510
|
+
throw new UnsupportedSchemaFeatureError("auto-increment UUID columns", driver);
|
|
511
|
+
return driver === "pgsql" ? "UUID" : driver === "mysql" ? "CHAR(36)" : "TEXT";
|
|
502
512
|
case "text":
|
|
503
513
|
return compileTextType(driver);
|
|
504
514
|
case "boolean":
|
|
@@ -688,6 +698,9 @@ function compileDropTable(driver, tableName) {
|
|
|
688
698
|
return [`DROP TABLE IF EXISTS ${quoteIdentifier(tableName)}${cascade}`];
|
|
689
699
|
}
|
|
690
700
|
function compileColumn(driver, column, mode) {
|
|
701
|
+
if (driver === "sqlite" && mode === "alter" && column.isUnique) {
|
|
702
|
+
throw new UnsupportedSchemaFeatureError("column-level unique() in ADD COLUMN (add the column without unique() and use table.unique(columnName) in the same schema.table callback instead)", driver);
|
|
703
|
+
}
|
|
691
704
|
const quoteIdentifier = dialectFor(driver).quoteIdentifier;
|
|
692
705
|
const parts = [quoteIdentifier(column.name), compileColumnType(driver, column)];
|
|
693
706
|
if (column.autoIncrement && driver === "mysql") {
|
package/dist/entries/facades.js
CHANGED
|
@@ -500,8 +500,10 @@ function createMailDriver() {
|
|
|
500
500
|
}
|
|
501
501
|
return new LogMailDriver;
|
|
502
502
|
}
|
|
503
|
-
var appMailer
|
|
503
|
+
var appMailer;
|
|
504
504
|
function mailer() {
|
|
505
|
+
if (!appMailer)
|
|
506
|
+
appMailer = new Mailer(createMailDriver());
|
|
505
507
|
return appMailer;
|
|
506
508
|
}
|
|
507
509
|
|
|
@@ -1,14 +1,25 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
// ../../src/core/http/parseFormBody.ts
|
|
3
3
|
import { BadRequestError } from "@getstrata/core/errors/http";
|
|
4
|
-
async function parseFormBody(request) {
|
|
4
|
+
async function parseFormBody(request, options = {}) {
|
|
5
5
|
const contentType = request.headers.get("content-type")?.toLowerCase() ?? "";
|
|
6
6
|
if (!contentType.includes("application/x-www-form-urlencoded") && !contentType.includes("multipart/form-data")) {
|
|
7
7
|
throw new BadRequestError("Expected a form submission.");
|
|
8
8
|
}
|
|
9
|
-
return formDataToRecord(await request.formData());
|
|
9
|
+
return formDataToRecord(await request.formData(), options);
|
|
10
10
|
}
|
|
11
|
-
function formDataToRecord(formData) {
|
|
11
|
+
function formDataToRecord(formData, options = {}) {
|
|
12
|
+
if (options.preserveRepeated === true) {
|
|
13
|
+
const values = new Map;
|
|
14
|
+
for (const [key, value] of formData.entries()) {
|
|
15
|
+
const entries = values.get(key);
|
|
16
|
+
if (entries)
|
|
17
|
+
entries.push(value);
|
|
18
|
+
else
|
|
19
|
+
values.set(key, [value]);
|
|
20
|
+
}
|
|
21
|
+
return Object.fromEntries(values);
|
|
22
|
+
}
|
|
12
23
|
const values = {};
|
|
13
24
|
for (const [key, value] of formData.entries()) {
|
|
14
25
|
if (typeof value === "string") {
|
|
@@ -35,14 +35,25 @@ function requestPrefersJson(request) {
|
|
|
35
35
|
|
|
36
36
|
// ../../src/core/http/parseFormBody.ts
|
|
37
37
|
import { BadRequestError } from "@getstrata/core/errors/http";
|
|
38
|
-
async function parseFormBody(request) {
|
|
38
|
+
async function parseFormBody(request, options = {}) {
|
|
39
39
|
const contentType = request.headers.get("content-type")?.toLowerCase() ?? "";
|
|
40
40
|
if (!contentType.includes("application/x-www-form-urlencoded") && !contentType.includes("multipart/form-data")) {
|
|
41
41
|
throw new BadRequestError("Expected a form submission.");
|
|
42
42
|
}
|
|
43
|
-
return formDataToRecord(await request.formData());
|
|
44
|
-
}
|
|
45
|
-
function formDataToRecord(formData) {
|
|
43
|
+
return formDataToRecord(await request.formData(), options);
|
|
44
|
+
}
|
|
45
|
+
function formDataToRecord(formData, options = {}) {
|
|
46
|
+
if (options.preserveRepeated === true) {
|
|
47
|
+
const values = new Map;
|
|
48
|
+
for (const [key, value] of formData.entries()) {
|
|
49
|
+
const entries = values.get(key);
|
|
50
|
+
if (entries)
|
|
51
|
+
entries.push(value);
|
|
52
|
+
else
|
|
53
|
+
values.set(key, [value]);
|
|
54
|
+
}
|
|
55
|
+
return Object.fromEntries(values);
|
|
56
|
+
}
|
|
46
57
|
const values = {};
|
|
47
58
|
for (const [key, value] of formData.entries()) {
|
|
48
59
|
if (typeof value === "string") {
|
|
@@ -183,6 +194,10 @@ function parsePositiveIntParam(value, name = "id") {
|
|
|
183
194
|
|
|
184
195
|
// ../../src/core/http/webFormRequest.ts
|
|
185
196
|
class WebFormRequest {
|
|
197
|
+
#preserveRepeated;
|
|
198
|
+
constructor(options = {}) {
|
|
199
|
+
this.#preserveRepeated = options.preserveRepeated === true;
|
|
200
|
+
}
|
|
186
201
|
authorize(_request) {
|
|
187
202
|
return true;
|
|
188
203
|
}
|
|
@@ -193,7 +208,7 @@ class WebFormRequest {
|
|
|
193
208
|
if (!await this.authorize(request)) {
|
|
194
209
|
throw new ForbiddenError;
|
|
195
210
|
}
|
|
196
|
-
const payload = requestPrefersJson(request) ? await parseJsonBody(request, (body) => body) : await parseFormBody(request);
|
|
211
|
+
const payload = requestPrefersJson(request) ? await parseJsonBody(request, (body) => body) : await parseFormBody(request, { preserveRepeated: this.#preserveRepeated });
|
|
197
212
|
try {
|
|
198
213
|
return this.validatePayload(payload);
|
|
199
214
|
} catch (error) {
|
|
@@ -488,8 +488,10 @@ function createMailDriver() {
|
|
|
488
488
|
}
|
|
489
489
|
return new LogMailDriver;
|
|
490
490
|
}
|
|
491
|
-
var appMailer
|
|
491
|
+
var appMailer;
|
|
492
492
|
function mailer() {
|
|
493
|
+
if (!appMailer)
|
|
494
|
+
appMailer = new Mailer(createMailDriver());
|
|
493
495
|
return appMailer;
|
|
494
496
|
}
|
|
495
497
|
export {
|
|
@@ -197,11 +197,15 @@ function postgresAppRolePrivilegeSql(options) {
|
|
|
197
197
|
const role = assertSafeSqlIdentifier(options.role ?? POSTGRES_APP_ROLE, "role name");
|
|
198
198
|
return `GRANT CONNECT ON DATABASE ${database} TO ${role};
|
|
199
199
|
GRANT USAGE ON SCHEMA public TO ${role};
|
|
200
|
-
|
|
201
|
-
GRANT
|
|
200
|
+
REVOKE ALL PRIVILEGES ON ALL TABLES IN SCHEMA public FROM ${role};
|
|
201
|
+
GRANT SELECT, INSERT, UPDATE, DELETE ON ALL TABLES IN SCHEMA public TO ${role};
|
|
202
|
+
REVOKE ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA public FROM ${role};
|
|
203
|
+
GRANT USAGE, SELECT ON ALL SEQUENCES IN SCHEMA public TO ${role};
|
|
202
204
|
GRANT EXECUTE ON ALL FUNCTIONS IN SCHEMA public TO ${role};
|
|
203
|
-
ALTER DEFAULT PRIVILEGES IN SCHEMA public
|
|
204
|
-
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT
|
|
205
|
+
ALTER DEFAULT PRIVILEGES IN SCHEMA public REVOKE ALL ON TABLES FROM ${role};
|
|
206
|
+
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT, INSERT, UPDATE, DELETE ON TABLES TO ${role};
|
|
207
|
+
ALTER DEFAULT PRIVILEGES IN SCHEMA public REVOKE ALL ON SEQUENCES FROM ${role};
|
|
208
|
+
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT USAGE, SELECT ON SEQUENCES TO ${role};
|
|
205
209
|
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT EXECUTE ON FUNCTIONS TO ${role};
|
|
206
210
|
`;
|
|
207
211
|
}
|
package/dist/index.js
CHANGED
|
@@ -6990,6 +6990,12 @@ class Blueprint {
|
|
|
6990
6990
|
this.columns.push(column);
|
|
6991
6991
|
return column;
|
|
6992
6992
|
}
|
|
6993
|
+
uuid(name) {
|
|
6994
|
+
const column = new ColumnDefinition(name, "uuid");
|
|
6995
|
+
column.notNullable();
|
|
6996
|
+
this.columns.push(column);
|
|
6997
|
+
return column;
|
|
6998
|
+
}
|
|
6993
6999
|
text(name) {
|
|
6994
7000
|
const column = new ColumnDefinition(name, "text");
|
|
6995
7001
|
column.notNullable();
|
|
@@ -7132,6 +7138,10 @@ function compileColumnType(driver, column) {
|
|
|
7132
7138
|
return compileIdType(driver);
|
|
7133
7139
|
case "string":
|
|
7134
7140
|
return compileStringType(driver, column.length);
|
|
7141
|
+
case "uuid":
|
|
7142
|
+
if (column.autoIncrement)
|
|
7143
|
+
throw new UnsupportedSchemaFeatureError("auto-increment UUID columns", driver);
|
|
7144
|
+
return driver === "pgsql" ? "UUID" : driver === "mysql" ? "CHAR(36)" : "TEXT";
|
|
7135
7145
|
case "text":
|
|
7136
7146
|
return compileTextType(driver);
|
|
7137
7147
|
case "boolean":
|
|
@@ -7321,6 +7331,9 @@ function compileDropTable(driver, tableName) {
|
|
|
7321
7331
|
return [`DROP TABLE IF EXISTS ${quoteIdentifier(tableName)}${cascade}`];
|
|
7322
7332
|
}
|
|
7323
7333
|
function compileColumn(driver, column, mode) {
|
|
7334
|
+
if (driver === "sqlite" && mode === "alter" && column.isUnique) {
|
|
7335
|
+
throw new UnsupportedSchemaFeatureError("column-level unique() in ADD COLUMN (add the column without unique() and use table.unique(columnName) in the same schema.table callback instead)", driver);
|
|
7336
|
+
}
|
|
7324
7337
|
const quoteIdentifier = dialectFor(driver).quoteIdentifier;
|
|
7325
7338
|
const parts = [quoteIdentifier(column.name), compileColumnType(driver, column)];
|
|
7326
7339
|
if (column.autoIncrement && driver === "mysql") {
|
|
@@ -8070,6 +8083,9 @@ async function recordAppliedMigration(db, name, batch) {
|
|
|
8070
8083
|
}
|
|
8071
8084
|
async function getAppliedMigrations(db) {
|
|
8072
8085
|
await ensureMigrationsTable(db);
|
|
8086
|
+
return readAppliedMigrations(db);
|
|
8087
|
+
}
|
|
8088
|
+
async function readAppliedMigrations(db) {
|
|
8073
8089
|
return await db.unsafe(`
|
|
8074
8090
|
SELECT name, batch
|
|
8075
8091
|
FROM ${MIGRATIONS_TABLE}
|
|
@@ -8089,7 +8105,7 @@ async function loadMigrationsFromDirectory(directory) {
|
|
|
8089
8105
|
}
|
|
8090
8106
|
async function getMigrationStatus(db, migrations) {
|
|
8091
8107
|
validateMigrations(migrations);
|
|
8092
|
-
const applied = await
|
|
8108
|
+
const applied = await readAppliedMigrations(db);
|
|
8093
8109
|
const appliedByName = new Map(applied.map(({ name, batch }) => [name, Number(batch)]));
|
|
8094
8110
|
return migrations.map(({ name }) => ({
|
|
8095
8111
|
name,
|
|
@@ -11600,8 +11616,10 @@ function createMailDriver() {
|
|
|
11600
11616
|
}
|
|
11601
11617
|
return new LogMailDriver;
|
|
11602
11618
|
}
|
|
11603
|
-
var appMailer
|
|
11619
|
+
var appMailer;
|
|
11604
11620
|
function mailer() {
|
|
11621
|
+
if (!appMailer)
|
|
11622
|
+
appMailer = new Mailer(createMailDriver());
|
|
11605
11623
|
return appMailer;
|
|
11606
11624
|
}
|
|
11607
11625
|
|
|
@@ -14293,14 +14311,25 @@ function createValidateSignatureMiddleware() {
|
|
|
14293
14311
|
};
|
|
14294
14312
|
}
|
|
14295
14313
|
// ../../src/core/http/parseFormBody.ts
|
|
14296
|
-
async function parseFormBody(request) {
|
|
14314
|
+
async function parseFormBody(request, options = {}) {
|
|
14297
14315
|
const contentType = request.headers.get("content-type")?.toLowerCase() ?? "";
|
|
14298
14316
|
if (!contentType.includes("application/x-www-form-urlencoded") && !contentType.includes("multipart/form-data")) {
|
|
14299
14317
|
throw new BadRequestError("Expected a form submission.");
|
|
14300
14318
|
}
|
|
14301
|
-
return formDataToRecord(await request.formData());
|
|
14319
|
+
return formDataToRecord(await request.formData(), options);
|
|
14302
14320
|
}
|
|
14303
|
-
function formDataToRecord(formData) {
|
|
14321
|
+
function formDataToRecord(formData, options = {}) {
|
|
14322
|
+
if (options.preserveRepeated === true) {
|
|
14323
|
+
const values = new Map;
|
|
14324
|
+
for (const [key, value] of formData.entries()) {
|
|
14325
|
+
const entries = values.get(key);
|
|
14326
|
+
if (entries)
|
|
14327
|
+
entries.push(value);
|
|
14328
|
+
else
|
|
14329
|
+
values.set(key, [value]);
|
|
14330
|
+
}
|
|
14331
|
+
return Object.fromEntries(values);
|
|
14332
|
+
}
|
|
14304
14333
|
const values = {};
|
|
14305
14334
|
for (const [key, value] of formData.entries()) {
|
|
14306
14335
|
if (typeof value === "string") {
|
|
@@ -14312,6 +14341,10 @@ function formDataToRecord(formData) {
|
|
|
14312
14341
|
|
|
14313
14342
|
// ../../src/core/http/webFormRequest.ts
|
|
14314
14343
|
class WebFormRequest {
|
|
14344
|
+
#preserveRepeated;
|
|
14345
|
+
constructor(options = {}) {
|
|
14346
|
+
this.#preserveRepeated = options.preserveRepeated === true;
|
|
14347
|
+
}
|
|
14315
14348
|
authorize(_request) {
|
|
14316
14349
|
return true;
|
|
14317
14350
|
}
|
|
@@ -14322,7 +14355,7 @@ class WebFormRequest {
|
|
|
14322
14355
|
if (!await this.authorize(request)) {
|
|
14323
14356
|
throw new ForbiddenError;
|
|
14324
14357
|
}
|
|
14325
|
-
const payload = requestPrefersJson(request) ? await parseJsonBody(request, (body) => body) : await parseFormBody(request);
|
|
14358
|
+
const payload = requestPrefersJson(request) ? await parseJsonBody(request, (body) => body) : await parseFormBody(request, { preserveRepeated: this.#preserveRepeated });
|
|
14326
14359
|
try {
|
|
14327
14360
|
return this.validatePayload(payload);
|
|
14328
14361
|
} catch (error) {
|