json-schema-library 5.3.0 → 7.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (161) hide show
  1. package/.editorconfig +1 -0
  2. package/.prettierignore +1 -0
  3. package/.prettierrc +7 -0
  4. package/CHANGELOG.md +106 -0
  5. package/README.md +811 -199
  6. package/TASKS.md +3 -81
  7. package/dist/index.d.ts +29 -71
  8. package/dist/jsonSchemaLibrary.js +1 -1
  9. package/dist/lib/SchemaService.d.ts +6 -8
  10. package/dist/lib/{addSchema.d.ts → addRemoteSchema.d.ts} +2 -1
  11. package/dist/lib/addValidator.d.ts +3 -2
  12. package/dist/lib/compile/getRef.d.ts +2 -1
  13. package/dist/lib/compile/index.d.ts +15 -1
  14. package/dist/lib/compile/types.d.ts +5 -0
  15. package/dist/lib/config/strings.d.ts +1 -39
  16. package/dist/lib/draft/index.d.ts +132 -0
  17. package/dist/lib/draft04/index.d.ts +7 -0
  18. package/dist/lib/draft06/compile/index.d.ts +16 -0
  19. package/dist/lib/draft06/index.d.ts +7 -0
  20. package/dist/lib/draft06/validation/keyword.d.ts +3 -0
  21. package/dist/lib/draft06/validation/type.d.ts +10 -0
  22. package/dist/lib/draft06/validation/typeKeywordMapping.d.ts +13 -0
  23. package/dist/lib/draft07/index.d.ts +7 -0
  24. package/dist/lib/each.d.ts +3 -2
  25. package/dist/lib/eachSchema.d.ts +2 -4
  26. package/dist/lib/getChildSchemaSelection.d.ts +7 -5
  27. package/dist/lib/getSchema.d.ts +2 -2
  28. package/dist/lib/getTemplate.d.ts +1 -1
  29. package/dist/lib/getTypeOf.d.ts +2 -1
  30. package/dist/lib/isValid.d.ts +1 -1
  31. package/dist/lib/jsoneditor/index.d.ts +7 -0
  32. package/dist/lib/resolveAllOf.d.ts +1 -1
  33. package/dist/lib/resolveAnyOf.d.ts +1 -1
  34. package/dist/lib/resolveOneOf.fuzzy.d.ts +1 -1
  35. package/dist/lib/resolveOneOf.strict.d.ts +2 -2
  36. package/dist/lib/{resolveRef.withOverwrite.d.ts → resolveRef.merge.d.ts} +0 -0
  37. package/dist/lib/schema/getTypeDefs.d.ts +6 -4
  38. package/dist/lib/schema/getTypeId.d.ts +1 -1
  39. package/dist/lib/schema/types.d.ts +7 -57
  40. package/dist/lib/step.d.ts +5 -5
  41. package/dist/lib/types.d.ts +11 -3
  42. package/dist/lib/utils/createCustomError.d.ts +8 -11
  43. package/dist/lib/utils/filter.d.ts +4 -4
  44. package/dist/lib/utils/flattenArray.d.ts +1 -1
  45. package/dist/lib/utils/merge.d.ts +3 -0
  46. package/dist/lib/utils/punycode.ucs2decode.d.ts +1 -1
  47. package/dist/lib/validate.d.ts +2 -2
  48. package/dist/lib/validateAsync.d.ts +1 -1
  49. package/dist/lib/validation/errors.d.ts +1 -3
  50. package/dist/lib/validation/format.d.ts +4 -11
  51. package/dist/lib/validation/keyword.d.ts +2 -27
  52. package/dist/lib/validation/type.d.ts +3 -10
  53. package/dist/lib/validation/typeKeywordMapping.d.ts +4 -4
  54. package/dist/module/index.js +23 -32
  55. package/dist/module/lib/SchemaService.js +7 -4
  56. package/dist/module/lib/{addSchema.js → addRemoteSchema.js} +2 -4
  57. package/dist/module/lib/addValidator.js +3 -4
  58. package/dist/module/lib/compile/getRef.js +1 -1
  59. package/dist/module/lib/compile/index.js +43 -18
  60. package/dist/module/lib/compile/types.js +1 -0
  61. package/dist/module/lib/config/strings.js +15 -2
  62. package/dist/module/lib/createSchemaOf.js +1 -1
  63. package/dist/module/lib/draft/index.js +133 -0
  64. package/dist/module/lib/draft04/index.js +90 -0
  65. package/dist/module/lib/draft06/compile/index.js +77 -0
  66. package/dist/module/lib/draft06/index.js +96 -0
  67. package/dist/module/lib/draft06/validation/keyword.js +168 -0
  68. package/dist/module/lib/draft06/validation/type.js +31 -0
  69. package/dist/module/lib/draft06/validation/typeKeywordMapping.js +15 -0
  70. package/dist/module/lib/draft07/index.js +96 -0
  71. package/dist/module/lib/each.js +2 -2
  72. package/dist/module/lib/eachSchema.js +28 -19
  73. package/dist/module/lib/getChildSchemaSelection.js +7 -6
  74. package/dist/module/lib/getSchema.js +4 -2
  75. package/dist/module/lib/getTemplate.js +42 -15
  76. package/dist/module/lib/jsoneditor/index.js +16 -0
  77. package/dist/module/lib/resolveAllOf.js +3 -4
  78. package/dist/module/lib/resolveOneOf.fuzzy.js +13 -3
  79. package/dist/module/lib/resolveOneOf.strict.js +49 -2
  80. package/dist/module/lib/{resolveRef.withOverwrite.js → resolveRef.merge.js} +0 -0
  81. package/dist/module/lib/resolveRef.strict.js +8 -0
  82. package/dist/module/lib/schema/getTypeDefs.js +14 -3
  83. package/dist/module/lib/schema/getTypeId.js +10 -6
  84. package/dist/module/lib/schema/types.js +33 -9
  85. package/dist/module/lib/step.js +67 -13
  86. package/dist/module/lib/types.js +7 -1
  87. package/dist/module/lib/utils/createCustomError.js +4 -4
  88. package/dist/module/lib/utils/filter.js +3 -5
  89. package/dist/module/lib/utils/flattenArray.js +4 -3
  90. package/dist/module/lib/utils/merge.js +4 -0
  91. package/dist/module/lib/utils/punycode.ucs2decode.js +4 -3
  92. package/dist/module/lib/validate.js +34 -8
  93. package/dist/module/lib/validateAsync.js +7 -7
  94. package/dist/module/lib/validation/errors.js +16 -3
  95. package/dist/module/lib/validation/format.js +115 -8
  96. package/dist/module/lib/validation/keyword.js +79 -32
  97. package/dist/module/lib/validation/type.js +2 -1
  98. package/index.ts +46 -32
  99. package/lib/SchemaService.ts +18 -11
  100. package/lib/{addSchema.ts → addRemoteSchema.ts} +3 -5
  101. package/lib/addValidator.ts +15 -12
  102. package/lib/compile/getRef.ts +3 -4
  103. package/lib/compile/index.ts +65 -19
  104. package/lib/compile/types.ts +6 -0
  105. package/lib/config/strings.ts +17 -3
  106. package/lib/createSchemaOf.ts +1 -3
  107. package/lib/draft/index.ts +201 -0
  108. package/lib/draft04/index.ts +95 -0
  109. package/lib/draft06/compile/index.ts +104 -0
  110. package/lib/draft06/index.ts +101 -0
  111. package/lib/draft06/validation/keyword.ts +199 -0
  112. package/lib/draft06/validation/type.ts +47 -0
  113. package/lib/draft06/validation/typeKeywordMapping.ts +15 -0
  114. package/lib/draft07/index.ts +101 -0
  115. package/lib/each.ts +11 -4
  116. package/lib/eachSchema.ts +45 -32
  117. package/lib/getChildSchemaSelection.ts +14 -7
  118. package/lib/getSchema.ts +18 -9
  119. package/lib/getTemplate.ts +155 -42
  120. package/lib/getTypeOf.ts +2 -1
  121. package/lib/isValid.ts +7 -3
  122. package/lib/jsoneditor/index.ts +20 -0
  123. package/lib/resolveAllOf.ts +10 -6
  124. package/lib/resolveAnyOf.ts +7 -3
  125. package/lib/resolveOneOf.fuzzy.ts +26 -9
  126. package/lib/resolveOneOf.strict.ts +63 -5
  127. package/lib/{resolveRef.withOverwrite.ts → resolveRef.merge.ts} +0 -0
  128. package/lib/resolveRef.strict.ts +9 -0
  129. package/lib/schema/getTypeDefs.ts +19 -7
  130. package/lib/schema/getTypeId.ts +11 -8
  131. package/lib/schema/types.ts +41 -9
  132. package/lib/step.ts +109 -25
  133. package/lib/types.ts +23 -5
  134. package/lib/utils/createCustomError.ts +8 -13
  135. package/lib/utils/filter.ts +7 -9
  136. package/lib/utils/flattenArray.ts +5 -4
  137. package/lib/utils/merge.ts +5 -0
  138. package/lib/utils/punycode.ucs2decode.ts +6 -5
  139. package/lib/validate.ts +47 -16
  140. package/lib/validateAsync.ts +15 -14
  141. package/lib/validation/errors.ts +17 -6
  142. package/lib/validation/format.ts +147 -13
  143. package/lib/validation/keyword.ts +172 -103
  144. package/lib/validation/type.ts +5 -1
  145. package/package.json +75 -63
  146. package/{dist/module/remotes/draft04.json → remotes/draft06.json} +47 -42
  147. package/remotes/draft07.json +172 -0
  148. package/remotes/draft2019-09.json +86 -0
  149. package/tsconfig.json +3 -10
  150. package/dist/lib/cores/CoreInterface.d.ts +0 -23
  151. package/dist/lib/cores/Draft04.d.ts +0 -13
  152. package/dist/lib/cores/JsonEditor.d.ts +0 -13
  153. package/dist/module/lib/cores/CoreInterface.js +0 -51
  154. package/dist/module/lib/cores/Draft04.js +0 -52
  155. package/dist/module/lib/cores/JsonEditor.js +0 -51
  156. package/dist/module/remotes/index.js +0 -10
  157. package/dist/remotes/index.d.ts +0 -5
  158. package/lib/cores/CoreInterface.ts +0 -76
  159. package/lib/cores/Draft04.ts +0 -66
  160. package/lib/cores/JsonEditor.ts +0 -64
  161. package/remotes/index.ts +0 -11
package/.editorconfig CHANGED
@@ -14,6 +14,7 @@ insert_final_newline = true
14
14
 
15
15
  [*.md]
16
16
  trim_trailing_whitespace = false
17
+ indent_size = 2
17
18
 
18
19
  [{package.json,bower.json}]
19
20
  indent_style = space
@@ -0,0 +1 @@
1
+ lib/config/strings.ts
package/.prettierrc ADDED
@@ -0,0 +1,7 @@
1
+ {
2
+ "printWidth": 100,
3
+ "tabWidth": 4,
4
+ "singleQuote": false,
5
+ "bracketSpacing": true,
6
+ "trailingComma": "none"
7
+ }
package/CHANGELOG.md ADDED
@@ -0,0 +1,106 @@
1
+ ## Changelog
2
+
3
+ ### 7.0.0
4
+
5
+ - changed core interface to draft for simpler configuration using a configuration map
6
+
7
+ **Breaking Changes**
8
+
9
+ - replaced `Core` interface by new `Draft` interface
10
+ - changed export of `Interface` to `Draft`
11
+ - changed export of `Interface` to `Draft`
12
+ - renamed `addSchema` to `addRemoteSchema`
13
+ - changed api of `compileSchema` to have an additional schema-parameter for rootSchema reference
14
+ - changed `compileSchema` and `addRemoteSchema` to work on instance state, instead of global state
15
+ - `addRemoteSchema`, `compileSchema` now requires draft instance as first parameter
16
+ - removed direct export of following functions: `addValidator`, `compileSchema`, `createSchemaOf`, `each`, `eachSchema`, `getChildSchemaSelection`, `getSchema`, `getTemplate`, `isValid`, `step`, `validate`. They are still accessible under the draftConfigs of each draft-version
17
+ - changed draft version of `JsonEditor` to draft07
18
+
19
+ **Milestone**
20
+
21
+ - [✓] configurable and consistent draft api
22
+ - [✓] expose all function under their draft-version
23
+ - [✓] remove global states in remotes
24
+
25
+
26
+ ### 6.1.0
27
+
28
+ - [✓] Feature -- add support for dependencies in _getSchema_ and _getTemplate_
29
+ - [✓] Feature -- added isJSONError type guard
30
+ - fixe and improve types
31
+
32
+ ### version 4.0
33
+
34
+ - [✓] Fix -- latest benchmark tests
35
+ - [✓] Fix -- iterate schema (using typeDefs)
36
+ - [✓] Fix -- scopes per schema-instance
37
+ - [✓] Fix -- insane $ref resolution 'node' can be in 'root/node' or 'root/folder/node'
38
+ - [✓] Refactor -- remove duplication from resolveRef.strict and resolveRef.withOverwrite
39
+ - [✓] Change -- improve function apis (param order, rootSchema per default)
40
+ - [✓] Fix -- `getTemplate` to resolve $ref to infinity
41
+
42
+ **Breaking Changes**
43
+
44
+ - `iterateSchema` renamed to `eachSchema`
45
+ - `validate` and `isValid` changed signature from (schema, data, [pointer]) to (data, [schema], [pointer])
46
+ - `validateAsync` changed signature from (schema, data, [pointer], [onError]) to (data, [{ schema, pointer, onError }])
47
+ - `getTemplate` changed signature from (schema, data) to (data, [schema])
48
+ - `getSchema` changed signature from (schema, data, [pointer]) to (pointer, [data], [schema])
49
+ - `each` changed signature from (schema, data, [pointer]) to (data, [schema], [pointer])
50
+ - `resolveOneOf` changed signature from (schema, data, [pointer]) to (data, [schema], [pointer])
51
+ - `precompileSchema` renamed to `compileSchema`
52
+
53
+ **Milestone** consistent feature support
54
+
55
+ - [✓] no side-effects on added remote-schemas
56
+ - [✓] rootSchema should always be compiled
57
+ - [✓] Add missing support for allOf and anyOf type definitions in 'step' and 'getTemplate'
58
+ - [✓] Complete schema support in iterateSchema
59
+
60
+
61
+ ## 2017
62
+
63
+ - [~] Features -- Improve validation maps to add & hook (!) custom entries (WIP, Add tests)
64
+ - [✓] Fix -- Return all errors in oneOf-validation
65
+ - [✓] Feature -- Error progress notification for async validation
66
+ - [✓] Refactor -- Keyword validators should only be called for defined keyword
67
+ - [✓] Feature -- getSchema of patternProperties
68
+
69
+ **Milestone** add remaining draft04 features
70
+ - [✓] remote references
71
+ - [✓] default format validations
72
+ - [✓] definitions
73
+ - [✓] dependencies
74
+ - [✓] Features -- allOf
75
+ - [✓] Features -- anyOf
76
+ - [✓] Features -- type-array
77
+ - [✓] Features -- patternProperties
78
+ - [✓] Features -- uniqueItems
79
+ - [✓] Features -- oneOf: fail for multiple matching oneof-schemas
80
+ - [✓] Features -- oneOf: for non-arrays
81
+ - [✓] Features -- required (array of properties). Currently every property is required by default
82
+
83
+
84
+ ## 16/12
85
+
86
+ - [✓] Testing (validate real json files)
87
+ - [✓] Test + document core differences
88
+ - [✓] Add async validation
89
+
90
+ **Milestone** customizable default and form (json-editor) validation
91
+ - [✓] Sanitize Errors
92
+ - [✓] Features -- Add core: Form, fix core: Draft04 - by using separate functions
93
+ - [✓] Add getTemplate to core (resolveOneOf)
94
+ - [✓] Breaking -- Add sort of 'core' to customize validation, stepper, errors etc and reduce requried arguments
95
+
96
+ **Milestone** custom validator (form-validation, oneOfProperty)
97
+ - [✓] Features -- additionalProperties: Boolean | Schema
98
+ - [✓] Features -- additionalItems: Boolean | Schema
99
+ - [✓] Features -- Add support for type "integer"
100
+ - [✓] Features -- oneOf -> oneOfProperty ( + Documentation)
101
+ - [✓] Breaking -- change isValid to return boolean
102
+ - [✓] Breaking -- use `step` in isValid -- bad: circular dependencies with step -> guessOneOfSchema -> isValid --X-> step
103
+ - [✓] Features -- items: [] schema (order/defined indices)
104
+ - [✓] Features -- not
105
+ - [✓] Features -- return custom errors in data validation
106
+ - [✓] Basics