nicot 1.1.28 → 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.mjs CHANGED
@@ -117,6 +117,7 @@ import {
117
117
  IsNumber,
118
118
  IsOptional as IsOptional2,
119
119
  IsString,
120
+ IsUUID,
120
121
  MaxLength,
121
122
  Min,
122
123
  ValidateNested as ValidateNested2
@@ -195,6 +196,24 @@ var StringColumn = (length, options = {}) => {
195
196
  swaggerDecorator(options, { type: String, maxLength: length })
196
197
  ]);
197
198
  };
199
+ var UuidColumn = (options = {}) => {
200
+ return MergePropertyDecorators2([
201
+ Column("uuid", {
202
+ ...columnDecoratorOptions(options),
203
+ ...options.generated ? {
204
+ nullable: false,
205
+ generated: "uuid"
206
+ } : {}
207
+ }),
208
+ IsUUID(),
209
+ validatorDecorator(options),
210
+ swaggerDecorator(options, {
211
+ type: String,
212
+ format: "uuid",
213
+ example: "550e8400-e29b-41d4-a716-446655440000"
214
+ })
215
+ ]);
216
+ };
198
217
  var IntColumn = (type, options = {}) => {
199
218
  const decs = [
200
219
  Column(type, {
@@ -677,8 +696,8 @@ __decorateClass([
677
696
  ], TimeBase.prototype, "deleteTime", 2);
678
697
 
679
698
  // src/bases/id-base.ts
680
- import { Generated } from "typeorm";
681
- import { IsNotEmpty as IsNotEmpty2, IsString as IsString3 } from "class-validator";
699
+ import { Generated as Generated2 } from "typeorm";
700
+ import { IsNotEmpty as IsNotEmpty2 } from "class-validator";
682
701
  import { MergePropertyDecorators as MergePropertyDecorators4 } from "nesties";
683
702
  function IdBase(idOptions = {}) {
684
703
  const cl = class IdBase extends TimeBase {
@@ -687,7 +706,6 @@ function IdBase(idOptions = {}) {
687
706
  if (!idOptions.noOrderById) {
688
707
  qb.orderBy(`${entityName}.id`, "DESC");
689
708
  }
690
- applyQueryProperty(this, qb, entityName, "id");
691
709
  }
692
710
  };
693
711
  const dec = MergePropertyDecorators4([
@@ -698,7 +716,8 @@ function IdBase(idOptions = {}) {
698
716
  columnExtras: { nullable: false, primary: true }
699
717
  }),
700
718
  Reflect.metadata("design:type", Number),
701
- Generated("increment")
719
+ Generated2("increment"),
720
+ QueryEqual()
702
721
  ]);
703
722
  dec(cl.prototype, "id");
704
723
  return cl;
@@ -707,19 +726,28 @@ function StringIdBase(idOptions) {
707
726
  const cl = class StringIdBase extends TimeBase {
708
727
  applyQuery(qb, entityName) {
709
728
  super.applyQuery(qb, entityName);
710
- console.log("idbase order by");
711
- qb.orderBy(`${entityName}.id`, "ASC");
712
- applyQueryProperty(this, qb, entityName, "id");
729
+ if (!idOptions.noOrderById) {
730
+ qb.orderBy(`${entityName}.id`, "ASC");
731
+ }
713
732
  }
714
733
  };
734
+ const columnOptions = {
735
+ required: !idOptions.uuid,
736
+ description: idOptions.description,
737
+ columnExtras: { primary: true, nullable: false }
738
+ };
715
739
  const decs = [
716
- StringColumn(idOptions.length || (idOptions.uuid ? 36 : 255), {
717
- required: !idOptions.uuid,
718
- description: idOptions.description,
719
- columnExtras: { primary: true, nullable: false }
720
- }),
721
740
  Reflect.metadata("design:type", String),
722
- ...idOptions.uuid ? [Generated("uuid"), NotWritable()] : [IsString3(), IsNotEmpty2(), NotChangeable()]
741
+ QueryEqual(),
742
+ ...idOptions.uuid ? [
743
+ UuidColumn({ ...columnOptions, generated: true }),
744
+ Generated2("uuid"),
745
+ NotWritable()
746
+ ] : [
747
+ StringColumn(idOptions.length || 255, columnOptions),
748
+ IsNotEmpty2(),
749
+ NotChangeable()
750
+ ]
723
751
  ];
724
752
  const dec = MergePropertyDecorators4(decs);
725
753
  dec(cl.prototype, "id");
@@ -2175,6 +2203,7 @@ export {
2175
2203
  StringIdBase,
2176
2204
  TimeBase,
2177
2205
  UpdatePipe,
2206
+ UuidColumn,
2178
2207
  applyQueryMatchBoolean,
2179
2208
  applyQueryProperty,
2180
2209
  applyQueryPropertyLike,