@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/apis/events.d.ts
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
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
|
+
/**
|
|
33
|
+
* Represents the invocation context of incoming request and event messages.
|
|
34
|
+
* @see [capire docs](https://cap.cloud.sap/docs/node.js/events)
|
|
35
|
+
*/
|
|
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
|
+
}
|
|
@@ -1,39 +1,25 @@
|
|
|
1
|
-
import {
|
|
2
|
-
CSN as ParsedModel,
|
|
3
|
-
Association as ParsedAssociation,
|
|
4
|
-
entity as ParsedEntity,
|
|
5
|
-
kind
|
|
6
|
-
} from "./csn"
|
|
1
|
+
import { CSN, FQN, Association, Definition, entity, kinds } from "./csn"
|
|
7
2
|
|
|
3
|
+
export type LinkedDefinition = linked & Definition & LinkedEntity & LinkedAssociation
|
|
4
|
+
export type Definitions = { [name: string]: LinkedDefinition }
|
|
8
5
|
|
|
9
|
-
export
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
type Filter = string | ((def:Definition) => boolean)
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Applying cds.reflect in a model ensures that all contained definitions have their `name` and `kind` filled in.
|
|
17
|
-
*/
|
|
18
|
-
export interface LinkedDefinition {
|
|
19
|
-
is (kind: kind | 'Association' | 'Composition') : boolean
|
|
20
|
-
name : string
|
|
6
|
+
export interface linked {
|
|
7
|
+
is(kind: kinds | 'Association' | 'Composition'): boolean
|
|
8
|
+
name: FQN
|
|
21
9
|
}
|
|
22
10
|
|
|
23
|
-
interface
|
|
24
|
-
|
|
25
|
-
|
|
11
|
+
interface LinkedEntity extends linked, entity {
|
|
12
|
+
constructor (properties: object)
|
|
13
|
+
keys: Definitions
|
|
14
|
+
drafts: LinkedEntity
|
|
26
15
|
}
|
|
27
16
|
|
|
28
|
-
interface
|
|
29
|
-
|
|
17
|
+
interface LinkedAssociation extends linked, Association {
|
|
18
|
+
is2one: boolean
|
|
19
|
+
is2many: boolean
|
|
30
20
|
}
|
|
31
21
|
|
|
32
|
-
|
|
33
|
-
export interface LinkedModel extends ReflectedModel {}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
export interface ReflectedModel extends ParsedModel {
|
|
22
|
+
export interface LinkedCSN extends CSN {
|
|
37
23
|
|
|
38
24
|
/**
|
|
39
25
|
* Fetches definitions matching the given filter, returning an iterator on them.
|
|
@@ -43,13 +29,13 @@ export interface ReflectedModel extends ParsedModel {
|
|
|
43
29
|
* let entities = [...m.each('entity')] //> capture all
|
|
44
30
|
* let entities = m.all('entity') //> equivalent shortcut
|
|
45
31
|
*/
|
|
46
|
-
each
|
|
32
|
+
each(x: Filter, defs?: Definitions): IterableIterator<any>
|
|
47
33
|
|
|
48
34
|
/**
|
|
49
35
|
* Fetches definitions matching the given filter, returning them in an array.
|
|
50
36
|
* Convenience shortcut for `[...reflect.each('entity')]`
|
|
51
37
|
*/
|
|
52
|
-
all
|
|
38
|
+
all(x: Filter, defs?: Definitions): any[]
|
|
53
39
|
|
|
54
40
|
/**
|
|
55
41
|
* Fetches definitions matching the given filter, returning the first match, if any.
|
|
@@ -58,19 +44,21 @@ export interface ReflectedModel extends ParsedModel {
|
|
|
58
44
|
* @param {Filter} [x] the filter
|
|
59
45
|
* @param {Definitions} [defs] the definitions to fetch in, default: `this.definitions`
|
|
60
46
|
*/
|
|
61
|
-
find
|
|
47
|
+
find(x: Filter, defs?: Definitions): any
|
|
62
48
|
|
|
63
49
|
/**
|
|
64
50
|
* Calls the visitor for each definition matching the given filter.
|
|
65
51
|
* @see [capire](https://github.wdf.sap.corp/pages/cap/node.js/api#cds-reflect-foreach)
|
|
66
52
|
*/
|
|
67
|
-
foreach
|
|
53
|
+
foreach(x: Filter, visitor: Visitor, defs?: Definitions): this
|
|
54
|
+
foreach(visitor: Visitor, defs?: Definitions): this
|
|
68
55
|
|
|
69
56
|
/**
|
|
70
57
|
* Same as foreach but recursively visits each element definition
|
|
71
58
|
* @see [capire](https://github.wdf.sap.corp/pages/cap/node.js/api#cds-reflect-foreach)
|
|
72
59
|
*/
|
|
73
|
-
forall
|
|
60
|
+
forall(x: Filter, visitor: Visitor, defs?: Definitions): this
|
|
61
|
+
forall(visitor: Visitor, defs?: Definitions): this
|
|
74
62
|
|
|
75
63
|
/**
|
|
76
64
|
* Fetches definitions declared as children of a given parent context or service.
|
|
@@ -82,7 +70,7 @@ export interface ReflectedModel extends ParsedModel {
|
|
|
82
70
|
* @param parent either the parent itself or its fully-qualified name
|
|
83
71
|
* @param filter an optional filter to apply before picking a child
|
|
84
72
|
*/
|
|
85
|
-
childrenOf
|
|
73
|
+
childrenOf(parent: any | string, filter?: ((def: LinkedDefinition) => boolean)): Definitions
|
|
86
74
|
|
|
87
75
|
/**
|
|
88
76
|
* Provides convenient access to the model's top-level definitions.
|
|
@@ -98,9 +86,12 @@ export interface ReflectedModel extends ParsedModel {
|
|
|
98
86
|
* const {Books,Authors} = model.exports
|
|
99
87
|
* SELECT.from (Books) .where ({ID:11})
|
|
100
88
|
*/
|
|
101
|
-
exports
|
|
102
|
-
entities
|
|
103
|
-
services
|
|
104
|
-
definitions
|
|
89
|
+
exports: Definitions & ((namespace: string) => Definitions)
|
|
90
|
+
entities: Definitions & ((namespace: string) => Definitions)
|
|
91
|
+
services: Definitions & ((namespace: string) => Definitions)
|
|
92
|
+
definitions: Definitions
|
|
105
93
|
|
|
106
94
|
}
|
|
95
|
+
|
|
96
|
+
type Visitor = (def: LinkedDefinition, name: string, parent: LinkedDefinition, defs: Definitions) => void
|
|
97
|
+
type Filter = string | ((def: LinkedDefinition) => boolean)
|
package/apis/models.d.ts
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import { Query, expr, _xpr } from "./cqn"
|
|
1
|
+
import { Query as CQN, expr, _xpr } from "./cqn"
|
|
2
|
+
import { LinkedCSN } from "./linked"
|
|
2
3
|
import { CSN } from "./csn"
|
|
3
4
|
|
|
4
|
-
type csn = CSN
|
|
5
|
-
type cqn = Query
|
|
6
|
-
|
|
7
5
|
type _flavor = 'parsed' | 'xtended' | 'inferred'
|
|
8
6
|
type _odata_options = {
|
|
9
7
|
flavor?: 'v2' | 'v4' | 'w4'| 'x4',
|
|
@@ -29,8 +27,13 @@ type EDMX = XML
|
|
|
29
27
|
type filename = string
|
|
30
28
|
|
|
31
29
|
|
|
32
|
-
export
|
|
33
|
-
|
|
30
|
+
export default class cds {
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* The effective CDS model loaded during bootstrapping, which contains all service and entity definitions,
|
|
34
|
+
* including required services.
|
|
35
|
+
*/
|
|
36
|
+
model?: LinkedCSN
|
|
34
37
|
|
|
35
38
|
/**
|
|
36
39
|
* Provides a set of methods to parse a given model, query or expression.
|
|
@@ -38,9 +41,9 @@ declare class cds {
|
|
|
38
41
|
*/
|
|
39
42
|
parse : {
|
|
40
43
|
/** Shortcut to `cds.parse.cdl()` */
|
|
41
|
-
(cdl:CDL) :
|
|
42
|
-
cdl (cdl:CDL) :
|
|
43
|
-
cql (src:string) :
|
|
44
|
+
(cdl:CDL) : CSN
|
|
45
|
+
cdl (cdl:CDL) : CSN
|
|
46
|
+
cql (src:string) : CQN
|
|
44
47
|
expr (src:string) : expr
|
|
45
48
|
xpr (src:string) : _xpr
|
|
46
49
|
ref (src:string) : string[]
|
|
@@ -53,49 +56,49 @@ declare class cds {
|
|
|
53
56
|
*/
|
|
54
57
|
compile : {
|
|
55
58
|
/** Shortcut for `cds.compile.to.csn()` */
|
|
56
|
-
cdl (model:CDL, o?:_options) :
|
|
59
|
+
cdl (model:CDL, o?:_options) : CSN,
|
|
57
60
|
|
|
58
61
|
for: {
|
|
59
|
-
odata (model:
|
|
60
|
-
sql (model:
|
|
62
|
+
odata (model:CSN, o?:_options) : CSN
|
|
63
|
+
sql (model:CSN, o?:_options) : CSN
|
|
61
64
|
},
|
|
62
65
|
to: {
|
|
63
66
|
parsed:{
|
|
64
|
-
csn (files:filename[], o?:_options) : Promise<
|
|
65
|
-
csn (model:CDL, o?:_options) :
|
|
67
|
+
csn (files:filename[], o?:_options) : Promise<CSN>
|
|
68
|
+
csn (model:CDL, o?:_options) : CSN
|
|
66
69
|
}
|
|
67
70
|
xtended:{
|
|
68
|
-
csn (files:filename[], o?:_options) : Promise<
|
|
69
|
-
csn (model:CDL, o?:_options) :
|
|
71
|
+
csn (files:filename[], o?:_options) : Promise<CSN>
|
|
72
|
+
csn (model:CDL, o?:_options) : CSN
|
|
70
73
|
}
|
|
71
74
|
inferred:{
|
|
72
|
-
csn (files:filename[], o?:_options) : Promise<
|
|
73
|
-
csn (model:CDL, o?:_options) :
|
|
75
|
+
csn (files:filename[], o?:_options) : Promise<CSN>
|
|
76
|
+
csn (model:CDL, o?:_options) : CSN
|
|
74
77
|
}
|
|
75
|
-
csn (files:filename[], o?:_options) : Promise<
|
|
76
|
-
csn (model:CDL, o?:_options) :
|
|
77
|
-
yml (model:
|
|
78
|
-
yaml (model:
|
|
79
|
-
json (model:
|
|
80
|
-
sql (model:
|
|
81
|
-
cdl (model:
|
|
82
|
-
edm (model:
|
|
83
|
-
edmx (model:
|
|
84
|
-
hdbcds (model:
|
|
85
|
-
hdbtable (model:
|
|
78
|
+
csn (files:filename[], o?:_options) : Promise<CSN>
|
|
79
|
+
csn (model:CDL, o?:_options) : CSN
|
|
80
|
+
yml (model:CSN, o?:_options) : YAML
|
|
81
|
+
yaml (model:CSN, o?:_options) : YAML
|
|
82
|
+
json (model:CSN, o?:_options) : JSON
|
|
83
|
+
sql (model:CSN, o?:_options) : SQL[]
|
|
84
|
+
cdl (model:CSN, o?:_options) : CDL | Iterable<[CDL,{file:filename}]>
|
|
85
|
+
edm (model:CSN, o?:_options|_odata_options) : EDM | string
|
|
86
|
+
edmx (model:CSN, o?:_options|_odata_options) : EDMX | Iterable<[EDMX,{file:filename}]>
|
|
87
|
+
hdbcds (model:CSN, o?:_options) : SQL | Iterable<[SQL,{file:filename}]>
|
|
88
|
+
hdbtable (model:CSN, o?:_options) : SQL | Iterable<[SQL,{file:filename}]>
|
|
86
89
|
}
|
|
87
90
|
|
|
88
91
|
/** Fluent API variant */
|
|
89
|
-
(model:
|
|
92
|
+
(model: CSN | CDL) : {
|
|
90
93
|
for: {
|
|
91
|
-
odata (o?:_options) :
|
|
92
|
-
sql (o?:_options) :
|
|
94
|
+
odata (o?:_options) : CSN
|
|
95
|
+
sql (o?:_options) : CSN
|
|
93
96
|
},
|
|
94
97
|
to: {
|
|
95
|
-
parsed:{ csn (o?:_options) :
|
|
96
|
-
xtended:{ csn (o?:_options) :
|
|
97
|
-
inferred:{ csn (o?:_options) :
|
|
98
|
-
csn (o?:_options) :
|
|
98
|
+
parsed:{ csn (o?:_options) : CSN }
|
|
99
|
+
xtended:{ csn (o?:_options) : CSN }
|
|
100
|
+
inferred:{ csn (o?:_options) : CSN }
|
|
101
|
+
csn (o?:_options) : CSN
|
|
99
102
|
yml (o?:_options) : YAML
|
|
100
103
|
yaml (o?:_options) : YAML
|
|
101
104
|
json (o?:_options) : JSON
|
|
@@ -111,14 +114,14 @@ declare class cds {
|
|
|
111
114
|
/** Async fluent variant reading from files */
|
|
112
115
|
(files: filename[]) : {
|
|
113
116
|
for: {
|
|
114
|
-
odata (o?:_options) : Promise<
|
|
115
|
-
sql (o?:_options) : Promise<
|
|
117
|
+
odata (o?:_options) : Promise<CSN>
|
|
118
|
+
sql (o?:_options) : Promise<CSN>
|
|
116
119
|
},
|
|
117
120
|
to: {
|
|
118
|
-
parsed:{ csn (o?:_options) : Promise <
|
|
119
|
-
xtended:{ csn (o?:_options) : Promise <
|
|
120
|
-
inferred:{ csn (o?:_options) : Promise <
|
|
121
|
-
csn (o?:_options) : Promise <
|
|
121
|
+
parsed:{ csn (o?:_options) : Promise <CSN> }
|
|
122
|
+
xtended:{ csn (o?:_options) : Promise <CSN> }
|
|
123
|
+
inferred:{ csn (o?:_options) : Promise <CSN> }
|
|
124
|
+
csn (o?:_options) : Promise <CSN>
|
|
122
125
|
yml (o?:_options) : Promise <YAML>
|
|
123
126
|
yaml (o?:_options) : Promise <YAML>
|
|
124
127
|
json (o?:_options) : Promise <JSON>
|
|
@@ -138,18 +141,18 @@ declare class cds {
|
|
|
138
141
|
* Essentially a shortcut for `cds.compile.to.csn(files)`
|
|
139
142
|
* @param {string} files - filenames of models or if folder containing models
|
|
140
143
|
*/
|
|
141
|
-
get(files: '*' | filename | filename[], o?:_options) : Promise<
|
|
144
|
+
get(files: '*' | filename | filename[], o?:_options) : Promise<CSN>
|
|
142
145
|
|
|
143
146
|
/**
|
|
144
147
|
* Shortcut for `cds.get(files, 'inferred')`
|
|
145
148
|
* @param {string} files - filenames of models or if folder containing models
|
|
146
149
|
*/
|
|
147
|
-
load(files: '*' | filename | filename[], o?:_options) : Promise<
|
|
150
|
+
load(files: '*' | filename | filename[], o?:_options) : Promise<CSN>
|
|
148
151
|
|
|
149
152
|
/**
|
|
150
153
|
* Emitted whenever a model is loaded using cds.load().
|
|
151
154
|
*/
|
|
152
|
-
on (event : 'loaded', listener : (model :
|
|
155
|
+
on (event : 'loaded', listener : (model : CSN) => void) : this
|
|
153
156
|
|
|
154
157
|
|
|
155
158
|
/**
|
|
@@ -162,4 +165,16 @@ declare class cds {
|
|
|
162
165
|
*/
|
|
163
166
|
resolve (files: '*' | filename | filename[]) : filename[] | undefined
|
|
164
167
|
|
|
168
|
+
/**
|
|
169
|
+
* Turns the given plain CSN model into a linked model
|
|
170
|
+
* @see [capire](https://cap.cloud.sap/docs/node.js/cds-reflect)
|
|
171
|
+
*/
|
|
172
|
+
linked(model: CSN): LinkedCSN
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Turns the given plain CSN model into a reflected model
|
|
176
|
+
* @see [capire](https://cap.cloud.sap/docs/node.js/cds-reflect)
|
|
177
|
+
*/
|
|
178
|
+
reflect(model: CSN): LinkedCSN
|
|
179
|
+
|
|
165
180
|
}
|
package/apis/ql.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Definition } from "./csn"
|
|
1
|
+
import { CSN, Definition, EntityElements } from "./csn"
|
|
2
2
|
import * as CQN from "./cqn"
|
|
3
3
|
import { Constructable, ArrayConstructable, SingularType } from "./internal/inference"
|
|
4
|
+
import { LinkedEntity } from "./linked"
|
|
4
5
|
|
|
5
|
-
export type CQNQuery = CQN.CQNQuery
|
|
6
6
|
export type Query = CQN.Query
|
|
7
7
|
|
|
8
8
|
export class ConstructedQuery {
|
|
@@ -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: SELECT_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>
|
|
@@ -172,8 +172,10 @@ export class SELECT<T> extends ConstructedQuery {
|
|
|
172
172
|
forUpdate ({wait}? : {wait?: number}) : this
|
|
173
173
|
alias (as: string) : this
|
|
174
174
|
|
|
175
|
+
elements: EntityElements
|
|
175
176
|
|
|
176
|
-
|
|
177
|
+
|
|
178
|
+
// Not yet public
|
|
177
179
|
// fullJoin (other: string, as: string) : this
|
|
178
180
|
// leftJoin (other: string, as: string) : this
|
|
179
181
|
// rightJoin (other: string, as: string) : this
|
|
@@ -183,7 +185,12 @@ export class SELECT<T> extends ConstructedQuery {
|
|
|
183
185
|
// & ((...expr : string[]) => this)
|
|
184
186
|
// & ((predicate:object) => this)
|
|
185
187
|
|
|
186
|
-
SELECT : CQN.SELECT["SELECT"]
|
|
188
|
+
SELECT : CQN.SELECT["SELECT"] & {
|
|
189
|
+
forUpdate?: { wait: number }
|
|
190
|
+
forShareLock?: { wait: number }
|
|
191
|
+
search?: CQN.predicate
|
|
192
|
+
count?: boolean
|
|
193
|
+
}
|
|
187
194
|
}
|
|
188
195
|
|
|
189
196
|
|
|
@@ -200,6 +207,7 @@ TaggedTemplateQueryPart<Awaitable<SELECT<unknown>, InstanceType<any>>>
|
|
|
200
207
|
=> Awaitable<SELECT<SingularType<T>>, SingularType<T>>)
|
|
201
208
|
|
|
202
209
|
& ((entity: Definition | string, primaryKey? : PK, projection? : Projection<unknown>) => SELECT<any>)
|
|
210
|
+
& ((entity: LinkedEntity | string, primaryKey? : PK, projection? : Projection<unknown>) => SELECT<any>)
|
|
203
211
|
& (<T> (entity: T[], projection? : Projection<T>) => Awaitable<SELECT<T>, T>)
|
|
204
212
|
& (<T> (entity: T[], primaryKey : PK, projection? : Projection<T>) => Awaitable<SELECT<T>, T>)
|
|
205
213
|
& (<T> (entity: {new():T}, projection? : Projection<T>) => Awaitable<SELECT<T>, T>)
|
|
@@ -219,6 +227,7 @@ type SELECT_from =
|
|
|
219
227
|
=> Awaitable<SELECT<SingularType<T>>, InstanceType<SingularType<T>>>) // when specifying a key, we expect a single element as result
|
|
220
228
|
// calling with definition
|
|
221
229
|
& ((entity: Definition | string, primaryKey? : PK, projection? : Projection<unknown>) => SELECT<any>)
|
|
230
|
+
& ((entity: LinkedEntity | string, primaryKey? : PK, projection? : Projection<unknown>) => SELECT<any>)
|
|
222
231
|
// calling with concrete list
|
|
223
232
|
& (<T> (entity: T[], projection? : Projection<T>) => SELECT<T> & Promise<T[]>)
|
|
224
233
|
& (<T> (entity: T[], primaryKey : PK, projection? : Projection<T>) => Awaitable<SELECT<T>, T>)
|
|
@@ -228,6 +237,7 @@ export class INSERT<T> extends ConstructedQuery {
|
|
|
228
237
|
static into : (<T extends ArrayConstructable<any>> (entity:T, entries? : object | object[]) => INSERT<SingularType<T>>)
|
|
229
238
|
& (TaggedTemplateQueryPart<INSERT<unknown>>)
|
|
230
239
|
& ((entity : Definition | string, entries? : object | object[]) => INSERT<any>)
|
|
240
|
+
& ((entity : LinkedEntity | string, entries? : object | object[]) => INSERT<any>)
|
|
231
241
|
& (<T> (entity:Constructable<T>, entries? : object | object[]) => INSERT<T>)
|
|
232
242
|
& (<T> (entity:T, entries? : T | object | object[]) => INSERT<T>)
|
|
233
243
|
|
|
@@ -249,6 +259,7 @@ export class UPSERT<T> extends ConstructedQuery {
|
|
|
249
259
|
static into : (<T extends ArrayConstructable<any>> (entity:T, entries? : object | object[]) => UPSERT<SingularType<T>>)
|
|
250
260
|
& (TaggedTemplateQueryPart<UPSERT<unknown>>)
|
|
251
261
|
& ((entity : Definition | string, entries? : object | object[]) => UPSERT<any>)
|
|
262
|
+
& ((entity : LinkedEntity | string, entries? : object | object[]) => UPSERT<any>)
|
|
252
263
|
& (<T> (entity:Constructable<T>, entries? : object | object[]) => UPSERT<T>)
|
|
253
264
|
& (<T> (entity:T, entries? : T | object | object[]) => UPSERT<T>)
|
|
254
265
|
|
|
@@ -283,6 +294,7 @@ export class UPDATE<T> extends ConstructedQuery {
|
|
|
283
294
|
static entity <T extends ArrayConstructable<any>> (entity:T, primaryKey? : PK) : UPDATE<SingularType<T>>
|
|
284
295
|
|
|
285
296
|
static entity (entity : Definition | string, primaryKey? : PK) : UPDATE<any>
|
|
297
|
+
static entity (entity : LinkedEntity | string, primaryKey? : PK) : UPDATE<any>
|
|
286
298
|
static entity <T> (entity:Constructable<T>, primaryKey? : PK) : UPDATE<T>
|
|
287
299
|
static entity <T> (entity:T, primaryKey? : PK) : UPDATE<T>
|
|
288
300
|
byKey (primaryKey? : PK) : this
|
|
@@ -301,10 +313,12 @@ export class UPDATE<T> extends ConstructedQuery {
|
|
|
301
313
|
|
|
302
314
|
export class CREATE<T> extends ConstructedQuery {
|
|
303
315
|
static entity (entity : Definition | string) : CREATE<any>
|
|
316
|
+
static entity (entity : LinkedEntity | string) : CREATE<any>
|
|
304
317
|
CREATE : CQN.CREATE["CREATE"]
|
|
305
318
|
}
|
|
306
319
|
|
|
307
320
|
export class DROP<T> extends ConstructedQuery {
|
|
308
321
|
static entity (entity : Definition | string) : DROP<any>
|
|
322
|
+
static entity (entity : LinkedEntity | string) : DROP<any>
|
|
309
323
|
DROP : CQN.DROP["DROP"]
|
|
310
324
|
}
|
|
@@ -1,41 +1,50 @@
|
|
|
1
1
|
import { Service, ServiceImpl } from "./services"
|
|
2
|
-
import {
|
|
3
|
-
import { csn } from "./csn"
|
|
2
|
+
import { CSN } from "./csn"
|
|
4
3
|
import * as http from "http"
|
|
5
4
|
import { Application } from "express"
|
|
6
5
|
|
|
7
|
-
|
|
6
|
+
export default class cds {
|
|
8
7
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
// (req,res) : void
|
|
16
|
-
}
|
|
8
|
+
connect: {
|
|
9
|
+
/**
|
|
10
|
+
* Connects to a specific datasource.
|
|
11
|
+
* @see [capire](https://cap.cloud.sap/docs/node.js/cds-connect#cds-connect-to)
|
|
12
|
+
*/
|
|
13
|
+
to(datasource: string, options?: cds_connect_options): Promise<Service>
|
|
17
14
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
15
|
+
/**
|
|
16
|
+
* Connects to a specific datasource via options.
|
|
17
|
+
* @see [capire](https://cap.cloud.sap/docs/node.js/cds-connect#cds-connect-to)
|
|
18
|
+
*/
|
|
19
|
+
to(options: cds_connect_options): Promise<Service>
|
|
24
20
|
|
|
25
|
-
|
|
26
|
-
|
|
21
|
+
/**
|
|
22
|
+
* Connects the primary datasource.
|
|
23
|
+
* @see [capire](https://cap.cloud.sap/docs/node.js/cds-connect)
|
|
24
|
+
*/
|
|
25
|
+
(options?: string | cds_connect_options): Promise<typeof cds> //> cds.connect(<options>)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* The default bootstrap function as loaded from server.js
|
|
30
|
+
*/
|
|
31
|
+
server: Function
|
|
27
32
|
|
|
28
33
|
/**
|
|
29
34
|
* Constructs service providers from respective service definitions
|
|
30
35
|
* @see [capire](https://cap.cloud.sap/docs/node.js/cds-serve)
|
|
31
36
|
*/
|
|
32
|
-
serve (service : string, options?:
|
|
37
|
+
serve (service : string, options?: {
|
|
38
|
+
service?: string,
|
|
39
|
+
from?: '*' | 'all' | string,
|
|
40
|
+
[key: string]: unknown
|
|
41
|
+
}) : Promise<cds_services> & cds_serve_fluent
|
|
42
|
+
|
|
33
43
|
|
|
34
44
|
/**
|
|
35
|
-
*
|
|
45
|
+
* Emitted whenever a specific service is connected for the first time.
|
|
36
46
|
*/
|
|
37
|
-
|
|
38
|
-
|
|
47
|
+
on(event: 'connect', listener: (srv: Service) => void): this
|
|
39
48
|
|
|
40
49
|
|
|
41
50
|
/**
|
|
@@ -83,27 +92,44 @@ declare class cds_serve {
|
|
|
83
92
|
*/
|
|
84
93
|
service : service
|
|
85
94
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
95
|
+
/**
|
|
96
|
+
* Provides a graceful shutdown for running servers, by first emitting `cds.emit('shutdown')`.
|
|
97
|
+
* @see [capire](https://cap.cloud.sap/docs/node.js/cds-facade#cds-exit)
|
|
98
|
+
*/
|
|
99
|
+
exit(): void
|
|
91
100
|
|
|
92
101
|
}
|
|
93
102
|
|
|
94
|
-
export type service =
|
|
103
|
+
export type service = {
|
|
95
104
|
/**
|
|
96
105
|
* Dummy wrapper for service implementation functions.
|
|
97
106
|
* Use that in modules to get IntelliSense.
|
|
98
107
|
*/
|
|
99
108
|
impl (impl: ServiceImpl) : typeof impl
|
|
100
|
-
impl <T> (srv:T, impl: ( this: T, srv: (T) ) => any) : typeof impl
|
|
109
|
+
// impl <T> (srv:T, impl: ( this: T, srv: (T) ) => any) : typeof impl
|
|
110
|
+
|
|
101
111
|
/**
|
|
102
112
|
* Array of all services constructed.
|
|
103
113
|
*/
|
|
104
|
-
providers : Service
|
|
114
|
+
providers : Service[]
|
|
105
115
|
}
|
|
106
116
|
|
|
107
117
|
|
|
108
|
-
|
|
109
|
-
|
|
118
|
+
type cds_services = { [name:string]: Service }
|
|
119
|
+
|
|
120
|
+
interface cds_serve_fluent {
|
|
121
|
+
from (model : string | CSN) : this
|
|
122
|
+
to (protocol: string) : this
|
|
123
|
+
at (path: string) : this
|
|
124
|
+
in (app: Application) : this
|
|
125
|
+
with (impl: ServiceImpl | string) : this
|
|
126
|
+
// (req,res) : void
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
interface cds_connect_options {
|
|
130
|
+
impl?: string,
|
|
131
|
+
service?: string,
|
|
132
|
+
kind?: string,
|
|
133
|
+
model?: string,
|
|
134
|
+
credentials?: object
|
|
135
|
+
}
|