@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.
- package/.github/workflows/main.yml +6 -5
- package/README.md +97 -71
- package/__tests__/app/CoreApp.ts +141 -143
- package/__tests__/app/Culture.ts +23 -23
- package/__tests__/app/TestApp.ts +107 -105
- package/__tests__/business/BusinessUtils.ts +37 -37
- package/__tests__/result/ActionResult.ts +14 -14
- package/__tests__/tsconfig.json +16 -16
- package/babel.config.json +8 -8
- package/lib/cjs/address/AddressAutocomplete.d.ts +1 -1
- package/lib/cjs/address/AddressPlace.d.ts +3 -3
- package/lib/cjs/address/AddressPlaceBase.d.ts +1 -1
- package/lib/cjs/address/AddressRegion.d.ts +2 -2
- package/lib/cjs/address/AddressRegion.js +12 -12
- package/lib/cjs/address/AddressUtils.d.ts +1 -1
- package/lib/cjs/api/AuthApi.d.ts +14 -14
- package/lib/cjs/api/AuthApi.js +17 -17
- package/lib/cjs/api/BaseApi.d.ts +1 -1
- package/lib/cjs/api/EntityApi.d.ts +8 -8
- package/lib/cjs/api/EntityApi.js +4 -4
- package/lib/cjs/api/dto/AuditLineDto.d.ts +24 -0
- package/lib/cjs/api/dto/AuditLineDto.js +2 -0
- package/lib/cjs/api/dto/IdLabelDto.d.ts +1 -1
- package/lib/cjs/api/dto/IdLabelPrimaryDto.d.ts +1 -1
- package/lib/cjs/api/dto/PinDto.d.ts +61 -0
- package/lib/cjs/api/dto/PinDto.js +2 -0
- package/lib/cjs/api/dto/ResultPayload.d.ts +2 -2
- package/lib/cjs/api/rq/AuthRequest.d.ts +1 -1
- package/lib/cjs/api/rq/LoginRQ.d.ts +2 -2
- package/lib/cjs/api/rq/MergeRQ.d.ts +1 -1
- package/lib/cjs/api/rq/QueryRQ.d.ts +2 -2
- package/lib/cjs/api/rq/StatusQueryRQ.d.ts +3 -3
- package/lib/cjs/api/rq/UpdateModel.d.ts +2 -2
- package/lib/cjs/api/rq/UpdateStatusRQ.d.ts +2 -2
- package/lib/cjs/app/AppSettings.d.ts +3 -3
- package/lib/cjs/bridges/FlutterHost.d.ts +2 -2
- package/lib/cjs/bridges/FlutterHost.js +11 -11
- package/lib/cjs/business/BusinessTax.js +6 -6
- package/lib/cjs/business/BusinessUtils.d.ts +2 -2
- package/lib/cjs/business/BusinessUtils.js +5 -5
- package/lib/cjs/business/Currency.d.ts +1 -1
- package/lib/cjs/business/Currency.js +10 -10
- package/lib/cjs/business/ProductUnit.d.ts +1 -1
- package/lib/cjs/business/ShoppingCart.d.ts +9 -9
- package/lib/cjs/business/ShoppingCart.js +11 -11
- package/lib/cjs/custom/CustomField.d.ts +1 -1
- package/lib/cjs/custom/CustomFieldData.d.ts +2 -2
- package/lib/cjs/i18n/Culture.d.ts +31 -0
- package/lib/cjs/i18n/Culture.js +51 -0
- package/lib/cjs/index.d.ts +3 -4
- package/lib/cjs/index.js +3 -4
- package/lib/cjs/result/ActionResult.d.ts +1 -1
- package/lib/cjs/result/ActionResultError.d.ts +1 -1
- package/lib/cjs/result/ActionResultError.js +3 -3
- package/lib/cjs/result/InitCallResult.d.ts +1 -1
- package/lib/cjs/state/Culture.d.ts +2 -2
- package/lib/cjs/state/User.d.ts +1 -1
- package/lib/mjs/address/AddressAutocomplete.d.ts +1 -1
- package/lib/mjs/address/AddressPlace.d.ts +3 -3
- package/lib/mjs/address/AddressPlaceBase.d.ts +1 -1
- package/lib/mjs/address/AddressRegion.d.ts +2 -2
- package/lib/mjs/address/AddressRegion.js +13 -13
- package/lib/mjs/address/AddressUtils.d.ts +1 -1
- package/lib/mjs/address/AddressUtils.js +1 -1
- package/lib/mjs/api/AuthApi.d.ts +14 -14
- package/lib/mjs/api/AuthApi.js +19 -19
- package/lib/mjs/api/BaseApi.d.ts +1 -1
- package/lib/mjs/api/EntityApi.d.ts +8 -8
- package/lib/mjs/api/EntityApi.js +5 -5
- package/lib/mjs/api/dto/AuditLineDto.d.ts +24 -0
- package/lib/mjs/api/dto/AuditLineDto.js +1 -0
- package/lib/mjs/api/dto/IdLabelDto.d.ts +1 -1
- package/lib/mjs/api/dto/IdLabelPrimaryDto.d.ts +1 -1
- package/lib/mjs/api/dto/PinDto.d.ts +61 -0
- package/lib/mjs/api/dto/PinDto.js +1 -0
- package/lib/mjs/api/dto/ResultPayload.d.ts +2 -2
- package/lib/mjs/api/rq/AuthRequest.d.ts +1 -1
- package/lib/mjs/api/rq/LoginRQ.d.ts +2 -2
- package/lib/mjs/api/rq/MergeRQ.d.ts +1 -1
- package/lib/mjs/api/rq/QueryRQ.d.ts +2 -2
- package/lib/mjs/api/rq/StatusQueryRQ.d.ts +3 -3
- package/lib/mjs/api/rq/UpdateModel.d.ts +2 -2
- package/lib/mjs/api/rq/UpdateStatusRQ.d.ts +2 -2
- package/lib/mjs/app/AppSettings.d.ts +3 -3
- package/lib/mjs/bridges/FlutterHost.d.ts +2 -2
- package/lib/mjs/bridges/FlutterHost.js +13 -13
- package/lib/mjs/business/BusinessTax.js +6 -6
- package/lib/mjs/business/BusinessUtils.d.ts +2 -2
- package/lib/mjs/business/BusinessUtils.js +5 -5
- package/lib/mjs/business/Currency.d.ts +1 -1
- package/lib/mjs/business/Currency.js +10 -10
- package/lib/mjs/business/ProductUnit.d.ts +1 -1
- package/lib/mjs/business/ProductUnit.js +1 -1
- package/lib/mjs/business/ShoppingCart.d.ts +9 -9
- package/lib/mjs/business/ShoppingCart.js +12 -12
- package/lib/mjs/custom/CustomField.d.ts +1 -1
- package/lib/mjs/custom/CustomFieldData.d.ts +2 -2
- package/lib/mjs/i18n/Culture.d.ts +31 -0
- package/lib/mjs/i18n/Culture.js +48 -0
- package/lib/mjs/index.d.ts +3 -4
- package/lib/mjs/index.js +3 -4
- package/lib/mjs/result/ActionResult.d.ts +1 -1
- package/lib/mjs/result/ActionResult.js +1 -1
- package/lib/mjs/result/ActionResultError.d.ts +1 -1
- package/lib/mjs/result/ActionResultError.js +3 -3
- package/lib/mjs/result/InitCallResult.d.ts +1 -1
- package/lib/mjs/state/Culture.d.ts +2 -2
- package/lib/mjs/state/User.d.ts +1 -1
- package/package.json +1 -1
- package/src/address/AddressAutocomplete.ts +16 -16
- package/src/address/AddressCity.ts +12 -12
- package/src/address/AddressContinent.ts +35 -35
- package/src/address/AddressDistrict.ts +12 -12
- package/src/address/AddressLocation.ts +8 -8
- package/src/address/AddressPlace.ts +23 -23
- package/src/address/AddressPlaceBase.ts +31 -31
- package/src/address/AddressRegion.ts +286 -286
- package/src/address/AddressState.ts +12 -12
- package/src/address/AddressUtils.ts +27 -27
- package/src/api/AuthApi.ts +194 -194
- package/src/api/BaseApi.ts +13 -13
- package/src/api/EntityApi.ts +181 -194
- package/src/api/dto/AntiforgeryRequestToken.ts +15 -15
- package/src/api/dto/ApiRefreshTokenDto.ts +16 -16
- package/src/api/dto/AuditLineDto.ts +27 -0
- package/src/api/dto/IdLabelDto.ts +3 -3
- package/src/api/dto/IdLabelPrimaryDto.ts +7 -7
- package/src/api/dto/InitCallDto.ts +12 -12
- package/src/api/dto/PinDto.ts +71 -0
- package/src/api/dto/ResultPayload.ts +6 -6
- package/src/api/rq/ApiRefreshTokenRQ.ts +8 -8
- package/src/api/rq/AuthRequest.ts +40 -40
- package/src/api/rq/GetLogInUrlRQ.ts +8 -8
- package/src/api/rq/LoginIdRQ.ts +12 -12
- package/src/api/rq/LoginRQ.ts +18 -18
- package/src/api/rq/MergeRQ.ts +13 -13
- package/src/api/rq/QueryPagingData.ts +16 -16
- package/src/api/rq/QueryRQ.ts +22 -22
- package/src/api/rq/RefreshTokenRQ.ts +4 -4
- package/src/api/rq/ResetPasswordRQ.ts +20 -20
- package/src/api/rq/SignoutRQ.ts +8 -8
- package/src/api/rq/StatusQueryRQ.ts +11 -11
- package/src/api/rq/SwitchOrgRQ.ts +8 -8
- package/src/api/rq/TokenRQ.ts +4 -4
- package/src/api/rq/UpdateModel.ts +12 -12
- package/src/api/rq/UpdateStatusRQ.ts +10 -10
- package/src/app/AppSettings.ts +27 -27
- package/src/app/UserRole.ts +44 -44
- package/src/bridges/FlutterHost.ts +92 -97
- package/src/bridges/IBridgeHost.ts +49 -51
- package/src/business/ApiService.ts +25 -25
- package/src/business/BusinessTax.ts +63 -63
- package/src/business/BusinessUtils.ts +75 -75
- package/src/business/CultureItem.ts +43 -43
- package/src/business/Currency.ts +11 -11
- package/src/business/DataPrivacy.ts +35 -35
- package/src/business/EntityStatus.ts +44 -44
- package/src/business/ProductUnit.ts +58 -58
- package/src/business/RepeatOption.ts +50 -50
- package/src/business/ShoppingCart.ts +696 -706
- package/src/custom/CustomField.ts +20 -20
- package/src/custom/CustomFieldData.ts +43 -43
- package/src/def/ListItem.ts +12 -12
- package/src/i18n/Culture.ts +60 -0
- package/src/i18n/en.json +244 -244
- package/src/i18n/zh-Hans.json +244 -244
- package/src/i18n/zh-Hant.json +244 -244
- package/src/index.ts +3 -4
- package/src/result/ActionResult.ts +19 -19
- package/src/result/ActionResultError.ts +30 -30
- package/src/result/InitCallResult.ts +21 -21
- package/src/state/Culture.ts +3 -3
- package/src/state/State.ts +5 -5
- package/src/state/User.ts +92 -92
- package/tsconfig.cjs.json +17 -17
- package/tsconfig.json +17 -17
- package/lib/cjs/i18n/CultureUtils.d.ts +0 -13
- package/lib/cjs/i18n/CultureUtils.js +0 -32
- package/lib/cjs/i18n/en.d.ts +0 -6
- package/lib/cjs/i18n/en.js +0 -12
- package/lib/cjs/i18n/zhHans.d.ts +0 -6
- package/lib/cjs/i18n/zhHans.js +0 -12
- package/lib/cjs/i18n/zhHant.d.ts +0 -6
- package/lib/cjs/i18n/zhHant.js +0 -12
- package/lib/mjs/i18n/CultureUtils.d.ts +0 -13
- package/lib/mjs/i18n/CultureUtils.js +0 -29
- package/lib/mjs/i18n/en.d.ts +0 -6
- package/lib/mjs/i18n/en.js +0 -8
- package/lib/mjs/i18n/zhHans.d.ts +0 -6
- package/lib/mjs/i18n/zhHans.js +0 -8
- package/lib/mjs/i18n/zhHant.d.ts +0 -6
- package/lib/mjs/i18n/zhHant.js +0 -8
- package/src/i18n/CultureUtils.ts +0 -36
- package/src/i18n/en.ts +0 -10
- package/src/i18n/zhHans.ts +0 -10
- 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:
|
|
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:
|
|
32
|
-
registry-url:
|
|
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
|
-
|
|
20
|
-
-
|
|
21
|
-
-
|
|
22
|
-
-
|
|
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
|
-
|
|
30
|
+
#### AddressContinent.ts
|
|
31
|
+
|
|
32
|
+
- AddressContinent - Continent Enum
|
|
33
|
+
|
|
34
|
+
#### AddressRegion.ts
|
|
30
35
|
|
|
31
|
-
|
|
32
|
-
-
|
|
33
|
-
- AddressRegion - Address or region
|
|
36
|
+
- IAddressRegion - Country or region interface
|
|
37
|
+
- AddressRegion - Address or region
|
|
34
38
|
|
|
35
|
-
#### AddressUtils.ts
|
|
36
|
-
|
|
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
|
-
|
|
45
|
+
#### AppSettings.ts
|
|
46
|
+
|
|
47
|
+
- IAppSettings - App settings interface
|
|
48
|
+
|
|
49
|
+
#### CoreApp.ts
|
|
42
50
|
|
|
43
|
-
|
|
44
|
-
-
|
|
45
|
-
-
|
|
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
|
-
|
|
53
|
-
-
|
|
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
|
-
|
|
66
|
+
#### BridgeUtils.ts
|
|
67
|
+
|
|
68
|
+
- BridgeUtils - Bridge utils
|
|
59
69
|
|
|
60
|
-
#### FlutterHost.ts
|
|
61
|
-
- FlutterHost - Flutter JavaScript Host
|
|
70
|
+
#### FlutterHost.ts
|
|
62
71
|
|
|
63
|
-
|
|
64
|
-
|
|
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
|
-
|
|
70
|
-
-
|
|
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
|
-
|
|
81
|
-
-
|
|
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
|
-
####
|
|
84
|
-
- ProductUnit - Product units enum
|
|
94
|
+
#### EntityStatus.ts
|
|
85
95
|
|
|
86
|
-
|
|
87
|
-
|
|
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
|
-
|
|
93
|
-
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
####
|
|
118
|
-
|
|
119
|
-
-
|
|
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
|
-
|
|
127
|
-
-
|
|
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
|
-
####
|
|
130
|
-
- IState - state interface.
|
|
131
|
-
- IAction - state action interface
|
|
158
|
+
#### User.ts
|
|
132
159
|
|
|
133
|
-
|
|
134
|
-
-
|
|
135
|
-
- IUser - extends IState for user state
|
|
160
|
+
- IUserData - User basic data.
|
|
161
|
+
- IUser - extends IState for user state
|
package/__tests__/app/CoreApp.ts
CHANGED
|
@@ -1,188 +1,186 @@
|
|
|
1
|
-
import { ApiDataError, ApiMethod } from
|
|
2
|
-
import { DataTypes, IActionResult } from
|
|
3
|
-
import { EntityStatus, UserRole } from
|
|
4
|
-
import { TestApp } from
|
|
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
|
-
|
|
9
|
+
Base: TBase
|
|
10
10
|
) {
|
|
11
|
-
|
|
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(
|
|
19
|
-
|
|
18
|
+
test("Test for domain replacement", () => {
|
|
19
|
+
expect(app.settings.endpoint).toBe("http://localhost:9000/api/");
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
expect(app.settings.endpoints?.core.endpoint).toBe(
|
|
22
|
+
"https://localhost:9001/api/"
|
|
23
|
+
);
|
|
24
24
|
});
|
|
25
25
|
|
|
26
|
-
test(
|
|
27
|
-
|
|
26
|
+
test("Test for properties", () => {
|
|
27
|
+
expect(app.settings.currentRegion.label).toBe("中国大陆");
|
|
28
28
|
});
|
|
29
29
|
|
|
30
|
-
test(
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
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(
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
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(
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
46
|
+
test("Tests for encrypt / decrypt", async () => {
|
|
47
|
+
// Arrange
|
|
48
|
+
const input = "Hello, world!";
|
|
49
|
+
const passphrase = "My password";
|
|
50
50
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
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(
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
57
|
+
test("Tests for encryptEnhanced / decryptEnhanced", async () => {
|
|
58
|
+
// Arrange
|
|
59
|
+
const input = "Hello, world!";
|
|
60
|
+
const passphrase = "My password";
|
|
61
61
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
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(
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
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(
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
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(
|
|
90
|
-
|
|
91
|
-
|
|
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(
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
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(
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
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(
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
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
|
-
|
|
141
|
-
|
|
138
|
+
const formatted = app.formatResult(result, () => "Url");
|
|
139
|
+
expect(formatted).toBe("Url is required. (ItemRequired, url)");
|
|
142
140
|
});
|
|
143
141
|
|
|
144
|
-
test(
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
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
|
-
|
|
152
|
-
|
|
153
|
-
|
|
149
|
+
const fieldLabel = "文章地址";
|
|
150
|
+
const formatted = app.formatResult(result, () => fieldLabel);
|
|
151
|
+
expect(formatted).toBe(`'${fieldLabel}'已经存在 (ItemExists, url)`);
|
|
154
152
|
});
|
|
155
153
|
|
|
156
|
-
test(
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
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(
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
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
|
});
|
package/__tests__/app/Culture.ts
CHANGED
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Culture } from "../../src";
|
|
2
2
|
|
|
3
|
-
test(
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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
|
-
|
|
9
|
+
expect(e.name).toBe("en");
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
const resources =
|
|
12
|
+
typeof e.resources === "object" ? e.resources : await e.resources();
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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(
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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
|
-
|
|
25
|
+
expect(zh.name).toBe("zh-Hans");
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
const resources =
|
|
28
|
+
typeof zh.resources === "object" ? zh.resources : await zh.resources();
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
expect(resources.name).toBe("姓名");
|
|
31
|
+
expect(resources.nameB).toBe("名称覆盖");
|
|
32
|
+
expect(resources.no).toBe("No override");
|
|
33
33
|
});
|