@fonoster/ctl 0.27.0 → 0.31.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +588 -90
- package/dist/AuthenticatedCommand.d.ts +5 -0
- package/dist/AuthenticatedCommand.js +12 -1
- package/dist/commands/applications/create.d.ts +22 -0
- package/dist/commands/applications/create.js +68 -169
- package/dist/commands/applications/eval.d.ts +1 -1
- package/dist/commands/applications/eval.js +46 -33
- package/dist/commands/applications/get.d.ts +2 -0
- package/dist/commands/applications/get.js +67 -24
- package/dist/commands/applications/list.js +19 -3
- package/dist/commands/applications/rotate-secret.d.ts +9 -0
- package/dist/commands/applications/rotate-secret.js +97 -0
- package/dist/commands/applications/update.d.ts +21 -1
- package/dist/commands/applications/update.js +18 -168
- package/dist/commands/providers/catalog.d.ts +10 -0
- package/dist/commands/providers/catalog.js +128 -0
- package/dist/commands/providers/keys/delete.d.ts +9 -0
- package/dist/commands/providers/keys/delete.js +92 -0
- package/dist/commands/providers/keys/list.d.ts +6 -0
- package/dist/commands/providers/keys/list.js +97 -0
- package/dist/commands/providers/keys/set.d.ts +12 -0
- package/dist/commands/providers/keys/set.js +110 -0
- package/dist/commands/records/download.d.ts +15 -0
- package/dist/commands/records/download.js +132 -0
- package/dist/commands/records/get.d.ts +15 -0
- package/dist/commands/records/get.js +146 -0
- package/dist/commands/records/list.d.ts +15 -0
- package/dist/commands/records/list.js +136 -0
- package/dist/commands/sipnet/calls/create.d.ts +3 -3
- package/dist/commands/sipnet/calls/create.js +35 -52
- package/dist/commands/sipnet/numbers/linkTwilioNumber.js +4 -3
- package/dist/commands/webhooks/create.d.ts +10 -0
- package/dist/commands/webhooks/create.js +104 -0
- package/dist/commands/webhooks/delete.d.ts +9 -0
- package/dist/commands/webhooks/delete.js +92 -0
- package/dist/commands/webhooks/deliveries.d.ts +12 -0
- package/dist/commands/webhooks/deliveries.js +119 -0
- package/dist/commands/webhooks/get.d.ts +9 -0
- package/dist/commands/webhooks/get.js +110 -0
- package/dist/commands/webhooks/list.d.ts +9 -0
- package/dist/commands/webhooks/list.js +104 -0
- package/dist/commands/webhooks/resend.d.ts +9 -0
- package/dist/commands/webhooks/resend.js +95 -0
- package/dist/commands/webhooks/rotate.d.ts +9 -0
- package/dist/commands/webhooks/rotate.js +98 -0
- package/dist/commands/webhooks/update.d.ts +13 -0
- package/dist/commands/webhooks/update.js +103 -0
- package/dist/commands/workspaces/login.d.ts +5 -0
- package/dist/commands/workspaces/login.js +28 -2
- package/dist/constants.d.ts +1 -2
- package/dist/constants.js +2 -3
- package/dist/utils/applicationFlags.d.ts +24 -0
- package/dist/utils/applicationFlags.js +95 -0
- package/dist/utils/applicationRequest.d.ts +42 -0
- package/dist/utils/applicationRequest.js +215 -0
- package/dist/utils/createOrUpdateApplication.d.ts +26 -1
- package/dist/utils/createOrUpdateApplication.js +23 -27
- package/dist/utils/format.d.ts +20 -0
- package/dist/utils/format.js +31 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +1 -0
- package/dist/utils/trackCallStatus.d.ts +4 -0
- package/dist/utils/trackCallStatus.js +67 -0
- package/dist/utils/webhookFlags.d.ts +3 -0
- package/dist/utils/webhookFlags.js +34 -0
- package/package.json +6 -7
|
@@ -0,0 +1,136 @@
|
|
|
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
|
+
/**
|
|
49
|
+
* Copyright (C) 2025 by Fonoster Inc (https://fonoster.com)
|
|
50
|
+
* http://github.com/fonoster/fonoster
|
|
51
|
+
*
|
|
52
|
+
* This file is part of Fonoster
|
|
53
|
+
*
|
|
54
|
+
* Licensed under the MIT License (the "License");
|
|
55
|
+
* you may not use this file except in compliance with
|
|
56
|
+
* the License. You may obtain a copy of the License at
|
|
57
|
+
*
|
|
58
|
+
* https://opensource.org/licenses/MIT
|
|
59
|
+
*
|
|
60
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
61
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
62
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
63
|
+
* See the License for the specific language governing permissions and
|
|
64
|
+
* limitations under the License.
|
|
65
|
+
*/
|
|
66
|
+
const SDK = __importStar(require("@fonoster/sdk"));
|
|
67
|
+
const core_1 = require("@oclif/core");
|
|
68
|
+
const cliui_1 = __importDefault(require("cliui"));
|
|
69
|
+
const AuthenticatedCommand_1 = require("../../AuthenticatedCommand");
|
|
70
|
+
const errorHandler_1 = __importDefault(require("../../errorHandler"));
|
|
71
|
+
const format_1 = require("../../utils/format");
|
|
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
|
+
try {
|
|
77
|
+
const client = yield this.createSdkClient();
|
|
78
|
+
const records = new SDK.CallRecords(client);
|
|
79
|
+
const response = yield records.listRecords({
|
|
80
|
+
after: flags.after,
|
|
81
|
+
before: flags.before,
|
|
82
|
+
number: flags.number,
|
|
83
|
+
appRef: flags.app,
|
|
84
|
+
status: flags.status,
|
|
85
|
+
pageSize: parseInt(flags["page-size"]),
|
|
86
|
+
pageToken: flags["page-token"]
|
|
87
|
+
});
|
|
88
|
+
const ui = (0, cliui_1.default)({ width: 200 });
|
|
89
|
+
ui.div({ text: "CALL REF", padding: [0, 0, 0, 0], width: 40 }, { text: "STARTED", padding: [0, 0, 0, 0], width: 22 }, { text: "FROM", padding: [0, 0, 0, 0], width: 18 }, { text: "TO", padding: [0, 0, 0, 0], width: 18 }, { text: "STATUS", padding: [0, 0, 0, 0], width: 10 }, { text: "SECS", padding: [0, 0, 0, 0], width: 7 }, { text: "END REASON", padding: [0, 0, 0, 0] });
|
|
90
|
+
response.items.forEach((r) => {
|
|
91
|
+
var _a, _b, _c, _d, _e;
|
|
92
|
+
ui.div({ text: r.callRef, padding: [0, 0, 0, 0], width: 40 }, { text: (0, format_1.formatDate)(r.startedAt), padding: [0, 0, 0, 0], width: 22 }, { text: (_a = r.from) !== null && _a !== void 0 ? _a : "-", padding: [0, 0, 0, 0], width: 18 }, { text: (_b = r.to) !== null && _b !== void 0 ? _b : "-", padding: [0, 0, 0, 0], width: 18 }, { text: r.status, padding: [0, 0, 0, 0], width: 10 }, {
|
|
93
|
+
text: String(Math.round((_c = r.durationSeconds) !== null && _c !== void 0 ? _c : 0)),
|
|
94
|
+
padding: [0, 0, 0, 0],
|
|
95
|
+
width: 7
|
|
96
|
+
}, {
|
|
97
|
+
text: (_e = (_d = r.endReason) !== null && _d !== void 0 ? _d : r.failureReason) !== null && _e !== void 0 ? _e : "-",
|
|
98
|
+
padding: [0, 0, 0, 0]
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
this.log(ui.toString());
|
|
102
|
+
if (response.nextPageToken) {
|
|
103
|
+
this.log(`Next page: --page-token ${response.nextPageToken}`);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
catch (e) {
|
|
107
|
+
(0, errorHandler_1.default)(e, this.error.bind(this));
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
List.description = "search the call records (vCon) of the active Workspace, newest first";
|
|
113
|
+
List.examples = [
|
|
114
|
+
"<%= config.bin %> <%= command.id %>",
|
|
115
|
+
"<%= config.bin %> <%= command.id %> --after 2026-10-01 --number +17853178070",
|
|
116
|
+
"<%= config.bin %> <%= command.id %> --app <app-ref> --status failed"
|
|
117
|
+
];
|
|
118
|
+
List.flags = {
|
|
119
|
+
after: core_1.Flags.string({ description: "started at or after (ISO date/time)" }),
|
|
120
|
+
before: core_1.Flags.string({ description: "started before (ISO date/time)" }),
|
|
121
|
+
number: core_1.Flags.string({ description: "calls from or to this number" }),
|
|
122
|
+
app: core_1.Flags.string({ description: "calls handled by this Application" }),
|
|
123
|
+
status: core_1.Flags.string({
|
|
124
|
+
description: "record status (e.g. sealed, failed)"
|
|
125
|
+
}),
|
|
126
|
+
"page-size": core_1.Flags.string({
|
|
127
|
+
char: "s",
|
|
128
|
+
description: "the number of items to show",
|
|
129
|
+
default: "50"
|
|
130
|
+
}),
|
|
131
|
+
"page-token": core_1.Flags.string({
|
|
132
|
+
char: "t",
|
|
133
|
+
description: "the token for the next page (printed after a full page)"
|
|
134
|
+
})
|
|
135
|
+
};
|
|
136
|
+
exports.default = List;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { AuthenticatedCommand } from "../../../AuthenticatedCommand";
|
|
2
2
|
export default class Create extends AuthenticatedCommand<typeof Create> {
|
|
3
|
-
static readonly description = "
|
|
3
|
+
static readonly description = "place an outbound call to a phone number or SIP URI and follow its status";
|
|
4
4
|
static readonly examples: string[];
|
|
5
5
|
static readonly flags: {
|
|
6
6
|
from: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
7
7
|
to: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
8
8
|
"app-ref": import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
9
|
-
timeout: import("@oclif/core/lib/interfaces").OptionFlag<
|
|
10
|
-
"track-call": import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
9
|
+
timeout: import("@oclif/core/lib/interfaces").OptionFlag<number, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
11
10
|
metadata: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
11
|
+
detach: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
12
12
|
};
|
|
13
13
|
run(): Promise<void>;
|
|
14
14
|
}
|
|
@@ -41,13 +41,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
41
41
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
42
42
|
});
|
|
43
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
44
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
52
45
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
53
46
|
};
|
|
@@ -70,51 +63,40 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
70
63
|
* See the License for the specific language governing permissions and
|
|
71
64
|
* limitations under the License.
|
|
72
65
|
*/
|
|
73
|
-
const common_1 = require("@fonoster/common");
|
|
74
66
|
const SDK = __importStar(require("@fonoster/sdk"));
|
|
75
67
|
const core_1 = require("@oclif/core");
|
|
76
68
|
const AuthenticatedCommand_1 = require("../../../AuthenticatedCommand");
|
|
77
69
|
const errorHandler_1 = __importDefault(require("../../../errorHandler"));
|
|
70
|
+
const trackCallStatus_1 = require("../../../utils/trackCallStatus");
|
|
78
71
|
class Create extends AuthenticatedCommand_1.AuthenticatedCommand {
|
|
79
72
|
run() {
|
|
80
73
|
return __awaiter(this, void 0, void 0, function* () {
|
|
81
|
-
|
|
74
|
+
const { flags } = yield this.parse(Create);
|
|
75
|
+
let metadata = {};
|
|
76
|
+
try {
|
|
77
|
+
metadata = JSON.parse(flags.metadata || "{}");
|
|
78
|
+
}
|
|
79
|
+
catch (_a) {
|
|
80
|
+
this.error("--metadata must be a JSON object");
|
|
81
|
+
}
|
|
82
82
|
try {
|
|
83
83
|
const client = yield this.createSdkClient();
|
|
84
84
|
const calls = new SDK.Calls(client);
|
|
85
85
|
const callRequest = {
|
|
86
|
-
from:
|
|
87
|
-
to:
|
|
88
|
-
appRef:
|
|
89
|
-
timeout:
|
|
90
|
-
metadata
|
|
86
|
+
from: flags.from,
|
|
87
|
+
to: flags.to,
|
|
88
|
+
appRef: flags["app-ref"],
|
|
89
|
+
timeout: flags.timeout,
|
|
90
|
+
metadata
|
|
91
91
|
};
|
|
92
92
|
const response = yield calls.createCall(callRequest);
|
|
93
93
|
this.log(`Call created: ${response.ref}`);
|
|
94
|
-
if (
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
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
|
-
}
|
|
94
|
+
if (!flags.detach) {
|
|
95
|
+
const last = yield (0, trackCallStatus_1.trackCallStatus)(response.statusStream, this.log.bind(this));
|
|
96
|
+
if (last === "ANSWER") {
|
|
97
|
+
this.log("Answered. Its call record appears in records:list after hangup.");
|
|
105
98
|
}
|
|
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
99
|
}
|
|
117
|
-
process.exit(0);
|
|
118
100
|
}
|
|
119
101
|
catch (e) {
|
|
120
102
|
(0, errorHandler_1.default)(e, this.error.bind(this));
|
|
@@ -122,8 +104,12 @@ class Create extends AuthenticatedCommand_1.AuthenticatedCommand {
|
|
|
122
104
|
});
|
|
123
105
|
}
|
|
124
106
|
}
|
|
125
|
-
Create.description = "
|
|
126
|
-
Create.examples = [
|
|
107
|
+
Create.description = "place an outbound call to a phone number or SIP URI and follow its status";
|
|
108
|
+
Create.examples = [
|
|
109
|
+
"<%= config.bin %> <%= command.id %> -f +17853178070 -t +18287854037 -a <app-ref>",
|
|
110
|
+
"<%= config.bin %> <%= command.id %> -f +17853178070 -t +18287854037 -a <app-ref> --detach",
|
|
111
|
+
`<%= config.bin %> <%= command.id %> -f +17853178070 -t +18287854037 -a <app-ref> -m '{"name":"Jane"}'`
|
|
112
|
+
];
|
|
127
113
|
Create.flags = {
|
|
128
114
|
from: core_1.Flags.string({
|
|
129
115
|
char: "f",
|
|
@@ -132,30 +118,27 @@ Create.flags = {
|
|
|
132
118
|
}),
|
|
133
119
|
to: core_1.Flags.string({
|
|
134
120
|
char: "t",
|
|
135
|
-
description: "the number
|
|
121
|
+
description: "the number or SIP URI to call",
|
|
136
122
|
required: true
|
|
137
123
|
}),
|
|
138
124
|
"app-ref": core_1.Flags.string({
|
|
139
125
|
char: "a",
|
|
140
|
-
description: "the
|
|
126
|
+
description: "the Application that handles the call",
|
|
141
127
|
required: true
|
|
142
128
|
}),
|
|
143
|
-
timeout: core_1.Flags.
|
|
129
|
+
timeout: core_1.Flags.integer({
|
|
144
130
|
char: "o",
|
|
145
|
-
description: "
|
|
146
|
-
default:
|
|
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
|
|
131
|
+
description: "seconds to wait for an answer",
|
|
132
|
+
default: 30
|
|
154
133
|
}),
|
|
155
134
|
metadata: core_1.Flags.string({
|
|
156
135
|
char: "m",
|
|
157
|
-
description: 'a JSON object
|
|
158
|
-
|
|
136
|
+
description: 'a JSON object the app receives with the session (e.g. \'{"name": "John Doe"}\')'
|
|
137
|
+
}),
|
|
138
|
+
detach: core_1.Flags.boolean({
|
|
139
|
+
char: "d",
|
|
140
|
+
description: "print the call ref and return without following the status",
|
|
141
|
+
default: false
|
|
159
142
|
})
|
|
160
143
|
};
|
|
161
144
|
exports.default = Create;
|
|
@@ -71,6 +71,7 @@ const utils_1 = require("../../../utils");
|
|
|
71
71
|
class LinkTwilioNumber extends AuthenticatedCommand_1.AuthenticatedCommand {
|
|
72
72
|
run() {
|
|
73
73
|
return __awaiter(this, void 0, void 0, function* () {
|
|
74
|
+
var _a;
|
|
74
75
|
const { flags } = yield this.parse(LinkTwilioNumber);
|
|
75
76
|
const fonosterClient = yield this.createSdkClient();
|
|
76
77
|
const applications = new Fonoster.Applications(fonosterClient);
|
|
@@ -115,7 +116,8 @@ class LinkTwilioNumber extends AuthenticatedCommand_1.AuthenticatedCommand {
|
|
|
115
116
|
phoneNumber: answers.number,
|
|
116
117
|
accessKeyId,
|
|
117
118
|
aclEntries: flags["access-control-list"].split(","),
|
|
118
|
-
|
|
119
|
+
// Trunk inbound URIs live under pstn.<domain> (features.sip.names).
|
|
120
|
+
originationUriBase: (_a = flags["outbound-uri-base"]) !== null && _a !== void 0 ? _a : `pstn.${(yield fonosterClient.getCapabilities()).domain}`,
|
|
119
121
|
applicationRef: answers.applicationRef,
|
|
120
122
|
friendlyName: answers.friendlyName
|
|
121
123
|
});
|
|
@@ -131,8 +133,7 @@ LinkTwilioNumber.examples = ["<%= config.bin %> <%= command.id %>"];
|
|
|
131
133
|
LinkTwilioNumber.flags = {
|
|
132
134
|
"outbound-uri-base": core_1.Flags.string({
|
|
133
135
|
char: "b",
|
|
134
|
-
description: "the
|
|
135
|
-
default: constants_1.FONOSTER_ORIGINATION_URI_BASE,
|
|
136
|
+
description: "the host Twilio sends calls to, under which the trunk's inbound URI is made (default: pstn.<the server's domain>)",
|
|
136
137
|
required: false
|
|
137
138
|
}),
|
|
138
139
|
"access-control-list": core_1.Flags.string({
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { AuthenticatedCommand } from "../../AuthenticatedCommand";
|
|
2
|
+
export default class Create extends AuthenticatedCommand<typeof Create> {
|
|
3
|
+
static readonly description = "subscribe an HTTPS endpoint to Workspace events";
|
|
4
|
+
static readonly examples: string[];
|
|
5
|
+
static readonly flags: {
|
|
6
|
+
url: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
7
|
+
event: import("@oclif/core/lib/interfaces").OptionFlag<string[], import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
8
|
+
};
|
|
9
|
+
run(): Promise<void>;
|
|
10
|
+
}
|
|
@@ -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
|
+
/**
|
|
49
|
+
* Copyright (C) 2025 by Fonoster Inc (https://fonoster.com)
|
|
50
|
+
* http://github.com/fonoster/fonoster
|
|
51
|
+
*
|
|
52
|
+
* This file is part of Fonoster
|
|
53
|
+
*
|
|
54
|
+
* Licensed under the MIT License (the "License");
|
|
55
|
+
* you may not use this file except in compliance with
|
|
56
|
+
* the License. You may obtain a copy of the License at
|
|
57
|
+
*
|
|
58
|
+
* https://opensource.org/licenses/MIT
|
|
59
|
+
*
|
|
60
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
61
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
62
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
63
|
+
* See the License for the specific language governing permissions and
|
|
64
|
+
* limitations under the License.
|
|
65
|
+
*/
|
|
66
|
+
const SDK = __importStar(require("@fonoster/sdk"));
|
|
67
|
+
const core_1 = require("@oclif/core");
|
|
68
|
+
const AuthenticatedCommand_1 = require("../../AuthenticatedCommand");
|
|
69
|
+
const errorHandler_1 = __importDefault(require("../../errorHandler"));
|
|
70
|
+
const webhookFlags_1 = require("../../utils/webhookFlags");
|
|
71
|
+
class Create extends AuthenticatedCommand_1.AuthenticatedCommand {
|
|
72
|
+
run() {
|
|
73
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
74
|
+
const { flags } = yield this.parse(Create);
|
|
75
|
+
try {
|
|
76
|
+
const client = yield this.createSdkClient();
|
|
77
|
+
const webhooks = new SDK.Webhooks(client);
|
|
78
|
+
const response = yield webhooks.createWebhook({
|
|
79
|
+
url: flags.url,
|
|
80
|
+
events: flags.event
|
|
81
|
+
});
|
|
82
|
+
this.log(`Webhook created: ${response.ref}`);
|
|
83
|
+
this.log(`Signing secret: ${response.secret}`);
|
|
84
|
+
this.log("Save it now: it is shown only once.");
|
|
85
|
+
}
|
|
86
|
+
catch (e) {
|
|
87
|
+
(0, errorHandler_1.default)(e, this.error.bind(this));
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
Create.description = "subscribe an HTTPS endpoint to Workspace events";
|
|
93
|
+
Create.examples = [
|
|
94
|
+
"<%= config.bin %> <%= command.id %> --url https://example.com/hooks -e call.ended -e call_record.sealed"
|
|
95
|
+
];
|
|
96
|
+
Create.flags = {
|
|
97
|
+
url: core_1.Flags.string({
|
|
98
|
+
char: "u",
|
|
99
|
+
description: "the endpoint that receives the events (https://)",
|
|
100
|
+
required: true
|
|
101
|
+
}),
|
|
102
|
+
event: (0, webhookFlags_1.eventFlag)(true)
|
|
103
|
+
};
|
|
104
|
+
exports.default = Create;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { AuthenticatedCommand } from "../../AuthenticatedCommand";
|
|
2
|
+
export default class Delete extends AuthenticatedCommand<typeof Delete> {
|
|
3
|
+
static readonly description = "delete a Webhook from the active Workspace";
|
|
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,92 @@
|
|
|
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
|
+
/**
|
|
49
|
+
* Copyright (C) 2025 by Fonoster Inc (https://fonoster.com)
|
|
50
|
+
* http://github.com/fonoster/fonoster
|
|
51
|
+
*
|
|
52
|
+
* This file is part of Fonoster
|
|
53
|
+
*
|
|
54
|
+
* Licensed under the MIT License (the "License");
|
|
55
|
+
* you may not use this file except in compliance with
|
|
56
|
+
* the License. You may obtain a copy of the License at
|
|
57
|
+
*
|
|
58
|
+
* https://opensource.org/licenses/MIT
|
|
59
|
+
*
|
|
60
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
61
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
62
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
63
|
+
* See the License for the specific language governing permissions and
|
|
64
|
+
* limitations under the License.
|
|
65
|
+
*/
|
|
66
|
+
const SDK = __importStar(require("@fonoster/sdk"));
|
|
67
|
+
const core_1 = require("@oclif/core");
|
|
68
|
+
const AuthenticatedCommand_1 = require("../../AuthenticatedCommand");
|
|
69
|
+
const errorHandler_1 = __importDefault(require("../../errorHandler"));
|
|
70
|
+
class Delete extends AuthenticatedCommand_1.AuthenticatedCommand {
|
|
71
|
+
run() {
|
|
72
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
73
|
+
const { args } = yield this.parse(Delete);
|
|
74
|
+
try {
|
|
75
|
+
const client = yield this.createSdkClient();
|
|
76
|
+
yield new SDK.Webhooks(client).deleteWebhook(args.ref);
|
|
77
|
+
this.log("Done!");
|
|
78
|
+
}
|
|
79
|
+
catch (e) {
|
|
80
|
+
(0, errorHandler_1.default)(e, this.error.bind(this));
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
Delete.description = "delete a Webhook from the active Workspace";
|
|
86
|
+
Delete.examples = [
|
|
87
|
+
"<%= config.bin %> <%= command.id %> <ref>"
|
|
88
|
+
];
|
|
89
|
+
Delete.args = {
|
|
90
|
+
ref: core_1.Args.string({ description: "the Webhook to delete", required: true })
|
|
91
|
+
};
|
|
92
|
+
exports.default = Delete;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { AuthenticatedCommand } from "../../AuthenticatedCommand";
|
|
2
|
+
export default class Deliveries extends AuthenticatedCommand<typeof Deliveries> {
|
|
3
|
+
static readonly description = "show the delivery log (all Webhooks, or one)";
|
|
4
|
+
static readonly examples: string[];
|
|
5
|
+
static readonly args: {
|
|
6
|
+
ref: import("@oclif/core/lib/interfaces").Arg<string, Record<string, unknown>>;
|
|
7
|
+
};
|
|
8
|
+
static readonly flags: {
|
|
9
|
+
"page-size": import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
10
|
+
};
|
|
11
|
+
run(): Promise<void>;
|
|
12
|
+
}
|