@digipair/skill-twilio 0.91.0-0 → 0.91.0
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/index.cjs.d.ts +1 -0
- package/index.cjs.js +51 -0
- package/index.esm.js +46 -0
- package/libs/skill-twilio/src/lib/skill-twilio.d.ts +3 -0
- package/package.json +5 -21
- package/.swcrc +0 -28
- package/README.md +0 -7
- package/eslint.config.mjs +0 -22
- package/rollup.config.cjs +0 -28
- package/src/lib/skill-twilio.spec.ts +0 -7
- package/src/lib/skill-twilio.ts +0 -65
- package/tsconfig.json +0 -13
- package/tsconfig.lib.json +0 -19
- /package/{src/index.d.ts → index.d.ts} +0 -0
- /package/{src/index.ts → libs/skill-twilio/src/index.d.ts} +0 -0
- /package/{src/schema.fr.json → schema.fr.json} +0 -0
- /package/{src/schema.json → schema.json} +0 -0
package/index.cjs.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./src/index";
|
package/index.cjs.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
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.esm.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
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 };
|
package/package.json
CHANGED
|
@@ -1,28 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@digipair/skill-twilio",
|
|
3
|
-
"version": "0.91.0
|
|
4
|
-
"type": "module",
|
|
5
|
-
"main": "dist/libs/skill-twilio/index.cjs.js",
|
|
6
|
-
"module": "dist/libs/skill-twilio/index.esm.js",
|
|
7
|
-
"types": "dist/libs/skill-twilio/index.esm.d.ts",
|
|
8
|
-
"exports": {
|
|
9
|
-
"./package.json": "./libs/skill-twilio/package.json",
|
|
10
|
-
".": {
|
|
11
|
-
"development": "./dist/libs/skill-twilio/src/index.ts",
|
|
12
|
-
"types": "./dist/libs/skill-twilio/index.esm.d.ts",
|
|
13
|
-
"import": "./dist/libs/skill-twilio/index.esm.js",
|
|
14
|
-
"default": "./dist/libs/skill-twilio/index.cjs.js"
|
|
15
|
-
}
|
|
16
|
-
},
|
|
3
|
+
"version": "0.91.0",
|
|
17
4
|
"keywords": [
|
|
18
5
|
"digipair",
|
|
19
6
|
"service",
|
|
20
7
|
"tool"
|
|
21
8
|
],
|
|
22
|
-
"
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
"@digipair/engine": "0.91.0-0"
|
|
27
|
-
}
|
|
28
|
-
}
|
|
9
|
+
"dependencies": {},
|
|
10
|
+
"main": "./index.cjs.js",
|
|
11
|
+
"module": "./index.esm.js"
|
|
12
|
+
}
|
package/.swcrc
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"jsc": {
|
|
3
|
-
"target": "es2017",
|
|
4
|
-
"parser": {
|
|
5
|
-
"syntax": "typescript",
|
|
6
|
-
"decorators": true,
|
|
7
|
-
"dynamicImport": true
|
|
8
|
-
},
|
|
9
|
-
"transform": {
|
|
10
|
-
"decoratorMetadata": true,
|
|
11
|
-
"legacyDecorator": true
|
|
12
|
-
},
|
|
13
|
-
"keepClassNames": true,
|
|
14
|
-
"externalHelpers": true,
|
|
15
|
-
"loose": true
|
|
16
|
-
},
|
|
17
|
-
"module": {
|
|
18
|
-
"type": "es6"
|
|
19
|
-
},
|
|
20
|
-
"sourceMaps": true,
|
|
21
|
-
"exclude": [
|
|
22
|
-
"jest.config.ts",
|
|
23
|
-
".*\\.spec.tsx?$",
|
|
24
|
-
".*\\.test.tsx?$",
|
|
25
|
-
"./src/jest-setup.ts$",
|
|
26
|
-
"./**/jest-setup.ts$"
|
|
27
|
-
]
|
|
28
|
-
}
|
package/README.md
DELETED
package/eslint.config.mjs
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import baseConfig from '../../eslint.config.mjs';
|
|
2
|
-
|
|
3
|
-
export default [
|
|
4
|
-
...baseConfig,
|
|
5
|
-
{
|
|
6
|
-
files: ['**/*.json'],
|
|
7
|
-
rules: {
|
|
8
|
-
'@nx/dependency-checks': [
|
|
9
|
-
'error',
|
|
10
|
-
{
|
|
11
|
-
ignoredFiles: [
|
|
12
|
-
'{projectRoot}/eslint.config.{js,cjs,mjs}',
|
|
13
|
-
'{projectRoot}/rollup.config.{js,ts,mjs,mts,cjs,cts}',
|
|
14
|
-
],
|
|
15
|
-
},
|
|
16
|
-
],
|
|
17
|
-
},
|
|
18
|
-
languageOptions: {
|
|
19
|
-
parser: await import('jsonc-eslint-parser'),
|
|
20
|
-
},
|
|
21
|
-
},
|
|
22
|
-
];
|
package/rollup.config.cjs
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
const { withNx } = require('@nx/rollup/with-nx');
|
|
2
|
-
|
|
3
|
-
module.exports = withNx(
|
|
4
|
-
{
|
|
5
|
-
main: 'libs/skill-twilio/src/index.ts',
|
|
6
|
-
outputPath: 'dist/libs/skill-twilio',
|
|
7
|
-
tsConfig: 'libs/skill-twilio/tsconfig.lib.json',
|
|
8
|
-
compiler: 'swc',
|
|
9
|
-
format: ['esm', "cjs"],
|
|
10
|
-
assets: [
|
|
11
|
-
{
|
|
12
|
-
input: 'libs/skill-twilio/',
|
|
13
|
-
glob: 'package.json',
|
|
14
|
-
output: '.'
|
|
15
|
-
},
|
|
16
|
-
{
|
|
17
|
-
input: 'libs/skill-twilio/src/',
|
|
18
|
-
glob: '*.json',
|
|
19
|
-
output: '.'
|
|
20
|
-
}
|
|
21
|
-
]
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
// Provide additional rollup configuration here. See: https://rollupjs.org/configuration-options
|
|
25
|
-
// e.g.
|
|
26
|
-
// output: { sourcemap: true },
|
|
27
|
-
}
|
|
28
|
-
);
|
package/src/lib/skill-twilio.ts
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
-
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
3
|
-
import { PinsSettings } from '@digipair/engine';
|
|
4
|
-
|
|
5
|
-
class TwilioService {
|
|
6
|
-
private FROM_NUMBER: string;
|
|
7
|
-
private TWILIO_SID: string;
|
|
8
|
-
private TWILIO_TOKEN: string;
|
|
9
|
-
private API_ENDPOINT: string;
|
|
10
|
-
|
|
11
|
-
constructor(context: any, params: any) {
|
|
12
|
-
this.TWILIO_SID =
|
|
13
|
-
context.privates.TWILIO_SID ?? params?.TWILIO_SID ?? process.env['TWILIO_SID'];
|
|
14
|
-
this.TWILIO_TOKEN =
|
|
15
|
-
context.privates.TWILIO_TOKEN ?? params?.TWILIO_TOKEN ?? process.env['TWILIO_TOKEN'];
|
|
16
|
-
this.FROM_NUMBER =
|
|
17
|
-
context.privates.TWILIO_FROM_NUMBER ??
|
|
18
|
-
params?.TWILIO_FROM_NUMBER ??
|
|
19
|
-
process.env['TWILIO_FROM_NUMBER'];
|
|
20
|
-
|
|
21
|
-
this.API_ENDPOINT =
|
|
22
|
-
context.privates.TWILIO_API_ENDPOINT ??
|
|
23
|
-
params?.TWILIO_API_ENDPOINT ??
|
|
24
|
-
process.env['TWILIO_API_ENDPOINT'] ??
|
|
25
|
-
'https://api.twilio.com/2010-04-01';
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
async call(url: string, method: string, data: any, headers: any, signal: AbortSignal) {
|
|
29
|
-
const response = await fetch(`${this.API_ENDPOINT}${url}`, {
|
|
30
|
-
signal,
|
|
31
|
-
method,
|
|
32
|
-
headers: {
|
|
33
|
-
Authorization: 'Basic ' + btoa(this.TWILIO_SID + ':' + this.TWILIO_TOKEN),
|
|
34
|
-
...headers,
|
|
35
|
-
},
|
|
36
|
-
body: data,
|
|
37
|
-
});
|
|
38
|
-
if (!response.ok) throw new Error('[SKILL-TWILIO] REQUEST FAILED: ' + response.status);
|
|
39
|
-
return await response.json();
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
async sendSms(
|
|
43
|
-
params: any,
|
|
44
|
-
_pinsSettingsList: PinsSettings[],
|
|
45
|
-
context: any,
|
|
46
|
-
whatsapp: boolean = false,
|
|
47
|
-
): Promise<any> {
|
|
48
|
-
const { message, phoneNumber } = params;
|
|
49
|
-
return await this.call(
|
|
50
|
-
`/Accounts/${this.TWILIO_SID}/Messages.json`,
|
|
51
|
-
'POST',
|
|
52
|
-
`From=${encodeURIComponent(`${whatsapp ? 'whatsapp:' : ''}${this.FROM_NUMBER}`)}&Body=${encodeURIComponent(message)}&To=${encodeURIComponent(`${phoneNumber}`)}`,
|
|
53
|
-
{
|
|
54
|
-
'Content-Type': 'application/x-www-form-urlencoded',
|
|
55
|
-
},
|
|
56
|
-
context.protected?.signal,
|
|
57
|
-
);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export const sendSms = (params: any, pinsSettingsList: PinsSettings[], context: any) =>
|
|
62
|
-
new TwilioService(context, params).sendSms(params, pinsSettingsList, context);
|
|
63
|
-
|
|
64
|
-
export const sendWhatsapp = (params: any, pinsSettingsList: PinsSettings[], context: any) =>
|
|
65
|
-
new TwilioService(context, params).sendSms(params, pinsSettingsList, context, true);
|
package/tsconfig.json
DELETED
package/tsconfig.lib.json
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "../../tsconfig.base.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"rootDir": "src",
|
|
5
|
-
"outDir": "dist",
|
|
6
|
-
"tsBuildInfoFile": "dist/tsconfig.lib.tsbuildinfo",
|
|
7
|
-
"emitDeclarationOnly": true,
|
|
8
|
-
"module": "esnext",
|
|
9
|
-
"moduleResolution": "node",
|
|
10
|
-
"forceConsistentCasingInFileNames": true,
|
|
11
|
-
"types": ["node"]
|
|
12
|
-
},
|
|
13
|
-
"include": ["src/**/*.ts"],
|
|
14
|
-
"references": [
|
|
15
|
-
{
|
|
16
|
-
"path": "../engine/tsconfig.lib.json"
|
|
17
|
-
}
|
|
18
|
-
]
|
|
19
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|