Skip to content
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

Extensibility walkthrough in capire #407

Closed
wants to merge 19 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions orders-ext/.cdsrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
31 changes: 31 additions & 0 deletions orders-ext/.gitignore
Original file line number Diff line number Diff line change
@@ -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 changes: 20 additions & 0 deletions orders-ext/.vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -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 changes: 15 additions & 0 deletions orders-ext/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -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>/**" ]
}
]
}
11 changes: 11 additions & 0 deletions orders-ext/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"eslint.validate": [
"cds",
"csn",
"csv",
"csv",
"csv (semicolon)",
"tsv",
"tab"
]
}
25 changes: 25 additions & 0 deletions orders-ext/.vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -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 changes: 26 additions & 0 deletions orders-ext/README.md
Original file line number Diff line number Diff line change
@@ -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 build && cds push` your extension to **test** tenant
- `cds build && cds push` your extension to **prod** tenant


## Learn More

Learn more at https://cap.cloud.sap/docs/guides/extensibility/customization.
25 changes: 25 additions & 0 deletions orders-ext/app/extensions.cds
Original file line number Diff line number Diff line change
@@ -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 x_SalesRegion:name with @title: 'Sales Region';

annotate OrdersService.Orders with @UI.LineItem: [
... up to { Value: OrderNo },
{ Value: x_priority },
{ Value: x_salesRegion.name },
...
];
46 changes: 46 additions & 0 deletions orders-ext/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"name": "@capire/orders-ext",
"extends": "@capire/orders",
"version": "1.0.0",
"description": "An extension to @capire/orders application.",
"license": "UNLICENSED",
"private": true,
"dependencies": {
"@sap/cds": "^6",
"express": "^4"
},
"devDependencies": {
"sqlite3": "^5.1.6"
},
"scripts": {
"start": "cds watch"
},
"eslintConfig": {
"extends": [
"eslint:recommended",
"plugin:@sap/cds/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 changes: 3 additions & 0 deletions orders-ext/test/data/sap.capire.orders-Orders.csv
Original file line number Diff line number Diff line change
@@ -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 changes: 4 additions & 0 deletions orders-ext/test/data/x_orders.ext-x_SalesRegion.csv
Original file line number Diff line number Diff line change
@@ -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
2 changes: 0 additions & 2 deletions orders/.env

This file was deleted.

2 changes: 1 addition & 1 deletion orders/index.cds
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
This model controls what gets exposed
*/
namespace sap.capire.orders;
using from './srv/orders-service';
using from './app/fiori';
using from './db/schema';
21 changes: 18 additions & 3 deletions orders/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,22 @@
"name": "@capire/orders",
"version": "1.0.0",
"dependencies": {
"@capire/common": "*",
"@sap/cds": ">=5"
"@sap/cds": "^6",
"@sap/cds-mtxs": "^1",
"express": "^4"
},
"devDependencies": {
"sqlite3": "^5"
},
"scripts": {
"start": "cds-serve"
},
"cds": {
"profile": "with-mtx-sidecar",
"requires": {
"multitenancy": true,
"toggles": true,
"extensibility": true
}
}
}
}
Loading