@quatrain/core 1.0.0-beta16 → 1.0.0-beta18
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/lib/Core.d.ts +3 -0
- package/lib/Core.js +46 -0
- package/package.json +4 -2
package/lib/Core.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ export type BackendRegistry<T extends AbstractAdapter> = {
|
|
|
8
8
|
export interface AuthAdapter extends AbstractAuthAdapter {
|
|
9
9
|
}
|
|
10
10
|
export declare class Core {
|
|
11
|
+
static storagePrefix: string;
|
|
11
12
|
static defaultBackend: string;
|
|
12
13
|
static defaultStorage: string;
|
|
13
14
|
static userClass: typeof User;
|
|
@@ -25,6 +26,8 @@ export declare class Core {
|
|
|
25
26
|
mandatory: boolean;
|
|
26
27
|
};
|
|
27
28
|
};
|
|
29
|
+
static addConfig(key: string, value: any): Promise<void>;
|
|
30
|
+
static getConfig(key: string): Promise<any>;
|
|
28
31
|
static addBackend(backend: AbstractAdapter, alias: string, setDefault?: boolean): void;
|
|
29
32
|
static getBackend<T extends AbstractAdapter>(alias?: string): T;
|
|
30
33
|
static addStorage(backend: AbstractAdapter, alias: string, setDefault?: boolean): void;
|
package/lib/Core.js
CHANGED
|
@@ -1,8 +1,41 @@
|
|
|
1
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 (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
};
|
|
2
34
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
35
|
exports.Core = void 0;
|
|
4
36
|
const DataObject_1 = require("./components/DataObject");
|
|
5
37
|
const User_1 = require("./components/User");
|
|
38
|
+
const storage = __importStar(require("node-persist"));
|
|
6
39
|
class Core {
|
|
7
40
|
static definition(key) {
|
|
8
41
|
return {
|
|
@@ -12,6 +45,18 @@ class Core {
|
|
|
12
45
|
},
|
|
13
46
|
};
|
|
14
47
|
}
|
|
48
|
+
static addConfig(key, value) {
|
|
49
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
50
|
+
storage.init( /* options ... */);
|
|
51
|
+
yield storage.setItem(`${this.storagePrefix}_${key}`, value);
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
static getConfig(key) {
|
|
55
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
56
|
+
storage.init( /* options ... */);
|
|
57
|
+
return yield storage.getItem(`${this.storagePrefix}_${key}`);
|
|
58
|
+
});
|
|
59
|
+
}
|
|
15
60
|
static addBackend(backend, alias, setDefault = false) {
|
|
16
61
|
Core._backends[alias] = backend;
|
|
17
62
|
if (setDefault) {
|
|
@@ -65,6 +110,7 @@ class Core {
|
|
|
65
110
|
}
|
|
66
111
|
}
|
|
67
112
|
exports.Core = Core;
|
|
113
|
+
Core.storagePrefix = 'core';
|
|
68
114
|
Core.defaultBackend = '@default';
|
|
69
115
|
Core.defaultStorage = '@default';
|
|
70
116
|
Core.userClass = User_1.User;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quatrain/core",
|
|
3
|
-
"version": "1.0.0-
|
|
3
|
+
"version": "1.0.0-beta18",
|
|
4
4
|
"description": "Core objects for business apps",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -21,7 +21,9 @@
|
|
|
21
21
|
"typescript": "^5.1.5"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@faker-js/faker": "^7.6.0"
|
|
24
|
+
"@faker-js/faker": "^7.6.0",
|
|
25
|
+
"@types/node-persist": "^3.1.8",
|
|
26
|
+
"node-persist": "^4.0.3"
|
|
25
27
|
},
|
|
26
28
|
"scripts": {
|
|
27
29
|
"test": "tsc && jest --verbose",
|