@quatrain/core 0.4.3 → 0.5.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.
Files changed (73) hide show
  1. package/lib/Backend.d.ts +6 -5
  2. package/lib/Backend.js +17 -5
  3. package/lib/Core.d.ts +3 -3
  4. package/lib/backends/AbstractAdapter.d.ts +11 -6
  5. package/lib/backends/AbstractAdapter.js +13 -3
  6. package/lib/backends/Filter.d.ts +2 -2
  7. package/lib/backends/FilterOperators.d.ts +1 -1
  8. package/lib/backends/FilterOperators.js +1 -1
  9. package/lib/backends/MockAdapter.js +13 -5
  10. package/lib/backends/Query.d.ts +9 -3
  11. package/lib/backends/Query.js +26 -6
  12. package/lib/backends/middlewares/InjectMetaMiddleware.d.ts +7 -6
  13. package/lib/backends/middlewares/InjectMetaMiddleware.js +8 -28
  14. package/lib/backends/middlewares/Middleware.d.ts +5 -0
  15. package/lib/common/ResourcesErrors.d.ts +13 -0
  16. package/lib/common/ResourcesErrors.js +25 -0
  17. package/lib/components/AbstractObject.d.ts +1 -3
  18. package/lib/components/AbstractObject.js +2 -6
  19. package/lib/components/BaseObject.d.ts +11 -13
  20. package/lib/components/BaseObject.js +84 -78
  21. package/lib/components/BaseObjectCore.d.ts +60 -0
  22. package/lib/components/BaseObjectCore.js +153 -0
  23. package/lib/components/BaseRepository.d.ts +24 -0
  24. package/lib/components/BaseRepository.js +116 -0
  25. package/lib/components/DataObject.d.ts +21 -6
  26. package/lib/components/DataObject.js +63 -28
  27. package/lib/components/Entity.d.ts +22 -3
  28. package/lib/components/Entity.js +23 -22
  29. package/lib/components/EntityRepository.d.ts +6 -0
  30. package/lib/components/EntityRepository.js +14 -0
  31. package/lib/components/ObjectUri.js +3 -3
  32. package/lib/components/User.d.ts +14 -3
  33. package/lib/components/User.js +10 -8
  34. package/lib/components/UserRepository.d.ts +7 -0
  35. package/lib/components/UserRepository.js +36 -0
  36. package/lib/components/index.d.ts +4 -5
  37. package/lib/components/index.js +6 -9
  38. package/lib/components/types/AbstractObjectClass.d.ts +1 -1
  39. package/lib/components/types/BaseObjectClass.d.ts +3 -2
  40. package/lib/components/types/DataObjectClass.d.ts +4 -1
  41. package/lib/components/types/Payload.d.ts +10 -0
  42. package/lib/components/types/Payload.js +2 -0
  43. package/lib/components/types/Persisted.d.ts +6 -0
  44. package/lib/components/types/Persisted.js +2 -0
  45. package/lib/components/types/Properties.d.ts +3 -0
  46. package/lib/components/types/Properties.js +1 -0
  47. package/lib/components/types/ProxyConstructor.d.ts +10 -0
  48. package/lib/components/types/ProxyConstructor.js +4 -0
  49. package/lib/components/types/RepositoryClass.d.ts +40 -0
  50. package/lib/components/types/RepositoryClass.js +2 -0
  51. package/lib/index.d.ts +11 -3
  52. package/lib/index.js +21 -8
  53. package/lib/properties/BaseProperty.d.ts +2 -1
  54. package/lib/properties/BaseProperty.js +5 -1
  55. package/lib/properties/CollectionProperty.d.ts +4 -3
  56. package/lib/properties/HashProperty.d.ts +1 -1
  57. package/lib/properties/NumberProperty.d.ts +2 -2
  58. package/lib/properties/ObjectProperty.d.ts +5 -3
  59. package/lib/properties/ObjectProperty.js +7 -3
  60. package/lib/properties/Property.js +6 -0
  61. package/lib/properties/index.d.ts +2 -2
  62. package/lib/properties/types/PropertyClassType.d.ts +2 -1
  63. package/lib/properties/types/PropertyHTMLType.d.ts +1 -1
  64. package/lib/properties/types/PropertyTypes.d.ts +2 -2
  65. package/lib/utils/DataGenerator.d.ts +3 -2
  66. package/lib/utils/DataGenerator.js +4 -3
  67. package/package.json +31 -29
  68. package/lib/components/BaseObjectProperties.d.ts +0 -13
  69. package/lib/components/BaseObjectProperties.js +0 -87
  70. package/lib/components/UserProperties.d.ts +0 -1
  71. package/lib/components/UserProperties.js +0 -103
  72. package/lib/components/types/UserClass.d.ts +0 -3
  73. /package/lib/{components/types/UserClass.js → backends/middlewares/Middleware.js} +0 -0
@@ -2,7 +2,7 @@ import { DataObjectClass } from '../components/types/DataObjectClass';
2
2
  import { AbstractPropertyType } from './types/AbstractPropertyType';
3
3
  import { PropertyClassType } from './types/PropertyClassType';
4
4
  import { PropertyHTMLType } from './types/PropertyHTMLType';
5
- export declare type EventTypes = typeof BaseProperty.EVENT_ONCHANGE | typeof BaseProperty.EVENT_ONDELETE;
5
+ export type EventTypes = typeof BaseProperty.EVENT_ONCHANGE | typeof BaseProperty.EVENT_ONDELETE;
6
6
  export interface BasePropertyType extends AbstractPropertyType {
7
7
  parent?: DataObjectClass<any>;
8
8
  protected?: boolean;
@@ -37,4 +37,5 @@ export declare class BaseProperty implements PropertyClassType {
37
37
  val(transform?: any): any;
38
38
  protected _enable(value: boolean | undefined): boolean;
39
39
  toJSON(): any;
40
+ clone(): any;
40
41
  }
@@ -43,7 +43,7 @@ class BaseProperty {
43
43
  this._value !== null &&
44
44
  this._value !== this._defaultValue &&
45
45
  this._protected === true) {
46
- throw new Error(`Value already defined as '${this._value}' and protected from change`);
46
+ throw new Error(`Value '${this._name}' already defined as '${this._value}' and protected from change`);
47
47
  }
48
48
  this._value = value;
49
49
  if (this._events[BaseProperty.EVENT_ONCHANGE]) {
@@ -60,6 +60,10 @@ class BaseProperty {
60
60
  toJSON() {
61
61
  return this._value;
62
62
  }
63
+ clone() {
64
+ const cloned = Object.create(Object.getPrototypeOf(this), Object.getOwnPropertyDescriptors(this));
65
+ return cloned;
66
+ }
63
67
  }
64
68
  exports.BaseProperty = BaseProperty;
65
69
  BaseProperty.TYPE = 'any';
@@ -4,21 +4,22 @@ import { Filter } from '../backends/Filter';
4
4
  import { ObjectUri } from '../components/ObjectUri';
5
5
  import { returnAs } from '../backends/Query';
6
6
  import { DataObjectClass } from '../components/types/DataObjectClass';
7
+ import { BaseObjectCore } from '../components';
7
8
  export interface CollectionPropertyType extends BasePropertyType {
8
- instanceOf?: Function | string | Object;
9
+ instanceOf: typeof BaseObjectCore;
9
10
  backend?: any;
10
11
  parentKey?: string;
11
12
  }
12
13
  export declare class CollectionProperty extends BaseProperty {
13
14
  static TYPE: string;
14
15
  protected _value: Array<any> | Array<DataObjectClass<any>> | Array<ObjectUri> | undefined;
15
- protected _instanceOf: any;
16
+ protected _instanceOf: typeof BaseObjectCore;
16
17
  protected _backend: any;
17
18
  protected _parentKey: string;
18
19
  protected _query: Query<any>;
19
20
  protected _filters: Filter[] | Filter | undefined;
20
21
  constructor(config: CollectionPropertyType);
21
- protected _setQuery(filters?: Filter[]): any;
22
+ protected _setQuery(filters?: Filter[]): Query<typeof BaseObjectCore>;
22
23
  set(value: Array<any>): this;
23
24
  /**
24
25
  * get objects matching collection class and filters
@@ -1,5 +1,5 @@
1
1
  import { StringProperty, StringPropertyType } from './StringProperty';
2
- export declare type HashPropertyAlgos = typeof HashProperty.ALGORITHM_MD5 | typeof HashProperty.ALGORITHM_SHA1 | typeof HashProperty.ALGORITHM_SHA256;
2
+ export type HashPropertyAlgos = typeof HashProperty.ALGORITHM_MD5 | typeof HashProperty.ALGORITHM_SHA1 | typeof HashProperty.ALGORITHM_SHA256;
3
3
  export interface HashPropertyType extends StringPropertyType {
4
4
  algorithm?: HashPropertyAlgos;
5
5
  salt?: string;
@@ -1,6 +1,6 @@
1
1
  import { BaseProperty, BasePropertyType } from './BaseProperty';
2
- export declare type NumberSign = typeof NumberProperty.TYPE_SIGNED | typeof NumberProperty.TYPE_UNSIGNED;
3
- export declare type NumberType = typeof NumberProperty.TYPE_INTEGER | typeof NumberProperty.TYPE_FLOAT;
2
+ export type NumberSign = typeof NumberProperty.TYPE_SIGNED | typeof NumberProperty.TYPE_UNSIGNED;
3
+ export type NumberType = typeof NumberProperty.TYPE_INTEGER | typeof NumberProperty.TYPE_FLOAT;
4
4
  export interface NumberPropertyType extends BasePropertyType {
5
5
  minVal?: number;
6
6
  maxVal?: number;
@@ -1,13 +1,15 @@
1
- import { BaseObjectClass } from '../components/types/BaseObjectClass';
1
+ import { BaseObject } from '../components/BaseObject';
2
+ import { ObjectUri } from '../components/ObjectUri';
2
3
  import { BaseProperty, BasePropertyType } from './BaseProperty';
4
+ import { Proxy } from '../components/types/ProxyConstructor';
3
5
  export interface ObjectPropertyType extends BasePropertyType {
4
6
  instanceOf?: Function | string | Object;
5
7
  }
6
8
  export declare class ObjectProperty extends BaseProperty {
7
9
  static TYPE: string;
8
- _value: BaseObjectClass | undefined;
10
+ _value: Proxy<BaseObject> | ObjectUri | undefined;
9
11
  _instanceOf: Function | string | Object;
10
12
  constructor(config: ObjectPropertyType);
11
- set(value: any): this;
13
+ set(value: object): this;
12
14
  toJSON(): any;
13
15
  }
@@ -19,9 +19,13 @@ class ObjectProperty extends BaseProperty_1.BaseProperty {
19
19
  return super.set(value);
20
20
  }
21
21
  toJSON() {
22
- return this._value && this._value.dataObject
23
- ? this._value.dataObject.toReference()
24
- : undefined;
22
+ if (this._value instanceof ObjectUri_1.ObjectUri) {
23
+ return this._value.toJSON();
24
+ }
25
+ return this._value &&
26
+ (this._value.core.dataObject || this._value instanceof DataObject_1.DataObject)
27
+ ? this._value.core.dataObject.toReference()
28
+ : null;
25
29
  }
26
30
  }
27
31
  exports.ObjectProperty = ObjectProperty;
@@ -10,6 +10,7 @@ const StringProperty_1 = require("./StringProperty");
10
10
  const NumberProperty_1 = require("./NumberProperty");
11
11
  const ObjectProperty_1 = require("./ObjectProperty");
12
12
  const CollectionProperty_1 = require("./CollectionProperty");
13
+ const ArrayProperty_1 = require("./ArrayProperty");
13
14
  class Property {
14
15
  static factory(params, parent) {
15
16
  params.parent = parent;
@@ -31,7 +32,12 @@ class Property {
31
32
  case DateTimeProperty_1.DateTimeProperty.TYPE:
32
33
  return new DateTimeProperty_1.DateTimeProperty(params);
33
34
  case CollectionProperty_1.CollectionProperty.TYPE:
35
+ if (!('instanceOf' in params)) {
36
+ throw new Error('Missing property instanceOf!');
37
+ }
34
38
  return new CollectionProperty_1.CollectionProperty(params);
39
+ case ArrayProperty_1.ArrayProperty.TYPE:
40
+ return new ArrayProperty_1.ArrayProperty(params);
35
41
  default:
36
42
  throw new Error(`Unknown property type ${params.type}`);
37
43
  }
@@ -12,7 +12,7 @@ import { MapProperty, MapPropertyType } from './MapProperty';
12
12
  import { CollectionProperty, CollectionPropertyType } from './CollectionProperty';
13
13
  import { PropertyTypes } from './types/PropertyTypes';
14
14
  export { Property, BaseProperty, BasePropertyType, ArrayProperty, ArrayPropertyType, NumberProperty, NumberPropertyType, BooleanProperty, BooleanPropertyType, DateTimeProperty, DateTimePropertyType, EnumProperty, EnumPropertyType, ObjectProperty, ObjectPropertyType, StringProperty, StringPropertyType, HashProperty, HashPropertyType, MapProperty, MapPropertyType, CollectionProperty, CollectionPropertyType, };
15
- declare type BaseType = {
15
+ type BaseType = {
16
16
  type: PropertyTypes;
17
17
  };
18
- export declare type DataObjectProperties = ((NumberPropertyType & BaseType) | (BooleanPropertyType & BaseType) | (EnumPropertyType & BaseType) | (ObjectPropertyType & BaseType) | (StringPropertyType & BaseType) | (HashPropertyType & BaseType) | (DateTimeProperty & BaseType) | (ArrayPropertyType & BaseType) | (MapPropertyType & BaseType) | (CollectionPropertyType & BaseType))[];
18
+ export type DataObjectProperties = ((NumberPropertyType & BaseType) | (BooleanPropertyType & BaseType) | (EnumPropertyType & BaseType) | (ObjectPropertyType & BaseType) | (StringPropertyType & BaseType) | (HashPropertyType & BaseType) | (DateTimeProperty & BaseType) | (ArrayPropertyType & BaseType) | (MapPropertyType & BaseType) | (CollectionPropertyType & BaseType))[];
@@ -1,6 +1,7 @@
1
- import { AbstractPropertyType } from "./AbstractPropertyType";
1
+ import { AbstractPropertyType } from './AbstractPropertyType';
2
2
  export interface PropertyClassType {
3
3
  set(value: any): AbstractPropertyType;
4
4
  val(transform?: any): any;
5
5
  toJSON(): any;
6
+ clone(): PropertyClassType;
6
7
  }
@@ -7,4 +7,4 @@ export declare const PASSWORD = "password";
7
7
  export declare const BIRTHDAY = "bday";
8
8
  export declare const GENDER = "sex";
9
9
  export declare const ORG = "organization";
10
- export declare type PropertyHTMLType = typeof OFF | typeof NAME | typeof GIVEN_NAME | typeof FAMILY_NAME | typeof EMAIL | typeof PASSWORD | typeof BIRTHDAY | typeof GENDER | typeof ORG;
10
+ export type PropertyHTMLType = typeof OFF | typeof NAME | typeof GIVEN_NAME | typeof FAMILY_NAME | typeof EMAIL | typeof PASSWORD | typeof BIRTHDAY | typeof GENDER | typeof ORG;
@@ -1,5 +1,5 @@
1
1
  import { Property } from '..';
2
- export declare type PropertyTypes = typeof Property.TYPE_STRING | typeof Property.TYPE_NUMBER | typeof Property.TYPE_ENUM | typeof Property.TYPE_BOOLEAN | typeof Property.TYPE_OBJECT | typeof Property.TYPE_DATETIME | typeof Property.TYPE_HASH | typeof Property.TYPE_ARRAY;
3
- export declare type BaseType = {
2
+ export type PropertyTypes = typeof Property.TYPE_STRING | typeof Property.TYPE_NUMBER | typeof Property.TYPE_ENUM | typeof Property.TYPE_BOOLEAN | typeof Property.TYPE_OBJECT | typeof Property.TYPE_DATETIME | typeof Property.TYPE_HASH | typeof Property.TYPE_ARRAY;
3
+ export type BaseType = {
4
4
  type: PropertyTypes;
5
5
  };
@@ -1,4 +1,5 @@
1
- import { BaseObject } from '../components';
1
+ import { BaseObject } from '../components/BaseObject';
2
+ import { Proxy } from '../components/types/ProxyConstructor';
2
3
  /**
3
4
  * Generate data from model of object and save it in default backend
4
5
  * @param model
@@ -6,4 +7,4 @@ import { BaseObject } from '../components';
6
7
  * @param forcedValues
7
8
  * @returns
8
9
  */
9
- export declare const DataGenerator: <T extends BaseObject>(model: T, qty?: number, forcedValues?: any) => Promise<any>;
10
+ export declare const DataGenerator: <T extends BaseObject>(model: Proxy<T>, qty?: number, forcedValues?: any) => Promise<any>;
@@ -47,7 +47,7 @@ const DataGenerator = (model, qty = 5, forcedValues = {}) => __awaiter(void 0, v
47
47
  const promises = [];
48
48
  Core_1.Core.log(`Starting to create ${qty} ${model.constructor.name} records`);
49
49
  for (let i = 0; i < qty; i++) {
50
- const dao = yield model.dataObject.clone(); //model.dataObject.toJSON())
50
+ const dao = yield model.core.dataObject.clone(); //model.dataObject.toJSON())
51
51
  Object.keys(dao.properties).forEach((key) => {
52
52
  const property = dao.get(key);
53
53
  if (forcedValues[key]) {
@@ -93,8 +93,9 @@ const DataGenerator = (model, qty = 5, forcedValues = {}) => __awaiter(void 0, v
93
93
  break;
94
94
  }
95
95
  });
96
- promises.push(dao.save());
96
+ yield dao.save();
97
+ promises.push(dao);
97
98
  }
98
- return Promise.all(promises);
99
+ return promises;
99
100
  });
100
101
  exports.DataGenerator = DataGenerator;
package/package.json CHANGED
@@ -1,30 +1,32 @@
1
1
  {
2
- "name": "@quatrain/core",
3
- "version": "0.4.3",
4
- "description": "Core objects for business apps",
5
- "main": "lib/index.js",
6
- "types": "lib/index.d.ts",
7
- "files": [
8
- "lib/",
9
- "README.md"
10
- ],
11
- "author": "Quatrain Développement SAS <developers@quatrain.com>",
12
- "license": "MIT",
13
- "devDependencies": {
14
- "@faker-js/faker": "^7.6.0",
15
- "@tsconfig/recommended": "^1.0.1",
16
- "@types/jest": "^27.0.3",
17
- "jest": "^27.4.7",
18
- "jest-node-exports-resolver": "^1.1.6",
19
- "trace-unhandled": "^2.0.1",
20
- "ts-jest": "^27.1.2",
21
- "ts-node": "^10.4.0",
22
- "typescript": "^4.7.4"
23
- },
24
- "scripts": {
25
- "test": "tsc && jest --verbose",
26
- "build": "tsc --watch",
27
- "push": "yarn version --patch --no-git-tag-version ; yarn publish --access public",
28
- "prepublish": "tsc"
29
- }
30
- }
2
+ "name": "@quatrain/core",
3
+ "version": "0.5.0",
4
+ "description": "Core objects for business apps",
5
+ "main": "lib/index.js",
6
+ "types": "lib/index.d.ts",
7
+ "files": [
8
+ "lib/",
9
+ "README.md"
10
+ ],
11
+ "author": "Quatrain Développement SAS <developers@quatrain.com>",
12
+ "license": "MIT",
13
+ "devDependencies": {
14
+ "@tsconfig/recommended": "^1.0.1",
15
+ "@types/jest": "^27.0.3",
16
+ "jest": "^27.4.7",
17
+ "jest-node-exports-resolver": "^1.1.6",
18
+ "trace-unhandled": "^2.0.1",
19
+ "ts-jest": "^27.1.2",
20
+ "ts-node": "^10.4.0",
21
+ "typescript": "^5.1.5"
22
+ },
23
+ "dependencies": {
24
+ "@faker-js/faker": "^7.6.0"
25
+ },
26
+ "scripts": {
27
+ "test": "tsc && jest --verbose",
28
+ "build": "tsc --watch",
29
+ "push": "yarn version --patch --no-git-tag-version ; yarn publish --access public",
30
+ "prepublish": "tsc"
31
+ }
32
+ }
@@ -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 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
- ];
@@ -1,3 +0,0 @@
1
- import { BaseObjectClass } from './BaseObjectClass';
2
- export interface UserClass extends BaseObjectClass {
3
- }