Namespace: SCIMMY.Schemas
Namespace - SCIMMY.Schemas
Description
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:
TheSCIMMY.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 theSCIMMY.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
- Source:
- src/lib/schemas.js, line 8
Classes
-
- Ensures an EnterpriseUser instance conforms to the EnterpriseUser schema extension set out in RFC7643§4.3.
- Can be used directly, but is typically used to extend the
SCIMMY.Schemas.User
schema definition.
-
- Ensures a Group instance conforms to the Group schema set out in RFC7643§4.2.
-
- Ensures a ResourceType instance conforms to the ResourceType schema set out in RFC7643§6.
-
- Ensures a ServiceProviderConfig instance conforms to the Service Provider Configuration schema set out in RFC7643§5.
-
- Ensures a User instance conforms to the User schema set out in RFC7643§4.1.
Methods
(static) declare(definition, nameopt) → {SCIMMY.Schemas}
Register a SchemaDefinition implementation for exposure via Schemas HTTP endpoint
- Source:
- src/lib/schemas.js, line 94
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
(static) declared(definitionopt) → {SCIMMY.Types.SchemaDefinition[], SCIMMY.Types.SchemaDefinition, Boolean}
Get registration status of specific schema definition, or get all registered schema definitions
- Source:
- src/lib/schemas.js, line 126
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.