scim-patch
Advanced tools
Comparing version 0.8.2 to 0.8.3
@@ -1,1 +0,1 @@ | ||
{"processes":{"9bee56ee-0ad8-4164-a35b-48039eb43275":{"parent":null,"children":[]}},"files":{"/home/runner/work/scim-patch/scim-patch/lib/src/scimPatch.js":["9bee56ee-0ad8-4164-a35b-48039eb43275"],"/home/runner/work/scim-patch/scim-patch/lib/src/errors/scimErrors.js":["9bee56ee-0ad8-4164-a35b-48039eb43275"]},"externalIds":{}} | ||
{"processes":{"dbca0585-5379-4dc4-88f4-d0998b420c33":{"parent":null,"children":[]}},"files":{"/home/runner/work/scim-patch/scim-patch/lib/src/scimPatch.js":["dbca0585-5379-4dc4-88f4-d0998b420c33"],"/home/runner/work/scim-patch/scim-patch/lib/src/errors/scimErrors.js":["dbca0585-5379-4dc4-88f4-d0998b420c33"]},"externalIds":{}} |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.scimPatch = exports.patchBodyValidation = exports.PATCH_OPERATION_SCHEMA = exports.InvalidScimRemoveValue = exports.RemoveValueNotArray = exports.RemoveValueNestedArrayNotSupported = exports.NoTarget = exports.InvalidScimPatchRequest = exports.NoPathInScimPatchOp = exports.InvalidScimPatchOp = exports.InvalidScimPatch = exports.ScimError = void 0; | ||
exports.PATCH_OPERATION_SCHEMA = exports.InvalidScimRemoveValue = exports.RemoveValueNotArray = exports.RemoveValueNestedArrayNotSupported = exports.NoTarget = exports.InvalidScimPatchRequest = exports.NoPathInScimPatchOp = exports.InvalidScimPatchOp = exports.InvalidScimPatch = exports.ScimError = void 0; | ||
exports.patchBodyValidation = patchBodyValidation; | ||
exports.scimPatch = scimPatch; | ||
const scimErrors_1 = require("./errors/scimErrors"); | ||
@@ -48,3 +50,2 @@ Object.defineProperty(exports, "ScimError", { enumerable: true, get: function () { return scimErrors_1.ScimError; } }); | ||
} | ||
exports.patchBodyValidation = patchBodyValidation; | ||
/* | ||
@@ -79,3 +80,2 @@ * This method apply patch operations on a SCIM Resource. | ||
} | ||
exports.scimPatch = scimPatch; | ||
/* | ||
@@ -185,3 +185,3 @@ * validateOperation is validating that the SCIM Patch Operation follow the RFC. | ||
result[parsedPath.attrPath] = parsedPath.compValue; | ||
result[lastSubPath] = addOrReplaceAttribute(resource, patch, true); | ||
result[lastSubPath] = addOrReplaceAttribute(undefined, patch, true); | ||
resource[e.attrName] = [...((_a = resource[e.attrName]) !== null && _a !== void 0 ? _a : []), result]; | ||
@@ -337,7 +337,2 @@ return scimResource; | ||
} | ||
// fix https://github.com/thomaspoignant/scim-patch/issues/489 | ||
// when trying to insert an empty object, we should directly insert it without merging. | ||
if (Object.keys(patch.value).length === 0) { | ||
return {}; | ||
} | ||
// We add all the patch values to the property object. | ||
@@ -344,0 +339,0 @@ for (const [key, value] of Object.entries(patch.value)) { |
@@ -398,2 +398,9 @@ "use strict"; | ||
}); | ||
// see https://github.com/thomaspoignant/scim-patch/issues/693 | ||
it('REPLACE: Replace op with value of empty object should merge if the target property is an object', done => { | ||
const patch = { op: 'replace', value: {}, path: 'name' }; | ||
const afterPatch = (0, scimPatch_1.scimPatch)(scimUser, [patch], { mutateDocument: false, treatMissingAsAdd: true }); | ||
(0, chai_1.expect)(afterPatch.name).to.be.deep.eq(scimUser.name); | ||
return done(); | ||
}); | ||
}); | ||
@@ -864,2 +871,9 @@ describe('add', () => { | ||
}); | ||
// see https://github.com/thomaspoignant/scim-patch/issues/693 | ||
it('ADD: value of empty object should merge if the target property is an object', done => { | ||
const patch = { op: 'add', value: {}, path: 'name' }; | ||
const afterPatch = (0, scimPatch_1.scimPatch)(scimUser, [patch], { mutateDocument: false, treatMissingAsAdd: true }); | ||
(0, chai_1.expect)(afterPatch.name).to.be.deep.eq(scimUser.name); | ||
return done(); | ||
}); | ||
}); | ||
@@ -866,0 +880,0 @@ describe('remove', () => { |
{ | ||
"name": "scim-patch", | ||
"version": "0.8.2", | ||
"version": "0.8.3", | ||
"description": "SCIM Patch operation (rfc7644).", | ||
@@ -28,21 +28,21 @@ "main": "lib/src/scimPatch.js", | ||
"@types/benchmark": "2.1.5", | ||
"@types/chai": "4.3.11", | ||
"@types/mocha": "10.0.6", | ||
"@types/chai": "4.3.16", | ||
"@types/mocha": "10.0.7", | ||
"@typescript-eslint/eslint-plugin": "7.0.0", | ||
"@typescript-eslint/parser": "6.21.0", | ||
"benchmark": "2.1.4", | ||
"chai": "4.3.10", | ||
"chai": "4.5.0", | ||
"coveralls": "3.1.1", | ||
"eslint": "8.57.0", | ||
"eslint-plugin-mocha": "10.4.1", | ||
"eslint-plugin-testing-library": "6.2.0", | ||
"eslint-plugin-mocha": "10.5.0", | ||
"eslint-plugin-testing-library": "6.2.2", | ||
"mocha": "^10.2.0", | ||
"nyc": "15.1.0", | ||
"nyc": "17.0.0", | ||
"ts-node": "10.9.2", | ||
"typescript": "5.4.3" | ||
"typescript": "5.5.4" | ||
}, | ||
"dependencies": { | ||
"@types/node": "^20.4.5", | ||
"@types/node": "^22.0.0", | ||
"fast-deep-equal": "3.1.3", | ||
"scim2-parse-filter": "0.2.9" | ||
"scim2-parse-filter": "0.2.10" | ||
}, | ||
@@ -49,0 +49,0 @@ "publishConfig": { |
@@ -246,3 +246,3 @@ import { | ||
result[parsedPath.attrPath] = parsedPath.compValue; | ||
result[lastSubPath] = addOrReplaceAttribute(resource, patch, true); | ||
result[lastSubPath] = addOrReplaceAttribute(undefined, patch, true); | ||
resource[e.attrName] = [...(resource[e.attrName] ?? []), result]; | ||
@@ -424,8 +424,2 @@ return scimResource; | ||
// fix https://github.com/thomaspoignant/scim-patch/issues/489 | ||
// when trying to insert an empty object, we should directly insert it without merging. | ||
if (Object.keys(patch.value).length === 0) { | ||
return {}; | ||
} | ||
// We add all the patch values to the property object. | ||
@@ -432,0 +426,0 @@ for (const [key, value] of Object.entries(patch.value)) { |
@@ -435,2 +435,10 @@ import { | ||
}); | ||
// see https://github.com/thomaspoignant/scim-patch/issues/693 | ||
it('REPLACE: Replace op with value of empty object should merge if the target property is an object', done => { | ||
const patch: ScimPatchAddReplaceOperation = {op: 'replace', value: {}, path: 'name'}; | ||
const afterPatch = scimPatch(scimUser, [patch], { mutateDocument: false, treatMissingAsAdd: true }); | ||
expect(afterPatch.name).to.be.deep.eq(scimUser.name); | ||
return done(); | ||
}); | ||
}); | ||
@@ -939,2 +947,11 @@ | ||
}); | ||
// see https://github.com/thomaspoignant/scim-patch/issues/693 | ||
it('ADD: value of empty object should merge if the target property is an object', done => { | ||
const patch: ScimPatchAddReplaceOperation = {op: 'add', value: {}, path: 'name'}; | ||
const afterPatch = scimPatch(scimUser, [patch], { mutateDocument: false, treatMissingAsAdd: true }); | ||
expect(afterPatch.name).to.be.deep.eq(scimUser.name); | ||
return done(); | ||
}); | ||
}); | ||
@@ -941,0 +958,0 @@ describe('remove', () => { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
4042
367630
+ Added@types/node@22.13.9(transitive)
+ Addedscim2-parse-filter@0.2.10(transitive)
+ Addedundici-types@6.20.0(transitive)
- Removed@types/node@20.17.23(transitive)
- Removedscim2-parse-filter@0.2.9(transitive)
- Removedundici-types@6.19.8(transitive)
Updated@types/node@^22.0.0
Updatedscim2-parse-filter@0.2.10