Skip to content

Commit

Permalink
Merge branch 'main' into feat/ql-select-localized
Browse files Browse the repository at this point in the history
  • Loading branch information
daogrady authored Oct 14, 2024
2 parents d4eb991 + aa0f1ec commit e38faca
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 64 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/).

## Version 0.7.0 - tbd

### Fixed
- Added missing type for `cds.context.model`
- Added missing type for `cds.context.model`
- Added missing type for `req.query.elements`

### Added
- `cds.app` typed as express.js application
- `cds.cli` CLI arguments
Expand Down
7 changes: 5 additions & 2 deletions apis/cqn.d.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import { entity } from './csn' // cyclic dependency
import { Definition, entity } from './csn' // cyclic dependency
import { UnionToIntersection, UnionsToIntersections } from './internal/inference'

// FIXME: a union type would be more appropriate here
export type Query = Partial<SELECT & INSERT & UPDATE & DELETE & CREATE & DROP & UPSERT>
export type Query = {
/** @since 7.4.0 */
elements: { [key: string]: Definition },
} & Partial<SELECT & INSERT & UPDATE & DELETE & CREATE & DROP & UPSERT>

export type SELECT = { SELECT: {
distinct?: true,
Expand Down
4 changes: 3 additions & 1 deletion apis/events.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Definition } from './linked'
import { Definition, LinkedCSN } from './linked'
import { Query } from './cqn'
import { ref } from './cqn'
import * as express from 'express'
Expand All @@ -25,6 +25,8 @@ export class EventContext {

features?: { [key: string]: boolean }

model: LinkedCSN

}

/**
Expand Down
114 changes: 57 additions & 57 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion test/typescript/apis/project/cds-linked.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,4 +103,6 @@ cds.linked.classes.Association === cds.Association
cds.linked.classes.Association === cds.linked.classes.event

// but make sure we can still call .linked(CSN)
const ln: LinkedCSN = cds.linked({})
const ln: LinkedCSN = cds.linked({})

const ln2: LinkedCSN | undefined = cds.context?.model
8 changes: 5 additions & 3 deletions test/typescript/apis/project/cds-services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ await srv.run([query, query])
await srv.run('SELECT * from Authors where name like ?', ['%Poe%'])
await srv.run('SELECT * from Authors where name like :name', { name: '%Poe%' })

srv.foreach({ SELECT: { from: { ref: ['Foo'] } } }, () => {})
srv.foreach({ SELECT: { from: { ref: ['Foo'] } }, elements: {} }, () => {})

await srv.stream({ SELECT: { from: { ref: ['Foo'] } } })
await srv.stream({ SELECT: { from: { ref: ['Foo'] } }, elements: {} })
srv.stream('data').from('T').where({ ID: 1 }).getReader

await srv.emit('UPDATE', {}, {})
Expand Down Expand Up @@ -143,6 +143,8 @@ srv.before('*', Books, req => {
if (req.query.SELECT?.columns?.length ?? 0 > 0) {
console.log("foooooooo")
}

req.query.elements['foo'].type
})
srv.before('*', async req => {
req.event
Expand Down Expand Up @@ -367,7 +369,7 @@ if (myUser instanceof cds.User) {
myUser.id === 'u2'
}

cds.context = { tenant:'t1', user: new cds.User('u2'), locale: 'en_GB', id: 'aaaa', timestamp: new Date() }
cds.context = { tenant:'t1', user: new cds.User('u2'), locale: 'en_GB', id: 'aaaa', timestamp: new Date(), model: ctx!.model }
const tx3 = cds.tx (cds.context)
const db = await cds.connect.to('db')
cds.context.features = {foo: true}
Expand Down

0 comments on commit e38faca

Please sign in to comment.