functional-models 2.0.5 → 2.0.8
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/interfaces.d.ts +15 -15
- package/interfaces.js.map +1 -1
- package/models.js.map +1 -1
- package/package.json +1 -1
- package/properties.d.ts +1048 -15
- package/properties.js +9 -6
- package/properties.js.map +1 -1
- package/validation.d.ts +50 -2
- package/validation.js.map +1 -1
package/interfaces.d.ts
CHANGED
|
@@ -41,7 +41,7 @@ declare type PropertyGetters<T extends FunctionalModel, TModel extends Model<T>
|
|
|
41
41
|
readonly [Property in keyof T as T[Property] extends ModelMethodTypes<T, TModel> ? never : Property]: () => T[Property];
|
|
42
42
|
};
|
|
43
43
|
declare type FunctionalModel = ({
|
|
44
|
-
readonly [s: string]: Arrayable<number> | Promise<number> | Arrayable<string> | Arrayable<boolean> | Arrayable<null> | Arrayable<FunctionalModel> | Arrayable<Date> | Arrayable<undefined> |
|
|
44
|
+
readonly [s: string]: Arrayable<number> | Promise<number> | Arrayable<string> | Arrayable<boolean> | Arrayable<null> | Arrayable<FunctionalModel> | Arrayable<Date> | Arrayable<undefined> | ModelReference<any> | ModelInstanceMethod | ModelMethod;
|
|
45
45
|
} & {
|
|
46
46
|
readonly id?: PrimaryKeyType;
|
|
47
47
|
});
|
|
@@ -67,24 +67,24 @@ declare type PropertyValidatorComponentAsync<T extends FunctionalModel, TModel e
|
|
|
67
67
|
declare type PropertyValidatorComponent<T extends FunctionalModel, TModel extends Model<T> = Model<T>, TModelInstance extends ModelInstance<T, TModel> = ModelInstance<T, TModel>> = PropertyValidatorComponentSync<T, TModel, TModelInstance> | PropertyValidatorComponentAsync<T, TModel, TModelInstance>;
|
|
68
68
|
declare type PropertyValidator<T extends FunctionalModel, TModel extends Model<T> = Model<T>, TModelInstance extends ModelInstance<T, TModel> = ModelInstance<T, TModel>> = (instance: TModelInstance, instanceData: T | JsonAble, configurations: ValidatorConfiguration) => Promise<ValidationErrors>;
|
|
69
69
|
declare type ModelValidatorComponent<T extends FunctionalModel, TModel extends Model<T> = Model<T>, TModelInstance extends ModelInstance<T, TModel> = ModelInstance<T, TModel>> = (instance: TModelInstance, instanceData: T | JsonAble, configurations: ValidatorConfiguration) => Promise<ModelError>;
|
|
70
|
-
declare type ValueGetter<
|
|
71
|
-
declare type PropertyInstance<TValue extends Arrayable<FunctionalValue>> = {
|
|
70
|
+
declare type ValueGetter<TValue extends Arrayable<FunctionalValue>, T extends FunctionalModel = FunctionalModel, TModel extends Model<T> = Model<T>, TModelInstance extends ModelInstance<T, TModel> = ModelInstance<T, TModel>> = () => MaybePromise<TValue | TModelInstance>;
|
|
71
|
+
declare type PropertyInstance<TValue extends Arrayable<FunctionalValue>, T extends FunctionalModel = FunctionalModel, TModel extends Model<T> = Model<T>, TModelInstance extends ModelInstance<T, TModel> = ModelInstance<T, TModel>> = {
|
|
72
72
|
readonly getConfig: () => object;
|
|
73
73
|
readonly getChoices: () => readonly VeryPrimitivesTypes[];
|
|
74
74
|
readonly getDefaultValue: () => TValue;
|
|
75
75
|
readonly getConstantValue: () => TValue;
|
|
76
76
|
readonly getPropertyType: () => string;
|
|
77
|
-
readonly createGetter: (value: TValue) => ValueGetter<TValue>;
|
|
78
|
-
readonly getValidator:
|
|
77
|
+
readonly createGetter: (value: TValue) => ValueGetter<TValue, T, TModel, TModelInstance>;
|
|
78
|
+
readonly getValidator: (valueGetter: ValueGetter<TValue, T, TModel, TModelInstance>) => PropertyValidator<TModel>;
|
|
79
79
|
};
|
|
80
80
|
declare type PropertiesList<T extends FunctionalModel> = {
|
|
81
81
|
readonly [P in keyof T as T[P] extends Arrayable<FunctionalValue> ? P : never]: PropertyInstance<any>;
|
|
82
82
|
};
|
|
83
|
-
interface
|
|
84
|
-
readonly getReferencedId: (instanceValues:
|
|
85
|
-
readonly getReferencedModel: () =>
|
|
83
|
+
interface ModelReferencePropertyInstance<T extends FunctionalModel, TProperty extends Arrayable<FunctionalValue>, TModel extends Model<T> = Model<T>, TModelInstance extends ModelInstance<T, TModel> = ModelInstance<T, TModel>> extends PropertyInstance<TProperty> {
|
|
84
|
+
readonly getReferencedId: (instanceValues: ModelReference<T, TModel, TModelInstance>) => Maybe<PrimaryKeyType>;
|
|
85
|
+
readonly getReferencedModel: () => TModel;
|
|
86
86
|
}
|
|
87
|
-
declare type
|
|
87
|
+
declare type ModelReference<T extends FunctionalModel, TModel extends Model<T> = Model<T>, TModelInstance extends ModelInstance<T, TModel> = ModelInstance<T, TModel>> = TModelInstance | ModelInstanceInputData<T> | PrimaryKeyType;
|
|
88
88
|
declare type DefaultPropertyValidators = {
|
|
89
89
|
readonly required?: boolean;
|
|
90
90
|
readonly isInteger?: boolean;
|
|
@@ -134,8 +134,8 @@ declare type Model<T extends FunctionalModel> = {
|
|
|
134
134
|
readonly create: (data: CreateParams<T>) => ModelInstance<T>;
|
|
135
135
|
readonly methods: ModelMethodGetters<T>;
|
|
136
136
|
};
|
|
137
|
-
declare type
|
|
138
|
-
readonly [s: string]: () =>
|
|
137
|
+
declare type ModelReferenceFunctions = {
|
|
138
|
+
readonly [s: string]: () => ModelReference<any>;
|
|
139
139
|
};
|
|
140
140
|
declare type PropertyValidators<T extends FunctionalModel, TModel extends Model<T> = Model<T>> = {
|
|
141
141
|
readonly [s: string]: PropertyValidator<T, TModel>;
|
|
@@ -145,7 +145,7 @@ declare type ModelInstance<T extends FunctionalModel, TModel extends Model<T> =
|
|
|
145
145
|
readonly id: () => MaybePromise<PrimaryKeyType>;
|
|
146
146
|
};
|
|
147
147
|
readonly methods: InstanceMethodGetters<T, TModel>;
|
|
148
|
-
readonly references:
|
|
148
|
+
readonly references: ModelReferenceFunctions;
|
|
149
149
|
readonly toObj: toObj<T>;
|
|
150
150
|
readonly getPrimaryKeyName: () => string;
|
|
151
151
|
readonly getPrimaryKey: () => PrimaryKeyType;
|
|
@@ -155,8 +155,8 @@ declare type ModelInstance<T extends FunctionalModel, TModel extends Model<T> =
|
|
|
155
155
|
};
|
|
156
156
|
declare type ValueRequired<T extends Arrayable<FunctionalValue>> = NonNullable<T>;
|
|
157
157
|
declare type ValueOptional<T extends Arrayable<FunctionalValue>> = Maybe<T>;
|
|
158
|
-
declare type ValueOptionalR<T extends FunctionalModel> = ValueOptional<
|
|
159
|
-
declare type ValueRequiredR<T extends FunctionalModel> = ValueRequired<
|
|
158
|
+
declare type ValueOptionalR<T extends FunctionalModel> = ValueOptional<ModelReference<T>>;
|
|
159
|
+
declare type ValueRequiredR<T extends FunctionalModel> = ValueRequired<ModelReference<T>>;
|
|
160
160
|
declare type IsAsync<T extends Arrayable<FunctionalValue>> = Promise<T>;
|
|
161
161
|
declare type PropertyModifier<T extends Arrayable<FunctionalValue>> = ValueRequired<T> | ValueOptional<T> | T;
|
|
162
162
|
declare type ModelOptions<T extends FunctionalModel, TModel extends Model<T> = Model<T>, TModelInstance extends ModelInstance<T, TModel> = ModelInstance<T, TModel>> = {
|
|
@@ -167,4 +167,4 @@ declare type OptionalModelOptions<T extends FunctionalModel, TModel extends Mode
|
|
|
167
167
|
readonly instanceCreatedCallback?: Nullable<Arrayable<(instance: TModelInstance) => void>>;
|
|
168
168
|
readonly [s: string]: any;
|
|
169
169
|
} | undefined;
|
|
170
|
-
export { MaybeFunction, Maybe, MaybePromise, Nullable, Arrayable, MaybeLazy, JsonAble, toObj, ModelInstance, Model, PropertyValidatorComponent, PropertyValidatorComponentSync, PropertyValidatorComponentAsync, PropertyValidator, ModelValidatorComponent, PropertyInstance, PropertyConfig, FunctionalValue, ValueGetter,
|
|
170
|
+
export { MaybeFunction, Maybe, MaybePromise, Nullable, Arrayable, MaybeLazy, JsonAble, toObj, ModelInstance, Model, PropertyValidatorComponent, PropertyValidatorComponentSync, PropertyValidatorComponentAsync, PropertyValidator, ModelValidatorComponent, PropertyInstance, PropertyConfig, FunctionalValue, ValueGetter, ModelReference, ModelDefinition, ModelOptions, ModelMethod, OptionalModelOptions, ModelReferencePropertyInstance, PropertyGetters, PropertyValidators, PropertyValidatorComponentTypeAdvanced, ModelInstanceMethod, FunctionalModel, ModelInstanceInputData, ModelMethodGetters, InstanceMethodGetters, ModelReferenceFunctions, ModelErrors, PrimaryKeyType, ModelFactory, ModelFetcher, CreateParams, ValidatorConfiguration, ValuePropertyValidatorComponent, ValueRequired, ValueOptional, ValueOptionalR, ValueRequiredR, PropertyModifier, ValidationErrors, ModelError, IsAsync, ModelInstanceMethodClient, ModelMethodClient, TypedJsonObj, JsonObj, };
|
package/interfaces.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":";;AAyeA,kCAAkC"}
|
package/models.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"models.js","sourceRoot":"","sources":["../src/models.ts"],"names":[],"mappings":";;;;;;AAAA,yDAAgC;AAChC,mDAA4C;AAC5C,6CAAmD;AACnD,6CAAuC;AAsBvC,MAAM,eAAe,GAAG,GAGK,EAAE,CAAC,CAAC;IAC/B,uBAAuB,EAAE,IAAI;CAC9B,CAAC,CAAA;AAEF,MAAM,eAAe,GAAG,CAKtB,OAAyD,EACzD,EAAE;IACF,MAAM,CAAC,GAA4C,IAAA,eAAK,EACtD,EAAE,EACF,eAAe,EAAE,EACjB,OAAO,CACR,CAAA;IACD,OAAO,CAAC,CAAA;AACV,CAAC,CAAA;AAED,MAAM,6BAA6B,GAAG,CAKpC,aAAyD,EACb,EAAE;IAC9C,OAAO;QACL,iBAAiB,EAAE,GAAG,EAAE,CAAC,IAAI;QAC7B,YAAY,EAAE,aAAa,CAAC,YAAY;QACxC,eAAe,EAAE,aAAa,CAAC,eAAe;QAC9C,UAAU,kBACR,EAAE,EAAE,IAAA,qBAAQ,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,IAC7B,aAAa,CAA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