@etsoo/appscript 1.3.1 → 1.3.3
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/README.md +0 -1
- package/__tests__/app/CoreApp.ts +54 -16
- package/lib/cjs/address/AddressContinent.d.ts +5 -1
- package/lib/cjs/address/AddressContinent.js +1 -1
- package/lib/cjs/address/AddressRegion.d.ts +31 -15
- package/lib/cjs/address/AddressRegion.js +3 -2
- package/lib/cjs/address/AddressState.d.ts +17 -0
- package/lib/cjs/address/AddressState.js +2 -0
- package/lib/cjs/address/AddressUtils.d.ts +1 -17
- package/lib/cjs/address/AddressUtils.js +4 -35
- package/lib/cjs/app/CoreApp.d.ts +7 -21
- package/lib/cjs/app/CoreApp.js +16 -46
- package/lib/cjs/app/ExternalSettings.d.ts +1 -0
- package/lib/cjs/app/ExternalSettings.js +16 -10
- package/lib/cjs/app/IApp.d.ts +7 -21
- package/lib/cjs/business/BusinessUtils.d.ts +1 -43
- package/lib/cjs/business/BusinessUtils.js +0 -72
- package/lib/cjs/business/Currency.d.ts +8 -0
- package/lib/cjs/business/Currency.js +18 -0
- package/lib/cjs/erp/AddressApi.d.ts +44 -0
- package/lib/cjs/erp/AddressApi.js +105 -0
- package/lib/cjs/erp/OrgApi.d.ts +26 -0
- package/lib/cjs/erp/OrgApi.js +43 -0
- package/lib/cjs/erp/PublicApi.d.ts +81 -0
- package/lib/cjs/erp/PublicApi.js +124 -0
- package/lib/cjs/erp/dto/CurrencyDto.d.ts +6 -0
- package/lib/cjs/erp/dto/CurrencyDto.js +2 -0
- package/lib/cjs/erp/dto/ExchangeRateDto.d.ts +13 -0
- package/lib/cjs/erp/dto/ExchangeRateDto.js +2 -0
- package/lib/cjs/erp/dto/ExchangeRateHistoryDto.d.ts +8 -0
- package/lib/cjs/erp/dto/ExchangeRateHistoryDto.js +2 -0
- package/lib/cjs/erp/dto/PublicProductDto.d.ts +35 -0
- package/lib/cjs/erp/dto/PublicProductDto.js +2 -0
- package/lib/cjs/i18n/en-US.json +1 -0
- package/lib/cjs/i18n/zh-CN.json +1 -0
- package/lib/cjs/i18n/zh-HK.json +1 -0
- package/lib/cjs/index.d.ts +5 -0
- package/lib/cjs/index.js +6 -0
- package/lib/mjs/address/AddressContinent.d.ts +5 -1
- package/lib/mjs/address/AddressContinent.js +1 -1
- package/lib/mjs/address/AddressRegion.d.ts +31 -15
- package/lib/mjs/address/AddressRegion.js +3 -2
- package/lib/mjs/address/AddressState.d.ts +17 -0
- package/lib/mjs/address/AddressState.js +1 -0
- package/lib/mjs/address/AddressUtils.d.ts +1 -17
- package/lib/mjs/address/AddressUtils.js +1 -32
- package/lib/mjs/app/CoreApp.d.ts +7 -21
- package/lib/mjs/app/CoreApp.js +16 -46
- package/lib/mjs/app/ExternalSettings.d.ts +1 -0
- package/lib/mjs/app/ExternalSettings.js +16 -10
- package/lib/mjs/app/IApp.d.ts +7 -21
- package/lib/mjs/business/BusinessUtils.d.ts +1 -43
- package/lib/mjs/business/BusinessUtils.js +0 -72
- package/lib/mjs/business/Currency.d.ts +8 -0
- package/lib/mjs/business/Currency.js +15 -0
- package/lib/mjs/erp/AddressApi.d.ts +44 -0
- package/lib/mjs/erp/AddressApi.js +78 -0
- package/lib/mjs/erp/OrgApi.d.ts +26 -0
- package/lib/mjs/erp/OrgApi.js +39 -0
- package/lib/mjs/erp/PublicApi.d.ts +81 -0
- package/lib/mjs/erp/PublicApi.js +120 -0
- package/lib/mjs/erp/dto/CurrencyDto.d.ts +6 -0
- package/lib/mjs/erp/dto/CurrencyDto.js +1 -0
- package/lib/mjs/erp/dto/ExchangeRateDto.d.ts +13 -0
- package/lib/mjs/erp/dto/ExchangeRateDto.js +1 -0
- package/lib/mjs/erp/dto/ExchangeRateHistoryDto.d.ts +8 -0
- package/lib/mjs/erp/dto/ExchangeRateHistoryDto.js +1 -0
- package/lib/mjs/erp/dto/PublicProductDto.d.ts +35 -0
- package/lib/mjs/erp/dto/PublicProductDto.js +1 -0
- package/lib/mjs/i18n/en-US.json +1 -0
- package/lib/mjs/i18n/zh-CN.json +1 -0
- package/lib/mjs/i18n/zh-HK.json +1 -0
- package/lib/mjs/index.d.ts +5 -0
- package/lib/mjs/index.js +6 -0
- package/package.json +8 -8
- package/src/address/AddressContinent.ts +6 -1
- package/src/address/AddressRegion.ts +36 -16
- package/src/address/AddressState.ts +19 -0
- package/src/address/AddressUtils.ts +1 -35
- package/src/app/CoreApp.ts +21 -56
- package/src/app/ExternalSettings.ts +17 -13
- package/src/app/IApp.ts +8 -26
- package/src/business/BusinessUtils.ts +1 -105
- package/src/business/Currency.ts +20 -0
- package/src/erp/AddressApi.ts +103 -0
- package/src/erp/OrgApi.ts +45 -0
- package/src/erp/PublicApi.ts +162 -0
- package/src/erp/dto/CurrencyDto.ts +7 -0
- package/src/erp/dto/ExchangeRateDto.ts +14 -0
- package/src/erp/dto/ExchangeRateHistoryDto.ts +9 -0
- package/src/erp/dto/PublicProductDto.ts +41 -0
- package/src/i18n/address.en-US.json +21 -0
- package/src/i18n/address.zh-CN.json +21 -0
- package/src/i18n/address.zh-HK.json +21 -0
- package/src/i18n/en-US.json +1 -0
- package/src/i18n/zh-CN.json +1 -0
- package/src/i18n/zh-HK.json +1 -0
- package/src/index.ts +7 -0
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import { DataTypes, ListType
|
|
2
|
-
import { ICultureGet } from '../state/Culture';
|
|
3
|
-
import { ProductUnit } from './ProductUnit';
|
|
1
|
+
import { DataTypes, ListType } from '@etsoo/shared';
|
|
4
2
|
/**
|
|
5
3
|
* Business utils
|
|
6
4
|
*/
|
|
@@ -13,13 +11,6 @@ export declare namespace BusinessUtils {
|
|
|
13
11
|
* @returns Result
|
|
14
12
|
*/
|
|
15
13
|
function formatAvatarTitle(title?: string, maxChars?: number, defaultTitle?: string): string;
|
|
16
|
-
/**
|
|
17
|
-
* Get currency collection
|
|
18
|
-
* @param currencyNames Names like CNY, USD
|
|
19
|
-
* @param func Label delegate
|
|
20
|
-
* @returns Collection
|
|
21
|
-
*/
|
|
22
|
-
function getCurrencies(currencyNames: string[], func: ICultureGet): ListType1[];
|
|
23
14
|
/**
|
|
24
15
|
* Get 12-month items
|
|
25
16
|
* @param monthLabels Month labels
|
|
@@ -27,39 +18,6 @@ export declare namespace BusinessUtils {
|
|
|
27
18
|
* @returns 12 months
|
|
28
19
|
*/
|
|
29
20
|
function getMonths(monthLabels: string[], startMonth?: number): ListType[];
|
|
30
|
-
/**
|
|
31
|
-
* Get product unit's label
|
|
32
|
-
* Please define the label in culture with key 'unitPC' for ProductUnit.PC like that
|
|
33
|
-
* @param unit Unit
|
|
34
|
-
* @param func Label delegate
|
|
35
|
-
* @param isJoined Add the join label like 'per Kg' for Kg
|
|
36
|
-
* @returns Label
|
|
37
|
-
*/
|
|
38
|
-
function getUnitLabel(unit: ProductUnit, func: ICultureGet, isJoined?: boolean): string;
|
|
39
|
-
/**
|
|
40
|
-
* Get all product units
|
|
41
|
-
* @param func Label delegate
|
|
42
|
-
* @returns Units
|
|
43
|
-
*/
|
|
44
|
-
function getUnits(func: ICultureGet): ListType[];
|
|
45
|
-
/**
|
|
46
|
-
*
|
|
47
|
-
* Get all product units
|
|
48
|
-
* @param func Label delegate
|
|
49
|
-
* @param options Define the order and limit the items
|
|
50
|
-
* @param isJoined Add the join label like 'per Kg' for Kg
|
|
51
|
-
* @returns Units
|
|
52
|
-
*/
|
|
53
|
-
function getUnits(func: ICultureGet, options?: string[], isJoined?: boolean): ListType[];
|
|
54
|
-
/**
|
|
55
|
-
*
|
|
56
|
-
* Get all repeat options
|
|
57
|
-
* @param func Label delegate
|
|
58
|
-
* @param options Define the order and limit the items
|
|
59
|
-
* @param isJoined Add the join label like 'per Kg' for Kg
|
|
60
|
-
* @returns Units
|
|
61
|
-
*/
|
|
62
|
-
function getRepeatOptions(func: ICultureGet, options?: string[], isJoined?: boolean): ListType[];
|
|
63
21
|
/**
|
|
64
22
|
* Set id value
|
|
65
23
|
* @param item QueryRQ or TiplistRQ or similiar item
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.BusinessUtils = void 0;
|
|
4
|
-
const shared_1 = require("@etsoo/shared");
|
|
5
|
-
const ProductUnit_1 = require("./ProductUnit");
|
|
6
|
-
const RepeatOption_1 = require("./RepeatOption");
|
|
7
4
|
/**
|
|
8
5
|
* Business utils
|
|
9
6
|
*/
|
|
@@ -41,22 +38,6 @@ var BusinessUtils;
|
|
|
41
38
|
return defaultTitle;
|
|
42
39
|
}
|
|
43
40
|
BusinessUtils.formatAvatarTitle = formatAvatarTitle;
|
|
44
|
-
/**
|
|
45
|
-
* Get currency collection
|
|
46
|
-
* @param currencyNames Names like CNY, USD
|
|
47
|
-
* @param func Label delegate
|
|
48
|
-
* @returns Collection
|
|
49
|
-
*/
|
|
50
|
-
function getCurrencies(currencyNames, func) {
|
|
51
|
-
return currencyNames.map((name) => {
|
|
52
|
-
var _a;
|
|
53
|
-
return ({
|
|
54
|
-
id: name,
|
|
55
|
-
label: (_a = func(`currency${name}`)) !== null && _a !== void 0 ? _a : name
|
|
56
|
-
});
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
BusinessUtils.getCurrencies = getCurrencies;
|
|
60
41
|
/**
|
|
61
42
|
* Get 12-month items
|
|
62
43
|
* @param monthLabels Month labels
|
|
@@ -74,59 +55,6 @@ var BusinessUtils;
|
|
|
74
55
|
return months;
|
|
75
56
|
}
|
|
76
57
|
BusinessUtils.getMonths = getMonths;
|
|
77
|
-
/**
|
|
78
|
-
* Get product unit's label
|
|
79
|
-
* Please define the label in culture with key 'unitPC' for ProductUnit.PC like that
|
|
80
|
-
* @param unit Unit
|
|
81
|
-
* @param func Label delegate
|
|
82
|
-
* @param isJoined Add the join label like 'per Kg' for Kg
|
|
83
|
-
* @returns Label
|
|
84
|
-
*/
|
|
85
|
-
function getUnitLabel(unit, func, isJoined) {
|
|
86
|
-
var _a;
|
|
87
|
-
const key = ProductUnit_1.ProductUnit[unit];
|
|
88
|
-
const label = (_a = func('unit' + key)) !== null && _a !== void 0 ? _a : key;
|
|
89
|
-
if (isJoined) {
|
|
90
|
-
const jLabel = func('unitJoin');
|
|
91
|
-
if (jLabel)
|
|
92
|
-
return jLabel.format(label);
|
|
93
|
-
}
|
|
94
|
-
return label;
|
|
95
|
-
}
|
|
96
|
-
BusinessUtils.getUnitLabel = getUnitLabel;
|
|
97
|
-
/**
|
|
98
|
-
*
|
|
99
|
-
* Get all product units
|
|
100
|
-
* @param func Label delegate
|
|
101
|
-
* @param options Define the order and limit the items
|
|
102
|
-
* @param isJoined Add the join label like 'per Kg' for Kg
|
|
103
|
-
* @returns Units
|
|
104
|
-
*/
|
|
105
|
-
function getUnits(func, options, isJoined) {
|
|
106
|
-
options !== null && options !== void 0 ? options : (options = shared_1.DataTypes.getEnumKeys(ProductUnit_1.ProductUnit));
|
|
107
|
-
return options.map((key) => {
|
|
108
|
-
const id = shared_1.DataTypes.getEnumByKey(ProductUnit_1.ProductUnit, key);
|
|
109
|
-
return {
|
|
110
|
-
id,
|
|
111
|
-
label: getUnitLabel(id, func, isJoined).formatInitial(true)
|
|
112
|
-
};
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
BusinessUtils.getUnits = getUnits;
|
|
116
|
-
/**
|
|
117
|
-
*
|
|
118
|
-
* Get all repeat options
|
|
119
|
-
* @param func Label delegate
|
|
120
|
-
* @param options Define the order and limit the items
|
|
121
|
-
* @param isJoined Add the join label like 'per Kg' for Kg
|
|
122
|
-
* @returns Units
|
|
123
|
-
*/
|
|
124
|
-
function getRepeatOptions(func, options, isJoined = true) {
|
|
125
|
-
options !== null && options !== void 0 ? options : (options = shared_1.DataTypes.getEnumKeys(RepeatOption_1.RepeatOption));
|
|
126
|
-
isJoined !== null && isJoined !== void 0 ? isJoined : (isJoined = true);
|
|
127
|
-
return getUnits(func, options, isJoined);
|
|
128
|
-
}
|
|
129
|
-
BusinessUtils.getRepeatOptions = getRepeatOptions;
|
|
130
58
|
/**
|
|
131
59
|
* Set id value
|
|
132
60
|
* @param item QueryRQ or TiplistRQ or similiar item
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Currencies = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Currency array
|
|
6
|
+
*/
|
|
7
|
+
exports.Currencies = [
|
|
8
|
+
'AUD',
|
|
9
|
+
'CAD',
|
|
10
|
+
'CNY',
|
|
11
|
+
'EUR',
|
|
12
|
+
'GBP',
|
|
13
|
+
'HKD',
|
|
14
|
+
'JPY',
|
|
15
|
+
'NZD',
|
|
16
|
+
'SGD',
|
|
17
|
+
'USD'
|
|
18
|
+
];
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { DataTypes } from '@etsoo/shared';
|
|
2
|
+
import { AddressRegion, AddressRegionDb } from '../address/AddressRegion';
|
|
3
|
+
import { AddressState } from '../address/AddressState';
|
|
4
|
+
import { IApp } from '../app/IApp';
|
|
5
|
+
import { IdLabelConditional } from '../dto/IdLabelDto';
|
|
6
|
+
/**
|
|
7
|
+
* Address Api
|
|
8
|
+
*/
|
|
9
|
+
export declare class AddressApi {
|
|
10
|
+
private app;
|
|
11
|
+
private languageLabels;
|
|
12
|
+
/**
|
|
13
|
+
* Constructor
|
|
14
|
+
* @param app Application
|
|
15
|
+
*/
|
|
16
|
+
constructor(app: IApp);
|
|
17
|
+
/**
|
|
18
|
+
* Get address labels
|
|
19
|
+
* @param language Language
|
|
20
|
+
* @returns Result
|
|
21
|
+
*/
|
|
22
|
+
getLabels(language?: string): Promise<DataTypes.StringRecord>;
|
|
23
|
+
/**
|
|
24
|
+
* Get all continents
|
|
25
|
+
* @param language Language
|
|
26
|
+
* @param isNumberKey Is number key or key as id
|
|
27
|
+
* @returns Continents
|
|
28
|
+
*/
|
|
29
|
+
continents<T extends boolean>(language?: string, isNumberKey?: T): Promise<IdLabelConditional<T>>;
|
|
30
|
+
/**
|
|
31
|
+
* Get region list from database
|
|
32
|
+
* @param language Language
|
|
33
|
+
* @param isLocal Is local version
|
|
34
|
+
* @returns Result
|
|
35
|
+
*/
|
|
36
|
+
regions<T extends boolean = true>(language?: string, isLocal?: T): Promise<T extends true | undefined ? AddressRegion[] : AddressRegionDb[] | undefined>;
|
|
37
|
+
/**
|
|
38
|
+
* Get state list from database
|
|
39
|
+
* @param regionId Region id
|
|
40
|
+
* @param language Language
|
|
41
|
+
* @returns Result
|
|
42
|
+
*/
|
|
43
|
+
states(regionId: string, language?: string): Promise<AddressState[] | undefined>;
|
|
44
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.AddressApi = void 0;
|
|
27
|
+
const shared_1 = require("@etsoo/shared");
|
|
28
|
+
const AddressContinent_1 = require("../address/AddressContinent");
|
|
29
|
+
const AddressRegion_1 = require("../address/AddressRegion");
|
|
30
|
+
/**
|
|
31
|
+
* Address Api
|
|
32
|
+
*/
|
|
33
|
+
class AddressApi {
|
|
34
|
+
/**
|
|
35
|
+
* Constructor
|
|
36
|
+
* @param app Application
|
|
37
|
+
*/
|
|
38
|
+
constructor(app) {
|
|
39
|
+
this.app = app;
|
|
40
|
+
this.languageLabels = {};
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Get address labels
|
|
44
|
+
* @param language Language
|
|
45
|
+
* @returns Result
|
|
46
|
+
*/
|
|
47
|
+
async getLabels(language) {
|
|
48
|
+
const l = this.app.checkLanguage(language);
|
|
49
|
+
let labels = this.languageLabels[l];
|
|
50
|
+
if (labels == null) {
|
|
51
|
+
labels = await Promise.resolve().then(() => __importStar(require(`./../i18n/address.${l}.json`)));
|
|
52
|
+
// Cache
|
|
53
|
+
this.languageLabels[l] = labels;
|
|
54
|
+
}
|
|
55
|
+
return labels;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Get all continents
|
|
59
|
+
* @param language Language
|
|
60
|
+
* @param isNumberKey Is number key or key as id
|
|
61
|
+
* @returns Continents
|
|
62
|
+
*/
|
|
63
|
+
async continents(language, isNumberKey = false) {
|
|
64
|
+
const labels = await this.getLabels(language);
|
|
65
|
+
return shared_1.DataTypes.getEnumKeys(AddressContinent_1.AddressContinent).map((key) => {
|
|
66
|
+
var _a;
|
|
67
|
+
return ({
|
|
68
|
+
id: isNumberKey
|
|
69
|
+
? shared_1.DataTypes.getEnumByKey(AddressContinent_1.AddressContinent, key)
|
|
70
|
+
: key.toString(),
|
|
71
|
+
label: (_a = labels['continent' + key]) !== null && _a !== void 0 ? _a : key
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Get region list from database
|
|
77
|
+
* @param language Language
|
|
78
|
+
* @param isLocal Is local version
|
|
79
|
+
* @returns Result
|
|
80
|
+
*/
|
|
81
|
+
async regions(language, isLocal) {
|
|
82
|
+
language = this.app.checkLanguage(language);
|
|
83
|
+
if (isLocal == null || isLocal) {
|
|
84
|
+
const labels = await this.getLabels(language);
|
|
85
|
+
return AddressRegion_1.AddressRegion.all.map((region) => {
|
|
86
|
+
region.label = labels['region' + region.id];
|
|
87
|
+
return { ...region };
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
return (await this.app.api.get(`Address/RegionList?language=${language}`, undefined, { defaultValue: [] }));
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Get state list from database
|
|
96
|
+
* @param regionId Region id
|
|
97
|
+
* @param language Language
|
|
98
|
+
* @returns Result
|
|
99
|
+
*/
|
|
100
|
+
states(regionId, language) {
|
|
101
|
+
language = this.app.checkLanguage(language);
|
|
102
|
+
return this.app.api.get(`Address/StateList?regionId=${regionId}&language=${language}`, undefined, { defaultValue: [] });
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
exports.AddressApi = AddressApi;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ListType } from '@etsoo/shared';
|
|
2
|
+
import { IApp } from '../app/IApp';
|
|
3
|
+
/**
|
|
4
|
+
* Organization API
|
|
5
|
+
*/
|
|
6
|
+
export declare class OrgApi {
|
|
7
|
+
private app;
|
|
8
|
+
/**
|
|
9
|
+
* Constructor
|
|
10
|
+
* @param app Application
|
|
11
|
+
*/
|
|
12
|
+
constructor(app: IApp);
|
|
13
|
+
/**
|
|
14
|
+
* Get organization list
|
|
15
|
+
* @param items Max items
|
|
16
|
+
* @param serviceId Service id
|
|
17
|
+
* @returns Result
|
|
18
|
+
*/
|
|
19
|
+
list(items?: number, serviceId?: number): Promise<ListType[] | undefined>;
|
|
20
|
+
/**
|
|
21
|
+
* Switch organization
|
|
22
|
+
* @param id Organization id
|
|
23
|
+
* @param serviceId Service id
|
|
24
|
+
*/
|
|
25
|
+
switch(id: number, serviceId?: number): Promise<boolean | undefined>;
|
|
26
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OrgApi = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Organization API
|
|
6
|
+
*/
|
|
7
|
+
class OrgApi {
|
|
8
|
+
/**
|
|
9
|
+
* Constructor
|
|
10
|
+
* @param app Application
|
|
11
|
+
*/
|
|
12
|
+
constructor(app) {
|
|
13
|
+
this.app = app;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Get organization list
|
|
17
|
+
* @param items Max items
|
|
18
|
+
* @param serviceId Service id
|
|
19
|
+
* @returns Result
|
|
20
|
+
*/
|
|
21
|
+
list(items, serviceId) {
|
|
22
|
+
return this.app.api.post('Organization/List', {
|
|
23
|
+
items,
|
|
24
|
+
serviceId
|
|
25
|
+
}, { defaultValue: [], showLoading: false });
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Switch organization
|
|
29
|
+
* @param id Organization id
|
|
30
|
+
* @param serviceId Service id
|
|
31
|
+
*/
|
|
32
|
+
async switch(id, serviceId) {
|
|
33
|
+
const result = await this.app.api.put('Organization/Switch', {
|
|
34
|
+
id,
|
|
35
|
+
serviceId,
|
|
36
|
+
deviceId: this.app.deviceId
|
|
37
|
+
});
|
|
38
|
+
if (result)
|
|
39
|
+
return await this.app.refreshToken();
|
|
40
|
+
return result;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
exports.OrgApi = OrgApi;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { ListType, ListType1 } from '@etsoo/shared';
|
|
2
|
+
import { IApp } from '../app/IApp';
|
|
3
|
+
import { Currency } from '../business/Currency';
|
|
4
|
+
import { ProductUnit } from '../business/ProductUnit';
|
|
5
|
+
import { CurrencyDto } from './dto/CurrencyDto';
|
|
6
|
+
import { ExchangeRateDto } from './dto/ExchangeRateDto';
|
|
7
|
+
import { ExchangeRateHistoryDto } from './dto/ExchangeRateHistoryDto';
|
|
8
|
+
import { PublicOrgProductDto, PublicProductDto } from './dto/PublicProductDto';
|
|
9
|
+
/**
|
|
10
|
+
* Public API
|
|
11
|
+
*/
|
|
12
|
+
export declare class PublicApi {
|
|
13
|
+
private app;
|
|
14
|
+
/**
|
|
15
|
+
* Constructor
|
|
16
|
+
* @param app Application
|
|
17
|
+
*/
|
|
18
|
+
constructor(app: IApp);
|
|
19
|
+
/**
|
|
20
|
+
* Get currencies
|
|
21
|
+
* @param currencyNames Limited currency names for local data, undefined will try to retrive remoately
|
|
22
|
+
* @returns Result
|
|
23
|
+
*/
|
|
24
|
+
currencies<T extends string[] | Currency[] | undefined>(currencyNames?: T): Promise<T extends undefined ? CurrencyDto[] | undefined : ListType1[]>;
|
|
25
|
+
/**
|
|
26
|
+
* Get exchange rate
|
|
27
|
+
* @param currency Currency
|
|
28
|
+
* @returns Result
|
|
29
|
+
*/
|
|
30
|
+
exchangeRate(currency: Currency): Promise<ExchangeRateDto | undefined>;
|
|
31
|
+
/**
|
|
32
|
+
* Get exchange rate history
|
|
33
|
+
* @param currencies Currencies
|
|
34
|
+
* @param months Max months
|
|
35
|
+
* @returns Result
|
|
36
|
+
*/
|
|
37
|
+
exchangeRateHistory(currencies: Currency[], months?: number): Promise<ExchangeRateHistoryDto[] | undefined>;
|
|
38
|
+
/**
|
|
39
|
+
* Get product unit's label
|
|
40
|
+
* Please define the label in culture with key 'unitPC' for ProductUnit.PC like that
|
|
41
|
+
* @param unit Unit
|
|
42
|
+
* @param isJoined Add the join label like 'per Kg' for Kg
|
|
43
|
+
* @returns Label
|
|
44
|
+
*/
|
|
45
|
+
getUnitLabel(unit: ProductUnit, isJoined?: boolean | string): string;
|
|
46
|
+
private getUnitJoin;
|
|
47
|
+
/**
|
|
48
|
+
* Get mobile base64 QRCode
|
|
49
|
+
* @param id User id
|
|
50
|
+
* @param host Host URL
|
|
51
|
+
*/
|
|
52
|
+
mobileQRCode(id?: string, host?: string): Promise<string | undefined>;
|
|
53
|
+
/**
|
|
54
|
+
* Get public and valid product data
|
|
55
|
+
* @param id Product/Service Id or Uid
|
|
56
|
+
* @param culture Language
|
|
57
|
+
* @returns Result
|
|
58
|
+
*/
|
|
59
|
+
product<T extends number | string>(id: T, culture?: string): T extends number ? PublicProductDto : PublicOrgProductDto;
|
|
60
|
+
/**
|
|
61
|
+
*
|
|
62
|
+
* Get all repeat options
|
|
63
|
+
* @param options Define the order and limit the items
|
|
64
|
+
* @param isJoined Add the join label like 'per Kg' for Kg
|
|
65
|
+
* @returns Units
|
|
66
|
+
*/
|
|
67
|
+
repeatOptions(options?: string[], isJoined?: boolean): ListType[];
|
|
68
|
+
/**
|
|
69
|
+
* Get all product units
|
|
70
|
+
* @returns Units
|
|
71
|
+
*/
|
|
72
|
+
units(): ListType[];
|
|
73
|
+
/**
|
|
74
|
+
*
|
|
75
|
+
* Get all product units
|
|
76
|
+
* @param options Define the order and limit the items
|
|
77
|
+
* @param isJoined Add the join label like 'per Kg' for Kg
|
|
78
|
+
* @returns Units
|
|
79
|
+
*/
|
|
80
|
+
units(options?: string[], isJoined?: boolean): ListType[];
|
|
81
|
+
}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PublicApi = void 0;
|
|
4
|
+
const shared_1 = require("@etsoo/shared");
|
|
5
|
+
const ProductUnit_1 = require("../business/ProductUnit");
|
|
6
|
+
const RepeatOption_1 = require("../business/RepeatOption");
|
|
7
|
+
/**
|
|
8
|
+
* Public API
|
|
9
|
+
*/
|
|
10
|
+
class PublicApi {
|
|
11
|
+
/**
|
|
12
|
+
* Constructor
|
|
13
|
+
* @param app Application
|
|
14
|
+
*/
|
|
15
|
+
constructor(app) {
|
|
16
|
+
this.app = app;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Get currencies
|
|
20
|
+
* @param currencyNames Limited currency names for local data, undefined will try to retrive remoately
|
|
21
|
+
* @returns Result
|
|
22
|
+
*/
|
|
23
|
+
async currencies(currencyNames) {
|
|
24
|
+
if (currencyNames == null)
|
|
25
|
+
return (await this.app.api.get('Public/GetCurrencies'));
|
|
26
|
+
else
|
|
27
|
+
return currencyNames.map((name) => {
|
|
28
|
+
var _a;
|
|
29
|
+
return ({
|
|
30
|
+
id: name,
|
|
31
|
+
label: (_a = this.app.get(`currency${name}`)) !== null && _a !== void 0 ? _a : name
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Get exchange rate
|
|
37
|
+
* @param currency Currency
|
|
38
|
+
* @returns Result
|
|
39
|
+
*/
|
|
40
|
+
exchangeRate(currency) {
|
|
41
|
+
return this.app.api.get(`Public/ExchangeRate/${currency}`);
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Get exchange rate history
|
|
45
|
+
* @param currencies Currencies
|
|
46
|
+
* @param months Max months
|
|
47
|
+
* @returns Result
|
|
48
|
+
*/
|
|
49
|
+
exchangeRateHistory(currencies, months) {
|
|
50
|
+
return this.app.api.post('Public/ExchangeRateHistory', { currencies, months }, { defaultValue: [] });
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Get product unit's label
|
|
54
|
+
* Please define the label in culture with key 'unitPC' for ProductUnit.PC like that
|
|
55
|
+
* @param unit Unit
|
|
56
|
+
* @param isJoined Add the join label like 'per Kg' for Kg
|
|
57
|
+
* @returns Label
|
|
58
|
+
*/
|
|
59
|
+
getUnitLabel(unit, isJoined) {
|
|
60
|
+
var _a;
|
|
61
|
+
const key = ProductUnit_1.ProductUnit[unit];
|
|
62
|
+
const label = (_a = this.app.get('unit' + key)) !== null && _a !== void 0 ? _a : key;
|
|
63
|
+
const join = this.getUnitJoin(isJoined);
|
|
64
|
+
if (join) {
|
|
65
|
+
return join.format(label);
|
|
66
|
+
}
|
|
67
|
+
return label;
|
|
68
|
+
}
|
|
69
|
+
getUnitJoin(isJoined) {
|
|
70
|
+
var _a;
|
|
71
|
+
return typeof isJoined === 'string'
|
|
72
|
+
? (_a = this.app.get(isJoined)) !== null && _a !== void 0 ? _a : isJoined
|
|
73
|
+
: isJoined
|
|
74
|
+
? this.app.get('unitJoin')
|
|
75
|
+
: undefined;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Get mobile base64 QRCode
|
|
79
|
+
* @param id User id
|
|
80
|
+
* @param host Host URL
|
|
81
|
+
*/
|
|
82
|
+
mobileQRCode(id, host) {
|
|
83
|
+
return this.app.api.post('Public/MobileQRCode', { id, host });
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Get public and valid product data
|
|
87
|
+
* @param id Product/Service Id or Uid
|
|
88
|
+
* @param culture Language
|
|
89
|
+
* @returns Result
|
|
90
|
+
*/
|
|
91
|
+
product(id, culture) {
|
|
92
|
+
culture = this.app.checkLanguage(culture);
|
|
93
|
+
return this.app.api.post(`Public/Product/${id}/${culture}`);
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
*
|
|
97
|
+
* Get all repeat options
|
|
98
|
+
* @param options Define the order and limit the items
|
|
99
|
+
* @param isJoined Add the join label like 'per Kg' for Kg
|
|
100
|
+
* @returns Units
|
|
101
|
+
*/
|
|
102
|
+
repeatOptions(options, isJoined = true) {
|
|
103
|
+
options !== null && options !== void 0 ? options : (options = shared_1.DataTypes.getEnumKeys(RepeatOption_1.RepeatOption));
|
|
104
|
+
return this.units(options, isJoined);
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
*
|
|
108
|
+
* Get all product units
|
|
109
|
+
* @param options Define the order and limit the items
|
|
110
|
+
* @param isJoined Add the join label like 'per Kg' for Kg
|
|
111
|
+
* @returns Units
|
|
112
|
+
*/
|
|
113
|
+
units(options, isJoined) {
|
|
114
|
+
options !== null && options !== void 0 ? options : (options = shared_1.DataTypes.getEnumKeys(ProductUnit_1.ProductUnit));
|
|
115
|
+
return options.map((key) => {
|
|
116
|
+
const id = shared_1.DataTypes.getEnumByKey(ProductUnit_1.ProductUnit, key);
|
|
117
|
+
return {
|
|
118
|
+
id,
|
|
119
|
+
label: this.getUnitLabel(id, this.getUnitJoin(isJoined)).formatInitial(true)
|
|
120
|
+
};
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
exports.PublicApi = PublicApi;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { EntityStatus } from '../../business/EntityStatus';
|
|
2
|
+
/**
|
|
3
|
+
* Public product data
|
|
4
|
+
*/
|
|
5
|
+
export declare type PublicProductDto = {
|
|
6
|
+
/**
|
|
7
|
+
* Id
|
|
8
|
+
*/
|
|
9
|
+
id: number;
|
|
10
|
+
/**
|
|
11
|
+
* Name
|
|
12
|
+
*/
|
|
13
|
+
name: string;
|
|
14
|
+
/**
|
|
15
|
+
* Logo
|
|
16
|
+
*/
|
|
17
|
+
logo?: string;
|
|
18
|
+
/**
|
|
19
|
+
* Web URL for access
|
|
20
|
+
*/
|
|
21
|
+
webUrl: string;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Public product with organization data
|
|
25
|
+
*/
|
|
26
|
+
export declare type PublicOrgProductDto = PublicProductDto & {
|
|
27
|
+
/**
|
|
28
|
+
* Purchased service status
|
|
29
|
+
*/
|
|
30
|
+
serviceEntityStatus?: EntityStatus;
|
|
31
|
+
/**
|
|
32
|
+
* Purchased service expiry
|
|
33
|
+
*/
|
|
34
|
+
serviceExpiry?: string | Date;
|
|
35
|
+
};
|