@abapify/adt-plugin

中文文档
0.4.34发布于 2026/11/03MITTypeScriptES Module构建来源已验证近 30 天下载 3714

ADT 插件接口和机床

中文使用文档
文档目录10 节
  1. 概览
  2. 安装
  3. 使用量
  4. 创建插件
  5. 使用插件
  6. API 密码
  7. 纯树物质化
  8. createPlugin(definition)
  9. AdtPlugin 接口
  10. 术语

@abapify/adt-plugin (中文(简体) )

version

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)

版本与发布记录

@abapify/adt-plugin 共发布 31 个版本,首次发布于 2026/04/21;过去 12 个月发布了 31 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.4.34latest2026/11/034 天前
0.4.332026/11/025 天前
0.4.322026/11/025 天前
0.4.312026/11/016 天前
0.4.292026/10/308 天前
0.4.282026/10/308 天前

关于 @abapify/adt-plugin 的常见问题

@abapify/adt-plugin 是什么?

ADT 插件接口和机床

如何安装 @abapify/adt-plugin?

在项目目录运行 npm install @abapify/adt-plugin,或使用 pnpm add / yarn add / bun add。

@abapify/adt-plugin 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@abapify/adt-plugin 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@abapify/adt-plugin 可以商用吗?

@abapify/adt-plugin 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@abapify/adt-plugin 的下载量有多少?

根据 npm 官方下载统计,@abapify/adt-plugin 在 2026/10/05 – 2026/11/03 这 30 天内被下载 3,714 次,日均约 124 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@abapify/adt-plugin 还在维护吗?

最新版本 0.4.34 发布于 2026/11/03(4 天前);至今共发布 31 个版本,其中过去 12 个月发布了 31 个;首次发布于 2026/04/21。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。