@swaggerexpert/arazzo-runtime-expression 2.0.1 → 2.0.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/README.md CHANGED
@@ -20,7 +20,7 @@ It supports Runtime Expressions defined in following Arazzo specification versio
20
20
  <table>
21
21
  <tr>
22
22
  <td align="right" valign="middle">
23
- <img src="https://cdn2.hubspot.net/hubfs/4008838/website/logos/logos_for_download/Tidelift_primary-shorthand-logo.png" alt="Tidelift" width="60" />
23
+ <img src="https://raw.githubusercontent.com/swaggerexpert/arazzo-runtime-expression/main/assets/tidelift.webp" alt="Tidelift" width="60" />
24
24
  </td>
25
25
  <td valign="middle">
26
26
  <a href="https://tidelift.com/subscription/pkg/npm-.swaggerexpert-arazzo-runtime-expression?utm_source=npm-swaggerexpert-arazzo-runtime-expression&utm_medium=referral&utm_campaign=readme">
@@ -302,9 +302,9 @@ source-descriptions-reference = 1*CHAR
302
302
 
303
303
  ; Secondary grammar for parsing $components name part
304
304
  ; Format: {field}.{subField}
305
- ; Allowed fields: inputs, parameters, successActions, failureActions
305
+ ; Allowed fields: parameters, successActions, failureActions
306
306
  components-name = components-field "." components-sub-field
307
- components-field = "inputs" / "parameters" / "successActions" / "failureActions"
307
+ components-field = "parameters" / "successActions" / "failureActions"
308
308
  components-sub-field = 1*(ALPHA / DIGIT / "." / "-" / "_")
309
309
 
310
310
  ; https://datatracker.ietf.org/doc/html/rfc6901#section-3
package/cjs/grammar.cjs CHANGED
@@ -11,13 +11,13 @@ function grammar() {
11
11
  // SUMMARY
12
12
  // rules = 36
13
13
  // udts = 0
14
- // opcodes = 213
14
+ // opcodes = 212
15
15
  // --- ABNF original opcodes
16
16
  // ALT = 21
17
17
  // CAT = 24
18
18
  // REP = 16
19
19
  // RNM = 55
20
- // TLS = 73
20
+ // TLS = 72
21
21
  // TBS = 12
22
22
  // TRG = 12
23
23
  // --- SABNF superset opcodes
@@ -847,21 +847,17 @@ function grammar() {
847
847
  this.rules[22].opcodes = [];
848
848
  this.rules[22].opcodes[0] = {
849
849
  type: 1,
850
- children: [1, 2, 3, 4]
850
+ children: [1, 2, 3]
851
851
  }; // ALT
852
852
  this.rules[22].opcodes[1] = {
853
- type: 7,
854
- string: [105, 110, 112, 117, 116, 115]
855
- }; // TLS
856
- this.rules[22].opcodes[2] = {
857
853
  type: 7,
858
854
  string: [112, 97, 114, 97, 109, 101, 116, 101, 114, 115]
859
855
  }; // TLS
860
- this.rules[22].opcodes[3] = {
856
+ this.rules[22].opcodes[2] = {
861
857
  type: 7,
862
858
  string: [115, 117, 99, 99, 101, 115, 115, 97, 99, 116, 105, 111, 110, 115]
863
859
  }; // TLS
864
- this.rules[22].opcodes[4] = {
860
+ this.rules[22].opcodes[3] = {
865
861
  type: 7,
866
862
  string: [102, 97, 105, 108, 117, 114, 101, 97, 99, 116, 105, 111, 110, 115]
867
863
  }; // TLS
@@ -1280,9 +1276,9 @@ function grammar() {
1280
1276
  str += "\n";
1281
1277
  str += "; Secondary grammar for parsing $components name part\n";
1282
1278
  str += "; Format: {field}.{subField}\n";
1283
- str += "; Allowed fields: inputs, parameters, successActions, failureActions\n";
1279
+ str += "; Allowed fields: parameters, successActions, failureActions\n";
1284
1280
  str += "components-name = components-field \".\" components-sub-field\n";
1285
- str += "components-field = \"inputs\" / \"parameters\" / \"successActions\" / \"failureActions\"\n";
1281
+ str += "components-field = \"parameters\" / \"successActions\" / \"failureActions\"\n";
1286
1282
  str += "components-sub-field = 1*(ALPHA / DIGIT / \".\" / \"-\" / \"_\")\n";
1287
1283
  str += "\n";
1288
1284
  str += "; https://datatracker.ietf.org/doc/html/rfc6901#section-3\n";
package/es/grammar.mjs CHANGED
@@ -7,13 +7,13 @@ export default function grammar() {
7
7
  // SUMMARY
8
8
  // rules = 36
9
9
  // udts = 0
10
- // opcodes = 213
10
+ // opcodes = 212
11
11
  // --- ABNF original opcodes
12
12
  // ALT = 21
13
13
  // CAT = 24
14
14
  // REP = 16
15
15
  // RNM = 55
16
- // TLS = 73
16
+ // TLS = 72
17
17
  // TBS = 12
18
18
  // TRG = 12
19
19
  // --- SABNF superset opcodes
@@ -843,21 +843,17 @@ export default function grammar() {
843
843
  this.rules[22].opcodes = [];
844
844
  this.rules[22].opcodes[0] = {
845
845
  type: 1,
846
- children: [1, 2, 3, 4]
846
+ children: [1, 2, 3]
847
847
  }; // ALT
848
848
  this.rules[22].opcodes[1] = {
849
- type: 7,
850
- string: [105, 110, 112, 117, 116, 115]
851
- }; // TLS
852
- this.rules[22].opcodes[2] = {
853
849
  type: 7,
854
850
  string: [112, 97, 114, 97, 109, 101, 116, 101, 114, 115]
855
851
  }; // TLS
856
- this.rules[22].opcodes[3] = {
852
+ this.rules[22].opcodes[2] = {
857
853
  type: 7,
858
854
  string: [115, 117, 99, 99, 101, 115, 115, 97, 99, 116, 105, 111, 110, 115]
859
855
  }; // TLS
860
- this.rules[22].opcodes[4] = {
856
+ this.rules[22].opcodes[3] = {
861
857
  type: 7,
862
858
  string: [102, 97, 105, 108, 117, 114, 101, 97, 99, 116, 105, 111, 110, 115]
863
859
  }; // TLS
@@ -1276,9 +1272,9 @@ export default function grammar() {
1276
1272
  str += "\n";
1277
1273
  str += "; Secondary grammar for parsing $components name part\n";
1278
1274
  str += "; Format: {field}.{subField}\n";
1279
- str += "; Allowed fields: inputs, parameters, successActions, failureActions\n";
1275
+ str += "; Allowed fields: parameters, successActions, failureActions\n";
1280
1276
  str += "components-name = components-field \".\" components-sub-field\n";
1281
- str += "components-field = \"inputs\" / \"parameters\" / \"successActions\" / \"failureActions\"\n";
1277
+ str += "components-field = \"parameters\" / \"successActions\" / \"failureActions\"\n";
1282
1278
  str += "components-sub-field = 1*(ALPHA / DIGIT / \".\" / \"-\" / \"_\")\n";
1283
1279
  str += "\n";
1284
1280
  str += "; https://datatracker.ietf.org/doc/html/rfc6901#section-3\n";
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "2.0.1",
6
+ "version": "2.0.2",
7
7
  "description": "Arazzo Runtime expressions parser, validator and extractor.",
8
8
  "main": "./cjs/index.cjs",
9
9
  "types": "./types/index.d.ts",
package/types/index.d.ts CHANGED
@@ -14,7 +14,7 @@ export interface CSTNode {
14
14
  * Translator base interface
15
15
  */
16
16
  export interface Translator {
17
- getTree(): CSTNode | string | undefined;
17
+ getTree(): CSTNode | ASTNode | string | undefined;
18
18
  }
19
19
 
20
20
  /**
@@ -29,7 +29,8 @@ export class CSTTranslator implements Translator {
29
29
  /**
30
30
  * XMLTranslator - Produces XML string representation
31
31
  */
32
- export class XMLTranslator extends CSTTranslator {
32
+ export class XMLTranslator implements Translator {
33
+ constructor();
33
34
  getTree(): string;
34
35
  }
35
36
 
@@ -203,7 +204,7 @@ export interface SourceDescriptionsExpression {
203
204
  */
204
205
  export interface ComponentsExpression {
205
206
  readonly type: 'ComponentsExpression';
206
- readonly field: 'inputs' | 'parameters' | 'successActions' | 'failureActions';
207
+ readonly field: 'parameters' | 'successActions' | 'failureActions';
207
208
  readonly subField: string;
208
209
  }
209
210
 
@@ -227,7 +228,8 @@ export type ASTNode =
227
228
  * ASTTranslator - Produces Abstract Syntax Tree
228
229
  * Suitable for implementations that need to analyze or evaluate expressions.
229
230
  */
230
- export class ASTTranslator extends CSTTranslator {
231
+ export class ASTTranslator implements Translator {
232
+ constructor();
231
233
  getTree(): ASTNode;
232
234
  }
233
235
 
@@ -258,36 +260,65 @@ export class Stats {
258
260
  /**
259
261
  * Parse options
260
262
  */
261
- export interface ParseOptions {
263
+ export interface ParseOptions<T extends Translator | null = Translator | null> {
262
264
  readonly stats?: boolean;
263
265
  readonly trace?: boolean;
264
- readonly translator?: Translator | null;
266
+ readonly translator?: T;
267
+ }
268
+
269
+ /**
270
+ * Parse result metadata
271
+ */
272
+ export interface ParseResultMeta {
273
+ readonly success: boolean;
274
+ readonly state: number;
275
+ readonly stateName: string;
276
+ readonly length: number;
277
+ readonly matched: number;
278
+ readonly maxMatched: number;
279
+ readonly maxTreeDepth: number;
280
+ readonly nodeHits: number;
265
281
  }
266
282
 
267
283
  /**
268
284
  * Parse result
269
285
  */
270
- export interface ParseResult {
271
- readonly result: {
272
- readonly success: boolean;
273
- readonly state: number;
274
- readonly stateName: string;
275
- readonly length: number;
276
- readonly matched: number;
277
- readonly maxMatched: number;
278
- readonly maxTreeDepth: number;
279
- readonly nodeHits: number;
280
- };
281
- readonly tree: CSTNode | string | undefined;
286
+ export interface ParseResult<T = CSTNode | ASTNode | string | undefined> {
287
+ readonly result: ParseResultMeta;
288
+ readonly tree: T;
282
289
  readonly stats: Stats | undefined;
283
290
  readonly trace: Trace | undefined;
284
291
  }
285
292
 
286
293
  /**
287
- * Parse a runtime expression
294
+ * Parse a runtime expression with ASTTranslator
295
+ * https://spec.openapis.org/arazzo/latest.html#runtime-expressions
296
+ */
297
+ export function parse(runtimeExpression: string, options: ParseOptions<ASTTranslator>): ParseResult<ASTNode>;
298
+
299
+ /**
300
+ * Parse a runtime expression with XMLTranslator
301
+ * https://spec.openapis.org/arazzo/latest.html#runtime-expressions
302
+ */
303
+ export function parse(runtimeExpression: string, options: ParseOptions<XMLTranslator>): ParseResult<string>;
304
+
305
+ /**
306
+ * Parse a runtime expression with CSTTranslator
307
+ * https://spec.openapis.org/arazzo/latest.html#runtime-expressions
308
+ */
309
+ export function parse(runtimeExpression: string, options: ParseOptions<CSTTranslator>): ParseResult<CSTNode>;
310
+
311
+ /**
312
+ * Parse a runtime expression with null translator (validation only)
313
+ * https://spec.openapis.org/arazzo/latest.html#runtime-expressions
314
+ */
315
+ export function parse(runtimeExpression: string, options: ParseOptions<null>): ParseResult<undefined>;
316
+
317
+ /**
318
+ * Parse a runtime expression with default ASTTranslator
288
319
  * https://spec.openapis.org/arazzo/latest.html#runtime-expressions
289
320
  */
290
- export function parse(runtimeExpression: string, options?: ParseOptions): ParseResult;
321
+ export function parse(runtimeExpression: string, options?: ParseOptions): ParseResult<ASTNode>;
291
322
 
292
323
  /**
293
324
  * Test if a string is a valid runtime expression