Compare commits

..

10 Commits

Author SHA1 Message Date
D065023
926a3eaa9a fixed version 2019-10-25 09:55:42 +02:00
johannes-vogel
de871e11cb Update README.md 2019-09-23 14:13:42 +02:00
d045778
b5684841e6 final state of exercise 4 2019-09-23 13:45:43 +02:00
d045778
00f118deed final state of exercise 3 2019-09-23 13:32:14 +02:00
d045778
fb8f6acac7 final state of exercise 2 2019-09-23 13:25:44 +02:00
d045778
1e28cb217f final state of exercise 1 2019-09-23 13:19:24 +02:00
d045778
2fc2cea260 add sap registry to npmrc 2019-09-23 13:06:09 +02:00
johannes-vogel
bfaaf36e14 Fix Key in Products 2019-09-22 13:32:18 +02:00
johannes-vogel
33b24c8d96 Use version 3.17.4 (#1) 2019-09-21 11:36:45 +02:00
i079695
387b25b1bf Add initial branch for CAA265 2019-09-11 11:07:11 +02:00
207 changed files with 1266 additions and 12345 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -1,9 +0,0 @@
{
"name": "approuter",
"dependencies": {
"@sap/approuter": "^20.0.0"
},
"scripts": {
"start": "node node_modules/@sap/approuter/approuter.js"
}
}

View File

@@ -1 +0,0 @@
../../../bookshop/app/vue

View File

@@ -1 +0,0 @@
../../../orders/app/orders

View File

@@ -1 +0,0 @@
../../../reviews/app/vue

View File

@@ -1,41 +0,0 @@
{
"welcomeFile": "app/bookshop/index.html",
"routes": [
{
"source": "^/app/(.*)$",
"target": "$1",
"localDir": "resources",
"cacheControl": "no-cache, no-store, must-revalidate"
},
{
"source": "^/admin/(.*)$",
"target": "/admin/$1",
"destination": "bookstore-api",
"csrfProtection": true
},
{
"source": "^/browse/(.*)$",
"target": "/browse/$1",
"destination": "bookstore-api",
"csrfProtection": true
},
{
"source": "^/user/(.*)$",
"target": "/user/$1",
"destination": "bookstore-api",
"csrfProtection": true
},
{
"source": "^/odata/v4/orders/(.*)$",
"target": "/odata/v4/orders/$1",
"destination": "orders-api",
"csrfProtection": true
},
{
"source": "^/reviews/(.*)$",
"target": "/reviews/$1",
"destination": "reviews-api",
"csrfProtection": true
}
]
}

24
.eslintrc Normal file
View File

@@ -0,0 +1,24 @@
{
"extends": "eslint:recommended",
"env": {
"node": true,
"es6": true,
"jest": true
},
"parserOptions": {
"ecmaVersion": 2017
},
"globals": {
"SELECT": true,
"INSERT": true,
"UPDATE": true,
"DELETE": true,
"CREATE": true,
"DROP": true,
"cds": true
},
"rules": {
"no-console": "off",
"require-atomic-updates": "off"
}
}

View File

@@ -1,5 +0,0 @@
blank_issues_enabled: false
contact_links:
- name: This channel is CLOSED.
about: Use SAP community instead
url: https://answers.sap.com/tags/9f13aee1-834c-4105-8e43-ee442775e5ce

View File

@@ -1,23 +0,0 @@
version: 2
updates:
- package-ecosystem: npm
directory: /
versioning-strategy: increase-if-necessary
schedule:
interval: weekly
groups:
production-dependencies:
dependency-type: "production"
development-dependencies:
dependency-type: "development"
ignore:
- dependency-name: "chai"
# chai 5 doesn't work atm w/ cds.test, TODO fix that in cds.test
versions: ["5.x"]
- dependency-name: "chai-as-promised"
# chai-as-promised 8 doesn't work atm w/ cds.test, TODO fix that in cds.test
versions: ["8.x"]
- dependency-name: "express"
# express 5 not supported atm
versions: ["5.x"]

View File

@@ -1,38 +0,0 @@
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
name: CI
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [22.x, 20.x]
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- run: npm ci
- run: npm test
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22.x
- run: npm ci
- run: npm run lint

10
.gitignore vendored
View File

@@ -12,14 +12,4 @@ target/
*.mtar *.mtar
connection.properties connection.properties
default-env.json default-env.json
.cdsrc-private.json
packages/messageBox packages/messageBox
reviews/msg-box
reviews/db/test.db
*.openapi3.json
*.sqlite
*.db
@types/
@cds-models/

2
.npmrc Normal file
View File

@@ -0,0 +1,2 @@
@sap:registry=https://npm.sap.com
package-lock=false

View File

@@ -1,29 +0,0 @@
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: cloud-cap-samples
Upstream-Contact: <Christian Georgi (christian.georgi@sap.com)>
Source: https://github.com/SAP-samples/cloud-cap-samples
Disclaimer: The code in this project may include calls to APIs (“API Calls”) of
SAP or third-party products or services developed outside of this project
(“External Products”).
“APIs” means application programming interfaces, as well as their respective
specifications and implementing code that allows software to communicate with
other software.
API Calls to External Products are not licensed under the open source license
that governs this project. The use of such API Calls and related External
Products are subject to applicable additional agreements with the relevant
provider of the External Products. In no event shall the open source license
that governs this project grant any rights in or to any External Products,or
alter, expand or supersede any terms of the applicable additional agreements.
If you have a valid license agreement with SAP for the use of a particular SAP
External Product, then you may make use of any API Calls included in this
project’s code for that SAP External Product, subject to the terms of such
license agreement. If you do not have a valid license agreement for the use of
a particular SAP External Product, then you may only make use of any API Calls
in this project for that SAP External Product for your internal, non-productive
and non-commercial test and evaluation of such API Calls. Nothing herein grants
you any rights to use or access any SAP External Product, or provide any third
parties the right to use of access any SAP External Product, through API Calls.
Files: *.*
Copyright: 2019-2025 SAP SE or an SAP affiliate company and cap-cloud-samples
License: Apache-2.0

View File

@@ -1,17 +0,0 @@
{
// 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": [
"qwtel.sqlite-viewer",
"sapse.vscode-cds",
"dbaeumer.vscode-eslint",
"mechatroner.rainbow-csv",
"humao.rest-client",
],
// List of extensions recommended by VS Code that should not be recommended for users of this workspace.
"unwantedRecommendations": [
]
}

34
.vscode/launch.json vendored
View File

@@ -1,34 +0,0 @@
{
// 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": [
{
"name": "bookshop",
"command": "npx cds watch bookshop",
"type": "node-terminal",
"request": "launch",
"skipFiles": [
"<node_internals>/**",
"**/node_modules/**",
"**/cds/lib/lazy.js",
"**/cds/lib/req/cds-context.js",
"**/odata-v4/okra/**"
]
},
{
"name": "bookstore",
"command": "npx cds watch bookstore",
"type": "node-terminal",
"request": "launch",
"skipFiles": [
"<node_internals>/**",
"**/node_modules/**",
"**/cds/lib/lazy.js",
"**/cds/lib/req/cds-context.js",
"**/odata-v4/okra/**"
]
}
]
}

16
.vscode/settings.json vendored
View File

@@ -1,16 +0,0 @@
{
"files.exclude": {
"**/node_modules": true,
"LICENSES": true,
".reuse": true
},
"debug.javascript.terminalOptions": {
"skipFiles": [
"<node_internals>/**",
"**/node_modules/**",
"**/cds/lib/lazy.js",
"**/cds/lib/req/cds-context.js",
"**/odata-v4/okra/**"
]
}
}

15
.vscode/tasks.json vendored
View File

@@ -1,15 +0,0 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"type": "npm",
"script": "jest",
"group": {
"kind": "test",
"isDefault": true
}
}
]
}

391
LICENSE
View File

@@ -1,201 +1,190 @@
Apache License SAP SAMPLE CODE LICENSE AGREEMENT
Version 2.0, January 2004
http://www.apache.org/licenses/ Please scroll down and read the following SAP Sample Code License Agreement
carefully ("Agreement"). By downloading, installing, or otherwise using the
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION SAP sample code or any materials that accompany the sample code documentation
(collectively, the "Sample Code"), You agree that this Agreement forms a legally
1. Definitions. binding agreement between You ("You" or "Your") and SAP SE, for and on behalf
of itself and its subsidiaries and affiliates (as defined in Section 15 of the
"License" shall mean the terms and conditions for use, reproduction, German Stock Corporation Act), and You agree to be bound by all of the terms
and distribution as defined by Sections 1 through 9 of this document. and conditions stated in this Agreement. If You are trying to access or download
the Sample Code on behalf of Your employer or as a consultant or agent of a
"Licensor" shall mean the copyright owner or entity authorized by third party (either "Your Company"), You represent and warrant that You have
the copyright owner that is granting the License. the authority to act on behalf of and bind Your Company to the terms of this
Agreement and everywhere in this Agreement that refers to 'You' or 'Your' shall
"Legal Entity" shall mean the union of the acting entity and all also include Your Company. If You do not agree to these terms, do not attempt
other entities that control, are controlled by, or are under common to access or use the Sample Code.
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the 1. LICENSE: Subject to the terms of this Agreement, SAP grants You a nonexclusive,
direction or management of such entity, whether by contract or non-transferable, non-sublicensable, revocable, royalty-free,
otherwise, or (ii) ownership of fifty percent (50%) or more of the limited license to use, copy, and modify the Sample Code solely for Your internal
outstanding shares, or (iii) beneficial ownership of such entity. business purposes.
"You" (or "Your") shall mean an individual or Legal Entity 2. RESTRICTIONS: You must not use the Sample Code to: (a) impair, degrade or
exercising permissions granted by this License. reduce the performance or security of any SAP products, services or related
technology (collectively, "SAP Products"); (b) enable the bypassing or
"Source" form shall mean the preferred form for making modifications, circumventing of SAP's license restrictions and/or provide users with access to
including but not limited to software source code, documentation the SAP Products to which such users are not licensed; or (c) permit mass data
source, and configuration files. extraction from an SAP Product to a non-SAP Product, including use,
modification, saving or other processing of such data in the non-SAP Product.
"Object" form shall mean any form resulting from mechanical Further, You must not: (i) provide or make the Sample Code available to any
transformation or translation of a Source form, including but third party other than your authorized employees, contractors and agents
not limited to compiled object code, generated documentation, (collectively, “Representatives”) and solely to be used by Your Representatives
and conversions to other media types. for Your own internal business purposes; ii) remove or modify any marks or
proprietary notices from the Sample Code; iii) assign this Agreement, or any
"Work" shall mean the work of authorship, whether in Source or interest therein, to any third party; (iv) use any SAP name, trademark or logo
Object form, made available under the License, as indicated by a without the prior written authorization of SAP; or (v) use the Sample Code to
copyright notice that is included in or attached to the work modify an SAP Product or decompile, disassemble or reverse engineer an SAP
(an example is provided in the Appendix below). Product (except to the extent permitted by applicable law). You are responsible
for any breach of the terms of this Agreement by You or Your Representatives.
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the 3. INTELLECTUAL PROPERTY: SAP or its licensors retain all ownership and
editorial revisions, annotations, elaborations, or other modifications intellectual property rights in and to the Sample Code and SAP Products. In
represent, as a whole, an original work of authorship. For the purposes exchange for the right to use, copy and modify the Sample Code provided under
of this License, Derivative Works shall not include works that remain this Agreement, You covenant not to assert any intellectual property rights in
separable from, or merely link (or bind by name) to the interfaces of, or to any of Your products, services, or related technology that are based on
the Work and Derivative Works thereof. or incorporate the Sample Code against any individual or entity in respect of
any current or future SAP Products.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions 4. SAP AND THIRD PARTY APIS: The Sample Code may include API (application
to that Work or Derivative Works thereof, that is intentionally programming interface) calls to SAP and third-party products or services. The
submitted to Licensor for inclusion in the Work by the copyright owner access or use of the third-party products and services to which the API calls
or by an individual or Legal Entity authorized to submit on behalf of are directed may be subject to additional terms and conditions between you and
the copyright owner. For the purposes of this definition, "submitted" SAP or such third parties. You (and not SAP) are solely responsible for
means any form of electronic, verbal, or written communication sent understanding and complying with any additional terms and conditions that apply
to the Licensor or its representatives, including but not limited to to the access or use of those APIs and/or third-party products and services.
communication on electronic mailing lists, source code control systems, SAP does not grant You any rights in or to these APIs, products or services
and issue tracking systems that are managed by, or on behalf of, the under this Agreement.
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise 5. FREE AND OPEN SOURCE COMPONENTS: The Sample Code may include third party
designated in writing by the copyright owner as "Not a Contribution." free or open source components ("FOSS Components"). You may have additional
rights in such FOSS Components that are provided by the third party licensors
"Contributor" shall mean Licensor and any individual or Legal Entity of those components.
on behalf of whom a Contribution has been received by Licensor and 6. THIRD PARTY DEPENDENCIES: The Sample Code may require third party software
subsequently incorporated within the Work. dependencies ("Dependencies") for the use or operation of the Sample Code. These
Dependencies may be identified by SAP in Maven POM files, documentation or by
2. Grant of Copyright License. Subject to the terms and conditions of other means. SAP does not grant You any rights in or to such Dependencies under
this License, each Contributor hereby grants to You a perpetual, this Agreement. You are solely responsible for the acquisition, installation
worldwide, non-exclusive, no-charge, royalty-free, irrevocable and use of such Dependencies.
copyright license to reproduce, prepare Derivative Works of, 7. WARRANTY:
publicly display, publicly perform, sublicense, and distribute the a) If You are located outside the US or Canada: AS THE SAMPLE CODE IS PROVIDED
Work and such Derivative Works in Source or Object form. TO YOU FREE OF CHARGE, SAP DOES NOT GUARANTEE OR WARRANT ANY FEATURES OR
QUALITIES OF THE SAMPLE CODE OR GIVE ANY UNDERTAKING WITH REGARD TO ANY OTHER
3. Grant of Patent License. Subject to the terms and conditions of QUALITY. NO SUCH WARRANTY OR UNDERTAKING SHALL BE IMPLIED BY YOU FROM ANY
this License, each Contributor hereby grants to You a perpetual, DESCRIPTION IN THE SAMPLE CODE OR ANY OTHER MATERIALS, COMMUNICATION OR
worldwide, non-exclusive, no-charge, royalty-free, irrevocable ADVERTISEMENT. IN PARTICULAR, SAP DOES NOT WARRANT THAT THE SAMPLE CODE WILL BE
(except as stated in this section) patent license to make, have made, AVAILABLE UNINTERRUPTED, ERROR FREE, OR PERMANENTLY AVAILABLE. ALL WARRANTY
use, offer to sell, sell, import, and otherwise transfer the Work, CLAIMS RESPECTING THE SAMPLE CODE ARE SUBJECT TO THE LIMITATION OF LIABILITY
where such license applies only to those patent claims licensable STIPULATED IN SECTION 8 BELOW.
by such Contributor that are necessarily infringed by their b) If You are located in the US or Canada: THE SAMPLE CODE IS LICENSED TO YOU
Contribution(s) alone or by combination of their Contribution(s) "AS IS", WITHOUT ANY WARRANTY, ESCROW, TRAINING, MAINTENANCE, OR SERVICE
with the Work to which such Contribution(s) was submitted. If You OBLIGATIONS WHATSOEVER ON THE PART OF SAP. SAP MAKES NO EXPRESS OR IMPLIED
institute patent litigation against any entity (including a WARRANTIES OR CONDITIONS OF SALE OF ANY TYPE WHATSOEVER, INCLUDING BUT NOT
cross-claim or counterclaim in a lawsuit) alleging that the Work LIMITED TO IMPLIED WARRANTIES OF MERCHANTABILITY AND OF FITNESS FOR A PARTICULAR
or a Contribution incorporated within the Work constitutes direct PURPOSE. IN PARTICULAR, SAP DOES NOT WARRANT THAT THE SAMPLE CODE WILL BE
or contributory patent infringement, then any patent licenses AVAILABLE UNINTERRUPTED, ERROR FREE, OR PERMANENTLY AVAILABLE. YOU ASSUME ALL
granted to You under this License for that Work shall terminate RISKS ASSOCIATED WITH THE USE OF THE SAMPLE CODE, INCLUDING WITHOUT LIMITATION
as of the date such litigation is filed. RISKS RELATING TO QUALITY, AVAILABILITY, PERFORMANCE, DATA LOSS, AND UTILITY IN
A PRODUCTION ENVIRONMENT.
4. Redistribution. You may reproduce and distribute copies of the c) For all locations: SAP DOES NOT MAKE ANY REPRESENTATIONS OR WARRANTIES IN
Work or Derivative Works thereof in any medium, with or without RESPECT OF THIRD PARTY DEPENDENCIES, APIS, PRODUCTS AND SERVICES, INCLUDING BUT
modifications, and in Source or Object form, provided that You NOT LIMITED TO IMPLIED WARRANTIES OF MERCHANTABILITY AND OF FITNESS FOR A
meet the following conditions: PARTICULAR PURPOSE. IN PARTICULAR, SAP DOES NOT WARRANT THAT THIRDPARTY
DEPENDENCIES, APIS, PRODUCTS AND SERVICES WILL BE AVAILABLE, ERROR FREE,
(a) You must give any other recipients of the Work or INTEROPERABLE WITH THE SAMPLE CODE, SUITABLE FOR ANY PARTICULAR PURPOSE OR NONINFRINGING.
Derivative Works a copy of this License; and YOU ASSUME ALL RISKS ASSOCIATED WITH THE USE OF THIRD
PARTY DEPENDENCIES, APIS, PRODUCTS AND SERVICES, INCLUDING WITHOUT LIMITATION
(b) You must cause any modified files to carry prominent notices RISKS RELATING TO QUALITY, AVAILABILITY, PERFORMANCE, DATA LOSS, UTILITY IN A
stating that You changed the files; and PRODUCTION ENVIRONMENT, AND NON-INFRINGEMENT. IN NO EVENT WILL SAP BE LIABLE
DIRECTLY OR INDIRECTLY IN RESPECT OF ANY USE OF THIRD PARTY DEPENDENCIES, APIS,
(c) You must retain, in the Source form of any Derivative Works PRODUCTS AND SERVICES BY YOU.
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work, 8. LIMITATION OF LIABILITY:
excluding those notices that do not pertain to any part of a) If You are located outside the US or Canada: IRRESPECTIVE OF THE LEGAL
the Derivative Works; and REASONS, SAP SHALL ONLY BE LIABLE FOR DAMAGES UNDER THIS AGREEMENT IF SUCH
DAMAGE (I) CAN BE CLAIMED UNDER THE GERMAN PRODUCT LIABILITY ACT OR (II) IS
(d) If the Work includes a "NOTICE" text file as part of its CAUSED BY INTENTIONAL MISCONDUCT OF SAP OR (III) CONSISTS OF PERSONAL INJURY.
distribution, then any Derivative Works that You distribute must IN ALL OTHER CASES, NEITHER SAP NOR ITS EMPLOYEES, AGENTS AND SUBCONTRACTORS
include a readable copy of the attribution notices contained SHALL BE LIABLE FOR ANY KIND OF DAMAGE OR CLAIMS HEREUNDER.
within such NOTICE file, excluding those notices that do not b) If You are located in the US or Canada: IN NO EVENT SHALL SAP BE LIABLE TO
pertain to any part of the Derivative Works, in at least one YOU, YOUR COMPANY OR TO ANY THIRD PARTY FOR ANY DAMAGES IN AN AMOUNT IN EXCESS
of the following places: within a NOTICE text file distributed OF $100 ARISING IN CONNECTION WITH YOUR USE OF OR INABILITY TO USE THE SAMPLE
as part of the Derivative Works; within the Source form or CODE OR IN CONNECTION WITH SAP'S PROVISION OF OR FAILURE TO PROVIDE SERVICES
documentation, if provided along with the Derivative Works; or, PERTAINING TO THE SAMPLE CODE, OR AS A RESULT OF ANY DEFECT IN THE SAMPLE COED.
within a display generated by the Derivative Works, if and THIS DISCLAIMER OF LIABILITY SHALL APPLY REGARDLESS OF THE FORM OF ACTION THAT
wherever such third-party notices normally appear. The contents MAY BE BROUGHT AGAINST SAP, WHETHER IN CONTRACT OR TORT, INCLUDING WITHOUT
of the NOTICE file are for informational purposes only and LIMITATION ANY ACTION FOR NEGLIGENCE. YOUR SOLE REMEDY IN THE EVENT OF BREACH
do not modify the License. You may add Your own attribution OF THIS AGREEMENT BY SAP OR FOR ANY OTHER CLAIM RELATED TO THE SAMPLE CODE SHALL
notices within Derivative Works that You distribute, alongside BE TERMINATION OF THIS AGREEMENT. NOTWITHSTANDING ANYTHING TO THE CONTRARY
or as an addendum to the NOTICE text from the Work, provided HEREIN, UNDER NO CIRCUMSTANCES SHALL SAP OR ITS LICENSORS BE LIABLE TO YOU OR
that such additional attribution notices cannot be construed ANY OTHER PERSON OR ENTITY FOR ANY SPECIAL, INCIDENTAL, CONSEQUENTIAL, OR
as modifying the License. INDIRECT DAMAGES, LOSS OF GOOD WILL OR BUSINESS PROFITS, WORK STOPPAGE, DATA
LOSS, COMPUTER FAILURE OR MALFUNCTION, ANY AND ALL OTHER COMMERCIAL DAMAGES OR
You may add Your own copyright statement to Your modifications and LOSS, OR EXEMPLARY OR PUNITIVE DAMAGES.
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or 9. INDEMNITY: You will fully indemnify, hold harmless and defend SAP against
for any such Derivative Works as a whole, provided Your use, law suits based on any claim: (a) that any of Your products, services or related
reproduction, and distribution of the Work otherwise complies with technology that are based on or incorporate the Sample Code infringes or
the conditions stated in this License. misappropriates any patent, copyright, trademark, trade secrets, or other
proprietary rights of a third party, or (b) related to Your alleged violation
5. Submission of Contributions. Unless You explicitly state otherwise, of the terms of this Agreement.
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of 10. EXPORT: The Sample Code is subject to German, EU and US export control
this License, without any additional terms or conditions. regulations. You confirm that: a) You will not use the Sample Code for, and
Notwithstanding the above, nothing herein shall supersede or modify will not allow the Sample Code to be used for, any purposes prohibited by
the terms of any separate license agreement you may have executed German, EU and US law, including, without limitation, for the development,
with Licensor regarding such Contributions. design, manufacture or production of nuclear, chemical or biological weapons of
mass destruction; b) You are not located in Cuba, Iran, Sudan, Iraq, North
6. Trademarks. This License does not grant permission to use the trade Korea, Syria, nor any other country to which the United States has prohibited
names, trademarks, service marks, or product names of the Licensor, export or that has been designated by the U.S. Government as a "terrorist
except as required for reasonable and customary use in describing the supporting" country (any, an "US Embargoed Country"); c) You are not a citizen,
origin of the Work and reproducing the content of the NOTICE file. national or resident of, and are not under the control of, a US Embargoed
Country; d) You will not download or otherwise export or re-export the Sample
7. Disclaimer of Warranty. Unless required by applicable law or Code, directly or indirectly, to a US Embargoed Country nor to citizens,
agreed to in writing, Licensor provides the Work (and each nationals or residents of a US Embargoed Country; e) You are not listed on the
Contributor provides its Contributions) on an "AS IS" BASIS, United States Department of Treasury lists of Specially Designated Nationals,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or Specially Designated Terrorists, and Specially Designated Narcotic Traffickers,
implied, including, without limitation, any warranties or conditions nor listed on the United States Department of Commerce Table of Denial Orders
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A or any other U.S. government list of prohibited or restricted parties and f)
PARTICULAR PURPOSE. You are solely responsible for determining the You will not download or otherwise export or re-export the Sample Code, directly
appropriateness of using or redistributing the Work and assume any or indirectly, to persons on the above-mentioned lists.
risks associated with Your exercise of permissions under this License.
11. SUPPORT: SAP does not offer support for the Sample Code.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise, 12. TERM AND TERMINATION: You may terminate this Agreement by destroying all
unless required by applicable law (such as deliberate and grossly copies of the Sample Code in Your possession or control. SAP may terminate Your
negligent acts) or agreed to in writing, shall any Contributor be license to use the Sample Code immediately if You fail to comply with any of
liable to You for damages, including any direct, indirect, special, the terms of this Agreement, or, for SAP's convenience by providing you with
incidental, or consequential damages of any character arising as a ten (10) days written notice of termination. In case of termination or
result of this License or out of the use or inability to use the expiration of this Agreement, You must immediately destroy all copies of the
Work (including but not limited to damages for loss of goodwill, Sample Code in your possession or control. In the event Your Company is acquired
work stoppage, computer failure or malfunction, or any and all (by merger, purchase of stock, assets or intellectual property or exclusive
other commercial damages or losses), even if such Contributor license), or You become employed, by a direct competitor of SAP, then this
has been advised of the possibility of such damages. Agreement and all licenses granted to You in this Agreement shall immediately
terminate upon the date of such acquisition or change of employment.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer, 13. LAW/VENUE:
and charge a fee for, acceptance of support, warranty, indemnity, a) If You are located outside the US or Canada: This Agreement is governed by
or other liability obligations and/or rights consistent with this and construed in accordance with the laws of Germany without reference to its
License. However, in accepting such obligations, You may act only conflicts of law principles. You and SAP agree to submit to the exclusive
on Your own behalf and on Your sole responsibility, not on behalf jurisdiction of, and venue in, the courts located in Karlsruhe, Germany in any
of any other Contributor, and only if You agree to indemnify, dispute arising out of or relating to this Agreement or the Sample Code. The
defend, and hold each Contributor harmless for any liability United Nations Convention on Contracts for the International Sale of Goods shall
incurred by, or claims asserted against, such Contributor by reason not apply to this Agreement.
of your accepting any such warranty or additional liability. b) If You are located in the US or Canada: This Agreement shall be governed by
and construed in accordance with the laws of the State of New York, USA without
END OF TERMS AND CONDITIONS reference to its conflicts of law principles. You and SAP agree to submit to
the exclusive jurisdiction of, and venue in, the courts located in New York,
APPENDIX: How to apply the Apache License to your work. New York, USA in any dispute arising out of or relating to this Agreement or
the Sample Code. The United Nations Convention on Contracts for the
To apply the Apache License to your work, attach the following International Sale of Goods shall not apply to this Agreement.
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include 14. MISCELLANEOUS: This Agreement is the complete agreement between the parties
the brackets!) The text should be enclosed in the appropriate respecting the Sample Code. This Agreement supersedes all prior or
comment syntax for the file format. We also recommend that a contemporaneous agreements or representations with regards to the Sample Code.
file or class name and description of purpose be included on the If any term of this Agreement is found to be invalid or unenforceable, the
same "printed page" as the copyright notice for easier surviving provisions shall remain effective. SAP's failure to enforce any right
identification within third-party archives. or provisions stipulated in this Agreement will not constitute a waiver of such
provision, or any other provision of this Agreement.
Copyright [yyyy] [name of copyright owner]
v1.0-071618
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

1
NOTICE Normal file
View File

@@ -0,0 +1 @@
Copyright (c) 2019 SAP SE or an SAP affiliate company. All rights reserved.

3
README.md Normal file
View File

@@ -0,0 +1,3 @@
# Final state of exercise 4 for CAA265 - Rapid Service Development with SAP Cloud Application Programming Model
**DO NOT MERGE IN MASTER**

View File

@@ -1,25 +0,0 @@
{
// 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": [
{
"name": "Attach to...",
"type": "node",
"request": "attach",
"processId": "${command:PickProcess}",
"skipFiles": ["<node_internals>/**"]
},
{
"name": "cds run",
"type": "node",
"request": "launch",
"runtimeExecutable": "npx",
"runtimeArgs": ["-n"],
"args": ["--", "cds", "run", "--with-mocks", "--in-memory?"],
"console": "integratedTerminal",
"skipFiles": ["<node_internals>/**"]
}
]
}

View File

@@ -1,89 +0,0 @@
/* global Vue axios */ //> from vue.html
const $ = sel => document.querySelector(sel)
const GET = (url) => axios.get('/browse'+url)
const POST = (cmd,data) => axios.post('/browse'+cmd,data)
const books = Vue.createApp ({
data() {
return {
list: [],
book: undefined,
order: { quantity:1, succeeded:'', failed:'' },
user: undefined
}
},
methods: {
search: ({target:{value:v}}) => books.fetch(v && '&$search='+v),
async fetch (etc='') {
const {data} = await GET(`/ListOfBooks?$expand=genre($select=name),currency($select=symbol)${etc}`)
books.list = data.value
},
async inspect (eve) {
const book = books.book = books.list [eve.currentTarget.rowIndex-1]
const res = await GET(`/Books/${book.ID}?$select=descr,stock,image`)
Object.assign (book, res.data)
books.order = { quantity:1 }
setTimeout (()=> $('form > input').focus(), 111)
},
async submitOrder () {
const {book,order} = books, quantity = parseInt (order.quantity) || 1 // REVISIT: Okra should be less strict
try {
const res = await POST(`/submitOrder`, { quantity, book: book.ID })
book.stock = res.data.stock
books.order = { quantity, succeeded: `Successfully ordered ${quantity} item(s).` }
} catch (e) {
books.order = { quantity, failed: e.response.data.error ? e.response.data.error.message : e.response.data }
}
},
async login() {
try {
const { data:user } = await axios.post('/user/login',{})
if (user.id !== 'anonymous') books.user = user
} catch (err) { books.user = { id: err.message } }
},
async getUserInfo() {
try {
const { data:user } = await axios.get('/user/me')
if (user.id !== 'anonymous') books.user = user
} catch (err) { books.user = { id: err.message } }
},
}
}).mount('#app')
books.getUserInfo()
books.fetch() // initially fill list of books
document.addEventListener('keydown', (event) => {
// hide user info on request
if (event.key === 'u') books.user = undefined
})
axios.interceptors.request.use(csrfToken)
function csrfToken (request) {
if (request.method === 'head' || request.method === 'get') return request
if ('csrfToken' in document) {
request.headers['x-csrf-token'] = document.csrfToken
return request
}
return fetchToken().then(token => {
document.csrfToken = token
request.headers['x-csrf-token'] = document.csrfToken
return request
}).catch(() => {
document.csrfToken = null // set mark to not try again
return request
})
function fetchToken() {
return axios.get('/', { headers: { 'x-csrf-token': 'fetch' } })
.then(res => res.headers['x-csrf-token'])
}
}

View File

@@ -1,78 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title> Capire Books </title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/primitive-ui/dist/css/main.css">
<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/vue@3/dist/vue.global.prod.js"></script>
<style>
.hovering tr:hover td { color:cyan; background: #123; cursor: pointer; }
.rating-stars { color:teal }
.succeeded { color:teal }
.failed { color:red }
.user {text-align: end; color: grey;}
</style>
</head>
<body class="small-container", style="margin-top: 70px;">
<div id='app'>
<form class="user" @submit.prevent="login">
<div v-if="user">
<div v-if="user.tenant">Tenant: {{ user.tenant }}</div>
<div> User: {{ user.id }}</div>
<div>Locale: {{ user.locale }}</div>
</div>
<div v-else>
<input type="submit" value="Login" class="muted-button">
<!-- <a href="/user/login()">Login</a> -->
</div>
</form>
<h1> Capire Books </h1>
<input type="text" placeholder="Search..." @input="search">
<table id='books' class="hovering">
<thead>
<th> Book </th>
<th> Author </th>
<th> Genre </th>
<th> Rating </th>
<th> Price </th>
</thead>
<tr v-for="book in list" v-bind:id="book.ID" v-on:click="inspect">
<td>{{ book.title }}</td>
<td>{{ book.author }}</td>
<td>{{ book.genre.name }}</td>
<td class="rating-stars">
{{ ('★'.repeat(Math.round(book.rating))+'☆☆☆☆☆').slice(0,5) }} ({{ book.numberOfReviews }})
</td>
<td>{{ book.currency && book.currency.symbol }} {{ book.price }}</td>
</tr>
</table>
<div v-if="book">
<img v-bind:src="book.image" alt=""/>
<label style="text-align:right">
<span class="succeeded"> {{ order.succeeded }} </span>
<span class="failed"> {{ order.failed }} </span>
&nbsp;&nbsp; {{ book.stock }} in stock
</label>
<form @submit.prevent="submitOrder" style="float:right; display:flex; flex-direction:row-reverse">
<input type="number" v-model="order.quantity" v-bind:class="{ failed: order.failed }" style="width:5em">
<input type="submit" value="Order:" class="muted-button">
</form>
<h4> {{ book.title }} </h4>
<p> {{ book.descr }} </p>
</div>
<div v-else>
( click on a row to see details... )
</div>
</div>
</body>
<script src="app.js"></script>
</html>

View File

@@ -1,5 +0,0 @@
ID,name,dateOfBirth,placeOfBirth,dateOfDeath,placeOfDeath
101,Emily Brontë,1818-07-30,"Thornton, Yorkshire",1848-12-19,"Haworth, Yorkshire"
107,Charlotte Brontë,1818-04-21,"Thornton, Yorkshire",1855-03-31,"Haworth, Yorkshire"
150,Edgar Allen Poe,1809-01-19,"Boston, Massachusetts",1849-10-07,"Baltimore, Maryland"
170,Richard Carpenter,1929-08-14,"King’s Lynn, Norfolk",2012-02-26,"Hertfordshire, England"
Internal Server Error - Bruno's Gitea
500 Internal Server Error

Gitea Version: 1.24.4