Skip to content

Commit

Permalink
Merge branch 'main' into deprecating-lazify
Browse files Browse the repository at this point in the history
  • Loading branch information
daogrady authored Oct 14, 2024
2 parents 466cc32 + aa0f1ec commit b0ca7e5
Show file tree
Hide file tree
Showing 8 changed files with 211 additions and 127 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,18 @@ 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
- `cds.requires` types for MTX services
- `cds.utils.colors` types
- The CQL methods `.where` and `.having` now suggest property names for certain overloads.
- `Service.before/on/after(event, target...)` now accept also an array of typer-generated classes in the `target` parameter

### Changed
- Most `cds.requires` entries are now optionals.
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
18 changes: 9 additions & 9 deletions apis/services.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,8 @@ export class Service extends QueryAPI {
// Provider API
prepend (fn: ServiceImpl): this

on<T extends ArrayConstructable>(eve: types.event, entity: T, handler: CRUDEventHandler.On<Unwrap<T>>): this
on<T extends Constructable>(eve: types.event, entity: T, handler: CRUDEventHandler.On<InstanceType<T>>): this
on<T extends ArrayConstructable>(eve: types.event, entity: T | T[], handler: CRUDEventHandler.On<Unwrap<T>>): this
on<T extends Constructable>(eve: types.event, entity: T | T[], handler: CRUDEventHandler.On<InstanceType<T>>): this
on<F extends CdsFunction>(boundAction: F, service: string, handler: ActionEventHandler<F['__parameters'], void | Error | F['__returns']>): this
on<F extends CdsFunction>(unboundAction: F, handler: ActionEventHandler<F['__parameters'], void | Error | F['__returns']>): this
on (eve: types.event, entity: types.target, handler: OnEventHandler): this
Expand All @@ -239,8 +239,8 @@ export class Service extends QueryAPI {
// onFailed (eve: types.Events, handler: types.EventHandler): this
before<F extends CdsFunction>(boundAction: F, service: string, handler: CRUDEventHandler.Before<F['__parameters'], void | Error | F['__returns']>): this
before<F extends CdsFunction>(unboundAction: F, handler: CRUDEventHandler.Before<F['__parameters'], void | Error | F['__returns']>): this
before<T extends ArrayConstructable>(eve: types.event, entity: T, handler: CRUDEventHandler.Before<Unwrap<T>>): this
before<T extends Constructable>(eve: types.event, entity: T, handler: CRUDEventHandler.Before<InstanceType<T>>): this
before<T extends ArrayConstructable>(eve: types.event, entity: T | T[], handler: CRUDEventHandler.Before<Unwrap<T>>): this
before<T extends Constructable>(eve: types.event, entity: T | T[], handler: CRUDEventHandler.Before<InstanceType<T>>): this
before (eve: types.event, entity: types.target, handler: EventHandler): this
before (eve: types.event, handler: EventHandler): this

Expand All @@ -249,11 +249,11 @@ export class Service extends QueryAPI {
// (3) check if T is scalar -> use T directly
// this streamlines that in _most_ cases, handlers will receive a single object.
// _Except_ for after.read handlers (1), which will change its inflection based on T.
after<T extends ArrayConstructable>(event: 'READ', entity: T, handler: CRUDEventHandler.After<InstanceType<T>>): this
after<T extends ArrayConstructable>(event: 'each', entity: T, handler: CRUDEventHandler.After<Unwrap<T>>): this
after<T extends Constructable>(event: 'READ' | 'each', entity: T, handler: CRUDEventHandler.After<InstanceType<T>>): this
after<T extends ArrayConstructable>(eve: types.event, entity: T, handler: CRUDEventHandler.After<Unwrap<T>>): this
after<T extends Constructable>(eve: types.event, entity: T, handler: CRUDEventHandler.After<InstanceType<T>>): this
after<T extends ArrayConstructable>(event: 'READ', entity: T | T[], handler: CRUDEventHandler.After<InstanceType<T>>): this
after<T extends ArrayConstructable>(event: 'each', entity: T | T[], handler: CRUDEventHandler.After<Unwrap<T>>): this
after<T extends Constructable>(event: 'READ' | 'each', entity: T | T[], handler: CRUDEventHandler.After<InstanceType<T>>): this
after<T extends ArrayConstructable>(eve: types.event, entity: T | T[], handler: CRUDEventHandler.After<Unwrap<T>>): this
after<T extends Constructable>(eve: types.event, entity: T | T[], handler: CRUDEventHandler.After<InstanceType<T>>): this
after<F extends CdsFunction>(boundAction: F, service: string, handler: CRUDEventHandler.After<F['__parameters'], void | Error | F['__returns']>): this
after<F extends CdsFunction>(unboundAction: F, handler: CRUDEventHandler.After<F['__parameters'], void | Error | F['__returns']>): this
after (eve: types.event, entity: types.target, handler: ResultsHandler): this
Expand Down
Loading

0 comments on commit b0ca7e5

Please sign in to comment.