@etsoo/appscript 1.0.86 → 1.0.90

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.
@@ -106,6 +106,11 @@ export interface ICoreApp<S extends IAppSettings, N> {
106
106
  * @returns response refresh token
107
107
  */
108
108
  getResponseToken(rawResponse: any): string | null;
109
+ /**
110
+ * Get time zone
111
+ * @returns Time zone
112
+ */
113
+ getTimeZone(): string | undefined;
109
114
  /**
110
115
  * Callback where exit a page
111
116
  */
@@ -244,6 +249,11 @@ export declare abstract class CoreApp<S extends IAppSettings, N> implements ICor
244
249
  * @returns response refresh token
245
250
  */
246
251
  getResponseToken(rawResponse: any): string | null;
252
+ /**
253
+ * Get time zone
254
+ * @returns Time zone
255
+ */
256
+ getTimeZone(): string | undefined;
247
257
  /**
248
258
  * Callback where exit a page
249
259
  */
@@ -213,6 +213,15 @@ class CoreApp {
213
213
  const response = this.api.transformResponse(rawResponse);
214
214
  return this.api.getHeaderValue(response.headers, this.headerTokenField);
215
215
  }
216
+ /**
217
+ * Get time zone
218
+ * @returns Time zone
219
+ */
220
+ getTimeZone() {
221
+ var _a, _b;
222
+ // settings.timeZone = Utils.getTimeZone()
223
+ return (_a = this.settings.timeZone) !== null && _a !== void 0 ? _a : (_b = this.ipData) === null || _b === void 0 ? void 0 : _b.timezone;
224
+ }
216
225
  /**
217
226
  * Callback where exit a page
218
227
  */
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Product units enum
3
+ * See com.etsoo.CoreFramework.Business.ProductUnit
4
+ */
5
+ export declare enum ProductUnit {
6
+ PC = 0,
7
+ SET = 1,
8
+ YEAR = 10,
9
+ QUATER = 11,
10
+ MONTH = 12,
11
+ FORNIGHT = 13,
12
+ WEEK = 14,
13
+ DAY = 15,
14
+ HOUR = 16,
15
+ TON = 31,
16
+ KILOGRAM = 32,
17
+ GRAM = 33
18
+ }
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ProductUnit = void 0;
4
+ /**
5
+ * Product units enum
6
+ * See com.etsoo.CoreFramework.Business.ProductUnit
7
+ */
8
+ var ProductUnit;
9
+ (function (ProductUnit) {
10
+ /// <summary>
11
+ /// Picese
12
+ /// 件
13
+ /// </summary>
14
+ ProductUnit[ProductUnit["PC"] = 0] = "PC";
15
+ /// <summary>
16
+ /// Set
17
+ /// 套
18
+ /// </summary>
19
+ ProductUnit[ProductUnit["SET"] = 1] = "SET";
20
+ /// <summary>
21
+ /// Year
22
+ /// 年
23
+ /// </summary>
24
+ ProductUnit[ProductUnit["YEAR"] = 10] = "YEAR";
25
+ /// <summary>
26
+ /// Quater
27
+ /// 季
28
+ /// </summary>
29
+ ProductUnit[ProductUnit["QUATER"] = 11] = "QUATER";
30
+ /// <summary>
31
+ /// Month
32
+ /// 月
33
+ /// </summary>
34
+ ProductUnit[ProductUnit["MONTH"] = 12] = "MONTH";
35
+ /// <summary>
36
+ /// Fortnight
37
+ /// 两周
38
+ /// </summary>
39
+ ProductUnit[ProductUnit["FORNIGHT"] = 13] = "FORNIGHT";
40
+ /// <summary>
41
+ /// Week
42
+ /// 周
43
+ /// </summary>
44
+ ProductUnit[ProductUnit["WEEK"] = 14] = "WEEK";
45
+ /// <summary>
46
+ /// Day
47
+ /// 天
48
+ /// </summary>
49
+ ProductUnit[ProductUnit["DAY"] = 15] = "DAY";
50
+ /// <summary>
51
+ /// Hour
52
+ /// 小时
53
+ /// </summary>
54
+ ProductUnit[ProductUnit["HOUR"] = 16] = "HOUR";
55
+ /// <summary>
56
+ /// Ton
57
+ /// 吨
58
+ /// </summary>
59
+ ProductUnit[ProductUnit["TON"] = 31] = "TON";
60
+ /// <summary>
61
+ /// Kilogram
62
+ /// 千克
63
+ /// </summary>
64
+ ProductUnit[ProductUnit["KILOGRAM"] = 32] = "KILOGRAM";
65
+ /// <summary>
66
+ /// Gram
67
+ /// 克
68
+ /// </summary>
69
+ ProductUnit[ProductUnit["GRAM"] = 33] = "GRAM";
70
+ })(ProductUnit = exports.ProductUnit || (exports.ProductUnit = {}));
@@ -0,0 +1,15 @@
1
+ import { ICultureGet } from '../state/Culture';
2
+ import { ProductUnit } from './ProductUnit';
3
+ /**
4
+ * Business utils
5
+ */
6
+ export declare namespace Utils {
7
+ /**
8
+ * Get product unit's label
9
+ * Please define the label in culture with key 'unitPC' for ProductUnit.PC like that
10
+ * @param unit Unit
11
+ * @param func Label delegate
12
+ * @returns Label
13
+ */
14
+ function getUnitLabel(unit: ProductUnit, func: ICultureGet): string;
15
+ }
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Utils = void 0;
4
+ const ProductUnit_1 = require("./ProductUnit");
5
+ /**
6
+ * Business utils
7
+ */
8
+ var Utils;
9
+ (function (Utils) {
10
+ /**
11
+ * Get product unit's label
12
+ * Please define the label in culture with key 'unitPC' for ProductUnit.PC like that
13
+ * @param unit Unit
14
+ * @param func Label delegate
15
+ * @returns Label
16
+ */
17
+ function getUnitLabel(unit, func) {
18
+ var _a;
19
+ const key = ProductUnit_1.ProductUnit[unit];
20
+ return (_a = func('unit' + key)) !== null && _a !== void 0 ? _a : key;
21
+ }
22
+ Utils.getUnitLabel = getUnitLabel;
23
+ })(Utils = exports.Utils || (exports.Utils = {}));
@@ -7,3 +7,9 @@ import { IState } from './State';
7
7
  */
8
8
  export interface ICulture extends DataTypes.CultureDefinition, IState {
9
9
  }
10
+ /**
11
+ * Culture get delegate
12
+ */
13
+ export interface ICultureGet {
14
+ (key: string): string | undefined;
15
+ }
@@ -106,6 +106,11 @@ export interface ICoreApp<S extends IAppSettings, N> {
106
106
  * @returns response refresh token
107
107
  */
108
108
  getResponseToken(rawResponse: any): string | null;
109
+ /**
110
+ * Get time zone
111
+ * @returns Time zone
112
+ */
113
+ getTimeZone(): string | undefined;
109
114
  /**
110
115
  * Callback where exit a page
111
116
  */
@@ -244,6 +249,11 @@ export declare abstract class CoreApp<S extends IAppSettings, N> implements ICor
244
249
  * @returns response refresh token
245
250
  */
246
251
  getResponseToken(rawResponse: any): string | null;
252
+ /**
253
+ * Get time zone
254
+ * @returns Time zone
255
+ */
256
+ getTimeZone(): string | undefined;
247
257
  /**
248
258
  * Callback where exit a page
249
259
  */
@@ -210,6 +210,15 @@ export class CoreApp {
210
210
  const response = this.api.transformResponse(rawResponse);
211
211
  return this.api.getHeaderValue(response.headers, this.headerTokenField);
212
212
  }
213
+ /**
214
+ * Get time zone
215
+ * @returns Time zone
216
+ */
217
+ getTimeZone() {
218
+ var _a, _b;
219
+ // settings.timeZone = Utils.getTimeZone()
220
+ return (_a = this.settings.timeZone) !== null && _a !== void 0 ? _a : (_b = this.ipData) === null || _b === void 0 ? void 0 : _b.timezone;
221
+ }
213
222
  /**
214
223
  * Callback where exit a page
215
224
  */
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Product units enum
3
+ * See com.etsoo.CoreFramework.Business.ProductUnit
4
+ */
5
+ export declare enum ProductUnit {
6
+ PC = 0,
7
+ SET = 1,
8
+ YEAR = 10,
9
+ QUATER = 11,
10
+ MONTH = 12,
11
+ FORNIGHT = 13,
12
+ WEEK = 14,
13
+ DAY = 15,
14
+ HOUR = 16,
15
+ TON = 31,
16
+ KILOGRAM = 32,
17
+ GRAM = 33
18
+ }
@@ -0,0 +1,67 @@
1
+ /**
2
+ * Product units enum
3
+ * See com.etsoo.CoreFramework.Business.ProductUnit
4
+ */
5
+ export var ProductUnit;
6
+ (function (ProductUnit) {
7
+ /// <summary>
8
+ /// Picese
9
+ /// 件
10
+ /// </summary>
11
+ ProductUnit[ProductUnit["PC"] = 0] = "PC";
12
+ /// <summary>
13
+ /// Set
14
+ /// 套
15
+ /// </summary>
16
+ ProductUnit[ProductUnit["SET"] = 1] = "SET";
17
+ /// <summary>
18
+ /// Year
19
+ /// 年
20
+ /// </summary>
21
+ ProductUnit[ProductUnit["YEAR"] = 10] = "YEAR";
22
+ /// <summary>
23
+ /// Quater
24
+ /// 季
25
+ /// </summary>
26
+ ProductUnit[ProductUnit["QUATER"] = 11] = "QUATER";
27
+ /// <summary>
28
+ /// Month
29
+ /// 月
30
+ /// </summary>
31
+ ProductUnit[ProductUnit["MONTH"] = 12] = "MONTH";
32
+ /// <summary>
33
+ /// Fortnight
34
+ /// 两周
35
+ /// </summary>
36
+ ProductUnit[ProductUnit["FORNIGHT"] = 13] = "FORNIGHT";
37
+ /// <summary>
38
+ /// Week
39
+ /// 周
40
+ /// </summary>
41
+ ProductUnit[ProductUnit["WEEK"] = 14] = "WEEK";
42
+ /// <summary>
43
+ /// Day
44
+ /// 天
45
+ /// </summary>
46
+ ProductUnit[ProductUnit["DAY"] = 15] = "DAY";
47
+ /// <summary>
48
+ /// Hour
49
+ /// 小时
50
+ /// </summary>
51
+ ProductUnit[ProductUnit["HOUR"] = 16] = "HOUR";
52
+ /// <summary>
53
+ /// Ton
54
+ /// 吨
55
+ /// </summary>
56
+ ProductUnit[ProductUnit["TON"] = 31] = "TON";
57
+ /// <summary>
58
+ /// Kilogram
59
+ /// 千克
60
+ /// </summary>
61
+ ProductUnit[ProductUnit["KILOGRAM"] = 32] = "KILOGRAM";
62
+ /// <summary>
63
+ /// Gram
64
+ /// 克
65
+ /// </summary>
66
+ ProductUnit[ProductUnit["GRAM"] = 33] = "GRAM";
67
+ })(ProductUnit || (ProductUnit = {}));
@@ -0,0 +1,15 @@
1
+ import { ICultureGet } from '../state/Culture';
2
+ import { ProductUnit } from './ProductUnit';
3
+ /**
4
+ * Business utils
5
+ */
6
+ export declare namespace Utils {
7
+ /**
8
+ * Get product unit's label
9
+ * Please define the label in culture with key 'unitPC' for ProductUnit.PC like that
10
+ * @param unit Unit
11
+ * @param func Label delegate
12
+ * @returns Label
13
+ */
14
+ function getUnitLabel(unit: ProductUnit, func: ICultureGet): string;
15
+ }
@@ -0,0 +1,20 @@
1
+ import { ProductUnit } from './ProductUnit';
2
+ /**
3
+ * Business utils
4
+ */
5
+ export var Utils;
6
+ (function (Utils) {
7
+ /**
8
+ * Get product unit's label
9
+ * Please define the label in culture with key 'unitPC' for ProductUnit.PC like that
10
+ * @param unit Unit
11
+ * @param func Label delegate
12
+ * @returns Label
13
+ */
14
+ function getUnitLabel(unit, func) {
15
+ var _a;
16
+ const key = ProductUnit[unit];
17
+ return (_a = func('unit' + key)) !== null && _a !== void 0 ? _a : key;
18
+ }
19
+ Utils.getUnitLabel = getUnitLabel;
20
+ })(Utils || (Utils = {}));
@@ -7,3 +7,9 @@ import { IState } from './State';
7
7
  */
8
8
  export interface ICulture extends DataTypes.CultureDefinition, IState {
9
9
  }
10
+ /**
11
+ * Culture get delegate
12
+ */
13
+ export interface ICultureGet {
14
+ (key: string): string | undefined;
15
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/appscript",
3
- "version": "1.0.86",
3
+ "version": "1.0.90",
4
4
  "description": "Applications shared TypeScript framework",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/mjs/index.js",
@@ -47,23 +47,23 @@
47
47
  },
48
48
  "homepage": "https://github.com/ETSOO/NotificationBase#readme",
49
49
  "dependencies": {
50
- "@etsoo/notificationbase": "^1.0.77",
50
+ "@etsoo/notificationbase": "^1.0.78",
51
51
  "@etsoo/restclient": "^1.0.51",
52
52
  "@etsoo/shared": "^1.0.41"
53
53
  },
54
54
  "devDependencies": {
55
- "@babel/cli": "^7.15.4",
55
+ "@babel/cli": "^7.15.7",
56
56
  "@babel/core": "^7.15.5",
57
57
  "@babel/plugin-transform-runtime": "^7.15.0",
58
58
  "@babel/preset-env": "^7.15.6",
59
59
  "@babel/runtime-corejs3": "^7.15.4",
60
- "@types/jest": "^27.0.1",
61
- "@typescript-eslint/eslint-plugin": "^4.31.1",
62
- "@typescript-eslint/parser": "^4.31.1",
60
+ "@types/jest": "^27.0.2",
61
+ "@typescript-eslint/eslint-plugin": "^4.32.0",
62
+ "@typescript-eslint/parser": "^4.32.0",
63
63
  "eslint": "^7.32.0",
64
64
  "eslint-config-airbnb-base": "^14.2.1",
65
65
  "eslint-plugin-import": "^2.24.2",
66
- "jest": "^27.2.0",
66
+ "jest": "^27.2.3",
67
67
  "ts-jest": "^27.0.5",
68
68
  "typescript": "^4.4.3"
69
69
  }
@@ -129,6 +129,12 @@ export interface ICoreApp<S extends IAppSettings, N> {
129
129
  */
130
130
  getResponseToken(rawResponse: any): string | null;
131
131
 
132
+ /**
133
+ * Get time zone
134
+ * @returns Time zone
135
+ */
136
+ getTimeZone(): string | undefined;
137
+
132
138
  /**
133
139
  * Callback where exit a page
134
140
  */
@@ -453,6 +459,15 @@ export abstract class CoreApp<S extends IAppSettings, N>
453
459
  return this.api.getHeaderValue(response.headers, this.headerTokenField);
454
460
  }
455
461
 
462
+ /**
463
+ * Get time zone
464
+ * @returns Time zone
465
+ */
466
+ getTimeZone(): string | undefined {
467
+ // settings.timeZone = Utils.getTimeZone()
468
+ return this.settings.timeZone ?? this.ipData?.timezone;
469
+ }
470
+
456
471
  /**
457
472
  * Callback where exit a page
458
473
  */
@@ -0,0 +1,77 @@
1
+ /**
2
+ * Product units enum
3
+ * See com.etsoo.CoreFramework.Business.ProductUnit
4
+ */
5
+ export enum ProductUnit {
6
+ /// <summary>
7
+ /// Picese
8
+ /// 件
9
+ /// </summary>
10
+ PC = 0,
11
+
12
+ /// <summary>
13
+ /// Set
14
+ /// 套
15
+ /// </summary>
16
+ SET = 1,
17
+
18
+ /// <summary>
19
+ /// Year
20
+ /// 年
21
+ /// </summary>
22
+ YEAR = 10,
23
+
24
+ /// <summary>
25
+ /// Quater
26
+ /// 季
27
+ /// </summary>
28
+ QUATER = 11,
29
+
30
+ /// <summary>
31
+ /// Month
32
+ /// 月
33
+ /// </summary>
34
+ MONTH = 12,
35
+
36
+ /// <summary>
37
+ /// Fortnight
38
+ /// 两周
39
+ /// </summary>
40
+ FORNIGHT = 13,
41
+
42
+ /// <summary>
43
+ /// Week
44
+ /// 周
45
+ /// </summary>
46
+ WEEK = 14,
47
+
48
+ /// <summary>
49
+ /// Day
50
+ /// 天
51
+ /// </summary>
52
+ DAY = 15,
53
+
54
+ /// <summary>
55
+ /// Hour
56
+ /// 小时
57
+ /// </summary>
58
+ HOUR = 16,
59
+
60
+ /// <summary>
61
+ /// Ton
62
+ /// 吨
63
+ /// </summary>
64
+ TON = 31,
65
+
66
+ /// <summary>
67
+ /// Kilogram
68
+ /// 千克
69
+ /// </summary>
70
+ KILOGRAM = 32,
71
+
72
+ /// <summary>
73
+ /// Gram
74
+ /// 克
75
+ /// </summary>
76
+ GRAM = 33
77
+ }
@@ -0,0 +1,19 @@
1
+ import { ICultureGet } from '../state/Culture';
2
+ import { ProductUnit } from './ProductUnit';
3
+
4
+ /**
5
+ * Business utils
6
+ */
7
+ export namespace Utils {
8
+ /**
9
+ * Get product unit's label
10
+ * Please define the label in culture with key 'unitPC' for ProductUnit.PC like that
11
+ * @param unit Unit
12
+ * @param func Label delegate
13
+ * @returns Label
14
+ */
15
+ export function getUnitLabel(unit: ProductUnit, func: ICultureGet) {
16
+ const key = ProductUnit[unit];
17
+ return func('unit' + key) ?? key;
18
+ }
19
+ }
@@ -7,3 +7,10 @@ import { IState } from './State';
7
7
  * Indexable type
8
8
  */
9
9
  export interface ICulture extends DataTypes.CultureDefinition, IState {}
10
+
11
+ /**
12
+ * Culture get delegate
13
+ */
14
+ export interface ICultureGet {
15
+ (key: string): string | undefined;
16
+ }