sigo-entities 1.2.539 → 1.2.541

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
@@ -266,6 +266,180 @@ function isObject(value) {
266
266
  return typeof value === "object" && value !== null && !Array.isArray(value);
267
267
  }
268
268
 
269
+ // src/shared/utils/mongoJsonSchema/index.ts
270
+ import "reflect-metadata";
271
+ import { plainToInstance as plainToInstance4 } from "class-transformer";
272
+ import { getMetadataStorage } from "class-validator";
273
+
274
+ // src/shared/utils/mongoJsonSchema/constraints.ts
275
+ var EMAIL_PATTERN = "^[^@\\s]+@[^@\\s]+\\.[^@\\s]+$";
276
+ var UUID_PATTERN = "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$";
277
+ var BSON_TYPES = {
278
+ isString: "string",
279
+ isEmail: "string",
280
+ isUuid: "string",
281
+ matches: "string",
282
+ isDateString: "string",
283
+ isNumberString: "string",
284
+ isNumber: "number",
285
+ isInt: "number",
286
+ isBoolean: "bool",
287
+ isDate: "date",
288
+ isArray: "array",
289
+ isObject: "object"
290
+ };
291
+ var minLength = ([min], schema) => {
292
+ schema.minLength = Math.max(schema.minLength ?? 0, min);
293
+ };
294
+ var RULES = {
295
+ isLength: ([min, max], schema) => {
296
+ minLength([min], schema);
297
+ if (max !== void 0) schema.maxLength = max;
298
+ },
299
+ minLength,
300
+ maxLength: ([max], schema) => {
301
+ schema.maxLength = max;
302
+ },
303
+ isNotEmpty: (_, schema) => {
304
+ if (schema.bsonType === "string") minLength([1], schema);
305
+ },
306
+ min: ([min], schema) => {
307
+ schema.minimum = min;
308
+ },
309
+ max: ([max], schema) => {
310
+ schema.maximum = max;
311
+ },
312
+ isPositive: (_, schema) => {
313
+ schema.minimum = 0;
314
+ schema.exclusiveMinimum = true;
315
+ },
316
+ isEnum: ([, values], schema) => {
317
+ schema.enum = values;
318
+ },
319
+ isIn: ([values], schema) => {
320
+ schema.enum = values;
321
+ },
322
+ arrayNotEmpty: (_, schema) => {
323
+ schema.minItems = 1;
324
+ },
325
+ arrayMinSize: ([min], schema) => {
326
+ schema.minItems = min;
327
+ },
328
+ arrayMaxSize: ([max], schema) => {
329
+ schema.maxItems = max;
330
+ },
331
+ isEmail: (_, schema) => {
332
+ schema.pattern = EMAIL_PATTERN;
333
+ },
334
+ isUuid: (_, schema) => {
335
+ schema.pattern = UUID_PATTERN;
336
+ },
337
+ matches: ([pattern], schema) => {
338
+ schema.pattern = pattern instanceof RegExp ? pattern.source : pattern;
339
+ }
340
+ };
341
+ function applyConstraints(metadatas) {
342
+ const schema = {};
343
+ const bsonType = metadatas.map((m) => BSON_TYPES[m.name ?? ""]).find(Boolean);
344
+ if (bsonType) schema.bsonType = bsonType;
345
+ const notEmpty = metadatas.filter((m) => m.name === "isNotEmpty");
346
+ const others = metadatas.filter((m) => m.name !== "isNotEmpty");
347
+ const ordered = [...others, ...notEmpty];
348
+ for (const metadata of ordered) {
349
+ const rule = RULES[metadata.name ?? ""];
350
+ if (rule) rule(metadata.constraints ?? [], schema);
351
+ }
352
+ if (schema.minLength === 0) delete schema.minLength;
353
+ return schema;
354
+ }
355
+
356
+ // src/shared/utils/mongoJsonSchema/conditional.ts
357
+ function evaluateConditional(metadatas, property) {
358
+ const conditions = metadatas.filter((m) => m.type === "conditionalValidation").map((m) => m.constraints[0]);
359
+ if (!conditions.length) return void 0;
360
+ const skips = (value) => conditions.some((condition) => {
361
+ try {
362
+ return !condition({ [property]: value }, value);
363
+ } catch {
364
+ return true;
365
+ }
366
+ });
367
+ const isDefined = metadatas.some((m) => m.name === "isDefined");
368
+ return {
369
+ required: isDefined || !skips(void 0),
370
+ nullable: !isDefined && skips(null),
371
+ emptyString: skips(""),
372
+ unconstrained: skips("x") && skips(1)
373
+ };
374
+ }
375
+ function withConditionalAlternatives(schema, rule) {
376
+ const alternatives = [];
377
+ if (rule.nullable) alternatives.push({ bsonType: "null" });
378
+ if (rule.emptyString) alternatives.push({ bsonType: "string", maxLength: 0 });
379
+ return alternatives.length ? { anyOf: [...alternatives, schema] } : schema;
380
+ }
381
+
382
+ // src/shared/utils/mongoJsonSchema/index.ts
383
+ function entityToMongoJsonSchema(entity) {
384
+ return buildObjectSchema(entity, []);
385
+ }
386
+ function buildObjectSchema(entity, stack) {
387
+ if (stack.includes(entity)) return { bsonType: "object" };
388
+ const storage = getMetadataStorage();
389
+ const metadatas = storage.getTargetValidationMetadatas(entity, "", false, false);
390
+ const grouped = storage.groupByPropertyName(metadatas);
391
+ const defaults = new entity();
392
+ const nextStack = [...stack, entity];
393
+ const required = [];
394
+ const properties = {};
395
+ for (const [property, propertyMetadatas] of Object.entries(grouped)) {
396
+ const conditional = evaluateConditional(propertyMetadatas, property);
397
+ if (conditional?.unconstrained) continue;
398
+ if (!conditional || conditional.required) required.push(property);
399
+ const propertySchema = buildPropertySchema(entity, property, propertyMetadatas, defaults[property], nextStack);
400
+ properties[property] = conditional ? withConditionalAlternatives(propertySchema, conditional) : propertySchema;
401
+ }
402
+ const schema = { bsonType: "object" };
403
+ if (required.length) schema.required = required;
404
+ schema.properties = properties;
405
+ return schema;
406
+ }
407
+ function buildPropertySchema(entity, property, metadatas, defaultValue, stack) {
408
+ const validators = metadatas.filter((m) => m.type !== "nestedValidation" && m.type !== "conditionalValidation");
409
+ const nested = metadatas.find((m) => m.type === "nestedValidation");
410
+ const ownValidators = validators.filter((m) => !m.each);
411
+ const schema = applyConstraints(ownValidators);
412
+ const isArray = schema.bsonType === "array" || Array.isArray(defaultValue) || Boolean(nested?.each);
413
+ if (!isArray) {
414
+ const nestedType = nested ? resolveNestedType(entity, property, false, defaultValue) : void 0;
415
+ if (!nestedType) return schema;
416
+ const objectSchema = buildObjectSchema(nestedType, stack);
417
+ return { ...schema, ...objectSchema };
418
+ }
419
+ const eachValidators = validators.filter((m) => m.each);
420
+ const itemConstraints = applyConstraints(eachValidators);
421
+ const itemType = nested ? resolveNestedType(entity, property, true, void 0) : void 0;
422
+ const itemObjectSchema = itemType ? buildObjectSchema(itemType, stack) : {};
423
+ const items = { ...itemConstraints, ...itemObjectSchema };
424
+ schema.bsonType = "array";
425
+ if (Object.keys(items).length) schema.items = items;
426
+ return schema;
427
+ }
428
+ function resolveNestedType(entity, property, isArray, defaultValue) {
429
+ const sample = isArray ? [{}] : {};
430
+ let resolved;
431
+ try {
432
+ const instance = plainToInstance4(entity, { [property]: sample });
433
+ const value = instance[property];
434
+ resolved = isArray ? value?.[0] : value;
435
+ } catch {
436
+ resolved = defaultValue;
437
+ }
438
+ const type = resolved?.constructor ?? defaultValue?.constructor;
439
+ const isClass = type && type !== Object && type !== Array && type !== Date;
440
+ return isClass ? type : void 0;
441
+ }
442
+
269
443
  // src/shared/dto/WBE-dto.ts
270
444
  import { Expose as Expose2 } from "class-transformer";
271
445
  import { IsNotEmpty as IsNotEmpty2, IsNumber, IsString as IsString2, Length as Length2, Min } from "class-validator";
@@ -53127,7 +53301,7 @@ __decorateClass([
53127
53301
 
53128
53302
  // src/operativa/procesos/btalppluzpendiente_order/shared/index.ts
53129
53303
  import { Expose as Expose813 } from "class-transformer";
53130
- import { IsDefined as IsDefined301, IsString as IsString671, IsDate as IsDate192 } from "class-validator";
53304
+ import { IsBoolean as IsBoolean71, IsDate as IsDate192, IsDefined as IsDefined301, IsString as IsString671 } from "class-validator";
53131
53305
  import "reflect-metadata";
53132
53306
  var BtAlpPluzPendienteOrderENTITY = class {
53133
53307
  _id = "";
@@ -53166,6 +53340,15 @@ var BtAlpPluzPendienteOrderENTITY = class {
53166
53340
  inicio_act_mas_temprano = /* @__PURE__ */ new Date();
53167
53341
  ticket_de_averia_sc_udf = "";
53168
53342
  tecnico = "";
53343
+ en_fsm = false;
53344
+ escenario_fsm = "";
53345
+ id_externo_actividad = "";
53346
+ paso_workflow = "";
53347
+ fecha_vencimiento = /* @__PURE__ */ new Date(0);
53348
+ hoja_ruta_operacion = "";
53349
+ activity_remarks = "";
53350
+ alimentador = "";
53351
+ sed = "";
53169
53352
  };
53170
53353
  __decorateClass([
53171
53354
  Expose813(),
@@ -53347,6 +53530,51 @@ __decorateClass([
53347
53530
  IsDefined301(),
53348
53531
  IsString671()
53349
53532
  ], BtAlpPluzPendienteOrderENTITY.prototype, "tecnico", 2);
53533
+ __decorateClass([
53534
+ Expose813(),
53535
+ IsDefined301(),
53536
+ IsBoolean71()
53537
+ ], BtAlpPluzPendienteOrderENTITY.prototype, "en_fsm", 2);
53538
+ __decorateClass([
53539
+ Expose813(),
53540
+ IsDefined301(),
53541
+ IsString671()
53542
+ ], BtAlpPluzPendienteOrderENTITY.prototype, "escenario_fsm", 2);
53543
+ __decorateClass([
53544
+ Expose813(),
53545
+ IsDefined301(),
53546
+ IsString671()
53547
+ ], BtAlpPluzPendienteOrderENTITY.prototype, "id_externo_actividad", 2);
53548
+ __decorateClass([
53549
+ Expose813(),
53550
+ IsDefined301(),
53551
+ IsString671()
53552
+ ], BtAlpPluzPendienteOrderENTITY.prototype, "paso_workflow", 2);
53553
+ __decorateClass([
53554
+ Expose813(),
53555
+ IsDefined301(),
53556
+ IsDate192({ message: "El campo fecha_vencimiento debe ser una fecha" })
53557
+ ], BtAlpPluzPendienteOrderENTITY.prototype, "fecha_vencimiento", 2);
53558
+ __decorateClass([
53559
+ Expose813(),
53560
+ IsDefined301(),
53561
+ IsString671()
53562
+ ], BtAlpPluzPendienteOrderENTITY.prototype, "hoja_ruta_operacion", 2);
53563
+ __decorateClass([
53564
+ Expose813(),
53565
+ IsDefined301(),
53566
+ IsString671()
53567
+ ], BtAlpPluzPendienteOrderENTITY.prototype, "activity_remarks", 2);
53568
+ __decorateClass([
53569
+ Expose813(),
53570
+ IsDefined301(),
53571
+ IsString671()
53572
+ ], BtAlpPluzPendienteOrderENTITY.prototype, "alimentador", 2);
53573
+ __decorateClass([
53574
+ Expose813(),
53575
+ IsDefined301(),
53576
+ IsString671()
53577
+ ], BtAlpPluzPendienteOrderENTITY.prototype, "sed", 2);
53350
53578
 
53351
53579
  // src/operativa/procesos/btalppluz_order2/shared/index.ts
53352
53580
  import { Expose as Expose817, Type as Type502 } from "class-transformer";
@@ -53662,7 +53890,7 @@ __decorateClass([
53662
53890
 
53663
53891
  // src/operativa/procesos/btalppluz_order2/shared/dto/cuadrilla-bt-alp-pluz-order2-dto.ts
53664
53892
  import { Expose as Expose815 } from "class-transformer";
53665
- import { IsBoolean as IsBoolean71, IsDefined as IsDefined303, IsEnum as IsEnum57, IsNumber as IsNumber533, IsOptional as IsOptional79, IsString as IsString673 } from "class-validator";
53893
+ import { IsBoolean as IsBoolean72, IsDefined as IsDefined303, IsEnum as IsEnum57, IsNumber as IsNumber533, IsOptional as IsOptional79, IsString as IsString673 } from "class-validator";
53666
53894
  import "reflect-metadata";
53667
53895
  var CuadrillaBtAlpPluzOrder2DTO = class {
53668
53896
  Codigo = "";
@@ -53710,12 +53938,12 @@ __decorateClass([
53710
53938
  __decorateClass([
53711
53939
  Expose815(),
53712
53940
  IsOptional79(),
53713
- IsBoolean71()
53941
+ IsBoolean72()
53714
53942
  ], CuadrillaBtAlpPluzOrder2DTO.prototype, "EsJefe", 2);
53715
53943
  __decorateClass([
53716
53944
  Expose815(),
53717
53945
  IsOptional79(),
53718
- IsBoolean71()
53946
+ IsBoolean72()
53719
53947
  ], CuadrillaBtAlpPluzOrder2DTO.prototype, "EsJefeSuplente", 2);
53720
53948
  __decorateClass([
53721
53949
  Expose815(),
@@ -53735,7 +53963,7 @@ __decorateClass([
53735
53963
 
53736
53964
  // src/operativa/procesos/btalppluz_order2/shared/dto/eecc-bt-alp-pluz-dto.ts
53737
53965
  import { Expose as Expose816 } from "class-transformer";
53738
- import { IsBoolean as IsBoolean72, IsDefined as IsDefined304, IsString as IsString674 } from "class-validator";
53966
+ import { IsBoolean as IsBoolean73, IsDefined as IsDefined304, IsString as IsString674 } from "class-validator";
53739
53967
  import "reflect-metadata";
53740
53968
  var EECCBtAlpPluzDTO = class {
53741
53969
  RUC = "";
@@ -53755,7 +53983,7 @@ __decorateClass([
53755
53983
  __decorateClass([
53756
53984
  Expose816(),
53757
53985
  IsDefined304(),
53758
- IsBoolean72()
53986
+ IsBoolean73()
53759
53987
  ], EECCBtAlpPluzDTO.prototype, "Propio", 2);
53760
53988
 
53761
53989
  // src/operativa/procesos/btalppluz_order2/shared/index.ts
@@ -54586,7 +54814,7 @@ import { IsDefined as IsDefined311, IsEnum as IsEnum60, IsObject as IsObject15,
54586
54814
  import { Expose as Expose823, Type as Type505 } from "class-transformer";
54587
54815
 
54588
54816
  // src/v2/dtos/AuthUser.ts
54589
- import { IsBoolean as IsBoolean73, IsDefined as IsDefined309, IsEmail as IsEmail7, IsString as IsString678, IsUUID as IsUUID25, ValidateIf as ValidateIf8 } from "class-validator";
54817
+ import { IsBoolean as IsBoolean74, IsDefined as IsDefined309, IsEmail as IsEmail7, IsString as IsString678, IsUUID as IsUUID25, ValidateIf as ValidateIf8 } from "class-validator";
54590
54818
  import { Expose as Expose821, Transform as Transform119 } from "class-transformer";
54591
54819
  var AuthUserDto = class {
54592
54820
  email;
@@ -54629,7 +54857,7 @@ __decorateClass([
54629
54857
  ], AuthUserDto.prototype, "identification", 2);
54630
54858
  __decorateClass([
54631
54859
  IsDefined309({ message: 'La propiedad "root" es obligatoria.' }),
54632
- IsBoolean73({ message: 'La propiedad "root" debe ser un valor booleano.' }),
54860
+ IsBoolean74({ message: 'La propiedad "root" debe ser un valor booleano.' }),
54633
54861
  Expose821()
54634
54862
  ], AuthUserDto.prototype, "root", 2);
54635
54863
  __decorateClass([
@@ -54757,7 +54985,7 @@ import { Expose as Expose826, Type as Type506 } from "class-transformer";
54757
54985
 
54758
54986
  // src/v2/entities/SystemOption.ts
54759
54987
  import { Expose as Expose825 } from "class-transformer";
54760
- import { IsBoolean as IsBoolean75, IsDefined as IsDefined313, IsNotEmpty as IsNotEmpty467, IsString as IsString681, IsUUID as IsUUID27 } from "class-validator";
54988
+ import { IsBoolean as IsBoolean76, IsDefined as IsDefined313, IsNotEmpty as IsNotEmpty467, IsString as IsString681, IsUUID as IsUUID27 } from "class-validator";
54761
54989
  var SystemOptionEntity = class {
54762
54990
  _id;
54763
54991
  key;
@@ -54800,7 +55028,7 @@ __decorateClass([
54800
55028
  Expose825()
54801
55029
  ], SystemOptionEntity.prototype, "route", 2);
54802
55030
  __decorateClass([
54803
- IsBoolean75({ message: "Root debe ser booleano" }),
55031
+ IsBoolean76({ message: "Root debe ser booleano" }),
54804
55032
  Expose825()
54805
55033
  ], SystemOptionEntity.prototype, "root", 2);
54806
55034
 
@@ -54911,7 +55139,7 @@ __decorateClass([
54911
55139
 
54912
55140
  // src/v2/dtos/UpdateProfile.ts
54913
55141
  import { Expose as Expose830, Transform as Transform124 } from "class-transformer";
54914
- import { IsArray as IsArray262, IsDefined as IsDefined317, IsString as IsString685, Length as Length347, MinLength as MinLength61, IsBoolean as IsBoolean77 } from "class-validator";
55142
+ import { IsArray as IsArray262, IsDefined as IsDefined317, IsString as IsString685, Length as Length347, MinLength as MinLength61, IsBoolean as IsBoolean78 } from "class-validator";
54915
55143
  var UpdateProfileDto = class {
54916
55144
  active;
54917
55145
  name;
@@ -54920,7 +55148,7 @@ var UpdateProfileDto = class {
54920
55148
  };
54921
55149
  __decorateClass([
54922
55150
  IsDefined317({ message: 'La propiedad "activo" es obligatoria.' }),
54923
- IsBoolean77({ message: 'La propiedad "activo" debe ser un valor booleano.' }),
55151
+ IsBoolean78({ message: 'La propiedad "activo" debe ser un valor booleano.' }),
54924
55152
  Expose830()
54925
55153
  ], UpdateProfileDto.prototype, "active", 2);
54926
55154
  __decorateClass([
@@ -54980,7 +55208,7 @@ __decorateClass([
54980
55208
  import { Expose as Expose833, Type as Type508 } from "class-transformer";
54981
55209
  import {
54982
55210
  IsArray as IsArray265,
54983
- IsBoolean as IsBoolean80,
55211
+ IsBoolean as IsBoolean81,
54984
55212
  IsDefined as IsDefined320,
54985
55213
  IsEnum as IsEnum62,
54986
55214
  IsNotEmpty as IsNotEmpty469,
@@ -55052,7 +55280,7 @@ __decorateClass([
55052
55280
  ], _DocumentRequirementDto.prototype, "maxFiles", 2);
55053
55281
  __decorateClass([
55054
55282
  IsDefined320({ message: "La propiedad de requiere metadatos es requerida" }),
55055
- IsBoolean80({ message: "La propiedad de requiere metadatos debe ser un booleano" }),
55283
+ IsBoolean81({ message: "La propiedad de requiere metadatos debe ser un booleano" }),
55056
55284
  Expose833()
55057
55285
  ], _DocumentRequirementDto.prototype, "requiresMetadata", 2);
55058
55286
  __decorateClass([
@@ -55188,7 +55416,7 @@ var CompanyType = /* @__PURE__ */ ((CompanyType2) => {
55188
55416
 
55189
55417
  // src/v2/dtos/CreateCompany.ts
55190
55418
  import { Expose as Expose838 } from "class-transformer";
55191
- import { IsArray as IsArray266, IsBoolean as IsBoolean81, IsDefined as IsDefined325, IsEmail as IsEmail11, IsEnum as IsEnum63, IsNotEmpty as IsNotEmpty474, IsString as IsString693, IsUUID as IsUUID36 } from "class-validator";
55419
+ import { IsArray as IsArray266, IsBoolean as IsBoolean82, IsDefined as IsDefined325, IsEmail as IsEmail11, IsEnum as IsEnum63, IsNotEmpty as IsNotEmpty474, IsString as IsString693, IsUUID as IsUUID36 } from "class-validator";
55192
55420
  var CreateCompanyDto = class {
55193
55421
  _id;
55194
55422
  companyType;
@@ -55238,7 +55466,7 @@ __decorateClass([
55238
55466
  ], CreateCompanyDto.prototype, "tradeName", 2);
55239
55467
  __decorateClass([
55240
55468
  IsDefined325({ message: "La propiedad es propia es requerida" }),
55241
- IsBoolean81({ message: "La propiedad es propia debe ser un booleano" }),
55469
+ IsBoolean82({ message: "La propiedad es propia debe ser un booleano" }),
55242
55470
  Expose838()
55243
55471
  ], CreateCompanyDto.prototype, "isOwn", 2);
55244
55472
  __decorateClass([
@@ -55268,7 +55496,7 @@ __decorateClass([
55268
55496
 
55269
55497
  // src/v2/dtos/UpdateCompany.ts
55270
55498
  import { Expose as Expose839 } from "class-transformer";
55271
- import { IsArray as IsArray267, IsBoolean as IsBoolean82, IsDefined as IsDefined326, IsEmail as IsEmail12, IsEnum as IsEnum64, IsNotEmpty as IsNotEmpty475, IsString as IsString694, IsUUID as IsUUID37 } from "class-validator";
55499
+ import { IsArray as IsArray267, IsBoolean as IsBoolean83, IsDefined as IsDefined326, IsEmail as IsEmail12, IsEnum as IsEnum64, IsNotEmpty as IsNotEmpty475, IsString as IsString694, IsUUID as IsUUID37 } from "class-validator";
55272
55500
  var UpdateCompanyDto = class {
55273
55501
  _id;
55274
55502
  companyType;
@@ -55318,7 +55546,7 @@ __decorateClass([
55318
55546
  ], UpdateCompanyDto.prototype, "tradeName", 2);
55319
55547
  __decorateClass([
55320
55548
  IsDefined326({ message: "La propiedad es propia es requerida" }),
55321
- IsBoolean82({ message: "La propiedad es propia debe ser un booleano" }),
55549
+ IsBoolean83({ message: "La propiedad es propia debe ser un booleano" }),
55322
55550
  Expose839()
55323
55551
  ], UpdateCompanyDto.prototype, "isOwn", 2);
55324
55552
  __decorateClass([
@@ -55347,7 +55575,7 @@ __decorateClass([
55347
55575
  ], UpdateCompanyDto.prototype, "countryId", 2);
55348
55576
 
55349
55577
  // src/v2/dtos/CreateUser.ts
55350
- import { IsArray as IsArray268, IsBoolean as IsBoolean83, IsDefined as IsDefined328, IsEmail as IsEmail13, IsString as IsString696, IsUUID as IsUUID38, ValidateIf as ValidateIf10, ValidateNested as ValidateNested440 } from "class-validator";
55578
+ import { IsArray as IsArray268, IsBoolean as IsBoolean84, IsDefined as IsDefined328, IsEmail as IsEmail13, IsString as IsString696, IsUUID as IsUUID38, ValidateIf as ValidateIf10, ValidateNested as ValidateNested440 } from "class-validator";
55351
55579
  import { Expose as Expose841, Transform as Transform128, Type as Type510 } from "class-transformer";
55352
55580
 
55353
55581
  // src/v2/dtos/ResourceSystemDto.ts
@@ -55467,7 +55695,7 @@ __decorateClass([
55467
55695
  ], CreateUserDto.prototype, "delegationIds", 2);
55468
55696
  __decorateClass([
55469
55697
  IsDefined328({ message: 'La propiedad "root" es obligatoria.' }),
55470
- IsBoolean83({ message: 'La propiedad "root" debe ser un valor booleano.' }),
55698
+ IsBoolean84({ message: 'La propiedad "root" debe ser un valor booleano.' }),
55471
55699
  Expose841()
55472
55700
  ], CreateUserDto.prototype, "root", 2);
55473
55701
  __decorateClass([
@@ -56663,6 +56891,26 @@ function IsNotAfter(property, validationOptions) {
56663
56891
  });
56664
56892
  };
56665
56893
  }
56894
+ var DAY_MS = 24 * 60 * 60 * 1e3;
56895
+ var MAX_SEARCH_RANGE_DAYS = 14;
56896
+ function MaxDaysFrom(property, days, validationOptions) {
56897
+ return function(object, propertyName) {
56898
+ registerDecorator3({
56899
+ name: "maxDaysFrom",
56900
+ target: object.constructor,
56901
+ propertyName,
56902
+ constraints: [property, days],
56903
+ options: validationOptions,
56904
+ validator: {
56905
+ validate(value, args) {
56906
+ const related = args.object[property];
56907
+ if (!value || !related) return true;
56908
+ return (new Date(String(value)).getTime() - new Date(String(related)).getTime()) / DAY_MS <= days;
56909
+ }
56910
+ }
56911
+ });
56912
+ };
56913
+ }
56666
56914
  var SearchDateRangeDto = class {
56667
56915
  from;
56668
56916
  to;
@@ -56676,6 +56924,7 @@ __decorateClass([
56676
56924
  __decorateClass([
56677
56925
  IsNotEmpty484({ message: "La fecha hasta es requerida" }),
56678
56926
  IsDateString({}, { message: "La fecha hasta no es v\xE1lida" }),
56927
+ MaxDaysFrom("from", MAX_SEARCH_RANGE_DAYS, { message: `El rango no puede superar las 2 semanas (${MAX_SEARCH_RANGE_DAYS} d\xEDas)` }),
56679
56928
  Expose868()
56680
56929
  ], SearchDateRangeDto.prototype, "to", 2);
56681
56930
 
@@ -56685,7 +56934,7 @@ import { IsDefined as IsDefined351, IsNotEmpty as IsNotEmpty485, IsString as IsS
56685
56934
 
56686
56935
  // src/v2/entities/Base.ts
56687
56936
  import { Expose as Expose869 } from "class-transformer";
56688
- import { IsBoolean as IsBoolean84, IsDefined as IsDefined350, IsUUID as IsUUID41 } from "class-validator";
56937
+ import { IsBoolean as IsBoolean85, IsDefined as IsDefined350, IsUUID as IsUUID41 } from "class-validator";
56689
56938
  var BaseEntity = class {
56690
56939
  _id;
56691
56940
  active;
@@ -56697,7 +56946,7 @@ __decorateClass([
56697
56946
  ], BaseEntity.prototype, "_id", 2);
56698
56947
  __decorateClass([
56699
56948
  IsDefined350({ message: 'La propiedad "activo" es obligatoria.' }),
56700
- IsBoolean84({ message: 'La propiedad "activo" debe ser un valor booleano.' }),
56949
+ IsBoolean85({ message: 'La propiedad "activo" debe ser un valor booleano.' }),
56701
56950
  Expose869()
56702
56951
  ], BaseEntity.prototype, "active", 2);
56703
56952
 
@@ -56726,7 +56975,7 @@ __decorateClass([
56726
56975
  ], DelegationEntity.prototype, "name", 2);
56727
56976
 
56728
56977
  // src/v2/entities/User.ts
56729
- import { IsArray as IsArray277, IsBoolean as IsBoolean85, IsDefined as IsDefined352, IsEmail as IsEmail14, IsString as IsString719, IsUUID as IsUUID43, ValidateIf as ValidateIf12, ValidateNested as ValidateNested452 } from "class-validator";
56978
+ import { IsArray as IsArray277, IsBoolean as IsBoolean86, IsDefined as IsDefined352, IsEmail as IsEmail14, IsString as IsString719, IsUUID as IsUUID43, ValidateIf as ValidateIf12, ValidateNested as ValidateNested452 } from "class-validator";
56730
56979
  import { Expose as Expose871, Transform as Transform140, Type as Type525 } from "class-transformer";
56731
56980
  var UserEntity = class extends BaseEntity {
56732
56981
  email;
@@ -56792,7 +57041,7 @@ __decorateClass([
56792
57041
  ], UserEntity.prototype, "delegationIds", 2);
56793
57042
  __decorateClass([
56794
57043
  IsDefined352({ message: 'La propiedad "root" es obligatoria.' }),
56795
- IsBoolean85({ message: 'La propiedad "root" debe ser un valor booleano.' }),
57044
+ IsBoolean86({ message: 'La propiedad "root" debe ser un valor booleano.' }),
56796
57045
  Expose871()
56797
57046
  ], UserEntity.prototype, "root", 2);
56798
57047
  __decorateClass([
@@ -56861,7 +57110,7 @@ __decorateClass([
56861
57110
 
56862
57111
  // src/v2/entities/Company.ts
56863
57112
  import { Expose as Expose874 } from "class-transformer";
56864
- import { IsArray as IsArray279, IsBoolean as IsBoolean86, IsDefined as IsDefined355, IsEmail as IsEmail15, IsEnum as IsEnum68, IsNotEmpty as IsNotEmpty487, IsString as IsString722, IsUUID as IsUUID44 } from "class-validator";
57113
+ import { IsArray as IsArray279, IsBoolean as IsBoolean87, IsDefined as IsDefined355, IsEmail as IsEmail15, IsEnum as IsEnum68, IsNotEmpty as IsNotEmpty487, IsString as IsString722, IsUUID as IsUUID44 } from "class-validator";
56865
57114
  var CompanyEntity = class extends BaseEntity {
56866
57115
  companyType;
56867
57116
  identification;
@@ -56905,7 +57154,7 @@ __decorateClass([
56905
57154
  ], CompanyEntity.prototype, "tradeName", 2);
56906
57155
  __decorateClass([
56907
57156
  IsDefined355({ message: "La propiedad es propia es requerida" }),
56908
- IsBoolean86({ message: "La propiedad es propia debe ser un booleano" }),
57157
+ IsBoolean87({ message: "La propiedad es propia debe ser un booleano" }),
56909
57158
  Expose874()
56910
57159
  ], CompanyEntity.prototype, "isOwn", 2);
56911
57160
  __decorateClass([
@@ -57009,7 +57258,7 @@ __decorateClass([
57009
57258
 
57010
57259
  // src/v2/entities/ThemeConfigUser.ts
57011
57260
  import { Expose as Expose877, Type as Type527 } from "class-transformer";
57012
- import { IsNumber as IsNumber549, IsString as IsString725, ValidateNested as ValidateNested454, IsArray as IsArray281, IsOptional as IsOptional95, IsDefined as IsDefined356, IsBoolean as IsBoolean87 } from "class-validator";
57261
+ import { IsNumber as IsNumber549, IsString as IsString725, ValidateNested as ValidateNested454, IsArray as IsArray281, IsOptional as IsOptional95, IsDefined as IsDefined356, IsBoolean as IsBoolean88 } from "class-validator";
57013
57262
  var ThemeConfigUserEntity = class {
57014
57263
  _id;
57015
57264
  active = true;
@@ -57026,7 +57275,7 @@ __decorateClass([
57026
57275
  ], ThemeConfigUserEntity.prototype, "_id", 2);
57027
57276
  __decorateClass([
57028
57277
  IsDefined356({ message: 'La propiedad "activo" es obligatoria.' }),
57029
- IsBoolean87({ message: 'La propiedad "activo" debe ser un valor booleano.' }),
57278
+ IsBoolean88({ message: 'La propiedad "activo" debe ser un valor booleano.' }),
57030
57279
  Expose877()
57031
57280
  ], ThemeConfigUserEntity.prototype, "active", 2);
57032
57281
  __decorateClass([
@@ -57060,7 +57309,7 @@ __decorateClass([
57060
57309
  ], ThemeConfigUserEntity.prototype, "Favoritos", 2);
57061
57310
 
57062
57311
  // src/v2/utils/validateCustom.ts
57063
- import { plainToInstance as plainToInstance4 } from "class-transformer";
57312
+ import { plainToInstance as plainToInstance5 } from "class-transformer";
57064
57313
  import { validate as validate3 } from "class-validator";
57065
57314
 
57066
57315
  // src/v2/utils/getFirstError.ts
@@ -57102,7 +57351,7 @@ function removeUndefined(obj) {
57102
57351
 
57103
57352
  // src/v2/utils/validateCustom.ts
57104
57353
  async function validateCustom(plain, cls, UnprocessableEntityException, groups) {
57105
- const instance = plainToInstance4(cls, plain, { excludeExtraneousValues: true, groups });
57354
+ const instance = plainToInstance5(cls, plain, { excludeExtraneousValues: true, groups });
57106
57355
  const errors = await validate3(instance, { groups });
57107
57356
  if (errors.length) {
57108
57357
  const msg = getFirstError(errors);
@@ -57112,14 +57361,14 @@ async function validateCustom(plain, cls, UnprocessableEntityException, groups)
57112
57361
  }
57113
57362
 
57114
57363
  // src/v2/middlewares/validateRequestBody.ts
57115
- import { plainToInstance as plainToInstance5 } from "class-transformer";
57364
+ import { plainToInstance as plainToInstance6 } from "class-transformer";
57116
57365
  import { validate as validate4 } from "class-validator";
57117
57366
  async function validateRequestBody({ dtoClass, BadRequestException, groups }, req, _res, next) {
57118
57367
  try {
57119
57368
  if (Array.isArray(req.body)) {
57120
57369
  const newBody = [];
57121
57370
  for (const element of req.body) {
57122
- const dtoInstance2 = plainToInstance5(dtoClass, element, { excludeExtraneousValues: true, groups });
57371
+ const dtoInstance2 = plainToInstance6(dtoClass, element, { excludeExtraneousValues: true, groups });
57123
57372
  const errors2 = await validate4(dtoInstance2, { groups });
57124
57373
  if (errors2.length > 0) {
57125
57374
  const firstError = getFirstError(errors2);
@@ -57130,7 +57379,7 @@ async function validateRequestBody({ dtoClass, BadRequestException, groups }, re
57130
57379
  req.body = newBody;
57131
57380
  return next();
57132
57381
  }
57133
- const dtoInstance = plainToInstance5(dtoClass, req.body, { excludeExtraneousValues: true, groups });
57382
+ const dtoInstance = plainToInstance6(dtoClass, req.body, { excludeExtraneousValues: true, groups });
57134
57383
  const errors = await validate4(dtoInstance, { groups });
57135
57384
  if (errors.length > 0) {
57136
57385
  const firstError = getFirstError(errors);
@@ -57583,6 +57832,7 @@ export {
57583
57832
  LogRegisterDTO,
57584
57833
  LoginDto,
57585
57834
  LoteDTO,
57835
+ MAX_SEARCH_RANGE_DAYS,
57586
57836
  MOAltasNVTDTO,
57587
57837
  MOBaremoDTO,
57588
57838
  MOChileVigenciaDTO,
@@ -58077,6 +58327,7 @@ export {
58077
58327
  ZonasDTO,
58078
58328
  convertStringsToDates,
58079
58329
  convertTypeNumber,
58330
+ entityToMongoJsonSchema,
58080
58331
  enumToArray,
58081
58332
  getFirstError,
58082
58333
  hydrate,
package/package.json CHANGED
@@ -1,39 +1,40 @@
1
- {
2
- "name": "sigo-entities",
3
- "version": "1.2.539",
4
- "description": "Desarrollo de modelos de datos SIGO",
5
- "main": "dist/index.js",
6
- "module": "dist/index.mjs",
7
- "types": "dist/index.d.ts",
8
- "scripts": {
9
- "build": "tsup && tsc-alias",
10
- "prepare": "npm run build",
11
- "test": "node --test \"__tests__/*.test.mjs\"",
12
- "gen-dto": "ts-node ./generateDtos.ts"
13
- },
14
- "repository": {
15
- "type": "git",
16
- "url": "git@github.com-trabajo:GRUPOCOBRA/sigo-entities.git"
17
- },
18
- "keywords": [],
19
- "author": "usuario088",
20
- "license": "ISC",
21
- "devDependencies": {
22
- "@types/express": "^5.0.1",
23
- "ts-morph": "^28.0.0",
24
- "tsc-alias": "^1.8.15",
25
- "tsconfig-paths": "^4.2.0",
26
- "tsup": "^8.1.0",
27
- "typescript": "^5.4.5"
28
- },
29
- "dependencies": {
30
- "class-transformer": "^0.5.1",
31
- "class-validator": "^0.15.1"
32
- },
33
- "peerDependencies": {
34
- "reflect-metadata": "^0.2.2"
35
- },
36
- "overrides": {
37
- "esbuild": "^0.28.0"
38
- }
39
- }
1
+ {
2
+ "name": "sigo-entities",
3
+ "version": "1.2.541",
4
+ "description": "Desarrollo de modelos de datos SIGO",
5
+ "main": "dist/index.js",
6
+ "module": "dist/index.mjs",
7
+ "types": "dist/index.d.ts",
8
+ "scripts": {
9
+ "build": "tsup && tsc-alias",
10
+ "prepare": "npm run build",
11
+ "test": "node --test \"__tests__/*.test.mjs\"",
12
+ "gen-dto": "ts-node ./generateDtos.ts"
13
+ },
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "git@github.com-trabajo:GRUPOCOBRA/sigo-entities.git"
17
+ },
18
+ "keywords": [],
19
+ "author": "usuario088",
20
+ "license": "ISC",
21
+ "devDependencies": {
22
+ "@types/express": "^5.0.1",
23
+ "ts-morph": "^28.0.0",
24
+ "tsc-alias": "^1.8.15",
25
+ "tsconfig-paths": "^4.2.0",
26
+ "tsup": "^8.1.0",
27
+ "typescript": "^5.4.5"
28
+ },
29
+ "dependencies": {
30
+ "class-transformer": "^0.5.1",
31
+ "class-validator": "^0.15.1",
32
+ "sigo-package": "^1.2.184"
33
+ },
34
+ "peerDependencies": {
35
+ "reflect-metadata": "^0.2.2"
36
+ },
37
+ "overrides": {
38
+ "esbuild": "^0.28.0"
39
+ }
40
+ }
@@ -1,8 +0,0 @@
1
- {
2
- "permissions": {
3
- "allow": [
4
- "Read(//c/Users/Antonio/AppData/Local/Temp/claude/c--Users-Antonio-Documents-github-sigo-entities/2f99285a-2809-4d8e-971e-ccaacf3cfec7/scratchpad/**)",
5
- "Bash(bash build.sh)"
6
- ]
7
- }
8
- }