webpipe-js 0.1.0 → 0.1.2
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/dist/index.cjs +721 -0
- package/dist/{parser.d.ts → index.d.cts} +26 -23
- package/dist/index.d.ts +132 -0
- package/{parser.ts → dist/index.mjs} +297 -349
- package/package.json +16 -6
- package/comprehensive_test.wp +0 -1139
- package/dist/parser.js +0 -594
- package/dist/tests/parser.test.d.ts +0 -1
- package/dist/tests/parser.test.js +0 -106
- package/tests/parser.test.ts +0 -119
- package/tsconfig.json +0 -18
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
|
|
1
|
+
interface Program {
|
|
2
2
|
configs: Config[];
|
|
3
3
|
pipelines: NamedPipeline[];
|
|
4
4
|
variables: Variable[];
|
|
5
5
|
routes: Route[];
|
|
6
6
|
describes: Describe[];
|
|
7
7
|
}
|
|
8
|
-
|
|
8
|
+
interface Config {
|
|
9
9
|
name: string;
|
|
10
10
|
properties: ConfigProperty[];
|
|
11
11
|
}
|
|
12
|
-
|
|
12
|
+
interface ConfigProperty {
|
|
13
13
|
key: string;
|
|
14
14
|
value: ConfigValue;
|
|
15
15
|
}
|
|
16
|
-
|
|
16
|
+
type ConfigValue = {
|
|
17
17
|
kind: 'String';
|
|
18
18
|
value: string;
|
|
19
19
|
} | {
|
|
@@ -27,31 +27,31 @@ export type ConfigValue = {
|
|
|
27
27
|
kind: 'Number';
|
|
28
28
|
value: number;
|
|
29
29
|
};
|
|
30
|
-
|
|
30
|
+
interface NamedPipeline {
|
|
31
31
|
name: string;
|
|
32
32
|
pipeline: Pipeline;
|
|
33
33
|
}
|
|
34
|
-
|
|
34
|
+
interface Variable {
|
|
35
35
|
varType: string;
|
|
36
36
|
name: string;
|
|
37
37
|
value: string;
|
|
38
38
|
}
|
|
39
|
-
|
|
39
|
+
interface Route {
|
|
40
40
|
method: string;
|
|
41
41
|
path: string;
|
|
42
42
|
pipeline: PipelineRef;
|
|
43
43
|
}
|
|
44
|
-
|
|
44
|
+
type PipelineRef = {
|
|
45
45
|
kind: 'Inline';
|
|
46
46
|
pipeline: Pipeline;
|
|
47
47
|
} | {
|
|
48
48
|
kind: 'Named';
|
|
49
49
|
name: string;
|
|
50
50
|
};
|
|
51
|
-
|
|
51
|
+
interface Pipeline {
|
|
52
52
|
steps: PipelineStep[];
|
|
53
53
|
}
|
|
54
|
-
|
|
54
|
+
type PipelineStep = {
|
|
55
55
|
kind: 'Regular';
|
|
56
56
|
name: string;
|
|
57
57
|
config: string;
|
|
@@ -59,12 +59,12 @@ export type PipelineStep = {
|
|
|
59
59
|
kind: 'Result';
|
|
60
60
|
branches: ResultBranch[];
|
|
61
61
|
};
|
|
62
|
-
|
|
62
|
+
interface ResultBranch {
|
|
63
63
|
branchType: ResultBranchType;
|
|
64
64
|
statusCode: number;
|
|
65
65
|
pipeline: Pipeline;
|
|
66
66
|
}
|
|
67
|
-
|
|
67
|
+
type ResultBranchType = {
|
|
68
68
|
kind: 'Ok';
|
|
69
69
|
} | {
|
|
70
70
|
kind: 'Custom';
|
|
@@ -72,23 +72,23 @@ export type ResultBranchType = {
|
|
|
72
72
|
} | {
|
|
73
73
|
kind: 'Default';
|
|
74
74
|
};
|
|
75
|
-
|
|
75
|
+
interface Describe {
|
|
76
76
|
name: string;
|
|
77
77
|
mocks: Mock[];
|
|
78
78
|
tests: It[];
|
|
79
79
|
}
|
|
80
|
-
|
|
80
|
+
interface Mock {
|
|
81
81
|
target: string;
|
|
82
82
|
returnValue: string;
|
|
83
83
|
}
|
|
84
|
-
|
|
84
|
+
interface It {
|
|
85
85
|
name: string;
|
|
86
86
|
mocks: Mock[];
|
|
87
87
|
when: When;
|
|
88
88
|
input?: string;
|
|
89
89
|
conditions: Condition[];
|
|
90
90
|
}
|
|
91
|
-
|
|
91
|
+
type When = {
|
|
92
92
|
kind: 'CallingRoute';
|
|
93
93
|
method: string;
|
|
94
94
|
path: string;
|
|
@@ -100,30 +100,33 @@ export type When = {
|
|
|
100
100
|
varType: string;
|
|
101
101
|
name: string;
|
|
102
102
|
};
|
|
103
|
-
|
|
103
|
+
interface Condition {
|
|
104
104
|
conditionType: 'Then' | 'And';
|
|
105
105
|
field: string;
|
|
106
106
|
jqExpr?: string;
|
|
107
107
|
comparison: string;
|
|
108
108
|
value: string;
|
|
109
109
|
}
|
|
110
|
-
|
|
111
|
-
|
|
110
|
+
type DiagnosticSeverity = 'error' | 'warning' | 'info';
|
|
111
|
+
interface ParseDiagnostic {
|
|
112
112
|
message: string;
|
|
113
113
|
start: number;
|
|
114
114
|
end: number;
|
|
115
115
|
severity: DiagnosticSeverity;
|
|
116
116
|
}
|
|
117
|
-
|
|
118
|
-
|
|
117
|
+
declare function parseProgram(text: string): Program;
|
|
118
|
+
declare function parseProgramWithDiagnostics(text: string): {
|
|
119
119
|
program: Program;
|
|
120
120
|
diagnostics: ParseDiagnostic[];
|
|
121
121
|
};
|
|
122
|
-
|
|
122
|
+
declare function getPipelineRanges(text: string): Map<string, {
|
|
123
123
|
start: number;
|
|
124
124
|
end: number;
|
|
125
125
|
}>;
|
|
126
|
-
|
|
126
|
+
declare function getVariableRanges(text: string): Map<string, {
|
|
127
127
|
start: number;
|
|
128
128
|
end: number;
|
|
129
129
|
}>;
|
|
130
|
+
declare function prettyPrint(program: Program): string;
|
|
131
|
+
|
|
132
|
+
export { type Condition, type Config, type ConfigProperty, type ConfigValue, type Describe, type DiagnosticSeverity, type It, type Mock, type NamedPipeline, type ParseDiagnostic, type Pipeline, type PipelineRef, type PipelineStep, type Program, type ResultBranch, type ResultBranchType, type Route, type Variable, type When, getPipelineRanges, getVariableRanges, parseProgram, parseProgramWithDiagnostics, prettyPrint };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
interface Program {
|
|
2
|
+
configs: Config[];
|
|
3
|
+
pipelines: NamedPipeline[];
|
|
4
|
+
variables: Variable[];
|
|
5
|
+
routes: Route[];
|
|
6
|
+
describes: Describe[];
|
|
7
|
+
}
|
|
8
|
+
interface Config {
|
|
9
|
+
name: string;
|
|
10
|
+
properties: ConfigProperty[];
|
|
11
|
+
}
|
|
12
|
+
interface ConfigProperty {
|
|
13
|
+
key: string;
|
|
14
|
+
value: ConfigValue;
|
|
15
|
+
}
|
|
16
|
+
type ConfigValue = {
|
|
17
|
+
kind: 'String';
|
|
18
|
+
value: string;
|
|
19
|
+
} | {
|
|
20
|
+
kind: 'EnvVar';
|
|
21
|
+
var: string;
|
|
22
|
+
default?: string;
|
|
23
|
+
} | {
|
|
24
|
+
kind: 'Boolean';
|
|
25
|
+
value: boolean;
|
|
26
|
+
} | {
|
|
27
|
+
kind: 'Number';
|
|
28
|
+
value: number;
|
|
29
|
+
};
|
|
30
|
+
interface NamedPipeline {
|
|
31
|
+
name: string;
|
|
32
|
+
pipeline: Pipeline;
|
|
33
|
+
}
|
|
34
|
+
interface Variable {
|
|
35
|
+
varType: string;
|
|
36
|
+
name: string;
|
|
37
|
+
value: string;
|
|
38
|
+
}
|
|
39
|
+
interface Route {
|
|
40
|
+
method: string;
|
|
41
|
+
path: string;
|
|
42
|
+
pipeline: PipelineRef;
|
|
43
|
+
}
|
|
44
|
+
type PipelineRef = {
|
|
45
|
+
kind: 'Inline';
|
|
46
|
+
pipeline: Pipeline;
|
|
47
|
+
} | {
|
|
48
|
+
kind: 'Named';
|
|
49
|
+
name: string;
|
|
50
|
+
};
|
|
51
|
+
interface Pipeline {
|
|
52
|
+
steps: PipelineStep[];
|
|
53
|
+
}
|
|
54
|
+
type PipelineStep = {
|
|
55
|
+
kind: 'Regular';
|
|
56
|
+
name: string;
|
|
57
|
+
config: string;
|
|
58
|
+
} | {
|
|
59
|
+
kind: 'Result';
|
|
60
|
+
branches: ResultBranch[];
|
|
61
|
+
};
|
|
62
|
+
interface ResultBranch {
|
|
63
|
+
branchType: ResultBranchType;
|
|
64
|
+
statusCode: number;
|
|
65
|
+
pipeline: Pipeline;
|
|
66
|
+
}
|
|
67
|
+
type ResultBranchType = {
|
|
68
|
+
kind: 'Ok';
|
|
69
|
+
} | {
|
|
70
|
+
kind: 'Custom';
|
|
71
|
+
name: string;
|
|
72
|
+
} | {
|
|
73
|
+
kind: 'Default';
|
|
74
|
+
};
|
|
75
|
+
interface Describe {
|
|
76
|
+
name: string;
|
|
77
|
+
mocks: Mock[];
|
|
78
|
+
tests: It[];
|
|
79
|
+
}
|
|
80
|
+
interface Mock {
|
|
81
|
+
target: string;
|
|
82
|
+
returnValue: string;
|
|
83
|
+
}
|
|
84
|
+
interface It {
|
|
85
|
+
name: string;
|
|
86
|
+
mocks: Mock[];
|
|
87
|
+
when: When;
|
|
88
|
+
input?: string;
|
|
89
|
+
conditions: Condition[];
|
|
90
|
+
}
|
|
91
|
+
type When = {
|
|
92
|
+
kind: 'CallingRoute';
|
|
93
|
+
method: string;
|
|
94
|
+
path: string;
|
|
95
|
+
} | {
|
|
96
|
+
kind: 'ExecutingPipeline';
|
|
97
|
+
name: string;
|
|
98
|
+
} | {
|
|
99
|
+
kind: 'ExecutingVariable';
|
|
100
|
+
varType: string;
|
|
101
|
+
name: string;
|
|
102
|
+
};
|
|
103
|
+
interface Condition {
|
|
104
|
+
conditionType: 'Then' | 'And';
|
|
105
|
+
field: string;
|
|
106
|
+
jqExpr?: string;
|
|
107
|
+
comparison: string;
|
|
108
|
+
value: string;
|
|
109
|
+
}
|
|
110
|
+
type DiagnosticSeverity = 'error' | 'warning' | 'info';
|
|
111
|
+
interface ParseDiagnostic {
|
|
112
|
+
message: string;
|
|
113
|
+
start: number;
|
|
114
|
+
end: number;
|
|
115
|
+
severity: DiagnosticSeverity;
|
|
116
|
+
}
|
|
117
|
+
declare function parseProgram(text: string): Program;
|
|
118
|
+
declare function parseProgramWithDiagnostics(text: string): {
|
|
119
|
+
program: Program;
|
|
120
|
+
diagnostics: ParseDiagnostic[];
|
|
121
|
+
};
|
|
122
|
+
declare function getPipelineRanges(text: string): Map<string, {
|
|
123
|
+
start: number;
|
|
124
|
+
end: number;
|
|
125
|
+
}>;
|
|
126
|
+
declare function getVariableRanges(text: string): Map<string, {
|
|
127
|
+
start: number;
|
|
128
|
+
end: number;
|
|
129
|
+
}>;
|
|
130
|
+
declare function prettyPrint(program: Program): string;
|
|
131
|
+
|
|
132
|
+
export { type Condition, type Config, type ConfigProperty, type ConfigValue, type Describe, type DiagnosticSeverity, type It, type Mock, type NamedPipeline, type ParseDiagnostic, type Pipeline, type PipelineRef, type PipelineStep, type Program, type ResultBranch, type ResultBranchType, type Route, type Variable, type When, getPipelineRanges, getVariableRanges, parseProgram, parseProgramWithDiagnostics, prettyPrint };
|