@cap-js/cds-types 0.2.0 → 0.4.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.
@@ -0,0 +1,2778 @@
1
+ import { Application } from 'express';
2
+ import { AxiosInstance } from 'axios';
3
+ import chai from 'chai';
4
+ import * as express from 'express';
5
+ import * as fs from 'node:fs';
6
+ import * as http from 'http';
7
+ import { ReadableStream } from 'node:stream/web';
8
+ import { RequestHandler } from 'express';
9
+
10
+ export declare class action extends any_<'action' | 'function'> {}
11
+
12
+ export declare interface ActionEventHandler<P, R> {
13
+ (req: Omit<Request_2, 'data'> & { data: P }, next: Function): Promise<R> | R
14
+ }
15
+
16
+ export declare const any: typeof any_;
17
+
18
+ export declare interface any_ extends csn.any_ {}
19
+
20
+ export declare class any_<K extends kinds = kinds> {
21
+ private _: K // break covariance
22
+ constructor (...aspects: any[])
23
+
24
+ readonly name: string
25
+ // parked, might be deprecated
26
+ // is (kind: kinds | 'Association' | 'Composition'): boolean
27
+ }
28
+
29
+ declare interface any__2 {
30
+ kind?: kinds
31
+ }
32
+
33
+ export declare class ApplicationService extends Service {}
34
+
35
+ export declare class array extends type<'type' | 'elements'> { }
36
+
37
+ declare interface ArrayConstructable<T = any> {
38
+ new(...args: any[]): T[]
39
+ }
40
+
41
+ /**
42
+ * A subset of array-like methods, but not `ArrayLike`, as it does not expose `.length`.
43
+ * @see [capire](https://cap.cloud.sap/docs/node.js/cds-reflect#iterable)
44
+ * @internal
45
+ * @since cds 7.9
46
+ */
47
+ declare type _ArrayLike<T> = Iterable<T> & {
48
+ forEach: (handler: (element: T) => any) => void,
49
+ filter: (predicate: (element: T) => boolean) => Array<T>,
50
+ map: <R>(converter: (element: T) => R) => Array<R>,
51
+ some: (predicate: (element: T) => boolean) => boolean,
52
+ find: (predicate: (element: T) => boolean) => T | undefined,
53
+ }
54
+
55
+ export declare class aspect<K extends kinds = 'aspect'> extends type<K> implements WithElements {
56
+ elements: Definitions<type<'type'>>
57
+ }
58
+
59
+ /**
60
+ * @see [capire](https://cap.cloud.sap/docs/node.js/cds-reflect#cds-association)
61
+ */
62
+ export declare interface Association extends Omit<csn.Association, 'type' | 'items'> {}
63
+
64
+ export declare class Association extends type {
65
+ _target: entity
66
+
67
+ isAssociation: true
68
+
69
+ is2one: boolean
70
+
71
+ is2many: boolean
72
+
73
+ }
74
+
75
+ declare interface Association_2 extends type_2 {
76
+ type: 'cds.Association' | 'cds.Composition'
77
+ target: FQN
78
+
79
+ /**
80
+ * The specified cardinality. to-one = `{max:1}`, to-many = `{max:'*'}`
81
+ */
82
+ cardinality?: { src?: 1, min?: 1 | 0, max?: 1 | '*' }
83
+
84
+ /**
85
+ * The parsed on condition in case of unmanaged Associations
86
+ */
87
+ on?: predicate
88
+
89
+ /**
90
+ * The optionally specified keys in case of managed Associations
91
+ */
92
+ keys?: (ref & { as: string })[]
93
+ }
94
+
95
+ declare type Awaitable<T, I> = T & Promise<I>
96
+
97
+ declare class Axios {
98
+
99
+ get axios (): AxiosInstance
100
+ get: AxiosInstance['get'];
101
+
102
+ put: AxiosInstance['put']
103
+
104
+ post: AxiosInstance['post']
105
+
106
+ patch: AxiosInstance['patch']
107
+
108
+ delete: AxiosInstance['delete']
109
+
110
+ options: AxiosInstance['options']
111
+
112
+ get GET (): Axios['get']
113
+
114
+ get PUT (): Axios['put']
115
+
116
+ get POST (): Axios['post']
117
+
118
+ get PATCH (): Axios['patch']
119
+
120
+ get DELETE (): Axios['delete']
121
+
122
+ get OPTIONS (): Axios['options']
123
+
124
+ }
125
+
126
+ export declare class Binary extends string { }
127
+
128
+ export declare const boolean: typeof boolean_;
129
+
130
+ declare class boolean_ extends scalar { }
131
+
132
+ declare class Boolean_2 extends boolean { }
133
+ export { Boolean_2 as Boolean }
134
+
135
+ export declare const builtin: {
136
+
137
+ /**
138
+ * @see {@link models.linked.classes}
139
+ */
140
+ classes: typeof models.linked.classes,
141
+ types: Record<string, object>, // FIXME: value should be any class part of linked.classes
142
+ };
143
+
144
+ export declare type CDL = string
145
+
146
+ declare namespace cds {
147
+ export {
148
+ log,
149
+ debug,
150
+ test,
151
+ ql,
152
+ QLExtensions,
153
+ csn,
154
+ delete_ as delete,
155
+ version,
156
+ home,
157
+ root,
158
+ requires,
159
+ extend,
160
+ lazify,
161
+ lazified,
162
+ entity,
163
+ event,
164
+ type,
165
+ array,
166
+ struct,
167
+ Association,
168
+ Composition,
169
+ builtin,
170
+ on,
171
+ once,
172
+ exit,
173
+ _cds,
174
+ cds_services,
175
+ connect,
176
+ server,
177
+ serve,
178
+ services,
179
+ service,
180
+ cds_serve_fluent,
181
+ cds_connect_options,
182
+ Middleswares,
183
+ middlewares,
184
+ env,
185
+ _TODO,
186
+ get,
187
+ load,
188
+ resolve,
189
+ reflect,
190
+ _flavor,
191
+ _odata_options,
192
+ _options,
193
+ JSON_2 as JSON,
194
+ YAML,
195
+ CDL,
196
+ SQL,
197
+ XML,
198
+ EDM,
199
+ EDMX,
200
+ filename,
201
+ model,
202
+ parse,
203
+ linked,
204
+ compile,
205
+ spawn,
206
+ Key,
207
+ QueryAPI,
208
+ Service,
209
+ ApplicationService,
210
+ MessagingService,
211
+ RemoteService,
212
+ DatabaseService,
213
+ Transaction,
214
+ ResultSet,
215
+ ServiceImpl,
216
+ EventHandler,
217
+ OnEventHandler,
218
+ OnErrorHandler,
219
+ Partial_2 as Partial,
220
+ OneOrMany,
221
+ CdsFunction,
222
+ TypedRequest,
223
+ CRUDEventHandler,
224
+ ActionEventHandler,
225
+ ResultsHandler,
226
+ SpawnEvents,
227
+ SpawnEventEmitter,
228
+ types,
229
+ SpawnOptions,
230
+ context,
231
+ tx,
232
+ entities,
233
+ run,
234
+ foreach,
235
+ stream,
236
+ read,
237
+ create,
238
+ insert,
239
+ update,
240
+ transaction,
241
+ db,
242
+ outboxed,
243
+ unboxed,
244
+ EventContext,
245
+ Event_2 as Event,
246
+ Request_2 as Request,
247
+ User,
248
+ Privileged,
249
+ utils,
250
+ Query,
251
+ SELECT_2 as SELECT,
252
+ INSERT_2 as INSERT,
253
+ UPSERT_2 as UPSERT,
254
+ UPDATE_2 as UPDATE,
255
+ DELETE_2 as DELETE,
256
+ CREATE_2 as CREATE,
257
+ DROP_2 as DROP,
258
+ primitive,
259
+ data,
260
+ name,
261
+ source,
262
+ column_expr,
263
+ predicate,
264
+ ordering_term,
265
+ expr,
266
+ ref,
267
+ val,
268
+ xpr,
269
+ _xpr,
270
+ operator,
271
+ function_call,
272
+ enum_literal,
273
+ expr_literal,
274
+ ModelPart,
275
+ Definition,
276
+ CSN,
277
+ mixin,
278
+ Protocol,
279
+ Column,
280
+ Definitions,
281
+ WithElements,
282
+ any_,
283
+ any,
284
+ aspect,
285
+ scalar,
286
+ boolean,
287
+ Boolean_2 as Boolean,
288
+ string,
289
+ UUID,
290
+ String_2 as String,
291
+ LargeString,
292
+ Binary,
293
+ LargeBinary,
294
+ Vector,
295
+ number,
296
+ Integer,
297
+ UInt8,
298
+ Int16,
299
+ Int32,
300
+ Int64,
301
+ Float,
302
+ Double,
303
+ Decimal,
304
+ date,
305
+ Date_2 as Date,
306
+ Time,
307
+ DateTime,
308
+ TimeStamp,
309
+ context_,
310
+ service_,
311
+ action,
312
+ ManagedAssociation,
313
+ MixedIn
314
+ }
315
+ }
316
+
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 }
347
+
348
+ export declare type column_expr = UnionToIntersection<expr> & { as?: name, cast?: any, expand?: column_expr[], inline?: column_expr[] }
349
+
350
+ /**
351
+ * Provides a set of methods to parse a given model, query or expression.
352
+ * You can also use `cds.compile(csn).to('<output>')` as a fluent variant.
353
+ */
354
+ export declare const compile: {
355
+
356
+ /** Shortcut for `cds.compile.to.csn()` */
357
+ cdl (model: CDL, o?: _options): csn.CSN,
358
+
359
+ for: {
360
+ odata (model: csn.CSN, o?: _options): csn.CSN,
361
+ sql (model: csn.CSN, o?: _options): csn.CSN,
362
+ },
363
+ to: {
364
+ parsed: {
365
+ csn (files: filename[], o?: _options): Promise<csn.CSN>,
366
+ csn (model: CDL, o?: _options): csn.CSN,
367
+ },
368
+ xtended: {
369
+ csn (files: filename[], o?: _options): Promise<csn.CSN>,
370
+ csn (model: CDL, o?: _options): csn.CSN,
371
+ },
372
+ inferred: {
373
+ csn (files: filename[], o?: _options): Promise<csn.CSN>,
374
+ csn (model: CDL, o?: _options): csn.CSN,
375
+ },
376
+ csn (files: filename[], o?: _options): Promise<csn.CSN>,
377
+ csn (model: CDL, o?: _options): csn.CSN,
378
+ yml (model: csn.CSN, o?: _options): YAML,
379
+ yaml (model: csn.CSN, o?: _options): YAML,
380
+ json (model: csn.CSN, o?: _options): JSON_2,
381
+ sql (model: csn.CSN, o?: _options): SQL[],
382
+ cdl (model: csn.CSN, o?: _options): CDL | Iterable<[CDL, { file: filename }]>,
383
+ edm (model: csn.CSN, o?: _options | _odata_options): EDM | string,
384
+ edmx (model: csn.CSN, o?: _options | _odata_options): EDMX | Iterable<[EDMX, { file: filename }]>,
385
+ hdbcds (model: csn.CSN, o?: _options): SQL | Iterable<[SQL, { file: filename }]>,
386
+ hdbtable (model: csn.CSN, o?: _options): SQL | Iterable<[SQL, { file: filename }]>,
387
+ },
388
+
389
+ /** Fluent API variant */
390
+ (model: csn.CSN | CDL): {
391
+ for: {
392
+ odata (o?: _options): csn.CSN,
393
+ sql (o?: _options): csn.CSN,
394
+ },
395
+ to: {
396
+ parsed: { csn (o?: _options): csn.CSN },
397
+ xtended: { csn (o?: _options): csn.CSN },
398
+ inferred: { csn (o?: _options): csn.CSN },
399
+ csn (o?: _options): csn.CSN,
400
+ yml (o?: _options): YAML,
401
+ yaml (o?: _options): YAML,
402
+ json (o?: _options): JSON_2,
403
+ sql (o?: _options): SQL[],
404
+ cdl (o?: _options): CDL | Iterable<[CDL, { file: filename }]>,
405
+ edm (o?: _options | _odata_options): EDM | string,
406
+ edmx (o?: _options | _odata_options): EDMX | Iterable<[EDMX, { file: filename }]>,
407
+ hdbcds (o?: _options): SQL | Iterable<[SQL, { file: filename }]>,
408
+ hdbtable (o?: _options): SQL | Iterable<[SQL, { file: filename }]>,
409
+ },
410
+ },
411
+
412
+ /** Async fluent variant reading from files */
413
+ (files: filename[]): {
414
+ for: {
415
+ odata (o?: _options): Promise<csn.CSN>,
416
+ sql (o?: _options): Promise<csn.CSN>,
417
+ },
418
+ to: {
419
+ parsed: { csn (o?: _options): Promise <csn.CSN> },
420
+ xtended: { csn (o?: _options): Promise <csn.CSN> },
421
+ inferred: { csn (o?: _options): Promise <csn.CSN> },
422
+ csn (o?: _options): Promise <csn.CSN>,
423
+ yml (o?: _options): Promise <YAML>,
424
+ yaml (o?: _options): Promise <YAML>,
425
+ json (o?: _options): Promise <JSON_2>,
426
+ sql (o?: _options): Promise <SQL[]>,
427
+ cdl (o?: _options): Promise <CDL | Iterable<[CDL, { file: filename }]>>,
428
+ edm (o?: _options | _odata_options): Promise <EDM | string>,
429
+ edmx (o?: _options | _odata_options): Promise <EDMX | Iterable<[EDMX, { file: filename }]>>,
430
+ hdbcds (o?: _options): Promise <SQL | Iterable<[SQL, { file: filename }]>>,
431
+ hdbtable (o?: _options): Promise <SQL | Iterable<[SQL, { file: filename }]>>,
432
+ },
433
+ },
434
+ };
435
+
436
+ export declare class Composition extends Association {
437
+ isComposition: true
438
+ }
439
+
440
+ export declare const connect: {
441
+
442
+ /**
443
+ * Connects to a specific datasource.
444
+ * @see [capire](https://cap.cloud.sap/docs/node.js/cds-connect#cds-connect-to)
445
+ */
446
+ to(datasource: string, options?: cds_connect_options): Promise<Service>,
447
+
448
+ /**
449
+ * Connects to a specific datasource via options.
450
+ * @see [capire](https://cap.cloud.sap/docs/node.js/cds-connect#cds-connect-to)
451
+ */
452
+ to(options: cds_connect_options): Promise<Service>,
453
+
454
+ /**
455
+ * Connects the primary datasource.
456
+ * @see [capire](https://cap.cloud.sap/docs/node.js/cds-connect)
457
+ */
458
+ // API extractor cannot handle the direct usages of the cds namespace in typeof cds, so add an indirection.
459
+ (options?: string | cds_connect_options): Promise<_cds>, // > cds.connect(<options>)
460
+ };
461
+
462
+ declare interface Constructable<T = any> {
463
+ new(...args: any[]): T
464
+ }
465
+
466
+ declare class ConstructedQuery {
467
+
468
+ then (_resolved: (x: any) => any, _rejected: (e: Error) => any): any
469
+
470
+ }
471
+
472
+ /**
473
+ * @see [docs](https://cap.cloud.sap/docs/node.js/cds-tx#event-contexts
474
+ */
475
+ export declare let context: EventContext | undefined;
476
+
477
+ export declare interface context_ extends csn.context {}
478
+
479
+ export declare class context_ extends any_ { }
480
+
481
+ declare interface context_2 extends any__2 { }
482
+
483
+ declare namespace CQN {
484
+ export {
485
+ Query,
486
+ SELECT_2 as SELECT,
487
+ INSERT_2 as INSERT,
488
+ UPSERT_2 as UPSERT,
489
+ UPDATE_2 as UPDATE,
490
+ DELETE_2 as DELETE,
491
+ CREATE_2 as CREATE,
492
+ DROP_2 as DROP,
493
+ primitive,
494
+ data,
495
+ name,
496
+ source,
497
+ column_expr,
498
+ predicate,
499
+ ordering_term,
500
+ expr,
501
+ ref,
502
+ val,
503
+ xpr,
504
+ _xpr,
505
+ operator,
506
+ function_call,
507
+ enum_literal,
508
+ expr_literal
509
+ }
510
+ }
511
+
512
+ export declare const create: Service['create'];
513
+
514
+ declare type CREATE_2 = { CREATE: {
515
+ entity: entity_2 | name,
516
+ as: SELECT_2,
517
+ }, }
518
+ export { CREATE_2 as CREATE }
519
+
520
+ declare class CREATE_3<T> extends ConstructedQuery {
521
+
522
+ static entity (entity: Target): CREATE_3<any>
523
+
524
+ CREATE: CQN.CREATE['CREATE']
525
+
526
+ }
527
+
528
+ export declare namespace CRUDEventHandler {
529
+ export type Before<P, R = P | void | Error> = (req: TypedRequest<P>) => Promise<R> | R
530
+ export type On<P, R = P | void | Error> = (req: TypedRequest<P>, next: (...args: any[]) => Promise<R> | R) => Promise<R> | R
531
+ export type After<P, R = P | void | Error> = (data: undefined | P, req: TypedRequest<P>) => Promise<R> | R
532
+ }
533
+
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
+ * A parsed CDS model in CSN object notation.
636
+ */
637
+ declare interface CSN_2 {
638
+
639
+ /**
640
+ * The assigned namespace. If parsed from multiple sources,
641
+ * this is the topmost model's namespace, if any, not the
642
+ * ones of imported models.
643
+ */
644
+ namespace?: string
645
+
646
+ /**
647
+ * The list of usings in this parsed model. Not available after
648
+ * imports have been resolved into a merged model.
649
+ */
650
+ requires?: string[]
651
+
652
+ /**
653
+ * All definitions in the model including those from imported models.
654
+ */
655
+ definitions?: Record<FQN, Definition_2>
656
+
657
+ /**
658
+ * All extensions in the model including those from imported models.
659
+ * Not available after extensions have been applied.
660
+ */
661
+ extensions?: Extension[]
662
+
663
+ /**
664
+ * The names of the files from which this model has been loaded.
665
+ */
666
+ $sources?: string[]
667
+ }
668
+
669
+ /** @private */
670
+ export declare type data = Record<string, any>
671
+
672
+ export declare class DatabaseService extends Service {
673
+ deploy (model?: csn.CSN | string): Promise<csn.CSN>
674
+ begin (): Promise<void>
675
+ commit (): Promise<void>
676
+ rollback (): Promise<void>
677
+ }
678
+
679
+ declare class DataUtil {
680
+
681
+ delete (db?: Service): Promise<void>
682
+
683
+ reset (db?: Service): Promise<void>
684
+
685
+ /**
686
+ * @deprecated if needed, call `reset()`, considering test performance
687
+ */
688
+ autoReset (enabled: boolean): this
689
+
690
+ }
691
+
692
+ export declare class date extends scalar { }
693
+
694
+ declare class Date_2 extends date { }
695
+ export { Date_2 as Date }
696
+
697
+ export declare class DateTime extends date { }
698
+
699
+ export declare const db: DatabaseService;
700
+
701
+ /**
702
+ * Shortcut to `cds.log(...).debug`, returning `undefined` if `cds.log(...)._debug` is `false`.
703
+ * Use like this:
704
+ * @example
705
+ * ```js
706
+ * const dbg = cds.debug('foo')
707
+ * ...
708
+ * dbg && dbg('message')
709
+ * ```
710
+ *
711
+ * @param name - logger name
712
+ */
713
+ export declare function debug (name: string): undefined | Log
714
+
715
+ export declare class Decimal extends Float { }
716
+
717
+ export declare type Definition = any_
718
+
719
+ /**
720
+ * Definitions are the central elements of a CDS model.
721
+ */
722
+ declare type Definition_2 = context_2 & service_2 & type_2 & struct_2 & entity_2 & Association_2
723
+
724
+ /**
725
+ * @see [capire](https://cap.cloud.sap/docs/node.js/cds-reflect#iterable)
726
+ */
727
+ export declare type Definitions<T extends any_ = any_> = IterableMap<T>
728
+
729
+ declare const delete_: Service['delete'];
730
+ export { delete_ as delete };
731
+
732
+ declare type DELETE_2 = { DELETE: {
733
+ from: ref | name,
734
+ where?: predicate,
735
+ }, }
736
+ export { DELETE_2 as DELETE }
737
+
738
+ declare class DELETE_3<T> extends ConstructedQuery {
739
+
740
+ static from:
741
+ TaggedTemplateQueryPart<Awaitable<SELECT_3<unknown>, InstanceType<any>>>
742
+ & ((entity: Target | ArrayConstructable, primaryKey?: PK) => DELETE_3<any>)
743
+ & ((subject: ref) => DELETE_3<any>)
744
+
745
+ byKey (primaryKey?: PK): this
746
+
747
+ where (predicate: object): this
748
+
749
+ where (...expr: any[]): this
750
+
751
+ and (predicate: object): this
752
+
753
+ and (...expr: any[]): this
754
+ DELETE: CQN.DELETE['DELETE']
755
+
756
+ }
757
+
758
+ export declare class Double extends Float { }
759
+
760
+ declare type DROP_2 = { DROP: {
761
+ entity: name,
762
+ table: ref,
763
+ view: ref,
764
+ }, }
765
+ export { DROP_2 as DROP }
766
+
767
+ declare class DROP_3<T> extends ConstructedQuery {
768
+
769
+ static entity (entity: Target): DROP_3<any>
770
+
771
+ DROP: CQN.DROP['DROP']
772
+
773
+ }
774
+
775
+ export declare type EDM = { $version: string }
776
+
777
+ export declare type EDMX = XML
778
+
779
+ declare type Element = type_2 & struct_2 & Association_2
780
+
781
+ export declare const entities: Service['entities'];
782
+
783
+ /**
784
+ * @see [capire](https://cap.cloud.sap/docs/node.js/cds-reflect#cds-entity)
785
+ */
786
+ export declare interface entity extends Omit<csn.entity, 'elements' | 'items' | 'keys' | 'drafts'> {}
787
+
788
+ export declare class entity extends struct<'entity'> {
789
+ is_entity: true
790
+
791
+ keys: Definitions<type>
792
+
793
+ associations: Definitions<Association>
794
+
795
+ compositions: Definitions<Composition>
796
+
797
+ actions: Definitions<action>
798
+
799
+ texts?: entity
800
+
801
+ drafts?: entity
802
+ }
803
+
804
+ declare interface entity_2 extends Omit<struct_2, 'elements'> {
805
+
806
+ /**
807
+ * Entities with a query signify a view
808
+ */
809
+ query?: SELECT_2
810
+
811
+ /**
812
+ * Elements of entities may have additional qualifiers
813
+ */
814
+ elements: EntityElements
815
+ // REVISIT: following should move to LinkedCSN
816
+ keys: { [name: string]: Definition_2 }
817
+ drafts?: entity_2
818
+ }
819
+
820
+ declare type EntityElements = {
821
+ [name: string]: Element & {
822
+ key?: boolean,
823
+ virtual?: boolean,
824
+ unique?: boolean,
825
+ notNull?: boolean,
826
+ },
827
+ }
828
+
829
+ export declare type enum_literal = { '#': string }
830
+
831
+ /**
832
+ * Access to the configuration for Node.js runtime and tools.
833
+ * The object is the effective result of configuration merged from various sources,
834
+ * filtered through the currently active profiles, thus highly dependent on the current working
835
+ * directory and process environment.
836
+ */
837
+ export declare const env: {
838
+ build: _TODO,
839
+ hana: _TODO,
840
+ i18n: {
841
+ languages: string[],
842
+ default_language: string,
843
+ folders: string[],
844
+ [key: string]: any,
845
+ },
846
+ requires: env.Requires,
847
+ folders: {
848
+ app: string,
849
+ db: string,
850
+ srv: string,
851
+ fts: string,
852
+ [key: string]: string, // to allow additional values
853
+ },
854
+ odata: _TODO,
855
+ query: _TODO,
856
+ sql: _TODO,
857
+ } & { [key: string]: any };
858
+
859
+ export declare namespace env {
860
+
861
+ export interface MockUser {
862
+ tenant?: string
863
+ roles?: string[]
864
+ features?: string[]
865
+ }
866
+
867
+ export interface MockUsers {
868
+ alice: MockUser
869
+ bob: MockUser
870
+ carol: MockUser
871
+ dave: MockUser
872
+ erin: MockUser
873
+ fred: MockUser
874
+ [key: string]: MockUser | undefined
875
+ }
876
+
877
+ /* eslint-disable-next-line @typescript-eslint/no-unused-vars */
878
+ export type Requires = {
879
+ auth: {
880
+ kind: 'dummy' | 'mocked' | 'basic' | 'xsuaa' | 'ias' | string,
881
+ impl: string,
882
+ users?: MockUsers,
883
+ tenants?: {
884
+ [key: string]: {
885
+ features?: string[],
886
+ },
887
+ },
888
+ credentials?: Credentials,
889
+ binding?: Binding,
890
+ [key: string]: any,
891
+ },
892
+ db: {
893
+ kind: 'hana' | 'sqlite' | 'sql' | string,
894
+ binding?: Binding,
895
+ [key: string]: any,
896
+ },
897
+ multitenancy: boolean | { kind: string, jobs: {
898
+ clusterSize: number,
899
+ workerSize: number,
900
+ t0: string,
901
+ [key: string]: any,
902
+ },},
903
+ toggles: boolean,
904
+ extensibility: boolean | {
905
+ model: string[],
906
+ tenantCheckInterval: number,
907
+ [key: string]: any,
908
+ },
909
+ messaging: {
910
+ kind: 'file-based-messaging' | 'redis-messaging' | 'local-messaging' | 'enterprise-messaging' | 'enterprise-messaging-shared' | string,
911
+ format: 'cloudevents' | string,
912
+ [key: string]: any,
913
+ },
914
+ [key: string]: any,
915
+ }
916
+
917
+ export type Binding = {
918
+ type: 'cf' | 'k8s' | string,
919
+ apiEndpoint?: string,
920
+ org?: string,
921
+ space?: string,
922
+ instance?: string,
923
+ key?: string,
924
+ }
925
+
926
+ export type Credentials = {
927
+ clientid?: string,
928
+ clientsecret?: string,
929
+ url?: string,
930
+ xsappname?: string,
931
+ certurl?: string,
932
+ certificate?: string,
933
+ [key: string]: any,
934
+ }
935
+ }
936
+
937
+ export declare class event extends aspect<'event'> {}
938
+
939
+ /**
940
+ * @see [capire docs](https://cap.cloud.sap/docs/node.js/events)
941
+ */
942
+ declare class Event_2 extends EventContext {
943
+
944
+ event: string
945
+
946
+ data: any
947
+
948
+ headers: any
949
+
950
+ }
951
+ export { Event_2 as Event }
952
+
953
+ /**
954
+ * Represents the invocation context of incoming request and event messages.
955
+ * @see [capire docs](https://cap.cloud.sap/docs/node.js/events)
956
+ */
957
+ export declare class EventContext {
958
+
959
+ constructor (properties: { event: string, data?: object, query?: object, headers?: object })
960
+ http?: { req: express.Request, res: express.Response }
961
+
962
+ tenant: string
963
+
964
+ user: User
965
+
966
+ id: string
967
+
968
+ locale: `${string}_${string}`
969
+
970
+ timestamp: Date
971
+
972
+ features?: { [key: string]: boolean }
973
+
974
+ }
975
+
976
+ export declare interface EventHandler {
977
+ // (msg : types.EventMessage) : Promise<any> | any | void
978
+ (req: Request_2): Promise<any> | any | void
979
+ }
980
+
981
+ /**
982
+ * Provides a graceful shutdown for running servers, by first emitting `cds.emit('shutdown')`.
983
+ * @see [capire](https://cap.cloud.sap/docs/node.js/cds-facade#cds-exit)
984
+ */
985
+ export declare function exit (): void
986
+
987
+ export declare type expr = ref | val | xpr | function_call | SELECT_2
988
+
989
+ export declare type expr_literal = { '=': string }
990
+
991
+ /**
992
+ * Add aspects to a given object, for example:
993
+ *
994
+ * @example
995
+ * ```js
996
+ * extend (Object.prototype) .with (class {
997
+ * get foo() { return ... }
998
+ * bar() {...}
999
+ * }.prototype)
1000
+ * ```
1001
+ */
1002
+ export declare function extend<T> (target: T): {
1003
+ with<E extends readonly any[]>(...ext: E): T & Intersect<E>,
1004
+ }
1005
+
1006
+ /**
1007
+ * Extensions capture `extend Foo with { ... }` directives.
1008
+ */
1009
+ declare type Extension = {
1010
+ extend: FQN,
1011
+ elements?: { [name: string]: Element },
1012
+ includes?: FQN[],
1013
+ }
1014
+
1015
+ export declare type filename = string
1016
+
1017
+ declare type Filter = string | (<T extends any_ = any_>(def: T) => boolean)
1018
+
1019
+ export declare type _flavor = 'parsed' | 'xtended' | 'inferred'
1020
+
1021
+ export declare class Float extends number { }
1022
+
1023
+ export declare const foreach: Service['foreach'];
1024
+
1025
+ declare type Formatter = {
1026
+
1027
+ /**
1028
+ * Custom format function
1029
+ *
1030
+ * @param module - logger name
1031
+ * @param level - log level
1032
+ * @param args - additional arguments
1033
+ * @returns an array of arguments, which are passed to the logger (for example, `console.log()`)
1034
+ */
1035
+ (module: string, level: number, args: any[]): any[],
1036
+ }
1037
+
1038
+ /**
1039
+ * The fully-quality name of a definition.
1040
+ */
1041
+ declare type FQN = string
1042
+
1043
+ /** @private */
1044
+ export declare type function_call = { func: string, args: { [key: string]: any }[] }
1045
+
1046
+ /**
1047
+ * Loads and parses models from the specified files.
1048
+ * Uses `cds.resolve` to fetch the respective models.
1049
+ * Essentially a shortcut for `cds.compile.to.csn(files)`
1050
+ * @param files - filenames of models or if folder containing models
1051
+ */
1052
+ export declare function get (files: '*' | filename | filename[], o?: _options): Promise<csn.CSN>
1053
+
1054
+ export declare const home: string;
1055
+
1056
+ export declare const insert: Service['insert'];
1057
+
1058
+ declare type INSERT_2 = { INSERT: {
1059
+ into: ref | name,
1060
+ entries: data[],
1061
+ columns: string[],
1062
+ values: primitive[],
1063
+ rows: primitive[][],
1064
+ as: SELECT_2,
1065
+ }, }
1066
+ export { INSERT_2 as INSERT }
1067
+
1068
+ declare class INSERT_3<T> extends ConstructedQuery {
1069
+
1070
+ static into: (<T extends ArrayConstructable<any>> (entity: T, entries?: object | object[]) => INSERT_3<SingularType<T>>)
1071
+ & (TaggedTemplateQueryPart<INSERT_3<unknown>>)
1072
+ & ((entity: Target, entries?: object | object[]) => INSERT_3<any>)
1073
+ & (<T> (entity: Constructable<T>, entries?: object | object[]) => INSERT_3<T>)
1074
+ & (<T> (entity: T, entries?: T | object | object[]) => INSERT_3<T>)
1075
+
1076
+ into: (<T extends ArrayConstructable> (entity: T) => this)
1077
+ & TaggedTemplateQueryPart<this>
1078
+ & ((entity: Target) => this)
1079
+
1080
+ data (block: (e: T) => void): this
1081
+
1082
+ entries (...entries: object[]): this
1083
+
1084
+ columns (...col: (T extends ArrayConstructable<any> ? keyof SingularType<T> : keyof T)[]): this
1085
+
1086
+ columns (...col: string[]): this
1087
+
1088
+ values (...val: any[]): this
1089
+
1090
+ rows (...row: any[]): this
1091
+
1092
+ as (select: SELECT_3<T>): this
1093
+ INSERT: CQN.INSERT['INSERT']
1094
+
1095
+ }
1096
+
1097
+ export declare class Int16 extends Integer { }
1098
+
1099
+ export declare class Int32 extends Integer { }
1100
+
1101
+ export declare class Int64 extends Integer { }
1102
+
1103
+ export declare class Integer extends number { }
1104
+
1105
+ declare type Intersect<T extends readonly unknown[]> = T extends [infer Head, ...infer Tail]
1106
+ ? Head & Intersect<Tail>
1107
+ : unknown
1108
+
1109
+ /**
1110
+ * Object structure that exposes both array-like and object-like behaviour.
1111
+ * @see [capire](https://cap.cloud.sap/docs/node.js/cds-reflect#iterable)
1112
+ */
1113
+ declare type IterableMap<T> = { [name: string]: T } & _ArrayLike<T>
1114
+
1115
+ declare type JSON_2 = string
1116
+ export { JSON_2 as JSON }
1117
+
1118
+ export declare type Key = number | string | any
1119
+
1120
+ declare type kinds = 'aspect' | 'entity' | 'type' | 'event' | 'action' | 'function' | 'service' | 'context' | 'elements'
1121
+
1122
+ export declare class LargeBinary extends Binary { }
1123
+
1124
+ export declare class LargeString extends String_2 { }
1125
+
1126
+ /**
1127
+ * Prepare a node module for lazy-loading submodules instead
1128
+ * of static requires. Example:
1129
+ *
1130
+ * @example
1131
+ * ```js
1132
+ * require = lazify (module) //> turns require into a lazy one
1133
+ * const facade = module.exports = {
1134
+ * sub: require ('./sub-module')
1135
+ * })
1136
+ * ```
1137
+ *
1138
+ * The first usage of `facade.sub` will load the sub module
1139
+ * using standard Node.js's `module.require` functions.
1140
+ */
1141
+ export declare function lazified<T> (target: T): T
1142
+
1143
+ /**
1144
+ * Equip a given facade object with getters for lazy-loading modules instead
1145
+ * of static requires. Example:
1146
+ *
1147
+ * @example
1148
+ * ```js
1149
+ * const facade = lazify ({
1150
+ * sub: lazy => require ('./sub-module')
1151
+ * })
1152
+ * ```
1153
+ *
1154
+ * The first usage of `facade.sub` will load the sub module
1155
+ * using standard Node.js's `module.require` functions.
1156
+ */
1157
+ export declare function lazify<T> (target: T): T
1158
+
1159
+ declare enum levels {
1160
+ // SILLY and VERBOSE are aliases for TRACE
1161
+ /* eslint-disable-next-line @typescript-eslint/no-duplicate-enum-values */
1162
+ SILENT = 0, ERROR = 1, WARN = 2, INFO = 3, DEBUG = 4, TRACE = 5, SILLY = 5, VERBOSE = 5
1163
+ }
1164
+
1165
+ export declare const linked: {
1166
+
1167
+ /**
1168
+ * Turns the given plain CSN model into a linked model
1169
+ * @see [capire](https://cap.cloud.sap/docs/node.js/cds-reflect)
1170
+ */
1171
+ (model: csn.CSN): linked_2.CSN,
1172
+
1173
+ /**
1174
+ * Base classes of linked definitions from reflected models.
1175
+ * @see [capire](https://cap.cloud.sap/docs/node.js/cds-reflect#cds-builtin-classes)
1176
+ */
1177
+ classes: typeof LinkedClasses,
1178
+ };
1179
+
1180
+ declare namespace linked_2 {
1181
+ export {
1182
+ 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
1229
+ }
1230
+ }
1231
+
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
+ }
1279
+ }
1280
+
1281
+ /**
1282
+ * Shortcut for `cds.get(files, 'inferred')`
1283
+ * @param files - filenames of models or if folder containing models
1284
+ */
1285
+ export declare function load (files: '*' | filename | filename[], o?: _options): Promise<csn.CSN>
1286
+
1287
+ declare type Log = {
1288
+
1289
+ /**
1290
+ * Logs a message
1291
+ *
1292
+ * @param message - text to log
1293
+ * @param optionalParams - additional parameters, same as in `console.log(text, param1, ...)`
1294
+ */
1295
+ (message?: any, ...optionalParams: any[]): void,
1296
+ }
1297
+
1298
+ /**
1299
+ * Create a new logger, or install a custom log formatter
1300
+ */
1301
+ export declare const log: LogFactory;
1302
+
1303
+ declare type LogFactory = {
1304
+
1305
+ /**
1306
+ * Returns a trace logger for the given module if trace is switched on for it,
1307
+ * otherwise returns null. All cds runtime packages use this method for their
1308
+ * trace and debug output.
1309
+ *
1310
+ * By default this logger would prefix all output with `[sql] - `
1311
+ * You can change this by specifying another prefix in the options:
1312
+ * @example
1313
+ * ```js
1314
+ * const LOG = cds.log('sql|db', { prefix: 'cds.ql' })
1315
+ * ```
1316
+ *
1317
+ * Call `cds.log()` for a given module again to dynamically change the log level
1318
+ * of all formerly created loggers, for example:
1319
+ * @example
1320
+ * ```js
1321
+ * const LOG = cds.log('sql')
1322
+ * LOG.info ('this will show, as default level is info')
1323
+ * cds.log('sql', 'warn')
1324
+ * LOG.info('this will be suppressed now')
1325
+ * ```
1326
+ *
1327
+ * @param name - logger name
1328
+ * @param options - level, label and prefix
1329
+ * @returns the logger
1330
+ * @see [capire](https://cap.cloud.sap/docs/node.js/cds-log)
1331
+ */
1332
+ (name: string, options?: string | number | { level?: LogLevel, label?: string, prefix?: string }): Logger,
1333
+
1334
+ /**
1335
+ * Set a custom formatter function like that:
1336
+ * ```js
1337
+ * cds.log.format = (module, level, ...args) => [ '[', module, ']', ...args ]
1338
+ * ```
1339
+ *
1340
+ * The formatter shall return an array of arguments, which are passed to the logger (for example, `console.log()`)
1341
+ */
1342
+ format: Formatter,
1343
+
1344
+ /**
1345
+ * Set a custom logger.
1346
+ * ```js
1347
+ * cds.log.Logger = ...
1348
+ * ```
1349
+ */
1350
+ Logger: Logger,
1351
+
1352
+ // FIXME
1353
+ /* eslint-disable-next-line @typescript-eslint/ban-types */
1354
+ winstonLogger (LoggerOptions?: { level?: string, levels?: any, format?: any, transports?: any, exitOnError?: boolean | Function, silent?: boolean }),
1355
+ }
1356
+
1357
+ declare class Logger {
1358
+
1359
+
1360
+ /**
1361
+ * Logs with 'trace' level
1362
+ */
1363
+ trace: Log
1364
+
1365
+ /**
1366
+ * Logs with 'debug' level
1367
+ */
1368
+ debug: Log
1369
+
1370
+ /**
1371
+ * Logs with 'info' level
1372
+ */
1373
+ info: Log
1374
+
1375
+ /**
1376
+ * Logs with 'warn' level
1377
+ */
1378
+ warn: Log
1379
+
1380
+ /**
1381
+ * Logs with 'error' level
1382
+ */
1383
+ error: Log
1384
+
1385
+ /**
1386
+ * Logs with default level
1387
+ */
1388
+ log: Log
1389
+
1390
+ /**
1391
+ * @returns whether 'trace' level is active
1392
+ */
1393
+ _trace: boolean
1394
+
1395
+ /**
1396
+ * @returns whether 'debug' level is active
1397
+ */
1398
+ _debug: boolean
1399
+
1400
+ /**
1401
+ * @returns whether 'info' level is active
1402
+ */
1403
+ _info: boolean
1404
+
1405
+ /**
1406
+ * @returns whether 'warn' level is active
1407
+ */
1408
+ _warn: boolean
1409
+
1410
+ /**
1411
+ * @returns whether 'error' level is active
1412
+ */
1413
+ _error: boolean
1414
+
1415
+ /**
1416
+ * Change the format for this logger instance:
1417
+ * ```
1418
+ * cds.log('foo').setFormat((module, level, ...args) => [ '[', module, ']', ...args ])
1419
+ * ```
1420
+ *
1421
+ * The formatter shall return an array of arguments, which are passed to the logger (for example, `console.log()`)
1422
+ */
1423
+ setFormat (formatter: Formatter)
1424
+
1425
+ }
1426
+
1427
+ declare type LogLevel = keyof typeof levels | Lowercase<keyof typeof levels> | levels
1428
+
1429
+ export declare type ManagedAssociation = Association & {
1430
+ foreignKeys: Definitions<type>,
1431
+ keys: Column[],
1432
+ }
1433
+
1434
+ export declare class MessagingService extends Service {}
1435
+
1436
+ export declare type Middleswares = 'context' | 'trace' | 'auth' | 'ctx_model' | string
1437
+
1438
+ export declare const middlewares: {
1439
+ add: (middleware: RequestHandler, pos?: XOR<XOR<{ at: number }, { after: Middleswares }>, { before: Middleswares }>) => void,
1440
+ };
1441
+
1442
+ /**
1443
+ * Allows arbitrary property access. Can be used for explicitly casting
1444
+ * classes you have added {@link mixin}s to.
1445
+ * Use with caution, as the type system will no longer
1446
+ * warn you about possibly missing properties.
1447
+ * @example
1448
+ * ```ts
1449
+ * mixin(class struct { foo: string }))
1450
+ *
1451
+ * const s1 = new struct() as MixedIn<struct>
1452
+ * s1.is_struct
1453
+ * s1.foo
1454
+ * s1.bar // no error, despite not being defined :(
1455
+ *
1456
+ * const s2 = new struct() as struct & { foo: string } // better!
1457
+ * s2.is_struct
1458
+ * s2.foo
1459
+ * s2.bar // error :)
1460
+ * ```
1461
+ */
1462
+ export declare type MixedIn<T> = T & { [key: string | number | symbol]: unknown }
1463
+
1464
+ /**
1465
+ * Using this will require you to explicitly cast all classes you added mixins to
1466
+ * to be able to access the additional properties. If you want to allow any additional
1467
+ * properties, you can use the {@link MixedIn} type.
1468
+ * @see [capire](https://cap.cloud.sap/docs/node.js/cds-reflect#mixin)
1469
+ */
1470
+ export declare function mixin (...classes: (new () => any)[]): void
1471
+
1472
+ /**
1473
+ * The effective CDS model loaded during bootstrapping, which contains all service and entity definitions,
1474
+ * including required services.
1475
+ * Should only be ever set explictly in test scenarios!
1476
+ */
1477
+ export declare let model: linked_2.CSN | undefined;
1478
+
1479
+ export declare type ModelPart<T extends any_> = IterableMap<T> & ((namespace: string) => IterableMap<T>)
1480
+
1481
+ declare namespace models {
1482
+ export {
1483
+ get,
1484
+ load,
1485
+ resolve,
1486
+ reflect,
1487
+ _flavor,
1488
+ _odata_options,
1489
+ _options,
1490
+ JSON_2 as JSON,
1491
+ YAML,
1492
+ CDL,
1493
+ SQL,
1494
+ XML,
1495
+ EDM,
1496
+ EDMX,
1497
+ filename,
1498
+ model,
1499
+ parse,
1500
+ linked,
1501
+ compile
1502
+ }
1503
+ }
1504
+
1505
+ /** @private */
1506
+ export declare type name = string
1507
+
1508
+ export declare const number: typeof number_;
1509
+
1510
+ declare class number_ extends scalar { }
1511
+
1512
+ export declare type _odata_options = {
1513
+ flavor?: 'v2' | 'v4' | 'w4' | 'x4',
1514
+ version?: 'v2' | 'v4',
1515
+ structs?: boolean,
1516
+ refs?: boolean,
1517
+ }
1518
+
1519
+ /**
1520
+ * Emitted whenever a model is loaded using cds.load().
1521
+ */
1522
+ // FIXME: this is actually supposed to be part of models.d.ts
1523
+ // 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
1525
+
1526
+ /**
1527
+ * Emitted whenever a specific service is connected for the first time.
1528
+ */
1529
+ export declare function on (event: 'connect', listener: (srv: Service) => void): _cds
1530
+
1531
+ /**
1532
+ * Emitted at the very beginning of the bootsrapping process, when the
1533
+ * express application has been constructed but no middlewares or routes
1534
+ * added yet.
1535
+ */
1536
+ export declare function on (event: 'bootstrap', listener: (app: Application) => void): _cds
1537
+
1538
+ /**
1539
+ * Emitted for each service served by cds.serve().
1540
+ */
1541
+ export declare function on (event: 'serving', listener: (srv: Service) => void): _cds
1542
+
1543
+ /**
1544
+ * Emitted by the default, built-in `server.js` when all services are
1545
+ * constructed and mounted by cds.serve().
1546
+ */
1547
+ export declare function on (event: 'served', listener: (all: cds_services) => void): _cds
1548
+
1549
+ /**
1550
+ * Emitted by the default, built-in `server.js` when the http server
1551
+ * is started and listening for incoming requests.
1552
+ */
1553
+ export declare function on (event: 'listening', listener: (args: { server: http.Server, url: string }) => void): _cds
1554
+
1555
+ /**
1556
+ * Emitted by the default, built-in `server.js` when the http server
1557
+ * is shutdown.
1558
+ */
1559
+ export declare function on (event: 'shutdown', listener: () => void): _cds
1560
+
1561
+ export declare function once (event: 'bootstrap', listener: (app: Application) => void): _cds
1562
+
1563
+ export declare function once (event: 'served', listener: (all: cds_services) => void): _cds
1564
+
1565
+ export declare function once (event: 'listening', listener: (args: { server: http.Server, url: string }) => void): _cds
1566
+
1567
+ export declare function once (event: 'shutdown', listener: () => void): _cds
1568
+
1569
+ export declare type OneOrMany<T> = T | T[]
1570
+
1571
+ export declare interface OnErrorHandler {
1572
+ (err: Error, req: Request_2): any | void
1573
+ }
1574
+
1575
+ export declare interface OnEventHandler {
1576
+ (req: Request_2, next: Function): Promise<any> | any | void
1577
+ }
1578
+
1579
+ /** @private */
1580
+ export declare type operator = string
1581
+
1582
+ export declare type _options = {
1583
+ flavor?: _flavor,
1584
+ plain?: boolean,
1585
+ docs?: boolean,
1586
+ names?: string,
1587
+ odata?: _odata_options,
1588
+ } | _flavor
1589
+
1590
+ /** @private */
1591
+ export declare type ordering_term = expr & { sort?: 'asc' | 'desc', nulls?: 'first' | 'last' }
1592
+
1593
+ export declare const outboxed: (service: Service) => Service;
1594
+
1595
+ /**
1596
+ * Provides a set of methods to parse a given model, query or expression.
1597
+ * You can also use `cds.parse()` as a shortcut to `cds.parse.cdl()`.
1598
+ */
1599
+ export declare const parse: {
1600
+
1601
+ /** Shortcut to `cds.parse.cdl()` */
1602
+ (cdl: CDL): csn.CSN,
1603
+ cdl (cdl: CDL): csn.CSN,
1604
+ cql (src: string): Query,
1605
+ expr (src: string): expr,
1606
+ xpr (src: string): _xpr,
1607
+ ref (src: string): string[],
1608
+ };
1609
+
1610
+ declare type Partial_2<T> = { [Key in keyof T]: undefined | T[Key] }
1611
+ export { Partial_2 as Partial }
1612
+
1613
+ declare type PK = number | string | object
1614
+
1615
+ declare type PluralType<T extends Constructable> = Array<InstanceType<T>>
1616
+
1617
+ export declare type predicate = UnionsToIntersections<_xpr>
1618
+
1619
+ declare type Primitive = string | number | boolean | Date
1620
+
1621
+ /** @private */
1622
+ export declare type primitive = number | string | boolean | null
1623
+
1624
+ /**
1625
+ * Subclass for executing code with superuser privileges.
1626
+ */
1627
+ export declare class Privileged extends User {
1628
+
1629
+ constructor ()
1630
+
1631
+ is (): boolean
1632
+
1633
+ }
1634
+
1635
+ declare type Projection<T> = (e: QLExtensions<T extends ArrayConstructable ? SingularType<T> : T>) => void
1636
+
1637
+ /**
1638
+ * @alpha
1639
+ * related to .protocols getters
1640
+ */
1641
+ export declare type Protocol = 'odata' | 'rest'
1642
+
1643
+ declare class QL<T> {
1644
+
1645
+ SELECT: StaticSELECT<T>
1646
+
1647
+ INSERT: typeof INSERT_3
1648
+ & ((...entries: object[]) => INSERT_3<any>) & ((entries: object[]) => INSERT_3<any>)
1649
+
1650
+ UPSERT: typeof UPSERT_3
1651
+ & ((...entries: object[]) => UPSERT_3<any>) & ((entries: object[]) => UPSERT_3<any>)
1652
+
1653
+ UPDATE: typeof UPDATE_3
1654
+ & typeof UPDATE_3.entity
1655
+
1656
+ DELETE: typeof DELETE_3
1657
+ & ((...entries: object[]) => DELETE_3<any>) & ((entries: object[]) => DELETE_3<any>)
1658
+
1659
+ CREATE: typeof CREATE_3
1660
+
1661
+ DROP: typeof DROP_3
1662
+
1663
+ }
1664
+
1665
+ declare namespace ql {
1666
+ export {
1667
+ Query_2 as Query,
1668
+ ConstructedQuery,
1669
+ PK,
1670
+ Primitive,
1671
+ QLExtensions,
1672
+ Target,
1673
+ QLExtensions_,
1674
+ Subqueryable,
1675
+ Projection,
1676
+ Awaitable,
1677
+ StaticSELECT,
1678
+ QL,
1679
+ TaggedTemplateQueryPart,
1680
+ SELECT_3 as SELECT,
1681
+ SELECT_one,
1682
+ SELECT_from,
1683
+ INSERT_3 as INSERT,
1684
+ UPSERT_3 as UPSERT,
1685
+ DELETE_3 as DELETE,
1686
+ UPDATE_3 as UPDATE,
1687
+ CREATE_3 as CREATE,
1688
+ DROP_3 as DROP
1689
+ }
1690
+ }
1691
+ export { ql }
1692
+
1693
+ export declare type QLExtensions<T> = T extends QLExtensions_<any> ? T : QLExtensions_<T>
1694
+
1695
+ /**
1696
+ * QLExtensions are properties that are attached to entities in CQL contexts.
1697
+ * They are passed down to all properties recursively.
1698
+ */
1699
+ declare type QLExtensions_<T> = {
1700
+ [Key in keyof T]: QLExtensions<T[Key]>
1701
+ } & {
1702
+
1703
+ /**
1704
+ * Alias for this attribute.
1705
+ */
1706
+ as: (alias: string) => void,
1707
+
1708
+ /**
1709
+ * Accesses any nested attribute based on a [path](https://cap.cloud.sap/cap/docs/java/query-api#path-expressions):
1710
+ * `X.get('a.b.c.d')`. Note that you will not receive
1711
+ * proper typing after this call.
1712
+ * To still have access to typed results, use
1713
+ * `X.a().b().c().d()` instead.
1714
+ */
1715
+ get: (path: string) => any,
1716
+
1717
+ // have to exclude undefined from the type, or we'd end up with a distribution of Subqueryable
1718
+ // over T and undefined, which gives us zero code completion within the callable.
1719
+ } & Subqueryable<Exclude<T, undefined>>
1720
+
1721
+ export declare type Query = Partial<SELECT_2 & INSERT_2 & UPDATE_2 & DELETE_2 & CREATE_2 & DROP_2 & UPSERT_2>
1722
+
1723
+ declare type Query_2 = CQN.Query
1724
+
1725
+ export declare class QueryAPI {
1726
+
1727
+ entities: linked_2.CSN['entities']
1728
+
1729
+ /**
1730
+ * @see [docs](https://cap.cloud.sap/docs/node.js/core-services#crud-style-api)
1731
+ */
1732
+ read: {
1733
+ <T extends ArrayConstructable>(entity: T, key?: Key): Awaitable<SELECT_3<T>, InstanceType<T>>,
1734
+ <T>(entity: linked_2.Definition | string, key?: Key): SELECT_3<T>,
1735
+ }
1736
+
1737
+ /**
1738
+ * @see [docs](https://cap.cloud.sap/docs/node.js/core-services#crud-style-api)
1739
+ */
1740
+ create: {
1741
+ <T extends ArrayConstructable>(entity: T, key?: Key): INSERT_3<T>,
1742
+ <T>(entity: linked_2.Definition | string, key?: Key): INSERT_3<T>,
1743
+ }
1744
+
1745
+ /**
1746
+ * @see [docs](https://cap.cloud.sap/docs/node.js/core-services#crud-style-api)
1747
+ */
1748
+ insert: {
1749
+ <T extends ArrayConstructable>(data: T): INSERT_3<T>,
1750
+ <T>(data: object | object[]): INSERT_3<T>,
1751
+ }
1752
+
1753
+ /**
1754
+ * @see [docs](https://cap.cloud.sap/docs/node.js/core-services#crud-style-api)
1755
+ */
1756
+ upsert: {
1757
+ <T extends ArrayConstructable>(data: T): UPSERT_3<T>,
1758
+ <T>(data: object | object[]): UPSERT_3<T>,
1759
+ }
1760
+
1761
+ /**
1762
+ * @see [docs](https://cap.cloud.sap/docs/node.js/core-services#crud-style-api)
1763
+ */
1764
+ update: {
1765
+ <T extends ArrayConstructable>(entity: T, key?: Key): UPDATE_3<T>,
1766
+ <T>(entity: linked_2.Definition | string, key?: Key): UPDATE_3<T>,
1767
+ }
1768
+
1769
+ /**
1770
+ * @see [docs](https://cap.cloud.sap/docs/node.js/core-services#crud-style-api)
1771
+ */
1772
+ run: {
1773
+ (query: ConstructedQuery | ConstructedQuery[]): Promise<ResultSet | any>,
1774
+ (query: Query_2): Promise<ResultSet | any>,
1775
+ (query: string, args?: any[] | object): Promise<ResultSet | any>,
1776
+ }
1777
+
1778
+ /**
1779
+ * @see [docs](https://cap.cloud.sap/docs/node.js/core-services#srv-stream-column)
1780
+ */
1781
+ stream: {
1782
+ (column: string): {
1783
+ from(entity: linked_2.Definition | string): {
1784
+ where(filter: any): ReadableStream,
1785
+ },
1786
+ },
1787
+ (query: Query_2): Promise<ReadableStream>,
1788
+ }
1789
+
1790
+ /**
1791
+ * @see [docs](https://cap.cloud.sap/docs/node.js/core-services#crud-style-api)
1792
+ */
1793
+ delete<T>(entity: linked_2.Definition | string, key?: Key): DELETE_3<T>
1794
+
1795
+ /**
1796
+ * @see [docs](https://cap.cloud.sap/docs/node.js/core-services#srv-foreach-entity)
1797
+ */
1798
+ foreach (query: Query_2, callback: (row: object) => void): this
1799
+
1800
+ /**
1801
+ * @deprecated use {@link QueryAPI.tx} instead
1802
+ */
1803
+ transaction: QueryAPI['tx']
1804
+
1805
+ tx: {
1806
+ (fn: (tx: Transaction) => object): Promise<unknown>,
1807
+ (context?: object): Transaction,
1808
+ (context: object, fn: (tx: Transaction) => object): Promise<unknown>,
1809
+ }
1810
+
1811
+ }
1812
+
1813
+ export declare const read: Service['read'];
1814
+
1815
+ /** @private */
1816
+ export declare type ref = { ref: (name & { id?: string, where?: expr, args?: expr[] })[] }
1817
+
1818
+ /**
1819
+ * Turns the given plain CSN model into a reflected model
1820
+ * @see [capire](https://cap.cloud.sap/docs/node.js/cds-reflect)
1821
+ */
1822
+ export declare function reflect (model: csn.CSN): linked_2.CSN
1823
+
1824
+ export declare class RemoteService extends Service {}
1825
+
1826
+ /**
1827
+ * @see [capire docs](https://cap.cloud.sap/docs/node.js/events)
1828
+ */
1829
+ declare class Request_2 extends Event_2 {
1830
+
1831
+ params: (string | object)[]
1832
+
1833
+ method: string
1834
+
1835
+ path: string
1836
+
1837
+ target: Definition
1838
+
1839
+ /**
1840
+ * Shortcut to {@link Request.target | target (entity) name}
1841
+ * @see https://cap.cloud.sap/docs/node.js/events#req-entity
1842
+ */
1843
+ entity: string
1844
+
1845
+ query: Query
1846
+
1847
+ subject: ref
1848
+
1849
+ reply (results: any): void
1850
+
1851
+ notify (code: number, message: string, target?: string, args?: any[]): Error
1852
+
1853
+ info (code: number, message: string, target?: string, args?: any[]): Error
1854
+
1855
+ warn (code: number, message: string, target?: string, args?: any[]): Error
1856
+
1857
+ error (code: number, message: string, target?: string, args?: any[]): Error
1858
+
1859
+ reject (code: number, message: string, target?: string, args?: any[]): Error
1860
+
1861
+ notify (code: number, message: string, args?: any[]): Error
1862
+
1863
+ info (code: number, message: string, args?: any[]): Error
1864
+
1865
+ warn (code: number, message: string, args?: any[]): Error
1866
+
1867
+ error (code: number, message: string, args?: any[]): Error
1868
+
1869
+ reject (code: number, message: string, args?: any[]): Error
1870
+
1871
+ notify (message: string, target?: string, args?: any[]): Error
1872
+
1873
+ info (message: string, target?: string, args?: any[]): Error
1874
+
1875
+ warn (message: string, target?: string, args?: any[]): Error
1876
+
1877
+ error (message: string, target?: string, args?: any[]): Error
1878
+
1879
+ reject (message: string, target?: string, args?: any[]): Error
1880
+
1881
+ notify (message: { code?: number | string, message: string, target?: string, args?: any[] }): Error
1882
+
1883
+ info (message: { code?: number | string, message: string, target?: string, args?: any[] }): Error
1884
+
1885
+ warn (message: { code?: number | string, message: string, target?: string, args?: any[] }): Error
1886
+
1887
+ error (message: { code?: number | string, message: string, target?: string, args?: any[], status?: number }): Error
1888
+
1889
+ reject (message: { code?: number | string, message: string, target?: string, args?: any[], status?: number }): Error
1890
+
1891
+ }
1892
+ export { Request_2 as Request }
1893
+
1894
+ export declare const requires: env.Requires;
1895
+
1896
+ /**
1897
+ * Resolves given file or module name(s) to an array of absolute file names.
1898
+ * Uses Node's `require.resolve` internally with the following additions:
1899
+ * - relative names are resolved relative to the current working directory instead of the current JavaScript module; hence, use __dirname if you want to find or load models relative to the current module.
1900
+ * - if no file extension is given, `.csn` and `.cds` will be appended in that order.
1901
+ * @param files - The file or module name(s) of a model or a folder containing models. Specify `'*'` to fetch moels from default locations, i.e. `[ 'db/', 'srv/', 'app/' ]`
1902
+ * @returns An array of absolute file names or `undefined` if none could be resolved.
1903
+ */
1904
+ export declare function resolve (files: '*' | filename | filename[]): filename[] | undefined
1905
+
1906
+ export declare interface ResultSet extends Array<object> {}
1907
+
1908
+ export declare interface ResultsHandler {
1909
+ (results: any[], req: Request_2): void
1910
+ (each: any, req: Request_2): void
1911
+ }
1912
+
1913
+ export declare const root: string;
1914
+
1915
+ export declare const run: Service['run'];
1916
+
1917
+ export declare class scalar extends type { }
1918
+
1919
+ declare type Scalarise<A> = A extends Array<infer N> ? N : A
1920
+
1921
+ declare type SELECT_2 = { SELECT: {
1922
+ distinct?: true,
1923
+ one?: boolean,
1924
+ from: source,
1925
+ mixin?: { [key: string]: expr },
1926
+ columns?: column_expr[],
1927
+ excluding?: string[],
1928
+ where?: predicate,
1929
+ having?: predicate,
1930
+ groupBy?: expr[],
1931
+ orderBy?: ordering_term[],
1932
+ limit?: { rows: val, offset: val },
1933
+ }, }
1934
+ export { SELECT_2 as SELECT }
1935
+
1936
+ declare class SELECT_3<T> extends ConstructedQuery {
1937
+
1938
+ static one: SELECT_one & { from: SELECT_one }
1939
+
1940
+ static distinct: typeof SELECT_3
1941
+
1942
+ static from: SELECT_from
1943
+
1944
+ from: SELECT_from & TaggedTemplateQueryPart<this>
1945
+ & ((entity: Target, primaryKey?: PK, projection?: Projection<unknown>) => this)
1946
+
1947
+ byKey (primaryKey?: PK): this
1948
+ columns: TaggedTemplateQueryPart<this>
1949
+ & ((projection: Projection<T>) => this)
1950
+ & ((...col: (T extends ArrayConstructable<any> ? keyof SingularType<T> : keyof T)[]) => this)
1951
+ & ((...col: (string | column_expr)[]) => this)
1952
+ & ((col: (string | column_expr)[]) => this)
1953
+
1954
+ where: TaggedTemplateQueryPart<this>
1955
+ & ((predicate: object) => this)
1956
+ & ((...expr: any[]) => this)
1957
+
1958
+ and: TaggedTemplateQueryPart<this>
1959
+ & ((predicate: object) => this)
1960
+ & ((...expr: any[]) => this)
1961
+
1962
+ having: TaggedTemplateQueryPart<this>
1963
+ & ((...expr: string[]) => this)
1964
+ & ((predicate: object) => this)
1965
+
1966
+ groupBy: TaggedTemplateQueryPart<this>
1967
+ & ((...expr: string[]) => this)
1968
+
1969
+ orderBy: TaggedTemplateQueryPart<this>
1970
+ & ((...expr: string[]) => this)
1971
+
1972
+ limit: TaggedTemplateQueryPart<this>
1973
+ & ((rows: number, offset?: number) => this)
1974
+
1975
+ forShareLock (): this
1976
+
1977
+ forUpdate ({ wait }?: { wait?: number }): this
1978
+
1979
+ alias (as: string): this
1980
+ elements: EntityElements
1981
+
1982
+
1983
+ // Not yet public
1984
+ // fullJoin (other: string, as: string) : this
1985
+ // leftJoin (other: string, as: string) : this
1986
+ // rightJoin (other: string, as: string) : this
1987
+ // innerJoin (other: string, as: string) : this
1988
+ // join (other: string, as: string, kind?: string) : this
1989
+ // on : TaggedTemplateQueryPart<this>
1990
+ // & ((...expr : string[]) => this)
1991
+ // & ((predicate:object) => this)
1992
+
1993
+ SELECT: CQN.SELECT['SELECT'] & {
1994
+ forUpdate?: { wait: number },
1995
+ forShareLock?: { wait: number },
1996
+ search?: CQN.predicate,
1997
+ count?: boolean,
1998
+ }
1999
+
2000
+ }
2001
+
2002
+ declare type SELECT_from =
2003
+ // tagged template
2004
+ TaggedTemplateQueryPart<Awaitable<SELECT_3<unknown>, InstanceType<any>>>
2005
+ &
2006
+ // calling with class
2007
+ (<T extends ArrayConstructable<any>>
2008
+ (entityType: T, projection?: Projection<QLExtensions<SingularType<T>>>)
2009
+ => Awaitable<SELECT_3<T>, InstanceType<T>>)
2010
+ &
2011
+ (<T extends ArrayConstructable<any>>
2012
+ (entityType: T, primaryKey: PK, projection?: Projection<SingularType<T>>)
2013
+ => Awaitable<SELECT_3<SingularType<T>>, InstanceType<SingularType<T>>>) // when specifying a key, we expect a single element as result
2014
+ // calling with definition
2015
+ & ((entity: Target, primaryKey?: PK, projection?: Projection<unknown>) => SELECT_3<any>)
2016
+ // calling with concrete list
2017
+ & (<T> (entity: T[], projection?: Projection<T>) => SELECT_3<T> & Promise<T[]>)
2018
+ & (<T> (entity: T[], primaryKey: PK, projection?: Projection<T>) => Awaitable<SELECT_3<T>, T>)
2019
+ & ((subject: ref) => SELECT_3<any>)
2020
+ // put these overloads at the very end, as they would also match the above
2021
+ // We expect these to be the overloads for scalars since we covered arrays above -> wrap them back in Array
2022
+ & (<T extends Constructable<any>>(
2023
+ entityType: T,
2024
+ projection?: Projection<InstanceType<T>>
2025
+ ) => Awaitable<SELECT_3<PluralType<T>>, PluralType<T>>)
2026
+ & (<T extends Constructable<any>>(
2027
+ entityType: T,
2028
+ primaryKey: PK,
2029
+ projection?: Projection<InstanceType<T>>
2030
+ ) => Awaitable<SELECT_3<PluralType<T>>, PluralType<T>>)
2031
+
2032
+ declare type SELECT_one =
2033
+ TaggedTemplateQueryPart<Awaitable<SELECT_3<unknown>, InstanceType<any>>>
2034
+ &
2035
+ // calling with class
2036
+ (<T extends ArrayConstructable<any>>
2037
+ (entityType: T, projection?: Projection<QLExtensions<SingularType<T>>>)
2038
+ => Awaitable<SELECT_3<SingularType<T>>, SingularType<T>>)
2039
+ &
2040
+ (<T extends ArrayConstructable<any>>
2041
+ (entityType: T, primaryKey: PK, projection?: Projection<QLExtensions<SingularType<T>>>)
2042
+ => Awaitable<SELECT_3<SingularType<T>>, SingularType<T>>)
2043
+
2044
+ & ((entity: Target, primaryKey?: PK, projection?: Projection<unknown>) => SELECT_3<any>)
2045
+ & (<T> (entity: T[], projection?: Projection<T>) => Awaitable<SELECT_3<T>, T>)
2046
+ & (<T> (entity: T[], primaryKey: PK, projection?: Projection<T>) => Awaitable<SELECT_3<T>, T>)
2047
+ & (<T> (entity: { new(): T }, projection?: Projection<T>) => Awaitable<SELECT_3<T>, T>)
2048
+ & (<T> (entity: { new(): T }, primaryKey: PK, projection?: Projection<T>) => Awaitable<SELECT_3<T>, T>)
2049
+ & ((subject: ref) => SELECT_3<any>)
2050
+
2051
+ /**
2052
+ * Constructs service providers from respective service definitions
2053
+ * @see [capire](https://cap.cloud.sap/docs/node.js/cds-serve)
2054
+ */
2055
+ export declare const serve: (service: string, options?: {
2056
+ service?: string,
2057
+ from?: '*' | 'all' | string,
2058
+ [key: string]: any,
2059
+ }) => Promise<cds_services> & cds_serve_fluent;
2060
+
2061
+ /**
2062
+ * The default bootstrap function as loaded from server.js
2063
+ */
2064
+ export declare const server: Function;
2065
+
2066
+ /**
2067
+ * Class cds.Service
2068
+ * @see [capire docs](https://cap.cloud.sap/docs/node.js/core-services)
2069
+ */
2070
+ export declare class Service extends QueryAPI {
2071
+
2072
+ constructor (
2073
+ name?: string,
2074
+ model?: csn.CSN,
2075
+ options?: {
2076
+ kind: string,
2077
+ impl: string | ServiceImpl,
2078
+ }
2079
+ )
2080
+
2081
+ /**
2082
+ * The kind of the service
2083
+ */
2084
+ kind: string
2085
+
2086
+ /**
2087
+ * The name of the service
2088
+ */
2089
+ name: string
2090
+
2091
+ /**
2092
+ * The model from which the service's definition was loaded
2093
+ * @see [capire docs](https://cap.cloud.sap/docs/node.js/core-services)
2094
+ */
2095
+ model: linked_2.CSN
2096
+
2097
+ /**
2098
+ * Provides access to the entities exposed by a service
2099
+ * @see [capire docs](https://cap.cloud.sap/docs/node.js/core-services)
2100
+ */
2101
+ entities: linked_2.ModelPart<linked_2.entity>
2102
+
2103
+ /**
2104
+ * Provides access to the events declared by a service
2105
+ * @see [capire docs](https://cap.cloud.sap/docs/node.js/core-services)
2106
+ */
2107
+ events: linked_2.ModelPart<linked_2.event>
2108
+
2109
+ /**
2110
+ * Provides access to the types exposed by a service
2111
+ * @see [capire docs](https://cap.cloud.sap/docs/node.js/core-services)
2112
+ */
2113
+ types: linked_2.ModelPart<linked_2.type>
2114
+
2115
+ /**
2116
+ * Provides access to the operations, i.e. actions and functions, exposed by a service
2117
+ * @see [capire docs](https://cap.cloud.sap/docs/node.js/core-services)
2118
+ */
2119
+ operations: linked_2.ModelPart<linked_2.action>
2120
+
2121
+ /**
2122
+ * Acts like a parameter-less constructor. Ensure to call `await super.init()` to have the base class’s handlers added.
2123
+ * You may register own handlers before the base class’s ones, to intercept requests before the default handlers snap in.
2124
+ * @see [capire docs](https://cap.cloud.sap/docs/node.js/core-services#srv-init)
2125
+ */
2126
+ init (): Promise<void>
2127
+
2128
+ /**
2129
+ * Constructs and emits an asynchronous event.
2130
+ * @see [capire docs](https://cap.cloud.sap/docs/core-services#srv-emit-event)
2131
+ */
2132
+ emit: {
2133
+ <T = any>(details: { event: types.event, data?: object, headers?: object }): Promise<T>,
2134
+ <T = any>(event: types.event, data?: object, headers?: object): Promise<T>,
2135
+ }
2136
+
2137
+ /**
2138
+ * Constructs and sends a synchronous request.
2139
+ * @see [capire docs](https://cap.cloud.sap/docs/node.js/core-services#srv-send-request)
2140
+ */
2141
+ send: {
2142
+ <T = any>(event: types.event, path: string, data?: object, headers?: object): Promise<T>,
2143
+ <T = any>(event: types.event, data?: object, headers?: object): Promise<T>,
2144
+ <T = any>(details: { event: types.event, data?: object, headers?: object }): Promise<T>,
2145
+ <T = any>(details: { query: ConstructedQuery, data?: object, headers?: object }): Promise<T>,
2146
+ <T = any>(details: { method: types.eventName, path: string, data?: object, headers?: object }): Promise<T>,
2147
+ <T = any>(details: { event: types.eventName, entity: linked_2.Definition | string, data?: object, params?: object, headers?: object }): Promise<T>,
2148
+ }
2149
+
2150
+ /**
2151
+ * Constructs and sends a GET request.
2152
+ * @see [capire docs](https://cap.cloud.sap/docs/node.js/core-services#rest-style-api)
2153
+ */
2154
+ get<T = any>(entityOrPath: types.target, data?: object): Promise<T>
2155
+
2156
+ /**
2157
+ * Constructs and sends a POST request.
2158
+ * @see [capire docs](https://cap.cloud.sap/docs/node.js/core-services#rest-style-api)
2159
+ */
2160
+ post<T = any>(entityOrPath: types.target, data?: object): Promise<T>
2161
+
2162
+ /**
2163
+ * Constructs and sends a PUT request.
2164
+ * @see [capire docs](https://cap.cloud.sap/docs/node.js/core-services#rest-style-api)
2165
+ */
2166
+ put<T = any>(entityOrPath: types.target, data?: object): Promise<T>
2167
+
2168
+ /**
2169
+ * Constructs and sends a PATCH request.
2170
+ * @see [capire docs](https://cap.cloud.sap/docs/node.js/core-services#rest-style-api)
2171
+ */
2172
+ patch<T = any>(entityOrPath: types.target, data?: object): Promise<T>
2173
+
2174
+ /**
2175
+ * Constructs and sends a DELETE request.
2176
+ */
2177
+ delete: {
2178
+ <T = any>(entityOrPath: types.target, data?: object): DELETE_3<T>,
2179
+ <T extends ArrayConstructable>(entity: T, key?: Key): DELETE_3<T>,
2180
+ <T>(entity: linked_2.Definition | string, key?: Key): DELETE_3<T>,
2181
+ }
2182
+
2183
+ // The central method to dispatch events
2184
+ dispatch (msg: types.event): Promise<any>
2185
+
2186
+ // FIXME: not yet documented, will come in future version
2187
+ // disconnect (tenant?: string): Promise<void>
2188
+
2189
+ // Provider API
2190
+ prepend (fn: ServiceImpl): this
2191
+
2192
+ on<T extends ArrayConstructable>(eve: types.event, entity: T, handler: CRUDEventHandler.On<InstanceType<T>>): this
2193
+ on<T extends Constructable>(eve: types.event, entity: T, handler: CRUDEventHandler.On<Array<InstanceType<T>>>): this
2194
+ on<F extends CdsFunction>(boundAction: F, service: string, handler: ActionEventHandler<F['__parameters'], void | Error | F['__returns']>): this
2195
+ on<F extends CdsFunction>(unboundAction: F, handler: ActionEventHandler<F['__parameters'], void | Error | F['__returns']>): this
2196
+ on (eve: types.event, entity: types.target, handler: OnEventHandler): this
2197
+ on (eve: types.event, handler: OnEventHandler): this
2198
+ on (eve: 'error', handler: OnErrorHandler): this
2199
+
2200
+ // onSucceeded (eve: types.Events, entity: types.Target, handler: types.EventHandler): this
2201
+ // onSucceeded (eve: types.Events, handler: types.EventHandler): this
2202
+ // onFailed (eve: types.Events, entity: types.Target, handler: types.EventHandler): this
2203
+ // onFailed (eve: types.Events, handler: types.EventHandler): this
2204
+ before<T extends ArrayConstructable>(eve: types.event, entity: T, handler: CRUDEventHandler.Before<InstanceType<T>>): this
2205
+ before<T extends Constructable>(eve: types.event, entity: T, handler: CRUDEventHandler.Before<Array<InstanceType<T>>>): this
2206
+ before (eve: types.event, entity: types.target, handler: EventHandler): this
2207
+ before (eve: types.event, handler: EventHandler): this
2208
+
2209
+ // order relevant:
2210
+ // (2) check if T is arrayable -> use T directly
2211
+ // (3) check if T is scalar -> wrap into array
2212
+ // this streamlines that in _most_ cases, handlers will receive an array.
2213
+ // _Except_ for after.read handlers (1), which will change its inflection based on T.
2214
+ after<T extends ArrayConstructable>(event: 'READ' | 'EACH', entity: T, handler: CRUDEventHandler.After<Unwrap<T>>): this
2215
+ after<T extends Constructable>(event: 'READ' | 'EACH', entity: T, handler: CRUDEventHandler.After<InstanceType<T>>): this
2216
+ after<T extends ArrayConstructable>(eve: types.event, entity: T, handler: CRUDEventHandler.After<InstanceType<T>>): this
2217
+ after<T extends Constructable>(eve: types.event, entity: T, handler: CRUDEventHandler.After<Array<InstanceType<T>>>): this
2218
+ after (eve: types.event, entity: types.target, handler: ResultsHandler): this
2219
+ after (eve: types.event, handler: ResultsHandler): this
2220
+
2221
+ reject (eves: types.event, ...entity: types.target[]): this
2222
+
2223
+ }
2224
+
2225
+ /**
2226
+ * Shortcut to base class for all service definitions from linked models.
2227
+ * Plus accessors to impl functions and constructed providers.
2228
+ */
2229
+ export declare const service: service;
2230
+
2231
+ export declare type service = {
2232
+
2233
+ /**
2234
+ * Dummy wrapper for service implementation functions.
2235
+ * Use that in modules to get IntelliSense.
2236
+ */
2237
+ impl (impl: ServiceImpl): typeof impl,
2238
+ // impl <T> (srv:T, impl: ( _cds: T, srv: (T) ) => any) : typeof impl
2239
+
2240
+ /**
2241
+ * Array of all services constructed.
2242
+ */
2243
+ providers: Service[],
2244
+ }
2245
+
2246
+ /**
2247
+ * @see [capire](https://cap.cloud.sap/docs/node.js/cds-reflect#cds-service)
2248
+ */
2249
+ export declare interface service_ extends csn.service {}
2250
+
2251
+ export declare class service_ extends context_ {
2252
+ is_service: true
2253
+ get entities (): Definitions<entity>
2254
+ get types (): Definitions<type>
2255
+ get events (): Definitions<event>
2256
+ get actions (): Definitions<action>
2257
+
2258
+ /**
2259
+ * @deprecated use `.actions` instead
2260
+ */
2261
+ get operations (): Definitions<action>
2262
+
2263
+ /**
2264
+ * @alpha
2265
+ * not public yet
2266
+ */
2267
+ get protocols (): { [protocol in Protocol]?: boolean | undefined }
2268
+ }
2269
+
2270
+ declare interface service_2 extends any__2 { }
2271
+
2272
+ export declare interface ServiceImpl {
2273
+ (this: Service, srv: Service): any
2274
+ }
2275
+
2276
+ /**
2277
+ * Dictionary of all services constructed and/or connected.
2278
+ */
2279
+ export declare const services: cds_services;
2280
+
2281
+ declare type SingularType<T extends ArrayConstructable<T>> = InstanceType<T>[number]
2282
+
2283
+ /** @private */
2284
+ export declare type source = UnionToIntersection<ref | SELECT_2> & { as?: name, join?: name, on?: xpr }
2285
+
2286
+ /**
2287
+ * @see [docs](https://cap.cloud.sap/docs/node.js/cds-tx#cds-spawn)
2288
+ */
2289
+ export declare function spawn (options: SpawnOptions, fn: (tx: Transaction) => object): SpawnEventEmitter
2290
+
2291
+ export declare class SpawnEventEmitter {
2292
+
2293
+ on<U extends keyof SpawnEvents>(
2294
+ event: U, listener: SpawnEvents[U]
2295
+ ): this
2296
+
2297
+ emit<U extends keyof SpawnEvents>(
2298
+ event: U, ...args: Parameters<SpawnEvents[U]>
2299
+ ): boolean
2300
+ timer: any
2301
+
2302
+ }
2303
+
2304
+ export declare interface SpawnEvents {
2305
+ succeeded: (res: any) => void
2306
+ failed: (error: any) => void
2307
+ done: () => void
2308
+ }
2309
+
2310
+ export declare type SpawnOptions = {
2311
+ [key: string]: any,
2312
+ every?: number,
2313
+ after?: number,
2314
+ }
2315
+
2316
+ export declare type SQL = string
2317
+
2318
+ declare type StaticSELECT<T> = typeof SELECT_3
2319
+ & ((...columns: (T extends ArrayConstructable<any> ? keyof SingularType<T> : keyof T)[]) => SELECT_3<T>)
2320
+ & ((...columns: string[]) => SELECT_3<T>)
2321
+ & ((columns: string[]) => SELECT_3<T>)
2322
+ & (TaggedTemplateQueryPart<SELECT_3<T>>)
2323
+ & SELECT_from // as it is not directly quantified, ...
2324
+ & SELECT_one
2325
+
2326
+ export declare const stream: Service['stream'];
2327
+
2328
+ export declare const string: typeof string_;
2329
+
2330
+ declare class string_ extends scalar { }
2331
+
2332
+ declare class String_2 extends string { }
2333
+ export { String_2 as String }
2334
+
2335
+ /**
2336
+ * @see [capire](https://cap.cloud.sap/docs/node.js/cds-reflect#cds-struct)
2337
+ */
2338
+ export declare interface struct extends Omit<csn.struct, 'items' | 'elements'> {}
2339
+
2340
+ export declare class struct<K extends kinds = 'elements' | 'type'> extends type<K> implements WithElements {
2341
+ is_struct: true
2342
+
2343
+ elements: Definitions<type<'type'>>
2344
+ }
2345
+
2346
+ declare interface struct_2 extends type_2 {
2347
+
2348
+ /**
2349
+ * References to definitions to be included.
2350
+ * Not available after extensions have been applied.
2351
+ */
2352
+ includes?: FQN[]
2353
+ elements: { [name: string]: Element }
2354
+ }
2355
+
2356
+ /**
2357
+ * Adds the ability for subqueries to structured properties.
2358
+ * The final result of each subquery will be the property itself:
2359
+ * `Book.title` == `Subqueryable<Book>.title()`
2360
+ */
2361
+ declare type Subqueryable<T> = T extends Primitive ? unknown
2362
+ // composition of many/ association to many
2363
+ : T extends readonly unknown[] ? {
2364
+
2365
+ /**
2366
+ * @example
2367
+ * ```js
2368
+ * SELECT.from(Books, b => b.author)
2369
+ * ```
2370
+ * means: "select all books and project each book's author"
2371
+ *
2372
+ * whereas
2373
+ * ```js
2374
+ * SELECT.from(Books, b => b.author(a => a.ID))
2375
+ * ```
2376
+ * means: "select all books, subselect each book's author's ID
2377
+ *
2378
+ * Note that you do not need to return anything from these subqueries.
2379
+ */
2380
+ (fn: ((a: QLExtensions<T[number]>) => any) | '*'): T[number],
2381
+ }
2382
+ // composition of one/ association to one
2383
+ : {
2384
+
2385
+ /**
2386
+ * @example
2387
+ * ```js
2388
+ * SELECT.from(Books, b => b.author)
2389
+ * ```
2390
+ * means: "select all books and project each book's author"
2391
+ *
2392
+ * whereas
2393
+ * ```js
2394
+ * SELECT.from(Books, b => b.author(a => a.ID))
2395
+ * ```
2396
+ * means: "select all books, subselect each book's author's ID
2397
+ *
2398
+ * Note that you do not need to return anything from these subqueries.
2399
+ */
2400
+ (fn: ((a: QLExtensions<T>) => any) | '*'): T,
2401
+ }
2402
+
2403
+ declare type TaggedTemplateQueryPart<T> = (strings: TemplateStringsArray, ...params: unknown[]) => T
2404
+
2405
+ /**
2406
+ * Target for any QL operation
2407
+ */
2408
+ declare type Target = linked_2.entity | Definition_2 | string
2409
+
2410
+ declare class Test extends Axios {
2411
+
2412
+ test: Test
2413
+
2414
+ run (cmd: string, ...args: string[]): this
2415
+
2416
+ in (...paths: string[]): this
2417
+
2418
+ silent (): this
2419
+
2420
+ /**
2421
+ * @deprecated Server log is shown by default. Use `log()` to get control over it.
2422
+ */
2423
+ verbose (v: boolean): this
2424
+
2425
+ get chai (): typeof chai
2426
+
2427
+ get expect (): typeof chai.expect
2428
+
2429
+ get assert (): typeof chai.assert
2430
+
2431
+ get data (): DataUtil
2432
+
2433
+ get cds (): _cds_2
2434
+
2435
+ log (): {
2436
+ output: string,
2437
+ clear(): void,
2438
+ release(): void,
2439
+ }
2440
+
2441
+ then (r: (args: { server: http.Server, url: string }) => void): void
2442
+
2443
+ // get sleep(): (ms: number) => Promise<void>;
2444
+ // get spy(): <T, K extends keyof T>(o: T, f: K) => T[K] extends (...args: infer TArgs) => infer TReturnValue
2445
+ // ? Spy<TArgs, TReturnValue>
2446
+ // : Spy;
2447
+
2448
+ }
2449
+
2450
+ export declare const test: {
2451
+ Test: typeof Test,
2452
+
2453
+ /**
2454
+ * @see [capire docs](https://cap.cloud.sap/docs/node.js/cds-test#class-cds-test-test)
2455
+ */
2456
+ (dirname: string): Test,
2457
+
2458
+ /**
2459
+ * @see [capire docs](https://cap.cloud.sap/docs/node.js/cds-test#class-cds-test-test)
2460
+ */
2461
+ (command: string, ...args: string[]): Test,
2462
+
2463
+ in (dirname: string): Test,
2464
+ };
2465
+
2466
+ export declare class Time extends date { }
2467
+
2468
+ export declare class TimeStamp extends DateTime { }
2469
+
2470
+ /**
2471
+ * DO NOT USE
2472
+ * @internal
2473
+ */
2474
+ export declare type _TODO = any
2475
+
2476
+ export declare interface Transaction extends Service {
2477
+ commit(): Promise<void>
2478
+ rollback(): Promise<void>
2479
+ }
2480
+
2481
+ export declare const transaction: Service['transaction'];
2482
+
2483
+ /**
2484
+ * Starts or joins a transaction
2485
+ * @see [docs](https://cap.cloud.sap/docs/node.js/cds-tx)
2486
+ */
2487
+ export declare const tx: {
2488
+ (fn: (tx: Transaction) => object): Promise<any>,
2489
+ (context?: object): Transaction,
2490
+ (context: object, fn: (tx: Transaction) => object): Promise<any>,
2491
+ };
2492
+
2493
+ export declare interface type extends Omit<csn.type, 'items'> {
2494
+ items: type
2495
+ }
2496
+
2497
+ export declare class type<K extends kinds = 'type'> extends any_<K> { }
2498
+
2499
+ declare interface type_2 extends any__2 {
2500
+ type?: FQN
2501
+ items?: type_2
2502
+ }
2503
+
2504
+ export declare type TypedRequest<T> = Omit<Request_2, 'data'> & { data: T }
2505
+
2506
+ export declare namespace types {
2507
+ export type event = eventName | eventName[]
2508
+ export type eventName = string
2509
+ | 'CREATE' | 'READ' | 'UPDATE' | 'DELETE'
2510
+ | 'NEW' | 'EDIT' | 'PATCH' | 'SAVE'
2511
+ | 'GET' | 'PUT' | 'POST' | 'PATCH' | 'DELETE'
2512
+ | 'COMMIT' | 'ROLLBACK'
2513
+ export type target = string | linked_2.Definition | linked_2.entity | (string | linked_2.Definition | linked_2.entity)[] | ArrayConstructable
2514
+ }
2515
+
2516
+ export declare class UInt8 extends Integer { }
2517
+
2518
+ export declare const unboxed: (service: Service) => Service;
2519
+
2520
+ declare type UnionsToIntersections<U> = Array<UnionToIntersection<Scalarise<U>>>
2521
+
2522
+ declare type UnionToIntersection<U> = Partial<(U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never>
2523
+
2524
+ declare type Unwrap<T> = T extends ArrayConstructable
2525
+ ? SingularType<T>
2526
+ : T extends Array<infer U>
2527
+ ? U
2528
+ : T
2529
+
2530
+ export declare const update: Service['update'];
2531
+
2532
+ declare type UPDATE_2 = { UPDATE: {
2533
+ entity: ref | name,
2534
+ data: { [key: string]: expr },
2535
+ where?: predicate,
2536
+ }, }
2537
+ export { UPDATE_2 as UPDATE }
2538
+
2539
+ declare class UPDATE_3<T> extends ConstructedQuery {
2540
+
2541
+ // cds-typer plural
2542
+ static entity<T extends ArrayConstructable<any>> (entity: T, primaryKey?: PK): UPDATE_3<SingularType<T>>
2543
+
2544
+ static entity (entity: Target, primaryKey?: PK): UPDATE_3<any>
2545
+
2546
+ static entity<T> (entity: Constructable<T>, primaryKey?: PK): UPDATE_3<T>
2547
+
2548
+ static entity<T> (entity: T, primaryKey?: PK): UPDATE_3<T>
2549
+
2550
+ byKey (primaryKey?: PK): this
2551
+ // with (block: (e:T)=>void) : this
2552
+ // set (block: (e:T)=>void) : this
2553
+ set: TaggedTemplateQueryPart<this>
2554
+ & ((data: object) => this);
2555
+
2556
+ with: TaggedTemplateQueryPart<this>
2557
+ & ((data: object) => this)
2558
+
2559
+ where (predicate: object): this
2560
+
2561
+ where (...expr: any[]): this
2562
+
2563
+ and (predicate: object): this
2564
+
2565
+ and (...expr: any[]): this
2566
+ UPDATE: CQN.UPDATE['UPDATE']
2567
+
2568
+ }
2569
+
2570
+ declare type UPSERT_2 = { UPSERT: {
2571
+ into: ref | name,
2572
+ columns: string[],
2573
+ entries: data[],
2574
+ values: primitive[],
2575
+ rows: primitive[][],
2576
+ }, }
2577
+ export { UPSERT_2 as UPSERT }
2578
+
2579
+ declare class UPSERT_3<T> extends ConstructedQuery {
2580
+
2581
+ static into: (<T extends ArrayConstructable<any>> (entity: T, entries?: object | object[]) => UPSERT_3<SingularType<T>>)
2582
+ & (TaggedTemplateQueryPart<UPSERT_3<unknown>>)
2583
+ & ((entity: Target, entries?: object | object[]) => UPSERT_3<any>)
2584
+ & (<T> (entity: Constructable<T>, entries?: object | object[]) => UPSERT_3<T>)
2585
+ & (<T> (entity: T, entries?: T | object | object[]) => UPSERT_3<T>)
2586
+
2587
+ into: (<T extends ArrayConstructable> (entity: T) => this)
2588
+ & TaggedTemplateQueryPart<this>
2589
+ & ((entity: Target) => this)
2590
+
2591
+ data (block: (e: T) => void): this
2592
+
2593
+ entries (...entries: object[]): this
2594
+
2595
+ columns (...col: (T extends ArrayConstructable<any> ? keyof SingularType<T> : keyof T)[]): this
2596
+
2597
+ columns (...col: string[]): this
2598
+
2599
+ values (...val: any[]): this
2600
+
2601
+ rows (...row: any[]): this
2602
+ UPSERT: CQN.UPSERT['UPSERT']
2603
+
2604
+ }
2605
+
2606
+ /**
2607
+ * Represents the user in a given context.
2608
+ * @see [capire docs](https://cap.cloud.sap/docs/node.js/authentication#cds-user)
2609
+ */
2610
+ export declare class User {
2611
+
2612
+ constructor (obj?: string | { id: string, attr: Record<string, string>, roles: Array<string> | Record<string, string> } | User)
2613
+ id: string
2614
+
2615
+ /**
2616
+ * @deprecated Use https://cap.cloud.sap/docs/node.js/events#locale instead
2617
+ */
2618
+ locale: string
2619
+
2620
+ /**
2621
+ * @deprecated Use https://cap.cloud.sap/docs/node.js/events#tenant instead
2622
+ */
2623
+ tenant: string | undefined
2624
+
2625
+ attr: Record<string, string>
2626
+
2627
+ roles: Array<string> | Record<string, string>
2628
+
2629
+ static Privileged: typeof Privileged
2630
+
2631
+ is (role: string): boolean
2632
+
2633
+ }
2634
+
2635
+ /**
2636
+ * Provides a set of utility functionss
2637
+ */
2638
+ export declare const utils: {
2639
+
2640
+ /**
2641
+ * Generates a new v4 UUID
2642
+ * @see https://cap.cloud.sap/docs/node.js/cds-facade#cds-utils
2643
+ */
2644
+ uuid (): string,
2645
+
2646
+ /**
2647
+ * @see https://cap.cloud.sap/docs/node.js/cds-utils#decodeuri
2648
+ */
2649
+ decodeURI(input: string): string,
2650
+
2651
+ /**
2652
+ * @see https://cap.cloud.sap/docs/node.js/cds-utils#decodeuricomponent
2653
+ */
2654
+ decodeURIComponent(input: string): string,
2655
+
2656
+ /**
2657
+ * @see https://cap.cloud.sap/docs/node.js/cds-utils#local-filename
2658
+ */
2659
+ local(filename: string): string,
2660
+
2661
+ /**
2662
+ * @see https://cap.cloud.sap/docs/node.js/cds-utils#exists-file
2663
+ */
2664
+ exists(file: string): boolean,
2665
+
2666
+ /**
2667
+ * @see https://cap.cloud.sap/docs/node.js/cds-utils#isdir-file
2668
+ */
2669
+ isdir(file: string): string,
2670
+
2671
+ /**
2672
+ * @see https://cap.cloud.sap/docs/node.js/cds-utils#isdir-file
2673
+ */
2674
+ isfile(file: string): string,
2675
+
2676
+ /**
2677
+ * @see https://cap.cloud.sap/docs/node.js/cds-utils#async-read-file
2678
+ */
2679
+ read(file: string): Promise<Buffer | object>,
2680
+
2681
+ /**
2682
+ * @see https://cap.cloud.sap/docs/node.js/cds-utils#async-write-data-to-file
2683
+ */
2684
+ write: {
2685
+ (data: object): {
2686
+ to(...file: string[]): Promise<ReturnType<typeof fs.promises.writeFile>>,
2687
+ },
2688
+ (file: string, data: object): Promise<ReturnType<typeof fs.promises.writeFile>>,
2689
+ },
2690
+
2691
+ /**
2692
+ * @see https://cap.cloud.sap/docs/node.js/cds-utils#async-copy-src-to-dst
2693
+ */
2694
+ copy: {
2695
+ (src: string): {
2696
+ to(...dst: string[]): Promise<ReturnType<typeof fs.promises.copyFile>>,
2697
+ },
2698
+ (dst: string, src: string): Promise<ReturnType<typeof fs.promises.copyFile>>,
2699
+ },
2700
+
2701
+ /**
2702
+ * @see https://cap.cloud.sap/docs/node.js/cds-utils#async-mkdirp-path
2703
+ */
2704
+ mkdirp: (...path: string[]) => Promise<string>,
2705
+
2706
+ /**
2707
+ * @see https://cap.cloud.sap/docs/node.js/cds-utils#async-rmdir-path
2708
+ */
2709
+ rmdir: (...path: string[]) => Promise<ReturnType<typeof fs.promises.rm>>,
2710
+
2711
+
2712
+ /**
2713
+ * @see https://cap.cloud.sap/docs/node.js/cds-utils#async-rimraf-path
2714
+ */
2715
+ rimraf: (...path: string[]) => Promise<ReturnType<typeof fs.promises.rm>>,
2716
+
2717
+
2718
+ /**
2719
+ * @see https://cap.cloud.sap/docs/node.js/cds-utils#async-rm-path
2720
+ */
2721
+ rm: (...path: string[]) => Promise<ReturnType<typeof fs.promises.rm>>,
2722
+ };
2723
+
2724
+ export declare class UUID extends string { }
2725
+
2726
+ /** @private */
2727
+ export declare type val = { val: any }
2728
+
2729
+ export declare class Vector extends Binary { }
2730
+
2731
+ export declare const version: string;
2732
+
2733
+ declare type Visitor = (def: any_, name: string, parent: any_, defs: Definitions) => void
2734
+
2735
+ export declare interface WithElements {
2736
+ elements: Definitions<type>
2737
+ }
2738
+
2739
+ /**
2740
+ * https://stackoverflow.com/a/53229567
2741
+ * @internal
2742
+ */
2743
+ declare type Without<T, U> = { [P in Exclude<keyof T, keyof U>]?: never }
2744
+
2745
+ export declare type XML = string
2746
+
2747
+ /** @internal */
2748
+ declare type XOR<T, U> = (T | U) extends object ? (Without<T, U> & U) | (Without<U, T> & T) : T | U
2749
+
2750
+ /** @private */
2751
+ export declare type xpr = { xpr: _xpr }
2752
+
2753
+ /** @private */
2754
+ export declare type _xpr = (expr | operator) []
2755
+
2756
+ export declare type YAML = string
2757
+
2758
+ export { }
2759
+
2760
+ declare global {
2761
+ // these provide the functionality from SELECT, INSERT, etc in the global facade
2762
+ const SELECT: ql.QL<any>['SELECT']
2763
+ const INSERT: ql.QL<any>['INSERT']
2764
+ const UPSERT: ql.QL<any>['UPSERT']
2765
+ const UPDATE: ql.QL<any>['UPDATE']
2766
+ const DELETE: ql.QL<any>['DELETE']
2767
+ const CREATE: ql.QL<any>['CREATE']
2768
+ const DROP: ql.QL<any>['DROP']
2769
+
2770
+ // and these allow us to use them as type too, i.e. `const q: SELECT<Book> = ...`
2771
+ type SELECT<T> = ql.SELECT<T>
2772
+ type INSERT<T> = ql.INSERT<T>
2773
+ type UPSERT<T> = ql.UPSERT<T>
2774
+ type UPDATE<T> = ql.UPDATE<T>
2775
+ type DELETE<T> = ql.DELETE<T>
2776
+ type CREATE<T> = ql.CREATE<T>
2777
+ type DROP<T> = ql.DROP<T>
2778
+ }