@abapify/adt-schemas 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.
Files changed (2) hide show
  1. package/README.md +360 -1
  2. package/package.json +32 -3
package/README.md CHANGED
@@ -1,3 +1,362 @@
1
1
  # @abapify/adt-schemas
2
2
 
3
- Placeholder. The real release is published via CI/CD.
3
+ [![version](https://img.shields.io/github/package-json/v/abapify/adt-cli?filename=packages/adt-schemas/package.json)](https://github.com/abapify/adt-cli/pkgs/npm/%40abapify%2Fadt-schemas)
4
+
5
+ **Type-safe SAP ADT schemas** generated from official XSD definitions with **shared types** and **optimal tree-shaking**.
6
+
7
+ ## Overview
8
+
9
+ This package provides TypeScript schemas for SAP ADT (ABAP Development Tools) REST APIs, auto-generated from SAP's official XSD schema definitions using [@abapify/ts-xsd](../ts-xsd/README.md).
10
+
11
+ ### Key Features
12
+
13
+ - **204+ TypeScript interfaces** - Pre-generated, no runtime inference overhead
14
+ - **Shared types across schemas** - `AdtObject`, `LinkType`, etc. are defined once
15
+ - **Optimal bundling** - Tree-shakeable, import only what you need
16
+ - **Full type safety** - Compile-time validation of XML parsing/building
17
+ - **speci integration** - Works directly with REST contract definitions
18
+
19
+ ### Architecture Highlights
20
+
21
+ ```
22
+ XSD Files (SAP Official)
23
+ ↓ ts-xsd codegen
24
+ Schema Literals (as const)
25
+ ↓ interface generator
26
+ TypeScript Interfaces (204 types)
27
+ ↓ typed() wrapper
28
+ Typed Schemas (parse/build)
29
+ ```
30
+
31
+ **Single source of truth**: All type definitions flow from XSD → TypeScript, eliminating manual type maintenance.
32
+
33
+ ## Installation
34
+
35
+ ```bash
36
+ npm install @abapify/adt-schemas
37
+ # or
38
+ bun add @abapify/adt-schemas
39
+ ```
40
+
41
+ ## Quick Start
42
+
43
+ ### Parse ADT XML
44
+
45
+ ```typescript
46
+ import { classes, type AbapClass } from '@abapify/adt-schemas';
47
+
48
+ // Parse XML to typed object
49
+ const xml = await fetch('/sap/bc/adt/oo/classes/zcl_my_class').then((r) =>
50
+ r.text(),
51
+ );
52
+ const data = classes.parse(xml);
53
+
54
+ // Full type safety - TypeScript knows all properties
55
+ console.log(data.name); // string
56
+ console.log(data.category); // 'generalObjectType' | 'exceptionClass' | ...
57
+ console.log(data.include?.[0]); // AbapClassInclude | undefined
58
+ ```
59
+
60
+ ### Build ADT XML
61
+
62
+ ```typescript
63
+ import { classes } from '@abapify/adt-schemas';
64
+
65
+ const xml = classes.build({
66
+ name: 'ZCL_MY_CLASS',
67
+ type: 'CLAS/OC',
68
+ category: 'generalObjectType',
69
+ final: false,
70
+ abstract: false,
71
+ });
72
+ ```
73
+
74
+ ### Use with speci Contracts
75
+
76
+ ```typescript
77
+ import { classes, configurations } from '@abapify/adt-schemas';
78
+ import { http } from 'speci/rest';
79
+
80
+ const adtContracts = {
81
+ getClass: (name: string) =>
82
+ http.get(`/sap/bc/adt/oo/classes/${name}`, {
83
+ responses: { 200: classes },
84
+ }),
85
+
86
+ getConfigurations: () =>
87
+ http.get(
88
+ '/sap/bc/adt/cts/transportrequests/searchconfiguration/configurations',
89
+ {
90
+ responses: { 200: configurations },
91
+ },
92
+ ),
93
+ };
94
+ ```
95
+
96
+ ## Available Schemas
97
+
98
+ ### Core Schemas
99
+
100
+ | Schema | Type | Description |
101
+ | ------------ | ------------------ | ------------------------------------ |
102
+ | `adtcore` | `AdtObject` | Core ADT object types |
103
+ | `atom` | `LinkType` | Atom feed format (links, categories) |
104
+ | `abapsource` | `AbapSourceObject` | ABAP source code structures |
105
+ | `abapoo` | `AbapOoObject` | ABAP OO base types |
106
+
107
+ ### Repository Objects
108
+
109
+ | Schema | Type | Description |
110
+ | ------------ | --------------- | ------------------------- |
111
+ | `classes` | `AbapClass` | ABAP class metadata |
112
+ | `interfaces` | `AbapInterface` | ABAP interface metadata |
113
+ | `packagesV1` | `Package` | Package/devclass metadata |
114
+
115
+ ### Transport Management
116
+
117
+ | Schema | Type | Description |
118
+ | -------------------------- | ---------------- | ---------------------------------- |
119
+ | `transportfind` | `Abap` | Transport search (ABAP XML format) |
120
+ | `transportmanagmentCreate` | `RootType` | Transport creation |
121
+ | `configurations` | `Configurations` | Search configurations |
122
+ | `configuration` | `Configuration` | Single configuration |
123
+
124
+ ### ATC (ABAP Test Cockpit)
125
+
126
+ | Schema | Type | Description |
127
+ | ------------- | ------------------ | ------------------- |
128
+ | `atc` | `AtcWorklist` | ATC main schema |
129
+ | `atcworklist` | `AtcWorklist` | ATC worklist |
130
+ | `atcresult` | `AtcWorklist` | ATC results |
131
+ | `checklist` | `CheckMessageList` | Check message lists |
132
+ | `quickfixes` | `AtcQuickfixes` | ATC quickfixes |
133
+
134
+ ### Debugging & Tracing
135
+
136
+ | Schema | Type | Description |
137
+ | ---------- | ------------- | -------------------- |
138
+ | `logpoint` | `AdtLogpoint` | Logpoint definitions |
139
+ | `traces` | `Traces` | Trace data |
140
+
141
+ ### Templates
142
+
143
+ | Schema | Type | Description |
144
+ | ---------------------- | ------------------- | ----------------------- |
145
+ | `templatelink` | `LinkType` | Template links |
146
+ | `templatelinkExtended` | `TemplateLinksType` | Extended template links |
147
+
148
+ ## Type System
149
+
150
+ ### Pre-generated Interfaces
151
+
152
+ All types are pre-generated as TypeScript interfaces, avoiding runtime inference overhead:
153
+
154
+ ```typescript
155
+ // Import types directly
156
+ import type {
157
+ AbapClass,
158
+ AbapInterface,
159
+ AdtObject,
160
+ AdtObjectReference,
161
+ LinkType,
162
+ } from '@abapify/adt-schemas';
163
+
164
+ // Use in your code
165
+ function processClass(cls: AbapClass) {
166
+ console.log(cls.name);
167
+ console.log(cls.superClassRef?.name);
168
+ cls.include?.forEach((inc) => console.log(inc.includeType));
169
+ }
170
+ ```
171
+
172
+ ### Shared Types
173
+
174
+ Types are shared across schemas - `AdtObject` is defined once and reused:
175
+
176
+ ```typescript
177
+ // All these extend AdtObject
178
+ interface AbapSourceObject extends AdtObject { ... }
179
+ interface AbapOoObject extends AbapSourceMainObject { ... }
180
+ interface AbapClass extends AbapOoObject { ... }
181
+ interface AbapInterface extends AbapOoObject { ... }
182
+ ```
183
+
184
+ ### Type Hierarchy
185
+
186
+ ```
187
+ AdtObject
188
+ ├── AdtMainObject
189
+ │ └── AbapSourceMainObject
190
+ │ └── AbapOoObject
191
+ │ ├── AbapClass
192
+ │ └── AbapInterface
193
+ └── AbapSourceObject
194
+ └── AbapClassInclude
195
+ ```
196
+
197
+ ## Schema Structure
198
+
199
+ Each schema is a W3C-compliant XSD representation with linked imports:
200
+
201
+ ```typescript
202
+ // Generated schema literal (classes.ts)
203
+ export default {
204
+ $xmlns: {
205
+ adtcore: "http://www.sap.com/adt/core",
206
+ abapoo: "http://www.sap.com/adt/oo",
207
+ class: "http://www.sap.com/adt/oo/classes",
208
+ },
209
+ $imports: [adtcore, abapoo, abapsource], // Linked schemas
210
+ targetNamespace: "http://www.sap.com/adt/oo/classes",
211
+ element: [
212
+ { name: "abapClass", type: "class:AbapClass" },
213
+ ],
214
+ complexType: [
215
+ {
216
+ name: "AbapClass",
217
+ complexContent: {
218
+ extension: {
219
+ base: "abapoo:AbapOoObject", // Type inheritance
220
+ sequence: { element: [...] },
221
+ attribute: [...],
222
+ }
223
+ }
224
+ }
225
+ ],
226
+ } as const;
227
+ ```
228
+
229
+ ### Cross-Schema Type Resolution
230
+
231
+ The `$imports` array enables cross-schema type resolution:
232
+
233
+ ```typescript
234
+ // classes schema imports adtcore, abapoo, abapsource
235
+ // Type "adtcore:AdtObjectReference" resolves to AdtObjectReference interface
236
+ // Type "abapoo:AbapOoObject" resolves to AbapOoObject interface
237
+ ```
238
+
239
+ ## Architecture
240
+
241
+ ```
242
+ @abapify/adt-schemas
243
+ ├── src/
244
+ │ ├── index.ts # Main exports
245
+ │ ├── speci.ts # typed() wrapper factory
246
+ │ └── schemas/
247
+ │ ├── index.ts # Re-exports from generated
248
+ │ └── generated/
249
+ │ ├── index.ts # Typed schema exports
250
+ │ ├── schemas/
251
+ │ │ ├── sap/ # SAP official schemas (23 files)
252
+ │ │ └── custom/ # Custom schemas (9 files)
253
+ │ └── types/
254
+ │ └── index.ts # 204 TypeScript interfaces
255
+ ```
256
+
257
+ ### Generation Pipeline
258
+
259
+ ```
260
+ 1. Download XSD → .xsd/model/*.xsd
261
+ 2. Parse XSD → Schema objects (ts-xsd)
262
+ 3. Generate Literal → schemas/sap/*.ts (as const)
263
+ 4. Generate Types → types/index.ts (interfaces)
264
+ 5. Wrap with typed()→ index.ts (parse/build methods)
265
+ ```
266
+
267
+ ## Custom Schemas (ABAP XML Format)
268
+
269
+ Some SAP endpoints return ABAP XML format (`asx:abap` envelope) without official XSD. Create manual schemas in `src/schemas/generated/schemas/custom/`:
270
+
271
+ ```typescript
272
+ // schemas/custom/transportfind.ts
273
+ export default {
274
+ $xmlns: { asx: 'http://www.sap.com/abapxml' },
275
+ targetNamespace: 'http://www.sap.com/abapxml',
276
+ element: [{ name: 'abap', type: 'Abap' }],
277
+ complexType: [
278
+ {
279
+ name: 'Abap',
280
+ sequence: {
281
+ element: [{ name: 'values', type: 'Values' }],
282
+ },
283
+ attribute: [{ name: 'version', type: 'xs:string' }],
284
+ },
285
+ ],
286
+ // ... more types
287
+ } as const; // CRITICAL: 'as const' required!
288
+ ```
289
+
290
+ ### Key Points
291
+
292
+ 1. **`as const`** - Required for type inference
293
+ 2. **Element names without prefix** - Use `'abap'`, not `'asx:abap'`
294
+ 3. **Add to typed index** - Register in `generated/index.ts`
295
+
296
+ ## Development
297
+
298
+ ### Regenerate Schemas
299
+
300
+ ```bash
301
+ # Full regeneration pipeline
302
+ npx nx run adt-schemas:generate
303
+
304
+ # Individual steps
305
+ npx nx run adt-schemas:download # Download XSD files
306
+ npx nx run adt-schemas:codegen # Generate schema literals
307
+ npx nx run adt-schemas:types # Generate TypeScript interfaces
308
+ ```
309
+
310
+ ### Add New Schema
311
+
312
+ 1. Add XSD to `.xsd/model/sap/` or create custom schema
313
+ 2. Update generation config
314
+ 3. Run `npx nx run adt-schemas:generate`
315
+ 4. Add typed wrapper in `generated/index.ts`
316
+ 5. **Add test scenario** (mandatory)
317
+
318
+ ### Testing
319
+
320
+ ```bash
321
+ # Run all tests
322
+ npx nx test adt-schemas
323
+
324
+ # Run specific test
325
+ npx vitest run tests/scenarios.test.ts
326
+ ```
327
+
328
+ Every schema **must** have a test scenario with real SAP XML fixtures.
329
+
330
+ ## speci Integration
331
+
332
+ Schemas implement the `Serializable` interface for seamless speci integration:
333
+
334
+ ```typescript
335
+ interface Serializable<T> {
336
+ parse(raw: string): T;
337
+ build?(data: T): string;
338
+ }
339
+ ```
340
+
341
+ This enables automatic type inference in REST contracts:
342
+
343
+ ```typescript
344
+ import { classes } from '@abapify/adt-schemas';
345
+
346
+ const contract = http.get('/sap/bc/adt/oo/classes/zcl_test', {
347
+ responses: { 200: classes },
348
+ });
349
+
350
+ // Response type is automatically inferred as AbapClass
351
+ const response = await client.execute(contract);
352
+ console.log(response.data.name); // TypeScript knows this is string
353
+ ```
354
+
355
+ ## Related Packages
356
+
357
+ - **[@abapify/ts-xsd](../ts-xsd)** - Core XSD parser and type inference
358
+ - **[speci](../speci)** - REST contract library
359
+
360
+ ## License
361
+
362
+ MIT
package/package.json CHANGED
@@ -1,5 +1,34 @@
1
1
  {
2
2
  "name": "@abapify/adt-schemas",
3
- "version": "0.0.0",
4
- "description": "Placeholder — real package is published via CI/CD (trusted publishing)."
5
- }
3
+ "version": "0.3.5",
4
+ "description": "ADT XML schemas generated from SAP XSD definitions",
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
+ "dependencies": {
16
+ "@abapify/ts-xsd": "0.3.5",
17
+ "zod": "^3.24.0 || ^4.0.0"
18
+ },
19
+ "devDependencies": {
20
+ "@abapify/adt-fixtures": "0.3.5"
21
+ },
22
+ "files": [
23
+ "dist"
24
+ ],
25
+ "repository": {
26
+ "type": "git",
27
+ "url": "git+https://github.com/abapify/adt-cli.git",
28
+ "directory": "packages/adt-schemas"
29
+ },
30
+ "homepage": "https://github.com/abapify/adt-cli/tree/main/packages/adt-schemas#readme",
31
+ "bugs": {
32
+ "url": "https://github.com/abapify/adt-cli/issues"
33
+ }
34
+ }