Class Resource

Describes an Atomic Resource, which has a Subject URL and a bunch of Property / Value combinations.

Hierarchy

  • Resource

Constructors

  • Parameters

    • subject: string
    • Optional newResource: boolean

    Returns Resource

Properties

appliedCommitSignatures: Set<string>

Every commit that has been applied should be stored here, which prevents applying the same commit twice

commitBuilder: any
commitError?: Error

If the commit could not be saved, we put that info here.

error?: Error

If the resource could not be fetched, we put that info here.

loading: boolean

Is true when the Resource is currently being fetched, awaiting a response from the Server

new: boolean

Is true for locally created, unsaved resources

propvals: any
subject: any

Accessors

Methods

  • Checks if the agent has write rights by traversing the graph. Recursive function.

    Parameters

    • store: Store
    • Optional agent: string
    • Optional child: string

    Returns Promise<[boolean, undefined | string]>

  • Creates a clone of the Resource, which makes sure the reference is different from the previous one. This can be useful when doing reference compares.

    Returns Resource

  • Removes the resource form both the server and locally

    Parameters

    Returns Promise<void>

  • Get a Value by its property

    Parameters

    • propUrl: string

    Returns JSONValue

  • Get a Value by its property, returns as Array or throws error. Returns empty array if there is no value

    Parameters

    • propUrl: string

    Returns JSONArray

  • Returns the subject of the list of Children

    Returns string

  • Get a Value by its property

    Returns string[]

  • Returns the current Commit Builder, which describes the pending changes of the resource

    Returns CommitBuilder

  • Returns the internal Map of Property-Values

    Returns PropVals

  • Iterates over the parents of the resource, returns who has read / write rights for this resource

    Parameters

    Returns Promise<Right[]>

  • Returns the subject URL of the Resource

    Returns string

  • Returns the subject URL of the Resource

    Returns string

  • Get a Value by its property, returns as Array with subjects instead of the full resource or throws error. Returns empty array if there is no value

    Parameters

    • propUrl: string

    Returns string[]

  • Checks if the resource is all of the given classes

    Parameters

    • Rest ...classSubjects: string[]

    Returns boolean

  • Checks if the resource is both loaded and free from errors

    Returns boolean

  • Returns true is the resource had an Unauthorized 401 response.

    Returns boolean

  • Appends a Resource to a ResourceArray

    Parameters

    Returns void

  • Removes a property value combination from the resource and adds it to the next Commit

    Parameters

    • propertyUrl: string

    Returns void

  • Removes a property value combination from this resource, does not store the remove action in Commit

    Parameters

    • propertyUrl: string

    Returns void

  • Commits the changes and sends the Commit to the resource's /commit endpoint. Returns the Url of the created Commit. If you don't pass an Agent explicitly, the default Agent of the Store is used.

    Parameters

    Returns Promise<string>

  • Set a Property, Value combination and perform a validation. Will throw if property is not valid for the datatype. Will fetch the datatype if it's not available. Adds the property to the commitbuilder.

    Parameters

    • prop: string
    • value: JSONValue
    • store: Store
    • Optional validate: boolean

      Disable validation if you don't need it. It might cause a fetch if the Property is not present when set is called

    Returns Promise<void>

  • Sets the error on the Resource. Does not Throw.

    Parameters

    • e: Error

    Returns void

  • Set the Subject / ID URL of the Resource. Does not update the Store.

    Parameters

    • subject: string

    Returns void

  • Set a Property, Value combination without performing validations or adding it to the CommitBuilder.

    Parameters

    Returns void

Generated using TypeDoc