@etsoo/appscript 1.3.18 → 1.3.20
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/__tests__/app/CoreApp.ts +5 -1
- package/lib/cjs/erp/OrgApi.js +1 -1
- package/lib/cjs/erp/PublicApi.d.ts +3 -2
- package/lib/cjs/erp/PublicApi.js +19 -10
- package/lib/mjs/erp/OrgApi.js +1 -1
- package/lib/mjs/erp/PublicApi.d.ts +3 -2
- package/lib/mjs/erp/PublicApi.js +19 -10
- package/package.json +6 -6
- package/src/erp/OrgApi.ts +1 -1
- package/src/erp/PublicApi.ts +27 -18
package/__tests__/app/CoreApp.ts
CHANGED
|
@@ -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 =
|
|
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);
|
package/lib/cjs/erp/OrgApi.js
CHANGED
|
@@ -20,7 +20,7 @@ class OrgApi extends EntityApi_1.EntityApi {
|
|
|
20
20
|
return this.listBase(items, serviceId);
|
|
21
21
|
}
|
|
22
22
|
else {
|
|
23
|
-
if (typeof serviceId
|
|
23
|
+
if (typeof serviceId === 'object')
|
|
24
24
|
return undefined;
|
|
25
25
|
return this.listBase({ items, serviceId }, { defaultValue: [], showLoading: false });
|
|
26
26
|
}
|
|
@@ -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
|
|
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
|
package/lib/cjs/erp/PublicApi.js
CHANGED
|
@@ -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
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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
|
package/lib/mjs/erp/OrgApi.js
CHANGED
|
@@ -17,7 +17,7 @@ export class OrgApi extends EntityApi {
|
|
|
17
17
|
return this.listBase(items, serviceId);
|
|
18
18
|
}
|
|
19
19
|
else {
|
|
20
|
-
if (typeof serviceId
|
|
20
|
+
if (typeof serviceId === 'object')
|
|
21
21
|
return undefined;
|
|
22
22
|
return this.listBase({ items, serviceId }, { defaultValue: [], showLoading: false });
|
|
23
23
|
}
|
|
@@ -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
|
|
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
|
package/lib/mjs/erp/PublicApi.js
CHANGED
|
@@ -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
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@etsoo/appscript",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.20",
|
|
4
4
|
"description": "Applications shared TypeScript framework",
|
|
5
5
|
"main": "lib/cjs/index.js",
|
|
6
6
|
"module": "lib/mjs/index.js",
|
|
@@ -54,20 +54,20 @@
|
|
|
54
54
|
"dependencies": {
|
|
55
55
|
"@etsoo/notificationbase": "^1.1.13",
|
|
56
56
|
"@etsoo/restclient": "^1.0.75",
|
|
57
|
-
"@etsoo/shared": "^1.1.
|
|
57
|
+
"@etsoo/shared": "^1.1.66",
|
|
58
58
|
"@types/crypto-js": "^4.1.1",
|
|
59
59
|
"crypto-js": "^4.1.1"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
62
|
"@babel/cli": "^7.19.3",
|
|
63
|
-
"@babel/core": "^7.19.
|
|
64
|
-
"@babel/plugin-transform-runtime": "^7.19.
|
|
63
|
+
"@babel/core": "^7.19.6",
|
|
64
|
+
"@babel/plugin-transform-runtime": "^7.19.6",
|
|
65
65
|
"@babel/preset-env": "^7.19.4",
|
|
66
|
-
"@babel/runtime-corejs3": "^7.19.
|
|
66
|
+
"@babel/runtime-corejs3": "^7.19.6",
|
|
67
67
|
"@types/jest": "^29.2.0",
|
|
68
68
|
"@typescript-eslint/eslint-plugin": "^5.40.1",
|
|
69
69
|
"@typescript-eslint/parser": "^5.40.1",
|
|
70
|
-
"eslint": "^8.
|
|
70
|
+
"eslint": "^8.26.0",
|
|
71
71
|
"eslint-config-airbnb-base": "^15.0.0",
|
|
72
72
|
"eslint-plugin-import": "^2.26.0",
|
|
73
73
|
"jest": "^29.2.1",
|
package/src/erp/OrgApi.ts
CHANGED
|
@@ -40,7 +40,7 @@ export class OrgApi extends EntityApi {
|
|
|
40
40
|
if (typeof serviceId === 'number') return undefined;
|
|
41
41
|
return this.listBase(items, serviceId);
|
|
42
42
|
} else {
|
|
43
|
-
if (typeof serviceId
|
|
43
|
+
if (typeof serviceId === 'object') return undefined;
|
|
44
44
|
return this.listBase<OrgListRQ, ListType>(
|
|
45
45
|
{ items, serviceId },
|
|
46
46
|
{ defaultValue: [], showLoading: false }
|
package/src/erp/PublicApi.ts
CHANGED
|
@@ -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
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
if (
|
|
25
|
-
return (
|
|
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
|
-
}))
|
|
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<
|
|
120
|
-
|
|
121
|
-
|
|
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
|
-
)
|
|
137
|
+
);
|
|
129
138
|
}
|
|
130
139
|
|
|
131
140
|
/**
|