• Core
  • Distribute
  • Document
  • Encryption
  • Index
  • Log
  • Record
  • Request
  • Transaction
  • Warehouse
  • Version

Core

Core forms the basis for all classes and their member methods (PHP) or object functions (Javascript) and are only called by these methods or functions.

PHP
Core class methods are protected. All classes expcept \Vxsn\Extension extend \Vxsn\Core.

Javascript
Core functions are marked *.

  • fileRead(filename)

    filename is full directory and filename. Reads files suited to method-specific requests as inferred by file extension. Will return data as object, array, or variable on success. Will return false !filename.
  • fileWrite(filename, data, true)

    filename is full directory and filename. data is object, array, or variable. Writes files suited to method-specific requests as inferred by file extension. Returns true on success. Will return false if unlock is true and file is not locked.
  • filter(id)*

    filters id according to whitelisted characters and trims spaces.
  • id(count, length)*

    count is starting count as unsigned integer. 0 is default. length is unsigned integer and represents number of characters in ID. Default is defined in configuration constant. Returns a new alpha ID of length using count as ID counter.
  • link(id, name)*

    id is hierarchical ID. name is index name. name when set is link record to index; name when not set is link index to record. Link index to record in {id}/record.link or link record to index in {id}/Index/{name}.link. Required when \Record\create, \Record\update, \Index\create or \Index\update.
  • parse(id)*

    id is complete hierarchical ID or full directory hierarchy. Returns directory hierarchy if id is hierarchical ID. Returns hierarchical ID if id is directory hierarchy. Returns false on fail.
  • delink(id, name)*

    id is hierarchical ID. name is index name. name when set is unlink record from index; name when not set is unlink index from record. Unlink index from record in {id}/record.link or unlink record from index in {id}/Index/{name}.link. Required when \Record\delete or \Index\delete.
  • unlinks(path)

    Unlink tree starting at node (recursive).

Distribute

Distribute allows the distribution of a node-branch or node-tree to a constellation of VXSN endpoints.

PHP
Distribute extends \Vxsn\Core.

Javascript
Distribute functions are marked *.

  • commit(mid)

    mid is map ID. Returns JSON-formatted object string including constellation ID, master URI and constellation of slave URIs on success. Returns false on fail.
  • map(id)

    id is node ID to map across a constellation. Returns map ID on success. Returns false on fail.

Document

Document is one of three primary classes or objects. Document supports isolated CRUD functions, distributed CRUD functions when used with Distribute, and document versioning. Documents can be made immutable with \Vxsn\Record. Documents are application-defined primitives, arrays, or objects stored as JSON formatted plain text files.

PHP
Document extends \Vxsn\Core.

Javascript
Document functions are marked *.

  • create(id)*

    id is hierarchical record ID. Returns true on success. Returns false on fail.
  • read(id, true)

    id is hierarchical record ID. true is only read object at end of node tree ID. Returns JSON-formatted object string on success. Returns false on fail.
  • update(id, version, overwrite)

    id is hierarchical record ID. version if true will \Vxsn\Document\version(filename), default is false. overwrite if true will overwrite existing record. Default is \Vxsn\Document\read(id) and merge keys before write.
  • delete(id)

    id is hierarchical record ID. Deletes record and all children at id. Returns true on success. Returns false on fail.
  • version(filename)

    Private method. filename is full directory and filename. Copies Document.json to /Version/microtime.json. Makes /Version is !exist.

Encryption

Encryption provides asymmetric key encryption for primitive, array or object data stored in or read from documents. Public key indices (private keys are discarded after generation) or public-private keypairs can persist within a VXSN data store.

PHP
Encryption extends \Vxsn\Core. \Vxsn\Encryption::encrypt and \Vxsn\Encryption::decrypt are static methods and called before write or after read.

Javascript
Encryption functions are marked *.

  • create(id, length, true)

    length is bit length. Default is 2048. true will store private-public key-pair. Default is false. Creates new RSA asymmetric encryption private→public key-pair. Returns true on success. Returns false if public key exists. Stores public key as id.pub. If true will store private key as id.pem.
  • read(id, type)

    id is hierarchical ID. type is private or public. id and type are required. Reads private or public key for id. Returns key of type for id on success. Returns false on fail.
  • delete(id)

    id is hierarchical ID. Deletes key or key-pair from id. Returns true on success. Returns false on fail.
  • ::encrypt(type, string)

    type is public or private. string is plain-text data string to encrypt. Encrypts string with key of type. Returns string encrypted by key type on success. Returns false on fail.
  • ::decrypt(type, string)

    type is public or private. string is encrypted data string to decrypt. Decrypts string with key of type. Returns string decrypted by key type on success. Returns false on fail.

Index

Index is one of three primary classes or objects. Index supports isolated CRUD functions or distributed CRUD functions when used with Distribute. Indices should always be a sequence (indexed) of values or a collection of single dimension key->value pairs. *Indices may also be a collection of recursive key->object pairs but this will affect sharding.

PHP
Index extends \Vxsn\Core.

Javascript
Index functions are marked *.

  • create(id, name)

    id is hierarchical ID. name is index name.
  • read(id, name)

    id is hierarchical ID. name is index name. Returns JSON-formatted index object from /Index/name.json or if Index/name is directory, reads Index/name/shard.json and returns JSON-formatted index object from Index/name/{x}.json where {x} is nearest shard. Resets name if index is a shard. Returns false on fail.
  • update(id, name, true)

    id is hierarchical ID. name is index name. true is overwrite entire index. Default is \read and merge update before write.
  • delete(id, name)

    id is hierarchical ID. name is index name.
  • merge(id, name, true)

    id is hierarchical ID. name is index name. true is write index at Index/name.json.
  • shard(id, name, size)

    Shards index at size and writes shard index to /Index/name/shard.json and index shards to /Index/name/{1}.json … {x}.json.
  • size(id, name)

    Returns index size by number of objects.

Log

Log provides a running a record of Class:method CRUD operations on all persistent Document, Index, Record and Warehouse objects.

PHP
Log extends \Vxsn\Core. \Vxsn\Log::core is a static method called by all classes and their member methods.

Javascript
Log functions are are not available.

  • ::entry(id)

    id is hierarchical record ID. Appends id/Log/Class::method.log with microtime and requestor ID. Infers Class::method from parent request.
  • read(id, class, method)

    id is hierarchical record ID. Returns JSON-formatted object string with microtime as key and requestor ID as value.

Record

Record is a document made immutable. Once a document becomes a record it will be read-only. C-UD and Version operations will be disallowed. Record is applied on the last node in an ID. Record cannot be undone. \Vxsn\Document\read will return record if !document.

PHP
Record extends \Vxsn\Core.

Javascript
Record functions are marked *.

  • create(id)

    id is document ID. Returns true on success; false on fail.

Request

Request composes or decomposes an ID string with inherent order and relation from a collection of IDs. Request also two-way ID string mask translation.

PHP
Request extends \Vxsn\Core.

Javascript
Request functions are marked *.

  • compose(collection)*

    collection is a JSON formatted strings that includes a collection of ordered document IDs. Returns composed ID string on success; false on fail.
  • decompose(id)*

    id is a composed ID string. Returns Request object as a quasi-warehouse on success; false on fail.
  • mask(id)

    id is composed ID string. Returns a short ID mask and persists this ID in /Index/Mask.json on success; false on fail. ID masks should be used judiciously as they are indexed globally.

Transaction

Transaction provides ordered or dependent operations that can be performed in-memory and committed upon success.

PHP
Transaction extends \Vxsn\Core.

Javascript
Transaction functions are marked *.

  • create(transactions)

    transactions is a JSON formatted string that includes and ordered set of instructions. Returns transaction ID on success; false on fail.
  • commit(tid)

    tid is transaction ID. Will persist all transactions in tid object on success; false on fail.
  • cancel(tid)

    tid is transaction ID. Will destroy transaction and return true on success; false on fail.

Warehouse

Warehouse creates a recursive mirror of stored nodes or imports a collection of CSVs for in-memory operations.

PHP
Warehouse extends \Vxsn\Core.

Javascript
Warehouse functions are marked *.

  • construct(ids)

    ids is array of IDs. Constructs warehouse recursively from starting node IDs. Returns Warehouse object on success; false on fail.
  • import(id, name, files)

    id is parent id. name is warehouse name. files is array of uploaded CSVs. Creates an Index for each CSV. First-row column headers are Document keys. Each row is a Document and row values are Document values. Returns Warehouse object on success; false on fail.
  • commit(id, name)*

    id is parent ID. name is warehouse name. Stores (block storage or localStorage*) warehouse for parent ID at Warehouse/name. Returns true on success; false on fail.
  • read(id, name)*

    id is parent ID. name is warehouse name. Returns Warehouse object on success; false on fail.
  • delete(id, name)*

    id is parent ID. name is warehouse name. Returns true on success; false on fail.
  • size(id, name)

    id is parent ID. name is warehouse name. Returns size of warehouse in bytes; false on fail.

Version

Version provides support functions for Document versioning including document revision list, document revision review, and document reversion to an existing revision.

PHP
Version extends \Vxsn\Core.

Javascript
Version functions are marked *.

  • list(id)

    id is document ID. Returns list of document revision timestamps on success. Returns false on fail.
  • revert(id, time)

    id is document ID. time is revision micro timestamp. Returns true on success; false on fail.
  • review(id, time)

    id is document ID. time is revision micro timestamp. Returns Version object on success; false on fail.