@cap-js/cds-types 0.10.0 → 0.11.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.
Files changed (2) hide show
  1. package/dist/cds-types.d.ts +236 -197
  2. package/package.json +1 -1
@@ -1,5 +1,5 @@
1
1
  declare module '@sap/cds' {
2
-
2
+
3
3
 
4
4
  export type __any_ = classes.any_
5
5
 
@@ -102,6 +102,11 @@ class any_<K extends kinds = kinds> {
102
102
 
103
103
  interface any__2 {
104
104
  kind?: kinds
105
+ /**
106
+ * only available when compiled with docs:true
107
+ * @see [capire docs](https://cap.cloud.sap/docs/cds/cdl#comments)
108
+ */
109
+ doc?: string
105
110
  }
106
111
 
107
112
  /**
@@ -111,7 +116,15 @@ interface any__2 {
111
116
  */
112
117
  export const app: import('express').Application;
113
118
 
114
- export class ApplicationService extends Service {}
119
+ export class ApplicationService extends Service {
120
+ new<T extends Constructable>(draft: T, data: {[K in keyof InstanceType<T>]?: InstanceType<T>[K]}): Promise<unknown>
121
+ new<T extends Constructable>(draft: T): {
122
+ for(keys: Key[]): Promise<unknown>,
123
+ }
124
+ discard(draft: Constructable, keys: Key[]): Promise<unknown>
125
+ edit(draft: Constructable, keys: Key[]): Promise<unknown>
126
+ save(draft: Constructable, keys: Key[]): Promise<unknown>
127
+ }
115
128
 
116
129
  export class array extends type<'type' | 'elements'> { }
117
130
 
@@ -214,7 +227,6 @@ export type CDL = string
214
227
 
215
228
  namespace cds {
216
229
  export {
217
- default_2 as default,
218
230
  log,
219
231
  debug,
220
232
  test,
@@ -309,6 +321,7 @@ namespace cds {
309
321
  spawn,
310
322
  Key,
311
323
  QueryAPI,
324
+ PropertiesOf,
312
325
  Service,
313
326
  ApplicationService,
314
327
  MessagingService,
@@ -387,10 +400,188 @@ namespace cds {
387
400
  i18n
388
401
  }
389
402
  }
403
+ export default cds;
390
404
 
391
- export type _cds = typeof cds
405
+ export type _cds = typeof cds_2
392
406
 
393
- type _cds_2 = typeof cds
407
+ namespace cds_2 {
408
+ export {
409
+ cds as default,
410
+ log,
411
+ debug,
412
+ test,
413
+ ql,
414
+ QLExtensions,
415
+ csn,
416
+ delete_ as delete,
417
+ version,
418
+ home,
419
+ root,
420
+ cli,
421
+ requires,
422
+ extend,
423
+ lazify,
424
+ lazified,
425
+ entity,
426
+ event,
427
+ type,
428
+ array,
429
+ struct,
430
+ Association,
431
+ Composition,
432
+ builtin,
433
+ on,
434
+ once,
435
+ exit,
436
+ _cds,
437
+ cds_services,
438
+ connect,
439
+ server,
440
+ serve,
441
+ services,
442
+ service,
443
+ cds_serve_fluent,
444
+ cds_connect_options,
445
+ Middlewares,
446
+ middlewares,
447
+ app,
448
+ env,
449
+ _TODO,
450
+ get,
451
+ load,
452
+ resolve,
453
+ minify,
454
+ reflect,
455
+ _flavor,
456
+ _odata_options,
457
+ _options,
458
+ JSON_2 as JSON,
459
+ YAML,
460
+ CDL,
461
+ SQL,
462
+ XML,
463
+ EDM,
464
+ EDMX,
465
+ filename,
466
+ model,
467
+ parse,
468
+ linked,
469
+ __type,
470
+ __aspect,
471
+ __any_,
472
+ __scalar,
473
+ __Boolean,
474
+ __UUID,
475
+ __String,
476
+ __LargeString,
477
+ __Binary,
478
+ __LargeBinary,
479
+ __Vector,
480
+ __Integer,
481
+ __UInt8,
482
+ __Int16,
483
+ __Int32,
484
+ __Int64,
485
+ __Float,
486
+ __Double,
487
+ __Decimal,
488
+ __date,
489
+ __Date,
490
+ __Time,
491
+ __DateTime,
492
+ __TimeStamp,
493
+ __array,
494
+ __struct,
495
+ __context_,
496
+ __service,
497
+ __entity,
498
+ __Association,
499
+ __Composition,
500
+ compile,
501
+ spawn,
502
+ Key,
503
+ QueryAPI,
504
+ PropertiesOf,
505
+ Service,
506
+ ApplicationService,
507
+ MessagingService,
508
+ RemoteService,
509
+ DatabaseService,
510
+ Transaction,
511
+ ResultSet,
512
+ ServiceImpl,
513
+ EventHandler,
514
+ OnEventHandler,
515
+ OnErrorHandler,
516
+ Partial_2 as Partial,
517
+ OneOrMany,
518
+ CdsFunction,
519
+ CdsFunctions,
520
+ HandlerFunction,
521
+ CRUDEventHandler,
522
+ ActionEventHandler,
523
+ ResultsHandler,
524
+ SpawnEvents,
525
+ SpawnEventEmitter,
526
+ types,
527
+ SpawnOptions,
528
+ context,
529
+ tx,
530
+ entities,
531
+ run,
532
+ foreach,
533
+ stream,
534
+ read,
535
+ create,
536
+ insert,
537
+ update,
538
+ transaction,
539
+ db,
540
+ outboxed,
541
+ unboxed,
542
+ EventContext,
543
+ Event_2 as Event,
544
+ Request_2 as Request,
545
+ User,
546
+ Anonymous,
547
+ Privileged,
548
+ utils,
549
+ Query,
550
+ SELECT_2 as SELECT,
551
+ INSERT_2 as INSERT,
552
+ UPSERT_2 as UPSERT,
553
+ UPDATE_2 as UPDATE,
554
+ DELETE_2 as DELETE,
555
+ CREATE_2 as CREATE,
556
+ DROP_2 as DROP,
557
+ primitive,
558
+ data,
559
+ name,
560
+ source,
561
+ column_expr,
562
+ predicate,
563
+ ordering_term,
564
+ expr,
565
+ ref,
566
+ _segment,
567
+ _named,
568
+ val,
569
+ xpr,
570
+ _xpr,
571
+ operator,
572
+ function_call,
573
+ enum_literal,
574
+ expr_literal,
575
+ Texts,
576
+ I18nBundle,
577
+ I18nFacade,
578
+ I18nFilesOptions,
579
+ I18nFiles,
580
+ i18n
581
+ }
582
+ }
583
+
584
+ type _cds_2 = typeof cds_2
394
585
 
395
586
  export interface cds_connect_options {
396
587
  impl?: string
@@ -609,7 +800,7 @@ export const connect: {
609
800
  * Shortcut for 'db' as the primary database returning `cds.DatabaseService`
610
801
  * @example await cds.connect.to ('db')
611
802
  */
612
- to(datasource: 'db', options?: cds_connect_options): Promise<cds.DatabaseService>,
803
+ to(datasource: 'db', options?: cds_connect_options): Promise<cds_2.DatabaseService>,
613
804
 
614
805
  /**
615
806
  * Connects to a specific datasource via a Service subclass
@@ -625,7 +816,7 @@ export const connect: {
625
816
  * await cds.connect.to (ServiceClass)
626
817
  * @see [capire](https://cap.cloud.sap/docs/node.js/cds-connect#cds-connect-to)
627
818
  */
628
- to<S>(datasource: S, options?: cds_connect_options): Promise<cds.CdsFunctions<S> & Service>,
819
+ to<S>(datasource: S, options?: cds_connect_options): Promise<cds_2.CdsFunctions<S> & Service>,
629
820
 
630
821
  /**
631
822
  * Connects to a specific datasource via options.
@@ -825,181 +1016,6 @@ class Decimal extends Float {
825
1016
  scale?: number
826
1017
  }
827
1018
 
828
- export namespace default_2 {
829
- export {
830
- log,
831
- debug,
832
- test,
833
- ql,
834
- QLExtensions,
835
- csn,
836
- delete_ as delete,
837
- version,
838
- home,
839
- root,
840
- cli,
841
- requires,
842
- extend,
843
- lazify,
844
- lazified,
845
- entity,
846
- event,
847
- type,
848
- array,
849
- struct,
850
- Association,
851
- Composition,
852
- builtin,
853
- on,
854
- once,
855
- exit,
856
- _cds,
857
- cds_services,
858
- connect,
859
- server,
860
- serve,
861
- services,
862
- service,
863
- cds_serve_fluent,
864
- cds_connect_options,
865
- Middlewares,
866
- middlewares,
867
- app,
868
- env,
869
- _TODO,
870
- get,
871
- load,
872
- resolve,
873
- minify,
874
- reflect,
875
- _flavor,
876
- _odata_options,
877
- _options,
878
- JSON_2 as JSON,
879
- YAML,
880
- CDL,
881
- SQL,
882
- XML,
883
- EDM,
884
- EDMX,
885
- filename,
886
- model,
887
- parse,
888
- linked,
889
- __type,
890
- __aspect,
891
- __any_,
892
- __scalar,
893
- __Boolean,
894
- __UUID,
895
- __String,
896
- __LargeString,
897
- __Binary,
898
- __LargeBinary,
899
- __Vector,
900
- __Integer,
901
- __UInt8,
902
- __Int16,
903
- __Int32,
904
- __Int64,
905
- __Float,
906
- __Double,
907
- __Decimal,
908
- __date,
909
- __Date,
910
- __Time,
911
- __DateTime,
912
- __TimeStamp,
913
- __array,
914
- __struct,
915
- __context_,
916
- __service,
917
- __entity,
918
- __Association,
919
- __Composition,
920
- compile,
921
- spawn,
922
- Key,
923
- QueryAPI,
924
- Service,
925
- ApplicationService,
926
- MessagingService,
927
- RemoteService,
928
- DatabaseService,
929
- Transaction,
930
- ResultSet,
931
- ServiceImpl,
932
- EventHandler,
933
- OnEventHandler,
934
- OnErrorHandler,
935
- Partial_2 as Partial,
936
- OneOrMany,
937
- CdsFunction,
938
- CdsFunctions,
939
- HandlerFunction,
940
- CRUDEventHandler,
941
- ActionEventHandler,
942
- ResultsHandler,
943
- SpawnEvents,
944
- SpawnEventEmitter,
945
- types,
946
- SpawnOptions,
947
- context,
948
- tx,
949
- entities,
950
- run,
951
- foreach,
952
- stream,
953
- read,
954
- create,
955
- insert,
956
- update,
957
- transaction,
958
- db,
959
- outboxed,
960
- unboxed,
961
- EventContext,
962
- Event_2 as Event,
963
- Request_2 as Request,
964
- User,
965
- Anonymous,
966
- Privileged,
967
- utils,
968
- Query,
969
- SELECT_2 as SELECT,
970
- INSERT_2 as INSERT,
971
- UPSERT_2 as UPSERT,
972
- UPDATE_2 as UPDATE,
973
- DELETE_2 as DELETE,
974
- CREATE_2 as CREATE,
975
- DROP_2 as DROP,
976
- primitive,
977
- data,
978
- name,
979
- source,
980
- column_expr,
981
- predicate,
982
- ordering_term,
983
- expr,
984
- ref,
985
- _segment,
986
- _named,
987
- val,
988
- xpr,
989
- _xpr,
990
- operator,
991
- function_call,
992
- enum_literal,
993
- expr_literal,
994
- Texts,
995
- I18nBundle,
996
- I18nFacade,
997
- I18nFilesOptions,
998
- I18nFiles,
999
- i18n
1000
- }
1001
- }
1002
-
1003
1019
  /**
1004
1020
  * Definitions are the central elements of a CDS model.
1005
1021
  */
@@ -1648,6 +1664,9 @@ export const linked: {
1648
1664
  export namespace linked {
1649
1665
  export type LinkedDefinitions = IterableMap<linked_2.classes.any_>
1650
1666
  export type LinkedCSN = linked_2.LinkedCSN
1667
+ // synthetic class that is prominently featured in capire,
1668
+ // but described as "accessible through cds.linked.classes.any"
1669
+ export type LinkedDefinition = linked_2.classes.any_
1651
1670
 
1652
1671
  export namespace classes {
1653
1672
  export type type = __type
@@ -2201,6 +2220,10 @@ export class Privileged extends User {
2201
2220
 
2202
2221
  type Projection<T> = (e: QLExtensions<T extends ArrayConstructable ? SingularInstanceType<T> : T>) => void
2203
2222
 
2223
+ export type PropertiesOf<T> = {
2224
+ [K in keyof T]?: T[K];
2225
+ };
2226
+
2204
2227
  /**
2205
2228
  * @alpha
2206
2229
  * related to .protocols getters
@@ -2419,7 +2442,7 @@ class Request_2<T = any> extends Event_2<T> {
2419
2442
 
2420
2443
  error (code: number, message: string, target?: string, args?: any[]): Error
2421
2444
 
2422
- reject (code: number, message: string, target?: string, args?: any[]): Error
2445
+ reject (code: number, message: string, target?: string, args?: any[]): never
2423
2446
 
2424
2447
  notify (code: number, message: string, args?: any[]): Error
2425
2448
 
@@ -2429,7 +2452,7 @@ class Request_2<T = any> extends Event_2<T> {
2429
2452
 
2430
2453
  error (code: number, message: string, args?: any[]): Error
2431
2454
 
2432
- reject (code: number, message: string, args?: any[]): Error
2455
+ reject (code: number, message: string, args?: any[]): never
2433
2456
 
2434
2457
  notify (message: string, target?: string, args?: any[]): Error
2435
2458
 
@@ -2439,7 +2462,7 @@ class Request_2<T = any> extends Event_2<T> {
2439
2462
 
2440
2463
  error (message: string, target?: string, args?: any[]): Error
2441
2464
 
2442
- reject (message: string, target?: string, args?: any[]): Error
2465
+ reject (message: string, target?: string, args?: any[]): never
2443
2466
 
2444
2467
  notify (message: { code?: number | string, message: string, target?: string, args?: any[] }): Error
2445
2468
 
@@ -2449,7 +2472,7 @@ class Request_2<T = any> extends Event_2<T> {
2449
2472
 
2450
2473
  error (message: { code?: number | string, message: string, target?: string, args?: any[], status?: number }): Error
2451
2474
 
2452
- reject (message: { code?: number | string, message: string, target?: string, args?: any[], status?: number }): Error
2475
+ reject (message: { code?: number | string, message: string, target?: string, args?: any[], status?: number }): never
2453
2476
 
2454
2477
  }
2455
2478
  export { Request_2 as Request }
@@ -2538,17 +2561,6 @@ class SELECT_3<T, Q = SELECT_from> extends ConstructedQuery<T> {
2538
2561
  alias (as: string): this
2539
2562
  elements: EntityElements
2540
2563
 
2541
-
2542
- // Not yet public
2543
- // fullJoin (other: string, as: string) : this
2544
- // leftJoin (other: string, as: string) : this
2545
- // rightJoin (other: string, as: string) : this
2546
- // innerJoin (other: string, as: string) : this
2547
- // join (other: string, as: string, kind?: string) : this
2548
- // on : TaggedTemplateQueryPart<this>
2549
- // & ((...expr : string[]) => this)
2550
- // & ((predicate:object) => this)
2551
-
2552
2564
  SELECT: CQN.SELECT['SELECT'] & {
2553
2565
  forUpdate?: { wait: number },
2554
2566
  forShareLock?: { wait: number },
@@ -2698,6 +2710,14 @@ export class Service extends QueryAPI {
2698
2710
  * @see [capire docs](https://cap.cloud.sap/docs/node.js/core-services#srv-emit-event)
2699
2711
  */
2700
2712
  emit: {
2713
+ // we can only give very little guidance as to code completion here.
2714
+ // Users will receive suggestions/ code completion for the property names of P.
2715
+ // But they will see no complaints for when they pass a non-existing property or use the wrong type for it.
2716
+ // That is because classes still fulfill {name:string}, so they can be used for the overload where event of type types.event,
2717
+ // which allows for any object as data.
2718
+ <P extends Constructable, R>(event: P, data: PropertiesOf<InstanceType<P>>, headers?: object): Promise<R>,
2719
+ <P extends ArrayConstructable, R>(event: P, data: PropertiesOf<SingularInstanceType<P>>, headers?: object): Promise<R>,
2720
+ <T = any>(event: types.event, data?: object, headers?: object): Promise<T>,
2701
2721
  <T = any>(details: { event: types.event, data?: object, headers?: object }): Promise<T>,
2702
2722
  <T = any>(event: types.event, data?: object, headers?: object): Promise<T>,
2703
2723
  }
@@ -2952,6 +2972,8 @@ type Subqueryable<T> = T extends Primitive ? unknown
2952
2972
  * Note that you do not need to return anything from these subqueries.
2953
2973
  */
2954
2974
  (fn: ((a: QLExtensions<T[number]>) => any) | '*'): T[number],
2975
+ // infix filters, like b.author`[city='Paris']`('*')
2976
+ (predicate: TemplateStringsArray): Subqueryable<T>,
2955
2977
  }
2956
2978
  // composition of one/ association to one
2957
2979
  : {
@@ -2972,6 +2994,8 @@ type Subqueryable<T> = T extends Primitive ? unknown
2972
2994
  * Note that you do not need to return anything from these subqueries.
2973
2995
  */
2974
2996
  (fn: ((a: QLExtensions<T>) => any) | '*'): T,
2997
+ // infix filters, like b.author`[city='Paris']`('*')
2998
+ (predicate: TemplateStringsArray): Subqueryable<T>,
2975
2999
  }
2976
3000
 
2977
3001
  type TaggedTemplateQueryPart<T> = (strings: TemplateStringsArray, ...params: unknown[]) => T
@@ -3302,6 +3326,21 @@ export const utils: {
3302
3326
  */
3303
3327
  rm: (...path: string[]) => Promise<ReturnType<typeof import('node:fs').promises.rm>>,
3304
3328
 
3329
+ /**
3330
+ * Shortcut for require("fs")
3331
+ */
3332
+ fs: typeof import('node:fs'),
3333
+
3334
+ /**
3335
+ * Shortcut for require("path")
3336
+ */
3337
+ path: typeof import('node:path'),
3338
+
3339
+ /**
3340
+ * Shortcut for require("util").inspect
3341
+ */
3342
+ inspect: typeof import('node:util').inspect,
3343
+
3305
3344
  /**
3306
3345
  * @since 8.3.0
3307
3346
  * @see https://cap.cloud.sap/docs/node.js/cds-utils#colors
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cap-js/cds-types",
3
- "version": "0.10.0",
3
+ "version": "0.11.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/",