@colior115/all-connected-be-sdk 1.0.36 → 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 CHANGED
@@ -7,7 +7,7 @@
7
7
  "type": "git",
8
8
  "url": "https://github.com/colior115/allConnectedBE.git"
9
9
  },
10
- "version": "1.0.36",
10
+ "version": "1.0.38",
11
11
  "type": "module",
12
12
  "main": "src/index.ts",
13
13
  "types": "src/index.ts",
@@ -1,5 +1,5 @@
1
1
  import { request, SdkConfig } from "../http";
2
- import { ProjectDTO, ProjectListResponseDTO, 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;
@@ -19,17 +19,29 @@ export const createProjectClient = (config: SdkConfig) => ({
19
19
  request<ProjectListResponseDTO>(config, `/api/project/${businessId}/all${buildQs(params)}`, { withBusinessToken: true }),
20
20
 
21
21
  getAllByCustomer: (customerId: string, params: GetProjectsParams = {}) =>
22
- request<ProjectListResponseDTO>(config, `/api/project/customer/${customerId}${buildQs(params)}`, { withBusinessToken: true }),
22
+ request<ProjectDetailListResponseDTO>(config, `/api/project/customer/${customerId}${buildQs(params)}`, { withBusinessToken: true }),
23
+
24
+ getAllByEmployee: (employeeId: string, params: GetProjectsParams = {}) =>
25
+ request<ProjectListResponseDTO>(config, `/api/projects/byEmployee/${employeeId}${buildQs(params)}`, { withBusinessToken: true }),
23
26
 
24
27
  get: (id: string) =>
25
28
  request<ProjectDTO>(config, `/api/project/${id}`, { withBusinessToken: true }),
26
29
 
27
30
  create: (input: CreateProjectInputDTO) =>
28
- request<ProjectDTO>(config, "/api/project", { method: "POST", body: input, withBusinessToken: true }),
31
+ request<ProjectDetailDTO>(config, "/api/project", { method: "POST", body: input, withBusinessToken: true }),
29
32
 
30
33
  update: (id: string, input: UpdateProjectInputDTO) =>
31
- request<ProjectDTO>(config, `/api/project/${id}`, { method: "PUT", body: input, withBusinessToken: true }),
34
+ request<ProjectDetailDTO>(config, `/api/project/${id}`, { method: "PUT", body: input, withBusinessToken: true }),
32
35
 
33
36
  delete: (id: string) =>
34
- request<ProjectDTO>(config, `/api/project/${id}`, { method: "DELETE", withBusinessToken: true }),
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
@@ -1,7 +1,7 @@
1
1
  // ── Shared primitives ─────────────────────────────────────────────────────────
2
2
 
3
3
  export type UserSystemRole = "admin" | "user";
4
- export type AppArea = "employees" | "accounts" | "customers";
4
+ export type AppArea = "employees" | "accounts" | "customers" | "business" | "business_roles" | "projects";
5
5
  export type PermissionLevel = "EDIT" | "VIEW" | "NONE";
6
6
  export type Permissions = { [K in AppArea]: PermissionLevel };
7
7
  export type EmploymentStatus = "active" | "terminated" | "on_leave";
@@ -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,6 +148,21 @@ export type ProjectCustomerDTO = {
144
148
  email?: string;
145
149
  };
146
150
 
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
147
166
  export type ProjectDTO = {
148
167
  id: string;
149
168
  businessId: string;
@@ -153,6 +172,7 @@ export type ProjectDTO = {
153
172
  currency: string;
154
173
  toBePaidAmount?: number;
155
174
  nextPayment?: NextPaymentDTO;
175
+ employees: ProjectEmployeeDTO[];
156
176
  };
157
177
 
158
178
  export type ProjectListResponseDTO = {
@@ -162,6 +182,26 @@ export type ProjectListResponseDTO = {
162
182
  limit: number;
163
183
  };
164
184
 
185
+ // Returned by getAllByCustomer, create, update, delete — plain project with customerId + raw employees
186
+ export type ProjectDetailDTO = {
187
+ id: string;
188
+ businessId: string;
189
+ customerId: string;
190
+ totalContractAmount: number;
191
+ totalPaidAmount?: number;
192
+ currency: string;
193
+ toBePaidAmount?: number;
194
+ nextPayment?: NextPaymentDTO;
195
+ employees: ProjectEmployeeInputDTO[];
196
+ };
197
+
198
+ export type ProjectDetailListResponseDTO = {
199
+ data: ProjectDetailDTO[];
200
+ total: number;
201
+ page: number;
202
+ limit: number;
203
+ };
204
+
165
205
  export type CreateProjectInputDTO = {
166
206
  businessId: string;
167
207
  customerId: string;
@@ -170,5 +210,8 @@ export type CreateProjectInputDTO = {
170
210
  totalPaidAmount?: number;
171
211
  toBePaidAmount?: number;
172
212
  nextPayment?: NextPaymentDTO;
213
+ employees?: ProjectEmployeeInputDTO[];
173
214
  };
174
215
  export type UpdateProjectInputDTO = Partial<CreateProjectInputDTO>;
216
+
217
+ export type AddProjectEmployeeInputDTO = ProjectEmployeeInputDTO;