@cap-js/cds-types 0.1.0 → 0.3.0-beta.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/README.md +11 -0
- package/dist/cds-types.d.ts +2778 -0
- package/package.json +23 -8
- package/apis/cds.d.ts +0 -44
- package/apis/core.d.ts +0 -95
- package/apis/cqn.d.ts +0 -87
- package/apis/csn.d.ts +0 -117
- package/apis/env.d.ts +0 -22
- package/apis/events.d.ts +0 -105
- package/apis/internal/inference.d.ts +0 -32
- package/apis/linked.d.ts +0 -105
- package/apis/log.d.ts +0 -164
- package/apis/models.d.ts +0 -171
- package/apis/ql.d.ts +0 -327
- package/apis/server.d.ts +0 -143
- package/apis/services.d.ts +0 -414
- package/apis/test.d.ts +0 -87
- package/apis/utils.d.ts +0 -89
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cap-js/cds-types",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0-beta.1",
|
|
4
4
|
"description": "Type definitions for main packages of CAP, like `@sap/cds`",
|
|
5
5
|
"repository": "github:cap-js/cds-types",
|
|
6
6
|
"homepage": "https://cap.cloud.sap/",
|
|
@@ -11,28 +11,43 @@
|
|
|
11
11
|
],
|
|
12
12
|
"author": "SAP SE (https://www.sap.com)",
|
|
13
13
|
"license": "SEE LICENSE IN LICENSE",
|
|
14
|
-
"typings": "
|
|
14
|
+
"typings": "dist/cds-types.d.ts",
|
|
15
15
|
"files": [
|
|
16
|
-
"
|
|
16
|
+
"dist/",
|
|
17
17
|
"LICENSE",
|
|
18
18
|
"README.md"
|
|
19
19
|
],
|
|
20
20
|
"scripts": {
|
|
21
21
|
"test": "jest --silent",
|
|
22
|
-
"
|
|
22
|
+
"rollup": "rm -rf dist/ && mkdir -p etc/ && npx -y @microsoft/api-extractor run --local --verbose && .github/rollup-patch.js",
|
|
23
|
+
"rollup:on": "npm pkg set typings=dist/cds-types.d.ts && [ -d 'apis' ] && mv -- apis -apis || true",
|
|
24
|
+
"rollup:off": "npm pkg set typings=apis/cds.d.ts && [ -d '-apis' ] && mv -- -apis apis || true",
|
|
25
|
+
"lint": "npx eslint .",
|
|
26
|
+
"lint:fix": "npx eslint . --fix",
|
|
27
|
+
"setup": "npm i && npm i file:. --no-save --force",
|
|
28
|
+
"prerelease:ci-fix": ".github/prerelease-fix.js"
|
|
23
29
|
},
|
|
24
30
|
"peerDependencies": {
|
|
25
|
-
"@sap/cds": ">=7"
|
|
31
|
+
"@sap/cds": ">=7 || ^8.0.0-beta"
|
|
32
|
+
},
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"@types/express": "^4.17.21"
|
|
26
35
|
},
|
|
27
36
|
"devDependencies": {
|
|
28
|
-
"@
|
|
37
|
+
"@eslint/js": "^9.2.0",
|
|
38
|
+
"@sap/cds": ">=7.5.0",
|
|
39
|
+
"@stylistic/eslint-plugin-js": "^2.1.0",
|
|
40
|
+
"@stylistic/eslint-plugin-ts": "^2.1.0",
|
|
41
|
+
"@types/jest": "^29.5.11",
|
|
29
42
|
"@types/node": "^20",
|
|
30
43
|
"axios": "^1.6.2",
|
|
31
44
|
"chai": "^4.3.10",
|
|
45
|
+
"eslint": "^9.2.0",
|
|
32
46
|
"jest": "^29.7.0",
|
|
33
47
|
"ts-jest": "^29.1.1",
|
|
34
|
-
"typescript": "^5.
|
|
35
|
-
"
|
|
48
|
+
"typescript": "^5.4.5",
|
|
49
|
+
"typescript-eslint": "^8.0.0-alpha.10",
|
|
50
|
+
"winston": "^3.13.0"
|
|
36
51
|
},
|
|
37
52
|
"jest": {
|
|
38
53
|
"transform": {
|
package/apis/cds.d.ts
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
export * from './core'
|
|
2
|
-
export * from './server'
|
|
3
|
-
export * from './env'
|
|
4
|
-
export * from './models'
|
|
5
|
-
export * from './services'
|
|
6
|
-
export * from './events'
|
|
7
|
-
export * from './utils'
|
|
8
|
-
export { log, debug } from './log'
|
|
9
|
-
export { test } from './test'
|
|
10
|
-
export * from './cqn'
|
|
11
|
-
|
|
12
|
-
// FIXME: sort out what needs to be exported from csn/linked and under which namespace
|
|
13
|
-
// export { Association, CSN, Definition, Extension, Element, EntityElements, FQN, kinds } from './csn'
|
|
14
|
-
// export { Definitions, LinkedCSN, LinkedDefinition, LinkedAssociation, LinkedEntity, Filter, Visitor } from './linked'
|
|
15
|
-
|
|
16
|
-
// API extractor cannot handle export * as ql from './ql', so split it into an import and an export statement
|
|
17
|
-
import * as ql from './ql'
|
|
18
|
-
export { ql }
|
|
19
|
-
export { QLExtensions } from './ql' // cds-ql.ts test tries to import this from top level? Correct? Or ql.QLExtensions?
|
|
20
|
-
|
|
21
|
-
// trick to work around "delete" as reserved identifier
|
|
22
|
-
import { Service } from './services'
|
|
23
|
-
declare const delete_: Service['delete']
|
|
24
|
-
export { delete_ as delete }
|
|
25
|
-
|
|
26
|
-
declare global {
|
|
27
|
-
// these provide the functionality from SELECT, INSERT, etc in the global facade
|
|
28
|
-
const SELECT: ql.QL<any>['SELECT']
|
|
29
|
-
const INSERT: ql.QL<any>['INSERT']
|
|
30
|
-
const UPSERT: ql.QL<any>['UPSERT']
|
|
31
|
-
const UPDATE: ql.QL<any>['UPDATE']
|
|
32
|
-
const DELETE: ql.QL<any>['DELETE']
|
|
33
|
-
const CREATE: ql.QL<any>['CREATE']
|
|
34
|
-
const DROP: ql.QL<any>['DROP']
|
|
35
|
-
|
|
36
|
-
// and these allow us to use them as type too, i.e. `const q: SELECT<Book> = ...`
|
|
37
|
-
type SELECT<T> = ql.SELECT<T>
|
|
38
|
-
type INSERT<T> = ql.INSERT<T>
|
|
39
|
-
type UPSERT<T> = ql.UPSERT<T>
|
|
40
|
-
type UPDATE<T> = ql.UPDATE<T>
|
|
41
|
-
type DELETE<T> = ql.DELETE<T>
|
|
42
|
-
type CREATE<T> = ql.CREATE<T>
|
|
43
|
-
type DROP<T> = ql.DROP<T>
|
|
44
|
-
}
|
package/apis/core.d.ts
DELETED
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import { LinkedAssociation, LinkedEntity, linked } from './linked'
|
|
2
|
-
import * as csn from './csn'
|
|
3
|
-
import { service } from './server'
|
|
4
|
-
|
|
5
|
-
type Intersect<T extends readonly unknown[]> = T extends [infer Head, ...infer Tail]
|
|
6
|
-
? Head & Intersect<Tail>
|
|
7
|
-
: unknown
|
|
8
|
-
|
|
9
|
-
// These are classes actually -> using the new() => interface trick
|
|
10
|
-
/**
|
|
11
|
-
* Base class for linked Associations from reflected models.
|
|
12
|
-
* @see [capire](https://cap.cloud.sap/docs/node.js/cds-reflect#cds-Association)
|
|
13
|
-
*/
|
|
14
|
-
export type Association = new(_?:object) => LinkedAssociation
|
|
15
|
-
/**
|
|
16
|
-
* Base class for linked Compositions from reflected models.
|
|
17
|
-
* @see [capire](https://cap.cloud.sap/docs/node.js/cds-reflect#cds-Association)
|
|
18
|
-
*/
|
|
19
|
-
export type Composition = new(_?:object) => LinkedAssociation
|
|
20
|
-
/**
|
|
21
|
-
* Base class for linked entities from reflected models.
|
|
22
|
-
* @see [capire](https://cap.cloud.sap/docs/node.js/cds-reflect#cds-entity)
|
|
23
|
-
*/
|
|
24
|
-
export type entity = new(_?:object) => LinkedEntity
|
|
25
|
-
export type event = new(_?:object) => linked & csn.struct
|
|
26
|
-
export type type = new(_?:object) => linked & csn.type
|
|
27
|
-
export type array = new(_?:object) => linked & csn.type
|
|
28
|
-
export type struct = new(_?:object) => linked & csn.struct
|
|
29
|
-
|
|
30
|
-
// infer (query : cqn, model : csn) : LinkedDefinition
|
|
31
|
-
export const builtin: {
|
|
32
|
-
/**
|
|
33
|
-
* Base classes of linked definitions from reflected models.
|
|
34
|
-
* @see [capire](https://cap.cloud.sap/docs/node.js/cds-reflect#cds-builtin-classes)
|
|
35
|
-
*/
|
|
36
|
-
classes: {
|
|
37
|
-
Association: Association
|
|
38
|
-
Composition: Composition
|
|
39
|
-
entity: entity
|
|
40
|
-
event: event
|
|
41
|
-
type: type
|
|
42
|
-
array: array
|
|
43
|
-
struct: struct
|
|
44
|
-
service: service
|
|
45
|
-
}
|
|
46
|
-
types: {}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Add aspects to a given object, for example:
|
|
51
|
-
*
|
|
52
|
-
* @example
|
|
53
|
-
* ```js
|
|
54
|
-
* extend (Object.prototype) .with (class {
|
|
55
|
-
* get foo() { return ... }
|
|
56
|
-
* bar() {...}
|
|
57
|
-
* }.prototype)
|
|
58
|
-
* ```
|
|
59
|
-
*/
|
|
60
|
-
export function extend<T>(target: T): {
|
|
61
|
-
with<E extends readonly unknown[]>(...ext: E): T & Intersect<E>
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Equip a given facade object with getters for lazy-loading modules instead
|
|
66
|
-
* of static requires. Example:
|
|
67
|
-
*
|
|
68
|
-
* @example
|
|
69
|
-
* ```js
|
|
70
|
-
* const facade = lazify ({
|
|
71
|
-
* sub: lazy => require ('./sub-module')
|
|
72
|
-
* })
|
|
73
|
-
* ```
|
|
74
|
-
*
|
|
75
|
-
* The first usage of `facade.sub` will load the sub module
|
|
76
|
-
* using standard Node.js's `module.require` functions.
|
|
77
|
-
*/
|
|
78
|
-
export function lazify <T>(target: T) : T
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* Prepare a node module for lazy-loading submodules instead
|
|
82
|
-
* of static requires. Example:
|
|
83
|
-
*
|
|
84
|
-
* @example
|
|
85
|
-
* ```js
|
|
86
|
-
* require = lazify (module) //> turns require into a lazy one
|
|
87
|
-
* const facade = module.exports = {
|
|
88
|
-
* sub: require ('./sub-module')
|
|
89
|
-
* })
|
|
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
|
-
export function lazified <T>(target: T) : T
|
package/apis/cqn.d.ts
DELETED
|
@@ -1,87 +0,0 @@
|
|
|
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
|
-
/** @private */
|
|
60
|
-
type scalar = number | string | boolean | null
|
|
61
|
-
/** @private */
|
|
62
|
-
type data = Record<string,any>
|
|
63
|
-
/** @private */
|
|
64
|
-
type name = string
|
|
65
|
-
/** @private */
|
|
66
|
-
type source = ( ref | SELECT ) & { as?: name, join?:name, on?:xpr }
|
|
67
|
-
export type column_expr = expr & { as?: name, cast?:any, expand?: column_expr[], inline?: column_expr[] }
|
|
68
|
-
export type predicate = _xpr
|
|
69
|
-
/** @private */
|
|
70
|
-
type ordering_term = expr & { sort?: "asc"|"desc", nulls?: "first"|"last" }
|
|
71
|
-
|
|
72
|
-
export type expr = ref | val | xpr | function_call | SELECT
|
|
73
|
-
/** @private */
|
|
74
|
-
type ref = {ref:( name & { id?:string, where?:expr, args?:expr[] } )[]}
|
|
75
|
-
/** @private */
|
|
76
|
-
type val = {val:any}
|
|
77
|
-
/** @private */
|
|
78
|
-
type xpr = {xpr:_xpr}
|
|
79
|
-
/** @private */
|
|
80
|
-
type _xpr = ( expr | operator ) []
|
|
81
|
-
/** @private */
|
|
82
|
-
type operator = string
|
|
83
|
-
/** @private */
|
|
84
|
-
type function_call = {func: string, args: {[key: string]: unknown}[]}
|
|
85
|
-
|
|
86
|
-
export type enum_literal = {"#": string}
|
|
87
|
-
export type expr_literal = {"=": string}
|
package/apis/csn.d.ts
DELETED
|
@@ -1,117 +0,0 @@
|
|
|
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
|
-
/**
|
|
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>
|
|
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
|
-
}
|
|
101
|
-
|
|
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
|
-
}
|
package/apis/env.d.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Access to the configuration for Node.js runtime and tools.
|
|
3
|
-
* The object is the effective result of configuration merged from various sources,
|
|
4
|
-
* filtered through the currently active profiles, thus highly dependent on the current working
|
|
5
|
-
* directory and process environment.
|
|
6
|
-
*/
|
|
7
|
-
export const env : {
|
|
8
|
-
build: any,
|
|
9
|
-
hana: any,
|
|
10
|
-
i18n: any,
|
|
11
|
-
mtx: any,
|
|
12
|
-
requires: any,
|
|
13
|
-
folders: any,
|
|
14
|
-
odata: any,
|
|
15
|
-
query: any,
|
|
16
|
-
sql: any
|
|
17
|
-
} & { [key: string]: any } // to allow additional values we have not yet captured
|
|
18
|
-
|
|
19
|
-
export const requires: any
|
|
20
|
-
export const version: string
|
|
21
|
-
export const home: string
|
|
22
|
-
export const root: string
|
package/apis/events.d.ts
DELETED
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import { LinkedDefinition } from './linked'
|
|
2
|
-
import { Query } from './cqn'
|
|
3
|
-
import { ref } from './cqn'
|
|
4
|
-
import * as express from 'express'
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Represents the invocation context of incoming request and event messages.
|
|
9
|
-
* @see [capire docs](https://cap.cloud.sap/docs/node.js/events)
|
|
10
|
-
*/
|
|
11
|
-
export class EventContext {
|
|
12
|
-
constructor(properties:{event:string, data?:object, query?:object, headers?:object});
|
|
13
|
-
http?: {req: express.Request, res: express.Response}
|
|
14
|
-
tenant: string
|
|
15
|
-
user: User
|
|
16
|
-
id: string
|
|
17
|
-
locale: `${string}_${string}`
|
|
18
|
-
timestamp: Date
|
|
19
|
-
features?: { [key: string]: boolean }
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* @see [capire docs](https://cap.cloud.sap/docs/node.js/events)
|
|
24
|
-
*/
|
|
25
|
-
export class Event extends EventContext {
|
|
26
|
-
event: string
|
|
27
|
-
data: any
|
|
28
|
-
headers: any
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* @see [capire docs](https://cap.cloud.sap/docs/node.js/events)
|
|
33
|
-
*/
|
|
34
|
-
export class Request extends Event {
|
|
35
|
-
params: (string | {})[]
|
|
36
|
-
method: string
|
|
37
|
-
path: string
|
|
38
|
-
target: LinkedDefinition
|
|
39
|
-
/**
|
|
40
|
-
* Shortcut to {@link Request.target | target (entity) name}
|
|
41
|
-
* @see https://cap.cloud.sap/docs/node.js/events#req-entity
|
|
42
|
-
*/
|
|
43
|
-
entity: string
|
|
44
|
-
query: Query
|
|
45
|
-
subject: ref
|
|
46
|
-
|
|
47
|
-
reply(results: any): void
|
|
48
|
-
|
|
49
|
-
notify(code: number, message: string, target?: string, args?: any[]): Error
|
|
50
|
-
info(code: number, message: string, target?: string, args?: any[]): Error
|
|
51
|
-
warn(code: number, message: string, target?: string, args?: any[]): Error
|
|
52
|
-
error(code: number, message: string, target?: string, args?: any[]): Error
|
|
53
|
-
reject(code: number, message: string, target?: string, args?: any[]): Error
|
|
54
|
-
|
|
55
|
-
notify(code: number, message: string, args?: any[]): Error
|
|
56
|
-
info(code: number, message: string, args?: any[]): Error
|
|
57
|
-
warn(code: number, message: string, args?: any[]): Error
|
|
58
|
-
error(code: number, message: string, args?: any[]): Error
|
|
59
|
-
reject(code: number, message: string, args?: any[]): Error
|
|
60
|
-
|
|
61
|
-
notify(message: string, target?: string, args?: any[]): Error
|
|
62
|
-
info(message: string, target?: string, args?: any[]): Error
|
|
63
|
-
warn(message: string, target?: string, args?: any[]): Error
|
|
64
|
-
error(message: string, target?: string, args?: any[]): Error
|
|
65
|
-
reject(message: string, target?: string, args?: any[]): Error
|
|
66
|
-
|
|
67
|
-
notify(message: { code?: number | string; message: string; target?: string; args?: any[] }): Error
|
|
68
|
-
info(message: { code?: number | string; message: string; target?: string; args?: any[] }): Error
|
|
69
|
-
warn(message: { code?: number | string; message: string; target?: string; args?: any[] }): Error
|
|
70
|
-
error(message: { code?: number | string; message: string; target?: string; args?: any[], status?: number }): Error
|
|
71
|
-
reject(message: { code?: number | string; message: string; target?: string; args?: any[], status?: number }): Error
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* Represents the user in a given context.
|
|
77
|
-
* @see [capire docs](https://cap.cloud.sap/docs/node.js/authentication#cds-user)
|
|
78
|
-
*/
|
|
79
|
-
export class User {
|
|
80
|
-
constructor(obj?: string | { id: string; attr: Record<string, string>; roles: Record<string, string> } | User)
|
|
81
|
-
id: string
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* @deprecated Use https://cap.cloud.sap/docs/node.js/events#locale instead
|
|
85
|
-
*/
|
|
86
|
-
locale: string
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* @deprecated Use https://cap.cloud.sap/docs/node.js/events#tenant instead
|
|
90
|
-
*/
|
|
91
|
-
tenant: string | undefined
|
|
92
|
-
|
|
93
|
-
attr: Record<string, string>
|
|
94
|
-
roles: Array<string> | Record<string, string>
|
|
95
|
-
static Privileged: typeof Privileged
|
|
96
|
-
is(role: string): boolean
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* Subclass for executing code with superuser privileges.
|
|
101
|
-
*/
|
|
102
|
-
declare class Privileged extends User {
|
|
103
|
-
constructor()
|
|
104
|
-
is(): boolean
|
|
105
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
// Types in this file are not part of the API.
|
|
2
|
-
// They are merely meant as definitions that are used
|
|
3
|
-
// in several places within the API.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export interface Constructable<T = any> {
|
|
7
|
-
new(...args: any[]): T
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
// any class (not value) of array to represent plural types used in cds-typer.
|
|
11
|
-
// Mainly used as pattern match for SingularType
|
|
12
|
-
//type ArrayConstructable = Constructable<Array<unknown>>
|
|
13
|
-
export interface ArrayConstructable<T = any> {
|
|
14
|
-
new(...args: any[]): T[]
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
// concrete singular type.
|
|
18
|
-
// `SingularType<typeof Books>` == `Book`.
|
|
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
|
package/apis/linked.d.ts
DELETED
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import { CSN, FQN, Association, Definition, entity, kinds } from "./csn"
|
|
2
|
-
|
|
3
|
-
export type LinkedDefinition = linked & Definition & LinkedEntity & LinkedAssociation
|
|
4
|
-
export type Definitions = { [name: string]: LinkedDefinition }
|
|
5
|
-
// FIXME: this is only a temporary alias. Definitions is actually correct,
|
|
6
|
-
// but the name may be misleading, as it is indeed a mapping of strings to LinkedDefinition objects.
|
|
7
|
-
export type LinkedDefinitions = Definitions
|
|
8
|
-
export interface linked {
|
|
9
|
-
is(kind: kinds | 'Association' | 'Composition'): boolean
|
|
10
|
-
name: FQN
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
interface LinkedEntity extends linked, entity {
|
|
14
|
-
constructor (properties: object)
|
|
15
|
-
keys: Definitions
|
|
16
|
-
drafts: LinkedEntity
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
interface LinkedAssociation extends linked, Association {
|
|
20
|
-
is2one: boolean
|
|
21
|
-
is2many: boolean
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export interface LinkedCSN extends CSN {
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Fetches definitions matching the given filter, returning an iterator on them.
|
|
28
|
-
* @example
|
|
29
|
-
* ```js
|
|
30
|
-
* let m = cds.reflect (aParsedModel)
|
|
31
|
-
* for (let d of m.each('entity')) console.log (d.kind, d.name)
|
|
32
|
-
* let entities = [...m.each('entity')] //> capture all
|
|
33
|
-
* let entities = m.all('entity') //> equivalent shortcut
|
|
34
|
-
* ```
|
|
35
|
-
*/
|
|
36
|
-
each(x: Filter, defs?: Definitions): IterableIterator<any>
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Fetches definitions matching the given filter, returning them in an array.
|
|
40
|
-
* Convenience shortcut for `[...reflect.each('entity')]`
|
|
41
|
-
*/
|
|
42
|
-
all(x: Filter, defs?: Definitions): any[]
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Fetches definitions matching the given filter, returning the first match, if any.
|
|
46
|
-
* @example
|
|
47
|
-
* let service = model.find('service')
|
|
48
|
-
* @param x - the filter
|
|
49
|
-
* @param defs - the definitions to fetch in, default: `this.definitions`
|
|
50
|
-
*/
|
|
51
|
-
find(x: Filter, defs?: Definitions): any
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Calls the visitor for each definition matching the given filter.
|
|
55
|
-
* @see [capire](https://github.wdf.sap.corp/pages/cap/node.js/api#cds-reflect-foreach)
|
|
56
|
-
*/
|
|
57
|
-
foreach(x: Filter, visitor: Visitor, defs?: Definitions): this
|
|
58
|
-
foreach(visitor: Visitor, defs?: Definitions): this
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Same as foreach but recursively visits each element definition
|
|
62
|
-
* @see [capire](https://github.wdf.sap.corp/pages/cap/node.js/api#cds-reflect-foreach)
|
|
63
|
-
*/
|
|
64
|
-
forall(x: Filter, visitor: Visitor, defs?: Definitions): this
|
|
65
|
-
forall(visitor: Visitor, defs?: Definitions): this
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* Fetches definitions declared as children of a given parent context or service.
|
|
69
|
-
* It fetches all definitions whose fully-qualified names start with the parent's name.
|
|
70
|
-
* Returns the found definitions as an object with the local names as keys.
|
|
71
|
-
* @example
|
|
72
|
-
* ```js
|
|
73
|
-
* let service = model.find ('service')
|
|
74
|
-
* let entities = m.childrenOf (service)
|
|
75
|
-
* ```
|
|
76
|
-
* @param parent - either the parent itself or its fully-qualified name
|
|
77
|
-
* @param filter - an optional filter to apply before picking a child
|
|
78
|
-
*/
|
|
79
|
-
childrenOf(parent: any | string, filter?: ((def: LinkedDefinition) => boolean)): Definitions
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* Provides convenient access to the model's top-level definitions.
|
|
83
|
-
* For example, you can use it in an es6-import-like fashion to avoid
|
|
84
|
-
* working with fully-qualified names as follows:
|
|
85
|
-
*
|
|
86
|
-
* @example
|
|
87
|
-
* ```js
|
|
88
|
-
* let model = cds.reflect (cds.parse(`
|
|
89
|
-
* namespace our.lovely.bookshop;
|
|
90
|
-
* entity Books {...}
|
|
91
|
-
* entity Authors {...}
|
|
92
|
-
* `))
|
|
93
|
-
* const {Books,Authors} = model.exports
|
|
94
|
-
* SELECT.from (Books) .where ({ID:11})
|
|
95
|
-
* ```
|
|
96
|
-
*/
|
|
97
|
-
exports: Definitions & ((namespace: string) => Definitions)
|
|
98
|
-
entities: Definitions & ((namespace: string) => Definitions)
|
|
99
|
-
services: Definitions & ((namespace: string) => Definitions)
|
|
100
|
-
definitions: Definitions
|
|
101
|
-
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
type Visitor = (def: LinkedDefinition, name: string, parent: LinkedDefinition, defs: Definitions) => void
|
|
105
|
-
type Filter = string | ((def: LinkedDefinition) => boolean)
|