@etsoo/smarterp-core 1.0.0

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 (226) hide show
  1. package/.github/workflows/main.yml +60 -0
  2. package/LICENSE +21 -0
  3. package/README.md +17 -0
  4. package/__tests__/OrgApi.ts +132 -0
  5. package/__tests__/PublicApi.ts +130 -0
  6. package/__tests__/UserApi.ts +29 -0
  7. package/__tests__/app/TestApp.ts +138 -0
  8. package/__tests__/tsconfig.json +18 -0
  9. package/babel.config.json +11 -0
  10. package/lib/cjs/AppApi.d.ts +48 -0
  11. package/lib/cjs/AppApi.js +54 -0
  12. package/lib/cjs/CoreApp.d.ts +58 -0
  13. package/lib/cjs/CoreApp.js +68 -0
  14. package/lib/cjs/MemberApi.d.ts +38 -0
  15. package/lib/cjs/MemberApi.js +45 -0
  16. package/lib/cjs/OrgApi.d.ts +95 -0
  17. package/lib/cjs/OrgApi.js +110 -0
  18. package/lib/cjs/PublicApi.d.ts +105 -0
  19. package/lib/cjs/PublicApi.js +143 -0
  20. package/lib/cjs/UserApi.d.ts +53 -0
  21. package/lib/cjs/UserApi.js +68 -0
  22. package/lib/cjs/dto/IdentityType.d.ts +21 -0
  23. package/lib/cjs/dto/IdentityType.js +25 -0
  24. package/lib/cjs/dto/app/AppData.d.ts +31 -0
  25. package/lib/cjs/dto/app/AppData.js +2 -0
  26. package/lib/cjs/dto/app/AppListDto.d.ts +6 -0
  27. package/lib/cjs/dto/app/AppListDto.js +2 -0
  28. package/lib/cjs/dto/app/AppPurchasedQueryData.d.ts +28 -0
  29. package/lib/cjs/dto/app/AppPurchasedQueryData.js +2 -0
  30. package/lib/cjs/dto/app/AppQueryData.d.ts +42 -0
  31. package/lib/cjs/dto/app/AppQueryData.js +2 -0
  32. package/lib/cjs/dto/member/MemberListDto.d.ts +6 -0
  33. package/lib/cjs/dto/member/MemberListDto.js +2 -0
  34. package/lib/cjs/dto/member/MemberQueryDto.d.ts +35 -0
  35. package/lib/cjs/dto/member/MemberQueryDto.js +2 -0
  36. package/lib/cjs/dto/org/OrgGetMyData.d.ts +21 -0
  37. package/lib/cjs/dto/org/OrgGetMyData.js +2 -0
  38. package/lib/cjs/dto/org/OrgListDto.d.ts +6 -0
  39. package/lib/cjs/dto/org/OrgListDto.js +2 -0
  40. package/lib/cjs/dto/org/OrgQueryDto.d.ts +39 -0
  41. package/lib/cjs/dto/org/OrgQueryDto.js +2 -0
  42. package/lib/cjs/dto/org/OrgReadDto.d.ts +47 -0
  43. package/lib/cjs/dto/org/OrgReadDto.js +2 -0
  44. package/lib/cjs/dto/org/OrgUpdateReadDto.d.ts +39 -0
  45. package/lib/cjs/dto/org/OrgUpdateReadDto.js +2 -0
  46. package/lib/cjs/dto/public/CurrencyItem.d.ts +31 -0
  47. package/lib/cjs/dto/public/CurrencyItem.js +2 -0
  48. package/lib/cjs/dto/public/PlaceCommon.d.ts +43 -0
  49. package/lib/cjs/dto/public/PlaceCommon.js +2 -0
  50. package/lib/cjs/dto/public/PlaceLocation.d.ts +14 -0
  51. package/lib/cjs/dto/public/PlaceLocation.js +2 -0
  52. package/lib/cjs/dto/public/RegionData.d.ts +36 -0
  53. package/lib/cjs/dto/public/RegionData.js +2 -0
  54. package/lib/cjs/dto/user/AuditHistoryDto.d.ts +26 -0
  55. package/lib/cjs/dto/user/AuditHistoryDto.js +2 -0
  56. package/lib/cjs/dto/user/DeviceListDto.d.ts +8 -0
  57. package/lib/cjs/dto/user/DeviceListDto.js +2 -0
  58. package/lib/cjs/i18n/CoreCulture.d.ts +44 -0
  59. package/lib/cjs/i18n/CoreCulture.js +52 -0
  60. package/lib/cjs/i18n/en.json +40 -0
  61. package/lib/cjs/i18n/zh-Hans.json +40 -0
  62. package/lib/cjs/i18n/zh-Hant.json +40 -0
  63. package/lib/cjs/index.d.ts +39 -0
  64. package/lib/cjs/index.js +59 -0
  65. package/lib/cjs/rq/app/AppGetMyRQ.d.ts +19 -0
  66. package/lib/cjs/rq/app/AppGetMyRQ.js +2 -0
  67. package/lib/cjs/rq/app/AppListRQ.d.ts +18 -0
  68. package/lib/cjs/rq/app/AppListRQ.js +2 -0
  69. package/lib/cjs/rq/app/AppPurchasedQueryRQ.d.ts +17 -0
  70. package/lib/cjs/rq/app/AppPurchasedQueryRQ.js +2 -0
  71. package/lib/cjs/rq/app/AppQueryRQ.d.ts +6 -0
  72. package/lib/cjs/rq/app/AppQueryRQ.js +2 -0
  73. package/lib/cjs/rq/member/MemberListRQ.d.ts +18 -0
  74. package/lib/cjs/rq/member/MemberListRQ.js +2 -0
  75. package/lib/cjs/rq/member/MemberQueryRQ.d.ts +10 -0
  76. package/lib/cjs/rq/member/MemberQueryRQ.js +2 -0
  77. package/lib/cjs/rq/org/OrgCreateRQ.d.ts +37 -0
  78. package/lib/cjs/rq/org/OrgCreateRQ.js +2 -0
  79. package/lib/cjs/rq/org/OrgGetMyRQ.d.ts +11 -0
  80. package/lib/cjs/rq/org/OrgGetMyRQ.js +2 -0
  81. package/lib/cjs/rq/org/OrgListRQ.d.ts +12 -0
  82. package/lib/cjs/rq/org/OrgListRQ.js +2 -0
  83. package/lib/cjs/rq/org/OrgQueryRQ.d.ts +11 -0
  84. package/lib/cjs/rq/org/OrgQueryRQ.js +2 -0
  85. package/lib/cjs/rq/org/OrgUpdateRQ.d.ts +37 -0
  86. package/lib/cjs/rq/org/OrgUpdateRQ.js +2 -0
  87. package/lib/cjs/rq/public/CreateBarcodeRQ.d.ts +56 -0
  88. package/lib/cjs/rq/public/CreateBarcodeRQ.js +2 -0
  89. package/lib/cjs/rq/public/PinyinRQ.d.ts +38 -0
  90. package/lib/cjs/rq/public/PinyinRQ.js +21 -0
  91. package/lib/cjs/rq/public/PlaceQueryRQ.d.ts +58 -0
  92. package/lib/cjs/rq/public/PlaceQueryRQ.js +21 -0
  93. package/lib/cjs/rq/user/AuditHistoryRQ.d.ts +19 -0
  94. package/lib/cjs/rq/user/AuditHistoryRQ.js +2 -0
  95. package/lib/mjs/AppApi.d.ts +48 -0
  96. package/lib/mjs/AppApi.js +50 -0
  97. package/lib/mjs/CoreApp.d.ts +58 -0
  98. package/lib/mjs/CoreApp.js +64 -0
  99. package/lib/mjs/MemberApi.d.ts +38 -0
  100. package/lib/mjs/MemberApi.js +41 -0
  101. package/lib/mjs/OrgApi.d.ts +95 -0
  102. package/lib/mjs/OrgApi.js +106 -0
  103. package/lib/mjs/PublicApi.d.ts +105 -0
  104. package/lib/mjs/PublicApi.js +139 -0
  105. package/lib/mjs/UserApi.d.ts +53 -0
  106. package/lib/mjs/UserApi.js +64 -0
  107. package/lib/mjs/dto/IdentityType.d.ts +21 -0
  108. package/lib/mjs/dto/IdentityType.js +22 -0
  109. package/lib/mjs/dto/app/AppData.d.ts +31 -0
  110. package/lib/mjs/dto/app/AppData.js +1 -0
  111. package/lib/mjs/dto/app/AppListDto.d.ts +6 -0
  112. package/lib/mjs/dto/app/AppListDto.js +1 -0
  113. package/lib/mjs/dto/app/AppPurchasedQueryData.d.ts +28 -0
  114. package/lib/mjs/dto/app/AppPurchasedQueryData.js +1 -0
  115. package/lib/mjs/dto/app/AppQueryData.d.ts +42 -0
  116. package/lib/mjs/dto/app/AppQueryData.js +1 -0
  117. package/lib/mjs/dto/member/MemberListDto.d.ts +6 -0
  118. package/lib/mjs/dto/member/MemberListDto.js +1 -0
  119. package/lib/mjs/dto/member/MemberQueryDto.d.ts +35 -0
  120. package/lib/mjs/dto/member/MemberQueryDto.js +1 -0
  121. package/lib/mjs/dto/org/OrgGetMyData.d.ts +21 -0
  122. package/lib/mjs/dto/org/OrgGetMyData.js +1 -0
  123. package/lib/mjs/dto/org/OrgListDto.d.ts +6 -0
  124. package/lib/mjs/dto/org/OrgListDto.js +1 -0
  125. package/lib/mjs/dto/org/OrgQueryDto.d.ts +39 -0
  126. package/lib/mjs/dto/org/OrgQueryDto.js +1 -0
  127. package/lib/mjs/dto/org/OrgReadDto.d.ts +47 -0
  128. package/lib/mjs/dto/org/OrgReadDto.js +1 -0
  129. package/lib/mjs/dto/org/OrgUpdateReadDto.d.ts +39 -0
  130. package/lib/mjs/dto/org/OrgUpdateReadDto.js +1 -0
  131. package/lib/mjs/dto/public/CurrencyItem.d.ts +31 -0
  132. package/lib/mjs/dto/public/CurrencyItem.js +1 -0
  133. package/lib/mjs/dto/public/PlaceCommon.d.ts +43 -0
  134. package/lib/mjs/dto/public/PlaceCommon.js +1 -0
  135. package/lib/mjs/dto/public/PlaceLocation.d.ts +14 -0
  136. package/lib/mjs/dto/public/PlaceLocation.js +1 -0
  137. package/lib/mjs/dto/public/RegionData.d.ts +36 -0
  138. package/lib/mjs/dto/public/RegionData.js +1 -0
  139. package/lib/mjs/dto/user/AuditHistoryDto.d.ts +26 -0
  140. package/lib/mjs/dto/user/AuditHistoryDto.js +1 -0
  141. package/lib/mjs/dto/user/DeviceListDto.d.ts +8 -0
  142. package/lib/mjs/dto/user/DeviceListDto.js +1 -0
  143. package/lib/mjs/i18n/CoreCulture.d.ts +44 -0
  144. package/lib/mjs/i18n/CoreCulture.js +49 -0
  145. package/lib/mjs/i18n/en.json +40 -0
  146. package/lib/mjs/i18n/zh-Hans.json +40 -0
  147. package/lib/mjs/i18n/zh-Hant.json +40 -0
  148. package/lib/mjs/index.d.ts +39 -0
  149. package/lib/mjs/index.js +43 -0
  150. package/lib/mjs/rq/app/AppGetMyRQ.d.ts +19 -0
  151. package/lib/mjs/rq/app/AppGetMyRQ.js +1 -0
  152. package/lib/mjs/rq/app/AppListRQ.d.ts +18 -0
  153. package/lib/mjs/rq/app/AppListRQ.js +1 -0
  154. package/lib/mjs/rq/app/AppPurchasedQueryRQ.d.ts +17 -0
  155. package/lib/mjs/rq/app/AppPurchasedQueryRQ.js +1 -0
  156. package/lib/mjs/rq/app/AppQueryRQ.d.ts +6 -0
  157. package/lib/mjs/rq/app/AppQueryRQ.js +1 -0
  158. package/lib/mjs/rq/member/MemberListRQ.d.ts +18 -0
  159. package/lib/mjs/rq/member/MemberListRQ.js +1 -0
  160. package/lib/mjs/rq/member/MemberQueryRQ.d.ts +10 -0
  161. package/lib/mjs/rq/member/MemberQueryRQ.js +1 -0
  162. package/lib/mjs/rq/org/OrgCreateRQ.d.ts +37 -0
  163. package/lib/mjs/rq/org/OrgCreateRQ.js +1 -0
  164. package/lib/mjs/rq/org/OrgGetMyRQ.d.ts +11 -0
  165. package/lib/mjs/rq/org/OrgGetMyRQ.js +1 -0
  166. package/lib/mjs/rq/org/OrgListRQ.d.ts +12 -0
  167. package/lib/mjs/rq/org/OrgListRQ.js +1 -0
  168. package/lib/mjs/rq/org/OrgQueryRQ.d.ts +11 -0
  169. package/lib/mjs/rq/org/OrgQueryRQ.js +1 -0
  170. package/lib/mjs/rq/org/OrgUpdateRQ.d.ts +37 -0
  171. package/lib/mjs/rq/org/OrgUpdateRQ.js +1 -0
  172. package/lib/mjs/rq/public/CreateBarcodeRQ.d.ts +56 -0
  173. package/lib/mjs/rq/public/CreateBarcodeRQ.js +1 -0
  174. package/lib/mjs/rq/public/PinyinRQ.d.ts +38 -0
  175. package/lib/mjs/rq/public/PinyinRQ.js +18 -0
  176. package/lib/mjs/rq/public/PlaceQueryRQ.d.ts +58 -0
  177. package/lib/mjs/rq/public/PlaceQueryRQ.js +18 -0
  178. package/lib/mjs/rq/user/AuditHistoryRQ.d.ts +19 -0
  179. package/lib/mjs/rq/user/AuditHistoryRQ.js +1 -0
  180. package/package.json +75 -0
  181. package/src/AppApi.ts +66 -0
  182. package/src/CoreApp.ts +75 -0
  183. package/src/MemberApi.ts +51 -0
  184. package/src/OrgApi.ts +134 -0
  185. package/src/PublicApi.ts +183 -0
  186. package/src/UserApi.ts +77 -0
  187. package/src/dto/IdentityType.ts +23 -0
  188. package/src/dto/app/AppData.ts +35 -0
  189. package/src/dto/app/AppListDto.ts +7 -0
  190. package/src/dto/app/AppPurchasedQueryData.ts +32 -0
  191. package/src/dto/app/AppQueryData.ts +49 -0
  192. package/src/dto/member/MemberListDto.ts +7 -0
  193. package/src/dto/member/MemberQueryDto.ts +43 -0
  194. package/src/dto/org/OrgGetMyData.ts +23 -0
  195. package/src/dto/org/OrgListDto.ts +7 -0
  196. package/src/dto/org/OrgQueryDto.ts +47 -0
  197. package/src/dto/org/OrgReadDto.ts +57 -0
  198. package/src/dto/org/OrgUpdateReadDto.ts +47 -0
  199. package/src/dto/public/CurrencyItem.ts +35 -0
  200. package/src/dto/public/PlaceCommon.ts +52 -0
  201. package/src/dto/public/PlaceLocation.ts +15 -0
  202. package/src/dto/public/RegionData.ts +41 -0
  203. package/src/dto/user/AuditHistoryDto.ts +30 -0
  204. package/src/dto/user/DeviceListDto.ts +8 -0
  205. package/src/i18n/CoreCulture.ts +84 -0
  206. package/src/i18n/en.json +40 -0
  207. package/src/i18n/zh-Hans.json +40 -0
  208. package/src/i18n/zh-Hant.json +40 -0
  209. package/src/index.ts +54 -0
  210. package/src/rq/app/AppGetMyRQ.ts +21 -0
  211. package/src/rq/app/AppListRQ.ts +20 -0
  212. package/src/rq/app/AppPurchasedQueryRQ.ts +19 -0
  213. package/src/rq/app/AppQueryRQ.ts +7 -0
  214. package/src/rq/member/MemberListRQ.ts +21 -0
  215. package/src/rq/member/MemberQueryRQ.ts +11 -0
  216. package/src/rq/org/OrgCreateRQ.ts +43 -0
  217. package/src/rq/org/OrgGetMyRQ.ts +11 -0
  218. package/src/rq/org/OrgListRQ.ts +13 -0
  219. package/src/rq/org/OrgQueryRQ.ts +12 -0
  220. package/src/rq/org/OrgUpdateRQ.ts +43 -0
  221. package/src/rq/public/CreateBarcodeRQ.ts +65 -0
  222. package/src/rq/public/PinyinRQ.ts +43 -0
  223. package/src/rq/public/PlaceQueryRQ.ts +67 -0
  224. package/src/rq/user/AuditHistoryRQ.ts +22 -0
  225. package/tsconfig.cjs.json +19 -0
  226. package/tsconfig.json +19 -0
@@ -0,0 +1,106 @@
1
+ import { EntityApi } from "@etsoo/appscript";
2
+ /**
3
+ * Organization API
4
+ * 机构接口
5
+ */
6
+ export class OrgApi extends EntityApi {
7
+ /**
8
+ * Constructor
9
+ * @param app Application
10
+ * @param api API
11
+ */
12
+ constructor(app, api = app.api) {
13
+ super("Org", app, api);
14
+ }
15
+ /**
16
+ * Create
17
+ * @param rq Request data
18
+ * @param payload Payload
19
+ * @returns Result
20
+ */
21
+ create(rq, payload) {
22
+ return this.createBase(rq, payload);
23
+ }
24
+ /**
25
+ * Delete
26
+ * @param id Id
27
+ * @param payload Payload
28
+ * @returns Result
29
+ */
30
+ delete(id, payload) {
31
+ return this.deleteBase(id, payload);
32
+ }
33
+ /**
34
+ * Get user's latest accessed organizations
35
+ * @param rq Request data
36
+ * @param payload Payload
37
+ * @returns Result
38
+ */
39
+ getMy(rq, payload) {
40
+ return this.api.post(`${this.flag}/GetMy`, rq, payload);
41
+ }
42
+ /**
43
+ * List
44
+ * @param rq Request data
45
+ * @param payload Payload
46
+ * @returns Result
47
+ */
48
+ list(rq, payload) {
49
+ return this.listBase(rq, payload);
50
+ }
51
+ /**
52
+ * Query
53
+ * @param rq Request data
54
+ * @param payload Payload
55
+ * @returns Result
56
+ */
57
+ query(rq, payload) {
58
+ return this.queryBase(rq, payload);
59
+ }
60
+ /**
61
+ * Read
62
+ * @param id Id
63
+ * @param payload Payload
64
+ * @returns Result
65
+ */
66
+ read(id, payload) {
67
+ return this.readBase(id, payload);
68
+ }
69
+ /**
70
+ * Get Antiforgery request token
71
+ * 获取反伪造请求令牌
72
+ * @param payload Payload
73
+ * @returns Result
74
+ */
75
+ requestToken(payload) {
76
+ return this.api.get(`${this.flag}/RequestToken`, undefined, payload);
77
+ }
78
+ /**
79
+ * Update
80
+ * @param rq Request data
81
+ * @param payload Payload
82
+ * @returns Result
83
+ */
84
+ update(rq, payload) {
85
+ return this.updateBase(rq, payload);
86
+ }
87
+ /**
88
+ * Upload avatar
89
+ * @param id Organization id
90
+ * @param data Avatar form data
91
+ * @param payload Payload
92
+ * @returns Result
93
+ */
94
+ uploadAvatar(id, data, payload) {
95
+ return this.api.put(`${this.flag}/UploadAvatar/${id}`, data, payload);
96
+ }
97
+ /**
98
+ * Update read
99
+ * @param id Id
100
+ * @param payload Payload
101
+ * @returns Result
102
+ */
103
+ updateRead(id, payload) {
104
+ return this.updateReadBase(id, payload);
105
+ }
106
+ }
@@ -0,0 +1,105 @@
1
+ import { IApi, IApiPayload } from "@etsoo/restclient";
2
+ import { ListType, ListType1 } from "@etsoo/shared";
3
+ import { PinyinRQ } from "./rq/public/PinyinRQ";
4
+ import { CreateBarcodeRQ } from "./rq/public/CreateBarcodeRQ";
5
+ import { CurrencyItem } from "./dto/public/CurrencyItem";
6
+ import { RegionData } from "./dto/public/RegionData";
7
+ import { PlaceQueryRQ } from "./rq/public/PlaceQueryRQ";
8
+ import { PlaceCommon } from "./dto/public/PlaceCommon";
9
+ import { BaseApi, Currency, IApp, ProductUnit } from "@etsoo/appscript";
10
+ /**
11
+ * Public API
12
+ * 公共接口
13
+ */
14
+ export declare class PublicApi extends BaseApi {
15
+ /**
16
+ * Constructor
17
+ * @param app Application
18
+ * @param api API
19
+ */
20
+ constructor(app: IApp, api?: IApi);
21
+ /**
22
+ * Create barcode
23
+ * @param rq Request data
24
+ * @param payload Payload
25
+ * @returns Result
26
+ */
27
+ createBarcode(rq: CreateBarcodeRQ, payload?: IApiPayload<string>): Promise<string | undefined>;
28
+ /**
29
+ * Get currency label
30
+ * @param currency Currency
31
+ * @returns Label
32
+ */
33
+ getCurrencyLabel(currency: Currency | string): string;
34
+ /**
35
+ * Get currencies
36
+ * @param ids Currency ids to include and order by
37
+ * @param payload Payload
38
+ * @returns Result
39
+ */
40
+ getCurrencies(ids?: string[], payload?: IApiPayload<CurrencyItem[]>): Promise<CurrencyItem[] | undefined>;
41
+ /**
42
+ * Get Pinyin
43
+ * @param rq Request data
44
+ * @param payload Payload
45
+ * @returns Result
46
+ */
47
+ getPinyin(rq: PinyinRQ, payload?: IApiPayload<string>): Promise<string | undefined>;
48
+ /**
49
+ * Get regions
50
+ * @param ids Region ids to include and order by
51
+ * @param payload Payload
52
+ * @returns Result
53
+ */
54
+ getRegions(ids?: string[], payload?: IApiPayload<RegionData[]>): Promise<RegionData[] | undefined>;
55
+ /**
56
+ * Get product unit's label
57
+ * Please define the label in culture with key 'unitPC' for ProductUnit.PC like that
58
+ * @param unit Unit
59
+ * @param isJoined Add the join label like 'per Kg' for Kg
60
+ * @returns Label
61
+ */
62
+ getUnitLabel(unit: ProductUnit | number, isJoined?: boolean | string): string;
63
+ private getUnitJoin;
64
+ /**
65
+ * Get mobile base64 QRCode
66
+ * @param id User id
67
+ * @param host Host URL
68
+ * @param payload Payload
69
+ */
70
+ mobileQRCode(id?: string, host?: string, payload?: IApiPayload<string>): Promise<string | undefined>;
71
+ /**
72
+ * Query place
73
+ * @param rq Request data
74
+ * @param payload Payload
75
+ * @returns Result
76
+ */
77
+ queryPlace(rq: PlaceQueryRQ, payload?: IApiPayload<PlaceCommon[]>): Promise<PlaceCommon[] | undefined>;
78
+ /**
79
+ *
80
+ * Get all repeat options
81
+ * @param options Define the order and limit the items
82
+ * @param isJoined Add the join label
83
+ * @returns Result
84
+ */
85
+ repeatOptions(options?: string[], isJoined?: boolean): ListType[];
86
+ /**
87
+ * Get all supported cultures
88
+ * @param payload Payload
89
+ * @returns Result
90
+ */
91
+ supportedCultures(payload?: IApiPayload<ListType1[]>): Promise<ListType1[] | undefined>;
92
+ /**
93
+ * Get all product units
94
+ * @returns Units
95
+ */
96
+ units(): ListType[];
97
+ /**
98
+ *
99
+ * Get all product units
100
+ * @param options Define the order and limit the items
101
+ * @param isJoined Add the join label like 'per Kg' for Kg
102
+ * @returns Units
103
+ */
104
+ units(options?: string[], isJoined?: boolean): ListType[];
105
+ }
@@ -0,0 +1,139 @@
1
+ import { DataTypes } from "@etsoo/shared";
2
+ import { BaseApi, ProductUnit, RepeatOption } from "@etsoo/appscript";
3
+ const unitPrefix = "unit";
4
+ /**
5
+ * Public API
6
+ * 公共接口
7
+ */
8
+ export class PublicApi extends BaseApi {
9
+ /**
10
+ * Constructor
11
+ * @param app Application
12
+ * @param api API
13
+ */
14
+ constructor(app, api = app.api) {
15
+ super(app, api);
16
+ }
17
+ /**
18
+ * Create barcode
19
+ * @param rq Request data
20
+ * @param payload Payload
21
+ * @returns Result
22
+ */
23
+ createBarcode(rq, payload) {
24
+ return this.api.post("Public/CreateBarcode", rq, payload);
25
+ }
26
+ /**
27
+ * Get currency label
28
+ * @param currency Currency
29
+ * @returns Label
30
+ */
31
+ getCurrencyLabel(currency) {
32
+ const c = `currency${currency}`;
33
+ return this.app.get(c) ?? c;
34
+ }
35
+ /**
36
+ * Get currencies
37
+ * @param ids Currency ids to include and order by
38
+ * @param payload Payload
39
+ * @returns Result
40
+ */
41
+ getCurrencies(ids, payload) {
42
+ return this.api.post("Public/GetCurrencies", ids, payload);
43
+ }
44
+ /**
45
+ * Get Pinyin
46
+ * @param rq Request data
47
+ * @param payload Payload
48
+ * @returns Result
49
+ */
50
+ getPinyin(rq, payload) {
51
+ return this.api.post("Public/GetPinyin", rq, payload);
52
+ }
53
+ /**
54
+ * Get regions
55
+ * @param ids Region ids to include and order by
56
+ * @param payload Payload
57
+ * @returns Result
58
+ */
59
+ getRegions(ids, payload) {
60
+ return this.api.post("Public/GetRegions", ids, payload);
61
+ }
62
+ /**
63
+ * Get product unit's label
64
+ * Please define the label in culture with key 'unitPC' for ProductUnit.PC like that
65
+ * @param unit Unit
66
+ * @param isJoined Add the join label like 'per Kg' for Kg
67
+ * @returns Label
68
+ */
69
+ getUnitLabel(unit, isJoined) {
70
+ const key = ProductUnit[unit];
71
+ const label = this.app.get(unitPrefix + key) ?? key;
72
+ const join = this.getUnitJoin(isJoined);
73
+ if (join) {
74
+ return join.format(label);
75
+ }
76
+ return label;
77
+ }
78
+ getUnitJoin(isJoined) {
79
+ return typeof isJoined === "string"
80
+ ? this.app.get(isJoined) ?? isJoined
81
+ : isJoined
82
+ ? this.app.get("unitJoin")
83
+ : undefined;
84
+ }
85
+ /**
86
+ * Get mobile base64 QRCode
87
+ * @param id User id
88
+ * @param host Host URL
89
+ * @param payload Payload
90
+ */
91
+ mobileQRCode(id, host, payload) {
92
+ return this.api.post("Public/MobileQRCode", { id, host }, payload);
93
+ }
94
+ /**
95
+ * Query place
96
+ * @param rq Request data
97
+ * @param payload Payload
98
+ * @returns Result
99
+ */
100
+ queryPlace(rq, payload) {
101
+ return this.api.post("Public/QueryPlace", rq, payload);
102
+ }
103
+ /**
104
+ *
105
+ * Get all repeat options
106
+ * @param options Define the order and limit the items
107
+ * @param isJoined Add the join label
108
+ * @returns Result
109
+ */
110
+ repeatOptions(options, isJoined = true) {
111
+ options ?? (options = DataTypes.getEnumKeys(RepeatOption));
112
+ return this.units(options, isJoined);
113
+ }
114
+ /**
115
+ * Get all supported cultures
116
+ * @param payload Payload
117
+ * @returns Result
118
+ */
119
+ supportedCultures(payload) {
120
+ return this.api.get("Public/SupportedCultures", undefined, payload);
121
+ }
122
+ /**
123
+ *
124
+ * Get all product units
125
+ * @param options Define the order and limit the items
126
+ * @param isJoined Add the join label like 'per Kg' for Kg
127
+ * @returns Units
128
+ */
129
+ units(options, isJoined) {
130
+ options ?? (options = DataTypes.getEnumKeys(ProductUnit));
131
+ return options.map((key) => {
132
+ const id = DataTypes.getEnumByKey(ProductUnit, key);
133
+ return {
134
+ id,
135
+ label: this.getUnitLabel(id, this.getUnitJoin(isJoined)).formatInitial(true)
136
+ };
137
+ });
138
+ }
139
+ }
@@ -0,0 +1,53 @@
1
+ import { EntityApi, IApp, MsgResultPayload, QueryRQ } from "@etsoo/appscript";
2
+ import { IApi, IApiPayload } from "@etsoo/restclient";
3
+ import { DeviceListDto } from "./dto/user/DeviceListDto";
4
+ import { AuditHistoryRQ } from "./rq/user/AuditHistoryRQ";
5
+ import { AuditHistoryDto } from "./dto/user/AuditHistoryDto";
6
+ import { AppData } from "./dto/app/AppData";
7
+ /**
8
+ * User API
9
+ * 用户接口
10
+ */
11
+ export declare class UserApi extends EntityApi {
12
+ /**
13
+ * Constructor
14
+ * @param app Application
15
+ * @param api API
16
+ */
17
+ constructor(app: IApp, api?: IApi);
18
+ /**
19
+ * Audit history
20
+ * @param rq Request data
21
+ * @param payload Payload
22
+ * @returns Result
23
+ */
24
+ auditHistory(rq: AuditHistoryRQ, payload?: IApiPayload<AuditHistoryDto[]>): Promise<AuditHistoryDto[] | undefined>;
25
+ /**
26
+ * Device list
27
+ * @param rq Request data
28
+ * @param payload Payload
29
+ * @returns Result
30
+ */
31
+ deviceList(rq: QueryRQ, payload?: IApiPayload<DeviceListDto[]>): Promise<DeviceListDto[] | undefined>;
32
+ /**
33
+ * Get user's current apps
34
+ * 获取用户当前应用
35
+ * @param payload Payload
36
+ * @returns Result
37
+ */
38
+ getCurrentApps(payload?: IApiPayload<AppData[]>): Promise<AppData[] | undefined>;
39
+ /**
40
+ * Get user latest app
41
+ * 获取用户最新应用
42
+ * @param payload Payload
43
+ * @returns Result
44
+ */
45
+ getLatestApp(payload?: IApiPayload<string>): Promise<string | undefined>;
46
+ /**
47
+ * Update avatar
48
+ * @param data Avatar form data
49
+ * @param payload Payload
50
+ * @returns Result
51
+ */
52
+ updateAvatar(data: FormData, payload?: MsgResultPayload): Promise<import("@etsoo/shared").MsgActionResult | undefined>;
53
+ }
@@ -0,0 +1,64 @@
1
+ import { EntityApi } from "@etsoo/appscript";
2
+ /**
3
+ * User API
4
+ * 用户接口
5
+ */
6
+ export class UserApi extends EntityApi {
7
+ /**
8
+ * Constructor
9
+ * @param app Application
10
+ * @param api API
11
+ */
12
+ constructor(app, api = app.api) {
13
+ super("User", app, api);
14
+ }
15
+ /**
16
+ * Audit history
17
+ * @param rq Request data
18
+ * @param payload Payload
19
+ * @returns Result
20
+ */
21
+ auditHistory(rq, payload) {
22
+ return this.api.post(`${this.flag}/AuditHistory`, rq, payload);
23
+ }
24
+ /**
25
+ * Device list
26
+ * @param rq Request data
27
+ * @param payload Payload
28
+ * @returns Result
29
+ */
30
+ deviceList(rq, payload) {
31
+ return this.api.post(`${this.flag}/DeviceList`, rq, payload);
32
+ }
33
+ /**
34
+ * Get user's current apps
35
+ * 获取用户当前应用
36
+ * @param payload Payload
37
+ * @returns Result
38
+ */
39
+ getCurrentApps(payload) {
40
+ return this.api.get(`${this.flag}/GetCurrentApps`, undefined, payload);
41
+ }
42
+ /**
43
+ * Get user latest app
44
+ * 获取用户最新应用
45
+ * @param payload Payload
46
+ * @returns Result
47
+ */
48
+ getLatestApp(payload) {
49
+ return this.api.get("User/GetLatestApp", undefined, payload);
50
+ }
51
+ /**
52
+ * Update avatar
53
+ * @param data Avatar form data
54
+ * @param payload Payload
55
+ * @returns Result
56
+ */
57
+ updateAvatar(data, payload) {
58
+ payload ?? (payload = { config: {} });
59
+ // Credentials for anti-forgery cookie sending
60
+ if (payload.config && payload.config.credentials == null)
61
+ payload.config.credentials = "include";
62
+ return this.api.put(`${this.flag}/UpdateAvatar`, data, payload);
63
+ }
64
+ }
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Identity type
3
+ * 标识类型
4
+ */
5
+ export declare enum IdentityType {
6
+ /**
7
+ * User
8
+ * 用户
9
+ */
10
+ User = 1,
11
+ /**
12
+ * Customer
13
+ * 客户
14
+ */
15
+ Customer = 2,
16
+ /**
17
+ * Supplier
18
+ * 供应商
19
+ */
20
+ Supplier = 4
21
+ }
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Identity type
3
+ * 标识类型
4
+ */
5
+ export var IdentityType;
6
+ (function (IdentityType) {
7
+ /**
8
+ * User
9
+ * 用户
10
+ */
11
+ IdentityType[IdentityType["User"] = 1] = "User";
12
+ /**
13
+ * Customer
14
+ * 客户
15
+ */
16
+ IdentityType[IdentityType["Customer"] = 2] = "Customer";
17
+ /**
18
+ * Supplier
19
+ * 供应商
20
+ */
21
+ IdentityType[IdentityType["Supplier"] = 4] = "Supplier";
22
+ })(IdentityType || (IdentityType = {}));
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Application data
3
+ * 程序数据
4
+ */
5
+ export type AppData = {
6
+ /**
7
+ * Id
8
+ * 编号
9
+ */
10
+ id: number;
11
+ /**
12
+ * Application name
13
+ * 程序名称
14
+ */
15
+ name: string;
16
+ /**
17
+ * Web URL
18
+ * Web网址
19
+ */
20
+ webUrl: string;
21
+ /**
22
+ * Help URL
23
+ * 帮助网址
24
+ */
25
+ helpUrl?: string;
26
+ /**
27
+ * Logo
28
+ * 图标
29
+ */
30
+ logo?: string;
31
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,6 @@
1
+ import { DataTypes } from "@etsoo/shared";
2
+ /**
3
+ * Application list data
4
+ * 应用列表数据
5
+ */
6
+ export type AppListDto = DataTypes.IdNameItem & {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,28 @@
1
+ import { EntityStatus } from "@etsoo/appscript";
2
+ import { AppQueryData } from "./AppQueryData";
3
+ /**
4
+ * Application purchased query data
5
+ * 购买的应用查询数据
6
+ */
7
+ export type AppPurchasedQueryData = AppQueryData & {
8
+ /**
9
+ * Expiry
10
+ * 到期时间
11
+ */
12
+ expiry?: string | Date;
13
+ /**
14
+ * Expiry days
15
+ * 到期天数
16
+ */
17
+ expiryDays?: number;
18
+ /**
19
+ * Status
20
+ * 状态
21
+ */
22
+ status: EntityStatus;
23
+ /**
24
+ * Creation
25
+ * 创建时间
26
+ */
27
+ creation: string | Date;
28
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,42 @@
1
+ import { IdentityType } from "../IdentityType";
2
+ /**
3
+ * Application query data
4
+ * 应用查询数据
5
+ */
6
+ export type AppQueryData = {
7
+ /**
8
+ * Id
9
+ * 编号
10
+ */
11
+ id: number;
12
+ /**
13
+ * Name
14
+ * 名称
15
+ */
16
+ name: string;
17
+ /**
18
+ * Identity type
19
+ * 身份类型
20
+ */
21
+ identityType: IdentityType;
22
+ /**
23
+ * Require local URL or not
24
+ * 是否需要本地地址
25
+ */
26
+ requireLocalUrl?: boolean;
27
+ /**
28
+ * Web URL
29
+ * 网页地址
30
+ */
31
+ webUrl: string;
32
+ /**
33
+ * Help URL
34
+ * 帮助地址
35
+ */
36
+ helpUrl?: string;
37
+ /**
38
+ * Logo
39
+ * 图标
40
+ */
41
+ logo?: string;
42
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,6 @@
1
+ import { DataTypes } from "@etsoo/shared";
2
+ /**
3
+ * Member list data
4
+ * 成员列表数据
5
+ */
6
+ export type MemberListDto = DataTypes.IdNameItem & {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,35 @@
1
+ import { EntityStatus, UserRole } from "@etsoo/appscript";
2
+ export type MemberQueryDto = {
3
+ /**
4
+ * Id
5
+ */
6
+ id: number;
7
+ /**
8
+ * Name
9
+ */
10
+ name: string;
11
+ /**
12
+ * User role
13
+ */
14
+ userRole: UserRole;
15
+ /**
16
+ * Status
17
+ */
18
+ status: EntityStatus;
19
+ /**
20
+ * Assigned ID
21
+ */
22
+ assignedId?: string;
23
+ /**
24
+ * Is myself
25
+ */
26
+ isSelf: boolean;
27
+ /**
28
+ * Is owner
29
+ */
30
+ isOwner: boolean;
31
+ /**
32
+ * Creation
33
+ */
34
+ creation: string | Date;
35
+ };
@@ -0,0 +1 @@
1
+ export {};