@quatrain/core 1.0.0-beta2 → 1.0.0-beta3
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/Auth.d.ts +25 -0
- package/lib/Auth.js +9 -0
- package/lib/Core.d.ts +4 -2
- package/lib/Core.js +1 -1
- package/lib/authentication/AbstractAuthAdapter.d.ts +21 -0
- package/lib/authentication/AbstractAuthAdapter.js +28 -0
- package/lib/authentication/AuthenticationError.d.ts +2 -0
- package/lib/authentication/AuthenticationError.js +6 -0
- package/lib/authentication/index.d.ts +4 -0
- package/lib/authentication/index.js +7 -0
- package/lib/authentication/middlewares/AbstractAuthMiddleware.d.ts +0 -0
- package/lib/authentication/middlewares/AbstractAuthMiddleware.js +1 -0
- package/lib/authentication/middlewares/Middleware.d.ts +5 -0
- package/lib/authentication/types/AuthInterface.d.ts +9 -0
- package/lib/backends/AbstractAdapter.d.ts +6 -0
- package/lib/backends/AbstractAdapter.js +18 -0
- package/lib/backends/middlewares/InjectMetaMiddleware.d.ts +3 -3
- package/lib/components/AbstractObject.d.ts +1 -1
- package/lib/components/DataObject.js +1 -0
- package/lib/components/Entity.d.ts +3 -3
- package/lib/components/Entity.js +6 -6
- package/lib/components/EntityRepository.d.ts +2 -2
- package/lib/components/EntityRepository.js +1 -1
- package/lib/components/ObjectUri.js +1 -2
- package/lib/components/User.d.ts +3 -3
- package/lib/components/User.js +16 -9
- package/lib/components/UserRepository.d.ts +3 -3
- package/lib/components/UserRepository.js +2 -2
- package/lib/components/index.d.ts +2 -2
- package/lib/components/index.js +4 -2
- package/lib/index.d.ts +4 -2
- package/lib/index.js +10 -1
- package/package.json +2 -2
- package/README.md +0 -124
- package/lib/backends/BackendInterface.d.ts +0 -13
- package/lib/backends/middlewares/InjectMetaMiddleware copy.d.ts +0 -12
- package/lib/backends/middlewares/InjectMetaMiddleware copy.js +0 -30
- package/lib/components/BaseObjectProperties.d.ts +0 -13
- package/lib/components/BaseObjectProperties.js +0 -87
- package/lib/components/EntityProperties.d.ts +0 -1
- package/lib/components/EntityProperties.js +0 -54
- package/lib/components/UserProperties.d.ts +0 -1
- package/lib/components/UserProperties.js +0 -103
- package/lib/components/types/UserClass.d.ts +0 -3
- /package/lib/{backends/BackendInterface.js → authentication/middlewares/Middleware.js} +0 -0
- /package/lib/{components/types/UserClass.js → authentication/types/AuthInterface.js} +0 -0
package/lib/Auth.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import Middleware from './authentication/middlewares/Middleware';
|
|
2
|
+
export declare enum AuthAction {
|
|
3
|
+
SIGNIN = "signin",
|
|
4
|
+
SIGNUP = "signup",
|
|
5
|
+
SIGNOUT = "signout"
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Authentication Parameters acceptable keys
|
|
9
|
+
*/
|
|
10
|
+
export type AuthParametersKeys = 'host' | 'alias' | 'mapping' | 'middlewares' | 'config' | 'fixtures' | 'debug';
|
|
11
|
+
/**
|
|
12
|
+
* Backend parameters interface
|
|
13
|
+
*/
|
|
14
|
+
export interface AuthParameters {
|
|
15
|
+
host?: string;
|
|
16
|
+
alias?: string;
|
|
17
|
+
mapping?: {
|
|
18
|
+
[x: string]: any;
|
|
19
|
+
};
|
|
20
|
+
middlewares?: Middleware[];
|
|
21
|
+
config?: any;
|
|
22
|
+
fixtures?: any;
|
|
23
|
+
softDelete?: boolean;
|
|
24
|
+
debug?: boolean;
|
|
25
|
+
}
|
package/lib/Auth.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AuthAction = void 0;
|
|
4
|
+
var AuthAction;
|
|
5
|
+
(function (AuthAction) {
|
|
6
|
+
AuthAction["SIGNIN"] = "signin";
|
|
7
|
+
AuthAction["SIGNUP"] = "signup";
|
|
8
|
+
AuthAction["SIGNOUT"] = "signout";
|
|
9
|
+
})(AuthAction || (exports.AuthAction = AuthAction = {}));
|
package/lib/Core.d.ts
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
|
+
import { AbstractAuthAdapter } from './authentication';
|
|
1
2
|
import { AbstractAdapter } from './backends/AbstractAdapter';
|
|
2
|
-
import {
|
|
3
|
+
import { User } from './components/User';
|
|
3
4
|
import { DataObjectClass } from './components/types/DataObjectClass';
|
|
4
5
|
export type BackendRegistry<T extends AbstractAdapter> = {
|
|
5
6
|
[x: string]: T;
|
|
6
7
|
};
|
|
7
8
|
export declare class Core {
|
|
8
9
|
static defaultBackend: string;
|
|
9
|
-
static userClass: typeof
|
|
10
|
+
static userClass: typeof User;
|
|
10
11
|
static classRegistry: {
|
|
11
12
|
[key: string]: any;
|
|
12
13
|
};
|
|
13
14
|
static logger: Console;
|
|
15
|
+
static auth: AbstractAuthAdapter;
|
|
14
16
|
static timestamp: () => string;
|
|
15
17
|
protected static _backends: BackendRegistry<any>;
|
|
16
18
|
static definition(key: string): {
|
package/lib/Core.js
CHANGED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { AuthParameters, AuthParametersKeys } from '../Auth';
|
|
2
|
+
import { User } from '../components/User';
|
|
3
|
+
import Middleware from './middlewares/Middleware';
|
|
4
|
+
import { AuthInterface } from './types/AuthInterface';
|
|
5
|
+
export declare abstract class AbstractAuthAdapter implements AuthInterface {
|
|
6
|
+
protected _alias: string;
|
|
7
|
+
protected _params: AuthParameters;
|
|
8
|
+
protected _middlewares: any[];
|
|
9
|
+
constructor(params?: AuthParameters);
|
|
10
|
+
setParam(key: AuthParametersKeys, value: any): void;
|
|
11
|
+
getParam(key: AuthParametersKeys): any;
|
|
12
|
+
addMiddleware(middleware: Middleware): void;
|
|
13
|
+
set alias(alias: string);
|
|
14
|
+
get alias(): string;
|
|
15
|
+
abstract register(user: User): Promise<any>;
|
|
16
|
+
abstract signup(login: string, password: string): Promise<any>;
|
|
17
|
+
abstract signout(user: User): Promise<any>;
|
|
18
|
+
abstract update(user: User, updatable: any): Promise<any>;
|
|
19
|
+
abstract delete(user: User): Promise<any>;
|
|
20
|
+
abstract getAuthToken(token: string): any;
|
|
21
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AbstractAuthAdapter = void 0;
|
|
4
|
+
class AbstractAuthAdapter {
|
|
5
|
+
constructor(params = {}) {
|
|
6
|
+
this._alias = '';
|
|
7
|
+
this._params = {};
|
|
8
|
+
this._middlewares = [];
|
|
9
|
+
this._alias = params.alias || '';
|
|
10
|
+
this._middlewares = params.middlewares || [];
|
|
11
|
+
}
|
|
12
|
+
setParam(key, value) {
|
|
13
|
+
this._params[key] = value;
|
|
14
|
+
}
|
|
15
|
+
getParam(key) {
|
|
16
|
+
return this._params[key];
|
|
17
|
+
}
|
|
18
|
+
addMiddleware(middleware) {
|
|
19
|
+
this._middlewares.push(middleware);
|
|
20
|
+
}
|
|
21
|
+
set alias(alias) {
|
|
22
|
+
this._alias = alias;
|
|
23
|
+
}
|
|
24
|
+
get alias() {
|
|
25
|
+
return this._alias;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
exports.AbstractAuthAdapter = AbstractAuthAdapter;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AuthenticationError = exports.AbstractAuthAdapter = void 0;
|
|
4
|
+
const AbstractAuthAdapter_1 = require("./AbstractAuthAdapter");
|
|
5
|
+
Object.defineProperty(exports, "AbstractAuthAdapter", { enumerable: true, get: function () { return AbstractAuthAdapter_1.AbstractAuthAdapter; } });
|
|
6
|
+
const AuthenticationError_1 = require("./AuthenticationError");
|
|
7
|
+
Object.defineProperty(exports, "AuthenticationError", { enumerable: true, get: function () { return AuthenticationError_1.AuthenticationError; } });
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { User } from '../../components/User';
|
|
2
|
+
export interface AuthInterface {
|
|
3
|
+
register(user: User): Promise<any>;
|
|
4
|
+
signup(login: string, password: string): Promise<any>;
|
|
5
|
+
signout(user: User): Promise<any>;
|
|
6
|
+
update(user: User, updatable: any): Promise<any>;
|
|
7
|
+
delete(user: User): Promise<any>;
|
|
8
|
+
getAuthToken(token: string): any;
|
|
9
|
+
}
|
|
@@ -14,6 +14,12 @@ export declare abstract class AbstractAdapter implements BackendInterface {
|
|
|
14
14
|
setParam(key: BackendParametersKeys, value: any): void;
|
|
15
15
|
getParam(key: BackendParametersKeys): any;
|
|
16
16
|
addMiddleware(middleware: Middleware): void;
|
|
17
|
+
/**
|
|
18
|
+
* Returns true if a given middleware is attached
|
|
19
|
+
* @param className
|
|
20
|
+
* @returns boolean
|
|
21
|
+
*/
|
|
22
|
+
hasMiddleware(className: string): boolean;
|
|
17
23
|
set alias(alias: string);
|
|
18
24
|
get alias(): string;
|
|
19
25
|
getCollection(dao: DataObjectClass<any>): string | undefined;
|
|
@@ -10,6 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.AbstractAdapter = void 0;
|
|
13
|
+
const BackendError_1 = require("./BackendError");
|
|
13
14
|
class AbstractAdapter {
|
|
14
15
|
constructor(params = {}) {
|
|
15
16
|
this._alias = '';
|
|
@@ -25,8 +26,25 @@ class AbstractAdapter {
|
|
|
25
26
|
return this._params[key];
|
|
26
27
|
}
|
|
27
28
|
addMiddleware(middleware) {
|
|
29
|
+
if (this.hasMiddleware(middleware.constructor.name)) {
|
|
30
|
+
throw new BackendError_1.BackendError(`Middleware '${middleware.constructor.name}' is already attached`);
|
|
31
|
+
}
|
|
28
32
|
this._middlewares.push(middleware);
|
|
29
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* Returns true if a given middleware is attached
|
|
36
|
+
* @param className
|
|
37
|
+
* @returns boolean
|
|
38
|
+
*/
|
|
39
|
+
hasMiddleware(className) {
|
|
40
|
+
let has = false;
|
|
41
|
+
this._middlewares.forEach((middleware) => {
|
|
42
|
+
if (middleware.constructor.name === className) {
|
|
43
|
+
has = true;
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
return has;
|
|
47
|
+
}
|
|
30
48
|
set alias(alias) {
|
|
31
49
|
this._alias = alias;
|
|
32
50
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { DataObjectClass } from '../../components';
|
|
2
2
|
import { BackendAction } from '../../Backend';
|
|
3
|
-
import {
|
|
3
|
+
import { User } from '../../components/User';
|
|
4
4
|
import Middleware from './Middleware';
|
|
5
5
|
export interface InjectMetaMiddlewareParams {
|
|
6
|
-
user:
|
|
6
|
+
user: User;
|
|
7
7
|
}
|
|
8
8
|
export declare class InjectMetaMiddleware implements Middleware {
|
|
9
|
-
protected _user:
|
|
9
|
+
protected _user: User;
|
|
10
10
|
constructor(params: InjectMetaMiddlewareParams);
|
|
11
11
|
execute(dataObject: DataObjectClass<any>, action: BackendAction): void;
|
|
12
12
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DataObjectClass } from './types/DataObjectClass';
|
|
2
|
-
import { DataObjectProperties } from '../properties
|
|
2
|
+
import { DataObjectProperties } from '../properties';
|
|
3
3
|
export declare abstract class AbstractObject {
|
|
4
4
|
static PROPS_DEFINITION: DataObjectProperties;
|
|
5
5
|
static COLLECTION: string | undefined;
|
|
@@ -242,6 +242,7 @@ class DataObject {
|
|
|
242
242
|
break;
|
|
243
243
|
case 'ObjectProperty':
|
|
244
244
|
const value = prop.val();
|
|
245
|
+
console.log(value, typeof value);
|
|
245
246
|
Reflect.set(data, key, value
|
|
246
247
|
? objectsAsReferences && !(value instanceof ObjectUri_1.ObjectUri)
|
|
247
248
|
? value.asReference()
|
|
@@ -3,10 +3,10 @@ import { BaseObject } from './BaseObject';
|
|
|
3
3
|
import { User } from './User';
|
|
4
4
|
import { EntityClass } from './types/EntityClass';
|
|
5
5
|
export declare const EntityProperties: any;
|
|
6
|
-
export interface
|
|
7
|
-
users
|
|
6
|
+
export interface EntityType extends BaseObject {
|
|
7
|
+
users?: User[];
|
|
8
8
|
}
|
|
9
|
-
export declare class
|
|
9
|
+
export declare class Entity extends BaseObjectCore implements EntityClass {
|
|
10
10
|
static COLLECTION: string;
|
|
11
11
|
static PROPS_DEFINITION: any[];
|
|
12
12
|
}
|
package/lib/components/Entity.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.
|
|
26
|
+
exports.Entity = exports.EntityProperties = void 0;
|
|
27
27
|
const BaseObjectCore_1 = require("./BaseObjectCore");
|
|
28
28
|
const BaseObject_1 = require("./BaseObject");
|
|
29
29
|
const User_1 = require("./User");
|
|
@@ -47,11 +47,11 @@ exports.EntityProperties = [
|
|
|
47
47
|
parentKey: 'entity',
|
|
48
48
|
},
|
|
49
49
|
];
|
|
50
|
-
class
|
|
50
|
+
class Entity extends BaseObjectCore_1.BaseObjectCore {
|
|
51
51
|
}
|
|
52
|
-
exports.
|
|
53
|
-
|
|
54
|
-
|
|
52
|
+
exports.Entity = Entity;
|
|
53
|
+
Entity.COLLECTION = 'entities';
|
|
54
|
+
Entity.PROPS_DEFINITION = [
|
|
55
55
|
...BaseObject_1.BaseObjectProperties,
|
|
56
56
|
{
|
|
57
57
|
// surcharge property minLength and htmlType
|
|
@@ -65,7 +65,7 @@ EntityCore.PROPS_DEFINITION = [
|
|
|
65
65
|
name: 'users',
|
|
66
66
|
mandatory: true,
|
|
67
67
|
type: CollectionProperty_1.CollectionProperty.TYPE,
|
|
68
|
-
instanceOf: User_1.
|
|
68
|
+
instanceOf: User_1.User,
|
|
69
69
|
parentKey: 'entity',
|
|
70
70
|
},
|
|
71
71
|
];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BackendInterface } from '../backends/types/BackendInterface';
|
|
2
2
|
import BaseRepository from './BaseRepository';
|
|
3
|
-
import {
|
|
4
|
-
export default class EntityRepository extends BaseRepository<
|
|
3
|
+
import { EntityType } from './Entity';
|
|
4
|
+
export default class EntityRepository extends BaseRepository<EntityType> {
|
|
5
5
|
constructor(backendAdapter?: BackendInterface);
|
|
6
6
|
}
|
|
@@ -8,7 +8,7 @@ const BaseRepository_1 = __importDefault(require("./BaseRepository"));
|
|
|
8
8
|
const Entity_1 = require("./Entity");
|
|
9
9
|
class EntityRepository extends BaseRepository_1.default {
|
|
10
10
|
constructor(backendAdapter = Core_1.Core.getBackend()) {
|
|
11
|
-
super(Entity_1.
|
|
11
|
+
super(Entity_1.Entity, backendAdapter);
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
14
|
exports.default = EntityRepository;
|
|
@@ -52,10 +52,9 @@ class ObjectUri {
|
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
set class(objClass) {
|
|
55
|
-
var _a;
|
|
56
55
|
this._objClass = objClass;
|
|
57
56
|
if (objClass) {
|
|
58
|
-
this._collection = objClass.COLLECTION ||
|
|
57
|
+
this._collection = objClass.COLLECTION || objClass.name && objClass.name.toLowerCase();
|
|
59
58
|
}
|
|
60
59
|
else {
|
|
61
60
|
this._collection = undefined;
|
package/lib/components/User.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BaseObjectCore } from './BaseObjectCore';
|
|
2
2
|
import { BaseObject } from './BaseObject';
|
|
3
|
-
export interface
|
|
3
|
+
export interface UserType extends BaseObject {
|
|
4
4
|
name: string;
|
|
5
5
|
firstname: string;
|
|
6
6
|
lastname: string;
|
|
@@ -10,8 +10,8 @@ export interface User extends BaseObject {
|
|
|
10
10
|
email: string;
|
|
11
11
|
}
|
|
12
12
|
export declare const UserProperties: any;
|
|
13
|
-
export declare class
|
|
13
|
+
export declare class User extends BaseObjectCore {
|
|
14
14
|
static PROPS_DEFINITION: any;
|
|
15
15
|
static COLLECTION: string;
|
|
16
|
-
static factory(src?: any): Promise<
|
|
16
|
+
static factory(src?: any): Promise<User>;
|
|
17
17
|
}
|
package/lib/components/User.js
CHANGED
|
@@ -32,7 +32,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
32
32
|
});
|
|
33
33
|
};
|
|
34
34
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
-
exports.
|
|
35
|
+
exports.User = exports.UserProperties = void 0;
|
|
36
36
|
const BaseObjectCore_1 = require("./BaseObjectCore");
|
|
37
37
|
const properties_1 = require("../properties");
|
|
38
38
|
const HashProperty_1 = require("../properties/HashProperty");
|
|
@@ -97,33 +97,40 @@ exports.UserProperties = [
|
|
|
97
97
|
fullSearch: true,
|
|
98
98
|
htmlType: htmlType.EMAIL,
|
|
99
99
|
},
|
|
100
|
+
{
|
|
101
|
+
name: 'phone',
|
|
102
|
+
type: StringProperty_1.StringProperty.TYPE,
|
|
103
|
+
minLength: 1,
|
|
104
|
+
maxLength: 100,
|
|
105
|
+
htmlType: htmlType.OFF,
|
|
106
|
+
},
|
|
100
107
|
{
|
|
101
108
|
name: 'password',
|
|
102
109
|
mandatory: true,
|
|
103
110
|
type: HashProperty_1.HashProperty.TYPE,
|
|
104
111
|
algorithm: HashProperty_1.HashProperty.ALGORITHM_SHA256,
|
|
105
|
-
salt: '',
|
|
112
|
+
salt: '', // you should override it in your code
|
|
106
113
|
minLength: 5,
|
|
107
|
-
maxLength: 20,
|
|
114
|
+
maxLength: 20, // this is for the clear password
|
|
108
115
|
htmlType: htmlType.PASSWORD,
|
|
109
116
|
},
|
|
110
117
|
{
|
|
111
118
|
name: 'entity',
|
|
112
119
|
mandatory: false,
|
|
113
120
|
type: properties_1.ObjectProperty.TYPE,
|
|
114
|
-
instanceOf: Entity_1.
|
|
121
|
+
instanceOf: Entity_1.Entity,
|
|
115
122
|
},
|
|
116
123
|
];
|
|
117
|
-
class
|
|
124
|
+
class User extends BaseObjectCore_1.BaseObjectCore {
|
|
118
125
|
static factory(src = undefined) {
|
|
119
126
|
const _super = Object.create(null, {
|
|
120
127
|
factory: { get: () => super.factory }
|
|
121
128
|
});
|
|
122
129
|
return __awaiter(this, void 0, void 0, function* () {
|
|
123
|
-
return _super.factory.call(this, src,
|
|
130
|
+
return _super.factory.call(this, src, User);
|
|
124
131
|
});
|
|
125
132
|
}
|
|
126
133
|
}
|
|
127
|
-
exports.
|
|
128
|
-
|
|
129
|
-
|
|
134
|
+
exports.User = User;
|
|
135
|
+
User.PROPS_DEFINITION = exports.UserProperties;
|
|
136
|
+
User.COLLECTION = 'user';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { BackendInterface } from '../backends/types/BackendInterface';
|
|
2
2
|
import BaseRepository from './BaseRepository';
|
|
3
|
-
import {
|
|
4
|
-
export default class UserRepository extends BaseRepository<
|
|
3
|
+
import { UserType } from './User';
|
|
4
|
+
export default class UserRepository extends BaseRepository<UserType> {
|
|
5
5
|
constructor(backendAdapter?: BackendInterface);
|
|
6
|
-
getFromEmail(email: string): Promise<
|
|
6
|
+
getFromEmail(email: string): Promise<UserType>;
|
|
7
7
|
}
|
|
@@ -19,11 +19,11 @@ const User_1 = require("./User");
|
|
|
19
19
|
const UNAUTHORIZED_ERROR = `Wrong password or email`;
|
|
20
20
|
class UserRepository extends BaseRepository_1.default {
|
|
21
21
|
constructor(backendAdapter) {
|
|
22
|
-
super(User_1.
|
|
22
|
+
super(User_1.User, backendAdapter);
|
|
23
23
|
}
|
|
24
24
|
getFromEmail(email) {
|
|
25
25
|
return __awaiter(this, void 0, void 0, function* () {
|
|
26
|
-
const query = new backends_1.Query(User_1.
|
|
26
|
+
const query = new backends_1.Query(User_1.User);
|
|
27
27
|
query.where('email', email).batch(1);
|
|
28
28
|
const { items } = yield this.query(query);
|
|
29
29
|
if (items.length == 0) {
|
|
@@ -5,6 +5,6 @@ import { AbstractObject } from './AbstractObject';
|
|
|
5
5
|
import { BaseObjectCore } from './BaseObjectCore';
|
|
6
6
|
import { BaseObjectProperties } from './BaseObject';
|
|
7
7
|
import BaseRepository from './BaseRepository';
|
|
8
|
-
import {
|
|
8
|
+
import { User, UserProperties } from './User';
|
|
9
9
|
import { Entity } from './Entity';
|
|
10
|
-
export { DataObject, DataObjectParams, DataObjectClass, ObjectUri, AbstractObject, BaseObjectCore, BaseRepository,
|
|
10
|
+
export { DataObject, DataObjectParams, DataObjectClass, ObjectUri, AbstractObject, BaseObjectCore, BaseRepository, User, Entity, BaseObjectProperties, UserProperties, };
|
package/lib/components/index.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.UserProperties = exports.BaseObjectProperties = exports.
|
|
6
|
+
exports.UserProperties = exports.BaseObjectProperties = exports.Entity = exports.User = exports.BaseRepository = exports.BaseObjectCore = exports.AbstractObject = exports.ObjectUri = exports.DataObject = void 0;
|
|
7
7
|
const DataObject_1 = require("./DataObject");
|
|
8
8
|
Object.defineProperty(exports, "DataObject", { enumerable: true, get: function () { return DataObject_1.DataObject; } });
|
|
9
9
|
const ObjectUri_1 = require("./ObjectUri");
|
|
@@ -17,5 +17,7 @@ Object.defineProperty(exports, "BaseObjectProperties", { enumerable: true, get:
|
|
|
17
17
|
const BaseRepository_1 = __importDefault(require("./BaseRepository"));
|
|
18
18
|
exports.BaseRepository = BaseRepository_1.default;
|
|
19
19
|
const User_1 = require("./User");
|
|
20
|
-
Object.defineProperty(exports, "
|
|
20
|
+
Object.defineProperty(exports, "User", { enumerable: true, get: function () { return User_1.User; } });
|
|
21
21
|
Object.defineProperty(exports, "UserProperties", { enumerable: true, get: function () { return User_1.UserProperties; } });
|
|
22
|
+
const Entity_1 = require("./Entity");
|
|
23
|
+
Object.defineProperty(exports, "Entity", { enumerable: true, get: function () { return Entity_1.Entity; } });
|
package/lib/index.d.ts
CHANGED
|
@@ -22,10 +22,12 @@ import RepositoryClass from './components/types/RepositoryClass';
|
|
|
22
22
|
import BaseRepository from './components/BaseRepository';
|
|
23
23
|
import { BackendAction, BackendParameters, BackendParametersKeys, BackendRecordType } from './Backend';
|
|
24
24
|
import Middleware from './backends/middlewares/Middleware';
|
|
25
|
-
import { User } from './components/User';
|
|
25
|
+
import { UserType, User } from './components/User';
|
|
26
26
|
import UserRepository from './components/UserRepository';
|
|
27
27
|
import { Entity } from './components/Entity';
|
|
28
28
|
import EntityRepository from './components/EntityRepository';
|
|
29
|
+
import { AuthAction, AuthParameters, AuthParametersKeys } from './Auth';
|
|
30
|
+
import { AuthInterface, AbstractAuthAdapter, AuthenticationError } from './authentication';
|
|
29
31
|
import { AbstractAdapter, MockAdapter, BackendError, Query, QueryMetaType, QueryResultType, Filter, Filters, Limits, Sorting, SortAndLimit } from './backends';
|
|
30
32
|
import { BadRequestError, UnauthorizedError, ForbiddenError, NotFoundError, GoneError } from './common/ResourcesErrors';
|
|
31
|
-
export { statuses, utils, Core, Property, BaseProperty, BasePropertyType, BooleanProperty, BooleanPropertyType, DateTimeProperty, DateTimePropertyType, EnumProperty, EnumPropertyType, HashProperty, HashPropertyType, ObjectProperty, ObjectPropertyType, StringProperty, StringPropertyType, AbstractAdapter, RepositoryClass, MockAdapter, ObjectUri, DataObjectClass, DataObject, AbstractObject, BaseObject, BaseObjectCore, BaseObjectProperties, BackendParameters, BackendParametersKeys, BackendRecordType, BackendAction, BaseRepository, BackendError, Query, QueryMetaType, QueryResultType, Filter, Filters, Limits, Sorting, SortAndLimit, Middleware, InjectMetaMiddleware, InjectKeywordsMiddleware, User, Proxy, UserRepository, Entity, EntityRepository, BadRequestError, UnauthorizedError, ForbiddenError, NotFoundError, GoneError, };
|
|
33
|
+
export { statuses, utils, Core, Property, BaseProperty, BasePropertyType, BooleanProperty, BooleanPropertyType, DateTimeProperty, DateTimePropertyType, EnumProperty, EnumPropertyType, HashProperty, HashPropertyType, ObjectProperty, ObjectPropertyType, StringProperty, StringPropertyType, AbstractAdapter, RepositoryClass, MockAdapter, ObjectUri, DataObjectClass, DataObject, AbstractObject, BaseObject, BaseObjectCore, BaseObjectProperties, AuthAction, AuthParameters, AuthParametersKeys, AuthInterface, AbstractAuthAdapter, AuthenticationError, BackendParameters, BackendParametersKeys, BackendRecordType, BackendAction, BaseRepository, BackendError, Query, QueryMetaType, QueryResultType, Filter, Filters, Limits, Sorting, SortAndLimit, Middleware, InjectMetaMiddleware, InjectKeywordsMiddleware, User, UserType, Proxy, UserRepository, Entity, EntityRepository, BadRequestError, UnauthorizedError, ForbiddenError, NotFoundError, GoneError, };
|
package/lib/index.js
CHANGED
|
@@ -26,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.GoneError = exports.NotFoundError = exports.ForbiddenError = exports.UnauthorizedError = exports.BadRequestError = exports.EntityRepository = exports.UserRepository = exports.InjectKeywordsMiddleware = exports.InjectMetaMiddleware = exports.SortAndLimit = exports.Sorting = exports.Limits = exports.Filters = exports.Filter = exports.Query = exports.BackendError = exports.BaseRepository = exports.BackendAction = exports.BaseObjectProperties = exports.BaseObjectCore = 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;
|
|
29
|
+
exports.GoneError = exports.NotFoundError = exports.ForbiddenError = exports.UnauthorizedError = exports.BadRequestError = exports.EntityRepository = exports.Entity = exports.UserRepository = exports.User = exports.InjectKeywordsMiddleware = exports.InjectMetaMiddleware = exports.SortAndLimit = exports.Sorting = exports.Limits = exports.Filters = exports.Filter = exports.Query = exports.BackendError = exports.BaseRepository = exports.BackendAction = exports.AuthenticationError = exports.AbstractAuthAdapter = exports.AuthAction = exports.BaseObjectProperties = exports.BaseObjectCore = 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;
|
|
30
30
|
const Core_1 = require("./Core");
|
|
31
31
|
Object.defineProperty(exports, "Core", { enumerable: true, get: function () { return Core_1.Core; } });
|
|
32
32
|
const statuses = __importStar(require("./common/statuses"));
|
|
@@ -67,10 +67,19 @@ const BaseRepository_1 = __importDefault(require("./components/BaseRepository"))
|
|
|
67
67
|
exports.BaseRepository = BaseRepository_1.default;
|
|
68
68
|
const Backend_1 = require("./Backend");
|
|
69
69
|
Object.defineProperty(exports, "BackendAction", { enumerable: true, get: function () { return Backend_1.BackendAction; } });
|
|
70
|
+
const User_1 = require("./components/User");
|
|
71
|
+
Object.defineProperty(exports, "User", { enumerable: true, get: function () { return User_1.User; } });
|
|
70
72
|
const UserRepository_1 = __importDefault(require("./components/UserRepository"));
|
|
71
73
|
exports.UserRepository = UserRepository_1.default;
|
|
74
|
+
const Entity_1 = require("./components/Entity");
|
|
75
|
+
Object.defineProperty(exports, "Entity", { enumerable: true, get: function () { return Entity_1.Entity; } });
|
|
72
76
|
const EntityRepository_1 = __importDefault(require("./components/EntityRepository"));
|
|
73
77
|
exports.EntityRepository = EntityRepository_1.default;
|
|
78
|
+
const Auth_1 = require("./Auth");
|
|
79
|
+
Object.defineProperty(exports, "AuthAction", { enumerable: true, get: function () { return Auth_1.AuthAction; } });
|
|
80
|
+
const authentication_1 = require("./authentication");
|
|
81
|
+
Object.defineProperty(exports, "AbstractAuthAdapter", { enumerable: true, get: function () { return authentication_1.AbstractAuthAdapter; } });
|
|
82
|
+
Object.defineProperty(exports, "AuthenticationError", { enumerable: true, get: function () { return authentication_1.AuthenticationError; } });
|
|
74
83
|
const backends_1 = require("./backends");
|
|
75
84
|
Object.defineProperty(exports, "AbstractAdapter", { enumerable: true, get: function () { return backends_1.AbstractAdapter; } });
|
|
76
85
|
Object.defineProperty(exports, "MockAdapter", { enumerable: true, get: function () { return backends_1.MockAdapter; } });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quatrain/core",
|
|
3
|
-
"version": "1.0.0-
|
|
3
|
+
"version": "1.0.0-beta3",
|
|
4
4
|
"description": "Core objects for business apps",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -30,4 +30,4 @@
|
|
|
30
30
|
"push": "yarn publish --access public",
|
|
31
31
|
"prepublish": "tsc"
|
|
32
32
|
}
|
|
33
|
-
}
|
|
33
|
+
}
|
package/README.md
DELETED
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
# Quatrain Core
|
|
2
|
-
|
|
3
|
-
## Why
|
|
4
|
-
|
|
5
|
-
Quatrain Core is an abstraction layer designed to accelerate and simplify the development
|
|
6
|
-
of applications using many models and various data stores, being database or APIs.
|
|
7
|
-
|
|
8
|
-
With Quatrain Core and peer packages, one may develop robust applications based on
|
|
9
|
-
Oriented Object Programming with a clear separation of concerns between logic, data
|
|
10
|
-
and storage.
|
|
11
|
-
|
|
12
|
-
## How to install
|
|
13
|
-
|
|
14
|
-
```bash
|
|
15
|
-
yarn install @quatrain/core
|
|
16
|
-
```
|
|
17
|
-
|
|
18
|
-
Quatrain Core comes with a built-in Mock backend adapter. Other adapters are available in
|
|
19
|
-
different packages. For example, a Google Firestore adapter is available:
|
|
20
|
-
|
|
21
|
-
```bash
|
|
22
|
-
yarn install @quatrain/backend-firestore
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
## How to use
|
|
26
|
-
|
|
27
|
-
### Setup
|
|
28
|
-
|
|
29
|
-
```ts
|
|
30
|
-
import { Core } from '@quatrain/core'
|
|
31
|
-
|
|
32
|
-
Core.addBackend(myAdapter, 'myDB', true)
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
### Create a model
|
|
36
|
-
|
|
37
|
-
```ts
|
|
38
|
-
import { BaseObjectCore } from '@quatrain/core'
|
|
39
|
-
|
|
40
|
-
export type Cat = {
|
|
41
|
-
name: string
|
|
42
|
-
color: `#${string}`
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export class CatCore extends BaseObjectCore {
|
|
46
|
-
static COLLECTION = 'cats'
|
|
47
|
-
|
|
48
|
-
static PROPERTIES = [
|
|
49
|
-
{
|
|
50
|
-
name: 'name',
|
|
51
|
-
type: Property.STRING,
|
|
52
|
-
minLength: 1,
|
|
53
|
-
maxLength: 32,
|
|
54
|
-
},
|
|
55
|
-
{
|
|
56
|
-
name: 'color',
|
|
57
|
-
type: Property.STRING,
|
|
58
|
-
minLength: 4,
|
|
59
|
-
maxLength: 7,
|
|
60
|
-
},
|
|
61
|
-
]
|
|
62
|
-
}
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
### Instantiate a model
|
|
66
|
-
|
|
67
|
-
```ts
|
|
68
|
-
const catData: Cat = {
|
|
69
|
-
name: 'Garfield',
|
|
70
|
-
color: '#ffa502',
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
const garfield = CatCore.fromObject(catData)
|
|
74
|
-
|
|
75
|
-
console.log(garfield.name)
|
|
76
|
-
// > "Garfield"
|
|
77
|
-
console.log(garfield.color)
|
|
78
|
-
// > "#ffa502"
|
|
79
|
-
console.log(garfield.core)
|
|
80
|
-
// > CatCore { ... }
|
|
81
|
-
```
|
|
82
|
-
|
|
83
|
-
### Interact with backend
|
|
84
|
-
|
|
85
|
-
```ts
|
|
86
|
-
// Let's save Garfield in our database
|
|
87
|
-
garfield.core.save()
|
|
88
|
-
|
|
89
|
-
// Now, let's retrieve Garfield in the database
|
|
90
|
-
const persistedGarfield = await CatCore.fromBackend('garfield')
|
|
91
|
-
```
|
|
92
|
-
|
|
93
|
-
### Using repositories
|
|
94
|
-
|
|
95
|
-
You can use repositories as an alternative way to persist and retrieve models in your backend.
|
|
96
|
-
|
|
97
|
-
This module provides a BaseRepository class that you can extend and override to apply your business logic when doing backend operations.
|
|
98
|
-
|
|
99
|
-
Let's create a repository for our Cat model, that prevents us from deleting a cat.
|
|
100
|
-
|
|
101
|
-
```ts
|
|
102
|
-
import { Core, BackendInterface, BaseRepository } from '@quatrain/core'
|
|
103
|
-
|
|
104
|
-
export default class CatRepository extends BaseRepository<Cat> {
|
|
105
|
-
constructor(backendAdapter: BackendInterface = Core.getBackend()) {
|
|
106
|
-
super(CatCore, backendAdapter)
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
async delete(uid: string) {
|
|
110
|
-
throw Error("Don't delete the cats!")
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
```
|
|
114
|
-
|
|
115
|
-
Now, let's use our new CatRepository.
|
|
116
|
-
|
|
117
|
-
```ts
|
|
118
|
-
const repository = new CatRepository()
|
|
119
|
-
|
|
120
|
-
repository.create(garfield)
|
|
121
|
-
repository.read('garfield')
|
|
122
|
-
repository.update(persistedGarfield)
|
|
123
|
-
repository.delete('garfield') // Will throw "Don't delete the cats!"
|
|
124
|
-
```
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { DataObjectClass } from '../components';
|
|
2
|
-
import { Filter } from './Filter';
|
|
3
|
-
import { Filters } from './Filters';
|
|
4
|
-
import { Query, QueryResultType } from './Query';
|
|
5
|
-
import { SortAndLimit } from './SortAndLimit';
|
|
6
|
-
export interface BackendInterface {
|
|
7
|
-
create(dataObject: DataObjectClass<any>, desiredUid: string | undefined): Promise<DataObjectClass<any>>;
|
|
8
|
-
read(param: string | DataObjectClass<any>): Promise<DataObjectClass<any>>;
|
|
9
|
-
update(dataObject: DataObjectClass<any>): Promise<DataObjectClass<any>>;
|
|
10
|
-
delete(dataObject: DataObjectClass<any>): Promise<DataObjectClass<any>>;
|
|
11
|
-
query(query: Query<any>): Promise<QueryResultType<DataObjectClass<any>>>;
|
|
12
|
-
find(dataObject: DataObjectClass<any>, filters: Filters | Filter[] | undefined, pagination: SortAndLimit | undefined): Promise<QueryResultType<DataObjectClass<any>>>;
|
|
13
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { DataObjectClass } from '../../components';
|
|
2
|
-
import { BackendAction } from '../../Backend';
|
|
3
|
-
import { UserCore } from '../../components/User';
|
|
4
|
-
import Middleware from './Middleware';
|
|
5
|
-
export interface InjectMetaMiddlewareParams {
|
|
6
|
-
user: UserCore;
|
|
7
|
-
}
|
|
8
|
-
export declare class InjectMetaMiddleware implements Middleware {
|
|
9
|
-
protected _user: UserCore;
|
|
10
|
-
constructor(params: InjectMetaMiddlewareParams);
|
|
11
|
-
execute(dataObject: DataObjectClass<any>, action: BackendAction): void;
|
|
12
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.InjectMetaMiddleware = void 0;
|
|
4
|
-
const Backend_1 = require("../../Backend");
|
|
5
|
-
class InjectMetaMiddleware {
|
|
6
|
-
constructor(params) {
|
|
7
|
-
this._user = params.user;
|
|
8
|
-
}
|
|
9
|
-
execute(dataObject, action) {
|
|
10
|
-
switch (action) {
|
|
11
|
-
// add properties existence validation
|
|
12
|
-
case Backend_1.BackendAction.CREATE:
|
|
13
|
-
dataObject.set('createdBy', this._user);
|
|
14
|
-
dataObject.set('createdAt', Date.now());
|
|
15
|
-
break;
|
|
16
|
-
case Backend_1.BackendAction.UPDATE:
|
|
17
|
-
dataObject.set('updatedBy', this._user);
|
|
18
|
-
dataObject.set('updatedAt', Date.now());
|
|
19
|
-
break;
|
|
20
|
-
case Backend_1.BackendAction.DELETE:
|
|
21
|
-
dataObject.set('deletedBy', this._user);
|
|
22
|
-
dataObject.set('deletedAt', Date.now());
|
|
23
|
-
break;
|
|
24
|
-
default:
|
|
25
|
-
break;
|
|
26
|
-
}
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
exports.InjectMetaMiddleware = InjectMetaMiddleware;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { UserClass } from './types/UserClass';
|
|
2
|
-
import { ObjectUri } from './ObjectUri';
|
|
3
|
-
export interface BaseObjectType {
|
|
4
|
-
name: string;
|
|
5
|
-
status: string;
|
|
6
|
-
createdBy?: UserClass | ObjectUri;
|
|
7
|
-
createdAt?: number;
|
|
8
|
-
updatedBy?: UserClass | ObjectUri;
|
|
9
|
-
updatedAt?: number;
|
|
10
|
-
deletedBy?: UserClass | ObjectUri;
|
|
11
|
-
deletedAt?: number;
|
|
12
|
-
}
|
|
13
|
-
export declare const BaseObjectProperties: any;
|
|
@@ -1,87 +0,0 @@
|
|
|
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
|
-
htmlType: htmlType.NAME,
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
name: 'status',
|
|
44
|
-
mandatory: true,
|
|
45
|
-
type: EnumProperty_1.EnumProperty.TYPE,
|
|
46
|
-
values: [
|
|
47
|
-
statuses.CREATED,
|
|
48
|
-
statuses.PENDING,
|
|
49
|
-
statuses.ACTIVE,
|
|
50
|
-
statuses.DELETED,
|
|
51
|
-
],
|
|
52
|
-
defaultValue: statuses.CREATED,
|
|
53
|
-
},
|
|
54
|
-
{
|
|
55
|
-
name: 'createdBy',
|
|
56
|
-
type: ObjectProperty_1.ObjectProperty.TYPE,
|
|
57
|
-
instanceOf: 'User',
|
|
58
|
-
mandatory: true,
|
|
59
|
-
protected: true,
|
|
60
|
-
},
|
|
61
|
-
{
|
|
62
|
-
name: 'createdAt',
|
|
63
|
-
type: DateTimeProperty_1.DateTimeProperty.TYPE,
|
|
64
|
-
mandatory: true,
|
|
65
|
-
protected: true,
|
|
66
|
-
},
|
|
67
|
-
{
|
|
68
|
-
name: 'updatedBy',
|
|
69
|
-
type: ObjectProperty_1.ObjectProperty.TYPE,
|
|
70
|
-
instanceOf: 'User',
|
|
71
|
-
},
|
|
72
|
-
{
|
|
73
|
-
name: 'updatedAt',
|
|
74
|
-
type: DateTimeProperty_1.DateTimeProperty.TYPE,
|
|
75
|
-
},
|
|
76
|
-
{
|
|
77
|
-
name: 'deletedBy',
|
|
78
|
-
type: ObjectProperty_1.ObjectProperty.TYPE,
|
|
79
|
-
instanceOf: 'User',
|
|
80
|
-
protected: true,
|
|
81
|
-
},
|
|
82
|
-
{
|
|
83
|
-
name: 'deletedAt',
|
|
84
|
-
type: DateTimeProperty_1.DateTimeProperty.TYPE,
|
|
85
|
-
protected: true,
|
|
86
|
-
},
|
|
87
|
-
];
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const EntityProperties: any;
|
|
@@ -1,54 +0,0 @@
|
|
|
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 CollectionProperty_1 = require("../properties/CollectionProperty");
|
|
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: 'bogus',
|
|
42
|
-
type: StringProperty_1.StringProperty.TYPE,
|
|
43
|
-
mandatory: true,
|
|
44
|
-
minLength: 1,
|
|
45
|
-
htmlType: htmlType.ORG,
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
name: 'users',
|
|
49
|
-
mandatory: true,
|
|
50
|
-
type: CollectionProperty_1.CollectionProperty.TYPE,
|
|
51
|
-
instanceOf: User_1.User,
|
|
52
|
-
parentKey: 'entity',
|
|
53
|
-
},
|
|
54
|
-
];
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const UserProperties: any;
|
|
@@ -1,103 +0,0 @@
|
|
|
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
|
-
];
|
|
File without changes
|
|
File without changes
|