diff --git a/.gitignore b/.gitignore index 9f14d60b..c4d1b518 100644 --- a/.gitignore +++ b/.gitignore @@ -18,3 +18,5 @@ reviews/msg-box reviews/db/test.db *.openapi3.json +*.sqlite +*.db diff --git a/bookshop/app/vue/app.js b/bookshop/app/vue/app.js index 18e4ef23..b637d115 100644 --- a/bookshop/app/vue/app.js +++ b/bookshop/app/vue/app.js @@ -56,7 +56,7 @@ const books = Vue.createApp ({ } catch (err) { books.user = { id: err.message } } }, } -}).mount("#app") +}).mount('#app') books.getUserInfo() books.fetch() // initially fill list of books @@ -65,3 +65,25 @@ 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']) + } +} \ No newline at end of file diff --git a/bookshop/db/data/sap.capire.bookshop-Books.csv b/bookshop/db/data/sap.capire.bookshop-Books.csv index 702375bb..bfe13f2c 100644 --- a/bookshop/db/data/sap.capire.bookshop-Books.csv +++ b/bookshop/db/data/sap.capire.bookshop-Books.csv @@ -2,5 +2,5 @@ ID;title;descr;author_ID;stock;price;currency_code;genre_ID 201;Wuthering Heights;"Wuthering Heights, Emily Brontë's only novel, was published in 1847 under the pseudonym ""Ellis Bell"". It was written between October 1845 and June 1846. Wuthering Heights and Anne Brontë's Agnes Grey were accepted by publisher Thomas Newby before the success of their sister Charlotte's novel Jane Eyre. After Emily's death, Charlotte edited the manuscript of Wuthering Heights and arranged for the edited version to be published as a posthumous second edition in 1850.";101;12;11.11;GBP;11 207;Jane Eyre;"Jane Eyre /ɛər/ (originally published as Jane Eyre: An Autobiography) is a novel by English writer Charlotte Brontë, published under the pen name ""Currer Bell"", on 16 October 1847, by Smith, Elder & Co. of London. The first American edition was published the following year by Harper & Brothers of New York. Primarily a bildungsroman, Jane Eyre follows the experiences of its eponymous heroine, including her growth to adulthood and her love for Mr. Rochester, the brooding master of Thornfield Hall. The novel revolutionised prose fiction in that the focus on Jane's moral and spiritual development is told through an intimate, first-person narrative, where actions and events are coloured by a psychological intensity. The book contains elements of social criticism, with a strong sense of Christian morality at its core and is considered by many to be ahead of its time because of Jane's individualistic character and how the novel approaches the topics of class, sexuality, religion and feminism.";107;11;12.34;GBP;11 251;The Raven;"""The Raven"" is a narrative poem by American writer Edgar Allan Poe. First published in January 1845, the poem is often noted for its musicality, stylized language, and supernatural atmosphere. It tells of a talking raven's mysterious visit to a distraught lover, tracing the man's slow fall into madness. The lover, often identified as being a student, is lamenting the loss of his love, Lenore. Sitting on a bust of Pallas, the raven seems to further distress the protagonist with its constant repetition of the word ""Nevermore"". The poem makes use of folk, mythological, religious, and classical references.";150;333;13.13;USD;16 -252;Eleonora;"""Eleonora"" is a short story by Edgar Allan Poe, first published in 1842 in Philadelphia in the literary annual The Gift. It is often regarded as somewhat autobiographical and has a relatively ""happy"" ending.";150;555;14;USD;16 +252;Eleonora;"""Eleonora"" is a short story by Edgar Allan Poe, first published in 1842 in Philadelphia in the literary annual The Gift. It is often regarded as somewhat autobiographical and has a relatively ""happy"" ending.";150;555;14;USD;15 271;Catweazle;Catweazle is a British fantasy television series, starring Geoffrey Bayldon in the title role, and created by Richard Carpenter for London Weekend Television. The first series, produced and directed by Quentin Lawrence, was screened in the UK on ITV in 1970. The second series, directed by David Reid and David Lane, was shown in 1971. Each series had thirteen episodes, most but not all written by Carpenter, who also published two books based on the scripts.;170;22;150;JPY;13 \ No newline at end of file diff --git a/bookshop/srv/cat-service.js b/bookshop/srv/cat-service.js index eb314db5..3c557078 100644 --- a/bookshop/srv/cat-service.js +++ b/bookshop/srv/cat-service.js @@ -2,7 +2,8 @@ const cds = require('@sap/cds') class CatalogService extends cds.ApplicationService { init(){ - const { Books } = this.entities ('sap.capire.bookshop') + const { Books } = cds.entities ('sap.capire.bookshop') + const { ListOfBooks } = this.entities // Reduce stock of ordered books if available stock suffices this.on ('submitOrder', async req => { @@ -18,7 +19,7 @@ class CatalogService extends cds.ApplicationService { init(){ }) // Add some discount for overstocked books - this.after ('READ','ListOfBooks', each => { + this.after ('READ', ListOfBooks, each => { if (each.stock > 111) each.title += ` -- 11% discount!` }) diff --git a/bookshop/srv/user-service.cds b/bookshop/srv/user-service.cds index 47f58971..09b7676f 100644 --- a/bookshop/srv/user-service.cds +++ b/bookshop/srv/user-service.cds @@ -5,7 +5,7 @@ service UserService { /** * The current user */ - @odata.singleton entity me { + @odata.singleton entity me @cds.persistence.skip { id : String; // user id locale : String; tenant : String; diff --git a/bookstore/server.js b/bookstore/server.js index 15a41c60..26f5d843 100644 --- a/bookstore/server.js +++ b/bookstore/server.js @@ -19,4 +19,4 @@ module.exports = cds.server // For didactic reasons in capire const { ReviewsService, OrdersService } = cds.requires -if (!ReviewsService.credentials && !OrdersService.credentials) cds.requires.messaging = false +if (!ReviewsService?.credentials && !OrdersService?.credentials) cds.requires.messaging = false diff --git a/data-viewer/srv/data-service.cds b/data-viewer/srv/data-service.cds index 0420d309..d03cfce4 100644 --- a/data-viewer/srv/data-service.cds +++ b/data-viewer/srv/data-service.cds @@ -2,12 +2,12 @@ * Exposes data + entity metadata */ @requires:'authenticated-user' -service DataService @( path:'-data' ) { +@odata service DataService @( path:'-data' ) { /** * Metadata like name and columns/elements */ - entity Entities { + entity Entities @cds.persistence.skip { key name : String; columns: Composition of many { name : String; @@ -19,7 +19,7 @@ service DataService @( path:'-data' ) { /** * The actual data, organized by column name */ - entity Data { + entity Data @cds.persistence.skip { record : array of { column : String; data : String; diff --git a/fiori/app/browse/fiori-service.cds b/fiori/app/browse/fiori-service.cds index ef960b29..def17d31 100644 --- a/fiori/app/browse/fiori-service.cds +++ b/fiori/app/browse/fiori-service.cds @@ -33,7 +33,7 @@ annotate CatalogService.Books with @(UI : { //////////////////////////////////////////////////////////////////////////// // -// Books Object Page +// Books List Page // annotate CatalogService.Books with @(UI : { SelectionFields : [ diff --git a/fiori/app/common.cds b/fiori/app/common.cds index 7337c56a..1f396d8d 100644 --- a/fiori/app/common.cds +++ b/fiori/app/common.cds @@ -10,40 +10,31 @@ using { sap.common } from '@capire/common'; // Books Lists // annotate my.Books with @( - Common.SemanticKey : [ID], - UI : { - Identification : [{Value : title}], - SelectionFields : [ - ID, - author_ID, - price, - currency_code - ], - LineItem : [ - { - Value : ID, - Label : '{i18n>Title}' - }, - { - Value : author.ID, - Label : '{i18n>Author}' - }, - {Value : genre.name}, - {Value : stock}, - {Value : price}, - { - Value : currency.symbol, - Label : ' ' - }, - ] - } + Common.SemanticKey : [ID], + UI : { + Identification : [{ Value: title }], + SelectionFields : [ + ID, + author_ID, + price, + currency_code + ], + LineItem : [ + { Value: ID, Label: '{i18n>Title}' }, + { Value: author.ID, Label: '{i18n>Author}' }, + { Value: genre.name }, + { Value: stock }, + { Value: price }, + { Value: currency.symbol, Label: ' ' }, + ] + } ) { - ID @Common: { - SemanticObject : 'Books', - Text: title, - TextArrangement : #TextOnly - }; - author @ValueList.entity : 'Authors'; + ID @Common: { + SemanticObject : 'Books', + Text: title, + TextArrangement : #TextOnly + }; + author @ValueList.entity : 'Authors'; }; //////////////////////////////////////////////////////////////////////////// @@ -51,10 +42,10 @@ annotate my.Books with @( // Books Details // annotate my.Books with @(UI : {HeaderInfo : { - TypeName : '{i18n>Book}', - TypeNamePlural : '{i18n>Books}', - Title : {Value : title}, - Description : {Value : author.name} + TypeName : '{i18n>Book}', + TypeNamePlural : '{i18n>Books}', + Title : { Value: title }, + Description : { Value: author.name } }, }); @@ -63,19 +54,13 @@ annotate my.Books with @(UI : {HeaderInfo : { // Books Elements // annotate my.Books with { - ID @title : '{i18n>ID}'; - title @title : '{i18n>Title}'; - genre @title : '{i18n>Genre}' @Common : { - Text : genre.name, - TextArrangement : #TextOnly - }; - author @title : '{i18n>Author}' @Common : { - Text : author.name, - TextArrangement : #TextOnly - }; - price @title : '{i18n>Price}' @Measures.ISOCurrency : currency_code; - stock @title : '{i18n>Stock}'; - descr @UI.MultiLineText; + ID @title: '{i18n>ID}'; + title @title: '{i18n>Title}'; + genre @title: '{i18n>Genre}' @Common: { Text: genre.name, TextArrangement: #TextOnly }; + author @title: '{i18n>Author}' @Common: { Text: author.name, TextArrangement: #TextOnly }; + price @title: '{i18n>Price}' @Measures.ISOCurrency : currency_code; + stock @title: '{i18n>Stock}'; + descr @UI.MultiLineText; } //////////////////////////////////////////////////////////////////////////// @@ -83,17 +68,17 @@ annotate my.Books with { // Genres List // annotate my.Genres with @( - Common.SemanticKey : [name], - UI : { - SelectionFields : [name], - LineItem : [ - {Value : name}, - { - Value : parent.name, - Label : 'Main Genre' - }, - ], - } + Common.SemanticKey : [name], + UI : { + SelectionFields : [name], + LineItem : [ + { Value: name }, + { + Value : parent.name, + Label: 'Main Genre' + }, + ], + } ); //////////////////////////////////////////////////////////////////////////// @@ -101,18 +86,18 @@ annotate my.Genres with @( // Genre Details // annotate my.Genres with @(UI : { - Identification : [{Value : name}], - HeaderInfo : { - TypeName : '{i18n>Genre}', - TypeNamePlural : '{i18n>Genres}', - Title : {Value : name}, - Description : {Value : ID} - }, - Facets : [{ - $Type : 'UI.ReferenceFacet', - Label : '{i18n>SubGenres}', - Target : 'children/@UI.LineItem' - }, ], + Identification : [{ Value: name}], + HeaderInfo : { + TypeName : '{i18n>Genre}', + TypeNamePlural : '{i18n>Genres}', + Title : { Value: name }, + Description : { Value: ID } + }, + Facets : [{ + $Type : 'UI.ReferenceFacet', + Label : '{i18n>SubGenres}', + Target : 'children/@UI.LineItem' + }, ], }); //////////////////////////////////////////////////////////////////////////// @@ -120,8 +105,8 @@ annotate my.Genres with @(UI : { // Genres Elements // annotate my.Genres with { - ID @title : '{i18n>ID}'; - name @title : '{i18n>Genre}'; + ID @title: '{i18n>ID}'; + name @title: '{i18n>Genre}'; } //////////////////////////////////////////////////////////////////////////// @@ -129,24 +114,24 @@ annotate my.Genres with { // Authors List // annotate my.Authors with @( - Common.SemanticKey : [ID], - UI : { - Identification : [{Value : name}], - SelectionFields : [name], - LineItem : [ - {Value : ID}, - {Value : dateOfBirth}, - {Value : dateOfDeath}, - {Value : placeOfBirth}, - {Value : placeOfDeath}, - ], - } + Common.SemanticKey : [ID], + UI : { + Identification : [{ Value: name}], + SelectionFields : [name], + LineItem : [ + { Value: ID }, + { Value: dateOfBirth }, + { Value: dateOfDeath }, + { Value: placeOfBirth }, + { Value: placeOfDeath }, + ], + } ) { - ID @Common: { - SemanticObject : 'Authors', - Text: name, - TextArrangement : #TextOnly, - }; + ID @Common: { + SemanticObject : 'Authors', + Text: name, + TextArrangement : #TextOnly, + }; }; //////////////////////////////////////////////////////////////////////////// @@ -154,16 +139,16 @@ annotate my.Authors with @( // Author Details // annotate my.Authors with @(UI : { - HeaderInfo : { - TypeName : '{i18n>Author}', - TypeNamePlural : '{i18n>Authors}', - Title : {Value : name}, - Description : {Value : dateOfBirth} - }, - Facets : [{ - $Type : 'UI.ReferenceFacet', - Target : 'books/@UI.LineItem' - }, ], + HeaderInfo : { + TypeName : '{i18n>Author}', + TypeNamePlural : '{i18n>Authors}', + Title : { Value: name }, + Description : { Value: dateOfBirth } + }, + Facets : [{ + $Type : 'UI.ReferenceFacet', + Target : 'books/@UI.LineItem' + }, ], }); @@ -172,12 +157,12 @@ annotate my.Authors with @(UI : { // Authors Elements // annotate my.Authors with { - ID @title : '{i18n>ID}'; - name @title : '{i18n>Name}'; - dateOfBirth @title : '{i18n>DateOfBirth}'; - dateOfDeath @title : '{i18n>DateOfDeath}'; - placeOfBirth @title : '{i18n>PlaceOfBirth}'; - placeOfDeath @title : '{i18n>PlaceOfDeath}'; + ID @title: '{i18n>ID}'; + name @title: '{i18n>Name}'; + dateOfBirth @title: '{i18n>DateOfBirth}'; + dateOfDeath @title: '{i18n>DateOfDeath}'; + placeOfBirth @title: '{i18n>PlaceOfBirth}'; + placeOfDeath @title: '{i18n>PlaceOfDeath}'; } //////////////////////////////////////////////////////////////////////////// @@ -185,18 +170,18 @@ annotate my.Authors with { // Languages List // annotate common.Languages with @( - Common.SemanticKey : [code], - Identification : [{Value : code}], - UI : { - SelectionFields : [ - name, - descr - ], - LineItem : [ - {Value : code}, - {Value : name}, - ], - } + Common.SemanticKey : [code], + Identification : [{ Value: code}], + UI : { + SelectionFields : [ + name, + descr + ], + LineItem : [ + { Value: code }, + { Value: name }, + ], + } ); //////////////////////////////////////////////////////////////////////////// @@ -204,22 +189,22 @@ annotate common.Languages with @( // Language Details // annotate common.Languages with @(UI : { - HeaderInfo : { - TypeName : '{i18n>Language}', - TypeNamePlural : '{i18n>Languages}', - Title : {Value : name}, - Description : {Value : descr} - }, - Facets : [{ - $Type : 'UI.ReferenceFacet', - Label : '{i18n>Details}', - Target : '@UI.FieldGroup#Details' - }, ], - FieldGroup #Details : {Data : [ - {Value : code}, - {Value : name}, - {Value : descr} - ]}, + HeaderInfo : { + TypeName : '{i18n>Language}', + TypeNamePlural : '{i18n>Languages}', + Title : { Value: name }, + Description : { Value: descr } + }, + Facets : [{ + $Type : 'UI.ReferenceFacet', + Label : '{i18n>Details}', + Target : '@UI.FieldGroup#Details' + }, ], + FieldGroup #Details : {Data : [ + { Value: code }, + { Value: name }, + { Value: descr } + ]}, }); //////////////////////////////////////////////////////////////////////////// @@ -227,19 +212,19 @@ annotate common.Languages with @(UI : { // Currencies List // annotate common.Currencies with @( - Common.SemanticKey : [code], - Identification : [{Value : code}], - UI : { - SelectionFields : [ - name, - descr - ], - LineItem : [ - {Value : descr}, - {Value : symbol}, - {Value : code}, - ], - } + Common.SemanticKey : [code], + Identification : [{ Value: code}], + UI : { + SelectionFields : [ + name, + descr + ], + LineItem : [ + { Value: descr }, + { Value: symbol }, + { Value: code }, + ], + } ); //////////////////////////////////////////////////////////////////////////// @@ -247,35 +232,35 @@ annotate common.Currencies with @( // Currency Details // annotate common.Currencies with @(UI : { - HeaderInfo : { - TypeName : '{i18n>Currency}', - TypeNamePlural : '{i18n>Currencies}', - Title : {Value : descr}, - Description : {Value : code} + HeaderInfo : { + TypeName : '{i18n>Currency}', + TypeNamePlural : '{i18n>Currencies}', + Title : { Value: descr }, + Description : { Value: code } + }, + Facets : [ + { + $Type : 'UI.ReferenceFacet', + Label : '{i18n>Details}', + Target : '@UI.FieldGroup#Details' }, - Facets : [ - { - $Type : 'UI.ReferenceFacet', - Label : '{i18n>Details}', - Target : '@UI.FieldGroup#Details' - }, - { - $Type : 'UI.ReferenceFacet', - Label : '{i18n>Extended}', - Target : '@UI.FieldGroup#Extended' - }, - ], - FieldGroup #Details : {Data : [ - {Value : name}, - {Value : symbol}, - {Value : code}, - {Value : descr} - ]}, - FieldGroup #Extended : {Data : [ - {Value : numcode}, - {Value : minor}, - {Value : exponent} - ]}, + { + $Type : 'UI.ReferenceFacet', + Label : '{i18n>Extended}', + Target : '@UI.FieldGroup#Extended' + }, + ], + FieldGroup #Details : {Data : [ + { Value: name }, + { Value: symbol }, + { Value: code }, + { Value: descr } + ]}, + FieldGroup #Extended : {Data : [ + { Value: numcode }, + { Value: minor }, + { Value: exponent } + ]}, }); //////////////////////////////////////////////////////////////////////////// @@ -283,7 +268,7 @@ annotate common.Currencies with @(UI : { // Currencies Elements // annotate common.Currencies with { - numcode @title : '{i18n>NumCode}'; - minor @title : '{i18n>MinorUnit}'; - exponent @title : '{i18n>Exponent}'; + numcode @title: '{i18n>NumCode}'; + minor @title: '{i18n>MinorUnit}'; + exponent @title: '{i18n>Exponent}'; } diff --git a/orders/app/fiori.cds b/orders/app/fiori.cds index e3644ede..8e2a3ab6 100644 --- a/orders/app/fiori.cds +++ b/orders/app/fiori.cds @@ -16,11 +16,12 @@ using { OrdersService } from '../srv/orders-service'; @odata.draft.enabled annotate OrdersService.Orders with @( UI: { - SelectionFields: [ createdAt, createdBy ], + SelectionFields: [ createdBy ], LineItem: [ {Value: OrderNo, Label:'OrderNo'}, {Value: buyer, Label:'Customer'}, - {Value: createdAt, Label:'Date'} + {Value: currency.symbol, Label:'Currency'}, + {Value: createdAt, Label:'Date'}, ], HeaderInfo: { TypeName: 'Order', TypeNamePlural: 'Orders', diff --git a/orders/app/orders/index.html b/orders/app/orders/index.html index 6324cec3..5761894b 100644 --- a/orders/app/orders/index.html +++ b/orders/app/orders/index.html @@ -13,7 +13,7 @@ applications: { "manage-orders": { title: "Manage Orders", - description: "... testing FE v42", + description: "CAP Sample App", additionalInformation: "SAPUI5.Component=orders", applicationType : "URL", url: "/orders/webapp", diff --git a/orders/app/orders/webapp/manifest.json b/orders/app/orders/webapp/manifest.json index 045fa70a..257be403 100644 --- a/orders/app/orders/webapp/manifest.json +++ b/orders/app/orders/webapp/manifest.json @@ -3,8 +3,8 @@ "sap.app": { "id": "orders", "type": "application", - "title": "Order Books", - "description": "Sample Application", + "title": "Order Management", + "description": "CAP Sample Application", "i18n": "i18n/i18n.properties", "dataSources": { "OrdersService": { diff --git a/orders/db/schema.cds b/orders/db/schema.cds index 85effeaf..ec9549ac 100644 --- a/orders/db/schema.cds +++ b/orders/db/schema.cds @@ -2,7 +2,7 @@ using { Currency, User, managed, cuid } from '@sap/cds/common'; namespace sap.capire.orders; entity Orders : cuid, managed { - OrderNo : String @title:'Order Number'; //> readable key + OrderNo : String(22) @title:'Order Number'; //> readable key Items : Composition of many { key ID : UUID; product : Association to Products; diff --git a/package-lock.json b/package-lock.json index ce45b039..d5836158 100644 --- a/package-lock.json +++ b/package-lock.json @@ -58,9 +58,9 @@ "dev": true }, "@mapbox/node-pre-gyp": { - "version": "1.0.9", - "resolved": "https://registry.npmjs.org/@mapbox/node-pre-gyp/-/node-pre-gyp-1.0.9.tgz", - "integrity": "sha512-aDF3S3rK9Q2gey/WAttUlISduDItz5BU3306M9Eyv6/oS40aMprnopshtlKTykxRNIBEZuRMaZAnbrQ4QtKGyw==", + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/@mapbox/node-pre-gyp/-/node-pre-gyp-1.0.10.tgz", + "integrity": "sha512-4ySo4CjzStuprMwk35H5pPbkymjv1SF3jGLj6rAHp/xT/RF7TL7bd9CTm1xDY49K2qF7jmR/g7k+SkLETP6opA==", "dev": true, "requires": { "detect-libc": "^2.0.0", @@ -123,18 +123,18 @@ } }, "@sap/cds": { - "version": "6.1.3", - "resolved": "https://registry.npmjs.org/@sap/cds/-/cds-6.1.3.tgz", - "integrity": "sha512-yvL9lPonVwUx9Md1eylAtpY0JrlSMyoxZXnCA2q9lNoVNudmjPMynO5CJBfAYEaThZSqd2yMJg/+xyKy/mn3wg==", + "version": "6.2.2", + "resolved": "https://registry.npmjs.org/@sap/cds/-/cds-6.2.2.tgz", + "integrity": "sha512-l1ps/Ofp+0k/ngSrCHBFNUXQew6n9A4OJhrm3CroxIEq8wQeXB5LBq53YQQYoCj807eQlXbVbzg6hRCm+BgDaQ==", "requires": { - "@sap/cds-compiler": "^3.0.0", + "@sap/cds-compiler": "^3.2.0", "@sap/cds-foss": "^4" } }, "@sap/cds-compiler": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/@sap/cds-compiler/-/cds-compiler-3.1.2.tgz", - "integrity": "sha512-csH3aEs4aPCzAtc75Jx/Ayym2A06JgAeaDUFLXI867/Vsp2F0g7MJxuCkNhpa+zVZsXcyB0Kxzzv4xU7zuJXsQ==", + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/@sap/cds-compiler/-/cds-compiler-3.3.2.tgz", + "integrity": "sha512-jOUEjSMBOVZXmWgx3/mu8H9BbvgP+HVyyKXbHHZWJlk0NMlk+FI/q4KagUaGWJFyRVBskdzF4zBD/QLlrhRnHA==", "requires": { "antlr4": "4.9.3" } @@ -383,13 +383,14 @@ "dev": true }, "axios": { - "version": "0.27.2", - "resolved": "https://registry.npmjs.org/axios/-/axios-0.27.2.tgz", - "integrity": "sha512-t+yRIyySRTp/wua5xEr+z1q60QmLq8ABsS5O9Me1AsE5dfKqgnCFzwiCZZ/cGNd1lq4/7akDWMxdhVlucjmnOQ==", + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.1.2.tgz", + "integrity": "sha512-bznQyETwElsXl2RK7HLLwb5GPpOLlycxHCtrpDR/4RqqBzjARaOTo3jz4IgtntWUYee7Ne4S8UHd92VCuzPaWA==", "dev": true, "requires": { - "follow-redirects": "^1.14.9", - "form-data": "^4.0.0" + "follow-redirects": "^1.15.0", + "form-data": "^4.0.0", + "proxy-from-env": "^1.1.0" } }, "balanced-match": { @@ -940,9 +941,9 @@ } }, "generic-pool": { - "version": "3.8.2", - "resolved": "https://registry.npmjs.org/generic-pool/-/generic-pool-3.8.2.tgz", - "integrity": "sha512-nGToKy6p3PAbYQ7p1UlWl6vSPwfwU6TMSWK7TTu+WUY4ZjyZQGniGGt2oNVvyNSpyZYSB43zMXVLcBm08MTMkg==" + "version": "3.9.0", + "resolved": "https://registry.npmjs.org/generic-pool/-/generic-pool-3.9.0.tgz", + "integrity": "sha512-hymDOu5B53XvN4QT9dBmZxPX4CWhBPPLguTZ9MMFeFa/Kg0xWVfylOVNlJji/E7yTZWFd/q9GO5TxDLq156D7g==" }, "get-func-name": { "version": "2.0.0", @@ -1721,10 +1722,15 @@ "dev": true, "optional": true }, + "sax": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/sax/-/sax-1.2.4.tgz", + "integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw==" + }, "semver": { - "version": "7.3.7", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.7.tgz", - "integrity": "sha512-QlYTucUYOews+WeEujDoEGziz4K6c47V/Bd+LjSSYcA94p+DmINdf7ncaUinThfvZyu13lN9OY1XDxt8C0Tw0g==", + "version": "7.3.8", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.8.tgz", + "integrity": "sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A==", "dev": true, "requires": { "lru-cache": "^6.0.0" @@ -1771,9 +1777,9 @@ "optional": true }, "socks": { - "version": "2.7.0", - "resolved": "https://registry.npmjs.org/socks/-/socks-2.7.0.tgz", - "integrity": "sha512-scnOe9y4VuiNUULJN72GrM26BNOjVsfPXI+j+98PkyEfsIXroa5ofyjT+FzGvn/xHs73U2JtoBYAVx9Hl4quSA==", + "version": "2.7.1", + "resolved": "https://registry.npmjs.org/socks/-/socks-2.7.1.tgz", + "integrity": "sha512-7maUZy1N7uo6+WVEX6psASxtNlKaNVMlGQKkG/63nEDdLOWNbiUMoLK7X4uYoLhQstau72mLgfEWcXcwsaHbYQ==", "dev": true, "optional": true, "requires": { @@ -1794,9 +1800,9 @@ } }, "sqlite3": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/sqlite3/-/sqlite3-5.1.0.tgz", - "integrity": "sha512-/cZl9DfeSQMWR5g9SdluHGt+YL3URetjtvgv1XPQx7rzXOFdZx30EnZj709wCEIznjjzZdo5Lmt5GUeNyGgUbQ==", + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/sqlite3/-/sqlite3-5.1.2.tgz", + "integrity": "sha512-D0Reg6pRWAFXFUnZKsszCI67tthFD8fGPewRddDCX6w4cYwz3MbvuwRICbL+YQjBAh9zbw+lJ/V9oC8nG5j6eg==", "dev": true, "requires": { "@mapbox/node-pre-gyp": "^1.0.0", @@ -2001,6 +2007,22 @@ "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", "dev": true }, + "xml2js": { + "version": "0.4.23", + "resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.4.23.tgz", + "integrity": "sha512-ySPiMjM0+pLDftHgXY4By0uswI3SPKLDw/i3UXbnO8M/p28zqexCUoPmQFrYD+/1BzhGJSs2i1ERWKJAtiLrug==", + "requires": { + "sax": ">=0.6.0", + "xmlbuilder": "~11.0.0" + }, + "dependencies": { + "xmlbuilder": { + "version": "11.0.1", + "resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-11.0.1.tgz", + "integrity": "sha512-fDlsI/kFEx7gLvbecc0/ohLG50fugQp8ryHzMTuW9vSa1GJ0XYWKnhsUx7oie3G98+r56aTQIUB4kht42R3JvA==" + } + } + }, "xmlbuilder": { "version": "15.1.1", "resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-15.1.1.tgz", @@ -2013,10 +2035,6 @@ "dev": true }, "yaml": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.1.1.tgz", - "integrity": "sha512-o96x3OPo8GjWeSLF+wOAbrPfhFOGY0W00GNaxCDv+9hkcDJEnev1yh8S7pgHF0ik6zc8sQLuL8hjHjJULZp8bw==" - }, "yocto-queue": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", diff --git a/package.json b/package.json index ccde6ef7..fcb58d3f 100644 --- a/package.json +++ b/package.json @@ -8,10 +8,18 @@ "@sap/cds": ">=5.5.3" }, "workspaces": [ - "./*/" + "./bookshop", + "./bookstore", + "./common", + "./data-viewer", + "./fiori", + "./hello", + "./media", + "./orders", + "./reviews" ], "devDependencies": { - "axios": "^0", + "axios": "^1", "chai": "^4.3.4", "chai-as-promised": "^7.1.1", "chai-subset": "^1.6.0", diff --git a/test/cds.ql.test.js b/test/cds.ql.test.js index c9f3f6dc..e3c76e42 100644 --- a/test/cds.ql.test.js +++ b/test/cds.ql.test.js @@ -411,18 +411,67 @@ describe('cds.ql → cqn', () => { ] }}) - expect ( - SELECT.from(Foo).where({x:1,or:{y:2}}) - ).to.eql ( - CQL`SELECT from Foo where x=1 or y=2` - ).to.eql ({ SELECT: { - from: {ref:['Foo']}, - where: [ - {ref:['x']}, '=', {val:1}, - 'or', - {ref:['y']}, '=', {val:2} - ] - }}) + const ql_with_groups_fix = !!cds.ql.Query.prototype.flat + if (ql_with_groups_fix) { + + expect ( + SELECT.from(Foo).where({x:1}).or({y:2}).and({z:3}) + ).to.eql ({ SELECT: { + from: {ref:['Foo']}, + where: [ + {ref:['x']}, '=', {val:1}, + 'or', + {ref:['y']}, '=', {val:2}, + 'and', + {ref:['z']}, '=', {val:3}, + ] + }}) + + expect ( + SELECT.from(Foo).where({x:1,or:{y:2}}).and({z:3}) + ).to.eql ({ SELECT: { + from: {ref:['Foo']}, + where: [ + {xpr:[ + {ref:['x']}, '=', {val:1}, + 'or', + {ref:['y']}, '=', {val:2}, + ]}, + 'and', + {ref:['z']}, '=', {val:3}, + ] + }}) + + expect ( + SELECT.from(Foo).where({a:1}).or({x:1,or:{y:2}}).and({z:3}) + ).to.eql ({ SELECT: { + from: {ref:['Foo']}, + where: [ + {ref:['a']}, '=', {val:1}, + 'or', + {xpr:[ + {ref:['x']}, '=', {val:1}, + 'or', + {ref:['y']}, '=', {val:2}, + ]}, + 'and', + {ref:['z']}, '=', {val:3}, + ] + }}) + + expect ( + { SELECT: SELECT.from(Foo).where({x:1,or:{y:2}}).SELECT } + ).to.eql ({ SELECT: { + from: {ref:['Foo']}, + where: [ + {ref:['x']}, '=', {val:1}, + 'or', + {ref:['y']}, '=', {val:2}, + ] + }}) + + } + expect ( SELECT.from(Foo).where({x:1,and:{y:2}}).or({z:3}) diff --git a/test/odata.test.js b/test/odata.test.js index f5eba97e..71d6f0a8 100644 --- a/test/odata.test.js +++ b/test/odata.test.js @@ -17,10 +17,10 @@ describe('cap/samples - Bookshop APIs', () => { "ID": 16, "parent_ID": 10 } - const Fantasy = { - "name": "Fantasy", + const Romance = { + "name": "Romance", "descr": null, - "ID": 13, + "ID": 15, "parent_ID": 10 } @@ -62,7 +62,7 @@ describe('cap/samples - Bookshop APIs', () => { }}` 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 }, + { ID: 252, title: 'Eleonora', author: 'Edgar Allen Poe', genre:Romance, currency:USD }, ]) }) diff --git a/test/registry.test.js b/test/registry.test.js index e42a94ca..5c64c31e 100644 --- a/test/registry.test.js +++ b/test/registry.test.js @@ -17,7 +17,7 @@ describe('cap/samples - Local NPM registry', () => { const env = Object.assign(process.env, {PORT:'0'}) const res = await exec (resolve(cwd, '.registry/server.js'), {cwd, stdio: 'pipe', env}) registry = res.cp - axios = require('axios').default.create ({ baseURL: res.url, validateStatus: (status)=>status<500 }) + axios = require('axios').create ({ baseURL: res.url, validateStatus: (status)=>status<500 }) }) after(() => { registry.kill() })