@fonoster/ctl 0.7.43 → 0.7.45

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 (125) hide show
  1. package/README.md +1 -1
  2. package/bin/run.js +3 -3
  3. package/dist/AuthenticatedCommand.d.ts +6 -0
  4. package/dist/AuthenticatedCommand.js +92 -0
  5. package/dist/BaseCommand.d.ts +1 -1
  6. package/dist/BaseCommand.js +1 -1
  7. package/dist/commands/apikeys/create.d.ts +10 -0
  8. package/dist/commands/apikeys/create.js +99 -0
  9. package/dist/commands/apikeys/delete.d.ts +9 -0
  10. package/dist/commands/apikeys/delete.js +87 -0
  11. package/dist/commands/apikeys/list.d.ts +9 -0
  12. package/dist/commands/apikeys/list.js +105 -0
  13. package/dist/commands/apikeys/regenerate.d.ts +9 -0
  14. package/dist/commands/apikeys/regenerate.js +91 -0
  15. package/dist/commands/applications/create.d.ts +4 -4
  16. package/dist/commands/applications/create.js +9 -18
  17. package/dist/commands/applications/delete.d.ts +5 -5
  18. package/dist/commands/applications/delete.js +11 -23
  19. package/dist/commands/applications/get.d.ts +5 -5
  20. package/dist/commands/applications/get.js +4 -17
  21. package/dist/commands/applications/list.d.ts +5 -5
  22. package/dist/commands/applications/list.js +5 -18
  23. package/dist/commands/applications/update.d.ts +5 -5
  24. package/dist/commands/applications/update.js +11 -26
  25. package/dist/commands/bug.js +1 -1
  26. package/dist/commands/feedback.js +2 -2
  27. package/dist/commands/secrets/create.d.ts +6 -0
  28. package/dist/commands/secrets/create.js +106 -0
  29. package/dist/commands/secrets/delete.d.ts +9 -0
  30. package/dist/commands/secrets/delete.js +87 -0
  31. package/dist/commands/secrets/get.d.ts +9 -0
  32. package/dist/commands/secrets/get.js +95 -0
  33. package/dist/commands/secrets/list.d.ts +9 -0
  34. package/dist/commands/secrets/list.js +99 -0
  35. package/dist/commands/secrets/update.d.ts +9 -0
  36. package/dist/commands/secrets/update.js +116 -0
  37. package/dist/commands/sipnet/acls/create.d.ts +6 -0
  38. package/dist/commands/sipnet/acls/create.js +107 -0
  39. package/dist/commands/sipnet/acls/delete.d.ts +9 -0
  40. package/dist/commands/sipnet/acls/delete.js +87 -0
  41. package/dist/commands/sipnet/acls/get.d.ts +9 -0
  42. package/dist/commands/sipnet/acls/get.js +100 -0
  43. package/dist/commands/sipnet/acls/list.d.ts +9 -0
  44. package/dist/commands/sipnet/acls/list.js +99 -0
  45. package/dist/commands/sipnet/acls/update.d.ts +9 -0
  46. package/dist/commands/sipnet/acls/update.js +123 -0
  47. package/dist/commands/sipnet/agents/create.d.ts +6 -0
  48. package/dist/commands/sipnet/agents/create.js +132 -0
  49. package/dist/commands/sipnet/agents/delete.d.ts +9 -0
  50. package/dist/commands/sipnet/agents/delete.js +87 -0
  51. package/dist/commands/sipnet/agents/get.d.ts +9 -0
  52. package/dist/commands/sipnet/agents/get.js +109 -0
  53. package/dist/commands/sipnet/agents/list.d.ts +9 -0
  54. package/dist/commands/sipnet/agents/list.js +99 -0
  55. package/dist/commands/sipnet/agents/update.d.ts +9 -0
  56. package/dist/commands/sipnet/agents/update.js +149 -0
  57. package/dist/commands/sipnet/calls/create.d.ts +13 -0
  58. package/dist/commands/sipnet/calls/create.js +156 -0
  59. package/dist/commands/sipnet/calls/get.d.ts +9 -0
  60. package/dist/commands/sipnet/calls/get.js +104 -0
  61. package/dist/commands/sipnet/calls/list.d.ts +9 -0
  62. package/dist/commands/sipnet/calls/list.js +108 -0
  63. package/dist/commands/sipnet/credentials/create.d.ts +6 -0
  64. package/dist/commands/sipnet/credentials/create.js +110 -0
  65. package/dist/commands/sipnet/credentials/delete.d.ts +9 -0
  66. package/dist/commands/sipnet/credentials/delete.js +87 -0
  67. package/dist/commands/sipnet/credentials/get.d.ts +9 -0
  68. package/dist/commands/sipnet/credentials/get.js +100 -0
  69. package/dist/commands/sipnet/credentials/list.d.ts +9 -0
  70. package/dist/commands/sipnet/credentials/list.js +99 -0
  71. package/dist/commands/sipnet/credentials/update.d.ts +9 -0
  72. package/dist/commands/sipnet/credentials/update.js +121 -0
  73. package/dist/commands/sipnet/domains/create.d.ts +6 -0
  74. package/dist/commands/sipnet/domains/create.js +107 -0
  75. package/dist/commands/sipnet/domains/delete.d.ts +9 -0
  76. package/dist/commands/sipnet/domains/delete.js +87 -0
  77. package/dist/commands/sipnet/domains/get.d.ts +9 -0
  78. package/dist/commands/sipnet/domains/get.js +100 -0
  79. package/dist/commands/sipnet/domains/list.d.ts +9 -0
  80. package/dist/commands/sipnet/domains/list.js +99 -0
  81. package/dist/commands/sipnet/domains/update.d.ts +9 -0
  82. package/dist/commands/sipnet/domains/update.js +118 -0
  83. package/dist/commands/sipnet/numbers/create.d.ts +6 -0
  84. package/dist/commands/sipnet/numbers/create.js +148 -0
  85. package/dist/commands/sipnet/numbers/delete.d.ts +9 -0
  86. package/dist/commands/sipnet/numbers/delete.js +87 -0
  87. package/dist/commands/sipnet/numbers/get.d.ts +9 -0
  88. package/dist/commands/{numbers → sipnet/numbers}/get.js +7 -13
  89. package/dist/commands/sipnet/numbers/linkTwilioNumber.d.ts +10 -0
  90. package/dist/commands/{numbers → sipnet/numbers}/linkTwilioNumber.js +12 -17
  91. package/dist/commands/sipnet/numbers/list.d.ts +9 -0
  92. package/dist/commands/{numbers → sipnet/numbers}/list.js +9 -14
  93. package/dist/commands/sipnet/numbers/update.d.ts +9 -0
  94. package/dist/commands/sipnet/numbers/update.js +136 -0
  95. package/dist/commands/sipnet/trunks/create.d.ts +6 -0
  96. package/dist/commands/sipnet/trunks/create.js +156 -0
  97. package/dist/commands/sipnet/trunks/delete.d.ts +9 -0
  98. package/dist/commands/sipnet/trunks/delete.js +87 -0
  99. package/dist/commands/sipnet/trunks/get.d.ts +9 -0
  100. package/dist/commands/sipnet/trunks/get.js +120 -0
  101. package/dist/commands/sipnet/trunks/list.d.ts +9 -0
  102. package/dist/commands/sipnet/trunks/list.js +99 -0
  103. package/dist/commands/sipnet/trunks/update.d.ts +9 -0
  104. package/dist/commands/sipnet/trunks/update.js +174 -0
  105. package/dist/commands/workspaces/current.js +1 -1
  106. package/dist/commands/workspaces/list.js +1 -1
  107. package/dist/commands/workspaces/login.js +2 -2
  108. package/dist/commands/workspaces/logout.d.ts +3 -3
  109. package/dist/commands/workspaces/logout.js +7 -6
  110. package/dist/commands/workspaces/use.d.ts +3 -3
  111. package/dist/commands/workspaces/use.js +8 -8
  112. package/dist/config/getCurrentWorkspace.d.ts +1 -1
  113. package/dist/config/getCurrentWorkspace.js +1 -5
  114. package/dist/errorHandler.d.ts +2 -0
  115. package/dist/errorHandler.js +31 -0
  116. package/dist/utils/calculateFutureDate.d.ts +2 -0
  117. package/dist/utils/calculateFutureDate.js +37 -0
  118. package/dist/utils/getOutboundUri.d.ts +7 -0
  119. package/dist/utils/getOutboundUri.js +10 -0
  120. package/dist/utils/index.d.ts +1 -0
  121. package/dist/utils/index.js +1 -0
  122. package/package.json +6 -7
  123. package/dist/commands/numbers/get.d.ts +0 -9
  124. package/dist/commands/numbers/linkTwilioNumber.d.ts +0 -10
  125. package/dist/commands/numbers/list.d.ts +0 -9
@@ -0,0 +1,149 @@
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
+ /* eslint-disable import/no-unresolved */
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 SDK = __importStar(require("@fonoster/sdk"));
68
+ const prompts_1 = require("@inquirer/prompts");
69
+ const AuthenticatedCommand_1 = require("../../../AuthenticatedCommand");
70
+ const errorHandler_1 = __importDefault(require("../../../errorHandler"));
71
+ const core_1 = require("@oclif/core");
72
+ class Update extends AuthenticatedCommand_1.AuthenticatedCommand {
73
+ run() {
74
+ return __awaiter(this, void 0, void 0, function* () {
75
+ var _a, _b;
76
+ this.log("This utility will help you add a new SIP Agent to the network.");
77
+ this.log("Press ^C at any time to quit.");
78
+ const { args } = yield this.parse(Update);
79
+ const { ref } = args;
80
+ const client = yield this.createSdkClient();
81
+ const agents = new SDK.Agents(client);
82
+ const domains = new SDK.Domains(client);
83
+ const credentials = new SDK.Credentials(client);
84
+ const agentFromDB = yield agents.getAgent(ref);
85
+ if (!agentFromDB) {
86
+ this.error("Agent not found.");
87
+ }
88
+ const domainsList = (yield domains.listDomains({ pageSize: 1000 })).items.map((d) => ({ name: d.name, value: d.ref }));
89
+ const credentialsList = (yield credentials.listCredentials({ pageSize: 1000 })).items.map((c) => ({ name: c.name, value: c.ref }));
90
+ const answers = {
91
+ ref,
92
+ name: yield (0, prompts_1.input)({
93
+ message: "Name",
94
+ required: true,
95
+ default: agentFromDB.name
96
+ }),
97
+ domainRef: yield (0, prompts_1.select)({
98
+ message: "Domain",
99
+ choices: [{ name: "None", value: null }].concat(domainsList),
100
+ default: (_a = agentFromDB.domain) === null || _a === void 0 ? void 0 : _a.ref
101
+ }),
102
+ credentialsRef: yield (0, prompts_1.select)({
103
+ message: "Credentials",
104
+ choices: [{ name: "None", value: null }].concat(credentialsList),
105
+ default: (_b = agentFromDB.credentials) === null || _b === void 0 ? void 0 : _b.ref
106
+ }),
107
+ privacy: yield (0, prompts_1.select)({
108
+ message: "Privacy",
109
+ choices: [
110
+ { name: "Private", value: "PRIVATE" },
111
+ { name: "None", value: "NONE" }
112
+ ],
113
+ default: agentFromDB.privacy === "ID" ? "PRIVATE" : "NONE"
114
+ }),
115
+ enabled: yield (0, prompts_1.confirm)({
116
+ message: "Enabled?",
117
+ default: agentFromDB.enabled
118
+ }),
119
+ maxContacts: yield (0, prompts_1.number)({
120
+ message: "Max Contacts",
121
+ default: agentFromDB.maxContacts
122
+ }),
123
+ confirm: yield (0, prompts_1.confirm)({
124
+ message: "Ready?"
125
+ })
126
+ };
127
+ if (!answers.confirm) {
128
+ this.log("Aborted!");
129
+ return;
130
+ }
131
+ try {
132
+ yield agents.updateAgent(answers);
133
+ this.log("Done!");
134
+ }
135
+ catch (e) {
136
+ (0, errorHandler_1.default)(e, this.error.bind(this));
137
+ }
138
+ });
139
+ }
140
+ }
141
+ Update.description = "add a new SIP Agent to the network";
142
+ Update.examples = ["<%= config.bin %> <%= command.id %>"];
143
+ Update.args = {
144
+ ref: core_1.Args.string({
145
+ description: "the ACL reference",
146
+ required: true
147
+ })
148
+ };
149
+ exports.default = Update;
@@ -0,0 +1,13 @@
1
+ import { AuthenticatedCommand } from "../../../AuthenticatedCommand";
2
+ export default class Create extends AuthenticatedCommand<typeof Create> {
3
+ static readonly description = "initiate a call to a phone number or SIP URI";
4
+ static readonly examples: string[];
5
+ static readonly flags: {
6
+ "from-number": import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
7
+ "to-number": import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
8
+ "app-ref": import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
9
+ timeout: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
10
+ "track-call": import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
11
+ };
12
+ run(): Promise<void>;
13
+ }
@@ -0,0 +1,156 @@
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 __asyncValues = (this && this.__asyncValues) || function (o) {
45
+ if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
46
+ var m = o[Symbol.asyncIterator], i;
47
+ return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
48
+ function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
49
+ function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
50
+ };
51
+ var __importDefault = (this && this.__importDefault) || function (mod) {
52
+ return (mod && mod.__esModule) ? mod : { "default": mod };
53
+ };
54
+ Object.defineProperty(exports, "__esModule", { value: true });
55
+ /* eslint-disable import/no-unresolved */
56
+ /*
57
+ * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com)
58
+ * http://github.com/fonoster/fonoster
59
+ *
60
+ * This file is part of Fonoster
61
+ *
62
+ * Licensed under the MIT License (the "License");
63
+ * you may not use this file except in compliance with
64
+ * the License. You may obtain a copy of the License at
65
+ *
66
+ * https://opensource.org/licenses/MIT
67
+ *
68
+ * Unless required by applicable law or agreed to in writing, software
69
+ * distributed under the License is distributed on an "AS IS" BASIS,
70
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
71
+ * See the License for the specific language governing permissions and
72
+ * limitations under the License.
73
+ */
74
+ const SDK = __importStar(require("@fonoster/sdk"));
75
+ const AuthenticatedCommand_1 = require("../../../AuthenticatedCommand");
76
+ const errorHandler_1 = __importDefault(require("../../../errorHandler"));
77
+ const core_1 = require("@oclif/core");
78
+ const common_1 = require("@fonoster/common");
79
+ class Create extends AuthenticatedCommand_1.AuthenticatedCommand {
80
+ run() {
81
+ return __awaiter(this, void 0, void 0, function* () {
82
+ var _a, e_1, _b, _c;
83
+ try {
84
+ const client = yield this.createSdkClient();
85
+ const calls = new SDK.Calls(client);
86
+ const callRequest = {
87
+ from: this.flags["from-number"],
88
+ to: this.flags["to-number"],
89
+ appRef: this.flags["app-ref"],
90
+ timeout: parseInt(this.flags.timeout || "30")
91
+ };
92
+ const response = yield calls.createCall(callRequest);
93
+ this.log(`Call created: ${response.ref}`);
94
+ if (this.flags["track-call"]) {
95
+ try {
96
+ for (var _d = true, _e = __asyncValues(response.statusStream), _f; _f = yield _e.next(), _a = _f.done, !_a; _d = true) {
97
+ _c = _f.value;
98
+ _d = false;
99
+ const entry = _c;
100
+ this.log(`Call status: ${entry.status}`);
101
+ if (entry.status === common_1.DialStatus.ANSWER) {
102
+ break;
103
+ }
104
+ }
105
+ }
106
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
107
+ finally {
108
+ try {
109
+ if (!_d && !_a && (_b = _e.return)) yield _b.call(_e);
110
+ }
111
+ finally { if (e_1) throw e_1.error; }
112
+ }
113
+ this.log("Call ended.");
114
+ process.exit(0);
115
+ return;
116
+ }
117
+ process.exit(0);
118
+ }
119
+ catch (e) {
120
+ (0, errorHandler_1.default)(e, this.error.bind(this));
121
+ }
122
+ });
123
+ }
124
+ }
125
+ Create.description = "initiate a call to a phone number or SIP URI";
126
+ Create.examples = ["<%= config.bin %> <%= command.id %>"];
127
+ Create.flags = {
128
+ "from-number": core_1.Flags.string({
129
+ char: "f",
130
+ description: "The number to make the call from",
131
+ required: true
132
+ }),
133
+ "to-number": core_1.Flags.string({
134
+ char: "t",
135
+ description: "The number to make the call to",
136
+ required: true
137
+ }),
138
+ "app-ref": core_1.Flags.string({
139
+ char: "a",
140
+ description: "The application reference",
141
+ required: true
142
+ }),
143
+ timeout: core_1.Flags.string({
144
+ char: "o",
145
+ description: "The call timeout",
146
+ default: "30",
147
+ required: false
148
+ }),
149
+ "track-call": core_1.Flags.boolean({
150
+ char: "c",
151
+ description: "Track the call",
152
+ default: false,
153
+ required: false
154
+ })
155
+ };
156
+ exports.default = Create;
@@ -0,0 +1,9 @@
1
+ import { AuthenticatedCommand } from "../../../AuthenticatedCommand";
2
+ export default class Get extends AuthenticatedCommand<typeof Get> {
3
+ static readonly description = "get a specific Access Control List (ACL)";
4
+ static readonly examples: string[];
5
+ static readonly args: {
6
+ ref: import("@oclif/core/lib/interfaces").Arg<string, Record<string, unknown>>;
7
+ };
8
+ run(): Promise<void>;
9
+ }
@@ -0,0 +1,104 @@
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
+ /* eslint-disable import/no-unresolved */
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 SDK = __importStar(require("@fonoster/sdk"));
68
+ const core_1 = require("@oclif/core");
69
+ const cliui_1 = __importDefault(require("cliui"));
70
+ const moment_1 = __importDefault(require("moment"));
71
+ const AuthenticatedCommand_1 = require("../../../AuthenticatedCommand");
72
+ class Get extends AuthenticatedCommand_1.AuthenticatedCommand {
73
+ run() {
74
+ return __awaiter(this, void 0, void 0, function* () {
75
+ const { args } = yield this.parse(Get);
76
+ const { ref } = args;
77
+ const client = yield this.createSdkClient();
78
+ const calls = new SDK.Calls(client);
79
+ const response = yield calls.getCall(ref);
80
+ const ui = (0, cliui_1.default)({ width: 200 });
81
+ ui.div("CALL DETAILS\n" +
82
+ "------------------\n" +
83
+ `CALL ID: \t${response.callId}\n` +
84
+ `TYPE: \t${response.type}\n` +
85
+ `STATUS: \t${response.status}\n` +
86
+ `FROM: \t${response.from}\n` +
87
+ `TO: \t${response.to}\n` +
88
+ `DURATION: \t${response.duration}\n` +
89
+ `DIRECTION: \t${response.direction}\n` +
90
+ `STARTED: \t${(0, moment_1.default)(response.startedAt).format("YYYY-MM-DD HH:mm:ss")}\n` +
91
+ `ENDED: \t${(0, moment_1.default)(response.endedAt).format("YYYY-MM-DD HH:mm:ss")}`);
92
+ this.log(ui.toString());
93
+ });
94
+ }
95
+ }
96
+ Get.description = "get a specific Access Control List (ACL)";
97
+ Get.examples = ["<%= config.bin %> <%= command.id %>"];
98
+ Get.args = {
99
+ ref: core_1.Args.string({
100
+ description: "The ACL reference",
101
+ required: true
102
+ })
103
+ };
104
+ exports.default = Get;
@@ -0,0 +1,9 @@
1
+ import { AuthenticatedCommand } from "../../../AuthenticatedCommand";
2
+ export default class List extends AuthenticatedCommand<typeof List> {
3
+ static readonly description = "display all calls made in the active Workspace";
4
+ static readonly examples: string[];
5
+ static readonly flags: {
6
+ "page-size": import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
7
+ };
8
+ run(): Promise<void>;
9
+ }
@@ -0,0 +1,108 @@
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
+ /* eslint-disable import/no-unresolved */
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 SDK = __importStar(require("@fonoster/sdk"));
68
+ const core_1 = require("@oclif/core");
69
+ const cliui_1 = __importDefault(require("cliui"));
70
+ const AuthenticatedCommand_1 = require("../../../AuthenticatedCommand");
71
+ const moment_1 = __importDefault(require("moment"));
72
+ class List extends AuthenticatedCommand_1.AuthenticatedCommand {
73
+ run() {
74
+ return __awaiter(this, void 0, void 0, function* () {
75
+ const { flags } = yield this.parse(List);
76
+ const client = yield this.createSdkClient();
77
+ const calls = new SDK.Calls(client);
78
+ const response = yield calls.listCalls({
79
+ pageSize: parseInt(flags["page-size"])
80
+ });
81
+ const ui = (0, cliui_1.default)({ width: 100 });
82
+ ui.div({ text: "CALL ID", padding: [0, 0, 0, 0], width: 25 }, { text: "STARTED AT", padding: [0, 0, 0, 0], width: 25 }, { text: "ENDED AT", padding: [0, 0, 0, 0], width: 25 }, { text: "FROM", padding: [0, 0, 0, 0], width: 30 }, { text: "TO", padding: [0, 0, 0, 0], width: 30 }, { text: "DURATION", padding: [0, 0, 0, 0], width: 10 });
83
+ response.items.forEach((call) => {
84
+ ui.div({ text: call.callId, padding: [0, 0, 0, 0], width: 25 }, {
85
+ text: (0, moment_1.default)(call.startedAt).format("YYYY-MM-DD HH:mm:ss"),
86
+ padding: [0, 0, 0, 0],
87
+ width: 25
88
+ }, {
89
+ text: (0, moment_1.default)(call.endedAt).format("YYYY-MM-DD HH:mm:ss"),
90
+ padding: [0, 0, 0, 0],
91
+ width: 25
92
+ }, { text: call.from, padding: [0, 0, 0, 0], width: 30 }, { text: call.to, padding: [0, 0, 0, 0], width: 30 }, { text: call.duration + "", padding: [0, 0, 0, 0], width: 10 });
93
+ });
94
+ this.log(ui.toString());
95
+ });
96
+ }
97
+ }
98
+ List.description = "display all calls made in the active Workspace";
99
+ List.examples = ["<%= config.bin %> <%= command.id %>"];
100
+ List.flags = {
101
+ "page-size": core_1.Flags.string({
102
+ char: "s",
103
+ description: "the number of items to show",
104
+ default: "1000",
105
+ required: false
106
+ })
107
+ };
108
+ exports.default = List;
@@ -0,0 +1,6 @@
1
+ import { AuthenticatedCommand } from "../../../AuthenticatedCommand";
2
+ export default class Create extends AuthenticatedCommand<typeof Create> {
3
+ static readonly description = "add a new set of Credentials to the network";
4
+ static readonly examples: string[];
5
+ run(): Promise<void>;
6
+ }
@@ -0,0 +1,110 @@
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
+ /* eslint-disable import/no-unresolved */
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 SDK = __importStar(require("@fonoster/sdk"));
68
+ const prompts_1 = require("@inquirer/prompts");
69
+ const AuthenticatedCommand_1 = require("../../../AuthenticatedCommand");
70
+ const errorHandler_1 = __importDefault(require("../../../errorHandler"));
71
+ class Create extends AuthenticatedCommand_1.AuthenticatedCommand {
72
+ run() {
73
+ return __awaiter(this, void 0, void 0, function* () {
74
+ this.log("This utility will help you add a new set of Credentials to the network.");
75
+ this.log("Press ^C at any time to quit.");
76
+ const answers = {
77
+ name: yield (0, prompts_1.input)({
78
+ message: "Name",
79
+ required: true
80
+ }),
81
+ username: yield (0, prompts_1.input)({
82
+ message: "Username",
83
+ required: true
84
+ }),
85
+ password: yield (0, prompts_1.password)({
86
+ message: "Password"
87
+ }),
88
+ confirm: yield (0, prompts_1.confirm)({
89
+ message: "Ready?"
90
+ })
91
+ };
92
+ if (!answers.confirm) {
93
+ this.log("Aborted!");
94
+ return;
95
+ }
96
+ try {
97
+ const client = yield this.createSdkClient();
98
+ const credentials = new SDK.Credentials(client);
99
+ yield credentials.createCredentials(answers);
100
+ this.log("Done!");
101
+ }
102
+ catch (e) {
103
+ (0, errorHandler_1.default)(e, this.error.bind(this));
104
+ }
105
+ });
106
+ }
107
+ }
108
+ Create.description = "add a new set of Credentials to the network";
109
+ Create.examples = ["<%= config.bin %> <%= command.id %>"];
110
+ exports.default = Create;