-
Notifications
You must be signed in to change notification settings - Fork 1
RAP contracts integration tests #94
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| /** | ||
| * ADT RAP Behavior Definition Contract | ||
| * | ||
| * Endpoint: /sap/bc/adt/rap/behavdeft | ||
| * | ||
| * Behavior Definitions (BDEF) define the behavior of RAP business objects. | ||
| * They specify which operations (create, update, delete, read, actions) | ||
| * are supported and how they behave. | ||
| * | ||
| * The BDEF contract supports: | ||
| * - GET: Retrieve BDEF metadata | ||
| * - POST: Create new BDEF | ||
| * - PUT: Update existing BDEF | ||
| * - DELETE: Remove BDEF | ||
| * - Lock/Unlock for editing | ||
| * - Source code access | ||
| */ | ||
|
|
||
| import { crud } from '../../base'; | ||
| import { classes as classesSchema } from '../../schemas'; | ||
|
|
||
| export const behavdeftContract = crud({ | ||
| basePath: '/sap/bc/adt/rap/behavdeft', | ||
| schema: classesSchema, | ||
| contentType: 'application/vnd.sap.adt.rap.behavdeft.v1+xml', | ||
| accept: | ||
| 'application/vnd.sap.adt.rap.behavdeft.v1+xml, application/vnd.sap.adt.rap.behavdeft+xml', | ||
| sources: ['main'] as const, | ||
| }); | ||
|
|
||
| export type BehavdeftContract = typeof behavdeftContract; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| /** | ||
| * ADT RAP CDS View/Entity Contract | ||
| * | ||
| * Endpoint: /sap/bc/adt/ddl/ddls | ||
| * | ||
| * CDS Views and View Entities are core RAP data sources. | ||
| * DDLS (Data Definition Language Source) objects define: | ||
| * - CDS Views: define projection views on database tables | ||
| * - View Entities: RAP-managed CDS views with behavior | ||
| * | ||
| * This contract handles CRUD operations for all DDLS objects, | ||
| * including RAP-managed ones that have behavior definitions. | ||
| * | ||
| * Note: While DDLS is the generic DDL endpoint, RAP-managed | ||
| * CDS objects are specifically identified by their type | ||
| * (e.g., zrap_c_view for managed view entities). | ||
| */ | ||
|
|
||
| import { crud } from '../../base'; | ||
| import { classes as classesSchema } from '../../schemas'; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔴 Wrong schema ( Same issue as with behavdeft: the Was this helpful? React with 👍 or 👎 to provide feedback. |
||
|
|
||
| export const ddlsContract = crud({ | ||
| basePath: '/sap/bc/adt/ddl/ddls', | ||
| schema: classesSchema, | ||
| contentType: 'application/vnd.sap.adt.ddl.ddlsource.v2+xml', | ||
| accept: | ||
| 'application/vnd.sap.adt.ddl.ddlsource.v2+xml, application/vnd.sap.adt.ddl.ddlsource.v1+xml, application/vnd.sap.adt.ddl.ddlsource+xml', | ||
| sources: ['main'] as const, | ||
| }); | ||
|
|
||
| export type DdlsContract = typeof ddlsContract; | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,156 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * ADT RAP Generator Workspace Contract | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * Endpoint: /sap/bc/adt/rap/generator | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * RAP Generator is used to generate RAP artifacts from CDS views. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * It can create: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * - Business object (BO) projections | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * - Behavior definitions | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * - Service bindings | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * - OData services | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * The generator workspace manages the generation process | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * and tracks which artifacts have been generated. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { http } from '../../base'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { classes as classesSchema } from '../../schemas'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔴 Wrong schema ( Same issue as with behavdeft and ddls: the Was this helpful? React with 👍 or 👎 to provide feedback. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export const generatorContract = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * GET /sap/bc/adt/rap/generator - List generator workspace contents | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| list: () => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| http.get('/sap/bc/adt/rap/generator', { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| responses: { 200: classesSchema }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| headers: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Accept: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 'application/vnd.sap.adt.rap.generator.v1+xml, application/vnd.sap.adt.rap.generator+xml', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * GET /sap/bc/adt/rap/generator/{name} - Get generator workspace item | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| get: (name: string) => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| http.get(`/sap/bc/adt/rap/generator/${name.toLowerCase()}`, { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| responses: { 200: classesSchema }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| headers: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Accept: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 'application/vnd.sap.adt.rap.generator.v1+xml, application/vnd.sap.adt.rap.generator+xml', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * POST /sap/bc/adt/rap/generator - Create generator workspace item | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| create: (options?: { corrNr?: string }) => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| http.post('/sap/bc/adt/rap/generator', { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| body: classesSchema, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| responses: { 200: classesSchema }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| headers: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Accept: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 'application/vnd.sap.adt.rap.generator.v1+xml, application/vnd.sap.adt.rap.generator+xml', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 'Content-Type': 'application/vnd.sap.adt.rap.generator.v1+xml', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| query: options?.corrNr ? { corrNr: options.corrNr } : undefined, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * PUT /sap/bc/adt/rap/generator/{name} - Update generator workspace item | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| update: (name: string, options?: { corrNr?: string; lockHandle?: string }) => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| http.put(`/sap/bc/adt/rap/generator/${name.toLowerCase()}`, { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| body: classesSchema, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| responses: { 200: classesSchema }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| headers: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Accept: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 'application/vnd.sap.adt.rap.generator.v1+xml, application/vnd.sap.adt.rap.generator+xml', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 'Content-Type': 'application/vnd.sap.adt.rap.generator.v1+xml', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| query: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ...(options?.corrNr ? { corrNr: options.corrNr } : {}), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ...(options?.lockHandle ? { lockHandle: options.lockHandle } : {}), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * DELETE /sap/bc/adt/rap/generator/{name} - Delete generator workspace item | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| delete: (name: string, options?: { corrNr?: string; lockHandle?: string }) => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| http.delete(`/sap/bc/adt/rap/generator/${name.toLowerCase()}`, { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| responses: { 204: undefined }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| query: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ...(options?.corrNr ? { corrNr: options.corrNr } : {}), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ...(options?.lockHandle ? { lockHandle: options.lockHandle } : {}), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * POST /sap/bc/adt/rap/generator/{name}?_action=LOCK - Lock for editing | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| lock: (name: string, options?: { corrNr?: string }) => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| http.post(`/sap/bc/adt/rap/generator/${name.toLowerCase()}`, { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| responses: { 200: undefined }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| headers: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 'X-sap-adt-sessiontype': 'stateful', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 'x-sap-security-session': 'use', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Accept: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 'application/*,application/vnd.sap.as+xml;charset=UTF-8;dataname=com.sap.adt.lock.result', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| query: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| _action: 'LOCK', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| accessMode: 'MODIFY', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ...(options?.corrNr ? { corrNr: options.corrNr } : {}), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * POST /sap/bc/adt/rap/generator/{name}?_action=UNLOCK - Unlock | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| unlock: (name: string, lockHandle: string) => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| http.post(`/sap/bc/adt/rap/generator/${name.toLowerCase()}`, { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| responses: { 200: undefined }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| headers: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 'X-sap-adt-sessiontype': 'stateful', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 'x-sap-security-session': 'use', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| query: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| _action: 'UNLOCK', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| accessMode: 'MODIFY', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| lockHandle, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+112
to
+124
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 Generator The hand-written
Suggested change
Was this helpful? React with 👍 or 👎 to provide feedback. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * GET /sap/bc/adt/rap/generator/{name}/source/main - Get source code | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| getSource: (name: string) => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| http.get(`/sap/bc/adt/rap/generator/${name.toLowerCase()}/source/main`, { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| responses: { 200: undefined as unknown as string }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| headers: { Accept: 'text/plain' }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * PUT /sap/bc/adt/rap/generator/{name}/source/main - Update source code | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| putSource: ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| name: string, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| options?: { corrNr?: string; lockHandle?: string }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| http.put(`/sap/bc/adt/rap/generator/${name.toLowerCase()}/source/main`, { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| body: undefined as unknown as string, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| responses: { 200: undefined as unknown as string }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| headers: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Accept: 'text/plain', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 'Content-Type': 'text/plain', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| query: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ...(options?.corrNr ? { corrNr: options.corrNr } : {}), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ...(options?.lockHandle ? { lockHandle: options.lockHandle } : {}), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export type GeneratorContract = typeof generatorContract; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| /** | ||
| * ADT RAP (RESTful ABAP Programming) Contracts | ||
| * | ||
| * RAP is the modern ABAP development model for building OData services. | ||
| * These contracts cover: | ||
| * - Behavior Definitions (BDEF) - /sap/bc/adt/rap/behavdeft | ||
| * - CDS View/Entity (DDLS) - /sap/bc/adt/ddl/ddls | ||
| * - RAP Generator - /sap/bc/adt/rap/generator | ||
| * | ||
| * RAP-managed CDS objects extend standard DDIC objects with additional | ||
| * metadata and versioning for the RAP framework. | ||
| */ | ||
|
|
||
| export * from './behavdeft'; | ||
| export * from './ddls'; | ||
| export * from './generator'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔴 Wrong schema (
classes) used for Behavior Definition contract — will misparse XML at runtimeThe
behavdeftContractusesclasses(the ABAP OO Classes schema rooted in namespacehttp://www.sap.com/adt/oo/classeswithAbapClassas root element) as its schema. This schema defines class-specific attributes likefinal,abstract,sharedMemoryEnabled,constructorGenerated, etc. (packages/adt-schemas/src/schemas/generated/schemas/sap/classes.ts). When the client callsadtContract.rap.behavdeft.get(...), theclassesschema'sparse()will attempt to interpret BDEF XML as OO class XML, producing incorrect/empty results. Similarly,post()/put()willbuild()OO class XML instead of BDEF XML. Every other contract in the codebase uses its matching schema (e.g.,domains→domain,interfaces→interfaces).Prompt for agents
Was this helpful? React with 👍 or 👎 to provide feedback.