@sap/cds 7.3.1 → 7.4.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.
- package/CHANGELOG.md +69 -3
- package/_i18n/i18n_es_MX.properties +110 -0
- package/apis/cds.d.ts +13 -12
- package/apis/core.d.ts +27 -108
- package/apis/cqn.d.ts +15 -18
- package/apis/csn.d.ts +95 -60
- package/apis/env.d.ts +25 -0
- package/apis/events.d.ts +125 -0
- package/apis/{reflect.d.ts → linked.d.ts} +29 -38
- package/apis/models.d.ts +60 -45
- package/apis/ql.d.ts +19 -5
- package/apis/{serve.d.ts → server.d.ts} +59 -33
- package/apis/services.d.ts +76 -147
- package/apis/test.d.ts +1 -1
- package/bin/serve.js +3 -0
- package/lib/compile/cds-compile.js +2 -2
- package/lib/compile/etc/csv.js +2 -1
- package/lib/compile/to/edm.js +8 -3
- package/lib/compile/to/gql.js +4 -0
- package/lib/dbs/cds-deploy.js +52 -4
- package/lib/env/cds-requires.js +27 -15
- package/lib/env/defaults.js +1 -0
- package/lib/env/schemas/index.js +10 -0
- package/lib/index.js +7 -4
- package/lib/linked/models.js +8 -5
- package/lib/ql/CREATE.js +2 -0
- package/lib/ql/DELETE.js +1 -0
- package/lib/ql/DROP.js +2 -0
- package/lib/ql/INSERT.js +2 -22
- package/lib/ql/Query.js +59 -22
- package/lib/ql/SELECT.js +5 -0
- package/lib/ql/STREAM.js +2 -0
- package/lib/ql/UPDATE.js +2 -0
- package/lib/ql/UPSERT.js +3 -1
- package/lib/ql/cds-ql.js +21 -5
- package/lib/ql/infer.js +129 -0
- package/lib/req/cds-context.js +8 -5
- package/lib/srv/cds-connect.js +3 -1
- package/lib/utils/axios.js +4 -2
- package/lib/utils/data.js +3 -0
- package/libx/_runtime/cds-services/adapter/odata-v4/handlers/error.js +12 -0
- package/libx/_runtime/cds-services/adapter/odata-v4/handlers/metadata.js +27 -9
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/batch/BatchProcessor.js +1 -1
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/serializer/TrustedResourceJsonSerializer.js +8 -1
- package/libx/_runtime/cds-services/adapter/odata-v4/utils/data.js +11 -8
- package/libx/_runtime/common/code-ext/worker.js +5 -16
- package/libx/_runtime/common/generic/auth/capabilities.js +11 -2
- package/libx/_runtime/common/i18n/messages.properties +1 -0
- package/libx/_runtime/common/utils/postProcessing.js +1 -1
- package/libx/_runtime/common/utils/resolveView.js +28 -9
- package/libx/{common → _runtime/common}/utils/ucsn.js +19 -11
- package/libx/_runtime/db/expand/expandCQNToJoin.js +6 -6
- package/libx/_runtime/db/expand/rawToExpanded.js +4 -4
- package/libx/_runtime/db/sql-builder/InsertBuilder.js +6 -1
- package/libx/_runtime/db/sql-builder/UpdateBuilder.js +6 -1
- package/libx/_runtime/db/sql-builder/dollar.js +7 -7
- package/libx/_runtime/fiori/generic/activate.js +2 -2
- package/libx/_runtime/fiori/generic/edit.js +25 -45
- package/libx/_runtime/fiori/generic/read.js +3 -5
- package/libx/_runtime/fiori/lean-draft.js +171 -84
- package/libx/_runtime/fiori/utils/delete.js +7 -1
- package/libx/_runtime/fiori/utils/handler.js +4 -6
- package/libx/_runtime/fiori/utils/lockInfo.js +27 -0
- package/libx/_runtime/fiori/utils/where.js +20 -1
- package/libx/_runtime/messaging/AMQPWebhookMessaging.js +3 -2
- package/libx/_runtime/messaging/Outbox.js +12 -47
- package/libx/_runtime/messaging/common-utils/AMQPClient.js +1 -3
- package/libx/_runtime/messaging/common-utils/authorizedRequest.js +3 -0
- package/libx/_runtime/messaging/common-utils/connections.js +1 -1
- package/libx/_runtime/messaging/enterprise-messaging.js +12 -13
- package/libx/_runtime/messaging/file-based.js +7 -5
- package/libx/_runtime/messaging/redis-messaging.js +10 -11
- package/libx/_runtime/messaging/service.js +12 -26
- package/libx/_runtime/remote/Service.js +52 -36
- package/libx/_runtime/remote/utils/client.js +24 -125
- package/libx/odata/afterburner.js +16 -6
- package/libx/odata/grammar.peggy +26 -7
- package/libx/odata/metadata.js +18 -1
- package/libx/odata/parser.js +1 -1
- package/libx/odata/service-document.js +0 -1
- package/libx/odata/utils.js +19 -3
- package/libx/{_runtime/messaging/outbox/utils.js → outbox/index.js} +94 -24
- package/libx/rest/middleware/parse.js +1 -1
- package/package.json +2 -2
- package/apis/connect.d.ts +0 -39
- package/bin/utils/modules.js +0 -7
- package/bin/utils/term.js +0 -56
- package/lib/env/schema.js +0 -9
- package/lib/linked/queries.js +0 -41
- package/lib/srv/protocols/odata-v2-proxy.js +0 -3699
- package/libx/common/asserts.js +0 -0
- package/libx/common/crud.js +0 -0
- package/libx/common/etag.js +0 -0
- package/libx/common/localized.js +0 -0
- package/libx/common/managed.js +0 -0
- package/libx/common/paging.js +0 -0
- package/libx/common/readme.md +0 -4
- package/libx/common/sorting.js +0 -0
- package/libx/common/temporal.js +0 -0
- package/libx/connect/auth.js +0 -0
- package/libx/connect/perf.js +0 -0
- package/libx/connect/readme.md +0 -3
- package/libx/fiori/draft/readme.md +0 -1
- package/libx/fiori/readme.md +0 -1
- package/libx/hana/readme.md +0 -1
- package/libx/msg/readme.md +0 -3
- package/libx/readme.md +0 -1
- package/libx/sqlite/readme.md +0 -1
- /package/libx/_runtime/{messaging/common-utils → common/utils}/waitingTime.js +0 -0
- /package/libx/{_runtime/messaging/outbox → outbox}/OutboxRunner.js +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,72 @@
|
|
|
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.4.1 - 2023-11-23
|
|
8
|
+
|
|
9
|
+
### Fixed
|
|
10
|
+
|
|
11
|
+
- Add dynamic properties to result when experimental feature `cds.env.features.okra_skip_query_options` is active
|
|
12
|
+
- Allow negative integers in new parser
|
|
13
|
+
- Allow deletion of instances outside the draft tree
|
|
14
|
+
- Tenant lookup in OData metadata requests
|
|
15
|
+
- `cds.parse.csv` and `cds deploy` correctly parse CSV files with Windows file endings (CRLF) and quoted values
|
|
16
|
+
- Typescript Typings
|
|
17
|
+
|
|
18
|
+
## Version 7.4.0 - 2023-11-13
|
|
19
|
+
|
|
20
|
+
### Added
|
|
21
|
+
|
|
22
|
+
- Any service is outboxable via `srv = cds.outboxed(srv)`
|
|
23
|
+
- Draft: support `HasActiveEntity eq false` by read
|
|
24
|
+
- Check if OData function/action params exist for complex types
|
|
25
|
+
- Remote services: destination option `jwt` set to `null` instructs that an incoming request's JWT shall not be passed to SAP Cloud SDK, e.g., when it shall use a fresh client credentials flow token
|
|
26
|
+
+ Example:
|
|
27
|
+
```json
|
|
28
|
+
"requires": {
|
|
29
|
+
"API_BUSINESS_PARTNER": {
|
|
30
|
+
[...]
|
|
31
|
+
"destinationOptions": {
|
|
32
|
+
"jwt": null
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
```
|
|
37
|
+
- Alpha feature flag `cds.env.fiori.wrap_multiple_errors` to toggle the following behaviour for OData errors meant to be consumed by SAP Fiori Elements:
|
|
38
|
+
In cases where multiple errors occur and the flag is set to `false`, the first error is presented as the top-level error (replacing the generic "multiple errors" wrapper).
|
|
39
|
+
The default value is `true`, but `false` will become the default value in cds^8.
|
|
40
|
+
- On CF, the default keep alive timeout of the server is set to 91s (to exceed the 90s of CF's gorouter)
|
|
41
|
+
- `cds deploy` now auto-fills the `ID_texts` field (which get created for entities marked with `@fiori.draft.enabled`) in csv and json data files with a stable UUID. This way, it does not need to be manually added to data files. Also, as the value is stable (a hash of the semantic key fields `ID` and `locale`), it works with `UPSERT` statements.
|
|
42
|
+
|
|
43
|
+
### Changed
|
|
44
|
+
|
|
45
|
+
- Default outbox configuration (overridable via `cds.env.requires.outbox = { ... }`):
|
|
46
|
+
+ `kind` changed to `persistent-outbox` (was `in-memory-outbox`)
|
|
47
|
+
+ `parallel` changed to `true` (i.e., messages are not emitted in sequence)
|
|
48
|
+
- Internal class `OutboxService` is deprecated and will be removed
|
|
49
|
+
|
|
50
|
+
### Fixed
|
|
51
|
+
|
|
52
|
+
- `req.subject` in lean-draft handlers
|
|
53
|
+
- `cds.odata.batch_limit` wasn't taken into account
|
|
54
|
+
- Enterprise-Messaging: Only set tenant information for multitenant apps
|
|
55
|
+
- Enterprise-Messaging: Race condition in `subscribe` event
|
|
56
|
+
- Draft: delete of active entity is forbidden, if draft exist
|
|
57
|
+
- Draft: sorting of draft entities in `list status: all`
|
|
58
|
+
- Draft: invalid delete draft request now rejects with error
|
|
59
|
+
- Draft: Enhance Draft Edit functionality with exclusive record lock
|
|
60
|
+
- Typings for `req.reject/error/info/warn`
|
|
61
|
+
- Deep delete with mixins on new db layer did not work
|
|
62
|
+
- Special strings like `'$now'`, `'$user'` and `'$uuid'` expanded automatically
|
|
63
|
+
- Only services that are served via OData are precompiled during startup
|
|
64
|
+
- Response status of not existing mocks returned 200 instead of 404
|
|
65
|
+
- Calculation of @Capabilities in case of complex $apply
|
|
66
|
+
- `test.data.reset()` did not delete drafts
|
|
67
|
+
- `resolveView` considers `list` for renamed columns
|
|
68
|
+
- `cds.schema` now loads lazily
|
|
69
|
+
- `odata_new_parser`: `$expand=` no longer throws an error with and is simply ignored
|
|
70
|
+
- `odata_new_parser`: Empty custom query params like `Foo?bar` are ignored
|
|
71
|
+
- `odata_new_parser`: generated wrong CQN for queries like `$filter=false or ref eq 5`
|
|
72
|
+
|
|
7
73
|
## Version 7.3.1 - 2023-10-23
|
|
8
74
|
|
|
9
75
|
### Fixed
|
|
@@ -18,7 +84,7 @@
|
|
|
18
84
|
- `cds.localized` now caches i18n bundles per locale and per model to speed up repeated usages of the same bundle at runtime, for example, in repeated calls to `cds.compile.for.edmx()`.
|
|
19
85
|
- Based on `cds.localized` with cached bundles, a new operation `cds.localized.lookup(i18n_key, locale)` is provided.
|
|
20
86
|
- If env variable `CDS_TEST_ENV_CHECK` is set, `cds.test.in()` detects if `cds.env` was loaded before from a different folder.
|
|
21
|
-
- `cds.test.log()` allows to capture and
|
|
87
|
+
- `cds.test.log()` allows to capture and analyze any console log output. `cds.test.verbose()` is now deprecated.
|
|
22
88
|
- Typings for `cds.tx`
|
|
23
89
|
- Add method `cds.schema.default4(schemaId)` to retrieve json schema based on its id
|
|
24
90
|
- Support for pseudo role `internal-user` with authentication kind `ias`
|
|
@@ -26,7 +92,7 @@
|
|
|
26
92
|
|
|
27
93
|
### Changed
|
|
28
94
|
|
|
29
|
-
- If
|
|
95
|
+
- If omitted in the accept header, `ExponentialDecimals` no longer gets defaulted (to `true`), which violated the OData 4.0 specification.
|
|
30
96
|
This change can _temporarily_ be overridden via `cds.env.odata.defaultExponentialDecimals = 'true/false'`.
|
|
31
97
|
- Make type signature of `extend.with` more general
|
|
32
98
|
- `cds.test.data.autoReset()` is deprecated in favor of explicit `cds.test.data.reset()` call, like `beforeEach (test.data.reset)`.
|
|
@@ -728,7 +794,7 @@ Content-Length: 145
|
|
|
728
794
|
- Signatures for QL operations are now more specific
|
|
729
795
|
- `basic-auth` does not inherit users of `mocked-auth`
|
|
730
796
|
- `cds.localize` now ignores i18n files defined outside the project scope.
|
|
731
|
-
- Allow `@Capabilities.NavigationRestrictions.RestrictedProperties` to be specified in the format `{ InsertRestrictions
|
|
797
|
+
- Allow `@Capabilities.NavigationRestrictions.RestrictedProperties` to be specified in the format `{ InsertRestrictions: { Insertable: false } }`
|
|
732
798
|
- Bound actions/functions while calling remote service
|
|
733
799
|
- `$search`: Search on localized projections/views does not always return the localized data
|
|
734
800
|
- `cds push` now shows better output for failed extension validations
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
#Text Types
|
|
2
|
+
#
|
|
3
|
+
#XACT: Text with explicit importance for accessibility.
|
|
4
|
+
#XBUT: Button
|
|
5
|
+
#XCKL: Checkbox
|
|
6
|
+
#XFLD: Field label
|
|
7
|
+
#XLNK: Hyperlink
|
|
8
|
+
#XMIT: Menu item (Menu item, either top-level like "File" or lower-level like "Save as...")
|
|
9
|
+
#XMSG: Message
|
|
10
|
+
#XRBL: Radio button
|
|
11
|
+
#XSEL: Selection (Values in a drop-down list, or a status. For example: "In Process", "Shipped" or "Open".)
|
|
12
|
+
#XTIT: Title (or heading) of a non-actionable user interface element like a column, wizard, or screen area.
|
|
13
|
+
#XTOL: Explanatory text for an UI element, such as a tooltip, input help.
|
|
14
|
+
#YINS: Instruction for a user, for example, a permanent text on a screen that introduces a group of fields.
|
|
15
|
+
#----------------------------------------------------------------------------------------------------------------------
|
|
16
|
+
#For text elements that are not supposed to be translated, use the text type NOTR
|
|
17
|
+
#----------------------------------------------------------------------------------------------------------------------
|
|
18
|
+
#Recommended pattern
|
|
19
|
+
#
|
|
20
|
+
#<TextType>:<AdditionalContextInformation>
|
|
21
|
+
#If there is a maximum length restriction, please indicate as shown below.
|
|
22
|
+
#<TextType>,<MaximumLength>:<AdditionalContextInformation>
|
|
23
|
+
#----------------------------------------------------------------------------------------------------------------------
|
|
24
|
+
# This is the resource bundle for foundation
|
|
25
|
+
# __ldi.translation.uuid=dd6c5800-b108-11e8-be90-bd1cf6ac87fb
|
|
26
|
+
#----------------------------------------------------------------------------------------------------------------------
|
|
27
|
+
|
|
28
|
+
#XTIT: Created By (Answer to: "Which user has created a certain entity?")
|
|
29
|
+
CreatedBy=Creado por
|
|
30
|
+
|
|
31
|
+
#XTIT: Created On (Answer to: "When has a certain entity been created?")
|
|
32
|
+
CreatedAt=Fecha de creaci\u00F3n
|
|
33
|
+
|
|
34
|
+
#XTIT: Changed By (Answer to: "Which user has changed a certain entity?")
|
|
35
|
+
ChangedBy=Modificado por
|
|
36
|
+
|
|
37
|
+
#XTIT: Changed On (Answer to: "When has a certain entity been changed?")
|
|
38
|
+
ChangedAt=Modificado el
|
|
39
|
+
|
|
40
|
+
#XTIT: Currency
|
|
41
|
+
Currency=Moneda
|
|
42
|
+
|
|
43
|
+
#XTIT: Currency Code
|
|
44
|
+
CurrencyCode=C\u00F3digo de moneda
|
|
45
|
+
|
|
46
|
+
#XTIT: Currency Code Description
|
|
47
|
+
CurrencyCode.Description=C\u00F3digo de moneda seg\u00FAn especificado por ISO 4217
|
|
48
|
+
|
|
49
|
+
#XTIT: Currency Symbol
|
|
50
|
+
CurrencySymbol=S\u00EDmbolo de moneda
|
|
51
|
+
|
|
52
|
+
#XTIT: Currency Minor Unit Fractions (Answer to: "How many fractions has a currency's minor unit?", e.g. "0" or "2")
|
|
53
|
+
CurrencyMinorUnit=Fracciones unidad secundaria de moneda
|
|
54
|
+
|
|
55
|
+
#XTIT: Country/Region
|
|
56
|
+
Country=Pa\u00EDs/Regi\u00F3n
|
|
57
|
+
|
|
58
|
+
#XTIT: Country/Region Code
|
|
59
|
+
CountryCode=C\u00F3digo de pa\u00EDs/regi\u00F3n
|
|
60
|
+
|
|
61
|
+
#XTIT: Country/Region Code Description
|
|
62
|
+
CountryCode.Description=C\u00F3digo de pa\u00EDs/regi\u00F3n seg\u00FAn especificado por ISO 3166-1
|
|
63
|
+
|
|
64
|
+
#XTIT: Language
|
|
65
|
+
Language=Idioma
|
|
66
|
+
|
|
67
|
+
#XTIT: Language Code
|
|
68
|
+
LanguageCode=C\u00F3digo de idioma
|
|
69
|
+
|
|
70
|
+
#XTIT: Language Code Description
|
|
71
|
+
LanguageCode.Description=C\u00F3digo de idioma seg\u00FAn especificado por ISO 639-1
|
|
72
|
+
|
|
73
|
+
#XTIT: User Identifier
|
|
74
|
+
UserID=ID de usuario
|
|
75
|
+
|
|
76
|
+
#XTIT: Any kind of name
|
|
77
|
+
Name=Nombre
|
|
78
|
+
|
|
79
|
+
#XTIT: Any kind of description
|
|
80
|
+
Description=Descripci\u00F3n
|
|
81
|
+
|
|
82
|
+
#XTOL: A user's unique Indentifier
|
|
83
|
+
UserID.Description=ID \u00FAnico de usuario
|
|
84
|
+
|
|
85
|
+
#XTIT: Admin data for a draft document
|
|
86
|
+
Draft_DraftAdministrativeData=Datos administrativos en borrador
|
|
87
|
+
|
|
88
|
+
#XTIT: Technical ID of a draft document
|
|
89
|
+
Draft_DraftUUID=Borrador (ID t\u00E9cnico)
|
|
90
|
+
|
|
91
|
+
#XTIT: Creation time of a draft
|
|
92
|
+
Draft_CreationDateTime=Borrador creado el
|
|
93
|
+
|
|
94
|
+
#XTIT: User created the draft
|
|
95
|
+
Draft_CreatedByUser=Borrador creado por
|
|
96
|
+
|
|
97
|
+
#XTIT: The current user (me) created the draft
|
|
98
|
+
Draft_DraftIsCreatedByMe=Borrador creado por m\u00ED
|
|
99
|
+
|
|
100
|
+
#XTIT: Time a draft was last changed on
|
|
101
|
+
Draft_LastChangeDateTime=Fecha del \u00FAltimo cambio en borrador
|
|
102
|
+
|
|
103
|
+
#XTIT: User that changed the draft last
|
|
104
|
+
Draft_LastChangedByUser=Autor del \u00FAltimo cambio en borrador
|
|
105
|
+
|
|
106
|
+
#XTIT: User that is working on the draft
|
|
107
|
+
Draft_InProcessByUser=Borrador en proceso por
|
|
108
|
+
|
|
109
|
+
#XTIT: The current user (me) is working on the draft
|
|
110
|
+
Draft_DraftIsProcessedByMe=Borrador en proceso por m\u00ED
|
package/apis/cds.d.ts
CHANGED
|
@@ -1,24 +1,25 @@
|
|
|
1
1
|
import * as ql from './ql'
|
|
2
2
|
|
|
3
|
-
declare
|
|
3
|
+
declare global {
|
|
4
|
+
const cds : cds_facade
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export = cds
|
|
8
|
+
|
|
9
|
+
type cds_facade = {}
|
|
4
10
|
& import('./core').default
|
|
5
|
-
& import('./
|
|
6
|
-
& import('./
|
|
7
|
-
& import('./
|
|
8
|
-
& import('./ql').cds_ql
|
|
9
|
-
& import('./services').default
|
|
11
|
+
& import('./env').default
|
|
12
|
+
& import('./models').default
|
|
13
|
+
& import('./server').default
|
|
10
14
|
& import('./services').QueryAPI
|
|
15
|
+
& import('./services').default
|
|
16
|
+
& import('./events').default
|
|
17
|
+
& import('./ql').cds_ql
|
|
11
18
|
& import('./log')
|
|
12
19
|
& import('./utils')
|
|
13
20
|
& import('./test')
|
|
14
|
-
export default cds
|
|
15
|
-
|
|
16
|
-
export * from './core'
|
|
17
|
-
export * from './serve'
|
|
18
|
-
export * from './services'
|
|
19
21
|
|
|
20
22
|
declare global {
|
|
21
|
-
|
|
22
23
|
// these provide the functionality from SELECT, INSERT, etc in the global facade
|
|
23
24
|
const SELECT: typeof cds.ql.SELECT
|
|
24
25
|
const INSERT: typeof cds.ql.INSERT
|
package/apis/core.d.ts
CHANGED
|
@@ -1,68 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
type
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
export type
|
|
11
|
-
export type
|
|
12
|
-
export type
|
|
13
|
-
|
|
14
|
-
export
|
|
15
|
-
export type array = Definition
|
|
16
|
-
export type struct = Definition
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
export class User {
|
|
20
|
-
constructor(obj?: UserInput)
|
|
21
|
-
id: string
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* @deprecated Use https://cap.cloud.sap/docs/node.js/events#locale instead
|
|
25
|
-
*/
|
|
26
|
-
locale: string
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* @deprecated Use https://cap.cloud.sap/docs/node.js/events#tenant instead
|
|
30
|
-
*/
|
|
31
|
-
tenant: string | undefined
|
|
32
|
-
|
|
33
|
-
attr: Record<string, string>
|
|
34
|
-
roles: Array<string> | Record<string, string>
|
|
35
|
-
static Privileged: typeof Privileged
|
|
36
|
-
is(role: string): boolean
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Subclass for executing code with superuser privileges.
|
|
41
|
-
*/
|
|
42
|
-
declare class Privileged extends User {
|
|
43
|
-
constructor()
|
|
44
|
-
is(): boolean
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
declare class cds {
|
|
48
|
-
/**
|
|
49
|
-
* Turns the given plain CSN model into a linked model
|
|
50
|
-
* @see [capire](https://cap.cloud.sap/docs/node.js/cds-reflect)
|
|
51
|
-
*/
|
|
52
|
-
linked(model: csn): LinkedModel
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Turns the given plain CSN model into a reflected model
|
|
56
|
-
* @see [capire](https://cap.cloud.sap/docs/node.js/cds-reflect)
|
|
57
|
-
*/
|
|
58
|
-
reflect(model: csn): ReflectedModel
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Represents the user in a given context.
|
|
62
|
-
* @see [capire docs](https://cap.cloud.sap/docs/node.js/authentication#cds-user)
|
|
63
|
-
*/
|
|
64
|
-
User: typeof User
|
|
65
|
-
|
|
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 {
|
|
66
15
|
// infer (query : cqn, model : csn) : LinkedDefinition
|
|
67
16
|
|
|
68
17
|
builtin: {
|
|
@@ -71,15 +20,14 @@ declare class cds {
|
|
|
71
20
|
* @see [capire](https://cap.cloud.sap/docs/node.js/cds-reflect#cds-builtin-classes)
|
|
72
21
|
*/
|
|
73
22
|
classes: {
|
|
74
|
-
Association:
|
|
75
|
-
Composition:
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
type:
|
|
79
|
-
array:
|
|
80
|
-
struct:
|
|
81
|
-
|
|
82
|
-
event: Definition
|
|
23
|
+
Association: Association
|
|
24
|
+
Composition: Composition
|
|
25
|
+
entity: entity
|
|
26
|
+
event: event
|
|
27
|
+
type: type
|
|
28
|
+
array: array
|
|
29
|
+
struct: struct
|
|
30
|
+
service: service
|
|
83
31
|
}
|
|
84
32
|
types: {}
|
|
85
33
|
}
|
|
@@ -130,7 +78,7 @@ declare class cds {
|
|
|
130
78
|
* The first usage of `facade.sub` will load the sub module
|
|
131
79
|
* using standard Node.js's `module.require` functions.
|
|
132
80
|
*/
|
|
133
|
-
lazify
|
|
81
|
+
lazify <T>(target: T) : T
|
|
134
82
|
|
|
135
83
|
/**
|
|
136
84
|
* Prepare a node module for lazy-loading submodules instead
|
|
@@ -144,39 +92,10 @@ declare class cds {
|
|
|
144
92
|
* The first usage of `facade.sub` will load the sub module
|
|
145
93
|
* using standard Node.js's `module.require` functions.
|
|
146
94
|
*/
|
|
147
|
-
lazified
|
|
148
|
-
|
|
149
|
-
/**
|
|
150
|
-
* Provides a graceful shutdown for running servers, by first emitting `cds.emit('shutdown')`.
|
|
151
|
-
* @see [capire](https://cap.cloud.sap/docs/node.js/cds-facade#cds-exit)
|
|
152
|
-
*/
|
|
153
|
-
exit(): void
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
/**
|
|
157
|
-
* Access to the configuration for Node.js runtime and tools.
|
|
158
|
-
* The object is the effective result of configuration merged from various sources,
|
|
159
|
-
* filtered through the currently active profiles, thus highly dependent on the current working
|
|
160
|
-
* directory and process environment.
|
|
161
|
-
*/
|
|
162
|
-
env : {
|
|
163
|
-
build: any,
|
|
164
|
-
hana: any,
|
|
165
|
-
i18n: any,
|
|
166
|
-
mtx: any,
|
|
167
|
-
requires: any,
|
|
168
|
-
folders: any,
|
|
169
|
-
odata: any,
|
|
170
|
-
query: any,
|
|
171
|
-
sql: any
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
requires: any
|
|
175
|
-
version: string
|
|
176
|
-
home: string
|
|
177
|
-
root: string
|
|
95
|
+
lazified <T>(target: T) : T
|
|
178
96
|
|
|
179
97
|
}
|
|
180
98
|
|
|
181
|
-
|
|
182
|
-
|
|
99
|
+
type Intersect<T extends readonly unknown[]> = T extends [infer Head, ...infer Tail]
|
|
100
|
+
? Head & Intersect<Tail>
|
|
101
|
+
: unknown
|
package/apis/cqn.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { entity } from "./csn"
|
|
1
|
+
import { entity } from "./csn" // cyclic dependency
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
export type Query = SELECT
|
|
5
|
-
export type ParsedExpr = expr & { _:string }
|
|
3
|
+
// FIXME: a union type would be more appropriate here
|
|
4
|
+
export type Query = Partial<SELECT & INSERT & UPDATE & DELETE & CREATE & DROP & UPSERT>
|
|
6
5
|
|
|
7
6
|
export type SELECT = {SELECT:{
|
|
8
7
|
distinct?: true
|
|
@@ -16,37 +15,33 @@ export type SELECT = {SELECT:{
|
|
|
16
15
|
groupBy? : expr[]
|
|
17
16
|
orderBy? : ordering_term[]
|
|
18
17
|
limit?: { rows:val, offset:val }
|
|
19
|
-
forUpdate?: { wait: number }
|
|
20
|
-
forShareLock?: { wait: number }
|
|
21
|
-
search?: _xpr
|
|
22
|
-
count?: boolean
|
|
23
18
|
}}
|
|
24
19
|
|
|
25
20
|
export type INSERT = {INSERT:{
|
|
26
|
-
into :
|
|
27
|
-
entries :
|
|
21
|
+
into : ref | name
|
|
22
|
+
entries : data[]
|
|
28
23
|
columns : string[]
|
|
29
|
-
values :
|
|
30
|
-
rows :
|
|
24
|
+
values : scalar[]
|
|
25
|
+
rows : scalar[][]
|
|
31
26
|
as : SELECT
|
|
32
27
|
}}
|
|
33
28
|
|
|
34
29
|
export type UPSERT = {UPSERT:{
|
|
35
|
-
into :
|
|
36
|
-
entries : any[]
|
|
30
|
+
into : ref | name
|
|
37
31
|
columns : string[]
|
|
38
|
-
|
|
39
|
-
|
|
32
|
+
entries : data[]
|
|
33
|
+
values : scalar[]
|
|
34
|
+
rows : scalar[][]
|
|
40
35
|
}}
|
|
41
36
|
|
|
42
37
|
export type UPDATE = {UPDATE:{
|
|
43
|
-
entity : name
|
|
38
|
+
entity : ref | name
|
|
44
39
|
data : { [key:string] : expr }
|
|
45
40
|
where? : predicate
|
|
46
41
|
}}
|
|
47
42
|
|
|
48
43
|
export type DELETE = {DELETE:{
|
|
49
|
-
from : name
|
|
44
|
+
from : ref | name
|
|
50
45
|
where? : predicate
|
|
51
46
|
}}
|
|
52
47
|
|
|
@@ -61,6 +56,8 @@ export type DROP = {DROP:{
|
|
|
61
56
|
view: ref
|
|
62
57
|
}}
|
|
63
58
|
|
|
59
|
+
type scalar = number | string | boolean | null
|
|
60
|
+
type data = Record<string,any>
|
|
64
61
|
type name = string
|
|
65
62
|
type source = ( ref | SELECT ) & { as?: name, join?:name, on?:xpr }
|
|
66
63
|
export type column_expr = expr & { as?: name, cast?:any, expand?: column_expr[], inline?: column_expr[] }
|
package/apis/csn.d.ts
CHANGED
|
@@ -1,82 +1,117 @@
|
|
|
1
|
-
import { SELECT,
|
|
1
|
+
import { SELECT, ref, predicate } from './cqn'
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
/**
|
|
4
|
+
* A parsed CDS model in CSN object notation.
|
|
5
|
+
*/
|
|
6
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
|
|
7
13
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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[]
|
|
13
19
|
|
|
14
|
-
|
|
15
|
-
|
|
20
|
+
/**
|
|
21
|
+
* All definitions in the model including those from imported models.
|
|
22
|
+
*/
|
|
23
|
+
definitions?: Record<FQN, Definition>
|
|
16
24
|
|
|
17
|
-
|
|
18
|
-
|
|
25
|
+
/**
|
|
26
|
+
* All extensions in the model including those from imported models.
|
|
27
|
+
* Not available after extensions have been applied.
|
|
28
|
+
*/
|
|
29
|
+
extensions?: Extension[]
|
|
19
30
|
|
|
20
|
-
|
|
31
|
+
/**
|
|
32
|
+
* The names of the files from which this model has been loaded.
|
|
33
|
+
*/
|
|
34
|
+
$sources?: string[]
|
|
21
35
|
}
|
|
22
36
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
Association: Association
|
|
28
|
-
}
|
|
29
|
-
export type Definition = DefinitionRegistry[keyof DefinitionRegistry];
|
|
37
|
+
/**
|
|
38
|
+
* The fully-quality name of a definition.
|
|
39
|
+
*/
|
|
40
|
+
export type FQN = string
|
|
30
41
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
42
|
+
/**
|
|
43
|
+
* Definitions are the central elements of a CDS model.
|
|
44
|
+
*/
|
|
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>
|
|
34
47
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
48
|
+
/**
|
|
49
|
+
* Extensions capture extend Foo with { ... } directives.
|
|
50
|
+
*/
|
|
51
|
+
export type Extension = {
|
|
52
|
+
extend: FQN
|
|
53
|
+
elements?: { [name: string]: Element }
|
|
54
|
+
includes?: FQN[]
|
|
38
55
|
}
|
|
39
56
|
|
|
40
|
-
export
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
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
|
|
44
68
|
}
|
|
45
69
|
|
|
46
70
|
export interface struct extends type {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
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 }
|
|
51
77
|
}
|
|
52
78
|
|
|
53
|
-
export interface entity extends struct {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
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
|
|
68
99
|
}
|
|
69
|
-
drafts: entity
|
|
70
100
|
}
|
|
71
101
|
|
|
72
102
|
export interface Association extends type {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
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 })[]
|
|
82
117
|
}
|
package/apis/env.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export default class {
|
|
2
|
+
/**
|
|
3
|
+
* Access to the configuration for Node.js runtime and tools.
|
|
4
|
+
* The object is the effective result of configuration merged from various sources,
|
|
5
|
+
* filtered through the currently active profiles, thus highly dependent on the current working
|
|
6
|
+
* directory and process environment.
|
|
7
|
+
*/
|
|
8
|
+
env : {
|
|
9
|
+
build: any,
|
|
10
|
+
hana: any,
|
|
11
|
+
i18n: any,
|
|
12
|
+
mtx: any,
|
|
13
|
+
requires: any,
|
|
14
|
+
folders: any,
|
|
15
|
+
odata: any,
|
|
16
|
+
query: any,
|
|
17
|
+
sql: any
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
requires: any
|
|
21
|
+
version: string
|
|
22
|
+
home: string
|
|
23
|
+
root: string
|
|
24
|
+
|
|
25
|
+
}
|