@abapify/adt-schemas

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

ADT XML schemas generated from SAP XSD definitions

原始使用文档
文档目录32 节
  1. Overview
  2. Key Features
  3. Architecture Highlights
  4. Installation
  5. Quick Start
  6. Parse ADT XML
  7. Build ADT XML
  8. Use with speci Contracts
  9. Available Schemas
  10. Core Schemas
  11. Repository Objects
  12. Transport Management
  13. ATC (ABAP Test Cockpit)
  14. Debugging & Tracing
  15. Templates
  16. Type System
  17. Pre-generated Interfaces
  18. Shared Types
  19. Type Hierarchy
  20. Schema Structure
  21. Cross-Schema Type Resolution
  22. Architecture
  23. Generation Pipeline
  24. Custom Schemas (ABAP XML Format)
  25. Key Points
  26. Development
  27. Regenerate Schemas
  28. Add New Schema
  29. Testing
  30. speci Integration
  31. Related Packages
  32. License

@abapify/adt-schemas

version

Type-safe SAP ADT schemas generated from official XSD definitions with shared types and optimal tree-shaking.

Overview

This package provides TypeScript schemas for SAP ADT (ABAP Development Tools) REST APIs, auto-generated from SAP's official XSD schema definitions using @abapify/ts-xsd.

Key Features

  • 204+ TypeScript interfaces - Pre-generated, no runtime inference overhead
  • Shared types across schemas - AdtObject, LinkType, etc. are defined once
  • Optimal bundling - Tree-shakeable, import only what you need
  • Full type safety - Compile-time validation of XML parsing/building
  • speci integration - Works directly with REST contract definitions

Architecture Highlights

XSD Files (SAP Official)
    ↓ ts-xsd codegen
Schema Literals (as const)
    ↓ interface generator
TypeScript Interfaces (204 types)
    ↓ typed() wrapper
Typed Schemas (parse/build)

Single source of truth: All type definitions flow from XSD → TypeScript, eliminating manual type maintenance.

Installation

npm install @abapify/adt-schemas
# or
bun add @abapify/adt-schemas

Quick Start

Parse ADT XML

import { classes, type AbapClass } from '@abapify/adt-schemas';

// Parse XML to typed object
const xml = await fetch('/sap/bc/adt/oo/classes/zcl_my_class').then((r) =>
  r.text(),
);
const data = classes.parse(xml);

// Full type safety - TypeScript knows all properties
console.log(data.name); // string
console.log(data.category); // 'generalObjectType' | 'exceptionClass' | ...
console.log(data.include?.[0]); // AbapClassInclude | undefined

Build ADT XML

import { classes } from '@abapify/adt-schemas';

const xml = classes.build({
  name: 'ZCL_MY_CLASS',
  type: 'CLAS/OC',
  category: 'generalObjectType',
  final: false,
  abstract: false,
});

Use with speci Contracts

import { classes, configurations } from '@abapify/adt-schemas';
import { http } from 'speci/rest';

const adtContracts = {
  getClass: (name: string) =>
    http.get(`/sap/bc/adt/oo/classes/${name}`, {
      responses: { 200: classes },
    }),

  getConfigurations: () =>
    http.get(
      '/sap/bc/adt/cts/transportrequests/searchconfiguration/configurations',
      {
        responses: { 200: configurations },
      },
    ),
};

Available Schemas

Core Schemas

SchemaTypeDescription
adtcoreAdtObjectCore ADT object types
atomLinkTypeAtom feed format (links, categories)
abapsourceAbapSourceObjectABAP source code structures
abapooAbapOoObjectABAP OO base types

Repository Objects

SchemaTypeDescription
classesAbapClassABAP class metadata
interfacesAbapInterfaceABAP interface metadata
packagesV1PackagePackage/devclass metadata

Transport Management

SchemaTypeDescription
transportfindAbapTransport search (ABAP XML format)
transportmanagmentCreateRootTypeTransport creation
configurationsConfigurationsSearch configurations
configurationConfigurationSingle configuration

ATC (ABAP Test Cockpit)

SchemaTypeDescription
atcAtcWorklistATC main schema
atcworklistAtcWorklistATC worklist
atcresultAtcWorklistATC results
checklistCheckMessageListCheck message lists
quickfixesAtcQuickfixesATC quickfixes

Debugging & Tracing

SchemaTypeDescription
logpointAdtLogpointLogpoint definitions
tracesTracesTrace data

Templates

SchemaTypeDescription
templatelinkLinkTypeTemplate links
templatelinkExtendedTemplateLinksTypeExtended template links

Type System

Pre-generated Interfaces

All types are pre-generated as TypeScript interfaces, avoiding runtime inference overhead:

// Import types directly
import type {
  AbapClass,
  AbapInterface,
  AdtObject,
  AdtObjectReference,
  LinkType,
} from '@abapify/adt-schemas';

// Use in your code
function processClass(cls: AbapClass) {
  console.log(cls.name);
  console.log(cls.superClassRef?.name);
  cls.include?.forEach((inc) => console.log(inc.includeType));
}

Shared Types

Types are shared across schemas - AdtObject is defined once and reused:

// All these extend AdtObject
interface AbapSourceObject extends AdtObject { ... }
interface AbapOoObject extends AbapSourceMainObject { ... }
interface AbapClass extends AbapOoObject { ... }
interface AbapInterface extends AbapOoObject { ... }

Type Hierarchy

AdtObject
├── AdtMainObject
│   └── AbapSourceMainObject
│       └── AbapOoObject
│           ├── AbapClass
│           └── AbapInterface
└── AbapSourceObject
    └── AbapClassInclude

Schema Structure

Each schema is a W3C-compliant XSD representation with linked imports:

// Generated schema literal (classes.ts)
export default {
  $xmlns: {
    adtcore: "http://www.sap.com/adt/core",
    abapoo: "http://www.sap.com/adt/oo",
    class: "http://www.sap.com/adt/oo/classes",
  },
  $imports: [adtcore, abapoo, abapsource],  // Linked schemas
  targetNamespace: "http://www.sap.com/adt/oo/classes",
  element: [
    { name: "abapClass", type: "class:AbapClass" },
  ],
  complexType: [
    {
      name: "AbapClass",
      complexContent: {
        extension: {
          base: "abapoo:AbapOoObject",  // Type inheritance
          sequence: { element: [...] },
          attribute: [...],
        }
      }
    }
  ],
} as const;

Cross-Schema Type Resolution

The $imports array enables cross-schema type resolution:

// classes schema imports adtcore, abapoo, abapsource
// Type "adtcore:AdtObjectReference" resolves to AdtObjectReference interface
// Type "abapoo:AbapOoObject" resolves to AbapOoObject interface

Architecture

@abapify/adt-schemas
├── src/
│   ├── index.ts              # Main exports
│   ├── speci.ts              # typed() wrapper factory
│   └── schemas/
│       ├── index.ts          # Re-exports from generated
│       └── generated/
│           ├── index.ts      # Typed schema exports
│           ├── schemas/
│           │   ├── sap/      # SAP official schemas (23 files)
│           │   └── custom/   # Custom schemas (9 files)
│           └── types/
│               └── index.ts  # 204 TypeScript interfaces

Generation Pipeline

1. Download XSD     → .xsd/model/*.xsd
2. Parse XSD        → Schema objects (ts-xsd)
3. Generate Literal → schemas/sap/*.ts (as const)
4. Generate Types   → types/index.ts (interfaces)
5. Wrap with typed()→ index.ts (parse/build methods)

Custom Schemas (ABAP XML Format)

Some SAP endpoints return ABAP XML format (asx:abap envelope) without official XSD. Create manual schemas in src/schemas/generated/schemas/custom/:

// schemas/custom/transportfind.ts
export default {
  $xmlns: { asx: 'http://www.sap.com/abapxml' },
  targetNamespace: 'http://www.sap.com/abapxml',
  element: [{ name: 'abap', type: 'Abap' }],
  complexType: [
    {
      name: 'Abap',
      sequence: {
        element: [{ name: 'values', type: 'Values' }],
      },
      attribute: [{ name: 'version', type: 'xs:string' }],
    },
  ],
  // ... more types
} as const; // CRITICAL: 'as const' required!

Key Points

  1. as const - Required for type inference
  2. Element names without prefix - Use 'abap', not 'asx:abap'
  3. Add to typed index - Register in generated/index.ts

Development

Regenerate Schemas

# Full regeneration pipeline
npx nx run adt-schemas:generate

# Individual steps
npx nx run adt-schemas:download   # Download XSD files
npx nx run adt-schemas:codegen    # Generate schema literals
npx nx run adt-schemas:types      # Generate TypeScript interfaces

Add New Schema

  1. Add XSD to .xsd/model/sap/ or create custom schema
  2. Update generation config
  3. Run npx nx run adt-schemas:generate
  4. Add typed wrapper in generated/index.ts
  5. Add test scenario (mandatory)

Testing

# Run all tests
npx nx test adt-schemas

# Run specific test
npx vitest run tests/scenarios.test.ts

Every schema must have a test scenario with real SAP XML fixtures.

speci Integration

Schemas implement the Serializable interface for seamless speci integration:

interface Serializable<T> {
  parse(raw: string): T;
  build?(data: T): string;
}

This enables automatic type inference in REST contracts:

import { classes } from '@abapify/adt-schemas';

const contract = http.get('/sap/bc/adt/oo/classes/zcl_test', {
  responses: { 200: classes },
});

// Response type is automatically inferred as AbapClass
const response = await client.execute(contract);
console.log(response.data.name); // TypeScript knows this is string

License

MIT

版本与发布记录

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

版本发布日期距今
0.4.34latest2026/11/033 天前
0.4.332026/11/023 天前
0.4.322026/11/023 天前
0.4.302026/10/316 天前
0.4.292026/10/306 天前
0.4.282026/10/307 天前

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

@abapify/adt-schemas 是什么?

ADT XML schemas generated from SAP XSD definitions

如何安装 @abapify/adt-schemas?

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

@abapify/adt-schemas 支持 TypeScript 吗?

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

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

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

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

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

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

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

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

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