Compare commits

..

33 Commits

Author SHA1 Message Date
Heiko Witteborg
b97da977e5 Prepare for serve_on_root false 2023-06-16 10:07:48 +02:00
Christian Georgi
50085fe7be Better clone path 2020-04-20 17:09:47 +02:00
Christian Georgi
8c3733c9cd Add package-lock.json, fix readme 2020-04-02 15:54:15 +02:00
Christian Georgi
a412c41970 Update readme 2020-03-23 17:07:25 +01:00
Harini Gunabalan
e49e9ae823 Update README.md 2020-03-21 23:39:10 +01:00
Harini Gunabalan
6cc2741c3e Adding demo codebase of OpenSAP week3 unit1 2020-03-21 23:39:12 +01:00
Daniel
06755978b2 Removed work-around for auto-exposed entities 2020-02-15 14:31:07 +01:00
Daniel
02469acebb Moved @odata.draft.enabled to app model 2020-02-15 14:25:15 +01:00
Dr. David Kunz
e2b47228db Update services.js 2020-02-12 17:13:35 +01:00
Christian Georgi
13480ad99e Added issue URL again 2020-02-04 09:11:28 +01:00
Daniel
8071faa62d Adding requires.db: {kind:'sql'} 2020-02-03 07:55:56 +01:00
johannes-vogel
9ea294586a remove link 2020-01-31 08:49:54 +01:00
Lakshmi C Rajeev
a56a11ff3e Create index.cds 2020-01-28 10:58:24 +05:30
Matthias Bühl
b4084b45cb rollback change in master 2020-01-27 15:33:14 +01:00
Matthias Bühl
26e3c0d753 check autthorization in cat service 2020-01-27 15:29:43 +01:00
Lakshmi C Rajeev
6d0194acc0 Merge pull request #12 from LakshmiCR/master
Media-server implementation
2020-01-17 15:02:15 +05:30
Lakshmi C Rajeev
db75a99808 Merge branch 'master' into master 2020-01-17 15:01:59 +05:30
Volker Buzek
a04755efed feat(npm): add .npmrc for @sap-scope
- `npm set @sap...` is unnecessary
- update README.md accordingly
2020-01-14 14:55:36 +01:00
Daniel
6a9a1bc4d6 cleaned up dot files 2020-01-04 07:27:19 +01:00
Daniel
a0847e603f settings.json restored 2020-01-04 07:24:11 +01:00
Daniel
b1270bc0eb fixed launch scripts 2020-01-04 07:16:05 +01:00
Lakshmi C Rajeev
ba72d7f478 Update package.json 2020-01-03 14:29:53 +05:30
Lakshmi C Rajeev
cd808c76dd Update media-service.js 2020-01-03 14:07:17 +05:30
Daniel
3a77707f49 Merge pull request #17 from SAP-samples/cleanup
cleaned up start scripts
2020-01-03 03:03:23 +01:00
Daniel
583c97a494 cleaned up start scripts 2020-01-03 02:59:27 +01:00
Daniel
eb7431afed fixed: dev dependency to sqlite3 2019-12-30 13:32:02 +01:00
Lakshmi C Rajeev
630bb2b19c Update package.json 2019-12-19 10:59:57 +05:30
Lakshmi C Rajeev
f9a7aa59de Update media-service.js 2019-12-19 10:43:22 +05:30
Daniel
c0bce5ae5b Merge pull request #14 from SAP-samples/new-fiori-theme
using sap_fiori_3 theme
2019-12-13 20:09:49 +01:00
Daniel
ad05e2b9db using sap_fiori_3 theme 2019-12-13 20:08:41 +01:00
Christian Georgi
b7c2eee961 Fix broken link to VS Code plugin
Fixes #13
2019-12-13 11:55:52 +01:00
Lakshmi C Rajeev
9205e0893a Update media-service.js 2019-12-02 15:27:38 +05:30
Lakshmi C Rajeev
7137bf227e Media-server 2019-11-29 12:30:07 +05:30
17 changed files with 949 additions and 5810 deletions

View File

@@ -6,7 +6,7 @@
"jest": true "jest": true
}, },
"parserOptions": { "parserOptions": {
"ecmaVersion": 2017 "ecmaVersion": 2018
}, },
"globals": { "globals": {
"SELECT": true, "SELECT": true,

27
.vscode/launch.json vendored
View File

@@ -5,19 +5,17 @@
"version": "0.2.0", "version": "0.2.0",
"configurations": [ "configurations": [
{ {
"name": "cds run", "name": "bookshop", "request": "launch", "type": "node", "runtimeExecutable": "npx", "runtimeArgs": [ "-n" ],
"request": "launch", "args": [ "--", "cds", "run", "--in-memory" ],
"type": "node", "cwd": "${workspaceFolder}/packages/bookshop",
"runtimeExecutable": "npx", "console": "integratedTerminal",
"runtimeArgs": ["-n"], "skipFiles": ["<node_internals>/**"]
"args": ["--", "cds", "run", "--with-mocks", "--in-memory?"], // the leading "--" arg ensures it works with as well as without debugging },
{
"name": "cds run ...", "request": "launch", "type": "node", "runtimeExecutable": "npx", "runtimeArgs": [ "-n" ],
"args": [ "--", "cds", "run", "--with-mocks", "--in-memory?" ],
"cwd": "${workspaceFolder}/packages/${input:service}", "cwd": "${workspaceFolder}/packages/${input:service}",
"console": "integratedTerminal", "console": "integratedTerminal",
"serverReadyAction": {
"pattern": "server listening on (https?://\\S+|[0-9]+)",
"uriFormat": "http://localhost:%s",
"action": "openExternally"
},
"skipFiles": ["<node_internals>/**"] "skipFiles": ["<node_internals>/**"]
} }
], ],
@@ -31,12 +29,9 @@
"bookstore", "bookstore",
"media-server", "media-server",
"office-supplies", "office-supplies",
"orders-service", "reviews-service"
"products-service",
"reviews-service",
"user-service"
], ],
"default": "bookstore" "default": "bookshop"
} }
] ]
} }

View File

@@ -1,7 +1,6 @@
{ {
"files.exclude": { "files.exclude": {
"**/.gitignore": false, "**/.gitignore": true,
"**/.git": false, "**/.vscode": true
"**/.vscode": false
} }
} }

19
.vscode/tasks.json vendored
View File

@@ -4,23 +4,14 @@
"version": "2.0.0", "version": "2.0.0",
"tasks": [ "tasks": [
{ {
"type": "shell", "label": "cds run bookshop", "type": "npm", "script": "watch", "path": "packages/bookshop/",
"command": "npx", "args": [ "cds", "watch", "packages/bookshop" ], "options": { "env": { "PORT": "4004" }},
"presentation": { "group": "A" }, "presentation": { "group": "A" }
"problemMatcher": []
}, },
{ {
"type": "shell", "label": "cds run bookshop-enhanced", "type": "npm", "script": "watch", "path": "packages/reviews-service/",
"command": "npx", "args": [ "cds", "watch", "packages/bookshop-enhanced" ],
"presentation": { "group": "A" },
"problemMatcher": []
},
{
"type": "shell", "label": "cds run reviews-service",
"command": "npx", "args": [ "cds", "watch", "packages/reviews-service" ],
"options": { "env": { "PORT": "5005" }}, "options": { "env": { "PORT": "5005" }},
"presentation": { "group": "A" }, "presentation": { "group": "A" }
"problemMatcher": []
} }
] ]
} }

View File

@@ -11,7 +11,7 @@ In SAP Business Application Studio, open a terminal.
Then clone the repo with this specific branch: Then clone the repo with this specific branch:
```sh ```sh
git clone https://github.com/sap-samples/cloud-cap-samples projects/cloud-cap-samples -b openSAP-week4-unit1-final git clone https://github.com/sap-samples/cloud-cap-samples projects/cloud-cap-samples -b openSAP-week3-unit1
cd projects/cloud-cap-samples cd projects/cloud-cap-samples
``` ```

836
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -5,23 +5,24 @@
"author": "daniel.hutzel@sap.com", "author": "daniel.hutzel@sap.com",
"private": true, "private": true,
"scripts": { "scripts": {
"cleanup": "lerna clean -y && rm -fr node_modules",
"install": "(npm -s run lerna) && lerna bootstrap --hoist",
"lerna": "npx --no-install lerna -v > /dev/null || npm i lerna --no-save", "lerna": "npx --no-install lerna -v > /dev/null || npm i lerna --no-save",
"test": "jest", "install": "(npm -s run lerna) && lerna bootstrap --hoist",
"bookshop-enhanced": "cds watch packages/bookshop-enhanced", "cleanup": "lerna clean -y && rm -fr node_modules",
"bookshop": "cds watch packages/bookshop", "bookshop": "cds watch packages/bookshop",
"bookshop-enhanced": "cds watch packages/bookshop-enhanced",
"reviews-service": "cds watch packages/reviews-service",
"bookstore": "cds watch packages/bookstore", "bookstore": "cds watch packages/bookstore",
"products-service": "cds watch packages/products-service", "media-server": "cds watch packages/media-server"
"reviews-service": "cds watch packages/reviews-service"
}, },
"dependencies": { "dependencies": {
"@sap/cds": "^3", "@sap/cds": "^3",
"express": "^4" "express": "^4"
}, },
"devDependencies": {
"sqlite3": "*"
},
"--add-these-to-devDependencies-for-tests": { "--add-these-to-devDependencies-for-tests": {
"@types/jest": "*", "@types/jest": "*",
"sqlite3": "*",
"jest": "*" "jest": "*"
}, },
"license": "SAP SAMPLE CODE LICENSE" "license": "SAP SAMPLE CODE LICENSE"

View File

@@ -43,7 +43,7 @@
<script src="https://sapui5.hana.ondemand.com/resources/sap-ui-core.js" <script src="https://sapui5.hana.ondemand.com/resources/sap-ui-core.js"
data-sap-ui-libs="sap.m, sap.ushell, sap.collaboration, sap.ui.layout" data-sap-ui-libs="sap.m, sap.ushell, sap.collaboration, sap.ui.layout"
data-sap-ui-compatVersion="edge" data-sap-ui-compatVersion="edge"
data-sap-ui-theme="sap_belize" data-sap-ui-theme="sap_fiori_3"
data-sap-ui-frameOptions="allow" data-sap-ui-frameOptions="allow"
></script> ></script>
<script> <script>

View File

@@ -1,5 +1,3 @@
ID;modifiedAt;createdAt;createdBy;modifiedBy;OrderNo;currency_code;status ID;modifiedAt;createdAt;createdBy;modifiedBy;OrderNo;currency_code
da86efd0-4ba1-4078-b7f0-5c9c530297f7;;2019-01-31;ALICE;;1;EUR;processing 7e2f2640-6866-4dcf-8f4d-3027aa831cad;;2019-01-31;john.doe@test.com;;1;EUR
2f2f2640-6866-4dcf-8f4d-3027aa831cad;;2019-03-25;ALICE;;10;EUR;completed 64e718c9-ff99-47f1-8ca3-950c850777d4;;2019-01-30;jane.doe@test.com;;2;EUR
64e718c9-ff99-47f1-8ca3-950c850777d4;;2019-01-30;BOB;;2;EUR;processing
1af3322d-3cb1-46be-b312-0ae9ec311537;;2019-03-16;BOB;;9;EUR;completed
1 ID modifiedAt createdAt createdBy modifiedBy OrderNo currency_code status
2 da86efd0-4ba1-4078-b7f0-5c9c530297f7 7e2f2640-6866-4dcf-8f4d-3027aa831cad 2019-01-31 ALICE john.doe@test.com 1 EUR processing
3 2f2f2640-6866-4dcf-8f4d-3027aa831cad 64e718c9-ff99-47f1-8ca3-950c850777d4 2019-03-25 2019-01-30 ALICE jane.doe@test.com 10 2 EUR completed
64e718c9-ff99-47f1-8ca3-950c850777d4 2019-01-30 BOB 2 EUR processing
1af3322d-3cb1-46be-b312-0ae9ec311537 2019-03-16 BOB 9 EUR completed

View File

@@ -1,16 +1,5 @@
namespace sap.capire.bookshop; namespace sap.capire.bookshop;
using { Currency, managed, cuid } from '@sap/cds/common';
using {
Currency,
managed,
cuid
} from '@sap/cds/common';
type Status : String enum {
completed;
processing;
blocked;
}
entity Books : managed { entity Books : managed {
key ID : Integer; key ID : Integer;
@@ -29,19 +18,15 @@ entity Authors : managed {
dateOfDeath : Date; dateOfDeath : Date;
placeOfBirth : String; placeOfBirth : String;
placeOfDeath : String; placeOfDeath : String;
books : Association to many Books books : Association to many Books on books.author = $self;
on books.author = $self;
} }
entity Orders : cuid, managed { entity Orders : cuid, managed {
OrderNo : String @title:'Order Number'; //> readable key OrderNo : String @title:'Order Number'; //> readable key
status : Status default 'processing'; Items : Composition of many OrderItems on Items.parent = $self;
Items : Composition of many OrderItems
on Items.parent = $self;
total : Decimal(9,2) @readonly; total : Decimal(9,2) @readonly;
currency : Currency; currency : Currency;
} }
entity OrderItems : cuid { entity OrderItems : cuid {
parent : Association to Orders; parent : Association to Orders;
book : Association to Books; book : Association to Books;

View File

@@ -5,20 +5,16 @@
"license": "SAP SAMPLE CODE LICENSE", "license": "SAP SAMPLE CODE LICENSE",
"dependencies": { "dependencies": {
"@sap/cds": "^3", "@sap/cds": "^3",
"express": "^4", "express": "^4"
"@sap/xb-msg-amqp-v100": "^0.9.35"
},
"devDependencies": {
"sqlite3": "^4.1.1"
}, },
"scripts": { "scripts": {
"start": "npx cds run" "start": "cds run --in-memory?",
"watch": "cds watch"
}, },
"cds": { "cds": {
"requires": { "requires": {
"API_BUSINESS_PARTNER": { "db": {
"kind": "odata", "kind": "sql"
"model": "srv/external/API_BUSINESS_PARTNER"
} }
} }
} }

View File

@@ -1,6 +1,6 @@
using { sap.capire.bookshop as my } from '../db/schema'; using { sap.capire.bookshop as my } from '../db/schema';
service AdminService @(_requires:'authenticated-user') { service AdminService @(_requires:'authenticated-user',path:'/admin') {
entity Books as projection on my.Books; entity Books as projection on my.Books;
entity Authors as projection on my.Authors; entity Authors as projection on my.Authors;
entity Orders as select from my.Orders; entity Orders as select from my.Orders;
@@ -10,7 +10,7 @@ service AdminService @(_requires:'authenticated-user') {
annotate AdminService.Orders with @odata.draft.enabled; annotate AdminService.Orders with @odata.draft.enabled;
// annotate AdminService.Books with @odata.draft.enabled; // annotate AdminService.Books with @odata.draft.enabled;
// Temporary workaround -> https://github.wdf.sap.corp/cap/issues/issues/3121 // Temporary workaround -> cap/issues#3121
extend service AdminService with { extend service AdminService with {
entity OrderItems as select from my.OrderItems; entity OrderItems as select from my.OrderItems;
} }

View File

@@ -1,10 +1,11 @@
const cds = require('@sap/cds') const cds = require('@sap/cds')
const { Books } = cds.entities
/** Service implementation for CatalogService */ /** Service implementation for CatalogService */
module.exports = cds.service.impl(function() { module.exports = cds.service.impl(function() {
const { Books, Orders } = this.entities this.after ('READ', 'Books', each => each.stock > 111 && _addDiscount2(each,11))
this.after('READ', Books, each => each.stock > 111 && _addDiscount2(each, 11)) this.before ('CREATE', 'Orders', _reduceStock)
this.before('CREATE', Orders, _reduceStock) })
/** Add some discount for overstocked books */ /** Add some discount for overstocked books */
function _addDiscount2 (each,discount) { function _addDiscount2 (each,discount) {
@@ -23,4 +24,3 @@ module.exports = cds.service.impl(function () {
) )
})) }))
} }
})

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,25 @@
### Service Document
GET http://localhost:4004/admin/Authors
### Create Author
POST http://localhost:4004/admin/Authors HTTP/1.1
content-Type: application/json
{
"ID": 105,
"name": "J.K. Rowling",
"dateOfBirth": null,
"dateOfDeath": null,
"placeOfBirth": "",
"placeOfDeath": ""
}
### Update Author
PATCH http://localhost:4004/admin/Authors/105 HTTP/1.1
content-Type: application/json
{
"placeOfBirth": "United Kingdom"
}
### Delete Author
DELETE http://localhost:4004/admin/Authors/105 HTTP/1.1