Compare commits
2 Commits
trying-esm
...
cg-deploy-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1f8a78fe8a | ||
|
|
7f9474244b |
@@ -16,8 +16,7 @@ app.use('/-/:tarball', (req,res,next) => {
|
||||
console.debug ('GET', req.params)
|
||||
try {
|
||||
const { tarball } = req.params
|
||||
const pkgFull = tarball.substring(0, tarball.lastIndexOf('-'))
|
||||
const [, pkg ] = /^\w+-(.+)/.exec(pkgFull)
|
||||
const [, pkg ] = /^\w+-(\w+)/.exec(tarball)
|
||||
fs.lstat(tarball,(err => {
|
||||
if (err) console.debug (`npm pack ../${pkg}`)
|
||||
if (err) exec(`npm pack ../${pkg}`,{cwd},next)
|
||||
@@ -32,7 +31,7 @@ app.use('/-/:tarball', (req,res,next) => {
|
||||
app.use('/-', express.static(__dirname))
|
||||
|
||||
app.get('/*', (req,res)=>{
|
||||
const urlRegex = /^\/(@[\w-]+)\/(.+)/
|
||||
const urlRegex = /^\/(@\w+)\/(\w+)/
|
||||
const url = decodeURIComponent(req.url)
|
||||
console.debug ('GET',url)
|
||||
try {
|
||||
|
||||
3752
bookshop/app/package-lock.json
generated
Normal file
3752
bookshop/app/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
12
bookshop/app/package.json
Normal file
12
bookshop/app/package.json
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"name": "approuter",
|
||||
"dependencies": {
|
||||
"@sap/approuter": "^10"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^16"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "node node_modules/@sap/approuter/approuter.js"
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,7 @@ const books = Vue.createApp ({
|
||||
list: [],
|
||||
book: undefined,
|
||||
order: { quantity:1, succeeded:'', failed:'' },
|
||||
user: undefined
|
||||
user: {}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -40,28 +40,19 @@ const books = Vue.createApp ({
|
||||
} 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
|
||||
// initially fill list of books
|
||||
books.fetch()
|
||||
|
||||
document.addEventListener('keydown', (event) => {
|
||||
// hide user info on request
|
||||
if (event.key === 'u') books.user = undefined
|
||||
// show user info on request
|
||||
document.addEventListener('keydown', async (event) => {
|
||||
if (event.key === 'u') {
|
||||
try {
|
||||
books.user = (await axios.get('/user/User')).data
|
||||
} catch (err) { }
|
||||
}
|
||||
})
|
||||
|
||||
@@ -18,17 +18,11 @@
|
||||
<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 v-if="user.ID && user.ID !== 'anonymous'" class="user">
|
||||
<div>User: {{ user.ID }}</div>
|
||||
<div>Locale: {{ user.locale }}</div>
|
||||
<div>Tenant: {{ user.tenant }}</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>
|
||||
|
||||
|
||||
19
bookshop/app/xs-app.json
Normal file
19
bookshop/app/xs-app.json
Normal file
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"authenticationMethod": "route",
|
||||
"routes": [
|
||||
{
|
||||
"source": "^/app/(.*)$",
|
||||
"target": "$1",
|
||||
"localDir": ".",
|
||||
"authenticationType": "xsuaa",
|
||||
"cacheControl": "no-cache, no-store, must-revalidate"
|
||||
},
|
||||
{
|
||||
"source": "^/(.*)$",
|
||||
"target": "$1",
|
||||
"destination": "srv-api",
|
||||
"authenticationType": "xsuaa",
|
||||
"csrfProtection": false
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -4,7 +4,7 @@
|
||||
* currencies, if not obtained through @capire/common.
|
||||
*/
|
||||
|
||||
export default async (db)=>{
|
||||
module.exports = async (db)=>{
|
||||
|
||||
const has_common = db.model.definitions['sap.common.Currencies'].elements.numcode
|
||||
if (has_common) return
|
||||
|
||||
136
bookshop/db/src/.hdiconfig
Normal file
136
bookshop/db/src/.hdiconfig
Normal file
@@ -0,0 +1,136 @@
|
||||
{
|
||||
"file_suffixes": {
|
||||
"csv": {
|
||||
"plugin_name": "com.sap.hana.di.tabledata.source"
|
||||
},
|
||||
"hdbafllangprocedure": {
|
||||
"plugin_name": "com.sap.hana.di.afllangprocedure"
|
||||
},
|
||||
"hdbanalyticprivilege": {
|
||||
"plugin_name": "com.sap.hana.di.analyticprivilege"
|
||||
},
|
||||
"hdbcalculationview": {
|
||||
"plugin_name": "com.sap.hana.di.calculationview"
|
||||
},
|
||||
"hdbcollection": {
|
||||
"plugin_name": "com.sap.hana.di.collection"
|
||||
},
|
||||
"hdbconstraint": {
|
||||
"plugin_name": "com.sap.hana.di.constraint"
|
||||
},
|
||||
"hdbdropcreatetable": {
|
||||
"plugin_name": "com.sap.hana.di.dropcreatetable"
|
||||
},
|
||||
"hdbflowgraph": {
|
||||
"plugin_name": "com.sap.hana.di.flowgraph"
|
||||
},
|
||||
"hdbfunction": {
|
||||
"plugin_name": "com.sap.hana.di.function"
|
||||
},
|
||||
"hdbgraphworkspace": {
|
||||
"plugin_name": "com.sap.hana.di.graphworkspace"
|
||||
},
|
||||
"hdbhadoopmrjob": {
|
||||
"plugin_name": "com.sap.hana.di.virtualfunctionpackage.hadoop"
|
||||
},
|
||||
"hdbindex": {
|
||||
"plugin_name": "com.sap.hana.di.index"
|
||||
},
|
||||
"hdblibrary": {
|
||||
"plugin_name": "com.sap.hana.di.library"
|
||||
},
|
||||
"hdbmigrationtable": {
|
||||
"plugin_name": "com.sap.hana.di.table.migration"
|
||||
},
|
||||
"hdbprocedure": {
|
||||
"plugin_name": "com.sap.hana.di.procedure"
|
||||
},
|
||||
"hdbprojectionview": {
|
||||
"plugin_name": "com.sap.hana.di.projectionview"
|
||||
},
|
||||
"hdbprojectionviewconfig": {
|
||||
"plugin_name": "com.sap.hana.di.projectionview.config"
|
||||
},
|
||||
"hdbreptask": {
|
||||
"plugin_name": "com.sap.hana.di.reptask"
|
||||
},
|
||||
"hdbresultcache": {
|
||||
"plugin_name": "com.sap.hana.di.resultcache"
|
||||
},
|
||||
"hdbrole": {
|
||||
"plugin_name": "com.sap.hana.di.role"
|
||||
},
|
||||
"hdbroleconfig": {
|
||||
"plugin_name": "com.sap.hana.di.role.config"
|
||||
},
|
||||
"hdbsearchruleset": {
|
||||
"plugin_name": "com.sap.hana.di.searchruleset"
|
||||
},
|
||||
"hdbsequence": {
|
||||
"plugin_name": "com.sap.hana.di.sequence"
|
||||
},
|
||||
"hdbstatistics": {
|
||||
"plugin_name": "com.sap.hana.di.statistics"
|
||||
},
|
||||
"hdbstructuredprivilege": {
|
||||
"plugin_name": "com.sap.hana.di.structuredprivilege"
|
||||
},
|
||||
"hdbsynonym": {
|
||||
"plugin_name": "com.sap.hana.di.synonym"
|
||||
},
|
||||
"hdbsynonymconfig": {
|
||||
"plugin_name": "com.sap.hana.di.synonym.config"
|
||||
},
|
||||
"hdbsystemversioning": {
|
||||
"plugin_name": "com.sap.hana.di.systemversioning"
|
||||
},
|
||||
"hdbtable": {
|
||||
"plugin_name": "com.sap.hana.di.table"
|
||||
},
|
||||
"hdbtabledata": {
|
||||
"plugin_name": "com.sap.hana.di.tabledata"
|
||||
},
|
||||
"hdbtabletype": {
|
||||
"plugin_name": "com.sap.hana.di.tabletype"
|
||||
},
|
||||
"hdbtrigger": {
|
||||
"plugin_name": "com.sap.hana.di.trigger"
|
||||
},
|
||||
"hdbview": {
|
||||
"plugin_name": "com.sap.hana.di.view"
|
||||
},
|
||||
"hdbvirtualfunction": {
|
||||
"plugin_name": "com.sap.hana.di.virtualfunction"
|
||||
},
|
||||
"hdbvirtualfunctionconfig": {
|
||||
"plugin_name": "com.sap.hana.di.virtualfunction.config"
|
||||
},
|
||||
"hdbvirtualpackagehadoop": {
|
||||
"plugin_name": "com.sap.hana.di.virtualpackage.hadoop"
|
||||
},
|
||||
"hdbvirtualpackagesparksql": {
|
||||
"plugin_name": "com.sap.hana.di.virtualpackage.sparksql"
|
||||
},
|
||||
"hdbvirtualprocedure": {
|
||||
"plugin_name": "com.sap.hana.di.virtualprocedure"
|
||||
},
|
||||
"hdbvirtualprocedureconfig": {
|
||||
"plugin_name": "com.sap.hana.di.virtualprocedure.config"
|
||||
},
|
||||
"hdbvirtualtable": {
|
||||
"plugin_name": "com.sap.hana.di.virtualtable"
|
||||
},
|
||||
"hdbvirtualtableconfig": {
|
||||
"plugin_name": "com.sap.hana.di.virtualtable.config"
|
||||
},
|
||||
"properties": {
|
||||
"plugin_name": "com.sap.hana.di.tabledata.properties"
|
||||
},
|
||||
"tags": {
|
||||
"plugin_name": "com.sap.hana.di.tabledata.properties"
|
||||
},
|
||||
"txt": {
|
||||
"plugin_name": "com.sap.hana.di.copyonly"
|
||||
}
|
||||
}
|
||||
}
|
||||
5
bookshop/db/undeploy.json
Normal file
5
bookshop/db/undeploy.json
Normal file
@@ -0,0 +1,5 @@
|
||||
[
|
||||
"src/gen/**/*.hdbview",
|
||||
"src/gen/**/*.hdbindex",
|
||||
"src/gen/**/*.hdbconstraint"
|
||||
]
|
||||
@@ -1,2 +1,2 @@
|
||||
import { CatalogService } from './srv/cat-service.js'
|
||||
export { CatalogService }
|
||||
const { CatalogService } = require('./srv/cat-service')
|
||||
module.exports = { CatalogService }
|
||||
|
||||
98
bookshop/mta.yaml
Normal file
98
bookshop/mta.yaml
Normal file
@@ -0,0 +1,98 @@
|
||||
---
|
||||
_schema-version: '3.1'
|
||||
ID: capire.bookshop
|
||||
version: 1.0.0
|
||||
description: "A simple self-contained bookshop service."
|
||||
parameters:
|
||||
enable-parallel-deployments: true
|
||||
build-parameters:
|
||||
before-all:
|
||||
- builder: custom
|
||||
commands:
|
||||
- npx -p @sap/cds-dk cds build --production
|
||||
|
||||
modules:
|
||||
- name: bookshop-srv
|
||||
type: nodejs
|
||||
path: gen/srv
|
||||
parameters:
|
||||
buildpack: nodejs_buildpack
|
||||
build-parameters:
|
||||
builder: npm-ci
|
||||
provides:
|
||||
- name: srv-api # required by consumers of CAP services (e.g. approuter)
|
||||
properties:
|
||||
srv-url: ${default-url}
|
||||
- name: mtx-api # potentially required by approuter
|
||||
properties:
|
||||
mtx-url: ${default-url}
|
||||
requires:
|
||||
- name: bookshop-auth
|
||||
- name: bookshop-db
|
||||
- name: bookshop-registry
|
||||
properties:
|
||||
SUBSCRIPTION_URL: ${protocol}://\${tenant_subdomain}-${default-uri}
|
||||
SUBSCRIPTION_URL_REPLACEMENT_RULES: [ [ '-srv', '' ] ]
|
||||
|
||||
- name: bookshop
|
||||
type: approuter.nodejs
|
||||
path: app/ # from cds.env.folders. Consider also cds.env.build.target -> gen/app
|
||||
parameters:
|
||||
keep-existing-routes: true
|
||||
disk-quota: 256M
|
||||
memory: 256M
|
||||
requires:
|
||||
- name: srv-api
|
||||
group: destinations
|
||||
properties:
|
||||
name: srv-api # must be used in xs-app.json as well
|
||||
url: ~{srv-url}
|
||||
forwardAuthToken: true
|
||||
- name: bookshop-auth
|
||||
- name: mtx-api
|
||||
group: destinations
|
||||
properties:
|
||||
name: mtx-api # must be used in xs-app.json as well
|
||||
url: ~{mtx-url}
|
||||
properties:
|
||||
TENANT_HOST_PATTERN: "^(.*)-${default-uri}"
|
||||
|
||||
resources:
|
||||
|
||||
- name: bookshop-auth
|
||||
type: org.cloudfoundry.managed-service
|
||||
parameters:
|
||||
service: xsuaa
|
||||
service-plan: application
|
||||
path: ./xs-security.json
|
||||
config:
|
||||
xsappname: bookshop-${org}-${space}
|
||||
tenant-mode: shared
|
||||
|
||||
- name: bookshop-db
|
||||
type: org.cloudfoundry.managed-service
|
||||
parameters:
|
||||
service: service-manager
|
||||
service-plan: container
|
||||
properties:
|
||||
hdi-service-name: ${service-name}
|
||||
|
||||
- name: bookshop-registry
|
||||
type: org.cloudfoundry.managed-service
|
||||
requires:
|
||||
- name: mtx-api
|
||||
parameters:
|
||||
service: saas-registry
|
||||
service-plan: application
|
||||
config:
|
||||
xsappname: bookshop-${org}-${space}
|
||||
appName: bookshop-${org}-${space}
|
||||
displayName: bookshop
|
||||
description: A simple CAP project.
|
||||
category: 'Category'
|
||||
appUrls:
|
||||
getDependencies: ~{mtx-api/mtx-url}/mtx/v1/provisioning/dependencies
|
||||
onSubscription: ~{mtx-api/mtx-url}/mtx/v1/provisioning/tenant/{tenantId}
|
||||
onSubscriptionAsync: false
|
||||
onUnSubscriptionAsync: false
|
||||
callbackTimeoutMillis: 300000
|
||||
4025
bookshop/package-lock.json
generated
Normal file
4025
bookshop/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -2,7 +2,6 @@
|
||||
"name": "@capire/bookshop",
|
||||
"version": "1.0.0",
|
||||
"description": "A simple self-contained bookshop service.",
|
||||
"type": "module",
|
||||
"files": [
|
||||
"app",
|
||||
"srv",
|
||||
@@ -11,9 +10,12 @@
|
||||
"index.js"
|
||||
],
|
||||
"dependencies": {
|
||||
"@sap/cds": ">=5.9",
|
||||
"@sap/cds": "^5",
|
||||
"@sap/cds-mtx": "^2",
|
||||
"@sap/xssec": "^3",
|
||||
"express": "^4.17.1",
|
||||
"passport": ">=0.4.1"
|
||||
"hdb": "^0.19.0",
|
||||
"passport": "0.4.1"
|
||||
},
|
||||
"scripts": {
|
||||
"genres": "cds serve test/genres.cds",
|
||||
@@ -24,7 +26,24 @@
|
||||
"requires": {
|
||||
"db": {
|
||||
"kind": "sql"
|
||||
}
|
||||
},
|
||||
"[production]": {
|
||||
"db": {
|
||||
"kind": "hana-mt"
|
||||
},
|
||||
"auth": {
|
||||
"kind": "xsuaa"
|
||||
},
|
||||
"multitenancy": true,
|
||||
"approuter": {
|
||||
"kind": "cloudfoundry"
|
||||
}
|
||||
}
|
||||
},
|
||||
"mtx": {
|
||||
"element-prefix": "Z_",
|
||||
"namespace-blocklist": [],
|
||||
"extension-allowlist": []
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import cds from '@sap/cds'
|
||||
const cds = require('@sap/cds')
|
||||
|
||||
export default cds.service.impl (function(){
|
||||
module.exports = cds.service.impl (function(){
|
||||
this.before ('NEW','Authors', genid)
|
||||
this.before ('NEW','Books', genid)
|
||||
})
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import cds from '@sap/cds'
|
||||
const cds = require('@sap/cds')
|
||||
|
||||
export class CatalogService extends cds.ApplicationService { init(){
|
||||
class CatalogService extends cds.ApplicationService { init(){
|
||||
|
||||
const { Books } = this.entities ('sap.capire.bookshop')
|
||||
const { Books } = cds.entities ('sap.capire.bookshop')
|
||||
|
||||
// Reduce stock of ordered books if available stock suffices
|
||||
this.on ('submitOrder', async req => {
|
||||
@@ -24,3 +24,5 @@ export class CatalogService extends cds.ApplicationService { init(){
|
||||
|
||||
return super.init()
|
||||
}}
|
||||
|
||||
module.exports = { CatalogService }
|
||||
|
||||
@@ -1,15 +1,11 @@
|
||||
/**
|
||||
* Exposes user information
|
||||
*/
|
||||
@requires : 'authenticated-user'
|
||||
service UserService {
|
||||
/**
|
||||
* The current user
|
||||
*/
|
||||
@odata.singleton entity me {
|
||||
id : String; // user id
|
||||
|
||||
@odata.singleton
|
||||
entity User {
|
||||
ID : String;
|
||||
locale : String;
|
||||
tenant : String;
|
||||
}
|
||||
|
||||
action login() returns me;
|
||||
}
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import cds from '@sap/cds'
|
||||
const cds = require('@sap/cds');
|
||||
|
||||
export default class UserService extends cds.Service { init(){
|
||||
this.on('READ', 'me', ({ tenant, user, locale }) => ({ id: user.id, locale, tenant }))
|
||||
this.on('login', (req) => {
|
||||
if (req.user._is_anonymous)
|
||||
req._.res.set('WWW-Authenticate','Basic realm="Users"').sendStatus(401)
|
||||
else return this.read('me')
|
||||
})
|
||||
}}
|
||||
module.exports = cds.service.impl((srv) => {
|
||||
srv.on('READ', 'User', ({ user }) => {
|
||||
return {
|
||||
ID: user.id,
|
||||
locale: user.locale,
|
||||
tenant: user.tenant,
|
||||
};
|
||||
});
|
||||
});
|
||||
|
||||
@@ -16,9 +16,9 @@ GET {{server}}/browse/$metadata
|
||||
|
||||
### ------------------------------------------------------------------------
|
||||
# Browse Books as any user
|
||||
GET {{server}}/browse/ListOfBooks?
|
||||
GET {{server}}/browse/Books?
|
||||
# &$select=title,stock
|
||||
&$expand=genre
|
||||
# &$expand=currency
|
||||
# &sap-language=de
|
||||
{{me}}
|
||||
|
||||
|
||||
70
bookshop/xs-security.json
Normal file
70
bookshop/xs-security.json
Normal file
@@ -0,0 +1,70 @@
|
||||
{
|
||||
"scopes": [
|
||||
{
|
||||
"name": "$XSAPPNAME.admin",
|
||||
"description": "admin"
|
||||
},
|
||||
{
|
||||
"name": "$XSAPPNAME.MtxDiagnose",
|
||||
"description": "Diagnose MTX"
|
||||
},
|
||||
{
|
||||
"name": "$XSAPPNAME.mtcallback",
|
||||
"description": "Subscribe to applications",
|
||||
"grant-as-authority-to-apps": [
|
||||
"$XSAPPNAME(application,sap-provisioning,tenant-onboarding)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "$XSAPPNAME.mtdeployment",
|
||||
"description": "Deploy applications"
|
||||
},
|
||||
{
|
||||
"name": "$XSAPPNAME.ExtendCDS",
|
||||
"description": "Extend CDS applications"
|
||||
},
|
||||
{
|
||||
"name": "$XSAPPNAME.ExtendCDSdelete",
|
||||
"description": "Extend CDS applications with undeployments"
|
||||
}
|
||||
],
|
||||
"attributes": [],
|
||||
"role-templates": [
|
||||
{
|
||||
"name": "admin",
|
||||
"description": "generated",
|
||||
"scope-references": [
|
||||
"$XSAPPNAME.admin"
|
||||
],
|
||||
"attribute-references": []
|
||||
},
|
||||
{
|
||||
"name": "MultitenancyAdministrator",
|
||||
"description": "Administrate multitenant applications",
|
||||
"scope-references": [
|
||||
"$XSAPPNAME.MtxDiagnose",
|
||||
"$XSAPPNAME.mtdeployment",
|
||||
"$XSAPPNAME.mtcallback"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "ExtensionDeveloper",
|
||||
"description": "Extend application",
|
||||
"scope-references": [
|
||||
"$XSAPPNAME.ExtendCDS"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "ExtensionDeveloperUndeploy",
|
||||
"description": "Undeploy extension",
|
||||
"scope-references": [
|
||||
"$XSAPPNAME.ExtendCDSdelete"
|
||||
]
|
||||
}
|
||||
],
|
||||
"authorities": [
|
||||
"$XSAPPNAME.MtxDiagnose",
|
||||
"$XSAPPNAME.mtdeployment",
|
||||
"$XSAPPNAME.mtcallback"
|
||||
]
|
||||
}
|
||||
@@ -7,7 +7,7 @@
|
||||
"@capire/orders": "*",
|
||||
"@capire/common": "*",
|
||||
"@capire/data-viewer": "*",
|
||||
"@sap/cds": ">=5",
|
||||
"@sap/cds": "^5",
|
||||
"express": "^4.17.1"
|
||||
},
|
||||
"cds": {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
"version": "0.1.0",
|
||||
"description": "A generic browser for data",
|
||||
"dependencies": {
|
||||
"@sap/cds": ">=5.0.4"
|
||||
"@sap/cds": "^5.0.4"
|
||||
},
|
||||
"files": [
|
||||
"app",
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
},
|
||||
"dataSources": {
|
||||
"AdminService": {
|
||||
"uri": "admin/",
|
||||
"uri": "/admin/",
|
||||
"type": "OData",
|
||||
"settings": {
|
||||
"odataVersion": "4.0"
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
"i18n": "i18n/i18n.properties",
|
||||
"dataSources": {
|
||||
"AdminService": {
|
||||
"uri": "admin/",
|
||||
"uri": "/admin/",
|
||||
"type": "OData",
|
||||
"settings": {
|
||||
"odataVersion": "4.0"
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
},
|
||||
"dataSources": {
|
||||
"CatalogService": {
|
||||
"uri": "browse/",
|
||||
"uri": "/browse/",
|
||||
"type": "OData",
|
||||
"settings": {
|
||||
"odataVersion": "4.0"
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
"version": "1.0.0",
|
||||
"dependencies": {
|
||||
"@capire/bookstore": "*",
|
||||
"@sap/cds": ">=5",
|
||||
"@sap/cds": "^5",
|
||||
"express": "^4.17.1",
|
||||
"passport": ">=0.4.1"
|
||||
"passport": "^0.4.1"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "cds run --in-memory?",
|
||||
@@ -14,7 +14,7 @@
|
||||
"cds": {
|
||||
"requires": {
|
||||
"auth": {
|
||||
"kind": "dummy-auth"
|
||||
"strategy": "dummy"
|
||||
},
|
||||
"ReviewsService": {
|
||||
"kind": "odata",
|
||||
|
||||
@@ -7,11 +7,11 @@
|
||||
"start:ts": "cds-ts serve srv/world.cds"
|
||||
},
|
||||
"dependencies": {
|
||||
"@sap/cds": ">=5.0.4"
|
||||
"@sap/cds": "^5.0.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/jest": "*",
|
||||
"@types/node": "*",
|
||||
"@types/jest": "^27.0.2",
|
||||
"@types/node": "^16.11.6",
|
||||
"ts-jest": "^27.0.2",
|
||||
"typescript": "^4.3.5"
|
||||
},
|
||||
|
||||
@@ -3,6 +3,6 @@
|
||||
"version": "1.0.0",
|
||||
"dependencies": {
|
||||
"@capire/common": "*",
|
||||
"@sap/cds": ">=5"
|
||||
"@sap/cds": "^5"
|
||||
}
|
||||
}
|
||||
3341
package-lock.json
generated
3341
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -14,14 +14,14 @@
|
||||
"@capire/media": "./media",
|
||||
"@capire/orders": "./orders",
|
||||
"@capire/reviews": "./reviews",
|
||||
"@sap/cds": ">=5.5.3"
|
||||
"@sap/cds": "^5.5.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"chai": "^4.3.4",
|
||||
"chai-as-promised": "^7.1.1",
|
||||
"chai-subset": "^1.6.0",
|
||||
"semver": "^7",
|
||||
"sqlite3": "^5"
|
||||
"sqlite3": "npm:@mendix/sqlite3@^5"
|
||||
},
|
||||
"scripts": {
|
||||
"cleanup": "rm -rf node_modules && rm -rf */node_modules && rm -rf */*/node_modules",
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
"index.cds"
|
||||
],
|
||||
"dependencies": {
|
||||
"@sap/cds": ">=5",
|
||||
"@sap/cds": "^5",
|
||||
"express": "^4.17.1"
|
||||
},
|
||||
"cds": {
|
||||
|
||||
@@ -81,8 +81,6 @@ describe('cds.ql → cqn', () => {
|
||||
.to.eql(SELECT('Foo','Boo').from('Bar'))
|
||||
.to.eql(SELECT(['Foo','Boo']).from('Bar'))
|
||||
.to.eql(SELECT `Bar` .columns `Foo, Boo`)
|
||||
.to.eql(SELECT `Bar` .columns `{ Foo, Boo }`)
|
||||
.to.eql(SELECT `Bar` .columns ('{ Foo, Boo }'))
|
||||
.to.eql(SELECT `Bar` .columns ('Foo','Boo'))
|
||||
.to.eql(SELECT `Bar` .columns (['Foo','Boo']))
|
||||
.to.eql(SELECT.from `Bar` .columns ('Foo','Boo'))
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
const cds = require('@sap/cds/lib')
|
||||
const { expect } = cds.test ('@capire/bookshop')
|
||||
|
||||
describe('cap/samples - Consuming Services locally', () => {
|
||||
describe('Consuming Services locally', () => {
|
||||
//
|
||||
it('bootstrapped the database successfully', ()=>{
|
||||
const { AdminService } = cds.services
|
||||
|
||||
@@ -3,7 +3,7 @@ const { GET, POST, expect } = cds.test(__dirname+'/../bookshop')
|
||||
if (cds.User.default) cds.User.default = cds.User.Privileged // hard core monkey patch
|
||||
else cds.User = cds.User.Privileged // hard core monkey patch for older cds releases
|
||||
|
||||
describe('cap/samples - Custom Handlers', () => {
|
||||
describe('Custom Handlers', () => {
|
||||
|
||||
it('should reject out-of-stock orders', async () => {
|
||||
await POST `/browse/submitOrder ${{ book: 201, quantity: 5 }}`
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
const cds = require('@sap/cds/lib')
|
||||
const { GET, expect } = cds.test (__dirname+'/../hello')
|
||||
|
||||
describe('cap/samples - Hello world!', () => {
|
||||
describe('Hello world!', () => {
|
||||
|
||||
it('should say hello with class impl', async () => {
|
||||
const {data} = await GET `/say/hello(to='world')`
|
||||
|
||||
@@ -13,7 +13,7 @@ const model = cds.compile.to.csn (`
|
||||
const {Categories:Cats} = model.definitions
|
||||
|
||||
|
||||
describe('cap/samples - Hierarchical Data', ()=>{
|
||||
describe('Hierarchical Data', ()=>{
|
||||
|
||||
before ('bootstrap sqlite in-memory db...', async()=>{
|
||||
await cds.deploy (model) .to ('sqlite::memory:')
|
||||
|
||||
@@ -2,7 +2,7 @@ const { GET, expect, cds } = require('@sap/cds/lib').test (__dirname)
|
||||
if (cds.User.default) cds.User.default = cds.User.Privileged // hard core monkey patch
|
||||
else cds.User = cds.User.Privileged // hard core monkey patch for older cds releases
|
||||
|
||||
describe('cap/samples - Localized Data', () => {
|
||||
describe('Localized Data', () => {
|
||||
|
||||
it('serves localized $metadata documents', async () => {
|
||||
const { data } = await GET`/browse/$metadata?sap-language=de`
|
||||
|
||||
@@ -4,7 +4,7 @@ const _model = '@capire/reviews'
|
||||
if (cds.User.default) cds.User.default = cds.User.Privileged // hard core monkey patch
|
||||
else cds.User = cds.User.Privileged // hard core monkey patch for older cds releases
|
||||
|
||||
describe('cap/samples - Messaging', ()=>{
|
||||
describe('Messaging', ()=>{
|
||||
|
||||
it ('should bootstrap sqlite in-memory db', async()=>{
|
||||
const db = await cds.deploy (_model) .to ('sqlite::memory:')
|
||||
|
||||
@@ -1,48 +1,9 @@
|
||||
const cds = require('@sap/cds/lib')
|
||||
const { GET, expect, axios } = cds.test ('@capire/bookshop')
|
||||
axios.defaults.auth = { username: 'alice', password: 'admin' }
|
||||
const { GET, expect } = cds.test ('@capire/bookshop')
|
||||
if (cds.User.default) cds.User.default = cds.User.Privileged // hard core monkey patch
|
||||
else cds.User = cds.User.Privileged // hard core monkey patch for older cds releases
|
||||
|
||||
describe('cap/samples - Bookshop APIs', () => {
|
||||
|
||||
// Genres
|
||||
const Drama = {
|
||||
"name": "Drama",
|
||||
"descr": null,
|
||||
"ID": 11,
|
||||
"parent_ID": 10
|
||||
}
|
||||
const Mystery = {
|
||||
"name": "Mystery",
|
||||
"descr": null,
|
||||
"ID": 16,
|
||||
"parent_ID": 10
|
||||
}
|
||||
const Fantasy = {
|
||||
"name": "Fantasy",
|
||||
"descr": null,
|
||||
"ID": 13,
|
||||
"parent_ID": 10
|
||||
}
|
||||
|
||||
// Currencies
|
||||
const GBP = {
|
||||
"name": "British Pound",
|
||||
"descr": null,
|
||||
"code": "GBP",
|
||||
"symbol": "£"
|
||||
}
|
||||
const USD = {
|
||||
"name": "US Dollar",
|
||||
"descr": null,
|
||||
"code": "USD",
|
||||
"symbol": "$"
|
||||
}
|
||||
const JPY = {
|
||||
"name": "Yen",
|
||||
"descr": null,
|
||||
"code": "JPY",
|
||||
"symbol": "¥"
|
||||
}
|
||||
describe('OData Protocol', () => {
|
||||
|
||||
|
||||
it('serves $metadata documents in v4', async () => {
|
||||
@@ -56,16 +17,6 @@ describe('cap/samples - Bookshop APIs', () => {
|
||||
expect(data).to.contain('<Annotation Term="Common.Label" String="Currency"/>')
|
||||
})
|
||||
|
||||
it('serves ListOfBooks?$expand=genre,currency', async () => {
|
||||
const { data } = await GET `/browse/ListOfBooks ${{
|
||||
params: { $search: 'Po', $select: `title,author`, $expand:`genre,currency` },
|
||||
}}`
|
||||
expect(data.value).to.eql([
|
||||
{ ID: 251, title: 'The Raven', author: 'Edgar Allen Poe', genre:Mystery, currency:USD },
|
||||
{ ID: 252, title: 'Eleonora', author: 'Edgar Allen Poe', genre:Mystery, currency:USD },
|
||||
])
|
||||
})
|
||||
|
||||
it('supports $search in multiple fields', async () => {
|
||||
const { data } = await GET `/browse/Books ${{
|
||||
params: { $search: 'Po', $select: `title,author` },
|
||||
@@ -124,16 +75,4 @@ describe('cap/samples - Bookshop APIs', () => {
|
||||
{ ID: 271, title: 'Catweazle' },
|
||||
])
|
||||
})
|
||||
|
||||
it('serves user info', async () => {
|
||||
{
|
||||
const { data } = await GET (`/user/me`)
|
||||
expect(data).to.containSubset({ id: 'alice', locale:'en', tenant: null })
|
||||
}
|
||||
{
|
||||
const { data } = await GET (`/user/me`, {auth: { username: 'joe' }})
|
||||
expect(data).to.containSubset({ id: 'joe', locale:'en', tenant: null })
|
||||
}
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
@@ -6,7 +6,7 @@ const { resolve } = require('path')
|
||||
const verbose = process.env.CDS_TEST_VERBOSE
|
||||
// ||true
|
||||
|
||||
describe('cap/samples - Local NPM registry', () => {
|
||||
describe('Local NPM registry', () => {
|
||||
let registry
|
||||
let axios
|
||||
const cwd = resolve(__dirname, '..')
|
||||
@@ -20,7 +20,7 @@ describe('cap/samples - Local NPM registry', () => {
|
||||
|
||||
after(() => { registry.kill() })
|
||||
|
||||
for (const mod of ['bookshop', 'data-viewer', 'fiori','orders','reviews']) {
|
||||
for (const mod of ['bookshop','fiori','orders','reviews']) {
|
||||
it(`should serve ${mod}`, async () => {
|
||||
const resp = await axios.get(`/@capire/${mod}`)
|
||||
expect(resp.data).to.containSubset({name: `@capire/${mod}`, versions:{}})
|
||||
|
||||
Reference in New Issue
Block a user