functional-models 1.0.28 → 1.1.3
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/.eslintignore +1 -0
- package/.eslintrc +9 -15
- package/cucumber.js +10 -0
- package/dist/src/constants.d.ts +14 -0
- package/dist/src/constants.js +19 -0
- package/dist/src/constants.js.map +1 -0
- package/dist/src/errors.d.ts +9 -0
- package/dist/src/errors.js +15 -0
- package/dist/src/errors.js.map +1 -0
- package/dist/src/index.d.ts +10 -0
- package/dist/src/index.js +41 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/interfaces.d.ts +145 -0
- package/dist/src/interfaces.js +5 -0
- package/dist/src/interfaces.js.map +1 -0
- package/dist/src/lazy.d.ts +2 -0
- package/dist/src/lazy.js +37 -0
- package/dist/src/lazy.js.map +1 -0
- package/dist/src/methods.d.ts +4 -0
- package/dist/src/methods.js +18 -0
- package/dist/src/methods.js.map +1 -0
- package/dist/src/models.d.ts +3 -0
- package/dist/src/models.js +128 -0
- package/dist/src/models.js.map +1 -0
- package/dist/src/properties.d.ts +16 -0
- package/dist/src/properties.js +208 -0
- package/dist/src/properties.js.map +1 -0
- package/dist/src/serialization.d.ts +3 -0
- package/dist/src/serialization.js +49 -0
- package/dist/src/serialization.js.map +1 -0
- package/dist/src/utils.d.ts +4 -0
- package/dist/src/utils.js +44 -0
- package/dist/src/utils.js.map +1 -0
- package/dist/src/validation.d.ts +29 -0
- package/dist/src/validation.js +286 -0
- package/dist/src/validation.js.map +1 -0
- package/dist/stepDefinitions/oldSteps.d.ts +1 -0
- package/dist/stepDefinitions/oldSteps.js +191 -0
- package/dist/stepDefinitions/oldSteps.js.map +1 -0
- package/dist/stepDefinitions/tssteps.d.ts +1 -0
- package/dist/stepDefinitions/tssteps.js +96 -0
- package/dist/stepDefinitions/tssteps.js.map +1 -0
- package/dist/test/src/errors.test.d.ts +1 -0
- package/dist/test/src/errors.test.js +33 -0
- package/dist/test/src/errors.test.js.map +1 -0
- package/dist/test/src/lazy.test.d.ts +1 -0
- package/dist/test/src/lazy.test.js +28 -0
- package/dist/test/src/lazy.test.js.map +1 -0
- package/dist/test/src/methods.test.d.ts +1 -0
- package/dist/test/src/methods.test.js +48 -0
- package/dist/test/src/methods.test.js.map +1 -0
- package/dist/test/src/models.test.d.ts +1 -0
- package/dist/test/src/models.test.js +395 -0
- package/dist/test/src/models.test.js.map +1 -0
- package/dist/test/src/properties.test.d.ts +1 -0
- package/dist/test/src/properties.test.js +724 -0
- package/dist/test/src/properties.test.js.map +1 -0
- package/dist/test/src/serialization.test.d.ts +1 -0
- package/dist/test/src/serialization.test.js +91 -0
- package/dist/test/src/serialization.test.js.map +1 -0
- package/dist/test/src/utils.test.d.ts +1 -0
- package/dist/test/src/utils.test.js +81 -0
- package/dist/test/src/utils.test.js.map +1 -0
- package/dist/test/src/validation.test.d.ts +1 -0
- package/dist/test/src/validation.test.js +612 -0
- package/dist/test/src/validation.test.js.map +1 -0
- package/features/arrayFields.feature +7 -7
- package/features/basic-ts.feature +13 -0
- package/features/functions.feature +2 -3
- package/package.json +34 -10
- package/src/constants.ts +15 -0
- package/src/{errors.js → errors.ts} +6 -4
- package/src/index.ts +12 -0
- package/src/interfaces.ts +323 -0
- package/src/{lazy.js → lazy.ts} +7 -9
- package/src/methods.ts +30 -0
- package/src/models.ts +183 -0
- package/src/properties.ts +375 -0
- package/src/serialization.ts +39 -0
- package/src/{utils.js → utils.ts} +16 -26
- package/src/validation.ts +390 -0
- package/{features/stepDefinitions/steps.js → stepDefinitions/oldSteps.ts} +76 -53
- package/stepDefinitions/tssteps.ts +107 -0
- package/test/src/errors.test.ts +31 -0
- package/test/src/{lazy.test.js → lazy.test.ts} +4 -4
- package/test/src/methods.test.ts +45 -0
- package/test/src/models.test.ts +417 -0
- package/test/src/{properties.test.js → properties.test.ts} +251 -58
- package/test/src/serialization.test.ts +80 -0
- package/test/src/{utils.test.js → utils.test.ts} +29 -7
- package/test/src/{validation.test.js → validation.test.ts} +278 -210
- package/tsconfig.json +100 -0
- package/src/constants.js +0 -19
- package/src/functions.js +0 -7
- package/src/index.js +0 -10
- package/src/models.js +0 -152
- package/src/properties.js +0 -313
- package/src/serialization.js +0 -50
- package/src/validation.js +0 -285
- package/test/base/index.test.js +0 -5
- package/test/src/functions.test.js +0 -45
- package/test/src/index.test.js +0 -5
- package/test/src/models.test.js +0 -380
- package/test/src/serialization.test.js +0 -127
package/.eslintignore
CHANGED
package/.eslintrc
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"extends": ["eslint:recommended", "prettier"],
|
|
3
|
-
"plugins": ["import", "functional"],
|
|
3
|
+
"plugins": ["import", "functional", "@typescript-eslint"],
|
|
4
4
|
"env": {
|
|
5
5
|
"browser": true,
|
|
6
6
|
"node": true,
|
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
"es6": true
|
|
9
9
|
},
|
|
10
10
|
"rules": {
|
|
11
|
+
"@typescript-eslint/no-unused-vars": "error",
|
|
12
|
+
|
|
11
13
|
"no-await-in-loop": ["error"],
|
|
12
14
|
"no-console": ["error", { "allow": ["warn", "error", "info"] }],
|
|
13
15
|
"no-constant-condition": ["error"],
|
|
@@ -91,15 +93,7 @@
|
|
|
91
93
|
"linebreak-style": 0,
|
|
92
94
|
"no-underscore-dangle": 0,
|
|
93
95
|
"no-unused-labels": 0,
|
|
94
|
-
"no-unused-vars":
|
|
95
|
-
"error",
|
|
96
|
-
{
|
|
97
|
-
"vars": "all",
|
|
98
|
-
"argsIgnorePattern": "(_+)|(action)",
|
|
99
|
-
"args": "after-used",
|
|
100
|
-
"ignoreRestSiblings": false
|
|
101
|
-
}
|
|
102
|
-
],
|
|
96
|
+
"no-unused-vars": 0,
|
|
103
97
|
"object-shorthand": 0,
|
|
104
98
|
"prefer-rest-params": 0,
|
|
105
99
|
"semi": ["error", "never"],
|
|
@@ -114,13 +108,13 @@
|
|
|
114
108
|
"functional/no-method-signature": ["error"],
|
|
115
109
|
"functional/prefer-readonly-type": ["error"],
|
|
116
110
|
"functional/no-class": ["error"],
|
|
117
|
-
"functional/no-mixed-type":
|
|
111
|
+
"functional/no-mixed-type": 0,
|
|
118
112
|
"functional/no-this-expression": ["error"],
|
|
119
|
-
"functional/prefer-type-literal":
|
|
113
|
+
"functional/prefer-type-literal": 0,
|
|
120
114
|
"functional/no-conditional-statement": 0,
|
|
121
115
|
"functional/no-expression-statement": 0,
|
|
122
116
|
"functional/no-loop-statement": ["error"],
|
|
123
|
-
"functional/no-return-void":
|
|
117
|
+
"functional/no-return-void": 0,
|
|
124
118
|
"functional/no-promise-reject": 0,
|
|
125
119
|
"functional/no-throw-statement": 0,
|
|
126
120
|
"functional/no-try-statement": ["error"],
|
|
@@ -156,7 +150,7 @@
|
|
|
156
150
|
"import/first": ["error"],
|
|
157
151
|
"import/exports-last": ["error"],
|
|
158
152
|
"import/no-duplicates": ["error"],
|
|
159
|
-
"import/no-namespace":
|
|
153
|
+
"import/no-namespace": 0,
|
|
160
154
|
"import/extensions": ["error"],
|
|
161
155
|
"import/order": ["error"],
|
|
162
156
|
"import/newline-after-import": ["error"],
|
|
@@ -182,5 +176,5 @@
|
|
|
182
176
|
"jsx": true
|
|
183
177
|
}
|
|
184
178
|
},
|
|
185
|
-
"parser": "
|
|
179
|
+
"parser": "@typescript-eslint/parser"
|
|
186
180
|
}
|
package/cucumber.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
declare enum PROPERTY_TYPES {
|
|
2
|
+
UniqueId = "UniqueId",
|
|
3
|
+
DateProperty = "DateProperty",
|
|
4
|
+
ArrayProperty = "ArrayProperty",
|
|
5
|
+
ReferenceProperty = "ReferenceProperty",
|
|
6
|
+
IntegerProperty = "IntegerProperty",
|
|
7
|
+
TextProperty = "TextProperty",
|
|
8
|
+
ConstantValueProperty = "ConstantValueProperty",
|
|
9
|
+
NumberProperty = "NumberProperty",
|
|
10
|
+
ObjectProperty = "ObjectProperty",
|
|
11
|
+
EmailProperty = "EmailProperty",
|
|
12
|
+
BooleanProperty = "BooleanProperty"
|
|
13
|
+
}
|
|
14
|
+
export { PROPERTY_TYPES };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PROPERTY_TYPES = void 0;
|
|
4
|
+
var PROPERTY_TYPES;
|
|
5
|
+
(function (PROPERTY_TYPES) {
|
|
6
|
+
PROPERTY_TYPES["UniqueId"] = "UniqueId";
|
|
7
|
+
PROPERTY_TYPES["DateProperty"] = "DateProperty";
|
|
8
|
+
PROPERTY_TYPES["ArrayProperty"] = "ArrayProperty";
|
|
9
|
+
PROPERTY_TYPES["ReferenceProperty"] = "ReferenceProperty";
|
|
10
|
+
PROPERTY_TYPES["IntegerProperty"] = "IntegerProperty";
|
|
11
|
+
PROPERTY_TYPES["TextProperty"] = "TextProperty";
|
|
12
|
+
PROPERTY_TYPES["ConstantValueProperty"] = "ConstantValueProperty";
|
|
13
|
+
PROPERTY_TYPES["NumberProperty"] = "NumberProperty";
|
|
14
|
+
PROPERTY_TYPES["ObjectProperty"] = "ObjectProperty";
|
|
15
|
+
PROPERTY_TYPES["EmailProperty"] = "EmailProperty";
|
|
16
|
+
PROPERTY_TYPES["BooleanProperty"] = "BooleanProperty";
|
|
17
|
+
})(PROPERTY_TYPES || (PROPERTY_TYPES = {}));
|
|
18
|
+
exports.PROPERTY_TYPES = PROPERTY_TYPES;
|
|
19
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":";;;AAAA,IAAK,cAYJ;AAZD,WAAK,cAAc;IACjB,uCAAqB,CAAA;IACrB,+CAA6B,CAAA;IAC7B,iDAA+B,CAAA;IAC/B,yDAAuC,CAAA;IACvC,qDAAmC,CAAA;IACnC,+CAA6B,CAAA;IAC7B,iEAA+C,CAAA;IAC/C,mDAAiC,CAAA;IACjC,mDAAiC,CAAA;IACjC,iDAA+B,CAAA;IAC/B,qDAAmC,CAAA;AACrC,CAAC,EAZI,cAAc,KAAd,cAAc,QAYlB;AAEQ,wCAAc"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ValidationError = void 0;
|
|
4
|
+
/* eslint-disable functional/no-this-expression */
|
|
5
|
+
/* eslint-disable functional/no-class */
|
|
6
|
+
class ValidationError extends Error {
|
|
7
|
+
constructor(modelName, keysToErrors) {
|
|
8
|
+
super(`${modelName} did not pass validation`);
|
|
9
|
+
this.name = 'ValidationError';
|
|
10
|
+
this.modelName = modelName;
|
|
11
|
+
this.keysToErrors = keysToErrors;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
exports.ValidationError = ValidationError;
|
|
15
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":";;;AAEA,kDAAkD;AAClD,wCAAwC;AACxC,MAAM,eAAgB,SAAQ,KAAK;IAGjC,YAAY,SAAiB,EAAE,YAA0B;QACvD,KAAK,CAAC,GAAG,SAAS,0BAA0B,CAAC,CAAA;QAC7C,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAA;QAC7B,IAAI,CAAC,SAAS,GAAG,SAAS,CAAA;QAC1B,IAAI,CAAC,YAAY,GAAG,YAAY,CAAA;IAClC,CAAC;CACF;AAIQ,0CAAe"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as constants from './constants';
|
|
2
|
+
import * as errors from './errors';
|
|
3
|
+
import * as validation from './validation';
|
|
4
|
+
import * as serialization from './serialization';
|
|
5
|
+
import * as utils from './utils';
|
|
6
|
+
import * as interfaces from './interfaces';
|
|
7
|
+
export * from './models';
|
|
8
|
+
export * from './properties';
|
|
9
|
+
export * from './methods';
|
|
10
|
+
export { constants, errors, validation, serialization, utils, interfaces };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
22
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
23
|
+
};
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
exports.interfaces = exports.utils = exports.serialization = exports.validation = exports.errors = exports.constants = void 0;
|
|
26
|
+
const constants = __importStar(require("./constants"));
|
|
27
|
+
exports.constants = constants;
|
|
28
|
+
const errors = __importStar(require("./errors"));
|
|
29
|
+
exports.errors = errors;
|
|
30
|
+
const validation = __importStar(require("./validation"));
|
|
31
|
+
exports.validation = validation;
|
|
32
|
+
const serialization = __importStar(require("./serialization"));
|
|
33
|
+
exports.serialization = serialization;
|
|
34
|
+
const utils = __importStar(require("./utils"));
|
|
35
|
+
exports.utils = utils;
|
|
36
|
+
const interfaces = __importStar(require("./interfaces"));
|
|
37
|
+
exports.interfaces = interfaces;
|
|
38
|
+
__exportStar(require("./models"), exports);
|
|
39
|
+
__exportStar(require("./properties"), exports);
|
|
40
|
+
__exportStar(require("./methods"), exports);
|
|
41
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uDAAwC;AAW/B,8BAAS;AAVlB,iDAAkC;AAUd,wBAAM;AAT1B,yDAA0C;AASd,gCAAU;AARtC,+DAAgD;AAQR,sCAAa;AAPrD,+CAAgC;AAOuB,sBAAK;AAN5D,yDAA0C;AAMoB,gCAAU;AAJxE,2CAAwB;AACxB,+CAA4B;AAC5B,4CAAyB"}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
declare type MaybeFunction<T> = T | (() => T);
|
|
2
|
+
declare type MaybePromise<T> = T | Promise<T>;
|
|
3
|
+
declare type Nullable<T> = T | null;
|
|
4
|
+
declare type Maybe<T> = T | undefined | null;
|
|
5
|
+
declare type Arrayable<T> = T | readonly T[];
|
|
6
|
+
declare type MaybeLazy<T> = Maybe<Promise<T>>;
|
|
7
|
+
declare type MaybeEmpty<T> = T | null | undefined;
|
|
8
|
+
declare type JsonAble = number | string | boolean | null | Arrayable<{
|
|
9
|
+
readonly [s: string]: JsonAble;
|
|
10
|
+
}>;
|
|
11
|
+
declare type VeryPrimitivesTypes = null | string | number | boolean;
|
|
12
|
+
declare type toObj = () => Promise<JsonAble>;
|
|
13
|
+
declare type ValueIsOfType<T, V> = {
|
|
14
|
+
readonly [P in keyof T as T[P] extends V ? P : never]: T[P];
|
|
15
|
+
};
|
|
16
|
+
declare type ValueIsNotOfType<T, V> = {
|
|
17
|
+
readonly [P in keyof T as T[P] extends V ? never : P]: T[P];
|
|
18
|
+
};
|
|
19
|
+
declare type InstanceMethodGetters<T> = {
|
|
20
|
+
readonly [P in keyof T as T[P] extends ModelInstanceMethod ? P : never]: ModelInstanceMethodClient;
|
|
21
|
+
};
|
|
22
|
+
declare type ModelMethodGetters<T> = {
|
|
23
|
+
readonly [P in keyof T as T[P] extends ModelMethod ? P : never]: ModelMethodClient;
|
|
24
|
+
};
|
|
25
|
+
declare type ModelMethodTypes<T extends FunctionalModel> = ModelMethod | ModelInstanceMethod | ModelMethodTyped<T> | ModelInstanceMethodTyped<T>;
|
|
26
|
+
declare type PropertyGetters<T extends FunctionalModel> = {
|
|
27
|
+
readonly [Property in keyof T as T[Property] extends ModelMethodTypes<T> ? never : Property]: () => T[Property] | Promise<T[Property]>;
|
|
28
|
+
};
|
|
29
|
+
declare type FunctionalModel = {
|
|
30
|
+
readonly [s: string]: Arrayable<number> | Arrayable<string> | Arrayable<boolean> | Arrayable<null> | Arrayable<FunctionalModel> | Arrayable<Date> | Arrayable<undefined> | ReferenceValueType<any> | ModelInstanceMethod | ModelMethod;
|
|
31
|
+
} | JsonAble;
|
|
32
|
+
declare type FunctionalType = JsonAble | (() => FunctionalType) | Arrayable<undefined> | Arrayable<Date> | Arrayable<FunctionalModel> | Arrayable<{
|
|
33
|
+
readonly [s: string]: JsonAble;
|
|
34
|
+
}>;
|
|
35
|
+
declare type ModelInstanceInputData<T extends FunctionalModel> = ValueIsNotOfType<T, ModelMethodTypes<T>>;
|
|
36
|
+
declare type PropertyValidatorComponentTypeAdvanced<TValue, TModel extends FunctionalModel> = (value: TValue, instance: ModelInstance<TModel>, instanceData: FunctionalModel) => string | undefined;
|
|
37
|
+
declare type PropertyValidatorComponentType<TValue> = (value: TValue, instance: ModelInstance<any>, instanceData: FunctionalModel) => string | undefined;
|
|
38
|
+
declare type PropertyValidatorComponentSync = PropertyValidatorComponentType<any>;
|
|
39
|
+
declare type PropertyValidatorComponentAsync = (value: Arrayable<FunctionalModel>, instance: ModelInstance<any>, instanceData: FunctionalModel) => Promise<string | undefined>;
|
|
40
|
+
declare type PropertyValidatorComponent = PropertyValidatorComponentSync | PropertyValidatorComponentAsync;
|
|
41
|
+
declare type PropertyValidator = (instance: ModelInstance<any>, instanceData: FunctionalModel) => Promise<ValidationErrors>;
|
|
42
|
+
declare type ValidationError = string | undefined;
|
|
43
|
+
declare type ValidationErrors = readonly ValidationError[];
|
|
44
|
+
declare type ModelError = string;
|
|
45
|
+
declare type ModelErrors = {
|
|
46
|
+
readonly [s: string]: readonly ModelError[];
|
|
47
|
+
};
|
|
48
|
+
declare type ModelComponentValidator = (instance: ModelInstance<any>, instanceData: FunctionalModel, options?: object) => Promise<ValidationErrors>;
|
|
49
|
+
declare type ValueGetter = () => MaybePromise<Arrayable<FunctionalType>> | MaybePromise<ModelInstance<any>>;
|
|
50
|
+
declare type PropertyInstance<T extends Arrayable<FunctionalType>> = {
|
|
51
|
+
readonly getConfig: () => object;
|
|
52
|
+
readonly getChoices: () => readonly VeryPrimitivesTypes[];
|
|
53
|
+
readonly getDefaultValue: () => T;
|
|
54
|
+
readonly getConstantValue: () => T;
|
|
55
|
+
readonly getPropertyType: () => string;
|
|
56
|
+
readonly createGetter: (value: T) => ValueGetter;
|
|
57
|
+
readonly getValidator: (valueGetter: ValueGetter) => PropertyValidator;
|
|
58
|
+
};
|
|
59
|
+
declare type PropertiesList<T> = {
|
|
60
|
+
readonly [P in keyof T as T[P] extends Arrayable<FunctionalType> ? P : never]: PropertyInstance<any>;
|
|
61
|
+
};
|
|
62
|
+
interface ReferencePropertyInstance<T extends FunctionalModel> extends PropertyInstance<ModelInstance<T> | T | MaybeEmpty<PrimaryKeyType>> {
|
|
63
|
+
readonly getReferencedId: (instanceValues: ReferenceValueType<T>) => MaybeEmpty<PrimaryKeyType>;
|
|
64
|
+
readonly getReferencedModel: () => Model<T>;
|
|
65
|
+
}
|
|
66
|
+
declare type ReferenceValueType<T extends FunctionalModel> = ModelInstance<T> | ModelInstanceInputData<T> | string | number | null | undefined;
|
|
67
|
+
declare type DefaultPropertyValidators = {
|
|
68
|
+
readonly required?: boolean;
|
|
69
|
+
readonly isInteger?: boolean;
|
|
70
|
+
readonly isNumber?: boolean;
|
|
71
|
+
readonly isString?: boolean;
|
|
72
|
+
readonly isArray?: boolean;
|
|
73
|
+
readonly isBoolean?: boolean;
|
|
74
|
+
};
|
|
75
|
+
declare type PropertyConfigContents = {
|
|
76
|
+
readonly type?: string;
|
|
77
|
+
readonly defaultValue?: Arrayable<FunctionalType>;
|
|
78
|
+
readonly value?: Arrayable<FunctionalType>;
|
|
79
|
+
readonly choices?: readonly VeryPrimitivesTypes[];
|
|
80
|
+
readonly lazyLoadMethod?: (value: Arrayable<FunctionalType>) => MaybeLazy<Arrayable<FunctionalType>>;
|
|
81
|
+
readonly valueSelector?: (instanceValue: MaybePromise<Arrayable<FunctionalType>>) => Arrayable<FunctionalType>;
|
|
82
|
+
readonly validators?: readonly PropertyValidatorComponent[];
|
|
83
|
+
readonly maxLength?: number;
|
|
84
|
+
readonly minLength?: number;
|
|
85
|
+
readonly maxValue?: number;
|
|
86
|
+
readonly minValue?: number;
|
|
87
|
+
readonly autoNow?: boolean;
|
|
88
|
+
readonly fetcher?: (model: Model<any>, primaryKey: PrimaryKeyType) => Promise<any>;
|
|
89
|
+
};
|
|
90
|
+
declare type PropertyConfig = (PropertyConfigContents & DefaultPropertyValidators) | undefined;
|
|
91
|
+
declare type PrimaryKeyPropertyInstanceType = PropertyInstance<string> | PropertyInstance<number>;
|
|
92
|
+
declare type PrimaryKeyType = string | number;
|
|
93
|
+
declare type ModelMethods<T extends FunctionalModel> = ValueIsOfType<T, ModelMethod | ModelMethodTyped<T>>;
|
|
94
|
+
declare type InstanceMethods<T extends FunctionalModel> = ValueIsOfType<T, ModelInstanceMethod | ModelInstanceMethodTyped<T>>;
|
|
95
|
+
declare type ModelDefinition<T extends FunctionalModel> = {
|
|
96
|
+
readonly getPrimaryKeyName?: () => string;
|
|
97
|
+
readonly properties: PropertiesList<T> & {
|
|
98
|
+
readonly id?: PrimaryKeyPropertyInstanceType;
|
|
99
|
+
};
|
|
100
|
+
readonly instanceMethods?: InstanceMethods<T>;
|
|
101
|
+
readonly modelMethods?: ModelMethods<T>;
|
|
102
|
+
readonly modelValidators?: readonly ModelComponentValidator[];
|
|
103
|
+
};
|
|
104
|
+
declare type Model<T extends FunctionalModel> = {
|
|
105
|
+
readonly getName: () => string;
|
|
106
|
+
readonly getPrimaryKeyName: () => string;
|
|
107
|
+
readonly getModelDefinition: () => ModelDefinition<T>;
|
|
108
|
+
readonly getPrimaryKey: (t: ModelInstanceInputData<T>) => PrimaryKeyType;
|
|
109
|
+
readonly create: (data: ModelInstanceInputData<T> & {
|
|
110
|
+
readonly id?: PrimaryKeyType;
|
|
111
|
+
}) => ModelInstance<T>;
|
|
112
|
+
readonly methods: ModelMethodGetters<T>;
|
|
113
|
+
};
|
|
114
|
+
declare type ReferenceFunctions = {
|
|
115
|
+
readonly [s: string]: () => ReferenceValueType<any>;
|
|
116
|
+
};
|
|
117
|
+
declare type PropertyValidators = {
|
|
118
|
+
readonly [s: string]: PropertyValidator;
|
|
119
|
+
};
|
|
120
|
+
declare type ModelInstance<T extends FunctionalModel> = {
|
|
121
|
+
readonly get: PropertyGetters<T> & {
|
|
122
|
+
readonly id: () => MaybePromise<PrimaryKeyType>;
|
|
123
|
+
};
|
|
124
|
+
readonly methods: InstanceMethodGetters<T>;
|
|
125
|
+
readonly references: ReferenceFunctions;
|
|
126
|
+
readonly toObj: toObj;
|
|
127
|
+
readonly getPrimaryKeyName: () => string;
|
|
128
|
+
readonly getPrimaryKey: () => PrimaryKeyType;
|
|
129
|
+
readonly validators: PropertyValidators;
|
|
130
|
+
readonly validate: (options?: {}) => Promise<ModelErrors>;
|
|
131
|
+
readonly getModel: () => Model<T>;
|
|
132
|
+
};
|
|
133
|
+
declare type ModelMethodTyped<T extends FunctionalModel> = (model: Model<T>, args?: readonly any[]) => any;
|
|
134
|
+
declare type ModelMethod = ModelMethodTyped<any>;
|
|
135
|
+
declare type ModelMethodClient = (...args: readonly any[]) => any;
|
|
136
|
+
declare type ModelInstanceMethodTyped<T extends FunctionalModel> = (instance: ModelInstance<T>, args?: readonly any[]) => any;
|
|
137
|
+
declare type ModelInstanceMethod = ModelInstanceMethodTyped<any>;
|
|
138
|
+
declare type ModelInstanceMethodClient = (...args: readonly any[]) => any;
|
|
139
|
+
declare type ModelOptions = {
|
|
140
|
+
readonly instanceCreatedCallback: Nullable<Arrayable<(instance: ModelInstance<any>) => void>>;
|
|
141
|
+
};
|
|
142
|
+
declare type OptionalModelOptions = {
|
|
143
|
+
readonly instanceCreatedCallback?: Nullable<Arrayable<(instance: ModelInstance<any>) => void>>;
|
|
144
|
+
} | undefined;
|
|
145
|
+
export { MaybeFunction, Maybe, MaybePromise, Nullable, Arrayable, MaybeLazy, JsonAble, toObj, ModelInstance, Model, PropertyValidatorComponent, PropertyValidatorComponentSync, PropertyValidatorComponentAsync, PropertyValidatorComponentType, PropertyValidator, ModelComponentValidator, PropertyInstance, PropertyConfig, FunctionalType, ValueGetter, ReferenceValueType, ModelDefinition, ModelOptions, ModelMethod, OptionalModelOptions, ReferencePropertyInstance, PropertyGetters, PropertyValidators, PropertyValidatorComponentTypeAdvanced, ModelInstanceMethod, ModelInstanceMethodTyped, FunctionalModel, ModelInstanceInputData, ModelMethodTyped, ModelMethodGetters, InstanceMethodGetters, ReferenceFunctions, ModelErrors, MaybeEmpty, PrimaryKeyType, };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../src/interfaces.ts"],"names":[],"mappings":";AAAA,mCAAmC;;AAkUnC,kCAAkC"}
|
package/dist/src/lazy.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.lazyValue = void 0;
|
|
16
|
+
const async_lock_1 = __importDefault(require("async-lock"));
|
|
17
|
+
const utils_1 = require("./utils");
|
|
18
|
+
const lazyValue = (method) => {
|
|
19
|
+
const key = (0, utils_1.createUuid)();
|
|
20
|
+
const lock = new async_lock_1.default();
|
|
21
|
+
/* eslint-disable functional/no-let */
|
|
22
|
+
let value = undefined;
|
|
23
|
+
let called = false;
|
|
24
|
+
return (...args) => __awaiter(void 0, void 0, void 0, function* () {
|
|
25
|
+
return lock.acquire(key, () => __awaiter(void 0, void 0, void 0, function* () {
|
|
26
|
+
if (!called) {
|
|
27
|
+
called = true;
|
|
28
|
+
value = yield method(...args);
|
|
29
|
+
// eslint-disable-next-line require-atomic-updates
|
|
30
|
+
}
|
|
31
|
+
return value;
|
|
32
|
+
}));
|
|
33
|
+
});
|
|
34
|
+
/* eslint-enable functional/no-let */
|
|
35
|
+
};
|
|
36
|
+
exports.lazyValue = lazyValue;
|
|
37
|
+
//# sourceMappingURL=lazy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lazy.js","sourceRoot":"","sources":["../../src/lazy.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,4DAAkC;AAClC,mCAAoC;AAEpC,MAAM,SAAS,GAAG,CAAC,MAAgB,EAAE,EAAE;IACrC,MAAM,GAAG,GAAG,IAAA,kBAAU,GAAE,CAAA;IACxB,MAAM,IAAI,GAAG,IAAI,oBAAS,EAAE,CAAA;IAC5B,sCAAsC;IACtC,IAAI,KAAK,GAAQ,SAAS,CAAA;IAC1B,IAAI,MAAM,GAAG,KAAK,CAAA;IAClB,OAAO,CAAO,GAAG,IAAoB,EAAE,EAAE;QACvC,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,GAAS,EAAE;YAClC,IAAI,CAAC,MAAM,EAAE;gBACX,MAAM,GAAG,IAAI,CAAA;gBACb,KAAK,GAAG,MAAM,MAAM,CAAC,GAAG,IAAI,CAAC,CAAA;gBAC7B,kDAAkD;aACnD;YAED,OAAO,KAAK,CAAA;QACd,CAAC,CAAA,CAAC,CAAA;IACJ,CAAC,CAAA,CAAA;IACD,qCAAqC;AACvC,CAAC,CAAA;AAEQ,8BAAS"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { ModelInstanceMethodTyped, ModelInstance, FunctionalModel, Model, ModelMethodTyped } from './interfaces';
|
|
2
|
+
declare const WrapperInstanceMethod: <T extends FunctionalModel>(method: (instance: ModelInstance<T>, args?: readonly any[] | undefined) => any) => ModelInstanceMethodTyped<T>;
|
|
3
|
+
declare const WrapperModelMethod: <T extends FunctionalModel>(method: (model: Model<T>, args?: readonly any[] | undefined) => any) => ModelMethodTyped<T>;
|
|
4
|
+
export { WrapperInstanceMethod, WrapperModelMethod };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WrapperModelMethod = exports.WrapperInstanceMethod = void 0;
|
|
4
|
+
const WrapperInstanceMethod = (method) => {
|
|
5
|
+
const r = (instance, ...args) => {
|
|
6
|
+
return method(instance, ...args);
|
|
7
|
+
};
|
|
8
|
+
return r;
|
|
9
|
+
};
|
|
10
|
+
exports.WrapperInstanceMethod = WrapperInstanceMethod;
|
|
11
|
+
const WrapperModelMethod = (method) => {
|
|
12
|
+
const r = (model, ...args) => {
|
|
13
|
+
return method(model, ...args);
|
|
14
|
+
};
|
|
15
|
+
return r;
|
|
16
|
+
};
|
|
17
|
+
exports.WrapperModelMethod = WrapperModelMethod;
|
|
18
|
+
//# sourceMappingURL=methods.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"methods.js","sourceRoot":"","sources":["../../src/methods.ts"],"names":[],"mappings":";;;AAQA,MAAM,qBAAqB,GAAG,CAC5B,MAAkE,EAClE,EAAE;IACF,MAAM,CAAC,GAAgC,CACrC,QAA0B,EAC1B,GAAG,IAAoB,EACvB,EAAE;QACF,OAAO,MAAM,CAAC,QAAQ,EAAE,GAAG,IAAI,CAAC,CAAA;IAClC,CAAC,CAAA;IACD,OAAO,CAAC,CAAA;AACV,CAAC,CAAA;AAWQ,sDAAqB;AAT9B,MAAM,kBAAkB,GAAG,CACzB,MAAuD,EACvD,EAAE;IACF,MAAM,CAAC,GAAwB,CAAC,KAAe,EAAE,GAAG,IAAoB,EAAE,EAAE;QAC1E,OAAO,MAAM,CAAC,KAAK,EAAE,GAAG,IAAI,CAAC,CAAA;IAC/B,CAAC,CAAA;IACD,OAAO,CAAC,CAAA;AACV,CAAC,CAAA;AAE+B,gDAAkB"}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.BaseModel = void 0;
|
|
7
|
+
const merge_1 = __importDefault(require("lodash/merge"));
|
|
8
|
+
const serialization_1 = require("./serialization");
|
|
9
|
+
const validation_1 = require("./validation");
|
|
10
|
+
const properties_1 = require("./properties");
|
|
11
|
+
const _defaultOptions = () => ({
|
|
12
|
+
instanceCreatedCallback: null,
|
|
13
|
+
});
|
|
14
|
+
const _convertOptions = (options) => {
|
|
15
|
+
const r = (0, merge_1.default)({}, _defaultOptions(), options);
|
|
16
|
+
return r;
|
|
17
|
+
};
|
|
18
|
+
const _createModelDefWithPrimaryKey = (keyToProperty) => {
|
|
19
|
+
return {
|
|
20
|
+
getPrimaryKeyName: () => 'id',
|
|
21
|
+
modelMethods: keyToProperty.modelMethods,
|
|
22
|
+
instanceMethods: keyToProperty.instanceMethods,
|
|
23
|
+
properties: Object.assign({ id: (0, properties_1.UniqueId)({ required: true }) }, keyToProperty.properties),
|
|
24
|
+
modelValidators: keyToProperty.modelValidators,
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
const BaseModel = (modelName, modelDefinition,
|
|
28
|
+
//keyToProperty: IModelDefinition2<T>,
|
|
29
|
+
options) => {
|
|
30
|
+
/*
|
|
31
|
+
* This non-functional approach is specifically used to
|
|
32
|
+
* allow instances to be able to refer back to its parent without
|
|
33
|
+
* having to duplicate it for every instance.
|
|
34
|
+
* This is set at the very end and returned, so it can be referenced
|
|
35
|
+
* throughout instance methods.
|
|
36
|
+
*/
|
|
37
|
+
// eslint-disable-next-line functional/no-let
|
|
38
|
+
let model = null;
|
|
39
|
+
const theOptions = _convertOptions(options);
|
|
40
|
+
modelDefinition = !modelDefinition.getPrimaryKeyName
|
|
41
|
+
? _createModelDefWithPrimaryKey(modelDefinition)
|
|
42
|
+
: modelDefinition;
|
|
43
|
+
// @ts-ignore
|
|
44
|
+
const getPrimaryKeyName = () => modelDefinition.getPrimaryKeyName();
|
|
45
|
+
const getPrimaryKey = (t) =>
|
|
46
|
+
// @ts-ignore
|
|
47
|
+
t[getPrimaryKeyName()];
|
|
48
|
+
const create = (instanceValues) => {
|
|
49
|
+
// eslint-disable-next-line functional/no-let
|
|
50
|
+
let instance = null;
|
|
51
|
+
const startingInternals = {
|
|
52
|
+
get: {},
|
|
53
|
+
validators: {},
|
|
54
|
+
references: {},
|
|
55
|
+
};
|
|
56
|
+
const loadedInternals = Object.entries(modelDefinition.properties).reduce((acc, [key, property]) => {
|
|
57
|
+
// @ts-ignore
|
|
58
|
+
const propertyGetter = property.createGetter(instanceValues[key]);
|
|
59
|
+
// @ts-ignore
|
|
60
|
+
const propertyValidator = property.getValidator(propertyGetter);
|
|
61
|
+
const fleshedOutInstanceProperties = {
|
|
62
|
+
get: {
|
|
63
|
+
[key]: propertyGetter,
|
|
64
|
+
},
|
|
65
|
+
validators: {
|
|
66
|
+
[key]: propertyValidator,
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
const asReferenced = property;
|
|
70
|
+
const referencedProperty = asReferenced.getReferencedId
|
|
71
|
+
? {
|
|
72
|
+
references: {
|
|
73
|
+
[key]: () => asReferenced.getReferencedId(
|
|
74
|
+
// @ts-ignore
|
|
75
|
+
instanceValues[key]),
|
|
76
|
+
},
|
|
77
|
+
}
|
|
78
|
+
: {};
|
|
79
|
+
return (0, merge_1.default)(acc, fleshedOutInstanceProperties, referencedProperty);
|
|
80
|
+
}, startingInternals);
|
|
81
|
+
const methods = Object.entries(modelDefinition.instanceMethods || {}).reduce((acc, [key, func]) => {
|
|
82
|
+
return (0, merge_1.default)(acc, {
|
|
83
|
+
[key]: (...args) => {
|
|
84
|
+
return func(instance, ...args);
|
|
85
|
+
},
|
|
86
|
+
});
|
|
87
|
+
}, {});
|
|
88
|
+
const getModel = () => model;
|
|
89
|
+
const toObj = (0, serialization_1.toJsonAble)(loadedInternals.get);
|
|
90
|
+
const validate = (options = {}) => {
|
|
91
|
+
return (0, validation_1.createModelValidator)(loadedInternals.validators, modelDefinition.modelValidators || [])(instance, options);
|
|
92
|
+
};
|
|
93
|
+
instance = (0, merge_1.default)(loadedInternals, {
|
|
94
|
+
getModel,
|
|
95
|
+
toObj,
|
|
96
|
+
getPrimaryKey: () => getPrimaryKey(instanceValues),
|
|
97
|
+
getPrimaryKeyName,
|
|
98
|
+
validate,
|
|
99
|
+
methods,
|
|
100
|
+
});
|
|
101
|
+
if (theOptions.instanceCreatedCallback) {
|
|
102
|
+
const toCall = Array.isArray(theOptions.instanceCreatedCallback)
|
|
103
|
+
? theOptions.instanceCreatedCallback
|
|
104
|
+
: [theOptions.instanceCreatedCallback];
|
|
105
|
+
toCall.map(func => func(instance));
|
|
106
|
+
}
|
|
107
|
+
return instance;
|
|
108
|
+
};
|
|
109
|
+
const fleshedOutModelFunctions = Object.entries(modelDefinition.modelMethods || {}).reduce((acc, [key, func]) => {
|
|
110
|
+
return (0, merge_1.default)(acc, {
|
|
111
|
+
[key]: (...args) => {
|
|
112
|
+
return func(model, ...args);
|
|
113
|
+
},
|
|
114
|
+
});
|
|
115
|
+
}, {});
|
|
116
|
+
// This sets the model that is used by the instances later.
|
|
117
|
+
model = (0, merge_1.default)({}, {
|
|
118
|
+
create,
|
|
119
|
+
getName: () => modelName,
|
|
120
|
+
getModelDefinition: () => modelDefinition,
|
|
121
|
+
getPrimaryKeyName,
|
|
122
|
+
getPrimaryKey,
|
|
123
|
+
methods: fleshedOutModelFunctions,
|
|
124
|
+
});
|
|
125
|
+
return model;
|
|
126
|
+
};
|
|
127
|
+
exports.BaseModel = BaseModel;
|
|
128
|
+
//# sourceMappingURL=models.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"models.js","sourceRoot":"","sources":["../../src/models.ts"],"names":[],"mappings":";;;;;;AAAA,yDAAgC;AAChC,mDAA4C;AAC5C,6CAAmD;AACnD,6CAAuC;AAqBvC,MAAM,eAAe,GAAG,GAAiB,EAAE,CAAC,CAAC;IAC3C,uBAAuB,EAAE,IAAI;CAC9B,CAAC,CAAA;AAEF,MAAM,eAAe,GAAG,CAAC,OAA8B,EAAE,EAAE;IACzD,MAAM,CAAC,GAAiB,IAAA,eAAK,EAAC,EAAE,EAAE,eAAe,EAAE,EAAE,OAAO,CAAC,CAAA;IAC7D,OAAO,CAAC,CAAA;AACV,C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AA2D;IAC3D,KAAK,GAAG,IAAA,eAAK,EACX,EAAE,EACF;QACE,MAAM;QACN,OAAO,EAAE,GAAG,EAAE,CAAC,SAAS;QACxB,kBAAkB,EAAE,GAAG,EAAE,CAAC,eAAe;QACzC,iBAAiB;QACjB,aAAa;QACb,OAAO,EAAE,wBAAwB;KAClC,CACF,CAAA;IACD,OAAO,KAAiB,CAAA;AAC1B,CAAC,CAAA;AAEQ,8BAAS"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { MaybeEmpty, Model, PropertyInstance, FunctionalType, PropertyConfig, MaybeFunction, Arrayable, ReferencePropertyInstance, FunctionalModel, JsonAble } from './interfaces';
|
|
2
|
+
declare function Property<T extends Arrayable<FunctionalType>>(type: string, config?: PropertyConfig, additionalMetadata?: {}): PropertyInstance<T>;
|
|
3
|
+
declare const DateProperty: (config?: PropertyConfig, additionalMetadata?: {}) => PropertyInstance<MaybeEmpty<Date>>;
|
|
4
|
+
declare const ArrayProperty: <T extends FunctionalType>(config?: {}, additionalMetadata?: {}) => PropertyInstance<readonly T[]>;
|
|
5
|
+
declare const ObjectProperty: (config?: {}, additionalMetadata?: {}) => PropertyInstance<{
|
|
6
|
+
readonly [s: string]: JsonAble;
|
|
7
|
+
}>;
|
|
8
|
+
declare const TextProperty: (config?: PropertyConfig, additionalMetadata?: {}) => PropertyInstance<MaybeEmpty<string>>;
|
|
9
|
+
declare const IntegerProperty: (config?: PropertyConfig, additionalMetadata?: {}) => PropertyInstance<MaybeEmpty<number>>;
|
|
10
|
+
declare const NumberProperty: (config?: PropertyConfig, additionalMetadata?: {}) => PropertyInstance<MaybeEmpty<number>>;
|
|
11
|
+
declare const ConstantValueProperty: (value: string, config?: PropertyConfig, additionalMetadata?: {}) => PropertyInstance<MaybeEmpty<string>>;
|
|
12
|
+
declare const EmailProperty: (config?: PropertyConfig, additionalMetadata?: {}) => PropertyInstance<MaybeEmpty<string>>;
|
|
13
|
+
declare const BooleanProperty: (config?: PropertyConfig, additionalMetadata?: {}) => PropertyInstance<MaybeEmpty<boolean>>;
|
|
14
|
+
declare const UniqueId: (config?: PropertyConfig, additionalMetadata?: {}) => PropertyInstance<string>;
|
|
15
|
+
declare const ReferenceProperty: <T extends FunctionalModel>(model: MaybeFunction<Model<T>>, config?: PropertyConfig, additionalMetadata?: {}) => ReferencePropertyInstance<T>;
|
|
16
|
+
export { Property, UniqueId, DateProperty, ArrayProperty, ReferenceProperty, IntegerProperty, TextProperty, ConstantValueProperty, NumberProperty, ObjectProperty, EmailProperty, BooleanProperty, };
|