Skip to content

Commit c78c21b

Browse files
authored
Merge pull request #301 from performant-software/feature/cdc292_import_compare
CDC #292 - Import Compare
2 parents a288298 + 717bc3f commit c78c21b

File tree

12 files changed

+1032
-26
lines changed

12 files changed

+1032
-26
lines changed

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@
1616
"publish-beta": "node --experimental-json-modules ./scripts/publish.js --tag beta"
1717
},
1818
"devDependencies": {
19-
"@babel/core": "^7.17.9",
20-
"babel-jest": "^27.5.1",
19+
"@babel/core": "^7.25.7",
20+
"@babel/preset-env": "^7.25.7",
21+
"babel-jest": "^29.7.0",
2122
"babel-plugin-transform-flow-strip-types": "^6.22.0",
2223
"eslint": "^7.1.0",
2324
"eslint-config-airbnb": "^18.1.0",

packages/controlled-vocabulary/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@performant-software/controlled-vocabulary",
3-
"version": "2.2.15",
3+
"version": "2.2.16",
44
"description": "A package of components to allow user to configure dropdown elements. Use with the \"controlled_vocabulary\" gem.",
55
"license": "MIT",
66
"main": "./dist/index.cjs.js",
@@ -23,8 +23,8 @@
2323
"underscore": "^1.13.2"
2424
},
2525
"peerDependencies": {
26-
"@performant-software/semantic-components": "^2.2.15",
27-
"@performant-software/shared-components": "^2.2.15",
26+
"@performant-software/semantic-components": "^2.2.16",
27+
"@performant-software/shared-components": "^2.2.16",
2828
"react": ">= 16.13.1 < 19.0.0",
2929
"react-dom": ">= 16.13.1 < 19.0.0"
3030
},

packages/core-data/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@performant-software/core-data",
3-
"version": "2.2.15",
3+
"version": "2.2.16",
44
"description": "A package of components used with the Core Data platform.",
55
"license": "MIT",
66
"main": "./dist/index.cjs.js",
@@ -40,8 +40,8 @@
4040
"underscore": "^1.13.2"
4141
},
4242
"peerDependencies": {
43-
"@performant-software/geospatial": "^2.2.15",
44-
"@performant-software/shared-components": "^2.2.15",
43+
"@performant-software/geospatial": "^2.2.16",
44+
"@performant-software/shared-components": "^2.2.16",
4545
"@peripleo/maplibre": "^0.5.2",
4646
"@peripleo/peripleo": "^0.5.2",
4747
"react": ">= 16.13.1 < 19.0.0",

packages/geospatial/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@performant-software/geospatial",
3-
"version": "2.2.15",
3+
"version": "2.2.16",
44
"description": "A package of components for all things map-related.",
55
"license": "MIT",
66
"main": "./dist/index.cjs.js",

packages/semantic-ui/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@performant-software/semantic-components",
3-
"version": "2.2.15",
3+
"version": "2.2.16",
44
"description": "A package of shared components based on the Semantic UI Framework.",
55
"license": "MIT",
66
"main": "./dist/index.cjs.js",
@@ -35,7 +35,7 @@
3535
"zotero-translation-client": "^5.0.1"
3636
},
3737
"peerDependencies": {
38-
"@performant-software/shared-components": "^2.2.15",
38+
"@performant-software/shared-components": "^2.2.16",
3939
"@samvera/clover-iiif": "^2.3.2",
4040
"react": ">= 16.13.1 < 19.0.0",
4141
"react-dnd": "^11.1.3",

packages/shared/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@performant-software/shared-components",
3-
"version": "2.2.15",
3+
"version": "2.2.16",
44
"description": "A package of shared, framework agnostic, components.",
55
"license": "MIT",
66
"main": "./dist/index.cjs.js",

packages/shared/src/utils/Object.js

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,25 @@
33
import _ from 'underscore';
44

55
type OptionsProps = {
6-
emptyValues: Array<any>,
7-
ignoreHtml: boolean
6+
/**
7+
* List of values to consider "empty", these values will be treated as equivalent.
8+
*/
9+
emptyValues?: Array<any>,
10+
11+
/**
12+
* If true, HTML tags will be stripped from string values.
13+
*/
14+
ignoreHtml?: boolean,
15+
16+
/**
17+
* If true, whitespace will be stripped from string values.
18+
*/
19+
ignoreWhitespace?: boolean,
20+
21+
/**
22+
* If true, "empty" keys/values will be removed from objects prior to equality check.
23+
*/
24+
removeEmptyValues?: boolean
825
};
926

1027
const EMPTY_VALUES = [
@@ -18,7 +35,8 @@ const EMPTY_VALUES = [
1835
const DEFAULT_OPTIONS = {
1936
emptyValues: EMPTY_VALUES,
2037
ignoreHtml: true,
21-
ignoreWhitespace: true
38+
ignoreWhitespace: true,
39+
removeEmptyValues: false
2240
};
2341

2442
const HTML_REGEX = /(<([^>]+)>)/gi;
@@ -85,8 +103,16 @@ const isEqual = (a: any, b: any, userOptions: OptionsProps = {}) => {
85103
}
86104

87105
if (a !== null && typeof a === 'object' && b !== null && typeof b === 'object') {
88-
const aKeys = _.keys(a);
89-
const bKeys = _.keys(b);
106+
let aObject = a;
107+
let bObject = b;
108+
109+
if (options.removeEmptyValues) {
110+
aObject = _.omit(a, (value) => _.contains(options.emptyValues, value));
111+
bObject = _.omit(b, (value) => _.contains(options.emptyValues, value));
112+
}
113+
114+
const aKeys = _.keys(aObject);
115+
const bKeys = _.keys(bObject);
90116

91117
// If the objects contain different number of keys, return false
92118
if (aKeys.length !== bKeys.length) {
@@ -96,8 +122,8 @@ const isEqual = (a: any, b: any, userOptions: OptionsProps = {}) => {
96122
// Recursively check each key for equality
97123
let equal = true;
98124

99-
_.each(_.keys(a), (key) => {
100-
if (!(_.has(b, key) && isEqual(a[key], b[key]))) {
125+
_.each(_.keys(aObject), (key) => {
126+
if (!(_.has(bObject, key) && isEqual(aObject[key], bObject[key]))) {
101127
equal = false;
102128
}
103129
});

packages/shared/test/utils/Object.spec.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,30 @@ describe('isEqual', () => {
3939

4040
expect(ObjectUtils.isEqual(func1, func2)).toBeTruthy();
4141
});
42+
43+
test('should be equal for objects with different keys with null values', () => {
44+
const a = {
45+
name: 'Test 123',
46+
address: null
47+
};
48+
49+
const b = {
50+
name: 'Test 123'
51+
};
52+
53+
expect(ObjectUtils.isEqual(a, b, { removeEmptyValues: true })).toBeTruthy();
54+
});
55+
56+
test('should be unequal for objects with different keys with null values with removeEmptyValues "false"', () => {
57+
const a = {
58+
name: 'Test 123',
59+
address: null
60+
};
61+
62+
const b = {
63+
name: 'Test 123'
64+
};
65+
66+
expect(ObjectUtils.isEqual(a, b)).toBeFalsy();
67+
});
4268
});

packages/user-defined-fields/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@performant-software/user-defined-fields",
3-
"version": "2.2.15",
3+
"version": "2.2.16",
44
"description": "A package of components used for allowing end users to define fields on models. Use with the \"user_defined_fields\" gem.",
55
"license": "MIT",
66
"main": "./dist/index.cjs.js",
@@ -23,8 +23,8 @@
2323
"underscore": "^1.13.2"
2424
},
2525
"peerDependencies": {
26-
"@performant-software/semantic-components": "^2.2.15",
27-
"@performant-software/shared-components": "^2.2.15",
26+
"@performant-software/semantic-components": "^2.2.16",
27+
"@performant-software/shared-components": "^2.2.16",
2828
"react": ">= 16.13.1 < 19.0.0",
2929
"react-dom": ">= 16.13.1 < 19.0.0"
3030
},

packages/visualize/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@performant-software/visualize",
3-
"version": "2.2.15",
3+
"version": "2.2.16",
44
"description": "A package of components used for data visualization",
55
"license": "MIT",
66
"main": "./dist/index.cjs.js",

0 commit comments

Comments
 (0)