@abapify/adt合同
SAP APT REST API合同 - 使用 speci + 键 ts-xsd 计划.
部分 生化单体。 。 。 .
这是什么?
这个包是 合同层 介于 adt-client 财务报告和审定财务报表 adt-schemas它为SAP ADT(ABAP开发工具)端点提供了声明性REST API合同.
┌─────────────────────────────────────────────────────────────────┐
│ adt-client │
│ (HTTP Client + Request Execution) │
└─────────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────┐
│ adt-contracts (this package) │
│ (REST API Contracts using speci + ts-xsd) │
└─────────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────┐
│ adt-schemas │
│ (TypeScript schemas from SAP XSD definitions) │
└─────────────────────────────────────────────────────────────────┘
合同是界定下列内容的纯数据结构:
- 端点 URL - 返回路径
- HTTP 方法 - 得到,邮递,PUT,德利特
- 请求/响应计划 - 使用
ts-xsd根据 SAP XSD 定义生成 - 内容 - 类型 - SAP供应商特有的媒体类型
安装
bun add adt-contracts
使用量
带有 speci 客户端
import { adtContract } from 'adt-contracts';
import { createClient } from 'speci/rest';
const client = createClient(adtContract, {
baseUrl: 'https://sap-server.example.com/sap/bc/adt',
adapter: myAdapter,
});
// Full type inference from XSD schemas!
const transport = await client.cts.getTransportRequests();
const classInfo = await client.oo.getClass('ZCL_MY_CLASS');
个人合同
import { ctsContract, atcContract, ooContract } from 'adt-contracts';
// Use specific contracts
const cts = createClient(ctsContract, config);
const atc = createClient(atcContract, config);
现有合同
| 合同 | 说明 |
|---|---|
coreContract | 核心 ADT 对象操作 |
ctsContract | 变革和运输系统 |
atcContract | ABAP 测试舱 |
ooContract | 面向对象(类、接口) |
建筑
adt-contracts (this package)
├── speci contracts (endpoint definitions)
└── adt-schemas (ts-xsd schemas)
└── ts-xsd (XSD → TypeScript)
合同是纯数据 没有HTTP客户端 没有商业逻辑 与任意 speci- 兼容的适配器.
添加新合同
- 确保在
adt-schemas - 创建合同文件于
src/adt/<feature>/index.ts - 使用
adtHttp.get/post/put/delete - 导出自
src/adt/index.ts
import { adtHttp } from '../../base';
import { mySchema } from 'adt-schemas';
export const myContract = {
getResource: (id: string) =>
adtHttp.get(`/my/endpoint/${id}`, {
responses: { 200: mySchema },
headers: { Accept: 'application/vnd.sap.adt.my.v1+xml' },
}),
};
许可证
麻省理工学院