@cap-js/cds-types 0.0.1 → 0.1.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.
- package/README.md +2 -2
- package/apis/cds.d.ts +29 -25
- package/apis/core.d.ts +76 -82
- package/apis/cqn.d.ts +11 -0
- package/apis/csn.d.ts +2 -2
- package/apis/env.d.ts +12 -15
- package/apis/events.d.ts +7 -28
- package/apis/linked.d.ts +19 -11
- package/apis/log.d.ts +32 -33
- package/apis/models.d.ts +140 -149
- package/apis/ql.d.ts +0 -3
- package/apis/server.d.ts +34 -26
- package/apis/services.d.ts +66 -43
- package/apis/test.d.ts +19 -13
- package/apis/utils.d.ts +70 -76
- package/package.json +4 -2
package/apis/models.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Query as CQN, expr, _xpr } from "./cqn"
|
|
2
2
|
import { LinkedCSN } from "./linked"
|
|
3
3
|
import { CSN } from "./csn"
|
|
4
|
+
import * as cds from './cds'
|
|
4
5
|
|
|
5
6
|
type _flavor = 'parsed' | 'xtended' | 'inferred'
|
|
6
7
|
type _odata_options = {
|
|
@@ -27,154 +28,144 @@ type EDMX = XML
|
|
|
27
28
|
type filename = string
|
|
28
29
|
|
|
29
30
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
ref (src:string) : string[]
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Provides a set of methods to parse a given model, query or expression.
|
|
55
|
-
* You can also use `cds.compile(csn).to('<output>')` as a fluent variant.
|
|
56
|
-
*/
|
|
57
|
-
compile : {
|
|
58
|
-
/** Shortcut for `cds.compile.to.csn()` */
|
|
59
|
-
cdl (model:CDL, o?:_options) : CSN,
|
|
60
|
-
|
|
61
|
-
for: {
|
|
62
|
-
odata (model:CSN, o?:_options) : CSN
|
|
63
|
-
sql (model:CSN, o?:_options) : CSN
|
|
64
|
-
},
|
|
65
|
-
to: {
|
|
66
|
-
parsed:{
|
|
67
|
-
csn (files:filename[], o?:_options) : Promise<CSN>
|
|
68
|
-
csn (model:CDL, o?:_options) : CSN
|
|
69
|
-
}
|
|
70
|
-
xtended:{
|
|
71
|
-
csn (files:filename[], o?:_options) : Promise<CSN>
|
|
72
|
-
csn (model:CDL, o?:_options) : CSN
|
|
73
|
-
}
|
|
74
|
-
inferred:{
|
|
75
|
-
csn (files:filename[], o?:_options) : Promise<CSN>
|
|
76
|
-
csn (model:CDL, o?:_options) : CSN
|
|
77
|
-
}
|
|
78
|
-
csn (files:filename[], o?:_options) : Promise<CSN>
|
|
79
|
-
csn (model:CDL, o?:_options) : CSN
|
|
80
|
-
yml (model:CSN, o?:_options) : YAML
|
|
81
|
-
yaml (model:CSN, o?:_options) : YAML
|
|
82
|
-
json (model:CSN, o?:_options) : JSON
|
|
83
|
-
sql (model:CSN, o?:_options) : SQL[]
|
|
84
|
-
cdl (model:CSN, o?:_options) : CDL | Iterable<[CDL,{file:filename}]>
|
|
85
|
-
edm (model:CSN, o?:_options|_odata_options) : EDM | string
|
|
86
|
-
edmx (model:CSN, o?:_options|_odata_options) : EDMX | Iterable<[EDMX,{file:filename}]>
|
|
87
|
-
hdbcds (model:CSN, o?:_options) : SQL | Iterable<[SQL,{file:filename}]>
|
|
88
|
-
hdbtable (model:CSN, o?:_options) : SQL | Iterable<[SQL,{file:filename}]>
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
/** Fluent API variant */
|
|
92
|
-
(model: CSN | CDL) : {
|
|
93
|
-
for: {
|
|
94
|
-
odata (o?:_options) : CSN
|
|
95
|
-
sql (o?:_options) : CSN
|
|
96
|
-
},
|
|
97
|
-
to: {
|
|
98
|
-
parsed:{ csn (o?:_options) : CSN }
|
|
99
|
-
xtended:{ csn (o?:_options) : CSN }
|
|
100
|
-
inferred:{ csn (o?:_options) : CSN }
|
|
101
|
-
csn (o?:_options) : CSN
|
|
102
|
-
yml (o?:_options) : YAML
|
|
103
|
-
yaml (o?:_options) : YAML
|
|
104
|
-
json (o?:_options) : JSON
|
|
105
|
-
sql (o?:_options) : SQL[]
|
|
106
|
-
cdl (o?:_options) : CDL | Iterable<[CDL,{file:filename}]>
|
|
107
|
-
edm (o?:_options|_odata_options) : EDM | string
|
|
108
|
-
edmx (o?:_options|_odata_options) : EDMX | Iterable<[EDMX,{file:filename}]>
|
|
109
|
-
hdbcds (o?:_options) : SQL | Iterable<[SQL,{file:filename}]>
|
|
110
|
-
hdbtable (o?:_options) : SQL | Iterable<[SQL,{file:filename}]>
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
/** Async fluent variant reading from files */
|
|
115
|
-
(files: filename[]) : {
|
|
116
|
-
for: {
|
|
117
|
-
odata (o?:_options) : Promise<CSN>
|
|
118
|
-
sql (o?:_options) : Promise<CSN>
|
|
119
|
-
},
|
|
120
|
-
to: {
|
|
121
|
-
parsed:{ csn (o?:_options) : Promise <CSN> }
|
|
122
|
-
xtended:{ csn (o?:_options) : Promise <CSN> }
|
|
123
|
-
inferred:{ csn (o?:_options) : Promise <CSN> }
|
|
124
|
-
csn (o?:_options) : Promise <CSN>
|
|
125
|
-
yml (o?:_options) : Promise <YAML>
|
|
126
|
-
yaml (o?:_options) : Promise <YAML>
|
|
127
|
-
json (o?:_options) : Promise <JSON>
|
|
128
|
-
sql (o?:_options) : Promise <SQL[]>
|
|
129
|
-
cdl (o?:_options) : Promise <CDL | Iterable<[CDL,{file:filename}]>>
|
|
130
|
-
edm (o?:_options|_odata_options) : Promise <EDM | string>
|
|
131
|
-
edmx (o?:_options|_odata_options) : Promise <EDMX | Iterable<[EDMX,{file:filename}]>>
|
|
132
|
-
hdbcds (o?:_options) : Promise <SQL | Iterable<[SQL,{file:filename}]>>
|
|
133
|
-
hdbtable (o?:_options) : Promise <SQL | Iterable<[SQL,{file:filename}]>>
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
/**
|
|
139
|
-
* Loads and parses models from the specified files.
|
|
140
|
-
* Uses `cds.resolve` to fetch the respective models.
|
|
141
|
-
* Essentially a shortcut for `cds.compile.to.csn(files)`
|
|
142
|
-
* @param {string} files - filenames of models or if folder containing models
|
|
143
|
-
*/
|
|
144
|
-
get(files: '*' | filename | filename[], o?:_options) : Promise<CSN>
|
|
145
|
-
|
|
146
|
-
/**
|
|
147
|
-
* Shortcut for `cds.get(files, 'inferred')`
|
|
148
|
-
* @param {string} files - filenames of models or if folder containing models
|
|
149
|
-
*/
|
|
150
|
-
load(files: '*' | filename | filename[], o?:_options) : Promise<CSN>
|
|
151
|
-
|
|
152
|
-
/**
|
|
153
|
-
* Emitted whenever a model is loaded using cds.load().
|
|
154
|
-
*/
|
|
155
|
-
on (event : 'loaded', listener : (model : CSN) => void) : this
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
/**
|
|
159
|
-
* Resolves given file or module name(s) to an array of absolute file names.
|
|
160
|
-
* Uses Node's `require.resolve` internally with the following additions:
|
|
161
|
-
* - relative names are resolved relative to the current working directory instead of the current JavaScript module; hence, use __dirname if you want to find or load models relative to the current module.
|
|
162
|
-
* - if no file extension is given, `.csn` and `.cds` will be appended in that order.
|
|
163
|
-
* @param files - The file or module name(s) of a model or a folder containing models. Specify `'*'` to fetch moels from default locations, i.e. `[ 'db/', 'srv/', 'app/' ]`
|
|
164
|
-
* @returns An array of absolute file names or `undefined` if none could be resolved.
|
|
165
|
-
*/
|
|
166
|
-
resolve (files: '*' | filename | filename[]) : filename[] | undefined
|
|
167
|
-
|
|
168
|
-
/**
|
|
169
|
-
* Turns the given plain CSN model into a linked model
|
|
170
|
-
* @see [capire](https://cap.cloud.sap/docs/node.js/cds-reflect)
|
|
171
|
-
*/
|
|
172
|
-
linked(model: CSN): LinkedCSN
|
|
173
|
-
|
|
174
|
-
/**
|
|
175
|
-
* Turns the given plain CSN model into a reflected model
|
|
176
|
-
* @see [capire](https://cap.cloud.sap/docs/node.js/cds-reflect)
|
|
177
|
-
*/
|
|
178
|
-
reflect(model: CSN): LinkedCSN
|
|
31
|
+
/**
|
|
32
|
+
* The effective CDS model loaded during bootstrapping, which contains all service and entity definitions,
|
|
33
|
+
* including required services.
|
|
34
|
+
*/
|
|
35
|
+
export const model : LinkedCSN | undefined // was ?: LinkedCSN
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Provides a set of methods to parse a given model, query or expression.
|
|
39
|
+
* You can also use `cds.parse()` as a shortcut to `cds.parse.cdl()`.
|
|
40
|
+
*/
|
|
41
|
+
export const parse : {
|
|
42
|
+
/** Shortcut to `cds.parse.cdl()` */
|
|
43
|
+
(cdl:CDL) : CSN
|
|
44
|
+
cdl (cdl:CDL) : CSN
|
|
45
|
+
cql (src:string) : CQN
|
|
46
|
+
expr (src:string) : expr
|
|
47
|
+
xpr (src:string) : _xpr
|
|
48
|
+
ref (src:string) : string[]
|
|
49
|
+
}
|
|
179
50
|
|
|
51
|
+
/**
|
|
52
|
+
* Loads and parses models from the specified files.
|
|
53
|
+
* Uses `cds.resolve` to fetch the respective models.
|
|
54
|
+
* Essentially a shortcut for `cds.compile.to.csn(files)`
|
|
55
|
+
* @param files - filenames of models or if folder containing models
|
|
56
|
+
*/
|
|
57
|
+
export function get (files: '*' | filename | filename[], o?:_options): Promise<CSN>
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Shortcut for `cds.get(files, 'inferred')`
|
|
61
|
+
* @param files - filenames of models or if folder containing models
|
|
62
|
+
*/
|
|
63
|
+
export function load (files: '*' | filename | filename[], o?:_options): Promise<CSN>
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Resolves given file or module name(s) to an array of absolute file names.
|
|
68
|
+
* Uses Node's `require.resolve` internally with the following additions:
|
|
69
|
+
* - relative names are resolved relative to the current working directory instead of the current JavaScript module; hence, use __dirname if you want to find or load models relative to the current module.
|
|
70
|
+
* - if no file extension is given, `.csn` and `.cds` will be appended in that order.
|
|
71
|
+
* @param files - The file or module name(s) of a model or a folder containing models. Specify `'*'` to fetch moels from default locations, i.e. `[ 'db/', 'srv/', 'app/' ]`
|
|
72
|
+
* @returns An array of absolute file names or `undefined` if none could be resolved.
|
|
73
|
+
*/
|
|
74
|
+
export function resolve (files: '*' | filename | filename[]): filename[] | undefined
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Turns the given plain CSN model into a linked model
|
|
78
|
+
* @see [capire](https://cap.cloud.sap/docs/node.js/cds-reflect)
|
|
79
|
+
*/
|
|
80
|
+
declare const linked: (model: CSN) => LinkedCSN
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Turns the given plain CSN model into a reflected model
|
|
84
|
+
* @see [capire](https://cap.cloud.sap/docs/node.js/cds-reflect)
|
|
85
|
+
*/
|
|
86
|
+
export const reflect: (model: CSN) => LinkedCSN
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Provides a set of methods to parse a given model, query or expression.
|
|
90
|
+
* You can also use `cds.compile(csn).to('<output>')` as a fluent variant.
|
|
91
|
+
*/
|
|
92
|
+
export const compile: {
|
|
93
|
+
/** Shortcut for `cds.compile.to.csn()` */
|
|
94
|
+
cdl (model:CDL, o?:_options) : CSN,
|
|
95
|
+
|
|
96
|
+
for: {
|
|
97
|
+
odata (model:CSN, o?:_options) : CSN
|
|
98
|
+
sql (model:CSN, o?:_options) : CSN
|
|
99
|
+
},
|
|
100
|
+
to: {
|
|
101
|
+
parsed:{
|
|
102
|
+
csn (files:filename[], o?:_options) : Promise<CSN>
|
|
103
|
+
csn (model:CDL, o?:_options) : CSN
|
|
104
|
+
}
|
|
105
|
+
xtended:{
|
|
106
|
+
csn (files:filename[], o?:_options) : Promise<CSN>
|
|
107
|
+
csn (model:CDL, o?:_options) : CSN
|
|
108
|
+
}
|
|
109
|
+
inferred:{
|
|
110
|
+
csn (files:filename[], o?:_options) : Promise<CSN>
|
|
111
|
+
csn (model:CDL, o?:_options) : CSN
|
|
112
|
+
}
|
|
113
|
+
csn (files:filename[], o?:_options) : Promise<CSN>
|
|
114
|
+
csn (model:CDL, o?:_options) : CSN
|
|
115
|
+
yml (model:CSN, o?:_options) : YAML
|
|
116
|
+
yaml (model:CSN, o?:_options) : YAML
|
|
117
|
+
json (model:CSN, o?:_options) : JSON
|
|
118
|
+
sql (model:CSN, o?:_options) : SQL[]
|
|
119
|
+
cdl (model:CSN, o?:_options) : CDL | Iterable<[CDL,{file:filename}]>
|
|
120
|
+
edm (model:CSN, o?:_options|_odata_options) : EDM | string
|
|
121
|
+
edmx (model:CSN, o?:_options|_odata_options) : EDMX | Iterable<[EDMX,{file:filename}]>
|
|
122
|
+
hdbcds (model:CSN, o?:_options) : SQL | Iterable<[SQL,{file:filename}]>
|
|
123
|
+
hdbtable (model:CSN, o?:_options) : SQL | Iterable<[SQL,{file:filename}]>
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/** Fluent API variant */
|
|
127
|
+
(model: CSN | CDL) : {
|
|
128
|
+
for: {
|
|
129
|
+
odata (o?:_options) : CSN
|
|
130
|
+
sql (o?:_options) : CSN
|
|
131
|
+
},
|
|
132
|
+
to: {
|
|
133
|
+
parsed:{ csn (o?:_options) : CSN }
|
|
134
|
+
xtended:{ csn (o?:_options) : CSN }
|
|
135
|
+
inferred:{ csn (o?:_options) : CSN }
|
|
136
|
+
csn (o?:_options) : CSN
|
|
137
|
+
yml (o?:_options) : YAML
|
|
138
|
+
yaml (o?:_options) : YAML
|
|
139
|
+
json (o?:_options) : JSON
|
|
140
|
+
sql (o?:_options) : SQL[]
|
|
141
|
+
cdl (o?:_options) : CDL | Iterable<[CDL,{file:filename}]>
|
|
142
|
+
edm (o?:_options|_odata_options) : EDM | string
|
|
143
|
+
edmx (o?:_options|_odata_options) : EDMX | Iterable<[EDMX,{file:filename}]>
|
|
144
|
+
hdbcds (o?:_options) : SQL | Iterable<[SQL,{file:filename}]>
|
|
145
|
+
hdbtable (o?:_options) : SQL | Iterable<[SQL,{file:filename}]>
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/** Async fluent variant reading from files */
|
|
150
|
+
(files: filename[]) : {
|
|
151
|
+
for: {
|
|
152
|
+
odata (o?:_options) : Promise<CSN>
|
|
153
|
+
sql (o?:_options) : Promise<CSN>
|
|
154
|
+
},
|
|
155
|
+
to: {
|
|
156
|
+
parsed:{ csn (o?:_options) : Promise <CSN> }
|
|
157
|
+
xtended:{ csn (o?:_options) : Promise <CSN> }
|
|
158
|
+
inferred:{ csn (o?:_options) : Promise <CSN> }
|
|
159
|
+
csn (o?:_options) : Promise <CSN>
|
|
160
|
+
yml (o?:_options) : Promise <YAML>
|
|
161
|
+
yaml (o?:_options) : Promise <YAML>
|
|
162
|
+
json (o?:_options) : Promise <JSON>
|
|
163
|
+
sql (o?:_options) : Promise <SQL[]>
|
|
164
|
+
cdl (o?:_options) : Promise <CDL | Iterable<[CDL,{file:filename}]>>
|
|
165
|
+
edm (o?:_options|_odata_options) : Promise <EDM | string>
|
|
166
|
+
edmx (o?:_options|_odata_options) : Promise <EDMX | Iterable<[EDMX,{file:filename}]>>
|
|
167
|
+
hdbcds (o?:_options) : Promise <SQL | Iterable<[SQL,{file:filename}]>>
|
|
168
|
+
hdbtable (o?:_options) : Promise <SQL | Iterable<[SQL,{file:filename}]>>
|
|
169
|
+
}
|
|
170
|
+
}
|
|
180
171
|
}
|
package/apis/ql.d.ts
CHANGED
package/apis/server.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { Service, ServiceImpl } from "./services"
|
|
2
2
|
import { CSN } from "./csn"
|
|
3
3
|
import * as http from "http"
|
|
4
|
+
import * as cds from './cds'
|
|
4
5
|
import { Application } from "express"
|
|
5
6
|
|
|
6
|
-
|
|
7
|
+
type _cds = typeof cds
|
|
7
8
|
|
|
8
|
-
connect: {
|
|
9
|
+
export const connect: {
|
|
9
10
|
/**
|
|
10
11
|
* Connects to a specific datasource.
|
|
11
12
|
* @see [capire](https://cap.cloud.sap/docs/node.js/cds-connect#cds-connect-to)
|
|
@@ -22,29 +23,36 @@ export default class cds {
|
|
|
22
23
|
* Connects the primary datasource.
|
|
23
24
|
* @see [capire](https://cap.cloud.sap/docs/node.js/cds-connect)
|
|
24
25
|
*/
|
|
25
|
-
|
|
26
|
+
// API extractor cannot handle the direct usages of the cds namespace in typeof cds, so add an indirection.
|
|
27
|
+
(options?: string | cds_connect_options): Promise<_cds> //> cds.connect(<options>)
|
|
26
28
|
}
|
|
27
29
|
|
|
28
30
|
/**
|
|
29
31
|
* The default bootstrap function as loaded from server.js
|
|
30
32
|
*/
|
|
31
|
-
server: Function
|
|
33
|
+
export const server: Function
|
|
32
34
|
|
|
33
35
|
/**
|
|
34
36
|
* Constructs service providers from respective service definitions
|
|
35
37
|
* @see [capire](https://cap.cloud.sap/docs/node.js/cds-serve)
|
|
36
38
|
*/
|
|
37
|
-
serve (service : string, options?: {
|
|
39
|
+
export const serve: (service : string, options?: {
|
|
38
40
|
service?: string,
|
|
39
41
|
from?: '*' | 'all' | string,
|
|
40
42
|
[key: string]: unknown
|
|
41
|
-
})
|
|
43
|
+
}) => Promise<cds_services> & cds_serve_fluent
|
|
42
44
|
|
|
45
|
+
/**
|
|
46
|
+
* Emitted whenever a model is loaded using cds.load().
|
|
47
|
+
*/
|
|
48
|
+
// FIXME: this is actually supposed to be part of models.d.ts
|
|
49
|
+
// but had to be moved here so export * would not clash their definitions
|
|
50
|
+
export function on (event : 'loaded', listener : (model : CSN) => void): _cds
|
|
43
51
|
|
|
44
52
|
/**
|
|
45
53
|
* Emitted whenever a specific service is connected for the first time.
|
|
46
54
|
*/
|
|
47
|
-
on(event: 'connect', listener: (srv: Service) => void):
|
|
55
|
+
export function on(event: 'connect', listener: (srv: Service) => void): _cds
|
|
48
56
|
|
|
49
57
|
|
|
50
58
|
/**
|
|
@@ -52,53 +60,53 @@ export default class cds {
|
|
|
52
60
|
* express application has been constructed but no middlewares or routes
|
|
53
61
|
* added yet.
|
|
54
62
|
*/
|
|
55
|
-
on (event : 'bootstrap', listener : (app : Application) => void) :
|
|
56
|
-
once (event : 'bootstrap', listener : (app : Application) => void) :
|
|
63
|
+
export function on (event : 'bootstrap', listener : (app : Application) => void) : _cds
|
|
64
|
+
export function once (event : 'bootstrap', listener : (app : Application) => void) : _cds
|
|
57
65
|
|
|
58
66
|
/**
|
|
59
67
|
* Emitted for each service served by cds.serve().
|
|
60
68
|
*/
|
|
61
|
-
on (event : 'serving', listener : (srv : Service) => void) :
|
|
69
|
+
export function on (event : 'serving', listener : (srv : Service) => void) : _cds
|
|
62
70
|
|
|
63
71
|
/**
|
|
64
72
|
* Emitted by the default, built-in `server.js` when all services are
|
|
65
73
|
* constructed and mounted by cds.serve().
|
|
66
74
|
*/
|
|
67
|
-
on (event : 'served', listener : (all : cds_services) => void) :
|
|
68
|
-
once (event : 'served', listener : (all : cds_services) => void) :
|
|
75
|
+
export function on (event : 'served', listener : (all : cds_services) => void) : _cds
|
|
76
|
+
export function once (event : 'served', listener : (all : cds_services) => void) : _cds
|
|
69
77
|
|
|
70
78
|
/**
|
|
71
79
|
* Emitted by the default, built-in `server.js` when the http server
|
|
72
80
|
* is started and listening for incoming requests.
|
|
73
81
|
*/
|
|
74
|
-
on (event : 'listening', listener : (args : { server: http.Server, url:string }) => void) :
|
|
75
|
-
once (event : 'listening', listener : (args : { server: http.Server, url:string }) => void) :
|
|
82
|
+
export function on (event : 'listening', listener : (args : { server: http.Server, url:string }) => void) : _cds
|
|
83
|
+
export function once (event : 'listening', listener : (args : { server: http.Server, url:string }) => void) : _cds
|
|
76
84
|
|
|
77
85
|
/**
|
|
78
86
|
* Emitted by the default, built-in `server.js` when the http server
|
|
79
87
|
* is shutdown.
|
|
80
88
|
*/
|
|
81
|
-
on (event : 'shutdown', listener : () => void) :
|
|
82
|
-
once (event : 'shutdown', listener : () => void) :
|
|
89
|
+
export function on (event : 'shutdown', listener : () => void) : _cds
|
|
90
|
+
export function once (event : 'shutdown', listener : () => void) : _cds
|
|
83
91
|
|
|
84
92
|
/**
|
|
85
93
|
* Dictionary of all services constructed and/or connected.
|
|
86
94
|
*/
|
|
87
|
-
services : cds_services
|
|
95
|
+
export const services : cds_services
|
|
88
96
|
|
|
89
97
|
/**
|
|
90
98
|
* Shortcut to base class for all service definitions from linked models.
|
|
91
99
|
* Plus accessors to impl functions and constructed providers.
|
|
92
100
|
*/
|
|
93
|
-
service : service
|
|
101
|
+
export const service : service
|
|
94
102
|
|
|
95
103
|
/**
|
|
96
104
|
* Provides a graceful shutdown for running servers, by first emitting `cds.emit('shutdown')`.
|
|
97
105
|
* @see [capire](https://cap.cloud.sap/docs/node.js/cds-facade#cds-exit)
|
|
98
106
|
*/
|
|
99
|
-
exit(): void
|
|
107
|
+
export function exit(): void
|
|
108
|
+
|
|
100
109
|
|
|
101
|
-
}
|
|
102
110
|
|
|
103
111
|
export type service = {
|
|
104
112
|
/**
|
|
@@ -106,7 +114,7 @@ export type service = {
|
|
|
106
114
|
* Use that in modules to get IntelliSense.
|
|
107
115
|
*/
|
|
108
116
|
impl (impl: ServiceImpl) : typeof impl
|
|
109
|
-
// impl <T> (srv:T, impl: (
|
|
117
|
+
// impl <T> (srv:T, impl: ( _cds: T, srv: (T) ) => any) : typeof impl
|
|
110
118
|
|
|
111
119
|
/**
|
|
112
120
|
* Array of all services constructed.
|
|
@@ -118,11 +126,11 @@ export type service = {
|
|
|
118
126
|
type cds_services = { [name:string]: Service }
|
|
119
127
|
|
|
120
128
|
interface cds_serve_fluent {
|
|
121
|
-
from (model : string | CSN) :
|
|
122
|
-
to (protocol: string) :
|
|
123
|
-
at (path: string) :
|
|
124
|
-
in (app: Application) :
|
|
125
|
-
with (impl: ServiceImpl | string) :
|
|
129
|
+
from (model : string | CSN) : cds_serve_fluent
|
|
130
|
+
to (protocol: string) : cds_serve_fluent
|
|
131
|
+
at (path: string) : cds_serve_fluent
|
|
132
|
+
in (app: Application) : cds_serve_fluent
|
|
133
|
+
with (impl: ServiceImpl | string) : cds_serve_fluent
|
|
126
134
|
// (req,res) : void
|
|
127
135
|
}
|
|
128
136
|
|
package/apis/services.d.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { SELECT, INSERT, UPDATE, DELETE, Query, ConstructedQuery, UPSERT } from './ql'
|
|
2
2
|
import { Awaitable } from './ql'
|
|
3
3
|
import { ArrayConstructable, Constructable } from './internal/inference'
|
|
4
|
-
import { LinkedCSN, LinkedDefinition, Definitions, LinkedEntity } from './linked'
|
|
4
|
+
import { LinkedCSN, LinkedDefinition, Definitions as LinkedDefinitions, LinkedEntity } from './linked'
|
|
5
5
|
import { CSN } from './csn'
|
|
6
6
|
import { EventContext } from './events'
|
|
7
7
|
import { Request } from './events'
|
|
8
|
+
import { ReadableStream } from 'node:stream/web'
|
|
9
|
+
|
|
8
10
|
|
|
9
11
|
export class QueryAPI {
|
|
10
12
|
|
|
@@ -59,16 +61,6 @@ export class QueryAPI {
|
|
|
59
61
|
(query: string, args?: any[] | object): Promise<ResultSet | any>
|
|
60
62
|
}
|
|
61
63
|
|
|
62
|
-
/**
|
|
63
|
-
* @see [docs](https://cap.cloud.sap/docs/node.js/core-services#crud-style-api)
|
|
64
|
-
*/
|
|
65
|
-
delete<T>(entity: LinkedDefinition | string, key?: any): DELETE<T>
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* @see [docs](https://cap.cloud.sap/docs/node.js/core-services#srv-foreach-entity)
|
|
69
|
-
*/
|
|
70
|
-
foreach(query: Query, callback: (row: object) => void): this
|
|
71
|
-
|
|
72
64
|
/**
|
|
73
65
|
* @see [docs](https://cap.cloud.sap/docs/node.js/core-services#srv-stream-column)
|
|
74
66
|
*/
|
|
@@ -82,37 +74,20 @@ export class QueryAPI {
|
|
|
82
74
|
}
|
|
83
75
|
|
|
84
76
|
/**
|
|
85
|
-
*
|
|
86
|
-
* @see [docs](https://cap.cloud.sap/docs/node.js/cds-tx)
|
|
77
|
+
* @see [docs](https://cap.cloud.sap/docs/node.js/core-services#crud-style-api)
|
|
87
78
|
*/
|
|
79
|
+
delete<T>(entity: LinkedDefinition | string, key?: any): DELETE<T>
|
|
88
80
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
}
|
|
81
|
+
/**
|
|
82
|
+
* @see [docs](https://cap.cloud.sap/docs/node.js/core-services#srv-foreach-entity)
|
|
83
|
+
*/
|
|
84
|
+
foreach(query: Query, callback: (row: object) => void): this
|
|
94
85
|
|
|
95
86
|
transaction: {
|
|
96
87
|
(fn: (tx: Transaction) => {}): Promise<unknown>
|
|
97
88
|
(context?: object): Transaction
|
|
98
89
|
(context: object, fn: (tx: Transaction) => {}): Promise<unknown>
|
|
99
90
|
}
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* @see [docs](https://cap.cloud.sap/docs/node.js/cds-tx#cds-spawn)
|
|
103
|
-
*/
|
|
104
|
-
spawn(options: {
|
|
105
|
-
[key: string]: any
|
|
106
|
-
every?: number
|
|
107
|
-
after?: number
|
|
108
|
-
}, fn: (tx: Transaction) => {}): SpawnEventEmitter
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
* @see [docs](https://cap.cloud.sap/docs/node.js/cds-tx#event-contexts
|
|
112
|
-
*/
|
|
113
|
-
context?: EventContext
|
|
114
|
-
|
|
115
|
-
db: DatabaseService
|
|
116
91
|
}
|
|
117
92
|
|
|
118
93
|
|
|
@@ -131,14 +106,14 @@ export class Service extends QueryAPI {
|
|
|
131
106
|
)
|
|
132
107
|
|
|
133
108
|
/**
|
|
134
|
-
* The
|
|
109
|
+
* The kind of the service
|
|
135
110
|
*/
|
|
136
|
-
|
|
111
|
+
kind: string
|
|
137
112
|
|
|
138
113
|
/**
|
|
139
|
-
* The
|
|
114
|
+
* The name of the service
|
|
140
115
|
*/
|
|
141
|
-
|
|
116
|
+
name: string
|
|
142
117
|
|
|
143
118
|
/**
|
|
144
119
|
* The model from which the service's definition was loaded
|
|
@@ -150,25 +125,25 @@ export class Service extends QueryAPI {
|
|
|
150
125
|
* Provides access to the entities exposed by a service
|
|
151
126
|
* @see [capire docs](https://cap.cloud.sap/docs/node.js/core-services)
|
|
152
127
|
*/
|
|
153
|
-
entities:
|
|
128
|
+
entities: LinkedDefinitions & ((namespace: string) => LinkedDefinitions)
|
|
154
129
|
|
|
155
130
|
/**
|
|
156
131
|
* Provides access to the events declared by a service
|
|
157
132
|
* @see [capire docs](https://cap.cloud.sap/docs/node.js/core-services)
|
|
158
133
|
*/
|
|
159
|
-
events:
|
|
134
|
+
events: LinkedDefinitions & ((namespace: string) => LinkedDefinitions)
|
|
160
135
|
|
|
161
136
|
/**
|
|
162
137
|
* Provides access to the types exposed by a service
|
|
163
138
|
* @see [capire docs](https://cap.cloud.sap/docs/node.js/core-services)
|
|
164
139
|
*/
|
|
165
|
-
types:
|
|
140
|
+
types: LinkedDefinitions & ((namespace: string) => LinkedDefinitions)
|
|
166
141
|
|
|
167
142
|
/**
|
|
168
143
|
* Provides access to the operations, i.e. actions and functions, exposed by a service
|
|
169
144
|
* @see [capire docs](https://cap.cloud.sap/docs/node.js/core-services)
|
|
170
145
|
*/
|
|
171
|
-
operations:
|
|
146
|
+
operations: LinkedDefinitions & ((namespace: string) => LinkedDefinitions)
|
|
172
147
|
|
|
173
148
|
/**
|
|
174
149
|
* Acts like a parameter-less constructor. Ensure to call `await super.init()` to have the base class’s handlers added.
|
|
@@ -231,6 +206,9 @@ export class Service extends QueryAPI {
|
|
|
231
206
|
// The central method to dispatch events
|
|
232
207
|
dispatch(msg: types.event): Promise<any>
|
|
233
208
|
|
|
209
|
+
// FIXME: not yet documented, will come in future version
|
|
210
|
+
//disconnect (tenant?: string): Promise<void>
|
|
211
|
+
|
|
234
212
|
// Provider API
|
|
235
213
|
prepend(fn: ServiceImpl): Promise<this>
|
|
236
214
|
on<T extends Constructable>(eve: types.event, entity: T, handler: CRUDEventHandler.On<InstanceType<T>, InstanceType<T> | void | Error>): this
|
|
@@ -292,7 +270,7 @@ export default class cds {
|
|
|
292
270
|
}
|
|
293
271
|
|
|
294
272
|
|
|
295
|
-
interface Transaction extends Service {
|
|
273
|
+
export interface Transaction extends Service {
|
|
296
274
|
commit(): Promise<void>
|
|
297
275
|
rollback(): Promise<void>
|
|
298
276
|
}
|
|
@@ -389,3 +367,48 @@ declare namespace types {
|
|
|
389
367
|
| 'COMMIT' | 'ROLLBACK'
|
|
390
368
|
type target = string | LinkedDefinition | LinkedEntity | (string | LinkedDefinition | LinkedEntity)[] | ArrayConstructable<any>
|
|
391
369
|
}
|
|
370
|
+
|
|
371
|
+
type SpawnOptions = {
|
|
372
|
+
[key: string]: any
|
|
373
|
+
every?: number
|
|
374
|
+
after?: number
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
// FIXME: this was ?: EventContext before. Is context supposed to not be present sometimes?
|
|
378
|
+
// let, as apparently we can reassign?
|
|
379
|
+
/**
|
|
380
|
+
* @see [docs](https://cap.cloud.sap/docs/node.js/cds-tx#event-contexts
|
|
381
|
+
*/
|
|
382
|
+
export let context: EventContext | undefined
|
|
383
|
+
|
|
384
|
+
/**
|
|
385
|
+
* @see [docs](https://cap.cloud.sap/docs/node.js/cds-tx#cds-spawn)
|
|
386
|
+
*/
|
|
387
|
+
export function spawn(options: SpawnOptions, fn: (tx: Transaction) => {}): SpawnEventEmitter
|
|
388
|
+
|
|
389
|
+
|
|
390
|
+
// facade proxies into cds.db, which is a Service
|
|
391
|
+
/**
|
|
392
|
+
* Starts or joins a transaction
|
|
393
|
+
* @see [docs](https://cap.cloud.sap/docs/node.js/cds-tx)
|
|
394
|
+
*/
|
|
395
|
+
export const tx: {
|
|
396
|
+
(fn: (tx: Transaction) => {}): Promise<unknown>
|
|
397
|
+
(context?: object): Transaction
|
|
398
|
+
(context: object, fn: (tx: Transaction) => {}): Promise<unknown>
|
|
399
|
+
}
|
|
400
|
+
export const entities: Service['entities']
|
|
401
|
+
export const run: Service['run']
|
|
402
|
+
export const foreach: Service['foreach']
|
|
403
|
+
export const stream: Service['stream']
|
|
404
|
+
export const read: Service['read']
|
|
405
|
+
export const create: Service['create']
|
|
406
|
+
export const insert: Service['insert']
|
|
407
|
+
export const update: Service['update']
|
|
408
|
+
// temporarily moved to cds.d.ts, as "delete" is a reserved keyword
|
|
409
|
+
// export const delete: Service['delete']
|
|
410
|
+
// FIXME: see Service.disconnect comment
|
|
411
|
+
//export const disconnect: Service['disconnect']
|
|
412
|
+
export const transaction: Service['transaction']
|
|
413
|
+
export const db: DatabaseService
|
|
414
|
+
//export const upsert: Service['upsert']
|