@cap-js/cds-types 0.0.1 → 0.2.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 +13 -2
- package/apis/cds.d.ts +30 -26
- package/apis/core.d.ts +90 -83
- package/apis/cqn.d.ts +87 -65
- package/apis/csn.d.ts +25 -16
- package/apis/env.d.ts +21 -24
- package/apis/events.d.ts +82 -59
- package/apis/internal/inference.d.ts +39 -5
- package/apis/linked.d.ts +45 -38
- package/apis/log.d.ts +79 -71
- package/apis/models.d.ts +155 -162
- package/apis/ql.d.ts +256 -191
- package/apis/server.d.ts +72 -62
- package/apis/services.d.ts +164 -106
- package/apis/test.d.ts +80 -49
- package/apis/utils.d.ts +85 -90
- package/package.json +13 -3
package/apis/server.d.ts
CHANGED
|
@@ -1,135 +1,145 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import
|
|
1
|
+
/* eslint-disable @typescript-eslint/ban-types */
|
|
2
|
+
import { Service, ServiceImpl } from './services'
|
|
3
|
+
import { CSN } from './csn'
|
|
4
|
+
import * as http from 'http'
|
|
5
|
+
import * as cds from './cds'
|
|
6
|
+
import { Application } from 'express'
|
|
5
7
|
|
|
6
|
-
|
|
8
|
+
type _cds = typeof cds
|
|
7
9
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
+
export const connect: {
|
|
11
|
+
|
|
12
|
+
/**
|
|
10
13
|
* Connects to a specific datasource.
|
|
11
14
|
* @see [capire](https://cap.cloud.sap/docs/node.js/cds-connect#cds-connect-to)
|
|
12
15
|
*/
|
|
13
|
-
|
|
16
|
+
to(datasource: string, options?: cds_connect_options): Promise<Service>,
|
|
14
17
|
|
|
15
|
-
|
|
18
|
+
/**
|
|
16
19
|
* Connects to a specific datasource via options.
|
|
17
20
|
* @see [capire](https://cap.cloud.sap/docs/node.js/cds-connect#cds-connect-to)
|
|
18
21
|
*/
|
|
19
|
-
|
|
22
|
+
to(options: cds_connect_options): Promise<Service>,
|
|
20
23
|
|
|
21
|
-
|
|
24
|
+
/**
|
|
22
25
|
* Connects the primary datasource.
|
|
23
26
|
* @see [capire](https://cap.cloud.sap/docs/node.js/cds-connect)
|
|
24
27
|
*/
|
|
25
|
-
|
|
26
|
-
|
|
28
|
+
// API extractor cannot handle the direct usages of the cds namespace in typeof cds, so add an indirection.
|
|
29
|
+
(options?: string | cds_connect_options): Promise<_cds>, // > cds.connect(<options>)
|
|
30
|
+
}
|
|
27
31
|
|
|
28
|
-
|
|
32
|
+
/**
|
|
29
33
|
* The default bootstrap function as loaded from server.js
|
|
30
34
|
*/
|
|
31
|
-
|
|
35
|
+
export const server: Function
|
|
32
36
|
|
|
33
|
-
|
|
37
|
+
/**
|
|
34
38
|
* Constructs service providers from respective service definitions
|
|
35
39
|
* @see [capire](https://cap.cloud.sap/docs/node.js/cds-serve)
|
|
36
40
|
*/
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
export const serve: (service: string, options?: {
|
|
42
|
+
service?: string,
|
|
43
|
+
from?: '*' | 'all' | string,
|
|
44
|
+
[key: string]: any,
|
|
45
|
+
}) => Promise<cds_services> & cds_serve_fluent
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Emitted whenever a model is loaded using cds.load().
|
|
49
|
+
*/
|
|
50
|
+
// FIXME: this is actually supposed to be part of models.d.ts
|
|
51
|
+
// but had to be moved here so export * would not clash their definitions
|
|
52
|
+
export function on (event: 'loaded', listener: (model: CSN) => void): _cds
|
|
43
53
|
|
|
44
|
-
|
|
54
|
+
/**
|
|
45
55
|
* Emitted whenever a specific service is connected for the first time.
|
|
46
56
|
*/
|
|
47
|
-
|
|
57
|
+
export function on (event: 'connect', listener: (srv: Service) => void): _cds
|
|
48
58
|
|
|
49
59
|
|
|
50
|
-
|
|
60
|
+
/**
|
|
51
61
|
* Emitted at the very beginning of the bootsrapping process, when the
|
|
52
62
|
* express application has been constructed but no middlewares or routes
|
|
53
63
|
* added yet.
|
|
54
64
|
*/
|
|
55
|
-
|
|
56
|
-
|
|
65
|
+
export function on (event: 'bootstrap', listener: (app: Application) => void): _cds
|
|
66
|
+
export function once (event: 'bootstrap', listener: (app: Application) => void): _cds
|
|
57
67
|
|
|
58
|
-
|
|
68
|
+
/**
|
|
59
69
|
* Emitted for each service served by cds.serve().
|
|
60
70
|
*/
|
|
61
|
-
|
|
71
|
+
export function on (event: 'serving', listener: (srv: Service) => void): _cds
|
|
62
72
|
|
|
63
|
-
|
|
73
|
+
/**
|
|
64
74
|
* Emitted by the default, built-in `server.js` when all services are
|
|
65
75
|
* constructed and mounted by cds.serve().
|
|
66
76
|
*/
|
|
67
|
-
|
|
68
|
-
|
|
77
|
+
export function on (event: 'served', listener: (all: cds_services) => void): _cds
|
|
78
|
+
export function once (event: 'served', listener: (all: cds_services) => void): _cds
|
|
69
79
|
|
|
70
|
-
|
|
80
|
+
/**
|
|
71
81
|
* Emitted by the default, built-in `server.js` when the http server
|
|
72
82
|
* is started and listening for incoming requests.
|
|
73
83
|
*/
|
|
74
|
-
|
|
75
|
-
|
|
84
|
+
export function on (event: 'listening', listener: (args: { server: http.Server, url: string }) => void): _cds
|
|
85
|
+
export function once (event: 'listening', listener: (args: { server: http.Server, url: string }) => void): _cds
|
|
76
86
|
|
|
77
|
-
|
|
87
|
+
/**
|
|
78
88
|
* Emitted by the default, built-in `server.js` when the http server
|
|
79
89
|
* is shutdown.
|
|
80
90
|
*/
|
|
81
|
-
|
|
82
|
-
|
|
91
|
+
export function on (event: 'shutdown', listener: () => void): _cds
|
|
92
|
+
export function once (event: 'shutdown', listener: () => void): _cds
|
|
83
93
|
|
|
84
|
-
|
|
94
|
+
/**
|
|
85
95
|
* Dictionary of all services constructed and/or connected.
|
|
86
96
|
*/
|
|
87
|
-
|
|
97
|
+
export const services: cds_services
|
|
88
98
|
|
|
89
|
-
|
|
99
|
+
/**
|
|
90
100
|
* Shortcut to base class for all service definitions from linked models.
|
|
91
101
|
* Plus accessors to impl functions and constructed providers.
|
|
92
102
|
*/
|
|
93
|
-
|
|
103
|
+
export const service: service
|
|
94
104
|
|
|
95
|
-
|
|
105
|
+
/**
|
|
96
106
|
* Provides a graceful shutdown for running servers, by first emitting `cds.emit('shutdown')`.
|
|
97
107
|
* @see [capire](https://cap.cloud.sap/docs/node.js/cds-facade#cds-exit)
|
|
98
108
|
*/
|
|
99
|
-
|
|
109
|
+
export function exit (): void
|
|
100
110
|
|
|
101
|
-
}
|
|
102
111
|
|
|
103
112
|
export type service = {
|
|
104
|
-
|
|
113
|
+
|
|
114
|
+
/**
|
|
105
115
|
* Dummy wrapper for service implementation functions.
|
|
106
116
|
* Use that in modules to get IntelliSense.
|
|
107
117
|
*/
|
|
108
|
-
|
|
109
|
-
|
|
118
|
+
impl (impl: ServiceImpl): typeof impl,
|
|
119
|
+
// impl <T> (srv:T, impl: ( _cds: T, srv: (T) ) => any) : typeof impl
|
|
110
120
|
|
|
111
|
-
|
|
121
|
+
/**
|
|
112
122
|
* Array of all services constructed.
|
|
113
123
|
*/
|
|
114
|
-
|
|
124
|
+
providers: Service[],
|
|
115
125
|
}
|
|
116
126
|
|
|
117
127
|
|
|
118
|
-
type cds_services = { [name:string]: Service }
|
|
128
|
+
type cds_services = { [name: string]: Service }
|
|
119
129
|
|
|
120
130
|
interface cds_serve_fluent {
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
131
|
+
from (model: string | CSN): cds_serve_fluent
|
|
132
|
+
to (protocol: string): cds_serve_fluent
|
|
133
|
+
at (path: string): cds_serve_fluent
|
|
134
|
+
in (app: Application): cds_serve_fluent
|
|
135
|
+
with (impl: ServiceImpl | string): cds_serve_fluent
|
|
136
|
+
// (req,res) : void
|
|
127
137
|
}
|
|
128
138
|
|
|
129
139
|
interface cds_connect_options {
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
140
|
+
impl?: string
|
|
141
|
+
service?: string
|
|
142
|
+
kind?: string
|
|
143
|
+
model?: string
|
|
144
|
+
credentials?: object
|
|
135
145
|
}
|