@sap/cds 7.4.2 → 7.5.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 +94 -0
- package/apis/cds.d.ts +1 -38
- package/apis/core.d.ts +21 -101
- package/apis/cqn.d.ts +18 -76
- package/apis/csn.d.ts +18 -114
- package/apis/events.d.ts +16 -123
- package/apis/internal/inference.d.ts +18 -32
- package/apis/linked.d.ts +18 -97
- package/apis/log.d.ts +19 -164
- package/apis/models.d.ts +18 -180
- package/apis/ql.d.ts +16 -323
- package/apis/reflect.d.ts +32 -0
- package/apis/server.d.ts +18 -135
- package/apis/services.d.ts +18 -380
- package/bin/cds-serve.js +5 -2
- package/bin/serve.js +7 -16
- package/lib/auth/basic-auth.js +3 -1
- package/lib/auth/ias-auth.js +62 -48
- package/lib/auth/ias-claims.js +34 -0
- package/lib/auth/index.js +54 -33
- package/lib/auth/jwt-auth.js +55 -52
- package/lib/compile/cdsc.js +2 -2
- package/lib/compile/to/edm.js +4 -4
- package/lib/compile/to/hdbtabledata.js +5 -8
- package/lib/compile/to/srvinfo.js +2 -2
- package/lib/env/cds-env.js +3 -9
- package/lib/env/cds-requires.js +16 -17
- package/lib/env/compat.js +0 -9
- package/lib/env/defaults.js +17 -6
- package/lib/i18n/localize.js +46 -42
- package/lib/index.js +6 -8
- package/lib/linked/classes.js +7 -118
- package/lib/linked/entities.js +1 -1
- package/lib/log/cds-log.js +15 -10
- package/lib/log/format/aspects/als.js +41 -0
- package/lib/log/format/aspects/cf.js +36 -0
- package/lib/log/format/json.js +96 -0
- package/lib/plugins.js +7 -3
- package/lib/req/context.js +4 -2
- package/lib/srv/cds-connect.js +3 -5
- package/lib/srv/cds-serve.js +13 -26
- package/lib/srv/factory.js +3 -3
- package/lib/srv/middlewares/index.js +0 -2
- package/lib/srv/middlewares/trace.js +2 -3
- package/lib/srv/protocols/_legacy.js +27 -30
- package/lib/srv/protocols/index.js +173 -58
- package/lib/srv/protocols/odata-v4.js +29 -16
- package/lib/srv/srv-api.js +8 -13
- package/lib/srv/srv-handlers.js +14 -14
- package/lib/utils/cds-utils.js +15 -0
- package/libx/_runtime/auth/index.js +4 -5
- package/libx/_runtime/auth/strategies/basic.js +2 -2
- package/libx/_runtime/cds-services/adapter/odata-v4/OData.js +23 -13
- package/libx/_runtime/cds-services/adapter/odata-v4/ODataRequest.js +6 -15
- package/libx/_runtime/cds-services/adapter/odata-v4/handlers/update.js +10 -3
- package/libx/_runtime/cds-services/adapter/odata-v4/to.js +5 -2
- package/libx/_runtime/cds-services/adapter/odata-v4/utils/metaInfo.js +2 -1
- package/libx/_runtime/cds-services/services/utils/columns.js +3 -9
- package/libx/_runtime/cds.js +13 -0
- package/libx/_runtime/common/composition/data.js +3 -0
- package/libx/_runtime/common/composition/delete.js +1 -1
- package/libx/_runtime/common/error/frontend.js +2 -2
- package/libx/_runtime/common/generic/auth/readOnly.js +1 -1
- package/libx/_runtime/common/generic/auth/restrictions.js +1 -1
- package/libx/_runtime/common/generic/sorting.js +4 -5
- package/libx/_runtime/common/utils/csn.js +23 -18
- package/libx/_runtime/common/utils/restrictions.js +6 -15
- package/libx/_runtime/db/generic/input.js +3 -2
- package/libx/_runtime/fiori/generic/readOverDraft.js +2 -5
- package/libx/_runtime/fiori/lean-draft.js +69 -5
- package/libx/_runtime/hana/Service.js +1 -1
- package/libx/_runtime/messaging/AMQPWebhookMessaging.js +1 -1
- package/libx/_runtime/messaging/Outbox.js +3 -8
- package/libx/_runtime/messaging/enterprise-messaging.js +1 -1
- package/libx/_runtime/messaging/file-based.js +1 -1
- package/libx/_runtime/messaging/service.js +7 -10
- package/libx/_runtime/remote/Service.js +15 -45
- package/libx/_runtime/remote/utils/client.js +20 -33
- package/libx/_runtime/remote/utils/cloudSdkProvider.js +30 -0
- package/libx/_runtime/sqlite/Service.js +2 -2
- package/libx/odata/afterburner.js +29 -21
- package/libx/odata/cqn2odata.js +1 -1
- package/libx/odata/error.js +7 -0
- package/libx/odata/grammar.peggy +16 -20
- package/libx/odata/metadata.js +73 -78
- package/libx/odata/parser.js +1 -1
- package/libx/odata/read.js +94 -0
- package/libx/odata/result.js +91 -0
- package/libx/odata/service-document.js +31 -37
- package/libx/odata/utils.js +2 -1
- package/libx/outbox/index.js +9 -4
- package/libx/rest/RestAdapter.js +68 -67
- package/libx/rest/middleware/create.js +20 -26
- package/libx/rest/middleware/delete.js +5 -3
- package/libx/rest/middleware/error.js +2 -3
- package/libx/rest/middleware/input.js +5 -5
- package/libx/rest/middleware/operation.js +96 -41
- package/libx/rest/middleware/parse.js +4 -6
- package/libx/rest/middleware/payload.js +5 -5
- package/libx/rest/middleware/read.js +11 -17
- package/libx/rest/middleware/update.js +20 -25
- package/package.json +2 -1
- package/server.js +7 -4
- package/srv/outbox.cds +9 -10
- package/apis/env.d.ts +0 -25
- package/apis/test.d.ts +0 -81
- package/apis/utils.d.ts +0 -15
- package/lib/auth/passport-basic.js +0 -14
- package/lib/auth/passport-digest.js +0 -16
- package/lib/env/presets.js +0 -35
- package/lib/log/format/cf.js +0 -16
- package/lib/log/format/kibana.js +0 -92
- package/lib/srv/middlewares/ctx-auth.js +0 -11
- package/libx/_runtime/cds-services/adapter/rest/utils/validation-checks.js +0 -119
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,100 @@
|
|
|
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.5.0 - 2023-12-14
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
|
|
11
|
+
- Support for expressions in where clause of `@restrict` annotation.
|
|
12
|
+
- Example: `@(restrict : [{ grant : ['*'], where : (NAME = $user) }])`
|
|
13
|
+
- Function `cds.unboxed(srv)` to get the non-outboxed variant of the service
|
|
14
|
+
- Service implementations can now be provided in .mjs modules.
|
|
15
|
+
- Remote services: advanced configurable `CSRF` token fetching HTTP method and the URL.
|
|
16
|
+
For example, in the configuration of your remote services, you can now configure the HTTP method and URL as follows:
|
|
17
|
+
```json
|
|
18
|
+
"cds": {
|
|
19
|
+
"requires": {
|
|
20
|
+
"API_BUSINESS_PARTNER": {
|
|
21
|
+
"kind": "odata",
|
|
22
|
+
"model": "srv/external/API_BUSINESS_PARTNER",
|
|
23
|
+
"csrf": { // this configuration implies `csrf: true`
|
|
24
|
+
"method": "get",
|
|
25
|
+
"url": "..."
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
```
|
|
31
|
+
- `cds.log`'s built-in JSON formatter:
|
|
32
|
+
+ Extract custom fields (`cds.env.log.als_custom_fields`) and categories from args (not only error-like first objects)
|
|
33
|
+
* Example: `LOG.info('foo', { query: 'SELECT * FROM DUMMY' }, 'bar', { categories: ['baz'] })`
|
|
34
|
+
+ `cds.env.log.mask_headers = [...]` allows to specify a list of matchers for which the header value shall be masked (i.e., printed as `***`)
|
|
35
|
+
* Default: `['/authorization/i', '/cookie/i']`
|
|
36
|
+
- `cds.env.fiori.bypass_draft` feature flag, designed to enable direct modifications via `POST` and `PATCH` of
|
|
37
|
+
active instances in lean draft mode (`cds.env.fiori.lean_draft=true`). For example:
|
|
38
|
+
|
|
39
|
+
```http
|
|
40
|
+
POST /Orders
|
|
41
|
+
{
|
|
42
|
+
"IsActiveEntity": true
|
|
43
|
+
}
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
- Auth kind `ias`: same SAML attr api as auth kind `xsuaa` for easier migration
|
|
47
|
+
|
|
48
|
+
### Changed
|
|
49
|
+
|
|
50
|
+
- Removed and integrated former `ctx-auth` middleware into `cds.auth` middleware
|
|
51
|
+
- `cds.log`:
|
|
52
|
+
+ `cds.env.log.format = 'plain'|'json'` allows to configure which built-in formatter is used. Defaults to `json` in production, `plain` otherwise.
|
|
53
|
+
+ If built-in JSON formatter is used:
|
|
54
|
+
* Field `tenant_subdomain` is filled if running on CF and information is available through authentication
|
|
55
|
+
* Additional CF-related fields are filled if running on CF
|
|
56
|
+
* Custom fields (`cds.env.log.als_custom_fields`) are filled if bound to an instance of Application Logging Service
|
|
57
|
+
* Field `categories` is filled if bound to an instance of Application Logging Service
|
|
58
|
+
+ Config `cds.env.log.kibana_custom_fields` changed to `cds.env.log.als_custom_fields` (ALS = Application Logging Service) with compatibility until next major
|
|
59
|
+
- Package `passport` is no longer required (if `cds.env.requires.middlewares` is not set to `false`)
|
|
60
|
+
- Type definitions for the APIs of this package are now maintained in package [`@cap-js/cds-types`](https://npmjs.com/package/@cap-js/cds-types).
|
|
61
|
+
- If you used one of the types `CSN`, `Definitions`, `entity` of _@sap/cds/apis/reflect_, use the `Linked` counterparts instead.
|
|
62
|
+
- If you used the type `CQNQuery` of _@sap/cds/apis/cqn_, use `SELECT` or a union type instead.
|
|
63
|
+
- This also includes various fixes to Typings for
|
|
64
|
+
- `req.subject` like `SELECT.from(req.subject)`
|
|
65
|
+
- `SELECT.columns([...])`
|
|
66
|
+
- `cds.db`
|
|
67
|
+
- `cds.util`
|
|
68
|
+
- `cds.context.features`
|
|
69
|
+
- The number of files logged on `cds serve` is now limited to 30 by default. You can run with `DEBUG=serve` to show all files.
|
|
70
|
+
- `express.static` is only mounted if the target folder (`cds.folders.app`) exists
|
|
71
|
+
- `cds.outbox.Messages` no longer uses aspect `cuid` to reduce model size impact in case `@sap/cds/common` is not used otherwise
|
|
72
|
+
|
|
73
|
+
### Fixed
|
|
74
|
+
|
|
75
|
+
- Messaging: Listen to `*`
|
|
76
|
+
- Drafts of `@readonly` entities cannot be deleted
|
|
77
|
+
- Made `srv.prepend()` robust by not allowing async callbacks and hence not being an async function itself anymore
|
|
78
|
+
- Formatting for stringified number-literal value
|
|
79
|
+
- Secrets are now masked with `DEBUG=cds.service.factory`
|
|
80
|
+
- The timestamp of cds.context is not propagated to new root contexts
|
|
81
|
+
- `cds.localize` uses less memory to create translation bundles
|
|
82
|
+
- `UPSERT` operation failed to fill DateTime/Timestamp fields
|
|
83
|
+
- Use original logic (based on `NODE_ENV`) to load cds plugins from `devDependencies`
|
|
84
|
+
- Property `tenant` also available on express' `req` object with basic and mocked auth
|
|
85
|
+
- Empty `req.data` in before `DELETE` handler in draft
|
|
86
|
+
- Loading `cds-plugins` now offers a hook to add more flexible plugin loader, e.g. for corrupt `package.json` files.
|
|
87
|
+
- Ignore default values of associations for draft entities
|
|
88
|
+
- OData: client-side errors (4xx) logged as warnings instead of errors
|
|
89
|
+
- IAS authentication: use `tokenInfo.getClientId()` instead of `payload.azp` as it implements a fallback
|
|
90
|
+
- Deep updates with binary keys
|
|
91
|
+
- Allow `null` values in `cds.env` (example package.json excerpt: `{ "cds": { "features": { "foo": null } } }`)
|
|
92
|
+
- Collection bound actions/functions called via navigation
|
|
93
|
+
|
|
94
|
+
### Removed
|
|
95
|
+
|
|
96
|
+
- Deprecated global configuration feature flag `cds.env.features.fetch_csrf`.
|
|
97
|
+
Instead, please use `csrf` and `csrfInBatch` in the configuration of your remote services.
|
|
98
|
+
These options will allow to configure CSRF-token handling.
|
|
99
|
+
- Compat for deprecated `cds.env.auth.passport`. Use `cds.env.requires.auth` instead.
|
|
100
|
+
|
|
7
101
|
## Version 7.4.2 - 2023-11-30
|
|
8
102
|
|
|
9
103
|
### Fixed
|
package/apis/cds.d.ts
CHANGED
|
@@ -1,40 +1,3 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
|
|
3
|
-
declare global {
|
|
4
|
-
const cds : cds_facade
|
|
5
|
-
}
|
|
1
|
+
import * as cds from '@cap-js/cds-types'
|
|
6
2
|
|
|
7
3
|
export = cds
|
|
8
|
-
|
|
9
|
-
type cds_facade = {}
|
|
10
|
-
& import('./core').default
|
|
11
|
-
& import('./env').default
|
|
12
|
-
& import('./models').default
|
|
13
|
-
& import('./server').default
|
|
14
|
-
& import('./services').QueryAPI
|
|
15
|
-
& import('./services').default
|
|
16
|
-
& import('./events').default
|
|
17
|
-
& import('./ql').cds_ql
|
|
18
|
-
& import('./log')
|
|
19
|
-
& import('./utils')
|
|
20
|
-
& import('./test')
|
|
21
|
-
|
|
22
|
-
declare global {
|
|
23
|
-
// these provide the functionality from SELECT, INSERT, etc in the global facade
|
|
24
|
-
const SELECT: typeof cds.ql.SELECT
|
|
25
|
-
const INSERT: typeof cds.ql.INSERT
|
|
26
|
-
const UPSERT: typeof cds.ql.UPSERT
|
|
27
|
-
const UPDATE: typeof cds.ql.UPDATE
|
|
28
|
-
const DELETE: typeof cds.ql.DELETE
|
|
29
|
-
const CREATE: typeof cds.ql.CREATE
|
|
30
|
-
const DROP: typeof cds.ql.DROP
|
|
31
|
-
|
|
32
|
-
// and these allow us to use them as type too, i.e. `const q: SELECT<Book> = ...`
|
|
33
|
-
type SELECT<T> = ql.SELECT<T>
|
|
34
|
-
type INSERT<T> = ql.INSERT<T>
|
|
35
|
-
type UPSERT<T> = ql.UPSERT<T>
|
|
36
|
-
type UPDATE<T> = ql.UPDATE<T>
|
|
37
|
-
type DELETE<T> = ql.DELETE<T>
|
|
38
|
-
type CREATE<T> = ql.CREATE<T>
|
|
39
|
-
type DROP<T> = ql.DROP<T>
|
|
40
|
-
}
|
package/apis/core.d.ts
CHANGED
|
@@ -1,101 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
classes: {
|
|
23
|
-
Association: Association
|
|
24
|
-
Composition: Composition
|
|
25
|
-
entity: entity
|
|
26
|
-
event: event
|
|
27
|
-
type: type
|
|
28
|
-
array: array
|
|
29
|
-
struct: struct
|
|
30
|
-
service: service
|
|
31
|
-
}
|
|
32
|
-
types: {}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Base class for linked Associations from reflected models.
|
|
37
|
-
* @see [capire](https://cap.cloud.sap/docs/node.js/cds-reflect#cds-Association)
|
|
38
|
-
*/
|
|
39
|
-
Association: Association
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Base class for linked Compositions from reflected models.
|
|
43
|
-
* @see [capire](https://cap.cloud.sap/docs/node.js/cds-reflect#cds-Association)
|
|
44
|
-
*/
|
|
45
|
-
Composition: Composition
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Base class for linked entities from reflected models.
|
|
49
|
-
* @see [capire](https://cap.cloud.sap/docs/node.js/cds-reflect#cds-entity)
|
|
50
|
-
*/
|
|
51
|
-
entity: entity
|
|
52
|
-
|
|
53
|
-
event: event
|
|
54
|
-
type: type
|
|
55
|
-
array: array
|
|
56
|
-
struct: struct
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Add aspects to a given object, for example:
|
|
60
|
-
*
|
|
61
|
-
* extend (Object.prototype) .with (class {
|
|
62
|
-
* get foo() { return ... }
|
|
63
|
-
* bar() {...}
|
|
64
|
-
* }.prototype)
|
|
65
|
-
*/
|
|
66
|
-
extend<T>(target: T): {
|
|
67
|
-
with<E extends readonly unknown[]>(...ext: E): T & Intersect<E>
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Equip a given facade object with getters for lazy-loading modules instead
|
|
72
|
-
* of static requires. Example:
|
|
73
|
-
*
|
|
74
|
-
* const facade = lazify ({
|
|
75
|
-
* sub: lazy => require ('./sub-module')
|
|
76
|
-
* })
|
|
77
|
-
*
|
|
78
|
-
* The first usage of `facade.sub` will load the sub module
|
|
79
|
-
* using standard Node.js's `module.require` functions.
|
|
80
|
-
*/
|
|
81
|
-
lazify <T>(target: T) : T
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* Prepare a node module for lazy-loading submodules instead
|
|
85
|
-
* of static requires. Example:
|
|
86
|
-
*
|
|
87
|
-
* require = lazify (module) //> turns require into a lazy one
|
|
88
|
-
* const facade = module.exports = {
|
|
89
|
-
* sub: require ('./sub-module')
|
|
90
|
-
* })
|
|
91
|
-
*
|
|
92
|
-
* The first usage of `facade.sub` will load the sub module
|
|
93
|
-
* using standard Node.js's `module.require` functions.
|
|
94
|
-
*/
|
|
95
|
-
lazified <T>(target: T) : T
|
|
96
|
-
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
type Intersect<T extends readonly unknown[]> = T extends [infer Head, ...infer Tail]
|
|
100
|
-
? Head & Intersect<Tail>
|
|
101
|
-
: unknown
|
|
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/core'
|
|
19
|
+
|
|
20
|
+
// this was moved to 'events' with 7.4
|
|
21
|
+
export { User } from '@cap-js/cds-types'
|
package/apis/cqn.d.ts
CHANGED
|
@@ -1,76 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
export type INSERT = {INSERT:{
|
|
21
|
-
into : ref | name
|
|
22
|
-
entries : data[]
|
|
23
|
-
columns : string[]
|
|
24
|
-
values : scalar[]
|
|
25
|
-
rows : scalar[][]
|
|
26
|
-
as : SELECT
|
|
27
|
-
}}
|
|
28
|
-
|
|
29
|
-
export type UPSERT = {UPSERT:{
|
|
30
|
-
into : ref | name
|
|
31
|
-
columns : string[]
|
|
32
|
-
entries : data[]
|
|
33
|
-
values : scalar[]
|
|
34
|
-
rows : scalar[][]
|
|
35
|
-
}}
|
|
36
|
-
|
|
37
|
-
export type UPDATE = {UPDATE:{
|
|
38
|
-
entity : ref | name
|
|
39
|
-
data : { [key:string] : expr }
|
|
40
|
-
where? : predicate
|
|
41
|
-
}}
|
|
42
|
-
|
|
43
|
-
export type DELETE = {DELETE:{
|
|
44
|
-
from : ref | name
|
|
45
|
-
where? : predicate
|
|
46
|
-
}}
|
|
47
|
-
|
|
48
|
-
export type CREATE = {CREATE:{
|
|
49
|
-
entity : entity | name
|
|
50
|
-
as: SELECT
|
|
51
|
-
}}
|
|
52
|
-
|
|
53
|
-
export type DROP = {DROP:{
|
|
54
|
-
entity : name
|
|
55
|
-
table: ref
|
|
56
|
-
view: ref
|
|
57
|
-
}}
|
|
58
|
-
|
|
59
|
-
type scalar = number | string | boolean | null
|
|
60
|
-
type data = Record<string,any>
|
|
61
|
-
type name = string
|
|
62
|
-
type source = ( ref | SELECT ) & { as?: name, join?:name, on?:xpr }
|
|
63
|
-
export type column_expr = expr & { as?: name, cast?:any, expand?: column_expr[], inline?: column_expr[] }
|
|
64
|
-
export type predicate = _xpr
|
|
65
|
-
type ordering_term = expr & { sort?: "asc"|"desc", nulls?: "first"|"last" }
|
|
66
|
-
|
|
67
|
-
export type expr = ref | val | xpr | function_call | SELECT
|
|
68
|
-
type ref = {ref:( name & { id?:string, where?:expr, args?:expr[] } )[]}
|
|
69
|
-
type val = {val:any}
|
|
70
|
-
type xpr = {xpr:_xpr}
|
|
71
|
-
type _xpr = ( expr | operator ) []
|
|
72
|
-
type operator = string
|
|
73
|
-
type function_call = {func: string, args: {[key: string]: unknown}[]}
|
|
74
|
-
|
|
75
|
-
export type enum_literal = {"#": string}
|
|
76
|
-
export type expr_literal = {"=": string}
|
|
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/cqn'
|
package/apis/csn.d.ts
CHANGED
|
@@ -1,117 +1,21 @@
|
|
|
1
|
-
import { SELECT, ref, predicate } from './cqn'
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* A parsed CDS model in CSN object notation.
|
|
5
|
-
*/
|
|
6
|
-
export interface CSN {
|
|
7
|
-
/**
|
|
8
|
-
* The assigned namespace. If parsed from multiple sources,
|
|
9
|
-
* this is the topmost model's namespace, if any, not the
|
|
10
|
-
* ones of imported models.
|
|
11
|
-
*/
|
|
12
|
-
namespace?: string
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* The list of usings in this parsed model. Not available after
|
|
16
|
-
* imports have been resolved into a merged model.
|
|
17
|
-
*/
|
|
18
|
-
requires?: string[]
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* All definitions in the model including those from imported models.
|
|
22
|
-
*/
|
|
23
|
-
definitions?: Record<FQN, Definition>
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* All extensions in the model including those from imported models.
|
|
27
|
-
* Not available after extensions have been applied.
|
|
28
|
-
*/
|
|
29
|
-
extensions?: Extension[]
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* The names of the files from which this model has been loaded.
|
|
33
|
-
*/
|
|
34
|
-
$sources?: string[]
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* The fully-quality name of a definition.
|
|
39
|
-
*/
|
|
40
|
-
export type FQN = string
|
|
41
|
-
|
|
42
1
|
/**
|
|
43
|
-
*
|
|
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
|
|
44
17
|
*/
|
|
45
|
-
export
|
|
46
|
-
// NOTE: If we use & instead of | CSN.definitions values would be reduced to <never>
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Extensions capture extend Foo with { ... } directives.
|
|
50
|
-
*/
|
|
51
|
-
export type Extension = {
|
|
52
|
-
extend: FQN
|
|
53
|
-
elements?: { [name: string]: Element }
|
|
54
|
-
includes?: FQN[]
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export type Element = type & struct & Association
|
|
58
|
-
|
|
59
|
-
export type kinds = 'type' | 'entity' | 'event' | 'service' | 'context' | 'struct'
|
|
60
|
-
|
|
61
|
-
export interface any_ { kind?: kinds }
|
|
62
|
-
export interface context extends any_ { }
|
|
63
|
-
export interface service extends any_ { }
|
|
64
|
-
|
|
65
|
-
export interface type extends any_ {
|
|
66
|
-
type?: FQN
|
|
67
|
-
items?: type
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
export interface struct extends type {
|
|
71
|
-
/**
|
|
72
|
-
* References to definitions to be included.
|
|
73
|
-
* Not available after extensions have been applied.
|
|
74
|
-
*/
|
|
75
|
-
includes?: FQN[]
|
|
76
|
-
elements: { [name: string]: Element }
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
export interface entity extends Omit<struct,'elements'> {
|
|
80
|
-
/**
|
|
81
|
-
* Entities with a query signify a view
|
|
82
|
-
*/
|
|
83
|
-
query?: SELECT
|
|
84
|
-
/**
|
|
85
|
-
* Elements of entities may have additional qualifiers
|
|
86
|
-
*/
|
|
87
|
-
elements : EntityElements
|
|
88
|
-
// REVISIT: following should move to LinkedCSN
|
|
89
|
-
keys: { [name: string]: Definition }
|
|
90
|
-
drafts: entity
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
export type EntityElements = {
|
|
94
|
-
[name:string]: Element & {
|
|
95
|
-
key? : boolean
|
|
96
|
-
virtual? : boolean
|
|
97
|
-
unique? : boolean
|
|
98
|
-
notNull? : boolean
|
|
99
|
-
}
|
|
100
|
-
}
|
|
18
|
+
export * from '@cap-js/cds-types/apis/csn'
|
|
101
19
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
target: FQN
|
|
105
|
-
/**
|
|
106
|
-
* The specified cardinality. to-one = {max:1}, to-many = {max:'*'}
|
|
107
|
-
*/
|
|
108
|
-
cardinality?: { src?: 1; min?: 1 | 0; max?: 1 | '*' }
|
|
109
|
-
/**
|
|
110
|
-
* The parsed on condition in case of unmanaged Associations
|
|
111
|
-
*/
|
|
112
|
-
on?: predicate
|
|
113
|
-
/**
|
|
114
|
-
* The optionally specified keys in case of managed Associations
|
|
115
|
-
*/
|
|
116
|
-
keys?: (ref & { as: string })[]
|
|
117
|
-
}
|
|
20
|
+
// this got moved to 'linked' with 7.4
|
|
21
|
+
export { Definitions } from '@cap-js/cds-types/apis/linked'
|
package/apis/events.d.ts
CHANGED
|
@@ -1,125 +1,18 @@
|
|
|
1
|
-
import { LinkedDefinition } from './linked'
|
|
2
|
-
import { Query } from './cqn'
|
|
3
|
-
import { ref } from './cqn'
|
|
4
|
-
import * as express from "express"
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export default class cds {
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* @see [capire docs](https://cap.cloud.sap/docs/node.js/events)
|
|
11
|
-
*/
|
|
12
|
-
EventContext: typeof EventContext
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* @see [capire docs](https://cap.cloud.sap/docs/node.js/events)
|
|
16
|
-
*/
|
|
17
|
-
Event: typeof Event
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* @see [capire docs](https://cap.cloud.sap/docs/node.js/events)
|
|
21
|
-
*/
|
|
22
|
-
Request: typeof Request
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Represents the user in a given context.
|
|
26
|
-
* @see [capire docs](https://cap.cloud.sap/docs/node.js/authentication#cds-user)
|
|
27
|
-
*/
|
|
28
|
-
User: typeof User
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
|
|
32
1
|
/**
|
|
33
|
-
*
|
|
34
|
-
*
|
|
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
|
|
35
17
|
*/
|
|
36
|
-
export
|
|
37
|
-
constructor(properties:{event:string, data?:object, query?:object, headers:object});
|
|
38
|
-
http?: {req: express.Request, res: express.Response}
|
|
39
|
-
tenant: string
|
|
40
|
-
user: User
|
|
41
|
-
id: string
|
|
42
|
-
locale: `${string}_${string}`
|
|
43
|
-
timestamp: Date
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* @see [capire docs](https://cap.cloud.sap/docs/node.js/events)
|
|
48
|
-
*/
|
|
49
|
-
export class Event extends EventContext {
|
|
50
|
-
event: string
|
|
51
|
-
data: any
|
|
52
|
-
headers: any
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* @see [capire docs](https://cap.cloud.sap/docs/node.js/events)
|
|
57
|
-
*/
|
|
58
|
-
export class Request extends Event {
|
|
59
|
-
params: (string | {})[]
|
|
60
|
-
method: string
|
|
61
|
-
path: string
|
|
62
|
-
target: LinkedDefinition
|
|
63
|
-
/**
|
|
64
|
-
* Shortcut to {@link target.name}
|
|
65
|
-
* @see https://cap.cloud.sap/docs/node.js/events#req-entity
|
|
66
|
-
*/
|
|
67
|
-
entity: string
|
|
68
|
-
query: Query
|
|
69
|
-
subject: ref
|
|
70
|
-
|
|
71
|
-
reply(results: any): void
|
|
72
|
-
|
|
73
|
-
notify(code: number, message: string, target?: string, args?: any[]): Error
|
|
74
|
-
info(code: number, message: string, target?: string, args?: any[]): Error
|
|
75
|
-
warn(code: number, message: string, target?: string, args?: any[]): Error
|
|
76
|
-
error(code: number, message: string, target?: string, args?: any[]): Error
|
|
77
|
-
reject(code: number, message: string, target?: string, args?: any[]): Error
|
|
78
|
-
|
|
79
|
-
notify(code: number, message: string, args?: any[]): Error
|
|
80
|
-
info(code: number, message: string, args?: any[]): Error
|
|
81
|
-
warn(code: number, message: string, args?: any[]): Error
|
|
82
|
-
error(code: number, message: string, args?: any[]): Error
|
|
83
|
-
reject(code: number, message: string, args?: any[]): Error
|
|
84
|
-
|
|
85
|
-
notify(message: string, target?: string, args?: any[]): Error
|
|
86
|
-
info(message: string, target?: string, args?: any[]): Error
|
|
87
|
-
warn(message: string, target?: string, args?: any[]): Error
|
|
88
|
-
error(message: string, target?: string, args?: any[]): Error
|
|
89
|
-
reject(message: string, target?: string, args?: any[]): Error
|
|
90
|
-
|
|
91
|
-
notify(message: { code?: number | string; message: string; target?: string; args?: any[] }): Error
|
|
92
|
-
info(message: { code?: number | string; message: string; target?: string; args?: any[] }): Error
|
|
93
|
-
warn(message: { code?: number | string; message: string; target?: string; args?: any[] }): Error
|
|
94
|
-
error(message: { code?: number | string; message: string; target?: string; args?: any[], status?: number }): Error
|
|
95
|
-
reject(message: { code?: number | string; message: string; target?: string; args?: any[], status?: number }): Error
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
export class User {
|
|
100
|
-
constructor(obj?: string | { id: string; attr: Record<string, string>; roles: Record<string, string> } | User)
|
|
101
|
-
id: string
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* @deprecated Use https://cap.cloud.sap/docs/node.js/events#locale instead
|
|
105
|
-
*/
|
|
106
|
-
locale: string
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* @deprecated Use https://cap.cloud.sap/docs/node.js/events#tenant instead
|
|
110
|
-
*/
|
|
111
|
-
tenant: string | undefined
|
|
112
|
-
|
|
113
|
-
attr: Record<string, string>
|
|
114
|
-
roles: Array<string> | Record<string, string>
|
|
115
|
-
static Privileged: typeof Privileged
|
|
116
|
-
is(role: string): boolean
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* Subclass for executing code with superuser privileges.
|
|
121
|
-
*/
|
|
122
|
-
declare class Privileged extends User {
|
|
123
|
-
constructor()
|
|
124
|
-
is(): boolean
|
|
125
|
-
}
|
|
18
|
+
export * from '@cap-js/cds-types/apis/events'
|
|
@@ -1,32 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
export type SingularType<T extends ArrayConstructable<T>> = InstanceType<T>[number]
|
|
20
|
-
|
|
21
|
-
// Convenient way of unwrapping the inner type from array-typed values, as well as the value type itself
|
|
22
|
-
// `class MyArray<T> extends Array<T>``
|
|
23
|
-
// The latter is used heavily in the CDS typer, but its behaviour depends based on how the types are imported:
|
|
24
|
-
// If they are imported on a value based (`require('path/to/type')`) they will be considered `ArrayConstructable`.
|
|
25
|
-
// But if they are being used on type level (JSDOC: `/* @type {import('path/to/type')} */`) they are considered an `Array` .
|
|
26
|
-
// This type introduces an indirection that streamlines their behaviour for both cases.
|
|
27
|
-
// For any scalar type `Unwrap` behaves idempotent.
|
|
28
|
-
export type Unwrap<T> = T extends ArrayConstructable
|
|
29
|
-
? SingularType<T>
|
|
30
|
-
: T extends Array<infer U>
|
|
31
|
-
? U
|
|
32
|
-
: T
|
|
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/internal/inference'
|