@open-discord-bots/framework 0.2.11 → 0.2.13

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 (107) hide show
  1. package/dist/api/index.d.ts +26 -26
  2. package/dist/api/index.js +26 -42
  3. package/dist/api/main.d.ts +24 -24
  4. package/dist/api/main.js +7 -11
  5. package/dist/api/modules/action.d.ts +12 -12
  6. package/dist/api/modules/action.js +11 -17
  7. package/dist/api/modules/base.d.ts +7 -5
  8. package/dist/api/modules/base.js +22 -67
  9. package/dist/api/modules/builder.d.ts +44 -44
  10. package/dist/api/modules/builder.js +81 -142
  11. package/dist/api/modules/checker.d.ts +7 -7
  12. package/dist/api/modules/checker.js +55 -87
  13. package/dist/api/modules/client.d.ts +4 -4
  14. package/dist/api/modules/client.js +71 -118
  15. package/dist/api/modules/code.d.ts +2 -2
  16. package/dist/api/modules/code.js +3 -8
  17. package/dist/api/modules/config.d.ts +2 -2
  18. package/dist/api/modules/config.js +21 -63
  19. package/dist/api/modules/console.d.ts +16 -16
  20. package/dist/api/modules/console.js +61 -83
  21. package/dist/api/modules/cooldown.d.ts +2 -2
  22. package/dist/api/modules/cooldown.js +13 -23
  23. package/dist/api/modules/database.d.ts +2 -2
  24. package/dist/api/modules/database.js +19 -29
  25. package/dist/api/modules/event.d.ts +2 -2
  26. package/dist/api/modules/event.js +6 -11
  27. package/dist/api/modules/flag.d.ts +2 -2
  28. package/dist/api/modules/flag.js +3 -8
  29. package/dist/api/modules/fuse.js +2 -7
  30. package/dist/api/modules/helpmenu.d.ts +2 -2
  31. package/dist/api/modules/helpmenu.js +8 -16
  32. package/dist/api/modules/language.d.ts +2 -2
  33. package/dist/api/modules/language.js +12 -21
  34. package/dist/api/modules/permission.d.ts +3 -3
  35. package/dist/api/modules/permission.js +9 -47
  36. package/dist/api/modules/plugin.d.ts +2 -2
  37. package/dist/api/modules/plugin.js +9 -18
  38. package/dist/api/modules/post.d.ts +3 -3
  39. package/dist/api/modules/post.js +3 -8
  40. package/dist/api/modules/progressbar.d.ts +2 -2
  41. package/dist/api/modules/progressbar.js +14 -26
  42. package/dist/api/modules/responder.d.ts +42 -42
  43. package/dist/api/modules/responder.js +79 -138
  44. package/dist/api/modules/session.d.ts +2 -2
  45. package/dist/api/modules/session.js +4 -42
  46. package/dist/api/modules/startscreen.d.ts +4 -4
  47. package/dist/api/modules/startscreen.js +28 -44
  48. package/dist/api/modules/statistic.d.ts +3 -3
  49. package/dist/api/modules/statistic.js +11 -22
  50. package/dist/api/modules/verifybar.d.ts +5 -5
  51. package/dist/api/modules/verifybar.js +6 -11
  52. package/dist/api/modules/worker.d.ts +15 -15
  53. package/dist/api/modules/worker.js +12 -17
  54. package/dist/cli/editConfig.d.ts +2 -2
  55. package/dist/cli/editConfig.js +194 -248
  56. package/dist/cli/index.d.ts +2 -2
  57. package/dist/cli/index.js +37 -62
  58. package/dist/index.d.ts +4 -4
  59. package/dist/index.js +6 -13
  60. package/dist/startup/compilation.d.ts +1 -1
  61. package/dist/startup/compilation.js +35 -42
  62. package/dist/startup/dump.d.ts +1 -1
  63. package/dist/startup/dump.js +4 -41
  64. package/dist/startup/errorHandling.d.ts +1 -1
  65. package/dist/startup/errorHandling.js +2 -38
  66. package/dist/startup/pluginLauncher.d.ts +1 -1
  67. package/dist/startup/pluginLauncher.js +14 -52
  68. package/dist/utilities/index.d.ts +3 -3
  69. package/dist/utilities/index.js +20 -71
  70. package/package.json +5 -4
  71. package/src/api/index.ts +26 -26
  72. package/src/api/main.ts +25 -25
  73. package/src/api/modules/action.ts +13 -13
  74. package/src/api/modules/base.ts +14 -10
  75. package/src/api/modules/builder.ts +56 -56
  76. package/src/api/modules/checker.ts +7 -7
  77. package/src/api/modules/client.ts +18 -18
  78. package/src/api/modules/code.ts +2 -2
  79. package/src/api/modules/component.txt +350 -0
  80. package/src/api/modules/config.ts +3 -3
  81. package/src/api/modules/console.ts +28 -28
  82. package/src/api/modules/cooldown.ts +2 -2
  83. package/src/api/modules/database.ts +3 -3
  84. package/src/api/modules/event.ts +5 -5
  85. package/src/api/modules/flag.ts +2 -2
  86. package/src/api/modules/helpmenu.ts +4 -4
  87. package/src/api/modules/language.ts +3 -3
  88. package/src/api/modules/permission.ts +3 -3
  89. package/src/api/modules/plugin.ts +4 -4
  90. package/src/api/modules/post.ts +3 -3
  91. package/src/api/modules/progressbar.ts +5 -3
  92. package/src/api/modules/responder.ts +48 -48
  93. package/src/api/modules/session.ts +2 -2
  94. package/src/api/modules/startscreen.ts +4 -4
  95. package/src/api/modules/statistic.ts +3 -4
  96. package/src/api/modules/verifybar.ts +5 -5
  97. package/src/api/modules/worker.ts +25 -25
  98. package/src/cli/editConfig.ts +23 -37
  99. package/src/cli/index.ts +3 -3
  100. package/src/index.ts +5 -5
  101. package/src/startup/compilation.ts +2 -2
  102. package/src/startup/dump.ts +2 -2
  103. package/src/startup/errorHandling.ts +2 -2
  104. package/src/startup/pluginLauncher.ts +11 -8
  105. package/src/utilities/index.ts +4 -4
  106. package/tools/cleanup.js +1 -1
  107. package/tsconfig.json +2 -1
@@ -1,48 +1,9 @@
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 __importDefault = (this && this.__importDefault) || function (mod) {
36
- return (mod && mod.__esModule) ? mod : { "default": mod };
37
- };
38
- Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.ODCliEditConfigInstance = void 0;
40
- const api = __importStar(require("../api/index"));
41
- const utilities = __importStar(require("../utilities/index"));
42
- const terminal_kit_1 = require("terminal-kit");
43
- const ansis_1 = __importDefault(require("ansis"));
44
- const _1 = require(".");
45
- class ODCliEditConfigInstance {
1
+ import * as api from "../api/index.js";
2
+ import * as utilities from "../utilities/index.js";
3
+ import { terminal } from "terminal-kit";
4
+ import ansis from "ansis";
5
+ import { renderHeader } from "./index.js";
6
+ export class ODCliEditConfigInstance {
46
7
  opts;
47
8
  opendiscord;
48
9
  constructor(opts, opendiscord) {
@@ -50,17 +11,17 @@ class ODCliEditConfigInstance {
50
11
  this.opendiscord = opendiscord;
51
12
  }
52
13
  async renderEditConfig(backFn) {
53
- (0, _1.renderHeader)(this.opts, []);
54
- (0, terminal_kit_1.terminal)(ansis_1.default.bold.green("Please select which config you would like to edit.\n") + ansis_1.default.italic.gray("(use arrow keys to navigate, go back using escape)\n"));
14
+ renderHeader(this.opts, []);
15
+ terminal(ansis.bold.green("Please select which config you would like to edit.\n") + ansis.italic.gray("(use arrow keys to navigate, go back using escape)\n"));
55
16
  const checkerList = this.opendiscord.checkers.getAll();
56
17
  const checkerNameList = checkerList.map((checker) => (checker.options.cliDisplayName ? checker.options.cliDisplayName + " (" + checker.config.file + ")" : checker.config.file));
57
18
  const checkerNameLength = utilities.getLongestLength(checkerNameList);
58
- const finalCheckerNameList = checkerNameList.map((name, index) => name.padEnd(checkerNameLength + 5, " ") + ansis_1.default.gray(checkerList[index].options.cliDisplayDescription ? "=> " + checkerList[index].options.cliDisplayDescription : ""));
59
- const answer = await terminal_kit_1.terminal.singleColumnMenu(finalCheckerNameList, {
19
+ const finalCheckerNameList = checkerNameList.map((name, index) => name.padEnd(checkerNameLength + 5, " ") + ansis.gray(checkerList[index].options.cliDisplayDescription ? "=> " + checkerList[index].options.cliDisplayDescription : ""));
20
+ const answer = await terminal.singleColumnMenu(finalCheckerNameList, {
60
21
  leftPadding: "> ",
61
- style: terminal_kit_1.terminal.cyan,
62
- selectedStyle: terminal_kit_1.terminal.bgDefaultColor.bold,
63
- submittedStyle: terminal_kit_1.terminal.bgBlue,
22
+ style: terminal.cyan,
23
+ selectedStyle: terminal.bgDefaultColor.bold,
24
+ submittedStyle: terminal.bgBlue,
64
25
  extraLines: 2,
65
26
  cancelable: true
66
27
  }).promise;
@@ -90,28 +51,28 @@ class ODCliEditConfigInstance {
90
51
  else if (structure instanceof api.ODCheckerTypeSwitchStructure)
91
52
  await this.renderConfigTypeSwitchStructureEditor(checker, backFn, structure, data, parent, parentIndex, path);
92
53
  else
93
- terminal_kit_1.terminal.red.bold("❌ Unable to detect type of variable! Please try to edit this property in the JSON file itself!");
54
+ terminal.red.bold("❌ Unable to detect type of variable! Please try to edit this property in the JSON file itself!");
94
55
  }
95
56
  async renderConfigObjectStructureSelector(checker, backFn, structure, data, parent, parentIndex, path) {
96
57
  if (typeof data != "object" || Array.isArray(data))
97
58
  throw new api.ODSystemError("OD CLI => Property is not of the type 'object'. Please check your config for possible errors. (index: " + parentIndex + ", path: " + path.join(".") + ")");
98
- (0, _1.renderHeader)(this.opts, path);
99
- (0, terminal_kit_1.terminal)(ansis_1.default.bold.green("Please select which variable you would like to edit.\n") + ansis_1.default.italic.gray("(use arrow keys to navigate, go back using escape)\n"));
59
+ renderHeader(this.opts, path);
60
+ terminal(ansis.bold.green("Please select which variable you would like to edit.\n") + ansis.italic.gray("(use arrow keys to navigate, go back using escape)\n"));
100
61
  if (!structure.options.children)
101
62
  return await backFn();
102
63
  if (structure.options.cliDisplayName) {
103
- terminal_kit_1.terminal.gray("\nProperty: " + ansis_1.default.bold.blue(structure.options.cliDisplayName) + "\n");
104
- terminal_kit_1.terminal.gray("Description: " + ansis_1.default.bold(structure.options.cliDisplayDescription ?? "/") + "\n");
64
+ terminal.gray("\nProperty: " + ansis.bold.blue(structure.options.cliDisplayName) + "\n");
65
+ terminal.gray("Description: " + ansis.bold(structure.options.cliDisplayDescription ?? "/") + "\n");
105
66
  }
106
67
  const list = structure.options.children.filter((child) => !child.cliHideInEditMode);
107
68
  const nameList = list.map((child) => (child.checker.options.cliDisplayName ? child.checker.options.cliDisplayName : child.key));
108
69
  const nameLength = utilities.getLongestLength(nameList);
109
- const finalnameList = nameList.map((name, index) => name.padEnd(nameLength + 5, " ") + ansis_1.default.gray((!list[index].checker.options.cliHideDescriptionInParent && list[index].checker.options.cliDisplayDescription) ? "=> " + list[index].checker.options.cliDisplayDescription : ""));
110
- const answer = await terminal_kit_1.terminal.singleColumnMenu(finalnameList, {
70
+ const finalnameList = nameList.map((name, index) => name.padEnd(nameLength + 5, " ") + ansis.gray((!list[index].checker.options.cliHideDescriptionInParent && list[index].checker.options.cliDisplayDescription) ? "=> " + list[index].checker.options.cliDisplayDescription : ""));
71
+ const answer = await terminal.singleColumnMenu(finalnameList, {
111
72
  leftPadding: "> ",
112
- style: terminal_kit_1.terminal.cyan,
113
- selectedStyle: terminal_kit_1.terminal.bgDefaultColor.bold.defaultColor,
114
- submittedStyle: terminal_kit_1.terminal.bgBlue,
73
+ style: terminal.cyan,
74
+ selectedStyle: terminal.bgDefaultColor.bold.defaultColor,
75
+ submittedStyle: terminal.bgBlue,
115
76
  extraLines: 2,
116
77
  cancelable: true
117
78
  }).promise;
@@ -158,16 +119,16 @@ class ODCliEditConfigInstance {
158
119
  async renderConfigArrayStructureSelector(checker, backFn, structure, data, parent, parentIndex, path) {
159
120
  if (!Array.isArray(data))
160
121
  throw new api.ODSystemError("OD CLI => Property is not of the type 'array'. Please check your config for possible errors. (index: " + parentIndex + ", path: " + path.join(".") + ")");
161
- (0, _1.renderHeader)(this.opts, path);
162
- (0, terminal_kit_1.terminal)(ansis_1.default.bold.green("Please select what you would like to do.\n") + ansis_1.default.italic.gray("(use arrow keys to navigate, go back using escape)\n"));
122
+ renderHeader(this.opts, path);
123
+ terminal(ansis.bold.green("Please select what you would like to do.\n") + ansis.italic.gray("(use arrow keys to navigate, go back using escape)\n"));
163
124
  if (!structure.options.propertyChecker)
164
125
  return await backFn();
165
126
  if (structure.options.cliDisplayName || typeof parentIndex == "string" || !isNaN(parentIndex)) {
166
- terminal_kit_1.terminal.gray("\nProperty: " + ansis_1.default.bold.blue(structure.options.cliDisplayName ?? parentIndex.toString()) + "\n");
167
- terminal_kit_1.terminal.gray("Description: " + ansis_1.default.bold(structure.options.cliDisplayDescription ?? "/") + "\n");
127
+ terminal.gray("\nProperty: " + ansis.bold.blue(structure.options.cliDisplayName ?? parentIndex.toString()) + "\n");
128
+ terminal.gray("Description: " + ansis.bold(structure.options.cliDisplayDescription ?? "/") + "\n");
168
129
  }
169
130
  const propertyName = structure.options.cliDisplayPropertyName ?? "index";
170
- const answer = await terminal_kit_1.terminal.singleColumnMenu(data.length < 1 ? ["Add " + propertyName] : [
131
+ const answer = await terminal.singleColumnMenu(data.length < 1 ? ["Add " + propertyName] : [
171
132
  "Add " + propertyName,
172
133
  "Edit " + propertyName,
173
134
  "Move " + propertyName,
@@ -175,9 +136,9 @@ class ODCliEditConfigInstance {
175
136
  "Duplicate " + propertyName
176
137
  ], {
177
138
  leftPadding: "> ",
178
- style: terminal_kit_1.terminal.cyan,
179
- selectedStyle: terminal_kit_1.terminal.bgDefaultColor.bold,
180
- submittedStyle: terminal_kit_1.terminal.bgBlue,
139
+ style: terminal.cyan,
140
+ selectedStyle: terminal.bgDefaultColor.bold,
141
+ submittedStyle: terminal.bgBlue,
181
142
  extraLines: 2,
182
143
  cancelable: true
183
144
  }).promise;
@@ -201,15 +162,15 @@ class ODCliEditConfigInstance {
201
162
  }
202
163
  async renderConfigArrayStructureEditSelector(checker, backFn, arrayStructure, structure, data, parent, parentIndex, path) {
203
164
  const propertyName = arrayStructure.options.cliDisplayPropertyName ?? "index";
204
- (0, _1.renderHeader)(this.opts, path);
205
- (0, terminal_kit_1.terminal)(ansis_1.default.bold.green("Please select the " + propertyName + " you would like to edit.\n") + ansis_1.default.italic.gray("(use arrow keys to navigate, go back using escape)\n"));
165
+ renderHeader(this.opts, path);
166
+ terminal(ansis.bold.green("Please select the " + propertyName + " you would like to edit.\n") + ansis.italic.gray("(use arrow keys to navigate, go back using escape)\n"));
206
167
  const longestDataListName = Math.max(...data.map((d, i) => this.getArrayPreviewStructureNameLength(structure, d, data, i)));
207
168
  const dataList = data.map((d, i) => (i + 1) + ". " + this.getArrayPreviewFromStructure(structure, d, data, i, longestDataListName));
208
- const dataAnswer = await terminal_kit_1.terminal.singleColumnMenu(dataList, {
169
+ const dataAnswer = await terminal.singleColumnMenu(dataList, {
209
170
  leftPadding: "> ",
210
- style: terminal_kit_1.terminal.cyan,
211
- selectedStyle: terminal_kit_1.terminal.bgDefaultColor.bold,
212
- submittedStyle: terminal_kit_1.terminal.bgBlue,
171
+ style: terminal.cyan,
172
+ selectedStyle: terminal.bgDefaultColor.bold,
173
+ submittedStyle: terminal.bgBlue,
213
174
  extraLines: 2,
214
175
  cancelable: true
215
176
  }).promise;
@@ -220,27 +181,27 @@ class ODCliEditConfigInstance {
220
181
  }
221
182
  async renderConfigArrayStructureMoveSelector(checker, backFn, arrayStructure, structure, data, parent, parentIndex, path) {
222
183
  const propertyName = arrayStructure.options.cliDisplayPropertyName ?? "index";
223
- (0, _1.renderHeader)(this.opts, path);
224
- (0, terminal_kit_1.terminal)(ansis_1.default.bold.green("Please select the " + propertyName + " you would like to move.\n") + ansis_1.default.italic.gray("(use arrow keys to navigate, go back using escape)\n"));
184
+ renderHeader(this.opts, path);
185
+ terminal(ansis.bold.green("Please select the " + propertyName + " you would like to move.\n") + ansis.italic.gray("(use arrow keys to navigate, go back using escape)\n"));
225
186
  const longestDataListName = Math.max(...data.map((d, i) => this.getArrayPreviewStructureNameLength(structure, d, data, i)));
226
187
  const dataList = data.map((d, i) => (i + 1) + ". " + this.getArrayPreviewFromStructure(structure, d, data, i, longestDataListName));
227
- const dataAnswer = await terminal_kit_1.terminal.singleColumnMenu(dataList, {
188
+ const dataAnswer = await terminal.singleColumnMenu(dataList, {
228
189
  leftPadding: "> ",
229
- style: terminal_kit_1.terminal.cyan,
230
- selectedStyle: terminal_kit_1.terminal.bgDefaultColor.bold,
231
- submittedStyle: terminal_kit_1.terminal.bgBlue,
190
+ style: terminal.cyan,
191
+ selectedStyle: terminal.bgDefaultColor.bold,
192
+ submittedStyle: terminal.bgBlue,
232
193
  extraLines: 2,
233
194
  cancelable: true
234
195
  }).promise;
235
196
  if (dataAnswer.canceled)
236
197
  return await backFn();
237
- (0, _1.renderHeader)(this.opts, [...path, dataAnswer.selectedIndex]);
238
- (0, terminal_kit_1.terminal)(ansis_1.default.bold.green("Please select the position you would like to move to.\n") + ansis_1.default.italic.gray("(use arrow keys to navigate, go back using escape)\n"));
239
- const moveAnswer = await terminal_kit_1.terminal.singleColumnMenu(data.map((d, i) => "Position " + (i + 1)), {
198
+ renderHeader(this.opts, [...path, dataAnswer.selectedIndex]);
199
+ terminal(ansis.bold.green("Please select the position you would like to move to.\n") + ansis.italic.gray("(use arrow keys to navigate, go back using escape)\n"));
200
+ const moveAnswer = await terminal.singleColumnMenu(data.map((d, i) => "Position " + (i + 1)), {
240
201
  leftPadding: "> ",
241
- style: terminal_kit_1.terminal.cyan,
242
- selectedStyle: terminal_kit_1.terminal.bgDefaultColor.bold,
243
- submittedStyle: terminal_kit_1.terminal.bgBlue,
202
+ style: terminal.cyan,
203
+ selectedStyle: terminal.bgDefaultColor.bold,
204
+ submittedStyle: terminal.bgBlue,
244
205
  extraLines: 2,
245
206
  cancelable: true
246
207
  }).promise;
@@ -251,21 +212,21 @@ class ODCliEditConfigInstance {
251
212
  const insertedData = [...slicedData.slice(0, moveAnswer.selectedIndex), subData, ...slicedData.slice(moveAnswer.selectedIndex)];
252
213
  insertedData.forEach((d, i) => data[i] = d);
253
214
  await checker.config.save();
254
- terminal_kit_1.terminal.bold.blue("\n\n✅ Property moved succesfully!");
215
+ terminal.bold.blue("\n\n✅ Property moved succesfully!");
255
216
  await utilities.timer(400);
256
217
  await backFn();
257
218
  }
258
219
  async renderConfigArrayStructureRemoveSelector(checker, backFn, arrayStructure, structure, data, parent, parentIndex, path) {
259
220
  const propertyName = arrayStructure.options.cliDisplayPropertyName ?? "index";
260
- (0, _1.renderHeader)(this.opts, path);
261
- (0, terminal_kit_1.terminal)(ansis_1.default.bold.green("Please select the " + propertyName + " you would like to delete.\n") + ansis_1.default.italic.gray("(use arrow keys to navigate, go back using escape)\n"));
221
+ renderHeader(this.opts, path);
222
+ terminal(ansis.bold.green("Please select the " + propertyName + " you would like to delete.\n") + ansis.italic.gray("(use arrow keys to navigate, go back using escape)\n"));
262
223
  const longestDataListName = Math.max(...data.map((d, i) => this.getArrayPreviewStructureNameLength(structure, d, data, i)));
263
224
  const dataList = data.map((d, i) => (i + 1) + ". " + this.getArrayPreviewFromStructure(structure, d, data, i, longestDataListName));
264
- const dataAnswer = await terminal_kit_1.terminal.singleColumnMenu(dataList, {
225
+ const dataAnswer = await terminal.singleColumnMenu(dataList, {
265
226
  leftPadding: "> ",
266
- style: terminal_kit_1.terminal.cyan,
267
- selectedStyle: terminal_kit_1.terminal.bgDefaultColor.bold,
268
- submittedStyle: terminal_kit_1.terminal.bgBlue,
227
+ style: terminal.cyan,
228
+ selectedStyle: terminal.bgDefaultColor.bold,
229
+ submittedStyle: terminal.bgBlue,
269
230
  extraLines: 2,
270
231
  cancelable: true
271
232
  }).promise;
@@ -273,21 +234,21 @@ class ODCliEditConfigInstance {
273
234
  return await backFn();
274
235
  data.splice(dataAnswer.selectedIndex, 1);
275
236
  await checker.config.save();
276
- terminal_kit_1.terminal.bold.blue("\n\n✅ Property deleted succesfully!");
237
+ terminal.bold.blue("\n\n✅ Property deleted succesfully!");
277
238
  await utilities.timer(400);
278
239
  await backFn();
279
240
  }
280
241
  async renderConfigArrayStructureDuplicateSelector(checker, backFn, arrayStructure, structure, data, parent, parentIndex, path) {
281
242
  const propertyName = arrayStructure.options.cliDisplayPropertyName ?? "index";
282
- (0, _1.renderHeader)(this.opts, path);
283
- (0, terminal_kit_1.terminal)(ansis_1.default.bold.green("Please select the " + propertyName + " you would like to duplicate.\n") + ansis_1.default.italic.gray("(use arrow keys to navigate, go back using escape)\n"));
243
+ renderHeader(this.opts, path);
244
+ terminal(ansis.bold.green("Please select the " + propertyName + " you would like to duplicate.\n") + ansis.italic.gray("(use arrow keys to navigate, go back using escape)\n"));
284
245
  const longestDataListName = Math.max(...data.map((d, i) => this.getArrayPreviewStructureNameLength(structure, d, data, i)));
285
246
  const dataList = data.map((d, i) => (i + 1) + ". " + this.getArrayPreviewFromStructure(structure, d, data, i, longestDataListName));
286
- const dataAnswer = await terminal_kit_1.terminal.singleColumnMenu(dataList, {
247
+ const dataAnswer = await terminal.singleColumnMenu(dataList, {
287
248
  leftPadding: "> ",
288
- style: terminal_kit_1.terminal.cyan,
289
- selectedStyle: terminal_kit_1.terminal.bgDefaultColor.bold,
290
- submittedStyle: terminal_kit_1.terminal.bgBlue,
249
+ style: terminal.cyan,
250
+ selectedStyle: terminal.bgDefaultColor.bold,
251
+ submittedStyle: terminal.bgBlue,
291
252
  extraLines: 2,
292
253
  cancelable: true
293
254
  }).promise;
@@ -295,22 +256,22 @@ class ODCliEditConfigInstance {
295
256
  return await backFn();
296
257
  data.push(JSON.parse(JSON.stringify(data[dataAnswer.selectedIndex])));
297
258
  await checker.config.save();
298
- terminal_kit_1.terminal.bold.blue("\n\n✅ Property duplicated succesfully!");
259
+ terminal.bold.blue("\n\n✅ Property duplicated succesfully!");
299
260
  await utilities.timer(400);
300
261
  await backFn();
301
262
  }
302
263
  async renderConfigBooleanStructureEditor(checker, backFn, structure, data, parent, parentIndex, path) {
303
264
  if (typeof data != "boolean")
304
265
  throw new api.ODSystemError("OD CLI => Property is not of the type 'boolean'. Please check your config for possible errors. (index: " + parentIndex + ", path: " + path.join(".") + ")");
305
- (0, _1.renderHeader)(this.opts, path);
306
- (0, terminal_kit_1.terminal)(ansis_1.default.bold.green("You are now editing " + (typeof parentIndex == "string" ? "the boolean property " + ansis_1.default.blue("\"" + parentIndex + "\"") : "boolean property " + ansis_1.default.blue("#" + (parentIndex + 1))) + ".\n") + ansis_1.default.italic.gray("(use arrow keys to navigate, go back using escape)\n"));
307
- terminal_kit_1.terminal.gray("\nCurrent value: " + ansis_1.default.bold[data ? "green" : "red"](data.toString()) + "\n");
308
- terminal_kit_1.terminal.gray("Description: " + ansis_1.default.bold(structure.options.cliDisplayDescription ?? "/") + "\n");
309
- const answer = await terminal_kit_1.terminal.singleColumnMenu(["false (Disabled)", "true (Enabled)"], {
266
+ renderHeader(this.opts, path);
267
+ terminal(ansis.bold.green("You are now editing " + (typeof parentIndex == "string" ? "the boolean property " + ansis.blue("\"" + parentIndex + "\"") : "boolean property " + ansis.blue("#" + (parentIndex + 1))) + ".\n") + ansis.italic.gray("(use arrow keys to navigate, go back using escape)\n"));
268
+ terminal.gray("\nCurrent value: " + ansis.bold[data ? "green" : "red"](data.toString()) + "\n");
269
+ terminal.gray("Description: " + ansis.bold(structure.options.cliDisplayDescription ?? "/") + "\n");
270
+ const answer = await terminal.singleColumnMenu(["false (Disabled)", "true (Enabled)"], {
310
271
  leftPadding: "> ",
311
- style: terminal_kit_1.terminal.cyan,
312
- selectedStyle: terminal_kit_1.terminal.bgDefaultColor.bold,
313
- submittedStyle: terminal_kit_1.terminal.bgBlue,
272
+ style: terminal.cyan,
273
+ selectedStyle: terminal.bgDefaultColor.bold,
274
+ submittedStyle: terminal.bgBlue,
314
275
  extraLines: 2,
315
276
  cancelable: true
316
277
  }).promise;
@@ -325,14 +286,14 @@ class ODCliEditConfigInstance {
325
286
  if (isDataValid) {
326
287
  parent[parentIndex] = newValue;
327
288
  await checker.config.save();
328
- terminal_kit_1.terminal.bold.blue("\n\n✅ Variable saved succesfully!");
289
+ terminal.bold.blue("\n\n✅ Variable saved succesfully!");
329
290
  await utilities.timer(400);
330
291
  await backFn();
331
292
  }
332
293
  else {
333
294
  const messages = checker.messages.map((msg) => "=> [" + msg.type.toUpperCase() + "] " + msg.message).join("\n");
334
- terminal_kit_1.terminal.bold.blue("\n\n❌ Variable is invalid! Please try again!");
335
- terminal_kit_1.terminal.gray("\n" + messages);
295
+ terminal.bold.blue("\n\n❌ Variable is invalid! Please try again!");
296
+ terminal.gray("\n" + messages);
336
297
  await utilities.timer(1000 + (2000 * checker.messages.length));
337
298
  await this.renderConfigBooleanStructureEditor(checker, backFn, structure, data, parent, parentIndex, path);
338
299
  }
@@ -340,13 +301,13 @@ class ODCliEditConfigInstance {
340
301
  async renderConfigNumberStructureEditor(checker, backFn, structure, data, parent, parentIndex, path, prefillValue) {
341
302
  if (typeof data != "number")
342
303
  throw new api.ODSystemError("OD CLI => Property is not of the type 'number'. Please check your config for possible errors. (index: " + parentIndex + ", path: " + path.join(".") + ")");
343
- (0, _1.renderHeader)(this.opts, path);
344
- (0, terminal_kit_1.terminal)(ansis_1.default.bold.green("You are now editing " + (typeof parentIndex == "string" ? "the number property " + ansis_1.default.blue("\"" + parentIndex + "\"") : "number property " + ansis_1.default.blue("#" + (parentIndex + 1))) + ".\n") + ansis_1.default.italic.gray("(insert a new value and press enter, go back using escape)\n"));
345
- terminal_kit_1.terminal.gray("\nCurrent value: " + ansis_1.default.bold.blue(data.toString()) + "\n");
346
- terminal_kit_1.terminal.gray("Description: " + ansis_1.default.bold(structure.options.cliDisplayDescription ?? "/") + "\n");
347
- const answer = await terminal_kit_1.terminal.inputField({
304
+ renderHeader(this.opts, path);
305
+ terminal(ansis.bold.green("You are now editing " + (typeof parentIndex == "string" ? "the number property " + ansis.blue("\"" + parentIndex + "\"") : "number property " + ansis.blue("#" + (parentIndex + 1))) + ".\n") + ansis.italic.gray("(insert a new value and press enter, go back using escape)\n"));
306
+ terminal.gray("\nCurrent value: " + ansis.bold.blue(data.toString()) + "\n");
307
+ terminal.gray("Description: " + ansis.bold(structure.options.cliDisplayDescription ?? "/") + "\n");
308
+ const answer = await terminal.inputField({
348
309
  default: prefillValue,
349
- style: terminal_kit_1.terminal.cyan,
310
+ style: terminal.cyan,
350
311
  cancelable: true
351
312
  }).promise;
352
313
  if (typeof answer != "string")
@@ -360,14 +321,14 @@ class ODCliEditConfigInstance {
360
321
  if (isDataValid) {
361
322
  parent[parentIndex] = newValue;
362
323
  await checker.config.save();
363
- terminal_kit_1.terminal.bold.blue("\n\n✅ Variable saved succesfully!");
324
+ terminal.bold.blue("\n\n✅ Variable saved succesfully!");
364
325
  await utilities.timer(400);
365
326
  await backFn();
366
327
  }
367
328
  else {
368
329
  const messages = checker.messages.map((msg) => "=> [" + msg.type.toUpperCase() + "] " + msg.message).join("\n");
369
- terminal_kit_1.terminal.bold.blue("\n\n❌ Variable is invalid! Please try again!");
370
- terminal_kit_1.terminal.red("\n" + messages);
330
+ terminal.bold.blue("\n\n❌ Variable is invalid! Please try again!");
331
+ terminal.red("\n" + messages);
371
332
  await utilities.timer(1000 + (2000 * checker.messages.length));
372
333
  await this.renderConfigNumberStructureEditor(checker, backFn, structure, data, parent, parentIndex, path, answer);
373
334
  }
@@ -375,35 +336,35 @@ class ODCliEditConfigInstance {
375
336
  async renderConfigStringStructureEditor(checker, backFn, structure, data, parent, parentIndex, path, prefillValue) {
376
337
  if (typeof data != "string")
377
338
  throw new api.ODSystemError("OD CLI => Property is not of the type 'string'. Please check your config for possible errors. (index: " + parentIndex + ", path: " + path.join(".") + ")");
378
- (0, _1.renderHeader)(this.opts, path);
379
- (0, terminal_kit_1.terminal)(ansis_1.default.bold.green("You are now editing " + (typeof parentIndex == "string" ? "the string property " + ansis_1.default.blue("\"" + parentIndex + "\"") : "string property " + ansis_1.default.blue("#" + (parentIndex + 1))) + ".\n") + ansis_1.default.italic.gray("(insert a new value and press enter, go back using escape)\n"));
380
- terminal_kit_1.terminal.gray("\nCurrent value:" + (data.includes("\n") ? "\n" : " \"") + ansis_1.default.bold.blue(data) + ansis_1.default.gray(!data.includes("\n") ? "\"\n" : "\n"));
381
- terminal_kit_1.terminal.gray("Description: " + ansis_1.default.bold(structure.options.cliDisplayDescription ?? "/") + "\n");
339
+ renderHeader(this.opts, path);
340
+ terminal(ansis.bold.green("You are now editing " + (typeof parentIndex == "string" ? "the string property " + ansis.blue("\"" + parentIndex + "\"") : "string property " + ansis.blue("#" + (parentIndex + 1))) + ".\n") + ansis.italic.gray("(insert a new value and press enter, go back using escape)\n"));
341
+ terminal.gray("\nCurrent value:" + (data.includes("\n") ? "\n" : " \"") + ansis.bold.blue(data) + ansis.gray(!data.includes("\n") ? "\"\n" : "\n"));
342
+ terminal.gray("Description: " + ansis.bold(structure.options.cliDisplayDescription ?? "/") + "\n");
382
343
  const customExtraOptions = (structure instanceof api.ODCheckerCustomStructure_DiscordId) ? structure.extraOptions : undefined;
383
344
  const customAutocompleteFunc = structure.options.cliAutocompleteFunc ? await structure.options.cliAutocompleteFunc() : null;
384
345
  const autocompleteList = ((customAutocompleteFunc ?? structure.options.cliAutocompleteList) ?? customExtraOptions) ?? structure.options.choices;
385
346
  const autoCompleteMenuOpts = {
386
- style: terminal_kit_1.terminal.white,
387
- selectedStyle: terminal_kit_1.terminal.bgBlue.white
347
+ style: terminal.white,
348
+ selectedStyle: terminal.bgBlue.white
388
349
  };
389
- const input = terminal_kit_1.terminal.inputField({
350
+ const input = terminal.inputField({
390
351
  default: prefillValue,
391
- style: terminal_kit_1.terminal.cyan,
392
- hintStyle: terminal_kit_1.terminal.gray,
352
+ style: terminal.cyan,
353
+ hintStyle: terminal.gray,
393
354
  cancelable: false,
394
355
  autoComplete: autocompleteList,
395
356
  autoCompleteHint: (!!autocompleteList),
396
357
  autoCompleteMenu: (autocompleteList) ? autoCompleteMenuOpts : false
397
358
  });
398
- terminal_kit_1.terminal.on("key", async (name, matches, data) => {
359
+ terminal.on("key", async (name, matches, data) => {
399
360
  if (name == "ESCAPE") {
400
- terminal_kit_1.terminal.removeListener("key", "cli-render-string-structure-edit");
361
+ terminal.removeListener("key", "cli-render-string-structure-edit");
401
362
  input.abort();
402
363
  await backFn();
403
364
  }
404
365
  }, { id: "cli-render-string-structure-edit" });
405
366
  const answer = await input.promise;
406
- terminal_kit_1.terminal.removeListener("key", "cli-render-string-structure-edit");
367
+ terminal.removeListener("key", "cli-render-string-structure-edit");
407
368
  if (typeof answer != "string")
408
369
  return;
409
370
  //run config checker
@@ -415,14 +376,14 @@ class ODCliEditConfigInstance {
415
376
  if (isDataValid) {
416
377
  parent[parentIndex] = newValue;
417
378
  await checker.config.save();
418
- terminal_kit_1.terminal.bold.blue("\n\n✅ Variable saved succesfully!");
379
+ terminal.bold.blue("\n\n✅ Variable saved succesfully!");
419
380
  await utilities.timer(400);
420
381
  await backFn();
421
382
  }
422
383
  else {
423
384
  const messages = checker.messages.map((msg) => "=> [" + msg.type.toUpperCase() + "] " + msg.message).join("\n");
424
- terminal_kit_1.terminal.bold.blue("\n\n❌ Variable is invalid! Please try again!");
425
- terminal_kit_1.terminal.red("\n" + messages);
385
+ terminal.bold.blue("\n\n❌ Variable is invalid! Please try again!");
386
+ terminal.red("\n" + messages);
426
387
  await utilities.timer(1000 + (2000 * checker.messages.length));
427
388
  await this.renderConfigStringStructureEditor(checker, backFn, structure, data, parent, parentIndex, path, answer);
428
389
  }
@@ -430,15 +391,15 @@ class ODCliEditConfigInstance {
430
391
  async renderConfigNullStructureEditor(checker, backFn, structure, data, parent, parentIndex, path) {
431
392
  if (data !== null)
432
393
  throw new api.ODSystemError("OD CLI => Property is not of the type 'null'. Please check your config for possible errors. (index: " + parentIndex + ", path: " + path.join(".") + ")");
433
- (0, _1.renderHeader)(this.opts, path);
434
- (0, terminal_kit_1.terminal)(ansis_1.default.bold.green("You are now editing " + (typeof parentIndex == "string" ? "the null property " + ansis_1.default.blue("\"" + parentIndex + "\"") : "null property " + ansis_1.default.blue("#" + (parentIndex + 1))) + ".\n") + ansis_1.default.italic.gray("(use arrow keys to navigate, go back using escape)\n"));
435
- terminal_kit_1.terminal.gray("\nCurrent value: " + ansis_1.default.bold.blue("null") + "\n");
436
- terminal_kit_1.terminal.gray("Description: " + ansis_1.default.bold(structure.options.cliDisplayDescription ?? "/") + "\n");
437
- const answer = await terminal_kit_1.terminal.singleColumnMenu(["null"], {
394
+ renderHeader(this.opts, path);
395
+ terminal(ansis.bold.green("You are now editing " + (typeof parentIndex == "string" ? "the null property " + ansis.blue("\"" + parentIndex + "\"") : "null property " + ansis.blue("#" + (parentIndex + 1))) + ".\n") + ansis.italic.gray("(use arrow keys to navigate, go back using escape)\n"));
396
+ terminal.gray("\nCurrent value: " + ansis.bold.blue("null") + "\n");
397
+ terminal.gray("Description: " + ansis.bold(structure.options.cliDisplayDescription ?? "/") + "\n");
398
+ const answer = await terminal.singleColumnMenu(["null"], {
438
399
  leftPadding: "> ",
439
- style: terminal_kit_1.terminal.cyan,
440
- selectedStyle: terminal_kit_1.terminal.bgDefaultColor.bold,
441
- submittedStyle: terminal_kit_1.terminal.bgBlue,
400
+ style: terminal.cyan,
401
+ selectedStyle: terminal.bgDefaultColor.bold,
402
+ submittedStyle: terminal.bgBlue,
442
403
  extraLines: 2,
443
404
  cancelable: true
444
405
  }).promise;
@@ -453,23 +414,23 @@ class ODCliEditConfigInstance {
453
414
  if (isDataValid) {
454
415
  parent[parentIndex] = newValue;
455
416
  await checker.config.save();
456
- terminal_kit_1.terminal.bold.blue("\n\n✅ Variable saved succesfully!");
417
+ terminal.bold.blue("\n\n✅ Variable saved succesfully!");
457
418
  await utilities.timer(400);
458
419
  await backFn();
459
420
  }
460
421
  else {
461
422
  const messages = checker.messages.map((msg) => "=> [" + msg.type.toUpperCase() + "] " + msg.message).join("\n");
462
- terminal_kit_1.terminal.bold.blue("\n\n❌ Variable is invalid! Please try again!");
463
- terminal_kit_1.terminal.red("\n" + messages);
423
+ terminal.bold.blue("\n\n❌ Variable is invalid! Please try again!");
424
+ terminal.red("\n" + messages);
464
425
  await utilities.timer(1000 + (2000 * checker.messages.length));
465
426
  await this.renderConfigNullStructureEditor(checker, backFn, structure, data, parent, parentIndex, path);
466
427
  }
467
428
  }
468
429
  async renderConfigTypeSwitchStructureEditor(checker, backFn, structure, data, parent, parentIndex, path) {
469
- (0, _1.renderHeader)(this.opts, path);
470
- (0, terminal_kit_1.terminal)(ansis_1.default.bold.green("You are now editing " + (typeof parentIndex == "string" ? "the property " + ansis_1.default.blue("\"" + parentIndex + "\"") : "property " + ansis_1.default.blue("#" + (parentIndex + 1))) + ".\n") + ansis_1.default.italic.gray("(use arrow keys to navigate, go back using escape)\n"));
471
- terminal_kit_1.terminal.gray("\nCurrent value: " + ansis_1.default.bold.blue(data.toString()) + "\n");
472
- terminal_kit_1.terminal.gray("Description: " + ansis_1.default.bold(structure.options.cliDisplayDescription ?? "/") + "\n");
430
+ renderHeader(this.opts, path);
431
+ terminal(ansis.bold.green("You are now editing " + (typeof parentIndex == "string" ? "the property " + ansis.blue("\"" + parentIndex + "\"") : "property " + ansis.blue("#" + (parentIndex + 1))) + ".\n") + ansis.italic.gray("(use arrow keys to navigate, go back using escape)\n"));
432
+ terminal.gray("\nCurrent value: " + ansis.bold.blue(data.toString()) + "\n");
433
+ terminal.gray("Description: " + ansis.bold(structure.options.cliDisplayDescription ?? "/") + "\n");
473
434
  const actionsList = [];
474
435
  if (structure.options.boolean)
475
436
  actionsList.push("Edit as boolean");
@@ -483,11 +444,11 @@ class ODCliEditConfigInstance {
483
444
  actionsList.push("Edit as array/list");
484
445
  if (structure.options.null)
485
446
  actionsList.push("Edit as null");
486
- const answer = await terminal_kit_1.terminal.singleColumnMenu(actionsList, {
447
+ const answer = await terminal.singleColumnMenu(actionsList, {
487
448
  leftPadding: "> ",
488
- style: terminal_kit_1.terminal.cyan,
489
- selectedStyle: terminal_kit_1.terminal.bgDefaultColor.bold,
490
- submittedStyle: terminal_kit_1.terminal.bgBlue,
449
+ style: terminal.cyan,
450
+ selectedStyle: terminal.bgDefaultColor.bold,
451
+ submittedStyle: terminal.bgBlue,
491
452
  extraLines: 2,
492
453
  cancelable: true
493
454
  }).promise;
@@ -522,7 +483,7 @@ class ODCliEditConfigInstance {
522
483
  if (!structure.options.cliDisplayKeyInParentArray)
523
484
  return "Object".length;
524
485
  else
525
- return data[structure.options.cliDisplayKeyInParentArray].toString().length;
486
+ return data[structure.options.cliDisplayKeyInParentArray]?.toString().length ?? 0;
526
487
  }
527
488
  else if (structure instanceof api.ODCheckerEnabledObjectStructure && typeof data == "object" && !Array.isArray(data) && data) {
528
489
  const subStructure = structure.options.checker;
@@ -571,11 +532,11 @@ class ODCliEditConfigInstance {
571
532
  else if (structure instanceof api.ODCheckerArrayStructure && Array.isArray(data))
572
533
  return "Array";
573
534
  else if (structure instanceof api.ODCheckerObjectStructure && typeof data == "object" && !Array.isArray(data) && data) {
574
- const additionalKeys = (structure.options.cliDisplayAdditionalKeysInParentArray ?? []).map((key) => key + ": " + data[key].toString()).join(", ");
535
+ const additionalKeys = (structure.options.cliDisplayAdditionalKeysInParentArray ?? []).map((key) => key + ": " + data[key]?.toString()).join(", ");
575
536
  if (!structure.options.cliDisplayKeyInParentArray)
576
537
  return "Object";
577
538
  else
578
- return data[structure.options.cliDisplayKeyInParentArray].toString().padEnd(nameLength + 5, " ") + ansis_1.default.gray(additionalKeys.length > 0 ? "(" + additionalKeys + ")" : "");
539
+ return data[structure.options.cliDisplayKeyInParentArray]?.toString().padEnd(nameLength + 5, " ") + ansis.gray(additionalKeys.length > 0 ? "(" + additionalKeys + ")" : "");
579
540
  }
580
541
  else if (structure instanceof api.ODCheckerEnabledObjectStructure && typeof data == "object" && !Array.isArray(data) && data) {
581
542
  const subStructure = structure.options.checker;
@@ -671,7 +632,7 @@ class ODCliEditConfigInstance {
671
632
  await backFn();
672
633
  }, async () => {
673
634
  //finish setup
674
- terminal_kit_1.terminal.bold.blue("\n\n✅ Variable saved succesfully!");
635
+ terminal.bold.blue("\n\n✅ Variable saved succesfully!");
675
636
  await utilities.timer(400);
676
637
  await nextFn(localData);
677
638
  });
@@ -715,28 +676,21 @@ class ODCliEditConfigInstance {
715
676
  else {
716
677
  localData[enabledProperty] = data;
717
678
  //copy old object checker to new object checker => all options get de-referenced (this is needed for the new object skip keys are temporary)
718
- const newStructure = new api.ODCheckerObjectStructure(subStructure.id, { children: [] });
719
- //copy all options over to the new checker
720
- newStructure.options.children = [...subStructure.options.children];
721
- newStructure.options.cliInitSkipKeys = subStructure.options.children.map((child) => child.key);
722
- for (const key of Object.keys(subStructure.options)) {
723
- if (key != "children" && key != "cliInitSkipKeys")
724
- newStructure.options[key] = subStructure.options[key];
725
- }
726
- //adds all properties to object as "skipKeys", then continues to next function
679
+ const newStructure = new api.ODCheckerObjectStructure(subStructure.id, structuredClone(subStructure.options));
680
+ //continues to next function
727
681
  await this.renderAdditionConfigObjectStructure(checker, async () => { await this.renderAdditionConfigEnabledObjectStructure(checker, backFn, nextFn, structure, parent, parentIndex, path, localPath); }, nextFn, newStructure, parent, parentIndex, path, localPath, localData);
728
682
  await nextFn(localData);
729
683
  }
730
684
  }, propertyStructure, localData, enabledProperty, [...path, parentIndex], [...localPath, parentIndex]);
731
685
  }
732
686
  async renderAdditionConfigObjectSwitchStructure(checker, backFn, nextFn, structure, parent, parentIndex, path, localPath) {
733
- (0, _1.renderHeader)(this.opts, [...path, parentIndex]);
734
- (0, terminal_kit_1.terminal)(ansis_1.default.bold.green("What type of object would you like to add?\n") + ansis_1.default.italic.gray("(use arrow keys to navigate, go back using escape)\n"));
735
- const answer = await terminal_kit_1.terminal.singleColumnMenu(structure.options.objects.map((obj) => obj.name), {
687
+ renderHeader(this.opts, [...path, parentIndex]);
688
+ terminal(ansis.bold.green("What type of object would you like to add?\n") + ansis.italic.gray("(use arrow keys to navigate, go back using escape)\n"));
689
+ const answer = await terminal.singleColumnMenu(structure.options.objects.map((obj) => obj.name), {
736
690
  leftPadding: "> ",
737
- style: terminal_kit_1.terminal.cyan,
738
- selectedStyle: terminal_kit_1.terminal.bgDefaultColor.bold,
739
- submittedStyle: terminal_kit_1.terminal.bgBlue,
691
+ style: terminal.cyan,
692
+ selectedStyle: terminal.bgDefaultColor.bold,
693
+ submittedStyle: terminal.bgBlue,
740
694
  extraLines: 2,
741
695
  cancelable: true
742
696
  }).promise;
@@ -745,14 +699,7 @@ class ODCliEditConfigInstance {
745
699
  const objectTemplate = structure.options.objects[answer.selectedIndex];
746
700
  //copy old object checker to new object checker => all options get de-referenced (this is needed for the new object switch properties which are temporary)
747
701
  const oldStructure = objectTemplate.checker;
748
- const newStructure = new api.ODCheckerObjectStructure(oldStructure.id, { children: [] });
749
- //copy all options over to the new checker
750
- newStructure.options.children = [...oldStructure.options.children];
751
- newStructure.options.cliInitSkipKeys = [...(oldStructure.options.cliInitSkipKeys ?? [])];
752
- for (const key of Object.keys(oldStructure.options)) {
753
- if (key != "children" && key != "cliInitSkipKeys")
754
- newStructure.options[key] = oldStructure.options[key];
755
- }
702
+ const newStructure = new api.ODCheckerObjectStructure(oldStructure.id, structuredClone(oldStructure.options));
756
703
  //add the keys of the object switch properties to the 'cliInitSkipKeys' because they need to be skipped.
757
704
  objectTemplate.properties.map((p) => p.key).forEach((p) => {
758
705
  if (!newStructure.options.cliInitSkipKeys)
@@ -774,15 +721,15 @@ class ODCliEditConfigInstance {
774
721
  await this.chooseAdditionConfigStructure(checker, backFn, nextFn, newStructure, parent, parentIndex, path, localPath);
775
722
  }
776
723
  async renderAdditionConfigBooleanStructure(checker, backFn, nextFn, structure, parent, parentIndex, path, localPath) {
777
- (0, _1.renderHeader)(this.opts, [...path, parentIndex]);
778
- (0, terminal_kit_1.terminal)(ansis_1.default.bold.green("You are now creating " + (typeof parentIndex == "string" ? "the boolean property " + ansis_1.default.blue("\"" + parentIndex + "\"") : "boolean property " + ansis_1.default.blue("#" + (parentIndex + 1))) + ".\n") + ansis_1.default.italic.gray("(use arrow keys to navigate, go back using escape)\n"));
779
- terminal_kit_1.terminal.gray("\nProperty: " + ansis_1.default.bold.blue(structure.options.cliDisplayName ?? [...localPath, parentIndex].join(".")) + "\n");
780
- terminal_kit_1.terminal.gray("Description: " + ansis_1.default.bold(structure.options.cliDisplayDescription ?? "/") + "\n");
781
- const answer = await terminal_kit_1.terminal.singleColumnMenu(["false (Disabled)", "true (Enabled)"], {
724
+ renderHeader(this.opts, [...path, parentIndex]);
725
+ terminal(ansis.bold.green("You are now creating " + (typeof parentIndex == "string" ? "the boolean property " + ansis.blue("\"" + parentIndex + "\"") : "boolean property " + ansis.blue("#" + (parentIndex + 1))) + ".\n") + ansis.italic.gray("(use arrow keys to navigate, go back using escape)\n"));
726
+ terminal.gray("\nProperty: " + ansis.bold.blue(structure.options.cliDisplayName ?? [...localPath, parentIndex].join(".")) + "\n");
727
+ terminal.gray("Description: " + ansis.bold(structure.options.cliDisplayDescription ?? "/") + "\n");
728
+ const answer = await terminal.singleColumnMenu(["false (Disabled)", "true (Enabled)"], {
782
729
  leftPadding: "> ",
783
- style: terminal_kit_1.terminal.cyan,
784
- selectedStyle: terminal_kit_1.terminal.bgDefaultColor.bold,
785
- submittedStyle: terminal_kit_1.terminal.bgBlue,
730
+ style: terminal.cyan,
731
+ selectedStyle: terminal.bgDefaultColor.bold,
732
+ submittedStyle: terminal.bgBlue,
786
733
  extraLines: 2,
787
734
  cancelable: true
788
735
  }).promise;
@@ -795,26 +742,26 @@ class ODCliEditConfigInstance {
795
742
  checker.messages = []; //manually clear previous messages
796
743
  const isDataValid = structure.check(checker, newValue, newPath);
797
744
  if (isDataValid) {
798
- terminal_kit_1.terminal.bold.blue("\n\n✅ Variable saved succesfully!");
745
+ terminal.bold.blue("\n\n✅ Variable saved succesfully!");
799
746
  await utilities.timer(400);
800
747
  await nextFn(newValue);
801
748
  }
802
749
  else {
803
750
  const messages = checker.messages.map((msg) => "=> [" + msg.type.toUpperCase() + "] " + msg.message).join("\n");
804
- terminal_kit_1.terminal.bold.blue("\n\n❌ Variable is invalid! Please try again!");
805
- terminal_kit_1.terminal.gray("\n" + messages);
751
+ terminal.bold.blue("\n\n❌ Variable is invalid! Please try again!");
752
+ terminal.gray("\n" + messages);
806
753
  await utilities.timer(1000 + (2000 * checker.messages.length));
807
754
  await this.renderAdditionConfigBooleanStructure(checker, backFn, nextFn, structure, parent, parentIndex, path, localPath);
808
755
  }
809
756
  }
810
757
  async renderAdditionConfigNumberStructure(checker, backFn, nextFn, structure, parent, parentIndex, path, localPath, prefillValue) {
811
- (0, _1.renderHeader)(this.opts, [...path, parentIndex]);
812
- (0, terminal_kit_1.terminal)(ansis_1.default.bold.green("You are now creating " + (typeof parentIndex == "string" ? "the number property " + ansis_1.default.blue("\"" + parentIndex + "\"") : "number property " + ansis_1.default.blue("#" + (parentIndex + 1))) + ".\n") + ansis_1.default.italic.gray("(insert a new value and press enter, go back using escape)\n"));
813
- terminal_kit_1.terminal.gray("\nProperty: " + ansis_1.default.bold.blue(structure.options.cliDisplayName ?? [...localPath, parentIndex].join(".")) + "\n");
814
- terminal_kit_1.terminal.gray("Description: " + ansis_1.default.bold(structure.options.cliDisplayDescription ?? "/") + "\n");
815
- const answer = await terminal_kit_1.terminal.inputField({
758
+ renderHeader(this.opts, [...path, parentIndex]);
759
+ terminal(ansis.bold.green("You are now creating " + (typeof parentIndex == "string" ? "the number property " + ansis.blue("\"" + parentIndex + "\"") : "number property " + ansis.blue("#" + (parentIndex + 1))) + ".\n") + ansis.italic.gray("(insert a new value and press enter, go back using escape)\n"));
760
+ terminal.gray("\nProperty: " + ansis.bold.blue(structure.options.cliDisplayName ?? [...localPath, parentIndex].join(".")) + "\n");
761
+ terminal.gray("Description: " + ansis.bold(structure.options.cliDisplayDescription ?? "/") + "\n");
762
+ const answer = await terminal.inputField({
816
763
  default: prefillValue,
817
- style: terminal_kit_1.terminal.cyan,
764
+ style: terminal.cyan,
818
765
  cancelable: true
819
766
  }).promise;
820
767
  if (typeof answer != "string")
@@ -826,48 +773,48 @@ class ODCliEditConfigInstance {
826
773
  checker.messages = []; //manually clear previous messages
827
774
  const isDataValid = structure.check(checker, newValue, newPath);
828
775
  if (isDataValid) {
829
- terminal_kit_1.terminal.bold.blue("\n\n✅ Variable saved succesfully!");
776
+ terminal.bold.blue("\n\n✅ Variable saved succesfully!");
830
777
  await utilities.timer(400);
831
778
  await nextFn(newValue);
832
779
  }
833
780
  else {
834
781
  const messages = checker.messages.map((msg) => "=> [" + msg.type.toUpperCase() + "] " + msg.message).join("\n");
835
- terminal_kit_1.terminal.bold.blue("\n\n❌ Variable is invalid! Please try again!");
836
- terminal_kit_1.terminal.red("\n" + messages);
782
+ terminal.bold.blue("\n\n❌ Variable is invalid! Please try again!");
783
+ terminal.red("\n" + messages);
837
784
  await utilities.timer(1000 + (2000 * checker.messages.length));
838
785
  await this.renderAdditionConfigNumberStructure(checker, backFn, nextFn, structure, parent, parentIndex, path, localPath, answer);
839
786
  }
840
787
  }
841
788
  async renderAdditionConfigStringStructure(checker, backFn, nextFn, structure, parent, parentIndex, path, localPath, prefillValue) {
842
- (0, _1.renderHeader)(this.opts, [...path, parentIndex]);
843
- (0, terminal_kit_1.terminal)(ansis_1.default.bold.green("You are now creating " + (typeof parentIndex == "string" ? "the string property " + ansis_1.default.blue("\"" + parentIndex + "\"") : "string property " + ansis_1.default.blue("#" + (parentIndex + 1))) + ".\n") + ansis_1.default.italic.gray("(insert a new value and press enter, go back using escape)\n"));
844
- terminal_kit_1.terminal.gray("\nProperty: " + ansis_1.default.bold.blue(structure.options.cliDisplayName ?? [...localPath, parentIndex].join(".")) + "\n");
845
- terminal_kit_1.terminal.gray("Description: " + ansis_1.default.bold(structure.options.cliDisplayDescription ?? "/") + "\n");
789
+ renderHeader(this.opts, [...path, parentIndex]);
790
+ terminal(ansis.bold.green("You are now creating " + (typeof parentIndex == "string" ? "the string property " + ansis.blue("\"" + parentIndex + "\"") : "string property " + ansis.blue("#" + (parentIndex + 1))) + ".\n") + ansis.italic.gray("(insert a new value and press enter, go back using escape)\n"));
791
+ terminal.gray("\nProperty: " + ansis.bold.blue(structure.options.cliDisplayName ?? [...localPath, parentIndex].join(".")) + "\n");
792
+ terminal.gray("Description: " + ansis.bold(structure.options.cliDisplayDescription ?? "/") + "\n");
846
793
  const customExtraOptions = (structure instanceof api.ODCheckerCustomStructure_DiscordId) ? structure.extraOptions : undefined;
847
794
  const customAutocompleteFunc = structure.options.cliAutocompleteFunc ? await structure.options.cliAutocompleteFunc() : null;
848
795
  const autocompleteList = ((customAutocompleteFunc ?? structure.options.cliAutocompleteList) ?? customExtraOptions) ?? structure.options.choices;
849
796
  const autoCompleteMenuOpts = {
850
- style: terminal_kit_1.terminal.white,
851
- selectedStyle: terminal_kit_1.terminal.bgBlue.white
797
+ style: terminal.white,
798
+ selectedStyle: terminal.bgBlue.white
852
799
  };
853
- const input = terminal_kit_1.terminal.inputField({
800
+ const input = terminal.inputField({
854
801
  default: prefillValue,
855
- style: terminal_kit_1.terminal.cyan,
856
- hintStyle: terminal_kit_1.terminal.gray,
802
+ style: terminal.cyan,
803
+ hintStyle: terminal.gray,
857
804
  cancelable: false,
858
805
  autoComplete: autocompleteList,
859
806
  autoCompleteHint: (!!autocompleteList),
860
807
  autoCompleteMenu: (autocompleteList) ? autoCompleteMenuOpts : false
861
808
  });
862
- terminal_kit_1.terminal.on("key", async (name, matches, data) => {
809
+ terminal.on("key", async (name, matches, data) => {
863
810
  if (name == "ESCAPE") {
864
- terminal_kit_1.terminal.removeListener("key", "cli-render-string-structure-add");
811
+ terminal.removeListener("key", "cli-render-string-structure-add");
865
812
  input.abort();
866
813
  await backFn();
867
814
  }
868
815
  }, { id: "cli-render-string-structure-add" });
869
816
  const answer = await input.promise;
870
- terminal_kit_1.terminal.removeListener("key", "cli-render-string-structure-add");
817
+ terminal.removeListener("key", "cli-render-string-structure-add");
871
818
  if (typeof answer != "string")
872
819
  return;
873
820
  //run config checker
@@ -877,28 +824,28 @@ class ODCliEditConfigInstance {
877
824
  checker.messages = []; //manually clear previous messages
878
825
  const isDataValid = structure.check(checker, newValue, newPath);
879
826
  if (isDataValid) {
880
- terminal_kit_1.terminal.bold.blue("\n\n✅ Variable saved succesfully!");
827
+ terminal.bold.blue("\n\n✅ Variable saved succesfully!");
881
828
  await utilities.timer(400);
882
829
  await nextFn(newValue);
883
830
  }
884
831
  else {
885
832
  const messages = checker.messages.map((msg) => "=> [" + msg.type.toUpperCase() + "] " + msg.message).join("\n");
886
- terminal_kit_1.terminal.bold.blue("\n\n❌ Variable is invalid! Please try again!");
887
- terminal_kit_1.terminal.red("\n" + messages);
833
+ terminal.bold.blue("\n\n❌ Variable is invalid! Please try again!");
834
+ terminal.red("\n" + messages);
888
835
  await utilities.timer(1000 + (2000 * checker.messages.length));
889
836
  await this.renderAdditionConfigStringStructure(checker, backFn, nextFn, structure, parent, parentIndex, path, localPath, answer);
890
837
  }
891
838
  }
892
839
  async renderAdditionConfigNullStructure(checker, backFn, nextFn, structure, parent, parentIndex, path, localPath) {
893
- (0, _1.renderHeader)(this.opts, [...path, parentIndex]);
894
- (0, terminal_kit_1.terminal)(ansis_1.default.bold.green("You are now creating " + (typeof parentIndex == "string" ? "the null property " + ansis_1.default.blue("\"" + parentIndex + "\"") : "null property " + ansis_1.default.blue("#" + (parentIndex + 1))) + ".\n") + ansis_1.default.italic.gray("(use arrow keys to navigate, go back using escape)\n"));
895
- terminal_kit_1.terminal.gray("\nProperty: " + ansis_1.default.bold.blue(structure.options.cliDisplayName ?? [...localPath, parentIndex].join(".")) + "\n");
896
- terminal_kit_1.terminal.gray("Description: " + ansis_1.default.bold(structure.options.cliDisplayDescription ?? "/") + "\n");
897
- const answer = await terminal_kit_1.terminal.singleColumnMenu(["null"], {
840
+ renderHeader(this.opts, [...path, parentIndex]);
841
+ terminal(ansis.bold.green("You are now creating " + (typeof parentIndex == "string" ? "the null property " + ansis.blue("\"" + parentIndex + "\"") : "null property " + ansis.blue("#" + (parentIndex + 1))) + ".\n") + ansis.italic.gray("(use arrow keys to navigate, go back using escape)\n"));
842
+ terminal.gray("\nProperty: " + ansis.bold.blue(structure.options.cliDisplayName ?? [...localPath, parentIndex].join(".")) + "\n");
843
+ terminal.gray("Description: " + ansis.bold(structure.options.cliDisplayDescription ?? "/") + "\n");
844
+ const answer = await terminal.singleColumnMenu(["null"], {
898
845
  leftPadding: "> ",
899
- style: terminal_kit_1.terminal.cyan,
900
- selectedStyle: terminal_kit_1.terminal.bgDefaultColor.bold,
901
- submittedStyle: terminal_kit_1.terminal.bgBlue,
846
+ style: terminal.cyan,
847
+ selectedStyle: terminal.bgDefaultColor.bold,
848
+ submittedStyle: terminal.bgBlue,
902
849
  extraLines: 2,
903
850
  cancelable: true
904
851
  }).promise;
@@ -911,28 +858,28 @@ class ODCliEditConfigInstance {
911
858
  checker.messages = []; //manually clear previous messages
912
859
  const isDataValid = structure.check(checker, newValue, newPath);
913
860
  if (isDataValid) {
914
- terminal_kit_1.terminal.bold.blue("\n\n✅ Variable saved succesfully!");
861
+ terminal.bold.blue("\n\n✅ Variable saved succesfully!");
915
862
  await utilities.timer(400);
916
863
  await nextFn(newValue);
917
864
  }
918
865
  else {
919
866
  const messages = checker.messages.map((msg) => "=> [" + msg.type.toUpperCase() + "] " + msg.message).join("\n");
920
- terminal_kit_1.terminal.bold.blue("\n\n❌ Variable is invalid! Please try again!");
921
- terminal_kit_1.terminal.red("\n" + messages);
867
+ terminal.bold.blue("\n\n❌ Variable is invalid! Please try again!");
868
+ terminal.red("\n" + messages);
922
869
  await utilities.timer(1000 + (2000 * checker.messages.length));
923
870
  await this.renderAdditionConfigNullStructure(checker, backFn, nextFn, structure, parent, parentIndex, path, localPath);
924
871
  }
925
872
  }
926
873
  async renderAdditionConfigArrayStructureSelector(checker, backFn, nextFn, structure, parent, parentIndex, path, localPath, localData = []) {
927
- (0, _1.renderHeader)(this.opts, [...path, parentIndex]);
928
- (0, terminal_kit_1.terminal)(ansis_1.default.bold.green("Please select what you would like to do with the new array.\n") + ansis_1.default.italic.gray("(use arrow keys to navigate, go back using escape)\n"));
874
+ renderHeader(this.opts, [...path, parentIndex]);
875
+ terminal(ansis.bold.green("Please select what you would like to do with the new array.\n") + ansis.italic.gray("(use arrow keys to navigate, go back using escape)\n"));
929
876
  if (!structure.options.propertyChecker)
930
877
  return await backFn();
931
- terminal_kit_1.terminal.gray("\nProperty: " + ansis_1.default.bold.blue(structure.options.cliDisplayName ?? [...localPath, parentIndex].join(".")) + "\n");
932
- terminal_kit_1.terminal.gray("Description: " + ansis_1.default.bold(structure.options.cliDisplayDescription ?? "/") + "\n");
878
+ terminal.gray("\nProperty: " + ansis.bold.blue(structure.options.cliDisplayName ?? [...localPath, parentIndex].join(".")) + "\n");
879
+ terminal.gray("Description: " + ansis.bold(structure.options.cliDisplayDescription ?? "/") + "\n");
933
880
  const propertyName = structure.options.cliDisplayPropertyName ?? "index";
934
- const answer = await terminal_kit_1.terminal.singleColumnMenu(localData.length < 1 ? [ansis_1.default.magenta("-> Continue to next variable"), "Add " + propertyName] : [
935
- ansis_1.default.magenta("-> Continue to next variable"),
881
+ const answer = await terminal.singleColumnMenu(localData.length < 1 ? [ansis.magenta("-> Continue to next variable"), "Add " + propertyName] : [
882
+ ansis.magenta("-> Continue to next variable"),
936
883
  "Add " + propertyName,
937
884
  "Edit " + propertyName,
938
885
  "Move " + propertyName,
@@ -940,9 +887,9 @@ class ODCliEditConfigInstance {
940
887
  "Duplicate " + propertyName,
941
888
  ], {
942
889
  leftPadding: "> ",
943
- style: terminal_kit_1.terminal.cyan,
944
- selectedStyle: terminal_kit_1.terminal.bgDefaultColor.bold,
945
- submittedStyle: terminal_kit_1.terminal.bgBlue,
890
+ style: terminal.cyan,
891
+ selectedStyle: terminal.bgDefaultColor.bold,
892
+ submittedStyle: terminal.bgBlue,
946
893
  extraLines: 2,
947
894
  cancelable: true
948
895
  }).promise;
@@ -966,10 +913,10 @@ class ODCliEditConfigInstance {
966
913
  await this.renderConfigArrayStructureDuplicateSelector(checker, backFnFunc, structure, structure.options.propertyChecker, localData, parent, parentIndex, path);
967
914
  }
968
915
  async renderAdditionConfigTypeSwitchStructure(checker, backFn, nextFn, structure, parent, parentIndex, path, localPath) {
969
- (0, _1.renderHeader)(this.opts, path);
970
- (0, terminal_kit_1.terminal)(ansis_1.default.bold.green("You are now creating " + (typeof parentIndex == "string" ? "the property " + ansis_1.default.blue("\"" + parentIndex + "\"") : "property " + ansis_1.default.blue("#" + (parentIndex + 1))) + ".\n") + ansis_1.default.italic.gray("(use arrow keys to navigate, go back using escape)\n"));
971
- terminal_kit_1.terminal.gray("\nProperty: " + ansis_1.default.bold.blue(structure.options.cliDisplayName ?? [...localPath, parentIndex].join(".")) + "\n");
972
- terminal_kit_1.terminal.gray("Description: " + ansis_1.default.bold(structure.options.cliDisplayDescription ?? "/") + "\n");
916
+ renderHeader(this.opts, path);
917
+ terminal(ansis.bold.green("You are now creating " + (typeof parentIndex == "string" ? "the property " + ansis.blue("\"" + parentIndex + "\"") : "property " + ansis.blue("#" + (parentIndex + 1))) + ".\n") + ansis.italic.gray("(use arrow keys to navigate, go back using escape)\n"));
918
+ terminal.gray("\nProperty: " + ansis.bold.blue(structure.options.cliDisplayName ?? [...localPath, parentIndex].join(".")) + "\n");
919
+ terminal.gray("Description: " + ansis.bold(structure.options.cliDisplayDescription ?? "/") + "\n");
973
920
  const actionsList = [];
974
921
  if (structure.options.boolean)
975
922
  actionsList.push("Create as boolean");
@@ -983,11 +930,11 @@ class ODCliEditConfigInstance {
983
930
  actionsList.push("Create as array/list");
984
931
  if (structure.options.null)
985
932
  actionsList.push("Create as null");
986
- const answer = await terminal_kit_1.terminal.singleColumnMenu(actionsList, {
933
+ const answer = await terminal.singleColumnMenu(actionsList, {
987
934
  leftPadding: "> ",
988
- style: terminal_kit_1.terminal.cyan,
989
- selectedStyle: terminal_kit_1.terminal.bgDefaultColor.bold,
990
- submittedStyle: terminal_kit_1.terminal.bgBlue,
935
+ style: terminal.cyan,
936
+ selectedStyle: terminal.bgDefaultColor.bold,
937
+ submittedStyle: terminal.bgBlue,
991
938
  extraLines: 2,
992
939
  cancelable: true
993
940
  }).promise;
@@ -1008,4 +955,3 @@ class ODCliEditConfigInstance {
1008
955
  await this.renderAdditionConfigNullStructure(checker, async () => { await this.renderAdditionConfigTypeSwitchStructure(checker, backFn, nextFn, structure, parent, parentIndex, path, localPath); }, nextFn, structure.options.null, parent, parentIndex, path, localPath);
1009
956
  }
1010
957
  }
1011
- exports.ODCliEditConfigInstance = ODCliEditConfigInstance;