c2-mongoose 2.1.341 → 2.1.344
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/dist/flow/searcher/GetOneByFilterFlow.js +1 -1
- package/dist/flow/searcher/SearcherV2Flow.js +1 -1
- package/dist/flow/searcher/item/GetFieldDefinitionFlowItem.d.ts +12 -0
- package/dist/flow/searcher/item/GetFieldDefinitionFlowItem.js +20 -0
- package/dist/flow/searcher/item/PopulateFlowItem.js +6 -10
- package/dist/index.d.ts +2 -1
- package/dist/index.js +3 -1
- package/package.json +1 -1
- package/src/flow/searcher/GetOneByFilterFlow.ts +1 -1
- package/src/flow/searcher/SearcherV2Flow.ts +1 -1
- package/src/flow/searcher/item/GetFieldDefinitionFlowItem.ts +17 -0
- package/src/flow/searcher/item/PopulateFlowItem.ts +8 -11
- package/src/index.ts +2 -1
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import mongoose from "mongoose";
|
|
2
|
+
declare class GetFieldDefinitionFlowItem {
|
|
3
|
+
execute(modelRoot: mongoose.Model<any, {}, {}, {}, any, any>, first: string): mongoose.SchemaType<any, mongoose.Document<unknown, {}, mongoose.FlatRecord<{
|
|
4
|
+
[x: string]: any;
|
|
5
|
+
}>> & Omit<mongoose.FlatRecord<{
|
|
6
|
+
[x: string]: any;
|
|
7
|
+
}> & Required<{
|
|
8
|
+
_id: unknown;
|
|
9
|
+
}>, never>>;
|
|
10
|
+
}
|
|
11
|
+
declare const _default: GetFieldDefinitionFlowItem;
|
|
12
|
+
export default _default;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var GetFieldDefinitionFlowItem = /** @class */ (function () {
|
|
4
|
+
function GetFieldDefinitionFlowItem() {
|
|
5
|
+
}
|
|
6
|
+
GetFieldDefinitionFlowItem.prototype.execute = function (modelRoot, first) {
|
|
7
|
+
var fieldDefinition = modelRoot.schema.path(first);
|
|
8
|
+
if (!fieldDefinition && modelRoot.discriminators) {
|
|
9
|
+
for (var _i = 0, _a = Object.entries(modelRoot.discriminators); _i < _a.length; _i++) {
|
|
10
|
+
var _b = _a[_i], name_1 = _b[0], discriminatorModel = _b[1];
|
|
11
|
+
fieldDefinition = discriminatorModel.schema.path(first);
|
|
12
|
+
if (fieldDefinition)
|
|
13
|
+
break;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
return fieldDefinition;
|
|
17
|
+
};
|
|
18
|
+
return GetFieldDefinitionFlowItem;
|
|
19
|
+
}());
|
|
20
|
+
exports.default = new GetFieldDefinitionFlowItem;
|
|
@@ -8,7 +8,11 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
8
8
|
}
|
|
9
9
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
10
10
|
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
11
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
var GetFieldDefinitionFlowItem_1 = __importDefault(require("./GetFieldDefinitionFlowItem"));
|
|
12
16
|
var PopulateFlowItem = /** @class */ (function () {
|
|
13
17
|
function PopulateFlowItem() {
|
|
14
18
|
}
|
|
@@ -18,26 +22,18 @@ var PopulateFlowItem = /** @class */ (function () {
|
|
|
18
22
|
populate.forEach(function (populateField) {
|
|
19
23
|
var _a, _b;
|
|
20
24
|
var _c = populateField.split('.'), first = _c[0], rest = _c.slice(1);
|
|
21
|
-
var fieldDefinition =
|
|
25
|
+
var fieldDefinition = GetFieldDefinitionFlowItem_1.default.execute(modelRoot, first);
|
|
22
26
|
if (!fieldDefinition)
|
|
23
27
|
return;
|
|
24
28
|
var typeFirst = fieldDefinition.instance;
|
|
25
29
|
while ((typeFirst === 'Array' || typeFirst === 'Embedded') && (rest === null || rest === void 0 ? void 0 : rest.length)) {
|
|
26
30
|
first = [first, rest[0]].join(".");
|
|
27
31
|
rest.splice(0, 1);
|
|
28
|
-
fieldDefinition =
|
|
32
|
+
fieldDefinition = GetFieldDefinitionFlowItem_1.default.execute(modelRoot, first);
|
|
29
33
|
if (!fieldDefinition)
|
|
30
34
|
return;
|
|
31
35
|
typeFirst = fieldDefinition.instance;
|
|
32
36
|
}
|
|
33
|
-
// let typeFirst = fieldDefinition.instance
|
|
34
|
-
// if (typeFirst === 'Array' || typeFirst === 'Embedded') {
|
|
35
|
-
// if (rest?.length) {
|
|
36
|
-
// first = [first, rest[0]].join(".")
|
|
37
|
-
// rest.splice(0, 1)
|
|
38
|
-
// fieldDefinition = modelRoot.schema.path(first);
|
|
39
|
-
// }
|
|
40
|
-
// }
|
|
41
37
|
if (!fieldDefinition || !fieldDefinition.options || !fieldDefinition.options.ref) {
|
|
42
38
|
throw new Error("[1]No reference found for populate field: ".concat(populateField));
|
|
43
39
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -10,10 +10,11 @@ import BuildPopulateSingleFlowItem from "./flow/item/BuildPopulateSingleFlowItem
|
|
|
10
10
|
import BuildSelectSingleFlowItem from "./flow/item/BuildSelectSingleFlowItem";
|
|
11
11
|
import ConvertToSearchResponseFlowItem from "./flow/item/ConvertToSearchResponseFlowItem";
|
|
12
12
|
import GetHighestNumberFlow from "./flow/searcher/GetHighestNumberFlow";
|
|
13
|
+
import GetOneByFilterFlow from "./flow/searcher/GetOneByFilterFlow";
|
|
13
14
|
import SearcherV2Flow from "./flow/searcher/SearcherV2Flow";
|
|
14
15
|
import { IFacet } from "./model/Facet";
|
|
15
16
|
import { ILogger, LoggerModel, LoggerSearch, TypeOfOperation } from "./model/Logger";
|
|
16
17
|
import { Options } from "./types/Options";
|
|
17
18
|
import { Pagination, SearchResponse } from "./types/SearchResponse";
|
|
18
19
|
import { initialize } from "./utils/Utils";
|
|
19
|
-
export { GetHighestNumberFlow, AddStagePaginationFlowItem, AddStageSortFlowItem, BuildPipelineToCountJoinFlowItem, BuildPipelineToJoinFlowItem, BuildPopulateSingleFlowItem, BuildSelectSingleFlowItem, C2Flow, ConvertToSearchResponseFlowItem, CrudFlow, IFacet, ILogger, LoggerModel, LoggerSearch, Options, Pagination, SearchFlow, SearchResponse, SearcherFlow, TypeOfOperation, initialize, SearcherV2Flow };
|
|
20
|
+
export { GetHighestNumberFlow, AddStagePaginationFlowItem, AddStageSortFlowItem, BuildPipelineToCountJoinFlowItem, BuildPipelineToJoinFlowItem, BuildPopulateSingleFlowItem, BuildSelectSingleFlowItem, C2Flow, ConvertToSearchResponseFlowItem, CrudFlow, IFacet, ILogger, LoggerModel, LoggerSearch, Options, Pagination, SearchFlow, SearchResponse, SearcherFlow, TypeOfOperation, initialize, SearcherV2Flow, GetOneByFilterFlow };
|
package/dist/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.SearcherV2Flow = exports.initialize = exports.TypeOfOperation = exports.SearcherFlow = exports.SearchFlow = exports.LoggerSearch = exports.LoggerModel = exports.CrudFlow = exports.ConvertToSearchResponseFlowItem = exports.C2Flow = exports.BuildSelectSingleFlowItem = exports.BuildPopulateSingleFlowItem = exports.BuildPipelineToJoinFlowItem = exports.BuildPipelineToCountJoinFlowItem = exports.AddStageSortFlowItem = exports.AddStagePaginationFlowItem = exports.GetHighestNumberFlow = void 0;
|
|
6
|
+
exports.GetOneByFilterFlow = exports.SearcherV2Flow = exports.initialize = exports.TypeOfOperation = exports.SearcherFlow = exports.SearchFlow = exports.LoggerSearch = exports.LoggerModel = exports.CrudFlow = exports.ConvertToSearchResponseFlowItem = exports.C2Flow = exports.BuildSelectSingleFlowItem = exports.BuildPopulateSingleFlowItem = exports.BuildPipelineToJoinFlowItem = exports.BuildPipelineToCountJoinFlowItem = exports.AddStageSortFlowItem = exports.AddStagePaginationFlowItem = exports.GetHighestNumberFlow = void 0;
|
|
7
7
|
var C2Flow_1 = __importDefault(require("./flow/C2Flow"));
|
|
8
8
|
exports.C2Flow = C2Flow_1.default;
|
|
9
9
|
var CrudFlow_1 = __importDefault(require("./flow/CrudFlow"));
|
|
@@ -28,6 +28,8 @@ var ConvertToSearchResponseFlowItem_1 = __importDefault(require("./flow/item/Con
|
|
|
28
28
|
exports.ConvertToSearchResponseFlowItem = ConvertToSearchResponseFlowItem_1.default;
|
|
29
29
|
var GetHighestNumberFlow_1 = __importDefault(require("./flow/searcher/GetHighestNumberFlow"));
|
|
30
30
|
exports.GetHighestNumberFlow = GetHighestNumberFlow_1.default;
|
|
31
|
+
var GetOneByFilterFlow_1 = __importDefault(require("./flow/searcher/GetOneByFilterFlow"));
|
|
32
|
+
exports.GetOneByFilterFlow = GetOneByFilterFlow_1.default;
|
|
31
33
|
var SearcherV2Flow_1 = __importDefault(require("./flow/searcher/SearcherV2Flow"));
|
|
32
34
|
exports.SearcherV2Flow = SearcherV2Flow_1.default;
|
|
33
35
|
var Logger_1 = require("./model/Logger");
|
package/package.json
CHANGED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import mongoose from "mongoose";
|
|
2
|
+
|
|
3
|
+
class GetFieldDefinitionFlowItem {
|
|
4
|
+
execute(modelRoot: mongoose.Model<any, {}, {}, {}, any, any>, first: string) {
|
|
5
|
+
let fieldDefinition = modelRoot.schema.path(first);
|
|
6
|
+
|
|
7
|
+
if (!fieldDefinition && modelRoot.discriminators) {
|
|
8
|
+
for (const [name, discriminatorModel] of Object.entries(modelRoot.discriminators)) {
|
|
9
|
+
fieldDefinition = discriminatorModel.schema.path(first);
|
|
10
|
+
if (fieldDefinition) break;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
return fieldDefinition;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export default new GetFieldDefinitionFlowItem
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import mongoose from "mongoose";
|
|
2
|
+
import GetFieldDefinitionFlowItem from "./GetFieldDefinitionFlowItem";
|
|
2
3
|
|
|
3
4
|
class PopulateFlowItem {
|
|
4
5
|
exec(populate = [], modelRoot: mongoose.Model<any>): any[] {
|
|
@@ -7,26 +8,22 @@ class PopulateFlowItem {
|
|
|
7
8
|
let [first, ...rest] = populateField.split('.')
|
|
8
9
|
|
|
9
10
|
|
|
10
|
-
let fieldDefinition =
|
|
11
|
+
let fieldDefinition = GetFieldDefinitionFlowItem.execute(modelRoot, first);
|
|
12
|
+
|
|
11
13
|
if (!fieldDefinition) return
|
|
12
14
|
|
|
13
15
|
let typeFirst = fieldDefinition.instance
|
|
16
|
+
|
|
14
17
|
while ((typeFirst === 'Array' || typeFirst === 'Embedded') && rest?.length) {
|
|
15
18
|
first = [first, rest[0]].join(".")
|
|
16
19
|
rest.splice(0, 1)
|
|
17
|
-
|
|
20
|
+
|
|
21
|
+
fieldDefinition = GetFieldDefinitionFlowItem.execute(modelRoot, first);
|
|
22
|
+
|
|
18
23
|
if (!fieldDefinition) return;
|
|
19
24
|
typeFirst = fieldDefinition.instance
|
|
20
25
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
// if (typeFirst === 'Array' || typeFirst === 'Embedded') {
|
|
24
|
-
// if (rest?.length) {
|
|
25
|
-
// first = [first, rest[0]].join(".")
|
|
26
|
-
// rest.splice(0, 1)
|
|
27
|
-
// fieldDefinition = modelRoot.schema.path(first);
|
|
28
|
-
// }
|
|
29
|
-
// }
|
|
26
|
+
|
|
30
27
|
|
|
31
28
|
if (!fieldDefinition || !fieldDefinition.options || !fieldDefinition.options.ref) {
|
|
32
29
|
throw new Error(`[1]No reference found for populate field: ${populateField}`);
|
package/src/index.ts
CHANGED
|
@@ -10,6 +10,7 @@ import BuildPopulateSingleFlowItem from "./flow/item/BuildPopulateSingleFlowItem
|
|
|
10
10
|
import BuildSelectSingleFlowItem from "./flow/item/BuildSelectSingleFlowItem"
|
|
11
11
|
import ConvertToSearchResponseFlowItem from "./flow/item/ConvertToSearchResponseFlowItem"
|
|
12
12
|
import GetHighestNumberFlow from "./flow/searcher/GetHighestNumberFlow"
|
|
13
|
+
import GetOneByFilterFlow from "./flow/searcher/GetOneByFilterFlow"
|
|
13
14
|
import SearcherV2Flow from "./flow/searcher/SearcherV2Flow"
|
|
14
15
|
import { IFacet } from "./model/Facet"
|
|
15
16
|
import { ILogger, LoggerModel, LoggerSearch, TypeOfOperation } from "./model/Logger"
|
|
@@ -19,5 +20,5 @@ import { initialize } from "./utils/Utils"
|
|
|
19
20
|
|
|
20
21
|
(global as any).LoggerRepository = undefined
|
|
21
22
|
|
|
22
|
-
export { GetHighestNumberFlow, AddStagePaginationFlowItem, AddStageSortFlowItem, BuildPipelineToCountJoinFlowItem, BuildPipelineToJoinFlowItem, BuildPopulateSingleFlowItem, BuildSelectSingleFlowItem, C2Flow, ConvertToSearchResponseFlowItem, CrudFlow, IFacet, ILogger, LoggerModel, LoggerSearch, Options, Pagination, SearchFlow, SearchResponse, SearcherFlow, TypeOfOperation, initialize, SearcherV2Flow }
|
|
23
|
+
export { GetHighestNumberFlow, AddStagePaginationFlowItem, AddStageSortFlowItem, BuildPipelineToCountJoinFlowItem, BuildPipelineToJoinFlowItem, BuildPopulateSingleFlowItem, BuildSelectSingleFlowItem, C2Flow, ConvertToSearchResponseFlowItem, CrudFlow, IFacet, ILogger, LoggerModel, LoggerSearch, Options, Pagination, SearchFlow, SearchResponse, SearcherFlow, TypeOfOperation, initialize, SearcherV2Flow, GetOneByFilterFlow }
|
|
23
24
|
|