Namespace: SCIMMY.Schemas

SCIMMY provides a singleton class, SCIMMY.Schemas, that is used to declare schema definitions implemented by a SCIM Service Provider. It also provides access to supplied implementations of core resource type schema definitions. It is also used to retrieve a service provider's declared schema definitions to be sent via the Schemas HTTP endpoint.

Note:
The SCIMMY.Schemas class is a singleton, which means that declared schema definitions will remain the same, regardless of where the class is accessed from within your code.

Declaring Definitions

Schema definitions are typically declared automatically at the same time as resource type instances are declared in SCIMMY.Resources. If necessary, schema definitions can be declared manually with the SCIMMY.Schemas.declare method. Nested definitions that extend declared schema definitions are also automatically declared to the SCIMMY.Schemas class.

// Manually declare the EnterpriseUser schema definition
SCIMMY.Schemas.declare(SCIMMY.Schemas.EnterpriseUser.definition);

Once declared, schema definitions are made available to the SCIMMY.Resources.Schema resource type, which handles formatting them for transmission/consumption according to the Schema Definition schema set out in RFC7643§7.

Each schema definition must be declared with a unique name, and each name can only be declared once. Attempting to declare a new schema definition with a name that has already been declared will throw a TypeError with the message "Schema definition '<name>' already declared with id '<id>'", where <name> and <id> are the name and id, respectively, of the existing schema definition.

Similarly, each schema definition can only be declared under one name. Attempting to declare an existing schema definition under a new name will throw a TypeError with the message "Schema definition '<id>' already declared with name '<name>'", where <id> and <name> are the id and name, respectively, of the existing schema definition.

// Declaring a schema definition under a different name
let definition = new SCIMMY.Types.SchemaDefinition("User", "urn:ietf:params:scim:schemas:MyOrg:CustomUser", "MyOrg Custom User");
SCIMMY.Schemas.declare(definition, "CustomUser");

Modifying Definitions

Not all SCIM clients and service providers support every attribute defined in the SCIM core schemas, and conversely, some custom attributes may not be defined in the core schemas. In such situations, it is possible to modify schema definitions using their extend and truncate instance methods.

Note:
Like the SCIMMY.Schemas class, the schema implementations included in this class are all singletons, and any changes to their schema definitions will persist across any location they are accessed.

// Remove unsupported "name" sub-attributes from the User schema definition
SCIMMY.Schemas.User.definition.truncate(["name.middleName", "name.honorificPrefix", "name.honorificSuffix"]);

// Remove unsupported "ims" attribute and its sub-attributes from the User schema
SCIMMY.Schemas.User.definition.truncate(["ims"]);

// Add custom "mail" attribute to the Group schema definition
SCIMMY.Schemas.Group.definition.extend([new SCIMMY.Types.Attribute("string", "mail", {required: true})]);

// Extend the User schema definition with the EnterpriseUser schema definition, and make it required
SCIMMY.Schemas.User.definition.extend(SCIMMY.Schemas.EnterpriseUser.definition, true);

// Remove the EnterpriseUser extension schema definition from the User schema definition
SCIMMY.Schemas.User.definition.truncate(SCIMMY.Schemas.EnterpriseUser.definition);

Usage

Kind:
singleton

Classes

Methods

(static) declare(definition, nameopt) → {SCIMMY.Schemas}

Register a SchemaDefinition implementation for exposure via Schemas HTTP endpoint

Parameters:
Name Type Description
definition SCIMMY.Types.SchemaDefinition

the schema definition to register

nameopt String

the name of the definition being declared, if different from definition's name property

Returns:

the Schemas class for chaining

Type:
{SCIMMY.Schemas}

(static) declared(definitionopt) → {SCIMMY.Types.SchemaDefinition[], SCIMMY.Types.SchemaDefinition, Boolean}

Get registration status of specific schema definition, or get all registered schema definitions

Parameters:
Name Type Description
definitionopt SCIMMY.Types.SchemaDefinition|String

the schema definition or name to query registration status for

Returns:
  • Array containing declared schema definitions for exposure via Schemas HTTP endpoint, if no arguments are supplied.
  • The registered schema definition with matching name or ID, or undefined, if a string argument is supplied.
  • The registration status of the specified schema definition, if a class extending SCIMMY.Types.SchemaDefinition was supplied.