@venturialstd/twilio 0.0.6 → 0.0.7

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.
@@ -1 +1 @@
1
- {"version":3,"file":"twilio.client.d.ts","sourceRoot":"","sources":["../../src/clients/twilio.client.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAGhC,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAE3D,qBACa,YAAY;IACX,OAAO,CAAC,QAAQ,CAAC,eAAe;gBAAf,eAAe,EAAE,eAAe;IAEvD,SAAS,CAAC,MAAM,GAAE,YAAY,GAAG,IAAW,GAAG,OAAO,CAAC,MAAM,CAAC;IAgB9D,cAAc,CAClB,MAAM,GAAE,YAAY,GAAG,IAAW,EAClC,OAAO,GAAE,MAAmB,GAC3B,OAAO,CAAC,MAAM,CAAC;CAWnB"}
1
+ {"version":3,"file":"twilio.client.d.ts","sourceRoot":"","sources":["../../src/clients/twilio.client.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAOhC,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAE3D,qBACa,YAAY;IACX,OAAO,CAAC,QAAQ,CAAC,eAAe;gBAAf,eAAe,EAAE,eAAe;IAEvD,SAAS,CAAC,MAAM,GAAE,YAAY,GAAG,IAAW,GAAG,OAAO,CAAC,MAAM,CAAC;IAoB9D,cAAc,CAClB,MAAM,GAAE,YAAY,GAAG,IAAW,EAClC,OAAO,GAAE,MAAmB,GAC3B,OAAO,CAAC,MAAM,CAAC;CAgBnB"}
@@ -20,23 +20,32 @@ let TwilioClient = class TwilioClient {
20
20
  this.settingsService = settingsService;
21
21
  }
22
22
  async getClient(config = null) {
23
- if (config && config.auth) {
23
+ if (config?.auth?.accountSid && config?.auth?.authToken) {
24
24
  return new twilio_1.Twilio(config.auth.accountSid, config.auth.authToken);
25
25
  }
26
26
  const twilioSettings = await this.settingsService.getManyWithDefaults([
27
27
  twilio_settings_constant_1.TWILIO_SETTING_KEYS.GENERAL_ACCOUNT_SID,
28
28
  twilio_settings_constant_1.TWILIO_SETTING_KEYS.GENERAL_AUTH_TOKEN,
29
29
  ]);
30
- return new twilio_1.Twilio(twilioSettings[twilio_settings_constant_1.TWILIO_SETTING_KEYS.GENERAL_ACCOUNT_SID], twilioSettings[twilio_settings_constant_1.TWILIO_SETTING_KEYS.GENERAL_AUTH_TOKEN]);
30
+ const accountSid = twilioSettings[twilio_settings_constant_1.TWILIO_SETTING_KEYS.GENERAL_ACCOUNT_SID];
31
+ const authToken = twilioSettings[twilio_settings_constant_1.TWILIO_SETTING_KEYS.GENERAL_AUTH_TOKEN];
32
+ if (!accountSid?.trim() || !authToken?.trim()) {
33
+ throw new common_1.BadGatewayException(twilio_settings_constant_1.TWILIO_NOT_CONFIGURED_MESSAGE);
34
+ }
35
+ return new twilio_1.Twilio(accountSid, authToken);
31
36
  }
32
37
  async getPhoneNumber(config = null, channel = 'whatsapp') {
33
- if (config && config.phoneNumber) {
38
+ if (config?.phoneNumber) {
34
39
  return `${channel}:${config.phoneNumber}`;
35
40
  }
36
41
  const twilioSettings = await this.settingsService.getManyWithDefaults([
37
42
  twilio_settings_constant_1.TWILIO_SETTING_KEYS.GENERAL_PHONE_NUMBER,
38
43
  ]);
39
- return `${channel}:${twilioSettings[twilio_settings_constant_1.TWILIO_SETTING_KEYS.GENERAL_PHONE_NUMBER]}`;
44
+ const phoneNumber = twilioSettings[twilio_settings_constant_1.TWILIO_SETTING_KEYS.GENERAL_PHONE_NUMBER];
45
+ if (!phoneNumber?.trim()) {
46
+ throw new common_1.BadGatewayException(twilio_settings_constant_1.TWILIO_PHONE_NUMBER_NOT_CONFIGURED_MESSAGE);
47
+ }
48
+ return `${channel}:${phoneNumber}`;
40
49
  }
41
50
  };
42
51
  exports.TwilioClient = TwilioClient;
@@ -1 +1 @@
1
- {"version":3,"file":"twilio.client.js","sourceRoot":"","sources":["../../src/clients/twilio.client.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4C;AAC5C,6CAAqD;AACrD,mCAAgC;AAEhC,oFAA4E;AAIrE,IAAM,YAAY,GAAlB,MAAM,YAAY;IACM;IAA7B,YAA6B,eAAgC;QAAhC,oBAAe,GAAf,eAAe,CAAiB;IAAG,CAAC;IAEjE,KAAK,CAAC,SAAS,CAAC,SAA8B,IAAI;QAChD,IAAI,MAAM,IAAI,MAAM,CAAC,IAAI,EAAE,CAAC;YAC1B,OAAO,IAAI,eAAM,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,EAAE,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QACnE,CAAC;QAED,MAAM,cAAc,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,mBAAmB,CAAC;YACpE,8CAAmB,CAAC,mBAAmB;YACvC,8CAAmB,CAAC,kBAAkB;SACvC,CAAC,CAAC;QAEH,OAAO,IAAI,eAAM,CACf,cAAc,CAAC,8CAAmB,CAAC,mBAAmB,CAAC,EACvD,cAAc,CAAC,8CAAmB,CAAC,kBAAkB,CAAC,CACvD,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,cAAc,CAClB,SAA8B,IAAI,EAClC,UAAkB,UAAU;QAE5B,IAAI,MAAM,IAAI,MAAM,CAAC,WAAW,EAAE,CAAC;YACjC,OAAO,GAAG,OAAO,IAAI,MAAM,CAAC,WAAW,EAAE,CAAC;QAC5C,CAAC;QAED,MAAM,cAAc,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,mBAAmB,CAAC;YACpE,8CAAmB,CAAC,oBAAoB;SACzC,CAAC,CAAC;QAEH,OAAO,GAAG,OAAO,IAAI,cAAc,CAAC,8CAAmB,CAAC,oBAAoB,CAAC,EAAE,CAA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AE,WAAW,EAAE,CAAC;YACxB,OAAO,GAAG,OAAO,IAAI,MAAM,CAAC,WAAW,EAAE,CAAC;QAC5C,CAAC;QAED,MAAM,cAAc,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,mBAAmB,CAAC;YACpE,8CAAmB,CAAC,oBAAoB;SACzC,CAAC,CAAC;QAEH,MAAM,WAAW,GAAG,cAAc,CAAC,8CAAmB,CAAC,oBAAoB,CAAC,CAAC;QAC7E,IAAI,CAAC,WAAW,EAAE,IAAI,EAAE,EAAE,CAAC;YACzB,MAAM,IAAI,4BAAmB,CAAC,qEAA0C,CAAC,CAAC;QAC5E,CAAC;QAED,OAAO,GAAG,OAAO,IAAI,WAAW,EAAE,CAAC;IACrC,CAAC;CACF,CAAA;AA1CY,oCAAY;uBAAZ,YAAY;IADxB,IAAA,mBAAU,GAAE;qCAEmC,sBAAe;GADlD,YAAY,CA0CxB"}
@@ -4,4 +4,6 @@ export declare const TWILIO_SETTING_KEYS: {
4
4
  GENERAL_AUTH_TOKEN: string;
5
5
  GENERAL_PHONE_NUMBER: string;
6
6
  };
7
+ export declare const TWILIO_NOT_CONFIGURED_MESSAGE = "Twilio is not configured. Please set Account SID and Auth Token in settings.";
8
+ export declare const TWILIO_PHONE_NUMBER_NOT_CONFIGURED_MESSAGE = "Twilio phone number is not configured. Please set it in settings.";
7
9
  //# sourceMappingURL=twilio.settings.constant.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"twilio.settings.constant.d.ts","sourceRoot":"","sources":["../../src/constants/twilio.settings.constant.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,mBAAmB;;;;;CAK/B,CAAC"}
1
+ {"version":3,"file":"twilio.settings.constant.d.ts","sourceRoot":"","sources":["../../src/constants/twilio.settings.constant.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,mBAAmB;;;;;CAK/B,CAAC;AAEF,eAAO,MAAM,6BAA6B,iFACsC,CAAC;AAEjF,eAAO,MAAM,0CAA0C,sEACc,CAAC"}
@@ -1,10 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TWILIO_SETTING_KEYS = void 0;
3
+ exports.TWILIO_PHONE_NUMBER_NOT_CONFIGURED_MESSAGE = exports.TWILIO_NOT_CONFIGURED_MESSAGE = exports.TWILIO_SETTING_KEYS = void 0;
4
4
  exports.TWILIO_SETTING_KEYS = {
5
5
  GENERAL_ENABLED: 'GLOBAL:TWILIO:GENERAL:ENABLED',
6
6
  GENERAL_ACCOUNT_SID: 'GLOBAL:TWILIO:GENERAL:ACCOUNT_SID',
7
7
  GENERAL_AUTH_TOKEN: 'GLOBAL:TWILIO:GENERAL:AUTH_TOKEN',
8
8
  GENERAL_PHONE_NUMBER: 'GLOBAL:TWILIO:GENERAL:PHONE_NUMBER',
9
9
  };
10
+ exports.TWILIO_NOT_CONFIGURED_MESSAGE = 'Twilio is not configured. Please set Account SID and Auth Token in settings.';
11
+ exports.TWILIO_PHONE_NUMBER_NOT_CONFIGURED_MESSAGE = 'Twilio phone number is not configured. Please set it in settings.';
10
12
  //# sourceMappingURL=twilio.settings.constant.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"twilio.settings.constant.js","sourceRoot":"","sources":["../../src/constants/twilio.settings.constant.ts"],"names":[],"mappings":";;;AAAa,QAAA,mBAAmB,GAAG;IACjC,eAAe,EAAE,+BAA+B;IAChD,mBAAmB,EAAE,mCAAmC;IACxD,kBAAkB,EAAE,kCAAkC;IACtD,oBAAoB,EAAE,oCAAoC;CAC3D,CAAC"}
1
+ {"version":3,"file":"twilio.settings.constant.js","sourceRoot":"","sources":["../../src/constants/twilio.settings.constant.ts"],"names":[],"mappings":";;;AAAa,QAAA,mBAAmB,GAAG;IACjC,eAAe,EAAE,+BAA+B;IAChD,mBAAmB,EAAE,mCAAmC;IACxD,kBAAkB,EAAE,kCAAkC;IACtD,oBAAoB,EAAE,oCAAoC;CAC3D,CAAC;AAEW,QAAA,6BAA6B,GACxC,8EAA8E,CAAC;AAEpE,QAAA,0CAA0C,GACrD,mEAAmE,CAAC"}
package/package.json CHANGED
@@ -1,97 +1,97 @@
1
- {
2
- "name": "@venturialstd/twilio",
3
- "version": "0.0.6",
4
- "description": "Twilio Module for Venturial",
5
- "main": "dist/index.js",
6
- "types": "dist/index.d.ts",
7
- "type": "commonjs",
8
- "files": [
9
- "dist"
10
- ],
11
- "publishConfig": {
12
- "access": "public"
13
- },
14
- "scripts": {
15
- "build": "tsc -p tsconfig.json",
16
- "postbuild": "node ../../scripts/postbuild-link-nest.js @venturialstd/twilio",
17
- "prepublishOnly": "npm run build",
18
- "release:patch": "npm run build && npm version patch --no-git-tag-version && npm publish",
19
- "test:dev": "ts-node -r tsconfig-paths/register test/main.ts",
20
- "test:watch": "nodemon --watch src --watch test --ext ts --exec npm run test:dev",
21
- "migration:generate": "ts-node node_modules/.bin/typeorm migration:generate -d test/data-source.ts test/migrations/$npm_config_name",
22
- "migration:run": "ts-node node_modules/.bin/typeorm migration:run -d test/data-source.ts",
23
- "migration:revert": "ts-node node_modules/.bin/typeorm migration:revert -d test/data-source.ts"
24
- },
25
- "devDependencies": {
26
- "@dataui/crud": "^5.3.4",
27
- "@dataui/crud-request": "^5.3.4",
28
- "@dataui/crud-typeorm": "^5.3.4",
29
- "@keyv/redis": "^4.2.0",
30
- "@nestjs/cache-manager": "^3.0.0",
31
- "@nestjs/common": "^11.0.11",
32
- "@nestjs/config": "^4.0.0",
33
- "@nestjs/core": "^11.0.5",
34
- "@nestjs/event-emitter": "^3.0.1",
35
- "@nestjs/jwt": "^11.0.0",
36
- "@nestjs/passport": "^11.0.5",
37
- "@nestjs/platform-express": "^11.0.5",
38
- "@nestjs/swagger": "^11.0.3",
39
- "@nestjs/typeorm": "^11.0.0",
40
- "@types/node": "^20.0.0",
41
- "@venturialstd/core": "^1.0.16",
42
- "bcrypt": "^5.1.1",
43
- "cache-manager": "^6.4.0",
44
- "class-transformer": "^0.5.1",
45
- "class-validator": "^0.14.1",
46
- "dotenv": "^17.2.3",
47
- "express": "^5.2.1",
48
- "glob": "^13.0.0",
49
- "joi": "^17.13.3",
50
- "jwks-rsa": "^3.1.0",
51
- "lodash": "^4.17.21",
52
- "nodemon": "^3.0.0",
53
- "passport": "^0.7.0",
54
- "passport-auth0": "^1.4.4",
55
- "passport-jwt": "^4.0.1",
56
- "passport-local": "^1.0.0",
57
- "rxjs": "^7.8.1",
58
- "ts-node": "^10.9.0",
59
- "tsconfig-paths": "^4.2.0",
60
- "twilio": "^5.6.1",
61
- "typeorm": "^0.3.20",
62
- "typescript": "^5.9.3",
63
- "uuid": "^11.0.5",
64
- "winston": "^3.17.0"
65
- },
66
- "peerDependencies": {
67
- "@dataui/crud": "^5.3.4",
68
- "@dataui/crud-request": "^5.3.4",
69
- "@dataui/crud-typeorm": "^5.3.4",
70
- "@nestjs/cache-manager": "^3.0.0",
71
- "@nestjs/common": "^11.0.11",
72
- "@nestjs/config": "^4.0.0",
73
- "@nestjs/core": "^11.0.5",
74
- "@nestjs/event-emitter": "^3.0.1",
75
- "@nestjs/jwt": "^11.0.0",
76
- "@nestjs/passport": "^11.0.5",
77
- "@nestjs/swagger": "^11.0.3",
78
- "@nestjs/typeorm": "^11.0.0",
79
- "@venturialstd/core": "^1.0.16",
80
- "bcrypt": "^5.1.1",
81
- "cache-manager": "^6.4.0",
82
- "class-transformer": "^0.5.1",
83
- "class-validator": "^0.14.1",
84
- "jwks-rsa": "^3.1.0",
85
- "passport": "^0.7.0",
86
- "passport-auth0": "^1.4.0",
87
- "passport-jwt": "^4.0.1",
88
- "passport-local": "^1.0.0",
89
- "rxjs": "^7.8.1",
90
- "twilio": "^5.6.1",
91
- "typeorm": "^0.3.20",
92
- "uuid": "^11.0.5"
93
- },
94
- "dependencies": {
95
- "pg": "^8.16.3"
96
- }
97
- }
1
+ {
2
+ "name": "@venturialstd/twilio",
3
+ "version": "0.0.7",
4
+ "description": "Twilio Module for Venturial",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "type": "commonjs",
8
+ "files": [
9
+ "dist"
10
+ ],
11
+ "publishConfig": {
12
+ "access": "public"
13
+ },
14
+ "scripts": {
15
+ "build": "tsc -p tsconfig.json",
16
+ "postbuild": "node ../../scripts/postbuild-link-nest.js @venturialstd/twilio",
17
+ "prepublishOnly": "npm run build",
18
+ "release:patch": "npm run build && npm version patch --no-git-tag-version && npm publish",
19
+ "test:dev": "ts-node -r tsconfig-paths/register test/main.ts",
20
+ "test:watch": "nodemon --watch src --watch test --ext ts --exec npm run test:dev",
21
+ "migration:generate": "ts-node node_modules/.bin/typeorm migration:generate -d test/data-source.ts test/migrations/$npm_config_name",
22
+ "migration:run": "ts-node node_modules/.bin/typeorm migration:run -d test/data-source.ts",
23
+ "migration:revert": "ts-node node_modules/.bin/typeorm migration:revert -d test/data-source.ts"
24
+ },
25
+ "devDependencies": {
26
+ "@dataui/crud": "^5.3.4",
27
+ "@dataui/crud-request": "^5.3.4",
28
+ "@dataui/crud-typeorm": "^5.3.4",
29
+ "@keyv/redis": "^4.2.0",
30
+ "@nestjs/cache-manager": "^3.0.0",
31
+ "@nestjs/common": "^11.0.11",
32
+ "@nestjs/config": "^4.0.0",
33
+ "@nestjs/core": "^11.0.5",
34
+ "@nestjs/event-emitter": "^3.0.1",
35
+ "@nestjs/jwt": "^11.0.0",
36
+ "@nestjs/passport": "^11.0.5",
37
+ "@nestjs/platform-express": "^11.0.5",
38
+ "@nestjs/swagger": "^11.0.3",
39
+ "@nestjs/typeorm": "^11.0.0",
40
+ "@types/node": "^20.0.0",
41
+ "@venturialstd/core": "^1.0.16",
42
+ "bcrypt": "^5.1.1",
43
+ "cache-manager": "^6.4.0",
44
+ "class-transformer": "^0.5.1",
45
+ "class-validator": "^0.14.1",
46
+ "dotenv": "^17.2.3",
47
+ "express": "^5.2.1",
48
+ "glob": "^13.0.0",
49
+ "joi": "^17.13.3",
50
+ "jwks-rsa": "^3.1.0",
51
+ "lodash": "^4.17.21",
52
+ "nodemon": "^3.0.0",
53
+ "passport": "^0.7.0",
54
+ "passport-auth0": "^1.4.4",
55
+ "passport-jwt": "^4.0.1",
56
+ "passport-local": "^1.0.0",
57
+ "rxjs": "^7.8.1",
58
+ "ts-node": "^10.9.0",
59
+ "tsconfig-paths": "^4.2.0",
60
+ "twilio": "^5.6.1",
61
+ "typeorm": "^0.3.20",
62
+ "typescript": "^5.9.3",
63
+ "uuid": "^11.0.5",
64
+ "winston": "^3.17.0"
65
+ },
66
+ "peerDependencies": {
67
+ "@dataui/crud": "^5.3.4",
68
+ "@dataui/crud-request": "^5.3.4",
69
+ "@dataui/crud-typeorm": "^5.3.4",
70
+ "@nestjs/cache-manager": "^3.0.0",
71
+ "@nestjs/common": "^11.0.11",
72
+ "@nestjs/config": "^4.0.0",
73
+ "@nestjs/core": "^11.0.5",
74
+ "@nestjs/event-emitter": "^3.0.1",
75
+ "@nestjs/jwt": "^11.0.0",
76
+ "@nestjs/passport": "^11.0.5",
77
+ "@nestjs/swagger": "^11.0.3",
78
+ "@nestjs/typeorm": "^11.0.0",
79
+ "@venturialstd/core": "^1.0.16",
80
+ "bcrypt": "^5.1.1",
81
+ "cache-manager": "^6.4.0",
82
+ "class-transformer": "^0.5.1",
83
+ "class-validator": "^0.14.1",
84
+ "jwks-rsa": "^3.1.0",
85
+ "passport": "^0.7.0",
86
+ "passport-auth0": "^1.4.0",
87
+ "passport-jwt": "^4.0.1",
88
+ "passport-local": "^1.0.0",
89
+ "rxjs": "^7.8.1",
90
+ "twilio": "^5.6.1",
91
+ "typeorm": "^0.3.20",
92
+ "uuid": "^11.0.5"
93
+ },
94
+ "dependencies": {
95
+ "pg": "^8.16.3"
96
+ }
97
+ }