@adaptivestone/framework 5.0.0-beta.20 → 5.0.0-beta.22
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/CHANGELOG.md
CHANGED
|
@@ -37,6 +37,15 @@ Main feature of that release is full TypeScript support insluding mongoose model
|
|
|
37
37
|
[BREAKING] ESM only. No more commonJS. That help to fix a lot of bugs with tests and provides better development expirience
|
|
38
38
|
[BREAKING] Mongoose v8. https://mongoosejs.com/docs/migrating_to_8.html
|
|
39
39
|
|
|
40
|
+
|
|
41
|
+
### 5.0.0-beta.22
|
|
42
|
+
|
|
43
|
+
[UPDATE] update types
|
|
44
|
+
|
|
45
|
+
### 5.0.0-beta.21
|
|
46
|
+
|
|
47
|
+
[FIX] fix bug with missed model options
|
|
48
|
+
|
|
40
49
|
### 5.0.0-beta.20
|
|
41
50
|
|
|
42
51
|
[FIX] fix bug with Lock model index
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Model } from 'mongoose';
|
|
2
|
-
import type { Schema, InferRawDocType } from 'mongoose';
|
|
2
|
+
import type { Schema, InferRawDocType, HydratedDocument } from 'mongoose';
|
|
3
3
|
export type Merge<M, N> = Omit<M, keyof N> & N;
|
|
4
4
|
export type WithTimestamps<TOptions> = TOptions extends {
|
|
5
5
|
timestamps: true;
|
|
@@ -16,15 +16,23 @@ export type ExtractProperty<T, K extends PropertyKey, Default = {}> = T extends
|
|
|
16
16
|
[P in K]: infer R;
|
|
17
17
|
} ? R : Default;
|
|
18
18
|
export type GetModelSchemaTypeFromClass<T extends typeof BaseModel> = Schema<InferRawDocType<ExtractProperty<T, 'modelSchema'> & WithTimestamps<Merge<typeof defaultOptions, ExtractProperty<T, 'schemaOptions'>>>>, // TRawDocType
|
|
19
|
-
Model<
|
|
19
|
+
Model<InferRawDocType<ExtractProperty<T, 'modelSchema'> & WithTimestamps<Merge<typeof defaultOptions, ExtractProperty<T, 'schemaOptions'>>>>, {}, // TQueryHelpers
|
|
20
|
+
ExtractProperty<T, 'modelInstanceMethods'>, // TInstanceMethods
|
|
21
|
+
ExtractProperty<T, 'modelVirtuals'>>, // TModelType
|
|
20
22
|
ExtractProperty<T, 'modelInstanceMethods'>, // TInstanceMethods
|
|
21
23
|
{}, // TQueryHelpers
|
|
22
24
|
ExtractProperty<T, 'modelVirtuals'>, // TVirtuals
|
|
23
25
|
ExtractProperty<T, 'modelStatics'>, // TStaticMethods
|
|
24
26
|
ExtractProperty<T, 'schemaOptions'>>;
|
|
25
27
|
export type GetModelTypeFromClass<T extends typeof BaseModel> = Model<InferRawDocType<ExtractProperty<T, 'modelSchema'> & WithTimestamps<Merge<typeof defaultOptions, ExtractProperty<T, 'schemaOptions'>>>>, // TRawDocType
|
|
28
|
+
{}, // TQueryHelpers
|
|
26
29
|
ExtractProperty<T, 'modelInstanceMethods'>, // TInstanceMethods
|
|
27
|
-
|
|
30
|
+
ExtractProperty<T, 'modelVirtuals'>, // TVirtuals
|
|
31
|
+
HydratedDocument<InferRawDocType<ExtractProperty<T, 'modelSchema'> & WithTimestamps<Merge<typeof defaultOptions, ExtractProperty<T, 'schemaOptions'>>>>, //TRawDocType
|
|
32
|
+
//TRawDocType
|
|
33
|
+
ExtractProperty<T, 'modelVirtuals'> & ExtractProperty<T, 'modelInstanceMethods'>, // TVirtuals & TInstanceMethods
|
|
34
|
+
{}, // TQueryHelpers
|
|
35
|
+
ExtractProperty<T, 'modelVirtuals'>>, GetModelSchemaTypeFromClass<T>> & ExtractProperty<T, 'modelStatics'>;
|
|
28
36
|
export type GetModelTypeLiteFromSchema<T extends typeof BaseModel.modelSchema, TOptions = {}> = Model<InferRawDocType<T & WithTimestamps<Merge<typeof defaultOptions, TOptions>>>>;
|
|
29
37
|
export declare const defaultOptions: {
|
|
30
38
|
readonly timestamps: true;
|
|
@@ -22,6 +22,7 @@ export class BaseModel {
|
|
|
22
22
|
// Properly typed static method with generic constraints
|
|
23
23
|
static initialize() {
|
|
24
24
|
const schema = new mongoose.Schema(this.modelSchema, {
|
|
25
|
+
...defaultOptions,
|
|
25
26
|
...this.schemaOptions,
|
|
26
27
|
methods: this.modelInstanceMethods,
|
|
27
28
|
statics: this.modelStatics,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseModel.js","sourceRoot":"","sources":["../../src/modules/BaseModel.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,EAAE,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"BaseModel.js","sourceRoot":"","sources":["../../src/modules/BaseModel.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,EAAE,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAoF3C,MAAM,CAAC,MAAM,cAAc,GAAG,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAW,CAAC;AAE7E,MAAM,OAAO,SAAS;IACpB,MAAM,KAAK,WAAW;QACpB,OAAO,EAAW,CAAC;IACrB,CAAC;IAED,MAAM,KAAK,aAAa;QACtB,OAAO,EAAW,CAAC;IACrB,CAAC;IAED,MAAM,KAAK,oBAAoB;QAC7B,OAAO,EAAW,CAAC;IACrB,CAAC;IAED,MAAM,KAAK,aAAa;QACtB,OAAO,EAAW,CAAC;IACrB,CAAC;IAED,MAAM,KAAK,YAAY;QACrB,OAAO,EAAW,CAAC;IACrB,CAAC;IAED,MAAM,CAAC,SAAS,CAAC,MAAc;QAC7B,iBAAiB;IACnB,CAAC;IAED,wDAAwD;IACjD,MAAM,CAAC,UAAU;QACtB,MAAM,MAAM,GAAG,IAAI,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,EAAE;YACnD,GAAG,cAAc;YACjB,GAAI,IAAI,CAAC,aAA+B;YACxC,OAAO,EAAE,IAAI,CAAC,oBAAoB;YAClC,OAAO,EAAE,IAAI,CAAC,YAAY;YAC1B,QAAQ,EAAE,IAAI,CAAC,aAAa;SAC7B,CAAmC,CAAC;QAErC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QAEvB,MAAM,aAAa,GAAG,QAAQ,CAAC,KAAK,CAClC,IAAI,CAAC,IAAI,EACT,MAAM,CACqB,CAAC;QAE9B,OAAO,aAAa,CAAC;IACvB,CAAC;CACF"}
|