@rjsf/utils 6.1.0 → 6.1.2
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/dist/index.cjs +13 -8
- package/dist/index.cjs.map +3 -3
- package/dist/utils.esm.js +13 -8
- package/dist/utils.esm.js.map +3 -3
- package/dist/utils.umd.js +16 -10
- package/lib/schema/retrieveSchema.js +19 -8
- package/lib/schema/retrieveSchema.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -3
- package/src/schema/retrieveSchema.ts +22 -8
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rjsf/utils",
|
|
3
|
-
"version": "6.1.
|
|
3
|
+
"version": "6.1.2",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"module": "lib/index.js",
|
|
6
6
|
"typings": "lib/index.d.ts",
|
|
@@ -65,8 +65,8 @@
|
|
|
65
65
|
"react": ">=18"
|
|
66
66
|
},
|
|
67
67
|
"dependencies": {
|
|
68
|
+
"@x0k/json-schema-merge": "^1.0.2",
|
|
68
69
|
"fast-uri": "^3.1.0",
|
|
69
|
-
"json-schema-merge-allof": "^0.8.1",
|
|
70
70
|
"jsonpointer": "^5.0.1",
|
|
71
71
|
"lodash": "^4.17.21",
|
|
72
72
|
"lodash-es": "^4.17.21",
|
|
@@ -74,7 +74,6 @@
|
|
|
74
74
|
},
|
|
75
75
|
"devDependencies": {
|
|
76
76
|
"@types/json-schema": "^7.0.15",
|
|
77
|
-
"@types/json-schema-merge-allof": "^0.6.5",
|
|
78
77
|
"@types/react-is": "^18.3.1",
|
|
79
78
|
"deep-freeze-es6": "^4.0.1",
|
|
80
79
|
"eslint": "^8.57.1"
|
|
@@ -5,7 +5,9 @@ import transform from 'lodash/transform';
|
|
|
5
5
|
import merge from 'lodash/merge';
|
|
6
6
|
import flattenDeep from 'lodash/flattenDeep';
|
|
7
7
|
import uniq from 'lodash/uniq';
|
|
8
|
-
import
|
|
8
|
+
import isEmpty from 'lodash/isEmpty';
|
|
9
|
+
import { createComparator, createMerger, createShallowAllOfMerge } from '@x0k/json-schema-merge';
|
|
10
|
+
import { createDeduplicator, createIntersector } from '@x0k/json-schema-merge/lib/array';
|
|
9
11
|
|
|
10
12
|
import {
|
|
11
13
|
ADDITIONAL_PROPERTIES_KEY,
|
|
@@ -36,7 +38,6 @@ import {
|
|
|
36
38
|
} from '../types';
|
|
37
39
|
import getFirstMatchingOption from './getFirstMatchingOption';
|
|
38
40
|
import deepEquals from '../deepEquals';
|
|
39
|
-
import isEmpty from 'lodash/isEmpty';
|
|
40
41
|
|
|
41
42
|
/** Retrieves an expanded schema that has had all of its conditions, additional properties, references and dependencies
|
|
42
43
|
* resolved and merged into the `schema` given a `validator`, `rootSchema` and `rawFormData` that is used to do the
|
|
@@ -512,6 +513,24 @@ export function stubExistingAdditionalProperties<
|
|
|
512
513
|
return schema;
|
|
513
514
|
}
|
|
514
515
|
|
|
516
|
+
// Set up @x0k/json-schema-merge utilities
|
|
517
|
+
const { compareSchemaDefinitions, compareSchemaValues } = createComparator();
|
|
518
|
+
const { mergeArrayOfSchemaDefinitions } = createMerger({
|
|
519
|
+
intersectJson: createIntersector(compareSchemaValues),
|
|
520
|
+
deduplicateJsonSchemaDef: createDeduplicator(compareSchemaDefinitions),
|
|
521
|
+
});
|
|
522
|
+
|
|
523
|
+
const shallowAllOfMerge = createShallowAllOfMerge(mergeArrayOfSchemaDefinitions);
|
|
524
|
+
|
|
525
|
+
/**
|
|
526
|
+
* Internal helper that merges allOf schemas using @x0k/json-schema-merge's shallow allOf merge
|
|
527
|
+
* @param schema - The schema containing an `allOf` keyword
|
|
528
|
+
* @returns The schema with allOf schemas merged
|
|
529
|
+
*/
|
|
530
|
+
function mergeAllOf<S extends StrictRJSFSchema = RJSFSchema>(schema: S): S {
|
|
531
|
+
return shallowAllOfMerge(schema) as S;
|
|
532
|
+
}
|
|
533
|
+
|
|
515
534
|
/** Internal handler that retrieves an expanded schema that has had all of its conditions, additional properties,
|
|
516
535
|
* references and dependencies resolved and merged into the `schema` given a `validator`, `rootSchema` and `rawFormData`
|
|
517
536
|
* that is used to do the potentially recursive resolution. If `expandAllBranches` is true, then all possible branches
|
|
@@ -590,12 +609,7 @@ export function retrieveSchemaInternal<
|
|
|
590
609
|
}
|
|
591
610
|
resolvedSchema = experimental_customMergeAllOf
|
|
592
611
|
? experimental_customMergeAllOf(resolvedSchema)
|
|
593
|
-
:
|
|
594
|
-
deep: false,
|
|
595
|
-
resolvers: {
|
|
596
|
-
$defs: mergeAllOf.options.resolvers.definitions,
|
|
597
|
-
},
|
|
598
|
-
} as Options) as S);
|
|
612
|
+
: mergeAllOf(resolvedSchema);
|
|
599
613
|
if (withContainsSchemas.length) {
|
|
600
614
|
resolvedSchema.allOf = withContainsSchemas;
|
|
601
615
|
}
|