Options
All
  • Public
  • Public/Protected
  • All
Menu

Namespace handle

The namespace handle contains some low level API to communicate with the server side API. It is the only API layer that communicate directly with the server. To make AntOS compatible with any server side API, all exported variable unctions defined in the handle namespace should be re-implemented

Index

Variables

get

get: string = `${REST}/VFS/get`

Base URI for reading content of VFS file

shared

shared: string = `${REST}/VFS/shared`

Base URI for VFS file sharing

Functions

apigateway

  • An apigateway allows client side to execute a custom server-side script and get back the result. This gateway is particularly useful in case of performing a task that is not provided by the core API

    export

    Parameters

    • d: GenericObject<any>

      execution indication, provided only when ws is false otherwise, d should be written directly to the websocket stream as JSON object. Two possible formats of d:

      execute an server-side script file:
      
      {
       path: [VFS path],
       parameters: [parameters of the server-side script]
      }
      
      or, execute directly a snippet of server-side script:
      
      { code: [server-side script code snippet as string] }
      
    • ws: boolean

      flag indicate whether to use websocket for the connection to the gateway API. In case of streaming data, the websocket is preferred

    Returns Promise<any>

    a promise on the result object (any)

auth

dbquery

  • This is the low level function of AntOS VDB API. It requests the server API to perform some simple SQL query.

    export

    Parameters

    • cmd: string

      action to perform: save, delete, get, select

    • d: GenericObject<any>

      data object of the request based on each action:

      • save:
        { table: "table name", data: [record data object]}
        
      • get:
        { table: "table name", id: [record id]}
        
      • delete:
        { table: "table name", id: [record id]}
        or
        { table: "table name", cond: [conditional object]}
        
      • select:
        { table: "table name", cond: [conditional object]}
        

    Returns Promise<RequestResult>

    a promise of RequestResult on the query data

    A conditional object represents a SQL condition statement as an object, example: pid = 10 AND cid = 2 ORDER BY date DESC

     {
         exp: {
             "and": {
                 pid: 10,
                 cid: 2
             }
         },
         order: {
             date: "DESC"
         }
     }
    

fileblob

  • fileblob(p: string): Promise<ArrayBuffer>
  • Read the file as binary data

    export

    Parameters

    • p: string

      VFS file to be read

    Returns Promise<ArrayBuffer>

    a Promise on an array buffer

fileinfo

login

logout

mkdir

  • Send a request to the server-side API for directory creation

    export

    Parameters

    • p: string

      VFS path of the directory to be created

    Returns Promise<RequestResult>

    A promise on a RequestResult which contains an error or true on success

move

packages

readfile

  • readfile(p: string, t: string): Promise<any>
  • Read a VFS file content. There are many ways a VFS file can be read:

    • Read as a raw text content
    • Read as a javascript file, in this case the content of the file will be executed
    • Read as JSON object
    export

    Parameters

    • p: string

      path of the VFS file

    • t: string

      return data type:

      • jsonp: the response is an json object
      • script: the response is a javascript code
      • xml, html: the response is a XML/HTML object
      • text: plain text

    Returns Promise<any>

    A promise on a RequestResult which contains an error or an object of FileInfoType

remove

scandir

setting

sharefile

  • Send a request to the server-side API for sharing/unsharing a VFS file, once shared a VFS file will be publicly visible by everyone

    export

    Parameters

    • p: string

      VFS file path to be shared

    • pub: boolean

      flag: share (true) or unshare (false)

    Returns Promise<RequestResult>

    A promise on a RequestResult which contains an error or true on success

upload

write