eservices-core 1.0.594 → 1.0.595

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.
@@ -5,13 +5,14 @@ import * as types from "./types";
5
5
  import Table from "./classes/table/Table";
6
6
  import "./../styles/index.css";
7
7
  import * as testTypes from "./../../backend/src/types/main";
8
+ import { MasterEntity, MasterEntities } from "./types";
8
9
  import StylesInterface from "./styles/types";
9
10
  import { Values } from "./types";
10
11
  import historyService, { IParsedHistoryResponse } from "./services/history-service";
11
12
  import * as newImport from "./new/new-import";
12
13
  import { MetadataStore, ComputedMetadata, prettifyValueByMetadata } from "./classes/MetadataStore";
13
14
  import { Metadata, MetadataField, MetadataResponse } from "./../../backend/src/types/main";
14
- export { Metadata, MetadataResponse, MetadataField };
15
+ export { Metadata, MetadataResponse, MetadataField, MasterEntity, MasterEntities };
15
16
  export { newImport, testTypes, MetadataStore, ComputedMetadata, prettifyValueByMetadata };
16
17
  import { ICustomerContext, ApplicationType } from "./classes/ApplicationManager";
17
18
  import { IActionExecuteResult, IValidationEffect, IActionResponse } from "./services/action-service";
@@ -1,4 +1,4 @@
1
- import { ValuesInterface } from "../types";
1
+ import { MasterEntities, MasterEntity, ValuesInterface } from "../types";
2
2
  import { IRequestUpdateResult, IRequestCreateResult } from "./../../../backend/src/types/main";
3
3
  export default class dataService {
4
4
  static anonymousGetList<T>(entity: string): Promise<T[]>;
@@ -14,11 +14,11 @@ export default class dataService {
14
14
  /**
15
15
  * @description Creating entity.
16
16
  * */
17
- static create(entity: string, values: ValuesInterface, rule?: string): Promise<IRequestCreateResult>;
17
+ static create(entity: string, values: ValuesInterface, options?: ModificationOption): Promise<IRequestCreateResult>;
18
18
  /**
19
19
  * @description Default update method, update entity by primaryKeys.
20
20
  * */
21
- static update(entity: string, primaryKeys: any, values: any): Promise<IRequestUpdateResult>;
21
+ static update(entity: string, primaryKeys: any, values: any, options?: ModificationOption): Promise<IRequestUpdateResult>;
22
22
  /**
23
23
  * @description Reading entity's data by id.
24
24
  * @param {String} entity Entity name in the singular.
@@ -36,7 +36,7 @@ export default class dataService {
36
36
  static removeById(entity: string, Id: number | number[], version?: any | undefined): Promise<IRequestUpdateResult>;
37
37
  static removeByKeys(entity: string, keys: Record<string, any> | Record<string, any>[], version?: any): Promise<IRequestUpdateResult>;
38
38
  }
39
- interface UpdateOptions {
39
+ interface UpdateOptions extends ModificationOption {
40
40
  version?: number;
41
41
  }
42
42
  interface IListOptions {
@@ -47,4 +47,7 @@ interface IListOptions {
47
47
  limit: number;
48
48
  offset: number;
49
49
  }
50
+ interface ModificationOption {
51
+ masterEntities?: MasterEntities | MasterEntity;
52
+ }
50
53
  export {};
@@ -1,2 +1,2 @@
1
- import { MasterEntities } from "../types";
2
- export default function addMasterEntitiesToSearchParams(urlSearchParams: URLSearchParams, masterEntities?: MasterEntities): void;
1
+ import { MasterEntities, MasterEntity } from "../types";
2
+ export default function addMasterEntitiesToSearchParams(urlSearchParams: URLSearchParams, masterEntities?: MasterEntities | MasterEntity): void;
@@ -0,0 +1,2 @@
1
+ import { MasterEntity } from "../types";
2
+ export default function isMasterEntity(object: unknown): object is MasterEntity;
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * eservices-core v1.0.594
2
+ * eservices-core v1.0.595
3
3
  * (c) 2023 ESERVICES
4
4
  */
5
5
  'use strict';
@@ -2541,6 +2541,24 @@ var types = /*#__PURE__*/Object.freeze({
2541
2541
  __proto__: null
2542
2542
  });
2543
2543
 
2544
+ function isMasterEntity(object) {
2545
+ return Array.isArray(object) && object.length === 2 && typeof object[0] === 'string' && typeof object[1] === 'number';
2546
+ }
2547
+
2548
+ const MASTER_ID_NAME = 'masterId';
2549
+ const MASTER_ENTITY_NAME = 'masterEntity';
2550
+ function addMasterEntitiesToSearchParams(urlSearchParams, masterEntities) {
2551
+ if (!Array.isArray(masterEntities))
2552
+ return;
2553
+ if (isMasterEntity(masterEntities))
2554
+ return add(masterEntities);
2555
+ masterEntities.forEach(add);
2556
+ function add(object) {
2557
+ urlSearchParams.append(MASTER_ENTITY_NAME, object[0]);
2558
+ urlSearchParams.append(MASTER_ID_NAME, object[1].toString());
2559
+ }
2560
+ }
2561
+
2544
2562
  class dataService {
2545
2563
  static anonymousGetList(entity) {
2546
2564
  return __awaiter(this, void 0, void 0, function* () {
@@ -2650,8 +2668,10 @@ class dataService {
2650
2668
  /**
2651
2669
  * @description Creating entity.
2652
2670
  * */
2653
- static create(entity, values, rule = "*") {
2654
- return Request(`/close-api/data/${entity}?rule=${rule}`, {
2671
+ static create(entity, values, options) {
2672
+ const query = new URLSearchParams();
2673
+ addMasterEntitiesToSearchParams(query, options === null || options === void 0 ? void 0 : options.masterEntities);
2674
+ return Request(`/close-api/data/${entity}?${query.toString()}`, {
2655
2675
  method: 'POST',
2656
2676
  headers: {
2657
2677
  'Content-Type': 'application/json',
@@ -2664,7 +2684,7 @@ class dataService {
2664
2684
  /**
2665
2685
  * @description Default update method, update entity by primaryKeys.
2666
2686
  * */
2667
- static update(entity, primaryKeys, values) {
2687
+ static update(entity, primaryKeys, values, options = {}) {
2668
2688
  return Request(`/close-api/data/entities/${entity}`, {
2669
2689
  method: 'PUT',
2670
2690
  headers: {
@@ -2698,7 +2718,9 @@ class dataService {
2698
2718
  });
2699
2719
  }
2700
2720
  static updateById(entity, id, values, options) {
2701
- return Request(`/close-api/data/entities/${entity}/id/${id}`, {
2721
+ const query = new URLSearchParams();
2722
+ addMasterEntitiesToSearchParams(query, options === null || options === void 0 ? void 0 : options.masterEntities);
2723
+ return Request(`/close-api/data/entities/${entity}/id/${id}?${query.toString()}`, {
2702
2724
  method: 'PUT',
2703
2725
  headers: {
2704
2726
  'Content-Type': 'application/json'
@@ -5083,17 +5105,6 @@ class processWizardService {
5083
5105
  }
5084
5106
  processWizardService.url = '/close-api/views/process-wizard';
5085
5107
 
5086
- const MASTER_ID_NAME = 'masterId';
5087
- const MASTER_ENTITY_NAME = 'masterEntity';
5088
- function addMasterEntitiesToSearchParams(urlSearchParams, masterEntities) {
5089
- if (!Array.isArray(masterEntities))
5090
- return;
5091
- masterEntities.forEach(item => {
5092
- urlSearchParams.append(MASTER_ENTITY_NAME, item[0]);
5093
- urlSearchParams.append(MASTER_ID_NAME, item[1].toString());
5094
- });
5095
- }
5096
-
5097
5108
  class metadataService {
5098
5109
  static get url() {
5099
5110
  return `/close-api/metadata`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eservices-core",
3
- "version": "1.0.594",
3
+ "version": "1.0.595",
4
4
  "description": "Core library",
5
5
  "author": "",
6
6
  "scripts": {