@etsoo/appscript 1.2.78 → 1.2.81

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.
@@ -3,7 +3,6 @@ import { ApiDataError, IApi, IPData } from '@etsoo/restclient';
3
3
  import { DataTypes, DateUtils, IStorage } from '@etsoo/shared';
4
4
  import { AddressRegion } from '../address/AddressRegion';
5
5
  import { ProductUnit } from '../business/ProductUnit';
6
- import { IdLabelDto } from '../dto/IdLabelDto';
7
6
  import { InitCallDto } from '../dto/InitCallDto';
8
7
  import { IActionResult } from '../result/IActionResult';
9
8
  import { InitCallResult, InitCallResultData } from '../result/InitCallResult';
@@ -270,7 +269,7 @@ export interface ICoreApp<U extends IUser, S extends IAppSettings, N, C extends
270
269
  * Get roles
271
270
  * @param role Combination role value
272
271
  */
273
- getRoles(role: number): IdLabelDto[];
272
+ getRoles(role: number): DataTypes.IdLabelItem[];
274
273
  /**
275
274
  * Get status label
276
275
  * @param status Status value
@@ -280,7 +279,7 @@ export interface ICoreApp<U extends IUser, S extends IAppSettings, N, C extends
280
279
  * Get status list
281
280
  * @returns list
282
281
  */
283
- getStatusList(): IdLabelDto[];
282
+ getStatusList(): DataTypes.IdLabelItem[];
284
283
  /**
285
284
  * Get refresh token from response headers
286
285
  * @param rawResponse Raw response from API call
@@ -349,7 +348,7 @@ export interface ICoreApp<U extends IUser, S extends IAppSettings, N, C extends
349
348
  * @param serviceId Service id
350
349
  * @returns Result
351
350
  */
352
- orgList(items?: number, serviceId?: number): Promise<IdLabelDto[] | undefined>;
351
+ orgList(items?: number, serviceId?: number): Promise<DataTypes.IdLabelItem[] | undefined>;
353
352
  /**
354
353
  * Persist settings to source when application exit
355
354
  */
@@ -718,7 +717,7 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
718
717
  * @param filter Filter
719
718
  * @returns List
720
719
  */
721
- protected getEnumList<E extends DataTypes.EnumBase = DataTypes.EnumBase>(em: E, prefix: string, filter?: (id: E[keyof E], key: keyof E & string) => E[keyof E] | undefined): IdLabelDto[];
720
+ protected getEnumList<E extends DataTypes.EnumBase = DataTypes.EnumBase>(em: E, prefix: string, filter?: (id: E[keyof E], key: keyof E & string) => E[keyof E] | undefined): DataTypes.IdLabelItem[];
722
721
  /**
723
722
  * Get enum item string id list
724
723
  * @param em Enum
@@ -726,7 +725,7 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
726
725
  * @param filter Filter
727
726
  * @returns List
728
727
  */
729
- protected getEnumStrList<E extends DataTypes.EnumBase = DataTypes.EnumBase>(em: E, prefix: string, filter?: (id: E[keyof E], key: keyof E & string) => E[keyof E] | undefined): IdLabelDto<string>[];
728
+ protected getEnumStrList<E extends DataTypes.EnumBase = DataTypes.EnumBase>(em: E, prefix: string, filter?: (id: E[keyof E], key: keyof E & string) => E[keyof E] | undefined): DataTypes.IdLabelItem<string>[];
730
729
  /**
731
730
  * Get all regions
732
731
  * @returns Regions
@@ -736,12 +735,12 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
736
735
  * Get roles
737
736
  * @param role Combination role value
738
737
  */
739
- getRoles(role: number): IdLabelDto<number>[];
738
+ getRoles(role: number): DataTypes.IdLabelItem<number>[];
740
739
  /**
741
740
  * Get status list
742
741
  * @returns list
743
742
  */
744
- getStatusList(): IdLabelDto<number>[];
743
+ getStatusList(): DataTypes.IdLabelItem<number>[];
745
744
  /**
746
745
  * Get status label
747
746
  * @param status Status value
@@ -824,7 +823,7 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
824
823
  * @param serviceId Service id
825
824
  * @returns Result
826
825
  */
827
- orgList(items?: number, serviceId?: number): Promise<IdLabelDto<number>[] | undefined>;
826
+ orgList(items?: number, serviceId?: number): Promise<DataTypes.IdLabelItem<number>[] | undefined>;
828
827
  /**
829
828
  * Switch organization
830
829
  * @param id Organization id
@@ -1,5 +1,4 @@
1
1
  import { DataTypes } from '@etsoo/shared';
2
- import { IdLabelDto } from '../dto/IdLabelDto';
3
2
  import { ICultureGet } from '../state/Culture';
4
3
  import { ProductUnit } from './ProductUnit';
5
4
  /**
@@ -20,7 +19,7 @@ export declare namespace BusinessUtils {
20
19
  * @param func Label delegate
21
20
  * @returns Collection
22
21
  */
23
- function getCurrencies(currencyNames: string[], func: ICultureGet): IdLabelDto<string>[];
22
+ function getCurrencies(currencyNames: string[], func: ICultureGet): DataTypes.IdLabelItem<string>[];
24
23
  /**
25
24
  * Get 12-month items
26
25
  * @param monthLabels Month labels
@@ -42,7 +41,7 @@ export declare namespace BusinessUtils {
42
41
  * @param func Label delegate
43
42
  * @returns Units
44
43
  */
45
- function getUnits(func: ICultureGet): IdLabelDto[];
44
+ function getUnits(func: ICultureGet): DataTypes.IdLabelItem[];
46
45
  /**
47
46
  *
48
47
  * Get all product units
@@ -51,7 +50,7 @@ export declare namespace BusinessUtils {
51
50
  * @param isJoined Add the join label like 'per Kg' for Kg
52
51
  * @returns Units
53
52
  */
54
- function getUnits(func: ICultureGet, options?: string[], isJoined?: boolean): IdLabelDto[];
53
+ function getUnits(func: ICultureGet, options?: string[], isJoined?: boolean): DataTypes.IdLabelItem[];
55
54
  /**
56
55
  *
57
56
  * Get all repeat options
@@ -60,5 +59,14 @@ export declare namespace BusinessUtils {
60
59
  * @param isJoined Add the join label like 'per Kg' for Kg
61
60
  * @returns Units
62
61
  */
63
- function getRepeatOptions(func: ICultureGet, options?: string[], isJoined?: boolean): IdLabelDto[];
62
+ function getRepeatOptions(func: ICultureGet, options?: string[], isJoined?: boolean): DataTypes.IdLabelItem[];
63
+ /**
64
+ * Set id value
65
+ * @param item QueryRQ or TiplistRQ or similiar item
66
+ * @param id Id value
67
+ */
68
+ function setIdValue<T extends {
69
+ id?: number;
70
+ sid?: string;
71
+ }>(item: T, id?: DataTypes.IdType): void;
64
72
  }
@@ -127,4 +127,18 @@ var BusinessUtils;
127
127
  return getUnits(func, options, isJoined);
128
128
  }
129
129
  BusinessUtils.getRepeatOptions = getRepeatOptions;
130
+ /**
131
+ * Set id value
132
+ * @param item QueryRQ or TiplistRQ or similiar item
133
+ * @param id Id value
134
+ */
135
+ function setIdValue(item, id) {
136
+ if (id == null)
137
+ return;
138
+ if (typeof id === 'number')
139
+ item.id = id;
140
+ else
141
+ item.sid = id;
142
+ }
143
+ BusinessUtils.setIdValue = setIdValue;
130
144
  })(BusinessUtils = exports.BusinessUtils || (exports.BusinessUtils = {}));
@@ -1,14 +1,5 @@
1
1
  import { DataTypes } from '@etsoo/shared';
2
- /**
3
- * Dto with id and label field
4
- */
5
- export declare type IdLabelDto<T extends DataTypes.IdType = number> = DataTypes.IdItem<T> & {
6
- /**
7
- * Label
8
- */
9
- label: string;
10
- };
11
2
  /**
12
3
  * Conditional IdLabel type
13
4
  */
14
- export declare type IdLabelConditional<T extends boolean> = T extends true ? IdLabelDto<number>[] : IdLabelDto<string>[];
5
+ export declare type IdLabelConditional<T extends boolean> = T extends true ? DataTypes.IdLabelItem<number>[] : DataTypes.IdLabelItem<string>[];
@@ -1,9 +1,8 @@
1
1
  import { DataTypes } from '@etsoo/shared';
2
- import { IdLabelDto } from './IdLabelDto';
3
2
  /**
4
3
  * Dto with id, label and primary field
5
4
  */
6
- export declare type IdLabelPrimaryDto<T extends DataTypes.IdType = number> = IdLabelDto<T> & {
5
+ export declare type IdLabelPrimaryDto<T extends DataTypes.IdType = number> = DataTypes.IdLabelItem<T> & {
7
6
  /**
8
7
  * Is primary
9
8
  */
@@ -1,16 +1,21 @@
1
+ import { DataTypes } from '@etsoo/shared';
1
2
  /**
2
3
  * Tiplist request data
3
4
  * com.etsoo.CoreFramework.Models.TiplistRQ
4
5
  */
5
- export declare type TiplistRQ<T = number> = {
6
+ export declare type TiplistRQ = {
6
7
  /**
7
- * Current id
8
+ * number id
8
9
  */
9
- id: T;
10
+ id?: number;
11
+ /**
12
+ * String id
13
+ */
14
+ sid?: string;
10
15
  /**
11
16
  * Excluded ids
12
17
  */
13
- excludedIds?: T[];
18
+ excludedIds?: DataTypes.IdType[];
14
19
  /**
15
20
  * Filter keyword
16
21
  */
@@ -3,7 +3,6 @@ import { ApiDataError, IApi, IPData } from '@etsoo/restclient';
3
3
  import { DataTypes, DateUtils, IStorage } from '@etsoo/shared';
4
4
  import { AddressRegion } from '../address/AddressRegion';
5
5
  import { ProductUnit } from '../business/ProductUnit';
6
- import { IdLabelDto } from '../dto/IdLabelDto';
7
6
  import { InitCallDto } from '../dto/InitCallDto';
8
7
  import { IActionResult } from '../result/IActionResult';
9
8
  import { InitCallResult, InitCallResultData } from '../result/InitCallResult';
@@ -270,7 +269,7 @@ export interface ICoreApp<U extends IUser, S extends IAppSettings, N, C extends
270
269
  * Get roles
271
270
  * @param role Combination role value
272
271
  */
273
- getRoles(role: number): IdLabelDto[];
272
+ getRoles(role: number): DataTypes.IdLabelItem[];
274
273
  /**
275
274
  * Get status label
276
275
  * @param status Status value
@@ -280,7 +279,7 @@ export interface ICoreApp<U extends IUser, S extends IAppSettings, N, C extends
280
279
  * Get status list
281
280
  * @returns list
282
281
  */
283
- getStatusList(): IdLabelDto[];
282
+ getStatusList(): DataTypes.IdLabelItem[];
284
283
  /**
285
284
  * Get refresh token from response headers
286
285
  * @param rawResponse Raw response from API call
@@ -349,7 +348,7 @@ export interface ICoreApp<U extends IUser, S extends IAppSettings, N, C extends
349
348
  * @param serviceId Service id
350
349
  * @returns Result
351
350
  */
352
- orgList(items?: number, serviceId?: number): Promise<IdLabelDto[] | undefined>;
351
+ orgList(items?: number, serviceId?: number): Promise<DataTypes.IdLabelItem[] | undefined>;
353
352
  /**
354
353
  * Persist settings to source when application exit
355
354
  */
@@ -718,7 +717,7 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
718
717
  * @param filter Filter
719
718
  * @returns List
720
719
  */
721
- protected getEnumList<E extends DataTypes.EnumBase = DataTypes.EnumBase>(em: E, prefix: string, filter?: (id: E[keyof E], key: keyof E & string) => E[keyof E] | undefined): IdLabelDto[];
720
+ protected getEnumList<E extends DataTypes.EnumBase = DataTypes.EnumBase>(em: E, prefix: string, filter?: (id: E[keyof E], key: keyof E & string) => E[keyof E] | undefined): DataTypes.IdLabelItem[];
722
721
  /**
723
722
  * Get enum item string id list
724
723
  * @param em Enum
@@ -726,7 +725,7 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
726
725
  * @param filter Filter
727
726
  * @returns List
728
727
  */
729
- protected getEnumStrList<E extends DataTypes.EnumBase = DataTypes.EnumBase>(em: E, prefix: string, filter?: (id: E[keyof E], key: keyof E & string) => E[keyof E] | undefined): IdLabelDto<string>[];
728
+ protected getEnumStrList<E extends DataTypes.EnumBase = DataTypes.EnumBase>(em: E, prefix: string, filter?: (id: E[keyof E], key: keyof E & string) => E[keyof E] | undefined): DataTypes.IdLabelItem<string>[];
730
729
  /**
731
730
  * Get all regions
732
731
  * @returns Regions
@@ -736,12 +735,12 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
736
735
  * Get roles
737
736
  * @param role Combination role value
738
737
  */
739
- getRoles(role: number): IdLabelDto<number>[];
738
+ getRoles(role: number): DataTypes.IdLabelItem<number>[];
740
739
  /**
741
740
  * Get status list
742
741
  * @returns list
743
742
  */
744
- getStatusList(): IdLabelDto<number>[];
743
+ getStatusList(): DataTypes.IdLabelItem<number>[];
745
744
  /**
746
745
  * Get status label
747
746
  * @param status Status value
@@ -824,7 +823,7 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
824
823
  * @param serviceId Service id
825
824
  * @returns Result
826
825
  */
827
- orgList(items?: number, serviceId?: number): Promise<IdLabelDto<number>[] | undefined>;
826
+ orgList(items?: number, serviceId?: number): Promise<DataTypes.IdLabelItem<number>[] | undefined>;
828
827
  /**
829
828
  * Switch organization
830
829
  * @param id Organization id
@@ -1,5 +1,4 @@
1
1
  import { DataTypes } from '@etsoo/shared';
2
- import { IdLabelDto } from '../dto/IdLabelDto';
3
2
  import { ICultureGet } from '../state/Culture';
4
3
  import { ProductUnit } from './ProductUnit';
5
4
  /**
@@ -20,7 +19,7 @@ export declare namespace BusinessUtils {
20
19
  * @param func Label delegate
21
20
  * @returns Collection
22
21
  */
23
- function getCurrencies(currencyNames: string[], func: ICultureGet): IdLabelDto<string>[];
22
+ function getCurrencies(currencyNames: string[], func: ICultureGet): DataTypes.IdLabelItem<string>[];
24
23
  /**
25
24
  * Get 12-month items
26
25
  * @param monthLabels Month labels
@@ -42,7 +41,7 @@ export declare namespace BusinessUtils {
42
41
  * @param func Label delegate
43
42
  * @returns Units
44
43
  */
45
- function getUnits(func: ICultureGet): IdLabelDto[];
44
+ function getUnits(func: ICultureGet): DataTypes.IdLabelItem[];
46
45
  /**
47
46
  *
48
47
  * Get all product units
@@ -51,7 +50,7 @@ export declare namespace BusinessUtils {
51
50
  * @param isJoined Add the join label like 'per Kg' for Kg
52
51
  * @returns Units
53
52
  */
54
- function getUnits(func: ICultureGet, options?: string[], isJoined?: boolean): IdLabelDto[];
53
+ function getUnits(func: ICultureGet, options?: string[], isJoined?: boolean): DataTypes.IdLabelItem[];
55
54
  /**
56
55
  *
57
56
  * Get all repeat options
@@ -60,5 +59,14 @@ export declare namespace BusinessUtils {
60
59
  * @param isJoined Add the join label like 'per Kg' for Kg
61
60
  * @returns Units
62
61
  */
63
- function getRepeatOptions(func: ICultureGet, options?: string[], isJoined?: boolean): IdLabelDto[];
62
+ function getRepeatOptions(func: ICultureGet, options?: string[], isJoined?: boolean): DataTypes.IdLabelItem[];
63
+ /**
64
+ * Set id value
65
+ * @param item QueryRQ or TiplistRQ or similiar item
66
+ * @param id Id value
67
+ */
68
+ function setIdValue<T extends {
69
+ id?: number;
70
+ sid?: string;
71
+ }>(item: T, id?: DataTypes.IdType): void;
64
72
  }
@@ -124,4 +124,18 @@ export var BusinessUtils;
124
124
  return getUnits(func, options, isJoined);
125
125
  }
126
126
  BusinessUtils.getRepeatOptions = getRepeatOptions;
127
+ /**
128
+ * Set id value
129
+ * @param item QueryRQ or TiplistRQ or similiar item
130
+ * @param id Id value
131
+ */
132
+ function setIdValue(item, id) {
133
+ if (id == null)
134
+ return;
135
+ if (typeof id === 'number')
136
+ item.id = id;
137
+ else
138
+ item.sid = id;
139
+ }
140
+ BusinessUtils.setIdValue = setIdValue;
127
141
  })(BusinessUtils || (BusinessUtils = {}));
@@ -1,14 +1,5 @@
1
1
  import { DataTypes } from '@etsoo/shared';
2
- /**
3
- * Dto with id and label field
4
- */
5
- export declare type IdLabelDto<T extends DataTypes.IdType = number> = DataTypes.IdItem<T> & {
6
- /**
7
- * Label
8
- */
9
- label: string;
10
- };
11
2
  /**
12
3
  * Conditional IdLabel type
13
4
  */
14
- export declare type IdLabelConditional<T extends boolean> = T extends true ? IdLabelDto<number>[] : IdLabelDto<string>[];
5
+ export declare type IdLabelConditional<T extends boolean> = T extends true ? DataTypes.IdLabelItem<number>[] : DataTypes.IdLabelItem<string>[];
@@ -1,9 +1,8 @@
1
1
  import { DataTypes } from '@etsoo/shared';
2
- import { IdLabelDto } from './IdLabelDto';
3
2
  /**
4
3
  * Dto with id, label and primary field
5
4
  */
6
- export declare type IdLabelPrimaryDto<T extends DataTypes.IdType = number> = IdLabelDto<T> & {
5
+ export declare type IdLabelPrimaryDto<T extends DataTypes.IdType = number> = DataTypes.IdLabelItem<T> & {
7
6
  /**
8
7
  * Is primary
9
8
  */
@@ -1,16 +1,21 @@
1
+ import { DataTypes } from '@etsoo/shared';
1
2
  /**
2
3
  * Tiplist request data
3
4
  * com.etsoo.CoreFramework.Models.TiplistRQ
4
5
  */
5
- export declare type TiplistRQ<T = number> = {
6
+ export declare type TiplistRQ = {
6
7
  /**
7
- * Current id
8
+ * number id
8
9
  */
9
- id: T;
10
+ id?: number;
11
+ /**
12
+ * String id
13
+ */
14
+ sid?: string;
10
15
  /**
11
16
  * Excluded ids
12
17
  */
13
- excludedIds?: T[];
18
+ excludedIds?: DataTypes.IdType[];
14
19
  /**
15
20
  * Filter keyword
16
21
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/appscript",
3
- "version": "1.2.78",
3
+ "version": "1.2.81",
4
4
  "description": "Applications shared TypeScript framework",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/mjs/index.js",
@@ -54,19 +54,19 @@
54
54
  "dependencies": {
55
55
  "@etsoo/notificationbase": "^1.1.6",
56
56
  "@etsoo/restclient": "^1.0.70",
57
- "@etsoo/shared": "^1.1.45",
57
+ "@etsoo/shared": "^1.1.46",
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.18.10",
63
- "@babel/core": "^7.18.10",
63
+ "@babel/core": "^7.18.13",
64
64
  "@babel/plugin-transform-runtime": "^7.18.10",
65
65
  "@babel/preset-env": "^7.18.10",
66
66
  "@babel/runtime-corejs3": "^7.18.9",
67
67
  "@types/jest": "^28.1.7",
68
- "@typescript-eslint/eslint-plugin": "^5.33.1",
69
- "@typescript-eslint/parser": "^5.33.1",
68
+ "@typescript-eslint/eslint-plugin": "^5.34.0",
69
+ "@typescript-eslint/parser": "^5.34.0",
70
70
  "eslint": "^8.22.0",
71
71
  "eslint-config-airbnb-base": "^15.0.0",
72
72
  "eslint-plugin-import": "^2.26.0",
@@ -33,7 +33,6 @@ import { BridgeUtils } from '../bridges/BridgeUtils';
33
33
  import { BusinessUtils } from '../business/BusinessUtils';
34
34
  import { EntityStatus } from '../business/EntityStatus';
35
35
  import { ProductUnit } from '../business/ProductUnit';
36
- import { IdLabelDto } from '../dto/IdLabelDto';
37
36
  import { InitCallDto } from '../dto/InitCallDto';
38
37
  import { ActionResultError } from '../result/ActionResultError';
39
38
  import { IActionResult } from '../result/IActionResult';
@@ -386,7 +385,7 @@ export interface ICoreApp<
386
385
  * Get roles
387
386
  * @param role Combination role value
388
387
  */
389
- getRoles(role: number): IdLabelDto[];
388
+ getRoles(role: number): DataTypes.IdLabelItem[];
390
389
 
391
390
  /**
392
391
  * Get status label
@@ -398,7 +397,7 @@ export interface ICoreApp<
398
397
  * Get status list
399
398
  * @returns list
400
399
  */
401
- getStatusList(): IdLabelDto[];
400
+ getStatusList(): DataTypes.IdLabelItem[];
402
401
 
403
402
  /**
404
403
  * Get refresh token from response headers
@@ -487,7 +486,7 @@ export interface ICoreApp<
487
486
  orgList(
488
487
  items?: number,
489
488
  serviceId?: number
490
- ): Promise<IdLabelDto[] | undefined>;
489
+ ): Promise<DataTypes.IdLabelItem[] | undefined>;
491
490
 
492
491
  /**
493
492
  * Persist settings to source when application exit
@@ -1621,8 +1620,8 @@ export abstract class CoreApp<
1621
1620
  id: E[keyof E],
1622
1621
  key: keyof E & string
1623
1622
  ) => E[keyof E] | undefined
1624
- ): IdLabelDto[] {
1625
- const list: IdLabelDto<number>[] = [];
1623
+ ): DataTypes.IdLabelItem[] {
1624
+ const list: DataTypes.IdLabelItem<number>[] = [];
1626
1625
  const keys = DataTypes.getEnumKeys(em);
1627
1626
  for (const key of keys) {
1628
1627
  let id = em[key as keyof E];
@@ -1652,8 +1651,8 @@ export abstract class CoreApp<
1652
1651
  id: E[keyof E],
1653
1652
  key: keyof E & string
1654
1653
  ) => E[keyof E] | undefined
1655
- ): IdLabelDto<string>[] {
1656
- const list: IdLabelDto<string>[] = [];
1654
+ ): DataTypes.IdLabelItem<string>[] {
1655
+ const list: DataTypes.IdLabelItem<string>[] = [];
1657
1656
  const keys = DataTypes.getEnumKeys(em);
1658
1657
  for (const key of keys) {
1659
1658
  let id = em[key as keyof E];
@@ -1884,7 +1883,7 @@ export abstract class CoreApp<
1884
1883
  * @returns Result
1885
1884
  */
1886
1885
  async orgList(items?: number, serviceId?: number) {
1887
- return await this.api.post<IdLabelDto[]>(
1886
+ return await this.api.post<DataTypes.IdLabelItem[]>(
1888
1887
  'Organization/List',
1889
1888
  {
1890
1889
  items,
@@ -1,5 +1,4 @@
1
1
  import { DataTypes } from '@etsoo/shared';
2
- import { IdLabelDto } from '../dto/IdLabelDto';
3
2
  import { ICultureGet } from '../state/Culture';
4
3
  import { ProductUnit } from './ProductUnit';
5
4
  import { RepeatOption } from './RepeatOption';
@@ -56,7 +55,7 @@ export namespace BusinessUtils {
56
55
  export function getCurrencies(
57
56
  currencyNames: string[],
58
57
  func: ICultureGet
59
- ): IdLabelDto<string>[] {
58
+ ): DataTypes.IdLabelItem<string>[] {
60
59
  return currencyNames.map((name) => ({
61
60
  id: name,
62
61
  label: func(`currency${name}`) ?? name
@@ -110,7 +109,7 @@ export namespace BusinessUtils {
110
109
  * @param func Label delegate
111
110
  * @returns Units
112
111
  */
113
- export function getUnits(func: ICultureGet): IdLabelDto[];
112
+ export function getUnits(func: ICultureGet): DataTypes.IdLabelItem[];
114
113
 
115
114
  /**
116
115
  *
@@ -124,7 +123,7 @@ export namespace BusinessUtils {
124
123
  func: ICultureGet,
125
124
  options?: string[],
126
125
  isJoined?: boolean
127
- ): IdLabelDto[];
126
+ ): DataTypes.IdLabelItem[];
128
127
 
129
128
  /**
130
129
  *
@@ -138,7 +137,7 @@ export namespace BusinessUtils {
138
137
  func: ICultureGet,
139
138
  options?: string[],
140
139
  isJoined?: boolean
141
- ): IdLabelDto[] {
140
+ ): DataTypes.IdLabelItem[] {
142
141
  options ??= DataTypes.getEnumKeys(ProductUnit);
143
142
  return options.map((key) => {
144
143
  const id = DataTypes.getEnumByKey(ProductUnit, key)! as number;
@@ -161,10 +160,24 @@ export namespace BusinessUtils {
161
160
  func: ICultureGet,
162
161
  options?: string[],
163
162
  isJoined: boolean = true
164
- ): IdLabelDto[] {
163
+ ): DataTypes.IdLabelItem[] {
165
164
  options ??= DataTypes.getEnumKeys(RepeatOption);
166
165
  isJoined ??= true;
167
166
 
168
167
  return getUnits(func, options, isJoined);
169
168
  }
169
+
170
+ /**
171
+ * Set id value
172
+ * @param item QueryRQ or TiplistRQ or similiar item
173
+ * @param id Id value
174
+ */
175
+ export function setIdValue<T extends { id?: number; sid?: string }>(
176
+ item: T,
177
+ id?: DataTypes.IdType
178
+ ) {
179
+ if (id == null) return;
180
+ if (typeof id === 'number') item.id = id;
181
+ else item.sid = id;
182
+ }
170
183
  }
@@ -1,19 +1,8 @@
1
1
  import { DataTypes } from '@etsoo/shared';
2
2
 
3
- /**
4
- * Dto with id and label field
5
- */
6
- export type IdLabelDto<T extends DataTypes.IdType = number> =
7
- DataTypes.IdItem<T> & {
8
- /**
9
- * Label
10
- */
11
- label: string;
12
- };
13
-
14
3
  /**
15
4
  * Conditional IdLabel type
16
5
  */
17
6
  export type IdLabelConditional<T extends boolean> = T extends true
18
- ? IdLabelDto<number>[]
19
- : IdLabelDto<string>[];
7
+ ? DataTypes.IdLabelItem<number>[]
8
+ : DataTypes.IdLabelItem<string>[];
@@ -1,11 +1,10 @@
1
1
  import { DataTypes } from '@etsoo/shared';
2
- import { IdLabelDto } from './IdLabelDto';
3
2
 
4
3
  /**
5
4
  * Dto with id, label and primary field
6
5
  */
7
6
  export type IdLabelPrimaryDto<T extends DataTypes.IdType = number> =
8
- IdLabelDto<T> & {
7
+ DataTypes.IdLabelItem<T> & {
9
8
  /**
10
9
  * Is primary
11
10
  */
@@ -1,17 +1,24 @@
1
+ import { DataTypes } from '@etsoo/shared';
2
+
1
3
  /**
2
4
  * Tiplist request data
3
5
  * com.etsoo.CoreFramework.Models.TiplistRQ
4
6
  */
5
- export type TiplistRQ<T = number> = {
7
+ export type TiplistRQ = {
8
+ /**
9
+ * number id
10
+ */
11
+ id?: number;
12
+
6
13
  /**
7
- * Current id
14
+ * String id
8
15
  */
9
- id: T;
16
+ sid?: string;
10
17
 
11
18
  /**
12
19
  * Excluded ids
13
20
  */
14
- excludedIds?: T[];
21
+ excludedIds?: DataTypes.IdType[];
15
22
 
16
23
  /**
17
24
  * Filter keyword