c2-mongoose 2.1.347 → 2.1.350
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/C2Flow.js +1 -1
- package/dist/flow/CrudFlow.js +1 -1
- package/dist/flow/searcher/v2/item/GetFieldDefinitionFlowItem.d.ts +6 -4
- package/dist/flow/searcher/v3/item/GetFieldDefinitionFlowItem.d.ts +6 -4
- package/dist/index.d.ts +2 -1
- package/dist/index.js +3 -1
- package/dist/model/Logger.d.ts +10 -8
- package/package.json +2 -2
- package/src/flow/C2Flow.ts +1 -1
- package/src/flow/CrudFlow.ts +1 -1
- package/src/index.ts +2 -1
- package/dist/flow/item/GetStagePaginationFlowItem.d.ts +0 -7
- package/dist/flow/item/GetStagePaginationFlowItem.js +0 -22
- package/dist/flow/item/GetStageSortFlowItem.d.ts +0 -7
- package/dist/flow/item/GetStageSortFlowItem.js +0 -17
- package/dist/flow/searcher/GetHighestNumberFlow.d.ts +0 -6
- package/dist/flow/searcher/GetHighestNumberFlow.js +0 -85
- package/dist/flow/searcher/GetOneByFilterFlow.d.ts +0 -6
- package/dist/flow/searcher/GetOneByFilterFlow.js +0 -81
- package/dist/flow/searcher/SearcherV2Flow.d.ts +0 -10
- package/dist/flow/searcher/SearcherV2Flow.js +0 -117
- package/dist/flow/searcher/item/BuildConditionFlowItem.d.ts +0 -6
- package/dist/flow/searcher/item/BuildConditionFlowItem.js +0 -130
- package/dist/flow/searcher/item/BuildPaginationDataFlowItem.d.ts +0 -5
- package/dist/flow/searcher/item/BuildPaginationDataFlowItem.js +0 -35
- package/dist/flow/searcher/item/BuildRegexFlowItem.d.ts +0 -5
- package/dist/flow/searcher/item/BuildRegexFlowItem.js +0 -24
- package/dist/flow/searcher/item/ExtractFieldsOfTypeFlowItem.d.ts +0 -6
- package/dist/flow/searcher/item/ExtractFieldsOfTypeFlowItem.js +0 -32
- package/dist/flow/searcher/item/GetFieldDefinitionFlowItem.d.ts +0 -12
- package/dist/flow/searcher/item/GetFieldDefinitionFlowItem.js +0 -20
- package/dist/flow/searcher/item/GetTypeOfFieldInModelFlowItem.d.ts +0 -6
- package/dist/flow/searcher/item/GetTypeOfFieldInModelFlowItem.js +0 -12
- package/dist/flow/searcher/item/GroupFlowItem.d.ts +0 -6
- package/dist/flow/searcher/item/GroupFlowItem.js +0 -80
- package/dist/flow/searcher/item/IsValidObjectIdFlowItem.d.ts +0 -5
- package/dist/flow/searcher/item/IsValidObjectIdFlowItem.js +0 -12
- package/dist/flow/searcher/item/MatchFlowItem.d.ts +0 -8
- package/dist/flow/searcher/item/MatchFlowItem.js +0 -132
- package/dist/flow/searcher/item/NormalizeValueFlowItem.d.ts +0 -5
- package/dist/flow/searcher/item/NormalizeValueFlowItem.js +0 -25
- package/dist/flow/searcher/item/PopulateFlowItem.d.ts +0 -6
- package/dist/flow/searcher/item/PopulateFlowItem.js +0 -104
- package/dist/flow/searcher/item/ProjectFlowItem.d.ts +0 -5
- package/dist/flow/searcher/item/ProjectFlowItem.js +0 -42
- package/dist/flow/searcher/item/SortFlowItem.d.ts +0 -5
- package/dist/flow/searcher/item/SortFlowItem.js +0 -13
package/dist/flow/C2Flow.js
CHANGED
|
@@ -218,7 +218,7 @@ var C2Flow = /** @class */ (function () {
|
|
|
218
218
|
var dataAfter, log;
|
|
219
219
|
return __generator(this, function (_a) {
|
|
220
220
|
switch (_a.label) {
|
|
221
|
-
case 0: return [4 /*yield*/, this.repository.
|
|
221
|
+
case 0: return [4 /*yield*/, this.repository.findByIdAndDelete(_id, { session: options.session })];
|
|
222
222
|
case 1:
|
|
223
223
|
dataAfter = _a.sent();
|
|
224
224
|
if (options.logger === false) {
|
package/dist/flow/CrudFlow.js
CHANGED
|
@@ -61,7 +61,7 @@ var CrudFlow = /** @class */ (function () {
|
|
|
61
61
|
return __awaiter(this, void 0, void 0, function () {
|
|
62
62
|
return __generator(this, function (_a) {
|
|
63
63
|
switch (_a.label) {
|
|
64
|
-
case 0: return [4 /*yield*/, this.repository.
|
|
64
|
+
case 0: return [4 /*yield*/, this.repository.findByIdAndDelete(id, { session: session })];
|
|
65
65
|
case 1:
|
|
66
66
|
_a.sent();
|
|
67
67
|
return [2 /*return*/];
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import mongoose from "mongoose";
|
|
2
2
|
declare class GetFieldDefinitionFlowItem {
|
|
3
3
|
execute(modelRoot: mongoose.Model<any, {}, {}, {}, any, any>, first: string): mongoose.SchemaType<any, mongoose.Document<unknown, {}, mongoose.FlatRecord<{
|
|
4
|
-
[x: string]:
|
|
5
|
-
}
|
|
6
|
-
[x: string]:
|
|
4
|
+
[x: string]: unknown;
|
|
5
|
+
}>, {}> & mongoose.FlatRecord<{
|
|
6
|
+
[x: string]: unknown;
|
|
7
7
|
}> & Required<{
|
|
8
8
|
_id: unknown;
|
|
9
|
-
}
|
|
9
|
+
}> & {
|
|
10
|
+
__v: number;
|
|
11
|
+
}>;
|
|
10
12
|
}
|
|
11
13
|
declare const _default: GetFieldDefinitionFlowItem;
|
|
12
14
|
export default _default;
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import mongoose from "mongoose";
|
|
2
2
|
declare class GetFieldDefinitionFlowItem {
|
|
3
3
|
execute(modelRoot: mongoose.Model<any, {}, {}, {}, any, any>, first: string): mongoose.SchemaType<any, mongoose.Document<unknown, {}, mongoose.FlatRecord<{
|
|
4
|
-
[x: string]:
|
|
5
|
-
}
|
|
6
|
-
[x: string]:
|
|
4
|
+
[x: string]: unknown;
|
|
5
|
+
}>, {}> & mongoose.FlatRecord<{
|
|
6
|
+
[x: string]: unknown;
|
|
7
7
|
}> & Required<{
|
|
8
8
|
_id: unknown;
|
|
9
|
-
}
|
|
9
|
+
}> & {
|
|
10
|
+
__v: number;
|
|
11
|
+
}>;
|
|
10
12
|
}
|
|
11
13
|
declare const _default: GetFieldDefinitionFlowItem;
|
|
12
14
|
export default _default;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import mongoose from "mongoose";
|
|
1
2
|
import C2Flow from "./flow/C2Flow";
|
|
2
3
|
import CrudFlow from "./flow/CrudFlow";
|
|
3
4
|
import SearchFlow from "./flow/SearchFlow";
|
|
@@ -18,4 +19,4 @@ import { ILogger, LoggerModel, LoggerSearch, TypeOfOperation } from "./model/Log
|
|
|
18
19
|
import { Options } from "./types/Options";
|
|
19
20
|
import { Pagination, SearchResponse } from "./types/SearchResponse";
|
|
20
21
|
import { initialize } from "./utils/Utils";
|
|
21
|
-
export { GetHighestNumberFlow, AddStagePaginationFlowItem, AddStageSortFlowItem, BuildPipelineToCountJoinFlowItem, BuildPipelineToJoinFlowItem, BuildPopulateSingleFlowItem, BuildSelectSingleFlowItem, C2Flow, ConvertToSearchResponseFlowItem, CrudFlow, IFacet, ILogger, LoggerModel, LoggerSearch, Options, Pagination, SearchFlow, SearchResponse, SearcherFlow, TypeOfOperation, initialize, SearcherV2Flow, SearcherV3Flow, GetOneByFilterFlow };
|
|
22
|
+
export { mongoose, GetHighestNumberFlow, AddStagePaginationFlowItem, AddStageSortFlowItem, BuildPipelineToCountJoinFlowItem, BuildPipelineToJoinFlowItem, BuildPopulateSingleFlowItem, BuildSelectSingleFlowItem, C2Flow, ConvertToSearchResponseFlowItem, CrudFlow, IFacet, ILogger, LoggerModel, LoggerSearch, Options, Pagination, SearchFlow, SearchResponse, SearcherFlow, TypeOfOperation, initialize, SearcherV2Flow, SearcherV3Flow, GetOneByFilterFlow };
|
package/dist/index.js
CHANGED
|
@@ -3,7 +3,9 @@ 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.GetOneByFilterFlow = exports.SearcherV3Flow = 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.SearcherV3Flow = 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 = exports.mongoose = void 0;
|
|
7
|
+
var mongoose_1 = __importDefault(require("mongoose"));
|
|
8
|
+
exports.mongoose = mongoose_1.default;
|
|
7
9
|
var C2Flow_1 = __importDefault(require("./flow/C2Flow"));
|
|
8
10
|
exports.C2Flow = C2Flow_1.default;
|
|
9
11
|
var CrudFlow_1 = __importDefault(require("./flow/CrudFlow"));
|
package/dist/model/Logger.d.ts
CHANGED
|
@@ -16,38 +16,40 @@ interface ILogger {
|
|
|
16
16
|
filters: any;
|
|
17
17
|
notes: string;
|
|
18
18
|
}
|
|
19
|
-
declare const LoggerModel: mongoose.Schema<any, mongoose.Model<any, any, any, any, any, any>, {}, {}, {}, {},
|
|
19
|
+
declare const LoggerModel: mongoose.Schema<any, mongoose.Model<any, any, any, any, any, any>, {}, {}, {}, {}, {
|
|
20
20
|
timestamps: {
|
|
21
21
|
createdAt: string;
|
|
22
22
|
updatedAt: string;
|
|
23
23
|
};
|
|
24
|
-
}
|
|
24
|
+
}, {} & {
|
|
25
25
|
owner: Types.ObjectId;
|
|
26
26
|
user: Types.ObjectId;
|
|
27
27
|
collectionName: string;
|
|
28
28
|
operation: string;
|
|
29
29
|
data?: any;
|
|
30
30
|
filters?: any;
|
|
31
|
-
notes?: string | undefined;
|
|
32
|
-
}, mongoose.Document<unknown, {}, mongoose.FlatRecord<{
|
|
31
|
+
notes?: string | null | undefined;
|
|
32
|
+
}, mongoose.Document<unknown, {}, mongoose.FlatRecord<{} & {
|
|
33
33
|
owner: Types.ObjectId;
|
|
34
34
|
user: Types.ObjectId;
|
|
35
35
|
collectionName: string;
|
|
36
36
|
operation: string;
|
|
37
37
|
data?: any;
|
|
38
38
|
filters?: any;
|
|
39
|
-
notes?: string | undefined;
|
|
40
|
-
}
|
|
39
|
+
notes?: string | null | undefined;
|
|
40
|
+
}>, {}> & mongoose.FlatRecord<{} & {
|
|
41
41
|
owner: Types.ObjectId;
|
|
42
42
|
user: Types.ObjectId;
|
|
43
43
|
collectionName: string;
|
|
44
44
|
operation: string;
|
|
45
45
|
data?: any;
|
|
46
46
|
filters?: any;
|
|
47
|
-
notes?: string | undefined;
|
|
47
|
+
notes?: string | null | undefined;
|
|
48
48
|
}> & {
|
|
49
49
|
_id: Types.ObjectId;
|
|
50
|
-
}
|
|
50
|
+
} & {
|
|
51
|
+
__v: number;
|
|
52
|
+
}>;
|
|
51
53
|
declare class LoggerSearch extends SearchFlow {
|
|
52
54
|
model: Partial<ILogger>;
|
|
53
55
|
constructor(params: any);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "c2-mongoose",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.350",
|
|
4
4
|
"description": "Lib to make any search in database mongoose and use as basic crud",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"express-http-context": "^1.2.4",
|
|
33
33
|
"moment": "^2.29.4",
|
|
34
34
|
"moment-timezone": "^0.5.43",
|
|
35
|
-
"mongoose": "^
|
|
35
|
+
"mongoose": "^8.16.1"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"typescript": "^4.9.5"
|
package/src/flow/C2Flow.ts
CHANGED
|
@@ -129,7 +129,7 @@ class C2Flow<D> {
|
|
|
129
129
|
|
|
130
130
|
public async deleteById(_id: Types.ObjectId, options: Partial<Options>) {
|
|
131
131
|
|
|
132
|
-
let dataAfter = await this.repository.
|
|
132
|
+
let dataAfter = await this.repository.findByIdAndDelete(_id, { session: options.session })
|
|
133
133
|
|
|
134
134
|
if (options.logger === false) {
|
|
135
135
|
return
|
package/src/flow/CrudFlow.ts
CHANGED
|
@@ -22,7 +22,7 @@ class CrudFlow<D> {
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
public async delete(id: string, session: any = undefined) {
|
|
25
|
-
await this.repository.
|
|
25
|
+
await this.repository.findByIdAndDelete(id, { session })
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
public async deleteMany(conditions: {}, session: any = undefined) {
|
package/src/index.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import mongoose from "mongoose"
|
|
1
2
|
import C2Flow from "./flow/C2Flow"
|
|
2
3
|
import CrudFlow from "./flow/CrudFlow"
|
|
3
4
|
import SearchFlow from "./flow/SearchFlow"
|
|
@@ -21,6 +22,6 @@ import { initialize } from "./utils/Utils"
|
|
|
21
22
|
|
|
22
23
|
(global as any).LoggerRepository = undefined
|
|
23
24
|
|
|
24
|
-
export { GetHighestNumberFlow, AddStagePaginationFlowItem, AddStageSortFlowItem, BuildPipelineToCountJoinFlowItem, BuildPipelineToJoinFlowItem, BuildPopulateSingleFlowItem, BuildSelectSingleFlowItem, C2Flow, ConvertToSearchResponseFlowItem, CrudFlow, IFacet, ILogger, LoggerModel, LoggerSearch, Options, Pagination, SearchFlow, SearchResponse, SearcherFlow, TypeOfOperation, initialize,
|
|
25
|
+
export { mongoose, GetHighestNumberFlow, AddStagePaginationFlowItem, AddStageSortFlowItem, BuildPipelineToCountJoinFlowItem, BuildPipelineToJoinFlowItem, BuildPopulateSingleFlowItem, BuildSelectSingleFlowItem, C2Flow, ConvertToSearchResponseFlowItem, CrudFlow, IFacet, ILogger, LoggerModel, LoggerSearch, Options, Pagination, SearchFlow, SearchResponse, SearcherFlow, TypeOfOperation, initialize,
|
|
25
26
|
SearcherV2Flow, SearcherV3Flow, GetOneByFilterFlow }
|
|
26
27
|
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { IFacet } from "../../model/Facet";
|
|
2
|
-
import SearchFlow from "../SearchFlow";
|
|
3
|
-
declare class GetStagePaginationFlowItem {
|
|
4
|
-
get(facet: IFacet | undefined, searcher: SearchFlow): IFacet;
|
|
5
|
-
}
|
|
6
|
-
declare const _default: GetStagePaginationFlowItem;
|
|
7
|
-
export default _default;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
var GetStagePaginationFlowItem = /** @class */ (function () {
|
|
4
|
-
function GetStagePaginationFlowItem() {
|
|
5
|
-
}
|
|
6
|
-
GetStagePaginationFlowItem.prototype.get = function (facet, searcher) {
|
|
7
|
-
if (facet === void 0) { facet = { items: [] }; }
|
|
8
|
-
var facetAfter = facet;
|
|
9
|
-
if (searcher.pageable === false) {
|
|
10
|
-
return facetAfter;
|
|
11
|
-
}
|
|
12
|
-
facetAfter.items.push({ $skip: ((searcher.page - 1) * searcher.limit) });
|
|
13
|
-
facetAfter.items.push({ $limit: searcher.limit });
|
|
14
|
-
facetAfter.paging = [
|
|
15
|
-
{ $count: "total" },
|
|
16
|
-
{ $addFields: { page: searcher.page || 1, limit: searcher.limit } }
|
|
17
|
-
];
|
|
18
|
-
return facetAfter;
|
|
19
|
-
};
|
|
20
|
-
return GetStagePaginationFlowItem;
|
|
21
|
-
}());
|
|
22
|
-
exports.default = new GetStagePaginationFlowItem;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
var GetStageSortFlowItem = /** @class */ (function () {
|
|
4
|
-
function GetStageSortFlowItem() {
|
|
5
|
-
}
|
|
6
|
-
GetStageSortFlowItem.prototype.get = function (facet, searcher) {
|
|
7
|
-
var _a;
|
|
8
|
-
if (facet === void 0) { facet = { items: [] }; }
|
|
9
|
-
var facetAfter = facet;
|
|
10
|
-
var sortByDirection = searcher.order === "desc" ? -1 : 1;
|
|
11
|
-
var sortByField = searcher.orderBy || "_id";
|
|
12
|
-
facetAfter.items.push({ $sort: (_a = {}, _a["".concat(sortByField)] = sortByDirection, _a) });
|
|
13
|
-
return facetAfter;
|
|
14
|
-
};
|
|
15
|
-
return GetStageSortFlowItem;
|
|
16
|
-
}());
|
|
17
|
-
exports.default = new GetStageSortFlowItem;
|
|
@@ -1,85 +0,0 @@
|
|
|
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 __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
39
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
40
|
-
if (ar || !(i in from)) {
|
|
41
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
42
|
-
ar[i] = from[i];
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
46
|
-
};
|
|
47
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
48
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
49
|
-
};
|
|
50
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
51
|
-
var MatchFlowItem_1 = __importDefault(require("./item/MatchFlowItem"));
|
|
52
|
-
var GetHighestNumberFlow = /** @class */ (function () {
|
|
53
|
-
function GetHighestNumberFlow() {
|
|
54
|
-
}
|
|
55
|
-
GetHighestNumberFlow.prototype.exec = function (params, model, field) {
|
|
56
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
57
|
-
var result, highestCode;
|
|
58
|
-
var _a;
|
|
59
|
-
return __generator(this, function (_b) {
|
|
60
|
-
switch (_b.label) {
|
|
61
|
-
case 0: return [4 /*yield*/, model.aggregate(__spreadArray(__spreadArray([], MatchFlowItem_1.default.exec(params, model), true), [
|
|
62
|
-
{
|
|
63
|
-
$match: (_a = {},
|
|
64
|
-
_a[field] = { $regex: '^[0-9]+$' } // Filtra apenas códigos numéricos válidos
|
|
65
|
-
,
|
|
66
|
-
_a)
|
|
67
|
-
},
|
|
68
|
-
{
|
|
69
|
-
$group: {
|
|
70
|
-
_id: null,
|
|
71
|
-
maxCode: { $max: { $toInt: "$".concat(field) } }
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
], false))];
|
|
75
|
-
case 1:
|
|
76
|
-
result = _b.sent();
|
|
77
|
-
highestCode = result.length > 0 ? result[0].maxCode : 0;
|
|
78
|
-
return [2 /*return*/, highestCode + 1];
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
});
|
|
82
|
-
};
|
|
83
|
-
return GetHighestNumberFlow;
|
|
84
|
-
}());
|
|
85
|
-
exports.default = new GetHighestNumberFlow;
|
|
@@ -1,81 +0,0 @@
|
|
|
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 __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
39
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
40
|
-
if (ar || !(i in from)) {
|
|
41
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
42
|
-
ar[i] = from[i];
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
46
|
-
};
|
|
47
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
48
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
49
|
-
};
|
|
50
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
51
|
-
var MatchFlowItem_1 = __importDefault(require("./item/MatchFlowItem"));
|
|
52
|
-
var PopulateFlowItem_1 = __importDefault(require("./item/PopulateFlowItem"));
|
|
53
|
-
var ProjectFlowItem_1 = __importDefault(require("./item/ProjectFlowItem"));
|
|
54
|
-
var GetOneByFilterFlow = /** @class */ (function () {
|
|
55
|
-
function GetOneByFilterFlow() {
|
|
56
|
-
}
|
|
57
|
-
GetOneByFilterFlow.prototype.exec = function (params, model) {
|
|
58
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
59
|
-
var pipeline, result;
|
|
60
|
-
return __generator(this, function (_a) {
|
|
61
|
-
switch (_a.label) {
|
|
62
|
-
case 0:
|
|
63
|
-
pipeline = [];
|
|
64
|
-
pipeline = __spreadArray(__spreadArray([], pipeline, true), PopulateFlowItem_1.default.exec(params.populate, model), true);
|
|
65
|
-
pipeline = __spreadArray(__spreadArray([], pipeline, true), ProjectFlowItem_1.default.exec(params.select), true);
|
|
66
|
-
return [4 /*yield*/, model.aggregate(__spreadArray(__spreadArray([], MatchFlowItem_1.default.exec(params, model), true), pipeline, true), {
|
|
67
|
-
collation: {
|
|
68
|
-
locale: "pt",
|
|
69
|
-
numericOrdering: true
|
|
70
|
-
}
|
|
71
|
-
}).read('secondaryPreferred')];
|
|
72
|
-
case 1:
|
|
73
|
-
result = _a.sent();
|
|
74
|
-
return [2 /*return*/, result[0]];
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
});
|
|
78
|
-
};
|
|
79
|
-
return GetOneByFilterFlow;
|
|
80
|
-
}());
|
|
81
|
-
exports.default = new GetOneByFilterFlow;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import mongoose from "mongoose";
|
|
2
|
-
export interface IParams {
|
|
3
|
-
[key: string]: any;
|
|
4
|
-
mainFilter: any;
|
|
5
|
-
}
|
|
6
|
-
declare class SearcherV2Flow {
|
|
7
|
-
exec(params: IParams, model: mongoose.Model<any>): Promise<any>;
|
|
8
|
-
}
|
|
9
|
-
declare const _default: SearcherV2Flow;
|
|
10
|
-
export default _default;
|
|
@@ -1,117 +0,0 @@
|
|
|
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 __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
39
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
40
|
-
if (ar || !(i in from)) {
|
|
41
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
42
|
-
ar[i] = from[i];
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
46
|
-
};
|
|
47
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
48
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
49
|
-
};
|
|
50
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
51
|
-
var GroupFlowItem_1 = __importDefault(require("./item/GroupFlowItem"));
|
|
52
|
-
var PopulateFlowItem_1 = __importDefault(require("./item/PopulateFlowItem"));
|
|
53
|
-
var SortFlowItem_1 = __importDefault(require("./item/SortFlowItem"));
|
|
54
|
-
var ProjectFlowItem_1 = __importDefault(require("./item/ProjectFlowItem"));
|
|
55
|
-
var MatchFlowItem_1 = __importDefault(require("./item/MatchFlowItem"));
|
|
56
|
-
var BuildPaginationDataFlowItem_1 = __importDefault(require("./item/BuildPaginationDataFlowItem"));
|
|
57
|
-
var SearcherV2Flow = /** @class */ (function () {
|
|
58
|
-
function SearcherV2Flow() {
|
|
59
|
-
}
|
|
60
|
-
SearcherV2Flow.prototype.exec = function (params, model) {
|
|
61
|
-
var _a, _b, _c;
|
|
62
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
63
|
-
var facet, pipelineFacetPaging, pipelineFacetItems, result, ret;
|
|
64
|
-
return __generator(this, function (_d) {
|
|
65
|
-
switch (_d.label) {
|
|
66
|
-
case 0:
|
|
67
|
-
params.page = Number((_a = params.page) !== null && _a !== void 0 ? _a : 1);
|
|
68
|
-
params.limit = Number((_b = params.limit) !== null && _b !== void 0 ? _b : 50);
|
|
69
|
-
facet = {};
|
|
70
|
-
pipelineFacetPaging = [];
|
|
71
|
-
pipelineFacetItems = [];
|
|
72
|
-
pipelineFacetItems = __spreadArray(__spreadArray([], pipelineFacetItems, true), GroupFlowItem_1.default.exec(params.groupBy, params.sumFields, params.groupDetailed, model), true);
|
|
73
|
-
pipelineFacetItems = __spreadArray(__spreadArray([], pipelineFacetItems, true), PopulateFlowItem_1.default.exec(params.populate, model), true);
|
|
74
|
-
pipelineFacetItems = __spreadArray(__spreadArray([], pipelineFacetItems, true), MatchFlowItem_1.default.exec(params, model), true);
|
|
75
|
-
pipelineFacetItems = __spreadArray(__spreadArray([], pipelineFacetItems, true), SortFlowItem_1.default.exec(params.orderBy, params.orderSense), true);
|
|
76
|
-
pipelineFacetItems = __spreadArray(__spreadArray([], pipelineFacetItems, true), ProjectFlowItem_1.default.exec(params.select), true);
|
|
77
|
-
if (params.pageable !== false) {
|
|
78
|
-
pipelineFacetItems = __spreadArray(__spreadArray([], pipelineFacetItems, true), [
|
|
79
|
-
{ $skip: (params.page - 1) * (params.limit) },
|
|
80
|
-
{ $limit: params.limit }
|
|
81
|
-
], false);
|
|
82
|
-
pipelineFacetPaging = __spreadArray(__spreadArray(__spreadArray(__spreadArray([], GroupFlowItem_1.default.exec(params.groupBy, params.sumFields, params.groupDetailed, model), true), PopulateFlowItem_1.default.exec(params.populate, model), true), MatchFlowItem_1.default.exec(params, model), true), BuildPaginationDataFlowItem_1.default.exec(params.page, params.limit), true);
|
|
83
|
-
facet.paging = pipelineFacetPaging;
|
|
84
|
-
}
|
|
85
|
-
facet.items = pipelineFacetItems;
|
|
86
|
-
return [4 /*yield*/, model.aggregate(__spreadArray(__spreadArray([], MatchFlowItem_1.default.exec(params.mainFilter, model), true), [
|
|
87
|
-
{
|
|
88
|
-
$facet: facet
|
|
89
|
-
}
|
|
90
|
-
], false), {
|
|
91
|
-
collation: {
|
|
92
|
-
locale: "pt",
|
|
93
|
-
numericOrdering: true
|
|
94
|
-
}
|
|
95
|
-
}).read('secondaryPreferred')];
|
|
96
|
-
case 1:
|
|
97
|
-
result = _d.sent();
|
|
98
|
-
ret = {};
|
|
99
|
-
ret.items = result[0].items;
|
|
100
|
-
if (params.pageable !== false) {
|
|
101
|
-
ret.paging = (_c = result[0].paging[0]) !== null && _c !== void 0 ? _c : {
|
|
102
|
-
page: 1,
|
|
103
|
-
limit: 50,
|
|
104
|
-
total: 0,
|
|
105
|
-
totalPages: 0,
|
|
106
|
-
startIndex: 0,
|
|
107
|
-
endIndex: 0
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
return [2 /*return*/, ret];
|
|
111
|
-
}
|
|
112
|
-
});
|
|
113
|
-
});
|
|
114
|
-
};
|
|
115
|
-
return SearcherV2Flow;
|
|
116
|
-
}());
|
|
117
|
-
exports.default = new SearcherV2Flow;
|