@hyperjump/json-schema 0.21.0 → 0.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -108,6 +108,7 @@ MediaTypePlugin to support that.
108
108
 
109
109
  ```javascript
110
110
  const JsonSchema = require("@hyperjump/json-schema");
111
+ const YAML = require("yaml");
111
112
 
112
113
 
113
114
  // Add support for JSON Schemas written in YAML
@@ -2759,13 +2759,22 @@ define(['exports'], (function (exports) { 'use strict';
2759
2759
 
2760
2760
  var invalidSchemaError = InvalidSchemaError$3;
2761
2761
 
2762
+ const Schema$R = schema$5;
2763
+
2764
+
2765
+ const compile$O = (schema) => Schema$R.value(schema);
2766
+ const interpret$O = () => true;
2767
+
2768
+ var metaData$4 = { compile: compile$O, interpret: interpret$O };
2769
+
2762
2770
  const curry = justCurryIt;
2763
2771
  const PubSub$1 = pubsub.exports;
2764
2772
  const { resolveUrl } = common$1;
2765
2773
  const Instance$E = instance;
2766
- const Schema$R = schema$5;
2774
+ const Schema$Q = schema$5;
2767
2775
  const InvalidSchemaError$2 = invalidSchemaError;
2768
2776
  const MediaTypes = mediaTypes;
2777
+ const metaData$3 = metaData$4;
2769
2778
 
2770
2779
 
2771
2780
  const FLAG = "FLAG", BASIC = "BASIC", DETAILED = "DETAILED", VERBOSE = "VERBOSE";
@@ -2779,19 +2788,19 @@ define(['exports'], (function (exports) { 'use strict';
2779
2788
  });
2780
2789
 
2781
2790
  const validate$2 = async (schema, value = undefined, outputFormat = undefined) => {
2782
- const compiled = await compile$O(schema);
2783
- const interpretAst = (value, outputFormat) => interpret$O(compiled, Instance$E.cons(value), outputFormat);
2791
+ const compiled = await compile$N(schema);
2792
+ const interpretAst = (value, outputFormat) => interpret$N(compiled, Instance$E.cons(value), outputFormat);
2784
2793
 
2785
2794
  return value === undefined ? interpretAst : interpretAst(value, outputFormat);
2786
2795
  };
2787
2796
 
2788
- const compile$O = async (schema) => {
2797
+ const compile$N = async (schema) => {
2789
2798
  const ast = { metaData: {} };
2790
2799
  const schemaUri = await compileSchema(schema, ast);
2791
2800
  return { ast, schemaUri };
2792
2801
  };
2793
2802
 
2794
- const interpret$O = curry(({ ast, schemaUri }, value, outputFormat = FLAG) => {
2803
+ const interpret$N = curry(({ ast, schemaUri }, value, outputFormat = FLAG) => {
2795
2804
  if (![FLAG, BASIC, DETAILED, VERBOSE].includes(outputFormat)) {
2796
2805
  throw Error(`The '${outputFormat}' error format is not supported`);
2797
2806
  }
@@ -2845,7 +2854,7 @@ define(['exports'], (function (exports) { 'use strict';
2845
2854
  };
2846
2855
 
2847
2856
  const _keywords = {};
2848
- const getKeyword = (id) => _keywords[id];
2857
+ const getKeyword = (id) => _keywords[id] || metaData$3;
2849
2858
  const hasKeyword = (id) => id in _keywords;
2850
2859
  const addKeyword = (id, keywordHandler) => {
2851
2860
  _keywords[id] = {
@@ -2866,10 +2875,10 @@ define(['exports'], (function (exports) { 'use strict';
2866
2875
 
2867
2876
  // Vocabularies
2868
2877
  if (!hasKeyword(`${schema.dialectId}#validate`)) {
2869
- const metaSchema = await Schema$R.get(schema.dialectId);
2878
+ const metaSchema = await Schema$Q.get(schema.dialectId);
2870
2879
 
2871
2880
  // Check for mandatory vocabularies
2872
- const mandatoryVocabularies = Schema$R.getConfig(metaSchema.id, "mandatoryVocabularies") || [];
2881
+ const mandatoryVocabularies = Schema$Q.getConfig(metaSchema.id, "mandatoryVocabularies") || [];
2873
2882
  mandatoryVocabularies.forEach((vocabularyId) => {
2874
2883
  if (!metaSchema.vocabulary[vocabularyId]) {
2875
2884
  throw Error(`Vocabulary '${vocabularyId}' must be explicitly declared and required`);
@@ -2892,13 +2901,13 @@ define(['exports'], (function (exports) { 'use strict';
2892
2901
 
2893
2902
  // Meta validation
2894
2903
  if (shouldMetaValidate && !schema.validated) {
2895
- Schema$R.markValidated(schema.id);
2904
+ Schema$Q.markValidated(schema.id);
2896
2905
 
2897
2906
  // Compile
2898
2907
  if (!(schema.dialectId in metaValidators)) {
2899
- const metaSchema = await Schema$R.get(schema.dialectId);
2900
- const compiledSchema = await compile$O(metaSchema);
2901
- metaValidators[metaSchema.id] = interpret$O(compiledSchema);
2908
+ const metaSchema = await Schema$Q.get(schema.dialectId);
2909
+ const compiledSchema = await compile$N(metaSchema);
2910
+ metaValidators[metaSchema.id] = interpret$N(compiledSchema);
2902
2911
  }
2903
2912
 
2904
2913
  // Interpret
@@ -2921,7 +2930,7 @@ define(['exports'], (function (exports) { 'use strict';
2921
2930
  };
2922
2931
 
2923
2932
  const followReferences = async (doc) => {
2924
- return Schema$R.typeOf(doc, "string") ? followReferences(await Schema$R.get(Schema$R.value(doc), doc)) : doc;
2933
+ return Schema$Q.typeOf(doc, "string") ? followReferences(await Schema$Q.get(Schema$Q.value(doc), doc)) : doc;
2925
2934
  };
2926
2935
 
2927
2936
  const interpretSchema = (schemaUri, instance, ast, dynamicAnchors) => {
@@ -2949,26 +2958,18 @@ define(['exports'], (function (exports) { 'use strict';
2949
2958
  };
2950
2959
 
2951
2960
  const add = (schema, url = "", defaultSchemaVersion = "") => {
2952
- const id = Schema$R.add(schema, url, defaultSchemaVersion);
2961
+ const id = Schema$Q.add(schema, url, defaultSchemaVersion);
2953
2962
  delete metaValidators[id];
2954
2963
  };
2955
2964
 
2956
2965
  var core$2 = {
2957
- validate: validate$2, compile: compile$O, interpret: interpret$O,
2966
+ validate: validate$2, compile: compile$N, interpret: interpret$N,
2958
2967
  setMetaOutputFormat, setShouldMetaValidate, FLAG, BASIC, DETAILED, VERBOSE,
2959
2968
  add, getKeyword, hasKeyword, defineVocabulary,
2960
2969
  compileSchema, interpretSchema, collectEvaluatedProperties: collectEvaluatedProperties$e, collectEvaluatedItems: collectEvaluatedItems$f,
2961
2970
  addMediaTypePlugin: MediaTypes.addPlugin
2962
2971
  };
2963
2972
 
2964
- const Schema$Q = schema$5;
2965
-
2966
-
2967
- const compile$N = (schema) => Schema$Q.value(schema);
2968
- const interpret$N = () => true;
2969
-
2970
- var metaData$3 = { compile: compile$N, interpret: interpret$N };
2971
-
2972
2973
  const Pact$9 = lib$2;
2973
2974
  const PubSub = pubsub.exports;
2974
2975
  const Core$x = core$2;
@@ -2992,7 +2993,7 @@ define(['exports'], (function (exports) { 'use strict';
2992
2993
  typeof schemaValue === "boolean" ? schemaValue : await Pact$9.pipeline([
2993
2994
  Schema$P.entries,
2994
2995
  Pact$9.map(([keyword, keywordSchema]) => [`${schema.dialectId}#${keyword}`, keywordSchema]),
2995
- Pact$9.filter(([keywordId]) => Core$x.hasKeyword(keywordId) && keywordId !== `${schema.dialectId}#validate`),
2996
+ Pact$9.filter(([keywordId]) => keywordId !== `${schema.dialectId}#validate`),
2996
2997
  Pact$9.map(async ([keywordId, keywordSchema]) => {
2997
2998
  const keywordAst = await Core$x.getKeyword(keywordId).compile(keywordSchema, ast, schema);
2998
2999
  return [keywordId, Schema$P.uri(keywordSchema), keywordAst];
@@ -3068,7 +3069,7 @@ define(['exports'], (function (exports) { 'use strict';
3068
3069
 
3069
3070
  var validate$1 = { compile: compile$M, interpret: interpret$M, collectEvaluatedProperties: collectEvaluatedProperties$d, collectEvaluatedItems: collectEvaluatedItems$e };
3070
3071
 
3071
- const metaData$2 = metaData$3;
3072
+ const metaData$2 = metaData$4;
3072
3073
  const validate = validate$1;
3073
3074
 
3074
3075