@metriport/shared 0.36.0 → 0.36.2

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 (37) hide show
  1. package/dist/common/__tests__/uuid.test.d.ts +2 -0
  2. package/dist/common/__tests__/uuid.test.d.ts.map +1 -0
  3. package/dist/common/__tests__/uuid.test.js +51 -0
  4. package/dist/common/__tests__/uuid.test.js.map +1 -0
  5. package/dist/domain/message/internal-message-for-sender.d.ts +29 -0
  6. package/dist/domain/message/internal-message-for-sender.d.ts.map +1 -0
  7. package/dist/domain/message/internal-message-for-sender.js +26 -0
  8. package/dist/domain/message/internal-message-for-sender.js.map +1 -0
  9. package/dist/error/conflict.d.ts +5 -0
  10. package/dist/error/conflict.d.ts.map +1 -0
  11. package/dist/error/conflict.js +17 -0
  12. package/dist/error/conflict.js.map +1 -0
  13. package/dist/net/axios.d.ts +3 -0
  14. package/dist/net/axios.d.ts.map +1 -0
  15. package/dist/net/axios.js +21 -0
  16. package/dist/net/axios.js.map +1 -0
  17. package/dist/util/sqs-delay-from-uuid.d.ts +11 -0
  18. package/dist/util/sqs-delay-from-uuid.d.ts.map +1 -0
  19. package/dist/util/sqs-delay-from-uuid.js +21 -0
  20. package/dist/util/sqs-delay-from-uuid.js.map +1 -0
  21. package/package.json +2 -2
  22. package/dist/domain/__tests__/cohort-purpose-of-use-hies.test.d.ts +0 -2
  23. package/dist/domain/__tests__/cohort-purpose-of-use-hies.test.d.ts.map +0 -1
  24. package/dist/domain/__tests__/cohort-purpose-of-use-hies.test.js +0 -10
  25. package/dist/domain/__tests__/cohort-purpose-of-use-hies.test.js.map +0 -1
  26. package/dist/domain/__tests__/cohort-response-dto.test.d.ts +0 -2
  27. package/dist/domain/__tests__/cohort-response-dto.test.d.ts.map +0 -1
  28. package/dist/domain/__tests__/cohort-response-dto.test.js +0 -48
  29. package/dist/domain/__tests__/cohort-response-dto.test.js.map +0 -1
  30. package/dist/domain/cohort-purpose-of-use-hies.d.ts +0 -4
  31. package/dist/domain/cohort-purpose-of-use-hies.d.ts.map +0 -1
  32. package/dist/domain/cohort-purpose-of-use-hies.js +0 -15
  33. package/dist/domain/cohort-purpose-of-use-hies.js.map +0 -1
  34. package/dist/interface/internal/adt.d.ts +0 -1
  35. package/dist/interface/internal/adt.d.ts.map +0 -1
  36. package/dist/interface/internal/adt.js +0 -2
  37. package/dist/interface/internal/adt.js.map +0 -1
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=uuid.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"uuid.test.d.ts","sourceRoot":"","sources":["../../../src/common/__tests__/uuid.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const util_1 = require("../../util");
4
+ const sleep_1 = require("../sleep");
5
+ const uuid_1 = require("../uuid");
6
+ describe("pickLexicographicallyLatestUuid", () => {
7
+ it("returns undefined for an empty list", () => {
8
+ expect((0, uuid_1.pickLexicographicallyLatestUuid)([])).toBeUndefined();
9
+ });
10
+ it("returns undefined when every entry is null or undefined", () => {
11
+ expect((0, uuid_1.pickLexicographicallyLatestUuid)([undefined, null, undefined])).toBeUndefined();
12
+ });
13
+ it("returns the only UUID when there is one", () => {
14
+ const id = "0194a8c0-0000-7000-8000-000000000001";
15
+ expect((0, uuid_1.pickLexicographicallyLatestUuid)([id])).toBe(id);
16
+ });
17
+ it("returns the lexicographically greatest UUID", async () => {
18
+ const uuid1 = (0, util_1.uuidv7)();
19
+ await (0, sleep_1.sleep)(10);
20
+ const uuid2 = (0, util_1.uuidv7)();
21
+ await (0, sleep_1.sleep)(10);
22
+ const uuid3 = (0, util_1.uuidv7)();
23
+ expect((0, uuid_1.pickLexicographicallyLatestUuid)([uuid1, uuid2, uuid3])).toBe(uuid3);
24
+ });
25
+ it("returns the lexicographically greatest UUID", () => {
26
+ expect((0, uuid_1.pickLexicographicallyLatestUuid)([
27
+ "0194a8c0-0000-7000-8000-000000000001",
28
+ "0194a8c0-0000-7000-8000-000000000003",
29
+ "0194a8c0-0000-7000-8000-000000000002",
30
+ ])).toBe("0194a8c0-0000-7000-8000-000000000003");
31
+ });
32
+ it("is insensitive to input order", () => {
33
+ const a = "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa";
34
+ const b = "bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb";
35
+ expect((0, uuid_1.pickLexicographicallyLatestUuid)([a, b])).toBe(b);
36
+ expect((0, uuid_1.pickLexicographicallyLatestUuid)([b, a])).toBe(b);
37
+ });
38
+ it("deduplicates before picking", () => {
39
+ const id = "0194a8c0-0000-7000-8000-000000000001";
40
+ expect((0, uuid_1.pickLexicographicallyLatestUuid)([id, id, id])).toBe(id);
41
+ });
42
+ it("drops null and undefined entries", () => {
43
+ const id = "ffffffff-ffff-ffff-ffff-ffffffffffff";
44
+ expect((0, uuid_1.pickLexicographicallyLatestUuid)([undefined, id, null])).toBe(id);
45
+ });
46
+ it("keeps empty string as a candidate (not treated like missing)", () => {
47
+ expect((0, uuid_1.pickLexicographicallyLatestUuid)(["", "a"])).toBe("a");
48
+ expect((0, uuid_1.pickLexicographicallyLatestUuid)(["b", ""])).toBe("b");
49
+ });
50
+ });
51
+ //# sourceMappingURL=uuid.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"uuid.test.js","sourceRoot":"","sources":["../../../src/common/__tests__/uuid.test.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,29 @@
1
+ import { z } from "zod";
2
+ export declare const messageSenderAttachmentSchema: z.ZodObject<{
3
+ documentId: z.ZodString;
4
+ s3Key: z.ZodString;
5
+ mimeType: z.ZodString;
6
+ title: z.ZodOptional<z.ZodString>;
7
+ }, "strict", z.ZodTypeAny, {
8
+ mimeType: string;
9
+ documentId: string;
10
+ s3Key: string;
11
+ title?: string | undefined;
12
+ }, {
13
+ mimeType: string;
14
+ documentId: string;
15
+ s3Key: string;
16
+ title?: string | undefined;
17
+ }>;
18
+ export type MessageSenderAttachment = z.infer<typeof messageSenderAttachmentSchema>;
19
+ export declare const internalMessageForSenderSchema: any;
20
+ export type InternalMessageForSender = z.infer<typeof internalMessageForSenderSchema>;
21
+ export declare const internalMessageForSenderQuerySchema: z.ZodObject<{
22
+ cxId: z.ZodString;
23
+ }, "strict", z.ZodTypeAny, {
24
+ cxId: string;
25
+ }, {
26
+ cxId: string;
27
+ }>;
28
+ export type InternalMessageForSenderQuery = z.infer<typeof internalMessageForSenderQuerySchema>;
29
+ //# sourceMappingURL=internal-message-for-sender.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"internal-message-for-sender.d.ts","sourceRoot":"","sources":["../../../src/domain/message/internal-message-for-sender.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,eAAO,MAAM,6BAA6B;;;;;;;;;;;;;;;EAO/B,CAAC;AACZ,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,6BAA6B,CAAC,CAAC;AAEpF,eAAO,MAAM,8BAA8B,KAMhC,CAAC;AACZ,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,8BAA8B,CAAC,CAAC;AAEtF,eAAO,MAAM,mCAAmC;;;;;;EAIrC,CAAC;AACZ,MAAM,MAAM,6BAA6B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mCAAmC,CAAC,CAAC"}
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.internalMessageForSenderQuerySchema = exports.internalMessageForSenderSchema = exports.messageSenderAttachmentSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ const message_1 = require("./message");
6
+ exports.messageSenderAttachmentSchema = zod_1.z
7
+ .object({
8
+ documentId: zod_1.z.string().uuid(),
9
+ s3Key: zod_1.z.string().min(1),
10
+ mimeType: zod_1.z.string().min(1),
11
+ title: zod_1.z.string().min(1).optional(),
12
+ })
13
+ .strict();
14
+ exports.internalMessageForSenderSchema = message_1.messageSchema
15
+ .extend({
16
+ urlXdr: zod_1.z.string().url(),
17
+ destinationName: zod_1.z.string().min(1).optional(),
18
+ attachmentsForSender: zod_1.z.array(exports.messageSenderAttachmentSchema),
19
+ })
20
+ .strict();
21
+ exports.internalMessageForSenderQuerySchema = zod_1.z
22
+ .object({
23
+ cxId: zod_1.z.string().uuid(),
24
+ })
25
+ .strict();
26
+ //# sourceMappingURL=internal-message-for-sender.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"internal-message-for-sender.js","sourceRoot":"","sources":["../../../src/domain/message/internal-message-for-sender.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AACxB,uCAA0C;AAE7B,QAAA,6BAA6B,GAAG,OAAC;KAC3C,MAAM,CAAC;IACN,UAAU,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE;IAC7B,KAAK,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACxB,QAAQ,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC3B,KAAK,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;CACpC,CAAC;KACD,MAAM,EAAE,CAAC;AAGC,QAAA,8BAA8B,GAAG,uBAAa;KACxD,MAAM,CAAC;IACN,MAAM,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE;IACxB,eAAe,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;IAC7C,oBAAoB,EAAE,OAAC,CAAC,KAAK,CAAC,qCAA6B,CAAC;CAC7D,CAAC;KACD,MAAM,EAAE,CAAC;AAGC,QAAA,mCAAmC,GAAG,OAAC;KACjD,MAAM,CAAC;IACN,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE;CACxB,CAAC;KACD,MAAM,EAAE,CAAC"}
@@ -0,0 +1,5 @@
1
+ import { AdditionalInfo, MetriportError } from "./metriport-error";
2
+ export declare class ConflictError extends MetriportError {
3
+ constructor(message?: string, cause?: unknown, additionalInfo?: AdditionalInfo);
4
+ }
5
+ //# sourceMappingURL=conflict.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"conflict.d.ts","sourceRoot":"","sources":["../../src/error/conflict.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnE,qBAAa,aAAc,SAAQ,cAAc;gBAE7C,OAAO,SAAkE,EACzE,KAAK,CAAC,EAAE,OAAO,EACf,cAAc,CAAC,EAAE,cAAc;CAMlC"}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.ConflictError = void 0;
7
+ const http_status_1 = __importDefault(require("http-status"));
8
+ const metriport_error_1 = require("./metriport-error");
9
+ class ConflictError extends metriport_error_1.MetriportError {
10
+ constructor(message = "The request conflicts with the current state of the resource.", cause, additionalInfo) {
11
+ super(message, cause, additionalInfo);
12
+ this.status = http_status_1.default.CONFLICT;
13
+ this.name = this.constructor.name;
14
+ }
15
+ }
16
+ exports.ConflictError = ConflictError;
17
+ //# sourceMappingURL=conflict.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"conflict.js","sourceRoot":"","sources":["../../src/error/conflict.ts"],"names":[],"mappings":";;;;;;AAAA,8DAAqC;AACrC,uDAAmE;AAEnE,MAAa,aAAc,SAAQ,gCAAc;IAC/C,YACE,OAAO,GAAG,+DAA+D,EACzE,KAAe,EACf,cAA+B;QAE/B,KAAK,CAAC,OAAO,EAAE,KAAK,EAAE,cAAc,CAAC,CAAC;QACtC,IAAI,CAAC,MAAM,GAAG,qBAAU,CAAC,QAAQ,CAAC;QAClC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC;IACpC,CAAC;CACF;AAVD,sCAUC"}
@@ -0,0 +1,3 @@
1
+ import { AxiosInstance, CreateAxiosDefaults } from "axios";
2
+ export declare function makeAxiosInstance(config?: Partial<CreateAxiosDefaults>): AxiosInstance;
3
+ //# sourceMappingURL=axios.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"axios.d.ts","sourceRoot":"","sources":["../../src/net/axios.ts"],"names":[],"mappings":"AAAA,OAAc,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,OAAO,CAAC;AAMlE,wBAAgB,iBAAiB,CAAC,MAAM,GAAE,OAAO,CAAC,mBAAmB,CAAM,GAAG,aAAa,CAQ1F"}
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.makeAxiosInstance = void 0;
7
+ const axios_1 = __importDefault(require("axios"));
8
+ const http_1 = __importDefault(require("http"));
9
+ const https_1 = __importDefault(require("https"));
10
+ const isLocalDevelopment = process.env["NODE_ENV"] !== "production";
11
+ function makeAxiosInstance(config = {}) {
12
+ const defaults = {};
13
+ if (isLocalDevelopment) {
14
+ // Fix IPv4 only by default so we don't get errors on local development from Axios trying to use IPv6.
15
+ defaults.httpAgent = new http_1.default.Agent({ family: 4 });
16
+ defaults.httpsAgent = new https_1.default.Agent({ family: 4 });
17
+ }
18
+ return axios_1.default.create({ ...defaults, ...config });
19
+ }
20
+ exports.makeAxiosInstance = makeAxiosInstance;
21
+ //# sourceMappingURL=axios.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"axios.js","sourceRoot":"","sources":["../../src/net/axios.ts"],"names":[],"mappings":";;;;;;AAAA,kDAAkE;AAClE,gDAAwB;AACxB,kDAA0B;AAE1B,MAAM,kBAAkB,GAAG,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,KAAK,YAAY,CAAC;AAEpE,SAAgB,iBAAiB,CAAC,SAAuC,EAAE;IACzE,MAAM,QAAQ,GAAiC,EAAE,CAAC;IAClD,IAAI,kBAAkB,EAAE;QACtB,sGAAsG;QACtG,QAAQ,CAAC,SAAS,GAAG,IAAI,cAAI,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC,CAAC;QACnD,QAAQ,CAAC,UAAU,GAAG,IAAI,eAAK,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC,CAAC;KACtD;IACD,OAAO,eAAK,CAAC,MAAM,CAAC,EAAE,GAAG,QAAQ,EAAE,GAAG,MAAM,EAAE,CAAC,CAAC;AAClD,CAAC;AARD,8CAQC"}
@@ -0,0 +1,11 @@
1
+ /** SQS max delivery delay is 15 minutes (900 seconds). Delay must not exceed this. */
2
+ export declare const SQS_MAX_DELAY_SECONDS = 900;
3
+ /**
4
+ * Maps a string (e.g. cxId or UUID v4) to a delivery delay in seconds for SQS,
5
+ * evenly distributed across 0 to 15 minutes (max). Same input always gets the same delay (deterministic).
6
+ *
7
+ * @param id - Any string identifier (e.g. cxId, UUID v4)
8
+ * @returns Delay in seconds in [0, 900] (≤ 15 min, SQS max)
9
+ */
10
+ export declare function uuidToDelaySeconds(id: string, maxDelaySeconds?: number): number;
11
+ //# sourceMappingURL=sqs-delay-from-uuid.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sqs-delay-from-uuid.d.ts","sourceRoot":"","sources":["../../src/util/sqs-delay-from-uuid.ts"],"names":[],"mappings":"AAEA,sFAAsF;AACtF,eAAO,MAAM,qBAAqB,MAAM,CAAC;AAEzC;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAChC,EAAE,EAAE,MAAM,EACV,eAAe,GAAE,MAA8B,GAC9C,MAAM,CAKR"}
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SQS_MAX_DELAY_SECONDS = void 0;
4
+ exports.uuidToDelaySeconds = uuidToDelaySeconds;
5
+ const node_crypto_1 = require("node:crypto");
6
+ /** SQS max delivery delay is 15 minutes (900 seconds). Delay must not exceed this. */
7
+ exports.SQS_MAX_DELAY_SECONDS = 900;
8
+ /**
9
+ * Maps a string (e.g. cxId or UUID v4) to a delivery delay in seconds for SQS,
10
+ * evenly distributed across 0 to 15 minutes (max). Same input always gets the same delay (deterministic).
11
+ *
12
+ * @param id - Any string identifier (e.g. cxId, UUID v4)
13
+ * @returns Delay in seconds in [0, 900] (≤ 15 min, SQS max)
14
+ */
15
+ function uuidToDelaySeconds(id, maxDelaySeconds = exports.SQS_MAX_DELAY_SECONDS) {
16
+ const BUCKET_COUNT = maxDelaySeconds + 1; // maxDelaySeconds + 1 → 0..maxDelaySeconds
17
+ const hash = (0, node_crypto_1.createHash)("sha256").update(id, "utf8").digest();
18
+ const value = hash.readUInt32BE(0) * 0x100000000 + hash.readUInt32BE(4);
19
+ return value % BUCKET_COUNT; // always in [0, maxDelaySeconds]
20
+ }
21
+ //# sourceMappingURL=sqs-delay-from-uuid.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sqs-delay-from-uuid.js","sourceRoot":"","sources":["../../src/util/sqs-delay-from-uuid.ts"],"names":[],"mappings":";;;AAYA,gDAQC;AApBD,6CAAyC;AAEzC,sFAAsF;AACzE,QAAA,qBAAqB,GAAG,GAAG,CAAC;AAEzC;;;;;;GAMG;AACH,SAAgB,kBAAkB,CAChC,EAAU,EACV,kBAA0B,6BAAqB;IAE/C,MAAM,YAAY,GAAG,eAAe,GAAG,CAAC,CAAC,CAAC,2CAA2C;IACrF,MAAM,IAAI,GAAG,IAAA,wBAAU,EAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC,MAAM,EAAE,CAAC;IAC9D,MAAM,KAAK,GAAG,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,GAAG,WAAW,GAAG,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;IACxE,OAAO,KAAK,GAAG,YAAY,CAAC,CAAC,iCAAiC;AAChE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metriport/shared",
3
- "version": "0.36.0",
3
+ "version": "0.36.2",
4
4
  "description": "Common code shared across packages - by Metriport Inc.",
5
5
  "author": "Metriport Inc. <contact@metriport.com>",
6
6
  "homepage": "https://metriport.com/",
@@ -172,5 +172,5 @@
172
172
  "ts-jest": "29.4.11",
173
173
  "typescript": "6.0.3"
174
174
  },
175
- "gitHead": "2aad09ef93c15f1cffc5557ed2e39d010094eee7"
175
+ "gitHead": "7314dafc57bf98da496ddc903b0bc0192f6cd3c2"
176
176
  }
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=cohort-purpose-of-use-hies.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"cohort-purpose-of-use-hies.test.d.ts","sourceRoot":"","sources":["../../../src/domain/__tests__/cohort-purpose-of-use-hies.test.ts"],"names":[],"mappings":""}
@@ -1,10 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const constants_1 = require("../../external/hl7v2/constants");
4
- const cohort_purpose_of_use_hies_1 = require("../cohort-purpose-of-use-hies");
5
- describe("cohort-purpose-of-use-hies", () => {
6
- it("defines ops ADT HIE allowlist", () => {
7
- expect(cohort_purpose_of_use_hies_1.OPS_ADT_HIE_NAMES).toEqual([constants_1.HieName.Bamboo, constants_1.HieName.Riqi, constants_1.HieName.Pcc, constants_1.HieName.Konza]);
8
- });
9
- });
10
- //# sourceMappingURL=cohort-purpose-of-use-hies.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"cohort-purpose-of-use-hies.test.js","sourceRoot":"","sources":["../../../src/domain/__tests__/cohort-purpose-of-use-hies.test.ts"],"names":[],"mappings":";;AAAA,8DAAyD;AACzD,8EAAkE;AAElE,QAAQ,CAAC,4BAA4B,EAAE,GAAG,EAAE;IAC1C,EAAE,CAAC,+BAA+B,EAAE,GAAG,EAAE;QACvC,MAAM,CAAC,8CAAiB,CAAC,CAAC,OAAO,CAAC,CAAC,mBAAO,CAAC,MAAM,EAAE,mBAAO,CAAC,IAAI,EAAE,mBAAO,CAAC,GAAG,EAAE,mBAAO,CAAC,KAAK,CAAC,CAAC,CAAC;IAChG,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=cohort-response-dto.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"cohort-response-dto.test.d.ts","sourceRoot":"","sources":["../../../src/domain/__tests__/cohort-response-dto.test.ts"],"names":[],"mappings":""}
@@ -1,48 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const cohort_1 = require("../cohort");
4
- const now = new Date("2024-01-01T12:00:00Z");
5
- const cohortBase = {
6
- id: "cohort-id",
7
- eTag: "1",
8
- cxId: "cx-id",
9
- name: "Test Cohort",
10
- color: "red",
11
- description: "Test description",
12
- createdAt: now,
13
- updatedAt: now,
14
- };
15
- describe("resolveCohortPurposeOfUseForResponse", () => {
16
- it("returns explicit purposeOfUse when set", () => {
17
- expect((0, cohort_1.resolveCohortPurposeOfUseForResponse)("operations")).toBe("operations");
18
- });
19
- it("defaults to treatment when purposeOfUse is missing", () => {
20
- expect((0, cohort_1.resolveCohortPurposeOfUseForResponse)(undefined)).toBe("treatment");
21
- });
22
- });
23
- describe("responseDtoFromCohort", () => {
24
- it("includes purposeOfUse when set on domain cohort", () => {
25
- const response = (0, cohort_1.responseDtoFromCohort)({
26
- ...cohortBase,
27
- purposeOfUse: "operations",
28
- settings: {
29
- monitoring: cohort_1.DEFAULT_MONITORING,
30
- overrides: cohort_1.DEFAULT_OVERRIDES,
31
- },
32
- });
33
- expect(response.purposeOfUse).toBe("operations");
34
- expect(response.settings.monitoring).toEqual(cohort_1.DEFAULT_MONITORING);
35
- });
36
- it("strips overrides from public response", () => {
37
- const response = (0, cohort_1.responseDtoFromCohort)({
38
- ...cohortBase,
39
- purposeOfUse: "treatment",
40
- settings: {
41
- monitoring: cohort_1.DEFAULT_MONITORING,
42
- overrides: { [cohort_1.STATE_VALIDATION_OVERRIDE_KEY]: true },
43
- },
44
- });
45
- expect(response.settings).not.toHaveProperty("overrides");
46
- });
47
- });
48
- //# sourceMappingURL=cohort-response-dto.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"cohort-response-dto.test.js","sourceRoot":"","sources":["../../../src/domain/__tests__/cohort-response-dto.test.ts"],"names":[],"mappings":";;AAAA,sCAMmB;AAEnB,MAAM,GAAG,GAAG,IAAI,IAAI,CAAC,sBAAsB,CAAC,CAAC;AAE7C,MAAM,UAAU,GAAG;IACjB,EAAE,EAAE,WAAW;IACf,IAAI,EAAE,GAAG;IACT,IAAI,EAAE,OAAO;IACb,IAAI,EAAE,aAAa;IACnB,KAAK,EAAE,KAAc;IACrB,WAAW,EAAE,kBAAkB;IAC/B,SAAS,EAAE,GAAG;IACd,SAAS,EAAE,GAAG;CACf,CAAC;AAEF,QAAQ,CAAC,sCAAsC,EAAE,GAAG,EAAE;IACpD,EAAE,CAAC,wCAAwC,EAAE,GAAG,EAAE;QAChD,MAAM,CAAC,IAAA,6CAAoC,EAAC,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IAChF,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,oDAAoD,EAAE,GAAG,EAAE;QAC5D,MAAM,CAAC,IAAA,6CAAoC,EAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IAC5E,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,QAAQ,CAAC,uBAAuB,EAAE,GAAG,EAAE;IACrC,EAAE,CAAC,iDAAiD,EAAE,GAAG,EAAE;QACzD,MAAM,QAAQ,GAAG,IAAA,8BAAqB,EAAC;YACrC,GAAG,UAAU;YACb,YAAY,EAAE,YAAY;YAC1B,QAAQ,EAAE;gBACR,UAAU,EAAE,2BAAkB;gBAC9B,SAAS,EAAE,0BAAiB;aAC7B;SACF,CAAC,CAAC;QAEH,MAAM,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QACjD,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,2BAAkB,CAAC,CAAC;IACnE,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,uCAAuC,EAAE,GAAG,EAAE;QAC/C,MAAM,QAAQ,GAAG,IAAA,8BAAqB,EAAC;YACrC,GAAG,UAAU;YACb,YAAY,EAAE,WAAW;YACzB,QAAQ,EAAE;gBACR,UAAU,EAAE,2BAAkB;gBAC9B,SAAS,EAAE,EAAE,CAAC,sCAA6B,CAAC,EAAE,IAAI,EAAE;aACrD;SACF,CAAC,CAAC;QAEH,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC;IAC5D,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -1,4 +0,0 @@
1
- import { HieName } from "../external/hl7v2/constants";
2
- export declare const operationsAllowedHies: readonly HieName[];
3
- export declare function isOperationsAllowedAdtHie(hieName: string): boolean;
4
- //# sourceMappingURL=cohort-purpose-of-use-hies.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"cohort-purpose-of-use-hies.d.ts","sourceRoot":"","sources":["../../src/domain/cohort-purpose-of-use-hies.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAEtD,eAAO,MAAM,qBAAqB,EAAE,SAAS,OAAO,EAKnD,CAAC;AAEF,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAElE"}
@@ -1,15 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.operationsAllowedHies = void 0;
4
- exports.isOperationsAllowedAdtHie = isOperationsAllowedAdtHie;
5
- const constants_1 = require("../external/hl7v2/constants");
6
- exports.operationsAllowedHies = [
7
- constants_1.HieName.Bamboo,
8
- constants_1.HieName.Riqi,
9
- constants_1.HieName.Pcc,
10
- constants_1.HieName.Konza,
11
- ];
12
- function isOperationsAllowedAdtHie(hieName) {
13
- return exports.operationsAllowedHies.includes(hieName);
14
- }
15
- //# sourceMappingURL=cohort-purpose-of-use-hies.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"cohort-purpose-of-use-hies.js","sourceRoot":"","sources":["../../src/domain/cohort-purpose-of-use-hies.ts"],"names":[],"mappings":";;;AASA,8DAEC;AAXD,2DAAsD;AAEzC,QAAA,qBAAqB,GAAuB;IACvD,mBAAO,CAAC,MAAM;IACd,mBAAO,CAAC,IAAI;IACZ,mBAAO,CAAC,GAAG;IACX,mBAAO,CAAC,KAAK;CACd,CAAC;AAEF,SAAgB,yBAAyB,CAAC,OAAe;IACvD,OAAO,6BAAqB,CAAC,QAAQ,CAAC,OAAkB,CAAC,CAAC;AAC5D,CAAC"}
@@ -1 +0,0 @@
1
- //# sourceMappingURL=adt.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"adt.d.ts","sourceRoot":"","sources":["../../../src/interface/internal/adt.ts"],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
- "use strict";
2
- //# sourceMappingURL=adt.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"adt.js","sourceRoot":"","sources":["../../../src/interface/internal/adt.ts"],"names":[],"mappings":""}