@hyperjump/json-schema 0.21.0 → 0.23.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/README.md +10 -5
- package/dist/json-schema-amd.js +1615 -435
- package/dist/json-schema-amd.js.map +1 -1
- package/dist/json-schema-amd.min.js +2 -2
- package/dist/json-schema-amd.min.js.map +1 -1
- package/dist/json-schema-cjs.js +1615 -435
- package/dist/json-schema-cjs.js.map +1 -1
- package/dist/json-schema-cjs.min.js +2 -2
- package/dist/json-schema-cjs.min.js.map +1 -1
- package/dist/json-schema-esm.js +1615 -435
- package/dist/json-schema-esm.js.map +1 -1
- package/dist/json-schema-esm.min.js +2 -2
- package/dist/json-schema-esm.min.js.map +1 -1
- package/dist/json-schema-iife.js +1615 -435
- package/dist/json-schema-iife.js.map +1 -1
- package/dist/json-schema-iife.min.js +2 -2
- package/dist/json-schema-iife.min.js.map +1 -1
- package/dist/json-schema-system.js +1615 -435
- package/dist/json-schema-system.js.map +1 -1
- package/dist/json-schema-system.min.js +2 -2
- package/dist/json-schema-system.min.js.map +1 -1
- package/dist/json-schema-umd.js +1615 -435
- package/dist/json-schema-umd.js.map +1 -1
- package/dist/json-schema-umd.min.js +2 -2
- package/dist/json-schema-umd.min.js.map +1 -1
- package/package.json +3 -3
package/dist/json-schema-iife.js
CHANGED
|
@@ -3,7 +3,7 @@ var JsonSchema = (function (exports) {
|
|
|
3
3
|
|
|
4
4
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
5
5
|
|
|
6
|
-
var justCurryIt = curry$
|
|
6
|
+
var justCurryIt$2 = curry$j;
|
|
7
7
|
|
|
8
8
|
/*
|
|
9
9
|
function add(a, b, c) {
|
|
@@ -28,7 +28,7 @@ var JsonSchema = (function (exports) {
|
|
|
28
28
|
milesToKm(10); // 16.2
|
|
29
29
|
*/
|
|
30
30
|
|
|
31
|
-
function curry$
|
|
31
|
+
function curry$j(fn, arity) {
|
|
32
32
|
return function curried() {
|
|
33
33
|
if (arity == null) {
|
|
34
34
|
arity = fn.length;
|
|
@@ -1899,84 +1899,84 @@ var JsonSchema = (function (exports) {
|
|
|
1899
1899
|
|
|
1900
1900
|
var common$1 = { jsonTypeOf: jsonTypeOf$2, resolveUrl: resolveUrl$3, urlFragment: urlFragment$1, pathRelative: pathRelative$1 };
|
|
1901
1901
|
|
|
1902
|
-
const curry$
|
|
1902
|
+
const curry$i = justCurryIt$2;
|
|
1903
1903
|
|
|
1904
1904
|
|
|
1905
|
-
const nil$
|
|
1905
|
+
const nil$3 = "";
|
|
1906
1906
|
|
|
1907
|
-
const compile$
|
|
1907
|
+
const compile$Q = (pointer) => {
|
|
1908
1908
|
if (pointer.length > 0 && pointer[0] !== "/") {
|
|
1909
1909
|
throw Error("Invalid JSON Pointer");
|
|
1910
1910
|
}
|
|
1911
1911
|
|
|
1912
|
-
return pointer.split("/").slice(1).map(unescape);
|
|
1912
|
+
return pointer.split("/").slice(1).map(unescape$1);
|
|
1913
1913
|
};
|
|
1914
1914
|
|
|
1915
|
-
const get$
|
|
1916
|
-
const ptr = compile$
|
|
1915
|
+
const get$3 = (pointer, value = undefined) => {
|
|
1916
|
+
const ptr = compile$Q(pointer);
|
|
1917
1917
|
|
|
1918
1918
|
const fn = (value) => ptr.reduce(([value, pointer], segment) => {
|
|
1919
|
-
return [applySegment(value, segment, pointer), append(segment, pointer)];
|
|
1919
|
+
return [applySegment$1(value, segment, pointer), append$1(segment, pointer)];
|
|
1920
1920
|
}, [value, ""])[0];
|
|
1921
1921
|
|
|
1922
1922
|
return value === undefined ? fn : fn(value);
|
|
1923
1923
|
};
|
|
1924
1924
|
|
|
1925
|
-
const set = (pointer, subject = undefined, value = undefined) => {
|
|
1926
|
-
const ptr = compile$
|
|
1927
|
-
const fn = curry$
|
|
1925
|
+
const set$1 = (pointer, subject = undefined, value = undefined) => {
|
|
1926
|
+
const ptr = compile$Q(pointer);
|
|
1927
|
+
const fn = curry$i((subject, value) => _set$1(ptr, subject, value, nil$3));
|
|
1928
1928
|
return subject === undefined ? fn : fn(subject, value);
|
|
1929
1929
|
};
|
|
1930
1930
|
|
|
1931
|
-
const _set = (pointer, subject, value, cursor) => {
|
|
1931
|
+
const _set$1 = (pointer, subject, value, cursor) => {
|
|
1932
1932
|
if (pointer.length === 0) {
|
|
1933
1933
|
return value;
|
|
1934
1934
|
} else if (pointer.length > 1) {
|
|
1935
1935
|
const segment = pointer.shift();
|
|
1936
|
-
return { ...subject, [segment]: _set(pointer, applySegment(subject, segment, cursor), value, append(segment, cursor)) };
|
|
1936
|
+
return { ...subject, [segment]: _set$1(pointer, applySegment$1(subject, segment, cursor), value, append$1(segment, cursor)) };
|
|
1937
1937
|
} else if (Array.isArray(subject)) {
|
|
1938
1938
|
const clonedSubject = [...subject];
|
|
1939
|
-
const segment = computeSegment(subject, pointer[0]);
|
|
1939
|
+
const segment = computeSegment$1(subject, pointer[0]);
|
|
1940
1940
|
clonedSubject[segment] = value;
|
|
1941
1941
|
return clonedSubject;
|
|
1942
1942
|
} else if (typeof subject === "object" && subject !== null) {
|
|
1943
1943
|
return { ...subject, [pointer[0]]: value };
|
|
1944
1944
|
} else {
|
|
1945
|
-
return applySegment(subject, pointer[0], cursor);
|
|
1945
|
+
return applySegment$1(subject, pointer[0], cursor);
|
|
1946
1946
|
}
|
|
1947
1947
|
};
|
|
1948
1948
|
|
|
1949
|
-
const assign = (pointer, subject = undefined, value = undefined) => {
|
|
1950
|
-
const ptr = compile$
|
|
1951
|
-
const fn = curry$
|
|
1949
|
+
const assign$1 = (pointer, subject = undefined, value = undefined) => {
|
|
1950
|
+
const ptr = compile$Q(pointer);
|
|
1951
|
+
const fn = curry$i((subject, value) => _assign$1(ptr, subject, value, nil$3));
|
|
1952
1952
|
return subject === undefined ? fn : fn(subject, value);
|
|
1953
1953
|
};
|
|
1954
1954
|
|
|
1955
|
-
const _assign = (pointer, subject, value, cursor) => {
|
|
1955
|
+
const _assign$1 = (pointer, subject, value, cursor) => {
|
|
1956
1956
|
if (pointer.length === 0) {
|
|
1957
1957
|
return;
|
|
1958
|
-
} else if (pointer.length === 1 && !isScalar(subject)) {
|
|
1959
|
-
const segment = computeSegment(subject, pointer[0]);
|
|
1958
|
+
} else if (pointer.length === 1 && !isScalar$1(subject)) {
|
|
1959
|
+
const segment = computeSegment$1(subject, pointer[0]);
|
|
1960
1960
|
subject[segment] = value;
|
|
1961
1961
|
} else {
|
|
1962
1962
|
const segment = pointer.shift();
|
|
1963
|
-
_assign(pointer, applySegment(subject, segment, cursor), value, append(segment, cursor));
|
|
1963
|
+
_assign$1(pointer, applySegment$1(subject, segment, cursor), value, append$1(segment, cursor));
|
|
1964
1964
|
}
|
|
1965
1965
|
};
|
|
1966
1966
|
|
|
1967
|
-
const unset = (pointer, subject = undefined) => {
|
|
1968
|
-
const ptr = compile$
|
|
1969
|
-
const fn = (subject) => _unset(ptr, subject, nil$
|
|
1967
|
+
const unset$1 = (pointer, subject = undefined) => {
|
|
1968
|
+
const ptr = compile$Q(pointer);
|
|
1969
|
+
const fn = (subject) => _unset$1(ptr, subject, nil$3);
|
|
1970
1970
|
return subject === undefined ? fn : fn(subject);
|
|
1971
1971
|
};
|
|
1972
1972
|
|
|
1973
|
-
const _unset = (pointer, subject, cursor) => {
|
|
1973
|
+
const _unset$1 = (pointer, subject, cursor) => {
|
|
1974
1974
|
if (pointer.length == 0) {
|
|
1975
1975
|
return undefined;
|
|
1976
1976
|
} else if (pointer.length > 1) {
|
|
1977
1977
|
const segment = pointer.shift();
|
|
1978
|
-
const value = applySegment(subject, segment, cursor);
|
|
1979
|
-
return { ...subject, [segment]: _unset(pointer, value, append(segment, cursor)) };
|
|
1978
|
+
const value = applySegment$1(subject, segment, cursor);
|
|
1979
|
+
return { ...subject, [segment]: _unset$1(pointer, value, append$1(segment, cursor)) };
|
|
1980
1980
|
} else if (Array.isArray(subject)) {
|
|
1981
1981
|
return subject.filter((_, ndx) => ndx != pointer[0]);
|
|
1982
1982
|
} else if (typeof subject === "object" && subject !== null) {
|
|
@@ -1984,54 +1984,54 @@ var JsonSchema = (function (exports) {
|
|
|
1984
1984
|
const { [pointer[0]]: _, ...result } = subject;
|
|
1985
1985
|
return result;
|
|
1986
1986
|
} else {
|
|
1987
|
-
return applySegment(subject, pointer[0], cursor);
|
|
1987
|
+
return applySegment$1(subject, pointer[0], cursor);
|
|
1988
1988
|
}
|
|
1989
1989
|
};
|
|
1990
1990
|
|
|
1991
|
-
const remove = (pointer, subject = undefined) => {
|
|
1992
|
-
const ptr = compile$
|
|
1993
|
-
const fn = (subject) => _remove(ptr, subject, nil$
|
|
1991
|
+
const remove$1 = (pointer, subject = undefined) => {
|
|
1992
|
+
const ptr = compile$Q(pointer);
|
|
1993
|
+
const fn = (subject) => _remove$1(ptr, subject, nil$3);
|
|
1994
1994
|
return subject === undefined ? fn : fn(subject);
|
|
1995
1995
|
};
|
|
1996
1996
|
|
|
1997
|
-
const _remove = (pointer, subject, cursor) => {
|
|
1997
|
+
const _remove$1 = (pointer, subject, cursor) => {
|
|
1998
1998
|
if (pointer.length === 0) {
|
|
1999
1999
|
return;
|
|
2000
2000
|
} else if (pointer.length > 1) {
|
|
2001
2001
|
const segment = pointer.shift();
|
|
2002
|
-
const value = applySegment(subject, segment, cursor);
|
|
2003
|
-
_remove(pointer, value, append(segment, cursor));
|
|
2002
|
+
const value = applySegment$1(subject, segment, cursor);
|
|
2003
|
+
_remove$1(pointer, value, append$1(segment, cursor));
|
|
2004
2004
|
} else if (Array.isArray(subject)) {
|
|
2005
2005
|
subject.splice(pointer[0], 1);
|
|
2006
2006
|
} else if (typeof subject === "object" && subject !== null) {
|
|
2007
2007
|
delete subject[pointer[0]];
|
|
2008
2008
|
} else {
|
|
2009
|
-
applySegment(subject, pointer[0], cursor);
|
|
2009
|
+
applySegment$1(subject, pointer[0], cursor);
|
|
2010
2010
|
}
|
|
2011
2011
|
};
|
|
2012
2012
|
|
|
2013
|
-
const append = curry$
|
|
2013
|
+
const append$1 = curry$i((segment, pointer) => pointer + "/" + escape$2(segment));
|
|
2014
2014
|
|
|
2015
|
-
const escape = (segment) => segment.toString().replace(/~/g, "~0").replace(/\//g, "~1");
|
|
2016
|
-
const unescape = (segment) => segment.toString().replace(/~1/g, "/").replace(/~0/g, "~");
|
|
2017
|
-
const computeSegment = (value, segment) => Array.isArray(value) && segment === "-" ? value.length : segment;
|
|
2015
|
+
const escape$2 = (segment) => segment.toString().replace(/~/g, "~0").replace(/\//g, "~1");
|
|
2016
|
+
const unescape$1 = (segment) => segment.toString().replace(/~1/g, "/").replace(/~0/g, "~");
|
|
2017
|
+
const computeSegment$1 = (value, segment) => Array.isArray(value) && segment === "-" ? value.length : segment;
|
|
2018
2018
|
|
|
2019
|
-
const applySegment = (value, segment, cursor = "") => {
|
|
2019
|
+
const applySegment$1 = (value, segment, cursor = "") => {
|
|
2020
2020
|
if (value === undefined) {
|
|
2021
2021
|
throw TypeError(`Value at '${cursor}' is undefined and does not have property '${segment}'`);
|
|
2022
2022
|
} else if (value === null) {
|
|
2023
2023
|
throw TypeError(`Value at '${cursor}' is null and does not have property '${segment}'`);
|
|
2024
|
-
} else if (isScalar(value)) {
|
|
2024
|
+
} else if (isScalar$1(value)) {
|
|
2025
2025
|
throw TypeError(`Value at '${cursor}' is a ${typeof value} and does not have property '${segment}'`);
|
|
2026
2026
|
} else {
|
|
2027
|
-
const computedSegment = computeSegment(value, segment);
|
|
2027
|
+
const computedSegment = computeSegment$1(value, segment);
|
|
2028
2028
|
return value[computedSegment];
|
|
2029
2029
|
}
|
|
2030
2030
|
};
|
|
2031
2031
|
|
|
2032
|
-
const isScalar = (value) => value === null || typeof value !== "object";
|
|
2032
|
+
const isScalar$1 = (value) => value === null || typeof value !== "object";
|
|
2033
2033
|
|
|
2034
|
-
var lib$
|
|
2034
|
+
var lib$6 = { nil: nil$3, append: append$1, get: get$3, set: set$1, assign: assign$1, unset: unset$1, remove: remove$1 };
|
|
2035
2035
|
|
|
2036
2036
|
const $__value = Symbol("$__value");
|
|
2037
2037
|
const $__href = Symbol("$__href");
|
|
@@ -2047,261 +2047,1299 @@ var JsonSchema = (function (exports) {
|
|
|
2047
2047
|
|
|
2048
2048
|
var reference = { cons: cons$1, isReference, href, value: value$2 };
|
|
2049
2049
|
|
|
2050
|
-
const JsonPointer$
|
|
2051
|
-
const curry$
|
|
2050
|
+
const JsonPointer$3 = lib$6;
|
|
2051
|
+
const curry$h = justCurryIt$2;
|
|
2052
2052
|
const { resolveUrl: resolveUrl$2, jsonTypeOf: jsonTypeOf$1 } = common$1;
|
|
2053
2053
|
const Reference$2 = reference;
|
|
2054
2054
|
|
|
2055
2055
|
|
|
2056
|
-
const nil$
|
|
2057
|
-
const cons = (instance, id = "") => Object.freeze({ ...nil$
|
|
2056
|
+
const nil$2 = Object.freeze({ id: "", pointer: "", instance: undefined, value: undefined });
|
|
2057
|
+
const cons = (instance, id = "") => Object.freeze({ ...nil$2, id: resolveUrl$2(id, ""), instance, value: instance });
|
|
2058
|
+
|
|
2059
|
+
const get$2 = (url, instance = nil$2) => {
|
|
2060
|
+
if (!url.startsWith("#")) {
|
|
2061
|
+
throw Error(`No JSON document found at '${url.split("#")[0]}'`);
|
|
2062
|
+
}
|
|
2063
|
+
|
|
2064
|
+
return Object.freeze({ ...instance, pointer: url.substr(1) });
|
|
2065
|
+
};
|
|
2066
|
+
|
|
2058
2067
|
const uri$1 = (doc) => `${doc.id}#${encodeURI(doc.pointer)}`;
|
|
2059
2068
|
const value$1 = (doc) => Reference$2.isReference(doc.value) ? Reference$2.value(doc.value) : doc.value;
|
|
2060
2069
|
const has$1 = (key, doc) => key in value$1(doc);
|
|
2061
|
-
const typeOf$1 = curry$
|
|
2070
|
+
const typeOf$1 = curry$h((doc, type) => jsonTypeOf$1(value$1(doc), type));
|
|
2062
2071
|
|
|
2063
2072
|
const step$1 = (key, doc) => Object.freeze({
|
|
2064
2073
|
...doc,
|
|
2065
|
-
pointer: JsonPointer$
|
|
2074
|
+
pointer: JsonPointer$3.append(key, doc.pointer),
|
|
2066
2075
|
value: value$1(doc)[key]
|
|
2067
2076
|
});
|
|
2068
2077
|
|
|
2069
|
-
const entries$
|
|
2078
|
+
const entries$5 = (doc) => Object.keys(value$1(doc))
|
|
2070
2079
|
.map((key) => [key, step$1(key, doc)]);
|
|
2071
2080
|
|
|
2072
2081
|
const keys$1 = (doc) => Object.keys(value$1(doc));
|
|
2073
2082
|
|
|
2074
|
-
const map$
|
|
2083
|
+
const map$7 = curry$h((fn, doc) => value$1(doc)
|
|
2075
2084
|
.map((item, ndx, array, thisArg) => fn(step$1(ndx, doc), ndx, array, thisArg)));
|
|
2076
2085
|
|
|
2077
|
-
const
|
|
2086
|
+
const forEach = curry$h((fn, doc) => value$1(doc)
|
|
2087
|
+
.forEach((item, ndx, array, thisArg) => fn(step$1(ndx, doc), ndx, array, thisArg)));
|
|
2088
|
+
|
|
2089
|
+
const filter$2 = curry$h((fn, doc) => value$1(doc)
|
|
2078
2090
|
.map((item, ndx, array, thisArg) => step$1(ndx, doc))
|
|
2079
2091
|
.filter((item, ndx, array, thisArg) => fn(item, ndx, array, thisArg)));
|
|
2080
2092
|
|
|
2081
|
-
const reduce$
|
|
2093
|
+
const reduce$6 = curry$h((fn, acc, doc) => value$1(doc)
|
|
2082
2094
|
.reduce((acc, item, ndx) => fn(acc, step$1(ndx, doc), ndx), acc));
|
|
2083
2095
|
|
|
2084
|
-
const every$
|
|
2096
|
+
const every$2 = curry$h((fn, doc) => value$1(doc)
|
|
2085
2097
|
.every((item, ndx, array, thisArg) => fn(step$1(ndx, doc), ndx, array, thisArg)));
|
|
2086
2098
|
|
|
2087
|
-
const some$
|
|
2099
|
+
const some$2 = curry$h((fn, doc) => value$1(doc)
|
|
2088
2100
|
.some((item, ndx, array, thisArg) => fn(step$1(ndx, doc), ndx, array, thisArg)));
|
|
2089
2101
|
|
|
2090
2102
|
const length$1 = (doc) => value$1(doc).length;
|
|
2091
2103
|
|
|
2092
|
-
var instance = {
|
|
2104
|
+
var instance = {
|
|
2105
|
+
nil: nil$2, cons, get: get$2, uri: uri$1, value: value$1, has: has$1, typeOf: typeOf$1, length: length$1,
|
|
2106
|
+
step: step$1, entries: entries$5, keys: keys$1, map: map$7, forEach, filter: filter$2, reduce: reduce$6, every: every$2, some: some$2
|
|
2107
|
+
};
|
|
2093
2108
|
|
|
2094
|
-
var entries$
|
|
2109
|
+
var entries$4 = async (doc) => Object.entries(await doc);
|
|
2095
2110
|
|
|
2096
|
-
const curry$
|
|
2111
|
+
const curry$g = justCurryIt$2;
|
|
2097
2112
|
|
|
2098
2113
|
|
|
2099
|
-
var map$
|
|
2114
|
+
var map$6 = curry$g(async (fn, doc) => (await doc).map(fn));
|
|
2100
2115
|
|
|
2101
|
-
const curry$
|
|
2116
|
+
const curry$f = justCurryIt$2;
|
|
2102
2117
|
|
|
2103
2118
|
|
|
2104
|
-
var reduce$
|
|
2119
|
+
var reduce$5 = curry$f(async (fn, acc, doc) => {
|
|
2105
2120
|
return (await doc).reduce(async (acc, item) => fn(await acc, item), acc);
|
|
2106
2121
|
});
|
|
2107
2122
|
|
|
2108
|
-
const curry$
|
|
2109
|
-
const reduce$
|
|
2123
|
+
const curry$e = justCurryIt$2;
|
|
2124
|
+
const reduce$4 = reduce$5;
|
|
2110
2125
|
|
|
2111
2126
|
|
|
2112
|
-
var filter = curry$
|
|
2113
|
-
return reduce$
|
|
2127
|
+
var filter$1 = curry$e(async (fn, doc, options = {}) => {
|
|
2128
|
+
return reduce$4(async (acc, item) => {
|
|
2114
2129
|
return (await fn(item)) ? acc.concat([item]) : acc;
|
|
2115
2130
|
}, [], doc, options);
|
|
2116
2131
|
});
|
|
2117
2132
|
|
|
2118
|
-
const curry$
|
|
2119
|
-
const map$
|
|
2133
|
+
const curry$d = justCurryIt$2;
|
|
2134
|
+
const map$5 = map$6;
|
|
2120
2135
|
|
|
2121
2136
|
|
|
2122
|
-
var some = curry$
|
|
2123
|
-
const results = await map$
|
|
2137
|
+
var some$1 = curry$d(async (fn, doc) => {
|
|
2138
|
+
const results = await map$5(fn, doc);
|
|
2124
2139
|
return (await Promise.all(results))
|
|
2125
2140
|
.some((a) => a);
|
|
2126
2141
|
});
|
|
2127
2142
|
|
|
2128
|
-
const curry$
|
|
2129
|
-
const map$
|
|
2143
|
+
const curry$c = justCurryIt$2;
|
|
2144
|
+
const map$4 = map$6;
|
|
2130
2145
|
|
|
2131
2146
|
|
|
2132
|
-
var every = curry$
|
|
2133
|
-
const results = await map$
|
|
2147
|
+
var every$1 = curry$c(async (fn, doc) => {
|
|
2148
|
+
const results = await map$4(fn, doc);
|
|
2134
2149
|
return (await Promise.all(results))
|
|
2135
2150
|
.every((a) => a);
|
|
2136
2151
|
});
|
|
2137
2152
|
|
|
2138
|
-
const curry$
|
|
2153
|
+
const curry$b = justCurryIt$2;
|
|
2139
2154
|
|
|
2140
2155
|
|
|
2141
|
-
var pipeline$
|
|
2156
|
+
var pipeline$3 = curry$b((fns, doc) => {
|
|
2142
2157
|
return fns.reduce(async (acc, fn) => fn(await acc), doc);
|
|
2143
2158
|
});
|
|
2144
2159
|
|
|
2145
|
-
var all = (doc) => Promise.all(doc);
|
|
2160
|
+
var all$1 = (doc) => Promise.all(doc);
|
|
2146
2161
|
|
|
2147
|
-
const pipeline = pipeline$
|
|
2148
|
-
const entries$
|
|
2149
|
-
const reduce = reduce$
|
|
2162
|
+
const pipeline$2 = pipeline$3;
|
|
2163
|
+
const entries$3 = entries$4;
|
|
2164
|
+
const reduce$3 = reduce$5;
|
|
2150
2165
|
|
|
2151
2166
|
|
|
2152
|
-
var allValues = (doc) => {
|
|
2153
|
-
return pipeline([
|
|
2154
|
-
entries$
|
|
2155
|
-
reduce(async (acc, [propertyName, propertyValue]) => {
|
|
2167
|
+
var allValues$1 = (doc) => {
|
|
2168
|
+
return pipeline$2([
|
|
2169
|
+
entries$3,
|
|
2170
|
+
reduce$3(async (acc, [propertyName, propertyValue]) => {
|
|
2156
2171
|
acc[propertyName] = await propertyValue;
|
|
2157
2172
|
return acc;
|
|
2158
2173
|
}, {})
|
|
2159
2174
|
], doc);
|
|
2160
2175
|
};
|
|
2161
2176
|
|
|
2162
|
-
var lib$
|
|
2163
|
-
entries: entries$
|
|
2164
|
-
map: map$
|
|
2165
|
-
filter: filter,
|
|
2166
|
-
reduce: reduce$
|
|
2167
|
-
some: some,
|
|
2168
|
-
every: every,
|
|
2169
|
-
pipeline: pipeline$
|
|
2170
|
-
all: all,
|
|
2171
|
-
allValues: allValues
|
|
2177
|
+
var lib$5 = {
|
|
2178
|
+
entries: entries$4,
|
|
2179
|
+
map: map$6,
|
|
2180
|
+
filter: filter$1,
|
|
2181
|
+
reduce: reduce$5,
|
|
2182
|
+
some: some$1,
|
|
2183
|
+
every: every$1,
|
|
2184
|
+
pipeline: pipeline$3,
|
|
2185
|
+
all: all$1,
|
|
2186
|
+
allValues: allValues$1
|
|
2172
2187
|
};
|
|
2173
2188
|
|
|
2174
|
-
var
|
|
2175
|
-
|
|
2176
|
-
var contentType = {};
|
|
2177
|
-
|
|
2178
|
-
/*!
|
|
2179
|
-
* content-type
|
|
2180
|
-
* Copyright(c) 2015 Douglas Christopher Wilson
|
|
2181
|
-
* MIT Licensed
|
|
2182
|
-
*/
|
|
2183
|
-
|
|
2184
|
-
/**
|
|
2185
|
-
* RegExp to match *( ";" parameter ) in RFC 7231 sec 3.1.1.1
|
|
2186
|
-
*
|
|
2187
|
-
* parameter = token "=" ( token / quoted-string )
|
|
2188
|
-
* token = 1*tchar
|
|
2189
|
-
* tchar = "!" / "#" / "$" / "%" / "&" / "'" / "*"
|
|
2190
|
-
* / "+" / "-" / "." / "^" / "_" / "`" / "|" / "~"
|
|
2191
|
-
* / DIGIT / ALPHA
|
|
2192
|
-
* ; any VCHAR, except delimiters
|
|
2193
|
-
* quoted-string = DQUOTE *( qdtext / quoted-pair ) DQUOTE
|
|
2194
|
-
* qdtext = HTAB / SP / %x21 / %x23-5B / %x5D-7E / obs-text
|
|
2195
|
-
* obs-text = %x80-FF
|
|
2196
|
-
* quoted-pair = "\" ( HTAB / SP / VCHAR / obs-text )
|
|
2197
|
-
*/
|
|
2198
|
-
var PARAM_REGEXP = /; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g;
|
|
2199
|
-
var TEXT_REGEXP = /^[\u000b\u0020-\u007e\u0080-\u00ff]+$/;
|
|
2200
|
-
var TOKEN_REGEXP = /^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;
|
|
2201
|
-
|
|
2202
|
-
/**
|
|
2203
|
-
* RegExp to match quoted-pair in RFC 7230 sec 3.2.6
|
|
2204
|
-
*
|
|
2205
|
-
* quoted-pair = "\" ( HTAB / SP / VCHAR / obs-text )
|
|
2206
|
-
* obs-text = %x80-FF
|
|
2207
|
-
*/
|
|
2208
|
-
var QESC_REGEXP = /\\([\u000b\u0020-\u00ff])/g;
|
|
2209
|
-
|
|
2210
|
-
/**
|
|
2211
|
-
* RegExp to match chars that must be quoted-pair in RFC 7230 sec 3.2.6
|
|
2212
|
-
*/
|
|
2213
|
-
var QUOTE_REGEXP = /([\\"])/g;
|
|
2214
|
-
|
|
2215
|
-
/**
|
|
2216
|
-
* RegExp to match type in RFC 7231 sec 3.1.1.1
|
|
2217
|
-
*
|
|
2218
|
-
* media-type = type "/" subtype
|
|
2219
|
-
* type = token
|
|
2220
|
-
* subtype = token
|
|
2221
|
-
*/
|
|
2222
|
-
var TYPE_REGEXP = /^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;
|
|
2223
|
-
|
|
2224
|
-
/**
|
|
2225
|
-
* Module exports.
|
|
2226
|
-
* @public
|
|
2227
|
-
*/
|
|
2228
|
-
|
|
2229
|
-
contentType.format = format$1;
|
|
2230
|
-
contentType.parse = parse$1;
|
|
2231
|
-
|
|
2232
|
-
/**
|
|
2233
|
-
* Format object to media type.
|
|
2234
|
-
*
|
|
2235
|
-
* @param {object} obj
|
|
2236
|
-
* @return {string}
|
|
2237
|
-
* @public
|
|
2238
|
-
*/
|
|
2189
|
+
var justCurryIt$1 = curry$a;
|
|
2239
2190
|
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2191
|
+
/*
|
|
2192
|
+
function add(a, b, c) {
|
|
2193
|
+
return a + b + c;
|
|
2243
2194
|
}
|
|
2195
|
+
curry(add)(1)(2)(3); // 6
|
|
2196
|
+
curry(add)(1)(2)(2); // 5
|
|
2197
|
+
curry(add)(2)(4, 3); // 9
|
|
2244
2198
|
|
|
2245
|
-
|
|
2246
|
-
|
|
2199
|
+
function add(...args) {
|
|
2200
|
+
return args.reduce((sum, n) => sum + n, 0)
|
|
2201
|
+
}
|
|
2202
|
+
var curryAdd4 = curry(add, 4)
|
|
2203
|
+
curryAdd4(1)(2, 3)(4); // 10
|
|
2247
2204
|
|
|
2248
|
-
|
|
2249
|
-
|
|
2205
|
+
function converter(ratio, input) {
|
|
2206
|
+
return (input*ratio).toFixed(1);
|
|
2250
2207
|
}
|
|
2208
|
+
const curriedConverter = curry(converter)
|
|
2209
|
+
const milesToKm = curriedConverter(1.62);
|
|
2210
|
+
milesToKm(35); // 56.7
|
|
2211
|
+
milesToKm(10); // 16.2
|
|
2212
|
+
*/
|
|
2251
2213
|
|
|
2252
|
-
|
|
2214
|
+
function curry$a(fn, arity) {
|
|
2215
|
+
return function curried() {
|
|
2216
|
+
if (arity == null) {
|
|
2217
|
+
arity = fn.length;
|
|
2218
|
+
}
|
|
2219
|
+
var args = [].slice.call(arguments);
|
|
2220
|
+
if (args.length >= arity) {
|
|
2221
|
+
return fn.apply(this, args);
|
|
2222
|
+
} else {
|
|
2223
|
+
return function() {
|
|
2224
|
+
return curried.apply(this, args.concat([].slice.call(arguments)));
|
|
2225
|
+
};
|
|
2226
|
+
}
|
|
2227
|
+
};
|
|
2228
|
+
}
|
|
2253
2229
|
|
|
2254
|
-
|
|
2255
|
-
if (parameters && typeof parameters === 'object') {
|
|
2256
|
-
var param;
|
|
2257
|
-
var params = Object.keys(parameters).sort();
|
|
2230
|
+
const curry$9 = justCurryIt$1;
|
|
2258
2231
|
|
|
2259
|
-
for (var i = 0; i < params.length; i++) {
|
|
2260
|
-
param = params[i];
|
|
2261
2232
|
|
|
2262
|
-
|
|
2263
|
-
throw new TypeError('invalid parameter name')
|
|
2264
|
-
}
|
|
2233
|
+
const nil$1 = "";
|
|
2265
2234
|
|
|
2266
|
-
|
|
2267
|
-
|
|
2235
|
+
const compile$P = (pointer) => {
|
|
2236
|
+
if (pointer.length > 0 && pointer[0] !== "/") {
|
|
2237
|
+
throw Error("Invalid JSON Pointer");
|
|
2268
2238
|
}
|
|
2269
2239
|
|
|
2270
|
-
return
|
|
2271
|
-
}
|
|
2240
|
+
return pointer.split("/").slice(1).map(unescape);
|
|
2241
|
+
};
|
|
2272
2242
|
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
*
|
|
2276
|
-
* @param {string|object} string
|
|
2277
|
-
* @return {Object}
|
|
2278
|
-
* @public
|
|
2279
|
-
*/
|
|
2243
|
+
const get$1 = (pointer, value = undefined) => {
|
|
2244
|
+
const ptr = compile$P(pointer);
|
|
2280
2245
|
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
}
|
|
2246
|
+
const fn = (value) => ptr.reduce(([value, pointer], segment) => {
|
|
2247
|
+
return [applySegment(value, segment, pointer), append(segment, pointer)];
|
|
2248
|
+
}, [value, ""])[0];
|
|
2285
2249
|
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
? getcontenttype(string)
|
|
2289
|
-
: string;
|
|
2250
|
+
return value === undefined ? fn : fn(value);
|
|
2251
|
+
};
|
|
2290
2252
|
|
|
2291
|
-
|
|
2292
|
-
|
|
2253
|
+
const set = (pointer, subject = undefined, value = undefined) => {
|
|
2254
|
+
const ptr = compile$P(pointer);
|
|
2255
|
+
const fn = curry$9((subject, value) => _set(ptr, subject, value, nil$1));
|
|
2256
|
+
return subject === undefined ? fn : fn(subject, value);
|
|
2257
|
+
};
|
|
2258
|
+
|
|
2259
|
+
const _set = (pointer, subject, value, cursor) => {
|
|
2260
|
+
if (pointer.length === 0) {
|
|
2261
|
+
return value;
|
|
2262
|
+
} else if (pointer.length > 1) {
|
|
2263
|
+
if (Array.isArray(subject)) {
|
|
2264
|
+
const index = pointer.shift();
|
|
2265
|
+
const clonedSubject = [...subject];
|
|
2266
|
+
clonedSubject[index] = _set(pointer, applySegment(subject, index, cursor), value, append(index, cursor));
|
|
2267
|
+
return clonedSubject;
|
|
2268
|
+
} else {
|
|
2269
|
+
const segment = pointer.shift();
|
|
2270
|
+
return { ...subject, [segment]: _set(pointer, applySegment(subject, segment, cursor), value, append(segment, cursor)) };
|
|
2271
|
+
}
|
|
2272
|
+
} else if (Array.isArray(subject)) {
|
|
2273
|
+
const clonedSubject = [...subject];
|
|
2274
|
+
const segment = computeSegment(subject, pointer[0]);
|
|
2275
|
+
clonedSubject[segment] = value;
|
|
2276
|
+
return clonedSubject;
|
|
2277
|
+
} else if (typeof subject === "object" && subject !== null) {
|
|
2278
|
+
return { ...subject, [pointer[0]]: value };
|
|
2279
|
+
} else {
|
|
2280
|
+
return applySegment(subject, pointer[0], cursor);
|
|
2293
2281
|
}
|
|
2282
|
+
};
|
|
2294
2283
|
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2284
|
+
const assign = (pointer, subject = undefined, value = undefined) => {
|
|
2285
|
+
const ptr = compile$P(pointer);
|
|
2286
|
+
const fn = curry$9((subject, value) => _assign(ptr, subject, value, nil$1));
|
|
2287
|
+
return subject === undefined ? fn : fn(subject, value);
|
|
2288
|
+
};
|
|
2299
2289
|
|
|
2300
|
-
|
|
2301
|
-
|
|
2290
|
+
const _assign = (pointer, subject, value, cursor) => {
|
|
2291
|
+
if (pointer.length === 0) {
|
|
2292
|
+
return;
|
|
2293
|
+
} else if (pointer.length === 1 && !isScalar(subject)) {
|
|
2294
|
+
const segment = computeSegment(subject, pointer[0]);
|
|
2295
|
+
subject[segment] = value;
|
|
2296
|
+
} else {
|
|
2297
|
+
const segment = pointer.shift();
|
|
2298
|
+
_assign(pointer, applySegment(subject, segment, cursor), value, append(segment, cursor));
|
|
2302
2299
|
}
|
|
2300
|
+
};
|
|
2303
2301
|
|
|
2304
|
-
|
|
2302
|
+
const unset = (pointer, subject = undefined) => {
|
|
2303
|
+
const ptr = compile$P(pointer);
|
|
2304
|
+
const fn = (subject) => _unset(ptr, subject, nil$1);
|
|
2305
|
+
return subject === undefined ? fn : fn(subject);
|
|
2306
|
+
};
|
|
2307
|
+
|
|
2308
|
+
const _unset = (pointer, subject, cursor) => {
|
|
2309
|
+
if (pointer.length == 0) {
|
|
2310
|
+
return undefined;
|
|
2311
|
+
} else if (pointer.length > 1) {
|
|
2312
|
+
const segment = pointer.shift();
|
|
2313
|
+
const value = applySegment(subject, segment, cursor);
|
|
2314
|
+
return { ...subject, [segment]: _unset(pointer, value, append(segment, cursor)) };
|
|
2315
|
+
} else if (Array.isArray(subject)) {
|
|
2316
|
+
return subject.filter((_, ndx) => ndx != pointer[0]);
|
|
2317
|
+
} else if (typeof subject === "object" && subject !== null) {
|
|
2318
|
+
// eslint-disable-next-line no-unused-vars
|
|
2319
|
+
const { [pointer[0]]: _, ...result } = subject;
|
|
2320
|
+
return result;
|
|
2321
|
+
} else {
|
|
2322
|
+
return applySegment(subject, pointer[0], cursor);
|
|
2323
|
+
}
|
|
2324
|
+
};
|
|
2325
|
+
|
|
2326
|
+
const remove = (pointer, subject = undefined) => {
|
|
2327
|
+
const ptr = compile$P(pointer);
|
|
2328
|
+
const fn = (subject) => _remove(ptr, subject, nil$1);
|
|
2329
|
+
return subject === undefined ? fn : fn(subject);
|
|
2330
|
+
};
|
|
2331
|
+
|
|
2332
|
+
const _remove = (pointer, subject, cursor) => {
|
|
2333
|
+
if (pointer.length === 0) {
|
|
2334
|
+
return;
|
|
2335
|
+
} else if (pointer.length > 1) {
|
|
2336
|
+
const segment = pointer.shift();
|
|
2337
|
+
const value = applySegment(subject, segment, cursor);
|
|
2338
|
+
_remove(pointer, value, append(segment, cursor));
|
|
2339
|
+
} else if (Array.isArray(subject)) {
|
|
2340
|
+
subject.splice(pointer[0], 1);
|
|
2341
|
+
} else if (typeof subject === "object" && subject !== null) {
|
|
2342
|
+
delete subject[pointer[0]];
|
|
2343
|
+
} else {
|
|
2344
|
+
applySegment(subject, pointer[0], cursor);
|
|
2345
|
+
}
|
|
2346
|
+
};
|
|
2347
|
+
|
|
2348
|
+
const append = curry$9((segment, pointer) => pointer + "/" + escape$1(segment));
|
|
2349
|
+
|
|
2350
|
+
const escape$1 = (segment) => segment.toString().replace(/~/g, "~0").replace(/\//g, "~1");
|
|
2351
|
+
const unescape = (segment) => segment.toString().replace(/~1/g, "/").replace(/~0/g, "~");
|
|
2352
|
+
const computeSegment = (value, segment) => Array.isArray(value) && segment === "-" ? value.length : segment;
|
|
2353
|
+
|
|
2354
|
+
const applySegment = (value, segment, cursor = "") => {
|
|
2355
|
+
if (value === undefined) {
|
|
2356
|
+
throw TypeError(`Value at '${cursor}' is undefined and does not have property '${segment}'`);
|
|
2357
|
+
} else if (value === null) {
|
|
2358
|
+
throw TypeError(`Value at '${cursor}' is null and does not have property '${segment}'`);
|
|
2359
|
+
} else if (isScalar(value)) {
|
|
2360
|
+
throw TypeError(`Value at '${cursor}' is a ${typeof value} and does not have property '${segment}'`);
|
|
2361
|
+
} else {
|
|
2362
|
+
const computedSegment = computeSegment(value, segment);
|
|
2363
|
+
return value[computedSegment];
|
|
2364
|
+
}
|
|
2365
|
+
};
|
|
2366
|
+
|
|
2367
|
+
const isScalar = (value) => value === null || typeof value !== "object";
|
|
2368
|
+
|
|
2369
|
+
var lib$4 = { nil: nil$1, append, get: get$1, set, assign, unset, remove };
|
|
2370
|
+
|
|
2371
|
+
var moo$1 = {exports: {}};
|
|
2372
|
+
|
|
2373
|
+
(function (module) {
|
|
2374
|
+
(function(root, factory) {
|
|
2375
|
+
if (module.exports) {
|
|
2376
|
+
module.exports = factory();
|
|
2377
|
+
} else {
|
|
2378
|
+
root.moo = factory();
|
|
2379
|
+
}
|
|
2380
|
+
}(commonjsGlobal, function() {
|
|
2381
|
+
|
|
2382
|
+
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
2383
|
+
var toString = Object.prototype.toString;
|
|
2384
|
+
var hasSticky = typeof new RegExp().sticky === 'boolean';
|
|
2385
|
+
|
|
2386
|
+
/***************************************************************************/
|
|
2387
|
+
|
|
2388
|
+
function isRegExp(o) { return o && toString.call(o) === '[object RegExp]' }
|
|
2389
|
+
function isObject(o) { return o && typeof o === 'object' && !isRegExp(o) && !Array.isArray(o) }
|
|
2390
|
+
|
|
2391
|
+
function reEscape(s) {
|
|
2392
|
+
return s.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&')
|
|
2393
|
+
}
|
|
2394
|
+
function reGroups(s) {
|
|
2395
|
+
var re = new RegExp('|' + s);
|
|
2396
|
+
return re.exec('').length - 1
|
|
2397
|
+
}
|
|
2398
|
+
function reCapture(s) {
|
|
2399
|
+
return '(' + s + ')'
|
|
2400
|
+
}
|
|
2401
|
+
function reUnion(regexps) {
|
|
2402
|
+
if (!regexps.length) return '(?!)'
|
|
2403
|
+
var source = regexps.map(function(s) {
|
|
2404
|
+
return "(?:" + s + ")"
|
|
2405
|
+
}).join('|');
|
|
2406
|
+
return "(?:" + source + ")"
|
|
2407
|
+
}
|
|
2408
|
+
|
|
2409
|
+
function regexpOrLiteral(obj) {
|
|
2410
|
+
if (typeof obj === 'string') {
|
|
2411
|
+
return '(?:' + reEscape(obj) + ')'
|
|
2412
|
+
|
|
2413
|
+
} else if (isRegExp(obj)) {
|
|
2414
|
+
// TODO: consider /u support
|
|
2415
|
+
if (obj.ignoreCase) throw new Error('RegExp /i flag not allowed')
|
|
2416
|
+
if (obj.global) throw new Error('RegExp /g flag is implied')
|
|
2417
|
+
if (obj.sticky) throw new Error('RegExp /y flag is implied')
|
|
2418
|
+
if (obj.multiline) throw new Error('RegExp /m flag is implied')
|
|
2419
|
+
return obj.source
|
|
2420
|
+
|
|
2421
|
+
} else {
|
|
2422
|
+
throw new Error('Not a pattern: ' + obj)
|
|
2423
|
+
}
|
|
2424
|
+
}
|
|
2425
|
+
|
|
2426
|
+
function objectToRules(object) {
|
|
2427
|
+
var keys = Object.getOwnPropertyNames(object);
|
|
2428
|
+
var result = [];
|
|
2429
|
+
for (var i = 0; i < keys.length; i++) {
|
|
2430
|
+
var key = keys[i];
|
|
2431
|
+
var thing = object[key];
|
|
2432
|
+
var rules = [].concat(thing);
|
|
2433
|
+
if (key === 'include') {
|
|
2434
|
+
for (var j = 0; j < rules.length; j++) {
|
|
2435
|
+
result.push({include: rules[j]});
|
|
2436
|
+
}
|
|
2437
|
+
continue
|
|
2438
|
+
}
|
|
2439
|
+
var match = [];
|
|
2440
|
+
rules.forEach(function(rule) {
|
|
2441
|
+
if (isObject(rule)) {
|
|
2442
|
+
if (match.length) result.push(ruleOptions(key, match));
|
|
2443
|
+
result.push(ruleOptions(key, rule));
|
|
2444
|
+
match = [];
|
|
2445
|
+
} else {
|
|
2446
|
+
match.push(rule);
|
|
2447
|
+
}
|
|
2448
|
+
});
|
|
2449
|
+
if (match.length) result.push(ruleOptions(key, match));
|
|
2450
|
+
}
|
|
2451
|
+
return result
|
|
2452
|
+
}
|
|
2453
|
+
|
|
2454
|
+
function arrayToRules(array) {
|
|
2455
|
+
var result = [];
|
|
2456
|
+
for (var i = 0; i < array.length; i++) {
|
|
2457
|
+
var obj = array[i];
|
|
2458
|
+
if (obj.include) {
|
|
2459
|
+
var include = [].concat(obj.include);
|
|
2460
|
+
for (var j = 0; j < include.length; j++) {
|
|
2461
|
+
result.push({include: include[j]});
|
|
2462
|
+
}
|
|
2463
|
+
continue
|
|
2464
|
+
}
|
|
2465
|
+
if (!obj.type) {
|
|
2466
|
+
throw new Error('Rule has no type: ' + JSON.stringify(obj))
|
|
2467
|
+
}
|
|
2468
|
+
result.push(ruleOptions(obj.type, obj));
|
|
2469
|
+
}
|
|
2470
|
+
return result
|
|
2471
|
+
}
|
|
2472
|
+
|
|
2473
|
+
function ruleOptions(type, obj) {
|
|
2474
|
+
if (!isObject(obj)) {
|
|
2475
|
+
obj = { match: obj };
|
|
2476
|
+
}
|
|
2477
|
+
if (obj.include) {
|
|
2478
|
+
throw new Error('Matching rules cannot also include states')
|
|
2479
|
+
}
|
|
2480
|
+
|
|
2481
|
+
// nb. error and fallback imply lineBreaks
|
|
2482
|
+
var options = {
|
|
2483
|
+
defaultType: type,
|
|
2484
|
+
lineBreaks: !!obj.error || !!obj.fallback,
|
|
2485
|
+
pop: false,
|
|
2486
|
+
next: null,
|
|
2487
|
+
push: null,
|
|
2488
|
+
error: false,
|
|
2489
|
+
fallback: false,
|
|
2490
|
+
value: null,
|
|
2491
|
+
type: null,
|
|
2492
|
+
shouldThrow: false,
|
|
2493
|
+
};
|
|
2494
|
+
|
|
2495
|
+
// Avoid Object.assign(), so we support IE9+
|
|
2496
|
+
for (var key in obj) {
|
|
2497
|
+
if (hasOwnProperty.call(obj, key)) {
|
|
2498
|
+
options[key] = obj[key];
|
|
2499
|
+
}
|
|
2500
|
+
}
|
|
2501
|
+
|
|
2502
|
+
// type transform cannot be a string
|
|
2503
|
+
if (typeof options.type === 'string' && type !== options.type) {
|
|
2504
|
+
throw new Error("Type transform cannot be a string (type '" + options.type + "' for token '" + type + "')")
|
|
2505
|
+
}
|
|
2506
|
+
|
|
2507
|
+
// convert to array
|
|
2508
|
+
var match = options.match;
|
|
2509
|
+
options.match = Array.isArray(match) ? match : match ? [match] : [];
|
|
2510
|
+
options.match.sort(function(a, b) {
|
|
2511
|
+
return isRegExp(a) && isRegExp(b) ? 0
|
|
2512
|
+
: isRegExp(b) ? -1 : isRegExp(a) ? +1 : b.length - a.length
|
|
2513
|
+
});
|
|
2514
|
+
return options
|
|
2515
|
+
}
|
|
2516
|
+
|
|
2517
|
+
function toRules(spec) {
|
|
2518
|
+
return Array.isArray(spec) ? arrayToRules(spec) : objectToRules(spec)
|
|
2519
|
+
}
|
|
2520
|
+
|
|
2521
|
+
var defaultErrorRule = ruleOptions('error', {lineBreaks: true, shouldThrow: true});
|
|
2522
|
+
function compileRules(rules, hasStates) {
|
|
2523
|
+
var errorRule = null;
|
|
2524
|
+
var fast = Object.create(null);
|
|
2525
|
+
var fastAllowed = true;
|
|
2526
|
+
var unicodeFlag = null;
|
|
2527
|
+
var groups = [];
|
|
2528
|
+
var parts = [];
|
|
2529
|
+
|
|
2530
|
+
// If there is a fallback rule, then disable fast matching
|
|
2531
|
+
for (var i = 0; i < rules.length; i++) {
|
|
2532
|
+
if (rules[i].fallback) {
|
|
2533
|
+
fastAllowed = false;
|
|
2534
|
+
}
|
|
2535
|
+
}
|
|
2536
|
+
|
|
2537
|
+
for (var i = 0; i < rules.length; i++) {
|
|
2538
|
+
var options = rules[i];
|
|
2539
|
+
|
|
2540
|
+
if (options.include) {
|
|
2541
|
+
// all valid inclusions are removed by states() preprocessor
|
|
2542
|
+
throw new Error('Inheritance is not allowed in stateless lexers')
|
|
2543
|
+
}
|
|
2544
|
+
|
|
2545
|
+
if (options.error || options.fallback) {
|
|
2546
|
+
// errorRule can only be set once
|
|
2547
|
+
if (errorRule) {
|
|
2548
|
+
if (!options.fallback === !errorRule.fallback) {
|
|
2549
|
+
throw new Error("Multiple " + (options.fallback ? "fallback" : "error") + " rules not allowed (for token '" + options.defaultType + "')")
|
|
2550
|
+
} else {
|
|
2551
|
+
throw new Error("fallback and error are mutually exclusive (for token '" + options.defaultType + "')")
|
|
2552
|
+
}
|
|
2553
|
+
}
|
|
2554
|
+
errorRule = options;
|
|
2555
|
+
}
|
|
2556
|
+
|
|
2557
|
+
var match = options.match.slice();
|
|
2558
|
+
if (fastAllowed) {
|
|
2559
|
+
while (match.length && typeof match[0] === 'string' && match[0].length === 1) {
|
|
2560
|
+
var word = match.shift();
|
|
2561
|
+
fast[word.charCodeAt(0)] = options;
|
|
2562
|
+
}
|
|
2563
|
+
}
|
|
2564
|
+
|
|
2565
|
+
// Warn about inappropriate state-switching options
|
|
2566
|
+
if (options.pop || options.push || options.next) {
|
|
2567
|
+
if (!hasStates) {
|
|
2568
|
+
throw new Error("State-switching options are not allowed in stateless lexers (for token '" + options.defaultType + "')")
|
|
2569
|
+
}
|
|
2570
|
+
if (options.fallback) {
|
|
2571
|
+
throw new Error("State-switching options are not allowed on fallback tokens (for token '" + options.defaultType + "')")
|
|
2572
|
+
}
|
|
2573
|
+
}
|
|
2574
|
+
|
|
2575
|
+
// Only rules with a .match are included in the RegExp
|
|
2576
|
+
if (match.length === 0) {
|
|
2577
|
+
continue
|
|
2578
|
+
}
|
|
2579
|
+
fastAllowed = false;
|
|
2580
|
+
|
|
2581
|
+
groups.push(options);
|
|
2582
|
+
|
|
2583
|
+
// Check unicode flag is used everywhere or nowhere
|
|
2584
|
+
for (var j = 0; j < match.length; j++) {
|
|
2585
|
+
var obj = match[j];
|
|
2586
|
+
if (!isRegExp(obj)) {
|
|
2587
|
+
continue
|
|
2588
|
+
}
|
|
2589
|
+
|
|
2590
|
+
if (unicodeFlag === null) {
|
|
2591
|
+
unicodeFlag = obj.unicode;
|
|
2592
|
+
} else if (unicodeFlag !== obj.unicode && options.fallback === false) {
|
|
2593
|
+
throw new Error('If one rule is /u then all must be')
|
|
2594
|
+
}
|
|
2595
|
+
}
|
|
2596
|
+
|
|
2597
|
+
// convert to RegExp
|
|
2598
|
+
var pat = reUnion(match.map(regexpOrLiteral));
|
|
2599
|
+
|
|
2600
|
+
// validate
|
|
2601
|
+
var regexp = new RegExp(pat);
|
|
2602
|
+
if (regexp.test("")) {
|
|
2603
|
+
throw new Error("RegExp matches empty string: " + regexp)
|
|
2604
|
+
}
|
|
2605
|
+
var groupCount = reGroups(pat);
|
|
2606
|
+
if (groupCount > 0) {
|
|
2607
|
+
throw new Error("RegExp has capture groups: " + regexp + "\nUse (?: … ) instead")
|
|
2608
|
+
}
|
|
2609
|
+
|
|
2610
|
+
// try and detect rules matching newlines
|
|
2611
|
+
if (!options.lineBreaks && regexp.test('\n')) {
|
|
2612
|
+
throw new Error('Rule should declare lineBreaks: ' + regexp)
|
|
2613
|
+
}
|
|
2614
|
+
|
|
2615
|
+
// store regex
|
|
2616
|
+
parts.push(reCapture(pat));
|
|
2617
|
+
}
|
|
2618
|
+
|
|
2619
|
+
|
|
2620
|
+
// If there's no fallback rule, use the sticky flag so we only look for
|
|
2621
|
+
// matches at the current index.
|
|
2622
|
+
//
|
|
2623
|
+
// If we don't support the sticky flag, then fake it using an irrefutable
|
|
2624
|
+
// match (i.e. an empty pattern).
|
|
2625
|
+
var fallbackRule = errorRule && errorRule.fallback;
|
|
2626
|
+
var flags = hasSticky && !fallbackRule ? 'ym' : 'gm';
|
|
2627
|
+
var suffix = hasSticky || fallbackRule ? '' : '|';
|
|
2628
|
+
|
|
2629
|
+
if (unicodeFlag === true) flags += "u";
|
|
2630
|
+
var combined = new RegExp(reUnion(parts) + suffix, flags);
|
|
2631
|
+
return {regexp: combined, groups: groups, fast: fast, error: errorRule || defaultErrorRule}
|
|
2632
|
+
}
|
|
2633
|
+
|
|
2634
|
+
function compile(rules) {
|
|
2635
|
+
var result = compileRules(toRules(rules));
|
|
2636
|
+
return new Lexer({start: result}, 'start')
|
|
2637
|
+
}
|
|
2638
|
+
|
|
2639
|
+
function checkStateGroup(g, name, map) {
|
|
2640
|
+
var state = g && (g.push || g.next);
|
|
2641
|
+
if (state && !map[state]) {
|
|
2642
|
+
throw new Error("Missing state '" + state + "' (in token '" + g.defaultType + "' of state '" + name + "')")
|
|
2643
|
+
}
|
|
2644
|
+
if (g && g.pop && +g.pop !== 1) {
|
|
2645
|
+
throw new Error("pop must be 1 (in token '" + g.defaultType + "' of state '" + name + "')")
|
|
2646
|
+
}
|
|
2647
|
+
}
|
|
2648
|
+
function compileStates(states, start) {
|
|
2649
|
+
var all = states.$all ? toRules(states.$all) : [];
|
|
2650
|
+
delete states.$all;
|
|
2651
|
+
|
|
2652
|
+
var keys = Object.getOwnPropertyNames(states);
|
|
2653
|
+
if (!start) start = keys[0];
|
|
2654
|
+
|
|
2655
|
+
var ruleMap = Object.create(null);
|
|
2656
|
+
for (var i = 0; i < keys.length; i++) {
|
|
2657
|
+
var key = keys[i];
|
|
2658
|
+
ruleMap[key] = toRules(states[key]).concat(all);
|
|
2659
|
+
}
|
|
2660
|
+
for (var i = 0; i < keys.length; i++) {
|
|
2661
|
+
var key = keys[i];
|
|
2662
|
+
var rules = ruleMap[key];
|
|
2663
|
+
var included = Object.create(null);
|
|
2664
|
+
for (var j = 0; j < rules.length; j++) {
|
|
2665
|
+
var rule = rules[j];
|
|
2666
|
+
if (!rule.include) continue
|
|
2667
|
+
var splice = [j, 1];
|
|
2668
|
+
if (rule.include !== key && !included[rule.include]) {
|
|
2669
|
+
included[rule.include] = true;
|
|
2670
|
+
var newRules = ruleMap[rule.include];
|
|
2671
|
+
if (!newRules) {
|
|
2672
|
+
throw new Error("Cannot include nonexistent state '" + rule.include + "' (in state '" + key + "')")
|
|
2673
|
+
}
|
|
2674
|
+
for (var k = 0; k < newRules.length; k++) {
|
|
2675
|
+
var newRule = newRules[k];
|
|
2676
|
+
if (rules.indexOf(newRule) !== -1) continue
|
|
2677
|
+
splice.push(newRule);
|
|
2678
|
+
}
|
|
2679
|
+
}
|
|
2680
|
+
rules.splice.apply(rules, splice);
|
|
2681
|
+
j--;
|
|
2682
|
+
}
|
|
2683
|
+
}
|
|
2684
|
+
|
|
2685
|
+
var map = Object.create(null);
|
|
2686
|
+
for (var i = 0; i < keys.length; i++) {
|
|
2687
|
+
var key = keys[i];
|
|
2688
|
+
map[key] = compileRules(ruleMap[key], true);
|
|
2689
|
+
}
|
|
2690
|
+
|
|
2691
|
+
for (var i = 0; i < keys.length; i++) {
|
|
2692
|
+
var name = keys[i];
|
|
2693
|
+
var state = map[name];
|
|
2694
|
+
var groups = state.groups;
|
|
2695
|
+
for (var j = 0; j < groups.length; j++) {
|
|
2696
|
+
checkStateGroup(groups[j], name, map);
|
|
2697
|
+
}
|
|
2698
|
+
var fastKeys = Object.getOwnPropertyNames(state.fast);
|
|
2699
|
+
for (var j = 0; j < fastKeys.length; j++) {
|
|
2700
|
+
checkStateGroup(state.fast[fastKeys[j]], name, map);
|
|
2701
|
+
}
|
|
2702
|
+
}
|
|
2703
|
+
|
|
2704
|
+
return new Lexer(map, start)
|
|
2705
|
+
}
|
|
2706
|
+
|
|
2707
|
+
function keywordTransform(map) {
|
|
2708
|
+
var reverseMap = Object.create(null);
|
|
2709
|
+
var byLength = Object.create(null);
|
|
2710
|
+
var types = Object.getOwnPropertyNames(map);
|
|
2711
|
+
for (var i = 0; i < types.length; i++) {
|
|
2712
|
+
var tokenType = types[i];
|
|
2713
|
+
var item = map[tokenType];
|
|
2714
|
+
var keywordList = Array.isArray(item) ? item : [item];
|
|
2715
|
+
keywordList.forEach(function(keyword) {
|
|
2716
|
+
(byLength[keyword.length] = byLength[keyword.length] || []).push(keyword);
|
|
2717
|
+
if (typeof keyword !== 'string') {
|
|
2718
|
+
throw new Error("keyword must be string (in keyword '" + tokenType + "')")
|
|
2719
|
+
}
|
|
2720
|
+
reverseMap[keyword] = tokenType;
|
|
2721
|
+
});
|
|
2722
|
+
}
|
|
2723
|
+
|
|
2724
|
+
// fast string lookup
|
|
2725
|
+
// https://jsperf.com/string-lookups
|
|
2726
|
+
function str(x) { return JSON.stringify(x) }
|
|
2727
|
+
var source = '';
|
|
2728
|
+
source += 'switch (value.length) {\n';
|
|
2729
|
+
for (var length in byLength) {
|
|
2730
|
+
var keywords = byLength[length];
|
|
2731
|
+
source += 'case ' + length + ':\n';
|
|
2732
|
+
source += 'switch (value) {\n';
|
|
2733
|
+
keywords.forEach(function(keyword) {
|
|
2734
|
+
var tokenType = reverseMap[keyword];
|
|
2735
|
+
source += 'case ' + str(keyword) + ': return ' + str(tokenType) + '\n';
|
|
2736
|
+
});
|
|
2737
|
+
source += '}\n';
|
|
2738
|
+
}
|
|
2739
|
+
source += '}\n';
|
|
2740
|
+
return Function('value', source) // type
|
|
2741
|
+
}
|
|
2742
|
+
|
|
2743
|
+
/***************************************************************************/
|
|
2744
|
+
|
|
2745
|
+
var Lexer = function(states, state) {
|
|
2746
|
+
this.startState = state;
|
|
2747
|
+
this.states = states;
|
|
2748
|
+
this.buffer = '';
|
|
2749
|
+
this.stack = [];
|
|
2750
|
+
this.reset();
|
|
2751
|
+
};
|
|
2752
|
+
|
|
2753
|
+
Lexer.prototype.reset = function(data, info) {
|
|
2754
|
+
this.buffer = data || '';
|
|
2755
|
+
this.index = 0;
|
|
2756
|
+
this.line = info ? info.line : 1;
|
|
2757
|
+
this.col = info ? info.col : 1;
|
|
2758
|
+
this.queuedToken = info ? info.queuedToken : null;
|
|
2759
|
+
this.queuedThrow = info ? info.queuedThrow : null;
|
|
2760
|
+
this.setState(info ? info.state : this.startState);
|
|
2761
|
+
this.stack = info && info.stack ? info.stack.slice() : [];
|
|
2762
|
+
return this
|
|
2763
|
+
};
|
|
2764
|
+
|
|
2765
|
+
Lexer.prototype.save = function() {
|
|
2766
|
+
return {
|
|
2767
|
+
line: this.line,
|
|
2768
|
+
col: this.col,
|
|
2769
|
+
state: this.state,
|
|
2770
|
+
stack: this.stack.slice(),
|
|
2771
|
+
queuedToken: this.queuedToken,
|
|
2772
|
+
queuedThrow: this.queuedThrow,
|
|
2773
|
+
}
|
|
2774
|
+
};
|
|
2775
|
+
|
|
2776
|
+
Lexer.prototype.setState = function(state) {
|
|
2777
|
+
if (!state || this.state === state) return
|
|
2778
|
+
this.state = state;
|
|
2779
|
+
var info = this.states[state];
|
|
2780
|
+
this.groups = info.groups;
|
|
2781
|
+
this.error = info.error;
|
|
2782
|
+
this.re = info.regexp;
|
|
2783
|
+
this.fast = info.fast;
|
|
2784
|
+
};
|
|
2785
|
+
|
|
2786
|
+
Lexer.prototype.popState = function() {
|
|
2787
|
+
this.setState(this.stack.pop());
|
|
2788
|
+
};
|
|
2789
|
+
|
|
2790
|
+
Lexer.prototype.pushState = function(state) {
|
|
2791
|
+
this.stack.push(this.state);
|
|
2792
|
+
this.setState(state);
|
|
2793
|
+
};
|
|
2794
|
+
|
|
2795
|
+
var eat = hasSticky ? function(re, buffer) { // assume re is /y
|
|
2796
|
+
return re.exec(buffer)
|
|
2797
|
+
} : function(re, buffer) { // assume re is /g
|
|
2798
|
+
var match = re.exec(buffer);
|
|
2799
|
+
// will always match, since we used the |(?:) trick
|
|
2800
|
+
if (match[0].length === 0) {
|
|
2801
|
+
return null
|
|
2802
|
+
}
|
|
2803
|
+
return match
|
|
2804
|
+
};
|
|
2805
|
+
|
|
2806
|
+
Lexer.prototype._getGroup = function(match) {
|
|
2807
|
+
var groupCount = this.groups.length;
|
|
2808
|
+
for (var i = 0; i < groupCount; i++) {
|
|
2809
|
+
if (match[i + 1] !== undefined) {
|
|
2810
|
+
return this.groups[i]
|
|
2811
|
+
}
|
|
2812
|
+
}
|
|
2813
|
+
throw new Error('Cannot find token type for matched text')
|
|
2814
|
+
};
|
|
2815
|
+
|
|
2816
|
+
function tokenToString() {
|
|
2817
|
+
return this.value
|
|
2818
|
+
}
|
|
2819
|
+
|
|
2820
|
+
Lexer.prototype.next = function() {
|
|
2821
|
+
var index = this.index;
|
|
2822
|
+
|
|
2823
|
+
// If a fallback token matched, we don't need to re-run the RegExp
|
|
2824
|
+
if (this.queuedGroup) {
|
|
2825
|
+
var token = this._token(this.queuedGroup, this.queuedText, index);
|
|
2826
|
+
this.queuedGroup = null;
|
|
2827
|
+
this.queuedText = "";
|
|
2828
|
+
return token
|
|
2829
|
+
}
|
|
2830
|
+
|
|
2831
|
+
var buffer = this.buffer;
|
|
2832
|
+
if (index === buffer.length) {
|
|
2833
|
+
return // EOF
|
|
2834
|
+
}
|
|
2835
|
+
|
|
2836
|
+
// Fast matching for single characters
|
|
2837
|
+
var group = this.fast[buffer.charCodeAt(index)];
|
|
2838
|
+
if (group) {
|
|
2839
|
+
return this._token(group, buffer.charAt(index), index)
|
|
2840
|
+
}
|
|
2841
|
+
|
|
2842
|
+
// Execute RegExp
|
|
2843
|
+
var re = this.re;
|
|
2844
|
+
re.lastIndex = index;
|
|
2845
|
+
var match = eat(re, buffer);
|
|
2846
|
+
|
|
2847
|
+
// Error tokens match the remaining buffer
|
|
2848
|
+
var error = this.error;
|
|
2849
|
+
if (match == null) {
|
|
2850
|
+
return this._token(error, buffer.slice(index, buffer.length), index)
|
|
2851
|
+
}
|
|
2852
|
+
|
|
2853
|
+
var group = this._getGroup(match);
|
|
2854
|
+
var text = match[0];
|
|
2855
|
+
|
|
2856
|
+
if (error.fallback && match.index !== index) {
|
|
2857
|
+
this.queuedGroup = group;
|
|
2858
|
+
this.queuedText = text;
|
|
2859
|
+
|
|
2860
|
+
// Fallback tokens contain the unmatched portion of the buffer
|
|
2861
|
+
return this._token(error, buffer.slice(index, match.index), index)
|
|
2862
|
+
}
|
|
2863
|
+
|
|
2864
|
+
return this._token(group, text, index)
|
|
2865
|
+
};
|
|
2866
|
+
|
|
2867
|
+
Lexer.prototype._token = function(group, text, offset) {
|
|
2868
|
+
// count line breaks
|
|
2869
|
+
var lineBreaks = 0;
|
|
2870
|
+
if (group.lineBreaks) {
|
|
2871
|
+
var matchNL = /\n/g;
|
|
2872
|
+
var nl = 1;
|
|
2873
|
+
if (text === '\n') {
|
|
2874
|
+
lineBreaks = 1;
|
|
2875
|
+
} else {
|
|
2876
|
+
while (matchNL.exec(text)) { lineBreaks++; nl = matchNL.lastIndex; }
|
|
2877
|
+
}
|
|
2878
|
+
}
|
|
2879
|
+
|
|
2880
|
+
var token = {
|
|
2881
|
+
type: (typeof group.type === 'function' && group.type(text)) || group.defaultType,
|
|
2882
|
+
value: typeof group.value === 'function' ? group.value(text) : text,
|
|
2883
|
+
text: text,
|
|
2884
|
+
toString: tokenToString,
|
|
2885
|
+
offset: offset,
|
|
2886
|
+
lineBreaks: lineBreaks,
|
|
2887
|
+
line: this.line,
|
|
2888
|
+
col: this.col,
|
|
2889
|
+
};
|
|
2890
|
+
// nb. adding more props to token object will make V8 sad!
|
|
2891
|
+
|
|
2892
|
+
var size = text.length;
|
|
2893
|
+
this.index += size;
|
|
2894
|
+
this.line += lineBreaks;
|
|
2895
|
+
if (lineBreaks !== 0) {
|
|
2896
|
+
this.col = size - nl + 1;
|
|
2897
|
+
} else {
|
|
2898
|
+
this.col += size;
|
|
2899
|
+
}
|
|
2900
|
+
|
|
2901
|
+
// throw, if no rule with {error: true}
|
|
2902
|
+
if (group.shouldThrow) {
|
|
2903
|
+
throw new Error(this.formatError(token, "invalid syntax"))
|
|
2904
|
+
}
|
|
2905
|
+
|
|
2906
|
+
if (group.pop) this.popState();
|
|
2907
|
+
else if (group.push) this.pushState(group.push);
|
|
2908
|
+
else if (group.next) this.setState(group.next);
|
|
2909
|
+
|
|
2910
|
+
return token
|
|
2911
|
+
};
|
|
2912
|
+
|
|
2913
|
+
if (typeof Symbol !== 'undefined' && Symbol.iterator) {
|
|
2914
|
+
var LexerIterator = function(lexer) {
|
|
2915
|
+
this.lexer = lexer;
|
|
2916
|
+
};
|
|
2917
|
+
|
|
2918
|
+
LexerIterator.prototype.next = function() {
|
|
2919
|
+
var token = this.lexer.next();
|
|
2920
|
+
return {value: token, done: !token}
|
|
2921
|
+
};
|
|
2922
|
+
|
|
2923
|
+
LexerIterator.prototype[Symbol.iterator] = function() {
|
|
2924
|
+
return this
|
|
2925
|
+
};
|
|
2926
|
+
|
|
2927
|
+
Lexer.prototype[Symbol.iterator] = function() {
|
|
2928
|
+
return new LexerIterator(this)
|
|
2929
|
+
};
|
|
2930
|
+
}
|
|
2931
|
+
|
|
2932
|
+
Lexer.prototype.formatError = function(token, message) {
|
|
2933
|
+
if (token == null) {
|
|
2934
|
+
// An undefined token indicates EOF
|
|
2935
|
+
var text = this.buffer.slice(this.index);
|
|
2936
|
+
var token = {
|
|
2937
|
+
text: text,
|
|
2938
|
+
offset: this.index,
|
|
2939
|
+
lineBreaks: text.indexOf('\n') === -1 ? 0 : 1,
|
|
2940
|
+
line: this.line,
|
|
2941
|
+
col: this.col,
|
|
2942
|
+
};
|
|
2943
|
+
}
|
|
2944
|
+
var start = Math.max(0, token.offset - token.col + 1);
|
|
2945
|
+
var eol = token.lineBreaks ? token.text.indexOf('\n') : token.text.length;
|
|
2946
|
+
var firstLine = this.buffer.substring(start, token.offset + eol);
|
|
2947
|
+
message += " at line " + token.line + " col " + token.col + ":\n\n";
|
|
2948
|
+
message += " " + firstLine + "\n";
|
|
2949
|
+
message += " " + Array(token.col).join(" ") + "^";
|
|
2950
|
+
return message
|
|
2951
|
+
};
|
|
2952
|
+
|
|
2953
|
+
Lexer.prototype.clone = function() {
|
|
2954
|
+
return new Lexer(this.states, this.state)
|
|
2955
|
+
};
|
|
2956
|
+
|
|
2957
|
+
Lexer.prototype.has = function(tokenType) {
|
|
2958
|
+
return true
|
|
2959
|
+
};
|
|
2960
|
+
|
|
2961
|
+
|
|
2962
|
+
return {
|
|
2963
|
+
compile: compile,
|
|
2964
|
+
states: compileStates,
|
|
2965
|
+
error: Object.freeze({error: true}),
|
|
2966
|
+
fallback: Object.freeze({fallback: true}),
|
|
2967
|
+
keywords: keywordTransform,
|
|
2968
|
+
}
|
|
2969
|
+
|
|
2970
|
+
}));
|
|
2971
|
+
} (moo$1));
|
|
2972
|
+
|
|
2973
|
+
const moo = moo$1.exports;
|
|
2974
|
+
|
|
2975
|
+
|
|
2976
|
+
const digit = `[0-9]`;
|
|
2977
|
+
const digit19 = `[1-9]`;
|
|
2978
|
+
const hexdig = `[0-9a-fA-F]`;
|
|
2979
|
+
|
|
2980
|
+
// String
|
|
2981
|
+
const unescaped = `[\\x20-\\x21\\x23-\\x5b\\x5d-\\u{10ffff}]`;
|
|
2982
|
+
const escape = `\\\\`;
|
|
2983
|
+
const escaped = `${escape}(?:["\\/\\\\brfnt]|u${hexdig}{4})`;
|
|
2984
|
+
const char = `(?:${unescaped}|${escaped})`;
|
|
2985
|
+
const string = `"${char}*"`;
|
|
2986
|
+
|
|
2987
|
+
// Number
|
|
2988
|
+
const int = `(?:0|${digit19}${digit}*)`;
|
|
2989
|
+
const frac = `\\.${digit}+`;
|
|
2990
|
+
const e = `[eE]`;
|
|
2991
|
+
const exp = `${e}[-+]?${digit}+`;
|
|
2992
|
+
const number = `-?${int}(?:${frac})?(?:${exp})?`;
|
|
2993
|
+
|
|
2994
|
+
// Whitespace
|
|
2995
|
+
const whitespace = `(?:(?:\\r?\\n)|[ \\t])+`;
|
|
2996
|
+
|
|
2997
|
+
var lexer = (json) => {
|
|
2998
|
+
const lexer = moo.states({
|
|
2999
|
+
main: {
|
|
3000
|
+
WS: { match: new RegExp(whitespace, "u"), lineBreaks: true },
|
|
3001
|
+
true: { match: "true", value: () => true },
|
|
3002
|
+
false: { match: "false", value: () => false },
|
|
3003
|
+
null: { match: "null", value: () => null },
|
|
3004
|
+
number: { match: new RegExp(number, "u"), value: parseFloat },
|
|
3005
|
+
string: { match: new RegExp(string, "u"), value: JSON.parse },
|
|
3006
|
+
"{": "{",
|
|
3007
|
+
"}": "}",
|
|
3008
|
+
"[": "[",
|
|
3009
|
+
"]": "]",
|
|
3010
|
+
":": ":",
|
|
3011
|
+
",": ",",
|
|
3012
|
+
error: moo.error
|
|
3013
|
+
}
|
|
3014
|
+
});
|
|
3015
|
+
lexer.reset(json);
|
|
3016
|
+
|
|
3017
|
+
const _next = () => {
|
|
3018
|
+
let token;
|
|
3019
|
+
do {
|
|
3020
|
+
token = lexer.next();
|
|
3021
|
+
if (token?.type === "error") {
|
|
3022
|
+
throw SyntaxError(lexer.formatError(token, "Unrecognized token"));
|
|
3023
|
+
}
|
|
3024
|
+
} while (token?.type === "WS");
|
|
3025
|
+
|
|
3026
|
+
return token;
|
|
3027
|
+
};
|
|
3028
|
+
|
|
3029
|
+
let previous;
|
|
3030
|
+
let nextToken = _next();
|
|
3031
|
+
|
|
3032
|
+
const next = (expectedType = undefined) => {
|
|
3033
|
+
previous = nextToken;
|
|
3034
|
+
nextToken = _next();
|
|
3035
|
+
if (expectedType && previous?.type !== expectedType) {
|
|
3036
|
+
throw SyntaxError(lexer.formatError(previous, `Expected a '${expectedType}'`));
|
|
3037
|
+
}
|
|
3038
|
+
return previous;
|
|
3039
|
+
};
|
|
3040
|
+
|
|
3041
|
+
const peek = () => nextToken;
|
|
3042
|
+
|
|
3043
|
+
const defaultErrorToken = { offset: 0, line: 1, col: 0, text: "" };
|
|
3044
|
+
const syntaxError = (message) => {
|
|
3045
|
+
const referenceToken = previous || defaultErrorToken;
|
|
3046
|
+
const errorToken = {
|
|
3047
|
+
...referenceToken,
|
|
3048
|
+
offset: referenceToken.offset + referenceToken.text.length,
|
|
3049
|
+
col: referenceToken.col + referenceToken.text.length
|
|
3050
|
+
};
|
|
3051
|
+
throw new SyntaxError(lexer.formatError(errorToken, message));
|
|
3052
|
+
};
|
|
3053
|
+
|
|
3054
|
+
return { next, peek, syntaxError };
|
|
3055
|
+
};
|
|
3056
|
+
|
|
3057
|
+
const JsonPointer$2 = lib$4;
|
|
3058
|
+
const jsonLexer = lexer;
|
|
3059
|
+
|
|
3060
|
+
|
|
3061
|
+
const defaultReviver = (key, value) => value;
|
|
3062
|
+
const parse$3 = (json, reviver = defaultReviver) => {
|
|
3063
|
+
const lexer = jsonLexer(json);
|
|
3064
|
+
const value = parseValue(lexer, "", JsonPointer$2.nil, reviver);
|
|
3065
|
+
|
|
3066
|
+
const token = lexer.peek();
|
|
3067
|
+
if (token) {
|
|
3068
|
+
lexer.syntaxError("A value has been parsed, but more tokens were found");
|
|
3069
|
+
}
|
|
3070
|
+
return value;
|
|
3071
|
+
};
|
|
3072
|
+
|
|
3073
|
+
const parseValue = (lexer, key, pointer, reviver) => {
|
|
3074
|
+
let value;
|
|
3075
|
+
const token = lexer.next();
|
|
3076
|
+
switch (token?.type) {
|
|
3077
|
+
case "true":
|
|
3078
|
+
case "false":
|
|
3079
|
+
case "null":
|
|
3080
|
+
case "number":
|
|
3081
|
+
case "string":
|
|
3082
|
+
value = token.value;
|
|
3083
|
+
break;
|
|
3084
|
+
case "{":
|
|
3085
|
+
value = parseObject(lexer, key, pointer, reviver);
|
|
3086
|
+
break;
|
|
3087
|
+
case "[":
|
|
3088
|
+
value = parseArray(lexer, key, pointer, reviver);
|
|
3089
|
+
break;
|
|
3090
|
+
default:
|
|
3091
|
+
lexer.syntaxError("Expected a JSON value");
|
|
3092
|
+
}
|
|
3093
|
+
|
|
3094
|
+
return reviver(key, value, pointer);
|
|
3095
|
+
};
|
|
3096
|
+
|
|
3097
|
+
const parseObject = (lexer, key, pointer, reviver) => {
|
|
3098
|
+
const value = {};
|
|
3099
|
+
|
|
3100
|
+
if (lexer.peek()?.type !== "}") {
|
|
3101
|
+
parseProperties(lexer, key, pointer, reviver, value);
|
|
3102
|
+
}
|
|
3103
|
+
|
|
3104
|
+
lexer.next("}");
|
|
3105
|
+
|
|
3106
|
+
return value;
|
|
3107
|
+
};
|
|
3108
|
+
|
|
3109
|
+
const parseProperties = (lexer, key, pointer, reviver, value) => {
|
|
3110
|
+
const propertyName = lexer.next("string").value;
|
|
3111
|
+
lexer.next(":");
|
|
3112
|
+
if (!isValueToken(lexer.peek())) {
|
|
3113
|
+
lexer.syntaxError("Expected a JSON value");
|
|
3114
|
+
}
|
|
3115
|
+
value[propertyName] = parseValue(lexer, propertyName, JsonPointer$2.append(propertyName, pointer), reviver);
|
|
3116
|
+
|
|
3117
|
+
if (lexer.peek()?.type === ",") {
|
|
3118
|
+
lexer.next(); // burn comma
|
|
3119
|
+
parseProperties(lexer, propertyName, pointer, reviver, value);
|
|
3120
|
+
} else if (isValueToken(lexer.peek())) {
|
|
3121
|
+
lexer.next(",");
|
|
3122
|
+
}
|
|
3123
|
+
};
|
|
3124
|
+
|
|
3125
|
+
const parseArray = (lexer, key, pointer, reviver) => {
|
|
3126
|
+
const value = [];
|
|
3127
|
+
|
|
3128
|
+
if (lexer.peek()?.type !== "]") {
|
|
3129
|
+
parseItems(lexer, 0, pointer, reviver, value);
|
|
3130
|
+
}
|
|
3131
|
+
|
|
3132
|
+
lexer.next("]");
|
|
3133
|
+
|
|
3134
|
+
return value;
|
|
3135
|
+
};
|
|
3136
|
+
|
|
3137
|
+
const parseItems = (lexer, key, pointer, reviver, value) => {
|
|
3138
|
+
if (!isValueToken(lexer.peek())) {
|
|
3139
|
+
lexer.syntaxError("Expected a JSON value");
|
|
3140
|
+
}
|
|
3141
|
+
value[key] = parseValue(lexer, key, JsonPointer$2.append(key, pointer), reviver);
|
|
3142
|
+
if (lexer.peek()?.type === ",") {
|
|
3143
|
+
lexer.next(); // burn comma
|
|
3144
|
+
parseItems(lexer, key + 1, pointer, reviver, value);
|
|
3145
|
+
} else if (isValueToken(lexer.peek())) {
|
|
3146
|
+
lexer.next(",");
|
|
3147
|
+
}
|
|
3148
|
+
};
|
|
3149
|
+
|
|
3150
|
+
const valueType = new Set(["string", "number", "true", "false", "null", "[", "{"]);
|
|
3151
|
+
const isValueToken = (token) => valueType.has(token?.type);
|
|
3152
|
+
|
|
3153
|
+
var parse_1 = parse$3;
|
|
3154
|
+
|
|
3155
|
+
const JsonPointer$1 = lib$4;
|
|
3156
|
+
|
|
3157
|
+
|
|
3158
|
+
const defaultReplacer = (key, value) => value;
|
|
3159
|
+
const stringify$2 = (value, replacer = defaultReplacer, space = "") => {
|
|
3160
|
+
return stringifyValue(value, replacer, space, "", JsonPointer$1.nil, 1);
|
|
3161
|
+
};
|
|
3162
|
+
|
|
3163
|
+
const stringifyValue = (value, replacer, space, key, pointer, depth) => {
|
|
3164
|
+
value = replacer(key, value, pointer);
|
|
3165
|
+
let result;
|
|
3166
|
+
if (Array.isArray(value)) {
|
|
3167
|
+
result = stringifyArray(value, replacer, space, pointer, depth);
|
|
3168
|
+
} else if (typeof value === "object" && value !== null) {
|
|
3169
|
+
result = stringifyObject(value, replacer, space, pointer, depth);
|
|
3170
|
+
} else {
|
|
3171
|
+
result = JSON.stringify(value);
|
|
3172
|
+
}
|
|
3173
|
+
|
|
3174
|
+
return result;
|
|
3175
|
+
};
|
|
3176
|
+
|
|
3177
|
+
const stringifyArray = (value, replacer, space, pointer, depth) => {
|
|
3178
|
+
if (value.length === 0) {
|
|
3179
|
+
space = "";
|
|
3180
|
+
}
|
|
3181
|
+
const padding = space ? `\n${space.repeat(depth - 1)}` : "";
|
|
3182
|
+
return "[" + padding + space + value
|
|
3183
|
+
.map((item, index) => {
|
|
3184
|
+
const indexPointer = JsonPointer$1.append(index, pointer);
|
|
3185
|
+
return stringifyValue(item, replacer, space, index, indexPointer, depth + 1);
|
|
3186
|
+
})
|
|
3187
|
+
.join(`,${padding}${space}`) + padding + "]";
|
|
3188
|
+
};
|
|
3189
|
+
|
|
3190
|
+
const stringifyObject = (value, replacer, space, pointer, depth) => {
|
|
3191
|
+
if (Object.keys(value).length === 0) {
|
|
3192
|
+
space = "";
|
|
3193
|
+
}
|
|
3194
|
+
const padding = space ? `\n${space.repeat(depth - 1)}` : "";
|
|
3195
|
+
const spacing = space ? " " : "";
|
|
3196
|
+
return "{" + padding + space + Object.entries(value)
|
|
3197
|
+
.map(([key, value]) => {
|
|
3198
|
+
const keyPointer = JsonPointer$1.append(key, pointer);
|
|
3199
|
+
return JSON.stringify(key) + ":" + spacing + stringifyValue(value, replacer, space, key, keyPointer, depth + 1);
|
|
3200
|
+
})
|
|
3201
|
+
.join(`,${padding}${space}`) + padding + "}";
|
|
3202
|
+
};
|
|
3203
|
+
|
|
3204
|
+
var stringify_1 = stringify$2;
|
|
3205
|
+
|
|
3206
|
+
const parse$2 = parse_1;
|
|
3207
|
+
const stringify$1 = stringify_1;
|
|
3208
|
+
|
|
3209
|
+
|
|
3210
|
+
var lib$3 = { parse: parse$2, stringify: stringify$1 };
|
|
3211
|
+
|
|
3212
|
+
var fetch_browser = fetch;
|
|
3213
|
+
|
|
3214
|
+
var contentType = {};
|
|
3215
|
+
|
|
3216
|
+
/*!
|
|
3217
|
+
* content-type
|
|
3218
|
+
* Copyright(c) 2015 Douglas Christopher Wilson
|
|
3219
|
+
* MIT Licensed
|
|
3220
|
+
*/
|
|
3221
|
+
|
|
3222
|
+
/**
|
|
3223
|
+
* RegExp to match *( ";" parameter ) in RFC 7231 sec 3.1.1.1
|
|
3224
|
+
*
|
|
3225
|
+
* parameter = token "=" ( token / quoted-string )
|
|
3226
|
+
* token = 1*tchar
|
|
3227
|
+
* tchar = "!" / "#" / "$" / "%" / "&" / "'" / "*"
|
|
3228
|
+
* / "+" / "-" / "." / "^" / "_" / "`" / "|" / "~"
|
|
3229
|
+
* / DIGIT / ALPHA
|
|
3230
|
+
* ; any VCHAR, except delimiters
|
|
3231
|
+
* quoted-string = DQUOTE *( qdtext / quoted-pair ) DQUOTE
|
|
3232
|
+
* qdtext = HTAB / SP / %x21 / %x23-5B / %x5D-7E / obs-text
|
|
3233
|
+
* obs-text = %x80-FF
|
|
3234
|
+
* quoted-pair = "\" ( HTAB / SP / VCHAR / obs-text )
|
|
3235
|
+
*/
|
|
3236
|
+
var PARAM_REGEXP = /; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g;
|
|
3237
|
+
var TEXT_REGEXP = /^[\u000b\u0020-\u007e\u0080-\u00ff]+$/;
|
|
3238
|
+
var TOKEN_REGEXP = /^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;
|
|
3239
|
+
|
|
3240
|
+
/**
|
|
3241
|
+
* RegExp to match quoted-pair in RFC 7230 sec 3.2.6
|
|
3242
|
+
*
|
|
3243
|
+
* quoted-pair = "\" ( HTAB / SP / VCHAR / obs-text )
|
|
3244
|
+
* obs-text = %x80-FF
|
|
3245
|
+
*/
|
|
3246
|
+
var QESC_REGEXP = /\\([\u000b\u0020-\u00ff])/g;
|
|
3247
|
+
|
|
3248
|
+
/**
|
|
3249
|
+
* RegExp to match chars that must be quoted-pair in RFC 7230 sec 3.2.6
|
|
3250
|
+
*/
|
|
3251
|
+
var QUOTE_REGEXP = /([\\"])/g;
|
|
3252
|
+
|
|
3253
|
+
/**
|
|
3254
|
+
* RegExp to match type in RFC 7231 sec 3.1.1.1
|
|
3255
|
+
*
|
|
3256
|
+
* media-type = type "/" subtype
|
|
3257
|
+
* type = token
|
|
3258
|
+
* subtype = token
|
|
3259
|
+
*/
|
|
3260
|
+
var TYPE_REGEXP = /^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;
|
|
3261
|
+
|
|
3262
|
+
/**
|
|
3263
|
+
* Module exports.
|
|
3264
|
+
* @public
|
|
3265
|
+
*/
|
|
3266
|
+
|
|
3267
|
+
contentType.format = format$1;
|
|
3268
|
+
contentType.parse = parse$1;
|
|
3269
|
+
|
|
3270
|
+
/**
|
|
3271
|
+
* Format object to media type.
|
|
3272
|
+
*
|
|
3273
|
+
* @param {object} obj
|
|
3274
|
+
* @return {string}
|
|
3275
|
+
* @public
|
|
3276
|
+
*/
|
|
3277
|
+
|
|
3278
|
+
function format$1 (obj) {
|
|
3279
|
+
if (!obj || typeof obj !== 'object') {
|
|
3280
|
+
throw new TypeError('argument obj is required')
|
|
3281
|
+
}
|
|
3282
|
+
|
|
3283
|
+
var parameters = obj.parameters;
|
|
3284
|
+
var type = obj.type;
|
|
3285
|
+
|
|
3286
|
+
if (!type || !TYPE_REGEXP.test(type)) {
|
|
3287
|
+
throw new TypeError('invalid type')
|
|
3288
|
+
}
|
|
3289
|
+
|
|
3290
|
+
var string = type;
|
|
3291
|
+
|
|
3292
|
+
// append parameters
|
|
3293
|
+
if (parameters && typeof parameters === 'object') {
|
|
3294
|
+
var param;
|
|
3295
|
+
var params = Object.keys(parameters).sort();
|
|
3296
|
+
|
|
3297
|
+
for (var i = 0; i < params.length; i++) {
|
|
3298
|
+
param = params[i];
|
|
3299
|
+
|
|
3300
|
+
if (!TOKEN_REGEXP.test(param)) {
|
|
3301
|
+
throw new TypeError('invalid parameter name')
|
|
3302
|
+
}
|
|
3303
|
+
|
|
3304
|
+
string += '; ' + param + '=' + qstring(parameters[param]);
|
|
3305
|
+
}
|
|
3306
|
+
}
|
|
3307
|
+
|
|
3308
|
+
return string
|
|
3309
|
+
}
|
|
3310
|
+
|
|
3311
|
+
/**
|
|
3312
|
+
* Parse media type to object.
|
|
3313
|
+
*
|
|
3314
|
+
* @param {string|object} string
|
|
3315
|
+
* @return {Object}
|
|
3316
|
+
* @public
|
|
3317
|
+
*/
|
|
3318
|
+
|
|
3319
|
+
function parse$1 (string) {
|
|
3320
|
+
if (!string) {
|
|
3321
|
+
throw new TypeError('argument string is required')
|
|
3322
|
+
}
|
|
3323
|
+
|
|
3324
|
+
// support req/res-like objects as argument
|
|
3325
|
+
var header = typeof string === 'object'
|
|
3326
|
+
? getcontenttype(string)
|
|
3327
|
+
: string;
|
|
3328
|
+
|
|
3329
|
+
if (typeof header !== 'string') {
|
|
3330
|
+
throw new TypeError('argument string is required to be a string')
|
|
3331
|
+
}
|
|
3332
|
+
|
|
3333
|
+
var index = header.indexOf(';');
|
|
3334
|
+
var type = index !== -1
|
|
3335
|
+
? header.substr(0, index).trim()
|
|
3336
|
+
: header.trim();
|
|
3337
|
+
|
|
3338
|
+
if (!TYPE_REGEXP.test(type)) {
|
|
3339
|
+
throw new TypeError('invalid media type')
|
|
3340
|
+
}
|
|
3341
|
+
|
|
3342
|
+
var obj = new ContentType(type.toLowerCase());
|
|
2305
3343
|
|
|
2306
3344
|
// parse parameters
|
|
2307
3345
|
if (index !== -1) {
|
|
@@ -2406,11 +3444,11 @@ var JsonSchema = (function (exports) {
|
|
|
2406
3444
|
};
|
|
2407
3445
|
|
|
2408
3446
|
const parse = (response) => {
|
|
2409
|
-
const contentType = contentTypeParser.parse(response.headers.get("content-type"))
|
|
2410
|
-
if (!(contentType in mediaTypePlugins)) {
|
|
2411
|
-
throw Error(`${response.url} is not a schema. Found a document with media type: ${contentType}`);
|
|
3447
|
+
const contentType = contentTypeParser.parse(response.headers.get("content-type"));
|
|
3448
|
+
if (!(contentType.type in mediaTypePlugins)) {
|
|
3449
|
+
throw Error(`${response.url} is not a schema. Found a document with media type: ${contentType.type}`);
|
|
2412
3450
|
}
|
|
2413
|
-
return mediaTypePlugins[contentType].parse(response);
|
|
3451
|
+
return mediaTypePlugins[contentType.type].parse(response, contentType.parameters);
|
|
2414
3452
|
};
|
|
2415
3453
|
|
|
2416
3454
|
const getContentType = (path) => {
|
|
@@ -2425,9 +3463,10 @@ var JsonSchema = (function (exports) {
|
|
|
2425
3463
|
|
|
2426
3464
|
var mediaTypes = { addPlugin, parse, getContentType };
|
|
2427
3465
|
|
|
2428
|
-
const curry$
|
|
2429
|
-
const Pact$a = lib$
|
|
2430
|
-
const
|
|
3466
|
+
const curry$8 = justCurryIt$2;
|
|
3467
|
+
const Pact$a = lib$5;
|
|
3468
|
+
const Json = lib$3;
|
|
3469
|
+
const JsonPointer = lib$6;
|
|
2431
3470
|
const { jsonTypeOf, resolveUrl: resolveUrl$1, urlFragment, pathRelative } = common$1;
|
|
2432
3471
|
const fetch$1 = fetch_browser;
|
|
2433
3472
|
const Reference$1 = reference;
|
|
@@ -2442,6 +3481,8 @@ var JsonSchema = (function (exports) {
|
|
|
2442
3481
|
const dialectJsonSchemaVersion = {};
|
|
2443
3482
|
|
|
2444
3483
|
const setConfig = (jsonSchemaVersion, key, value) => {
|
|
3484
|
+
dialectJsonSchemaVersion[jsonSchemaVersion] = jsonSchemaVersion;
|
|
3485
|
+
|
|
2445
3486
|
if (!config[jsonSchemaVersion]) {
|
|
2446
3487
|
config[jsonSchemaVersion] = {};
|
|
2447
3488
|
}
|
|
@@ -2456,62 +3497,61 @@ var JsonSchema = (function (exports) {
|
|
|
2456
3497
|
// Schema Management
|
|
2457
3498
|
const schemaStore = {};
|
|
2458
3499
|
const schemaStoreAlias = {};
|
|
3500
|
+
const add$1 = (schema, retrievalUri = "", defaultDialectId = "") => {
|
|
3501
|
+
const dialectId = getDialectId(schema, retrievalUri, defaultDialectId);
|
|
2459
3502
|
|
|
2460
|
-
|
|
2461
|
-
schema = JSON.parse(JSON.stringify(schema));
|
|
2462
|
-
const externalId = resolveUrl$1(url, "");
|
|
3503
|
+
const id = getBaseUri(schema, retrievalUri, dialectJsonSchemaVersion[dialectId]);
|
|
2463
3504
|
|
|
2464
|
-
//
|
|
2465
|
-
const
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
|
|
2469
|
-
|
|
3505
|
+
// Extract embedded schemas and collect anchors
|
|
3506
|
+
const embeddedToken = getConfig(dialectId, "embeddedToken");
|
|
3507
|
+
const baseToken = getConfig(dialectId, "baseToken");
|
|
3508
|
+
const anchorToken = getConfig(dialectId, "anchorToken");
|
|
3509
|
+
const dynamicAnchorToken = getConfig(dialectId, "dynamicAnchorToken");
|
|
3510
|
+
const jrefToken = getConfig(dialectId, "jrefToken");
|
|
2470
3511
|
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
|
|
2481
|
-
|
|
2482
|
-
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
|
|
3512
|
+
const dynamicAnchors = {};
|
|
3513
|
+
const anchors = { "": "" };
|
|
3514
|
+
|
|
3515
|
+
schema = Json.parse(JSON.stringify(schema), (key, value, pointer) => {
|
|
3516
|
+
if (jsonTypeOf(value, "object")) {
|
|
3517
|
+
// Embedded Schema
|
|
3518
|
+
const embeddedSchemaDialectId = typeof value.$schema === "string" ? resolveUrl$1(value.$schema, "") : dialectId;
|
|
3519
|
+
const embeddedEmbeddedToken = getConfig(embeddedSchemaDialectId, "embeddedToken");
|
|
3520
|
+
const embeddedAnchorToken = getConfig(embeddedSchemaDialectId, "anchorToken");
|
|
3521
|
+
if (typeof value[embeddedEmbeddedToken] === "string" && (embeddedEmbeddedToken !== embeddedAnchorToken || value[embeddedEmbeddedToken][0] !== "#") && pointer !== "") {
|
|
3522
|
+
const embeddedRetrievalUri = resolveUrl$1(id, value[embeddedEmbeddedToken]);
|
|
3523
|
+
add$1(value, embeddedRetrievalUri, dialectId);
|
|
3524
|
+
return Reference$1.cons(value[embeddedEmbeddedToken], value);
|
|
3525
|
+
}
|
|
3526
|
+
|
|
3527
|
+
if (typeof value[jrefToken] === "string") {
|
|
3528
|
+
return Reference$1.cons(value[jrefToken], value);
|
|
3529
|
+
}
|
|
3530
|
+
|
|
3531
|
+
if (typeof value[anchorToken] === "string" && pointer !== JsonPointer.nil) {
|
|
3532
|
+
const anchor = anchorToken !== embeddedToken ? value[anchorToken] : value[anchorToken].slice(1);
|
|
3533
|
+
anchors[anchor] = pointer;
|
|
3534
|
+
delete value[anchorToken];
|
|
3535
|
+
}
|
|
3536
|
+
|
|
3537
|
+
if (typeof value[dynamicAnchorToken] === "string") {
|
|
3538
|
+
dynamicAnchors[value[dynamicAnchorToken]] = `${id}#${pointer}`;
|
|
3539
|
+
anchors[value[dynamicAnchorToken]] = pointer;
|
|
3540
|
+
delete value[dynamicAnchorToken];
|
|
2489
3541
|
}
|
|
2490
3542
|
}
|
|
2491
|
-
}
|
|
2492
3543
|
|
|
2493
|
-
|
|
2494
|
-
|
|
2495
|
-
|
|
2496
|
-
throw Error("Couldn't determine an identifier for the schema");
|
|
2497
|
-
}
|
|
2498
|
-
const baseToken = getConfig(dialectId, "baseToken");
|
|
2499
|
-
delete schema[baseToken];
|
|
2500
|
-
if (externalId) {
|
|
2501
|
-
schemaStoreAlias[externalId] = id;
|
|
2502
|
-
}
|
|
3544
|
+
return value;
|
|
3545
|
+
});
|
|
3546
|
+
console.log(embeddedIds);
|
|
2503
3547
|
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
schema[anchorToken] = anchorToken !== baseToken ? encodeURI(fragment) : `#${encodeURI(fragment)}`;
|
|
2507
|
-
}
|
|
3548
|
+
delete schema.$schema;
|
|
3549
|
+
delete schema[baseToken];
|
|
2508
3550
|
|
|
2509
3551
|
// recursiveAnchor
|
|
2510
|
-
const dynamicAnchors = {};
|
|
2511
3552
|
const recursiveAnchorToken = getConfig(dialectId, "recursiveAnchorToken");
|
|
2512
3553
|
if (schema[recursiveAnchorToken] === true) {
|
|
2513
3554
|
dynamicAnchors[""] = `${id}#`;
|
|
2514
|
-
schema[anchorToken] = "";
|
|
2515
3555
|
delete schema[recursiveAnchorToken];
|
|
2516
3556
|
}
|
|
2517
3557
|
|
|
@@ -2526,69 +3566,66 @@ var JsonSchema = (function (exports) {
|
|
|
2526
3566
|
}
|
|
2527
3567
|
|
|
2528
3568
|
// Store Schema
|
|
2529
|
-
const anchors = { "": "" };
|
|
2530
3569
|
schemaStore[id] = {
|
|
2531
|
-
id
|
|
2532
|
-
dialectId
|
|
2533
|
-
schema
|
|
2534
|
-
anchors
|
|
2535
|
-
dynamicAnchors
|
|
2536
|
-
vocabulary
|
|
3570
|
+
id,
|
|
3571
|
+
dialectId,
|
|
3572
|
+
schema,
|
|
3573
|
+
anchors,
|
|
3574
|
+
dynamicAnchors,
|
|
3575
|
+
vocabulary,
|
|
2537
3576
|
validated: false
|
|
2538
3577
|
};
|
|
3578
|
+
if (id === "https://example.com/schema/root") {
|
|
3579
|
+
console.log(Object.keys(schemaStore).filter((id) => !/json-schema\.org/.test(id)));
|
|
3580
|
+
}
|
|
2539
3581
|
|
|
2540
|
-
|
|
3582
|
+
if (retrievalUri) {
|
|
3583
|
+
schemaStoreAlias[resolveUrl$1(retrievalUri, "")] = id;
|
|
3584
|
+
}
|
|
2541
3585
|
};
|
|
2542
3586
|
|
|
2543
|
-
const
|
|
2544
|
-
const
|
|
2545
|
-
|
|
2546
|
-
|
|
2547
|
-
|
|
2548
|
-
|
|
2549
|
-
const processSchema = (subject, id, dialectId, pointer, anchors, dynamicAnchors) => {
|
|
2550
|
-
if (jsonTypeOf(subject, "object")) {
|
|
2551
|
-
const embeddedSchemaDialectId = typeof subject.$schema === "string" ? resolveUrl$1(subject.$schema, "") : dialectId;
|
|
2552
|
-
const embeddedEmbeddedToken = getConfig(embeddedSchemaDialectId, "embeddedToken");
|
|
2553
|
-
const embeddedAnchorToken = getConfig(embeddedSchemaDialectId, "anchorToken");
|
|
2554
|
-
if (typeof subject[embeddedEmbeddedToken] === "string" && (embeddedEmbeddedToken !== embeddedAnchorToken || subject[embeddedEmbeddedToken][0] !== "#")) {
|
|
2555
|
-
const ref = resolveUrl$1(id, subject[embeddedEmbeddedToken]);
|
|
2556
|
-
const embeddedBaseToken = getConfig(embeddedSchemaDialectId, "baseToken");
|
|
2557
|
-
subject[embeddedBaseToken] = ref;
|
|
2558
|
-
add$1(subject, ref, dialectId);
|
|
2559
|
-
return Reference$1.cons(subject[embeddedEmbeddedToken], subject);
|
|
2560
|
-
}
|
|
2561
|
-
|
|
2562
|
-
const anchorToken = getConfig(dialectId, "anchorToken");
|
|
2563
|
-
const dynamicAnchorToken = getConfig(dialectId, "dynamicAnchorToken");
|
|
2564
|
-
if (typeof subject[dynamicAnchorToken] === "string") {
|
|
2565
|
-
dynamicAnchors[subject[dynamicAnchorToken]] = `${id}#${encodeURI(pointer)}`;
|
|
2566
|
-
anchors[subject[dynamicAnchorToken]] = pointer;
|
|
2567
|
-
delete subject[dynamicAnchorToken];
|
|
2568
|
-
}
|
|
2569
|
-
|
|
2570
|
-
const embeddedToken = getConfig(dialectId, "embeddedToken");
|
|
2571
|
-
if (typeof subject[anchorToken] === "string") {
|
|
2572
|
-
const anchor = anchorToken !== embeddedToken ? subject[anchorToken] : subject[anchorToken].slice(1);
|
|
2573
|
-
anchors[anchor] = pointer;
|
|
2574
|
-
delete subject[anchorToken];
|
|
2575
|
-
}
|
|
3587
|
+
const getDialectId = (schema, retrievalUri, defaultDialectId) => {
|
|
3588
|
+
const dialectId = resolveUrl$1(schema.$schema || defaultDialectId, "");
|
|
3589
|
+
if (!dialectId) {
|
|
3590
|
+
throw Error("Couldn't determine schema dialect");
|
|
3591
|
+
}
|
|
2576
3592
|
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
|
|
3593
|
+
// Determine JSON Schema version
|
|
3594
|
+
if (!(dialectId in dialectJsonSchemaVersion)) {
|
|
3595
|
+
if (schema?.$vocabulary?.[core201909Id] === true && dialectId === getBaseUri(schema, retrievalUri, core201909Id)) {
|
|
3596
|
+
// Self describing 2019-09 meta-schema
|
|
3597
|
+
dialectJsonSchemaVersion[dialectId] = core201909Id;
|
|
3598
|
+
} else if (schema?.$vocabulary?.[core202012Id] === true && dialectId === getBaseUri(schema, retrievalUri, core202012Id)) {
|
|
3599
|
+
// Self describing 2020-12 meta-schema
|
|
3600
|
+
dialectJsonSchemaVersion[dialectId] = core202012Id;
|
|
3601
|
+
} else {
|
|
3602
|
+
// Need to look at meta-schema to determine version
|
|
3603
|
+
const metaSchema = schemaStore[dialectId];
|
|
3604
|
+
if (!metaSchema) {
|
|
3605
|
+
throw Error(`Couldn't determine JSON Schema version for dialect: '${dialectId}'`);
|
|
3606
|
+
} else if (metaSchema.vocabulary[core201909Id] === true) {
|
|
3607
|
+
dialectJsonSchemaVersion[dialectId] = core201909Id;
|
|
3608
|
+
} else if (metaSchema.vocabulary[core202012Id] === true) {
|
|
3609
|
+
dialectJsonSchemaVersion[dialectId] = core202012Id;
|
|
3610
|
+
} else {
|
|
3611
|
+
// Assume the jsonSchemaVersion is the meta-schema's dialectId (non-standard behavior)
|
|
3612
|
+
dialectJsonSchemaVersion[dialectId] = dialectJsonSchemaVersion[metaSchema.dialectId];
|
|
3613
|
+
}
|
|
2580
3614
|
}
|
|
3615
|
+
}
|
|
2581
3616
|
|
|
2582
|
-
|
|
2583
|
-
|
|
2584
|
-
}
|
|
3617
|
+
return dialectId;
|
|
3618
|
+
};
|
|
2585
3619
|
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
|
|
3620
|
+
const getBaseUri = (schema, retrievalUri, jsonSchemaVersion) => {
|
|
3621
|
+
const baseToken = config[jsonSchemaVersion]?.["baseToken"];
|
|
3622
|
+
const relativeBaseUri = typeof schema[baseToken] === "string" ? schema[baseToken] : "";
|
|
3623
|
+
const baseUri = resolveUrl$1(resolveUrl$1(retrievalUri, relativeBaseUri), "");
|
|
3624
|
+
if (!baseUri) {
|
|
3625
|
+
throw Error("Couldn't determine an identifier for the schema");
|
|
2591
3626
|
}
|
|
3627
|
+
|
|
3628
|
+
return baseUri;
|
|
2592
3629
|
};
|
|
2593
3630
|
|
|
2594
3631
|
const hasStoredSchema = (id) => id in schemaStore || id in schemaStoreAlias;
|
|
@@ -2623,7 +3660,23 @@ var JsonSchema = (function (exports) {
|
|
|
2623
3660
|
throw Error(`Failed to retrieve schema with id: ${id}`);
|
|
2624
3661
|
}
|
|
2625
3662
|
|
|
2626
|
-
|
|
3663
|
+
const [schema, defaultDialectId] = await MediaTypes$1.parse(response);
|
|
3664
|
+
|
|
3665
|
+
let dialectId;
|
|
3666
|
+
if (schema.$schema) {
|
|
3667
|
+
dialectId = resolveUrl$1(schema.$schema, "");
|
|
3668
|
+
} else if (defaultDialectId) {
|
|
3669
|
+
dialectId = resolveUrl$1(id, defaultDialectId);
|
|
3670
|
+
} else {
|
|
3671
|
+
dialectId = "";
|
|
3672
|
+
}
|
|
3673
|
+
|
|
3674
|
+
// Make sure the meta-schema is loaded if this isn't a known dialect
|
|
3675
|
+
if (dialectId && id !== dialectId && !(dialectId in dialectJsonSchemaVersion)) {
|
|
3676
|
+
await get(dialectId);
|
|
3677
|
+
}
|
|
3678
|
+
|
|
3679
|
+
add$1(schema, id, dialectId);
|
|
2627
3680
|
}
|
|
2628
3681
|
|
|
2629
3682
|
const storedSchema = getStoredSchema(id);
|
|
@@ -2666,14 +3719,14 @@ var JsonSchema = (function (exports) {
|
|
|
2666
3719
|
|
|
2667
3720
|
const keys = (doc) => Object.keys(value(doc));
|
|
2668
3721
|
|
|
2669
|
-
const entries = (doc) => Pact$a.pipeline([
|
|
3722
|
+
const entries$2 = (doc) => Pact$a.pipeline([
|
|
2670
3723
|
value,
|
|
2671
3724
|
Object.keys,
|
|
2672
3725
|
Pact$a.map(async (key) => [key, await step(key, doc)]),
|
|
2673
3726
|
Pact$a.all
|
|
2674
3727
|
], doc);
|
|
2675
3728
|
|
|
2676
|
-
const map = curry$
|
|
3729
|
+
const map$3 = curry$8((fn, doc) => Pact$a.pipeline([
|
|
2677
3730
|
value,
|
|
2678
3731
|
Pact$a.map(async (item, ndx) => fn(await step(ndx, doc), ndx)),
|
|
2679
3732
|
Pact$a.all
|
|
@@ -2689,41 +3742,43 @@ var JsonSchema = (function (exports) {
|
|
|
2689
3742
|
const toSchema = (schemaDoc, options = {}) => {
|
|
2690
3743
|
const fullOptions = { ...toSchemaDefaultOptions, ...options };
|
|
2691
3744
|
|
|
2692
|
-
const
|
|
2693
|
-
|
|
2694
|
-
|
|
3745
|
+
const anchorToken = getConfig(schemaDoc.dialectId, "anchorToken");
|
|
3746
|
+
const dynamicAnchorToken = getConfig(schemaDoc.dialectId, "dynamicAnchorToken");
|
|
3747
|
+
|
|
3748
|
+
const anchors = {};
|
|
3749
|
+
for (const anchor in schemaDoc.anchors) {
|
|
3750
|
+
if (anchor !== "" && !schemaDoc.dynamicAnchors[anchor]) {
|
|
3751
|
+
anchors[schemaDoc.anchors[anchor]] = anchor;
|
|
2695
3752
|
}
|
|
3753
|
+
}
|
|
3754
|
+
|
|
3755
|
+
const dynamicAnchors = {};
|
|
3756
|
+
for (const anchor in schemaDoc.dynamicAnchors) {
|
|
3757
|
+
const pointer = urlFragment(schemaDoc.dynamicAnchors[anchor]);
|
|
3758
|
+
dynamicAnchors[pointer] = anchor;
|
|
3759
|
+
}
|
|
2696
3760
|
|
|
2697
|
-
|
|
2698
|
-
|
|
2699
|
-
|
|
2700
|
-
|
|
2701
|
-
|
|
3761
|
+
const schema = JSON.parse(Json.stringify(schemaDoc.schema, (key, value, pointer) => {
|
|
3762
|
+
if (Reference$1.isReference(value)) {
|
|
3763
|
+
const refValue = Reference$1.value(value);
|
|
3764
|
+
const embeddedDialect = typeof refValue.$schema === "string" ? resolveUrl$1(refValue.$schema, "") : schemaDoc.dialectId;
|
|
3765
|
+
const embeddedToken = getConfig(embeddedDialect, "embeddedToken");
|
|
3766
|
+
if (!fullOptions.includeEmbedded && embeddedToken in refValue) {
|
|
3767
|
+
return;
|
|
3768
|
+
} else {
|
|
3769
|
+
return Reference$1.value(value);
|
|
3770
|
+
}
|
|
2702
3771
|
} else {
|
|
2703
|
-
|
|
3772
|
+
if (pointer in anchors) {
|
|
3773
|
+
value = { [anchorToken]: anchors[pointer], ...value };
|
|
3774
|
+
}
|
|
3775
|
+
if (pointer in dynamicAnchors) {
|
|
3776
|
+
value = { [dynamicAnchorToken]: dynamicAnchors[pointer], ...value };
|
|
3777
|
+
}
|
|
3778
|
+
return value;
|
|
2704
3779
|
}
|
|
2705
3780
|
}));
|
|
2706
3781
|
|
|
2707
|
-
const dynamicAnchorToken = getConfig(schemaDoc.dialectId, "dynamicAnchorToken");
|
|
2708
|
-
Object.entries(schemaDoc.dynamicAnchors)
|
|
2709
|
-
.forEach(([anchor, uri]) => {
|
|
2710
|
-
const pointer = urlFragment(uri);
|
|
2711
|
-
JsonPointer.assign(pointer, schema, {
|
|
2712
|
-
[dynamicAnchorToken]: anchor,
|
|
2713
|
-
...JsonPointer.get(pointer, schema)
|
|
2714
|
-
});
|
|
2715
|
-
});
|
|
2716
|
-
|
|
2717
|
-
const anchorToken = getConfig(schemaDoc.dialectId, "anchorToken");
|
|
2718
|
-
Object.entries(schemaDoc.anchors)
|
|
2719
|
-
.filter(([anchor]) => anchor !== "")
|
|
2720
|
-
.forEach(([anchor, pointer]) => {
|
|
2721
|
-
JsonPointer.assign(pointer, schema, {
|
|
2722
|
-
[anchorToken]: anchor,
|
|
2723
|
-
...JsonPointer.get(pointer, schema)
|
|
2724
|
-
});
|
|
2725
|
-
});
|
|
2726
|
-
|
|
2727
3782
|
const baseToken = getConfig(schemaDoc.dialectId, "baseToken");
|
|
2728
3783
|
const id = relativeUri(fullOptions.parentId, schemaDoc.id);
|
|
2729
3784
|
const dialect = fullOptions.parentDialect === schemaDoc.dialectId ? "" : schemaDoc.dialectId;
|
|
@@ -2746,7 +3801,7 @@ var JsonSchema = (function (exports) {
|
|
|
2746
3801
|
var schema$5 = {
|
|
2747
3802
|
setConfig, getConfig,
|
|
2748
3803
|
add: add$1, get, markValidated,
|
|
2749
|
-
uri, value, getAnchorPointer, typeOf, has, step, keys, entries, map, length,
|
|
3804
|
+
uri, value, getAnchorPointer, typeOf, has, step, keys, entries: entries$2, map: map$3, length,
|
|
2750
3805
|
toSchema
|
|
2751
3806
|
};
|
|
2752
3807
|
|
|
@@ -2760,13 +3815,22 @@ var JsonSchema = (function (exports) {
|
|
|
2760
3815
|
|
|
2761
3816
|
var invalidSchemaError = InvalidSchemaError$3;
|
|
2762
3817
|
|
|
2763
|
-
const
|
|
3818
|
+
const Schema$R = schema$5;
|
|
3819
|
+
|
|
3820
|
+
|
|
3821
|
+
const compile$O = (schema) => Schema$R.value(schema);
|
|
3822
|
+
const interpret$O = () => true;
|
|
3823
|
+
|
|
3824
|
+
var metaData$4 = { compile: compile$O, interpret: interpret$O };
|
|
3825
|
+
|
|
3826
|
+
const curry$7 = justCurryIt$2;
|
|
2764
3827
|
const PubSub$1 = pubsub.exports;
|
|
2765
3828
|
const { resolveUrl } = common$1;
|
|
2766
3829
|
const Instance$E = instance;
|
|
2767
|
-
const Schema$
|
|
3830
|
+
const Schema$Q = schema$5;
|
|
2768
3831
|
const InvalidSchemaError$2 = invalidSchemaError;
|
|
2769
3832
|
const MediaTypes = mediaTypes;
|
|
3833
|
+
const metaData$3 = metaData$4;
|
|
2770
3834
|
|
|
2771
3835
|
|
|
2772
3836
|
const FLAG = "FLAG", BASIC = "BASIC", DETAILED = "DETAILED", VERBOSE = "VERBOSE";
|
|
@@ -2775,24 +3839,27 @@ var JsonSchema = (function (exports) {
|
|
|
2775
3839
|
let shouldMetaValidate = true;
|
|
2776
3840
|
|
|
2777
3841
|
MediaTypes.addPlugin("application/schema+json", {
|
|
2778
|
-
parse: async (response) =>
|
|
3842
|
+
parse: async (response, contentTypeParameters) => [
|
|
3843
|
+
await response.json(),
|
|
3844
|
+
contentTypeParameters.schema || contentTypeParameters.profile
|
|
3845
|
+
],
|
|
2779
3846
|
matcher: (path) => path.endsWith(".schema.json")
|
|
2780
3847
|
});
|
|
2781
3848
|
|
|
2782
3849
|
const validate$2 = async (schema, value = undefined, outputFormat = undefined) => {
|
|
2783
|
-
const compiled = await compile$
|
|
2784
|
-
const interpretAst = (value, outputFormat) => interpret$
|
|
3850
|
+
const compiled = await compile$N(schema);
|
|
3851
|
+
const interpretAst = (value, outputFormat) => interpret$N(compiled, Instance$E.cons(value), outputFormat);
|
|
2785
3852
|
|
|
2786
3853
|
return value === undefined ? interpretAst : interpretAst(value, outputFormat);
|
|
2787
3854
|
};
|
|
2788
3855
|
|
|
2789
|
-
const compile$
|
|
3856
|
+
const compile$N = async (schema) => {
|
|
2790
3857
|
const ast = { metaData: {} };
|
|
2791
3858
|
const schemaUri = await compileSchema(schema, ast);
|
|
2792
3859
|
return { ast, schemaUri };
|
|
2793
3860
|
};
|
|
2794
3861
|
|
|
2795
|
-
const interpret$
|
|
3862
|
+
const interpret$N = curry$7(({ ast, schemaUri }, value, outputFormat = FLAG) => {
|
|
2796
3863
|
if (![FLAG, BASIC, DETAILED, VERBOSE].includes(outputFormat)) {
|
|
2797
3864
|
throw Error(`The '${outputFormat}' error format is not supported`);
|
|
2798
3865
|
}
|
|
@@ -2846,7 +3913,7 @@ var JsonSchema = (function (exports) {
|
|
|
2846
3913
|
};
|
|
2847
3914
|
|
|
2848
3915
|
const _keywords = {};
|
|
2849
|
-
const getKeyword = (id) => _keywords[id];
|
|
3916
|
+
const getKeyword = (id) => _keywords[id] || metaData$3;
|
|
2850
3917
|
const hasKeyword = (id) => id in _keywords;
|
|
2851
3918
|
const addKeyword = (id, keywordHandler) => {
|
|
2852
3919
|
_keywords[id] = {
|
|
@@ -2867,10 +3934,10 @@ var JsonSchema = (function (exports) {
|
|
|
2867
3934
|
|
|
2868
3935
|
// Vocabularies
|
|
2869
3936
|
if (!hasKeyword(`${schema.dialectId}#validate`)) {
|
|
2870
|
-
const metaSchema = await Schema$
|
|
3937
|
+
const metaSchema = await Schema$Q.get(schema.dialectId);
|
|
2871
3938
|
|
|
2872
3939
|
// Check for mandatory vocabularies
|
|
2873
|
-
const mandatoryVocabularies = Schema$
|
|
3940
|
+
const mandatoryVocabularies = Schema$Q.getConfig(metaSchema.id, "mandatoryVocabularies") || [];
|
|
2874
3941
|
mandatoryVocabularies.forEach((vocabularyId) => {
|
|
2875
3942
|
if (!metaSchema.vocabulary[vocabularyId]) {
|
|
2876
3943
|
throw Error(`Vocabulary '${vocabularyId}' must be explicitly declared and required`);
|
|
@@ -2893,13 +3960,13 @@ var JsonSchema = (function (exports) {
|
|
|
2893
3960
|
|
|
2894
3961
|
// Meta validation
|
|
2895
3962
|
if (shouldMetaValidate && !schema.validated) {
|
|
2896
|
-
Schema$
|
|
3963
|
+
Schema$Q.markValidated(schema.id);
|
|
2897
3964
|
|
|
2898
3965
|
// Compile
|
|
2899
3966
|
if (!(schema.dialectId in metaValidators)) {
|
|
2900
|
-
const metaSchema = await Schema$
|
|
2901
|
-
const compiledSchema = await compile$
|
|
2902
|
-
metaValidators[metaSchema.id] = interpret$
|
|
3967
|
+
const metaSchema = await Schema$Q.get(schema.dialectId);
|
|
3968
|
+
const compiledSchema = await compile$N(metaSchema);
|
|
3969
|
+
metaValidators[metaSchema.id] = interpret$N(compiledSchema);
|
|
2903
3970
|
}
|
|
2904
3971
|
|
|
2905
3972
|
// Interpret
|
|
@@ -2922,7 +3989,7 @@ var JsonSchema = (function (exports) {
|
|
|
2922
3989
|
};
|
|
2923
3990
|
|
|
2924
3991
|
const followReferences = async (doc) => {
|
|
2925
|
-
return Schema$
|
|
3992
|
+
return Schema$Q.typeOf(doc, "string") ? followReferences(await Schema$Q.get(Schema$Q.value(doc), doc)) : doc;
|
|
2926
3993
|
};
|
|
2927
3994
|
|
|
2928
3995
|
const interpretSchema = (schemaUri, instance, ast, dynamicAnchors) => {
|
|
@@ -2950,27 +4017,19 @@ var JsonSchema = (function (exports) {
|
|
|
2950
4017
|
};
|
|
2951
4018
|
|
|
2952
4019
|
const add = (schema, url = "", defaultSchemaVersion = "") => {
|
|
2953
|
-
const id = Schema$
|
|
4020
|
+
const id = Schema$Q.add(schema, url, defaultSchemaVersion);
|
|
2954
4021
|
delete metaValidators[id];
|
|
2955
4022
|
};
|
|
2956
4023
|
|
|
2957
4024
|
var core$2 = {
|
|
2958
|
-
validate: validate$2, compile: compile$
|
|
4025
|
+
validate: validate$2, compile: compile$N, interpret: interpret$N,
|
|
2959
4026
|
setMetaOutputFormat, setShouldMetaValidate, FLAG, BASIC, DETAILED, VERBOSE,
|
|
2960
4027
|
add, getKeyword, hasKeyword, defineVocabulary,
|
|
2961
4028
|
compileSchema, interpretSchema, collectEvaluatedProperties: collectEvaluatedProperties$e, collectEvaluatedItems: collectEvaluatedItems$f,
|
|
2962
4029
|
addMediaTypePlugin: MediaTypes.addPlugin
|
|
2963
4030
|
};
|
|
2964
4031
|
|
|
2965
|
-
const
|
|
2966
|
-
|
|
2967
|
-
|
|
2968
|
-
const compile$N = (schema) => Schema$Q.value(schema);
|
|
2969
|
-
const interpret$N = () => true;
|
|
2970
|
-
|
|
2971
|
-
var metaData$3 = { compile: compile$N, interpret: interpret$N };
|
|
2972
|
-
|
|
2973
|
-
const Pact$9 = lib$2;
|
|
4032
|
+
const Pact$9 = lib$5;
|
|
2974
4033
|
const PubSub = pubsub.exports;
|
|
2975
4034
|
const Core$x = core$2;
|
|
2976
4035
|
const Instance$D = instance;
|
|
@@ -2993,7 +4052,7 @@ var JsonSchema = (function (exports) {
|
|
|
2993
4052
|
typeof schemaValue === "boolean" ? schemaValue : await Pact$9.pipeline([
|
|
2994
4053
|
Schema$P.entries,
|
|
2995
4054
|
Pact$9.map(([keyword, keywordSchema]) => [`${schema.dialectId}#${keyword}`, keywordSchema]),
|
|
2996
|
-
Pact$9.filter(([keywordId]) =>
|
|
4055
|
+
Pact$9.filter(([keywordId]) => keywordId !== `${schema.dialectId}#validate`),
|
|
2997
4056
|
Pact$9.map(async ([keywordId, keywordSchema]) => {
|
|
2998
4057
|
const keywordAst = await Core$x.getKeyword(keywordId).compile(keywordSchema, ast, schema);
|
|
2999
4058
|
return [keywordId, Schema$P.uri(keywordSchema), keywordAst];
|
|
@@ -3069,7 +4128,7 @@ var JsonSchema = (function (exports) {
|
|
|
3069
4128
|
|
|
3070
4129
|
var validate$1 = { compile: compile$M, interpret: interpret$M, collectEvaluatedProperties: collectEvaluatedProperties$d, collectEvaluatedItems: collectEvaluatedItems$e };
|
|
3071
4130
|
|
|
3072
|
-
const metaData$2 = metaData$
|
|
4131
|
+
const metaData$2 = metaData$4;
|
|
3073
4132
|
const validate = validate$1;
|
|
3074
4133
|
|
|
3075
4134
|
|
|
@@ -3083,9 +4142,9 @@ var JsonSchema = (function (exports) {
|
|
|
3083
4142
|
const InvalidSchemaError$1 = invalidSchemaError;
|
|
3084
4143
|
|
|
3085
4144
|
|
|
3086
|
-
var lib$
|
|
4145
|
+
var lib$2 = { Core: Core$w, Schema: Schema$O, Instance: Instance$C, Reference, Keywords: Keywords$2, InvalidSchemaError: InvalidSchemaError$1 };
|
|
3087
4146
|
|
|
3088
|
-
const { Core: Core$v, Schema: Schema$N, Instance: Instance$B } = lib$
|
|
4147
|
+
const { Core: Core$v, Schema: Schema$N, Instance: Instance$B } = lib$2;
|
|
3089
4148
|
|
|
3090
4149
|
|
|
3091
4150
|
const compile$L = async (schema, ast, parentSchema) => {
|
|
@@ -3113,7 +4172,7 @@ var JsonSchema = (function (exports) {
|
|
|
3113
4172
|
|
|
3114
4173
|
var additionalItems = { compile: compile$L, interpret: interpret$L };
|
|
3115
4174
|
|
|
3116
|
-
const { Core: Core$u, Schema: Schema$M, Instance: Instance$A } = lib$
|
|
4175
|
+
const { Core: Core$u, Schema: Schema$M, Instance: Instance$A } = lib$2;
|
|
3117
4176
|
|
|
3118
4177
|
|
|
3119
4178
|
const compile$K = async (schema, ast, parentSchema) => {
|
|
@@ -3137,7 +4196,7 @@ var JsonSchema = (function (exports) {
|
|
|
3137
4196
|
|
|
3138
4197
|
var additionalItems6 = { compile: compile$K, interpret: interpret$K, collectEvaluatedItems: collectEvaluatedItems$d };
|
|
3139
4198
|
|
|
3140
|
-
const { Core: Core$t, Schema: Schema$L, Instance: Instance$z } = lib$
|
|
4199
|
+
const { Core: Core$t, Schema: Schema$L, Instance: Instance$z } = lib$2;
|
|
3141
4200
|
|
|
3142
4201
|
|
|
3143
4202
|
const compile$J = async (schema, ast, parentSchema) => {
|
|
@@ -3171,7 +4230,7 @@ var JsonSchema = (function (exports) {
|
|
|
3171
4230
|
|
|
3172
4231
|
var additionalProperties = { compile: compile$J, interpret: interpret$J };
|
|
3173
4232
|
|
|
3174
|
-
const { Core: Core$s, Schema: Schema$K, Instance: Instance$y } = lib$
|
|
4233
|
+
const { Core: Core$s, Schema: Schema$K, Instance: Instance$y } = lib$2;
|
|
3175
4234
|
|
|
3176
4235
|
|
|
3177
4236
|
const compile$I = async (schema, ast, parentSchema) => {
|
|
@@ -3200,8 +4259,129 @@ var JsonSchema = (function (exports) {
|
|
|
3200
4259
|
|
|
3201
4260
|
var additionalProperties6 = { compile: compile$I, interpret: interpret$I, collectEvaluatedProperties: collectEvaluatedProperties$c };
|
|
3202
4261
|
|
|
3203
|
-
|
|
3204
|
-
|
|
4262
|
+
var entries$1 = async (doc) => Object.entries(await doc);
|
|
4263
|
+
|
|
4264
|
+
var justCurryIt = curry$6;
|
|
4265
|
+
|
|
4266
|
+
/*
|
|
4267
|
+
function add(a, b, c) {
|
|
4268
|
+
return a + b + c;
|
|
4269
|
+
}
|
|
4270
|
+
curry(add)(1)(2)(3); // 6
|
|
4271
|
+
curry(add)(1)(2)(2); // 5
|
|
4272
|
+
curry(add)(2)(4, 3); // 9
|
|
4273
|
+
|
|
4274
|
+
function add(...args) {
|
|
4275
|
+
return args.reduce((sum, n) => sum + n, 0)
|
|
4276
|
+
}
|
|
4277
|
+
var curryAdd4 = curry(add, 4)
|
|
4278
|
+
curryAdd4(1)(2, 3)(4); // 10
|
|
4279
|
+
|
|
4280
|
+
function converter(ratio, input) {
|
|
4281
|
+
return (input*ratio).toFixed(1);
|
|
4282
|
+
}
|
|
4283
|
+
const curriedConverter = curry(converter)
|
|
4284
|
+
const milesToKm = curriedConverter(1.62);
|
|
4285
|
+
milesToKm(35); // 56.7
|
|
4286
|
+
milesToKm(10); // 16.2
|
|
4287
|
+
*/
|
|
4288
|
+
|
|
4289
|
+
function curry$6(fn, arity) {
|
|
4290
|
+
return function curried() {
|
|
4291
|
+
if (arity == null) {
|
|
4292
|
+
arity = fn.length;
|
|
4293
|
+
}
|
|
4294
|
+
var args = [].slice.call(arguments);
|
|
4295
|
+
if (args.length >= arity) {
|
|
4296
|
+
return fn.apply(this, args);
|
|
4297
|
+
} else {
|
|
4298
|
+
return function() {
|
|
4299
|
+
return curried.apply(this, args.concat([].slice.call(arguments)));
|
|
4300
|
+
};
|
|
4301
|
+
}
|
|
4302
|
+
};
|
|
4303
|
+
}
|
|
4304
|
+
|
|
4305
|
+
const curry$5 = justCurryIt;
|
|
4306
|
+
|
|
4307
|
+
|
|
4308
|
+
var map$2 = curry$5(async (fn, doc) => (await doc).map(fn));
|
|
4309
|
+
|
|
4310
|
+
const curry$4 = justCurryIt;
|
|
4311
|
+
|
|
4312
|
+
|
|
4313
|
+
var reduce$2 = curry$4(async (fn, acc, doc) => {
|
|
4314
|
+
return (await doc).reduce(async (acc, item) => fn(await acc, item), acc);
|
|
4315
|
+
});
|
|
4316
|
+
|
|
4317
|
+
const curry$3 = justCurryIt;
|
|
4318
|
+
const reduce$1 = reduce$2;
|
|
4319
|
+
|
|
4320
|
+
|
|
4321
|
+
var filter = curry$3(async (fn, doc, options = {}) => {
|
|
4322
|
+
return reduce$1(async (acc, item) => {
|
|
4323
|
+
return (await fn(item)) ? acc.concat([item]) : acc;
|
|
4324
|
+
}, [], doc, options);
|
|
4325
|
+
});
|
|
4326
|
+
|
|
4327
|
+
const curry$2 = justCurryIt;
|
|
4328
|
+
const map$1 = map$2;
|
|
4329
|
+
|
|
4330
|
+
|
|
4331
|
+
var some = curry$2(async (fn, doc) => {
|
|
4332
|
+
const results = await map$1(fn, doc);
|
|
4333
|
+
return (await Promise.all(results))
|
|
4334
|
+
.some((a) => a);
|
|
4335
|
+
});
|
|
4336
|
+
|
|
4337
|
+
const curry$1 = justCurryIt;
|
|
4338
|
+
const map = map$2;
|
|
4339
|
+
|
|
4340
|
+
|
|
4341
|
+
var every = curry$1(async (fn, doc) => {
|
|
4342
|
+
const results = await map(fn, doc);
|
|
4343
|
+
return (await Promise.all(results))
|
|
4344
|
+
.every((a) => a);
|
|
4345
|
+
});
|
|
4346
|
+
|
|
4347
|
+
const curry = justCurryIt;
|
|
4348
|
+
|
|
4349
|
+
|
|
4350
|
+
var pipeline$1 = curry((fns, doc) => {
|
|
4351
|
+
return fns.reduce(async (acc, fn) => fn(await acc), doc);
|
|
4352
|
+
});
|
|
4353
|
+
|
|
4354
|
+
var all = (doc) => Promise.all(doc);
|
|
4355
|
+
|
|
4356
|
+
const pipeline = pipeline$1;
|
|
4357
|
+
const entries = entries$1;
|
|
4358
|
+
const reduce = reduce$2;
|
|
4359
|
+
|
|
4360
|
+
|
|
4361
|
+
var allValues = (doc) => {
|
|
4362
|
+
return pipeline([
|
|
4363
|
+
entries,
|
|
4364
|
+
reduce(async (acc, [propertyName, propertyValue]) => {
|
|
4365
|
+
acc[propertyName] = await propertyValue;
|
|
4366
|
+
return acc;
|
|
4367
|
+
}, {})
|
|
4368
|
+
], doc);
|
|
4369
|
+
};
|
|
4370
|
+
|
|
4371
|
+
var lib$1 = {
|
|
4372
|
+
entries: entries$1,
|
|
4373
|
+
map: map$2,
|
|
4374
|
+
filter: filter,
|
|
4375
|
+
reduce: reduce$2,
|
|
4376
|
+
some: some,
|
|
4377
|
+
every: every,
|
|
4378
|
+
pipeline: pipeline$1,
|
|
4379
|
+
all: all,
|
|
4380
|
+
allValues: allValues
|
|
4381
|
+
};
|
|
4382
|
+
|
|
4383
|
+
const { Core: Core$r, Schema: Schema$J } = lib$2;
|
|
4384
|
+
const Pact$8 = lib$1;
|
|
3205
4385
|
|
|
3206
4386
|
|
|
3207
4387
|
const compile$H = (schema, ast) => Pact$8.pipeline([
|
|
@@ -3229,8 +4409,8 @@ var JsonSchema = (function (exports) {
|
|
|
3229
4409
|
|
|
3230
4410
|
var allOf = { compile: compile$H, interpret: interpret$H, collectEvaluatedProperties: collectEvaluatedProperties$b, collectEvaluatedItems: collectEvaluatedItems$c };
|
|
3231
4411
|
|
|
3232
|
-
const { Core: Core$q, Schema: Schema$I } = lib$
|
|
3233
|
-
const Pact$7 = lib$
|
|
4412
|
+
const { Core: Core$q, Schema: Schema$I } = lib$2;
|
|
4413
|
+
const Pact$7 = lib$1;
|
|
3234
4414
|
|
|
3235
4415
|
|
|
3236
4416
|
const compile$G = (schema, ast) => Pact$7.pipeline([
|
|
@@ -3318,7 +4498,7 @@ var JsonSchema = (function (exports) {
|
|
|
3318
4498
|
|
|
3319
4499
|
var fastestStableStringify = function(obj) { return '' + stringify(obj, false); };
|
|
3320
4500
|
|
|
3321
|
-
const { Schema: Schema$H, Instance: Instance$x } = lib$
|
|
4501
|
+
const { Schema: Schema$H, Instance: Instance$x } = lib$2;
|
|
3322
4502
|
const jsonStringify$2 = fastestStableStringify;
|
|
3323
4503
|
|
|
3324
4504
|
|
|
@@ -3327,7 +4507,7 @@ var JsonSchema = (function (exports) {
|
|
|
3327
4507
|
|
|
3328
4508
|
var _const = { compile: compile$F, interpret: interpret$F };
|
|
3329
4509
|
|
|
3330
|
-
const { Core: Core$p, Instance: Instance$w } = lib$
|
|
4510
|
+
const { Core: Core$p, Instance: Instance$w } = lib$2;
|
|
3331
4511
|
|
|
3332
4512
|
|
|
3333
4513
|
const compile$E = (schema, ast) => Core$p.compileSchema(schema, ast);
|
|
@@ -3338,7 +4518,7 @@ var JsonSchema = (function (exports) {
|
|
|
3338
4518
|
|
|
3339
4519
|
var contains = { compile: compile$E, interpret: interpret$E };
|
|
3340
4520
|
|
|
3341
|
-
const { Core: Core$o, Schema: Schema$G, Instance: Instance$v } = lib$
|
|
4521
|
+
const { Core: Core$o, Schema: Schema$G, Instance: Instance$v } = lib$2;
|
|
3342
4522
|
|
|
3343
4523
|
|
|
3344
4524
|
const compile$D = async (schema, ast, parentSchema) => {
|
|
@@ -3372,8 +4552,8 @@ var JsonSchema = (function (exports) {
|
|
|
3372
4552
|
|
|
3373
4553
|
var containsMinContainsMaxContains = { compile: compile$D, interpret: interpret$D, collectEvaluatedItems: collectEvaluatedItems$a };
|
|
3374
4554
|
|
|
3375
|
-
const { Core: Core$n, Schema: Schema$F } = lib$
|
|
3376
|
-
const Pact$6 = lib$
|
|
4555
|
+
const { Core: Core$n, Schema: Schema$F } = lib$2;
|
|
4556
|
+
const Pact$6 = lib$1;
|
|
3377
4557
|
|
|
3378
4558
|
|
|
3379
4559
|
const compile$C = async (schema, ast) => {
|
|
@@ -3388,8 +4568,8 @@ var JsonSchema = (function (exports) {
|
|
|
3388
4568
|
|
|
3389
4569
|
var definitions = { compile: compile$C, interpret: interpret$C };
|
|
3390
4570
|
|
|
3391
|
-
const { Core: Core$m, Schema: Schema$E, Instance: Instance$u } = lib$
|
|
3392
|
-
const Pact$5 = lib$
|
|
4571
|
+
const { Core: Core$m, Schema: Schema$E, Instance: Instance$u } = lib$2;
|
|
4572
|
+
const Pact$5 = lib$1;
|
|
3393
4573
|
|
|
3394
4574
|
|
|
3395
4575
|
const compile$B = (schema, ast) => Pact$5.pipeline([
|
|
@@ -3418,8 +4598,8 @@ var JsonSchema = (function (exports) {
|
|
|
3418
4598
|
|
|
3419
4599
|
var dependencies = { compile: compile$B, interpret: interpret$B };
|
|
3420
4600
|
|
|
3421
|
-
const { Schema: Schema$D, Instance: Instance$t } = lib$
|
|
3422
|
-
const Pact$4 = lib$
|
|
4601
|
+
const { Schema: Schema$D, Instance: Instance$t } = lib$2;
|
|
4602
|
+
const Pact$4 = lib$1;
|
|
3423
4603
|
|
|
3424
4604
|
|
|
3425
4605
|
const compile$A = (schema) => Pact$4.pipeline([
|
|
@@ -3438,8 +4618,8 @@ var JsonSchema = (function (exports) {
|
|
|
3438
4618
|
|
|
3439
4619
|
var dependentRequired = { compile: compile$A, interpret: interpret$A };
|
|
3440
4620
|
|
|
3441
|
-
const { Core: Core$l, Schema: Schema$C, Instance: Instance$s } = lib$
|
|
3442
|
-
const Pact$3 = lib$
|
|
4621
|
+
const { Core: Core$l, Schema: Schema$C, Instance: Instance$s } = lib$2;
|
|
4622
|
+
const Pact$3 = lib$1;
|
|
3443
4623
|
|
|
3444
4624
|
|
|
3445
4625
|
const compile$z = (schema, ast) => Pact$3.pipeline([
|
|
@@ -3469,7 +4649,7 @@ var JsonSchema = (function (exports) {
|
|
|
3469
4649
|
|
|
3470
4650
|
var dependentSchemas = { compile: compile$z, interpret: interpret$z, collectEvaluatedProperties: collectEvaluatedProperties$9 };
|
|
3471
4651
|
|
|
3472
|
-
const { Schema: Schema$B, Instance: Instance$r } = lib$
|
|
4652
|
+
const { Schema: Schema$B, Instance: Instance$r } = lib$2;
|
|
3473
4653
|
const jsonStringify$1 = fastestStableStringify;
|
|
3474
4654
|
|
|
3475
4655
|
|
|
@@ -3478,7 +4658,7 @@ var JsonSchema = (function (exports) {
|
|
|
3478
4658
|
|
|
3479
4659
|
var _enum = { compile: compile$y, interpret: interpret$y };
|
|
3480
4660
|
|
|
3481
|
-
const { Schema: Schema$A, Instance: Instance$q } = lib$
|
|
4661
|
+
const { Schema: Schema$A, Instance: Instance$q } = lib$2;
|
|
3482
4662
|
|
|
3483
4663
|
|
|
3484
4664
|
const compile$x = async (schema) => Schema$A.value(schema);
|
|
@@ -3486,7 +4666,7 @@ var JsonSchema = (function (exports) {
|
|
|
3486
4666
|
|
|
3487
4667
|
var exclusiveMaximum = { compile: compile$x, interpret: interpret$x };
|
|
3488
4668
|
|
|
3489
|
-
const { Schema: Schema$z, Instance: Instance$p } = lib$
|
|
4669
|
+
const { Schema: Schema$z, Instance: Instance$p } = lib$2;
|
|
3490
4670
|
|
|
3491
4671
|
|
|
3492
4672
|
const compile$w = async (schema) => Schema$z.value(schema);
|
|
@@ -3494,7 +4674,7 @@ var JsonSchema = (function (exports) {
|
|
|
3494
4674
|
|
|
3495
4675
|
var exclusiveMinimum = { compile: compile$w, interpret: interpret$w };
|
|
3496
4676
|
|
|
3497
|
-
const { Core: Core$k } = lib$
|
|
4677
|
+
const { Core: Core$k } = lib$2;
|
|
3498
4678
|
|
|
3499
4679
|
|
|
3500
4680
|
const compile$v = (schema, ast) => Core$k.compileSchema(schema, ast);
|
|
@@ -3514,7 +4694,7 @@ var JsonSchema = (function (exports) {
|
|
|
3514
4694
|
|
|
3515
4695
|
var _if = { compile: compile$v, interpret: interpret$v, collectEvaluatedProperties: collectEvaluatedProperties$8, collectEvaluatedItems: collectEvaluatedItems$9 };
|
|
3516
4696
|
|
|
3517
|
-
const { Core: Core$j, Schema: Schema$y } = lib$
|
|
4697
|
+
const { Core: Core$j, Schema: Schema$y } = lib$2;
|
|
3518
4698
|
|
|
3519
4699
|
|
|
3520
4700
|
const compile$u = async (schema, ast, parentSchema) => {
|
|
@@ -3558,7 +4738,7 @@ var JsonSchema = (function (exports) {
|
|
|
3558
4738
|
|
|
3559
4739
|
var then = { compile: compile$u, interpret: interpret$u, collectEvaluatedProperties: collectEvaluatedProperties$7, collectEvaluatedItems: collectEvaluatedItems$8 };
|
|
3560
4740
|
|
|
3561
|
-
const { Core: Core$i, Schema: Schema$x } = lib$
|
|
4741
|
+
const { Core: Core$i, Schema: Schema$x } = lib$2;
|
|
3562
4742
|
|
|
3563
4743
|
|
|
3564
4744
|
const compile$t = async (schema, ast, parentSchema) => {
|
|
@@ -3602,7 +4782,7 @@ var JsonSchema = (function (exports) {
|
|
|
3602
4782
|
|
|
3603
4783
|
var _else = { compile: compile$t, interpret: interpret$t, collectEvaluatedProperties: collectEvaluatedProperties$6, collectEvaluatedItems: collectEvaluatedItems$7 };
|
|
3604
4784
|
|
|
3605
|
-
const { Core: Core$h, Schema: Schema$w, Instance: Instance$o } = lib$
|
|
4785
|
+
const { Core: Core$h, Schema: Schema$w, Instance: Instance$o } = lib$2;
|
|
3606
4786
|
|
|
3607
4787
|
|
|
3608
4788
|
const compile$s = async (schema, ast) => {
|
|
@@ -3634,7 +4814,7 @@ var JsonSchema = (function (exports) {
|
|
|
3634
4814
|
|
|
3635
4815
|
var items = { compile: compile$s, interpret: interpret$s, collectEvaluatedItems: collectEvaluatedItems$6 };
|
|
3636
4816
|
|
|
3637
|
-
const { Core: Core$g, Schema: Schema$v, Instance: Instance$n } = lib$
|
|
4817
|
+
const { Core: Core$g, Schema: Schema$v, Instance: Instance$n } = lib$2;
|
|
3638
4818
|
|
|
3639
4819
|
|
|
3640
4820
|
const compile$r = async (schema, ast, parentSchema) => {
|
|
@@ -3658,7 +4838,7 @@ var JsonSchema = (function (exports) {
|
|
|
3658
4838
|
|
|
3659
4839
|
var items202012 = { compile: compile$r, interpret: interpret$r, collectEvaluatedItems: collectEvaluatedItems$5 };
|
|
3660
4840
|
|
|
3661
|
-
const { Schema: Schema$u, Instance: Instance$m } = lib$
|
|
4841
|
+
const { Schema: Schema$u, Instance: Instance$m } = lib$2;
|
|
3662
4842
|
|
|
3663
4843
|
|
|
3664
4844
|
const compile$q = (schema) => Schema$u.value(schema);
|
|
@@ -3666,7 +4846,7 @@ var JsonSchema = (function (exports) {
|
|
|
3666
4846
|
|
|
3667
4847
|
var maxItems = { compile: compile$q, interpret: interpret$q };
|
|
3668
4848
|
|
|
3669
|
-
const { Schema: Schema$t, Instance: Instance$l } = lib$
|
|
4849
|
+
const { Schema: Schema$t, Instance: Instance$l } = lib$2;
|
|
3670
4850
|
|
|
3671
4851
|
|
|
3672
4852
|
const compile$p = (schema) => Schema$t.value(schema);
|
|
@@ -3674,7 +4854,7 @@ var JsonSchema = (function (exports) {
|
|
|
3674
4854
|
|
|
3675
4855
|
var maxLength = { compile: compile$p, interpret: interpret$p };
|
|
3676
4856
|
|
|
3677
|
-
const { Schema: Schema$s, Instance: Instance$k } = lib$
|
|
4857
|
+
const { Schema: Schema$s, Instance: Instance$k } = lib$2;
|
|
3678
4858
|
|
|
3679
4859
|
|
|
3680
4860
|
const compile$o = (schema) => Schema$s.value(schema);
|
|
@@ -3682,7 +4862,7 @@ var JsonSchema = (function (exports) {
|
|
|
3682
4862
|
|
|
3683
4863
|
var maxLength6 = { compile: compile$o, interpret: interpret$o };
|
|
3684
4864
|
|
|
3685
|
-
const { Schema: Schema$r, Instance: Instance$j } = lib$
|
|
4865
|
+
const { Schema: Schema$r, Instance: Instance$j } = lib$2;
|
|
3686
4866
|
|
|
3687
4867
|
|
|
3688
4868
|
const compile$n = (schema) => Schema$r.value(schema);
|
|
@@ -3690,7 +4870,7 @@ var JsonSchema = (function (exports) {
|
|
|
3690
4870
|
|
|
3691
4871
|
var maxProperties = { compile: compile$n, interpret: interpret$n };
|
|
3692
4872
|
|
|
3693
|
-
const { Schema: Schema$q, Instance: Instance$i } = lib$
|
|
4873
|
+
const { Schema: Schema$q, Instance: Instance$i } = lib$2;
|
|
3694
4874
|
|
|
3695
4875
|
|
|
3696
4876
|
const compile$m = async (schema, ast, parentSchema) => {
|
|
@@ -3711,7 +4891,7 @@ var JsonSchema = (function (exports) {
|
|
|
3711
4891
|
|
|
3712
4892
|
var maximumExclusiveMaximum = { compile: compile$m, interpret: interpret$m };
|
|
3713
4893
|
|
|
3714
|
-
const { Schema: Schema$p, Instance: Instance$h } = lib$
|
|
4894
|
+
const { Schema: Schema$p, Instance: Instance$h } = lib$2;
|
|
3715
4895
|
|
|
3716
4896
|
|
|
3717
4897
|
const compile$l = async (schema) => Schema$p.value(schema);
|
|
@@ -3719,7 +4899,7 @@ var JsonSchema = (function (exports) {
|
|
|
3719
4899
|
|
|
3720
4900
|
var maximum = { compile: compile$l, interpret: interpret$l };
|
|
3721
4901
|
|
|
3722
|
-
const { Schema: Schema$o, Instance: Instance$g } = lib$
|
|
4902
|
+
const { Schema: Schema$o, Instance: Instance$g } = lib$2;
|
|
3723
4903
|
|
|
3724
4904
|
|
|
3725
4905
|
const compile$k = (schema) => Schema$o.value(schema);
|
|
@@ -3727,7 +4907,7 @@ var JsonSchema = (function (exports) {
|
|
|
3727
4907
|
|
|
3728
4908
|
var minItems = { compile: compile$k, interpret: interpret$k };
|
|
3729
4909
|
|
|
3730
|
-
const { Schema: Schema$n, Instance: Instance$f } = lib$
|
|
4910
|
+
const { Schema: Schema$n, Instance: Instance$f } = lib$2;
|
|
3731
4911
|
|
|
3732
4912
|
|
|
3733
4913
|
const compile$j = (schema) => Schema$n.value(schema);
|
|
@@ -3735,7 +4915,7 @@ var JsonSchema = (function (exports) {
|
|
|
3735
4915
|
|
|
3736
4916
|
var minLength = { compile: compile$j, interpret: interpret$j };
|
|
3737
4917
|
|
|
3738
|
-
const { Schema: Schema$m, Instance: Instance$e } = lib$
|
|
4918
|
+
const { Schema: Schema$m, Instance: Instance$e } = lib$2;
|
|
3739
4919
|
|
|
3740
4920
|
|
|
3741
4921
|
const compile$i = (schema) => Schema$m.value(schema);
|
|
@@ -3743,7 +4923,7 @@ var JsonSchema = (function (exports) {
|
|
|
3743
4923
|
|
|
3744
4924
|
var minLength6 = { compile: compile$i, interpret: interpret$i };
|
|
3745
4925
|
|
|
3746
|
-
const { Schema: Schema$l, Instance: Instance$d } = lib$
|
|
4926
|
+
const { Schema: Schema$l, Instance: Instance$d } = lib$2;
|
|
3747
4927
|
|
|
3748
4928
|
|
|
3749
4929
|
const compile$h = (schema) => Schema$l.value(schema);
|
|
@@ -3751,7 +4931,7 @@ var JsonSchema = (function (exports) {
|
|
|
3751
4931
|
|
|
3752
4932
|
var minProperties = { compile: compile$h, interpret: interpret$h };
|
|
3753
4933
|
|
|
3754
|
-
const { Schema: Schema$k, Instance: Instance$c } = lib$
|
|
4934
|
+
const { Schema: Schema$k, Instance: Instance$c } = lib$2;
|
|
3755
4935
|
|
|
3756
4936
|
|
|
3757
4937
|
const compile$g = async (schema, ast, parentSchema) => {
|
|
@@ -3772,7 +4952,7 @@ var JsonSchema = (function (exports) {
|
|
|
3772
4952
|
|
|
3773
4953
|
var minimumExclusiveMinimum = { compile: compile$g, interpret: interpret$g };
|
|
3774
4954
|
|
|
3775
|
-
const { Schema: Schema$j, Instance: Instance$b } = lib$
|
|
4955
|
+
const { Schema: Schema$j, Instance: Instance$b } = lib$2;
|
|
3776
4956
|
|
|
3777
4957
|
|
|
3778
4958
|
const compile$f = async (schema) => Schema$j.value(schema);
|
|
@@ -3780,7 +4960,7 @@ var JsonSchema = (function (exports) {
|
|
|
3780
4960
|
|
|
3781
4961
|
var minimum = { compile: compile$f, interpret: interpret$f };
|
|
3782
4962
|
|
|
3783
|
-
const { Schema: Schema$i, Instance: Instance$a } = lib$
|
|
4963
|
+
const { Schema: Schema$i, Instance: Instance$a } = lib$2;
|
|
3784
4964
|
|
|
3785
4965
|
|
|
3786
4966
|
const compile$e = (schema) => Schema$i.value(schema);
|
|
@@ -3798,7 +4978,7 @@ var JsonSchema = (function (exports) {
|
|
|
3798
4978
|
|
|
3799
4979
|
var multipleOf = { compile: compile$e, interpret: interpret$e };
|
|
3800
4980
|
|
|
3801
|
-
const { Core: Core$f } = lib$
|
|
4981
|
+
const { Core: Core$f } = lib$2;
|
|
3802
4982
|
|
|
3803
4983
|
|
|
3804
4984
|
const compile$d = Core$f.compileSchema;
|
|
@@ -3806,7 +4986,7 @@ var JsonSchema = (function (exports) {
|
|
|
3806
4986
|
|
|
3807
4987
|
var not = { compile: compile$d, interpret: interpret$d };
|
|
3808
4988
|
|
|
3809
|
-
const { Core: Core$e, Schema: Schema$h } = lib$
|
|
4989
|
+
const { Core: Core$e, Schema: Schema$h } = lib$2;
|
|
3810
4990
|
|
|
3811
4991
|
|
|
3812
4992
|
const compile$c = async (schema, ast) => {
|
|
@@ -3855,7 +5035,7 @@ var JsonSchema = (function (exports) {
|
|
|
3855
5035
|
|
|
3856
5036
|
var oneOf = { compile: compile$c, interpret: interpret$c, collectEvaluatedProperties: collectEvaluatedProperties$5, collectEvaluatedItems: collectEvaluatedItems$4 };
|
|
3857
5037
|
|
|
3858
|
-
const { Schema: Schema$g, Instance: Instance$9 } = lib$
|
|
5038
|
+
const { Schema: Schema$g, Instance: Instance$9 } = lib$2;
|
|
3859
5039
|
|
|
3860
5040
|
|
|
3861
5041
|
const compile$b = (schema) => new RegExp(Schema$g.value(schema), "u");
|
|
@@ -3863,8 +5043,8 @@ var JsonSchema = (function (exports) {
|
|
|
3863
5043
|
|
|
3864
5044
|
var pattern = { compile: compile$b, interpret: interpret$b };
|
|
3865
5045
|
|
|
3866
|
-
const { Core: Core$d, Schema: Schema$f, Instance: Instance$8 } = lib$
|
|
3867
|
-
const Pact$2 = lib$
|
|
5046
|
+
const { Core: Core$d, Schema: Schema$f, Instance: Instance$8 } = lib$2;
|
|
5047
|
+
const Pact$2 = lib$1;
|
|
3868
5048
|
|
|
3869
5049
|
|
|
3870
5050
|
const compile$a = (schema, ast) => Pact$2.pipeline([
|
|
@@ -3901,8 +5081,8 @@ var JsonSchema = (function (exports) {
|
|
|
3901
5081
|
|
|
3902
5082
|
var common = { isObject, escapeRegExp: escapeRegExp$1, splitUrl: splitUrl$1 };
|
|
3903
5083
|
|
|
3904
|
-
const { Core: Core$c, Schema: Schema$e, Instance: Instance$7 } = lib$
|
|
3905
|
-
const Pact$1 = lib$
|
|
5084
|
+
const { Core: Core$c, Schema: Schema$e, Instance: Instance$7 } = lib$2;
|
|
5085
|
+
const Pact$1 = lib$1;
|
|
3906
5086
|
const { escapeRegExp } = common;
|
|
3907
5087
|
|
|
3908
5088
|
|
|
@@ -3927,7 +5107,7 @@ var JsonSchema = (function (exports) {
|
|
|
3927
5107
|
|
|
3928
5108
|
var properties = { compile: compile$9, interpret: interpret$9, collectEvaluatedProperties: collectEvaluatedProperties$3 };
|
|
3929
5109
|
|
|
3930
|
-
const { Core: Core$b, Instance: Instance$6 } = lib$
|
|
5110
|
+
const { Core: Core$b, Instance: Instance$6 } = lib$2;
|
|
3931
5111
|
|
|
3932
5112
|
|
|
3933
5113
|
const compile$8 = (schema, ast) => Core$b.compileSchema(schema, ast);
|
|
@@ -3939,7 +5119,7 @@ var JsonSchema = (function (exports) {
|
|
|
3939
5119
|
|
|
3940
5120
|
var propertyNames = { compile: compile$8, interpret: interpret$8 };
|
|
3941
5121
|
|
|
3942
|
-
const { Core: Core$a, Schema: Schema$d } = lib$
|
|
5122
|
+
const { Core: Core$a, Schema: Schema$d } = lib$2;
|
|
3943
5123
|
const { splitUrl } = common;
|
|
3944
5124
|
|
|
3945
5125
|
|
|
@@ -3964,7 +5144,7 @@ var JsonSchema = (function (exports) {
|
|
|
3964
5144
|
|
|
3965
5145
|
var dynamicRef = { compile: compile$7, interpret: interpret$7, collectEvaluatedProperties: collectEvaluatedProperties$2, collectEvaluatedItems: collectEvaluatedItems$3 };
|
|
3966
5146
|
|
|
3967
|
-
const { Core: Core$9, Schema: Schema$c } = lib$
|
|
5147
|
+
const { Core: Core$9, Schema: Schema$c } = lib$2;
|
|
3968
5148
|
|
|
3969
5149
|
|
|
3970
5150
|
const compile$6 = async (ref, ast) => {
|
|
@@ -3978,7 +5158,7 @@ var JsonSchema = (function (exports) {
|
|
|
3978
5158
|
|
|
3979
5159
|
var ref = { compile: compile$6, interpret: interpret$6, collectEvaluatedProperties: collectEvaluatedProperties$1, collectEvaluatedItems: collectEvaluatedItems$2 };
|
|
3980
5160
|
|
|
3981
|
-
const { Schema: Schema$b, Instance: Instance$5 } = lib$
|
|
5161
|
+
const { Schema: Schema$b, Instance: Instance$5 } = lib$2;
|
|
3982
5162
|
|
|
3983
5163
|
|
|
3984
5164
|
const compile$5 = (schema) => Schema$b.value(schema);
|
|
@@ -3989,8 +5169,8 @@ var JsonSchema = (function (exports) {
|
|
|
3989
5169
|
|
|
3990
5170
|
var required = { compile: compile$5, interpret: interpret$5 };
|
|
3991
5171
|
|
|
3992
|
-
const { Core: Core$8, Schema: Schema$a, Instance: Instance$4 } = lib$
|
|
3993
|
-
const Pact = lib$
|
|
5172
|
+
const { Core: Core$8, Schema: Schema$a, Instance: Instance$4 } = lib$2;
|
|
5173
|
+
const Pact = lib$1;
|
|
3994
5174
|
|
|
3995
5175
|
|
|
3996
5176
|
const compile$4 = (schema, ast) => {
|
|
@@ -4014,7 +5194,7 @@ var JsonSchema = (function (exports) {
|
|
|
4014
5194
|
|
|
4015
5195
|
var tupleItems = { compile: compile$4, interpret: interpret$4, collectEvaluatedItems: collectEvaluatedItems$1 };
|
|
4016
5196
|
|
|
4017
|
-
const { Schema: Schema$9, Instance: Instance$3 } = lib$
|
|
5197
|
+
const { Schema: Schema$9, Instance: Instance$3 } = lib$2;
|
|
4018
5198
|
|
|
4019
5199
|
|
|
4020
5200
|
const compile$3 = (schema) => Schema$9.value(schema);
|
|
@@ -4022,7 +5202,7 @@ var JsonSchema = (function (exports) {
|
|
|
4022
5202
|
|
|
4023
5203
|
var type = { compile: compile$3, interpret: interpret$3 };
|
|
4024
5204
|
|
|
4025
|
-
const { Core: Core$7, Schema: Schema$8, Instance: Instance$2 } = lib$
|
|
5205
|
+
const { Core: Core$7, Schema: Schema$8, Instance: Instance$2 } = lib$2;
|
|
4026
5206
|
|
|
4027
5207
|
|
|
4028
5208
|
const compile$2 = async (schema, ast, parentSchema) => {
|
|
@@ -4046,7 +5226,7 @@ var JsonSchema = (function (exports) {
|
|
|
4046
5226
|
|
|
4047
5227
|
var unevaluatedItems = { compile: compile$2, interpret: interpret$2, collectEvaluatedItems };
|
|
4048
5228
|
|
|
4049
|
-
const { Core: Core$6, Schema: Schema$7, Instance: Instance$1 } = lib$
|
|
5229
|
+
const { Core: Core$6, Schema: Schema$7, Instance: Instance$1 } = lib$2;
|
|
4050
5230
|
|
|
4051
5231
|
|
|
4052
5232
|
const compile$1 = async (schema, ast, parentSchema) => {
|
|
@@ -4071,7 +5251,7 @@ var JsonSchema = (function (exports) {
|
|
|
4071
5251
|
|
|
4072
5252
|
var unevaluatedProperties = { compile: compile$1, interpret: interpret$1, collectEvaluatedProperties };
|
|
4073
5253
|
|
|
4074
|
-
const { Schema: Schema$6, Instance } = lib$
|
|
5254
|
+
const { Schema: Schema$6, Instance } = lib$2;
|
|
4075
5255
|
const jsonStringify = fastestStableStringify;
|
|
4076
5256
|
|
|
4077
5257
|
|
|
@@ -4088,7 +5268,7 @@ var JsonSchema = (function (exports) {
|
|
|
4088
5268
|
|
|
4089
5269
|
var uniqueItems = { compile, interpret };
|
|
4090
5270
|
|
|
4091
|
-
const { Keywords: Keywords$1 } = lib$
|
|
5271
|
+
const { Keywords: Keywords$1 } = lib$2;
|
|
4092
5272
|
|
|
4093
5273
|
|
|
4094
5274
|
var keywords$5 = {
|
|
@@ -4294,7 +5474,7 @@ var JsonSchema = (function (exports) {
|
|
|
4294
5474
|
"default": {}
|
|
4295
5475
|
}`;
|
|
4296
5476
|
|
|
4297
|
-
const { Core: Core$5, Schema: Schema$5 } = lib$
|
|
5477
|
+
const { Core: Core$5, Schema: Schema$5 } = lib$2;
|
|
4298
5478
|
const keywords$4 = keywords$5;
|
|
4299
5479
|
const metaSchema$4 = schema$4;
|
|
4300
5480
|
|
|
@@ -4496,7 +5676,7 @@ var JsonSchema = (function (exports) {
|
|
|
4496
5676
|
"default": {}
|
|
4497
5677
|
}`;
|
|
4498
5678
|
|
|
4499
|
-
const { Core: Core$4, Schema: Schema$4 } = lib$
|
|
5679
|
+
const { Core: Core$4, Schema: Schema$4 } = lib$2;
|
|
4500
5680
|
const keywords$3 = keywords$5;
|
|
4501
5681
|
const metaSchema$3 = schema$3;
|
|
4502
5682
|
|
|
@@ -4721,7 +5901,7 @@ var JsonSchema = (function (exports) {
|
|
|
4721
5901
|
"default": true
|
|
4722
5902
|
}`;
|
|
4723
5903
|
|
|
4724
|
-
const { Core: Core$3, Schema: Schema$3 } = lib$
|
|
5904
|
+
const { Core: Core$3, Schema: Schema$3 } = lib$2;
|
|
4725
5905
|
const keywords$2 = keywords$5;
|
|
4726
5906
|
const metaSchema$2 = schema$2;
|
|
4727
5907
|
|
|
@@ -5104,7 +6284,7 @@ var JsonSchema = (function (exports) {
|
|
|
5104
6284
|
}
|
|
5105
6285
|
}`;
|
|
5106
6286
|
|
|
5107
|
-
const { Core: Core$2, Schema: Schema$2 } = lib$
|
|
6287
|
+
const { Core: Core$2, Schema: Schema$2 } = lib$2;
|
|
5108
6288
|
const keywords$1 = keywords$5;
|
|
5109
6289
|
const metaSchema$1 = schema$1;
|
|
5110
6290
|
const coreMetaSchema$1 = core$1;
|
|
@@ -5551,7 +6731,7 @@ var JsonSchema = (function (exports) {
|
|
|
5551
6731
|
}
|
|
5552
6732
|
}`;
|
|
5553
6733
|
|
|
5554
|
-
const { Core: Core$1, Schema: Schema$1 } = lib$
|
|
6734
|
+
const { Core: Core$1, Schema: Schema$1 } = lib$2;
|
|
5555
6735
|
const keywords = keywords$5;
|
|
5556
6736
|
const metaSchema = schema;
|
|
5557
6737
|
const coreMetaSchema = core;
|
|
@@ -5655,7 +6835,7 @@ var JsonSchema = (function (exports) {
|
|
|
5655
6835
|
"unevaluatedProperties": keywords.unevaluatedProperties
|
|
5656
6836
|
});
|
|
5657
6837
|
|
|
5658
|
-
const { Core, Schema, InvalidSchemaError } = lib$
|
|
6838
|
+
const { Core, Schema, InvalidSchemaError } = lib$2;
|
|
5659
6839
|
const Keywords = keywords$5;
|
|
5660
6840
|
|
|
5661
6841
|
|