@etsoo/appscript 1.5.64 → 1.5.66

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 (182) hide show
  1. package/.github/workflows/main.yml +6 -5
  2. package/__tests__/app/CoreApp.ts +141 -143
  3. package/__tests__/app/Culture.ts +23 -23
  4. package/__tests__/app/TestApp.ts +107 -105
  5. package/__tests__/business/BusinessUtils.ts +37 -37
  6. package/__tests__/result/ActionResult.ts +14 -14
  7. package/__tests__/tsconfig.json +16 -16
  8. package/lib/cjs/address/AddressAutocomplete.d.ts +1 -1
  9. package/lib/cjs/address/AddressPlace.d.ts +3 -3
  10. package/lib/cjs/address/AddressPlaceBase.d.ts +1 -1
  11. package/lib/cjs/address/AddressRegion.d.ts +2 -2
  12. package/lib/cjs/address/AddressRegion.js +12 -12
  13. package/lib/cjs/address/AddressUtils.d.ts +1 -1
  14. package/lib/cjs/api/AuthApi.d.ts +14 -14
  15. package/lib/cjs/api/AuthApi.js +17 -17
  16. package/lib/cjs/api/BaseApi.d.ts +1 -1
  17. package/lib/cjs/api/EntityApi.d.ts +8 -8
  18. package/lib/cjs/api/EntityApi.js +4 -4
  19. package/lib/cjs/api/dto/IdLabelDto.d.ts +1 -1
  20. package/lib/cjs/api/dto/IdLabelPrimaryDto.d.ts +1 -1
  21. package/lib/cjs/api/dto/ResultPayload.d.ts +2 -2
  22. package/lib/cjs/api/rq/AuthRequest.d.ts +1 -1
  23. package/lib/cjs/api/rq/LoginRQ.d.ts +2 -2
  24. package/lib/cjs/api/rq/MergeRQ.d.ts +1 -1
  25. package/lib/cjs/api/rq/QueryRQ.d.ts +2 -2
  26. package/lib/cjs/api/rq/StatusQueryRQ.d.ts +3 -3
  27. package/lib/cjs/api/rq/UpdateModel.d.ts +2 -2
  28. package/lib/cjs/api/rq/UpdateStatusRQ.d.ts +2 -2
  29. package/lib/cjs/app/AppSettings.d.ts +3 -3
  30. package/lib/cjs/bridges/FlutterHost.d.ts +2 -2
  31. package/lib/cjs/bridges/FlutterHost.js +11 -11
  32. package/lib/cjs/business/BusinessTax.js +6 -6
  33. package/lib/cjs/business/BusinessUtils.d.ts +2 -2
  34. package/lib/cjs/business/BusinessUtils.js +5 -5
  35. package/lib/cjs/business/Currency.d.ts +1 -1
  36. package/lib/cjs/business/Currency.js +10 -10
  37. package/lib/cjs/business/ProductUnit.d.ts +1 -1
  38. package/lib/cjs/business/ShoppingCart.d.ts +9 -9
  39. package/lib/cjs/business/ShoppingCart.js +11 -11
  40. package/lib/cjs/custom/CustomField.d.ts +1 -1
  41. package/lib/cjs/custom/CustomFieldData.d.ts +2 -2
  42. package/lib/cjs/i18n/Culture.d.ts +31 -0
  43. package/lib/cjs/i18n/Culture.js +51 -0
  44. package/lib/cjs/index.d.ts +1 -4
  45. package/lib/cjs/index.js +1 -4
  46. package/lib/cjs/result/ActionResult.d.ts +1 -1
  47. package/lib/cjs/result/ActionResultError.d.ts +1 -1
  48. package/lib/cjs/result/ActionResultError.js +3 -3
  49. package/lib/cjs/result/InitCallResult.d.ts +1 -1
  50. package/lib/cjs/state/Culture.d.ts +2 -2
  51. package/lib/cjs/state/User.d.ts +1 -1
  52. package/lib/mjs/address/AddressAutocomplete.d.ts +1 -1
  53. package/lib/mjs/address/AddressPlace.d.ts +3 -3
  54. package/lib/mjs/address/AddressPlaceBase.d.ts +1 -1
  55. package/lib/mjs/address/AddressRegion.d.ts +2 -2
  56. package/lib/mjs/address/AddressRegion.js +13 -13
  57. package/lib/mjs/address/AddressUtils.d.ts +1 -1
  58. package/lib/mjs/address/AddressUtils.js +1 -1
  59. package/lib/mjs/api/AuthApi.d.ts +14 -14
  60. package/lib/mjs/api/AuthApi.js +19 -19
  61. package/lib/mjs/api/BaseApi.d.ts +1 -1
  62. package/lib/mjs/api/EntityApi.d.ts +8 -8
  63. package/lib/mjs/api/EntityApi.js +5 -5
  64. package/lib/mjs/api/dto/IdLabelDto.d.ts +1 -1
  65. package/lib/mjs/api/dto/IdLabelPrimaryDto.d.ts +1 -1
  66. package/lib/mjs/api/dto/ResultPayload.d.ts +2 -2
  67. package/lib/mjs/api/rq/AuthRequest.d.ts +1 -1
  68. package/lib/mjs/api/rq/LoginRQ.d.ts +2 -2
  69. package/lib/mjs/api/rq/MergeRQ.d.ts +1 -1
  70. package/lib/mjs/api/rq/QueryRQ.d.ts +2 -2
  71. package/lib/mjs/api/rq/StatusQueryRQ.d.ts +3 -3
  72. package/lib/mjs/api/rq/UpdateModel.d.ts +2 -2
  73. package/lib/mjs/api/rq/UpdateStatusRQ.d.ts +2 -2
  74. package/lib/mjs/app/AppSettings.d.ts +3 -3
  75. package/lib/mjs/bridges/FlutterHost.d.ts +2 -2
  76. package/lib/mjs/bridges/FlutterHost.js +13 -13
  77. package/lib/mjs/business/BusinessTax.js +6 -6
  78. package/lib/mjs/business/BusinessUtils.d.ts +2 -2
  79. package/lib/mjs/business/BusinessUtils.js +5 -5
  80. package/lib/mjs/business/Currency.d.ts +1 -1
  81. package/lib/mjs/business/Currency.js +10 -10
  82. package/lib/mjs/business/ProductUnit.d.ts +1 -1
  83. package/lib/mjs/business/ProductUnit.js +1 -1
  84. package/lib/mjs/business/ShoppingCart.d.ts +9 -9
  85. package/lib/mjs/business/ShoppingCart.js +12 -12
  86. package/lib/mjs/custom/CustomField.d.ts +1 -1
  87. package/lib/mjs/custom/CustomFieldData.d.ts +2 -2
  88. package/lib/mjs/i18n/Culture.d.ts +31 -0
  89. package/lib/mjs/i18n/Culture.js +48 -0
  90. package/lib/mjs/index.d.ts +1 -4
  91. package/lib/mjs/index.js +1 -4
  92. package/lib/mjs/result/ActionResult.d.ts +1 -1
  93. package/lib/mjs/result/ActionResult.js +1 -1
  94. package/lib/mjs/result/ActionResultError.d.ts +1 -1
  95. package/lib/mjs/result/ActionResultError.js +3 -3
  96. package/lib/mjs/result/InitCallResult.d.ts +1 -1
  97. package/lib/mjs/state/Culture.d.ts +2 -2
  98. package/lib/mjs/state/User.d.ts +1 -1
  99. package/package.json +1 -1
  100. package/src/address/AddressAutocomplete.ts +16 -16
  101. package/src/address/AddressCity.ts +12 -12
  102. package/src/address/AddressContinent.ts +35 -35
  103. package/src/address/AddressDistrict.ts +12 -12
  104. package/src/address/AddressLocation.ts +8 -8
  105. package/src/address/AddressPlace.ts +23 -23
  106. package/src/address/AddressPlaceBase.ts +31 -31
  107. package/src/address/AddressRegion.ts +286 -286
  108. package/src/address/AddressState.ts +12 -12
  109. package/src/address/AddressUtils.ts +27 -27
  110. package/src/api/AuthApi.ts +194 -194
  111. package/src/api/BaseApi.ts +13 -13
  112. package/src/api/EntityApi.ts +181 -194
  113. package/src/api/dto/AntiforgeryRequestToken.ts +15 -15
  114. package/src/api/dto/ApiRefreshTokenDto.ts +16 -16
  115. package/src/api/dto/IdLabelDto.ts +3 -3
  116. package/src/api/dto/IdLabelPrimaryDto.ts +7 -7
  117. package/src/api/dto/InitCallDto.ts +12 -12
  118. package/src/api/dto/ResultPayload.ts +6 -6
  119. package/src/api/rq/ApiRefreshTokenRQ.ts +8 -8
  120. package/src/api/rq/AuthRequest.ts +40 -40
  121. package/src/api/rq/GetLogInUrlRQ.ts +8 -8
  122. package/src/api/rq/LoginIdRQ.ts +12 -12
  123. package/src/api/rq/LoginRQ.ts +18 -18
  124. package/src/api/rq/MergeRQ.ts +13 -13
  125. package/src/api/rq/QueryPagingData.ts +16 -16
  126. package/src/api/rq/QueryRQ.ts +22 -22
  127. package/src/api/rq/RefreshTokenRQ.ts +4 -4
  128. package/src/api/rq/ResetPasswordRQ.ts +20 -20
  129. package/src/api/rq/SignoutRQ.ts +8 -8
  130. package/src/api/rq/StatusQueryRQ.ts +11 -11
  131. package/src/api/rq/SwitchOrgRQ.ts +8 -8
  132. package/src/api/rq/TokenRQ.ts +4 -4
  133. package/src/api/rq/UpdateModel.ts +12 -12
  134. package/src/api/rq/UpdateStatusRQ.ts +10 -10
  135. package/src/app/AppSettings.ts +27 -27
  136. package/src/app/UserRole.ts +44 -44
  137. package/src/bridges/FlutterHost.ts +92 -97
  138. package/src/bridges/IBridgeHost.ts +49 -51
  139. package/src/business/ApiService.ts +25 -25
  140. package/src/business/BusinessTax.ts +63 -63
  141. package/src/business/BusinessUtils.ts +75 -75
  142. package/src/business/CultureItem.ts +43 -43
  143. package/src/business/Currency.ts +11 -11
  144. package/src/business/DataPrivacy.ts +35 -35
  145. package/src/business/EntityStatus.ts +44 -44
  146. package/src/business/ProductUnit.ts +58 -58
  147. package/src/business/RepeatOption.ts +50 -50
  148. package/src/business/ShoppingCart.ts +696 -706
  149. package/src/custom/CustomField.ts +20 -20
  150. package/src/custom/CustomFieldData.ts +43 -43
  151. package/src/def/ListItem.ts +12 -12
  152. package/src/i18n/Culture.ts +60 -0
  153. package/src/i18n/en.json +244 -244
  154. package/src/i18n/zh-Hans.json +244 -244
  155. package/src/i18n/zh-Hant.json +244 -244
  156. package/src/index.ts +1 -4
  157. package/src/result/ActionResult.ts +19 -19
  158. package/src/result/ActionResultError.ts +30 -30
  159. package/src/result/InitCallResult.ts +21 -21
  160. package/src/state/Culture.ts +3 -3
  161. package/src/state/State.ts +5 -5
  162. package/src/state/User.ts +92 -92
  163. package/lib/cjs/i18n/CultureUtils.d.ts +0 -13
  164. package/lib/cjs/i18n/CultureUtils.js +0 -32
  165. package/lib/cjs/i18n/en.d.ts +0 -6
  166. package/lib/cjs/i18n/en.js +0 -12
  167. package/lib/cjs/i18n/zhHans.d.ts +0 -6
  168. package/lib/cjs/i18n/zhHans.js +0 -12
  169. package/lib/cjs/i18n/zhHant.d.ts +0 -6
  170. package/lib/cjs/i18n/zhHant.js +0 -12
  171. package/lib/mjs/i18n/CultureUtils.d.ts +0 -13
  172. package/lib/mjs/i18n/CultureUtils.js +0 -29
  173. package/lib/mjs/i18n/en.d.ts +0 -6
  174. package/lib/mjs/i18n/en.js +0 -8
  175. package/lib/mjs/i18n/zhHans.d.ts +0 -6
  176. package/lib/mjs/i18n/zhHans.js +0 -8
  177. package/lib/mjs/i18n/zhHant.d.ts +0 -6
  178. package/lib/mjs/i18n/zhHant.js +0 -8
  179. package/src/i18n/CultureUtils.ts +0 -36
  180. package/src/i18n/en.ts +0 -10
  181. package/src/i18n/zhHans.ts +0 -10
  182. 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 }}
@@ -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
  });