@opencrvs/toolkit 1.9.12-rc.bce2e6f → 1.9.12-rc.bf52336

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/dist/application-config/index.js +2038 -45
  2. package/dist/cli.js +850 -35
  3. package/dist/commons/api/router.d.ts +86 -79
  4. package/dist/commons/application-config/index.d.ts +6 -4
  5. package/dist/commons/events/ActionDocument.d.ts +6 -6
  6. package/dist/commons/events/ActionType.d.ts +3 -3
  7. package/dist/commons/events/AdvancedSearchConfig.d.ts +10 -10
  8. package/dist/commons/events/CountryConfigQueryInput.d.ts +222 -222
  9. package/dist/commons/events/Draft.d.ts +8 -8
  10. package/dist/commons/events/EventConfig.d.ts +1 -1
  11. package/dist/commons/events/EventDocument.d.ts +3 -3
  12. package/dist/commons/events/EventIndex.d.ts +15 -15
  13. package/dist/commons/events/EventMetadata.d.ts +12 -12
  14. package/dist/commons/events/FieldConfig.d.ts +26 -26
  15. package/dist/commons/events/FieldType.d.ts +1 -1
  16. package/dist/commons/events/FieldTypeMapping.d.ts +4 -4
  17. package/dist/commons/events/WorkqueueColumnConfig.d.ts +13 -13
  18. package/dist/commons/events/WorkqueueConfig.d.ts +239 -239
  19. package/dist/commons/events/state/index.d.ts +2 -2
  20. package/dist/commons/events/state/utils.d.ts +3 -3
  21. package/dist/commons/events/utils.d.ts +3 -3
  22. package/dist/migrations/v2.0/convert-config-files-to-ts.d.ts.map +1 -1
  23. package/dist/migrations/v2.0/convert-config-files-to-ts.js +97 -21
  24. package/dist/migrations/v2.0/index.d.ts.map +1 -1
  25. package/dist/migrations/v2.0/index.js +848 -33
  26. package/dist/migrations/v2.0/migrate-scopes.d.ts.map +1 -1
  27. package/dist/migrations/v2.0/migrate-scopes.js +6 -5
  28. package/dist/migrations/v2.0/migrate-workqueue-configs.d.ts +3 -0
  29. package/dist/migrations/v2.0/migrate-workqueue-configs.d.ts.map +1 -0
  30. package/dist/migrations/v2.0/migrate-workqueue-configs.js +237 -0
  31. package/dist/migrations/v2.0/remove-demo-scope.d.ts +3 -0
  32. package/dist/migrations/v2.0/remove-demo-scope.d.ts.map +1 -0
  33. package/dist/migrations/v2.0/remove-demo-scope.js +75 -0
  34. package/dist/migrations/v2.0/remove-hearth-migrations.d.ts +3 -0
  35. package/dist/migrations/v2.0/remove-hearth-migrations.d.ts.map +1 -0
  36. package/dist/migrations/v2.0/remove-hearth-migrations.js +78 -0
  37. package/opencrvs-toolkit-1.9.12-rc.bf52336.tgz +0 -0
  38. package/package.json +1 -1
  39. package/tsconfig.json +3 -0
  40. package/tsconfig.tsbuildinfo +1 -1
  41. package/opencrvs-toolkit-1.9.12-rc.bce2e6f.tgz +0 -0
@@ -7,7 +7,7 @@ import { Draft } from '../Draft';
7
7
  import { EventConfig } from '../EventConfig';
8
8
  import { UUID } from '../../uuid';
9
9
  import { DocumentPath } from '../../documents';
10
- export declare function getStatusFromActions(actions: Array<Action>): "ARCHIVED" | "DECLARED" | "REGISTERED" | "CREATED" | "NOTIFIED";
10
+ export declare function getStatusFromActions(actions: Array<Action>): "CREATED" | "NOTIFIED" | "DECLARED" | "REGISTERED" | "ARCHIVED";
11
11
  export declare function getAssignedUserFromActions(actions: Array<ActionDocument>): string | null;
12
12
  export declare function getAssignedUserSignatureFromActions(actions: Array<ActionDocument>): string | null;
13
13
  type NonNullableDeep<T> = T extends [unknown, ...unknown[]] ? {
@@ -64,7 +64,7 @@ export declare function applyDeclarationToEventIndex(eventIndex: EventIndex, dec
64
64
  export declare function applyDraftToEventIndex(eventIndex: EventIndex, draft: Draft, eventConfiguration: EventConfig): {
65
65
  id: string & import("zod").$brand<"UUID">;
66
66
  type: string;
67
- status: "ARCHIVED" | "DECLARED" | "REGISTERED" | "CREATED" | "NOTIFIED";
67
+ status: "CREATED" | "NOTIFIED" | "DECLARED" | "REGISTERED" | "ARCHIVED";
68
68
  legalStatuses: {
69
69
  DECLARED?: {
70
70
  createdAt: string;
@@ -289,15 +289,15 @@ export declare function getActionUpdateMetadata(actions: Action[]): Partial<{
289
289
  originalActionId?: (string & import("zod").$brand<"UUID">) | null | undefined;
290
290
  } | {
291
291
  id: string & import("zod").$brand<"UUID">;
292
- createdAt: string;
293
292
  transactionId: string;
294
293
  createdByUserType: "user" | "system";
294
+ createdAt: string;
295
295
  createdBy: string;
296
- type: "NOTIFY" | "DECLARE" | "REGISTER" | "EDIT" | "REJECT" | "ARCHIVE" | "PRINT_CERTIFICATE" | "REQUEST_CORRECTION" | "REJECT_CORRECTION" | "APPROVE_CORRECTION" | "CUSTOM";
296
+ type: "CUSTOM" | "NOTIFY" | "DECLARE" | "REGISTER" | "EDIT" | "REJECT" | "ARCHIVE" | "PRINT_CERTIFICATE" | "REQUEST_CORRECTION" | "REJECT_CORRECTION" | "APPROVE_CORRECTION";
297
297
  status: "Rejected";
298
- createdAtLocation?: (string & import("zod").$brand<"UUID">) | null | undefined;
299
298
  createdByRole?: string | undefined;
300
299
  createdBySignature?: (string & import("zod").$brand<"DocumentPath">) | null | undefined;
300
+ createdAtLocation?: (string & import("zod").$brand<"UUID">) | null | undefined;
301
301
  originalActionId?: (string & import("zod").$brand<"UUID">) | null | undefined;
302
302
  }>;
303
303
  /**
@@ -434,15 +434,15 @@ export declare function findLastAssignmentAction(actions: Action[]): {
434
434
  originalActionId?: (string & import("zod").$brand<"UUID">) | null | undefined;
435
435
  } | {
436
436
  id: string & import("zod").$brand<"UUID">;
437
- createdAt: string;
438
437
  transactionId: string;
439
438
  createdByUserType: "user" | "system";
439
+ createdAt: string;
440
440
  createdBy: string;
441
- type: "NOTIFY" | "DECLARE" | "REGISTER" | "EDIT" | "REJECT" | "ARCHIVE" | "PRINT_CERTIFICATE" | "REQUEST_CORRECTION" | "REJECT_CORRECTION" | "APPROVE_CORRECTION" | "CUSTOM";
441
+ type: "CUSTOM" | "NOTIFY" | "DECLARE" | "REGISTER" | "EDIT" | "REJECT" | "ARCHIVE" | "PRINT_CERTIFICATE" | "REQUEST_CORRECTION" | "REJECT_CORRECTION" | "APPROVE_CORRECTION";
442
442
  status: "Rejected";
443
- createdAtLocation?: (string & import("zod").$brand<"UUID">) | null | undefined;
444
443
  createdByRole?: string | undefined;
445
444
  createdBySignature?: (string & import("zod").$brand<"DocumentPath">) | null | undefined;
445
+ createdAtLocation?: (string & import("zod").$brand<"UUID">) | null | undefined;
446
446
  originalActionId?: (string & import("zod").$brand<"UUID">) | null | undefined;
447
447
  } | undefined;
448
448
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"convert-config-files-to-ts.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/convert-config-files-to-ts.ts"],"names":[],"mappings":"AA+pBA,wBAAsB,IAAI,kBAiOzB"}
1
+ {"version":3,"file":"convert-config-files-to-ts.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/convert-config-files-to-ts.ts"],"names":[],"mappings":"AAyuBA,wBAAsB,IAAI,kBAyPzB"}
@@ -318,25 +318,6 @@ function transformDashboardsValue(init, isProd) {
318
318
  */
319
319
  function generateTsContent(configObj, exportName, group, isProd) {
320
320
  var _a;
321
- // ── File header ─────────────────────────────────────────────────────────────
322
- const headerLines = [];
323
- if (isProd) {
324
- headerLines.push(`import { env } from './environment'`);
325
- }
326
- headerLines.push(`import { ${group.defineFn} } from '${group.importFrom}'`);
327
- if (group.applicationConfigImportPath) {
328
- headerLines.push(`import { applicationConfig } from '${group.applicationConfigImportPath}'`);
329
- }
330
- headerLines.push('');
331
- if (isProd) {
332
- headerLines.push(`const scheme = 'https'`);
333
- headerLines.push(`const hostname = env.DOMAIN`);
334
- headerLines.push(`const sentry = env.SENTRY_DSN`);
335
- }
336
- else {
337
- headerLines.push(`const scheme = 'http'`);
338
- headerLines.push(`const hostname = 'localhost'`);
339
- }
340
321
  // ── Config properties ────────────────────────────────────────────────────────
341
322
  const propertyLines = [];
342
323
  const seenKeys = new Set();
@@ -379,6 +360,26 @@ function generateTsContent(configObj, exportName, group, isProd) {
379
360
  propertyLines.push(` ${key}: applicationConfig.${key}`);
380
361
  }
381
362
  const body = propertyLines.join(',\n');
363
+ const headerLines = [];
364
+ headerLines.push(`import * as fs from 'fs'`);
365
+ headerLines.push(`import { join } from 'path'`);
366
+ if (isProd) {
367
+ headerLines.push(`import { env } from './environment'`);
368
+ }
369
+ headerLines.push(`import { ${group.defineFn} } from '${group.importFrom}'`);
370
+ if (group.applicationConfigImportPath) {
371
+ headerLines.push(`import { applicationConfig } from '${group.applicationConfigImportPath}'`);
372
+ }
373
+ headerLines.push('');
374
+ if (isProd) {
375
+ headerLines.push(`const scheme = 'https'`);
376
+ headerLines.push(`const hostname = env.DOMAIN`);
377
+ headerLines.push(`const sentry = env.SENTRY_DSN`);
378
+ }
379
+ else {
380
+ headerLines.push(`const scheme = 'http'`);
381
+ headerLines.push(`const hostname = 'localhost'`);
382
+ }
382
383
  return [
383
384
  ...headerLines,
384
385
  '',
@@ -571,6 +572,64 @@ function resolveConfigChain(configObj, path) {
571
572
  }
572
573
  return current.getText();
573
574
  }
575
+ /**
576
+ * When inlining a value from `application-config.ts` into a file in a
577
+ * different directory, `__dirname`-based paths (e.g. for reading image
578
+ * assets) must be adjusted so they continue to resolve to the original
579
+ * location — the referenced files themselves are NOT moved.
580
+ *
581
+ * Rewrites `join(__dirname, ...)` / `path.join(__dirname, ...)` /
582
+ * `resolve(__dirname, ...)` / `path.resolve(__dirname, ...)` by inserting
583
+ * the relative path from the target directory back to the source directory
584
+ * as an extra leading argument.
585
+ *
586
+ * Example: inlining from `src/api/application/` into `src/login-config.ts`
587
+ * join(__dirname, 'login-bg.jpg')
588
+ * → join(__dirname, 'api/application', 'login-bg.jpg')
589
+ */
590
+ function rewriteDirnameRefs(text, relDir) {
591
+ if (!relDir || relDir === '.')
592
+ return text;
593
+ const relForward = relDir.replace(/\\/g, '/');
594
+ return text.replace(/\b((?:path\.)?(?:join|resolve))\s*\(\s*__dirname\s*,/g, `$1(__dirname, '${relForward}',`);
595
+ }
596
+ /**
597
+ * Ensures the source file has a namespace `fs` import (`import * as fs from 'fs'`).
598
+ * No-op if a namespace or default `fs` import is already present.
599
+ */
600
+ function ensureFsImport(sf) {
601
+ const hasFs = sf
602
+ .getImportDeclarations()
603
+ .some((d) => d.getModuleSpecifierValue() === 'fs' &&
604
+ (d.getNamespaceImport() || d.getDefaultImport()));
605
+ if (hasFs)
606
+ return;
607
+ sf.addImportDeclaration({
608
+ moduleSpecifier: 'fs',
609
+ namespaceImport: 'fs'
610
+ });
611
+ }
612
+ /**
613
+ * Ensures the source file has a named `join` import from 'path'.
614
+ * Merges into an existing 'path' import if present, otherwise adds a new
615
+ * `import { join } from 'path'` declaration.
616
+ */
617
+ function ensureJoinImport(sf) {
618
+ const pathImports = sf
619
+ .getImportDeclarations()
620
+ .filter((d) => d.getModuleSpecifierValue() === 'path');
621
+ if (pathImports.some((d) => d.getNamedImports().some((ni) => ni.getName() === 'join'))) {
622
+ return;
623
+ }
624
+ if (pathImports.length > 0) {
625
+ pathImports[0].addNamedImport('join');
626
+ return;
627
+ }
628
+ sf.addImportDeclaration({
629
+ moduleSpecifier: 'path',
630
+ namedImports: ['join']
631
+ });
632
+ }
574
633
  // ─── Entry point ─────────────────────────────────────────────────────────────
575
634
  function main() {
576
635
  return __awaiter(this, void 0, void 0, function* () {
@@ -627,6 +686,7 @@ function main() {
627
686
  // Before removing, inline every cross-file reference to each unknown key.
628
687
  // Example: applicationConfig.BIRTH.LATE_REGISTRATION_TARGET → 45
629
688
  const filesToSaveAfterInlining = new Set();
689
+ const appConfigDir = path_1.default.dirname(appConfigAbsPath);
630
690
  for (const removedProp of propsToRemove) {
631
691
  const key = removedProp.getName();
632
692
  for (const sf of appConfigProject.getSourceFiles()) {
@@ -637,6 +697,12 @@ function main() {
637
697
  continue;
638
698
  if (sf.getFilePath().includes('/node_modules/'))
639
699
  continue;
700
+ // Relative path from the target file's directory back to the
701
+ // applicationConfig's directory. Used to adjust `__dirname`-based
702
+ // paths in the inlined value (e.g. image asset references) since
703
+ // those assets are not moved.
704
+ const targetDir = path_1.default.dirname(sf.getFilePath());
705
+ const relDirFromTarget = path_1.default.relative(targetDir, appConfigDir);
640
706
  // Break-and-restart after each replacement because replaceWithText()
641
707
  // invalidates existing node references in the ts-morph tree
642
708
  let madeReplacement = true;
@@ -664,8 +730,18 @@ function main() {
664
730
  console.log(` Cannot resolve applicationConfig.${accessPath.join('.')} — skipping inline replacement`);
665
731
  continue;
666
732
  }
667
- node.replaceWithText(resolvedValue);
668
- console.log(` Inlined applicationConfig.${accessPath.join('.')} → ${resolvedValue} in ${path_1.default.relative((0, _1.getCwd)(), sf.getFilePath())}`);
733
+ const adjustedValue = rewriteDirnameRefs(resolvedValue, relDirFromTarget);
734
+ node.replaceWithText(adjustedValue);
735
+ // If the inlined value references `fs` or `join`, ensure the
736
+ // target file has the corresponding imports — these are
737
+ // commonly used to read image assets from disk.
738
+ if (/\bfs\s*\./.test(adjustedValue)) {
739
+ ensureFsImport(sf);
740
+ }
741
+ if (/\bjoin\s*\(/.test(adjustedValue)) {
742
+ ensureJoinImport(sf);
743
+ }
744
+ console.log(` Inlined applicationConfig.${accessPath.join('.')} → ${adjustedValue} in ${path_1.default.relative((0, _1.getCwd)(), sf.getFilePath())}`);
669
745
  filesToSaveAfterInlining.add(sf);
670
746
  madeReplacement = true;
671
747
  break; // restart — tree has changed
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/index.ts"],"names":[],"mappings":"AAyBA,wBAAgB,MAAM,WAMrB;AAED;;;GAGG;AACH,wBAAsB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,iBAwBxD"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/index.ts"],"names":[],"mappings":"AA4BA,wBAAgB,MAAM,WAMrB;AAED;;;GAGG;AACH,wBAAsB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,iBA2BxD"}