@fonoster/ctl 0.7.44 → 0.7.45

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (163) hide show
  1. package/README.md +1 -1
  2. package/bin/run.js +0 -18
  3. package/dist/AuthenticatedCommand.d.ts +6 -0
  4. package/dist/AuthenticatedCommand.js +92 -0
  5. package/dist/BaseCommand.d.ts +15 -0
  6. package/dist/BaseCommand.js +80 -0
  7. package/dist/Help.d.ts +6 -0
  8. package/dist/Help.js +52 -0
  9. package/dist/commands/apikeys/create.d.ts +10 -0
  10. package/dist/commands/apikeys/create.js +99 -0
  11. package/dist/commands/apikeys/delete.d.ts +9 -0
  12. package/dist/commands/apikeys/delete.js +87 -0
  13. package/dist/commands/apikeys/list.d.ts +9 -0
  14. package/dist/commands/apikeys/list.js +105 -0
  15. package/dist/commands/apikeys/regenerate.d.ts +9 -0
  16. package/dist/commands/apikeys/regenerate.js +91 -0
  17. package/dist/commands/applications/create.d.ts +6 -0
  18. package/dist/commands/applications/create.js +155 -0
  19. package/dist/commands/applications/delete.d.ts +9 -0
  20. package/dist/commands/applications/delete.js +87 -0
  21. package/dist/commands/applications/get.d.ts +9 -0
  22. package/dist/commands/applications/get.js +107 -0
  23. package/dist/commands/applications/list.d.ts +9 -0
  24. package/dist/commands/applications/list.js +99 -0
  25. package/dist/commands/applications/update.d.ts +9 -0
  26. package/dist/commands/applications/update.js +172 -0
  27. package/dist/commands/bug.d.ts +6 -0
  28. package/dist/commands/bug.js +42 -0
  29. package/dist/commands/feedback.d.ts +6 -0
  30. package/dist/commands/feedback.js +45 -0
  31. package/dist/commands/secrets/create.d.ts +6 -0
  32. package/dist/commands/secrets/create.js +106 -0
  33. package/dist/commands/secrets/delete.d.ts +9 -0
  34. package/dist/commands/secrets/delete.js +87 -0
  35. package/dist/commands/secrets/get.d.ts +9 -0
  36. package/dist/commands/secrets/get.js +95 -0
  37. package/dist/commands/secrets/list.d.ts +9 -0
  38. package/dist/commands/secrets/list.js +99 -0
  39. package/dist/commands/secrets/update.d.ts +9 -0
  40. package/dist/commands/secrets/update.js +116 -0
  41. package/dist/commands/sipnet/acls/create.d.ts +6 -0
  42. package/dist/commands/sipnet/acls/create.js +107 -0
  43. package/dist/commands/sipnet/acls/delete.d.ts +9 -0
  44. package/dist/commands/sipnet/acls/delete.js +87 -0
  45. package/dist/commands/sipnet/acls/get.d.ts +9 -0
  46. package/dist/commands/sipnet/acls/get.js +100 -0
  47. package/dist/commands/sipnet/acls/list.d.ts +9 -0
  48. package/dist/commands/sipnet/acls/list.js +99 -0
  49. package/dist/commands/sipnet/acls/update.d.ts +9 -0
  50. package/dist/commands/sipnet/acls/update.js +123 -0
  51. package/dist/commands/sipnet/agents/create.d.ts +6 -0
  52. package/dist/commands/sipnet/agents/create.js +132 -0
  53. package/dist/commands/sipnet/agents/delete.d.ts +9 -0
  54. package/dist/commands/sipnet/agents/delete.js +87 -0
  55. package/dist/commands/sipnet/agents/get.d.ts +9 -0
  56. package/dist/commands/sipnet/agents/get.js +109 -0
  57. package/dist/commands/sipnet/agents/list.d.ts +9 -0
  58. package/dist/commands/sipnet/agents/list.js +99 -0
  59. package/dist/commands/sipnet/agents/update.d.ts +9 -0
  60. package/dist/commands/sipnet/agents/update.js +149 -0
  61. package/dist/commands/sipnet/calls/create.d.ts +13 -0
  62. package/dist/commands/sipnet/calls/create.js +156 -0
  63. package/dist/commands/sipnet/calls/get.d.ts +9 -0
  64. package/dist/commands/sipnet/calls/get.js +104 -0
  65. package/dist/commands/sipnet/calls/list.d.ts +9 -0
  66. package/dist/commands/sipnet/calls/list.js +108 -0
  67. package/dist/commands/sipnet/credentials/create.d.ts +6 -0
  68. package/dist/commands/sipnet/credentials/create.js +110 -0
  69. package/dist/commands/sipnet/credentials/delete.d.ts +9 -0
  70. package/dist/commands/sipnet/credentials/delete.js +87 -0
  71. package/dist/commands/sipnet/credentials/get.d.ts +9 -0
  72. package/dist/commands/sipnet/credentials/get.js +100 -0
  73. package/dist/commands/sipnet/credentials/list.d.ts +9 -0
  74. package/dist/commands/sipnet/credentials/list.js +99 -0
  75. package/dist/commands/sipnet/credentials/update.d.ts +9 -0
  76. package/dist/commands/sipnet/credentials/update.js +121 -0
  77. package/dist/commands/sipnet/domains/create.d.ts +6 -0
  78. package/dist/commands/sipnet/domains/create.js +107 -0
  79. package/dist/commands/sipnet/domains/delete.d.ts +9 -0
  80. package/dist/commands/sipnet/domains/delete.js +87 -0
  81. package/dist/commands/sipnet/domains/get.d.ts +9 -0
  82. package/dist/commands/sipnet/domains/get.js +100 -0
  83. package/dist/commands/sipnet/domains/list.d.ts +9 -0
  84. package/dist/commands/sipnet/domains/list.js +99 -0
  85. package/dist/commands/sipnet/domains/update.d.ts +9 -0
  86. package/dist/commands/sipnet/domains/update.js +118 -0
  87. package/dist/commands/sipnet/numbers/create.d.ts +6 -0
  88. package/dist/commands/sipnet/numbers/create.js +148 -0
  89. package/dist/commands/sipnet/numbers/delete.d.ts +9 -0
  90. package/dist/commands/sipnet/numbers/delete.js +87 -0
  91. package/dist/commands/sipnet/numbers/get.d.ts +9 -0
  92. package/dist/commands/sipnet/numbers/get.js +119 -0
  93. package/dist/commands/sipnet/numbers/linkTwilioNumber.d.ts +10 -0
  94. package/dist/commands/sipnet/numbers/linkTwilioNumber.js +150 -0
  95. package/dist/commands/sipnet/numbers/list.d.ts +9 -0
  96. package/dist/commands/sipnet/numbers/list.js +111 -0
  97. package/dist/commands/sipnet/numbers/update.d.ts +9 -0
  98. package/dist/commands/sipnet/numbers/update.js +136 -0
  99. package/dist/commands/sipnet/trunks/create.d.ts +6 -0
  100. package/dist/commands/sipnet/trunks/create.js +156 -0
  101. package/dist/commands/sipnet/trunks/delete.d.ts +9 -0
  102. package/dist/commands/sipnet/trunks/delete.js +87 -0
  103. package/dist/commands/sipnet/trunks/get.d.ts +9 -0
  104. package/dist/commands/sipnet/trunks/get.js +120 -0
  105. package/dist/commands/sipnet/trunks/list.d.ts +9 -0
  106. package/dist/commands/sipnet/trunks/list.js +99 -0
  107. package/dist/commands/sipnet/trunks/update.d.ts +9 -0
  108. package/dist/commands/sipnet/trunks/update.js +174 -0
  109. package/dist/commands/workspaces/current.d.ts +6 -0
  110. package/dist/commands/workspaces/current.js +46 -0
  111. package/dist/commands/workspaces/list.d.ts +6 -0
  112. package/dist/commands/workspaces/list.js +53 -0
  113. package/dist/commands/workspaces/login.d.ts +8 -0
  114. package/dist/commands/workspaces/login.js +145 -0
  115. package/dist/commands/workspaces/logout.d.ts +9 -0
  116. package/dist/commands/workspaces/logout.js +55 -0
  117. package/dist/commands/workspaces/use.d.ts +9 -0
  118. package/dist/commands/workspaces/use.js +57 -0
  119. package/dist/config/addWorkspace.d.ts +3 -0
  120. package/dist/config/addWorkspace.js +15 -0
  121. package/dist/config/getConfig.d.ts +3 -0
  122. package/dist/config/getConfig.js +34 -0
  123. package/dist/config/getCurrentWorkspace.d.ts +3 -0
  124. package/dist/config/getCurrentWorkspace.js +6 -0
  125. package/dist/config/index.d.ts +7 -0
  126. package/dist/config/index.js +41 -0
  127. package/dist/config/removeWorkspace.d.ts +3 -0
  128. package/dist/config/removeWorkspace.js +6 -0
  129. package/dist/config/saveConfig.d.ts +3 -0
  130. package/dist/config/saveConfig.js +32 -0
  131. package/dist/config/setCurrentWorkspace.d.ts +3 -0
  132. package/dist/config/setCurrentWorkspace.js +11 -0
  133. package/dist/config/types.d.ts +4 -0
  134. package/dist/config/types.js +2 -0
  135. package/dist/config/validations.d.ts +27 -0
  136. package/dist/config/validations.js +34 -0
  137. package/dist/constants.d.ts +6 -0
  138. package/dist/constants.js +29 -0
  139. package/dist/errorHandler.d.ts +2 -0
  140. package/dist/errorHandler.js +31 -0
  141. package/dist/utils/assignTwilioNumberToTrunk.d.ts +3 -0
  142. package/dist/utils/assignTwilioNumberToTrunk.js +33 -0
  143. package/dist/utils/calculateFutureDate.d.ts +2 -0
  144. package/dist/utils/calculateFutureDate.js +37 -0
  145. package/dist/utils/createTwilioTrunk.d.ts +4 -0
  146. package/dist/utils/createTwilioTrunk.js +54 -0
  147. package/dist/utils/getFonosterNumberByTelUrl.d.ts +4 -0
  148. package/dist/utils/getFonosterNumberByTelUrl.js +76 -0
  149. package/dist/utils/getFonosterTrunkByInboundUri.d.ts +4 -0
  150. package/dist/utils/getFonosterTrunkByInboundUri.js +76 -0
  151. package/dist/utils/getOutboundUri.d.ts +7 -0
  152. package/dist/utils/getOutboundUri.js +10 -0
  153. package/dist/utils/getTwilioNumber.d.ts +4 -0
  154. package/dist/utils/getTwilioNumber.js +23 -0
  155. package/dist/utils/getTwilioTrunk.d.ts +4 -0
  156. package/dist/utils/getTwilioTrunk.js +23 -0
  157. package/dist/utils/index.d.ts +9 -0
  158. package/dist/utils/index.js +43 -0
  159. package/dist/utils/linkTwilioNumberToApplication.d.ts +5 -0
  160. package/dist/utils/linkTwilioNumberToApplication.js +128 -0
  161. package/dist/utils/types.d.ts +14 -0
  162. package/dist/utils/types.js +2 -0
  163. package/package.json +3 -3
package/README.md CHANGED
@@ -9,7 +9,7 @@ ctl
9
9
  ## Installation
10
10
 
11
11
  ```sh-session
12
- $ npm install --save @fonoster/ctl@next
12
+ $ npm install --save @fonoster/ctl
13
13
  ```
14
14
 
15
15
  ## Usage
package/bin/run.js CHANGED
@@ -1,21 +1,3 @@
1
- /*
2
- * Copyright (C) 2024 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
1
  #!/usr/bin/env node
20
2
 
21
3
  // eslint-disable-next-line unicorn/prefer-top-level-await
@@ -0,0 +1,6 @@
1
+ import * as SDK from "@fonoster/sdk";
2
+ import { Command } from "@oclif/core";
3
+ import { BaseCommand } from "./BaseCommand";
4
+ export declare abstract class AuthenticatedCommand<T extends typeof Command> extends BaseCommand<T> {
5
+ protected createSdkClient(): Promise<SDK.Client>;
6
+ }
@@ -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
+ Object.defineProperty(exports, "__esModule", { value: true });
45
+ exports.AuthenticatedCommand = void 0;
46
+ /* eslint-disable import/no-unresolved */
47
+ /*
48
+ * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com)
49
+ * http://github.com/fonoster/fonoster
50
+ *
51
+ * This file is part of Fonoster
52
+ *
53
+ * Licensed under the MIT License (the "License");
54
+ * you may not use this file except in compliance with
55
+ * the License. You may obtain a copy of the License at
56
+ *
57
+ * https://opensource.org/licenses/MIT
58
+ *
59
+ * Unless required by applicable law or agreed to in writing, software
60
+ * distributed under the License is distributed on an "AS IS" BASIS,
61
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
62
+ * See the License for the specific language governing permissions and
63
+ * limitations under the License.
64
+ */
65
+ const SDK = __importStar(require("@fonoster/sdk"));
66
+ const BaseCommand_1 = require("./BaseCommand"); // Adjust the import based on your structure
67
+ const config_1 = require("./config");
68
+ const constants_1 = require("./constants");
69
+ class AuthenticatedCommand extends BaseCommand_1.BaseCommand {
70
+ createSdkClient() {
71
+ return __awaiter(this, void 0, void 0, function* () {
72
+ const workspaces = (0, config_1.getConfig)(constants_1.CONFIG_FILE);
73
+ const currentWorkspace = (0, config_1.getCurrentWorkspace)(workspaces);
74
+ if (!currentWorkspace) {
75
+ throw new Error("No active workspace found. Please login to a Workspace.");
76
+ }
77
+ try {
78
+ const client = new SDK.Client({
79
+ endpoint: currentWorkspace.endpoint,
80
+ accessKeyId: `WO${currentWorkspace.workspaceRef.replaceAll("-", "")}`,
81
+ allowInsecure: this.flags.insecure
82
+ });
83
+ yield client.loginWithApiKey(currentWorkspace.accessKeyId, currentWorkspace.accessKeySecret);
84
+ return client;
85
+ }
86
+ catch (error) {
87
+ this.error("Failed to initialize the SDK client. Please try by login to the Workspace again.", { exit: 1 });
88
+ }
89
+ });
90
+ }
91
+ }
92
+ exports.AuthenticatedCommand = AuthenticatedCommand;
@@ -0,0 +1,15 @@
1
+ import { Command, Interfaces } from "@oclif/core";
2
+ export type Args<T extends typeof Command> = Interfaces.InferredArgs<T["args"]>;
3
+ export declare abstract class BaseCommand<T extends typeof Command> extends Command {
4
+ static readonly baseFlags: {
5
+ insecure: Interfaces.BooleanFlag<boolean>;
6
+ };
7
+ protected flags: Flags<T>;
8
+ protected args: Args<T>;
9
+ init(): Promise<void>;
10
+ protected catch(err: Error & {
11
+ exitCode?: number;
12
+ }): Promise<any>;
13
+ protected finally(_: Error | undefined): Promise<any>;
14
+ }
15
+ export type Flags<T extends typeof Command> = Interfaces.InferredFlags<(typeof BaseCommand)["baseFlags"] & T["flags"]>;
@@ -0,0 +1,80 @@
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
+ exports.BaseCommand = void 0;
13
+ /* eslint-disable import/no-unresolved */
14
+ /*
15
+ * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com)
16
+ * http://github.com/fonoster/fonoster
17
+ *
18
+ * This file is part of Fonoster
19
+ *
20
+ * Licensed under the MIT License (the "License");
21
+ * you may not use this file except in compliance with
22
+ * the License. You may obtain a copy of the License at
23
+ *
24
+ * https://opensource.org/licenses/MIT
25
+ *
26
+ * Unless required by applicable law or agreed to in writing, software
27
+ * distributed under the License is distributed on an "AS IS" BASIS,
28
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
29
+ * See the License for the specific language governing permissions and
30
+ * limitations under the License.
31
+ */
32
+ const core_1 = require("@oclif/core");
33
+ class BaseCommand extends core_1.Command {
34
+ init() {
35
+ const _super = Object.create(null, {
36
+ init: { get: () => super.init },
37
+ ctor: { get: () => super.ctor }
38
+ });
39
+ return __awaiter(this, void 0, void 0, function* () {
40
+ yield _super.init.call(this);
41
+ const { args, flags } = yield this.parse({
42
+ flags: this.ctor.flags,
43
+ baseFlags: _super.ctor.baseFlags,
44
+ enableJsonFlag: this.ctor.enableJsonFlag,
45
+ args: this.ctor.args,
46
+ strict: this.ctor.strict
47
+ });
48
+ this.flags = flags;
49
+ this.args = args;
50
+ });
51
+ }
52
+ catch(err) {
53
+ const _super = Object.create(null, {
54
+ catch: { get: () => super.catch }
55
+ });
56
+ return __awaiter(this, void 0, void 0, function* () {
57
+ // add any custom logic to handle errors from the command
58
+ // or simply return the parent class error handling
59
+ return _super.catch.call(this, err);
60
+ });
61
+ }
62
+ finally(_) {
63
+ const _super = Object.create(null, {
64
+ finally: { get: () => super.finally }
65
+ });
66
+ return __awaiter(this, void 0, void 0, function* () {
67
+ // called after run and catch regardless of whether or not the command errored
68
+ return _super.finally.call(this, _);
69
+ });
70
+ }
71
+ }
72
+ exports.BaseCommand = BaseCommand;
73
+ // define flags that can be inherited by any command that extends BaseCommand
74
+ BaseCommand.baseFlags = {
75
+ insecure: core_1.Flags.boolean({
76
+ char: "i",
77
+ description: "allow connections to a server with no TLS",
78
+ default: false
79
+ })
80
+ };
package/dist/Help.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ import { Help } from "@oclif/core";
2
+ export default class CustomHelp extends Help {
3
+ protected showRootHelp(): Promise<void>;
4
+ private showLogo;
5
+ private get customCommands();
6
+ }
package/dist/Help.js ADDED
@@ -0,0 +1,52 @@
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
+ /*
7
+ * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com)
8
+ * http://github.com/fonoster/fonoster
9
+ *
10
+ * This file is part of Fonoster
11
+ *
12
+ * Licensed under the MIT License (the "License");
13
+ * you may not use this file except in compliance with
14
+ * the License. You may obtain a copy of the License at
15
+ *
16
+ * https://opensource.org/licenses/MIT
17
+ *
18
+ * Unless required by applicable law or agreed to in writing, software
19
+ * distributed under the License is distributed on an "AS IS" BASIS,
20
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21
+ * See the License for the specific language governing permissions and
22
+ * limitations under the License.
23
+ */
24
+ // eslint-disable-next-line import/no-unresolved
25
+ const core_1 = require("@oclif/core");
26
+ const figlet_1 = __importDefault(require("figlet"));
27
+ class CustomHelp extends core_1.Help {
28
+ showRootHelp() {
29
+ this.showLogo();
30
+ this.log(this.formatRoot());
31
+ this.log("");
32
+ this.log(this.formatCommands(this.customCommands));
33
+ this.log("");
34
+ return Promise.resolve();
35
+ }
36
+ showLogo() {
37
+ this.log("\x1b[32m");
38
+ this.log(figlet_1.default.textSync("Fonoster", {
39
+ horizontalLayout: "default",
40
+ verticalLayout: "default",
41
+ width: 60,
42
+ whitespaceBreak: true
43
+ }));
44
+ this.log("\x1b[0m");
45
+ }
46
+ get customCommands() {
47
+ return this.sortedCommands
48
+ .filter((c) => c.id)
49
+ .sort((a, b) => (a.id.includes(":") ? 1 : b.id.includes(":") ? -1 : 0));
50
+ }
51
+ }
52
+ exports.default = CustomHelp;
@@ -0,0 +1,10 @@
1
+ import { AuthenticatedCommand } from "../../AuthenticatedCommand";
2
+ export default class Create extends AuthenticatedCommand<typeof Create> {
3
+ static readonly description = "create an API key for the active Workspace";
4
+ static readonly examples: string[];
5
+ static readonly flags: {
6
+ expiration: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
7
+ role: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
8
+ };
9
+ run(): Promise<void>;
10
+ }
@@ -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
+ 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 core_1 = require("@oclif/core");
66
+ const AuthenticatedCommand_1 = require("../../AuthenticatedCommand");
67
+ class Create extends AuthenticatedCommand_1.AuthenticatedCommand {
68
+ run() {
69
+ return __awaiter(this, void 0, void 0, function* () {
70
+ const { flags } = yield this.parse(Create);
71
+ const sdkClient = yield this.createSdkClient();
72
+ const apiKeys = new SDK.ApiKeys(sdkClient);
73
+ const result = yield apiKeys.createApiKey({
74
+ role: flags.role
75
+ });
76
+ this.log("Access Key regenerated successfully!");
77
+ this.log(`Access Key ID: ${result.accessKeyId}`);
78
+ this.log(`Access Key Secret: ${result.accessKeySecret}`);
79
+ this.log("");
80
+ this.warn("This is the only time the Access Key Secret will be shown.\nPlease copy it and store it securely!");
81
+ });
82
+ }
83
+ }
84
+ Create.description = "create an API key for the active Workspace";
85
+ Create.examples = ["<%= config.bin %> <%= command.id %>"];
86
+ Create.flags = {
87
+ expiration: core_1.Flags.string({
88
+ char: "e",
89
+ description: "API Key expiration time in days(e.g. 10d) or months(e.g. 10m)",
90
+ required: false
91
+ }),
92
+ role: core_1.Flags.string({
93
+ char: "r",
94
+ description: "API Key role",
95
+ default: "WORKSPACE_ADMIN",
96
+ required: false
97
+ })
98
+ };
99
+ 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 an API key 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,87 @@
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 core_1 = require("@oclif/core");
66
+ const AuthenticatedCommand_1 = require("../../AuthenticatedCommand");
67
+ class Delete extends AuthenticatedCommand_1.AuthenticatedCommand {
68
+ run() {
69
+ return __awaiter(this, void 0, void 0, function* () {
70
+ const { args } = yield this.parse(Delete);
71
+ const { ref } = args;
72
+ const client = yield this.createSdkClient();
73
+ const applications = new SDK.ApiKeys(client);
74
+ yield applications.deleteApiKey(ref);
75
+ this.log("Done!");
76
+ });
77
+ }
78
+ }
79
+ Delete.description = "delete an API key from the active Workspace";
80
+ Delete.examples = ["<%= config.bin %> <%= command.id %>"];
81
+ Delete.args = {
82
+ ref: core_1.Args.string({
83
+ description: "the ApiKey to delete from the Workspace",
84
+ required: true
85
+ })
86
+ };
87
+ exports.default = Delete;
@@ -0,0 +1,9 @@
1
+ import { AuthenticatedCommand } from "../../AuthenticatedCommand";
2
+ export default class List extends AuthenticatedCommand<typeof List> {
3
+ static readonly description = "display all API keys 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,105 @@
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 apiKeys = new SDK.ApiKeys(client);
77
+ const response = yield apiKeys.listApiKeys({
78
+ pageSize: parseInt(flags["page-size"])
79
+ });
80
+ const ui = (0, cliui_1.default)({ width: 170 });
81
+ ui.div({ text: "REF", padding: [0, 0, 0, 0], width: 40 }, { text: "ACCESS KEY ID", padding: [0, 0, 0, 0], width: 38 }, { text: "ROLE", padding: [0, 0, 0, 0], width: 20 }, { text: "EXPIRATION", padding: [0, 0, 0, 0], width: 10 });
82
+ response.items.forEach((application) => {
83
+ ui.div({ text: application.ref, padding: [0, 0, 0, 0], width: 40 }, { text: application.accessKeyId, padding: [0, 0, 0, 0], width: 38 }, { text: application.role, padding: [0, 0, 0, 0], width: 20 }, {
84
+ text: application.expiresAt
85
+ ? new Date(application.expiresAt).toISOString()
86
+ : "Never",
87
+ padding: [0, 0, 0, 0],
88
+ width: 10
89
+ });
90
+ });
91
+ this.log(ui.toString());
92
+ });
93
+ }
94
+ }
95
+ List.description = "display all API keys in the active Workspace";
96
+ List.examples = ["<%= config.bin %> <%= command.id %>"];
97
+ List.flags = {
98
+ "page-size": core_1.Flags.string({
99
+ char: "s",
100
+ description: "the number of items to show",
101
+ default: "1000",
102
+ required: false
103
+ })
104
+ };
105
+ exports.default = List;
@@ -0,0 +1,9 @@
1
+ import { AuthenticatedCommand } from "../../AuthenticatedCommand";
2
+ export default class Regenerate extends AuthenticatedCommand<typeof Regenerate> {
3
+ static readonly description = "generate a new access key secret for an API key";
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
+ }