@fonoster/ctl 0.7.43 → 0.7.44

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. package/bin/run.js +21 -3
  2. package/package.json +6 -7
  3. package/dist/BaseCommand.d.ts +0 -15
  4. package/dist/BaseCommand.js +0 -80
  5. package/dist/Help.d.ts +0 -6
  6. package/dist/Help.js +0 -52
  7. package/dist/commands/applications/create.d.ts +0 -6
  8. package/dist/commands/applications/create.js +0 -164
  9. package/dist/commands/applications/delete.d.ts +0 -9
  10. package/dist/commands/applications/delete.js +0 -99
  11. package/dist/commands/applications/get.d.ts +0 -9
  12. package/dist/commands/applications/get.js +0 -120
  13. package/dist/commands/applications/list.d.ts +0 -9
  14. package/dist/commands/applications/list.js +0 -112
  15. package/dist/commands/applications/update.d.ts +0 -9
  16. package/dist/commands/applications/update.js +0 -187
  17. package/dist/commands/bug.d.ts +0 -6
  18. package/dist/commands/bug.js +0 -42
  19. package/dist/commands/feedback.d.ts +0 -6
  20. package/dist/commands/feedback.js +0 -45
  21. package/dist/commands/numbers/get.d.ts +0 -9
  22. package/dist/commands/numbers/get.js +0 -125
  23. package/dist/commands/numbers/linkTwilioNumber.d.ts +0 -10
  24. package/dist/commands/numbers/linkTwilioNumber.js +0 -155
  25. package/dist/commands/numbers/list.d.ts +0 -9
  26. package/dist/commands/numbers/list.js +0 -116
  27. package/dist/commands/workspaces/current.d.ts +0 -6
  28. package/dist/commands/workspaces/current.js +0 -46
  29. package/dist/commands/workspaces/list.d.ts +0 -6
  30. package/dist/commands/workspaces/list.js +0 -53
  31. package/dist/commands/workspaces/login.d.ts +0 -8
  32. package/dist/commands/workspaces/login.js +0 -145
  33. package/dist/commands/workspaces/logout.d.ts +0 -9
  34. package/dist/commands/workspaces/logout.js +0 -54
  35. package/dist/commands/workspaces/use.d.ts +0 -9
  36. package/dist/commands/workspaces/use.js +0 -57
  37. package/dist/config/addWorkspace.d.ts +0 -3
  38. package/dist/config/addWorkspace.js +0 -15
  39. package/dist/config/getConfig.d.ts +0 -3
  40. package/dist/config/getConfig.js +0 -34
  41. package/dist/config/getCurrentWorkspace.d.ts +0 -3
  42. package/dist/config/getCurrentWorkspace.js +0 -10
  43. package/dist/config/index.d.ts +0 -7
  44. package/dist/config/index.js +0 -41
  45. package/dist/config/removeWorkspace.d.ts +0 -3
  46. package/dist/config/removeWorkspace.js +0 -6
  47. package/dist/config/saveConfig.d.ts +0 -3
  48. package/dist/config/saveConfig.js +0 -32
  49. package/dist/config/setCurrentWorkspace.d.ts +0 -3
  50. package/dist/config/setCurrentWorkspace.js +0 -11
  51. package/dist/config/types.d.ts +0 -4
  52. package/dist/config/types.js +0 -2
  53. package/dist/config/validations.d.ts +0 -27
  54. package/dist/config/validations.js +0 -34
  55. package/dist/constants.d.ts +0 -6
  56. package/dist/constants.js +0 -29
  57. package/dist/utils/assignTwilioNumberToTrunk.d.ts +0 -3
  58. package/dist/utils/assignTwilioNumberToTrunk.js +0 -33
  59. package/dist/utils/createTwilioTrunk.d.ts +0 -4
  60. package/dist/utils/createTwilioTrunk.js +0 -54
  61. package/dist/utils/getFonosterNumberByTelUrl.d.ts +0 -4
  62. package/dist/utils/getFonosterNumberByTelUrl.js +0 -76
  63. package/dist/utils/getFonosterTrunkByInboundUri.d.ts +0 -4
  64. package/dist/utils/getFonosterTrunkByInboundUri.js +0 -76
  65. package/dist/utils/getTwilioNumber.d.ts +0 -4
  66. package/dist/utils/getTwilioNumber.js +0 -23
  67. package/dist/utils/getTwilioTrunk.d.ts +0 -4
  68. package/dist/utils/getTwilioTrunk.js +0 -23
  69. package/dist/utils/index.d.ts +0 -8
  70. package/dist/utils/index.js +0 -42
  71. package/dist/utils/linkTwilioNumberToApplication.d.ts +0 -5
  72. package/dist/utils/linkTwilioNumberToApplication.js +0 -128
  73. package/dist/utils/types.d.ts +0 -14
  74. package/dist/utils/types.js +0 -2
@@ -1,155 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
36
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
37
- return new (P || (P = Promise))(function (resolve, reject) {
38
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
39
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
40
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
41
- step((generator = generator.apply(thisArg, _arguments || [])).next());
42
- });
43
- };
44
- Object.defineProperty(exports, "__esModule", { value: true });
45
- /* eslint-disable import/no-unresolved */
46
- /*
47
- * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com)
48
- * http://github.com/fonoster/fonoster
49
- *
50
- * This file is part of Fonoster
51
- *
52
- * Licensed under the MIT License (the "License");
53
- * you may not use this file except in compliance with
54
- * the License. You may obtain a copy of the License at
55
- *
56
- * https://opensource.org/licenses/MIT
57
- *
58
- * Unless required by applicable law or agreed to in writing, software
59
- * distributed under the License is distributed on an "AS IS" BASIS,
60
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
61
- * See the License for the specific language governing permissions and
62
- * limitations under the License.
63
- */
64
- const Fonoster = __importStar(require("@fonoster/sdk"));
65
- const prompts_1 = require("@inquirer/prompts");
66
- const core_1 = require("@oclif/core");
67
- const twilio_1 = require("twilio");
68
- const BaseCommand_1 = require("../../BaseCommand");
69
- const config_1 = require("../../config");
70
- const constants_1 = require("../../constants");
71
- const utils_1 = require("../../utils");
72
- class LinkTwilioNumber extends BaseCommand_1.BaseCommand {
73
- run() {
74
- return __awaiter(this, void 0, void 0, function* () {
75
- const { flags } = yield this.parse(LinkTwilioNumber);
76
- const workspaces = (0, config_1.getConfig)(constants_1.CONFIG_FILE);
77
- const currentWorkspace = workspaces.find((w) => w.active);
78
- const accessKeyId = `WO${currentWorkspace.workspaceRef.replaceAll("-", "")}`;
79
- if (!currentWorkspace) {
80
- this.error("No active workspace found.");
81
- }
82
- const fonosterClient = new Fonoster.Client({
83
- endpoint: currentWorkspace.endpoint,
84
- accessKeyId,
85
- allowInsecure: flags.insecure
86
- });
87
- yield fonosterClient.loginWithApiKey(currentWorkspace.accessKeyId, currentWorkspace.accessKeySecret);
88
- const applications = new Fonoster.Applications(fonosterClient);
89
- const appsList = yield applications.listApplications({ pageSize: 1000 });
90
- this.log("This utility will help you create an Application.");
91
- this.log("Press ^C at any time to quit.");
92
- const answers = {
93
- number: yield (0, prompts_1.input)({
94
- message: "Number to link (E.164 format)",
95
- required: true
96
- }),
97
- friendlyName: yield (0, prompts_1.input)({
98
- message: "Friendly Name"
99
- }),
100
- applicationRef: yield (0, prompts_1.select)({
101
- message: "Application",
102
- choices: appsList.items.map((app) => ({
103
- name: app.name,
104
- value: app.ref
105
- }))
106
- }),
107
- twilioAccountSid: yield (0, prompts_1.input)({
108
- message: "Twilio Account SID",
109
- required: true
110
- }),
111
- twilioAuthToken: yield (0, prompts_1.password)({
112
- message: "Twilio Auth Token"
113
- }),
114
- confirm: yield (0, prompts_1.confirm)({
115
- message: "Ready?"
116
- })
117
- };
118
- if (!answers.confirm) {
119
- this.log("Aborted!");
120
- return;
121
- }
122
- try {
123
- const twilioClient = new twilio_1.Twilio(answers.twilioAccountSid, answers.twilioAuthToken);
124
- yield (0, utils_1.linkTwilioNumberToApplication)(twilioClient, fonosterClient, {
125
- phoneNumber: answers.number,
126
- accessKeyId,
127
- aclEntries: flags["access-control-list"].split(","),
128
- originationUriBase: flags["outbound-uri-base"],
129
- applicationRef: answers.applicationRef,
130
- friendlyName: answers.friendlyName
131
- });
132
- }
133
- catch (error) {
134
- this.error(`Failed to link number: ${error.message}`);
135
- }
136
- });
137
- }
138
- }
139
- LinkTwilioNumber.description = "connect a Twilio number to a Fonoster application";
140
- LinkTwilioNumber.examples = ["<%= config.bin %> <%= command.id %>"];
141
- LinkTwilioNumber.flags = {
142
- "outbound-uri-base": core_1.Flags.string({
143
- char: "b",
144
- description: "the uri to point twilio to for outbound calls (use if running your Fonoster instance)",
145
- default: constants_1.FONOSTER_ORIGINATION_URI_BASE,
146
- required: false
147
- }),
148
- "access-control-list": core_1.Flags.string({
149
- char: "a",
150
- description: "the access control list to allow (use if running your Fonoster instance)",
151
- default: constants_1.FONOSTER_ACCESS_CONTROL_LIST.join(","),
152
- required: false
153
- })
154
- };
155
- exports.default = LinkTwilioNumber;
@@ -1,9 +0,0 @@
1
- import { BaseCommand } from "../../BaseCommand";
2
- export default class List extends BaseCommand<typeof List> {
3
- static description: string;
4
- static examples: string[];
5
- static flags: {
6
- "page-size": import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
7
- };
8
- run(): Promise<void>;
9
- }
@@ -1,116 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
36
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
37
- return new (P || (P = Promise))(function (resolve, reject) {
38
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
39
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
40
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
41
- step((generator = generator.apply(thisArg, _arguments || [])).next());
42
- });
43
- };
44
- var __importDefault = (this && this.__importDefault) || function (mod) {
45
- return (mod && mod.__esModule) ? mod : { "default": mod };
46
- };
47
- Object.defineProperty(exports, "__esModule", { value: true });
48
- /* 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 BaseCommand_1 = require("../../BaseCommand");
71
- const config_1 = require("../../config");
72
- const constants_1 = require("../../constants");
73
- class List extends BaseCommand_1.BaseCommand {
74
- run() {
75
- return __awaiter(this, void 0, void 0, function* () {
76
- const { flags } = yield this.parse(List);
77
- const workspaces = (0, config_1.getConfig)(constants_1.CONFIG_FILE);
78
- const currentWorkspace = workspaces.find((w) => w.active);
79
- if (!currentWorkspace) {
80
- this.error("No active workspace found.");
81
- }
82
- const client = new SDK.Client({
83
- endpoint: currentWorkspace.endpoint,
84
- accessKeyId: `WO${currentWorkspace.workspaceRef.replaceAll("-", "")}`,
85
- allowInsecure: flags.insecure
86
- });
87
- yield client.loginWithApiKey(currentWorkspace.accessKeyId, currentWorkspace.accessKeySecret);
88
- const numbers = new SDK.Numbers(client);
89
- const response = yield numbers.listNumbers({
90
- pageSize: parseInt(flags["page-size"]),
91
- pageToken: ""
92
- });
93
- const ui = (0, cliui_1.default)({ width: 200 });
94
- ui.div({ text: "REF", padding: [0, 0, 0, 0], width: 40 }, { text: "NAME", padding: [0, 0, 0, 0], width: 30 }, { text: "TEL URL", padding: [0, 0, 0, 0], width: 25 }, { text: "APP REF", padding: [0, 0, 0, 0], width: 40 });
95
- response.items.forEach((number) => {
96
- ui.div({ text: number.ref, padding: [0, 0, 0, 0], width: 40 }, { text: number.name, padding: [0, 0, 0, 0], width: 30 }, {
97
- text: `${number.telUrl} (${number.countryIsoCode})`,
98
- padding: [0, 0, 0, 0],
99
- width: 25
100
- }, { text: number.appRef, padding: [0, 0, 0, 0], width: 40 });
101
- });
102
- this.log(ui.toString());
103
- });
104
- }
105
- }
106
- List.description = "list all existing Numbers";
107
- List.examples = ["<%= config.bin %> <%= command.id %>"];
108
- List.flags = {
109
- "page-size": core_1.Flags.string({
110
- char: "s",
111
- description: "the number of items to return",
112
- default: "1000",
113
- required: false
114
- })
115
- };
116
- exports.default = List;
@@ -1,6 +0,0 @@
1
- import { Command } from "@oclif/core";
2
- export default class Current extends Command {
3
- static description: string;
4
- static examples: string[];
5
- run(): Promise<void>;
6
- }
@@ -1,46 +0,0 @@
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
- Object.defineProperty(exports, "__esModule", { value: true });
12
- /* eslint-disable import/no-unresolved */
13
- /*
14
- * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com)
15
- * http://github.com/fonoster/fonoster
16
- *
17
- * This file is part of Fonoster
18
- *
19
- * Licensed under the MIT License (the "License");
20
- * you may not use this file except in compliance with
21
- * the License. You may obtain a copy of the License at
22
- *
23
- * https://opensource.org/licenses/MIT
24
- *
25
- * Unless required by applicable law or agreed to in writing, software
26
- * distributed under the License is distributed on an "AS IS" BASIS,
27
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
28
- * See the License for the specific language governing permissions and
29
- * limitations under the License.
30
- */
31
- const core_1 = require("@oclif/core");
32
- const config_1 = require("../../config");
33
- const constants_1 = require("../../constants");
34
- class Current extends core_1.Command {
35
- run() {
36
- return __awaiter(this, void 0, void 0, function* () {
37
- const workspaces = (0, config_1.getConfig)(constants_1.CONFIG_FILE);
38
- const currentWorkspace = workspaces.find((w) => w.active === true);
39
- const { workspaceName, workspaceRef } = currentWorkspace;
40
- this.log(`Current Workspace: ${workspaceName} (${workspaceRef})`);
41
- });
42
- }
43
- }
44
- Current.description = "show the name of the current Workspace";
45
- Current.examples = ["<%= config.bin %> <%= command.id %>"];
46
- exports.default = Current;
@@ -1,6 +0,0 @@
1
- import { Command } from "@oclif/core";
2
- export default class List extends Command {
3
- static description: string;
4
- static examples: string[];
5
- run(): Promise<void>;
6
- }
@@ -1,53 +0,0 @@
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 __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- /* eslint-disable import/no-unresolved */
16
- /*
17
- * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com)
18
- * http://github.com/fonoster/fonoster
19
- *
20
- * This file is part of Fonoster
21
- *
22
- * Licensed under the MIT License (the "License");
23
- * you may not use this file except in compliance with
24
- * the License. You may obtain a copy of the License at
25
- *
26
- * https://opensource.org/licenses/MIT
27
- *
28
- * Unless required by applicable law or agreed to in writing, software
29
- * distributed under the License is distributed on an "AS IS" BASIS,
30
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
31
- * See the License for the specific language governing permissions and
32
- * limitations under the License.
33
- */
34
- const core_1 = require("@oclif/core");
35
- const cliui_1 = __importDefault(require("cliui"));
36
- const config_1 = require("../../config");
37
- const constants_1 = require("../../constants");
38
- class List extends core_1.Command {
39
- run() {
40
- return __awaiter(this, void 0, void 0, function* () {
41
- const workspaces = (0, config_1.getConfig)(constants_1.CONFIG_FILE);
42
- const ui = (0, cliui_1.default)({ width: 120 });
43
- ui.div({ text: "REF", padding: [0, 0, 0, 0] }, { text: "NAME", padding: [0, 0, 0, 0] }, { text: "STATUS", padding: [0, 0, 0, 0] });
44
- workspaces.forEach((workspace) => {
45
- ui.div({ text: workspace.workspaceRef, padding: [0, 0, 0, 0] }, { text: workspace.workspaceName, padding: [0, 0, 0, 0] }, { text: workspace.active ? "[ACTIVE]" : "", padding: [0, 0, 0, 0] });
46
- });
47
- this.log(ui.toString());
48
- });
49
- }
50
- }
51
- List.description = "list all linked Workspaces";
52
- List.examples = ["<%= config.bin %> <%= command.id %>"];
53
- exports.default = List;
@@ -1,8 +0,0 @@
1
- import { BaseCommand } from "../../BaseCommand";
2
- export default class Login extends BaseCommand<typeof Login> {
3
- static description: string;
4
- static examples: string[];
5
- run(): Promise<void>;
6
- private saveConfig;
7
- private getWorkspaceFromDB;
8
- }
@@ -1,145 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
36
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
37
- return new (P || (P = Promise))(function (resolve, reject) {
38
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
39
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
40
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
41
- step((generator = generator.apply(thisArg, _arguments || [])).next());
42
- });
43
- };
44
- Object.defineProperty(exports, "__esModule", { value: true });
45
- /* eslint-disable import/no-unresolved */
46
- /*
47
- * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com)
48
- * http://github.com/fonoster/fonoster
49
- *
50
- * This file is part of Fonoster
51
- *
52
- * Licensed under the MIT License (the "License");
53
- * you may not use this file except in compliance with
54
- * the License. You may obtain a copy of the License at
55
- *
56
- * https://opensource.org/licenses/MIT
57
- *
58
- * Unless required by applicable law or agreed to in writing, software
59
- * distributed under the License is distributed on an "AS IS" BASIS,
60
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
61
- * See the License for the specific language governing permissions and
62
- * limitations under the License.
63
- */
64
- const SDK = __importStar(require("@fonoster/sdk"));
65
- const prompts_1 = require("@inquirer/prompts");
66
- const BaseCommand_1 = require("../../BaseCommand");
67
- const config_1 = require("../../config");
68
- const saveConfig_1 = require("../../config/saveConfig");
69
- const constants_1 = require("../../constants");
70
- class Login extends BaseCommand_1.BaseCommand {
71
- run() {
72
- return __awaiter(this, void 0, void 0, function* () {
73
- this.log("This utility will help you add a Workspace.");
74
- this.log("Press ^C at any time to quit.");
75
- const answers = {
76
- endpoint: yield (0, prompts_1.input)({
77
- message: "Endpoint",
78
- default: "api.fonoster.dev"
79
- }),
80
- accessKeyId: yield (0, prompts_1.input)({
81
- message: "Access Key Id",
82
- required: true
83
- }),
84
- accessKeySecret: yield (0, prompts_1.password)({
85
- message: "Access Key Secret"
86
- }),
87
- confirm: yield (0, prompts_1.confirm)({
88
- message: "Ready?"
89
- })
90
- };
91
- if (!answers.confirm) {
92
- this.log("Aborted!");
93
- return;
94
- }
95
- try {
96
- const workspaceFromDB = yield this.getWorkspaceFromDB(answers);
97
- this.saveConfig(Object.assign(Object.assign({}, answers), { workspaceAccessKeyId: workspaceFromDB.accessKeyId, ref: workspaceFromDB.ref, name: workspaceFromDB.name }));
98
- }
99
- catch (e) {
100
- this.error(e.message);
101
- }
102
- });
103
- }
104
- saveConfig(params) {
105
- const { endpoint, workspaceAccessKeyId, accessKeyId, accessKeySecret, ref: workspaceRef, name: workspaceName } = params;
106
- const workspace = {
107
- workspaceAccessKeyId,
108
- endpoint,
109
- accessKeyId,
110
- accessKeySecret,
111
- workspaceRef,
112
- workspaceName
113
- };
114
- const config = (0, config_1.getConfig)(constants_1.CONFIG_FILE);
115
- const updatedConfig = (0, config_1.addWorkspace)(workspace, config);
116
- (0, saveConfig_1.saveConfig)(constants_1.CONFIG_FILE, updatedConfig);
117
- this.log("Added Workspace!");
118
- }
119
- getWorkspaceFromDB(params) {
120
- return __awaiter(this, void 0, void 0, function* () {
121
- const { flags } = yield this.parse(Login);
122
- const { endpoint, accessKeyId, accessKeySecret } = params;
123
- const client = new SDK.Client({
124
- endpoint,
125
- accessKeyId,
126
- allowInsecure: flags.insecure
127
- });
128
- try {
129
- yield client.loginWithApiKey(accessKeyId, accessKeySecret);
130
- const workspaces = new SDK.Workspaces(client);
131
- const workspaceFromDB = (yield workspaces.listWorkspaces()).items[0];
132
- if (!workspaceFromDB) {
133
- this.error("Invalid credentials!");
134
- }
135
- return workspaceFromDB;
136
- }
137
- catch (e) {
138
- this.error(e.message);
139
- }
140
- });
141
- }
142
- }
143
- Login.description = "add a Workspace to the local environment";
144
- Login.examples = ["<%= config.bin %> <%= command.id %>"];
145
- exports.default = Login;
@@ -1,9 +0,0 @@
1
- import { Command } from "@oclif/core";
2
- export default class Logout extends Command {
3
- static description: string;
4
- static examples: string[];
5
- static args: {
6
- ref: import("@oclif/core/lib/interfaces").Arg<string, Record<string, unknown>>;
7
- };
8
- run(): Promise<void>;
9
- }
@@ -1,54 +0,0 @@
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
- Object.defineProperty(exports, "__esModule", { value: true });
12
- /* eslint-disable import/no-unresolved */
13
- /*
14
- * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com)
15
- * http://github.com/fonoster/fonoster
16
- *
17
- * This file is part of Fonoster
18
- *
19
- * Licensed under the MIT License (the "License");
20
- * you may not use this file except in compliance with
21
- * the License. You may obtain a copy of the License at
22
- *
23
- * https://opensource.org/licenses/MIT
24
- *
25
- * Unless required by applicable law or agreed to in writing, software
26
- * distributed under the License is distributed on an "AS IS" BASIS,
27
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
28
- * See the License for the specific language governing permissions and
29
- * limitations under the License.
30
- */
31
- const core_1 = require("@oclif/core");
32
- const config_1 = require("../../config");
33
- const saveConfig_1 = require("../../config/saveConfig");
34
- const constants_1 = require("../../constants");
35
- class Logout extends core_1.Command {
36
- run() {
37
- return __awaiter(this, void 0, void 0, function* () {
38
- const { args } = yield this.parse(Logout);
39
- if (!args.ref) {
40
- this.error("Missing Workspace reference");
41
- }
42
- const workspaces = (0, config_1.getConfig)(constants_1.CONFIG_FILE);
43
- const updatedWorkspaces = (0, config_1.removeWorkspace)(args.ref, workspaces);
44
- (0, saveConfig_1.saveConfig)(constants_1.CONFIG_FILE, updatedWorkspaces);
45
- this.log("Done!");
46
- });
47
- }
48
- }
49
- Logout.description = "remove a linked Workspace";
50
- Logout.examples = ["<%= config.bin %> <%= command.id %>"];
51
- Logout.args = {
52
- ref: core_1.Args.string({ description: "the Workspace to unlink from" })
53
- };
54
- exports.default = Logout;
@@ -1,9 +0,0 @@
1
- import { Command } from "@oclif/core";
2
- export default class Use extends Command {
3
- static description: string;
4
- static examples: string[];
5
- static args: {
6
- ref: import("@oclif/core/lib/interfaces").Arg<string, Record<string, unknown>>;
7
- };
8
- run(): Promise<void>;
9
- }