@colior115/all-connected-be-sdk 1.0.28 → 1.0.35

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.28",
10
+ "version": "1.0.35",
11
11
  "type": "module",
12
12
  "main": "src/index.ts",
13
13
  "types": "src/index.ts",
@@ -0,0 +1,35 @@
1
+ import { request, SdkConfig } from "../http";
2
+ import { ProjectDTO, ProjectListResponseDTO, CreateProjectInputDTO, UpdateProjectInputDTO } from "../types";
3
+
4
+ export type GetProjectsParams = {
5
+ page?: number;
6
+ limit?: number;
7
+ };
8
+
9
+ const buildQs = (params: GetProjectsParams): string => {
10
+ const q = new URLSearchParams();
11
+ if (params.page !== undefined) q.set("page", String(params.page));
12
+ if (params.limit !== undefined) q.set("limit", String(params.limit));
13
+ const qs = q.toString();
14
+ return qs ? `?${qs}` : "";
15
+ };
16
+
17
+ export const createProjectClient = (config: SdkConfig) => ({
18
+ getAllByBusiness: (businessId: string, params: GetProjectsParams = {}) =>
19
+ request<ProjectListResponseDTO>(config, `/api/project/${businessId}/all${buildQs(params)}`, { withBusinessToken: true }),
20
+
21
+ getAllByCustomer: (customerId: string, params: GetProjectsParams = {}) =>
22
+ request<ProjectListResponseDTO>(config, `/api/project/customer/${customerId}${buildQs(params)}`, { withBusinessToken: true }),
23
+
24
+ get: (id: string) =>
25
+ request<ProjectDTO>(config, `/api/project/${id}`, { withBusinessToken: true }),
26
+
27
+ create: (input: CreateProjectInputDTO) =>
28
+ request<ProjectDTO>(config, "/api/project", { method: "POST", body: input, withBusinessToken: true }),
29
+
30
+ update: (id: string, input: UpdateProjectInputDTO) =>
31
+ request<ProjectDTO>(config, `/api/project/${id}`, { method: "PUT", body: input, withBusinessToken: true }),
32
+
33
+ delete: (id: string) =>
34
+ request<ProjectDTO>(config, `/api/project/${id}`, { method: "DELETE", withBusinessToken: true }),
35
+ });
package/src/index.ts CHANGED
@@ -5,6 +5,7 @@ import { createEmployeeClient } from "./clients/employee.client";
5
5
  import { createBusinessRelationClient } from "./clients/businessRelation.client";
6
6
  import { createUserRoleClient } from "./clients/userRole.client";
7
7
  import { createCustomerClient } from "./clients/customer.client";
8
+ import { createProjectClient } from "./clients/project.client";
8
9
 
9
10
  export const createSdk = (config: SdkConfig) => ({
10
11
  user: createUserClient(config),
@@ -13,6 +14,7 @@ export const createSdk = (config: SdkConfig) => ({
13
14
  businessRelation: createBusinessRelationClient(config),
14
15
  userRole: createUserRoleClient(config),
15
16
  customer: createCustomerClient(config),
17
+ project: createProjectClient(config),
16
18
  });
17
19
 
18
20
  export type { SdkConfig } from "./http";
package/src/types.ts CHANGED
@@ -126,3 +126,32 @@ export type CustomerListResponseDTO = {
126
126
 
127
127
  export type CreateCustomerInputDTO = Omit<CustomerDTO, "id">;
128
128
  export type UpdateCustomerInputDTO = Partial<Omit<CustomerDTO, "id">>;
129
+
130
+ // ── Project ───────────────────────────────────────────────────────────────────
131
+
132
+ export type NextPaymentDTO = {
133
+ amount: number;
134
+ date?: string;
135
+ milestone?: string;
136
+ };
137
+
138
+ export type ProjectDTO = {
139
+ id: string;
140
+ businessId: string;
141
+ customerId: string;
142
+ totalContractAmount: number;
143
+ totalPaidAmount?: number;
144
+ currency: string;
145
+ toBePaidAmount?: number;
146
+ nextPayment?: NextPaymentDTO;
147
+ };
148
+
149
+ export type ProjectListResponseDTO = {
150
+ data: ProjectDTO[];
151
+ total: number;
152
+ page: number;
153
+ limit: number;
154
+ };
155
+
156
+ export type CreateProjectInputDTO = Omit<ProjectDTO, "id">;
157
+ export type UpdateProjectInputDTO = Partial<Omit<ProjectDTO, "id">>;