@open-discord-bots/framework 0.2.10 → 0.2.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/main.js +1 -1
- package/dist/api/modules/action.d.ts +9 -9
- package/dist/api/modules/action.js +3 -3
- package/dist/api/modules/base.d.ts +5 -3
- package/dist/api/modules/base.js +8 -4
- package/dist/api/modules/builder.d.ts +41 -41
- package/dist/api/modules/builder.js +20 -20
- package/dist/api/modules/checker.d.ts +3 -3
- package/dist/api/modules/client.js +2 -2
- package/dist/api/modules/console.d.ts +15 -15
- package/dist/api/modules/console.js +31 -31
- package/dist/api/modules/event.js +2 -2
- package/dist/api/modules/helpmenu.js +1 -1
- package/dist/api/modules/progressbar.js +1 -0
- package/dist/api/modules/responder.d.ts +37 -37
- package/dist/api/modules/responder.js +13 -13
- package/dist/api/modules/statistic.js +0 -2
- package/dist/api/modules/worker.d.ts +14 -14
- package/dist/api/modules/worker.js +9 -9
- package/dist/cli/editConfig.js +6 -20
- package/dist/startup/pluginLauncher.js +6 -4
- package/dist/utilities/index.d.ts +2 -2
- package/package.json +4 -4
- package/src/api/main.ts +1 -1
- package/src/api/modules/action.ts +10 -10
- package/src/api/modules/base.ts +12 -8
- package/src/api/modules/builder.ts +53 -53
- package/src/api/modules/checker.ts +3 -3
- package/src/api/modules/client.ts +15 -15
- package/src/api/modules/component.txt +350 -0
- package/src/api/modules/config.ts +1 -1
- package/src/api/modules/console.ts +26 -26
- package/src/api/modules/database.ts +1 -1
- package/src/api/modules/event.ts +5 -5
- package/src/api/modules/helpmenu.ts +3 -3
- package/src/api/modules/language.ts +1 -1
- package/src/api/modules/plugin.ts +1 -1
- package/src/api/modules/progressbar.ts +3 -1
- package/src/api/modules/responder.ts +43 -43
- package/src/api/modules/statistic.ts +0 -1
- package/src/api/modules/worker.ts +25 -25
- package/src/cli/editConfig.ts +20 -34
- package/src/startup/compilation.ts +2 -2
- package/src/startup/pluginLauncher.ts +9 -6
- package/src/utilities/index.ts +3 -3
- package/tsconfig.json +1 -0
|
@@ -2,7 +2,7 @@ import { ODManager, ODManagerData, ODValidId } from "./base";
|
|
|
2
2
|
/**## ODWorkerCallback `type`
|
|
3
3
|
* This is the callback used in `ODWorker`!
|
|
4
4
|
*/
|
|
5
|
-
export type ODWorkerCallback<Instance,
|
|
5
|
+
export type ODWorkerCallback<Instance, Origin extends string, Params> = (instance: Instance, params: Params, origin: Origin, cancel: () => void) => void | Promise<void>;
|
|
6
6
|
/**## ODWorker `class`
|
|
7
7
|
* This is an Open Discord worker.
|
|
8
8
|
*
|
|
@@ -10,15 +10,15 @@ export type ODWorkerCallback<Instance, Source extends string, Params> = (instanc
|
|
|
10
10
|
*
|
|
11
11
|
* - It has an `id` for identification of the function
|
|
12
12
|
* - A `priority` to know when to execute this callback (related to others)
|
|
13
|
-
* - It knows who called this callback (`
|
|
13
|
+
* - It knows who called this callback (`origin`)
|
|
14
14
|
* - And much more!
|
|
15
15
|
*/
|
|
16
|
-
export declare class ODWorker<Instance,
|
|
16
|
+
export declare class ODWorker<Instance, Origin extends string, Params> extends ODManagerData {
|
|
17
17
|
/**The priority of this worker */
|
|
18
18
|
priority: number;
|
|
19
19
|
/**The main callback of this worker */
|
|
20
|
-
callback: ODWorkerCallback<Instance,
|
|
21
|
-
constructor(id: ODValidId, priority: number, callback: ODWorkerCallback<Instance,
|
|
20
|
+
callback: ODWorkerCallback<Instance, Origin, Params>;
|
|
21
|
+
constructor(id: ODValidId, priority: number, callback: ODWorkerCallback<Instance, Origin, Params>);
|
|
22
22
|
}
|
|
23
23
|
/**## ODWorker `class`
|
|
24
24
|
* This is an Open Discord worker manager.
|
|
@@ -27,21 +27,21 @@ export declare class ODWorker<Instance, Source extends string, Params> extends O
|
|
|
27
27
|
*
|
|
28
28
|
* You can register a custom worker in this class to create a message or button.
|
|
29
29
|
*/
|
|
30
|
-
export declare class ODWorkerManager<Instance,
|
|
30
|
+
export declare class ODWorkerManager<Instance, Origin extends string, Params, WorkerIds extends string = string> extends ODManager<ODWorker<Instance, Origin, Params>> {
|
|
31
31
|
#private;
|
|
32
32
|
/**The backup worker will be executed when one of the workers fails or cancels execution. */
|
|
33
33
|
backupWorker: ODWorker<{
|
|
34
34
|
reason: "error" | "cancel";
|
|
35
|
-
},
|
|
35
|
+
}, Origin, Params> | null;
|
|
36
36
|
constructor(priorityOrder: "ascending" | "descending");
|
|
37
37
|
/**Get all workers in sorted order. */
|
|
38
|
-
getSortedWorkers(priority: "ascending" | "descending"): ODWorker<Instance,
|
|
39
|
-
/**Execute all workers on an instance using the given
|
|
40
|
-
executeWorkers(instance: Instance,
|
|
41
|
-
get(id: WorkerIds): ODWorker<Instance,
|
|
42
|
-
get(id: ODValidId): ODWorker<Instance,
|
|
43
|
-
remove(id: WorkerIds): ODWorker<Instance,
|
|
44
|
-
remove(id: ODValidId): ODWorker<Instance,
|
|
38
|
+
getSortedWorkers(priority: "ascending" | "descending"): ODWorker<Instance, Origin, Params>[];
|
|
39
|
+
/**Execute all workers on an instance using the given origin & parameters. */
|
|
40
|
+
executeWorkers(instance: Instance, origin: Origin, params: Params): Promise<void>;
|
|
41
|
+
get(id: WorkerIds): ODWorker<Instance, Origin, Params>;
|
|
42
|
+
get(id: ODValidId): ODWorker<Instance, Origin, Params> | null;
|
|
43
|
+
remove(id: WorkerIds): ODWorker<Instance, Origin, Params>;
|
|
44
|
+
remove(id: ODValidId): ODWorker<Instance, Origin, Params> | null;
|
|
45
45
|
exists(id: WorkerIds): boolean;
|
|
46
46
|
exists(id: ODValidId): boolean;
|
|
47
47
|
}
|
|
@@ -12,7 +12,7 @@ const base_1 = require("./base");
|
|
|
12
12
|
*
|
|
13
13
|
* - It has an `id` for identification of the function
|
|
14
14
|
* - A `priority` to know when to execute this callback (related to others)
|
|
15
|
-
* - It knows who called this callback (`
|
|
15
|
+
* - It knows who called this callback (`origin`)
|
|
16
16
|
* - And much more!
|
|
17
17
|
*/
|
|
18
18
|
class ODWorker extends base_1.ODManagerData {
|
|
@@ -53,8 +53,8 @@ class ODWorkerManager extends base_1.ODManager {
|
|
|
53
53
|
return b.priority - a.priority;
|
|
54
54
|
});
|
|
55
55
|
}
|
|
56
|
-
/**Execute all workers on an instance using the given
|
|
57
|
-
async executeWorkers(instance,
|
|
56
|
+
/**Execute all workers on an instance using the given origin & parameters. */
|
|
57
|
+
async executeWorkers(instance, origin, params) {
|
|
58
58
|
const derefParams = { ...params };
|
|
59
59
|
const workers = this.getSortedWorkers(this.#priorityOrder);
|
|
60
60
|
let didCancel = false;
|
|
@@ -63,29 +63,29 @@ class ODWorkerManager extends base_1.ODManager {
|
|
|
63
63
|
if (didCancel)
|
|
64
64
|
break;
|
|
65
65
|
try {
|
|
66
|
-
await worker.callback(instance, derefParams,
|
|
66
|
+
await worker.callback(instance, derefParams, origin, () => {
|
|
67
67
|
didCancel = true;
|
|
68
68
|
});
|
|
69
69
|
}
|
|
70
70
|
catch (err) {
|
|
71
|
-
process.emit("uncaughtException", err);
|
|
71
|
+
process.emit("uncaughtException", new base_1.ODSystemError(err));
|
|
72
72
|
didCrash = true;
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
75
|
if (didCancel && this.backupWorker) {
|
|
76
76
|
try {
|
|
77
|
-
await this.backupWorker.callback({ reason: "cancel" }, derefParams,
|
|
77
|
+
await this.backupWorker.callback({ reason: "cancel" }, derefParams, origin, () => { });
|
|
78
78
|
}
|
|
79
79
|
catch (err) {
|
|
80
|
-
process.emit("uncaughtException", err);
|
|
80
|
+
process.emit("uncaughtException", new base_1.ODSystemError(err));
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
83
|
else if (didCrash && this.backupWorker) {
|
|
84
84
|
try {
|
|
85
|
-
await this.backupWorker.callback({ reason: "error" }, derefParams,
|
|
85
|
+
await this.backupWorker.callback({ reason: "error" }, derefParams, origin, () => { });
|
|
86
86
|
}
|
|
87
87
|
catch (err) {
|
|
88
|
-
process.emit("uncaughtException", err);
|
|
88
|
+
process.emit("uncaughtException", new base_1.ODSystemError(err));
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
91
|
}
|
package/dist/cli/editConfig.js
CHANGED
|
@@ -522,7 +522,7 @@ class ODCliEditConfigInstance {
|
|
|
522
522
|
if (!structure.options.cliDisplayKeyInParentArray)
|
|
523
523
|
return "Object".length;
|
|
524
524
|
else
|
|
525
|
-
return data[structure.options.cliDisplayKeyInParentArray]
|
|
525
|
+
return data[structure.options.cliDisplayKeyInParentArray]?.toString().length ?? 0;
|
|
526
526
|
}
|
|
527
527
|
else if (structure instanceof api.ODCheckerEnabledObjectStructure && typeof data == "object" && !Array.isArray(data) && data) {
|
|
528
528
|
const subStructure = structure.options.checker;
|
|
@@ -571,11 +571,11 @@ class ODCliEditConfigInstance {
|
|
|
571
571
|
else if (structure instanceof api.ODCheckerArrayStructure && Array.isArray(data))
|
|
572
572
|
return "Array";
|
|
573
573
|
else if (structure instanceof api.ODCheckerObjectStructure && typeof data == "object" && !Array.isArray(data) && data) {
|
|
574
|
-
const additionalKeys = (structure.options.cliDisplayAdditionalKeysInParentArray ?? []).map((key) => key + ": " + data[key]
|
|
574
|
+
const additionalKeys = (structure.options.cliDisplayAdditionalKeysInParentArray ?? []).map((key) => key + ": " + data[key]?.toString()).join(", ");
|
|
575
575
|
if (!structure.options.cliDisplayKeyInParentArray)
|
|
576
576
|
return "Object";
|
|
577
577
|
else
|
|
578
|
-
return data[structure.options.cliDisplayKeyInParentArray]
|
|
578
|
+
return data[structure.options.cliDisplayKeyInParentArray]?.toString().padEnd(nameLength + 5, " ") + ansis_1.default.gray(additionalKeys.length > 0 ? "(" + additionalKeys + ")" : "");
|
|
579
579
|
}
|
|
580
580
|
else if (structure instanceof api.ODCheckerEnabledObjectStructure && typeof data == "object" && !Array.isArray(data) && data) {
|
|
581
581
|
const subStructure = structure.options.checker;
|
|
@@ -715,15 +715,8 @@ class ODCliEditConfigInstance {
|
|
|
715
715
|
else {
|
|
716
716
|
localData[enabledProperty] = data;
|
|
717
717
|
//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,
|
|
719
|
-
//
|
|
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
|
|
718
|
+
const newStructure = new api.ODCheckerObjectStructure(subStructure.id, structuredClone(subStructure.options));
|
|
719
|
+
//continues to next function
|
|
727
720
|
await this.renderAdditionConfigObjectStructure(checker, async () => { await this.renderAdditionConfigEnabledObjectStructure(checker, backFn, nextFn, structure, parent, parentIndex, path, localPath); }, nextFn, newStructure, parent, parentIndex, path, localPath, localData);
|
|
728
721
|
await nextFn(localData);
|
|
729
722
|
}
|
|
@@ -745,14 +738,7 @@ class ODCliEditConfigInstance {
|
|
|
745
738
|
const objectTemplate = structure.options.objects[answer.selectedIndex];
|
|
746
739
|
//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
740
|
const oldStructure = objectTemplate.checker;
|
|
748
|
-
const newStructure = new api.ODCheckerObjectStructure(oldStructure.id,
|
|
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
|
-
}
|
|
741
|
+
const newStructure = new api.ODCheckerObjectStructure(oldStructure.id, structuredClone(oldStructure.options));
|
|
756
742
|
//add the keys of the object switch properties to the 'cliInitSkipKeys' because they need to be skipped.
|
|
757
743
|
objectTemplate.properties.map((p) => p.key).forEach((p) => {
|
|
758
744
|
if (!newStructure.options.cliInitSkipKeys)
|
|
@@ -53,17 +53,19 @@ const loadAllPlugins = async (opendiscord) => {
|
|
|
53
53
|
for (const p of plugins) {
|
|
54
54
|
//prechecks
|
|
55
55
|
if (p === ".DS_Store")
|
|
56
|
-
|
|
57
|
-
if (!fs_1.default.statSync("./plugins/" + p).isDirectory())
|
|
58
|
-
|
|
56
|
+
continue; //ignore MacOS DS_Store file
|
|
57
|
+
if (!fs_1.default.statSync("./plugins/" + p).isDirectory()) {
|
|
58
|
+
opendiscord.log("Plugin is not a directory, canceling plugin execution...", "plugin", [
|
|
59
59
|
{ key: "plugin", value: "./plugins/" + p }
|
|
60
60
|
]);
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
61
63
|
if (!fs_1.default.existsSync("./plugins/" + p + "/plugin.json")) {
|
|
62
64
|
initPluginError = true;
|
|
63
65
|
opendiscord.log("Plugin doesn't have a plugin.json, canceling plugin execution...", "plugin", [
|
|
64
66
|
{ key: "plugin", value: "./plugins/" + p }
|
|
65
67
|
]);
|
|
66
|
-
|
|
68
|
+
continue;
|
|
67
69
|
}
|
|
68
70
|
//plugin loading
|
|
69
71
|
try {
|
|
@@ -38,7 +38,7 @@ export declare function timedAwait<ReturnValue>(promise: ReturnValue, timeout: n
|
|
|
38
38
|
/**## dateString `utility function`
|
|
39
39
|
* Use this function to create a short date string in the following format: `DD/MM/YYYY HH:MM:SS`
|
|
40
40
|
*/
|
|
41
|
-
export declare function dateString(date:
|
|
41
|
+
export declare function dateString(date: Date): string;
|
|
42
42
|
/**## asyncReplace `utility function`
|
|
43
43
|
* Same as `string.replace(search, value)` but with async compatibility
|
|
44
44
|
*/
|
|
@@ -54,7 +54,7 @@ export declare function ordinalNumber(num: number): string;
|
|
|
54
54
|
/**## trimEmojis `utility function`
|
|
55
55
|
* Trim/remove all emoji's from a Javascript string.
|
|
56
56
|
*/
|
|
57
|
-
export declare function trimEmojis(text:
|
|
57
|
+
export declare function trimEmojis(text: string): string;
|
|
58
58
|
/**## easterEggs `utility object`
|
|
59
59
|
* Object containing data for Open Ticket easter eggs.
|
|
60
60
|
*/
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@open-discord-bots/framework",
|
|
3
3
|
"author": "DJj123dj",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.12",
|
|
5
5
|
"description": "The core framework of the popular open-source discord bots: Open Ticket & Open Moderation.",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"module": "dist/index.js",
|
|
@@ -14,10 +14,10 @@
|
|
|
14
14
|
"@discordjs/rest": "^2.6.1",
|
|
15
15
|
"@types/terminal-kit": "^2.5.7",
|
|
16
16
|
"ansis": "^4.2.0",
|
|
17
|
-
"discord.js": "^14.26.
|
|
18
|
-
"formatted-json-stringify": "^1.
|
|
17
|
+
"discord.js": "^14.26.3",
|
|
18
|
+
"formatted-json-stringify": "^1.3.0",
|
|
19
19
|
"terminal-kit": "^3.1.2",
|
|
20
|
-
"typescript": "^
|
|
20
|
+
"typescript": "^6.0.3"
|
|
21
21
|
},
|
|
22
22
|
"repository": {
|
|
23
23
|
"type": "git",
|
package/src/api/main.ts
CHANGED
|
@@ -142,7 +142,7 @@ export class ODMain implements ODMainManagers {
|
|
|
142
142
|
constructor(managers:ODMainManagers,project:ODProjectType){
|
|
143
143
|
this.project = project
|
|
144
144
|
this.versions = managers.versions
|
|
145
|
-
this.versions.add(ODVersion.fromString("opendiscord:api","v0.2.
|
|
145
|
+
this.versions.add(ODVersion.fromString("opendiscord:api","v0.2.12"))
|
|
146
146
|
this.versions.add(ODVersion.fromString("opendiscord:livestatus","v2.0.0"))
|
|
147
147
|
|
|
148
148
|
this.debugfile = managers.debugfile
|
|
@@ -12,17 +12,17 @@ import { ODDebugger } from "./console"
|
|
|
12
12
|
*
|
|
13
13
|
* This class can't be used stand-alone & needs to be extended from!
|
|
14
14
|
*/
|
|
15
|
-
export class ODActionImplementation<
|
|
15
|
+
export class ODActionImplementation<Origin extends string,Params extends object,Result extends object,WorkerIds extends string = string> extends ODManagerData {
|
|
16
16
|
/**The manager that has all workers of this implementation */
|
|
17
|
-
workers: ODWorkerManager<
|
|
17
|
+
workers: ODWorkerManager<Partial<Result>,Origin,Params,WorkerIds>
|
|
18
18
|
|
|
19
|
-
constructor(id:ODValidId, callback?:ODWorkerCallback<
|
|
19
|
+
constructor(id:ODValidId, callback?:ODWorkerCallback<Partial<Result>,Origin,Params>, priority?:number, callbackId?:ODValidId){
|
|
20
20
|
super(id)
|
|
21
21
|
this.workers = new ODWorkerManager("descending")
|
|
22
22
|
if (callback) this.workers.add(new ODWorker(callbackId ? callbackId : id,priority ?? 0,callback))
|
|
23
23
|
}
|
|
24
24
|
/**Execute all workers & return the result. */
|
|
25
|
-
async run(
|
|
25
|
+
async run(origin:Origin, params:Params): Promise<Partial<Result>> {
|
|
26
26
|
throw new ODSystemError("Tried to build an unimplemented ODResponderImplementation")
|
|
27
27
|
}
|
|
28
28
|
}
|
|
@@ -30,7 +30,7 @@ export class ODActionImplementation<Source extends string,Params extends object,
|
|
|
30
30
|
/**## ODActionManagerIdConstraint `type`
|
|
31
31
|
* The constraint/layout for id mappings/interfaces of the `ODActionManager` class.
|
|
32
32
|
*/
|
|
33
|
-
export type ODActionManagerIdConstraint = Record<string,{
|
|
33
|
+
export type ODActionManagerIdConstraint = Record<string,{origin:string,params:object,result:object,workers:string}>
|
|
34
34
|
|
|
35
35
|
/**## ODActionManager `class`
|
|
36
36
|
* This is an Open Discord action manager.
|
|
@@ -47,14 +47,14 @@ export class ODActionManager<IdList extends ODActionManagerIdConstraint = ODActi
|
|
|
47
47
|
super(debug,"action")
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
get<ActionId extends keyof ODNoGeneric<IdList>>(id:ActionId): ODAction<IdList[ActionId]["
|
|
50
|
+
get<ActionId extends keyof ODNoGeneric<IdList>>(id:ActionId): ODAction<IdList[ActionId]["origin"],IdList[ActionId]["params"],IdList[ActionId]["result"],IdList[ActionId]["workers"]>
|
|
51
51
|
get(id:ODValidId): ODAction<string,{},{},string>|null
|
|
52
52
|
|
|
53
53
|
get(id:ODValidId): ODAction<string,{},{},string>|null {
|
|
54
54
|
return super.get(id)
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
remove<ActionId extends keyof ODNoGeneric<IdList>>(id:ActionId): ODAction<IdList[ActionId]["
|
|
57
|
+
remove<ActionId extends keyof ODNoGeneric<IdList>>(id:ActionId): ODAction<IdList[ActionId]["origin"],IdList[ActionId]["params"],IdList[ActionId]["result"],IdList[ActionId]["workers"]>
|
|
58
58
|
remove(id:ODValidId): ODAction<string,{},{},string>|null
|
|
59
59
|
|
|
60
60
|
remove(id:ODValidId): ODAction<string,{},{},string>|null {
|
|
@@ -76,14 +76,14 @@ export class ODActionManager<IdList extends ODActionManagerIdConstraint = ODActi
|
|
|
76
76
|
*
|
|
77
77
|
* Can be used standalone.
|
|
78
78
|
*/
|
|
79
|
-
export class ODAction<
|
|
79
|
+
export class ODAction<Origin extends string,Params extends object,Result extends object,WorkerIds extends string = string> extends ODActionImplementation<Origin,Params,Result,WorkerIds> {
|
|
80
80
|
/**Run this action */
|
|
81
|
-
async run(
|
|
81
|
+
async run(origin:Origin, params:Params): Promise<Partial<Result>> {
|
|
82
82
|
//create instance
|
|
83
83
|
const instance = {}
|
|
84
84
|
|
|
85
85
|
//wait for workers to finish
|
|
86
|
-
await this.workers.executeWorkers(instance,
|
|
86
|
+
await this.workers.executeWorkers(instance,origin,params)
|
|
87
87
|
|
|
88
88
|
//return data generated by workers
|
|
89
89
|
return instance
|
package/src/api/modules/base.ts
CHANGED
|
@@ -37,7 +37,7 @@ export type ODValidId = string|number|symbol|ODId
|
|
|
37
37
|
*
|
|
38
38
|
* list: `string`, `number`, `boolean`, `array`, `object`, `null`
|
|
39
39
|
*/
|
|
40
|
-
export type ODValidJsonType = string|number|boolean|
|
|
40
|
+
export type ODValidJsonType = string|number|boolean|{[key:string]:ODValidJsonType}|ODValidJsonType[]|null
|
|
41
41
|
|
|
42
42
|
/**## ODInterfaceWithPartialProperty `type`
|
|
43
43
|
* A utility type to create an interface where some properties are optional!
|
|
@@ -734,9 +734,9 @@ export class ODHTTPPostRequest {
|
|
|
734
734
|
*/
|
|
735
735
|
export class ODEnvHelper {
|
|
736
736
|
/**All variables found in the `.env` file */
|
|
737
|
-
dotenv:
|
|
737
|
+
dotenv: Record<string,any>
|
|
738
738
|
/**All variables found in `process.env` */
|
|
739
|
-
env:
|
|
739
|
+
env: Record<string,any>
|
|
740
740
|
|
|
741
741
|
constructor(customEnvPath?:string){
|
|
742
742
|
if (typeof customEnvPath != "undefined" && typeof customEnvPath != "string") throw new ODSystemError("Invalid constructor parameter => customEnvPath?:string")
|
|
@@ -767,7 +767,7 @@ export class ODEnvHelper {
|
|
|
767
767
|
//Source: https://github.com/motdotla/dotenv/blob/master/lib/main.js#L12
|
|
768
768
|
#readDotEnv(src:Buffer){
|
|
769
769
|
const LINE = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg
|
|
770
|
-
const obj = {}
|
|
770
|
+
const obj: Record<string,any> = {}
|
|
771
771
|
|
|
772
772
|
// Convert buffer to string
|
|
773
773
|
let lines = src.toString()
|
|
@@ -815,8 +815,10 @@ export class ODSystemError extends Error {
|
|
|
815
815
|
|
|
816
816
|
/**Create an `ODSystemError` directly from an `Error` class */
|
|
817
817
|
static fromError(err:Error){
|
|
818
|
-
|
|
819
|
-
|
|
818
|
+
const modifiedErr: ODSystemError = Object.assign(err,{
|
|
819
|
+
_ODErrorType:"system"
|
|
820
|
+
})
|
|
821
|
+
return modifiedErr as ODSystemError
|
|
820
822
|
}
|
|
821
823
|
}
|
|
822
824
|
|
|
@@ -831,8 +833,10 @@ export class ODPluginError extends Error {
|
|
|
831
833
|
|
|
832
834
|
/**Create an `ODPluginError` directly from an `Error` class */
|
|
833
835
|
static fromError(err:Error){
|
|
834
|
-
|
|
835
|
-
|
|
836
|
+
const modifiedErr: ODPluginError = Object.assign(err,{
|
|
837
|
+
_ODErrorType:"plugin"
|
|
838
|
+
})
|
|
839
|
+
return modifiedErr as ODPluginError
|
|
836
840
|
}
|
|
837
841
|
}
|
|
838
842
|
|