@sap/cds 7.4.2 → 7.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (115) hide show
  1. package/CHANGELOG.md +100 -0
  2. package/apis/cds.d.ts +1 -38
  3. package/apis/core.d.ts +21 -101
  4. package/apis/cqn.d.ts +18 -76
  5. package/apis/csn.d.ts +18 -114
  6. package/apis/events.d.ts +16 -123
  7. package/apis/internal/inference.d.ts +18 -32
  8. package/apis/linked.d.ts +18 -97
  9. package/apis/log.d.ts +19 -164
  10. package/apis/models.d.ts +18 -180
  11. package/apis/ql.d.ts +16 -323
  12. package/apis/reflect.d.ts +32 -0
  13. package/apis/server.d.ts +18 -135
  14. package/apis/services.d.ts +18 -380
  15. package/bin/cds-serve.js +5 -2
  16. package/bin/serve.js +7 -16
  17. package/lib/auth/basic-auth.js +3 -1
  18. package/lib/auth/ias-auth.js +62 -48
  19. package/lib/auth/ias-claims.js +34 -0
  20. package/lib/auth/index.js +55 -33
  21. package/lib/auth/jwt-auth.js +55 -52
  22. package/lib/compile/cdsc.js +2 -2
  23. package/lib/compile/to/edm.js +4 -4
  24. package/lib/compile/to/hdbtabledata.js +5 -8
  25. package/lib/compile/to/srvinfo.js +2 -2
  26. package/lib/env/cds-env.js +3 -9
  27. package/lib/env/cds-requires.js +16 -17
  28. package/lib/env/compat.js +0 -9
  29. package/lib/env/defaults.js +17 -6
  30. package/lib/i18n/localize.js +46 -42
  31. package/lib/index.js +6 -8
  32. package/lib/linked/classes.js +7 -118
  33. package/lib/linked/entities.js +1 -1
  34. package/lib/log/cds-log.js +15 -10
  35. package/lib/log/format/aspects/als.js +41 -0
  36. package/lib/log/format/aspects/cf.js +36 -0
  37. package/lib/log/format/json.js +96 -0
  38. package/lib/plugins.js +7 -3
  39. package/lib/req/context.js +4 -2
  40. package/lib/srv/cds-connect.js +3 -5
  41. package/lib/srv/cds-serve.js +13 -26
  42. package/lib/srv/factory.js +3 -3
  43. package/lib/srv/middlewares/index.js +0 -2
  44. package/lib/srv/middlewares/trace.js +2 -3
  45. package/lib/srv/protocols/_legacy.js +27 -30
  46. package/lib/srv/protocols/index.js +173 -58
  47. package/lib/srv/protocols/odata-v4.js +29 -16
  48. package/lib/srv/srv-api.js +8 -13
  49. package/lib/srv/srv-handlers.js +14 -14
  50. package/lib/utils/cds-utils.js +15 -0
  51. package/libx/_runtime/auth/index.js +4 -5
  52. package/libx/_runtime/auth/strategies/basic.js +2 -2
  53. package/libx/_runtime/cds-services/adapter/odata-v4/OData.js +23 -13
  54. package/libx/_runtime/cds-services/adapter/odata-v4/ODataRequest.js +6 -15
  55. package/libx/_runtime/cds-services/adapter/odata-v4/handlers/update.js +10 -3
  56. package/libx/_runtime/cds-services/adapter/odata-v4/to.js +5 -2
  57. package/libx/_runtime/cds-services/adapter/odata-v4/utils/metaInfo.js +2 -1
  58. package/libx/_runtime/cds-services/services/utils/columns.js +3 -9
  59. package/libx/_runtime/cds.js +13 -0
  60. package/libx/_runtime/common/composition/data.js +3 -0
  61. package/libx/_runtime/common/composition/delete.js +1 -1
  62. package/libx/_runtime/common/error/frontend.js +2 -2
  63. package/libx/_runtime/common/generic/auth/readOnly.js +1 -1
  64. package/libx/_runtime/common/generic/auth/restrictions.js +1 -1
  65. package/libx/_runtime/common/generic/sorting.js +4 -5
  66. package/libx/_runtime/common/utils/csn.js +23 -18
  67. package/libx/_runtime/common/utils/restrictions.js +6 -15
  68. package/libx/_runtime/db/generic/input.js +3 -2
  69. package/libx/_runtime/fiori/generic/readOverDraft.js +2 -5
  70. package/libx/_runtime/fiori/lean-draft.js +69 -5
  71. package/libx/_runtime/hana/Service.js +1 -1
  72. package/libx/_runtime/messaging/AMQPWebhookMessaging.js +1 -1
  73. package/libx/_runtime/messaging/Outbox.js +3 -8
  74. package/libx/_runtime/messaging/enterprise-messaging-utils/registerEndpoints.js +1 -0
  75. package/libx/_runtime/messaging/enterprise-messaging.js +1 -1
  76. package/libx/_runtime/messaging/file-based.js +1 -1
  77. package/libx/_runtime/messaging/service.js +7 -10
  78. package/libx/_runtime/remote/Service.js +15 -45
  79. package/libx/_runtime/remote/utils/client.js +20 -33
  80. package/libx/_runtime/remote/utils/cloudSdkProvider.js +30 -0
  81. package/libx/_runtime/sqlite/Service.js +2 -2
  82. package/libx/odata/afterburner.js +29 -21
  83. package/libx/odata/cqn2odata.js +1 -1
  84. package/libx/odata/error.js +7 -0
  85. package/libx/odata/grammar.peggy +16 -20
  86. package/libx/odata/metadata.js +73 -78
  87. package/libx/odata/parser.js +1 -1
  88. package/libx/odata/read.js +94 -0
  89. package/libx/odata/result.js +91 -0
  90. package/libx/odata/service-document.js +31 -37
  91. package/libx/odata/utils.js +2 -1
  92. package/libx/outbox/index.js +9 -4
  93. package/libx/rest/RestAdapter.js +68 -67
  94. package/libx/rest/middleware/create.js +20 -26
  95. package/libx/rest/middleware/delete.js +5 -3
  96. package/libx/rest/middleware/error.js +2 -3
  97. package/libx/rest/middleware/input.js +5 -5
  98. package/libx/rest/middleware/operation.js +96 -41
  99. package/libx/rest/middleware/parse.js +4 -6
  100. package/libx/rest/middleware/payload.js +5 -5
  101. package/libx/rest/middleware/read.js +11 -17
  102. package/libx/rest/middleware/update.js +20 -25
  103. package/package.json +2 -1
  104. package/server.js +7 -4
  105. package/srv/outbox.cds +9 -10
  106. package/apis/env.d.ts +0 -25
  107. package/apis/test.d.ts +0 -81
  108. package/apis/utils.d.ts +0 -15
  109. package/lib/auth/passport-basic.js +0 -14
  110. package/lib/auth/passport-digest.js +0 -16
  111. package/lib/env/presets.js +0 -35
  112. package/lib/log/format/cf.js +0 -16
  113. package/lib/log/format/kibana.js +0 -92
  114. package/lib/srv/middlewares/ctx-auth.js +0 -11
  115. package/libx/_runtime/cds-services/adapter/rest/utils/validation-checks.js +0 -119
package/CHANGELOG.md CHANGED
@@ -4,6 +4,106 @@
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.1 - 2023-12-21
8
+
9
+ ### Fixed
10
+
11
+ - Resolving custom authentication implementation pointer
12
+
13
+ ## Version 7.5.0 - 2023-12-14
14
+
15
+ ### Added
16
+
17
+ - Support for expressions in where clause of `@restrict` annotation.
18
+ - Example: `@(restrict : [{ grant : ['*'], where : (NAME = $user) }])`
19
+ - Function `cds.unboxed(srv)` to get the non-outboxed variant of the service
20
+ - Service implementations can now be provided in .mjs modules.
21
+ - Remote services: advanced configurable `CSRF` token fetching HTTP method and the URL.
22
+ For example, in the configuration of your remote services, you can now configure the HTTP method and URL as follows:
23
+ ```json
24
+ "cds": {
25
+ "requires": {
26
+ "API_BUSINESS_PARTNER": {
27
+ "kind": "odata",
28
+ "model": "srv/external/API_BUSINESS_PARTNER",
29
+ "csrf": { // this configuration implies `csrf: true`
30
+ "method": "get",
31
+ "url": "..."
32
+ }
33
+ }
34
+ }
35
+ }
36
+ ```
37
+ - `cds.log`'s built-in JSON formatter:
38
+ + Extract custom fields (`cds.env.log.als_custom_fields`) and categories from args (not only error-like first objects)
39
+ * Example: `LOG.info('foo', { query: 'SELECT * FROM DUMMY' }, 'bar', { categories: ['baz'] })`
40
+ + `cds.env.log.mask_headers = [...]` allows to specify a list of matchers for which the header value shall be masked (i.e., printed as `***`)
41
+ * Default: `['/authorization/i', '/cookie/i']`
42
+ - `cds.env.fiori.bypass_draft` feature flag, designed to enable direct modifications via `POST` and `PATCH` of
43
+ active instances in lean draft mode (`cds.env.fiori.lean_draft=true`). For example:
44
+
45
+ ```http
46
+ POST /Orders
47
+ {
48
+ "IsActiveEntity": true
49
+ }
50
+ ```
51
+
52
+ - Auth kind `ias`: same SAML attr api as auth kind `xsuaa` for easier migration
53
+
54
+ ### Changed
55
+
56
+ - Removed and integrated former `ctx-auth` middleware into `cds.auth` middleware
57
+ - `cds.log`:
58
+ + `cds.env.log.format = 'plain'|'json'` allows to configure which built-in formatter is used. Defaults to `json` in production, `plain` otherwise.
59
+ + If built-in JSON formatter is used:
60
+ * Field `tenant_subdomain` is filled if running on CF and information is available through authentication
61
+ * Additional CF-related fields are filled if running on CF
62
+ * Custom fields (`cds.env.log.als_custom_fields`) are filled if bound to an instance of Application Logging Service
63
+ * Field `categories` is filled if bound to an instance of Application Logging Service
64
+ + Config `cds.env.log.kibana_custom_fields` changed to `cds.env.log.als_custom_fields` (ALS = Application Logging Service) with compatibility until next major
65
+ - Package `passport` is no longer required (if `cds.env.requires.middlewares` is not set to `false`)
66
+ - 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).
67
+ - If you used one of the types `CSN`, `Definitions`, `entity` of _@sap/cds/apis/reflect_, use the `Linked` counterparts instead.
68
+ - If you used the type `CQNQuery` of _@sap/cds/apis/cqn_, use `SELECT` or a union type instead.
69
+ - This also includes various fixes to Typings for
70
+ - `req.subject` like `SELECT.from(req.subject)`
71
+ - `SELECT.columns([...])`
72
+ - `cds.db`
73
+ - `cds.util`
74
+ - `cds.context.features`
75
+ - 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.
76
+ - `express.static` is only mounted if the target folder (`cds.folders.app`) exists
77
+ - `cds.outbox.Messages` no longer uses aspect `cuid` to reduce model size impact in case `@sap/cds/common` is not used otherwise
78
+
79
+ ### Fixed
80
+
81
+ - Messaging: Listen to `*`
82
+ - Drafts of `@readonly` entities cannot be deleted
83
+ - Made `srv.prepend()` robust by not allowing async callbacks and hence not being an async function itself anymore
84
+ - Formatting for stringified number-literal value
85
+ - Secrets are now masked with `DEBUG=cds.service.factory`
86
+ - The timestamp of cds.context is not propagated to new root contexts
87
+ - `cds.localize` uses less memory to create translation bundles
88
+ - `UPSERT` operation failed to fill DateTime/Timestamp fields
89
+ - Use original logic (based on `NODE_ENV`) to load cds plugins from `devDependencies`
90
+ - Property `tenant` also available on express' `req` object with basic and mocked auth
91
+ - Empty `req.data` in before `DELETE` handler in draft
92
+ - Loading `cds-plugins` now offers a hook to add more flexible plugin loader, e.g. for corrupt `package.json` files.
93
+ - Ignore default values of associations for draft entities
94
+ - OData: client-side errors (4xx) logged as warnings instead of errors
95
+ - IAS authentication: use `tokenInfo.getClientId()` instead of `payload.azp` as it implements a fallback
96
+ - Deep updates with binary keys
97
+ - Allow `null` values in `cds.env` (example package.json excerpt: `{ "cds": { "features": { "foo": null } } }`)
98
+ - Collection bound actions/functions called via navigation
99
+
100
+ ### Removed
101
+
102
+ - Deprecated global configuration feature flag `cds.env.features.fetch_csrf`.
103
+ Instead, please use `csrf` and `csrfInBatch` in the configuration of your remote services.
104
+ These options will allow to configure CSRF-token handling.
105
+ - Compat for deprecated `cds.env.auth.passport`. Use `cds.env.requires.auth` instead.
106
+
7
107
  ## Version 7.4.2 - 2023-11-30
8
108
 
9
109
  ### Fixed
package/apis/cds.d.ts CHANGED
@@ -1,40 +1,3 @@
1
- import * as ql from './ql'
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
- import { LinkedAssociation, LinkedEntity, linked } from './linked'
2
- import * as csn from './csn'
3
- import { service } from './server'
4
-
5
- // These are classes actually -> using the new() => interface trick
6
- export type Association = new(_?:object) => LinkedAssociation
7
- export type Composition = new(_?:object) => LinkedAssociation
8
- export type entity = new(_?:object) => LinkedEntity
9
- export type event = new(_?:object) => linked & csn.struct
10
- export type type = new(_?:object) => linked & csn.type
11
- export type array = new(_?:object) => linked & csn.type
12
- export type struct = new(_?:object) => linked & csn.struct
13
-
14
- export default class cds {
15
- // infer (query : cqn, model : csn) : LinkedDefinition
16
-
17
- builtin: {
18
- /**
19
- * Base classes of linked definitions from reflected models.
20
- * @see [capire](https://cap.cloud.sap/docs/node.js/cds-reflect#cds-builtin-classes)
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
- import { entity } from "./csn" // cyclic dependency
2
-
3
- // FIXME: a union type would be more appropriate here
4
- export type Query = Partial<SELECT & INSERT & UPDATE & DELETE & CREATE & DROP & UPSERT>
5
-
6
- export type SELECT = {SELECT:{
7
- distinct?: true
8
- one? : boolean
9
- from : source
10
- mixin?: {[key:string]: expr}
11
- columns? : column_expr[]
12
- excluding? : string[]
13
- where? : predicate
14
- having? : predicate
15
- groupBy? : expr[]
16
- orderBy? : ordering_term[]
17
- limit?: { rows:val, offset:val }
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
- * Definitions are the central elements of a CDS model.
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 type Definition = context & service & type & struct & entity & Association
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
- export interface Association extends type {
103
- type: 'cds.Association' | 'cds.Composition'
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
- * Represents the invocation context of incoming request and event messages.
34
- * @see [capire docs](https://cap.cloud.sap/docs/node.js/events)
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 class EventContext {
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'