extension-restrictions
Rule Details
CAP provides intrinsic extensibility, which means all your entities and services are extensible by default. Your SaaS app becomes the base app for extensions by your customers, and your data model the base model. Normally, you'll want to restrict which services or entities your SaaS customers are allowed to extend and to what degree they may do so. This rule ensures that extensions do not violate any restrictions set by the extended SaaS app.
Examples
✅ Correct example
cds
using { sap.capire.orders, OrdersService, sap.common } from 'base-app';
namespace x_bookshop.extension;
extend orders.Orders with {
x_priority : String;
x_SalesRegion : Association to x_SalesRegion;
}
entity x_SalesRegion: common.CodeList {
key regionCode : String(11);
}
1
2
3
4
5
6
7
8
9
10
11
12
13
2
3
4
5
6
7
8
9
10
11
12
13
❌ Incorrect example
cds
using { sap.capire.orders, OrdersService, sap.common } from 'base-app';
namespace x_bookshop.extension;
extend orders.Orders with {
x_priority : String;
x_SalesRegion : Association to x_SalesRegion;
// Element 'other' in 'sap.capire.orders.Orders' must start with x_.
other : String;
}
extend service OrdersService with {
// 'OrdersService.x_SalesRegion' exceeds extension limit of 1
// for Service 'OrdersService'.
entity x_SalesRegion as projection on extension.x_SalesRegion;
// 'OrdersService.x_MyOrders' exceeds extension limit of 1
// for Service 'OrdersService'.
entity x_MyOrders as projection on orders.Orders;
}
@sql.append: 'foo'
// Annotation '@sql.append' in 'x_bookshop.extension.x_SalesRegion'
// is not supported in extensions
entity x_SalesRegion: common.CodeList {
key regionCode : String(11);
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
Version
This rule was introduced in @sap/eslint-plugin-cds 2.6.0
.