This commit is contained in:
Marshal
2026-08-08 14:02:58 +00:00
104 changed files with 8507 additions and 962 deletions

View File

@@ -1302,6 +1302,16 @@ export const GRANULAR_SPLIT_PERMISSIONS: FreightPermissionSeed[] = [
"edr_freight_app:settings:contract_templates:read",
"Read contract template data (API only)",
),
perm(
"b4f00001-0001-4000-8000-000000000001",
"edr_freight_app:settings:support_content:view",
"View portal help & legal content",
),
perm(
"b4f00001-0001-4000-8000-000000000002",
"edr_freight_app:settings:support_content:manage",
"Edit portal help, FAQ & legal content",
),
];
// N. Previously-ungated staff surfaces (support inbox, procurement, compliance,
@@ -1851,6 +1861,11 @@ export const FREIGHT_PERMS = {
delete: "edr_freight_app:settings:contract_templates:delete",
read: "edr_freight_app:settings:contract_templates:read",
},
// Portal-facing help/FAQ/legal copy, edited from Portal content.
supportContent: {
view: "edr_freight_app:settings:support_content:view",
manage: "edr_freight_app:settings:support_content:manage",
},
},
audit: {
view: "edr_freight_app:audit:view",

View File

@@ -0,0 +1,62 @@
import { SUPPORT_CONTENT_DEFAULTS, SUPPORT_DOC_SLUGS } from "@edr/types";
import { Injectable, Logger } from "@nestjs/common";
import { DataSource } from "typeorm";
import {
SupportDocument,
SupportDocumentVersion,
} from "../modules/support-content/entities/support-document.entity";
/**
* Puts the portal's shipped help/FAQ/legal copy into the database on first
* boot. Idempotent by emptiness, like the other reference-data seeders: once a
* row exists the content is admin-managed, so a redeploy must never clobber it.
*
* Each document is written together with its `version = 1` history row, which
* is what makes `max(version)` in the log always equal the live row — the
* invariant the version list and rollback both assume.
*/
@Injectable()
export class SupportContentSeeder {
private readonly logger = new Logger(SupportContentSeeder.name);
constructor(private readonly dataSource: DataSource) {}
async run() {
const documents = this.dataSource.getRepository(SupportDocument);
const versions = this.dataSource.getRepository(SupportDocumentVersion);
const existing = await documents.count({ withDeleted: true });
if (existing > 0) {
this.logger.log(
`support_documents already has ${existing} rows — skipping seed`,
);
return;
}
for (const slug of SUPPORT_DOC_SLUGS) {
const document = await documents.save(
documents.create({
slug,
payload: SUPPORT_CONTENT_DEFAULTS[slug],
version: 1,
updatedById: null,
}),
);
await versions.save(
versions.create({
documentId: document.id,
version: 1,
payload: document.payload,
actorId: null,
note: "Initial content",
}),
);
}
this.logger.log(
`Seeded ${SUPPORT_DOC_SLUGS.length} portal content documents`,
);
}
}