@dakkitor/api-contracts 1.1.0 → 1.1.1

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.
@@ -0,0 +1,185 @@
1
+ import { z } from 'zod';
2
+ export declare const ClientContactSchema: z.ZodObject<{
3
+ id: z.ZodUUID;
4
+ clientId: z.ZodUUID;
5
+ client: z.ZodObject<{
6
+ id: z.ZodUUID;
7
+ name: z.ZodString;
8
+ crn: z.ZodString;
9
+ govLink: z.ZodURL;
10
+ status: z.ZodEnum<{
11
+ APPROVED: "APPROVED";
12
+ PENDING_VERIFICATION: "PENDING_VERIFICATION";
13
+ BLACKLISTED: "BLACKLISTED";
14
+ }>;
15
+ director: z.ZodString;
16
+ blacklistReason: z.ZodOptional<z.ZodNullable<z.ZodString>>;
17
+ lastUpdatedBy: z.ZodObject<{
18
+ id: z.ZodUUID;
19
+ firstName: z.ZodString;
20
+ lastName: z.ZodString;
21
+ email: z.ZodEmail;
22
+ }, z.core.$strip>;
23
+ createdAt: z.ZodISODateTime;
24
+ updatedAt: z.ZodISODateTime;
25
+ version: z.ZodNumber;
26
+ agentClientLinks: z.ZodObject<{
27
+ agentId: z.ZodString;
28
+ }, z.core.$strip>;
29
+ }, z.core.$strip>;
30
+ name: z.ZodString;
31
+ position: z.ZodOptional<z.ZodString>;
32
+ phone: z.ZodString;
33
+ email: z.ZodEmail;
34
+ source: z.ZodOptional<z.ZodString>;
35
+ createdBy: z.ZodObject<{
36
+ id: z.ZodUUID;
37
+ firstName: z.ZodString;
38
+ lastName: z.ZodString;
39
+ email: z.ZodEmail;
40
+ }, z.core.$strip>;
41
+ createdAt: z.ZodCoercedDate<unknown>;
42
+ updatedAt: z.ZodCoercedDate<unknown>;
43
+ version: z.ZodNumber;
44
+ }, z.core.$strip>;
45
+ export declare const CreateClientContactSchema: z.ZodObject<{
46
+ client: z.ZodObject<{
47
+ id: z.ZodUUID;
48
+ }, z.core.$strip>;
49
+ name: z.ZodString;
50
+ position: z.ZodOptional<z.ZodString>;
51
+ phone: z.ZodString;
52
+ email: z.ZodEmail;
53
+ source: z.ZodOptional<z.ZodString>;
54
+ }, z.core.$strip>;
55
+ export declare const CreateClientContactBodySchema: z.ZodObject<{
56
+ email: z.ZodEmail;
57
+ name: z.ZodString;
58
+ position: z.ZodOptional<z.ZodString>;
59
+ phone: z.ZodString;
60
+ source: z.ZodOptional<z.ZodString>;
61
+ }, z.core.$strip>;
62
+ export declare const UpdateClientContactSchema: z.ZodObject<{
63
+ email: z.ZodOptional<z.ZodEmail>;
64
+ name: z.ZodOptional<z.ZodString>;
65
+ version: z.ZodNumber;
66
+ position: z.ZodOptional<z.ZodOptional<z.ZodString>>;
67
+ phone: z.ZodOptional<z.ZodString>;
68
+ source: z.ZodOptional<z.ZodOptional<z.ZodString>>;
69
+ }, z.core.$strip>;
70
+ export declare const FilterClientContactSchema: z.ZodObject<{
71
+ page: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
72
+ limit: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
73
+ name: z.ZodOptional<z.ZodString>;
74
+ email: z.ZodOptional<z.ZodString>;
75
+ phone: z.ZodOptional<z.ZodString>;
76
+ clientId: z.ZodOptional<z.ZodUUID>;
77
+ createdById: z.ZodOptional<z.ZodUUID>;
78
+ sortBy: z.ZodDefault<z.ZodEnum<{
79
+ email: "email";
80
+ name: "name";
81
+ createdAt: "createdAt";
82
+ updatedAt: "updatedAt";
83
+ position: "position";
84
+ }>>;
85
+ sortOrder: z.ZodDefault<z.ZodEnum<{
86
+ ASC: "ASC";
87
+ DESC: "DESC";
88
+ }>>;
89
+ }, z.core.$strip>;
90
+ export type ClientContactV2 = z.infer<typeof ClientContactSchema>;
91
+ export type CreateClientContactV2 = z.infer<typeof CreateClientContactSchema>;
92
+ export type CreateClientContactBodyV2 = z.infer<typeof CreateClientContactBodySchema>;
93
+ export type UpdateClientContactV2 = z.infer<typeof UpdateClientContactSchema>;
94
+ export type FilterClientContactV2 = z.infer<typeof FilterClientContactSchema>;
95
+ export declare const clientContactsContract: {
96
+ create: {
97
+ [x: string]: any;
98
+ summary: "Create a new client contact";
99
+ method: "POST";
100
+ body: z.ZodObject<{
101
+ client: z.ZodObject<{
102
+ id: z.ZodUUID;
103
+ }, z.core.$strip>;
104
+ name: z.ZodString;
105
+ position: z.ZodOptional<z.ZodString>;
106
+ phone: z.ZodString;
107
+ email: z.ZodEmail;
108
+ source: z.ZodOptional<z.ZodString>;
109
+ }, z.core.$strip>;
110
+ };
111
+ createByClientId: {
112
+ [x: string]: any;
113
+ pathParams: z.ZodObject<{
114
+ clientId: z.ZodUUID;
115
+ }, z.core.$strip>;
116
+ summary: "Create a new contact for a specific client";
117
+ method: "POST";
118
+ body: z.ZodObject<{
119
+ email: z.ZodEmail;
120
+ name: z.ZodString;
121
+ position: z.ZodOptional<z.ZodString>;
122
+ phone: z.ZodString;
123
+ source: z.ZodOptional<z.ZodString>;
124
+ }, z.core.$strip>;
125
+ };
126
+ findAll: {
127
+ [x: string]: any;
128
+ query: z.ZodObject<{
129
+ page: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
130
+ limit: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
131
+ name: z.ZodOptional<z.ZodString>;
132
+ email: z.ZodOptional<z.ZodString>;
133
+ phone: z.ZodOptional<z.ZodString>;
134
+ clientId: z.ZodOptional<z.ZodUUID>;
135
+ createdById: z.ZodOptional<z.ZodUUID>;
136
+ sortBy: z.ZodDefault<z.ZodEnum<{
137
+ email: "email";
138
+ name: "name";
139
+ createdAt: "createdAt";
140
+ updatedAt: "updatedAt";
141
+ position: "position";
142
+ }>>;
143
+ sortOrder: z.ZodDefault<z.ZodEnum<{
144
+ ASC: "ASC";
145
+ DESC: "DESC";
146
+ }>>;
147
+ }, z.core.$strip>;
148
+ summary: "Get all client contacts";
149
+ method: "GET";
150
+ };
151
+ findOne: {
152
+ [x: string]: any;
153
+ pathParams: z.ZodObject<{
154
+ contactId: z.ZodUUID;
155
+ }, z.core.$strip>;
156
+ summary: "Get a client contact by ID";
157
+ method: "GET";
158
+ };
159
+ update: {
160
+ [x: string]: any;
161
+ pathParams: z.ZodObject<{
162
+ contactId: z.ZodUUID;
163
+ }, z.core.$strip>;
164
+ summary: "Update a client contact";
165
+ method: "PATCH";
166
+ body: z.ZodObject<{
167
+ email: z.ZodOptional<z.ZodEmail>;
168
+ name: z.ZodOptional<z.ZodString>;
169
+ version: z.ZodNumber;
170
+ position: z.ZodOptional<z.ZodOptional<z.ZodString>>;
171
+ phone: z.ZodOptional<z.ZodString>;
172
+ source: z.ZodOptional<z.ZodOptional<z.ZodString>>;
173
+ }, z.core.$strip>;
174
+ };
175
+ remove: {
176
+ [x: string]: any;
177
+ pathParams: z.ZodObject<{
178
+ contactId: z.ZodUUID;
179
+ }, z.core.$strip>;
180
+ summary: "Delete a client contact";
181
+ method: "DELETE";
182
+ body: typeof import("@ts-rest/core").ContractNoBody;
183
+ };
184
+ };
185
+ //# sourceMappingURL=client-contacts.contract.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client-contacts.contract.d.ts","sourceRoot":"","sources":["../../contracts/client-contacts/client-contacts.contract.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AA4BxB,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAa9B,CAAC;AAEH,eAAO,MAAM,yBAAyB;;;;;;;;;iBAOpC,CAAC;AAEH,eAAO,MAAM,6BAA6B;;;;;;iBAExC,CAAC;AAEH,eAAO,MAAM,yBAAyB;;;;;;;iBAIb,CAAC;AAE1B,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;iBAapC,CAAC;AAIH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAClE,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAC9E,MAAM,MAAM,yBAAyB,GAAG,CAAC,CAAC,KAAK,CAC7C,OAAO,6BAA6B,CACrC,CAAC;AACF,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAC9E,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAE9E,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqGlC,CAAC"}
@@ -0,0 +1,169 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.clientContactsContract = exports.FilterClientContactSchema = exports.UpdateClientContactSchema = exports.CreateClientContactBodySchema = exports.CreateClientContactSchema = exports.ClientContactSchema = void 0;
4
+ const core_1 = require("@ts-rest/core");
5
+ const zod_1 = require("zod");
6
+ const clients_contract_1 = require("../clients/clients.contract");
7
+ const error_schemas_1 = require("../common/error-schemas");
8
+ const pagination_schema_1 = require("../common/pagination.schema");
9
+ // Enums
10
+ const SortOrderSchema = zod_1.z.enum(['ASC', 'DESC']);
11
+ const ClientContactSortableFieldsSchema = zod_1.z.enum([
12
+ 'name',
13
+ 'position',
14
+ 'email',
15
+ 'createdAt',
16
+ 'updatedAt',
17
+ ]);
18
+ // Shared Schemas
19
+ const ResourceIdSchema = zod_1.z.object({
20
+ id: zod_1.z.uuid(),
21
+ });
22
+ // User Schema (duplicated from clients for now to avoid export issues, ideally should be in common)
23
+ const UserSchema = zod_1.z.object({
24
+ id: zod_1.z.uuid(),
25
+ firstName: zod_1.z.string(),
26
+ lastName: zod_1.z.string(),
27
+ email: zod_1.z.email(),
28
+ });
29
+ exports.ClientContactSchema = zod_1.z.object({
30
+ id: zod_1.z.uuid().describe('Contact ID'),
31
+ clientId: zod_1.z.uuid().describe('Client ID'),
32
+ client: clients_contract_1.ClientSchema.describe('Client Details'),
33
+ name: zod_1.z.string().describe('Contact Name'),
34
+ position: zod_1.z.string().optional().describe('Job Position'),
35
+ phone: zod_1.z.string().describe('Phone Number'),
36
+ email: zod_1.z.email().describe('Email Address'),
37
+ source: zod_1.z.string().optional().describe('Source'),
38
+ createdBy: UserSchema.describe('Created By'),
39
+ createdAt: zod_1.z.coerce.date().describe('Creation Date'),
40
+ updatedAt: zod_1.z.coerce.date().describe('Last Update Date'),
41
+ version: zod_1.z.number().describe('Version Number'),
42
+ });
43
+ exports.CreateClientContactSchema = zod_1.z.object({
44
+ client: ResourceIdSchema.describe('Client ID'),
45
+ name: zod_1.z.string().max(255).describe('Full Name'),
46
+ position: zod_1.z.string().max(255).optional().describe('Job Position'),
47
+ phone: zod_1.z.string().max(50).describe('Phone Number'),
48
+ email: zod_1.z.email().max(255).describe('Email Address'),
49
+ source: zod_1.z.string().max(255).optional().describe('Source'),
50
+ });
51
+ exports.CreateClientContactBodySchema = exports.CreateClientContactSchema.omit({
52
+ client: true,
53
+ });
54
+ exports.UpdateClientContactSchema = exports.CreateClientContactSchema.partial()
55
+ .extend({
56
+ version: zod_1.z.number().int().describe('Version for optimistic locking'),
57
+ })
58
+ .omit({ client: true }); // client cannot be updated via this endpoint usually
59
+ exports.FilterClientContactSchema = zod_1.z.object({
60
+ page: zod_1.z.coerce.number().default(1).describe('Page number'),
61
+ limit: zod_1.z.coerce.number().default(50).describe('Results per page'),
62
+ name: zod_1.z.string().optional().describe('Filter by name'),
63
+ email: zod_1.z.string().optional().describe('Filter by email'),
64
+ phone: zod_1.z.string().optional().describe('Filter by phone'),
65
+ clientId: zod_1.z.uuid().optional().describe('Search client'),
66
+ createdById: zod_1.z.uuid().optional().describe('Search by creator'),
67
+ sortBy: ClientContactSortableFieldsSchema.default('createdAt').describe('Sort field'),
68
+ sortOrder: SortOrderSchema.default('DESC').describe('Sort order'),
69
+ });
70
+ const c = (0, core_1.initContract)();
71
+ exports.clientContactsContract = c.router({
72
+ create: {
73
+ method: 'POST',
74
+ path: '/client-contacts',
75
+ responses: {
76
+ 201: exports.ClientContactSchema,
77
+ 400: error_schemas_1.ErrorResponseSchema,
78
+ 401: error_schemas_1.ErrorResponseSchema,
79
+ 403: error_schemas_1.ErrorResponseSchema,
80
+ 409: error_schemas_1.ErrorResponseSchema,
81
+ 500: error_schemas_1.ErrorResponseSchema,
82
+ },
83
+ body: exports.CreateClientContactSchema,
84
+ summary: 'Create a new client contact',
85
+ },
86
+ createByClientId: {
87
+ method: 'POST',
88
+ path: '/client-contacts/client/:clientId',
89
+ responses: {
90
+ 201: exports.ClientContactSchema,
91
+ 400: error_schemas_1.ErrorResponseSchema,
92
+ 401: error_schemas_1.ErrorResponseSchema,
93
+ 403: error_schemas_1.ErrorResponseSchema,
94
+ 409: error_schemas_1.ErrorResponseSchema,
95
+ 500: error_schemas_1.ErrorResponseSchema,
96
+ },
97
+ pathParams: zod_1.z.object({
98
+ clientId: zod_1.z.uuid(),
99
+ }),
100
+ body: exports.CreateClientContactBodySchema,
101
+ summary: 'Create a new contact for a specific client',
102
+ },
103
+ findAll: {
104
+ method: 'GET',
105
+ path: '/client-contacts',
106
+ responses: {
107
+ 200: (0, pagination_schema_1.createPaginatedResponseSchema)(exports.ClientContactSchema),
108
+ 400: error_schemas_1.ErrorResponseSchema,
109
+ 401: error_schemas_1.ErrorResponseSchema,
110
+ 403: error_schemas_1.ErrorResponseSchema,
111
+ 500: error_schemas_1.ErrorResponseSchema,
112
+ },
113
+ query: exports.FilterClientContactSchema,
114
+ summary: 'Get all client contacts',
115
+ },
116
+ findOne: {
117
+ method: 'GET',
118
+ path: '/client-contacts/:contactId',
119
+ responses: {
120
+ 200: exports.ClientContactSchema,
121
+ 400: error_schemas_1.ErrorResponseSchema,
122
+ 401: error_schemas_1.ErrorResponseSchema,
123
+ 403: error_schemas_1.ErrorResponseSchema,
124
+ 404: error_schemas_1.ErrorResponseSchema,
125
+ 500: error_schemas_1.ErrorResponseSchema,
126
+ },
127
+ pathParams: zod_1.z.object({
128
+ contactId: zod_1.z.uuid(),
129
+ }),
130
+ summary: 'Get a client contact by ID',
131
+ },
132
+ update: {
133
+ method: 'PATCH',
134
+ path: '/client-contacts/:contactId',
135
+ responses: {
136
+ 200: exports.ClientContactSchema,
137
+ 400: error_schemas_1.ErrorResponseSchema,
138
+ 401: error_schemas_1.ErrorResponseSchema,
139
+ 403: error_schemas_1.ErrorResponseSchema,
140
+ 404: error_schemas_1.ErrorResponseSchema,
141
+ 409: error_schemas_1.ErrorResponseSchema,
142
+ 500: error_schemas_1.ErrorResponseSchema,
143
+ },
144
+ pathParams: zod_1.z.object({
145
+ contactId: zod_1.z.uuid(),
146
+ }),
147
+ body: exports.UpdateClientContactSchema,
148
+ summary: 'Update a client contact',
149
+ },
150
+ remove: {
151
+ method: 'DELETE',
152
+ path: '/client-contacts/:contactId',
153
+ responses: {
154
+ 204: c.noBody(),
155
+ 400: error_schemas_1.ErrorResponseSchema,
156
+ 401: error_schemas_1.ErrorResponseSchema,
157
+ 403: error_schemas_1.ErrorResponseSchema,
158
+ 404: error_schemas_1.ErrorResponseSchema,
159
+ 500: error_schemas_1.ErrorResponseSchema,
160
+ },
161
+ pathParams: zod_1.z.object({
162
+ contactId: zod_1.z.uuid(),
163
+ }),
164
+ body: c.noBody(),
165
+ summary: 'Delete a client contact',
166
+ },
167
+ }, {
168
+ pathPrefix: '/v2',
169
+ });
@@ -1,9 +1,9 @@
1
1
  import { z } from 'zod';
2
2
  export declare const ClientSchema: z.ZodObject<{
3
- id: z.ZodString;
3
+ id: z.ZodUUID;
4
4
  name: z.ZodString;
5
5
  crn: z.ZodString;
6
- govLink: z.ZodString;
6
+ govLink: z.ZodURL;
7
7
  status: z.ZodEnum<{
8
8
  APPROVED: "APPROVED";
9
9
  PENDING_VERIFICATION: "PENDING_VERIFICATION";
@@ -12,13 +12,13 @@ export declare const ClientSchema: z.ZodObject<{
12
12
  director: z.ZodString;
13
13
  blacklistReason: z.ZodOptional<z.ZodNullable<z.ZodString>>;
14
14
  lastUpdatedBy: z.ZodObject<{
15
- id: z.ZodString;
15
+ id: z.ZodUUID;
16
16
  firstName: z.ZodString;
17
17
  lastName: z.ZodString;
18
- email: z.ZodString;
18
+ email: z.ZodEmail;
19
19
  }, z.core.$strip>;
20
- createdAt: z.ZodDate;
21
- updatedAt: z.ZodDate;
20
+ createdAt: z.ZodISODateTime;
21
+ updatedAt: z.ZodISODateTime;
22
22
  version: z.ZodNumber;
23
23
  agentClientLinks: z.ZodObject<{
24
24
  agentId: z.ZodString;
@@ -26,12 +26,12 @@ export declare const ClientSchema: z.ZodObject<{
26
26
  }, z.core.$strip>;
27
27
  export declare const CreateClientSchema: z.ZodObject<{
28
28
  name: z.ZodString;
29
- govLink: z.ZodString;
29
+ govLink: z.ZodURL;
30
30
  director: z.ZodString;
31
31
  }, z.core.$strip>;
32
32
  export declare const UpdateClientSchema: z.ZodObject<{
33
33
  name: z.ZodOptional<z.ZodString>;
34
- govLink: z.ZodOptional<z.ZodString>;
34
+ govLink: z.ZodOptional<z.ZodURL>;
35
35
  director: z.ZodOptional<z.ZodString>;
36
36
  status: z.ZodOptional<z.ZodEnum<{
37
37
  APPROVED: "APPROVED";
@@ -59,10 +59,10 @@ export declare const AutocompleteQuerySchema: z.ZodObject<{
59
59
  }, z.core.$strip>;
60
60
  export declare const PaginatedResponseSchema: z.ZodObject<{
61
61
  data: z.ZodArray<z.ZodObject<{
62
- id: z.ZodString;
62
+ id: z.ZodUUID;
63
63
  name: z.ZodString;
64
64
  crn: z.ZodString;
65
- govLink: z.ZodString;
65
+ govLink: z.ZodURL;
66
66
  status: z.ZodEnum<{
67
67
  APPROVED: "APPROVED";
68
68
  PENDING_VERIFICATION: "PENDING_VERIFICATION";
@@ -71,13 +71,13 @@ export declare const PaginatedResponseSchema: z.ZodObject<{
71
71
  director: z.ZodString;
72
72
  blacklistReason: z.ZodOptional<z.ZodNullable<z.ZodString>>;
73
73
  lastUpdatedBy: z.ZodObject<{
74
- id: z.ZodString;
74
+ id: z.ZodUUID;
75
75
  firstName: z.ZodString;
76
76
  lastName: z.ZodString;
77
- email: z.ZodString;
77
+ email: z.ZodEmail;
78
78
  }, z.core.$strip>;
79
- createdAt: z.ZodDate;
80
- updatedAt: z.ZodDate;
79
+ createdAt: z.ZodISODateTime;
80
+ updatedAt: z.ZodISODateTime;
81
81
  version: z.ZodNumber;
82
82
  agentClientLinks: z.ZodObject<{
83
83
  agentId: z.ZodString;
@@ -101,7 +101,7 @@ export declare const clientsContract: {
101
101
  method: "POST";
102
102
  body: z.ZodObject<{
103
103
  name: z.ZodString;
104
- govLink: z.ZodString;
104
+ govLink: z.ZodURL;
105
105
  director: z.ZodString;
106
106
  }, z.core.$strip>;
107
107
  };
@@ -131,7 +131,7 @@ export declare const clientsContract: {
131
131
  findOne: {
132
132
  [x: string]: any;
133
133
  pathParams: z.ZodObject<{
134
- id: z.ZodString;
134
+ id: z.ZodUUID;
135
135
  }, z.core.$strip>;
136
136
  summary: "Get a client by ID";
137
137
  method: "GET";
@@ -139,13 +139,13 @@ export declare const clientsContract: {
139
139
  update: {
140
140
  [x: string]: any;
141
141
  pathParams: z.ZodObject<{
142
- id: z.ZodString;
142
+ id: z.ZodUUID;
143
143
  }, z.core.$strip>;
144
144
  summary: "Update a client";
145
145
  method: "PATCH";
146
146
  body: z.ZodObject<{
147
147
  name: z.ZodOptional<z.ZodString>;
148
- govLink: z.ZodOptional<z.ZodString>;
148
+ govLink: z.ZodOptional<z.ZodURL>;
149
149
  director: z.ZodOptional<z.ZodString>;
150
150
  status: z.ZodOptional<z.ZodEnum<{
151
151
  APPROVED: "APPROVED";
@@ -158,7 +158,7 @@ export declare const clientsContract: {
158
158
  remove: {
159
159
  [x: string]: any;
160
160
  pathParams: z.ZodObject<{
161
- id: z.ZodString;
161
+ id: z.ZodUUID;
162
162
  }, z.core.$strip>;
163
163
  summary: "Delete a client";
164
164
  method: "DELETE";
@@ -1 +1 @@
1
- {"version":3,"file":"clients.contract.d.ts","sourceRoot":"","sources":["../../contracts/clients/clients.contract.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAgBxB,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;iBAiBvB,CAAC;AAEH,eAAO,MAAM,kBAAkB;;;;iBAI7B,CAAC;AAEH,eAAO,MAAM,kBAAkB;;;;;;;;;;iBA4B5B,CAAC;AAEJ,eAAO,MAAM,kBAAkB;;;;;;;;;iBAK7B,CAAC;AAEH,eAAO,MAAM,gCAAgC;;;iBAG3C,CAAC;AAEH,eAAO,MAAM,uBAAuB;;iBAElC,CAAC;AAEH,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAKlC,CAAC;AAIH,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAC;AACpD,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAChE,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAChE,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAChE,MAAM,MAAM,4BAA4B,GAAG,CAAC,CAAC,KAAK,CAChD,OAAO,gCAAgC,CACxC,CAAC;AACF,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAC1E,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAE1E,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiG3B,CAAC"}
1
+ {"version":3,"file":"clients.contract.d.ts","sourceRoot":"","sources":["../../contracts/clients/clients.contract.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAiBxB,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;iBAiBvB,CAAC;AAEH,eAAO,MAAM,kBAAkB;;;;iBAI7B,CAAC;AAEH,eAAO,MAAM,kBAAkB;;;;;;;;;;iBA2B5B,CAAC;AAEJ,eAAO,MAAM,kBAAkB;;;;;;;;;iBAK7B,CAAC;AAEH,eAAO,MAAM,gCAAgC;;;iBAG3C,CAAC;AAEH,eAAO,MAAM,uBAAuB;;iBAElC,CAAC;AAEH,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBACS,CAAC;AAI9C,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAC;AACpD,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAChE,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAChE,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAChE,MAAM,MAAM,4BAA4B,GAAG,CAAC,CAAC,KAAK,CAChD,OAAO,gCAAgC,CACxC,CAAC;AACF,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAC1E,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAE1E,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiG3B,CAAC"}
@@ -4,22 +4,23 @@ exports.clientsContract = exports.PaginatedResponseSchema = exports.Autocomplete
4
4
  const core_1 = require("@ts-rest/core");
5
5
  const zod_1 = require("zod");
6
6
  const error_schemas_1 = require("../common/error-schemas");
7
+ const pagination_schema_1 = require("../common/pagination.schema");
7
8
  const ClientStatusSchema = zod_1.z.enum([
8
9
  'APPROVED',
9
10
  'PENDING_VERIFICATION',
10
11
  'BLACKLISTED',
11
12
  ]);
12
13
  const UserSchema = zod_1.z.object({
13
- id: zod_1.z.string().uuid(),
14
+ id: zod_1.z.uuid(),
14
15
  firstName: zod_1.z.string(),
15
16
  lastName: zod_1.z.string(),
16
- email: zod_1.z.string().email(),
17
+ email: zod_1.z.email(),
17
18
  });
18
19
  exports.ClientSchema = zod_1.z.object({
19
- id: zod_1.z.string().uuid().describe('Client ID'),
20
+ id: zod_1.z.uuid().describe('Client ID'),
20
21
  name: zod_1.z.string().describe('Client Name'),
21
22
  crn: zod_1.z.string().describe('Company Registration Number'),
22
- govLink: zod_1.z.string().url().describe('Government Registration Link'),
23
+ govLink: zod_1.z.url().describe('Government Registration Link'),
23
24
  status: ClientStatusSchema.describe('Client Status'),
24
25
  director: zod_1.z.string().describe('Director Name'),
25
26
  blacklistReason: zod_1.z
@@ -28,21 +29,20 @@ exports.ClientSchema = zod_1.z.object({
28
29
  .optional()
29
30
  .describe('Reason for Blacklisting'),
30
31
  lastUpdatedBy: UserSchema.describe('Last Updated By'),
31
- createdAt: zod_1.z.date().describe('Creation Date'),
32
- updatedAt: zod_1.z.date().describe('Last Update Date'),
32
+ createdAt: zod_1.z.iso.datetime().describe('Creation Date'),
33
+ updatedAt: zod_1.z.iso.datetime().describe('Last Update Date'),
33
34
  version: zod_1.z.number().describe('Version Number'),
34
35
  agentClientLinks: zod_1.z.object({ agentId: zod_1.z.string() }).describe('Agent Link'),
35
36
  });
36
37
  exports.CreateClientSchema = zod_1.z.object({
37
38
  name: zod_1.z.string().max(255).describe('Client Name'),
38
- govLink: zod_1.z.string().url().max(2048).describe('Government Registration Link'),
39
+ govLink: zod_1.z.url().max(2048).describe('Government Registration Link'),
39
40
  director: zod_1.z.string().max(255).describe('Director Name'),
40
41
  });
41
42
  exports.UpdateClientSchema = zod_1.z
42
43
  .object({
43
44
  name: zod_1.z.string().max(255).optional().describe('Client Name'),
44
45
  govLink: zod_1.z
45
- .string()
46
46
  .url()
47
47
  .max(2048)
48
48
  .optional()
@@ -77,12 +77,7 @@ exports.ClientAutocompleteResponseSchema = zod_1.z.object({
77
77
  exports.AutocompleteQuerySchema = zod_1.z.object({
78
78
  search: zod_1.z.string().optional().describe('Search...'),
79
79
  });
80
- exports.PaginatedResponseSchema = zod_1.z.object({
81
- data: zod_1.z.array(exports.ClientSchema).describe('Client records'),
82
- total: zod_1.z.number().describe('Total count'),
83
- limit: zod_1.z.number().describe('Results per page'),
84
- skip: zod_1.z.number().describe('Records skipped'),
85
- });
80
+ exports.PaginatedResponseSchema = (0, pagination_schema_1.createPaginatedResponseSchema)(exports.ClientSchema);
86
81
  const c = (0, core_1.initContract)();
87
82
  exports.clientsContract = c.router({
88
83
  create: {
@@ -137,7 +132,7 @@ exports.clientsContract = c.router({
137
132
  500: error_schemas_1.ErrorResponseSchema,
138
133
  },
139
134
  pathParams: zod_1.z.object({
140
- id: zod_1.z.string().uuid(),
135
+ id: zod_1.z.uuid(),
141
136
  }),
142
137
  summary: 'Get a client by ID',
143
138
  },
@@ -154,7 +149,7 @@ exports.clientsContract = c.router({
154
149
  500: error_schemas_1.ErrorResponseSchema,
155
150
  },
156
151
  pathParams: zod_1.z.object({
157
- id: zod_1.z.string().uuid(),
152
+ id: zod_1.z.uuid(),
158
153
  }),
159
154
  body: exports.UpdateClientSchema,
160
155
  summary: 'Update a client',
@@ -171,7 +166,7 @@ exports.clientsContract = c.router({
171
166
  500: error_schemas_1.ErrorResponseSchema,
172
167
  },
173
168
  pathParams: zod_1.z.object({
174
- id: zod_1.z.string().uuid(),
169
+ id: zod_1.z.uuid(),
175
170
  }),
176
171
  body: zod_1.z.undefined(),
177
172
  summary: 'Delete a client',
@@ -0,0 +1,8 @@
1
+ import { z } from 'zod';
2
+ export declare const createPaginatedResponseSchema: <T extends z.ZodTypeAny>(itemSchema: T) => z.ZodObject<{
3
+ data: z.ZodArray<T>;
4
+ total: z.ZodNumber;
5
+ limit: z.ZodNumber;
6
+ skip: z.ZodNumber;
7
+ }, z.core.$strip>;
8
+ //# sourceMappingURL=pagination.schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pagination.schema.d.ts","sourceRoot":"","sources":["../../contracts/common/pagination.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,6BAA6B,GAAI,CAAC,SAAS,CAAC,CAAC,UAAU,EAClE,YAAY,CAAC;;;;;iBAQd,CAAC"}
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createPaginatedResponseSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ const createPaginatedResponseSchema = (itemSchema) => {
6
+ return zod_1.z.object({
7
+ data: zod_1.z.array(itemSchema).describe('Records'),
8
+ total: zod_1.z.number().describe('Total count'),
9
+ limit: zod_1.z.number().describe('Results per page'),
10
+ skip: zod_1.z.number().describe('Records skipped'),
11
+ });
12
+ };
13
+ exports.createPaginatedResponseSchema = createPaginatedResponseSchema;
package/dist/index.d.ts CHANGED
@@ -1,3 +1,168 @@
1
+ export * from './client-contacts/client-contacts.contract';
1
2
  export * from './clients/clients.contract';
2
3
  export * from './common/error-schemas';
4
+ export * from './common/pagination.schema';
5
+ export declare const apiContract: {
6
+ clients: {
7
+ create: {
8
+ [x: string]: any;
9
+ summary: "Create a new client";
10
+ method: "POST";
11
+ body: import("zod").ZodObject<{
12
+ name: import("zod").ZodString;
13
+ govLink: import("zod").ZodURL;
14
+ director: import("zod").ZodString;
15
+ }, import("zod/v4/core").$strip>;
16
+ };
17
+ findAll: {
18
+ [x: string]: any;
19
+ query: import("zod").ZodObject<{
20
+ limit: import("zod").ZodDefault<import("zod").ZodCoercedNumber<unknown>>;
21
+ page: import("zod").ZodDefault<import("zod").ZodCoercedNumber<unknown>>;
22
+ search: import("zod").ZodOptional<import("zod").ZodString>;
23
+ status: import("zod").ZodOptional<import("zod").ZodEnum<{
24
+ APPROVED: "APPROVED";
25
+ PENDING_VERIFICATION: "PENDING_VERIFICATION";
26
+ BLACKLISTED: "BLACKLISTED";
27
+ }>>;
28
+ }, import("zod/v4/core").$strip>;
29
+ summary: "Get all clients";
30
+ method: "GET";
31
+ };
32
+ autocomplete: {
33
+ [x: string]: any;
34
+ query: import("zod").ZodObject<{
35
+ search: import("zod").ZodOptional<import("zod").ZodString>;
36
+ }, import("zod/v4/core").$strip>;
37
+ summary: "Get clients for autocomplete";
38
+ method: "GET";
39
+ };
40
+ findOne: {
41
+ [x: string]: any;
42
+ pathParams: import("zod").ZodObject<{
43
+ id: import("zod").ZodUUID;
44
+ }, import("zod/v4/core").$strip>;
45
+ summary: "Get a client by ID";
46
+ method: "GET";
47
+ };
48
+ update: {
49
+ [x: string]: any;
50
+ pathParams: import("zod").ZodObject<{
51
+ id: import("zod").ZodUUID;
52
+ }, import("zod/v4/core").$strip>;
53
+ summary: "Update a client";
54
+ method: "PATCH";
55
+ body: import("zod").ZodObject<{
56
+ name: import("zod").ZodOptional<import("zod").ZodString>;
57
+ govLink: import("zod").ZodOptional<import("zod").ZodURL>;
58
+ director: import("zod").ZodOptional<import("zod").ZodString>;
59
+ status: import("zod").ZodOptional<import("zod").ZodEnum<{
60
+ APPROVED: "APPROVED";
61
+ PENDING_VERIFICATION: "PENDING_VERIFICATION";
62
+ BLACKLISTED: "BLACKLISTED";
63
+ }>>;
64
+ blacklistReason: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodString>>;
65
+ }, import("zod/v4/core").$strip>;
66
+ };
67
+ remove: {
68
+ [x: string]: any;
69
+ pathParams: import("zod").ZodObject<{
70
+ id: import("zod").ZodUUID;
71
+ }, import("zod/v4/core").$strip>;
72
+ summary: "Delete a client";
73
+ method: "DELETE";
74
+ body: import("zod").ZodUndefined;
75
+ };
76
+ };
77
+ clientContacts: {
78
+ create: {
79
+ [x: string]: any;
80
+ summary: "Create a new client contact";
81
+ method: "POST";
82
+ body: import("zod").ZodObject<{
83
+ client: import("zod").ZodObject<{
84
+ id: import("zod").ZodUUID;
85
+ }, import("zod/v4/core").$strip>;
86
+ name: import("zod").ZodString;
87
+ position: import("zod").ZodOptional<import("zod").ZodString>;
88
+ phone: import("zod").ZodString;
89
+ email: import("zod").ZodEmail;
90
+ source: import("zod").ZodOptional<import("zod").ZodString>;
91
+ }, import("zod/v4/core").$strip>;
92
+ };
93
+ createByClientId: {
94
+ [x: string]: any;
95
+ pathParams: import("zod").ZodObject<{
96
+ clientId: import("zod").ZodUUID;
97
+ }, import("zod/v4/core").$strip>;
98
+ summary: "Create a new contact for a specific client";
99
+ method: "POST";
100
+ body: import("zod").ZodObject<{
101
+ email: import("zod").ZodEmail;
102
+ name: import("zod").ZodString;
103
+ position: import("zod").ZodOptional<import("zod").ZodString>;
104
+ phone: import("zod").ZodString;
105
+ source: import("zod").ZodOptional<import("zod").ZodString>;
106
+ }, import("zod/v4/core").$strip>;
107
+ };
108
+ findAll: {
109
+ [x: string]: any;
110
+ query: import("zod").ZodObject<{
111
+ page: import("zod").ZodDefault<import("zod").ZodCoercedNumber<unknown>>;
112
+ limit: import("zod").ZodDefault<import("zod").ZodCoercedNumber<unknown>>;
113
+ name: import("zod").ZodOptional<import("zod").ZodString>;
114
+ email: import("zod").ZodOptional<import("zod").ZodString>;
115
+ phone: import("zod").ZodOptional<import("zod").ZodString>;
116
+ clientId: import("zod").ZodOptional<import("zod").ZodUUID>;
117
+ createdById: import("zod").ZodOptional<import("zod").ZodUUID>;
118
+ sortBy: import("zod").ZodDefault<import("zod").ZodEnum<{
119
+ email: "email";
120
+ name: "name";
121
+ createdAt: "createdAt";
122
+ updatedAt: "updatedAt";
123
+ position: "position";
124
+ }>>;
125
+ sortOrder: import("zod").ZodDefault<import("zod").ZodEnum<{
126
+ ASC: "ASC";
127
+ DESC: "DESC";
128
+ }>>;
129
+ }, import("zod/v4/core").$strip>;
130
+ summary: "Get all client contacts";
131
+ method: "GET";
132
+ };
133
+ findOne: {
134
+ [x: string]: any;
135
+ pathParams: import("zod").ZodObject<{
136
+ contactId: import("zod").ZodUUID;
137
+ }, import("zod/v4/core").$strip>;
138
+ summary: "Get a client contact by ID";
139
+ method: "GET";
140
+ };
141
+ update: {
142
+ [x: string]: any;
143
+ pathParams: import("zod").ZodObject<{
144
+ contactId: import("zod").ZodUUID;
145
+ }, import("zod/v4/core").$strip>;
146
+ summary: "Update a client contact";
147
+ method: "PATCH";
148
+ body: import("zod").ZodObject<{
149
+ email: import("zod").ZodOptional<import("zod").ZodEmail>;
150
+ name: import("zod").ZodOptional<import("zod").ZodString>;
151
+ version: import("zod").ZodNumber;
152
+ position: import("zod").ZodOptional<import("zod").ZodOptional<import("zod").ZodString>>;
153
+ phone: import("zod").ZodOptional<import("zod").ZodString>;
154
+ source: import("zod").ZodOptional<import("zod").ZodOptional<import("zod").ZodString>>;
155
+ }, import("zod/v4/core").$strip>;
156
+ };
157
+ remove: {
158
+ [x: string]: any;
159
+ pathParams: import("zod").ZodObject<{
160
+ contactId: import("zod").ZodUUID;
161
+ }, import("zod/v4/core").$strip>;
162
+ summary: "Delete a client contact";
163
+ method: "DELETE";
164
+ body: typeof import("@ts-rest/core").ContractNoBody;
165
+ };
166
+ };
167
+ };
3
168
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../contracts/index.ts"],"names":[],"mappings":"AACA,cAAc,4BAA4B,CAAC;AAC3C,cAAc,wBAAwB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../contracts/index.ts"],"names":[],"mappings":"AAAA,cAAc,4CAA4C,CAAC;AAC3D,cAAc,4BAA4B,CAAC;AAC3C,cAAc,wBAAwB,CAAC;AACvC,cAAc,4BAA4B,CAAC;AAQ3C,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAGtB,CAAC"}
package/dist/index.js CHANGED
@@ -14,6 +14,16 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- // Export all contracts
17
+ exports.apiContract = void 0;
18
+ __exportStar(require("./client-contacts/client-contacts.contract"), exports);
18
19
  __exportStar(require("./clients/clients.contract"), exports);
19
20
  __exportStar(require("./common/error-schemas"), exports);
21
+ __exportStar(require("./common/pagination.schema"), exports);
22
+ const core_1 = require("@ts-rest/core");
23
+ const client_contacts_contract_1 = require("./client-contacts/client-contacts.contract");
24
+ const clients_contract_1 = require("./clients/clients.contract");
25
+ const c = (0, core_1.initContract)();
26
+ exports.apiContract = c.router({
27
+ clients: clients_contract_1.clientsContract,
28
+ clientContacts: client_contacts_contract_1.clientContactsContract,
29
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dakkitor/api-contracts",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "description": "TypeScript API contracts using ts-rest and Zod",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",