@abapify/adt-plugin (中文(简体) )
ADT格式序列化的核心插件接口.
概览
此软件包定义 插件合同 用于将 ADK 对象序列化到各种格式(abapGit等)。 插件执行此接口以提供特定格式的序列化.
关键原则: 插件只处理序列化格式。 它们接收ADK对象并生成文件 - 没有ADT客户端逻辑.
安装
bun add @abapify/adt-plugin
使用量
创建插件
import { createPlugin, type AdtPlugin } from '@abapify/adt-plugin';
export const myPlugin = createPlugin({
name: 'myFormat',
version: '1.0.0',
description: 'My custom format plugin',
// Registry service - what object types are supported
registry: {
isSupported: (type) => ['CLAS', 'INTF'].includes(type),
getSupportedTypes: () => ['CLAS', 'INTF'],
},
// Format service - import/export operations
format: {
// Import: ADK object → file system
import: async (object, targetPath, context) => {
// Serialize object to files
return {
success: true,
filesCreated: ['myclass.clas.xml'],
};
},
// Export: file system → ADK object (optional)
export: async (sourcePath, type, name) => {
// Deserialize files to ADK object
return {
success: true,
object: myAdkObject,
};
},
},
// Lifecycle hooks (optional)
hooks: {
afterImport: async (targetPath) => {
// Generate metadata files, etc.
},
},
});
使用插件
import { abapGitPlugin } from '@abapify/adt-plugin-abapgit';
// Check if type is supported
if (abapGitPlugin.registry.isSupported('CLAS')) {
// Import object to file system
const result = await abapGitPlugin.format.import(myClassObject, './output', {
packagePath: ['ZROOT', 'ZSUB'],
});
if (result.success) {
console.log('Files created:', result.filesCreated);
}
}
// Get all supported types
const types = abapGitPlugin.registry.getSupportedTypes();
// → ['CLAS', 'INTF', 'DOMA', 'DEVC', 'DTEL']
API 密码
纯树物质化
流体式消费者需要先计算寄存器的变化,然后才能触摸
文件系统。 A 类 FormatPlugin 暴露可选的纯物质化
能力。 获取一个通过 requireFormatPlugin (无) createPlugin,哪个
返回一个 AdtPlugin:
import { requireFormatPlugin } from '@abapify/adt-plugin';
const formatPlugin = requireFormatPlugin('abapGit');
const result = await formatPlugin.materialize?.({
object: adkObject,
objectType: 'CLAS',
packagePath: ['ZROOT', 'ZROOT_FEATURE'],
sources: {
main: historicalMainSource,
definitions: historicalLocalDefinitions,
},
formatOptions: { folderLogic: 'prefix' },
});
何时 sources 它具有权威性。 处理器只发出这些
组件,不得通过 ADK 对象读取可变源。 结果
包含确定寄存器与文件 source 或者说 metadata
角色; 呼叫者拥有验证和文件系统调节.
createPlugin(definition)
Factory 函数创建已验证的插件实例 .
AdtPlugin 接口
interface AdtPlugin {
readonly name: string;
readonly version: string;
readonly description: string;
readonly registry: {
isSupported(type: AbapObjectType): boolean;
getSupportedTypes(): AbapObjectType[];
};
readonly format: {
import(object, targetPath, context): Promise<ImportResult>;
export?(sourcePath, type, name): Promise<ExportResult>;
};
readonly hooks?: {
afterImport?(targetPath: string): Promise<void>;
beforeExport?(sourcePath: string): Promise<void>;
};
}
术语
- 导入 (到 Git): ADK 对象 ~ 序列文件 (SAP ~ 文件系统)
- 导出 (取自 Git ): 序列文件 → ADK 对象( 文件系统 → SAP)