@awell-health/awell-extensions 2.1.40 → 2.1.42

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 (35) hide show
  1. package/dist/extensions/bland/actions/sendCall/sendCall.js +1 -1
  2. package/dist/extensions/bland/actions/sendCall/sendCall.js.map +1 -1
  3. package/dist/extensions/bland/actions/sendCallWithPathway/sendCallWithPathway.js +1 -1
  4. package/dist/extensions/bland/actions/sendCallWithPathway/sendCallWithPathway.js.map +1 -1
  5. package/dist/extensions/shelly/actions/index.d.ts +30 -0
  6. package/dist/extensions/shelly/actions/index.js +2 -0
  7. package/dist/extensions/shelly/actions/index.js.map +1 -1
  8. package/dist/extensions/shelly/actions/parseStructuredData/config/datapoints.d.ts +14 -0
  9. package/dist/extensions/shelly/actions/parseStructuredData/config/datapoints.js +18 -0
  10. package/dist/extensions/shelly/actions/parseStructuredData/config/datapoints.js.map +1 -0
  11. package/dist/extensions/shelly/actions/parseStructuredData/config/fields.d.ts +48 -0
  12. package/dist/extensions/shelly/actions/parseStructuredData/config/fields.js +74 -0
  13. package/dist/extensions/shelly/actions/parseStructuredData/config/fields.js.map +1 -0
  14. package/dist/extensions/shelly/actions/parseStructuredData/config/index.d.ts +2 -0
  15. package/dist/extensions/shelly/actions/parseStructuredData/config/index.js +9 -0
  16. package/dist/extensions/shelly/actions/parseStructuredData/config/index.js.map +1 -0
  17. package/dist/extensions/shelly/actions/parseStructuredData/index.d.ts +1 -0
  18. package/dist/extensions/shelly/actions/parseStructuredData/index.js +6 -0
  19. package/dist/extensions/shelly/actions/parseStructuredData/index.js.map +1 -0
  20. package/dist/extensions/shelly/actions/parseStructuredData/lib/parseStructuredDataWithLLM/index.d.ts +1 -0
  21. package/dist/extensions/shelly/actions/parseStructuredData/lib/parseStructuredDataWithLLM/index.js +6 -0
  22. package/dist/extensions/shelly/actions/parseStructuredData/lib/parseStructuredDataWithLLM/index.js.map +1 -0
  23. package/dist/extensions/shelly/actions/parseStructuredData/lib/parseStructuredDataWithLLM/parseStructuredDataWithLLM.d.ts +35 -0
  24. package/dist/extensions/shelly/actions/parseStructuredData/lib/parseStructuredDataWithLLM/parseStructuredDataWithLLM.js +52 -0
  25. package/dist/extensions/shelly/actions/parseStructuredData/lib/parseStructuredDataWithLLM/parseStructuredDataWithLLM.js.map +1 -0
  26. package/dist/extensions/shelly/actions/parseStructuredData/lib/parseStructuredDataWithLLM/parser.d.ts +24 -0
  27. package/dist/extensions/shelly/actions/parseStructuredData/lib/parseStructuredDataWithLLM/parser.js +28 -0
  28. package/dist/extensions/shelly/actions/parseStructuredData/lib/parseStructuredDataWithLLM/parser.js.map +1 -0
  29. package/dist/extensions/shelly/actions/parseStructuredData/lib/parseStructuredDataWithLLM/prompt.d.ts +14 -0
  30. package/dist/extensions/shelly/actions/parseStructuredData/lib/parseStructuredDataWithLLM/prompt.js +51 -0
  31. package/dist/extensions/shelly/actions/parseStructuredData/lib/parseStructuredDataWithLLM/prompt.js.map +1 -0
  32. package/dist/extensions/shelly/actions/parseStructuredData/parseStructuredData.d.ts +13 -0
  33. package/dist/extensions/shelly/actions/parseStructuredData/parseStructuredData.js +78 -0
  34. package/dist/extensions/shelly/actions/parseStructuredData/parseStructuredData.js.map +1 -0
  35. package/package.json +1 -1
@@ -30,9 +30,9 @@ exports.sendCall = {
30
30
  // otherData helps us to pass in fields that are not part of the SendCallInputSchema,
31
31
  // given bland's schema is updating quickly
32
32
  const sendCallInput = schema_1.SendCallInputSchema.parse({
33
- ...otherData,
34
33
  ...fields,
35
34
  webhook: getWebhookUrl(),
35
+ ...otherData, // there can be a 'webhook' field in this otherData object, it needs to be able to override the webhook from the fields object
36
36
  phone_number: fields.phoneNumber,
37
37
  request_data: fields.requestData,
38
38
  metadata: {
@@ -1 +1 @@
1
- {"version":3,"file":"sendCall.js","sourceRoot":"","sources":["../../../../../extensions/bland/actions/sendCall/sendCall.ts"],"names":[],"mappings":";;;AACA,mEAAwD;AACxD,uFAAmF;A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AAO,CAAC,OAAO,CAAC,EAAE;gBACtC,iBAAiB,EAAE,OAAO,CAAC,QAAQ,CAAC,EAAE;aACvC;YACD,eAAe,EAAE,MAAM,CAAC,cAAc;SACvC,CAAC,CAAA;QAEF,IAAI,CAAC;YACH,GAAG,CAAC,EAAE,aAAa,EAAE,EAAE,uBAAuB,CAAC,CAAA;QACjD,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,OAAO,CAAC,KAAK,CAAC,+BAA+B,CAAC,CAAA;YAC9C,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAA;QACpC,CAAC;QACD,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,QAAQ,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAA;QAEvD;;;WAGG;QACH,IAAI,SAAS,CAAC,8BAA8B,EAAE,CAAC;YAC7C,OAAM;QACR,CAAC;QAED,MAAM,UAAU,CAAC;YACf,WAAW,EAAE;gBACX,OAAO,EAAE,IAAI,CAAC,OAAO;aACtB;YACD,MAAM,EAAE;gBACN,IAAA,iCAAmB,EAAC;oBAClB,OAAO,EAAE,4CAA4C,IAAI,CAAC,MAAM,cAAc,IAAI,CAAC,OAAO,cAAc,IAAI,CAAC,OAAO,EAAE;iBACvH,CAAC;aACH;SACF,CAAC,CAAA;IACJ,CAAC;CACF,CAAA"}
1
+ {"version":3,"file":"sendCall.js","sourceRoot":"","sources":["../../../../../extensions/bland/actions/sendCall/sendCall.ts"],"names":[],"mappings":";;;AACA,mEAAwD;AACxD,uFAAmF;AAEnF,qCAAqE;AACrE,6CAAsD;AACtD,uEAA2E;AAE9D,QAAA,QAAQ,GAIjB;IACF,GAAG,EAAE,UAAU;IACf,QAAQ,EAAE,0BAAQ,CAAC,aAAa;IAChC,KAAK,EAAE,WAAW;IAClB,WAAW,EAAE,4DAA4D;IACzE,MAAM,EAAN,eAAM;IACN,WAAW,EAAE,KAAK;IAClB,UAAU,EAAV,mBAAU;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AAO,GAAG,EAAE,CAAC;YACb,OAAO,CAAC,KAAK,CAAC,+BAA+B,CAAC,CAAA;YAC9C,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAA;QACpC,CAAC;QACD,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,QAAQ,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAA;QAEvD;;;WAGG;QACH,IAAI,SAAS,CAAC,8BAA8B,EAAE,CAAC;YAC7C,OAAM;QACR,CAAC;QAED,MAAM,UAAU,CAAC;YACf,WAAW,EAAE;gBACX,OAAO,EAAE,IAAI,CAAC,OAAO;aACtB;YACD,MAAM,EAAE;gBACN,IAAA,iCAAmB,EAAC;oBAClB,OAAO,EAAE,4CAA4C,IAAI,CAAC,MAAM,cAAc,IAAI,CAAC,OAAO,cAAc,IAAI,CAAC,OAAO,EAAE;iBACvH,CAAC;aACH;SACF,CAAC,CAAA;IACJ,CAAC;CACF,CAAA"}
@@ -28,9 +28,9 @@ exports.sendCallWithPathway = {
28
28
  };
29
29
  const { otherData, ...fields } = allFields;
30
30
  const sendCallInput = schema_1.SendCallInputSchema.parse({
31
- ...otherData,
32
31
  ...fields,
33
32
  webhook: getWebhookUrl(),
33
+ ...otherData, // there was a 'webhook' field in this otherData object
34
34
  phone_number: fields.phoneNumber,
35
35
  pathway_id: fields.pathwayId,
36
36
  request_data: fields.requestData,
@@ -1 +1 @@
1
- {"version":3,"file":"sendCallWithPathway.js","sourceRoot":"","sources":["../../../../../extensions/bland/actions/sendCallWithPathway/sendCallWithPathway.ts"],"names":[],"mappings":";;;AACA,mEAAwD;AACxD,uFAAmF;AAEnF,qCAAqE;AACrE,6CAAsD;AACtD,uEAA2E;AAE9D,QAAA,mBAAmB,GAI5B;IACF,GAAG,EAAE,qBAAqB;IAC1B,QAAQ,EAAE,0BAAQ,CAAC,aAAa;IAChC,KAAK,EAAE,wBAAwB;IAC/B,WAAW,EAAE,0CAA0C;IACvD,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AG,CAAC,EAAE,aAAa,EAAE,EAAE,uBAAuB,CAAC,CAAA;QACjD,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,OAAO,CAAC,KAAK,CAAC,+BAA+B,CAAC,CAAA;YAC9C,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAA;QACpC,CAAC;QACD,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,QAAQ,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAA;QAEvD;;;WAGG;QACH,IAAI,SAAS,CAAC,8BAA8B,EAAE,CAAC;YAC7C,OAAM;QACR,CAAC;QAED,MAAM,UAAU,CAAC;YACf,WAAW,EAAE;gBACX,OAAO,EAAE,IAAI,CAAC,OAAO;aACtB;YACD,MAAM,EAAE;gBACN,IAAA,iCAAmB,EAAC;oBAClB,OAAO,EAAE,yDAAyD,IAAI,CAAC,MAAM,cAAc,IAAI,CAAC,OAAO,cAAc,IAAI,CAAC,OAAO,EAAE;iBACpI,CAAC;aACH;SACF,CAAC,CAAA;IACJ,CAAC;CACF,CAAA"}
1
+ {"version":3,"file":"sendCallWithPathway.js","sourceRoot":"","sources":["../../../../../extensions/bland/actions/sendCallWithPathway/sendCallWithPathway.ts"],"names":[],"mappings":";;;AACA,mEAAwD;AACxD,uFAAmF;AAEnF,qCAAqE;AACrE,6CAAsD;AACtD,uEAA2E;AAE9D,QAAA,mBAAmB,GAI5B;IACF,GAAG,EAAE,qBAAqB;IAC1B,QAAQ,EAAE,0BAAQ,CAAC,aAAa;IAChC,KAAK,EAAE,wBAAwB;IAC/B,WAAW,EAAE,0CAA0C;IACvD,MAAM,EAAN,eAAM;IACN,WAAW,EAAE,KAAK;IAClB,UAAU,EAAV,mBAAU;IACV,OAAO,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,EAAE,GAAG,EAAE,EAAE,EAAiB,EAAE;QAC1E,MAAM,EAAE,MAAM,EAAE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AAS,CAAC,GAAG,CAAC,CAAC,CAAA;QACpC,CAAC;QACD,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,QAAQ,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAA;QAEvD;;;WAGG;QACH,IAAI,SAAS,CAAC,8BAA8B,EAAE,CAAC;YAC7C,OAAM;QACR,CAAC;QAED,MAAM,UAAU,CAAC;YACf,WAAW,EAAE;gBACX,OAAO,EAAE,IAAI,CAAC,OAAO;aACtB;YACD,MAAM,EAAE;gBACN,IAAA,iCAAmB,EAAC;oBAClB,OAAO,EAAE,yDAAyD,IAAI,CAAC,MAAM,cAAc,IAAI,CAAC,OAAO,cAAc,IAAI,CAAC,OAAO,EAAE;iBACpI,CAAC;aACH;SACF,CAAC,CAAA;IACJ,CAAC;CACF,CAAA"}
@@ -68,6 +68,36 @@ declare const actions: {
68
68
  required: true;
69
69
  };
70
70
  }, Record<string, never>, "data" | "medicationAsText">;
71
+ parseStructuredData: import("@awell-health/extensions-core").Action<{
72
+ messageDataPoint: {
73
+ id: string;
74
+ label: string;
75
+ description: string;
76
+ type: import("@awell-health/extensions-core").FieldType.STRING;
77
+ required: false;
78
+ };
79
+ message: {
80
+ id: string;
81
+ label: string;
82
+ description: string;
83
+ type: import("@awell-health/extensions-core").FieldType.TEXT;
84
+ required: false;
85
+ };
86
+ schema: {
87
+ id: string;
88
+ label: string;
89
+ description: string;
90
+ type: import("@awell-health/extensions-core").FieldType.JSON;
91
+ required: true;
92
+ };
93
+ instructions: {
94
+ id: string;
95
+ label: string;
96
+ description: string;
97
+ type: import("@awell-health/extensions-core").FieldType.TEXT;
98
+ required: false;
99
+ };
100
+ }, Record<string, never>, "explanation" | "confidenceLevel" | "parsedData">;
71
101
  reviewMedicationExtraction: import("@awell-health/extensions-core").Action<{
72
102
  imageUrl: {
73
103
  id: string;
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const categorizeMessage_1 = require("./categorizeMessage");
4
4
  const generateMessage_1 = require("./generateMessage");
5
5
  const medicationFromImage_1 = require("./medicationFromImage");
6
+ const parseStructuredData_1 = require("./parseStructuredData");
6
7
  const reviewMedicationExtraction_1 = require("./reviewMedicationExtraction");
7
8
  const summarizeCareFlow_1 = require("./summarizeCareFlow");
8
9
  const summarizeForm_1 = require("./summarizeForm");
@@ -12,6 +13,7 @@ const actions = {
12
13
  categorizeMessage: categorizeMessage_1.categorizeMessage,
13
14
  generateMessage: generateMessage_1.generateMessage,
14
15
  medicationFromImage: medicationFromImage_1.medicationFromImage,
16
+ parseStructuredData: parseStructuredData_1.parseStructuredData,
15
17
  reviewMedicationExtraction: reviewMedicationExtraction_1.reviewMedicationExtraction,
16
18
  summarizeCareFlow: summarizeCareFlow_1.summarizeCareFlow,
17
19
  summarizeForm: summarizeForm_1.summarizeForm,
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../extensions/shelly/actions/index.ts"],"names":[],"mappings":";;AAAA,2DAAuD;AACvD,uDAAmD;AACnD,+DAA2D;AAC3D,6EAAyE;AACzE,2DAAuD;AACvD,mDAA+C;AAC/C,iEAA6D;AAC7D,mEAA+D;AAE/D,MAAM,OAAO,GAAG;IACd,iBAAiB,EAAjB,qCAAiB;IACjB,eAAe,EAAf,iCAAe;IACf,mBAAmB,EAAnB,yCAAmB;IACnB,0BAA0B,EAA1B,uDAA0B;IAC1B,iBAAiB,EAAjB,qCAAiB;IACjB,aAAa,EAAb,6BAAa;IACb,oBAAoB,EAApB,2CAAoB;IACpB,qBAAqB,EAArB,6CAAqB;CACtB,CAAA;AAED,kBAAe,OAAO,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../extensions/shelly/actions/index.ts"],"names":[],"mappings":";;AAAA,2DAAuD;AACvD,uDAAmD;AACnD,+DAA2D;AAC3D,+DAA2D;AAC3D,6EAAyE;AACzE,2DAAuD;AACvD,mDAA+C;AAC/C,iEAA6D;AAC7D,mEAA+D;AAE/D,MAAM,OAAO,GAAG;IACd,iBAAiB,EAAjB,qCAAiB;IACjB,eAAe,EAAf,iCAAe;IACf,mBAAmB,EAAnB,yCAAmB;IACnB,mBAAmB,EAAnB,yCAAmB;IACnB,0BAA0B,EAA1B,uDAA0B;IAC1B,iBAAiB,EAAjB,qCAAiB;IACjB,aAAa,EAAb,6BAAa;IACb,oBAAoB,EAApB,2CAAoB;IACpB,qBAAqB,EAArB,6CAAqB;CACtB,CAAA;AAED,kBAAe,OAAO,CAAA"}
@@ -0,0 +1,14 @@
1
+ export declare const dataPoints: {
2
+ parsedData: {
3
+ key: string;
4
+ valueType: "json";
5
+ };
6
+ explanation: {
7
+ key: string;
8
+ valueType: "string";
9
+ };
10
+ confidenceLevel: {
11
+ key: string;
12
+ valueType: "number";
13
+ };
14
+ };
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.dataPoints = void 0;
4
+ exports.dataPoints = {
5
+ parsedData: {
6
+ key: 'parsedData',
7
+ valueType: 'json',
8
+ },
9
+ explanation: {
10
+ key: 'explanation',
11
+ valueType: 'string',
12
+ },
13
+ confidenceLevel: {
14
+ key: 'confidenceLevel',
15
+ valueType: 'number',
16
+ },
17
+ };
18
+ //# sourceMappingURL=datapoints.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"datapoints.js","sourceRoot":"","sources":["../../../../../../extensions/shelly/actions/parseStructuredData/config/datapoints.ts"],"names":[],"mappings":";;;AAEa,QAAA,UAAU,GAAG;IACxB,UAAU,EAAE;QACV,GAAG,EAAE,YAAY;QACjB,SAAS,EAAE,MAAM;KAClB;IACD,WAAW,EAAE;QACX,GAAG,EAAE,aAAa;QAClB,SAAS,EAAE,QAAQ;KACpB;IACD,eAAe,EAAE;QACf,GAAG,EAAE,iBAAiB;QACtB,SAAS,EAAE,QAAQ;KACpB;CAC4C,CAAA"}
@@ -0,0 +1,48 @@
1
+ import { FieldType } from '@awell-health/extensions-core';
2
+ import z from 'zod';
3
+ export declare const fields: {
4
+ messageDataPoint: {
5
+ id: string;
6
+ label: string;
7
+ description: string;
8
+ type: FieldType.STRING;
9
+ required: false;
10
+ };
11
+ message: {
12
+ id: string;
13
+ label: string;
14
+ description: string;
15
+ type: FieldType.TEXT;
16
+ required: false;
17
+ };
18
+ schema: {
19
+ id: string;
20
+ label: string;
21
+ description: string;
22
+ type: FieldType.JSON;
23
+ required: true;
24
+ };
25
+ instructions: {
26
+ id: string;
27
+ label: string;
28
+ description: string;
29
+ type: FieldType.TEXT;
30
+ required: false;
31
+ };
32
+ };
33
+ export declare const FieldsValidationSchema: z.ZodObject<{
34
+ message: z.ZodOptional<z.ZodString>;
35
+ messageDataPoint: z.ZodOptional<z.ZodString>;
36
+ schema: z.ZodEffects<z.ZodString, Record<string, string>, string>;
37
+ instructions: z.ZodOptional<z.ZodString>;
38
+ }, "strip", z.ZodTypeAny, {
39
+ schema: Record<string, string>;
40
+ message?: string | undefined;
41
+ instructions?: string | undefined;
42
+ messageDataPoint?: string | undefined;
43
+ }, {
44
+ schema: string;
45
+ message?: string | undefined;
46
+ instructions?: string | undefined;
47
+ messageDataPoint?: string | undefined;
48
+ }>;
@@ -0,0 +1,74 @@
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.FieldsValidationSchema = exports.fields = void 0;
7
+ const extensions_core_1 = require("@awell-health/extensions-core");
8
+ const core_1 = require("@medplum/core");
9
+ const zod_1 = __importDefault(require("zod"));
10
+ exports.fields = {
11
+ messageDataPoint: {
12
+ id: 'messageDataPoint',
13
+ label: 'Message Data Point',
14
+ description: 'The message to parse. Use this if you want to use a data point for the message.',
15
+ type: extensions_core_1.FieldType.STRING,
16
+ required: false,
17
+ },
18
+ message: {
19
+ id: 'message',
20
+ label: 'Message',
21
+ description: 'The message to parse. Use this if you want to use a text for the message.',
22
+ type: extensions_core_1.FieldType.TEXT,
23
+ required: false,
24
+ },
25
+ schema: {
26
+ id: 'schema',
27
+ label: 'Schema',
28
+ description: 'JSON schema defining the structure to extract from the message. Example: {"name": "string", "age": "number", "email": "string"}',
29
+ type: extensions_core_1.FieldType.JSON,
30
+ required: true,
31
+ },
32
+ instructions: {
33
+ id: 'instructions',
34
+ label: 'Instructions',
35
+ description: 'Add additional instructions prompt for the LLM',
36
+ type: extensions_core_1.FieldType.TEXT,
37
+ required: false,
38
+ },
39
+ };
40
+ exports.FieldsValidationSchema = zod_1.default.object({
41
+ message: zod_1.default.string().optional(),
42
+ messageDataPoint: zod_1.default.string().optional(),
43
+ schema: zod_1.default.string().transform((str, ctx) => {
44
+ if ((0, core_1.isEmpty)(str)) {
45
+ ctx.addIssue({
46
+ code: 'custom',
47
+ message: 'Schema is required',
48
+ });
49
+ return zod_1.default.NEVER;
50
+ }
51
+ try {
52
+ const parsed = JSON.parse(str);
53
+ if (typeof parsed !== 'object' ||
54
+ parsed === null ||
55
+ Array.isArray(parsed)) {
56
+ ctx.addIssue({
57
+ code: 'custom',
58
+ message: 'Schema must be a JSON object',
59
+ });
60
+ return zod_1.default.NEVER;
61
+ }
62
+ return parsed;
63
+ }
64
+ catch (e) {
65
+ ctx.addIssue({
66
+ code: 'custom',
67
+ message: 'Invalid JSON schema',
68
+ });
69
+ return zod_1.default.NEVER;
70
+ }
71
+ }),
72
+ instructions: zod_1.default.string().optional(),
73
+ });
74
+ //# sourceMappingURL=fields.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fields.js","sourceRoot":"","sources":["../../../../../../extensions/shelly/actions/parseStructuredData/config/fields.ts"],"names":[],"mappings":";;;;;;AAAA,mEAAqE;AACrE,wCAAuC;AACvC,8CAAwC;AAE3B,QAAA,MAAM,GAAG;IACpB,gBAAgB,EAAE;QAChB,EAAE,EAAE,kBAAkB;QACtB,KAAK,EAAE,oBAAoB;QAC3B,WAAW,EACT,iFAAiF;QACnF,IAAI,EAA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G,CAAC,QAAQ,CAAC;oBACX,IAAI,EAAE,QAAQ;oBACd,OAAO,EAAE,8BAA8B;iBACxC,CAAC,CAAA;gBACF,OAAO,aAAC,CAAC,KAAK,CAAA;YAChB,CAAC;YACD,OAAO,MAAgC,CAAA;QACzC,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,GAAG,CAAC,QAAQ,CAAC;gBACX,IAAI,EAAE,QAAQ;gBACd,OAAO,EAAE,qBAAqB;aAC/B,CAAC,CAAA;YACF,OAAO,aAAC,CAAC,KAAK,CAAA;QAChB,CAAC;IACH,CAAC,CAAC;IACF,YAAY,EAAE,aAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CACc,CAAC,CAAA"}
@@ -0,0 +1,2 @@
1
+ export { fields, FieldsValidationSchema } from './fields';
2
+ export { dataPoints } from './datapoints';
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.dataPoints = exports.FieldsValidationSchema = exports.fields = void 0;
4
+ var fields_1 = require("./fields");
5
+ Object.defineProperty(exports, "fields", { enumerable: true, get: function () { return fields_1.fields; } });
6
+ Object.defineProperty(exports, "FieldsValidationSchema", { enumerable: true, get: function () { return fields_1.FieldsValidationSchema; } });
7
+ var datapoints_1 = require("./datapoints");
8
+ Object.defineProperty(exports, "dataPoints", { enumerable: true, get: function () { return datapoints_1.dataPoints; } });
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../extensions/shelly/actions/parseStructuredData/config/index.ts"],"names":[],"mappings":";;;AAAA,mCAAyD;AAAhD,gGAAA,MAAM,OAAA;AAAE,gHAAA,sBAAsB,OAAA;AACvC,2CAAyC;AAAhC,wGAAA,UAAU,OAAA"}
@@ -0,0 +1 @@
1
+ export { parseStructuredData } from './parseStructuredData';
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseStructuredData = void 0;
4
+ var parseStructuredData_1 = require("./parseStructuredData");
5
+ Object.defineProperty(exports, "parseStructuredData", { enumerable: true, get: function () { return parseStructuredData_1.parseStructuredData; } });
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../extensions/shelly/actions/parseStructuredData/index.ts"],"names":[],"mappings":";;;AAAA,6DAA2D;AAAlD,0HAAA,mBAAmB,OAAA"}
@@ -0,0 +1 @@
1
+ export { parseStructuredDataWithLLM } from './parseStructuredDataWithLLM';
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseStructuredDataWithLLM = void 0;
4
+ var parseStructuredDataWithLLM_1 = require("./parseStructuredDataWithLLM");
5
+ Object.defineProperty(exports, "parseStructuredDataWithLLM", { enumerable: true, get: function () { return parseStructuredDataWithLLM_1.parseStructuredDataWithLLM; } });
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../extensions/shelly/actions/parseStructuredData/lib/parseStructuredDataWithLLM/index.ts"],"names":[],"mappings":";;;AAAA,2EAAyE;AAAhE,wIAAA,0BAA0B,OAAA"}
@@ -0,0 +1,35 @@
1
+ import { type ChatOpenAI } from '@langchain/openai';
2
+ import { type AIActionMetadata } from '../../../../../../src/lib/llm/openai/types';
3
+ import type { BaseCallbackHandler } from '@langchain/core/callbacks/base';
4
+ /**
5
+ * Uses LLM to extract structured data from a message according to a provided schema.
6
+ * The function follows these steps:
7
+ * 1. Formats prompt with schema and message
8
+ * 2. Runs LLM chain with structured output parsing
9
+ * 3. Validates and processes the result
10
+ *
11
+ * @example
12
+ * const result = await parseStructuredDataWithLLM({
13
+ * model,
14
+ * message: "Patient John Doe, age 45, scheduled for tomorrow at 2pm",
15
+ * schema: { name: "string", age: "number", appointmentTime: "string" },
16
+ * metadata: { ... }
17
+ * })
18
+ * // Returns: {
19
+ * // data: { name: "John Doe", age: 45, appointmentTime: "2pm tomorrow" },
20
+ * // confidenceLevel: 85,
21
+ * // explanation: "..."
22
+ * // }
23
+ */
24
+ export declare const parseStructuredDataWithLLM: ({ model, message, schema, instructions, metadata, callbacks, }: {
25
+ model: ChatOpenAI;
26
+ message: string;
27
+ schema: Record<string, string>;
28
+ instructions?: string;
29
+ metadata: AIActionMetadata;
30
+ callbacks?: BaseCallbackHandler[];
31
+ }) => Promise<{
32
+ data: Record<string, any>;
33
+ confidenceLevel: number;
34
+ explanation: string;
35
+ }>;
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseStructuredDataWithLLM = void 0;
4
+ const parser_1 = require("./parser");
5
+ const prompt_1 = require("./prompt");
6
+ /**
7
+ * Uses LLM to extract structured data from a message according to a provided schema.
8
+ * The function follows these steps:
9
+ * 1. Formats prompt with schema and message
10
+ * 2. Runs LLM chain with structured output parsing
11
+ * 3. Validates and processes the result
12
+ *
13
+ * @example
14
+ * const result = await parseStructuredDataWithLLM({
15
+ * model,
16
+ * message: "Patient John Doe, age 45, scheduled for tomorrow at 2pm",
17
+ * schema: { name: "string", age: "number", appointmentTime: "string" },
18
+ * metadata: { ... }
19
+ * })
20
+ * // Returns: {
21
+ * // data: { name: "John Doe", age: 45, appointmentTime: "2pm tomorrow" },
22
+ * // confidenceLevel: 85,
23
+ * // explanation: "..."
24
+ * // }
25
+ */
26
+ const parseStructuredDataWithLLM = async ({ model, message, schema, instructions, metadata, callbacks, }) => {
27
+ var _a, _b, _c;
28
+ const prompt = await prompt_1.systemPrompt.format({
29
+ schema: JSON.stringify(schema, null, 2),
30
+ input: message,
31
+ instructions: instructions !== null && instructions !== void 0 ? instructions : 'No additional instructions have been provided',
32
+ });
33
+ const chain = model.pipe(parser_1.parser);
34
+ let result;
35
+ try {
36
+ result = await chain.invoke(prompt, {
37
+ metadata,
38
+ runName: 'ShellyParseStructuredData',
39
+ callbacks,
40
+ });
41
+ }
42
+ catch (error) {
43
+ throw new Error('Failed to parse structured data from the message due to an internal error.');
44
+ }
45
+ return {
46
+ data: (_a = result.extracted_data) !== null && _a !== void 0 ? _a : {},
47
+ confidenceLevel: (_b = result.confidence_level) !== null && _b !== void 0 ? _b : 0,
48
+ explanation: (_c = result.extraction_explanation) !== null && _c !== void 0 ? _c : '',
49
+ };
50
+ };
51
+ exports.parseStructuredDataWithLLM = parseStructuredDataWithLLM;
52
+ //# sourceMappingURL=parseStructuredDataWithLLM.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parseStructuredDataWithLLM.js","sourceRoot":"","sources":["../../../../../../../extensions/shelly/actions/parseStructuredData/lib/parseStructuredDataWithLLM/parseStructuredDataWithLLM.ts"],"names":[],"mappings":";;;AAAA,qCAAiC;AACjC,qCAAuC;AAKvC;;;;;;;;;;;;;;;;;;;GAmBG;AACI,MAAM,0BAA0B,GAAG,KAAK,EAAE,EAC/C,KAAK,EACL,OAAO,EACP,MAAM,EACN,YAAY,EACZ,QAAQ,EACR,SAAS,GAQV,EAIE,EAAE;;IACH,MAAM,MAAM,GAAG,MAAM,qBAAY,CAAC,MAAM,CAAC;QACvC,MAAM,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;QACvC,KAAK,EAAE,OAAO;QACd,YAAY,EACV,YAAY,aAAZ,YAAY,cAAZ,YAAY,GAAI,+CAA+C;KAClE,CAAC,CAAA;IAEF,MAAM,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,eAAM,CAAC,CAAA;IAEhC,IAAI,MAAM,CAAA;IACV,IAAI,CAAC;QACH,MAAM,GAAG,MAAM,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE;YAClC,QAAQ;YACR,OAAO,EAAE,2BAA2B;YACpC,SAAS;SACV,CAAC,CAAA;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CACb,4EAA4E,CAC7E,CAAA;IACH,CAAC;IAED,OAAO;QACL,IAAI,EAAE,MAAA,MAAM,CAAC,cAAc,mCAAI,EAAE;QACjC,eAAe,EAAE,MAAA,MAAM,CAAC,gBAAgB,mCAAI,CAAC;QAC7C,WAAW,EAAE,MAAA,MAAM,CAAC,sBAAsB,mCAAI,EAAE;KACjD,CAAA;AACH,CAAC,CAAA;AA9CY,QAAA,0BAA0B,8BA8CtC"}
@@ -0,0 +1,24 @@
1
+ import { StructuredOutputParser } from 'langchain/output_parsers';
2
+ import { z } from 'zod';
3
+ /**
4
+ * Structured Output Parser
5
+ * Ensures LLM response follows the format:
6
+ * {
7
+ * extracted_data: Record<string, any> // Data matching the provided schema
8
+ * confidence_level: number // 0-100 indicating extraction reliability
9
+ * extraction_explanation: string // Brief explanation of the extraction
10
+ * }
11
+ */
12
+ export declare const parser: StructuredOutputParser<z.ZodObject<{
13
+ extracted_data: z.ZodRecord<z.ZodString, z.ZodAny>;
14
+ confidence_level: z.ZodNumber;
15
+ extraction_explanation: z.ZodString;
16
+ }, "strip", z.ZodTypeAny, {
17
+ extracted_data: Record<string, any>;
18
+ confidence_level: number;
19
+ extraction_explanation: string;
20
+ }, {
21
+ extracted_data: Record<string, any>;
22
+ confidence_level: number;
23
+ extraction_explanation: string;
24
+ }>>;
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parser = void 0;
4
+ const output_parsers_1 = require("langchain/output_parsers");
5
+ const zod_1 = require("zod");
6
+ /**
7
+ * Structured Output Parser
8
+ * Ensures LLM response follows the format:
9
+ * {
10
+ * extracted_data: Record<string, any> // Data matching the provided schema
11
+ * confidence_level: number // 0-100 indicating extraction reliability
12
+ * extraction_explanation: string // Brief explanation of the extraction
13
+ * }
14
+ */
15
+ exports.parser = output_parsers_1.StructuredOutputParser.fromZodSchema(zod_1.z.object({
16
+ extracted_data: zod_1.z
17
+ .record(zod_1.z.any())
18
+ .describe('Extracted data matching the schema'),
19
+ confidence_level: zod_1.z
20
+ .number()
21
+ .min(0)
22
+ .max(100)
23
+ .describe('Confidence level of the extraction (0-100)'),
24
+ extraction_explanation: zod_1.z
25
+ .string()
26
+ .describe('Brief explanation of the extraction process'),
27
+ }));
28
+ //# sourceMappingURL=parser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parser.js","sourceRoot":"","sources":["../../../../../../../extensions/shelly/actions/parseStructuredData/lib/parseStructuredDataWithLLM/parser.ts"],"names":[],"mappings":";;;AAAA,6DAAiE;AACjE,6BAAuB;AAEvB;;;;;;;;GAQG;AACU,QAAA,MAAM,GAAG,uCAAsB,CAAC,aAAa,CACxD,OAAC,CAAC,MAAM,CAAC;IACP,cAAc,EAAE,OAAC;SACd,MAAM,CAAC,OAAC,CAAC,GAAG,EAAE,CAAC;SACf,QAAQ,CAAC,oCAAoC,CAAC;IACjD,gBAAgB,EAAE,OAAC;SAChB,MAAM,EAAE;SACR,GAAG,CAAC,CAAC,CAAC;SACN,GAAG,CAAC,GAAG,CAAC;SACR,QAAQ,CAAC,4CAA4C,CAAC;IACzD,sBAAsB,EAAE,OAAC;SACtB,MAAM,EAAE;SACR,QAAQ,CAAC,6CAA6C,CAAC;CAC3D,CAAC,CACH,CAAA"}
@@ -0,0 +1,14 @@
1
+ import { ChatPromptTemplate } from '@langchain/core/prompts';
2
+ /**
3
+ * System Prompt Template
4
+ * Instructs the LLM to:
5
+ * 1. Extract structured data from the message according to the provided schema
6
+ * 2. Provide a confidence level (0-100) for the extraction
7
+ * 3. Explain the extraction process
8
+ *
9
+ * Variables:
10
+ * {schema} - JSON schema defining the structure to extract
11
+ * {input} - Message to parse
12
+ * {instructions} - Additional instructions
13
+ */
14
+ export declare const systemPrompt: ChatPromptTemplate<import("@langchain/core/prompts").ParamsFromFString<"\n You are an expert in extracting structured data from unstructured text messages in a clinical context.\n Use your expertise to solve the data extraction task:\n \n 1. Extract data from the input message according to the provided schema structure.\n 2. Return the extracted data in JSON format matching the schema.\n 3. Provide a confidence level (0-100) indicating how reliable the extraction is:\n - 90-100: Very confident, all required fields found with clear values\n - 70-89: Confident, most fields found but some ambiguity\n - 50-69: Moderately confident, some fields missing or unclear\n - 0-49: Low confidence, many fields missing or highly ambiguous\n 4. Provide a brief explanation of the extraction process and any challenges.\n \n Schema Structure:\n {schema}\n \n Important Instructions:\n - The message may be in multiple languages.\n - Extract only the information explicitly stated in the message.\n - If a field cannot be determined from the message, use null for that field.\n - Be accurate and avoid making assumptions beyond what is stated in the message.\n - Format dates, numbers, and other data types according to standard conventions.\n \n Respond exclusively with a valid JSON object containing the following keys:\n - extracted_data: An object matching the provided schema structure\n - confidence_level: A number between 0 and 100\n - extraction_explanation: A brief explanation of the extraction process\n \n Additional Instructions:\n {instructions}\n \n Input Message:\n {input}\n">, any>;
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.systemPrompt = void 0;
4
+ const prompts_1 = require("@langchain/core/prompts");
5
+ /**
6
+ * System Prompt Template
7
+ * Instructs the LLM to:
8
+ * 1. Extract structured data from the message according to the provided schema
9
+ * 2. Provide a confidence level (0-100) for the extraction
10
+ * 3. Explain the extraction process
11
+ *
12
+ * Variables:
13
+ * {schema} - JSON schema defining the structure to extract
14
+ * {input} - Message to parse
15
+ * {instructions} - Additional instructions
16
+ */
17
+ exports.systemPrompt = prompts_1.ChatPromptTemplate.fromTemplate(`
18
+ You are an expert in extracting structured data from unstructured text messages in a clinical context.
19
+ Use your expertise to solve the data extraction task:
20
+
21
+ 1. Extract data from the input message according to the provided schema structure.
22
+ 2. Return the extracted data in JSON format matching the schema.
23
+ 3. Provide a confidence level (0-100) indicating how reliable the extraction is:
24
+ - 90-100: Very confident, all required fields found with clear values
25
+ - 70-89: Confident, most fields found but some ambiguity
26
+ - 50-69: Moderately confident, some fields missing or unclear
27
+ - 0-49: Low confidence, many fields missing or highly ambiguous
28
+ 4. Provide a brief explanation of the extraction process and any challenges.
29
+
30
+ Schema Structure:
31
+ {schema}
32
+
33
+ Important Instructions:
34
+ - The message may be in multiple languages.
35
+ - Extract only the information explicitly stated in the message.
36
+ - If a field cannot be determined from the message, use null for that field.
37
+ - Be accurate and avoid making assumptions beyond what is stated in the message.
38
+ - Format dates, numbers, and other data types according to standard conventions.
39
+
40
+ Respond exclusively with a valid JSON object containing the following keys:
41
+ - extracted_data: An object matching the provided schema structure
42
+ - confidence_level: A number between 0 and 100
43
+ - extraction_explanation: A brief explanation of the extraction process
44
+
45
+ Additional Instructions:
46
+ {instructions}
47
+
48
+ Input Message:
49
+ {input}
50
+ `);
51
+ //# sourceMappingURL=prompt.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompt.js","sourceRoot":"","sources":["../../../../../../../extensions/shelly/actions/parseStructuredData/lib/parseStructuredDataWithLLM/prompt.ts"],"names":[],"mappings":";;;AAAA,qDAA4D;AAE5D;;;;;;;;;;;GAWG;AACU,QAAA,YAAY,GAAG,4BAAkB,CAAC,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiC3D,CAAC,CAAA"}
@@ -0,0 +1,13 @@
1
+ import { type Action } from '@awell-health/extensions-core';
2
+ import { fields, dataPoints } from './config';
3
+ /**
4
+ * Awell Action: Parse Structured Data
5
+ *
6
+ * Takes a message and a JSON schema as input, uses LLM to:
7
+ * 1. Extract structured data matching the schema
8
+ * 2. Provide a confidence level (0-100) for the extraction
9
+ * 3. Provide explanation for the extraction process
10
+ *
11
+ * @returns parsed data (JSON), confidence level (number), and HTML-formatted explanation
12
+ */
13
+ export declare const parseStructuredData: Action<typeof fields, Record<string, never>, keyof typeof dataPoints>;
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseStructuredData = void 0;
4
+ const extensions_core_1 = require("@awell-health/extensions-core");
5
+ const parseStructuredDataWithLLM_1 = require("./lib/parseStructuredDataWithLLM");
6
+ const createOpenAIModel_1 = require("../../../../src/lib/llm/openai/createOpenAIModel");
7
+ const constants_1 = require("../../../../src/lib/llm/openai/constants");
8
+ const config_1 = require("./config");
9
+ const utils_1 = require("../../../../src/utils");
10
+ const lodash_1 = require("lodash");
11
+ /**
12
+ * Awell Action: Parse Structured Data
13
+ *
14
+ * Takes a message and a JSON schema as input, uses LLM to:
15
+ * 1. Extract structured data matching the schema
16
+ * 2. Provide a confidence level (0-100) for the extraction
17
+ * 3. Provide explanation for the extraction process
18
+ *
19
+ * @returns parsed data (JSON), confidence level (number), and HTML-formatted explanation
20
+ */
21
+ exports.parseStructuredData = {
22
+ key: 'parseStructuredData',
23
+ category: extensions_core_1.Category.WORKFLOW,
24
+ title: 'Parse Structured Data (Beta)',
25
+ description: 'Extracts structured data from unstructured text messages using a provided JSON schema.',
26
+ fields: config_1.fields,
27
+ previewable: false,
28
+ dataPoints: config_1.dataPoints,
29
+ onEvent: async ({ payload, onComplete, onError, helpers }) => {
30
+ // 1. Validate input fields
31
+ const { message: messageText, messageDataPoint, schema, instructions, } = config_1.FieldsValidationSchema.parse(payload.fields);
32
+ const message = !(0, lodash_1.isNil)(messageDataPoint) && (messageDataPoint === null || messageDataPoint === void 0 ? void 0 : messageDataPoint.length) > 0
33
+ ? messageDataPoint
34
+ : (messageText !== null && messageText !== void 0 ? messageText : '');
35
+ // ensure message is not empty
36
+ if (message.length === 0) {
37
+ await onError({
38
+ events: [
39
+ {
40
+ date: new Date().toISOString(),
41
+ text: { en: 'Either message or messageDataPoint is required' },
42
+ error: {
43
+ category: 'BAD_REQUEST',
44
+ message: 'Either message or messageDataPoint is required',
45
+ },
46
+ },
47
+ ],
48
+ });
49
+ return;
50
+ }
51
+ // 2. Initialize OpenAI model with metadata
52
+ const { model, metadata, callbacks } = await (0, createOpenAIModel_1.createOpenAIModel)({
53
+ settings: {}, // we use built-in API key for OpenAI
54
+ helpers,
55
+ payload,
56
+ modelType: constants_1.OPENAI_MODELS.GPT4oMini,
57
+ });
58
+ // 3. Perform structured data extraction
59
+ const result = await (0, parseStructuredDataWithLLM_1.parseStructuredDataWithLLM)({
60
+ model,
61
+ message,
62
+ schema,
63
+ instructions,
64
+ metadata,
65
+ callbacks,
66
+ });
67
+ // 4. Format and return results
68
+ const explanationHtml = await (0, utils_1.markdownToHtml)(result.explanation);
69
+ await onComplete({
70
+ data_points: {
71
+ parsedData: JSON.stringify(result.data),
72
+ confidenceLevel: String(result.confidenceLevel),
73
+ explanation: explanationHtml,
74
+ },
75
+ });
76
+ },
77
+ };
78
+ //# sourceMappingURL=parseStructuredData.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parseStructuredData.js","sourceRoot":"","sources":["../../../../../extensions/shelly/actions/parseStructuredData/parseStructuredData.ts"],"names":[],"mappings":";;;AAAA,mEAAqE;AACrE,iFAA6E;AAC7E,wFAAoF;AACpF,wEAAwE;AACxE,qCAAqE;AACrE,iDAAsD;AACtD,mCAA8B;AAE9B;;;;;;;;;GASG;AACU,QAAA,mBAAmB,GAI5B;IACF,GAAG,EAAE,qBAAqB;IAC1B,QAAQ,EAAE,0BAAQ,CAAC,QAAQ;IAC3B,KAAK,EAAE,8BAA8B;IACrC,WAAW,EACT,wFAAwF;IAC1F,MAAM,EAAN,eAAM;IACN,WAAW,EAAE,KAAK;IAClB,UAAU,EAAV,mBAAU;IAEV,OAAO,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,EAAiB,EAAE;QAC1E,2BAA2B;QAC3B,MAAM,EACJ,OAAO,EAAE,WAAW,EACpB,gBAAgB,EAChB,MAAM,EACN,YAAY,GACb,GAAG,+BAAsB,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;QAEhD,MAAM,OAAO,GACX,CAAC,IAAA,cAAK,EAAC,gBAAgB,CAAC,IAAI,CAAA,gBAAgB,aAAhB,gBAAgB,uBAAhB,gBAAgB,CAAE,MAAM,IAAG,CAAC;YAC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ions",
3
- "version": "2.1.40",
3
+ "version": "2.1.42",
4
4
  "packageManager": "yarn@4.5.3",
5
5
  "main": "dist/src/index.js",
6
6
  "repository": {