@etsoo/smarterp-core 1.0.0 → 1.0.2

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 (217) hide show
  1. package/__tests__/OrgApi.ts +6 -3
  2. package/__tests__/PublicApi.ts +3 -1
  3. package/__tests__/UserApi.ts +1 -1
  4. package/__tests__/tsconfig.json +12 -10
  5. package/lib/cjs/AppApi.d.ts +59 -1
  6. package/lib/cjs/AppApi.js +64 -1
  7. package/lib/cjs/AuthCodeApi.d.ts +29 -0
  8. package/lib/cjs/AuthCodeApi.js +50 -0
  9. package/lib/cjs/CoreApp.d.ts +116 -10
  10. package/lib/cjs/CoreApp.js +72 -6
  11. package/lib/cjs/CoreUtils.d.ts +4 -0
  12. package/lib/cjs/CoreUtils.js +2 -0
  13. package/lib/cjs/ICoreServiceApp.d.ts +30 -0
  14. package/lib/cjs/ICoreServiceApp.js +49 -0
  15. package/lib/cjs/MemberApi.d.ts +41 -1
  16. package/lib/cjs/MemberApi.js +46 -0
  17. package/lib/cjs/OrgApi.d.ts +9 -2
  18. package/lib/cjs/OrgApi.js +12 -3
  19. package/lib/cjs/PublicApi.d.ts +17 -1
  20. package/lib/cjs/PublicApi.js +20 -2
  21. package/lib/cjs/UserApi.d.ts +30 -1
  22. package/lib/cjs/UserApi.js +36 -1
  23. package/lib/cjs/components/DefaultUI.d.ts +21 -0
  24. package/lib/cjs/components/DefaultUI.js +34 -0
  25. package/lib/cjs/components/app/AppSwitchPopover.d.ts +4 -0
  26. package/lib/cjs/components/app/AppSwitchPopover.js +43 -0
  27. package/lib/cjs/components/index.d.ts +4 -0
  28. package/lib/cjs/components/index.js +23 -0
  29. package/lib/cjs/components/org/OrgSwitchPopover.d.ts +4 -0
  30. package/lib/cjs/components/org/OrgSwitchPopover.js +49 -0
  31. package/lib/cjs/components/org/OrgTiplist.d.ts +23 -0
  32. package/lib/cjs/components/org/OrgTiplist.js +28 -0
  33. package/lib/cjs/dto/app/AppQueryData.d.ts +5 -0
  34. package/lib/cjs/dto/app/AppReadDto.d.ts +62 -0
  35. package/lib/cjs/dto/app/AppReadDto.js +2 -0
  36. package/lib/cjs/dto/app/AppUpdateReadDto.d.ts +35 -0
  37. package/lib/cjs/dto/app/AppUpdateReadDto.js +2 -0
  38. package/lib/cjs/dto/app/CreateApiKeyData.d.ts +16 -0
  39. package/lib/cjs/dto/app/CreateApiKeyData.js +2 -0
  40. package/lib/cjs/dto/authCode/AuthCodeAction.d.ts +12 -0
  41. package/lib/cjs/dto/authCode/AuthCodeAction.js +16 -0
  42. package/lib/cjs/dto/member/MemberQueryDto.d.ts +4 -0
  43. package/lib/cjs/dto/member/MemberReadDto.d.ts +56 -0
  44. package/lib/cjs/dto/member/MemberReadDto.js +2 -0
  45. package/lib/cjs/dto/member/MemberUpdateReadDto.d.ts +39 -0
  46. package/lib/cjs/dto/member/MemberUpdateReadDto.js +2 -0
  47. package/lib/cjs/dto/org/OrgListDto.d.ts +7 -1
  48. package/lib/cjs/dto/org/OrgQueryDto.d.ts +8 -0
  49. package/lib/cjs/dto/org/OrgReadDto.d.ts +16 -0
  50. package/lib/cjs/dto/org/OrgUpdateReadDto.d.ts +0 -4
  51. package/lib/cjs/dto/public/MemberInvitationDto.d.ts +29 -0
  52. package/lib/cjs/dto/public/MemberInvitationDto.js +2 -0
  53. package/lib/cjs/dto/user/AuditHistoryDto.d.ts +8 -4
  54. package/lib/cjs/dto/user/UserIdentifierData.d.ts +27 -0
  55. package/lib/cjs/dto/user/UserIdentifierData.js +2 -0
  56. package/lib/cjs/i18n/en.json +40 -2
  57. package/lib/cjs/i18n/zh-Hans.json +40 -2
  58. package/lib/cjs/i18n/zh-Hant.json +40 -2
  59. package/lib/cjs/index.d.ts +22 -0
  60. package/lib/cjs/index.js +22 -0
  61. package/lib/cjs/rq/app/AppBuyNewRQ.d.ts +26 -0
  62. package/lib/cjs/rq/app/AppBuyNewRQ.js +2 -0
  63. package/lib/cjs/rq/app/AppBuyRQ.d.ts +16 -0
  64. package/lib/cjs/rq/app/AppBuyRQ.js +2 -0
  65. package/lib/cjs/rq/app/AppCreateApiKeyRQ.d.ts +16 -0
  66. package/lib/cjs/rq/app/AppCreateApiKeyRQ.js +2 -0
  67. package/lib/cjs/rq/app/AppGetMyRQ.d.ts +1 -1
  68. package/lib/cjs/rq/app/AppRenewRQ.d.ts +16 -0
  69. package/lib/cjs/rq/app/AppRenewRQ.js +2 -0
  70. package/lib/cjs/rq/app/AppUpdateRQ.d.ts +31 -0
  71. package/lib/cjs/rq/app/AppUpdateRQ.js +2 -0
  72. package/lib/cjs/rq/authCode/SendEmailRQ.d.ts +31 -0
  73. package/lib/cjs/rq/authCode/SendEmailRQ.js +2 -0
  74. package/lib/cjs/rq/authCode/SendSMSRQ.d.ts +27 -0
  75. package/lib/cjs/rq/authCode/SendSMSRQ.js +2 -0
  76. package/lib/cjs/rq/authCode/ValidateRQ.d.ts +17 -0
  77. package/lib/cjs/rq/authCode/ValidateRQ.js +2 -0
  78. package/lib/cjs/rq/member/MemberInviteRQ.d.ts +22 -0
  79. package/lib/cjs/rq/member/MemberInviteRQ.js +2 -0
  80. package/lib/cjs/rq/member/MemberUpdateRQ.d.ts +32 -0
  81. package/lib/cjs/rq/member/MemberUpdateRQ.js +2 -0
  82. package/lib/cjs/rq/org/OrgCreateRQ.d.ts +5 -0
  83. package/lib/cjs/rq/public/AcceptInvitationRQ.d.ts +16 -0
  84. package/lib/cjs/rq/public/AcceptInvitationRQ.js +2 -0
  85. package/lib/cjs/rq/user/AuditHistoryRQ.d.ts +8 -0
  86. package/lib/mjs/AppApi.d.ts +59 -1
  87. package/lib/mjs/AppApi.js +64 -1
  88. package/lib/mjs/AuthCodeApi.d.ts +29 -0
  89. package/lib/mjs/AuthCodeApi.js +46 -0
  90. package/lib/mjs/CoreApp.d.ts +116 -10
  91. package/lib/mjs/CoreApp.js +73 -7
  92. package/lib/mjs/CoreUtils.d.ts +4 -0
  93. package/lib/mjs/CoreUtils.js +1 -0
  94. package/lib/mjs/ICoreServiceApp.d.ts +30 -0
  95. package/lib/mjs/ICoreServiceApp.js +41 -0
  96. package/lib/mjs/MemberApi.d.ts +41 -1
  97. package/lib/mjs/MemberApi.js +46 -0
  98. package/lib/mjs/OrgApi.d.ts +9 -2
  99. package/lib/mjs/OrgApi.js +12 -3
  100. package/lib/mjs/PublicApi.d.ts +17 -1
  101. package/lib/mjs/PublicApi.js +20 -2
  102. package/lib/mjs/UserApi.d.ts +30 -1
  103. package/lib/mjs/UserApi.js +36 -1
  104. package/lib/mjs/components/DefaultUI.d.ts +21 -0
  105. package/lib/mjs/components/DefaultUI.js +31 -0
  106. package/lib/mjs/components/app/AppSwitchPopover.d.ts +4 -0
  107. package/lib/mjs/components/app/AppSwitchPopover.js +37 -0
  108. package/lib/mjs/components/index.d.ts +4 -0
  109. package/lib/mjs/components/index.js +7 -0
  110. package/lib/mjs/components/org/OrgSwitchPopover.d.ts +4 -0
  111. package/lib/mjs/components/org/OrgSwitchPopover.js +43 -0
  112. package/lib/mjs/components/org/OrgTiplist.d.ts +23 -0
  113. package/lib/mjs/components/org/OrgTiplist.js +25 -0
  114. package/lib/mjs/dto/app/AppQueryData.d.ts +5 -0
  115. package/lib/mjs/dto/app/AppReadDto.d.ts +62 -0
  116. package/lib/mjs/dto/app/AppReadDto.js +1 -0
  117. package/lib/mjs/dto/app/AppUpdateReadDto.d.ts +35 -0
  118. package/lib/mjs/dto/app/AppUpdateReadDto.js +1 -0
  119. package/lib/mjs/dto/app/CreateApiKeyData.d.ts +16 -0
  120. package/lib/mjs/dto/app/CreateApiKeyData.js +1 -0
  121. package/lib/mjs/dto/authCode/AuthCodeAction.d.ts +12 -0
  122. package/lib/mjs/dto/authCode/AuthCodeAction.js +13 -0
  123. package/lib/mjs/dto/member/MemberQueryDto.d.ts +4 -0
  124. package/lib/mjs/dto/member/MemberReadDto.d.ts +56 -0
  125. package/lib/mjs/dto/member/MemberReadDto.js +1 -0
  126. package/lib/mjs/dto/member/MemberUpdateReadDto.d.ts +39 -0
  127. package/lib/mjs/dto/member/MemberUpdateReadDto.js +1 -0
  128. package/lib/mjs/dto/org/OrgListDto.d.ts +7 -1
  129. package/lib/mjs/dto/org/OrgQueryDto.d.ts +8 -0
  130. package/lib/mjs/dto/org/OrgReadDto.d.ts +16 -0
  131. package/lib/mjs/dto/org/OrgUpdateReadDto.d.ts +0 -4
  132. package/lib/mjs/dto/public/MemberInvitationDto.d.ts +29 -0
  133. package/lib/mjs/dto/public/MemberInvitationDto.js +1 -0
  134. package/lib/mjs/dto/user/AuditHistoryDto.d.ts +8 -4
  135. package/lib/mjs/dto/user/UserIdentifierData.d.ts +27 -0
  136. package/lib/mjs/dto/user/UserIdentifierData.js +1 -0
  137. package/lib/mjs/i18n/en.json +40 -2
  138. package/lib/mjs/i18n/zh-Hans.json +40 -2
  139. package/lib/mjs/i18n/zh-Hant.json +40 -2
  140. package/lib/mjs/index.d.ts +22 -0
  141. package/lib/mjs/index.js +22 -0
  142. package/lib/mjs/rq/app/AppBuyNewRQ.d.ts +26 -0
  143. package/lib/mjs/rq/app/AppBuyNewRQ.js +1 -0
  144. package/lib/mjs/rq/app/AppBuyRQ.d.ts +16 -0
  145. package/lib/mjs/rq/app/AppBuyRQ.js +1 -0
  146. package/lib/mjs/rq/app/AppCreateApiKeyRQ.d.ts +16 -0
  147. package/lib/mjs/rq/app/AppCreateApiKeyRQ.js +1 -0
  148. package/lib/mjs/rq/app/AppGetMyRQ.d.ts +1 -1
  149. package/lib/mjs/rq/app/AppRenewRQ.d.ts +16 -0
  150. package/lib/mjs/rq/app/AppRenewRQ.js +1 -0
  151. package/lib/mjs/rq/app/AppUpdateRQ.d.ts +31 -0
  152. package/lib/mjs/rq/app/AppUpdateRQ.js +1 -0
  153. package/lib/mjs/rq/authCode/SendEmailRQ.d.ts +31 -0
  154. package/lib/mjs/rq/authCode/SendEmailRQ.js +1 -0
  155. package/lib/mjs/rq/authCode/SendSMSRQ.d.ts +27 -0
  156. package/lib/mjs/rq/authCode/SendSMSRQ.js +1 -0
  157. package/lib/mjs/rq/authCode/ValidateRQ.d.ts +17 -0
  158. package/lib/mjs/rq/authCode/ValidateRQ.js +1 -0
  159. package/lib/mjs/rq/member/MemberInviteRQ.d.ts +22 -0
  160. package/lib/mjs/rq/member/MemberInviteRQ.js +1 -0
  161. package/lib/mjs/rq/member/MemberUpdateRQ.d.ts +32 -0
  162. package/lib/mjs/rq/member/MemberUpdateRQ.js +1 -0
  163. package/lib/mjs/rq/org/OrgCreateRQ.d.ts +5 -0
  164. package/lib/mjs/rq/public/AcceptInvitationRQ.d.ts +16 -0
  165. package/lib/mjs/rq/public/AcceptInvitationRQ.js +1 -0
  166. package/lib/mjs/rq/user/AuditHistoryRQ.d.ts +8 -0
  167. package/package.json +26 -36
  168. package/src/AppApi.ts +89 -2
  169. package/src/AuthCodeApi.ts +51 -0
  170. package/src/CoreApp.ts +152 -9
  171. package/src/CoreUtils.ts +4 -0
  172. package/src/ICoreServiceApp.ts +62 -0
  173. package/src/MemberApi.ts +61 -2
  174. package/src/OrgApi.ts +13 -3
  175. package/src/PublicApi.ts +24 -1
  176. package/src/UserApi.ts +53 -1
  177. package/src/components/DefaultUI.tsx +37 -0
  178. package/src/components/app/AppSwitchPopover.tsx +83 -0
  179. package/src/components/index.ts +9 -0
  180. package/src/components/org/OrgSwitchPopover.tsx +99 -0
  181. package/src/components/org/OrgTiplist.tsx +69 -0
  182. package/src/dto/app/AppQueryData.ts +6 -0
  183. package/src/dto/app/AppReadDto.ts +75 -0
  184. package/src/dto/app/AppUpdateReadDto.ts +42 -0
  185. package/src/dto/app/CreateApiKeyData.ts +17 -0
  186. package/src/dto/authCode/AuthCodeAction.ts +13 -0
  187. package/src/dto/member/MemberQueryDto.ts +5 -0
  188. package/src/dto/member/MemberReadDto.ts +68 -0
  189. package/src/dto/member/MemberUpdateReadDto.ts +47 -0
  190. package/src/dto/org/OrgListDto.ts +7 -1
  191. package/src/dto/org/OrgQueryDto.ts +10 -0
  192. package/src/dto/org/OrgReadDto.ts +20 -0
  193. package/src/dto/org/OrgUpdateReadDto.ts +0 -5
  194. package/src/dto/public/MemberInvitationDto.ts +34 -0
  195. package/src/dto/user/AuditHistoryDto.ts +9 -4
  196. package/src/dto/user/UserIdentifierData.ts +31 -0
  197. package/src/i18n/en.json +40 -2
  198. package/src/i18n/zh-Hans.json +40 -2
  199. package/src/i18n/zh-Hant.json +40 -2
  200. package/src/index.ts +24 -0
  201. package/src/rq/app/AppBuyNewRQ.ts +29 -0
  202. package/src/rq/app/AppBuyRQ.ts +17 -0
  203. package/src/rq/app/AppCreateApiKeyRQ.ts +17 -0
  204. package/src/rq/app/AppGetMyRQ.ts +1 -1
  205. package/src/rq/app/AppRenewRQ.ts +17 -0
  206. package/src/rq/app/AppUpdateRQ.ts +36 -0
  207. package/src/rq/authCode/SendEmailRQ.ts +36 -0
  208. package/src/rq/authCode/SendSMSRQ.ts +31 -0
  209. package/src/rq/authCode/ValidateRQ.ts +19 -0
  210. package/src/rq/member/MemberInviteRQ.ts +25 -0
  211. package/src/rq/member/MemberUpdateRQ.ts +37 -0
  212. package/src/rq/org/OrgCreateRQ.ts +6 -0
  213. package/src/rq/public/AcceptInvitationRQ.ts +17 -0
  214. package/src/rq/user/AuditHistoryRQ.ts +10 -0
  215. package/tsconfig.cjs.json +4 -3
  216. package/tsconfig.json +5 -4
  217. package/vite.config.mts +12 -0
@@ -3,10 +3,11 @@ import { isLocalTest, TestApp } from "./app/TestApp";
3
3
  import { EntityStatus } from "@etsoo/appscript";
4
4
  import { OrgApi } from "../src/OrgApi";
5
5
  import { OrgCreateRQ } from "../src/rq/org/OrgCreateRQ";
6
+ import { OrgUpdateRQ } from "../src";
6
7
 
7
8
  if (isLocalTest) {
8
9
  const app = new TestApp();
9
- app.changeCulture(app.settings.cultures[0]);
10
+ await app.changeCulture(app.settings.cultures[0]);
10
11
 
11
12
  // Simulate logined
12
13
  app.authorize(
@@ -22,12 +23,14 @@ if (isLocalTest) {
22
23
  ? {
23
24
  name: `青岛亿速思维网络科技有限公司`,
24
25
  brand: "亿速思维",
25
- pin: guid
26
+ pin: guid,
27
+ region: "CN"
26
28
  }
27
29
  : {
28
30
  name: `上海亿商网络科技有限公司`,
29
31
  brand: "亿商",
30
- pin: guid
32
+ pin: guid,
33
+ region: "CN"
31
34
  };
32
35
 
33
36
  const result = await api.create(rq);
@@ -2,9 +2,11 @@ import { isLocalTest, TestApp } from "./app/TestApp";
2
2
  import { PublicApi } from "../src/PublicApi";
3
3
  import { PinyinFormatType } from "../src/rq/public/PinyinRQ";
4
4
  import { ApiProvider } from "../src/rq/public/PlaceQueryRQ";
5
+ import { act } from "react";
5
6
 
6
7
  const app = new TestApp();
7
- app.changeCulture(app.settings.cultures[0]);
8
+
9
+ await app.changeCulture(app.settings.cultures[0]);
8
10
 
9
11
  const api = new PublicApi(app);
10
12
 
@@ -3,7 +3,7 @@ import { UserApi } from "../src";
3
3
 
4
4
  if (isLocalTest) {
5
5
  const app = new TestApp();
6
- app.changeCulture(app.settings.cultures[0]);
6
+ await app.changeCulture(app.settings.cultures[0]);
7
7
 
8
8
  // Simulate logined
9
9
  app.authorize(
@@ -1,18 +1,20 @@
1
1
  {
2
2
  "compilerOptions": {
3
- "target": "ES2020",
4
- "module": "ESNext",
5
- "moduleResolution": "Node10",
3
+ /* Visit https://aka.ms/tsconfig.json to read more about this file */
4
+ "target": "ES2022",
5
+ "module": "ES2022",
6
+ "moduleResolution": "bundler",
6
7
  "allowJs": false,
7
- "skipLibCheck": true,
8
- "esModuleInterop": true,
9
- "allowSyntheticDefaultImports": true,
8
+ "isolatedModules": true,
9
+ "outDir": "./lib",
10
+ "noEmit": false,
11
+ "declaration": true,
10
12
  "strict": true,
13
+ "esModuleInterop": true,
14
+ "skipLibCheck": false,
15
+ "jsx": "react-jsx",
11
16
  "forceConsistentCasingInFileNames": true,
12
- "resolveJsonModule": true,
13
- "isolatedModules": true,
14
- "noEmit": true,
15
- "declaration": true
17
+ "types": ["vitest/globals"]
16
18
  },
17
19
  "include": [".."]
18
20
  }
@@ -1,5 +1,5 @@
1
1
  import { IApi, IApiPayload } from "@etsoo/restclient";
2
- import { EntityApi, IApp } from "@etsoo/appscript";
2
+ import { EntityApi, IApp, IdResultPayload, ResultPayload } from "@etsoo/appscript";
3
3
  import { AppGetMyRQ } from "./rq/app/AppGetMyRQ";
4
4
  import { AppQueryData } from "./dto/app/AppQueryData";
5
5
  import { AppListRQ } from "./rq/app/AppListRQ";
@@ -7,6 +7,15 @@ import { AppListDto } from "./dto/app/AppListDto";
7
7
  import { AppQueryRQ } from "./rq/app/AppQueryRQ";
8
8
  import { AppPurchasedQueryRQ } from "./rq/app/AppPurchasedQueryRQ";
9
9
  import { AppPurchasedQueryData } from "./dto/app/AppPurchasedQueryData";
10
+ import { AppBuyNewRQ } from "./rq/app/AppBuyNewRQ";
11
+ import { AppBuyRQ } from "./rq/app/AppBuyRQ";
12
+ import { AppRenewRQ } from "./rq/app/AppRenewRQ";
13
+ import { AppUpdateRQ } from "./rq/app/AppUpdateRQ";
14
+ import { AppUpdateReadDto } from "./dto/app/AppUpdateReadDto";
15
+ import { AppReadDto } from "./dto/app/AppReadDto";
16
+ import { CreateApiKeyData } from "./dto/app/CreateApiKeyData";
17
+ import { IActionResult } from "@etsoo/shared";
18
+ import { AppCreateApiKeyRQ } from "./rq/app/AppCreateApiKeyRQ";
10
19
  /**
11
20
  * Application API
12
21
  */
@@ -17,6 +26,27 @@ export declare class AppApi extends EntityApi {
17
26
  * @param api API
18
27
  */
19
28
  constructor(app: IApp, api?: IApi);
29
+ /**
30
+ * Buy the application
31
+ * @param rq Request data
32
+ * @param payload Payload
33
+ * @returns Result
34
+ */
35
+ buy(rq: AppBuyRQ, payload?: ResultPayload): Promise<IActionResult<{}> | undefined>;
36
+ /**
37
+ * Buy and create new organization
38
+ * @param rq Request data
39
+ * @param payload Payload
40
+ * @returns Result
41
+ */
42
+ buyNew(rq: AppBuyNewRQ, payload?: IdResultPayload): Promise<import("@etsoo/shared").IdActionResult | undefined>;
43
+ /**
44
+ * Create API key
45
+ * @param rq Request data
46
+ * @param payload Payload
47
+ * @returns Result
48
+ */
49
+ createApiKey(rq: AppCreateApiKeyRQ, payload?: IApiPayload<IActionResult<CreateApiKeyData>>): Promise<IActionResult<CreateApiKeyData> | undefined>;
20
50
  /**
21
51
  * Get user's latest accessed applications
22
52
  * @param rq Request data
@@ -45,4 +75,32 @@ export declare class AppApi extends EntityApi {
45
75
  * @returns Result
46
76
  */
47
77
  queryPurchased(rq: AppPurchasedQueryRQ, payload?: IApiPayload<AppPurchasedQueryData[]>): Promise<AppPurchasedQueryData[] | undefined>;
78
+ /**
79
+ * Read
80
+ * @param id Id
81
+ * @param payload Payload
82
+ * @returns Result
83
+ */
84
+ read(id: number, payload?: IApiPayload<AppReadDto>): Promise<AppReadDto | undefined>;
85
+ /**
86
+ * Renew the application
87
+ * @param rq Request data
88
+ * @param payload Payload
89
+ * @returns Result
90
+ */
91
+ renew(rq: AppRenewRQ, payload?: ResultPayload): Promise<IActionResult<{}> | undefined>;
92
+ /**
93
+ * Update the application
94
+ * @param rq Request data
95
+ * @param payload Payload
96
+ * @returns Result
97
+ */
98
+ update(rq: AppUpdateRQ, payload?: ResultPayload): Promise<IActionResult<{}> | undefined>;
99
+ /**
100
+ * Update read
101
+ * @param id Id
102
+ * @param payload Payload
103
+ * @returns Result
104
+ */
105
+ updateRead(id: number, payload?: IApiPayload<AppUpdateReadDto>): Promise<AppUpdateReadDto | undefined>;
48
106
  }
package/lib/cjs/AppApi.js CHANGED
@@ -14,6 +14,33 @@ class AppApi extends appscript_1.EntityApi {
14
14
  constructor(app, api = app.api) {
15
15
  super("App", app, api);
16
16
  }
17
+ /**
18
+ * Buy the application
19
+ * @param rq Request data
20
+ * @param payload Payload
21
+ * @returns Result
22
+ */
23
+ buy(rq, payload) {
24
+ return this.api.post(`${this.flag}/Buy`, rq, payload);
25
+ }
26
+ /**
27
+ * Buy and create new organization
28
+ * @param rq Request data
29
+ * @param payload Payload
30
+ * @returns Result
31
+ */
32
+ buyNew(rq, payload) {
33
+ return this.api.post(`${this.flag}/BuyNew`, rq, payload);
34
+ }
35
+ /**
36
+ * Create API key
37
+ * @param rq Request data
38
+ * @param payload Payload
39
+ * @returns Result
40
+ */
41
+ createApiKey(rq, payload) {
42
+ return this.api.put(`${this.flag}/CreateApiKey`, rq, payload);
43
+ }
17
44
  /**
18
45
  * Get user's latest accessed applications
19
46
  * @param rq Request data
@@ -48,7 +75,43 @@ class AppApi extends appscript_1.EntityApi {
48
75
  * @returns Result
49
76
  */
50
77
  queryPurchased(rq, payload) {
51
- return this.queryBase(rq, payload);
78
+ return this.queryBase(rq, payload, "Purchased");
79
+ }
80
+ /**
81
+ * Read
82
+ * @param id Id
83
+ * @param payload Payload
84
+ * @returns Result
85
+ */
86
+ read(id, payload) {
87
+ return this.readBase(id, payload);
88
+ }
89
+ /**
90
+ * Renew the application
91
+ * @param rq Request data
92
+ * @param payload Payload
93
+ * @returns Result
94
+ */
95
+ renew(rq, payload) {
96
+ return this.api.put(`${this.flag}/Renew`, rq, payload);
97
+ }
98
+ /**
99
+ * Update the application
100
+ * @param rq Request data
101
+ * @param payload Payload
102
+ * @returns Result
103
+ */
104
+ update(rq, payload) {
105
+ return this.api.put(`${this.flag}/Update`, rq, payload);
106
+ }
107
+ /**
108
+ * Update read
109
+ * @param id Id
110
+ * @param payload Payload
111
+ * @returns Result
112
+ */
113
+ updateRead(id, payload) {
114
+ return this.updateReadBase(id, payload);
52
115
  }
53
116
  }
54
117
  exports.AppApi = AppApi;
@@ -0,0 +1,29 @@
1
+ import { BaseApi, IApi, IApp, StringIdResultPayload } from "@etsoo/appscript";
2
+ import { SendEmailInputRQ } from "./rq/authCode/SendEmailRQ";
3
+ import { SendSMSInputRQ } from "./rq/authCode/SendSMSRQ";
4
+ /**
5
+ * Auth Code API
6
+ * 验证码接口
7
+ */
8
+ export declare class AuthCodeApi extends BaseApi {
9
+ /**
10
+ * Constructor
11
+ * @param app Application
12
+ * @param api API
13
+ */
14
+ constructor(app: IApp, api?: IApi);
15
+ /**
16
+ * Send email
17
+ * @param rq Request data
18
+ * @param payload Payload
19
+ * @returns Result
20
+ */
21
+ sendEmail(rq: SendEmailInputRQ, payload?: StringIdResultPayload): Promise<import("@etsoo/shared").IdActionResult<string> | undefined>;
22
+ /**
23
+ * Send email
24
+ * @param rq Request data
25
+ * @param payload Payload
26
+ * @returns Result
27
+ */
28
+ sendSMS(rq: SendSMSInputRQ, payload?: StringIdResultPayload): Promise<import("@etsoo/shared").IdActionResult<string> | undefined>;
29
+ }
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AuthCodeApi = void 0;
4
+ const appscript_1 = require("@etsoo/appscript");
5
+ /**
6
+ * Auth Code API
7
+ * 验证码接口
8
+ */
9
+ class AuthCodeApi extends appscript_1.BaseApi {
10
+ /**
11
+ * Constructor
12
+ * @param app Application
13
+ * @param api API
14
+ */
15
+ constructor(app, api = app.api) {
16
+ super(app, api);
17
+ }
18
+ /**
19
+ * Send email
20
+ * @param rq Request data
21
+ * @param payload Payload
22
+ * @returns Result
23
+ */
24
+ sendEmail(rq, payload) {
25
+ const { deviceId, region } = this.app;
26
+ const data = {
27
+ ...rq,
28
+ deviceId,
29
+ region,
30
+ timezone: this.app.getTimeZone()
31
+ };
32
+ return this.api.put("AuthCode/SendEmail", data, payload);
33
+ }
34
+ /**
35
+ * Send email
36
+ * @param rq Request data
37
+ * @param payload Payload
38
+ * @returns Result
39
+ */
40
+ sendSMS(rq, payload) {
41
+ const { deviceId, region } = this.app;
42
+ const data = {
43
+ ...rq,
44
+ deviceId,
45
+ region
46
+ };
47
+ return this.api.put("AuthCode/SendSMS", data, payload);
48
+ }
49
+ }
50
+ exports.AuthCodeApi = AuthCodeApi;
@@ -4,45 +4,118 @@ import { OrgApi } from "./OrgApi";
4
4
  import { AppApi } from "./AppApi";
5
5
  import { PublicApi } from "./PublicApi";
6
6
  import { UserApi } from "./UserApi";
7
- import { AuthApi, IApp } from "@etsoo/appscript";
7
+ import { AuthApi, IApp, UserIdentifierType } from "@etsoo/appscript";
8
+ import { IdentityType } from "./dto/IdentityType";
9
+ import { AuthCodeApi } from "./AuthCodeApi";
10
+ import { AppQueryData } from "./dto/app/AppQueryData";
11
+ import { ListType } from "@etsoo/shared";
12
+ /**
13
+ * Core application interface
14
+ * 核心应用程序接口
15
+ */
16
+ export interface ICoreApp {
17
+ /**
18
+ * Application API
19
+ */
20
+ appApi: AppApi;
21
+ /**
22
+ * Authentication API
23
+ */
24
+ readonly authApi: AuthApi;
25
+ /**
26
+ * Auth code API
27
+ */
28
+ readonly authCodeApi: AuthCodeApi;
29
+ /**
30
+ * Member API
31
+ */
32
+ readonly memberApi: MemberApi;
33
+ /**
34
+ * Organization API
35
+ */
36
+ readonly orgApi: OrgApi;
37
+ /**
38
+ * Public API
39
+ */
40
+ readonly publicApi: PublicApi;
41
+ /**
42
+ * User API
43
+ */
44
+ readonly userApi: UserApi;
45
+ /**
46
+ * Get app name
47
+ * 获取应用名称
48
+ * @param data App data
49
+ * @returns Name
50
+ */
51
+ getAppName(data: AppQueryData): string;
52
+ /**
53
+ * Get user identifier type label
54
+ * 获取用户标识类型标签
55
+ * @param type Type
56
+ * @returns Label
57
+ */
58
+ getIdentifierTypeLabel(type: UserIdentifierType): string;
59
+ /**
60
+ * Get identity label
61
+ * 获取身份标签
62
+ * @param identity Identity value
63
+ * @param joinChar Join character
64
+ * @returns Label(s)
65
+ */
66
+ getIdentityLabel(identity: IdentityType | null | undefined, joinChar?: string): string;
67
+ /**
68
+ * Get identities
69
+ * 获取身份列表
70
+ * @param identity Identity value combined
71
+ * @returns List
72
+ */
73
+ getIdentities(identity?: number): ListType[];
74
+ }
8
75
  /**
9
76
  * Core application
10
77
  * 核心应用程序
11
78
  */
12
- export declare class CoreApp {
13
- protected app: IApp;
14
- protected api: IApi;
15
- _appApi?: AppApi;
79
+ export declare class CoreApp implements ICoreApp {
80
+ readonly app: IApp;
81
+ readonly api: IApi;
82
+ private _appApi?;
16
83
  /**
17
84
  * Application API
18
85
  * 应用程序接口
19
86
  */
20
87
  get appApi(): AppApi;
21
- _authApi?: AuthApi;
88
+ private _authApi?;
22
89
  /**
23
90
  * Authentication API
24
91
  * 认证接口
25
92
  */
26
93
  get authApi(): AuthApi;
27
- _memberApi?: MemberApi;
94
+ private _authCodeApi?;
95
+ /**
96
+ * Authentication API
97
+ * 认证接口
98
+ */
99
+ get authCodeApi(): AuthCodeApi;
100
+ private _memberApi?;
28
101
  /**
29
102
  * Member API
30
103
  * 会员接口
31
104
  */
32
105
  get memberApi(): MemberApi;
33
- _orgApi?: OrgApi;
106
+ private _orgApi?;
34
107
  /**
35
108
  * Organization API
36
109
  * 机构接口
37
110
  */
38
111
  get orgApi(): OrgApi;
39
- _publicApi?: PublicApi;
112
+ private _publicApi?;
40
113
  /**
41
114
  * Public API
42
115
  * 公共接口
43
116
  */
44
117
  get publicApi(): PublicApi;
45
- _userApi?: UserApi;
118
+ private _userApi?;
46
119
  /**
47
120
  * User API
48
121
  * 用户接口
@@ -55,4 +128,37 @@ export declare class CoreApp {
55
128
  * @param api API
56
129
  */
57
130
  constructor(app: IApp, api: IApi);
131
+ /**
132
+ * Get app name
133
+ * 获取应用名称
134
+ * @param data App data
135
+ * @returns Name
136
+ */
137
+ getAppName(data: {
138
+ id: number;
139
+ name: string;
140
+ localName?: string;
141
+ }): string;
142
+ /**
143
+ * Get user identifier type label
144
+ * 获取用户标识类型标签
145
+ * @param type Type
146
+ * @returns Label
147
+ */
148
+ getIdentifierTypeLabel(type: UserIdentifierType): string;
149
+ /**
150
+ * Get identity label
151
+ * 获取身份标签
152
+ * @param identity Identity value
153
+ * @param joinChar Join character
154
+ * @returns Label(s)
155
+ */
156
+ getIdentityLabel(identity: IdentityType | null | undefined, joinChar?: string): string;
157
+ /**
158
+ * Get identities
159
+ * 获取身份列表
160
+ * @param identity Identity value combined
161
+ * @returns List
162
+ */
163
+ getIdentities(identity?: number): ListType[];
58
164
  }
@@ -7,52 +7,71 @@ const AppApi_1 = require("./AppApi");
7
7
  const PublicApi_1 = require("./PublicApi");
8
8
  const UserApi_1 = require("./UserApi");
9
9
  const appscript_1 = require("@etsoo/appscript");
10
+ const IdentityType_1 = require("./dto/IdentityType");
11
+ const AuthCodeApi_1 = require("./AuthCodeApi");
12
+ const shared_1 = require("@etsoo/shared");
10
13
  /**
11
14
  * Core application
12
15
  * 核心应用程序
13
16
  */
14
17
  class CoreApp {
18
+ app;
19
+ api;
20
+ _appApi;
15
21
  /**
16
22
  * Application API
17
23
  * 应用程序接口
18
24
  */
19
25
  get appApi() {
20
- return (this._appApi ?? (this._appApi = new AppApi_1.AppApi(this.app, this.api)));
26
+ return (this._appApi ??= new AppApi_1.AppApi(this.app, this.api));
21
27
  }
28
+ _authApi;
22
29
  /**
23
30
  * Authentication API
24
31
  * 认证接口
25
32
  */
26
33
  get authApi() {
27
- return (this._authApi ?? (this._authApi = new appscript_1.AuthApi(this.app, this.api)));
34
+ return (this._authApi ??= new appscript_1.AuthApi(this.app, this.api));
28
35
  }
36
+ _authCodeApi;
37
+ /**
38
+ * Authentication API
39
+ * 认证接口
40
+ */
41
+ get authCodeApi() {
42
+ return (this._authCodeApi ??= new AuthCodeApi_1.AuthCodeApi(this.app, this.api));
43
+ }
44
+ _memberApi;
29
45
  /**
30
46
  * Member API
31
47
  * 会员接口
32
48
  */
33
49
  get memberApi() {
34
- return (this._memberApi ?? (this._memberApi = new MemberApi_1.MemberApi(this.app, this.api)));
50
+ return (this._memberApi ??= new MemberApi_1.MemberApi(this.app, this.api));
35
51
  }
52
+ _orgApi;
36
53
  /**
37
54
  * Organization API
38
55
  * 机构接口
39
56
  */
40
57
  get orgApi() {
41
- return (this._orgApi ?? (this._orgApi = new OrgApi_1.OrgApi(this.app, this.api)));
58
+ return (this._orgApi ??= new OrgApi_1.OrgApi(this.app, this.api));
42
59
  }
60
+ _publicApi;
43
61
  /**
44
62
  * Public API
45
63
  * 公共接口
46
64
  */
47
65
  get publicApi() {
48
- return (this._publicApi ?? (this._publicApi = new PublicApi_1.PublicApi(this.app, this.api)));
66
+ return (this._publicApi ??= new PublicApi_1.PublicApi(this.app, this.api));
49
67
  }
68
+ _userApi;
50
69
  /**
51
70
  * User API
52
71
  * 用户接口
53
72
  */
54
73
  get userApi() {
55
- return (this._userApi ?? (this._userApi = new UserApi_1.UserApi(this.app, this.api)));
74
+ return (this._userApi ??= new UserApi_1.UserApi(this.app, this.api));
56
75
  }
57
76
  /**
58
77
  * Constructor
@@ -64,5 +83,52 @@ class CoreApp {
64
83
  this.app = app;
65
84
  this.api = api;
66
85
  }
86
+ /**
87
+ * Get app name
88
+ * 获取应用名称
89
+ * @param data App data
90
+ * @returns Name
91
+ */
92
+ getAppName(data) {
93
+ return data.localName ?? this.app.get(`app${data.id}`) ?? data.name;
94
+ }
95
+ /**
96
+ * Get user identifier type label
97
+ * 获取用户标识类型标签
98
+ * @param type Type
99
+ * @returns Label
100
+ */
101
+ getIdentifierTypeLabel(type) {
102
+ const key = shared_1.DataTypes.getEnumKey(appscript_1.UserIdentifierType, type);
103
+ return this.app.get(`uiType${key}`) ?? key;
104
+ }
105
+ /**
106
+ * Get identity label
107
+ * 获取身份标签
108
+ * @param identity Identity value
109
+ * @param joinChar Join character
110
+ * @returns Label(s)
111
+ */
112
+ getIdentityLabel(identity, joinChar) {
113
+ if (identity == null)
114
+ return "";
115
+ joinChar ??= ", ";
116
+ const identities = this.getIdentities(identity);
117
+ return identities.map((r) => r.label).join(joinChar);
118
+ }
119
+ /**
120
+ * Get identities
121
+ * 获取身份列表
122
+ * @param identity Identity value combined
123
+ * @returns List
124
+ */
125
+ getIdentities(identity) {
126
+ if (identity == null)
127
+ return this.app.getEnumList(IdentityType_1.IdentityType, "id");
128
+ return this.app.getEnumList(IdentityType_1.IdentityType, "id", (id, _key) => {
129
+ if ((id & identity) > 0)
130
+ return id;
131
+ });
132
+ }
67
133
  }
68
134
  exports.CoreApp = CoreApp;
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Core utilities
3
+ */
4
+ export declare namespace CoreUtils { }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,30 @@
1
+ import { IServiceApp } from "@etsoo/materialui";
2
+ import { ICoreApp } from "./CoreApp";
3
+ import { DependencyList } from "react";
4
+ /**
5
+ * Get core service application context hook
6
+ * @returns Application
7
+ */
8
+ export declare function useRequiredAppContext(): ICoreServiceApp;
9
+ /**
10
+ * Use page data
11
+ * @param app Application
12
+ * @param pageTitle Page title
13
+ * @param deps Dependencies
14
+ */
15
+ export declare function usePageData(app: ICoreServiceApp, pageTitle?: string, deps?: DependencyList): void;
16
+ /**
17
+ * Use page data empty
18
+ * @param app Application
19
+ */
20
+ export declare function usePageDataEmpty(app: ICoreServiceApp): void;
21
+ /**
22
+ * Core service application interface
23
+ * 核心服务应用程序接口
24
+ */
25
+ export interface ICoreServiceApp extends IServiceApp {
26
+ /**
27
+ * Core application
28
+ */
29
+ readonly core: ICoreApp;
30
+ }