@awell-health/awell-extensions 1.1.58 → 1.1.60
Sign up to get free protection for your applications and to get access to all the features.
- 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/rest/actions/index.d.ts +33 -0
- package/dist/extensions/rest/actions/index.js +8 -0
- package/dist/extensions/rest/actions/index.js.map +1 -0
- package/dist/extensions/rest/actions/post/config/dataPoints.d.ts +10 -0
- package/dist/extensions/rest/actions/post/config/dataPoints.js +14 -0
- package/dist/extensions/rest/actions/post/config/dataPoints.js.map +1 -0
- package/dist/extensions/rest/actions/post/config/fields.d.ts +48 -0
- package/dist/extensions/rest/actions/post/config/fields.js +108 -0
- package/dist/extensions/rest/actions/post/config/fields.js.map +1 -0
- package/dist/extensions/rest/actions/post/config/index.d.ts +2 -0
- package/dist/extensions/rest/actions/post/config/index.js +9 -0
- package/dist/extensions/rest/actions/post/config/index.js.map +1 -0
- package/dist/extensions/rest/actions/post/index.d.ts +1 -0
- package/dist/extensions/rest/actions/post/index.js +6 -0
- package/dist/extensions/rest/actions/post/index.js.map +1 -0
- package/dist/extensions/rest/actions/post/post.d.ts +4 -0
- package/dist/extensions/rest/actions/post/post.js +43 -0
- package/dist/extensions/rest/actions/post/post.js.map +1 -0
- package/dist/extensions/rest/actions/post/post.test.d.ts +1 -0
- package/dist/extensions/rest/actions/post/post.test.js +61 -0
- package/dist/extensions/rest/actions/post/post.test.js.map +1 -0
- package/dist/extensions/rest/index.d.ts +2 -0
- package/dist/extensions/rest/index.js +22 -0
- package/dist/extensions/rest/index.js.map +1 -0
- package/dist/extensions/rest/settings.d.ts +1 -0
- package/dist/extensions/rest/settings.js +5 -0
- package/dist/extensions/rest/settings.js.map +1 -0
- package/dist/extensions/sfdc/actions/createLead/createLead.js +25 -9
- package/dist/extensions/sfdc/actions/createLead/createLead.js.map +1 -1
- package/dist/extensions/sfdc/actions/updateLead/updateLead.js +22 -6
- package/dist/extensions/sfdc/actions/updateLead/updateLead.js.map +1 -1
- package/dist/extensions/sfdc/lib/errors.d.ts +4 -0
- package/dist/extensions/sfdc/lib/errors.js +39 -0
- package/dist/extensions/sfdc/lib/errors.js.map +1 -0
- package/package.json +1 -1
package/dist/extensions/index.js
CHANGED
@@ -60,6 +60,7 @@ const medplum_1 = require("./medplum");
|
|
60
60
|
const dockHealth_1 = require("./dockHealth");
|
61
61
|
const stripe_1 = require("./stripe");
|
62
62
|
const sfdc_1 = require("./sfdc");
|
63
|
+
const rest_1 = require("./rest");
|
63
64
|
const json = __importStar(require("./markdown.json"));
|
64
65
|
const external_server_1 = require("./external-server");
|
65
66
|
exports.markdown = json;
|
@@ -91,6 +92,7 @@ exports.extensions = [
|
|
91
92
|
medplum_1.Medplum,
|
92
93
|
metriport_1.Metriport,
|
93
94
|
nexuzhealth_1.nexuzhealth,
|
95
|
+
rest_1.rest,
|
94
96
|
sendbird_1.Sendbird,
|
95
97
|
sendgrid_extension_1.Sendgrid,
|
96
98
|
sfdc_1.sfdc,
|
@@ -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;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"}
|
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;AAC7B,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,WAAI;IACJ,mBAAQ;IACR,6BAAQ;IACR,WAAI;IACJ,eAAM;IACN,mBAAQ;IACR,mBAAQ;IACR,qBAAS;IACT,eAAM;IACN,iBAAO;IACP,iBAAO;CACR,CAAA"}
|
@@ -107,6 +107,10 @@
|
|
107
107
|
"readme": "---\ntitle: nexuzhealth\ndescription: Demo extension for nexuzhealth\n---\n\nThis is an extension that can only be used for demo purposes.",
|
108
108
|
"changelog": "# nexuzhealth changelog"
|
109
109
|
},
|
110
|
+
"rest": {
|
111
|
+
"readme": "---\ntitle: REST\ndescription: A utility extension with more advanced options to make REST API calls\n---\n\n# REST\n\nThis is a utility extension with more advanced options to make REST API calls.\n\n## Custom Actions\n\n### POST\n\nMakes a POST request using fetch to the provided endpoint.\n",
|
112
|
+
"changelog": "# REST changelog\n"
|
113
|
+
},
|
110
114
|
"sendbird": {
|
111
115
|
"readme": "---\ntitle: Sendbird\ndescription: Sendbird is a cloud-based chat and messaging platform that enables developers to integrate real-time messaging functionality into their applications.\n---\n\n# Sendbird\n\nSendbird is a cloud-based chat and messaging platform that enables developers to integrate real-time messaging functionality into their applications.\n\nSendbird offers a range of features, including real-time chat, group chat, one-on-one messaging, push notifications, and file sharing. It supports various platforms and programming languages, making it flexible and accessible for developers to integrate with different applications.\n\n## Extension settings\n\nIn order to set up this extension, you will need:\n\n1. An **Application ID** - visit https://dashboard.sendbird.com/ to retrieve **Application ID** for the app of your choosing\n2. A **Chat API token** - visit Application's settings and go to **Settings > Application > General > API tokens** to retrieve either Master API token or Secondary API token\n3. A **Desk API token** - visit Application's settings and go to **Settings > Desk > Credentials** to retrieve Desk API token\n\n## Custom Actions\n\n### Create user\n\nCreates a user in Sendbird using the Chat API. See [Update metadata](#update-metadata) to check metadata field details. The `userId` of the newly created user is then saved as a data point.\n\n### Update user\n\nUpdates a user using the Chat API.\n\nPlease note that updating `metadata` of a user needs to be done with the [Update metadata action](#update-metadata).\n\n### Delete user\n\nDeletes a user in Sendbird using the Chat API.\n\n### Get user\n\nRetrieve information about a user using the Chat API. The following fields are saved as a data point:\n\n- Nickname\n- Access token\n- Is active\n- Created at\n- Last seen at\n- Has ever logged in\n- Metadata (stored as string)\n\n### Update metadata\n\nUpdates the user's metadata using the Chat API. Only updates existing or adds new fields to metadata. To delete some metedata fields, check the [Delete metadata action](#delete-metadata).\n\nMetadata is a JSON object that can store up to five key-value items of additional user information such as a phone number, an email address, or a long description of the user. The key must not have a comma (,) and its length is limited to 128 characters. The value must be a string and its length is limited to 190 characters.\n\n### Delete metadata\n\nDeletes user metadata using the Chat API. Takes the key of a metadata item to be deleted (deletes one key at a time if a key is provided). If not specified, all items of the metadata are deleted.\n\n### Deactivate user\n\nDeactivates a user, using the \"Update user\" endpoint, in the Chat API. Optionally, it can be set for the user to `Leave all group channels upon deactivation`.\n\nThe user is deactivated by setting `is_active` to false.\n\n### Activate user\n\nActivates a user, using the \"Update user\" endpoint, in the Chat API. The user is activated by setting `is_active` to true.\n\n### Create customer\n\nCreates a customer using the Desk API. Only the `sendbirdId` is passed and it must be an ID that already exists in Sendbird's Chat platform (eg: the `userId` of an existing user). The `customerId` of the newly created customer is stored as data point.\n\nTo add custom fields to your customer, use the [Update custom fields action](#update-customers-custom-fields).\n\n### Get customer\n\nRetrieves information on a specific customer using the Desk API. The following fields are saved as a data point:\n\n- Sendbird ID\n- Channel Type\n- Project\n- Created At\n- Display Name\n- Custom Fields (stored as string)\n\n### Update customer's custom fields\n\nUpdates a customer's custom fields using the Desk API.\n\nCustom fields is a JSON object that can store up to twenty key-value items for additional customer information such as a phone number, an email address, or a long description of the customer.\n\nThe specified keys must be registered as a custom field in Settings > Customer fields of your dashboard beforehand. The key must not have a comma (,) and its length is limited to 20 characters. The value's length is limited to 190 characters.\n\n### Create ticket\n\nCreates a ticket using the Desk API. The `ticketId` of the newly created ticket is stored as data point.\n\nPlease note that the Ticket won't be shown in the Sendbird console **until** the user for which that Ticket was created writes a message inside the Chat.\n",
|
112
116
|
"changelog": "# Sendbird changelog\n\n## 2023-08-22\n\n- add `relatedChannelUrls` field to `Create ticket` action\n"
|
@@ -0,0 +1,33 @@
|
|
1
|
+
declare const actions: {
|
2
|
+
post: import("@awell-health/extensions-core").Action<{
|
3
|
+
endpoint: {
|
4
|
+
id: string;
|
5
|
+
label: string;
|
6
|
+
description: string;
|
7
|
+
type: import("@awell-health/extensions-core").FieldType.STRING;
|
8
|
+
required: true;
|
9
|
+
};
|
10
|
+
headers: {
|
11
|
+
id: string;
|
12
|
+
label: string;
|
13
|
+
description: string;
|
14
|
+
type: import("@awell-health/extensions-core").FieldType.JSON;
|
15
|
+
required: true;
|
16
|
+
};
|
17
|
+
jsonPayload: {
|
18
|
+
id: string;
|
19
|
+
label: string;
|
20
|
+
description: string;
|
21
|
+
type: import("@awell-health/extensions-core").FieldType.JSON;
|
22
|
+
required: true;
|
23
|
+
};
|
24
|
+
additionalPayload: {
|
25
|
+
id: string;
|
26
|
+
label: string;
|
27
|
+
description: string;
|
28
|
+
type: import("@awell-health/extensions-core").FieldType.JSON;
|
29
|
+
required: false;
|
30
|
+
};
|
31
|
+
}, {}, "statusCode" | "response">;
|
32
|
+
};
|
33
|
+
export default actions;
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../extensions/rest/actions/index.ts"],"names":[],"mappings":";;AAAA,iCAA6B;AAE7B,MAAM,OAAO,GAAG;IACd,IAAI,EAAJ,WAAI;CACL,CAAA;AAED,kBAAe,OAAO,CAAA"}
|
@@ -0,0 +1,14 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.dataPoints = void 0;
|
4
|
+
exports.dataPoints = {
|
5
|
+
response: {
|
6
|
+
key: 'response',
|
7
|
+
valueType: 'json',
|
8
|
+
},
|
9
|
+
statusCode: {
|
10
|
+
key: 'statusCode',
|
11
|
+
valueType: 'number',
|
12
|
+
},
|
13
|
+
};
|
14
|
+
//# sourceMappingURL=dataPoints.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"dataPoints.js","sourceRoot":"","sources":["../../../../../../extensions/rest/actions/post/config/dataPoints.ts"],"names":[],"mappings":";;;AAEa,QAAA,UAAU,GAAG;IACxB,QAAQ,EAAE;QACR,GAAG,EAAE,UAAU;QACf,SAAS,EAAE,MAAM;KAClB;IACD,UAAU,EAAE;QACV,GAAG,EAAE,YAAY;QACjB,SAAS,EAAE,QAAQ;KACpB;CAC4C,CAAA"}
|
@@ -0,0 +1,48 @@
|
|
1
|
+
import { z } from 'zod';
|
2
|
+
import { FieldType } from '@awell-health/extensions-core';
|
3
|
+
export declare const fields: {
|
4
|
+
endpoint: {
|
5
|
+
id: string;
|
6
|
+
label: string;
|
7
|
+
description: string;
|
8
|
+
type: FieldType.STRING;
|
9
|
+
required: true;
|
10
|
+
};
|
11
|
+
headers: {
|
12
|
+
id: string;
|
13
|
+
label: string;
|
14
|
+
description: string;
|
15
|
+
type: FieldType.JSON;
|
16
|
+
required: true;
|
17
|
+
};
|
18
|
+
jsonPayload: {
|
19
|
+
id: string;
|
20
|
+
label: string;
|
21
|
+
description: string;
|
22
|
+
type: FieldType.JSON;
|
23
|
+
required: true;
|
24
|
+
};
|
25
|
+
additionalPayload: {
|
26
|
+
id: string;
|
27
|
+
label: string;
|
28
|
+
description: string;
|
29
|
+
type: FieldType.JSON;
|
30
|
+
required: false;
|
31
|
+
};
|
32
|
+
};
|
33
|
+
export declare const FieldsValidationSchema: z.ZodObject<{
|
34
|
+
endpoint: z.ZodString;
|
35
|
+
headers: z.ZodEffects<z.ZodOptional<z.ZodString>, Record<string, string>, string | undefined>;
|
36
|
+
jsonPayload: z.ZodEffects<z.ZodString, Record<string, unknown>, string>;
|
37
|
+
additionalPayload: z.ZodEffects<z.ZodOptional<z.ZodString>, Record<string, unknown>, string | undefined>;
|
38
|
+
}, "strip", z.ZodTypeAny, {
|
39
|
+
headers: Record<string, string>;
|
40
|
+
endpoint: string;
|
41
|
+
jsonPayload: Record<string, unknown>;
|
42
|
+
additionalPayload: Record<string, unknown>;
|
43
|
+
}, {
|
44
|
+
endpoint: string;
|
45
|
+
jsonPayload: string;
|
46
|
+
headers?: string | undefined;
|
47
|
+
additionalPayload?: string | undefined;
|
48
|
+
}>;
|
@@ -0,0 +1,108 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.FieldsValidationSchema = exports.fields = void 0;
|
4
|
+
const zod_1 = require("zod");
|
5
|
+
const extensions_core_1 = require("@awell-health/extensions-core");
|
6
|
+
const lodash_1 = require("lodash");
|
7
|
+
exports.fields = {
|
8
|
+
endpoint: {
|
9
|
+
id: 'endpoint',
|
10
|
+
label: 'Endpoint',
|
11
|
+
description: '',
|
12
|
+
type: extensions_core_1.FieldType.STRING,
|
13
|
+
required: true,
|
14
|
+
},
|
15
|
+
headers: {
|
16
|
+
id: 'headers',
|
17
|
+
label: 'Headers',
|
18
|
+
description: '',
|
19
|
+
type: extensions_core_1.FieldType.JSON,
|
20
|
+
required: true,
|
21
|
+
},
|
22
|
+
jsonPayload: {
|
23
|
+
id: 'jsonPayload',
|
24
|
+
label: 'JSON payload',
|
25
|
+
description: '',
|
26
|
+
type: extensions_core_1.FieldType.JSON,
|
27
|
+
required: true,
|
28
|
+
},
|
29
|
+
additionalPayload: {
|
30
|
+
id: 'additionalPayload',
|
31
|
+
label: 'Additional payload',
|
32
|
+
description: 'The JSON payload and additional payload will be merged into a single payload',
|
33
|
+
type: extensions_core_1.FieldType.JSON,
|
34
|
+
required: false,
|
35
|
+
},
|
36
|
+
};
|
37
|
+
exports.FieldsValidationSchema = zod_1.z.object({
|
38
|
+
endpoint: zod_1.z.string().min(1),
|
39
|
+
headers: zod_1.z
|
40
|
+
.string()
|
41
|
+
.trim()
|
42
|
+
.optional()
|
43
|
+
.transform((str, ctx) => {
|
44
|
+
if ((0, lodash_1.isNil)(str) || (0, lodash_1.isEmpty)(str)) {
|
45
|
+
return {};
|
46
|
+
}
|
47
|
+
try {
|
48
|
+
const parsedJson = JSON.parse(str);
|
49
|
+
if ((0, lodash_1.isEmpty)(parsedJson)) {
|
50
|
+
return {};
|
51
|
+
}
|
52
|
+
if (typeof parsedJson !== 'object' ||
|
53
|
+
Array.isArray(parsedJson) ||
|
54
|
+
Object.values(parsedJson).some((value) => typeof value !== 'string')) {
|
55
|
+
ctx.addIssue({
|
56
|
+
code: 'custom',
|
57
|
+
message: 'Headers must be a key-value object where each value is a string',
|
58
|
+
});
|
59
|
+
return zod_1.z.NEVER;
|
60
|
+
}
|
61
|
+
return parsedJson;
|
62
|
+
}
|
63
|
+
catch (e) {
|
64
|
+
ctx.addIssue({ code: 'custom', message: 'Invalid JSON' });
|
65
|
+
return zod_1.z.NEVER;
|
66
|
+
}
|
67
|
+
}),
|
68
|
+
jsonPayload: zod_1.z
|
69
|
+
.string()
|
70
|
+
.trim()
|
71
|
+
.transform((str, ctx) => {
|
72
|
+
if ((0, lodash_1.isNil)(str) || (0, lodash_1.isEmpty)(str)) {
|
73
|
+
return {};
|
74
|
+
}
|
75
|
+
try {
|
76
|
+
const parsedJson = JSON.parse(str);
|
77
|
+
if ((0, lodash_1.isEmpty)(parsedJson)) {
|
78
|
+
return {};
|
79
|
+
}
|
80
|
+
return parsedJson;
|
81
|
+
}
|
82
|
+
catch (e) {
|
83
|
+
ctx.addIssue({ code: 'custom', message: 'Invalid JSON' });
|
84
|
+
return zod_1.z.NEVER;
|
85
|
+
}
|
86
|
+
}),
|
87
|
+
additionalPayload: zod_1.z
|
88
|
+
.string()
|
89
|
+
.trim()
|
90
|
+
.optional()
|
91
|
+
.transform((str, ctx) => {
|
92
|
+
if ((0, lodash_1.isNil)(str) || (0, lodash_1.isEmpty)(str)) {
|
93
|
+
return {};
|
94
|
+
}
|
95
|
+
try {
|
96
|
+
const parsedJson = JSON.parse(str);
|
97
|
+
if ((0, lodash_1.isEmpty)(parsedJson)) {
|
98
|
+
return {};
|
99
|
+
}
|
100
|
+
return parsedJson;
|
101
|
+
}
|
102
|
+
catch (e) {
|
103
|
+
ctx.addIssue({ code: 'custom', message: 'Invalid JSON' });
|
104
|
+
return zod_1.z.NEVER;
|
105
|
+
}
|
106
|
+
}),
|
107
|
+
});
|
108
|
+
//# sourceMappingURL=fields.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"fields.js","sourceRoot":"","sources":["../../../../../../extensions/rest/actions/post/config/fields.ts"],"names":[],"mappings":";;;AAAA,6BAAwC;AACxC,mEAAqE;AACrE,mCAAuC;AAE1B,QAAA,MAAM,GAAG;IACpB,QAAQ,EAAE;QACR,EAAE,EAAE,UAAU;QACd,KAAK,EAAE,UAAU;QACjB,WAAW,EAAE,EAAE;QACf,IAAI,EAAE,2BAAS,CAAC,MAAM;QACtB,QAAQ,EAAE,IAAI;KACf;IACD,OAAO,EAAE;QACP,EAAE,EAAE,SAAS;QACb,KAAK,EAAE,SAAS;QAChB,WAAW,EAAE,EAAE;QACf,IAAI,EAAE,2BAAS,CAAC,IAAI;QACpB,QAAQ,EAAE,IAAI;KACf;IACD,WAAW,EAAE;QACX,EAAE,EAAE,aAAa;QACjB,KAAK,EAAE,cAAc;QACrB,WAAW,EAAE,EAAE;QACf,IAAI,EAAE,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;YACzD,OAAO,OAAC,CAAC,KAAK,CAAA;SACf;IACH,CAAC,CAAC;CAC6C,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/rest/actions/post/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 { post } from './post';
|
@@ -0,0 +1,6 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.post = void 0;
|
4
|
+
var post_1 = require("./post");
|
5
|
+
Object.defineProperty(exports, "post", { enumerable: true, get: function () { return post_1.post; } });
|
6
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../extensions/rest/actions/post/index.ts"],"names":[],"mappings":";;;AAAA,+BAA6B;AAApB,4FAAA,IAAI,OAAA"}
|
@@ -0,0 +1,43 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.post = void 0;
|
4
|
+
const extensions_core_1 = require("@awell-health/extensions-core");
|
5
|
+
const config_1 = require("./config");
|
6
|
+
const zod_1 = require("zod");
|
7
|
+
exports.post = {
|
8
|
+
key: 'post',
|
9
|
+
title: 'POST request',
|
10
|
+
description: 'Make a POST request',
|
11
|
+
category: extensions_core_1.Category.DATA,
|
12
|
+
fields: config_1.fields,
|
13
|
+
dataPoints: config_1.dataPoints,
|
14
|
+
previewable: true,
|
15
|
+
onActivityCreated: async (payload, onComplete, onError) => {
|
16
|
+
const { fields: { endpoint, headers, jsonPayload, additionalPayload }, } = (0, extensions_core_1.validate)({
|
17
|
+
schema: zod_1.z.object({
|
18
|
+
fields: config_1.FieldsValidationSchema,
|
19
|
+
}),
|
20
|
+
payload,
|
21
|
+
});
|
22
|
+
const response = await fetch(endpoint, {
|
23
|
+
method: 'POST',
|
24
|
+
headers: {
|
25
|
+
...headers,
|
26
|
+
'Content-Type': 'application/json',
|
27
|
+
},
|
28
|
+
body: JSON.stringify({
|
29
|
+
...jsonPayload,
|
30
|
+
...additionalPayload,
|
31
|
+
}),
|
32
|
+
});
|
33
|
+
const responseBody = await response.json();
|
34
|
+
const statusCode = response.status;
|
35
|
+
await onComplete({
|
36
|
+
data_points: {
|
37
|
+
response: JSON.stringify(responseBody),
|
38
|
+
statusCode: String(statusCode),
|
39
|
+
},
|
40
|
+
});
|
41
|
+
},
|
42
|
+
};
|
43
|
+
//# sourceMappingURL=post.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"post.js","sourceRoot":"","sources":["../../../../../extensions/rest/actions/post/post.ts"],"names":[],"mappings":";;;AACA,mEAAkE;AAElE,qCAAqE;AACrE,6BAAuB;AAEV,QAAA,IAAI,GAIb;IACF,GAAG,EAAE,MAAM;IACX,KAAK,EAAE,cAAc;IACrB,WAAW,EAAE,qBAAqB;IAClC,QAAQ,EAAE,0BAAQ,CAAC,IAAI;IACvB,MAAM,EAAN,eAAM;IACN,UAAU,EAAV,mBAAU;IACV,WAAW,EAAE,IAAI;IACjB,iBAAiB,EAAE,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,EAAE;QACxD,MAAM,EACJ,MAAM,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,GAC9D,GAAG,IAAA,0BAAQ,EAAC;YACX,MAAM,EAAE,OAAC,CAAC,MAAM,CAAC;gBACf,MAAM,EAAE,+BAAsB;aAC/B,CAAC;YACF,OAAO;SACR,CAAC,CAAA;QAEF,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,QAAQ,EAAE;YACrC,MAAM,EAAE,MAAM;YACd,OAAO,EAAE;gBACP,GAAG,OAAO;gBACV,cAAc,EAAE,kBAAkB;aACnC;YACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;gBACnB,GAAG,WAAW;gBACd,GAAG,iBAAiB;aACrB,CAAC;SACH,CAAC,CAAA;QAEF,MAAM,YAAY,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAA;QAC1C,MAAM,UAAU,GAAG,QAAQ,CAAC,MAAM,CAAA;QAElC,MAAM,UAAU,CAAC;YACf,WAAW,EAAE;gBACX,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC;gBACtC,UAAU,EAAE,MAAM,CAAC,UAAU,CAAC;aAC/B;SACF,CAAC,CAAA;IACJ,CAAC;CACF,CAAA"}
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1,61 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
const _1 = require(".");
|
4
|
+
const tests_1 = require("../../../../src/tests");
|
5
|
+
describe('REST - POST', () => {
|
6
|
+
const onComplete = jest.fn();
|
7
|
+
const onError = jest.fn();
|
8
|
+
beforeEach(() => {
|
9
|
+
jest.clearAllMocks();
|
10
|
+
jest.spyOn(global, 'fetch');
|
11
|
+
});
|
12
|
+
afterEach(() => {
|
13
|
+
jest.restoreAllMocks();
|
14
|
+
});
|
15
|
+
test('Should work', async () => {
|
16
|
+
;
|
17
|
+
global.fetch.mockResolvedValue({
|
18
|
+
status: 200,
|
19
|
+
json: jest.fn().mockResolvedValue({
|
20
|
+
success: true,
|
21
|
+
message: 'Data received successfully',
|
22
|
+
}),
|
23
|
+
});
|
24
|
+
const jsonPayload = {
|
25
|
+
'key-1': 'value',
|
26
|
+
};
|
27
|
+
const additionalPayload = {
|
28
|
+
'key-2': 'value',
|
29
|
+
};
|
30
|
+
const mockOnActivityCreateParams = (0, tests_1.generateTestPayload)({
|
31
|
+
fields: {
|
32
|
+
endpoint: 'https://webhook.site/bb853fec-9260-44e5-a944-17894d678a7f',
|
33
|
+
headers: JSON.stringify({
|
34
|
+
Authorization: 'Bearer key',
|
35
|
+
}),
|
36
|
+
jsonPayload: JSON.stringify(jsonPayload),
|
37
|
+
additionalPayload: JSON.stringify(additionalPayload),
|
38
|
+
},
|
39
|
+
settings: {},
|
40
|
+
});
|
41
|
+
await _1.post.onActivityCreated(mockOnActivityCreateParams, onComplete, onError);
|
42
|
+
expect(global.fetch).toHaveBeenCalledWith('https://webhook.site/bb853fec-9260-44e5-a944-17894d678a7f', expect.objectContaining({
|
43
|
+
method: 'POST',
|
44
|
+
headers: {
|
45
|
+
Authorization: 'Bearer key',
|
46
|
+
'Content-Type': 'application/json',
|
47
|
+
},
|
48
|
+
body: JSON.stringify({
|
49
|
+
...jsonPayload,
|
50
|
+
...additionalPayload,
|
51
|
+
}),
|
52
|
+
}));
|
53
|
+
expect(onComplete).toHaveBeenCalledWith({
|
54
|
+
data_points: {
|
55
|
+
response: '{"success":true,"message":"Data received successfully"}',
|
56
|
+
statusCode: '200',
|
57
|
+
},
|
58
|
+
});
|
59
|
+
});
|
60
|
+
});
|
61
|
+
//# sourceMappingURL=post.test.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"post.test.js","sourceRoot":"","sources":["../../../../../extensions/rest/actions/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AC1B,UAAU,EACV,OAAO,CACR,CAAA;QAED,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,oBAAoB,CACvC,2DAA2D,EAC3D,MAAM,CAAC,gBAAgB,CAAC;YACtB,MAAM,EAAE,MAAM;YACd,OAAO,EAAE;gBACP,aAAa,EAAE,YAAY;gBAC3B,cAAc,EAAE,kBAAkB;aACnC;YACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;gBACnB,GAAG,WAAW;gBACd,GAAG,iBAAiB;aACrB,CAAC;SACH,CAAC,CACH,CAAA;QAED,MAAM,CAAC,UAAU,CAAC,CAAC,oBAAoB,CAAC;YACtC,WAAW,EAAE;gBACX,QAAQ,EAAE,yDAAyD;gBACnE,UAAU,EAAE,KAAK;aAClB;SACF,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC,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.rest = 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.rest = {
|
11
|
+
key: 'rest',
|
12
|
+
title: 'REST',
|
13
|
+
icon_url: 'https://res.cloudinary.com/da7x4rzl4/image/upload/v1724322431/Awell%20Extensions/REST_socialmedia.webp',
|
14
|
+
description: 'A utility extension with more advanced options to make REST API calls',
|
15
|
+
category: extensions_core_1.Category.DATA,
|
16
|
+
author: {
|
17
|
+
authorType: extensions_core_1.AuthorType.AWELL,
|
18
|
+
},
|
19
|
+
actions: actions_1.default,
|
20
|
+
settings: settings_1.settings,
|
21
|
+
};
|
22
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../extensions/rest/index.ts"],"names":[],"mappings":";;;;;;AACA,mEAAoE;AACpE,wDAA+B;AAC/B,yCAAqC;AAExB,QAAA,IAAI,GAAc;IAC7B,GAAG,EAAE,MAAM;IACX,KAAK,EAAE,MAAM;IACb,QAAQ,EACN,wGAAwG;IAC1G,WAAW,EACT,uEAAuE;IACzE,QAAQ,EAAE,0BAAQ,CAAC,IAAI;IACvB,MAAM,EAAE;QACN,UAAU,EAAE,4BAAU,CAAC,KAAK;KAC7B;IACD,OAAO,EAAP,iBAAO;IACP,QAAQ,EAAR,mBAAQ;CACT,CAAA"}
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare const settings: {};
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"settings.js","sourceRoot":"","sources":["../../../extensions/rest/settings.ts"],"names":[],"mappings":";;;AAEa,QAAA,QAAQ,GAAG,EAAoC,CAAA"}
|
@@ -4,6 +4,8 @@ exports.createLead = void 0;
|
|
4
4
|
const extensions_core_1 = require("@awell-health/extensions-core");
|
5
5
|
const config_1 = require("./config");
|
6
6
|
const lib_1 = require("../../lib");
|
7
|
+
const axios_1 = require("axios");
|
8
|
+
const errors_1 = require("../../lib/errors");
|
7
9
|
exports.createLead = {
|
8
10
|
key: 'createLead',
|
9
11
|
category: extensions_core_1.Category.CUSTOMER_SUPPORT,
|
@@ -17,15 +19,29 @@ exports.createLead = {
|
|
17
19
|
fieldsSchema: config_1.FieldsValidationSchema,
|
18
20
|
payload,
|
19
21
|
});
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
22
|
+
try {
|
23
|
+
const res = await salesforceClient.createRecord({
|
24
|
+
sObject: 'Lead',
|
25
|
+
data: fields.data,
|
26
|
+
});
|
27
|
+
await onComplete({
|
28
|
+
data_points: {
|
29
|
+
createdLeadId: String(res.id),
|
30
|
+
},
|
31
|
+
});
|
32
|
+
}
|
33
|
+
catch (error) {
|
34
|
+
let parsedError;
|
35
|
+
if ((0, axios_1.isAxiosError)(error)) {
|
36
|
+
parsedError = (0, errors_1.parseAxiosError)(error);
|
37
|
+
}
|
38
|
+
else {
|
39
|
+
parsedError = (0, errors_1.parseUnknowError)(error);
|
40
|
+
}
|
41
|
+
await onError({
|
42
|
+
events: [parsedError],
|
43
|
+
});
|
44
|
+
}
|
29
45
|
},
|
30
46
|
};
|
31
47
|
//# sourceMappingURL=createLead.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"createLead.js","sourceRoot":"","sources":["../../../../../extensions/sfdc/actions/createLead/createLead.ts"],"names":[],"mappings":";;;AAAA,mEAAqE;AAErE,qCAAqE;AACrE,mCAA0D;
|
1
|
+
{"version":3,"file":"createLead.js","sourceRoot":"","sources":["../../../../../extensions/sfdc/actions/createLead/createLead.ts"],"names":[],"mappings":";;;AAAA,mEAAqE;AAErE,qCAAqE;AACrE,mCAA0D;AAC1D,iCAAgD;AAChD,6CAAoE;AAEvD,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,IAAI;YACF,MAAM,GAAG,GAAG,MAAM,gBAAgB,CAAC,YAAY,CAAC;gBAC9C,OAAO,EAAE,MAAM;gBACf,IAAI,EAAE,MAAM,CAAC,IAAI;aAClB,CAAC,CAAA;YAEF,MAAM,UAAU,CAAC;gBACf,WAAW,EAAE;oBACX,aAAa,EAAE,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC;iBAC9B;aACF,CAAC,CAAA;SACH;QAAC,OAAO,KAAK,EAAE;YACd,IAAI,WAAW,CAAA;YAEf,IAAI,IAAA,oBAAY,EAAC,KAAK,CAAC,EAAE;gBACvB,WAAW,GAAG,IAAA,wBAAe,EAAC,KAAmB,CAAC,CAAA;aACnD;iBAAM;gBACL,WAAW,GAAG,IAAA,yBAAgB,EAAC,KAAc,CAAC,CAAA;aAC/C;YACD,MAAM,OAAO,CAAC;gBACZ,MAAM,EAAE,CAAC,WAAW,CAAC;aACtB,CAAC,CAAA;SACH;IACH,CAAC;CACF,CAAA"}
|
@@ -4,6 +4,8 @@ exports.updateLead = void 0;
|
|
4
4
|
const extensions_core_1 = require("@awell-health/extensions-core");
|
5
5
|
const config_1 = require("./config");
|
6
6
|
const lib_1 = require("../../lib");
|
7
|
+
const axios_1 = require("axios");
|
8
|
+
const errors_1 = require("../../lib/errors");
|
7
9
|
exports.updateLead = {
|
8
10
|
key: 'updateLead',
|
9
11
|
category: extensions_core_1.Category.CUSTOMER_SUPPORT,
|
@@ -17,12 +19,26 @@ exports.updateLead = {
|
|
17
19
|
fieldsSchema: config_1.FieldsValidationSchema,
|
18
20
|
payload,
|
19
21
|
});
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
22
|
+
try {
|
23
|
+
await salesforceClient.updateRecord({
|
24
|
+
sObject: 'Lead',
|
25
|
+
sObjectId: fields.sObjectId,
|
26
|
+
data: fields.data,
|
27
|
+
});
|
28
|
+
await onComplete();
|
29
|
+
}
|
30
|
+
catch (error) {
|
31
|
+
let parsedError;
|
32
|
+
if ((0, axios_1.isAxiosError)(error)) {
|
33
|
+
parsedError = (0, errors_1.parseAxiosError)(error);
|
34
|
+
}
|
35
|
+
else {
|
36
|
+
parsedError = (0, errors_1.parseUnknowError)(error);
|
37
|
+
}
|
38
|
+
await onError({
|
39
|
+
events: [parsedError],
|
40
|
+
});
|
41
|
+
}
|
26
42
|
},
|
27
43
|
};
|
28
44
|
//# sourceMappingURL=updateLead.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"updateLead.js","sourceRoot":"","sources":["../../../../../extensions/sfdc/actions/updateLead/updateLead.ts"],"names":[],"mappings":";;;AAAA,mEAAqE;AAErE,qCAAqE;AACrE,mCAA0D;
|
1
|
+
{"version":3,"file":"updateLead.js","sourceRoot":"","sources":["../../../../../extensions/sfdc/actions/updateLead/updateLead.ts"],"names":[],"mappings":";;;AAAA,mEAAqE;AAErE,qCAAqE;AACrE,mCAA0D;AAC1D,iCAAgD;AAChD,6CAAoE;AAEvD,QAAA,UAAU,GAInB;IACF,GAAG,EAAE,YAAY;IACjB,QAAQ,EAAE,0BAAQ,CAAC,gBAAgB;IACnC,KAAK,EAAE,aAAa;IACpB,WAAW,EAAE,+CAA+C;IAC5D,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,IAAI;YACF,MAAM,gBAAgB,CAAC,YAAY,CAAC;gBAClC,OAAO,EAAE,MAAM;gBACf,SAAS,EAAE,MAAM,CAAC,SAAS;gBAC3B,IAAI,EAAE,MAAM,CAAC,IAAI;aAClB,CAAC,CAAA;YAEF,MAAM,UAAU,EAAE,CAAA;SACnB;QAAC,OAAO,KAAK,EAAE;YACd,IAAI,WAAW,CAAA;YAEf,IAAI,IAAA,oBAAY,EAAC,KAAK,CAAC,EAAE;gBACvB,WAAW,GAAG,IAAA,wBAAe,EAAC,KAAmB,CAAC,CAAA;aACnD;iBAAM;gBACL,WAAW,GAAG,IAAA,yBAAgB,EAAC,KAAc,CAAC,CAAA;aAC/C;YACD,MAAM,OAAO,CAAC;gBACZ,MAAM,EAAE,CAAC,WAAW,CAAC;aACtB,CAAC,CAAA;SACH;IACH,CAAC;CACF,CAAA"}
|
@@ -0,0 +1,39 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.parseUnknowError = exports.parseAxiosError = void 0;
|
4
|
+
const parseAxiosError = (error) => {
|
5
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
6
|
+
const category = 'BAD_REQUEST';
|
7
|
+
let message = `${(_c = (_b = (_a = error === null || error === void 0 ? void 0 : error.response) === null || _a === void 0 ? void 0 : _a.status) === null || _b === void 0 ? void 0 : _b.toString()) !== null && _c !== void 0 ? _c : 'UNKNOWN_STATUS'}: ${error.message}`;
|
8
|
+
// Check if it's a Salesforce error
|
9
|
+
if (Array.isArray((_d = error === null || error === void 0 ? void 0 : error.response) === null || _d === void 0 ? void 0 : _d.data) &&
|
10
|
+
((_f = (_e = error === null || error === void 0 ? void 0 : error.response) === null || _e === void 0 ? void 0 : _e.data[0]) === null || _f === void 0 ? void 0 : _f.errorCode) &&
|
11
|
+
((_h = (_g = error === null || error === void 0 ? void 0 : error.response) === null || _g === void 0 ? void 0 : _g.data[0]) === null || _h === void 0 ? void 0 : _h.message)) {
|
12
|
+
const salesforceError = (_j = error === null || error === void 0 ? void 0 : error.response) === null || _j === void 0 ? void 0 : _j.data[0];
|
13
|
+
message = `${salesforceError.errorCode}: ${salesforceError.message}`;
|
14
|
+
}
|
15
|
+
return {
|
16
|
+
date: new Date().toISOString(),
|
17
|
+
text: {
|
18
|
+
en: message,
|
19
|
+
},
|
20
|
+
error: {
|
21
|
+
category,
|
22
|
+
message,
|
23
|
+
},
|
24
|
+
};
|
25
|
+
};
|
26
|
+
exports.parseAxiosError = parseAxiosError;
|
27
|
+
const parseUnknowError = (error) => {
|
28
|
+
const message = error.message;
|
29
|
+
return {
|
30
|
+
date: new Date().toISOString(),
|
31
|
+
text: { en: message },
|
32
|
+
error: {
|
33
|
+
category: 'SERVER_ERROR',
|
34
|
+
message,
|
35
|
+
},
|
36
|
+
};
|
37
|
+
};
|
38
|
+
exports.parseUnknowError = parseUnknowError;
|
39
|
+
//# sourceMappingURL=errors.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../../extensions/sfdc/lib/errors.ts"],"names":[],"mappings":";;;AAGO,MAAM,eAAe,GAAG,CAAC,KAAiB,EAAiB,EAAE;;IAClE,MAAM,QAAQ,GAAG,aAAa,CAAA;IAC9B,IAAI,OAAO,GAAG,GAAG,MAAA,MAAA,MAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,QAAQ,0CAAE,MAAM,0CAAE,QAAQ,EAAE,mCAAI,gBAAgB,KACtE,KAAK,CAAC,OACR,EAAE,CAAA;IAEF,mCAAmC;IACnC,IACE,KAAK,CAAC,OAAO,CAAC,MAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,QAAQ,0CAAE,IAAI,CAAC;SACpC,MAAA,MAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,QAAQ,0CAAE,IAAI,CAAC,CAAC,CAAC,0CAAE,SAAS,CAAA;SACnC,MAAA,MAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,QAAQ,0CAAE,IAAI,CAAC,CAAC,CAAC,0CAAE,OAAO,CAAA,EACjC;QACA,MAAM,eAAe,GAAG,MAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,QAAQ,0CAAE,IAAI,CAAC,CAAC,CAAC,CAAA;QAChD,OAAO,GAAG,GAAG,eAAe,CAAC,SAAS,KAAK,eAAe,CAAC,OAAO,EAAE,CAAA;KACrE;IAED,OAAO;QACL,IAAI,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;QAC9B,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