@abapify/adt-client

中文文档
0.4.33发布于 2026/11/02MITTypeScriptES Module构建来源已验证近 30 天下载 4544

Minimalistic speci-based ADT client for SAP ABAP Development Tools

原始使用文档
文档目录20 节
  1. Why v2?
  2. Features
  3. Installation
  4. Quick Start
  5. API Reference
  6. Client Creation
  7. Class Operations
  8. Types
  9. ClassMetadata
  10. ClassIncludes
  11. ClassObject
  12. Examples
  13. Read and Modify Class
  14. Create New Class
  15. Lock, Edit, Unlock Pattern
  16. Architecture
  17. Two-Layer Design
  18. Comparison with adt-client v1
  19. Related Packages
  20. License

@abapify/adt-client

version

Contract-driven SAP ADT REST client — uses speci + ts-xsd for full type safety.

Why v2?

This package replaces the legacy adt-client with a contract-first design:

┌─────────────────────────────────────────────────────────────────┐
│                      adt-client                               │
│              (HTTP Client + Request Execution)                   │
└─────────────────────────────────────────────────────────────────┘
                              │
                              ▼
┌─────────────────────────────────────────────────────────────────┐
│                      adt-contracts                               │
│         (REST API Contracts using speci + ts-xsd)                │
└─────────────────────────────────────────────────────────────────┘
                              │
                              ▼
┌─────────────────────────────────────────────────────────────────┐
│                     adt-schemas                              │
│        (TypeScript schemas from SAP XSD definitions)             │
└─────────────────────────────────────────────────────────────────┘

Benefits over v1:

  • ✅ Type-safe from XSD - Types generated from official SAP schemas
  • ✅ Contract-first - API contracts define the interface
  • ✅ Zero manual types - No hand-written type definitions
  • ✅ Easy to extend - Add endpoints by defining contracts
  • ✅ Testable - Contracts are pure data, easy to mock

Features

  • ✅ Contract-driven - Uses speci + ts-xsd contracts
  • ✅ Full type inference - Types flow from XSD to response
  • ✅ Zero dependencies - Only uses native fetch API
  • ✅ Clean API - Arrow-function contracts
  • ✅ Promise-based - Modern async/await API

Installation

bun add @abapify/adt-client

Quick Start

import { createAdtClient } from '@abapify/adt-client';

// Create client
const client = createAdtClient({
  baseUrl: 'https://sap-system.com:8000',
  username: 'YOUR_USER',
  password: 'YOUR_PASS',
  client: '100',
  language: 'EN',
});

// Get complete class with all includes
const classObj = await client.getClass('ZCL_MY_CLASS');
console.log(classObj.metadata.description);
console.log(classObj.includes.main);
console.log(classObj.includes.definitions);
console.log(classObj.includes.implementations);

// Update main source
await client.updateMainSource('ZCL_MY_CLASS', newSource);

API Reference

Client Creation

createAdtClient(config: AdtConnectionConfig): AdtClient

Config:

  • baseUrl - SAP system URL (e.g., https://sap-system.com:8000)
  • username - SAP username
  • password - SAP password
  • client - SAP client (optional, e.g., '100')
  • language - SAP language (optional, e.g., 'EN')
  • headersTimeoutMs - response-header timeout for long-running SAP requests (optional; otherwise the native HTTP client default applies)

Class Operations

Get Complete Class

getClass(className: string): Promise<ClassObject>

Returns class metadata and all includes (main, definitions, implementations, macros, testclasses).

Get Metadata Only

getMetadata(className: string): Promise<ClassMetadata>

Returns class metadata (name, description, package, etc.).

Get All Includes

getIncludes(className: string): Promise<ClassIncludes>

Returns all class source includes.

Get Specific Include

getInclude(className: string, includeType: 'main' | 'definitions' | 'implementations' | 'macros' | 'testclasses'): Promise<string>

Returns specific include source code.

Update Main Source

updateMainSource(className: string, source: string): Promise<OperationResult>

Updates the main class source code.

Create Class

createClass(className: string, metadata: Partial<ClassMetadata>): Promise<OperationResult>

Creates a new class with specified metadata.

Delete Class

deleteClass(className: string): Promise<OperationResult>

Deletes a class.

Lock/Unlock

lockClass(className: string): Promise<string>
unlockClass(className: string, lockHandle: string): Promise<OperationResult>

Lock and unlock class for editing.

Types

ClassMetadata

interface ClassMetadata {
  name: string;
  description?: string;
  packageName?: string;
  responsible?: string;
  createdBy?: string;
  createdAt?: string;
  changedBy?: string;
  changedAt?: string;
  final?: boolean;
  abstract?: boolean;
  visibility?: 'public' | 'protected' | 'private';
}

ClassIncludes

interface ClassIncludes {
  main?: string;
  definitions?: string;
  implementations?: string;
  macros?: string;
  testclasses?: string;
}

ClassObject

interface ClassObject {
  metadata: ClassMetadata;
  includes: ClassIncludes;
}

Examples

Read and Modify Class

// Get class
const classObj = await client.getClass('ZCL_MY_CLASS');

// Modify source
const newSource = classObj.includes.main?.replace('OLD_TEXT', 'NEW_TEXT');

// Update
if (newSource) {
  await client.updateMainSource('ZCL_MY_CLASS', newSource);
}

Create New Class

await client.createClass('ZCL_NEW_CLASS', {
  description: 'My new class',
  packageName: 'ZPACKAGE',
  visibility: 'public',
  final: false,
  abstract: false,
});

Lock, Edit, Unlock Pattern

// Lock class
const lockHandle = await client.lockClass('ZCL_MY_CLASS');

try {
  // Edit class
  await client.updateMainSource('ZCL_MY_CLASS', newSource);
} finally {
  // Always unlock
  await client.unlockClass('ZCL_MY_CLASS', lockHandle);
}

Architecture

Two-Layer Design

const client = createAdtClient({...});

// Layer 1: Low-level contracts (direct ADT REST access)
client.adt.core.http.sessions.getSession()
client.adt.cts.transportrequests.getTransport(id)

// Layer 2: High-level services (business logic)
client.services.transports.importAndActivate(transportId)  // Future

// Utility: Raw HTTP for debugging
client.fetch('/arbitrary/endpoint', { method: 'GET' })

Contracts - Thin, declarative HTTP definitions with 1:1 mapping to SAP ADT endpoints Services - Business logic orchestration combining multiple contract calls

Comparison with adt-client v1

Featurev1 (Legacy)v2 (New)
Type SafetyManual typesGenerated from XSD
ArchitectureService-basedContract-first
DependenciesManyZero
ExtensibilityComplexAdd contracts
TestingDifficultEasy (pure data)
  • adt-contracts - REST API contracts (speci + ts-xsd)
  • adt-schemas - TypeScript schemas from SAP XSD
  • speci - Contract specification system
  • ts-xsd - XSD → TypeScript generation

License

MIT

版本与发布记录

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

版本发布日期距今
0.4.33latest2026/11/023 天前
0.4.312026/11/014 天前
0.4.292026/10/306 天前
0.4.272026/10/307 天前
0.4.252026/10/307 天前
0.4.232026/10/2611 天前

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

@abapify/adt-client 是什么?

Minimalistic speci-based ADT client for SAP ABAP Development Tools

如何安装 @abapify/adt-client?

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

@abapify/adt-client 支持 TypeScript 吗?

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

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

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

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

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

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

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

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

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