@awell-health/awell-extensions 1.1.53 → 1.1.55
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/extensions/healthie/actions/createAppointment/config/fields.js.map +1 -1
- package/dist/extensions/index.js +2 -0
- package/dist/extensions/index.js.map +1 -1
- package/dist/extensions/markdown.json +4 -0
- package/dist/extensions/sfdc/actions/createLead/config/datapoints.d.ts +6 -0
- package/dist/extensions/sfdc/actions/createLead/config/datapoints.js +10 -0
- package/dist/extensions/sfdc/actions/createLead/config/datapoints.js.map +1 -0
- package/dist/extensions/sfdc/actions/createLead/config/fields.d.ts +18 -0
- package/dist/extensions/sfdc/actions/createLead/config/fields.js +44 -0
- package/dist/extensions/sfdc/actions/createLead/config/fields.js.map +1 -0
- package/dist/extensions/sfdc/actions/createLead/config/index.d.ts +2 -0
- package/dist/extensions/sfdc/actions/createLead/config/index.js +9 -0
- package/dist/extensions/sfdc/actions/createLead/config/index.js.map +1 -0
- package/dist/extensions/sfdc/actions/createLead/createLead.d.ts +4 -0
- package/dist/extensions/sfdc/actions/createLead/createLead.js +31 -0
- package/dist/extensions/sfdc/actions/createLead/createLead.js.map +1 -0
- package/dist/extensions/sfdc/actions/createLead/createLead.test.d.ts +1 -0
- package/dist/extensions/sfdc/actions/createLead/createLead.test.js +36 -0
- package/dist/extensions/sfdc/actions/createLead/createLead.test.js.map +1 -0
- package/dist/extensions/sfdc/actions/createLead/index.d.ts +1 -0
- package/dist/extensions/sfdc/actions/createLead/index.js +6 -0
- package/dist/extensions/sfdc/actions/createLead/index.js.map +1 -0
- package/dist/extensions/sfdc/actions/index.d.ts +55 -0
- package/dist/extensions/sfdc/actions/index.js +8 -0
- package/dist/extensions/sfdc/actions/index.js.map +1 -0
- package/dist/extensions/sfdc/actions/testAction/config/datapoints.d.ts +6 -0
- package/dist/extensions/sfdc/actions/testAction/config/datapoints.js +10 -0
- package/dist/extensions/sfdc/actions/testAction/config/datapoints.js.map +1 -0
- package/dist/extensions/sfdc/actions/testAction/config/fields.d.ts +18 -0
- package/dist/extensions/sfdc/actions/testAction/config/fields.js +21 -0
- package/dist/extensions/sfdc/actions/testAction/config/fields.js.map +1 -0
- package/dist/extensions/sfdc/actions/testAction/config/index.d.ts +2 -0
- package/dist/extensions/sfdc/actions/testAction/config/index.js +9 -0
- package/dist/extensions/sfdc/actions/testAction/config/index.js.map +1 -0
- package/dist/extensions/sfdc/actions/testAction/index.d.ts +1 -0
- package/dist/extensions/sfdc/actions/testAction/index.js +6 -0
- package/dist/extensions/sfdc/actions/testAction/index.js.map +1 -0
- package/dist/extensions/sfdc/actions/testAction/testAction.d.ts +4 -0
- package/dist/extensions/sfdc/actions/testAction/testAction.js +28 -0
- package/dist/extensions/sfdc/actions/testAction/testAction.js.map +1 -0
- package/dist/extensions/sfdc/actions/testAction/testAction.test.d.ts +1 -0
- package/dist/extensions/sfdc/actions/testAction/testAction.test.js +27 -0
- package/dist/extensions/sfdc/actions/testAction/testAction.test.js.map +1 -0
- package/dist/extensions/sfdc/api/cacheService.d.ts +11 -0
- package/dist/extensions/sfdc/api/cacheService.js +15 -0
- package/dist/extensions/sfdc/api/cacheService.js.map +1 -0
- package/dist/extensions/sfdc/api/client.d.ts +24 -0
- package/dist/extensions/sfdc/api/client.js +68 -0
- package/dist/extensions/sfdc/api/client.js.map +1 -0
- package/dist/extensions/sfdc/api/constants.d.ts +5 -0
- package/dist/extensions/sfdc/api/constants.js +21 -0
- package/dist/extensions/sfdc/api/constants.js.map +1 -0
- package/dist/extensions/sfdc/api/schema/index.d.ts +1 -0
- package/dist/extensions/sfdc/api/schema/index.js +18 -0
- package/dist/extensions/sfdc/api/schema/index.js.map +1 -0
- package/dist/extensions/sfdc/api/schema/record.schema.d.ts +26 -0
- package/dist/extensions/sfdc/api/schema/record.schema.js +14 -0
- package/dist/extensions/sfdc/api/schema/record.schema.js.map +1 -0
- package/dist/extensions/sfdc/index.d.ts +2 -0
- package/dist/extensions/sfdc/index.js +22 -0
- package/dist/extensions/sfdc/index.js.map +1 -0
- package/dist/extensions/sfdc/lib/index.d.ts +1 -0
- package/dist/extensions/sfdc/lib/index.js +6 -0
- package/dist/extensions/sfdc/lib/index.js.map +1 -0
- package/dist/extensions/sfdc/lib/validatePayloadAndCreateClient.d.ts +15 -0
- package/dist/extensions/sfdc/lib/validatePayloadAndCreateClient.js +54 -0
- package/dist/extensions/sfdc/lib/validatePayloadAndCreateClient.js.map +1 -0
- package/dist/extensions/sfdc/settings.d.ts +67 -0
- package/dist/extensions/sfdc/settings.js +58 -0
- package/dist/extensions/sfdc/settings.js.map +1 -0
- package/package.json +1 -1
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"fields.js","sourceRoot":"","sources":["../../../../../../extensions/healthie/actions/createAppointment/config/fields.ts"],"names":[],"mappings":";;;AAAA,mEAIsC;AACtC,mCAAuC;AACvC,
|
1
|
+
{"version":3,"file":"fields.js","sourceRoot":"","sources":["../../../../../../extensions/healthie/actions/createAppointment/config/fields.ts"],"names":[],"mappings":";;;AAAA,mEAIsC;AACtC,mCAAuC;AACvC,6BAAwC;AAE3B,QAAA,MAAM,GAAG;IACpB,SAAS,EAAE;QACT,EAAE,EAAE,WAAW;QACf,KAAK,EAAE,YAAY;QACnB,WAAW,EAAE,8DAA8D;QAC3E,IAAI,EAAE,2BAAS,CAAC,MAAM;QACtB,QAAQ,EAAE,IAAI;KACf;IACD,YAAY,EAAE;QACZ,EAAE,EAAE,cAAc;QAClB,KAAK,EAAE,aAAa;QACpB,WAAW,EACT,yHAAyH;QAC3H,IAAI,EAAE,2BAAS,CAAC,MAAM;KACvB;IACD,aAAa,EAAE;QACb,EAAE,EAAE,eAAe;QACnB,KAAK,EAAE,iBAAiB;QACxB,WAAW,EAAE,wCAAwC;QACrD,IAAI,EAAE,2BAAS,CAAC,MAAM;QACtB,QAAQ,EAAE,IAAI;KACf;IACD,iBAAiB,EAAE;QACjB,EAAE,EAAE,mBAAmB;QACvB,KAAK,EAAE,qBAAqB;QAC5B,WAAW,EAAE,iCAAiC;QAC9C,IAAI,EAAE,2BAAS,CAAC,MAAM;QACtB,QAAQ,EAAE,IAAI;KACf;IACD,QAAQ,EAAE;QACR,EAAE,EAAE,UAAU;QACd,KAAK,EAAE,2BAA2B;QAClC,WAAW,EAAE,yDAAyD;QACtE,IAAI,EAAE,2BAAS,CAAC,IAAI;QACpB,QAAQ,EAAE,IAAI;KACf;IACD,QAAQ,EAAE;QACR,EAAE,EAAE,UAAU;QACd,KAAK,EAAE,UAAU;QACjB,WAAW,EAAE,EAAE;QACf,IAAI,EAAE,2BAAS,CAAC,IAAI;QACpB,QAAQ,EAAE,KAAK;KAChB;CAC8B,CAAA;AAEpB,QAAA,sBAAsB,GAAG,OAAC,CAAC,MAAM,CAAC;IAC7C,SAAS,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC5B,YAAY,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IACnC,aAAa,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAChC,iBAAiB,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACpC,QAAQ,EAAE,gCAAc;IACxB,QAAQ,EAAE,OAAC;SACR,MAAM,EAAE;SACR,QAAQ,EAAE;SACV,SAAS,CAAC,CAAC,GAAG,EAAE,GAAG,EAAuB,EAAE;QAC3C,IAAI,IAAA,cAAK,EAAC,GAAG,CAAC,IAAI,IAAA,gBAAO,EAAC,GAAG,CAAC;YAAE,OAAO,EAAE,CAAA;QACzC,IAAI;YACF,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;SACvB;QAAC,OAAO,CAAC,EAAE;YACV,GAAG,CAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,cAAc,EAAE,CAAC,CAAA;YACzD,OAAO,OAAC,CAAC,KAAK,CAAA;SACf;IACH,CAAC,CAAC;CAC6C,CAAC,CAAA"}
|
package/dist/extensions/index.js
CHANGED
@@ -59,6 +59,7 @@ const textline_1 = require("./textline");
|
|
59
59
|
const medplum_1 = require("./medplum");
|
60
60
|
const dockHealth_1 = require("./dockHealth");
|
61
61
|
const stripe_1 = require("./stripe");
|
62
|
+
const sfdc_1 = require("./sfdc");
|
62
63
|
const json = __importStar(require("./markdown.json"));
|
63
64
|
const external_server_1 = require("./external-server");
|
64
65
|
exports.markdown = json;
|
@@ -92,6 +93,7 @@ exports.extensions = [
|
|
92
93
|
nexuzhealth_1.nexuzhealth,
|
93
94
|
sendbird_1.Sendbird,
|
94
95
|
sendgrid_extension_1.Sendgrid,
|
96
|
+
sfdc_1.sfdc,
|
95
97
|
stripe_1.stripe,
|
96
98
|
talkDesk_1.TalkDesk,
|
97
99
|
textline_1.TextLine,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../extensions/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mCAA+B;AAC/B,2CAAuC;AACvC,yCAAqC;AACrC,mDAA+C;AAC/C,6CAAyC;AACzC,+CAA2C;AAC3C,uCAAmC;AACnC,iDAA6C;AAC7C,yCAAqC;AACrC,yCAAqC;AACrC,+CAA0C;AAC1C,2CAAuC;AACvC,uCAAmC;AACnC,iCAAsC;AACtC,+CAA2C;AAC3C,2CAAuC;AACvC,qCAAiC;AACjC,6DAA+C;AAC/C,yCAAqC;AACrC,yCAAqC;AACrC,yCAAqC;AACrC,yCAAqC;AACrC,2CAAuC;AACvC,yCAAqC;AACrC,uCAAmC;AACnC,uCAAmC;AACnC,uCAAmC;AACnC,+CAA2C;AAC3C,+CAA2C;AAC3C,iDAA6C;AAC7C,+BAA2B;AAC3B,yCAAqC;AACrC,uCAAmC;AACnC,6CAAyC;AACzC,qCAAiC;
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../extensions/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mCAA+B;AAC/B,2CAAuC;AACvC,yCAAqC;AACrC,mDAA+C;AAC/C,6CAAyC;AACzC,+CAA2C;AAC3C,uCAAmC;AACnC,iDAA6C;AAC7C,yCAAqC;AACrC,yCAAqC;AACrC,+CAA0C;AAC1C,2CAAuC;AACvC,uCAAmC;AACnC,iCAAsC;AACtC,+CAA2C;AAC3C,2CAAuC;AACvC,qCAAiC;AACjC,6DAA+C;AAC/C,yCAAqC;AACrC,yCAAqC;AACrC,yCAAqC;AACrC,yCAAqC;AACrC,2CAAuC;AACvC,yCAAqC;AACrC,uCAAmC;AACnC,uCAAmC;AACnC,uCAAmC;AACnC,+CAA2C;AAC3C,+CAA2C;AAC3C,iDAA6C;AAC7C,+BAA2B;AAC3B,yCAAqC;AACrC,uCAAmC;AACnC,6CAAyC;AACzC,qCAAiC;AACjC,iCAA6B;AAE7B,sDAAuC;AACvC,uDAAkD;AAGrC,QAAA,QAAQ,GAAa,IAAI,CAAA;AAEzB,QAAA,UAAU,GAAG;IACxB,aAAK;IACL,2BAAY;IACZ,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,SAAG;IACH,iBAAO;IACP,mBAAQ;IACR,qBAAS;IACT,iBAAO;IACP,oBAAa;IACb,yBAAW;IACX,iBAAO;IACP,qBAAS;IACT,yBAAW;IACX,mBAAQ;IACR,6BAAQ;IACR,WAAI;IACJ,eAAM;IACN,mBAAQ;IACR,mBAAQ;IACR,qBAAS;IACT,eAAM;IACN,iBAAO;IACP,iBAAO;CACR,CAAA"}
|
@@ -115,6 +115,10 @@
|
|
115
115
|
"readme": "---\ntitle: Sendgrid\ndescription: SendGrid is a cloud-based email delivery platform that provides services for sending and managing email campaigns, transactional emails, and other types of messages.\n---\n# Sendgrid\n\nSendGrid is a cloud-based email delivery platform that provides services for sending and managing email campaigns, transactional emails, and other types of messages.\n\n## Extension settings\n\nIn order to set up this extension, you will need to provide:\n\n1. An API key\n2. A from name\n3. A from email\n\n## Custom Actions\n\n### Send email\n\nAllows for sending a plain email to a recipient.\n\n### Send email with a template\n\nAllows for sending an email based on a template to a recipient. You can also insert variables so they are rendered in your template.\n\n### Add or update contact\n\nAllows adding or updating contacts. The contact to update will be determined only by the email field and any fields omitted from the request will remain as they were. A contact's ID cannot be used to update the contact.\n\nPlease note that custom fields need to have been already created if you wish to set their values for the contacts being upserted. To do this, please use the \"Create Custom Field Definition\" endpoint. They also can be created in **Marketing -> Custom Fields** section in Sendgrid.\n\n### Add and remove emails from suppression lists\n\nSuppression lists ([link on SendGrid's website](https://docs.sendgrid.com/api-reference/suppressions-suppressions/add-suppressions-to-a-suppression-group)) are unsubscribe groups. Use these actions to add an email address to any number of unsubscribe groups. You can apply a suppression add/remove to multiple groups by using comma-separated lists for the groups. Only a single email can be used. **This functionality is different from SendGrid's API, which allows multiple email addresses for a single group**.\n\n### Check an import status\n\nAllows user to check the status of contact import jobs when given a jobID. Statuses are either: `pending`, `completed`, `failed`, or `errored`.",
|
116
116
|
"changelog": "# Sendgrid changelog\n\n## July 7, 2023\n\nAdded \"Add Email to Suppression Lists\" and \"Remove Email from Suppression Lists\" actions.\n\n## July 15, 2023\n\nUpdated \"Add or Update Contact\" acction to create a datapoint of the Job ID.\n\nAdded \"Check Import Status\" action.\n\n## July 27, 2023\n\nAdds \"Finished At\" data point to the importStatus action."
|
117
117
|
},
|
118
|
+
"sfdc": {
|
119
|
+
"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.",
|
120
|
+
"changelog": "# Salesforce changelog"
|
121
|
+
},
|
118
122
|
"stripe": {
|
119
123
|
"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\")",
|
120
124
|
"changelog": "# Stripe changelog"
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"datapoints.js","sourceRoot":"","sources":["../../../../../../extensions/sfdc/actions/createLead/config/datapoints.ts"],"names":[],"mappings":";;;AAEa,QAAA,UAAU,GAAG;IACxB,aAAa,EAAE;QACb,GAAG,EAAE,eAAe;QACpB,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
|
+
data: {
|
5
|
+
id: string;
|
6
|
+
label: string;
|
7
|
+
description: string;
|
8
|
+
type: FieldType.JSON;
|
9
|
+
required: true;
|
10
|
+
};
|
11
|
+
};
|
12
|
+
export declare const FieldsValidationSchema: z.ZodObject<{
|
13
|
+
data: z.ZodPipeline<z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodString, any, string>, any, string>, any, string>, any, string>, z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
14
|
+
}, "strip", z.ZodTypeAny, {
|
15
|
+
data: Record<string, unknown>;
|
16
|
+
}, {
|
17
|
+
data: string;
|
18
|
+
}>;
|
@@ -0,0 +1,44 @@
|
|
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
|
+
data: {
|
11
|
+
id: 'data',
|
12
|
+
label: 'Data',
|
13
|
+
description: 'Information used to create the Lead',
|
14
|
+
type: extensions_core_1.FieldType.JSON,
|
15
|
+
required: true,
|
16
|
+
},
|
17
|
+
};
|
18
|
+
exports.FieldsValidationSchema = zod_1.default.object({
|
19
|
+
data: zod_1.default
|
20
|
+
.string()
|
21
|
+
.transform((str) => {
|
22
|
+
try {
|
23
|
+
return JSON.parse(str);
|
24
|
+
}
|
25
|
+
catch (e) {
|
26
|
+
throw new Error('Invalid JSON string');
|
27
|
+
}
|
28
|
+
})
|
29
|
+
.refine((obj) => typeof obj === 'object' && obj !== null && !Array.isArray(obj), {
|
30
|
+
message: 'Parsed value is not an object',
|
31
|
+
})
|
32
|
+
.refine((obj) => {
|
33
|
+
return Object.keys(obj).every((key) => typeof key === 'string');
|
34
|
+
}, {
|
35
|
+
message: 'All keys must be strings',
|
36
|
+
})
|
37
|
+
.refine((obj) => {
|
38
|
+
return Object.values(obj).every((value) => typeof value !== 'undefined');
|
39
|
+
}, {
|
40
|
+
message: 'All values must be defined',
|
41
|
+
})
|
42
|
+
.pipe(zod_1.default.record(zod_1.default.unknown())),
|
43
|
+
});
|
44
|
+
//# sourceMappingURL=fields.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"fields.js","sourceRoot":"","sources":["../../../../../../extensions/sfdc/actions/createLead/config/fields.ts"],"names":[],"mappings":";;;;;;AAAA,mEAAqE;AACrE,8CAAwC;AAE3B,QAAA,MAAM,GAAG;IACpB,IAAI,EAAE;QACJ,EAAE,EAAE,MAAM;QACV,KAAK,EAAE,MAAM;QACb,WAAW,EAAE,qCAAqC;QAClD,IAAI,EAAE,2BAAS,CAAC,IAAI;QACpB,QAAQ,EAAE,IAAI;KACf;CAC8B,CAAA;AAEpB,QAAA,sBAAsB,GAAG,aAAC,CAAC,MAAM,CAAC;IAC7C,IAAI,EAAE,aAAC;SACJ,MAAM,EAAE;SACR,SAAS,CAAC,CAAC,GAAG,EAAE,EAAE;QACjB,IAAI;YACF,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;SACvB;QAAC,OAAO,CAAC,EAAE;YACV,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAA;SACvC;IACH,CAAC,CAAC;SACD,MAAM,CACL,CAAC,GAAG,EAAE,EAAE,CAAC,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,EACvE;QACE,OAAO,EAAE,+BAA+B;KACzC,CACF;SACA,MAAM,CACL,CAAC,GAAG,EAAE,EAAE;QACN,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,OAAO,GAAG,KAAK,QAAQ,CAAC,CAAA;IACjE,CAAC,EACD;QACE,OAAO,EAAE,0BAA0B;KACpC,CACF;SACA,MAAM,CACL,CAAC,GAAG,EAAE,EAAE;QACN,OAAO,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,OAAO,KAAK,KAAK,WAAW,CAAC,CAAA;IAC1E,CAAC,EACD;QACE,OAAO,EAAE,4BAA4B;KACtC,CACF;SACA,IAAI,CAAC,aAAC,CAAC,MAAM,CAAC,aAAC,CAAC,OAAO,EAAE,CAAC,CAAC;CACmB,CAAC,CAAA"}
|
@@ -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/sfdc/actions/createLead/config/index.ts"],"names":[],"mappings":";;;AAAA,mCAAyD;AAAhD,gGAAA,MAAM,OAAA;AAAE,gHAAA,sBAAsB,OAAA;AACvC,2CAAyC;AAAhC,wGAAA,UAAU,OAAA"}
|
@@ -0,0 +1,31 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.createLead = void 0;
|
4
|
+
const extensions_core_1 = require("@awell-health/extensions-core");
|
5
|
+
const config_1 = require("./config");
|
6
|
+
const lib_1 = require("../../lib");
|
7
|
+
exports.createLead = {
|
8
|
+
key: 'createLead',
|
9
|
+
category: extensions_core_1.Category.CUSTOMER_SUPPORT,
|
10
|
+
title: 'Create lead',
|
11
|
+
description: 'Creates a new lead object in Salesforce',
|
12
|
+
fields: config_1.fields,
|
13
|
+
previewable: false,
|
14
|
+
dataPoints: config_1.dataPoints,
|
15
|
+
onActivityCreated: async (payload, onComplete, onError) => {
|
16
|
+
const { fields, salesforceClient } = await (0, lib_1.validatePayloadAndCreateClient)({
|
17
|
+
fieldsSchema: config_1.FieldsValidationSchema,
|
18
|
+
payload,
|
19
|
+
});
|
20
|
+
const res = await salesforceClient.createRecord({
|
21
|
+
sObject: 'Lead',
|
22
|
+
data: fields.data,
|
23
|
+
});
|
24
|
+
await onComplete({
|
25
|
+
data_points: {
|
26
|
+
createdLeadId: String(res.id),
|
27
|
+
},
|
28
|
+
});
|
29
|
+
},
|
30
|
+
};
|
31
|
+
//# sourceMappingURL=createLead.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"createLead.js","sourceRoot":"","sources":["../../../../../extensions/sfdc/actions/createLead/createLead.ts"],"names":[],"mappings":";;;AAAA,mEAAqE;AAErE,qCAAqE;AACrE,mCAA0D;AAE7C,QAAA,UAAU,GAInB;IACF,GAAG,EAAE,YAAY;IACjB,QAAQ,EAAE,0BAAQ,CAAC,gBAAgB;IACnC,KAAK,EAAE,aAAa;IACpB,WAAW,EAAE,yCAAyC;IACtD,MAAM,EAAN,eAAM;IACN,WAAW,EAAE,KAAK;IAClB,UAAU,EAAV,mBAAU;IACV,iBAAiB,EAAE,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,EAAiB,EAAE;QACvE,MAAM,EAAE,MAAM,EAAE,gBAAgB,EAAE,GAAG,MAAM,IAAA,oCAA8B,EAAC;YACxE,YAAY,EAAE,+BAAsB;YACpC,OAAO;SACR,CAAC,CAAA;QAEF,MAAM,GAAG,GAAG,MAAM,gBAAgB,CAAC,YAAY,CAAC;YAC9C,OAAO,EAAE,MAAM;YACf,IAAI,EAAE,MAAM,CAAC,IAAI;SAClB,CAAC,CAAA;QAEF,MAAM,UAAU,CAAC;YACf,WAAW,EAAE;gBACX,aAAa,EAAE,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC;aAC9B;SACF,CAAC,CAAA;IACJ,CAAC;CACF,CAAA"}
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1,36 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
const _1 = require(".");
|
4
|
+
const tests_1 = require("../../../../src/tests");
|
5
|
+
const __mocks__1 = require("../../api/__mocks__");
|
6
|
+
jest.mock('../../api/client');
|
7
|
+
describe('Salesforce - Create Lead', () => {
|
8
|
+
const onComplete = jest.fn();
|
9
|
+
const onError = jest.fn();
|
10
|
+
beforeEach(() => {
|
11
|
+
jest.clearAllMocks();
|
12
|
+
});
|
13
|
+
test('Should create a Lead', async () => {
|
14
|
+
const mockOnActivityCreateParams = (0, tests_1.generateTestPayload)({
|
15
|
+
fields: {
|
16
|
+
data: JSON.stringify({
|
17
|
+
RecordTypeId: '0125w000000BRDxAAO',
|
18
|
+
LeadSource: 'Website',
|
19
|
+
Referral_Type__c: 'Online Search',
|
20
|
+
LastName: 'Doe',
|
21
|
+
Email: 'johndoe@example.com',
|
22
|
+
Phone: '123-456-7890',
|
23
|
+
Status: 'New',
|
24
|
+
}),
|
25
|
+
},
|
26
|
+
settings: __mocks__1.mockSettings,
|
27
|
+
});
|
28
|
+
await _1.createLead.onActivityCreated(mockOnActivityCreateParams, onComplete, onError);
|
29
|
+
expect(onComplete).toHaveBeenCalledWith({
|
30
|
+
data_points: {
|
31
|
+
createdLeadId: String(__mocks__1.mockCreateRecordResponse.id),
|
32
|
+
},
|
33
|
+
});
|
34
|
+
});
|
35
|
+
});
|
36
|
+
//# sourceMappingURL=createLead.test.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"createLead.test.js","sourceRoot":"","sources":["../../../../../extensions/sfdc/actions/createLead/createLead.test.ts"],"names":[],"mappings":";;AAAA,wBAA8B;AAC9B,iDAA2D;AAC3D,kDAA4E;AAE5E,IAAI,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAA;AAE7B,QAAQ,CAAC,0BAA0B,EAAE,GAAG,EAAE;IACxC,MAAM,UAAU,GAAG,IAAI,CAAC,EAAE,EAAE,CAAA;IAC5B,MAAM,OAAO,GAAG,IAAI,CAAC,EAAE,EAAE,CAAA;IAEzB,UAAU,CAAC,GAAG,EAAE;QACd,IAAI,CAAC,aAAa,EAAE,CAAA;IACtB,CAAC,CAAC,CAAA;IAEF,IAAI,CAAC,sBAAsB,EAAE,KAAK,IAAI,EAAE;QACtC,MAAM,0BAA0B,GAAG,IAAA,2BAAmB,EAAC;YACrD,MAAM,EAAE;gBACN,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;oBACnB,YAAY,EAAE,oBAAoB;oBAClC,UAAU,EAAE,SAAS;oBACrB,gBAAgB,EAAE,eAAe;oBACjC,QAAQ,EAAE,KAAK;oBACf,KAAK,EAAE,qBAAqB;oBAC5B,KAAK,EAAE,cAAc;oBACrB,MAAM,EAAE,KAAK;iBACd,CAAC;aACH;YACD,QAAQ,EAAE,uBAAY;SACvB,CAAC,CAAA;QAEF,MAAM,aAAU,CAAC,iBAAiB,CAChC,0BAA0B,EAC1B,UAAU,EACV,OAAO,CACR,CAAA;QAED,MAAM,CAAC,UAAU,CAAC,CAAC,oBAAoB,CAAC;YACtC,WAAW,EAAE;gBACX,aAAa,EAAE,MAAM,CAAC,mCAAwB,CAAC,EAAE,CAAC;aACnD;SACF,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
@@ -0,0 +1 @@
|
|
1
|
+
export { createLead } from './createLead';
|
@@ -0,0 +1,6 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.createLead = void 0;
|
4
|
+
var createLead_1 = require("./createLead");
|
5
|
+
Object.defineProperty(exports, "createLead", { enumerable: true, get: function () { return createLead_1.createLead; } });
|
6
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../extensions/sfdc/actions/createLead/index.ts"],"names":[],"mappings":";;;AAAA,2CAAyC;AAAhC,wGAAA,UAAU,OAAA"}
|
@@ -0,0 +1,55 @@
|
|
1
|
+
declare const actions: {
|
2
|
+
createLead: import("@awell-health/extensions-core").Action<{
|
3
|
+
data: {
|
4
|
+
id: string;
|
5
|
+
label: string;
|
6
|
+
description: string;
|
7
|
+
type: import("@awell-health/extensions-core").FieldType.JSON;
|
8
|
+
required: true;
|
9
|
+
};
|
10
|
+
}, {
|
11
|
+
salesforceSubdomain: {
|
12
|
+
key: string;
|
13
|
+
label: string;
|
14
|
+
obfuscated: false;
|
15
|
+
required: true;
|
16
|
+
description: string;
|
17
|
+
};
|
18
|
+
clientId: {
|
19
|
+
key: string;
|
20
|
+
label: string;
|
21
|
+
obfuscated: false;
|
22
|
+
required: true;
|
23
|
+
description: string;
|
24
|
+
};
|
25
|
+
clientSecret: {
|
26
|
+
key: string;
|
27
|
+
label: string;
|
28
|
+
obfuscated: true;
|
29
|
+
required: true;
|
30
|
+
description: string;
|
31
|
+
};
|
32
|
+
username: {
|
33
|
+
key: string;
|
34
|
+
label: string;
|
35
|
+
obfuscated: false;
|
36
|
+
required: false;
|
37
|
+
description: string;
|
38
|
+
};
|
39
|
+
password: {
|
40
|
+
key: string;
|
41
|
+
label: string;
|
42
|
+
obfuscated: true;
|
43
|
+
required: false;
|
44
|
+
description: string;
|
45
|
+
};
|
46
|
+
apiVersion: {
|
47
|
+
key: string;
|
48
|
+
label: string;
|
49
|
+
obfuscated: false;
|
50
|
+
required: false;
|
51
|
+
description: string;
|
52
|
+
};
|
53
|
+
}, "createdLeadId">;
|
54
|
+
};
|
55
|
+
export default actions;
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../extensions/sfdc/actions/index.ts"],"names":[],"mappings":";;AAAA,6CAAyC;AAEzC,MAAM,OAAO,GAAG;IACd,UAAU,EAAV,uBAAU;CACX,CAAA;AAED,kBAAe,OAAO,CAAA"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"datapoints.js","sourceRoot":"","sources":["../../../../../../extensions/sfdc/actions/testAction/config/datapoints.ts"],"names":[],"mappings":";;;AAEa,QAAA,UAAU,GAAG;IACxB,GAAG,EAAE;QACH,GAAG,EAAE,KAAK;QACV,SAAS,EAAE,MAAM;KAClB;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
|
+
sObject: {
|
5
|
+
id: string;
|
6
|
+
label: string;
|
7
|
+
description: string;
|
8
|
+
type: FieldType.STRING;
|
9
|
+
required: true;
|
10
|
+
};
|
11
|
+
};
|
12
|
+
export declare const FieldsValidationSchema: z.ZodObject<{
|
13
|
+
sObject: z.ZodString;
|
14
|
+
}, "strip", z.ZodTypeAny, {
|
15
|
+
sObject: string;
|
16
|
+
}, {
|
17
|
+
sObject: string;
|
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
|
+
sObject: {
|
11
|
+
id: 'sObject',
|
12
|
+
label: 'sObject',
|
13
|
+
description: '',
|
14
|
+
type: extensions_core_1.FieldType.STRING,
|
15
|
+
required: true,
|
16
|
+
},
|
17
|
+
};
|
18
|
+
exports.FieldsValidationSchema = zod_1.default.object({
|
19
|
+
sObject: zod_1.default.string().min(1),
|
20
|
+
});
|
21
|
+
//# sourceMappingURL=fields.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"fields.js","sourceRoot":"","sources":["../../../../../../extensions/sfdc/actions/testAction/config/fields.ts"],"names":[],"mappings":";;;;;;AAAA,mEAAqE;AACrE,8CAAwC;AAE3B,QAAA,MAAM,GAAG;IACpB,OAAO,EAAE;QACP,EAAE,EAAE,SAAS;QACb,KAAK,EAAE,SAAS;QAChB,WAAW,EAAE,EAAE;QACf,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,CAAC;CACuB,CAAC,CAAA"}
|
@@ -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/sfdc/actions/testAction/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 { testAction } from './testAction';
|
@@ -0,0 +1,6 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.testAction = void 0;
|
4
|
+
var testAction_1 = require("./testAction");
|
5
|
+
Object.defineProperty(exports, "testAction", { enumerable: true, get: function () { return testAction_1.testAction; } });
|
6
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../extensions/sfdc/actions/testAction/index.ts"],"names":[],"mappings":";;;AAAA,2CAAyC;AAAhC,wGAAA,UAAU,OAAA"}
|
@@ -0,0 +1,28 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.testAction = void 0;
|
4
|
+
const extensions_core_1 = require("@awell-health/extensions-core");
|
5
|
+
const config_1 = require("./config");
|
6
|
+
const lib_1 = require("../../lib");
|
7
|
+
exports.testAction = {
|
8
|
+
key: 'testAction',
|
9
|
+
category: extensions_core_1.Category.CUSTOMER_SUPPORT,
|
10
|
+
title: 'Test action',
|
11
|
+
description: 'Test connection with SFDC',
|
12
|
+
fields: config_1.fields,
|
13
|
+
previewable: false,
|
14
|
+
dataPoints: config_1.dataPoints,
|
15
|
+
onActivityCreated: async (payload, onComplete, onError) => {
|
16
|
+
const { fields, salesforceClient } = await (0, lib_1.validatePayloadAndCreateClient)({
|
17
|
+
fieldsSchema: config_1.FieldsValidationSchema,
|
18
|
+
payload,
|
19
|
+
});
|
20
|
+
const res = await salesforceClient.getRecordShape(fields.sObject);
|
21
|
+
await onComplete({
|
22
|
+
data_points: {
|
23
|
+
res: JSON.stringify(res),
|
24
|
+
},
|
25
|
+
});
|
26
|
+
},
|
27
|
+
};
|
28
|
+
//# sourceMappingURL=testAction.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"testAction.js","sourceRoot":"","sources":["../../../../../extensions/sfdc/actions/testAction/testAction.ts"],"names":[],"mappings":";;;AAAA,mEAAqE;AAErE,qCAAqE;AACrE,mCAA0D;AAE7C,QAAA,UAAU,GAInB;IACF,GAAG,EAAE,YAAY;IACjB,QAAQ,EAAE,0BAAQ,CAAC,gBAAgB;IACnC,KAAK,EAAE,aAAa;IACpB,WAAW,EAAE,2BAA2B;IACxC,MAAM,EAAN,eAAM;IACN,WAAW,EAAE,KAAK;IAClB,UAAU,EAAV,mBAAU;IACV,iBAAiB,EAAE,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,EAAiB,EAAE;QACvE,MAAM,EAAE,MAAM,EAAE,gBAAgB,EAAE,GAAG,MAAM,IAAA,oCAA8B,EAAC;YACxE,YAAY,EAAE,+BAAsB;YACpC,OAAO;SACR,CAAC,CAAA;QAEF,MAAM,GAAG,GAAG,MAAM,gBAAgB,CAAC,cAAc,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;QAEjE,MAAM,UAAU,CAAC;YACf,WAAW,EAAE;gBACX,GAAG,EAAE,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC;aACzB;SACF,CAAC,CAAA;IACJ,CAAC;CACF,CAAA"}
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1,27 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
const _1 = require(".");
|
4
|
+
const tests_1 = require("../../../../src/tests");
|
5
|
+
const __mocks__1 = require("../../api/__mocks__");
|
6
|
+
jest.mock('../../api/client');
|
7
|
+
describe('Salesforce - Test action', () => {
|
8
|
+
const onComplete = jest.fn();
|
9
|
+
const onError = jest.fn();
|
10
|
+
beforeEach(() => {
|
11
|
+
jest.clearAllMocks();
|
12
|
+
});
|
13
|
+
test('Test retrieval of record shape', async () => {
|
14
|
+
const mockOnActivityCreateParams = (0, tests_1.generateTestPayload)({
|
15
|
+
fields: {
|
16
|
+
sObject: 'Lead',
|
17
|
+
},
|
18
|
+
settings: __mocks__1.mockSettings,
|
19
|
+
});
|
20
|
+
await _1.testAction.onActivityCreated(mockOnActivityCreateParams, onComplete, onError);
|
21
|
+
const mockCall = onComplete.mock.calls[0][0];
|
22
|
+
const parsedRes = JSON.parse(mockCall.data_points.res);
|
23
|
+
expect(onComplete).toHaveBeenCalled();
|
24
|
+
expect(parsedRes).toHaveProperty('label', 'Lead');
|
25
|
+
});
|
26
|
+
});
|
27
|
+
//# sourceMappingURL=testAction.test.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"testAction.test.js","sourceRoot":"","sources":["../../../../../extensions/sfdc/actions/testAction/testAction.test.ts"],"names":[],"mappings":";;AAAA,wBAA8B;AAC9B,iDAA2D;AAC3D,kDAAkD;AAElD,IAAI,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAA;AAE7B,QAAQ,CAAC,0BAA0B,EAAE,GAAG,EAAE;IACxC,MAAM,UAAU,GAAG,IAAI,CAAC,EAAE,EAAE,CAAA;IAC5B,MAAM,OAAO,GAAG,IAAI,CAAC,EAAE,EAAE,CAAA;IAEzB,UAAU,CAAC,GAAG,EAAE;QACd,IAAI,CAAC,aAAa,EAAE,CAAA;IACtB,CAAC,CAAC,CAAA;IAEF,IAAI,CAAC,gCAAgC,EAAE,KAAK,IAAI,EAAE;QAChD,MAAM,0BAA0B,GAAG,IAAA,2BAAmB,EAAC;YACrD,MAAM,EAAE;gBACN,OAAO,EAAE,MAAM;aAChB;YACD,QAAQ,EAAE,uBAAY;SACvB,CAAC,CAAA;QAEF,MAAM,aAAU,CAAC,iBAAiB,CAChC,0BAA0B,EAC1B,UAAU,EACV,OAAO,CACR,CAAA;QAED,MAAM,QAAQ,GAAG,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;QAC5C,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,WAAW,CAAC,GAAG,CAAC,CAAA;QAEtD,MAAM,CAAC,UAAU,CAAC,CAAC,gBAAgB,EAAE,CAAA;QACrC,MAAM,CAAC,SAAS,CAAC,CAAC,cAAc,CAAC,OAAO,EAAE,MAAM,CAAC,CAAA;IACnD,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import { cache } from '@awell-health/extensions-core';
|
2
|
+
/**
|
3
|
+
* A cache service can be used in combination with the OAuth API client
|
4
|
+
* to automatically cache tokens between requests.
|
5
|
+
* The only cache implementation available is a simple in-memory cache,
|
6
|
+
* so it has to be initialised as a singleton to preserve the data across
|
7
|
+
* the lifecycle of the server running your extension.
|
8
|
+
* Note that we will soon be releasing another implementation of the cache
|
9
|
+
* service that will remove this restriction.
|
10
|
+
*/
|
11
|
+
export declare const salesforceCacheService: cache.InMemoryCache;
|
@@ -0,0 +1,15 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.salesforceCacheService = void 0;
|
4
|
+
const extensions_core_1 = require("@awell-health/extensions-core");
|
5
|
+
/**
|
6
|
+
* A cache service can be used in combination with the OAuth API client
|
7
|
+
* to automatically cache tokens between requests.
|
8
|
+
* The only cache implementation available is a simple in-memory cache,
|
9
|
+
* so it has to be initialised as a singleton to preserve the data across
|
10
|
+
* the lifecycle of the server running your extension.
|
11
|
+
* Note that we will soon be releasing another implementation of the cache
|
12
|
+
* service that will remove this restriction.
|
13
|
+
*/
|
14
|
+
exports.salesforceCacheService = new extensions_core_1.cache.InMemoryCache();
|
15
|
+
//# sourceMappingURL=cacheService.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"cacheService.js","sourceRoot":"","sources":["../../../../extensions/sfdc/api/cacheService.ts"],"names":[],"mappings":";;;AAAA,mEAAqD;AAErD;;;;;;;;GAQG;AACU,QAAA,sBAAsB,GAAG,IAAI,uBAAK,CAAC,aAAa,EAAE,CAAA"}
|
@@ -0,0 +1,24 @@
|
|
1
|
+
import { APIClient, DataWrapper, type DataWrapperCtor, type OAuthGrantRequest } from '@awell-health/extensions-core';
|
2
|
+
import { type CreateRecordInputType, type CreateRecordResponseType } from './schema';
|
3
|
+
export declare class SalesforceDataWrapper extends DataWrapper {
|
4
|
+
private readonly apiVersion;
|
5
|
+
constructor(token: string, baseUrl: string, opts: {
|
6
|
+
apiVersion: string;
|
7
|
+
});
|
8
|
+
createRecord(input: CreateRecordInputType): Promise<CreateRecordResponseType>;
|
9
|
+
getRecordShape(sObject: string): Promise<unknown>;
|
10
|
+
}
|
11
|
+
interface SalesforceConstructorProps {
|
12
|
+
authUrl: string;
|
13
|
+
requestConfig: Omit<OAuthGrantRequest, 'grant_type'>;
|
14
|
+
baseUrl: string;
|
15
|
+
apiVersion: string;
|
16
|
+
}
|
17
|
+
export declare class SalesforceRestAPIClient extends APIClient<SalesforceDataWrapper> {
|
18
|
+
readonly apiVersion: string;
|
19
|
+
readonly ctor: DataWrapperCtor<SalesforceDataWrapper>;
|
20
|
+
constructor({ authUrl, requestConfig, ...opts }: SalesforceConstructorProps);
|
21
|
+
createRecord(input: CreateRecordInputType): Promise<CreateRecordResponseType>;
|
22
|
+
getRecordShape(sObject: string): Promise<unknown>;
|
23
|
+
}
|
24
|
+
export {};
|
@@ -0,0 +1,68 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.SalesforceRestAPIClient = exports.SalesforceDataWrapper = void 0;
|
4
|
+
const extensions_core_1 = require("@awell-health/extensions-core");
|
5
|
+
const cacheService_1 = require("./cacheService");
|
6
|
+
class SalesforceDataWrapper extends extensions_core_1.DataWrapper {
|
7
|
+
constructor(token, baseUrl, opts) {
|
8
|
+
super(token, baseUrl);
|
9
|
+
this.apiVersion = opts.apiVersion;
|
10
|
+
}
|
11
|
+
async createRecord(input) {
|
12
|
+
const res = await this.Request({
|
13
|
+
method: 'POST',
|
14
|
+
url: `/services/data/${this.apiVersion}/sobjects/${input.sObject}/`,
|
15
|
+
headers: {
|
16
|
+
'Content-Type': 'application/json',
|
17
|
+
},
|
18
|
+
data: JSON.stringify(input.data),
|
19
|
+
});
|
20
|
+
return res;
|
21
|
+
}
|
22
|
+
async getRecordShape(sObject) {
|
23
|
+
const res = await this.Request({
|
24
|
+
method: 'GET',
|
25
|
+
url: `/services/data/${this.apiVersion}/sobjects/${sObject}/describe`,
|
26
|
+
headers: {
|
27
|
+
'Content-Type': 'application/json',
|
28
|
+
},
|
29
|
+
});
|
30
|
+
return res;
|
31
|
+
}
|
32
|
+
}
|
33
|
+
exports.SalesforceDataWrapper = SalesforceDataWrapper;
|
34
|
+
class SalesforceRestAPIClient extends extensions_core_1.APIClient {
|
35
|
+
constructor({ authUrl, requestConfig, ...opts }) {
|
36
|
+
const getAuth = () => {
|
37
|
+
if ('username' in requestConfig && 'password' in requestConfig) {
|
38
|
+
return new extensions_core_1.OAuthPassword({
|
39
|
+
auth_url: authUrl,
|
40
|
+
request_config: requestConfig,
|
41
|
+
/**
|
42
|
+
* Not sure whether caching is possible with the password grant
|
43
|
+
*/
|
44
|
+
// cacheService: salesforceCacheService,
|
45
|
+
});
|
46
|
+
}
|
47
|
+
return new extensions_core_1.OAuthClientCredentials({
|
48
|
+
auth_url: authUrl,
|
49
|
+
request_config: requestConfig,
|
50
|
+
cacheService: cacheService_1.salesforceCacheService,
|
51
|
+
});
|
52
|
+
};
|
53
|
+
super({
|
54
|
+
...opts,
|
55
|
+
auth: getAuth(),
|
56
|
+
});
|
57
|
+
this.ctor = (token, baseUrl) => new SalesforceDataWrapper(token, baseUrl, { apiVersion: this.apiVersion });
|
58
|
+
this.apiVersion = opts.apiVersion;
|
59
|
+
}
|
60
|
+
async createRecord(input) {
|
61
|
+
return await this.FetchData(async (dw) => await dw.createRecord(input));
|
62
|
+
}
|
63
|
+
async getRecordShape(sObject) {
|
64
|
+
return await this.FetchData(async (dw) => await dw.getRecordShape(sObject));
|
65
|
+
}
|
66
|
+
}
|
67
|
+
exports.SalesforceRestAPIClient = SalesforceRestAPIClient;
|
68
|
+
//# sourceMappingURL=client.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../../../extensions/sfdc/api/client.ts"],"names":[],"mappings":";;;AAAA,mEASsC;AACtC,iDAAuD;AAMvD,MAAa,qBAAsB,SAAQ,6BAAW;IAGpD,YACE,KAAa,EACb,OAAe,EACf,IAEC;QAED,KAAK,CAAC,KAAK,EAAE,OAAO,CAAC,CAAA;QAErB,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAA;IACnC,CAAC;IAEM,KAAK,CAAC,YAAY,CACvB,KAA4B;QAE5B,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,OAAO,CAA2B;YACvD,MAAM,EAAE,MAAM;YACd,GAAG,EAAE,kBAAkB,IAAI,CAAC,UAAU,aAAa,KAAK,CAAC,OAAO,GAAG;YACnE,OAAO,EAAE;gBACP,cAAc,EAAE,kBAAkB;aACnC;YACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC;SACjC,CAAC,CAAA;QAEF,OAAO,GAAG,CAAA;IACZ,CAAC;IAEM,KAAK,CAAC,cAAc,CAAC,OAAe;QACzC,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,OAAO,CAAU;YACtC,MAAM,EAAE,KAAK;YACb,GAAG,EAAE,kBAAkB,IAAI,CAAC,UAAU,aAAa,OAAO,WAAW;YACrE,OAAO,EAAE;gBACP,cAAc,EAAE,kBAAkB;aACnC;SACF,CAAC,CAAA;QAEF,OAAO,GAAG,CAAA;IACZ,CAAC;CACF;AAzCD,sDAyCC;AASD,MAAa,uBAAwB,SAAQ,2BAAgC;IAS3E,YAAmB,EACjB,OAAO,EACP,aAAa,EACb,GAAG,IAAI,EACoB;QAC3B,MAAM,OAAO,GAAG,GAA2C,EAAE;YAC3D,IAAI,UAAU,IAAI,aAAa,IAAI,UAAU,IAAI,aAAa,EAAE;gBAC9D,OAAO,IAAI,+BAAa,CAAC;oBACvB,QAAQ,EAAE,OAAO;oBACjB,cAAc,EAAE,aAGf;oBACD;;uBAEG;oBACH,wCAAwC;iBACzC,CAAC,CAAA;aACH;YAED,OAAO,IAAI,wCAAsB,CAAC;gBAChC,QAAQ,EAAE,OAAO;gBACjB,cAAc,EAAE,aAGf;gBACD,YAAY,EAAE,qCAAsB;aACrC,CAAC,CAAA;QACJ,CAAC,CAAA;QAED,KAAK,CAAC;YACJ,GAAG,IAAI;YACP,IAAI,EAAE,OAAO,EAAE;SAChB,CAAC,CAAA;QAvCK,SAAI,GAA2C,CACtD,KAAa,EACb,OAAe,EACf,EAAE,CACF,IAAI,qBAAqB,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,CAAC,CAAA;QAqC1E,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAA;IACnC,CAAC;IAEM,KAAK,CAAC,YAAY,CACvB,KAA4B;QAE5B,OAAO,MAAM,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,EAAE,EAAE,EAAE,CAAC,MAAM,EAAE,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAA;IACzE,CAAC;IAEM,KAAK,CAAC,cAAc,CAAC,OAAe;QACzC,OAAO,MAAM,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,EAAE,EAAE,EAAE,CAAC,MAAM,EAAE,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,CAAA;IAC7E,CAAC;CACF;AAxDD,0DAwDC"}
|
@@ -0,0 +1,5 @@
|
|
1
|
+
export type SFDCApiType = 'REST';
|
2
|
+
export type GrantType = 'password' | 'client_credentials';
|
3
|
+
export declare const DEFAULT_API_VERSION = "v61.0";
|
4
|
+
export declare const getAuthUrl: (apiType: SFDCApiType, grant_type: GrantType, subdomain: string) => string;
|
5
|
+
export declare const getApiUrl: (apiType: SFDCApiType, subdomain: string) => string;
|
@@ -0,0 +1,21 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.getApiUrl = exports.getAuthUrl = exports.DEFAULT_API_VERSION = void 0;
|
4
|
+
exports.DEFAULT_API_VERSION = 'v61.0';
|
5
|
+
const getAuthUrl = (apiType, grant_type, subdomain) => {
|
6
|
+
if (grant_type === 'password')
|
7
|
+
return 'https://test.salesforce.com/services/oauth2/token';
|
8
|
+
if (apiType === 'REST') {
|
9
|
+
return `https://${subdomain}.my.salesforce.com/services/oauth2/token`;
|
10
|
+
}
|
11
|
+
throw new Error(`No auth URL available for the Salesforce ${apiType} API`);
|
12
|
+
};
|
13
|
+
exports.getAuthUrl = getAuthUrl;
|
14
|
+
const getApiUrl = (apiType, subdomain) => {
|
15
|
+
if (apiType === 'REST') {
|
16
|
+
return `https://${subdomain}.my.salesforce.com`;
|
17
|
+
}
|
18
|
+
throw new Error(`No API URL available for the SFDC ${apiType} API`);
|
19
|
+
};
|
20
|
+
exports.getApiUrl = getApiUrl;
|
21
|
+
//# sourceMappingURL=constants.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../extensions/sfdc/api/constants.ts"],"names":[],"mappings":";;;AAGa,QAAA,mBAAmB,GAAG,OAAO,CAAA;AAEnC,MAAM,UAAU,GAAG,CACxB,OAAoB,EACpB,UAAqB,EACrB,SAAiB,EACT,EAAE;IACV,IAAI,UAAU,KAAK,UAAU;QAC3B,OAAO,mDAAmD,CAAA;IAE5D,IAAI,OAAO,KAAK,MAAM,EAAE;QACtB,OAAO,WAAW,SAAS,0CAA0C,CAAA;KACtE;IAED,MAAM,IAAI,KAAK,CACb,4CAA4C,OAAiB,MAAM,CACpE,CAAA;AACH,CAAC,CAAA;AAfY,QAAA,UAAU,cAetB;AAEM,MAAM,SAAS,GAAG,CAAC,OAAoB,EAAE,SAAiB,EAAU,EAAE;IAC3E,IAAI,OAAO,KAAK,MAAM,EAAE;QACtB,OAAO,WAAW,SAAS,oBAAoB,CAAA;KAChD;IAED,MAAM,IAAI,KAAK,CAAC,qCAAqC,OAAiB,MAAM,CAAC,CAAA;AAC/E,CAAC,CAAA;AANY,QAAA,SAAS,aAMrB"}
|
@@ -0,0 +1 @@
|
|
1
|
+
export * from './record.schema';
|
@@ -0,0 +1,18 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
+
if (k2 === undefined) k2 = k;
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
7
|
+
}
|
8
|
+
Object.defineProperty(o, k2, desc);
|
9
|
+
}) : (function(o, m, k, k2) {
|
10
|
+
if (k2 === undefined) k2 = k;
|
11
|
+
o[k2] = m[k];
|
12
|
+
}));
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
15
|
+
};
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
17
|
+
__exportStar(require("./record.schema"), exports);
|
18
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../extensions/sfdc/api/schema/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kDAA+B"}
|
@@ -0,0 +1,26 @@
|
|
1
|
+
import { z } from 'zod';
|
2
|
+
export declare const CreateRecordInputSchema: z.ZodObject<{
|
3
|
+
sObject: z.ZodString;
|
4
|
+
data: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
5
|
+
}, "strip", z.ZodTypeAny, {
|
6
|
+
data: Record<string, unknown>;
|
7
|
+
sObject: string;
|
8
|
+
}, {
|
9
|
+
data: Record<string, unknown>;
|
10
|
+
sObject: string;
|
11
|
+
}>;
|
12
|
+
export type CreateRecordInputType = z.infer<typeof CreateRecordInputSchema>;
|
13
|
+
export declare const CreateRecordResponseSchema: z.ZodObject<{
|
14
|
+
id: z.ZodString;
|
15
|
+
errors: z.ZodArray<z.ZodUnknown, "many">;
|
16
|
+
success: z.ZodBoolean;
|
17
|
+
}, "strip", z.ZodTypeAny, {
|
18
|
+
id: string;
|
19
|
+
success: boolean;
|
20
|
+
errors: unknown[];
|
21
|
+
}, {
|
22
|
+
id: string;
|
23
|
+
success: boolean;
|
24
|
+
errors: unknown[];
|
25
|
+
}>;
|
26
|
+
export type CreateRecordResponseType = z.infer<typeof CreateRecordResponseSchema>;
|
@@ -0,0 +1,14 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.CreateRecordResponseSchema = exports.CreateRecordInputSchema = void 0;
|
4
|
+
const zod_1 = require("zod");
|
5
|
+
exports.CreateRecordInputSchema = zod_1.z.object({
|
6
|
+
sObject: zod_1.z.string().min(1),
|
7
|
+
data: zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()),
|
8
|
+
});
|
9
|
+
exports.CreateRecordResponseSchema = zod_1.z.object({
|
10
|
+
id: zod_1.z.string(),
|
11
|
+
errors: zod_1.z.array(zod_1.z.unknown()),
|
12
|
+
success: zod_1.z.boolean(),
|
13
|
+
});
|
14
|
+
//# sourceMappingURL=record.schema.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"record.schema.js","sourceRoot":"","sources":["../../../../../extensions/sfdc/api/schema/record.schema.ts"],"names":[],"mappings":";;;AAAA,6BAAuB;AAEV,QAAA,uBAAuB,GAAG,OAAC,CAAC,MAAM,CAAC;IAC9C,OAAO,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC1B,IAAI,EAAE,OAAC,CAAC,MAAM,CAAC,OAAC,CAAC,MAAM,EAAE,EAAE,OAAC,CAAC,OAAO,EAAE,CAAC;CACxC,CAAC,CAAA;AAIW,QAAA,0BAA0B,GAAG,OAAC,CAAC,MAAM,CAAC;IACjD,EAAE,EAAE,OAAC,CAAC,MAAM,EAAE;IACd,MAAM,EAAE,OAAC,CAAC,KAAK,CAAC,OAAC,CAAC,OAAO,EAAE,CAAC;IAC5B,OAAO,EAAE,OAAC,CAAC,OAAO,EAAE;CACrB,CAAC,CAAA"}
|
@@ -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.sfdc = 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.sfdc = {
|
11
|
+
key: 'sfdc',
|
12
|
+
title: 'Salesforce',
|
13
|
+
description: 'Salesforce.com is a cloud-based customer relationship management (CRM) software used to manage customer data, sales processes, marketing campaigns, and customer service activities',
|
14
|
+
icon_url: 'https://res.cloudinary.com/da7x4rzl4/image/upload/v1723280338/Awell%20Extensions/logo-sfdc-netherlands-b-v-salesforce-com.jpg',
|
15
|
+
category: extensions_core_1.Category.CUSTOMER_SUPPORT,
|
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/sfdc/index.ts"],"names":[],"mappings":";;;;;;AAAA,mEAIsC;AACtC,wDAA+B;AAC/B,yCAAqC;AAExB,QAAA,IAAI,GAAc;IAC7B,GAAG,EAAE,MAAM;IACX,KAAK,EAAE,YAAY;IACnB,WAAW,EACT,qLAAqL;IACvL,QAAQ,EACN,+HAA+H;IACjI,QAAQ,EAAE,0BAAQ,CAAC,gBAAgB;IACnC,MAAM,EAAE;QACN,UAAU,EAAE,4BAAU,CAAC,KAAK;KAC7B;IACD,QAAQ,EAAR,mBAAQ;IACR,OAAO,EAAP,iBAAO;CACR,CAAA"}
|
@@ -0,0 +1 @@
|
|
1
|
+
export { validatePayloadAndCreateClient } from './validatePayloadAndCreateClient';
|
@@ -0,0 +1,6 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.validatePayloadAndCreateClient = void 0;
|
4
|
+
var validatePayloadAndCreateClient_1 = require("./validatePayloadAndCreateClient");
|
5
|
+
Object.defineProperty(exports, "validatePayloadAndCreateClient", { enumerable: true, get: function () { return validatePayloadAndCreateClient_1.validatePayloadAndCreateClient; } });
|
6
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../extensions/sfdc/lib/index.ts"],"names":[],"mappings":";;;AAAA,mFAAiF;AAAxE,gJAAA,8BAA8B,OAAA"}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
import z from 'zod';
|
2
|
+
import { SalesforceRestAPIClient } from '../api/client';
|
3
|
+
import { SettingsValidationSchema } from '../settings';
|
4
|
+
type ValidateAndCreateClient = <T extends z.ZodTypeAny>(args: {
|
5
|
+
fieldsSchema: T;
|
6
|
+
payload: unknown;
|
7
|
+
}) => Promise<{
|
8
|
+
salesforceClient: SalesforceRestAPIClient;
|
9
|
+
fields: z.infer<(typeof args)['fieldsSchema']>;
|
10
|
+
settings: z.infer<typeof SettingsValidationSchema>;
|
11
|
+
pathwayId: string;
|
12
|
+
activityId: string;
|
13
|
+
}>;
|
14
|
+
export declare const validatePayloadAndCreateClient: ValidateAndCreateClient;
|
15
|
+
export {};
|
@@ -0,0 +1,54 @@
|
|
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.validatePayloadAndCreateClient = void 0;
|
7
|
+
const extensions_core_1 = require("@awell-health/extensions-core");
|
8
|
+
const lodash_1 = require("lodash");
|
9
|
+
const zod_1 = __importDefault(require("zod"));
|
10
|
+
const client_1 = require("../api/client");
|
11
|
+
const constants_1 = require("../api/constants");
|
12
|
+
const settings_1 = require("../settings");
|
13
|
+
const validatePayloadAndCreateClient = async ({ fieldsSchema, payload, }) => {
|
14
|
+
const { settings: { salesforceSubdomain, clientId, clientSecret, username, password, apiVersion, }, pathway: { id: pathwayId }, activity: { id: activityId }, fields, settings, } = (0, extensions_core_1.validate)({
|
15
|
+
schema: zod_1.default.object({
|
16
|
+
fields: fieldsSchema,
|
17
|
+
settings: settings_1.SettingsValidationSchema,
|
18
|
+
pathway: zod_1.default.object({ id: zod_1.default.string() }),
|
19
|
+
activity: zod_1.default.object({ id: zod_1.default.string() }),
|
20
|
+
}),
|
21
|
+
payload,
|
22
|
+
});
|
23
|
+
const getGrantType = () => {
|
24
|
+
if ((0, lodash_1.isEmpty)(username) || (0, lodash_1.isEmpty)(password))
|
25
|
+
return 'client_credentials';
|
26
|
+
return 'password';
|
27
|
+
};
|
28
|
+
const grantType = getGrantType();
|
29
|
+
const getRequestConfig = () => {
|
30
|
+
if (grantType === 'client_credentials')
|
31
|
+
return {
|
32
|
+
client_id: clientId,
|
33
|
+
client_secret: clientSecret,
|
34
|
+
};
|
35
|
+
if (!(0, lodash_1.isEmpty)(username) && !(0, lodash_1.isEmpty)(password)) {
|
36
|
+
return {
|
37
|
+
client_id: clientId,
|
38
|
+
client_secret: clientSecret,
|
39
|
+
username: username,
|
40
|
+
password: password,
|
41
|
+
};
|
42
|
+
}
|
43
|
+
throw new Error('Should not happen');
|
44
|
+
};
|
45
|
+
const salesforceClient = new client_1.SalesforceRestAPIClient({
|
46
|
+
authUrl: (0, constants_1.getAuthUrl)('REST', grantType, salesforceSubdomain),
|
47
|
+
baseUrl: (0, constants_1.getApiUrl)('REST', salesforceSubdomain),
|
48
|
+
requestConfig: getRequestConfig(),
|
49
|
+
apiVersion: apiVersion !== null && apiVersion !== void 0 ? apiVersion : constants_1.DEFAULT_API_VERSION,
|
50
|
+
});
|
51
|
+
return { salesforceClient, fields, settings, pathwayId, activityId };
|
52
|
+
};
|
53
|
+
exports.validatePayloadAndCreateClient = validatePayloadAndCreateClient;
|
54
|
+
//# sourceMappingURL=validatePayloadAndCreateClient.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"validatePayloadAndCreateClient.js","sourceRoot":"","sources":["../../../../extensions/sfdc/lib/validatePayloadAndCreateClient.ts"],"names":[],"mappings":";;;;;;AAAA,mEAIsC;AACtC,mCAAgC;AAChC,8CAAmB;AACnB,0CAAuD;AACvD,gDAKyB;AACzB,0CAAsD;AAa/C,MAAM,8BAA8B,GAA4B,KAAK,EAAE,EAC5E,YAAY,EACZ,OAAO,GACR,EAAE,EAAE;IACH,MAAM,EACJ,QAAQ,EAAE,EACR,mBAAmB,EACnB,QAAQ,EACR,YAAY,EACZ,QAAQ,EACR,QAAQ,EACR,UAAU,GACX,EACD,OAAO,EAAE,EAAE,EAAE,EAAE,SAAS,EAAE,EAC1B,QAAQ,EAAE,EAAE,EAAE,EAAE,UAAU,EAAE,EAC5B,MAAM,EACN,QAAQ,GACT,GAAG,IAAA,0BAAQ,EAAC;QACX,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;SACvC,CAAC;QACF,OAAO;KACR,CAAC,CAAA;IAEF,MAAM,YAAY,GAAG,GAAc,EAAE;QACnC,IAAI,IAAA,gBAAO,EAAC,QAAQ,CAAC,IAAI,IAAA,gBAAO,EAAC,QAAQ,CAAC;YAAE,OAAO,oBAAoB,CAAA;QAEvE,OAAO,UAAU,CAAA;IACnB,CAAC,CAAA;IAED,MAAM,SAAS,GAAG,YAAY,EAAE,CAAA;IAEhC,MAAM,gBAAgB,GAAG,GAEyB,EAAE;QAClD,IAAI,SAAS,KAAK,oBAAoB;YACpC,OAAO;gBACL,SAAS,EAAE,QAAQ;gBACnB,aAAa,EAAE,YAAY;aACqC,CAAA;QAEpE,IAAI,CAAC,IAAA,gBAAO,EAAC,QAAQ,CAAC,IAAI,CAAC,IAAA,gBAAO,EAAC,QAAQ,CAAC,EAAE;YAC5C,OAAO;gBACL,SAAS,EAAE,QAAQ;gBACnB,aAAa,EAAE,YAAY;gBAC3B,QAAQ,EAAE,QAAkB;gBAC5B,QAAQ,EAAE,QAAkB;aAC2B,CAAA;SAC1D;QAED,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAA;IACtC,CAAC,CAAA;IAED,MAAM,gBAAgB,GAAG,IAAI,gCAAuB,CAAC;QACnD,OAAO,EAAE,IAAA,sBAAU,EAAC,MAAM,EAAE,SAAS,EAAE,mBAAmB,CAAC;QAC3D,OAAO,EAAE,IAAA,qBAAS,EAAC,MAAM,EAAE,mBAAmB,CAAC;QAC/C,aAAa,EAAE,gBAAgB,EAAE;QACjC,UAAU,EAAE,UAAU,aAAV,UAAU,cAAV,UAAU,GAAI,+BAAmB;KAC9C,CAAC,CAAA;IAEF,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,UAAU,EAAE,CAAA;AACtE,CAAC,CAAA;AAhEY,QAAA,8BAA8B,kCAgE1C"}
|
@@ -0,0 +1,67 @@
|
|
1
|
+
import { z } from 'zod';
|
2
|
+
export declare const settings: {
|
3
|
+
salesforceSubdomain: {
|
4
|
+
key: string;
|
5
|
+
label: string;
|
6
|
+
obfuscated: false;
|
7
|
+
required: true;
|
8
|
+
description: string;
|
9
|
+
};
|
10
|
+
clientId: {
|
11
|
+
key: string;
|
12
|
+
label: string;
|
13
|
+
obfuscated: false;
|
14
|
+
required: true;
|
15
|
+
description: string;
|
16
|
+
};
|
17
|
+
clientSecret: {
|
18
|
+
key: string;
|
19
|
+
label: string;
|
20
|
+
obfuscated: true;
|
21
|
+
required: true;
|
22
|
+
description: string;
|
23
|
+
};
|
24
|
+
username: {
|
25
|
+
key: string;
|
26
|
+
label: string;
|
27
|
+
obfuscated: false;
|
28
|
+
required: false;
|
29
|
+
description: string;
|
30
|
+
};
|
31
|
+
password: {
|
32
|
+
key: string;
|
33
|
+
label: string;
|
34
|
+
obfuscated: true;
|
35
|
+
required: false;
|
36
|
+
description: string;
|
37
|
+
};
|
38
|
+
apiVersion: {
|
39
|
+
key: string;
|
40
|
+
label: string;
|
41
|
+
obfuscated: false;
|
42
|
+
required: false;
|
43
|
+
description: string;
|
44
|
+
};
|
45
|
+
};
|
46
|
+
export declare const SettingsValidationSchema: z.ZodObject<{
|
47
|
+
salesforceSubdomain: z.ZodString;
|
48
|
+
clientId: z.ZodString;
|
49
|
+
clientSecret: z.ZodString;
|
50
|
+
username: z.ZodOptional<z.ZodString>;
|
51
|
+
password: z.ZodOptional<z.ZodString>;
|
52
|
+
apiVersion: z.ZodOptional<z.ZodString>;
|
53
|
+
}, "strip", z.ZodTypeAny, {
|
54
|
+
clientId: string;
|
55
|
+
clientSecret: string;
|
56
|
+
salesforceSubdomain: string;
|
57
|
+
username?: string | undefined;
|
58
|
+
password?: string | undefined;
|
59
|
+
apiVersion?: string | undefined;
|
60
|
+
}, {
|
61
|
+
clientId: string;
|
62
|
+
clientSecret: string;
|
63
|
+
salesforceSubdomain: string;
|
64
|
+
username?: string | undefined;
|
65
|
+
password?: string | undefined;
|
66
|
+
apiVersion?: string | undefined;
|
67
|
+
}>;
|
@@ -0,0 +1,58 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.SettingsValidationSchema = exports.settings = void 0;
|
4
|
+
const zod_1 = require("zod");
|
5
|
+
const constants_1 = require("./api/constants");
|
6
|
+
exports.settings = {
|
7
|
+
salesforceSubdomain: {
|
8
|
+
key: 'salesforceSubdomain',
|
9
|
+
label: 'Domain name',
|
10
|
+
obfuscated: false,
|
11
|
+
required: true,
|
12
|
+
description: 'The subdomain of your Salesforce tenant (e.g. "awell" or "awell.sandbox")',
|
13
|
+
},
|
14
|
+
clientId: {
|
15
|
+
key: 'clientId',
|
16
|
+
label: 'Client ID',
|
17
|
+
obfuscated: false,
|
18
|
+
required: true,
|
19
|
+
description: '',
|
20
|
+
},
|
21
|
+
clientSecret: {
|
22
|
+
key: 'clientSecret',
|
23
|
+
label: 'Client secret',
|
24
|
+
obfuscated: true,
|
25
|
+
required: true,
|
26
|
+
description: '',
|
27
|
+
},
|
28
|
+
username: {
|
29
|
+
key: 'username',
|
30
|
+
label: 'Username ',
|
31
|
+
obfuscated: false,
|
32
|
+
required: false,
|
33
|
+
description: 'The username of the user that the connected app is imitating. A username is only needed when using the Password grant, leave blank to use client credentials grant.',
|
34
|
+
},
|
35
|
+
password: {
|
36
|
+
key: 'password',
|
37
|
+
label: 'Password ',
|
38
|
+
obfuscated: true,
|
39
|
+
required: false,
|
40
|
+
description: 'The password of the user that the connected app is imitating. A password is only needed when using the Password grant, leave blank to use client credentials grant',
|
41
|
+
},
|
42
|
+
apiVersion: {
|
43
|
+
key: 'apiVersion',
|
44
|
+
label: 'API version ',
|
45
|
+
obfuscated: false,
|
46
|
+
required: false,
|
47
|
+
description: `Defaults to ${constants_1.DEFAULT_API_VERSION}`,
|
48
|
+
},
|
49
|
+
};
|
50
|
+
exports.SettingsValidationSchema = zod_1.z.object({
|
51
|
+
salesforceSubdomain: zod_1.z.string().min(1),
|
52
|
+
clientId: zod_1.z.string(),
|
53
|
+
clientSecret: zod_1.z.string(),
|
54
|
+
username: zod_1.z.string().optional(),
|
55
|
+
password: zod_1.z.string().optional(),
|
56
|
+
apiVersion: zod_1.z.string().optional(),
|
57
|
+
});
|
58
|
+
//# sourceMappingURL=settings.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"settings.js","sourceRoot":"","sources":["../../../extensions/sfdc/settings.ts"],"names":[],"mappings":";;;AACA,6BAAwC;AACxC,+CAAqD;AAExC,QAAA,QAAQ,GAAG;IACtB,mBAAmB,EAAE;QACnB,GAAG,EAAE,qBAAqB;QAC1B,KAAK,EAAE,aAAa;QACpB,UAAU,EAAE,KAAK;QACjB,QAAQ,EAAE,IAAI;QACd,WAAW,EACT,2EAA2E;KAC9E;IACD,QAAQ,EAAE;QACR,GAAG,EAAE,UAAU;QACf,KAAK,EAAE,WAAW;QAClB,UAAU,EAAE,KAAK;QACjB,QAAQ,EAAE,IAAI;QACd,WAAW,EAAE,EAAE;KAChB;IACD,YAAY,EAAE;QACZ,GAAG,EAAE,cAAc;QACnB,KAAK,EAAE,eAAe;QACtB,UAAU,EAAE,IAAI;QAChB,QAAQ,EAAE,IAAI;QACd,WAAW,EAAE,EAAE;KAChB;IACD,QAAQ,EAAE;QACR,GAAG,EAAE,UAAU;QACf,KAAK,EAAE,WAAW;QAClB,UAAU,EAAE,KAAK;QACjB,QAAQ,EAAE,KAAK;QACf,WAAW,EACT,qKAAqK;KACxK;IACD,QAAQ,EAAE;QACR,GAAG,EAAE,UAAU;QACf,KAAK,EAAE,WAAW;QAClB,UAAU,EAAE,IAAI;QAChB,QAAQ,EAAE,KAAK;QACf,WAAW,EACT,oKAAoK;KACvK;IACD,UAAU,EAAE;QACV,GAAG,EAAE,YAAY;QACjB,KAAK,EAAE,cAAc;QACrB,UAAU,EAAE,KAAK;QACjB,QAAQ,EAAE,KAAK;QACf,WAAW,EAAE,eAAe,+BAAmB,EAAE;KAClD;CACgC,CAAA;AAEtB,QAAA,wBAAwB,GAAG,OAAC,CAAC,MAAM,CAAC;IAC/C,mBAAmB,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACtC,QAAQ,EAAE,OAAC,CAAC,MAAM,EAAE;IACpB,YAAY,EAAE,OAAC,CAAC,MAAM,EAAE;IACxB,QAAQ,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC/B,QAAQ,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC/B,UAAU,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CACkB,CAAC,CAAA"}
|