@abapify/adt-plugin 0.0.0 → 0.3.6
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 +121 -1
- package/package.json +31 -3
package/README.md
CHANGED
|
@@ -1,3 +1,123 @@
|
|
|
1
1
|
# @abapify/adt-plugin
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://github.com/abapify/adt-cli/pkgs/npm/%40abapify%2Fadt-plugin)
|
|
4
|
+
|
|
5
|
+
Core plugin interface for ADT format serialization.
|
|
6
|
+
|
|
7
|
+
## Overview
|
|
8
|
+
|
|
9
|
+
This package defines the **plugin contract** for serializing ADK objects to various formats (abapGit, etc.). Plugins implement this interface to provide format-specific serialization.
|
|
10
|
+
|
|
11
|
+
**Key principle:** Plugins only handle serialization format. They receive ADK objects and produce files - no ADT client logic.
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
bun add @abapify/adt-plugin
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Usage
|
|
20
|
+
|
|
21
|
+
### Creating a Plugin
|
|
22
|
+
|
|
23
|
+
```typescript
|
|
24
|
+
import { createPlugin, type AdtPlugin } from '@abapify/adt-plugin';
|
|
25
|
+
|
|
26
|
+
export const myPlugin = createPlugin({
|
|
27
|
+
name: 'myFormat',
|
|
28
|
+
version: '1.0.0',
|
|
29
|
+
description: 'My custom format plugin',
|
|
30
|
+
|
|
31
|
+
// Registry service - what object types are supported
|
|
32
|
+
registry: {
|
|
33
|
+
isSupported: (type) => ['CLAS', 'INTF'].includes(type),
|
|
34
|
+
getSupportedTypes: () => ['CLAS', 'INTF'],
|
|
35
|
+
},
|
|
36
|
+
|
|
37
|
+
// Format service - import/export operations
|
|
38
|
+
format: {
|
|
39
|
+
// Import: ADK object → file system
|
|
40
|
+
import: async (object, targetPath, context) => {
|
|
41
|
+
// Serialize object to files
|
|
42
|
+
return {
|
|
43
|
+
success: true,
|
|
44
|
+
filesCreated: ['myclass.clas.xml'],
|
|
45
|
+
};
|
|
46
|
+
},
|
|
47
|
+
|
|
48
|
+
// Export: file system → ADK object (optional)
|
|
49
|
+
export: async (sourcePath, type, name) => {
|
|
50
|
+
// Deserialize files to ADK object
|
|
51
|
+
return {
|
|
52
|
+
success: true,
|
|
53
|
+
object: myAdkObject,
|
|
54
|
+
};
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
|
|
58
|
+
// Lifecycle hooks (optional)
|
|
59
|
+
hooks: {
|
|
60
|
+
afterImport: async (targetPath) => {
|
|
61
|
+
// Generate metadata files, etc.
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
});
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### Using a Plugin
|
|
68
|
+
|
|
69
|
+
```typescript
|
|
70
|
+
import { abapGitPlugin } from '@abapify/adt-plugin-abapgit';
|
|
71
|
+
|
|
72
|
+
// Check if type is supported
|
|
73
|
+
if (abapGitPlugin.registry.isSupported('CLAS')) {
|
|
74
|
+
// Import object to file system
|
|
75
|
+
const result = await abapGitPlugin.format.import(myClassObject, './output', {
|
|
76
|
+
packagePath: ['ZROOT', 'ZSUB'],
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
if (result.success) {
|
|
80
|
+
console.log('Files created:', result.filesCreated);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// Get all supported types
|
|
85
|
+
const types = abapGitPlugin.registry.getSupportedTypes();
|
|
86
|
+
// → ['CLAS', 'INTF', 'DOMA', 'DEVC', 'DTEL']
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## API
|
|
90
|
+
|
|
91
|
+
### `createPlugin(definition)`
|
|
92
|
+
|
|
93
|
+
Factory function to create a validated plugin instance.
|
|
94
|
+
|
|
95
|
+
### `AdtPlugin` Interface
|
|
96
|
+
|
|
97
|
+
```typescript
|
|
98
|
+
interface AdtPlugin {
|
|
99
|
+
readonly name: string;
|
|
100
|
+
readonly version: string;
|
|
101
|
+
readonly description: string;
|
|
102
|
+
|
|
103
|
+
readonly registry: {
|
|
104
|
+
isSupported(type: AbapObjectType): boolean;
|
|
105
|
+
getSupportedTypes(): AbapObjectType[];
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
readonly format: {
|
|
109
|
+
import(object, targetPath, context): Promise<ImportResult>;
|
|
110
|
+
export?(sourcePath, type, name): Promise<ExportResult>;
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
readonly hooks?: {
|
|
114
|
+
afterImport?(targetPath: string): Promise<void>;
|
|
115
|
+
beforeExport?(sourcePath: string): Promise<void>;
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
## Terminology
|
|
121
|
+
|
|
122
|
+
- **Import** (to Git): ADK object → serialized files (SAP → file system)
|
|
123
|
+
- **Export** (from Git): serialized files → ADK object (file system → SAP)
|
package/package.json
CHANGED
|
@@ -1,5 +1,33 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abapify/adt-plugin",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
5
|
-
|
|
3
|
+
"version": "0.3.6",
|
|
4
|
+
"description": "ADT Plugin interface and factory for abapify",
|
|
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
|
+
"nx": {
|
|
16
|
+
"name": "adt-plugin"
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"dist"
|
|
20
|
+
],
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"@abapify/adk": "0.3.6"
|
|
23
|
+
},
|
|
24
|
+
"repository": {
|
|
25
|
+
"type": "git",
|
|
26
|
+
"url": "git+https://github.com/abapify/adt-cli.git",
|
|
27
|
+
"directory": "packages/adt-plugin"
|
|
28
|
+
},
|
|
29
|
+
"homepage": "https://github.com/abapify/adt-cli/tree/main/packages/adt-plugin#readme",
|
|
30
|
+
"bugs": {
|
|
31
|
+
"url": "https://github.com/abapify/adt-cli/issues"
|
|
32
|
+
}
|
|
33
|
+
}
|