Extensibility Walkthrough in capire (#405)
* Extension project template * SalesRegion -> x_SalesRegion * enhanced order repo * updated package-lock.json
This commit is contained in:
1
orders-ext/.cdsrc.json
Normal file
1
orders-ext/.cdsrc.json
Normal file
@@ -0,0 +1 @@
|
||||
{}
|
||||
31
orders-ext/.gitignore
vendored
Normal file
31
orders-ext/.gitignore
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
# CAP ext
|
||||
_out
|
||||
*.db
|
||||
*.sqlite
|
||||
connection.properties
|
||||
default-*.json
|
||||
.cdsrc-private.json
|
||||
gen/
|
||||
node_modules/
|
||||
target/
|
||||
|
||||
# Web IDE, App Studio
|
||||
.che/
|
||||
.gen/
|
||||
|
||||
# MTA
|
||||
*_mta_build_tmp
|
||||
*.mtar
|
||||
mta_archives/
|
||||
|
||||
# Other
|
||||
.DS_Store
|
||||
*.orig
|
||||
*.log
|
||||
|
||||
*.iml
|
||||
*.flattened-pom.xml
|
||||
|
||||
# IDEs
|
||||
# .vscode
|
||||
# .idea
|
||||
20
orders-ext/.vscode/extensions.json
vendored
Normal file
20
orders-ext/.vscode/extensions.json
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
{
|
||||
// See https://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.
|
||||
// Extension identifier format: ${publisher}.${name}. Example: vscode.csharp
|
||||
|
||||
// List of extensions which should be recommended for users of this workspace.
|
||||
"recommendations": [
|
||||
"SAPSE.vscode-cds",
|
||||
"dbaeumer.vscode-eslint",
|
||||
"esbenp.prettier-vscode",
|
||||
"mechatroner.rainbow-csv",
|
||||
"humao.rest-client",
|
||||
"alexcvzz.vscode-sqlite",
|
||||
"hbenl.vscode-mocha-test-adapter",
|
||||
"sdras.night-owl"
|
||||
],
|
||||
// List of extensions recommended by VS Code that should not be recommended for users of this workspace.
|
||||
"unwantedRecommendations": [
|
||||
|
||||
]
|
||||
}
|
||||
15
orders-ext/.vscode/launch.json
vendored
Normal file
15
orders-ext/.vscode/launch.json
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
// Use IntelliSense to learn about possible attributes.
|
||||
// Hover to view descriptions of existing attributes.
|
||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"command": "cds run --with-mocks --in-memory?",
|
||||
"name": "cds run",
|
||||
"request": "launch",
|
||||
"type": "node-terminal",
|
||||
"skipFiles": [ "<node_internals>/**" ]
|
||||
}
|
||||
]
|
||||
}
|
||||
25
orders-ext/.vscode/tasks.json
vendored
Normal file
25
orders-ext/.vscode/tasks.json
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
{
|
||||
// See https://go.microsoft.com/fwlink/?LinkId=733558
|
||||
// for the documentation about the tasks.json format
|
||||
"version": "2.0.0",
|
||||
"tasks": [
|
||||
{
|
||||
"type": "shell",
|
||||
"label": "cds watch",
|
||||
"command": "cds",
|
||||
"args": ["watch"],
|
||||
"group": {
|
||||
"kind": "build",
|
||||
"isDefault": true
|
||||
},
|
||||
"problemMatcher": []
|
||||
},
|
||||
{
|
||||
"type": "shell",
|
||||
"label": "cds run",
|
||||
"command": "cds",
|
||||
"args": ["run", "--with-mocks", "--in-memory?"],
|
||||
"problemMatcher": []
|
||||
}
|
||||
]
|
||||
}
|
||||
26
orders-ext/README.md
Normal file
26
orders-ext/README.md
Normal file
@@ -0,0 +1,26 @@
|
||||
# Getting Started
|
||||
|
||||
Welcome to your extension project to `@capire/orders`.
|
||||
|
||||
It contains these folders and files, following our recommended project layout:
|
||||
|
||||
File or Folder | Purpose
|
||||
---------|----------
|
||||
`app/` | all extensions content is here
|
||||
`test/` | all test content is here
|
||||
`package.json` | project configuration
|
||||
`readme.md` | this getting started guide
|
||||
|
||||
|
||||
## Next Steps
|
||||
|
||||
- `cds pull` latest models from your base application
|
||||
- edit [`./app/extensions.cds`](./app/extensions.cds) to add your extensions
|
||||
- `cds watch` your extension in local test-drives
|
||||
- `cds push` your extension to **test** tenant
|
||||
- `cds push` your extension to **prod** tenant
|
||||
|
||||
|
||||
## Learn More
|
||||
|
||||
Learn more at https://cap.cloud.sap/docs/guides/extensibility/customization.
|
||||
25
orders-ext/app/extensions.cds
Normal file
25
orders-ext/app/extensions.cds
Normal file
@@ -0,0 +1,25 @@
|
||||
namespace x_orders.ext; // for new entities like SalesRegion below
|
||||
using { OrdersService, sap, sap.capire.orders.Orders } from '@capire/orders';
|
||||
|
||||
extend Orders with { // 2 new fields....
|
||||
x_priority : String enum {high; medium; low} default 'medium';
|
||||
x_salesRegion : Association to x_SalesRegion;
|
||||
}
|
||||
|
||||
entity x_SalesRegion : sap.common.CodeList { // Value Help
|
||||
key code : String(11);
|
||||
}
|
||||
|
||||
|
||||
// -------------------------------------------
|
||||
// Fiori Annotations
|
||||
|
||||
annotate Orders:x_priority with @title: 'Priority';
|
||||
annotate SalesRegion:name with @title: 'Sales Region';
|
||||
|
||||
annotate OrdersService.Orders with @UI.LineItem: [
|
||||
... up to { Value: OrderNo },
|
||||
{ Value: x_priority },
|
||||
{ Value: x_salesRegion.name },
|
||||
...
|
||||
];
|
||||
47
orders-ext/package.json
Normal file
47
orders-ext/package.json
Normal file
@@ -0,0 +1,47 @@
|
||||
{
|
||||
"name": "@capire/orders-ext",
|
||||
"extends": "@capire/orders",
|
||||
"version": "1.0.0",
|
||||
"description": "A simple CAP project.",
|
||||
"repository": "<Add your repository here>",
|
||||
"license": "UNLICENSED",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@sap/cds": "^6",
|
||||
"express": "^4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"sqlite3": "^5.0.4"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "cds run"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^16.15"
|
||||
},
|
||||
"eslintConfig": {
|
||||
"extends": "eslint:recommended",
|
||||
"env": {
|
||||
"es2020": true,
|
||||
"node": true,
|
||||
"jest": true,
|
||||
"mocha": true
|
||||
},
|
||||
"globals": {
|
||||
"SELECT": true,
|
||||
"INSERT": true,
|
||||
"UPDATE": true,
|
||||
"DELETE": true,
|
||||
"CREATE": true,
|
||||
"DROP": true,
|
||||
"CDL": true,
|
||||
"CQL": true,
|
||||
"CXL": true,
|
||||
"cds": true
|
||||
},
|
||||
"rules": {
|
||||
"no-console": "off",
|
||||
"require-atomic-updates": "off"
|
||||
}
|
||||
}
|
||||
}
|
||||
3
orders-ext/test/data/sap.capire.orders-Orders.csv
Normal file
3
orders-ext/test/data/sap.capire.orders-Orders.csv
Normal file
@@ -0,0 +1,3 @@
|
||||
ID;createdAt;buyer;OrderNo;currency_code;x_priority;x_salesRegion_code
|
||||
7e2f2640-6866-4dcf-8f4d-3027aa831cad;2019-01-31;john.doe@test.com;1;EUR;high;EMEA
|
||||
64e718c9-ff99-47f1-8ca3-950c850777d4;2019-01-30;jane.doe@test.com;2;EUR;low;APJ
|
||||
|
4
orders-ext/test/data/x_orders.ext-x_SalesRegion.csv
Normal file
4
orders-ext/test/data/x_orders.ext-x_SalesRegion.csv
Normal file
@@ -0,0 +1,4 @@
|
||||
code;name;descr
|
||||
AMER;Americas;North, Central and South America
|
||||
EMEA;Europe, the Middle East and Africa;Europe, the Middle East and Africa
|
||||
APJ;Asia Pacific and Japan;Asia Pacific and Japan
|
||||
|
Reference in New Issue
Block a user