storemw-core-client 1.0.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.
- package/.env +1 -0
- package/.vscode/launch.json +24 -0
- package/dist/config/config.d.ts +6 -0
- package/dist/config/config.js +13 -0
- package/dist/config/env.d.ts +7 -0
- package/dist/config/env.js +16 -0
- package/dist/config/index.d.ts +2 -0
- package/dist/config/index.js +8 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +32 -0
- package/dist/lib/ApiService.d.ts +41 -0
- package/dist/lib/ApiService.js +143 -0
- package/dist/lib/index.d.ts +4 -0
- package/dist/lib/index.js +9 -0
- package/dist/lib/queryParams.d.ts +43 -0
- package/dist/lib/queryParams.js +99 -0
- package/dist/services/account/AccountService.d.ts +52 -0
- package/dist/services/account/AccountService.js +119 -0
- package/dist/services/auth/AuthService.d.ts +44 -0
- package/dist/services/auth/AuthService.js +76 -0
- package/dist/services/branch/BranchService.d.ts +124 -0
- package/dist/services/branch/BranchService.js +162 -0
- package/dist/services/business/BusinessService.d.ts +91 -0
- package/dist/services/business/BusinessService.js +153 -0
- package/dist/services/document/DocumentService.d.ts +578 -0
- package/dist/services/document/DocumentService.js +615 -0
- package/dist/services/index.d.ts +36 -0
- package/dist/services/index.js +97 -0
- package/dist/services/injection_field/InjectionFieldService.d.ts +113 -0
- package/dist/services/injection_field/InjectionFieldService.js +220 -0
- package/dist/services/inventory/InventoryService.d.ts +27 -0
- package/dist/services/inventory/InventoryService.js +231 -0
- package/dist/services/item/ItemService.d.ts +227 -0
- package/dist/services/item/ItemService.js +411 -0
- package/dist/services/location/LocationService.d.ts +154 -0
- package/dist/services/location/LocationService.js +256 -0
- package/dist/services/logistic/LogisticService.d.ts +104 -0
- package/dist/services/logistic/LogisticService.js +150 -0
- package/dist/services/permission/PermissionService.d.ts +296 -0
- package/dist/services/permission/PermissionService.js +576 -0
- package/dist/services/permission/config/custom/adminPermission.d.ts +4 -0
- package/dist/services/permission/config/custom/adminPermission.js +18 -0
- package/dist/services/permission/config/custom/config.d.ts +40 -0
- package/dist/services/permission/config/custom/config.js +23 -0
- package/dist/services/permission/config/default/adminPermission.d.ts +2 -0
- package/dist/services/permission/config/default/adminPermission.js +129 -0
- package/dist/services/permission/config/default/agentPermission.d.ts +2 -0
- package/dist/services/permission/config/default/agentPermission.js +43 -0
- package/dist/services/permission/config/default/customerPermission.d.ts +2 -0
- package/dist/services/permission/config/default/customerPermission.js +10 -0
- package/dist/services/permission/config/default/driverPermission.d.ts +2 -0
- package/dist/services/permission/config/default/driverPermission.js +4 -0
- package/dist/services/permission/config/default/workerPermission.d.ts +2 -0
- package/dist/services/permission/config/default/workerPermission.js +25 -0
- package/dist/services/rate/RateService.d.ts +201 -0
- package/dist/services/rate/RateService.js +303 -0
- package/dist/services/region/RegionService.d.ts +111 -0
- package/dist/services/region/RegionService.js +193 -0
- package/dist/services/repository/RepositoryService.d.ts +153 -0
- package/dist/services/repository/RepositoryService.js +243 -0
- package/dist/services/transaction/TransactionService.d.ts +153 -0
- package/dist/services/transaction/TransactionService.js +173 -0
- package/dist/services/user/BranchUserService.d.ts +129 -0
- package/dist/services/user/BranchUserService.js +193 -0
- package/dist/services/user/UserRoleService.d.ts +105 -0
- package/dist/services/user/UserRoleService.js +193 -0
- package/dist/services/user/UserService.d.ts +269 -0
- package/dist/services/user/UserService.js +477 -0
- package/dist/services/wallet/WalletService.d.ts +104 -0
- package/dist/services/wallet/WalletService.js +163 -0
- package/dist/utils/dateUtils.d.ts +6 -0
- package/dist/utils/dateUtils.js +28 -0
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.js +13 -0
- package/package.json +27 -0
- package/src/config/config.ts +15 -0
- package/src/config/env.ts +18 -0
- package/src/config/index.ts +2 -0
- package/src/index.ts +41 -0
- package/src/lib/ApiService.ts +170 -0
- package/src/lib/index.ts +5 -0
- package/src/lib/queryParams.ts +162 -0
- package/src/services/account/AccountService.ts +232 -0
- package/src/services/auth/AuthService.ts +125 -0
- package/src/services/branch/BranchService.ts +330 -0
- package/src/services/business/BusinessService.ts +277 -0
- package/src/services/document/DocumentService.ts +1471 -0
- package/src/services/index.ts +73 -0
- package/src/services/injection_field/InjectionFieldService.ts +483 -0
- package/src/services/inventory/InventoryService.ts +314 -0
- package/src/services/item/ItemService.ts +707 -0
- package/src/services/location/LocationService.ts +505 -0
- package/src/services/logistic/LogisticService.ts +285 -0
- package/src/services/permission/PermissionService.ts +1069 -0
- package/src/services/permission/config/custom/adminPermission.ts +19 -0
- package/src/services/permission/config/custom/config.ts +39 -0
- package/src/services/permission/config/default/adminPermission.ts +129 -0
- package/src/services/permission/config/default/agentPermission.ts +42 -0
- package/src/services/permission/config/default/customerPermission.ts +9 -0
- package/src/services/permission/config/default/driverPermission.ts +4 -0
- package/src/services/permission/config/default/workerPermission.ts +25 -0
- package/src/services/rate/RateService.ts +570 -0
- package/src/services/region/RegionService.ts +353 -0
- package/src/services/repository/RepositoryService.ts +437 -0
- package/src/services/transaction/TransactionService.ts +404 -0
- package/src/services/user/BranchUserService.ts +381 -0
- package/src/services/user/UserRoleService.ts +342 -0
- package/src/services/user/UserService.ts +807 -0
- package/src/services/wallet/WalletService.ts +300 -0
- package/src/utils/dateUtils.ts +26 -0
- package/src/utils/index.ts +2 -0
- package/tsconfig.json +119 -0
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
import { ApiService, ApiServiceType } from '@/lib';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
buildApiListUrl,
|
|
5
|
+
BuildApiListParamsProps,
|
|
6
|
+
buildApiGetUrl,
|
|
7
|
+
BuildApiGetParamsProps,
|
|
8
|
+
filterOperatorTypes
|
|
9
|
+
} from '@/lib';
|
|
10
|
+
|
|
11
|
+
export const inventoryTypes = {
|
|
12
|
+
inventory: "inventory",
|
|
13
|
+
// item_threshold: "inventory/item_threshold"
|
|
14
|
+
inventoryRelocateThreshold: "relocate_threshold",
|
|
15
|
+
inventoryReorderThreshold: "reorder_threshold",
|
|
16
|
+
} as const
|
|
17
|
+
|
|
18
|
+
export const inventoryTargetTypes = {
|
|
19
|
+
inventory: "inventory"
|
|
20
|
+
} as const
|
|
21
|
+
|
|
22
|
+
export type InventoryType = typeof inventoryTypes[keyof typeof inventoryTypes]
|
|
23
|
+
export type InventoryTargetType = typeof inventoryTargetTypes[keyof typeof inventoryTargetTypes]
|
|
24
|
+
export type InventoryTargetKey = keyof typeof inventoryTargetTypes
|
|
25
|
+
|
|
26
|
+
export type InventoryServiceProps = ApiServiceType & {
|
|
27
|
+
inventoryTargetType?: InventoryTargetType
|
|
28
|
+
inventoryType?: InventoryType
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export type ListInventoryProps = BuildApiListParamsProps & {
|
|
32
|
+
inventoryType?: InventoryType
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// export type GetInventoryProps = BuildApiGetParamsProps & {
|
|
36
|
+
// id: number | string
|
|
37
|
+
// inventoryType?: InventoryType
|
|
38
|
+
// }
|
|
39
|
+
|
|
40
|
+
// export type CreateInventoryProps = {
|
|
41
|
+
// inventoryTargetType?: InventoryTargetType
|
|
42
|
+
// inventoryType?: InventoryType
|
|
43
|
+
// data:
|
|
44
|
+
// // administrator
|
|
45
|
+
// {
|
|
46
|
+
// administrator: {
|
|
47
|
+
// credential: UserCredential,
|
|
48
|
+
// locationIds: number[]
|
|
49
|
+
// }
|
|
50
|
+
// } |
|
|
51
|
+
// // customer
|
|
52
|
+
// {
|
|
53
|
+
// customer: {
|
|
54
|
+
// credential: UserCredential,
|
|
55
|
+
// code: string
|
|
56
|
+
// accountCode: string
|
|
57
|
+
// companyName: string
|
|
58
|
+
// regNo: string
|
|
59
|
+
// secondaryRegNo: string
|
|
60
|
+
// taxIdentificationNo: string,
|
|
61
|
+
// taxRegistrationNo: string,
|
|
62
|
+
// remark: string
|
|
63
|
+
// salesperson: string
|
|
64
|
+
// excludeTaxRate: number[]
|
|
65
|
+
// }
|
|
66
|
+
// }
|
|
67
|
+
// }
|
|
68
|
+
|
|
69
|
+
// export type UpdateInventoryProps = {
|
|
70
|
+
// id: number
|
|
71
|
+
// inventoryTargetType?: InventoryTargetType
|
|
72
|
+
// inventoryType?: InventoryType
|
|
73
|
+
// data:
|
|
74
|
+
// // administatrator
|
|
75
|
+
// {
|
|
76
|
+
// administrator: {
|
|
77
|
+
// credential: Omit<UserCredential, "username" | "password"> & { password?: string },
|
|
78
|
+
// locationIds: number[]
|
|
79
|
+
// }
|
|
80
|
+
// } |
|
|
81
|
+
// // customer
|
|
82
|
+
// {
|
|
83
|
+
// customer: {
|
|
84
|
+
// credential: Omit<UserCredential, "username" | "password"> & { password?: string },
|
|
85
|
+
// code: string
|
|
86
|
+
// accountCode: string
|
|
87
|
+
// companyName: string
|
|
88
|
+
// regNo: string
|
|
89
|
+
// secondaryRegNo: string
|
|
90
|
+
// taxIdentificationNo: string,
|
|
91
|
+
// taxRegistrationNo: string,
|
|
92
|
+
// remark: string
|
|
93
|
+
// salesperson: string
|
|
94
|
+
// excludeTaxRate: number[]
|
|
95
|
+
// }
|
|
96
|
+
// }
|
|
97
|
+
// }
|
|
98
|
+
|
|
99
|
+
// export type RemoveInventoryProps = {
|
|
100
|
+
// inventoryTargetType?: InventoryTargetType
|
|
101
|
+
// ids: number[]
|
|
102
|
+
// }
|
|
103
|
+
|
|
104
|
+
// export type GetDataTypeInventoryProps = {
|
|
105
|
+
// inventoryType?: InventoryType
|
|
106
|
+
// }
|
|
107
|
+
|
|
108
|
+
// const getCreatePayload = (inventoryType: InventoryType, data: CreateInventoryProps["data"]) => {
|
|
109
|
+
|
|
110
|
+
// if (inventoryType === "inventory" && "inventory" in data) {
|
|
111
|
+
|
|
112
|
+
// return {
|
|
113
|
+
// credential: {
|
|
114
|
+
// username: data.administrator.credential.username,
|
|
115
|
+
// password: data.administrator.credential.password,
|
|
116
|
+
// user_type: inventoryType,
|
|
117
|
+
// firstname: data.administrator.credential.firstname,
|
|
118
|
+
// lastname: data.administrator.credential.lastname,
|
|
119
|
+
// contact: data.administrator.credential.contact,
|
|
120
|
+
// email: data.administrator.credential.email,
|
|
121
|
+
// status: (data.administrator.credential.status === true) ? 1 : 0,
|
|
122
|
+
// address: data.administrator.credential.address
|
|
123
|
+
// },
|
|
124
|
+
// administrator: [],
|
|
125
|
+
// props: {
|
|
126
|
+
// location_id: data.administrator.locationIds
|
|
127
|
+
// }
|
|
128
|
+
// }
|
|
129
|
+
// }
|
|
130
|
+
|
|
131
|
+
// }
|
|
132
|
+
|
|
133
|
+
// const getUpdatePayload = (inventoryType: InventoryType, data: UpdateInventoryProps["data"]) => {
|
|
134
|
+
|
|
135
|
+
// if (inventoryType === "administrator" && "administrator" in data) {
|
|
136
|
+
|
|
137
|
+
// return {
|
|
138
|
+
// credential: {
|
|
139
|
+
// ...(data.administrator.credential.password ? { password: data.administrator.credential.password } : {}),
|
|
140
|
+
// firstname: data.administrator.credential.firstname,
|
|
141
|
+
// lastname: data.administrator.credential.lastname,
|
|
142
|
+
// contact: data.administrator.credential.contact,
|
|
143
|
+
// email: data.administrator.credential.email,
|
|
144
|
+
// status: (data.administrator.credential.status === true) ? 1 : 0,
|
|
145
|
+
// address: data.administrator.credential.address
|
|
146
|
+
// },
|
|
147
|
+
// administrator: [],
|
|
148
|
+
// props: {
|
|
149
|
+
// location_id: data.administrator.locationIds
|
|
150
|
+
// }
|
|
151
|
+
// }
|
|
152
|
+
// }
|
|
153
|
+
|
|
154
|
+
// }
|
|
155
|
+
|
|
156
|
+
export const UserService = (props?: InventoryServiceProps) => {
|
|
157
|
+
|
|
158
|
+
const { inventoryType = "inventory", inventoryTargetType, ...rest } = props ?? {};
|
|
159
|
+
|
|
160
|
+
const { makeCall } = ApiService(rest?.customToken ? { customToken: rest.customToken } : {})
|
|
161
|
+
|
|
162
|
+
const endpoint1 = "inventories";
|
|
163
|
+
const endpoint2 = "inventories"
|
|
164
|
+
|
|
165
|
+
const list = async (props: ListInventoryProps) => {
|
|
166
|
+
|
|
167
|
+
const { inventoryType: overrideInventoryType } = props;
|
|
168
|
+
|
|
169
|
+
let _inventoryType = overrideInventoryType || inventoryType
|
|
170
|
+
|
|
171
|
+
let path: string = _inventoryType
|
|
172
|
+
|
|
173
|
+
if (_inventoryType === "relocate_threshold") {
|
|
174
|
+
path = `inventory/${_inventoryType}`
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
if (_inventoryType === "reorder_threshold") {
|
|
178
|
+
path = `inventory/${_inventoryType}`
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
const url = buildApiListUrl(
|
|
182
|
+
`${endpoint2}/${path}`,
|
|
183
|
+
props
|
|
184
|
+
);
|
|
185
|
+
|
|
186
|
+
const response = await makeCall({
|
|
187
|
+
url,
|
|
188
|
+
method: "get",
|
|
189
|
+
payload: {},
|
|
190
|
+
// configuration
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
return response;
|
|
194
|
+
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
// const get = async (props: GetInventoryProps) => {
|
|
198
|
+
|
|
199
|
+
// const { id, inventoryType: overrideInventoryType } = props;
|
|
200
|
+
|
|
201
|
+
// const url = buildApiGetUrl(
|
|
202
|
+
// `${endpoint1}/${overrideInventoryType || inventoryType}/${id}`,
|
|
203
|
+
// props
|
|
204
|
+
// );
|
|
205
|
+
|
|
206
|
+
// const response = await makeCall({
|
|
207
|
+
// url,
|
|
208
|
+
// method: "get",
|
|
209
|
+
// payload: {},
|
|
210
|
+
// // configuration
|
|
211
|
+
// });
|
|
212
|
+
|
|
213
|
+
// return response;
|
|
214
|
+
|
|
215
|
+
// }
|
|
216
|
+
|
|
217
|
+
// const create = async ({ data, inventoryType: overrideInventoryType, inventoryTargetType: overrideInventoryTargetType }: CreateInventoryProps) => {
|
|
218
|
+
|
|
219
|
+
// let _inventoryType = overrideInventoryType || inventoryType
|
|
220
|
+
|
|
221
|
+
// let payload: any = getCreatePayload(_inventoryType, data)
|
|
222
|
+
|
|
223
|
+
// let url = `${endpoint1}`;
|
|
224
|
+
|
|
225
|
+
// let postData = {
|
|
226
|
+
// scope: {
|
|
227
|
+
// target: overrideInventoryTargetType || inventoryTargetType,
|
|
228
|
+
// action: "",
|
|
229
|
+
// },
|
|
230
|
+
// payload
|
|
231
|
+
// }
|
|
232
|
+
|
|
233
|
+
// const response = await makeCall({
|
|
234
|
+
// url,
|
|
235
|
+
// method: "post",
|
|
236
|
+
// payload: postData
|
|
237
|
+
// });
|
|
238
|
+
|
|
239
|
+
// return response;
|
|
240
|
+
|
|
241
|
+
// }
|
|
242
|
+
|
|
243
|
+
// const update = async ({ id, data, inventoryType: overrideInventoryType, inventoryTargetType: overrideInventoryTargetType }: UpdateInventoryProps) => {
|
|
244
|
+
|
|
245
|
+
// let url = `${endpoint1}/${id}`
|
|
246
|
+
|
|
247
|
+
// let _inventoryType = overrideInventoryType || inventoryType
|
|
248
|
+
|
|
249
|
+
// let payload: any = getUpdatePayload(_inventoryType, data)
|
|
250
|
+
|
|
251
|
+
|
|
252
|
+
// const postData = {
|
|
253
|
+
// scope: {
|
|
254
|
+
// target: overrideInventoryTargetType || inventoryTargetType,
|
|
255
|
+
// action: "",
|
|
256
|
+
// },
|
|
257
|
+
// payload
|
|
258
|
+
// }
|
|
259
|
+
|
|
260
|
+
// const response = await makeCall({
|
|
261
|
+
// url,
|
|
262
|
+
// method: "put",
|
|
263
|
+
// payload: postData
|
|
264
|
+
// });
|
|
265
|
+
|
|
266
|
+
// return response;
|
|
267
|
+
|
|
268
|
+
// }
|
|
269
|
+
|
|
270
|
+
// const remove = async ({ ids, inventoryTargetType: overrideInventoryTargetType }: RemoveInventoryProps) => {
|
|
271
|
+
|
|
272
|
+
// let url = `${endpoint2}/delete`
|
|
273
|
+
|
|
274
|
+
// const postData = {
|
|
275
|
+
// scope: {
|
|
276
|
+
// target: overrideInventoryTargetType || inventoryTargetType,
|
|
277
|
+
// },
|
|
278
|
+
// payload: {
|
|
279
|
+
// ids
|
|
280
|
+
// }
|
|
281
|
+
// }
|
|
282
|
+
|
|
283
|
+
// const response = await makeCall({
|
|
284
|
+
// url,
|
|
285
|
+
// method: "post",
|
|
286
|
+
// payload: postData
|
|
287
|
+
// });
|
|
288
|
+
|
|
289
|
+
// return response;
|
|
290
|
+
|
|
291
|
+
// }
|
|
292
|
+
|
|
293
|
+
// const getDataTypes = async ({ inventoryType: overrideInventoryType }: GetDataTypeInventoryProps) => {
|
|
294
|
+
|
|
295
|
+
// let url = `${endpoint2}/data_types/${overrideInventoryType || inventoryType}`
|
|
296
|
+
|
|
297
|
+
// const response = await makeCall({
|
|
298
|
+
// url,
|
|
299
|
+
// method: "get",
|
|
300
|
+
// });
|
|
301
|
+
|
|
302
|
+
// return response;
|
|
303
|
+
|
|
304
|
+
// }
|
|
305
|
+
|
|
306
|
+
return {
|
|
307
|
+
list,
|
|
308
|
+
// get,
|
|
309
|
+
// create,
|
|
310
|
+
// update,
|
|
311
|
+
// remove,
|
|
312
|
+
// getDataTypes
|
|
313
|
+
};
|
|
314
|
+
}
|