@quatrain/core 1.0.1 → 1.0.2
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 +0 -3
- package/lib/components/AbstractObject.js +0 -21
- package/lib/components/BaseObjectCore.d.ts +2 -1
- package/lib/components/BaseObjectCore.js +2 -1
- package/lib/components/DataObject.d.ts +0 -2
- package/lib/components/DataObject.js +0 -4
- package/lib/components/types/DataObjectClass.d.ts +0 -4
- package/lib/index.d.ts +2 -1
- package/lib/properties/BaseProperty.d.ts +1 -0
- package/lib/properties/BaseProperty.js +3 -1
- package/lib/properties/ObjectProperty.js +6 -6
- package/package.json +1 -1
|
@@ -4,7 +4,6 @@ export declare abstract class AbstractObject {
|
|
|
4
4
|
static PROPS_DEFINITION: DataObjectProperties;
|
|
5
5
|
static COLLECTION: string | undefined;
|
|
6
6
|
static PARENT_PROP: string | undefined;
|
|
7
|
-
static DEFAULT_BACKEND: string;
|
|
8
7
|
static LABEL_KEY: string;
|
|
9
8
|
protected _dataObject: DataObjectClass<any>;
|
|
10
9
|
constructor(dao: DataObjectClass<any>);
|
|
@@ -27,6 +26,4 @@ export declare abstract class AbstractObject {
|
|
|
27
26
|
ref: string;
|
|
28
27
|
label: string;
|
|
29
28
|
};
|
|
30
|
-
save(): Promise<this>;
|
|
31
|
-
delete(): Promise<DataObjectClass<any>>;
|
|
32
29
|
}
|
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
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
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.AbstractObject = void 0;
|
|
13
4
|
class AbstractObject {
|
|
@@ -56,20 +47,8 @@ class AbstractObject {
|
|
|
56
47
|
var _a;
|
|
57
48
|
return typeof this.uri === 'string' ? this.uri : (_a = this.uri) === null || _a === void 0 ? void 0 : _a.toJSON();
|
|
58
49
|
}
|
|
59
|
-
save() {
|
|
60
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
61
|
-
yield this._dataObject.save();
|
|
62
|
-
return this;
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
delete() {
|
|
66
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
67
|
-
return yield this._dataObject.delete();
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
50
|
}
|
|
71
51
|
exports.AbstractObject = AbstractObject;
|
|
72
52
|
AbstractObject.PROPS_DEFINITION = [];
|
|
73
|
-
AbstractObject.DEFAULT_BACKEND = 'default';
|
|
74
53
|
// Which property's value to use in backend as label for object reference
|
|
75
54
|
AbstractObject.LABEL_KEY = 'name';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { ObjectUri, DataObjectClass, DataObject
|
|
1
|
+
import { ObjectUri, DataObjectClass, DataObject } from '../';
|
|
2
|
+
import { BaseObject } from './BaseObject';
|
|
2
3
|
import { AbstractObject } from './AbstractObject';
|
|
3
4
|
export declare class BaseObjectCore extends AbstractObject {
|
|
4
5
|
static PROPS_DEFINITION: any;
|
|
@@ -11,6 +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 BaseObject_1 = require("./BaseObject");
|
|
14
15
|
const AbstractObject_1 = require("./AbstractObject");
|
|
15
16
|
class BaseObjectCore extends AbstractObject_1.AbstractObject {
|
|
16
17
|
static getProperty(key) {
|
|
@@ -148,4 +149,4 @@ class BaseObjectCore extends AbstractObject_1.AbstractObject {
|
|
|
148
149
|
}
|
|
149
150
|
exports.BaseObjectCore = BaseObjectCore;
|
|
150
151
|
// implements BaseObjectClass {
|
|
151
|
-
BaseObjectCore.PROPS_DEFINITION =
|
|
152
|
+
BaseObjectCore.PROPS_DEFINITION = BaseObject_1.BaseObjectProperties;
|
|
@@ -27,7 +27,6 @@ export declare class DataObject implements DataObjectClass<any> {
|
|
|
27
27
|
protected _uid: string | undefined;
|
|
28
28
|
protected _properties: Properties;
|
|
29
29
|
protected _populated: boolean;
|
|
30
|
-
protected _persisted: boolean;
|
|
31
30
|
protected _parentProp: string | undefined;
|
|
32
31
|
protected _proxied: any;
|
|
33
32
|
/**
|
|
@@ -40,7 +39,6 @@ export declare class DataObject implements DataObjectClass<any> {
|
|
|
40
39
|
*/
|
|
41
40
|
protected constructor(params: DataObjectParams | undefined);
|
|
42
41
|
protected _init(properties: any[]): void;
|
|
43
|
-
isPersisted(): boolean;
|
|
44
42
|
/**
|
|
45
43
|
* Wrap instance into proxy to get access to properties
|
|
46
44
|
* @returns Proxy
|
|
@@ -27,7 +27,6 @@ class DataObject {
|
|
|
27
27
|
this._uid = undefined;
|
|
28
28
|
this._properties = {};
|
|
29
29
|
this._populated = false;
|
|
30
|
-
this._persisted = false;
|
|
31
30
|
/**
|
|
32
31
|
* Has data been modified since last backend operation?
|
|
33
32
|
*/
|
|
@@ -53,9 +52,6 @@ class DataObject {
|
|
|
53
52
|
this._properties[prop.name] = Property_1.Property.factory(prop, this);
|
|
54
53
|
});
|
|
55
54
|
}
|
|
56
|
-
isPersisted() {
|
|
57
|
-
return this._persisted;
|
|
58
|
-
}
|
|
59
55
|
/**
|
|
60
56
|
* Wrap instance into proxy to get access to properties
|
|
61
57
|
* @returns Proxy
|
|
@@ -14,14 +14,10 @@ export interface DataObjectClass<T extends DataObjectClass<any>> {
|
|
|
14
14
|
addProperty(property: PropertyClassType): void;
|
|
15
15
|
populate(data?: any): Promise<T>;
|
|
16
16
|
isPopulated(): boolean;
|
|
17
|
-
isPersisted(): boolean;
|
|
18
17
|
has(key: string): boolean;
|
|
19
18
|
get(key: string): any;
|
|
20
19
|
set(key: string, val: any): any;
|
|
21
20
|
val(key: string): any;
|
|
22
|
-
read(): Promise<T>;
|
|
23
|
-
save(): Promise<T>;
|
|
24
|
-
delete(): Promise<T>;
|
|
25
21
|
clone(data?: any): Promise<T>;
|
|
26
22
|
toReference(): any;
|
|
27
23
|
toJSON(params?: boolean | toJSONParams): any;
|
package/lib/index.d.ts
CHANGED
|
@@ -14,10 +14,11 @@ import { AbstractObject } from './components/AbstractObject';
|
|
|
14
14
|
import { ObjectUri } from './components/ObjectUri';
|
|
15
15
|
import { DataObjectClass } from './components/types/DataObjectClass';
|
|
16
16
|
import { DataObject } from './components/DataObject';
|
|
17
|
+
import { DataObjectProperties } from './properties';
|
|
17
18
|
import { BaseObjectCore } from './components/BaseObjectCore';
|
|
18
19
|
import { BaseObject, BaseObjectProperties } from './components/BaseObject';
|
|
19
20
|
import { Proxy } from './components/types/ProxyConstructor';
|
|
20
21
|
import { UserType, User, UserProperties } from './components/User';
|
|
21
22
|
import { EntityType, Entity } from './components/Entity';
|
|
22
23
|
import { BadRequestError, UnauthorizedError, ForbiddenError, NotFoundError, GoneError } from './common/ResourcesErrors';
|
|
23
|
-
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, AbstractObject, BaseObject, BaseObjectCore, BaseObjectProperties, User, UserType, UserProperties, Proxy, Entity, EntityType, BadRequestError, UnauthorizedError, ForbiddenError, NotFoundError, GoneError, };
|
|
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, BaseObject, BaseObjectCore, BaseObjectProperties, User, UserType, UserProperties, Proxy, Entity, EntityType, BadRequestError, UnauthorizedError, ForbiddenError, NotFoundError, GoneError, };
|
|
@@ -36,6 +36,7 @@ export declare class BaseProperty implements PropertyClassType {
|
|
|
36
36
|
set htmlType(type: PropertyHTMLType);
|
|
37
37
|
get htmlType(): PropertyHTMLType;
|
|
38
38
|
get hasChanged(): boolean;
|
|
39
|
+
set hasChanged(val: boolean);
|
|
39
40
|
set(value: any, setChanged?: boolean): this;
|
|
40
41
|
val(transform?: any): any;
|
|
41
42
|
protected _enable(value: boolean | undefined): boolean;
|
|
@@ -43,6 +43,9 @@ class BaseProperty {
|
|
|
43
43
|
get hasChanged() {
|
|
44
44
|
return this._hasChanged;
|
|
45
45
|
}
|
|
46
|
+
set hasChanged(val) {
|
|
47
|
+
this._hasChanged = val;
|
|
48
|
+
}
|
|
46
49
|
set(value, setChanged = true) {
|
|
47
50
|
if (this._value !== undefined &&
|
|
48
51
|
this._value !== null &&
|
|
@@ -51,7 +54,6 @@ class BaseProperty {
|
|
|
51
54
|
throw new Error(`Value '${this._name}' already defined as '${this._value}' and protected from change`);
|
|
52
55
|
}
|
|
53
56
|
if (value !== this._value) {
|
|
54
|
-
// console.log(this.name, value, this._value)
|
|
55
57
|
this._value = value;
|
|
56
58
|
this._hasChanged = setChanged;
|
|
57
59
|
}
|
|
@@ -32,28 +32,28 @@ class ObjectProperty extends BaseProperty_1.BaseProperty {
|
|
|
32
32
|
switch (transform) {
|
|
33
33
|
case returnAs.AS_DATAOBJECTS:
|
|
34
34
|
if (this._value instanceof DataObject_1.DataObject) {
|
|
35
|
-
|
|
35
|
+
Core_1.Core.log(`Returning already existing dataObject`);
|
|
36
36
|
return this._value;
|
|
37
37
|
}
|
|
38
38
|
else if (this._value instanceof ObjectUri_1.ObjectUri) {
|
|
39
|
-
|
|
39
|
+
Core_1.Core.log(`Converting objectUri -> dataObject`);
|
|
40
40
|
return DataObject_1.DataObject.factory({
|
|
41
41
|
properties: Reflect.get(this._instanceOf, 'PROPS_DEFINITION'),
|
|
42
42
|
uri: this._value,
|
|
43
43
|
});
|
|
44
44
|
}
|
|
45
45
|
else {
|
|
46
|
-
|
|
46
|
+
Core_1.Core.log(`Converting instance -> dataObject`);
|
|
47
47
|
return this._value.dataObject;
|
|
48
48
|
}
|
|
49
49
|
case returnAs.AS_INSTANCES:
|
|
50
50
|
if (this._value instanceof DataObject_1.DataObject) {
|
|
51
|
-
|
|
51
|
+
Core_1.Core.log(`Converting dataObject -> instance`);
|
|
52
52
|
return Reflect.construct(this._instanceOf, [this._value]);
|
|
53
53
|
}
|
|
54
54
|
else if (this._value instanceof ObjectUri_1.ObjectUri) {
|
|
55
55
|
// console.log('ObjectProperty', this)
|
|
56
|
-
|
|
56
|
+
Core_1.Core.log(`Converting objectUri -> dataObject -> instance`);
|
|
57
57
|
// console.log(this._instanceOf)
|
|
58
58
|
const dao = DataObject_1.DataObject.factory({
|
|
59
59
|
properties: Reflect.get(this._instanceOf, 'PROPS_DEFINITION'),
|
|
@@ -62,7 +62,7 @@ class ObjectProperty extends BaseProperty_1.BaseProperty {
|
|
|
62
62
|
return Reflect.construct(this._instanceOf, [dao]);
|
|
63
63
|
}
|
|
64
64
|
else {
|
|
65
|
-
|
|
65
|
+
Core_1.Core.log(`Returning already existing instance`);
|
|
66
66
|
return this._value;
|
|
67
67
|
}
|
|
68
68
|
case returnAs.AS_OBJECTURIS:
|