@eagleoutice/flowr 2.11.1 → 2.12.1
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/README.md +187 -257
- package/abstract-interpretation/absint-visitor.d.ts +1 -0
- package/abstract-interpretation/data-frame/mappers/arguments.js +7 -1
- package/abstract-interpretation/domains/set-range-domain.js +1 -1
- package/abstract-interpretation/domains/set-upper-bound-domain.js +6 -2
- package/benchmark/slicer.d.ts +1 -1
- package/benchmark/slicer.js +3 -1
- package/benchmark/summarizer/second-phase/graph.js +5 -0
- package/cli/common/options.d.ts +8 -0
- package/cli/common/options.js +2 -0
- package/cli/common/scripts-info.d.ts +8 -0
- package/cli/repl/commands/repl-commands.d.ts +1 -0
- package/cli/repl/commands/repl-commands.js +66 -15
- package/cli/repl/commands/repl-dataflow.js +48 -4
- package/cli/repl/commands/repl-main.d.ts +2 -0
- package/cli/repl/commands/repl-main.js +5 -0
- package/cli/repl/commands/repl-query.d.ts +4 -1
- package/cli/repl/commands/repl-query.js +72 -22
- package/cli/repl/commands/repl-signature.d.ts +7 -0
- package/cli/repl/commands/repl-signature.js +119 -0
- package/cli/repl/core.d.ts +8 -1
- package/cli/repl/core.js +46 -6
- package/cli/repl/ghost-hint.d.ts +37 -0
- package/cli/repl/ghost-hint.js +72 -0
- package/cli/repl/parser/slice-query-parser.d.ts +11 -1
- package/cli/repl/parser/slice-query-parser.js +45 -16
- package/cli/repl/print-version.d.ts +2 -4
- package/cli/repl/print-version.js +41 -23
- package/cli/repl/server/connection.js +19 -17
- package/cli/slicer-app.d.ts +2 -0
- package/cli/slicer-app.js +3 -3
- package/cli/wiki.d.ts +2 -2
- package/cli/wiki.js +2 -2
- package/config.d.ts +63 -2
- package/config.js +64 -8
- package/control-flow/cfg-dead-code.js +0 -1
- package/control-flow/control-flow-graph.js +6 -6
- package/control-flow/diff-cfg.js +2 -2
- package/control-flow/semantic-cfg-guided-visitor.js +2 -0
- package/core/print/slice-diff-ansi.js +8 -8
- package/core/steps/all/core/20-dataflow.d.ts +2 -2
- package/core/steps/all/static-slicing/00-slice.d.ts +5 -0
- package/core/steps/all/static-slicing/00-slice.js +1 -1
- package/core/steps/all/static-slicing/10-reconstruct.d.ts +7 -0
- package/core/steps/all/static-slicing/10-reconstruct.js +6 -2
- package/core/steps/pipeline/default-pipelines.d.ts +20 -16
- package/data/r-base-packages.generated.d.ts +44 -0
- package/data/r-base-packages.generated.js +32 -0
- package/data/r-base-primitives.generated.d.ts +1 -0
- package/data/r-base-primitives.generated.js +15 -0
- package/data/sigdb/sigdb.remote.json +112 -0
- package/dataflow/environments/built-in-proc-name.d.ts +4 -0
- package/dataflow/environments/built-in-proc-name.js +4 -0
- package/dataflow/environments/built-in.d.ts +14 -4
- package/dataflow/environments/built-in.js +13 -2
- package/dataflow/environments/data-masking-functions.d.ts +12 -0
- package/dataflow/environments/data-masking-functions.js +46 -0
- package/dataflow/environments/default-builtin-config.d.ts +72 -19
- package/dataflow/environments/default-builtin-config.js +48 -14
- package/dataflow/environments/diff.js +1 -1
- package/dataflow/environments/environment.js +1 -2
- package/dataflow/environments/identifier.d.ts +11 -4
- package/dataflow/environments/identifier.js +28 -10
- package/dataflow/environments/resolve-by-name.js +16 -2
- package/dataflow/extractor.js +6 -3
- package/dataflow/graph/call-graph.d.ts +2 -2
- package/dataflow/graph/df-helper.d.ts +4 -4
- package/dataflow/graph/diff-dataflow-graph.js +2 -2
- package/dataflow/graph/edge.d.ts +3 -3
- package/dataflow/graph/edge.js +3 -3
- package/dataflow/graph/graph-helper.d.ts +2 -2
- package/dataflow/internal/linker.js +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.d.ts +7 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +20 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.d.ts +1 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.js +2 -49
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +6 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-get.js +7 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-library.d.ts +19 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-library.js +111 -6
- package/dataflow/internal/process/functions/call/built-in/built-in-pipe.js +13 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-replacement.js +2 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.d.ts +9 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.js +19 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-with.js +12 -4
- package/dataflow/internal/process/functions/call/common.js +8 -1
- package/dataflow/internal/process/functions/call/default-call-handling.js +6 -0
- package/dataflow/internal/process/functions/call/known-call-handling.d.ts +17 -0
- package/dataflow/internal/process/functions/call/known-call-handling.js +32 -0
- package/dataflow/internal/process/functions/call/named-call-handling.js +29 -7
- package/dataflow/internal/process/functions/process-argument.js +12 -1
- package/dataflow/internal/process/process-named-call.d.ts +18 -1
- package/dataflow/internal/process/process-named-call.js +94 -0
- package/dataflow/processor.d.ts +18 -0
- package/documentation/data/faq/faqs.js +5 -1
- package/documentation/doc-capabilities.js +1 -1
- package/documentation/doc-util/doc-cli-option.d.ts +10 -0
- package/documentation/doc-util/doc-cli-option.js +23 -0
- package/documentation/doc-util/doc-dfg.js +2 -1
- package/documentation/doc-util/doc-query.d.ts +9 -3
- package/documentation/doc-util/doc-query.js +9 -4
- package/documentation/wiki-dataflow-graph.js +8 -5
- package/documentation/wiki-interface.js +4 -2
- package/documentation/wiki-linter.js +1 -1
- package/documentation/wiki-linting-and-testing.js +4 -1
- package/documentation/wiki-mk/doc-context.d.ts +14 -0
- package/documentation/wiki-mk/doc-context.js +3 -0
- package/documentation/wiki-mk/doc-maker.js +3 -1
- package/documentation/wiki-query.js +36 -15
- package/documentation/wiki-setup.js +10 -7
- package/documentation/wiki-signature-database.d.ts +16 -0
- package/documentation/wiki-signature-database.js +293 -0
- package/linter/linter-format.d.ts +7 -0
- package/linter/linter-rules.d.ts +10 -9
- package/linter/rules/naming-convention.d.ts +1 -0
- package/linter/rules/naming-convention.js +2 -0
- package/linter/rules/no-leaked-credentials.js +1 -2
- package/linter/rules/roxygen-arguments.js +18 -5
- package/linter/rules/stop-with-call-arg.js +2 -2
- package/linter/rules/undefined-symbol-util.d.ts +36 -0
- package/linter/rules/undefined-symbol-util.js +149 -0
- package/linter/rules/undefined-symbol.d.ts +58 -17
- package/linter/rules/undefined-symbol.js +143 -33
- package/linter/rules/unused-definition.d.ts +8 -1
- package/linter/rules/unused-definition.js +126 -1
- package/package.json +22 -10
- package/project/context/abstract-flowr-analyzer-context.js +7 -1
- package/project/context/flowr-analyzer-context.d.ts +8 -0
- package/project/context/flowr-analyzer-context.js +10 -0
- package/project/context/flowr-analyzer-dependencies-context.d.ts +28 -4
- package/project/context/flowr-analyzer-dependencies-context.js +51 -2
- package/project/context/flowr-analyzer-files-context.d.ts +1 -0
- package/project/context/flowr-analyzer-files-context.js +2 -1
- package/project/context/flowr-analyzer-functions-context.js +1 -1
- package/project/context/flowr-file.d.ts +5 -0
- package/project/context/flowr-file.js +5 -0
- package/project/flowr-analyzer-builder.js +12 -2
- package/project/plugins/file-plugins/files/flowr-description-file.js +6 -3
- package/project/plugins/file-plugins/files/flowr-namespace-file.js +9 -3
- package/project/plugins/file-plugins/files/flowr-news-file.js +1 -3
- package/project/plugins/file-plugins/flowr-analyzer-inst-file-plugin.d.ts +26 -0
- package/project/plugins/file-plugins/flowr-analyzer-inst-file-plugin.js +39 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-description-file-plugin.js +1 -1
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-lockfile-plugin.js +2 -2
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-namespace-file-plugin.js +1 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-plugin.d.ts +18 -2
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-plugin.js +19 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.d.ts +120 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +518 -0
- package/project/plugins/package-version-plugins/package.d.ts +5 -3
- package/project/plugins/package-version-plugins/package.js +27 -25
- package/project/plugins/plugin-registry.d.ts +3 -2
- package/project/plugins/plugin-registry.js +4 -2
- package/project/plugins/project-discovery/flowr-analyzer-gitignore-project-discovery-plugin.js +7 -2
- package/project/plugins/project-discovery/flowr-analyzer-project-discovery-plugin.js +3 -1
- package/project/sigdb/build.d.ts +131 -0
- package/project/sigdb/build.js +628 -0
- package/project/sigdb/codec.d.ts +51 -0
- package/project/sigdb/codec.js +122 -0
- package/project/sigdb/decode.d.ts +58 -0
- package/project/sigdb/decode.js +129 -0
- package/project/sigdb/decompress.d.ts +44 -0
- package/project/sigdb/decompress.js +176 -0
- package/project/sigdb/hash.d.ts +9 -0
- package/project/sigdb/hash.js +54 -0
- package/project/sigdb/index-format.d.ts +40 -0
- package/project/sigdb/index-format.js +28 -0
- package/project/sigdb/manifest.d.ts +68 -0
- package/project/sigdb/manifest.js +146 -0
- package/project/sigdb/reader.d.ts +250 -0
- package/project/sigdb/reader.js +692 -0
- package/project/sigdb/schema.d.ts +196 -0
- package/project/sigdb/schema.js +33 -0
- package/project/sigdb/sigdb-download.d.ts +65 -0
- package/project/sigdb/sigdb-download.js +237 -0
- package/project/sigdb/signature-match.d.ts +26 -0
- package/project/sigdb/signature-match.js +40 -0
- package/project/sigdb/version.d.ts +20 -0
- package/project/sigdb/version.js +55 -0
- package/queries/catalog/absint-query/absint-query-executor.d.ts +6 -0
- package/queries/catalog/absint-query/absint-query-executor.js +63 -0
- package/queries/catalog/absint-query/absint-query-format.d.ts +37 -0
- package/queries/catalog/absint-query/absint-query-format.js +102 -0
- package/queries/catalog/call-context-query/call-context-query-executor.js +1 -3
- package/queries/catalog/config-query/config-query-format.d.ts +3 -1
- package/queries/catalog/config-query/config-query-format.js +68 -9
- package/queries/catalog/dataflow-query/dataflow-query-format.js +11 -1
- package/queries/catalog/dependencies-query/dependencies-query-executor.js +1 -1
- package/queries/catalog/linter-query/linter-query-executor.d.ts +2 -0
- package/queries/catalog/linter-query/linter-query-executor.js +6 -1
- package/queries/catalog/linter-query/linter-query-format.d.ts +2 -1
- package/queries/catalog/linter-query/linter-query-format.js +40 -8
- package/queries/catalog/project-query/project-query-executor.d.ts +15 -0
- package/queries/catalog/project-query/project-query-executor.js +96 -4
- package/queries/catalog/project-query/project-query-format.d.ts +44 -0
- package/queries/catalog/project-query/project-query-format.js +33 -2
- package/queries/catalog/signature-query/signature-query-executor.d.ts +29 -0
- package/queries/catalog/signature-query/signature-query-executor.js +461 -0
- package/queries/catalog/signature-query/signature-query-format.d.ts +138 -0
- package/queries/catalog/signature-query/signature-query-format.js +76 -0
- package/queries/catalog/signature-query/signature-query-render.d.ts +15 -0
- package/queries/catalog/signature-query/signature-query-render.js +155 -0
- package/queries/catalog/static-slice-query/static-slice-query-executor.js +9 -3
- package/queries/catalog/static-slice-query/static-slice-query-format.d.ts +10 -0
- package/queries/catalog/static-slice-query/static-slice-query-format.js +19 -1
- package/queries/query-print.js +5 -0
- package/queries/query.d.ts +15 -5
- package/queries/query.js +7 -4
- package/r-bridge/init.js +5 -1
- package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.d.ts +10 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.js +55 -0
- package/r-bridge/lang-4.x/ast/model/processing/node-id.d.ts +16 -0
- package/r-bridge/lang-4.x/ast/model/processing/node-id.js +27 -0
- package/r-bridge/lang-4.x/ast/parser/json/format.js +89 -2
- package/r-bridge/lang-4.x/ast/parser/main/internal/structure/normalize-expressions.js +2 -4
- package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.js +2 -1
- package/r-bridge/parser.d.ts +2 -0
- package/r-bridge/retriever.js +4 -1
- package/r-bridge/roxygen2/documentation-provider.js +2 -1
- package/r-bridge/shell.d.ts +5 -0
- package/r-bridge/shell.js +17 -1
- package/reconstruct/inline/source-inline-map.d.ts +48 -0
- package/reconstruct/inline/source-inline-map.js +94 -0
- package/reconstruct/reconstruct.d.ts +19 -2
- package/reconstruct/reconstruct.js +79 -16
- package/search/search-executor/search-generators.js +5 -22
- package/search/search-executor/search-transformer.js +10 -6
- package/slicing/criterion/parse.d.ts +28 -4
- package/slicing/criterion/parse.js +133 -18
- package/slicing/static/slice-call.d.ts +24 -1
- package/slicing/static/slice-call.js +90 -0
- package/slicing/static/static-slicer.d.ts +7 -0
- package/slicing/static/static-slicer.js +38 -3
- package/util/collections/arrays.d.ts +4 -5
- package/util/collections/arrays.js +7 -18
- package/util/hash.d.ts +14 -0
- package/util/hash.js +31 -0
- package/util/mermaid/dfg.d.ts +7 -2
- package/util/mermaid/dfg.js +53 -13
- package/util/r-base-packages.d.ts +19 -0
- package/util/r-base-packages.js +72 -0
- package/util/r-license.js +2 -10
- package/util/r-version.d.ts +45 -15
- package/util/r-version.js +97 -36
- package/util/range.d.ts +15 -0
- package/util/range.js +39 -0
- package/util/schema.d.ts +10 -0
- package/util/schema.js +22 -0
- package/util/text/ansi.d.ts +3 -0
- package/util/text/ansi.js +10 -0
- package/util/text/args.js +1 -2
- package/util/version.js +28 -8
- package/data/pkgdb/pkgdb-latest.json.br +0 -0
- package/data/pkgdb/pkgdb-tiny.json.br +0 -0
- package/documentation/wiki-package-database.d.ts +0 -9
- package/documentation/wiki-package-database.js +0 -63
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-pkgdb-plugin.d.ts +0 -63
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-pkgdb-plugin.js +0 -176
- package/project/plugins/package-version-plugins/pkgdb.d.ts +0 -133
- package/project/plugins/package-version-plugins/pkgdb.js +0 -370
- package/queries/catalog/df-shape-query/df-shape-query-executor.d.ts +0 -6
- package/queries/catalog/df-shape-query/df-shape-query-executor.js +0 -58
- package/queries/catalog/df-shape-query/df-shape-query-format.d.ts +0 -27
- package/queries/catalog/df-shape-query/df-shape-query-format.js +0 -56
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* On-disk schema of the `flowr-sigdb` database (schema 4): the constants, enums, numeric tuple forms and
|
|
3
|
+
* data interfaces that define the serialized format and its read view. The reader/writer/builder logic that
|
|
4
|
+
* operates on these lives in `./sigdb` (which re-exports this module, so `./sigdb` stays the single entry point).
|
|
5
|
+
*/
|
|
6
|
+
/** The definition location of the binding, with a file path usually relative to the package project root. */
|
|
7
|
+
export interface SigDefinitionLocation {
|
|
8
|
+
readonly file: string;
|
|
9
|
+
readonly line: number;
|
|
10
|
+
}
|
|
11
|
+
/** The resolved identifiers of a singular package version */
|
|
12
|
+
export interface LibraryExports {
|
|
13
|
+
/** R version identifier (see `RVersion.parse`) */
|
|
14
|
+
readonly version: string;
|
|
15
|
+
readonly exported: readonly string[];
|
|
16
|
+
/** defined-but-not-exported identifiers (only available when internal names are stored, which we usually avoid in the db) */
|
|
17
|
+
readonly internal: readonly string[];
|
|
18
|
+
readonly deprecated: readonly string[];
|
|
19
|
+
/** flag indicating whether this is a package available on CRAN */
|
|
20
|
+
readonly cran: boolean;
|
|
21
|
+
/** package documentation url base in case this package is found at a different endpoint */
|
|
22
|
+
readonly cranUrl?: string;
|
|
23
|
+
/** definition location per identifier, if the database carries them */
|
|
24
|
+
readonly locations?: ReadonlyMap<string, SigDefinitionLocation>;
|
|
25
|
+
}
|
|
26
|
+
export declare const SigDbMagic = "flowr-sigdb";
|
|
27
|
+
export declare const SigDbSchema = 4;
|
|
28
|
+
/** default CRAN source-package base URL, used to build a version's tarball link */
|
|
29
|
+
export declare const DefaultCranBase = "https://cran.r-project.org/src/contrib/";
|
|
30
|
+
/**
|
|
31
|
+
* Parameter default expressions longer than this are stored truncated (with a `…` marker): flowR only needs a
|
|
32
|
+
* short lexeme preview of a default, not the whole expression, so a small cap keeps the dictionary compact.
|
|
33
|
+
*/
|
|
34
|
+
export declare const MaxDefaultLength = 10;
|
|
35
|
+
/** file extension of the (uncompressed) bundle */
|
|
36
|
+
export declare const SigDbExt = ".sigs.ndjson";
|
|
37
|
+
/** function-level boolean properties, packed into {@link SigFn}'s bitfield */
|
|
38
|
+
export declare const enum FnProp {
|
|
39
|
+
Exported = 1,
|
|
40
|
+
HigherOrder = 2,
|
|
41
|
+
Recursive = 4,
|
|
42
|
+
CallsDeprecated = 8,
|
|
43
|
+
CanThrow = 16,
|
|
44
|
+
Deprecated = 32,
|
|
45
|
+
CallsInternal = 64,
|
|
46
|
+
NonDeterministic = 128
|
|
47
|
+
}
|
|
48
|
+
/** the {@link FnProp} bit to its name (for decoding); integer keys iterate in ascending bit order */
|
|
49
|
+
export declare const FnPropNames: Readonly<Record<FnProp, string>>;
|
|
50
|
+
/** parameter flags, packed into {@link SigParam}'s flag int */
|
|
51
|
+
export declare const enum ParamFlag {
|
|
52
|
+
/** forced: the argument is always evaluated (crawlr `always-read`) */
|
|
53
|
+
Forced = 1,
|
|
54
|
+
/** the argument has no default value (crawlr `missing`) */
|
|
55
|
+
Missing = 2
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* One parameter of a signature (position implied by array order): just `nameIdx`, or `[nameIdx, flags]`,
|
|
59
|
+
* or `[nameIdx, flags, defaultIdx]`. All indices point into the global string dictionary.
|
|
60
|
+
*/
|
|
61
|
+
export type SigParam = number | [nameIdx: number, flags: number] | [nameIdx: number, flags: number, defaultIdx: number];
|
|
62
|
+
/** a full signature: the ordered parameter list */
|
|
63
|
+
export type Sig = SigParam[];
|
|
64
|
+
/** one function record `[nameIdx, sigIdx, cgIdx, propBits, fileIdx, line]` (`sigIdx`/`cgIdx`/`fileIdx` are -1 when absent) */
|
|
65
|
+
export type SigFn = [nameIdx: number, sigIdx: number, cgIdx: number, propBits: number, fileIdx: number, line: number];
|
|
66
|
+
/** the kind of a package dependency (mirrors the DESCRIPTION fields) */
|
|
67
|
+
export declare const enum DepType {
|
|
68
|
+
Depends = 0,
|
|
69
|
+
Imports = 1,
|
|
70
|
+
LinkingTo = 2,
|
|
71
|
+
Suggests = 3,
|
|
72
|
+
Enhances = 4
|
|
73
|
+
}
|
|
74
|
+
/** the {@link DepType} values in order, with their names (for decoding) */
|
|
75
|
+
export declare const DepTypeNames: readonly ["depends", "imports", "linkingTo", "suggests", "enhances"];
|
|
76
|
+
/** one dependency: `[nameIdx, type]` or `[nameIdx, type, constraintIdx]` (indices into the global dictionary) */
|
|
77
|
+
export type SigDep = [nameIdx: number, type: DepType] | [nameIdx: number, type: DepType, constraintIdx: number];
|
|
78
|
+
/**
|
|
79
|
+
* A self-contained package. A `versions[ver]` entry is a **delta-encoded** ascending list of indices into
|
|
80
|
+
* {@link PkgBlob.fns} (cumulative-sum to decode); its long runs of `1` just mean a version's functions sit in
|
|
81
|
+
* consecutive pool slots, which brotli collapses on disk. See {@link PkgBlobTuple} for the on-disk order.
|
|
82
|
+
*/
|
|
83
|
+
export interface PkgBlob {
|
|
84
|
+
sigs: Sig[];
|
|
85
|
+
cgs: number[][];
|
|
86
|
+
fns: SigFn[];
|
|
87
|
+
/** version name to a delta-encoded ascending list of indices into {@link PkgBlob.fns} */
|
|
88
|
+
versions: Record<string, number[]>;
|
|
89
|
+
/** the subset of {@link PkgBlob.versions} that are not from CRAN (usually empty, so left undefined in memory) */
|
|
90
|
+
noncran?: string[];
|
|
91
|
+
/** pool of unique dependency lists (shared across a package's versions) */
|
|
92
|
+
deps: SigDep[][];
|
|
93
|
+
/** version name to an index into {@link PkgBlob.deps} (absent when the version declares no dependencies) */
|
|
94
|
+
depsByVersion: Record<string, number>;
|
|
95
|
+
/** version name to its release date as **days since the Unix epoch** (absent when the date is unknown) */
|
|
96
|
+
dates: Record<string, number>;
|
|
97
|
+
}
|
|
98
|
+
/** on-disk tuple form of a {@link PkgBlob}: `[sigs, cgs, fns, versions, noncran, deps, depsByVersion, dates]` */
|
|
99
|
+
export type PkgBlobTuple = [Sig[], number[][], SigFn[], Record<string, number[]>, string[], SigDep[][], Record<string, number>, Record<string, number>?];
|
|
100
|
+
/**
|
|
101
|
+
* Per-package metadata. The optional 4th element marks an **R-core / base package** (`base`, `stats`,
|
|
102
|
+
* `parallel`, the historical `mva`/`nls`/…): for these the version keys are the R releases during which
|
|
103
|
+
* the package shipped with core R, so the set of versions is exactly the R versions it was part of core.
|
|
104
|
+
*/
|
|
105
|
+
export type SigDbPkgMeta = [latest: string, archived: number, downloads: number, core?: number];
|
|
106
|
+
/**
|
|
107
|
+
* Temporal tier of a bundle's packages:
|
|
108
|
+
* - `current` -- only each package's latest version.
|
|
109
|
+
* - `full` -- every version (self-contained history).
|
|
110
|
+
* - `history` -- every version EXCEPT the latest. This is the delta a `current` bundle already carries, so a
|
|
111
|
+
* `history` bundle mounts beside a `current`/slim one to add the older versions with no duplicate
|
|
112
|
+
*/
|
|
113
|
+
export type SigDbTier = 'full' | 'current' | 'history';
|
|
114
|
+
/** popularity shard: `top` keeps the most-downloaded packages, `rest` the remainder (undefined = all) */
|
|
115
|
+
export type SigDbShard = 'top' | 'rest';
|
|
116
|
+
export interface SigDbContent {
|
|
117
|
+
readonly version: number;
|
|
118
|
+
readonly date: string;
|
|
119
|
+
readonly generated: number;
|
|
120
|
+
/** temporal tier of this bundle */
|
|
121
|
+
readonly tier: SigDbTier;
|
|
122
|
+
/** popularity shard, when the bundle was split by download rank */
|
|
123
|
+
readonly shard?: SigDbShard;
|
|
124
|
+
/** the download-rank cutoff used for {@link SigDbContent.shard} */
|
|
125
|
+
readonly topN?: number;
|
|
126
|
+
/** which information this bundle stores */
|
|
127
|
+
readonly features?: Required<SigDbFeatures>;
|
|
128
|
+
readonly packages: number;
|
|
129
|
+
readonly versions: number;
|
|
130
|
+
readonly functions: number;
|
|
131
|
+
readonly uniquePackages: number;
|
|
132
|
+
readonly strings: number;
|
|
133
|
+
readonly hash: string;
|
|
134
|
+
}
|
|
135
|
+
export interface SigDb {
|
|
136
|
+
format: typeof SigDbMagic;
|
|
137
|
+
schema: typeof SigDbSchema;
|
|
138
|
+
scope: 'signatures';
|
|
139
|
+
content: SigDbContent;
|
|
140
|
+
cranBase?: string;
|
|
141
|
+
/** global string dictionary */
|
|
142
|
+
strings: string[];
|
|
143
|
+
/** unique per-package blobs */
|
|
144
|
+
blobs: PkgBlob[];
|
|
145
|
+
/** package name to its index into {@link SigDb.blobs} */
|
|
146
|
+
pkgs: Record<string, number>;
|
|
147
|
+
/** package name to its {@link SigDbPkgMeta} */
|
|
148
|
+
meta: Record<string, SigDbPkgMeta>;
|
|
149
|
+
}
|
|
150
|
+
export interface SigParamInfo {
|
|
151
|
+
readonly name: string;
|
|
152
|
+
readonly forced?: boolean;
|
|
153
|
+
/** the argument has no default value */
|
|
154
|
+
readonly missing?: boolean;
|
|
155
|
+
readonly default?: string;
|
|
156
|
+
}
|
|
157
|
+
export interface SigFunctionInfo {
|
|
158
|
+
readonly name: string;
|
|
159
|
+
/** bitfield of {@link FnProp} (must set {@link FnProp.Exported} for exported functions) */
|
|
160
|
+
readonly props: number;
|
|
161
|
+
readonly params: readonly SigParamInfo[];
|
|
162
|
+
/** named callees (order/duplication irrelevant; deduped + sorted internally) */
|
|
163
|
+
readonly callees: readonly string[];
|
|
164
|
+
readonly file?: string;
|
|
165
|
+
readonly line?: number;
|
|
166
|
+
}
|
|
167
|
+
/** one declared package dependency, e.g. `{ name: 'testthat', type: Suggests, constraint: '>= 2.1.0' }` */
|
|
168
|
+
export interface SigDependencyInfo {
|
|
169
|
+
readonly name: string;
|
|
170
|
+
readonly type: DepType;
|
|
171
|
+
/** the version qualifier as written in DESCRIPTION, e.g. `>= 3.0.0` (absent = any version) */
|
|
172
|
+
readonly constraint?: string;
|
|
173
|
+
}
|
|
174
|
+
export interface SigVersionInfo {
|
|
175
|
+
readonly cran: boolean;
|
|
176
|
+
readonly functions: readonly SigFunctionInfo[];
|
|
177
|
+
/** declared dependencies of this version (Depends/Imports/LinkingTo/Suggests/Enhances) */
|
|
178
|
+
readonly dependencies?: readonly SigDependencyInfo[];
|
|
179
|
+
/** release date as milliseconds since the Unix epoch (stored at day granularity, used to find the newest release) */
|
|
180
|
+
readonly date?: number;
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Which information to store in a bundle (default: everything). Turning a feature off shrinks the
|
|
184
|
+
* database -- e.g. an exports-and-dependencies-only bundle omits the (largest) call graphs and signatures.
|
|
185
|
+
* The export view (exported/internal/deprecated) is always available.
|
|
186
|
+
*/
|
|
187
|
+
export interface SigDbFeatures {
|
|
188
|
+
/** parameter lists (names, forced/optional, defaults) -- default true */
|
|
189
|
+
signatures?: boolean;
|
|
190
|
+
/** per-function call graphs (named callees) -- default true */
|
|
191
|
+
callGraphs?: boolean;
|
|
192
|
+
/** definition locations (file + line) -- default true */
|
|
193
|
+
locations?: boolean;
|
|
194
|
+
/** per-version declared dependencies -- default true */
|
|
195
|
+
dependencies?: boolean;
|
|
196
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* On-disk schema of the `flowr-sigdb` database (schema 4): the constants, enums, numeric tuple forms and
|
|
4
|
+
* data interfaces that define the serialized format and its read view. The reader/writer/builder logic that
|
|
5
|
+
* operates on these lives in `./sigdb` (which re-exports this module, so `./sigdb` stays the single entry point).
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.DepTypeNames = exports.FnPropNames = exports.SigDbExt = exports.MaxDefaultLength = exports.DefaultCranBase = exports.SigDbSchema = exports.SigDbMagic = void 0;
|
|
9
|
+
exports.SigDbMagic = 'flowr-sigdb';
|
|
10
|
+
exports.SigDbSchema = 4;
|
|
11
|
+
/** default CRAN source-package base URL, used to build a version's tarball link */
|
|
12
|
+
exports.DefaultCranBase = 'https://cran.r-project.org/src/contrib/';
|
|
13
|
+
/**
|
|
14
|
+
* Parameter default expressions longer than this are stored truncated (with a `…` marker): flowR only needs a
|
|
15
|
+
* short lexeme preview of a default, not the whole expression, so a small cap keeps the dictionary compact.
|
|
16
|
+
*/
|
|
17
|
+
exports.MaxDefaultLength = 10;
|
|
18
|
+
/** file extension of the (uncompressed) bundle */
|
|
19
|
+
exports.SigDbExt = '.sigs.ndjson';
|
|
20
|
+
/** the {@link FnProp} bit to its name (for decoding); integer keys iterate in ascending bit order */
|
|
21
|
+
exports.FnPropNames = {
|
|
22
|
+
[1 /* FnProp.Exported */]: 'exported',
|
|
23
|
+
[2 /* FnProp.HigherOrder */]: 'higher-order',
|
|
24
|
+
[4 /* FnProp.Recursive */]: 'recursive',
|
|
25
|
+
[8 /* FnProp.CallsDeprecated */]: 'calls-deprecated',
|
|
26
|
+
[16 /* FnProp.CanThrow */]: 'can-throw',
|
|
27
|
+
[32 /* FnProp.Deprecated */]: 'deprecated',
|
|
28
|
+
[64 /* FnProp.CallsInternal */]: 'calls-internal',
|
|
29
|
+
[128 /* FnProp.NonDeterministic */]: 'non-deterministic'
|
|
30
|
+
};
|
|
31
|
+
/** the {@link DepType} values in order, with their names (for decoding) */
|
|
32
|
+
exports.DepTypeNames = ['depends', 'imports', 'linkingTo', 'suggests', 'enhances'];
|
|
33
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/** hex sha256 of a file's contents (shared by the runtime verify and the `sigdb-remote` pointer generator) */
|
|
2
|
+
export declare const sha256File: (p: string) => string;
|
|
3
|
+
/** the committed link file naming every downloadable shard (base floor + CRAN sets); only this pointer is committed */
|
|
4
|
+
export declare const SigDbRemoteFileName = "sigdb.remote.json";
|
|
5
|
+
/** one downloadable shard as recorded in the committed {@link SigDbRemoteFileName} link file */
|
|
6
|
+
export interface RemoteShard {
|
|
7
|
+
sha256: string;
|
|
8
|
+
bytes: number;
|
|
9
|
+
}
|
|
10
|
+
/** the committed link file: the release tag + repo plus every downloadable shard's integrity hash + size */
|
|
11
|
+
export interface SigDbRemote {
|
|
12
|
+
format?: string;
|
|
13
|
+
schema?: number;
|
|
14
|
+
tag: string;
|
|
15
|
+
repo?: string;
|
|
16
|
+
shards: Record<string, RemoteShard>;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Group physical asset names by their logical (compression-ext-stripped) name and pick, per logical shard, the
|
|
20
|
+
* single best variant this runtime can use: `.zst` when zstd is supported, otherwise `.br` (then `.gz`/plain).
|
|
21
|
+
* On a Node without zstd, a `.zst`-only logical shard is skipped entirely (it could not be decompressed). So the
|
|
22
|
+
* downloader fetches exactly one variant per shard/dictionary -- never both -- matching what the reader resolves.
|
|
23
|
+
*/
|
|
24
|
+
export declare function selectDownloadVariants(names: Iterable<string>): string[];
|
|
25
|
+
export interface SigDbDownloadOptions {
|
|
26
|
+
/** GitHub `owner/repo` (default `flowr-analysis/flowr`) */
|
|
27
|
+
readonly repo?: string;
|
|
28
|
+
/** release version, i.e. tag `sigdb-v<version>` (default the running flowR version) */
|
|
29
|
+
readonly version?: string;
|
|
30
|
+
/** progress callback (one line per asset) */
|
|
31
|
+
readonly onProgress?: (msg: string) => void;
|
|
32
|
+
}
|
|
33
|
+
export interface SigDbDownloadResult {
|
|
34
|
+
/** the directory the bundle landed in (add it to `solver.sigdb.additionalPaths` to keep it mounted) */
|
|
35
|
+
readonly dir: string;
|
|
36
|
+
/** the manifest to mount (richest scope), or `undefined` if the release ships only standalone bundles */
|
|
37
|
+
readonly manifest: string | undefined;
|
|
38
|
+
/** every downloaded file */
|
|
39
|
+
readonly files: readonly string[];
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Download the signature-database shards into the cache directory and return where they landed. Prefers the
|
|
43
|
+
* committed `sigdb.remote.json`, we verify each download by content hash, and **skip shards already
|
|
44
|
+
* present with the right hash**.
|
|
45
|
+
* Use the returned {@link SigDbDownloadResult.manifest}, or point `solver.sigdb.additionalPaths` at the dir.
|
|
46
|
+
*/
|
|
47
|
+
export declare function downloadFullSigDb(opts?: SigDbDownloadOptions): Promise<SigDbDownloadResult>;
|
|
48
|
+
/**
|
|
49
|
+
* The cache dir a {@link downloadFullSigDb} for the committed link file would populate, or `undefined` if no
|
|
50
|
+
* pointer is committed. Lets a caller mount an already-synced bundle via `solver.sigdb.additionalPaths` without
|
|
51
|
+
* hitting the network.
|
|
52
|
+
*/
|
|
53
|
+
export declare function syncedSigDbDir(opts?: {
|
|
54
|
+
version?: string;
|
|
55
|
+
}): string | undefined;
|
|
56
|
+
/** the GitHub release (`{repo, tag, url}`) the committed pointer downloads from, or `undefined` when no pointer is committed */
|
|
57
|
+
export declare function sigDbRemoteRelease(): {
|
|
58
|
+
repo: string;
|
|
59
|
+
tag: string;
|
|
60
|
+
url: string;
|
|
61
|
+
} | undefined;
|
|
62
|
+
/** Startup check: `true` when a committed link file lists shards whose cached copies are missing or hash-mismatched */
|
|
63
|
+
export declare function sigDbNeedsSync(opts?: {
|
|
64
|
+
version?: string;
|
|
65
|
+
}): boolean;
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.SigDbRemoteFileName = exports.sha256File = void 0;
|
|
7
|
+
exports.selectDownloadVariants = selectDownloadVariants;
|
|
8
|
+
exports.downloadFullSigDb = downloadFullSigDb;
|
|
9
|
+
exports.syncedSigDbDir = syncedSigDbDir;
|
|
10
|
+
exports.sigDbRemoteRelease = sigDbRemoteRelease;
|
|
11
|
+
exports.sigDbNeedsSync = sigDbNeedsSync;
|
|
12
|
+
const fs_1 = __importDefault(require("fs"));
|
|
13
|
+
const path_1 = __importDefault(require("path"));
|
|
14
|
+
const https_1 = __importDefault(require("https"));
|
|
15
|
+
const crypto_1 = __importDefault(require("crypto"));
|
|
16
|
+
const decompress_1 = require("./decompress");
|
|
17
|
+
const codec_1 = require("./codec");
|
|
18
|
+
const version_1 = require("../../util/version");
|
|
19
|
+
/** the GitHub `owner/repo` the full-history bundle is published to (see `scripts/publish-sigdb.mjs`) */
|
|
20
|
+
const DefaultRepo = 'flowr-analysis/flowr';
|
|
21
|
+
/** GitHub request headers; the token (used only for the API's rate limit and private repos) is attached only when `withAuth` */
|
|
22
|
+
function ghHeaders(accept, withAuth) {
|
|
23
|
+
const token = withAuth ? (process.env.GH_TOKEN ?? process.env.GITHUB_TOKEN) : undefined;
|
|
24
|
+
return { 'User-Agent': 'flowr', Accept: accept, ...(token ? { Authorization: `Bearer ${token}` } : {}) };
|
|
25
|
+
}
|
|
26
|
+
/** GET following redirects (GitHub asset URLs redirect to a storage host); resolves the final response for streaming */
|
|
27
|
+
function httpGet(url, accept, redirects = 5, withAuth = true) {
|
|
28
|
+
return new Promise((resolve, reject) => {
|
|
29
|
+
https_1.default.get(url, { headers: ghHeaders(accept, withAuth) }, res => {
|
|
30
|
+
const status = res.statusCode ?? 0;
|
|
31
|
+
if (status >= 300 && status < 400 && res.headers.location && redirects > 0) {
|
|
32
|
+
res.resume();
|
|
33
|
+
const next = new URL(res.headers.location, url);
|
|
34
|
+
// GitHub redirects a release-asset download to a pre-signed storage host: never forward the token
|
|
35
|
+
// across hosts (it is unnecessary there, leaks the token, and the signed URL rejects a second auth header)
|
|
36
|
+
const keepAuth = withAuth && next.host === new URL(url).host;
|
|
37
|
+
httpGet(next.toString(), accept, redirects - 1, keepAuth).then(resolve, reject);
|
|
38
|
+
}
|
|
39
|
+
else if (status >= 200 && status < 300) {
|
|
40
|
+
resolve(res);
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
res.resume();
|
|
44
|
+
reject(new Error(`GET ${url} -> HTTP ${status}`));
|
|
45
|
+
}
|
|
46
|
+
}).on('error', reject);
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
async function readJson(url) {
|
|
50
|
+
const res = await httpGet(url, 'application/vnd.github+json');
|
|
51
|
+
const chunks = [];
|
|
52
|
+
for await (const c of res) {
|
|
53
|
+
chunks.push(c);
|
|
54
|
+
}
|
|
55
|
+
return JSON.parse(Buffer.concat(chunks).toString('utf8'));
|
|
56
|
+
}
|
|
57
|
+
async function downloadTo(url, dest) {
|
|
58
|
+
const res = await httpGet(url, 'application/octet-stream');
|
|
59
|
+
await new Promise((resolve, reject) => {
|
|
60
|
+
const out = fs_1.default.createWriteStream(dest);
|
|
61
|
+
res.on('error', reject);
|
|
62
|
+
out.on('error', reject).on('finish', () => out.close(err => err ? reject(err) : resolve()));
|
|
63
|
+
res.pipe(out);
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
/** hex sha256 of a file's contents (shared by the runtime verify and the `sigdb-remote` pointer generator) */
|
|
67
|
+
const sha256File = (p) => crypto_1.default.createHash('sha256').update(fs_1.default.readFileSync(p)).digest('hex');
|
|
68
|
+
exports.sha256File = sha256File;
|
|
69
|
+
/** the committed link file naming every downloadable shard (base floor + CRAN sets); only this pointer is committed */
|
|
70
|
+
exports.SigDbRemoteFileName = 'sigdb.remote.json';
|
|
71
|
+
/** locate the committed `sigdb.remote.json` link file in the sigdb data dir (dev `src`, built `dist`) */
|
|
72
|
+
function findRemotePointer() {
|
|
73
|
+
const candidates = [
|
|
74
|
+
path_1.default.join(__dirname, '../../data/sigdb', exports.SigDbRemoteFileName), // src/ and dist/src/ layouts (same depth)
|
|
75
|
+
path_1.default.join(process.cwd(), 'src/data/sigdb', exports.SigDbRemoteFileName),
|
|
76
|
+
path_1.default.join(process.cwd(), 'dist/src/data/sigdb', exports.SigDbRemoteFileName),
|
|
77
|
+
];
|
|
78
|
+
return candidates.find(p => {
|
|
79
|
+
try {
|
|
80
|
+
return fs_1.default.existsSync(p);
|
|
81
|
+
}
|
|
82
|
+
catch {
|
|
83
|
+
return false;
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
const readPointer = (p) => JSON.parse(fs_1.default.readFileSync(p, 'utf8'));
|
|
88
|
+
/** the direct release-asset CDN URL -- bypasses the REST API (and its rate limit) entirely */
|
|
89
|
+
const assetUrl = (repo, tag, name) => `https://github.com/${repo}/releases/download/${tag}/${encodeURIComponent(name)}`;
|
|
90
|
+
/** runtime-decodable variant extensions, most-preferred first, ending in plain (`''`) as a last resort */
|
|
91
|
+
function downloadVariantOrder() {
|
|
92
|
+
return [...(0, codec_1.readableExtsPreferred)(), ''];
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Group physical asset names by their logical (compression-ext-stripped) name and pick, per logical shard, the
|
|
96
|
+
* single best variant this runtime can use: `.zst` when zstd is supported, otherwise `.br` (then `.gz`/plain).
|
|
97
|
+
* On a Node without zstd, a `.zst`-only logical shard is skipped entirely (it could not be decompressed). So the
|
|
98
|
+
* downloader fetches exactly one variant per shard/dictionary -- never both -- matching what the reader resolves.
|
|
99
|
+
*/
|
|
100
|
+
function selectDownloadVariants(names) {
|
|
101
|
+
const groups = new Map(); // logical name -> (ext -> physical name)
|
|
102
|
+
for (const name of names) {
|
|
103
|
+
const logical = (0, codec_1.stripCompressedExt)(name);
|
|
104
|
+
const ext = (0, codec_1.compressedExtOf)(name) ?? '';
|
|
105
|
+
let byExt = groups.get(logical);
|
|
106
|
+
if (!byExt) {
|
|
107
|
+
byExt = new Map();
|
|
108
|
+
groups.set(logical, byExt);
|
|
109
|
+
}
|
|
110
|
+
byExt.set(ext, name);
|
|
111
|
+
}
|
|
112
|
+
const order = downloadVariantOrder();
|
|
113
|
+
const picked = [];
|
|
114
|
+
for (const byExt of groups.values()) {
|
|
115
|
+
const ext = order.find(e => byExt.has(e));
|
|
116
|
+
if (ext !== undefined) {
|
|
117
|
+
picked.push(byExt.get(ext));
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return picked;
|
|
121
|
+
}
|
|
122
|
+
/** pick the richest manifest among downloaded files (a `full`/scope manifest first, else any) */
|
|
123
|
+
const pickManifest = (files) => files.find(f => new RegExp(`full\\.manifest\\.json${codec_1.CompressedExtPattern}$`).test(f))
|
|
124
|
+
?? files.find(f => new RegExp(`\\.manifest\\.json${codec_1.CompressedExtPattern}$`).test(f));
|
|
125
|
+
/**
|
|
126
|
+
* Download the signature-database shards into the cache directory and return where they landed. Prefers the
|
|
127
|
+
* committed `sigdb.remote.json`, we verify each download by content hash, and **skip shards already
|
|
128
|
+
* present with the right hash**.
|
|
129
|
+
* Use the returned {@link SigDbDownloadResult.manifest}, or point `solver.sigdb.additionalPaths` at the dir.
|
|
130
|
+
*/
|
|
131
|
+
async function downloadFullSigDb(opts = {}) {
|
|
132
|
+
const progress = opts.onProgress ?? (() => { });
|
|
133
|
+
const pointerPath = findRemotePointer();
|
|
134
|
+
if (pointerPath) {
|
|
135
|
+
const remote = readPointer(pointerPath);
|
|
136
|
+
const repo = opts.repo ?? remote.repo ?? DefaultRepo;
|
|
137
|
+
const tag = opts.version ? `sigdb-v${opts.version}` : remote.tag;
|
|
138
|
+
const dir = path_1.default.join((0, decompress_1.sigDbCacheDir)(), 'bundles', tag);
|
|
139
|
+
fs_1.default.mkdirSync(dir, { recursive: true });
|
|
140
|
+
// one variant per logical shard/dictionary -- the best this runtime can decompress (never both codecs)
|
|
141
|
+
const picked = selectDownloadVariants(Object.keys(remote.shards));
|
|
142
|
+
progress(`syncing ${picked.length} shards for ${tag} from ${repo}`);
|
|
143
|
+
const files = [];
|
|
144
|
+
for (const name of picked) {
|
|
145
|
+
const meta = remote.shards[name];
|
|
146
|
+
const dest = path_1.default.join(dir, name);
|
|
147
|
+
if (fs_1.default.existsSync(dest) && (0, exports.sha256File)(dest) === meta.sha256) {
|
|
148
|
+
progress(`have ${name}`);
|
|
149
|
+
}
|
|
150
|
+
else {
|
|
151
|
+
progress(`downloading ${name} (${(meta.bytes / 1e6).toFixed(1)} MB)`);
|
|
152
|
+
await downloadTo(assetUrl(repo, tag, name), dest);
|
|
153
|
+
if ((0, exports.sha256File)(dest) !== meta.sha256) {
|
|
154
|
+
throw new Error(`sha256 mismatch for ${name} (${tag}); the download is corrupt -- retry, or regenerate sigdb.remote.json`);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
files.push(dest);
|
|
158
|
+
}
|
|
159
|
+
return { dir, manifest: pickManifest(files), files };
|
|
160
|
+
}
|
|
161
|
+
// fallback: no committed link file -> list the release via the API and download by size
|
|
162
|
+
const repo = opts.repo ?? DefaultRepo;
|
|
163
|
+
const version = opts.version ?? (0, version_1.flowrVersion)().toString();
|
|
164
|
+
const tag = `sigdb-v${version}`;
|
|
165
|
+
progress(`fetching release ${tag} from ${repo}`);
|
|
166
|
+
const release = await readJson(`https://api.github.com/repos/${repo}/releases/tags/${tag}`);
|
|
167
|
+
const assets = (release.assets ?? [])
|
|
168
|
+
.filter(a => a.name.endsWith('.br') || a.name.endsWith('.zst') || a.name.endsWith('.manifest.json'));
|
|
169
|
+
if (assets.length === 0) {
|
|
170
|
+
throw new Error(`release ${tag} in ${repo} has no signature-database assets${typeof release.message === 'string' ? ` (${release.message})` : ''}`);
|
|
171
|
+
}
|
|
172
|
+
const dir = path_1.default.join((0, decompress_1.sigDbCacheDir)(), 'bundles', tag);
|
|
173
|
+
fs_1.default.mkdirSync(dir, { recursive: true });
|
|
174
|
+
const byName = new Map(assets.map(a => [a.name, a]));
|
|
175
|
+
const files = [];
|
|
176
|
+
for (const name of selectDownloadVariants(byName.keys())) {
|
|
177
|
+
const a = byName.get(name);
|
|
178
|
+
const dest = path_1.default.join(dir, name);
|
|
179
|
+
if (fs_1.default.existsSync(dest) && fs_1.default.statSync(dest).size === a.size) {
|
|
180
|
+
progress(`have ${name}`);
|
|
181
|
+
}
|
|
182
|
+
else {
|
|
183
|
+
progress(`downloading ${name} (${(a.size / 1e6).toFixed(1)} MB)`);
|
|
184
|
+
await downloadTo(a.browser_download_url, dest);
|
|
185
|
+
}
|
|
186
|
+
files.push(dest);
|
|
187
|
+
}
|
|
188
|
+
return { dir, manifest: pickManifest(files), files };
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* The cache dir a {@link downloadFullSigDb} for the committed link file would populate, or `undefined` if no
|
|
192
|
+
* pointer is committed. Lets a caller mount an already-synced bundle via `solver.sigdb.additionalPaths` without
|
|
193
|
+
* hitting the network.
|
|
194
|
+
*/
|
|
195
|
+
function syncedSigDbDir(opts = {}) {
|
|
196
|
+
const pointerPath = findRemotePointer();
|
|
197
|
+
if (!pointerPath) {
|
|
198
|
+
return undefined;
|
|
199
|
+
}
|
|
200
|
+
const tag = opts.version ? `sigdb-v${opts.version}` : readPointer(pointerPath).tag;
|
|
201
|
+
return path_1.default.join((0, decompress_1.sigDbCacheDir)(), 'bundles', tag);
|
|
202
|
+
}
|
|
203
|
+
/** the GitHub release (`{repo, tag, url}`) the committed pointer downloads from, or `undefined` when no pointer is committed */
|
|
204
|
+
function sigDbRemoteRelease() {
|
|
205
|
+
const pointerPath = findRemotePointer();
|
|
206
|
+
if (!pointerPath) {
|
|
207
|
+
return undefined;
|
|
208
|
+
}
|
|
209
|
+
try {
|
|
210
|
+
const remote = readPointer(pointerPath);
|
|
211
|
+
const repo = remote.repo ?? DefaultRepo;
|
|
212
|
+
return { repo, tag: remote.tag, url: `https://github.com/${repo}/releases/tag/${remote.tag}` };
|
|
213
|
+
}
|
|
214
|
+
catch {
|
|
215
|
+
return undefined;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
/** Startup check: `true` when a committed link file lists shards whose cached copies are missing or hash-mismatched */
|
|
219
|
+
function sigDbNeedsSync(opts = {}) {
|
|
220
|
+
const pointerPath = findRemotePointer();
|
|
221
|
+
if (!pointerPath) {
|
|
222
|
+
return false;
|
|
223
|
+
}
|
|
224
|
+
try {
|
|
225
|
+
const remote = readPointer(pointerPath);
|
|
226
|
+
const tag = opts.version ? `sigdb-v${opts.version}` : remote.tag;
|
|
227
|
+
const dir = path_1.default.join((0, decompress_1.sigDbCacheDir)(), 'bundles', tag);
|
|
228
|
+
return Object.entries(remote.shards).some(([name, meta]) => {
|
|
229
|
+
const dest = path_1.default.join(dir, name);
|
|
230
|
+
return !fs_1.default.existsSync(dest) || (0, exports.sha256File)(dest) !== meta.sha256;
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
catch {
|
|
234
|
+
return false;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
//# sourceMappingURL=sigdb-download.js.map
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { FunctionArgument } from '../../dataflow/graph/graph';
|
|
2
|
+
import type { NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
3
|
+
import type { SigParameter } from './decode';
|
|
4
|
+
/**
|
|
5
|
+
* The {@link pMatch} parameter spec for a *known* signature (e.g. one resolved from the signature database):
|
|
6
|
+
* every formal parameter name maps to itself as its own target. A `...` parameter is kept as-is, so `pMatch`
|
|
7
|
+
* collects the overflow/unmatched arguments into it exactly as R does; a signature without `...` simply leaves
|
|
8
|
+
* extra arguments unbound.
|
|
9
|
+
*/
|
|
10
|
+
export declare function signatureParameterSpec(signature: readonly SigParameter[]): Record<string, string>;
|
|
11
|
+
/**
|
|
12
|
+
* Match a call's `args` against a *known* signature using R's argument-matching rules via the canonical
|
|
13
|
+
* {@link pMatch} (exact name, then partial `pmatch`, then positional; `...` collects the rest). Returns a map
|
|
14
|
+
* from parameter name to the id(s) of the argument(s) bound to it, so
|
|
15
|
+
* `matchArgumentsToSignature(ggplotCall.args, ggplotSignature).get('data')` yields the node(s) passed as
|
|
16
|
+
* ggplot's `data` argument. The signature typically comes from the signature database (a {@link SigParameter}
|
|
17
|
+
* list, e.g. via `PackageSignatureSource.functions(pkg)`).
|
|
18
|
+
*/
|
|
19
|
+
export declare function matchArgumentsToSignature(args: readonly FunctionArgument[], signature: readonly SigParameter[]): Map<string, NodeId[]>;
|
|
20
|
+
/**
|
|
21
|
+
* The id(s) of the argument bound to a single named `parameter` of a *known* signature, or `undefined` when
|
|
22
|
+
* nothing is bound to it. A convenience over {@link matchArgumentsToSignature} for the common
|
|
23
|
+
* "give me one parameter's argument" query, e.g.
|
|
24
|
+
* `argumentForParameter(ggplotCall.args, ggplotSignature, 'data')` returns ggplot's `data` argument node(s).
|
|
25
|
+
*/
|
|
26
|
+
export declare function argumentForParameter(args: readonly FunctionArgument[], signature: readonly SigParameter[], parameter: string): NodeId[] | undefined;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.signatureParameterSpec = signatureParameterSpec;
|
|
4
|
+
exports.matchArgumentsToSignature = matchArgumentsToSignature;
|
|
5
|
+
exports.argumentForParameter = argumentForParameter;
|
|
6
|
+
const linker_1 = require("../../dataflow/internal/linker");
|
|
7
|
+
/**
|
|
8
|
+
* The {@link pMatch} parameter spec for a *known* signature (e.g. one resolved from the signature database):
|
|
9
|
+
* every formal parameter name maps to itself as its own target. A `...` parameter is kept as-is, so `pMatch`
|
|
10
|
+
* collects the overflow/unmatched arguments into it exactly as R does; a signature without `...` simply leaves
|
|
11
|
+
* extra arguments unbound.
|
|
12
|
+
*/
|
|
13
|
+
function signatureParameterSpec(signature) {
|
|
14
|
+
const spec = {};
|
|
15
|
+
for (const p of signature) {
|
|
16
|
+
spec[p.name] = p.name;
|
|
17
|
+
}
|
|
18
|
+
return spec;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Match a call's `args` against a *known* signature using R's argument-matching rules via the canonical
|
|
22
|
+
* {@link pMatch} (exact name, then partial `pmatch`, then positional; `...` collects the rest). Returns a map
|
|
23
|
+
* from parameter name to the id(s) of the argument(s) bound to it, so
|
|
24
|
+
* `matchArgumentsToSignature(ggplotCall.args, ggplotSignature).get('data')` yields the node(s) passed as
|
|
25
|
+
* ggplot's `data` argument. The signature typically comes from the signature database (a {@link SigParameter}
|
|
26
|
+
* list, e.g. via `PackageSignatureSource.functions(pkg)`).
|
|
27
|
+
*/
|
|
28
|
+
function matchArgumentsToSignature(args, signature) {
|
|
29
|
+
return (0, linker_1.pMatch)(args, signatureParameterSpec(signature));
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* The id(s) of the argument bound to a single named `parameter` of a *known* signature, or `undefined` when
|
|
33
|
+
* nothing is bound to it. A convenience over {@link matchArgumentsToSignature} for the common
|
|
34
|
+
* "give me one parameter's argument" query, e.g.
|
|
35
|
+
* `argumentForParameter(ggplotCall.args, ggplotSignature, 'data')` returns ggplot's `data` argument node(s).
|
|
36
|
+
*/
|
|
37
|
+
function argumentForParameter(args, signature, parameter) {
|
|
38
|
+
return matchArgumentsToSignature(args, signature).get(parameter);
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=signature-match.js.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Version/date resolution over a {@link PkgBlob}: parsing stored version strings into comparable
|
|
3
|
+
* {@link RVersion}s, decoding the day-granularity release dates, and picking the effective version for a query.
|
|
4
|
+
* Split out of `../sigdb` so the reader/writer there stays focused on the byte format.
|
|
5
|
+
*/
|
|
6
|
+
import { RVersion } from '../../util/r-version';
|
|
7
|
+
import type { PkgBlob } from './schema';
|
|
8
|
+
/** milliseconds since the Unix epoch for a stored day count (dates are stored at day granularity to save space) */
|
|
9
|
+
export declare function dayToMillis(day: number): number;
|
|
10
|
+
/** one release: a parsed version paired with its release date */
|
|
11
|
+
export interface VersionRelease {
|
|
12
|
+
readonly version: RVersion;
|
|
13
|
+
readonly date: Date;
|
|
14
|
+
}
|
|
15
|
+
/** the known releases of a blob, ascending by R-version order (empty when no dates were stored) */
|
|
16
|
+
export declare function releasesOf(blob: Readonly<PkgBlob> | undefined): VersionRelease[];
|
|
17
|
+
/** the version with the newest release date (falling back to `latest`, then the highest by R-version order) */
|
|
18
|
+
export declare function newestVersion(blob: Readonly<PkgBlob>, latest: string): string | undefined;
|
|
19
|
+
/** pick the version tuple: requested, else the package's latest, else the highest present by R-version order */
|
|
20
|
+
export declare function resolveVersion(blob: Readonly<PkgBlob>, latest: string, version?: string): string | undefined;
|