@finnair/path-parser 4.0.0 → 5.0.1
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 +56 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -7
- package/dist/matcherGrammar.d.ts +5 -13
- package/dist/matcherGrammar.js +12 -43
- package/dist/parsePath.js +6 -13
- package/dist/parsePathMatcher.js +6 -13
- package/dist/pathGrammar.d.ts +5 -13
- package/dist/pathGrammar.js +7 -14
- package/package.json +13 -5
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,62 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [5.0.1](https://github.com/finnair/v-validation/compare/v5.0.0...v5.0.1) (2023-10-13)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* moo import ([a866737](https://github.com/finnair/v-validation/commit/a8667371515fd2fe92fa2e32b382ccc55612b704))
|
|
12
|
+
* npm ignore node_modules for published packages ([9690faf](https://github.com/finnair/v-validation/commit/9690fafb8289e6448dbbeb6274054a8f2b01907a))
|
|
13
|
+
* revert npm ignore node_modules for published packages ([53acd31](https://github.com/finnair/v-validation/commit/53acd312441e823d507152f371ecca0367412c18))
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
**Note:** Version bump only for package @finnair/path-parser
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
## [5.0.1](https://github.com/finnair/v-validation/compare/v5.0.0...v5.0.1) (2023-10-13)
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
### Bug Fixes
|
|
31
|
+
|
|
32
|
+
* moo import ([a866737](https://github.com/finnair/v-validation/commit/a8667371515fd2fe92fa2e32b382ccc55612b704))
|
|
33
|
+
* npm ignore node_modules for published packages ([9690faf](https://github.com/finnair/v-validation/commit/9690fafb8289e6448dbbeb6274054a8f2b01907a))
|
|
34
|
+
* revert npm ignore node_modules for published packages ([53acd31](https://github.com/finnair/v-validation/commit/53acd312441e823d507152f371ecca0367412c18))
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
# [5.0.0](https://github.com/finnair/v-validation/compare/v4.3.0...v5.0.0) (2023-10-13)
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
### Features
|
|
44
|
+
|
|
45
|
+
* use ECMAScript modules (ESM) instead of CommonJS ([#95](https://github.com/finnair/v-validation/issues/95)) ([92e9118](https://github.com/finnair/v-validation/commit/92e9118235957ec4bc2bcf2de73e195ea940378c))
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
# [5.0.0](https://github.com/finnair/v-validation/compare/v4.3.0...v5.0.0) (2023-10-13)
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
### Features
|
|
55
|
+
|
|
56
|
+
* use ECMAScript modules (ESM) instead of CommonJS ([#95](https://github.com/finnair/v-validation/issues/95)) ([92e9118](https://github.com/finnair/v-validation/commit/92e9118235957ec4bc2bcf2de73e195ea940378c))
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
|
|
6
62
|
# [4.0.0](https://github.com/finnair/v-validation/compare/v3.2.0...v4.0.0) (2022-11-07)
|
|
7
63
|
|
|
8
64
|
**Note:** Version bump only for package @finnair/path-parser
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { parsePath } from './parsePath';
|
|
2
|
-
export { parsePathMatcher } from './parsePathMatcher';
|
|
1
|
+
export { parsePath } from './parsePath.js';
|
|
2
|
+
export { parsePathMatcher } from './parsePathMatcher.js';
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.parsePathMatcher = exports.parsePath = void 0;
|
|
4
|
-
var parsePath_1 = require("./parsePath");
|
|
5
|
-
Object.defineProperty(exports, "parsePath", { enumerable: true, get: function () { return parsePath_1.parsePath; } });
|
|
6
|
-
var parsePathMatcher_1 = require("./parsePathMatcher");
|
|
7
|
-
Object.defineProperty(exports, "parsePathMatcher", { enumerable: true, get: function () { return parsePathMatcher_1.parsePathMatcher; } });
|
|
1
|
+
export { parsePath } from './parsePath.js';
|
|
2
|
+
export { parsePathMatcher } from './parsePathMatcher.js';
|
package/dist/matcherGrammar.d.ts
CHANGED
|
@@ -1,26 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
value: any;
|
|
3
|
-
[key: string]: any;
|
|
4
|
-
}
|
|
5
|
-
interface NearleyLexer {
|
|
6
|
-
reset: (chunk: string, info: any) => void;
|
|
7
|
-
next: () => NearleyToken | undefined;
|
|
8
|
-
save: () => any;
|
|
9
|
-
formatError: (token: NearleyToken) => string;
|
|
10
|
-
has: (tokenType: string) => boolean;
|
|
11
|
-
}
|
|
1
|
+
import moo from 'moo';
|
|
12
2
|
interface NearleyRule {
|
|
13
3
|
name: string;
|
|
14
4
|
symbols: NearleySymbol[];
|
|
15
5
|
postprocess?: (d: any[], loc?: number, reject?: {}) => any;
|
|
16
6
|
}
|
|
17
|
-
|
|
7
|
+
type NearleySymbol = string | {
|
|
18
8
|
literal: any;
|
|
9
|
+
} | {
|
|
10
|
+
type: any;
|
|
19
11
|
} | {
|
|
20
12
|
test: (token: any) => boolean;
|
|
21
13
|
};
|
|
22
14
|
interface Grammar {
|
|
23
|
-
Lexer:
|
|
15
|
+
Lexer: moo.Lexer | undefined;
|
|
24
16
|
ParserRules: NearleyRule[];
|
|
25
17
|
ParserStart: string;
|
|
26
18
|
}
|
package/dist/matcherGrammar.js
CHANGED
|
@@ -1,37 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
// Generated automatically by nearley, version 2.19.2
|
|
27
|
-
// http://github.com/Hardmath123/nearley
|
|
28
|
-
// Bypasses TS6133. Allow declared but unused functions.
|
|
29
|
-
// @ts-ignore
|
|
30
|
-
function id(d) {
|
|
31
|
-
return d[0];
|
|
32
|
-
}
|
|
33
|
-
const matchers = __importStar(require("@finnair/path"));
|
|
34
|
-
const moo = require('moo');
|
|
1
|
+
// Based on a grammar that was automatically generated by nearley, version 2.19.2
|
|
2
|
+
import * as matchers from '@finnair/path';
|
|
3
|
+
import moo from 'moo';
|
|
35
4
|
const lexer = moo.compile({
|
|
36
5
|
qString: /'(?:\\["bfnrt\/\\]|\\u[a-fA-F0-9]{4}|[^"\\])*?'/,
|
|
37
6
|
qqString: /"(?:\\["bfnrt\/\\]|\\u[a-fA-F0-9]{4}|[^"\\])*?"/,
|
|
@@ -59,32 +28,32 @@ const grammar = {
|
|
|
59
28
|
{ name: 'PropertyExpression', symbols: [{ literal: '*' }], postprocess: d => matchers.AnyProperty },
|
|
60
29
|
{
|
|
61
30
|
name: 'PropertyExpression',
|
|
62
|
-
symbols: [
|
|
31
|
+
symbols: [{ type: 'property' }],
|
|
63
32
|
postprocess: d => new matchers.PropertyMatcher(d[0].value),
|
|
64
33
|
},
|
|
65
34
|
{
|
|
66
35
|
name: 'IndexExpression',
|
|
67
|
-
symbols: [
|
|
36
|
+
symbols: [{ type: 'integer' }],
|
|
68
37
|
postprocess: d => new matchers.IndexMatcher(parseInt(d[0].value)),
|
|
69
38
|
},
|
|
70
39
|
{
|
|
71
40
|
name: 'IndexExpression',
|
|
72
|
-
symbols: [
|
|
41
|
+
symbols: [{ type: 'qqString' }],
|
|
73
42
|
postprocess: d => new matchers.PropertyMatcher(JSON.parse(d[0].value)),
|
|
74
43
|
},
|
|
75
44
|
{
|
|
76
45
|
name: 'IndexExpression',
|
|
77
|
-
symbols: [
|
|
46
|
+
symbols: [{ type: 'qString' }],
|
|
78
47
|
postprocess: d => new matchers.PropertyMatcher(handleQString(d[0].value)),
|
|
79
48
|
},
|
|
80
49
|
{ name: 'IndexExpression', symbols: [{ literal: '*' }], postprocess: d => matchers.AnyIndex },
|
|
81
50
|
{ name: 'UnionExpression', symbols: ['ComponentExpression', { literal: ',' }, 'ComponentExpression'], postprocess: d => [d[0], d[2]] },
|
|
82
51
|
{ name: 'UnionExpression', symbols: ['ComponentExpression', { literal: ',' }, 'UnionExpression'], postprocess: d => [d[0], ...d[2]] },
|
|
83
|
-
{ name: 'ComponentExpression', symbols: [
|
|
84
|
-
{ name: 'ComponentExpression', symbols: [
|
|
85
|
-
{ name: 'ComponentExpression', symbols: [
|
|
86
|
-
{ name: 'ComponentExpression', symbols: [
|
|
52
|
+
{ name: 'ComponentExpression', symbols: [{ type: 'integer' }], postprocess: d => parseInt(d[0].value) },
|
|
53
|
+
{ name: 'ComponentExpression', symbols: [{ type: 'property' }], postprocess: d => d[0].value },
|
|
54
|
+
{ name: 'ComponentExpression', symbols: [{ type: 'qqString' }], postprocess: d => JSON.parse(d[0].value) },
|
|
55
|
+
{ name: 'ComponentExpression', symbols: [{ type: 'qString' }], postprocess: d => handleQString(d[0].value) },
|
|
87
56
|
],
|
|
88
57
|
ParserStart: 'Path',
|
|
89
58
|
};
|
|
90
|
-
|
|
59
|
+
export default grammar;
|
package/dist/parsePath.js
CHANGED
|
@@ -1,20 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
exports.parsePath = void 0;
|
|
7
|
-
const path_1 = require("@finnair/path");
|
|
8
|
-
const nearley_1 = __importDefault(require("nearley"));
|
|
9
|
-
const pathGrammar_1 = __importDefault(require("./pathGrammar"));
|
|
10
|
-
function parsePath(str) {
|
|
11
|
-
const parser = new nearley_1.default.Parser(nearley_1.default.Grammar.fromCompiled(pathGrammar_1.default));
|
|
1
|
+
import { Path } from '@finnair/path';
|
|
2
|
+
import nearley from 'nearley';
|
|
3
|
+
import pathGrammar from './pathGrammar.js';
|
|
4
|
+
export function parsePath(str) {
|
|
5
|
+
const parser = new nearley.Parser(nearley.Grammar.fromCompiled(pathGrammar));
|
|
12
6
|
parser.feed(str);
|
|
13
7
|
if (parser.results[0]) {
|
|
14
|
-
return
|
|
8
|
+
return Path.of(...parser.results[0]);
|
|
15
9
|
}
|
|
16
10
|
else {
|
|
17
11
|
throw new Error(`Unrecognized Path: ${str}`);
|
|
18
12
|
}
|
|
19
13
|
}
|
|
20
|
-
exports.parsePath = parsePath;
|
package/dist/parsePathMatcher.js
CHANGED
|
@@ -1,20 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
exports.parsePathMatcher = void 0;
|
|
7
|
-
const nearley_1 = __importDefault(require("nearley"));
|
|
8
|
-
const matcherGrammar_1 = __importDefault(require("./matcherGrammar"));
|
|
9
|
-
const path_1 = require("@finnair/path");
|
|
10
|
-
function parsePathMatcher(str) {
|
|
11
|
-
const parser = new nearley_1.default.Parser(nearley_1.default.Grammar.fromCompiled(matcherGrammar_1.default));
|
|
1
|
+
import nearley from 'nearley';
|
|
2
|
+
import matcherGrammar from './matcherGrammar.js';
|
|
3
|
+
import { PathMatcher } from '@finnair/path';
|
|
4
|
+
export function parsePathMatcher(str) {
|
|
5
|
+
const parser = new nearley.Parser(nearley.Grammar.fromCompiled(matcherGrammar));
|
|
12
6
|
parser.feed(str);
|
|
13
7
|
if (parser.results[0]) {
|
|
14
|
-
return
|
|
8
|
+
return PathMatcher.of(...parser.results[0]);
|
|
15
9
|
}
|
|
16
10
|
else {
|
|
17
11
|
throw new Error(`Unrecognized PathMatcher: ${str}`);
|
|
18
12
|
}
|
|
19
13
|
}
|
|
20
|
-
exports.parsePathMatcher = parsePathMatcher;
|
package/dist/pathGrammar.d.ts
CHANGED
|
@@ -1,26 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
value: any;
|
|
3
|
-
[key: string]: any;
|
|
4
|
-
}
|
|
5
|
-
interface NearleyLexer {
|
|
6
|
-
reset: (chunk: string, info: any) => void;
|
|
7
|
-
next: () => NearleyToken | undefined;
|
|
8
|
-
save: () => any;
|
|
9
|
-
formatError: (token: NearleyToken) => string;
|
|
10
|
-
has: (tokenType: string) => boolean;
|
|
11
|
-
}
|
|
1
|
+
import moo from 'moo';
|
|
12
2
|
interface NearleyRule {
|
|
13
3
|
name: string;
|
|
14
4
|
symbols: NearleySymbol[];
|
|
15
5
|
postprocess?: (d: any[], loc?: number, reject?: {}) => any;
|
|
16
6
|
}
|
|
17
|
-
|
|
7
|
+
type NearleySymbol = string | {
|
|
18
8
|
literal: any;
|
|
9
|
+
} | {
|
|
10
|
+
type: any;
|
|
19
11
|
} | {
|
|
20
12
|
test: (token: any) => boolean;
|
|
21
13
|
};
|
|
22
14
|
interface Grammar {
|
|
23
|
-
Lexer:
|
|
15
|
+
Lexer: moo.Lexer | undefined;
|
|
24
16
|
ParserRules: NearleyRule[];
|
|
25
17
|
ParserStart: string;
|
|
26
18
|
}
|
package/dist/pathGrammar.js
CHANGED
|
@@ -1,11 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
// Generated automatically by nearley, version 2.19.2
|
|
1
|
+
// Based on a grammar that was automatically generated by nearley, version 2.19.2
|
|
4
2
|
// http://github.com/Hardmath123/nearley
|
|
5
|
-
|
|
6
|
-
// @ts-ignore
|
|
7
|
-
function id(d) { return d[0]; }
|
|
8
|
-
const moo = require('moo');
|
|
3
|
+
import moo from 'moo';
|
|
9
4
|
const lexer = moo.compile({
|
|
10
5
|
qString: /'(?:\\["bfnrt\/\\]|\\u[a-fA-F0-9]{4}|[^"\\])*?'/,
|
|
11
6
|
qqString: /"(?:\\["bfnrt\/\\]|\\u[a-fA-F0-9]{4}|[^"\\])*?"/,
|
|
@@ -21,8 +16,6 @@ function handleQString(qString) {
|
|
|
21
16
|
}
|
|
22
17
|
;
|
|
23
18
|
;
|
|
24
|
-
;
|
|
25
|
-
;
|
|
26
19
|
const grammar = {
|
|
27
20
|
Lexer: lexer,
|
|
28
21
|
ParserRules: [
|
|
@@ -31,11 +24,11 @@ const grammar = {
|
|
|
31
24
|
{ "name": "Path", "symbols": [{ "literal": "$" }, "Path$ebnf$1"], "postprocess": d => d[1].reduce((result, component) => result.concat(component), []) },
|
|
32
25
|
{ "name": "PathExpression", "symbols": [{ "literal": "." }, "PropertyExpression"], "postprocess": d => d[1] },
|
|
33
26
|
{ "name": "PathExpression", "symbols": [{ "literal": "[" }, "IndexExpression", { "literal": "]" }], "postprocess": d => d[1] },
|
|
34
|
-
{ "name": "PropertyExpression", "symbols": [
|
|
35
|
-
{ "name": "IndexExpression", "symbols": [
|
|
36
|
-
{ "name": "IndexExpression", "symbols": [
|
|
37
|
-
{ "name": "IndexExpression", "symbols": [
|
|
27
|
+
{ "name": "PropertyExpression", "symbols": [{ type: "property" }], "postprocess": d => d[0].value },
|
|
28
|
+
{ "name": "IndexExpression", "symbols": [{ type: "integer" }], "postprocess": d => parseInt(d[0].value) },
|
|
29
|
+
{ "name": "IndexExpression", "symbols": [{ type: "qqString" }], "postprocess": d => JSON.parse(d[0].value) },
|
|
30
|
+
{ "name": "IndexExpression", "symbols": [{ type: "qString" }], "postprocess": d => handleQString(d[0].value) }
|
|
38
31
|
],
|
|
39
32
|
ParserStart: "Path",
|
|
40
33
|
};
|
|
41
|
-
|
|
34
|
+
export default grammar;
|
package/package.json
CHANGED
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@finnair/path-parser",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Simple object path as array of strings and numbers",
|
|
6
|
-
"
|
|
7
|
-
"
|
|
6
|
+
"type": "module",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"import": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"default": "./dist/index.js"
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
},
|
|
8
15
|
"license": "MIT",
|
|
9
16
|
"homepage": "https://github.com/finnair/v-validation/tree/master/packages/path-matcher-parser#readme",
|
|
10
17
|
"bugs": "https://github.com/finnair/v-validation/issues",
|
|
@@ -23,9 +30,10 @@
|
|
|
23
30
|
"build": "tsc -b ."
|
|
24
31
|
},
|
|
25
32
|
"dependencies": {
|
|
26
|
-
"@finnair/path": "^
|
|
33
|
+
"@finnair/path": "^5.0.1",
|
|
34
|
+
"@types/moo": "0.5.1",
|
|
27
35
|
"@types/nearley": "2.11.2",
|
|
28
36
|
"nearley": "2.20.1"
|
|
29
37
|
},
|
|
30
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "002badde317763fb6ec6a0350b0043d04cc07163"
|
|
31
39
|
}
|