@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.
- package/README.md +1 -1
- package/bin/run.js +3 -3
- package/dist/AuthenticatedCommand.d.ts +6 -0
- package/dist/AuthenticatedCommand.js +92 -0
- package/dist/BaseCommand.d.ts +1 -1
- package/dist/BaseCommand.js +1 -1
- package/dist/commands/apikeys/create.d.ts +10 -0
- package/dist/commands/apikeys/create.js +99 -0
- package/dist/commands/apikeys/delete.d.ts +9 -0
- package/dist/commands/apikeys/delete.js +87 -0
- package/dist/commands/apikeys/list.d.ts +9 -0
- package/dist/commands/apikeys/list.js +105 -0
- package/dist/commands/apikeys/regenerate.d.ts +9 -0
- package/dist/commands/apikeys/regenerate.js +91 -0
- package/dist/commands/applications/create.d.ts +4 -4
- package/dist/commands/applications/create.js +9 -18
- package/dist/commands/applications/delete.d.ts +5 -5
- package/dist/commands/applications/delete.js +11 -23
- package/dist/commands/applications/get.d.ts +5 -5
- package/dist/commands/applications/get.js +4 -17
- package/dist/commands/applications/list.d.ts +5 -5
- package/dist/commands/applications/list.js +5 -18
- package/dist/commands/applications/update.d.ts +5 -5
- package/dist/commands/applications/update.js +11 -26
- package/dist/commands/bug.js +1 -1
- package/dist/commands/feedback.js +2 -2
- package/dist/commands/secrets/create.d.ts +6 -0
- package/dist/commands/secrets/create.js +106 -0
- package/dist/commands/secrets/delete.d.ts +9 -0
- package/dist/commands/secrets/delete.js +87 -0
- package/dist/commands/secrets/get.d.ts +9 -0
- package/dist/commands/secrets/get.js +95 -0
- package/dist/commands/secrets/list.d.ts +9 -0
- package/dist/commands/secrets/list.js +99 -0
- package/dist/commands/secrets/update.d.ts +9 -0
- package/dist/commands/secrets/update.js +116 -0
- package/dist/commands/sipnet/acls/create.d.ts +6 -0
- package/dist/commands/sipnet/acls/create.js +107 -0
- package/dist/commands/sipnet/acls/delete.d.ts +9 -0
- package/dist/commands/sipnet/acls/delete.js +87 -0
- package/dist/commands/sipnet/acls/get.d.ts +9 -0
- package/dist/commands/sipnet/acls/get.js +100 -0
- package/dist/commands/sipnet/acls/list.d.ts +9 -0
- package/dist/commands/sipnet/acls/list.js +99 -0
- package/dist/commands/sipnet/acls/update.d.ts +9 -0
- package/dist/commands/sipnet/acls/update.js +123 -0
- package/dist/commands/sipnet/agents/create.d.ts +6 -0
- package/dist/commands/sipnet/agents/create.js +132 -0
- package/dist/commands/sipnet/agents/delete.d.ts +9 -0
- package/dist/commands/sipnet/agents/delete.js +87 -0
- package/dist/commands/sipnet/agents/get.d.ts +9 -0
- package/dist/commands/sipnet/agents/get.js +109 -0
- package/dist/commands/sipnet/agents/list.d.ts +9 -0
- package/dist/commands/sipnet/agents/list.js +99 -0
- package/dist/commands/sipnet/agents/update.d.ts +9 -0
- package/dist/commands/sipnet/agents/update.js +149 -0
- package/dist/commands/sipnet/calls/create.d.ts +13 -0
- package/dist/commands/sipnet/calls/create.js +156 -0
- package/dist/commands/sipnet/calls/get.d.ts +9 -0
- package/dist/commands/sipnet/calls/get.js +104 -0
- package/dist/commands/sipnet/calls/list.d.ts +9 -0
- package/dist/commands/sipnet/calls/list.js +108 -0
- package/dist/commands/sipnet/credentials/create.d.ts +6 -0
- package/dist/commands/sipnet/credentials/create.js +110 -0
- package/dist/commands/sipnet/credentials/delete.d.ts +9 -0
- package/dist/commands/sipnet/credentials/delete.js +87 -0
- package/dist/commands/sipnet/credentials/get.d.ts +9 -0
- package/dist/commands/sipnet/credentials/get.js +100 -0
- package/dist/commands/sipnet/credentials/list.d.ts +9 -0
- package/dist/commands/sipnet/credentials/list.js +99 -0
- package/dist/commands/sipnet/credentials/update.d.ts +9 -0
- package/dist/commands/sipnet/credentials/update.js +121 -0
- package/dist/commands/sipnet/domains/create.d.ts +6 -0
- package/dist/commands/sipnet/domains/create.js +107 -0
- package/dist/commands/sipnet/domains/delete.d.ts +9 -0
- package/dist/commands/sipnet/domains/delete.js +87 -0
- package/dist/commands/sipnet/domains/get.d.ts +9 -0
- package/dist/commands/sipnet/domains/get.js +100 -0
- package/dist/commands/sipnet/domains/list.d.ts +9 -0
- package/dist/commands/sipnet/domains/list.js +99 -0
- package/dist/commands/sipnet/domains/update.d.ts +9 -0
- package/dist/commands/sipnet/domains/update.js +118 -0
- package/dist/commands/sipnet/numbers/create.d.ts +6 -0
- package/dist/commands/sipnet/numbers/create.js +148 -0
- package/dist/commands/sipnet/numbers/delete.d.ts +9 -0
- package/dist/commands/sipnet/numbers/delete.js +87 -0
- package/dist/commands/sipnet/numbers/get.d.ts +9 -0
- package/dist/commands/{numbers → sipnet/numbers}/get.js +7 -13
- package/dist/commands/sipnet/numbers/linkTwilioNumber.d.ts +10 -0
- package/dist/commands/{numbers → sipnet/numbers}/linkTwilioNumber.js +12 -17
- package/dist/commands/sipnet/numbers/list.d.ts +9 -0
- package/dist/commands/{numbers → sipnet/numbers}/list.js +9 -14
- package/dist/commands/sipnet/numbers/update.d.ts +9 -0
- package/dist/commands/sipnet/numbers/update.js +136 -0
- package/dist/commands/sipnet/trunks/create.d.ts +6 -0
- package/dist/commands/sipnet/trunks/create.js +156 -0
- package/dist/commands/sipnet/trunks/delete.d.ts +9 -0
- package/dist/commands/sipnet/trunks/delete.js +87 -0
- package/dist/commands/sipnet/trunks/get.d.ts +9 -0
- package/dist/commands/sipnet/trunks/get.js +120 -0
- package/dist/commands/sipnet/trunks/list.d.ts +9 -0
- package/dist/commands/sipnet/trunks/list.js +99 -0
- package/dist/commands/sipnet/trunks/update.d.ts +9 -0
- package/dist/commands/sipnet/trunks/update.js +174 -0
- package/dist/commands/workspaces/current.js +1 -1
- package/dist/commands/workspaces/list.js +1 -1
- package/dist/commands/workspaces/login.js +2 -2
- package/dist/commands/workspaces/logout.d.ts +3 -3
- package/dist/commands/workspaces/logout.js +7 -6
- package/dist/commands/workspaces/use.d.ts +3 -3
- package/dist/commands/workspaces/use.js +8 -8
- package/dist/config/getCurrentWorkspace.d.ts +1 -1
- package/dist/config/getCurrentWorkspace.js +1 -5
- package/dist/errorHandler.d.ts +2 -0
- package/dist/errorHandler.js +31 -0
- package/dist/utils/calculateFutureDate.d.ts +2 -0
- package/dist/utils/calculateFutureDate.js +37 -0
- package/dist/utils/getOutboundUri.d.ts +7 -0
- package/dist/utils/getOutboundUri.js +10 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +1 -0
- package/package.json +6 -7
- package/dist/commands/numbers/get.d.ts +0 -9
- package/dist/commands/numbers/linkTwilioNumber.d.ts +0 -10
- package/dist/commands/numbers/list.d.ts +0 -9
|
@@ -0,0 +1,120 @@
|
|
|
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
|
+
const getOutboundUri_1 = require("../../../utils/getOutboundUri");
|
|
73
|
+
class Get extends AuthenticatedCommand_1.AuthenticatedCommand {
|
|
74
|
+
run() {
|
|
75
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
76
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
77
|
+
const { args } = yield this.parse(Get);
|
|
78
|
+
const { ref } = args;
|
|
79
|
+
const client = yield this.createSdkClient();
|
|
80
|
+
const trunks = new SDK.Trunks(client);
|
|
81
|
+
const credentials = new SDK.Credentials(client);
|
|
82
|
+
const acls = new SDK.Acls(client);
|
|
83
|
+
const response = yield trunks.getTrunk(ref);
|
|
84
|
+
const credentialsList = yield credentials.listCredentials({
|
|
85
|
+
pageSize: 1000
|
|
86
|
+
});
|
|
87
|
+
const aclList = yield acls.listAcls({
|
|
88
|
+
pageSize: 1000
|
|
89
|
+
});
|
|
90
|
+
const inboundCredentialsObject = credentialsList.items.find((item) => item.ref === response.inboundCredentialsRef);
|
|
91
|
+
const outboundCredentialsObject = credentialsList.items.find((item) => item.ref === response.outboundCredentialsRef);
|
|
92
|
+
const acl = aclList.items.find((item) => item.ref === response.accessControlListRef);
|
|
93
|
+
const ui = (0, cliui_1.default)({ width: 200 });
|
|
94
|
+
ui.div("TRUNK DETAILS\n" +
|
|
95
|
+
"------------------\n" +
|
|
96
|
+
`NAME: \t${response.name}\n` +
|
|
97
|
+
`REF: \t${response.ref}\n` +
|
|
98
|
+
`INBOUND URI: \t${(_a = response.inboundUri) !== null && _a !== void 0 ? _a : ""}\n` +
|
|
99
|
+
`INBOUND CREDENTIALS: \t${(_b = inboundCredentialsObject === null || inboundCredentialsObject === void 0 ? void 0 : inboundCredentialsObject.name) !== null && _b !== void 0 ? _b : ""}\n` +
|
|
100
|
+
`INBOUND CREDENTIALS REF: \t${(_c = inboundCredentialsObject === null || inboundCredentialsObject === void 0 ? void 0 : inboundCredentialsObject.ref) !== null && _c !== void 0 ? _c : ""}\n` +
|
|
101
|
+
`ACL: \t${(_d = acl === null || acl === void 0 ? void 0 : acl.name) !== null && _d !== void 0 ? _d : ""}\n` +
|
|
102
|
+
`ACL REF: \t${(_e = acl === null || acl === void 0 ? void 0 : acl.ref) !== null && _e !== void 0 ? _e : ""}\n` +
|
|
103
|
+
`OUTBOUND URIS: \t${(0, getOutboundUri_1.getOutboundUri)(response.uris)}\n` +
|
|
104
|
+
`OUTBOUND CREDENTIALS: \t${(_f = outboundCredentialsObject === null || outboundCredentialsObject === void 0 ? void 0 : outboundCredentialsObject.name) !== null && _f !== void 0 ? _f : ""}\n` +
|
|
105
|
+
`OUTBOUND CREDENTIALS REF: \t${(_g = outboundCredentialsObject === null || outboundCredentialsObject === void 0 ? void 0 : outboundCredentialsObject.ref) !== null && _g !== void 0 ? _g : ""}\n` +
|
|
106
|
+
`CREATED: \t${(0, moment_1.default)(response.createdAt).format("YYYY-MM-DD HH:mm:ss")}\n` +
|
|
107
|
+
`UPDATED: \t${(0, moment_1.default)(response.updatedAt).format("YYYY-MM-DD HH:mm:ss")}`);
|
|
108
|
+
this.log(ui.toString());
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
Get.description = "retrieve details of a Trunk by reference";
|
|
113
|
+
Get.examples = ["<%= config.bin %> <%= command.id %>"];
|
|
114
|
+
Get.args = {
|
|
115
|
+
ref: core_1.Args.string({
|
|
116
|
+
description: "The Trunk's reference",
|
|
117
|
+
required: true
|
|
118
|
+
})
|
|
119
|
+
};
|
|
120
|
+
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 Trunks 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,99 @@
|
|
|
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
|
+
class List extends AuthenticatedCommand_1.AuthenticatedCommand {
|
|
72
|
+
run() {
|
|
73
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
74
|
+
const { flags } = yield this.parse(List);
|
|
75
|
+
const client = yield this.createSdkClient();
|
|
76
|
+
const trunks = new SDK.Trunks(client);
|
|
77
|
+
const response = yield trunks.listTrunks({
|
|
78
|
+
pageSize: parseInt(flags["page-size"])
|
|
79
|
+
});
|
|
80
|
+
const ui = (0, cliui_1.default)({ width: 100 });
|
|
81
|
+
ui.div({ text: "REF", padding: [0, 0, 0, 0], width: 40 }, { text: "NAME", padding: [0, 0, 0, 0], width: 20 }, { text: "INBOUND URI", padding: [0, 0, 0, 0], width: 40 });
|
|
82
|
+
response.items.forEach((application) => {
|
|
83
|
+
ui.div({ text: application.ref, padding: [0, 0, 0, 0], width: 40 }, { text: application.name, padding: [0, 0, 0, 0], width: 20 }, { text: application.inboundUri, padding: [0, 0, 0, 0], width: 40 });
|
|
84
|
+
});
|
|
85
|
+
this.log(ui.toString());
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
List.description = "display all Trunks in the active Workspace";
|
|
90
|
+
List.examples = ["<%= config.bin %> <%= command.id %>"];
|
|
91
|
+
List.flags = {
|
|
92
|
+
"page-size": core_1.Flags.string({
|
|
93
|
+
char: "s",
|
|
94
|
+
description: "the number of items to show",
|
|
95
|
+
default: "1000",
|
|
96
|
+
required: false
|
|
97
|
+
})
|
|
98
|
+
};
|
|
99
|
+
exports.default = List;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { AuthenticatedCommand } from "../../../AuthenticatedCommand";
|
|
2
|
+
export default class Update extends AuthenticatedCommand<typeof Update> {
|
|
3
|
+
static readonly description = "modify the configuration of a Trunk";
|
|
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,174 @@
|
|
|
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 core_1 = require("@oclif/core");
|
|
70
|
+
const AuthenticatedCommand_1 = require("../../../AuthenticatedCommand");
|
|
71
|
+
const errorHandler_1 = __importDefault(require("../../../errorHandler"));
|
|
72
|
+
class Update extends AuthenticatedCommand_1.AuthenticatedCommand {
|
|
73
|
+
run() {
|
|
74
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
75
|
+
this.log("This utility will help you update a Trunk.");
|
|
76
|
+
this.log("Press ^C at any time to quit.");
|
|
77
|
+
this.log("(The previous outbound values will be lost.)");
|
|
78
|
+
const { args } = yield this.parse(Update);
|
|
79
|
+
const { ref } = args;
|
|
80
|
+
const client = yield this.createSdkClient();
|
|
81
|
+
const trunks = new SDK.Trunks(client);
|
|
82
|
+
const acls = new SDK.Acls(client);
|
|
83
|
+
const credentials = new SDK.Credentials(client);
|
|
84
|
+
const trunkFromDB = yield trunks.getTrunk(ref);
|
|
85
|
+
const listAcls = (yield acls.listAcls({ pageSize: 100 })).items.map((item) => ({
|
|
86
|
+
name: item.name,
|
|
87
|
+
value: item.ref
|
|
88
|
+
}));
|
|
89
|
+
const listCredentials = (yield credentials.listCredentials({
|
|
90
|
+
pageSize: 100
|
|
91
|
+
})).items.map((item) => ({
|
|
92
|
+
name: item.name,
|
|
93
|
+
value: item.ref
|
|
94
|
+
}));
|
|
95
|
+
const name = yield (0, prompts_1.input)({
|
|
96
|
+
message: "Friendly name",
|
|
97
|
+
required: true,
|
|
98
|
+
default: trunkFromDB.name
|
|
99
|
+
});
|
|
100
|
+
const inboundAnswers = {
|
|
101
|
+
inboundUri: yield (0, prompts_1.input)({
|
|
102
|
+
message: "Inbound URI",
|
|
103
|
+
required: true,
|
|
104
|
+
default: trunkFromDB.inboundUri
|
|
105
|
+
}),
|
|
106
|
+
accessControlListRef: yield (0, prompts_1.select)({
|
|
107
|
+
message: "Access Control List",
|
|
108
|
+
choices: [{ name: "None", value: null }].concat(listAcls),
|
|
109
|
+
default: trunkFromDB.accessControlListRef
|
|
110
|
+
}),
|
|
111
|
+
inboundCredentialsRef: yield (0, prompts_1.select)({
|
|
112
|
+
message: "Inbound Credentials",
|
|
113
|
+
choices: [{ name: "None", value: null }].concat(listCredentials),
|
|
114
|
+
default: trunkFromDB.inboundCredentialsRef
|
|
115
|
+
})
|
|
116
|
+
};
|
|
117
|
+
const needOutboundUri = yield (0, prompts_1.confirm)({
|
|
118
|
+
message: "Do you need an Outbound URI?"
|
|
119
|
+
});
|
|
120
|
+
let outboundAnswers = {};
|
|
121
|
+
if (needOutboundUri) {
|
|
122
|
+
outboundAnswers = {
|
|
123
|
+
outboundCredentialsRef: yield (0, prompts_1.select)({
|
|
124
|
+
message: "Outbound Credentials",
|
|
125
|
+
choices: [{ name: "None", value: null }].concat(listCredentials),
|
|
126
|
+
default: trunkFromDB.outboundCredentialsRef
|
|
127
|
+
}),
|
|
128
|
+
uris: [
|
|
129
|
+
{
|
|
130
|
+
host: yield (0, prompts_1.input)({
|
|
131
|
+
message: "Host",
|
|
132
|
+
required: true
|
|
133
|
+
}),
|
|
134
|
+
port: yield (0, prompts_1.number)({
|
|
135
|
+
message: "Port",
|
|
136
|
+
required: true,
|
|
137
|
+
default: 5060
|
|
138
|
+
}),
|
|
139
|
+
transport: yield (0, prompts_1.select)({
|
|
140
|
+
message: "Transport",
|
|
141
|
+
choices: ["TCP", "UDP"]
|
|
142
|
+
}),
|
|
143
|
+
enabled: true,
|
|
144
|
+
weight: 1,
|
|
145
|
+
priority: 1,
|
|
146
|
+
user: "placeholder"
|
|
147
|
+
}
|
|
148
|
+
]
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
const confirmAnswers = yield (0, prompts_1.confirm)({
|
|
152
|
+
message: "Ready?"
|
|
153
|
+
});
|
|
154
|
+
if (!confirmAnswers) {
|
|
155
|
+
this.log("Aborted!");
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
try {
|
|
159
|
+
yield trunks.updateTrunk(Object.assign(Object.assign({ ref,
|
|
160
|
+
name, sendRegister: true }, inboundAnswers), outboundAnswers));
|
|
161
|
+
this.log("Done!");
|
|
162
|
+
}
|
|
163
|
+
catch (e) {
|
|
164
|
+
(0, errorHandler_1.default)(e, this.error.bind(this));
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
Update.description = "modify the configuration of a Trunk";
|
|
170
|
+
Update.examples = ["<%= config.bin %> <%= command.id %>"];
|
|
171
|
+
Update.args = {
|
|
172
|
+
ref: core_1.Args.string({ description: "the Trunk to update" })
|
|
173
|
+
};
|
|
174
|
+
exports.default = Update;
|
|
@@ -41,6 +41,6 @@ class Current extends core_1.Command {
|
|
|
41
41
|
});
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
|
-
Current.description = "
|
|
44
|
+
Current.description = "display the name of the active Workspace";
|
|
45
45
|
Current.examples = ["<%= config.bin %> <%= command.id %>"];
|
|
46
46
|
exports.default = Current;
|
|
@@ -114,7 +114,7 @@ class Login extends BaseCommand_1.BaseCommand {
|
|
|
114
114
|
const config = (0, config_1.getConfig)(constants_1.CONFIG_FILE);
|
|
115
115
|
const updatedConfig = (0, config_1.addWorkspace)(workspace, config);
|
|
116
116
|
(0, saveConfig_1.saveConfig)(constants_1.CONFIG_FILE, updatedConfig);
|
|
117
|
-
this.log("
|
|
117
|
+
this.log("Done!");
|
|
118
118
|
}
|
|
119
119
|
getWorkspaceFromDB(params) {
|
|
120
120
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -140,6 +140,6 @@ class Login extends BaseCommand_1.BaseCommand {
|
|
|
140
140
|
});
|
|
141
141
|
}
|
|
142
142
|
}
|
|
143
|
-
Login.description = "
|
|
143
|
+
Login.description = "link a Workspace to the local environment";
|
|
144
144
|
Login.examples = ["<%= config.bin %> <%= command.id %>"];
|
|
145
145
|
exports.default = Login;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Command } from "@oclif/core";
|
|
2
2
|
export default class Logout extends Command {
|
|
3
|
-
static description
|
|
4
|
-
static examples: string[];
|
|
5
|
-
static args: {
|
|
3
|
+
static readonly description = "unlink a Workspace from the local environment";
|
|
4
|
+
static readonly examples: string[];
|
|
5
|
+
static readonly args: {
|
|
6
6
|
ref: import("@oclif/core/lib/interfaces").Arg<string, Record<string, unknown>>;
|
|
7
7
|
};
|
|
8
8
|
run(): Promise<void>;
|
|
@@ -36,19 +36,20 @@ class Logout extends core_1.Command {
|
|
|
36
36
|
run() {
|
|
37
37
|
return __awaiter(this, void 0, void 0, function* () {
|
|
38
38
|
const { args } = yield this.parse(Logout);
|
|
39
|
-
|
|
40
|
-
this.error("Missing Workspace reference");
|
|
41
|
-
}
|
|
39
|
+
const { ref } = args;
|
|
42
40
|
const workspaces = (0, config_1.getConfig)(constants_1.CONFIG_FILE);
|
|
43
|
-
const updatedWorkspaces = (0, config_1.removeWorkspace)(
|
|
41
|
+
const updatedWorkspaces = (0, config_1.removeWorkspace)(ref, workspaces);
|
|
44
42
|
(0, saveConfig_1.saveConfig)(constants_1.CONFIG_FILE, updatedWorkspaces);
|
|
45
43
|
this.log("Done!");
|
|
46
44
|
});
|
|
47
45
|
}
|
|
48
46
|
}
|
|
49
|
-
Logout.description = "
|
|
47
|
+
Logout.description = "unlink a Workspace from the local environment";
|
|
50
48
|
Logout.examples = ["<%= config.bin %> <%= command.id %>"];
|
|
51
49
|
Logout.args = {
|
|
52
|
-
ref: core_1.Args.string({
|
|
50
|
+
ref: core_1.Args.string({
|
|
51
|
+
description: "the Workspace to unlink from",
|
|
52
|
+
required: true
|
|
53
|
+
})
|
|
53
54
|
};
|
|
54
55
|
exports.default = Logout;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Command } from "@oclif/core";
|
|
2
2
|
export default class Use extends Command {
|
|
3
|
-
static description
|
|
4
|
-
static examples: string[];
|
|
5
|
-
static args: {
|
|
3
|
+
static readonly description = "set a Workspace as the default";
|
|
4
|
+
static readonly examples: string[];
|
|
5
|
+
static readonly args: {
|
|
6
6
|
ref: import("@oclif/core/lib/interfaces").Arg<string, Record<string, unknown>>;
|
|
7
7
|
};
|
|
8
8
|
run(): Promise<void>;
|
|
@@ -36,22 +36,22 @@ class Use extends core_1.Command {
|
|
|
36
36
|
run() {
|
|
37
37
|
return __awaiter(this, void 0, void 0, function* () {
|
|
38
38
|
const { args } = yield this.parse(Use);
|
|
39
|
-
|
|
40
|
-
this.error("Missing Workspace reference");
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
39
|
+
const { ref } = args;
|
|
43
40
|
const workspaces = (0, config_1.getConfig)(constants_1.CONFIG_FILE);
|
|
44
|
-
const updatedWorkspaces = (0, config_1.setCurrentWorkspace)(
|
|
45
|
-
const currentWorkspace =
|
|
41
|
+
const updatedWorkspaces = (0, config_1.setCurrentWorkspace)(ref, workspaces);
|
|
42
|
+
const currentWorkspace = (0, config_1.getCurrentWorkspace)(updatedWorkspaces);
|
|
46
43
|
(0, saveConfig_1.saveConfig)(constants_1.CONFIG_FILE, updatedWorkspaces);
|
|
47
44
|
const { workspaceName, workspaceRef } = currentWorkspace;
|
|
48
45
|
this.log(`Current Workspace: ${workspaceName} (${workspaceRef})`);
|
|
49
46
|
});
|
|
50
47
|
}
|
|
51
48
|
}
|
|
52
|
-
Use.description = "
|
|
49
|
+
Use.description = "set a Workspace as the default";
|
|
53
50
|
Use.examples = ["<%= config.bin %> <%= command.id %>"];
|
|
54
51
|
Use.args = {
|
|
55
|
-
ref: core_1.Args.string({
|
|
52
|
+
ref: core_1.Args.string({
|
|
53
|
+
description: "The Workspace to unlink from",
|
|
54
|
+
required: true
|
|
55
|
+
})
|
|
56
56
|
};
|
|
57
57
|
exports.default = Use;
|
|
@@ -2,9 +2,5 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getCurrentWorkspace = getCurrentWorkspace;
|
|
4
4
|
function getCurrentWorkspace(workspaces) {
|
|
5
|
-
|
|
6
|
-
if (!workspace) {
|
|
7
|
-
throw new Error("No active workspace found");
|
|
8
|
-
}
|
|
9
|
-
return `Current Workspace: ${workspace.workspaceName} (${workspace.workspaceRef})`;
|
|
5
|
+
return workspaces.find((w) => w.active === true);
|
|
10
6
|
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/*
|
|
4
|
+
* Copyright (C) 2024 by Fonoster Inc (https://fonoster.com)
|
|
5
|
+
* http://github.com/fonoster/fonoster
|
|
6
|
+
*
|
|
7
|
+
* This file is part of Fonoster
|
|
8
|
+
*
|
|
9
|
+
* Licensed under the MIT License (the "License");
|
|
10
|
+
* you may not use this file except in compliance with
|
|
11
|
+
* the License. You may obtain a copy of the License at
|
|
12
|
+
*
|
|
13
|
+
* https://opensource.org/licenses/MIT
|
|
14
|
+
*
|
|
15
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
16
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
17
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
18
|
+
* See the License for the specific language governing permissions and
|
|
19
|
+
* limitations under the License.
|
|
20
|
+
*/
|
|
21
|
+
function errorHandler(e, log) {
|
|
22
|
+
const error = e;
|
|
23
|
+
if (error.code === 3) {
|
|
24
|
+
const splitPoint = "3 INVALID_ARGUMENT:";
|
|
25
|
+
const message = error.message.split(splitPoint);
|
|
26
|
+
log(message[1]);
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
log === null || log === void 0 ? void 0 : log(error.message.trim());
|
|
30
|
+
}
|
|
31
|
+
exports.default = errorHandler;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.calculateFutureDate = calculateFutureDate;
|
|
7
|
+
/*
|
|
8
|
+
* Copyright (C) 2024 by Fonoster Inc (https://fonoster.com)
|
|
9
|
+
* http://github.com/fonoster/fonoster
|
|
10
|
+
*
|
|
11
|
+
* This file is part of Fonoster
|
|
12
|
+
*
|
|
13
|
+
* Licensed under the MIT License (the "License");
|
|
14
|
+
* you may not use this file except in compliance with
|
|
15
|
+
* the License. You may obtain a copy of the License at
|
|
16
|
+
*
|
|
17
|
+
* https://opensource.org/licenses/MIT
|
|
18
|
+
*
|
|
19
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
20
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
21
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
22
|
+
* See the License for the specific language governing permissions and
|
|
23
|
+
* limitations under the License.
|
|
24
|
+
*/
|
|
25
|
+
const moment_1 = __importDefault(require("moment"));
|
|
26
|
+
function calculateFutureDate(input) {
|
|
27
|
+
const value = parseInt(input, 10);
|
|
28
|
+
const unit = input.replace(/\d/g, "").toLowerCase(); // Extract the unit (d, mo)
|
|
29
|
+
switch (unit) {
|
|
30
|
+
case "d":
|
|
31
|
+
return (0, moment_1.default)().add(value, "days").toDate();
|
|
32
|
+
case "mo":
|
|
33
|
+
return (0, moment_1.default)().add(value, "months").toDate();
|
|
34
|
+
default:
|
|
35
|
+
throw new Error(`Invalid unit: ${unit}. Use 'd' for days or 'mo' for months.`);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getOutboundUri = getOutboundUri;
|
|
4
|
+
function getOutboundUri(uris) {
|
|
5
|
+
const uri = uris[0];
|
|
6
|
+
if (!uri) {
|
|
7
|
+
return "";
|
|
8
|
+
}
|
|
9
|
+
return `${uri.transport.toLowerCase()}://${uri.host}:${uri.port}`;
|
|
10
|
+
}
|