Skip to content

Latest commit

 

History

History
223 lines (172 loc) · 6.07 KB

PropsAPI.md

File metadata and controls

223 lines (172 loc) · 6.07 KB

Props API Specification

Use Props to store user preferences, configuration, data relations, module settings, etc.

Total number of Props per module per dataset is limited and must be used wisely.

🔖 Docs Index

Constructor

ModulePropsAPI(module_id: string, dataset_id: string): object

Methods

🟣 Get Props

Please refer to this link for supported filtersAndOptions properties.

getProps(filtersAndOptions: object): Promise<Array>

Response:

[
    {
        _id: string,            // document id
        _created_on: number,    // UTC milliseconds
        "<prop_name>": "key",   // You prop data
        ...
    },
    ...
]




🟣 Insert Props

insertProps({ 'props': Array<object> }): Promise<object>

Response:

  • If response is OK

    {
        insert_status: number,              // (0, 1, 2, 3) See below for its meaning
        props_count: number,                // Number of props given to insert
        inserted_count: number,             // Number of props successfully inserted
        inserted_props: Array<object>       // Copy of inserted props
    }
  • For other responses read General Errors.

Values for insert_status
insert_status Meaning
0 Invalid Request Type, HTTP Status 400 (Bad Request)
1 Successfully inserted the props
2 No props to insert. Operation not performed
3 No props inserted, number of props exceeds allowed limit of props per dataset




🟣 Update Prop

updateProp({ 'prop_id': string, 'prop_updates': object }): Promise<object>

Response:

  • If response is OK

    {
        update_status: number,      // (1, 2, 3) See below for its meaning
        updated_prop: object        // Copy of entire prop after updating
    }
  • If update_status ≠ 1

    {
        update_status: number,      // (1, 2, 3) See below for its meaning
        error_message: string       // Small error description
    }
  • For other responses read General Errors.

Values for update_status
update_status Meaning
1 Successfully updated the prop.
2 Incomplete request, missing required fields. Operation not performed.
3 Could not find prop by specified prop_id




🟣 Delete Props

deleteProp(prop_ids_to_delete: Array<string>): Promise<object>

Response:

  • If response is OK

    {
        delete_status: number,      // (0, 1, 2) See below for its meaning
        deleted_count: number,      // Number of deleted props
        deleted_ids: Array<string>  // IDs of deleted props
    }
  • If delete_status ≠ 1

    {
        delete_status: number,      // (0, 1, 2) See below for its meaning
        error_message: string,      // Small error description
    }
  • For other responses read General Errors.

Values for delete_status
delete_status Meaning
0 Invalid Request Type or Invalid prop ID(s)
1 Successfully deleted the props.
2 No prop IDs provided to delete. Operation not performed.




🟡 Get all space users

getWorkspaceUsers(forceFetch: boolean = false): Promise<Array>

The list of users in the space is locally cached for some time. To bypass cache and get fresh list of users set forceFetch to true. It is recommended to not forceFetch unless required as it unnecessarily burdens the server.

Response:

[
    {
        _id: string,    // user id
        email: string,  // user address
        fname: string,  // first name
        lname: string,  // last name
        img: string     // user profile picture full URL
    },
    ...
]




🟡 Get current user

getUser(): Promise<object>

Response:

{
    _id: string,    // user id
    email: string,  // user address
    fname: string,  // first name
    lname: string,  // last name
    img: string     // user profile picture full URL
}




🟡 Get Manifest File

getStaticConfig(): object

Response:

All the content of manifest.json file parsed to object type.




⛔️ General Errors

In all the case when HTTP response is OK (200) but the request was not fulfilled, a response of following type must be expected and handled:

{
    <action>_status: number // (insert, update, delete) action status code
    message: string         // short error description
}

Fluidspace environment automatically handles the following errors:

  • HTTP 401 (Invalid user session)
  • HTTP 500 (internal server error)
  • Network error
  • JSON parsing error

A more graceful Error will be thrown to the API caller so, make sure to .catch() in all the API requests and handle them appropriately at the module level.

The message PARSING_ERROR or NETWORK_ERROR can be expected in error.message property in catch():