@managemint-solutions/sdk 0.36.0 → 0.38.0
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/README.md +61 -0
- package/dist/client.d.ts +6 -0
- package/dist/client.js +11 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +25 -1
- package/dist/leave/dto.d.ts +76 -0
- package/dist/leave/dto.js +382 -0
- package/dist/leave/index.d.ts +5 -0
- package/dist/leave/index.js +29 -0
- package/dist/leave/leave-entitlements.d.ts +48 -0
- package/dist/leave/leave-entitlements.js +192 -0
- package/dist/leave/leave-requests.d.ts +69 -0
- package/dist/leave/leave-requests.js +184 -0
- package/dist/leave/leave-types.d.ts +21 -0
- package/dist/leave/leave-types.js +95 -0
- package/dist/leave/working-days.d.ts +29 -0
- package/dist/leave/working-days.js +80 -0
- package/dist/permissions/dto.d.ts +12 -0
- package/dist/permissions/dto.js +60 -24
- package/dist/public-holidays/dto.d.ts +4 -0
- package/dist/public-holidays/dto.js +30 -0
- package/dist/public-holidays/index.d.ts +21 -0
- package/dist/public-holidays/index.js +63 -0
- package/dist/users/index.d.ts +2 -0
- package/dist/users/index.js +11 -0
- package/dist/validators.d.ts +8 -0
- package/dist/validators.js +32 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -400,6 +400,67 @@ await service.configs.update('feature_flags', { value: { ...flags.value, timeshe
|
|
|
400
400
|
await service.configs.remove('maintenance'); // hard delete, service role only
|
|
401
401
|
```
|
|
402
402
|
|
|
403
|
+
## Leave
|
|
404
|
+
|
|
405
|
+
The first slice of the HR module: `leave_types`, `leave_entitlements` and `leave_requests`, one
|
|
406
|
+
org-scoped audited resource each on the caller's client. Every date is a calendar date
|
|
407
|
+
(`YYYY-MM-DD`, the columns are `date`), and the DTOs refuse anything else; body fields are
|
|
408
|
+
required keys, with `null` for an empty one. Balances are never stored — an entitlement's
|
|
409
|
+
`days_used` / `days_pending` / `days_remaining` are computed on read from the approved and pending
|
|
410
|
+
requests of that user and type whose start date falls in its period — and a request's `days` is
|
|
411
|
+
a snapshot taken when it was filed, so a holiday added later does not rewrite approved history.
|
|
412
|
+
|
|
413
|
+
The calendar arithmetic is plain exported functions, shared with the api:
|
|
414
|
+
|
|
415
|
+
```ts
|
|
416
|
+
import { countWorkingDays, leavePeriodFor, todayInJohannesburg } from '@managemint-solutions/sdk';
|
|
417
|
+
|
|
418
|
+
const org = await supabase.organizations.get();
|
|
419
|
+
const period = leavePeriodFor('2026-09-21', org.leave_calendar_start_month); // { period_start, period_end }
|
|
420
|
+
const holidays = await supabase.publicHolidays.datesBetween('2026-09-21', '2026-09-25'); // see Public holidays
|
|
421
|
+
const days = countWorkingDays('2026-09-21', '2026-09-25', holidays); // Mon–Fri less holidays; 0.5 for a half day
|
|
422
|
+
const today = todayInJohannesburg(); // the cancel rule's "today"
|
|
423
|
+
```
|
|
424
|
+
|
|
425
|
+
```ts
|
|
426
|
+
const types = await supabase.leaveTypes.list({ active: true });
|
|
427
|
+
const annual = await supabase.leaveTypes.create({ name: 'Annual', description: null, default_days: 15, is_paid: true, requires_approval: true });
|
|
428
|
+
await supabase.leaveTypes.remove(annual.mms_id); // hard delete; 409 once a request or entitlement references it
|
|
429
|
+
|
|
430
|
+
const taken = await supabase.leaveEntitlements.overlaps(userId, annual.mms_id, '2026-01-01', '2026-12-31'); // an entitlement of that type already covers part of the period
|
|
431
|
+
const cover = await supabase.leaveEntitlements.findFor(userId, annual.mms_id, '2026-09-21'); // period + cap, or null = untracked
|
|
432
|
+
const committed = await supabase.leaveRequests.sumDays(userId, annual.mms_id, cover, [LeaveRequestStatus.APPROVED, LeaveRequestStatus.PENDING]);
|
|
433
|
+
const clash = await supabase.leaveRequests.overlaps(userId, '2026-09-21', '2026-09-25');
|
|
434
|
+
|
|
435
|
+
const request = await supabase.leaveRequests.create({ user_id: userId, leave_type_id: annual.mms_id, start_date: '2026-09-21', end_date: '2026-09-25', is_half_day: false, days, reason: null, status: LeaveRequestStatus.PENDING });
|
|
436
|
+
const reviewed = await supabase.leaveRequests.review(request.mms_id, { status: LeaveReviewDecision.APPROVED, reviewed_by: managerId, review_note: null }); // null = no longer pending
|
|
437
|
+
const cancelled = await supabase.leaveRequests.cancel(request.mms_id, userId); // null = already closed
|
|
438
|
+
const mine = await supabase.leaveRequests.list({ ...query, user_id: me }); // one list; user_id narrows it
|
|
439
|
+
const annualOnly = await supabase.leaveRequests.list({ ...query, leave_type_id: annual.mms_id }); // leave_type_id narrows it too
|
|
440
|
+
const reports = await supabase.leaveRequests.list(query, { userIds: [me, ...(await supabase.users.idsManagedBy(me))] });
|
|
441
|
+
```
|
|
442
|
+
|
|
443
|
+
`review`, `cancel` and `update` are compare-and-set writes (`updateWhere`): they land only while
|
|
444
|
+
the request is still in the status they expect and resolve to `null` otherwise, so two reviewers
|
|
445
|
+
cannot both decide the same request. The `leave_requests` table also carries an exclusion
|
|
446
|
+
constraint so two overlapping live requests of one user cannot both be inserted in a race.
|
|
447
|
+
|
|
448
|
+
Notes, additional details and supporting files may attach to leave as well: their `entity`
|
|
449
|
+
accepts `leave_requests` and `leave_entitlements` alongside the CRM entity types.
|
|
450
|
+
|
|
451
|
+
## Public holidays
|
|
452
|
+
|
|
453
|
+
The public-holiday calendar, `public_holidays`, on the caller's client as `supabase.publicHolidays`.
|
|
454
|
+
Global like configs: there is no organization on a row, every signed-in caller reads the same
|
|
455
|
+
list, and only the service role may write — Scott maintains it in Supabase Studio, so the SDK is
|
|
456
|
+
read-only here. Several holidays may share a date; only the ones with `religion` null count as a
|
|
457
|
+
day off for everyone.
|
|
458
|
+
|
|
459
|
+
```ts
|
|
460
|
+
const year = await supabase.publicHolidays.list({ year: 2026 });
|
|
461
|
+
const off = await supabase.publicHolidays.datesBetween('2026-09-21', '2026-09-25'); // Set of religion-neutral dates
|
|
462
|
+
```
|
|
463
|
+
|
|
403
464
|
## Errors
|
|
404
465
|
|
|
405
466
|
Every error the SDK throws is a `SupabaseClientError` carrying the HTTP `status` to respond
|
package/dist/client.d.ts
CHANGED
|
@@ -8,9 +8,11 @@ import { NotesResource } from './notes';
|
|
|
8
8
|
import { NotificationsResource } from './notifications';
|
|
9
9
|
import { BillingReadsResource } from './billing';
|
|
10
10
|
import { InvoicesReadsResource } from './billing/invoices';
|
|
11
|
+
import { LeaveEntitlementsResource, LeaveRequestsResource, LeaveTypesResource } from './leave';
|
|
11
12
|
import { OrganizationsResource } from './organizations';
|
|
12
13
|
import { PermissionsResource } from './permissions';
|
|
13
14
|
import { ProjectsResource } from './projects';
|
|
15
|
+
import { PublicHolidaysResource } from './public-holidays';
|
|
14
16
|
import { StatusesResource } from './statuses';
|
|
15
17
|
import { SupportingFilesResource } from './supporting-files';
|
|
16
18
|
import { TasksResource } from './tasks';
|
|
@@ -56,6 +58,10 @@ export declare class SupabaseClient {
|
|
|
56
58
|
readonly clients: ClientsResource;
|
|
57
59
|
readonly projects: ProjectsResource;
|
|
58
60
|
readonly tasks: TasksResource;
|
|
61
|
+
readonly leaveTypes: LeaveTypesResource;
|
|
62
|
+
readonly publicHolidays: PublicHolidaysResource;
|
|
63
|
+
readonly leaveEntitlements: LeaveEntitlementsResource;
|
|
64
|
+
readonly leaveRequests: LeaveRequestsResource;
|
|
59
65
|
constructor(config: SupabaseClientConfig);
|
|
60
66
|
}
|
|
61
67
|
export declare const createSupabaseClient: (config: SupabaseClientConfig) => SupabaseClient;
|
package/dist/client.js
CHANGED
|
@@ -10,9 +10,11 @@ const notes_1 = require("./notes");
|
|
|
10
10
|
const notifications_1 = require("./notifications");
|
|
11
11
|
const billing_1 = require("./billing");
|
|
12
12
|
const invoices_1 = require("./billing/invoices");
|
|
13
|
+
const leave_1 = require("./leave");
|
|
13
14
|
const organizations_1 = require("./organizations");
|
|
14
15
|
const permissions_1 = require("./permissions");
|
|
15
16
|
const projects_1 = require("./projects");
|
|
17
|
+
const public_holidays_1 = require("./public-holidays");
|
|
16
18
|
const statuses_1 = require("./statuses");
|
|
17
19
|
const supporting_files_1 = require("./supporting-files");
|
|
18
20
|
const tasks_1 = require("./tasks");
|
|
@@ -41,6 +43,10 @@ class SupabaseClient {
|
|
|
41
43
|
clients;
|
|
42
44
|
projects;
|
|
43
45
|
tasks;
|
|
46
|
+
leaveTypes;
|
|
47
|
+
publicHolidays;
|
|
48
|
+
leaveEntitlements;
|
|
49
|
+
leaveRequests;
|
|
44
50
|
constructor(config) {
|
|
45
51
|
this.auth = config.auth;
|
|
46
52
|
this.supabase =
|
|
@@ -61,6 +67,11 @@ class SupabaseClient {
|
|
|
61
67
|
this.clients = new clients_1.ClientsResource(this.supabase, this.auth, this.audit);
|
|
62
68
|
this.projects = new projects_1.ProjectsResource(this.supabase, this.auth, this.audit);
|
|
63
69
|
this.tasks = new tasks_1.TasksResource(this.supabase, this.auth, this.audit);
|
|
70
|
+
this.leaveTypes = new leave_1.LeaveTypesResource(this.supabase, this.auth, this.audit);
|
|
71
|
+
// Global like configs: every signed-in caller reads the same calendar, nobody writes it here.
|
|
72
|
+
this.publicHolidays = new public_holidays_1.PublicHolidaysResource(this.supabase);
|
|
73
|
+
this.leaveEntitlements = new leave_1.LeaveEntitlementsResource(this.supabase, this.auth, this.audit);
|
|
74
|
+
this.leaveRequests = new leave_1.LeaveRequestsResource(this.supabase, this.auth, this.audit);
|
|
64
75
|
}
|
|
65
76
|
}
|
|
66
77
|
exports.SupabaseClient = SupabaseClient;
|
package/dist/index.d.ts
CHANGED
|
@@ -36,4 +36,8 @@ export { GetSupportingFilesDto, SupportingFileIdDto } from './supporting-files';
|
|
|
36
36
|
export { ClientIdDto, CreateClientDto, GetClientsDto, UpdateClientDto } from './clients';
|
|
37
37
|
export { CreateProjectDto, GetProjectsDto, ProjectIdDto, UpdateProjectDto } from './projects';
|
|
38
38
|
export { CreateTaskDto, GetTasksDto, TaskIdDto, UpdateTaskDto } from './tasks';
|
|
39
|
+
export type { CreateLeaveEntitlementInput, CreateLeaveRequestRow, LeaveEntitlementCover, ReviewLeaveRequestRow, UpdateLeaveRequestRow, } from './leave';
|
|
40
|
+
export { CreateLeaveEntitlementDto, CreateLeaveRequestDto, CreateLeaveTypeDto, GetLeaveEntitlementsDto, GetLeaveRequestsDto, GetLeaveTypesDto, LeaveEntitlementIdDto, LeaveRequestIdDto, LeaveTypeIdDto, ReviewLeaveRequestDto, UpdateLeaveEntitlementDto, UpdateLeaveRequestDto, UpdateLeaveTypeDto, } from './leave';
|
|
41
|
+
export { GetPublicHolidaysDto } from './public-holidays';
|
|
42
|
+
export { addOneYearMinusDay, countWorkingDays, isWithinPeriod, leavePeriodFor, todayInJohannesburg, } from './leave';
|
|
39
43
|
export { monthlyTotalMinor } from './pricebooks';
|
package/dist/index.js
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
// to keep. The row and input types they produce and accept are exported for annotations.
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
10
|
exports.UserIdDto = exports.UpdateUserDto = exports.UpdateMyProfileDto = exports.GetUsersQueryDto = exports.AddUserDto = exports.UpdatePermissionsDto = exports.PermissionsResource = exports.UpdateOrganizationDto = exports.CreateOrganizationDto = exports.NotificationIdDto = exports.GetNotificationsDto = exports.NoteIdDto = exports.GetNotesDto = exports.AddNoteDto = exports.UpdateAdditionalDetailsDto = exports.IsAdditionalDetailsValueByType = exports.GetAdditionalDetailsDto = exports.AdditionalDetailsIdDto = exports.AddAdditionalDetailsDto = exports.UpdateStatusDto = exports.StatusIdDto = exports.GetStatusesDto = exports.AddStatusDto = exports.CreateSupportRequestDto = exports.UpdateConfigDto = exports.CreateConfigDto = exports.CreateFeatureRequestDto = exports.InvoiceIdDto = exports.GetInvoicesQueryDto = exports.ReinstateSubscriptionDto = exports.PurchaseModuleDto = exports.PaymentIdDto = exports.InitialPaymentDto = exports.GetPaymentsQueryDto = exports.CancelSubscriptionDto = exports.GetAuditTrailDto = exports.IsNullable = exports.EmptyToNull = exports.SupabaseClientError = exports.createSupabaseServiceClient = exports.SupabaseServiceClient = exports.SignInDto = exports.SendPasswordResetEmailDto = exports.ResetPasswordDto = exports.ExchangeTokenHashDto = exports.ExchangeRefreshTokenDto = exports.createSupabaseAuthClient = exports.SupabaseAuthClient = exports.createSupabaseClient = exports.SupabaseClient = void 0;
|
|
11
|
-
exports.monthlyTotalMinor = exports.UpdateTaskDto = exports.TaskIdDto = exports.GetTasksDto = exports.CreateTaskDto = exports.UpdateProjectDto = exports.ProjectIdDto = exports.GetProjectsDto = exports.CreateProjectDto = exports.UpdateClientDto = exports.GetClientsDto = exports.CreateClientDto = exports.ClientIdDto = exports.SupportingFileIdDto = exports.GetSupportingFilesDto = void 0;
|
|
11
|
+
exports.monthlyTotalMinor = exports.todayInJohannesburg = exports.leavePeriodFor = exports.isWithinPeriod = exports.countWorkingDays = exports.addOneYearMinusDay = exports.GetPublicHolidaysDto = exports.UpdateLeaveTypeDto = exports.UpdateLeaveRequestDto = exports.UpdateLeaveEntitlementDto = exports.ReviewLeaveRequestDto = exports.LeaveTypeIdDto = exports.LeaveRequestIdDto = exports.LeaveEntitlementIdDto = exports.GetLeaveTypesDto = exports.GetLeaveRequestsDto = exports.GetLeaveEntitlementsDto = exports.CreateLeaveTypeDto = exports.CreateLeaveRequestDto = exports.CreateLeaveEntitlementDto = exports.UpdateTaskDto = exports.TaskIdDto = exports.GetTasksDto = exports.CreateTaskDto = exports.UpdateProjectDto = exports.ProjectIdDto = exports.GetProjectsDto = exports.CreateProjectDto = exports.UpdateClientDto = exports.GetClientsDto = exports.CreateClientDto = exports.ClientIdDto = exports.SupportingFileIdDto = exports.GetSupportingFilesDto = void 0;
|
|
12
12
|
var client_1 = require("./client");
|
|
13
13
|
Object.defineProperty(exports, "SupabaseClient", { enumerable: true, get: function () { return client_1.SupabaseClient; } });
|
|
14
14
|
Object.defineProperty(exports, "createSupabaseClient", { enumerable: true, get: function () { return client_1.createSupabaseClient; } });
|
|
@@ -99,5 +99,29 @@ Object.defineProperty(exports, "CreateTaskDto", { enumerable: true, get: functio
|
|
|
99
99
|
Object.defineProperty(exports, "GetTasksDto", { enumerable: true, get: function () { return tasks_1.GetTasksDto; } });
|
|
100
100
|
Object.defineProperty(exports, "TaskIdDto", { enumerable: true, get: function () { return tasks_1.TaskIdDto; } });
|
|
101
101
|
Object.defineProperty(exports, "UpdateTaskDto", { enumerable: true, get: function () { return tasks_1.UpdateTaskDto; } });
|
|
102
|
+
var leave_1 = require("./leave");
|
|
103
|
+
Object.defineProperty(exports, "CreateLeaveEntitlementDto", { enumerable: true, get: function () { return leave_1.CreateLeaveEntitlementDto; } });
|
|
104
|
+
Object.defineProperty(exports, "CreateLeaveRequestDto", { enumerable: true, get: function () { return leave_1.CreateLeaveRequestDto; } });
|
|
105
|
+
Object.defineProperty(exports, "CreateLeaveTypeDto", { enumerable: true, get: function () { return leave_1.CreateLeaveTypeDto; } });
|
|
106
|
+
Object.defineProperty(exports, "GetLeaveEntitlementsDto", { enumerable: true, get: function () { return leave_1.GetLeaveEntitlementsDto; } });
|
|
107
|
+
Object.defineProperty(exports, "GetLeaveRequestsDto", { enumerable: true, get: function () { return leave_1.GetLeaveRequestsDto; } });
|
|
108
|
+
Object.defineProperty(exports, "GetLeaveTypesDto", { enumerable: true, get: function () { return leave_1.GetLeaveTypesDto; } });
|
|
109
|
+
Object.defineProperty(exports, "LeaveEntitlementIdDto", { enumerable: true, get: function () { return leave_1.LeaveEntitlementIdDto; } });
|
|
110
|
+
Object.defineProperty(exports, "LeaveRequestIdDto", { enumerable: true, get: function () { return leave_1.LeaveRequestIdDto; } });
|
|
111
|
+
Object.defineProperty(exports, "LeaveTypeIdDto", { enumerable: true, get: function () { return leave_1.LeaveTypeIdDto; } });
|
|
112
|
+
Object.defineProperty(exports, "ReviewLeaveRequestDto", { enumerable: true, get: function () { return leave_1.ReviewLeaveRequestDto; } });
|
|
113
|
+
Object.defineProperty(exports, "UpdateLeaveEntitlementDto", { enumerable: true, get: function () { return leave_1.UpdateLeaveEntitlementDto; } });
|
|
114
|
+
Object.defineProperty(exports, "UpdateLeaveRequestDto", { enumerable: true, get: function () { return leave_1.UpdateLeaveRequestDto; } });
|
|
115
|
+
Object.defineProperty(exports, "UpdateLeaveTypeDto", { enumerable: true, get: function () { return leave_1.UpdateLeaveTypeDto; } });
|
|
116
|
+
var public_holidays_1 = require("./public-holidays");
|
|
117
|
+
Object.defineProperty(exports, "GetPublicHolidaysDto", { enumerable: true, get: function () { return public_holidays_1.GetPublicHolidaysDto; } });
|
|
118
|
+
// The calendar arithmetic is plain functions, not a resource, so the api counts days with the
|
|
119
|
+
// same code the SDK's tests pin down.
|
|
120
|
+
var leave_2 = require("./leave");
|
|
121
|
+
Object.defineProperty(exports, "addOneYearMinusDay", { enumerable: true, get: function () { return leave_2.addOneYearMinusDay; } });
|
|
122
|
+
Object.defineProperty(exports, "countWorkingDays", { enumerable: true, get: function () { return leave_2.countWorkingDays; } });
|
|
123
|
+
Object.defineProperty(exports, "isWithinPeriod", { enumerable: true, get: function () { return leave_2.isWithinPeriod; } });
|
|
124
|
+
Object.defineProperty(exports, "leavePeriodFor", { enumerable: true, get: function () { return leave_2.leavePeriodFor; } });
|
|
125
|
+
Object.defineProperty(exports, "todayInJohannesburg", { enumerable: true, get: function () { return leave_2.todayInJohannesburg; } });
|
|
102
126
|
var pricebooks_1 = require("./pricebooks");
|
|
103
127
|
Object.defineProperty(exports, "monthlyTotalMinor", { enumerable: true, get: function () { return pricebooks_1.monthlyTotalMinor; } });
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import type { CreateLeaveEntitlementDto as CreateLeaveEntitlementDtoType, CreateLeaveRequestDto as CreateLeaveRequestDtoType, CreateLeaveTypeDto as CreateLeaveTypeDtoType, GetLeaveEntitlementsDto as GetLeaveEntitlementsDtoType, GetLeaveRequestsDto as GetLeaveRequestsDtoType, GetLeaveTypesDto as GetLeaveTypesDtoType, LeaveEntitlementIdDto as LeaveEntitlementIdDtoType, LeaveRequestIdDto as LeaveRequestIdDtoType, LeaveTypeIdDto as LeaveTypeIdDtoType, ReviewLeaveRequestDto as ReviewLeaveRequestDtoType, UpdateLeaveEntitlementDto as UpdateLeaveEntitlementDtoType, UpdateLeaveRequestDto as UpdateLeaveRequestDtoType, UpdateLeaveTypeDto as UpdateLeaveTypeDtoType } from '@managemint-solutions/entities/leave/dto';
|
|
2
|
+
import { LeaveRequestStatus, LeaveReviewDecision } from '@managemint-solutions/entities/leave/enum';
|
|
3
|
+
export declare class LeaveTypeIdDto implements LeaveTypeIdDtoType {
|
|
4
|
+
readonly leaveTypeId: string;
|
|
5
|
+
}
|
|
6
|
+
export declare class GetLeaveTypesDto implements GetLeaveTypesDtoType {
|
|
7
|
+
readonly active?: boolean | null;
|
|
8
|
+
}
|
|
9
|
+
export declare class CreateLeaveTypeDto implements CreateLeaveTypeDtoType {
|
|
10
|
+
readonly name: string;
|
|
11
|
+
readonly description: string | null;
|
|
12
|
+
readonly default_days: number;
|
|
13
|
+
readonly is_paid: boolean;
|
|
14
|
+
readonly requires_approval: boolean;
|
|
15
|
+
}
|
|
16
|
+
export declare class UpdateLeaveTypeDto implements UpdateLeaveTypeDtoType {
|
|
17
|
+
readonly name: string;
|
|
18
|
+
readonly description: string | null;
|
|
19
|
+
readonly default_days: number;
|
|
20
|
+
readonly is_paid: boolean;
|
|
21
|
+
readonly requires_approval: boolean;
|
|
22
|
+
readonly active: boolean;
|
|
23
|
+
}
|
|
24
|
+
export declare class LeaveEntitlementIdDto implements LeaveEntitlementIdDtoType {
|
|
25
|
+
readonly leaveEntitlementId: string;
|
|
26
|
+
}
|
|
27
|
+
export declare class GetLeaveEntitlementsDto implements GetLeaveEntitlementsDtoType {
|
|
28
|
+
readonly page: number;
|
|
29
|
+
readonly page_size: number;
|
|
30
|
+
readonly user_id?: string | null;
|
|
31
|
+
readonly leave_type_id?: string | null;
|
|
32
|
+
readonly as_of?: string | null;
|
|
33
|
+
}
|
|
34
|
+
export declare class CreateLeaveEntitlementDto implements CreateLeaveEntitlementDtoType {
|
|
35
|
+
readonly user_id: string;
|
|
36
|
+
readonly leave_type_id: string;
|
|
37
|
+
readonly days_entitled: number;
|
|
38
|
+
readonly period_start: string | null;
|
|
39
|
+
readonly period_end: string | null;
|
|
40
|
+
readonly notes: string | null;
|
|
41
|
+
}
|
|
42
|
+
export declare class UpdateLeaveEntitlementDto implements UpdateLeaveEntitlementDtoType {
|
|
43
|
+
readonly days_entitled: number;
|
|
44
|
+
readonly period_end: string;
|
|
45
|
+
readonly notes: string | null;
|
|
46
|
+
}
|
|
47
|
+
export declare class LeaveRequestIdDto implements LeaveRequestIdDtoType {
|
|
48
|
+
readonly leaveRequestId: string;
|
|
49
|
+
}
|
|
50
|
+
export declare class GetLeaveRequestsDto implements GetLeaveRequestsDtoType {
|
|
51
|
+
readonly page: number;
|
|
52
|
+
readonly page_size: number;
|
|
53
|
+
readonly user_id?: string | null;
|
|
54
|
+
readonly leave_type_id?: string | null;
|
|
55
|
+
readonly status?: LeaveRequestStatus | null;
|
|
56
|
+
readonly start_date_after?: string | null;
|
|
57
|
+
readonly start_date_before?: string | null;
|
|
58
|
+
}
|
|
59
|
+
export declare class CreateLeaveRequestDto implements CreateLeaveRequestDtoType {
|
|
60
|
+
readonly leave_type_id: string;
|
|
61
|
+
readonly start_date: string;
|
|
62
|
+
readonly end_date: string;
|
|
63
|
+
readonly is_half_day: boolean;
|
|
64
|
+
readonly reason: string | null;
|
|
65
|
+
}
|
|
66
|
+
export declare class UpdateLeaveRequestDto implements UpdateLeaveRequestDtoType {
|
|
67
|
+
readonly leave_type_id: string;
|
|
68
|
+
readonly start_date: string;
|
|
69
|
+
readonly end_date: string;
|
|
70
|
+
readonly is_half_day: boolean;
|
|
71
|
+
readonly reason: string | null;
|
|
72
|
+
}
|
|
73
|
+
export declare class ReviewLeaveRequestDto implements ReviewLeaveRequestDtoType {
|
|
74
|
+
readonly status: LeaveReviewDecision;
|
|
75
|
+
readonly review_note: string | null;
|
|
76
|
+
}
|
|
@@ -0,0 +1,382 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.ReviewLeaveRequestDto = exports.UpdateLeaveRequestDto = exports.CreateLeaveRequestDto = exports.GetLeaveRequestsDto = exports.LeaveRequestIdDto = exports.UpdateLeaveEntitlementDto = exports.CreateLeaveEntitlementDto = exports.GetLeaveEntitlementsDto = exports.LeaveEntitlementIdDto = exports.UpdateLeaveTypeDto = exports.CreateLeaveTypeDto = exports.GetLeaveTypesDto = exports.LeaveTypeIdDto = void 0;
|
|
13
|
+
const class_validator_1 = require("class-validator");
|
|
14
|
+
const class_transformer_1 = require("class-transformer");
|
|
15
|
+
const enum_1 = require("@managemint-solutions/entities/leave/enum");
|
|
16
|
+
const validators_1 = require("../validators");
|
|
17
|
+
// class-validator versions of the shared DTO types from @managemint-solutions/entities.
|
|
18
|
+
// Each class `implements` its entities type so the wire contract cannot drift.
|
|
19
|
+
//
|
|
20
|
+
// Body fields are required: a nullable one carries `@IsNullable()` without `@IsOptional()`,
|
|
21
|
+
// so `null` passes and a missing key fails. Only the query-string filters are optional.
|
|
22
|
+
const Trim = () => (0, class_transformer_1.Transform)(({ value }) => (typeof value === 'string' ? value.trim() : value), { toClassOnly: true });
|
|
23
|
+
/** A query-string tri-state: `'true'`/`'false'` become booleans, anything else is left to fail. */
|
|
24
|
+
const QueryBoolean = () => (0, class_transformer_1.Transform)(({ value }) => (value === 'true' ? true : value === 'false' ? false : value), {
|
|
25
|
+
toClassOnly: true,
|
|
26
|
+
});
|
|
27
|
+
// The users columns (`user_id`) are v4: they carry the GoTrue auth uid the signup trigger copies
|
|
28
|
+
// out of `auth.users.id`, so the table's uuidv7 default never fires. Every other id is v7.
|
|
29
|
+
// ---- Leave types ----
|
|
30
|
+
class LeaveTypeIdDto {
|
|
31
|
+
leaveTypeId;
|
|
32
|
+
}
|
|
33
|
+
exports.LeaveTypeIdDto = LeaveTypeIdDto;
|
|
34
|
+
__decorate([
|
|
35
|
+
(0, class_validator_1.IsUUID)('7', { message: 'Invalid leave type ID format' }),
|
|
36
|
+
__metadata("design:type", String)
|
|
37
|
+
], LeaveTypeIdDto.prototype, "leaveTypeId", void 0);
|
|
38
|
+
class GetLeaveTypesDto {
|
|
39
|
+
active;
|
|
40
|
+
}
|
|
41
|
+
exports.GetLeaveTypesDto = GetLeaveTypesDto;
|
|
42
|
+
__decorate([
|
|
43
|
+
(0, class_validator_1.IsOptional)(),
|
|
44
|
+
(0, validators_1.IsNullable)(),
|
|
45
|
+
QueryBoolean(),
|
|
46
|
+
(0, class_validator_1.IsBoolean)({ message: 'Active must be true or false' }),
|
|
47
|
+
__metadata("design:type", Object)
|
|
48
|
+
], GetLeaveTypesDto.prototype, "active", void 0);
|
|
49
|
+
class CreateLeaveTypeDto {
|
|
50
|
+
name;
|
|
51
|
+
description;
|
|
52
|
+
default_days;
|
|
53
|
+
is_paid;
|
|
54
|
+
requires_approval;
|
|
55
|
+
}
|
|
56
|
+
exports.CreateLeaveTypeDto = CreateLeaveTypeDto;
|
|
57
|
+
__decorate([
|
|
58
|
+
Trim(),
|
|
59
|
+
(0, class_validator_1.IsString)({ message: 'Invalid name' }),
|
|
60
|
+
(0, class_validator_1.MinLength)(1, { message: 'Name cannot be empty' }),
|
|
61
|
+
(0, class_validator_1.MaxLength)(100, { message: 'Name cannot exceed 100 characters' }),
|
|
62
|
+
__metadata("design:type", String)
|
|
63
|
+
], CreateLeaveTypeDto.prototype, "name", void 0);
|
|
64
|
+
__decorate([
|
|
65
|
+
(0, validators_1.EmptyToNull)(),
|
|
66
|
+
(0, validators_1.IsNullable)(),
|
|
67
|
+
(0, class_validator_1.IsString)({ message: 'Invalid description' }),
|
|
68
|
+
(0, class_validator_1.MaxLength)(2000, { message: 'Description cannot exceed 2000 characters' }),
|
|
69
|
+
__metadata("design:type", Object)
|
|
70
|
+
], CreateLeaveTypeDto.prototype, "description", void 0);
|
|
71
|
+
__decorate([
|
|
72
|
+
(0, class_validator_1.IsNumber)({ maxDecimalPlaces: 1 }, { message: 'Default days must be a number with at most one decimal' }),
|
|
73
|
+
(0, class_validator_1.Min)(0, { message: 'Default days cannot be negative' }),
|
|
74
|
+
(0, class_validator_1.Max)(999.9, { message: 'Default days cannot exceed 999.9' }),
|
|
75
|
+
__metadata("design:type", Number)
|
|
76
|
+
], CreateLeaveTypeDto.prototype, "default_days", void 0);
|
|
77
|
+
__decorate([
|
|
78
|
+
(0, class_validator_1.IsBoolean)({ message: 'Is paid must be true or false' }),
|
|
79
|
+
__metadata("design:type", Boolean)
|
|
80
|
+
], CreateLeaveTypeDto.prototype, "is_paid", void 0);
|
|
81
|
+
__decorate([
|
|
82
|
+
(0, class_validator_1.IsBoolean)({ message: 'Requires approval must be true or false' }),
|
|
83
|
+
__metadata("design:type", Boolean)
|
|
84
|
+
], CreateLeaveTypeDto.prototype, "requires_approval", void 0);
|
|
85
|
+
class UpdateLeaveTypeDto {
|
|
86
|
+
name;
|
|
87
|
+
description;
|
|
88
|
+
default_days;
|
|
89
|
+
is_paid;
|
|
90
|
+
requires_approval;
|
|
91
|
+
active;
|
|
92
|
+
}
|
|
93
|
+
exports.UpdateLeaveTypeDto = UpdateLeaveTypeDto;
|
|
94
|
+
__decorate([
|
|
95
|
+
Trim(),
|
|
96
|
+
(0, class_validator_1.IsString)({ message: 'Invalid name' }),
|
|
97
|
+
(0, class_validator_1.MinLength)(1, { message: 'Name cannot be empty' }),
|
|
98
|
+
(0, class_validator_1.MaxLength)(100, { message: 'Name cannot exceed 100 characters' }),
|
|
99
|
+
__metadata("design:type", String)
|
|
100
|
+
], UpdateLeaveTypeDto.prototype, "name", void 0);
|
|
101
|
+
__decorate([
|
|
102
|
+
(0, validators_1.EmptyToNull)(),
|
|
103
|
+
(0, validators_1.IsNullable)(),
|
|
104
|
+
(0, class_validator_1.IsString)({ message: 'Invalid description' }),
|
|
105
|
+
(0, class_validator_1.MaxLength)(2000, { message: 'Description cannot exceed 2000 characters' }),
|
|
106
|
+
__metadata("design:type", Object)
|
|
107
|
+
], UpdateLeaveTypeDto.prototype, "description", void 0);
|
|
108
|
+
__decorate([
|
|
109
|
+
(0, class_validator_1.IsNumber)({ maxDecimalPlaces: 1 }, { message: 'Default days must be a number with at most one decimal' }),
|
|
110
|
+
(0, class_validator_1.Min)(0, { message: 'Default days cannot be negative' }),
|
|
111
|
+
(0, class_validator_1.Max)(999.9, { message: 'Default days cannot exceed 999.9' }),
|
|
112
|
+
__metadata("design:type", Number)
|
|
113
|
+
], UpdateLeaveTypeDto.prototype, "default_days", void 0);
|
|
114
|
+
__decorate([
|
|
115
|
+
(0, class_validator_1.IsBoolean)({ message: 'Is paid must be true or false' }),
|
|
116
|
+
__metadata("design:type", Boolean)
|
|
117
|
+
], UpdateLeaveTypeDto.prototype, "is_paid", void 0);
|
|
118
|
+
__decorate([
|
|
119
|
+
(0, class_validator_1.IsBoolean)({ message: 'Requires approval must be true or false' }),
|
|
120
|
+
__metadata("design:type", Boolean)
|
|
121
|
+
], UpdateLeaveTypeDto.prototype, "requires_approval", void 0);
|
|
122
|
+
__decorate([
|
|
123
|
+
(0, class_validator_1.IsBoolean)({ message: 'Active must be true or false' }),
|
|
124
|
+
__metadata("design:type", Boolean)
|
|
125
|
+
], UpdateLeaveTypeDto.prototype, "active", void 0);
|
|
126
|
+
// ---- Leave entitlements ----
|
|
127
|
+
class LeaveEntitlementIdDto {
|
|
128
|
+
leaveEntitlementId;
|
|
129
|
+
}
|
|
130
|
+
exports.LeaveEntitlementIdDto = LeaveEntitlementIdDto;
|
|
131
|
+
__decorate([
|
|
132
|
+
(0, class_validator_1.IsUUID)('7', { message: 'Invalid leave entitlement ID format' }),
|
|
133
|
+
__metadata("design:type", String)
|
|
134
|
+
], LeaveEntitlementIdDto.prototype, "leaveEntitlementId", void 0);
|
|
135
|
+
class GetLeaveEntitlementsDto {
|
|
136
|
+
page = 1;
|
|
137
|
+
page_size = 10;
|
|
138
|
+
user_id;
|
|
139
|
+
leave_type_id;
|
|
140
|
+
as_of;
|
|
141
|
+
}
|
|
142
|
+
exports.GetLeaveEntitlementsDto = GetLeaveEntitlementsDto;
|
|
143
|
+
__decorate([
|
|
144
|
+
(0, class_validator_1.IsOptional)(),
|
|
145
|
+
(0, class_transformer_1.Transform)(({ value }) => value ? Number(value) : 1, { toClassOnly: true }),
|
|
146
|
+
(0, class_validator_1.IsNumber)({}, { message: 'Page must be a number' }),
|
|
147
|
+
(0, class_validator_1.Min)(1, { message: 'Page must be at least 1' }),
|
|
148
|
+
__metadata("design:type", Number)
|
|
149
|
+
], GetLeaveEntitlementsDto.prototype, "page", void 0);
|
|
150
|
+
__decorate([
|
|
151
|
+
(0, class_validator_1.IsOptional)(),
|
|
152
|
+
(0, class_transformer_1.Transform)(({ value }) => value ? Number(value) : 10, { toClassOnly: true }),
|
|
153
|
+
(0, class_validator_1.IsNumber)({}, { message: 'Page size must be a number' }),
|
|
154
|
+
(0, class_validator_1.Min)(1, { message: 'Page size must be at least 1' }),
|
|
155
|
+
(0, class_validator_1.Max)(100, { message: 'Page size cannot exceed 100' }),
|
|
156
|
+
__metadata("design:type", Number)
|
|
157
|
+
], GetLeaveEntitlementsDto.prototype, "page_size", void 0);
|
|
158
|
+
__decorate([
|
|
159
|
+
(0, class_validator_1.IsOptional)(),
|
|
160
|
+
(0, validators_1.IsNullable)(),
|
|
161
|
+
(0, class_validator_1.IsUUID)('4', { message: 'Invalid user ID format' }),
|
|
162
|
+
__metadata("design:type", Object)
|
|
163
|
+
], GetLeaveEntitlementsDto.prototype, "user_id", void 0);
|
|
164
|
+
__decorate([
|
|
165
|
+
(0, class_validator_1.IsOptional)(),
|
|
166
|
+
(0, validators_1.IsNullable)(),
|
|
167
|
+
(0, class_validator_1.IsUUID)('7', { message: 'Invalid leave type ID format' }),
|
|
168
|
+
__metadata("design:type", Object)
|
|
169
|
+
], GetLeaveEntitlementsDto.prototype, "leave_type_id", void 0);
|
|
170
|
+
__decorate([
|
|
171
|
+
(0, class_validator_1.IsOptional)(),
|
|
172
|
+
(0, validators_1.IsNullable)(),
|
|
173
|
+
(0, validators_1.IsCalendarDate)({ message: 'As of must be a calendar date (YYYY-MM-DD)' }),
|
|
174
|
+
__metadata("design:type", Object)
|
|
175
|
+
], GetLeaveEntitlementsDto.prototype, "as_of", void 0);
|
|
176
|
+
class CreateLeaveEntitlementDto {
|
|
177
|
+
user_id;
|
|
178
|
+
leave_type_id;
|
|
179
|
+
days_entitled;
|
|
180
|
+
period_start;
|
|
181
|
+
period_end;
|
|
182
|
+
notes;
|
|
183
|
+
}
|
|
184
|
+
exports.CreateLeaveEntitlementDto = CreateLeaveEntitlementDto;
|
|
185
|
+
__decorate([
|
|
186
|
+
(0, class_validator_1.IsUUID)('4', { message: 'Invalid user ID format' }),
|
|
187
|
+
__metadata("design:type", String)
|
|
188
|
+
], CreateLeaveEntitlementDto.prototype, "user_id", void 0);
|
|
189
|
+
__decorate([
|
|
190
|
+
(0, class_validator_1.IsUUID)('7', { message: 'Invalid leave type ID format' }),
|
|
191
|
+
__metadata("design:type", String)
|
|
192
|
+
], CreateLeaveEntitlementDto.prototype, "leave_type_id", void 0);
|
|
193
|
+
__decorate([
|
|
194
|
+
(0, class_validator_1.IsNumber)({ maxDecimalPlaces: 1 }, { message: 'Days entitled must be a number with at most one decimal' }),
|
|
195
|
+
(0, class_validator_1.Min)(0, { message: 'Days entitled cannot be negative' }),
|
|
196
|
+
(0, class_validator_1.Max)(999.9, { message: 'Days entitled cannot exceed 999.9' }),
|
|
197
|
+
__metadata("design:type", Number)
|
|
198
|
+
], CreateLeaveEntitlementDto.prototype, "days_entitled", void 0);
|
|
199
|
+
__decorate([
|
|
200
|
+
(0, validators_1.IsNullable)(),
|
|
201
|
+
(0, validators_1.IsCalendarDate)({ message: 'Period start must be a calendar date (YYYY-MM-DD)' }),
|
|
202
|
+
__metadata("design:type", Object)
|
|
203
|
+
], CreateLeaveEntitlementDto.prototype, "period_start", void 0);
|
|
204
|
+
__decorate([
|
|
205
|
+
(0, validators_1.IsNullable)(),
|
|
206
|
+
(0, validators_1.IsCalendarDate)({ message: 'Period end must be a calendar date (YYYY-MM-DD)' }),
|
|
207
|
+
__metadata("design:type", Object)
|
|
208
|
+
], CreateLeaveEntitlementDto.prototype, "period_end", void 0);
|
|
209
|
+
__decorate([
|
|
210
|
+
(0, validators_1.EmptyToNull)(),
|
|
211
|
+
(0, validators_1.IsNullable)(),
|
|
212
|
+
(0, class_validator_1.IsString)({ message: 'Invalid notes' }),
|
|
213
|
+
(0, class_validator_1.MaxLength)(2000, { message: 'Notes cannot exceed 2000 characters' }),
|
|
214
|
+
__metadata("design:type", Object)
|
|
215
|
+
], CreateLeaveEntitlementDto.prototype, "notes", void 0);
|
|
216
|
+
class UpdateLeaveEntitlementDto {
|
|
217
|
+
days_entitled;
|
|
218
|
+
period_end;
|
|
219
|
+
notes;
|
|
220
|
+
}
|
|
221
|
+
exports.UpdateLeaveEntitlementDto = UpdateLeaveEntitlementDto;
|
|
222
|
+
__decorate([
|
|
223
|
+
(0, class_validator_1.IsNumber)({ maxDecimalPlaces: 1 }, { message: 'Days entitled must be a number with at most one decimal' }),
|
|
224
|
+
(0, class_validator_1.Min)(0, { message: 'Days entitled cannot be negative' }),
|
|
225
|
+
(0, class_validator_1.Max)(999.9, { message: 'Days entitled cannot exceed 999.9' }),
|
|
226
|
+
__metadata("design:type", Number)
|
|
227
|
+
], UpdateLeaveEntitlementDto.prototype, "days_entitled", void 0);
|
|
228
|
+
__decorate([
|
|
229
|
+
(0, validators_1.IsCalendarDate)({ message: 'Period end must be a calendar date (YYYY-MM-DD)' }),
|
|
230
|
+
__metadata("design:type", String)
|
|
231
|
+
], UpdateLeaveEntitlementDto.prototype, "period_end", void 0);
|
|
232
|
+
__decorate([
|
|
233
|
+
(0, validators_1.EmptyToNull)(),
|
|
234
|
+
(0, validators_1.IsNullable)(),
|
|
235
|
+
(0, class_validator_1.IsString)({ message: 'Invalid notes' }),
|
|
236
|
+
(0, class_validator_1.MaxLength)(2000, { message: 'Notes cannot exceed 2000 characters' }),
|
|
237
|
+
__metadata("design:type", Object)
|
|
238
|
+
], UpdateLeaveEntitlementDto.prototype, "notes", void 0);
|
|
239
|
+
// ---- Leave requests ----
|
|
240
|
+
class LeaveRequestIdDto {
|
|
241
|
+
leaveRequestId;
|
|
242
|
+
}
|
|
243
|
+
exports.LeaveRequestIdDto = LeaveRequestIdDto;
|
|
244
|
+
__decorate([
|
|
245
|
+
(0, class_validator_1.IsUUID)('7', { message: 'Invalid leave request ID format' }),
|
|
246
|
+
__metadata("design:type", String)
|
|
247
|
+
], LeaveRequestIdDto.prototype, "leaveRequestId", void 0);
|
|
248
|
+
class GetLeaveRequestsDto {
|
|
249
|
+
page = 1;
|
|
250
|
+
page_size = 10;
|
|
251
|
+
user_id;
|
|
252
|
+
leave_type_id;
|
|
253
|
+
status;
|
|
254
|
+
start_date_after;
|
|
255
|
+
start_date_before;
|
|
256
|
+
}
|
|
257
|
+
exports.GetLeaveRequestsDto = GetLeaveRequestsDto;
|
|
258
|
+
__decorate([
|
|
259
|
+
(0, class_validator_1.IsOptional)(),
|
|
260
|
+
(0, class_transformer_1.Transform)(({ value }) => value ? Number(value) : 1, { toClassOnly: true }),
|
|
261
|
+
(0, class_validator_1.IsNumber)({}, { message: 'Page must be a number' }),
|
|
262
|
+
(0, class_validator_1.Min)(1, { message: 'Page must be at least 1' }),
|
|
263
|
+
__metadata("design:type", Number)
|
|
264
|
+
], GetLeaveRequestsDto.prototype, "page", void 0);
|
|
265
|
+
__decorate([
|
|
266
|
+
(0, class_validator_1.IsOptional)(),
|
|
267
|
+
(0, class_transformer_1.Transform)(({ value }) => value ? Number(value) : 10, { toClassOnly: true }),
|
|
268
|
+
(0, class_validator_1.IsNumber)({}, { message: 'Page size must be a number' }),
|
|
269
|
+
(0, class_validator_1.Min)(1, { message: 'Page size must be at least 1' }),
|
|
270
|
+
(0, class_validator_1.Max)(100, { message: 'Page size cannot exceed 100' }),
|
|
271
|
+
__metadata("design:type", Number)
|
|
272
|
+
], GetLeaveRequestsDto.prototype, "page_size", void 0);
|
|
273
|
+
__decorate([
|
|
274
|
+
(0, class_validator_1.IsOptional)(),
|
|
275
|
+
(0, validators_1.IsNullable)(),
|
|
276
|
+
(0, class_validator_1.IsUUID)('4', { message: 'Invalid user ID format' }),
|
|
277
|
+
__metadata("design:type", Object)
|
|
278
|
+
], GetLeaveRequestsDto.prototype, "user_id", void 0);
|
|
279
|
+
__decorate([
|
|
280
|
+
(0, class_validator_1.IsOptional)(),
|
|
281
|
+
(0, validators_1.IsNullable)(),
|
|
282
|
+
(0, class_validator_1.IsUUID)('7', { message: 'Invalid leave type ID format' }),
|
|
283
|
+
__metadata("design:type", Object)
|
|
284
|
+
], GetLeaveRequestsDto.prototype, "leave_type_id", void 0);
|
|
285
|
+
__decorate([
|
|
286
|
+
(0, class_validator_1.IsOptional)(),
|
|
287
|
+
(0, validators_1.IsNullable)(),
|
|
288
|
+
(0, class_validator_1.IsEnum)(enum_1.LeaveRequestStatus, { message: 'Invalid status' }),
|
|
289
|
+
__metadata("design:type", Object)
|
|
290
|
+
], GetLeaveRequestsDto.prototype, "status", void 0);
|
|
291
|
+
__decorate([
|
|
292
|
+
(0, class_validator_1.IsOptional)(),
|
|
293
|
+
(0, validators_1.IsNullable)(),
|
|
294
|
+
(0, validators_1.IsCalendarDate)({ message: 'Start date after must be a calendar date (YYYY-MM-DD)' }),
|
|
295
|
+
__metadata("design:type", Object)
|
|
296
|
+
], GetLeaveRequestsDto.prototype, "start_date_after", void 0);
|
|
297
|
+
__decorate([
|
|
298
|
+
(0, class_validator_1.IsOptional)(),
|
|
299
|
+
(0, validators_1.IsNullable)(),
|
|
300
|
+
(0, validators_1.IsCalendarDate)({ message: 'Start date before must be a calendar date (YYYY-MM-DD)' }),
|
|
301
|
+
__metadata("design:type", Object)
|
|
302
|
+
], GetLeaveRequestsDto.prototype, "start_date_before", void 0);
|
|
303
|
+
// No `user_id`: a request is always the caller's own. Filing on someone's behalf is a later
|
|
304
|
+
// feature, and leaving the field out is what keeps a forged one from validating.
|
|
305
|
+
class CreateLeaveRequestDto {
|
|
306
|
+
leave_type_id;
|
|
307
|
+
start_date;
|
|
308
|
+
end_date;
|
|
309
|
+
is_half_day;
|
|
310
|
+
reason;
|
|
311
|
+
}
|
|
312
|
+
exports.CreateLeaveRequestDto = CreateLeaveRequestDto;
|
|
313
|
+
__decorate([
|
|
314
|
+
(0, class_validator_1.IsUUID)('7', { message: 'Invalid leave type ID format' }),
|
|
315
|
+
__metadata("design:type", String)
|
|
316
|
+
], CreateLeaveRequestDto.prototype, "leave_type_id", void 0);
|
|
317
|
+
__decorate([
|
|
318
|
+
(0, validators_1.IsCalendarDate)({ message: 'Start date must be a calendar date (YYYY-MM-DD)' }),
|
|
319
|
+
__metadata("design:type", String)
|
|
320
|
+
], CreateLeaveRequestDto.prototype, "start_date", void 0);
|
|
321
|
+
__decorate([
|
|
322
|
+
(0, validators_1.IsCalendarDate)({ message: 'End date must be a calendar date (YYYY-MM-DD)' }),
|
|
323
|
+
__metadata("design:type", String)
|
|
324
|
+
], CreateLeaveRequestDto.prototype, "end_date", void 0);
|
|
325
|
+
__decorate([
|
|
326
|
+
(0, class_validator_1.IsBoolean)({ message: 'Is half day must be true or false' }),
|
|
327
|
+
__metadata("design:type", Boolean)
|
|
328
|
+
], CreateLeaveRequestDto.prototype, "is_half_day", void 0);
|
|
329
|
+
__decorate([
|
|
330
|
+
(0, validators_1.EmptyToNull)(),
|
|
331
|
+
(0, validators_1.IsNullable)(),
|
|
332
|
+
(0, class_validator_1.IsString)({ message: 'Invalid reason' }),
|
|
333
|
+
(0, class_validator_1.MaxLength)(2000, { message: 'Reason cannot exceed 2000 characters' }),
|
|
334
|
+
__metadata("design:type", Object)
|
|
335
|
+
], CreateLeaveRequestDto.prototype, "reason", void 0);
|
|
336
|
+
class UpdateLeaveRequestDto {
|
|
337
|
+
leave_type_id;
|
|
338
|
+
start_date;
|
|
339
|
+
end_date;
|
|
340
|
+
is_half_day;
|
|
341
|
+
reason;
|
|
342
|
+
}
|
|
343
|
+
exports.UpdateLeaveRequestDto = UpdateLeaveRequestDto;
|
|
344
|
+
__decorate([
|
|
345
|
+
(0, class_validator_1.IsUUID)('7', { message: 'Invalid leave type ID format' }),
|
|
346
|
+
__metadata("design:type", String)
|
|
347
|
+
], UpdateLeaveRequestDto.prototype, "leave_type_id", void 0);
|
|
348
|
+
__decorate([
|
|
349
|
+
(0, validators_1.IsCalendarDate)({ message: 'Start date must be a calendar date (YYYY-MM-DD)' }),
|
|
350
|
+
__metadata("design:type", String)
|
|
351
|
+
], UpdateLeaveRequestDto.prototype, "start_date", void 0);
|
|
352
|
+
__decorate([
|
|
353
|
+
(0, validators_1.IsCalendarDate)({ message: 'End date must be a calendar date (YYYY-MM-DD)' }),
|
|
354
|
+
__metadata("design:type", String)
|
|
355
|
+
], UpdateLeaveRequestDto.prototype, "end_date", void 0);
|
|
356
|
+
__decorate([
|
|
357
|
+
(0, class_validator_1.IsBoolean)({ message: 'Is half day must be true or false' }),
|
|
358
|
+
__metadata("design:type", Boolean)
|
|
359
|
+
], UpdateLeaveRequestDto.prototype, "is_half_day", void 0);
|
|
360
|
+
__decorate([
|
|
361
|
+
(0, validators_1.EmptyToNull)(),
|
|
362
|
+
(0, validators_1.IsNullable)(),
|
|
363
|
+
(0, class_validator_1.IsString)({ message: 'Invalid reason' }),
|
|
364
|
+
(0, class_validator_1.MaxLength)(2000, { message: 'Reason cannot exceed 2000 characters' }),
|
|
365
|
+
__metadata("design:type", Object)
|
|
366
|
+
], UpdateLeaveRequestDto.prototype, "reason", void 0);
|
|
367
|
+
class ReviewLeaveRequestDto {
|
|
368
|
+
status;
|
|
369
|
+
review_note;
|
|
370
|
+
}
|
|
371
|
+
exports.ReviewLeaveRequestDto = ReviewLeaveRequestDto;
|
|
372
|
+
__decorate([
|
|
373
|
+
(0, class_validator_1.IsEnum)(enum_1.LeaveReviewDecision, { message: 'Status must be approved or rejected' }),
|
|
374
|
+
__metadata("design:type", String)
|
|
375
|
+
], ReviewLeaveRequestDto.prototype, "status", void 0);
|
|
376
|
+
__decorate([
|
|
377
|
+
(0, validators_1.EmptyToNull)(),
|
|
378
|
+
(0, validators_1.IsNullable)(),
|
|
379
|
+
(0, class_validator_1.IsString)({ message: 'Invalid review note' }),
|
|
380
|
+
(0, class_validator_1.MaxLength)(2000, { message: 'Review note cannot exceed 2000 characters' }),
|
|
381
|
+
__metadata("design:type", Object)
|
|
382
|
+
], ReviewLeaveRequestDto.prototype, "review_note", void 0);
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export * from './dto';
|
|
2
|
+
export * from './working-days';
|
|
3
|
+
export { LeaveTypesResource } from './leave-types';
|
|
4
|
+
export { LeaveEntitlementsResource, type CreateLeaveEntitlementInput, type LeaveEntitlementCover, } from './leave-entitlements';
|
|
5
|
+
export { LeaveRequestsResource, type CreateLeaveRequestRow, type ReviewLeaveRequestRow, type UpdateLeaveRequestRow, } from './leave-requests';
|