### Define SCIM User Interface Source: https://github.com/thomaspoignant/scim-patch/blob/master/README.md Define a SCIM resource interface by extending `ScimResource`. This example shows the structure for a `ScimUser`. ```typescript export interface ScimUser extends ScimResource { schemas: ['urn:ietf:params:scim:schemas:core:2.0:User']; userName: string; name: { familyName: string; givenName: string; }; active: boolean; emails: Array<{ value: string; primary: boolean; }>; roles?: Array<{ value: string; type?: string; }>; meta: ScimMeta & { resourceType: 'User' }; }; ``` -------------------------------- ### Patch SCIM Resource Source: https://github.com/thomaspoignant/scim-patch/blob/master/README.md Patch a SCIM resource using the `scimPatch` function. This example demonstrates replacing the 'active' attribute. ```typescript const scimUser: ScimUser = { schemas: ['urn:ietf:params:scim:schemas:core:2.0:User'], userName: 'user1@test.com', name: { familyName: 'user1', givenName: 'user2' }, active: true, emails: [{value: 'user1@test.com', primary: true}], meta: { resourceType: 'User', created: new Date(), lastModified: new Date() } }; const patch: ScimPatchOperation = { op: 'replace', value: { active: false } }; const patchedUser = scimPatch(scimUser, patch); // scimUser === patchedUser, see Options section if you want to avoid updating the original object ``` -------------------------------- ### Patch SCIM Resource (Treat Missing as Add Disabled) Source: https://github.com/thomaspoignant/scim-patch/blob/master/README.md Configure `scimPatch` to throw an error when a replace operation targets a non-existent attribute by setting `treatMissingAsAdd: false`. By default, it treats missing attributes as an 'add' operation. ```typescript // scimUser has no addresses const patch = { op: 'replace', path: 'addresses[type eq "work"].country', value: 'Australia', }; const patchedUser = scimPatch(scimUser, patch, {treatMissingAsAdd: false}); // patchedUser.addresses[0].country === "Australia" ``` -------------------------------- ### Patch SCIM Resource (Immutable) Source: https://github.com/thomaspoignant/scim-patch/blob/master/README.md Patch a SCIM resource without modifying the original object by setting `mutateDocument: false`. The function will return a new patched object. ```typescript const patchedUser = scimPatch(scimUser, patch, {mutateDocument: false}); // scimUser !== patchedUser ``` -------------------------------- ### Validate SCIM Patch Body Source: https://github.com/thomaspoignant/scim-patch/blob/master/README.md Use `patchBodyValidation` to check if a SCIM Patch operation body is valid. Catches errors in the SCIM request structure. ```typescript import {patchBodyValidation} from 'scim-patch'; const scimBody: ScimPatchOperation = { 'schemas': ['urn:ietf:params:scim:api:messages:2.0:PatchOp'], 'Operations': [ {op: 'replace', path: 'name.familyName', value: 'newFamilyName'} ] }; try { patchBodyValidation(scimBody); } catch (error) { // Here if there are an error in you SCIM request. } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.