Reorganize repo structure and standards references
This commit is contained in:
1 parent
3cb93a81be
commit
be2054274d
5885 files changed
+2588
-195
No files matched your search
@@ -0,0 +1,93 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import {
|
||||
createAuditEvent,
|
||||
createStoredIdempotencyResponse,
|
||||
buildTenantSettingsRowCreateInput,
|
||||
buildTenantSettingsRowUpdateInput,
|
||||
databaseBoundary,
|
||||
findOptionalTenantSettingsEntity,
|
||||
findTenantSettingsEntity,
|
||||
findTenantWithSettingsById,
|
||||
getDatabaseBoundary,
|
||||
PRISMA_GENERATED_CLIENT_PATH,
|
||||
PRISMA_MIGRATIONS_PATH,
|
||||
PRISMA_SCHEMA_PATH,
|
||||
prismaOwnershipMetadata,
|
||||
tenantSettingsDetailsInclude,
|
||||
} from ".";
|
||||
|
||||
describe("@toolctrl/db boundary metadata", () => {
|
||||
it("documents the current Prisma ownership boundary", () => {
|
||||
expect(getDatabaseBoundary()).toBe(databaseBoundary);
|
||||
expect(databaseBoundary).toMatchObject({
|
||||
packageName: "@toolctrl/db",
|
||||
orm: "prisma",
|
||||
schemaPath: PRISMA_SCHEMA_PATH,
|
||||
migrationsPath: PRISMA_MIGRATIONS_PATH,
|
||||
generatedClientPath: PRISMA_GENERATED_CLIENT_PATH,
|
||||
serverClientEntrypoint: "@toolctrl/db/client.server",
|
||||
});
|
||||
});
|
||||
|
||||
it("is immutable at runtime", () => {
|
||||
expect(Object.isFrozen(databaseBoundary)).toBe(true);
|
||||
expect(Object.isFrozen(prismaOwnershipMetadata)).toBe(true);
|
||||
});
|
||||
|
||||
it("keeps the root Prisma config aligned with package metadata", async () => {
|
||||
process.env.DATABASE_URL ??= "postgresql://test:test@localhost:5432/test";
|
||||
const { default: prismaConfig } = await import("../../../prisma.config");
|
||||
|
||||
expect(prismaConfig.schema).toBe(prismaOwnershipMetadata.schemaPath);
|
||||
expect(prismaConfig.migrations?.path).toBe(
|
||||
prismaOwnershipMetadata.migrationsPath,
|
||||
);
|
||||
expect(prismaConfig.migrations?.seed).toBe(
|
||||
prismaOwnershipMetadata.seedCommand,
|
||||
);
|
||||
expect(PRISMA_GENERATED_CLIENT_PATH).toBe(
|
||||
prismaOwnershipMetadata.generatedClientPath,
|
||||
);
|
||||
});
|
||||
|
||||
it("exposes the tenant settings boundary from the package root", () => {
|
||||
expect(createAuditEvent).toEqual(expect.any(Function));
|
||||
expect(createStoredIdempotencyResponse).toEqual(expect.any(Function));
|
||||
expect(findOptionalTenantSettingsEntity).toEqual(expect.any(Function));
|
||||
expect(findTenantSettingsEntity).toEqual(expect.any(Function));
|
||||
expect(findTenantWithSettingsById).toEqual(expect.any(Function));
|
||||
expect(buildTenantSettingsRowCreateInput).toEqual(expect.any(Function));
|
||||
expect(buildTenantSettingsRowUpdateInput).toEqual(expect.any(Function));
|
||||
expect(tenantSettingsDetailsInclude).toEqual(
|
||||
expect.objectContaining({
|
||||
tenantSettingsRow: { include: { row: expect.any(Object) } },
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it("exposes the tenant settings boundary subpath export", async () => {
|
||||
const settingsBoundary = await import("@toolctrl/db/settings.server");
|
||||
|
||||
expect(settingsBoundary).toEqual(
|
||||
expect.objectContaining({
|
||||
findOptionalTenantSettingsEntity,
|
||||
findTenantSettingsEntity,
|
||||
findTenantWithSettingsById,
|
||||
buildTenantSettingsRowCreateInput,
|
||||
buildTenantSettingsRowUpdateInput,
|
||||
tenantSettingsDetailsInclude,
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it("exposes audit and idempotency boundary subpath exports", async () => {
|
||||
const auditBoundary = await import("@toolctrl/db/audit-events.server");
|
||||
const idempotencyBoundary = await import("@toolctrl/db/idempotency-keys.server");
|
||||
|
||||
expect(auditBoundary.createAuditEvent).toBe(createAuditEvent);
|
||||
expect(idempotencyBoundary.createStoredIdempotencyResponse).toBe(
|
||||
createStoredIdempotencyResponse,
|
||||
);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user