@quatrain/core 1.1.4 → 1.1.6
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 +8 -3
- package/lib/Core.js +24 -6
- package/package.json +36 -34
- package/lib/statuses.d.ts +0 -13
- package/lib/statuses.js +0 -16
package/lib/Core.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { User } from './components/User';
|
|
2
2
|
import { DataObjectClass } from './components/types/DataObjectClass';
|
|
3
|
+
import logger from 'loglevel';
|
|
3
4
|
export declare class Core {
|
|
4
5
|
static storage: any;
|
|
5
6
|
static storagePrefix: string;
|
|
@@ -7,7 +8,7 @@ export declare class Core {
|
|
|
7
8
|
static classRegistry: {
|
|
8
9
|
[key: string]: any;
|
|
9
10
|
};
|
|
10
|
-
static logger:
|
|
11
|
+
static logger: logger.RootLogger;
|
|
11
12
|
static timestamp: () => string;
|
|
12
13
|
static definition(key: string): {
|
|
13
14
|
manifest: {
|
|
@@ -25,11 +26,15 @@ export declare class Core {
|
|
|
25
26
|
* @returns DataObjectClass
|
|
26
27
|
*/
|
|
27
28
|
static getDataObjectClass(): DataObjectClass<any>;
|
|
29
|
+
protected static formatLogMessage: (message: any) => string;
|
|
28
30
|
/**
|
|
29
31
|
* Log message using defined logger
|
|
30
|
-
* This is currently just a stub that will be implemented from config in the future
|
|
31
32
|
* @param message string | object
|
|
32
33
|
* @param level string
|
|
33
34
|
*/
|
|
34
|
-
static log(message: any,
|
|
35
|
+
static log(message: any, level?: any): void;
|
|
36
|
+
static debug(message: any): void;
|
|
37
|
+
static warn(message: any): void;
|
|
38
|
+
static info(message: any): void;
|
|
39
|
+
static error(message: any): void;
|
|
35
40
|
}
|
package/lib/Core.js
CHANGED
|
@@ -8,10 +8,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
var _a;
|
|
11
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
16
|
exports.Core = void 0;
|
|
13
17
|
const DataObject_1 = require("./components/DataObject");
|
|
14
18
|
const User_1 = require("./components/User");
|
|
19
|
+
const loglevel_1 = __importDefault(require("loglevel"));
|
|
15
20
|
class Core {
|
|
16
21
|
static definition(key) {
|
|
17
22
|
return {
|
|
@@ -38,10 +43,10 @@ class Core {
|
|
|
38
43
|
});
|
|
39
44
|
}
|
|
40
45
|
static addClass(name, obj) {
|
|
41
|
-
|
|
46
|
+
_a.classRegistry[name] = obj;
|
|
42
47
|
}
|
|
43
48
|
static getClass(name) {
|
|
44
|
-
return
|
|
49
|
+
return _a.classRegistry[name];
|
|
45
50
|
}
|
|
46
51
|
/**
|
|
47
52
|
* Returns the class to use for a data object
|
|
@@ -53,19 +58,32 @@ class Core {
|
|
|
53
58
|
}
|
|
54
59
|
/**
|
|
55
60
|
* Log message using defined logger
|
|
56
|
-
* This is currently just a stub that will be implemented from config in the future
|
|
57
61
|
* @param message string | object
|
|
58
62
|
* @param level string
|
|
59
63
|
*/
|
|
60
|
-
static log(message,
|
|
61
|
-
|
|
64
|
+
static log(message, level = loglevel_1.default.levels.WARN) {
|
|
65
|
+
_a.logger.log(_a.formatLogMessage(message));
|
|
66
|
+
}
|
|
67
|
+
static debug(message) {
|
|
68
|
+
_a.logger.debug(_a.formatLogMessage(message));
|
|
69
|
+
}
|
|
70
|
+
static warn(message) {
|
|
71
|
+
_a.logger.warn(_a.formatLogMessage(message));
|
|
72
|
+
}
|
|
73
|
+
static info(message) {
|
|
74
|
+
_a.logger.info(_a.formatLogMessage(message));
|
|
75
|
+
}
|
|
76
|
+
static error(message) {
|
|
77
|
+
_a.logger.error(_a.formatLogMessage(message));
|
|
62
78
|
}
|
|
63
79
|
}
|
|
64
80
|
exports.Core = Core;
|
|
81
|
+
_a = Core;
|
|
65
82
|
Core.storage = require('node-persist');
|
|
66
83
|
Core.storagePrefix = 'core';
|
|
67
84
|
Core.userClass = User_1.User;
|
|
68
85
|
Core.classRegistry = {};
|
|
69
|
-
Core.logger =
|
|
86
|
+
Core.logger = loglevel_1.default;
|
|
70
87
|
// How timestamp are formatted
|
|
71
88
|
Core.timestamp = () => new Date().toISOString();
|
|
89
|
+
Core.formatLogMessage = (message) => `${_a.timestamp()} - [${_a.name}] ${typeof message === 'string' ? message : JSON.stringify(message)}`;
|
package/package.json
CHANGED
|
@@ -1,35 +1,37 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
2
|
+
"name": "@quatrain/core",
|
|
3
|
+
"version": "1.1.6",
|
|
4
|
+
"description": "Core objects for business apps",
|
|
5
|
+
"main": "lib/index.js",
|
|
6
|
+
"types": "lib/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"lib/",
|
|
9
|
+
"README.md"
|
|
10
|
+
],
|
|
11
|
+
"author": "Quatrain Développement SAS <developers@quatrain.com>",
|
|
12
|
+
"license": "MIT",
|
|
13
|
+
"devDependencies": {
|
|
14
|
+
"@tsconfig/recommended": "^1.0.1",
|
|
15
|
+
"@types/jest": "^27.0.3",
|
|
16
|
+
"@types/node": "^22.10.1",
|
|
17
|
+
"@types/node-persist": "^3.1.8",
|
|
18
|
+
"jest": "^27.4.7",
|
|
19
|
+
"jest-node-exports-resolver": "^1.1.6",
|
|
20
|
+
"trace-unhandled": "^2.0.1",
|
|
21
|
+
"ts-jest": "^27.1.2",
|
|
22
|
+
"ts-node": "^10.4.0",
|
|
23
|
+
"typescript": "^5.1.5"
|
|
24
|
+
},
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"@faker-js/faker": "^7.6.0",
|
|
27
|
+
"loglevel": "^1.9.2",
|
|
28
|
+
"node-persist": "^4.0.3"
|
|
29
|
+
},
|
|
30
|
+
"scripts": {
|
|
31
|
+
"test": "tsc && jest --verbose",
|
|
32
|
+
"build": "tsc",
|
|
33
|
+
"wbuild": "tsc --watch",
|
|
34
|
+
"bump-to": "yarn version",
|
|
35
|
+
"publish": "yarn build && yarn npm publish --access public"
|
|
36
|
+
}
|
|
37
|
+
}
|
package/lib/statuses.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export declare const CREATED = "created";
|
|
2
|
-
export declare const DOWNLOADING = "downloading";
|
|
3
|
-
export declare const DOWNLOADED = "downloaded";
|
|
4
|
-
export declare const PENDING = "pending";
|
|
5
|
-
export declare const PROCESSING = "processing";
|
|
6
|
-
export declare const ACTIVE = "active";
|
|
7
|
-
export declare const ERROR = "error";
|
|
8
|
-
export declare const DELETABLE = "deletable";
|
|
9
|
-
export declare const DELETED = "deleted";
|
|
10
|
-
export declare const COMPLETED = "completed";
|
|
11
|
-
export declare const DONE = "done";
|
|
12
|
-
export declare const KO = "ko";
|
|
13
|
-
export declare const UNKNOWN = "unknown";
|
package/lib/statuses.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.UNKNOWN = exports.KO = exports.DONE = exports.COMPLETED = exports.DELETED = exports.DELETABLE = exports.ERROR = exports.ACTIVE = exports.PROCESSING = exports.PENDING = exports.DOWNLOADED = exports.DOWNLOADING = exports.CREATED = void 0;
|
|
4
|
-
exports.CREATED = 'created';
|
|
5
|
-
exports.DOWNLOADING = 'downloading';
|
|
6
|
-
exports.DOWNLOADED = 'downloaded';
|
|
7
|
-
exports.PENDING = 'pending';
|
|
8
|
-
exports.PROCESSING = 'processing';
|
|
9
|
-
exports.ACTIVE = 'active';
|
|
10
|
-
exports.ERROR = 'error';
|
|
11
|
-
exports.DELETABLE = 'deletable';
|
|
12
|
-
exports.DELETED = 'deleted';
|
|
13
|
-
exports.COMPLETED = 'completed';
|
|
14
|
-
exports.DONE = 'done';
|
|
15
|
-
exports.KO = 'ko';
|
|
16
|
-
exports.UNKNOWN = 'unknown';
|