@remoteoss/json-schema-form 0.11.5-dev.20240821134012 → 0.11.6-beta.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/CHANGELOG.md +14 -0
- package/dist/index.cjs +6 -4
- package/dist/index.js +6 -4
- package/dist/standalone.js +6 -4
- package/package.json +1 -1
- package/src/tests/createHeadlessForm.test.js +32 -1
- package/src/tests/helpers.js +19 -0
- package/src/tests/modify.test.js +27 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
#### 0.11.6-beta.0 (2024-10-15)
|
|
2
|
+
|
|
3
|
+
##### Bug Fixes
|
|
4
|
+
|
|
5
|
+
* **modify:** Support json schemas without allOf ([#93](https://github.com/remoteoss/json-schema-form/pull/93)) ([03795d0a](https://github.com/remoteoss/json-schema-form/commit/03795d0ac1a7ae0d523cd8418b83342676f221cf))
|
|
6
|
+
|
|
7
|
+
#### 0.11.5-beta.0 (2024-08-22)
|
|
8
|
+
|
|
9
|
+
##### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **validation:** Validate null field type correctly ([#91](https://github.com/remoteoss/json-schema-form/pull/91)) ([1cb8b61f](https://github.com/remoteoss/json-schema-form/commit/1cb8b61fec06d851832f9e76b3156d6f574b5d41))
|
|
12
|
+
* **files:** accept object value with `name` property ([#91](https://github.com/remoteoss/json-schema-form/pull/91)) ([1cb8b61f](https://github.com/remoteoss/json-schema-form/commit/1cb8b61fec06d851832f9e76b3156d6f574b5d41))
|
|
13
|
+
|
|
14
|
+
|
|
1
15
|
#### 0.11.4-beta.0 (2024-08-20)
|
|
2
16
|
|
|
3
17
|
##### Bug Fixes
|
package/dist/index.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
|
|
2
2
|
/*!
|
|
3
3
|
Copyright (c) 2024 Remote Technology, Inc.
|
|
4
|
-
NPM Package: @remoteoss/json-schema-form@0.11.
|
|
5
|
-
Generated:
|
|
4
|
+
NPM Package: @remoteoss/json-schema-form@0.11.6-beta.0
|
|
5
|
+
Generated: Tue, 15 Oct 2024 12:38:54 GMT
|
|
6
6
|
|
|
7
7
|
MIT License
|
|
8
8
|
|
|
@@ -674,7 +674,9 @@ function buildYupSchema(field, config, logic) {
|
|
|
674
674
|
);
|
|
675
675
|
}
|
|
676
676
|
function isValidFileInput(files) {
|
|
677
|
-
return files === void 0 || files === null || files.every(
|
|
677
|
+
return files === void 0 || files === null || files.every(
|
|
678
|
+
(file) => file instanceof File || Object.prototype.hasOwnProperty.call(file, "name")
|
|
679
|
+
);
|
|
678
680
|
}
|
|
679
681
|
function withFile(yupSchema) {
|
|
680
682
|
return yupSchema.test("isValidFile", "Not a valid file.", isValidFileInput);
|
|
@@ -2042,7 +2044,7 @@ function pickFields(originalSchema, fieldsToPick) {
|
|
|
2042
2044
|
}
|
|
2043
2045
|
});
|
|
2044
2046
|
let missingFields = {};
|
|
2045
|
-
newSchema.allOf
|
|
2047
|
+
newSchema.allOf?.forEach((condition) => {
|
|
2046
2048
|
const { if: ifCondition, then: thenCondition, else: elseCondition } = condition;
|
|
2047
2049
|
const index = originalSchema.allOf.indexOf(condition);
|
|
2048
2050
|
missingFields = {
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
|
|
2
2
|
/*!
|
|
3
3
|
Copyright (c) 2024 Remote Technology, Inc.
|
|
4
|
-
NPM Package: @remoteoss/json-schema-form@0.11.
|
|
5
|
-
Generated:
|
|
4
|
+
NPM Package: @remoteoss/json-schema-form@0.11.6-beta.0
|
|
5
|
+
Generated: Tue, 15 Oct 2024 12:38:54 GMT
|
|
6
6
|
|
|
7
7
|
MIT License
|
|
8
8
|
|
|
@@ -637,7 +637,9 @@ function buildYupSchema(field, config, logic) {
|
|
|
637
637
|
);
|
|
638
638
|
}
|
|
639
639
|
function isValidFileInput(files) {
|
|
640
|
-
return files === void 0 || files === null || files.every(
|
|
640
|
+
return files === void 0 || files === null || files.every(
|
|
641
|
+
(file) => file instanceof File || Object.prototype.hasOwnProperty.call(file, "name")
|
|
642
|
+
);
|
|
641
643
|
}
|
|
642
644
|
function withFile(yupSchema) {
|
|
643
645
|
return yupSchema.test("isValidFile", "Not a valid file.", isValidFileInput);
|
|
@@ -2005,7 +2007,7 @@ function pickFields(originalSchema, fieldsToPick) {
|
|
|
2005
2007
|
}
|
|
2006
2008
|
});
|
|
2007
2009
|
let missingFields = {};
|
|
2008
|
-
newSchema.allOf
|
|
2010
|
+
newSchema.allOf?.forEach((condition) => {
|
|
2009
2011
|
const { if: ifCondition, then: thenCondition, else: elseCondition } = condition;
|
|
2010
2012
|
const index = originalSchema.allOf.indexOf(condition);
|
|
2011
2013
|
missingFields = {
|
package/dist/standalone.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
|
|
2
2
|
/*!
|
|
3
3
|
Copyright (c) 2024 Remote Technology, Inc.
|
|
4
|
-
NPM Package: @remoteoss/json-schema-form@0.11.
|
|
5
|
-
Generated:
|
|
4
|
+
NPM Package: @remoteoss/json-schema-form@0.11.6-beta.0
|
|
5
|
+
Generated: Tue, 15 Oct 2024 12:38:54 GMT
|
|
6
6
|
|
|
7
7
|
MIT License
|
|
8
8
|
|
|
@@ -12153,7 +12153,9 @@ function buildYupSchema(field, config, logic) {
|
|
|
12153
12153
|
);
|
|
12154
12154
|
}
|
|
12155
12155
|
function isValidFileInput(files) {
|
|
12156
|
-
return files === void 0 || files === null || files.every(
|
|
12156
|
+
return files === void 0 || files === null || files.every(
|
|
12157
|
+
(file) => file instanceof File || Object.prototype.hasOwnProperty.call(file, "name")
|
|
12158
|
+
);
|
|
12157
12159
|
}
|
|
12158
12160
|
function withFile(yupSchema) {
|
|
12159
12161
|
return yupSchema.test("isValidFile", "Not a valid file.", isValidFileInput);
|
|
@@ -13521,7 +13523,7 @@ function pickFields(originalSchema, fieldsToPick) {
|
|
|
13521
13523
|
}
|
|
13522
13524
|
});
|
|
13523
13525
|
let missingFields = {};
|
|
13524
|
-
newSchema.allOf
|
|
13526
|
+
newSchema.allOf?.forEach((condition) => {
|
|
13525
13527
|
const { if: ifCondition, then: thenCondition, else: elseCondition } = condition;
|
|
13526
13528
|
const index = originalSchema.allOf.indexOf(condition);
|
|
13527
13529
|
missingFields = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@remoteoss/json-schema-form",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.6-beta.0",
|
|
4
4
|
"description": "Headless UI form powered by JSON Schemas",
|
|
5
5
|
"author": "Remote.com <engineering@remote.com> (https://remote.com/)",
|
|
6
6
|
"license": "MIT",
|
|
@@ -2862,8 +2862,39 @@ describe('createHeadlessForm', () => {
|
|
|
2862
2862
|
.validate({ fileInput: [file] })
|
|
2863
2863
|
).resolves.toEqual(assertObj));
|
|
2864
2864
|
});
|
|
2865
|
+
|
|
2865
2866
|
describe('and file is not instance of a File', () => {
|
|
2866
|
-
it('
|
|
2867
|
+
it('accepts if file object has name property', async () => {
|
|
2868
|
+
expect(
|
|
2869
|
+
object()
|
|
2870
|
+
.shape({
|
|
2871
|
+
fileInput: fields[0].schema,
|
|
2872
|
+
})
|
|
2873
|
+
.validate({ fileInput: [{ name: 'foo.pdf' }] })
|
|
2874
|
+
).resolves.toEqual({ fileInput: [{ name: 'foo.pdf' }] });
|
|
2875
|
+
});
|
|
2876
|
+
|
|
2877
|
+
it('should validate format', async () =>
|
|
2878
|
+
expect(
|
|
2879
|
+
object()
|
|
2880
|
+
.shape({
|
|
2881
|
+
fileInput: fields[0].schema,
|
|
2882
|
+
})
|
|
2883
|
+
.validate({ fileInput: [{ name: 'foo.txt' }] })
|
|
2884
|
+
).rejects.toMatchObject({
|
|
2885
|
+
errors: ['Unsupported file format. The acceptable formats are .png,.jpg,.jpeg,.pdf.'],
|
|
2886
|
+
}));
|
|
2887
|
+
|
|
2888
|
+
it('should validate max size', async () =>
|
|
2889
|
+
expect(
|
|
2890
|
+
object()
|
|
2891
|
+
.shape({
|
|
2892
|
+
fileInput: fields[0].schema,
|
|
2893
|
+
})
|
|
2894
|
+
.validate({ fileInput: [{ name: 'foo.txt', size: 1024 * 1024 * 1024 }] })
|
|
2895
|
+
).rejects.toMatchObject({ errors: ['File size too large. The limit is 20 MB.'] }));
|
|
2896
|
+
|
|
2897
|
+
it('throw an error if invalid file object', async () =>
|
|
2867
2898
|
expect(
|
|
2868
2899
|
object()
|
|
2869
2900
|
.shape({
|
package/src/tests/helpers.js
CHANGED
|
@@ -782,6 +782,25 @@ export const schemaInputWithStatement = {
|
|
|
782
782
|
},
|
|
783
783
|
};
|
|
784
784
|
|
|
785
|
+
export const schemaHiddenInputWithStatement = {
|
|
786
|
+
properties: {
|
|
787
|
+
a_field_statement: {
|
|
788
|
+
type: 'null',
|
|
789
|
+
title: 'Company statement',
|
|
790
|
+
'x-jsf-presentation': {
|
|
791
|
+
inputType: 'hidden',
|
|
792
|
+
statement: {
|
|
793
|
+
title: 'Important statement',
|
|
794
|
+
description:
|
|
795
|
+
"This statement message will be shown at all times, irrespective of this field's visibility.",
|
|
796
|
+
inputType: 'statement',
|
|
797
|
+
severity: 'warning',
|
|
798
|
+
},
|
|
799
|
+
},
|
|
800
|
+
},
|
|
801
|
+
},
|
|
802
|
+
};
|
|
803
|
+
|
|
785
804
|
export const schemaInputWithExtra = {
|
|
786
805
|
properties: {
|
|
787
806
|
bonus: {
|
package/src/tests/modify.test.js
CHANGED
|
@@ -608,7 +608,7 @@ const schemaTickets = {
|
|
|
608
608
|
],
|
|
609
609
|
};
|
|
610
610
|
|
|
611
|
-
describe('modify() -
|
|
611
|
+
describe('modify() - reorder fields', () => {
|
|
612
612
|
it('reorder fields - basic usage', () => {
|
|
613
613
|
const baseExample = {
|
|
614
614
|
properties: {
|
|
@@ -821,6 +821,32 @@ describe('modify() - pick fields', () => {
|
|
|
821
821
|
expect(warnings).toHaveLength(0);
|
|
822
822
|
});
|
|
823
823
|
|
|
824
|
+
it('basic usage without conditionals', () => {
|
|
825
|
+
const schemaMinimal = {
|
|
826
|
+
properties: {
|
|
827
|
+
age: {
|
|
828
|
+
title: 'Age',
|
|
829
|
+
type: 'integer',
|
|
830
|
+
},
|
|
831
|
+
quantity: {
|
|
832
|
+
title: 'Quantity',
|
|
833
|
+
type: 'integer',
|
|
834
|
+
},
|
|
835
|
+
},
|
|
836
|
+
'x-jsf-order': ['age', 'quantity'],
|
|
837
|
+
};
|
|
838
|
+
const { schema, warnings } = modify(schemaMinimal, {
|
|
839
|
+
pick: ['quantity'],
|
|
840
|
+
});
|
|
841
|
+
|
|
842
|
+
expect(schema.properties.quantity).toBeDefined();
|
|
843
|
+
expect(schema.properties.age).toBeUndefined();
|
|
844
|
+
// `allOf` conditionals were not defined, and continue to be so.
|
|
845
|
+
// This test guards against a regression where lack of `allOf` caused a TypeError.
|
|
846
|
+
expect(schema.allOf).toBeUndefined();
|
|
847
|
+
expect(warnings).toHaveLength(0);
|
|
848
|
+
});
|
|
849
|
+
|
|
824
850
|
it('related conditionals are kept - (else)', () => {
|
|
825
851
|
const { schema, warnings } = modify(schemaTickets, {
|
|
826
852
|
pick: ['has_premium'],
|