style: format server and shared with prettier

A mechanical prettier --write over server/src, server/tests, server/scripts
and shared/src with the workspaces' .prettierrc; nothing but layout and
import order changes, and every file keeps the same set of imports. shared
is formatted throughout and its format baseline is empty. The server
baseline keeps the 35 files that Prettier would grow past their lint:size
limit (they need a split first, which is not a formatting change), and the
generated entity files stay as their generator writes them.
This commit is contained in:
Maurice
2026-10-10 21:23:37 +02:00
parent f4e518b2df
commit 724c88c201
1978 changed files with 78448 additions and 39347 deletions
@@ -36,27 +36,27 @@
* `nudge()`/`getLinkByToken`, so nothing in the test body before the
* `schedule()` call ever touches the EntityManager.
*/
import { describe, it, expect, beforeAll, afterAll, vi } from 'vitest';
import type { INestApplication } from '@nestjs/common';
import { buildApp } from '../../src/bootstrap';
import { db as testDb } from '../../src/db/database';
import { DocumentConnections } from '../../src/db/entities/DocumentConnections.entity';
import { DocumentProviders } from '../../src/db/entities/DocumentProviders.entity';
import { TripDocumentLinks } from '../../src/db/entities/TripDocumentLinks.entity';
import { DocSyncConfigService } from '../../src/nest/doc-sync/doc-sync-config.service';
import { DocSyncWebhookController } from '../../src/nest/doc-sync/doc-sync-webhook.controller';
import { WEBHOOK_NUDGE_DEBOUNCE_SECONDS } from '../../src/nest/doc-sync/doc-sync.constants';
import { createUser, createTrip } from '../helpers/factories';
import { insertRow, updateRows } from '../helpers/factories/rows';
import { setAddonEnabled } from '../helpers/factories/settings';
import { MikroORM } from '@mikro-orm/core';
import type { INestApplication } from '@nestjs/common';
import { describe, it, expect, beforeAll, afterAll, vi } from 'vitest';
vi.mock('../../src/db/database', async () => {
const { createSnapshotTestDb, buildDbMock } = await import('../helpers/db-mock');
return buildDbMock(createSnapshotTestDb());
});
import { db as testDb } from '../../src/db/database';
import { buildApp } from '../../src/bootstrap';
import { createUser, createTrip } from '../helpers/factories';
import { insertRow, updateRows } from '../helpers/factories/rows';
import { setAddonEnabled } from '../helpers/factories/settings';
import { DocumentConnections } from '../../src/db/entities/DocumentConnections.entity';
import { DocumentProviders } from '../../src/db/entities/DocumentProviders.entity';
import { TripDocumentLinks } from '../../src/db/entities/TripDocumentLinks.entity';
import { WEBHOOK_NUDGE_DEBOUNCE_SECONDS } from '../../src/nest/doc-sync/doc-sync.constants';
import { DocSyncWebhookController } from '../../src/nest/doc-sync/doc-sync-webhook.controller';
import { DocSyncConfigService } from '../../src/nest/doc-sync/doc-sync-config.service';
describe('DocSyncWebhookController#schedule() runs its detached timer body inside its own request context', () => {
let app: INestApplication;
let controller: DocSyncWebhookController;
@@ -107,32 +107,28 @@ describe('DocSyncWebhookController#schedule() runs its detached timer body insid
testDb.close();
});
it(
'WEBHOOK-CTX-001: schedule(), called from a genuinely bare (non-request) context, never logs cannotUseGlobalContext once its debounce timer fires',
async () => {
const errSpy = vi.spyOn(console, 'error').mockImplementation(() => {});
try {
// Calling the controller's own private `schedule()` directly, bracket
// notation only (no `any`/`as unknown as`): this test function body is
// not inside ANY AsyncLocalStorage context, unlike a real HTTP request
// through Nest's middleware — so the timer this starts is the real
// thing the docstring above describes, not one riding a caller's fork.
controller['schedule'](linkId, () => config.getLink(linkId));
it('WEBHOOK-CTX-001: schedule(), called from a genuinely bare (non-request) context, never logs cannotUseGlobalContext once its debounce timer fires', async () => {
const errSpy = vi.spyOn(console, 'error').mockImplementation(() => {});
try {
// Calling the controller's own private `schedule()` directly, bracket
// notation only (no `any`/`as unknown as`): this test function body is
// not inside ANY AsyncLocalStorage context, unlike a real HTTP request
// through Nest's middleware — so the timer this starts is the real
// thing the docstring above describes, not one riding a caller's fork.
controller['schedule'](linkId, () => config.getLink(linkId));
// Let the real debounce timer fire, then drain the microtasks its
// async body queues (real timers here — the detached body is a
// genuine `setTimeout`, not something fake timers can fast-forward
// through a real HTTP-free integration boot safely).
await new Promise((resolve) => setTimeout(resolve, (WEBHOOK_NUDGE_DEBOUNCE_SECONDS + 2) * 1000));
// Let the real debounce timer fire, then drain the microtasks its
// async body queues (real timers here — the detached body is a
// genuine `setTimeout`, not something fake timers can fast-forward
// through a real HTTP-free integration boot safely).
await new Promise((resolve) => setTimeout(resolve, (WEBHOOK_NUDGE_DEBOUNCE_SECONDS + 2) * 1000));
const suspicious = errSpy.mock.calls
.map((args) => args.map(String).join(' '))
.filter((line) => /cannotUseGlobalContext|global EntityManager/i.test(line));
expect(suspicious).toEqual([]);
} finally {
errSpy.mockRestore();
}
},
20_000,
);
const suspicious = errSpy.mock.calls
.map((args) => args.map(String).join(' '))
.filter((line) => /cannotUseGlobalContext|global EntityManager/i.test(line));
expect(suspicious).toEqual([]);
} finally {
errSpy.mockRestore();
}
}, 20_000);
});