@elara-services/packages 6.0.7 → 6.0.9

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elara-services/packages",
3
- "version": "6.0.7",
3
+ "version": "6.0.9",
4
4
  "description": "",
5
5
  "main": "./dist/src/index.js",
6
6
  "author": "SUPERCHIEFYT (Elara-Discord-Bots, Elara-Services)",
@@ -1 +1 @@
1
- export declare function fetch<B extends object, T>(url: string, key?: string, body?: B | undefined, postRequest?: boolean, returnRaw?: boolean): Promise<T | null>;
1
+ export declare function fetch<B extends object, T>(url: string, key?: string, body?: B | undefined, postRequest?: boolean, returnRaw?: boolean, addHeaders?: Record<string, string | number>): Promise<T | null>;
@@ -33,18 +33,22 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
33
33
  };
34
34
  Object.defineProperty(exports, "__esModule", { value: true });
35
35
  exports.fetch = void 0;
36
- function fetch(url, key = "", body = undefined, postRequest = false, returnRaw = false) {
36
+ const utils_1 = require("@elara-services/utils");
37
+ function fetch(url, key = "", body = undefined, postRequest = false, returnRaw = false, addHeaders) {
37
38
  return __awaiter(this, void 0, void 0, function* () {
38
39
  try {
39
40
  const client = yield Promise.resolve().then(() => __importStar(require("@elara-services/fetch"))).catch(() => { });
40
41
  if (!client) {
41
- throw new Error(`NPM package (@elara-services/fetch) now found`);
42
+ throw new Error(`NPM package (@elara-services/fetch) not found`);
42
43
  }
43
- const headers = {
44
- "User-Agent": `Services v${Math.floor(Math.random() * 999999)}`,
44
+ let headers = {
45
+ "user-agent": `Services v${Math.floor(Math.random() * 9999)}`,
45
46
  authorization: "",
46
47
  };
47
- if (key !== "" && key) {
48
+ if (utils_1.is.object(addHeaders)) {
49
+ headers = Object.assign(Object.assign({}, headers), addHeaders);
50
+ }
51
+ if (utils_1.is.string(key)) {
48
52
  headers["authorization"] = key;
49
53
  }
50
54
  else {
@@ -1,5 +1,5 @@
1
1
  export declare class Tasks extends null {
2
- create({ id, time, shouldCancel }: TaskCreate | undefined, run: (...args: unknown[]) => Promise<unknown> | unknown): Promise<string | import("node-schedule").Job>;
2
+ static create({ id, time, shouldCancel }: TaskCreate | undefined, run: (...args: unknown[]) => Promise<unknown> | unknown): Promise<string | import("node-schedule").Job>;
3
3
  static delete(id: string): Promise<boolean | null>;
4
4
  }
5
5
  export interface TaskCreate {
@@ -35,7 +35,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
35
35
  exports.Tasks = void 0;
36
36
  const utils_1 = require("@elara-services/utils");
37
37
  class Tasks extends null {
38
- create({ id, time, shouldCancel } = {
38
+ static create({ id, time, shouldCancel } = {
39
39
  id: "",
40
40
  time: "",
41
41
  shouldCancel: true,