@dakkitor/api-contracts 1.1.131 → 1.1.133
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/abilities/abilities.contract.d.ts +19 -13
- package/dist/abilities/abilities.contract.js +33 -18
- package/dist/abilities/first-agent.abilities.json +68 -56
- package/dist/abilities/second-agent.abilities.json +3 -3
- package/dist/abilities/team-leads.json +3 -6
- package/dist/actives/actives.contract.d.ts +6313 -6313
- package/dist/actives/actives.contract.js +92 -92
- package/dist/agent-client-links/agent-client-links.contract.d.ts +511 -511
- package/dist/auth/auth.contract.d.ts +16 -16
- package/dist/bookings/bookings.contract.d.ts +23378 -23378
- package/dist/call-history/call-history.contract.d.ts +366 -366
- package/dist/call-history/call-history.contract.js +67 -67
- package/dist/client-contacts/client-contacts.contract.d.ts +159 -159
- package/dist/clients/clients.contract.d.ts +72 -72
- package/dist/collaboration-checkings/collaboration-checkings.contract.d.ts +1330 -1330
- package/dist/collaborations/collaborations.contract.d.ts +1198 -1198
- package/dist/common/call-rating.schema.d.ts +12 -12
- package/dist/common/call-rating.schema.js +48 -40
- package/dist/common/common-schemas.d.ts +4 -4
- package/dist/common/common-schemas.d.ts.map +1 -1
- package/dist/common/common-schemas.js +1 -2
- package/dist/common/error-schemas.d.ts +11 -5
- package/dist/common/error-schemas.js +11 -8
- package/dist/common/openapi-metadata.d.ts +54 -44
- package/dist/common/openapi-metadata.js +135 -129
- package/dist/common/pagination-query.schema.d.ts +11 -5
- package/dist/common/pagination-query.schema.js +11 -8
- package/dist/companies/companies.contract.d.ts +40 -40
- package/dist/cron-executions/cron-executions.contract.d.ts +14 -14
- package/dist/curated-workers/curated-workers.contract.d.ts +211 -211
- package/dist/dashboards/agent-daily-metrics.contract.d.ts +798 -616
- package/dist/dashboards/agent-daily-metrics.contract.js +100 -89
- package/dist/dashboards/dashboard-widgets.contract.d.ts +75 -75
- package/dist/dashboards/dashboard-widgets.contract.js +89 -89
- package/dist/dashboards/dashboard.contract.d.ts +305 -215
- package/dist/files/files.contract.d.ts +1544 -1177
- package/dist/files/files.contract.js +177 -162
- package/dist/health/health.contract.d.ts +191 -144
- package/dist/health/health.contract.js +53 -40
- package/dist/index.d.ts +67 -67
- package/dist/jobs/jobs.contract.d.ts +2553 -2553
- package/dist/jobs/jobs.contract.js +150 -150
- package/dist/lead-assignments/lead-assignments.contract.d.ts +587 -587
- package/dist/lead-distribution/agent-lead-distribution.contract.d.ts +239 -239
- package/dist/lead-distribution/lead-distribution-config.contract.d.ts +25 -25
- package/dist/leads/leads.contract.d.ts +108 -108
- package/dist/leads/leads.contract.js +119 -119
- package/dist/locations/locations.contract.d.ts +7 -7
- package/dist/monitoring/monitoring.contract.d.ts +13 -13
- package/dist/monitoring/monitoring.contract.js +37 -37
- package/dist/own-research/own-research.contract.d.ts +535 -134
- package/dist/own-research/own-research.contract.d.ts.map +1 -1
- package/dist/own-research/own-research.contract.js +88 -56
- package/dist/postcodes/postcodes.contract.d.ts +24 -24
- package/dist/qualifications/qualifications.contract.d.ts +1898 -1387
- package/dist/qualifications/qualifications.contract.js +193 -171
- package/dist/trades/trades.contract.d.ts +991 -763
- package/dist/trades/trades.contract.js +111 -89
- package/dist/users/users.contract.d.ts +202 -202
- package/dist/users/users.contract.js +121 -121
- package/dist/workers/workers.contract.d.ts +710 -710
- package/dist/workers/workers.contract.js +150 -150
- package/package.json +1 -1
|
@@ -13,27 +13,27 @@ const users_contract_1 = require("../users/users.contract");
|
|
|
13
13
|
(0, zod_openapi_1.extendZodWithOpenApi)(zod_1.z);
|
|
14
14
|
// --- Enums ---
|
|
15
15
|
exports.AvailabilitySchema = zod_1.z.enum([
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
'AVAILABLE',
|
|
17
|
+
'PARTIALLY_AVAILABLE',
|
|
18
|
+
'UNAVAILABLE',
|
|
19
19
|
]);
|
|
20
20
|
// EnglishLevelSchema and NationalitySchema are now imported from common-schemas
|
|
21
21
|
exports.WorkerSortableFieldsSchema = zod_1.z
|
|
22
|
-
.enum([
|
|
23
|
-
.openapi({ title:
|
|
22
|
+
.enum(['nameSimilarity', 'fullName', 'distance', 'email', 'phone'])
|
|
23
|
+
.openapi({ title: 'WorkerSortableFields' });
|
|
24
24
|
exports.BooleanFilterSchema = zod_1.z
|
|
25
|
-
.enum([
|
|
26
|
-
.default(
|
|
27
|
-
.openapi({ title:
|
|
25
|
+
.enum(['only_with', 'only_without', 'all'])
|
|
26
|
+
.default('all')
|
|
27
|
+
.openapi({ title: 'BooleanFilter' });
|
|
28
28
|
// --- Nested Schemas ---
|
|
29
29
|
exports.WorkerPhoneNumberSchema = common_schemas_1.PhoneNumberResponseSchema.openapi({
|
|
30
|
-
title:
|
|
30
|
+
title: 'WorkerPhoneNumber',
|
|
31
31
|
});
|
|
32
32
|
exports.CreateWorkerPhoneNumberSchema = common_schemas_1.CreatePhoneNumberSchema.openapi({
|
|
33
|
-
title:
|
|
33
|
+
title: 'CreateWorkerPhoneNumber',
|
|
34
34
|
});
|
|
35
35
|
exports.UpsertWorkerPhoneNumberSchema = common_schemas_1.UpsertPhoneNumberSchema.openapi({
|
|
36
|
-
title:
|
|
36
|
+
title: 'UpsertWorkerPhoneNumber',
|
|
37
37
|
});
|
|
38
38
|
exports.WorkerTradeSchema = zod_1.z
|
|
39
39
|
.object({
|
|
@@ -41,40 +41,40 @@ exports.WorkerTradeSchema = zod_1.z
|
|
|
41
41
|
tradeId: zod_1.z.string().uuid(),
|
|
42
42
|
mainTrade: zod_1.z.boolean().default(false),
|
|
43
43
|
})
|
|
44
|
-
.openapi({ title:
|
|
44
|
+
.openapi({ title: 'WorkerTrade' });
|
|
45
45
|
exports.CreateWorkerTradeSchema = zod_1.z
|
|
46
46
|
.object({
|
|
47
|
-
tradeId: zod_1.z.string().uuid({ message:
|
|
47
|
+
tradeId: zod_1.z.string().uuid({ message: 'Trade must be selected' }),
|
|
48
48
|
mainTrade: zod_1.z.boolean().default(false),
|
|
49
49
|
})
|
|
50
|
-
.openapi({ title:
|
|
50
|
+
.openapi({ title: 'CreateWorkerTrade' });
|
|
51
51
|
exports.WorkerQualificationSchema = zod_1.z
|
|
52
52
|
.object({
|
|
53
53
|
id: zod_1.z.string().uuid().optional(),
|
|
54
54
|
qualificationId: zod_1.z.string().uuid(),
|
|
55
|
-
qualificationTypeId: zod_1.z.preprocess((val) => (val ===
|
|
55
|
+
qualificationTypeId: zod_1.z.preprocess((val) => (val === '' ? null : val), zod_1.z.string().uuid().optional().nullable()),
|
|
56
56
|
issueDate: zod_1.z
|
|
57
57
|
.union([zod_1.z.string().date(), zod_1.z.date()])
|
|
58
|
-
.transform((val) => val instanceof Date ? val.toISOString().split(
|
|
58
|
+
.transform((val) => val instanceof Date ? val.toISOString().split('T')[0] : val)
|
|
59
59
|
.optional()
|
|
60
60
|
.nullable(),
|
|
61
61
|
expiryDate: zod_1.z
|
|
62
62
|
.union([zod_1.z.string().date(), zod_1.z.date()])
|
|
63
|
-
.transform((val) => val instanceof Date ? val.toISOString().split(
|
|
63
|
+
.transform((val) => val instanceof Date ? val.toISOString().split('T')[0] : val)
|
|
64
64
|
.optional()
|
|
65
65
|
.nullable(),
|
|
66
66
|
referenceNumber: zod_1.z
|
|
67
67
|
.string()
|
|
68
68
|
.optional()
|
|
69
69
|
.nullable()
|
|
70
|
-
.describe(
|
|
70
|
+
.describe('Reference Number'),
|
|
71
71
|
proofDocumentFileId: zod_1.z.string().uuid().optional().nullable(),
|
|
72
72
|
})
|
|
73
|
-
.openapi({ title:
|
|
73
|
+
.openapi({ title: 'WorkerQualification' });
|
|
74
74
|
exports.CreateWorkerQualificationSchema = zod_1.z
|
|
75
75
|
.object({
|
|
76
76
|
qualificationId: zod_1.z.string().uuid(),
|
|
77
|
-
qualificationTypeId: zod_1.z.preprocess((val) => (val ===
|
|
77
|
+
qualificationTypeId: zod_1.z.preprocess((val) => (val === '' ? null : val), zod_1.z.string().uuid().optional().nullable()),
|
|
78
78
|
issueDate: zod_1.z.string().date().optional().nullable(),
|
|
79
79
|
expiryDate: zod_1.z.string().date().optional().nullable(),
|
|
80
80
|
referenceNumber: zod_1.z
|
|
@@ -82,36 +82,36 @@ exports.CreateWorkerQualificationSchema = zod_1.z
|
|
|
82
82
|
.max(255)
|
|
83
83
|
.optional()
|
|
84
84
|
.nullable()
|
|
85
|
-
.describe(
|
|
85
|
+
.describe('Reference Number'),
|
|
86
86
|
proofDocumentFileId: zod_1.z.string().uuid().optional().nullable(),
|
|
87
87
|
})
|
|
88
|
-
.openapi({ title:
|
|
88
|
+
.openapi({ title: 'CreateWorkerQualification' });
|
|
89
89
|
exports.ShareCodeSchema = zod_1.z
|
|
90
90
|
.object({
|
|
91
91
|
code: zod_1.z
|
|
92
92
|
.string()
|
|
93
|
-
.transform((val) => val.toUpperCase().replace(/\s/g,
|
|
94
|
-
.refine((val) => val ===
|
|
95
|
-
message:
|
|
93
|
+
.transform((val) => val.toUpperCase().replace(/\s/g, ''))
|
|
94
|
+
.refine((val) => val === '' || /^[A-Z0-9]{9}$/.test(val), {
|
|
95
|
+
message: 'Share code must be 9 alphanumeric characters (e.g., ABC 123 XYZ)',
|
|
96
96
|
})
|
|
97
|
-
.describe(
|
|
97
|
+
.describe('Enter share code (e.g., ABC 123 XYZ)'),
|
|
98
98
|
expiryDate: zod_1.z
|
|
99
99
|
.union([zod_1.z.string().date(), zod_1.z.date()])
|
|
100
|
-
.transform((val) => val instanceof Date ? val.toISOString().split(
|
|
100
|
+
.transform((val) => val instanceof Date ? val.toISOString().split('T')[0] : val)
|
|
101
101
|
.optional()
|
|
102
102
|
.nullable()
|
|
103
|
-
.describe(
|
|
103
|
+
.describe('Enter expiry date for the share code'),
|
|
104
104
|
})
|
|
105
105
|
.openapi({
|
|
106
|
-
title:
|
|
107
|
-
description:
|
|
106
|
+
title: 'ShareCode',
|
|
107
|
+
description: 'Share code information for right to work verification',
|
|
108
108
|
});
|
|
109
109
|
exports.TradeFilterSchema = zod_1.z
|
|
110
110
|
.object({
|
|
111
111
|
tradeId: zod_1.z.string().uuid(),
|
|
112
|
-
mainTrade: zod_1.z.preprocess((val) => (val ===
|
|
112
|
+
mainTrade: zod_1.z.preprocess((val) => (val === 'true' ? true : val === 'false' ? false : val), zod_1.z.boolean().optional()),
|
|
113
113
|
})
|
|
114
|
-
.openapi({ title:
|
|
114
|
+
.openapi({ title: 'TradeFilter' });
|
|
115
115
|
exports.WorkerUserSchema = zod_1.z.object({
|
|
116
116
|
id: zod_1.z.string().uuid(),
|
|
117
117
|
firstName: zod_1.z.string(),
|
|
@@ -121,293 +121,293 @@ exports.WorkerUserSchema = zod_1.z.object({
|
|
|
121
121
|
// --- Main Schemas ---
|
|
122
122
|
exports.WorkerSchema = zod_1.z
|
|
123
123
|
.object({
|
|
124
|
-
id: zod_1.z.string().uuid().describe(
|
|
125
|
-
firstName: zod_1.z.string().describe(
|
|
126
|
-
lastName: zod_1.z.string().optional().nullable().describe(
|
|
127
|
-
email: zod_1.z.string().email().nullable().optional().describe(
|
|
124
|
+
id: zod_1.z.string().uuid().describe('Worker ID'),
|
|
125
|
+
firstName: zod_1.z.string().describe('First Name'),
|
|
126
|
+
lastName: zod_1.z.string().optional().nullable().describe('Last Name'),
|
|
127
|
+
email: zod_1.z.string().email().nullable().optional().describe('Email'),
|
|
128
128
|
phoneNumbers: zod_1.z
|
|
129
129
|
.array(exports.WorkerPhoneNumberSchema)
|
|
130
130
|
.optional()
|
|
131
131
|
.default([])
|
|
132
|
-
.describe(
|
|
132
|
+
.describe('Phone Numbers'),
|
|
133
133
|
nino: zod_1.z
|
|
134
134
|
.string()
|
|
135
135
|
.nullable()
|
|
136
136
|
.optional()
|
|
137
|
-
.describe(
|
|
137
|
+
.describe('National Insurance Number'),
|
|
138
138
|
dateOfBirth: zod_1.z
|
|
139
139
|
.union([zod_1.z.string().date(), zod_1.z.date()])
|
|
140
|
-
.transform((val) => val instanceof Date ? val.toISOString().split(
|
|
140
|
+
.transform((val) => val instanceof Date ? val.toISOString().split('T')[0] : val)
|
|
141
141
|
.nullable()
|
|
142
142
|
.optional()
|
|
143
|
-
.describe(
|
|
144
|
-
bio: zod_1.z.string().nullable().optional().describe(
|
|
145
|
-
trades: zod_1.z.array(exports.WorkerTradeSchema).optional().describe(
|
|
143
|
+
.describe('Date of Birth'),
|
|
144
|
+
bio: zod_1.z.string().nullable().optional().describe('Bio'),
|
|
145
|
+
trades: zod_1.z.array(exports.WorkerTradeSchema).optional().describe('Trades'),
|
|
146
146
|
qualifications: zod_1.z
|
|
147
147
|
.array(exports.WorkerQualificationSchema)
|
|
148
148
|
.optional()
|
|
149
|
-
.describe(
|
|
149
|
+
.describe('Qualifications'),
|
|
150
150
|
englishLevel: common_schemas_1.EnglishLevelSchema.nullable()
|
|
151
151
|
.optional()
|
|
152
|
-
.describe(
|
|
152
|
+
.describe('English Level'),
|
|
153
153
|
nationality: common_schemas_1.NationalitySchema.nullable()
|
|
154
154
|
.optional()
|
|
155
|
-
.describe(
|
|
156
|
-
hasTools: zod_1.z.boolean().describe(
|
|
157
|
-
hasPpe: zod_1.z.boolean().describe(
|
|
158
|
-
location: common_schemas_1.LocationDetailsSchema.nullable().optional().describe(
|
|
159
|
-
shareCode: exports.ShareCodeSchema.optional().nullable().describe(
|
|
160
|
-
availability: exports.AvailabilitySchema.describe(
|
|
155
|
+
.describe('Nationality'),
|
|
156
|
+
hasTools: zod_1.z.boolean().describe('Has Tools'),
|
|
157
|
+
hasPpe: zod_1.z.boolean().describe('Has PPE'),
|
|
158
|
+
location: common_schemas_1.LocationDetailsSchema.nullable().optional().describe('Location'),
|
|
159
|
+
shareCode: exports.ShareCodeSchema.optional().nullable().describe('Share Code'),
|
|
160
|
+
availability: exports.AvailabilitySchema.describe('Availability'),
|
|
161
161
|
createdByUserId: zod_1.z
|
|
162
162
|
.string()
|
|
163
163
|
.uuid()
|
|
164
164
|
.nullable()
|
|
165
165
|
.optional()
|
|
166
|
-
.describe(
|
|
167
|
-
createdBy: users_contract_1.UserSchema.nullable().optional().describe(
|
|
168
|
-
distanceKm: zod_1.z.number().nullable().optional().describe(
|
|
166
|
+
.describe('Created By User ID'),
|
|
167
|
+
createdBy: users_contract_1.UserSchema.nullable().optional().describe('Created By User'),
|
|
168
|
+
distanceKm: zod_1.z.number().nullable().optional().describe('Distance in KM'),
|
|
169
169
|
createdAt: zod_1.z
|
|
170
170
|
.union([zod_1.z.string().datetime(), zod_1.z.date()])
|
|
171
171
|
.transform((val) => (val instanceof Date ? val.toISOString() : val))
|
|
172
|
-
.describe(
|
|
172
|
+
.describe('Creation Date'),
|
|
173
173
|
updatedAt: zod_1.z
|
|
174
174
|
.union([zod_1.z.string().datetime(), zod_1.z.date()])
|
|
175
175
|
.transform((val) => (val instanceof Date ? val.toISOString() : val))
|
|
176
|
-
.describe(
|
|
176
|
+
.describe('Last Update Date'),
|
|
177
177
|
})
|
|
178
|
-
.openapi({ title:
|
|
178
|
+
.openapi({ title: 'Worker' });
|
|
179
179
|
exports.CreateWorkerSchema = zod_1.z
|
|
180
180
|
.object({
|
|
181
|
-
firstName: zod_1.z.string().min(3).max(100).describe(
|
|
181
|
+
firstName: zod_1.z.string().min(3).max(100).describe('First Name'),
|
|
182
182
|
lastName: zod_1.z
|
|
183
183
|
.string()
|
|
184
184
|
.min(3)
|
|
185
185
|
.max(100)
|
|
186
186
|
.nullish()
|
|
187
|
-
.or(zod_1.z.literal(
|
|
188
|
-
.transform((val) => (val ===
|
|
189
|
-
.describe(
|
|
187
|
+
.or(zod_1.z.literal(''))
|
|
188
|
+
.transform((val) => (val === '' ? null : val))
|
|
189
|
+
.describe('Last Name'),
|
|
190
190
|
email: zod_1.z
|
|
191
191
|
.string()
|
|
192
192
|
.email()
|
|
193
193
|
.nullish()
|
|
194
|
-
.or(zod_1.z.literal(
|
|
195
|
-
.transform((val) => (val ===
|
|
196
|
-
.describe(
|
|
194
|
+
.or(zod_1.z.literal(''))
|
|
195
|
+
.transform((val) => (val === '' ? undefined : val))
|
|
196
|
+
.describe('Email'),
|
|
197
197
|
phoneNumbers: zod_1.z
|
|
198
198
|
.array(exports.CreateWorkerPhoneNumberSchema)
|
|
199
|
-
.min(1, { message:
|
|
199
|
+
.min(1, { message: 'At least one phone number is required' })
|
|
200
200
|
.refine((phoneNumbers) => phoneNumbers.some((phone) => phone.isPrimary), {
|
|
201
|
-
message:
|
|
201
|
+
message: 'Must have at least one primary phone number',
|
|
202
202
|
})
|
|
203
|
-
.describe(
|
|
203
|
+
.describe('Phone Numbers'),
|
|
204
204
|
nino: zod_1.z
|
|
205
205
|
.string()
|
|
206
206
|
.regex(/^(?:[A-Z]{2}[0-9]{6}[A-D])?$/)
|
|
207
207
|
.optional()
|
|
208
208
|
.nullable()
|
|
209
|
-
.describe(
|
|
209
|
+
.describe('National Insurance Number'),
|
|
210
210
|
dateOfBirth: zod_1.z
|
|
211
211
|
.union([zod_1.z.string().date(), zod_1.z.date()])
|
|
212
212
|
.optional()
|
|
213
213
|
.nullable()
|
|
214
|
-
.describe(
|
|
215
|
-
bio: zod_1.z.string().optional().nullable().describe(
|
|
214
|
+
.describe('Date of Birth'),
|
|
215
|
+
bio: zod_1.z.string().optional().nullable().describe('Bio'),
|
|
216
216
|
trades: zod_1.z
|
|
217
217
|
.array(exports.CreateWorkerTradeSchema)
|
|
218
|
-
.min(1, { message:
|
|
218
|
+
.min(1, { message: 'At least one trade must be selected' })
|
|
219
219
|
.max(10)
|
|
220
220
|
.refine((trades) => trades.some((trade) => trade.mainTrade), {
|
|
221
|
-
message:
|
|
221
|
+
message: 'Exactly one trade must be marked as the main trade',
|
|
222
222
|
})
|
|
223
|
-
.describe(
|
|
223
|
+
.describe('Trades'),
|
|
224
224
|
qualifications: zod_1.z
|
|
225
225
|
.array(exports.CreateWorkerQualificationSchema)
|
|
226
226
|
.optional()
|
|
227
227
|
.nullable()
|
|
228
|
-
.describe(
|
|
228
|
+
.describe('Qualifications'),
|
|
229
229
|
englishLevel: common_schemas_1.EnglishLevelSchema.optional()
|
|
230
230
|
.nullable()
|
|
231
|
-
.describe(
|
|
231
|
+
.describe('English Level'),
|
|
232
232
|
nationality: common_schemas_1.NationalitySchema.optional()
|
|
233
233
|
.nullable()
|
|
234
|
-
.describe(
|
|
235
|
-
hasTools: zod_1.z.boolean().describe(
|
|
236
|
-
hasPpe: zod_1.z.boolean().describe(
|
|
237
|
-
location: common_schemas_1.CreateLocationSchema.optional().nullable().describe(
|
|
238
|
-
shareCode: exports.ShareCodeSchema.optional().nullable().describe(
|
|
234
|
+
.describe('Nationality'),
|
|
235
|
+
hasTools: zod_1.z.boolean().describe('Has Tools'),
|
|
236
|
+
hasPpe: zod_1.z.boolean().describe('Has PPE'),
|
|
237
|
+
location: common_schemas_1.CreateLocationSchema.optional().nullable().describe('Location'),
|
|
238
|
+
shareCode: exports.ShareCodeSchema.optional().nullable().describe('Share Code'),
|
|
239
239
|
availability: exports.AvailabilitySchema.optional()
|
|
240
|
-
.default(
|
|
241
|
-
.describe(
|
|
240
|
+
.default('AVAILABLE')
|
|
241
|
+
.describe('Availability'),
|
|
242
242
|
})
|
|
243
|
-
.openapi({ title:
|
|
243
|
+
.openapi({ title: 'CreateWorker' });
|
|
244
244
|
exports.UpdateWorkerSchema = zod_1.z
|
|
245
245
|
.object({
|
|
246
|
-
firstName: zod_1.z.string().min(3).max(100).optional().describe(
|
|
246
|
+
firstName: zod_1.z.string().min(3).max(100).optional().describe('First Name'),
|
|
247
247
|
lastName: zod_1.z
|
|
248
248
|
.string()
|
|
249
249
|
.min(3)
|
|
250
250
|
.max(100)
|
|
251
251
|
.nullish()
|
|
252
|
-
.or(zod_1.z.literal(
|
|
253
|
-
.transform((val) => (val ===
|
|
254
|
-
.describe(
|
|
252
|
+
.or(zod_1.z.literal(''))
|
|
253
|
+
.transform((val) => (val === '' ? null : val))
|
|
254
|
+
.describe('Last Name'),
|
|
255
255
|
email: zod_1.z
|
|
256
256
|
.string()
|
|
257
257
|
.email()
|
|
258
258
|
.nullish()
|
|
259
|
-
.or(zod_1.z.literal(
|
|
260
|
-
.transform((val) => (val ===
|
|
261
|
-
.describe(
|
|
259
|
+
.or(zod_1.z.literal(''))
|
|
260
|
+
.transform((val) => (val === '' ? undefined : val))
|
|
261
|
+
.describe('Email'),
|
|
262
262
|
phoneNumbers: zod_1.z
|
|
263
263
|
.array(exports.UpsertWorkerPhoneNumberSchema)
|
|
264
|
-
.min(1, { message:
|
|
264
|
+
.min(1, { message: 'At least one phone number is required' })
|
|
265
265
|
.refine((phoneNumbers) => phoneNumbers.some((phone) => phone.isPrimary), {
|
|
266
|
-
message:
|
|
266
|
+
message: 'Must have at least one primary phone number',
|
|
267
267
|
})
|
|
268
268
|
.optional()
|
|
269
|
-
.describe(
|
|
269
|
+
.describe('Phone Numbers'),
|
|
270
270
|
nino: zod_1.z
|
|
271
271
|
.string()
|
|
272
272
|
.regex(/^(?:[A-Z]{2}[0-9]{6}[A-D])?$/)
|
|
273
273
|
.optional()
|
|
274
274
|
.nullable()
|
|
275
|
-
.describe(
|
|
275
|
+
.describe('National Insurance Number'),
|
|
276
276
|
dateOfBirth: zod_1.z
|
|
277
277
|
.union([zod_1.z.string().date(), zod_1.z.date()])
|
|
278
278
|
.optional()
|
|
279
279
|
.nullable()
|
|
280
|
-
.describe(
|
|
281
|
-
bio: zod_1.z.string().optional().nullable().describe(
|
|
280
|
+
.describe('Date of Birth'),
|
|
281
|
+
bio: zod_1.z.string().optional().nullable().describe('Bio'),
|
|
282
282
|
trades: zod_1.z
|
|
283
283
|
.array(exports.WorkerTradeSchema)
|
|
284
|
-
.min(1, { message:
|
|
284
|
+
.min(1, { message: 'At least one trade must be selected' })
|
|
285
285
|
.refine((trades) => trades.some((trade) => trade.mainTrade), {
|
|
286
|
-
message:
|
|
286
|
+
message: 'Exactly one trade must be marked as the main trade',
|
|
287
287
|
})
|
|
288
288
|
.optional()
|
|
289
|
-
.describe(
|
|
289
|
+
.describe('Trades'),
|
|
290
290
|
qualifications: zod_1.z
|
|
291
291
|
.array(exports.WorkerQualificationSchema)
|
|
292
292
|
.optional()
|
|
293
293
|
.nullable()
|
|
294
|
-
.describe(
|
|
294
|
+
.describe('Qualifications'),
|
|
295
295
|
englishLevel: common_schemas_1.EnglishLevelSchema.optional()
|
|
296
296
|
.nullable()
|
|
297
|
-
.describe(
|
|
297
|
+
.describe('English Level'),
|
|
298
298
|
nationality: common_schemas_1.NationalitySchema.optional()
|
|
299
299
|
.nullable()
|
|
300
|
-
.describe(
|
|
301
|
-
hasTools: zod_1.z.boolean().optional().describe(
|
|
302
|
-
hasPpe: zod_1.z.boolean().optional().describe(
|
|
303
|
-
location: common_schemas_1.CreateLocationSchema.optional().nullable().describe(
|
|
304
|
-
shareCode: exports.ShareCodeSchema.optional().nullable().describe(
|
|
305
|
-
availability: exports.AvailabilitySchema.optional().describe(
|
|
300
|
+
.describe('Nationality'),
|
|
301
|
+
hasTools: zod_1.z.boolean().optional().describe('Has Tools'),
|
|
302
|
+
hasPpe: zod_1.z.boolean().optional().describe('Has PPE'),
|
|
303
|
+
location: common_schemas_1.CreateLocationSchema.optional().nullable().describe('Location'),
|
|
304
|
+
shareCode: exports.ShareCodeSchema.optional().nullable().describe('Share Code'),
|
|
305
|
+
availability: exports.AvailabilitySchema.optional().describe('Availability'),
|
|
306
306
|
})
|
|
307
|
-
.openapi({ title:
|
|
307
|
+
.openapi({ title: 'UpdateWorker' });
|
|
308
308
|
exports.FilterWorkerSchema = pagination_query_schema_1.PaginationQuerySchema.extend({
|
|
309
|
-
name: zod_1.z.string().optional().describe(
|
|
310
|
-
email: zod_1.z.string().optional().describe(
|
|
311
|
-
phone: zod_1.z.string().optional().describe(
|
|
312
|
-
createdBy: zod_1.z.string().uuid().optional().describe(
|
|
309
|
+
name: zod_1.z.string().optional().describe('Search by name'),
|
|
310
|
+
email: zod_1.z.string().optional().describe('Filter by email'),
|
|
311
|
+
phone: zod_1.z.string().optional().describe('Filter by phone'),
|
|
312
|
+
createdBy: zod_1.z.string().uuid().optional().describe('Search Second Agent'),
|
|
313
313
|
availability: exports.AvailabilitySchema.optional()
|
|
314
314
|
.nullable()
|
|
315
|
-
.describe(
|
|
315
|
+
.describe('Availability'),
|
|
316
316
|
englishLevel: common_schemas_1.EnglishLevelSchema.optional()
|
|
317
317
|
.nullable()
|
|
318
|
-
.describe(
|
|
318
|
+
.describe('English level'),
|
|
319
319
|
nationality: common_schemas_1.NationalitySchema.optional()
|
|
320
320
|
.nullable()
|
|
321
|
-
.describe(
|
|
322
|
-
location: common_schemas_1.LocationFilterSchema.optional().describe(
|
|
323
|
-
hasTools: exports.BooleanFilterSchema.optional().describe(
|
|
324
|
-
hasPpe: exports.BooleanFilterSchema.optional().describe(
|
|
325
|
-
tradeFilters: zod_1.z.array(exports.TradeFilterSchema).optional().describe(
|
|
321
|
+
.describe('Filter by nationality'),
|
|
322
|
+
location: common_schemas_1.LocationFilterSchema.optional().describe('Filter by location'),
|
|
323
|
+
hasTools: exports.BooleanFilterSchema.optional().describe('Has Tools (default All)'),
|
|
324
|
+
hasPpe: exports.BooleanFilterSchema.optional().describe('Has PPE (default All)'),
|
|
325
|
+
tradeFilters: zod_1.z.array(exports.TradeFilterSchema).optional().describe('Trades'),
|
|
326
326
|
qualificationFilters: zod_1.z
|
|
327
327
|
.array(curated_workers_contract_1.QualificationFilterSchema)
|
|
328
328
|
.optional()
|
|
329
|
-
.describe(
|
|
330
|
-
createdAt: common_schemas_1.DateRangeSchema.optional().describe(
|
|
331
|
-
updatedAt: common_schemas_1.DateRangeSchema.optional().describe(
|
|
329
|
+
.describe('Qualifications'),
|
|
330
|
+
createdAt: common_schemas_1.DateRangeSchema.optional().describe('Filter by creation date'),
|
|
331
|
+
updatedAt: common_schemas_1.DateRangeSchema.optional().describe('Filter by update date'),
|
|
332
332
|
sortBy: exports.WorkerSortableFieldsSchema.optional()
|
|
333
333
|
.nullable()
|
|
334
|
-
.describe(
|
|
335
|
-
sortOrder: common_schemas_1.SortOrderSchema.optional().nullable().describe(
|
|
334
|
+
.describe('Sort by field'),
|
|
335
|
+
sortOrder: common_schemas_1.SortOrderSchema.optional().nullable().describe('Sort order'),
|
|
336
336
|
});
|
|
337
337
|
exports.PaginatedWorkerResponseSchema = (0, pagination_schema_1.createPaginatedResponseSchema)(exports.WorkerSchema)
|
|
338
|
-
.describe(
|
|
339
|
-
.openapi({ title:
|
|
338
|
+
.describe('Workers retrieved successfully.')
|
|
339
|
+
.openapi({ title: 'WorkersPaginatedResponse' });
|
|
340
340
|
// --- Contract ---
|
|
341
341
|
const c = (0, core_1.initContract)();
|
|
342
342
|
exports.workersContractRouter = c.router({
|
|
343
343
|
create: {
|
|
344
|
-
method:
|
|
345
|
-
path:
|
|
344
|
+
method: 'POST',
|
|
345
|
+
path: '/v2/workers',
|
|
346
346
|
responses: {
|
|
347
347
|
201: exports.WorkerSchema,
|
|
348
348
|
409: error_schemas_1.ErrorResponseSchema,
|
|
349
349
|
},
|
|
350
350
|
body: exports.CreateWorkerSchema,
|
|
351
|
-
summary:
|
|
352
|
-
metadata: { tags: [
|
|
351
|
+
summary: 'Create a new worker',
|
|
352
|
+
metadata: { tags: ['Workers'], openApi: { operationId: 'createWorker' } },
|
|
353
353
|
},
|
|
354
354
|
findAll: {
|
|
355
|
-
method:
|
|
356
|
-
path:
|
|
355
|
+
method: 'GET',
|
|
356
|
+
path: '/v2/workers',
|
|
357
357
|
responses: {
|
|
358
358
|
200: exports.PaginatedWorkerResponseSchema,
|
|
359
359
|
},
|
|
360
360
|
query: exports.FilterWorkerSchema,
|
|
361
|
-
summary:
|
|
361
|
+
summary: 'Get all workers',
|
|
362
362
|
metadata: {
|
|
363
|
-
tags: [
|
|
364
|
-
openApi: { operationId:
|
|
363
|
+
tags: ['Workers'],
|
|
364
|
+
openApi: { operationId: 'findAllWorkers' },
|
|
365
365
|
},
|
|
366
366
|
},
|
|
367
367
|
findOne: {
|
|
368
|
-
method:
|
|
369
|
-
path:
|
|
368
|
+
method: 'GET',
|
|
369
|
+
path: '/v2/workers/:id',
|
|
370
370
|
responses: {
|
|
371
371
|
200: exports.WorkerSchema,
|
|
372
372
|
404: error_schemas_1.ErrorResponseSchema,
|
|
373
373
|
},
|
|
374
374
|
pathParams: zod_1.z.object({
|
|
375
|
-
id: zod_1.z.string().uuid().describe(
|
|
375
|
+
id: zod_1.z.string().uuid().describe('Worker ID'),
|
|
376
376
|
}),
|
|
377
|
-
summary:
|
|
377
|
+
summary: 'Get a worker by ID',
|
|
378
378
|
metadata: {
|
|
379
|
-
tags: [
|
|
380
|
-
openApi: { operationId:
|
|
379
|
+
tags: ['Workers'],
|
|
380
|
+
openApi: { operationId: 'findWorkerById' },
|
|
381
381
|
},
|
|
382
382
|
},
|
|
383
383
|
update: {
|
|
384
|
-
method:
|
|
385
|
-
path:
|
|
384
|
+
method: 'PATCH',
|
|
385
|
+
path: '/v2/workers/:id',
|
|
386
386
|
responses: {
|
|
387
387
|
200: exports.WorkerSchema,
|
|
388
388
|
404: error_schemas_1.ErrorResponseSchema,
|
|
389
389
|
409: error_schemas_1.ErrorResponseSchema,
|
|
390
390
|
},
|
|
391
391
|
pathParams: zod_1.z.object({
|
|
392
|
-
id: zod_1.z.string().uuid().describe(
|
|
392
|
+
id: zod_1.z.string().uuid().describe('Worker ID'),
|
|
393
393
|
}),
|
|
394
394
|
body: exports.UpdateWorkerSchema,
|
|
395
|
-
summary:
|
|
396
|
-
metadata: { tags: [
|
|
395
|
+
summary: 'Update a worker',
|
|
396
|
+
metadata: { tags: ['Workers'], openApi: { operationId: 'updateWorker' } },
|
|
397
397
|
},
|
|
398
398
|
remove: {
|
|
399
|
-
method:
|
|
400
|
-
path:
|
|
399
|
+
method: 'DELETE',
|
|
400
|
+
path: '/v2/workers/:id',
|
|
401
401
|
responses: {
|
|
402
402
|
204: zod_1.z.undefined(),
|
|
403
403
|
404: error_schemas_1.ErrorResponseSchema,
|
|
404
404
|
},
|
|
405
405
|
pathParams: zod_1.z.object({
|
|
406
|
-
id: zod_1.z.string().uuid().describe(
|
|
406
|
+
id: zod_1.z.string().uuid().describe('Worker ID'),
|
|
407
407
|
}),
|
|
408
408
|
body: c.noBody(),
|
|
409
|
-
summary:
|
|
410
|
-
metadata: { tags: [
|
|
409
|
+
summary: 'Delete a worker',
|
|
410
|
+
metadata: { tags: ['Workers'], openApi: { operationId: 'deleteWorker' } },
|
|
411
411
|
},
|
|
412
412
|
}, {
|
|
413
413
|
commonResponses: {
|