@awell-health/awell-extensions 2.0.9 → 2.0.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. package/dist/extensions/index.js +2 -0
  2. package/dist/extensions/index.js.map +1 -1
  3. package/dist/extensions/markdown.json +4 -0
  4. package/dist/extensions/shelly/actions/index.d.ts +34 -0
  5. package/dist/extensions/shelly/actions/index.js +8 -0
  6. package/dist/extensions/shelly/actions/index.js.map +1 -0
  7. package/dist/extensions/shelly/actions/summarizeForm/config/datapoints.d.ts +6 -0
  8. package/dist/extensions/shelly/actions/summarizeForm/config/datapoints.js +10 -0
  9. package/dist/extensions/shelly/actions/summarizeForm/config/datapoints.js.map +1 -0
  10. package/dist/extensions/shelly/actions/summarizeForm/config/fields.d.ts +18 -0
  11. package/dist/extensions/shelly/actions/summarizeForm/config/fields.js +21 -0
  12. package/dist/extensions/shelly/actions/summarizeForm/config/fields.js.map +1 -0
  13. package/dist/extensions/shelly/actions/summarizeForm/config/index.d.ts +2 -0
  14. package/dist/extensions/shelly/actions/summarizeForm/config/index.js +9 -0
  15. package/dist/extensions/shelly/actions/summarizeForm/config/index.js.map +1 -0
  16. package/dist/extensions/shelly/actions/summarizeForm/index.d.ts +1 -0
  17. package/dist/extensions/shelly/actions/summarizeForm/index.js +6 -0
  18. package/dist/extensions/shelly/actions/summarizeForm/index.js.map +1 -0
  19. package/dist/extensions/shelly/actions/summarizeForm/lib/getResponseText/getResponseText.d.ts +12 -0
  20. package/dist/extensions/shelly/actions/summarizeForm/lib/getResponseText/getResponseText.js +73 -0
  21. package/dist/extensions/shelly/actions/summarizeForm/lib/getResponseText/getResponseText.js.map +1 -0
  22. package/dist/extensions/shelly/actions/summarizeForm/lib/getResponseText/index.d.ts +1 -0
  23. package/dist/extensions/shelly/actions/summarizeForm/lib/getResponseText/index.js +6 -0
  24. package/dist/extensions/shelly/actions/summarizeForm/lib/getResponseText/index.js.map +1 -0
  25. package/dist/extensions/shelly/actions/summarizeForm/summarizeForm.d.ts +4 -0
  26. package/dist/extensions/shelly/actions/summarizeForm/summarizeForm.js +64 -0
  27. package/dist/extensions/shelly/actions/summarizeForm/summarizeForm.js.map +1 -0
  28. package/dist/extensions/shelly/actions/summarizeForm/summarizeForm.test.d.ts +1 -0
  29. package/dist/extensions/shelly/actions/summarizeForm/summarizeForm.test.js +57 -0
  30. package/dist/extensions/shelly/actions/summarizeForm/summarizeForm.test.js.map +1 -0
  31. package/dist/extensions/shelly/index.d.ts +2 -0
  32. package/dist/extensions/shelly/index.js +22 -0
  33. package/dist/extensions/shelly/index.js.map +1 -0
  34. package/dist/extensions/shelly/lib/constants.d.ts +1 -0
  35. package/dist/extensions/shelly/lib/constants.js +5 -0
  36. package/dist/extensions/shelly/lib/constants.js.map +1 -0
  37. package/dist/extensions/shelly/lib/index.d.ts +1 -0
  38. package/dist/extensions/shelly/lib/index.js +6 -0
  39. package/dist/extensions/shelly/lib/index.js.map +1 -0
  40. package/dist/extensions/shelly/lib/utils/getLatestFormInStep.d.ts +11 -0
  41. package/dist/extensions/shelly/lib/utils/getLatestFormInStep.js +79 -0
  42. package/dist/extensions/shelly/lib/utils/getLatestFormInStep.js.map +1 -0
  43. package/dist/extensions/shelly/lib/utils/index.d.ts +1 -0
  44. package/dist/extensions/shelly/lib/utils/index.js +6 -0
  45. package/dist/extensions/shelly/lib/utils/index.js.map +1 -0
  46. package/dist/extensions/shelly/lib/validatePayloadAndCreateSdk.d.ts +18 -0
  47. package/dist/extensions/shelly/lib/validatePayloadAndCreateSdk.js +31 -0
  48. package/dist/extensions/shelly/lib/validatePayloadAndCreateSdk.js.map +1 -0
  49. package/dist/extensions/shelly/settings.d.ts +37 -0
  50. package/dist/extensions/shelly/settings.js +33 -0
  51. package/dist/extensions/shelly/settings.js.map +1 -0
  52. package/package.json +2 -2
@@ -55,6 +55,7 @@ const rest_1 = require("./rest");
55
55
  const sendbird_1 = require("./sendbird");
56
56
  const sendgrid_extension_1 = require("./sendgrid-extension");
57
57
  const sfdc_1 = require("./sfdc");
58
+ const shelly_1 = require("./shelly");
58
59
  const stripe_1 = require("./stripe");
59
60
  const talkDesk_1 = require("./talkDesk");
60
61
  const textline_1 = require("./textline");
@@ -97,6 +98,7 @@ exports.extensions = [
97
98
  sendbird_1.Sendbird,
98
99
  sendgrid_extension_1.Sendgrid,
99
100
  sfdc_1.sfdc,
101
+ shelly_1.shelly,
100
102
  stripe_1.stripe,
101
103
  talkDesk_1.TalkDesk,
102
104
  textline_1.TextLine,
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../extensions/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAA6C;AAC7C,mCAA+B;AAC/B,2CAAuC;AACvC,yCAAqC;AACrC,mDAA+C;AAC/C,6CAAyC;AACzC,yCAAqC;AACrC,+CAA2C;AAC3C,6CAAyC;AACzC,yCAAqC;AACrC,+CAA2C;AAC3C,uCAAmC;AACnC,iDAA6C;AAC7C,uDAAkD;AAClD,yCAAqC;AACrC,yCAAqC;AACrC,+CAA0C;AAC1C,iEAA6D;AAC7D,uCAAmC;AACnC,yCAAqC;AACrC,2CAAuC;AACvC,uCAAmC;AACnC,iCAAsC;AACtC,uCAAmC;AACnC,+CAA2C;AAC3C,2CAAuC;AACvC,+CAA2C;AAC3C,iCAA6B;AAC7B,yCAAqC;AACrC,6DAA+C;AAC/C,iCAA6B;AAC7B,qCAAiC;AACjC,yCAAqC;AACrC,yCAAqC;AACrC,2CAAuC;AACvC,qCAAiC;AACjC,uCAAmC;AACnC,yCAAqC;AACrC,uCAAmC;AAEnC,sDAAuC;AAG1B,QAAA,QAAQ,GAAa,IAAI,CAAA;AAEzB,QAAA,UAAU,GAAG;IACxB,2BAAY;IACZ,aAAK;IACL,qBAAS;IACT,mBAAQ;IACR,6BAAa;IACb,uBAAU;IACV,mBAAQ;IACR,yBAAW;IACX,uBAAU;IACV,mBAAQ;IACR,yBAAW;IACX,iBAAO;IACP,2BAAY;IACZ,gCAAc;IACd,mBAAQ;IACR,mBAAQ;IACR,wBAAU;IACV,2CAAoB;IACpB,iBAAO;IACP,mBAAQ;IACR,qBAAS;IACT,iBAAO;IACP,oBAAa;IACb,yBAAW;IACX,iBAAO;IACP,qBAAS;IACT,yBAAW;IACX,WAAI;IACJ,mBAAQ;IACR,6BAAQ;IACR,WAAI;IACJ,eAAM;IACN,mBAAQ;IACR,mBAAQ;IACR,qBAAS;IACT,eAAM;IACN,iBAAO;IACP,mBAAQ;IACR,iBAAO;CACR,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../extensions/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAA6C;AAC7C,mCAA+B;AAC/B,2CAAuC;AACvC,yCAAqC;AACrC,mDAA+C;AAC/C,6CAAyC;AACzC,yCAAqC;AACrC,+CAA2C;AAC3C,6CAAyC;AACzC,yCAAqC;AACrC,+CAA2C;AAC3C,uCAAmC;AACnC,iDAA6C;AAC7C,uDAAkD;AAClD,yCAAqC;AACrC,yCAAqC;AACrC,+CAA0C;AAC1C,iEAA6D;AAC7D,uCAAmC;AACnC,yCAAqC;AACrC,2CAAuC;AACvC,uCAAmC;AACnC,iCAAsC;AACtC,uCAAmC;AACnC,+CAA2C;AAC3C,2CAAuC;AACvC,+CAA2C;AAC3C,iCAA6B;AAC7B,yCAAqC;AACrC,6DAA+C;AAC/C,iCAA6B;AAC7B,qCAAiC;AACjC,qCAAiC;AACjC,yCAAqC;AACrC,yCAAqC;AACrC,2CAAuC;AACvC,qCAAiC;AACjC,uCAAmC;AACnC,yCAAqC;AACrC,uCAAmC;AAEnC,sDAAuC;AAG1B,QAAA,QAAQ,GAAa,IAAI,CAAA;AAEzB,QAAA,UAAU,GAAG;IACxB,2BAAY;IACZ,aAAK;IACL,qBAAS;IACT,mBAAQ;IACR,6BAAa;IACb,uBAAU;IACV,mBAAQ;IACR,yBAAW;IACX,uBAAU;IACV,mBAAQ;IACR,yBAAW;IACX,iBAAO;IACP,2BAAY;IACZ,gCAAc;IACd,mBAAQ;IACR,mBAAQ;IACR,wBAAU;IACV,2CAAoB;IACpB,iBAAO;IACP,mBAAQ;IACR,qBAAS;IACT,iBAAO;IACP,oBAAa;IACb,yBAAW;IACX,iBAAO;IACP,qBAAS;IACT,yBAAW;IACX,WAAI;IACJ,mBAAQ;IACR,6BAAQ;IACR,WAAI;IACJ,eAAM;IACN,eAAM;IACN,mBAAQ;IACR,mBAAQ;IACR,qBAAS;IACT,eAAM;IACN,iBAAO;IACP,mBAAQ;IACR,iBAAO;CACR,CAAA"}
@@ -123,6 +123,10 @@
123
123
  "readme": "---\ntitle: Salesforce\ndescription: SFDC is a cloud-based customer relationship management (CRM) software used to manage customer data, sales processes, marketing campaigns, and customer service activities\n---\n\n## Salesforce\n\nSFDC is a cloud-based customer relationship management (CRM) software used to manage customer data, sales processes, marketing campaigns, and customer service activities\n\n## Extension settings\n\nFor this extension to work, you will need to provide the below settings:\n\n- Salesforce subdomain (https://<SUBDOMAIN>.my.salesforce.com/services/oauth2/token)\n- Client ID\n- Client secret\n- Username*\n- Password*\n\nUsername and password are optional. When specified, the Password grant will be used to authenticate with the Salesforce API. When left blank, the Client Credentials grant will be used.\n\n## Actions\n\n### Create a Lead\n\nA lead is a standard Salesforce object (sObject). You can use this action to create a Lead object.\n\n### Update a lead\n\nUpdates a Lead record based on the specified data and provided Lead record ID. Field values provided replace the existing values in the Lead record (PATCH).",
124
124
  "changelog": "# Salesforce changelog"
125
125
  },
126
+ "shelly": {
127
+ "readme": "---\ntitle: Shelly\ndescription: Library of AI-powered actions\n---\n\n## Shelly verification\n\nLibrary of AI-powered actions",
128
+ "changelog": "# Shelly changelog"
129
+ },
126
130
  "stripe": {
127
131
  "readme": "---\ntitle: Stripe\ndescription: Stripe powers online and in-person payment processing and financial solutions for businesses of all sizes.\n---\n\n## Stripe\n\nStripe powers online and in-person payment processing and financial solutions for businesses of all sizes.\n\n## Extension settings\n\nFor the extension to function correctly, you must configure the following settings:\n\n- Secret key (test and live mode)\n- Publishable key (test and live mode)\n- Mode (\"Test\" or \"Live\")",
128
132
  "changelog": "# Stripe changelog"
@@ -0,0 +1,34 @@
1
+ declare const actions: {
2
+ summarizeForm: import("@awell-health/extensions-core").Action<{
3
+ prompt: {
4
+ id: string;
5
+ label: string;
6
+ description: string;
7
+ type: import("@awell-health/extensions-core").FieldType.TEXT;
8
+ required: false;
9
+ };
10
+ }, {
11
+ openAiOrgId: {
12
+ key: string;
13
+ label: string;
14
+ obfuscated: false;
15
+ required: true;
16
+ description: string;
17
+ };
18
+ openAiProjectId: {
19
+ key: string;
20
+ label: string;
21
+ obfuscated: false;
22
+ required: true;
23
+ description: string;
24
+ };
25
+ openAiApiKey: {
26
+ key: string;
27
+ label: string;
28
+ obfuscated: true;
29
+ required: true;
30
+ description: string;
31
+ };
32
+ }, "summary">;
33
+ };
34
+ export default actions;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const summarizeForm_1 = require("./summarizeForm");
4
+ const actions = {
5
+ summarizeForm: summarizeForm_1.summarizeForm,
6
+ };
7
+ exports.default = actions;
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../extensions/shelly/actions/index.ts"],"names":[],"mappings":";;AAAA,mDAA+C;AAE/C,MAAM,OAAO,GAAG;IACd,aAAa,EAAb,6BAAa;CACd,CAAA;AAED,kBAAe,OAAO,CAAA"}
@@ -0,0 +1,6 @@
1
+ export declare const dataPoints: {
2
+ summary: {
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
+ summary: {
6
+ key: 'summary',
7
+ valueType: 'string',
8
+ },
9
+ };
10
+ //# sourceMappingURL=datapoints.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"datapoints.js","sourceRoot":"","sources":["../../../../../../extensions/shelly/actions/summarizeForm/config/datapoints.ts"],"names":[],"mappings":";;;AAEa,QAAA,UAAU,GAAG;IACxB,OAAO,EAAE;QACP,GAAG,EAAE,SAAS;QACd,SAAS,EAAE,QAAQ;KACpB;CAC4C,CAAA"}
@@ -0,0 +1,18 @@
1
+ import { FieldType } from '@awell-health/extensions-core';
2
+ import z from 'zod';
3
+ export declare const fields: {
4
+ prompt: {
5
+ id: string;
6
+ label: string;
7
+ description: string;
8
+ type: FieldType.TEXT;
9
+ required: false;
10
+ };
11
+ };
12
+ export declare const FieldsValidationSchema: z.ZodObject<{
13
+ prompt: z.ZodOptional<z.ZodString>;
14
+ }, "strip", z.ZodTypeAny, {
15
+ prompt?: string | undefined;
16
+ }, {
17
+ prompt?: string | undefined;
18
+ }>;
@@ -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.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
+ prompt: {
11
+ id: 'prompt',
12
+ label: 'Prompt',
13
+ description: 'Leave blank to use the default prompt',
14
+ type: extensions_core_1.FieldType.TEXT,
15
+ required: false,
16
+ },
17
+ };
18
+ exports.FieldsValidationSchema = zod_1.default.object({
19
+ prompt: zod_1.default.string().optional(),
20
+ });
21
+ //# sourceMappingURL=fields.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fields.js","sourceRoot":"","sources":["../../../../../../extensions/shelly/actions/summarizeForm/config/fields.ts"],"names":[],"mappings":";;;;;;AAAA,mEAAqE;AACrE,8CAAwC;AAE3B,QAAA,MAAM,GAAG;IACpB,MAAM,EAAE;QACN,EAAE,EAAE,QAAQ;QACZ,KAAK,EAAE,QAAQ;QACf,WAAW,EAAE,uCAAuC;QACpD,IAAI,EAAE,2BAAS,CAAC,IAAI;QACpB,QAAQ,EAAE,KAAK;KAChB;CAC8B,CAAA;AAEpB,QAAA,sBAAsB,GAAG,aAAC,CAAC,MAAM,CAAC;IAC7C,MAAM,EAAE,aAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CACoB,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/summarizeForm/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 { summarizeForm } from './summarizeForm';
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.summarizeForm = void 0;
4
+ var summarizeForm_1 = require("./summarizeForm");
5
+ Object.defineProperty(exports, "summarizeForm", { enumerable: true, get: function () { return summarizeForm_1.summarizeForm; } });
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../extensions/shelly/actions/summarizeForm/index.ts"],"names":[],"mappings":";;;AAAA,iDAA+C;AAAtC,8GAAA,aAAa,OAAA"}
@@ -0,0 +1,12 @@
1
+ import { type Form, type FormResponse } from '@awell-health/awell-sdk';
2
+ export interface OmittedFormAnswer {
3
+ questionId: string;
4
+ reason: string;
5
+ }
6
+ export declare const getResponseText: (opts: {
7
+ formDefinition: Form;
8
+ formResponse: FormResponse;
9
+ }) => {
10
+ result: string;
11
+ omittedFormAnswers: OmittedFormAnswer[];
12
+ };
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getResponseText = void 0;
4
+ const getMultipleSelectAnswers = (questionDefinition, questionResponse) => {
5
+ const answerValues = JSON.parse(questionResponse.value);
6
+ const answerOptions = questionDefinition.options;
7
+ const answerLabels = answerValues
8
+ .map((answerValue) => {
9
+ var _a;
10
+ return (_a = answerOptions === null || answerOptions === void 0 ? void 0 : answerOptions.find((answerOption) => String(answerOption.value) === String(answerValue))) === null || _a === void 0 ? void 0 : _a.label;
11
+ })
12
+ .filter((answer) => answer !== undefined);
13
+ return answerLabels.map((_answerLabel) => `- ${_answerLabel}`).join('\n');
14
+ };
15
+ const getQuestionAndAnswer = (questionDefinition, questionResponse) => {
16
+ const userQuestionType = questionDefinition.userQuestionType;
17
+ const addQuestionLabel = (answer) => {
18
+ return `${questionDefinition.title}\n${answer}`;
19
+ };
20
+ switch (userQuestionType) {
21
+ case 'YES_NO':
22
+ return addQuestionLabel(String(questionResponse.value));
23
+ case 'DATE':
24
+ return addQuestionLabel(String(questionResponse.value));
25
+ case 'NUMBER':
26
+ return addQuestionLabel(String(questionResponse.value));
27
+ case 'LONG_TEXT':
28
+ return addQuestionLabel(String(questionResponse.value));
29
+ case 'MULTIPLE_CHOICE':
30
+ return addQuestionLabel(String(questionResponse.value));
31
+ case 'MULTIPLE_SELECT':
32
+ return addQuestionLabel(getMultipleSelectAnswers(questionDefinition, questionResponse));
33
+ case 'SLIDER':
34
+ return addQuestionLabel(String(questionResponse.value));
35
+ case 'SHORT_TEXT':
36
+ return addQuestionLabel(String(questionResponse.value));
37
+ case 'TELEPHONE':
38
+ return addQuestionLabel(String(questionResponse.value));
39
+ default:
40
+ return addQuestionLabel(String(questionResponse.value));
41
+ }
42
+ };
43
+ const getResponseText = (opts) => {
44
+ const formAnswers = [];
45
+ const omittedFormAnswers = [];
46
+ opts.formResponse.answers.forEach((questionResponse) => {
47
+ const questionDefinition = opts.formDefinition.questions.find((q) => q.id === questionResponse.question_id);
48
+ if (questionDefinition === undefined) {
49
+ omittedFormAnswers.push({
50
+ questionId: questionResponse.question_id,
51
+ reason: 'No corresponding question definition found in the form definition',
52
+ });
53
+ return;
54
+ }
55
+ try {
56
+ const answer = getQuestionAndAnswer(questionDefinition, questionResponse);
57
+ formAnswers.push(answer);
58
+ }
59
+ catch (error) {
60
+ const errorMessage = error instanceof Error ? error.message : 'Unknown error';
61
+ omittedFormAnswers.push({
62
+ questionId: questionResponse.question_id,
63
+ reason: `Error processing answer: ${errorMessage}`,
64
+ });
65
+ }
66
+ });
67
+ return {
68
+ result: formAnswers.join('\n\n'),
69
+ omittedFormAnswers,
70
+ };
71
+ };
72
+ exports.getResponseText = getResponseText;
73
+ //# sourceMappingURL=getResponseText.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getResponseText.js","sourceRoot":"","sources":["../../../../../../../extensions/shelly/actions/summarizeForm/lib/getResponseText/getResponseText.ts"],"names":[],"mappings":";;;AAOA,MAAM,wBAAwB,GAAG,CAC/B,kBAA4B,EAC5B,gBAAwB,EAChB,EAAE;IACV,MAAM,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAAC,KAAK,CAErD,CAAA;IACD,MAAM,aAAa,GAAG,kBAAkB,CAAC,OAAO,CAAA;IAEhD,MAAM,YAAY,GAAG,YAAY;SAC9B,GAAG,CAAC,CAAC,WAAW,EAAE,EAAE;;QACnB,OAAO,M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Ae,CAAA;YAE1D,kBAAkB,CAAC,IAAI,CAAC;gBACtB,UAAU,EAAE,gBAAgB,CAAC,WAAW;gBACxC,MAAM,EAAE,4BAA4B,YAAY,EAAE;aACnD,CAAC,CAAA;SACH;IACH,CAAC,CAAC,CAAA;IAEF,OAAO;QACL,MAAM,EAAE,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC;QAChC,kBAAkB;KACnB,CAAA;AACH,CAAC,CAAA;AA3CY,QAAA,eAAe,mBA2C3B"}
@@ -0,0 +1 @@
1
+ export { getResponseText } from './getResponseText';
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getResponseText = void 0;
4
+ var getResponseText_1 = require("./getResponseText");
5
+ Object.defineProperty(exports, "getResponseText", { enumerable: true, get: function () { return getResponseText_1.getResponseText; } });
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../extensions/shelly/actions/summarizeForm/lib/getResponseText/index.ts"],"names":[],"mappings":";;;AAAA,qDAAmD;AAA1C,kHAAA,eAAe,OAAA"}
@@ -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 summarizeForm: Action<typeof fields, typeof settings, keyof typeof dataPoints>;
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.summarizeForm = void 0;
4
+ // import { AwellSdk } from '@awell-health/awell-sdk'
5
+ const extensions_core_1 = require("@awell-health/extensions-core");
6
+ const lib_1 = require("@extensions/shelly/lib");
7
+ const getLatestFormInStep_1 = require("@extensions/shelly/lib/utils/getLatestFormInStep");
8
+ const config_1 = require("./config");
9
+ const getResponseText_1 = require("./lib/getResponseText");
10
+ exports.summarizeForm = {
11
+ key: 'summarizeForm',
12
+ category: extensions_core_1.Category.WORKFLOW,
13
+ title: 'Summarize form',
14
+ description: 'Summarize the response of a form',
15
+ fields: config_1.fields,
16
+ previewable: false,
17
+ dataPoints: config_1.dataPoints,
18
+ onEvent: async ({ payload, onComplete, onError, helpers }) => {
19
+ const { pathway, activity } = await (0, lib_1.validatePayloadAndCreateSdk)({
20
+ fieldsSchema: config_1.FieldsValidationSchema,
21
+ payload,
22
+ });
23
+ // const awellSdk = new AwellSdk({
24
+ // environment: 'development',
25
+ // apiKey: '',
26
+ // })
27
+ const { formDefinition, formResponse } = await (0, getLatestFormInStep_1.getLatestFormInStep)({
28
+ awellSdk: await helpers.awellSdk(),
29
+ // awellSdk,
30
+ pathwayId: pathway.id,
31
+ activityId: activity.id,
32
+ });
33
+ const { result: responseText } = (0, getResponseText_1.getResponseText)({
34
+ formDefinition,
35
+ formResponse,
36
+ });
37
+ await onComplete({
38
+ data_points: {
39
+ summary: responseText,
40
+ },
41
+ });
42
+ // const openAiSdk = openai
43
+ // const completion = await openAiSdk.chat.completions.create({
44
+ // messages: [
45
+ // // Prompt, context
46
+ // {
47
+ // role: 'system',
48
+ // content:
49
+ // 'You will be provided with a questionnaire response, and your task is to summarize the meeting as follows:\n\n- Overall summary of the response',
50
+ // },
51
+ // // Form answers
52
+ // { role: 'user', content: 'Who won the world series in 2020?' },
53
+ // ],
54
+ // model: 'gpt-3.5-turbo',
55
+ // })
56
+ // const result = completion.choices[0].message.content
57
+ // await onComplete({
58
+ // data_points: {
59
+ // summary: JSON.stringify(result),
60
+ // },
61
+ // })
62
+ },
63
+ };
64
+ //# sourceMappingURL=summarizeForm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"summarizeForm.js","sourceRoot":"","sources":["../../../../../extensions/shelly/actions/summarizeForm/summarizeForm.ts"],"names":[],"mappings":";;;AAAA,qDAAqD;AACrD,mEAAqE;AACrE,gDAAoE;AACpE,0FAAsF;AAEtF,qCAAqE;AACrE,2DAAuD;AAE1C,QAAA,aAAa,GAItB;IACF,GAAG,EAAE,eAAe;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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 pathwayActivitiesResponse_1 = require("./__mocks__/pathwayActivitiesResponse");
7
+ const formDefinitionResponse_1 = require("./__mocks__/formDefinitionResponse");
8
+ const formResponseResponse_1 = require("./__mocks__/formResponseResponse");
9
+ describe('Shelly - Summarize', () => {
10
+ const { onComplete, onError, helpers, extensionAction, clearMocks } = extensions_core_1.TestHelpers.fromAction(_1.summarizeForm);
11
+ const awellSdkMock = {
12
+ orchestration: {
13
+ mutation: jest.fn().mockResolvedValue({}),
14
+ query: jest.fn().mockResolvedValue({
15
+ pathwayActivities: pathwayActivitiesResponse_1.mockPathwayActivitiesResponse,
16
+ form: formDefinitionResponse_1.mockFormDefinitionResponse,
17
+ formResponse: formResponseResponse_1.mockFormResponseResponse,
18
+ }),
19
+ },
20
+ };
21
+ helpers.awellSdk = jest.fn().mockResolvedValue(awellSdkMock);
22
+ beforeEach(() => {
23
+ clearMocks();
24
+ });
25
+ test('Should work', async () => {
26
+ await extensionAction.onEvent({
27
+ payload: (0, tests_1.generateTestPayload)({
28
+ pathway: {
29
+ id: 'ai4rZaYEocjB',
30
+ definition_id: 'whatever',
31
+ },
32
+ activity: { id: 'X74HeDQ4N0gtdaSEuzF8s' },
33
+ patient: { id: 'whatever' },
34
+ fields: {
35
+ prompt: '',
36
+ },
37
+ settings: {
38
+ openAiApiKey: 'a',
39
+ openAiOrgId: 'b',
40
+ openAiProjectId: 'c',
41
+ },
42
+ }),
43
+ onComplete,
44
+ onError,
45
+ helpers,
46
+ });
47
+ expect(helpers.awellSdk).toHaveBeenCalledTimes(1);
48
+ expect(awellSdkMock.orchestration.query).toHaveBeenCalledTimes(3);
49
+ expect(onError).not.toHaveBeenCalled();
50
+ expect(onComplete).toHaveBeenCalledWith({
51
+ data_points: {
52
+ result: '99999',
53
+ },
54
+ });
55
+ });
56
+ });
57
+ //# sourceMappingURL=summarizeForm.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"summarizeForm.test.js","sourceRoot":"","sources":["../../../../../extensions/shelly/actions/summarizeForm/summarizeForm.test.ts"],"names":[],"mappings":";;AAAA,mEAA2D;AAC3D,mCAA6C;AAC7C,wBAAiC;AACjC,qFAAqF;AACrF,+EAA+E;AAC/E,2EAA2E;AAE3E,QAAQ,CAAC,oBAAoB,EAAE,GAAG,EAAE;IAClC,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,GACjE,6BAAW,CAAC,UAAU,CAAC,gBAAa,CAAC,CAAA;IAEvC,MAAM,YAAY,GAAG;QACnB,aAAa,EAAE;YACb,QAAQ,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,iBAAiB,CAAC,EAAE,CAAC;YACzC,KAAK,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,iBAAiB,CAAC;gBACjC,iBAAiB,EAAE,yDAA6B;gBAChD,IAAI,EAAE,mDAA0B;gBAChC,YAAY,EAAE,+CAAwB;aACvC,CAAC;SACH;KACF,CAAA;IAED,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC,iBAAiB,CAAC,YAAY,CAAC,CAAA;IAE5D,UAAU,CAAC,GAAG,EAAE;QACd,UAAU,EAAE,CAAA;IACd,CAAC,CAAC,CAAA;IAEF,IAAI,CAAC,aAAa,EAAE,KAAK,IAAI,EAAE;QAC7B,MAAM,eAAe,CAAC,OAAO,CAAC;YAC5B,OAAO,EAAE,IAAA,2BAAmB,EAAC;gBAC3B,OAAO,EAAE;oBACP,EAAE,EAAE,cAAc;oBAClB,aAAa,EAAE,UAAU;iBAC1B;gBACD,QAAQ,EAAE,EAAE,EAAE,EAAE,uBAAuB,EAAE;gBACzC,OAAO,EAAE,EAAE,EAAE,EAAE,UAAU,EAAE;gBAC3B,MAAM,EAAE;oBACN,MAAM,EAAE,EAAE;iBACX;gBACD,QAAQ,EAAE;oBACR,YAAY,EAAE,GAAG;oBACjB,WAAW,EAAE,GAAG;oBAChB,eAAe,EAAE,GAAG;iBACrB;aACF,CAAC;YACF,UAAU;YACV,OAAO;YACP,OAAO;SACR,CAAC,CAAA;QAEF,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAA;QACjD,MAAM,CAAC,YAAY,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAA;QAEjE,MAAM,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,gBAAgB,EAAE,CAAA;QACtC,MAAM,CAAC,UAAU,CAAC,CAAC,oBAAoB,CAAC;YACtC,WAAW,EAAE;gBACX,MAAM,EAAE,OAAO;aAChB;SACF,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
@@ -0,0 +1,2 @@
1
+ import { type Extension } from '@awell-health/extensions-core';
2
+ export declare const shelly: Extension;
@@ -0,0 +1,22 @@
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.shelly = void 0;
7
+ const extensions_core_1 = require("@awell-health/extensions-core");
8
+ const actions_1 = __importDefault(require("./actions"));
9
+ const settings_1 = require("./settings");
10
+ exports.shelly = {
11
+ key: 'shelly',
12
+ title: 'Shelly (experimental)',
13
+ description: 'Library of AI-powered actions',
14
+ icon_url: 'https://res.cloudinary.com/da7x4rzl4/image/upload/v1726037275/Awell%20Extensions/shelly_logo.png',
15
+ category: extensions_core_1.Category.WORKFLOW,
16
+ author: {
17
+ authorType: extensions_core_1.AuthorType.AWELL,
18
+ },
19
+ settings: settings_1.settings,
20
+ actions: actions_1.default,
21
+ };
22
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../extensions/shelly/index.ts"],"names":[],"mappings":";;;;;;AAAA,mEAIsC;AACtC,wDAA+B;AAC/B,yCAAqC;AAExB,QAAA,MAAM,GAAc;IAC/B,GAAG,EAAE,QAAQ;IACb,KAAK,EAAE,uBAAuB;IAC9B,WAAW,EAAE,+BAA+B;IAC5C,QAAQ,EACN,kGAAkG;IACpG,QAAQ,EAAE,0BAAQ,CAAC,QAAQ;IAC3B,MAAM,EAAE;QACN,UAAU,EAAE,4BAAU,CAAC,KAAK;KAC7B;IACD,QAAQ,EAAR,mBAAQ;IACR,OAAO,EAAP,iBAAO;CACR,CAAA"}
@@ -0,0 +1 @@
1
+ export declare const OPENAI_BASE_URL = "https://api.openai.com/v1/chat/completion";
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OPENAI_BASE_URL = void 0;
4
+ exports.OPENAI_BASE_URL = 'https://api.openai.com/v1/chat/completion';
5
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../extensions/shelly/lib/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,eAAe,GAAG,2CAA2C,CAAA"}
@@ -0,0 +1 @@
1
+ export { validatePayloadAndCreateSdk } from './validatePayloadAndCreateSdk';
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.validatePayloadAndCreateSdk = void 0;
4
+ var validatePayloadAndCreateSdk_1 = require("./validatePayloadAndCreateSdk");
5
+ Object.defineProperty(exports, "validatePayloadAndCreateSdk", { enumerable: true, get: function () { return validatePayloadAndCreateSdk_1.validatePayloadAndCreateSdk; } });
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../extensions/shelly/lib/index.ts"],"names":[],"mappings":";;;AAAA,6EAA2E;AAAlE,0IAAA,2BAA2B,OAAA"}
@@ -0,0 +1,11 @@
1
+ import { type AwellSdk, type FormResponse, type Form } from '@awell-health/awell-sdk';
2
+ type GetLatestFormInStep = ({ awellSdk, pathwayId, activityId, }: {
3
+ awellSdk: AwellSdk;
4
+ pathwayId: string;
5
+ activityId: string;
6
+ }) => Promise<{
7
+ formDefinition: Form;
8
+ formResponse: FormResponse;
9
+ }>;
10
+ export declare const getLatestFormInStep: GetLatestFormInStep;
11
+ export {};
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getLatestFormInStep = void 0;
4
+ const lodash_1 = require("lodash");
5
+ const getLatestFormInStep = async ({ awellSdk, pathwayId, activityId, }) => {
6
+ var _a;
7
+ const activities = await awellSdk.orchestration.query({
8
+ pathwayActivities: {
9
+ __args: {
10
+ pathway_id: pathwayId,
11
+ },
12
+ success: true,
13
+ activities: {
14
+ id: true,
15
+ status: true,
16
+ date: true,
17
+ object: {
18
+ id: true,
19
+ type: true,
20
+ },
21
+ context: {
22
+ step_id: true,
23
+ },
24
+ },
25
+ },
26
+ });
27
+ const currentActivity = activities.pathwayActivities.activities.find((a) => a.id === activityId);
28
+ if ((0, lodash_1.isNil)(currentActivity))
29
+ throw new Error('Cannot find the current activity');
30
+ const currentStepId = (_a = currentActivity.context) === null || _a === void 0 ? void 0 : _a.step_id;
31
+ if ((0, lodash_1.isNil)(currentStepId))
32
+ throw new Error('Could not find step ID of the current activity');
33
+ const formActivitiesInCurrentStep = activities.pathwayActivities.activities.filter((a) => {
34
+ var _a;
35
+ return ((_a = a.context) === null || _a === void 0 ? void 0 : _a.step_id) === currentStepId &&
36
+ a.object.type === 'FORM' &&
37
+ a.status === 'DONE' &&
38
+ a.date <= currentActivity.date;
39
+ });
40
+ // Grab the most recent form activity
41
+ const formActivity = formActivitiesInCurrentStep[0];
42
+ if ((0, lodash_1.isNil)(formActivity))
43
+ throw new Error('No (completed) form action found in the current step');
44
+ const formDefinition = await awellSdk.orchestration.query({
45
+ form: {
46
+ __args: {
47
+ id: formActivity.object.id,
48
+ },
49
+ form: {
50
+ __scalar: true,
51
+ questions: {
52
+ __scalar: true,
53
+ options: {
54
+ __scalar: true,
55
+ },
56
+ },
57
+ },
58
+ },
59
+ });
60
+ const formResponse = await awellSdk.orchestration.query({
61
+ formResponse: {
62
+ __args: {
63
+ pathway_id: pathwayId,
64
+ activity_id: formActivity.id,
65
+ },
66
+ response: {
67
+ answers: {
68
+ __scalar: true,
69
+ },
70
+ },
71
+ },
72
+ });
73
+ return {
74
+ formDefinition: formDefinition.form.form,
75
+ formResponse: formResponse.formResponse.response,
76
+ };
77
+ };
78
+ exports.getLatestFormInStep = getLatestFormInStep;
79
+ //# sourceMappingURL=getLatestFormInStep.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getLatestFormInStep.js","sourceRoot":"","sources":["../../../../../extensions/shelly/lib/utils/getLatestFormInStep.ts"],"names":[],"mappings":";;;AAKA,mCAA8B;AAevB,MAAM,mBAAmB,GAAwB,KAAK,EAAE,EAC7D,QAAQ,EACR,SAAS,EACT,UAAU,GACX,EAAE,EAAE;;IACH,MAAM,UAAU,GAAG,MAAM,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC;QACpD,iBAAiB,EAAE;YACjB,MAAM,EAAE;gBACN,UAAU,EAAE,SAAS;aACtB;YACD,OAAO,EAAE,IAAI;YACb,UAAU,EAAE;gBACV,EAAE,EAAE,IAAI;gBACR,MAAM,EAAE,IAAI;gBACZ,IAAI,EAAE,IAAI;gBACV,MAAM,EAAE;oBACN,EAAE,EAAE,IAAI;oBACR,IAAI,EAAE,IAAI;iBACX;gBACD,OAAO,EAAE;oBACP,OAAO,EAAE,IAAI;iBACd;aACF;SACF;KACF,CAAC,CAAA;IAEF,MAAM,eAAe,GAAG,UAAU,CAAC,iBAAiB,CAAC,UAAU,CAAC,IAAI,CAClE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,UAAU,CAC3B,CA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CAAC,EAAE;aAC7B;YACD,QAAQ,EAAE;gBACR,OAAO,EAAE;oBACP,QAAQ,EAAE,IAAI;iBACf;aACF;SACF;KACF,CAAC,CAAA;IAEF,OAAO;QACL,cAAc,EAAE,cAAc,CAAC,IAAI,CAAC,IAAY;QAChD,YAAY,EAAE,YAAY,CAAC,YAAY,CAAC,QAAwB;KACjE,CAAA;AACH,CAAC,CAAA;AAxFY,QAAA,mBAAmB,uBAwF/B"}
@@ -0,0 +1 @@
1
+ export { getLatestFormInStep } from './getLatestFormInStep';
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getLatestFormInStep = void 0;
4
+ var getLatestFormInStep_1 = require("./getLatestFormInStep");
5
+ Object.defineProperty(exports, "getLatestFormInStep", { enumerable: true, get: function () { return getLatestFormInStep_1.getLatestFormInStep; } });
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../extensions/shelly/lib/utils/index.ts"],"names":[],"mappings":";;;AAAA,6DAA2D;AAAlD,0HAAA,mBAAmB,OAAA"}
@@ -0,0 +1,18 @@
1
+ import { type NewActivityPayload, type Pathway, type Patient } from '@awell-health/extensions-core';
2
+ import z from 'zod';
3
+ import { SettingsValidationSchema } from '../settings';
4
+ import OpenAIApi from 'openai';
5
+ import { type Activity } from '@awell-health/extensions-core/dist/types/Activity';
6
+ type ValidatePayloadAndCreateSdk = <T extends z.ZodTypeAny, P extends NewActivityPayload<any, any>>(args: {
7
+ fieldsSchema: T;
8
+ payload: P;
9
+ }) => Promise<{
10
+ openai: OpenAIApi;
11
+ fields: z.infer<(typeof args)['fieldsSchema']>;
12
+ settings: z.infer<typeof SettingsValidationSchema>;
13
+ pathway: Pathway;
14
+ patient: Patient;
15
+ activity: Activity;
16
+ }>;
17
+ export declare const validatePayloadAndCreateSdk: ValidatePayloadAndCreateSdk;
18
+ export {};
@@ -0,0 +1,31 @@
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.validatePayloadAndCreateSdk = void 0;
7
+ const extensions_core_1 = require("@awell-health/extensions-core");
8
+ const zod_1 = __importDefault(require("zod"));
9
+ const settings_1 = require("../settings");
10
+ const openai_1 = __importDefault(require("openai"));
11
+ const validatePayloadAndCreateSdk = async ({ fieldsSchema, payload, }) => {
12
+ const { settings, fields } = (0, extensions_core_1.validate)({
13
+ schema: zod_1.default.object({
14
+ fields: fieldsSchema,
15
+ settings: settings_1.SettingsValidationSchema,
16
+ pathway: zod_1.default.object({ id: zod_1.default.string() }),
17
+ activity: zod_1.default.object({ id: zod_1.default.string() }),
18
+ patient: zod_1.default.object({ id: zod_1.default.string() }),
19
+ }),
20
+ payload,
21
+ });
22
+ const { patient, pathway, activity } = payload;
23
+ const openai = new openai_1.default({
24
+ apiKey: settings.openAiApiKey,
25
+ project: settings.openAiProjectId,
26
+ organization: settings.openAiOrgId,
27
+ });
28
+ return { openai, fields, settings, patient, pathway, activity };
29
+ };
30
+ exports.validatePayloadAndCreateSdk = validatePayloadAndCreateSdk;
31
+ //# sourceMappingURL=validatePayloadAndCreateSdk.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validatePayloadAndCreateSdk.js","sourceRoot":"","sources":["../../../../extensions/shelly/lib/validatePayloadAndCreateSdk.ts"],"names":[],"mappings":";;;;;;AAAA,mEAKsC;AACtC,8CAAmB;AACnB,0CAAsD;AACtD,oDAA8B;AAkBvB,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;YAClC,OAAO,EAAE,aAAC,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,aAAC,CAAC,MAAM,EAAE,EAAE,CAAC;YACrC,QAAQ,EAAE,aAAC,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,aAAC,CAAC,MAAM,EAAE,EAAE,CAAC;YACtC,OAAO,EAAE,aAAC,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,aAAC,CAAC,MAAM,EAAE,EAAE,CAAC;SACtC,CAAC;QACF,OAAO;KACR,CAAC,CAAA;IAEF,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAA;IAE9C,MAAM,MAAM,GAAG,IAAI,gBAAS,CAAC;QAC3B,MAAM,EAAE,QAAQ,CAAC,YAAY;QAC7B,OAAO,EAAE,QAAQ,CAAC,eAAe;QACjC,YAAY,EAAE,QAAQ,CAAC,WAAW;KACnC,CAAC,CAAA;IAEF,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAA;AACjE,CAAC,CAAA;AAxBY,QAAA,2BAA2B,+BAwBvC"}
@@ -0,0 +1,37 @@
1
+ import { z } from 'zod';
2
+ export declare const settings: {
3
+ openAiOrgId: {
4
+ key: string;
5
+ label: string;
6
+ obfuscated: false;
7
+ required: true;
8
+ description: string;
9
+ };
10
+ openAiProjectId: {
11
+ key: string;
12
+ label: string;
13
+ obfuscated: false;
14
+ required: true;
15
+ description: string;
16
+ };
17
+ openAiApiKey: {
18
+ key: string;
19
+ label: string;
20
+ obfuscated: true;
21
+ required: true;
22
+ description: string;
23
+ };
24
+ };
25
+ export declare const SettingsValidationSchema: z.ZodObject<{
26
+ openAiOrgId: z.ZodString;
27
+ openAiProjectId: z.ZodString;
28
+ openAiApiKey: z.ZodString;
29
+ }, "strip", z.ZodTypeAny, {
30
+ openAiOrgId: string;
31
+ openAiProjectId: string;
32
+ openAiApiKey: string;
33
+ }, {
34
+ openAiOrgId: string;
35
+ openAiProjectId: string;
36
+ openAiApiKey: string;
37
+ }>;
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SettingsValidationSchema = exports.settings = void 0;
4
+ const zod_1 = require("zod");
5
+ exports.settings = {
6
+ openAiOrgId: {
7
+ key: 'openAiOrgId',
8
+ label: 'OpenAI organisaiton ID ',
9
+ obfuscated: false,
10
+ required: true,
11
+ description: '',
12
+ },
13
+ openAiProjectId: {
14
+ key: 'openAiProjectId',
15
+ label: 'OpenAI project ID ',
16
+ obfuscated: false,
17
+ required: true,
18
+ description: '',
19
+ },
20
+ openAiApiKey: {
21
+ key: 'openAiApiKey',
22
+ label: 'OpenAI API key ',
23
+ obfuscated: true,
24
+ required: true,
25
+ description: '',
26
+ },
27
+ };
28
+ exports.SettingsValidationSchema = zod_1.z.object({
29
+ openAiOrgId: zod_1.z.string().min(1),
30
+ openAiProjectId: zod_1.z.string().min(1),
31
+ openAiApiKey: zod_1.z.string().min(1),
32
+ });
33
+ //# sourceMappingURL=settings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"settings.js","sourceRoot":"","sources":["../../../extensions/shelly/settings.ts"],"names":[],"mappings":";;;AACA,6BAAwC;AAE3B,QAAA,QAAQ,GAAG;IACtB,WAAW,EAAE;QACX,GAAG,EAAE,aAAa;QAClB,KAAK,EAAE,yBAAyB;QAChC,UAAU,EAAE,KAAK;QACjB,QAAQ,EAAE,IAAI;QACd,WAAW,EAAE,EAAE;KAChB;IACD,eAAe,EAAE;QACf,GAAG,EAAE,iBAAiB;QACtB,KAAK,EAAE,oBAAoB;QAC3B,UAAU,EAAE,KAAK;QACjB,QAAQ,EAAE,IAAI;QACd,WAAW,EAAE,EAAE;KAChB;IACD,YAAY,EAAE;QACZ,GAAG,EAAE,cAAc;QACnB,KAAK,EAAE,iBAAiB;QACxB,UAAU,EAAE,IAAI;QAChB,QAAQ,EAAE,IAAI;QACd,WAAW,EAAE,EAAE;KAChB;CACgC,CAAA;AAEtB,QAAA,wBAAwB,GAAG,OAAC,CAAC,MAAM,CAAC;IAC/C,WAAW,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC9B,eAAe,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAClC,YAAY,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;CACoB,CAAC,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@awell-health/awell-extensions",
3
- "version": "2.0.9",
3
+ "version": "2.0.12",
4
4
  "packageManager": "yarn@3.4.1",
5
5
  "main": "dist/src/index.js",
6
6
  "repository": {
@@ -102,7 +102,7 @@
102
102
  "mailgun.js": "^8.2.1",
103
103
  "messagebird": "^4.0.1",
104
104
  "node-fetch": "2",
105
- "openai": "^3.2.1",
105
+ "openai": "^4.59.0",
106
106
  "showdown": "^2.1.0",
107
107
  "stripe": "^15.5.0",
108
108
  "twilio": "^4.8.0",