@etsoo/appscript 1.3.34 → 1.3.36

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.
@@ -48,7 +48,11 @@ class AddressApi extends BaseApi_1.BaseApi {
48
48
  return undefined;
49
49
  cachedRegions[culture] = regions;
50
50
  }
51
- const { favoredIds = [], items = 8, keyword } = rq !== null && rq !== void 0 ? rq : {};
51
+ const { id, favoredIds = [], items = 8, keyword } = rq !== null && rq !== void 0 ? rq : {};
52
+ // Id first
53
+ if (id) {
54
+ return regions.filter((region) => region.id === id);
55
+ }
52
56
  // Keyword filter
53
57
  if (keyword)
54
58
  regions = regions.filter((region) => region.label.includes(keyword) || region.id === keyword);
@@ -54,6 +54,11 @@ export declare class EntityApi<T extends IApp = IApp> extends BaseApi<T> {
54
54
  * @returns Result
55
55
  */
56
56
  protected queryAuditBase<T extends DataTypes.IdType, R extends QueryRQ<T>>(rq: R, payload?: AuditLinePayload): Promise<AuditLineDto[] | undefined>;
57
+ /**
58
+ * Query favored country ids
59
+ * @returns Result
60
+ */
61
+ protected queryFavoredCountryIdsBase(api?: string): Promise<string[]>;
57
62
  /**
58
63
  * Read
59
64
  * @param id Id
@@ -59,6 +59,19 @@ class EntityApi extends BaseApi_1.BaseApi {
59
59
  queryAuditBase(rq, payload) {
60
60
  return this.api.post(`${this.flag}/QueryAudit`, rq, payload);
61
61
  }
62
+ /**
63
+ * Query favored country ids
64
+ * @returns Result
65
+ */
66
+ async queryFavoredCountryIdsBase(api) {
67
+ api !== null && api !== void 0 ? api : (api = `${this.flag}/QueryFavoredCountryIds`);
68
+ const result = await this.api.get(api, undefined, {
69
+ showLoading: false
70
+ });
71
+ if (result == null)
72
+ return [];
73
+ return result.map((item) => item.id);
74
+ }
62
75
  /**
63
76
  * Read
64
77
  * @param id Id
@@ -1,4 +1,8 @@
1
1
  export type RegionsRQ = {
2
+ /**
3
+ * Country id
4
+ */
5
+ id?: string;
2
6
  /**
3
7
  * Favored country ids from top to bottom
4
8
  */
@@ -32,6 +32,7 @@ export * from './erp/rq/OrgListRQ';
32
32
  export * from './erp/rq/OrgQueryRQ';
33
33
  export * from './erp/rq/QueryRQ';
34
34
  export * from './erp/rq/RefreshTokenRQ';
35
+ export * from './erp/rq/RegionsRQ';
35
36
  export * from './erp/rq/TiplistRQ';
36
37
  export * from './erp/AddressApi';
37
38
  export * from './erp/BaseApi';
package/lib/cjs/index.js CHANGED
@@ -56,6 +56,7 @@ __exportStar(require("./erp/rq/OrgListRQ"), exports);
56
56
  __exportStar(require("./erp/rq/OrgQueryRQ"), exports);
57
57
  __exportStar(require("./erp/rq/QueryRQ"), exports);
58
58
  __exportStar(require("./erp/rq/RefreshTokenRQ"), exports);
59
+ __exportStar(require("./erp/rq/RegionsRQ"), exports);
59
60
  __exportStar(require("./erp/rq/TiplistRQ"), exports);
60
61
  // erp api
61
62
  __exportStar(require("./erp/AddressApi"), exports);
@@ -45,7 +45,11 @@ export class AddressApi extends BaseApi {
45
45
  return undefined;
46
46
  cachedRegions[culture] = regions;
47
47
  }
48
- const { favoredIds = [], items = 8, keyword } = rq !== null && rq !== void 0 ? rq : {};
48
+ const { id, favoredIds = [], items = 8, keyword } = rq !== null && rq !== void 0 ? rq : {};
49
+ // Id first
50
+ if (id) {
51
+ return regions.filter((region) => region.id === id);
52
+ }
49
53
  // Keyword filter
50
54
  if (keyword)
51
55
  regions = regions.filter((region) => region.label.includes(keyword) || region.id === keyword);
@@ -54,6 +54,11 @@ export declare class EntityApi<T extends IApp = IApp> extends BaseApi<T> {
54
54
  * @returns Result
55
55
  */
56
56
  protected queryAuditBase<T extends DataTypes.IdType, R extends QueryRQ<T>>(rq: R, payload?: AuditLinePayload): Promise<AuditLineDto[] | undefined>;
57
+ /**
58
+ * Query favored country ids
59
+ * @returns Result
60
+ */
61
+ protected queryFavoredCountryIdsBase(api?: string): Promise<string[]>;
57
62
  /**
58
63
  * Read
59
64
  * @param id Id
@@ -56,6 +56,19 @@ export class EntityApi extends BaseApi {
56
56
  queryAuditBase(rq, payload) {
57
57
  return this.api.post(`${this.flag}/QueryAudit`, rq, payload);
58
58
  }
59
+ /**
60
+ * Query favored country ids
61
+ * @returns Result
62
+ */
63
+ async queryFavoredCountryIdsBase(api) {
64
+ api !== null && api !== void 0 ? api : (api = `${this.flag}/QueryFavoredCountryIds`);
65
+ const result = await this.api.get(api, undefined, {
66
+ showLoading: false
67
+ });
68
+ if (result == null)
69
+ return [];
70
+ return result.map((item) => item.id);
71
+ }
59
72
  /**
60
73
  * Read
61
74
  * @param id Id
@@ -1,4 +1,8 @@
1
1
  export type RegionsRQ = {
2
+ /**
3
+ * Country id
4
+ */
5
+ id?: string;
2
6
  /**
3
7
  * Favored country ids from top to bottom
4
8
  */
@@ -32,6 +32,7 @@ export * from './erp/rq/OrgListRQ';
32
32
  export * from './erp/rq/OrgQueryRQ';
33
33
  export * from './erp/rq/QueryRQ';
34
34
  export * from './erp/rq/RefreshTokenRQ';
35
+ export * from './erp/rq/RegionsRQ';
35
36
  export * from './erp/rq/TiplistRQ';
36
37
  export * from './erp/AddressApi';
37
38
  export * from './erp/BaseApi';
package/lib/mjs/index.js CHANGED
@@ -39,6 +39,7 @@ export * from './erp/rq/OrgListRQ';
39
39
  export * from './erp/rq/OrgQueryRQ';
40
40
  export * from './erp/rq/QueryRQ';
41
41
  export * from './erp/rq/RefreshTokenRQ';
42
+ export * from './erp/rq/RegionsRQ';
42
43
  export * from './erp/rq/TiplistRQ';
43
44
  // erp api
44
45
  export * from './erp/AddressApi';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/appscript",
3
- "version": "1.3.34",
3
+ "version": "1.3.36",
4
4
  "description": "Applications shared TypeScript framework",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/mjs/index.js",
@@ -67,7 +67,7 @@
67
67
  "@types/jest": "^29.2.3",
68
68
  "@typescript-eslint/eslint-plugin": "^5.43.0",
69
69
  "@typescript-eslint/parser": "^5.43.0",
70
- "eslint": "^8.27.0",
70
+ "eslint": "^8.28.0",
71
71
  "eslint-config-airbnb-base": "^15.0.0",
72
72
  "eslint-plugin-import": "^2.26.0",
73
73
  "jest": "^29.3.1",
@@ -59,7 +59,12 @@ export class AddressApi extends BaseApi {
59
59
  cachedRegions[culture] = regions;
60
60
  }
61
61
 
62
- const { favoredIds = [], items = 8, keyword } = rq ?? {};
62
+ const { id, favoredIds = [], items = 8, keyword } = rq ?? {};
63
+
64
+ // Id first
65
+ if (id) {
66
+ return regions.filter((region) => region.id === id);
67
+ }
63
68
 
64
69
  // Keyword filter
65
70
  if (keyword)
@@ -103,6 +103,19 @@ export class EntityApi<T extends IApp = IApp> extends BaseApi<T> {
103
103
  return this.api.post(`${this.flag}/QueryAudit`, rq, payload);
104
104
  }
105
105
 
106
+ /**
107
+ * Query favored country ids
108
+ * @returns Result
109
+ */
110
+ protected async queryFavoredCountryIdsBase(api?: string) {
111
+ api ??= `${this.flag}/QueryFavoredCountryIds`;
112
+ const result = await this.api.get<{ id: string }[]>(api, undefined, {
113
+ showLoading: false
114
+ });
115
+ if (result == null) return [];
116
+ return result.map((item) => item.id);
117
+ }
118
+
106
119
  /**
107
120
  * Read
108
121
  * @param id Id
@@ -1,4 +1,9 @@
1
1
  export type RegionsRQ = {
2
+ /**
3
+ * Country id
4
+ */
5
+ id?: string;
6
+
2
7
  /**
3
8
  * Favored country ids from top to bottom
4
9
  */
package/src/index.ts CHANGED
@@ -45,6 +45,7 @@ export * from './erp/rq/OrgListRQ';
45
45
  export * from './erp/rq/OrgQueryRQ';
46
46
  export * from './erp/rq/QueryRQ';
47
47
  export * from './erp/rq/RefreshTokenRQ';
48
+ export * from './erp/rq/RegionsRQ';
48
49
  export * from './erp/rq/TiplistRQ';
49
50
 
50
51
  // erp api