@cap-js/cds-types 0.1.0 → 0.2.0

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/ql.d.ts CHANGED
@@ -1,13 +1,15 @@
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"
1
+ import { Definition, EntityElements } from './csn'
2
+ import * as CQN from './cqn'
3
+ import { Constructable, ArrayConstructable, SingularType } from './internal/inference'
4
+ import { LinkedEntity } from './linked'
5
5
  import { ref, column_expr } from './cqn'
6
6
 
7
7
  export type Query = CQN.Query
8
8
 
9
9
  export class ConstructedQuery {
10
- then(_resolved:(x:any)=>any, _rejected:(e:Error)=>any) : any
10
+
11
+ then (_resolved: (x: any) => any, _rejected: (e: Error) => any): any
12
+
11
13
  }
12
14
 
13
15
 
@@ -24,24 +26,25 @@ type QLExtensions<T> = T extends QLExtensions_<any> ? T : QLExtensions_<T>
24
26
  * They are passed down to all properties recursively.
25
27
  */
26
28
  type QLExtensions_<T> = {
27
- [Key in keyof T]: QLExtensions<T[Key]>
29
+ [Key in keyof T]: QLExtensions<T[Key]>
28
30
  } & {
29
- /**
31
+
32
+ /**
30
33
  * Alias for this attribute.
31
34
  */
32
- as: (alias: string) => void
35
+ as: (alias: string) => void,
33
36
 
34
- /**
37
+ /**
35
38
  * Accesses any nested attribute based on a [path](https://cap.cloud.sap/cap/docs/java/query-api#path-expressions):
36
39
  * `X.get('a.b.c.d')`. Note that you will not receive
37
40
  * proper typing after this call.
38
41
  * To still have access to typed results, use
39
42
  * `X.a().b().c().d()` instead.
40
43
  */
41
- get: (path: string) => any
44
+ get: (path: string) => any,
42
45
 
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.
46
+ // have to exclude undefined from the type, or we'd end up with a distribution of Subqueryable
47
+ // over T and undefined, which gives us zero code completion within the callable.
45
48
  } & Subqueryable<Exclude<T, undefined>>
46
49
 
47
50
  /**
@@ -49,11 +52,11 @@ type QLExtensions_<T> = {
49
52
  * The final result of each subquery will be the property itself:
50
53
  * `Book.title` == `Subqueryable<Book>.title()`
51
54
  */
52
- type Subqueryable<T> =
53
- T extends Primitive ? {}
55
+ type Subqueryable<T> = T extends Primitive ? unknown
54
56
  // composition of many/ association to many
55
- : T extends readonly unknown[] ? {
56
- /**
57
+ : T extends readonly unknown[] ? {
58
+
59
+ /**
57
60
  * @example
58
61
  * ```js
59
62
  * SELECT.from(Books, b => b.author)
@@ -68,11 +71,12 @@ T extends Primitive ? {}
68
71
  *
69
72
  * Note that you do not need to return anything from these subqueries.
70
73
  */
71
- (fn: ((a:QLExtensions<T[number]>) => any) | '*'): T[number]
72
- }
73
- // composition of one/ association to one
74
- : {
75
- /**
74
+ (fn: ((a: QLExtensions<T[number]>) => any) | '*'): T[number],
75
+ }
76
+ // composition of one/ association to one
77
+ : {
78
+
79
+ /**
76
80
  * @example
77
81
  * ```js
78
82
  * SELECT.from(Books, b => b.author)
@@ -87,15 +91,14 @@ T extends Primitive ? {}
87
91
  *
88
92
  * Note that you do not need to return anything from these subqueries.
89
93
  */
90
- (fn: ((a:QLExtensions<T>) => any) | '*'): T
91
- }
92
- ;
94
+ (fn: ((a: QLExtensions<T>) => any) | '*'): T,
95
+ }
93
96
 
94
97
 
95
98
  // Alias for projections
96
99
  // 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
100
+ // export type Projection<T> = (e:T)=>void
101
+ export type Projection<T> = (e: QLExtensions<T extends ArrayConstructable ? SingularType<T> : T>) => void
99
102
  // Type for query pieces that can either be chained to build more complex queries or
100
103
  // awaited to materialise the result:
101
104
  // `Awaitable<SELECT<Book>, Book> = SELECT<Book> & Promise<Book>`
@@ -113,25 +116,33 @@ export type Awaitable<T, I> = T & Promise<I>
113
116
  // all the functionality of an instance of SELECT, but directly callable:
114
117
  // new SELECT(...).(...) == SELECT(...)
115
118
  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
119
+ & ((...columns: (T extends ArrayConstructable<any> ? keyof SingularType<T> : keyof T)[]) => SELECT<T>)
120
+ & ((...columns: string[]) => SELECT<T>)
121
+ & ((columns: string[]) => SELECT<T>)
122
+ & (TaggedTemplateQueryPart<SELECT<T>>)
123
+ & SELECT_one // as it is not directly quantified, ...
124
+ & SELECT_from // ...we should expect both a scalar and a list
122
125
 
123
126
  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
127
+
128
+ SELECT: StaticSELECT<T>
129
+
130
+ INSERT: typeof INSERT
131
+ & ((...entries: object[]) => INSERT<any>) & ((entries: object[]) => INSERT<any>)
132
+
133
+ UPSERT: typeof UPSERT
134
+ & ((...entries: object[]) => UPSERT<any>) & ((entries: object[]) => UPSERT<any>)
135
+
136
+ UPDATE: typeof UPDATE
137
+ & typeof UPDATE.entity
138
+
139
+ DELETE: typeof DELETE
140
+ & ((...entries: object[]) => DELETE<any>) & ((entries: object[]) => DELETE<any>)
141
+
142
+ CREATE: typeof CREATE
143
+
144
+ DROP: typeof DROP
145
+
135
146
  }
136
147
 
137
148
  // used as a catch-all type for using tagged template strings: SELECT `foo`. from `bar` etc.
@@ -142,186 +153,243 @@ declare class QL<T> {
142
153
  type TaggedTemplateQueryPart<T> = (strings: TemplateStringsArray, ...params: unknown[]) => T
143
154
 
144
155
  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
156
+
157
+ static one: SELECT_one & { from: SELECT_one }
158
+
159
+ static distinct: typeof SELECT
160
+
161
+ static from: SELECT_from
162
+
163
+ from: SELECT_from & TaggedTemplateQueryPart<this>
164
+ & ((entity: Definition | string, primaryKey?: PK, projection?: Projection<unknown>) => this)
165
+
166
+ byKey (primaryKey?: PK): this
167
+ columns: TaggedTemplateQueryPart<this>
168
+ & ((projection: Projection<T>) => this)
169
+ & ((...col: (T extends ArrayConstructable<any> ? keyof SingularType<T> : keyof T)[]) => this)
170
+ & ((...col: (string | column_expr)[]) => this)
171
+ & ((col: (string | column_expr)[]) => this)
172
+
173
+ where: TaggedTemplateQueryPart<this>
174
+ & ((predicate: object) => this)
175
+ & ((...expr: any[]) => this)
176
+
177
+ and: TaggedTemplateQueryPart<this>
178
+ & ((predicate: object) => this)
179
+ & ((...expr: any[]) => this)
180
+
181
+ having: TaggedTemplateQueryPart<this>
182
+ & ((...expr: string[]) => this)
183
+ & ((predicate: object) => this)
184
+
185
+ groupBy: TaggedTemplateQueryPart<this>
186
+ & ((...expr: string[]) => this)
187
+
188
+ orderBy: TaggedTemplateQueryPart<this>
189
+ & ((...expr: string[]) => this)
190
+
191
+ limit: TaggedTemplateQueryPart<this>
192
+ & ((rows: number, offset?: number) => this)
193
+
194
+ forShareLock (): this
195
+
196
+ forUpdate ({ wait }?: { wait?: number }): this
197
+
198
+ alias (as: string): this
199
+ elements: EntityElements
200
+
201
+
202
+ // Not yet public
203
+ // fullJoin (other: string, as: string) : this
204
+ // leftJoin (other: string, as: string) : this
181
205
  // rightJoin (other: string, as: string) : this
182
206
  // innerJoin (other: string, as: string) : this
183
207
  // 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
- }
208
+ // on : TaggedTemplateQueryPart<this>
209
+ // & ((...expr : string[]) => this)
210
+ // & ((predicate:object) => this)
211
+
212
+ SELECT: CQN.SELECT['SELECT'] & {
213
+ forUpdate?: { wait: number },
214
+ forShareLock?: { wait: number },
215
+ search?: CQN.predicate,
216
+ count?: boolean,
217
+ }
218
+
194
219
  }
195
220
 
196
221
 
197
222
  type SELECT_one =
198
- TaggedTemplateQueryPart<Awaitable<SELECT<unknown>, InstanceType<any>>>
223
+ TaggedTemplateQueryPart<Awaitable<SELECT<unknown>, InstanceType<any>>>
199
224
  &
200
225
  // calling with class
201
- (<T extends ArrayConstructable<any>>
202
- (entityType: T, projection?: Projection<QLExtensions<SingularType<T>>>)
203
- => Awaitable<SELECT<SingularType<T>>, SingularType<T>>)
226
+ (<T extends ArrayConstructable<any>>
227
+ (entityType: T, projection?: Projection<QLExtensions<SingularType<T>>>)
228
+ => Awaitable<SELECT<SingularType<T>>, SingularType<T>>)
204
229
  &
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>)
230
+ (<T extends ArrayConstructable<any>>
231
+ (entityType: T, primaryKey: PK, projection?: Projection<QLExtensions<SingularType<T>>>)
232
+ => Awaitable<SELECT<SingularType<T>>, SingularType<T>>)
233
+
234
+ & ((entity: Definition | string, primaryKey?: PK, projection?: Projection<unknown>) => SELECT<any>)
235
+ & ((entity: LinkedEntity | string, primaryKey?: PK, projection?: Projection<unknown>) => SELECT<any>)
236
+ & (<T> (entity: T[], projection?: Projection<T>) => Awaitable<SELECT<T>, T>)
237
+ & (<T> (entity: T[], primaryKey: PK, projection?: Projection<T>) => Awaitable<SELECT<T>, T>)
238
+ & (<T> (entity: { new(): T }, projection?: Projection<T>) => Awaitable<SELECT<T>, T>)
239
+ & (<T> (entity: { new(): T }, primaryKey: PK, projection?: Projection<T>) => Awaitable<SELECT<T>, T>)
240
+ & ((subject: ref) => SELECT<any>)
216
241
 
217
242
  type SELECT_from =
218
243
  // tagged template
219
- TaggedTemplateQueryPart<Awaitable<SELECT<unknown>, InstanceType<any>>>
244
+ TaggedTemplateQueryPart<Awaitable<SELECT<unknown>, InstanceType<any>>>
220
245
  &
221
246
  // calling with class
222
- (<T extends ArrayConstructable<any>>
223
- (entityType: T, projection?: Projection<QLExtensions<SingularType<T>>>)
224
- => Awaitable<SELECT<T>, InstanceType<T>>)
247
+ (<T extends ArrayConstructable<any>>
248
+ (entityType: T, projection?: Projection<QLExtensions<SingularType<T>>>)
249
+ => Awaitable<SELECT<T>, InstanceType<T>>)
225
250
  &
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
251
+ (<T extends ArrayConstructable<any>>
252
+ (entityType: T, primaryKey: PK, projection?: Projection<SingularType<T>>)
253
+ => Awaitable<SELECT<SingularType<T>>, InstanceType<SingularType<T>>>) // when specifying a key, we expect a single element as result
229
254
  // 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>)
255
+ & ((entity: Definition | string, primaryKey?: PK, projection?: Projection<unknown>) => SELECT<any>)
256
+ & ((entity: LinkedEntity | string, primaryKey?: PK, projection?: Projection<unknown>) => SELECT<any>)
232
257
  // 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>)
258
+ & (<T> (entity: T[], projection?: Projection<T>) => SELECT<T> & Promise<T[]>)
259
+ & (<T> (entity: T[], primaryKey: PK, projection?: Projection<T>) => Awaitable<SELECT<T>, T>)
260
+ & ((subject: ref) => SELECT<any>)
236
261
 
237
262
  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"]
263
+
264
+ static into: (<T extends ArrayConstructable<any>> (entity: T, entries?: object | object[]) => INSERT<SingularType<T>>)
265
+ & (TaggedTemplateQueryPart<INSERT<unknown>>)
266
+ & ((entity: Definition | string, entries?: object | object[]) => INSERT<any>)
267
+ & ((entity: LinkedEntity | string, entries?: object | object[]) => INSERT<any>)
268
+ & (<T> (entity: Constructable<T>, entries?: object | object[]) => INSERT<T>)
269
+ & (<T> (entity: T, entries?: T | object | object[]) => INSERT<T>)
270
+
271
+ into: (<T extends ArrayConstructable> (entity: T) => this)
272
+ & TaggedTemplateQueryPart<this>
273
+ & ((entity: Definition | string) => this)
274
+
275
+ data (block: (e: T) => void): this
276
+
277
+ entries (...entries: object[]): this
278
+
279
+ columns (...col: (T extends ArrayConstructable<any> ? keyof SingularType<T> : keyof T)[]): this
280
+
281
+ columns (...col: string[]): this
282
+
283
+ values (...val: any[]): this
284
+
285
+ rows (...row: any[]): this
286
+
287
+ as (select: SELECT<T>): this
288
+ INSERT: CQN.INSERT['INSERT']
289
+
256
290
  }
257
291
 
258
292
 
259
293
  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
294
 
295
+ static into: (<T extends ArrayConstructable<any>> (entity: T, entries?: object | object[]) => UPSERT<SingularType<T>>)
296
+ & (TaggedTemplateQueryPart<UPSERT<unknown>>)
297
+ & ((entity: Definition | string, entries?: object | object[]) => UPSERT<any>)
298
+ & ((entity: LinkedEntity | string, entries?: object | object[]) => UPSERT<any>)
299
+ & (<T> (entity: Constructable<T>, entries?: object | object[]) => UPSERT<T>)
300
+ & (<T> (entity: T, entries?: T | object | object[]) => UPSERT<T>)
301
+
302
+ into: (<T extends ArrayConstructable> (entity: T) => this)
303
+ & TaggedTemplateQueryPart<this>
304
+ & ((entity: Definition | string) => this)
305
+
306
+ data (block: (e: T) => void): this
307
+
308
+ entries (...entries: object[]): this
309
+
310
+ columns (...col: (T extends ArrayConstructable<any> ? keyof SingularType<T> : keyof T)[]): this
311
+
312
+ columns (...col: string[]): this
279
313
 
314
+ values (...val: any[]): this
280
315
 
316
+ rows (...row: any[]): this
317
+ UPSERT: CQN.UPSERT['UPSERT']
318
+
319
+ }
320
+
321
+ /* eslint-disable-next-line @typescript-eslint/no-unused-vars */
281
322
  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"]
323
+
324
+ static from:
325
+ TaggedTemplateQueryPart<Awaitable<SELECT<unknown>, InstanceType<any>>>
326
+ & ((entity: Definition | string | ArrayConstructable, primaryKey?: PK) => DELETE<any>)
327
+ & ((entity: LinkedEntity | string | ArrayConstructable, primaryKey?: PK) => DELETE<any>)
328
+ & ((subject: ref) => DELETE<any>)
329
+
330
+ byKey (primaryKey?: PK): this
331
+
332
+ where (predicate: object): this
333
+
334
+ where (...expr: any[]): this
335
+
336
+ and (predicate: object): this
337
+
338
+ and (...expr: any[]): this
339
+ DELETE: CQN.DELETE['DELETE']
340
+
293
341
  }
294
342
 
343
+ /* eslint-disable-next-line @typescript-eslint/no-unused-vars */
295
344
  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"]
345
+
346
+ // cds-typer plural
347
+ static entity<T extends ArrayConstructable<any>> (entity: T, primaryKey?: PK): UPDATE<SingularType<T>>
348
+
349
+ static entity (entity: Definition | string, primaryKey?: PK): UPDATE<any>
350
+
351
+ static entity (entity: LinkedEntity | string, primaryKey?: PK): UPDATE<any>
352
+
353
+ static entity<T> (entity: Constructable<T>, primaryKey?: PK): UPDATE<T>
354
+
355
+ static entity<T> (entity: T, primaryKey?: PK): UPDATE<T>
356
+
357
+ byKey (primaryKey?: PK): this
358
+ // with (block: (e:T)=>void) : this
359
+ // set (block: (e:T)=>void) : this
360
+ set: TaggedTemplateQueryPart<this>
361
+ & ((data: object) => this);
362
+
363
+ with: TaggedTemplateQueryPart<this>
364
+ & ((data: object) => this)
365
+
366
+ where (predicate: object): this
367
+
368
+ where (...expr: any[]): this
369
+
370
+ and (predicate: object): this
371
+
372
+ and (...expr: any[]): this
373
+ UPDATE: CQN.UPDATE['UPDATE']
374
+
315
375
  }
316
376
 
377
+ /* eslint-disable-next-line @typescript-eslint/no-unused-vars */
317
378
  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"]
379
+
380
+ static entity (entity: Definition | string): CREATE<any>
381
+
382
+ static entity (entity: LinkedEntity | string): CREATE<any>
383
+ CREATE: CQN.CREATE['CREATE']
384
+
321
385
  }
322
386
 
387
+ /* eslint-disable-next-line @typescript-eslint/no-unused-vars */
323
388
  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"]
389
+
390
+ static entity (entity: Definition | string): DROP<any>
391
+
392
+ static entity (entity: LinkedEntity | string): DROP<any>
393
+ DROP: CQN.DROP['DROP']
394
+
327
395
  }