@abapify/adt-plugin-abapgit 0.4.0 → 0.4.1

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.
@@ -0,0 +1,223 @@
1
+ import { AbapObjectType, AdtPlugin, AdtPlugin as AdtPlugin$1, ExportContext, ExportResult, FormatPlugin, ImportContext, ImportResult } from "@abapify/adt-plugin";
2
+ import { AdkObject } from "@abapify/adk";
3
+ import { SchemaLike, TypedSchema } from "@abapify/ts-xsd";
4
+ import { createAbapGitResolver as createFindingResolver } from "@abapify/adt-atc";
5
+
6
+ //#region src/lib/format-plugin.d.ts
7
+ declare const abapgitFormatPlugin: FormatPlugin;
8
+ //#endregion
9
+ //#region src/lib/folder-logic.d.ts
10
+ /**
11
+ * abapGit Folder Logic
12
+ *
13
+ * Shared functions for resolving SAP package names from directory paths
14
+ * using abapGit's folder logic (PREFIX/FULL).
15
+ *
16
+ * Used by both the serializer (import: SAP → Git) and deserializer (export: Git → SAP).
17
+ */
18
+ type FolderLogic = 'prefix' | 'full' | 'full-with-root';
19
+ /**
20
+ * Parse abapGit repository metadata from .abapgit.xml content
21
+ */
22
+ declare function parseAbapGitMetadata(xmlContent: string): {
23
+ folderLogic: FolderLogic;
24
+ startingFolder: string;
25
+ };
26
+ /**
27
+ * Reverse of calculatePackageDir — compute SAP package name from directory path
28
+ *
29
+ * Given a directory path relative to the starting folder, the folder logic,
30
+ * and the root package name, compute the SAP package name.
31
+ *
32
+ * PREFIX mode: root 'ZABAPGIT_EXAMPLES' + dir 'clas' → 'ZABAPGIT_EXAMPLES_CLAS'
33
+ * FULL mode: dir 'zabapgit_examples_clas' → 'ZABAPGIT_EXAMPLES_CLAS'
34
+ *
35
+ * @param dirPath - Directory path relative to starting folder
36
+ * @param folderLogic - Folder logic mode (prefix or full)
37
+ * @param rootPackage - Root SAP package name
38
+ * @returns SAP package name
39
+ */
40
+ declare function resolvePackageFromDir(dirPath: string, folderLogic: FolderLogic, rootPackage: string): string;
41
+ /**
42
+ * Reverse of resolvePackageFromDir — given a SAP package name and the
43
+ * relative directory of an object, back-derive the root package.
44
+ *
45
+ * PREFIX mode: sapPackage 'ZABAPGIT_EXAMPLES_FUGR' + dir 'fugr' → 'ZABAPGIT_EXAMPLES'
46
+ * FULL mode: cannot derive root (returns undefined)
47
+ *
48
+ * @param sapPackage - Actual SAP package name (from GET response)
49
+ * @param relDir - Directory path relative to starting folder
50
+ * @param folderLogic - Folder logic mode
51
+ * @returns Root package name, or undefined if it cannot be derived
52
+ */
53
+ declare function reverseResolveRootPackage(sapPackage: string, relDir: string, folderLogic: FolderLogic): string | undefined;
54
+ //#endregion
55
+ //#region src/lib/abapgit.d.ts
56
+ /**
57
+ * abapGit Plugin
58
+ *
59
+ * Provides import/export of ADK objects to abapGit repository format.
60
+ */
61
+ declare const abapGitPlugin: AdtPlugin$1;
62
+ //#endregion
63
+ //#region src/lib/handlers/abapgit-schema.d.ts
64
+ /**
65
+ * AbapGit schema instance with both full type and values type
66
+ *
67
+ * @typeParam TFull - Full AbapGitType (root XML structure)
68
+ * @typeParam TValues - Inner values type (e.g., DevcType)
69
+ * @typeParam S - Raw schema literal type
70
+ */
71
+ interface AbapGitSchema<TFull, TValues, S extends SchemaLike = SchemaLike> extends TypedSchema<TFull, S> {
72
+ /** The inner values type - use with typeof for type extraction */
73
+ readonly _values: TValues;
74
+ }
75
+ /** Extract the values type from an AbapGitSchema */
76
+ type InferValuesType<S> = S extends AbapGitSchema<unknown, infer V> ? V : unknown;
77
+ //#endregion
78
+ //#region src/lib/handlers/base.d.ts
79
+ /**
80
+ * Extract the data type (D) from an AdkObject<K, D>
81
+ * This allows us to infer the payload type from the ADK class itself
82
+ */
83
+ type InferAdkData<T> = T extends AdkObject<infer _K, infer D> ? D : never;
84
+ /**
85
+ * ABAP object type code (e.g., 'CLAS', 'INTF', 'DOMA')
86
+ */
87
+ type AbapObjectType$1 = string;
88
+ /**
89
+ * Result of serializing a single file
90
+ */
91
+ interface SerializedFile {
92
+ /** Relative path from object directory */
93
+ path: string;
94
+ /** File content */
95
+ content: string;
96
+ /** Optional encoding (default: utf-8) */
97
+ encoding?: BufferEncoding;
98
+ }
99
+ /**
100
+ * Handler interface for object serialization/deserialization
101
+ *
102
+ * @typeParam T - ADK object type
103
+ * @typeParam TSchema - AbapGit schema type (provides type-safe values)
104
+ */
105
+ interface ObjectHandler<T extends AdkObject = AdkObject, TSchema extends AbapGitSchema<unknown, unknown> = AbapGitSchema<unknown, unknown>> {
106
+ /** ABAP object type (e.g., 'CLAS', 'INTF') */
107
+ readonly type: AbapObjectType$1;
108
+ /** File extension for this type (e.g., 'clas', 'intf') */
109
+ readonly fileExtension: string;
110
+ /** Schema for parsing/building XML */
111
+ readonly schema: TSchema;
112
+ /** Map abapGit file suffix to source key */
113
+ readonly suffixToSourceKey?: Record<string, string>;
114
+ /** Serialize object to files (SAP → Git) */
115
+ serialize(object: T): Promise<SerializedFile[]>;
116
+ /**
117
+ * Map abapGit values to ADK data (Git → SAP)
118
+ * Return type includes name (required) plus any ADK data fields
119
+ */
120
+ fromAbapGit?(values: InferValuesType<TSchema>): Partial<InferAdkData<T>> & {
121
+ name: string;
122
+ };
123
+ /**
124
+ * Set source files on ADK object during deserialization (Git → SAP)
125
+ * Symmetric counterpart to getSources
126
+ */
127
+ setSources?(object: T, sources: Record<string, string>): void;
128
+ }
129
+ /**
130
+ * Get handler for object type
131
+ *
132
+ * Tries the full type first (e.g., 'TABL/DS'), then falls back to the
133
+ * main type (e.g., 'CLAS/OC' → 'CLAS'). This matches ADK's resolveType()
134
+ * behaviour and handles quickSearch results that return subtypes.
135
+ */
136
+ declare function getHandler(type: AbapObjectType$1): ObjectHandler | undefined;
137
+ /**
138
+ * Check if object type is supported
139
+ *
140
+ * Tries the full type first, then falls back to the main type.
141
+ */
142
+ declare function isSupported(type: AbapObjectType$1): boolean;
143
+ /**
144
+ * Get all supported object types
145
+ */
146
+ declare function getSupportedTypes(): AbapObjectType$1[];
147
+ //#endregion
148
+ //#region src/lib/deserializer.d.ts
149
+ /**
150
+ * abapGit file naming convention:
151
+ * - XML metadata: {name}.{type}.xml (e.g., zcl_myclass.clas.xml)
152
+ * - Source code: {name}.{type}.abap (e.g., zcl_myclass.clas.abap)
153
+ * - Source includes: {name}.{type}.{suffix}.abap (e.g., zcl_myclass.clas.testclasses.abap)
154
+ */
155
+ /**
156
+ * Parse abapGit filename to extract object info
157
+ */
158
+ declare function parseAbapGitFilename(filename: string): {
159
+ name: string;
160
+ type: string;
161
+ suffix?: string;
162
+ extension: string;
163
+ } | null;
164
+ //#endregion
165
+ //#region src/lib/filename/adt-uri-to-path.d.ts
166
+ /**
167
+ * Convert an ADT URI to an on-disk abapGit filename.
168
+ *
169
+ * abapGit stores objects as `<name>.<type>.<ext>` inside `src/`.
170
+ * Classes have additional includes serialised as
171
+ * `<name>.clas.<suffix>.abap`. Function modules become
172
+ * `<group>.fugr.<fm_name>.abap`. Namespaces are rendered as
173
+ * `(namespace)name`.
174
+ *
175
+ * Returns `null` for URIs we don't recognise; callers may warn or fall
176
+ * back to a synthetic path.
177
+ */
178
+ /**
179
+ * Convert an ADT URI to the abapGit on-disk filename (lower-cased,
180
+ * namespace-aware). Returns `null` when the URI shape is not recognised.
181
+ */
182
+ declare function adtUriToAbapGitPath(uri: string): string | null;
183
+ //#endregion
184
+ //#region src/lib/handlers/xml-format.d.ts
185
+ /**
186
+ * XML formatting utilities for abapGit serialization.
187
+ *
188
+ * Centralizes XML post-processing that was previously duplicated
189
+ * across base.ts, fugr.ts, tabl.ts, and roundtrip.ts.
190
+ *
191
+ * Uses indexOf-based parsing instead of regex to avoid
192
+ * super-linear backtracking (SonarQube S5852).
193
+ */
194
+ /**
195
+ * Format XML attributes on separate lines for better diff readability.
196
+ *
197
+ * Turns `<tag a="1" b="2">` into:
198
+ * ```
199
+ * <tag
200
+ * a="1"
201
+ * b="2"
202
+ * >
203
+ * ```
204
+ *
205
+ * Uses indexOf-based scanning to avoid regex backtracking (S5852).
206
+ */
207
+ declare function formatXmlAttributes(xml: string): string;
208
+ /**
209
+ * Move `xmlns:asx` declaration from root `<abapGit>` to nested `<asx:abap>`.
210
+ *
211
+ * Uses indexOf-based approach instead of regex to avoid backtracking on
212
+ * the `[\s\S]*?` pattern that SonarQube flags.
213
+ */
214
+ declare function moveNamespaceToAbap(xml: string): string;
215
+ /**
216
+ * Apply standard abapGit XML formatting:
217
+ * 1. Format attributes on separate lines
218
+ * 2. Move xmlns:asx to asx:abap element
219
+ */
220
+ declare function formatAbapGitXml(xml: string): string;
221
+ //#endregion
222
+ export { abapGitPlugin as AbapGitPlugin, abapGitPlugin, abapGitPlugin as default, type AbapObjectType, type AdtPlugin, type ExportContext, type ExportResult, type FolderLogic, type ImportContext, type ImportResult, type ObjectHandler, type SerializedFile, abapgitFormatPlugin, adtUriToAbapGitPath, createFindingResolver, formatAbapGitXml, formatXmlAttributes, getHandler, getSupportedTypes, isSupported, moveNamespaceToAbap, parseAbapGitFilename, parseAbapGitMetadata, resolvePackageFromDir, reverseResolveRootPackage };
223
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.mts","names":[],"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/deserializer.ts","../src/lib/filename/adt-uri-to-path.ts","../src/lib/handlers/xml-format.ts"],"mappings":";;;;;;cAoBa,mBAAA,EAAqB,YAAA;;;;;;;;;AAAlC;;KCXY,WAAA;;AA6CZ;;iBAAgB,oBAAA,CAAqB,UAAA;EACnC,WAAA,EAAa,WAAA;EACb,cAAA;AAAA;;;;;AAsBF;;;;;;;;;;iBAAgB,qBAAA,CACd,OAAA,UACA,WAAA,EAAa,WAAA,EACb,WAAA;;;;;;;;;;;;;iBA2Cc,yBAAA,CACd,UAAA,UACA,MAAA,UACA,WAAA,EAAa,WAAA;;;;;AD3Gf;;;cEmIa,aAAA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