@sap/cds 7.1.2 → 7.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/CHANGELOG.md +55 -4
- package/apis/cds.d.ts +10 -6
- package/apis/connect.d.ts +0 -1
- package/apis/core.d.ts +54 -5
- package/apis/log.d.ts +19 -6
- package/apis/models.d.ts +0 -18
- package/apis/ql.d.ts +23 -23
- package/apis/serve.d.ts +17 -14
- package/apis/services.d.ts +40 -29
- package/apis/test.d.ts +1 -2
- package/bin/serve.js +4 -4
- package/lib/auth/basic-auth.js +1 -1
- package/lib/auth/dummy-auth.js +2 -1
- package/lib/auth/ias-auth.js +68 -2
- package/lib/auth/index.js +5 -5
- package/lib/auth/jwt-auth.js +40 -24
- package/lib/auth/mocked-users.js +0 -13
- package/lib/auth/passport-basic.js +2 -0
- package/lib/auth/passport-digest.js +2 -0
- package/lib/compile/etc/_localized.js +0 -1
- package/lib/compile/extend.js +16 -0
- package/lib/compile/for/lean_drafts.js +38 -6
- package/lib/compile/resolve.js +7 -5
- package/lib/compile/to/json.js +6 -2
- package/lib/dbs/cds-deploy.js +3 -3
- package/lib/env/cds-env.js +3 -3
- package/lib/env/cds-requires.js +1 -0
- package/lib/env/defaults.js +8 -1
- package/lib/env/schemas/cds-rc.json +27 -3
- package/lib/i18n/localize.js +3 -3
- package/lib/index.js +4 -0
- package/lib/log/cds-log.js +10 -1
- package/lib/ql/Whereable.js +7 -3
- package/lib/req/user.js +18 -16
- package/lib/srv/middlewares/sap-statistics.js +3 -3
- package/lib/srv/middlewares/trace.js +5 -4
- package/lib/srv/srv-dispatch.js +10 -9
- package/lib/utils/axios.js +3 -0
- package/lib/utils/cds-test.js +3 -0
- package/lib/utils/cds-utils.js +2 -0
- package/libx/_runtime/auth/index.js +8 -32
- package/libx/_runtime/auth/strategies/ias-auth.js +1 -77
- package/libx/_runtime/auth/strategies/mock.js +1 -12
- package/libx/_runtime/auth/strategies/xssecUtils.js +2 -2
- package/libx/_runtime/cds-services/adapter/odata-v4/handlers/request.js +11 -9
- package/libx/_runtime/cds-services/adapter/odata-v4/odata-to-cqn/ExpressionToCQN.js +5 -0
- package/libx/_runtime/cds-services/adapter/odata-v4/odata-to-cqn/applyToCQN.js +5 -2
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/uri/UriParser.js +4 -0
- package/libx/_runtime/common/composition/data.js +5 -3
- package/libx/_runtime/common/composition/insert.js +6 -3
- package/libx/_runtime/common/composition/update.js +12 -8
- package/libx/_runtime/common/error/constants.js +6 -1
- package/libx/_runtime/common/generic/auth/requires.js +11 -3
- package/libx/_runtime/common/generic/auth/restrict.js +21 -15
- package/libx/_runtime/common/generic/auth/restrictions.js +5 -2
- package/libx/_runtime/common/generic/crud.js +6 -0
- package/libx/_runtime/common/generic/paging.js +2 -1
- package/libx/_runtime/common/utils/cqn2cqn4sql.js +3 -5
- package/libx/_runtime/common/utils/resolveView.js +3 -1
- package/libx/_runtime/common/utils/restrictions.js +47 -0
- package/libx/_runtime/db/data-conversion/post-processing.js +3 -3
- package/libx/_runtime/db/generic/input.js +1 -1
- package/libx/_runtime/db/sql-builder/ExpressionBuilder.js +0 -17
- package/libx/_runtime/fiori/lean-draft.js +6 -3
- package/libx/_runtime/hana/driver.js +2 -4
- package/libx/_runtime/hana/pool.js +1 -1
- package/libx/_runtime/messaging/enterprise-messaging-utils/registerEndpoints.js +2 -2
- package/libx/_runtime/messaging/outbox/utils.js +1 -2
- package/libx/_runtime/remote/utils/client.js +1 -1
- package/libx/_runtime/sqlite/Service.js +0 -4
- package/libx/_runtime/sqlite/customBuilder/CustomFunctionBuilder.js +2 -1
- package/libx/odata/afterburner.js +5 -3
- package/libx/odata/cqn2odata.js +7 -7
- package/libx/odata/utils.js +4 -1
- package/libx/rest/RestAdapter.js +15 -16
- package/package.json +1 -1
- package/lib/auth/xsuaa-auth.js +0 -2
- package/libx/_runtime/auth/utils.js +0 -32
- package/libx/audit-log/client.cds +0 -0
- package/libx/audit-log/client.js +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,43 @@
|
|
|
4
4
|
- The format is based on [Keep a Changelog](http://keepachangelog.com/).
|
|
5
5
|
- This project adheres to [Semantic Versioning](http://semver.org/).
|
|
6
6
|
|
|
7
|
+
## Version 7.2.0 - 2023-09-04
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
|
|
11
|
+
- Typescript definition for:
|
|
12
|
+
- The `cds.exit()` method.
|
|
13
|
+
- The `label` option parameter in the `cds.log()` API. For example: `cds.log('log message', { label: 'adapter' }`.
|
|
14
|
+
- `@restrict` annotations can now prevent the creation of drafts([see documentation](https://pages.github.tools.sap/cap/docs/guides/authorization#restrictions-and-draft-mode))
|
|
15
|
+
- JSON Schema validation for `cds.requires.multitenancy.jobs` settings.
|
|
16
|
+
- Managed associations to-one with exactly one foreign key can now have a default value.
|
|
17
|
+
- Skip Okra's parsing of query options via experimental feature flag `cds.env.features.okra_skip_query_options = true`.
|
|
18
|
+
Only allowed in combination with new OData parser, i.e., `cds.env.features.odata_new_parser = true`.
|
|
19
|
+
- Support for `@requires: 'any'` to make service public, i.e., no authenticated user is required
|
|
20
|
+
|
|
21
|
+
### Changed
|
|
22
|
+
|
|
23
|
+
- The built-in `java` profile sets `build.target` to `.` by default
|
|
24
|
+
- Decimals from query options (e.g., `$filter`) are represented as strings in CQN
|
|
25
|
+
- Improve error message for unsupported transformations with `$apply`
|
|
26
|
+
- For database dialect H2, specialized localized views for languages `de` and `fr` are no longer generated.
|
|
27
|
+
- Authentication kinds `jwt`, `xsuaa`, and `ias` throw an error during bootstrapping if the necessary credentials are not available.
|
|
28
|
+
Previously, a warning was logged and authentication was skipped.
|
|
29
|
+
See `cds bind`/ Hybrid Testing in CAPire for how to combine local development and cloud resources.
|
|
30
|
+
- The Typescript definitions now make use of the default export.
|
|
31
|
+
|
|
32
|
+
### Fixed
|
|
33
|
+
|
|
34
|
+
- Trace middleware: Adapted usage of `performance.now()` for Node 20.
|
|
35
|
+
- Draft: Associations to non-draft enabled entities must never point to drafts
|
|
36
|
+
- Avoid type error in old db post processing
|
|
37
|
+
- `<remote-srv>.run('/arbitrary-url')` properly defaults to a get request and does not add request body
|
|
38
|
+
- `@cds.query.limit` is cached per projection
|
|
39
|
+
- Application crash for incorrect usage of REST-style API to run queries
|
|
40
|
+
- The `@requires` annotation on entity level didn't get applied to bound operations
|
|
41
|
+
- `cds.test` run with a profile parameter such as `cds.test('run', '--profile', 'integration-tests')` will use the correct profile.
|
|
42
|
+
- `cds.env.requires.auth.restrict_all_services = false` in combination with `cds.env.requires.middlewares = true` (the default)
|
|
43
|
+
|
|
7
44
|
## Version 7.1.2 - 2023-08-11
|
|
8
45
|
|
|
9
46
|
### Fixed
|
|
@@ -21,14 +58,13 @@
|
|
|
21
58
|
### Fixed
|
|
22
59
|
|
|
23
60
|
- Lean draft: read actives via service on draft edit
|
|
24
|
-
- Resolve column name for `STREAM` CQN queries that point to views
|
|
25
61
|
- Only log the error in case of an unhandled rejection
|
|
62
|
+
- Resolve column name for experimental `STREAM` CQN queries that point to views
|
|
26
63
|
|
|
27
64
|
## Version 7.1.0 - 2023-07-28
|
|
28
65
|
|
|
29
66
|
### Added
|
|
30
67
|
|
|
31
|
-
- Support for resolving of `STREAM` CQN queries that point to views
|
|
32
68
|
- Enable PDF export via GET to collection with accept header `appplication/pdf`.
|
|
33
69
|
Custom handler must return the following:
|
|
34
70
|
```
|
|
@@ -48,6 +84,15 @@
|
|
|
48
84
|
{ kind: 'rest', path: '/rest/browse' }
|
|
49
85
|
]
|
|
50
86
|
```
|
|
87
|
+
- Service level support for @restrict. Limited to grant: '*' and all filter conditions in `where` are ignored.
|
|
88
|
+
Example:
|
|
89
|
+
```
|
|
90
|
+
@(restrict: [{
|
|
91
|
+
grant: '*',
|
|
92
|
+
to: ['authenticated-user']
|
|
93
|
+
}])
|
|
94
|
+
```
|
|
95
|
+
- Support for resolving of experimental `STREAM` CQN queries that point to views
|
|
51
96
|
|
|
52
97
|
### Fixed
|
|
53
98
|
|
|
@@ -152,13 +197,19 @@
|
|
|
152
197
|
- Deprecated compat mode `cds.env.features.cds_tx_protection = false`
|
|
153
198
|
- Beta `AuditLogService` and out-of-the-box audit logging. Use plugin `@cap-js/audit-logging` instead.
|
|
154
199
|
|
|
200
|
+
## Version 6.8.4 - 2023-06-14
|
|
201
|
+
|
|
202
|
+
### Fixed
|
|
203
|
+
|
|
204
|
+
- `$metadata` requests for multitenant applications
|
|
205
|
+
|
|
155
206
|
## Version 6.8.3 - 2023-06-13
|
|
156
207
|
|
|
157
208
|
### Fixed
|
|
158
209
|
|
|
159
210
|
- `cds build` no longer reports CAP Java Classic runtime usage by mistake.
|
|
160
211
|
- `cds version` prints the local `@sap/cds` version, even if called from a different `@sap/cds` installation.
|
|
161
|
-
- User challenges handling in case of `cds.env.auth.restrict_all_services: false`
|
|
212
|
+
- User challenges handling in case of `cds.env.requires.auth.restrict_all_services: false`
|
|
162
213
|
|
|
163
214
|
## Version 6.8.2 - 2023-05-26
|
|
164
215
|
|
|
@@ -1030,7 +1081,7 @@ In such scenarios, now the HTTP `404 Not Found` status code is returned rather t
|
|
|
1030
1081
|
- Avoid error that is caused e.g. in a streaming scenario when there is an issue while processing the stream. Trying to change/send the response object could cause a crash because the response was sent already.
|
|
1031
1082
|
- Correct URL generation for `Integer64` and `Decimal` for remote services
|
|
1032
1083
|
- Operation parameters from structured type and annotated with @open are not filtered from the input query
|
|
1033
|
-
- Services are secured by default in production. Can be disabled via feature flag `cds.env.auth.restrict_all_services: false` or by using `mocked-auth`.
|
|
1084
|
+
- Services are secured by default in production. Can be disabled via feature flag `cds.env.requires.auth.restrict_all_services: false` or by using `mocked-auth`.
|
|
1034
1085
|
- Optimized Search: Exception when searching on views using built-in SQL SAP HANA functions
|
|
1035
1086
|
- In some cases, custom error handlers were not called for rest
|
|
1036
1087
|
- `cds build` adds newline at EOF for `hdbmigrationtable` files
|
package/apis/cds.d.ts
CHANGED
|
@@ -1,18 +1,24 @@
|
|
|
1
1
|
import * as ql from './ql'
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
declare const cds : {}
|
|
4
|
+
& import('./core').default
|
|
4
5
|
& import('./models')
|
|
5
6
|
& import('./connect')
|
|
6
|
-
& import('./serve')
|
|
7
|
+
& import('./serve').default
|
|
7
8
|
& import('./ql').cds_ql
|
|
8
|
-
& import('./services').
|
|
9
|
+
& import('./services').default
|
|
9
10
|
& import('./services').QueryAPI
|
|
10
11
|
& import('./log')
|
|
11
12
|
& import('./utils')
|
|
12
13
|
& import('./test')
|
|
14
|
+
export default cds
|
|
15
|
+
|
|
16
|
+
export * from './core'
|
|
17
|
+
export * from './serve'
|
|
18
|
+
export * from './services'
|
|
13
19
|
|
|
14
20
|
declare global {
|
|
15
|
-
|
|
21
|
+
|
|
16
22
|
// these provide the functionality from SELECT, INSERT, etc in the global facade
|
|
17
23
|
const SELECT: typeof cds.ql.SELECT
|
|
18
24
|
const INSERT: typeof cds.ql.INSERT
|
|
@@ -31,5 +37,3 @@ declare global {
|
|
|
31
37
|
type CREATE<T> = ql.CREATE<T>
|
|
32
38
|
type DROP<T> = ql.DROP<T>
|
|
33
39
|
}
|
|
34
|
-
|
|
35
|
-
export = cds
|
package/apis/connect.d.ts
CHANGED
package/apis/core.d.ts
CHANGED
|
@@ -1,16 +1,27 @@
|
|
|
1
1
|
// import types from '../lib/core'
|
|
2
|
-
import { ReflectedModel, LinkedModel
|
|
2
|
+
import { ReflectedModel, LinkedModel } from './reflect'
|
|
3
3
|
import { CSN as csn, Definition } from './csn'
|
|
4
4
|
|
|
5
5
|
type UserInput = string | { id: string; attr: Record<string, string>; roles: Record<string, string> } | User
|
|
6
6
|
|
|
7
|
+
export type Association = Definition
|
|
8
|
+
export type Composition = Association
|
|
9
|
+
export type entity = Definition
|
|
10
|
+
export type event = Definition
|
|
11
|
+
export type type = Definition
|
|
12
|
+
export type array = Definition
|
|
13
|
+
export type struct = Definition
|
|
14
|
+
|
|
15
|
+
|
|
7
16
|
export class User {
|
|
8
17
|
constructor(obj?: UserInput)
|
|
9
18
|
id: string
|
|
19
|
+
|
|
10
20
|
/**
|
|
11
21
|
* @deprecated Use https://cap.cloud.sap/docs/node.js/events#locale instead
|
|
12
22
|
*/
|
|
13
23
|
locale: string
|
|
24
|
+
|
|
14
25
|
/**
|
|
15
26
|
* @deprecated Use https://cap.cloud.sap/docs/node.js/events#tenant instead
|
|
16
27
|
*/
|
|
@@ -20,6 +31,7 @@ export class User {
|
|
|
20
31
|
static Privileged: typeof Privileged
|
|
21
32
|
is(role: string): boolean
|
|
22
33
|
}
|
|
34
|
+
|
|
23
35
|
/**
|
|
24
36
|
* Subclass for executing code with superuser privileges.
|
|
25
37
|
*/
|
|
@@ -72,19 +84,24 @@ declare class cds {
|
|
|
72
84
|
* Base class for linked Associations from reflected models.
|
|
73
85
|
* @see [capire](https://cap.cloud.sap/docs/node.js/cds-reflect#cds-Association)
|
|
74
86
|
*/
|
|
75
|
-
Association:
|
|
87
|
+
Association: Association
|
|
76
88
|
|
|
77
89
|
/**
|
|
78
90
|
* Base class for linked Compositions from reflected models.
|
|
79
91
|
* @see [capire](https://cap.cloud.sap/docs/node.js/cds-reflect#cds-Association)
|
|
80
92
|
*/
|
|
81
|
-
Composition:
|
|
93
|
+
Composition: Composition
|
|
82
94
|
|
|
83
95
|
/**
|
|
84
96
|
* Base class for linked entities from reflected models.
|
|
85
97
|
* @see [capire](https://cap.cloud.sap/docs/node.js/cds-reflect#cds-entity)
|
|
86
98
|
*/
|
|
87
|
-
entity:
|
|
99
|
+
entity: entity
|
|
100
|
+
|
|
101
|
+
event: event
|
|
102
|
+
type: type
|
|
103
|
+
array: array
|
|
104
|
+
struct: struct
|
|
88
105
|
|
|
89
106
|
/**
|
|
90
107
|
* Add aspects to a given object, for example:
|
|
@@ -126,6 +143,38 @@ declare class cds {
|
|
|
126
143
|
* using standard Node.js's `module.require` functions.
|
|
127
144
|
*/
|
|
128
145
|
lazified: <T>(target: T) => T
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Provides a graceful shutdown for running servers, by first emitting `cds.emit('shutdown')`.
|
|
149
|
+
* @see [capire](https://cap.cloud.sap/docs/node.js/cds-facade#cds-exit)
|
|
150
|
+
*/
|
|
151
|
+
exit(): void
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Access to the configuration for Node.js runtime and tools.
|
|
156
|
+
* The object is the effective result of configuration merged from various sources,
|
|
157
|
+
* filtered through the currently active profiles, thus highly dependent on the current working
|
|
158
|
+
* directory and process environment.
|
|
159
|
+
*/
|
|
160
|
+
env : {
|
|
161
|
+
build: any,
|
|
162
|
+
hana: any,
|
|
163
|
+
i18n: any,
|
|
164
|
+
mtx: any,
|
|
165
|
+
requires: any,
|
|
166
|
+
folders: any,
|
|
167
|
+
odata: any,
|
|
168
|
+
query: any,
|
|
169
|
+
sql: any
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
requires: any
|
|
173
|
+
version: string
|
|
174
|
+
home: string
|
|
175
|
+
root: string
|
|
176
|
+
|
|
129
177
|
}
|
|
178
|
+
|
|
130
179
|
// & typeof import ('../lib/index')
|
|
131
|
-
export
|
|
180
|
+
export default cds
|
package/apis/log.d.ts
CHANGED
|
@@ -20,6 +20,7 @@ declare class cds {
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
declare type LogFactory = {
|
|
23
|
+
|
|
23
24
|
/**
|
|
24
25
|
* Returns a trace logger for the given module if trace is switched on for it,
|
|
25
26
|
* otherwise returns null. All cds runtime packages use this method for their
|
|
@@ -27,24 +28,27 @@ declare type LogFactory = {
|
|
|
27
28
|
*
|
|
28
29
|
* By default this logger would prefix all output with `[sql] - `
|
|
29
30
|
* You can change this by specifying another prefix in the options:
|
|
31
|
+
*
|
|
30
32
|
* ```
|
|
31
|
-
* const LOG = cds.log('sql|db',{ prefix:'cds.ql' })
|
|
33
|
+
* const LOG = cds.log('sql|db', { prefix: 'cds.ql' })
|
|
32
34
|
* ```
|
|
35
|
+
*
|
|
33
36
|
* Call `cds.log()` for a given module again to dynamically change the log level
|
|
34
37
|
* of all formerly created loggers, for example:
|
|
38
|
+
*
|
|
35
39
|
* ```
|
|
36
40
|
* const LOG = cds.log('sql')
|
|
37
41
|
* LOG.info ('this will show, as default level is info')
|
|
38
|
-
* cds.log('sql','warn')
|
|
39
|
-
* LOG.info
|
|
42
|
+
* cds.log('sql', 'warn')
|
|
43
|
+
* LOG.info('this will be suppressed now')
|
|
40
44
|
* ```
|
|
45
|
+
*
|
|
41
46
|
* @param name logger name
|
|
42
|
-
* @param options level and prefix
|
|
47
|
+
* @param options level, label and prefix
|
|
43
48
|
* @returns the logger
|
|
44
|
-
*
|
|
45
49
|
* @see [capire](https://cap.cloud.sap/docs/node.js/cds-log)
|
|
46
50
|
*/
|
|
47
|
-
(name: string, options?: string | number | { level?: number, prefix?: string }): Logger
|
|
51
|
+
(name: string, options?: string | number | { level?: number, label?: string, prefix?: string }): Logger
|
|
48
52
|
|
|
49
53
|
/**
|
|
50
54
|
* Set a custom formatter function like that:
|
|
@@ -72,22 +76,27 @@ declare class Logger {
|
|
|
72
76
|
* Logs with 'trace' level
|
|
73
77
|
*/
|
|
74
78
|
trace: Log
|
|
79
|
+
|
|
75
80
|
/**
|
|
76
81
|
* Logs with 'debug' level
|
|
77
82
|
*/
|
|
78
83
|
debug: Log
|
|
84
|
+
|
|
79
85
|
/**
|
|
80
86
|
* Logs with 'info' level
|
|
81
87
|
*/
|
|
82
88
|
info: Log
|
|
89
|
+
|
|
83
90
|
/**
|
|
84
91
|
* Logs with 'warn' level
|
|
85
92
|
*/
|
|
86
93
|
warn: Log
|
|
94
|
+
|
|
87
95
|
/**
|
|
88
96
|
* Logs with 'error' level
|
|
89
97
|
*/
|
|
90
98
|
error: Log
|
|
99
|
+
|
|
91
100
|
/**
|
|
92
101
|
* Logs with default level
|
|
93
102
|
*/
|
|
@@ -97,18 +106,22 @@ declare class Logger {
|
|
|
97
106
|
* @returns whether 'trace' level is active
|
|
98
107
|
*/
|
|
99
108
|
_trace: boolean
|
|
109
|
+
|
|
100
110
|
/**
|
|
101
111
|
* @returns whether 'debug' level is active
|
|
102
112
|
*/
|
|
103
113
|
_debug: boolean
|
|
114
|
+
|
|
104
115
|
/**
|
|
105
116
|
* @returns whether 'info' level is active
|
|
106
117
|
*/
|
|
107
118
|
_info: boolean
|
|
119
|
+
|
|
108
120
|
/**
|
|
109
121
|
* @returns whether 'warn' level is active
|
|
110
122
|
*/
|
|
111
123
|
_warn: boolean
|
|
124
|
+
|
|
112
125
|
/**
|
|
113
126
|
* @returns whether 'error' level is active
|
|
114
127
|
*/
|
package/apis/models.d.ts
CHANGED
|
@@ -162,22 +162,4 @@ declare class cds {
|
|
|
162
162
|
*/
|
|
163
163
|
resolve (files: '*' | filename | filename[]) : filename[] | undefined
|
|
164
164
|
|
|
165
|
-
/**
|
|
166
|
-
* Access to the configuration for Node.js runtime and tools.
|
|
167
|
-
* The object is the effective result of configuration merged from various sources,
|
|
168
|
-
* filtered through the currently active profiles, thus highly dependent on the current working
|
|
169
|
-
* directory and process environment.
|
|
170
|
-
*/
|
|
171
|
-
env : {
|
|
172
|
-
build: object,
|
|
173
|
-
hana: object,
|
|
174
|
-
i18n: object,
|
|
175
|
-
mtx: object,
|
|
176
|
-
requires: object,
|
|
177
|
-
folders: object,
|
|
178
|
-
odata: object,
|
|
179
|
-
query: object,
|
|
180
|
-
sql: object
|
|
181
|
-
}
|
|
182
|
-
|
|
183
165
|
}
|
package/apis/ql.d.ts
CHANGED
|
@@ -43,7 +43,7 @@ type QLExtensions_<T> = {
|
|
|
43
43
|
get: (path: string) => any
|
|
44
44
|
|
|
45
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.
|
|
46
|
+
// over T and undefined, which gives us zero code completion within the callable.
|
|
47
47
|
} & Subqueryable<Exclude<T, undefined>>
|
|
48
48
|
|
|
49
49
|
/**
|
|
@@ -51,45 +51,45 @@ type QLExtensions_<T> = {
|
|
|
51
51
|
* The final result of each subquery will be the property itself:
|
|
52
52
|
* `Book.title` == `Subqueryable<Book>.title()`
|
|
53
53
|
*/
|
|
54
|
-
type Subqueryable<T> =
|
|
54
|
+
type Subqueryable<T> =
|
|
55
55
|
T extends Primitive ? {}
|
|
56
56
|
// composition of many/ association to many
|
|
57
|
-
: T extends readonly unknown[] ? {
|
|
57
|
+
: T extends readonly unknown[] ? {
|
|
58
58
|
/**
|
|
59
59
|
* @example
|
|
60
60
|
* ```js
|
|
61
61
|
* SELECT.from(Books, b => b.author)
|
|
62
62
|
* ```
|
|
63
63
|
* means: "select all books and project each book's author"
|
|
64
|
-
*
|
|
64
|
+
*
|
|
65
65
|
* whereas
|
|
66
66
|
* ```js
|
|
67
67
|
* SELECT.from(Books, b => b.author(a => a.ID))
|
|
68
68
|
* ```
|
|
69
69
|
* means: "select all books, subselect each book's author's ID
|
|
70
|
-
*
|
|
70
|
+
*
|
|
71
71
|
* Note that you do not need to return anything from these subqueries.
|
|
72
72
|
*/
|
|
73
|
-
(fn: ((a:QLExtensions<T[number]>) => any) | '*'): T[number]
|
|
73
|
+
(fn: ((a:QLExtensions<T[number]>) => any) | '*'): T[number]
|
|
74
74
|
}
|
|
75
75
|
// composition of one/ association to one
|
|
76
|
-
: {
|
|
76
|
+
: {
|
|
77
77
|
/**
|
|
78
78
|
* @example
|
|
79
79
|
* ```js
|
|
80
80
|
* SELECT.from(Books, b => b.author)
|
|
81
81
|
* ```
|
|
82
82
|
* means: "select all books and project each book's author"
|
|
83
|
-
*
|
|
83
|
+
*
|
|
84
84
|
* whereas
|
|
85
85
|
* ```js
|
|
86
86
|
* SELECT.from(Books, b => b.author(a => a.ID))
|
|
87
87
|
* ```
|
|
88
88
|
* means: "select all books, subselect each book's author's ID
|
|
89
|
-
*
|
|
89
|
+
*
|
|
90
90
|
* Note that you do not need to return anything from these subqueries.
|
|
91
91
|
*/
|
|
92
|
-
(fn: ((a:QLExtensions<T>) => any) | '*'): T
|
|
92
|
+
(fn: ((a:QLExtensions<T>) => any) | '*'): T
|
|
93
93
|
}
|
|
94
94
|
;
|
|
95
95
|
|
|
@@ -102,7 +102,7 @@ export type Projection<T> = (e:QLExtensions<T extends ArrayConstructable ? Sing
|
|
|
102
102
|
// awaited to materialise the result:
|
|
103
103
|
// `Awaitable<SELECT<Book>, Book> = SELECT<Book> & Promise<Book>`
|
|
104
104
|
//
|
|
105
|
-
// While the benefit is probably not immediately obvious as we don't exactly
|
|
105
|
+
// While the benefit is probably not immediately obvious as we don't exactly
|
|
106
106
|
// save a lot of typing over explicitly writing `SELECT<Book> & Promise<Book>`,
|
|
107
107
|
// it makes the semantics more explicit. Also sets us up for when TypeScript ever
|
|
108
108
|
// improves their generics to support:
|
|
@@ -116,7 +116,7 @@ export type Awaitable<T, I> = T & Promise<I>
|
|
|
116
116
|
// new SELECT(...).(...) == SELECT(...)
|
|
117
117
|
export type StaticSELECT<T> = typeof SELECT
|
|
118
118
|
& ((...columns: (T extends ArrayConstructable<any> ? keyof SingularType<T> : keyof T)[]) => SELECT<T>)
|
|
119
|
-
& ((...columns:string[]) => SELECT<T>)
|
|
119
|
+
& ((...columns:string[]) => SELECT<T>)
|
|
120
120
|
& ((columns:string[]) => SELECT<T>)
|
|
121
121
|
& (TaggedTemplateQueryPart<SELECT<T>>)
|
|
122
122
|
& SELECT_one // as it is not directly quantified, ...
|
|
@@ -124,11 +124,11 @@ export type StaticSELECT<T> = typeof SELECT
|
|
|
124
124
|
|
|
125
125
|
declare class QL<T> {
|
|
126
126
|
SELECT : StaticSELECT<T>
|
|
127
|
-
INSERT : typeof INSERT
|
|
127
|
+
INSERT : typeof INSERT
|
|
128
128
|
& ((...entries:object[]) => INSERT<any>) & ((entries:object[]) => INSERT<any>)
|
|
129
129
|
UPSERT: typeof UPSERT
|
|
130
130
|
& ((...entries:object[]) => UPSERT<any>) & ((entries:object[]) => UPSERT<any>)
|
|
131
|
-
UPDATE : typeof UPDATE
|
|
131
|
+
UPDATE : typeof UPDATE
|
|
132
132
|
& typeof UPDATE.entity
|
|
133
133
|
DELETE : typeof DELETE
|
|
134
134
|
CREATE : typeof CREATE
|
|
@@ -146,7 +146,7 @@ export class SELECT<T> extends ConstructedQuery {
|
|
|
146
146
|
static one : SELECT_one & { from: SELECT_one }
|
|
147
147
|
static distinct : typeof SELECT
|
|
148
148
|
static from : SELECT_from
|
|
149
|
-
from: TaggedTemplateQueryPart<this>
|
|
149
|
+
from: TaggedTemplateQueryPart<this>
|
|
150
150
|
& ((entity: Definition | string, primaryKey? : PK, projection? : Projection<unknown>) => this)
|
|
151
151
|
byKey (primaryKey? : PK) : this
|
|
152
152
|
columns: TaggedTemplateQueryPart<this>
|
|
@@ -230,9 +230,9 @@ export class INSERT<T> extends ConstructedQuery {
|
|
|
230
230
|
& ((entity : Definition | string, entries? : object | object[]) => INSERT<any>)
|
|
231
231
|
& (<T> (entity:Constructable<T>, entries? : object | object[]) => INSERT<T>)
|
|
232
232
|
& (<T> (entity:T, entries? : T | object | object[]) => INSERT<T>)
|
|
233
|
-
|
|
234
|
-
into: (<T extends ArrayConstructable> (entity:T) => this)
|
|
235
|
-
& TaggedTemplateQueryPart<this>
|
|
233
|
+
|
|
234
|
+
into: (<T extends ArrayConstructable> (entity:T) => this)
|
|
235
|
+
& TaggedTemplateQueryPart<this>
|
|
236
236
|
& ((entity : Definition | string) => this)
|
|
237
237
|
data (block : (e:T)=>void) : this
|
|
238
238
|
entries (...entries : object[]) : this
|
|
@@ -251,9 +251,9 @@ export class UPSERT<T> extends ConstructedQuery {
|
|
|
251
251
|
& ((entity : Definition | string, entries? : object | object[]) => UPSERT<any>)
|
|
252
252
|
& (<T> (entity:Constructable<T>, entries? : object | object[]) => UPSERT<T>)
|
|
253
253
|
& (<T> (entity:T, entries? : T | object | object[]) => UPSERT<T>)
|
|
254
|
-
|
|
255
|
-
into: (<T extends ArrayConstructable> (entity:T) => this)
|
|
256
|
-
& TaggedTemplateQueryPart<this>
|
|
254
|
+
|
|
255
|
+
into: (<T extends ArrayConstructable> (entity:T) => this)
|
|
256
|
+
& TaggedTemplateQueryPart<this>
|
|
257
257
|
& ((entity : Definition | string) => this)
|
|
258
258
|
data (block : (e:T)=>void) : this
|
|
259
259
|
entries (...entries : object[]) : this
|
|
@@ -290,7 +290,7 @@ export class UPDATE<T> extends ConstructedQuery {
|
|
|
290
290
|
// set (block: (e:T)=>void) : this
|
|
291
291
|
set: TaggedTemplateQueryPart<this>
|
|
292
292
|
& ((data:object) => this)
|
|
293
|
-
with: TaggedTemplateQueryPart<this>
|
|
293
|
+
with: TaggedTemplateQueryPart<this>
|
|
294
294
|
& ((data:object) => this)
|
|
295
295
|
where (predicate:object) : this
|
|
296
296
|
where (...expr : any[]) : this
|
|
@@ -307,4 +307,4 @@ export class CREATE<T> extends ConstructedQuery {
|
|
|
307
307
|
export class DROP<T> extends ConstructedQuery {
|
|
308
308
|
static entity (entity : Definition | string) : DROP<any>
|
|
309
309
|
DROP : CQN.DROP["DROP"]
|
|
310
|
-
}
|
|
310
|
+
}
|
package/apis/serve.d.ts
CHANGED
|
@@ -22,7 +22,7 @@ interface service_options {
|
|
|
22
22
|
[key: string]: unknown
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
export
|
|
25
|
+
export default cds_serve
|
|
26
26
|
declare class cds_serve {
|
|
27
27
|
|
|
28
28
|
/**
|
|
@@ -36,7 +36,7 @@ declare class cds_serve {
|
|
|
36
36
|
*/
|
|
37
37
|
server: cds_server
|
|
38
38
|
|
|
39
|
-
|
|
39
|
+
|
|
40
40
|
|
|
41
41
|
/**
|
|
42
42
|
* Emitted at the very beginning of the bootsrapping process, when the
|
|
@@ -81,18 +81,7 @@ declare class cds_serve {
|
|
|
81
81
|
* Shortcut to base class for all service definitions from linked models.
|
|
82
82
|
* Plus accessors to impl functions and constructed providers.
|
|
83
83
|
*/
|
|
84
|
-
service :
|
|
85
|
-
/**
|
|
86
|
-
* Dummy wrapper for service implementation functions.
|
|
87
|
-
* Use that in modules to get IntelliSense.
|
|
88
|
-
*/
|
|
89
|
-
impl (impl: ServiceImpl) : typeof impl
|
|
90
|
-
impl <T> (srv:T, impl: ( this: T, srv: (T) ) => any) : typeof impl
|
|
91
|
-
/**
|
|
92
|
-
* Array of all services constructed.
|
|
93
|
-
*/
|
|
94
|
-
providers : Service
|
|
95
|
-
}
|
|
84
|
+
service : service
|
|
96
85
|
|
|
97
86
|
/**
|
|
98
87
|
* The effective CDS model loaded during bootstrapping, which contains all service and entity definitions,
|
|
@@ -102,5 +91,19 @@ declare class cds_serve {
|
|
|
102
91
|
|
|
103
92
|
}
|
|
104
93
|
|
|
94
|
+
export type service = LinkedDefinition & {
|
|
95
|
+
/**
|
|
96
|
+
* Dummy wrapper for service implementation functions.
|
|
97
|
+
* Use that in modules to get IntelliSense.
|
|
98
|
+
*/
|
|
99
|
+
impl (impl: ServiceImpl) : typeof impl
|
|
100
|
+
impl <T> (srv:T, impl: ( this: T, srv: (T) ) => any) : typeof impl
|
|
101
|
+
/**
|
|
102
|
+
* Array of all services constructed.
|
|
103
|
+
*/
|
|
104
|
+
providers : Service
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
|
|
105
108
|
declare type cds_services = { [name:string]: Service }
|
|
106
109
|
declare type cds_server = Function
|