c2-mongoose 2.1.330 → 2.1.332
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.
|
@@ -0,0 +1,72 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
var GetHighestNumberFlow = /** @class */ (function () {
|
|
40
|
+
function GetHighestNumberFlow() {
|
|
41
|
+
}
|
|
42
|
+
GetHighestNumberFlow.prototype.exec = function (model, field) {
|
|
43
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
44
|
+
var result, highestCode;
|
|
45
|
+
var _a;
|
|
46
|
+
return __generator(this, function (_b) {
|
|
47
|
+
switch (_b.label) {
|
|
48
|
+
case 0: return [4 /*yield*/, model.aggregate([
|
|
49
|
+
{
|
|
50
|
+
$match: (_a = {},
|
|
51
|
+
_a[field] = { $regex: '^[0-9]+$' } // Filtra apenas códigos numéricos válidos
|
|
52
|
+
,
|
|
53
|
+
_a)
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
$group: {
|
|
57
|
+
_id: null,
|
|
58
|
+
maxCode: { $max: { $toInt: "$".concat(field) } }
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
])];
|
|
62
|
+
case 1:
|
|
63
|
+
result = _b.sent();
|
|
64
|
+
highestCode = result.length > 0 ? result[0].maxCode : 0;
|
|
65
|
+
return [2 /*return*/, highestCode + 1];
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
};
|
|
70
|
+
return GetHighestNumberFlow;
|
|
71
|
+
}());
|
|
72
|
+
exports.default = new GetHighestNumberFlow;
|
package/dist/index.d.ts
CHANGED
|
@@ -9,10 +9,11 @@ import BuildPipelineToJoinFlowItem from "./flow/item/BuildPipelineToJoinFlowItem
|
|
|
9
9
|
import BuildPopulateSingleFlowItem from "./flow/item/BuildPopulateSingleFlowItem";
|
|
10
10
|
import BuildSelectSingleFlowItem from "./flow/item/BuildSelectSingleFlowItem";
|
|
11
11
|
import ConvertToSearchResponseFlowItem from "./flow/item/ConvertToSearchResponseFlowItem";
|
|
12
|
+
import GetHighestNumberFlow from "./flow/searcher/GetHighestNumberFlow";
|
|
12
13
|
import SearcherV2Flow from "./flow/searcher/SearcherV2Flow";
|
|
13
14
|
import { IFacet } from "./model/Facet";
|
|
14
15
|
import { ILogger, LoggerModel, LoggerSearch, TypeOfOperation } from "./model/Logger";
|
|
15
16
|
import { Options } from "./types/Options";
|
|
16
17
|
import { Pagination, SearchResponse } from "./types/SearchResponse";
|
|
17
18
|
import { initialize } from "./utils/Utils";
|
|
18
|
-
export { AddStagePaginationFlowItem, AddStageSortFlowItem, BuildPipelineToCountJoinFlowItem, BuildPipelineToJoinFlowItem, BuildPopulateSingleFlowItem, BuildSelectSingleFlowItem, C2Flow, ConvertToSearchResponseFlowItem, CrudFlow, IFacet, ILogger, LoggerModel, LoggerSearch, Options, Pagination, SearchFlow, SearchResponse, SearcherFlow, TypeOfOperation, initialize, SearcherV2Flow };
|
|
19
|
+
export { GetHighestNumberFlow, AddStagePaginationFlowItem, AddStageSortFlowItem, BuildPipelineToCountJoinFlowItem, BuildPipelineToJoinFlowItem, BuildPopulateSingleFlowItem, BuildSelectSingleFlowItem, C2Flow, ConvertToSearchResponseFlowItem, CrudFlow, IFacet, ILogger, LoggerModel, LoggerSearch, Options, Pagination, SearchFlow, SearchResponse, SearcherFlow, TypeOfOperation, initialize, SearcherV2Flow };
|
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 = void 0;
|
|
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;
|
|
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"));
|
|
@@ -26,6 +26,8 @@ var BuildSelectSingleFlowItem_1 = __importDefault(require("./flow/item/BuildSele
|
|
|
26
26
|
exports.BuildSelectSingleFlowItem = BuildSelectSingleFlowItem_1.default;
|
|
27
27
|
var ConvertToSearchResponseFlowItem_1 = __importDefault(require("./flow/item/ConvertToSearchResponseFlowItem"));
|
|
28
28
|
exports.ConvertToSearchResponseFlowItem = ConvertToSearchResponseFlowItem_1.default;
|
|
29
|
+
var GetHighestNumberFlow_1 = __importDefault(require("./flow/searcher/GetHighestNumberFlow"));
|
|
30
|
+
exports.GetHighestNumberFlow = GetHighestNumberFlow_1.default;
|
|
29
31
|
var SearcherV2Flow_1 = __importDefault(require("./flow/searcher/SearcherV2Flow"));
|
|
30
32
|
exports.SearcherV2Flow = SearcherV2Flow_1.default;
|
|
31
33
|
var Logger_1 = require("./model/Logger");
|
package/package.json
CHANGED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import mongoose from "mongoose";
|
|
2
|
+
|
|
3
|
+
class GetHighestNumberFlow {
|
|
4
|
+
async exec(model: mongoose.Model<any>, field: string) {
|
|
5
|
+
const result = await model.aggregate([
|
|
6
|
+
{
|
|
7
|
+
$match: {
|
|
8
|
+
[field]: { $regex: '^[0-9]+$' } // Filtra apenas códigos numéricos válidos
|
|
9
|
+
}
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
$group: {
|
|
13
|
+
_id: null,
|
|
14
|
+
maxCode: { $max: { $toInt: `$${field}` } }
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
]);
|
|
18
|
+
|
|
19
|
+
const highestCode = result.length > 0 ? result[0].maxCode : 0;
|
|
20
|
+
return highestCode + 1
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export default new GetHighestNumberFlow
|
package/src/index.ts
CHANGED
|
@@ -9,6 +9,7 @@ import BuildPipelineToJoinFlowItem from "./flow/item/BuildPipelineToJoinFlowItem
|
|
|
9
9
|
import BuildPopulateSingleFlowItem from "./flow/item/BuildPopulateSingleFlowItem"
|
|
10
10
|
import BuildSelectSingleFlowItem from "./flow/item/BuildSelectSingleFlowItem"
|
|
11
11
|
import ConvertToSearchResponseFlowItem from "./flow/item/ConvertToSearchResponseFlowItem"
|
|
12
|
+
import GetHighestNumberFlow from "./flow/searcher/GetHighestNumberFlow"
|
|
12
13
|
import SearcherV2Flow from "./flow/searcher/SearcherV2Flow"
|
|
13
14
|
import { IFacet } from "./model/Facet"
|
|
14
15
|
import { ILogger, LoggerModel, LoggerSearch, TypeOfOperation } from "./model/Logger"
|
|
@@ -18,5 +19,5 @@ import { initialize } from "./utils/Utils"
|
|
|
18
19
|
|
|
19
20
|
(global as any).LoggerRepository = undefined
|
|
20
21
|
|
|
21
|
-
export { AddStagePaginationFlowItem, AddStageSortFlowItem, BuildPipelineToCountJoinFlowItem, BuildPipelineToJoinFlowItem, BuildPopulateSingleFlowItem, BuildSelectSingleFlowItem, C2Flow, ConvertToSearchResponseFlowItem, CrudFlow, IFacet, ILogger, LoggerModel, LoggerSearch, Options, Pagination, SearchFlow, SearchResponse, SearcherFlow, TypeOfOperation, initialize, SearcherV2Flow }
|
|
22
|
+
export { GetHighestNumberFlow, AddStagePaginationFlowItem, AddStageSortFlowItem, BuildPipelineToCountJoinFlowItem, BuildPipelineToJoinFlowItem, BuildPopulateSingleFlowItem, BuildSelectSingleFlowItem, C2Flow, ConvertToSearchResponseFlowItem, CrudFlow, IFacet, ILogger, LoggerModel, LoggerSearch, Options, Pagination, SearchFlow, SearchResponse, SearcherFlow, TypeOfOperation, initialize, SearcherV2Flow }
|
|
22
23
|
|