@abapify/adt-plugin-gcts 0.4.0 → 0.4.3
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/dist/index.d.mts +166 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +1291 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +6 -3
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { AdtPlugin, AdtPlugin as AdtPlugin$1, FormatHandler, FormatHandler as FormatHandler$1, FormatPlugin, FormatPlugin as FormatPlugin$1, ParsedFormatFilename, SerializedFile, SerializedFile as SerializedFile$1 } from "@abapify/adt-plugin";
|
|
2
|
+
import { AdkClass, AdkDataElement, AdkDomain, AdkFunctionGroup, AdkInterface, AdkKind, AdkObject, AdkPackage, AdkProgram, AdkTable, AdkTableType } from "@abapify/adk";
|
|
3
|
+
//#region src/lib/format/types.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* gCTS / AFF format type definitions.
|
|
6
|
+
*
|
|
7
|
+
* The gCTS on-disk layout is essentially the layout documented by the AFF
|
|
8
|
+
* project (`SAP/abap-file-formats`): object-type subdirectory, JSON metadata,
|
|
9
|
+
* source files with AFF-specific extensions (`.abap`, `.acds`, ...).
|
|
10
|
+
*
|
|
11
|
+
* This plugin intentionally targets the AFF format so that a single plugin
|
|
12
|
+
* id (`gcts`) covers both gCTS-exported repos and AFF-exported repos. See
|
|
13
|
+
* `AGENTS.md` for the rationale and the open question tracked in
|
|
14
|
+
* `docs/roadmap/epics/e06-gcts-format-plugin.md`.
|
|
15
|
+
*/
|
|
16
|
+
/** Header common to every AFF/gCTS metadata JSON file. */
|
|
17
|
+
interface GctsHeader {
|
|
18
|
+
/** AFF format version (e.g. `1.0`). */
|
|
19
|
+
formatVersion: string;
|
|
20
|
+
/** Description of the object. */
|
|
21
|
+
description?: string;
|
|
22
|
+
/** Master language (ISO code, lowercase — e.g. `en`). */
|
|
23
|
+
originalLanguage?: string;
|
|
24
|
+
/** ABAP language version (e.g. `standard`, `cloudDevelopment`). */
|
|
25
|
+
abapLanguageVersion?: string;
|
|
26
|
+
/** Indicates whether the object source is Unicode. */
|
|
27
|
+
[key: string]: unknown;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Top-level shape of an AFF/gCTS metadata JSON file.
|
|
31
|
+
*
|
|
32
|
+
* Concrete handlers tighten this with per-type payload shapes.
|
|
33
|
+
*/
|
|
34
|
+
interface GctsMetadata<_TPayload extends object = object> {
|
|
35
|
+
/** Format header (mandatory on every file). */
|
|
36
|
+
header: GctsHeader;
|
|
37
|
+
/** Type-specific payload. Extended per ABAP object type. */
|
|
38
|
+
[payloadKey: string]: unknown;
|
|
39
|
+
}
|
|
40
|
+
/** Convenience helper for concrete metadata shapes. */
|
|
41
|
+
type WithHeader<TPayload extends object> = {
|
|
42
|
+
header: GctsHeader;
|
|
43
|
+
} & TPayload;
|
|
44
|
+
//#endregion
|
|
45
|
+
//#region src/lib/format/filename.d.ts
|
|
46
|
+
/** Metadata extension for all AFF/gCTS objects. */
|
|
47
|
+
declare const METADATA_EXTENSION = "json";
|
|
48
|
+
/** Fixed filename for package metadata (AFF / gCTS convention). */
|
|
49
|
+
declare const PACKAGE_FILENAME = "package.devc.json";
|
|
50
|
+
/**
|
|
51
|
+
* Build the AFF/gCTS on-disk filename for an object.
|
|
52
|
+
*
|
|
53
|
+
* @param name Object name (case preserved — AFF normalises to lowercase)
|
|
54
|
+
* @param type ABAP object type code (CLAS, INTF, ...)
|
|
55
|
+
* @param kind `"metadata"` (default) or `"source"`.
|
|
56
|
+
* @param suffix Optional sub-include suffix (e.g. `locals_def` for CLAS).
|
|
57
|
+
*/
|
|
58
|
+
declare function gctsFilename(name: string, type: string, kind?: 'metadata' | 'source', suffix?: string): string;
|
|
59
|
+
/**
|
|
60
|
+
* Parse an AFF/gCTS filename back into its components.
|
|
61
|
+
*
|
|
62
|
+
* Returns `undefined` if the filename does not look like a known AFF/gCTS
|
|
63
|
+
* artefact — callers should skip unknown files (e.g. `README.md`).
|
|
64
|
+
*/
|
|
65
|
+
declare function parseGctsFilename(filename: string): ParsedFormatFilename | undefined;
|
|
66
|
+
/**
|
|
67
|
+
* Translate an ADT object URI (e.g. `/sap/bc/adt/oo/classes/zcl_foo`) to
|
|
68
|
+
* the AFF/gCTS on-disk path (e.g. `zcl_foo/zcl_foo.clas.json`).
|
|
69
|
+
*
|
|
70
|
+
* Matches the `adtUriToAbapGitPath` helper in the abapGit plugin.
|
|
71
|
+
*/
|
|
72
|
+
declare function adtUriToGctsPath(uri: string): string | undefined;
|
|
73
|
+
//#endregion
|
|
74
|
+
//#region src/lib/handlers/base.d.ts
|
|
75
|
+
type AbapObjectType = string;
|
|
76
|
+
type AdkObjectClass<T extends AdkObject = AdkObject> = {
|
|
77
|
+
new (...args: any[]): T;
|
|
78
|
+
readonly kind: AdkKind;
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* Lazy source entry.
|
|
82
|
+
*
|
|
83
|
+
* `content` may be a string, a promise, or a thunk returning either — the
|
|
84
|
+
* factory awaits whichever form the handler returns.
|
|
85
|
+
*/
|
|
86
|
+
interface GctsSourceEntry {
|
|
87
|
+
suffix?: string;
|
|
88
|
+
content: string | Promise<string> | (() => string | Promise<string>);
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Extra file emitted alongside the standard metadata + source files.
|
|
92
|
+
* Used by compound handlers (e.g. FUGR emitting per-function-module files).
|
|
93
|
+
* `path` is relative to the object directory.
|
|
94
|
+
*/
|
|
95
|
+
interface GctsExtraFile {
|
|
96
|
+
path: string;
|
|
97
|
+
content: string | Promise<string> | (() => string | Promise<string>);
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Handler definition for a single ABAP object type.
|
|
101
|
+
*
|
|
102
|
+
* The shape intentionally mirrors the abapGit `HandlerDefinition` so that
|
|
103
|
+
* anyone familiar with the sister plugin can move between them with minimal
|
|
104
|
+
* friction. The `toMetadata` function is the only required hook: it maps an
|
|
105
|
+
* ADK object to the JSON metadata shape for the target type.
|
|
106
|
+
*/
|
|
107
|
+
interface GctsHandlerDefinition<T extends AdkObject, M extends GctsMetadata = GctsMetadata> {
|
|
108
|
+
/** Map ADK object → JSON metadata payload (including the required `header`). */
|
|
109
|
+
toMetadata(object: T): M;
|
|
110
|
+
/** Optional: single primary source file. */
|
|
111
|
+
getSource?(object: T): string | Promise<string>;
|
|
112
|
+
/** Optional: multiple source files (e.g. CLAS includes). */
|
|
113
|
+
getSources?(object: T): GctsSourceEntry[];
|
|
114
|
+
/** Optional: extra files with full paths (e.g. FUGR per-FM .func.json). */
|
|
115
|
+
getExtraFiles?(object: T): GctsExtraFile[] | Promise<GctsExtraFile[]>;
|
|
116
|
+
/** Optional: custom metadata filename (e.g. `package.devc.json` for DEVC). */
|
|
117
|
+
metadataFileName?: string | ((object: T) => string);
|
|
118
|
+
/**
|
|
119
|
+
* Optional: inverse mapping used during deserialization.
|
|
120
|
+
*
|
|
121
|
+
* `fromMetadata` receives the parsed JSON payload and returns a partial
|
|
122
|
+
* ADK-data projection. `setSources` mirrors abapGit's behaviour: it stages
|
|
123
|
+
* source content on the ADK object for later deploy.
|
|
124
|
+
*/
|
|
125
|
+
fromMetadata?(metadata: M): {
|
|
126
|
+
name: string;
|
|
127
|
+
} & Record<string, unknown>;
|
|
128
|
+
suffixToSourceKey?: Record<string, string>;
|
|
129
|
+
setSources?(object: T, sources: Record<string, string>): void;
|
|
130
|
+
}
|
|
131
|
+
/** Runtime shape of a gCTS handler after `createHandler` processing. */
|
|
132
|
+
interface GctsHandler<T extends AdkObject = AdkObject> extends FormatHandler$1 {
|
|
133
|
+
readonly type: AbapObjectType;
|
|
134
|
+
readonly fileExtension: string;
|
|
135
|
+
readonly schema: {
|
|
136
|
+
parse(raw: string): unknown;
|
|
137
|
+
build(data: unknown): string;
|
|
138
|
+
};
|
|
139
|
+
serialize(object: T): Promise<SerializedFile$1[]>;
|
|
140
|
+
fromAbapGit?(values: unknown): {
|
|
141
|
+
name: string;
|
|
142
|
+
} & Record<string, unknown>;
|
|
143
|
+
setSources?(object: T, sources: Record<string, string>): void;
|
|
144
|
+
}
|
|
145
|
+
/** Look up a handler (full-type first, then main-type fallback). */
|
|
146
|
+
declare function getHandler(type: AbapObjectType): GctsHandler | undefined;
|
|
147
|
+
/** `true` iff the given object type has a registered handler. */
|
|
148
|
+
declare function isSupported(type: AbapObjectType): boolean;
|
|
149
|
+
/** Snapshot of all registered object types. */
|
|
150
|
+
declare function getSupportedTypes(): AbapObjectType[];
|
|
151
|
+
/**
|
|
152
|
+
* Register a handler for an ADK class (preferred — `type` is derived from
|
|
153
|
+
* the static `kind`) or an explicit type string (for types without an ADK
|
|
154
|
+
* class, e.g. DOMA/DTEL).
|
|
155
|
+
*/
|
|
156
|
+
declare function createHandler<T extends AdkObject, M extends GctsMetadata = GctsMetadata>(adkClass: AdkObjectClass<T>, definition: GctsHandlerDefinition<T, M>): GctsHandler<T>;
|
|
157
|
+
declare function createHandler<T extends AdkObject, M extends GctsMetadata = GctsMetadata>(type: AbapObjectType, definition: GctsHandlerDefinition<T, M>): GctsHandler<T>;
|
|
158
|
+
//#endregion
|
|
159
|
+
//#region src/lib/format/gcts-format.d.ts
|
|
160
|
+
declare const gctsFormatPlugin: FormatPlugin$1;
|
|
161
|
+
//#endregion
|
|
162
|
+
//#region src/lib/gcts-plugin.d.ts
|
|
163
|
+
declare const gctsPlugin: AdtPlugin$1;
|
|
164
|
+
//#endregion
|
|
165
|
+
export { type AdtPlugin, type FormatHandler, type FormatPlugin, type GctsHandler, type GctsHandlerDefinition, type GctsHeader, type GctsMetadata, gctsPlugin as GctsPlugin, gctsPlugin as default, gctsPlugin, type GctsSourceEntry, METADATA_EXTENSION, PACKAGE_FILENAME, type SerializedFile, type WithHeader, adtUriToGctsPath, createHandler, gctsFilename, gctsFormatPlugin, getHandler, getSupportedTypes, isSupported, parseGctsFilename };
|
|
166
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/lib/format/types.ts","../src/lib/format/filename.ts","../src/lib/handlers/base.ts","../src/lib/format/gcts-format.ts","../src/lib/gcts-plugin.ts"],"mappings":";;;;;;;;;;;;;;;;UAciB;;EAEf;;EAEA;;EAEA;;EAEA;;GAEC;;;;;;;UAQc,aAAa;;EAE5B,QAAQ;;GAEP;;;KAIS,WAAW;EACrB,QAAQ;IACN;;;;cCNS;;cAGA;;;;;;;;;iBAUG,aACd,cACA,cACA,8BACA;;;;;;;iBAmBc,kBACd,mBACC;;;;;;;iBAwEa,iBAAiB;;;KC9HrB;KAEA,eAAe,UAAU,YAAY;UACvC,cAAc;WACb,MAAM;;;;;;;;UASA;EACf;EACA,kBAAkB,kCAAkC;;;;;;;UAQrC;EACf;EACA,kBAAkB,kCAAkC;;;;;;;;;;UAWrC,sBACf,UAAU,WACV,UAAU,eAAe;;EAGzB,WAAW,QAAQ,IAAI;;EAGvB,WAAW,QAAQ,aAAa;;EAGhC,YAAY,QAAQ,IAAI;;EAGxB,eAAe,QAAQ,IAAI,kBAAkB,QAAQ;;EAGrD,8BAA8B,QAAQ;;;;;;;;EAStC,cAAc,UAAU;IAAM;MAAiB;EAC/C,oBAAoB;EACpB,YAAY,QAAQ,GAAG,SAAS;;;UAIjB,YACf,UAAU,YAAY,mBACd;WACC,MAAM;WACN;WACA;IACP,MAAM;IACN,MAAM;;EAER,UAAU,QAAQ,IAAI,QAAQ;EAC9B,aAAa;IAAoB;MAAiB;EAClD,YAAY,QAAQ,GAAG,SAAS;;;iBAMlB,WAAW,MAAM,iBAAiB;;iBAKlC,YAAY,MAAM;;iBAKlB,qBAAqB;;;;;;iBAsBrB,cACd,UAAU,WACV,UAAU,eAAe,cAEzB,UAAU,eAAe,IACzB,YAAY,sBAAsB,GAAG,KACpC,YAAY;iBACC,cACd,UAAU,WACV,UAAU,eAAe,cAEzB,MAAM,gBACN,YAAY,sBAAsB,GAAG,KACpC,YAAY;;;cCpIF,kBAAkB;;;cCIlB,YAAY"}
|