ts2workflows 0.13.0 → 0.15.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/CHANGELOG.md +19 -0
- package/README.md +1 -1
- package/dist/ast/expressions.d.ts +2 -2
- package/dist/ast/expressions.d.ts.map +1 -1
- package/dist/ast/expressions.js +4 -1
- package/dist/cli.js +14 -72
- package/dist/diagnostics.d.ts +3 -0
- package/dist/diagnostics.d.ts.map +1 -0
- package/dist/diagnostics.js +46 -0
- package/dist/errors.d.ts +8 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +21 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/transpiler/generated/functionMetadata.d.ts.map +1 -1
- package/dist/transpiler/generated/functionMetadata.js +267 -0
- package/dist/transpiler/index.d.ts +1 -4
- package/dist/transpiler/index.d.ts.map +1 -1
- package/dist/transpiler/index.js +34 -15
- package/dist/transpiler/parseexpressions.d.ts.map +1 -1
- package/dist/transpiler/parseexpressions.js +15 -2
- package/dist/transpiler/transformations.d.ts.map +1 -1
- package/dist/transpiler/transformations.js +37 -12
- package/language_reference.md +27 -14
- package/package.json +3 -3
- package/types/global.d.ts +1 -0
- package/types/workflowslib.d.ts +369 -29
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# ts2workflows changelog
|
|
2
2
|
|
|
3
|
+
## Version 0.15.0 - 2026-03-18
|
|
4
|
+
|
|
5
|
+
New features:
|
|
6
|
+
|
|
7
|
+
- Static method `Array.includes(arr, x)` for checking if the array `arr` contain the value `x`
|
|
8
|
+
|
|
9
|
+
Fixes:
|
|
10
|
+
|
|
11
|
+
- Print the correct source code line on error messages
|
|
12
|
+
- Type annotation fixes in workflowslib
|
|
13
|
+
|
|
14
|
+
## Version 0.14.0 - 2025-11-19
|
|
15
|
+
|
|
16
|
+
Fixes:
|
|
17
|
+
|
|
18
|
+
- Blocking calls and assignments were generated in a wrong order in complex expressions
|
|
19
|
+
- Don't output undefined arguments in call steps
|
|
20
|
+
- Type annotation fixes in workflowslib
|
|
21
|
+
|
|
3
22
|
## Version 0.13.0 - 2025-10-12
|
|
4
23
|
|
|
5
24
|
Fixes:
|
package/README.md
CHANGED
|
@@ -38,9 +38,9 @@ export declare function variableReferenceEx(variableName: VariableName): Variabl
|
|
|
38
38
|
export interface FunctionInvocationExpression {
|
|
39
39
|
readonly tag: 'functionInvocation';
|
|
40
40
|
readonly functionName: string;
|
|
41
|
-
readonly arguments: Expression[];
|
|
41
|
+
readonly arguments: (Expression | undefined)[];
|
|
42
42
|
}
|
|
43
|
-
export declare function functionInvocationEx(functionName: string, argumentExpressions: Expression[]): FunctionInvocationExpression;
|
|
43
|
+
export declare function functionInvocationEx(functionName: string, argumentExpressions: (Expression | undefined)[]): FunctionInvocationExpression;
|
|
44
44
|
export interface MemberExpression {
|
|
45
45
|
readonly tag: 'member';
|
|
46
46
|
readonly object: Expression;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expressions.d.ts","sourceRoot":"","sources":["../../src/ast/expressions.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,YAAY,GAAG,MAAM,CAAA;AACjC,MAAM,MAAM,cAAc,GACtB,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,IAAI,GACJ,GAAG,GACH,IAAI,GACJ,IAAI,GACJ,GAAG,GACH,IAAI,GACJ,GAAG,GACH,IAAI,GACJ,IAAI,GACJ,KAAK,GACL,IAAI,CAAA;AACR,MAAM,MAAM,aAAa,GAAG,GAAG,GAAG,GAAG,GAAG,KAAK,CAAA;AA2B7C,MAAM,MAAM,+BAA+B,GACvC,IAAI,GACJ,MAAM,GACN,MAAM,GACN,OAAO,GACP,+BAA+B,EAAE,GACjC;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,+BAA+B,CAAA;CAAE,CAAA;AAEtD,MAAM,MAAM,UAAU,GAClB,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C9B,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAA;IACrB,QAAQ,CAAC,QAAQ,EAAE,aAAa,CAAA;IAChC,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAA;CAC3B;AAED,wBAAgB,OAAO,CACrB,QAAQ,EAAE,aAAa,EACvB,KAAK,EAAE,UAAU,GAChB,eAAe,CAEjB;AAGD,wBAAgB,kBAAkB,CAAC,EAAE,EAAE,UAAU,GAAG,MAAM,CAmDzD;AAoCD,wBAAgB,2CAA2C,CACzD,EAAE,EAAE,UAAU,GACb,+BAA+B,CAiCjC;AAED,wBAAgB,eAAe,CAAC,EAAE,EAAE,UAAU,GAAG,OAAO,CAuBvD;AAED,wBAAgB,WAAW,CACzB,EAAE,EAAE,UAAU,GACb,EAAE,IACD,gBAAgB,GAChB,gBAAgB,GAChB,iBAAiB,GACjB,cAAc,CAOjB"}
|
package/dist/ast/expressions.js
CHANGED
|
@@ -89,7 +89,10 @@ export function expressionToString(ex) {
|
|
|
89
89
|
case 'variableReference':
|
|
90
90
|
return ex.variableName;
|
|
91
91
|
case 'functionInvocation':
|
|
92
|
-
return `${ex.functionName}(${ex.arguments
|
|
92
|
+
return `${ex.functionName}(${ex.arguments
|
|
93
|
+
.map((x) => x ?? nullEx)
|
|
94
|
+
.map(expressionToString)
|
|
95
|
+
.join(', ')})`;
|
|
93
96
|
case 'member':
|
|
94
97
|
if (ex.computed) {
|
|
95
98
|
return `${expressionToString(ex.object)}[${expressionToString(ex.property)}]`;
|
package/dist/cli.js
CHANGED
|
@@ -6,6 +6,7 @@ import { program } from 'commander';
|
|
|
6
6
|
import { transpile, transpileText } from './transpiler/index.js';
|
|
7
7
|
import { WorkflowSyntaxError } from './errors.js';
|
|
8
8
|
import { TSError } from '@typescript-eslint/typescript-estree';
|
|
9
|
+
import { prettifySyntaxError } from './diagnostics.js';
|
|
9
10
|
function parseArgs() {
|
|
10
11
|
program
|
|
11
12
|
.name('ts2workflow')
|
|
@@ -37,19 +38,18 @@ function cliMain() {
|
|
|
37
38
|
files = args.sourceFiles;
|
|
38
39
|
}
|
|
39
40
|
files.forEach((inputFile) => {
|
|
40
|
-
const input = readSourceCode(inputFile);
|
|
41
41
|
try {
|
|
42
|
-
const transpiled = generateTranspiledText(
|
|
42
|
+
const transpiled = generateTranspiledText(inputFile, readSourceCode(inputFile), args.generatedFileComment, args.link, args.project);
|
|
43
43
|
writeOutput(transpiled, inputFile, args.outdir);
|
|
44
44
|
}
|
|
45
45
|
catch (err) {
|
|
46
46
|
if (isIoError(err)) {
|
|
47
47
|
let message;
|
|
48
|
-
if (
|
|
48
|
+
if (err.code === 'EAGAIN' && inputFile === '-') {
|
|
49
49
|
// Reading from stdin if there's no input causes error. This is a bug in node
|
|
50
50
|
message = 'Error: Failed to read from stdin';
|
|
51
51
|
}
|
|
52
|
-
else if (
|
|
52
|
+
else if (err.code === 'EISDIR') {
|
|
53
53
|
message = `Error: "${inputFile}" is a directory`;
|
|
54
54
|
}
|
|
55
55
|
else {
|
|
@@ -59,11 +59,11 @@ function cliMain() {
|
|
|
59
59
|
process.exit(1);
|
|
60
60
|
}
|
|
61
61
|
else if (err instanceof WorkflowSyntaxError) {
|
|
62
|
-
|
|
62
|
+
console.error(prettifySyntaxError(err));
|
|
63
63
|
process.exit(1);
|
|
64
64
|
}
|
|
65
65
|
else if (err instanceof TSError) {
|
|
66
|
-
|
|
66
|
+
console.error(prettifySyntaxError(err));
|
|
67
67
|
process.exit(1);
|
|
68
68
|
}
|
|
69
69
|
else {
|
|
@@ -72,31 +72,19 @@ function cliMain() {
|
|
|
72
72
|
}
|
|
73
73
|
});
|
|
74
74
|
}
|
|
75
|
-
function generateTranspiledText(
|
|
76
|
-
if (
|
|
77
|
-
return transpileText(
|
|
75
|
+
function generateTranspiledText(filename, sourceCode, addGeneratedFileComment, linkSubworkflows, project) {
|
|
76
|
+
if (filename === undefined) {
|
|
77
|
+
return transpileText(sourceCode);
|
|
78
78
|
}
|
|
79
79
|
else {
|
|
80
|
-
const header = addGeneratedFileComment
|
|
81
|
-
|
|
82
|
-
: '';
|
|
83
|
-
const transpiled = transpile(input, project, linkSubworkflows);
|
|
80
|
+
const header = addGeneratedFileComment ? generatedFileComment(filename) : '';
|
|
81
|
+
const transpiled = transpile(filename, sourceCode, project, linkSubworkflows);
|
|
84
82
|
return `${header}${transpiled}`;
|
|
85
83
|
}
|
|
86
84
|
}
|
|
87
85
|
function readSourceCode(filename) {
|
|
88
|
-
const
|
|
89
|
-
return
|
|
90
|
-
filename: filename === '-' ? undefined : filename,
|
|
91
|
-
read: () => readCode(),
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
function crateMemorizedReader(filenameOrFd) {
|
|
95
|
-
let cached;
|
|
96
|
-
return () => {
|
|
97
|
-
cached ??= fs.readFileSync(filenameOrFd, 'utf8');
|
|
98
|
-
return cached;
|
|
99
|
-
};
|
|
86
|
+
const filenameOrFd = filename === '-' ? process.stdin.fd : filename;
|
|
87
|
+
return fs.readFileSync(filenameOrFd, 'utf8');
|
|
100
88
|
}
|
|
101
89
|
function writeOutput(transpiled, inputFile, outdir) {
|
|
102
90
|
if (outdir !== undefined) {
|
|
@@ -119,58 +107,12 @@ function createOutputFilename(inputFile, outdir) {
|
|
|
119
107
|
});
|
|
120
108
|
}
|
|
121
109
|
function generatedFileComment(inputFile) {
|
|
122
|
-
return (`# This file has been generated by
|
|
110
|
+
return (`# This file has been generated by ts2workflows from source file ${inputFile}\n` +
|
|
123
111
|
'# Do not edit!\n\n');
|
|
124
112
|
}
|
|
125
113
|
function isIoError(err) {
|
|
126
114
|
return err instanceof Error && 'code' in err;
|
|
127
115
|
}
|
|
128
|
-
function prettyPrintSyntaxError(exception, inp) {
|
|
129
|
-
console.error(errorDisplay(inp, exception.location));
|
|
130
|
-
console.error(`${exception.message}`);
|
|
131
|
-
}
|
|
132
|
-
function errorDisplay(inp, location) {
|
|
133
|
-
const lines = [];
|
|
134
|
-
const prettyFilename = inp.filename ?? '<stdin>';
|
|
135
|
-
if (typeof location?.start === 'undefined' ||
|
|
136
|
-
typeof location?.end === 'undefined' ||
|
|
137
|
-
isNaN(location?.start.line) ||
|
|
138
|
-
isNaN(location?.end.line)) {
|
|
139
|
-
lines.push(`File ${prettyFilename}:`);
|
|
140
|
-
}
|
|
141
|
-
else {
|
|
142
|
-
lines.push(`File ${prettyFilename}, line ${location.start.line}, column ${location.start.column + 1}:`);
|
|
143
|
-
}
|
|
144
|
-
const highlightedLine = highlightedSourceCodeLine(inp.read(), location?.start?.line, location?.start?.column, location?.start?.line === location?.end?.line
|
|
145
|
-
? location?.end?.column
|
|
146
|
-
: undefined);
|
|
147
|
-
if (highlightedLine.length > 0) {
|
|
148
|
-
lines.push(highlightedLine);
|
|
149
|
-
lines.push('');
|
|
150
|
-
}
|
|
151
|
-
return lines.join('\n');
|
|
152
|
-
}
|
|
153
|
-
function highlightedSourceCodeLine(sourceCode, lineNumber, start, end) {
|
|
154
|
-
if (typeof lineNumber === 'undefined' ||
|
|
155
|
-
typeof start === 'undefined' ||
|
|
156
|
-
isNaN(start)) {
|
|
157
|
-
return '';
|
|
158
|
-
}
|
|
159
|
-
const lines = sourceCode.split('\n');
|
|
160
|
-
const sourceLine = lines[lineNumber - 1];
|
|
161
|
-
if (typeof sourceLine === 'undefined') {
|
|
162
|
-
return '';
|
|
163
|
-
}
|
|
164
|
-
let markerLength;
|
|
165
|
-
if (typeof end === 'undefined') {
|
|
166
|
-
markerLength = sourceLine.length - start;
|
|
167
|
-
}
|
|
168
|
-
else {
|
|
169
|
-
markerLength = Math.min(end - start + 1, sourceLine.length - start);
|
|
170
|
-
}
|
|
171
|
-
const markerLine = `${' '.repeat(start)}${'^'.repeat(markerLength)}`;
|
|
172
|
-
return `${sourceLine}\n${markerLine}`;
|
|
173
|
-
}
|
|
174
116
|
function versionFromPackageJson() {
|
|
175
117
|
const currentFile = fileURLToPath(import.meta.url);
|
|
176
118
|
const currentDir = path.dirname(currentFile);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diagnostics.d.ts","sourceRoot":"","sources":["../src/diagnostics.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,mBAAmB,EAEpB,MAAM,aAAa,CAAA;AAEpB,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,mBAAmB,GAAG,MAAM,CAc1E"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { WorkflowSyntaxErrorWithText, } from './errors.js';
|
|
2
|
+
export function prettifySyntaxError(exception) {
|
|
3
|
+
const filename = exception instanceof WorkflowSyntaxErrorWithText
|
|
4
|
+
? exception.filename
|
|
5
|
+
: '???';
|
|
6
|
+
const errorLineText = exception instanceof WorkflowSyntaxErrorWithText
|
|
7
|
+
? exception.errorLine
|
|
8
|
+
: undefined;
|
|
9
|
+
return (`${errorLocator(filename, exception.location, errorLineText)}\n` +
|
|
10
|
+
`${exception.message}`);
|
|
11
|
+
}
|
|
12
|
+
function errorLocator(filename, location, errorLineText) {
|
|
13
|
+
const lines = [];
|
|
14
|
+
if (isNaN(location.start.line) || isNaN(location.end.line)) {
|
|
15
|
+
lines.push(`File ${filename}:`);
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
lines.push(`File ${filename}, line ${location.start.line}, column ${location.start.column + 1}:`);
|
|
19
|
+
}
|
|
20
|
+
if (errorLineText) {
|
|
21
|
+
const highlightedLine = highlightedSourceCodeLine(errorLineText, location.start.column, location.start.line === location.end.line
|
|
22
|
+
? location.end.column
|
|
23
|
+
: undefined);
|
|
24
|
+
if (highlightedLine.length > 0) {
|
|
25
|
+
lines.push(highlightedLine);
|
|
26
|
+
lines.push('');
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return lines.join('\n');
|
|
30
|
+
}
|
|
31
|
+
function highlightedSourceCodeLine(errorLineText, start, end) {
|
|
32
|
+
if (isNaN(start) || start < 0) {
|
|
33
|
+
return '';
|
|
34
|
+
}
|
|
35
|
+
const sourceLine = errorLineText.split('\n')[0] ?? '';
|
|
36
|
+
let markerLength;
|
|
37
|
+
if (end === undefined || isNaN(end) || end < 0) {
|
|
38
|
+
markerLength = sourceLine.length - start;
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
markerLength = Math.min(end - start + 1, sourceLine.length - start);
|
|
42
|
+
}
|
|
43
|
+
markerLength = Math.max(markerLength, 0);
|
|
44
|
+
const markerLine = `${' '.repeat(start)}${'^'.repeat(markerLength)}`;
|
|
45
|
+
return `${sourceLine}\n${markerLine}`;
|
|
46
|
+
}
|
package/dist/errors.d.ts
CHANGED
|
@@ -9,9 +9,16 @@ export interface SourceCodeLocation {
|
|
|
9
9
|
};
|
|
10
10
|
}
|
|
11
11
|
export declare class WorkflowSyntaxError extends Error {
|
|
12
|
-
location: SourceCodeLocation;
|
|
12
|
+
readonly location: SourceCodeLocation;
|
|
13
13
|
constructor(message: string, location: SourceCodeLocation);
|
|
14
14
|
}
|
|
15
|
+
export declare class WorkflowSyntaxErrorWithText extends WorkflowSyntaxError {
|
|
16
|
+
readonly location: SourceCodeLocation;
|
|
17
|
+
readonly filename: string;
|
|
18
|
+
readonly errorLine: string;
|
|
19
|
+
constructor(message: string, location: SourceCodeLocation, filename: string, errorLine: string);
|
|
20
|
+
}
|
|
21
|
+
export declare function syntaxErrorWithText(error: WorkflowSyntaxError, filename: string, sourceCode: string): WorkflowSyntaxErrorWithText;
|
|
15
22
|
export declare class InternalTranspilingError extends Error {
|
|
16
23
|
constructor(message: string);
|
|
17
24
|
}
|
package/dist/errors.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAA;IACvC,GAAG,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAA;CACtC;AAID,qBAAa,mBAAoB,SAAQ,KAAK;
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAA;IACvC,GAAG,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAA;CACtC;AAID,qBAAa,mBAAoB,SAAQ,KAAK;aAG1B,QAAQ,EAAE,kBAAkB;gBAD5C,OAAO,EAAE,MAAM,EACC,QAAQ,EAAE,kBAAkB;CAI/C;AAID,qBAAa,2BAA4B,SAAQ,mBAAmB;aAGhD,QAAQ,EAAE,kBAAkB;aAC5B,QAAQ,EAAE,MAAM;aAChB,SAAS,EAAE,MAAM;gBAHjC,OAAO,EAAE,MAAM,EACC,QAAQ,EAAE,kBAAkB,EAC5B,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM;CAIpC;AAED,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,mBAAmB,EAC1B,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,GACjB,2BAA2B,CAW7B;AAID,qBAAa,wBAAyB,SAAQ,KAAK;gBACrC,OAAO,EAAE,MAAM;CAG5B;AAGD,qBAAa,OAAQ,SAAQ,KAAK;aAGd,IAAI,EAAE,MAAM;gBAD5B,OAAO,EAAE,MAAM,EACC,IAAI,EAAE,MAAM;CAI/B"}
|
package/dist/errors.js
CHANGED
|
@@ -7,13 +7,33 @@ export class WorkflowSyntaxError extends Error {
|
|
|
7
7
|
this.location = location;
|
|
8
8
|
}
|
|
9
9
|
}
|
|
10
|
+
// WorkflowSyntaxError enriched with the source code filename and the text of
|
|
11
|
+
// the line where the error occurred.
|
|
12
|
+
export class WorkflowSyntaxErrorWithText extends WorkflowSyntaxError {
|
|
13
|
+
location;
|
|
14
|
+
filename;
|
|
15
|
+
errorLine;
|
|
16
|
+
constructor(message, location, filename, errorLine) {
|
|
17
|
+
super(message, location);
|
|
18
|
+
this.location = location;
|
|
19
|
+
this.filename = filename;
|
|
20
|
+
this.errorLine = errorLine;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
export function syntaxErrorWithText(error, filename, sourceCode) {
|
|
24
|
+
const lineNumber = Math.max(error.location.start.line, 0);
|
|
25
|
+
const lines = sourceCode.split('\n');
|
|
26
|
+
const errorLine = lines[lineNumber - 1];
|
|
27
|
+
return new WorkflowSyntaxErrorWithText(error.message, error.location, filename, errorLine);
|
|
28
|
+
}
|
|
10
29
|
// InternalTranspilingError is thrown when ts2workflow ends up in an unexpected state.
|
|
11
|
-
//
|
|
30
|
+
// This is a bug in ts2workflow.
|
|
12
31
|
export class InternalTranspilingError extends Error {
|
|
13
32
|
constructor(message) {
|
|
14
33
|
super(`Internal error: ${message}`);
|
|
15
34
|
}
|
|
16
35
|
}
|
|
36
|
+
// An IO error with an error code string, similar to Node's SystemError
|
|
17
37
|
export class IOError extends Error {
|
|
18
38
|
code;
|
|
19
39
|
constructor(message, code) {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { transpile } from './transpiler/index.js';
|
|
2
|
-
export { WorkflowSyntaxError, InternalTranspilingError, SourceCodeLocation, } from './errors.js';
|
|
1
|
+
export { transpile, transpileText } from './transpiler/index.js';
|
|
2
|
+
export { WorkflowSyntaxError, WorkflowSyntaxErrorWithText, InternalTranspilingError, SourceCodeLocation, } from './errors.js';
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AAChE,OAAO,EACL,mBAAmB,EACnB,2BAA2B,EAC3B,wBAAwB,EACxB,kBAAkB,GACnB,MAAM,aAAa,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { transpile } from './transpiler/index.js';
|
|
2
|
-
export { WorkflowSyntaxError, InternalTranspilingError, } from './errors.js';
|
|
1
|
+
export { transpile, transpileText } from './transpiler/index.js';
|
|
2
|
+
export { WorkflowSyntaxError, WorkflowSyntaxErrorWithText, InternalTranspilingError, } from './errors.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"functionMetadata.d.ts","sourceRoot":"","sources":["../../../src/transpiler/generated/functionMetadata.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,iBAAiB,
|
|
1
|
+
{"version":3,"file":"functionMetadata.d.ts","sourceRoot":"","sources":["../../../src/transpiler/generated/functionMetadata.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,iBAAiB,uBA4kB5B,CAAA"}
|
|
@@ -320,5 +320,272 @@ export const blockingFunctions = new Map([
|
|
|
320
320
|
"pageSize",
|
|
321
321
|
"pageToken"
|
|
322
322
|
]
|
|
323
|
+
],
|
|
324
|
+
[
|
|
325
|
+
"googleapis.pubsub.v1.projects.schemas.create",
|
|
326
|
+
[
|
|
327
|
+
"parent",
|
|
328
|
+
"schemaId",
|
|
329
|
+
"body"
|
|
330
|
+
]
|
|
331
|
+
],
|
|
332
|
+
[
|
|
333
|
+
"googleapis.pubsub.v1.projects.schemas.delete",
|
|
334
|
+
[
|
|
335
|
+
"name"
|
|
336
|
+
]
|
|
337
|
+
],
|
|
338
|
+
[
|
|
339
|
+
"googleapis.pubsub.v1.projects.schemas.get",
|
|
340
|
+
[
|
|
341
|
+
"name",
|
|
342
|
+
"view"
|
|
343
|
+
]
|
|
344
|
+
],
|
|
345
|
+
[
|
|
346
|
+
"googleapis.pubsub.v1.projects.schemas.list",
|
|
347
|
+
[
|
|
348
|
+
"parent",
|
|
349
|
+
"pageSize",
|
|
350
|
+
"pageToken",
|
|
351
|
+
"view"
|
|
352
|
+
]
|
|
353
|
+
],
|
|
354
|
+
[
|
|
355
|
+
"googleapis.pubsub.v1.projects.schemas.validate",
|
|
356
|
+
[
|
|
357
|
+
"parent",
|
|
358
|
+
"body"
|
|
359
|
+
]
|
|
360
|
+
],
|
|
361
|
+
[
|
|
362
|
+
"googleapis.pubsub.v1.projects.schemas.validateMessage",
|
|
363
|
+
[
|
|
364
|
+
"parent",
|
|
365
|
+
"body"
|
|
366
|
+
]
|
|
367
|
+
],
|
|
368
|
+
[
|
|
369
|
+
"googleapis.pubsub.v1.projects.snapshots.create",
|
|
370
|
+
[
|
|
371
|
+
"name",
|
|
372
|
+
"object"
|
|
373
|
+
]
|
|
374
|
+
],
|
|
375
|
+
[
|
|
376
|
+
"googleapis.pubsub.v1.projects.snapshots.delete",
|
|
377
|
+
[
|
|
378
|
+
"snapshot"
|
|
379
|
+
]
|
|
380
|
+
],
|
|
381
|
+
[
|
|
382
|
+
"googleapis.pubsub.v1.projects.snapshots.getIamPolicy",
|
|
383
|
+
[
|
|
384
|
+
"resource",
|
|
385
|
+
"options"
|
|
386
|
+
]
|
|
387
|
+
],
|
|
388
|
+
[
|
|
389
|
+
"googleapis.pubsub.v1.projects.snapshots.list",
|
|
390
|
+
[
|
|
391
|
+
"project",
|
|
392
|
+
"pageSize",
|
|
393
|
+
"pageToken"
|
|
394
|
+
]
|
|
395
|
+
],
|
|
396
|
+
[
|
|
397
|
+
"googleapis.pubsub.v1.projects.snapshots.patch",
|
|
398
|
+
[
|
|
399
|
+
"name",
|
|
400
|
+
"body"
|
|
401
|
+
]
|
|
402
|
+
],
|
|
403
|
+
[
|
|
404
|
+
"googleapis.pubsub.v1.projects.snapshots.setIamPolicy",
|
|
405
|
+
[
|
|
406
|
+
"resource",
|
|
407
|
+
"body"
|
|
408
|
+
]
|
|
409
|
+
],
|
|
410
|
+
[
|
|
411
|
+
"googleapis.pubsub.v1.projects.snapshots.testIamPermissions",
|
|
412
|
+
[
|
|
413
|
+
"resource",
|
|
414
|
+
"body"
|
|
415
|
+
]
|
|
416
|
+
],
|
|
417
|
+
[
|
|
418
|
+
"googleapis.pubsub.v1.projects.subscriptions.acknowledge",
|
|
419
|
+
[
|
|
420
|
+
"subscription",
|
|
421
|
+
"body"
|
|
422
|
+
]
|
|
423
|
+
],
|
|
424
|
+
[
|
|
425
|
+
"googleapis.pubsub.v1.projects.subscriptions.create",
|
|
426
|
+
[
|
|
427
|
+
"name",
|
|
428
|
+
"body"
|
|
429
|
+
]
|
|
430
|
+
],
|
|
431
|
+
[
|
|
432
|
+
"googleapis.pubsub.v1.projects.subscriptions.delete",
|
|
433
|
+
[
|
|
434
|
+
"subscription"
|
|
435
|
+
]
|
|
436
|
+
],
|
|
437
|
+
[
|
|
438
|
+
"googleapis.pubsub.v1.projects.subscriptions.detach",
|
|
439
|
+
[
|
|
440
|
+
"subscription"
|
|
441
|
+
]
|
|
442
|
+
],
|
|
443
|
+
[
|
|
444
|
+
"googleapis.pubsub.v1.projects.subscriptions.get",
|
|
445
|
+
[
|
|
446
|
+
"subscription"
|
|
447
|
+
]
|
|
448
|
+
],
|
|
449
|
+
[
|
|
450
|
+
"googleapis.pubsub.v1.projects.subscriptions.getIamPolicy",
|
|
451
|
+
[
|
|
452
|
+
"resource",
|
|
453
|
+
"options"
|
|
454
|
+
]
|
|
455
|
+
],
|
|
456
|
+
[
|
|
457
|
+
"googleapis.pubsub.v1.projects.subscriptions.list",
|
|
458
|
+
[
|
|
459
|
+
"project",
|
|
460
|
+
"pageSize",
|
|
461
|
+
"pageToken"
|
|
462
|
+
]
|
|
463
|
+
],
|
|
464
|
+
[
|
|
465
|
+
"googleapis.pubsub.v1.projects.subscriptions.modifyAckDeadline",
|
|
466
|
+
[
|
|
467
|
+
"subscription",
|
|
468
|
+
"body"
|
|
469
|
+
]
|
|
470
|
+
],
|
|
471
|
+
[
|
|
472
|
+
"googleapis.pubsub.v1.projects.subscriptions.modifyPushConfig",
|
|
473
|
+
[
|
|
474
|
+
"subscription",
|
|
475
|
+
"body"
|
|
476
|
+
]
|
|
477
|
+
],
|
|
478
|
+
[
|
|
479
|
+
"googleapis.pubsub.v1.projects.subscriptions.patch",
|
|
480
|
+
[
|
|
481
|
+
"name",
|
|
482
|
+
"body"
|
|
483
|
+
]
|
|
484
|
+
],
|
|
485
|
+
[
|
|
486
|
+
"googleapis.pubsub.v1.projects.subscriptions.pull",
|
|
487
|
+
[
|
|
488
|
+
"subscription",
|
|
489
|
+
"body"
|
|
490
|
+
]
|
|
491
|
+
],
|
|
492
|
+
[
|
|
493
|
+
"googleapis.pubsub.v1.projects.subscriptions.seek",
|
|
494
|
+
[
|
|
495
|
+
"subscription",
|
|
496
|
+
"body"
|
|
497
|
+
]
|
|
498
|
+
],
|
|
499
|
+
[
|
|
500
|
+
"googleapis.pubsub.v1.projects.subscriptions.setIamPolicy",
|
|
501
|
+
[
|
|
502
|
+
"resource",
|
|
503
|
+
"body"
|
|
504
|
+
]
|
|
505
|
+
],
|
|
506
|
+
[
|
|
507
|
+
"googleapis.pubsub.v1.projects.subscriptions.testIamPermissions",
|
|
508
|
+
[
|
|
509
|
+
"resource",
|
|
510
|
+
"body"
|
|
511
|
+
]
|
|
512
|
+
],
|
|
513
|
+
[
|
|
514
|
+
"googleapis.pubsub.v1.projects.topics.create",
|
|
515
|
+
[
|
|
516
|
+
"name",
|
|
517
|
+
"body"
|
|
518
|
+
]
|
|
519
|
+
],
|
|
520
|
+
[
|
|
521
|
+
"googleapis.pubsub.v1.projects.topics.delete",
|
|
522
|
+
[
|
|
523
|
+
"topic"
|
|
524
|
+
]
|
|
525
|
+
],
|
|
526
|
+
[
|
|
527
|
+
"googleapis.pubsub.v1.projects.topics.get",
|
|
528
|
+
[
|
|
529
|
+
"topic"
|
|
530
|
+
]
|
|
531
|
+
],
|
|
532
|
+
[
|
|
533
|
+
"googleapis.pubsub.v1.projects.topics.getIamPolicy",
|
|
534
|
+
[
|
|
535
|
+
"resource",
|
|
536
|
+
"options"
|
|
537
|
+
]
|
|
538
|
+
],
|
|
539
|
+
[
|
|
540
|
+
"googleapis.pubsub.v1.projects.topics.list",
|
|
541
|
+
[
|
|
542
|
+
"project",
|
|
543
|
+
"pageSize",
|
|
544
|
+
"pageToken"
|
|
545
|
+
]
|
|
546
|
+
],
|
|
547
|
+
[
|
|
548
|
+
"googleapis.pubsub.v1.projects.topics.patch",
|
|
549
|
+
[
|
|
550
|
+
"name",
|
|
551
|
+
"body"
|
|
552
|
+
]
|
|
553
|
+
],
|
|
554
|
+
[
|
|
555
|
+
"googleapis.pubsub.v1.projects.topics.publish",
|
|
556
|
+
[
|
|
557
|
+
"topic",
|
|
558
|
+
"body"
|
|
559
|
+
]
|
|
560
|
+
],
|
|
561
|
+
[
|
|
562
|
+
"googleapis.pubsub.v1.projects.topics.setIamPolicy",
|
|
563
|
+
[
|
|
564
|
+
"resource",
|
|
565
|
+
"body"
|
|
566
|
+
]
|
|
567
|
+
],
|
|
568
|
+
[
|
|
569
|
+
"googleapis.pubsub.v1.projects.topics.testIamPermissions",
|
|
570
|
+
[
|
|
571
|
+
"resource",
|
|
572
|
+
"body"
|
|
573
|
+
]
|
|
574
|
+
],
|
|
575
|
+
[
|
|
576
|
+
"googleapis.pubsub.v1.projects.topics.snapshots.list",
|
|
577
|
+
[
|
|
578
|
+
"topic",
|
|
579
|
+
"pageSize",
|
|
580
|
+
"pageToken"
|
|
581
|
+
]
|
|
582
|
+
],
|
|
583
|
+
[
|
|
584
|
+
"googleapis.pubsub.v1.projects.topics.subscriptions.list",
|
|
585
|
+
[
|
|
586
|
+
"topic",
|
|
587
|
+
"pageSize",
|
|
588
|
+
"pageToken"
|
|
589
|
+
]
|
|
323
590
|
]
|
|
324
591
|
]);
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
2
|
import { WorkflowApp } from '../ast/workflows.js';
|
|
3
|
-
export declare function transpile(
|
|
4
|
-
filename?: string;
|
|
5
|
-
read: () => string;
|
|
6
|
-
}, tsconfigPath: string | undefined, linkSubworkflows: boolean): string;
|
|
3
|
+
export declare function transpile(filename: string, sourceCode: string, tsconfigPath: string | undefined, linkSubworkflows: boolean): string;
|
|
7
4
|
export declare function transpileText(sourceCode: string): string;
|
|
8
5
|
/**
|
|
9
6
|
* Returns true if node is an ambient function declaration.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/transpiler/index.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/transpiler/index.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,MAAM,YAAY,CAAA;AAQ3B,OAAO,EAGL,WAAW,EAEZ,MAAM,qBAAqB,CAAA;AAU5B,wBAAgB,SAAS,CACvB,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,EAClB,YAAY,EAAE,MAAM,GAAG,SAAS,EAChC,gBAAgB,EAAE,OAAO,GACxB,MAAM,CA2BR;AAED,wBAAgB,aAAa,CAAC,UAAU,EAAE,MAAM,UAS/C;AA2JD;;;;;;GAMG;AACH,wBAAgB,4BAA4B,CAC1C,IAAI,EAAE,EAAE,CAAC,mBAAmB,GAC3B,OAAO,CAkBT;AAgID;;GAEG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,WAAW,GAAG,MAAM,CAI1D"}
|