### SCIMMY.Config.set() Example Source: https://github.com/scimmyjs/scimmy/blob/main/_autodocs/GENERATION_REPORT.txt Illustrates setting configuration values with SCIMMY.Config.set(). ```javascript SCIMMY.Config.set() ``` -------------------------------- ### Complete Schema Setup for SCIMMY Source: https://github.com/scimmyjs/scimmy/blob/main/_autodocs/api-reference/schemas.md This pattern demonstrates the full setup for SCIMMY schemas, including defining custom schemas, extending built-in schemas, declaring resources, and querying declared schemas. ```javascript // 1. Custom schema definition const enterpriseSchema = new SCIMMY.Types.SchemaDefinition( "Enterprise", "urn:example:params:scim:schemas:enterprise:2.0:User", "Enterprise User Extension", [ new SCIMMY.Types.Attribute("string", "employeeId", {required: true}), new SCIMMY.Types.Attribute("string", "department") ] ); // 2. Modify built-in schema SCIMMY.Schemas.User.definition.truncate(["ims", "photos"]); // 3. Add extension to built-in schema SCIMMY.Schemas.User.definition.extend( enterpriseSchema, false // optional ); // 4. Declare custom schema SCIMMY.Schemas.declare(enterpriseSchema); // 5. Declare resources (automatically declares their schemas) SCIMMY.Resources.declare(SCIMMY.Resources.User) .ingress(/* ... */) .egress(/* ... */) .degress(/* ... */); // 6. Query declared schemas const declared = SCIMMY.Schemas.declared(); console.log(declared.length); // All schemas including extensions ``` -------------------------------- ### SCIMMY.Config.get() Example Source: https://github.com/scimmyjs/scimmy/blob/main/_autodocs/GENERATION_REPORT.txt Demonstrates how to retrieve configuration values using SCIMMY.Config.get(). ```javascript SCIMMY.Config.get() ``` -------------------------------- ### Message Constructor Example Source: https://github.com/scimmyjs/scimmy/blob/main/_autodocs/GENERATION_REPORT.txt This example demonstrates the basic usage of a message constructor within SCIMMY. ```javascript new SCIMMY.Messages.ErrorResponse() ``` -------------------------------- ### SCIMMY.Resources.declare() Example Source: https://github.com/scimmyjs/scimmy/blob/main/_autodocs/GENERATION_REPORT.txt Shows how to declare a new resource type using SCIMMY.Resources.declare(). ```javascript SCIMMY.Resources.declare() ``` -------------------------------- ### Install SCIMMY via NPM Source: https://github.com/scimmyjs/scimmy/blob/main/README.md Install the SCIMMY package using npm. Ensure you have Node.js v16+ and NPM 7+. ```bash npm install scimmy ``` -------------------------------- ### SchemaDefinition Methods Example Source: https://github.com/scimmyjs/scimmy/blob/main/_autodocs/GENERATION_REPORT.txt Illustrates the usage of methods available on a SchemaDefinition instance. ```javascript SchemaDefinition.methods() ``` -------------------------------- ### SCIMMY.Schemas.declare() Example Source: https://github.com/scimmyjs/scimmy/blob/main/_autodocs/GENERATION_REPORT.txt Illustrates declaring a new schema using SCIMMY.Schemas.declare(). ```javascript SCIMMY.Schemas.declare() ``` -------------------------------- ### Using Schema Extensions Source: https://github.com/scimmyjs/scimmy/blob/main/_autodocs/api-reference/schema.md Example of instantiating a schema with an extension, such as the EnterpriseUser extension, to include additional attributes. ```javascript // User with EnterpriseUser extension const user = new SCIMMY.Schemas.User({ userName: "john.doe@example.com", "urn:ietf:params:scim:schemas:extension:enterprise:2.0:User": { employeeNumber: "E123456", department: "Engineering", manager: { value: "manager-id-123", $ref: "https://example.com/scim/v2/Users/manager-id-123" } } }); ``` -------------------------------- ### Filter Methods Example Source: https://github.com/scimmyjs/scimmy/blob/main/_autodocs/GENERATION_REPORT.txt Shows how to use methods provided by the Filter class for query operations. ```javascript Filter.methods() ``` -------------------------------- ### SCIMMY.Resources.declared() Example Source: https://github.com/scimmyjs/scimmy/blob/main/_autodocs/GENERATION_REPORT.txt Demonstrates checking if a resource has been declared using SCIMMY.Resources.declared(). ```javascript SCIMMY.Resources.declared() ``` -------------------------------- ### SCIMMY.Schemas.declared() Example Source: https://github.com/scimmyjs/scimmy/blob/main/_autodocs/GENERATION_REPORT.txt Shows how to check if a schema has been declared using SCIMMY.Schemas.declared(). ```javascript SCIMMY.Schemas.declared() ``` -------------------------------- ### Declare SCIM Resources with Handlers Source: https://github.com/scimmyjs/scimmy/blob/main/_autodocs/api-reference/resources.md Configure service provider capabilities and declare custom resources like 'User' with specific ingress, egress, and degress handlers. This example shows setting up patch, filter, bulk, sort, and etag capabilities, then declaring a User resource with enterprise extensions and custom data access logic. ```javascript // 1. Configure service provider capabilities SCIMMY.Config.set({ patch: true, filter: 100, bulk: {supported: true, maxOperations: 1000}, sort: true, etag: true }); // 2. Declare resources with handlers SCIMMY.Resources.declare(SCIMMY.Resources.User, { basepath: "https://api.example.com/scim/v2", extensions: [{schema: SCIMMY.Schemas.EnterpriseUser, required: true}], ingress: async (resource, instance) => { return await UserService.save(instance); }, egress: async (resource) => { if (resource.id) return await UserService.getById(resource.id); return await UserService.search(resource.filter, resource.constraints); }, degress: async (resource) => { await UserService.delete(resource.id); } }) .egress(async (resource) => { // Group handler }) .degress(async (resource) => { // Group delete handler }); // 3. Query declared resources const declared = SCIMMY.Resources.declared(); console.log(Object.keys(declared)); // ["User", "Group", ...] ``` -------------------------------- ### Discover Available Schemas Source: https://github.com/scimmyjs/scimmy/blob/main/_autodocs/api-reference/schemas.md SCIM clients discover available schemas through the /Schemas endpoint. This example shows how to retrieve all declared schemas after setting up resources and custom schemas. ```javascript // After declaring resources and schemas: SCIMMY.Resources.declare(SCIMMY.Resources.User); // GET /Schemas returns all declared schemas // Response includes all User schema, Group schema, extensions, custom schemas, etc. ``` -------------------------------- ### SCIMMY BulkRequest Constructor and Example Source: https://github.com/scimmyjs/scimmy/blob/main/_autodocs/api-reference/messages.md Formats SCIM bulk operation requests. Each operation specifies a method, path, optional data, and a bulkId for client-side referencing. ```javascript const bulkRequest = new SCIMMY.Messages.BulkRequest([ { method: "POST", path: "/Users", bulkId: "qwerty", data: {userName: "newuser@example.com"} }, { method: "PATCH", path: "/Users/123", bulkId: "asdfgh", data: {Operations: [{op: "replace", path: "active", value: false}]} } ]); ``` -------------------------------- ### Schema Instance Validation Example Source: https://github.com/scimmyjs/scimmy/blob/main/_autodocs/api-reference/schema.md Illustrates attribute validation during schema instance creation and modification, including type coercion, mutability enforcement, and immutability checks. ```javascript const user = new SCIMMY.Schemas.User({userName: "test"}); // Valid: Setting a mutable attribute user.displayName = "Test User"; // OK // Invalid: Modifying immutable attribute throws error user.meta.created = new Date(); // SCIMError: 400 - Attribute 'meta.created' is not mutable // Invalid: Setting wrong type throws error user.active = "yes"; // SCIMError: 400 - Expected boolean type for attribute 'active' ``` -------------------------------- ### SCIMMY Configuration Structure Example Source: https://github.com/scimmyjs/scimmy/wiki/Global-Configuration-Store This JSON object represents the structure of a SCIM Service Provider's configuration as defined in RFC7643§8.5. It details supported features and their parameters. ```json { "documentationUri": "/path/to/documentation.html", "patch": { "supported": false }, "bulk": { "supported": false, "maxOperations": 1000, "maxPayloadSize": 1048576 }, "filter": { "supported": false, "maxResults": 200 }, "changePassword": { "supported": false }, "sort": { "supported": false }, "etag": { "supported": false }, "authenticationSchemes": [] } ``` -------------------------------- ### SCIMMY BulkResponse Constructor and Example Source: https://github.com/scimmyjs/scimmy/blob/main/_autodocs/api-reference/messages.md Formats SCIM bulk operation responses. Each operation in the response includes details like location, method, status, and the response body or error. ```javascript const bulkResponse = new SCIMMY.Messages.BulkResponse([ { bulkId: "qwerty", method: "POST", status: 201, location: "/Users/newid123", response: {id: "newid123", userName: "newuser@example.com"} }, { bulkId: "asdfgh", method: "PATCH", status: 204, location: "/Users/123" } ]); ``` -------------------------------- ### SCIMMY SearchRequest Constructor and Example Source: https://github.com/scimmyjs/scimmy/blob/main/_autodocs/api-reference/messages.md Formats SCIM search request messages for advanced resource queries. Supports filtering, attribute selection, sorting, and pagination. ```javascript const searchRequest = new SCIMMY.Messages.SearchRequest({ schemas: ["urn:ietf:params:scim:api:messages:2.0:SearchRequest"], filter: 'emails co "@example.com" and active eq true', attributes: ["id", "userName", "emails"], sortBy: "userName", sortOrder: "ascending", startIndex: 1, count: 20 }); ``` -------------------------------- ### Add Multiple Authentication Schemes Source: https://github.com/scimmyjs/scimmy/wiki/Global-Configuration-Store The `authenticationSchemes` collection can be updated by providing an array of scheme objects to the `set` method. This example adds two authentication schemes. ```javascript SCIMMY.Config.set("authenticationSchemes", [ {/* Your primary authentication scheme details */}, {/* Your secondary authentication scheme details */} ]); ``` -------------------------------- ### Get Service Provider Configuration Source: https://github.com/scimmyjs/scimmy/blob/main/_autodocs/INDEX.md Retrieves the current service provider configuration. This method is part of the SCIMMY.Config class. ```javascript SCIMMY.Config.get() ``` -------------------------------- ### SCIMMY PatchOp Constructor and Example Source: https://github.com/scimmyjs/scimmy/blob/main/_autodocs/api-reference/messages.md Constructs a SCIM patch operation object. Use this to define add, replace, or remove operations on resource attributes. The 'apply' method can be used to apply these operations to a resource. ```javascript const patchOp = new SCIMMY.Messages.PatchOp({ schemas: ["urn:ietf:params:scim:api:messages:2.0:PatchOp"], Operations: [ {op: "replace", path: "displayName", value: "New Name"}, {op: "add", path: "emails", value: [{value: "new@example.com", type: "work"}]}, {op: "remove", path: "nickName"} ] }); // Apply to resource await patchOp.apply(userResource, (patch) => { // Handle the patched resource }); ``` -------------------------------- ### Add Authentication Scheme Source: https://github.com/scimmyjs/scimmy/wiki/Global-Configuration-Store Authentication schemes can be added to the `authenticationSchemes` collection using the `set` method. This example shows adding a single scheme object. ```javascript SCIMMY.Config.set("authenticationSchemes", {/* Your authentication scheme details */}); ``` -------------------------------- ### Handle HTTP Endpoints for SCIM Resources Source: https://github.com/scimmyjs/scimmy/blob/main/_autodocs/README.md Implement HTTP endpoint handlers for common SCIM operations like GET and POST for resources like Users. This involves creating resource instances and handling request data. ```javascript // 3. Handle HTTP endpoints app.get('/scim/v2/Users/:id?', async (req, res) => { const resource = new SCIMMY.Resources.User(req.params.id); // ... handle request }); app.post('/scim/v2/Users', async (req, res) => { const resource = new SCIMMY.Resources.User(); // ... handle request }); ``` -------------------------------- ### Get SCIM Service Provider Configuration Source: https://github.com/scimmyjs/scimmy/blob/main/_autodocs/api-reference/config.md Retrieves the current SCIM service provider configuration as a protected clone. Defaults are returned if no configuration has been explicitly set. ```javascript const config = SCIMMY.Config.get(); console.log(config.patch.supported); // false (default) console.log(config.bulk.maxOperations); // 1000 ``` -------------------------------- ### Comparison Operators Source: https://github.com/scimmyjs/scimmy/blob/main/_autodocs/api-reference/filter.md Reference for all supported SCIM comparison operators used in filter expressions, including their name, example usage, and a brief description of their functionality. ```APIDOC ## Comparison Operators | Operator | Name | Example | Description | |----------|------|---------|-------------| | eq | Equal | `userName eq "bjensen"` | Exact match | | ne | Not equal | `userName ne "bjensen"` | Not matching | | co | Contains | `userName co "jensen"` | Substring match | | sw | Starts with | `userName sw "bj"` | Prefix match | | ew | Ends with | `userName ew "sen"` | Suffix match | | gt | Greater than | `id gt "5"` | Greater than comparison | | lt | Less than | `id lt "10"` | Less than comparison | | ge | Greater or equal | `id ge "5"` | Greater than or equal | | le | Less or equal | `id le "10"` | Less than or equal | | pr | Present | `name pr` | Attribute is present | | np | Not present | `name np` | Attribute is absent | ``` -------------------------------- ### Retrieve Service Provider Configuration Source: https://github.com/scimmyjs/scimmy/blob/main/_autodocs/api-reference/resources.md Fetch the service provider's configuration, detailing its supported features and capabilities. This is typically done via a GET request to the /ServiceProviderConfig endpoint. ```javascript // GET /ServiceProviderConfig - Returns service provider features ``` -------------------------------- ### Create a Paginated List Response Source: https://github.com/scimmyjs/scimmy/blob/main/_autodocs/api-reference/messages.md Use this snippet to construct a SCIM ListResponse for paginated results. It requires the retrieved resources, total count, starting index, and items per page. ```javascript // Retrieve resources with pagination const users = await db.users.find(filter).limit(20).skip(0); const totalResults = await db.users.countDocuments(filter); const listResponse = new SCIMMY.Messages.ListResponse(users, { totalResults, startIndex: 1, itemsPerPage: 20 }); res.json(listResponse); ``` -------------------------------- ### Set Patch Supported to True Source: https://github.com/scimmyjs/scimmy/wiki/Global-Configuration-Store Use the `set` method with a property name and a boolean value to enable or disable top-level configuration properties that only have a 'supported' child. This example enables the PATCH operation. ```javascript SCIMMY.Config.set("patch", true); ``` -------------------------------- ### Constructor Source: https://github.com/scimmyjs/scimmy/blob/main/_autodocs/api-reference/resource.md Instantiates a new resource instance and parses any supplied parameters for configuration. ```APIDOC ## Constructor(path, attributes, excludedAttributes, filter, sortBy, sortOrder, startIndex, count) ### Description Instantiate a new resource instance and parse any supplied parameters. ### Parameters - **path** (string or Object) - Resource ID or query parameters object. - **attributes** (string) - Comma-separated list of attributes to include. - **excludedAttributes** (string) - Comma-separated list of attributes to exclude. - **filter** (string) - SCIM filter expression. - **sortBy** (string) - Attribute path to sort by. - **sortOrder** (string) - "ascending" or "descending". - **startIndex** (string or number) - Start position for pagination (minimum 1). - **count** (string or number) - Number of results per page. ### Example ```javascript // Retrieve specific user const userResource = new SCIMMY.Resources.User("12345"); // List users with filter and pagination const listResource = new SCIMMY.Resources.User({ filter: 'userName eq "john.doe@example.com"', sortBy: "userName", sortOrder: "ascending", startIndex: 1, count: 20, attributes: "id,userName,displayName" }); ``` ``` -------------------------------- ### SCIMMY.Resources.declared() Source: https://github.com/scimmyjs/scimmy/blob/main/_autodocs/api-reference/resources.md Query the registration status of resources or retrieve declared resources. This method can be called without arguments to get all declared resources, with a resource name (string) to get a specific resource, or with a resource class to check its declaration status. ```APIDOC ## SCIMMY.Resources.declared([resource]) Query the registration status of resources or retrieve declared resources. ### Signature (Overload 1 - No Parameters): ```javascript static declared(): Record ``` ### Signature (Overload 2 - String Name): ```javascript static declared(resource: String): typeof SCIMMY.Types.Resource | undefined ``` ### Signature (Overload 3 - Resource Class): ```javascript static declared(resource: typeof SCIMMY.Types.Resource): Boolean ``` ### Parameters #### Path Parameters - **resource** (string or Resource class) - Optional: specific resource to query ### Returns - No arguments: Object with resource names as keys and resource classes as values - String argument: Resource class matching the name, or undefined if not found - Resource class argument: Boolean indicating if the resource is declared ### Example (Get All): ```javascript // Get all declared resources const declared = SCIMMY.Resources.declared(); console.log(Object.keys(declared)); // ["User", "Group", "CustomResource"] ``` ### Example (Get Specific): ```javascript // Get specific declared resource const UserResource = SCIMMY.Resources.declared("User"); console.log(UserResource.endpoint); // "/Users" // Undefined if not declared const notDeclared = SCIMMY.Resources.declared("Unknown"); console.log(notDeclared); // undefined ``` ### Example (Check Status): ```javascript // Check if resource is declared const isDeclared = SCIMMY.Resources.declared(SCIMMY.Resources.User); console.log(isDeclared); // true class CustomResource extends SCIMMY.Types.Resource {} console.log(SCIMMY.Resources.declared(CustomResource)); // false (not declared yet) ``` ``` -------------------------------- ### Query Schema Declaration Status Source: https://github.com/scimmyjs/scimmy/blob/main/_autodocs/api-reference/schemas.md Use `SCIMMY.Schemas.declared()` to check if a schema is declared or to retrieve its definition. It can be called with no arguments to get all declared schemas, a string name/ID to get a specific schema, or a SchemaDefinition instance to check its declaration status. ```javascript static declared(): SCIMMY.Types.SchemaDefinition[] ``` ```javascript static declared(definition: String): SCIMMY.Types.SchemaDefinition | undefined ``` ```javascript static declared(definition: SCIMMY.Types.SchemaDefinition): Boolean ``` -------------------------------- ### Instantiate Resource with Parameters Source: https://github.com/scimmyjs/scimmy/blob/main/_autodocs/api-reference/resource.md Instantiates a new resource instance. Use for retrieving a specific resource by ID or listing resources with filtering and pagination options. ```javascript // Retrieve specific user const userResource = new SCIMMY.Resources.User("12345"); // List users with filter and pagination const listResource = new SCIMMY.Resources.User({ filter: 'userName eq "john.doe@example.com"', sortBy: "userName", sortOrder: "ascending", startIndex: 1, count: 20, attributes: "id,userName,displayName" }); ``` -------------------------------- ### Initialize and Configure SCIMMY Service Provider Source: https://github.com/scimmyjs/scimmy/blob/main/_autodocs/README.md Set up the SCIMMY service provider configuration, including documentation URI, patch support, filter limits, bulk limits, sort options, and authentication schemes. ```javascript // 1. Initialize and configure import SCIMMY from "scimmy"; SCIMMY.Config.set({ documentationUri: "https://docs.example.com/scim", patch: true, filter: 50, bulk: 1000, sort: true, authenticationSchemes: [ {type: "oauthBearerToken", primary: true} ] }); ``` -------------------------------- ### GET /Schemas Source: https://github.com/scimmyjs/scimmy/blob/main/_autodocs/api-reference/resources.md Retrieves all declared schema definitions. This endpoint is read-only. ```APIDOC ## GET /Schemas ### Description Returns all declared schema definitions. ### Method GET ### Endpoint /Schemas ### Response #### Success Response (200) - **schemas** (object) - An object containing schema definitions. ``` -------------------------------- ### Basic SCIMMY Usage Source: https://github.com/scimmyjs/scimmy/blob/main/_autodocs/README.md Demonstrates configuring service provider features, declaring a resource type with ingress, egress, and degress handlers, and using it in an HTTP POST handler. ```javascript import SCIMMY from "scimmy"; // 1. Configure service provider features SCIMMY.Config.set({ patch: true, filter: 100, bulk: {supported: true, maxOperations: 1000}, sort: true }); // 2. Declare a resource type SCIMMY.Resources.declare(SCIMMY.Resources.User, { basepath: "https://api.example.com/scim/v2" }) .ingress(async (resource, instance, ctx) => { // Handle create/update if (resource.id) { return await db.users.update(resource.id, instance); } else { return await db.users.create(instance); } }) .egress(async (resource, ctx) => { // Handle read if (resource.id) { return await db.users.findById(resource.id); } else { return await db.users.findMany(resource.filter, resource.constraints); } }) .degress(async (resource, ctx) => { // Handle delete await db.users.delete(resource.id); }); // 3. Use in HTTP handlers app.post('/scim/v2/Users', async (req, res) => { try { const resource = new SCIMMY.Resources.User(); const created = await resource.write(req.body); res.status(201).json(created); } catch (error) { res.status(error.status || 500).json( new SCIMMY.Messages.ErrorResponse(error.scimType, error.message, error.status) ); } }); ``` -------------------------------- ### GET /ResourceTypes Source: https://github.com/scimmyjs/scimmy/blob/main/_autodocs/api-reference/resources.md Retrieves all declared resource type definitions. This endpoint is read-only. ```APIDOC ## GET /ResourceTypes ### Description Returns all declared resource types. ### Method GET ### Endpoint /ResourceTypes ### Response #### Success Response (200) - **resourceTypes** (object) - An object containing resource type definitions. ``` -------------------------------- ### Basic SCIMMY Usage with Resource Types Source: https://github.com/scimmyjs/scimmy/blob/main/README.md Declare a resource type (e.g., User) and define handlers for ingress (create/modify), egress (retrieve), and degress (delete) operations. This is for basic usage with provided resource type implementations. ```javascript import SCIMMY from "scimmy"; // Basic usage with provided resource type implementations SCIMMY.Resources.declare(SCIMMY.Resources.User) .ingress((resource, data) => {/* Your handler for creating or modifying user resources */}) .egress((resource) => {/* Your handler for retrieving user resources */}) .degress((resource) => {/* Your handler for deleting user resources */}); ``` -------------------------------- ### Attribute.coerce() Example Source: https://github.com/scimmyjs/scimmy/blob/main/_autodocs/GENERATION_REPORT.txt Demonstrates coercing a value to a specific attribute type using Attribute.coerce(). ```javascript Attribute.coerce() ``` -------------------------------- ### GET /ServiceProviderConfig Source: https://github.com/scimmyjs/scimmy/blob/main/_autodocs/api-reference/resources.md Retrieves the service provider configuration, detailing supported features. This endpoint is read-only. ```APIDOC ## GET /ServiceProviderConfig ### Description Returns service provider features. ### Method GET ### Endpoint /ServiceProviderConfig ### Response #### Success Response (200) - **config** (object) - An object detailing the service provider's configuration. ``` -------------------------------- ### Constructor Source: https://github.com/scimmyjs/scimmy/blob/main/_autodocs/api-reference/attribute.md Create a new SCIM attribute definition with configuration and optional sub-attributes. ```APIDOC ## new Attribute(type, name, [config], [subAttributes]) ### Description Create a new SCIM attribute definition with configuration and optional sub-attributes. ### Parameters #### Parameters - **type** (string) - Yes - — - Attribute data type (see Attribute Types) - **name** (string) - Yes - — - Attribute name (must start with lowercase per RFC7643) - **config** (object) - No - {} - Attribute configuration properties - **subAttributes** (Attribute[]) - No - [] - For complex types, array of sub-attributes #### Config Properties - **multiValued** (boolean) - false - Whether attribute is a collection - **required** (boolean) - false - Whether attribute is required - **mutable** (boolean\|string) - true - Mutability constraint (true, false, "readOnly", "readWrite", "immutable", "writeOnly") - **returned** (boolean\|string) - true - Whether returned in responses ("always", "never", "default", "request") - **caseExact** (boolean) - false - Whether value is case-sensitive - **description** (string) - "" - Human-readable attribute description - **canonicalValues** (string[] \| false) - false - List of allowed values, or false for unrestricted - **referenceTypes** (string[] \| false) - false - For reference types, list of referenceable types - **uniqueness** (string) - "none" - Uniqueness constraint ("none", "server", "global") - **direction** (string) - "both" - Data flow ("both", "in" for inbound, "out" for outbound) - **shadow** (boolean) - false - Hide from schema endpoint if true ### Returns - **Attribute** - Configured attribute instance ### Example ```javascript // Simple string attribute const userName = new SCIMMY.Types.Attribute("string", "userName", { required: true, uniqueness: "server", description: "Unique user identifier" }); // Complex multi-valued attribute const emails = new SCIMMY.Types.Attribute("complex", "emails", {multiValued: true, description: "User email addresses"}, [ new SCIMMY.Types.Attribute("string", "value"), new SCIMMY.Types.Attribute("string", "type", {canonicalValues: ["work", "home", "other"]}), new SCIMMY.Types.Attribute("boolean", "primary") ] ); // Reference attribute const manager = new SCIMMY.Types.Attribute("reference", "manager", { referenceTypes: ["User"], description: "User's manager" }); // Immutable attribute (can be set at creation only) const created = new SCIMMY.Types.Attribute("dateTime", "created", { mutable: "immutable", returned: "always" }); // Write-only attribute (password) const password = new SCIMMY.Types.Attribute("string", "password", { direction: "in", returned: "never", description: "User password" }); ``` ``` -------------------------------- ### Throw SCIMError with uniqueness constraint violation Source: https://github.com/scimmyjs/scimmy/blob/main/_autodocs/types.md Example of throwing a SCIMError when a uniqueness constraint is violated, such as a duplicate email address. ```javascript throw new SCIMMY.Types.Error( 409, "uniqueness", "Email address must be unique" ); ``` -------------------------------- ### Throw SCIMError with invalidValue Source: https://github.com/scimmyjs/scimmy/blob/main/_autodocs/types.md Example of throwing a SCIMError indicating an invalid attribute value, typically used for validation failures. ```javascript throw new SCIMMY.Types.Error( 400, "invalidValue", "Email address format is invalid" ); ``` -------------------------------- ### Get Schema by ID Source: https://github.com/scimmyjs/scimmy/blob/main/_autodocs/api-reference/schemas.md Retrieve a specific schema definition using its full URN identifier. This is useful for precise schema lookups. ```javascript // Get schema by URN ID const schema = SCIMMY.Schemas.declared( "urn:ietf:params:scim:schemas:core:2.0:User" ); console.log(schema.name); // "User" ``` -------------------------------- ### SCIMMY.Config.get() Source: https://github.com/scimmyjs/scimmy/blob/main/_autodocs/INDEX.md Retrieves the current service provider configuration settings. ```APIDOC ## SCIMMY.Config.get() ### Description Retrieves the current service provider configuration settings. ### Method GET ### Endpoint /ServiceProviderConfig ### Parameters None ### Response #### Success Response (200) - **config** (object) - The service provider configuration object. #### Response Example ```json { "documentation": "https://example.com/scim/v2/help", "patch": { "supported": true, "bulk": true }, "filter": { "supported": true, "maxResults": 100 }, "changePassword": { "supported": false }, "sort": { "supported": false }, "authenticationSchemes": [ { "name": "OAuth2", "description": "OAuth 2.0 Bearer Token Flow", "specUrl": "https://tools.ietf.org/html/rfc6750", "type": "oauth2", "primary": true } ] } ``` ``` -------------------------------- ### Get Schema by Name Source: https://github.com/scimmyjs/scimmy/blob/main/_autodocs/api-reference/schemas.md Retrieve a specific schema definition by its declared name (e.g., 'User'). Returns `undefined` if the schema is not found. ```javascript // Get schema by declaration name const userSchema = SCIMMY.Schemas.declared("User"); console.log(userSchema.id); // "urn:ietf:params:scim:schemas:core:2.0:User" // Undefined if not declared const notFound = SCIMMY.Schemas.declared("Unknown"); console.log(notFound); // undefined ``` -------------------------------- ### Config.get() Source: https://github.com/scimmyjs/scimmy/blob/main/_autodocs/api-reference/config.md Retrieves the current SCIM service provider configuration as a protected clone. This method allows users to inspect the supported features and their configurations without the risk of accidental modification. ```APIDOC ## Config.get() ### Description Retrieves the current SCIM service provider configuration as a protected clone. This method allows users to inspect the supported features and their configurations without the risk of accidental modification. ### Method `static get(): Object` ### Returns - **documentationUri** (string | undefined) - URI to service provider documentation - **patch** (Object) - Patch operation support configuration - **patch.supported** (boolean) - Whether PATCH operations are supported - **bulk** (Object) - Bulk operation configuration - **bulk.supported** (boolean) - Whether bulk operations are supported - **bulk.maxOperations** (number) - Maximum operations per bulk request (default: 1000) - **bulk.maxPayloadSize** (number) - Maximum payload size in bytes (default: 1048576) - **filter** (Object) - Filter expression support configuration - **filter.supported** (boolean) - Whether filter expressions are supported - **filter.maxResults** (number) - Maximum results per filtered request (default: 200) - **changePassword** (Object) - Change password operation support - **changePassword.supported** (boolean) - Whether change password is supported - **sort** (Object) - Sort operation support - **sort.supported** (boolean) - Whether sorting is supported - **etag** (Object) - ETag support configuration - **etag.supported** (boolean) - Whether ETags are supported - **authenticationSchemes** (Array) - Array of supported authentication schemes ### Throws Attempting to modify the returned configuration object throws `TypeError: SCIM Configuration can only be changed via the 'set' method`. ### Example ```javascript const config = SCIMMY.Config.get(); console.log(config.patch.supported); // false (default) console.log(config.bulk.maxOperations); // 1000 ``` ``` -------------------------------- ### Get All Declared Schemas Source: https://github.com/scimmyjs/scimmy/blob/main/_autodocs/api-reference/schemas.md Retrieve an array of all currently declared schema definitions, including any extensions. This is useful for inspecting the schema registry. ```javascript // Get all declared schema definitions const schemas = SCIMMY.Schemas.declared(); console.log(schemas.length); // Number of declared schemas schemas.forEach(schema => { console.log(schema.name, schema.id); }); ``` -------------------------------- ### Chaining Resource Declarations with Handlers Source: https://github.com/scimmyjs/scimmy/blob/main/_autodocs/api-reference/resources.md Demonstrates method chaining after declaring a resource. This allows for sequential configuration of ingress, egress, and degress handlers, improving code readability and organization for complex resource management. ```javascript SCIMMY.Resources.declare(SCIMMY.Resources.User) .ingress(async (resource, instance, ctx) => { if (resource.id) { return await UserController.update(resource.id, instance); } else { return await UserController.create(instance); } }) .egress(async (resource, ctx) => { if (resource.id) { return await UserController.getById(resource.id); } else { return await UserController.list(resource.filter); } }) .degress(async (resource, ctx) => { await UserController.delete(resource.id); }); ``` -------------------------------- ### Get Schema Definition Source: https://github.com/scimmyjs/scimmy/blob/main/_autodocs/api-reference/schema.md Access the SchemaDefinition instance associated with a SCIM schema. This allows retrieval of attribute configurations, constraints, and metadata. ```javascript const userDef = SCIMMY.Schemas.User.definition; const userName = userDef.attribute("userName"); ``` -------------------------------- ### Get Schema URN Identifier Source: https://github.com/scimmyjs/scimmy/blob/main/_autodocs/api-reference/schema.md Retrieve the unique URN identifier for a SCIM schema. This is a static getter specific to each schema subclass. ```javascript SCIMMY.Schemas.User.id; // "urn:ietf:params:scim:schemas:core:2.0:User" SCIMMY.Schemas.Group.id; // "urn:ietf:params:scim:schemas:core:2.0:Group" ``` -------------------------------- ### Declare and Configure Resource Source: https://github.com/scimmyjs/scimmy/blob/main/_autodocs/api-reference/resource.md Declares a resource with its configuration, including base path and extensions. This pattern is used to set up handlers for ingress (create/update), egress (read), and degress (delete) operations. ```javascript // 1. Declare resource with configuration SCIMMY.Resources.declare(SCIMMY.Resources.User, { basepath: "https://example.com/scim/v2", extensions: [{schema: SCIMMY.Schemas.EnterpriseUser, required: true}] }) .ingress(async (resource, instance, ctx) => { // Handle create/update }) .egress(async (resource, ctx) => { // Handle read }) .degress(async (resource, ctx) => { // Handle delete }); // 2. Use in request handling const userResource = new SCIMMY.Resources.User("user123"); const user = await userResource.read(); // Invokes egress handler ``` -------------------------------- ### Throw generic SCIMError Source: https://github.com/scimmyjs/scimmy/blob/main/_autodocs/types.md Example of throwing a generic SCIMError when no specific SCIM type applies, often used for 'Not Found' scenarios. ```javascript throw new SCIMMY.Types.Error( 404, null, "Resource not found" ); ``` -------------------------------- ### Create and Declare Custom Schema Source: https://github.com/scimmyjs/scimmy/blob/main/_autodocs/api-reference/schemedefinition.md Define a new custom SCIM schema using SchemaDefinition and Attribute classes, then register it using SCIMMY.Schemas.declare. ```javascript const customSchema = new SCIMMY.Types.SchemaDefinition( "CustomUser", "urn:example:params:scim:schemas:custom:2.0:User", "Extended User Schema", [ new SCIMMY.Types.Attribute("string", "employeeId", { required: true, uniqueness: "server" }), new SCIMMY.Types.Attribute("string", "department"), new SCIMMY.Types.Attribute("string", "manager", { referenceTypes: ["User"] }) ] ); // Register for use SCIMMY.Schemas.declare(customSchema, "CustomUser"); ``` -------------------------------- ### Get Resource Schema Source: https://github.com/scimmyjs/scimmy/blob/main/_autodocs/api-reference/resource.md Abstract getter returning the resource's core Schema definition class. Throws TypeError if not implemented by subclass. ```javascript SCIMMY.Resources.User.schema; SCIMMY.Resources.Group.schema; ``` -------------------------------- ### Declare a Resource Source: https://github.com/scimmyjs/scimmy/blob/main/_autodocs/api-reference/resources.md Declare a SCIM resource and configure its ingress, egress, and degress handlers. This is typically done once during application startup. ```javascript SCIMMY.Resources.declare(SCIMMY.Resources.User) .ingress(/* ... */) .egress(/* ... */) .degress(/* ... */); ``` -------------------------------- ### Access Attribute Instance Properties Source: https://github.com/scimmyjs/scimmy/blob/main/_autodocs/api-reference/attribute.md Demonstrates how to access the name, type, and configuration properties of a SCIMMY Attribute instance. ```javascript const attr = new SCIMMY.Types.Attribute("string", "email"); console.log(attr.name); // "email" console.log(attr.type); // "string" console.log(attr.config.required); // false console.log(attr.config.multiValued); // false ``` -------------------------------- ### Schema Constructor Source: https://github.com/scimmyjs/scimmy/blob/main/_autodocs/api-reference/schema.md Constructs a resource instance by verifying schema compatibility. It validates the provided data against the schema and coerces types. ```APIDOC ## new Schema(data, [direction]) ### Description Constructs a resource instance after verifying schema compatibility. ### Parameters #### Path Parameters * None #### Query Parameters * None #### Request Body * **data** (object) - Required - Source data to validate and coerce through schema * **direction** (string) - Optional - Defaults to "both". Can be "both", "in" (inbound request), or "out" (outbound response). ### Returns * **Schema** - Validated schema instance with attribute accessors ### Throws * `SCIMError` with status 400 if required attributes are missing * `SCIMError` with status 400 if invalid attribute values are provided * `SCIMError` with status 400 for mutability violations ### Request Example ```javascript // Create new user from inbound request data const userData = { userName: "john.doe@example.com", name: { givenName: "John", familyName: "Doe" }, emails: [ {value: "john.doe@example.com", type: "work", primary: true} ] }; const userInstance = new SCIMMY.Schemas.User(userData, "in"); // Access validated properties console.log(userInstance.userName); // "john.doe@example.com" console.log(userInstance.id); // Auto-generated UUID console.log(userInstance.meta); // {resourceType: "User", created: Date, ...} ``` ``` -------------------------------- ### Retrieve Attribute by Name Source: https://github.com/scimmyjs/scimmy/blob/main/_autodocs/api-reference/schemedefinition.md Get an attribute definition from a SchemaDefinition using its name. Supports dot notation for sub-attributes and filtering by direction ('in' or 'out'). ```javascript const userDef = SCIMMY.Schemas.User.definition; // Get top-level attribute const userName = userDef.attribute("userName"); console.log(userName.type); // "string" console.log(userName.config.required); // true // Get sub-attribute using dot notation const familyName = userDef.attribute("name.familyName"); console.log(familyName.type); // "string" // Get attribute for inbound direction only const password = userDef.attribute("password", "in"); // Returns password attribute const passwordOut = userDef.attribute("password", "out"); // Returns undefined (password is direction: "in") ``` -------------------------------- ### Declare User Resource (Minimal) Source: https://github.com/scimmyjs/scimmy/blob/main/_autodocs/api-reference/resources.md Registers the User resource with its default name. Use this for basic declarations without custom configurations. ```javascript SCIMMY.Resources.declare(SCIMMY.Resources.User); ``` -------------------------------- ### Define Complex Attribute with Sub-attributes Source: https://github.com/scimmyjs/scimmy/blob/main/_autodocs/api-reference/attribute.md Example of defining a complex attribute named 'address' with multiple sub-attributes. Use for structured data like physical addresses. ```javascript // Define a complex attribute with sub-attributes const address = new SCIMMY.Types.Attribute("complex", "address", {multiValued: true}, [ new SCIMMY.Types.Attribute("string", "formatted"), new SCIMMY.Types.Attribute("string", "streetAddress"), new SCIMMY.Types.Attribute("string", "locality"), new SCIMMY.Types.Attribute("string", "region"), new SCIMMY.Types.Attribute("string", "postalCode"), new SCIMMY.Types.Attribute("string", "country") ] ); // Usage in data: // addresses: [ // { // formatted: "100 Universal City Plaza, Hollywood, CA 91608 USA", // streetAddress: "100 Universal City Plaza", // locality: "Hollywood", // region: "CA", // postalCode: "91608", // country: "USA" // } // ] ``` -------------------------------- ### Create Custom SchemaDefinition Source: https://github.com/scimmyjs/scimmy/blob/main/_autodocs/api-reference/schemedefinition.md Instantiate a new SchemaDefinition with a name, ID, description, and an array of initial attributes. Use this to define custom SCIM schemas. ```javascript const customSchema = new SCIMMY.Types.SchemaDefinition( "Custom", "urn:custom:schema:custom:2.0", "Custom user schema", [ new SCIMMY.Types.Attribute("string", "customField", { required: true, description: "Custom field" }), new SCIMMY.Types.Attribute("integer", "customNumber") ] ); ``` -------------------------------- ### Create Custom SCIM Resources Source: https://github.com/scimmyjs/scimmy/blob/main/_autodocs/README.md Extend the SCIMMY.Types.Resource base class to define custom SCIM resources. Specify the endpoint and schema, then declare the resource with handlers. ```javascript // Extend Resource base class class CustomResource extends SCIMMY.Types.Resource { static get endpoint() { return "/Custom"; } static get schema() { return SCIMMY.Schemas.User; // or custom schema } } // Declare with handlers SCIMMY.Resources.declare(CustomResource, { ingress: async (resource, instance) => {/* ... */}, egress: async (resource) => {/* ... */}, degress: async (resource) => {/* ... */} }); ``` -------------------------------- ### Retrieve All Declared Schema Definitions Source: https://github.com/scimmyjs/scimmy/blob/main/_autodocs/api-reference/resources.md Fetch all schema definitions that have been declared within the SCIMMY application. This is typically done via a GET request to the /Schemas endpoint. ```javascript // GET /Schemas - Returns all declared schema definitions ``` -------------------------------- ### Declare User Resource with Handlers and Basepath Source: https://github.com/scimmyjs/scimmy/blob/main/_autodocs/api-reference/resources.md Declares the User resource with a custom base path and defines handlers for create/update (ingress), read (egress), and delete (degress) operations. This is useful for integrating SCIMMY with a custom data store or backend logic. ```javascript SCIMMY.Resources.declare(SCIMMY.Resources.User, { basepath: "https://example.com/scim/v2", ingress: async (resource, instance, ctx) => { // Handle create/update return await db.users.save(instance); }, egress: async (resource, ctx) => { // Handle read if (resource.id) { return await db.users.findById(resource.id); } else { return await db.users.find(resource.filter); } }, degress: async (resource, ctx) => { // Handle delete await db.users.deleteById(resource.id); } }); ``` -------------------------------- ### Declare SCIM Resources with Handlers Source: https://github.com/scimmyjs/scimmy/blob/main/_autodocs/README.md Declare SCIM resources, such as User, and define ingress, egress, and degress handlers to manage resource data flow. ```javascript // 2. Declare resources with handlers SCIMMY.Resources.declare(SCIMMY.Resources.User) .ingress(ingressHandler) .egress(egressHandler) .degress(degressHandler); ``` -------------------------------- ### Define Multi-valued Complex Attribute Source: https://github.com/scimmyjs/scimmy/blob/main/_autodocs/api-reference/attribute.md Example of creating a multi-valued complex attribute for 'emails', including sub-attributes for value, type, and primary status. Suitable for attributes that can have multiple entries. ```javascript const emails = new SCIMMY.Types.Attribute("complex", "emails", {multiValued: true}, [ new SCIMMY.Types.Attribute("string", "value"), new SCIMMY.Types.Attribute("string", "type", {canonicalValues: ["work", "home", "other"]}), new SCIMMY.Types.Attribute("boolean", "primary") ] ); // Usage in data: // emails: [ // {value: "john@work.com", type: "work", primary: true}, // {value: "john@personal.com", type: "home"}, // {value: "john@other.com", type: "other"} // ] ``` -------------------------------- ### Accessing SCIMMY.Messages Exports Source: https://github.com/scimmyjs/scimmy/blob/main/_autodocs/api-reference/messages.md Demonstrates the pattern for accessing various SCIM message classes exported by the SCIMMY.Messages singleton. ```javascript SCIMMY.Messages.ErrorResponse SCIMMY.Messages.ListResponse SCIMMY.Messages.PatchOp SCIMMY.Messages.BulkRequest SCIMMY.Messages.BulkResponse SCIMMY.Messages.SearchRequest ``` -------------------------------- ### Instantiate and Access User Schema Source: https://github.com/scimmyjs/scimmy/blob/main/_autodocs/api-reference/schema.md Create a new user instance from inbound data and access its validated properties, including auto-generated fields like ID and meta. ```javascript const userData = { userName: "john.doe@example.com", name: { givenName: "John", familyName: "Doe" }, emails: [ {value: "john.doe@example.com", type: "work", primary: true} ] }; const userInstance = new SCIMMY.Schemas.User(userData, "in"); // Access validated properties console.log(userInstance.userName); // "john.doe@example.com" console.log(userInstance.id); // Auto-generated UUID console.log(userInstance.meta); // {resourceType: "User", created: Date, ...} ``` -------------------------------- ### Directly Import Specific SCIMMY Classes Source: https://github.com/scimmyjs/scimmy/blob/main/_autodocs/README.md Import individual classes like Attribute, Schema, Resource, and SCIMError directly from the 'scimmy' package for more granular control. ```javascript // Import specific classes import { Attribute, SchemaDefinition, Schema, Resource, Filter, SCIMError, Config, Resources, Schemas, Messages } from "scimmy"; ``` -------------------------------- ### Declare Resource with Extensions Source: https://github.com/scimmyjs/scimmy/blob/main/_autodocs/api-reference/resources.md Declare a SCIM resource and include schema extensions at the time of declaration. This registers both the resource and its extensions. ```javascript SCIMMY.Resources.declare(SCIMMY.Resources.User, { extensions: [{schema: SCIMMY.Schemas.EnterpriseUser, required: true}] }); // Later retrieve: SCIMMY.Schemas.declared("EnterpriseUser"); // Returns schema ``` -------------------------------- ### Retrieve All Declared Resource Type Definitions Source: https://github.com/scimmyjs/scimmy/blob/main/_autodocs/api-reference/resources.md Fetch all resource type definitions that have been declared within the SCIMMY application. This is typically done via a GET request to the /ResourceTypes endpoint. ```javascript // GET /ResourceTypes - Returns all declared resource types ``` -------------------------------- ### Get Resource Endpoint Source: https://github.com/scimmyjs/scimmy/blob/main/_autodocs/api-reference/resource.md Abstract getter returning the resource's HTTP endpoint path relative to the service provider base URL. Throws TypeError if not implemented by subclass. ```javascript SCIMMY.Resources.User.endpoint; SCIMMY.Resources.Group.endpoint; ``` -------------------------------- ### ListResponse Source: https://github.com/scimmyjs/scimmy/blob/main/_autodocs/api-reference/messages.md Formats resource collections as paginated SCIM list responses. It accepts an array of resources and optional parameters for pagination and sorting. ```APIDOC ## ListResponse ### Description Formats resource collections as paginated SCIM list responses. This class is used to wrap arrays of SCIM resources, providing metadata for pagination and sorting as defined by the SCIM protocol. ### Constructor ```javascript new SCIMMY.Messages.ListResponse( resources?: Array | ListResponse, params?: { totalResults?: Number, itemsPerPage?: Number, startIndex?: Number, sortBy?: String, sortOrder?: String } ) ``` ### Properties ```json { "schemas": ["urn:ietf:params:scim:api:messages:2.0:ListResponse"], "Resources": Array, // Array of resource objects "totalResults": Number, // Total matching resources "startIndex": Number, // Start position (default: 1) "itemsPerPage": Number // Items in this response (default: 20) } ``` ### Example ```javascript const users = [ {id: "1", userName: "john.doe", displayName: "John Doe"}, {id: "2", userName: "jane.smith", displayName: "Jane Smith"} ]; const response = new SCIMMY.Messages.ListResponse(users, { totalResults: 1005, startIndex: 1, itemsPerPage: 2 }); console.log(response.Resources.length); // 2 console.log(response.totalResults); // 1005 ``` ```