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.
Files changed (112) hide show
  1. package/.env +1 -0
  2. package/.vscode/launch.json +24 -0
  3. package/dist/config/config.d.ts +6 -0
  4. package/dist/config/config.js +13 -0
  5. package/dist/config/env.d.ts +7 -0
  6. package/dist/config/env.js +16 -0
  7. package/dist/config/index.d.ts +2 -0
  8. package/dist/config/index.js +8 -0
  9. package/dist/index.d.ts +1 -0
  10. package/dist/index.js +32 -0
  11. package/dist/lib/ApiService.d.ts +41 -0
  12. package/dist/lib/ApiService.js +143 -0
  13. package/dist/lib/index.d.ts +4 -0
  14. package/dist/lib/index.js +9 -0
  15. package/dist/lib/queryParams.d.ts +43 -0
  16. package/dist/lib/queryParams.js +99 -0
  17. package/dist/services/account/AccountService.d.ts +52 -0
  18. package/dist/services/account/AccountService.js +119 -0
  19. package/dist/services/auth/AuthService.d.ts +44 -0
  20. package/dist/services/auth/AuthService.js +76 -0
  21. package/dist/services/branch/BranchService.d.ts +124 -0
  22. package/dist/services/branch/BranchService.js +162 -0
  23. package/dist/services/business/BusinessService.d.ts +91 -0
  24. package/dist/services/business/BusinessService.js +153 -0
  25. package/dist/services/document/DocumentService.d.ts +578 -0
  26. package/dist/services/document/DocumentService.js +615 -0
  27. package/dist/services/index.d.ts +36 -0
  28. package/dist/services/index.js +97 -0
  29. package/dist/services/injection_field/InjectionFieldService.d.ts +113 -0
  30. package/dist/services/injection_field/InjectionFieldService.js +220 -0
  31. package/dist/services/inventory/InventoryService.d.ts +27 -0
  32. package/dist/services/inventory/InventoryService.js +231 -0
  33. package/dist/services/item/ItemService.d.ts +227 -0
  34. package/dist/services/item/ItemService.js +411 -0
  35. package/dist/services/location/LocationService.d.ts +154 -0
  36. package/dist/services/location/LocationService.js +256 -0
  37. package/dist/services/logistic/LogisticService.d.ts +104 -0
  38. package/dist/services/logistic/LogisticService.js +150 -0
  39. package/dist/services/permission/PermissionService.d.ts +296 -0
  40. package/dist/services/permission/PermissionService.js +576 -0
  41. package/dist/services/permission/config/custom/adminPermission.d.ts +4 -0
  42. package/dist/services/permission/config/custom/adminPermission.js +18 -0
  43. package/dist/services/permission/config/custom/config.d.ts +40 -0
  44. package/dist/services/permission/config/custom/config.js +23 -0
  45. package/dist/services/permission/config/default/adminPermission.d.ts +2 -0
  46. package/dist/services/permission/config/default/adminPermission.js +129 -0
  47. package/dist/services/permission/config/default/agentPermission.d.ts +2 -0
  48. package/dist/services/permission/config/default/agentPermission.js +43 -0
  49. package/dist/services/permission/config/default/customerPermission.d.ts +2 -0
  50. package/dist/services/permission/config/default/customerPermission.js +10 -0
  51. package/dist/services/permission/config/default/driverPermission.d.ts +2 -0
  52. package/dist/services/permission/config/default/driverPermission.js +4 -0
  53. package/dist/services/permission/config/default/workerPermission.d.ts +2 -0
  54. package/dist/services/permission/config/default/workerPermission.js +25 -0
  55. package/dist/services/rate/RateService.d.ts +201 -0
  56. package/dist/services/rate/RateService.js +303 -0
  57. package/dist/services/region/RegionService.d.ts +111 -0
  58. package/dist/services/region/RegionService.js +193 -0
  59. package/dist/services/repository/RepositoryService.d.ts +153 -0
  60. package/dist/services/repository/RepositoryService.js +243 -0
  61. package/dist/services/transaction/TransactionService.d.ts +153 -0
  62. package/dist/services/transaction/TransactionService.js +173 -0
  63. package/dist/services/user/BranchUserService.d.ts +129 -0
  64. package/dist/services/user/BranchUserService.js +193 -0
  65. package/dist/services/user/UserRoleService.d.ts +105 -0
  66. package/dist/services/user/UserRoleService.js +193 -0
  67. package/dist/services/user/UserService.d.ts +269 -0
  68. package/dist/services/user/UserService.js +477 -0
  69. package/dist/services/wallet/WalletService.d.ts +104 -0
  70. package/dist/services/wallet/WalletService.js +163 -0
  71. package/dist/utils/dateUtils.d.ts +6 -0
  72. package/dist/utils/dateUtils.js +28 -0
  73. package/dist/utils/index.d.ts +2 -0
  74. package/dist/utils/index.js +13 -0
  75. package/package.json +27 -0
  76. package/src/config/config.ts +15 -0
  77. package/src/config/env.ts +18 -0
  78. package/src/config/index.ts +2 -0
  79. package/src/index.ts +41 -0
  80. package/src/lib/ApiService.ts +170 -0
  81. package/src/lib/index.ts +5 -0
  82. package/src/lib/queryParams.ts +162 -0
  83. package/src/services/account/AccountService.ts +232 -0
  84. package/src/services/auth/AuthService.ts +125 -0
  85. package/src/services/branch/BranchService.ts +330 -0
  86. package/src/services/business/BusinessService.ts +277 -0
  87. package/src/services/document/DocumentService.ts +1471 -0
  88. package/src/services/index.ts +73 -0
  89. package/src/services/injection_field/InjectionFieldService.ts +483 -0
  90. package/src/services/inventory/InventoryService.ts +314 -0
  91. package/src/services/item/ItemService.ts +707 -0
  92. package/src/services/location/LocationService.ts +505 -0
  93. package/src/services/logistic/LogisticService.ts +285 -0
  94. package/src/services/permission/PermissionService.ts +1069 -0
  95. package/src/services/permission/config/custom/adminPermission.ts +19 -0
  96. package/src/services/permission/config/custom/config.ts +39 -0
  97. package/src/services/permission/config/default/adminPermission.ts +129 -0
  98. package/src/services/permission/config/default/agentPermission.ts +42 -0
  99. package/src/services/permission/config/default/customerPermission.ts +9 -0
  100. package/src/services/permission/config/default/driverPermission.ts +4 -0
  101. package/src/services/permission/config/default/workerPermission.ts +25 -0
  102. package/src/services/rate/RateService.ts +570 -0
  103. package/src/services/region/RegionService.ts +353 -0
  104. package/src/services/repository/RepositoryService.ts +437 -0
  105. package/src/services/transaction/TransactionService.ts +404 -0
  106. package/src/services/user/BranchUserService.ts +381 -0
  107. package/src/services/user/UserRoleService.ts +342 -0
  108. package/src/services/user/UserService.ts +807 -0
  109. package/src/services/wallet/WalletService.ts +300 -0
  110. package/src/utils/dateUtils.ts +26 -0
  111. package/src/utils/index.ts +2 -0
  112. package/tsconfig.json +119 -0
@@ -0,0 +1,277 @@
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 businessTypes = {
12
+ business: "business",
13
+ } as const
14
+
15
+ export const businessTargetTypes = {
16
+ business: "business",
17
+ } as const
18
+
19
+ export type BusinessType = typeof businessTypes[keyof typeof businessTypes]
20
+ export type BusinessTargetType = typeof businessTargetTypes[keyof typeof businessTargetTypes]
21
+ export type BusinessTargetKey = keyof typeof businessTargetTypes
22
+
23
+ export type BusinessServiceProps = ApiServiceType & {
24
+ businessTargetType?: BusinessTargetType
25
+ businessType?: BusinessType
26
+ };
27
+
28
+ export type ListBusinessProps = BuildApiListParamsProps & {
29
+ businessType?: BusinessType
30
+ }
31
+
32
+ export type GetBusinessProps = BuildApiGetParamsProps & {
33
+ id: number | string
34
+ businessType?: BusinessType
35
+ }
36
+
37
+ type Business = {
38
+ companyName: string
39
+ idNumber: string
40
+ website: string
41
+ email: string
42
+ companyContact: string
43
+ address1: string
44
+ address2: string
45
+ countryId: number
46
+ stateId: number
47
+ areaId: number
48
+ postcode: string
49
+ status: boolean
50
+ }
51
+
52
+ export type CreateBusinessProps = {
53
+ businessTargetType?: BusinessTargetType
54
+ businessType?: BusinessType
55
+ data:
56
+ // for Business
57
+ {
58
+ business: Business
59
+ }
60
+ }
61
+
62
+ export type UpdateBusinessProps = {
63
+ id: number
64
+ businessTargetType?: BusinessTargetType
65
+ businessType?: BusinessType
66
+ data:
67
+ // for Business
68
+ {
69
+ business: Business
70
+ }
71
+ }
72
+
73
+ export type RemoveBusinessProps = {
74
+ businessTargetType?: BusinessTargetType
75
+ ids: number[]
76
+ }
77
+
78
+ export type GetDataTypeBusinessProps = {
79
+ businessType?: BusinessType
80
+ }
81
+
82
+ const getCreatePayload = (businessType: BusinessType, data: CreateBusinessProps["data"]) => {
83
+
84
+ if (businessType === "business") {
85
+ return {
86
+ business: {
87
+ company_name: data.business.companyName,
88
+ id_number: data.business.idNumber,
89
+ website: data.business.website,
90
+ email: data.business.email,
91
+ company_contact: data.business.companyContact,
92
+ address_1: data.business.address1,
93
+ address_2: data.business.address2,
94
+ country_id: data.business.countryId,
95
+ state_id: data.business.stateId,
96
+ area_id: data.business.areaId,
97
+ postcode: data.business.postcode,
98
+ status: (data.business.status === true) ? 1 : 0
99
+ }
100
+ }
101
+ }
102
+
103
+ }
104
+
105
+ const getUpdatePayload = (businessType: BusinessType, data: UpdateBusinessProps["data"]) => {
106
+
107
+ if (businessType === "business") {
108
+ return {
109
+ business: {
110
+ company_name: data.business.companyName,
111
+ id_number: data.business.idNumber,
112
+ website: data.business.website,
113
+ email: data.business.email,
114
+ company_contact: data.business.companyContact,
115
+ address_1: data.business.address1,
116
+ address_2: data.business.address2,
117
+ country_id: data.business.countryId,
118
+ state_id: data.business.stateId,
119
+ area_id: data.business.areaId,
120
+ postcode: data.business.postcode,
121
+ status: (data.business.status === true) ? 1 : 0
122
+ }
123
+ }
124
+ }
125
+
126
+ }
127
+
128
+ export const BusinessService = (props?: BusinessServiceProps) => {
129
+
130
+ const { businessType, businessTargetType, ...rest } = props ?? {};
131
+
132
+ const { makeCall } = ApiService(rest?.customToken ? { customToken: rest.customToken } : {})
133
+
134
+ const endpoint1 = "business";
135
+ const endpoint2 = "businesses"
136
+
137
+ const list = async (props: ListBusinessProps) => {
138
+
139
+ const { businessType: overrideBusinessType } = props;
140
+
141
+ const url = buildApiListUrl(
142
+ `${endpoint2}/${overrideBusinessType || businessType}`,
143
+ props
144
+ );
145
+
146
+ const response = await makeCall({
147
+ url,
148
+ method: "get",
149
+ payload: {},
150
+ // configuration
151
+ });
152
+
153
+ return response;
154
+
155
+ }
156
+
157
+ const get = async (props: GetBusinessProps) => {
158
+
159
+ const { id, businessType: overrideBusinessType } = props;
160
+
161
+ const url = buildApiGetUrl(
162
+ `${endpoint1}/${overrideBusinessType || businessType}/${id}`,
163
+ props
164
+ );
165
+
166
+ const response = await makeCall({
167
+ url,
168
+ method: "get",
169
+ payload: {},
170
+ // configuration
171
+ });
172
+
173
+ return response;
174
+
175
+ }
176
+
177
+ const create = async ({ data, businessType: overrideBusinessType, businessTargetType: overrideBusinessTargetType }: CreateBusinessProps) => {
178
+
179
+ let payload: any = {}
180
+
181
+ if (overrideBusinessType) {
182
+ payload = getCreatePayload(overrideBusinessType, data)
183
+ }
184
+
185
+ let url = `${endpoint1}`;
186
+
187
+ let postData = {
188
+ scope: {
189
+ target: overrideBusinessTargetType || businessTargetType,
190
+ action: "",
191
+ },
192
+ payload
193
+ }
194
+
195
+ const response = await makeCall({
196
+ url,
197
+ method: "post",
198
+ payload: postData
199
+ });
200
+
201
+ return response;
202
+
203
+ }
204
+
205
+ const update = async ({ id, data, businessType: overrideBusinessType, businessTargetType: overrideBusinessTargetType }: UpdateBusinessProps) => {
206
+
207
+ let url = `${endpoint1}/${id}`
208
+
209
+ let payload: any = {}
210
+
211
+ if (overrideBusinessType) {
212
+ payload = getUpdatePayload(overrideBusinessType, data)
213
+ }
214
+
215
+ const postData = {
216
+ scope: {
217
+ target: overrideBusinessTargetType || businessTargetType,
218
+ action: "",
219
+ },
220
+ payload
221
+ }
222
+
223
+ const response = await makeCall({
224
+ url,
225
+ method: "put",
226
+ payload: postData
227
+ });
228
+
229
+ return response;
230
+
231
+ }
232
+
233
+ const remove = async ({ ids, businessTargetType: overrideBusinessTargetType }: RemoveBusinessProps) => {
234
+
235
+ let url = `${endpoint2}/delete`
236
+
237
+ const postData = {
238
+ scope: {
239
+ target: overrideBusinessTargetType || businessTargetType,
240
+ },
241
+ payload: {
242
+ ids
243
+ }
244
+ }
245
+
246
+ const response = await makeCall({
247
+ url,
248
+ method: "post",
249
+ payload: postData
250
+ });
251
+
252
+ return response;
253
+
254
+ }
255
+
256
+ const getDataTypes = async ({ businessType: overrideBusinessType }: GetDataTypeBusinessProps) => {
257
+
258
+ let url = `${endpoint1}/data_types/${overrideBusinessType || businessType}`
259
+
260
+ const response = await makeCall({
261
+ url,
262
+ method: "get",
263
+ });
264
+
265
+ return response;
266
+
267
+ }
268
+
269
+ return {
270
+ list,
271
+ get,
272
+ create,
273
+ update,
274
+ remove,
275
+ getDataTypes
276
+ };
277
+ }