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,73 @@
|
|
|
1
|
+
export { AuthService, authTargetTypes } from '../services/auth/AuthService';
|
|
2
|
+
export type { AuthLoginProps, AuthTargetType } from '../services/auth/AuthService'
|
|
3
|
+
|
|
4
|
+
export { UserService, userTypes, userTargetTypes } from '../services/user/UserService';
|
|
5
|
+
export type { UserServiceProps, UserType, ListUserProps, GetUserProps, CreateUserProps, UpdateUserProps, RemoveUserProps } from '../services/user/UserService';
|
|
6
|
+
|
|
7
|
+
export { UserRoleService, roleTypes, roleTargetTypes } from '../services/user/UserRoleService';
|
|
8
|
+
export type { UserRoleServiceProps, RoleType, ListRoleProps, GetRoleProps, CreateRoleProps, UpdateRoleProps, RemoveRoleProps, UpdateRolePermissionProps } from '../services/user/UserRoleService';
|
|
9
|
+
|
|
10
|
+
export { BranchUserService, branchUserTypes, branchUserTargetTypes } from '../services/user/BranchUserService';
|
|
11
|
+
export type { BranchUserServiceProps, BranchUserType, ListBranchUserProps, GetBranchUserProps, CreateBranchUserProps, UpdateBranchUserProps, RemoveBranchUserProps } from '../services/user/BranchUserService';
|
|
12
|
+
|
|
13
|
+
export { BranchService, branchTypes, branchTargetTypes } from '../services/branch/BranchService';
|
|
14
|
+
export type { BranchServiceProps, BranchType, ListBranchProps, GetBranchProps, CreateBranchProps, UpdateBranchProps, RemoveBranchProps } from '../services/branch/BranchService';
|
|
15
|
+
|
|
16
|
+
export { DocumentService, documentTypes } from '../services/document/DocumentService';
|
|
17
|
+
export type { DocumentServiceProps, DocumentType, ListDocumentProps, GetDocumentProps, CreateDocumentProps, UpdateDocumentProps, RemoveDocumentProps } from '../services/document/DocumentService';
|
|
18
|
+
|
|
19
|
+
export { ItemService, itemTypes, itemTargetTypes } from '../services/item/ItemService';
|
|
20
|
+
export type { ItemServiceProps, ItemType, ListItemProps, GetItemProps, CreateItemProps, UpdateItemProps, RemoveItemProps, CreateMultipleItemProps, CreateMultipleItemPropsProps } from '../services/item/ItemService';
|
|
21
|
+
|
|
22
|
+
export { InjectionFieldService, injectionFieldMap, injectionFieldScopeTypes, injectionFieldDataTypes, getInjectionFieldsPayload } from '../services/injection_field/InjectionFieldService';
|
|
23
|
+
export type { InjectionFieldServiceProps, InjectionField, InjectionFieldScopeType, StrictInjectionField, ListInjectionFieldProps, GetInjectionFieldProps, CreateInjectionFieldProps, RemoveInjectionFieldProps, UpdateInjectionFieldValuesProps } from '../services/injection_field/InjectionFieldService';
|
|
24
|
+
|
|
25
|
+
export { LocationService, locationTypes, locationTargetTypes } from '../services/location/LocationService';
|
|
26
|
+
export type { LocationServiceProps, LocationType, ListLocationProps, GetLocationProps, CreateLocationProps, UpdateLocationProps, RemoveLocationProps } from '../services/location/LocationService';
|
|
27
|
+
|
|
28
|
+
export { RegionService, regionTypes, regionTargetTypes } from '../services/region/RegionService';
|
|
29
|
+
export type { RegionServiceProps, RegionType, ListRegionProps, GetRegionProps, CreateRegionProps, UpdateRegionProps, RemoveRegionProps } from '../services/region/RegionService';
|
|
30
|
+
|
|
31
|
+
export { RateService, rateTypes, rateTargetTypes, rateCalculationTypes } from '../services/rate/RateService';
|
|
32
|
+
export type { RateServiceProps, RateType, ListRateProps, GetRateProps, CreateRateProps, UpdateRateProps, RemoveRateProps, RemoveRateItemProps, CalculateRateProps } from '../services/rate/RateService';
|
|
33
|
+
|
|
34
|
+
export { WalletService, walletTypes, walletTargetTypes, walletCurrencyTypes } from '../services/wallet/WalletService';
|
|
35
|
+
export type { WalletServiceProps, WalletType, ListWalletProps, GetWalletProps, CreateWalletProps, UpdateWalletProps, RemoveWalletProps } from '../services/wallet/WalletService';
|
|
36
|
+
|
|
37
|
+
export { TransactionService, transactionTypes, transactionTargetTypes, transactionActionTypes } from '../services/transaction/TransactionService';
|
|
38
|
+
export type { TransactionServiceProps, TransactionType, ListTransactionProps, GetTransactionProps, CreateTransactionProps, UpdateStatusTransactionProps } from '../services/transaction/TransactionService';
|
|
39
|
+
|
|
40
|
+
export { BusinessService, businessTypes, businessTargetTypes } from '../services/business/BusinessService';
|
|
41
|
+
export type { BusinessServiceProps, BusinessType, ListBusinessProps, GetBusinessProps, CreateBusinessProps, UpdateBusinessProps, RemoveBusinessProps } from '../services/business/BusinessService';
|
|
42
|
+
|
|
43
|
+
export { LogisticService, logisticTypes, logisticTargetTypes, transportTypes } from '../services/logistic/LogisticService';
|
|
44
|
+
export type { LogisticServiceProps, LogisticType, ListLogisticProps, GetLogisticProps, CreateLogisticProps, UpdateLogisticProps, RemoveLogisticProps } from '../services/logistic/LogisticService';
|
|
45
|
+
|
|
46
|
+
export { AccountService, accountTypes, accountTargetTypes } from '../services/account/AccountService';
|
|
47
|
+
export type { AccountServiceProps, AccountType, ListAccountProps, GetAccountProps, UpdateAccountProps } from '../services/account/AccountService';
|
|
48
|
+
|
|
49
|
+
export { RepositoryService, repositoryTypes, repositoryTargetTypes } from '../services/repository/RepositoryService'
|
|
50
|
+
export type { RepositoryServiceProps, RepositoryType, ListRepositoryProps, GetRepositoryProps, CreateRepositoryProps, UpdateRepositoryProps, RemoveRepositoryProps } from '../services/repository/RepositoryService'
|
|
51
|
+
|
|
52
|
+
export { PermissionService, permissionTypes, permissionScopeTypes, permissionModuleTypes, permissionFunctionTypes, permissionFunctionActionTypes } from '../services/permission/PermissionService';
|
|
53
|
+
export type { PermissionServiceProps, CheckPermissionAllowProps, PermissionScopeType, PermissionFunctionType, PermissionFunctionActionType } from '../services/permission/PermissionService';
|
|
54
|
+
|
|
55
|
+
// export { SessionService } from './SessionService';
|
|
56
|
+
// export { StorageService } from '../StorageService';
|
|
57
|
+
// export { UserService, userTypes, targetTypes as userTargetTypes } from './UserService';
|
|
58
|
+
// export type { UserType, UserTargetType } from "./UserService"
|
|
59
|
+
|
|
60
|
+
// export { AccountingActivityService } from './AccountingActivityService';
|
|
61
|
+
// export type { AccountingActivityModuleType } from './AccountingActivityService';
|
|
62
|
+
|
|
63
|
+
// export { DocumentService, documentTypes } from './DocumentService';
|
|
64
|
+
// export type { DocumentType } from './DocumentService';
|
|
65
|
+
|
|
66
|
+
// export { MarkingService } from './MarkingService';
|
|
67
|
+
// export { AgentService } from './AgentService';
|
|
68
|
+
|
|
69
|
+
// export { filterOperatorTypes } from "../utils/buildApiParams";
|
|
70
|
+
// export type { BuildApiListParamsProps, BuildApiGetParamsProps } from "../utils/buildApiParams";
|
|
71
|
+
|
|
72
|
+
// export { AutocountDocumentService, AutocountDocumentTypes } from './AutocountDocumentService';
|
|
73
|
+
// export type { AutocountDocumentServiceCreateProps, AutocountDocumentServiceCancelProps, AutocountDocumentServiceListProps, AutocountDocumentServiceGetProps, AutocountDocumentType } from './AutocountDocumentService';
|
|
@@ -0,0 +1,483 @@
|
|
|
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 type InjectionFieldDataTypeValueMap = {
|
|
12
|
+
id: number;
|
|
13
|
+
text: string;
|
|
14
|
+
value: string;
|
|
15
|
+
numeric: number;
|
|
16
|
+
integer: number;
|
|
17
|
+
timestamp: string;
|
|
18
|
+
date: string;
|
|
19
|
+
date_time: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export const injectionFieldDataTypes: Record<keyof InjectionFieldDataTypeValueMap, any> = {
|
|
23
|
+
id: { id: "id", fieldName: "field_id" },
|
|
24
|
+
text: { id: "text", fieldName: "field_text" },
|
|
25
|
+
value: { id: "value", fieldName: "field_value" },
|
|
26
|
+
numeric: { id: "numeric", fieldName: "field_numeric" },
|
|
27
|
+
integer: { id: "integer", fieldName: "field_integer" },
|
|
28
|
+
timestamp: { id: "timestamp", fieldName: "field_timestamp" },
|
|
29
|
+
date: { id: "date", fieldName: "field_date" },
|
|
30
|
+
date_time: { id: "date_time", fieldName: "field_date_time" },
|
|
31
|
+
} as const
|
|
32
|
+
|
|
33
|
+
type InjectionFieldDataTypeId = keyof InjectionFieldDataTypeValueMap;
|
|
34
|
+
|
|
35
|
+
// 5. Extract correct value types from fieldDataTypeId
|
|
36
|
+
// type ExtractValueTypes<T extends Record<string, InjectionField>> = {
|
|
37
|
+
// [K in keyof T]: T[K]["fieldDataTypeId"] extends keyof InjectionFieldDataTypeValueMap
|
|
38
|
+
// ? InjectionFieldDataTypeValueMap[T[K]["fieldDataTypeId"]]
|
|
39
|
+
// : never;
|
|
40
|
+
// };
|
|
41
|
+
|
|
42
|
+
type InferValues<T extends Record<string, InjectionField>> = {
|
|
43
|
+
[K in keyof T]?: InjectionFieldDataTypeValueMap[T[K]["fieldDataTypeId"]];
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
// export const injectionFieldDataTypes = {
|
|
47
|
+
// id: { id: "id", fieldName: "field_id" },
|
|
48
|
+
// text: { id: "text", fieldName: "field_text" },
|
|
49
|
+
// value: { id: "value", fieldName: "field_value" },
|
|
50
|
+
// numeric: { id: "numeric", fieldName: "field_numeric" },
|
|
51
|
+
// integer: { id: "integer", fieldName: "field_integer" },
|
|
52
|
+
// timestamp: { id: "timestamp", fieldName: "field_timestamp" },
|
|
53
|
+
// date: { id: "date", fieldName: "field_date" },
|
|
54
|
+
// date_time: { id: "date_time", fieldName: "field_date_time" },
|
|
55
|
+
// }
|
|
56
|
+
export type InjectionFieldScopeType =
|
|
57
|
+
| "item"
|
|
58
|
+
| "document"
|
|
59
|
+
| "document_item"
|
|
60
|
+
| "repository"
|
|
61
|
+
| "repository_item"
|
|
62
|
+
| "user"
|
|
63
|
+
| "branch"
|
|
64
|
+
| "branch_user"
|
|
65
|
+
| "logistic";
|
|
66
|
+
|
|
67
|
+
type ScopeTypeMeta = {
|
|
68
|
+
id: string,
|
|
69
|
+
key: string,
|
|
70
|
+
description: string
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
type ScopeTypeMap = {
|
|
74
|
+
[K in InjectionFieldScopeType]: ScopeTypeMeta;
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
export const injectionFieldScopeTypes: ScopeTypeMap = {
|
|
78
|
+
item: { id: "item", key: "", description: "Support product, item, category, etc" },
|
|
79
|
+
document: { id: "document", key: "doc", description: "Support document, document_item, etc" },
|
|
80
|
+
document_item: { id: "document_item", key: "doci", description: "Subset from document" },
|
|
81
|
+
repository: { id: "repository", key: "", description: "Support repository, package, etc" },
|
|
82
|
+
repository_item: { id: "repository_item", key: "", description: "Support container, package, etc" },
|
|
83
|
+
user: { id: "user", key: "", description: "Support customer, retailer, branch, branch_user, etc" },
|
|
84
|
+
branch: { id: "branch", key: "", description: "Support customer, retailer branches" },
|
|
85
|
+
branch_user: { id: "branch_user", key: "", description: "Support branch users" },
|
|
86
|
+
logistic: { id: "logistic", key: "", description: "Support transporter, etc" },
|
|
87
|
+
} as const
|
|
88
|
+
|
|
89
|
+
// type ModuleTypeMap = {
|
|
90
|
+
// [K in InjectionFieldScopeType]: any
|
|
91
|
+
// }
|
|
92
|
+
|
|
93
|
+
// export const moduleTypes: ModuleTypeMap = {
|
|
94
|
+
// item: {
|
|
95
|
+
// product: "product",
|
|
96
|
+
// item: "item",
|
|
97
|
+
// category: "category",
|
|
98
|
+
// uom: "uom",
|
|
99
|
+
// brand: "brand",
|
|
100
|
+
// },
|
|
101
|
+
// document: {
|
|
102
|
+
// proformaSales: "proforma_sales",
|
|
103
|
+
// cashSales: "cash_sales",
|
|
104
|
+
// retailCashSales: "retail_cash_sales",
|
|
105
|
+
// salesOrder: "sales",
|
|
106
|
+
// salesInvoice: "sales_invoice",
|
|
107
|
+
// deliveryOrder: "delivery",
|
|
108
|
+
// itemReceive: "item_receive",
|
|
109
|
+
// tripOrder: "trip",
|
|
110
|
+
// },
|
|
111
|
+
// document_item: {
|
|
112
|
+
// proformaSales: "proforma_sales",
|
|
113
|
+
// cashSales: "cash_sales",
|
|
114
|
+
// salesOrder: "sales",
|
|
115
|
+
// deliveryOrder: "delivery",
|
|
116
|
+
// itemReceive: "item_receive",
|
|
117
|
+
// },
|
|
118
|
+
// repository: {
|
|
119
|
+
// package: "package",
|
|
120
|
+
// container: "container",
|
|
121
|
+
// },
|
|
122
|
+
// repository_item: {
|
|
123
|
+
// package: "package",
|
|
124
|
+
// container: "container",
|
|
125
|
+
// },
|
|
126
|
+
// user: {
|
|
127
|
+
// administrator: "administrator",
|
|
128
|
+
// supplier: "supplier",
|
|
129
|
+
// retailer: "retailer",
|
|
130
|
+
// customer: "customer",
|
|
131
|
+
// driver: "driver",
|
|
132
|
+
// worker: "worker",
|
|
133
|
+
// member: "member",
|
|
134
|
+
// },
|
|
135
|
+
// branch: {
|
|
136
|
+
// customer: "customer",
|
|
137
|
+
// retailer: "retailer",
|
|
138
|
+
// },
|
|
139
|
+
// branch_user: {
|
|
140
|
+
// customer: "customer"
|
|
141
|
+
// },
|
|
142
|
+
// logistic: {
|
|
143
|
+
// transporter: "transporter",
|
|
144
|
+
// },
|
|
145
|
+
// } as const
|
|
146
|
+
|
|
147
|
+
type InjectionFieldMeta = {
|
|
148
|
+
rootKey: string,
|
|
149
|
+
module: string,
|
|
150
|
+
key: string
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
type InjectionFieldMap = {
|
|
154
|
+
[K in InjectionFieldScopeType]: InjectionFieldMeta[];
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
export const injectionFieldMap: InjectionFieldMap = {
|
|
158
|
+
item: [
|
|
159
|
+
{ rootKey: "itm", module: "product", key: "prt" },
|
|
160
|
+
{ rootKey: "itm", module: "item", key: "itm" },
|
|
161
|
+
{ rootKey: "itm", module: "brand", key: "brd" },
|
|
162
|
+
{ rootKey: "itm", module: "category", key: "ct" },
|
|
163
|
+
{ rootKey: "itm", module: "item_uom", key: "uom" },
|
|
164
|
+
],
|
|
165
|
+
document: [
|
|
166
|
+
{ rootKey: "doc", module: "delivery", key: "do" },
|
|
167
|
+
{ rootKey: "doc", module: "cash_sales", key: "cs" },
|
|
168
|
+
{ rootKey: "doc", module: "sales", key: "so" },
|
|
169
|
+
{ rootKey: "doc", module: "proforma_sales", key: "pso" },
|
|
170
|
+
{ rootKey: "doc", module: "retail_cash_sales", key: "rcs" },
|
|
171
|
+
{ rootKey: "doc", module: "replacement_delivery", key: "rdo" },
|
|
172
|
+
],
|
|
173
|
+
document_item: [
|
|
174
|
+
{ rootKey: "doci", module: "delivery", key: "do" },
|
|
175
|
+
{ rootKey: "doci", module: "cash_sales", key: "cs" },
|
|
176
|
+
{ rootKey: "doci", module: "sales", key: "so" },
|
|
177
|
+
{ rootKey: "doci", module: "proforma_sales", key: "pso" },
|
|
178
|
+
{ rootKey: "doci", module: "retail_cash_sales", key: "rcs" },
|
|
179
|
+
{ rootKey: "doci", module: "replacement_delivery", key: "rdo" },
|
|
180
|
+
],
|
|
181
|
+
repository: [
|
|
182
|
+
{ rootKey: "repo", module: "package", key: "pk" },
|
|
183
|
+
{ rootKey: "repo", module: "container", key: "cont" },
|
|
184
|
+
],
|
|
185
|
+
repository_item: [
|
|
186
|
+
{ rootKey: "repo_item", module: "package", key: "pk" },
|
|
187
|
+
{ rootKey: "repo_item", module: "container", key: "cont" },
|
|
188
|
+
],
|
|
189
|
+
logistic: [
|
|
190
|
+
{ rootKey: "lgt", module: "transporter", key: "tpt" },
|
|
191
|
+
],
|
|
192
|
+
user: [
|
|
193
|
+
{ rootKey: "usr", module: "administrator", key: "admin" },
|
|
194
|
+
{ rootKey: "usr", module: "customer", key: "cust" },
|
|
195
|
+
{ rootKey: "usr", module: "driver", key: "dvr" },
|
|
196
|
+
{ rootKey: "usr", module: "supplier", key: "sup" },
|
|
197
|
+
{ rootKey: "usr", module: "worker", key: "wkr" },
|
|
198
|
+
],
|
|
199
|
+
branch_user: [
|
|
200
|
+
{ rootKey: "brusr", module: "customer", key: "cust" },
|
|
201
|
+
],
|
|
202
|
+
branch: [
|
|
203
|
+
{ rootKey: "br", module: "customer", key: "cust" },
|
|
204
|
+
],
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
export type InjectionField = {
|
|
208
|
+
fieldKey: string;
|
|
209
|
+
retrieveKey: string;
|
|
210
|
+
fieldDataTypeId: InjectionFieldDataTypeId;
|
|
211
|
+
} & StrictInjectionField;
|
|
212
|
+
|
|
213
|
+
type MainOptionsMap = typeof injectionFieldMap;
|
|
214
|
+
|
|
215
|
+
type Option<T extends InjectionFieldScopeType> = MainOptionsMap[T][number];
|
|
216
|
+
type Module<T extends InjectionFieldScopeType> = Option<T>["module"];
|
|
217
|
+
type Key<T extends InjectionFieldScopeType> = Option<T>["key"];
|
|
218
|
+
type RootKey<T extends InjectionFieldScopeType> = Option<T>["rootKey"];
|
|
219
|
+
|
|
220
|
+
type InjectionFieldBase = {
|
|
221
|
+
fieldKey: string;
|
|
222
|
+
};
|
|
223
|
+
|
|
224
|
+
// Typed injection field for a specific InjectionFieldScopeType
|
|
225
|
+
type GenericInjectionField<T extends InjectionFieldScopeType> = InjectionFieldBase & {
|
|
226
|
+
fieldRef: T;
|
|
227
|
+
fieldModule: Module<T>;
|
|
228
|
+
};
|
|
229
|
+
|
|
230
|
+
// Final union of all valid fields
|
|
231
|
+
export type StrictInjectionField =
|
|
232
|
+
| GenericInjectionField<"document">
|
|
233
|
+
| GenericInjectionField<"document_item">
|
|
234
|
+
| GenericInjectionField<"item">
|
|
235
|
+
| GenericInjectionField<"repository">
|
|
236
|
+
| GenericInjectionField<"repository_item">
|
|
237
|
+
| GenericInjectionField<"logistic">
|
|
238
|
+
| GenericInjectionField<"user">
|
|
239
|
+
| GenericInjectionField<"branch">
|
|
240
|
+
| GenericInjectionField<"branch_user">
|
|
241
|
+
;
|
|
242
|
+
|
|
243
|
+
export type InjectionFieldServiceProps<T extends InjectionFieldScopeType = InjectionFieldScopeType> = ApiServiceType & {
|
|
244
|
+
scopeType?: T;
|
|
245
|
+
};
|
|
246
|
+
|
|
247
|
+
export type ListInjectionFieldProps = BuildApiListParamsProps & {
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
export type GetInjectionFieldProps = BuildApiGetParamsProps & {
|
|
251
|
+
id: number | string
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
export type CreateInjectionFieldProps = {
|
|
255
|
+
scopeType?: InjectionFieldScopeType
|
|
256
|
+
data: (StrictInjectionField & {
|
|
257
|
+
fieldType: InjectionFieldDataTypeValueMap
|
|
258
|
+
})[]
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
export type UpdateInjectionFieldValuesProps = {
|
|
262
|
+
scopeType?: InjectionFieldScopeType
|
|
263
|
+
data: any[]
|
|
264
|
+
// (StrictInjectionField & { refId: any, value: any })[]
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
export type RemoveInjectionFieldProps = {
|
|
268
|
+
ids: number[]
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
const getCreatePayload = (mainType: InjectionFieldScopeType, data: CreateInjectionFieldProps["data"]) => {
|
|
272
|
+
|
|
273
|
+
return {
|
|
274
|
+
injection_fields: data.map((i) => ({
|
|
275
|
+
field_key: i.fieldKey,
|
|
276
|
+
field_module: i.fieldModule,
|
|
277
|
+
field_ref: i.fieldRef,
|
|
278
|
+
field_type: i.fieldType
|
|
279
|
+
}))
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
const getUpdatePayload = (mainType: InjectionFieldScopeType, data: UpdateInjectionFieldValuesProps["data"]) => {
|
|
285
|
+
|
|
286
|
+
return {
|
|
287
|
+
injection_fields: data.map((i) => ({
|
|
288
|
+
field_key: i.fieldKey,
|
|
289
|
+
field_module: i.fieldModule,
|
|
290
|
+
field_ref: i.fieldRef,
|
|
291
|
+
ref_id: i.refId,
|
|
292
|
+
field_value: i.value
|
|
293
|
+
}))
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
export function getInjectionFieldsPayload<
|
|
299
|
+
T extends Record<string, InjectionField>
|
|
300
|
+
>({
|
|
301
|
+
referId,
|
|
302
|
+
injectionFields,
|
|
303
|
+
values,
|
|
304
|
+
}: {
|
|
305
|
+
referId: number,
|
|
306
|
+
injectionFields: T;
|
|
307
|
+
values: InferValues<T>;
|
|
308
|
+
}) {
|
|
309
|
+
return Object.entries(values).map(([key, value]) => {
|
|
310
|
+
const field = injectionFields[key];
|
|
311
|
+
return {
|
|
312
|
+
refId: referId,
|
|
313
|
+
fieldRef: field.fieldRef,
|
|
314
|
+
fieldKey: field.fieldKey,
|
|
315
|
+
fieldModule: field.fieldModule,
|
|
316
|
+
value: value,
|
|
317
|
+
};
|
|
318
|
+
});
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
export const InjectionFieldService = <T extends InjectionFieldScopeType>(
|
|
322
|
+
props: InjectionFieldServiceProps<T>
|
|
323
|
+
) => {
|
|
324
|
+
|
|
325
|
+
const { scopeType = "document", ...rest } = props ?? {};
|
|
326
|
+
|
|
327
|
+
const { makeCall } = ApiService(rest?.customToken ? { customToken: rest.customToken } : {})
|
|
328
|
+
|
|
329
|
+
const endpoint1 = "injection_field";
|
|
330
|
+
const endpoint2 = "injection_fields"
|
|
331
|
+
|
|
332
|
+
const list = async (props: ListInjectionFieldProps) => {
|
|
333
|
+
|
|
334
|
+
const url = buildApiListUrl(
|
|
335
|
+
`${endpoint2}/injection_field`,
|
|
336
|
+
props
|
|
337
|
+
);
|
|
338
|
+
|
|
339
|
+
const response = await makeCall({
|
|
340
|
+
url,
|
|
341
|
+
method: "get",
|
|
342
|
+
payload: {},
|
|
343
|
+
// configuration
|
|
344
|
+
});
|
|
345
|
+
|
|
346
|
+
return response;
|
|
347
|
+
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
const get = async (props: GetInjectionFieldProps) => {
|
|
351
|
+
|
|
352
|
+
const { id } = props;
|
|
353
|
+
|
|
354
|
+
const url = buildApiGetUrl(
|
|
355
|
+
`${endpoint1}/definition/${id}`,
|
|
356
|
+
props
|
|
357
|
+
);
|
|
358
|
+
|
|
359
|
+
const response = await makeCall({
|
|
360
|
+
url,
|
|
361
|
+
method: "get",
|
|
362
|
+
payload: {},
|
|
363
|
+
// configuration
|
|
364
|
+
});
|
|
365
|
+
|
|
366
|
+
return response;
|
|
367
|
+
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
const create = async (props: CreateInjectionFieldProps) => {
|
|
371
|
+
|
|
372
|
+
let url = `${endpoint1}`;
|
|
373
|
+
|
|
374
|
+
const { data, scopeType: overrideScopeType } = props
|
|
375
|
+
|
|
376
|
+
let _scopeType = overrideScopeType || scopeType
|
|
377
|
+
|
|
378
|
+
let payload: any = getCreatePayload(_scopeType, data)
|
|
379
|
+
|
|
380
|
+
let postData = {
|
|
381
|
+
scope: {
|
|
382
|
+
target: "injection_field",
|
|
383
|
+
action: "",
|
|
384
|
+
},
|
|
385
|
+
payload
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
const response = await makeCall({
|
|
389
|
+
url,
|
|
390
|
+
method: "post",
|
|
391
|
+
payload: postData
|
|
392
|
+
});
|
|
393
|
+
|
|
394
|
+
return response;
|
|
395
|
+
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
const remove = async ({ ids }: RemoveInjectionFieldProps) => {
|
|
399
|
+
|
|
400
|
+
let url = `${endpoint2}/delete`
|
|
401
|
+
|
|
402
|
+
const postData = {
|
|
403
|
+
scope: {
|
|
404
|
+
target: "injection_field",
|
|
405
|
+
},
|
|
406
|
+
payload: {
|
|
407
|
+
ids
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
const response = await makeCall({
|
|
412
|
+
url,
|
|
413
|
+
method: "post",
|
|
414
|
+
payload: postData
|
|
415
|
+
});
|
|
416
|
+
|
|
417
|
+
return response;
|
|
418
|
+
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
// update field values - create if not exists
|
|
422
|
+
const updateInjectionFieldValues = async (props: UpdateInjectionFieldValuesProps) => {
|
|
423
|
+
|
|
424
|
+
let url = `${endpoint1}`;
|
|
425
|
+
|
|
426
|
+
const { data, scopeType: overrideScopeType } = props
|
|
427
|
+
|
|
428
|
+
let _scopeType = overrideScopeType || scopeType
|
|
429
|
+
|
|
430
|
+
let payload: any = getUpdatePayload(_scopeType, data)
|
|
431
|
+
|
|
432
|
+
let postData = {
|
|
433
|
+
scope: {
|
|
434
|
+
target: overrideScopeType || scopeType,
|
|
435
|
+
action: "",
|
|
436
|
+
},
|
|
437
|
+
payload
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
const response = await makeCall({
|
|
441
|
+
url,
|
|
442
|
+
method: "post",
|
|
443
|
+
payload: postData
|
|
444
|
+
});
|
|
445
|
+
|
|
446
|
+
return response;
|
|
447
|
+
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
// get all scopes
|
|
451
|
+
const getInjectionFieldScopeTypes = () => {
|
|
452
|
+
return injectionFieldScopeTypes
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
// get all modules by scope type
|
|
456
|
+
const getInjectionFieldModulesByScopeType = (scopeType: InjectionFieldScopeType) => {
|
|
457
|
+
return injectionFieldMap[scopeType]
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
return {
|
|
461
|
+
list,
|
|
462
|
+
get,
|
|
463
|
+
create,
|
|
464
|
+
remove,
|
|
465
|
+
updateInjectionFieldValues,
|
|
466
|
+
getInjectionFieldScopeTypes,
|
|
467
|
+
getInjectionFieldModulesByScopeType
|
|
468
|
+
};
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
// const { create, getAllInjectionFieldScopeTypes, getAllInjectionFieldModulesByScopeType } = InjectionFieldService({ scopeType: "document" })
|
|
472
|
+
|
|
473
|
+
// let payload: CreateInjectionFieldProps = {
|
|
474
|
+
// data: [{
|
|
475
|
+
// fieldKey: "",
|
|
476
|
+
// fieldModule: "",
|
|
477
|
+
// fieldRef: injectionFieldScopeTypes.branch.id as InjectionFieldScopeType,
|
|
478
|
+
// }]
|
|
479
|
+
// }
|
|
480
|
+
|
|
481
|
+
// const a = getAllInjectionFieldScopeTypes()
|
|
482
|
+
// const b = getAllInjectionFieldModulesByScopeType("branch")
|
|
483
|
+
|