elseware-nodejs 1.11.7 → 1.12.0
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/index.cjs +93 -35
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +31 -8
- package/dist/index.d.ts +31 -8
- package/dist/index.js +90 -31
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -5004,33 +5004,35 @@ var AsyncHandler = (fn) => (req, res, next) => {
|
|
|
5004
5004
|
Promise.resolve(fn(req, res, next)).catch(next);
|
|
5005
5005
|
};
|
|
5006
5006
|
|
|
5007
|
-
// src/infrastructure/http/query/
|
|
5008
|
-
var
|
|
5009
|
-
|
|
5010
|
-
|
|
5011
|
-
|
|
5012
|
-
"fields",
|
|
5013
|
-
|
|
5014
|
-
|
|
5015
|
-
|
|
5016
|
-
|
|
5017
|
-
|
|
5018
|
-
|
|
5019
|
-
|
|
5020
|
-
|
|
5021
|
-
|
|
5022
|
-
|
|
5023
|
-
|
|
5024
|
-
|
|
5025
|
-
|
|
5026
|
-
|
|
5027
|
-
"contains",
|
|
5028
|
-
"startsWith",
|
|
5029
|
-
"endsWith"
|
|
5030
|
-
];
|
|
5007
|
+
// src/infrastructure/http/query/ApiFeaturesConfig.ts
|
|
5008
|
+
var DefaultApiFeaturesConfig = {
|
|
5009
|
+
defaultPage: 1,
|
|
5010
|
+
defaultLimit: 100,
|
|
5011
|
+
maxLimit: 1e3,
|
|
5012
|
+
reservedFields: ["page", "limit", "sort", "fields", "populate"],
|
|
5013
|
+
supportedOperators: [
|
|
5014
|
+
"eq",
|
|
5015
|
+
"ne",
|
|
5016
|
+
"gt",
|
|
5017
|
+
"gte",
|
|
5018
|
+
"lt",
|
|
5019
|
+
"lte",
|
|
5020
|
+
"in",
|
|
5021
|
+
"nin",
|
|
5022
|
+
"contains",
|
|
5023
|
+
"startsWith",
|
|
5024
|
+
"endsWith"
|
|
5025
|
+
]
|
|
5026
|
+
};
|
|
5031
5027
|
|
|
5032
5028
|
// src/infrastructure/http/query/ApiFeatures.ts
|
|
5033
5029
|
var ApiFeatures = class {
|
|
5030
|
+
static getConfig() {
|
|
5031
|
+
return {
|
|
5032
|
+
...DefaultApiFeaturesConfig,
|
|
5033
|
+
...EJSContext.get().apiFeatures ?? {}
|
|
5034
|
+
};
|
|
5035
|
+
}
|
|
5034
5036
|
static parse(query) {
|
|
5035
5037
|
return {
|
|
5036
5038
|
filters: this.parseFilters(query),
|
|
@@ -5041,14 +5043,14 @@ var ApiFeatures = class {
|
|
|
5041
5043
|
};
|
|
5042
5044
|
}
|
|
5043
5045
|
static parseFilters(query) {
|
|
5046
|
+
const config = this.getConfig();
|
|
5044
5047
|
const filters = [];
|
|
5045
5048
|
Object.entries(query).forEach(([key, value]) => {
|
|
5046
|
-
if (
|
|
5049
|
+
if (config.reservedFields.includes(key)) {
|
|
5047
5050
|
return;
|
|
5048
5051
|
}
|
|
5049
|
-
const
|
|
5050
|
-
|
|
5051
|
-
);
|
|
5052
|
+
const operatorsPattern = config.supportedOperators.join("|");
|
|
5053
|
+
const match = key.match(new RegExp(`^(.+)\\[(${operatorsPattern})\\]$`));
|
|
5052
5054
|
if (match) {
|
|
5053
5055
|
filters.push({
|
|
5054
5056
|
field: match[1],
|
|
@@ -5098,8 +5100,10 @@ var ApiFeatures = class {
|
|
|
5098
5100
|
return populate.split(",").map((field) => field.trim()).filter(Boolean);
|
|
5099
5101
|
}
|
|
5100
5102
|
static parsePagination(query) {
|
|
5101
|
-
const
|
|
5102
|
-
const
|
|
5103
|
+
const config = this.getConfig();
|
|
5104
|
+
const page = Math.max(1, Number(query.page) || config.defaultPage);
|
|
5105
|
+
const requestedLimit = Number(query.limit) || config.defaultLimit;
|
|
5106
|
+
const limit = Math.min(Math.max(1, requestedLimit), config.maxLimit);
|
|
5103
5107
|
return {
|
|
5104
5108
|
page,
|
|
5105
5109
|
limit
|
|
@@ -5794,6 +5798,61 @@ var InternalServiceClient = class extends ServiceClient {
|
|
|
5794
5798
|
}
|
|
5795
5799
|
};
|
|
5796
5800
|
|
|
5801
|
+
// src/ejs/context/EJSConfig.ts
|
|
5802
|
+
var DefaultEJSConfig = {
|
|
5803
|
+
apiFeatures: DefaultApiFeaturesConfig
|
|
5804
|
+
};
|
|
5805
|
+
|
|
5806
|
+
// src/ejs/context/EJSContext.ts
|
|
5807
|
+
function deepMerge(target, source) {
|
|
5808
|
+
const result = {
|
|
5809
|
+
...target
|
|
5810
|
+
};
|
|
5811
|
+
Object.entries(source).forEach(([key, value]) => {
|
|
5812
|
+
if (value && typeof value === "object" && !Array.isArray(value)) {
|
|
5813
|
+
result[key] = deepMerge(
|
|
5814
|
+
result[key] ?? {},
|
|
5815
|
+
value
|
|
5816
|
+
);
|
|
5817
|
+
return;
|
|
5818
|
+
}
|
|
5819
|
+
result[key] = value;
|
|
5820
|
+
});
|
|
5821
|
+
return result;
|
|
5822
|
+
}
|
|
5823
|
+
var EJSContext = class {
|
|
5824
|
+
static config = {
|
|
5825
|
+
...DefaultEJSConfig
|
|
5826
|
+
};
|
|
5827
|
+
static configure(config) {
|
|
5828
|
+
this.config = deepMerge(
|
|
5829
|
+
this.config,
|
|
5830
|
+
config
|
|
5831
|
+
);
|
|
5832
|
+
}
|
|
5833
|
+
static get() {
|
|
5834
|
+
return this.config;
|
|
5835
|
+
}
|
|
5836
|
+
static reset() {
|
|
5837
|
+
this.config = {
|
|
5838
|
+
...DefaultEJSConfig
|
|
5839
|
+
};
|
|
5840
|
+
}
|
|
5841
|
+
};
|
|
5842
|
+
|
|
5843
|
+
// src/ejs/EJS.ts
|
|
5844
|
+
var EJS = class {
|
|
5845
|
+
static configure(config) {
|
|
5846
|
+
EJSContext.configure(config);
|
|
5847
|
+
}
|
|
5848
|
+
static getConfig() {
|
|
5849
|
+
return EJSContext.get();
|
|
5850
|
+
}
|
|
5851
|
+
static reset() {
|
|
5852
|
+
EJSContext.reset();
|
|
5853
|
+
}
|
|
5854
|
+
};
|
|
5855
|
+
|
|
5797
5856
|
// src/repositories/providers/MongoRepository.ts
|
|
5798
5857
|
var MongoRepository = class {
|
|
5799
5858
|
model;
|
|
@@ -6404,15 +6463,16 @@ exports.ConsistentHash = ConsistentHash;
|
|
|
6404
6463
|
exports.CorrelationId = CorrelationId;
|
|
6405
6464
|
exports.CountMinSketch = CountMinSketch;
|
|
6406
6465
|
exports.CrudControllerFactory = CrudControllerFactory;
|
|
6407
|
-
exports.DEFAULT_LIMIT = DEFAULT_LIMIT;
|
|
6408
|
-
exports.DEFAULT_PAGE = DEFAULT_PAGE;
|
|
6409
|
-
exports.DEFAULT_SORT_DIRECTION = DEFAULT_SORT_DIRECTION;
|
|
6410
6466
|
exports.DatabaseManager = DatabaseManager;
|
|
6467
|
+
exports.DefaultApiFeaturesConfig = DefaultApiFeaturesConfig;
|
|
6468
|
+
exports.DefaultEJSConfig = DefaultEJSConfig;
|
|
6411
6469
|
exports.Deque = Deque;
|
|
6412
6470
|
exports.DirectedGraph = DirectedGraph;
|
|
6413
6471
|
exports.DisjointSetUnion = DisjointSetUnion;
|
|
6414
6472
|
exports.DoublyLinkedList = DoublyLinkedList;
|
|
6415
6473
|
exports.DynamicArray = DynamicArray;
|
|
6474
|
+
exports.EJS = EJS;
|
|
6475
|
+
exports.EJSContext = EJSContext;
|
|
6416
6476
|
exports.EmailService = EmailService;
|
|
6417
6477
|
exports.ErrorMiddleware = ErrorMiddleware;
|
|
6418
6478
|
exports.ExponentialBackoffRetryPolicy = ExponentialBackoffRetryPolicy;
|
|
@@ -6446,14 +6506,12 @@ exports.OrderedSet = OrderedSet;
|
|
|
6446
6506
|
exports.PairingHeap = PairingHeap;
|
|
6447
6507
|
exports.PairingNode = PairingNode;
|
|
6448
6508
|
exports.PriorityQueue = PriorityQueue;
|
|
6449
|
-
exports.QUERY_RESERVED_FIELDS = QUERY_RESERVED_FIELDS;
|
|
6450
6509
|
exports.QuadTree = QuadTree;
|
|
6451
6510
|
exports.Queue = Queue;
|
|
6452
6511
|
exports.RadixTree = RadixTree;
|
|
6453
6512
|
exports.RedBlackTree = RedBlackTree;
|
|
6454
6513
|
exports.RequestContext = RequestContext;
|
|
6455
6514
|
exports.SMTPProvider = SMTPProvider;
|
|
6456
|
-
exports.SUPPORTED_OPERATORS = SUPPORTED_OPERATORS;
|
|
6457
6515
|
exports.SegmentTree = SegmentTree;
|
|
6458
6516
|
exports.ServiceClient = ServiceClient;
|
|
6459
6517
|
exports.Set = Set2;
|