@obisey/nest 0.1.3 → 0.1.5

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/fecha.d.ts ADDED
@@ -0,0 +1,15 @@
1
+ import { Dayjs, ConfigType } from 'dayjs';
2
+ import { DurationUnitType, Duration } from 'dayjs/plugin/duration';
3
+ import 'dayjs/locale/es';
4
+ type FechaConfig = {
5
+ year?: number;
6
+ month?: number;
7
+ day?: number;
8
+ hour?: number;
9
+ minute?: number;
10
+ second?: number;
11
+ millisecond?: number;
12
+ };
13
+ export declare function fecha(input?: ConfigType | FechaConfig): Dayjs;
14
+ export declare function duracion(value?: number | Record<string, number> | string, unit?: DurationUnitType): Duration;
15
+ export type { Dayjs, Duration };
package/fecha.js ADDED
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.fecha = fecha;
7
+ exports.duracion = duracion;
8
+ const dayjs_1 = __importDefault(require("dayjs"));
9
+ const utc_1 = __importDefault(require("dayjs/plugin/utc"));
10
+ const advancedFormat_1 = __importDefault(require("dayjs/plugin/advancedFormat"));
11
+ const localizedFormat_1 = __importDefault(require("dayjs/plugin/localizedFormat"));
12
+ const isSameOrAfter_1 = __importDefault(require("dayjs/plugin/isSameOrAfter"));
13
+ const isSameOrBefore_1 = __importDefault(require("dayjs/plugin/isSameOrBefore"));
14
+ const customParseFormat_1 = __importDefault(require("dayjs/plugin/customParseFormat"));
15
+ const duration_1 = __importDefault(require("dayjs/plugin/duration"));
16
+ require("dayjs/locale/es");
17
+ // ────────────────────────────────────────────────────────────────
18
+ // Plugins necesarios para emular la mayor parte de la API Moment
19
+ // ────────────────────────────────────────────────────────────────
20
+ dayjs_1.default.extend(utc_1.default);
21
+ dayjs_1.default.extend(advancedFormat_1.default);
22
+ dayjs_1.default.extend(localizedFormat_1.default);
23
+ dayjs_1.default.extend(isSameOrAfter_1.default);
24
+ dayjs_1.default.extend(isSameOrBefore_1.default);
25
+ dayjs_1.default.extend(customParseFormat_1.default);
26
+ dayjs_1.default.extend(duration_1.default);
27
+ dayjs_1.default.locale('es');
28
+ // Type‑guard para identificar si el argumento es un FechaConfig
29
+ function isFechaConfig(input) {
30
+ return (input &&
31
+ typeof input === 'object' &&
32
+ !(input instanceof Date) &&
33
+ !dayjs_1.default.isDayjs(input) &&
34
+ !Array.isArray(input));
35
+ }
36
+ // ────────────────────────────────────────────────────────────────
37
+ // Factory principal → `fecha()` (≈ `moment()`)
38
+ // ────────────────────────────────────────────────────────────────
39
+ function fecha(input) {
40
+ // Caso especial: objeto estilo moment({ hour: 0 })
41
+ if (isFechaConfig(input)) {
42
+ const now = (0, dayjs_1.default)();
43
+ return now
44
+ .set('year', input.year ?? now.year())
45
+ .set('month', input.month ?? now.month())
46
+ .set('date', input.day ?? now.date())
47
+ .set('hour', input.hour ?? 0)
48
+ .set('minute', input.minute ?? 0)
49
+ .set('second', input.second ?? 0)
50
+ .set('millisecond', input.millisecond ?? 0);
51
+ }
52
+ // Otros tipos compatibles con Day.js
53
+ if (input !== undefined) {
54
+ return (0, dayjs_1.default)(input);
55
+ }
56
+ // Sin argumentos → fecha actual
57
+ return (0, dayjs_1.default)();
58
+ }
59
+ // ────────────────────────────────────────────────────────────────
60
+ // Helper para Duration → `duracion()` (≈ `moment.duration()`)
61
+ // ────────────────────────────────────────────────────────────────
62
+ function duracion(value, unit) {
63
+ // @ts-ignore – la definición global de duration se añade por el plugin
64
+ return dayjs_1.default.duration(value, unit);
65
+ }
package/index.d.ts CHANGED
@@ -6,4 +6,8 @@ export * from './prototipos/utils/keyInterface';
6
6
  export * from './prototipos/utils/cifrado';
7
7
  export * from './prototipos/utils/cachear';
8
8
  export * from './prototipos/utils/activarRedis';
9
+ export * from './prototipos/utils/formarInclude';
10
+ export * from './prototipos/utils/formarorder';
11
+ export * from './prototipos/utils/formarwhere';
9
12
  export * from './types';
13
+ export * from './fecha';
package/index.js CHANGED
@@ -23,4 +23,8 @@ __exportStar(require("./prototipos/utils/keyInterface"), exports);
23
23
  __exportStar(require("./prototipos/utils/cifrado"), exports);
24
24
  __exportStar(require("./prototipos/utils/cachear"), exports);
25
25
  __exportStar(require("./prototipos/utils/activarRedis"), exports);
26
+ __exportStar(require("./prototipos/utils/formarInclude"), exports);
27
+ __exportStar(require("./prototipos/utils/formarorder"), exports);
28
+ __exportStar(require("./prototipos/utils/formarwhere"), exports);
26
29
  __exportStar(require("./types"), exports);
30
+ __exportStar(require("./fecha"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@obisey/nest",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "description": "NestJS utilities and base classes by Obisey",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -9,7 +9,6 @@
9
9
  "copy:assets": "cp package.json README.md dist/",
10
10
  "publish:dist": "npm run build && npm run copy:assets && cd dist && npm publish --access public"
11
11
  },
12
-
13
12
  "keywords": [
14
13
  "nestjs",
15
14
  "cache",
@@ -22,8 +21,8 @@
22
21
  "license": "MIT",
23
22
  "peerDependencies": {
24
23
  "lodash": "^4.17.21",
25
- "sequelize-typescript": "^2.1.5",
26
- "sequelize": "^6.32.1"
24
+ "sequelize": "^6.32.1",
25
+ "sequelize-typescript": "^2.1.5"
27
26
  },
28
27
  "devDependencies": {
29
28
  "@nestjs/axios": "^4.0.0",
@@ -31,15 +30,16 @@
31
30
  "@nestjs/common": "^10.3.3",
32
31
  "@nestjs/core": "^10.3.3",
33
32
  "@nestjs/graphql": "^12.1.1",
34
- "typegraphql-nestjs": "^0.7.0",
35
33
  "@types/moment": "^2.11.29",
36
34
  "cache-manager": "^7.0.0",
37
35
  "cache-manager-redis-store": "^3.0.1",
38
36
  "graphql": "^16.11.0",
39
37
  "ioredis": "^5.6.1",
40
38
  "reflect-metadata": "^0.2.2",
39
+ "typegraphql-nestjs": "^0.7.0",
41
40
  "typescript": "^5.4.5"
41
+ },
42
+ "dependencies": {
43
+ "dayjs": "^1.11.13"
42
44
  }
43
-
44
-
45
45
  }