@buka/nestjs-kit 3.0.1
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/.czrc +3 -0
- package/.vscode/tasks.json +21 -0
- package/LICENSE +21 -0
- package/README.md +9 -0
- package/coverage/cobertura-coverage.xml +1173 -0
- package/dist/index.d.mts +311 -0
- package/dist/index.d.ts +311 -0
- package/dist/index.js +2553 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +2478 -0
- package/dist/index.mjs.map +1 -0
- package/eslint.config.mjs +18 -0
- package/jest.config.cts +23 -0
- package/package.json +100 -0
- package/pnpm-workspace.yaml +4 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,2553 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
9
|
+
var __export = (target, all) => {
|
|
10
|
+
for (var name in all)
|
|
11
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from))
|
|
16
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
17
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
|
+
}
|
|
19
|
+
return to;
|
|
20
|
+
};
|
|
21
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
+
mod
|
|
28
|
+
));
|
|
29
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
+
|
|
31
|
+
// src/index.ts
|
|
32
|
+
var index_exports = {};
|
|
33
|
+
__export(index_exports, {
|
|
34
|
+
BaseEntity: () => BaseEntity,
|
|
35
|
+
BukaValidationPipe: () => BukaValidationPipe,
|
|
36
|
+
DatabaseConfig: () => DatabaseConfig,
|
|
37
|
+
EntityDtoType: () => EntityDtoType,
|
|
38
|
+
EntityEnum: () => EntityEnum,
|
|
39
|
+
EntityManyToMany: () => EntityManyToMany,
|
|
40
|
+
EntityManyToOne: () => EntityManyToOne,
|
|
41
|
+
EntityOneToMany: () => EntityOneToMany,
|
|
42
|
+
EntityOneToOne: () => EntityOneToOne,
|
|
43
|
+
EntityProperty: () => EntityProperty,
|
|
44
|
+
EntityRefType: () => EntityRefType,
|
|
45
|
+
EntityRefTypeClassMetadataPropertyKey: () => EntityRefTypeClassMetadataPropertyKey,
|
|
46
|
+
EntityTransient: () => EntityTransient,
|
|
47
|
+
FilterQueryOperators: () => FilterQueryOperators,
|
|
48
|
+
FilterQueryOperatorsMetadataKey: () => FilterQueryOperatorsMetadataKey,
|
|
49
|
+
FilterQueryType: () => FilterQueryType,
|
|
50
|
+
HAS_ANY_KEY: () => HAS_ANY_KEY,
|
|
51
|
+
HasAnyKey: () => HasAnyKey,
|
|
52
|
+
ListResponseBodyType: () => ListResponseBodyType,
|
|
53
|
+
MATCH_JSON_SCHEMA: () => MATCH_JSON_SCHEMA,
|
|
54
|
+
MatchJsonSchema: () => MatchJsonSchema,
|
|
55
|
+
Model: () => Model,
|
|
56
|
+
ModelRegister: () => ModelRegister,
|
|
57
|
+
Nested: () => Nested,
|
|
58
|
+
NestedProperty: () => NestedProperty,
|
|
59
|
+
OmitType: () => OmitType,
|
|
60
|
+
OptionalPageQuery: () => OptionalPageQuery,
|
|
61
|
+
OrderQueryType: () => OrderQueryType,
|
|
62
|
+
PageQuery: () => PageQuery,
|
|
63
|
+
PartialType: () => PartialType,
|
|
64
|
+
PickType: () => PickType,
|
|
65
|
+
Property: () => Property,
|
|
66
|
+
RELATION_METADATA_KEY: () => RELATION_METADATA_KEY,
|
|
67
|
+
ReferencePropertiesMetadataKey: () => ReferencePropertiesMetadataKey,
|
|
68
|
+
ReferenceProperty: () => ReferenceProperty,
|
|
69
|
+
Relation: () => Relation,
|
|
70
|
+
ResponseBodyType: () => ResponseBodyType,
|
|
71
|
+
Slice: () => Slice,
|
|
72
|
+
TimestampedEntity: () => TimestampedEntity,
|
|
73
|
+
deepObjectifyQueries: () => deepObjectifyQueries,
|
|
74
|
+
getFilterQueryOperators: () => getFilterQueryOperators
|
|
75
|
+
});
|
|
76
|
+
module.exports = __toCommonJS(index_exports);
|
|
77
|
+
|
|
78
|
+
// src/mikro-orm/models/base-entity.ts
|
|
79
|
+
var import_core6 = require("@mikro-orm/core");
|
|
80
|
+
var import_swagger5 = require("@nestjs/swagger");
|
|
81
|
+
var import_class_validator7 = require("class-validator");
|
|
82
|
+
|
|
83
|
+
// src/mikro-orm/models/timestamped-entity.ts
|
|
84
|
+
var import_core5 = require("@mikro-orm/core");
|
|
85
|
+
|
|
86
|
+
// src/mikro-orm/decorators/entity-property.decorator.ts
|
|
87
|
+
var import_core4 = require("@mikro-orm/core");
|
|
88
|
+
|
|
89
|
+
// src/mikro-orm/decorators/api-entity-property.decorator.ts
|
|
90
|
+
var import_swagger4 = require("@nestjs/swagger");
|
|
91
|
+
var import_core3 = require("@mikro-orm/core");
|
|
92
|
+
|
|
93
|
+
// src/mikro-orm/decorators/api-scalar-entity-property.decorator.ts
|
|
94
|
+
var import_core = require("@mikro-orm/core");
|
|
95
|
+
var import_common6 = require("@nestjs/common");
|
|
96
|
+
var import_class_validator6 = require("class-validator");
|
|
97
|
+
|
|
98
|
+
// src/decorators/nested-property.decorator.ts
|
|
99
|
+
var R2 = __toESM(require("ramda"));
|
|
100
|
+
var import_common = require("@nestjs/common");
|
|
101
|
+
var import_class_transformer = require("class-transformer");
|
|
102
|
+
var import_class_validator2 = require("class-validator");
|
|
103
|
+
|
|
104
|
+
// src/decorators/model/model.register.ts
|
|
105
|
+
var R = __toESM(require("ramda"));
|
|
106
|
+
var MODEL_METADATA_KEY = "buka:model";
|
|
107
|
+
var PROPERTY_METADATA_KEY = "buka:property";
|
|
108
|
+
var ModelRegister = class {
|
|
109
|
+
static {
|
|
110
|
+
__name(this, "ModelRegister");
|
|
111
|
+
}
|
|
112
|
+
static setModel(target, metadata) {
|
|
113
|
+
Reflect.defineMetadata(MODEL_METADATA_KEY, metadata, target);
|
|
114
|
+
}
|
|
115
|
+
static getModel(target) {
|
|
116
|
+
return Reflect.getMetadata(MODEL_METADATA_KEY, target);
|
|
117
|
+
}
|
|
118
|
+
static setProperty(target, propertyName, metadata) {
|
|
119
|
+
Reflect.defineMetadata(PROPERTY_METADATA_KEY, metadata, target.prototype, propertyName);
|
|
120
|
+
}
|
|
121
|
+
static getProperty(target, propertyName) {
|
|
122
|
+
return Reflect.getMetadata(PROPERTY_METADATA_KEY, target.prototype, propertyName);
|
|
123
|
+
}
|
|
124
|
+
static copyProperty(source, target, propertyName) {
|
|
125
|
+
const metadata = this.getProperty(source, propertyName);
|
|
126
|
+
if (metadata) {
|
|
127
|
+
const modelMetadata = this.addModel(target);
|
|
128
|
+
if (!modelMetadata.propertyKeys.includes(propertyName)) {
|
|
129
|
+
modelMetadata.propertyKeys.push(propertyName);
|
|
130
|
+
}
|
|
131
|
+
this.setProperty(target, propertyName, metadata);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
static addModel(target, kind = "model") {
|
|
135
|
+
const metadata = this.getModel(target);
|
|
136
|
+
if (!metadata) {
|
|
137
|
+
const metadata2 = {
|
|
138
|
+
kind,
|
|
139
|
+
propertyKeys: []
|
|
140
|
+
};
|
|
141
|
+
this.setModel(target, metadata2);
|
|
142
|
+
return metadata2;
|
|
143
|
+
}
|
|
144
|
+
return metadata;
|
|
145
|
+
}
|
|
146
|
+
static addProperty(target, propertyName, metadata = {}) {
|
|
147
|
+
const modelMetadata = this.addModel(target);
|
|
148
|
+
if (!modelMetadata.propertyKeys.includes(propertyName)) {
|
|
149
|
+
modelMetadata.propertyKeys.push(propertyName);
|
|
150
|
+
}
|
|
151
|
+
const propertyMetadata = {
|
|
152
|
+
type() {
|
|
153
|
+
return Reflect.getMetadata("design:type", target.prototype, propertyName);
|
|
154
|
+
},
|
|
155
|
+
...this.getProperty(target, propertyName) || {},
|
|
156
|
+
...R.omit([
|
|
157
|
+
"schema"
|
|
158
|
+
], metadata)
|
|
159
|
+
};
|
|
160
|
+
this.setProperty(target, propertyName, propertyMetadata);
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* 判断是否为已注册的 Model
|
|
164
|
+
*
|
|
165
|
+
* @example
|
|
166
|
+
* ```typescript
|
|
167
|
+
* const isModel = ModelRegister.isModel(Class.prototype)
|
|
168
|
+
* ```
|
|
169
|
+
*/
|
|
170
|
+
static isModel(target) {
|
|
171
|
+
return !!this.getModel(target);
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* 获取 Model 的所有属性
|
|
175
|
+
*
|
|
176
|
+
* @example
|
|
177
|
+
* ```typescript
|
|
178
|
+
* const properties = ModelRegister.getProperties(Class.prototype)
|
|
179
|
+
* ```
|
|
180
|
+
*/
|
|
181
|
+
static getModelPropertyKeys(target) {
|
|
182
|
+
const metadata = this.getModel(target);
|
|
183
|
+
return metadata ? metadata.propertyKeys : [];
|
|
184
|
+
}
|
|
185
|
+
static getProperties(target) {
|
|
186
|
+
const propertyKeys = this.getModelPropertyKeys(target);
|
|
187
|
+
return propertyKeys.map((propertyKey) => this.getProperty(target, propertyKey)).filter((property) => !!property);
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
// src/decorators/model/model.decorator.ts
|
|
192
|
+
function Model() {
|
|
193
|
+
return (target) => {
|
|
194
|
+
ModelRegister.addModel(target);
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
__name(Model, "Model");
|
|
198
|
+
|
|
199
|
+
// src/exceptions/exceptions.ts
|
|
200
|
+
var import_ts_custom_error = require("ts-custom-error");
|
|
201
|
+
var Exception = class extends import_ts_custom_error.CustomError {
|
|
202
|
+
static {
|
|
203
|
+
__name(this, "Exception");
|
|
204
|
+
}
|
|
205
|
+
constructor(message) {
|
|
206
|
+
super(`[@buka/nestjs] ${message}`);
|
|
207
|
+
Object.defineProperty(this, "name", {
|
|
208
|
+
value: "Exception"
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
};
|
|
212
|
+
|
|
213
|
+
// src/exceptions/type-exception.ts
|
|
214
|
+
var TypeException = class extends Exception {
|
|
215
|
+
static {
|
|
216
|
+
__name(this, "TypeException");
|
|
217
|
+
}
|
|
218
|
+
constructor(message) {
|
|
219
|
+
super(message);
|
|
220
|
+
Object.defineProperty(this, "name", {
|
|
221
|
+
value: "TypeException"
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
// src/decorators/model/property.decorator.ts
|
|
227
|
+
var import_class_validator = require("class-validator");
|
|
228
|
+
var import_swagger = require("@nestjs/swagger");
|
|
229
|
+
function Property(options) {
|
|
230
|
+
return (target, propertyKey) => {
|
|
231
|
+
if (!("constructor" in target)) {
|
|
232
|
+
throw new TypeException("@Property decorator can only be applied to class properties.");
|
|
233
|
+
}
|
|
234
|
+
if (options?.optional) {
|
|
235
|
+
(0, import_class_validator.IsOptional)()(target, propertyKey);
|
|
236
|
+
}
|
|
237
|
+
if (options?.schema) {
|
|
238
|
+
if (options?.optional) {
|
|
239
|
+
(0, import_swagger.ApiPropertyOptional)(options.schema)(target, propertyKey);
|
|
240
|
+
} else {
|
|
241
|
+
(0, import_swagger.ApiProperty)(options.schema)(target, propertyKey);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
ModelRegister.addProperty(target.constructor, propertyKey, options);
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
__name(Property, "Property");
|
|
248
|
+
|
|
249
|
+
// src/decorators/model/relation.decorator.ts
|
|
250
|
+
var RELATION_METADATA_KEY = "buka:relation";
|
|
251
|
+
function Relation(metadata) {
|
|
252
|
+
return (target, propertyKey) => {
|
|
253
|
+
ModelRegister.addProperty(target.constructor, propertyKey, {
|
|
254
|
+
relation: metadata
|
|
255
|
+
});
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
__name(Relation, "Relation");
|
|
259
|
+
|
|
260
|
+
// src/decorators/model/nested.decorator.ts
|
|
261
|
+
function Nested(options) {
|
|
262
|
+
return (target, propertyKey) => {
|
|
263
|
+
Property({
|
|
264
|
+
kind: "nested",
|
|
265
|
+
...options
|
|
266
|
+
})(target, propertyKey);
|
|
267
|
+
};
|
|
268
|
+
}
|
|
269
|
+
__name(Nested, "Nested");
|
|
270
|
+
|
|
271
|
+
// src/decorators/model/list.decorator.ts
|
|
272
|
+
function List(options) {
|
|
273
|
+
return (target, propertyKey) => {
|
|
274
|
+
Property({
|
|
275
|
+
kind: "list",
|
|
276
|
+
...options
|
|
277
|
+
})(target, propertyKey);
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
__name(List, "List");
|
|
281
|
+
|
|
282
|
+
// src/decorators/nested-property.decorator.ts
|
|
283
|
+
function NestedProperty(type, options = {}) {
|
|
284
|
+
const decorators = [
|
|
285
|
+
(0, import_class_validator2.ValidateNested)({
|
|
286
|
+
each: !!options.each
|
|
287
|
+
}),
|
|
288
|
+
(0, import_class_transformer.Type)(type)
|
|
289
|
+
];
|
|
290
|
+
const schema = options.schema || {
|
|
291
|
+
type: /* @__PURE__ */ __name(() => type(), "type")
|
|
292
|
+
};
|
|
293
|
+
const propertyMetadata = R2.pick([
|
|
294
|
+
"relation",
|
|
295
|
+
"optional"
|
|
296
|
+
], options);
|
|
297
|
+
if (options.each) {
|
|
298
|
+
decorators.push(List({
|
|
299
|
+
type,
|
|
300
|
+
schema,
|
|
301
|
+
...propertyMetadata
|
|
302
|
+
}));
|
|
303
|
+
} else {
|
|
304
|
+
decorators.push(Nested({
|
|
305
|
+
type,
|
|
306
|
+
schema,
|
|
307
|
+
...propertyMetadata
|
|
308
|
+
}));
|
|
309
|
+
}
|
|
310
|
+
if (!options.optional) {
|
|
311
|
+
decorators.push(...[
|
|
312
|
+
// 如果不添加 IsNotEmpty,ValidateNested 在没有 IsOptional 的情况下也会允许 undefined 值通过验证
|
|
313
|
+
// https://github.com/typestack/class-validator/issues/717
|
|
314
|
+
(0, import_class_validator2.IsNotEmpty)({
|
|
315
|
+
each: options.each,
|
|
316
|
+
message: "$property is required"
|
|
317
|
+
})
|
|
318
|
+
]);
|
|
319
|
+
}
|
|
320
|
+
return (0, import_common.applyDecorators)(...decorators);
|
|
321
|
+
}
|
|
322
|
+
__name(NestedProperty, "NestedProperty");
|
|
323
|
+
|
|
324
|
+
// src/decorators/reference-property.decorator.ts
|
|
325
|
+
var import_common2 = require("@nestjs/common");
|
|
326
|
+
var import_class_validator3 = require("class-validator");
|
|
327
|
+
var ReferencePropertiesMetadataKey = "buka:reference-properties";
|
|
328
|
+
function ReferenceProperty(entity) {
|
|
329
|
+
return (0, import_common2.applyDecorators)((0, import_class_validator3.Allow)(), NestedProperty(() => EntityRefType(entity()), {
|
|
330
|
+
relation: {
|
|
331
|
+
kind: "1:1",
|
|
332
|
+
type: /* @__PURE__ */ __name(() => entity(), "type")
|
|
333
|
+
}
|
|
334
|
+
}));
|
|
335
|
+
}
|
|
336
|
+
__name(ReferenceProperty, "ReferenceProperty");
|
|
337
|
+
|
|
338
|
+
// src/decorators/class-validator/has-any-key.ts
|
|
339
|
+
var import_class_validator4 = require("class-validator");
|
|
340
|
+
var HAS_ANY_KEY = "hasAnyKey";
|
|
341
|
+
function HasAnyKey(keys, validationOptions) {
|
|
342
|
+
return function(object, propertyName) {
|
|
343
|
+
(0, import_class_validator4.registerDecorator)({
|
|
344
|
+
name: HAS_ANY_KEY,
|
|
345
|
+
target: object.constructor,
|
|
346
|
+
propertyName,
|
|
347
|
+
constraints: [
|
|
348
|
+
keys
|
|
349
|
+
],
|
|
350
|
+
options: validationOptions,
|
|
351
|
+
validator: {
|
|
352
|
+
validate(value) {
|
|
353
|
+
if (typeof value !== "object" || value === null) return false;
|
|
354
|
+
for (const key of keys) {
|
|
355
|
+
if (key in value) return true;
|
|
356
|
+
}
|
|
357
|
+
return false;
|
|
358
|
+
},
|
|
359
|
+
defaultMessage() {
|
|
360
|
+
return `$property must have at least one of the keys: ${keys.join(", ")}`;
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
});
|
|
364
|
+
};
|
|
365
|
+
}
|
|
366
|
+
__name(HasAnyKey, "HasAnyKey");
|
|
367
|
+
|
|
368
|
+
// src/decorators/class-validator/match-json-schema.ts
|
|
369
|
+
var import_class_validator5 = require("class-validator");
|
|
370
|
+
var import_jsonschema = require("jsonschema");
|
|
371
|
+
var MATCH_JSON_SCHEMA = "matchJsonSchema";
|
|
372
|
+
function MatchJsonSchema(schema, validationOptions) {
|
|
373
|
+
return function(object, propertyName) {
|
|
374
|
+
(0, import_class_validator5.registerDecorator)({
|
|
375
|
+
name: MATCH_JSON_SCHEMA,
|
|
376
|
+
target: object.constructor,
|
|
377
|
+
propertyName,
|
|
378
|
+
constraints: [
|
|
379
|
+
schema
|
|
380
|
+
],
|
|
381
|
+
options: validationOptions,
|
|
382
|
+
validator: {
|
|
383
|
+
validate(value, args) {
|
|
384
|
+
const [schema2] = args.constraints;
|
|
385
|
+
const results = (0, import_jsonschema.validate)(value, schema2);
|
|
386
|
+
return results.valid;
|
|
387
|
+
},
|
|
388
|
+
defaultMessage({ value, constraints }) {
|
|
389
|
+
return `${propertyName} must match the JSON schema`;
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
});
|
|
393
|
+
};
|
|
394
|
+
}
|
|
395
|
+
__name(MatchJsonSchema, "MatchJsonSchema");
|
|
396
|
+
|
|
397
|
+
// src/decorators/page-query.ts
|
|
398
|
+
var import_common4 = require("@nestjs/common");
|
|
399
|
+
var import_swagger2 = require("@nestjs/swagger");
|
|
400
|
+
|
|
401
|
+
// src/pipes/page-query-validation.pipe.ts
|
|
402
|
+
var import_common3 = require("@nestjs/common");
|
|
403
|
+
function _ts_decorate(decorators, target, key, desc) {
|
|
404
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
405
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
406
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
407
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
408
|
+
}
|
|
409
|
+
__name(_ts_decorate, "_ts_decorate");
|
|
410
|
+
function _ts_metadata(k, v) {
|
|
411
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
412
|
+
}
|
|
413
|
+
__name(_ts_metadata, "_ts_metadata");
|
|
414
|
+
var mixedOffsetAndCursorError = "Invalid page query: cannot mix offset-based and cursor-based pagination parameters.";
|
|
415
|
+
var mixedNextAndLastCursorError = "Invalid page query: cannot mix next and last cursor pagination parameters.";
|
|
416
|
+
var BukaPageQueryValidationPipe = class {
|
|
417
|
+
static {
|
|
418
|
+
__name(this, "BukaPageQueryValidationPipe");
|
|
419
|
+
}
|
|
420
|
+
options;
|
|
421
|
+
constructor(options = {
|
|
422
|
+
optional: false
|
|
423
|
+
}) {
|
|
424
|
+
this.options = options;
|
|
425
|
+
}
|
|
426
|
+
transform(value, metadata) {
|
|
427
|
+
if (metadata.type !== "query") {
|
|
428
|
+
throw new import_common3.InternalServerErrorException("BukaPageQueryValidationPipe can only be used to validate query parameters.");
|
|
429
|
+
}
|
|
430
|
+
if (!value.page) {
|
|
431
|
+
if (this.options.optional) {
|
|
432
|
+
return value;
|
|
433
|
+
} else {
|
|
434
|
+
throw new import_common3.BadRequestException("Missing required query parameter: page");
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
const mode = this.options.mode;
|
|
438
|
+
if ((!mode || mode === "offset") && ("limit" in value.page || "offset" in value.page)) {
|
|
439
|
+
if ("after" in value.page || "first" in value.page || "before" in value.page || "last" in value.page) {
|
|
440
|
+
throw new import_common3.BadRequestException(mixedOffsetAndCursorError);
|
|
441
|
+
}
|
|
442
|
+
const limit = parseInt(value.page.limit, 10);
|
|
443
|
+
const offset = parseInt(value.page.offset, 10);
|
|
444
|
+
if (isNaN(limit) || limit <= 0) {
|
|
445
|
+
throw new import_common3.BadRequestException("Invalid page query: limit must be a positive integer.");
|
|
446
|
+
}
|
|
447
|
+
if (isNaN(offset) || offset < 0) {
|
|
448
|
+
throw new import_common3.BadRequestException("Invalid page query: offset must be a non-negative integer.");
|
|
449
|
+
}
|
|
450
|
+
return {
|
|
451
|
+
page: {
|
|
452
|
+
limit,
|
|
453
|
+
offset
|
|
454
|
+
}
|
|
455
|
+
};
|
|
456
|
+
}
|
|
457
|
+
if (!mode || mode === "cursor") {
|
|
458
|
+
if ("after" in value.page || "first" in value.page) {
|
|
459
|
+
if ("limit" in value.page || "offset" in value.page) {
|
|
460
|
+
throw new import_common3.BadRequestException(mixedOffsetAndCursorError);
|
|
461
|
+
}
|
|
462
|
+
if ("before" in value.page || "last" in value.page) {
|
|
463
|
+
throw new import_common3.BadRequestException(mixedNextAndLastCursorError);
|
|
464
|
+
}
|
|
465
|
+
const after = value.page.after;
|
|
466
|
+
const first = parseInt(value.page.first, 10);
|
|
467
|
+
if (typeof after !== "string") {
|
|
468
|
+
throw new import_common3.BadRequestException("Invalid page query: after must be a string.");
|
|
469
|
+
}
|
|
470
|
+
if (isNaN(first) || first <= 0) {
|
|
471
|
+
throw new import_common3.BadRequestException("Invalid page query: first must be a positive integer.");
|
|
472
|
+
}
|
|
473
|
+
return {
|
|
474
|
+
page: {
|
|
475
|
+
after,
|
|
476
|
+
first
|
|
477
|
+
}
|
|
478
|
+
};
|
|
479
|
+
}
|
|
480
|
+
if ("before" in value.page || "last" in value.page) {
|
|
481
|
+
if ("limit" in value.page || "offset" in value.page) {
|
|
482
|
+
throw new import_common3.BadRequestException(mixedOffsetAndCursorError);
|
|
483
|
+
}
|
|
484
|
+
if ("after" in value.page || "first" in value.page) {
|
|
485
|
+
throw new import_common3.BadRequestException(mixedNextAndLastCursorError);
|
|
486
|
+
}
|
|
487
|
+
const before = value.page.before;
|
|
488
|
+
const last = parseInt(value.page.last, 10);
|
|
489
|
+
if (typeof before !== "string") {
|
|
490
|
+
throw new import_common3.BadRequestException("Invalid page query: before must be a string.");
|
|
491
|
+
}
|
|
492
|
+
if (isNaN(last) || last <= 0) {
|
|
493
|
+
throw new import_common3.BadRequestException("Invalid page query: last must be a positive integer.");
|
|
494
|
+
}
|
|
495
|
+
return {
|
|
496
|
+
page: {
|
|
497
|
+
before,
|
|
498
|
+
last
|
|
499
|
+
}
|
|
500
|
+
};
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
throw new import_common3.BadRequestException("Invalid page query: missing pagination parameters.");
|
|
504
|
+
}
|
|
505
|
+
};
|
|
506
|
+
BukaPageQueryValidationPipe = _ts_decorate([
|
|
507
|
+
(0, import_common3.Injectable)(),
|
|
508
|
+
_ts_metadata("design:type", Function),
|
|
509
|
+
_ts_metadata("design:paramtypes", [
|
|
510
|
+
typeof BukaPageQueryValidationPipeOptions === "undefined" ? Object : BukaPageQueryValidationPipeOptions
|
|
511
|
+
])
|
|
512
|
+
], BukaPageQueryValidationPipe);
|
|
513
|
+
|
|
514
|
+
// src/decorators/page-query.ts
|
|
515
|
+
var OffsetPageSchema = {
|
|
516
|
+
type: "object",
|
|
517
|
+
properties: {
|
|
518
|
+
limit: {
|
|
519
|
+
type: "number"
|
|
520
|
+
},
|
|
521
|
+
offset: {
|
|
522
|
+
type: "number"
|
|
523
|
+
}
|
|
524
|
+
},
|
|
525
|
+
required: [
|
|
526
|
+
"limit",
|
|
527
|
+
"offset"
|
|
528
|
+
]
|
|
529
|
+
};
|
|
530
|
+
var NextCursorPageSchema = {
|
|
531
|
+
type: "object",
|
|
532
|
+
properties: {
|
|
533
|
+
after: {
|
|
534
|
+
type: "string"
|
|
535
|
+
},
|
|
536
|
+
first: {
|
|
537
|
+
type: "number"
|
|
538
|
+
}
|
|
539
|
+
},
|
|
540
|
+
required: [
|
|
541
|
+
"after",
|
|
542
|
+
"first"
|
|
543
|
+
]
|
|
544
|
+
};
|
|
545
|
+
var PreviousCursorPageSchema = {
|
|
546
|
+
type: "object",
|
|
547
|
+
properties: {
|
|
548
|
+
before: {
|
|
549
|
+
type: "string"
|
|
550
|
+
},
|
|
551
|
+
last: {
|
|
552
|
+
type: "number"
|
|
553
|
+
}
|
|
554
|
+
},
|
|
555
|
+
required: [
|
|
556
|
+
"before",
|
|
557
|
+
"last"
|
|
558
|
+
]
|
|
559
|
+
};
|
|
560
|
+
function PageQuery(mode) {
|
|
561
|
+
return (target, propertyKey, parameterIndex) => {
|
|
562
|
+
if (!propertyKey) {
|
|
563
|
+
throw new Error("@PageQuery decorator can only be used on method parameters.");
|
|
564
|
+
}
|
|
565
|
+
const descriptor = Reflect.getOwnPropertyDescriptor(target, propertyKey);
|
|
566
|
+
if (mode === "offset") {
|
|
567
|
+
(0, import_swagger2.ApiQuery)({
|
|
568
|
+
name: "page",
|
|
569
|
+
required: true,
|
|
570
|
+
schema: OffsetPageSchema
|
|
571
|
+
})(target, propertyKey, descriptor);
|
|
572
|
+
} else if (mode === "cursor") {
|
|
573
|
+
(0, import_swagger2.ApiQuery)({
|
|
574
|
+
name: "page",
|
|
575
|
+
required: true,
|
|
576
|
+
schema: {
|
|
577
|
+
oneOf: [
|
|
578
|
+
NextCursorPageSchema,
|
|
579
|
+
PreviousCursorPageSchema
|
|
580
|
+
]
|
|
581
|
+
}
|
|
582
|
+
})(target, propertyKey, descriptor);
|
|
583
|
+
} else {
|
|
584
|
+
(0, import_swagger2.ApiQuery)({
|
|
585
|
+
name: "page",
|
|
586
|
+
required: true,
|
|
587
|
+
schema: {
|
|
588
|
+
oneOf: [
|
|
589
|
+
OffsetPageSchema,
|
|
590
|
+
NextCursorPageSchema,
|
|
591
|
+
PreviousCursorPageSchema
|
|
592
|
+
]
|
|
593
|
+
}
|
|
594
|
+
})(target, propertyKey, descriptor);
|
|
595
|
+
}
|
|
596
|
+
(0, import_common4.Query)(new BukaPageQueryValidationPipe({
|
|
597
|
+
mode
|
|
598
|
+
}))(target, propertyKey, parameterIndex);
|
|
599
|
+
};
|
|
600
|
+
}
|
|
601
|
+
__name(PageQuery, "PageQuery");
|
|
602
|
+
function OptionalPageQuery(mode) {
|
|
603
|
+
return (target, propertyKey, parameterIndex) => {
|
|
604
|
+
if (!propertyKey) {
|
|
605
|
+
throw new Error("@PageQuery decorator can only be used on method parameters.");
|
|
606
|
+
}
|
|
607
|
+
const descriptor = Reflect.getOwnPropertyDescriptor(target, propertyKey);
|
|
608
|
+
if (mode === "offset") {
|
|
609
|
+
(0, import_swagger2.ApiQuery)({
|
|
610
|
+
name: "page",
|
|
611
|
+
required: false,
|
|
612
|
+
schema: OffsetPageSchema
|
|
613
|
+
});
|
|
614
|
+
} else if (mode === "cursor") {
|
|
615
|
+
(0, import_swagger2.ApiQuery)({
|
|
616
|
+
name: "page",
|
|
617
|
+
required: false,
|
|
618
|
+
schema: {
|
|
619
|
+
oneOf: [
|
|
620
|
+
NextCursorPageSchema,
|
|
621
|
+
PreviousCursorPageSchema
|
|
622
|
+
]
|
|
623
|
+
}
|
|
624
|
+
})(target, propertyKey, descriptor);
|
|
625
|
+
} else {
|
|
626
|
+
(0, import_swagger2.ApiQuery)({
|
|
627
|
+
name: "page",
|
|
628
|
+
required: false,
|
|
629
|
+
schema: {
|
|
630
|
+
oneOf: [
|
|
631
|
+
OffsetPageSchema,
|
|
632
|
+
NextCursorPageSchema,
|
|
633
|
+
PreviousCursorPageSchema
|
|
634
|
+
]
|
|
635
|
+
}
|
|
636
|
+
})(target, propertyKey, descriptor);
|
|
637
|
+
}
|
|
638
|
+
(0, import_common4.Query)(new BukaPageQueryValidationPipe({
|
|
639
|
+
mode,
|
|
640
|
+
optional: true
|
|
641
|
+
}))(target, propertyKey, parameterIndex);
|
|
642
|
+
};
|
|
643
|
+
}
|
|
644
|
+
__name(OptionalPageQuery, "OptionalPageQuery");
|
|
645
|
+
|
|
646
|
+
// src/utils/logger.ts
|
|
647
|
+
var import_common5 = require("@nestjs/common");
|
|
648
|
+
var logger = new import_common5.Logger("@buka/nestjs-kits");
|
|
649
|
+
|
|
650
|
+
// src/mikro-orm/decorators/api-scalar-entity-property.decorator.ts
|
|
651
|
+
function ApiScalarEntityProperty(options) {
|
|
652
|
+
const { meta } = options;
|
|
653
|
+
if (typeof meta["columnType"] === "string") {
|
|
654
|
+
const columnType = meta["columnType"].toLowerCase();
|
|
655
|
+
if (columnType.startsWith("varchar")) {
|
|
656
|
+
const length = Number(meta["columnType"].match(/\d+/)?.[0]);
|
|
657
|
+
return VarcharProperty(length, options);
|
|
658
|
+
}
|
|
659
|
+
if (columnType.startsWith("char")) {
|
|
660
|
+
const length = Number(meta["columnType"].match(/\d+/)?.[0]);
|
|
661
|
+
return CharProperty(length, options);
|
|
662
|
+
}
|
|
663
|
+
if (columnType === "text") return TextProperty(options);
|
|
664
|
+
if (columnType === "money") return MoneyProperty(options);
|
|
665
|
+
if (columnType.startsWith("int")) return IntProperty(options);
|
|
666
|
+
if (columnType.startsWith("smallint")) return IntProperty(options);
|
|
667
|
+
if (columnType.startsWith("tinyint")) return TinyintProperty(options);
|
|
668
|
+
if (columnType.startsWith("double")) return DoubleProperty(options);
|
|
669
|
+
if (columnType.startsWith("decimal") || columnType.startsWith("numeric")) return DecimalProperty(options);
|
|
670
|
+
if (columnType === "datetime") return DatetimeProperty(options);
|
|
671
|
+
}
|
|
672
|
+
if (meta.type === "varchar") return VarcharProperty(meta.length, options);
|
|
673
|
+
if (meta.type === "char") return CharProperty(meta.length, options);
|
|
674
|
+
if (meta.type === "text") return TextProperty(options);
|
|
675
|
+
if (meta.type === "money") return MoneyProperty(options);
|
|
676
|
+
if (meta.type === "int") return IntProperty(options);
|
|
677
|
+
if (meta.type === "smallint") return IntProperty(options);
|
|
678
|
+
if (meta.type === "tinyint") return TinyintProperty(options);
|
|
679
|
+
if (meta.type === "double") return DoubleProperty(options);
|
|
680
|
+
if (meta.type === "decimal" || meta.type === "numeric") return DecimalProperty(options);
|
|
681
|
+
if (meta.type === "datetime") return DatetimeProperty(options);
|
|
682
|
+
if (meta.type === "boolean" || meta.type === "bool") return BooleanProperty(options);
|
|
683
|
+
if (meta.type === "bigint") return BigIntProperty(options);
|
|
684
|
+
if (meta.type instanceof import_core.BigIntType) return BigIntProperty(options);
|
|
685
|
+
logger.warn(`No decorator founded for type ${meta.type} for property ${meta.name}.`);
|
|
686
|
+
return () => {
|
|
687
|
+
};
|
|
688
|
+
}
|
|
689
|
+
__name(ApiScalarEntityProperty, "ApiScalarEntityProperty");
|
|
690
|
+
function getEnumOptions(options) {
|
|
691
|
+
if (options.meta.enum !== true) return {};
|
|
692
|
+
const items = options.meta.items;
|
|
693
|
+
const values2 = typeof items === "function" ? items() : items;
|
|
694
|
+
const enumName = options.schema?.enumName;
|
|
695
|
+
return {
|
|
696
|
+
enum: values2,
|
|
697
|
+
enumName
|
|
698
|
+
};
|
|
699
|
+
}
|
|
700
|
+
__name(getEnumOptions, "getEnumOptions");
|
|
701
|
+
function VarcharProperty(length, options) {
|
|
702
|
+
const decorators = [];
|
|
703
|
+
if (!options.unverified) {
|
|
704
|
+
decorators.push((0, import_class_validator6.IsString)());
|
|
705
|
+
if (length) decorators.push((0, import_class_validator6.MaxLength)(length));
|
|
706
|
+
}
|
|
707
|
+
decorators.push(Property({
|
|
708
|
+
type: /* @__PURE__ */ __name(() => String, "type"),
|
|
709
|
+
optional: options.meta.nullable,
|
|
710
|
+
schema: {
|
|
711
|
+
type: "string",
|
|
712
|
+
maxLength: length,
|
|
713
|
+
...options.schema || {},
|
|
714
|
+
...getEnumOptions(options),
|
|
715
|
+
required: !options.meta.nullable,
|
|
716
|
+
description: options.meta.comment
|
|
717
|
+
}
|
|
718
|
+
}));
|
|
719
|
+
return (0, import_common6.applyDecorators)(...decorators);
|
|
720
|
+
}
|
|
721
|
+
__name(VarcharProperty, "VarcharProperty");
|
|
722
|
+
function CharProperty(length, options) {
|
|
723
|
+
const decorators = [];
|
|
724
|
+
if (!options.unverified) {
|
|
725
|
+
decorators.push((0, import_class_validator6.IsString)());
|
|
726
|
+
if (length) decorators.push((0, import_class_validator6.MaxLength)(length), (0, import_class_validator6.MinLength)(length));
|
|
727
|
+
}
|
|
728
|
+
decorators.push(Property({
|
|
729
|
+
type: /* @__PURE__ */ __name(() => String, "type"),
|
|
730
|
+
optional: options.meta.nullable,
|
|
731
|
+
schema: {
|
|
732
|
+
type: "string",
|
|
733
|
+
maxLength: length,
|
|
734
|
+
minimum: length,
|
|
735
|
+
...options.schema || {},
|
|
736
|
+
...getEnumOptions(options),
|
|
737
|
+
required: !options.meta.nullable,
|
|
738
|
+
description: options.meta.comment
|
|
739
|
+
}
|
|
740
|
+
}));
|
|
741
|
+
return (0, import_common6.applyDecorators)(...decorators);
|
|
742
|
+
}
|
|
743
|
+
__name(CharProperty, "CharProperty");
|
|
744
|
+
function TextProperty(options) {
|
|
745
|
+
const decorators = [];
|
|
746
|
+
if (!options.unverified) {
|
|
747
|
+
decorators.push((0, import_class_validator6.IsString)());
|
|
748
|
+
}
|
|
749
|
+
decorators.push(Property({
|
|
750
|
+
type: /* @__PURE__ */ __name(() => String, "type"),
|
|
751
|
+
optional: options.meta.nullable,
|
|
752
|
+
schema: {
|
|
753
|
+
type: "string",
|
|
754
|
+
...options.schema || {},
|
|
755
|
+
...getEnumOptions(options),
|
|
756
|
+
required: !options.meta.nullable,
|
|
757
|
+
description: options.meta.comment
|
|
758
|
+
}
|
|
759
|
+
}));
|
|
760
|
+
return (0, import_common6.applyDecorators)(...decorators);
|
|
761
|
+
}
|
|
762
|
+
__name(TextProperty, "TextProperty");
|
|
763
|
+
function MoneyProperty(options) {
|
|
764
|
+
const decorators = [];
|
|
765
|
+
if (!options.unverified) {
|
|
766
|
+
decorators.push((0, import_class_validator6.IsCurrency)({
|
|
767
|
+
symbol: ""
|
|
768
|
+
}));
|
|
769
|
+
}
|
|
770
|
+
decorators.push(Property({
|
|
771
|
+
type: /* @__PURE__ */ __name(() => String, "type"),
|
|
772
|
+
optional: options.meta.nullable,
|
|
773
|
+
schema: {
|
|
774
|
+
type: "string",
|
|
775
|
+
format: "money",
|
|
776
|
+
...options.schema || {},
|
|
777
|
+
required: !options.meta.nullable,
|
|
778
|
+
description: options.meta.comment
|
|
779
|
+
}
|
|
780
|
+
}));
|
|
781
|
+
return (0, import_common6.applyDecorators)(...decorators);
|
|
782
|
+
}
|
|
783
|
+
__name(MoneyProperty, "MoneyProperty");
|
|
784
|
+
function BigIntProperty(options) {
|
|
785
|
+
const { meta } = options;
|
|
786
|
+
let mode;
|
|
787
|
+
if (meta.type === "bigint") {
|
|
788
|
+
mode = "string";
|
|
789
|
+
} else if (meta.type instanceof import_core.BigIntType) {
|
|
790
|
+
const metaType = meta.type;
|
|
791
|
+
mode = metaType.mode === "string" ? "string" : "number";
|
|
792
|
+
} else {
|
|
793
|
+
throw new Error(`Unsupported type for BigIntProperty: ${meta.type}`);
|
|
794
|
+
}
|
|
795
|
+
const decorators = [];
|
|
796
|
+
if (mode === "string") {
|
|
797
|
+
if (!options.unverified) {
|
|
798
|
+
decorators.push((0, import_class_validator6.IsString)());
|
|
799
|
+
}
|
|
800
|
+
decorators.push(Property({
|
|
801
|
+
type: /* @__PURE__ */ __name(() => String, "type"),
|
|
802
|
+
optional: options.meta.nullable,
|
|
803
|
+
schema: {
|
|
804
|
+
type: "string",
|
|
805
|
+
...options.schema || {},
|
|
806
|
+
...getEnumOptions(options),
|
|
807
|
+
required: !options.meta.nullable,
|
|
808
|
+
description: options.meta.comment
|
|
809
|
+
}
|
|
810
|
+
}));
|
|
811
|
+
} else {
|
|
812
|
+
if (!options.unverified) {
|
|
813
|
+
decorators.push((0, import_class_validator6.IsInt)());
|
|
814
|
+
}
|
|
815
|
+
decorators.push(Property({
|
|
816
|
+
type: /* @__PURE__ */ __name(() => Number, "type"),
|
|
817
|
+
optional: options.meta.nullable,
|
|
818
|
+
schema: {
|
|
819
|
+
type: "integer",
|
|
820
|
+
format: "int64",
|
|
821
|
+
...options.schema || {},
|
|
822
|
+
...getEnumOptions(options),
|
|
823
|
+
required: !options.meta.nullable,
|
|
824
|
+
description: options.meta.comment
|
|
825
|
+
}
|
|
826
|
+
}));
|
|
827
|
+
}
|
|
828
|
+
return (0, import_common6.applyDecorators)(...decorators);
|
|
829
|
+
}
|
|
830
|
+
__name(BigIntProperty, "BigIntProperty");
|
|
831
|
+
function IntProperty(options) {
|
|
832
|
+
const decorators = [];
|
|
833
|
+
if (!options.unverified) {
|
|
834
|
+
decorators.push((0, import_class_validator6.IsInt)());
|
|
835
|
+
}
|
|
836
|
+
decorators.push(Property({
|
|
837
|
+
type: /* @__PURE__ */ __name(() => Number, "type"),
|
|
838
|
+
optional: options.meta.nullable,
|
|
839
|
+
schema: {
|
|
840
|
+
type: "integer",
|
|
841
|
+
minimum: options.meta.unsigned ? 0 : -2147483647,
|
|
842
|
+
maximum: options.meta.unsigned ? 4294967295 : 2147483647,
|
|
843
|
+
...options.schema || {},
|
|
844
|
+
...getEnumOptions(options),
|
|
845
|
+
required: !options.meta.nullable,
|
|
846
|
+
description: options.meta.comment
|
|
847
|
+
}
|
|
848
|
+
}));
|
|
849
|
+
return (0, import_common6.applyDecorators)(...decorators);
|
|
850
|
+
}
|
|
851
|
+
__name(IntProperty, "IntProperty");
|
|
852
|
+
function TinyintProperty(options) {
|
|
853
|
+
const decorators = [];
|
|
854
|
+
if (!options.unverified) {
|
|
855
|
+
decorators.push((0, import_class_validator6.IsInt)());
|
|
856
|
+
}
|
|
857
|
+
decorators.push(Property({
|
|
858
|
+
type: /* @__PURE__ */ __name(() => Number, "type"),
|
|
859
|
+
optional: options.meta.nullable,
|
|
860
|
+
schema: {
|
|
861
|
+
type: "integer",
|
|
862
|
+
minimum: options.meta.unsigned ? 0 : -128,
|
|
863
|
+
maximum: options.meta.unsigned ? 255 : 127,
|
|
864
|
+
...options.schema || {},
|
|
865
|
+
...getEnumOptions(options),
|
|
866
|
+
required: !options.meta.nullable,
|
|
867
|
+
description: options.meta.comment
|
|
868
|
+
}
|
|
869
|
+
}));
|
|
870
|
+
return (0, import_common6.applyDecorators)(...decorators);
|
|
871
|
+
}
|
|
872
|
+
__name(TinyintProperty, "TinyintProperty");
|
|
873
|
+
function DoubleProperty(options) {
|
|
874
|
+
const decorators = [];
|
|
875
|
+
if (!options.unverified) {
|
|
876
|
+
decorators.push((0, import_class_validator6.IsNumber)());
|
|
877
|
+
}
|
|
878
|
+
decorators.push(Property({
|
|
879
|
+
type: /* @__PURE__ */ __name(() => Number, "type"),
|
|
880
|
+
optional: options.meta.nullable,
|
|
881
|
+
schema: {
|
|
882
|
+
type: "number",
|
|
883
|
+
format: "double",
|
|
884
|
+
minimum: options.meta.unsigned ? 0 : void 0,
|
|
885
|
+
...options.schema || {},
|
|
886
|
+
...getEnumOptions(options),
|
|
887
|
+
required: !options.meta.nullable,
|
|
888
|
+
description: options.meta.comment
|
|
889
|
+
}
|
|
890
|
+
}));
|
|
891
|
+
return (0, import_common6.applyDecorators)(...decorators);
|
|
892
|
+
}
|
|
893
|
+
__name(DoubleProperty, "DoubleProperty");
|
|
894
|
+
function DecimalProperty(options) {
|
|
895
|
+
const decorators = [];
|
|
896
|
+
if (!options.unverified) {
|
|
897
|
+
if (options.meta.scale) decorators.push((0, import_class_validator6.IsNumber)({
|
|
898
|
+
maxDecimalPlaces: options.meta.scale
|
|
899
|
+
}));
|
|
900
|
+
else decorators.push((0, import_class_validator6.IsNumber)());
|
|
901
|
+
}
|
|
902
|
+
decorators.push(Property({
|
|
903
|
+
type: /* @__PURE__ */ __name(() => Number, "type"),
|
|
904
|
+
optional: options.meta.nullable,
|
|
905
|
+
schema: {
|
|
906
|
+
type: "number",
|
|
907
|
+
format: "double",
|
|
908
|
+
minimum: options.meta.unsigned ? 0 : void 0,
|
|
909
|
+
...options.schema || {},
|
|
910
|
+
...getEnumOptions(options),
|
|
911
|
+
required: !options.meta.nullable,
|
|
912
|
+
description: options.meta.comment
|
|
913
|
+
}
|
|
914
|
+
}));
|
|
915
|
+
return (0, import_common6.applyDecorators)(...decorators);
|
|
916
|
+
}
|
|
917
|
+
__name(DecimalProperty, "DecimalProperty");
|
|
918
|
+
function DatetimeProperty(options) {
|
|
919
|
+
const decorators = [];
|
|
920
|
+
if (!options.unverified) {
|
|
921
|
+
decorators.push((0, import_class_validator6.IsISO8601)());
|
|
922
|
+
}
|
|
923
|
+
decorators.push(Property({
|
|
924
|
+
type: /* @__PURE__ */ __name(() => Date, "type"),
|
|
925
|
+
optional: options.meta.nullable,
|
|
926
|
+
schema: {
|
|
927
|
+
type: "string",
|
|
928
|
+
format: "date-time",
|
|
929
|
+
...options.schema || {},
|
|
930
|
+
required: !options.meta.nullable,
|
|
931
|
+
description: options.meta.comment
|
|
932
|
+
}
|
|
933
|
+
}));
|
|
934
|
+
return (0, import_common6.applyDecorators)(...decorators);
|
|
935
|
+
}
|
|
936
|
+
__name(DatetimeProperty, "DatetimeProperty");
|
|
937
|
+
function BooleanProperty(options) {
|
|
938
|
+
const decorators = [];
|
|
939
|
+
if (!options.unverified) {
|
|
940
|
+
decorators.push((0, import_class_validator6.IsBoolean)());
|
|
941
|
+
}
|
|
942
|
+
decorators.push(Property({
|
|
943
|
+
type: /* @__PURE__ */ __name(() => Boolean, "type"),
|
|
944
|
+
optional: options.meta.nullable,
|
|
945
|
+
schema: {
|
|
946
|
+
type: "boolean",
|
|
947
|
+
...options.schema || {},
|
|
948
|
+
required: !options.meta.nullable,
|
|
949
|
+
description: options.meta.comment
|
|
950
|
+
}
|
|
951
|
+
}));
|
|
952
|
+
return (0, import_common6.applyDecorators)(...decorators);
|
|
953
|
+
}
|
|
954
|
+
__name(BooleanProperty, "BooleanProperty");
|
|
955
|
+
|
|
956
|
+
// src/utils/nestjs-swagger-utils.ts
|
|
957
|
+
var R3 = __toESM(require("ramda"));
|
|
958
|
+
var import_model_properties_accessor = require("@nestjs/swagger/dist/services/model-properties-accessor");
|
|
959
|
+
var import_constants = require("@nestjs/swagger/dist/constants");
|
|
960
|
+
var import_plugin_constants = require("@nestjs/swagger/dist/plugin/plugin-constants");
|
|
961
|
+
var import_mapped_types = require("@nestjs/swagger/dist/type-helpers/mapped-types.utils");
|
|
962
|
+
var import_swagger3 = require("@nestjs/swagger");
|
|
963
|
+
var import_shared = require("@nestjs/common/utils/shared.utils");
|
|
964
|
+
var import_is_built_in_type = require("@nestjs/swagger/dist/utils/is-built-in-type.util");
|
|
965
|
+
var import_schema_object_metadata = require("@nestjs/swagger/dist/interfaces/schema-object-metadata.interface");
|
|
966
|
+
var modelPropertiesAccessor = new import_model_properties_accessor.ModelPropertiesAccessor();
|
|
967
|
+
function cloneMetadata(target, source, keys) {
|
|
968
|
+
(0, import_mapped_types.clonePluginMetadataFactory)(target, source.prototype, (metadata) => R3.pick(keys, metadata));
|
|
969
|
+
for (const propertyKey of keys) {
|
|
970
|
+
const metadata = getMetadataOfDecorator(source, propertyKey);
|
|
971
|
+
if (metadata) {
|
|
972
|
+
(0, import_swagger3.ApiProperty)(metadata)(target.prototype, propertyKey);
|
|
973
|
+
}
|
|
974
|
+
}
|
|
975
|
+
}
|
|
976
|
+
__name(cloneMetadata, "cloneMetadata");
|
|
977
|
+
function getMetadataOfDecorator(classRef, propertyKey) {
|
|
978
|
+
if (propertyKey) {
|
|
979
|
+
return Reflect.getMetadata(import_constants.DECORATORS.API_MODEL_PROPERTIES, classRef.prototype, propertyKey);
|
|
980
|
+
}
|
|
981
|
+
const props = modelPropertiesAccessor.getModelProperties(classRef.prototype);
|
|
982
|
+
return R3.fromPairs(props.map((prop) => [
|
|
983
|
+
prop,
|
|
984
|
+
Reflect.getMetadata(import_constants.DECORATORS.API_MODEL_PROPERTIES, classRef.prototype, prop)
|
|
985
|
+
]));
|
|
986
|
+
}
|
|
987
|
+
__name(getMetadataOfDecorator, "getMetadataOfDecorator");
|
|
988
|
+
function getMetadataOfPlugin(classRef, propertyKey) {
|
|
989
|
+
const propsInPlugin = typeof classRef[import_plugin_constants.METADATA_FACTORY_NAME] === "function" ? classRef[import_plugin_constants.METADATA_FACTORY_NAME]() : {};
|
|
990
|
+
if (propertyKey) return propsInPlugin[propertyKey];
|
|
991
|
+
return propsInPlugin;
|
|
992
|
+
}
|
|
993
|
+
__name(getMetadataOfPlugin, "getMetadataOfPlugin");
|
|
994
|
+
function getMetadata(classRef, propertyKey) {
|
|
995
|
+
const propsInDecorator = getMetadataOfDecorator(classRef);
|
|
996
|
+
const propsInPlugin = getMetadataOfPlugin(classRef);
|
|
997
|
+
const metadataMap = R3.mergeRight(propsInPlugin, propsInDecorator);
|
|
998
|
+
if (propertyKey) return metadataMap[propertyKey];
|
|
999
|
+
return metadataMap;
|
|
1000
|
+
}
|
|
1001
|
+
__name(getMetadata, "getMetadata");
|
|
1002
|
+
function isLazyTypeFunc(type) {
|
|
1003
|
+
return (0, import_shared.isFunction)(type) && type.name == "type";
|
|
1004
|
+
}
|
|
1005
|
+
__name(isLazyTypeFunc, "isLazyTypeFunc");
|
|
1006
|
+
|
|
1007
|
+
// src/utils/mikro-orm-utils.ts
|
|
1008
|
+
var R4 = __toESM(require("ramda"));
|
|
1009
|
+
var import_core2 = require("@mikro-orm/core");
|
|
1010
|
+
function getMetadata2(classRef) {
|
|
1011
|
+
const metadatas = [];
|
|
1012
|
+
let parent = classRef;
|
|
1013
|
+
do {
|
|
1014
|
+
const meta = import_core2.MetadataStorage.getMetadataFromDecorator(parent);
|
|
1015
|
+
if (meta instanceof import_core2.EntityMetadata) metadatas.push(meta);
|
|
1016
|
+
parent = Object.getPrototypeOf(parent);
|
|
1017
|
+
} while (parent && parent !== Object.prototype);
|
|
1018
|
+
return R4.unnest(metadatas.map((meta) => R4.values(meta.properties)));
|
|
1019
|
+
}
|
|
1020
|
+
__name(getMetadata2, "getMetadata");
|
|
1021
|
+
|
|
1022
|
+
// src/mikro-orm/converters/entity-ref-type/entity-ref-type.ts
|
|
1023
|
+
var import_mapped_types2 = require("@nestjs/mapped-types");
|
|
1024
|
+
var EntityRefTypeClassMetadataPropertyKey = /* @__PURE__ */ Symbol("EntityRefTypeClassMetadataPropertyKey");
|
|
1025
|
+
var storage = /* @__PURE__ */ new WeakMap();
|
|
1026
|
+
function EntityRefType(classRef) {
|
|
1027
|
+
if (storage.has(classRef)) {
|
|
1028
|
+
return storage.get(classRef);
|
|
1029
|
+
}
|
|
1030
|
+
const properties = getMetadata2(classRef);
|
|
1031
|
+
const primaryProperties = properties.filter((prop) => prop.primary).map((prop) => prop.name);
|
|
1032
|
+
if (!primaryProperties.length) {
|
|
1033
|
+
throw new Error(`Cannot create EntityRefType for ${classRef.name} because it has no primary properties.`);
|
|
1034
|
+
}
|
|
1035
|
+
let EntityRefTypeClass = class EntityRefTypeClass {
|
|
1036
|
+
static {
|
|
1037
|
+
__name(this, "EntityRefTypeClass");
|
|
1038
|
+
}
|
|
1039
|
+
};
|
|
1040
|
+
EntityRefTypeClass[EntityRefTypeClassMetadataPropertyKey] = {};
|
|
1041
|
+
cloneMetadata(EntityRefTypeClass, classRef, primaryProperties);
|
|
1042
|
+
(0, import_mapped_types2.inheritValidationMetadata)(classRef, EntityRefTypeClass, (key) => primaryProperties.includes(key));
|
|
1043
|
+
(0, import_mapped_types2.inheritTransformationMetadata)(classRef, EntityRefTypeClass, (key) => primaryProperties.includes(key));
|
|
1044
|
+
storage.set(classRef, EntityRefTypeClass);
|
|
1045
|
+
return EntityRefTypeClass;
|
|
1046
|
+
}
|
|
1047
|
+
__name(EntityRefType, "EntityRefType");
|
|
1048
|
+
|
|
1049
|
+
// src/mikro-orm/decorators/api-entity-property.decorator.ts
|
|
1050
|
+
function ApiEntityProperty(options) {
|
|
1051
|
+
return (target, propertyKey) => {
|
|
1052
|
+
const meta = import_core3.MetadataStorage.getMetadataFromDecorator(target.constructor);
|
|
1053
|
+
const prop = meta.properties[propertyKey];
|
|
1054
|
+
if (!prop) return;
|
|
1055
|
+
if (prop.hidden === true) {
|
|
1056
|
+
(0, import_swagger4.ApiHideProperty)()(target, propertyKey);
|
|
1057
|
+
return;
|
|
1058
|
+
}
|
|
1059
|
+
if (prop.kind === import_core3.ReferenceKind.EMBEDDED) {
|
|
1060
|
+
return;
|
|
1061
|
+
}
|
|
1062
|
+
if (prop.kind === import_core3.ReferenceKind.SCALAR) {
|
|
1063
|
+
ApiScalarEntityProperty({
|
|
1064
|
+
meta: prop,
|
|
1065
|
+
schema: options
|
|
1066
|
+
})(target, propertyKey);
|
|
1067
|
+
return;
|
|
1068
|
+
}
|
|
1069
|
+
const getType = /* @__PURE__ */ __name(() => {
|
|
1070
|
+
const ent = prop.entity();
|
|
1071
|
+
if (prop.eager === true) return ent;
|
|
1072
|
+
if (typeof ent === "function") {
|
|
1073
|
+
return EntityRefType(ent);
|
|
1074
|
+
}
|
|
1075
|
+
return Object;
|
|
1076
|
+
}, "getType");
|
|
1077
|
+
if (prop.kind === import_core3.ReferenceKind.ONE_TO_ONE || prop.kind === import_core3.ReferenceKind.MANY_TO_ONE) {
|
|
1078
|
+
Property({
|
|
1079
|
+
type: /* @__PURE__ */ __name(() => getType(), "type"),
|
|
1080
|
+
relation: {
|
|
1081
|
+
kind: prop.kind,
|
|
1082
|
+
type: /* @__PURE__ */ __name(() => getType(), "type")
|
|
1083
|
+
},
|
|
1084
|
+
schema: {
|
|
1085
|
+
description: prop.comment,
|
|
1086
|
+
required: !prop.nullable
|
|
1087
|
+
}
|
|
1088
|
+
})(target, propertyKey);
|
|
1089
|
+
return;
|
|
1090
|
+
}
|
|
1091
|
+
if (prop.kind === import_core3.ReferenceKind.ONE_TO_MANY || prop.kind === import_core3.ReferenceKind.MANY_TO_MANY) {
|
|
1092
|
+
NestedProperty(() => getType(), {
|
|
1093
|
+
each: true,
|
|
1094
|
+
optional: prop.nullable,
|
|
1095
|
+
schema: {
|
|
1096
|
+
description: prop.comment,
|
|
1097
|
+
type: "array",
|
|
1098
|
+
items: {
|
|
1099
|
+
type: (0, import_swagger4.getSchemaPath)(() => getType())
|
|
1100
|
+
}
|
|
1101
|
+
}
|
|
1102
|
+
})(target, propertyKey);
|
|
1103
|
+
Relation({
|
|
1104
|
+
kind: prop.kind,
|
|
1105
|
+
type: /* @__PURE__ */ __name(() => getType(), "type")
|
|
1106
|
+
})(target, propertyKey);
|
|
1107
|
+
return;
|
|
1108
|
+
}
|
|
1109
|
+
};
|
|
1110
|
+
}
|
|
1111
|
+
__name(ApiEntityProperty, "ApiEntityProperty");
|
|
1112
|
+
|
|
1113
|
+
// src/mikro-orm/decorators/entity-property.decorator.ts
|
|
1114
|
+
function EntityProperty(options) {
|
|
1115
|
+
return (target, propertyKey) => {
|
|
1116
|
+
if (typeof propertyKey !== "string") throw new TypeError("@EntityProperty() can only be used on string property");
|
|
1117
|
+
(0, import_core4.Property)(options)(target, propertyKey);
|
|
1118
|
+
ApiEntityProperty({
|
|
1119
|
+
example: options?.example
|
|
1120
|
+
})(target, propertyKey);
|
|
1121
|
+
};
|
|
1122
|
+
}
|
|
1123
|
+
__name(EntityProperty, "EntityProperty");
|
|
1124
|
+
|
|
1125
|
+
// src/mikro-orm/models/timestamped-entity.ts
|
|
1126
|
+
function _ts_decorate2(decorators, target, key, desc) {
|
|
1127
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1128
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1129
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1130
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1131
|
+
}
|
|
1132
|
+
__name(_ts_decorate2, "_ts_decorate");
|
|
1133
|
+
function _ts_metadata2(k, v) {
|
|
1134
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
1135
|
+
}
|
|
1136
|
+
__name(_ts_metadata2, "_ts_metadata");
|
|
1137
|
+
var TimestampedEntity = class {
|
|
1138
|
+
static {
|
|
1139
|
+
__name(this, "TimestampedEntity");
|
|
1140
|
+
}
|
|
1141
|
+
[import_core5.Config];
|
|
1142
|
+
[import_core5.OptionalProps];
|
|
1143
|
+
createdAt = /* @__PURE__ */ new Date();
|
|
1144
|
+
updatedAt = /* @__PURE__ */ new Date();
|
|
1145
|
+
};
|
|
1146
|
+
_ts_decorate2([
|
|
1147
|
+
EntityProperty({
|
|
1148
|
+
type: "datetime",
|
|
1149
|
+
onCreate: /* @__PURE__ */ __name(() => /* @__PURE__ */ new Date(), "onCreate"),
|
|
1150
|
+
defaultRaw: "CURRENT_TIMESTAMP",
|
|
1151
|
+
comment: "\u521B\u5EFA\u65F6\u95F4"
|
|
1152
|
+
}),
|
|
1153
|
+
_ts_metadata2("design:type", typeof Date === "undefined" ? Object : Date)
|
|
1154
|
+
], TimestampedEntity.prototype, "createdAt", void 0);
|
|
1155
|
+
_ts_decorate2([
|
|
1156
|
+
EntityProperty({
|
|
1157
|
+
type: "datetime",
|
|
1158
|
+
onUpdate: /* @__PURE__ */ __name(() => /* @__PURE__ */ new Date(), "onUpdate"),
|
|
1159
|
+
defaultRaw: "CURRENT_TIMESTAMP",
|
|
1160
|
+
comment: "\u66F4\u65B0\u65F6\u95F4"
|
|
1161
|
+
}),
|
|
1162
|
+
_ts_metadata2("design:type", typeof Date === "undefined" ? Object : Date)
|
|
1163
|
+
], TimestampedEntity.prototype, "updatedAt", void 0);
|
|
1164
|
+
|
|
1165
|
+
// src/mikro-orm/models/base-entity.ts
|
|
1166
|
+
function _ts_decorate3(decorators, target, key, desc) {
|
|
1167
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1168
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1169
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1170
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1171
|
+
}
|
|
1172
|
+
__name(_ts_decorate3, "_ts_decorate");
|
|
1173
|
+
function _ts_metadata3(k, v) {
|
|
1174
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
1175
|
+
}
|
|
1176
|
+
__name(_ts_metadata3, "_ts_metadata");
|
|
1177
|
+
var BaseEntity = class extends TimestampedEntity {
|
|
1178
|
+
static {
|
|
1179
|
+
__name(this, "BaseEntity");
|
|
1180
|
+
}
|
|
1181
|
+
// [Config]?: DefineConfig<{ forceObject: true }>;
|
|
1182
|
+
[import_core6.PrimaryKeyProp];
|
|
1183
|
+
id;
|
|
1184
|
+
};
|
|
1185
|
+
_ts_decorate3([
|
|
1186
|
+
(0, import_swagger5.ApiProperty)({
|
|
1187
|
+
type: "string",
|
|
1188
|
+
description: "PK",
|
|
1189
|
+
example: "1",
|
|
1190
|
+
required: true
|
|
1191
|
+
}),
|
|
1192
|
+
(0, import_core6.PrimaryKey)({
|
|
1193
|
+
type: new import_core6.BigIntType("string"),
|
|
1194
|
+
comment: "\u4E3B\u952E"
|
|
1195
|
+
}),
|
|
1196
|
+
(0, import_class_validator7.IsNumberString)(),
|
|
1197
|
+
_ts_metadata3("design:type", String)
|
|
1198
|
+
], BaseEntity.prototype, "id", void 0);
|
|
1199
|
+
|
|
1200
|
+
// src/mikro-orm/converters/entity-dto-type/entity-dto-type.ts
|
|
1201
|
+
var import_mapped_types3 = require("@nestjs/mapped-types");
|
|
1202
|
+
var import_core7 = require("@mikro-orm/core");
|
|
1203
|
+
function EntityDtoType(entity) {
|
|
1204
|
+
const properties = getMetadata2(entity);
|
|
1205
|
+
if (!properties.length) {
|
|
1206
|
+
throw new Error(`Cannot create EntityDtoType for ${entity.name} because it isn't an MikroORM Entity.`);
|
|
1207
|
+
}
|
|
1208
|
+
const keys = properties.filter((prop) => {
|
|
1209
|
+
if (prop.hidden) return false;
|
|
1210
|
+
if (prop.kind === "scalar" && prop.ref) return false;
|
|
1211
|
+
return true;
|
|
1212
|
+
}).map((prop) => prop.name);
|
|
1213
|
+
let EntityDtoTypeClass = class EntityDtoTypeClass2 {
|
|
1214
|
+
static {
|
|
1215
|
+
__name(this, "EntityDtoTypeClass");
|
|
1216
|
+
}
|
|
1217
|
+
static from(entity2) {
|
|
1218
|
+
const dto = new EntityDtoTypeClass2();
|
|
1219
|
+
const json = (0, import_core7.wrap)(entity2).toPOJO();
|
|
1220
|
+
for (const property of properties) {
|
|
1221
|
+
if (property.hidden) continue;
|
|
1222
|
+
if (property.kind === "scalar" && !property.ref) {
|
|
1223
|
+
dto[property.name] = json[property.name];
|
|
1224
|
+
}
|
|
1225
|
+
if (property.kind === "m:n" || property.kind === "1:m") {
|
|
1226
|
+
dto[property.name] = json[property.name];
|
|
1227
|
+
}
|
|
1228
|
+
if (property.kind === "1:1" || property.kind === "m:1") {
|
|
1229
|
+
dto[property.name] = json[property.name];
|
|
1230
|
+
}
|
|
1231
|
+
}
|
|
1232
|
+
return dto;
|
|
1233
|
+
}
|
|
1234
|
+
};
|
|
1235
|
+
(0, import_mapped_types3.inheritValidationMetadata)(entity, EntityDtoTypeClass, (key) => keys.includes(key));
|
|
1236
|
+
(0, import_mapped_types3.inheritTransformationMetadata)(entity, EntityDtoTypeClass, (key) => keys.includes(key));
|
|
1237
|
+
cloneMetadata(EntityDtoTypeClass, entity, keys);
|
|
1238
|
+
for (const property of keys) {
|
|
1239
|
+
ModelRegister.copyProperty(entity, EntityDtoTypeClass, property);
|
|
1240
|
+
}
|
|
1241
|
+
return EntityDtoTypeClass;
|
|
1242
|
+
}
|
|
1243
|
+
__name(EntityDtoType, "EntityDtoType");
|
|
1244
|
+
|
|
1245
|
+
// src/mikro-orm/decorators/entity-enum.decorator.ts
|
|
1246
|
+
var import_core8 = require("@mikro-orm/core");
|
|
1247
|
+
function EntityEnum(options) {
|
|
1248
|
+
return (target, propertyKey) => {
|
|
1249
|
+
if (typeof propertyKey !== "string") throw new TypeError("@EntityEnum() can only be used on string property");
|
|
1250
|
+
(0, import_core8.Enum)(options)(target, propertyKey);
|
|
1251
|
+
ApiEntityProperty({
|
|
1252
|
+
example: options.example,
|
|
1253
|
+
enumName: options.enumName
|
|
1254
|
+
})(target, propertyKey);
|
|
1255
|
+
};
|
|
1256
|
+
}
|
|
1257
|
+
__name(EntityEnum, "EntityEnum");
|
|
1258
|
+
|
|
1259
|
+
// src/mikro-orm/decorators/entity-transient.decorator.ts
|
|
1260
|
+
var import_core9 = require("@mikro-orm/core");
|
|
1261
|
+
function EntityTransient() {
|
|
1262
|
+
return (0, import_core9.Property)({
|
|
1263
|
+
persist: false
|
|
1264
|
+
});
|
|
1265
|
+
}
|
|
1266
|
+
__name(EntityTransient, "EntityTransient");
|
|
1267
|
+
|
|
1268
|
+
// src/mikro-orm/decorators/entity-one-to-one.decorator.ts
|
|
1269
|
+
var import_core10 = require("@mikro-orm/core");
|
|
1270
|
+
function EntityOneToOne(entity, mappedByOrOptions, options) {
|
|
1271
|
+
return (target, propertyKey) => {
|
|
1272
|
+
if (typeof propertyKey !== "string") throw new TypeError("@EntityOneToOne() can only be used on string property");
|
|
1273
|
+
(0, import_core10.OneToOne)(entity, mappedByOrOptions, options)(target, propertyKey);
|
|
1274
|
+
ApiEntityProperty()(target, propertyKey);
|
|
1275
|
+
};
|
|
1276
|
+
}
|
|
1277
|
+
__name(EntityOneToOne, "EntityOneToOne");
|
|
1278
|
+
|
|
1279
|
+
// src/mikro-orm/decorators/entity-one-to-many.decorator.ts
|
|
1280
|
+
var import_core11 = require("@mikro-orm/core");
|
|
1281
|
+
function EntityOneToMany(options) {
|
|
1282
|
+
return (target, propertyKey) => {
|
|
1283
|
+
if (typeof propertyKey !== "string") throw new TypeError("@EntityOneToMany() can only be used on string property");
|
|
1284
|
+
(0, import_core11.OneToMany)(options)(target, propertyKey);
|
|
1285
|
+
ApiEntityProperty()(target, propertyKey);
|
|
1286
|
+
};
|
|
1287
|
+
}
|
|
1288
|
+
__name(EntityOneToMany, "EntityOneToMany");
|
|
1289
|
+
|
|
1290
|
+
// src/mikro-orm/decorators/entity-many-to-one.decorator.ts
|
|
1291
|
+
var import_core12 = require("@mikro-orm/core");
|
|
1292
|
+
function EntityManyToOne(entity, options) {
|
|
1293
|
+
return (target, propertyKey) => {
|
|
1294
|
+
if (typeof propertyKey !== "string") throw new TypeError("@EntityManyToOne() can only be used on string property");
|
|
1295
|
+
(0, import_core12.ManyToOne)(entity, options)(target, propertyKey);
|
|
1296
|
+
ApiEntityProperty()(target, propertyKey);
|
|
1297
|
+
};
|
|
1298
|
+
}
|
|
1299
|
+
__name(EntityManyToOne, "EntityManyToOne");
|
|
1300
|
+
|
|
1301
|
+
// src/mikro-orm/decorators/entity-many-to-many.decorator.ts
|
|
1302
|
+
var import_core13 = require("@mikro-orm/core");
|
|
1303
|
+
function EntityManyToMany(entity, mappedBy, options) {
|
|
1304
|
+
return (target, propertyKey) => {
|
|
1305
|
+
if (typeof propertyKey !== "string") throw new TypeError("@EntityManyToMany() can only be used on string property");
|
|
1306
|
+
(0, import_core13.ManyToMany)(entity, mappedBy, options)(target, propertyKey);
|
|
1307
|
+
ApiEntityProperty()(target, propertyKey);
|
|
1308
|
+
};
|
|
1309
|
+
}
|
|
1310
|
+
__name(EntityManyToMany, "EntityManyToMany");
|
|
1311
|
+
|
|
1312
|
+
// src/mikro-orm/database.config.ts
|
|
1313
|
+
var import_class_transformer_extra = require("@buka/class-transformer-extra");
|
|
1314
|
+
var import_class_validator8 = require("class-validator");
|
|
1315
|
+
var R5 = __toESM(require("ramda"));
|
|
1316
|
+
var util = __toESM(require("util"));
|
|
1317
|
+
var import_migrations = require("@mikro-orm/migrations");
|
|
1318
|
+
var import_core14 = require("@mikro-orm/core");
|
|
1319
|
+
var import_common7 = require("@nestjs/common");
|
|
1320
|
+
function _ts_decorate4(decorators, target, key, desc) {
|
|
1321
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1322
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1323
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1324
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1325
|
+
}
|
|
1326
|
+
__name(_ts_decorate4, "_ts_decorate");
|
|
1327
|
+
function _ts_metadata4(k, v) {
|
|
1328
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
1329
|
+
}
|
|
1330
|
+
__name(_ts_metadata4, "_ts_metadata");
|
|
1331
|
+
var DatabaseConfig = class {
|
|
1332
|
+
static {
|
|
1333
|
+
__name(this, "DatabaseConfig");
|
|
1334
|
+
}
|
|
1335
|
+
debug = false;
|
|
1336
|
+
migration = false;
|
|
1337
|
+
dbName;
|
|
1338
|
+
host;
|
|
1339
|
+
port;
|
|
1340
|
+
user;
|
|
1341
|
+
password;
|
|
1342
|
+
timezone = "+08:00";
|
|
1343
|
+
toMikroOrmOptions(config) {
|
|
1344
|
+
let options = {
|
|
1345
|
+
host: this.host,
|
|
1346
|
+
port: this.port,
|
|
1347
|
+
user: this.user,
|
|
1348
|
+
password: this.password,
|
|
1349
|
+
dbName: this.dbName,
|
|
1350
|
+
debug: this.debug,
|
|
1351
|
+
timezone: this.timezone,
|
|
1352
|
+
forceUndefined: true,
|
|
1353
|
+
flushMode: import_core14.FlushMode.COMMIT,
|
|
1354
|
+
serialization: {
|
|
1355
|
+
forceObject: true
|
|
1356
|
+
},
|
|
1357
|
+
findOneOrFailHandler: /* @__PURE__ */ __name((entityName, where) => new import_common7.BadRequestException(`Cannot find ${entityName} where ${util.inspect(where)}`), "findOneOrFailHandler")
|
|
1358
|
+
};
|
|
1359
|
+
if (this.migration) {
|
|
1360
|
+
options = R5.mergeDeepRight(options, {
|
|
1361
|
+
extensions: [
|
|
1362
|
+
import_migrations.Migrator
|
|
1363
|
+
],
|
|
1364
|
+
migrations: {
|
|
1365
|
+
snapshotName: "snapshot",
|
|
1366
|
+
path: "migrations",
|
|
1367
|
+
fileName: /* @__PURE__ */ __name((timestamp) => `migration-${timestamp}`, "fileName")
|
|
1368
|
+
}
|
|
1369
|
+
});
|
|
1370
|
+
}
|
|
1371
|
+
return R5.mergeDeepRight(options, config || {});
|
|
1372
|
+
}
|
|
1373
|
+
};
|
|
1374
|
+
_ts_decorate4([
|
|
1375
|
+
(0, import_class_validator8.IsBoolean)()
|
|
1376
|
+
], DatabaseConfig.prototype, "debug", void 0);
|
|
1377
|
+
_ts_decorate4([
|
|
1378
|
+
(0, import_class_validator8.IsBoolean)(),
|
|
1379
|
+
_ts_metadata4("design:type", Boolean)
|
|
1380
|
+
], DatabaseConfig.prototype, "migration", void 0);
|
|
1381
|
+
_ts_decorate4([
|
|
1382
|
+
(0, import_class_validator8.IsString)(),
|
|
1383
|
+
_ts_metadata4("design:type", String)
|
|
1384
|
+
], DatabaseConfig.prototype, "dbName", void 0);
|
|
1385
|
+
_ts_decorate4([
|
|
1386
|
+
(0, import_class_validator8.IsString)(),
|
|
1387
|
+
_ts_metadata4("design:type", String)
|
|
1388
|
+
], DatabaseConfig.prototype, "host", void 0);
|
|
1389
|
+
_ts_decorate4([
|
|
1390
|
+
(0, import_class_transformer_extra.ToNumber)(),
|
|
1391
|
+
(0, import_class_validator8.IsNumber)({
|
|
1392
|
+
allowNaN: false
|
|
1393
|
+
}),
|
|
1394
|
+
_ts_metadata4("design:type", Number)
|
|
1395
|
+
], DatabaseConfig.prototype, "port", void 0);
|
|
1396
|
+
_ts_decorate4([
|
|
1397
|
+
(0, import_class_validator8.IsString)(),
|
|
1398
|
+
_ts_metadata4("design:type", String)
|
|
1399
|
+
], DatabaseConfig.prototype, "user", void 0);
|
|
1400
|
+
_ts_decorate4([
|
|
1401
|
+
(0, import_class_validator8.IsString)(),
|
|
1402
|
+
_ts_metadata4("design:type", String)
|
|
1403
|
+
], DatabaseConfig.prototype, "password", void 0);
|
|
1404
|
+
_ts_decorate4([
|
|
1405
|
+
(0, import_class_validator8.IsString)()
|
|
1406
|
+
], DatabaseConfig.prototype, "timezone", void 0);
|
|
1407
|
+
|
|
1408
|
+
// src/swagger/is-reference-object.ts
|
|
1409
|
+
function isReferenceObject(obj) {
|
|
1410
|
+
return !!obj && typeof obj === "object" && typeof obj.$ref === "string";
|
|
1411
|
+
}
|
|
1412
|
+
__name(isReferenceObject, "isReferenceObject");
|
|
1413
|
+
|
|
1414
|
+
// src/swagger/deep-dereference.ts
|
|
1415
|
+
function deepDereference(openapi, reference) {
|
|
1416
|
+
let current = reference;
|
|
1417
|
+
const stack = [];
|
|
1418
|
+
while (isReferenceObject(current)) {
|
|
1419
|
+
const refPath = current.$ref;
|
|
1420
|
+
if (stack.includes(refPath)) return void 0;
|
|
1421
|
+
stack.push(refPath);
|
|
1422
|
+
const parts = refPath.replace(/^#\//, "").split("/");
|
|
1423
|
+
let next = openapi;
|
|
1424
|
+
for (const part of parts) {
|
|
1425
|
+
next = next[part];
|
|
1426
|
+
}
|
|
1427
|
+
if (!next) return void 0;
|
|
1428
|
+
current = next;
|
|
1429
|
+
}
|
|
1430
|
+
return current;
|
|
1431
|
+
}
|
|
1432
|
+
__name(deepDereference, "deepDereference");
|
|
1433
|
+
|
|
1434
|
+
// src/swagger/for-each-parameter.ts
|
|
1435
|
+
function forEachParameter(openapi, callback) {
|
|
1436
|
+
for (const pathItem of Object.values(openapi.paths)) {
|
|
1437
|
+
for (const operation of Object.values(pathItem)) {
|
|
1438
|
+
if (operation && operation.parameters) {
|
|
1439
|
+
for (const parameter of operation.parameters) {
|
|
1440
|
+
if (!("$ref" in parameter)) {
|
|
1441
|
+
callback(parameter);
|
|
1442
|
+
}
|
|
1443
|
+
}
|
|
1444
|
+
}
|
|
1445
|
+
}
|
|
1446
|
+
}
|
|
1447
|
+
for (const parameter of Object.values(openapi.components?.parameters || {})) {
|
|
1448
|
+
if (!("$ref" in parameter)) {
|
|
1449
|
+
callback(parameter);
|
|
1450
|
+
}
|
|
1451
|
+
}
|
|
1452
|
+
}
|
|
1453
|
+
__name(forEachParameter, "forEachParameter");
|
|
1454
|
+
|
|
1455
|
+
// src/swagger/deep-objectify-queries.ts
|
|
1456
|
+
function deepObjectifyQueries(openapi) {
|
|
1457
|
+
forEachParameter(openapi, (parameter) => {
|
|
1458
|
+
if (parameter.in === "query" && parameter.schema && parameter.style === void 0 && (parameter.explode === void 0 || parameter.explode === true)) {
|
|
1459
|
+
const schema = isReferenceObject(parameter.schema) ? deepDereference(openapi, parameter.schema) : parameter.schema;
|
|
1460
|
+
if (schema && (schema.type === "object" || schema.type === "array")) {
|
|
1461
|
+
parameter.style = "deepObject";
|
|
1462
|
+
}
|
|
1463
|
+
}
|
|
1464
|
+
});
|
|
1465
|
+
}
|
|
1466
|
+
__name(deepObjectifyQueries, "deepObjectifyQueries");
|
|
1467
|
+
|
|
1468
|
+
// src/pipes/validation.pipe.ts
|
|
1469
|
+
var import_core15 = require("@mikro-orm/core");
|
|
1470
|
+
var import_common8 = require("@nestjs/common");
|
|
1471
|
+
var import_common9 = require("@nestjs/common");
|
|
1472
|
+
function _ts_decorate5(decorators, target, key, desc) {
|
|
1473
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1474
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1475
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1476
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1477
|
+
}
|
|
1478
|
+
__name(_ts_decorate5, "_ts_decorate");
|
|
1479
|
+
function _ts_metadata5(k, v) {
|
|
1480
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
1481
|
+
}
|
|
1482
|
+
__name(_ts_metadata5, "_ts_metadata");
|
|
1483
|
+
function deepMap(obj, fn) {
|
|
1484
|
+
if (Array.isArray(obj)) {
|
|
1485
|
+
return obj.map((item) => deepMap(item, fn));
|
|
1486
|
+
} else {
|
|
1487
|
+
return fn(obj);
|
|
1488
|
+
}
|
|
1489
|
+
}
|
|
1490
|
+
__name(deepMap, "deepMap");
|
|
1491
|
+
function transformReference(em, value, metatype) {
|
|
1492
|
+
if (typeof value !== "object" || value === null) return value;
|
|
1493
|
+
const entityProperties = getMetadata2(metatype);
|
|
1494
|
+
const primaryProperties = entityProperties.filter((p) => p.primary);
|
|
1495
|
+
if (primaryProperties.length === 1) {
|
|
1496
|
+
const propertyKey = primaryProperties[0].name;
|
|
1497
|
+
const ref = em.getReference(metatype, value[propertyKey], {
|
|
1498
|
+
wrapped: true
|
|
1499
|
+
});
|
|
1500
|
+
return ref;
|
|
1501
|
+
} else if (primaryProperties.length > 1) {
|
|
1502
|
+
const propertyKeys = primaryProperties.map((p) => p.name);
|
|
1503
|
+
const ref = em.getReference(metatype, propertyKeys.map((key) => value[key]), {
|
|
1504
|
+
wrapped: true
|
|
1505
|
+
});
|
|
1506
|
+
return ref;
|
|
1507
|
+
}
|
|
1508
|
+
return value;
|
|
1509
|
+
}
|
|
1510
|
+
__name(transformReference, "transformReference");
|
|
1511
|
+
function deepTransform(em, value, metatype) {
|
|
1512
|
+
if (typeof value !== "object" || value === null) {
|
|
1513
|
+
return value;
|
|
1514
|
+
}
|
|
1515
|
+
const propertyKeys = ModelRegister.getModelPropertyKeys(metatype);
|
|
1516
|
+
const result = {
|
|
1517
|
+
...value
|
|
1518
|
+
};
|
|
1519
|
+
for (const propertyKey of propertyKeys) {
|
|
1520
|
+
const propertyMetadata = ModelRegister.getProperty(metatype, propertyKey);
|
|
1521
|
+
if (!propertyMetadata) continue;
|
|
1522
|
+
if (!(propertyKey in value)) continue;
|
|
1523
|
+
const propertyValue = value[propertyKey];
|
|
1524
|
+
if (propertyMetadata.kind === "nested") {
|
|
1525
|
+
const ctor = propertyMetadata.type();
|
|
1526
|
+
if (EntityRefTypeClassMetadataPropertyKey in ctor) {
|
|
1527
|
+
result[propertyKey] = transformReference(em, propertyValue, ctor);
|
|
1528
|
+
} else {
|
|
1529
|
+
const v = deepTransform(em, propertyValue, ctor);
|
|
1530
|
+
result[propertyKey] = v;
|
|
1531
|
+
}
|
|
1532
|
+
} else if (propertyMetadata.kind === "list") {
|
|
1533
|
+
result[propertyKey] = deepMap(propertyValue, (item) => deepTransform(em, item, propertyMetadata.type()));
|
|
1534
|
+
} else if (propertyMetadata.kind === "dictionary") {
|
|
1535
|
+
result[propertyKey] = Object.fromEntries(Object.entries(propertyValue).map(([k, v]) => [
|
|
1536
|
+
k,
|
|
1537
|
+
deepTransform(em, v, propertyMetadata.type())
|
|
1538
|
+
]));
|
|
1539
|
+
}
|
|
1540
|
+
}
|
|
1541
|
+
return result;
|
|
1542
|
+
}
|
|
1543
|
+
__name(deepTransform, "deepTransform");
|
|
1544
|
+
var BukaValidationPipe = class _BukaValidationPipe extends import_common8.ValidationPipe {
|
|
1545
|
+
static {
|
|
1546
|
+
__name(this, "BukaValidationPipe");
|
|
1547
|
+
}
|
|
1548
|
+
orm;
|
|
1549
|
+
em;
|
|
1550
|
+
logger = new import_common9.Logger(_BukaValidationPipe.name);
|
|
1551
|
+
constructor(orm, em) {
|
|
1552
|
+
super(), this.orm = orm, this.em = em;
|
|
1553
|
+
}
|
|
1554
|
+
async transform(value, metadata) {
|
|
1555
|
+
value = await super.transform(value, metadata);
|
|
1556
|
+
if (!metadata.metatype || typeof metadata.metatype !== "function") {
|
|
1557
|
+
return value;
|
|
1558
|
+
}
|
|
1559
|
+
const metatype = metadata.metatype;
|
|
1560
|
+
const result = await deepTransform(this.em, value, metatype);
|
|
1561
|
+
return result;
|
|
1562
|
+
}
|
|
1563
|
+
static withParams(options) {
|
|
1564
|
+
let BukaParametrizedValidationPipe = class BukaParametrizedValidationPipe2 extends import_common8.ValidationPipe {
|
|
1565
|
+
static {
|
|
1566
|
+
__name(this, "BukaParametrizedValidationPipe");
|
|
1567
|
+
}
|
|
1568
|
+
orm;
|
|
1569
|
+
em;
|
|
1570
|
+
logger = new import_common9.Logger(BukaParametrizedValidationPipe2.name);
|
|
1571
|
+
constructor(orm, em) {
|
|
1572
|
+
super(options), this.orm = orm, this.em = em;
|
|
1573
|
+
}
|
|
1574
|
+
async transform(value, metadata) {
|
|
1575
|
+
value = await super.transform(value, metadata);
|
|
1576
|
+
if (!options.transform) return value;
|
|
1577
|
+
if (!metadata.metatype || typeof metadata.metatype !== "function") {
|
|
1578
|
+
return value;
|
|
1579
|
+
}
|
|
1580
|
+
const metatype = metadata.metatype;
|
|
1581
|
+
const result = await deepTransform(this.em, value, metatype);
|
|
1582
|
+
return result;
|
|
1583
|
+
}
|
|
1584
|
+
};
|
|
1585
|
+
BukaParametrizedValidationPipe = _ts_decorate5([
|
|
1586
|
+
(0, import_common9.Injectable)(),
|
|
1587
|
+
_ts_metadata5("design:type", Function),
|
|
1588
|
+
_ts_metadata5("design:paramtypes", [
|
|
1589
|
+
typeof import_core15.MikroORM === "undefined" ? Object : import_core15.MikroORM,
|
|
1590
|
+
typeof import_core15.EntityManager === "undefined" ? Object : import_core15.EntityManager
|
|
1591
|
+
])
|
|
1592
|
+
], BukaParametrizedValidationPipe);
|
|
1593
|
+
return BukaParametrizedValidationPipe;
|
|
1594
|
+
}
|
|
1595
|
+
};
|
|
1596
|
+
BukaValidationPipe = _ts_decorate5([
|
|
1597
|
+
(0, import_common9.Injectable)(),
|
|
1598
|
+
_ts_metadata5("design:type", Function),
|
|
1599
|
+
_ts_metadata5("design:paramtypes", [
|
|
1600
|
+
typeof import_core15.MikroORM === "undefined" ? Object : import_core15.MikroORM,
|
|
1601
|
+
typeof import_core15.EntityManager === "undefined" ? Object : import_core15.EntityManager
|
|
1602
|
+
])
|
|
1603
|
+
], BukaValidationPipe);
|
|
1604
|
+
|
|
1605
|
+
// src/converters/filter-query-type/filter-query-type.ts
|
|
1606
|
+
var R8 = __toESM(require("ramda"));
|
|
1607
|
+
|
|
1608
|
+
// src/utils/class-validator-utils.ts
|
|
1609
|
+
var R6 = __toESM(require("ramda"));
|
|
1610
|
+
var import_class_validator9 = require("class-validator");
|
|
1611
|
+
function getMetadata3(source, propertyKey) {
|
|
1612
|
+
const metadataStorage = (0, import_class_validator9.getMetadataStorage)();
|
|
1613
|
+
const arr = metadataStorage.getTargetValidationMetadatas(source, null, false, false);
|
|
1614
|
+
if (!propertyKey) {
|
|
1615
|
+
const grouped = R6.groupBy((m) => m.propertyName, arr);
|
|
1616
|
+
const result = /* @__PURE__ */ new Map();
|
|
1617
|
+
for (const key in grouped) {
|
|
1618
|
+
result.set(key, grouped[key] || []);
|
|
1619
|
+
}
|
|
1620
|
+
return result;
|
|
1621
|
+
}
|
|
1622
|
+
return arr.filter((item) => item.propertyName === propertyKey);
|
|
1623
|
+
}
|
|
1624
|
+
__name(getMetadata3, "getMetadata");
|
|
1625
|
+
function setMetadata(target, propertyKey, metadata) {
|
|
1626
|
+
const metadataStorage = (0, import_class_validator9.getMetadataStorage)();
|
|
1627
|
+
metadataStorage.addValidationMetadata({
|
|
1628
|
+
...metadata,
|
|
1629
|
+
target,
|
|
1630
|
+
propertyName: propertyKey
|
|
1631
|
+
});
|
|
1632
|
+
}
|
|
1633
|
+
__name(setMetadata, "setMetadata");
|
|
1634
|
+
|
|
1635
|
+
// src/utils/class-transformer-utils.ts
|
|
1636
|
+
var classTransformer = __toESM(require("class-transformer/cjs/storage"));
|
|
1637
|
+
function getTransformMetadata(classRef, prop) {
|
|
1638
|
+
const metadataStorage = classTransformer.defaultMetadataStorage;
|
|
1639
|
+
const metadataMap = metadataStorage["_transformMetadatas"];
|
|
1640
|
+
const classMetadata = metadataMap.get(classRef);
|
|
1641
|
+
if (!classMetadata) return;
|
|
1642
|
+
if (!prop) return classMetadata;
|
|
1643
|
+
const propertyMetadata = classMetadata.get(prop);
|
|
1644
|
+
if (!propertyMetadata) return void 0;
|
|
1645
|
+
return Array.isArray(propertyMetadata) ? propertyMetadata : [
|
|
1646
|
+
propertyMetadata
|
|
1647
|
+
];
|
|
1648
|
+
}
|
|
1649
|
+
__name(getTransformMetadata, "getTransformMetadata");
|
|
1650
|
+
function setTransformMetadata(classRef, prop, metadata) {
|
|
1651
|
+
const meta = {
|
|
1652
|
+
...metadata,
|
|
1653
|
+
target: classRef,
|
|
1654
|
+
propertyName: prop
|
|
1655
|
+
};
|
|
1656
|
+
const metadataStorage = classTransformer.defaultMetadataStorage;
|
|
1657
|
+
const metadataMap = metadataStorage["_transformMetadatas"];
|
|
1658
|
+
if (metadataMap.has(classRef)) {
|
|
1659
|
+
const classMetadata = metadataMap.get(classRef);
|
|
1660
|
+
const propertyMetadata = classMetadata.get(prop);
|
|
1661
|
+
if (propertyMetadata) {
|
|
1662
|
+
classMetadata.set(prop, propertyMetadata.concat(meta));
|
|
1663
|
+
} else {
|
|
1664
|
+
classMetadata.set(prop, [
|
|
1665
|
+
meta
|
|
1666
|
+
]);
|
|
1667
|
+
}
|
|
1668
|
+
} else {
|
|
1669
|
+
metadataMap.set(classRef, /* @__PURE__ */ new Map([
|
|
1670
|
+
[
|
|
1671
|
+
prop,
|
|
1672
|
+
[
|
|
1673
|
+
meta
|
|
1674
|
+
]
|
|
1675
|
+
]
|
|
1676
|
+
]));
|
|
1677
|
+
}
|
|
1678
|
+
}
|
|
1679
|
+
__name(setTransformMetadata, "setTransformMetadata");
|
|
1680
|
+
|
|
1681
|
+
// src/converters/filter-query-type/decorators/filter-query-operators.decorator.ts
|
|
1682
|
+
var FilterQueryOperatorsMetadataKey = "buka:filter-query-operators";
|
|
1683
|
+
function FilterQueryOperators(operators) {
|
|
1684
|
+
if (!operators || operators.length === 0) {
|
|
1685
|
+
throw new TypeError("FilterQueryOperators: operators array must not be empty");
|
|
1686
|
+
}
|
|
1687
|
+
return /* @__PURE__ */ __name(function FilterQueryOperatorsDecorator(target, propertyKey) {
|
|
1688
|
+
Reflect.defineMetadata(FilterQueryOperatorsMetadataKey, operators, target, propertyKey);
|
|
1689
|
+
}, "FilterQueryOperatorsDecorator");
|
|
1690
|
+
}
|
|
1691
|
+
__name(FilterQueryOperators, "FilterQueryOperators");
|
|
1692
|
+
function getFilterQueryOperators(target, propertyKey) {
|
|
1693
|
+
return Reflect.getMetadata(FilterQueryOperatorsMetadataKey, target, propertyKey);
|
|
1694
|
+
}
|
|
1695
|
+
__name(getFilterQueryOperators, "getFilterQueryOperators");
|
|
1696
|
+
|
|
1697
|
+
// src/converters/filter-query-type/filter-query-type.ts
|
|
1698
|
+
var import_class_validator10 = require("class-validator");
|
|
1699
|
+
|
|
1700
|
+
// src/converters/filter-query-type/utils/get-collection-operators.ts
|
|
1701
|
+
var FilterQueryCollectionOperators = [
|
|
1702
|
+
"$some",
|
|
1703
|
+
"$every",
|
|
1704
|
+
"$none"
|
|
1705
|
+
];
|
|
1706
|
+
function getCollectionOperators(target, propertyKey) {
|
|
1707
|
+
const operators = getFilterQueryOperators(target.prototype, propertyKey);
|
|
1708
|
+
if (!operators) return FilterQueryCollectionOperators;
|
|
1709
|
+
return operators.filter((op) => FilterQueryCollectionOperators.includes(op));
|
|
1710
|
+
}
|
|
1711
|
+
__name(getCollectionOperators, "getCollectionOperators");
|
|
1712
|
+
|
|
1713
|
+
// src/converters/filter-query-type/utils/get-property-operators.ts
|
|
1714
|
+
var FilterQueryPropertyOperators = [
|
|
1715
|
+
"$eq",
|
|
1716
|
+
"$ne",
|
|
1717
|
+
"$lt",
|
|
1718
|
+
"$gt",
|
|
1719
|
+
"$lte",
|
|
1720
|
+
"$gte",
|
|
1721
|
+
"$in",
|
|
1722
|
+
"$nin"
|
|
1723
|
+
];
|
|
1724
|
+
function getPropertyOperators(target, propertyKey) {
|
|
1725
|
+
const operators = getFilterQueryOperators(target.prototype, propertyKey);
|
|
1726
|
+
if (!operators) return FilterQueryPropertyOperators;
|
|
1727
|
+
return operators.filter((op) => FilterQueryPropertyOperators.includes(op));
|
|
1728
|
+
}
|
|
1729
|
+
__name(getPropertyOperators, "getPropertyOperators");
|
|
1730
|
+
|
|
1731
|
+
// src/converters/filter-query-type/utils/swagger-metadata-to-json-schema.ts
|
|
1732
|
+
var R7 = __toESM(require("ramda"));
|
|
1733
|
+
var import_swagger6 = require("@nestjs/swagger");
|
|
1734
|
+
function scalarType(type) {
|
|
1735
|
+
if (typeof type === "string") return {
|
|
1736
|
+
type
|
|
1737
|
+
};
|
|
1738
|
+
if (type === String) return {
|
|
1739
|
+
type: "string"
|
|
1740
|
+
};
|
|
1741
|
+
if (type === Number) return {
|
|
1742
|
+
type: "number"
|
|
1743
|
+
};
|
|
1744
|
+
if (type === Boolean) return {
|
|
1745
|
+
type: "boolean"
|
|
1746
|
+
};
|
|
1747
|
+
return {
|
|
1748
|
+
$ref: (0, import_swagger6.getSchemaPath)(type)
|
|
1749
|
+
};
|
|
1750
|
+
}
|
|
1751
|
+
__name(scalarType, "scalarType");
|
|
1752
|
+
function swaggerMetadataToJsonSchema(metadata) {
|
|
1753
|
+
const base = R7.omit([
|
|
1754
|
+
"type",
|
|
1755
|
+
"required"
|
|
1756
|
+
], metadata);
|
|
1757
|
+
if (isLazyTypeFunc(metadata.type)) {
|
|
1758
|
+
return {
|
|
1759
|
+
...base,
|
|
1760
|
+
...scalarType(metadata.type())
|
|
1761
|
+
};
|
|
1762
|
+
}
|
|
1763
|
+
return {
|
|
1764
|
+
...base,
|
|
1765
|
+
...scalarType(metadata.type)
|
|
1766
|
+
};
|
|
1767
|
+
}
|
|
1768
|
+
__name(swaggerMetadataToJsonSchema, "swaggerMetadataToJsonSchema");
|
|
1769
|
+
|
|
1770
|
+
// src/converters/filter-query-type/get-filter-query-schema.ts
|
|
1771
|
+
function getObjectSchema(classRef) {
|
|
1772
|
+
const properties = {};
|
|
1773
|
+
const schema = {
|
|
1774
|
+
type: "object",
|
|
1775
|
+
properties
|
|
1776
|
+
};
|
|
1777
|
+
for (const propertyKey of ModelRegister.getModelPropertyKeys(classRef)) {
|
|
1778
|
+
if (typeof propertyKey !== "string") continue;
|
|
1779
|
+
const propertyMetadata = ModelRegister.getProperty(classRef, propertyKey);
|
|
1780
|
+
const isCollection = propertyMetadata?.relation?.kind === "1:m" || propertyMetadata?.relation?.kind === "m:n";
|
|
1781
|
+
const isRelation = !!propertyMetadata?.relation;
|
|
1782
|
+
const isOptional = !!propertyMetadata?.optional;
|
|
1783
|
+
if (isRelation) {
|
|
1784
|
+
if (isCollection) {
|
|
1785
|
+
const sub = getObjectSchema(propertyMetadata.relation.type());
|
|
1786
|
+
const operators = getCollectionOperators(classRef, propertyKey);
|
|
1787
|
+
for (const operator of operators) {
|
|
1788
|
+
properties[operator] = sub;
|
|
1789
|
+
}
|
|
1790
|
+
} else {
|
|
1791
|
+
const sub = getObjectSchema(propertyMetadata.relation.type());
|
|
1792
|
+
properties[propertyKey] = sub;
|
|
1793
|
+
}
|
|
1794
|
+
} else {
|
|
1795
|
+
const propertySchema = {
|
|
1796
|
+
type: "object",
|
|
1797
|
+
properties: {}
|
|
1798
|
+
};
|
|
1799
|
+
const originalSchema = getMetadata(classRef, propertyKey);
|
|
1800
|
+
const operators = getPropertyOperators(classRef, propertyKey);
|
|
1801
|
+
for (const operator of operators) {
|
|
1802
|
+
if ([
|
|
1803
|
+
"$in",
|
|
1804
|
+
"$nin"
|
|
1805
|
+
].includes(operator)) {
|
|
1806
|
+
propertySchema.properties[operator] = {
|
|
1807
|
+
type: "array",
|
|
1808
|
+
items: originalSchema ? swaggerMetadataToJsonSchema(originalSchema) : {
|
|
1809
|
+
type: "string"
|
|
1810
|
+
}
|
|
1811
|
+
};
|
|
1812
|
+
} else {
|
|
1813
|
+
propertySchema.properties[operator] = originalSchema ? swaggerMetadataToJsonSchema(originalSchema) : {
|
|
1814
|
+
type: "string"
|
|
1815
|
+
};
|
|
1816
|
+
}
|
|
1817
|
+
}
|
|
1818
|
+
properties[propertyKey] = propertySchema;
|
|
1819
|
+
}
|
|
1820
|
+
}
|
|
1821
|
+
return schema;
|
|
1822
|
+
}
|
|
1823
|
+
__name(getObjectSchema, "getObjectSchema");
|
|
1824
|
+
function getFilterQuerySchema(classRef) {
|
|
1825
|
+
return {
|
|
1826
|
+
...getObjectSchema(classRef),
|
|
1827
|
+
description: `Filter query for ${classRef.name}`,
|
|
1828
|
+
required: false
|
|
1829
|
+
};
|
|
1830
|
+
}
|
|
1831
|
+
__name(getFilterQuerySchema, "getFilterQuerySchema");
|
|
1832
|
+
|
|
1833
|
+
// src/converters/filter-query-type/filter-query-type.ts
|
|
1834
|
+
function createFilterQueryPropertyClassRef(classRef, propertyKey) {
|
|
1835
|
+
const propertyClass = class FilterQueryPropertyClass {
|
|
1836
|
+
static {
|
|
1837
|
+
__name(this, "FilterQueryPropertyClass");
|
|
1838
|
+
}
|
|
1839
|
+
};
|
|
1840
|
+
ModelRegister.addModel(propertyClass);
|
|
1841
|
+
const propertyMetadata = ModelRegister.getProperty(classRef, propertyKey);
|
|
1842
|
+
const validationMetadataList = getMetadata3(classRef, propertyKey).filter((metadata) => metadata.name !== import_class_validator10.IS_OPTIONAL);
|
|
1843
|
+
const transformerMetadataList = getTransformMetadata(classRef, propertyKey) || [];
|
|
1844
|
+
const operators = getPropertyOperators(classRef, propertyKey);
|
|
1845
|
+
for (const operator of operators) {
|
|
1846
|
+
if ([
|
|
1847
|
+
"$in",
|
|
1848
|
+
"$nin"
|
|
1849
|
+
].includes(operator)) {
|
|
1850
|
+
ModelRegister.addProperty(propertyClass, operator, {
|
|
1851
|
+
...propertyMetadata,
|
|
1852
|
+
kind: "list",
|
|
1853
|
+
optional: true
|
|
1854
|
+
});
|
|
1855
|
+
(0, import_class_validator10.IsArray)()(propertyClass.prototype, operator);
|
|
1856
|
+
(0, import_class_validator10.ArrayMinSize)(1)(propertyClass.prototype, operator);
|
|
1857
|
+
for (const metadata of validationMetadataList) {
|
|
1858
|
+
setMetadata(propertyClass, operator, {
|
|
1859
|
+
...metadata,
|
|
1860
|
+
each: true
|
|
1861
|
+
});
|
|
1862
|
+
}
|
|
1863
|
+
for (const metadata of transformerMetadataList) {
|
|
1864
|
+
const transformFn = metadata.transformFn;
|
|
1865
|
+
setTransformMetadata(propertyClass, operator, {
|
|
1866
|
+
...metadata,
|
|
1867
|
+
transformFn: /* @__PURE__ */ __name(function FilterQueryPropertyTransformer(params) {
|
|
1868
|
+
if (Array.isArray(params.value)) {
|
|
1869
|
+
return params.value.map((v, i, arr) => transformFn({
|
|
1870
|
+
...params,
|
|
1871
|
+
value: v,
|
|
1872
|
+
key: i,
|
|
1873
|
+
obj: arr
|
|
1874
|
+
}));
|
|
1875
|
+
}
|
|
1876
|
+
return params.value;
|
|
1877
|
+
}, "FilterQueryPropertyTransformer")
|
|
1878
|
+
});
|
|
1879
|
+
}
|
|
1880
|
+
} else {
|
|
1881
|
+
ModelRegister.addProperty(propertyClass, operator, {
|
|
1882
|
+
...propertyMetadata,
|
|
1883
|
+
optional: true
|
|
1884
|
+
});
|
|
1885
|
+
for (const metadata of validationMetadataList) {
|
|
1886
|
+
setMetadata(propertyClass, operator, metadata);
|
|
1887
|
+
}
|
|
1888
|
+
for (const metadata of transformerMetadataList) {
|
|
1889
|
+
setTransformMetadata(propertyClass, operator, metadata);
|
|
1890
|
+
}
|
|
1891
|
+
}
|
|
1892
|
+
(0, import_class_validator10.IsOptional)()(propertyClass.prototype, operator);
|
|
1893
|
+
}
|
|
1894
|
+
return propertyClass;
|
|
1895
|
+
}
|
|
1896
|
+
__name(createFilterQueryPropertyClassRef, "createFilterQueryPropertyClassRef");
|
|
1897
|
+
function createFilterQueryObjectClassRef(classRef) {
|
|
1898
|
+
let FilterQueryObjectClass = class FilterQueryObjectClass {
|
|
1899
|
+
static {
|
|
1900
|
+
__name(this, "FilterQueryObjectClass");
|
|
1901
|
+
}
|
|
1902
|
+
};
|
|
1903
|
+
ModelRegister.addModel(FilterQueryObjectClass);
|
|
1904
|
+
for (const propertyKey of ModelRegister.getModelPropertyKeys(classRef)) {
|
|
1905
|
+
if (typeof propertyKey !== "string") continue;
|
|
1906
|
+
const propertyMetadata = ModelRegister.getProperty(classRef, propertyKey);
|
|
1907
|
+
const isCollection = propertyMetadata?.relation?.kind === "1:m" || propertyMetadata?.relation?.kind === "m:n";
|
|
1908
|
+
const isRelation = !!propertyMetadata?.relation;
|
|
1909
|
+
const isOptional = !!propertyMetadata?.optional;
|
|
1910
|
+
if (isRelation) {
|
|
1911
|
+
if (isCollection) {
|
|
1912
|
+
let FilterQueryCollectionClass = class FilterQueryCollectionClass {
|
|
1913
|
+
static {
|
|
1914
|
+
__name(this, "FilterQueryCollectionClass");
|
|
1915
|
+
}
|
|
1916
|
+
};
|
|
1917
|
+
ModelRegister.addModel(FilterQueryCollectionClass);
|
|
1918
|
+
const sub = createFilterQueryObjectClassRef(propertyMetadata.relation.type());
|
|
1919
|
+
const operators = getCollectionOperators(classRef, propertyKey);
|
|
1920
|
+
for (const operator of operators) {
|
|
1921
|
+
NestedProperty(() => sub, {
|
|
1922
|
+
optional: true
|
|
1923
|
+
})(FilterQueryCollectionClass.prototype, operator);
|
|
1924
|
+
if (!isOptional) {
|
|
1925
|
+
HasAnyKey(getFilterQueryOperators(classRef, propertyKey))(FilterQueryCollectionClass.prototype, operator);
|
|
1926
|
+
}
|
|
1927
|
+
(0, import_class_validator10.IsOptional)()(FilterQueryCollectionClass.prototype, operator);
|
|
1928
|
+
}
|
|
1929
|
+
NestedProperty(() => FilterQueryCollectionClass, {
|
|
1930
|
+
optional: isOptional
|
|
1931
|
+
})(FilterQueryObjectClass.prototype, propertyKey);
|
|
1932
|
+
if (!isOptional) HasAnyKey(operators)(FilterQueryObjectClass.prototype, propertyKey);
|
|
1933
|
+
} else {
|
|
1934
|
+
const sub = createFilterQueryObjectClassRef(propertyMetadata.relation.type());
|
|
1935
|
+
NestedProperty(() => sub, {
|
|
1936
|
+
optional: isOptional
|
|
1937
|
+
})(FilterQueryObjectClass.prototype, propertyKey);
|
|
1938
|
+
}
|
|
1939
|
+
} else {
|
|
1940
|
+
const propertyClass = createFilterQueryPropertyClassRef(classRef, propertyKey);
|
|
1941
|
+
NestedProperty(() => propertyClass, {
|
|
1942
|
+
optional: isOptional
|
|
1943
|
+
})(FilterQueryObjectClass.prototype, propertyKey);
|
|
1944
|
+
if (!isOptional) {
|
|
1945
|
+
const operators = getPropertyOperators(classRef, propertyKey);
|
|
1946
|
+
HasAnyKey(operators)(FilterQueryObjectClass.prototype, propertyKey);
|
|
1947
|
+
}
|
|
1948
|
+
}
|
|
1949
|
+
}
|
|
1950
|
+
return FilterQueryObjectClass;
|
|
1951
|
+
}
|
|
1952
|
+
__name(createFilterQueryObjectClassRef, "createFilterQueryObjectClassRef");
|
|
1953
|
+
function FilterQueryType(classRef) {
|
|
1954
|
+
if (!ModelRegister.isModel(classRef)) {
|
|
1955
|
+
throw new TypeException("FilterQueryType only accepts a class annotated with @Model().");
|
|
1956
|
+
}
|
|
1957
|
+
const FilterQueryObjectClass = createFilterQueryObjectClassRef(classRef);
|
|
1958
|
+
const properties = ModelRegister.getProperties(FilterQueryObjectClass);
|
|
1959
|
+
const isRequired = R8.any((p) => !p.optional, properties);
|
|
1960
|
+
let FilterQueryClass = class FilterQueryClass {
|
|
1961
|
+
static {
|
|
1962
|
+
__name(this, "FilterQueryClass");
|
|
1963
|
+
}
|
|
1964
|
+
filter;
|
|
1965
|
+
};
|
|
1966
|
+
ModelRegister.addModel(FilterQueryObjectClass);
|
|
1967
|
+
NestedProperty(() => FilterQueryObjectClass, {
|
|
1968
|
+
optional: !isRequired,
|
|
1969
|
+
schema: getFilterQuerySchema(classRef)
|
|
1970
|
+
})(FilterQueryClass.prototype, "filter");
|
|
1971
|
+
return FilterQueryClass;
|
|
1972
|
+
}
|
|
1973
|
+
__name(FilterQueryType, "FilterQueryType");
|
|
1974
|
+
|
|
1975
|
+
// src/converters/pick-type/pick-type.ts
|
|
1976
|
+
var import_swagger7 = require("@nestjs/swagger");
|
|
1977
|
+
function PickType(classRef, keys) {
|
|
1978
|
+
if (!ModelRegister.isModel(classRef)) {
|
|
1979
|
+
throw new TypeException("PickType only accepts a class annotated with @Model().");
|
|
1980
|
+
}
|
|
1981
|
+
const PickTypeClass = (0, import_swagger7.PickType)(classRef, keys);
|
|
1982
|
+
for (const key of keys) {
|
|
1983
|
+
ModelRegister.copyProperty(classRef, PickTypeClass, key);
|
|
1984
|
+
const metadataKeys = Reflect.getMetadataKeys(classRef.prototype, key);
|
|
1985
|
+
for (const metadataKey of metadataKeys) {
|
|
1986
|
+
const metadata = Reflect.getMetadata(metadataKey, classRef.prototype, key);
|
|
1987
|
+
if (Reflect.hasMetadata(metadataKey, PickTypeClass.prototype, key)) continue;
|
|
1988
|
+
Reflect.defineMetadata(metadataKey, metadata, PickTypeClass.prototype, key);
|
|
1989
|
+
}
|
|
1990
|
+
}
|
|
1991
|
+
return PickTypeClass;
|
|
1992
|
+
}
|
|
1993
|
+
__name(PickType, "PickType");
|
|
1994
|
+
|
|
1995
|
+
// src/converters/omit-type/omit-type.ts
|
|
1996
|
+
var import_swagger8 = require("@nestjs/swagger");
|
|
1997
|
+
function OmitType(classRef, keys) {
|
|
1998
|
+
if (!ModelRegister.isModel(classRef)) {
|
|
1999
|
+
throw new TypeException("OmitType only accepts a class annotated with @Model().");
|
|
2000
|
+
}
|
|
2001
|
+
const OmitTypeClass = (0, import_swagger8.OmitType)(classRef, keys);
|
|
2002
|
+
for (const propertyKey of ModelRegister.getModelPropertyKeys(classRef)) {
|
|
2003
|
+
if (keys.includes(propertyKey)) continue;
|
|
2004
|
+
ModelRegister.copyProperty(classRef, OmitTypeClass, propertyKey);
|
|
2005
|
+
const metadataKeys = Reflect.getMetadataKeys(classRef.prototype, propertyKey);
|
|
2006
|
+
for (const metadataKey of metadataKeys) {
|
|
2007
|
+
const metadata = Reflect.getMetadata(metadataKey, classRef.prototype, propertyKey);
|
|
2008
|
+
if (Reflect.hasMetadata(metadataKey, OmitTypeClass.prototype, propertyKey)) continue;
|
|
2009
|
+
Reflect.defineMetadata(metadataKey, metadata, OmitTypeClass.prototype, propertyKey);
|
|
2010
|
+
}
|
|
2011
|
+
}
|
|
2012
|
+
return OmitTypeClass;
|
|
2013
|
+
}
|
|
2014
|
+
__name(OmitType, "OmitType");
|
|
2015
|
+
|
|
2016
|
+
// src/converters/partial-type/partial-type.ts
|
|
2017
|
+
var import_swagger9 = require("@nestjs/swagger");
|
|
2018
|
+
function PartialType(classRef) {
|
|
2019
|
+
const PartialTypeClass = (0, import_swagger9.PartialType)(classRef);
|
|
2020
|
+
for (const propertyKey of ModelRegister.getModelPropertyKeys(classRef)) {
|
|
2021
|
+
ModelRegister.copyProperty(classRef, PartialTypeClass, propertyKey);
|
|
2022
|
+
const metadataKeys = Reflect.getMetadataKeys(classRef.prototype, propertyKey);
|
|
2023
|
+
for (const metadataKey of metadataKeys) {
|
|
2024
|
+
const metadata = Reflect.getMetadata(metadataKey, classRef.prototype, propertyKey);
|
|
2025
|
+
if (Reflect.hasMetadata(metadataKey, PartialTypeClass.prototype, propertyKey)) continue;
|
|
2026
|
+
Reflect.defineMetadata(metadataKey, metadata, PartialTypeClass.prototype, propertyKey);
|
|
2027
|
+
}
|
|
2028
|
+
}
|
|
2029
|
+
return PartialTypeClass;
|
|
2030
|
+
}
|
|
2031
|
+
__name(PartialType, "PartialType");
|
|
2032
|
+
|
|
2033
|
+
// src/converters/order-query-type/get-order-query-schema.ts
|
|
2034
|
+
function getOrderQueryEnum() {
|
|
2035
|
+
return {
|
|
2036
|
+
type: "string",
|
|
2037
|
+
enum: [
|
|
2038
|
+
"asc",
|
|
2039
|
+
"asc nulls last",
|
|
2040
|
+
"asc nulls first",
|
|
2041
|
+
"desc",
|
|
2042
|
+
"desc nulls last",
|
|
2043
|
+
"desc nulls first"
|
|
2044
|
+
]
|
|
2045
|
+
};
|
|
2046
|
+
}
|
|
2047
|
+
__name(getOrderQueryEnum, "getOrderQueryEnum");
|
|
2048
|
+
function getOrderQueryMapSchema(classRef) {
|
|
2049
|
+
const properties = {};
|
|
2050
|
+
const schema = {
|
|
2051
|
+
type: "object",
|
|
2052
|
+
properties,
|
|
2053
|
+
required: []
|
|
2054
|
+
};
|
|
2055
|
+
for (const propertyKey of ModelRegister.getModelPropertyKeys(classRef)) {
|
|
2056
|
+
const propertyMetadata = ModelRegister.getProperty(classRef, propertyKey);
|
|
2057
|
+
const isRelation = !!propertyMetadata?.relation;
|
|
2058
|
+
if (isRelation) {
|
|
2059
|
+
properties[propertyKey] = getOrderQueryMapSchema(propertyMetadata.relation.type());
|
|
2060
|
+
} else {
|
|
2061
|
+
properties[propertyKey] = getOrderQueryEnum();
|
|
2062
|
+
}
|
|
2063
|
+
}
|
|
2064
|
+
return schema;
|
|
2065
|
+
}
|
|
2066
|
+
__name(getOrderQueryMapSchema, "getOrderQueryMapSchema");
|
|
2067
|
+
function getOrderQuerySchema(classRef) {
|
|
2068
|
+
const orderQueryMapSchema = getOrderQueryMapSchema(classRef);
|
|
2069
|
+
return {
|
|
2070
|
+
description: `Order query for ${classRef.name}`,
|
|
2071
|
+
oneOf: [
|
|
2072
|
+
{
|
|
2073
|
+
type: "array",
|
|
2074
|
+
items: orderQueryMapSchema
|
|
2075
|
+
},
|
|
2076
|
+
orderQueryMapSchema
|
|
2077
|
+
],
|
|
2078
|
+
required: false
|
|
2079
|
+
};
|
|
2080
|
+
}
|
|
2081
|
+
__name(getOrderQuerySchema, "getOrderQuerySchema");
|
|
2082
|
+
|
|
2083
|
+
// src/converters/order-query-type/order-query-type.ts
|
|
2084
|
+
function OrderQueryType(classRef) {
|
|
2085
|
+
const schema = getOrderQuerySchema(classRef);
|
|
2086
|
+
let OrderQueryClass = class OrderQueryClass {
|
|
2087
|
+
static {
|
|
2088
|
+
__name(this, "OrderQueryClass");
|
|
2089
|
+
}
|
|
2090
|
+
orderBy;
|
|
2091
|
+
};
|
|
2092
|
+
Property({
|
|
2093
|
+
optional: true,
|
|
2094
|
+
schema
|
|
2095
|
+
})(OrderQueryClass.prototype, "orderBy");
|
|
2096
|
+
MatchJsonSchema(schema, {
|
|
2097
|
+
message: "Invalid order query"
|
|
2098
|
+
})(OrderQueryClass.prototype, "orderBy");
|
|
2099
|
+
return OrderQueryClass;
|
|
2100
|
+
}
|
|
2101
|
+
__name(OrderQueryType, "OrderQueryType");
|
|
2102
|
+
|
|
2103
|
+
// src/ro/offset-pagination.ro.ts
|
|
2104
|
+
function _ts_decorate6(decorators, target, key, desc) {
|
|
2105
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2106
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
2107
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2108
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2109
|
+
}
|
|
2110
|
+
__name(_ts_decorate6, "_ts_decorate");
|
|
2111
|
+
function _ts_metadata6(k, v) {
|
|
2112
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
2113
|
+
}
|
|
2114
|
+
__name(_ts_metadata6, "_ts_metadata");
|
|
2115
|
+
var OffsetPaginationRo = class {
|
|
2116
|
+
static {
|
|
2117
|
+
__name(this, "OffsetPaginationRo");
|
|
2118
|
+
}
|
|
2119
|
+
total;
|
|
2120
|
+
limit;
|
|
2121
|
+
offset;
|
|
2122
|
+
};
|
|
2123
|
+
_ts_decorate6([
|
|
2124
|
+
Property({
|
|
2125
|
+
schema: {
|
|
2126
|
+
type: "number",
|
|
2127
|
+
description: "\u603B\u6570"
|
|
2128
|
+
}
|
|
2129
|
+
}),
|
|
2130
|
+
_ts_metadata6("design:type", Number)
|
|
2131
|
+
], OffsetPaginationRo.prototype, "total", void 0);
|
|
2132
|
+
_ts_decorate6([
|
|
2133
|
+
Property({
|
|
2134
|
+
schema: {
|
|
2135
|
+
type: "number",
|
|
2136
|
+
description: "\u6BCF\u9875\u6570\u91CF"
|
|
2137
|
+
}
|
|
2138
|
+
}),
|
|
2139
|
+
_ts_metadata6("design:type", Number)
|
|
2140
|
+
], OffsetPaginationRo.prototype, "limit", void 0);
|
|
2141
|
+
_ts_decorate6([
|
|
2142
|
+
Property({
|
|
2143
|
+
schema: {
|
|
2144
|
+
type: "number",
|
|
2145
|
+
description: "\u504F\u79FB\u91CF"
|
|
2146
|
+
}
|
|
2147
|
+
}),
|
|
2148
|
+
_ts_metadata6("design:type", Number)
|
|
2149
|
+
], OffsetPaginationRo.prototype, "offset", void 0);
|
|
2150
|
+
OffsetPaginationRo = _ts_decorate6([
|
|
2151
|
+
Model()
|
|
2152
|
+
], OffsetPaginationRo);
|
|
2153
|
+
|
|
2154
|
+
// src/ro/cursor-pagination.ro.ts
|
|
2155
|
+
function _ts_decorate7(decorators, target, key, desc) {
|
|
2156
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2157
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
2158
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2159
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2160
|
+
}
|
|
2161
|
+
__name(_ts_decorate7, "_ts_decorate");
|
|
2162
|
+
function _ts_metadata7(k, v) {
|
|
2163
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
2164
|
+
}
|
|
2165
|
+
__name(_ts_metadata7, "_ts_metadata");
|
|
2166
|
+
var CursorPaginationRo = class {
|
|
2167
|
+
static {
|
|
2168
|
+
__name(this, "CursorPaginationRo");
|
|
2169
|
+
}
|
|
2170
|
+
total;
|
|
2171
|
+
limit;
|
|
2172
|
+
startCursor;
|
|
2173
|
+
endCursor;
|
|
2174
|
+
hasNextPage;
|
|
2175
|
+
hasPrevPage;
|
|
2176
|
+
};
|
|
2177
|
+
_ts_decorate7([
|
|
2178
|
+
Property({
|
|
2179
|
+
schema: {
|
|
2180
|
+
type: "number",
|
|
2181
|
+
description: "\u603B\u6570"
|
|
2182
|
+
}
|
|
2183
|
+
}),
|
|
2184
|
+
_ts_metadata7("design:type", Number)
|
|
2185
|
+
], CursorPaginationRo.prototype, "total", void 0);
|
|
2186
|
+
_ts_decorate7([
|
|
2187
|
+
Property({
|
|
2188
|
+
schema: {
|
|
2189
|
+
type: "number",
|
|
2190
|
+
description: "\u6BCF\u9875\u6570\u91CF"
|
|
2191
|
+
}
|
|
2192
|
+
}),
|
|
2193
|
+
_ts_metadata7("design:type", Number)
|
|
2194
|
+
], CursorPaginationRo.prototype, "limit", void 0);
|
|
2195
|
+
_ts_decorate7([
|
|
2196
|
+
Property({
|
|
2197
|
+
schema: {
|
|
2198
|
+
type: "string",
|
|
2199
|
+
description: "\u5F00\u59CB\u6E38\u6807"
|
|
2200
|
+
}
|
|
2201
|
+
}),
|
|
2202
|
+
_ts_metadata7("design:type", String)
|
|
2203
|
+
], CursorPaginationRo.prototype, "startCursor", void 0);
|
|
2204
|
+
_ts_decorate7([
|
|
2205
|
+
Property({
|
|
2206
|
+
schema: {
|
|
2207
|
+
type: "string",
|
|
2208
|
+
description: "\u7ED3\u675F\u6E38\u6807"
|
|
2209
|
+
}
|
|
2210
|
+
}),
|
|
2211
|
+
_ts_metadata7("design:type", String)
|
|
2212
|
+
], CursorPaginationRo.prototype, "endCursor", void 0);
|
|
2213
|
+
_ts_decorate7([
|
|
2214
|
+
Property({
|
|
2215
|
+
schema: {
|
|
2216
|
+
type: "boolean",
|
|
2217
|
+
description: "\u662F\u5426\u6709\u4E0B\u4E00\u9875"
|
|
2218
|
+
}
|
|
2219
|
+
}),
|
|
2220
|
+
_ts_metadata7("design:type", Boolean)
|
|
2221
|
+
], CursorPaginationRo.prototype, "hasNextPage", void 0);
|
|
2222
|
+
_ts_decorate7([
|
|
2223
|
+
Property({
|
|
2224
|
+
schema: {
|
|
2225
|
+
type: "boolean",
|
|
2226
|
+
description: "\u662F\u5426\u6709\u4E0A\u4E00\u9875"
|
|
2227
|
+
}
|
|
2228
|
+
}),
|
|
2229
|
+
_ts_metadata7("design:type", Boolean)
|
|
2230
|
+
], CursorPaginationRo.prototype, "hasPrevPage", void 0);
|
|
2231
|
+
CursorPaginationRo = _ts_decorate7([
|
|
2232
|
+
Model()
|
|
2233
|
+
], CursorPaginationRo);
|
|
2234
|
+
|
|
2235
|
+
// src/converters/list-response-body-type/list-response-body-type.ts
|
|
2236
|
+
function _ts_decorate8(decorators, target, key, desc) {
|
|
2237
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2238
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
2239
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2240
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2241
|
+
}
|
|
2242
|
+
__name(_ts_decorate8, "_ts_decorate");
|
|
2243
|
+
function _ts_metadata8(k, v) {
|
|
2244
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
2245
|
+
}
|
|
2246
|
+
__name(_ts_metadata8, "_ts_metadata");
|
|
2247
|
+
function ListResponseBodyType(classRef, mode) {
|
|
2248
|
+
let ResponseBodyMeta = class ResponseBodyMeta {
|
|
2249
|
+
static {
|
|
2250
|
+
__name(this, "ResponseBodyMeta");
|
|
2251
|
+
}
|
|
2252
|
+
pagination;
|
|
2253
|
+
};
|
|
2254
|
+
if (mode === "cursor") {
|
|
2255
|
+
NestedProperty(() => CursorPaginationRo)(ResponseBodyMeta.prototype, "pagination");
|
|
2256
|
+
} else if (mode === "offset") {
|
|
2257
|
+
NestedProperty(() => OffsetPaginationRo)(ResponseBodyMeta.prototype, "pagination");
|
|
2258
|
+
}
|
|
2259
|
+
let ListResponseBody = class ListResponseBody2 {
|
|
2260
|
+
static {
|
|
2261
|
+
__name(this, "ListResponseBody");
|
|
2262
|
+
}
|
|
2263
|
+
data;
|
|
2264
|
+
meta;
|
|
2265
|
+
constructor(data, meta) {
|
|
2266
|
+
this.data = data;
|
|
2267
|
+
this.meta = meta;
|
|
2268
|
+
}
|
|
2269
|
+
static fromSlice(slice) {
|
|
2270
|
+
const data = slice.data;
|
|
2271
|
+
const meta = {
|
|
2272
|
+
pagination: slice.pagination
|
|
2273
|
+
};
|
|
2274
|
+
const res = new ListResponseBody2(data, meta);
|
|
2275
|
+
return res;
|
|
2276
|
+
}
|
|
2277
|
+
};
|
|
2278
|
+
_ts_decorate8([
|
|
2279
|
+
NestedProperty(() => classRef, {
|
|
2280
|
+
each: true
|
|
2281
|
+
}),
|
|
2282
|
+
_ts_metadata8("design:type", Array)
|
|
2283
|
+
], ListResponseBody.prototype, "data", void 0);
|
|
2284
|
+
_ts_decorate8([
|
|
2285
|
+
NestedProperty(() => ResponseBodyMeta),
|
|
2286
|
+
_ts_metadata8("design:type", typeof ResponseBodyMeta === "undefined" ? Object : ResponseBodyMeta)
|
|
2287
|
+
], ListResponseBody.prototype, "meta", void 0);
|
|
2288
|
+
return ListResponseBody;
|
|
2289
|
+
}
|
|
2290
|
+
__name(ListResponseBodyType, "ListResponseBodyType");
|
|
2291
|
+
|
|
2292
|
+
// src/converters/response-body-type/response-body-type.ts
|
|
2293
|
+
function ResponseBodyType(classRef) {
|
|
2294
|
+
let ResponseBodyClass = class ResponseBodyClass2 {
|
|
2295
|
+
static {
|
|
2296
|
+
__name(this, "ResponseBodyClass");
|
|
2297
|
+
}
|
|
2298
|
+
data;
|
|
2299
|
+
constructor(data) {
|
|
2300
|
+
this.data = data;
|
|
2301
|
+
}
|
|
2302
|
+
static from(data, meta) {
|
|
2303
|
+
const instance = new ResponseBodyClass2(data);
|
|
2304
|
+
return instance;
|
|
2305
|
+
}
|
|
2306
|
+
};
|
|
2307
|
+
Property({
|
|
2308
|
+
type: /* @__PURE__ */ __name(() => classRef, "type"),
|
|
2309
|
+
schema: {
|
|
2310
|
+
type: /* @__PURE__ */ __name(() => classRef, "type")
|
|
2311
|
+
}
|
|
2312
|
+
})(ResponseBodyClass.prototype, "data");
|
|
2313
|
+
Property({
|
|
2314
|
+
type: /* @__PURE__ */ __name(() => Object, "type"),
|
|
2315
|
+
schema: {
|
|
2316
|
+
additionalProperties: true
|
|
2317
|
+
}
|
|
2318
|
+
});
|
|
2319
|
+
return ResponseBodyClass;
|
|
2320
|
+
}
|
|
2321
|
+
__name(ResponseBodyType, "ResponseBodyType");
|
|
2322
|
+
|
|
2323
|
+
// src/models/offset-pagination.ts
|
|
2324
|
+
function _ts_decorate9(decorators, target, key, desc) {
|
|
2325
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2326
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
2327
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2328
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2329
|
+
}
|
|
2330
|
+
__name(_ts_decorate9, "_ts_decorate");
|
|
2331
|
+
function _ts_metadata9(k, v) {
|
|
2332
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
2333
|
+
}
|
|
2334
|
+
__name(_ts_metadata9, "_ts_metadata");
|
|
2335
|
+
var OffsetPagination = class {
|
|
2336
|
+
static {
|
|
2337
|
+
__name(this, "OffsetPagination");
|
|
2338
|
+
}
|
|
2339
|
+
total;
|
|
2340
|
+
limit;
|
|
2341
|
+
offset;
|
|
2342
|
+
constructor(total, parameters) {
|
|
2343
|
+
this.total = total;
|
|
2344
|
+
this.limit = parameters.limit;
|
|
2345
|
+
this.offset = parameters.offset;
|
|
2346
|
+
}
|
|
2347
|
+
};
|
|
2348
|
+
_ts_decorate9([
|
|
2349
|
+
Property({
|
|
2350
|
+
schema: {
|
|
2351
|
+
type: "number",
|
|
2352
|
+
description: "\u603B\u6570"
|
|
2353
|
+
}
|
|
2354
|
+
}),
|
|
2355
|
+
_ts_metadata9("design:type", Number)
|
|
2356
|
+
], OffsetPagination.prototype, "total", void 0);
|
|
2357
|
+
_ts_decorate9([
|
|
2358
|
+
Property({
|
|
2359
|
+
schema: {
|
|
2360
|
+
type: "number",
|
|
2361
|
+
description: "\u6BCF\u9875\u6570\u91CF"
|
|
2362
|
+
}
|
|
2363
|
+
}),
|
|
2364
|
+
_ts_metadata9("design:type", Number)
|
|
2365
|
+
], OffsetPagination.prototype, "limit", void 0);
|
|
2366
|
+
_ts_decorate9([
|
|
2367
|
+
Property({
|
|
2368
|
+
schema: {
|
|
2369
|
+
type: "number",
|
|
2370
|
+
description: "\u504F\u79FB\u91CF"
|
|
2371
|
+
}
|
|
2372
|
+
}),
|
|
2373
|
+
_ts_metadata9("design:type", Number)
|
|
2374
|
+
], OffsetPagination.prototype, "offset", void 0);
|
|
2375
|
+
OffsetPagination = _ts_decorate9([
|
|
2376
|
+
Model(),
|
|
2377
|
+
_ts_metadata9("design:type", Function),
|
|
2378
|
+
_ts_metadata9("design:paramtypes", [
|
|
2379
|
+
Number,
|
|
2380
|
+
Object
|
|
2381
|
+
])
|
|
2382
|
+
], OffsetPagination);
|
|
2383
|
+
|
|
2384
|
+
// src/models/cursor-pagination.ts
|
|
2385
|
+
var import_core16 = require("@mikro-orm/core");
|
|
2386
|
+
function _ts_decorate10(decorators, target, key, desc) {
|
|
2387
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2388
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
2389
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2390
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2391
|
+
}
|
|
2392
|
+
__name(_ts_decorate10, "_ts_decorate");
|
|
2393
|
+
function _ts_metadata10(k, v) {
|
|
2394
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
2395
|
+
}
|
|
2396
|
+
__name(_ts_metadata10, "_ts_metadata");
|
|
2397
|
+
var CursorPagination = class {
|
|
2398
|
+
static {
|
|
2399
|
+
__name(this, "CursorPagination");
|
|
2400
|
+
}
|
|
2401
|
+
total;
|
|
2402
|
+
limit;
|
|
2403
|
+
startCursor;
|
|
2404
|
+
endCursor;
|
|
2405
|
+
hasNextPage;
|
|
2406
|
+
hasPrevPage;
|
|
2407
|
+
constructor(cursor) {
|
|
2408
|
+
this.total = cursor.totalCount;
|
|
2409
|
+
this.limit = cursor.length;
|
|
2410
|
+
this.startCursor = cursor.startCursor;
|
|
2411
|
+
this.endCursor = cursor.endCursor;
|
|
2412
|
+
this.hasNextPage = cursor.hasNextPage;
|
|
2413
|
+
this.hasPrevPage = cursor.hasPrevPage;
|
|
2414
|
+
}
|
|
2415
|
+
};
|
|
2416
|
+
_ts_decorate10([
|
|
2417
|
+
Property({
|
|
2418
|
+
schema: {
|
|
2419
|
+
type: "number",
|
|
2420
|
+
description: "\u603B\u6570"
|
|
2421
|
+
}
|
|
2422
|
+
}),
|
|
2423
|
+
_ts_metadata10("design:type", Number)
|
|
2424
|
+
], CursorPagination.prototype, "total", void 0);
|
|
2425
|
+
_ts_decorate10([
|
|
2426
|
+
Property({
|
|
2427
|
+
schema: {
|
|
2428
|
+
type: "number",
|
|
2429
|
+
description: "\u6BCF\u9875\u6570\u91CF"
|
|
2430
|
+
}
|
|
2431
|
+
}),
|
|
2432
|
+
_ts_metadata10("design:type", Number)
|
|
2433
|
+
], CursorPagination.prototype, "limit", void 0);
|
|
2434
|
+
_ts_decorate10([
|
|
2435
|
+
Property({
|
|
2436
|
+
schema: {
|
|
2437
|
+
type: "string",
|
|
2438
|
+
description: "\u5F00\u59CB\u6E38\u6807",
|
|
2439
|
+
nullable: true
|
|
2440
|
+
}
|
|
2441
|
+
}),
|
|
2442
|
+
_ts_metadata10("design:type", Object)
|
|
2443
|
+
], CursorPagination.prototype, "startCursor", void 0);
|
|
2444
|
+
_ts_decorate10([
|
|
2445
|
+
Property({
|
|
2446
|
+
schema: {
|
|
2447
|
+
type: "string",
|
|
2448
|
+
description: "\u7ED3\u675F\u6E38\u6807",
|
|
2449
|
+
nullable: true
|
|
2450
|
+
}
|
|
2451
|
+
}),
|
|
2452
|
+
_ts_metadata10("design:type", Object)
|
|
2453
|
+
], CursorPagination.prototype, "endCursor", void 0);
|
|
2454
|
+
_ts_decorate10([
|
|
2455
|
+
Property({
|
|
2456
|
+
schema: {
|
|
2457
|
+
type: "boolean",
|
|
2458
|
+
description: "\u662F\u5426\u6709\u4E0B\u4E00\u9875"
|
|
2459
|
+
}
|
|
2460
|
+
}),
|
|
2461
|
+
_ts_metadata10("design:type", Boolean)
|
|
2462
|
+
], CursorPagination.prototype, "hasNextPage", void 0);
|
|
2463
|
+
_ts_decorate10([
|
|
2464
|
+
Property({
|
|
2465
|
+
schema: {
|
|
2466
|
+
type: "boolean",
|
|
2467
|
+
description: "\u662F\u5426\u6709\u4E0A\u4E00\u9875"
|
|
2468
|
+
}
|
|
2469
|
+
}),
|
|
2470
|
+
_ts_metadata10("design:type", Boolean)
|
|
2471
|
+
], CursorPagination.prototype, "hasPrevPage", void 0);
|
|
2472
|
+
CursorPagination = _ts_decorate10([
|
|
2473
|
+
Model(),
|
|
2474
|
+
_ts_metadata10("design:type", Function),
|
|
2475
|
+
_ts_metadata10("design:paramtypes", [
|
|
2476
|
+
typeof import_core16.Cursor === "undefined" ? Object : import_core16.Cursor
|
|
2477
|
+
])
|
|
2478
|
+
], CursorPagination);
|
|
2479
|
+
|
|
2480
|
+
// src/models/slice.ts
|
|
2481
|
+
var Slice = class _Slice {
|
|
2482
|
+
static {
|
|
2483
|
+
__name(this, "Slice");
|
|
2484
|
+
}
|
|
2485
|
+
data;
|
|
2486
|
+
pagination;
|
|
2487
|
+
constructor(data, pagination) {
|
|
2488
|
+
this.data = data;
|
|
2489
|
+
this.pagination = pagination;
|
|
2490
|
+
}
|
|
2491
|
+
*[Symbol.iterator]() {
|
|
2492
|
+
for (const item of this.data) {
|
|
2493
|
+
yield item;
|
|
2494
|
+
}
|
|
2495
|
+
}
|
|
2496
|
+
static fromOffset(data, total, parameters) {
|
|
2497
|
+
const pagination = new OffsetPagination(total, parameters);
|
|
2498
|
+
return new _Slice(data, pagination);
|
|
2499
|
+
}
|
|
2500
|
+
static fromCursor(cursor) {
|
|
2501
|
+
const pagination = new CursorPagination(cursor);
|
|
2502
|
+
return new _Slice(cursor.items, pagination);
|
|
2503
|
+
}
|
|
2504
|
+
map(fn) {
|
|
2505
|
+
const mappedData = this.data.map(fn);
|
|
2506
|
+
return new _Slice(mappedData, this.pagination);
|
|
2507
|
+
}
|
|
2508
|
+
};
|
|
2509
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
2510
|
+
0 && (module.exports = {
|
|
2511
|
+
BaseEntity,
|
|
2512
|
+
BukaValidationPipe,
|
|
2513
|
+
DatabaseConfig,
|
|
2514
|
+
EntityDtoType,
|
|
2515
|
+
EntityEnum,
|
|
2516
|
+
EntityManyToMany,
|
|
2517
|
+
EntityManyToOne,
|
|
2518
|
+
EntityOneToMany,
|
|
2519
|
+
EntityOneToOne,
|
|
2520
|
+
EntityProperty,
|
|
2521
|
+
EntityRefType,
|
|
2522
|
+
EntityRefTypeClassMetadataPropertyKey,
|
|
2523
|
+
EntityTransient,
|
|
2524
|
+
FilterQueryOperators,
|
|
2525
|
+
FilterQueryOperatorsMetadataKey,
|
|
2526
|
+
FilterQueryType,
|
|
2527
|
+
HAS_ANY_KEY,
|
|
2528
|
+
HasAnyKey,
|
|
2529
|
+
ListResponseBodyType,
|
|
2530
|
+
MATCH_JSON_SCHEMA,
|
|
2531
|
+
MatchJsonSchema,
|
|
2532
|
+
Model,
|
|
2533
|
+
ModelRegister,
|
|
2534
|
+
Nested,
|
|
2535
|
+
NestedProperty,
|
|
2536
|
+
OmitType,
|
|
2537
|
+
OptionalPageQuery,
|
|
2538
|
+
OrderQueryType,
|
|
2539
|
+
PageQuery,
|
|
2540
|
+
PartialType,
|
|
2541
|
+
PickType,
|
|
2542
|
+
Property,
|
|
2543
|
+
RELATION_METADATA_KEY,
|
|
2544
|
+
ReferencePropertiesMetadataKey,
|
|
2545
|
+
ReferenceProperty,
|
|
2546
|
+
Relation,
|
|
2547
|
+
ResponseBodyType,
|
|
2548
|
+
Slice,
|
|
2549
|
+
TimestampedEntity,
|
|
2550
|
+
deepObjectifyQueries,
|
|
2551
|
+
getFilterQueryOperators
|
|
2552
|
+
});
|
|
2553
|
+
//# sourceMappingURL=index.js.map
|