@cap-js/cds-types 0.4.0 → 0.5.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 +385 -287
  2. package/package.json +2 -1
@@ -7,17 +7,79 @@ import * as http from 'http';
7
7
  import { ReadableStream } from 'node:stream/web';
8
8
  import { RequestHandler } from 'express';
9
9
 
10
- export declare class action extends any_<'action' | 'function'> {}
10
+ export declare type __any_ = classes.any_
11
+
12
+ export declare type __array = classes.array
13
+
14
+ export declare type __aspect = classes.aspect
15
+
16
+ export declare type __Association = classes.Association
17
+
18
+ export declare type __Binary = classes.Binary
19
+
20
+ export declare type __Boolean = classes.Boolean
21
+
22
+ export declare type __Composition = classes.Composition
23
+
24
+ export declare type __context_ = classes.context_
25
+
26
+ export declare type __Date = classes.Date
27
+
28
+ export declare type __date = classes.date
29
+
30
+ export declare type __DateTime = classes.DateTime
31
+
32
+ export declare type __Decimal = classes.Decimal
33
+
34
+ export declare type __Double = classes.Double
35
+
36
+ export declare type __entity = classes.entity
37
+
38
+ export declare type __Float = classes.Float
39
+
40
+ export declare type __Int16 = classes.Int16
41
+
42
+ export declare type __Int32 = classes.Int32
43
+
44
+ export declare type __Int64 = classes.Int64
45
+
46
+ export declare type __Integer = classes.Integer
47
+
48
+ export declare type __LargeBinary = classes.LargeBinary
49
+
50
+ export declare type __LargeString = classes.LargeString
51
+
52
+ export declare type __scalar = classes.scalar
53
+
54
+ export declare type __service = classes.service_
55
+
56
+ export declare type __String = classes.String
57
+
58
+ export declare type __struct = classes.struct
59
+
60
+ export declare type __Time = classes.Time
61
+
62
+ export declare type __TimeStamp = classes.TimeStamp
63
+
64
+ export declare type __type = classes.type
65
+
66
+ export declare type __UInt8 = classes.UInt8
67
+
68
+ export declare type __UUID = classes.UUID
69
+
70
+ export declare type __Vector = classes.Vector
71
+
72
+ declare class action extends any_<'action' | 'function'> {}
11
73
 
12
74
  export declare interface ActionEventHandler<P, R> {
13
75
  (req: Omit<Request_2, 'data'> & { data: P }, next: Function): Promise<R> | R
14
76
  }
15
77
 
16
- export declare const any: typeof any_;
78
+ declare const any: typeof any_;
17
79
 
18
- export declare interface any_ extends csn.any_ {}
80
+ declare interface any_ extends csn.any_ {}
19
81
 
20
- export declare class any_<K extends kinds = kinds> {
82
+ declare class any_<K extends kinds = kinds> {
21
83
  private _: K // break covariance
22
84
  constructor (...aspects: any[])
23
85
 
@@ -52,7 +114,7 @@ declare type _ArrayLike<T> = Iterable<T> & {
52
114
  find: (predicate: (element: T) => boolean) => T | undefined,
53
115
  }
54
116
 
55
- export declare class aspect<K extends kinds = 'aspect'> extends type<K> implements WithElements {
117
+ declare class aspect<K extends kinds = 'aspect'> extends type<K> implements WithElements {
56
118
  elements: Definitions<type<'type'>>
57
119
  }
58
120
 
@@ -123,14 +185,13 @@ declare class Axios {
123
185
 
124
186
  }
125
187
 
126
- export declare class Binary extends string { }
188
+ declare class Binary extends string { }
127
189
 
128
- export declare const boolean: typeof boolean_;
190
+ declare const boolean: typeof boolean_;
129
191
 
130
192
  declare class boolean_ extends scalar { }
131
193
 
132
194
  declare class Boolean_2 extends boolean { }
133
- export { Boolean_2 as Boolean }
134
195
 
135
196
  export declare const builtin: {
136
197
 
@@ -201,6 +262,37 @@ declare namespace cds {
201
262
  model,
202
263
  parse,
203
264
  linked,
265
+ __type,
266
+ __aspect,
267
+ __any_,
268
+ __scalar,
269
+ __Boolean,
270
+ __UUID,
271
+ __String,
272
+ __LargeString,
273
+ __Binary,
274
+ __LargeBinary,
275
+ __Vector,
276
+ __Integer,
277
+ __UInt8,
278
+ __Int16,
279
+ __Int32,
280
+ __Int64,
281
+ __Float,
282
+ __Double,
283
+ __Decimal,
284
+ __date,
285
+ __Date,
286
+ __Time,
287
+ __DateTime,
288
+ __TimeStamp,
289
+ __array,
290
+ __struct,
291
+ __context_,
292
+ __service,
293
+ __entity,
294
+ __Association,
295
+ __Composition,
204
296
  compile,
205
297
  spawn,
206
298
  Key,
@@ -270,10 +362,41 @@ declare namespace cds {
270
362
  operator,
271
363
  function_call,
272
364
  enum_literal,
273
- expr_literal,
274
- ModelPart,
275
- Definition,
276
- CSN,
365
+ expr_literal
366
+ }
367
+ }
368
+
369
+ export declare type _cds = typeof cds
370
+
371
+ declare type _cds_2 = typeof cds
372
+
373
+ export declare interface cds_connect_options {
374
+ impl?: string
375
+ service?: string
376
+ kind?: string
377
+ model?: string
378
+ credentials?: object
379
+ }
380
+
381
+ export declare interface cds_serve_fluent {
382
+ from (model: string | CSN): cds_serve_fluent
383
+ to (protocol: string): cds_serve_fluent
384
+ at (path: string): cds_serve_fluent
385
+ in (app: Application): cds_serve_fluent
386
+ with (impl: ServiceImpl | string): cds_serve_fluent
387
+ // (req,res) : void
388
+ }
389
+
390
+ export declare type cds_services = { [name: string]: Service }
391
+
392
+ export declare type CdsFunction = {
393
+ (...args: any[]): any,
394
+ __parameters: object,
395
+ __returns: any,
396
+ }
397
+
398
+ declare namespace classes {
399
+ export {
277
400
  mixin,
278
401
  Protocol,
279
402
  Column,
@@ -282,6 +405,7 @@ declare namespace cds {
282
405
  any_,
283
406
  any,
284
407
  aspect,
408
+ type,
285
409
  scalar,
286
410
  boolean,
287
411
  Boolean_2 as Boolean,
@@ -306,44 +430,21 @@ declare namespace cds {
306
430
  Time,
307
431
  DateTime,
308
432
  TimeStamp,
433
+ array,
434
+ struct,
309
435
  context_,
310
436
  service_,
311
437
  action,
438
+ event,
439
+ entity,
440
+ Association,
441
+ Composition,
312
442
  ManagedAssociation,
313
443
  MixedIn
314
444
  }
315
445
  }
316
446
 
317
- export declare type _cds = typeof cds
318
-
319
- declare type _cds_2 = typeof cds
320
-
321
- export declare interface cds_connect_options {
322
- impl?: string
323
- service?: string
324
- kind?: string
325
- model?: string
326
- credentials?: object
327
- }
328
-
329
- export declare interface cds_serve_fluent {
330
- from (model: string | CSN_2): cds_serve_fluent
331
- to (protocol: string): cds_serve_fluent
332
- at (path: string): cds_serve_fluent
333
- in (app: Application): cds_serve_fluent
334
- with (impl: ServiceImpl | string): cds_serve_fluent
335
- // (req,res) : void
336
- }
337
-
338
- export declare type cds_services = { [name: string]: Service }
339
-
340
- export declare type CdsFunction = {
341
- (...args: any[]): any,
342
- __parameters: object,
343
- __returns: any,
344
- }
345
-
346
- export declare type Column = { ref: [string], as?: string }
447
+ declare type Column = { ref: [string], as?: string }
347
448
 
348
449
  export declare type column_expr = UnionToIntersection<expr> & { as?: name, cast?: any, expand?: column_expr[], inline?: column_expr[] }
349
450
 
@@ -474,9 +575,9 @@ declare class ConstructedQuery {
474
575
  */
475
576
  export declare let context: EventContext | undefined;
476
577
 
477
- export declare interface context_ extends csn.context {}
578
+ declare interface context_ extends csn.context {}
478
579
 
479
- export declare class context_ extends any_ { }
580
+ declare class context_ extends any_ { }
480
581
 
481
582
  declare interface context_2 extends any__2 { }
482
583
 
@@ -531,110 +632,10 @@ export declare namespace CRUDEventHandler {
531
632
  export type After<P, R = P | void | Error> = (data: undefined | P, req: TypedRequest<P>) => Promise<R> | R
532
633
  }
533
634
 
534
- export declare interface CSN extends Omit<csn.CSN, 'definitions'> {
535
-
536
- /**
537
- * Fetches definitions matching the given filter, returning an iterator on them.
538
- * @example
539
- * ```js
540
- * let m = cds.reflect (aParsedModel)
541
- * for (let d of m.each('entity')) console.log (d.kind, d.name)
542
- * let entities = [...m.each('entity')] //> capture all
543
- * let entities = m.all('entity') //> equivalent shortcut
544
- * ```
545
- */
546
- each<T extends any_>(x: Filter, defs?: Definitions<T>): IterableIterator<T>
547
-
548
- /**
549
- * Fetches definitions matching the given filter, returning them in an array.
550
- * Convenience shortcut for `[...reflect.each('entity')]`
551
- */
552
- all<T extends any_>(x: Filter, defs?: Definitions<T>): T[]
553
-
554
- /**
555
- * Fetches definitions matching the given filter, returning the first match, if any.
556
- * @example
557
- * let service = model.find('service')
558
- * @param x - the filter
559
- * @param defs - the definitions to fetch in, default: `this.definitions`
560
- */
561
- find<T extends any_>(x: Filter, defs?: Definitions<T>): T | undefined
562
-
563
- /**
564
- * Calls the visitor for each definition matching the given filter.
565
- * @see [capire](https://cap.cloud.sap/docs/node.js/cds-reflect#foreach)
566
- */
567
- foreach(x: Filter, visitor: Visitor, defs?: Definitions): this
568
- foreach(visitor: Visitor, defs?: Definitions): this
569
-
570
- /**
571
- * Same as foreach but recursively visits each element definition
572
- * @see [capire](https://cap.cloud.sap/docs/node.js/cds-reflect#foreach)
573
- */
574
- forall(x: Filter, visitor: Visitor, defs?: Definitions): this
575
- forall(visitor: Visitor, defs?: Definitions): this
576
-
577
- /**
578
- * Fetches definitions declared as children of a given parent context or service.
579
- * It fetches all definitions whose fully-qualified names start with the parent's name.
580
- * Returns the found definitions as an object with the local names as keys.
581
- * @example
582
- * ```js
583
- * let service = model.find ('service')
584
- * let entities = m.childrenOf (service)
585
- * ```
586
- * @param parent - either the parent itself or its fully-qualified name
587
- * @param filter - an optional filter to apply before picking a child
588
- */
589
- childrenOf(parent: any | string, filter?: ((def: any_) => boolean)): Definitions
590
-
591
- /**
592
- * Provides convenient access to the model's top-level definitions.
593
- * For example, you can use it in an es6-import-like fashion to avoid
594
- * working with fully-qualified names as follows:
595
- *
596
- * @example
597
- * ```js
598
- * let model = cds.reflect (cds.parse(`
599
- * namespace our.lovely.bookshop;
600
- * entity Books {...}
601
- * entity Authors {...}
602
- * `))
603
- * const {Books,Authors} = model.exports
604
- * SELECT.from (Books) .where ({ID:11})
605
- * ```
606
- */
607
- exports: IterableMap<any_>
608
- definitions: IterableMap<any_>
609
- entities: ModelPart<entity>
610
- services: ModelPart<service_>
611
-
612
- }
613
-
614
- declare namespace csn {
615
- export {
616
- CSN_2 as CSN,
617
- FQN,
618
- Definition_2 as Definition,
619
- Extension,
620
- Element,
621
- kinds,
622
- any__2 as any_,
623
- context_2 as context,
624
- service_2 as service,
625
- type_2 as type,
626
- struct_2 as struct,
627
- entity_2 as entity,
628
- EntityElements,
629
- Association_2 as Association
630
- }
631
- }
632
- export { csn }
633
-
634
635
  /**
635
636
  * A parsed CDS model in CSN object notation.
636
637
  */
637
- declare interface CSN_2 {
638
+ declare interface CSN {
638
639
 
639
640
  /**
640
641
  * The assigned namespace. If parsed from multiple sources,
@@ -652,7 +653,7 @@ declare interface CSN_2 {
652
653
  /**
653
654
  * All definitions in the model including those from imported models.
654
655
  */
655
- definitions?: Record<FQN, Definition_2>
656
+ definitions?: Record<FQN, Definition>
656
657
 
657
658
  /**
658
659
  * All extensions in the model including those from imported models.
@@ -666,6 +667,26 @@ declare interface CSN_2 {
666
667
  $sources?: string[]
667
668
  }
668
669
 
670
+ declare namespace csn {
671
+ export {
672
+ CSN,
673
+ FQN,
674
+ Definition,
675
+ Extension,
676
+ Element,
677
+ kinds,
678
+ any__2 as any_,
679
+ context_2 as context,
680
+ service_2 as service,
681
+ type_2 as type,
682
+ struct_2 as struct,
683
+ entity_2 as entity,
684
+ EntityElements,
685
+ Association_2 as Association
686
+ }
687
+ }
688
+ export { csn }
689
+
669
690
  /** @private */
670
691
  export declare type data = Record<string, any>
671
692
 
@@ -689,12 +710,11 @@ declare class DataUtil {
689
710
 
690
711
  }
691
712
 
692
- export declare class date extends scalar { }
713
+ declare class date extends scalar { }
693
714
 
694
715
  declare class Date_2 extends date { }
695
- export { Date_2 as Date }
696
716
 
697
- export declare class DateTime extends date { }
717
+ declare class DateTime extends date { }
698
718
 
699
719
  export declare const db: DatabaseService;
700
720
 
@@ -712,19 +732,19 @@ export declare const db: DatabaseService;
712
732
  */
713
733
  export declare function debug (name: string): undefined | Log
714
734
 
715
- export declare class Decimal extends Float { }
716
-
717
- export declare type Definition = any_
735
+ declare class Decimal extends Float { }
718
736
 
719
737
  /**
720
738
  * Definitions are the central elements of a CDS model.
721
739
  */
722
- declare type Definition_2 = context_2 & service_2 & type_2 & struct_2 & entity_2 & Association_2
740
+ declare type Definition = context_2 & service_2 & type_2 & struct_2 & entity_2 & Association_2
741
+
742
+ declare type Definition_2 = any_
723
743
 
724
744
  /**
725
745
  * @see [capire](https://cap.cloud.sap/docs/node.js/cds-reflect#iterable)
726
746
  */
727
- export declare type Definitions<T extends any_ = any_> = IterableMap<T>
747
+ declare type Definitions<T extends any_ = any_> = IterableMap<T>
728
748
 
729
749
  declare const delete_: Service['delete'];
730
750
  export { delete_ as delete };
@@ -755,7 +775,7 @@ declare class DELETE_3<T> extends ConstructedQuery {
755
775
 
756
776
  }
757
777
 
758
- export declare class Double extends Float { }
778
+ declare class Double extends Float { }
759
779
 
760
780
  declare type DROP_2 = { DROP: {
761
781
  entity: name,
@@ -813,7 +833,7 @@ declare interface entity_2 extends Omit<struct_2, 'elements'> {
813
833
  */
814
834
  elements: EntityElements
815
835
  // REVISIT: following should move to LinkedCSN
816
- keys: { [name: string]: Definition_2 }
836
+ keys: { [name: string]: Definition }
817
837
  drafts?: entity_2
818
838
  }
819
839
 
@@ -1018,7 +1038,7 @@ declare type Filter = string | (<T extends any_ = any_>(def: T) => boolean)
1018
1038
 
1019
1039
  export declare type _flavor = 'parsed' | 'xtended' | 'inferred'
1020
1040
 
1021
- export declare class Float extends number { }
1041
+ declare class Float extends number { }
1022
1042
 
1023
1043
  export declare const foreach: Service['foreach'];
1024
1044
 
@@ -1094,13 +1114,13 @@ declare class INSERT_3<T> extends ConstructedQuery {
1094
1114
 
1095
1115
  }
1096
1116
 
1097
- export declare class Int16 extends Integer { }
1117
+ declare class Int16 extends Integer { }
1098
1118
 
1099
- export declare class Int32 extends Integer { }
1119
+ declare class Int32 extends Integer { }
1100
1120
 
1101
- export declare class Int64 extends Integer { }
1121
+ declare class Int64 extends Integer { }
1102
1122
 
1103
- export declare class Integer extends number { }
1123
+ declare class Integer extends number { }
1104
1124
 
1105
1125
  declare type Intersect<T extends readonly unknown[]> = T extends [infer Head, ...infer Tail]
1106
1126
  ? Head & Intersect<Tail>
@@ -1119,9 +1139,9 @@ export declare type Key = number | string | any
1119
1139
 
1120
1140
  declare type kinds = 'aspect' | 'entity' | 'type' | 'event' | 'action' | 'function' | 'service' | 'context' | 'elements'
1121
1141
 
1122
- export declare class LargeBinary extends Binary { }
1142
+ declare class LargeBinary extends Binary { }
1123
1143
 
1124
- export declare class LargeString extends String_2 { }
1144
+ declare class LargeString extends String_2 { }
1125
1145
 
1126
1146
  /**
1127
1147
  * Prepare a node module for lazy-loading submodules instead
@@ -1168,114 +1188,162 @@ export declare const linked: {
1168
1188
  * Turns the given plain CSN model into a linked model
1169
1189
  * @see [capire](https://cap.cloud.sap/docs/node.js/cds-reflect)
1170
1190
  */
1171
- (model: csn.CSN): linked_2.CSN,
1191
+ (model: csn.CSN): linked_2.LinkedCSN,
1172
1192
 
1173
1193
  /**
1174
1194
  * Base classes of linked definitions from reflected models.
1175
1195
  * @see [capire](https://cap.cloud.sap/docs/node.js/cds-reflect#cds-builtin-classes)
1176
1196
  */
1177
- classes: typeof LinkedClasses,
1197
+ classes: typeof classes,
1198
+
1199
+ /**
1200
+ * @see [capire](https://cap.cloud.sap/docs/node.js/cds-reflect#linked-csn)
1201
+ */
1202
+ LinkedCSN: linked_2.LinkedCSN,
1203
+
1204
+ /**
1205
+ * @see [capire](https://cap.cloud.sap/docs/node.js/cds-reflect#iterable)
1206
+ */
1207
+ LinkedDefinitions: IterableMap<linked_2.classes.any_>,
1178
1208
  };
1179
1209
 
1210
+ export declare namespace linked {
1211
+ export type LinkedDefinitions = IterableMap<linked_2.classes.any_>
1212
+ export type LinkedCSN = linked_2.LinkedCSN
1213
+
1214
+ export namespace classes {
1215
+ export type type = __type
1216
+ export type aspect = __aspect
1217
+
1218
+ export type any_ = __any_
1219
+
1220
+ export type scalar = __scalar
1221
+ // can not shadow builtins. Same for string and number...
1222
+ //export type boolean = LinkedClasses.Boolean // on purpose
1223
+ export type Boolean = __Boolean
1224
+
1225
+ export type UUID = __UUID
1226
+ //export type string = LinkedClasses.String // on purpose
1227
+ export type String = __String
1228
+ export type LargeString = __LargeString
1229
+ export type Binary = __Binary
1230
+ export type LargeBinary = __LargeBinary
1231
+ export type Vector = __Vector
1232
+
1233
+ //export type number = LinkedClasses.scalar // currently no better way to do this
1234
+ export type Integer = __Integer
1235
+ export type UInt8 = __UInt8
1236
+ export type Int16 = __Int16
1237
+ export type Int32 = __Int32
1238
+ export type Int64 = __Int64
1239
+ export type Float = __Float
1240
+ export type Double = __Double
1241
+ export type Decimal = __Decimal
1242
+
1243
+ export type date = __date
1244
+ export type Date = __Date
1245
+ export type Time = __Time
1246
+ export type DateTime = __DateTime
1247
+ export type TimeStamp = __TimeStamp
1248
+
1249
+ export type array = __array
1250
+
1251
+ export type struct = __struct
1252
+ export type context_ = __context_
1253
+ export type service = __service
1254
+ export type entity = __entity
1255
+ export type Association = __Association
1256
+ export type Composition = __Composition
1257
+ }
1258
+ }
1259
+
1180
1260
  declare namespace linked_2 {
1181
1261
  export {
1182
1262
  ModelPart,
1183
- Definition,
1184
- CSN,
1185
- mixin,
1186
- Protocol,
1187
- Column,
1188
- Definitions,
1189
- WithElements,
1190
- any_,
1191
- any,
1192
- aspect,
1193
- type,
1194
- scalar,
1195
- boolean,
1196
- Boolean_2 as Boolean,
1197
- string,
1198
- UUID,
1199
- String_2 as String,
1200
- LargeString,
1201
- Binary,
1202
- LargeBinary,
1203
- Vector,
1204
- number,
1205
- Integer,
1206
- UInt8,
1207
- Int16,
1208
- Int32,
1209
- Int64,
1210
- Float,
1211
- Double,
1212
- Decimal,
1213
- date,
1214
- Date_2 as Date,
1215
- Time,
1216
- DateTime,
1217
- TimeStamp,
1218
- array,
1219
- struct,
1220
- context_,
1221
- service_,
1222
- action,
1223
- event,
1224
- entity,
1225
- Association,
1226
- Composition,
1227
- ManagedAssociation,
1228
- MixedIn
1263
+ Definition_2 as Definition,
1264
+ LinkedCSN,
1265
+ classes
1229
1266
  }
1230
1267
  }
1231
1268
 
1232
- declare namespace LinkedClasses {
1233
- export {
1234
- mixin,
1235
- Protocol,
1236
- Column,
1237
- Definitions,
1238
- WithElements,
1239
- any_,
1240
- any,
1241
- aspect,
1242
- type,
1243
- scalar,
1244
- boolean,
1245
- Boolean_2 as Boolean,
1246
- string,
1247
- UUID,
1248
- String_2 as String,
1249
- LargeString,
1250
- Binary,
1251
- LargeBinary,
1252
- Vector,
1253
- number,
1254
- Integer,
1255
- UInt8,
1256
- Int16,
1257
- Int32,
1258
- Int64,
1259
- Float,
1260
- Double,
1261
- Decimal,
1262
- date,
1263
- Date_2 as Date,
1264
- Time,
1265
- DateTime,
1266
- TimeStamp,
1267
- array,
1268
- struct,
1269
- context_,
1270
- service_,
1271
- action,
1272
- event,
1273
- entity,
1274
- Association,
1275
- Composition,
1276
- ManagedAssociation,
1277
- MixedIn
1278
- }
1269
+ declare interface LinkedCSN extends Omit<csn.CSN, 'definitions'> {
1270
+
1271
+ /**
1272
+ * Fetches definitions matching the given filter, returning an iterator on them.
1273
+ * @example
1274
+ * ```js
1275
+ * let m = cds.reflect (aParsedModel)
1276
+ * for (let d of m.each('entity')) console.log (d.kind, d.name)
1277
+ * let entities = [...m.each('entity')] //> capture all
1278
+ * let entities = m.all('entity') //> equivalent shortcut
1279
+ * ```
1280
+ */
1281
+ each<T extends any_>(x: Filter, defs?: Definitions<T>): IterableIterator<T>
1282
+
1283
+ /**
1284
+ * Fetches definitions matching the given filter, returning them in an array.
1285
+ * Convenience shortcut for `[...reflect.each('entity')]`
1286
+ */
1287
+ all<T extends any_>(x: Filter, defs?: Definitions<T>): T[]
1288
+
1289
+ /**
1290
+ * Fetches definitions matching the given filter, returning the first match, if any.
1291
+ * @example
1292
+ * let service = model.find('service')
1293
+ * @param x - the filter
1294
+ * @param defs - the definitions to fetch in, default: `this.definitions`
1295
+ */
1296
+ find<T extends any_>(x: Filter, defs?: Definitions<T>): T | undefined
1297
+
1298
+ /**
1299
+ * Calls the visitor for each definition matching the given filter.
1300
+ * @see [capire](https://cap.cloud.sap/docs/node.js/cds-reflect#foreach)
1301
+ */
1302
+ foreach(x: Filter, visitor: Visitor, defs?: Definitions): this
1303
+ foreach(visitor: Visitor, defs?: Definitions): this
1304
+
1305
+ /**
1306
+ * Same as foreach but recursively visits each element definition
1307
+ * @see [capire](https://cap.cloud.sap/docs/node.js/cds-reflect#foreach)
1308
+ */
1309
+ forall(x: Filter, visitor: Visitor, defs?: Definitions): this
1310
+ forall(visitor: Visitor, defs?: Definitions): this
1311
+
1312
+ /**
1313
+ * Fetches definitions declared as children of a given parent context or service.
1314
+ * It fetches all definitions whose fully-qualified names start with the parent's name.
1315
+ * Returns the found definitions as an object with the local names as keys.
1316
+ * @example
1317
+ * ```js
1318
+ * let service = model.find ('service')
1319
+ * let entities = m.childrenOf (service)
1320
+ * ```
1321
+ * @param parent - either the parent itself or its fully-qualified name
1322
+ * @param filter - an optional filter to apply before picking a child
1323
+ */
1324
+ childrenOf(parent: any | string, filter?: ((def: any_) => boolean)): Definitions
1325
+
1326
+ /**
1327
+ * Provides convenient access to the model's top-level definitions.
1328
+ * For example, you can use it in an es6-import-like fashion to avoid
1329
+ * working with fully-qualified names as follows:
1330
+ *
1331
+ * @example
1332
+ * ```js
1333
+ * let model = cds.reflect (cds.parse(`
1334
+ * namespace our.lovely.bookshop;
1335
+ * entity Books {...}
1336
+ * entity Authors {...}
1337
+ * `))
1338
+ * const {Books,Authors} = model.exports
1339
+ * SELECT.from (Books) .where ({ID:11})
1340
+ * ```
1341
+ */
1342
+ exports: IterableMap<any_>
1343
+ definitions: IterableMap<any_>
1344
+ entities: ModelPart<entity>
1345
+ services: ModelPart<service_>
1346
+
1279
1347
  }
1280
1348
 
1281
1349
  /**
@@ -1426,7 +1494,7 @@ declare class Logger {
1426
1494
 
1427
1495
  declare type LogLevel = keyof typeof levels | Lowercase<keyof typeof levels> | levels
1428
1496
 
1429
- export declare type ManagedAssociation = Association & {
1497
+ declare type ManagedAssociation = Association & {
1430
1498
  foreignKeys: Definitions<type>,
1431
1499
  keys: Column[],
1432
1500
  }
@@ -1459,7 +1527,7 @@ export declare const middlewares: {
1459
1527
  * s2.bar // error :)
1460
1528
  * ```
1461
1529
  */
1462
- export declare type MixedIn<T> = T & { [key: string | number | symbol]: unknown }
1530
+ declare type MixedIn<T> = T & { [key: string | number | symbol]: unknown }
1463
1531
 
1464
1532
  /**
1465
1533
  * Using this will require you to explicitly cast all classes you added mixins to
@@ -1467,16 +1535,16 @@ export declare type MixedIn<T> = T & { [key: string | number | symbol]: unknown
1467
1535
  * properties, you can use the {@link MixedIn} type.
1468
1536
  * @see [capire](https://cap.cloud.sap/docs/node.js/cds-reflect#mixin)
1469
1537
  */
1470
- export declare function mixin (...classes: (new () => any)[]): void
1538
+ declare function mixin (...classes: (new () => any)[]): void
1471
1539
 
1472
1540
  /**
1473
1541
  * The effective CDS model loaded during bootstrapping, which contains all service and entity definitions,
1474
1542
  * including required services.
1475
1543
  * Should only be ever set explictly in test scenarios!
1476
1544
  */
1477
- export declare let model: linked_2.CSN | undefined;
1545
+ export declare let model: linked_2.LinkedCSN | undefined;
1478
1546
 
1479
- export declare type ModelPart<T extends any_> = IterableMap<T> & ((namespace: string) => IterableMap<T>)
1547
+ declare type ModelPart<T extends any_> = IterableMap<T> & ((namespace: string) => IterableMap<T>)
1480
1548
 
1481
1549
  declare namespace models {
1482
1550
  export {
@@ -1498,6 +1566,37 @@ declare namespace models {
1498
1566
  model,
1499
1567
  parse,
1500
1568
  linked,
1569
+ __type,
1570
+ __aspect,
1571
+ __any_,
1572
+ __scalar,
1573
+ __Boolean,
1574
+ __UUID,
1575
+ __String,
1576
+ __LargeString,
1577
+ __Binary,
1578
+ __LargeBinary,
1579
+ __Vector,
1580
+ __Integer,
1581
+ __UInt8,
1582
+ __Int16,
1583
+ __Int32,
1584
+ __Int64,
1585
+ __Float,
1586
+ __Double,
1587
+ __Decimal,
1588
+ __date,
1589
+ __Date,
1590
+ __Time,
1591
+ __DateTime,
1592
+ __TimeStamp,
1593
+ __array,
1594
+ __struct,
1595
+ __context_,
1596
+ __service,
1597
+ __entity,
1598
+ __Association,
1599
+ __Composition,
1501
1600
  compile
1502
1601
  }
1503
1602
  }
@@ -1505,7 +1604,7 @@ declare namespace models {
1505
1604
  /** @private */
1506
1605
  export declare type name = string
1507
1606
 
1508
- export declare const number: typeof number_;
1607
+ declare const number: typeof number_;
1509
1608
 
1510
1609
  declare class number_ extends scalar { }
1511
1610
 
@@ -1521,7 +1620,7 @@ export declare type _odata_options = {
1521
1620
  */
1522
1621
  // FIXME: this is actually supposed to be part of models.d.ts
1523
1622
  // but had to be moved here so export * would not clash their definitions
1524
- export declare function on (event: 'loaded', listener: (model: CSN_2) => void): _cds
1623
+ export declare function on (event: 'loaded', listener: (model: CSN) => void): _cds
1525
1624
 
1526
1625
  /**
1527
1626
  * Emitted whenever a specific service is connected for the first time.
@@ -1638,7 +1737,7 @@ declare type Projection<T> = (e: QLExtensions<T extends ArrayConstructable ? Sin
1638
1737
  * @alpha
1639
1738
  * related to .protocols getters
1640
1739
  */
1641
- export declare type Protocol = 'odata' | 'rest'
1740
+ declare type Protocol = 'odata' | 'rest'
1642
1741
 
1643
1742
  declare class QL<T> {
1644
1743
 
@@ -1724,7 +1823,7 @@ declare type Query_2 = CQN.Query
1724
1823
 
1725
1824
  export declare class QueryAPI {
1726
1825
 
1727
- entities: linked_2.CSN['entities']
1826
+ entities: linked_2.LinkedCSN['entities']
1728
1827
 
1729
1828
  /**
1730
1829
  * @see [docs](https://cap.cloud.sap/docs/node.js/core-services#crud-style-api)
@@ -1819,7 +1918,7 @@ export declare type ref = { ref: (name & { id?: string, where?: expr, args?: exp
1819
1918
  * Turns the given plain CSN model into a reflected model
1820
1919
  * @see [capire](https://cap.cloud.sap/docs/node.js/cds-reflect)
1821
1920
  */
1822
- export declare function reflect (model: csn.CSN): linked_2.CSN
1921
+ export declare function reflect (model: csn.CSN): linked_2.LinkedCSN
1823
1922
 
1824
1923
  export declare class RemoteService extends Service {}
1825
1924
 
@@ -1834,7 +1933,7 @@ declare class Request_2 extends Event_2 {
1834
1933
 
1835
1934
  path: string
1836
1935
 
1837
- target: Definition
1936
+ target: Definition_2
1838
1937
 
1839
1938
  /**
1840
1939
  * Shortcut to {@link Request.target | target (entity) name}
@@ -1914,7 +2013,7 @@ export declare const root: string;
1914
2013
 
1915
2014
  export declare const run: Service['run'];
1916
2015
 
1917
- export declare class scalar extends type { }
2016
+ declare class scalar extends type { }
1918
2017
 
1919
2018
  declare type Scalarise<A> = A extends Array<infer N> ? N : A
1920
2019
 
@@ -2092,31 +2191,31 @@ export declare class Service extends QueryAPI {
2092
2191
  * The model from which the service's definition was loaded
2093
2192
  * @see [capire docs](https://cap.cloud.sap/docs/node.js/core-services)
2094
2193
  */
2095
- model: linked_2.CSN
2194
+ model: linked_2.LinkedCSN
2096
2195
 
2097
2196
  /**
2098
2197
  * Provides access to the entities exposed by a service
2099
2198
  * @see [capire docs](https://cap.cloud.sap/docs/node.js/core-services)
2100
2199
  */
2101
- entities: linked_2.ModelPart<linked_2.entity>
2200
+ entities: linked_2.ModelPart<linked_2.classes.entity>
2102
2201
 
2103
2202
  /**
2104
2203
  * Provides access to the events declared by a service
2105
2204
  * @see [capire docs](https://cap.cloud.sap/docs/node.js/core-services)
2106
2205
  */
2107
- events: linked_2.ModelPart<linked_2.event>
2206
+ events: linked_2.ModelPart<linked_2.classes.event>
2108
2207
 
2109
2208
  /**
2110
2209
  * Provides access to the types exposed by a service
2111
2210
  * @see [capire docs](https://cap.cloud.sap/docs/node.js/core-services)
2112
2211
  */
2113
- types: linked_2.ModelPart<linked_2.type>
2212
+ types: linked_2.ModelPart<linked_2.classes.type>
2114
2213
 
2115
2214
  /**
2116
2215
  * Provides access to the operations, i.e. actions and functions, exposed by a service
2117
2216
  * @see [capire docs](https://cap.cloud.sap/docs/node.js/core-services)
2118
2217
  */
2119
- operations: linked_2.ModelPart<linked_2.action>
2218
+ operations: linked_2.ModelPart<linked_2.classes.action>
2120
2219
 
2121
2220
  /**
2122
2221
  * Acts like a parameter-less constructor. Ensure to call `await super.init()` to have the base class’s handlers added.
@@ -2246,9 +2345,9 @@ export declare type service = {
2246
2345
  /**
2247
2346
  * @see [capire](https://cap.cloud.sap/docs/node.js/cds-reflect#cds-service)
2248
2347
  */
2249
- export declare interface service_ extends csn.service {}
2348
+ declare interface service_ extends csn.service {}
2250
2349
 
2251
- export declare class service_ extends context_ {
2350
+ declare class service_ extends context_ {
2252
2351
  is_service: true
2253
2352
  get entities (): Definitions<entity>
2254
2353
  get types (): Definitions<type>
@@ -2325,12 +2424,11 @@ declare type StaticSELECT<T> = typeof SELECT_3
2325
2424
 
2326
2425
  export declare const stream: Service['stream'];
2327
2426
 
2328
- export declare const string: typeof string_;
2427
+ declare const string: typeof string_;
2329
2428
 
2330
2429
  declare class string_ extends scalar { }
2331
2430
 
2332
2431
  declare class String_2 extends string { }
2333
- export { String_2 as String }
2334
2432
 
2335
2433
  /**
2336
2434
  * @see [capire](https://cap.cloud.sap/docs/node.js/cds-reflect#cds-struct)
@@ -2405,7 +2503,7 @@ declare type TaggedTemplateQueryPart<T> = (strings: TemplateStringsArray, ...par
2405
2503
  /**
2406
2504
  * Target for any QL operation
2407
2505
  */
2408
- declare type Target = linked_2.entity | Definition_2 | string
2506
+ declare type Target = linked_2.classes.entity | Definition | string
2409
2507
 
2410
2508
  declare class Test extends Axios {
2411
2509
 
@@ -2463,9 +2561,9 @@ export declare const test: {
2463
2561
  in (dirname: string): Test,
2464
2562
  };
2465
2563
 
2466
- export declare class Time extends date { }
2564
+ declare class Time extends date { }
2467
2565
 
2468
- export declare class TimeStamp extends DateTime { }
2566
+ declare class TimeStamp extends DateTime { }
2469
2567
 
2470
2568
  /**
2471
2569
  * DO NOT USE
@@ -2510,10 +2608,10 @@ export declare namespace types {
2510
2608
  | 'NEW' | 'EDIT' | 'PATCH' | 'SAVE'
2511
2609
  | 'GET' | 'PUT' | 'POST' | 'PATCH' | 'DELETE'
2512
2610
  | 'COMMIT' | 'ROLLBACK'
2513
- export type target = string | linked_2.Definition | linked_2.entity | (string | linked_2.Definition | linked_2.entity)[] | ArrayConstructable
2611
+ export type target = string | linked_2.Definition | linked_2.classes.entity | (string | linked_2.Definition | linked_2.classes.entity)[] | ArrayConstructable
2514
2612
  }
2515
2613
 
2516
- export declare class UInt8 extends Integer { }
2614
+ declare class UInt8 extends Integer { }
2517
2615
 
2518
2616
  export declare const unboxed: (service: Service) => Service;
2519
2617
 
@@ -2721,18 +2819,18 @@ export declare const utils: {
2721
2819
  rm: (...path: string[]) => Promise<ReturnType<typeof fs.promises.rm>>,
2722
2820
  };
2723
2821
 
2724
- export declare class UUID extends string { }
2822
+ declare class UUID extends string { }
2725
2823
 
2726
2824
  /** @private */
2727
2825
  export declare type val = { val: any }
2728
2826
 
2729
- export declare class Vector extends Binary { }
2827
+ declare class Vector extends Binary { }
2730
2828
 
2731
2829
  export declare const version: string;
2732
2830
 
2733
2831
  declare type Visitor = (def: any_, name: string, parent: any_, defs: Definitions) => void
2734
2832
 
2735
- export declare interface WithElements {
2833
+ declare interface WithElements {
2736
2834
  elements: Definitions<type>
2737
2835
  }
2738
2836
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cap-js/cds-types",
3
- "version": "0.4.0",
3
+ "version": "0.5.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/",
@@ -19,6 +19,7 @@
19
19
  ],
20
20
  "scripts": {
21
21
  "test": "jest --silent",
22
+ "test:rollup": "npm run rollup; npm run rollup:on; npm run test; npm run rollup:off",
22
23
  "rollup": "rm -rf dist/ && mkdir -p etc/ && npx -y @microsoft/api-extractor run --local --verbose && .github/rollup-patch.js",
23
24
  "rollup:on": "npm pkg set typings=dist/cds-types.d.ts && [ -d 'apis' ] && mv -- apis -apis || true",
24
25
  "rollup:off": "npm pkg set typings=apis/cds.d.ts && [ -d '-apis' ] && mv -- -apis apis || true",