@quatrain/core 0.2.0 → 0.4.0
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/Backend.d.ts +5 -0
- package/lib/Backend.js +7 -0
- package/lib/Core.d.ts +23 -3
- package/lib/Core.js +24 -5
- package/lib/backends/AbstractAdapter.d.ts +29 -13
- package/lib/backends/AbstractAdapter.js +31 -3
- package/lib/backends/Filter.d.ts +5 -3
- package/lib/backends/Filter.js +1 -1
- package/lib/backends/MockAdapter.d.ts +11 -12
- package/lib/backends/MockAdapter.js +126 -35
- package/lib/backends/NotFoundError.d.ts +2 -0
- package/lib/backends/NotFoundError.js +6 -0
- package/lib/backends/Query.d.ts +11 -3
- package/lib/backends/Query.js +30 -4
- package/lib/backends/middlewares/AbstractMiddleware.d.ts +0 -0
- package/lib/backends/middlewares/AbstractMiddleware.js +1 -0
- package/lib/backends/middlewares/InjectMetaMiddleware.d.ts +11 -0
- package/lib/backends/middlewares/InjectMetaMiddleware.js +50 -0
- package/lib/components/AbstractObject.d.ts +13 -10
- package/lib/components/AbstractObject.js +11 -2
- package/lib/components/BaseObject.d.ts +10 -11
- package/lib/components/BaseObject.js +42 -33
- package/lib/components/BaseObjectProperties.d.ts +6 -8
- package/lib/components/BaseObjectProperties.js +14 -9
- package/lib/components/DataObject.d.ts +25 -18
- package/lib/components/DataObject.js +63 -33
- package/lib/components/Entity.d.ts +6 -0
- package/lib/components/Entity.js +26 -0
- package/lib/components/EntityProperties.d.ts +1 -0
- package/lib/components/EntityProperties.js +47 -0
- package/lib/components/ObjectUri.d.ts +5 -2
- package/lib/components/ObjectUri.js +23 -8
- package/lib/components/User.d.ts +6 -4
- package/lib/components/User.js +78 -8
- package/lib/components/UserProperties.d.ts +1 -0
- package/lib/components/UserProperties.js +103 -0
- package/lib/components/index.d.ts +6 -3
- package/lib/components/index.js +5 -2
- package/lib/components/types/AbstractObjectClass.d.ts +6 -0
- package/lib/components/types/AbstractObjectClass.js +2 -0
- package/lib/components/types/BaseObjectClass.d.ts +6 -0
- package/lib/components/types/BaseObjectClass.js +2 -0
- package/lib/components/types/DataObjectClass.d.ts +23 -0
- package/lib/components/types/DataObjectClass.js +2 -0
- package/lib/components/types/EntityClass.d.ts +3 -0
- package/lib/components/types/EntityClass.js +2 -0
- package/lib/components/types/UserClass.d.ts +3 -0
- package/lib/components/types/UserClass.js +2 -0
- package/lib/index.d.ts +5 -1
- package/lib/index.js +7 -1
- package/lib/properties/ArrayProperty.d.ts +1 -0
- package/lib/properties/ArrayProperty.js +6 -5
- package/lib/properties/BaseProperty.d.ts +10 -4
- package/lib/properties/BaseProperty.js +11 -1
- package/lib/properties/BooleanProperty.d.ts +2 -1
- package/lib/properties/BooleanProperty.js +3 -2
- package/lib/properties/CollectionProperty.d.ts +32 -0
- package/lib/properties/CollectionProperty.js +63 -0
- package/lib/properties/DateTimeProperty.d.ts +1 -0
- package/lib/properties/DateTimeProperty.js +1 -0
- package/lib/properties/EnumProperty.d.ts +2 -0
- package/lib/properties/EnumProperty.js +5 -1
- package/lib/properties/HashProperty.d.ts +1 -0
- package/lib/properties/HashProperty.js +1 -0
- package/lib/properties/MapProperty.d.ts +8 -0
- package/lib/properties/MapProperty.js +17 -0
- package/lib/properties/NumberProperty.d.ts +1 -0
- package/lib/properties/NumberProperty.js +1 -0
- package/lib/properties/ObjectProperty.d.ts +4 -7
- package/lib/properties/ObjectProperty.js +4 -1
- package/lib/properties/Property.d.ts +3 -7
- package/lib/properties/Property.js +13 -15
- package/lib/properties/StringProperty.d.ts +10 -0
- package/lib/properties/StringProperty.js +42 -21
- package/lib/properties/index.d.ts +4 -2
- package/lib/properties/index.js +5 -1
- package/lib/properties/types/PropertyClassType.d.ts +4 -2
- package/lib/properties/types/PropertyHTMLType.d.ts +10 -0
- package/lib/properties/types/PropertyHTMLType.js +14 -0
- package/lib/properties/types/PropertyTypes.d.ts +4 -1
- package/lib/utils/DataGenerator.d.ts +9 -0
- package/lib/utils/DataGenerator.js +98 -0
- package/lib/utils/index.d.ts +2 -0
- package/lib/utils/index.js +5 -0
- package/package.json +3 -1
|
@@ -0,0 +1,47 @@
|
|
|
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.EntityProperties = void 0;
|
|
27
|
+
const properties_1 = require("../properties");
|
|
28
|
+
const StringProperty_1 = require("../properties/StringProperty");
|
|
29
|
+
const htmlType = __importStar(require("../properties/types/PropertyHTMLType"));
|
|
30
|
+
const User_1 = require("./User");
|
|
31
|
+
exports.EntityProperties = [
|
|
32
|
+
{
|
|
33
|
+
// surcharge property minLength and htmlType
|
|
34
|
+
name: 'name',
|
|
35
|
+
type: StringProperty_1.StringProperty.TYPE,
|
|
36
|
+
mandatory: true,
|
|
37
|
+
minLength: 1,
|
|
38
|
+
htmlType: htmlType.ORG,
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
name: 'users',
|
|
42
|
+
mandatory: true,
|
|
43
|
+
type: properties_1.CollectionProperty.TYPE,
|
|
44
|
+
instanceOf: User_1.User,
|
|
45
|
+
parentKey: 'entity',
|
|
46
|
+
},
|
|
47
|
+
];
|
|
@@ -9,6 +9,7 @@ export declare class ObjectUri {
|
|
|
9
9
|
protected _uid: string | undefined;
|
|
10
10
|
protected _collection: string | undefined;
|
|
11
11
|
protected _label: string | undefined;
|
|
12
|
+
protected _objClass: any;
|
|
12
13
|
/**
|
|
13
14
|
* create object uri from string:
|
|
14
15
|
* ex: 'xyz', '@backend:xyz', 'collection/xyz', '@backend:collection/xyz'
|
|
@@ -16,6 +17,8 @@ export declare class ObjectUri {
|
|
|
16
17
|
* @param str
|
|
17
18
|
*/
|
|
18
19
|
constructor(str?: string, label?: string | undefined);
|
|
20
|
+
set class(objClass: any);
|
|
21
|
+
get class(): any;
|
|
19
22
|
get backend(): string;
|
|
20
23
|
get path(): string;
|
|
21
24
|
set label(label: string | undefined);
|
|
@@ -35,8 +38,8 @@ export declare class ObjectUri {
|
|
|
35
38
|
label: string | undefined;
|
|
36
39
|
};
|
|
37
40
|
toJSON(): {
|
|
38
|
-
|
|
41
|
+
backend: string;
|
|
39
42
|
ref: string;
|
|
40
|
-
label: string
|
|
43
|
+
label: string;
|
|
41
44
|
};
|
|
42
45
|
}
|
|
@@ -9,15 +9,16 @@ class ObjectUri {
|
|
|
9
9
|
* some backends will need a collection or table name, some may deduct it from object
|
|
10
10
|
* @param str
|
|
11
11
|
*/
|
|
12
|
-
constructor(str = '', label =
|
|
12
|
+
constructor(str = '', label = '') {
|
|
13
13
|
this._pairs = [];
|
|
14
14
|
this._literal = '';
|
|
15
15
|
this._backend = Core_1.Core.defaultBackend;
|
|
16
16
|
this._path = ObjectUri.DEFAULT;
|
|
17
17
|
this._uid = undefined;
|
|
18
18
|
this._collection = undefined;
|
|
19
|
+
this._label = '';
|
|
19
20
|
this._str = str;
|
|
20
|
-
this._label = label
|
|
21
|
+
this._label = label;
|
|
21
22
|
if (str.indexOf(':') !== -1) {
|
|
22
23
|
const [backend, path] = str.split(':');
|
|
23
24
|
this._backend = backend || Core_1.Core.defaultBackend;
|
|
@@ -33,6 +34,7 @@ class ObjectUri {
|
|
|
33
34
|
this._uid = parts[0].length > 0 ? parts[0] : undefined;
|
|
34
35
|
this._collection = ObjectUri.MISSING_COLLECTION;
|
|
35
36
|
this._pairs.push(`${ObjectUri.MISSING_COLLECTION}${ObjectUri.DEFAULT}${this._uid}`);
|
|
37
|
+
this._label = label || this._uid;
|
|
36
38
|
}
|
|
37
39
|
else if (parts.length % 2 === 0) {
|
|
38
40
|
// General case is a path containing pairs of collection/uid
|
|
@@ -43,11 +45,25 @@ class ObjectUri {
|
|
|
43
45
|
this._pairs.push(`${parts[i]}${ObjectUri.DEFAULT}${parts[i + 1]}`);
|
|
44
46
|
i += 2;
|
|
45
47
|
}
|
|
48
|
+
this._label = label || this._uid;
|
|
46
49
|
}
|
|
47
50
|
else {
|
|
48
51
|
throw new Error('Path parts number must be 1 or even');
|
|
49
52
|
}
|
|
50
53
|
}
|
|
54
|
+
set class(objClass) {
|
|
55
|
+
var _a;
|
|
56
|
+
this._objClass = objClass;
|
|
57
|
+
if (objClass) {
|
|
58
|
+
this._collection = objClass.COLLECTION || ((_a = objClass.name) === null || _a === void 0 ? void 0 : _a.toLowerCase());
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
this._collection = undefined;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
get class() {
|
|
65
|
+
return this._objClass;
|
|
66
|
+
}
|
|
51
67
|
get backend() {
|
|
52
68
|
return this._backend;
|
|
53
69
|
}
|
|
@@ -61,9 +77,6 @@ class ObjectUri {
|
|
|
61
77
|
return this._label;
|
|
62
78
|
}
|
|
63
79
|
get literal() {
|
|
64
|
-
// return `${this._backend}:${
|
|
65
|
-
// this._collection || ObjectUri.MISSING_COLLECTION
|
|
66
|
-
// }${ObjectUri.DEFAULT}${this._uid}`
|
|
67
80
|
return `${this._backend}:${this._pairs.join(ObjectUri.DEFAULT)}`;
|
|
68
81
|
}
|
|
69
82
|
set path(path) {
|
|
@@ -71,8 +84,10 @@ class ObjectUri {
|
|
|
71
84
|
throw new Error(`Path value already set with '${this._path}'`);
|
|
72
85
|
}
|
|
73
86
|
this._path = path;
|
|
74
|
-
|
|
87
|
+
// TODO manage paths to subcollection
|
|
88
|
+
this._collection = path.split('/')[0];
|
|
75
89
|
this._literal = `${this._backend}:${this._path}`;
|
|
90
|
+
this._uid = path.split('/').pop();
|
|
76
91
|
}
|
|
77
92
|
get uid() {
|
|
78
93
|
return this._uid;
|
|
@@ -101,9 +116,9 @@ class ObjectUri {
|
|
|
101
116
|
}
|
|
102
117
|
toJSON() {
|
|
103
118
|
return {
|
|
104
|
-
|
|
119
|
+
backend: this._backend,
|
|
105
120
|
ref: this._path,
|
|
106
|
-
label: this._label,
|
|
121
|
+
label: this._label || '',
|
|
107
122
|
};
|
|
108
123
|
}
|
|
109
124
|
}
|
package/lib/components/User.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { DataObjectProperties } from '../properties';
|
|
2
1
|
import { BaseObject } from './BaseObject';
|
|
3
|
-
|
|
4
|
-
export declare
|
|
5
|
-
|
|
2
|
+
import { UserClass } from './types/UserClass';
|
|
3
|
+
export declare const UserProperties: any;
|
|
4
|
+
export declare class User extends BaseObject implements UserClass {
|
|
5
|
+
static PROPS_DEFINITION: any;
|
|
6
|
+
static COLLECTION: string;
|
|
7
|
+
static factory(src?: any): Promise<User>;
|
|
6
8
|
}
|
package/lib/components/User.js
CHANGED
|
@@ -1,9 +1,44 @@
|
|
|
1
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
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
};
|
|
2
34
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
35
|
exports.User = exports.UserProperties = void 0;
|
|
4
|
-
const Property_1 = require("../properties/Property");
|
|
5
|
-
const HashProperty_1 = require("../properties/HashProperty");
|
|
6
36
|
const BaseObject_1 = require("./BaseObject");
|
|
37
|
+
const properties_1 = require("../properties");
|
|
38
|
+
const HashProperty_1 = require("../properties/HashProperty");
|
|
39
|
+
const StringProperty_1 = require("../properties/StringProperty");
|
|
40
|
+
const Entity_1 = require("./Entity");
|
|
41
|
+
const htmlType = __importStar(require("../properties/types/PropertyHTMLType"));
|
|
7
42
|
/**
|
|
8
43
|
* Callback function to populate the 'name' property
|
|
9
44
|
* @param dao DataObject
|
|
@@ -14,43 +49,78 @@ exports.UserProperties = [
|
|
|
14
49
|
{
|
|
15
50
|
// change name property minLength
|
|
16
51
|
name: 'name',
|
|
17
|
-
type:
|
|
52
|
+
type: StringProperty_1.StringProperty.TYPE,
|
|
18
53
|
minLength: 0,
|
|
54
|
+
fullSearch: true,
|
|
55
|
+
htmlType: htmlType.NAME,
|
|
19
56
|
},
|
|
20
57
|
{
|
|
21
58
|
name: 'firstname',
|
|
22
59
|
mandatory: true,
|
|
23
|
-
type:
|
|
60
|
+
type: StringProperty_1.StringProperty.TYPE,
|
|
24
61
|
minLength: 1,
|
|
25
62
|
maxLength: 100,
|
|
63
|
+
htmlType: htmlType.GIVEN_NAME,
|
|
26
64
|
onChange,
|
|
27
65
|
},
|
|
28
66
|
{
|
|
29
67
|
name: 'lastname',
|
|
30
68
|
mandatory: true,
|
|
31
|
-
type:
|
|
69
|
+
type: StringProperty_1.StringProperty.TYPE,
|
|
32
70
|
minLength: 1,
|
|
33
71
|
maxLength: 100,
|
|
72
|
+
htmlType: htmlType.FAMILY_NAME,
|
|
34
73
|
onChange,
|
|
35
74
|
},
|
|
75
|
+
{
|
|
76
|
+
name: 'gender',
|
|
77
|
+
mandatory: false,
|
|
78
|
+
type: properties_1.EnumProperty.TYPE,
|
|
79
|
+
values: ['male', 'female', 'nonbinary'],
|
|
80
|
+
htmlType: htmlType.GENDER,
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
name: 'birthday',
|
|
84
|
+
mandatory: false,
|
|
85
|
+
type: properties_1.DateTimeProperty.TYPE,
|
|
86
|
+
htmlType: htmlType.BIRTHDAY,
|
|
87
|
+
},
|
|
36
88
|
{
|
|
37
89
|
name: 'email',
|
|
38
90
|
mandatory: true,
|
|
39
|
-
type:
|
|
91
|
+
type: StringProperty_1.StringProperty.TYPE,
|
|
40
92
|
minLength: 1,
|
|
41
93
|
maxLength: 100,
|
|
94
|
+
fullSearch: true,
|
|
95
|
+
htmlType: htmlType.EMAIL,
|
|
42
96
|
},
|
|
43
97
|
{
|
|
44
98
|
name: 'password',
|
|
45
99
|
mandatory: true,
|
|
46
|
-
type:
|
|
100
|
+
type: HashProperty_1.HashProperty.TYPE,
|
|
47
101
|
algorithm: HashProperty_1.HashProperty.ALGORITHM_SHA256,
|
|
48
102
|
salt: '',
|
|
49
103
|
minLength: 5,
|
|
50
|
-
maxLength: 20,
|
|
104
|
+
maxLength: 20,
|
|
105
|
+
htmlType: htmlType.PASSWORD,
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
name: 'entity',
|
|
109
|
+
mandatory: false,
|
|
110
|
+
type: properties_1.ObjectProperty.TYPE,
|
|
111
|
+
instanceof: Entity_1.Entity,
|
|
51
112
|
},
|
|
52
113
|
];
|
|
53
114
|
class User extends BaseObject_1.BaseObject {
|
|
115
|
+
static factory(src = undefined) {
|
|
116
|
+
const _super = Object.create(null, {
|
|
117
|
+
factory: { get: () => super.factory }
|
|
118
|
+
});
|
|
119
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
120
|
+
return _super.factory.call(this, src, User);
|
|
121
|
+
});
|
|
122
|
+
}
|
|
54
123
|
}
|
|
55
124
|
exports.User = User;
|
|
56
125
|
User.PROPS_DEFINITION = exports.UserProperties;
|
|
126
|
+
User.COLLECTION = 'users';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const UserProperties: any;
|
|
@@ -0,0 +1,103 @@
|
|
|
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.UserProperties = void 0;
|
|
27
|
+
const properties_1 = require("../properties");
|
|
28
|
+
const HashProperty_1 = require("../properties/HashProperty");
|
|
29
|
+
const StringProperty_1 = require("../properties/StringProperty");
|
|
30
|
+
const Entity_1 = require("./Entity");
|
|
31
|
+
const htmlType = __importStar(require("../properties/types/PropertyHTMLType"));
|
|
32
|
+
/**
|
|
33
|
+
* Callback function to populate the 'name' property
|
|
34
|
+
* @param dao DataObject
|
|
35
|
+
* @returns
|
|
36
|
+
*/
|
|
37
|
+
const onChange = (dao) => dao.set('name', `${dao.val('firstname')} ${dao.val('lastname')}`);
|
|
38
|
+
exports.UserProperties = [
|
|
39
|
+
{
|
|
40
|
+
// change name property minLength
|
|
41
|
+
name: 'name',
|
|
42
|
+
type: StringProperty_1.StringProperty.TYPE,
|
|
43
|
+
minLength: 0,
|
|
44
|
+
fullSearch: true,
|
|
45
|
+
htmlType: htmlType.NAME,
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
name: 'firstname',
|
|
49
|
+
mandatory: true,
|
|
50
|
+
type: StringProperty_1.StringProperty.TYPE,
|
|
51
|
+
minLength: 1,
|
|
52
|
+
maxLength: 100,
|
|
53
|
+
htmlType: htmlType.GIVEN_NAME,
|
|
54
|
+
onChange,
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
name: 'lastname',
|
|
58
|
+
mandatory: true,
|
|
59
|
+
type: StringProperty_1.StringProperty.TYPE,
|
|
60
|
+
minLength: 1,
|
|
61
|
+
maxLength: 100,
|
|
62
|
+
htmlType: htmlType.FAMILY_NAME,
|
|
63
|
+
onChange,
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
name: 'gender',
|
|
67
|
+
mandatory: false,
|
|
68
|
+
type: properties_1.EnumProperty.TYPE,
|
|
69
|
+
values: ['male', 'female', 'nonbinary'],
|
|
70
|
+
htmlType: htmlType.GENDER,
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
name: 'birthday',
|
|
74
|
+
mandatory: false,
|
|
75
|
+
type: properties_1.DateTimeProperty.TYPE,
|
|
76
|
+
htmlType: htmlType.BIRTHDAY,
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
name: 'email',
|
|
80
|
+
mandatory: true,
|
|
81
|
+
type: StringProperty_1.StringProperty.TYPE,
|
|
82
|
+
minLength: 1,
|
|
83
|
+
maxLength: 100,
|
|
84
|
+
fullSearch: true,
|
|
85
|
+
htmlType: htmlType.EMAIL,
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
name: 'password',
|
|
89
|
+
mandatory: true,
|
|
90
|
+
type: HashProperty_1.HashProperty.TYPE,
|
|
91
|
+
algorithm: HashProperty_1.HashProperty.ALGORITHM_SHA256,
|
|
92
|
+
salt: '',
|
|
93
|
+
minLength: 5,
|
|
94
|
+
maxLength: 20,
|
|
95
|
+
htmlType: htmlType.PASSWORD,
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
name: 'entity',
|
|
99
|
+
mandatory: false,
|
|
100
|
+
type: properties_1.ObjectProperty.TYPE,
|
|
101
|
+
instanceof: Entity_1.Entity,
|
|
102
|
+
},
|
|
103
|
+
];
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
import { DataObject } from './DataObject';
|
|
1
|
+
import { DataObject, DataObjectParams } from './DataObject';
|
|
2
|
+
import { DataObjectClass } from './types/DataObjectClass';
|
|
2
3
|
import { ObjectUri } from './ObjectUri';
|
|
3
4
|
import { AbstractObject } from './AbstractObject';
|
|
4
5
|
import { BaseObject } from './BaseObject';
|
|
5
6
|
import { BaseObjectProperties } from './BaseObjectProperties';
|
|
6
|
-
import {
|
|
7
|
-
|
|
7
|
+
import { UserProperties } from './UserProperties';
|
|
8
|
+
import { User } from './User';
|
|
9
|
+
import { Entity } from './Entity';
|
|
10
|
+
export { DataObject, DataObjectParams, DataObjectClass, ObjectUri, AbstractObject, BaseObject, User, Entity, BaseObjectProperties, UserProperties, };
|
package/lib/components/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.UserProperties = exports.BaseObjectProperties = exports.User = exports.BaseObject = exports.AbstractObject = exports.ObjectUri = exports.DataObject = void 0;
|
|
3
|
+
exports.UserProperties = exports.BaseObjectProperties = exports.Entity = exports.User = exports.BaseObject = exports.AbstractObject = exports.ObjectUri = exports.DataObject = void 0;
|
|
4
4
|
const DataObject_1 = require("./DataObject");
|
|
5
5
|
Object.defineProperty(exports, "DataObject", { enumerable: true, get: function () { return DataObject_1.DataObject; } });
|
|
6
6
|
const ObjectUri_1 = require("./ObjectUri");
|
|
@@ -11,6 +11,9 @@ const BaseObject_1 = require("./BaseObject");
|
|
|
11
11
|
Object.defineProperty(exports, "BaseObject", { enumerable: true, get: function () { return BaseObject_1.BaseObject; } });
|
|
12
12
|
const BaseObjectProperties_1 = require("./BaseObjectProperties");
|
|
13
13
|
Object.defineProperty(exports, "BaseObjectProperties", { enumerable: true, get: function () { return BaseObjectProperties_1.BaseObjectProperties; } });
|
|
14
|
+
const UserProperties_1 = require("./UserProperties");
|
|
15
|
+
Object.defineProperty(exports, "UserProperties", { enumerable: true, get: function () { return UserProperties_1.UserProperties; } });
|
|
14
16
|
const User_1 = require("./User");
|
|
15
17
|
Object.defineProperty(exports, "User", { enumerable: true, get: function () { return User_1.User; } });
|
|
16
|
-
|
|
18
|
+
const Entity_1 = require("./Entity");
|
|
19
|
+
Object.defineProperty(exports, "Entity", { enumerable: true, get: function () { return Entity_1.Entity; } });
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ObjectUri } from '../ObjectUri';
|
|
2
|
+
export interface DataObjectClass<T extends DataObjectClass<any>> {
|
|
3
|
+
uri: ObjectUri;
|
|
4
|
+
uid: any;
|
|
5
|
+
backend: any;
|
|
6
|
+
path: any;
|
|
7
|
+
class: any;
|
|
8
|
+
properties: any;
|
|
9
|
+
setProperties(properties: any): void;
|
|
10
|
+
populate(data?: any): Promise<T>;
|
|
11
|
+
isPopulated(): boolean;
|
|
12
|
+
isPersisted(): boolean;
|
|
13
|
+
has(key: string): boolean;
|
|
14
|
+
get(key: string): any;
|
|
15
|
+
set(key: string, val: any): any;
|
|
16
|
+
val(key: string): any;
|
|
17
|
+
read(): Promise<T>;
|
|
18
|
+
save(): Promise<T>;
|
|
19
|
+
delete(): Promise<T>;
|
|
20
|
+
clone(data?: any): Promise<T>;
|
|
21
|
+
toReference(): any;
|
|
22
|
+
toJSON(): any;
|
|
23
|
+
}
|
package/lib/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Core } from './Core';
|
|
2
2
|
import * as statuses from './common/statuses';
|
|
3
|
+
import * as utils from './utils';
|
|
3
4
|
import { Property } from './properties/Property';
|
|
4
5
|
import { BaseProperty, BasePropertyType } from './properties/BaseProperty';
|
|
5
6
|
import { StringProperty, StringPropertyType } from './properties/StringProperty';
|
|
@@ -10,8 +11,11 @@ import { DateTimeProperty, DateTimePropertyType } from './properties/DateTimePro
|
|
|
10
11
|
import { HashProperty, HashPropertyType } from './properties/HashProperty';
|
|
11
12
|
import { AbstractObject } from './components/AbstractObject';
|
|
12
13
|
import { ObjectUri } from './components/ObjectUri';
|
|
14
|
+
import { DataObjectClass } from './components/types/DataObjectClass';
|
|
13
15
|
import { DataObject } from './components/DataObject';
|
|
14
16
|
import { BaseObject } from './components/BaseObject';
|
|
15
17
|
import { BaseObjectProperties } from './components/BaseObjectProperties';
|
|
18
|
+
import { User } from './components/User';
|
|
19
|
+
import { Entity } from './components/Entity';
|
|
16
20
|
import { AbstractAdapter, MockAdapter, BackendError, BackendParameters, Query, Filter, Filters, Limits, Sorting, SortAndLimit } from './backends';
|
|
17
|
-
export { statuses, Core, Property, BaseProperty, BasePropertyType, BooleanProperty, BooleanPropertyType, DateTimeProperty, DateTimePropertyType, EnumProperty, EnumPropertyType, HashProperty, HashPropertyType, ObjectProperty, ObjectPropertyType, StringProperty, StringPropertyType, AbstractAdapter, MockAdapter, ObjectUri, DataObject, AbstractObject, BaseObject, BaseObjectProperties, BackendParameters, BackendError, Query, Filter, Filters, Limits, Sorting, SortAndLimit, };
|
|
21
|
+
export { statuses, utils, Core, Property, BaseProperty, BasePropertyType, BooleanProperty, BooleanPropertyType, DateTimeProperty, DateTimePropertyType, EnumProperty, EnumPropertyType, HashProperty, HashPropertyType, ObjectProperty, ObjectPropertyType, StringProperty, StringPropertyType, AbstractAdapter, MockAdapter, ObjectUri, DataObjectClass, DataObject, AbstractObject, BaseObject, BaseObjectProperties, BackendParameters, BackendError, Query, Filter, Filters, Limits, Sorting, SortAndLimit, User, Entity, };
|
package/lib/index.js
CHANGED
|
@@ -23,11 +23,13 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.SortAndLimit = exports.Sorting = exports.Limits = exports.Filters = exports.Filter = exports.Query = exports.BackendError = exports.BaseObjectProperties = exports.BaseObject = exports.AbstractObject = exports.DataObject = exports.ObjectUri = exports.MockAdapter = exports.AbstractAdapter = exports.StringProperty = exports.ObjectProperty = exports.HashProperty = exports.EnumProperty = exports.DateTimeProperty = exports.BooleanProperty = exports.BaseProperty = exports.Property = exports.Core = exports.statuses = void 0;
|
|
26
|
+
exports.Entity = exports.User = exports.SortAndLimit = exports.Sorting = exports.Limits = exports.Filters = exports.Filter = exports.Query = exports.BackendError = exports.BaseObjectProperties = exports.BaseObject = exports.AbstractObject = exports.DataObject = exports.ObjectUri = exports.MockAdapter = exports.AbstractAdapter = exports.StringProperty = exports.ObjectProperty = exports.HashProperty = exports.EnumProperty = exports.DateTimeProperty = exports.BooleanProperty = exports.BaseProperty = exports.Property = exports.Core = exports.utils = 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"));
|
|
30
30
|
exports.statuses = statuses;
|
|
31
|
+
const utils = __importStar(require("./utils"));
|
|
32
|
+
exports.utils = utils;
|
|
31
33
|
const Property_1 = require("./properties/Property");
|
|
32
34
|
Object.defineProperty(exports, "Property", { enumerable: true, get: function () { return Property_1.Property; } });
|
|
33
35
|
const BaseProperty_1 = require("./properties/BaseProperty");
|
|
@@ -54,6 +56,10 @@ const BaseObject_1 = require("./components/BaseObject");
|
|
|
54
56
|
Object.defineProperty(exports, "BaseObject", { enumerable: true, get: function () { return BaseObject_1.BaseObject; } });
|
|
55
57
|
const BaseObjectProperties_1 = require("./components/BaseObjectProperties");
|
|
56
58
|
Object.defineProperty(exports, "BaseObjectProperties", { enumerable: true, get: function () { return BaseObjectProperties_1.BaseObjectProperties; } });
|
|
59
|
+
const User_1 = require("./components/User");
|
|
60
|
+
Object.defineProperty(exports, "User", { enumerable: true, get: function () { return User_1.User; } });
|
|
61
|
+
const Entity_1 = require("./components/Entity");
|
|
62
|
+
Object.defineProperty(exports, "Entity", { enumerable: true, get: function () { return Entity_1.Entity; } });
|
|
57
63
|
const backends_1 = require("./backends");
|
|
58
64
|
Object.defineProperty(exports, "AbstractAdapter", { enumerable: true, get: function () { return backends_1.AbstractAdapter; } });
|
|
59
65
|
Object.defineProperty(exports, "MockAdapter", { enumerable: true, get: function () { return backends_1.MockAdapter; } });
|
|
@@ -6,6 +6,7 @@ export interface ArrayPropertyType extends BasePropertyType {
|
|
|
6
6
|
allowStrings?: boolean;
|
|
7
7
|
}
|
|
8
8
|
export declare class ArrayProperty extends BaseProperty {
|
|
9
|
+
static TYPE: string;
|
|
9
10
|
protected _value: Array<any> | undefined;
|
|
10
11
|
protected _minLength: number;
|
|
11
12
|
protected _maxLength: number;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ArrayProperty = void 0;
|
|
4
|
-
const Property_1 = require("./Property");
|
|
5
4
|
const BaseProperty_1 = require("./BaseProperty");
|
|
5
|
+
const StringProperty_1 = require("./StringProperty");
|
|
6
6
|
class ArrayProperty extends BaseProperty_1.BaseProperty {
|
|
7
7
|
constructor(config) {
|
|
8
8
|
super(config);
|
|
@@ -12,10 +12,10 @@ class ArrayProperty extends BaseProperty_1.BaseProperty {
|
|
|
12
12
|
this.minLength = config.minLength || 0;
|
|
13
13
|
this.maxLength = config.maxLength || 0;
|
|
14
14
|
if (this._enable(config.allowNumbers)) {
|
|
15
|
-
this._allows.push(
|
|
15
|
+
this._allows.push(StringProperty_1.StringProperty.ALLOW_NUMBERS);
|
|
16
16
|
}
|
|
17
17
|
if (this._enable(config.allowStrings)) {
|
|
18
|
-
this._allows.push(
|
|
18
|
+
this._allows.push(StringProperty_1.StringProperty.ALLOW_STRINGS);
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
set minLength(min) {
|
|
@@ -41,11 +41,11 @@ class ArrayProperty extends BaseProperty_1.BaseProperty {
|
|
|
41
41
|
throw new Error(`Array values are too many`);
|
|
42
42
|
}
|
|
43
43
|
const joined = value.join();
|
|
44
|
-
if (this._allows.includes(
|
|
44
|
+
if (this._allows.includes(StringProperty_1.StringProperty.ALLOW_STRINGS) === false &&
|
|
45
45
|
/[a-zA-Z]/.test(joined)) {
|
|
46
46
|
throw new Error(`Strings are not allowed in value`);
|
|
47
47
|
}
|
|
48
|
-
if (this._allows.includes(
|
|
48
|
+
if (this._allows.includes(StringProperty_1.StringProperty.ALLOW_NUMBERS) === false &&
|
|
49
49
|
/\d/.test(joined)) {
|
|
50
50
|
throw new Error(`Numbers are not allowed in value`);
|
|
51
51
|
}
|
|
@@ -59,3 +59,4 @@ class ArrayProperty extends BaseProperty_1.BaseProperty {
|
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
61
|
exports.ArrayProperty = ArrayProperty;
|
|
62
|
+
ArrayProperty.TYPE = 'array';
|
|
@@ -1,23 +1,27 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DataObjectClass } from '../components/types/DataObjectClass';
|
|
2
2
|
import { AbstractPropertyType } from './types/AbstractPropertyType';
|
|
3
3
|
import { PropertyClassType } from './types/PropertyClassType';
|
|
4
|
+
import { PropertyHTMLType } from './types/PropertyHTMLType';
|
|
4
5
|
export declare type EventTypes = typeof BaseProperty.EVENT_ONCHANGE | typeof BaseProperty.EVENT_ONDELETE;
|
|
5
6
|
export interface BasePropertyType extends AbstractPropertyType {
|
|
6
|
-
parent?:
|
|
7
|
+
parent?: DataObjectClass<any>;
|
|
7
8
|
protected?: boolean;
|
|
8
9
|
mandatory?: boolean;
|
|
9
10
|
defaultValue?: any;
|
|
10
|
-
|
|
11
|
+
htmlType?: PropertyHTMLType;
|
|
12
|
+
onChange?: (dao: DataObjectClass<any>) => DataObjectClass<any>;
|
|
11
13
|
}
|
|
12
14
|
export declare class BaseProperty implements PropertyClassType {
|
|
15
|
+
static TYPE: string;
|
|
13
16
|
static EVENT_ONCHANGE: string;
|
|
14
17
|
static EVENT_ONDELETE: string;
|
|
15
|
-
protected _parent:
|
|
18
|
+
protected _parent: DataObjectClass<any> | undefined;
|
|
16
19
|
protected _name: string;
|
|
17
20
|
protected _value: any;
|
|
18
21
|
protected _mandatory: boolean;
|
|
19
22
|
protected _protected: boolean;
|
|
20
23
|
protected _allows: String[];
|
|
24
|
+
protected _htmlType: PropertyHTMLType;
|
|
21
25
|
protected _defaultValue: any;
|
|
22
26
|
protected _events: {
|
|
23
27
|
[key: EventTypes]: Function;
|
|
@@ -27,6 +31,8 @@ export declare class BaseProperty implements PropertyClassType {
|
|
|
27
31
|
get mandatory(): boolean;
|
|
28
32
|
get protected(): boolean;
|
|
29
33
|
get allows(): String[];
|
|
34
|
+
set htmlType(type: PropertyHTMLType);
|
|
35
|
+
get htmlType(): PropertyHTMLType;
|
|
30
36
|
set(value: any): this;
|
|
31
37
|
val(transform?: any): any;
|
|
32
38
|
protected _enable(value: boolean | undefined): boolean;
|