Index

Constructors

constructor

  • Creates a Cordra Client, optionally setting default options.

    example
    
    // No default options
    const httpsClient = new CordraClient("https://localhost:8443");
    
    // Setting default options
    const options = {
      isDryRun: true
    };
    const httpClient = new CordraClient("http://localhost:8080/", options);
    

    Parameters

    • baseUri: string

      The URI of the Cordra instance, including protocol

    • Optional options: Options

      Set of default options to use with this client instance

    • Optional config: ClientConfig

    Returns CordraClient

Properties

baseUri

baseUri: string

The URI of the Cordra instance, including protocol

config

config: ClientConfig

Client-wide configuration

defaultOptions

defaultOptions: Options

Set of default options to use with this client instance

Methods

authenticate

  • Authenticates using the given options.

    example
    
    const authOptions = {
      username: 'admin',
      password: 'password'
    };
    const client = new CordraClient("https://localhost:8443");
    client.authenticate(authOptions);
    

    Parameters

    • options: Options = ...

      Options to use for this request

    Returns Promise<AuthResponse>

    The authentication response

buildAuthHeaders

  • buildAuthHeaders(options?: Options): Promise<Headers>
  • Builds a Headers object containing the authentication headers corresponding to the given options.

    Parameters

    • options: Options = ...

      Options to use for this request

    Returns Promise<Headers>

buildAuthHeadersReturnDetails

  • buildAuthHeadersReturnDetails(options?: Options, acquireNewToken?: boolean): Promise<object>
  • Parameters

    • options: Options = ...
    • acquireNewToken: boolean = true

    Returns Promise<object>

callMethod

  • callMethod(objectId: string, method: string, params: unknown, options?: Options): Promise<any>
  • Calls a method on an object instance, expecting a JSON response.

    Parameters

    • objectId: string

      The id of the object on which to call an instance method. Either objectId or type is required.

    • method: string

      The name of the method to call.

    • params: unknown

      The parameters to pass to the method as either a Body type or JSON-representable data.

    • options: Options = ...

      Options to use for this request

    Returns Promise<any>

callMethodAsResponse

  • callMethodAsResponse(objectId: string, method: string, params: unknown, options?: Options): Promise<Response>
  • Calls a method on an object instance, returning a Response (from which binary data can be retrieved).

    Parameters

    • objectId: string

      The id of the object on which to call an instance method. Either objectId or type is required.

    • method: string

      The name of the method to call.

    • params: unknown

      The parameters to pass to the method as either a Body type or JSON-representable data.

    • options: Options = ...

      Options to use for this request

    Returns Promise<Response>

callMethodForType

  • callMethodForType(type: string, method: string, params: unknown, options?: Options): Promise<any>
  • Calls a method for a given type, expecting a JSON response.

    Parameters

    • type: string

      The id of the object on which to call an instance method. Either objectId or type is required.

    • method: string

      The name of the method to call.

    • params: unknown

      The parameters to pass to the method as either a Body type or JSON-representable data.

    • options: Options = ...

      Options to use for this request

    Returns Promise<any>

callMethodForTypeAsResponse

  • callMethodForTypeAsResponse(type: string, method: string, params: unknown, options?: Options): Promise<Response>
  • Calls a method for a given type, returning a Response (from which binary data can be retrieved).

    Parameters

    • type: string

      The id of the object on which to call an instance method. Either objectId or type is required.

    • method: string

      The name of the method to call.

    • params: unknown

      The parameters to pass to the method as either a Body type or JSON-representable data.

    • options: Options = ...

      Options to use for this request

    Returns Promise<Response>

changeAdminPassword

  • changeAdminPassword(newPassword: string, options: Options): Promise<Response>
  • Requests a password change for the admin user.

    Parameters

    • newPassword: string

      The new password

    • options: Options

      Options to use for this request

    Returns Promise<Response>

changePassword

  • changePassword(newPassword: string, options: Options): Promise<Response>
  • Requests a password change for the currently authenticated user.

    Parameters

    • newPassword: string

      The new password

    • options: Options

      Options to use for this request

    Returns Promise<Response>

create

  • Creates a new object.

    example
    
    const cordraObject = {
        type: "Document",
        content: { id: '', name: 'test doc' }
    }
    client.create(cordraObject);
    

    Parameters

    • cordraObject: CordraObject

      An object containing the type and content of the new object.

    • Optional progressCallback: ProgressCallback

      Callback for progress notification

    • options: Options = ...

      Options to use for this request

    Returns Promise<CordraObject>

delete

  • delete(id: string, options?: Options): Promise<Response>
  • Deletes an object.

    Parameters

    • id: string

      ID of the object to delete

    • options: Options = ...

      Options to use for this request

    Returns Promise<Response>

deletePayload

  • Removes a payload from an object.

    Parameters

    • object: CordraObject

      The object to be updated

    • payloadName: string

      Name of the desired payload

    • options: Options = ...

      Options to use for this request

    Returns Promise<CordraObject>

genericGet

  • genericGet<T>(id: string, options: Options, processRequest: function): Promise<T>
  • Type parameters

    • T

    Parameters

    • id: string
    • options: Options
    • processRequest: function
        • (request: Request): Promise<T>
        • Parameters

          • request: Request

          Returns Promise<T>

    Returns Promise<T>

get

  • Retrieves an object from Cordra by ID, throwing if not found.

    Parameters

    • id: string

      The ID of the object to retrieve

    • options: Options = ...

      Options to use for this request

    Returns Promise<CordraObject>

    the object; throws if not found

getAclForObject

  • Gets the access control list for an object.

    Parameters

    • id: string

      ID of the object

    • options: Options = ...

      Options to use for this request

    Returns Promise<AccessControlList>

getAuthenticationStatus

  • Gets the authentication status for the supplied options. By default, returns active flag, userId, and username.

    Parameters

    • full: boolean = false

      Whether to get full auth info, including types user can create and groups user is a member of

    • options: Options = ...

      Options to use for this request

    Returns Promise<AuthResponse>

getHandleUpdateStatus

  • getHandleUpdateStatus(options?: Options): Promise<object>
  • Gets status of handle update process.

    Parameters

    • options: Options = ...

      Options to use for this request

    Returns Promise<object>

getObjectProperty

  • getObjectProperty(id: string, jsonPointer: string, options?: Options): Promise<any>
  • Retrieves the value of a property from the content of an object.

    Parameters

    • id: string

      ID of the object

    • jsonPointer: string

      JSON Pointer of the property to retrieve, in the content of the object

    • options: Options = ...

      Options to use for this request

    Returns Promise<any>

getObjectPropertyFromFullCordraObject

  • getObjectPropertyFromFullCordraObject(id: string, jsonPointer: string, options?: Options): Promise<any>
  • Retrieves the value of a property from a full Cordra object (not restricted to content).

    Parameters

    • id: string

      ID of the object

    • jsonPointer: string

      JSON Pointer of the property to retrieve, in the full Cordra object

    • options: Options = ...

      Options to use for this request

    Returns Promise<any>

getOrNull

  • Retrieves an object from Cordra by ID, returning null if not found.

    Parameters

    • id: string

      The ID of the object to retrieve

    • options: Options = ...

      Options to use for this request

    Returns Promise<null | CordraObject>

    the object; null if not found

getPartialPayload

  • getPartialPayload(id: string, payloadName: string, start: number, end: number, options?: Options): Promise<Blob>
  • Gets part of the payload of an object. This can be useful streaming payloads.

    Parameters

    • id: string

      ID of the object

    • payloadName: string

      Name of the desired payload

    • start: number

      Beginning of payload range

    • end: number

      End of payload range

    • options: Options = ...

      Options to use for this request

    Returns Promise<Blob>

getPayload

  • getPayload(id: string, payloadName: string, options?: Options): Promise<Blob>
  • Gets a payload for an object.

    Parameters

    • id: string

      ID of the object

    • payloadName: string

      Name of the desired payload

    • options: Options = ...

      Options to use for this request

    Returns Promise<Blob>

getPayloadDownloadLink

  • getPayloadDownloadLink(id: string, payloadName: string, options?: Options): string
  • Generates a URI that can be used to download the payload of an object.

    Parameters

    • id: string

      ID of the object

    • payloadName: string

      Name of the desired payload

    • options: Options = ...

      Options to use for this request

    Returns string

getVersionsFor

  • getVersionsFor(id: string, options?: Options): Promise<VersionInfo[]>
  • Retrieves all version snapshots for an object.

    Parameters

    • id: string

      ID of the object

    • options: Options = ...

      Options to use for this request

    Returns Promise<VersionInfo[]>

list

  • Retrieves a list of all objects in Cordra.

    Parameters

    • options: Options = ...

      Options to use for this request

    Returns Promise<SearchResults<CordraObject>>

listHandles

  • Retrieves a list of the handles for all objects in Cordra.

    Parameters

    • options: Options = ...

      Options to use for this request

    Returns Promise<SearchResults<string>>

listMethods

  • listMethods(id: string, options?: Options): Promise<string[]>
  • Lists the methods available for a given object.

    Parameters

    • id: string

      The id of the object you want to list methods of. Either objectId or type is required.

    • options: Options = ...

      Options to use for this request

    Returns Promise<string[]>

listMethodsForType

  • listMethodsForType(type: string, listStatic?: boolean, options?: Options): Promise<string[]>
  • Lists the methods available for a given type.

    Parameters

    • type: string

      A Cordra type; depending on the static parameter, this will list static methods on that type, or instance methods on objects of the type.

    • listStatic: boolean = false

      If true, listing methods for a type will list static methods instead of instance methods.

    • options: Options = ...

      Options to use for this request

    Returns Promise<string[]>

publishVersion

  • Creates a new version snapshot of an object.

    Parameters

    • id: string

      ID of the object

    • options: Options = ...

      Options to use for this request

    Returns Promise<VersionInfo>

retryAfterTokenFailure

  • retryAfterTokenFailure<T>(options: Options, fetcher: function): Promise<T>
  • Type parameters

    • T

    Parameters

    • options: Options
    • fetcher: function
        • (headers: Headers): Promise<T>
        • Parameters

          • headers: Headers

          Returns Promise<T>

    Returns Promise<T>

search

  • Searches Cordra for objects matching a given query. The query format is that used by the indexing backend, which is generally the inter-compatible Lucene/Solr/Elasticsearch format for fielded search.

    example
    
    // Search for all objects in Cordra
    client.search("*:*");
    
    // Search for all schemas.
    // Sort results in descending order by name and return 2 results
    const params = {
      pageSize: 2,
      sortFields: [{name: "/name", reverse: true}]
    };
    client.search("type:Schema", params);
    
    // Search for everything that is not a schema.
    // Sort results by type and then id
    const params = {
      sortFields: [{name: "type"}, {name: "id"}]
    };
    client.search("*:* -type:Schema", params);
    
    // Search for everything and returns facets
    // for each type
    const params = {
      facets: [{field: "type"}]
    };
    client.search("*:*", params);
    
    // Search for everything, filter using filter query
    const params = {
      filterQueries: ["+type:Schema"]
    };
    client.search("*:*", params);
    

    Parameters

    • query: string

      The query string to search

    • Optional params: QueryParams

      Parameters for this query

    • options: Options = ...

      Options to use for this request

    Returns Promise<SearchResults<CordraObject>>

searchHandles

  • Searches Cordra for objects matching a given query. Returns the object IDs instead of full objects. The query format is that used by the indexing backend, which is generally the inter-compatible Lucene/Solr/Elasticsearch format for fielded search.

    Parameters

    • query: string

      The query string to search

    • Optional params: QueryParams

      Parameters for this query

    • options: Options = ...

      Options to use for this request

    Returns Promise<SearchResults<string>>

signOut

  • Deletes any stored authentication token locally, and revokes the token at the server.

    Parameters

    • options: Options = ...

      Options to use for this request

    Returns Promise<AuthResponse>

update

  • Updates an object.

    example
    
    const cordraObject = {
        id: "test/12345",
        content: { id: "test/12345", name: 'a different name' }
    }
    client.update(cordraObject);
    

    Parameters

    • cordraObject: CordraObject

      An object containing the id of the object and the new content.

    • Optional progressCallback: ProgressCallback

      Callback for progress notification

    • options: Options = ...

      Options to use for this request

    Returns Promise<CordraObject>

updateAclForObject

  • Updates the access control list for an object.

    Parameters

    • id: string

      ID of the object

    • newAcl: object

      New ACL to set on object

    • options: Options = ...

      Options to use for this request

    Returns Promise<AccessControlList>

updateAllHandles

  • updateAllHandles(options?: Options): Promise<Response>
  • Starts a background process to update all handles in the system. Used to propagate prefix changes.

    Parameters

    • options: Options = ...

      Options to use for this request

    Returns Promise<Response>

updateObjectProperty

  • updateObjectProperty(id: string, jsonPointer: string, value: unknown, options?: Options): Promise<CordraObject>
  • Updates only the given property in the content of an object.

    Parameters

    • id: string

      ID of the object

    • jsonPointer: string

      JSON Pointer of the property to retrieve, in the content of the object

    • value: unknown

      Data to insert into content at that JSON Pointer

    • options: Options = ...

      Options to use for this request

    Returns Promise<CordraObject>

uploadObjects

  • uploadObjects(objects: CordraObject[], deleteCurrent?: boolean, options?: Options): Promise<object>
  • Batch uploads objects, optionally deleting existing objects.

    Parameters

    • objects: CordraObject[]

      Array of objects to upload

    • deleteCurrent: boolean = false

      Whether to delete current objects before uploading

    • options: Options = ...

      Options to use for this request

    Returns Promise<object>

Static checkForErrors

  • checkForErrors(response: Response | ErrorResponse): Promise<Response>
  • Parameters

    Returns Promise<Response>

Generated using TypeDoc