@hyperjump/json-schema 0.23.4 → 0.23.5

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.
@@ -43,7 +43,11 @@ define(['exports'], (function (exports) { 'use strict';
43
43
  };
44
44
  }
45
45
 
46
- var pubsub = {exports: {}};
46
+ var pubsubExports = {};
47
+ var pubsub = {
48
+ get exports(){ return pubsubExports; },
49
+ set exports(v){ pubsubExports = v; },
50
+ };
47
51
 
48
52
  /**
49
53
  * Copyright (c) 2010,2011,2012,2013,2014 Morgan Roderick http://roderick.dk
@@ -397,9 +401,13 @@ define(['exports'], (function (exports) { 'use strict';
397
401
  return result;
398
402
  };
399
403
  }));
400
- } (pubsub, pubsub.exports));
404
+ } (pubsub, pubsubExports));
401
405
 
402
- var uri_all = {exports: {}};
406
+ var uri_allExports = {};
407
+ var uri_all = {
408
+ get exports(){ return uri_allExports; },
409
+ set exports(v){ uri_allExports = v; },
410
+ };
403
411
 
404
412
  /** @license URI.js v4.4.1 (c) 2011 Gary Court. License: http://github.com/garycourt/uri-js */
405
413
 
@@ -1805,9 +1813,9 @@ define(['exports'], (function (exports) { 'use strict';
1805
1813
 
1806
1814
  })));
1807
1815
 
1808
- } (uri_all, uri_all.exports));
1816
+ } (uri_all, uri_allExports));
1809
1817
 
1810
- const URI = uri_all.exports;
1818
+ const URI = uri_allExports;
1811
1819
 
1812
1820
 
1813
1821
  const isObject$1 = (value) => typeof value === "object" && !Array.isArray(value) && value !== null;
@@ -1903,116 +1911,138 @@ define(['exports'], (function (exports) { 'use strict';
1903
1911
 
1904
1912
  const nil$2 = "";
1905
1913
 
1906
- const compile$N = (pointer) => {
1914
+ const EXISTS = Symbol("EXISTS");
1915
+
1916
+ const segmentGenerator = (pointer) => {
1907
1917
  if (pointer.length > 0 && pointer[0] !== "/") {
1908
1918
  throw Error("Invalid JSON Pointer");
1909
1919
  }
1910
1920
 
1911
- return pointer.split("/").slice(1).map(unescape);
1912
- };
1921
+ let segmentStart = 1;
1922
+ let segmentEnd = 0;
1913
1923
 
1914
- const get$2 = (pointer, value = undefined) => {
1915
- const ptr = compile$N(pointer);
1924
+ return (mode) => {
1925
+ if (mode === EXISTS) {
1926
+ return segmentEnd < pointer.length;
1927
+ }
1916
1928
 
1917
- const fn = (value) => ptr.reduce(([value, pointer], segment) => {
1918
- return [applySegment(value, segment, pointer), append(segment, pointer)];
1919
- }, [value, ""])[0];
1929
+ if (segmentEnd >= pointer.length) {
1930
+ return;
1931
+ }
1932
+
1933
+ const position = pointer.indexOf("/", segmentStart);
1934
+ segmentEnd = position === -1 ? pointer.length : position;
1935
+ const segment = unescape(pointer.slice(segmentStart, segmentEnd));
1936
+ segmentStart = segmentEnd + 1;
1920
1937
 
1921
- return value === undefined ? fn : fn(value);
1938
+ return segment;
1939
+ };
1940
+ };
1941
+
1942
+ const get$2 = (pointer, subject = undefined) => {
1943
+ const nextSegment = segmentGenerator(pointer);
1944
+ const fn = (subject) => _get(nextSegment, subject, nil$2);
1945
+ return subject === undefined ? fn : fn(subject);
1946
+ };
1947
+
1948
+ const _get = (nextSegment, subject, cursor) => {
1949
+ if (!nextSegment(EXISTS)) {
1950
+ return subject;
1951
+ } else {
1952
+ const segment = nextSegment();
1953
+ return _get(nextSegment, applySegment(subject, segment, cursor), append(segment, cursor));
1954
+ }
1922
1955
  };
1923
1956
 
1924
1957
  const set = (pointer, subject = undefined, value = undefined) => {
1925
- const ptr = compile$N(pointer);
1926
- const fn = curry$a((subject, value) => _set(ptr, subject, value, nil$2));
1958
+ const nextSegment = segmentGenerator(pointer);
1959
+ const fn = curry$a((subject, value) => _set(nextSegment, subject, value, nil$2));
1927
1960
  return subject === undefined ? fn : fn(subject, value);
1928
1961
  };
1929
1962
 
1930
- const _set = (pointer, subject, value, cursor) => {
1931
- if (pointer.length === 0) {
1963
+ const _set = (nextSegment, subject, value, cursor) => {
1964
+ const segment = nextSegment();
1965
+ if (segment === undefined) {
1932
1966
  return value;
1933
- } else if (pointer.length > 1) {
1967
+ } else if (nextSegment(EXISTS)) {
1934
1968
  if (Array.isArray(subject)) {
1935
- const index = pointer.shift();
1936
1969
  const clonedSubject = [...subject];
1937
- clonedSubject[index] = _set(pointer, applySegment(subject, index, cursor), value, append(index, cursor));
1970
+ clonedSubject[segment] = _set(nextSegment, applySegment(subject, segment, cursor), value, append(segment, cursor));
1938
1971
  return clonedSubject;
1939
1972
  } else {
1940
- const segment = pointer.shift();
1941
- return { ...subject, [segment]: _set(pointer, applySegment(subject, segment, cursor), value, append(segment, cursor)) };
1973
+ return { ...subject, [segment]: _set(nextSegment, applySegment(subject, segment, cursor), value, append(segment, cursor)) };
1942
1974
  }
1943
1975
  } else if (Array.isArray(subject)) {
1944
1976
  const clonedSubject = [...subject];
1945
- const segment = computeSegment(subject, pointer[0]);
1946
- clonedSubject[segment] = value;
1977
+ clonedSubject[computeSegment(subject, segment)] = value;
1947
1978
  return clonedSubject;
1948
1979
  } else if (typeof subject === "object" && subject !== null) {
1949
- return { ...subject, [pointer[0]]: value };
1980
+ return { ...subject, [segment]: value };
1950
1981
  } else {
1951
- return applySegment(subject, pointer[0], cursor);
1982
+ return applySegment(subject, segment, cursor);
1952
1983
  }
1953
1984
  };
1954
1985
 
1955
1986
  const assign = (pointer, subject = undefined, value = undefined) => {
1956
- const ptr = compile$N(pointer);
1957
- const fn = curry$a((subject, value) => _assign(ptr, subject, value, nil$2));
1987
+ const nextSegment = segmentGenerator(pointer);
1988
+ const fn = curry$a((subject, value) => _assign(nextSegment, subject, value, nil$2));
1958
1989
  return subject === undefined ? fn : fn(subject, value);
1959
1990
  };
1960
1991
 
1961
- const _assign = (pointer, subject, value, cursor) => {
1962
- if (pointer.length === 0) {
1992
+ const _assign = (nextSegment, subject, value, cursor) => {
1993
+ const segment = nextSegment();
1994
+ if (segment === undefined) {
1963
1995
  return;
1964
- } else if (pointer.length === 1 && !isScalar(subject)) {
1965
- const segment = computeSegment(subject, pointer[0]);
1966
- subject[segment] = value;
1996
+ } else if (!nextSegment(EXISTS) && !isScalar(subject)) {
1997
+ subject[computeSegment(subject, segment)] = value;
1967
1998
  } else {
1968
- const segment = pointer.shift();
1969
- _assign(pointer, applySegment(subject, segment, cursor), value, append(segment, cursor));
1999
+ _assign(nextSegment, applySegment(subject, segment, cursor), value, append(segment, cursor));
1970
2000
  }
1971
2001
  };
1972
2002
 
1973
2003
  const unset = (pointer, subject = undefined) => {
1974
- const ptr = compile$N(pointer);
1975
- const fn = (subject) => _unset(ptr, subject, nil$2);
2004
+ const nextSegment = segmentGenerator(pointer);
2005
+ const fn = (subject) => _unset(nextSegment, subject, nil$2);
1976
2006
  return subject === undefined ? fn : fn(subject);
1977
2007
  };
1978
2008
 
1979
- const _unset = (pointer, subject, cursor) => {
1980
- if (pointer.length == 0) {
1981
- return undefined;
1982
- } else if (pointer.length > 1) {
1983
- const segment = pointer.shift();
2009
+ const _unset = (nextSegment, subject, cursor) => {
2010
+ const segment = nextSegment();
2011
+ if (segment === undefined) {
2012
+ return;
2013
+ } else if (nextSegment(EXISTS)) {
1984
2014
  const value = applySegment(subject, segment, cursor);
1985
- return { ...subject, [segment]: _unset(pointer, value, append(segment, cursor)) };
2015
+ return { ...subject, [segment]: _unset(nextSegment, value, append(segment, cursor)) };
1986
2016
  } else if (Array.isArray(subject)) {
1987
- return subject.filter((_, ndx) => ndx != pointer[0]);
2017
+ const clonedSubject = [...subject];
2018
+ delete clonedSubject[computeSegment(subject, segment)];
2019
+ return clonedSubject;
1988
2020
  } else if (typeof subject === "object" && subject !== null) {
1989
2021
  // eslint-disable-next-line no-unused-vars
1990
- const { [pointer[0]]: _, ...result } = subject;
2022
+ const { [segment]: _, ...result } = subject;
1991
2023
  return result;
1992
2024
  } else {
1993
- return applySegment(subject, pointer[0], cursor);
2025
+ return applySegment(subject, segment, cursor);
1994
2026
  }
1995
2027
  };
1996
2028
 
1997
2029
  const remove = (pointer, subject = undefined) => {
1998
- const ptr = compile$N(pointer);
1999
- const fn = (subject) => _remove(ptr, subject, nil$2);
2030
+ const nextSegment = segmentGenerator(pointer);
2031
+ const fn = (subject) => _remove(nextSegment, subject, nil$2);
2000
2032
  return subject === undefined ? fn : fn(subject);
2001
2033
  };
2002
2034
 
2003
- const _remove = (pointer, subject, cursor) => {
2004
- if (pointer.length === 0) {
2035
+ const _remove = (nextSegment, subject, cursor) => {
2036
+ const segment = nextSegment();
2037
+ if (segment === undefined) {
2005
2038
  return;
2006
- } else if (pointer.length > 1) {
2007
- const segment = pointer.shift();
2039
+ } else if (nextSegment(EXISTS)) {
2008
2040
  const value = applySegment(subject, segment, cursor);
2009
- _remove(pointer, value, append(segment, cursor));
2010
- } else if (Array.isArray(subject)) {
2011
- subject.splice(pointer[0], 1);
2012
- } else if (typeof subject === "object" && subject !== null) {
2013
- delete subject[pointer[0]];
2041
+ _remove(nextSegment, value, append(segment, cursor));
2042
+ } else if (!isScalar(subject)) {
2043
+ delete subject[segment];
2014
2044
  } else {
2015
- applySegment(subject, pointer[0], cursor);
2045
+ applySegment(subject, segment, cursor);
2016
2046
  }
2017
2047
  };
2018
2048
 
@@ -2233,7 +2263,11 @@ define(['exports'], (function (exports) { 'use strict';
2233
2263
  allValues: allValues
2234
2264
  };
2235
2265
 
2236
- var moo$1 = {exports: {}};
2266
+ var mooExports = {};
2267
+ var moo$1 = {
2268
+ get exports(){ return mooExports; },
2269
+ set exports(v){ mooExports = v; },
2270
+ };
2237
2271
 
2238
2272
  (function (module) {
2239
2273
  (function(root, factory) {
@@ -2877,7 +2911,7 @@ define(['exports'], (function (exports) { 'use strict';
2877
2911
  }));
2878
2912
  } (moo$1));
2879
2913
 
2880
- const moo = moo$1.exports;
2914
+ const moo = mooExports;
2881
2915
 
2882
2916
 
2883
2917
  const digit = `[0-9]`;
@@ -3140,8 +3174,8 @@ define(['exports'], (function (exports) { 'use strict';
3140
3174
  * obs-text = %x80-FF
3141
3175
  * quoted-pair = "\" ( HTAB / SP / VCHAR / obs-text )
3142
3176
  */
3143
- var PARAM_REGEXP = /; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g;
3144
- var TEXT_REGEXP = /^[\u000b\u0020-\u007e\u0080-\u00ff]+$/;
3177
+ var PARAM_REGEXP = /; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g; // eslint-disable-line no-control-regex
3178
+ var TEXT_REGEXP = /^[\u000b\u0020-\u007e\u0080-\u00ff]+$/; // eslint-disable-line no-control-regex
3145
3179
  var TOKEN_REGEXP = /^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;
3146
3180
 
3147
3181
  /**
@@ -3150,7 +3184,7 @@ define(['exports'], (function (exports) { 'use strict';
3150
3184
  * quoted-pair = "\" ( HTAB / SP / VCHAR / obs-text )
3151
3185
  * obs-text = %x80-FF
3152
3186
  */
3153
- var QESC_REGEXP = /\\([\u000b\u0020-\u00ff])/g;
3187
+ var QESC_REGEXP = /\\([\u000b\u0020-\u00ff])/g; // eslint-disable-line no-control-regex
3154
3188
 
3155
3189
  /**
3156
3190
  * RegExp to match chars that must be quoted-pair in RFC 7230 sec 3.2.6
@@ -3239,7 +3273,7 @@ define(['exports'], (function (exports) { 'use strict';
3239
3273
 
3240
3274
  var index = header.indexOf(';');
3241
3275
  var type = index !== -1
3242
- ? header.substr(0, index).trim()
3276
+ ? header.slice(0, index).trim()
3243
3277
  : header.trim();
3244
3278
 
3245
3279
  if (!TYPE_REGEXP.test(type)) {
@@ -3265,11 +3299,14 @@ define(['exports'], (function (exports) { 'use strict';
3265
3299
  key = match[1].toLowerCase();
3266
3300
  value = match[2];
3267
3301
 
3268
- if (value[0] === '"') {
3269
- // remove quotes and escapes
3270
- value = value
3271
- .substr(1, value.length - 2)
3272
- .replace(QESC_REGEXP, '$1');
3302
+ if (value.charCodeAt(0) === 0x22 /* " */) {
3303
+ // remove quotes
3304
+ value = value.slice(1, -1);
3305
+
3306
+ // remove escapes
3307
+ if (value.indexOf('\\') !== -1) {
3308
+ value = value.replace(QESC_REGEXP, '$1');
3309
+ }
3273
3310
  }
3274
3311
 
3275
3312
  obj.parameters[key] = value;
@@ -3718,13 +3755,13 @@ define(['exports'], (function (exports) { 'use strict';
3718
3755
  toSchema
3719
3756
  };
3720
3757
 
3721
- class InvalidSchemaError$3 extends Error {
3758
+ let InvalidSchemaError$3 = class InvalidSchemaError extends Error {
3722
3759
  constructor(output) {
3723
3760
  super("Invalid Schema");
3724
3761
  this.name = this.constructor.name;
3725
3762
  this.output = output;
3726
3763
  }
3727
- }
3764
+ };
3728
3765
 
3729
3766
  var invalidSchemaError = InvalidSchemaError$3;
3730
3767
 
@@ -3737,7 +3774,7 @@ define(['exports'], (function (exports) { 'use strict';
3737
3774
  var metaData$4 = { compile: compile$M, interpret: interpret$M };
3738
3775
 
3739
3776
  const curry = justCurryIt$1;
3740
- const PubSub$1 = pubsub.exports;
3777
+ const PubSub$1 = pubsubExports;
3741
3778
  const { resolveUrl } = common$1;
3742
3779
  const Instance$C = instance;
3743
3780
  const Schema$O = schema$5;
@@ -3826,7 +3863,13 @@ define(['exports'], (function (exports) { 'use strict';
3826
3863
  };
3827
3864
 
3828
3865
  const _keywords = {};
3829
- const getKeyword = (id) => _keywords[id] || metaData$3;
3866
+ const getKeyword = (id) => {
3867
+ if (!_keywords[id]) {
3868
+ addKeyword(id, metaData$3);
3869
+ }
3870
+
3871
+ return _keywords[id];
3872
+ };
3830
3873
  const hasKeyword = (id) => id in _keywords;
3831
3874
  const addKeyword = (id, keywordHandler) => {
3832
3875
  _keywords[id] = {
@@ -3943,7 +3986,7 @@ define(['exports'], (function (exports) { 'use strict';
3943
3986
  };
3944
3987
 
3945
3988
  const Pact$9 = lib$3;
3946
- const PubSub = pubsub.exports;
3989
+ const PubSub = pubsubExports;
3947
3990
  const Core$x = core$2;
3948
3991
  const Instance$B = instance;
3949
3992
  const Schema$N = schema$5;
@@ -4104,7 +4147,16 @@ define(['exports'], (function (exports) { 'use strict';
4104
4147
  };
4105
4148
 
4106
4149
  const collectEvaluatedItems$d = (keywordValue, instance, ast, dynamicAnchors) => {
4107
- return interpret$I(keywordValue, instance, ast, dynamicAnchors) && new Set(Instance$y.map((item, ndx) => ndx, instance));
4150
+ if (!interpret$I(keywordValue, instance, ast, dynamicAnchors)) {
4151
+ return false;
4152
+ }
4153
+
4154
+ const evaluatedIndexes = new Set();
4155
+ for (let ndx = keywordValue[0]; ndx < Instance$y.length(instance); ndx++) {
4156
+ evaluatedIndexes.add(ndx);
4157
+ }
4158
+
4159
+ return evaluatedIndexes;
4108
4160
  };
4109
4161
 
4110
4162
  var additionalItems6 = { compile: compile$I, interpret: interpret$I, collectEvaluatedItems: collectEvaluatedItems$d };
@@ -4903,15 +4955,14 @@ define(['exports'], (function (exports) { 'use strict';
4903
4955
  const [, fragment] = splitUrl(Schema$d.value(dynamicRef));
4904
4956
  const referencedSchema = await Schema$d.get(Schema$d.value(dynamicRef), dynamicRef);
4905
4957
  await Core$a.compileSchema(referencedSchema, ast);
4906
- return [referencedSchema.id, fragment];
4958
+ return [referencedSchema.id, fragment, Schema$d.uri(referencedSchema)];
4907
4959
  };
4908
4960
 
4909
- const interpret$7 = ([id, fragment], instance, ast, dynamicAnchors) => {
4961
+ const interpret$7 = ([id, fragment, ref], instance, ast, dynamicAnchors) => {
4910
4962
  if (fragment in ast.metaData[id].dynamicAnchors) {
4911
4963
  return Core$a.interpretSchema(dynamicAnchors[fragment], instance, ast, dynamicAnchors);
4912
4964
  } else {
4913
- const pointer = Schema$d.getAnchorPointer(ast.metaData[id], fragment);
4914
- return Core$a.interpretSchema(`${id}#${encodeURI(pointer)}`, instance, ast, dynamicAnchors);
4965
+ return Core$a.interpretSchema(ref, instance, ast, dynamicAnchors);
4915
4966
  }
4916
4967
  };
4917
4968
 
@@ -6636,7 +6687,7 @@ define(['exports'], (function (exports) { 'use strict';
6636
6687
  InvalidSchemaError: InvalidSchemaError
6637
6688
  };
6638
6689
 
6639
- exports["default"] = lib;
6690
+ exports.default = lib;
6640
6691
 
6641
6692
  Object.defineProperty(exports, '__esModule', { value: true });
6642
6693