grm-shared-library 1.1.192 → 1.1.194

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 (68) hide show
  1. package/dist/cjs/index.js +2 -0
  2. package/dist/cjs/index.js.map +1 -1
  3. package/dist/cjs/modules/alert-dispatch/enums/incident-dispatch-scope.enum.js +27 -0
  4. package/dist/cjs/modules/alert-dispatch/enums/incident-dispatch-scope.enum.js.map +1 -0
  5. package/dist/cjs/modules/alert-dispatch/index.js +23 -0
  6. package/dist/cjs/modules/alert-dispatch/index.js.map +1 -0
  7. package/dist/cjs/modules/alert-dispatch/interfaces/alert-dispatch.js +3 -0
  8. package/dist/cjs/modules/alert-dispatch/interfaces/alert-dispatch.js.map +1 -0
  9. package/dist/cjs/modules/alert-dispatch/utils/alert-dispatch.util.js +86 -0
  10. package/dist/cjs/modules/alert-dispatch/utils/alert-dispatch.util.js.map +1 -0
  11. package/dist/cjs/modules/incident/dtos/incident/create-incident.dto.js +18 -0
  12. package/dist/cjs/modules/incident/dtos/incident/create-incident.dto.js.map +1 -1
  13. package/dist/cjs/modules/incident/dtos/incident/incident.dto.js +11 -0
  14. package/dist/cjs/modules/incident/dtos/incident/incident.dto.js.map +1 -1
  15. package/dist/cjs/modules/system-user/constants/system-user.const.js +31 -0
  16. package/dist/cjs/modules/system-user/constants/system-user.const.js.map +1 -0
  17. package/dist/cjs/modules/system-user/index.js +27 -0
  18. package/dist/cjs/modules/system-user/index.js.map +1 -0
  19. package/dist/cjs/modules/system-user/interfaces/system-user-env-source.js +3 -0
  20. package/dist/cjs/modules/system-user/interfaces/system-user-env-source.js.map +1 -0
  21. package/dist/cjs/modules/system-user/services/system-user.service.js +60 -0
  22. package/dist/cjs/modules/system-user/services/system-user.service.js.map +1 -0
  23. package/dist/cjs/modules/system-user/system-user.module.js +33 -0
  24. package/dist/cjs/modules/system-user/system-user.module.js.map +1 -0
  25. package/dist/cjs/modules/system-user/utils/system-user.util.js +57 -0
  26. package/dist/cjs/modules/system-user/utils/system-user.util.js.map +1 -0
  27. package/dist/esm/index.js +2 -0
  28. package/dist/esm/index.js.map +1 -1
  29. package/dist/esm/modules/alert-dispatch/enums/incident-dispatch-scope.enum.js +24 -0
  30. package/dist/esm/modules/alert-dispatch/enums/incident-dispatch-scope.enum.js.map +1 -0
  31. package/dist/esm/modules/alert-dispatch/index.js +7 -0
  32. package/dist/esm/modules/alert-dispatch/index.js.map +1 -0
  33. package/dist/esm/modules/alert-dispatch/interfaces/alert-dispatch.js +2 -0
  34. package/dist/esm/modules/alert-dispatch/interfaces/alert-dispatch.js.map +1 -0
  35. package/dist/esm/modules/alert-dispatch/utils/alert-dispatch.util.js +78 -0
  36. package/dist/esm/modules/alert-dispatch/utils/alert-dispatch.util.js.map +1 -0
  37. package/dist/esm/modules/incident/dtos/incident/create-incident.dto.js +18 -0
  38. package/dist/esm/modules/incident/dtos/incident/create-incident.dto.js.map +1 -1
  39. package/dist/esm/modules/incident/dtos/incident/incident.dto.js +12 -1
  40. package/dist/esm/modules/incident/dtos/incident/incident.dto.js.map +1 -1
  41. package/dist/esm/modules/system-user/constants/system-user.const.js +28 -0
  42. package/dist/esm/modules/system-user/constants/system-user.const.js.map +1 -0
  43. package/dist/esm/modules/system-user/index.js +11 -0
  44. package/dist/esm/modules/system-user/index.js.map +1 -0
  45. package/dist/esm/modules/system-user/interfaces/system-user-env-source.js +2 -0
  46. package/dist/esm/modules/system-user/interfaces/system-user-env-source.js.map +1 -0
  47. package/dist/esm/modules/system-user/services/system-user.service.js +57 -0
  48. package/dist/esm/modules/system-user/services/system-user.service.js.map +1 -0
  49. package/dist/esm/modules/system-user/system-user.module.js +30 -0
  50. package/dist/esm/modules/system-user/system-user.module.js.map +1 -0
  51. package/dist/esm/modules/system-user/utils/system-user.util.js +53 -0
  52. package/dist/esm/modules/system-user/utils/system-user.util.js.map +1 -0
  53. package/dist/types/index.d.ts +2 -0
  54. package/dist/types/interfaces/pagination.d.ts +8 -0
  55. package/dist/types/modules/alert-dispatch/enums/incident-dispatch-scope.enum.d.ts +22 -0
  56. package/dist/types/modules/alert-dispatch/index.d.ts +3 -0
  57. package/dist/types/modules/alert-dispatch/interfaces/alert-dispatch.d.ts +33 -0
  58. package/dist/types/modules/alert-dispatch/utils/alert-dispatch.util.d.ts +51 -0
  59. package/dist/types/modules/incident/dtos/incident/create-incident.dto.d.ts +14 -0
  60. package/dist/types/modules/incident/dtos/incident/incident.dto.d.ts +8 -0
  61. package/dist/types/modules/incident/intefaces/incident.d.ts +9 -0
  62. package/dist/types/modules/system-user/constants/system-user.const.d.ts +24 -0
  63. package/dist/types/modules/system-user/index.d.ts +5 -0
  64. package/dist/types/modules/system-user/interfaces/system-user-env-source.d.ts +10 -0
  65. package/dist/types/modules/system-user/services/system-user.service.d.ts +26 -0
  66. package/dist/types/modules/system-user/system-user.module.d.ts +13 -0
  67. package/dist/types/modules/system-user/utils/system-user.util.d.ts +41 -0
  68. package/package.json +5 -3
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Minimal read surface needed to resolve the system user id.
3
+ *
4
+ * Structurally satisfied by `ConfigService` from `@nestjs/config`, so callers
5
+ * can pass their existing config service straight through without the shared
6
+ * library taking a hard dependency on it.
7
+ */
8
+ export interface SystemUserEnvSource {
9
+ get<T = string>(key: string): T | undefined;
10
+ }
@@ -0,0 +1,26 @@
1
+ import { OnModuleInit } from '@nestjs/common';
2
+ import { ConfigService } from '@nestjs/config';
3
+ /**
4
+ * Single source of truth for the platform system user id inside a service.
5
+ *
6
+ * Resolution happens once, on module init, so a mis-set `SYSTEM_USER_ID`
7
+ * fails the pod's startup probe instead of surfacing later as records stamped
8
+ * with a user id that clarion-authentication cannot resolve.
9
+ *
10
+ * @example
11
+ * constructor(private readonly systemUser: SystemUserService) {}
12
+ * ...
13
+ * const actorId = userContext?.userId ?? this.systemUser.id;
14
+ */
15
+ export declare class SystemUserService implements OnModuleInit {
16
+ private readonly configService;
17
+ private readonly logger;
18
+ private resolvedId;
19
+ constructor(configService: ConfigService);
20
+ onModuleInit(): void;
21
+ /**
22
+ * The system user id. Throws if read before module init completed, which
23
+ * only happens if a provider resolves it inside its own constructor.
24
+ */
25
+ get id(): number;
26
+ }
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Global module exposing {@link SystemUserService} to every provider in the
3
+ * host application. Import once in the service's root `AppModule`:
4
+ *
5
+ * @example
6
+ * @Module({ imports: [ConfigModule.forRoot({ ... }), SystemUserModule] })
7
+ * export class AppModule {}
8
+ *
9
+ * Requires `ConfigModule` to be global (the convention across clarion
10
+ * services) or otherwise available where this module is imported.
11
+ */
12
+ export declare class SystemUserModule {
13
+ }
@@ -0,0 +1,41 @@
1
+ import { SystemUserEnvSource } from '../interfaces/system-user-env-source';
2
+ export interface ResolveSystemUserIdOptions {
3
+ /**
4
+ * Deprecated keys to fall back to, in order, when the canonical key is
5
+ * unset. Defaults to {@link LEGACY_SYSTEM_USER_ID_ENV_KEYS}; pass `[]` to
6
+ * disable legacy support entirely.
7
+ */
8
+ legacyKeys?: readonly string[];
9
+ /**
10
+ * Value to return when nothing resolves, instead of throwing. Use only
11
+ * where a missing system user must not stop the process from booting.
12
+ */
13
+ fallback?: number;
14
+ /**
15
+ * Invoked once per legacy-key hit so the service can surface the
16
+ * deprecation in its own logger.
17
+ */
18
+ onLegacyKeyUsed?: (key: string) => void;
19
+ }
20
+ /**
21
+ * Parses a raw environment value into a usable user id.
22
+ *
23
+ * Returns `null` for anything that is not a positive integer — including
24
+ * `'0'`, `'-1'`, `'abc'` and the empty string — so that a typo'd ConfigMap
25
+ * entry surfaces as a clear failure rather than silently stamping user `0`
26
+ * onto production records.
27
+ */
28
+ export declare function parseSystemUserId(raw: unknown): number | null;
29
+ /**
30
+ * Resolves the platform system user id from the environment.
31
+ *
32
+ * Precedence: {@link SYSTEM_USER_ID_ENV_KEY} → each legacy key in order →
33
+ * `options.fallback`. Throws when nothing resolves and no fallback is given,
34
+ * which is the intended behaviour at startup: a service that stamps records
35
+ * with the system user should refuse to boot rather than write a wrong id.
36
+ *
37
+ * @example
38
+ * // In a Nest provider that already injects ConfigService:
39
+ * this.systemUserId = resolveSystemUserId(this.configService);
40
+ */
41
+ export declare function resolveSystemUserId(source: SystemUserEnvSource, options?: ResolveSystemUserIdOptions): number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "grm-shared-library",
3
- "version": "1.1.192",
3
+ "version": "1.1.194",
4
4
  "main": "dist/cjs/index.js",
5
5
  "module": "dist/esm/index.js",
6
6
  "types": "dist/types/index.d.ts",
@@ -57,7 +57,8 @@
57
57
  "grm-shared-library": "^1.1.101",
58
58
  "libphonenumber-js": "^1.13.8",
59
59
  "rxjs": "^7.8.2",
60
- "swagger-ui-express": "^5.0.1"
60
+ "swagger-ui-express": "^5.0.1",
61
+ "@nestjs/config": "^4.0.0"
61
62
  },
62
63
  "peerDependencies": {
63
64
  "@nestjs/common": "^11.0.0",
@@ -65,6 +66,7 @@
65
66
  "@nestjs/microservices": "^11.0.0",
66
67
  "@sentry/node": "^8.0.0",
67
68
  "class-transformer": "^0.5.0",
68
- "class-validator": "^0.14.0"
69
+ "class-validator": "^0.14.0",
70
+ "@nestjs/config": "^4.0.0"
69
71
  }
70
72
  }