@fonoster/ctl 0.7.42 → 0.7.44

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.
Files changed (75) hide show
  1. package/README.md +8 -410
  2. package/bin/run.js +21 -3
  3. package/package.json +6 -7
  4. package/dist/BaseCommand.d.ts +0 -15
  5. package/dist/BaseCommand.js +0 -80
  6. package/dist/Help.d.ts +0 -6
  7. package/dist/Help.js +0 -52
  8. package/dist/commands/applications/create.d.ts +0 -6
  9. package/dist/commands/applications/create.js +0 -164
  10. package/dist/commands/applications/delete.d.ts +0 -9
  11. package/dist/commands/applications/delete.js +0 -99
  12. package/dist/commands/applications/get.d.ts +0 -9
  13. package/dist/commands/applications/get.js +0 -120
  14. package/dist/commands/applications/list.d.ts +0 -9
  15. package/dist/commands/applications/list.js +0 -112
  16. package/dist/commands/applications/update.d.ts +0 -9
  17. package/dist/commands/applications/update.js +0 -187
  18. package/dist/commands/bug.d.ts +0 -6
  19. package/dist/commands/bug.js +0 -42
  20. package/dist/commands/feedback.d.ts +0 -6
  21. package/dist/commands/feedback.js +0 -45
  22. package/dist/commands/numbers/get.d.ts +0 -9
  23. package/dist/commands/numbers/get.js +0 -125
  24. package/dist/commands/numbers/linkTwilioNumber.d.ts +0 -10
  25. package/dist/commands/numbers/linkTwilioNumber.js +0 -155
  26. package/dist/commands/numbers/list.d.ts +0 -9
  27. package/dist/commands/numbers/list.js +0 -116
  28. package/dist/commands/workspaces/current.d.ts +0 -6
  29. package/dist/commands/workspaces/current.js +0 -46
  30. package/dist/commands/workspaces/list.d.ts +0 -6
  31. package/dist/commands/workspaces/list.js +0 -53
  32. package/dist/commands/workspaces/login.d.ts +0 -8
  33. package/dist/commands/workspaces/login.js +0 -145
  34. package/dist/commands/workspaces/logout.d.ts +0 -9
  35. package/dist/commands/workspaces/logout.js +0 -54
  36. package/dist/commands/workspaces/use.d.ts +0 -9
  37. package/dist/commands/workspaces/use.js +0 -57
  38. package/dist/config/addWorkspace.d.ts +0 -3
  39. package/dist/config/addWorkspace.js +0 -15
  40. package/dist/config/getConfig.d.ts +0 -3
  41. package/dist/config/getConfig.js +0 -34
  42. package/dist/config/getCurrentWorkspace.d.ts +0 -3
  43. package/dist/config/getCurrentWorkspace.js +0 -10
  44. package/dist/config/index.d.ts +0 -7
  45. package/dist/config/index.js +0 -41
  46. package/dist/config/removeWorkspace.d.ts +0 -3
  47. package/dist/config/removeWorkspace.js +0 -6
  48. package/dist/config/saveConfig.d.ts +0 -3
  49. package/dist/config/saveConfig.js +0 -32
  50. package/dist/config/setCurrentWorkspace.d.ts +0 -3
  51. package/dist/config/setCurrentWorkspace.js +0 -11
  52. package/dist/config/types.d.ts +0 -4
  53. package/dist/config/types.js +0 -2
  54. package/dist/config/validations.d.ts +0 -27
  55. package/dist/config/validations.js +0 -34
  56. package/dist/constants.d.ts +0 -6
  57. package/dist/constants.js +0 -29
  58. package/dist/utils/assignTwilioNumberToTrunk.d.ts +0 -3
  59. package/dist/utils/assignTwilioNumberToTrunk.js +0 -33
  60. package/dist/utils/createTwilioTrunk.d.ts +0 -4
  61. package/dist/utils/createTwilioTrunk.js +0 -54
  62. package/dist/utils/getFonosterNumberByTelUrl.d.ts +0 -4
  63. package/dist/utils/getFonosterNumberByTelUrl.js +0 -76
  64. package/dist/utils/getFonosterTrunkByInboundUri.d.ts +0 -4
  65. package/dist/utils/getFonosterTrunkByInboundUri.js +0 -76
  66. package/dist/utils/getTwilioNumber.d.ts +0 -4
  67. package/dist/utils/getTwilioNumber.js +0 -23
  68. package/dist/utils/getTwilioTrunk.d.ts +0 -4
  69. package/dist/utils/getTwilioTrunk.js +0 -23
  70. package/dist/utils/index.d.ts +0 -8
  71. package/dist/utils/index.js +0 -42
  72. package/dist/utils/linkTwilioNumberToApplication.d.ts +0 -5
  73. package/dist/utils/linkTwilioNumberToApplication.js +0 -128
  74. package/dist/utils/types.d.ts +0 -14
  75. package/dist/utils/types.js +0 -2
@@ -1,128 +0,0 @@
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
36
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
37
- return new (P || (P = Promise))(function (resolve, reject) {
38
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
39
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
40
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
41
- step((generator = generator.apply(thisArg, _arguments || [])).next());
42
- });
43
- };
44
- var __importDefault = (this && this.__importDefault) || function (mod) {
45
- return (mod && mod.__esModule) ? mod : { "default": mod };
46
- };
47
- Object.defineProperty(exports, "__esModule", { value: true });
48
- exports.linkTwilioNumberToApplication = linkTwilioNumberToApplication;
49
- /*
50
- * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com)
51
- * http://github.com/fonoster/fonoster
52
- *
53
- * This file is part of Fonoster
54
- *
55
- * Licensed under the MIT License (the "License");
56
- * you may not use this file except in compliance with
57
- * the License. You may obtain a copy of the License at
58
- *
59
- * https://opensource.org/licenses/MIT
60
- *
61
- * Unless required by applicable law or agreed to in writing, software
62
- * distributed under the License is distributed on an "AS IS" BASIS,
63
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
64
- * See the License for the specific language governing permissions and
65
- * limitations under the License.
66
- */
67
- const Fonoster = __importStar(require("@fonoster/sdk"));
68
- const phone_1 = __importDefault(require("phone"));
69
- const constants_1 = require("../constants");
70
- const _1 = require(".");
71
- function linkTwilioNumberToApplication(twilioClient, fonosterClient, params) {
72
- return __awaiter(this, void 0, void 0, function* () {
73
- const { applicationRef, accessKeyId, aclEntries, originationUriBase, phoneNumber, friendlyName } = params;
74
- const resourceRef = accessKeyId.toLowerCase();
75
- const twilioNumber = yield (0, _1.getTwilioNumber)(twilioClient, phoneNumber);
76
- let twilioTrunk = yield (0, _1.getTwilioTrunk)(twilioClient, `${resourceRef}.${constants_1.TWILIO_PSTN_URI_BASE}`);
77
- const fonosterTrunk = yield (0, _1.getFonosterTrunkByInboundUri)(fonosterClient, `${resourceRef}.${originationUriBase}`);
78
- const fonosterNumber = yield (0, _1.getFonosterNumberByTelUrl)(fonosterClient, `tel:${phoneNumber}`);
79
- if (!twilioNumber) {
80
- throw Error(`The number ${phoneNumber} was not found in your account.`);
81
- }
82
- if (!twilioTrunk) {
83
- yield (0, _1.createTwilioTrunk)(twilioClient, {
84
- resourceRef,
85
- aclEntries,
86
- originationUriBase
87
- });
88
- twilioTrunk = yield (0, _1.getTwilioTrunk)(twilioClient, `${resourceRef}.${constants_1.TWILIO_PSTN_URI_BASE}`);
89
- }
90
- yield (0, _1.assignTwilioNumberToTrunk)(twilioClient, phoneNumber, twilioTrunk.sid);
91
- let trunkRef = fonosterTrunk === null || fonosterTrunk === void 0 ? void 0 : fonosterTrunk.ref;
92
- if (!fonosterTrunk) {
93
- const trunks = new Fonoster.Trunks(fonosterClient);
94
- const response = yield trunks.createTrunk({
95
- name: "Twilio Trunk",
96
- inboundUri: `${resourceRef}.${originationUriBase}`,
97
- sendRegister: true,
98
- uris: [
99
- {
100
- host: `${resourceRef}.${constants_1.TWILIO_PSTN_URI_BASE}`,
101
- port: 5060,
102
- transport: "TCP",
103
- enabled: true,
104
- weight: 10,
105
- priority: 10,
106
- user: ""
107
- }
108
- ]
109
- });
110
- trunkRef = response.ref;
111
- }
112
- if (fonosterNumber) {
113
- const numbers = new Fonoster.Numbers(fonosterClient);
114
- yield numbers.deleteNumber(fonosterNumber.ref);
115
- }
116
- const numbers = new Fonoster.Numbers(fonosterClient);
117
- const phoneInfo = (0, phone_1.default)(phoneNumber);
118
- yield numbers.createNumber({
119
- name: friendlyName !== null && friendlyName !== void 0 ? friendlyName : phoneNumber,
120
- telUrl: `tel:${phoneNumber}`,
121
- appRef: applicationRef,
122
- trunkRef,
123
- city: "unknown",
124
- country: phoneInfo.countryIso3,
125
- countryIsoCode: phoneInfo.countryIso2
126
- });
127
- });
128
- }
@@ -1,14 +0,0 @@
1
- type LinkTwilioNumberToApplicationParams = {
2
- phoneNumber: string;
3
- accessKeyId: string;
4
- aclEntries: string[];
5
- originationUriBase: string;
6
- applicationRef: string;
7
- friendlyName?: string;
8
- };
9
- type TwilioTrunkParams = {
10
- resourceRef: string;
11
- originationUriBase: string;
12
- aclEntries: string[];
13
- };
14
- export { LinkTwilioNumberToApplicationParams, TwilioTrunkParams };
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });