@abapify/adt-client 0.4.31 → 0.4.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.
- package/README.md +19 -265
- package/dist/index.d.mts +5 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +201 -146
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -1,287 +1,41 @@
|
|
|
1
1
|
# @abapify/adt-client
|
|
2
2
|
|
|
3
|
-
[](https://www.npmjs.com/package/@abapify/adt-client)
|
|
4
|
+
[](https://github.com/abapify/adt-cli/blob/main/LICENSE)
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
Minimalistic speci-based ADT client for SAP ABAP Development Tools.
|
|
6
7
|
|
|
7
|
-
##
|
|
8
|
-
|
|
9
|
-
This package replaces the legacy `adt-client` with a **contract-first design**:
|
|
10
|
-
|
|
11
|
-
```
|
|
12
|
-
┌─────────────────────────────────────────────────────────────────┐
|
|
13
|
-
│ adt-client │
|
|
14
|
-
│ (HTTP Client + Request Execution) │
|
|
15
|
-
└─────────────────────────────────────────────────────────────────┘
|
|
16
|
-
│
|
|
17
|
-
▼
|
|
18
|
-
┌─────────────────────────────────────────────────────────────────┐
|
|
19
|
-
│ adt-contracts │
|
|
20
|
-
│ (REST API Contracts using speci + ts-xsd) │
|
|
21
|
-
└─────────────────────────────────────────────────────────────────┘
|
|
22
|
-
│
|
|
23
|
-
▼
|
|
24
|
-
┌─────────────────────────────────────────────────────────────────┐
|
|
25
|
-
│ adt-schemas │
|
|
26
|
-
│ (TypeScript schemas from SAP XSD definitions) │
|
|
27
|
-
└─────────────────────────────────────────────────────────────────┘
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
**Benefits over v1:**
|
|
31
|
-
|
|
32
|
-
- ✅ **Type-safe from XSD** - Types generated from official SAP schemas
|
|
33
|
-
- ✅ **Contract-first** - API contracts define the interface
|
|
34
|
-
- ✅ **Zero manual types** - No hand-written type definitions
|
|
35
|
-
- ✅ **Easy to extend** - Add endpoints by defining contracts
|
|
36
|
-
- ✅ **Testable** - Contracts are pure data, easy to mock
|
|
37
|
-
|
|
38
|
-
## Features
|
|
39
|
-
|
|
40
|
-
- ✅ **Contract-driven** - Uses `speci` + `ts-xsd` contracts
|
|
41
|
-
- ✅ **Full type inference** - Types flow from XSD to response
|
|
42
|
-
- ✅ **Zero dependencies** - Only uses native fetch API
|
|
43
|
-
- ✅ **Clean API** - Arrow-function contracts
|
|
44
|
-
- ✅ **Promise-based** - Modern async/await API
|
|
45
|
-
|
|
46
|
-
## Installation
|
|
8
|
+
## Install
|
|
47
9
|
|
|
48
10
|
```bash
|
|
49
|
-
|
|
11
|
+
npm install @abapify/adt-client
|
|
50
12
|
```
|
|
51
13
|
|
|
52
|
-
##
|
|
14
|
+
## Usage
|
|
53
15
|
|
|
54
|
-
```
|
|
16
|
+
```ts
|
|
55
17
|
import { createAdtClient } from '@abapify/adt-client';
|
|
56
18
|
|
|
57
|
-
// Create client
|
|
58
19
|
const client = createAdtClient({
|
|
59
|
-
baseUrl: 'https://sap
|
|
60
|
-
username: '
|
|
61
|
-
password
|
|
20
|
+
baseUrl: 'https://sap.example.com',
|
|
21
|
+
username: 'DEVELOPER',
|
|
22
|
+
password,
|
|
62
23
|
client: '100',
|
|
63
|
-
language: 'EN',
|
|
64
24
|
});
|
|
65
25
|
|
|
66
|
-
|
|
67
|
-
const classObj = await client.getClass('ZCL_MY_CLASS');
|
|
68
|
-
console.log(classObj.metadata.description);
|
|
69
|
-
console.log(classObj.includes.main);
|
|
70
|
-
console.log(classObj.includes.definitions);
|
|
71
|
-
console.log(classObj.includes.implementations);
|
|
72
|
-
|
|
73
|
-
// Update main source
|
|
74
|
-
await client.updateMainSource('ZCL_MY_CLASS', newSource);
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
## API Reference
|
|
78
|
-
|
|
79
|
-
### Client Creation
|
|
80
|
-
|
|
81
|
-
```typescript
|
|
82
|
-
createAdtClient(config: AdtConnectionConfig): AdtClient
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
**Config:**
|
|
86
|
-
|
|
87
|
-
- `baseUrl` - SAP system URL (e.g., `https://sap-system.com:8000`)
|
|
88
|
-
- `username` - SAP username
|
|
89
|
-
- `password` - SAP password
|
|
90
|
-
- `client` - SAP client (optional, e.g., `'100'`)
|
|
91
|
-
- `language` - SAP language (optional, e.g., `'EN'`)
|
|
92
|
-
- `headersTimeoutMs` - response-header timeout for long-running SAP requests
|
|
93
|
-
(optional; otherwise the native HTTP client default applies)
|
|
94
|
-
|
|
95
|
-
### Class Operations
|
|
96
|
-
|
|
97
|
-
#### Get Complete Class
|
|
98
|
-
|
|
99
|
-
```typescript
|
|
100
|
-
getClass(className: string): Promise<ClassObject>
|
|
26
|
+
const discovery = await client.fetch('/sap/bc/adt/discovery');
|
|
101
27
|
```
|
|
102
28
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
#### Get Metadata Only
|
|
106
|
-
|
|
107
|
-
```typescript
|
|
108
|
-
getMetadata(className: string): Promise<ClassMetadata>
|
|
109
|
-
```
|
|
110
|
-
|
|
111
|
-
Returns class metadata (name, description, package, etc.).
|
|
112
|
-
|
|
113
|
-
#### Get All Includes
|
|
114
|
-
|
|
115
|
-
```typescript
|
|
116
|
-
getIncludes(className: string): Promise<ClassIncludes>
|
|
117
|
-
```
|
|
118
|
-
|
|
119
|
-
Returns all class source includes.
|
|
120
|
-
|
|
121
|
-
#### Get Specific Include
|
|
122
|
-
|
|
123
|
-
```typescript
|
|
124
|
-
getInclude(className: string, includeType: 'main' | 'definitions' | 'implementations' | 'macros' | 'testclasses'): Promise<string>
|
|
125
|
-
```
|
|
126
|
-
|
|
127
|
-
Returns specific include source code.
|
|
128
|
-
|
|
129
|
-
#### Update Main Source
|
|
130
|
-
|
|
131
|
-
```typescript
|
|
132
|
-
updateMainSource(className: string, source: string): Promise<OperationResult>
|
|
133
|
-
```
|
|
134
|
-
|
|
135
|
-
Updates the main class source code.
|
|
136
|
-
|
|
137
|
-
#### Create Class
|
|
138
|
-
|
|
139
|
-
```typescript
|
|
140
|
-
createClass(className: string, metadata: Partial<ClassMetadata>): Promise<OperationResult>
|
|
141
|
-
```
|
|
142
|
-
|
|
143
|
-
Creates a new class with specified metadata.
|
|
144
|
-
|
|
145
|
-
#### Delete Class
|
|
146
|
-
|
|
147
|
-
```typescript
|
|
148
|
-
deleteClass(className: string): Promise<OperationResult>
|
|
149
|
-
```
|
|
150
|
-
|
|
151
|
-
Deletes a class.
|
|
152
|
-
|
|
153
|
-
#### Lock/Unlock
|
|
154
|
-
|
|
155
|
-
```typescript
|
|
156
|
-
lockClass(className: string): Promise<string>
|
|
157
|
-
unlockClass(className: string, lockHandle: string): Promise<OperationResult>
|
|
158
|
-
```
|
|
159
|
-
|
|
160
|
-
Lock and unlock class for editing.
|
|
161
|
-
|
|
162
|
-
## Types
|
|
163
|
-
|
|
164
|
-
### ClassMetadata
|
|
165
|
-
|
|
166
|
-
```typescript
|
|
167
|
-
interface ClassMetadata {
|
|
168
|
-
name: string;
|
|
169
|
-
description?: string;
|
|
170
|
-
packageName?: string;
|
|
171
|
-
responsible?: string;
|
|
172
|
-
createdBy?: string;
|
|
173
|
-
createdAt?: string;
|
|
174
|
-
changedBy?: string;
|
|
175
|
-
changedAt?: string;
|
|
176
|
-
final?: boolean;
|
|
177
|
-
abstract?: boolean;
|
|
178
|
-
visibility?: 'public' | 'protected' | 'private';
|
|
179
|
-
}
|
|
180
|
-
```
|
|
181
|
-
|
|
182
|
-
### ClassIncludes
|
|
183
|
-
|
|
184
|
-
```typescript
|
|
185
|
-
interface ClassIncludes {
|
|
186
|
-
main?: string;
|
|
187
|
-
definitions?: string;
|
|
188
|
-
implementations?: string;
|
|
189
|
-
macros?: string;
|
|
190
|
-
testclasses?: string;
|
|
191
|
-
}
|
|
192
|
-
```
|
|
193
|
-
|
|
194
|
-
### ClassObject
|
|
195
|
-
|
|
196
|
-
```typescript
|
|
197
|
-
interface ClassObject {
|
|
198
|
-
metadata: ClassMetadata;
|
|
199
|
-
includes: ClassIncludes;
|
|
200
|
-
}
|
|
201
|
-
```
|
|
202
|
-
|
|
203
|
-
## Examples
|
|
204
|
-
|
|
205
|
-
### Read and Modify Class
|
|
206
|
-
|
|
207
|
-
```typescript
|
|
208
|
-
// Get class
|
|
209
|
-
const classObj = await client.getClass('ZCL_MY_CLASS');
|
|
210
|
-
|
|
211
|
-
// Modify source
|
|
212
|
-
const newSource = classObj.includes.main?.replace('OLD_TEXT', 'NEW_TEXT');
|
|
213
|
-
|
|
214
|
-
// Update
|
|
215
|
-
if (newSource) {
|
|
216
|
-
await client.updateMainSource('ZCL_MY_CLASS', newSource);
|
|
217
|
-
}
|
|
218
|
-
```
|
|
219
|
-
|
|
220
|
-
### Create New Class
|
|
221
|
-
|
|
222
|
-
```typescript
|
|
223
|
-
await client.createClass('ZCL_NEW_CLASS', {
|
|
224
|
-
description: 'My new class',
|
|
225
|
-
packageName: 'ZPACKAGE',
|
|
226
|
-
visibility: 'public',
|
|
227
|
-
final: false,
|
|
228
|
-
abstract: false,
|
|
229
|
-
});
|
|
230
|
-
```
|
|
231
|
-
|
|
232
|
-
### Lock, Edit, Unlock Pattern
|
|
233
|
-
|
|
234
|
-
```typescript
|
|
235
|
-
// Lock class
|
|
236
|
-
const lockHandle = await client.lockClass('ZCL_MY_CLASS');
|
|
237
|
-
|
|
238
|
-
try {
|
|
239
|
-
// Edit class
|
|
240
|
-
await client.updateMainSource('ZCL_MY_CLASS', newSource);
|
|
241
|
-
} finally {
|
|
242
|
-
// Always unlock
|
|
243
|
-
await client.unlockClass('ZCL_MY_CLASS', lockHandle);
|
|
244
|
-
}
|
|
245
|
-
```
|
|
246
|
-
|
|
247
|
-
## Architecture
|
|
248
|
-
|
|
249
|
-
### Two-Layer Design
|
|
250
|
-
|
|
251
|
-
```typescript
|
|
252
|
-
const client = createAdtClient({...});
|
|
253
|
-
|
|
254
|
-
// Layer 1: Low-level contracts (direct ADT REST access)
|
|
255
|
-
client.adt.core.http.sessions.getSession()
|
|
256
|
-
client.adt.cts.transportrequests.getTransport(id)
|
|
257
|
-
|
|
258
|
-
// Layer 2: High-level services (business logic)
|
|
259
|
-
client.services.transports.importAndActivate(transportId) // Future
|
|
260
|
-
|
|
261
|
-
// Utility: Raw HTTP for debugging
|
|
262
|
-
client.fetch('/arbitrary/endpoint', { method: 'GET' })
|
|
263
|
-
```
|
|
264
|
-
|
|
265
|
-
**Contracts** - Thin, declarative HTTP definitions with 1:1 mapping to SAP ADT endpoints
|
|
266
|
-
**Services** - Business logic orchestration combining multiple contract calls
|
|
267
|
-
|
|
268
|
-
## Comparison with adt-client v1
|
|
29
|
+
## Features
|
|
269
30
|
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
| **Architecture** | Service-based | Contract-first |
|
|
274
|
-
| **Dependencies** | Many | Zero |
|
|
275
|
-
| **Extensibility** | Complex | Add contracts |
|
|
276
|
-
| **Testing** | Difficult | Easy (pure data) |
|
|
31
|
+
- Contract-driven, fully typed ADT REST client
|
|
32
|
+
- Security session, CSRF token, and cookie handling
|
|
33
|
+
- Basic, cookie (SSO), and bearer-token authentication
|
|
277
34
|
|
|
278
|
-
##
|
|
35
|
+
## Documentation
|
|
279
36
|
|
|
280
|
-
|
|
281
|
-
- **[adt-schemas](../adt-schemas)** - TypeScript schemas from SAP XSD
|
|
282
|
-
- **[speci](../speci)** - Contract specification system
|
|
283
|
-
- **[ts-xsd](../ts-xsd)** - XSD → TypeScript generation
|
|
37
|
+
**[adt-cli.netlify.app/sdk/packages/adt-client](https://adt-cli.netlify.app/sdk/packages/adt-client)**
|
|
284
38
|
|
|
285
|
-
|
|
39
|
+
---
|
|
286
40
|
|
|
287
|
-
|
|
41
|
+
Part of [**abapify**](https://github.com/abapify/adt-cli) — open, typed tooling for SAP ABAP Development Tools (ADT): CLI, MCP server, and SDK.
|
package/dist/index.d.mts
CHANGED
|
@@ -70,6 +70,10 @@ interface AdtConnectionConfig {
|
|
|
70
70
|
logger?: Logger$1;
|
|
71
71
|
/** Override Undici's response-header timeout for long-running SAP requests. */
|
|
72
72
|
headersTimeoutMs?: number;
|
|
73
|
+
/** TCP/TLS connect timeout for the undici dispatcher (default undici 10s). */
|
|
74
|
+
connectTimeoutMs?: number;
|
|
75
|
+
/** Skip TLS certificate verification (self-signed SAP systems). */
|
|
76
|
+
insecure?: boolean;
|
|
73
77
|
}
|
|
74
78
|
interface LockHandle {
|
|
75
79
|
lockHandle: string;
|
|
@@ -112,7 +116,7 @@ interface ResponsePlugin {
|
|
|
112
116
|
* @param context - Response context with raw and parsed data
|
|
113
117
|
* @returns Modified data or original data
|
|
114
118
|
*/
|
|
115
|
-
process(context: ResponseContext):
|
|
119
|
+
process(context: ResponseContext): unknown;
|
|
116
120
|
}
|
|
117
121
|
/**
|
|
118
122
|
* Extended ADT connection config with plugins
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":["Logger","HttpAdapter","Logger","Logger"],"sources":["../src/errors.ts","../src/types.ts","../src/plugins/types.ts","../src/adapter.ts","../src/services/transports.ts","../src/services/users.ts","../src/services/source-history.ts","../src/client.ts","../src/cancellation.ts","../src/plugins/logging.ts","../src/plugins/file-logging.ts","../src/utils/session.ts"],"mappings":";;;;;;UA4BiB;;EAEf;;EAEA;;EAEA;;EAEA;;EAEA,aAAa;;;;;;;cAWF,iBAAiB;;WAEnB;;WAEA;;WAEA,YAAY;;WAEZ;;WAEA;;WAEA;EAEG,YAAA;IACV;IACA;IACA;IACA;IACA;IACA,YAAY;;;;;MA0BV;;;;EAWJ,OAAO;;;;EAOP,YAAY;;;;EAOZ,YAAY;;UChHG;EACf;EACA;EACA;EACA;EACA;EACA;EACA;EACA,SAASA;;EAET;;UAYe;EACf;EACA;;UAIe;EACf;EACA;;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":["Logger","HttpAdapter","Logger","Logger"],"sources":["../src/errors.ts","../src/types.ts","../src/plugins/types.ts","../src/adapter.ts","../src/services/transports.ts","../src/services/users.ts","../src/services/source-history.ts","../src/client.ts","../src/cancellation.ts","../src/plugins/logging.ts","../src/plugins/file-logging.ts","../src/utils/session.ts"],"mappings":";;;;;;UA4BiB;;EAEf;;EAEA;;EAEA;;EAEA;;EAEA,aAAa;;;;;;;cAWF,iBAAiB;;WAEnB;;WAEA;;WAEA,YAAY;;WAEZ;;WAEA;;WAEA;EAEG,YAAA;IACV;IACA;IACA;IACA;IACA;IACA,YAAY;;;;;MA0BV;;;;EAWJ,OAAO;;;;EAOP,YAAY;;;;EAOZ,YAAY;;UChHG;EACf;EACA;EACA;EACA;EACA;EACA;EACA;EACA,SAASA;;EAET;;EAEA;;EAEA;;UAYe;EACf;EACA;;UAIe;EACf;EACA;;;;;;;;UCnCe;;EAEf;;EAEA;;EAEA;;EAEA;;EAEA;;;;;UAMe;;;;EAIf;;;;;;;;EASA,QAAQ,SAAS;;;;;UCjBF,yBAAyB;;EAExC,UAAU;;;;;EAKV,yBAAyB;;;UAIV;EACf;EACA,UAAU;;;;;;cAOC,iCAAiC;WAIjC;WACA;WAJF;EAGE,YAAA,kBACA;;;;;;UAuII,uBAAuBC;;EAEtC,UAAU;;EAEV,gBACE,SAAS,2BACT,mBACC;;iBAGW,iBAAiB,QAAQ,mBAAmB;;;;UC3K3C;EACf;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,QAAQ;;UAGO;EACf;EACA;EACA;EACA;EACA;EACA;EACA;;;;;UAMe;EACf;EACA;EACA;EACA;EACA;;;;;UAMe;EACf;EACA;;;;;cAMW;mBACkB;EAAA,YAAA,KAAK;;;;EAK5B,KAAK,UAAU,wBAAwB,QAAQ;;;;EAa/C,IAAI,iBAAiB,QAAQ;;;;;;;;EAgEnC,OAAO,UAAU,yBAAyB,QAAQ;;;;EAc5C,OAAO,iBAAiB;;;;;;;EAU9B,QAAQ,kBAAkB;;;;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