@dakkitor/api-contracts 1.0.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
+ });