nicot 1.1.29 → 1.1.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +40 -11
- package/dist/index.cjs.map +2 -2
- package/dist/index.mjs +42 -13
- package/dist/index.mjs.map +3 -3
- package/dist/src/decorators/property.d.ts +3 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -86,6 +86,7 @@ __export(index_exports, {
|
|
|
86
86
|
StringIdBase: () => StringIdBase,
|
|
87
87
|
TimeBase: () => TimeBase,
|
|
88
88
|
UpdatePipe: () => UpdatePipe,
|
|
89
|
+
UuidColumn: () => UuidColumn,
|
|
89
90
|
applyQueryMatchBoolean: () => applyQueryMatchBoolean,
|
|
90
91
|
applyQueryProperty: () => applyQueryProperty,
|
|
91
92
|
applyQueryPropertyLike: () => applyQueryPropertyLike,
|
|
@@ -257,6 +258,24 @@ var StringColumn = (length, options = {}) => {
|
|
|
257
258
|
swaggerDecorator(options, { type: String, maxLength: length })
|
|
258
259
|
]);
|
|
259
260
|
};
|
|
261
|
+
var UuidColumn = (options = {}) => {
|
|
262
|
+
return (0, import_nesties3.MergePropertyDecorators)([
|
|
263
|
+
(0, import_typeorm.Column)("uuid", {
|
|
264
|
+
...columnDecoratorOptions(options),
|
|
265
|
+
...options.generated ? {
|
|
266
|
+
nullable: false,
|
|
267
|
+
generated: "uuid"
|
|
268
|
+
} : {}
|
|
269
|
+
}),
|
|
270
|
+
(0, import_class_validator3.IsUUID)(),
|
|
271
|
+
validatorDecorator(options),
|
|
272
|
+
swaggerDecorator(options, {
|
|
273
|
+
type: String,
|
|
274
|
+
format: "uuid",
|
|
275
|
+
example: "550e8400-e29b-41d4-a716-446655440000"
|
|
276
|
+
})
|
|
277
|
+
]);
|
|
278
|
+
};
|
|
260
279
|
var IntColumn = (type, options = {}) => {
|
|
261
280
|
const decs = [
|
|
262
281
|
(0, import_typeorm.Column)(type, {
|
|
@@ -743,7 +762,6 @@ function IdBase(idOptions = {}) {
|
|
|
743
762
|
if (!idOptions.noOrderById) {
|
|
744
763
|
qb.orderBy(`${entityName}.id`, "DESC");
|
|
745
764
|
}
|
|
746
|
-
applyQueryProperty(this, qb, entityName, "id");
|
|
747
765
|
}
|
|
748
766
|
};
|
|
749
767
|
const dec = (0, import_nesties7.MergePropertyDecorators)([
|
|
@@ -754,7 +772,8 @@ function IdBase(idOptions = {}) {
|
|
|
754
772
|
columnExtras: { nullable: false, primary: true }
|
|
755
773
|
}),
|
|
756
774
|
Reflect.metadata("design:type", Number),
|
|
757
|
-
(0, import_typeorm3.Generated)("increment")
|
|
775
|
+
(0, import_typeorm3.Generated)("increment"),
|
|
776
|
+
QueryEqual()
|
|
758
777
|
]);
|
|
759
778
|
dec(cl.prototype, "id");
|
|
760
779
|
return cl;
|
|
@@ -763,19 +782,28 @@ function StringIdBase(idOptions) {
|
|
|
763
782
|
const cl = class StringIdBase extends TimeBase {
|
|
764
783
|
applyQuery(qb, entityName) {
|
|
765
784
|
super.applyQuery(qb, entityName);
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
785
|
+
if (!idOptions.noOrderById) {
|
|
786
|
+
qb.orderBy(`${entityName}.id`, "ASC");
|
|
787
|
+
}
|
|
769
788
|
}
|
|
770
789
|
};
|
|
790
|
+
const columnOptions = {
|
|
791
|
+
required: !idOptions.uuid,
|
|
792
|
+
description: idOptions.description,
|
|
793
|
+
columnExtras: { primary: true, nullable: false }
|
|
794
|
+
};
|
|
771
795
|
const decs = [
|
|
772
|
-
StringColumn(idOptions.length || (idOptions.uuid ? void 0 : 255), {
|
|
773
|
-
required: !idOptions.uuid,
|
|
774
|
-
description: idOptions.description,
|
|
775
|
-
columnExtras: { primary: true, nullable: false }
|
|
776
|
-
}),
|
|
777
796
|
Reflect.metadata("design:type", String),
|
|
778
|
-
|
|
797
|
+
QueryEqual(),
|
|
798
|
+
...idOptions.uuid ? [
|
|
799
|
+
UuidColumn({ ...columnOptions, generated: true }),
|
|
800
|
+
(0, import_typeorm3.Generated)("uuid"),
|
|
801
|
+
NotWritable()
|
|
802
|
+
] : [
|
|
803
|
+
StringColumn(idOptions.length || 255, columnOptions),
|
|
804
|
+
(0, import_class_validator6.IsNotEmpty)(),
|
|
805
|
+
NotChangeable()
|
|
806
|
+
]
|
|
779
807
|
];
|
|
780
808
|
const dec = (0, import_nesties7.MergePropertyDecorators)(decs);
|
|
781
809
|
dec(cl.prototype, "id");
|
|
@@ -2201,6 +2229,7 @@ var RestfulFactory = class _RestfulFactory {
|
|
|
2201
2229
|
StringIdBase,
|
|
2202
2230
|
TimeBase,
|
|
2203
2231
|
UpdatePipe,
|
|
2232
|
+
UuidColumn,
|
|
2204
2233
|
applyQueryMatchBoolean,
|
|
2205
2234
|
applyQueryProperty,
|
|
2206
2235
|
applyQueryPropertyLike,
|