UNPKG

scimmy

Version:

SCIMMY - SCIM m(ade eas)y

943 lines (942 loc) 90.7 kB
declare module "scimmy/types" { import SCIMMY from "scimmy"; import Attribute = SCIMMY.Types.Attribute; import SCIMError = SCIMMY.Types.SCIMError; import Filter = SCIMMY.Types.Filter; import SchemaDefinition = SCIMMY.Types.SchemaDefinition; import Schema = SCIMMY.Types.Schema; import Resource = SCIMMY.Types.Resource; export { Attribute, SCIMError, Filter, SchemaDefinition, Schema, Resource }; export default SCIMMY.Types; } declare module "scimmy/schemas" { import SCIMMY from "scimmy"; import User = SCIMMY.Schemas.User; import Group = SCIMMY.Schemas.Group; import EnterpriseUser = SCIMMY.Schemas.EnterpriseUser; import ResourceType = SCIMMY.Schemas.ResourceType; import ServiceProviderConfig = SCIMMY.Schemas.ServiceProviderConfig; export { User, Group, EnterpriseUser, ResourceType, ServiceProviderConfig }; export default SCIMMY.Schemas; } declare module "scimmy/config" { import SCIMMY from "scimmy"; export default SCIMMY.Config; } declare module "scimmy/resources" { import SCIMMY from "scimmy"; import User = SCIMMY.Resources.User; import Group = SCIMMY.Resources.Group; import Schema = SCIMMY.Resources.Schema; import ResourceType = SCIMMY.Resources.ResourceType; import ServiceProviderConfig = SCIMMY.Resources.ServiceProviderConfig; export { User, Group, Schema, ResourceType, ServiceProviderConfig }; export default SCIMMY.Resources; } declare module "scimmy/messages" { import SCIMMY from "scimmy"; import ErrorResponse = SCIMMY.Messages.ErrorResponse; import ListResponse = SCIMMY.Messages.ListResponse; import PatchOp = SCIMMY.Messages.PatchOp; import BulkResponse = SCIMMY.Messages.BulkResponse; import BulkRequest = SCIMMY.Messages.BulkRequest; import SearchRequest = SCIMMY.Messages.SearchRequest; export { ErrorResponse, ListResponse, PatchOp, BulkResponse, BulkRequest, SearchRequest }; export default SCIMMY.Messages; } declare module "scimmy" { import Types = SCIMMY.Types; import Messages = SCIMMY.Messages; import Schemas = SCIMMY.Schemas; import Resources = SCIMMY.Resources; import Config = SCIMMY.Config; export { Types, Messages, Schemas, Resources, Config }; export default SCIMMY; export namespace SCIMMY { export class Types { static Error: typeof SCIMMY.Types.SCIMError; } export namespace Types { export class Attribute { /** * The data type of the attribute */ type: SCIMMY.Types.Attribute.ValidAttributeTypes; /** * The actual name of the attribute */ name: string; /** * Additional config defining the attribute's characteristics */ config: SCIMMY.Types.Attribute.AttributeConfig; /** * If the attribute is complex, the sub-attributes of the attribute */ subAttributes?: SCIMMY.Types.Attribute[]; /** * Constructs an instance of a full SCIM attribute definition * @param type The data type of the attribute * @param name The actual name of the attribute * @param config Additional config defining the attribute's characteristics * @param subAttributes If the attribute is complex, the sub-attributes of the attribute */ constructor(type: SCIMMY.Types.Attribute.ValidAttributeTypes, name: string, config?: SCIMMY.Types.Attribute.AttributeConfig, subAttributes?: SCIMMY.Types.Attribute[]); /** * Remove a subAttribute from a complex attribute definition * @param subAttributes The child attributes to remove from the complex attribute definition * @returns This attribute instance for chaining */ truncate(subAttributes: string | SCIMMY.Types.Attribute): SCIMMY.Types.Attribute; /** * Parse this Attribute instance into a valid SCIM attribute definition object * @returns An object representing a valid SCIM attribute definition */ toJSON(): SCIMMY.Types.Attribute.AttributeDefinition; /** * Coerce a given value by making sure it conforms to attribute's characteristics * @param source Value to coerce and confirm conformity with attribute's characteristics * @param direction Whether to check for inbound, outbound, or bidirectional attributes * @param isComplexMultiValue Indicates whether a coercion is for a single complex value in a collection of complex values * @returns The coerced value, conforming to attribute's characteristics */ coerce(source: any | any[], direction?: string, isComplexMultiValue?: boolean): any; } export namespace Attribute { /** * SCIMMY Attribute Instance Configuration properties */ export type AttributeConfig = { /** * Does the attribute expect a collection of values */ multiValued?: boolean; /** * A human-readable description of the attribute */ description?: string; /** * Whether the attribute is required for the type instance to be valid */ required?: boolean; /** * Values the attribute's contents must be set to */ canonicalValues?: boolean | string[]; /** * Whether the attribute's contents is case-sensitive */ caseExact?: boolean; /** * Whether the attribute's contents is modifiable */ mutable?: boolean | string; /** * Whether the attribute is returned in a response */ returned?: boolean | string; /** * List of referenced types if attribute type is reference */ referenceTypes?: boolean | string[]; /** * The attribute's uniqueness characteristic */ uniqueness?: string | boolean; /** * Whether the attribute should be present for inbound, outbound, or bidirectional requests */ direction?: string; /** * Whether the attribute should be hidden from schemas presented by the resource type endpoint */ shadow?: boolean; }; /** * Collection of valid attribute type characteristic's values */ export type ValidAttributeTypes = "string" | "complex" | "boolean" | "binary" | "decimal" | "integer" | "dateTime" | "reference"; /** * Collection of valid attribute mutability characteristic's values */ export type ValidMutabilityValues = "readOnly" | "readWrite" | "immutable" | "writeOnly"; /** * Collection of valid attribute returned characteristic's values */ export type ValidReturnedValues = "always" | "never" | "default" | "request"; /** * Collection of valid attribute uniqueness characteristic's values */ export type ValidUniquenessValues = "none" | "server" | "global"; /** * SCIM Attribute Definition properties */ export type AttributeDefinition = { /** * The attribute's name */ name: string; /** * The attribute's data type */ type: SCIMMY.Types.Attribute.ValidAttributeTypes; /** * Specifies a SCIM resourceType that a reference attribute may refer to */ referenceTypes?: string[]; /** * Boolean value indicating an attribute's plurality */ multiValued: boolean; /** * A human-readable description of the attribute */ description: string; /** * Boolean value indicating whether the attribute is required */ required: boolean; /** * Defines the sub-attributes of a complex attribute */ subAttributes?: SCIMMY.Types.Attribute.AttributeDefinition[]; /** * Boolean value indicating whether a string attribute is case-sensitive */ caseExact?: boolean; /** * Collection of canonical values */ canonicalValues?: string[]; /** * Indicates whether an attribute is modifiable */ mutability: string; /** * Indicates when an attribute is returned in a response */ returned: string; /** * Indicates how unique a value must be */ uniqueness?: string; }; } export class SCIMError extends Error { /** * HTTP status code to be sent with the error */ status: number; /** * The SCIM detail error keyword as per [RFC7644§3.12]{@link https://datatracker.ietf.org/doc/html/rfc7644.section-3.12} */ scimType: string; /** * A human-readable description of what caused the error to occur */ message: string; /** * Instantiate a new error with SCIM error details * @param status HTTP status code to be sent with the error * @param scimType The SCIM detail error keyword as per [RFC7644§3.12]{@link https://datatracker.ietf.org/doc/html/rfc7644.section-3.12} * @param message A human-readable description of what caused the error to occur */ constructor(status: number, scimType: string, message: string); } export class Filter extends Array { /** * The original string that was parsed by the filter, or the stringified representation of filter expression objects */ expression: string; /** * Instantiate and parse a new SCIM filter string or expression * @param expression The query string to parse, or an existing filter expression object or set of objects */ constructor(expression: string | any | any[]); /** * Compare and filter a given set of values against this filter instance * @param values Values to evaluate filters against * @returns Subset of values that match any expressions of this filter instance */ match(values: any[]): any[]; } export namespace Filter { /** * Collection of valid logical operator strings in a filter expression */ export type ValidLogicStrings = "and" | "or" | "not"; /** * Collection of valid comparison operator strings in a filter expression */ export type ValidComparisonStrings = "eq" | "ne" | "co" | "sw" | "ew" | "gt" | "lt" | "ge" | "le" | "pr" | "np"; } export class SchemaDefinition { /** * Friendly name of the SCIM schema */ name: string; /** * URN namespace of the SCIM schema */ id: string; /** * Human-readable description of the schema */ description: string; /** * Attributes that make up the schema */ attributes: SCIMMY.Types.Attribute[]; /** * Constructs an instance of a full SCIM schema definition * @param name Friendly name of the SCIM schema * @param id URN namespace of the SCIM schema * @param description A human-readable description of the schema * @param attributes Attributes that make up the schema */ constructor(name: string, id: string, description?: string, attributes?: SCIMMY.Types.Attribute[]); /** * Get the SCIM schema definition for consumption by clients * @param basepath The base path for the schema's meta.location property * @returns The schema definition for consumption by clients */ describe(basepath?: string): SCIMMY.Types.SchemaDefinition.SchemaDescription; /** * Find an attribute or extension instance belonging to the schema definition by its name * @param name The name of the attribute to look for (namespaced or direct) * @returns The Attribute or SchemaDefinition instance with matching name */ attribute<T extends SCIMMY.Types.Attribute | SCIMMY.Types.SchemaDefinition = SCIMMY.Types.Attribute>(name: string): T; /** * Extend a schema definition instance by mixing in other schemas or attributes * @param extension The schema extension or collection of attributes to register * @param required If the extension is a schema, whether the extension is required * @returns This schema definition instance for chaining */ extend(extension: SCIMMY.Types.SchemaDefinition | SCIMMY.Types.Attribute[], required?: boolean): SCIMMY.Types.SchemaDefinition; /** * Remove an attribute, extension schema, or subAttribute from a schema or attribute definition * @param target The name, or names, of attributes to remove from the schema definition * @param target The attribute instance, or instances, to remove from the schema definition * @param target The extension schema, or schemas, to remove from the schema definition * @returns This schema definition instance for chaining */ truncate(...target: Array<string | SCIMMY.Types.Attribute | SCIMMY.Types.SchemaDefinition>): SCIMMY.Types.SchemaDefinition; /** * Coerce a given value by making sure it conforms to all schema attributes' characteristics * @param data Value to coerce and confirm conformity of properties to schema attributes' characteristics * @param direction Whether to check for inbound, outbound, or bidirectional attributes * @param basepath The URI representing the resource type's location * @param filter The attribute filters to apply to the coerced value * @returns The coerced value, conforming to all schema attributes' characteristics */ coerce(data: any, direction?: string, basepath?: string, filter?: SCIMMY.Types.Filter): any; } export namespace SchemaDefinition { export type SchemaDescription = { /** * URN namespaces that identify the type of resource being described */ schemas: string[]; /** * URN namespace of the SCIM schema definition */ id: string; /** * Friendly name of the SCIM schema definition */ name: string; /** * Human-readable description of the SCIM schema definition */ description: string; /** * Attributes that make up this schema */ attributes: SCIMMY.Types.Attribute.AttributeDefinition[]; /** * Metadata details of this schema */ meta: { /** * Identifies the type of resource being described */ resourceType: string; /** * Canonical location of this resource */ location: string; }; }; } export class Schema { /** * SCIM schema URN namespace */ static readonly id: string; /** * Retrieves a schema's definition instance */ static readonly definition: SCIMMY.Types.SchemaDefinition; /** * Extend a schema by mixing in other schemas or attributes * @param extension The schema extensions or collection of attributes to register * @param required If the extension is a schema, whether the extension is required */ static extend(extension: SCIMMY.Types.Schema | SCIMMY.Types.Attribute[], required?: boolean): void; /** * Remove an attribute, schema extension, or subAttribute from the schema's definition * @param attributes The child attributes to remove from the schema definition */ static truncate(attributes: SCIMMY.Types.Schema | string | SCIMMY.Types.Attribute | string[] | SCIMMY.Types.Attribute[]): void; /** * Unique identifier for a SCIM resource as defined by the service provider */ id: string; /** * Namespace URIs of the SCIM schemas that define the attributes present in the current data structure */ schemas: string[]; /** * Identifier for the resource as defined by the provisioning client */ externalId?: string; /** * A complex attribute containing resource metadata */ meta: { /** * Name of the resource type of the resource */ resourceType: string; /** * When the resource was added to the service provider */ created?: Date; /** * When this resource was last updated at the service provider */ lastModified?: Date; /** * Full, canonical URI of the resource being returned */ location: string; /** * Version of the resource being returned, if any */ version?: string; }; /** * Construct a resource instance after verifying schema compatibility * @param data The source data to feed through the schema definition * @param direction Whether the resource is inbound from a request or outbound for a response */ constructor(data: any, direction?: string); } export namespace Schema { /** * Automatically assigned attributes not required in schema extension values */ export type ShadowAttributes = "id" | "schemas" | "meta"; /** * A schema instance type with an added schema extension */ export type Extended<S extends SCIMMY.Types.Schema, E extends typeof SCIMMY.Types.Schema, V extends S = S & { [K in keyof Pick<E, "id"> as `${E[K]}`]?: Omit<InstanceType<E>, Schema.ShadowAttributes>; }> = V; } export class Resource<S extends SCIMMY.Types.Schema = any> { /** * Retrieves a resource's endpoint relative to the service provider's base URL */ static readonly endpoint: string; /** * Sets or retrieves the base path for resolution of a resource's location * @param path The path to use as the base of a resource's location * @returns This resource type class for chaining if path is a string, or the resource's basepath */ static basepath: Resource.basepath<any>; /** * Retrieves a resource's core schema */ static readonly schema: typeof SCIMMY.Types.Schema; /** * Register an extension to the resource's core schema * @param extension The schema extension to register * @param required Whether the extension is required * @returns This resource type implementation for chaining */ static extend: Resource.extend<any, any>; /** * Sets the method to be called to consume a resource on create * @param handler Function to invoke to consume a resource on create * @returns This resource type class for chaining */ static ingress: Resource.ingress<any, any>; /** * Sets the method to be called to retrieve a resource on read * @param handler Function to invoke to retrieve a resource on read * @returns This resource type class for chaining */ static egress: Resource.egress<any, any>; /** * Sets the method to be called to dispose of a resource on delete * @param handler Function to invoke to dispose of a resource on delete * @returns This resource type class for chaining */ static degress: Resource.degress<any>; /** * Describe this resource type implementation * @returns Object describing the resource type implementation */ static describe(): SCIMMY.Types.Resource.ResourceDescription; /** * ID of the resource instance being targeted */ id?: string; /** * Filter parsed from the supplied config */ filter?: SCIMMY.Types.Filter; /** * Attributes or excluded attributes parsed from the supplied config */ attributes?: SCIMMY.Types.Filter; /** * Sort and pagination properties parsed from the supplied config */ constraints?: SCIMMY.Messages.ListResponse.ListConstraints & { /** * The attribute retrieved resources should be sorted by */ sortBy?: string; /** * The direction retrieved resources should be sorted in */ sortOrder?: string; /** * Offset index that retrieved resources should start from */ startIndex?: number; /** * Maximum number of retrieved resources that should be returned in one operation */ count?: number; }; /** * Instantiate a new SCIM resource and parse any supplied parameters * @param id The ID of the requested resource * @param config The parameters of the resource instance request * @param config.filter The filter to be applied on ingress/egress by implementing resource * @param config.excludedAttributes The comma-separated string list of attributes or filters to exclude on egress * @param config.attributes The comma-separated string list of attributes or filters to include on egress * @param config.sortBy The attribute retrieved resources should be sorted by * @param config.sortOrder The direction retrieved resources should be sorted in * @param config.startIndex Offset index that retrieved resources should start from * @param config.count Maximum number of retrieved resources that should be returned in one operation */ constructor(id?: string, config?: { filter?: string; excludedAttributes?: string; attributes?: string; sortBy?: string; sortOrder?: string; startIndex?: number; count?: number; }); /** * Calls resource's egress method for data retrieval. * Wraps the results in valid SCIM list response or single resource syntax. * @param ctx Any additional context information to pass to the egress handler * @returns The specifically requested resource instance, if an ID was supplied to resource constructor, or collection of resources matching instance's configured filter. */ read<T = any>(ctx?: T): Promise<SCIMMY.Messages.ListResponse | S>; /** * Calls resource's ingress method for consumption after unwrapping the SCIM resource * @param instance The raw resource type instance for consumption by ingress method * @param ctx Any additional context information to pass to the ingress handler * @returns The consumed resource type instance */ write<T = any>(instance: any, ctx?: T): Promise<S>; /** * Retrieves resources via egress method, and applies specified patch operations. * Emits patched resources for consumption with resource's ingress method. * @param message The PatchOp message to apply to the received resource * @param message.schemas List exclusively containing SCIM PatchOp message schema ID * @param message.Operations PatchOp operations to be applied * @param ctx Any additional context information to pass to the ingress/egress handlers * @returns The resource type instance after patching and consumption by ingress method */ patch<T = any>(message: { schemas: (typeof SCIMMY.Messages.PatchOp.id)[]; Operations: SCIMMY.Messages.PatchOp.PatchOpOperation[]; }, ctx?: T): Promise<S>; /** * Calls resource's degress method for disposal of the SCIM resource * @param ctx Any additional context information to pass to the degress handler */ dispose<T = any>(ctx?: T): Promise<void>; } export namespace Resource { /** * Automatically assigned attributes not required in handler return values */ export type ShadowAttributes = "schemas" | "meta"; /** * Sets or retrieves the base path for resolution of a resource's location * @param path The path to use as the base of a resource's location * @returns This resource type class for chaining if path is a string, or the resource's basepath */ type basepath<R extends typeof SCIMMY.Types.Resource<any>> = (path?: string) => string | R; /** * Register an extension to the resource's core schema * @param extension The schema extension to register * @param required Whether the extension is required * @returns This resource type implementation for chaining */ type extend<R extends typeof SCIMMY.Types.Resource<S>, S extends SCIMMY.Types.Schema = any> = (extension: typeof SCIMMY.Types.Schema, required?: boolean) => R; /** * Handler for ingress of a resource * @param resource The resource performing the ingress * @param instance An instance of the resource type that conforms to the resource's schema * @param ctx External context in which the handler has been called * @returns An object to be used to create a new schema instance, whose properties conform to the resource type's schema */ export type IngressHandler<R extends SCIMMY.Types.Resource<S>, S extends SCIMMY.Types.Schema, V extends Record<string, any> = Omit<Awaited<S>, Resource.ShadowAttributes>> = (resource: R, instance: S, ctx?: any) => V | Promise<V>; /** * Sets the method to be called to consume a resource on create * @param handler Function to invoke to consume a resource on create * @returns This resource type class for chaining */ type ingress<R extends typeof SCIMMY.Types.Resource<any>, S extends SCIMMY.Types.Schema> = <V extends S = S>(handler: SCIMMY.Types.Resource.IngressHandler<InstanceType<R>, V>) => R; /** * Handler for egress of a resource * @param resource The resource performing the egress * @param ctx External context in which the handler has been called * @returns An object, or array of objects, to be used to create a new schema instances, whose properties conform to the resource type's schema */ export type EgressHandler<R extends SCIMMY.Types.Resource<S>, S extends SCIMMY.Types.Schema, V extends Record<string, any> = Omit<Awaited<S>, Resource.ShadowAttributes>> = (resource: R, ctx?: any) => V | V[] | Promise<V | V[]>; /** * Sets the method to be called to retrieve a resource on read * @param handler Function to invoke to retrieve a resource on read * @returns This resource type class for chaining */ type egress<R extends typeof SCIMMY.Types.Resource<any>, S extends SCIMMY.Types.Schema> = <V extends S = S>(handler: SCIMMY.Types.Resource.EgressHandler<InstanceType<R>, V>) => R; /** * Handler for degress of a resource * @param resource The resource performing the degress * @param ctx External context in which the handler has been called */ export type DegressHandler<R extends SCIMMY.Types.Resource<any>> = (resource: R, ctx?: any) => void | Promise<void>; /** * Sets the method to be called to dispose of a resource on delete * @param handler Function to invoke to dispose of a resource on delete * @returns This resource type class for chaining */ type degress<R extends typeof SCIMMY.Types.Resource<any>> = (handler: SCIMMY.Types.Resource.DegressHandler<InstanceType<R>>) => R; /** * An object describing a resource type's implementation */ export type ResourceDescription = { /** * URN namespace of the resource's SCIM schema definition */ id: string; /** * Friendly name of the resource's SCIM schema definition */ name: string; /** * Resource type's endpoint, relative to a service provider's base URL */ endpoint: string; /** * Human-readable description of the resource */ description: string; /** * Schema extensions that augment the resource */ schemaExtensions?: Array<{ /** * URN namespace of the schema extension that augments the resource */ schema: string; /** * Whether resource instances must include the schema extension */ required: boolean; }>; }; } } export class Messages { static Error: typeof SCIMMY.Messages.ErrorResponse; } export namespace Messages { export class ErrorResponse extends Error { /** * SCIM Error Message Schema ID */ static readonly id: "urn:ietf:params:scim:api:messages:2.0:Error"; /** * List exclusively containing the SCIM Error message schema ID */ schemas: [typeof SCIMMY.Messages.ErrorResponse.id]; /** * Stringified HTTP status code to be sent with the error */ status: SCIMMY.Messages.ErrorResponse.ValidStatusCodes; /** * The SCIM detail error keyword as per [RFC7644§3.12]{@link https://datatracker.ietf.org/doc/html/rfc7644.section-3.12} */ scimType?: SCIMMY.Messages.ErrorResponse.ValidScimTypes; /** * A human-readable description of what caused the error to occur */ detail?: string; /** * Instantiate a new SCIM Error Message with relevant details * @param ex The initiating exception to parse into a SCIM error message */ constructor(ex?: typeof SCIMMY.Types.Error | SCIMMY.Messages.ErrorResponse.CauseDetails | Error); } export namespace ErrorResponse { /** * HTTP response status codes specified by RFC7644§3.12 */ export type ValidStatusCodes = 307 | 308 | 400 | 401 | 403 | 404 | 409 | 412 | 413 | 500 | 501; /** * SCIM detail error keywords specified by RFC7644§3.12 */ export type ValidScimTypes = "uniqueness" | "tooMany" | "invalidFilter" | "mutability" | "invalidSyntax" | "invalidPath" | "noTarget" | "invalidValue" | "invalidVers" | "sensitive"; /** * Details of the underlying cause of the error response */ export type CauseDetails = { /** * HTTP status code to be sent with the error */ status?: SCIMMY.Messages.ErrorResponse.ValidStatusCodes; /** * The SCIM detail error keyword as per [RFC7644§3.12]{@link https://datatracker.ietf.org/doc/html/rfc7644.section-3.12} */ scimType?: SCIMMY.Messages.ErrorResponse.ValidScimTypes; /** * A human-readable description of what caused the error to occur */ detail?: string; }; } export class ListResponse<T extends SCIMMY.Types.Schema = any> { /** * SCIM List Response Message Schema ID */ static readonly id: "urn:ietf:params:scim:api:messages:2.0:ListResponse"; /** * List exclusively containing the SCIM ListResponse message schema ID */ schemas: [typeof SCIMMY.Messages.ListResponse.id]; /** * Resources included in the list response */ Resources: T[]; /** * The total number of resources matching a given request */ totalResults: number; /** * Index within total results that included resources start from */ startIndex: number; /** * Maximum number of items returned in this list response */ itemsPerPage: number; /** * Instantiate a new SCIM List Response Message with relevant details * @param request Contents of the ListResponse message, or items to include in the list response * @param params Parameters for the list response (i.e. sort details, start index, and items per page) * @param params.sortBy The attribute to sort results by, if any * @param params.sortOrder The direction to sort results in, if sortBy is specified * @param params.startIndex Offset index that items start from * @param params.count Alias property for itemsPerPage, used only if itemsPerPage is unset * @param params.itemsPerPage Maximum number of items returned in this list response * @param params.totalResults The total number of resources matching a given request */ constructor(request: SCIMMY.Messages.ListResponse<T> | T[], params?: SCIMMY.Messages.ListResponse.ListConstraints & { sortBy?: string; sortOrder?: string; startIndex?: number; count?: number; itemsPerPage?: number; totalResults?: number; }); } export namespace ListResponse { /** * ListResponse sort and pagination constraints */ export type ListConstraints = { /** * The attribute to sort results by, if any */ sortBy?: string; /** * The direction to sort results in, if sortBy is specified */ sortOrder?: string; /** * Offset index that items start from */ startIndex?: number; /** * Maximum number of items returned in this list response */ count?: number; }; } export class PatchOp { /** * SCIM Patch Operation Message Schema ID */ static readonly id: "urn:ietf:params:scim:api:messages:2.0:PatchOp"; /** * List exclusively containing the SCIM PatchOp message schema ID */ schemas: [typeof SCIMMY.Messages.PatchOp.id]; /** * List of SCIM-compliant patch operations to apply to the given resource */ Operations: SCIMMY.Messages.PatchOp.PatchOpOperation[]; /** * Instantiate a new SCIM Patch Operation Message with relevant details * @param request Contents of the patch operation request being performed * @param request.schemas List exclusively containing SCIM PatchOp message schema ID * @param request.Operations List of SCIM-compliant patch operations to apply to the given resource */ constructor(request?: { schemas: [typeof SCIMMY.Messages.PatchOp.id]; Operations: SCIMMY.Messages.PatchOp.PatchOpOperation[]; }); /** * Apply patch operations to a resource as defined by the PatchOp instance * @param resource The schema instance the patch operation will be performed on * @param finalise Method to call when all operations are complete, to feed target back through model * @returns An instance of the resource modified as per the included patch operations */ apply<S extends SCIMMY.Types.Schema = any>(resource: S, finalise?: SCIMMY.Messages.PatchOp.PatchOpFinaliser<S>): Promise<S>; } export namespace PatchOp { /** * List of valid SCIM patch operations */ export type ValidPatchOperations = "add" | "remove" | "replace"; /** * SCIM PatchOp Operation definition */ export type PatchOpOperation = { /** * The operation to perform */ op: SCIMMY.Messages.PatchOp.ValidPatchOperations; /** * An attribute path describing the target of the operation */ path?: string; /** * Value to add or update */ value?: any; }; /** * Apply final transformations or database operations before determining whether a PatchOp resulted in any actual changes * @param instance A patched version of the originally supplied resource schema instance * @returns The resource instance after final transformations have been applied */ export type PatchOpFinaliser<S extends SCIMMY.Types.Schema = any> = (instance: S) => Promise<Record<string, any>>; } export class BulkResponse { /** * SCIM BulkResponse Message Schema ID */ static readonly id: "urn:ietf:params:scim:api:messages:2.0:BulkResponse"; /** * List exclusively containing the SCIM BulkResponse message schema ID */ schemas: [typeof SCIMMY.Messages.BulkResponse.id]; /** * List of BulkResponse operation results */ Operations: SCIMMY.Messages.BulkResponse.BulkOpResponse[]; /** * Instantiate a new outbound SCIM BulkResponse message from the results of performed operations * @param operations Results of performed operations */ constructor(operations: SCIMMY.Messages.BulkResponse.BulkOpResponse[]); /** * Instantiate a new inbound SCIM BulkResponse message instance from the received response * @param request Contents of the received BulkResponse message * @param request.Operations List of SCIM-compliant bulk operation results */ constructor(request: { Operations: SCIMMY.Messages.BulkResponse.BulkOpResponse[]; }); /** * Instantiate a new SCIM BulkResponse message from the supplied Operations * @param request Results of performed operations if array * @param request Contents of the received BulkResponse message if object * @param request.Operations List of SCIM-compliant bulk operation results */ constructor(request: SCIMMY.Messages.BulkResponse.BulkOpResponse[] | { Operations: SCIMMY.Messages.BulkResponse.BulkOpResponse[]; }); /** * Resolve bulkIds of POST operations into new resource IDs * @returns Map of bulkIds to resource IDs if operation was successful, or false if not */ resolve(): Map<string, string | boolean>; } export namespace BulkResponse { /** * BulkResponse operation response status codes */ export type ResponseStatusCodes = 200 | 201 | 204 | 307 | 308 | 400 | 401 | 403 | 404 | 409 | 412 | 500 | 501; /** * BulkResponse operation details for a given BulkRequest operation */ export type BulkOpResponse = { /** * Canonical URI for the target resource of the operation */ location?: string; /** * The HTTP method used for the requested operation */ method: SCIMMY.Messages.BulkRequest.ValidBulkMethods; /** * The transient identifier of a newly created resource, unique within a bulk request and created by the client */ bulkId?: string; /** * Resource version after operation has been applied */ version?: string; /** * The HTTP response status code for the requested operation */ status: SCIMMY.Messages.BulkResponse.ResponseStatusCodes; /** * The HTTP response body for the specified request operation */ response?: any; }; } export class BulkRequest { /** * SCIM BulkRequest Message Schema ID */ static readonly id: "urn:ietf:params:scim:api:messages:2.0:BulkRequest"; /** * List exclusively containing the SCIM BulkRequest message schema ID */ schemas: [typeof SCIMMY.Messages.BulkRequest.id]; /** * List of operations in this BulkRequest instance */ Operations: SCIMMY.Messages.BulkRequest.BulkOpOperation[]; /** * Number of error results a service provider should tolerate before aborting any following operations */ failOnErrors?: number; /** * Instantiate a new SCIM BulkRequest message from the supplied operations * @param request Contents of the BulkRequest operation being performed * @param request.schemas List exclusively containing the SCIM BulkRequest message schema ID * @param request.Operations List of SCIM-compliant bulk operations to apply * @param request.failOnErrors Number of error results to encounter before aborting any following operations * @param maxOperations Maximum number of operations supported in the request, as specified by the service provider */ constructor(request: { schemas: [typeof SCIMMY.Messages.BulkRequest.id]; Operations: SCIMMY.Messages.BulkRequest.BulkOpOperation[]; failOnErrors?: number; }, maxOperations?: number); /** * Apply the operations specified by the supplied BulkRequest and return a new BulkResponse message * @param resourceTypes Resource type classes to be used while processing bulk operations, defaults to declared resources * @param ctx Any additional context information to pass to the ingress, egress, and degress handlers * @returns A new BulkResponse Message instance with results of the requested operations */ apply(resourceTypes?: (typeof SCIMMY.Types.Resource)[], ctx?: any): Promise<SCIMMY.Messages.BulkResponse>; } export namespace BulkRequest {