@sap/cds-compiler 2.11.2 → 2.13.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +175 -2
- package/bin/.eslintrc.json +1 -2
- package/bin/cds_update_identifiers.js +10 -8
- package/bin/cdsc.js +23 -17
- package/bin/cdsse.js +2 -2
- package/bin/cdsv2m.js +3 -2
- package/doc/CHANGELOG_ARCHIVE.md +1 -1
- package/doc/CHANGELOG_BETA.md +25 -6
- package/doc/CHANGELOG_DEPRECATED.md +22 -6
- package/doc/NameResolution.md +21 -16
- package/lib/api/main.js +32 -79
- package/lib/api/options.js +3 -2
- package/lib/api/validate.js +2 -1
- package/lib/backends.js +16 -26
- package/lib/base/dictionaries.js +0 -8
- package/lib/base/error.js +26 -0
- package/lib/base/keywords.js +10 -19
- package/lib/base/location.js +9 -4
- package/lib/base/message-registry.js +75 -9
- package/lib/base/messages.js +31 -35
- package/lib/base/model.js +2 -62
- package/lib/base/optionProcessorHelper.js +246 -183
- package/lib/checks/.eslintrc.json +2 -0
- package/lib/checks/actionsFunctions.js +2 -1
- package/lib/checks/annotationsOData.js +1 -1
- package/lib/checks/cdsPersistence.js +2 -1
- package/lib/checks/emptyOrOnlyVirtual.js +2 -2
- package/lib/checks/enricher.js +17 -1
- package/lib/checks/foreignKeys.js +4 -4
- package/lib/checks/invalidTarget.js +3 -1
- package/lib/checks/managedInType.js +4 -4
- package/lib/checks/managedWithoutKeys.js +3 -1
- package/lib/checks/queryNoDbArtifacts.js +1 -3
- package/lib/checks/selectItems.js +4 -4
- package/lib/checks/sql-snippets.js +94 -0
- package/lib/checks/types.js +1 -1
- package/lib/checks/unknownMagic.js +1 -1
- package/lib/checks/validator.js +12 -7
- package/lib/compiler/assert-consistency.js +12 -8
- package/lib/compiler/base.js +0 -1
- package/lib/compiler/builtins.js +42 -21
- package/lib/compiler/checks.js +46 -12
- package/lib/compiler/cycle-detector.js +1 -1
- package/lib/compiler/define.js +1103 -0
- package/lib/compiler/extend.js +983 -0
- package/lib/compiler/finalize-parse-cdl.js +231 -0
- package/lib/compiler/index.js +46 -39
- package/lib/compiler/kick-start.js +190 -0
- package/lib/compiler/moduleLayers.js +4 -4
- package/lib/compiler/populate.js +1226 -0
- package/lib/compiler/propagator.js +113 -47
- package/lib/compiler/resolve.js +1433 -0
- package/lib/compiler/shared.js +100 -65
- package/lib/compiler/tweak-assocs.js +529 -0
- package/lib/compiler/utils.js +215 -33
- package/lib/edm/.eslintrc.json +5 -0
- package/lib/edm/annotations/genericTranslation.js +38 -25
- package/lib/edm/annotations/preprocessAnnotations.js +3 -3
- package/lib/edm/csn2edm.js +10 -9
- package/lib/edm/edm.js +19 -20
- package/lib/edm/edmPreprocessor.js +166 -95
- package/lib/edm/edmUtils.js +127 -34
- package/lib/gen/Dictionary.json +92 -43
- package/lib/gen/language.checksum +1 -1
- package/lib/gen/language.interp +11 -1
- package/lib/gen/language.tokens +86 -82
- package/lib/gen/languageLexer.interp +18 -1
- package/lib/gen/languageLexer.js +925 -847
- package/lib/gen/languageLexer.tokens +78 -74
- package/lib/gen/languageParser.js +5434 -4298
- package/lib/json/from-csn.js +59 -17
- package/lib/json/to-csn.js +189 -71
- package/lib/language/antlrParser.js +3 -3
- package/lib/language/docCommentParser.js +3 -3
- package/lib/language/errorStrategy.js +26 -8
- package/lib/language/genericAntlrParser.js +144 -53
- package/lib/language/language.g4 +424 -200
- package/lib/language/multiLineStringParser.js +536 -0
- package/lib/main.d.ts +550 -61
- package/lib/main.js +38 -11
- package/lib/model/api.js +3 -1
- package/lib/model/csnRefs.js +322 -198
- package/lib/model/csnUtils.js +226 -370
- package/lib/model/enrichCsn.js +124 -69
- package/lib/model/revealInternalProperties.js +29 -7
- package/lib/model/sortViews.js +10 -2
- package/lib/modelCompare/compare.js +17 -12
- package/lib/optionProcessor.js +8 -3
- package/lib/render/.eslintrc.json +1 -2
- package/lib/render/DuplicateChecker.js +1 -1
- package/lib/render/manageConstraints.js +36 -33
- package/lib/render/toCdl.js +174 -275
- package/lib/render/toHdbcds.js +203 -122
- package/lib/render/toRename.js +7 -10
- package/lib/render/toSql.js +161 -82
- package/lib/render/utils/common.js +22 -8
- package/lib/render/utils/sql.js +10 -7
- package/lib/render/utils/stringEscapes.js +111 -0
- package/lib/sql-identifier.js +1 -1
- package/lib/transform/.eslintrc.json +5 -0
- package/lib/transform/braceExpression.js +4 -2
- package/lib/transform/db/.eslintrc.json +2 -0
- package/lib/transform/db/applyTransformations.js +212 -0
- package/lib/transform/db/assertUnique.js +1 -1
- package/lib/transform/db/associations.js +187 -0
- package/lib/transform/db/cdsPersistence.js +150 -0
- package/lib/transform/db/constraints.js +61 -56
- package/lib/transform/db/expansion.js +50 -29
- package/lib/transform/db/flattening.js +556 -106
- package/lib/transform/db/groupByOrderBy.js +3 -1
- package/lib/transform/db/temporal.js +236 -0
- package/lib/transform/db/transformExists.js +103 -28
- package/lib/transform/db/views.js +92 -44
- package/lib/transform/draft/.eslintrc.json +38 -0
- package/lib/transform/{db/draft.js → draft/db.js} +9 -7
- package/lib/transform/draft/odata.js +227 -0
- package/lib/transform/forHanaNew.js +98 -783
- package/lib/transform/forOdataNew.js +22 -175
- package/lib/transform/localized.js +36 -32
- package/lib/transform/odata/generateForeignKeyElements.js +3 -3
- package/lib/transform/odata/referenceFlattener.js +95 -89
- package/lib/transform/odata/structureFlattener.js +1 -1
- package/lib/transform/odata/toFinalBaseType.js +86 -12
- package/lib/transform/odata/typesExposure.js +5 -5
- package/lib/transform/odata/utils.js +2 -2
- package/lib/transform/transformUtilsNew.js +47 -33
- package/lib/transform/translateAssocsToJoins.js +13 -30
- package/lib/transform/universalCsn/.eslintrc.json +36 -0
- package/lib/transform/universalCsn/coreComputed.js +170 -0
- package/lib/transform/universalCsn/universalCsnEnricher.js +715 -0
- package/lib/transform/universalCsn/utils.js +63 -0
- package/lib/utils/file.js +8 -3
- package/lib/utils/objectUtils.js +30 -0
- package/lib/utils/timetrace.js +8 -2
- package/package.json +1 -1
- package/share/messages/README.md +26 -0
- package/lib/compiler/definer.js +0 -2349
- package/lib/compiler/resolver.js +0 -2922
- package/lib/transform/db/helpers.js +0 -58
- package/lib/transform/universalCsnEnricher.js +0 -67
package/lib/main.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
// These types are improved step by step and use a lot any types at the moment.
|
|
6
6
|
|
|
7
7
|
// Author's note: All "options" interfaces should actually be types. However, due to
|
|
8
|
-
// https://github.com/TypeStrong/typedoc/issues/1519 we can't use
|
|
8
|
+
// <https://github.com/TypeStrong/typedoc/issues/1519> we can't use
|
|
9
9
|
// intersection types at the moment.
|
|
10
10
|
|
|
11
11
|
export = compiler;
|
|
@@ -59,6 +59,36 @@ declare namespace compiler {
|
|
|
59
59
|
* Dictionaries are e.g. "definitions" and "elements".
|
|
60
60
|
*/
|
|
61
61
|
dictionaryPrototype?: any
|
|
62
|
+
/**
|
|
63
|
+
* CSN Flavor: The compiler supports different CSN flavors. Backends may support
|
|
64
|
+
* different flavors. This option is mainly used in `compile()`.
|
|
65
|
+
* Flavors are:
|
|
66
|
+
* - client : (default) Standard CSN consumable by clients and backends.
|
|
67
|
+
* - gensrc : CSN specifically for use as a source, e.g. for combination with
|
|
68
|
+
* additional "extend" or "annotate" statements, but not suitable
|
|
69
|
+
* for consumption by clients or backends.
|
|
70
|
+
* - universal : In development (BETA)
|
|
71
|
+
*/
|
|
72
|
+
csnFlavor?: string | 'client' | 'gensrc' | 'universal'
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Options relevant for compilation and parsing of CDL and CSN files.
|
|
77
|
+
*/
|
|
78
|
+
export interface CompileOptions extends Options {
|
|
79
|
+
/**
|
|
80
|
+
* If the given filename does not have a known file extension,
|
|
81
|
+
* use this frontend as the fallback parser.
|
|
82
|
+
*/
|
|
83
|
+
fallbackParser?: string | 'cdl' | 'csn'
|
|
84
|
+
/**
|
|
85
|
+
* Option for {@link compileSources}. If set, all objects inside the
|
|
86
|
+
* provided sources dictionary are interpreted as XSN structures instead
|
|
87
|
+
* of CSN, i.e. a compiler-internal representation.
|
|
88
|
+
*
|
|
89
|
+
* @since v2.12.1
|
|
90
|
+
*/
|
|
91
|
+
$xsnObjects?: boolean
|
|
62
92
|
}
|
|
63
93
|
|
|
64
94
|
/**
|
|
@@ -157,6 +187,168 @@ declare namespace compiler {
|
|
|
157
187
|
serviceNames?: string[]
|
|
158
188
|
}
|
|
159
189
|
|
|
190
|
+
/**
|
|
191
|
+
* Options used by SQL `to.sql()` backend.
|
|
192
|
+
*
|
|
193
|
+
* @see to.sql()
|
|
194
|
+
*/
|
|
195
|
+
export interface SqlOptions extends Options {
|
|
196
|
+
/**
|
|
197
|
+
* The SQL naming mode decides how names are represented.
|
|
198
|
+
* Among others, this includes whether identifiers are quoted or not (note
|
|
199
|
+
* that "smart quoting" is handled by `sqlDialect`).
|
|
200
|
+
*
|
|
201
|
+
* - `plain`:
|
|
202
|
+
* In this naming mode, dots are replaced by underscores.
|
|
203
|
+
* Names are neither upper-cased nor quoted, unless "smart-quoting" is used.
|
|
204
|
+
* This mode can be used with all SQL dialects.
|
|
205
|
+
* - `quoted`:
|
|
206
|
+
* In this mode, all identifiers are quoted. Dots are not replaced in table
|
|
207
|
+
* and view names but are still replaced by underscores in element names.
|
|
208
|
+
* This mode can only be used with SQL dialect `hana`.
|
|
209
|
+
* - `hdbcds`:
|
|
210
|
+
* This mode uses names that are compatible to SAP HANA CDS.
|
|
211
|
+
* In this mode, all identifiers are quoted. Dots are neither replaced in table
|
|
212
|
+
* nor element names. Namespace identifiers are separated from the remaining
|
|
213
|
+
* identifier by `::`, i.e. the dot is replaced. For example `Ns.Books`
|
|
214
|
+
* becomes `"Ns::Books"`.
|
|
215
|
+
* This mode can only be used with SQL dialect `hana`.
|
|
216
|
+
*
|
|
217
|
+
* @default 'plain'
|
|
218
|
+
*/
|
|
219
|
+
sqlMapping?: string | 'plain' | 'quoted' | 'hdbcds'
|
|
220
|
+
/**
|
|
221
|
+
* Use this option to specify what dialect of SQL you want.
|
|
222
|
+
*
|
|
223
|
+
* Different databases may support different feature sets of SQL.
|
|
224
|
+
* For example, timestamps are handled differently. Furthermore, "smart-quoting"
|
|
225
|
+
* is enabled for `sqlite` and `hana`. This is useful if identifiers
|
|
226
|
+
* collide with reserved keywords.
|
|
227
|
+
*
|
|
228
|
+
* - `plain`:
|
|
229
|
+
* Use this option for best compatibility with standard SQL.
|
|
230
|
+
* Note that "smart-quoting" is not available for this mode.
|
|
231
|
+
* Requires `sqlMapping: 'plain'`.
|
|
232
|
+
* - `sqlite`:
|
|
233
|
+
* This SQL dialect ensures compatibility with SQLite, which may not support
|
|
234
|
+
* all SQL features used in your CDS files. For example, `$at.from`/`$at.to` are
|
|
235
|
+
* handled differently to ensure correctness for SQLite. "smart-quoting"
|
|
236
|
+
* quotes identifiers that are reserved keywords, but does not upper-case them.
|
|
237
|
+
* Requires `sqlMapping: 'plain'`.
|
|
238
|
+
* - `hana`:
|
|
239
|
+
* Use this SQL dialect for best compatibility with SAP HANA.
|
|
240
|
+
* "smart-quoting" upper-cases and quotes identifiers.
|
|
241
|
+
*
|
|
242
|
+
* @default 'plain'
|
|
243
|
+
*/
|
|
244
|
+
sqlDialect?: string | 'plain' | 'sqlite' | 'hana'
|
|
245
|
+
/**
|
|
246
|
+
* Object containing magic variables. These magic variables are
|
|
247
|
+
* used as placeholder values.
|
|
248
|
+
*
|
|
249
|
+
* @since 2.11.0
|
|
250
|
+
*/
|
|
251
|
+
variableReplacements?: {
|
|
252
|
+
[option: string]: string | object,
|
|
253
|
+
/**
|
|
254
|
+
* Commonly used placeholders for user's name and locale.
|
|
255
|
+
*/
|
|
256
|
+
$user?: {
|
|
257
|
+
[option: string]: string | object,
|
|
258
|
+
id?: string
|
|
259
|
+
locale?: string
|
|
260
|
+
},
|
|
261
|
+
/**
|
|
262
|
+
* Commonly used placeholders for session variables.
|
|
263
|
+
*/
|
|
264
|
+
$session?: Record<string, string | object>
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* Options used by to.hdbcds()
|
|
270
|
+
*/
|
|
271
|
+
export interface HdbcdsOptions extends Options {
|
|
272
|
+
/**
|
|
273
|
+
* The SQL naming mode decides how names are represented.
|
|
274
|
+
* Among others, this includes whether identifiers are quoted or not.
|
|
275
|
+
*
|
|
276
|
+
* - `plain`:
|
|
277
|
+
* In this naming mode, dots are replaced by underscores.
|
|
278
|
+
* Identifiers are always uppercased. If "smart-quoting" is used, they are also quoted
|
|
279
|
+
if they are also HDBCDS keywords.
|
|
280
|
+
* - `quoted`:
|
|
281
|
+
* In this mode, all identifiers are quoted. Dots are not replaced in table
|
|
282
|
+
* and view names but are still replaced by underscores in element names.
|
|
283
|
+
* Identifier casing is kept as specified in the source.
|
|
284
|
+
* - `hdbcds`:
|
|
285
|
+
* This mode uses names that are compatible to SAP HANA CDS.
|
|
286
|
+
* In this mode, all identifiers are quoted. Dots are neither replaced in table
|
|
287
|
+
* nor element names: Structured elements persist, contexts are nested.
|
|
288
|
+
* Managed associations/compositions are left as-is. No association-to-join-translation
|
|
289
|
+
* is done.
|
|
290
|
+
*
|
|
291
|
+
* @default 'plain'
|
|
292
|
+
*/
|
|
293
|
+
sqlMapping?: string | 'plain' | 'quoted' | 'hdbcds'
|
|
294
|
+
/**
|
|
295
|
+
* For to.hdbcds(), the SQL dialect is always set to 'hana'.
|
|
296
|
+
*/
|
|
297
|
+
sqlDialect?: 'hana'
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
/**
|
|
301
|
+
* Options used by to.hdi() and to.hdi.migration()
|
|
302
|
+
*/
|
|
303
|
+
export interface HdiOptions extends Options {
|
|
304
|
+
/**
|
|
305
|
+
* The SQL naming mode decides how names are represented.
|
|
306
|
+
* Among others, this includes whether identifiers are quoted or not.
|
|
307
|
+
*
|
|
308
|
+
* - `plain`:
|
|
309
|
+
* In this naming mode, dots are replaced by underscores.
|
|
310
|
+
* Names are neither upper-cased nor quoted, unless "smart-quoting" is used.
|
|
311
|
+
* - `quoted`:
|
|
312
|
+
* In this mode, all identifiers are quoted. Dots are not replaced in table
|
|
313
|
+
* and view names but are still replaced by underscores in element names.
|
|
314
|
+
* - `hdbcds`:
|
|
315
|
+
* This mode uses names that are compatible to SAP HANA CDS.
|
|
316
|
+
* In this mode, all identifiers are quoted. Dots are neither replaced in table
|
|
317
|
+
* nor element names. Namespace identifiers are separated from the remaining
|
|
318
|
+
* identifier by `::`, i.e. the dot is replaced. For example `Ns.Books`
|
|
319
|
+
* becomes `"Ns::Books"`.
|
|
320
|
+
*
|
|
321
|
+
* @default 'plain'
|
|
322
|
+
*/
|
|
323
|
+
sqlMapping?: string | 'plain' | 'quoted' | 'hdbcds'
|
|
324
|
+
/**
|
|
325
|
+
* For to.hdi(), the SQL dialect is always set to 'hana'.
|
|
326
|
+
*/
|
|
327
|
+
sqlDialect?: 'hana'
|
|
328
|
+
/**
|
|
329
|
+
* Only for to.hdi.migration().
|
|
330
|
+
* SQL change mode to use (for changed columns).
|
|
331
|
+
*
|
|
332
|
+
* @default 'alter'
|
|
333
|
+
*/
|
|
334
|
+
sqlChangeMode?: string | 'alter' | 'drop'
|
|
335
|
+
/**
|
|
336
|
+
* Only for `to.hdi.migration`. If `true`, `to.hdi.migration` allows that the two
|
|
337
|
+
* passed CSNs are of different CSN versions. Use at own risk.
|
|
338
|
+
*
|
|
339
|
+
* @default false
|
|
340
|
+
*/
|
|
341
|
+
allowCsnDowngrade?: boolean
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
/**
|
|
345
|
+
* Options used by `to.cdl()` backend.
|
|
346
|
+
*
|
|
347
|
+
* @note `to.cdl()` currently has no specific options.
|
|
348
|
+
* @see to.cdl()
|
|
349
|
+
*/
|
|
350
|
+
export interface CdlOptions extends Options {}
|
|
351
|
+
|
|
160
352
|
/**
|
|
161
353
|
* The compiler's package version.
|
|
162
354
|
* For more details on versioning and SemVer, see `doc/Versioning.md`
|
|
@@ -167,7 +359,7 @@ declare namespace compiler {
|
|
|
167
359
|
* Main function: Compile the sources from the files given by the array of
|
|
168
360
|
* `filenames`. As usual with the `fs` library, relative file names are
|
|
169
361
|
* relative to the working directory `process.cwd()`. With argument `dir`, the
|
|
170
|
-
* file names are relative to `process.cwd()+dir
|
|
362
|
+
* file names are relative to `process.cwd()+dir` (or just `dir` if it is absolute).
|
|
171
363
|
*
|
|
172
364
|
* This function returns a Promise and can be used with `await`. For an example
|
|
173
365
|
* see `examples/api-usage/`.
|
|
@@ -185,15 +377,32 @@ declare namespace compiler {
|
|
|
185
377
|
* @param filenames Array of files that should be compiled.
|
|
186
378
|
* @param dir Working directory. Relative paths in `filenames` will be resolved relatively to this directory.
|
|
187
379
|
* @param options Compiler options. If you do not set `messages`, they will be printed to console.
|
|
188
|
-
* @param fileCache
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
380
|
+
* @param fileCache
|
|
381
|
+
*/
|
|
382
|
+
export function compile(filenames: string[], dir?: string, options?: CompileOptions, fileCache?: FileCache): Promise<CSN>;
|
|
383
|
+
|
|
384
|
+
/**
|
|
385
|
+
* Synchronous version of {@link compile}.
|
|
386
|
+
* Usage is discouraged. Use the asynchronous version if possible.
|
|
387
|
+
*
|
|
388
|
+
* @see compile
|
|
389
|
+
*/
|
|
390
|
+
export function compileSync(filenames: string[], dir?: string, options?: CompileOptions, fileCache?: FileCache): CSN;
|
|
391
|
+
|
|
392
|
+
/**
|
|
393
|
+
* Synchronously compiles the given sources.
|
|
394
|
+
*
|
|
395
|
+
* Argument `sourcesDict` is a dictionary mapping filenames to either source texts (string)
|
|
396
|
+
* or JavaScript objects, which are usually CSNs, or XSNs (compiler internal AST-like augmented CSNs).
|
|
397
|
+
* The latter requires option `$xsnObjects` to be set to `true`.
|
|
398
|
+
* It could also be a simple string, which is then considered to be the source
|
|
399
|
+
* text of a file named `<stdin>.cds`.
|
|
400
|
+
*
|
|
401
|
+
* See function {@link compile} for the meaning of the argument `options`. If there
|
|
402
|
+
* are parse or other compilation errors, throws an exception {@link CompilationError}
|
|
403
|
+
* containing a list of individual errors.
|
|
193
404
|
*/
|
|
194
|
-
export function
|
|
195
|
-
export function compileSync(filenames: string[], dir?: string, options?: Options, fileCache?: Record<string, any>): any;
|
|
196
|
-
export function compileSources(sourcesDict: any, options?: Options): any;
|
|
405
|
+
export function compileSources(sourcesDict: Record<string, string|object> | string, options?: CompileOptions): CSN;
|
|
197
406
|
|
|
198
407
|
/**
|
|
199
408
|
* In version 2 of cds-compiler, this is an identity function and
|
|
@@ -202,11 +411,17 @@ declare namespace compiler {
|
|
|
202
411
|
* @deprecated
|
|
203
412
|
* @returns The input parameter "csn".
|
|
204
413
|
*/
|
|
205
|
-
export function compactModel(csn: CSN):
|
|
414
|
+
export function compactModel(csn: CSN): CSN;
|
|
206
415
|
|
|
416
|
+
/**
|
|
417
|
+
* Exception thrown by the compiler if errors are encountered.
|
|
418
|
+
*
|
|
419
|
+
* Note that compiler functions (e.g. renderers) may not always throw if errors are encountered.
|
|
420
|
+
* You always need to check the option's `messages` array for a {@link CompileMessage} of severity 'Error'.
|
|
421
|
+
*/
|
|
207
422
|
export class CompilationError extends Error {
|
|
208
|
-
constructor(messages:
|
|
209
|
-
messages:
|
|
423
|
+
constructor(messages: CompileMessage[], model?: any, text?: string, ...args: any[]);
|
|
424
|
+
messages: CompileMessage[];
|
|
210
425
|
toString(): string;
|
|
211
426
|
/**
|
|
212
427
|
* If `options.attachValidNames` is set, this non-enumerable property holds the CSN model.
|
|
@@ -220,6 +435,15 @@ declare namespace compiler {
|
|
|
220
435
|
hasBeenReported: boolean;
|
|
221
436
|
}
|
|
222
437
|
|
|
438
|
+
/**
|
|
439
|
+
* Exception thrown by the compiler if {@link compile} and its variants are invoked incorrectly.
|
|
440
|
+
* For example, this error is thrown if the same file is passed to {@link compile} twice.
|
|
441
|
+
*/
|
|
442
|
+
export class InvocationError extends Error {
|
|
443
|
+
constructor(errs: any, ...args: any[]);
|
|
444
|
+
errors: any[]
|
|
445
|
+
}
|
|
446
|
+
|
|
223
447
|
/**
|
|
224
448
|
* Sort the given messages according to their location. Messages are sorted
|
|
225
449
|
* in ascending order according to their:
|
|
@@ -318,7 +542,7 @@ declare namespace compiler {
|
|
|
318
542
|
* @param config.withLineSpacer If true, an additional line (with `|`) will be inserted between message and location.
|
|
319
543
|
* @param config.color If true, ANSI escape codes will be used for coloring the severity. If false, no
|
|
320
544
|
* coloring will be used. If 'auto', we will decide based on certain factors such
|
|
321
|
-
* as whether the shell is a TTY and whether the environment variable
|
|
545
|
+
* as whether the shell is a TTY and whether the environment variable `NO_COLOR` is
|
|
322
546
|
* unset.
|
|
323
547
|
*/
|
|
324
548
|
export function messageStringMultiline(msg: CompileMessage, config?: {
|
|
@@ -350,7 +574,7 @@ declare namespace compiler {
|
|
|
350
574
|
* @param config Configuration for the message context.
|
|
351
575
|
* @param config.color If true, ANSI escape codes will be used for coloring the severity. If false, no
|
|
352
576
|
* coloring will be used. If 'auto', we will decide based on certain factors such
|
|
353
|
-
* as whether the shell is a TTY and whether the environment variable
|
|
577
|
+
* as whether the shell is a TTY and whether the environment variable `NO_COLOR` is
|
|
354
578
|
* unset.
|
|
355
579
|
|
|
356
580
|
*/
|
|
@@ -364,28 +588,39 @@ declare namespace compiler {
|
|
|
364
588
|
* If the message explanation does not exist, an exception is thrown.
|
|
365
589
|
*
|
|
366
590
|
* @throws May throw an ENOENT error if the message explanation cannot be found.
|
|
367
|
-
* @see
|
|
591
|
+
* @see hasMessageExplanation
|
|
368
592
|
*/
|
|
369
593
|
export function explainMessage(messageId: string): string;
|
|
370
594
|
/**
|
|
371
595
|
* Returns `true` if the given messageId has an explanatory text.
|
|
372
|
-
* Contrary to {@link explainMessage}, this function does not
|
|
373
|
-
*
|
|
596
|
+
* Contrary to {@link explainMessage}, this function does not do
|
|
597
|
+
* any file lookup.
|
|
374
598
|
*/
|
|
375
599
|
export function hasMessageExplanation(messageId: string): boolean;
|
|
376
600
|
|
|
377
|
-
export class InvocationError extends Error {
|
|
378
|
-
constructor(errs: any, ...args);
|
|
379
|
-
errors: any[]
|
|
380
|
-
}
|
|
381
|
-
|
|
382
601
|
/**
|
|
383
|
-
* Returns true if at least one of the given messages is of severity "Error"
|
|
602
|
+
* Returns true if at least one of the given messages is of severity "Error".
|
|
384
603
|
*/
|
|
385
604
|
export function hasErrors(messages: CompileMessage[]): boolean;
|
|
386
605
|
|
|
387
|
-
|
|
388
|
-
|
|
606
|
+
/**
|
|
607
|
+
* Same as {@link to.edm} but expects a {@link for.odata} transformed CSN.
|
|
608
|
+
*
|
|
609
|
+
* Note that parameter `service` is the same as `ODataOptions.service`.
|
|
610
|
+
* The latter is not used. OData specific options have an internal format.
|
|
611
|
+
*
|
|
612
|
+
* @deprecated Use {@link to.edm} instead. If it detects a pre-transformed CSN, it won't run for.odata().
|
|
613
|
+
*/
|
|
614
|
+
export function preparedCsnToEdm(csn: CSN, service: string, options: ODataOptions): object;
|
|
615
|
+
/**
|
|
616
|
+
* Same as {@link to.edm} but expects a {@link for.odata} transformed CSN.
|
|
617
|
+
*
|
|
618
|
+
* Note that parameter `service` is the same as `ODataOptions.service`.
|
|
619
|
+
* The latter is not used. OData specific options have an outdated format.
|
|
620
|
+
*
|
|
621
|
+
* @deprecated Use {@link to.edmx} instead. If it detects a pre-transformed CSN, it won't run for.odata().
|
|
622
|
+
*/
|
|
623
|
+
export function preparedCsnToEdmx(csn: CSN, service: string, options: ODataOptions): string;
|
|
389
624
|
|
|
390
625
|
export namespace parse {
|
|
391
626
|
/**
|
|
@@ -395,89 +630,336 @@ declare namespace compiler {
|
|
|
395
630
|
* @param filename Filename to be used in compiler messages.
|
|
396
631
|
* @param options Compiler options. Note that if `options.messages` is not set, messages will be printed to stderr.
|
|
397
632
|
*/
|
|
398
|
-
function cdl(cdl: string, filename: string, options?: Options):
|
|
633
|
+
function cdl(cdl: string, filename: string, options?: Options): CSN;
|
|
399
634
|
|
|
400
635
|
/**
|
|
401
|
-
* Parse the given CQL and return its corresponding
|
|
636
|
+
* Parse the given CQL and return its corresponding CQN representation.
|
|
402
637
|
*
|
|
403
638
|
* @param cdl CDL source as string.
|
|
404
639
|
* @param filename Filename to be used in compiler messages, default is '<query>.cds'
|
|
405
640
|
* @param options Compiler options. Note that if `options.messages` is not set, messages will be printed to stderr.
|
|
641
|
+
* @returns Returns the CSN representation of the expression, i.e. CDS Query Notation.
|
|
406
642
|
*/
|
|
407
|
-
function cql(cdl: string, filename?: string, options?: Options):
|
|
643
|
+
function cql(cdl: string, filename?: string, options?: Options): CQN;
|
|
408
644
|
|
|
409
645
|
/**
|
|
410
|
-
* Parse the given CDL expression and return its corresponding
|
|
646
|
+
* Parse the given CDL expression and return its corresponding CXN representation.
|
|
411
647
|
*
|
|
412
648
|
* @param cdl CDL source as string.
|
|
413
649
|
* @param filename Filename to be used in compiler messages, default is '<expr>.cds'
|
|
414
650
|
* @param options Compiler options. Note that if `options.messages` is not set, messages will be printed to stderr.
|
|
651
|
+
* @returns Returns the CSN representation of the expression, i.e. CDS Expression Notation.
|
|
415
652
|
*/
|
|
416
|
-
function expr(cdl: string, filename?: string, options?: Options):
|
|
653
|
+
function expr(cdl: string, filename?: string, options?: Options): CXN;
|
|
417
654
|
}
|
|
418
655
|
|
|
419
656
|
/**
|
|
420
657
|
* @deprecated Use {@link parse.cql} instead.
|
|
421
658
|
*/
|
|
422
|
-
export function parseToCqn(
|
|
659
|
+
export function parseToCqn(cql: string, filename?: string, options?: Options): CQN;
|
|
423
660
|
/**
|
|
424
661
|
* @deprecated Use {@link parse.expr} instead.
|
|
425
662
|
*/
|
|
426
|
-
export function parseToExpr(
|
|
663
|
+
export function parseToExpr(expr: string, filename?: string, options?: Options): CXN;
|
|
427
664
|
|
|
428
665
|
/**
|
|
429
|
-
* @
|
|
430
|
-
*
|
|
666
|
+
* @note Actual name is "for" which can't be used directly in the documentation
|
|
667
|
+
* as it is a reserved name in TypeScript.
|
|
668
|
+
*
|
|
669
|
+
* @see for
|
|
431
670
|
*/
|
|
432
|
-
export namespace
|
|
671
|
+
export namespace _for {
|
|
433
672
|
/**
|
|
434
673
|
* Transform the given (generic) CSN into one that is used for OData.
|
|
435
674
|
* Changes include flattening, type resolution and more, according to
|
|
436
675
|
* the provided options.
|
|
437
676
|
*/
|
|
438
|
-
function odata(csn: CSN, options
|
|
677
|
+
function odata(csn: CSN, options?: ODataOptions): CSN;
|
|
439
678
|
}
|
|
440
679
|
|
|
680
|
+
export { _for as for };
|
|
681
|
+
|
|
441
682
|
export namespace to {
|
|
442
|
-
|
|
443
|
-
|
|
683
|
+
/**
|
|
684
|
+
* Renders the given CSN into a CDL source representation.
|
|
685
|
+
*
|
|
686
|
+
* @returns Object containing the rendered model.
|
|
687
|
+
*/
|
|
688
|
+
function cdl(csn: CSN, options?: CdlOptions): CdlResult;
|
|
689
|
+
namespace cdl {
|
|
690
|
+
/**
|
|
691
|
+
* Immutable list of reserved keywords in CDL.
|
|
692
|
+
* These keywords are used for automatic quoting in {@link to.cdl}.
|
|
693
|
+
*/
|
|
694
|
+
const keywords: string[];
|
|
695
|
+
/**
|
|
696
|
+
* Immutable list of CDL functions, used for automatic quoting in {@link to.cdl}.
|
|
697
|
+
* Only relevant for element references of path length 1.
|
|
698
|
+
*/
|
|
699
|
+
const functions: string[];
|
|
700
|
+
}
|
|
444
701
|
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
702
|
+
/**
|
|
703
|
+
* Renders the given CSN into SQL statements such as `CREATE TABLE`, `CREATE VIEW`, etc.
|
|
704
|
+
*
|
|
705
|
+
* @returns Array of SQL statements as strings, tables first, views second and optionally table constraints last.
|
|
706
|
+
*/
|
|
707
|
+
function sql(csn: CSN, options?: SqlOptions): string[];
|
|
708
|
+
namespace sql {
|
|
709
|
+
namespace sqlite {
|
|
710
|
+
/**
|
|
711
|
+
* Immutable list of reserved keywords for SQLite. The list is used by {@link to.sql}.
|
|
712
|
+
* Taken from <http://www.sqlite.org/draft/lang_keywords.html>.
|
|
713
|
+
*/
|
|
714
|
+
const keywords: string[];
|
|
448
715
|
}
|
|
716
|
+
function smartId(name: string, dialect: string) : string;
|
|
717
|
+
function smartFunctionId(name: string, dialect: string) : string;
|
|
718
|
+
function delimitedId(name: string, dialect: string) : string;
|
|
719
|
+
}
|
|
449
720
|
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
721
|
+
/**
|
|
722
|
+
* Renders the given CSN into EDM (JSON format). Requires `options.service` to be set.
|
|
723
|
+
*
|
|
724
|
+
* @returns Rendered EDM as JSON structure.
|
|
725
|
+
*/
|
|
726
|
+
function edm(csn: CSN, options?: ODataOptions): object;
|
|
727
|
+
namespace edm {
|
|
728
|
+
/**
|
|
729
|
+
* Renders the given CSN into EDM (JSON format) for each service.
|
|
730
|
+
* If `options.serviceNames` is not set, all services will be rendered.
|
|
731
|
+
*
|
|
732
|
+
* @returns A map of `{ '<serviceName>': object }` entries.
|
|
733
|
+
*/
|
|
734
|
+
function all(csn: CSN, options: ODataOptions): Record<string, object>;
|
|
735
|
+
}
|
|
454
736
|
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
737
|
+
/**
|
|
738
|
+
* Renders the given CSN into EDMX. Requires `options.service` to be set.
|
|
739
|
+
*
|
|
740
|
+
* @returns Rendered EDMX as string.
|
|
741
|
+
*/
|
|
742
|
+
function edmx(csn: CSN, options: ODataOptions): string;
|
|
743
|
+
namespace edmx {
|
|
744
|
+
/**
|
|
745
|
+
* Renders the given CSN into EDMX for each service.
|
|
746
|
+
* If `options.serviceNames` is not set, all services will be rendered.
|
|
747
|
+
*
|
|
748
|
+
* @returns A map of `{ '<serviceName>': '<xml>' }` entries.
|
|
749
|
+
*/
|
|
750
|
+
function all(csn: CSN, options?: ODataOptions): Record<string, string>;
|
|
751
|
+
}
|
|
752
|
+
|
|
753
|
+
/**
|
|
754
|
+
* Renders the given CSN into HDBCDS artifacts.
|
|
755
|
+
*
|
|
756
|
+
* @returns A map of `{ '<artifactName>.hdbcds|hdbconstraint>': '<content>' }` entries.
|
|
757
|
+
*/
|
|
758
|
+
function hdbcds(csn: CSN, options?: HdbcdsOptions): Record<string, string>;
|
|
759
|
+
namespace hdbcds {
|
|
760
|
+
/**
|
|
761
|
+
* Immutable list of SAP HANA CDS keywords, used for smart quoting in
|
|
762
|
+
* {@link to.hdbcds} with option `sqlMapping: 'plain'`.
|
|
763
|
+
*/
|
|
764
|
+
const keywords: string[];
|
|
765
|
+
}
|
|
766
|
+
|
|
767
|
+
/**
|
|
768
|
+
* Renders the given CSN into HDI statements such as `COLUMN TABLE`, `VIEW`, etc.
|
|
769
|
+
*
|
|
770
|
+
* @returns A map of `{ '<artifactName>.hdbtable|hdbview|hdbconstraint>': '<content>' }` entries.
|
|
771
|
+
*/
|
|
772
|
+
function hdi(csn: CSN, options?: HdiOptions): Record<string, string>;
|
|
773
|
+
namespace hdi {
|
|
774
|
+
/**
|
|
775
|
+
* Immutable list of SAP HANA keywords, used for smart quoting in
|
|
776
|
+
* {@link to.hdi} with option `sqlMapping: 'plain'`.
|
|
777
|
+
* Taken from <https://help.sap.com/viewer/7c78579ce9b14a669c1f3295b0d8ca16/Cloud/en-US/28bcd6af3eb6437892719f7c27a8a285.html>.
|
|
778
|
+
*/
|
|
779
|
+
const keywords: string[];
|
|
780
|
+
|
|
781
|
+
/**
|
|
782
|
+
* Return all changes in artifacts between two given models.
|
|
783
|
+
* Note: Only supports changes in entities (not views etc.) compiled/rendered as HANA-CSN/SQL.
|
|
784
|
+
*
|
|
785
|
+
* @param csn A clean input CSN representing the desired "after-image"
|
|
786
|
+
* @param options Options
|
|
787
|
+
* @param beforeImage A HANA-transformed CSN representing the "before-image", or null in case no such image
|
|
788
|
+
* is known, i.e. for the very first migration step
|
|
789
|
+
* @returns See {@link HdiMigrationResult} for details.
|
|
790
|
+
*/
|
|
791
|
+
function migration(csn: CSN, options: HdiOptions, beforeImage: CSN): HdiMigrationResult;
|
|
792
|
+
}
|
|
460
793
|
}
|
|
461
794
|
|
|
462
|
-
|
|
463
|
-
|
|
795
|
+
/**
|
|
796
|
+
* Result of the `to.cdl()` renderer.
|
|
797
|
+
*/
|
|
798
|
+
export type CdlResult = {
|
|
799
|
+
/**
|
|
800
|
+
* Rendered model, excluding not-applied extensions.
|
|
801
|
+
*/
|
|
802
|
+
model?: string
|
|
803
|
+
/**
|
|
804
|
+
* Rendered extend/annotate statements of `csn.extensions`
|
|
805
|
+
*/
|
|
806
|
+
unappliedExtensions?: string
|
|
807
|
+
/**
|
|
808
|
+
* Rendered csn.namespace property + using directives.
|
|
809
|
+
*/
|
|
810
|
+
[namespace: string]: string
|
|
811
|
+
}
|
|
812
|
+
|
|
813
|
+
/**
|
|
814
|
+
* Result type of {@link to.hdi.migration}.
|
|
815
|
+
*/
|
|
816
|
+
export type HdiMigrationResult = {
|
|
817
|
+
/**
|
|
818
|
+
* The desired after-image in HANA-CSN format
|
|
819
|
+
*/
|
|
820
|
+
afterImage: CSN
|
|
821
|
+
/**
|
|
822
|
+
* An array of objects with all artifacts in the after-image. Each object specifies
|
|
823
|
+
* the artifact filename, the suffix, and the corresponding SQL statement to create
|
|
824
|
+
* the artifact.
|
|
825
|
+
*/
|
|
826
|
+
definitions: object[],
|
|
827
|
+
/**
|
|
828
|
+
* An array of objects with the deleted artifacts. Each object specifies the artifact
|
|
829
|
+
* filename and the suffix.
|
|
830
|
+
*/
|
|
831
|
+
deletions: object[],
|
|
832
|
+
/**
|
|
833
|
+
* An array of objects with the changed (migrated) artifacts. Each object specifies the
|
|
834
|
+
* artifact filename, the suffix, and the changeset (an array of changes, each specifying
|
|
835
|
+
* whether it incurs potential data loss, and its respective SQL statement(s), with
|
|
836
|
+
* multiple statements concatenated as a multi-line string in case the change e.g.
|
|
837
|
+
* consists of a column drop and add).
|
|
838
|
+
*/
|
|
839
|
+
migrations: Array<{
|
|
840
|
+
name: string
|
|
841
|
+
suffix: string
|
|
842
|
+
changeset: object[]
|
|
843
|
+
}>,
|
|
844
|
+
}
|
|
845
|
+
|
|
846
|
+
/**
|
|
847
|
+
* Return the resulting database name for (absolute) 'artifactName', depending on the current naming
|
|
848
|
+
* mode.
|
|
849
|
+
*
|
|
850
|
+
* - For the 'hdbcds' naming mode, this means converting `.` to `::` on
|
|
851
|
+
* the border between namespace and top-level artifact and correctly replacing some `.` with `_`.
|
|
852
|
+
* - For the 'plain' naming mode, it means converting all `.` to `_` and upper-casing.
|
|
853
|
+
* - For the 'quoted' naming mode, this means correctly replacing some `.` with `_`.
|
|
854
|
+
*
|
|
855
|
+
* @param artifactName The fully qualified name of the artifact
|
|
856
|
+
* @param sqlMapping The naming mode to use. See {@link SqlOptions.sqlMapping} for more details.
|
|
857
|
+
* @param csn
|
|
858
|
+
* @returns {string} The resulting database name for (absolute) 'artifactName', depending on the current naming mode.
|
|
859
|
+
* @since v2.1.0
|
|
860
|
+
*/
|
|
861
|
+
export function getArtifactCdsPersistenceName(artifactName: string, sqlMapping: string, csn: CSN): string;
|
|
862
|
+
/**
|
|
863
|
+
* This is an old function signature. If it is used - with a namespace as the third argument - the result might be wrong,
|
|
864
|
+
* since the `.` -> `_` conversion for 'quoted'/'hdbcds' is missing.
|
|
865
|
+
*
|
|
866
|
+
* @deprecated Use the other overload with CSN instead.
|
|
867
|
+
*/
|
|
868
|
+
export function getArtifactCdsPersistenceName(artifactName: string, sqlMapping: string, namespace: string): string;
|
|
869
|
+
/**
|
|
870
|
+
* Return the resulting database element name for `elemName`, depending on the current
|
|
871
|
+
* naming mode.
|
|
872
|
+
* - For the 'hdbcds' naming mode, this is just 'elemName'.
|
|
873
|
+
* - For the 'plain' naming mode, it means converting all `.` to `_` and upper-casing.
|
|
874
|
+
* - For the 'quoted' naming mode, it means converting all `.` to `_`.
|
|
875
|
+
* No other naming modes are accepted!
|
|
876
|
+
*
|
|
877
|
+
* @param elemName The name of the element. For structured elements, concat by dot, e.g. `sub.elem`.
|
|
878
|
+
* @param sqlMapping The naming mode to use. See {@link SqlOptions.sqlMapping} for more details.
|
|
879
|
+
* @returns The resulting database element name for 'elemName', depending on the current naming mode.
|
|
880
|
+
*/
|
|
881
|
+
export function getElementCdsPersistenceName(elemName: string, sqlMapping: string): string;
|
|
882
|
+
|
|
883
|
+
/**
|
|
884
|
+
* Traverse the CSN node `csn`.
|
|
885
|
+
*
|
|
886
|
+
* If `csn` is an array, call it recursively on each array item.
|
|
887
|
+
* If `csn` is an(other) object, call a function on each property:
|
|
888
|
+
* - The property name is a used as key in argument `userFunctions` and the
|
|
889
|
+
* constant `defaultFunctions` above to get the function which is called on
|
|
890
|
+
* the property value, see `defaultFunctions` for details.
|
|
891
|
+
* - If no function is found with the property name, try to find one with the
|
|
892
|
+
* first char, which is useful for annotations.
|
|
893
|
+
* - If still not found, call `traverseCsn` recursively.
|
|
894
|
+
*
|
|
895
|
+
* The functions in `userFunctions` are usually transformer functions, which
|
|
896
|
+
* change the input CSN destructively.
|
|
897
|
+
*/
|
|
898
|
+
export function traverseCsn(userFunctions: Record<string, Function>, csn: object|any[]);
|
|
464
899
|
|
|
465
900
|
/**
|
|
466
901
|
* @private
|
|
467
902
|
*/
|
|
468
903
|
export namespace $lsp {
|
|
469
|
-
|
|
470
|
-
|
|
904
|
+
/**
|
|
905
|
+
* Compiler internal notation.
|
|
906
|
+
* @private
|
|
907
|
+
*/
|
|
908
|
+
type XSN = any;
|
|
909
|
+
/**
|
|
910
|
+
* Compile the given files with the given options. The return object uses an internal object
|
|
911
|
+
* format that must not be used outside of the cds-lsp.
|
|
912
|
+
* Respects the value of `options.fallbackParser`.
|
|
913
|
+
*
|
|
914
|
+
* @param filenames Array of files that should be compiled.
|
|
915
|
+
* @param dir Working directory. Relative paths in `filenames` will be resolved relatively to this directory.
|
|
916
|
+
* @param options Compiler options. If you do not set `messages`, they will be printed to console.
|
|
917
|
+
* @param fileCache
|
|
918
|
+
* @private
|
|
919
|
+
*/
|
|
920
|
+
function compile(filenames: string[], dir?: string, options?: CompileOptions, fileCache?: FileCache): Promise<XSN>;
|
|
921
|
+
/**
|
|
922
|
+
* Parse the given source with the correct parser based on the file name's
|
|
923
|
+
* extension. For example uses CDL parser for `.cds` files.
|
|
924
|
+
* Respects the value of `options.fallbackParser`.
|
|
925
|
+
*
|
|
926
|
+
* @param {string} source Source code of the file.
|
|
927
|
+
* @param {string} filename Filename including its extension, e.g. "file.cds"
|
|
928
|
+
* @param {object} options Compile options
|
|
929
|
+
* @param {object} messageFunctions If not provided, parse errors will not lead to an exception
|
|
930
|
+
* @private
|
|
931
|
+
*/
|
|
932
|
+
function parse(source: string, filename: string, options?: CompileOptions, messageFunctions?: object): XSN;
|
|
933
|
+
/**
|
|
934
|
+
* Get the name of the given artifact. This function is internal and does not work with CSN.
|
|
935
|
+
* It should be used to retrieve an artifact's name instead of relying on `artifact.name`
|
|
936
|
+
* as that object may be modified in the future.
|
|
937
|
+
*
|
|
938
|
+
* @private
|
|
939
|
+
*/
|
|
940
|
+
function getArtifactName(artifact: object): object;
|
|
471
941
|
}
|
|
472
942
|
|
|
473
943
|
/**
|
|
474
|
-
*
|
|
944
|
+
* CDS Schema Notation. Not yet specified in this TypeScript declaration file.
|
|
945
|
+
* See <https://pages.github.tools.sap/cap/docs/cds/csn> for more.
|
|
475
946
|
*/
|
|
476
947
|
export type CSN = any;
|
|
477
948
|
|
|
949
|
+
/**
|
|
950
|
+
* CDS Query Notation. Not yet specified in this TypeScript declaration file.
|
|
951
|
+
* See <https://pages.github.tools.sap/cap/docs/cds/cqn> for more.
|
|
952
|
+
*/
|
|
953
|
+
export type CQN = any;
|
|
954
|
+
|
|
955
|
+
/**
|
|
956
|
+
* CDS Expression Notation. Not yet specified in this TypeScript declaration file.
|
|
957
|
+
* See <https://pages.github.tools.sap/cap/docs/cds/cxn> for more.
|
|
958
|
+
*/
|
|
959
|
+
export type CXN = any;
|
|
960
|
+
|
|
478
961
|
export class CompileMessage {
|
|
479
962
|
constructor(location: Location, msg: string, severity?: MessageSeverity, id?: string | null, home?: string | null, moduleName?: string | null);
|
|
480
|
-
|
|
481
963
|
/**
|
|
482
964
|
* Optional ID of the message. Can be used to reclassify messages.
|
|
483
965
|
*
|
|
@@ -491,7 +973,6 @@ declare namespace compiler {
|
|
|
491
973
|
* @deprecated Use `$location` instead.
|
|
492
974
|
*/
|
|
493
975
|
location: Location
|
|
494
|
-
|
|
495
976
|
/**
|
|
496
977
|
* Location information like file and line/column of the message.
|
|
497
978
|
*/
|
|
@@ -507,7 +988,6 @@ declare namespace compiler {
|
|
|
507
988
|
* String representation of the message. May be a multi-line message in the future.
|
|
508
989
|
*/
|
|
509
990
|
message: string
|
|
510
|
-
|
|
511
991
|
/**
|
|
512
992
|
* A string describing the path to the artifact, e.g. `entity:"E"/element:"x"`.
|
|
513
993
|
*/
|
|
@@ -523,7 +1003,6 @@ declare namespace compiler {
|
|
|
523
1003
|
* If `internalMsg` is set, then this property will have an error object with a stack trace.
|
|
524
1004
|
*/
|
|
525
1005
|
error?: Error
|
|
526
|
-
|
|
527
1006
|
/**
|
|
528
1007
|
* Returns a human readable string of the compiler message. Uses {@link messageString} to render
|
|
529
1008
|
* the message without filename normalization and without a message ID.
|
|
@@ -534,7 +1013,7 @@ declare namespace compiler {
|
|
|
534
1013
|
/**
|
|
535
1014
|
* Severities a compiler message can have.
|
|
536
1015
|
*/
|
|
537
|
-
export type MessageSeverity = 'Error' | 'Warning' | 'Info' | 'Debug';
|
|
1016
|
+
export type MessageSeverity = string | 'Error' | 'Warning' | 'Info' | 'Debug';
|
|
538
1017
|
|
|
539
1018
|
/**
|
|
540
1019
|
* CSN Location, often exposed by `$location` in CSN.
|
|
@@ -551,4 +1030,14 @@ declare namespace compiler {
|
|
|
551
1030
|
endCol?: number
|
|
552
1031
|
}
|
|
553
1032
|
|
|
1033
|
+
/**
|
|
1034
|
+
* File cache for compile() functions.
|
|
1035
|
+
* This cache is a dictionary of absolute file names to the file content with values:
|
|
1036
|
+
* - `false`: the file does not exist
|
|
1037
|
+
* - `true`: file exists (fstat), no further knowledge yet - i.e. value will change!
|
|
1038
|
+
* - `string` or `Buffer`: the file content
|
|
1039
|
+
* - `{ realname: fs.realpath(filename) }`: if filename is not canonicalized
|
|
1040
|
+
*/
|
|
1041
|
+
export type FileCache = Record<string, boolean | string | Buffer | { realname: string }>;
|
|
1042
|
+
|
|
554
1043
|
}
|