@sanoma-ai/workflows 0.0.0-stage → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +105 -0
- package/README.md +544 -2
- package/dist/apply-steps.d.ts +6 -0
- package/dist/apply-steps.js +93 -0
- package/dist/apply-steps.js.map +1 -0
- package/dist/apply.d.ts +197 -0
- package/dist/apply.js +470 -0
- package/dist/apply.js.map +1 -0
- package/dist/approvals.d.ts +46 -0
- package/dist/approvals.js +111 -0
- package/dist/approvals.js.map +1 -0
- package/dist/ast.d.ts +57 -0
- package/dist/ast.js +81 -0
- package/dist/ast.js.map +1 -0
- package/dist/call.d.ts +37 -0
- package/dist/call.js +417 -0
- package/dist/call.js.map +1 -0
- package/dist/client.d.ts +203 -0
- package/dist/client.js +457 -0
- package/dist/client.js.map +1 -0
- package/dist/config.d.ts +126 -0
- package/dist/config.js +264 -0
- package/dist/config.js.map +1 -0
- package/dist/credentials.d.ts +55 -0
- package/dist/credentials.js +261 -0
- package/dist/credentials.js.map +1 -0
- package/dist/cucumber.d.ts +64 -0
- package/dist/cucumber.js +158 -0
- package/dist/cucumber.js.map +1 -0
- package/dist/datafile.d.ts +71 -0
- package/dist/datafile.js +380 -0
- package/dist/datafile.js.map +1 -0
- package/dist/db.d.ts +58 -0
- package/dist/db.js +179 -0
- package/dist/db.js.map +1 -0
- package/dist/define.d.ts +205 -0
- package/dist/define.js +103 -0
- package/dist/define.js.map +1 -0
- package/dist/describe.d.ts +141 -0
- package/dist/describe.js +135 -0
- package/dist/describe.js.map +1 -0
- package/dist/drift.d.ts +127 -0
- package/dist/drift.js +167 -0
- package/dist/drift.js.map +1 -0
- package/dist/env.d.ts +49 -0
- package/dist/env.js +83 -0
- package/dist/env.js.map +1 -0
- package/dist/errors.d.ts +88 -0
- package/dist/errors.js +148 -0
- package/dist/errors.js.map +1 -0
- package/dist/expectations.d.ts +26 -0
- package/dist/expectations.js +162 -0
- package/dist/expectations.js.map +1 -0
- package/dist/fake.d.ts +55 -0
- package/dist/fake.js +87 -0
- package/dist/fake.js.map +1 -0
- package/dist/fill.d.ts +9 -0
- package/dist/fill.js +17 -0
- package/dist/fill.js.map +1 -0
- package/dist/host.d.ts +56 -0
- package/dist/host.js +45 -0
- package/dist/host.js.map +1 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.js +29 -0
- package/dist/index.js.map +1 -0
- package/dist/ledger.d.ts +217 -0
- package/dist/ledger.js +251 -0
- package/dist/ledger.js.map +1 -0
- package/dist/lint.d.ts +32 -0
- package/dist/lint.js +168 -0
- package/dist/lint.js.map +1 -0
- package/dist/lockfile.d.ts +36 -0
- package/dist/lockfile.js +69 -0
- package/dist/lockfile.js.map +1 -0
- package/dist/log.d.ts +24 -0
- package/dist/log.js +83 -0
- package/dist/log.js.map +1 -0
- package/dist/op.d.ts +260 -0
- package/dist/op.js +188 -0
- package/dist/op.js.map +1 -0
- package/dist/outline.d.ts +179 -0
- package/dist/outline.js +506 -0
- package/dist/outline.js.map +1 -0
- package/dist/paths.d.ts +11 -0
- package/dist/paths.js +30 -0
- package/dist/paths.js.map +1 -0
- package/dist/plugin.d.ts +28 -0
- package/dist/plugin.js +25 -0
- package/dist/plugin.js.map +1 -0
- package/dist/policy.d.ts +114 -0
- package/dist/policy.js +60 -0
- package/dist/policy.js.map +1 -0
- package/dist/resource.d.ts +378 -0
- package/dist/resource.js +430 -0
- package/dist/resource.js.map +1 -0
- package/dist/resources.d.ts +77 -0
- package/dist/resources.js +244 -0
- package/dist/resources.js.map +1 -0
- package/dist/run.d.ts +101 -0
- package/dist/run.js +7 -0
- package/dist/run.js.map +1 -0
- package/dist/sandbox.d.ts +33 -0
- package/dist/sandbox.js +127 -0
- package/dist/sandbox.js.map +1 -0
- package/dist/scenario.d.ts +221 -0
- package/dist/scenario.js +1104 -0
- package/dist/scenario.js.map +1 -0
- package/dist/scenarios.d.ts +55 -0
- package/dist/scenarios.js +71 -0
- package/dist/scenarios.js.map +1 -0
- package/dist/secret.d.ts +42 -0
- package/dist/secret.js +58 -0
- package/dist/secret.js.map +1 -0
- package/dist/shared.d.ts +69 -0
- package/dist/shared.js +84 -0
- package/dist/shared.js.map +1 -0
- package/dist/source.d.ts +58 -0
- package/dist/source.js +54 -0
- package/dist/source.js.map +1 -0
- package/dist/steps.d.ts +76 -0
- package/dist/steps.js +23 -0
- package/dist/steps.js.map +1 -0
- package/dist/version.d.ts +29 -0
- package/dist/version.js +76 -0
- package/dist/version.js.map +1 -0
- package/dist/worker.d.ts +37 -0
- package/dist/worker.js +228 -0
- package/dist/worker.js.map +1 -0
- package/dist/writer.d.ts +35 -0
- package/dist/writer.js +201 -0
- package/dist/writer.js.map +1 -0
- package/oxlint.json +128 -0
- package/package.json +96 -3
- package/src/apply-steps.ts +110 -0
- package/src/apply.ts +626 -0
- package/src/approvals.ts +157 -0
- package/src/ast.ts +115 -0
- package/src/call.ts +483 -0
- package/src/client.ts +604 -0
- package/src/config.ts +404 -0
- package/src/credentials.ts +296 -0
- package/src/cucumber.ts +230 -0
- package/src/datafile.ts +481 -0
- package/src/db.ts +197 -0
- package/src/define.ts +285 -0
- package/src/describe.ts +282 -0
- package/src/drift.ts +259 -0
- package/src/env.ts +122 -0
- package/src/errors.ts +202 -0
- package/src/expectations.ts +191 -0
- package/src/fake.ts +156 -0
- package/src/fill.ts +24 -0
- package/src/host.ts +96 -0
- package/src/index.ts +143 -0
- package/src/ledger.ts +419 -0
- package/src/lint.ts +208 -0
- package/src/lockfile.ts +95 -0
- package/src/log.ts +82 -0
- package/src/op.ts +402 -0
- package/src/outline.ts +620 -0
- package/src/paths.ts +32 -0
- package/src/plugin.ts +37 -0
- package/src/policy.ts +139 -0
- package/src/resource.ts +670 -0
- package/src/resources.ts +311 -0
- package/src/run.ts +106 -0
- package/src/sandbox.ts +161 -0
- package/src/scenario.ts +1365 -0
- package/src/scenarios.ts +111 -0
- package/src/secret.ts +92 -0
- package/src/shared.ts +126 -0
- package/src/source.ts +82 -0
- package/src/steps.ts +90 -0
- package/src/version.ts +86 -0
- package/src/worker.ts +264 -0
- package/src/writer.ts +225 -0
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { type ISupportCodeLibrary } from "@cucumber/cucumber/api";
|
|
2
|
+
import { type Pickle, type PickleStep, TestStepResultStatus } from "@cucumber/messages";
|
|
3
|
+
import { Query } from "@cucumber/query";
|
|
4
|
+
/** A parameter type the steps' expressions use, as Cucumber's `defineParameterType` takes it. */
|
|
5
|
+
export interface ParameterTypeSpec {
|
|
6
|
+
name: string;
|
|
7
|
+
regexp: RegExp | string | readonly (RegExp | string)[];
|
|
8
|
+
transformer: (...match: string[]) => unknown;
|
|
9
|
+
}
|
|
10
|
+
/** What one run does with its scenarios' steps. */
|
|
11
|
+
export interface SanomaWorld {
|
|
12
|
+
/** Called before the scenario's first step. */
|
|
13
|
+
begin(pickle: Pickle): void;
|
|
14
|
+
/** Runs one step: `expression` is the expression it matched, `values` its parameters. */
|
|
15
|
+
step(expression: string, values: unknown[], pickleStep: PickleStep): unknown;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Builds a support code library: the parameter types, then one step definition per expression,
|
|
19
|
+
* each handing its step to the World. Cucumber keeps one builder per process, so the library is
|
|
20
|
+
* built here, by hand, in one synchronous stretch (`reset`, register, `finalize`): building it
|
|
21
|
+
* again in the same process gives the same definitions, where a second `loadSupport` would
|
|
22
|
+
* import nothing new and find none.
|
|
23
|
+
*/
|
|
24
|
+
export declare function buildLibrary(parameterTypes: readonly ParameterTypeSpec[], expressions: Iterable<string>): ISupportCodeLibrary;
|
|
25
|
+
/** How one step ended. */
|
|
26
|
+
export interface StepResult {
|
|
27
|
+
status: TestStepResultStatus;
|
|
28
|
+
/** Why it failed: its error's message. */
|
|
29
|
+
message?: string;
|
|
30
|
+
/** The expressions that match it: none for an undefined step, more than one for an ambiguous one. */
|
|
31
|
+
matches: string[];
|
|
32
|
+
}
|
|
33
|
+
/** What a run read: Cucumber's `Query` of its messages, each file's text, and the files Gherkin could not parse. */
|
|
34
|
+
export interface Report {
|
|
35
|
+
query: Query;
|
|
36
|
+
/** Each file's text, by its path relative to the run's `cwd`. */
|
|
37
|
+
texts: Map<string, string>;
|
|
38
|
+
/** Files Gherkin could not parse; none of the run's scenarios ran when there are any. */
|
|
39
|
+
parseErrors: {
|
|
40
|
+
uri: string;
|
|
41
|
+
line?: number;
|
|
42
|
+
message: string;
|
|
43
|
+
}[];
|
|
44
|
+
}
|
|
45
|
+
/** How each step of a run ended, by its pickle step's id; a step of a pickle that did not run has none. */
|
|
46
|
+
export declare function stepResults({ query }: Report): Map<string, StepResult>;
|
|
47
|
+
/** A pickle's line: its examples row's, or its scenario's. */
|
|
48
|
+
export declare const lineOf: (report: Report, pickle: Pickle) => number;
|
|
49
|
+
/**
|
|
50
|
+
* Runs the feature files `files` (relative to `cwd`) with the library, serially, in this
|
|
51
|
+
* process, and reads back what happened. `line`, with a single file, runs only the scenario or
|
|
52
|
+
* examples row at that line. `makeWorld` makes each scenario's World, given the report so far
|
|
53
|
+
* (every file and pickle, read before the first scenario starts). A dry run matches the steps
|
|
54
|
+
* and runs none. A step's error that is a bug in code (`isBug`) is rethrown once the run is
|
|
55
|
+
* over, rather than reported as the step's failure.
|
|
56
|
+
*/
|
|
57
|
+
export declare function runFeatures(library: ISupportCodeLibrary, makeWorld: (report: Report) => SanomaWorld, { cwd, files, line, dryRun, isBug, }: {
|
|
58
|
+
cwd: string;
|
|
59
|
+
files: string[];
|
|
60
|
+
line?: number;
|
|
61
|
+
dryRun?: boolean;
|
|
62
|
+
isBug: (err: unknown) => boolean;
|
|
63
|
+
}): Promise<Report>;
|
|
64
|
+
export { TestStepResultStatus as StepStatus };
|
package/dist/cucumber.js
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { Writable } from "node:stream";
|
|
2
|
+
import { supportCodeLibraryBuilder } from "@cucumber/cucumber";
|
|
3
|
+
import { runCucumber } from "@cucumber/cucumber/api";
|
|
4
|
+
import { NodeType } from "@cucumber/cucumber-expressions";
|
|
5
|
+
import { IdGenerator, TestStepResultStatus } from "@cucumber/messages";
|
|
6
|
+
import { Query } from "@cucumber/query";
|
|
7
|
+
/**
|
|
8
|
+
* Builds a support code library: the parameter types, then one step definition per expression,
|
|
9
|
+
* each handing its step to the World. Cucumber keeps one builder per process, so the library is
|
|
10
|
+
* built here, by hand, in one synchronous stretch (`reset`, register, `finalize`): building it
|
|
11
|
+
* again in the same process gives the same definitions, where a second `loadSupport` would
|
|
12
|
+
* import nothing new and find none.
|
|
13
|
+
*/
|
|
14
|
+
export function buildLibrary(parameterTypes, expressions) {
|
|
15
|
+
const builder = supportCodeLibraryBuilder;
|
|
16
|
+
builder.reset(process.cwd(), IdGenerator.uuid(), {
|
|
17
|
+
requireModules: [],
|
|
18
|
+
requirePaths: [],
|
|
19
|
+
importPaths: [],
|
|
20
|
+
loaders: [],
|
|
21
|
+
});
|
|
22
|
+
const { defineParameterType, defineStep, Before, BeforeStep } = builder.methods;
|
|
23
|
+
for (const { name, regexp, transformer } of parameterTypes) {
|
|
24
|
+
defineParameterType({ name, regexp: regexp, transformer, useForSnippets: false });
|
|
25
|
+
}
|
|
26
|
+
for (const expression of expressions)
|
|
27
|
+
defineStep(expression, stepCode(expression));
|
|
28
|
+
Before(function ({ pickle }) {
|
|
29
|
+
if (this.run.skips(pickle))
|
|
30
|
+
return "skipped";
|
|
31
|
+
this.begin(pickle);
|
|
32
|
+
return undefined;
|
|
33
|
+
});
|
|
34
|
+
BeforeStep(function ({ pickleStep }) {
|
|
35
|
+
this.current = pickleStep;
|
|
36
|
+
});
|
|
37
|
+
const library = builder.finalize();
|
|
38
|
+
// Cucumber checks a definition's code's `length` against what it passes: the expression's
|
|
39
|
+
// parameters, then the step's doc string or table, or else a callback. Its own parse of each
|
|
40
|
+
// expression says how many parameters it has.
|
|
41
|
+
for (const { code, expression } of library.stepDefinitions) {
|
|
42
|
+
Object.defineProperty(code, "length", {
|
|
43
|
+
value: countParameters(expression.ast) + 1,
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
return library;
|
|
47
|
+
}
|
|
48
|
+
const countParameters = (node) => node.type === NodeType.parameter ? 1 : (node.nodes ?? []).reduce((n, child) => n + countParameters(child), 0);
|
|
49
|
+
/**
|
|
50
|
+
* A step definition's code. Cucumber passes the expression's values, then the step's doc string
|
|
51
|
+
* or table when it has one, then a callback: with one more argument than the parameters it took
|
|
52
|
+
* the callback of a step with no argument (the callback interface), and with two more, the
|
|
53
|
+
* argument of a step that has one (the promise interface). The World reads the argument from
|
|
54
|
+
* the pickle step, so the code answers both.
|
|
55
|
+
*/
|
|
56
|
+
function stepCode(expression) {
|
|
57
|
+
const code = function (...args) {
|
|
58
|
+
const parameters = code.length - 1;
|
|
59
|
+
const result = Promise.resolve()
|
|
60
|
+
.then(() => this.step(expression, args.slice(0, parameters), this.current))
|
|
61
|
+
.catch((err) => {
|
|
62
|
+
this.run.caught(err);
|
|
63
|
+
throw err;
|
|
64
|
+
});
|
|
65
|
+
if (args.length > parameters + 1)
|
|
66
|
+
return result;
|
|
67
|
+
const done = args.at(-1);
|
|
68
|
+
result.then((value) => done(null, value), (err) => done(err));
|
|
69
|
+
return undefined;
|
|
70
|
+
};
|
|
71
|
+
return code;
|
|
72
|
+
}
|
|
73
|
+
/** How each step of a run ended, by its pickle step's id; a step of a pickle that did not run has none. */
|
|
74
|
+
export function stepResults({ query }) {
|
|
75
|
+
const results = new Map();
|
|
76
|
+
for (const finished of query.findAllTestStepFinished()) {
|
|
77
|
+
const testStep = query.findTestStepBy(finished);
|
|
78
|
+
if (!testStep?.pickleStepId)
|
|
79
|
+
continue;
|
|
80
|
+
const { status, message, exception } = finished.testStepResult;
|
|
81
|
+
const why = exception?.message ?? message;
|
|
82
|
+
results.set(testStep.pickleStepId, {
|
|
83
|
+
status,
|
|
84
|
+
matches: query.findStepDefinitionsBy(testStep).map((d) => d.pattern.source),
|
|
85
|
+
...(why !== undefined && { message: why }),
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
return results;
|
|
89
|
+
}
|
|
90
|
+
/** A pickle's line: its examples row's, or its scenario's. */
|
|
91
|
+
export const lineOf = (report, pickle) => report.query.findLocationOf(pickle)?.line ?? 1;
|
|
92
|
+
/** A stream that drops what it is given: Cucumber's formatters and logger write nowhere. */
|
|
93
|
+
const sink = () => new Writable({
|
|
94
|
+
write(_chunk, _encoding, callback) {
|
|
95
|
+
callback();
|
|
96
|
+
},
|
|
97
|
+
});
|
|
98
|
+
/**
|
|
99
|
+
* A path as a glob that matches it alone: Cucumber globs each path it is given, and reads one
|
|
100
|
+
* whose name starts with `@` as a list of paths. Brackets escape what they can; brace
|
|
101
|
+
* expansion reads braces and commas before brackets, so those (and backslashes) match any
|
|
102
|
+
* character instead.
|
|
103
|
+
*/
|
|
104
|
+
const literal = (path) => path.replaceAll(/[*?[\]()+@]/g, "[$&]").replaceAll(/[{},\\]/g, "?");
|
|
105
|
+
/**
|
|
106
|
+
* Runs the feature files `files` (relative to `cwd`) with the library, serially, in this
|
|
107
|
+
* process, and reads back what happened. `line`, with a single file, runs only the scenario or
|
|
108
|
+
* examples row at that line. `makeWorld` makes each scenario's World, given the report so far
|
|
109
|
+
* (every file and pickle, read before the first scenario starts). A dry run matches the steps
|
|
110
|
+
* and runs none. A step's error that is a bug in code (`isBug`) is rethrown once the run is
|
|
111
|
+
* over, rather than reported as the step's failure.
|
|
112
|
+
*/
|
|
113
|
+
export async function runFeatures(library, makeWorld, { cwd, files, line, dryRun = false, isBug, }) {
|
|
114
|
+
const report = { query: new Query(), texts: new Map(), parseErrors: [] };
|
|
115
|
+
let bug;
|
|
116
|
+
const run = {
|
|
117
|
+
skips: (pickle) => line !== undefined && lineOf(report, pickle) !== line,
|
|
118
|
+
caught: (err) => {
|
|
119
|
+
if (isBug(err))
|
|
120
|
+
bug ??= err;
|
|
121
|
+
},
|
|
122
|
+
};
|
|
123
|
+
// Cucumber makes a scenario's World with `new`: a constructor that returns an object gives that object.
|
|
124
|
+
function World() {
|
|
125
|
+
return Object.assign(makeWorld(report), { run });
|
|
126
|
+
}
|
|
127
|
+
const configuration = {
|
|
128
|
+
sources: { defaultDialect: "en", paths: files.map(literal), names: [], tagExpression: "", order: "defined" },
|
|
129
|
+
support: { ...library, World },
|
|
130
|
+
runtime: {
|
|
131
|
+
dryRun,
|
|
132
|
+
failFast: false,
|
|
133
|
+
filterStacktraces: true,
|
|
134
|
+
parallel: 0,
|
|
135
|
+
retry: 0,
|
|
136
|
+
retryTagFilter: "",
|
|
137
|
+
strict: true,
|
|
138
|
+
worldParameters: {},
|
|
139
|
+
},
|
|
140
|
+
// Cucumber always formats to stdout, here a sink: `rerun` is the formatter that does least.
|
|
141
|
+
formats: { stdout: "rerun", files: {}, publish: false, options: {} },
|
|
142
|
+
};
|
|
143
|
+
await runCucumber(configuration, { cwd, stdout: sink(), stderr: sink(), env: {} }, (envelope) => {
|
|
144
|
+
report.query.update(envelope);
|
|
145
|
+
const { source, parseError } = envelope;
|
|
146
|
+
if (source)
|
|
147
|
+
report.texts.set(source.uri, source.data);
|
|
148
|
+
if (parseError) {
|
|
149
|
+
const { uri = "", location } = parseError.source;
|
|
150
|
+
report.parseErrors.push({ uri, ...(location && { line: location.line }), message: parseError.message });
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
if (bug !== undefined)
|
|
154
|
+
throw bug;
|
|
155
|
+
return report;
|
|
156
|
+
}
|
|
157
|
+
export { TestStepResultStatus as StepStatus };
|
|
158
|
+
//# sourceMappingURL=cucumber.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cucumber.js","sourceRoot":"","sources":["../src/cucumber.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EAA8C,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACjG,O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C,OAAO,EAAE,CAAC,CAAC;QAC1G,CAAC;IACH,CAAC,CAAC,CAAC;IACH,IAAI,GAAG,KAAK,SAAS;QAAE,MAAM,GAAG,CAAC;IACjC,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,OAAO,EAAE,oBAAoB,IAAI,UAAU,EAAE,CAAC"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import type { Node } from "./ast.ts";
|
|
2
|
+
import { type Secret } from "./secret.ts";
|
|
3
|
+
/** Something a data file may not hold, at UTF-16 offsets into its text. */
|
|
4
|
+
export interface DataFileProblem {
|
|
5
|
+
start: number;
|
|
6
|
+
end: number;
|
|
7
|
+
message: string;
|
|
8
|
+
}
|
|
9
|
+
/** A name in a data file that refers to a declared resource: one imported from a data file, or exported by this one. */
|
|
10
|
+
export declare class Reference {
|
|
11
|
+
readonly name: string;
|
|
12
|
+
constructor(name: string);
|
|
13
|
+
}
|
|
14
|
+
/** True for a `Reference`, made by any copy of this package: read by a registered symbol, not `instanceof`. */
|
|
15
|
+
export declare const isReference: (value: unknown) => value is Reference;
|
|
16
|
+
/** What `secret("NAME")` stands for in a data file: its marker, `{ $secret: "NAME", generate?: true }`. */
|
|
17
|
+
export type SecretRef = Secret;
|
|
18
|
+
/** A value in a data file: a literal, a reference to a declared resource, or a secret's marker. */
|
|
19
|
+
export type DataValue = null | boolean | number | string | Reference | SecretRef | DataValue[] | {
|
|
20
|
+
[field: string]: DataValue;
|
|
21
|
+
};
|
|
22
|
+
/** An `import { name } from "…"`: of a connector's constructors (`from "…/resources"`), or of another data file's resource. */
|
|
23
|
+
export interface DataFileImport {
|
|
24
|
+
kind: "constructors" | "file";
|
|
25
|
+
/** The specifier as written. */
|
|
26
|
+
source: string;
|
|
27
|
+
/** The name the other module exports. */
|
|
28
|
+
imported: string;
|
|
29
|
+
/** The name it has in this file. */
|
|
30
|
+
local: string;
|
|
31
|
+
start: number;
|
|
32
|
+
}
|
|
33
|
+
/** An `export const name = vendor.type({ … })`. */
|
|
34
|
+
export interface DataFileExport {
|
|
35
|
+
name: string;
|
|
36
|
+
/** The local name of the constructors it calls (`github`). */
|
|
37
|
+
vendor: string;
|
|
38
|
+
type: string;
|
|
39
|
+
desired: {
|
|
40
|
+
[field: string]: DataValue;
|
|
41
|
+
};
|
|
42
|
+
/** The `export const` statement. */
|
|
43
|
+
start: number;
|
|
44
|
+
end: number;
|
|
45
|
+
}
|
|
46
|
+
export interface DataFile {
|
|
47
|
+
imports: DataFileImport[];
|
|
48
|
+
/** Each `export const` whose value is in the subset. */
|
|
49
|
+
exports: DataFileExport[];
|
|
50
|
+
/** Every name an `export const` declares, its value in the subset or not. */
|
|
51
|
+
declared: string[];
|
|
52
|
+
problems: DataFileProblem[];
|
|
53
|
+
}
|
|
54
|
+
/** Where a data file imports `secret` from; checked before `CONSTRUCTORS`, which they match too. */
|
|
55
|
+
export declare const SECRET_ENTRIES: ReadonlySet<string>;
|
|
56
|
+
/**
|
|
57
|
+
* Reads a data file's program without running it: its imports, each `export const` resource
|
|
58
|
+
* with its fields evaluated, and everything outside the data-file subset as a problem that says
|
|
59
|
+
* what to write instead.
|
|
60
|
+
*
|
|
61
|
+
* The subset: named imports, from a connector's `…/resources` entry or a `.ts` data file;
|
|
62
|
+
* `export const <name> = <vendor>.<type>({ … })`, one per statement, its argument built of
|
|
63
|
+
* strings (template literals without `${}` too), numbers, booleans, null, objects and arrays,
|
|
64
|
+
* and names of resources this file declares or imports; and `export default [a, b]`.
|
|
65
|
+
*
|
|
66
|
+
* `root` is the directory relative imports must stay in: by default the nearest `resources/`
|
|
67
|
+
* directory above `filename`, else the file's own.
|
|
68
|
+
*/
|
|
69
|
+
export declare function readDataFile(program: Node, filename: string, root?: string): DataFile;
|
|
70
|
+
/** A property's name: an identifier's, or a literal's as a string; undefined for any other key. */
|
|
71
|
+
export declare const keyName: (key: Node) => string | undefined;
|