added format command and added trailing commas to reduce conflicts

This commit is contained in:
dswbx
2025-02-26 20:06:03 +01:00
parent 88b5359f1c
commit 7743f71a11
414 changed files with 3622 additions and 3610 deletions

View File

@@ -43,10 +43,10 @@ describe("AppAuth", () => {
{
enabled: true,
jwt: {
secret: "123456"
}
secret: "123456",
},
},
ctx
ctx,
);
await auth.build();
@@ -63,12 +63,12 @@ describe("AppAuth", () => {
const res = await app.request("/password/register", {
method: "POST",
headers: {
"Content-Type": "application/json"
"Content-Type": "application/json",
},
body: JSON.stringify({
email: "some@body.com",
password: "123456"
})
password: "123456",
}),
});
enableConsoleLog();
expect(res.status).toBe(200);
@@ -85,10 +85,10 @@ describe("AppAuth", () => {
auth: {
enabled: true,
jwt: {
secret: "123456"
}
}
}
secret: "123456",
},
},
},
});
await app.build();
@@ -109,14 +109,14 @@ describe("AppAuth", () => {
initialConfig: {
auth: {
entity_name: "users",
enabled: true
enabled: true,
},
data: em({
users: entity("users", {
additional: text()
})
}).toJSON()
}
additional: text(),
}),
}).toJSON(),
},
});
await app.build();
@@ -132,21 +132,21 @@ describe("AppAuth", () => {
const app = createApp({
initialConfig: {
auth: {
enabled: true
enabled: true,
},
data: em({
users: entity("users", {
strategy: text({
fillable: true,
hidden: false
hidden: false,
}),
strategy_value: text({
fillable: true,
hidden: false
})
})
}).toJSON()
}
hidden: false,
}),
}),
}).toJSON(),
},
});
await app.build();

View File

@@ -19,16 +19,16 @@ describe("AppMedia", () => {
adapter: {
type: "local",
config: {
path: "./"
}
}
path: "./",
},
},
},
data: em({
media: entity("media", {
additional: text()
})
}).toJSON()
}
additional: text(),
}),
}).toJSON(),
},
});
await app.build();
@@ -49,7 +49,7 @@ describe("AppMedia", () => {
"modified_at",
"reference",
"entity_id",
"metadata"
"metadata",
]);
});
});

View File

@@ -47,7 +47,7 @@ describe("Module", async () => {
prt = {
ensureEntity: this.ensureEntity.bind(this),
ensureIndex: this.ensureIndex.bind(this),
ensureSchema: this.ensureSchema.bind(this)
ensureSchema: this.ensureSchema.bind(this),
};
get em() {
@@ -60,7 +60,7 @@ describe("Module", async () => {
Object.values(_em.entities),
new DummyConnection(),
_em.relations,
_em.indices
_em.indices,
);
return new M({} as any, { em, flags: Module.ctx_flags } as any);
}
@@ -69,14 +69,14 @@ describe("Module", async () => {
entities: _em.entities.map((e) => ({
name: e.name,
fields: e.fields.map((f) => f.name),
type: e.type
type: e.type,
})),
indices: _em.indices.map((i) => ({
name: i.name,
entity: i.entity.name,
fields: i.fields.map((f) => f.name),
unique: i.unique
}))
unique: i.unique,
})),
};
}
@@ -88,15 +88,15 @@ describe("Module", async () => {
expect(flat(make(initial).em)).toEqual({
entities: [],
indices: []
indices: [],
});
});
test("init", () => {
const initial = em({
users: entity("u", {
name: text()
})
name: text(),
}),
});
const m = make(initial);
@@ -107,18 +107,18 @@ describe("Module", async () => {
{
name: "u",
fields: ["id", "name"],
type: "regular"
}
type: "regular",
},
],
indices: []
indices: [],
});
});
test("ensure entity", () => {
const initial = em({
users: entity("u", {
name: text()
})
name: text(),
}),
});
const m = make(initial);
@@ -127,17 +127,17 @@ describe("Module", async () => {
{
name: "u",
fields: ["id", "name"],
type: "regular"
}
type: "regular",
},
],
indices: []
indices: [],
});
// this should add a new entity
m.prt.ensureEntity(
entity("p", {
title: text()
})
title: text(),
}),
);
// this should only add the field "important"
@@ -145,11 +145,11 @@ describe("Module", async () => {
entity(
"u",
{
important: text()
important: text(),
},
undefined,
"system"
)
"system",
),
);
expect(m.ctx.flags.sync_required).toBe(true);
@@ -159,22 +159,22 @@ describe("Module", async () => {
name: "u",
fields: ["id", "name", "important"],
// ensured type must be present
type: "system"
type: "system",
},
{
name: "p",
fields: ["id", "title"],
type: "regular"
}
type: "regular",
},
],
indices: []
indices: [],
});
});
test("ensure index", () => {
const users = entity("u", {
name: text(),
title: text()
title: text(),
});
const initial = em({ users }, ({ index }, { users }) => {
index(users).on(["title"]);
@@ -189,23 +189,23 @@ describe("Module", async () => {
{
name: "u",
fields: ["id", "name", "title"],
type: "regular"
}
type: "regular",
},
],
indices: [
{
name: "idx_u_title",
entity: "u",
fields: ["title"],
unique: false
unique: false,
},
{
name: "idx_u_name",
entity: "u",
fields: ["name"],
unique: false
}
]
unique: false,
},
],
});
});
});

View File

@@ -39,10 +39,10 @@ describe("ModuleManager", async () => {
basepath: "/api/data2",
entities: {
test: entity("test", {
content: text()
}).toJSON()
}
}
content: text(),
}).toJSON(),
},
},
});
//const { version, ...json } = mm.toJSON() as any;
@@ -69,10 +69,10 @@ describe("ModuleManager", async () => {
basepath: "/api/data2",
entities: {
test: entity("test", {
content: text()
}).toJSON()
}
}
content: text(),
}).toJSON(),
},
},
};
//const { version, ...json } = mm.toJSON() as any;
@@ -105,7 +105,7 @@ describe("ModuleManager", async () => {
const c2 = getDummyConnection();
const db = c2.dummyConnection.kysely;
const mm2 = new ModuleManager(c2.dummyConnection, {
initial: { version: version - 1, ...json }
initial: { version: version - 1, ...json },
});
await mm2.syncConfigTable();
@@ -129,7 +129,7 @@ describe("ModuleManager", async () => {
const db = c2.dummyConnection.kysely;
const mm2 = new ModuleManager(c2.dummyConnection, {
initial: { version: version - 1, ...json }
initial: { version: version - 1, ...json },
});
await mm2.syncConfigTable();
await db
@@ -157,8 +157,8 @@ describe("ModuleManager", async () => {
...json,
data: {
...json.data,
basepath: "/api/data2"
}
basepath: "/api/data2",
},
};
await db
.insertInto(TABLE_NAME)
@@ -190,9 +190,9 @@ describe("ModuleManager", async () => {
...configs.server,
admin: {
...configs.server.admin,
color_scheme: "dark"
}
}
color_scheme: "dark",
},
},
});
});
@@ -201,11 +201,11 @@ describe("ModuleManager", async () => {
const partial = {
auth: {
enabled: true
}
enabled: true,
},
};
const mm = new ModuleManager(dummyConnection, {
initial: partial
initial: partial,
});
await mm.build();
@@ -227,9 +227,9 @@ describe("ModuleManager", async () => {
const mm2 = new ModuleManager(c2.dummyConnection, {
initial: {
auth: {
basepath: "/shouldnt/take/this"
}
}
basepath: "/shouldnt/take/this",
},
},
});
await mm2.syncConfigTable();
const payload = {
@@ -237,15 +237,15 @@ describe("ModuleManager", async () => {
auth: {
...json.auth,
enabled: true,
basepath: "/api/auth2"
}
basepath: "/api/auth2",
},
};
await db
.insertInto(TABLE_NAME)
.values({
type: "config",
json: JSON.stringify(payload),
version: CURRENT_VERSION
version: CURRENT_VERSION,
})
.execute();
await mm2.build();
@@ -256,7 +256,7 @@ describe("ModuleManager", async () => {
describe("revert", async () => {
const failingModuleSchema = Type.Object({
value: Type.Optional(Type.Number())
value: Type.Optional(Type.Number()),
});
class FailingModule extends Module<typeof failingModuleSchema> {
getSchema() {
@@ -301,8 +301,8 @@ describe("ModuleManager", async () => {
const mm = new TestModuleManager(dummyConnection, {
initial: {
// @ts-ignore
failing: { value: 2 }
}
failing: { value: 2 },
},
});
await mm.build();
expect(mm.configs()["failing"].value).toBe(2);
@@ -313,8 +313,8 @@ describe("ModuleManager", async () => {
const mm = new TestModuleManager(dummyConnection, {
initial: {
// @ts-ignore
failing: { value: -1 }
}
failing: { value: -1 },
},
});
expect(mm.build()).rejects.toThrow(/value must be positive/);
expect(mm.configs()["failing"].value).toBe(-1);
@@ -326,7 +326,7 @@ describe("ModuleManager", async () => {
const mm = new TestModuleManager(dummyConnection, {
onUpdated: async () => {
mockOnUpdated();
}
},
});
await mm.build();
// @ts-ignore
@@ -342,11 +342,11 @@ describe("ModuleManager", async () => {
const mm = new TestModuleManager(dummyConnection, {
initial: {
// @ts-ignore
failing: { value: 1 }
failing: { value: 1 },
},
onUpdated: async () => {
mockOnUpdated();
}
},
});
await mm.build();
expect(mm.configs()["failing"].value).toBe(1);
@@ -354,7 +354,7 @@ describe("ModuleManager", async () => {
// now safe mutate
// @ts-ignore
expect(mm.mutateConfigSafe("failing").set({ value: -2 })).rejects.toThrow(
/value must be positive/
/value must be positive/,
);
expect(mm.configs()["failing"].value).toBe(1);
expect(mockOnUpdated).toHaveBeenCalled();

View File

@@ -19,7 +19,7 @@ export function makeCtx(overrides?: Partial<ModuleBuildContext>): ModuleBuildCon
guard: new Guard(),
flags: Module.ctx_flags,
logger: new DebugLogger(false),
...overrides
...overrides,
};
}