@awell-health/awell-extensions 2.0.14 → 2.0.16

Sign up to get free protection for your applications and to get access to all the features.
Files changed (179) hide show
  1. package/dist/extensions/cmDotCom/v1/actions/sendSms/config/fields.d.ts +1 -1
  2. package/dist/extensions/healthie/actions/createGoal/createGoal.test.js +1 -1
  3. package/dist/extensions/healthie/actions/createGoal/createGoal.test.js.map +1 -1
  4. package/dist/extensions/healthie/actions/index.d.ts +31 -0
  5. package/dist/extensions/healthie/actions/index.js +2 -0
  6. package/dist/extensions/healthie/actions/index.js.map +1 -1
  7. package/dist/extensions/healthie/actions/pushFormResponseToHealthie/config/datapoints.d.ts +6 -0
  8. package/dist/extensions/healthie/actions/pushFormResponseToHealthie/config/datapoints.js +10 -0
  9. package/dist/extensions/healthie/actions/pushFormResponseToHealthie/config/datapoints.js.map +1 -0
  10. package/dist/extensions/healthie/actions/pushFormResponseToHealthie/config/fields.d.ts +28 -0
  11. package/dist/extensions/healthie/actions/pushFormResponseToHealthie/config/fields.js +29 -0
  12. package/dist/extensions/healthie/actions/pushFormResponseToHealthie/config/fields.js.map +1 -0
  13. package/dist/extensions/healthie/actions/pushFormResponseToHealthie/config/index.d.ts +2 -0
  14. package/dist/extensions/healthie/actions/pushFormResponseToHealthie/config/index.js +9 -0
  15. package/dist/extensions/healthie/actions/pushFormResponseToHealthie/config/index.js.map +1 -0
  16. package/dist/extensions/healthie/actions/pushFormResponseToHealthie/errors.d.ts +6 -0
  17. package/dist/extensions/healthie/actions/pushFormResponseToHealthie/errors.js +27 -0
  18. package/dist/extensions/healthie/actions/pushFormResponseToHealthie/errors.js.map +1 -0
  19. package/dist/extensions/healthie/actions/pushFormResponseToHealthie/index.d.ts +1 -0
  20. package/dist/extensions/healthie/actions/pushFormResponseToHealthie/index.js +6 -0
  21. package/dist/extensions/healthie/actions/pushFormResponseToHealthie/index.js.map +1 -0
  22. package/dist/extensions/healthie/actions/pushFormResponseToHealthie/logs/getSubActivityLogs/getSubActivityLogs.d.ts +3 -0
  23. package/dist/extensions/healthie/actions/pushFormResponseToHealthie/logs/getSubActivityLogs/getSubActivityLogs.js +89 -0
  24. package/dist/extensions/healthie/actions/pushFormResponseToHealthie/logs/getSubActivityLogs/getSubActivityLogs.js.map +1 -0
  25. package/dist/extensions/healthie/actions/pushFormResponseToHealthie/logs/getSubActivityLogs/getSubActivityLogs.test.d.ts +1 -0
  26. package/dist/extensions/healthie/actions/pushFormResponseToHealthie/logs/getSubActivityLogs/getSubActivityLogs.test.js +72 -0
  27. package/dist/extensions/healthie/actions/pushFormResponseToHealthie/logs/getSubActivityLogs/getSubActivityLogs.test.js.map +1 -0
  28. package/dist/extensions/healthie/actions/pushFormResponseToHealthie/logs/getSubActivityLogs/index.d.ts +1 -0
  29. package/dist/extensions/healthie/actions/pushFormResponseToHealthie/logs/getSubActivityLogs/index.js +18 -0
  30. package/dist/extensions/healthie/actions/pushFormResponseToHealthie/logs/getSubActivityLogs/index.js.map +1 -0
  31. package/dist/extensions/healthie/actions/pushFormResponseToHealthie/logs/index.d.ts +1 -0
  32. package/dist/extensions/healthie/actions/pushFormResponseToHealthie/logs/index.js +18 -0
  33. package/dist/extensions/healthie/actions/pushFormResponseToHealthie/logs/index.js.map +1 -0
  34. package/dist/extensions/healthie/actions/pushFormResponseToHealthie/pushFormResponseToHealthie.d.ts +4 -0
  35. package/dist/extensions/healthie/actions/pushFormResponseToHealthie/pushFormResponseToHealthie.js +98 -0
  36. package/dist/extensions/healthie/actions/pushFormResponseToHealthie/pushFormResponseToHealthie.js.map +1 -0
  37. package/dist/extensions/healthie/actions/pushFormResponseToHealthie/pushFormResponseToHealthie.test.d.ts +1 -0
  38. package/dist/extensions/healthie/actions/pushFormResponseToHealthie/pushFormResponseToHealthie.test.js +84 -0
  39. package/dist/extensions/healthie/actions/pushFormResponseToHealthie/pushFormResponseToHealthie.test.js.map +1 -0
  40. package/dist/extensions/healthie/lib/sdk/validatePayloadAndCreateSdk.d.ts +7 -2
  41. package/dist/extensions/healthie/lib/sdk/validatePayloadAndCreateSdk.js +10 -1
  42. package/dist/extensions/healthie/lib/sdk/validatePayloadAndCreateSdk.js.map +1 -1
  43. package/dist/extensions/shelly/actions/categorizeMessage/categorizeMessage.d.ts +4 -0
  44. package/dist/extensions/shelly/actions/categorizeMessage/categorizeMessage.js +40 -0
  45. package/dist/extensions/shelly/actions/categorizeMessage/categorizeMessage.js.map +1 -0
  46. package/dist/extensions/shelly/actions/categorizeMessage/categorizeMessage.test.d.ts +1 -0
  47. package/dist/extensions/shelly/actions/categorizeMessage/categorizeMessage.test.js +63 -0
  48. package/dist/extensions/shelly/actions/categorizeMessage/categorizeMessage.test.js.map +1 -0
  49. package/dist/extensions/shelly/actions/categorizeMessage/config/datapoints.d.ts +6 -0
  50. package/dist/extensions/shelly/actions/categorizeMessage/config/datapoints.js +10 -0
  51. package/dist/extensions/shelly/actions/categorizeMessage/config/datapoints.js.map +1 -0
  52. package/dist/extensions/shelly/actions/categorizeMessage/config/fields.d.ts +28 -0
  53. package/dist/extensions/shelly/actions/categorizeMessage/config/fields.js +36 -0
  54. package/dist/extensions/shelly/actions/categorizeMessage/config/fields.js.map +1 -0
  55. package/dist/extensions/shelly/actions/categorizeMessage/config/index.d.ts +2 -0
  56. package/dist/extensions/shelly/actions/categorizeMessage/config/index.js +9 -0
  57. package/dist/extensions/shelly/actions/categorizeMessage/config/index.js.map +1 -0
  58. package/dist/extensions/shelly/actions/categorizeMessage/index.d.ts +1 -0
  59. package/dist/extensions/shelly/actions/categorizeMessage/index.js +6 -0
  60. package/dist/extensions/shelly/actions/categorizeMessage/index.js.map +1 -0
  61. package/dist/extensions/shelly/actions/categorizeMessage/lib/categorizeMessageWithLLM/categorizeMessageWithLLM.d.ts +6 -0
  62. package/dist/extensions/shelly/actions/categorizeMessage/lib/categorizeMessageWithLLM/categorizeMessageWithLLM.js +22 -0
  63. package/dist/extensions/shelly/actions/categorizeMessage/lib/categorizeMessageWithLLM/categorizeMessageWithLLM.js.map +1 -0
  64. package/dist/extensions/shelly/actions/categorizeMessage/lib/categorizeMessageWithLLM/categorizeMessageWithLLM.test.d.ts +1 -0
  65. package/dist/extensions/shelly/actions/categorizeMessage/lib/categorizeMessageWithLLM/categorizeMessageWithLLM.test.js +72 -0
  66. package/dist/extensions/shelly/actions/categorizeMessage/lib/categorizeMessageWithLLM/categorizeMessageWithLLM.test.js.map +1 -0
  67. package/dist/extensions/shelly/actions/categorizeMessage/lib/categorizeMessageWithLLM/constants.d.ts +18 -0
  68. package/dist/extensions/shelly/actions/categorizeMessage/lib/categorizeMessageWithLLM/constants.js +24 -0
  69. package/dist/extensions/shelly/actions/categorizeMessage/lib/categorizeMessageWithLLM/constants.js.map +1 -0
  70. package/dist/extensions/shelly/actions/categorizeMessage/lib/categorizeMessageWithLLM/index.d.ts +1 -0
  71. package/dist/extensions/shelly/actions/categorizeMessage/lib/categorizeMessageWithLLM/index.js +6 -0
  72. package/dist/extensions/shelly/actions/categorizeMessage/lib/categorizeMessageWithLLM/index.js.map +1 -0
  73. package/dist/extensions/shelly/actions/categorizeMessage/realTest.test.d.ts +1 -0
  74. package/dist/extensions/shelly/actions/categorizeMessage/realTest.test.js +62 -0
  75. package/dist/extensions/shelly/actions/categorizeMessage/realTest.test.js.map +1 -0
  76. package/dist/extensions/shelly/actions/index.d.ts +49 -5
  77. package/dist/extensions/shelly/actions/index.js +6 -0
  78. package/dist/extensions/shelly/actions/index.js.map +1 -1
  79. package/dist/extensions/shelly/actions/medicationFromImage/config/datapoints.d.ts +6 -0
  80. package/dist/extensions/shelly/actions/medicationFromImage/config/datapoints.js +10 -0
  81. package/dist/extensions/shelly/actions/medicationFromImage/config/datapoints.js.map +1 -0
  82. package/dist/extensions/shelly/actions/medicationFromImage/config/fields.d.ts +18 -0
  83. package/dist/extensions/shelly/actions/medicationFromImage/config/fields.js +21 -0
  84. package/dist/extensions/shelly/actions/medicationFromImage/config/fields.js.map +1 -0
  85. package/dist/extensions/shelly/actions/medicationFromImage/config/index.d.ts +2 -0
  86. package/dist/extensions/shelly/actions/medicationFromImage/config/index.js +9 -0
  87. package/dist/extensions/shelly/actions/medicationFromImage/config/index.js.map +1 -0
  88. package/dist/extensions/shelly/actions/medicationFromImage/index.d.ts +1 -0
  89. package/dist/extensions/shelly/actions/medicationFromImage/index.js +6 -0
  90. package/dist/extensions/shelly/actions/medicationFromImage/index.js.map +1 -0
  91. package/dist/extensions/shelly/actions/medicationFromImage/medicationFromImage.d.ts +4 -0
  92. package/dist/extensions/shelly/actions/medicationFromImage/medicationFromImage.js +31 -0
  93. package/dist/extensions/shelly/actions/medicationFromImage/medicationFromImage.js.map +1 -0
  94. package/dist/extensions/shelly/actions/medicationFromImage/medicationFromImage.test.d.ts +1 -0
  95. package/dist/extensions/shelly/actions/medicationFromImage/medicationFromImage.test.js +33 -0
  96. package/dist/extensions/shelly/actions/medicationFromImage/medicationFromImage.test.js.map +1 -0
  97. package/dist/extensions/shelly/actions/summarizeCareFlow/config/datapoints.d.ts +6 -0
  98. package/dist/extensions/shelly/actions/summarizeCareFlow/config/datapoints.js +10 -0
  99. package/dist/extensions/shelly/actions/summarizeCareFlow/config/datapoints.js.map +1 -0
  100. package/dist/extensions/shelly/actions/summarizeCareFlow/config/fields.d.ts +18 -0
  101. package/dist/extensions/shelly/actions/summarizeCareFlow/config/fields.js +21 -0
  102. package/dist/extensions/shelly/actions/summarizeCareFlow/config/fields.js.map +1 -0
  103. package/dist/extensions/shelly/actions/summarizeCareFlow/config/index.d.ts +2 -0
  104. package/dist/extensions/shelly/actions/summarizeCareFlow/config/index.js +9 -0
  105. package/dist/extensions/shelly/actions/summarizeCareFlow/config/index.js.map +1 -0
  106. package/dist/extensions/shelly/actions/summarizeCareFlow/index.d.ts +1 -0
  107. package/dist/extensions/shelly/actions/summarizeCareFlow/index.js +6 -0
  108. package/dist/extensions/shelly/actions/summarizeCareFlow/index.js.map +1 -0
  109. package/dist/extensions/shelly/actions/summarizeCareFlow/summarizeCareFlow.d.ts +4 -0
  110. package/dist/extensions/shelly/actions/summarizeCareFlow/summarizeCareFlow.js +67 -0
  111. package/dist/extensions/shelly/actions/summarizeCareFlow/summarizeCareFlow.js.map +1 -0
  112. package/dist/extensions/shelly/actions/summarizeCareFlow/summarizeCareFlow.test.d.ts +1 -0
  113. package/dist/extensions/shelly/actions/summarizeCareFlow/summarizeCareFlow.test.js +48 -0
  114. package/dist/extensions/shelly/actions/summarizeCareFlow/summarizeCareFlow.test.js.map +1 -0
  115. package/dist/extensions/shelly/actions/summarizeForm/lib/getResponseText/getResponseText.js +28 -19
  116. package/dist/extensions/shelly/actions/summarizeForm/lib/getResponseText/getResponseText.js.map +1 -1
  117. package/dist/extensions/shelly/actions/summarizeForm/summarizeForm.js +3 -28
  118. package/dist/extensions/shelly/actions/summarizeForm/summarizeForm.js.map +1 -1
  119. package/dist/extensions/shelly/actions/summarizeForm/summarizeForm.test.js +1 -3
  120. package/dist/extensions/shelly/actions/summarizeForm/summarizeForm.test.js.map +1 -1
  121. package/dist/extensions/shelly/lib/validatePayloadAndCreateSdk.d.ts +2 -2
  122. package/dist/extensions/shelly/lib/validatePayloadAndCreateSdk.js +6 -6
  123. package/dist/extensions/shelly/lib/validatePayloadAndCreateSdk.js.map +1 -1
  124. package/dist/extensions/shelly/settings.d.ts +0 -20
  125. package/dist/extensions/shelly/settings.js +0 -16
  126. package/dist/extensions/shelly/settings.js.map +1 -1
  127. package/dist/extensions/textline/actions/sendSms/config/fields.d.ts +1 -1
  128. package/dist/extensions/textline/actions/setContactConsent/config/fields.d.ts +1 -1
  129. package/dist/extensions/twilio/v2/actions/createFlowExecution/config/actionSchema.d.ts +5 -5
  130. package/dist/extensions/twilio/v2/actions/createFlowExecution/config/fields.d.ts +1 -1
  131. package/dist/extensions/twilio/v2/actions/sendSms/config/datapoints.d.ts +9 -0
  132. package/dist/extensions/twilio/v2/actions/sendSms/config/datapoints.js +13 -0
  133. package/dist/extensions/twilio/v2/actions/sendSms/config/datapoints.js.map +1 -0
  134. package/dist/extensions/twilio/v2/actions/sendSms/config/fields.d.ts +1 -1
  135. package/dist/extensions/twilio/v2/actions/sendSms/config/index.d.ts +1 -0
  136. package/dist/extensions/twilio/v2/actions/sendSms/config/index.js +3 -1
  137. package/dist/extensions/twilio/v2/actions/sendSms/config/index.js.map +1 -1
  138. package/dist/extensions/twilio/v2/actions/sendSms/sendSms.js +7 -2
  139. package/dist/extensions/twilio/v2/actions/sendSms/sendSms.js.map +1 -1
  140. package/dist/extensions/twilio/v2/actions/sendSmsDuringBusinessHours/config/fields.d.ts +1 -1
  141. package/dist/extensions/twilio/v2/actions/sendSmsWithMessagingSid/config/datapoints.d.ts +9 -0
  142. package/dist/extensions/twilio/v2/actions/sendSmsWithMessagingSid/config/datapoints.js +13 -0
  143. package/dist/extensions/twilio/v2/actions/sendSmsWithMessagingSid/config/datapoints.js.map +1 -0
  144. package/dist/extensions/twilio/v2/actions/sendSmsWithMessagingSid/config/fields.d.ts +1 -1
  145. package/dist/extensions/twilio/v2/actions/sendSmsWithMessagingSid/config/index.d.ts +1 -0
  146. package/dist/extensions/twilio/v2/actions/sendSmsWithMessagingSid/config/index.js +3 -1
  147. package/dist/extensions/twilio/v2/actions/sendSmsWithMessagingSid/config/index.js.map +1 -1
  148. package/dist/extensions/twilio/v2/actions/sendSmsWithMessagingSid/sendSmsWithMessagingService.js +7 -2
  149. package/dist/extensions/twilio/v2/actions/sendSmsWithMessagingSid/sendSmsWithMessagingService.js.map +1 -1
  150. package/dist/src/lib/awell/getLatestFormInCurrentStep/__testdata__/formDefinitionResponse.d.ts +37 -0
  151. package/dist/src/lib/awell/getLatestFormInCurrentStep/__testdata__/formDefinitionResponse.js +288 -0
  152. package/dist/src/lib/awell/getLatestFormInCurrentStep/__testdata__/formDefinitionResponse.js.map +1 -0
  153. package/dist/src/lib/awell/getLatestFormInCurrentStep/__testdata__/formResponseResponse.d.ts +17 -0
  154. package/dist/src/lib/awell/getLatestFormInCurrentStep/__testdata__/formResponseResponse.js +94 -0
  155. package/dist/src/lib/awell/getLatestFormInCurrentStep/__testdata__/formResponseResponse.js.map +1 -0
  156. package/dist/src/lib/awell/getLatestFormInCurrentStep/__testdata__/index.d.ts +3 -0
  157. package/dist/src/lib/awell/getLatestFormInCurrentStep/__testdata__/index.js +20 -0
  158. package/dist/src/lib/awell/getLatestFormInCurrentStep/__testdata__/index.js.map +1 -0
  159. package/dist/src/lib/awell/getLatestFormInCurrentStep/__testdata__/pathwayActivitiesResponse.d.ts +26 -0
  160. package/dist/src/lib/awell/getLatestFormInCurrentStep/__testdata__/pathwayActivitiesResponse.js +81 -0
  161. package/dist/src/lib/awell/getLatestFormInCurrentStep/__testdata__/pathwayActivitiesResponse.js.map +1 -0
  162. package/dist/{extensions/shelly/lib/utils/getLatestFormInStep.d.ts → src/lib/awell/getLatestFormInCurrentStep/getLatestFormInCurrentStep.d.ts} +4 -2
  163. package/dist/{extensions/shelly/lib/utils/getLatestFormInStep.js → src/lib/awell/getLatestFormInCurrentStep/getLatestFormInCurrentStep.js} +6 -4
  164. package/dist/src/lib/awell/getLatestFormInCurrentStep/getLatestFormInCurrentStep.js.map +1 -0
  165. package/dist/src/lib/awell/getLatestFormInCurrentStep/getLatestFormInCurrentStep.test.d.ts +1 -0
  166. package/dist/src/lib/awell/getLatestFormInCurrentStep/getLatestFormInCurrentStep.test.js +46 -0
  167. package/dist/src/lib/awell/getLatestFormInCurrentStep/getLatestFormInCurrentStep.test.js.map +1 -0
  168. package/dist/src/lib/awell/getLatestFormInCurrentStep/index.d.ts +1 -0
  169. package/dist/src/lib/awell/getLatestFormInCurrentStep/index.js +18 -0
  170. package/dist/src/lib/awell/getLatestFormInCurrentStep/index.js.map +1 -0
  171. package/dist/src/lib/awell/index.d.ts +1 -0
  172. package/dist/src/lib/awell/index.js +18 -0
  173. package/dist/src/lib/awell/index.js.map +1 -0
  174. package/dist/src/tests/constants.js.map +1 -1
  175. package/package.json +7 -5
  176. package/dist/extensions/shelly/lib/utils/getLatestFormInStep.js.map +0 -1
  177. package/dist/extensions/shelly/lib/utils/index.d.ts +0 -1
  178. package/dist/extensions/shelly/lib/utils/index.js +0 -6
  179. package/dist/extensions/shelly/lib/utils/index.js.map +0 -1
@@ -0,0 +1,84 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const awell_sdk_1 = require("@awell-health/awell-sdk");
4
+ const extensions_core_1 = require("@awell-health/extensions-core");
5
+ const _1 = require(".");
6
+ const genql_1 = require("@extensions/healthie/lib/sdk/genql");
7
+ const __mocks__1 = require("./__mocks__");
8
+ jest.mock('@extensions/healthie/lib/sdk/genql', () => ({
9
+ HealthieSdk: jest.fn().mockImplementation(() => ({
10
+ client: {
11
+ mutation: jest.fn().mockResolvedValue({
12
+ createFormAnswerGroup: { form_answer_group: { id: '99999' } },
13
+ }),
14
+ },
15
+ })),
16
+ }));
17
+ const mockedHealthieSdk = jest.mocked(genql_1.HealthieSdk);
18
+ describe('pushFormResponseToHealthie', () => {
19
+ const { extensionAction: action, onComplete, onError, helpers, clearMocks, } = extensions_core_1.TestHelpers.fromAction(_1.pushFormResponseToHealthie);
20
+ const awellSdkMock = {
21
+ orchestration: {
22
+ mutation: jest.fn().mockResolvedValue({}),
23
+ query: jest.fn().mockResolvedValue({
24
+ pathwayActivities: __mocks__1.mockPathwayActivitiesResponse,
25
+ form: __mocks__1.mockFormDefinitionResponse,
26
+ formResponse: __mocks__1.mockFormResponseResponse,
27
+ }),
28
+ },
29
+ /**
30
+ * Utilities don't need to be mocked so we'll just add them back in here
31
+ */
32
+ utils: new awell_sdk_1.AwellSdk({
33
+ environment: 'sandbox',
34
+ apiKey: 'sth',
35
+ }).utils,
36
+ };
37
+ helpers.awellSdk = jest.fn().mockResolvedValue(awellSdkMock);
38
+ beforeEach(() => {
39
+ clearMocks();
40
+ });
41
+ test('Should call onComplete', async () => {
42
+ const formResponseToHealthieSpy = jest.spyOn(awellSdkMock.utils.healthie, 'awellFormResponseToHealthieFormAnswers');
43
+ await action.onEvent({
44
+ payload: {
45
+ pathway: {
46
+ id: '5eN4qWbxZGSA',
47
+ definition_id: 'whatever',
48
+ },
49
+ activity: { id: 'X74HeDQ4N0gtdaSEuzF8s' },
50
+ patient: { id: 'whatever' },
51
+ fields: {
52
+ healthiePatientId: '357883',
53
+ healthieFormId: '1686361',
54
+ },
55
+ settings: {
56
+ apiUrl: 'https://staging-api.gethealthie.com/graphql',
57
+ apiKey: 'apiKey',
58
+ },
59
+ },
60
+ onComplete,
61
+ onError,
62
+ helpers,
63
+ });
64
+ expect(mockedHealthieSdk).toHaveBeenCalled();
65
+ expect(helpers.awellSdk).toHaveBeenCalledTimes(1);
66
+ expect(awellSdkMock.orchestration.query).toHaveBeenCalledTimes(3);
67
+ expect(formResponseToHealthieSpy).toHaveReturnedWith({
68
+ formAnswers: [
69
+ { answer: 'Hellemans', custom_module_id: '14460376' },
70
+ { answer: '1993-11-30', custom_module_id: '14460378' },
71
+ { answer: 'Nick', custom_module_id: '14460375' },
72
+ { answer: '123', custom_module_id: '14460377' },
73
+ ],
74
+ omittedFormAnswers: [],
75
+ });
76
+ expect(onComplete).toHaveBeenCalledWith({
77
+ data_points: {
78
+ formAnswerGroupId: '99999',
79
+ },
80
+ events: [],
81
+ });
82
+ });
83
+ });
84
+ //# sourceMappingURL=pushFormResponseToHealthie.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pushFormResponseToHealthie.test.js","sourceRoot":"","sources":["../../../../../extensions/healthie/actions/pushFormResponseToHealthie/pushFormResponseToHealthie.test.ts"],"names":[],"mappings":";;AAAA,uDAAkD;AAClD,mEAA2D;AAC3D,wBAAiE;AACjE,8DAAgE;AAChE,0CAIoB;AAEpB,IAAI,CAAC,IAAI,CAAC,oCAAoC,EAAE,GAAG,EAAE,CAAC,CAAC;IACrD,WAAW,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,kBAAkB,CAAC,GAAG,EAAE,CAAC,CAAC;QAC/C,MAAM,EAAE;YACN,QAAQ,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,iB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
1
2
  import z from 'zod';
2
3
  import { SettingsValidationSchema } from '../../settings';
3
4
  import { HealthieSdk } from './genql';
4
5
  import { getSdk } from './graphql-codegen/generated/sdk';
5
- type ValidatePayloadAndCreateSdk = <T extends z.ZodTypeAny>(args: {
6
+ import { type Activity } from '@awell-health/extensions-core/dist/types/Activity';
7
+ type ValidatePayloadAndCreateSdk = <T extends z.ZodTypeAny, P extends NewActivityPayload<any, any>>(args: {
6
8
  fieldsSchema: T;
7
- payload: unknown;
9
+ payload: P;
8
10
  }) => Promise<{
9
11
  /**
10
12
  * @deprecated DO NOT USE
@@ -14,6 +16,9 @@ type ValidatePayloadAndCreateSdk = <T extends z.ZodTypeAny>(args: {
14
16
  healthieSdk: HealthieSdk;
15
17
  fields: z.infer<(typeof args)['fieldsSchema']>;
16
18
  settings: z.infer<typeof SettingsValidationSchema>;
19
+ pathway: Pathway;
20
+ patient: Patient;
21
+ activity: Activity;
17
22
  }>;
18
23
  export declare const validatePayloadAndCreateSdk: ValidatePayloadAndCreateSdk;
19
24
  export {};
@@ -18,6 +18,7 @@ const validatePayloadAndCreateSdk = async ({ fieldsSchema, payload, }) => {
18
18
  }),
19
19
  payload,
20
20
  });
21
+ const { patient, pathway, activity } = payload;
21
22
  const client = (0, graphqlClient_1.initialiseClient)(settings);
22
23
  if (client === undefined)
23
24
  throw new Error('Healthie client cannot be undefined.');
@@ -29,7 +30,15 @@ const validatePayloadAndCreateSdk = async ({ fieldsSchema, payload, }) => {
29
30
  * New sdk, generated with GenQL
30
31
  */
31
32
  const healthieSdk = new genql_1.HealthieSdk(settings);
32
- return { settings, fields, sdk: deprecatedSdk, healthieSdk };
33
+ return {
34
+ settings,
35
+ fields,
36
+ sdk: deprecatedSdk,
37
+ healthieSdk,
38
+ patient,
39
+ pathway,
40
+ activity,
41
+ };
33
42
  };
34
43
  exports.validatePayloadAndCreateSdk = validatePayloadAndCreateSdk;
35
44
  //# sourceMappingURL=validatePayloadAndCreateSdk.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"validatePayloadAndCreateSdk.js","sourceRoot":"","sources":["../../../../../extensions/healthie/lib/sdk/validatePayloadAndCreateSdk.ts"],"names":[],"mappings":";;;;;;AAAA,mEAAwD;AACxD,8CAAmB;AACnB,6CAAyD;AACzD,mCAAqC;AACrC,yDAAwD;AACxD,mEAAkE;AAgB3D,MAAM,2BAA2B,GAAgC,KAAK,EAAE,EAC7E,YAAY,EACZ,OAAO,GACR,EAAE,EAAE;IACH,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,IAAA,0BAAQ,EAAC;QACpC,MAAM,EAAE,aAAC,CAAC,MAAM,CAAC;YACf,MAAM,EAAE,YAAY;YACpB,QAAQ,EAAE,mCAAwB;SACnC,CAAC;QACF,OAAO;KACR,CAAC,CAAA;IAEF,MAAM,MAAM,GAAG,IAAA,gCAAgB,EAAC,QAAQ,CAAC,CAAA;IAEzC,IAAI,MAAM,KAAK,SAAS;QACtB,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAA;IAEzD;;OAEG;IACH,MAAM,aAAa,GAAG,IAAA,YAAM,EAAC,MAAM,CAAC,CAAA;IAEpC;;OAEG;IACH,MAAM,WAAW,GAAG,IAAI,mBAAW,CAAC,QAAQ,CAAC,CAAA;IAE7C,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,aAAa,EAAE,WAAW,EAAE,CAAA;AAC9D,CAAC,CAAA;AA5BY,QAAA,2BAA2B,+BA4BvC"}
1
+ {"version":3,"file":"validatePayloadAndCreateSdk.js","sourceRoot":"","sources":["../../../../../extensions/healthie/lib/sdk/validatePayloadAndCreateSdk.ts"],"names":[],"mappings":";;;;;;AAAA,mEAKsC;AACtC,8CAAmB;AACnB,6CAAyD;AACzD,mCAAqC;AACrC,yDAAwD;AACxD,mEAAkE;AAuB3D,MAAM,2BAA2B,GAAgC,KAAK,EAAE,EAC7E,YAAY,EACZ,OAAO,GACR,EAAE,EAAE;IACH,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,IAAA,0BAAQ,EAAC;QACpC,MAAM,EAAE,aAAC,CAAC,MAAM,CAAC;YACf,MAAM,EAAE,YAAY;YACpB,QAAQ,EAAE,mCAAwB;SACnC,CAAC;QACF,OAAO;KACR,CAAC,CAAA;IAEF,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAA;IAE9C,MAAM,MAAM,GAAG,IAAA,gCAAgB,EAAC,QAAQ,CAAC,CAAA;IAEzC,IAAI,MAAM,KAAK,SAAS;QACtB,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAA;IAEzD;;OAEG;IACH,MAAM,aAAa,GAAG,IAAA,YAAM,EAAC,MAAM,CAAC,CAAA;IAEpC;;OAEG;IACH,MAAM,WAAW,GAAG,IAAI,mBAAW,CAAC,QAAQ,CAAC,CAAA;IAE7C,OAAO;QACL,QAAQ;QACR,MAAM;QACN,GAAG,EAAE,aAAa;QAClB,WAAW;QACX,OAAO;QACP,OAAO;QACP,QAAQ;KACT,CAAA;AACH,CAAC,CAAA;AAtCY,QAAA,2BAA2B,+BAsCvC"}
@@ -0,0 +1,4 @@
1
+ import { type Action } from '@awell-health/extensions-core';
2
+ import { type settings } from '../../settings';
3
+ import { fields, dataPoints } from './config';
4
+ export declare const categorizeMessage: Action<typeof fields, typeof settings, keyof typeof dataPoints>;
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.categorizeMessage = void 0;
4
+ const extensions_core_1 = require("@awell-health/extensions-core");
5
+ const categorizeMessageWithLLM_1 = require("./lib/categorizeMessageWithLLM");
6
+ const lib_1 = require("../../lib");
7
+ const config_1 = require("./config");
8
+ exports.categorizeMessage = {
9
+ key: 'categorizeMessage',
10
+ category: extensions_core_1.Category.WORKFLOW,
11
+ title: 'Categorize Message',
12
+ description: 'Categorize the input message into set of predefined categories',
13
+ fields: config_1.fields,
14
+ previewable: false,
15
+ dataPoints: config_1.dataPoints,
16
+ onEvent: async ({ payload, onComplete, onError, helpers }) => {
17
+ const { langChainOpenAiSdk, fields: { categories, message }, } = await (0, lib_1.validatePayloadAndCreateSdk)({
18
+ fieldsSchema: config_1.FieldsValidationSchema,
19
+ payload,
20
+ });
21
+ try {
22
+ const category = await (0, categorizeMessageWithLLM_1.categorizeMessageWithLLM)({
23
+ langChainOpenAiSdk,
24
+ message,
25
+ categories,
26
+ });
27
+ await onComplete({
28
+ data_points: {
29
+ category,
30
+ },
31
+ });
32
+ }
33
+ catch (error) {
34
+ console.error('Error categorizing message:', error);
35
+ // Catch in extention server
36
+ throw new Error('Error categorizing message');
37
+ }
38
+ },
39
+ };
40
+ //# sourceMappingURL=categorizeMessage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"categorizeMessage.js","sourceRoot":"","sources":["../../../../../extensions/shelly/actions/categorizeMessage/categorizeMessage.ts"],"names":[],"mappings":";;;AAAA,mEAAqE;AACrE,6EAAyE;AACzE,mCAAuD;AAEvD,qCAAqE;AAExD,QAAA,iBAAiB,GAI1B;IACF,GAAG,EAAE,mBAAmB;IACxB,QAAQ,EAAE,0BAAQ,CAAC,QAAQ;IAC3B,KAAK,EAAE,oBAAoB;IAC3B,WAAW,EAAE,gEAAgE;IAC7E,MAAM,EAAN,eAAM;IACN,WAAW,EAAE,KAAK;IAClB,UAAU,EAAV,mBAAU;IACV,OAAO,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,EAAiB,EAAE;QAC1E,MAAM,EACJ,kBAAkB,EAClB,MAAM,EAAE,EAAE,UAAU,EAAE,OAAO,EAAE,GAChC,GAAG,MAAM,IAAA,iCAA2B,EAAC;YACpC,YAAY,EAAE,+BAAsB;YACpC,OAAO;SACR,CAAC,CAAA;QAEF,IAAI;YACF,MAAM,QAAQ,GAAG,MAAM,IAAA,mDAAwB,EAAC;gBAC9C,kBAAkB;gBAClB,OAAO;gBACP,UAAU;aACX,CAAC,CAAA;YAEF,MAAM,UAAU,CAAC;gBACf,WAAW,EAAE;oBACX,QAAQ;iBACT;aACF,CAAC,CAAA;SACH;QAAC,OAAO,KAAK,EAAE;YACd,OAAO,CAAC,KAAK,CAAC,6BAA6B,EAAE,KAAK,CAAC,CAAA;YACnD,4BAA4B;YAC5B,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAA;SAC9C;IACH,CAAC;CACF,CAAA"}
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const extensions_core_1 = require("@awell-health/extensions-core");
4
+ const tests_1 = require("@/tests");
5
+ const _1 = require(".");
6
+ const openai_1 = require("@langchain/openai");
7
+ jest.mock('@langchain/openai', () => ({
8
+ OpenAI: jest.fn().mockImplementation(() => ({
9
+ pipe: jest.fn().mockReturnThis(),
10
+ invoke: jest.fn().mockResolvedValue({
11
+ matched_entity: 'Appointment Scheduling',
12
+ }),
13
+ })),
14
+ }));
15
+ const mockedOpenAiSdk = jest.mocked(openai_1.OpenAI);
16
+ describe('categorizeMessage - Mocked LLM calls', () => {
17
+ const { onComplete, onError, helpers, extensionAction, clearMocks } = extensions_core_1.TestHelpers.fromAction(_1.categorizeMessage);
18
+ beforeEach(() => {
19
+ clearMocks();
20
+ jest.clearAllMocks();
21
+ });
22
+ it('should work', async () => {
23
+ const mockedOpenAiInstance = new openai_1.OpenAI();
24
+ jest.spyOn(mockedOpenAiInstance, 'invoke').mockResolvedValue({
25
+ // @ts-expect-error fine, we have a parser
26
+ matched_entity: 'Appointment Scheduling',
27
+ });
28
+ const categorizeMessageWithLLMSpy = jest.spyOn(require('./lib/categorizeMessageWithLLM'), 'categorizeMessageWithLLM');
29
+ const payload = (0, tests_1.generateTestPayload)({
30
+ fields: {
31
+ message: 'I would like to schedule an appointment for next week.',
32
+ categories: 'Appointment Scheduling,Medication Questions,Administrative Assistance,Feedback or Complaints',
33
+ },
34
+ settings: {
35
+ openAiApiKey: 'a',
36
+ },
37
+ });
38
+ await extensionAction.onEvent({
39
+ payload,
40
+ onComplete,
41
+ onError,
42
+ helpers,
43
+ });
44
+ expect(mockedOpenAiSdk).toHaveBeenCalled();
45
+ expect(categorizeMessageWithLLMSpy).toHaveBeenCalledWith({
46
+ langChainOpenAiSdk: expect.any(Object),
47
+ message: 'I would like to schedule an appointment for next week.',
48
+ categories: [
49
+ 'Appointment Scheduling',
50
+ 'Medication Questions',
51
+ 'Administrative Assistance',
52
+ 'Feedback or Complaints',
53
+ ],
54
+ });
55
+ expect(onComplete).toHaveBeenCalledWith({
56
+ data_points: {
57
+ category: 'Appointment Scheduling', // Expected category
58
+ },
59
+ });
60
+ expect(onError).not.toHaveBeenCalled();
61
+ });
62
+ });
63
+ //# sourceMappingURL=categorizeMessage.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"categorizeMessage.test.js","sourceRoot":"","sources":["../../../../../extensions/shelly/actions/categorizeMessage/categorizeMessage.test.ts"],"names":[],"mappings":";;AAAA,mEAA2D;AAC3D,mCAA6C;AAC7C,wBAAqC;AACrC,8CAA0C;AAE1C,IAAI,CAAC,IAAI,CAAC,mBAAmB,EAAE,GAAG,EAAE,CAAC,CAAC;IACpC,MAAM,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,kBAAkB,CAAC,GAAG,EAAE,CAAC,CAAC;QAC1C,IAAI,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,cAAc,EAAE;QAChC,MAAM,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,iBAAiB,CAAC;YAClC,cAAc,EAAE,wBAAwB;SACzC,CAAC;KACH,CAAC,CAAC;CACJ,CAAC,CAAC,CAAA;AAEH,MAAM,eAAe,GAAG,IAAI,CAAC,MAAM,CAAC,eAAM,CAAC,CAAA;AAE3C,QAAQ,CAAC,sCAAsC,EAAE,GAAG,EAAE;IACpD,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,eAAe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F,CAAC,CAAA;QAEF,MAAM,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,gBAAgB,EAAE,CAAA;IACxC,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
@@ -0,0 +1,6 @@
1
+ export declare const dataPoints: {
2
+ category: {
3
+ key: string;
4
+ valueType: "string";
5
+ };
6
+ };
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.dataPoints = void 0;
4
+ exports.dataPoints = {
5
+ category: {
6
+ key: 'category',
7
+ valueType: 'string',
8
+ },
9
+ };
10
+ //# sourceMappingURL=datapoints.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"datapoints.js","sourceRoot":"","sources":["../../../../../../extensions/shelly/actions/categorizeMessage/config/datapoints.ts"],"names":[],"mappings":";;;AAEa,QAAA,UAAU,GAAG;IACxB,QAAQ,EAAE;QACR,GAAG,EAAE,UAAU;QACf,SAAS,EAAE,QAAQ;KACpB;CAC4C,CAAA"}
@@ -0,0 +1,28 @@
1
+ import { FieldType } from '@awell-health/extensions-core';
2
+ import z from 'zod';
3
+ export declare const fields: {
4
+ message: {
5
+ id: string;
6
+ label: string;
7
+ description: string;
8
+ type: FieldType.STRING;
9
+ required: true;
10
+ };
11
+ categories: {
12
+ id: string;
13
+ label: string;
14
+ description: string;
15
+ type: FieldType.STRING;
16
+ required: true;
17
+ };
18
+ };
19
+ export declare const FieldsValidationSchema: z.ZodObject<{
20
+ message: z.ZodString;
21
+ categories: z.ZodEffects<z.ZodEffects<z.ZodString, string[], string>, string[], string>;
22
+ }, "strip", z.ZodTypeAny, {
23
+ message: string;
24
+ categories: string[];
25
+ }, {
26
+ message: string;
27
+ categories: string;
28
+ }>;
@@ -0,0 +1,36 @@
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 zod_1 = __importDefault(require("zod"));
9
+ exports.fields = {
10
+ message: {
11
+ id: 'message',
12
+ label: 'Message',
13
+ description: 'The message to be categorized',
14
+ type: extensions_core_1.FieldType.STRING,
15
+ required: true,
16
+ },
17
+ categories: {
18
+ id: 'categories',
19
+ label: 'Categories',
20
+ description: 'List of categories (comma-separated, no spaces)',
21
+ type: extensions_core_1.FieldType.STRING,
22
+ required: true,
23
+ },
24
+ };
25
+ exports.FieldsValidationSchema = zod_1.default.object({
26
+ message: zod_1.default.string().min(1, 'Message is required'),
27
+ categories: zod_1.default
28
+ .string()
29
+ .trim()
30
+ .min(1, 'At least one category is required')
31
+ .transform((s) => s.split(',').map((item) => item.trim()))
32
+ .refine((arr) => arr.length > 0, {
33
+ message: 'At least one category is required',
34
+ }),
35
+ });
36
+ //# sourceMappingURL=fields.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fields.js","sourceRoot":"","sources":["../../../../../../extensions/shelly/actions/categorizeMessage/config/fields.ts"],"names":[],"mappings":";;;;;;AAAA,mEAAqE;AACrE,8CAAwC;AAC3B,QAAA,MAAM,GAAG;IACpB,OAAO,EAAE;QACP,EAAE,EAAE,SAAS;QACb,KAAK,EAAE,SAAS;QAChB,WAAW,EAAE,+BAA+B;QAC5C,IAAI,EAAE,2BAAS,CAAC,MAAM;QACtB,QAAQ,EAAE,IAAI;KACf;IACD,UAAU,EAAE;QACV,EAAE,EAAE,YAAY;QAChB,KAAK,EAAE,YAAY;QACnB,WAAW,EAAE,iDAAiD;QAC9D,IAAI,EAAE,2BAAS,CAAC,MAAM;QACtB,QAAQ,EAAE,IAAI;KACf;CAC8B,CAAA;AAEpB,QAAA,sBAAsB,GAAG,aAAC,CAAC,MAAM,CAAC;IAC7C,OAAO,EAAE,aAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,qBAAqB,CAAC;IACjD,UAAU,EAAE,aAAC;SACV,MAAM,EAAE;SACR,IAAI,EAAE;SACN,GAAG,CAAC,CAAC,EAAE,mCAAmC,CAAC;SAC3C,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;SACzD,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC,EAAE;QAC/B,OAAO,EAAE,mCAAmC;KAC7C,CAAC;CAC6C,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/categorizeMessage/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 { categorizeMessage } from './categorizeMessage';
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.categorizeMessage = void 0;
4
+ var categorizeMessage_1 = require("./categorizeMessage");
5
+ Object.defineProperty(exports, "categorizeMessage", { enumerable: true, get: function () { return categorizeMessage_1.categorizeMessage; } });
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../extensions/shelly/actions/categorizeMessage/index.ts"],"names":[],"mappings":";;;AAAA,yDAAuD;AAA9C,sHAAA,iBAAiB,OAAA"}
@@ -0,0 +1,6 @@
1
+ import { type OpenAI } from '@langchain/openai';
2
+ export declare const categorizeMessageWithLLM: ({ langChainOpenAiSdk, message, categories, }: {
3
+ langChainOpenAiSdk: OpenAI;
4
+ message: string;
5
+ categories: string[];
6
+ }) => Promise<string>;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.categorizeMessageWithLLM = void 0;
4
+ const constants_1 = require("./constants");
5
+ const categorizeMessageWithLLM = async ({ langChainOpenAiSdk, message, categories, }) => {
6
+ var _a;
7
+ const prompt = await constants_1.systemPrompt.format({
8
+ categories: categories.concat('None').join(', '),
9
+ input: message,
10
+ });
11
+ const chain = langChainOpenAiSdk.pipe(constants_1.parser);
12
+ console.log('Prompt:', prompt);
13
+ const result = await chain.invoke(prompt);
14
+ console.log('Result', typeof result);
15
+ const matchedEntity = (_a = result.matched_entity) !== null && _a !== void 0 ? _a : 'None';
16
+ console.log('I am matching:', matchedEntity);
17
+ // Ensure that the returned matched entity is valid
18
+ const category = categories.includes(matchedEntity) ? matchedEntity : 'None';
19
+ return category;
20
+ };
21
+ exports.categorizeMessageWithLLM = categorizeMessageWithLLM;
22
+ //# sourceMappingURL=categorizeMessageWithLLM.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"categorizeMessageWithLLM.js","sourceRoot":"","sources":["../../../../../../../extensions/shelly/actions/categorizeMessage/lib/categorizeMessageWithLLM/categorizeMessageWithLLM.ts"],"names":[],"mappings":";;;AAAA,2CAAkD;AAG3C,MAAM,wBAAwB,GAAG,KAAK,EAAE,EAC7C,kBAAkB,EAClB,OAAO,EACP,UAAU,GAKX,EAAmB,EAAE;;IACpB,MAAM,MAAM,GAAG,MAAM,wBAAY,CAAC,MAAM,CAAC;QACvC,UAAU,EAAE,UAAU,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;QAChD,KAAK,EAAE,OAAO;KACf,CAAC,CAAA;IAEF,MAAM,KAAK,GAAG,kBAAkB,CAAC,IAAI,CAAC,kBAAM,CAAC,CAAA;IAC7C,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,MAAM,CAAC,CAAA;IAC9B,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;IAEzC,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,OAAO,MAAM,CAAC,CAAA;IAEpC,MAAM,aAAa,GAAG,MAAA,MAAM,CAAC,cAAc,mCAAI,MAAM,CAAA;IACrD,OAAO,CAAC,GAAG,CAAC,gBAAgB,EAAE,aAAa,CAAC,CAAA;IAE5C,mDAAmD;IACnD,MAAM,QAAQ,GAAG,UAAU,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,MAAM,CAAA;IAE5E,OAAO,QAAQ,CAAA;AACjB,CAAC,CAAA;AA3BY,QAAA,wBAAwB,4BA2BpC"}
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ require("dotenv/config");
4
+ const _1 = require("./");
5
+ describe('categorizeMessageWithLLM', () => {
6
+ let langChainOpenAiSdkMock;
7
+ beforeEach(() => {
8
+ // Create a mock for langChainOpenAiSdk
9
+ langChainOpenAiSdkMock = {
10
+ pipe: jest.fn().mockReturnThis(),
11
+ invoke: jest.fn(), // Will mock this separately for each test
12
+ };
13
+ });
14
+ it('should categorize a message about scheduling an appointment using real LLM', async () => {
15
+ langChainOpenAiSdkMock.invoke.mockResolvedValue({
16
+ // @ts-expect-error it's fine, we have a parser
17
+ matched_entity: 'Appointment Scheduling',
18
+ });
19
+ const categories = [
20
+ 'Appointment Scheduling',
21
+ 'Medical Symptoms Inquiry',
22
+ 'Medication Questions',
23
+ 'Administrative Assistance',
24
+ ];
25
+ const message = 'I would like to schedule an appointment for next week.';
26
+ const result = await (0, _1.categorizeMessageWithLLM)({
27
+ langChainOpenAiSdk: langChainOpenAiSdkMock,
28
+ message,
29
+ categories,
30
+ });
31
+ expect(result).toBe('Appointment Scheduling'); // Expected category
32
+ });
33
+ it('should categorize a message about medication using real LLM', async () => {
34
+ langChainOpenAiSdkMock.invoke.mockResolvedValue({
35
+ // @ts-expect-error it's fine, we have a parser
36
+ matched_entity: 'Medication Questions',
37
+ });
38
+ const categories = [
39
+ 'Appointment Scheduling',
40
+ 'Medical Symptoms Inquiry',
41
+ 'Medication Questions',
42
+ 'Administrative Assistance',
43
+ ];
44
+ const message = 'Can you tell me the correct dosage for my medication?';
45
+ const result = await (0, _1.categorizeMessageWithLLM)({
46
+ langChainOpenAiSdk: langChainOpenAiSdkMock,
47
+ message,
48
+ categories,
49
+ });
50
+ expect(result).toBe('Medication Questions'); // Expected category
51
+ });
52
+ it('should return "None" when the message does not match any category using real LLM', async () => {
53
+ langChainOpenAiSdkMock.invoke.mockResolvedValue({
54
+ // @ts-expect-error it's fine, we have a parser
55
+ matched_entity: 'None',
56
+ });
57
+ const categories = [
58
+ 'Appointment Scheduling',
59
+ 'Medical Symptoms Inquiry',
60
+ 'Medication Questions',
61
+ 'Administrative Assistance',
62
+ ];
63
+ const message = 'Is it going to rain tomorrow?'; // Non-related medical category
64
+ const result = await (0, _1.categorizeMessageWithLLM)({
65
+ langChainOpenAiSdk: langChainOpenAiSdkMock,
66
+ message,
67
+ categories,
68
+ });
69
+ expect(result).toBe('None'); // No match expected
70
+ });
71
+ });
72
+ //# sourceMappingURL=categorizeMessageWithLLM.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"categorizeMessageWithLLM.test.js","sourceRoot":"","sources":["../../../../../../../extensions/shelly/actions/categorizeMessage/lib/categorizeMessageWithLLM/categorizeMessageWithLLM.test.ts"],"names":[],"mappings":";;AAAA,yBAAsB;AACtB,yBAA6C;AAG7C,QAAQ,CAAC,0BAA0B,EAAE,GAAG,EAAE;IACxC,IAAI,sBAA2C,CAAA;IAE/C,UAAU,CAAC,GAAG,EAAE;QACd,uCAAuC;QACvC,sBAAsB,GAAG;YACvB,IAAI,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,cAAc,EAAE;YAChC,MAAM,EAAE,IAAI,CAAC,EAAE,EAAE,EAAE,0CAA0C;SAC5B,CAAA;IACrC,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,4EAA4E,EAAE,KAAK,IAAI,EAAE;QAC1F,sBAAsB,CAAC,MAAM,CAAC,iBAAiB,CAAC;YAC9C,+CAA+C;YAC/C,cAAc,EAAE,wBAAwB;SACzC,CAAC,CAAA;QAEF,MAAM,UAAU,GAAG;YACjB,wBAAwB;YACxB,0BAA0B;YAC1B,sBAAsB;YACtB,2BAA2B;SAC5B,CAAA;QACD,MAAM,OAAO,GAAG,wDAAwD,CAAA;QAExE,MAAM,MAAM,GAAG,MAAM,IAAA,2BAAwB,EAAC;YAC5C,kBAAkB,EAAE,sBAAsB;YAC1C,OAAO;YACP,UAAU;SACX,CAAC,CAAA;QAEF,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAA,CAAC,oBAAoB;IACpE,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,6DAA6D,EAAE,KAAK,IAAI,EAAE;QAC3E,sBAAsB,CAAC,MAAM,CAAC,iBAAiB,CAAC;YAC9C,+CAA+C;YAC/C,cAAc,EAAE,sBAAsB;SACvC,CAAC,CAAA;QAEF,MAAM,UAAU,GAAG;YACjB,wBAAwB;YACxB,0BAA0B;YAC1B,sBAAsB;YACtB,2BAA2B;SAC5B,CAAA;QACD,MAAM,OAAO,GAAG,uDAAuD,CAAA;QAEvE,MAAM,MAAM,GAAG,MAAM,IAAA,2BAAwB,EAAC;YAC5C,kBAAkB,EAAE,sBAAsB;YAC1C,OAAO;YACP,UAAU;SACX,CAAC,CAAA;QAEF,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAA,CAAC,oBAAoB;IAClE,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,kFAAkF,EAAE,KAAK,IAAI,EAAE;QAChG,sBAAsB,CAAC,MAAM,CAAC,iBAAiB,CAAC;YAC9C,+CAA+C;YAC/C,cAAc,EAAE,MAAM;SACvB,CAAC,CAAA;QAEF,MAAM,UAAU,GAAG;YACjB,wBAAwB;YACxB,0BAA0B;YAC1B,sBAAsB;YACtB,2BAA2B;SAC5B,CAAA;QACD,MAAM,OAAO,GAAG,+BAA+B,CAAA,CAAC,+BAA+B;QAE/E,MAAM,MAAM,GAAG,MAAM,IAAA,2BAAwB,EAAC;YAC5C,kBAAkB,EAAE,sBAAsB;YAC1C,OAAO;YACP,UAAU;SACX,CAAC,CAAA;QAEF,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA,CAAC,oBAAoB;IAClD,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
@@ -0,0 +1,18 @@
1
+ import { ChatPromptTemplate } from '@langchain/core/prompts';
2
+ import { StructuredOutputParser } from 'langchain/output_parsers';
3
+ import { z } from 'zod';
4
+ export declare const messageCategoriesSchema: z.ZodObject<{
5
+ matched_entity: z.ZodDefault<z.ZodOptional<z.ZodString>>;
6
+ }, "strip", z.ZodTypeAny, {
7
+ matched_entity: string;
8
+ }, {
9
+ matched_entity?: string | undefined;
10
+ }>;
11
+ export declare const parser: StructuredOutputParser<z.ZodObject<{
12
+ matched_entity: z.ZodDefault<z.ZodOptional<z.ZodString>>;
13
+ }, "strip", z.ZodTypeAny, {
14
+ matched_entity: string;
15
+ }, {
16
+ matched_entity?: string | undefined;
17
+ }>>;
18
+ export declare const systemPrompt: ChatPromptTemplate<import("@langchain/core/prompts").ParamsFromFString<"\n You are an expert in categorizing messages. Your task is to match the provided message to one of the following categories: {categories}.\n If no match is found, return \"None.\"\n \n Please respond with a valid JSON object with the following key: matched_entity.\n \n \n Input:\n {input}\n ">, any>;
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.systemPrompt = exports.parser = exports.messageCategoriesSchema = void 0;
4
+ const prompts_1 = require("@langchain/core/prompts");
5
+ const output_parsers_1 = require("langchain/output_parsers");
6
+ const zod_1 = require("zod");
7
+ // Define the Zod schema for the structured response
8
+ exports.messageCategoriesSchema = zod_1.z.object({
9
+ matched_entity: zod_1.z.string().optional().default('None'), // The matched category
10
+ });
11
+ // Create a structured output parser
12
+ exports.parser = output_parsers_1.StructuredOutputParser.fromZodSchema(exports.messageCategoriesSchema);
13
+ // Update the prompt to enforce a structured JSON response
14
+ exports.systemPrompt = prompts_1.ChatPromptTemplate.fromTemplate(`
15
+ You are an expert in categorizing messages. Your task is to match the provided message to one of the following categories: {categories}.
16
+ If no match is found, return "None."
17
+
18
+ Please respond with a valid JSON object with the following key: matched_entity.
19
+
20
+
21
+ Input:
22
+ {input}
23
+ `);
24
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../../../extensions/shelly/actions/categorizeMessage/lib/categorizeMessageWithLLM/constants.ts"],"names":[],"mappings":";;;AAAA,qDAA4D;AAC5D,6DAAiE;AACjE,6BAAuB;AAEvB,oDAAoD;AACvC,QAAA,uBAAuB,GAAG,OAAC,CAAC,MAAM,CAAC;IAC9C,cAAc,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,uBAAuB;CAC/E,CAAC,CAAA;AAEF,oCAAoC;AACvB,QAAA,MAAM,GAAG,uCAAsB,CAAC,aAAa,CACxD,+BAAuB,CACxB,CAAA;AAED,0DAA0D;AAC7C,QAAA,YAAY,GAAG,4BAAkB,CAAC,YAAY,CAAC;;;;;;;;;OASrD,CAAC,CAAA"}
@@ -0,0 +1 @@
1
+ export { categorizeMessageWithLLM } from './categorizeMessageWithLLM';
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.categorizeMessageWithLLM = void 0;
4
+ var categorizeMessageWithLLM_1 = require("./categorizeMessageWithLLM");
5
+ Object.defineProperty(exports, "categorizeMessageWithLLM", { enumerable: true, get: function () { return categorizeMessageWithLLM_1.categorizeMessageWithLLM; } });
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../extensions/shelly/actions/categorizeMessage/lib/categorizeMessageWithLLM/index.ts"],"names":[],"mappings":";;;AAAA,uEAAqE;AAA5D,oIAAA,wBAAwB,OAAA"}
@@ -0,0 +1 @@
1
+ import 'dotenv/config';