@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/apis/log.d.ts DELETED
@@ -1,164 +0,0 @@
1
-
2
- /**
3
- * Create a new logger, or install a custom log formatter
4
- */
5
- export declare const log: LogFactory
6
-
7
- /**
8
- * Shortcut to `cds.log(...).debug`, returning `undefined` if `cds.log(...)._debug` is `false`.
9
- * Use like this:
10
- * @example
11
- * ```js
12
- * const dbg = cds.debug('foo')
13
- * ...
14
- * dbg && dbg('message')
15
- * ```
16
- *
17
- * @param name - logger name
18
- */
19
- export declare function debug(name: string): undefined | Log
20
-
21
- declare type LogFactory = {
22
-
23
- /**
24
- * Returns a trace logger for the given module if trace is switched on for it,
25
- * otherwise returns null. All cds runtime packages use this method for their
26
- * trace and debug output.
27
- *
28
- * By default this logger would prefix all output with `[sql] - `
29
- * You can change this by specifying another prefix in the options:
30
- * @example
31
- * ```js
32
- * const LOG = cds.log('sql|db', { prefix: 'cds.ql' })
33
- * ```
34
- *
35
- * Call `cds.log()` for a given module again to dynamically change the log level
36
- * of all formerly created loggers, for example:
37
- * @example
38
- * ```js
39
- * const LOG = cds.log('sql')
40
- * LOG.info ('this will show, as default level is info')
41
- * cds.log('sql', 'warn')
42
- * LOG.info('this will be suppressed now')
43
- * ```
44
- *
45
- * @param name - logger name
46
- * @param options - level, label and prefix
47
- * @returns the logger
48
- * @see [capire](https://cap.cloud.sap/docs/node.js/cds-log)
49
- */
50
- (name: string, options?: string | number | { level?: number, label?: string, prefix?: string }): Logger
51
-
52
- /**
53
- * Set a custom formatter function like that:
54
- * ```js
55
- * cds.log.format = (module, level, ...args) => [ '[', module, ']', ...args ]
56
- * ```
57
- *
58
- * The formatter shall return an array of arguments, which are passed to the logger (for example, `console.log()`)
59
- */
60
- format: Formatter
61
-
62
- /**
63
- * Set a custom logger.
64
- * ```js
65
- * cds.log.Logger = ...
66
- * ```
67
- */
68
- Logger: Logger
69
-
70
- winstonLogger (LoggerOptions?: {level?: string, levels?: any, format?: any, transports?: any, exitOnError?: boolean | Function, silent?: boolean})
71
- }
72
-
73
- declare class Logger {
74
- /**
75
- * Logs with 'trace' level
76
- */
77
- trace: Log
78
-
79
- /**
80
- * Logs with 'debug' level
81
- */
82
- debug: Log
83
-
84
- /**
85
- * Logs with 'info' level
86
- */
87
- info: Log
88
-
89
- /**
90
- * Logs with 'warn' level
91
- */
92
- warn: Log
93
-
94
- /**
95
- * Logs with 'error' level
96
- */
97
- error: Log
98
-
99
- /**
100
- * Logs with default level
101
- */
102
- log: Log
103
-
104
- /**
105
- * @returns whether 'trace' level is active
106
- */
107
- _trace: boolean
108
-
109
- /**
110
- * @returns whether 'debug' level is active
111
- */
112
- _debug: boolean
113
-
114
- /**
115
- * @returns whether 'info' level is active
116
- */
117
- _info: boolean
118
-
119
- /**
120
- * @returns whether 'warn' level is active
121
- */
122
- _warn: boolean
123
-
124
- /**
125
- * @returns whether 'error' level is active
126
- */
127
- _error: boolean
128
-
129
- /**
130
- * Change the format for this logger instance:
131
- * ```
132
- * cds.log('foo').setFormat((module, level, ...args) => [ '[', module, ']', ...args ])
133
- * ```
134
- *
135
- * The formatter shall return an array of arguments, which are passed to the logger (for example, `console.log()`)
136
- */
137
- setFormat(formatter: Formatter)
138
- }
139
-
140
- declare type Formatter = {
141
- /**
142
- * Custom format function
143
- *
144
- * @param module - logger name
145
- * @param level - log level
146
- * @param args - additional arguments
147
- * @returns an array of arguments, which are passed to the logger (for example, `console.log()`)
148
- */
149
- (module: string, level: number, args: any[]): any[]
150
- }
151
-
152
- declare type Log = {
153
- /**
154
- * Logs a message
155
- *
156
- * @param message - text to log
157
- * @param optionalParams - additional parameters, same as in `console.log(text, param1, ...)`
158
- */
159
- (message?: any, ...optionalParams: any[]): void
160
- }
161
-
162
- declare enum levels {
163
- SILENT = 0, ERROR = 1, WARN = 2, INFO = 3, DEBUG = 4, TRACE = 5, SILLY = 5, VERBOSE = 5
164
- }
package/apis/models.d.ts DELETED
@@ -1,171 +0,0 @@
1
- import { Query as CQN, expr, _xpr } from "./cqn"
2
- import { LinkedCSN } from "./linked"
3
- import { CSN } from "./csn"
4
- import * as cds from './cds'
5
-
6
- type _flavor = 'parsed' | 'xtended' | 'inferred'
7
- type _odata_options = {
8
- flavor?: 'v2' | 'v4' | 'w4'| 'x4',
9
- version?: 'v2' | 'v4',
10
- structs?: boolean,
11
- refs?: boolean,
12
- }
13
- type _options = {
14
- flavor?: _flavor,
15
- plain?: boolean,
16
- docs?: boolean,
17
- names?: string,
18
- odata?: _odata_options,
19
- } | _flavor
20
-
21
- type JSON = string
22
- type YAML = string
23
- type CDL = string
24
- type SQL = string
25
- type XML = string
26
- type EDM = { $version:string }
27
- type EDMX = XML
28
- type filename = string
29
-
30
-
31
- /**
32
- * The effective CDS model loaded during bootstrapping, which contains all service and entity definitions,
33
- * including required services.
34
- */
35
- export const model : LinkedCSN | undefined // was ?: LinkedCSN
36
-
37
- /**
38
- * Provides a set of methods to parse a given model, query or expression.
39
- * You can also use `cds.parse()` as a shortcut to `cds.parse.cdl()`.
40
- */
41
- export const parse : {
42
- /** Shortcut to `cds.parse.cdl()` */
43
- (cdl:CDL) : CSN
44
- cdl (cdl:CDL) : CSN
45
- cql (src:string) : CQN
46
- expr (src:string) : expr
47
- xpr (src:string) : _xpr
48
- ref (src:string) : string[]
49
- }
50
-
51
- /**
52
- * Loads and parses models from the specified files.
53
- * Uses `cds.resolve` to fetch the respective models.
54
- * Essentially a shortcut for `cds.compile.to.csn(files)`
55
- * @param files - filenames of models or if folder containing models
56
- */
57
- export function get (files: '*' | filename | filename[], o?:_options): Promise<CSN>
58
-
59
- /**
60
- * Shortcut for `cds.get(files, 'inferred')`
61
- * @param files - filenames of models or if folder containing models
62
- */
63
- export function load (files: '*' | filename | filename[], o?:_options): Promise<CSN>
64
-
65
-
66
- /**
67
- * Resolves given file or module name(s) to an array of absolute file names.
68
- * Uses Node's `require.resolve` internally with the following additions:
69
- * - relative names are resolved relative to the current working directory instead of the current JavaScript module; hence, use __dirname if you want to find or load models relative to the current module.
70
- * - if no file extension is given, `.csn` and `.cds` will be appended in that order.
71
- * @param files - The file or module name(s) of a model or a folder containing models. Specify `'*'` to fetch moels from default locations, i.e. `[ 'db/', 'srv/', 'app/' ]`
72
- * @returns An array of absolute file names or `undefined` if none could be resolved.
73
- */
74
- export function resolve (files: '*' | filename | filename[]): filename[] | undefined
75
-
76
- /**
77
- * Turns the given plain CSN model into a linked model
78
- * @see [capire](https://cap.cloud.sap/docs/node.js/cds-reflect)
79
- */
80
- declare const linked: (model: CSN) => LinkedCSN
81
-
82
- /**
83
- * Turns the given plain CSN model into a reflected model
84
- * @see [capire](https://cap.cloud.sap/docs/node.js/cds-reflect)
85
- */
86
- export const reflect: (model: CSN) => LinkedCSN
87
-
88
- /**
89
- * Provides a set of methods to parse a given model, query or expression.
90
- * You can also use `cds.compile(csn).to('<output>')` as a fluent variant.
91
- */
92
- export const compile: {
93
- /** Shortcut for `cds.compile.to.csn()` */
94
- cdl (model:CDL, o?:_options) : CSN,
95
-
96
- for: {
97
- odata (model:CSN, o?:_options) : CSN
98
- sql (model:CSN, o?:_options) : CSN
99
- },
100
- to: {
101
- parsed:{
102
- csn (files:filename[], o?:_options) : Promise<CSN>
103
- csn (model:CDL, o?:_options) : CSN
104
- }
105
- xtended:{
106
- csn (files:filename[], o?:_options) : Promise<CSN>
107
- csn (model:CDL, o?:_options) : CSN
108
- }
109
- inferred:{
110
- csn (files:filename[], o?:_options) : Promise<CSN>
111
- csn (model:CDL, o?:_options) : CSN
112
- }
113
- csn (files:filename[], o?:_options) : Promise<CSN>
114
- csn (model:CDL, o?:_options) : CSN
115
- yml (model:CSN, o?:_options) : YAML
116
- yaml (model:CSN, o?:_options) : YAML
117
- json (model:CSN, o?:_options) : JSON
118
- sql (model:CSN, o?:_options) : SQL[]
119
- cdl (model:CSN, o?:_options) : CDL | Iterable<[CDL,{file:filename}]>
120
- edm (model:CSN, o?:_options|_odata_options) : EDM | string
121
- edmx (model:CSN, o?:_options|_odata_options) : EDMX | Iterable<[EDMX,{file:filename}]>
122
- hdbcds (model:CSN, o?:_options) : SQL | Iterable<[SQL,{file:filename}]>
123
- hdbtable (model:CSN, o?:_options) : SQL | Iterable<[SQL,{file:filename}]>
124
- }
125
-
126
- /** Fluent API variant */
127
- (model: CSN | CDL) : {
128
- for: {
129
- odata (o?:_options) : CSN
130
- sql (o?:_options) : CSN
131
- },
132
- to: {
133
- parsed:{ csn (o?:_options) : CSN }
134
- xtended:{ csn (o?:_options) : CSN }
135
- inferred:{ csn (o?:_options) : CSN }
136
- csn (o?:_options) : CSN
137
- yml (o?:_options) : YAML
138
- yaml (o?:_options) : YAML
139
- json (o?:_options) : JSON
140
- sql (o?:_options) : SQL[]
141
- cdl (o?:_options) : CDL | Iterable<[CDL,{file:filename}]>
142
- edm (o?:_options|_odata_options) : EDM | string
143
- edmx (o?:_options|_odata_options) : EDMX | Iterable<[EDMX,{file:filename}]>
144
- hdbcds (o?:_options) : SQL | Iterable<[SQL,{file:filename}]>
145
- hdbtable (o?:_options) : SQL | Iterable<[SQL,{file:filename}]>
146
- }
147
- }
148
-
149
- /** Async fluent variant reading from files */
150
- (files: filename[]) : {
151
- for: {
152
- odata (o?:_options) : Promise<CSN>
153
- sql (o?:_options) : Promise<CSN>
154
- },
155
- to: {
156
- parsed:{ csn (o?:_options) : Promise <CSN> }
157
- xtended:{ csn (o?:_options) : Promise <CSN> }
158
- inferred:{ csn (o?:_options) : Promise <CSN> }
159
- csn (o?:_options) : Promise <CSN>
160
- yml (o?:_options) : Promise <YAML>
161
- yaml (o?:_options) : Promise <YAML>
162
- json (o?:_options) : Promise <JSON>
163
- sql (o?:_options) : Promise <SQL[]>
164
- cdl (o?:_options) : Promise <CDL | Iterable<[CDL,{file:filename}]>>
165
- edm (o?:_options|_odata_options) : Promise <EDM | string>
166
- edmx (o?:_options|_odata_options) : Promise <EDMX | Iterable<[EDMX,{file:filename}]>>
167
- hdbcds (o?:_options) : Promise <SQL | Iterable<[SQL,{file:filename}]>>
168
- hdbtable (o?:_options) : Promise <SQL | Iterable<[SQL,{file:filename}]>>
169
- }
170
- }
171
- }
package/apis/ql.d.ts DELETED
@@ -1,327 +0,0 @@
1
- import { CSN, Definition, EntityElements } from "./csn"
2
- import * as CQN from "./cqn"
3
- import { Constructable, ArrayConstructable, SingularType } from "./internal/inference"
4
- import { LinkedEntity } from "./linked"
5
- import { ref, column_expr } from './cqn'
6
-
7
- export type Query = CQN.Query
8
-
9
- export class ConstructedQuery {
10
- then(_resolved:(x:any)=>any, _rejected:(e:Error)=>any) : any
11
- }
12
-
13
-
14
- export type PK = number | string | object
15
-
16
-
17
- type Primitive = string | number | boolean | Date
18
-
19
- // don't wrap QLExtensions in more QLExtensions (indirection to work around recursive definition)
20
- type QLExtensions<T> = T extends QLExtensions_<any> ? T : QLExtensions_<T>
21
-
22
- /**
23
- * QLExtensions are properties that are attached to entities in CQL contexts.
24
- * They are passed down to all properties recursively.
25
- */
26
- type QLExtensions_<T> = {
27
- [Key in keyof T]: QLExtensions<T[Key]>
28
- } & {
29
- /**
30
- * Alias for this attribute.
31
- */
32
- as: (alias: string) => void
33
-
34
- /**
35
- * Accesses any nested attribute based on a [path](https://cap.cloud.sap/cap/docs/java/query-api#path-expressions):
36
- * `X.get('a.b.c.d')`. Note that you will not receive
37
- * proper typing after this call.
38
- * To still have access to typed results, use
39
- * `X.a().b().c().d()` instead.
40
- */
41
- get: (path: string) => any
42
-
43
- // have to exclude undefined from the type, or we'd end up with a distribution of Subqueryable
44
- // over T and undefined, which gives us zero code completion within the callable.
45
- } & Subqueryable<Exclude<T, undefined>>
46
-
47
- /**
48
- * Adds the ability for subqueries to structured properties.
49
- * The final result of each subquery will be the property itself:
50
- * `Book.title` == `Subqueryable<Book>.title()`
51
- */
52
- type Subqueryable<T> =
53
- T extends Primitive ? {}
54
- // composition of many/ association to many
55
- : T extends readonly unknown[] ? {
56
- /**
57
- * @example
58
- * ```js
59
- * SELECT.from(Books, b => b.author)
60
- * ```
61
- * means: "select all books and project each book's author"
62
- *
63
- * whereas
64
- * ```js
65
- * SELECT.from(Books, b => b.author(a => a.ID))
66
- * ```
67
- * means: "select all books, subselect each book's author's ID
68
- *
69
- * Note that you do not need to return anything from these subqueries.
70
- */
71
- (fn: ((a:QLExtensions<T[number]>) => any) | '*'): T[number]
72
- }
73
- // composition of one/ association to one
74
- : {
75
- /**
76
- * @example
77
- * ```js
78
- * SELECT.from(Books, b => b.author)
79
- * ```
80
- * means: "select all books and project each book's author"
81
- *
82
- * whereas
83
- * ```js
84
- * SELECT.from(Books, b => b.author(a => a.ID))
85
- * ```
86
- * means: "select all books, subselect each book's author's ID
87
- *
88
- * Note that you do not need to return anything from these subqueries.
89
- */
90
- (fn: ((a:QLExtensions<T>) => any) | '*'): T
91
- }
92
- ;
93
-
94
-
95
- // Alias for projections
96
- // https://cap.cloud.sap/docs/node.js/cds-ql?q=projection#projection-functions
97
- //export type Projection<T> = (e:T)=>void
98
- export type Projection<T> = (e:QLExtensions<T extends ArrayConstructable ? SingularType<T> : T>)=>void
99
- // Type for query pieces that can either be chained to build more complex queries or
100
- // awaited to materialise the result:
101
- // `Awaitable<SELECT<Book>, Book> = SELECT<Book> & Promise<Book>`
102
- //
103
- // While the benefit is probably not immediately obvious as we don't exactly
104
- // save a lot of typing over explicitly writing `SELECT<Book> & Promise<Book>`,
105
- // it makes the semantics more explicit. Also sets us up for when TypeScript ever
106
- // improves their generics to support:
107
- //
108
- // `Awaitable<T> = T extends unknown<infer I> ? (T & Promise<I>) : never`
109
- // (at the time of writing, infering the first generic parameter of ANY type
110
- // does not seem to be possible.)
111
- export type Awaitable<T, I> = T & Promise<I>
112
-
113
- // all the functionality of an instance of SELECT, but directly callable:
114
- // new SELECT(...).(...) == SELECT(...)
115
- export type StaticSELECT<T> = typeof SELECT
116
- & ((...columns: (T extends ArrayConstructable<any> ? keyof SingularType<T> : keyof T)[]) => SELECT<T>)
117
- & ((...columns:string[]) => SELECT<T>)
118
- & ((columns:string[]) => SELECT<T>)
119
- & (TaggedTemplateQueryPart<SELECT<T>>)
120
- & SELECT_one // as it is not directly quantified, ...
121
- & SELECT_from // ...we should expect both a scalar and a list
122
-
123
- declare class QL<T> {
124
- SELECT : StaticSELECT<T>
125
- INSERT : typeof INSERT
126
- & ((...entries:object[]) => INSERT<any>) & ((entries:object[]) => INSERT<any>)
127
- UPSERT: typeof UPSERT
128
- & ((...entries:object[]) => UPSERT<any>) & ((entries:object[]) => UPSERT<any>)
129
- UPDATE : typeof UPDATE
130
- & typeof UPDATE.entity
131
- DELETE : typeof DELETE
132
- & ((...entries:object[]) => DELETE<any>) & ((entries:object[]) => DELETE<any>)
133
- CREATE : typeof CREATE
134
- DROP : typeof DROP
135
- }
136
-
137
- // used as a catch-all type for using tagged template strings: SELECT `foo`. from `bar` etc.
138
- // the resulting signatures are actually not very strongly typed, but they at least accept template strings
139
- // when run in strict mode.
140
- // This signature has to be added to a method as intersection type.
141
- // Defining overloads with it will override preceding signatures and the other way around.
142
- type TaggedTemplateQueryPart<T> = (strings: TemplateStringsArray, ...params: unknown[]) => T
143
-
144
- export class SELECT<T> extends ConstructedQuery {
145
- static one : SELECT_one & { from: SELECT_one }
146
- static distinct : typeof SELECT
147
- static from : SELECT_from
148
- from: SELECT_from & TaggedTemplateQueryPart<this>
149
- & ((entity: Definition | string, primaryKey? : PK, projection? : Projection<unknown>) => this)
150
- byKey (primaryKey? : PK) : this
151
- columns: TaggedTemplateQueryPart<this>
152
- & ((projection: Projection<T>) => this)
153
- & ((...col: (T extends ArrayConstructable<any> ? keyof SingularType<T> : keyof T)[]) => this)
154
- & ((...col:(string | column_expr)[]) => this)
155
- & ((col:(string | column_expr)[]) => this)
156
- where: TaggedTemplateQueryPart<this>
157
- & ((predicate:object) => this)
158
- & ((...expr : any[]) => this)
159
- and: TaggedTemplateQueryPart<this>
160
- & ((predicate:object) => this)
161
- & ((...expr : any[]) => this)
162
- having: TaggedTemplateQueryPart<this>
163
- & ((...expr : string[]) => this)
164
- & ((predicate:object) => this)
165
- groupBy: TaggedTemplateQueryPart<this>
166
- & ((...expr : string[]) => this)
167
- orderBy: TaggedTemplateQueryPart<this>
168
- & ((...expr : string[]) => this)
169
- limit: TaggedTemplateQueryPart<this>
170
- & ((rows : number, offset? : number) => this)
171
- forShareLock () : this
172
- forUpdate ({wait}? : {wait?: number}) : this
173
- alias (as: string) : this
174
-
175
- elements: EntityElements
176
-
177
-
178
- // Not yet public
179
- // fullJoin (other: string, as: string) : this
180
- // leftJoin (other: string, as: string) : this
181
- // rightJoin (other: string, as: string) : this
182
- // innerJoin (other: string, as: string) : this
183
- // join (other: string, as: string, kind?: string) : this
184
- // on : TaggedTemplateQueryPart<this>
185
- // & ((...expr : string[]) => this)
186
- // & ((predicate:object) => this)
187
-
188
- SELECT : CQN.SELECT["SELECT"] & {
189
- forUpdate?: { wait: number }
190
- forShareLock?: { wait: number }
191
- search?: CQN.predicate
192
- count?: boolean
193
- }
194
- }
195
-
196
-
197
- type SELECT_one =
198
- TaggedTemplateQueryPart<Awaitable<SELECT<unknown>, InstanceType<any>>>
199
- &
200
- // calling with class
201
- (<T extends ArrayConstructable<any>>
202
- (entityType: T, projection?: Projection<QLExtensions<SingularType<T>>>)
203
- => Awaitable<SELECT<SingularType<T>>, SingularType<T>>)
204
- &
205
- (<T extends ArrayConstructable<any>>
206
- (entityType: T, primaryKey : PK, projection?: Projection<QLExtensions<SingularType<T>>>)
207
- => Awaitable<SELECT<SingularType<T>>, SingularType<T>>)
208
-
209
- & ((entity: Definition | string, primaryKey? : PK, projection? : Projection<unknown>) => SELECT<any>)
210
- & ((entity: LinkedEntity | string, primaryKey? : PK, projection? : Projection<unknown>) => SELECT<any>)
211
- & (<T> (entity: T[], projection? : Projection<T>) => Awaitable<SELECT<T>, T>)
212
- & (<T> (entity: T[], primaryKey : PK, projection? : Projection<T>) => Awaitable<SELECT<T>, T>)
213
- & (<T> (entity: {new():T}, projection? : Projection<T>) => Awaitable<SELECT<T>, T>)
214
- & (<T> (entity: {new():T}, primaryKey : PK, projection? : Projection<T>) => Awaitable<SELECT<T>, T>)
215
- & ((subject: ref) => SELECT<any>)
216
-
217
- type SELECT_from =
218
- // tagged template
219
- TaggedTemplateQueryPart<Awaitable<SELECT<unknown>, InstanceType<any>>>
220
- &
221
- // calling with class
222
- (<T extends ArrayConstructable<any>>
223
- (entityType: T, projection?: Projection<QLExtensions<SingularType<T>>>)
224
- => Awaitable<SELECT<T>, InstanceType<T>>)
225
- &
226
- (<T extends ArrayConstructable<any>>
227
- (entityType: T, primaryKey : PK, projection?: Projection<SingularType<T>>)
228
- => Awaitable<SELECT<SingularType<T>>, InstanceType<SingularType<T>>>) // when specifying a key, we expect a single element as result
229
- // calling with definition
230
- & ((entity: Definition | string, primaryKey? : PK, projection? : Projection<unknown>) => SELECT<any>)
231
- & ((entity: LinkedEntity | string, primaryKey? : PK, projection? : Projection<unknown>) => SELECT<any>)
232
- // calling with concrete list
233
- & (<T> (entity: T[], projection? : Projection<T>) => SELECT<T> & Promise<T[]>)
234
- & (<T> (entity: T[], primaryKey : PK, projection? : Projection<T>) => Awaitable<SELECT<T>, T>)
235
- & ((subject: ref) => SELECT<any>)
236
-
237
- export class INSERT<T> extends ConstructedQuery {
238
- static into : (<T extends ArrayConstructable<any>> (entity:T, entries? : object | object[]) => INSERT<SingularType<T>>)
239
- & (TaggedTemplateQueryPart<INSERT<unknown>>)
240
- & ((entity : Definition | string, entries? : object | object[]) => INSERT<any>)
241
- & ((entity : LinkedEntity | string, entries? : object | object[]) => INSERT<any>)
242
- & (<T> (entity:Constructable<T>, entries? : object | object[]) => INSERT<T>)
243
- & (<T> (entity:T, entries? : T | object | object[]) => INSERT<T>)
244
-
245
- into: (<T extends ArrayConstructable> (entity:T) => this)
246
- & TaggedTemplateQueryPart<this>
247
- & ((entity : Definition | string) => this)
248
- data (block : (e:T)=>void) : this
249
- entries (...entries : object[]) : this
250
- columns (...col: (T extends ArrayConstructable<any> ? keyof SingularType<T> : keyof T)[]) : this
251
- columns (...col: string[]) : this
252
- values (... val: any[]) : this
253
- rows (... row: any[]) : this
254
- as (select: SELECT<T>): this
255
- INSERT : CQN.INSERT["INSERT"]
256
- }
257
-
258
-
259
- export class UPSERT<T> extends ConstructedQuery {
260
- static into : (<T extends ArrayConstructable<any>> (entity:T, entries? : object | object[]) => UPSERT<SingularType<T>>)
261
- & (TaggedTemplateQueryPart<UPSERT<unknown>>)
262
- & ((entity : Definition | string, entries? : object | object[]) => UPSERT<any>)
263
- & ((entity : LinkedEntity | string, entries? : object | object[]) => UPSERT<any>)
264
- & (<T> (entity:Constructable<T>, entries? : object | object[]) => UPSERT<T>)
265
- & (<T> (entity:T, entries? : T | object | object[]) => UPSERT<T>)
266
-
267
- into: (<T extends ArrayConstructable> (entity:T) => this)
268
- & TaggedTemplateQueryPart<this>
269
- & ((entity : Definition | string) => this)
270
- data (block : (e:T)=>void) : this
271
- entries (...entries : object[]) : this
272
- columns (...col: (T extends ArrayConstructable<any> ? keyof SingularType<T> : keyof T)[]) : this
273
- columns (...col: string[]) : this
274
- values (... val: any[]) : this
275
- rows (... row: any[]) : this
276
- UPSERT : CQN.UPSERT["UPSERT"]
277
- }
278
-
279
-
280
-
281
- export class DELETE<T> extends ConstructedQuery {
282
- static from:
283
- TaggedTemplateQueryPart<Awaitable<SELECT<unknown>, InstanceType<any>>>
284
- & ((entity : Definition | string | ArrayConstructable, primaryKey? : PK) => DELETE<any>)
285
- & ((entity : LinkedEntity | string | ArrayConstructable, primaryKey? : PK) => DELETE<any>)
286
- & ((subject: ref) => DELETE<any>)
287
- byKey (primaryKey? : PK) : this
288
- where (predicate:object) : this
289
- where (...expr : any[]) : this
290
- and (predicate:object) : this
291
- and (...expr : any[]) : this
292
- DELETE : CQN.DELETE["DELETE"]
293
- }
294
-
295
- export class UPDATE<T> extends ConstructedQuery {
296
- // cds-typer plural
297
- static entity <T extends ArrayConstructable<any>> (entity:T, primaryKey? : PK) : UPDATE<SingularType<T>>
298
-
299
- static entity (entity : Definition | string, primaryKey? : PK) : UPDATE<any>
300
- static entity (entity : LinkedEntity | string, primaryKey? : PK) : UPDATE<any>
301
- static entity <T> (entity:Constructable<T>, primaryKey? : PK) : UPDATE<T>
302
- static entity <T> (entity:T, primaryKey? : PK) : UPDATE<T>
303
- byKey (primaryKey? : PK) : this
304
- // with (block: (e:T)=>void) : this
305
- // set (block: (e:T)=>void) : this
306
- set: TaggedTemplateQueryPart<this>
307
- & ((data:object) => this)
308
- with: TaggedTemplateQueryPart<this>
309
- & ((data:object) => this)
310
- where (predicate:object) : this
311
- where (...expr : any[]) : this
312
- and (predicate:object) : this
313
- and (...expr : any[]) : this
314
- UPDATE : CQN.UPDATE["UPDATE"]
315
- }
316
-
317
- export class CREATE<T> extends ConstructedQuery {
318
- static entity (entity : Definition | string) : CREATE<any>
319
- static entity (entity : LinkedEntity | string) : CREATE<any>
320
- CREATE : CQN.CREATE["CREATE"]
321
- }
322
-
323
- export class DROP<T> extends ConstructedQuery {
324
- static entity (entity : Definition | string) : DROP<any>
325
- static entity (entity : LinkedEntity | string) : DROP<any>
326
- DROP : CQN.DROP["DROP"]
327
- }