From 2536f36596ae333db75f947d1bef32000bef2214 Mon Sep 17 00:00:00 2001 From: Daniel Date: Tue, 13 Apr 2021 09:53:52 +0200 Subject: [PATCH 1/3] Adjust to latest capire docs --- bookshop/srv/cat-service.cds | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/bookshop/srv/cat-service.cds b/bookshop/srv/cat-service.cds index f6fb00cd..4cc44dff 100644 --- a/bookshop/srv/cat-service.cds +++ b/bookshop/srv/cat-service.cds @@ -1,13 +1,15 @@ using { sap.capire.bookshop as my } from '../db/schema'; service CatalogService @(path:'/browse') { - @readonly entity Books as SELECT from my.Books { *, + /** For displaying lists of Books */ + @readonly entity ListOfBooks as projection on Books + excluding { descr }; + + /** For display in details pages */ + @readonly entity Books as projection on my.Books { *, author.name as author } excluding { createdBy, modifiedBy }; - @readonly entity ListOfBooks as SELECT from Books - excluding { descr }; - @requires: 'authenticated-user' action submitOrder ( book: Books:ID, amount: Integer ) returns { stock: Integer }; event OrderedBook : { book: Books:ID; amount: Integer; buyer: String }; From 9b9bb4c114e8690113e59a85ee2197de487d66d9 Mon Sep 17 00:00:00 2001 From: Daniel Date: Sat, 24 Apr 2021 17:14:23 +0200 Subject: [PATCH 2/3] No process.chdir --- .registry/server.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.registry/server.js b/.registry/server.js index 58f99113..2696d948 100644 --- a/.registry/server.js +++ b/.registry/server.js @@ -5,7 +5,7 @@ const app = express() const { PORT=4444 } = process.env const [,,port=PORT] = process.argv -process.chdir(__dirname) +const cwd = __dirname app.use('/-/:tarball', (req,res,next) => { console.debug ('GET', req.params) @@ -13,7 +13,7 @@ app.use('/-/:tarball', (req,res,next) => { const { tarball } = req.params const [, pkg ] = /^capire-(\w+)/.exec(tarball) fs.lstat(tarball,(err => { - if (err) exec(`npm pack ../${pkg}`,next) + if (err) exec(`npm pack ../${pkg}`,{cwd},next) else next() })) } catch (e) { From 1cb169e8862ac9125e12bb48848fe498aeb9680e Mon Sep 17 00:00:00 2001 From: Daniel Date: Tue, 27 Apr 2021 16:06:59 +0200 Subject: [PATCH 3/3] fixed indentation --- test/cds.ql.test.js | 110 ++++++++++++++++++++++---------------------- 1 file changed, 55 insertions(+), 55 deletions(-) diff --git a/test/cds.ql.test.js b/test/cds.ql.test.js index dfade6b0..3f070111 100644 --- a/test/cds.ql.test.js +++ b/test/cds.ql.test.js @@ -152,69 +152,69 @@ describe('cds.ql → cqn', () => { expect(CQL`SELECT *,a,b from Foo`).to.eql(CQL`SELECT from Foo{*,a,b}`) //> .to.eql... FIXME: see skipped 'should handle * correctly' below expect(SELECT.from(Foo, ['a', 'b', '*'])) - .to.eql(SELECT.from(Foo).columns('a', 'b', '*')) - .to.eql(SELECT.from(Foo).columns(['a', 'b', '*'])) - .to.eql( - SELECT.from(Foo, (foo) => { - foo.a, foo.b, foo('*') - }) - ) - .to.eql({ - SELECT: { - from: { ref: ['Foo'] }, - columns: [{ ref: ['a'] }, { ref: ['b'] }, cdr ? '*' : { ref: ['*'] }], - }, + .to.eql(SELECT.from(Foo).columns('a', 'b', '*')) + .to.eql(SELECT.from(Foo).columns(['a', 'b', '*'])) + .to.eql( + SELECT.from(Foo, (foo) => { + foo.a, foo.b, foo('*') }) + ) + .to.eql({ + SELECT: { + from: { ref: ['Foo'] }, + columns: [{ ref: ['a'] }, { ref: ['b'] }, cdr ? '*' : { ref: ['*'] }], + }, }) + }) - test('from ( ..., => _.expand ( x=>{...}))', () => { - // SELECT from Foo { *, x, bar.*, car{*}, boo { *, moo.zoo } } - expect( - SELECT.from(Foo, (foo) => { - foo('*'), - foo.x, - foo.car('*'), - foo.boo((b) => { - b('*'), b.moo.zoo((x) => x.y.z) - }) - }) - ).to.eql({ - SELECT: { - from: { ref: ['Foo'] }, - columns: [ - cdr ? '*' : { ref: ['*'] }, - { ref: ['x'] }, - { ref: ['car'], expand: ['*'] }, - { - ref: ['boo'], - expand: ['*', { ref: ['moo', 'zoo'], expand: [{ ref: ['y', 'z'] }] }], - }, - ], - }, + test('from ( ..., => _.expand ( x=>{...}))', () => { + // SELECT from Foo { *, x, bar.*, car{*}, boo { *, moo.zoo } } + expect( + SELECT.from(Foo, (foo) => { + foo('*'), + foo.x, + foo.car('*'), + foo.boo((b) => { + b('*'), b.moo.zoo((x) => x.y.z) + }) }) + ).to.eql({ + SELECT: { + from: { ref: ['Foo'] }, + columns: [ + cdr ? '*' : { ref: ['*'] }, + { ref: ['x'] }, + { ref: ['car'], expand: ['*'] }, + { + ref: ['boo'], + expand: ['*', { ref: ['moo', 'zoo'], expand: [{ ref: ['y', 'z'] }] }], + }, + ], + }, }) + }) - test('from ( ..., => _.inline ( _=>{...}))', () => { - // SELECT from Foo { *, x, bar.*, car{*}, boo { *, moo.zoo } } - expect( - SELECT.from(Foo, (foo) => { - foo.bar('*'), - foo.bar('.*'), //> leading dot indicates inline - foo.boo((x) => x.moo.zoo), - foo.boo((_) => _.moo.zoo) //> underscore arg name indicates inline - }) - ).to.eql({ - SELECT: { - from: { ref: ['Foo'] }, - columns: [ - { ref: ['bar'], expand: ['*'] }, - { ref: ['bar'], inline: ['*'] }, - { ref: ['boo'], expand: [{ ref: ['moo', 'zoo'] }] }, - { ref: ['boo'], inline: [{ ref: ['moo', 'zoo'] }] }, - ], - }, + test('from ( ..., => _.inline ( _=>{...}))', () => { + // SELECT from Foo { *, x, bar.*, car{*}, boo { *, moo.zoo } } + expect( + SELECT.from(Foo, (foo) => { + foo.bar('*'), + foo.bar('.*'), //> leading dot indicates inline + foo.boo((x) => x.moo.zoo), + foo.boo((_) => _.moo.zoo) //> underscore arg name indicates inline }) + ).to.eql({ + SELECT: { + from: { ref: ['Foo'] }, + columns: [ + { ref: ['bar'], expand: ['*'] }, + { ref: ['bar'], inline: ['*'] }, + { ref: ['boo'], expand: [{ ref: ['moo', 'zoo'] }] }, + { ref: ['boo'], inline: [{ ref: ['moo', 'zoo'] }] }, + ], + }, }) + }) test('one / distinct ...', () => { expect(SELECT.distinct.from(Foo).SELECT)