@nomalism-com/types 0.45.68 → 0.45.70

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 CHANGED
@@ -5812,85 +5812,89 @@ var printLocationsQuery = joi118.object({
5812
5812
  // src/modules/user/timeSheet/interfaces.ts
5813
5813
  var interfaces_exports61 = {};
5814
5814
  __export(interfaces_exports61, {
5815
- IClockTypeEnum: () => IClockTypeEnum,
5816
- IRegistryTypeEnum: () => IRegistryTypeEnum,
5817
- ITimesheetStateEnum: () => ITimesheetStateEnum,
5815
+ ITimeSheetRecordTypeEnum: () => ITimeSheetRecordTypeEnum,
5816
+ ITimeSheetRegistryTypeEnum: () => ITimeSheetRegistryTypeEnum,
5818
5817
  Route: () => Route131,
5819
- clockTypes: () => clockTypes,
5820
- registryTypes: () => registryTypes,
5821
- timesheetStates: () => timesheetStates
5818
+ timeSheetRecordTypes: () => timeSheetRecordTypes,
5819
+ timeSheetRegistryTypes: () => timeSheetRegistryTypes
5822
5820
  });
5823
5821
  var Route131 = "time_sheet";
5824
- var IClockTypeEnum = {
5822
+ var ITimeSheetRecordTypeEnum = {
5825
5823
  ENTRY: "ENTRY",
5826
- EXIT: "EXIT"
5824
+ EXIT: "EXIT",
5825
+ CREDIT: "CREDIT",
5826
+ DEBIT: "DEBIT"
5827
5827
  };
5828
- var clockTypes = Object.keys(IClockTypeEnum);
5829
- var IRegistryTypeEnum = {
5828
+ var timeSheetRecordTypes = Object.values(ITimeSheetRecordTypeEnum);
5829
+ var ITimeSheetRegistryTypeEnum = {
5830
5830
  AUTOMATIC: "AUTOMATIC",
5831
5831
  MANUAL: "MANUAL"
5832
5832
  };
5833
- var registryTypes = Object.keys(IRegistryTypeEnum);
5834
- var ITimesheetStateEnum = {
5835
- CONFIRMED: "CONFIRMED",
5836
- PENDING: "PENDING",
5837
- ERROR: "ERROR"
5838
- };
5839
- var timesheetStates = Object.keys(ITimesheetStateEnum);
5833
+ var timeSheetRegistryTypes = Object.values(ITimeSheetRegistryTypeEnum);
5840
5834
 
5841
5835
  // src/modules/user/timeSheet/route.schema.ts
5842
5836
  var route_schema_exports118 = {};
5843
5837
  __export(route_schema_exports118, {
5844
5838
  createBody: () => createBody65,
5839
+ dailySummaryQuery: () => dailySummaryQuery,
5840
+ findByDateQuery: () => findByDateQuery,
5841
+ findQuery: () => findQuery34,
5845
5842
  updateBody: () => updateBody56
5846
5843
  });
5847
5844
  import joi119 from "joi";
5848
- var clockSchema = joi119.object({
5849
- id: joi119.string().uuid(),
5850
- time: joi119.date().required(),
5851
- type: joi119.string().valid(...Object.values(IClockTypeEnum)).required(),
5852
- registry_type: joi119.string().valid(...Object.values(IRegistryTypeEnum)).required(),
5853
- note: joi119.string().allow("", null).optional(),
5854
- created_by: joi119.string().uuid().required(),
5855
- // 👈 Adicionado para auditoria nos updates
5856
- updated_by: joi119.string().uuid().required()
5857
- // 👈 Adicionado para auditoria nos updates
5858
- });
5859
5845
  var createBodyKeys64 = {
5860
- date: joi119.date().required(),
5861
5846
  user_id: joi119.string().uuid().required(),
5862
- total_worked: joi119.number().integer().min(0),
5863
- balance: joi119.number().integer(),
5864
- state: joi119.string().valid(...Object.values(ITimesheetStateEnum)),
5847
+ type: joi119.string().valid("ENTRY", "EXIT", "CREDIT", "DEBIT").required(),
5848
+ time: joi119.when("type", {
5849
+ is: joi119.string().valid("ENTRY", "EXIT"),
5850
+ then: joi119.date().required(),
5851
+ otherwise: joi119.date().optional().allow(null)
5852
+ }),
5853
+ minutes: joi119.when("type", {
5854
+ is: joi119.string().valid("CREDIT", "DEBIT"),
5855
+ then: joi119.number().integer().min(1).required(),
5856
+ otherwise: joi119.number().optional().allow(null)
5857
+ }),
5858
+ registry_type: joi119.string().valid("AUTOMATIC", "MANUAL").default("MANUAL").optional(),
5859
+ note: joi119.string().allow("", null).optional(),
5865
5860
  created_by: joi119.string().uuid().required(),
5866
- // 👈 Adicionado na raiz do dia
5867
- updated_by: joi119.string().uuid().required(),
5868
- // 👈 Adicionado na raiz do dia
5869
- // Objeto opcional para quando se cria o dia já com a primeira picagem
5870
- clock: joi119.object({
5871
- time: joi119.date(),
5872
- type: joi119.string().valid(...Object.values(IClockTypeEnum)).required(),
5873
- registry_type: joi119.string().valid(...Object.values(IRegistryTypeEnum)).required(),
5874
- note: joi119.string().allow("", null).optional(),
5875
- created_by: joi119.string().uuid().required(),
5876
- // 👈 Adicionado no clock interno
5877
- updated_by: joi119.string().uuid().required()
5878
- // 👈 Adicionado no clock interno
5879
- })
5861
+ updated_by: joi119.string().uuid().required()
5880
5862
  };
5881
5863
  var createBody65 = joi119.object().keys(createBodyKeys64).messages(messages);
5882
5864
  var updateBodyKeys54 = {
5883
- total_worked: joi119.number().integer().min(0),
5884
- balance: joi119.number().integer(),
5885
- state: joi119.string().valid(...Object.values(ITimesheetStateEnum)),
5886
- created_by: joi119.string().uuid().optional(),
5887
- // 💡 Opcional no update para manter o original se quiseres
5865
+ type: joi119.string().valid("ENTRY", "EXIT", "CREDIT", "DEBIT").optional(),
5866
+ time: joi119.when("type", {
5867
+ is: joi119.string().valid("ENTRY", "EXIT"),
5868
+ then: joi119.date().optional(),
5869
+ otherwise: joi119.date().optional().allow(null)
5870
+ }),
5871
+ minutes: joi119.when("type", {
5872
+ is: joi119.string().valid("CREDIT", "DEBIT"),
5873
+ then: joi119.number().integer().min(1).optional(),
5874
+ otherwise: joi119.number().optional().allow(null)
5875
+ }),
5876
+ note: joi119.string().allow("", null).optional(),
5888
5877
  updated_by: joi119.string().uuid().required(),
5889
- // 👈 Obrigatório no update do dia
5890
- // Array de picagens enviado pelo formulário de edição
5891
- clocks: joi119.array().items(clockSchema)
5878
+ updated_at: joi119.date().optional()
5892
5879
  };
5893
5880
  var updateBody56 = joi119.object().keys(updateBodyKeys54).messages(messages);
5881
+ var findQueryKeys32 = {
5882
+ user_id: joi119.string().uuid().optional(),
5883
+ start_date: joi119.date().optional(),
5884
+ end_date: joi119.date().optional()
5885
+ };
5886
+ var findQuery34 = joi119.object().keys(findQueryKeys32).messages(messages);
5887
+ var findByDateQueryKeys = {
5888
+ user_id: joi119.string().uuid().required(),
5889
+ date: joi119.string().isoDate().required()
5890
+ };
5891
+ var findByDateQuery = joi119.object().keys(findByDateQueryKeys).messages(messages);
5892
+ var dailySummaryQueryKeys = {
5893
+ user_id: joi119.string().uuid().required(),
5894
+ start_date: joi119.string().isoDate().required(),
5895
+ end_date: joi119.string().isoDate().required()
5896
+ };
5897
+ var dailySummaryQuery = joi119.object().keys(dailySummaryQueryKeys).messages(messages);
5894
5898
 
5895
5899
  // src/modules/document/CAT/interfaces.ts
5896
5900
  var interfaces_exports62 = {};
package/dist/index.js CHANGED
@@ -5812,85 +5812,89 @@ var printLocationsQuery = joi118.object({
5812
5812
  // src/modules/user/timeSheet/interfaces.ts
5813
5813
  var interfaces_exports61 = {};
5814
5814
  __export(interfaces_exports61, {
5815
- IClockTypeEnum: () => IClockTypeEnum,
5816
- IRegistryTypeEnum: () => IRegistryTypeEnum,
5817
- ITimesheetStateEnum: () => ITimesheetStateEnum,
5815
+ ITimeSheetRecordTypeEnum: () => ITimeSheetRecordTypeEnum,
5816
+ ITimeSheetRegistryTypeEnum: () => ITimeSheetRegistryTypeEnum,
5818
5817
  Route: () => Route131,
5819
- clockTypes: () => clockTypes,
5820
- registryTypes: () => registryTypes,
5821
- timesheetStates: () => timesheetStates
5818
+ timeSheetRecordTypes: () => timeSheetRecordTypes,
5819
+ timeSheetRegistryTypes: () => timeSheetRegistryTypes
5822
5820
  });
5823
5821
  var Route131 = "time_sheet";
5824
- var IClockTypeEnum = {
5822
+ var ITimeSheetRecordTypeEnum = {
5825
5823
  ENTRY: "ENTRY",
5826
- EXIT: "EXIT"
5824
+ EXIT: "EXIT",
5825
+ CREDIT: "CREDIT",
5826
+ DEBIT: "DEBIT"
5827
5827
  };
5828
- var clockTypes = Object.keys(IClockTypeEnum);
5829
- var IRegistryTypeEnum = {
5828
+ var timeSheetRecordTypes = Object.values(ITimeSheetRecordTypeEnum);
5829
+ var ITimeSheetRegistryTypeEnum = {
5830
5830
  AUTOMATIC: "AUTOMATIC",
5831
5831
  MANUAL: "MANUAL"
5832
5832
  };
5833
- var registryTypes = Object.keys(IRegistryTypeEnum);
5834
- var ITimesheetStateEnum = {
5835
- CONFIRMED: "CONFIRMED",
5836
- PENDING: "PENDING",
5837
- ERROR: "ERROR"
5838
- };
5839
- var timesheetStates = Object.keys(ITimesheetStateEnum);
5833
+ var timeSheetRegistryTypes = Object.values(ITimeSheetRegistryTypeEnum);
5840
5834
 
5841
5835
  // src/modules/user/timeSheet/route.schema.ts
5842
5836
  var route_schema_exports118 = {};
5843
5837
  __export(route_schema_exports118, {
5844
5838
  createBody: () => createBody65,
5839
+ dailySummaryQuery: () => dailySummaryQuery,
5840
+ findByDateQuery: () => findByDateQuery,
5841
+ findQuery: () => findQuery34,
5845
5842
  updateBody: () => updateBody56
5846
5843
  });
5847
5844
  import joi119 from "joi";
5848
- var clockSchema = joi119.object({
5849
- id: joi119.string().uuid(),
5850
- time: joi119.date().required(),
5851
- type: joi119.string().valid(...Object.values(IClockTypeEnum)).required(),
5852
- registry_type: joi119.string().valid(...Object.values(IRegistryTypeEnum)).required(),
5853
- note: joi119.string().allow("", null).optional(),
5854
- created_by: joi119.string().uuid().required(),
5855
- // 👈 Adicionado para auditoria nos updates
5856
- updated_by: joi119.string().uuid().required()
5857
- // 👈 Adicionado para auditoria nos updates
5858
- });
5859
5845
  var createBodyKeys64 = {
5860
- date: joi119.date().required(),
5861
5846
  user_id: joi119.string().uuid().required(),
5862
- total_worked: joi119.number().integer().min(0),
5863
- balance: joi119.number().integer(),
5864
- state: joi119.string().valid(...Object.values(ITimesheetStateEnum)),
5847
+ type: joi119.string().valid("ENTRY", "EXIT", "CREDIT", "DEBIT").required(),
5848
+ time: joi119.when("type", {
5849
+ is: joi119.string().valid("ENTRY", "EXIT"),
5850
+ then: joi119.date().required(),
5851
+ otherwise: joi119.date().optional().allow(null)
5852
+ }),
5853
+ minutes: joi119.when("type", {
5854
+ is: joi119.string().valid("CREDIT", "DEBIT"),
5855
+ then: joi119.number().integer().min(1).required(),
5856
+ otherwise: joi119.number().optional().allow(null)
5857
+ }),
5858
+ registry_type: joi119.string().valid("AUTOMATIC", "MANUAL").default("MANUAL").optional(),
5859
+ note: joi119.string().allow("", null).optional(),
5865
5860
  created_by: joi119.string().uuid().required(),
5866
- // 👈 Adicionado na raiz do dia
5867
- updated_by: joi119.string().uuid().required(),
5868
- // 👈 Adicionado na raiz do dia
5869
- // Objeto opcional para quando se cria o dia já com a primeira picagem
5870
- clock: joi119.object({
5871
- time: joi119.date(),
5872
- type: joi119.string().valid(...Object.values(IClockTypeEnum)).required(),
5873
- registry_type: joi119.string().valid(...Object.values(IRegistryTypeEnum)).required(),
5874
- note: joi119.string().allow("", null).optional(),
5875
- created_by: joi119.string().uuid().required(),
5876
- // 👈 Adicionado no clock interno
5877
- updated_by: joi119.string().uuid().required()
5878
- // 👈 Adicionado no clock interno
5879
- })
5861
+ updated_by: joi119.string().uuid().required()
5880
5862
  };
5881
5863
  var createBody65 = joi119.object().keys(createBodyKeys64).messages(messages);
5882
5864
  var updateBodyKeys54 = {
5883
- total_worked: joi119.number().integer().min(0),
5884
- balance: joi119.number().integer(),
5885
- state: joi119.string().valid(...Object.values(ITimesheetStateEnum)),
5886
- created_by: joi119.string().uuid().optional(),
5887
- // 💡 Opcional no update para manter o original se quiseres
5865
+ type: joi119.string().valid("ENTRY", "EXIT", "CREDIT", "DEBIT").optional(),
5866
+ time: joi119.when("type", {
5867
+ is: joi119.string().valid("ENTRY", "EXIT"),
5868
+ then: joi119.date().optional(),
5869
+ otherwise: joi119.date().optional().allow(null)
5870
+ }),
5871
+ minutes: joi119.when("type", {
5872
+ is: joi119.string().valid("CREDIT", "DEBIT"),
5873
+ then: joi119.number().integer().min(1).optional(),
5874
+ otherwise: joi119.number().optional().allow(null)
5875
+ }),
5876
+ note: joi119.string().allow("", null).optional(),
5888
5877
  updated_by: joi119.string().uuid().required(),
5889
- // 👈 Obrigatório no update do dia
5890
- // Array de picagens enviado pelo formulário de edição
5891
- clocks: joi119.array().items(clockSchema)
5878
+ updated_at: joi119.date().optional()
5892
5879
  };
5893
5880
  var updateBody56 = joi119.object().keys(updateBodyKeys54).messages(messages);
5881
+ var findQueryKeys32 = {
5882
+ user_id: joi119.string().uuid().optional(),
5883
+ start_date: joi119.date().optional(),
5884
+ end_date: joi119.date().optional()
5885
+ };
5886
+ var findQuery34 = joi119.object().keys(findQueryKeys32).messages(messages);
5887
+ var findByDateQueryKeys = {
5888
+ user_id: joi119.string().uuid().required(),
5889
+ date: joi119.string().isoDate().required()
5890
+ };
5891
+ var findByDateQuery = joi119.object().keys(findByDateQueryKeys).messages(messages);
5892
+ var dailySummaryQueryKeys = {
5893
+ user_id: joi119.string().uuid().required(),
5894
+ start_date: joi119.string().isoDate().required(),
5895
+ end_date: joi119.string().isoDate().required()
5896
+ };
5897
+ var dailySummaryQuery = joi119.object().keys(dailySummaryQueryKeys).messages(messages);
5894
5898
 
5895
5899
  // src/modules/document/CAT/interfaces.ts
5896
5900
  var interfaces_exports62 = {};
@@ -1,73 +1,52 @@
1
1
  import * as IShared from '../../../shared/interface';
2
- import { TimeSheetDay, TimeSheetClock } from '../../../shared/entities/user';
3
- export type Entity = TimeSheetDay & {
4
- clocks: TimeSheetClock[];
5
- };
2
+ import { TimeSheet } from '../../../shared/entities/user';
3
+ export type Entity = TimeSheet;
6
4
  export declare const Route = "time_sheet";
7
- export declare const IClockTypeEnum: {
8
- ENTRY: 'ENTRY';
9
- EXIT: 'EXIT';
10
- };
11
- export type IClockType = (typeof IClockTypeEnum)[keyof typeof IClockTypeEnum];
12
- export declare const clockTypes: string[];
13
- export declare const IRegistryTypeEnum: {
14
- AUTOMATIC: 'AUTOMATIC';
15
- MANUAL: 'MANUAL';
5
+ export declare const ITimeSheetRecordTypeEnum: {
6
+ readonly ENTRY: "ENTRY";
7
+ readonly EXIT: "EXIT";
8
+ readonly CREDIT: "CREDIT";
9
+ readonly DEBIT: "DEBIT";
16
10
  };
17
- export type IRegistryType = (typeof IRegistryTypeEnum)[keyof typeof IRegistryTypeEnum];
18
- export declare const registryTypes: string[];
19
- export declare const ITimesheetStateEnum: {
20
- CONFIRMED: 'CONFIRMED';
21
- PENDING: 'PENDING';
22
- ERROR: 'ERROR';
11
+ export type ITimeSheetRecordType = (typeof ITimeSheetRecordTypeEnum)[keyof typeof ITimeSheetRecordTypeEnum];
12
+ export declare const timeSheetRecordTypes: ("ENTRY" | "EXIT" | "CREDIT" | "DEBIT")[];
13
+ export declare const ITimeSheetRegistryTypeEnum: {
14
+ readonly AUTOMATIC: "AUTOMATIC";
15
+ readonly MANUAL: "MANUAL";
23
16
  };
24
- export type ITimesheetState = (typeof ITimesheetStateEnum)[keyof typeof ITimesheetStateEnum];
25
- export declare const timesheetStates: string[];
17
+ export type ITimeSheetRegistryType = (typeof ITimeSheetRegistryTypeEnum)[keyof typeof ITimeSheetRegistryTypeEnum];
18
+ export declare const timeSheetRegistryTypes: ("AUTOMATIC" | "MANUAL")[];
26
19
  export interface IFindRequest {
27
20
  user_id?: string;
28
21
  start_date?: string;
29
22
  end_date?: string;
30
- state?: ITimesheetState;
31
23
  }
32
- export interface ICreateRequest {
33
- date: Date;
24
+ export interface IFindByDateRequest {
34
25
  user_id: string;
35
- total_worked?: number;
36
- balance?: number;
37
- state?: ITimesheetState;
38
- created_by: string;
39
- updated_by: string;
40
- clock?: {
41
- time?: Date;
42
- type: IClockType;
43
- registry_type: IRegistryType;
44
- note?: string | null;
45
- created_by: string;
46
- updated_by: string;
47
- };
26
+ date: string;
48
27
  }
49
- export interface IUpdateRequest {
50
- total_worked?: number;
51
- balance?: number;
52
- state?: ITimesheetState;
53
- created_by?: string;
54
- updated_by: string;
55
- clocks?: {
56
- id?: string;
57
- time: Date;
58
- type: IClockType;
59
- registry_type: IRegistryType;
60
- note?: string | null;
61
- created_by: string;
62
- updated_by: string;
63
- }[];
28
+ export interface IDailySummaryRequest {
29
+ user_id: string;
30
+ start_date: string;
31
+ end_date: string;
32
+ }
33
+ export interface IDailySummaryResponse {
34
+ user_id: string;
35
+ date: string;
36
+ total_worked: number;
37
+ balance: number;
38
+ record_count: number;
64
39
  }
40
+ export type ICreateRequest = Omit<Entity, 'id' | 'created_at' | 'updated_at'>;
41
+ export type IUpdateRequest = Partial<Pick<Entity, 'type' | 'time' | 'minutes' | 'note' | 'updated_by' | 'updated_at'>>;
65
42
  export interface IRepository {
66
43
  find(filters?: IFindRequest): Promise<Entity[]>;
67
44
  findById(id: string): Promise<Entity | null>;
68
45
  create(data: ICreateRequest): Promise<Entity>;
69
46
  update(selector: IShared.IFindByIdRequest, data: IUpdateRequest): Promise<Entity | null>;
70
47
  deleteOne(selector: IShared.IFindByIdRequest): Promise<Entity | null>;
48
+ findByUserAndDate(filters: IFindByDateRequest): Promise<Entity[]>;
49
+ getDailySummary(filters: IDailySummaryRequest): Promise<IDailySummaryResponse[]>;
71
50
  }
72
51
  export type IController = IShared.IEntityWithUserToken<IRepository>;
73
52
  export type IApi = Omit<IRepository, 'findById'>;
@@ -1,3 +1,6 @@
1
1
  import joi from 'joi';
2
2
  export declare const createBody: joi.ObjectSchema<any>;
3
3
  export declare const updateBody: joi.ObjectSchema<any>;
4
+ export declare const findQuery: joi.ObjectSchema<any>;
5
+ export declare const findByDateQuery: joi.ObjectSchema<any>;
6
+ export declare const dailySummaryQuery: joi.ObjectSchema<any>;
@@ -1,6 +1,6 @@
1
1
  import { IPaymentMethodsSaftCodeEnum } from '../../modules/user/paymentMethods/interfaces';
2
2
  import type { SystemModuleEnum } from '../../modules/user/systemModule/interface';
3
- import { IClockType, IRegistryType, ITimesheetState } from '../../modules/user/timeSheet/interfaces';
3
+ import { ITimeSheetRecordType, ITimeSheetRegistryType } from '../../modules/user/timeSheet/interfaces';
4
4
  /**
5
5
  * Model Users
6
6
  *
@@ -483,25 +483,14 @@ export type SystemModule = {
483
483
  * Model TimeSheet
484
484
  *
485
485
  */
486
- export interface TimeSheetDay {
486
+ export interface TimeSheet {
487
487
  id: string;
488
- date: Date;
489
- total_worked: number;
490
- balance: number;
491
488
  user_id: string;
492
- state: ITimesheetState;
493
- created_at: Date;
494
- updated_at: Date;
495
- created_by: string;
496
- updated_by: string;
497
- }
498
- export interface TimeSheetClock {
499
- id: string;
500
- timesheet_day_id: string;
501
- time: Date;
502
- type: IClockType;
503
- registry_type: IRegistryType;
504
- note: string | null;
489
+ type: ITimeSheetRecordType;
490
+ time?: Date;
491
+ minutes?: number;
492
+ registry_type: ITimeSheetRegistryType;
493
+ note?: string;
505
494
  created_at: Date;
506
495
  updated_at: Date;
507
496
  created_by: string;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@nomalism-com/types",
3
3
  "description": "A nomalism package with all necessary types and validations for developing APIs",
4
- "version": "0.45.68",
4
+ "version": "0.45.70",
5
5
  "author": "Nomalism <it.nomalism@gmail.com> (https://nomalism.com/)",
6
6
  "license": "UNLICENSED",
7
7
  "type": "module",
@@ -29,15 +29,15 @@
29
29
  "joi": "^18.2.1"
30
30
  },
31
31
  "devDependencies": {
32
- "@swc/core": "^1.15.40",
33
- "@types/node": "^24.13.1",
32
+ "@swc/core": "^1.15.41",
33
+ "@types/node": "^24.13.2",
34
34
  "@typescript-eslint/eslint-plugin": "^8.61.0",
35
35
  "@typescript-eslint/parser": "^8.61.0",
36
36
  "eslint": "^9.39.4",
37
37
  "eslint-config-prettier": "^10.1.8",
38
38
  "eslint-import-resolver-typescript": "^4.4.5",
39
39
  "eslint-plugin-prettier": "^5.5.6",
40
- "prettier": "^3.8.3",
40
+ "prettier": "^3.8.4",
41
41
  "tsup": "^8.5.1"
42
42
  },
43
43
  "repository": {