@etsoo/appscript 1.3.19 → 1.3.21

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.
@@ -219,9 +219,13 @@ test('Tests for publicApi', async () => {
219
219
  const options = app.publicApi.repeatOptions(['MONTH', 'QUATER', 'YEAR']);
220
220
  expect(options[2]).toStrictEqual({ id: 12, label: '每年' });
221
221
 
222
- const currencies = await app.publicApi.currencies(['NZD', 'AUD', 'USD']);
222
+ const currencies = app.publicApi.currencies(['NZD', 'AUD', 'USD']);
223
+ expect(currencies.length).toBe(3);
223
224
  expect(currencies[1].id).toBe('AUD');
224
225
 
226
+ const currencies1 = app.publicApi.currencies(true);
227
+ expect(currencies1.length >= 10).toBeTruthy();
228
+
225
229
  /*
226
230
  const orgs = await app.orgApi.list();
227
231
  console.log(orgs);
@@ -0,0 +1,22 @@
1
+ import { IApiPayload } from '@etsoo/restclient';
2
+ import { ListType1 } from '@etsoo/shared';
3
+ import { IApp } from '../app/IApp';
4
+ import { EntityApi } from './EntityApi';
5
+ import { MemberListRQ } from './rq/MemberListRQ';
6
+ /**
7
+ * Member API
8
+ */
9
+ export declare class MemberApi extends EntityApi {
10
+ /**
11
+ * Constructor
12
+ * @param app Application
13
+ */
14
+ constructor(app: IApp);
15
+ /**
16
+ * List
17
+ * @param rq Request data
18
+ * @param payload Payload
19
+ * @returns Result
20
+ */
21
+ list(rq: MemberListRQ, payload: IApiPayload<ListType1[]>): Promise<ListType1[] | undefined>;
22
+ }
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MemberApi = void 0;
4
+ const EntityApi_1 = require("./EntityApi");
5
+ /**
6
+ * Member API
7
+ */
8
+ class MemberApi extends EntityApi_1.EntityApi {
9
+ /**
10
+ * Constructor
11
+ * @param app Application
12
+ */
13
+ constructor(app) {
14
+ super('Member', app);
15
+ }
16
+ /**
17
+ * List
18
+ * @param rq Request data
19
+ * @param payload Payload
20
+ * @returns Result
21
+ */
22
+ list(rq, payload) {
23
+ return this.listBase(rq, payload);
24
+ }
25
+ }
26
+ exports.MemberApi = MemberApi;
@@ -16,7 +16,8 @@ export declare class PublicApi extends BaseApi {
16
16
  * @param currencyNames Limited currency names for local data, undefined will try to retrive remoately
17
17
  * @returns Result
18
18
  */
19
- currencies<T extends string[] | Currency[] | undefined>(currencyNames?: T): Promise<T extends undefined ? CurrencyDto[] | undefined : ListType1[]>;
19
+ currencies(): Promise<CurrencyDto[] | undefined>;
20
+ currencies(names: string[] | Currency[] | boolean): ListType1[];
20
21
  /**
21
22
  * Get exchange rate
22
23
  * @param currency Currency
@@ -55,7 +56,7 @@ export declare class PublicApi extends BaseApi {
55
56
  * @param payload Payload
56
57
  * @returns Result
57
58
  */
58
- product<T extends number | string>(id: T, culture?: string, payload?: IApiPayload<PublicProductDto>): Promise<(T extends number ? PublicProductDto : PublicOrgProductDto) | undefined>;
59
+ product<T extends number | string>(id: T, culture?: string, payload?: IApiPayload<T extends number ? PublicProductDto : PublicOrgProductDto>): Promise<(T extends number ? PublicProductDto : PublicOrgProductDto) | undefined>;
59
60
  /**
60
61
  *
61
62
  * Get all repeat options
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PublicApi = void 0;
4
4
  const shared_1 = require("@etsoo/shared");
5
+ const Currency_1 = require("../business/Currency");
5
6
  const ProductUnit_1 = require("../business/ProductUnit");
6
7
  const RepeatOption_1 = require("../business/RepeatOption");
7
8
  const BaseApi_1 = require("./BaseApi");
@@ -9,22 +10,29 @@ const BaseApi_1 = require("./BaseApi");
9
10
  * Public API
10
11
  */
11
12
  class PublicApi extends BaseApi_1.BaseApi {
12
- /**
13
- * Get currencies
14
- * @param currencyNames Limited currency names for local data, undefined will try to retrive remoately
15
- * @returns Result
16
- */
17
- async currencies(currencyNames) {
18
- if (currencyNames == null)
19
- return (await this.api.get('Public/GetCurrencies', undefined, { defaultValue: [], showLoading: false }));
20
- else
21
- return currencyNames.map((name) => {
13
+ currencies(names) {
14
+ if (typeof names === 'boolean' && names) {
15
+ return Currency_1.Currencies.map((name) => {
16
+ var _a;
17
+ return ({
18
+ id: name,
19
+ label: (_a = this.app.get(`currency${name}`)) !== null && _a !== void 0 ? _a : name
20
+ });
21
+ });
22
+ }
23
+ if (Array.isArray(names)) {
24
+ return names.map((name) => {
22
25
  var _a;
23
26
  return ({
24
27
  id: name,
25
28
  label: (_a = this.app.get(`currency${name}`)) !== null && _a !== void 0 ? _a : name
26
29
  });
27
30
  });
31
+ }
32
+ return this.api.get('Public/GetCurrencies', undefined, {
33
+ defaultValue: [],
34
+ showLoading: false
35
+ });
28
36
  }
29
37
  /**
30
38
  * Get exchange rate
@@ -80,6 +88,7 @@ class PublicApi extends BaseApi_1.BaseApi {
80
88
  mobileQRCode(id, host, payload) {
81
89
  return this.api.post('Public/MobileQRCode', { id, host }, payload);
82
90
  }
91
+ //product(id: number, culture?: string, ): Promise<PublicProductDto | undefined>;
83
92
  /**
84
93
  * Get public and valid product data
85
94
  * @param id Product/Service Id or Uid
@@ -0,0 +1,5 @@
1
+ import { TiplistRQ } from './TiplistRQ';
2
+ /**
3
+ * Member list request data
4
+ */
5
+ export declare type MemberListRQ = TiplistRQ & {};
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -26,6 +26,7 @@ export * from './erp/dto/OrgDto';
26
26
  export * from './erp/dto/OrgQueryDto';
27
27
  export * from './erp/dto/PublicProductDto';
28
28
  export * from './erp/dto/ResultPayload';
29
+ export * from './erp/rq/MemberListRQ';
29
30
  export * from './erp/rq/OrgListRQ';
30
31
  export * from './erp/rq/OrgQueryRQ';
31
32
  export * from './erp/rq/QueryRQ';
@@ -34,6 +35,7 @@ export * from './erp/rq/TiplistRQ';
34
35
  export * from './erp/AddressApi';
35
36
  export * from './erp/BaseApi';
36
37
  export * from './erp/EntityApi';
38
+ export * from './erp/MemberApi';
37
39
  export * from './erp/OrgApi';
38
40
  export * from './erp/PublicApi';
39
41
  export * from './i18n/enUS';
package/lib/cjs/index.js CHANGED
@@ -50,6 +50,7 @@ __exportStar(require("./erp/dto/OrgQueryDto"), exports);
50
50
  __exportStar(require("./erp/dto/PublicProductDto"), exports);
51
51
  __exportStar(require("./erp/dto/ResultPayload"), exports);
52
52
  // erp rq
53
+ __exportStar(require("./erp/rq/MemberListRQ"), exports);
53
54
  __exportStar(require("./erp/rq/OrgListRQ"), exports);
54
55
  __exportStar(require("./erp/rq/OrgQueryRQ"), exports);
55
56
  __exportStar(require("./erp/rq/QueryRQ"), exports);
@@ -59,6 +60,7 @@ __exportStar(require("./erp/rq/TiplistRQ"), exports);
59
60
  __exportStar(require("./erp/AddressApi"), exports);
60
61
  __exportStar(require("./erp/BaseApi"), exports);
61
62
  __exportStar(require("./erp/EntityApi"), exports);
63
+ __exportStar(require("./erp/MemberApi"), exports);
62
64
  __exportStar(require("./erp/OrgApi"), exports);
63
65
  __exportStar(require("./erp/PublicApi"), exports);
64
66
  // i18n
@@ -0,0 +1,22 @@
1
+ import { IApiPayload } from '@etsoo/restclient';
2
+ import { ListType1 } from '@etsoo/shared';
3
+ import { IApp } from '../app/IApp';
4
+ import { EntityApi } from './EntityApi';
5
+ import { MemberListRQ } from './rq/MemberListRQ';
6
+ /**
7
+ * Member API
8
+ */
9
+ export declare class MemberApi extends EntityApi {
10
+ /**
11
+ * Constructor
12
+ * @param app Application
13
+ */
14
+ constructor(app: IApp);
15
+ /**
16
+ * List
17
+ * @param rq Request data
18
+ * @param payload Payload
19
+ * @returns Result
20
+ */
21
+ list(rq: MemberListRQ, payload: IApiPayload<ListType1[]>): Promise<ListType1[] | undefined>;
22
+ }
@@ -0,0 +1,22 @@
1
+ import { EntityApi } from './EntityApi';
2
+ /**
3
+ * Member API
4
+ */
5
+ export class MemberApi extends EntityApi {
6
+ /**
7
+ * Constructor
8
+ * @param app Application
9
+ */
10
+ constructor(app) {
11
+ super('Member', app);
12
+ }
13
+ /**
14
+ * List
15
+ * @param rq Request data
16
+ * @param payload Payload
17
+ * @returns Result
18
+ */
19
+ list(rq, payload) {
20
+ return this.listBase(rq, payload);
21
+ }
22
+ }
@@ -16,7 +16,8 @@ export declare class PublicApi extends BaseApi {
16
16
  * @param currencyNames Limited currency names for local data, undefined will try to retrive remoately
17
17
  * @returns Result
18
18
  */
19
- currencies<T extends string[] | Currency[] | undefined>(currencyNames?: T): Promise<T extends undefined ? CurrencyDto[] | undefined : ListType1[]>;
19
+ currencies(): Promise<CurrencyDto[] | undefined>;
20
+ currencies(names: string[] | Currency[] | boolean): ListType1[];
20
21
  /**
21
22
  * Get exchange rate
22
23
  * @param currency Currency
@@ -55,7 +56,7 @@ export declare class PublicApi extends BaseApi {
55
56
  * @param payload Payload
56
57
  * @returns Result
57
58
  */
58
- product<T extends number | string>(id: T, culture?: string, payload?: IApiPayload<PublicProductDto>): Promise<(T extends number ? PublicProductDto : PublicOrgProductDto) | undefined>;
59
+ product<T extends number | string>(id: T, culture?: string, payload?: IApiPayload<T extends number ? PublicProductDto : PublicOrgProductDto>): Promise<(T extends number ? PublicProductDto : PublicOrgProductDto) | undefined>;
59
60
  /**
60
61
  *
61
62
  * Get all repeat options
@@ -1,4 +1,5 @@
1
1
  import { DataTypes } from '@etsoo/shared';
2
+ import { Currencies } from '../business/Currency';
2
3
  import { ProductUnit } from '../business/ProductUnit';
3
4
  import { RepeatOption } from '../business/RepeatOption';
4
5
  import { BaseApi } from './BaseApi';
@@ -6,22 +7,29 @@ import { BaseApi } from './BaseApi';
6
7
  * Public API
7
8
  */
8
9
  export class PublicApi extends BaseApi {
9
- /**
10
- * Get currencies
11
- * @param currencyNames Limited currency names for local data, undefined will try to retrive remoately
12
- * @returns Result
13
- */
14
- async currencies(currencyNames) {
15
- if (currencyNames == null)
16
- return (await this.api.get('Public/GetCurrencies', undefined, { defaultValue: [], showLoading: false }));
17
- else
18
- return currencyNames.map((name) => {
10
+ currencies(names) {
11
+ if (typeof names === 'boolean' && names) {
12
+ return Currencies.map((name) => {
13
+ var _a;
14
+ return ({
15
+ id: name,
16
+ label: (_a = this.app.get(`currency${name}`)) !== null && _a !== void 0 ? _a : name
17
+ });
18
+ });
19
+ }
20
+ if (Array.isArray(names)) {
21
+ return names.map((name) => {
19
22
  var _a;
20
23
  return ({
21
24
  id: name,
22
25
  label: (_a = this.app.get(`currency${name}`)) !== null && _a !== void 0 ? _a : name
23
26
  });
24
27
  });
28
+ }
29
+ return this.api.get('Public/GetCurrencies', undefined, {
30
+ defaultValue: [],
31
+ showLoading: false
32
+ });
25
33
  }
26
34
  /**
27
35
  * Get exchange rate
@@ -77,6 +85,7 @@ export class PublicApi extends BaseApi {
77
85
  mobileQRCode(id, host, payload) {
78
86
  return this.api.post('Public/MobileQRCode', { id, host }, payload);
79
87
  }
88
+ //product(id: number, culture?: string, ): Promise<PublicProductDto | undefined>;
80
89
  /**
81
90
  * Get public and valid product data
82
91
  * @param id Product/Service Id or Uid
@@ -0,0 +1,5 @@
1
+ import { TiplistRQ } from './TiplistRQ';
2
+ /**
3
+ * Member list request data
4
+ */
5
+ export declare type MemberListRQ = TiplistRQ & {};
@@ -0,0 +1 @@
1
+ export {};
@@ -26,6 +26,7 @@ export * from './erp/dto/OrgDto';
26
26
  export * from './erp/dto/OrgQueryDto';
27
27
  export * from './erp/dto/PublicProductDto';
28
28
  export * from './erp/dto/ResultPayload';
29
+ export * from './erp/rq/MemberListRQ';
29
30
  export * from './erp/rq/OrgListRQ';
30
31
  export * from './erp/rq/OrgQueryRQ';
31
32
  export * from './erp/rq/QueryRQ';
@@ -34,6 +35,7 @@ export * from './erp/rq/TiplistRQ';
34
35
  export * from './erp/AddressApi';
35
36
  export * from './erp/BaseApi';
36
37
  export * from './erp/EntityApi';
38
+ export * from './erp/MemberApi';
37
39
  export * from './erp/OrgApi';
38
40
  export * from './erp/PublicApi';
39
41
  export * from './i18n/enUS';
package/lib/mjs/index.js CHANGED
@@ -33,6 +33,7 @@ export * from './erp/dto/OrgQueryDto';
33
33
  export * from './erp/dto/PublicProductDto';
34
34
  export * from './erp/dto/ResultPayload';
35
35
  // erp rq
36
+ export * from './erp/rq/MemberListRQ';
36
37
  export * from './erp/rq/OrgListRQ';
37
38
  export * from './erp/rq/OrgQueryRQ';
38
39
  export * from './erp/rq/QueryRQ';
@@ -42,6 +43,7 @@ export * from './erp/rq/TiplistRQ';
42
43
  export * from './erp/AddressApi';
43
44
  export * from './erp/BaseApi';
44
45
  export * from './erp/EntityApi';
46
+ export * from './erp/MemberApi';
45
47
  export * from './erp/OrgApi';
46
48
  export * from './erp/PublicApi';
47
49
  // i18n
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/appscript",
3
- "version": "1.3.19",
3
+ "version": "1.3.21",
4
4
  "description": "Applications shared TypeScript framework",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/mjs/index.js",
@@ -65,13 +65,13 @@
65
65
  "@babel/preset-env": "^7.19.4",
66
66
  "@babel/runtime-corejs3": "^7.19.6",
67
67
  "@types/jest": "^29.2.0",
68
- "@typescript-eslint/eslint-plugin": "^5.40.1",
69
- "@typescript-eslint/parser": "^5.40.1",
70
- "eslint": "^8.25.0",
68
+ "@typescript-eslint/eslint-plugin": "^5.41.0",
69
+ "@typescript-eslint/parser": "^5.41.0",
70
+ "eslint": "^8.26.0",
71
71
  "eslint-config-airbnb-base": "^15.0.0",
72
72
  "eslint-plugin-import": "^2.26.0",
73
- "jest": "^29.2.1",
74
- "jest-environment-jsdom": "^29.2.1",
73
+ "jest": "^29.2.2",
74
+ "jest-environment-jsdom": "^29.2.2",
75
75
  "ts-jest": "^29.0.3",
76
76
  "typescript": "^4.8.4"
77
77
  }
@@ -0,0 +1,28 @@
1
+ import { IApiPayload } from '@etsoo/restclient';
2
+ import { ListType1 } from '@etsoo/shared';
3
+ import { IApp } from '../app/IApp';
4
+ import { EntityApi } from './EntityApi';
5
+ import { MemberListRQ } from './rq/MemberListRQ';
6
+
7
+ /**
8
+ * Member API
9
+ */
10
+ export class MemberApi extends EntityApi {
11
+ /**
12
+ * Constructor
13
+ * @param app Application
14
+ */
15
+ constructor(app: IApp) {
16
+ super('Member', app);
17
+ }
18
+
19
+ /**
20
+ * List
21
+ * @param rq Request data
22
+ * @param payload Payload
23
+ * @returns Result
24
+ */
25
+ list(rq: MemberListRQ, payload: IApiPayload<ListType1[]>) {
26
+ return this.listBase(rq, payload);
27
+ }
28
+ }
@@ -1,6 +1,6 @@
1
1
  import { IApiPayload } from '@etsoo/restclient';
2
2
  import { DataTypes, ListType, ListType1 } from '@etsoo/shared';
3
- import { Currency } from '../business/Currency';
3
+ import { Currencies, Currency } from '../business/Currency';
4
4
  import { ProductUnit } from '../business/ProductUnit';
5
5
  import { RepeatOption } from '../business/RepeatOption';
6
6
  import { BaseApi } from './BaseApi';
@@ -18,20 +18,27 @@ export class PublicApi extends BaseApi {
18
18
  * @param currencyNames Limited currency names for local data, undefined will try to retrive remoately
19
19
  * @returns Result
20
20
  */
21
- async currencies<T extends string[] | Currency[] | undefined>(
22
- currencyNames?: T
23
- ): Promise<T extends undefined ? CurrencyDto[] | undefined : ListType1[]> {
24
- if (currencyNames == null)
25
- return (await this.api.get<CurrencyDto[]>(
26
- 'Public/GetCurrencies',
27
- undefined,
28
- { defaultValue: [], showLoading: false }
29
- )) as any;
30
- else
31
- return currencyNames.map((name) => ({
21
+ currencies(): Promise<CurrencyDto[] | undefined>;
22
+ currencies(names: string[] | Currency[] | boolean): ListType1[];
23
+ currencies(names?: string[] | Currency[] | boolean) {
24
+ if (typeof names === 'boolean' && names) {
25
+ return Currencies.map((name) => ({
32
26
  id: name,
33
27
  label: this.app.get(`currency${name}`) ?? name
34
- })) as any;
28
+ }));
29
+ }
30
+
31
+ if (Array.isArray(names)) {
32
+ return names.map((name) => ({
33
+ id: name,
34
+ label: this.app.get(`currency${name}`) ?? name
35
+ }));
36
+ }
37
+
38
+ return this.api.get<CurrencyDto[]>('Public/GetCurrencies', undefined, {
39
+ defaultValue: [],
40
+ showLoading: false
41
+ });
35
42
  }
36
43
 
37
44
  /**
@@ -106,6 +113,8 @@ export class PublicApi extends BaseApi {
106
113
  return this.api.post('Public/MobileQRCode', { id, host }, payload);
107
114
  }
108
115
 
116
+ //product(id: number, culture?: string, ): Promise<PublicProductDto | undefined>;
117
+
109
118
  /**
110
119
  * Get public and valid product data
111
120
  * @param id Product/Service Id or Uid
@@ -116,16 +125,16 @@ export class PublicApi extends BaseApi {
116
125
  product<T extends number | string>(
117
126
  id: T,
118
127
  culture?: string,
119
- payload?: IApiPayload<PublicProductDto>
120
- ): Promise<
121
- (T extends number ? PublicProductDto : PublicOrgProductDto) | undefined
122
- > {
128
+ payload?: IApiPayload<
129
+ T extends number ? PublicProductDto : PublicOrgProductDto
130
+ >
131
+ ) {
123
132
  culture = this.app.checkLanguage(culture);
124
133
  return this.api.get(
125
134
  `Public/Product/${id}/${culture}`,
126
135
  undefined,
127
136
  payload
128
- ) as any;
137
+ );
129
138
  }
130
139
 
131
140
  /**
@@ -0,0 +1,6 @@
1
+ import { TiplistRQ } from './TiplistRQ';
2
+
3
+ /**
4
+ * Member list request data
5
+ */
6
+ export type MemberListRQ = TiplistRQ & {};
package/src/index.ts CHANGED
@@ -39,6 +39,7 @@ export * from './erp/dto/PublicProductDto';
39
39
  export * from './erp/dto/ResultPayload';
40
40
 
41
41
  // erp rq
42
+ export * from './erp/rq/MemberListRQ';
42
43
  export * from './erp/rq/OrgListRQ';
43
44
  export * from './erp/rq/OrgQueryRQ';
44
45
  export * from './erp/rq/QueryRQ';
@@ -49,6 +50,7 @@ export * from './erp/rq/TiplistRQ';
49
50
  export * from './erp/AddressApi';
50
51
  export * from './erp/BaseApi';
51
52
  export * from './erp/EntityApi';
53
+ export * from './erp/MemberApi';
52
54
  export * from './erp/OrgApi';
53
55
  export * from './erp/PublicApi';
54
56