@cap-js/cds-types 0.15.0 → 0.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/cds-types.d.ts +98 -76
  2. package/package.json +1 -1
@@ -64,13 +64,15 @@ export type __UUID = classes.UUID
64
64
 
65
65
  export type __Vector = classes.Vector
66
66
 
67
- class action extends any_<'action' | 'function'> {}
67
+ class action extends any__2<'action' | 'function'> {}
68
68
 
69
69
  export interface ActionEventHandler<S, P, R> {
70
70
  // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
71
- (req: Omit<Request_2, 'data'> & { data: P, subject: S }, next: Function): Promise<R> | R
71
+ (req: ActionRequest<P, S>, next: Function): Promise<R> | R
72
72
  }
73
73
 
74
+ export type ActionRequest<P, S> = Omit<Request_2, 'data'> & { data: P, subject: S }
75
+
74
76
  interface And {
75
77
  and: TaggedTemplateQueryPart<this>
76
78
  & ((predicate: object) => this)
@@ -88,11 +90,20 @@ export class Anonymous extends User {
88
90
 
89
91
  }
90
92
 
91
- const any: typeof any_;
93
+ const any: typeof any__2;
94
+
95
+ interface any_ {
96
+ kind?: kinds
97
+ /**
98
+ * only available when compiled with docs:true
99
+ * @see [capire docs](https://cap.cloud.sap/docs/cds/cdl#comments)
100
+ */
101
+ doc?: string
102
+ }
92
103
 
93
- interface any_ extends csn.any_ {}
104
+ interface any__2 extends csn.any_ {}
94
105
 
95
- class any_<K extends kinds = kinds> {
106
+ class any__2<K extends kinds = kinds> {
96
107
  private _: K // break covariance
97
108
  constructor (...aspects: any[])
98
109
 
@@ -101,15 +112,6 @@ class any_<K extends kinds = kinds> {
101
112
  // is (kind: kinds | 'Association' | 'Composition'): boolean
102
113
  }
103
114
 
104
- interface any__2 {
105
- kind?: kinds
106
- /**
107
- * only available when compiled with docs:true
108
- * @see [capire docs](https://cap.cloud.sap/docs/cds/cdl#comments)
109
- */
110
- doc?: string
111
- }
112
-
113
115
  /**
114
116
  * The {@link https://expressjs.com/en/4x/api.html#app| express.js application} constructed by the server implementation.
115
117
  *
@@ -343,6 +345,7 @@ namespace cds {
343
345
  CdsFunctions,
344
346
  HandlerFunction,
345
347
  CRUDEventHandler,
348
+ ActionRequest,
346
349
  ActionEventHandler,
347
350
  ResultsHandler,
348
351
  SpawnEvents,
@@ -351,7 +354,6 @@ namespace cds {
351
354
  SpawnOptions,
352
355
  context,
353
356
  tx,
354
- entities,
355
357
  run,
356
358
  foreach,
357
359
  stream,
@@ -361,6 +363,7 @@ namespace cds {
361
363
  update,
362
364
  transaction,
363
365
  db,
366
+ entities,
364
367
  queued,
365
368
  unqueued,
366
369
  outboxed,
@@ -531,6 +534,7 @@ namespace cds_2 {
531
534
  CdsFunctions,
532
535
  HandlerFunction,
533
536
  CRUDEventHandler,
537
+ ActionRequest,
534
538
  ActionEventHandler,
535
539
  ResultsHandler,
536
540
  SpawnEvents,
@@ -539,7 +543,6 @@ namespace cds_2 {
539
543
  SpawnOptions,
540
544
  context,
541
545
  tx,
542
- entities,
543
546
  run,
544
547
  foreach,
545
548
  stream,
@@ -549,6 +552,7 @@ namespace cds_2 {
549
552
  update,
550
553
  transaction,
551
554
  db,
555
+ entities,
552
556
  queued,
553
557
  unqueued,
554
558
  outboxed,
@@ -643,7 +647,7 @@ namespace classes {
643
647
  Column,
644
648
  Definitions,
645
649
  WithElements,
646
- any_,
650
+ any__2 as any_,
647
651
  any,
648
652
  aspect,
649
653
  type,
@@ -870,9 +874,9 @@ export let context: EventContext | undefined;
870
874
 
871
875
  interface context_ extends csn.context {}
872
876
 
873
- class context_ extends any_ { }
877
+ class context_ extends any__2 { }
874
878
 
875
- interface context_2 extends any__2 { }
879
+ interface context_2 extends any_ { }
876
880
 
877
881
  namespace CQN {
878
882
  export {
@@ -972,7 +976,7 @@ namespace csn {
972
976
  Extension,
973
977
  Element,
974
978
  kinds,
975
- any__2 as any_,
979
+ any_,
976
980
  context_2 as context,
977
981
  service_2 as service,
978
982
  type_2 as type,
@@ -1052,12 +1056,12 @@ type DeepPartial<T> = T extends object
1052
1056
  */
1053
1057
  type Definition = context_2 & service_2 & type_2 & struct_2 & entity_2 & Association_2
1054
1058
 
1055
- type Definition_2 = any_
1059
+ type Definition_2 = any__2
1056
1060
 
1057
1061
  /**
1058
1062
  * @see [capire](https://cap.cloud.sap/docs/node.js/cds-reflect#iterable)
1059
1063
  */
1060
- type Definitions<T extends any_ = any_> = IterableMap<T>
1064
+ type Definitions<T extends any__2 = any__2> = IterableMap<T>
1061
1065
 
1062
1066
  const delete_: Service['delete'];
1063
1067
  export { delete_ as delete };
@@ -1106,7 +1110,7 @@ export type EDMX = XML
1106
1110
 
1107
1111
  type Element = type_2 & struct_2 & Association_2
1108
1112
 
1109
- export const entities: Service['entities'];
1113
+ export const entities: linked_2.LinkedCSN['entities'];
1110
1114
 
1111
1115
  /**
1112
1116
  * @see [capire](https://cap.cloud.sap/docs/node.js/cds-reflect#cds-entity)
@@ -1305,11 +1309,11 @@ export namespace env {
1305
1309
  /**
1306
1310
  * @see [capire](https://cap.cloud.sap/docs/node.js/cds-facade#cds-error)
1307
1311
  */
1308
- export function error (code: number, message: string, details?: {stack?: unknown}, caller?: (...args: any[]) => unknown): Error
1312
+ export function error (status: number, message: string, details?: {stack?: unknown}, caller?: (...args: any[]) => unknown): Error
1309
1313
 
1310
- export function error (message: string, details?: {code: number, stack?: unknown}, caller?: (...args: any[]) => unknown): Error
1314
+ export function error (message: string, details?: {status: number, stack?: unknown}, caller?: (...args: any[]) => unknown): Error
1311
1315
 
1312
- export function error (details: {code: number, message: string}, caller?: (...args: any[]) => unknown): Error
1316
+ export function error (details: {status: number, message: string}, caller?: (...args: any[]) => unknown): Error
1313
1317
 
1314
1318
  export function error (string: TemplateStringsArray, ...args: any[]): Error
1315
1319
 
@@ -1408,7 +1412,7 @@ type Extension = {
1408
1412
 
1409
1413
  export type filename = string
1410
1414
 
1411
- type Filter = string | (<T extends any_ = any_>(def: T) => boolean)
1415
+ type Filter = string | (<T extends any__2 = any__2>(def: T) => boolean)
1412
1416
 
1413
1417
  export type _flavor = 'parsed' | 'xtended' | 'inferred'
1414
1418
 
@@ -1763,6 +1767,7 @@ export namespace linked {
1763
1767
  namespace linked_2 {
1764
1768
  export {
1765
1769
  ModelPart,
1770
+ ModelPartFn,
1766
1771
  Definition_2 as Definition,
1767
1772
  LinkedCSN,
1768
1773
  classes
@@ -1781,13 +1786,13 @@ interface LinkedCSN extends Omit<csn.CSN, 'definitions'> {
1781
1786
  * let entities = m.all('entity') //> equivalent shortcut
1782
1787
  * ```
1783
1788
  */
1784
- each<T extends any_>(x: Filter, defs?: Definitions<T>): IterableIterator<T>
1789
+ each<T extends any__2>(x: Filter, defs?: Definitions<T>): IterableIterator<T>
1785
1790
 
1786
1791
  /**
1787
1792
  * Fetches definitions matching the given filter, returning them in an array.
1788
1793
  * Convenience shortcut for `[...reflect.each('entity')]`
1789
1794
  */
1790
- all<T extends any_>(x: Filter, defs?: Definitions<T>): T[]
1795
+ all<T extends any__2>(x: Filter, defs?: Definitions<T>): T[]
1791
1796
 
1792
1797
  /**
1793
1798
  * Fetches definitions matching the given filter, returning the first match, if any.
@@ -1796,7 +1801,7 @@ interface LinkedCSN extends Omit<csn.CSN, 'definitions'> {
1796
1801
  * @param x - the filter
1797
1802
  * @param defs - the definitions to fetch in, default: `this.definitions`
1798
1803
  */
1799
- find<T extends any_>(x: Filter, defs?: Definitions<T>): T | undefined
1804
+ find<T extends any__2>(x: Filter, defs?: Definitions<T>): T | undefined
1800
1805
 
1801
1806
  /**
1802
1807
  * Calls the visitor for each definition matching the given filter.
@@ -1824,7 +1829,7 @@ interface LinkedCSN extends Omit<csn.CSN, 'definitions'> {
1824
1829
  * @param parent - either the parent itself or its fully-qualified name
1825
1830
  * @param filter - an optional filter to apply before picking a child
1826
1831
  */
1827
- childrenOf(parent: any | string, filter?: ((def: any_) => boolean)): Definitions
1832
+ childrenOf(parent: any | string, filter?: ((def: any__2) => boolean)): Definitions
1828
1833
 
1829
1834
  /**
1830
1835
  * Provides convenient access to the model's top-level definitions.
@@ -1842,9 +1847,9 @@ interface LinkedCSN extends Omit<csn.CSN, 'definitions'> {
1842
1847
  * SELECT.from (Books) .where ({ID:11})
1843
1848
  * ```
1844
1849
  */
1845
- exports: IterableMap<any_>
1846
- definitions: IterableMap<any_>
1847
- entities: ModelPart<entity>
1850
+ exports: IterableMap<any__2>
1851
+ definitions: IterableMap<any__2>
1852
+ entities: ModelPartFn<entity>
1848
1853
  services: ModelPart<service_>
1849
1854
 
1850
1855
  }
@@ -2022,6 +2027,7 @@ export type Middlewares = 'context' | 'trace' | 'auth' | 'ctx_model' | string
2022
2027
 
2023
2028
  export const middlewares: {
2024
2029
  add: (middleware: import('express').RequestHandler, pos?: XOR<XOR<{ at: number }, { after: Middlewares }>, { before: Middlewares }>) => void,
2030
+ before: import('express').RequestHandler[],
2025
2031
  };
2026
2032
 
2027
2033
  /**
@@ -2067,7 +2073,12 @@ function mixin (...classes: (new () => any)[]): void
2067
2073
  */
2068
2074
  export let model: linked_2.LinkedCSN | undefined;
2069
2075
 
2070
- type ModelPart<T extends any_> = IterableMap<T> & ((namespace: string) => IterableMap<T>)
2076
+ type ModelPart<T extends any__2> = IterableMap<T> & {
2077
+ /** @deprecated undocumented variant that will be removed in cds^10 */
2078
+ (namespace: string): IterableMap<T>,
2079
+ }
2080
+
2081
+ type ModelPartFn<T extends any__2> = IterableMap<T> & ((namespace: string) => IterableMap<T>)
2071
2082
 
2072
2083
  namespace models {
2073
2084
  export {
@@ -2162,7 +2173,7 @@ export function on (event: 'connect', listener: (srv: Service) => void): _cds
2162
2173
  export function on (event: 'bootstrap', listener: (app: import('express').Application) => void): _cds
2163
2174
 
2164
2175
  /**
2165
- * Emitted before the model is compiled for usage in Node.js or Java runtime.
2176
+ * Emitted the model is compiled for usage in Node.js or Java runtime.
2166
2177
  * @beta
2167
2178
  */
2168
2179
  export function on (event: 'compile.for.runtime', listener: (model: CSN) => void): _cds
@@ -2369,8 +2380,6 @@ type Query_2 = CQN.Query
2369
2380
 
2370
2381
  export class QueryAPI {
2371
2382
 
2372
- entities: linked_2.LinkedCSN['entities']
2373
-
2374
2383
  /**
2375
2384
  * @see [docs](https://cap.cloud.sap/docs/node.js/core-services#crud-style-api)
2376
2385
  */
@@ -2497,6 +2506,18 @@ D = any,
2497
2506
  P extends Record<string, any>[] = Record<string, any>[]
2498
2507
  > extends Event_2<D> {
2499
2508
 
2509
+ messages: {message: string, numericSeverity: levels}[]
2510
+
2511
+ errors: {
2512
+ code?: number,
2513
+ message: string,
2514
+ stack: string,
2515
+ target?: string,
2516
+ args?: unknown[],
2517
+ }[]
2518
+
2519
+ results: D[]
2520
+
2500
2521
  params: P
2501
2522
 
2502
2523
  method: string
@@ -2519,45 +2540,38 @@ P extends Record<string, any>[] = Record<string, any>[]
2519
2540
  /** @beta */
2520
2541
  reply (results: any, options: { mimetype?: string, filename?: string, [key: string]: any }): void
2521
2542
 
2522
- notify (code: number, message: string, target?: string, args?: any[]): Error
2523
-
2524
- info (code: number, message: string, target?: string, args?: any[]): Error
2525
-
2526
- warn (code: number, message: string, target?: string, args?: any[]): Error
2527
-
2528
- error (code: number, message: string, target?: string, args?: any[]): Error
2529
-
2530
- reject (code: number, message: string, target?: string, args?: any[]): never
2531
-
2532
- notify (code: number, message: string, args?: any[]): Error
2533
-
2534
- info (code: number, message: string, args?: any[]): Error
2535
-
2536
- warn (code: number, message: string, args?: any[]): Error
2537
-
2538
- error (code: number, message: string, args?: any[]): Error
2539
-
2540
- reject (code: number, message: string, args?: any[]): never
2541
-
2543
+ // positional args
2542
2544
  notify (message: string, target?: string, args?: any[]): Error
2545
+ notify (status: number, message?: string, target?: string, args?: any[]): Error
2543
2546
 
2544
2547
  info (message: string, target?: string, args?: any[]): Error
2548
+ info (status: number, message?: string, target?: string, args?: any[]): Error
2545
2549
 
2546
2550
  warn (message: string, target?: string, args?: any[]): Error
2551
+ warn (status: number, message?: string, target?: string, args?: any[]): Error
2547
2552
 
2548
2553
  error (message: string, target?: string, args?: any[]): Error
2554
+ error (status: number, message?: string, target?: string, args?: any[]): Error
2555
+ error (status: number, target?: string, args?: any[]): Error
2549
2556
 
2550
2557
  reject (message: string, target?: string, args?: any[]): never
2558
+ reject (status: number, message?: string, target?: string, args?: any[]): never
2551
2559
 
2552
- notify (message: { code?: number | string, message: string, target?: string, args?: any[] }): Error
2560
+ // single object arg
2561
+ notify (message: { status?: number, code?: number | string, message: string, target?: string, args?: any[] }): Error
2562
+ notify (message: { status?: number, code: number | string, message?: string, target?: string, args?: any[] }): Error
2553
2563
 
2554
- info (message: { code?: number | string, message: string, target?: string, args?: any[] }): Error
2564
+ info (message: { status?: number, code?: number | string, message: string, target?: string, args?: any[] }): Error
2565
+ info (message: { status?: number, code: number | string, message?: string, target?: string, args?: any[] }): Error
2555
2566
 
2556
- warn (message: { code?: number | string, message: string, target?: string, args?: any[] }): Error
2567
+ warn (message: { status?: number, code?: number | string, message: string, target?: string, args?: any[] }): Error
2568
+ warn (message: { status?: number, code: number | string, message?: string, target?: string, args?: any[] }): Error
2557
2569
 
2558
- error (message: { code?: number | string, message: string, target?: string, args?: any[], status?: number }): Error
2570
+ error (message: { status?: number, code?: number | string, message: string, target?: string, args?: any[] }): Error
2571
+ error (message: { status?: number, code: number | string, message?: string, target?: string, args?: any[] }): Error
2559
2572
 
2560
- reject (message: { code?: number | string, message: string, target?: string, args?: any[], status?: number }): never
2573
+ reject (message: { status?: number, code?: number | string, message: string, target?: string, args?: any[] }): never
2574
+ reject (message: { status?: number, code: number | string, message?: string, target?: string, args?: any[] }): never
2561
2575
 
2562
2576
  }
2563
2577
  export { Request_2 as Request }
@@ -2653,24 +2667,25 @@ class SELECT_3<T, Q = SELECT_from> extends ConstructedQuery<T> {
2653
2667
  }
2654
2668
 
2655
2669
  /**
2656
- * If a parameter is given, the raw data stream is piped into it.
2657
- *
2658
- * If no parameter is given, the raw data stream is returned.
2670
+ * Pipes the raw data stream into the given writable stream.
2659
2671
  * @param stream the writable stream to pipe the raw data into
2660
2672
  * @see [capire docs](https://cap.cloud.sap/docs/node.js/cds-ql#pipeline)
2661
2673
  * @since 9.3.0
2662
2674
  */
2663
2675
  pipeline(stream: import('node:stream').Writable): Promise<void>
2664
2676
  /**
2665
- * If a parameter is given, the raw data stream is piped into it.
2666
- *
2667
- * If no parameter is given, the raw data stream is returned.
2668
- * @see [capire docs](https://cap.cloud.sap/docs/node.js/cds-ql#pipeline)
2669
- * @since 9.3.0
2670
- * @returns Readable
2677
+ * @deprecated use `.stream()` instead
2671
2678
  */
2672
2679
  pipeline(): Promise<import('node:stream').Readable>
2673
2680
 
2681
+ /**
2682
+ * Returns the raw data stream.
2683
+ * @see [capire docs](https://cap.cloud.sap/docs/node.js/cds-ql#stream)
2684
+ * @since 9.4.0
2685
+ * @returns Readable
2686
+ */
2687
+ stream(): Promise<import('node:stream').Readable>
2688
+
2674
2689
  /**
2675
2690
  * Calls the given callback function for each row in the result set.
2676
2691
  * @param cb the callback function to call for each row
@@ -2812,11 +2827,18 @@ export class Service extends QueryAPI {
2812
2827
  types: linked_2.ModelPart<linked_2.classes.type>
2813
2828
 
2814
2829
  /**
2830
+ * @deprecated use {@link actions} instead
2815
2831
  * Provides access to the operations, i.e. actions and functions, exposed by a service
2816
2832
  * @see [capire docs](https://cap.cloud.sap/docs/node.js/core-services)
2817
2833
  */
2818
2834
  operations: linked_2.ModelPart<linked_2.classes.action>
2819
2835
 
2836
+ /**
2837
+ * Provides access to the actions and functions, exposed by a service
2838
+ * @see [capire docs](https://cap.cloud.sap/docs/node.js/core-services)
2839
+ */
2840
+ actions: linked_2.ModelPart<linked_2.classes.action>
2841
+
2820
2842
  /**
2821
2843
  * Acts like a parameter-less constructor. Ensure to call `await super.init()` to have the base class’s handlers added.
2822
2844
  * You may register own handlers before the base class’s ones, to intercept requests before the default handlers snap in.
@@ -2985,7 +3007,7 @@ class service_ extends context_ {
2985
3007
  get protocols (): { [protocol in Protocol]?: boolean | undefined }
2986
3008
  }
2987
3009
 
2988
- interface service_2 extends any__2 { }
3010
+ interface service_2 extends any_ { }
2989
3011
 
2990
3012
  export interface ServiceImpl {
2991
3013
  (this: Service, srv: Service): any
@@ -3224,9 +3246,9 @@ export interface type extends Omit<csn.type, 'items'> {
3224
3246
  virtual?: boolean
3225
3247
  }
3226
3248
 
3227
- export class type<K extends kinds = 'type'> extends any_<K> { }
3249
+ export class type<K extends kinds = 'type'> extends any__2<K> { }
3228
3250
 
3229
- interface type_2 extends any__2 {
3251
+ interface type_2 extends any_ {
3230
3252
  type?: 'cds.Boolean' |
3231
3253
  'cds.UUID' | 'cds.String' | 'cds.LargeString' | 'cds.Binary' | 'cds.LargeBinary' | 'cds.Vector' |
3232
3254
  'cds.Integer' | 'cds.UInt8' | 'cds.Int16' | 'cds.Int32' | 'cds.Int64' | 'cds.Double' | 'cds.Decimal' |
@@ -3528,7 +3550,7 @@ class Vector extends Binary { }
3528
3550
 
3529
3551
  export const version: string;
3530
3552
 
3531
- type Visitor = (def: any_, name: string, parent: any_, defs: Definitions) => void
3553
+ type Visitor = (def: any__2, name: string, parent: any__2, defs: Definitions) => void
3532
3554
 
3533
3555
  interface Where<T> {
3534
3556
  where: HavingWhere<this, T>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cap-js/cds-types",
3
- "version": "0.15.0",
3
+ "version": "0.16.0",
4
4
  "description": "Type definitions for main packages of CAP, like `@sap/cds`",
5
5
  "repository": "github:cap-js/cds-types",
6
6
  "homepage": "https://cap.cloud.sap/",