@colior115/all-connected-be-sdk 1.0.37 → 1.0.38
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/package.json +1 -1
- package/src/clients/project.client.ts +14 -2
- package/src/types.ts +25 -2
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { request, SdkConfig } from "../http";
|
|
2
|
-
import { ProjectListResponseDTO, ProjectDetailDTO, ProjectDetailListResponseDTO, CreateProjectInputDTO, UpdateProjectInputDTO } from "../types";
|
|
2
|
+
import { ProjectDTO, ProjectListResponseDTO, ProjectDetailDTO, ProjectDetailListResponseDTO, CreateProjectInputDTO, UpdateProjectInputDTO, AddProjectEmployeeInputDTO } from "../types";
|
|
3
3
|
|
|
4
4
|
export type GetProjectsParams = {
|
|
5
5
|
page?: number;
|
|
@@ -21,8 +21,11 @@ export const createProjectClient = (config: SdkConfig) => ({
|
|
|
21
21
|
getAllByCustomer: (customerId: string, params: GetProjectsParams = {}) =>
|
|
22
22
|
request<ProjectDetailListResponseDTO>(config, `/api/project/customer/${customerId}${buildQs(params)}`, { withBusinessToken: true }),
|
|
23
23
|
|
|
24
|
+
getAllByEmployee: (employeeId: string, params: GetProjectsParams = {}) =>
|
|
25
|
+
request<ProjectListResponseDTO>(config, `/api/projects/byEmployee/${employeeId}${buildQs(params)}`, { withBusinessToken: true }),
|
|
26
|
+
|
|
24
27
|
get: (id: string) =>
|
|
25
|
-
request<
|
|
28
|
+
request<ProjectDTO>(config, `/api/project/${id}`, { withBusinessToken: true }),
|
|
26
29
|
|
|
27
30
|
create: (input: CreateProjectInputDTO) =>
|
|
28
31
|
request<ProjectDetailDTO>(config, "/api/project", { method: "POST", body: input, withBusinessToken: true }),
|
|
@@ -32,4 +35,13 @@ export const createProjectClient = (config: SdkConfig) => ({
|
|
|
32
35
|
|
|
33
36
|
delete: (id: string) =>
|
|
34
37
|
request<ProjectDetailDTO>(config, `/api/project/${id}`, { method: "DELETE", withBusinessToken: true }),
|
|
38
|
+
|
|
39
|
+
addEmployee: (projectId: string, input: AddProjectEmployeeInputDTO) =>
|
|
40
|
+
request<{ projectId: string; employeeId: string }>(config, `/api/project/${projectId}/employees`, { method: "POST", body: input, withBusinessToken: true }),
|
|
41
|
+
|
|
42
|
+
updateEmployee: (projectId: string, employeeId: string, input: Pick<AddProjectEmployeeInputDTO, "amountOfTime">) =>
|
|
43
|
+
request<void>(config, `/api/project/${projectId}/employees/${employeeId}`, { method: "PUT", body: input, withBusinessToken: true }),
|
|
44
|
+
|
|
45
|
+
removeEmployee: (projectId: string, employeeId: string) =>
|
|
46
|
+
request<void>(config, `/api/project/${projectId}/employees/${employeeId}`, { method: "DELETE", withBusinessToken: true }),
|
|
35
47
|
});
|
package/src/types.ts
CHANGED
|
@@ -135,6 +135,10 @@ export type NextPaymentDTO = {
|
|
|
135
135
|
milestone?: string;
|
|
136
136
|
};
|
|
137
137
|
|
|
138
|
+
export type AmountOfTimeDTO =
|
|
139
|
+
| { unit: "full"; value?: never }
|
|
140
|
+
| { unit: "months" | "days" | "hours"; value: number };
|
|
141
|
+
|
|
138
142
|
export type ProjectCustomerDTO = {
|
|
139
143
|
id: string;
|
|
140
144
|
name: string;
|
|
@@ -144,7 +148,21 @@ export type ProjectCustomerDTO = {
|
|
|
144
148
|
email?: string;
|
|
145
149
|
};
|
|
146
150
|
|
|
147
|
-
//
|
|
151
|
+
// Used for employee input (create/update) and plain table responses
|
|
152
|
+
export type ProjectEmployeeInputDTO = {
|
|
153
|
+
employeeId: string;
|
|
154
|
+
amountOfTime: AmountOfTimeDTO;
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
// Enriched employee shape returned by view-based endpoints (includes names)
|
|
158
|
+
export type ProjectEmployeeDTO = {
|
|
159
|
+
employeeId: string;
|
|
160
|
+
firstName: string;
|
|
161
|
+
lastName: string;
|
|
162
|
+
amountOfTime: AmountOfTimeDTO;
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
// Returned by getAllByBusiness, get, getAllByEmployee — includes customer + enriched employees
|
|
148
166
|
export type ProjectDTO = {
|
|
149
167
|
id: string;
|
|
150
168
|
businessId: string;
|
|
@@ -154,6 +172,7 @@ export type ProjectDTO = {
|
|
|
154
172
|
currency: string;
|
|
155
173
|
toBePaidAmount?: number;
|
|
156
174
|
nextPayment?: NextPaymentDTO;
|
|
175
|
+
employees: ProjectEmployeeDTO[];
|
|
157
176
|
};
|
|
158
177
|
|
|
159
178
|
export type ProjectListResponseDTO = {
|
|
@@ -163,7 +182,7 @@ export type ProjectListResponseDTO = {
|
|
|
163
182
|
limit: number;
|
|
164
183
|
};
|
|
165
184
|
|
|
166
|
-
// Returned by getAllByCustomer
|
|
185
|
+
// Returned by getAllByCustomer, create, update, delete — plain project with customerId + raw employees
|
|
167
186
|
export type ProjectDetailDTO = {
|
|
168
187
|
id: string;
|
|
169
188
|
businessId: string;
|
|
@@ -173,6 +192,7 @@ export type ProjectDetailDTO = {
|
|
|
173
192
|
currency: string;
|
|
174
193
|
toBePaidAmount?: number;
|
|
175
194
|
nextPayment?: NextPaymentDTO;
|
|
195
|
+
employees: ProjectEmployeeInputDTO[];
|
|
176
196
|
};
|
|
177
197
|
|
|
178
198
|
export type ProjectDetailListResponseDTO = {
|
|
@@ -190,5 +210,8 @@ export type CreateProjectInputDTO = {
|
|
|
190
210
|
totalPaidAmount?: number;
|
|
191
211
|
toBePaidAmount?: number;
|
|
192
212
|
nextPayment?: NextPaymentDTO;
|
|
213
|
+
employees?: ProjectEmployeeInputDTO[];
|
|
193
214
|
};
|
|
194
215
|
export type UpdateProjectInputDTO = Partial<CreateProjectInputDTO>;
|
|
216
|
+
|
|
217
|
+
export type AddProjectEmployeeInputDTO = ProjectEmployeeInputDTO;
|