@abapify/adt-client 0.0.0 → 0.3.6
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 +283 -1
- package/package.json +31 -3
package/README.md
CHANGED
|
@@ -1,3 +1,285 @@
|
|
|
1
1
|
# @abapify/adt-client
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://github.com/abapify/adt-cli/pkgs/npm/%40abapify%2Fadt-client)
|
|
4
|
+
|
|
5
|
+
**Contract-driven SAP ADT REST client** — uses `speci` + `ts-xsd` for full type safety.
|
|
6
|
+
|
|
7
|
+
## Why v2?
|
|
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
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
bun add @abapify/adt-client
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Quick Start
|
|
53
|
+
|
|
54
|
+
```typescript
|
|
55
|
+
import { createAdtClient } from '@abapify/adt-client';
|
|
56
|
+
|
|
57
|
+
// Create client
|
|
58
|
+
const client = createAdtClient({
|
|
59
|
+
baseUrl: 'https://sap-system.com:8000',
|
|
60
|
+
username: 'YOUR_USER',
|
|
61
|
+
password: 'YOUR_PASS',
|
|
62
|
+
client: '100',
|
|
63
|
+
language: 'EN',
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
// Get complete class with all includes
|
|
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
|
+
|
|
93
|
+
### Class Operations
|
|
94
|
+
|
|
95
|
+
#### Get Complete Class
|
|
96
|
+
|
|
97
|
+
```typescript
|
|
98
|
+
getClass(className: string): Promise<ClassObject>
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
Returns class metadata and all includes (main, definitions, implementations, macros, testclasses).
|
|
102
|
+
|
|
103
|
+
#### Get Metadata Only
|
|
104
|
+
|
|
105
|
+
```typescript
|
|
106
|
+
getMetadata(className: string): Promise<ClassMetadata>
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
Returns class metadata (name, description, package, etc.).
|
|
110
|
+
|
|
111
|
+
#### Get All Includes
|
|
112
|
+
|
|
113
|
+
```typescript
|
|
114
|
+
getIncludes(className: string): Promise<ClassIncludes>
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
Returns all class source includes.
|
|
118
|
+
|
|
119
|
+
#### Get Specific Include
|
|
120
|
+
|
|
121
|
+
```typescript
|
|
122
|
+
getInclude(className: string, includeType: 'main' | 'definitions' | 'implementations' | 'macros' | 'testclasses'): Promise<string>
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
Returns specific include source code.
|
|
126
|
+
|
|
127
|
+
#### Update Main Source
|
|
128
|
+
|
|
129
|
+
```typescript
|
|
130
|
+
updateMainSource(className: string, source: string): Promise<OperationResult>
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
Updates the main class source code.
|
|
134
|
+
|
|
135
|
+
#### Create Class
|
|
136
|
+
|
|
137
|
+
```typescript
|
|
138
|
+
createClass(className: string, metadata: Partial<ClassMetadata>): Promise<OperationResult>
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
Creates a new class with specified metadata.
|
|
142
|
+
|
|
143
|
+
#### Delete Class
|
|
144
|
+
|
|
145
|
+
```typescript
|
|
146
|
+
deleteClass(className: string): Promise<OperationResult>
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
Deletes a class.
|
|
150
|
+
|
|
151
|
+
#### Lock/Unlock
|
|
152
|
+
|
|
153
|
+
```typescript
|
|
154
|
+
lockClass(className: string): Promise<string>
|
|
155
|
+
unlockClass(className: string, lockHandle: string): Promise<OperationResult>
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
Lock and unlock class for editing.
|
|
159
|
+
|
|
160
|
+
## Types
|
|
161
|
+
|
|
162
|
+
### ClassMetadata
|
|
163
|
+
|
|
164
|
+
```typescript
|
|
165
|
+
interface ClassMetadata {
|
|
166
|
+
name: string;
|
|
167
|
+
description?: string;
|
|
168
|
+
packageName?: string;
|
|
169
|
+
responsible?: string;
|
|
170
|
+
createdBy?: string;
|
|
171
|
+
createdAt?: string;
|
|
172
|
+
changedBy?: string;
|
|
173
|
+
changedAt?: string;
|
|
174
|
+
final?: boolean;
|
|
175
|
+
abstract?: boolean;
|
|
176
|
+
visibility?: 'public' | 'protected' | 'private';
|
|
177
|
+
}
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
### ClassIncludes
|
|
181
|
+
|
|
182
|
+
```typescript
|
|
183
|
+
interface ClassIncludes {
|
|
184
|
+
main?: string;
|
|
185
|
+
definitions?: string;
|
|
186
|
+
implementations?: string;
|
|
187
|
+
macros?: string;
|
|
188
|
+
testclasses?: string;
|
|
189
|
+
}
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
### ClassObject
|
|
193
|
+
|
|
194
|
+
```typescript
|
|
195
|
+
interface ClassObject {
|
|
196
|
+
metadata: ClassMetadata;
|
|
197
|
+
includes: ClassIncludes;
|
|
198
|
+
}
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
## Examples
|
|
202
|
+
|
|
203
|
+
### Read and Modify Class
|
|
204
|
+
|
|
205
|
+
```typescript
|
|
206
|
+
// Get class
|
|
207
|
+
const classObj = await client.getClass('ZCL_MY_CLASS');
|
|
208
|
+
|
|
209
|
+
// Modify source
|
|
210
|
+
const newSource = classObj.includes.main?.replace('OLD_TEXT', 'NEW_TEXT');
|
|
211
|
+
|
|
212
|
+
// Update
|
|
213
|
+
if (newSource) {
|
|
214
|
+
await client.updateMainSource('ZCL_MY_CLASS', newSource);
|
|
215
|
+
}
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
### Create New Class
|
|
219
|
+
|
|
220
|
+
```typescript
|
|
221
|
+
await client.createClass('ZCL_NEW_CLASS', {
|
|
222
|
+
description: 'My new class',
|
|
223
|
+
packageName: 'ZPACKAGE',
|
|
224
|
+
visibility: 'public',
|
|
225
|
+
final: false,
|
|
226
|
+
abstract: false,
|
|
227
|
+
});
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
### Lock, Edit, Unlock Pattern
|
|
231
|
+
|
|
232
|
+
```typescript
|
|
233
|
+
// Lock class
|
|
234
|
+
const lockHandle = await client.lockClass('ZCL_MY_CLASS');
|
|
235
|
+
|
|
236
|
+
try {
|
|
237
|
+
// Edit class
|
|
238
|
+
await client.updateMainSource('ZCL_MY_CLASS', newSource);
|
|
239
|
+
} finally {
|
|
240
|
+
// Always unlock
|
|
241
|
+
await client.unlockClass('ZCL_MY_CLASS', lockHandle);
|
|
242
|
+
}
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
## Architecture
|
|
246
|
+
|
|
247
|
+
### Two-Layer Design
|
|
248
|
+
|
|
249
|
+
```typescript
|
|
250
|
+
const client = createAdtClient({...});
|
|
251
|
+
|
|
252
|
+
// Layer 1: Low-level contracts (direct ADT REST access)
|
|
253
|
+
client.adt.core.http.sessions.getSession()
|
|
254
|
+
client.adt.cts.transportrequests.getTransport(id)
|
|
255
|
+
|
|
256
|
+
// Layer 2: High-level services (business logic)
|
|
257
|
+
client.services.transports.importAndActivate(transportId) // Future
|
|
258
|
+
|
|
259
|
+
// Utility: Raw HTTP for debugging
|
|
260
|
+
client.fetch('/arbitrary/endpoint', { method: 'GET' })
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
**Contracts** - Thin, declarative HTTP definitions with 1:1 mapping to SAP ADT endpoints
|
|
264
|
+
**Services** - Business logic orchestration combining multiple contract calls
|
|
265
|
+
|
|
266
|
+
## Comparison with adt-client v1
|
|
267
|
+
|
|
268
|
+
| Feature | v1 (Legacy) | v2 (New) |
|
|
269
|
+
| ----------------- | ------------- | ------------------ |
|
|
270
|
+
| **Type Safety** | Manual types | Generated from XSD |
|
|
271
|
+
| **Architecture** | Service-based | Contract-first |
|
|
272
|
+
| **Dependencies** | Many | Zero |
|
|
273
|
+
| **Extensibility** | Complex | Add contracts |
|
|
274
|
+
| **Testing** | Difficult | Easy (pure data) |
|
|
275
|
+
|
|
276
|
+
## Related Packages
|
|
277
|
+
|
|
278
|
+
- **[adt-contracts](../adt-contracts)** - REST API contracts (speci + ts-xsd)
|
|
279
|
+
- **[adt-schemas](../adt-schemas)** - TypeScript schemas from SAP XSD
|
|
280
|
+
- **[speci](../speci)** - Contract specification system
|
|
281
|
+
- **[ts-xsd](../ts-xsd)** - XSD → TypeScript generation
|
|
282
|
+
|
|
283
|
+
## License
|
|
284
|
+
|
|
285
|
+
MIT
|
package/package.json
CHANGED
|
@@ -1,5 +1,33 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abapify/adt-client",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
5
|
-
|
|
3
|
+
"version": "0.3.6",
|
|
4
|
+
"description": "Minimalistic speci-based ADT client for SAP ABAP Development Tools",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"publishConfig": {
|
|
7
|
+
"access": "public"
|
|
8
|
+
},
|
|
9
|
+
"type": "module",
|
|
10
|
+
"types": "./dist/index.d.mts",
|
|
11
|
+
"exports": {
|
|
12
|
+
".": "./dist/index.mjs",
|
|
13
|
+
"./package.json": "./package.json"
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist",
|
|
17
|
+
"README.md"
|
|
18
|
+
],
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"@abapify/logger": "0.3.6",
|
|
21
|
+
"@abapify/adt-contracts": "0.3.6",
|
|
22
|
+
"@abapify/adt-schemas": "0.3.6"
|
|
23
|
+
},
|
|
24
|
+
"repository": {
|
|
25
|
+
"type": "git",
|
|
26
|
+
"url": "git+https://github.com/abapify/adt-cli.git",
|
|
27
|
+
"directory": "packages/adt-client"
|
|
28
|
+
},
|
|
29
|
+
"homepage": "https://github.com/abapify/adt-cli/tree/main/packages/adt-client#readme",
|
|
30
|
+
"bugs": {
|
|
31
|
+
"url": "https://github.com/abapify/adt-cli/issues"
|
|
32
|
+
}
|
|
33
|
+
}
|