@abapify/adt-contracts 0.0.0 → 0.3.5
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 +113 -1
- package/package.json +34 -3
package/README.md
CHANGED
|
@@ -1,3 +1,115 @@
|
|
|
1
1
|
# @abapify/adt-contracts
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://github.com/abapify/adt-cli/pkgs/npm/%40abapify%2Fadt-contracts)
|
|
4
|
+
|
|
5
|
+
**SAP ADT REST API contracts** — typed endpoint definitions using `speci` + `ts-xsd` schemas.
|
|
6
|
+
|
|
7
|
+
Part of the [abapify monorepo](../../README.md).
|
|
8
|
+
|
|
9
|
+
## What is it?
|
|
10
|
+
|
|
11
|
+
This package is the **contract layer** between `adt-client` and `adt-schemas`. It provides declarative REST API contracts for SAP ADT (ABAP Development Tools) endpoints.
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
┌─────────────────────────────────────────────────────────────────┐
|
|
15
|
+
│ adt-client │
|
|
16
|
+
│ (HTTP Client + Request Execution) │
|
|
17
|
+
└─────────────────────────────────────────────────────────────────┘
|
|
18
|
+
│
|
|
19
|
+
▼
|
|
20
|
+
┌─────────────────────────────────────────────────────────────────┐
|
|
21
|
+
│ adt-contracts (this package) │
|
|
22
|
+
│ (REST API Contracts using speci + ts-xsd) │
|
|
23
|
+
└─────────────────────────────────────────────────────────────────┘
|
|
24
|
+
│
|
|
25
|
+
▼
|
|
26
|
+
┌─────────────────────────────────────────────────────────────────┐
|
|
27
|
+
│ adt-schemas │
|
|
28
|
+
│ (TypeScript schemas from SAP XSD definitions) │
|
|
29
|
+
└─────────────────────────────────────────────────────────────────┘
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Contracts are pure data structures that define:
|
|
33
|
+
|
|
34
|
+
- **Endpoint URLs** - REST paths
|
|
35
|
+
- **HTTP methods** - GET, POST, PUT, DELETE
|
|
36
|
+
- **Request/Response schemas** - Using `ts-xsd` generated from SAP XSD definitions
|
|
37
|
+
- **Content-Types** - SAP vendor-specific media types
|
|
38
|
+
|
|
39
|
+
## Installation
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
bun add adt-contracts
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Usage
|
|
46
|
+
|
|
47
|
+
### With speci client
|
|
48
|
+
|
|
49
|
+
```typescript
|
|
50
|
+
import { adtContract } from 'adt-contracts';
|
|
51
|
+
import { createClient } from 'speci/rest';
|
|
52
|
+
|
|
53
|
+
const client = createClient(adtContract, {
|
|
54
|
+
baseUrl: 'https://sap-server.example.com/sap/bc/adt',
|
|
55
|
+
adapter: myAdapter,
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
// Full type inference from XSD schemas!
|
|
59
|
+
const transport = await client.cts.getTransportRequests();
|
|
60
|
+
const classInfo = await client.oo.getClass('ZCL_MY_CLASS');
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Individual contracts
|
|
64
|
+
|
|
65
|
+
```typescript
|
|
66
|
+
import { ctsContract, atcContract, ooContract } from 'adt-contracts';
|
|
67
|
+
|
|
68
|
+
// Use specific contracts
|
|
69
|
+
const cts = createClient(ctsContract, config);
|
|
70
|
+
const atc = createClient(atcContract, config);
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Available Contracts
|
|
74
|
+
|
|
75
|
+
| Contract | Description |
|
|
76
|
+
| -------------- | ------------------------------------- |
|
|
77
|
+
| `coreContract` | Core ADT object operations |
|
|
78
|
+
| `ctsContract` | Change and Transport System |
|
|
79
|
+
| `atcContract` | ABAP Test Cockpit |
|
|
80
|
+
| `ooContract` | Object-Oriented (classes, interfaces) |
|
|
81
|
+
|
|
82
|
+
## Architecture
|
|
83
|
+
|
|
84
|
+
```
|
|
85
|
+
adt-contracts (this package)
|
|
86
|
+
├── speci contracts (endpoint definitions)
|
|
87
|
+
└── adt-schemas (ts-xsd schemas)
|
|
88
|
+
└── ts-xsd (XSD → TypeScript)
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
**Contracts are pure data** - no HTTP client, no business logic. Use with any `speci`-compatible adapter.
|
|
92
|
+
|
|
93
|
+
## Adding New Contracts
|
|
94
|
+
|
|
95
|
+
1. Ensure schema exists in `adt-schemas`
|
|
96
|
+
2. Create contract file in `src/adt/<feature>/index.ts`
|
|
97
|
+
3. Define endpoints using `adtHttp.get/post/put/delete`
|
|
98
|
+
4. Export from `src/adt/index.ts`
|
|
99
|
+
|
|
100
|
+
```typescript
|
|
101
|
+
import { adtHttp } from '../../base';
|
|
102
|
+
import { mySchema } from 'adt-schemas';
|
|
103
|
+
|
|
104
|
+
export const myContract = {
|
|
105
|
+
getResource: (id: string) =>
|
|
106
|
+
adtHttp.get(`/my/endpoint/${id}`, {
|
|
107
|
+
responses: { 200: mySchema },
|
|
108
|
+
headers: { Accept: 'application/vnd.sap.adt.my.v1+xml' },
|
|
109
|
+
}),
|
|
110
|
+
};
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
## License
|
|
114
|
+
|
|
115
|
+
MIT
|
package/package.json
CHANGED
|
@@ -1,5 +1,36 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abapify/adt-contracts",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
5
|
-
|
|
3
|
+
"version": "0.3.5",
|
|
4
|
+
"description": "SAP ADT REST API contracts using speci + ts-xsd",
|
|
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
|
+
"./base": "./dist/base.mjs",
|
|
14
|
+
"./schemas": "./dist/schemas.mjs",
|
|
15
|
+
"./package.json": "./package.json"
|
|
16
|
+
},
|
|
17
|
+
"dependencies": {
|
|
18
|
+
"@abapify/speci": "0.3.5",
|
|
19
|
+
"@abapify/adt-schemas": "0.3.5"
|
|
20
|
+
},
|
|
21
|
+
"devDependencies": {
|
|
22
|
+
"@abapify/adt-fixtures": "0.3.5"
|
|
23
|
+
},
|
|
24
|
+
"files": [
|
|
25
|
+
"dist"
|
|
26
|
+
],
|
|
27
|
+
"repository": {
|
|
28
|
+
"type": "git",
|
|
29
|
+
"url": "git+https://github.com/abapify/adt-cli.git",
|
|
30
|
+
"directory": "packages/adt-contracts"
|
|
31
|
+
},
|
|
32
|
+
"homepage": "https://github.com/abapify/adt-cli/tree/main/packages/adt-contracts#readme",
|
|
33
|
+
"bugs": {
|
|
34
|
+
"url": "https://github.com/abapify/adt-cli/issues"
|
|
35
|
+
}
|
|
36
|
+
}
|