http-sankhya 1.0.1 → 1.0.2

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/dist/Sankhya.js CHANGED
@@ -149,8 +149,8 @@ class Sankhya {
149
149
  dataRow: {
150
150
  localFields: SankhyaHelper_1.SankhyaHelper.transformLocalFields(localFields)
151
151
  },
152
- },
153
- entity
152
+ entity
153
+ }
154
154
  },
155
155
  outputType
156
156
  }, outputType);
@@ -11,5 +11,7 @@ export declare class SankhyaHelper {
11
11
  * Ex: { CAMPO: "VALOR" } -> { CAMPO: { "$": "VALOR" } }
12
12
  */
13
13
  static transformLocalFields(localFields: Record<string, any>): Record<string, any>;
14
+ private static processSaveRecord;
15
+ private static processLoadRecord;
14
16
  private static processLoadRecords;
15
17
  }
@@ -12,9 +12,11 @@ class SankhyaHelper {
12
12
  }
13
13
  switch (options.serviceName) {
14
14
  case 'CRUDServiceProvider.loadRecords':
15
- case 'CRUDServiceProvider.loadRecord':
16
- case 'CRUDServiceProvider.saveRecord':
17
15
  return this.processLoadRecords(response);
16
+ case 'CRUDServiceProvider.saveRecord':
17
+ return this.processSaveRecord(response);
18
+ case 'CRUDServiceProvider.loadRecord':
19
+ return this.processLoadRecord(response);
18
20
  default:
19
21
  // Se não for um dos serviços conhecidos de CRUD/Load, retorna original
20
22
  return response;
@@ -39,6 +41,19 @@ class SankhyaHelper {
39
41
  return transformed;
40
42
  }
41
43
  // Lógica de transformação extraída para método privado
44
+ static processSaveRecord(response) {
45
+ if (response.status === '0') {
46
+ return response;
47
+ }
48
+ return this.processLoadRecords(response);
49
+ }
50
+ static processLoadRecord(response) {
51
+ const { entities } = response.responseBody;
52
+ if (entities.total === '0') {
53
+ return null;
54
+ }
55
+ return this.processLoadRecords(response);
56
+ }
42
57
  static processLoadRecords(response) {
43
58
  const { entities } = response.responseBody;
44
59
  const metadata = entities.metadata;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "http-sankhya",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "Biblioteca TypeScript para integração com ERP Sankhya",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",