@etsoo/appscript 1.5.63 → 1.5.65

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 (196) hide show
  1. package/.github/workflows/main.yml +6 -5
  2. package/README.md +97 -71
  3. package/__tests__/app/CoreApp.ts +141 -143
  4. package/__tests__/app/Culture.ts +23 -23
  5. package/__tests__/app/TestApp.ts +107 -105
  6. package/__tests__/business/BusinessUtils.ts +37 -37
  7. package/__tests__/result/ActionResult.ts +14 -14
  8. package/__tests__/tsconfig.json +16 -16
  9. package/babel.config.json +8 -8
  10. package/lib/cjs/address/AddressAutocomplete.d.ts +1 -1
  11. package/lib/cjs/address/AddressPlace.d.ts +3 -3
  12. package/lib/cjs/address/AddressPlaceBase.d.ts +1 -1
  13. package/lib/cjs/address/AddressRegion.d.ts +2 -2
  14. package/lib/cjs/address/AddressRegion.js +12 -12
  15. package/lib/cjs/address/AddressUtils.d.ts +1 -1
  16. package/lib/cjs/api/AuthApi.d.ts +14 -14
  17. package/lib/cjs/api/AuthApi.js +17 -17
  18. package/lib/cjs/api/BaseApi.d.ts +1 -1
  19. package/lib/cjs/api/EntityApi.d.ts +8 -8
  20. package/lib/cjs/api/EntityApi.js +4 -4
  21. package/lib/cjs/api/dto/AuditLineDto.d.ts +24 -0
  22. package/lib/cjs/api/dto/AuditLineDto.js +2 -0
  23. package/lib/cjs/api/dto/IdLabelDto.d.ts +1 -1
  24. package/lib/cjs/api/dto/IdLabelPrimaryDto.d.ts +1 -1
  25. package/lib/cjs/api/dto/PinDto.d.ts +61 -0
  26. package/lib/cjs/api/dto/PinDto.js +2 -0
  27. package/lib/cjs/api/dto/ResultPayload.d.ts +2 -2
  28. package/lib/cjs/api/rq/AuthRequest.d.ts +1 -1
  29. package/lib/cjs/api/rq/LoginRQ.d.ts +2 -2
  30. package/lib/cjs/api/rq/MergeRQ.d.ts +1 -1
  31. package/lib/cjs/api/rq/QueryRQ.d.ts +2 -2
  32. package/lib/cjs/api/rq/StatusQueryRQ.d.ts +3 -3
  33. package/lib/cjs/api/rq/UpdateModel.d.ts +2 -2
  34. package/lib/cjs/api/rq/UpdateStatusRQ.d.ts +2 -2
  35. package/lib/cjs/app/AppSettings.d.ts +3 -3
  36. package/lib/cjs/bridges/FlutterHost.d.ts +2 -2
  37. package/lib/cjs/bridges/FlutterHost.js +11 -11
  38. package/lib/cjs/business/BusinessTax.js +6 -6
  39. package/lib/cjs/business/BusinessUtils.d.ts +2 -2
  40. package/lib/cjs/business/BusinessUtils.js +5 -5
  41. package/lib/cjs/business/Currency.d.ts +1 -1
  42. package/lib/cjs/business/Currency.js +10 -10
  43. package/lib/cjs/business/ProductUnit.d.ts +1 -1
  44. package/lib/cjs/business/ShoppingCart.d.ts +9 -9
  45. package/lib/cjs/business/ShoppingCart.js +11 -11
  46. package/lib/cjs/custom/CustomField.d.ts +1 -1
  47. package/lib/cjs/custom/CustomFieldData.d.ts +2 -2
  48. package/lib/cjs/i18n/Culture.d.ts +31 -0
  49. package/lib/cjs/i18n/Culture.js +51 -0
  50. package/lib/cjs/index.d.ts +3 -4
  51. package/lib/cjs/index.js +3 -4
  52. package/lib/cjs/result/ActionResult.d.ts +1 -1
  53. package/lib/cjs/result/ActionResultError.d.ts +1 -1
  54. package/lib/cjs/result/ActionResultError.js +3 -3
  55. package/lib/cjs/result/InitCallResult.d.ts +1 -1
  56. package/lib/cjs/state/Culture.d.ts +2 -2
  57. package/lib/cjs/state/User.d.ts +1 -1
  58. package/lib/mjs/address/AddressAutocomplete.d.ts +1 -1
  59. package/lib/mjs/address/AddressPlace.d.ts +3 -3
  60. package/lib/mjs/address/AddressPlaceBase.d.ts +1 -1
  61. package/lib/mjs/address/AddressRegion.d.ts +2 -2
  62. package/lib/mjs/address/AddressRegion.js +13 -13
  63. package/lib/mjs/address/AddressUtils.d.ts +1 -1
  64. package/lib/mjs/address/AddressUtils.js +1 -1
  65. package/lib/mjs/api/AuthApi.d.ts +14 -14
  66. package/lib/mjs/api/AuthApi.js +19 -19
  67. package/lib/mjs/api/BaseApi.d.ts +1 -1
  68. package/lib/mjs/api/EntityApi.d.ts +8 -8
  69. package/lib/mjs/api/EntityApi.js +5 -5
  70. package/lib/mjs/api/dto/AuditLineDto.d.ts +24 -0
  71. package/lib/mjs/api/dto/AuditLineDto.js +1 -0
  72. package/lib/mjs/api/dto/IdLabelDto.d.ts +1 -1
  73. package/lib/mjs/api/dto/IdLabelPrimaryDto.d.ts +1 -1
  74. package/lib/mjs/api/dto/PinDto.d.ts +61 -0
  75. package/lib/mjs/api/dto/PinDto.js +1 -0
  76. package/lib/mjs/api/dto/ResultPayload.d.ts +2 -2
  77. package/lib/mjs/api/rq/AuthRequest.d.ts +1 -1
  78. package/lib/mjs/api/rq/LoginRQ.d.ts +2 -2
  79. package/lib/mjs/api/rq/MergeRQ.d.ts +1 -1
  80. package/lib/mjs/api/rq/QueryRQ.d.ts +2 -2
  81. package/lib/mjs/api/rq/StatusQueryRQ.d.ts +3 -3
  82. package/lib/mjs/api/rq/UpdateModel.d.ts +2 -2
  83. package/lib/mjs/api/rq/UpdateStatusRQ.d.ts +2 -2
  84. package/lib/mjs/app/AppSettings.d.ts +3 -3
  85. package/lib/mjs/bridges/FlutterHost.d.ts +2 -2
  86. package/lib/mjs/bridges/FlutterHost.js +13 -13
  87. package/lib/mjs/business/BusinessTax.js +6 -6
  88. package/lib/mjs/business/BusinessUtils.d.ts +2 -2
  89. package/lib/mjs/business/BusinessUtils.js +5 -5
  90. package/lib/mjs/business/Currency.d.ts +1 -1
  91. package/lib/mjs/business/Currency.js +10 -10
  92. package/lib/mjs/business/ProductUnit.d.ts +1 -1
  93. package/lib/mjs/business/ProductUnit.js +1 -1
  94. package/lib/mjs/business/ShoppingCart.d.ts +9 -9
  95. package/lib/mjs/business/ShoppingCart.js +12 -12
  96. package/lib/mjs/custom/CustomField.d.ts +1 -1
  97. package/lib/mjs/custom/CustomFieldData.d.ts +2 -2
  98. package/lib/mjs/i18n/Culture.d.ts +31 -0
  99. package/lib/mjs/i18n/Culture.js +48 -0
  100. package/lib/mjs/index.d.ts +3 -4
  101. package/lib/mjs/index.js +3 -4
  102. package/lib/mjs/result/ActionResult.d.ts +1 -1
  103. package/lib/mjs/result/ActionResult.js +1 -1
  104. package/lib/mjs/result/ActionResultError.d.ts +1 -1
  105. package/lib/mjs/result/ActionResultError.js +3 -3
  106. package/lib/mjs/result/InitCallResult.d.ts +1 -1
  107. package/lib/mjs/state/Culture.d.ts +2 -2
  108. package/lib/mjs/state/User.d.ts +1 -1
  109. package/package.json +1 -1
  110. package/src/address/AddressAutocomplete.ts +16 -16
  111. package/src/address/AddressCity.ts +12 -12
  112. package/src/address/AddressContinent.ts +35 -35
  113. package/src/address/AddressDistrict.ts +12 -12
  114. package/src/address/AddressLocation.ts +8 -8
  115. package/src/address/AddressPlace.ts +23 -23
  116. package/src/address/AddressPlaceBase.ts +31 -31
  117. package/src/address/AddressRegion.ts +286 -286
  118. package/src/address/AddressState.ts +12 -12
  119. package/src/address/AddressUtils.ts +27 -27
  120. package/src/api/AuthApi.ts +194 -194
  121. package/src/api/BaseApi.ts +13 -13
  122. package/src/api/EntityApi.ts +181 -194
  123. package/src/api/dto/AntiforgeryRequestToken.ts +15 -15
  124. package/src/api/dto/ApiRefreshTokenDto.ts +16 -16
  125. package/src/api/dto/AuditLineDto.ts +27 -0
  126. package/src/api/dto/IdLabelDto.ts +3 -3
  127. package/src/api/dto/IdLabelPrimaryDto.ts +7 -7
  128. package/src/api/dto/InitCallDto.ts +12 -12
  129. package/src/api/dto/PinDto.ts +71 -0
  130. package/src/api/dto/ResultPayload.ts +6 -6
  131. package/src/api/rq/ApiRefreshTokenRQ.ts +8 -8
  132. package/src/api/rq/AuthRequest.ts +40 -40
  133. package/src/api/rq/GetLogInUrlRQ.ts +8 -8
  134. package/src/api/rq/LoginIdRQ.ts +12 -12
  135. package/src/api/rq/LoginRQ.ts +18 -18
  136. package/src/api/rq/MergeRQ.ts +13 -13
  137. package/src/api/rq/QueryPagingData.ts +16 -16
  138. package/src/api/rq/QueryRQ.ts +22 -22
  139. package/src/api/rq/RefreshTokenRQ.ts +4 -4
  140. package/src/api/rq/ResetPasswordRQ.ts +20 -20
  141. package/src/api/rq/SignoutRQ.ts +8 -8
  142. package/src/api/rq/StatusQueryRQ.ts +11 -11
  143. package/src/api/rq/SwitchOrgRQ.ts +8 -8
  144. package/src/api/rq/TokenRQ.ts +4 -4
  145. package/src/api/rq/UpdateModel.ts +12 -12
  146. package/src/api/rq/UpdateStatusRQ.ts +10 -10
  147. package/src/app/AppSettings.ts +27 -27
  148. package/src/app/UserRole.ts +44 -44
  149. package/src/bridges/FlutterHost.ts +92 -97
  150. package/src/bridges/IBridgeHost.ts +49 -51
  151. package/src/business/ApiService.ts +25 -25
  152. package/src/business/BusinessTax.ts +63 -63
  153. package/src/business/BusinessUtils.ts +75 -75
  154. package/src/business/CultureItem.ts +43 -43
  155. package/src/business/Currency.ts +11 -11
  156. package/src/business/DataPrivacy.ts +35 -35
  157. package/src/business/EntityStatus.ts +44 -44
  158. package/src/business/ProductUnit.ts +58 -58
  159. package/src/business/RepeatOption.ts +50 -50
  160. package/src/business/ShoppingCart.ts +696 -706
  161. package/src/custom/CustomField.ts +20 -20
  162. package/src/custom/CustomFieldData.ts +43 -43
  163. package/src/def/ListItem.ts +12 -12
  164. package/src/i18n/Culture.ts +60 -0
  165. package/src/i18n/en.json +244 -244
  166. package/src/i18n/zh-Hans.json +244 -244
  167. package/src/i18n/zh-Hant.json +244 -244
  168. package/src/index.ts +3 -4
  169. package/src/result/ActionResult.ts +19 -19
  170. package/src/result/ActionResultError.ts +30 -30
  171. package/src/result/InitCallResult.ts +21 -21
  172. package/src/state/Culture.ts +3 -3
  173. package/src/state/State.ts +5 -5
  174. package/src/state/User.ts +92 -92
  175. package/tsconfig.cjs.json +17 -17
  176. package/tsconfig.json +17 -17
  177. package/lib/cjs/i18n/CultureUtils.d.ts +0 -13
  178. package/lib/cjs/i18n/CultureUtils.js +0 -32
  179. package/lib/cjs/i18n/en.d.ts +0 -6
  180. package/lib/cjs/i18n/en.js +0 -12
  181. package/lib/cjs/i18n/zhHans.d.ts +0 -6
  182. package/lib/cjs/i18n/zhHans.js +0 -12
  183. package/lib/cjs/i18n/zhHant.d.ts +0 -6
  184. package/lib/cjs/i18n/zhHant.js +0 -12
  185. package/lib/mjs/i18n/CultureUtils.d.ts +0 -13
  186. package/lib/mjs/i18n/CultureUtils.js +0 -29
  187. package/lib/mjs/i18n/en.d.ts +0 -6
  188. package/lib/mjs/i18n/en.js +0 -8
  189. package/lib/mjs/i18n/zhHans.d.ts +0 -6
  190. package/lib/mjs/i18n/zhHans.js +0 -8
  191. package/lib/mjs/i18n/zhHant.d.ts +0 -6
  192. package/lib/mjs/i18n/zhHant.js +0 -8
  193. package/src/i18n/CultureUtils.ts +0 -36
  194. package/src/i18n/en.ts +0 -10
  195. package/src/i18n/zhHans.ts +0 -10
  196. package/src/i18n/zhHant.ts +0 -10
@@ -6,7 +6,8 @@
6
6
  name: Node.js Package
7
7
 
8
8
  # Event to trigger the action
9
- on: [push]
9
+ on:
10
+ [push]
10
11
  # release:
11
12
  # types: [created]
12
13
 
@@ -23,13 +24,13 @@ jobs:
23
24
  # https://github.com/actions/checkout, This action checks-out your repository under $GITHUB_WORKSPACE
24
25
  # so your workflow can access it.
25
26
  - uses: actions/checkout@v4
26
-
27
+
27
28
  # Set up your GitHub Actions workflow with a specific version of node.js
28
29
  # Setup .npmrc file to publish to npm
29
30
  - uses: actions/setup-node@v4
30
31
  with:
31
- node-version: '20.x'
32
- registry-url: 'https://registry.npmjs.org'
32
+ node-version: "20.x"
33
+ registry-url: "https://registry.npmjs.org"
33
34
 
34
35
  # Named after Continuous Integration, installs dependencies directly from package-lock.json
35
36
  # ci vs install
@@ -45,4 +46,4 @@ jobs:
45
46
  # For scoped package, make it public for free service
46
47
  - run: npm publish --access public
47
48
  env:
48
- NODE_AUTH_TOKEN: ${{ secrets.ETSOONpmToken }}
49
+ NODE_AUTH_TOKEN: ${{ secrets.ETSOONpmToken }}
package/README.md CHANGED
@@ -1,4 +1,5 @@
1
1
  # AppScript
2
+
2
3
  **TypeScript application scripts shared by different frameworks.**
3
4
 
4
5
  ## Installing
@@ -16,120 +17,145 @@ $ yarn add @etsoo/appscript
16
17
  ```
17
18
 
18
19
  ## Client data security framework
19
- - CoreApp, constructor, reads deviceId from session storage
20
- - restore, when deviceId is empty, try to restore from persisted storage, get the passphrase (encryption / decription) or remove all data keys
21
- - initCall (everytime the application running), if passphrase is there, just return, otherwise read from serverside
22
- - device updated will cause validataion failure. Please call initCall(undefined, true);
20
+
21
+ - CoreApp, constructor, reads deviceId from session storage
22
+ - restore, when deviceId is empty, try to restore from persisted storage, get the passphrase (encryption / decription) or remove all data keys
23
+ - initCall (everytime the application running), if passphrase is there, just return, otherwise read from serverside
24
+ - device updated will cause validataion failure. Please call initCall(undefined, true);
23
25
 
24
26
  ## Structure
25
27
 
26
28
  ### address - Address (region) related
27
29
 
28
- #### AddressContinent.ts ####
29
- - AddressContinent - Continent Enum
30
+ #### AddressContinent.ts
31
+
32
+ - AddressContinent - Continent Enum
33
+
34
+ #### AddressRegion.ts
30
35
 
31
- #### AddressRegion.ts ####
32
- - IAddressRegion - Country or region interface
33
- - AddressRegion - Address or region
36
+ - IAddressRegion - Country or region interface
37
+ - AddressRegion - Address or region
34
38
 
35
- #### AddressUtils.ts ####
36
- - getRegion - Get region from regions and detected region and language
39
+ #### AddressUtils.ts
40
+
41
+ - getRegion - Get region from regions and detected region and language
37
42
 
38
43
  ### app - Application related
39
44
 
40
- #### AppSettings.ts ####
41
- - IAppSettings - App settings interface
45
+ #### AppSettings.ts
46
+
47
+ - IAppSettings - App settings interface
48
+
49
+ #### CoreApp.ts
42
50
 
43
- #### CoreApp.ts ####
44
- - IDetectIPCallback - Detect IP callback interface
45
- - ICoreApp - Core application interface
46
- - CoreApp - Core application
51
+ - IDetectIPCallback - Detect IP callback interface
52
+ - ICoreApp - Core application interface
53
+ - CoreApp - Core application
47
54
 
48
- #### ExternalSettings.ts ####
49
- - IExternalSettings - External settings items
50
- - IExternalSettingsHost - External settings host passed by external script
55
+ #### ExternalSettings.ts
51
56
 
52
- #### UserRole.ts ####
53
- - Standard user roles
57
+ - IExternalSettings - External settings items
58
+ - IExternalSettingsHost - External settings host passed by external script
59
+
60
+ #### UserRole.ts
61
+
62
+ - Standard user roles
54
63
 
55
64
  ### bridges - Works with Electron
56
65
 
57
- #### BridgeUtils.ts ####
58
- - BridgeUtils - Bridge utils
66
+ #### BridgeUtils.ts
67
+
68
+ - BridgeUtils - Bridge utils
59
69
 
60
- #### FlutterHost.ts ####
61
- - FlutterHost - Flutter JavaScript Host
70
+ #### FlutterHost.ts
62
71
 
63
- #### IBridgeHost.ts ####
64
- - IBridgeHost - Bridge host interface
72
+ - FlutterHost - Flutter JavaScript Host
73
+
74
+ #### IBridgeHost.ts
75
+
76
+ - IBridgeHost - Bridge host interface
65
77
 
66
78
  ### business - Business logics
67
79
 
68
- #### BusinessTax.ts ####
69
- - IBusinessTax - Business tax interface
70
- - BusinessTax - Business tax
80
+ #### BusinessTax.ts
81
+
82
+ - IBusinessTax - Business tax interface
83
+ - BusinessTax - Business tax
71
84
 
72
- #### BusinessUtils.ts ####
73
- - getCurrencies - Get currency collection
74
- - getEntityStatusLabel - Get entity status's label
75
- - getEntityStatus - Get entity status collection
76
- - getUnitLabel - Get product unit's label
77
- - getUnits - Get all product units
78
- - getRepeatOptions - Get all repeat options
85
+ #### BusinessUtils.ts
79
86
 
80
- #### EntityStatus.ts ####
81
- - EntityStatus - Standard entity status enum
87
+ - getCurrencies - Get currency collection
88
+ - getEntityStatusLabel - Get entity status's label
89
+ - getEntityStatus - Get entity status collection
90
+ - getUnitLabel - Get product unit's label
91
+ - getUnits - Get all product units
92
+ - getRepeatOptions - Get all repeat options
82
93
 
83
- #### ProductUnit.ts ####
84
- - ProductUnit - Product units enum
94
+ #### EntityStatus.ts
85
95
 
86
- #### RepeatOption.ts ####
87
- - RepeatOption - Repeat options
96
+ - EntityStatus - Standard entity status enum
97
+
98
+ #### ProductUnit.ts
99
+
100
+ - ProductUnit - Product units enum
101
+
102
+ #### RepeatOption.ts
103
+
104
+ - RepeatOption - Repeat options
88
105
 
89
106
  ### custom - Custom dynamic component rendering
90
107
 
91
- #### CustomFieldData.ts ####
92
- - CustomFieldSpace - Custom field space (12 columns)
93
- - CustomFieldData - Custom field data
108
+ #### CustomFieldData.ts
109
+
110
+ - CustomFieldSpace - Custom field space (12 columns)
111
+ - CustomFieldData - Custom field data
94
112
 
95
113
  ### def - Type definition
96
114
 
97
- #### ListItem.ts ####
98
- - ListItem - List item definition
115
+ #### ListItem.ts
116
+
117
+ - ListItem - List item definition
99
118
 
100
119
  ### i18n - Multiple cultures
101
120
 
102
121
  ### result - API action result
103
122
 
104
- #### ActionResult.ts ####
105
- - ActionResult - API call action result extends IActionResult
123
+ #### ActionResult.ts
124
+
125
+ - ActionResult - API call action result extends IActionResult
106
126
 
107
- #### ActionResultError.ts ####
108
- - ActionResultError - Action result to error type
127
+ #### ActionResultError.ts
109
128
 
110
- #### IActionResult.ts ####
111
- - IResultData - Result data interface
112
- - IdResultData - extends IResultData for 'id' included return data
113
- - IResultErrors - Result errors interface
114
- - IActionResult - Action result interface
115
- - ActionResultId - Action result with id data
129
+ - ActionResultError - Action result to error type
116
130
 
117
- #### InitCallResultData.ts ####
118
- - InitCallResultData - Init call result data
119
- - InitCallResult - Init call result
131
+ #### IActionResult.ts
132
+
133
+ - IResultData - Result data interface
134
+ - IdResultData - extends IResultData for 'id' included return data
135
+ - IResultErrors - Result errors interface
136
+ - IActionResult - Action result interface
137
+ - ActionResultId - Action result with id data
138
+
139
+ #### InitCallResultData.ts
140
+
141
+ - InitCallResultData - Init call result data
142
+ - InitCallResult - Init call result
120
143
 
121
144
  ### erp - SmartERP APIs
122
145
 
123
146
  ### state - State management
124
147
 
125
- #### Culture.ts ####
126
- - ICulture - Culture resources state, simple i18n solution
127
- - ICultureGet - Culture get delegate
148
+ #### Culture.ts
149
+
150
+ - ICulture - Culture resources state, simple i18n solution
151
+ - ICultureGet - Culture get delegate
152
+
153
+ #### State.ts
154
+
155
+ - IState - state interface.
156
+ - IAction - state action interface
128
157
 
129
- #### State.ts ####
130
- - IState - state interface.
131
- - IAction - state action interface
158
+ #### User.ts
132
159
 
133
- #### User.ts ####
134
- - IUserData - User basic data.
135
- - IUser - extends IState for user state
160
+ - IUserData - User basic data.
161
+ - IUser - extends IState for user state
@@ -1,188 +1,186 @@
1
- import { ApiDataError, ApiMethod } from '@etsoo/restclient';
2
- import { DataTypes, IActionResult } from '@etsoo/shared';
3
- import { EntityStatus, UserRole } from '../../src';
4
- import { TestApp } from './TestApp';
1
+ import { ApiDataError, ApiMethod } from "@etsoo/restclient";
2
+ import { DataTypes, IActionResult } from "@etsoo/shared";
3
+ import { EntityStatus, UserRole } from "../../src";
4
+ import { TestApp } from "./TestApp";
5
5
 
6
6
  // Arrange
7
7
  // Mixins example
8
8
  function EnhanceApp<TBase extends DataTypes.MConstructor<TestApp>>(
9
- Base: TBase
9
+ Base: TBase
10
10
  ) {
11
- return class extends Base {};
11
+ return class extends Base {};
12
12
  }
13
13
 
14
14
  const appClass = EnhanceApp(TestApp);
15
15
  const app = new appClass();
16
16
  app.changeCulture(app.settings.cultures[0]);
17
17
 
18
- test('Test for domain replacement', () => {
19
- expect(app.settings.endpoint).toBe('http://localhost:9000/api/');
18
+ test("Test for domain replacement", () => {
19
+ expect(app.settings.endpoint).toBe("http://localhost:9000/api/");
20
20
 
21
- expect(app.settings.endpoints?.core.endpoint).toBe(
22
- 'https://localhost:9001/api/'
23
- );
21
+ expect(app.settings.endpoints?.core.endpoint).toBe(
22
+ "https://localhost:9001/api/"
23
+ );
24
24
  });
25
25
 
26
- test('Test for properties', () => {
27
- expect(app.settings.currentRegion.label).toBe('中国大陆');
26
+ test("Test for properties", () => {
27
+ expect(app.settings.currentRegion.label).toBe("中国大陆");
28
28
  });
29
29
 
30
- test('Test for formatAction', () => {
31
- Object.assign(app.settings.currentCulture.resources, {
32
- appName: '司友®云ERP'
33
- });
34
- expect(app.formatAction('修改', '客户A')).toBe('[司友®云ERP] 修改 - 客户A');
35
- expect(app.formatAction('修改', '客户A', '企业')).toBe(
36
- '[司友®云ERP] 修改 - 客户A, 企业'
37
- );
30
+ test("Test for formatAction", () => {
31
+ Object.assign(app.settings.currentCulture.resources, {
32
+ appName: "司友®云ERP"
33
+ });
34
+ expect(app.formatAction("修改", "客户A")).toBe("[司友®云ERP] 修改 - 客户A");
35
+ expect(app.formatAction("修改", "客户A", "企业")).toBe(
36
+ "[司友®云ERP] 修改 - 客户A, 企业"
37
+ );
38
38
  });
39
39
 
40
- test('Tests for addRootUrl', () => {
41
- expect(app.addRootUrl('/home')).toBe('/cms/home');
42
- expect(app.addRootUrl('./home')).toBe('/cms/./home');
43
- expect(app.addRootUrl('home')).toBe('/cms/home');
40
+ test("Tests for addRootUrl", () => {
41
+ expect(app.addRootUrl("/home")).toBe("/cms/home");
42
+ expect(app.addRootUrl("./home")).toBe("/cms/./home");
43
+ expect(app.addRootUrl("home")).toBe("/cms/home");
44
44
  });
45
45
 
46
- test('Tests for encrypt / decrypt', async () => {
47
- // Arrange
48
- const input = 'Hello, world!';
49
- const passphrase = 'My password';
46
+ test("Tests for encrypt / decrypt", async () => {
47
+ // Arrange
48
+ const input = "Hello, world!";
49
+ const passphrase = "My password";
50
50
 
51
- // Act
52
- const encrypted = app.encrypt(input, passphrase);
53
- const plain = app.decrypt(encrypted, passphrase);
54
- expect(plain).toEqual(input);
51
+ // Act
52
+ const encrypted = app.encrypt(input, passphrase);
53
+ const plain = app.decrypt(encrypted, passphrase);
54
+ expect(plain).toEqual(input);
55
55
  });
56
56
 
57
- test('Tests for encryptEnhanced / decryptEnhanced', async () => {
58
- // Arrange
59
- const input = 'Hello, world!';
60
- const passphrase = 'My password';
57
+ test("Tests for encryptEnhanced / decryptEnhanced", async () => {
58
+ // Arrange
59
+ const input = "Hello, world!";
60
+ const passphrase = "My password";
61
61
 
62
- // Act
63
- const encrypted = app.encryptEnhanced(input, passphrase);
64
- const plain = app.decryptEnhanced(encrypted, passphrase);
65
- expect(plain).toEqual(input);
62
+ // Act
63
+ const encrypted = app.encryptEnhanced(input, passphrase);
64
+ const plain = app.decryptEnhanced(encrypted, passphrase);
65
+ expect(plain).toEqual(input);
66
66
  });
67
67
 
68
- test('Tests for initCallUpdateLocal', () => {
69
- // Act
70
- const passphrase = app.initCallUpdateLocal(
71
- {
72
- deviceId:
73
- 'ZmNjZlov+10067A1520126643352C2022735B85DC8F380088468402C98A5631A8CFBE14E134zXfxmw77lFopTTlbqOfsK2KUqPSsTAQb35Ejrm1BAvUaQH3SuZcwGYu3+PQ/Rd56',
74
- passphrase:
75
- '01397BF28A93FC031BC8B9B808F880F12C398AB792DF2ADE7A8768CADD2259EB50HJuKhqGuLQO+SmvCVzuEGUN4TdkUuPMWR0E6lliszbNiXboCziXx5SdfX3lMpoBX'
76
- },
77
- 1639282438620
78
- );
79
- expect(passphrase).not.toBeNull();
68
+ test("Tests for initCallUpdateLocal", () => {
69
+ // Act
70
+ const passphrase = app.initCallUpdateLocal(
71
+ {
72
+ deviceId:
73
+ "ZmNjZlov+10067A1520126643352C2022735B85DC8F380088468402C98A5631A8CFBE14E134zXfxmw77lFopTTlbqOfsK2KUqPSsTAQb35Ejrm1BAvUaQH3SuZcwGYu3+PQ/Rd56",
74
+ passphrase:
75
+ "01397BF28A93FC031BC8B9B808F880F12C398AB792DF2ADE7A8768CADD2259EB50HJuKhqGuLQO+SmvCVzuEGUN4TdkUuPMWR0E6lliszbNiXboCziXx5SdfX3lMpoBX"
76
+ },
77
+ 1639282438620
78
+ );
79
+ expect(passphrase).not.toBeNull();
80
80
  });
81
81
 
82
- test('Tests for formatFullName', () => {
83
- expect(app.formatFullName('亿速', null)).toBe('亿速');
84
- expect(app.formatFullName(null, null)).toBe('');
85
- expect(app.formatFullName('亿速', '思维')).toBe('亿速思维');
86
- expect(app.formatFullName('Xiao', 'Garry')).toBe('Garry Xiao');
82
+ test("Tests for formatFullName", () => {
83
+ expect(app.formatFullName("亿速", null)).toBe("亿速");
84
+ expect(app.formatFullName(null, null)).toBe("");
85
+ expect(app.formatFullName("亿速", "思维")).toBe("亿速思维");
86
+ expect(app.formatFullName("Xiao", "Garry")).toBe("Garry Xiao");
87
87
  });
88
88
 
89
- test('Tests for getRoles', () => {
90
- const roles = app.getRoles(
91
- UserRole.User | UserRole.Manager | UserRole.Admin
92
- );
93
- expect(roles.length).toBe(3);
94
- expect(roles.map((r) => r.id)).toEqual([8, 128, 8192]);
89
+ test("Tests for getRoles", () => {
90
+ const roles = app.getRoles(UserRole.User | UserRole.Manager | UserRole.Admin);
91
+ expect(roles.length).toBe(3);
92
+ expect(roles.map((r) => r.id)).toEqual([8, 128, 8192]);
95
93
  });
96
94
 
97
- test('Tests for getStatusList', () => {
98
- const statuses = app.getStatusList([
99
- EntityStatus.Normal,
100
- EntityStatus.Approved,
101
- EntityStatus.Doing,
102
- EntityStatus.Completed,
103
- EntityStatus.Deleted
104
- ]);
105
- expect(statuses.length).toBe(5);
106
- expect(statuses.map((s) => s.id)).toStrictEqual([0, 100, 110, 250, 255]);
107
-
108
- expect(app.getStatusList().length).toBe(9);
95
+ test("Tests for getStatusList", () => {
96
+ const statuses = app.getStatusList([
97
+ EntityStatus.Normal,
98
+ EntityStatus.Approved,
99
+ EntityStatus.Doing,
100
+ EntityStatus.Completed,
101
+ EntityStatus.Deleted
102
+ ]);
103
+ expect(statuses.length).toBe(5);
104
+ expect(statuses.map((s) => s.id)).toStrictEqual([0, 100, 110, 250, 255]);
105
+
106
+ expect(app.getStatusList().length).toBe(9);
109
107
  });
110
108
 
111
- test('Tests for formatResult', () => {
112
- const result: IActionResult = {
113
- ok: false,
114
- type: 'https://tools.ietf.org/html/rfc9110#section-15.5.1',
115
- title: 'One or more validation errors occurred.',
116
- status: 400,
117
- errors: {
118
- $: [
119
- 'JSON deserialization for type \u0027com.etsoo.CMS.RQ.User.UserCreateRQ\u0027 was missing required properties, including the following: password'
120
- ],
121
- rq: ['The rq field is required.']
122
- },
123
- traceId: '00-ed96a4f0c83f066594ecc69b77da9803-df770e3cd714fedd-00'
124
- };
125
-
126
- const formatted = app.formatResult(result);
127
- expect(formatted).toBe(
128
- 'One or more validation errors occurred. (400, https://tools.ietf.org/html/rfc9110#section-15.5.1)'
129
- );
109
+ test("Tests for formatResult", () => {
110
+ const result: IActionResult = {
111
+ ok: false,
112
+ type: "https://tools.ietf.org/html/rfc9110#section-15.5.1",
113
+ title: "One or more validation errors occurred.",
114
+ status: 400,
115
+ errors: {
116
+ $: [
117
+ "JSON deserialization for type \u0027com.etsoo.CMS.RQ.User.UserCreateRQ\u0027 was missing required properties, including the following: password"
118
+ ],
119
+ rq: ["The rq field is required."]
120
+ },
121
+ traceId: "00-ed96a4f0c83f066594ecc69b77da9803-df770e3cd714fedd-00"
122
+ };
123
+
124
+ const formatted = app.formatResult(result);
125
+ expect(formatted).toBe(
126
+ "One or more validation errors occurred. (400, https://tools.ietf.org/html/rfc9110#section-15.5.1)"
127
+ );
130
128
  });
131
129
 
132
- test('Tests for formatResult with custom label', () => {
133
- const result: IActionResult = {
134
- ok: false,
135
- type: 'ItemRequired',
136
- title: '{0} is required.',
137
- field: 'url'
138
- };
130
+ test("Tests for formatResult with custom label", () => {
131
+ const result: IActionResult = {
132
+ ok: false,
133
+ type: "ItemRequired",
134
+ title: "{0} is required.",
135
+ field: "url"
136
+ };
139
137
 
140
- const formatted = app.formatResult(result, () => 'Url');
141
- expect(formatted).toBe('Url is required. (ItemRequired, url)');
138
+ const formatted = app.formatResult(result, () => "Url");
139
+ expect(formatted).toBe("Url is required. (ItemRequired, url)");
142
140
  });
143
141
 
144
- test('Tests for formatResult with custom label', () => {
145
- const result: IActionResult = {
146
- ok: false,
147
- type: 'ItemExists',
148
- field: 'url'
149
- };
142
+ test("Tests for formatResult with custom label", () => {
143
+ const result: IActionResult = {
144
+ ok: false,
145
+ type: "ItemExists",
146
+ field: "url"
147
+ };
150
148
 
151
- const fieldLabel = '文章地址';
152
- const formatted = app.formatResult(result, () => fieldLabel);
153
- expect(formatted).toBe(`'${fieldLabel}'已经存在 (ItemExists, url)`);
149
+ const fieldLabel = "文章地址";
150
+ const formatted = app.formatResult(result, () => fieldLabel);
151
+ expect(formatted).toBe(`'${fieldLabel}'已经存在 (ItemExists, url)`);
154
152
  });
155
153
 
156
- test('Tests for formatError', () => {
157
- const error: ApiDataError = {
158
- name: 'ApiDataError',
159
- message: 'Api data error',
160
- response: {
161
- type: 'https://tools.ietf.org/html/rfc9110#section-15.5.1',
162
- title: 'One or more validation errors occurred.',
163
- status: 400,
164
- errors: {
165
- $: [
166
- 'JSON deserialization for type \u0027com.etsoo.CMS.RQ.User.UserCreateRQ\u0027 was missing required properties, including the following: password'
167
- ],
168
- rq: ['The rq field is required.']
169
- },
170
- traceId: '00-ed96a4f0c83f066594ecc69b77da9803-df770e3cd714fedd-00'
171
- },
172
- data: {
173
- data: undefined,
174
- headers: [],
175
- method: ApiMethod.POST,
176
- params: {},
177
- url: ''
178
- }
179
- };
180
-
181
- expect(app.formatError(error)).toBe('Api data error (ApiDataError)');
154
+ test("Tests for formatError", () => {
155
+ const error: ApiDataError = {
156
+ name: "ApiDataError",
157
+ message: "Api data error",
158
+ response: {
159
+ type: "https://tools.ietf.org/html/rfc9110#section-15.5.1",
160
+ title: "One or more validation errors occurred.",
161
+ status: 400,
162
+ errors: {
163
+ $: [
164
+ "JSON deserialization for type \u0027com.etsoo.CMS.RQ.User.UserCreateRQ\u0027 was missing required properties, including the following: password"
165
+ ],
166
+ rq: ["The rq field is required."]
167
+ },
168
+ traceId: "00-ed96a4f0c83f066594ecc69b77da9803-df770e3cd714fedd-00"
169
+ },
170
+ data: {
171
+ data: undefined,
172
+ headers: [],
173
+ method: ApiMethod.POST,
174
+ params: {},
175
+ url: ""
176
+ }
177
+ };
178
+
179
+ expect(app.formatError(error)).toBe("Api data error (ApiDataError)");
182
180
  });
183
181
 
184
- test('Tests for isValidPassword', () => {
185
- expect(app.isValidPassword('12345678')).toBeFalsy();
186
- expect(app.isValidPassword('abcd3')).toBeFalsy();
187
- expect(app.isValidPassword('1234abcd')).toBeTruthy();
182
+ test("Tests for isValidPassword", () => {
183
+ expect(app.isValidPassword("12345678")).toBeFalsy();
184
+ expect(app.isValidPassword("abcd3")).toBeFalsy();
185
+ expect(app.isValidPassword("1234abcd")).toBeTruthy();
188
186
  });
@@ -1,33 +1,33 @@
1
- import { en, zhHans } from '../../src';
1
+ import { Culture } from "../../src";
2
2
 
3
- test('Tests for en', async () => {
4
- const e = en(
5
- { nameB: 'Name for Business' },
6
- new Promise((resolve) => resolve({ no: 'No override' }))
7
- );
3
+ test("Tests for en", async () => {
4
+ const e = Culture.en(
5
+ { nameB: "Name for Business" },
6
+ new Promise((resolve) => resolve({ no: "No override" }))
7
+ );
8
8
 
9
- expect(e.name).toBe('en');
9
+ expect(e.name).toBe("en");
10
10
 
11
- const resources =
12
- typeof e.resources === 'object' ? e.resources : await e.resources();
11
+ const resources =
12
+ typeof e.resources === "object" ? e.resources : await e.resources();
13
13
 
14
- expect(resources.name).toBe('Name');
15
- expect(resources.nameB).toBe('Name for Business');
16
- expect(resources.no).toBe('No override');
14
+ expect(resources.name).toBe("Name");
15
+ expect(resources.nameB).toBe("Name for Business");
16
+ expect(resources.no).toBe("No override");
17
17
  });
18
18
 
19
- test('Tests for zhHans', async () => {
20
- const zh = zhHans(
21
- { nameB: '名称覆盖' },
22
- new Promise((resolve) => resolve({ no: 'No override' }))
23
- );
19
+ test("Tests for zhHans", async () => {
20
+ const zh = Culture.zhHans(
21
+ { nameB: "名称覆盖" },
22
+ new Promise((resolve) => resolve({ no: "No override" }))
23
+ );
24
24
 
25
- expect(zh.name).toBe('zh-Hans');
25
+ expect(zh.name).toBe("zh-Hans");
26
26
 
27
- const resources =
28
- typeof zh.resources === 'object' ? zh.resources : await zh.resources();
27
+ const resources =
28
+ typeof zh.resources === "object" ? zh.resources : await zh.resources();
29
29
 
30
- expect(resources.name).toBe('姓名');
31
- expect(resources.nameB).toBe('名称覆盖');
32
- expect(resources.no).toBe('No override');
30
+ expect(resources.name).toBe("姓名");
31
+ expect(resources.nameB).toBe("名称覆盖");
32
+ expect(resources.no).toBe("No override");
33
33
  });