@quatrain/core 1.0.3 → 1.1.1
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/components/AbstractObject.d.ts +1 -2
- package/lib/components/AbstractObject.js +2 -5
- package/lib/components/BaseObject.d.ts +30 -12
- package/lib/components/BaseObject.js +100 -87
- package/lib/components/BaseObjectCore.d.ts +4 -4
- package/lib/components/BaseObjectCore.js +2 -2
- package/lib/components/BaseObjectProperties.d.ts +1 -0
- package/lib/components/BaseObjectProperties.js +90 -0
- package/lib/components/DataObject.d.ts +2 -6
- package/lib/components/DataObject.js +19 -17
- package/lib/components/Entity.d.ts +3 -3
- package/lib/components/Entity.js +3 -3
- package/lib/components/User.d.ts +3 -4
- package/lib/components/User.js +4 -4
- package/lib/components/index.d.ts +1 -1
- package/lib/components/index.js +2 -2
- package/lib/components/types/BaseObjectType.d.ts +10 -0
- package/lib/components/types/BaseObjectType.js +2 -0
- package/lib/components/types/DataObjectClass copy.d.ts +28 -0
- package/lib/components/types/DataObjectClass copy.js +2 -0
- package/lib/components/types/DataObjectClass.d.ts +0 -1
- package/lib/components/types/DataObjectType.d.ts +27 -0
- package/lib/components/types/DataObjectType.js +2 -0
- package/lib/components/types/Payload.d.ts +3 -4
- package/lib/index.d.ts +4 -3
- package/lib/index.js +4 -4
- package/lib/properties/CollectionProperty.d.ts +3 -3
- package/package.json +1 -1
|
@@ -15,13 +15,12 @@ export declare abstract class AbstractObject {
|
|
|
15
15
|
get(key: string): any;
|
|
16
16
|
set(key: string, val: any): any;
|
|
17
17
|
val(key: string): any;
|
|
18
|
-
|
|
18
|
+
has(key: string): boolean;
|
|
19
19
|
get path(): string;
|
|
20
20
|
get uid(): any;
|
|
21
21
|
get dataObject(): DataObjectClass<any>;
|
|
22
22
|
get _(): any;
|
|
23
23
|
get uri(): import("./ObjectUri").ObjectUri;
|
|
24
|
-
has(key: string): boolean;
|
|
25
24
|
toJSON(): {
|
|
26
25
|
backend: string | undefined;
|
|
27
26
|
ref: string;
|
|
@@ -25,8 +25,8 @@ class AbstractObject {
|
|
|
25
25
|
return null;
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
|
-
|
|
29
|
-
return this._dataObject.
|
|
28
|
+
has(key) {
|
|
29
|
+
return Reflect.has(this._dataObject.properties, key);
|
|
30
30
|
}
|
|
31
31
|
get path() {
|
|
32
32
|
return this._dataObject.path;
|
|
@@ -43,9 +43,6 @@ class AbstractObject {
|
|
|
43
43
|
get uri() {
|
|
44
44
|
return this._dataObject.uri;
|
|
45
45
|
}
|
|
46
|
-
has(key) {
|
|
47
|
-
return Reflect.has(this._dataObject.properties, key);
|
|
48
|
-
}
|
|
49
46
|
toJSON() {
|
|
50
47
|
var _a;
|
|
51
48
|
return typeof this.uri === 'string' ? this.uri : (_a = this.uri) === null || _a === void 0 ? void 0 : _a.toJSON();
|
|
@@ -1,13 +1,31 @@
|
|
|
1
|
-
import { ObjectUri } from '
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
import { ObjectUri, DataObjectClass, DataObject } from '..';
|
|
2
|
+
import { BaseObjectType } from './types/BaseObjectType';
|
|
3
|
+
import { AbstractObject } from './AbstractObject';
|
|
4
|
+
import { DataObjectType } from './types/DataObjectType';
|
|
5
|
+
export declare class BaseObject extends AbstractObject {
|
|
6
|
+
static PROPS_DEFINITION: any;
|
|
7
|
+
static getProperty(key: string): any;
|
|
8
|
+
static fillProperties(child?: any): DataObject;
|
|
9
|
+
static daoFactory(src?: string | ObjectUri | DataObjectType | undefined, child?: any): Promise<DataObjectType>;
|
|
10
|
+
/**
|
|
11
|
+
* Instantiates from an object
|
|
12
|
+
* @param src
|
|
13
|
+
* @param child
|
|
14
|
+
* @returns
|
|
15
|
+
*/
|
|
16
|
+
static fromObject<T extends BaseObjectType>(src: T, child?: any): any;
|
|
17
|
+
static factory(src?: string | ObjectUri | BaseObjectType | undefined, child?: any): Promise<any>;
|
|
18
|
+
/**
|
|
19
|
+
* Fetches an object from its backend path
|
|
20
|
+
* @param path
|
|
21
|
+
* @returns
|
|
22
|
+
*/
|
|
23
|
+
static fromBackend<T>(path: string): Promise<T>;
|
|
24
|
+
/**
|
|
25
|
+
* Instantiates from a DataObject
|
|
26
|
+
* @param dao
|
|
27
|
+
* @returns
|
|
28
|
+
*/
|
|
29
|
+
static fromDataObject<T extends BaseObjectType>(dao: DataObjectClass<any>): any;
|
|
30
|
+
asReference(): any;
|
|
12
31
|
}
|
|
13
|
-
export declare const BaseObjectProperties: any;
|
|
@@ -1,90 +1,103 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
})
|
|
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;
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
24
10
|
};
|
|
25
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.
|
|
27
|
-
const
|
|
28
|
-
const
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
{
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
12
|
+
exports.BaseObject = void 0;
|
|
13
|
+
const __1 = require("..");
|
|
14
|
+
const BaseObjectProperties_1 = require("./BaseObjectProperties");
|
|
15
|
+
const AbstractObject_1 = require("./AbstractObject");
|
|
16
|
+
class BaseObject extends AbstractObject_1.AbstractObject {
|
|
17
|
+
static getProperty(key) {
|
|
18
|
+
return BaseObject.PROPS_DEFINITION.find((prop) => prop.name === key);
|
|
19
|
+
}
|
|
20
|
+
static fillProperties(child = this) {
|
|
21
|
+
// merge base properties with additional or redefined ones
|
|
22
|
+
const base = [...BaseObject.PROPS_DEFINITION];
|
|
23
|
+
child.PROPS_DEFINITION.forEach((property) => {
|
|
24
|
+
// manage parent properties potential redeclaration
|
|
25
|
+
const found = base.findIndex((el) => el.name === property.name);
|
|
26
|
+
if (found !== -1) {
|
|
27
|
+
base[found] = property;
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
base.push(property);
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
const dao = __1.DataObject.factory({
|
|
34
|
+
properties: base,
|
|
35
|
+
parentProp: this.PARENT_PROP,
|
|
36
|
+
});
|
|
37
|
+
dao.uri.class = child;
|
|
38
|
+
return dao;
|
|
39
|
+
}
|
|
40
|
+
static daoFactory(src = undefined, child = this) {
|
|
41
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
42
|
+
const dao = this.fillProperties(child);
|
|
43
|
+
return dao;
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Instantiates from an object
|
|
48
|
+
* @param src
|
|
49
|
+
* @param child
|
|
50
|
+
* @returns
|
|
51
|
+
*/
|
|
52
|
+
static fromObject(src, child = this) {
|
|
53
|
+
const dao = this.fillProperties(child);
|
|
54
|
+
dao.uri = new __1.ObjectUri(`${this.COLLECTION}${__1.ObjectUri.DEFAULT}`, Reflect.get(src, 'name'));
|
|
55
|
+
dao.uri.class = child;
|
|
56
|
+
dao.populateFromData(src);
|
|
57
|
+
const obj = new this(dao);
|
|
58
|
+
return obj;
|
|
59
|
+
}
|
|
60
|
+
static factory(src = undefined, child = this) {
|
|
61
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
62
|
+
try {
|
|
63
|
+
if (typeof src == 'object' && !(src instanceof __1.ObjectUri)) {
|
|
64
|
+
return this.fromObject(src);
|
|
65
|
+
}
|
|
66
|
+
const dao = yield this.daoFactory(src, child);
|
|
67
|
+
const constructedObject = Reflect.construct(this, [dao]);
|
|
68
|
+
return constructedObject;
|
|
69
|
+
}
|
|
70
|
+
catch (err) {
|
|
71
|
+
throw new Error(`Unable to build instance for '${this.name}': ${err.message}`);
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Fetches an object from its backend path
|
|
77
|
+
* @param path
|
|
78
|
+
* @returns
|
|
79
|
+
*/
|
|
80
|
+
static fromBackend(path) {
|
|
81
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
82
|
+
if (!path.includes('/')) {
|
|
83
|
+
return this.factory(`${this.COLLECTION}/${path}`);
|
|
84
|
+
}
|
|
85
|
+
return this.factory(path);
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Instantiates from a DataObject
|
|
90
|
+
* @param dao
|
|
91
|
+
* @returns
|
|
92
|
+
*/
|
|
93
|
+
static fromDataObject(dao) {
|
|
94
|
+
const obj = new this(dao);
|
|
95
|
+
return obj; //.toProxy()
|
|
96
|
+
}
|
|
97
|
+
asReference() {
|
|
98
|
+
return this._dataObject.toReference();
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
exports.BaseObject = BaseObject;
|
|
102
|
+
// implements BaseObjectClass {
|
|
103
|
+
BaseObject.PROPS_DEFINITION = BaseObjectProperties_1.BaseObjectProperties;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ObjectUri, DataObjectClass, DataObject } from '../';
|
|
2
|
-
import {
|
|
2
|
+
import { BaseObjectType } from './types/BaseObjectType';
|
|
3
3
|
import { AbstractObject } from './AbstractObject';
|
|
4
4
|
export declare class BaseObjectCore extends AbstractObject {
|
|
5
5
|
static PROPS_DEFINITION: any;
|
|
@@ -12,8 +12,8 @@ export declare class BaseObjectCore extends AbstractObject {
|
|
|
12
12
|
* @param child
|
|
13
13
|
* @returns
|
|
14
14
|
*/
|
|
15
|
-
static fromObject<T extends
|
|
16
|
-
static factory(src?: string | ObjectUri |
|
|
15
|
+
static fromObject<T extends BaseObjectType>(src: T, child?: any): any;
|
|
16
|
+
static factory(src?: string | ObjectUri | BaseObjectType | undefined, child?: any): Promise<any>;
|
|
17
17
|
/**
|
|
18
18
|
* Fetches an object from its backend path
|
|
19
19
|
* @param path
|
|
@@ -25,7 +25,7 @@ export declare class BaseObjectCore extends AbstractObject {
|
|
|
25
25
|
* @param dao
|
|
26
26
|
* @returns
|
|
27
27
|
*/
|
|
28
|
-
static fromDataObject<T extends
|
|
28
|
+
static fromDataObject<T extends BaseObjectType>(dao: DataObjectClass<any>): any;
|
|
29
29
|
/**
|
|
30
30
|
* Wrap instance into proxy to get access to properties
|
|
31
31
|
* @returns Proxy
|
|
@@ -11,7 +11,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.BaseObjectCore = void 0;
|
|
13
13
|
const __1 = require("../");
|
|
14
|
-
const
|
|
14
|
+
const BaseObjectProperties_1 = require("./BaseObjectProperties");
|
|
15
15
|
const AbstractObject_1 = require("./AbstractObject");
|
|
16
16
|
class BaseObjectCore extends AbstractObject_1.AbstractObject {
|
|
17
17
|
static getProperty(key) {
|
|
@@ -149,4 +149,4 @@ class BaseObjectCore extends AbstractObject_1.AbstractObject {
|
|
|
149
149
|
}
|
|
150
150
|
exports.BaseObjectCore = BaseObjectCore;
|
|
151
151
|
// implements BaseObjectClass {
|
|
152
|
-
BaseObjectCore.PROPS_DEFINITION =
|
|
152
|
+
BaseObjectCore.PROPS_DEFINITION = BaseObjectProperties_1.BaseObjectProperties;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const BaseObjectProperties: any;
|
|
@@ -0,0 +1,90 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.BaseObjectProperties = void 0;
|
|
27
|
+
const statuses = __importStar(require("../statuses"));
|
|
28
|
+
const StringProperty_1 = require("../properties/StringProperty");
|
|
29
|
+
const ObjectProperty_1 = require("../properties/ObjectProperty");
|
|
30
|
+
const EnumProperty_1 = require("../properties/EnumProperty");
|
|
31
|
+
const DateTimeProperty_1 = require("../properties/DateTimeProperty");
|
|
32
|
+
const htmlType = __importStar(require("../properties/types/PropertyHTMLType"));
|
|
33
|
+
exports.BaseObjectProperties = [
|
|
34
|
+
{
|
|
35
|
+
name: 'name',
|
|
36
|
+
mandatory: true,
|
|
37
|
+
type: StringProperty_1.StringProperty.TYPE,
|
|
38
|
+
minLength: 1,
|
|
39
|
+
maxLength: 100,
|
|
40
|
+
fullSearch: true,
|
|
41
|
+
htmlType: htmlType.NAME,
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
name: 'status',
|
|
45
|
+
mandatory: true,
|
|
46
|
+
type: EnumProperty_1.EnumProperty.TYPE,
|
|
47
|
+
values: [
|
|
48
|
+
statuses.CREATED,
|
|
49
|
+
statuses.PENDING,
|
|
50
|
+
statuses.ACTIVE,
|
|
51
|
+
statuses.DELETED,
|
|
52
|
+
],
|
|
53
|
+
defaultValue: statuses.CREATED,
|
|
54
|
+
},
|
|
55
|
+
// the following properties may be optionally
|
|
56
|
+
// populated with a backend middleware
|
|
57
|
+
{
|
|
58
|
+
name: 'createdBy',
|
|
59
|
+
type: ObjectProperty_1.ObjectProperty.TYPE,
|
|
60
|
+
instanceOf: 'User',
|
|
61
|
+
mandatory: true,
|
|
62
|
+
protected: true,
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
name: 'createdAt',
|
|
66
|
+
type: DateTimeProperty_1.DateTimeProperty.TYPE,
|
|
67
|
+
mandatory: true,
|
|
68
|
+
protected: true,
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
name: 'updatedBy',
|
|
72
|
+
type: ObjectProperty_1.ObjectProperty.TYPE,
|
|
73
|
+
instanceOf: 'User',
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
name: 'updatedAt',
|
|
77
|
+
type: DateTimeProperty_1.DateTimeProperty.TYPE,
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
name: 'deletedBy',
|
|
81
|
+
type: ObjectProperty_1.ObjectProperty.TYPE,
|
|
82
|
+
instanceOf: 'User',
|
|
83
|
+
protected: true,
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
name: 'deletedAt',
|
|
87
|
+
type: DateTimeProperty_1.DateTimeProperty.TYPE,
|
|
88
|
+
protected: true,
|
|
89
|
+
},
|
|
90
|
+
];
|
|
@@ -2,8 +2,8 @@ import { DataObjectProperties } from '../properties';
|
|
|
2
2
|
import { PropertyClassType } from '../properties/types/PropertyClassType';
|
|
3
3
|
import { AbstractObject } from './AbstractObject';
|
|
4
4
|
import { ObjectUri } from './ObjectUri';
|
|
5
|
-
import { DataObjectClass } from './types/DataObjectClass';
|
|
6
5
|
import { toJSONParams } from './types/toJSONParams';
|
|
6
|
+
import { DataObjectType } from './types/DataObjectType';
|
|
7
7
|
export type CoreObject<T extends AbstractObject> = T;
|
|
8
8
|
export type Properties = {
|
|
9
9
|
[x: string]: PropertyClassType;
|
|
@@ -22,7 +22,7 @@ export interface DataObjectParams {
|
|
|
22
22
|
* They handle data and identifiers in a protected registry
|
|
23
23
|
* This is what backends and objects manipulate, oblivious of the other.
|
|
24
24
|
*/
|
|
25
|
-
export declare class DataObject implements
|
|
25
|
+
export declare class DataObject implements DataObjectType {
|
|
26
26
|
protected _objectUri: ObjectUri;
|
|
27
27
|
protected _uid: string | undefined;
|
|
28
28
|
protected _properties: Properties;
|
|
@@ -69,7 +69,6 @@ export declare class DataObject implements DataObjectClass<any> {
|
|
|
69
69
|
}): this;
|
|
70
70
|
isPopulated(): boolean;
|
|
71
71
|
get properties(): Properties;
|
|
72
|
-
get backend(): string | undefined;
|
|
73
72
|
get path(): string;
|
|
74
73
|
set uid(uid: string | undefined);
|
|
75
74
|
get uid(): string | undefined;
|
|
@@ -102,9 +101,6 @@ export declare class DataObject implements DataObjectClass<any> {
|
|
|
102
101
|
uri: string;
|
|
103
102
|
};
|
|
104
103
|
protected _dataToJSON(objectsAsReferences?: boolean, ignoreUnchanged?: boolean, converters?: {}): {};
|
|
105
|
-
read(): Promise<DataObjectClass<any>>;
|
|
106
|
-
save(): Promise<DataObjectClass<any>>;
|
|
107
|
-
delete(): Promise<DataObjectClass<any>>;
|
|
108
104
|
/**
|
|
109
105
|
* Data object must be created from factory in order for async-loaded data to be available
|
|
110
106
|
* @param className
|
|
@@ -154,9 +154,9 @@ class DataObject {
|
|
|
154
154
|
get properties() {
|
|
155
155
|
return this._properties;
|
|
156
156
|
}
|
|
157
|
-
get backend() {
|
|
158
|
-
|
|
159
|
-
}
|
|
157
|
+
// get backend() {
|
|
158
|
+
// return this._objectUri ? this._objectUri.backend : undefined
|
|
159
|
+
// }
|
|
160
160
|
get path() {
|
|
161
161
|
return this._objectUri ? this._objectUri.path : '';
|
|
162
162
|
}
|
|
@@ -224,7 +224,7 @@ class DataObject {
|
|
|
224
224
|
return Reflect.get(this._properties, key).val(transform);
|
|
225
225
|
}
|
|
226
226
|
else {
|
|
227
|
-
|
|
227
|
+
return undefined;
|
|
228
228
|
}
|
|
229
229
|
}
|
|
230
230
|
toJSON(params = false) {
|
|
@@ -279,19 +279,21 @@ class DataObject {
|
|
|
279
279
|
});
|
|
280
280
|
return data;
|
|
281
281
|
}
|
|
282
|
-
read() {
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
}
|
|
287
|
-
save() {
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
282
|
+
// async read(): Promise<DataObjectClass<any>> {
|
|
283
|
+
// throw new Error(
|
|
284
|
+
// `This is just a stub, please use DataObject from @quatrain/backend to persist`
|
|
285
|
+
// )
|
|
286
|
+
// }
|
|
287
|
+
// save(): Promise<DataObjectClass<any>> {
|
|
288
|
+
// throw new Error(
|
|
289
|
+
// `This is just a stub, please use DataObject from @quatrain/backend to persist`
|
|
290
|
+
// )
|
|
291
|
+
// }
|
|
292
|
+
// async delete(): Promise<DataObjectClass<any>> {
|
|
293
|
+
// throw new Error(
|
|
294
|
+
// `This is just a stub, please use DataObject from @quatrain/backend to persist`
|
|
295
|
+
// )
|
|
296
|
+
// }
|
|
295
297
|
/**
|
|
296
298
|
* Data object must be created from factory in order for async-loaded data to be available
|
|
297
299
|
* @param className
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { BaseObjectCore } from './BaseObjectCore';
|
|
2
1
|
import { BaseObject } from './BaseObject';
|
|
3
|
-
|
|
2
|
+
import { BaseObjectType } from './types/BaseObjectType';
|
|
3
|
+
export interface EntityType extends BaseObjectType {
|
|
4
4
|
}
|
|
5
|
-
export declare class Entity extends
|
|
5
|
+
export declare class Entity extends BaseObject {
|
|
6
6
|
static COLLECTION: string;
|
|
7
7
|
static PROPS_DEFINITION: any[];
|
|
8
8
|
static factory(src?: any): Promise<Entity>;
|
package/lib/components/Entity.js
CHANGED
|
@@ -33,13 +33,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
33
33
|
};
|
|
34
34
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
35
|
exports.Entity = void 0;
|
|
36
|
-
const BaseObjectCore_1 = require("./BaseObjectCore");
|
|
37
36
|
const BaseObject_1 = require("./BaseObject");
|
|
37
|
+
const BaseObjectProperties_1 = require("./BaseObjectProperties");
|
|
38
38
|
//import { User } from './User'
|
|
39
39
|
//import { CollectionProperty } from '../properties/CollectionProperty'
|
|
40
40
|
const StringProperty_1 = require("../properties/StringProperty");
|
|
41
41
|
const htmlType = __importStar(require("../properties/types/PropertyHTMLType"));
|
|
42
|
-
class Entity extends
|
|
42
|
+
class Entity extends BaseObject_1.BaseObject {
|
|
43
43
|
static factory(src = undefined) {
|
|
44
44
|
const _super = Object.create(null, {
|
|
45
45
|
factory: { get: () => super.factory }
|
|
@@ -52,7 +52,7 @@ class Entity extends BaseObjectCore_1.BaseObjectCore {
|
|
|
52
52
|
exports.Entity = Entity;
|
|
53
53
|
Entity.COLLECTION = 'entities';
|
|
54
54
|
Entity.PROPS_DEFINITION = [
|
|
55
|
-
...
|
|
55
|
+
...BaseObjectProperties_1.BaseObjectProperties,
|
|
56
56
|
{
|
|
57
57
|
// surcharge property minLength and htmlType
|
|
58
58
|
name: 'name',
|
package/lib/components/User.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { BaseObjectCore } from './BaseObjectCore';
|
|
2
1
|
import { BaseObject } from './BaseObject';
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
import { BaseObjectType } from './types/BaseObjectType';
|
|
3
|
+
export interface UserType extends BaseObjectType {
|
|
5
4
|
firstname: string;
|
|
6
5
|
lastname: string;
|
|
7
6
|
gender?: 'male' | 'female' | 'nonbinary';
|
|
@@ -10,7 +9,7 @@ export interface UserType extends BaseObject {
|
|
|
10
9
|
email: string;
|
|
11
10
|
}
|
|
12
11
|
export declare const UserProperties: any;
|
|
13
|
-
export declare class User extends
|
|
12
|
+
export declare class User extends BaseObject {
|
|
14
13
|
static PROPS_DEFINITION: any;
|
|
15
14
|
static COLLECTION: string;
|
|
16
15
|
static factory(src?: any): Promise<User>;
|
package/lib/components/User.js
CHANGED
|
@@ -33,12 +33,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
33
33
|
};
|
|
34
34
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
35
|
exports.User = exports.UserProperties = void 0;
|
|
36
|
-
const
|
|
36
|
+
const BaseObject_1 = require("./BaseObject");
|
|
37
37
|
const properties_1 = require("../properties");
|
|
38
38
|
const HashProperty_1 = require("../properties/HashProperty");
|
|
39
39
|
const StringProperty_1 = require("../properties/StringProperty");
|
|
40
40
|
const htmlType = __importStar(require("../properties/types/PropertyHTMLType"));
|
|
41
|
-
const
|
|
41
|
+
const BaseObjectProperties_1 = require("./BaseObjectProperties");
|
|
42
42
|
const Entity_1 = require("./Entity");
|
|
43
43
|
/**
|
|
44
44
|
* Callback function to populate the 'name' property
|
|
@@ -47,7 +47,7 @@ const Entity_1 = require("./Entity");
|
|
|
47
47
|
*/
|
|
48
48
|
const onChange = (dao) => dao.set('name', `${dao.val('firstname')} ${dao.val('lastname')}`);
|
|
49
49
|
exports.UserProperties = [
|
|
50
|
-
...
|
|
50
|
+
...BaseObjectProperties_1.BaseObjectProperties,
|
|
51
51
|
{
|
|
52
52
|
// change name property minLength
|
|
53
53
|
name: 'name',
|
|
@@ -121,7 +121,7 @@ exports.UserProperties = [
|
|
|
121
121
|
instanceOf: Entity_1.Entity,
|
|
122
122
|
},
|
|
123
123
|
];
|
|
124
|
-
class User extends
|
|
124
|
+
class User extends BaseObject_1.BaseObject {
|
|
125
125
|
static factory(src = undefined) {
|
|
126
126
|
const _super = Object.create(null, {
|
|
127
127
|
factory: { get: () => super.factory }
|
|
@@ -2,7 +2,7 @@ import { DataObject, DataObjectParams } from './DataObject';
|
|
|
2
2
|
import { DataObjectClass } from './types/DataObjectClass';
|
|
3
3
|
import { ObjectUri } from './ObjectUri';
|
|
4
4
|
import { AbstractObject } from './AbstractObject';
|
|
5
|
-
import { BaseObjectProperties } from './
|
|
5
|
+
import { BaseObjectProperties } from './BaseObjectProperties';
|
|
6
6
|
import { User, UserProperties } from './User';
|
|
7
7
|
import { Entity } from './Entity';
|
|
8
8
|
export { DataObject, DataObjectParams, DataObjectClass, ObjectUri, AbstractObject, User, Entity, BaseObjectProperties, UserProperties, };
|
package/lib/components/index.js
CHANGED
|
@@ -7,8 +7,8 @@ const ObjectUri_1 = require("./ObjectUri");
|
|
|
7
7
|
Object.defineProperty(exports, "ObjectUri", { enumerable: true, get: function () { return ObjectUri_1.ObjectUri; } });
|
|
8
8
|
const AbstractObject_1 = require("./AbstractObject");
|
|
9
9
|
Object.defineProperty(exports, "AbstractObject", { enumerable: true, get: function () { return AbstractObject_1.AbstractObject; } });
|
|
10
|
-
const
|
|
11
|
-
Object.defineProperty(exports, "BaseObjectProperties", { enumerable: true, get: function () { return
|
|
10
|
+
const BaseObjectProperties_1 = require("./BaseObjectProperties");
|
|
11
|
+
Object.defineProperty(exports, "BaseObjectProperties", { enumerable: true, get: function () { return BaseObjectProperties_1.BaseObjectProperties; } });
|
|
12
12
|
const User_1 = require("./User");
|
|
13
13
|
Object.defineProperty(exports, "User", { enumerable: true, get: function () { return User_1.User; } });
|
|
14
14
|
Object.defineProperty(exports, "UserProperties", { enumerable: true, get: function () { return User_1.UserProperties; } });
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { PropertyClassType } from '../../properties/types/PropertyClassType';
|
|
2
|
+
import { ObjectUri } from '../ObjectUri';
|
|
3
|
+
import { toJSONParams } from './toJSONParams';
|
|
4
|
+
export interface DataObjectClass<T extends DataObjectClass<any>> {
|
|
5
|
+
uri: ObjectUri;
|
|
6
|
+
uid: any;
|
|
7
|
+
backend: any;
|
|
8
|
+
path: any;
|
|
9
|
+
class: any;
|
|
10
|
+
properties: any;
|
|
11
|
+
parentProp: string | undefined;
|
|
12
|
+
setProperties(properties: any): void;
|
|
13
|
+
getProperties(type: any): any;
|
|
14
|
+
addProperty(property: PropertyClassType): void;
|
|
15
|
+
populate(data?: any): Promise<T>;
|
|
16
|
+
isPopulated(): boolean;
|
|
17
|
+
has(key: string): boolean;
|
|
18
|
+
get(key: string): any;
|
|
19
|
+
set(key: string, val: any): any;
|
|
20
|
+
val(key: string): any;
|
|
21
|
+
clone(data?: any): Promise<T>;
|
|
22
|
+
toReference(): any;
|
|
23
|
+
toJSON(params?: boolean | toJSONParams): any;
|
|
24
|
+
populateFromData(data: {
|
|
25
|
+
[x: string]: unknown;
|
|
26
|
+
}): this;
|
|
27
|
+
asProxy(): any;
|
|
28
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { PropertyClassType } from '../../properties/types/PropertyClassType';
|
|
2
|
+
import { ObjectUri } from '../ObjectUri';
|
|
3
|
+
import { toJSONParams } from './toJSONParams';
|
|
4
|
+
export interface DataObjectType {
|
|
5
|
+
uri: ObjectUri;
|
|
6
|
+
uid: any;
|
|
7
|
+
path: any;
|
|
8
|
+
class: any;
|
|
9
|
+
properties: any;
|
|
10
|
+
parentProp: string | undefined;
|
|
11
|
+
setProperties(properties: any): void;
|
|
12
|
+
getProperties(type: any): any;
|
|
13
|
+
addProperty(property: PropertyClassType): void;
|
|
14
|
+
populate(data?: any): Promise<any>;
|
|
15
|
+
isPopulated(): boolean;
|
|
16
|
+
has(key: string): boolean;
|
|
17
|
+
get(key: string): any;
|
|
18
|
+
set(key: string, val: any): any;
|
|
19
|
+
val(key: string): any;
|
|
20
|
+
clone(data?: any): Promise<any>;
|
|
21
|
+
toReference(): any;
|
|
22
|
+
toJSON(params?: boolean | toJSONParams): any;
|
|
23
|
+
populateFromData(data: {
|
|
24
|
+
[x: string]: unknown;
|
|
25
|
+
}): this;
|
|
26
|
+
asProxy(): any;
|
|
27
|
+
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
items: Persisted<T>[];
|
|
1
|
+
import { BaseObjectType } from './BaseObjectType';
|
|
2
|
+
export default interface Payload<T extends BaseObjectType> {
|
|
3
|
+
items: T[];
|
|
5
4
|
meta: Meta;
|
|
6
5
|
}
|
|
7
6
|
export interface Meta {
|
package/lib/index.d.ts
CHANGED
|
@@ -15,10 +15,11 @@ import { ObjectUri } from './components/ObjectUri';
|
|
|
15
15
|
import { DataObjectClass } from './components/types/DataObjectClass';
|
|
16
16
|
import { DataObject } from './components/DataObject';
|
|
17
17
|
import { DataObjectProperties } from './properties';
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
18
|
+
import { BaseObject } from './components/BaseObject';
|
|
19
|
+
import { BaseObjectProperties } from './components/BaseObjectProperties';
|
|
20
|
+
import { BaseObjectType } from './components/types/BaseObjectType';
|
|
20
21
|
import { Proxy } from './components/types/ProxyConstructor';
|
|
21
22
|
import { UserType, User, UserProperties } from './components/User';
|
|
22
23
|
import { EntityType, Entity } from './components/Entity';
|
|
23
24
|
import { BadRequestError, UnauthorizedError, ForbiddenError, NotFoundError, GoneError } from './common/ResourcesErrors';
|
|
24
|
-
export { statuses, Core, Property, BaseProperty, BasePropertyType, BooleanProperty, BooleanPropertyType, DateTimeProperty, DateTimePropertyType, EnumProperty, EnumPropertyType, HashProperty, HashPropertyType, CollectionProperty, CollectionPropertyType, ArrayProperty, ArrayPropertyType, ObjectProperty, ObjectPropertyType, returnAs, StringProperty, StringPropertyType, ObjectUri, DataObjectClass, DataObject, DataObjectProperties, AbstractObject,
|
|
25
|
+
export { statuses, Core, Property, BaseProperty, BasePropertyType, BooleanProperty, BooleanPropertyType, DateTimeProperty, DateTimePropertyType, EnumProperty, EnumPropertyType, HashProperty, HashPropertyType, CollectionProperty, CollectionPropertyType, ArrayProperty, ArrayPropertyType, ObjectProperty, ObjectPropertyType, returnAs, StringProperty, StringPropertyType, ObjectUri, DataObjectClass, DataObject, DataObjectProperties, AbstractObject, BaseObjectType, BaseObject, BaseObjectProperties, User, UserType, UserProperties, Proxy, Entity, EntityType, BadRequestError, UnauthorizedError, ForbiddenError, NotFoundError, GoneError, };
|
package/lib/index.js
CHANGED
|
@@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.GoneError = exports.NotFoundError = exports.ForbiddenError = exports.UnauthorizedError = exports.BadRequestError = exports.Entity = exports.UserProperties = exports.User = exports.BaseObjectProperties = exports.
|
|
26
|
+
exports.GoneError = exports.NotFoundError = exports.ForbiddenError = exports.UnauthorizedError = exports.BadRequestError = exports.Entity = exports.UserProperties = exports.User = exports.BaseObjectProperties = exports.BaseObject = exports.AbstractObject = exports.DataObject = exports.ObjectUri = exports.StringProperty = exports.returnAs = exports.ObjectProperty = exports.ArrayProperty = exports.CollectionProperty = exports.HashProperty = exports.EnumProperty = exports.DateTimeProperty = exports.BooleanProperty = exports.BaseProperty = exports.Property = exports.Core = exports.statuses = void 0;
|
|
27
27
|
const Core_1 = require("./Core");
|
|
28
28
|
Object.defineProperty(exports, "Core", { enumerable: true, get: function () { return Core_1.Core; } });
|
|
29
29
|
const statuses = __importStar(require("./common/statuses"));
|
|
@@ -55,10 +55,10 @@ const ObjectUri_1 = require("./components/ObjectUri");
|
|
|
55
55
|
Object.defineProperty(exports, "ObjectUri", { enumerable: true, get: function () { return ObjectUri_1.ObjectUri; } });
|
|
56
56
|
const DataObject_1 = require("./components/DataObject");
|
|
57
57
|
Object.defineProperty(exports, "DataObject", { enumerable: true, get: function () { return DataObject_1.DataObject; } });
|
|
58
|
-
const BaseObjectCore_1 = require("./components/BaseObjectCore");
|
|
59
|
-
Object.defineProperty(exports, "BaseObjectCore", { enumerable: true, get: function () { return BaseObjectCore_1.BaseObjectCore; } });
|
|
60
58
|
const BaseObject_1 = require("./components/BaseObject");
|
|
61
|
-
Object.defineProperty(exports, "
|
|
59
|
+
Object.defineProperty(exports, "BaseObject", { enumerable: true, get: function () { return BaseObject_1.BaseObject; } });
|
|
60
|
+
const BaseObjectProperties_1 = require("./components/BaseObjectProperties");
|
|
61
|
+
Object.defineProperty(exports, "BaseObjectProperties", { enumerable: true, get: function () { return BaseObjectProperties_1.BaseObjectProperties; } });
|
|
62
62
|
const User_1 = require("./components/User");
|
|
63
63
|
Object.defineProperty(exports, "User", { enumerable: true, get: function () { return User_1.User; } });
|
|
64
64
|
Object.defineProperty(exports, "UserProperties", { enumerable: true, get: function () { return User_1.UserProperties; } });
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { BaseProperty, BasePropertyType } from './BaseProperty';
|
|
2
2
|
import { ObjectUri } from '../components/ObjectUri';
|
|
3
3
|
import { DataObjectClass } from '../components/types/DataObjectClass';
|
|
4
|
-
import {
|
|
4
|
+
import { BaseObject } from '../components/BaseObject';
|
|
5
5
|
export interface CollectionPropertyType extends BasePropertyType {
|
|
6
|
-
instanceOf: typeof
|
|
6
|
+
instanceOf: typeof BaseObject;
|
|
7
7
|
backend?: any;
|
|
8
8
|
parentKey?: string;
|
|
9
9
|
}
|
|
10
10
|
export declare class CollectionProperty extends BaseProperty {
|
|
11
11
|
static TYPE: string;
|
|
12
12
|
protected _value: Array<any> | Array<DataObjectClass<any>> | Array<ObjectUri> | undefined;
|
|
13
|
-
protected _instanceOf: typeof
|
|
13
|
+
protected _instanceOf: typeof BaseObject;
|
|
14
14
|
protected _parentKey: string;
|
|
15
15
|
constructor(config: CollectionPropertyType);
|
|
16
16
|
set(value: Array<any>, setChanged?: boolean): this;
|