@quatrain/core 1.1.22 → 1.1.24
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/README.md +37 -0
- package/lib/Core.d.ts +1 -0
- package/lib/Core.js +3 -0
- package/lib/common/statuses.d.ts +13 -8
- package/lib/common/statuses.js +14 -9
- package/package.json +7 -2
package/README.md
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# @quatrain/core
|
|
2
|
+
|
|
3
|
+
The foundation of the Quatrain framework. This package provides the base components for building business objects and defining data models. It works entirely in-memory and has no persistence dependencies.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Base Objects**: `BaseObject`, `AbstractObject`, `DataObject` for in-memory object management.
|
|
8
|
+
- **Built-in Models**: `User` and `Entity` models with full property definitions.
|
|
9
|
+
- **Property System**: Strongly-typed properties with built-in validation (`StringProperty`, `NumberProperty`, etc.).
|
|
10
|
+
- **Object URI**: A unified resource identification system that works with or without a database.
|
|
11
|
+
- **Status Management**: Built-in lifecycle statuses (`created`, `pending`, `active`, `deleted`).
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install @quatrain/core
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Usage
|
|
20
|
+
|
|
21
|
+
This package is designed to be used as the base for all other Quatrain packages. You can define your data models and business logic without needing a database connection.
|
|
22
|
+
|
|
23
|
+
```typescript
|
|
24
|
+
import { BaseObject, StringProperty } from '@quatrain/core'
|
|
25
|
+
|
|
26
|
+
export class Product extends BaseObject {
|
|
27
|
+
static COLLECTION = 'products'
|
|
28
|
+
static PROPS_DEFINITION = [
|
|
29
|
+
{ name: 'name', type: StringProperty.TYPE, mandatory: true },
|
|
30
|
+
{ name: 'sku', type: StringProperty.TYPE, mandatory: true },
|
|
31
|
+
]
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const product = await Product.factory()
|
|
35
|
+
product._.name = 'My Awesome Product'
|
|
36
|
+
console.log(product.isValid()) // true
|
|
37
|
+
```
|
package/lib/Core.d.ts
CHANGED
|
@@ -34,6 +34,7 @@ export declare class Core {
|
|
|
34
34
|
*/
|
|
35
35
|
static readonly execPromise: (command: string, args?: any[], cwd?: string) => Promise<any>;
|
|
36
36
|
static readonly getSystemCommandPath: (command: string) => Promise<string>;
|
|
37
|
+
static sleep(seconds?: number): Promise<unknown>;
|
|
37
38
|
/**
|
|
38
39
|
* Returns the class to use for a data object
|
|
39
40
|
* This is currently just a stub that will be implemented from config in the future
|
package/lib/Core.js
CHANGED
|
@@ -56,6 +56,9 @@ class Core {
|
|
|
56
56
|
static getClass(name) {
|
|
57
57
|
return _a.classRegistry[name];
|
|
58
58
|
}
|
|
59
|
+
static sleep(seconds = 1) {
|
|
60
|
+
return new Promise((resolve) => setTimeout(resolve, seconds * 1000));
|
|
61
|
+
}
|
|
59
62
|
/**
|
|
60
63
|
* Returns the class to use for a data object
|
|
61
64
|
* This is currently just a stub that will be implemented from config in the future
|
package/lib/common/statuses.d.ts
CHANGED
|
@@ -1,15 +1,20 @@
|
|
|
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
1
|
export declare const ACTIVE = "active";
|
|
7
|
-
export declare const
|
|
2
|
+
export declare const COMPLETED = "completed";
|
|
3
|
+
export declare const CREATED = "created";
|
|
8
4
|
export declare const DELETABLE = "deletable";
|
|
9
5
|
export declare const DELETED = "deleted";
|
|
10
|
-
export declare const COMPLETED = "completed";
|
|
11
|
-
export declare const QUEUED = "queued";
|
|
12
6
|
export declare const DISABLED = "disabled";
|
|
13
7
|
export declare const DONE = "done";
|
|
8
|
+
export declare const DOWNLOADING = "downloading";
|
|
9
|
+
export declare const DOWNLOADED = "downloaded";
|
|
10
|
+
export declare const DOWNLOAD_KO = "download_ko";
|
|
11
|
+
export declare const ERROR = "error";
|
|
14
12
|
export declare const KO = "ko";
|
|
13
|
+
export declare const PENDING = "pending";
|
|
14
|
+
export declare const PREPARING = "preparing";
|
|
15
|
+
export declare const PROCESSING = "processing";
|
|
16
|
+
export declare const QUEUED = "queued";
|
|
15
17
|
export declare const UNKNOWN = "unknown";
|
|
18
|
+
export declare const UPLOADING = "uploading";
|
|
19
|
+
export declare const UPLOADED = "uploaded";
|
|
20
|
+
export declare const UPLOAD_KO = "upload_ko";
|
package/lib/common/statuses.js
CHANGED
|
@@ -1,18 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.CREATED = 'created';
|
|
5
|
-
exports.DOWNLOADING = 'downloading';
|
|
6
|
-
exports.DOWNLOADED = 'downloaded';
|
|
7
|
-
exports.PENDING = 'pending';
|
|
8
|
-
exports.PROCESSING = 'processing';
|
|
3
|
+
exports.UPLOAD_KO = exports.UPLOADED = exports.UPLOADING = exports.UNKNOWN = exports.QUEUED = exports.PROCESSING = exports.PREPARING = exports.PENDING = exports.KO = exports.ERROR = exports.DOWNLOAD_KO = exports.DOWNLOADED = exports.DOWNLOADING = exports.DONE = exports.DISABLED = exports.DELETED = exports.DELETABLE = exports.CREATED = exports.COMPLETED = exports.ACTIVE = void 0;
|
|
9
4
|
exports.ACTIVE = 'active';
|
|
10
|
-
exports.
|
|
5
|
+
exports.COMPLETED = 'completed';
|
|
6
|
+
exports.CREATED = 'created';
|
|
11
7
|
exports.DELETABLE = 'deletable';
|
|
12
8
|
exports.DELETED = 'deleted';
|
|
13
|
-
exports.COMPLETED = 'completed';
|
|
14
|
-
exports.QUEUED = 'queued';
|
|
15
9
|
exports.DISABLED = 'disabled';
|
|
16
10
|
exports.DONE = 'done';
|
|
11
|
+
exports.DOWNLOADING = 'downloading';
|
|
12
|
+
exports.DOWNLOADED = 'downloaded';
|
|
13
|
+
exports.DOWNLOAD_KO = 'download_ko';
|
|
14
|
+
exports.ERROR = 'error';
|
|
17
15
|
exports.KO = 'ko';
|
|
16
|
+
exports.PENDING = 'pending';
|
|
17
|
+
exports.PREPARING = 'preparing';
|
|
18
|
+
exports.PROCESSING = 'processing';
|
|
19
|
+
exports.QUEUED = 'queued';
|
|
18
20
|
exports.UNKNOWN = 'unknown';
|
|
21
|
+
exports.UPLOADING = 'uploading';
|
|
22
|
+
exports.UPLOADED = 'uploaded';
|
|
23
|
+
exports.UPLOAD_KO = 'upload_ko';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quatrain/core",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.24",
|
|
4
4
|
"description": "Core objects for business apps",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -13,10 +13,11 @@
|
|
|
13
13
|
"devDependencies": {
|
|
14
14
|
"@tsconfig/recommended": "^1.0.1",
|
|
15
15
|
"@types/jest": "^30.0.0",
|
|
16
|
+
"@types/module-alias": "^2",
|
|
16
17
|
"@types/node": "^22.10.1",
|
|
17
18
|
"@types/node-persist": "^3.1.8",
|
|
18
19
|
"@types/which": "^3.0.4",
|
|
19
|
-
"jest": "^30.
|
|
20
|
+
"jest": "^30.2.0",
|
|
20
21
|
"trace-unhandled": "^2.0.1",
|
|
21
22
|
"ts-jest": "^29.4.1",
|
|
22
23
|
"ts-node": "^10.4.0",
|
|
@@ -25,6 +26,7 @@
|
|
|
25
26
|
"dependencies": {
|
|
26
27
|
"@faker-js/faker": "^7.6.0",
|
|
27
28
|
"@quatrain/log": "^1.0.2",
|
|
29
|
+
"module-alias": "^2.2.3",
|
|
28
30
|
"node-persist": "^4.0.4",
|
|
29
31
|
"which": "^5.0.0"
|
|
30
32
|
},
|
|
@@ -38,5 +40,8 @@
|
|
|
38
40
|
"hash:compare": "yarn hash > .hash_newest.txt && cmp -s .hash_latest.txt .hash_newest.txt",
|
|
39
41
|
"publish": "yarn hash:compare || yarn publish:process",
|
|
40
42
|
"publish:process": "yarn version patch && yarn build && yarn npm publish --access public && yarn hash:persist"
|
|
43
|
+
},
|
|
44
|
+
"_moduleAliases": {
|
|
45
|
+
"@core": "."
|
|
41
46
|
}
|
|
42
47
|
}
|