@swaggerexpert/arazzo-runtime-expression 1.0.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 +202 -0
- package/NOTICE +10 -0
- package/README.md +290 -0
- package/SECURITY.md +15 -0
- package/cjs/apg-lite.cjs +1221 -0
- package/cjs/extract.cjs +21 -0
- package/cjs/index.cjs +13 -0
- package/cjs/parse/callbacks/body-reference.cjs +14 -0
- package/cjs/parse/callbacks/expression.cjs +15 -0
- package/cjs/parse/callbacks/header-reference.cjs +14 -0
- package/cjs/parse/callbacks/json-pointer.cjs +14 -0
- package/cjs/parse/callbacks/name.cjs +14 -0
- package/cjs/parse/callbacks/parameter-name.cjs +14 -0
- package/cjs/parse/callbacks/path-reference.cjs +14 -0
- package/cjs/parse/callbacks/query-reference.cjs +14 -0
- package/cjs/parse/callbacks/reference-token.cjs +14 -0
- package/cjs/parse/callbacks/source.cjs +14 -0
- package/cjs/parse/callbacks/token.cjs +15 -0
- package/cjs/parse/index.cjs +40 -0
- package/cjs/runtime-expression.cjs +779 -0
- package/cjs/test.cjs +15 -0
- package/es/extract.mjs +17 -0
- package/es/index.mjs +4 -0
- package/es/parse/callbacks/body-reference.mjs +10 -0
- package/es/parse/callbacks/expression.mjs +11 -0
- package/es/parse/callbacks/header-reference.mjs +10 -0
- package/es/parse/callbacks/json-pointer.mjs +10 -0
- package/es/parse/callbacks/name.mjs +10 -0
- package/es/parse/callbacks/parameter-name.mjs +10 -0
- package/es/parse/callbacks/path-reference.mjs +10 -0
- package/es/parse/callbacks/query-reference.mjs +10 -0
- package/es/parse/callbacks/reference-token.mjs +10 -0
- package/es/parse/callbacks/source.mjs +10 -0
- package/es/parse/callbacks/token.mjs +10 -0
- package/es/parse/index.mjs +35 -0
- package/es/runtime-expression.mjs +775 -0
- package/es/test.mjs +10 -0
- package/package.json +82 -0
- package/types/index.d.ts +54 -0
package/es/test.mjs
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@swaggerexpert/arazzo-runtime-expression",
|
|
3
|
+
"publishConfig": {
|
|
4
|
+
"access": "public"
|
|
5
|
+
},
|
|
6
|
+
"version": "1.0.0",
|
|
7
|
+
"description": "Arazzo Runtime expressions parser, validator and extractor.",
|
|
8
|
+
"main": "./cjs/index.cjs",
|
|
9
|
+
"types": "./types/index.d.ts",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"types": "./types/index.d.ts",
|
|
13
|
+
"import": "./es/index.mjs",
|
|
14
|
+
"require": "./cjs/index.cjs"
|
|
15
|
+
},
|
|
16
|
+
"./package.json": "./package.json"
|
|
17
|
+
},
|
|
18
|
+
"watch": {
|
|
19
|
+
"test": "{src,test}/*.js"
|
|
20
|
+
},
|
|
21
|
+
"scripts": {
|
|
22
|
+
"prepublishOnly": "npm run build",
|
|
23
|
+
"grammar:compile": "node ./scripts/apg-js.js --lite --in=./src/runtime-expression.bnf --out=./src/runtime-expression.js && cd ./src",
|
|
24
|
+
"build": "npm run grammar:compile && npm run build:es && npm run build:cjs && npm run build:cjs:apg-lite",
|
|
25
|
+
"build:es": "cross-env BABEL_ENV=es babel src --out-dir es --extensions '.js' --out-file-extension '.mjs'",
|
|
26
|
+
"build:cjs": "cross-env BABEL_ENV=cjs babel src --out-dir cjs --extensions '.js' --out-file-extension '.cjs'",
|
|
27
|
+
"build:cjs:apg-lite": "cross-env BABEL_ENV=cjs babel node_modules/apg-lite/lib/parser.js --out-file ./cjs/apg-lite.cjs",
|
|
28
|
+
"test": "mocha",
|
|
29
|
+
"test:watch": "npm-watch test",
|
|
30
|
+
"watch": "npm-watch"
|
|
31
|
+
},
|
|
32
|
+
"engines": {
|
|
33
|
+
"node": ">=12.20.0"
|
|
34
|
+
},
|
|
35
|
+
"type": "module",
|
|
36
|
+
"repository": {
|
|
37
|
+
"type": "git",
|
|
38
|
+
"url": "https://github.com/swaggerexpert/arazzo-runtime-expression.git"
|
|
39
|
+
},
|
|
40
|
+
"keywords": [
|
|
41
|
+
"arazzo",
|
|
42
|
+
"runtime",
|
|
43
|
+
"expression",
|
|
44
|
+
"parser",
|
|
45
|
+
"validator",
|
|
46
|
+
"extractor"
|
|
47
|
+
],
|
|
48
|
+
"author": "Vladimír Gorej <vladimir.gorej@gmail.com>",
|
|
49
|
+
"license": "Apache-2.0",
|
|
50
|
+
"bugs": {
|
|
51
|
+
"url": "https://github.com/swaggerexpert/arazzo-runtime-expression/issues"
|
|
52
|
+
},
|
|
53
|
+
"homepage": "https://github.com/swaggerexpert/arazzo-runtime-expression#readme",
|
|
54
|
+
"files": [
|
|
55
|
+
"es/",
|
|
56
|
+
"cjs/",
|
|
57
|
+
"types/",
|
|
58
|
+
"LICENSE",
|
|
59
|
+
"NOTICE",
|
|
60
|
+
"package.json",
|
|
61
|
+
"README.md",
|
|
62
|
+
"SECURITY.md"
|
|
63
|
+
],
|
|
64
|
+
"dependencies": {
|
|
65
|
+
"apg-lite": "^1.0.4"
|
|
66
|
+
},
|
|
67
|
+
"devDependencies": {
|
|
68
|
+
"@babel/cli": "=7.26.4",
|
|
69
|
+
"@babel/core": "=7.26.9",
|
|
70
|
+
"@babel/preset-env": "=7.26.9",
|
|
71
|
+
"@commitlint/cli": "=19.7.1",
|
|
72
|
+
"@commitlint/config-conventional": "=19.7.1",
|
|
73
|
+
"apg-js": "^4.4.0",
|
|
74
|
+
"babel-plugin-module-resolver": "^5.0.2",
|
|
75
|
+
"chai": "=5.2.0",
|
|
76
|
+
"cross-env": "^7.0.3",
|
|
77
|
+
"husky": "=9.1.7",
|
|
78
|
+
"mocha": "=11.1.0",
|
|
79
|
+
"npm-watch": "^0.13.0",
|
|
80
|
+
"prettier": "^3.1.1"
|
|
81
|
+
}
|
|
82
|
+
}
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parsing
|
|
3
|
+
*/
|
|
4
|
+
export function parse(runtimeExpression: string): ParseResult;
|
|
5
|
+
|
|
6
|
+
interface ParseResult {
|
|
7
|
+
readonly result: {
|
|
8
|
+
readonly success: boolean;
|
|
9
|
+
};
|
|
10
|
+
readonly ast: {
|
|
11
|
+
readonly translate: (parts: any[]) => Array<[string, string]>;
|
|
12
|
+
readonly toXml: () => string;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Testing
|
|
18
|
+
*/
|
|
19
|
+
export function test(runtimeExpression: string): boolean;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Extracting
|
|
23
|
+
*/
|
|
24
|
+
export function extract(openapiRuntimeExpression: string): string;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Grammar
|
|
28
|
+
*/
|
|
29
|
+
export function Grammar(): Grammar;
|
|
30
|
+
|
|
31
|
+
export interface Grammar {
|
|
32
|
+
grammarObject: string; // Internal identifier
|
|
33
|
+
rules: Rule[]; // List of grammar rules
|
|
34
|
+
udts: UDT[]; // User-defined terminals (empty in this grammar)
|
|
35
|
+
toString(): string; // Method to return the grammar in ABNF format
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface Rule {
|
|
39
|
+
name: string; // Rule name
|
|
40
|
+
lower: string; // Lowercased rule name
|
|
41
|
+
index: number; // Rule index
|
|
42
|
+
isBkr: boolean; // Is this a back-reference?
|
|
43
|
+
opcodes?: Opcode[]; // List of opcodes for the rule
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export type Opcode =
|
|
47
|
+
| { type: 1; children: number[] } // ALT (alternation)
|
|
48
|
+
| { type: 2; children: number[] } // CAT (concatenation)
|
|
49
|
+
| { type: 3; min: number; max: number } // REP (repetition)
|
|
50
|
+
| { type: 4; index: number } // RNM (rule reference)
|
|
51
|
+
| { type: 5; min: number; max: number } // TRG (terminal range)
|
|
52
|
+
| { type: 6 | 7; string: number[] }; // TBS or TLS (byte sequence or literal string)
|
|
53
|
+
|
|
54
|
+
export type UDT = {}; // User-defined terminals (empty in this grammar)
|