esi-cap 1.7.33 → 1.7.35
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/index.js +1 -1
- package/dist/lib/_classes/index.js +1 -1
- package/dist/lib/_config/index.js +1 -1
- package/dist/lib/_interface/appender/index.js +1 -1
- package/dist/lib/_interface/file/index.js +1 -1
- package/dist/lib/_interface/formatter/index.js +1 -1
- package/dist/lib/_interface/index.js +1 -1
- package/dist/lib/_interface/layout/index.js +1 -1
- package/dist/lib/_interface/log/index.js +1 -1
- package/dist/lib/_interface/path/index.js +1 -1
- package/dist/lib/connect/index.js +1 -1
- package/dist/lib/impl/index.js +1 -1
- package/dist/lib/log/index.js +1 -1
- package/dist/lib/query/index.js +1 -1
- package/dist/lib/service/index.js +1 -1
- package/dist/lib/utils/index.js +1 -1
- package/package.json +2 -2
- package/types/index.md +73 -0
- package/types/lib/connect/index.d.ts +21 -2
- package/types/lib/connect/index.d.ts.map +1 -1
- package/types/lib/utils/index.md +25 -34
package/types/index.md
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# esi-cap API Reference
|
|
2
|
+
|
|
3
|
+
> **Module:** `esi-cap` Package
|
|
4
|
+
> **Purpose:** `esi-cap` is a specialized API package designed for **Enterprise System Integration** within the [SAP Cloud Application Programming Model (CAP)](https://cap.cloud.sap/docs/) framework. It streamlines communication with remote systems and provides native support for service associations, requiring minimal configuration to achieve out-of-the-box connectivity.
|
|
5
|
+
> **Package Structure:** The package is organized into two primary modules:
|
|
6
|
+
> **`esi` Module**: Contains the core integration logic and foundational functions for system communication.
|
|
7
|
+
> **`utils` Module**: Provides a suite of generic utility functions to support common development tasks.
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## Table of Contents
|
|
12
|
+
|
|
13
|
+
- [Exports](#exports)
|
|
14
|
+
- [Module: `esi`](#module-esi)
|
|
15
|
+
- [Module: `utils`](#module-utils)
|
|
16
|
+
- [Quick Usage Examples](#quick-usage-examples)
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## Exports
|
|
21
|
+
|
|
22
|
+
```js
|
|
23
|
+
module.exports = { esi, utils };
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## Module: `esi`
|
|
29
|
+
|
|
30
|
+
Contains the core integration logic and foundational functions for system communication. Its core capabilities are outlined below:
|
|
31
|
+
|
|
32
|
+
| Feature | Module Name | Description |
|
|
33
|
+
| :--- | :--- | :--- |
|
|
34
|
+
| **Remote Communication** | `connect` | Streamlined protocols for connecting to external APIs. Simplifies connectivity with minimal configuration. It supports API of soap, odata v4/v2, rest, iflow-https. |
|
|
35
|
+
| **Service Implementation** | `impl` | Native support for remote service associations. Reduces boilerplate code for complex data models. |
|
|
36
|
+
| **Enriched Logging** | `log` | Pre-configured patterns for SAP environment logging. Accelerates development using CAP best practices. |
|
|
37
|
+
| **Core Functions** | `service`, `query` | Foundational functions for system-to-system messaging. Ensures consistent data handling across the enterprise. |
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
## Module: `utils`
|
|
43
|
+
|
|
44
|
+
Provides a suite of generic utility functions to support common development tasks. Refer to the [utils Documentation](./lib/utils/index.md) for more details.
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
## Quick Usage Examples
|
|
50
|
+
|
|
51
|
+
```js
|
|
52
|
+
const { cds } = require('@sap/cds');
|
|
53
|
+
const { esi, utils } = require('esi-cap');
|
|
54
|
+
|
|
55
|
+
// impl usage
|
|
56
|
+
const srvImpl = cds.service.impl(esi.impl.RemoteService);
|
|
57
|
+
|
|
58
|
+
// connect usage
|
|
59
|
+
const srv = esi.connect.to('<ServiceName>');
|
|
60
|
+
srv.run(SELECT.from('<EntityName').where('<Where Clause').columns('<Columns list'));
|
|
61
|
+
|
|
62
|
+
// log usage
|
|
63
|
+
const logger = esi.log('<LoggerName>');
|
|
64
|
+
const data = { a: 1, b: "Hello" };
|
|
65
|
+
logger.warn(esi.service.events.PreOn, req, "data", data); // [2026-01-01T12:32:20.197Z] [WARN] [<LoggerName>] [PreOn:READ:<Name of Service>.<Name of Entity>] - data | { a: 1, b: "Hello" }
|
|
66
|
+
|
|
67
|
+
// utils usage
|
|
68
|
+
const valid = await utils.date.isValid("2026-04-20");
|
|
69
|
+
const items = [{ id: 1, name: "A" }, { id: 2, name: "B" }];
|
|
70
|
+
const grouped = utils.array.toGroupByPropertyName(items, "name");
|
|
71
|
+
const merged = utils.json.merge({ a: 1 }, { b: 2 }); // { a: 1, b: 2 }
|
|
72
|
+
|
|
73
|
+
```
|
|
@@ -1,4 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* connect module for establishing connections to various services, including SOAP, ODATA v2/v4, Integration Flow and RESTful services.
|
|
3
|
+
* @class
|
|
4
|
+
* @public
|
|
5
|
+
*/
|
|
6
|
+
export class connect {
|
|
7
|
+
/**
|
|
8
|
+
* Establishes a connection to the specified service based on its configuration in `cds.requires`.
|
|
9
|
+
* It supports connecting to local services defined in the application as well as remote services,
|
|
10
|
+
* including SOAP, ODATA v2/v4, Integration Flow and RESTful services. The method determines the type of
|
|
11
|
+
* service based on the configuration and uses the appropriate connection method to establish the connection.
|
|
12
|
+
*
|
|
13
|
+
* @public
|
|
14
|
+
* @static
|
|
15
|
+
* @param {string} sServiceName - The name of the service to connect to (e.g., "LocalService.MyService", "RemoteService.MyService").
|
|
16
|
+
* @returns {Promise<any>} Resolves to the service connection object.
|
|
17
|
+
* @example
|
|
18
|
+
* await connect.to("LocalService.MyService"); // returns the service connection object
|
|
19
|
+
* await connect.to("RemoteService.MyService"); // returns the service connection object
|
|
20
|
+
*/
|
|
21
|
+
public static to(sServiceName: string): Promise<any>;
|
|
3
22
|
}
|
|
4
23
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../.types/lib/connect/index.js"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../.types/lib/connect/index.js"],"names":[],"mappings":"AA0FA;;;;GAIG;AACH;IACI;;;;;;;;;;;;;OAaG;IACH,+BAA2B,MAAM,GALpB,OAAO,CAAC,GAAG,CAAC,CAsCxB;CACJ"}
|
package/types/lib/utils/index.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# esi-cap Utilities API Reference
|
|
2
2
|
|
|
3
|
-
> **Module:** `
|
|
4
|
-
> **Purpose:** Core utility belt
|
|
3
|
+
> **Module:** `utils`
|
|
4
|
+
> **Purpose:** Core utility belt — date validation, XML parsing, JSON manipulation, array operations, and UUID generation/parsing.
|
|
5
5
|
|
|
6
6
|
---
|
|
7
7
|
|
|
@@ -9,11 +9,11 @@
|
|
|
9
9
|
|
|
10
10
|
- [Dependencies](#dependencies)
|
|
11
11
|
- [Exports](#exports)
|
|
12
|
-
- [
|
|
12
|
+
- [Class: `date`](#class-date)
|
|
13
13
|
- [date.isValid(sDate)](#dateisvalidsdate)
|
|
14
|
-
- [
|
|
14
|
+
- [Class: `xml`](#class-xml)
|
|
15
15
|
- [xml.isValid(oXML)](#xmlisvalidoxml)
|
|
16
|
-
- [
|
|
16
|
+
- [Class: `json`](#class-json)
|
|
17
17
|
- [json.isValid(oJson)](#jsonisvalidojson)
|
|
18
18
|
- [json.copy(oJson)](#jsoncopyojson)
|
|
19
19
|
- [json.replace(oJson, sOldValue, sNewValue, oEvaluate?)](#jsonreplaceojson-soldvalue-snewvalue-oevaluate)
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
- [json.merge(oJson1, oJson2)](#jsonmergeojson1-ojson2)
|
|
26
26
|
- [json.flat(oJson, sFlattenedProperty)](#jsonflatojson-sflattenedproperty)
|
|
27
27
|
- [json.stripUndefined(oSourceJson)](#jsonstripundefinedosourcejson)
|
|
28
|
-
- [
|
|
28
|
+
- [Class: `array`](#class-array)
|
|
29
29
|
- [array.add(oArray, oItem)](#arrayaddoarray-oitem)
|
|
30
30
|
- [array.topN(oSortedArray, iTop)](#arraytopnosortedarray-itop)
|
|
31
31
|
- [array.flat(oArray, sFlattenedProperty)](#arrayflatoarray-sflattenedproperty)
|
|
@@ -57,21 +57,20 @@
|
|
|
57
57
|
| `xml2js` | XML string parsing and validation |
|
|
58
58
|
| `uuid` | UUID format validation |
|
|
59
59
|
| `lodash` | Deep merge, orderBy, uniqWith, and isEqual |
|
|
60
|
-
| `../_interface` | Internal logger and `_LOG` constant |
|
|
61
60
|
|
|
62
61
|
---
|
|
63
62
|
|
|
64
63
|
## Exports
|
|
65
64
|
|
|
66
65
|
```js
|
|
67
|
-
module.exports = { date, xml, json, array, UUID
|
|
66
|
+
module.exports = { date, xml, json, array, UUID };
|
|
68
67
|
```
|
|
69
68
|
|
|
70
69
|
---
|
|
71
70
|
|
|
72
|
-
##
|
|
71
|
+
## Class: `date`
|
|
73
72
|
|
|
74
|
-
Date-related validation helpers.
|
|
73
|
+
Date-related validation helpers. All methods are `static`.
|
|
75
74
|
|
|
76
75
|
### `date.isValid(sDate)`
|
|
77
76
|
|
|
@@ -89,9 +88,9 @@ await date.isValid("not-a-date"); // false
|
|
|
89
88
|
|
|
90
89
|
---
|
|
91
90
|
|
|
92
|
-
##
|
|
91
|
+
## Class: `xml`
|
|
93
92
|
|
|
94
|
-
XML parsing and validation helpers.
|
|
93
|
+
XML parsing and validation helpers. All methods are `static`.
|
|
95
94
|
|
|
96
95
|
### `xml.isValid(oXML)`
|
|
97
96
|
|
|
@@ -104,14 +103,14 @@ XML parsing and validation helpers.
|
|
|
104
103
|
|
|
105
104
|
```js
|
|
106
105
|
await xml.isValid("<root><item>val</item></root>"); // true
|
|
107
|
-
await xml.isValid("not xml");
|
|
106
|
+
await xml.isValid("not xml"); // false
|
|
108
107
|
```
|
|
109
108
|
|
|
110
109
|
---
|
|
111
110
|
|
|
112
|
-
##
|
|
111
|
+
## Class: `json`
|
|
113
112
|
|
|
114
|
-
Comprehensive JSON/object manipulation utilities.
|
|
113
|
+
Comprehensive JSON/object manipulation utilities. All methods are `static`.
|
|
115
114
|
|
|
116
115
|
### `json.isValid(oJson)`
|
|
117
116
|
|
|
@@ -243,9 +242,9 @@ Removes properties where the value is `undefined`, `null`, or an empty string.
|
|
|
243
242
|
|
|
244
243
|
---
|
|
245
244
|
|
|
246
|
-
##
|
|
245
|
+
## Class: `array`
|
|
247
246
|
|
|
248
|
-
Array operations with automatic fallback to `json`
|
|
247
|
+
Array operations with automatic fallback to the `json` class for single-object inputs. All methods are `static`.
|
|
249
248
|
|
|
250
249
|
### `array.add(oArray, oItem)`
|
|
251
250
|
|
|
@@ -399,7 +398,7 @@ array.toGroupByPropertyList(data, ["region", "details.category"]);
|
|
|
399
398
|
|
|
400
399
|
## Class: `UUID`
|
|
401
400
|
|
|
402
|
-
Singleton class for deterministic UUID generation and parsing based on a fixed field configuration. Encodes/decodes structured business data
|
|
401
|
+
Singleton class for deterministic UUID generation and parsing based on a fixed field configuration. Encodes/decodes structured business data into RFC-4122-compliant UUIDs.
|
|
403
402
|
|
|
404
403
|
### Constructor
|
|
405
404
|
|
|
@@ -409,14 +408,6 @@ const uuidHelper = new UUID();
|
|
|
409
408
|
|
|
410
409
|
Creates a singleton instance. Subsequent `new UUID()` calls return the same instance.
|
|
411
410
|
|
|
412
|
-
**Internal field configuration:**
|
|
413
|
-
|
|
414
|
-
| Field | Order | Format (Regex) | Description |
|
|
415
|
-
|---|---|---|---|
|
|
416
|
-
| `CompanyCode` | 1 | `/^[A-Za-z]{2}\d{2}$/` | 2 letters + 2 digits |
|
|
417
|
-
| `PersonWorkAgreementExternalID` | 2 | `/^[Ii]\d{7}$\|^\d{1,9}$/` | I-number or numeric ID |
|
|
418
|
-
| `TimeSheetRecord` | 3 | `/^\d{12}$/` | 12-digit record number |
|
|
419
|
-
|
|
420
411
|
---
|
|
421
412
|
|
|
422
413
|
### `converse(oJsonData)`
|
|
@@ -425,16 +416,16 @@ Encodes structured JSON data into a deterministic UUID.
|
|
|
425
416
|
|
|
426
417
|
| Parameter | Type | Description |
|
|
427
418
|
|------------|----------|-------------------------------------------|
|
|
428
|
-
| `oJsonData` | `object` | Object
|
|
419
|
+
| `oJsonData` | `object` | Object |
|
|
429
420
|
| **Returns** | `string` | A valid UUID string |
|
|
430
421
|
| **Throws** | `Error` | If any field has an invalid format or the generated UUID fails validation |
|
|
431
422
|
|
|
432
423
|
```js
|
|
433
424
|
const uid = new UUID();
|
|
434
425
|
uid.converse({
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
426
|
+
ABC: "AB12",
|
|
427
|
+
MNO: "I1234567",
|
|
428
|
+
XYZ: "000000012345"
|
|
438
429
|
});
|
|
439
430
|
// Returns a valid UUID string e.g., "c0656612-2e12-4345-8670-000000012345"
|
|
440
431
|
```
|
|
@@ -448,12 +439,12 @@ Decodes a previously generated UUID back into its original structured data.
|
|
|
448
439
|
| Parameter | Type | Description |
|
|
449
440
|
|-----------|----------|------------------------------------|
|
|
450
441
|
| `sUUID` | `string` | A UUID previously created by `converse` |
|
|
451
|
-
| **Returns** | `object` | `{
|
|
442
|
+
| **Returns** | `object` | `{ ABC, MNO, XYZ }` or `{}` if invalid |
|
|
452
443
|
|
|
453
444
|
```js
|
|
454
445
|
const uid = new UUID();
|
|
455
446
|
uid.inverse("c0656612-2e12-4345-8670-000000012345");
|
|
456
|
-
// {
|
|
447
|
+
// { ABC: "AB12", MNO: "I1234567", XYZ: "000000012345" }
|
|
457
448
|
```
|
|
458
449
|
|
|
459
450
|
---
|
|
@@ -461,7 +452,7 @@ uid.inverse("c0656612-2e12-4345-8670-000000012345");
|
|
|
461
452
|
## Quick Usage Examples
|
|
462
453
|
|
|
463
454
|
```js
|
|
464
|
-
const { date, xml, json, array, UUID } = require('
|
|
455
|
+
const { date, xml, json, array, UUID } = require('esi-cap').utils;
|
|
465
456
|
|
|
466
457
|
// Validate & transform
|
|
467
458
|
const valid = await date.isValid("2026-04-20");
|
|
@@ -478,6 +469,6 @@ const merged = json.merge({ a: 1 }, { b: 2 }); // { a: 1, b:
|
|
|
478
469
|
|
|
479
470
|
// UUID round-trip
|
|
480
471
|
const uid = new UUID();
|
|
481
|
-
const uuidStr = uid.converse({
|
|
472
|
+
const uuidStr = uid.converse({ ABC: "AB12", MNO: "I1234567", XYZ: "000000012345" });
|
|
482
473
|
const original = uid.inverse(uuidStr);
|
|
483
474
|
```
|