@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
|
@@ -41,9 +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 __importDefault = (this && this.__importDefault) || function (mod) {
|
|
45
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
46
|
-
};
|
|
47
44
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
48
45
|
exports.createOrUpdateApplication = createOrUpdateApplication;
|
|
49
46
|
/**
|
|
@@ -64,39 +61,38 @@ exports.createOrUpdateApplication = createOrUpdateApplication;
|
|
|
64
61
|
* See the License for the specific language governing permissions and
|
|
65
62
|
* limitations under the License.
|
|
66
63
|
*/
|
|
67
|
-
const fs_1 = require("fs");
|
|
68
|
-
const path_1 = __importDefault(require("path"));
|
|
69
64
|
const SDK = __importStar(require("@fonoster/sdk"));
|
|
70
|
-
const
|
|
65
|
+
const applicationRequest_1 = require("./applicationRequest");
|
|
66
|
+
/**
|
|
67
|
+
* Creates an app, or updates one, from an optional YAML/JSON file in the app model plus flags.
|
|
68
|
+
* An update starts from the current app (the control plane replaces the whole app), then the
|
|
69
|
+
* file, then the flags.
|
|
70
|
+
*/
|
|
71
71
|
function createOrUpdateApplication(client_1, filePath_1, appRef_1) {
|
|
72
|
-
return __awaiter(this, arguments, void 0, function* (client, filePath, appRef, isUpdate = false) {
|
|
73
|
-
var _a, _b
|
|
74
|
-
const
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
if (fileExt === ".yaml" || fileExt === ".yml") {
|
|
78
|
-
config = (0, js_yaml_1.load)(fileContent);
|
|
79
|
-
}
|
|
80
|
-
else if (fileExt === ".json") {
|
|
81
|
-
config = JSON.parse(fileContent);
|
|
82
|
-
}
|
|
83
|
-
else {
|
|
84
|
-
throw new Error("Unsupported file format. Please use YAML or JSON files.");
|
|
85
|
-
}
|
|
72
|
+
return __awaiter(this, arguments, void 0, function* (client, filePath, appRef, isUpdate = false, flags = {}) {
|
|
73
|
+
var _a, _b;
|
|
74
|
+
const fromFile = filePath
|
|
75
|
+
? (0, applicationRequest_1.fileToRequest)((0, applicationRequest_1.readConfigFile)(filePath))
|
|
76
|
+
: {};
|
|
86
77
|
const applications = new SDK.Applications(client);
|
|
87
|
-
delete config.testCases;
|
|
88
|
-
(_c = (_b = (_a = config.intelligence) === null || _a === void 0 ? void 0 : _a.config) === null || _b === void 0 ? void 0 : _b.languageModel) === null || _c === void 0 ? true : delete _c.apiKey;
|
|
89
78
|
if (isUpdate) {
|
|
90
79
|
// The positional appRef takes precedence over any `ref` in the file; fall
|
|
91
80
|
// back to the file's `ref` when the positional is omitted.
|
|
92
|
-
const ref = appRef !== null && appRef !== void 0 ? appRef :
|
|
81
|
+
const ref = appRef !== null && appRef !== void 0 ? appRef : fromFile.ref;
|
|
93
82
|
if (!ref) {
|
|
94
83
|
throw new Error("An Application ref is required to update. Provide it as the positional argument or include `ref` in the file.");
|
|
95
84
|
}
|
|
96
|
-
|
|
97
|
-
const
|
|
98
|
-
|
|
85
|
+
const current = (0, applicationRequest_1.applicationToRequest)(yield applications.getApplication(ref));
|
|
86
|
+
const merged = Object.assign(Object.assign(Object.assign({}, current), fromFile), { speech: Object.assign(Object.assign({}, ((_a = current.speech) !== null && _a !== void 0 ? _a : {})), ((_b = fromFile.speech) !== null && _b !== void 0 ? _b : {})) });
|
|
87
|
+
delete merged.ref;
|
|
88
|
+
const request = (0, applicationRequest_1.applyFlags)(merged, flags);
|
|
89
|
+
(0, applicationRequest_1.checkRequest)(request);
|
|
90
|
+
const updateRequest = Object.assign(Object.assign({}, request), { ref });
|
|
91
|
+
return applications.updateApplication(updateRequest);
|
|
99
92
|
}
|
|
100
|
-
|
|
93
|
+
delete fromFile.ref;
|
|
94
|
+
const request = (0, applicationRequest_1.applyFlags)(fromFile, flags);
|
|
95
|
+
(0, applicationRequest_1.checkRequest)(request);
|
|
96
|
+
return applications.createApplication(request);
|
|
101
97
|
});
|
|
102
98
|
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (C) 2025 by Fonoster Inc (https://fonoster.com)
|
|
3
|
+
* http://github.com/fonoster/fonoster
|
|
4
|
+
*
|
|
5
|
+
* This file is part of Fonoster
|
|
6
|
+
*
|
|
7
|
+
* Licensed under the MIT License (the "License");
|
|
8
|
+
* you may not use this file except in compliance with
|
|
9
|
+
* the License. You may obtain a copy of the License at
|
|
10
|
+
*
|
|
11
|
+
* https://opensource.org/licenses/MIT
|
|
12
|
+
*
|
|
13
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
* See the License for the specific language governing permissions and
|
|
17
|
+
* limitations under the License.
|
|
18
|
+
*/
|
|
19
|
+
/** ISO time without milliseconds, or "-" when absent. */
|
|
20
|
+
export declare const formatDate: (value?: Date | string | null) => string;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.formatDate = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Copyright (C) 2025 by Fonoster Inc (https://fonoster.com)
|
|
6
|
+
* http://github.com/fonoster/fonoster
|
|
7
|
+
*
|
|
8
|
+
* This file is part of Fonoster
|
|
9
|
+
*
|
|
10
|
+
* Licensed under the MIT License (the "License");
|
|
11
|
+
* you may not use this file except in compliance with
|
|
12
|
+
* the License. You may obtain a copy of the License at
|
|
13
|
+
*
|
|
14
|
+
* https://opensource.org/licenses/MIT
|
|
15
|
+
*
|
|
16
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
17
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
18
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
19
|
+
* See the License for the specific language governing permissions and
|
|
20
|
+
* limitations under the License.
|
|
21
|
+
*/
|
|
22
|
+
/** ISO time without milliseconds, or "-" when absent. */
|
|
23
|
+
const formatDate = (value) => {
|
|
24
|
+
if (!value)
|
|
25
|
+
return "-";
|
|
26
|
+
const date = new Date(value);
|
|
27
|
+
return isNaN(date.getTime())
|
|
28
|
+
? "-"
|
|
29
|
+
: date.toISOString().replace(/\.\d{3}Z$/, "Z");
|
|
30
|
+
};
|
|
31
|
+
exports.formatDate = formatDate;
|
package/dist/utils/index.d.ts
CHANGED
package/dist/utils/index.js
CHANGED
|
@@ -42,3 +42,4 @@ __exportStar(require("./getTwilioTrunk"), exports);
|
|
|
42
42
|
__exportStar(require("./linkTwilioNumberToApplication"), exports);
|
|
43
43
|
__exportStar(require("./types"), exports);
|
|
44
44
|
__exportStar(require("./createOrUpdateApplication"), exports);
|
|
45
|
+
__exportStar(require("./applicationRequest"), exports);
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __asyncValues = (this && this.__asyncValues) || function (o) {
|
|
12
|
+
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
13
|
+
var m = o[Symbol.asyncIterator], i;
|
|
14
|
+
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);
|
|
15
|
+
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); }); }; }
|
|
16
|
+
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
|
17
|
+
};
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
exports.trackCallStatus = trackCallStatus;
|
|
20
|
+
/**
|
|
21
|
+
* Copyright (C) 2025 by Fonoster Inc (https://fonoster.com)
|
|
22
|
+
* http://github.com/fonoster/fonoster
|
|
23
|
+
*
|
|
24
|
+
* This file is part of Fonoster
|
|
25
|
+
*
|
|
26
|
+
* Licensed under the MIT License (the "License");
|
|
27
|
+
* you may not use this file except in compliance with
|
|
28
|
+
* the License. You may obtain a copy of the License at
|
|
29
|
+
*
|
|
30
|
+
* https://opensource.org/licenses/MIT
|
|
31
|
+
*
|
|
32
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
33
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
34
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
35
|
+
* See the License for the specific language governing permissions and
|
|
36
|
+
* limitations under the License.
|
|
37
|
+
*/
|
|
38
|
+
// The dial ends at one of these; the stream may stay open a moment after (the server closes it).
|
|
39
|
+
const FINAL = ["ANSWER", "BUSY", "CANCEL", "FAILED", "NOANSWER", "ERROR"];
|
|
40
|
+
/** Prints each dial status until a final one (or the stream ends); returns the last status. */
|
|
41
|
+
function trackCallStatus(statusStream, log) {
|
|
42
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
43
|
+
var _a, statusStream_1, statusStream_1_1;
|
|
44
|
+
var _b, e_1, _c, _d;
|
|
45
|
+
let last;
|
|
46
|
+
try {
|
|
47
|
+
// eslint-disable-next-line no-loops/no-loops
|
|
48
|
+
for (_a = true, statusStream_1 = __asyncValues(statusStream); statusStream_1_1 = yield statusStream_1.next(), _b = statusStream_1_1.done, !_b; _a = true) {
|
|
49
|
+
_d = statusStream_1_1.value;
|
|
50
|
+
_a = false;
|
|
51
|
+
const entry = _d;
|
|
52
|
+
last = entry.status;
|
|
53
|
+
log(`Call status: ${entry.status}`);
|
|
54
|
+
if (FINAL.includes(entry.status))
|
|
55
|
+
break;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
59
|
+
finally {
|
|
60
|
+
try {
|
|
61
|
+
if (!_a && !_b && (_c = statusStream_1.return)) yield _c.call(statusStream_1);
|
|
62
|
+
}
|
|
63
|
+
finally { if (e_1) throw e_1.error; }
|
|
64
|
+
}
|
|
65
|
+
return last;
|
|
66
|
+
});
|
|
67
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.formatDate = exports.eventFlag = exports.WEBHOOK_EVENTS = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Copyright (C) 2025 by Fonoster Inc (https://fonoster.com)
|
|
6
|
+
* http://github.com/fonoster/fonoster
|
|
7
|
+
*
|
|
8
|
+
* This file is part of Fonoster
|
|
9
|
+
*
|
|
10
|
+
* Licensed under the MIT License (the "License");
|
|
11
|
+
* you may not use this file except in compliance with
|
|
12
|
+
* the License. You may obtain a copy of the License at
|
|
13
|
+
*
|
|
14
|
+
* https://opensource.org/licenses/MIT
|
|
15
|
+
*
|
|
16
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
17
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
18
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
19
|
+
* See the License for the specific language governing permissions and
|
|
20
|
+
* limitations under the License.
|
|
21
|
+
*/
|
|
22
|
+
const common_1 = require("@fonoster/common");
|
|
23
|
+
const core_1 = require("@oclif/core");
|
|
24
|
+
exports.WEBHOOK_EVENTS = [...common_1.Webhooks.WEBHOOK_EVENT_TYPES];
|
|
25
|
+
const eventFlag = (required) => core_1.Flags.string({
|
|
26
|
+
char: "e",
|
|
27
|
+
description: "an event to receive (repeatable)",
|
|
28
|
+
options: exports.WEBHOOK_EVENTS,
|
|
29
|
+
multiple: true,
|
|
30
|
+
required
|
|
31
|
+
});
|
|
32
|
+
exports.eventFlag = eventFlag;
|
|
33
|
+
var format_1 = require("./format");
|
|
34
|
+
Object.defineProperty(exports, "formatDate", { enumerable: true, get: function () { return format_1.formatDate; } });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fonoster/ctl",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.31.0",
|
|
4
4
|
"description": "Fonoster Control Tool",
|
|
5
5
|
"author": "Pedro Sanders <psanders@fonoster.com>",
|
|
6
6
|
"homepage": "https://github.com/fonoster/fonoster#readme",
|
|
@@ -14,7 +14,6 @@
|
|
|
14
14
|
"scripts": {
|
|
15
15
|
"prebuild": "rimraf ./dist tsconfig.tsbuildinfo",
|
|
16
16
|
"build": "tsc -b tsconfig.json",
|
|
17
|
-
"clean": "rimraf ./dist node_modules tsconfig.tsbuildinfo",
|
|
18
17
|
"generate:readme": "oclif readme"
|
|
19
18
|
},
|
|
20
19
|
"files": [
|
|
@@ -30,7 +29,7 @@
|
|
|
30
29
|
"bugs": {
|
|
31
30
|
"url": "https://github.com/fonoster/fonoster/issues"
|
|
32
31
|
},
|
|
33
|
-
"gitHead": "
|
|
32
|
+
"gitHead": "f0a5102dddeea0f70f659234108805bc10690f2e",
|
|
34
33
|
"bin": {
|
|
35
34
|
"fonoster": "./bin/run.js"
|
|
36
35
|
},
|
|
@@ -51,7 +50,7 @@
|
|
|
51
50
|
}
|
|
52
51
|
},
|
|
53
52
|
"dependencies": {
|
|
54
|
-
"@fonoster/sdk": "^0.
|
|
53
|
+
"@fonoster/sdk": "^0.31.0",
|
|
55
54
|
"@inquirer/prompts": "^7.1.0",
|
|
56
55
|
"@oclif/core": "^4.0.34",
|
|
57
56
|
"@oclif/plugin-warn-if-update-available": "^3.1.28",
|
|
@@ -59,9 +58,8 @@
|
|
|
59
58
|
"cli-table3": "^0.6.5",
|
|
60
59
|
"cliui": "^8.0.1",
|
|
61
60
|
"figlet": "^1.8.0",
|
|
62
|
-
"js-yaml": "^4.
|
|
61
|
+
"js-yaml": "^4.3.2",
|
|
63
62
|
"moment": "^2.30.1",
|
|
64
|
-
"oclif": "^4.17.46",
|
|
65
63
|
"phone": "^3.1.55",
|
|
66
64
|
"terminal-link": "^3.0.0",
|
|
67
65
|
"twilio": "^5.4.0",
|
|
@@ -71,6 +69,7 @@
|
|
|
71
69
|
"@oclif/test": "^4.1.3",
|
|
72
70
|
"@types/figlet": "^1.7.0",
|
|
73
71
|
"@types/js-yaml": "^4.0.9",
|
|
74
|
-
"@types/node": "22.10.1"
|
|
72
|
+
"@types/node": "22.10.1",
|
|
73
|
+
"oclif": "^4.17.46"
|
|
75
74
|
}
|
|
76
75
|
}
|