mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-26 18:42:49 +00:00
fix: seeder
This commit is contained in:
@@ -65,7 +65,7 @@ import { FreightPositionsSeeder } from "./seed/freight-positions.seeder";
|
||||
import { PaymentModule } from "./modules/payment/payment.module";
|
||||
// import { PricingDataSeeder } from "./seed/pricing-data.seeder";
|
||||
import { FileUploadSettingsSeeder } from "./seed/file-upload-settings.seeder";
|
||||
import { YardFacilitiesSeeder } from "./seed/yard-facilities.seeder";
|
||||
// import { YardFacilitiesSeeder } from "./seed/yard-facilities.seeder";
|
||||
// import { IndodeFacilitySeeder } from "./seed/indode-facility.seeder";
|
||||
// import { Batch14TestDataSeeder } from "./seed/batch1-4-test-data.seeder";
|
||||
// import { Batch5TestDataSeeder } from "./seed/batch5-test-data.seeder";
|
||||
@@ -226,7 +226,7 @@ import { LoginAudienceMiddleware } from "./modules/auth/login-audience.middlewar
|
||||
EdrOrgSeeder,
|
||||
FreightPositionsSeeder,
|
||||
FileUploadSettingsSeeder,
|
||||
YardFacilitiesSeeder,
|
||||
// YardFacilitiesSeeder,
|
||||
FreightPermissionKeyMigrationSeeder,
|
||||
// Disabled seeds — providers commented out (imports/injection/run too):
|
||||
// DemoUsersSeeder,
|
||||
@@ -253,7 +253,7 @@ export class AppModule implements OnApplicationBootstrap {
|
||||
private readonly edrOrgSeeder: EdrOrgSeeder,
|
||||
private readonly freightPositionsSeeder: FreightPositionsSeeder,
|
||||
private readonly fileUploadSettingsSeeder: FileUploadSettingsSeeder,
|
||||
private readonly yardFacilitiesSeeder: YardFacilitiesSeeder,
|
||||
// private readonly yardFacilitiesSeeder: YardFacilitiesSeeder,
|
||||
private readonly freightPermissionKeyMigrationSeeder: FreightPermissionKeyMigrationSeeder,
|
||||
// Disabled seeds — injections commented out (imports/provider/run too):
|
||||
// private readonly demoUsersSeeder: DemoUsersSeeder,
|
||||
@@ -302,7 +302,7 @@ export class AppModule implements OnApplicationBootstrap {
|
||||
|
||||
// Flags which yards can load/unload cargo (Indode, Sebeta, Modjo, Adama,
|
||||
// Dire Dawa). Idempotent; creates no yards.
|
||||
await this.yardFacilitiesSeeder.run();
|
||||
// await this.yardFacilitiesSeeder.run();
|
||||
|
||||
// Dropdown settings are not seeded on boot; run them with
|
||||
// `pnpm seed:dropdown-settings` (src/scripts/seed-dropdown-settings.ts).
|
||||
@@ -333,7 +333,9 @@ export class AppModule implements OnApplicationBootstrap {
|
||||
|
||||
configure(consumer: MiddlewareConsumer) {
|
||||
consumer.apply(LoggerMiddleware).forRoutes("*");
|
||||
consumer.apply(LoginAudienceMiddleware).forRoutes(
|
||||
consumer
|
||||
.apply(LoginAudienceMiddleware)
|
||||
.forRoutes(
|
||||
{ path: "auth/login", method: RequestMethod.POST },
|
||||
{ path: "auth/mfa-verify", method: RequestMethod.POST },
|
||||
);
|
||||
|
||||
@@ -29,11 +29,13 @@ type SeedOrganization = {
|
||||
export class EdrOrgSeeder {
|
||||
private readonly logger = new Logger(EdrOrgSeeder.name);
|
||||
|
||||
constructor(private readonly dataSource: DataSource) {}
|
||||
constructor(private readonly dataSource: DataSource) { }
|
||||
|
||||
async run() {
|
||||
if (!this.shouldSeed()) {
|
||||
this.logger.log(`Skipping EDR org seed because ${SEED_FLAG} is not enabled`);
|
||||
this.logger.log(
|
||||
`Skipping EDR org seed because ${SEED_FLAG} is not enabled`,
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -95,20 +97,22 @@ export class EdrOrgSeeder {
|
||||
manager: EntityManager,
|
||||
organizationId: string,
|
||||
) {
|
||||
const organizationConfigurationRepository =
|
||||
manager.getRepository(OrganizationConfiguration);
|
||||
const organizationConfigurationRepository = manager.getRepository(
|
||||
OrganizationConfiguration,
|
||||
);
|
||||
|
||||
await organizationConfigurationRepository.upsert({
|
||||
await organizationConfigurationRepository.upsert(
|
||||
{
|
||||
organizationId,
|
||||
canCreateBranchByItself: true,
|
||||
canStartReceivingRecord: true,
|
||||
}, {
|
||||
},
|
||||
{
|
||||
conflictPaths: { organizationId: true },
|
||||
});
|
||||
|
||||
this.logger.log(
|
||||
`Ensured organization configuration for '${EDR_ORG_KEY}'`,
|
||||
},
|
||||
);
|
||||
|
||||
this.logger.log(`Ensured organization configuration for '${EDR_ORG_KEY}'`);
|
||||
}
|
||||
|
||||
private async ensureDefaultUnit(
|
||||
@@ -152,7 +156,9 @@ export class EdrOrgSeeder {
|
||||
key: EDR_FREIGHT_APPLICATION.key,
|
||||
name: { ...EDR_FREIGHT_APPLICATION.name },
|
||||
});
|
||||
this.logger.log(`Seeded EDR application '${EDR_FREIGHT_APPLICATION.key}'`);
|
||||
this.logger.log(
|
||||
`Seeded EDR application '${EDR_FREIGHT_APPLICATION.key}'`,
|
||||
);
|
||||
return { id: insertResult.identifiers[0]?.id as string };
|
||||
}
|
||||
|
||||
@@ -181,7 +187,8 @@ export class EdrOrgSeeder {
|
||||
applicationId,
|
||||
})),
|
||||
)
|
||||
.orUpdate(["name", "application_id"], ["key"])
|
||||
.orIgnore()
|
||||
// .orUpdate(["name", "application_id"], ["key"])
|
||||
.execute();
|
||||
|
||||
this.logger.log(
|
||||
|
||||
@@ -143,7 +143,11 @@ function up() {
|
||||
}
|
||||
}
|
||||
|
||||
const [cmd, ...extra] = process.argv.slice(2);
|
||||
const [cmd, ...rawExtra] = process.argv.slice(2);
|
||||
// `pnpm it:test -- src/foo.it.ts` hands us a literal "--" first. Forwarding it
|
||||
// makes vitest treat everything after it as CLI options and ignore the file
|
||||
// filter — the "one file" run silently becomes the whole suite.
|
||||
const extra = rawExtra[0] === "--" ? rawExtra.slice(1) : rawExtra;
|
||||
|
||||
switch (cmd) {
|
||||
case "up":
|
||||
|
||||
Reference in New Issue
Block a user