@abapify/adt-plugin-abapgit 0.4.34 → 0.4.38

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 CHANGED
@@ -1,191 +1,40 @@
1
1
  # @abapify/adt-plugin-abapgit
2
2
 
3
- [![version](https://img.shields.io/github/package-json/v/abapify/adt-cli?filename=packages/adt-plugin-abapgit/package.json)](https://github.com/abapify/adt-cli/pkgs/npm/%40abapify%2Fadt-plugin-abapgit)
3
+ [![npm](https://img.shields.io/npm/v/%40abapify%2Fadt-plugin-abapgit)](https://www.npmjs.com/package/@abapify/adt-plugin-abapgit)
4
+ [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/abapify/adt-cli/blob/main/LICENSE)
4
5
 
5
- abapGit format plugin for ADT — serializes ABAP objects to Git-compatible XML/ABAP files.
6
+ abapGit serialization plugin for adt-cli — round-trips ADT objects to/from the abapGit on-disk format.
6
7
 
7
- ## Pure materialization
8
+ ## Install
8
9
 
9
- The registered `abapgitFormatPlugin` can produce a desired object tree without
10
- filesystem, ADT, or Git side effects. Explicit source components override
11
- mutable ADK source getters, while existing XSD-backed handlers continue to
12
- produce metadata:
10
+ ```bash
11
+ npm install @abapify/adt-plugin-abapgit
12
+ ```
13
+
14
+ ## Usage
15
+
16
+ ```ts
17
+ import { abapgitFormatPlugin } from '@abapify/adt-plugin-abapgit';
13
18
 
14
- ```typescript
15
19
  const { files } = await abapgitFormatPlugin.materialize({
16
20
  object: adkClass,
17
21
  objectType: 'CLAS',
18
- packagePath: ['ZROOT', 'ZROOT_FEATURE'],
19
- sources: {
20
- main: selectedMainSource,
21
- definitions: selectedLocalDefinitions,
22
- },
22
+ packagePath: ['ZROOT'],
23
+ sources: { main: source },
23
24
  formatOptions: { folderLogic: 'prefix' },
24
25
  });
25
26
  ```
26
27
 
27
- Paths are rooted below `src/`, ordered deterministically, and annotated with
28
- their semantic role and source-component identity. Existing filesystem import
29
- and Git-to-SAP export APIs remain unchanged.
30
-
31
- ## Architecture Overview
32
-
33
- ```
34
- ┌─────────────────────────────────────────────────────────────────────┐
35
- │ adt-plugin-abapgit │
36
- ├─────────────────────────────────────────────────────────────────────┤
37
- │ XSD Schemas (xsd/) → ts-xsd codegen → TypeScript types │
38
- │ (XML structure definition) (build time) + parser/builder │
39
- ├─────────────────────────────────────────────────────────────────────┤
40
- │ Object Handlers (handlers/) │
41
- │ ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐ │
42
- │ │ CLAS │ │ INTF │ │ DEVC │ │ DTEL │ │ DOMA │ │
43
- │ │ handler │ │ handler │ │ handler │ │ handler │ │ handler │ │
44
- │ └────┬────┘ └────┬────┘ └────┬────┘ └────┬────┘ └────┬────┘ │
45
- │ └──────────┬┴──────────┬┴──────────┬┴──────────┘ │
46
- │ ▼ ▼ ▼ │
47
- │ createHandler (factory) │
48
- │ - Auto-registration │
49
- │ - Default serialize logic │
50
- │ - File naming conventions │
51
- ├─────────────────────────────────────────────────────────────────────┤
52
- │ ADK Facade (@abapify/adk) │
53
- │ - AdkClass, AdkInterface, AdkPackage... │
54
- │ - Client-agnostic object model │
55
- │ - Source code retrieval via getSource()/getIncludeSource() │
56
- └─────────────────────────────────────────────────────────────────────┘
57
- ```
58
-
59
- ## Key Design Decisions
60
-
61
- ### 1. XSD Schemas as Single Source of Truth
62
-
63
- **Why XSD?**
64
-
65
- - XML Schema Definition (XSD) is the **industry standard** for XML structure validation
66
- - Can be used **outside our tools** (e.g., `xmllint --schema intf.xsd file.xml`)
67
- - Provides **formal contract** for abapGit XML format
68
- - Enables **automated validation** in CI/CD pipelines
69
-
70
- ```bash
71
- # Validate any abapGit XML file against our schema
72
- xmllint --schema xsd/intf.xsd myinterface.intf.xml --noout
73
- ```
74
-
75
- ### 2. ts-xsd for Type-Safe XML Handling
76
-
77
- **Why ts-xsd?**
78
-
79
- Unlike typical XML codegen tools that only generate types, `ts-xsd` provides:
80
-
81
- - **TypeScript types** with full type inference
82
- - **XML parser** that returns typed objects
83
- - **XML builder** that accepts typed objects
84
- - **Schema object** for runtime validation
85
-
86
- ```typescript
87
- // Generated from XSD - fully typed parse/build
88
- import { intf } from './schemas/generated';
89
-
90
- const data = intf.parse(xmlString); // → AbapGitIntf (typed)
91
- const xml = intf.build(data); // → string (valid XML)
92
- ```
93
-
94
- ### 3. ADK as Client-Agnostic Facade
95
-
96
- **Why not implement ADT client features in the plugin?**
97
-
98
- The plugin **only consumes** the ADK facade:
99
-
100
- - ADK handles all SAP communication details
101
- - Plugin focuses purely on **serialization format**
102
- - Same plugin works with any ADT client implementation
103
- - Clear separation of concerns
104
-
105
- ```typescript
106
- // Plugin receives ADK objects, doesn't care how they were fetched
107
- getSources: (cls) =>
108
- cls.includes.map((inc) => ({
109
- suffix: ABAPGIT_SUFFIX[inc.includeType],
110
- content: cls.getIncludeSource(inc.includeType), // ADK handles this
111
- }));
112
- ```
113
-
114
- ### 4. Handlers Don't Touch File System
115
-
116
- **Why delegate file operations to base class?**
117
-
118
- Object handlers **only define mappings**:
119
-
120
- - `toAbapGit()` - ADK data → abapGit XML structure
121
- - `getSource()` / `getSources()` - which source files to create
122
-
123
- The `createHandler` factory handles:
124
-
125
- - File creation with correct naming
126
- - XML building with proper envelope
127
- - Promise resolution for async sources
128
- - Empty content filtering
129
-
130
- ## Supported Object Types
131
-
132
- | Type | Status | Handler | Notes |
133
- | ---- | ------ | --------- | --------------------------------------------------------------------- |
134
- | CLAS | ✅ | `clas.ts` | Multiple includes (main, locals_def, locals_imp, testclasses, macros) |
135
- | INTF | ✅ | `intf.ts` | Single source file |
136
- | DEVC | ✅ | `devc.ts` | Fixed filename `package.devc.xml` |
137
- | DTEL | ✅ | `dtel.ts` | Metadata only (no source) |
138
- | DOMA | ✅ | `doma.ts` | Custom serialize for fixed values |
139
-
140
- ## File Structure
141
-
142
- ```
143
- src/
144
- ├── zcl_example.clas.abap # Main class source
145
- ├── zcl_example.clas.locals_def.abap # Local type definitions
146
- ├── zcl_example.clas.locals_imp.abap # Local implementations
147
- ├── zcl_example.clas.testclasses.abap # Test classes
148
- ├── zcl_example.clas.xml # Class metadata
149
- ├── zif_example.intf.abap # Interface source
150
- ├── zif_example.intf.xml # Interface metadata
151
- ├── ztest_dtel.dtel.xml # Data element (no source)
152
- ├── ztest_doma.doma.xml # Domain (no source)
153
- └── package.devc.xml # Package definition
154
- ```
155
-
156
- ## Development
157
-
158
- ### Building
159
-
160
- ```bash
161
- npx nx build adt-plugin-abapgit
162
- ```
163
-
164
- ### Testing
165
-
166
- ```bash
167
- npx nx test adt-plugin-abapgit
168
- ```
169
-
170
- ### Regenerating Schemas
171
-
172
- After modifying XSD files:
173
-
174
- ```bash
175
- npx nx codegen adt-plugin-abapgit
176
- ```
28
+ ## Features
177
29
 
178
- ## Contributing
30
+ - Round-trips ADT objects to / from the abapGit on-disk format
31
+ - `prefix` and `full` folder logic
32
+ - Used by `adt checkout` / `adt checkin`
179
33
 
180
- See [CONTRIBUTING.md](./CONTRIBUTING.md) for detailed guidelines on:
34
+ ## Documentation
181
35
 
182
- - Adding new object type support
183
- - XSD schema conventions
184
- - Handler implementation patterns
185
- - Testing requirements
36
+ **[adt-cli.netlify.app/sdk/packages/adt-plugin-abapgit](https://adt-cli.netlify.app/sdk/packages/adt-plugin-abapgit)**
186
37
 
187
- ## See Also
38
+ ---
188
39
 
189
- - [abapGit Documentation](https://docs.abapgit.org/)
190
- - [@abapify/adt-plugin](../adt-plugin/README.md) - Plugin interface
191
- - [@abapify/adk](../adk/README.md) - ABAP Development Kit
40
+ 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
@@ -1,4 +1,4 @@
1
- import { AbapObjectType, AdtPlugin, AdtPlugin as AdtPlugin$1, ExportContext, ExportResult, FormatMaterializationInput, FormatMaterializationResult, FormatPlugin, FormatSerializeOptions, ImportContext, ImportResult, MaterializedFormatFile } from "@abapify/adt-plugin";
1
+ import { AdtPlugin, AdtPlugin as AdtPlugin$1, ExportContext, ExportResult, FormatMaterializationInput, FormatMaterializationResult, FormatPlugin, FormatSerializeOptions, ImportContext, ImportResult, MaterializedFormatFile } from "@abapify/adt-plugin";
2
2
  import { AdkObject } from "@abapify/adk";
3
3
  import { SchemaLike, TypedSchema } from "@abapify/ts-xsd";
4
4
  import { adtUriToAbapGitPath, createAbapGitResolver as createFindingResolver } from "@abapify/adt-atc";
@@ -70,11 +70,9 @@ type InferValuesType<S> = S extends AbapGitSchema<unknown, infer V> ? V : unknow
70
70
  * Extract the data type (D) from an AdkObject<K, D>
71
71
  * This allows us to infer the payload type from the ADK class itself
72
72
  */
73
- type InferAdkData<T> = T extends AdkObject<infer _K, infer D> ? D : never;
74
- /**
75
- * ABAP object type code (e.g., 'CLAS', 'INTF', 'DOMA')
76
- */
77
- type AbapObjectType$1 = string;
73
+ type InferAdkData<T> = T extends AdkObject<infer _K, infer D> ? D : keyof T extends keyof HandlerObject ? Record<string, unknown> : T;
74
+ /** Identity shared by ADK instances and string-type handler facades. */
75
+ type HandlerObject = Pick<AdkObject, 'name'>;
78
76
  /**
79
77
  * Result of serializing a single file
80
78
  */
@@ -92,9 +90,9 @@ interface SerializedFile {
92
90
  * @typeParam T - ADK object type
93
91
  * @typeParam TSchema - AbapGit schema type (provides type-safe values)
94
92
  */
95
- interface ObjectHandler<T extends AdkObject = AdkObject, TSchema extends AbapGitSchema<unknown, unknown> = AbapGitSchema<unknown, unknown>> {
93
+ interface ObjectHandler<T extends HandlerObject = AdkObject, TSchema extends AbapGitSchema<unknown, unknown> = AbapGitSchema<unknown, unknown>> {
96
94
  /** ABAP object type (e.g., 'CLAS', 'INTF') */
97
- readonly type: AbapObjectType$1;
95
+ readonly type: string;
98
96
  /** File extension for this type (e.g., 'clas', 'intf') */
99
97
  readonly fileExtension: string;
100
98
  /** Schema for parsing/building XML */
@@ -133,17 +131,17 @@ interface ObjectHandler<T extends AdkObject = AdkObject, TSchema extends AbapGit
133
131
  * main type (e.g., 'CLAS/OC' → 'CLAS'). This matches ADK's resolveType()
134
132
  * behaviour and handles quickSearch results that return subtypes.
135
133
  */
136
- declare function getHandler(type: AbapObjectType$1): ObjectHandler | undefined;
134
+ declare function getHandler(type: string): ObjectHandler<HandlerObject> | undefined;
137
135
  /**
138
136
  * Check if object type is supported
139
137
  *
140
138
  * Tries the full type first, then falls back to the main type.
141
139
  */
142
- declare function isSupported(type: AbapObjectType$1): boolean;
140
+ declare function isSupported(type: string): boolean;
143
141
  /**
144
142
  * Get all supported object types
145
143
  */
146
- declare function getSupportedTypes(): AbapObjectType$1[];
144
+ declare function getSupportedTypes(): string[];
147
145
  /**
148
146
  * abapGit filename parsing utilities.
149
147
  *
@@ -206,5 +204,5 @@ declare function moveNamespaceToAbap(xml: string): string;
206
204
  * 2. Move xmlns:asx to asx:abap element
207
205
  */
208
206
  declare function formatAbapGitXml(xml: string): string;
209
- export { abapGitPlugin as AbapGitPlugin, abapGitPlugin, abapGitPlugin as default, type AbapObjectType, type AdtPlugin, type ExportContext, type ExportResult, type FolderLogic, type FormatMaterializationInput, type FormatMaterializationResult, type ImportContext, type ImportResult, type MaterializedFormatFile, type ObjectHandler, type SerializedFile, abapgitFormatPlugin, adtUriToAbapGitPath, createFindingResolver, formatAbapGitXml, formatXmlAttributes, getHandler, getSupportedTypes, isSupported, moveNamespaceToAbap, parseAbapGitFilename, parseAbapGitMetadata, resolvePackageFromDir, reverseResolveRootPackage };
207
+ export { abapGitPlugin as AbapGitPlugin, abapGitPlugin, abapGitPlugin as default, type AdtPlugin, type ExportContext, type ExportResult, type FolderLogic, type FormatMaterializationInput, type FormatMaterializationResult, type ImportContext, type ImportResult, type MaterializedFormatFile, type ObjectHandler, type SerializedFile, abapgitFormatPlugin, adtUriToAbapGitPath, createFindingResolver, formatAbapGitXml, formatXmlAttributes, getHandler, getSupportedTypes, isSupported, moveNamespaceToAbap, parseAbapGitFilename, parseAbapGitMetadata, resolvePackageFromDir, reverseResolveRootPackage };
210
208
  //# sourceMappingURL=index.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":["AdtPlugin","AbapObjectType"],"sources":["../src/lib/format-plugin.ts","../src/lib/folder-logic.ts","../src/lib/abapgit.ts","../src/lib/handlers/abapgit-schema.ts","../src/lib/handlers/base.ts","../src/lib/filename-parser.ts","../src/lib/handlers/xml-format.ts"],"mappings":";;;;cAgGa,qBAAqB;;;;;;;;;KCvFtB;;;;iBA6CI,qBAAqB;EACnC,aAAa;EACb;;;;;;;;;;;;;;;;iBAsBc,sBACd,iBACA,aAAa,aACb;;;;;;;;;;;;;iBA2Cc,0BACd,oBACA,gBACA,aAAa;;;;;;cC2EF,eAAeA;;;;;;;;UCrLX,cACf,OACA,SACA,UAAU,aAAa,oBACf,YAAY,OAAO;;WAElB,SAAS;;;KA2CR,gBAAgB,KAC1B,UAAU,6BAA6B,KAAK;;;;;KC/ClC,aAAa,KACvB,UAAU,gBAAgB,UAAU,KAAK;;;;KAsB/BC;;;;UAKK;;EAEf;;EAEA;;EAEA,WAAW;;;;;;;;UASI,cACf,UAAU,YAAY,WACtB,gBAAgB,kCAAkC;;WAMzC,MAAMA;;WAEN;;WAEA,QAAQ;;WAER,oBAAoB;;WAEpB;;EAET,UACE,QAAQ,GACR,UAAU,yBACT,QAAQ;;;;;EAKX,aACE,QAAQ,gBAAgB,WACvB,QAAQ,aAAa;IAAQ;;;;;;;EAOhC,aAAa,MAAM,0BAA0B,QAAQ,aAAa;IAChE;;;;;;EAOF,YAAY,QAAQ,GAAG,SAAS;;;;;;;;;iBAyBlB,WAAW,MAAMA,mBAAiB;;;;;;iBASlC,YAAY,MAAMA;;;;iBAOlB,qBAAqBA;;;;;;;;;;;;;;;;;;;;;iBCjIrB,qBAAqB;EACnC;EACA;EACA;EACA;;;;;;;;;;;;;;;;;;;;;;;;iBC+Bc,oBAAoB;;;;;;;iBA8DpB,oBAAoB;;;;;;iBA8BpB,iBAAiB"}
1
+ {"version":3,"file":"index.d.mts","names":["AdtPlugin"],"sources":["../src/lib/format-plugin.ts","../src/lib/folder-logic.ts","../src/lib/abapgit.ts","../src/lib/handlers/abapgit-schema.ts","../src/lib/handlers/base.ts","../src/lib/filename-parser.ts","../src/lib/handlers/xml-format.ts"],"mappings":";;;;cAiGa,qBAAqB;;;;;;;;;KCxFtB;;;;iBA6CI,qBAAqB;EACnC,aAAa;EACb;;;;;;;;;;;;;;;;iBAsBc,sBACd,iBACA,aAAa,aACb;;;;;;;;;;;;;iBA2Cc,0BACd,oBACA,gBACA,aAAa;;;;;;cC2EF,eAAeA;;;;;;;;UCrLX,cACf,OACA,SACA,UAAU,aAAa,oBACf,YAAY,OAAO;;WAElB,SAAS;;;KA2CR,gBAAgB,KAC1B,UAAU,6BAA6B,KAAK;;;;;KC/ClC,aAAa,KACvB,UAAU,gBAAgB,UAAU,KAChC,UACM,gBAAgB,gBACpB,0BACA;;KAGI,gBAAgB,KAAK;;;;UAsBhB;;EAEf;;EAEA;;EAEA,WAAW;;;;;;;;UASI,cACf,UAAU,gBAAgB,WAC1B,gBAAgB,kCAAkC;;WAMzC;;WAEA;;WAEA,QAAQ;;WAER,oBAAoB;;WAEpB;;EAET,UACE,QAAQ,GACR,UAAU,yBACT,QAAQ;;;;;EAKX,aACE,QAAQ,gBAAgB,WACvB,QAAQ,aAAa;IAAQ;;;;;;;EAOhC,aAAa,MAAM,0BAA0B,QAAQ,aAAa;IAChE;;;;;;EAOF,YAAY,QAAQ,GAAG,SAAS;;;;;;;;;iBAyBlB,WACd,eACC,cAAc;;;;;;iBASD,YAAY;;;;iBAOZ;;;;;;;;;;;;;;;;;;;;;iBCrIA,qBAAqB;EACnC;EACA;EACA;EACA;;;;;;;;;;;;;;;;;;;;;;;;iBC+Bc,oBAAoB;;;;;;;iBA8DpB,oBAAoB;;;;;;iBA8BpB,iBAAiB"}