@sap/cds 7.4.2 → 7.5.1

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 (115) hide show
  1. package/CHANGELOG.md +100 -0
  2. package/apis/cds.d.ts +1 -38
  3. package/apis/core.d.ts +21 -101
  4. package/apis/cqn.d.ts +18 -76
  5. package/apis/csn.d.ts +18 -114
  6. package/apis/events.d.ts +16 -123
  7. package/apis/internal/inference.d.ts +18 -32
  8. package/apis/linked.d.ts +18 -97
  9. package/apis/log.d.ts +19 -164
  10. package/apis/models.d.ts +18 -180
  11. package/apis/ql.d.ts +16 -323
  12. package/apis/reflect.d.ts +32 -0
  13. package/apis/server.d.ts +18 -135
  14. package/apis/services.d.ts +18 -380
  15. package/bin/cds-serve.js +5 -2
  16. package/bin/serve.js +7 -16
  17. package/lib/auth/basic-auth.js +3 -1
  18. package/lib/auth/ias-auth.js +62 -48
  19. package/lib/auth/ias-claims.js +34 -0
  20. package/lib/auth/index.js +55 -33
  21. package/lib/auth/jwt-auth.js +55 -52
  22. package/lib/compile/cdsc.js +2 -2
  23. package/lib/compile/to/edm.js +4 -4
  24. package/lib/compile/to/hdbtabledata.js +5 -8
  25. package/lib/compile/to/srvinfo.js +2 -2
  26. package/lib/env/cds-env.js +3 -9
  27. package/lib/env/cds-requires.js +16 -17
  28. package/lib/env/compat.js +0 -9
  29. package/lib/env/defaults.js +17 -6
  30. package/lib/i18n/localize.js +46 -42
  31. package/lib/index.js +6 -8
  32. package/lib/linked/classes.js +7 -118
  33. package/lib/linked/entities.js +1 -1
  34. package/lib/log/cds-log.js +15 -10
  35. package/lib/log/format/aspects/als.js +41 -0
  36. package/lib/log/format/aspects/cf.js +36 -0
  37. package/lib/log/format/json.js +96 -0
  38. package/lib/plugins.js +7 -3
  39. package/lib/req/context.js +4 -2
  40. package/lib/srv/cds-connect.js +3 -5
  41. package/lib/srv/cds-serve.js +13 -26
  42. package/lib/srv/factory.js +3 -3
  43. package/lib/srv/middlewares/index.js +0 -2
  44. package/lib/srv/middlewares/trace.js +2 -3
  45. package/lib/srv/protocols/_legacy.js +27 -30
  46. package/lib/srv/protocols/index.js +173 -58
  47. package/lib/srv/protocols/odata-v4.js +29 -16
  48. package/lib/srv/srv-api.js +8 -13
  49. package/lib/srv/srv-handlers.js +14 -14
  50. package/lib/utils/cds-utils.js +15 -0
  51. package/libx/_runtime/auth/index.js +4 -5
  52. package/libx/_runtime/auth/strategies/basic.js +2 -2
  53. package/libx/_runtime/cds-services/adapter/odata-v4/OData.js +23 -13
  54. package/libx/_runtime/cds-services/adapter/odata-v4/ODataRequest.js +6 -15
  55. package/libx/_runtime/cds-services/adapter/odata-v4/handlers/update.js +10 -3
  56. package/libx/_runtime/cds-services/adapter/odata-v4/to.js +5 -2
  57. package/libx/_runtime/cds-services/adapter/odata-v4/utils/metaInfo.js +2 -1
  58. package/libx/_runtime/cds-services/services/utils/columns.js +3 -9
  59. package/libx/_runtime/cds.js +13 -0
  60. package/libx/_runtime/common/composition/data.js +3 -0
  61. package/libx/_runtime/common/composition/delete.js +1 -1
  62. package/libx/_runtime/common/error/frontend.js +2 -2
  63. package/libx/_runtime/common/generic/auth/readOnly.js +1 -1
  64. package/libx/_runtime/common/generic/auth/restrictions.js +1 -1
  65. package/libx/_runtime/common/generic/sorting.js +4 -5
  66. package/libx/_runtime/common/utils/csn.js +23 -18
  67. package/libx/_runtime/common/utils/restrictions.js +6 -15
  68. package/libx/_runtime/db/generic/input.js +3 -2
  69. package/libx/_runtime/fiori/generic/readOverDraft.js +2 -5
  70. package/libx/_runtime/fiori/lean-draft.js +69 -5
  71. package/libx/_runtime/hana/Service.js +1 -1
  72. package/libx/_runtime/messaging/AMQPWebhookMessaging.js +1 -1
  73. package/libx/_runtime/messaging/Outbox.js +3 -8
  74. package/libx/_runtime/messaging/enterprise-messaging-utils/registerEndpoints.js +1 -0
  75. package/libx/_runtime/messaging/enterprise-messaging.js +1 -1
  76. package/libx/_runtime/messaging/file-based.js +1 -1
  77. package/libx/_runtime/messaging/service.js +7 -10
  78. package/libx/_runtime/remote/Service.js +15 -45
  79. package/libx/_runtime/remote/utils/client.js +20 -33
  80. package/libx/_runtime/remote/utils/cloudSdkProvider.js +30 -0
  81. package/libx/_runtime/sqlite/Service.js +2 -2
  82. package/libx/odata/afterburner.js +29 -21
  83. package/libx/odata/cqn2odata.js +1 -1
  84. package/libx/odata/error.js +7 -0
  85. package/libx/odata/grammar.peggy +16 -20
  86. package/libx/odata/metadata.js +73 -78
  87. package/libx/odata/parser.js +1 -1
  88. package/libx/odata/read.js +94 -0
  89. package/libx/odata/result.js +91 -0
  90. package/libx/odata/service-document.js +31 -37
  91. package/libx/odata/utils.js +2 -1
  92. package/libx/outbox/index.js +9 -4
  93. package/libx/rest/RestAdapter.js +68 -67
  94. package/libx/rest/middleware/create.js +20 -26
  95. package/libx/rest/middleware/delete.js +5 -3
  96. package/libx/rest/middleware/error.js +2 -3
  97. package/libx/rest/middleware/input.js +5 -5
  98. package/libx/rest/middleware/operation.js +96 -41
  99. package/libx/rest/middleware/parse.js +4 -6
  100. package/libx/rest/middleware/payload.js +5 -5
  101. package/libx/rest/middleware/read.js +11 -17
  102. package/libx/rest/middleware/update.js +20 -25
  103. package/package.json +2 -1
  104. package/server.js +7 -4
  105. package/srv/outbox.cds +9 -10
  106. package/apis/env.d.ts +0 -25
  107. package/apis/test.d.ts +0 -81
  108. package/apis/utils.d.ts +0 -15
  109. package/lib/auth/passport-basic.js +0 -14
  110. package/lib/auth/passport-digest.js +0 -16
  111. package/lib/env/presets.js +0 -35
  112. package/lib/log/format/cf.js +0 -16
  113. package/lib/log/format/kibana.js +0 -92
  114. package/lib/srv/middlewares/ctx-auth.js +0 -11
  115. package/libx/_runtime/cds-services/adapter/rest/utils/validation-checks.js +0 -119
package/apis/ql.d.ts CHANGED
@@ -1,325 +1,18 @@
1
- import { CSN, Definition, EntityElements } from "./csn"
2
- import * as CQN from "./cqn"
3
- import { Constructable, ArrayConstructable, SingularType } from "./internal/inference"
4
- import { LinkedEntity } from "./linked"
5
-
6
- export type Query = CQN.Query
7
-
8
- export class ConstructedQuery {
9
- then(_resolved:(x:any)=>any, _rejected:(e:Error)=>any) : any
10
- }
11
-
12
- export class cds_ql {
13
- ql:QL<any> & ((context:object) => QL<any>)
14
- }
15
-
16
- export type PK = number | string | object
17
-
18
-
19
- type Primitive = string | number | boolean | Date
20
-
21
- // don't wrap QLExtensions in more QLExtensions (indirection to work around recursive definition)
22
- type QLExtensions<T> = T extends QLExtensions_<any> ? T : QLExtensions_<T>
23
-
24
1
  /**
25
- * QLExtensions are properties that are attached to entities in CQL contexts.
26
- * They are passed down to all properties recursively.
27
- */
28
- type QLExtensions_<T> = {
29
- [Key in keyof T]: QLExtensions<T[Key]>
30
- } & {
31
- /**
32
- * Alias for this attribute.
33
- */
34
- as: (alias: string) => void
35
-
36
- /**
37
- * Accesses any nested attribute based on a [path](https://cap.cloud.sap/cap/docs/java/query-api#path-expressions):
38
- * `X.get('a.b.c.d')`. Note that you will not receive
39
- * proper typing after this call.
40
- * To still have access to typed results, use
41
- * `X.a().b().c().d()` instead.
42
- */
43
- get: (path: string) => any
44
-
45
- // have to exclude undefined from the type, or we'd end up with a distribution of Subqueryable
46
- // over T and undefined, which gives us zero code completion within the callable.
47
- } & Subqueryable<Exclude<T, undefined>>
48
-
49
- /**
50
- * Adds the ability for subqueries to structured properties.
51
- * The final result of each subquery will be the property itself:
52
- * `Book.title` == `Subqueryable<Book>.title()`
2
+ * DO NO LONGER IMPORT THIS FILE
3
+ *
4
+ * Instead use:
5
+ *
6
+ * @example
7
+ * ```
8
+ * import * as cds from '@sap/cds'
9
+ * cds.Request
10
+ * or
11
+ * import { Request } from '@sap/cds'
12
+ * or
13
+ * @type { import('@sap/cds').Request }
14
+ * ```
15
+ *
16
+ * @deprecated
53
17
  */
54
- type Subqueryable<T> =
55
- T extends Primitive ? {}
56
- // composition of many/ association to many
57
- : T extends readonly unknown[] ? {
58
- /**
59
- * @example
60
- * ```js
61
- * SELECT.from(Books, b => b.author)
62
- * ```
63
- * means: "select all books and project each book's author"
64
- *
65
- * whereas
66
- * ```js
67
- * SELECT.from(Books, b => b.author(a => a.ID))
68
- * ```
69
- * means: "select all books, subselect each book's author's ID
70
- *
71
- * Note that you do not need to return anything from these subqueries.
72
- */
73
- (fn: ((a:QLExtensions<T[number]>) => any) | '*'): T[number]
74
- }
75
- // composition of one/ association to one
76
- : {
77
- /**
78
- * @example
79
- * ```js
80
- * SELECT.from(Books, b => b.author)
81
- * ```
82
- * means: "select all books and project each book's author"
83
- *
84
- * whereas
85
- * ```js
86
- * SELECT.from(Books, b => b.author(a => a.ID))
87
- * ```
88
- * means: "select all books, subselect each book's author's ID
89
- *
90
- * Note that you do not need to return anything from these subqueries.
91
- */
92
- (fn: ((a:QLExtensions<T>) => any) | '*'): T
93
- }
94
- ;
95
-
96
-
97
- // Alias for projections
98
- // https://cap.cloud.sap/docs/node.js/cds-ql?q=projection#projection-functions
99
- //export type Projection<T> = (e:T)=>void
100
- export type Projection<T> = (e:QLExtensions<T extends ArrayConstructable ? SingularType<T> : T>)=>void
101
- // Type for query pieces that can either be chained to build more complex queries or
102
- // awaited to materialise the result:
103
- // `Awaitable<SELECT<Book>, Book> = SELECT<Book> & Promise<Book>`
104
- //
105
- // While the benefit is probably not immediately obvious as we don't exactly
106
- // save a lot of typing over explicitly writing `SELECT<Book> & Promise<Book>`,
107
- // it makes the semantics more explicit. Also sets us up for when TypeScript ever
108
- // improves their generics to support:
109
- //
110
- // `Awaitable<T> = T extends unknown<infer I> ? (T & Promise<I>) : never`
111
- // (at the time of writing, infering the first generic parameter of ANY type
112
- // does not seem to be possible.)
113
- export type Awaitable<T, I> = T & Promise<I>
114
-
115
- // all the functionality of an instance of SELECT, but directly callable:
116
- // new SELECT(...).(...) == SELECT(...)
117
- export type StaticSELECT<T> = typeof SELECT
118
- & ((...columns: (T extends ArrayConstructable<any> ? keyof SingularType<T> : keyof T)[]) => SELECT<T>)
119
- & ((...columns:string[]) => SELECT<T>)
120
- & ((columns:string[]) => SELECT<T>)
121
- & (TaggedTemplateQueryPart<SELECT<T>>)
122
- & SELECT_one // as it is not directly quantified, ...
123
- & SELECT_from // ...we should expect both a scalar and a list
124
-
125
- declare class QL<T> {
126
- SELECT : StaticSELECT<T>
127
- INSERT : typeof INSERT
128
- & ((...entries:object[]) => INSERT<any>) & ((entries:object[]) => INSERT<any>)
129
- UPSERT: typeof UPSERT
130
- & ((...entries:object[]) => UPSERT<any>) & ((entries:object[]) => UPSERT<any>)
131
- UPDATE : typeof UPDATE
132
- & typeof UPDATE.entity
133
- DELETE : typeof DELETE
134
- CREATE : typeof CREATE
135
- DROP : typeof DROP
136
- }
137
-
138
- // used as a catch-all type for using tagged template strings: SELECT `foo`. from `bar` etc.
139
- // the resulting signatures are actually not very strongly typed, but they at least accept template strings
140
- // when run in strict mode.
141
- // This signature has to be added to a method as intersection type.
142
- // Defining overloads with it will override preceding signatures and the other way around.
143
- type TaggedTemplateQueryPart<T> = (strings: TemplateStringsArray, ...params: unknown[]) => T
144
-
145
- export class SELECT<T> extends ConstructedQuery {
146
- static one : SELECT_one & { from: SELECT_one }
147
- static distinct : typeof SELECT
148
- static from : SELECT_from
149
- from: SELECT_from & TaggedTemplateQueryPart<this>
150
- & ((entity: Definition | string, primaryKey? : PK, projection? : Projection<unknown>) => this)
151
- byKey (primaryKey? : PK) : this
152
- columns: TaggedTemplateQueryPart<this>
153
- & ((projection: Projection<T>) => this)
154
- & ((...col: (T extends ArrayConstructable<any> ? keyof SingularType<T> : keyof T)[]) => this)
155
- & ((...col:string[]) => this)
156
- where: TaggedTemplateQueryPart<this>
157
- & ((predicate:object) => this)
158
- & ((...expr : any[]) => this)
159
- and: TaggedTemplateQueryPart<this>
160
- & ((predicate:object) => this)
161
- & ((...expr : any[]) => this)
162
- having: TaggedTemplateQueryPart<this>
163
- & ((...expr : string[]) => this)
164
- & ((predicate:object) => this)
165
- groupBy: TaggedTemplateQueryPart<this>
166
- & ((...expr : string[]) => this)
167
- orderBy: TaggedTemplateQueryPart<this>
168
- & ((...expr : string[]) => this)
169
- limit: TaggedTemplateQueryPart<this>
170
- & ((rows : number, offset? : number) => this)
171
- forShareLock () : this
172
- forUpdate ({wait}? : {wait?: number}) : this
173
- alias (as: string) : this
174
-
175
- elements: EntityElements
176
-
177
-
178
- // Not yet public
179
- // fullJoin (other: string, as: string) : this
180
- // leftJoin (other: string, as: string) : this
181
- // rightJoin (other: string, as: string) : this
182
- // innerJoin (other: string, as: string) : this
183
- // join (other: string, as: string, kind?: string) : this
184
- // on : TaggedTemplateQueryPart<this>
185
- // & ((...expr : string[]) => this)
186
- // & ((predicate:object) => this)
187
-
188
- SELECT : CQN.SELECT["SELECT"] & {
189
- forUpdate?: { wait: number }
190
- forShareLock?: { wait: number }
191
- search?: CQN.predicate
192
- count?: boolean
193
- }
194
- }
195
-
196
-
197
- type SELECT_one =
198
- TaggedTemplateQueryPart<Awaitable<SELECT<unknown>, InstanceType<any>>>
199
- &
200
- // calling with class
201
- (<T extends ArrayConstructable<any>>
202
- (entityType: T, projection?: Projection<QLExtensions<SingularType<T>>>)
203
- => Awaitable<SELECT<SingularType<T>>, SingularType<T>>)
204
- &
205
- (<T extends ArrayConstructable<any>>
206
- (entityType: T, primaryKey : PK, projection?: Projection<QLExtensions<SingularType<T>>>)
207
- => Awaitable<SELECT<SingularType<T>>, SingularType<T>>)
208
-
209
- & ((entity: Definition | string, primaryKey? : PK, projection? : Projection<unknown>) => SELECT<any>)
210
- & ((entity: LinkedEntity | string, primaryKey? : PK, projection? : Projection<unknown>) => SELECT<any>)
211
- & (<T> (entity: T[], projection? : Projection<T>) => Awaitable<SELECT<T>, T>)
212
- & (<T> (entity: T[], primaryKey : PK, projection? : Projection<T>) => Awaitable<SELECT<T>, T>)
213
- & (<T> (entity: {new():T}, projection? : Projection<T>) => Awaitable<SELECT<T>, T>)
214
- & (<T> (entity: {new():T}, primaryKey : PK, projection? : Projection<T>) => Awaitable<SELECT<T>, T>)
215
-
216
- type SELECT_from =
217
- // tagged template
218
- TaggedTemplateQueryPart<Awaitable<SELECT<unknown>, InstanceType<any>>>
219
- &
220
- // calling with class
221
- (<T extends ArrayConstructable<any>>
222
- (entityType: T, projection?: Projection<QLExtensions<SingularType<T>>>)
223
- => Awaitable<SELECT<T>, InstanceType<T>>)
224
- &
225
- (<T extends ArrayConstructable<any>>
226
- (entityType: T, primaryKey : PK, projection?: Projection<SingularType<T>>)
227
- => Awaitable<SELECT<SingularType<T>>, InstanceType<SingularType<T>>>) // when specifying a key, we expect a single element as result
228
- // calling with definition
229
- & ((entity: Definition | string, primaryKey? : PK, projection? : Projection<unknown>) => SELECT<any>)
230
- & ((entity: LinkedEntity | string, primaryKey? : PK, projection? : Projection<unknown>) => SELECT<any>)
231
- // calling with concrete list
232
- & (<T> (entity: T[], projection? : Projection<T>) => SELECT<T> & Promise<T[]>)
233
- & (<T> (entity: T[], primaryKey : PK, projection? : Projection<T>) => Awaitable<SELECT<T>, T>)
234
-
235
-
236
- export class INSERT<T> extends ConstructedQuery {
237
- static into : (<T extends ArrayConstructable<any>> (entity:T, entries? : object | object[]) => INSERT<SingularType<T>>)
238
- & (TaggedTemplateQueryPart<INSERT<unknown>>)
239
- & ((entity : Definition | string, entries? : object | object[]) => INSERT<any>)
240
- & ((entity : LinkedEntity | string, entries? : object | object[]) => INSERT<any>)
241
- & (<T> (entity:Constructable<T>, entries? : object | object[]) => INSERT<T>)
242
- & (<T> (entity:T, entries? : T | object | object[]) => INSERT<T>)
243
-
244
- into: (<T extends ArrayConstructable> (entity:T) => this)
245
- & TaggedTemplateQueryPart<this>
246
- & ((entity : Definition | string) => this)
247
- data (block : (e:T)=>void) : this
248
- entries (...entries : object[]) : this
249
- columns (...col: (T extends ArrayConstructable<any> ? keyof SingularType<T> : keyof T)[]) : this
250
- columns (...col: string[]) : this
251
- values (... val: any[]) : this
252
- rows (... row: any[]) : this
253
- as (select: SELECT<T>): this
254
- INSERT : CQN.INSERT["INSERT"]
255
- }
256
-
257
-
258
- export class UPSERT<T> extends ConstructedQuery {
259
- static into : (<T extends ArrayConstructable<any>> (entity:T, entries? : object | object[]) => UPSERT<SingularType<T>>)
260
- & (TaggedTemplateQueryPart<UPSERT<unknown>>)
261
- & ((entity : Definition | string, entries? : object | object[]) => UPSERT<any>)
262
- & ((entity : LinkedEntity | string, entries? : object | object[]) => UPSERT<any>)
263
- & (<T> (entity:Constructable<T>, entries? : object | object[]) => UPSERT<T>)
264
- & (<T> (entity:T, entries? : T | object | object[]) => UPSERT<T>)
265
-
266
- into: (<T extends ArrayConstructable> (entity:T) => this)
267
- & TaggedTemplateQueryPart<this>
268
- & ((entity : Definition | string) => this)
269
- data (block : (e:T)=>void) : this
270
- entries (...entries : object[]) : this
271
- columns (...col: (T extends ArrayConstructable<any> ? keyof SingularType<T> : keyof T)[]) : this
272
- columns (...col: string[]) : this
273
- values (... val: any[]) : this
274
- rows (... row: any[]) : this
275
- UPSERT : CQN.UPSERT["UPSERT"]
276
- }
277
-
278
-
279
-
280
- export class DELETE<T> extends ConstructedQuery {
281
- static from:
282
- TaggedTemplateQueryPart<Awaitable<SELECT<unknown>, InstanceType<any>>>
283
- & ((entity : Definition | string | ArrayConstructable, primaryKey? : PK) => DELETE<any>)
284
- & ((entity : LinkedEntity | string | ArrayConstructable, primaryKey? : PK) => DELETE<any>)
285
- byKey (primaryKey? : PK) : this
286
- where (predicate:object) : this
287
- where (...expr : any[]) : this
288
- and (predicate:object) : this
289
- and (...expr : any[]) : this
290
- DELETE : CQN.DELETE["DELETE"]
291
- }
292
-
293
- export class UPDATE<T> extends ConstructedQuery {
294
- // cds-typer plural
295
- static entity <T extends ArrayConstructable<any>> (entity:T, primaryKey? : PK) : UPDATE<SingularType<T>>
296
-
297
- static entity (entity : Definition | string, primaryKey? : PK) : UPDATE<any>
298
- static entity (entity : LinkedEntity | string, primaryKey? : PK) : UPDATE<any>
299
- static entity <T> (entity:Constructable<T>, primaryKey? : PK) : UPDATE<T>
300
- static entity <T> (entity:T, primaryKey? : PK) : UPDATE<T>
301
- byKey (primaryKey? : PK) : this
302
- // with (block: (e:T)=>void) : this
303
- // set (block: (e:T)=>void) : this
304
- set: TaggedTemplateQueryPart<this>
305
- & ((data:object) => this)
306
- with: TaggedTemplateQueryPart<this>
307
- & ((data:object) => this)
308
- where (predicate:object) : this
309
- where (...expr : any[]) : this
310
- and (predicate:object) : this
311
- and (...expr : any[]) : this
312
- UPDATE : CQN.UPDATE["UPDATE"]
313
- }
314
-
315
- export class CREATE<T> extends ConstructedQuery {
316
- static entity (entity : Definition | string) : CREATE<any>
317
- static entity (entity : LinkedEntity | string) : CREATE<any>
318
- CREATE : CQN.CREATE["CREATE"]
319
- }
320
-
321
- export class DROP<T> extends ConstructedQuery {
322
- static entity (entity : Definition | string) : DROP<any>
323
- static entity (entity : LinkedEntity | string) : DROP<any>
324
- DROP : CQN.DROP["DROP"]
325
- }
18
+ export * from '@cap-js/cds-types/apis/ql'
@@ -0,0 +1,32 @@
1
+ /**
2
+ * DO NO LONGER IMPORT THIS FILE
3
+ *
4
+ * Instead use:
5
+ *
6
+ * @example
7
+ * ```
8
+ * import * as cds from '@sap/cds'
9
+ * cds.Request
10
+ * or
11
+ * import { Request } from '@sap/cds'
12
+ * or
13
+ * @type { import('@sap/cds').Request }
14
+ * ```
15
+ *
16
+ * @deprecated
17
+ */
18
+ export * from '@cap-js/cds-types/apis/linked'
19
+
20
+ // 'reflect' got removed with 7.4
21
+ // Also, these got removed/renamed in 7.4
22
+ export {
23
+ CSN as ParsedModel,
24
+ Definition,
25
+ entity
26
+ } from '@cap-js/cds-types/apis/csn'
27
+
28
+ export {
29
+ Definitions as ReflectedDefinitions,
30
+ LinkedCSN as LinkedModel,
31
+ LinkedCSN as ReflectedModel,
32
+ } from '@cap-js/cds-types/apis/linked'
package/apis/server.d.ts CHANGED
@@ -1,135 +1,18 @@
1
- import { Service, ServiceImpl } from "./services"
2
- import { CSN } from "./csn"
3
- import * as http from "http"
4
- import { Application } from "express"
5
-
6
- export default class cds {
7
-
8
- connect: {
9
- /**
10
- * Connects to a specific datasource.
11
- * @see [capire](https://cap.cloud.sap/docs/node.js/cds-connect#cds-connect-to)
12
- */
13
- to(datasource: string, options?: cds_connect_options): Promise<Service>
14
-
15
- /**
16
- * Connects to a specific datasource via options.
17
- * @see [capire](https://cap.cloud.sap/docs/node.js/cds-connect#cds-connect-to)
18
- */
19
- to(options: cds_connect_options): Promise<Service>
20
-
21
- /**
22
- * Connects the primary datasource.
23
- * @see [capire](https://cap.cloud.sap/docs/node.js/cds-connect)
24
- */
25
- (options?: string | cds_connect_options): Promise<typeof cds> //> cds.connect(<options>)
26
- }
27
-
28
- /**
29
- * The default bootstrap function as loaded from server.js
30
- */
31
- server: Function
32
-
33
- /**
34
- * Constructs service providers from respective service definitions
35
- * @see [capire](https://cap.cloud.sap/docs/node.js/cds-serve)
36
- */
37
- serve (service : string, options?: {
38
- service?: string,
39
- from?: '*' | 'all' | string,
40
- [key: string]: unknown
41
- }) : Promise<cds_services> & cds_serve_fluent
42
-
43
-
44
- /**
45
- * Emitted whenever a specific service is connected for the first time.
46
- */
47
- on(event: 'connect', listener: (srv: Service) => void): this
48
-
49
-
50
- /**
51
- * Emitted at the very beginning of the bootsrapping process, when the
52
- * express application has been constructed but no middlewares or routes
53
- * added yet.
54
- */
55
- on (event : 'bootstrap', listener : (app : Application) => void) : this
56
- once (event : 'bootstrap', listener : (app : Application) => void) : this
57
-
58
- /**
59
- * Emitted for each service served by cds.serve().
60
- */
61
- on (event : 'serving', listener : (srv : Service) => void) : this
62
-
63
- /**
64
- * Emitted by the default, built-in `server.js` when all services are
65
- * constructed and mounted by cds.serve().
66
- */
67
- on (event : 'served', listener : (all : cds_services) => void) : this
68
- once (event : 'served', listener : (all : cds_services) => void) : this
69
-
70
- /**
71
- * Emitted by the default, built-in `server.js` when the http server
72
- * is started and listening for incoming requests.
73
- */
74
- on (event : 'listening', listener : (args : { server: http.Server, url:string }) => void) : this
75
- once (event : 'listening', listener : (args : { server: http.Server, url:string }) => void) : this
76
-
77
- /**
78
- * Emitted by the default, built-in `server.js` when the http server
79
- * is shutdown.
80
- */
81
- on (event : 'shutdown', listener : () => void) : this
82
- once (event : 'shutdown', listener : () => void) : this
83
-
84
- /**
85
- * Dictionary of all services constructed and/or connected.
86
- */
87
- services : cds_services
88
-
89
- /**
90
- * Shortcut to base class for all service definitions from linked models.
91
- * Plus accessors to impl functions and constructed providers.
92
- */
93
- service : service
94
-
95
- /**
96
- * Provides a graceful shutdown for running servers, by first emitting `cds.emit('shutdown')`.
97
- * @see [capire](https://cap.cloud.sap/docs/node.js/cds-facade#cds-exit)
98
- */
99
- exit(): void
100
-
101
- }
102
-
103
- export type service = {
104
- /**
105
- * Dummy wrapper for service implementation functions.
106
- * Use that in modules to get IntelliSense.
107
- */
108
- impl (impl: ServiceImpl) : typeof impl
109
- // impl <T> (srv:T, impl: ( this: T, srv: (T) ) => any) : typeof impl
110
-
111
- /**
112
- * Array of all services constructed.
113
- */
114
- providers : Service[]
115
- }
116
-
117
-
118
- type cds_services = { [name:string]: Service }
119
-
120
- interface cds_serve_fluent {
121
- from (model : string | CSN) : this
122
- to (protocol: string) : this
123
- at (path: string) : this
124
- in (app: Application) : this
125
- with (impl: ServiceImpl | string) : this
126
- // (req,res) : void
127
- }
128
-
129
- interface cds_connect_options {
130
- impl?: string,
131
- service?: string,
132
- kind?: string,
133
- model?: string,
134
- credentials?: object
135
- }
1
+ /**
2
+ * DO NO LONGER IMPORT THIS FILE
3
+ *
4
+ * Instead use:
5
+ *
6
+ * @example
7
+ * ```
8
+ * import * as cds from '@sap/cds'
9
+ * cds.Request
10
+ * or
11
+ * import { Request } from '@sap/cds'
12
+ * or
13
+ * @type { import('@sap/cds').Request }
14
+ * ```
15
+ *
16
+ * @deprecated
17
+ */
18
+ export * from '@cap-js/cds-types/apis/server'