@cap-js/cds-types 0.8.0 → 0.10.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 +209 -67
- package/package.json +19 -26
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,
|
|
@@ -365,7 +378,13 @@ namespace cds {
|
|
|
365
378
|
operator,
|
|
366
379
|
function_call,
|
|
367
380
|
enum_literal,
|
|
368
|
-
expr_literal
|
|
381
|
+
expr_literal,
|
|
382
|
+
Texts,
|
|
383
|
+
I18nBundle,
|
|
384
|
+
I18nFacade,
|
|
385
|
+
I18nFilesOptions,
|
|
386
|
+
I18nFiles,
|
|
387
|
+
i18n
|
|
369
388
|
}
|
|
370
389
|
}
|
|
371
390
|
|
|
@@ -394,12 +413,20 @@ export interface cds_services {
|
|
|
394
413
|
[name: string]: Service
|
|
395
414
|
}
|
|
396
415
|
|
|
416
|
+
/**
|
|
417
|
+
* @beta helper
|
|
418
|
+
*/
|
|
397
419
|
export type CdsFunction = {
|
|
398
420
|
(...args: any[]): any,
|
|
399
421
|
__parameters: object,
|
|
400
422
|
__returns: any,
|
|
401
423
|
}
|
|
402
424
|
|
|
425
|
+
/**
|
|
426
|
+
* @beta helper
|
|
427
|
+
*/
|
|
428
|
+
export type CdsFunctions<T> = Pick<T, { [K in keyof T]: T[K] extends CdsFunction ? K : never }[keyof T]>
|
|
429
|
+
|
|
403
430
|
namespace classes {
|
|
404
431
|
export {
|
|
405
432
|
mixin,
|
|
@@ -437,6 +464,7 @@ namespace classes {
|
|
|
437
464
|
TimeStamp,
|
|
438
465
|
array,
|
|
439
466
|
struct,
|
|
467
|
+
Map_3 as Map,
|
|
440
468
|
context_,
|
|
441
469
|
service_,
|
|
442
470
|
action,
|
|
@@ -572,24 +600,33 @@ export const connect: {
|
|
|
572
600
|
|
|
573
601
|
/**
|
|
574
602
|
* Connects to a specific datasource.
|
|
575
|
-
* @example cds.connect.to ('service')
|
|
603
|
+
* @example await cds.connect.to ('service')
|
|
576
604
|
* @see [capire](https://cap.cloud.sap/docs/node.js/cds-connect#cds-connect-to)
|
|
577
605
|
*/
|
|
578
606
|
to(datasource: string, options?: cds_connect_options): Promise<Service>,
|
|
579
607
|
|
|
580
608
|
/**
|
|
581
609
|
* Shortcut for 'db' as the primary database returning `cds.DatabaseService`
|
|
582
|
-
* @example cds.connect.to ('db')
|
|
610
|
+
* @example await cds.connect.to ('db')
|
|
583
611
|
*/
|
|
584
612
|
to(datasource: 'db', options?: cds_connect_options): Promise<cds.DatabaseService>,
|
|
585
613
|
|
|
586
614
|
/**
|
|
587
615
|
* Connects to a specific datasource via a Service subclass
|
|
588
|
-
* @example cds.connect.to (ServiceClass)
|
|
616
|
+
* @example await cds.connect.to (ServiceClass)
|
|
589
617
|
* @see [capire](https://cap.cloud.sap/docs/node.js/cds-connect#cds-connect-to)
|
|
590
618
|
*/
|
|
591
619
|
to<S extends Service>(datasource: {new(): S}, options?: cds_connect_options): Promise<S>,
|
|
592
620
|
|
|
621
|
+
/**
|
|
622
|
+
* Connects to a specific datasource via a Service class from cds-typer
|
|
623
|
+
* @example
|
|
624
|
+
* import ServiceClass from '#cds-models/SomeService'
|
|
625
|
+
* await cds.connect.to (ServiceClass)
|
|
626
|
+
* @see [capire](https://cap.cloud.sap/docs/node.js/cds-connect#cds-connect-to)
|
|
627
|
+
*/
|
|
628
|
+
to<S>(datasource: S, options?: cds_connect_options): Promise<cds.CdsFunctions<S> & Service>,
|
|
629
|
+
|
|
593
630
|
/**
|
|
594
631
|
* Connects to a specific datasource via options.
|
|
595
632
|
* @example cds.connect.to ({ kind:..., impl:... })
|
|
@@ -614,7 +651,7 @@ class ConstructedQuery<T> {
|
|
|
614
651
|
// that don't make explicit use of the generic. So `UPDATE<Books> !<: UPDATE<number>`
|
|
615
652
|
private _: T
|
|
616
653
|
then (_resolved: (x: any) => any, _rejected: (e: Error) => any): any
|
|
617
|
-
|
|
654
|
+
bind (service: Service): this
|
|
618
655
|
}
|
|
619
656
|
|
|
620
657
|
/**
|
|
@@ -677,9 +714,9 @@ class CREATE_3<T> extends ConstructedQuery<T> {
|
|
|
677
714
|
}
|
|
678
715
|
|
|
679
716
|
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:
|
|
717
|
+
export type Before<P, R = P | void | Error> = (req: Request_2<P>) => Promise<R> | R
|
|
718
|
+
export type On<P, R = P | void | Error> = (req: Request_2<P>, next: (...args: any[]) => Promise<R> | R) => Promise<R> | R
|
|
719
|
+
export type After<P, R = P | void | Error> = (data: undefined | P, req: Request_2<P>) => Promise<R> | R
|
|
683
720
|
}
|
|
684
721
|
|
|
685
722
|
/**
|
|
@@ -730,6 +767,7 @@ namespace csn {
|
|
|
730
767
|
service_2 as service,
|
|
731
768
|
type_2 as type,
|
|
732
769
|
struct_2 as struct,
|
|
770
|
+
Map_2 as Map,
|
|
733
771
|
entity_2 as entity,
|
|
734
772
|
EntityElements,
|
|
735
773
|
Association_2 as Association
|
|
@@ -787,13 +825,6 @@ class Decimal extends Float {
|
|
|
787
825
|
scale?: number
|
|
788
826
|
}
|
|
789
827
|
|
|
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
828
|
export namespace default_2 {
|
|
798
829
|
export {
|
|
799
830
|
log,
|
|
@@ -831,7 +862,7 @@ export namespace default_2 {
|
|
|
831
862
|
service,
|
|
832
863
|
cds_serve_fluent,
|
|
833
864
|
cds_connect_options,
|
|
834
|
-
|
|
865
|
+
Middlewares,
|
|
835
866
|
middlewares,
|
|
836
867
|
app,
|
|
837
868
|
env,
|
|
@@ -904,7 +935,8 @@ export namespace default_2 {
|
|
|
904
935
|
Partial_2 as Partial,
|
|
905
936
|
OneOrMany,
|
|
906
937
|
CdsFunction,
|
|
907
|
-
|
|
938
|
+
CdsFunctions,
|
|
939
|
+
HandlerFunction,
|
|
908
940
|
CRUDEventHandler,
|
|
909
941
|
ActionEventHandler,
|
|
910
942
|
ResultsHandler,
|
|
@@ -930,6 +962,7 @@ export namespace default_2 {
|
|
|
930
962
|
Event_2 as Event,
|
|
931
963
|
Request_2 as Request,
|
|
932
964
|
User,
|
|
965
|
+
Anonymous,
|
|
933
966
|
Privileged,
|
|
934
967
|
utils,
|
|
935
968
|
Query,
|
|
@@ -957,7 +990,13 @@ export namespace default_2 {
|
|
|
957
990
|
operator,
|
|
958
991
|
function_call,
|
|
959
992
|
enum_literal,
|
|
960
|
-
expr_literal
|
|
993
|
+
expr_literal,
|
|
994
|
+
Texts,
|
|
995
|
+
I18nBundle,
|
|
996
|
+
I18nFacade,
|
|
997
|
+
I18nFilesOptions,
|
|
998
|
+
I18nFiles,
|
|
999
|
+
i18n
|
|
961
1000
|
}
|
|
962
1001
|
}
|
|
963
1002
|
|
|
@@ -1093,6 +1132,12 @@ export const env: {
|
|
|
1093
1132
|
[key: string]: any,
|
|
1094
1133
|
},
|
|
1095
1134
|
profiles: string[],
|
|
1135
|
+
log: {
|
|
1136
|
+
user: boolean,
|
|
1137
|
+
levels: Record<string, Lowercase<keyof typeof levels>>,
|
|
1138
|
+
als_custom_fields: Record<string, number>,
|
|
1139
|
+
cls_custom_fields: string[],
|
|
1140
|
+
},
|
|
1096
1141
|
requires: env.Requires,
|
|
1097
1142
|
folders: {
|
|
1098
1143
|
app: string,
|
|
@@ -1216,11 +1261,11 @@ export class event extends aspect<'event'> {}
|
|
|
1216
1261
|
/**
|
|
1217
1262
|
* @see [capire docs](https://cap.cloud.sap/docs/node.js/events)
|
|
1218
1263
|
*/
|
|
1219
|
-
class Event_2 extends EventContext {
|
|
1264
|
+
class Event_2<T = unknown> extends EventContext {
|
|
1220
1265
|
|
|
1221
1266
|
event: string
|
|
1222
1267
|
|
|
1223
|
-
data:
|
|
1268
|
+
data: T
|
|
1224
1269
|
|
|
1225
1270
|
headers: any
|
|
1226
1271
|
|
|
@@ -1351,6 +1396,28 @@ interface GroupBy {
|
|
|
1351
1396
|
// columns currently not being auto-completed due to complexity
|
|
1352
1397
|
}
|
|
1353
1398
|
|
|
1399
|
+
/**
|
|
1400
|
+
* Types herein can be used to type handler functions that are not declared in line:
|
|
1401
|
+
* @example
|
|
1402
|
+
* ```ts
|
|
1403
|
+
* import { myAction } from '#cds-models/myService'
|
|
1404
|
+
*
|
|
1405
|
+
* function onMyFunction (req: HandlerFunction<typeof myAction>['parameters']['req']): HandlerFunction<typeof myAction>['returns'] {
|
|
1406
|
+
* ...
|
|
1407
|
+
* }
|
|
1408
|
+
*
|
|
1409
|
+
* srv.on(myAction, onMyFunction)
|
|
1410
|
+
* ```
|
|
1411
|
+
*/
|
|
1412
|
+
export type HandlerFunction<F extends CdsFunction> = {
|
|
1413
|
+
parameters: {
|
|
1414
|
+
/** @beta helper */
|
|
1415
|
+
req: Request_2<F['__parameters']>,
|
|
1416
|
+
},
|
|
1417
|
+
/** @beta helper */
|
|
1418
|
+
returns: F['__returns'],
|
|
1419
|
+
}
|
|
1420
|
+
|
|
1354
1421
|
interface Having<T> {
|
|
1355
1422
|
having: HavingWhere<this, T>
|
|
1356
1423
|
}
|
|
@@ -1377,8 +1444,57 @@ type HavingWhere<This, E> =
|
|
|
1377
1444
|
& ((...expr: string[]) => This)
|
|
1378
1445
|
& TaggedTemplateQueryPart<This>
|
|
1379
1446
|
|
|
1447
|
+
interface Hints {
|
|
1448
|
+
hints: ((...hints: string[]) => this)
|
|
1449
|
+
& ((hints: string[]) => this)
|
|
1450
|
+
}
|
|
1451
|
+
|
|
1380
1452
|
export const home: string;
|
|
1381
1453
|
|
|
1454
|
+
export const i18n: I18nFacade;
|
|
1455
|
+
|
|
1456
|
+
export class I18nBundle {
|
|
1457
|
+
constructor(options: I18nFilesOptions)
|
|
1458
|
+
for(key: number | string | object, locale?: string | object, args?: object): string | undefined
|
|
1459
|
+
at(key: number | string | object, locale?: string | object, args?: object): string | undefined
|
|
1460
|
+
files: I18nFiles
|
|
1461
|
+
get defaults(): Record<string, string>
|
|
1462
|
+
get fallback(): Record<string, string>
|
|
1463
|
+
key4(definition: entity): string
|
|
1464
|
+
texts4 (locale: string): Texts
|
|
1465
|
+
translations4 (...locales : string[]) : { [locale: string]: Texts }
|
|
1466
|
+
translations4 (locale : 'all' ) : { [locale: string]: Texts }
|
|
1467
|
+
all () : Record<string, Texts>
|
|
1468
|
+
}
|
|
1469
|
+
|
|
1470
|
+
export interface I18nFacade {
|
|
1471
|
+
Bundle: typeof I18nBundle
|
|
1472
|
+
Facade: I18nFacade
|
|
1473
|
+
Files: typeof I18nFiles
|
|
1474
|
+
get file(): string
|
|
1475
|
+
get folders(): string[]
|
|
1476
|
+
get labels(): I18nBundle
|
|
1477
|
+
get messages(): I18nBundle
|
|
1478
|
+
|
|
1479
|
+
bundle4 (file: string, options?: I18nFilesOptions): I18nBundle
|
|
1480
|
+
bundle4 (model: csn.CSN): I18nBundle
|
|
1481
|
+
}
|
|
1482
|
+
|
|
1483
|
+
export class I18nFiles {
|
|
1484
|
+
constructor (options: I18nFilesOptions)
|
|
1485
|
+
get options(): I18nFilesOptions
|
|
1486
|
+
get basename(): string
|
|
1487
|
+
content4(locale: string, suffix: string): Array<object>
|
|
1488
|
+
}
|
|
1489
|
+
|
|
1490
|
+
export interface I18nFilesOptions {
|
|
1491
|
+
file? : string
|
|
1492
|
+
model? : csn.CSN
|
|
1493
|
+
roots? : string[]
|
|
1494
|
+
leafs? : string[]
|
|
1495
|
+
folders? : string[]
|
|
1496
|
+
}
|
|
1497
|
+
|
|
1382
1498
|
export const insert: Service['insert'];
|
|
1383
1499
|
|
|
1384
1500
|
type INSERT_2 = { INSERT: {
|
|
@@ -1396,11 +1512,13 @@ interface INSERT_3<T> extends Columns<T>, InUpsert<T> {}
|
|
|
1396
1512
|
class INSERT_3<T> extends ConstructedQuery<T> {
|
|
1397
1513
|
private constructor();
|
|
1398
1514
|
|
|
1399
|
-
static into: (<T extends ArrayConstructable> (entity: T, entries
|
|
1515
|
+
static into: (<T extends ArrayConstructable> (entity: T, ...entries: SingularInstanceType<T>[]) => INSERT_3<SingularInstanceType<T>>)
|
|
1516
|
+
& (<T extends ArrayConstructable> (entity: T, entries?: SingularInstanceType<T>[]) => INSERT_3<SingularInstanceType<T>>)
|
|
1400
1517
|
& (TaggedTemplateQueryPart<INSERT_3<unknown>>)
|
|
1518
|
+
& ((entity: EntityDescription, ...entries: Entries[]) => INSERT_3<StaticAny>)
|
|
1401
1519
|
& ((entity: EntityDescription, entries?: Entries) => INSERT_3<StaticAny>)
|
|
1402
|
-
& (<T> (entity: Constructable<T>, entries
|
|
1403
|
-
& (<T> (entity: T
|
|
1520
|
+
& (<T> (entity: Constructable<T>, ...entries: T[]) => INSERT_3<T>)
|
|
1521
|
+
& (<T> (entity: Constructable<T>, entries?: T[]) => INSERT_3<T>)
|
|
1404
1522
|
|
|
1405
1523
|
/**
|
|
1406
1524
|
* @deprected
|
|
@@ -1426,7 +1544,8 @@ type Intersect<T extends readonly unknown[]> = T extends [infer Head, ...infer T
|
|
|
1426
1544
|
interface InUpsert<T> {
|
|
1427
1545
|
data (block: (e: T) => void): this
|
|
1428
1546
|
|
|
1429
|
-
entries (...entries:
|
|
1547
|
+
entries (...entries: T[]): this
|
|
1548
|
+
entries (entries: T[]): this
|
|
1430
1549
|
|
|
1431
1550
|
values (...val: (null | Primitive)[]): this
|
|
1432
1551
|
values (val: (null | Primitive)[]): this
|
|
@@ -1818,12 +1937,23 @@ type ManagedAssociation = Association & {
|
|
|
1818
1937
|
keys: Column[],
|
|
1819
1938
|
}
|
|
1820
1939
|
|
|
1940
|
+
interface Map_2 extends Omit<struct_2, 'includes' | 'items'> {
|
|
1941
|
+
elements: Record<string,never>
|
|
1942
|
+
}
|
|
1943
|
+
|
|
1944
|
+
/**
|
|
1945
|
+
* @since 8.6.0
|
|
1946
|
+
*/
|
|
1947
|
+
interface Map_3 extends csn.Map {}
|
|
1948
|
+
|
|
1949
|
+
class Map_3 {}
|
|
1950
|
+
|
|
1821
1951
|
export class MessagingService extends Service {}
|
|
1822
1952
|
|
|
1823
|
-
export type
|
|
1953
|
+
export type Middlewares = 'context' | 'trace' | 'auth' | 'ctx_model' | string
|
|
1824
1954
|
|
|
1825
1955
|
export const middlewares: {
|
|
1826
|
-
add: (middleware: import('express').RequestHandler, pos?: XOR<XOR<{ at: number }, { after:
|
|
1956
|
+
add: (middleware: import('express').RequestHandler, pos?: XOR<XOR<{ at: number }, { after: Middlewares }>, { before: Middlewares }>) => void,
|
|
1827
1957
|
};
|
|
1828
1958
|
|
|
1829
1959
|
/**
|
|
@@ -1957,7 +2087,7 @@ export function on (event: 'loaded', listener: (model: CSN) => void): _cds
|
|
|
1957
2087
|
export function on (event: 'connect', listener: (srv: Service) => void): _cds
|
|
1958
2088
|
|
|
1959
2089
|
/**
|
|
1960
|
-
* Emitted at the very beginning of the
|
|
2090
|
+
* Emitted at the very beginning of the bootstrapping process, when the
|
|
1961
2091
|
* express application has been constructed but no middlewares or routes
|
|
1962
2092
|
* added yet.
|
|
1963
2093
|
*/
|
|
@@ -2077,6 +2207,8 @@ type Projection<T> = (e: QLExtensions<T extends ArrayConstructable ? SingularIns
|
|
|
2077
2207
|
*/
|
|
2078
2208
|
type Protocol = 'odata' | 'rest'
|
|
2079
2209
|
|
|
2210
|
+
type QbeOp = '=' | '-=' | '+=' | '*=' | '/=' | '%='
|
|
2211
|
+
|
|
2080
2212
|
class QL<T> {
|
|
2081
2213
|
|
|
2082
2214
|
SELECT: StaticSELECT<T>
|
|
@@ -2088,7 +2220,7 @@ class QL<T> {
|
|
|
2088
2220
|
& ((...entries: object[]) => UPSERT_3<T>) & ((entries: object[]) => UPSERT_3<T>)
|
|
2089
2221
|
|
|
2090
2222
|
UPDATE: typeof UPDATE_3<T>
|
|
2091
|
-
& typeof UPDATE_3.entity
|
|
2223
|
+
& typeof UPDATE_3.entity
|
|
2092
2224
|
|
|
2093
2225
|
DELETE: typeof DELETE_3<T>
|
|
2094
2226
|
& ((...entries: object[]) => DELETE_3<T>) & ((entries: object[]) => DELETE_3<T>)
|
|
@@ -2117,7 +2249,7 @@ namespace ql {
|
|
|
2117
2249
|
}
|
|
2118
2250
|
export { ql }
|
|
2119
2251
|
|
|
2120
|
-
export type QLExtensions<T> = T extends QLExtensions_<any> ? T : QLExtensions_<
|
|
2252
|
+
export type QLExtensions<T> = T extends QLExtensions_<any> ? T : QLExtensions_<Required<T>>
|
|
2121
2253
|
|
|
2122
2254
|
/**
|
|
2123
2255
|
* QLExtensions are properties that are attached to entities in CQL contexts.
|
|
@@ -2144,6 +2276,7 @@ export class QueryAPI {
|
|
|
2144
2276
|
read: {
|
|
2145
2277
|
<T extends ArrayConstructable>(entity: T, key?: Key): Awaitable<SELECT_3<T>, InstanceType<T>>,
|
|
2146
2278
|
<T>(entity: linked_2.Definition | string, key?: Key): SELECT_3<T>,
|
|
2279
|
+
(entity: ref, key?: Key): SELECT_3<unknown>,
|
|
2147
2280
|
}
|
|
2148
2281
|
|
|
2149
2282
|
/**
|
|
@@ -2256,7 +2389,7 @@ export class RemoteService extends Service {}
|
|
|
2256
2389
|
/**
|
|
2257
2390
|
* @see [capire docs](https://cap.cloud.sap/docs/node.js/events)
|
|
2258
2391
|
*/
|
|
2259
|
-
class Request_2 extends Event_2 {
|
|
2392
|
+
class Request_2<T = any> extends Event_2<T> {
|
|
2260
2393
|
|
|
2261
2394
|
params: (string | object)[]
|
|
2262
2395
|
|
|
@@ -2378,7 +2511,7 @@ type SELECT_2 = { SELECT: {
|
|
|
2378
2511
|
}, }
|
|
2379
2512
|
export { SELECT_2 as SELECT }
|
|
2380
2513
|
|
|
2381
|
-
interface SELECT_3<T> extends Where<T>, And, Having<T>, GroupBy, OrderBy<T>, Limit {
|
|
2514
|
+
interface SELECT_3<T> extends Where<T>, And, Having<T>, GroupBy, OrderBy<T>, Limit, Hints {
|
|
2382
2515
|
// overload specific to SELECT
|
|
2383
2516
|
columns: Columns<T, this>['columns'] & ((projection: Projection<T>) => this)
|
|
2384
2517
|
}
|
|
@@ -2436,7 +2569,7 @@ TaggedTemplateQueryPart<Awaitable<SELECT_3<_TODO_2>, InstanceType<_TODO_2>>>
|
|
|
2436
2569
|
&
|
|
2437
2570
|
(<E extends ArrayConstructable>
|
|
2438
2571
|
(entityType: E, primaryKey: PK, projection?: Projection<SingularInstanceType<E>>)
|
|
2439
|
-
=> Awaitable<SELECT_3<SingularInstanceType<E>>, SingularInstanceType<E
|
|
2572
|
+
=> Awaitable<SELECT_3<SingularInstanceType<E>>, SingularInstanceType<E> | null>) // when specifying a key, we expect a single element as result
|
|
2440
2573
|
// calling with definition
|
|
2441
2574
|
& (<T>(entity: EntityDescription, primaryKey?: PK, projection?: Projection<T>) => SELECT_3<T>)
|
|
2442
2575
|
// calling with concrete list
|
|
@@ -2470,17 +2603,17 @@ TaggedTemplateQueryPart<Awaitable<SELECT_3<_TODO_2, SELECT_one>, InstanceType<_T
|
|
|
2470
2603
|
// calling with class
|
|
2471
2604
|
(<T extends ArrayConstructable>
|
|
2472
2605
|
(entityType: T, projection?: Projection<QLExtensions<SingularInstanceType<T>>>)
|
|
2473
|
-
=> Awaitable<SELECT_3<SingularInstanceType<T>, SELECT_one>, SingularInstanceType<T
|
|
2606
|
+
=> Awaitable<SELECT_3<SingularInstanceType<T>, SELECT_one>, SingularInstanceType<T> | null>)
|
|
2474
2607
|
&
|
|
2475
2608
|
(<T extends ArrayConstructable>
|
|
2476
2609
|
(entityType: T, primaryKey: PK, projection?: Projection<QLExtensions<SingularInstanceType<T>>>)
|
|
2477
|
-
=> Awaitable<SELECT_3<SingularInstanceType<T>, SELECT_one>, SingularInstanceType<T
|
|
2610
|
+
=> Awaitable<SELECT_3<SingularInstanceType<T>, SELECT_one>, SingularInstanceType<T> | null>)
|
|
2478
2611
|
|
|
2479
2612
|
& ((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>)
|
|
2613
|
+
& (<T> (entity: T[], projection?: Projection<T>) => Awaitable<SELECT_3<T, SELECT_one>, T | null>)
|
|
2614
|
+
& (<T> (entity: T[], primaryKey: PK, projection?: Projection<T>) => Awaitable<SELECT_3<T, SELECT_one>, T | null>)
|
|
2615
|
+
& (<T> (entity: { new(): T }, projection?: Projection<T>) => Awaitable<SELECT_3<T, SELECT_one>, T | null>)
|
|
2616
|
+
& (<T> (entity: { new(): T }, primaryKey: PK, projection?: Projection<T>) => Awaitable<SELECT_3<T, SELECT_one>, T | null>)
|
|
2484
2617
|
& ((subject: ref) => SELECT_3<_TODO_2>)
|
|
2485
2618
|
|
|
2486
2619
|
/**
|
|
@@ -2562,7 +2695,7 @@ export class Service extends QueryAPI {
|
|
|
2562
2695
|
|
|
2563
2696
|
/**
|
|
2564
2697
|
* Constructs and emits an asynchronous event.
|
|
2565
|
-
* @see [capire docs](https://cap.cloud.sap/docs/core-services#srv-emit-event)
|
|
2698
|
+
* @see [capire docs](https://cap.cloud.sap/docs/node.js/core-services#srv-emit-event)
|
|
2566
2699
|
*/
|
|
2567
2700
|
emit: {
|
|
2568
2701
|
<T = any>(details: { event: types.event, data?: object, headers?: object }): Promise<T>,
|
|
@@ -2903,6 +3036,8 @@ export const test: {
|
|
|
2903
3036
|
log: Test['log'],
|
|
2904
3037
|
};
|
|
2905
3038
|
|
|
3039
|
+
export type Texts = Record<string, string>
|
|
3040
|
+
|
|
2906
3041
|
class Time extends date { }
|
|
2907
3042
|
|
|
2908
3043
|
class TimeStamp extends DateTime { }
|
|
@@ -2945,15 +3080,13 @@ export class type<K extends kinds = 'type'> extends any_<K> { }
|
|
|
2945
3080
|
interface type_2 extends any__2 {
|
|
2946
3081
|
type?: 'cds.Boolean' |
|
|
2947
3082
|
'cds.UUID' | 'cds.String' | 'cds.LargeString' | 'cds.Binary' | 'cds.LargeBinary' | 'cds.Vector' |
|
|
2948
|
-
'cds.Integer' | 'cds.UInt8' | 'cds.Int16' | 'cds.Int32' | 'cds.Int64' | 'cds.
|
|
3083
|
+
'cds.Integer' | 'cds.UInt8' | 'cds.Int16' | 'cds.Int32' | 'cds.Int64' | 'cds.Double' | 'cds.Decimal' |
|
|
2949
3084
|
'cds.Date' | 'cds.Time' | 'cds.DateTime' | 'cds.Timestamp' |
|
|
2950
|
-
'cds.Association' | 'cds.Composition' |
|
|
3085
|
+
'cds.Association' | 'cds.Composition' | 'cds.Map' |
|
|
2951
3086
|
FQN & Record<never,never> // allow any other CDS type as well (e.g. 'User')
|
|
2952
3087
|
items?: type_2
|
|
2953
3088
|
}
|
|
2954
3089
|
|
|
2955
|
-
export type TypedRequest<T> = Omit<Request_2, 'data'> & { data: T }
|
|
2956
|
-
|
|
2957
3090
|
export namespace types {
|
|
2958
3091
|
export type event = eventName | eventName[]
|
|
2959
3092
|
export type eventName = { name: string } | string
|
|
@@ -2994,29 +3127,30 @@ interface UPDATE_3<T> extends Where<T>, And, ByKey {}
|
|
|
2994
3127
|
class UPDATE_3<T> extends ConstructedQuery<T> {
|
|
2995
3128
|
private constructor();
|
|
2996
3129
|
|
|
2997
|
-
|
|
2998
|
-
//
|
|
2999
|
-
|
|
3000
|
-
|
|
3001
|
-
|
|
3002
|
-
|
|
3003
|
-
static entity<T extends Constructable> (entity: T, primaryKey?: PK): UPDATE_3<T>
|
|
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);
|
|
3130
|
+
static entity: (TaggedTemplateQueryPart<UPDATE_3<StaticAny>>)
|
|
3131
|
+
// UPDATE<SingularInstanceType<T>> is used here so type inference in set/with has the property keys of the singular type
|
|
3132
|
+
& (<T extends ArrayConstructable> (entity: T, primaryKey?: PK) => UPDATE_3<SingularInstanceType<T>>)
|
|
3133
|
+
& (<T extends Constructable> (entity: T, primaryKey?: PK) => UPDATE_3<InstanceType<T>>)
|
|
3134
|
+
& ((entity: EntityDescription | ref | Definition_2, primaryKey?: PK) => UPDATE_3<StaticAny>)
|
|
3135
|
+
& (<T> (entity: T, primaryKey?: PK) => UPDATE_3<T>)
|
|
3012
3136
|
|
|
3013
|
-
|
|
3014
|
-
|
|
3137
|
+
set: UpdateSet<this, T>
|
|
3138
|
+
with: UpdateSet<this, T>
|
|
3015
3139
|
|
|
3016
3140
|
UPDATE: CQN.UPDATE['UPDATE']
|
|
3017
3141
|
|
|
3018
3142
|
}
|
|
3019
3143
|
|
|
3144
|
+
/**
|
|
3145
|
+
* Represents updatable block that can be passed to either `.set` or `.with`
|
|
3146
|
+
* of an `UPDATE` query
|
|
3147
|
+
*/
|
|
3148
|
+
type UpdateSet<This, T> = TaggedTemplateQueryPart<This>
|
|
3149
|
+
// simple value > title: 'Some Title'
|
|
3150
|
+
// qbe expression > stock: { '-=': quantity }
|
|
3151
|
+
// cqn expression > descr: {xpr: [{ref:[descr]}, '||', 'Some addition to descr.']}
|
|
3152
|
+
& ((data: {[P in keyof T]?: T[P] | {[op in QbeOp]?: T[P]} | CQN.xpr}) => This)
|
|
3153
|
+
|
|
3020
3154
|
type UPSERT_2 = { UPSERT: {
|
|
3021
3155
|
into: ref | name,
|
|
3022
3156
|
columns: string[],
|
|
@@ -3031,13 +3165,13 @@ interface UPSERT_3<T> extends Columns<T>, InUpsert<T> {}
|
|
|
3031
3165
|
class UPSERT_3<T> extends ConstructedQuery<T> {
|
|
3032
3166
|
private constructor();
|
|
3033
3167
|
|
|
3034
|
-
static into: (<T extends ArrayConstructable> (entity: T, entries
|
|
3168
|
+
static into: (<T extends ArrayConstructable> (entity: T, ...entries: SingularInstanceType<T>[]) => UPSERT_3<SingularInstanceType<T>>)
|
|
3169
|
+
& (<T extends ArrayConstructable> (entity: T, entries?: SingularInstanceType<T>[]) => UPSERT_3<SingularInstanceType<T>>)
|
|
3035
3170
|
& (TaggedTemplateQueryPart<UPSERT_3<StaticAny>>)
|
|
3171
|
+
& ((entity: EntityDescription, ...entries: Entries[]) => UPSERT_3<StaticAny>)
|
|
3036
3172
|
& ((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
|
-
|
|
3173
|
+
& (<T> (entity: Constructable<T>, ...entries: T[]) => UPSERT_3<T>)
|
|
3174
|
+
& (<T> (entity: Constructable<T>, entries?: T[]) => UPSERT_3<T>)
|
|
3041
3175
|
|
|
3042
3176
|
UPSERT: CQN.UPSERT['UPSERT']
|
|
3043
3177
|
|
|
@@ -3066,8 +3200,16 @@ export class User {
|
|
|
3066
3200
|
|
|
3067
3201
|
roles: Array<string> | Record<string, string>
|
|
3068
3202
|
|
|
3203
|
+
static Anonymous: typeof Anonymous
|
|
3204
|
+
|
|
3205
|
+
static anonymous: Anonymous
|
|
3206
|
+
|
|
3069
3207
|
static Privileged: typeof Privileged
|
|
3070
3208
|
|
|
3209
|
+
static privileged: Privileged
|
|
3210
|
+
|
|
3211
|
+
static default: User
|
|
3212
|
+
|
|
3071
3213
|
is (role: string): boolean
|
|
3072
3214
|
|
|
3073
3215
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cap-js/cds-types",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.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/",
|
|
@@ -10,18 +10,25 @@
|
|
|
10
10
|
"Node.js"
|
|
11
11
|
],
|
|
12
12
|
"author": "SAP SE (https://www.sap.com)",
|
|
13
|
-
"license": "
|
|
13
|
+
"license": "Apache-2.0",
|
|
14
14
|
"typings": "dist/cds-types.d.ts",
|
|
15
15
|
"files": [
|
|
16
16
|
"dist/",
|
|
17
17
|
"scripts/",
|
|
18
|
-
"LICENSE",
|
|
19
18
|
"README.md"
|
|
20
19
|
],
|
|
21
20
|
"scripts": {
|
|
22
|
-
"test": "
|
|
23
|
-
"test:
|
|
24
|
-
"test:
|
|
21
|
+
"test:integration": "node --test ./test/postinstall.integrationtest.js",
|
|
22
|
+
"test:runtime": "npm run test:runtime:post-mortem; rm -rf test/typescript/_out",
|
|
23
|
+
"test:runtime:tsc": "npx tsc test/typescript/runtime.test.ts --outDir test/typescript/_out --target ES2020 --module commonjs --esModuleInterop",
|
|
24
|
+
"test:runtime:post-mortem": "npm run test:runtime:tsc && node --test './test/typescript/_out/runtime.test.js'",
|
|
25
|
+
"test:api-calls": "node --test './test/typescript/apis/cds-api-calls.test.js'",
|
|
26
|
+
"test:typings": "node --test './test/typescript/cds-typings.test.js'",
|
|
27
|
+
"test:all": "npm run test:runtime && npm run test:api-calls && npm run test:typings",
|
|
28
|
+
"test:setup": "npm install file:. --no-save --force && npm run prerelease:ci-fix",
|
|
29
|
+
"test": "npm run test:setup && npm run test:rollup-on",
|
|
30
|
+
"test:rollup-on": "npm run rollup && npm run rollup:on && npm run test:all --silent",
|
|
31
|
+
"test:rollup-off": "npm run rollup:off && npm run test:all --silent",
|
|
25
32
|
"rollup": "rm -rf dist/ && mkdir -p etc/ && npx -y @microsoft/api-extractor run --local --verbose && .github/rollup-patch.js",
|
|
26
33
|
"rollup:on": "npm pkg set typings=dist/cds-types.d.ts && [ -d 'apis' ] && mv -- apis -apis || true",
|
|
27
34
|
"rollup:off": "npm pkg set typings=apis/cds.d.ts && [ -d '-apis' ] && mv -- -apis apis || true",
|
|
@@ -33,30 +40,16 @@
|
|
|
33
40
|
"dependencies": "node ./scripts/postinstall.js"
|
|
34
41
|
},
|
|
35
42
|
"peerDependencies": {
|
|
36
|
-
"@sap/cds": "
|
|
37
|
-
|
|
38
|
-
"dependencies": {
|
|
39
|
-
"@types/express": "^4.17.21"
|
|
43
|
+
"@sap/cds": ">=8.0.0",
|
|
44
|
+
"@types/express": ">=4"
|
|
40
45
|
},
|
|
41
46
|
"devDependencies": {
|
|
42
|
-
"@
|
|
43
|
-
"@
|
|
44
|
-
"@stylistic/eslint-plugin-
|
|
45
|
-
"@stylistic/eslint-plugin-ts": "^2.1.0",
|
|
46
|
-
"@types/jest": "^29.5.11",
|
|
47
|
-
"@types/node": "^22",
|
|
47
|
+
"@cap-js/cds-test": "^0",
|
|
48
|
+
"@stylistic/eslint-plugin-js": "^4.0.1",
|
|
49
|
+
"@stylistic/eslint-plugin-ts": "^4.0.1",
|
|
48
50
|
"axios": "^1.6.2",
|
|
49
|
-
"chai": "^4.3.10",
|
|
50
51
|
"eslint": "^9.2.0",
|
|
51
|
-
"jest": "^29.7.0",
|
|
52
|
-
"ts-jest": "^29.1.1",
|
|
53
52
|
"typescript": "^5.4.5",
|
|
54
|
-
"typescript-eslint": "^8.0.0-alpha.51"
|
|
55
|
-
"winston": "^3.13.0"
|
|
56
|
-
},
|
|
57
|
-
"jest": {
|
|
58
|
-
"transform": {
|
|
59
|
-
"^.+\\.(ts|tsx)$": "ts-jest"
|
|
60
|
-
}
|
|
53
|
+
"typescript-eslint": "^8.0.0-alpha.51"
|
|
61
54
|
}
|
|
62
55
|
}
|