@abapify/adt-plugin

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

ADT Plugin interface and factory for abapify

原始使用文档
文档目录10 节
  1. Overview
  2. Installation
  3. Usage
  4. Creating a Plugin
  5. Using a Plugin
  6. API
  7. Pure tree materialization
  8. createPlugin(definition)
  9. AdtPlugin Interface
  10. Terminology

@abapify/adt-plugin

version

Core plugin interface for ADT format serialization.

Overview

This package defines the plugin contract for serializing ADK objects to various formats (abapGit, etc.). Plugins implement this interface to provide format-specific serialization.

Key principle: Plugins only handle serialization format. They receive ADK objects and produce files - no ADT client logic.

Installation

bun add @abapify/adt-plugin

Usage

Creating a 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.
    },
  },
});

Using a Plugin

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

Pure tree materialization

Flow-style consumers need to calculate repository changes before touching the filesystem. A FormatPlugin exposes the optional pure materialization capability. Obtain one through requireFormatPlugin (not createPlugin, which returns an 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' },
});

When sources is present it is authoritative. A handler emits only those components and must not read mutable source through the ADK object. The result contains deterministic repository-relative files with source or metadata roles; the caller owns validation and filesystem reconciliation.

createPlugin(definition)

Factory function to create a validated plugin instance.

AdtPlugin Interface

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>;
  };
}

Terminology

  • Import (to Git): ADK object → serialized files (SAP → file system)
  • Export (from Git): serialized files → ADK object (file system → 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 Plugin interface and factory for abapify

如何安装 @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 和提交记录判断。