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.
@@ -1,19 +1,19 @@
1
- export interface Program {
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
- export interface Config {
8
+ interface Config {
9
9
  name: string;
10
10
  properties: ConfigProperty[];
11
11
  }
12
- export interface ConfigProperty {
12
+ interface ConfigProperty {
13
13
  key: string;
14
14
  value: ConfigValue;
15
15
  }
16
- export type ConfigValue = {
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
- export interface NamedPipeline {
30
+ interface NamedPipeline {
31
31
  name: string;
32
32
  pipeline: Pipeline;
33
33
  }
34
- export interface Variable {
34
+ interface Variable {
35
35
  varType: string;
36
36
  name: string;
37
37
  value: string;
38
38
  }
39
- export interface Route {
39
+ interface Route {
40
40
  method: string;
41
41
  path: string;
42
42
  pipeline: PipelineRef;
43
43
  }
44
- export type PipelineRef = {
44
+ type PipelineRef = {
45
45
  kind: 'Inline';
46
46
  pipeline: Pipeline;
47
47
  } | {
48
48
  kind: 'Named';
49
49
  name: string;
50
50
  };
51
- export interface Pipeline {
51
+ interface Pipeline {
52
52
  steps: PipelineStep[];
53
53
  }
54
- export type PipelineStep = {
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
- export interface ResultBranch {
62
+ interface ResultBranch {
63
63
  branchType: ResultBranchType;
64
64
  statusCode: number;
65
65
  pipeline: Pipeline;
66
66
  }
67
- export type ResultBranchType = {
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
- export interface Describe {
75
+ interface Describe {
76
76
  name: string;
77
77
  mocks: Mock[];
78
78
  tests: It[];
79
79
  }
80
- export interface Mock {
80
+ interface Mock {
81
81
  target: string;
82
82
  returnValue: string;
83
83
  }
84
- export interface It {
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
- export type When = {
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
- export interface Condition {
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
- export type DiagnosticSeverity = 'error' | 'warning' | 'info';
111
- export interface ParseDiagnostic {
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
- export declare function parseProgram(text: string): Program;
118
- export declare function parseProgramWithDiagnostics(text: string): {
117
+ declare function parseProgram(text: string): Program;
118
+ declare function parseProgramWithDiagnostics(text: string): {
119
119
  program: Program;
120
120
  diagnostics: ParseDiagnostic[];
121
121
  };
122
- export declare function getPipelineRanges(text: string): Map<string, {
122
+ declare function getPipelineRanges(text: string): Map<string, {
123
123
  start: number;
124
124
  end: number;
125
125
  }>;
126
- export declare function getVariableRanges(text: string): Map<string, {
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 };
@@ -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 };