@digipair/skill-twilio 0.113.1 → 0.114.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,7 @@
1
+ # skill-test
2
+
3
+ This library was generated with [Nx](https://nx.dev).
4
+
5
+ ## Building
6
+
7
+ Run `nx build skill-twilio` to build the library.
@@ -0,0 +1,34 @@
1
+ 'use strict';
2
+
3
+ /* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable @typescript-eslint/no-unused-vars */ let TwilioService = class TwilioService {
4
+ constructor(context, params){
5
+ this.TWILIO_SID = context.privates.TWILIO_SID ?? params?.TWILIO_SID ?? process.env['TWILIO_SID'];
6
+ this.TWILIO_TOKEN = context.privates.TWILIO_TOKEN ?? params?.TWILIO_TOKEN ?? process.env['TWILIO_TOKEN'];
7
+ this.FROM_NUMBER = context.privates.TWILIO_FROM_NUMBER ?? params?.TWILIO_FROM_NUMBER ?? process.env['TWILIO_FROM_NUMBER'];
8
+ this.API_ENDPOINT = context.privates.TWILIO_API_ENDPOINT ?? params?.TWILIO_API_ENDPOINT ?? process.env['TWILIO_API_ENDPOINT'] ?? 'https://api.twilio.com/2010-04-01';
9
+ }
10
+ async call(url, method, data, headers, signal) {
11
+ const response = await fetch(`${this.API_ENDPOINT}${url}`, {
12
+ signal,
13
+ method,
14
+ headers: {
15
+ Authorization: 'Basic ' + btoa(this.TWILIO_SID + ':' + this.TWILIO_TOKEN),
16
+ ...headers
17
+ },
18
+ body: data
19
+ });
20
+ if (!response.ok) throw new Error('[SKILL-TWILIO] REQUEST FAILED: ' + response.status);
21
+ return await response.json();
22
+ }
23
+ async sendSms(params, _pinsSettingsList, context, whatsapp = false) {
24
+ const { message, phoneNumber } = params;
25
+ return await this.call(`/Accounts/${this.TWILIO_SID}/Messages.json`, 'POST', `From=${encodeURIComponent(`${whatsapp ? 'whatsapp:' : ''}${this.FROM_NUMBER}`)}&Body=${encodeURIComponent(message)}&To=${encodeURIComponent(`${phoneNumber}`)}`, {
26
+ 'Content-Type': 'application/x-www-form-urlencoded'
27
+ }, context.protected?.signal);
28
+ }
29
+ };
30
+ const sendSms = (params, pinsSettingsList, context)=>new TwilioService(context, params).sendSms(params, pinsSettingsList, context);
31
+ const sendWhatsapp = (params, pinsSettingsList, context)=>new TwilioService(context, params).sendSms(params, pinsSettingsList, context, true);
32
+
33
+ exports.sendSms = sendSms;
34
+ exports.sendWhatsapp = sendWhatsapp;
@@ -0,0 +1,31 @@
1
+ /* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable @typescript-eslint/no-unused-vars */ let TwilioService = class TwilioService {
2
+ constructor(context, params){
3
+ this.TWILIO_SID = context.privates.TWILIO_SID ?? params?.TWILIO_SID ?? process.env['TWILIO_SID'];
4
+ this.TWILIO_TOKEN = context.privates.TWILIO_TOKEN ?? params?.TWILIO_TOKEN ?? process.env['TWILIO_TOKEN'];
5
+ this.FROM_NUMBER = context.privates.TWILIO_FROM_NUMBER ?? params?.TWILIO_FROM_NUMBER ?? process.env['TWILIO_FROM_NUMBER'];
6
+ this.API_ENDPOINT = context.privates.TWILIO_API_ENDPOINT ?? params?.TWILIO_API_ENDPOINT ?? process.env['TWILIO_API_ENDPOINT'] ?? 'https://api.twilio.com/2010-04-01';
7
+ }
8
+ async call(url, method, data, headers, signal) {
9
+ const response = await fetch(`${this.API_ENDPOINT}${url}`, {
10
+ signal,
11
+ method,
12
+ headers: {
13
+ Authorization: 'Basic ' + btoa(this.TWILIO_SID + ':' + this.TWILIO_TOKEN),
14
+ ...headers
15
+ },
16
+ body: data
17
+ });
18
+ if (!response.ok) throw new Error('[SKILL-TWILIO] REQUEST FAILED: ' + response.status);
19
+ return await response.json();
20
+ }
21
+ async sendSms(params, _pinsSettingsList, context, whatsapp = false) {
22
+ const { message, phoneNumber } = params;
23
+ return await this.call(`/Accounts/${this.TWILIO_SID}/Messages.json`, 'POST', `From=${encodeURIComponent(`${whatsapp ? 'whatsapp:' : ''}${this.FROM_NUMBER}`)}&Body=${encodeURIComponent(message)}&To=${encodeURIComponent(`${phoneNumber}`)}`, {
24
+ 'Content-Type': 'application/x-www-form-urlencoded'
25
+ }, context.protected?.signal);
26
+ }
27
+ };
28
+ const sendSms = (params, pinsSettingsList, context)=>new TwilioService(context, params).sendSms(params, pinsSettingsList, context);
29
+ const sendWhatsapp = (params, pinsSettingsList, context)=>new TwilioService(context, params).sendSms(params, pinsSettingsList, context, true);
30
+
31
+ export { sendSms, sendWhatsapp };
@@ -1 +1,2 @@
1
1
  export * from './lib/skill-twilio';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC"}
@@ -1,3 +1,4 @@
1
1
  import { PinsSettings } from '@digipair/engine';
2
2
  export declare const sendSms: (params: any, pinsSettingsList: PinsSettings[], context: any) => Promise<any>;
3
3
  export declare const sendWhatsapp: (params: any, pinsSettingsList: PinsSettings[], context: any) => Promise<any>;
4
+ //# sourceMappingURL=skill-twilio.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"skill-twilio.d.ts","sourceRoot":"","sources":["../../../src/lib/skill-twilio.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AA0DhD,eAAO,MAAM,OAAO,GAAI,QAAQ,GAAG,EAAE,kBAAkB,YAAY,EAAE,EAAE,SAAS,GAAG,iBACJ,CAAC;AAEhF,eAAO,MAAM,YAAY,GAAI,QAAQ,GAAG,EAAE,kBAAkB,YAAY,EAAE,EAAE,SAAS,GAAG,iBACH,CAAC"}
package/package.json CHANGED
@@ -1,12 +1,33 @@
1
1
  {
2
2
  "name": "@digipair/skill-twilio",
3
- "version": "0.113.1",
3
+ "version": "0.114.2",
4
+ "main": "./dist/index.cjs.js",
5
+ "module": "./dist/index.esm.js",
6
+ "types": "./dist/index.d.ts",
4
7
  "keywords": [
5
8
  "digipair",
6
9
  "service",
7
10
  "tool"
8
11
  ],
9
- "dependencies": {},
10
- "main": "./index.cjs.js",
11
- "module": "./index.esm.js"
12
- }
12
+ "exports": {
13
+ ".": {
14
+ "types": "./dist/index.d.ts",
15
+ "import": "./dist/index.esm.js",
16
+ "default": "./dist/index.cjs.js"
17
+ },
18
+ "./index.esm.js": "./dist/index.esm.js",
19
+ "./index.cjs.js": "./dist/index.cjs.js",
20
+ "./package.json": "./package.json",
21
+ "./schema.json": "./dist/schema.json",
22
+ "./schema.fr.json": "./dist/schema.fr.json"
23
+ },
24
+ "files": [
25
+ "dist",
26
+ "README.md",
27
+ "package.json"
28
+ ],
29
+ "nx": {
30
+ "name": "skill-twilio"
31
+ },
32
+ "dependencies": {}
33
+ }
package/index.cjs.js DELETED
@@ -1,51 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- function _extends() {
6
- _extends = Object.assign || function assign(target) {
7
- for(var i = 1; i < arguments.length; i++){
8
- var source = arguments[i];
9
- for(var key in source)if (Object.prototype.hasOwnProperty.call(source, key)) target[key] = source[key];
10
- }
11
- return target;
12
- };
13
- return _extends.apply(this, arguments);
14
- }
15
-
16
- let TwilioService = class TwilioService {
17
- async call(url, method, data, headers, signal) {
18
- const response = await fetch(`${this.API_ENDPOINT}${url}`, {
19
- signal,
20
- method,
21
- headers: _extends({
22
- Authorization: 'Basic ' + btoa(this.TWILIO_SID + ':' + this.TWILIO_TOKEN)
23
- }, headers),
24
- body: data
25
- });
26
- if (!response.ok) throw new Error('[SKILL-TWILIO] REQUEST FAILED: ' + response.status);
27
- return await response.json();
28
- }
29
- async sendSms(params, _pinsSettingsList, context, whatsapp = false) {
30
- var _context_protected;
31
- const { message, phoneNumber } = params;
32
- return await this.call(`/Accounts/${this.TWILIO_SID}/Messages.json`, 'POST', `From=${encodeURIComponent(`${whatsapp ? 'whatsapp:' : ''}${this.FROM_NUMBER}`)}&Body=${encodeURIComponent(message)}&To=${encodeURIComponent(`${phoneNumber}`)}`, {
33
- 'Content-Type': 'application/x-www-form-urlencoded'
34
- }, (_context_protected = context.protected) == null ? void 0 : _context_protected.signal);
35
- }
36
- constructor(context, params){
37
- var _context_privates_TWILIO_SID, _ref;
38
- this.TWILIO_SID = (_ref = (_context_privates_TWILIO_SID = context.privates.TWILIO_SID) != null ? _context_privates_TWILIO_SID : params == null ? void 0 : params.TWILIO_SID) != null ? _ref : process.env['TWILIO_SID'];
39
- var _context_privates_TWILIO_TOKEN, _ref1;
40
- this.TWILIO_TOKEN = (_ref1 = (_context_privates_TWILIO_TOKEN = context.privates.TWILIO_TOKEN) != null ? _context_privates_TWILIO_TOKEN : params == null ? void 0 : params.TWILIO_TOKEN) != null ? _ref1 : process.env['TWILIO_TOKEN'];
41
- var _context_privates_TWILIO_FROM_NUMBER, _ref2;
42
- this.FROM_NUMBER = (_ref2 = (_context_privates_TWILIO_FROM_NUMBER = context.privates.TWILIO_FROM_NUMBER) != null ? _context_privates_TWILIO_FROM_NUMBER : params == null ? void 0 : params.TWILIO_FROM_NUMBER) != null ? _ref2 : process.env['TWILIO_FROM_NUMBER'];
43
- var _context_privates_TWILIO_API_ENDPOINT, _ref3, _ref4;
44
- this.API_ENDPOINT = (_ref4 = (_ref3 = (_context_privates_TWILIO_API_ENDPOINT = context.privates.TWILIO_API_ENDPOINT) != null ? _context_privates_TWILIO_API_ENDPOINT : params == null ? void 0 : params.TWILIO_API_ENDPOINT) != null ? _ref3 : process.env['TWILIO_API_ENDPOINT']) != null ? _ref4 : 'https://api.twilio.com/2010-04-01';
45
- }
46
- };
47
- const sendSms = (params, pinsSettingsList, context)=>new TwilioService(context, params).sendSms(params, pinsSettingsList, context);
48
- const sendWhatsapp = (params, pinsSettingsList, context)=>new TwilioService(context, params).sendSms(params, pinsSettingsList, context, true);
49
-
50
- exports.sendSms = sendSms;
51
- exports.sendWhatsapp = sendWhatsapp;
package/index.d.ts DELETED
@@ -1 +0,0 @@
1
- export * from './libs/skill-twilio/src/index';
package/index.esm.js DELETED
@@ -1,46 +0,0 @@
1
- function _extends() {
2
- _extends = Object.assign || function assign(target) {
3
- for(var i = 1; i < arguments.length; i++){
4
- var source = arguments[i];
5
- for(var key in source)if (Object.prototype.hasOwnProperty.call(source, key)) target[key] = source[key];
6
- }
7
- return target;
8
- };
9
- return _extends.apply(this, arguments);
10
- }
11
-
12
- let TwilioService = class TwilioService {
13
- async call(url, method, data, headers, signal) {
14
- const response = await fetch(`${this.API_ENDPOINT}${url}`, {
15
- signal,
16
- method,
17
- headers: _extends({
18
- Authorization: 'Basic ' + btoa(this.TWILIO_SID + ':' + this.TWILIO_TOKEN)
19
- }, headers),
20
- body: data
21
- });
22
- if (!response.ok) throw new Error('[SKILL-TWILIO] REQUEST FAILED: ' + response.status);
23
- return await response.json();
24
- }
25
- async sendSms(params, _pinsSettingsList, context, whatsapp = false) {
26
- var _context_protected;
27
- const { message, phoneNumber } = params;
28
- return await this.call(`/Accounts/${this.TWILIO_SID}/Messages.json`, 'POST', `From=${encodeURIComponent(`${whatsapp ? 'whatsapp:' : ''}${this.FROM_NUMBER}`)}&Body=${encodeURIComponent(message)}&To=${encodeURIComponent(`${phoneNumber}`)}`, {
29
- 'Content-Type': 'application/x-www-form-urlencoded'
30
- }, (_context_protected = context.protected) == null ? void 0 : _context_protected.signal);
31
- }
32
- constructor(context, params){
33
- var _context_privates_TWILIO_SID, _ref;
34
- this.TWILIO_SID = (_ref = (_context_privates_TWILIO_SID = context.privates.TWILIO_SID) != null ? _context_privates_TWILIO_SID : params == null ? void 0 : params.TWILIO_SID) != null ? _ref : process.env['TWILIO_SID'];
35
- var _context_privates_TWILIO_TOKEN, _ref1;
36
- this.TWILIO_TOKEN = (_ref1 = (_context_privates_TWILIO_TOKEN = context.privates.TWILIO_TOKEN) != null ? _context_privates_TWILIO_TOKEN : params == null ? void 0 : params.TWILIO_TOKEN) != null ? _ref1 : process.env['TWILIO_TOKEN'];
37
- var _context_privates_TWILIO_FROM_NUMBER, _ref2;
38
- this.FROM_NUMBER = (_ref2 = (_context_privates_TWILIO_FROM_NUMBER = context.privates.TWILIO_FROM_NUMBER) != null ? _context_privates_TWILIO_FROM_NUMBER : params == null ? void 0 : params.TWILIO_FROM_NUMBER) != null ? _ref2 : process.env['TWILIO_FROM_NUMBER'];
39
- var _context_privates_TWILIO_API_ENDPOINT, _ref3, _ref4;
40
- this.API_ENDPOINT = (_ref4 = (_ref3 = (_context_privates_TWILIO_API_ENDPOINT = context.privates.TWILIO_API_ENDPOINT) != null ? _context_privates_TWILIO_API_ENDPOINT : params == null ? void 0 : params.TWILIO_API_ENDPOINT) != null ? _ref3 : process.env['TWILIO_API_ENDPOINT']) != null ? _ref4 : 'https://api.twilio.com/2010-04-01';
41
- }
42
- };
43
- const sendSms = (params, pinsSettingsList, context)=>new TwilioService(context, params).sendSms(params, pinsSettingsList, context);
44
- const sendWhatsapp = (params, pinsSettingsList, context)=>new TwilioService(context, params).sendSms(params, pinsSettingsList, context, true);
45
-
46
- export { sendSms, sendWhatsapp };
File without changes
File without changes
File without changes