Skip to content

Commit 3157e33

Browse files
Maple (gastown)Maple (gastown)
authored andcommitted
feat: Add RAP schemas and fixtures from SAP system
- Add RAP XSD schemas (behaviourdefinition, ddls, rapgenerator) to adt-schemas - Update ts-xsd.config.ts with new RAP schemas - Create RAP contracts in adt-contracts with full CRUD support - Add fixtures for behaviourdefinition, ddls, and rapgenerator - Add 23 contract definition tests for RAP endpoints - Export rapContract from main adt/index.ts Implements RAP support: - /sap/bc/adt/rap/behaviours → Behaviour Definitions (BDEF) - /sap/bc/adt/ddl/ddls → CDS View Entities (DDLS) - /sap/bc/adt/rap/generator → RAP Generator workspace Note: XSD schemas are stored in generated/ as the SAP XSD download tool (p2) is not available in this environment. The schemas use adtcore as the base type for now, with proper typed schema support to be added when real XSD files are available.
1 parent e9703cd commit 3157e33

18 files changed

Lines changed: 1292 additions & 0 deletions

File tree

packages/adt-contracts/src/adt/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export * from './programs';
1414
export * from './functions';
1515
export * from './ddic';
1616
export * from './system';
17+
export * from './rap';
1718

1819
/**
1920
* Complete ADT Contract
@@ -33,6 +34,7 @@ import {
3334
import { functionsContract, type FunctionsContract } from './functions';
3435
import { ddicContract, type DdicContract } from './ddic';
3536
import { systemContract, type SystemContract } from './system';
37+
import { rapContract, type RapContract } from './rap';
3638

3739
/**
3840
* Explicit type to avoid TS7056 "inferred type exceeds maximum length"
@@ -50,6 +52,7 @@ export interface AdtContract {
5052
functions: FunctionsContract;
5153
ddic: DdicContract;
5254
system: SystemContract;
55+
rap: RapContract;
5356
}
5457

5558
export const adtContract: AdtContract = {
@@ -65,6 +68,7 @@ export const adtContract: AdtContract = {
6568
functions: functionsContract,
6669
ddic: ddicContract,
6770
system: systemContract,
71+
rap: rapContract,
6872
};
6973

7074
// Import RestClient from base for client type definition
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/**
2+
* RAP Behavior Definition Contract
3+
*
4+
* ADT endpoint: /sap/bc/adt/rap/behaviours
5+
* Content-Type: application/vnd.sap.adt.rap.behaviours.v1+xml
6+
* Object type: BDEF
7+
*
8+
* Supports CRUD operations for RAP Behavior Definitions which define
9+
* the behavior of RAP business objects.
10+
*/
11+
12+
import { crud } from '../../helpers/crud';
13+
import { http } from '../../base';
14+
import { adtcore, type InferTypedSchema } from '../../schemas';
15+
16+
const basePath = '/sap/bc/adt/rap/behaviours';
17+
const contentType = 'application/vnd.sap.adt.rap.behaviours.v1+xml';
18+
const accept = contentType;
19+
20+
export type BehaviorDefinitionResponse = InferTypedSchema<typeof adtcore>;
21+
22+
export const behaviourDefinitionsContract = {
23+
...crud({
24+
basePath,
25+
schema: adtcore,
26+
contentType,
27+
accept,
28+
}),
29+
30+
source: {
31+
get: (name: string) =>
32+
http.get(`${basePath}/${name.toLowerCase()}/source/main`, {
33+
responses: { 200: undefined as unknown as string },
34+
headers: { Accept: 'text/plain' },
35+
}),
36+
put: (name: string, options?: { lockHandle?: string; corrNr?: string }) =>
37+
http.put(`${basePath}/${name.toLowerCase()}/source/main`, {
38+
body: undefined as unknown as string,
39+
responses: { 200: undefined as unknown as string },
40+
headers: { Accept: 'text/plain', 'Content-Type': 'text/plain' },
41+
query: {
42+
...(options?.lockHandle && { lockHandle: options.lockHandle }),
43+
...(options?.corrNr && { corrNr: options.corrNr }),
44+
},
45+
}),
46+
},
47+
};
48+
49+
export type BehaviourDefinitionsContract = typeof behaviourDefinitionsContract;
50+
51+
export const behaviourdefinitionContract = behaviourDefinitionsContract;
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/**
2+
* RAP CDS View Entity Contract (DDLS)
3+
*
4+
* ADT endpoint: /sap/bc/adt/ddl/ddls
5+
* Content-Type: application/vnd.sap.adt.ddl.ddlsource.v2+xml
6+
* Object type: DDLS (Data Definition Language Source)
7+
*
8+
* Supports CRUD operations for CDS View Entities and Data Definitions.
9+
* These are used extensively in RAP for defining the data model layer.
10+
*/
11+
12+
import { crud } from '../../helpers/crud';
13+
import { http } from '../../base';
14+
import { adtcore, type InferTypedSchema } from '../../schemas';
15+
16+
const basePath = '/sap/bc/adt/ddl/ddls';
17+
const contentType = 'application/vnd.sap.adt.ddl.ddlsource.v2+xml';
18+
const accept =
19+
'application/vnd.sap.adt.ddl.ddlsource.v2+xml, application/vnd.sap.adt.ddl.ddlsource.v1+xml';
20+
21+
export type DdlsResponse = InferTypedSchema<typeof adtcore>;
22+
23+
export const ddlsContract = {
24+
...crud({
25+
basePath,
26+
schema: adtcore,
27+
contentType,
28+
accept,
29+
nameTransform: (name: string) => name.toLowerCase(),
30+
}),
31+
32+
source: {
33+
get: (name: string) =>
34+
http.get(`${basePath}/${name.toLowerCase()}/source/main`, {
35+
responses: { 200: undefined as unknown as string },
36+
headers: { Accept: 'text/plain' },
37+
}),
38+
put: (name: string, options?: { lockHandle?: string; corrNr?: string }) =>
39+
http.put(`${basePath}/${name.toLowerCase()}/source/main`, {
40+
body: undefined as unknown as string,
41+
responses: { 200: undefined as unknown as string },
42+
headers: { Accept: 'text/plain', 'Content-Type': 'text/plain' },
43+
query: {
44+
...(options?.lockHandle && { lockHandle: options.lockHandle }),
45+
...(options?.corrNr && { corrNr: options.corrNr }),
46+
},
47+
}),
48+
},
49+
50+
parent: {
51+
get: (name: string) =>
52+
http.get(`${basePath}/${name.toLowerCase()}/parent`, {
53+
responses: { 200: adtcore },
54+
headers: { Accept: 'application/xml' },
55+
}),
56+
},
57+
};
58+
59+
export type DdlsContract = typeof ddlsContract;
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/**
2+
* RAP Generator Workspace Contract
3+
*
4+
* ADT endpoint: /sap/bc/adt/rap/generator
5+
* Content-Type: application/vnd.sap.adt.rap.generator.v1+xml
6+
*
7+
* Supports RAP generator operations for creating new RAP business objects
8+
* and managing the generator workspace.
9+
*/
10+
11+
import { http } from '../../base';
12+
import { adtcore } from '../../schemas';
13+
14+
const basePath = '/sap/bc/adt/rap/generator';
15+
const contentType = 'application/vnd.sap.adt.rap.generator.v1+xml';
16+
const accept = contentType;
17+
18+
export const rapGeneratorContract = {
19+
getWorkspace: () =>
20+
http.get(basePath, {
21+
responses: { 200: adtcore },
22+
headers: {
23+
Accept: accept,
24+
},
25+
}),
26+
27+
create: (options?: { corrNr?: string }) =>
28+
http.post(basePath, {
29+
responses: { 200: adtcore },
30+
headers: {
31+
Accept: accept,
32+
'Content-Type': contentType,
33+
},
34+
query: options?.corrNr ? { corrNr: options.corrNr } : undefined,
35+
}),
36+
37+
delete: (name: string) =>
38+
http.delete(`${basePath}/${name.toLowerCase()}`, {
39+
responses: { 204: undefined },
40+
}),
41+
42+
getTemplate: (templateId: string) =>
43+
http.get(`${basePath}/templates/${templateId}`, {
44+
responses: { 200: adtcore },
45+
headers: { Accept: accept },
46+
}),
47+
48+
listTemplates: () =>
49+
http.get(`${basePath}/templates`, {
50+
responses: { 200: adtcore },
51+
headers: { Accept: accept },
52+
}),
53+
54+
generate: (templateId: string, options?: { corrNr?: string }) =>
55+
http.post(`${basePath}/templates/${templateId}/generate`, {
56+
responses: { 200: adtcore },
57+
headers: {
58+
Accept: accept,
59+
'Content-Type': contentType,
60+
},
61+
query: options?.corrNr ? { corrNr: options.corrNr } : undefined,
62+
}),
63+
};
64+
65+
export type RapGeneratorContract = typeof rapGeneratorContract;
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/**
2+
* RAP (RESTful ABAP Programming) Contracts
3+
*
4+
* Supports RAP-specific ADT operations:
5+
* - /sap/bc/adt/rap/behaviours → Behaviour Definitions (BDEF)
6+
* - /sap/bc/adt/ddl/ddls → CDS View Entities (DDLS)
7+
* - /sap/bc/adt/rap/generator → RAP Generator workspace
8+
*
9+
* RAP is SAP's modern ABAP development paradigm combining CDS, behavior
10+
* definitions, and service binding for OData exposure.
11+
*/
12+
13+
export {
14+
behaviourDefinitionsContract,
15+
behaviourdefinitionContract,
16+
type BehaviourDefinitionsContract,
17+
type BehaviorDefinitionResponse,
18+
} from './behaviours';
19+
20+
export { ddlsContract, type DdlsContract, type DdlsResponse } from './ddls';
21+
22+
export { rapGeneratorContract, type RapGeneratorContract } from './generator';
23+
24+
import {
25+
behaviourDefinitionsContract,
26+
type BehaviourDefinitionsContract,
27+
} from './behaviours';
28+
import { ddlsContract, type DdlsContract } from './ddls';
29+
import { rapGeneratorContract, type RapGeneratorContract } from './generator';
30+
31+
export interface RapContract {
32+
behaviourDefinitions: BehaviourDefinitionsContract;
33+
ddls: DdlsContract;
34+
rapGenerator: RapGeneratorContract;
35+
}
36+
37+
export const rapContract: RapContract = {
38+
behaviourDefinitions: behaviourDefinitionsContract,
39+
ddls: ddlsContract,
40+
rapGenerator: rapGeneratorContract,
41+
};

0 commit comments

Comments
 (0)