@quatrain/core 1.1.10 → 1.1.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/lib/Core.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { User } from './components/User';
|
|
|
2
2
|
import { DataObjectClass } from './components/types/DataObjectClass';
|
|
3
3
|
import logger from 'loglevel';
|
|
4
4
|
export declare class Core {
|
|
5
|
+
static me: string;
|
|
5
6
|
static storage: any;
|
|
6
7
|
static storagePrefix: string;
|
|
7
8
|
static userClass: typeof User;
|
|
@@ -26,7 +27,7 @@ export declare class Core {
|
|
|
26
27
|
* @returns DataObjectClass
|
|
27
28
|
*/
|
|
28
29
|
static getDataObjectClass(): DataObjectClass<any>;
|
|
29
|
-
protected static formatLogMessage: (message: any) => string;
|
|
30
|
+
protected static formatLogMessage: (message: any, prefix?: string) => string;
|
|
30
31
|
/**
|
|
31
32
|
* Log message using defined logger
|
|
32
33
|
* @param message string | object
|
package/lib/Core.js
CHANGED
|
@@ -82,6 +82,7 @@ class Core {
|
|
|
82
82
|
}
|
|
83
83
|
exports.Core = Core;
|
|
84
84
|
_a = Core;
|
|
85
|
+
Core.me = _a.name;
|
|
85
86
|
Core.storage = require('node-persist');
|
|
86
87
|
Core.storagePrefix = 'core';
|
|
87
88
|
Core.userClass = User_1.User;
|
|
@@ -89,4 +90,4 @@ Core.classRegistry = {};
|
|
|
89
90
|
Core.logger = loglevel_1.default;
|
|
90
91
|
// How timestamp are formatted
|
|
91
92
|
Core.timestamp = () => new Date().toISOString();
|
|
92
|
-
Core.formatLogMessage = (message) => `${_a.timestamp()} - [${_a.
|
|
93
|
+
Core.formatLogMessage = (message, prefix = _a.me) => `${_a.timestamp()} - [${_a.me}] ${typeof message === 'string' ? message : JSON.stringify(message)}`;
|
|
@@ -3,9 +3,12 @@ export interface DateTimePropertyType extends BasePropertyType {
|
|
|
3
3
|
timezone?: string;
|
|
4
4
|
}
|
|
5
5
|
export declare class DateTimeProperty extends BaseProperty {
|
|
6
|
+
static AS_IS: string;
|
|
7
|
+
static UNIX_TIMESTAMP: string;
|
|
6
8
|
static TYPE: string;
|
|
9
|
+
static RETURN_AS: string;
|
|
7
10
|
protected _timezone: string;
|
|
8
11
|
constructor(config: DateTimePropertyType);
|
|
9
|
-
set(value: string | Date, setChanged?: boolean): this;
|
|
12
|
+
set(value: string | Date | number, setChanged?: boolean): this;
|
|
10
13
|
get timezone(): string;
|
|
11
14
|
}
|
|
@@ -8,6 +8,14 @@ class DateTimeProperty extends BaseProperty_1.BaseProperty {
|
|
|
8
8
|
this._timezone = config.timezone || 'Z';
|
|
9
9
|
}
|
|
10
10
|
set(value, setChanged = true) {
|
|
11
|
+
if (value && DateTimeProperty.RETURN_AS === 'unix_timestamp') {
|
|
12
|
+
if (typeof value === 'string') {
|
|
13
|
+
value = Date.parse(value);
|
|
14
|
+
}
|
|
15
|
+
else if (typeof value === 'object') {
|
|
16
|
+
value = value.getTime();
|
|
17
|
+
}
|
|
18
|
+
}
|
|
11
19
|
return super.set(value, setChanged);
|
|
12
20
|
}
|
|
13
21
|
get timezone() {
|
|
@@ -15,4 +23,7 @@ class DateTimeProperty extends BaseProperty_1.BaseProperty {
|
|
|
15
23
|
}
|
|
16
24
|
}
|
|
17
25
|
exports.DateTimeProperty = DateTimeProperty;
|
|
26
|
+
DateTimeProperty.AS_IS = 'asis';
|
|
27
|
+
DateTimeProperty.UNIX_TIMESTAMP = 'unix_timestamp';
|
|
18
28
|
DateTimeProperty.TYPE = 'datetime';
|
|
29
|
+
DateTimeProperty.RETURN_AS = DateTimeProperty.AS_IS;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quatrain/core",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.12",
|
|
4
4
|
"description": "Core objects for business apps",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -28,10 +28,14 @@
|
|
|
28
28
|
"node-persist": "^4.0.3"
|
|
29
29
|
},
|
|
30
30
|
"scripts": {
|
|
31
|
-
"test": "
|
|
31
|
+
"test-ci": "jest --runInBand",
|
|
32
32
|
"build": "tsc",
|
|
33
33
|
"wbuild": "tsc --watch",
|
|
34
34
|
"bump-to": "yarn version",
|
|
35
|
-
"
|
|
35
|
+
"hash": "node ../../bin/hashFolder.js",
|
|
36
|
+
"hash:persist": "yarn hash > .hash_latest.txt",
|
|
37
|
+
"hash:compare": "yarn hash > .hash_newest.txt && cmp -s .hash_latest.txt .hash_newest.txt",
|
|
38
|
+
"publish": "yarn hash:compare || yarn publish:process",
|
|
39
|
+
"publish:process": "yarn version patch && yarn build && yarn npm publish --access public && yarn hash:persist"
|
|
36
40
|
}
|
|
37
41
|
}
|