@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
package/dist/outline.js
ADDED
|
@@ -0,0 +1,506 @@
|
|
|
1
|
+
import { childrenOf, readSource } from "./ast.js";
|
|
2
|
+
import { opIdsOf } from "./define.js";
|
|
3
|
+
import { childLists, DEFAULT_SLEEP_NAME, fitsOp, flatten } from "./shared.js";
|
|
4
|
+
const FUNCTIONS = new Set(["ArrowFunctionExpression", "FunctionExpression", "FunctionDeclaration"]);
|
|
5
|
+
const ITERATING = new Set(["map", "forEach", "reduce"]);
|
|
6
|
+
// Wrappers that leave the expression's value as it is: `ctx!.x`, `(ctx as Ctx).x`, `ctx?.x`.
|
|
7
|
+
const TRANSPARENT = new Set([
|
|
8
|
+
"TSNonNullExpression",
|
|
9
|
+
"TSAsExpression",
|
|
10
|
+
"TSSatisfiesExpression",
|
|
11
|
+
"TSTypeAssertion",
|
|
12
|
+
"ChainExpression",
|
|
13
|
+
]);
|
|
14
|
+
/**
|
|
15
|
+
* Outlines a workflow from the file that defined it (`wf.file`): TypeScript or, once built,
|
|
16
|
+
* JavaScript. Counts only calls on `run`'s first parameter, whatever it is named. Returns
|
|
17
|
+
* `{ error }` when the file cannot be read or parsed, holds no workflow of that name, `run`
|
|
18
|
+
* takes no `ctx` by name, or `run` holds what the outline cannot draw (each problem at
|
|
19
|
+
* `file:line:column`).
|
|
20
|
+
*/
|
|
21
|
+
export const outlineWorkflow = (wf) => outlineWithSource(wf, readSource(wf.file)).outline;
|
|
22
|
+
/**
|
|
23
|
+
* `outlineWorkflow` over `file`, the workflow's file as `readSource` read it, with the text its
|
|
24
|
+
* spans index into (none with an `{ error }`). `found` is whether the file was parsed and holds
|
|
25
|
+
* the workflow's `run`: an `{ error }` with it found is what `run` holds that the outline cannot
|
|
26
|
+
* draw, which the lint reports too; one without is the file's (unread, unparsed, or no workflow
|
|
27
|
+
* of that name).
|
|
28
|
+
*/
|
|
29
|
+
export function outlineWithSource(wf, file) {
|
|
30
|
+
if (typeof file === "string")
|
|
31
|
+
return { outline: { error: file }, found: false };
|
|
32
|
+
if (file.problems.length) {
|
|
33
|
+
const why = file.problems[0].message.replace(/^syntax: /, "");
|
|
34
|
+
return { outline: { error: `${file.file} could not be parsed: ${why}` }, found: false };
|
|
35
|
+
}
|
|
36
|
+
const consts = constsOf(file.program);
|
|
37
|
+
const fn = runIn(file.program, wf.name, consts);
|
|
38
|
+
if (!fn)
|
|
39
|
+
return { outline: { error: `${file.file} holds no workflow named "${wf.name}"` }, found: false };
|
|
40
|
+
const { nodes, problems } = outlineBody(fn, { consts, source: file.source });
|
|
41
|
+
if (problems.length) {
|
|
42
|
+
const lines = problems.map((p) => {
|
|
43
|
+
const { line, column } = file.at(p.start);
|
|
44
|
+
return `${file.file}:${line}:${column}: ${p.message}`;
|
|
45
|
+
});
|
|
46
|
+
return { outline: { error: lines.join("\n") }, found: true };
|
|
47
|
+
}
|
|
48
|
+
return {
|
|
49
|
+
source: file.source,
|
|
50
|
+
outline: { nodes: withOps(withPaths(nodes, ""), opIdsOf(wf)), file: wf.file },
|
|
51
|
+
found: true,
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
/** Gives each op node with a computed segment the ids in `uses` it fits, in place. */
|
|
55
|
+
function withOps(nodes, uses) {
|
|
56
|
+
for (const node of flatten(nodes)) {
|
|
57
|
+
if (node.kind === "op" && node.id.includes("*"))
|
|
58
|
+
node.ops = uses.filter((id) => fitsOp(node.id, id)).toSorted();
|
|
59
|
+
}
|
|
60
|
+
return nodes;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* The workflow's `run` in its file: the literal `defineWorkflow` is called with that has its
|
|
64
|
+
* `name` (a string, or a top-level `const` of the file holding it) and a `run` function.
|
|
65
|
+
*/
|
|
66
|
+
function runIn(program, name, consts) {
|
|
67
|
+
return workflowLiterals(program).find((literal) => literalOf(literal.name, consts) === name)?.run;
|
|
68
|
+
}
|
|
69
|
+
/** The file's top-level string constants, `export const NAME = "drift"`, by name: what a name may be besides a literal. */
|
|
70
|
+
export function constsOf(program) {
|
|
71
|
+
const consts = new Map();
|
|
72
|
+
for (const statement of program.body) {
|
|
73
|
+
const declaration = statement.type === "ExportNamedDeclaration" ? statement.declaration : statement;
|
|
74
|
+
if (declaration?.type !== "VariableDeclaration" || declaration.kind !== "const")
|
|
75
|
+
continue;
|
|
76
|
+
for (const d of declaration.declarations) {
|
|
77
|
+
const value = stringValue(d.init);
|
|
78
|
+
if (d.id.type === "Identifier" && value !== undefined)
|
|
79
|
+
consts.set(d.id.name, value);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return consts;
|
|
83
|
+
}
|
|
84
|
+
/** A string literal's value, or a top-level `const`'s holding one (`consts`). */
|
|
85
|
+
const literalOf = (node, consts) => unwrap(node)?.type === "Identifier" ? consts.get(unwrap(node).name) : stringValue(node);
|
|
86
|
+
/** The most of a loop's code its label quotes: past this, it is cut with `…`. */
|
|
87
|
+
const LABEL_TEXT = 40;
|
|
88
|
+
/**
|
|
89
|
+
* Numbers the nodes: each its index under `prefix`, its children under its path and their
|
|
90
|
+
* list's index. `outlineBody` leaves every path empty, since a node's place is known once the
|
|
91
|
+
* list it is in is whole; the nodes are freshly built, so they are filled in place.
|
|
92
|
+
*/
|
|
93
|
+
function withPaths(nodes, prefix) {
|
|
94
|
+
nodes.forEach((node, i) => {
|
|
95
|
+
node.path = `${prefix}${i}`;
|
|
96
|
+
childLists(node).forEach((list, j) => withPaths(list, `${node.path}.${j}.`));
|
|
97
|
+
});
|
|
98
|
+
return nodes;
|
|
99
|
+
}
|
|
100
|
+
const span = (node) => [node.start, node.end];
|
|
101
|
+
const PARAM = "run must take ctx as its first parameter, by one name: destructured, its calls cannot be read into the graph";
|
|
102
|
+
const CTX_USE = "ctx is only called, directly (`await ctx.<vendor>.<resource>.<op>(…)`, `ctx.approval(…)`, `ctx.sleep(…)`, " +
|
|
103
|
+
"`ctx.all([…])`) or read for ctx.runId: passed on, aliased or destructured, its calls are not in the graph";
|
|
104
|
+
const CTX_CALL = (what) => `ctx.${what} is not a call the graph can draw: an operation is ctx.<vendor>.<resource>.<op>(…), ` +
|
|
105
|
+
"and the built-ins are ctx.approval(…), ctx.sleep(…), ctx.all([…]) and ctx.now()";
|
|
106
|
+
const ALL_MEMBERS = "ctx.all's members must be written in the call, so the graph shows what each does: a list, " +
|
|
107
|
+
"`ctx.all([() => …, () => …])`, or one per item, `ctx.all(items.map((item) => () => …))`";
|
|
108
|
+
const UNREAD = "a function defined in run uses ctx, and the outline does not read it: inline its calls, or pass it to " +
|
|
109
|
+
"ctx.all, .map, .forEach or .reduce, so the run's graph shows them";
|
|
110
|
+
const FINALLY = "ctx is not allowed in a finally: the graph does not draw one; move the call after the try, or into the catch";
|
|
111
|
+
const RETURN = "`return` before the end of run is not allowed in a workflow: the graph runs top to bottom; use if/else around the rest";
|
|
112
|
+
const THROW = "`throw` outside a catch is not allowed in a workflow: the graph shows no way out; let the failing call end the run, or use if/else";
|
|
113
|
+
const BREAK = "`break` out of a loop, or to a label, is not allowed in a workflow: the graph repeats the whole body; use if/else, or a condition in the loop";
|
|
114
|
+
const CONTINUE = "`continue` is not allowed in a workflow: the graph repeats the whole body; use if/else around the rest of it";
|
|
115
|
+
const NAME = 'a step\'s name must be a string literal, or a top-level const holding one, so the outline can read it: `{ name: "…" }`';
|
|
116
|
+
const DEFAULT_LIKE = (name) => `"${name}" is what a call without a name is called (an operation's id, or "${DEFAULT_SLEEP_NAME}"), so a test ` +
|
|
117
|
+
'could not tell this step from those: name it in words, such as `{ name: "Draft the post" }`';
|
|
118
|
+
/** Two steps given one name, and how to tell them apart. */
|
|
119
|
+
const TWICE = (name, fix) => `two steps of this workflow are named "${name}": a name given is one step's, so a test or the graph can tell them apart; ${fix}`;
|
|
120
|
+
/** A name given that reads as an operation's id: what an unnamed call is called. */
|
|
121
|
+
const OP_ID = /^[\w-]+(\.[\w-]+){2}$/;
|
|
122
|
+
/** Where a function's body starts: its own statement rules, nothing of the caller's. */
|
|
123
|
+
const bodyOf = (fn) => ({ fn, inCatch: false });
|
|
124
|
+
/** The members of `ctx` that are read, not placed: no record, no node. */
|
|
125
|
+
const READS = new Set(["now", "runId"]);
|
|
126
|
+
/**
|
|
127
|
+
* The nodes of `fn`'s body (`run`'s, or a callback's the outline reads), each with an empty `path`
|
|
128
|
+
* for `withPaths` to fill, and the problems: what the body does that the graph could not show.
|
|
129
|
+
* A call's `{ name }`, and an approval's title, is a string literal or one of `consts`
|
|
130
|
+
* (`constsOf` the file); a name given is not an operation's id or `Sleep`, and no two steps are
|
|
131
|
+
* given one name (`twiceNamed`). A loop's label quotes its code from `source`, the file's text.
|
|
132
|
+
* `ctx` is `fn`'s first parameter, taken by one name (destructured is a problem; none, and the
|
|
133
|
+
* body makes no calls). `ctx` is only called, directly, as an operation or a built-in, or read
|
|
134
|
+
* for `ctx.runId`; a function defined inside that uses `ctx` is read only where the outline
|
|
135
|
+
* reads callbacks (`ctx.all`'s members, `.map`, `.forEach` and `.reduce`), elsewhere it is a
|
|
136
|
+
* problem; a `finally` may not use `ctx`; and in a body the outline reads, `return` comes last,
|
|
137
|
+
* `throw` only in a `catch`, `break` leaves only a `switch`, and there is no `continue`. A
|
|
138
|
+
* callback without `ctx` computes, and is not read.
|
|
139
|
+
*/
|
|
140
|
+
export function outlineBody(fn, { consts, source }) {
|
|
141
|
+
const problems = [];
|
|
142
|
+
const problem = (node, message) => {
|
|
143
|
+
problems.push({ start: node.start, message });
|
|
144
|
+
return [];
|
|
145
|
+
};
|
|
146
|
+
const param = unwrap(fn.params[0]);
|
|
147
|
+
if (param === undefined)
|
|
148
|
+
return { nodes: [], problems };
|
|
149
|
+
if (param.type !== "Identifier")
|
|
150
|
+
return { nodes: problem(param, PARAM), problems };
|
|
151
|
+
const ctx = param.name;
|
|
152
|
+
const path = "";
|
|
153
|
+
/** True when the code mentions `ctx` anywhere but as a property name. A function's answer is kept: `walk` asks again inside it. */
|
|
154
|
+
const functionsUsing = new WeakMap();
|
|
155
|
+
const usesCtx = (node) => {
|
|
156
|
+
if (!node || typeof node !== "object")
|
|
157
|
+
return false;
|
|
158
|
+
if (Array.isArray(node))
|
|
159
|
+
return node.some(usesCtx);
|
|
160
|
+
if (node.type === "Identifier")
|
|
161
|
+
return node.name === ctx;
|
|
162
|
+
if (node.type === "Property" && !node.computed)
|
|
163
|
+
return usesCtx(node.value);
|
|
164
|
+
if (node.type === "MemberExpression" && !node.computed)
|
|
165
|
+
return usesCtx(node.object);
|
|
166
|
+
if (!FUNCTIONS.has(node.type))
|
|
167
|
+
return childrenOf(node).some(usesCtx);
|
|
168
|
+
let uses = functionsUsing.get(node);
|
|
169
|
+
if (uses === undefined)
|
|
170
|
+
functionsUsing.set(node, (uses = childrenOf(node).some(usesCtx)));
|
|
171
|
+
return uses;
|
|
172
|
+
};
|
|
173
|
+
/** `ctx.runId`, read. */
|
|
174
|
+
const isRead = (member) => !member.computed &&
|
|
175
|
+
unwrap(member.object)?.type === "Identifier" &&
|
|
176
|
+
unwrap(member.object).name === ctx &&
|
|
177
|
+
READS.has(member.property.name);
|
|
178
|
+
const walk = (node, at) => {
|
|
179
|
+
if (!node || typeof node !== "object")
|
|
180
|
+
return [];
|
|
181
|
+
if (Array.isArray(node))
|
|
182
|
+
return node.flatMap((n) => walk(n, at));
|
|
183
|
+
const children = (...nodes) => nodes.flatMap((n) => walk(n, at));
|
|
184
|
+
switch (node.type) {
|
|
185
|
+
case "Identifier":
|
|
186
|
+
return node.name === ctx ? problem(node, CTX_USE) : [];
|
|
187
|
+
// A property's name is no reference, `{ ctx: 1 }`, `a.ctx`.
|
|
188
|
+
case "Property":
|
|
189
|
+
return node.computed ? children(node.key, node.value) : children(node.value);
|
|
190
|
+
case "MemberExpression":
|
|
191
|
+
if (isRead(node))
|
|
192
|
+
return [];
|
|
193
|
+
return node.computed ? children(node.object, node.property) : children(node.object);
|
|
194
|
+
case "CallExpression":
|
|
195
|
+
return call(node, at);
|
|
196
|
+
case "IfStatement":
|
|
197
|
+
return [...children(node.test), ...branch(node, ifArms(node), at)];
|
|
198
|
+
case "ConditionalExpression":
|
|
199
|
+
return [...children(node.test), ...branch(node, [node.consequent, node.alternate], at)];
|
|
200
|
+
case "LogicalExpression":
|
|
201
|
+
// The right side may not run: the way past it is an arm with no calls.
|
|
202
|
+
return [...children(node.left), ...branch(node, [node.right, null], at)];
|
|
203
|
+
case "SwitchStatement":
|
|
204
|
+
return [...children(node.discriminant), ...branch(node, switchArms(node), { ...at, breakable: "switch" })];
|
|
205
|
+
case "ForStatement":
|
|
206
|
+
return [...children(node.init), ...repeat(node, [node.test, node.body, node.update], at, whileOf(node.test))];
|
|
207
|
+
case "ForOfStatement":
|
|
208
|
+
return [...children(node.right), ...repeat(node, [node.left, node.body], at, of("for each of", node.right))];
|
|
209
|
+
case "ForInStatement":
|
|
210
|
+
return [
|
|
211
|
+
...children(node.right),
|
|
212
|
+
...repeat(node, [node.left, node.body], at, of("for each key of", node.right)),
|
|
213
|
+
];
|
|
214
|
+
case "WhileStatement":
|
|
215
|
+
return repeat(node, [node.test, node.body], at, whileOf(node.test));
|
|
216
|
+
case "DoWhileStatement":
|
|
217
|
+
return repeat(node, [node.body, node.test], at, whileOf(node.test));
|
|
218
|
+
case "LabeledStatement":
|
|
219
|
+
return children(node.body);
|
|
220
|
+
case "TryStatement": {
|
|
221
|
+
const inside = children(node.block);
|
|
222
|
+
const handler = walk(node.handler?.body, { ...at, inCatch: true });
|
|
223
|
+
// A finally makes no calls, and keeps to the statement rules like the rest.
|
|
224
|
+
if (usesCtx(node.finalizer))
|
|
225
|
+
problem(node.finalizer, FINALLY);
|
|
226
|
+
children(node.finalizer);
|
|
227
|
+
return inside.length || handler.length ? [{ kind: "try", path, body: inside, handler, span: span(node) }] : [];
|
|
228
|
+
}
|
|
229
|
+
case "ReturnStatement": {
|
|
230
|
+
// Last at the top of the function's body: anywhere else, what follows would be drawn as run.
|
|
231
|
+
const body = at.fn.body;
|
|
232
|
+
if (!(body?.type === "BlockStatement" && body.body.at(-1) === node))
|
|
233
|
+
problem(node, RETURN);
|
|
234
|
+
return children(node.argument);
|
|
235
|
+
}
|
|
236
|
+
case "ThrowStatement":
|
|
237
|
+
if (!at.inCatch)
|
|
238
|
+
problem(node, THROW);
|
|
239
|
+
return children(node.argument);
|
|
240
|
+
case "BreakStatement":
|
|
241
|
+
if (node.label || at.breakable === "loop")
|
|
242
|
+
problem(node, BREAK);
|
|
243
|
+
return [];
|
|
244
|
+
case "ContinueStatement":
|
|
245
|
+
return problem(node, CONTINUE);
|
|
246
|
+
}
|
|
247
|
+
// A function's body runs when the function is called, wherever and however often that is,
|
|
248
|
+
// which a reading of the source cannot follow. Only the callbacks of ctx.all and of `.map`,
|
|
249
|
+
// `.forEach` and `.reduce` are read, where they are passed (`call`, `all`).
|
|
250
|
+
if (FUNCTIONS.has(node.type))
|
|
251
|
+
return usesCtx(node) ? problem(node, UNREAD) : [];
|
|
252
|
+
return children(...childrenOf(node));
|
|
253
|
+
};
|
|
254
|
+
// The arms that make calls, and one empty arm when some arm makes none: the way past them.
|
|
255
|
+
const branch = (node, arms, at) => {
|
|
256
|
+
const walked = arms.map((arm) => walk(arm, at));
|
|
257
|
+
const cases = walked.filter((c) => c.length > 0);
|
|
258
|
+
if (!cases.length)
|
|
259
|
+
return [];
|
|
260
|
+
if (cases.length < walked.length)
|
|
261
|
+
cases.push([]);
|
|
262
|
+
return [{ kind: "branch", path, cases, span: span(node) }];
|
|
263
|
+
};
|
|
264
|
+
const repeat = (node, parts, at, label) => {
|
|
265
|
+
const inside = parts.flatMap((part) => walk(part, { ...at, breakable: "loop" }));
|
|
266
|
+
return inside.length ? [{ kind: "repeat", path, label, body: inside, span: span(node) }] : [];
|
|
267
|
+
};
|
|
268
|
+
/** Code as a label quotes it: on one line, cut at `LABEL_TEXT`. */
|
|
269
|
+
const quoted = (node) => {
|
|
270
|
+
// A chain broken over lines (`items\n .filter(…)`) joined again, then the rest on one line.
|
|
271
|
+
const text = source
|
|
272
|
+
.slice(node.start, node.end)
|
|
273
|
+
.replaceAll(/\s*\n\s*(?=\.)/g, "")
|
|
274
|
+
.replaceAll(/\s+/g, " ")
|
|
275
|
+
.trim();
|
|
276
|
+
return text.length > LABEL_TEXT ? `${text.slice(0, LABEL_TEXT - 1).trimEnd()}…` : text;
|
|
277
|
+
};
|
|
278
|
+
/** A loop over `items`: "for each of items", `how` saying how. */
|
|
279
|
+
const of = (how, items) => `${how} ${quoted(items)}`;
|
|
280
|
+
/** A loop while `test` holds: "repeat while test", or "repeat" without a test. */
|
|
281
|
+
const whileOf = (test) => (test ? `repeat while ${quoted(test)}` : "repeat");
|
|
282
|
+
/**
|
|
283
|
+
* A step's name as the call gives it, in `{ name: "…" }` after the call's input: a string
|
|
284
|
+
* literal or a top-level const, not an operation's id or `Sleep`, which unnamed calls are called.
|
|
285
|
+
*/
|
|
286
|
+
const nameIn = (options) => {
|
|
287
|
+
if (options === undefined)
|
|
288
|
+
return undefined;
|
|
289
|
+
const literal = unwrap(options);
|
|
290
|
+
const property = literal?.type === "ObjectExpression" && literal.properties.length === 1 ? literal.properties[0] : undefined;
|
|
291
|
+
const key = property?.type === "Property" && !property.computed ? (property.key.name ?? property.key.value) : "";
|
|
292
|
+
const name = key === "name" ? literalOf(property.value, consts) : undefined;
|
|
293
|
+
if (name === undefined || !/\S/.test(name))
|
|
294
|
+
problem(options, NAME);
|
|
295
|
+
else if (name === DEFAULT_SLEEP_NAME || OP_ID.test(name))
|
|
296
|
+
problem(options, DEFAULT_LIKE(name));
|
|
297
|
+
else
|
|
298
|
+
return name;
|
|
299
|
+
return undefined;
|
|
300
|
+
};
|
|
301
|
+
// The arguments are evaluated before the call is made, so their calls come first.
|
|
302
|
+
const call = (node, at) => {
|
|
303
|
+
const args = node.arguments;
|
|
304
|
+
const members = ctxPath(node.callee, ctx);
|
|
305
|
+
if (members) {
|
|
306
|
+
const id = members.join(".");
|
|
307
|
+
switch (id) {
|
|
308
|
+
case "all":
|
|
309
|
+
return all(node, at);
|
|
310
|
+
case "approval": {
|
|
311
|
+
const title = args[0] === undefined ? undefined : literalOf(args[0], consts);
|
|
312
|
+
return [
|
|
313
|
+
...walk(args, at),
|
|
314
|
+
{ kind: "approval", path, span: span(node), ...(title === undefined ? {} : { title, name: title }) },
|
|
315
|
+
];
|
|
316
|
+
}
|
|
317
|
+
case "sleep":
|
|
318
|
+
return [
|
|
319
|
+
...walk(args, at),
|
|
320
|
+
{ kind: "sleep", path, span: span(node), name: nameIn(args[1]) ?? DEFAULT_SLEEP_NAME },
|
|
321
|
+
];
|
|
322
|
+
default:
|
|
323
|
+
if (members.length === 3) {
|
|
324
|
+
// A computed id's own name is the operation it calls, known only in a run.
|
|
325
|
+
const name = nameIn(args[1]) ?? (id.includes("*") ? undefined : id);
|
|
326
|
+
return [
|
|
327
|
+
...walk(args, at),
|
|
328
|
+
{ kind: "op", path, id, span: span(node), ...(name === undefined ? {} : { name }) },
|
|
329
|
+
];
|
|
330
|
+
}
|
|
331
|
+
return READS.has(id) ? walk(args, at) : [...walk(args, at), ...problem(node, CTX_CALL(id))];
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
const callee = unwrap(node.callee);
|
|
335
|
+
const [callback, ...rest] = args;
|
|
336
|
+
if (callee?.type === "MemberExpression" && !callee.computed && ITERATING.has(callee.property.name)) {
|
|
337
|
+
if (FUNCTIONS.has(callback?.type) && usesCtx(callback)) {
|
|
338
|
+
return [
|
|
339
|
+
...walk(callee.object, at),
|
|
340
|
+
...walk(rest, at),
|
|
341
|
+
...repeat(node, [callback.body], bodyOf(callback), of("for each of", callee.object)),
|
|
342
|
+
];
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
return [...walk(node.callee, at), ...walk(args, at)];
|
|
346
|
+
};
|
|
347
|
+
// `node` is the `ctx.all(...)` call.
|
|
348
|
+
const all = (node, at) => {
|
|
349
|
+
const whole = span(node);
|
|
350
|
+
const arg = unwrap(node.arguments[0]);
|
|
351
|
+
if (arg?.type === "ArrayExpression") {
|
|
352
|
+
return [{ kind: "all", path, branches: arg.elements.map((m) => member(m, at)), span: whole }];
|
|
353
|
+
}
|
|
354
|
+
// Otherwise the members are made in the call, `items.map((item) => () => ctx.…)`: made anywhere
|
|
355
|
+
// else, the graph could not say what each does.
|
|
356
|
+
const callback = arg?.type === "CallExpression" ? arg.arguments.find((a) => FUNCTIONS.has(a?.type)) : undefined;
|
|
357
|
+
if (!callback)
|
|
358
|
+
return [...walk(arg, at), ...problem(node, ALL_MEMBERS)];
|
|
359
|
+
// `items.map(cb)` and the like, labelled by `items`; any other call taking a callback, by itself.
|
|
360
|
+
const made = unwrap(arg.callee);
|
|
361
|
+
const iterates = made?.type === "MemberExpression" && !made.computed && ITERATING.has(made.property.name);
|
|
362
|
+
return [
|
|
363
|
+
...walk(arg.callee, at),
|
|
364
|
+
{
|
|
365
|
+
kind: "each",
|
|
366
|
+
path,
|
|
367
|
+
label: iterates ? of("for each of", made.object) : `for each of ${quoted(arg)}`,
|
|
368
|
+
body: member(callback.body, bodyOf(callback)),
|
|
369
|
+
span: whole,
|
|
370
|
+
},
|
|
371
|
+
];
|
|
372
|
+
};
|
|
373
|
+
// What a member does: a function's body, read where the function is passed, or else the calls
|
|
374
|
+
// the expression makes.
|
|
375
|
+
const member = (node, at) => {
|
|
376
|
+
const callback = unwrap(node);
|
|
377
|
+
return FUNCTIONS.has(callback?.type) ? walk(callback.body, bodyOf(callback)) : walk(node, at);
|
|
378
|
+
};
|
|
379
|
+
const nodes = walk(fn.body, bodyOf(fn));
|
|
380
|
+
problems.push(...twiceNamed(nodes));
|
|
381
|
+
return { nodes, problems: problems.toSorted((a, b) => a.start - b.start) };
|
|
382
|
+
}
|
|
383
|
+
/**
|
|
384
|
+
* Each step after the first given a name another was given: an explicit `{ name }`, or an
|
|
385
|
+
* approval's title. An unnamed call's name (its operation's id, or `Sleep`) may be several
|
|
386
|
+
* calls': the same operation in two arms of an `if`, a retry in a `catch`.
|
|
387
|
+
*/
|
|
388
|
+
function twiceNamed(nodes) {
|
|
389
|
+
const seen = new Set();
|
|
390
|
+
const problems = [];
|
|
391
|
+
for (const node of flatten(nodes)) {
|
|
392
|
+
let given;
|
|
393
|
+
if (node.kind === "approval" && node.name !== undefined) {
|
|
394
|
+
given = { name: node.name, fix: "give each approval a title of its own" };
|
|
395
|
+
}
|
|
396
|
+
else if ((node.kind === "op" && node.name !== node.id) ||
|
|
397
|
+
(node.kind === "sleep" && node.name !== DEFAULT_SLEEP_NAME)) {
|
|
398
|
+
given = node.name === undefined ? undefined : { name: node.name, fix: "rename one" };
|
|
399
|
+
}
|
|
400
|
+
if (!given)
|
|
401
|
+
continue;
|
|
402
|
+
if (seen.has(given.name))
|
|
403
|
+
problems.push({ start: node.span[0], message: TWICE(given.name, given.fix) });
|
|
404
|
+
seen.add(given.name);
|
|
405
|
+
}
|
|
406
|
+
return problems;
|
|
407
|
+
}
|
|
408
|
+
const CALLS = new Set(["op", "approval", "sleep", "all", "each"]);
|
|
409
|
+
/** The outline's call nodes, wherever they are in it, in order: what `callAt` searches. */
|
|
410
|
+
export const callsOf = (nodes) => flatten(nodes).filter((node) => CALLS.has(node.kind));
|
|
411
|
+
/** What a call node is called as on `ctx`: the operation's id (`*` for a computed segment), or `all`, `approval`, `sleep`. */
|
|
412
|
+
export const callName = (node) => node.kind === "op" ? node.id : node.kind === "each" ? "all" : node.kind;
|
|
413
|
+
/**
|
|
414
|
+
* The call a position in the source belongs to: the innermost of `calls` (`callsOf`) whose span
|
|
415
|
+
* holds the offset, as a stack frame places a call at its callee (`ctx.ghost.post.create(…)` at
|
|
416
|
+
* `create`). A call inside another's arguments is the inner one. None when no call's code holds
|
|
417
|
+
* it: a call made from a helper, or from a function defined inside `run`, which the outline does
|
|
418
|
+
* not read.
|
|
419
|
+
*/
|
|
420
|
+
export function callAt(calls, offset) {
|
|
421
|
+
let best;
|
|
422
|
+
for (const node of calls) {
|
|
423
|
+
const [start, end] = node.span;
|
|
424
|
+
if (offset < start || offset >= end)
|
|
425
|
+
continue;
|
|
426
|
+
if (!best || end - start < best.span[1] - best.span[0])
|
|
427
|
+
best = node;
|
|
428
|
+
}
|
|
429
|
+
return best;
|
|
430
|
+
}
|
|
431
|
+
/**
|
|
432
|
+
* `if (a) … else if (b) … else …` as its arms, the `else if` tests included in theirs. With no
|
|
433
|
+
* final `else`, the last arm is `null`: an arm with no calls, the way past the others.
|
|
434
|
+
*/
|
|
435
|
+
function ifArms(node) {
|
|
436
|
+
const arms = [node.consequent];
|
|
437
|
+
let rest = node.alternate;
|
|
438
|
+
while (rest?.type === "IfStatement") {
|
|
439
|
+
arms.push([rest.test, rest.consequent]);
|
|
440
|
+
rest = rest.alternate;
|
|
441
|
+
}
|
|
442
|
+
arms.push(rest);
|
|
443
|
+
return arms;
|
|
444
|
+
}
|
|
445
|
+
/**
|
|
446
|
+
* A `switch`'s arms: each case with statements (an empty one falls into the next), and with no
|
|
447
|
+
* `default`, `null` for the way past them.
|
|
448
|
+
*/
|
|
449
|
+
function switchArms(node) {
|
|
450
|
+
const arms = node.cases.filter((c) => c.consequent.length > 0);
|
|
451
|
+
return node.cases.some((c) => c.test === null) ? arms : [...arms, null];
|
|
452
|
+
}
|
|
453
|
+
/** The member names from `ctx` to the callee, `*` for a computed one, when the callee is on `ctx`. */
|
|
454
|
+
function ctxPath(callee, ctx) {
|
|
455
|
+
const path = [];
|
|
456
|
+
let node = unwrap(callee);
|
|
457
|
+
while (node?.type === "MemberExpression") {
|
|
458
|
+
path.unshift((node.computed ? stringValue(node.property) : node.property.name) ?? "*");
|
|
459
|
+
node = unwrap(node.object);
|
|
460
|
+
}
|
|
461
|
+
return node?.type === "Identifier" && node.name === ctx ? path : undefined;
|
|
462
|
+
}
|
|
463
|
+
/** A string literal's value, or a template literal's with nothing interpolated. */
|
|
464
|
+
function stringValue(node) {
|
|
465
|
+
const n = unwrap(node);
|
|
466
|
+
if (n?.type === "Literal" && typeof n.value === "string")
|
|
467
|
+
return n.value;
|
|
468
|
+
if (n?.type === "TemplateLiteral" && n.expressions.length === 0)
|
|
469
|
+
return n.quasis[0]?.value.cooked ?? undefined;
|
|
470
|
+
return undefined;
|
|
471
|
+
}
|
|
472
|
+
/** The node under the wrappers that leave its value as it is, and a default's pattern. */
|
|
473
|
+
export function unwrap(node) {
|
|
474
|
+
let n = node;
|
|
475
|
+
while (n && (TRANSPARENT.has(n.type) || n.type === "AssignmentPattern")) {
|
|
476
|
+
n = n.type === "AssignmentPattern" ? n.left : n.expression;
|
|
477
|
+
}
|
|
478
|
+
return n;
|
|
479
|
+
}
|
|
480
|
+
/**
|
|
481
|
+
* Every workflow literal in a parsed file: the object literal `defineWorkflow({ name, …, run })`
|
|
482
|
+
* (or `sanoma.defineWorkflow(…)`) is called with, when it has a `name` and a `run` function. For
|
|
483
|
+
* the outline, which picks the one by its name, and the lint, which checks each `run`.
|
|
484
|
+
*/
|
|
485
|
+
export function workflowLiterals(program) {
|
|
486
|
+
const found = [];
|
|
487
|
+
const find = (node) => {
|
|
488
|
+
if (!node)
|
|
489
|
+
return;
|
|
490
|
+
const literal = unwrap(node.arguments?.[0]);
|
|
491
|
+
const callee = unwrap(node.callee);
|
|
492
|
+
const called = callee?.type === "MemberExpression" && !callee.computed ? callee.property.name : callee?.name;
|
|
493
|
+
if (node.type === "CallExpression" && called === "defineWorkflow" && literal?.type === "ObjectExpression") {
|
|
494
|
+
const value = (key) => literal.properties.find((p) => p.type === "Property" && !p.computed && (p.key.name ?? p.key.value) === key)?.value;
|
|
495
|
+
const run = value("run");
|
|
496
|
+
const name = value("name");
|
|
497
|
+
if (name && FUNCTIONS.has(run?.type))
|
|
498
|
+
found.push({ name, run });
|
|
499
|
+
}
|
|
500
|
+
for (const child of childrenOf(node))
|
|
501
|
+
find(child);
|
|
502
|
+
};
|
|
503
|
+
find(program);
|
|
504
|
+
return found;
|
|
505
|
+
}
|
|
506
|
+
//# sourceMappingURL=outline.js.map
|
|
@@ -0,0 +1 @@
|
|
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E: RegExp;
|
|
3
|
+
/**
|
|
4
|
+
* What `found` returns for the nearest of `dir` and its ancestors for which it returns something,
|
|
5
|
+
* nearest first; undefined when it returns nothing for any. The one walk up the directories.
|
|
6
|
+
*/
|
|
7
|
+
export declare function upFrom<T>(dir: string, found: (dir: string) => T | undefined): T | undefined;
|
|
8
|
+
/** The file's nearest ancestor directory with one of `names` (`workflows`, `resources`), else its own directory. */
|
|
9
|
+
export declare function nearestDir(filename: string, names: readonly string[]): string;
|
|
10
|
+
/** True when `path` is `dir` or inside it. */
|
|
11
|
+
export declare function inside(dir: string, path: string): boolean;
|
package/dist/paths.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { basename, dirname, isAbsolute, relative, sep } from "node:path";
|
|
2
|
+
// Where an import may reach, as the lints and the data-file reader all decide it, and the one
|
|
3
|
+
// walk up the directories. Node's `path` only, no parser: the oxlint plugin loads it.
|
|
4
|
+
/** A relative import specifier: `./x.ts`, `../y.ts`. */
|
|
5
|
+
export const RELATIVE = /^\.\.?\//;
|
|
6
|
+
/**
|
|
7
|
+
* What `found` returns for the nearest of `dir` and its ancestors for which it returns something,
|
|
8
|
+
* nearest first; undefined when it returns nothing for any. The one walk up the directories.
|
|
9
|
+
*/
|
|
10
|
+
export function upFrom(dir, found) {
|
|
11
|
+
for (;;) {
|
|
12
|
+
const value = found(dir);
|
|
13
|
+
if (value !== undefined)
|
|
14
|
+
return value;
|
|
15
|
+
const up = dirname(dir);
|
|
16
|
+
if (up === dir)
|
|
17
|
+
return undefined;
|
|
18
|
+
dir = up;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
/** The file's nearest ancestor directory with one of `names` (`workflows`, `resources`), else its own directory. */
|
|
22
|
+
export function nearestDir(filename, names) {
|
|
23
|
+
return upFrom(dirname(filename), (dir) => (names.includes(basename(dir)) ? dir : undefined)) ?? dirname(filename);
|
|
24
|
+
}
|
|
25
|
+
/** True when `path` is `dir` or inside it. */
|
|
26
|
+
export function inside(dir, path) {
|
|
27
|
+
const rel = relative(dir, path);
|
|
28
|
+
return rel === "" || (rel.split(sep)[0] !== ".." && !isAbsolute(rel));
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=paths.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paths.js","sourceRoot":"","sources":["../src/paths.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAEzE,8FAA8F;AAC9F,sFAAsF;AAEtF,wDAAwD;AACxD,MAAM,CAAC,MAAM,QAAQ,GAAG,UAAU,CAAC;AAEnC;;;GAGG;AACH,MAAM,UAAU,MAAM,CAAI,GAAW,EAAE,KAAqC;IAC1E,SAAS,CAAC;QACR,MAAM,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC;QACzB,IAAI,KAAK,KAAK,SAAS;YAAE,OAAO,KAAK,CAAC;QACtC,MAAM,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;QACxB,IAAI,EAAE,KAAK,GAAG;YAAE,OAAO,SAAS,CAAC;QACjC,GAAG,GAAG,EAAE,CAAC;IACX,CAAC;AACH,CAAC;AAED,oHAAoH;AACpH,MAAM,UAAU,UAAU,CAAC,QAAgB,EAAE,KAAwB;IACnE,OAAO,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,IAAI,OAAO,CAAC,QAAQ,CAAC,CAAC;AACpH,CAAC;AAED,8CAA8C;AAC9C,MAAM,UAAU,MAAM,CAAC,GAAW,EAAE,IAAY;IAC9C,MAAM,GAAG,GAAG,QAAQ,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;IAChC,OAAO,GAAG,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC;AACxE,CAAC"}
|
package/dist/plugin.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
interface Context {
|
|
2
|
+
filename: string;
|
|
3
|
+
report(diagnostic: {
|
|
4
|
+
message: string;
|
|
5
|
+
node: {
|
|
6
|
+
range: [number, number];
|
|
7
|
+
};
|
|
8
|
+
}): void;
|
|
9
|
+
}
|
|
10
|
+
declare const plugin: {
|
|
11
|
+
meta: {
|
|
12
|
+
name: string;
|
|
13
|
+
};
|
|
14
|
+
rules: {
|
|
15
|
+
"data-file": {
|
|
16
|
+
meta: {
|
|
17
|
+
type: string;
|
|
18
|
+
docs: {
|
|
19
|
+
description: string;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
create(context: Context): {
|
|
23
|
+
Program(program: unknown): void;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
export default plugin;
|
package/dist/plugin.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { readDataFile } from "./datafile.js";
|
|
2
|
+
const plugin = {
|
|
3
|
+
meta: { name: "sanoma" },
|
|
4
|
+
rules: {
|
|
5
|
+
"data-file": {
|
|
6
|
+
meta: {
|
|
7
|
+
type: "problem",
|
|
8
|
+
docs: {
|
|
9
|
+
description: "A data file under resources/ holds only imports, `export const <name> = <vendor>.<type>({ … })` with literal fields, and `export default [ … ]`",
|
|
10
|
+
},
|
|
11
|
+
},
|
|
12
|
+
create(context) {
|
|
13
|
+
return {
|
|
14
|
+
Program(program) {
|
|
15
|
+
for (const { start, end, message } of readDataFile(program, context.filename).problems) {
|
|
16
|
+
context.report({ message, node: { range: [start, end] } });
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
export default plugin;
|
|
25
|
+
//# sourceMappingURL=plugin.js.map
|