@cap-js/cds-types 0.8.0 → 0.9.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/dist/cds-types.d.ts +128 -62
- package/package.json +3 -5
package/dist/cds-types.d.ts
CHANGED
|
@@ -76,6 +76,17 @@ interface And {
|
|
|
76
76
|
& ((...expr: any[]) => this)
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
+
/**
|
|
80
|
+
* Subclass representing unauthenticated users.
|
|
81
|
+
*/
|
|
82
|
+
export class Anonymous extends User {
|
|
83
|
+
|
|
84
|
+
constructor ()
|
|
85
|
+
|
|
86
|
+
is (): boolean
|
|
87
|
+
|
|
88
|
+
}
|
|
89
|
+
|
|
79
90
|
const any: typeof any_;
|
|
80
91
|
|
|
81
92
|
interface any_ extends csn.any_ {}
|
|
@@ -239,7 +250,7 @@ namespace cds {
|
|
|
239
250
|
service,
|
|
240
251
|
cds_serve_fluent,
|
|
241
252
|
cds_connect_options,
|
|
242
|
-
|
|
253
|
+
Middlewares,
|
|
243
254
|
middlewares,
|
|
244
255
|
app,
|
|
245
256
|
env,
|
|
@@ -312,7 +323,8 @@ namespace cds {
|
|
|
312
323
|
Partial_2 as Partial,
|
|
313
324
|
OneOrMany,
|
|
314
325
|
CdsFunction,
|
|
315
|
-
|
|
326
|
+
CdsFunctions,
|
|
327
|
+
HandlerFunction,
|
|
316
328
|
CRUDEventHandler,
|
|
317
329
|
ActionEventHandler,
|
|
318
330
|
ResultsHandler,
|
|
@@ -338,6 +350,7 @@ namespace cds {
|
|
|
338
350
|
Event_2 as Event,
|
|
339
351
|
Request_2 as Request,
|
|
340
352
|
User,
|
|
353
|
+
Anonymous,
|
|
341
354
|
Privileged,
|
|
342
355
|
utils,
|
|
343
356
|
Query,
|
|
@@ -394,12 +407,20 @@ export interface cds_services {
|
|
|
394
407
|
[name: string]: Service
|
|
395
408
|
}
|
|
396
409
|
|
|
410
|
+
/**
|
|
411
|
+
* @beta helper
|
|
412
|
+
*/
|
|
397
413
|
export type CdsFunction = {
|
|
398
414
|
(...args: any[]): any,
|
|
399
415
|
__parameters: object,
|
|
400
416
|
__returns: any,
|
|
401
417
|
}
|
|
402
418
|
|
|
419
|
+
/**
|
|
420
|
+
* @beta helper
|
|
421
|
+
*/
|
|
422
|
+
export type CdsFunctions<T> = Pick<T, { [K in keyof T]: T[K] extends CdsFunction ? K : never }[keyof T]>
|
|
423
|
+
|
|
403
424
|
namespace classes {
|
|
404
425
|
export {
|
|
405
426
|
mixin,
|
|
@@ -572,24 +593,33 @@ export const connect: {
|
|
|
572
593
|
|
|
573
594
|
/**
|
|
574
595
|
* Connects to a specific datasource.
|
|
575
|
-
* @example cds.connect.to ('service')
|
|
596
|
+
* @example await cds.connect.to ('service')
|
|
576
597
|
* @see [capire](https://cap.cloud.sap/docs/node.js/cds-connect#cds-connect-to)
|
|
577
598
|
*/
|
|
578
599
|
to(datasource: string, options?: cds_connect_options): Promise<Service>,
|
|
579
600
|
|
|
580
601
|
/**
|
|
581
602
|
* Shortcut for 'db' as the primary database returning `cds.DatabaseService`
|
|
582
|
-
* @example cds.connect.to ('db')
|
|
603
|
+
* @example await cds.connect.to ('db')
|
|
583
604
|
*/
|
|
584
605
|
to(datasource: 'db', options?: cds_connect_options): Promise<cds.DatabaseService>,
|
|
585
606
|
|
|
586
607
|
/**
|
|
587
608
|
* Connects to a specific datasource via a Service subclass
|
|
588
|
-
* @example cds.connect.to (ServiceClass)
|
|
609
|
+
* @example await cds.connect.to (ServiceClass)
|
|
589
610
|
* @see [capire](https://cap.cloud.sap/docs/node.js/cds-connect#cds-connect-to)
|
|
590
611
|
*/
|
|
591
612
|
to<S extends Service>(datasource: {new(): S}, options?: cds_connect_options): Promise<S>,
|
|
592
613
|
|
|
614
|
+
/**
|
|
615
|
+
* Connects to a specific datasource via a Service class from cds-typer
|
|
616
|
+
* @example
|
|
617
|
+
* import ServiceClass from '#cds-models/SomeService'
|
|
618
|
+
* await cds.connect.to (ServiceClass)
|
|
619
|
+
* @see [capire](https://cap.cloud.sap/docs/node.js/cds-connect#cds-connect-to)
|
|
620
|
+
*/
|
|
621
|
+
to<S>(datasource: S, options?: cds_connect_options): Promise<cds.CdsFunctions<S> & Service>,
|
|
622
|
+
|
|
593
623
|
/**
|
|
594
624
|
* Connects to a specific datasource via options.
|
|
595
625
|
* @example cds.connect.to ({ kind:..., impl:... })
|
|
@@ -677,9 +707,9 @@ class CREATE_3<T> extends ConstructedQuery<T> {
|
|
|
677
707
|
}
|
|
678
708
|
|
|
679
709
|
export namespace CRUDEventHandler {
|
|
680
|
-
export type Before<P, R = P | void | Error> = (req:
|
|
681
|
-
export type On<P, R = P | void | Error> = (req:
|
|
682
|
-
export type After<P, R = P | void | Error> = (data: undefined | P, req:
|
|
710
|
+
export type Before<P, R = P | void | Error> = (req: Request_2<P>) => Promise<R> | R
|
|
711
|
+
export type On<P, R = P | void | Error> = (req: Request_2<P>, next: (...args: any[]) => Promise<R> | R) => Promise<R> | R
|
|
712
|
+
export type After<P, R = P | void | Error> = (data: undefined | P, req: Request_2<P>) => Promise<R> | R
|
|
683
713
|
}
|
|
684
714
|
|
|
685
715
|
/**
|
|
@@ -787,13 +817,6 @@ class Decimal extends Float {
|
|
|
787
817
|
scale?: number
|
|
788
818
|
}
|
|
789
819
|
|
|
790
|
-
/**
|
|
791
|
-
* Recursively excludes nullability from all properties of T.
|
|
792
|
-
*/
|
|
793
|
-
type DeepRequired<T> = {
|
|
794
|
-
[K in keyof T]: DeepRequired<T[K]>
|
|
795
|
-
} & Exclude<Required<T>, null>
|
|
796
|
-
|
|
797
820
|
export namespace default_2 {
|
|
798
821
|
export {
|
|
799
822
|
log,
|
|
@@ -831,7 +854,7 @@ export namespace default_2 {
|
|
|
831
854
|
service,
|
|
832
855
|
cds_serve_fluent,
|
|
833
856
|
cds_connect_options,
|
|
834
|
-
|
|
857
|
+
Middlewares,
|
|
835
858
|
middlewares,
|
|
836
859
|
app,
|
|
837
860
|
env,
|
|
@@ -904,7 +927,8 @@ export namespace default_2 {
|
|
|
904
927
|
Partial_2 as Partial,
|
|
905
928
|
OneOrMany,
|
|
906
929
|
CdsFunction,
|
|
907
|
-
|
|
930
|
+
CdsFunctions,
|
|
931
|
+
HandlerFunction,
|
|
908
932
|
CRUDEventHandler,
|
|
909
933
|
ActionEventHandler,
|
|
910
934
|
ResultsHandler,
|
|
@@ -930,6 +954,7 @@ export namespace default_2 {
|
|
|
930
954
|
Event_2 as Event,
|
|
931
955
|
Request_2 as Request,
|
|
932
956
|
User,
|
|
957
|
+
Anonymous,
|
|
933
958
|
Privileged,
|
|
934
959
|
utils,
|
|
935
960
|
Query,
|
|
@@ -1093,6 +1118,12 @@ export const env: {
|
|
|
1093
1118
|
[key: string]: any,
|
|
1094
1119
|
},
|
|
1095
1120
|
profiles: string[],
|
|
1121
|
+
log: {
|
|
1122
|
+
user: boolean,
|
|
1123
|
+
levels: Record<string, Lowercase<keyof typeof levels>>,
|
|
1124
|
+
als_custom_fields: Record<string, number>,
|
|
1125
|
+
cls_custom_fields: string[],
|
|
1126
|
+
},
|
|
1096
1127
|
requires: env.Requires,
|
|
1097
1128
|
folders: {
|
|
1098
1129
|
app: string,
|
|
@@ -1216,11 +1247,11 @@ export class event extends aspect<'event'> {}
|
|
|
1216
1247
|
/**
|
|
1217
1248
|
* @see [capire docs](https://cap.cloud.sap/docs/node.js/events)
|
|
1218
1249
|
*/
|
|
1219
|
-
class Event_2 extends EventContext {
|
|
1250
|
+
class Event_2<T = unknown> extends EventContext {
|
|
1220
1251
|
|
|
1221
1252
|
event: string
|
|
1222
1253
|
|
|
1223
|
-
data:
|
|
1254
|
+
data: T
|
|
1224
1255
|
|
|
1225
1256
|
headers: any
|
|
1226
1257
|
|
|
@@ -1351,6 +1382,28 @@ interface GroupBy {
|
|
|
1351
1382
|
// columns currently not being auto-completed due to complexity
|
|
1352
1383
|
}
|
|
1353
1384
|
|
|
1385
|
+
/**
|
|
1386
|
+
* Types herein can be used to type handler functions that are not declared in line:
|
|
1387
|
+
* @example
|
|
1388
|
+
* ```ts
|
|
1389
|
+
* import { myAction } from '#cds-models/myService'
|
|
1390
|
+
*
|
|
1391
|
+
* function onMyFunction (req: HandlerFunction<typeof myAction>['parameters']['req']): HandlerFunction<typeof myAction>['returns'] {
|
|
1392
|
+
* ...
|
|
1393
|
+
* }
|
|
1394
|
+
*
|
|
1395
|
+
* srv.on(myAction, onMyFunction)
|
|
1396
|
+
* ```
|
|
1397
|
+
*/
|
|
1398
|
+
export type HandlerFunction<F extends CdsFunction> = {
|
|
1399
|
+
parameters: {
|
|
1400
|
+
/** @beta helper */
|
|
1401
|
+
req: Request_2<F['__parameters']>,
|
|
1402
|
+
},
|
|
1403
|
+
/** @beta helper */
|
|
1404
|
+
returns: F['__returns'],
|
|
1405
|
+
}
|
|
1406
|
+
|
|
1354
1407
|
interface Having<T> {
|
|
1355
1408
|
having: HavingWhere<this, T>
|
|
1356
1409
|
}
|
|
@@ -1396,11 +1449,13 @@ interface INSERT_3<T> extends Columns<T>, InUpsert<T> {}
|
|
|
1396
1449
|
class INSERT_3<T> extends ConstructedQuery<T> {
|
|
1397
1450
|
private constructor();
|
|
1398
1451
|
|
|
1399
|
-
static into: (<T extends ArrayConstructable> (entity: T, entries
|
|
1452
|
+
static into: (<T extends ArrayConstructable> (entity: T, ...entries: SingularInstanceType<T>[]) => INSERT_3<SingularInstanceType<T>>)
|
|
1453
|
+
& (<T extends ArrayConstructable> (entity: T, entries?: SingularInstanceType<T>[]) => INSERT_3<SingularInstanceType<T>>)
|
|
1400
1454
|
& (TaggedTemplateQueryPart<INSERT_3<unknown>>)
|
|
1455
|
+
& ((entity: EntityDescription, ...entries: Entries[]) => INSERT_3<StaticAny>)
|
|
1401
1456
|
& ((entity: EntityDescription, entries?: Entries) => INSERT_3<StaticAny>)
|
|
1402
|
-
& (<T> (entity: Constructable<T>, entries
|
|
1403
|
-
& (<T> (entity: T
|
|
1457
|
+
& (<T> (entity: Constructable<T>, ...entries: T[]) => INSERT_3<T>)
|
|
1458
|
+
& (<T> (entity: Constructable<T>, entries?: T[]) => INSERT_3<T>)
|
|
1404
1459
|
|
|
1405
1460
|
/**
|
|
1406
1461
|
* @deprected
|
|
@@ -1426,7 +1481,8 @@ type Intersect<T extends readonly unknown[]> = T extends [infer Head, ...infer T
|
|
|
1426
1481
|
interface InUpsert<T> {
|
|
1427
1482
|
data (block: (e: T) => void): this
|
|
1428
1483
|
|
|
1429
|
-
entries (...entries:
|
|
1484
|
+
entries (...entries: T[]): this
|
|
1485
|
+
entries (entries: T[]): this
|
|
1430
1486
|
|
|
1431
1487
|
values (...val: (null | Primitive)[]): this
|
|
1432
1488
|
values (val: (null | Primitive)[]): this
|
|
@@ -1820,10 +1876,10 @@ type ManagedAssociation = Association & {
|
|
|
1820
1876
|
|
|
1821
1877
|
export class MessagingService extends Service {}
|
|
1822
1878
|
|
|
1823
|
-
export type
|
|
1879
|
+
export type Middlewares = 'context' | 'trace' | 'auth' | 'ctx_model' | string
|
|
1824
1880
|
|
|
1825
1881
|
export const middlewares: {
|
|
1826
|
-
add: (middleware: import('express').RequestHandler, pos?: XOR<XOR<{ at: number }, { after:
|
|
1882
|
+
add: (middleware: import('express').RequestHandler, pos?: XOR<XOR<{ at: number }, { after: Middlewares }>, { before: Middlewares }>) => void,
|
|
1827
1883
|
};
|
|
1828
1884
|
|
|
1829
1885
|
/**
|
|
@@ -1957,7 +2013,7 @@ export function on (event: 'loaded', listener: (model: CSN) => void): _cds
|
|
|
1957
2013
|
export function on (event: 'connect', listener: (srv: Service) => void): _cds
|
|
1958
2014
|
|
|
1959
2015
|
/**
|
|
1960
|
-
* Emitted at the very beginning of the
|
|
2016
|
+
* Emitted at the very beginning of the bootstrapping process, when the
|
|
1961
2017
|
* express application has been constructed but no middlewares or routes
|
|
1962
2018
|
* added yet.
|
|
1963
2019
|
*/
|
|
@@ -2077,6 +2133,8 @@ type Projection<T> = (e: QLExtensions<T extends ArrayConstructable ? SingularIns
|
|
|
2077
2133
|
*/
|
|
2078
2134
|
type Protocol = 'odata' | 'rest'
|
|
2079
2135
|
|
|
2136
|
+
type QbeOp = '=' | '-=' | '+=' | '*=' | '/=' | '%='
|
|
2137
|
+
|
|
2080
2138
|
class QL<T> {
|
|
2081
2139
|
|
|
2082
2140
|
SELECT: StaticSELECT<T>
|
|
@@ -2088,7 +2146,7 @@ class QL<T> {
|
|
|
2088
2146
|
& ((...entries: object[]) => UPSERT_3<T>) & ((entries: object[]) => UPSERT_3<T>)
|
|
2089
2147
|
|
|
2090
2148
|
UPDATE: typeof UPDATE_3<T>
|
|
2091
|
-
& typeof UPDATE_3.entity
|
|
2149
|
+
& typeof UPDATE_3.entity
|
|
2092
2150
|
|
|
2093
2151
|
DELETE: typeof DELETE_3<T>
|
|
2094
2152
|
& ((...entries: object[]) => DELETE_3<T>) & ((entries: object[]) => DELETE_3<T>)
|
|
@@ -2117,7 +2175,7 @@ namespace ql {
|
|
|
2117
2175
|
}
|
|
2118
2176
|
export { ql }
|
|
2119
2177
|
|
|
2120
|
-
export type QLExtensions<T> = T extends QLExtensions_<any> ? T : QLExtensions_<
|
|
2178
|
+
export type QLExtensions<T> = T extends QLExtensions_<any> ? T : QLExtensions_<Required<T>>
|
|
2121
2179
|
|
|
2122
2180
|
/**
|
|
2123
2181
|
* QLExtensions are properties that are attached to entities in CQL contexts.
|
|
@@ -2144,6 +2202,7 @@ export class QueryAPI {
|
|
|
2144
2202
|
read: {
|
|
2145
2203
|
<T extends ArrayConstructable>(entity: T, key?: Key): Awaitable<SELECT_3<T>, InstanceType<T>>,
|
|
2146
2204
|
<T>(entity: linked_2.Definition | string, key?: Key): SELECT_3<T>,
|
|
2205
|
+
(entity: ref, key?: Key): SELECT_3<unknown>,
|
|
2147
2206
|
}
|
|
2148
2207
|
|
|
2149
2208
|
/**
|
|
@@ -2256,7 +2315,7 @@ export class RemoteService extends Service {}
|
|
|
2256
2315
|
/**
|
|
2257
2316
|
* @see [capire docs](https://cap.cloud.sap/docs/node.js/events)
|
|
2258
2317
|
*/
|
|
2259
|
-
class Request_2 extends Event_2 {
|
|
2318
|
+
class Request_2<T = any> extends Event_2<T> {
|
|
2260
2319
|
|
|
2261
2320
|
params: (string | object)[]
|
|
2262
2321
|
|
|
@@ -2436,7 +2495,7 @@ TaggedTemplateQueryPart<Awaitable<SELECT_3<_TODO_2>, InstanceType<_TODO_2>>>
|
|
|
2436
2495
|
&
|
|
2437
2496
|
(<E extends ArrayConstructable>
|
|
2438
2497
|
(entityType: E, primaryKey: PK, projection?: Projection<SingularInstanceType<E>>)
|
|
2439
|
-
=> Awaitable<SELECT_3<SingularInstanceType<E>>, SingularInstanceType<E
|
|
2498
|
+
=> Awaitable<SELECT_3<SingularInstanceType<E>>, SingularInstanceType<E> | null>) // when specifying a key, we expect a single element as result
|
|
2440
2499
|
// calling with definition
|
|
2441
2500
|
& (<T>(entity: EntityDescription, primaryKey?: PK, projection?: Projection<T>) => SELECT_3<T>)
|
|
2442
2501
|
// calling with concrete list
|
|
@@ -2470,17 +2529,17 @@ TaggedTemplateQueryPart<Awaitable<SELECT_3<_TODO_2, SELECT_one>, InstanceType<_T
|
|
|
2470
2529
|
// calling with class
|
|
2471
2530
|
(<T extends ArrayConstructable>
|
|
2472
2531
|
(entityType: T, projection?: Projection<QLExtensions<SingularInstanceType<T>>>)
|
|
2473
|
-
=> Awaitable<SELECT_3<SingularInstanceType<T>, SELECT_one>, SingularInstanceType<T
|
|
2532
|
+
=> Awaitable<SELECT_3<SingularInstanceType<T>, SELECT_one>, SingularInstanceType<T> | null>)
|
|
2474
2533
|
&
|
|
2475
2534
|
(<T extends ArrayConstructable>
|
|
2476
2535
|
(entityType: T, primaryKey: PK, projection?: Projection<QLExtensions<SingularInstanceType<T>>>)
|
|
2477
|
-
=> Awaitable<SELECT_3<SingularInstanceType<T>, SELECT_one>, SingularInstanceType<T
|
|
2536
|
+
=> Awaitable<SELECT_3<SingularInstanceType<T>, SELECT_one>, SingularInstanceType<T> | null>)
|
|
2478
2537
|
|
|
2479
2538
|
& ((entity: EntityDescription, primaryKey?: PK, projection?: Projection<unknown>) => SELECT_3<_TODO_2, SELECT_one>)
|
|
2480
|
-
& (<T> (entity: T[], projection?: Projection<T>) => Awaitable<SELECT_3<T, SELECT_one>, T>)
|
|
2481
|
-
& (<T> (entity: T[], primaryKey: PK, projection?: Projection<T>) => Awaitable<SELECT_3<T, SELECT_one>, T>)
|
|
2482
|
-
& (<T> (entity: { new(): T }, projection?: Projection<T>) => Awaitable<SELECT_3<T, SELECT_one>, T>)
|
|
2483
|
-
& (<T> (entity: { new(): T }, primaryKey: PK, projection?: Projection<T>) => Awaitable<SELECT_3<T, SELECT_one>, T>)
|
|
2539
|
+
& (<T> (entity: T[], projection?: Projection<T>) => Awaitable<SELECT_3<T, SELECT_one>, T | null>)
|
|
2540
|
+
& (<T> (entity: T[], primaryKey: PK, projection?: Projection<T>) => Awaitable<SELECT_3<T, SELECT_one>, T | null>)
|
|
2541
|
+
& (<T> (entity: { new(): T }, projection?: Projection<T>) => Awaitable<SELECT_3<T, SELECT_one>, T | null>)
|
|
2542
|
+
& (<T> (entity: { new(): T }, primaryKey: PK, projection?: Projection<T>) => Awaitable<SELECT_3<T, SELECT_one>, T | null>)
|
|
2484
2543
|
& ((subject: ref) => SELECT_3<_TODO_2>)
|
|
2485
2544
|
|
|
2486
2545
|
/**
|
|
@@ -2562,7 +2621,7 @@ export class Service extends QueryAPI {
|
|
|
2562
2621
|
|
|
2563
2622
|
/**
|
|
2564
2623
|
* Constructs and emits an asynchronous event.
|
|
2565
|
-
* @see [capire docs](https://cap.cloud.sap/docs/core-services#srv-emit-event)
|
|
2624
|
+
* @see [capire docs](https://cap.cloud.sap/docs/node.js/core-services#srv-emit-event)
|
|
2566
2625
|
*/
|
|
2567
2626
|
emit: {
|
|
2568
2627
|
<T = any>(details: { event: types.event, data?: object, headers?: object }): Promise<T>,
|
|
@@ -2945,15 +3004,13 @@ export class type<K extends kinds = 'type'> extends any_<K> { }
|
|
|
2945
3004
|
interface type_2 extends any__2 {
|
|
2946
3005
|
type?: 'cds.Boolean' |
|
|
2947
3006
|
'cds.UUID' | 'cds.String' | 'cds.LargeString' | 'cds.Binary' | 'cds.LargeBinary' | 'cds.Vector' |
|
|
2948
|
-
'cds.Integer' | 'cds.UInt8' | 'cds.Int16' | 'cds.Int32' | 'cds.Int64' | 'cds.
|
|
3007
|
+
'cds.Integer' | 'cds.UInt8' | 'cds.Int16' | 'cds.Int32' | 'cds.Int64' | 'cds.Double' | 'cds.Decimal' |
|
|
2949
3008
|
'cds.Date' | 'cds.Time' | 'cds.DateTime' | 'cds.Timestamp' |
|
|
2950
3009
|
'cds.Association' | 'cds.Composition' |
|
|
2951
3010
|
FQN & Record<never,never> // allow any other CDS type as well (e.g. 'User')
|
|
2952
3011
|
items?: type_2
|
|
2953
3012
|
}
|
|
2954
3013
|
|
|
2955
|
-
export type TypedRequest<T> = Omit<Request_2, 'data'> & { data: T }
|
|
2956
|
-
|
|
2957
3014
|
export namespace types {
|
|
2958
3015
|
export type event = eventName | eventName[]
|
|
2959
3016
|
export type eventName = { name: string } | string
|
|
@@ -2994,29 +3051,30 @@ interface UPDATE_3<T> extends Where<T>, And, ByKey {}
|
|
|
2994
3051
|
class UPDATE_3<T> extends ConstructedQuery<T> {
|
|
2995
3052
|
private constructor();
|
|
2996
3053
|
|
|
2997
|
-
|
|
2998
|
-
//
|
|
2999
|
-
|
|
3000
|
-
|
|
3001
|
-
|
|
3054
|
+
static entity: (TaggedTemplateQueryPart<UPDATE_3<StaticAny>>)
|
|
3055
|
+
// UPDATE<SingularInstanceType<T>> is used here so type inference in set/with has the property keys of the singular type
|
|
3056
|
+
& (<T extends ArrayConstructable> (entity: T, primaryKey?: PK) => UPDATE_3<SingularInstanceType<T>>)
|
|
3057
|
+
& (<T extends Constructable> (entity: T, primaryKey?: PK) => UPDATE_3<InstanceType<T>>)
|
|
3058
|
+
& ((entity: EntityDescription | ref | Definition_2, primaryKey?: PK) => UPDATE_3<StaticAny>)
|
|
3059
|
+
& (<T> (entity: T, primaryKey?: PK) => UPDATE_3<T>)
|
|
3002
3060
|
|
|
3003
|
-
|
|
3004
|
-
|
|
3005
|
-
// currently no easy way to restrict T from being a primitive type
|
|
3006
|
-
static entity<T> (entity: T, primaryKey?: PK): UPDATE_3<T>
|
|
3007
|
-
|
|
3008
|
-
// with (block: (e:T)=>void) : this
|
|
3009
|
-
// set (block: (e:T)=>void) : this
|
|
3010
|
-
set: TaggedTemplateQueryPart<this>
|
|
3011
|
-
& ((data: object) => this);
|
|
3012
|
-
|
|
3013
|
-
with: TaggedTemplateQueryPart<this>
|
|
3014
|
-
& ((data: object) => this)
|
|
3061
|
+
set: UpdateSet<this, T>
|
|
3062
|
+
with: UpdateSet<this, T>
|
|
3015
3063
|
|
|
3016
3064
|
UPDATE: CQN.UPDATE['UPDATE']
|
|
3017
3065
|
|
|
3018
3066
|
}
|
|
3019
3067
|
|
|
3068
|
+
/**
|
|
3069
|
+
* Represents updatable block that can be passed to either `.set` or `.with`
|
|
3070
|
+
* of an `UPDATE` query
|
|
3071
|
+
*/
|
|
3072
|
+
type UpdateSet<This, T> = TaggedTemplateQueryPart<This>
|
|
3073
|
+
// simple value > title: 'Some Title'
|
|
3074
|
+
// qbe expression > stock: { '-=': quantity }
|
|
3075
|
+
// cqn expression > descr: {xpr: [{ref:[descr]}, '||', 'Some addition to descr.']}
|
|
3076
|
+
& ((data: {[P in keyof T]?: T[P] | {[op in QbeOp]?: T[P]} | CQN.xpr}) => This)
|
|
3077
|
+
|
|
3020
3078
|
type UPSERT_2 = { UPSERT: {
|
|
3021
3079
|
into: ref | name,
|
|
3022
3080
|
columns: string[],
|
|
@@ -3031,13 +3089,13 @@ interface UPSERT_3<T> extends Columns<T>, InUpsert<T> {}
|
|
|
3031
3089
|
class UPSERT_3<T> extends ConstructedQuery<T> {
|
|
3032
3090
|
private constructor();
|
|
3033
3091
|
|
|
3034
|
-
static into: (<T extends ArrayConstructable> (entity: T, entries
|
|
3092
|
+
static into: (<T extends ArrayConstructable> (entity: T, ...entries: SingularInstanceType<T>[]) => UPSERT_3<SingularInstanceType<T>>)
|
|
3093
|
+
& (<T extends ArrayConstructable> (entity: T, entries?: SingularInstanceType<T>[]) => UPSERT_3<SingularInstanceType<T>>)
|
|
3035
3094
|
& (TaggedTemplateQueryPart<UPSERT_3<StaticAny>>)
|
|
3095
|
+
& ((entity: EntityDescription, ...entries: Entries[]) => UPSERT_3<StaticAny>)
|
|
3036
3096
|
& ((entity: EntityDescription, entries?: Entries) => UPSERT_3<StaticAny>)
|
|
3037
|
-
& (<T> (entity: Constructable<T>, entries
|
|
3038
|
-
|
|
3039
|
-
& (<T> (entity: T, entries?: T | Entries) => UPSERT_3<T>)
|
|
3040
|
-
|
|
3097
|
+
& (<T> (entity: Constructable<T>, ...entries: T[]) => UPSERT_3<T>)
|
|
3098
|
+
& (<T> (entity: Constructable<T>, entries?: T[]) => UPSERT_3<T>)
|
|
3041
3099
|
|
|
3042
3100
|
UPSERT: CQN.UPSERT['UPSERT']
|
|
3043
3101
|
|
|
@@ -3066,8 +3124,16 @@ export class User {
|
|
|
3066
3124
|
|
|
3067
3125
|
roles: Array<string> | Record<string, string>
|
|
3068
3126
|
|
|
3127
|
+
static Anonymous: typeof Anonymous
|
|
3128
|
+
|
|
3129
|
+
static anonymous: Anonymous
|
|
3130
|
+
|
|
3069
3131
|
static Privileged: typeof Privileged
|
|
3070
3132
|
|
|
3133
|
+
static privileged: Privileged
|
|
3134
|
+
|
|
3135
|
+
static default: User
|
|
3136
|
+
|
|
3071
3137
|
is (role: string): boolean
|
|
3072
3138
|
|
|
3073
3139
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cap-js/cds-types",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
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/",
|
|
@@ -33,10 +33,8 @@
|
|
|
33
33
|
"dependencies": "node ./scripts/postinstall.js"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
|
-
"@sap/cds": "^8.0.0"
|
|
37
|
-
|
|
38
|
-
"dependencies": {
|
|
39
|
-
"@types/express": "^4.17.21"
|
|
36
|
+
"@sap/cds": "^8.0.0",
|
|
37
|
+
"@types/express": ">=4"
|
|
40
38
|
},
|
|
41
39
|
"devDependencies": {
|
|
42
40
|
"@eslint/js": "^9.2.0",
|