0.2.30 • Published 9 years ago

noinfopath-data v0.2.30

Weekly downloads
3
License
MIT
Repository
-
Last release
9 years ago

noinfopath-data

@version 0.2.30

Overview

NoInfoPath data provides several services to access data from local storage or remote XHR or WebSocket data services.

Build Status

Dependencies

  • AngularJS
  • jQuery
  • ngLodash
  • Dexie
  • Dexie Observable
  • Dexie Syncable

Development Dependencies

See package.json for exact version requirements.

  • indexedDB.polyfill
  • angular-mocks
  • es5-shim
  • grunt
  • grunt-bumpup
    • grunt-version
  • grunt-contrib-concat
  • grunt-contrib-copy
  • grunt-contrib-watch
  • grunt-karma
  • jasmine-ajax
  • jasmine-core
  • jshint-stylish
  • karma
  • karma-chrome-launcher
  • karma-coverage
  • karma-firefox-launcher
  • karma-html-reporter
  • karma-ie-launcher
  • karma-jasmine
  • karma-phantomjs-launcher
  • karma-safari-launcher
  • karma-verbose-reporter
  • noinfopath-helpers
  • phantomjs

Developers' Remarks

WhoWhenWhat
Jeff2015-06-20T22:25:00ZWhaaat?

@interface noInfoPath

Overview

This interface exposes some useful funtions on the global scope by attaching it to the window object as window.noInfoPath

Methods

getItem

setItem

bindFilters deprecated

noFilter deprecated

noFilterExpression deprecated

noDataReadRequest deprecated

noDataSource deprecated

digest deprecated

digestError deprecated

digestTimeout deprecated

@class NoFilterExpression : Object

Represents an single filter expression that can be applied to an IDBObjectStore.

Constructor

NoFilterExpression(column, operator, value , logic)

NameTypeDescription
columnStringThe name of the column filter on.
operatorStringOne of the following values: eq, ne, gt, ge, lt, le, contains, startswith
valueAny Primative or Array of Primatives or ObjectsThe vales to filter against.
logicString(Optional) One of the following values: and, or.

Properties

NameTypeDescription
columnStringThe name of the column filter on.
operatorStringOne of the following values: eq, ne, gt, ge, lt, le, contains, startswith
valueAny Primative or Array of Primatives or ObjectsThe vales to filter against.
logicString(Optional) One of the following values: and, or.

Class NoFilters : Array

NoFilters is an array of NoFilterExpression objects.

Properties

NameTypeDescription
lengthNumberNumber of elements in the array.

Methods

add(column, operator, value, logic)

Creates and adds a new NoFilterExpression into the underlying array that NoFilters represents.

Parameters

NameTypeDescription
columnStringThe name of the column filter on.
operatorStringOne of the following values: eq, ne, gt, ge, lt, le, contains, startswith
valueAny Primative or Array of Primatives or ObjectsThe vales to filter against.
logicString(Optional) One of the following values: and, or.

Class NoSortExpression : Object

Represents a single sort expression that can be applied to an IDBObjectStore.

Constructor

NoFilterExpression(column, dir)

Properties

NameTypeDescription
columnStringThe name of the column filter on.
dirString(Optional) One of the following values: asc, desc.

Class NoSort : Array

NoSort is an array of NoSortExpression objects.

Properties

NameTypeDescription
lengthNumberNumber of elements in the array.

Methods

add(column, dir)

Creates and adds a new NoSortExpression into the underlying array that NoSort represents.

Parameters

NameTypeDescription
columnStringThe name of the column filter on.
dirString(Optional) One of the following values: asc, desc.

Class NoPage : Object

NoPage represent that information required to support paging of a data set.

Constructor

NoPage(skip, take)

Properties

NameTypeDescription
skipNumberNumber of objects to skip before returning the desired amount specified in take.
takeNumberNumber of objects records to return when paging data.

Class NoResults : Object

NoResults is a wrapper around a standard JavaScript Array instance. It inherits all properties and method offered by Array, but adds support for paged queries.

@constructor NoResults(arrayOfThings)

Parameters

NameTypeDescription
arrayOfThingsArray(optional) An array of object that is used to populate the object on creation.

Properties

Inherited properties are omitted.

NameTypeDescription
totalNumberThe total number of items in the array

Methods

page(options)

Parameters
NameTypeDescription
optionsNoPageA NoPage object that contains the paging instructions
Parameters
NameTypeDescription
arrayOfThingsArray(optional) An array of object that is used to populate the object on creation.
Returns

void

@class NoFilterExpression : Object

Represents an single filter expression that can be applied to an IDBObjectStore.

Constructor

NoFilterExpression(column, operator, value , logic)

NameTypeDescription
columnStringThe name of the column filter on.
operatorStringOne of the following values: eq, ne, gt, ge, lt, le, contains, startswith
valueAny Primative or Array of Primatives or ObjectsThe vales to filter against.
logicString(Optional) One of the following values: and, or.

Properties

NameTypeDescription
columnStringThe name of the column filter on.
operatorStringOne of the following values: eq, ne, gt, ge, lt, le, contains, startswith
valueAny Primative or Array of Primatives or ObjectsThe vales to filter against.
logicString(Optional) One of the following values: and, or.

Class NoFilters : Array

NoFilters is an array of NoFilter objects.

Constructors

NoFilters()

Usage
var x = new noInfoPath.data.NoFilters()

Properties

NameTypeDescription
lengthNumberNumber of elements in the array.

Methods

add(column, logic, beginning, end, filters)

Creates and adds a new NoFilter into the underlying array that NoFilters represents.

Parameters
NameTypeDescription
columnStringThe name of the column to filter on.
logicStringOne of the following values: 'and', 'or'
beginningBooleanIf the NoFilter is the beginning of the filter expression
endBooleanIf the NoFilter is the end of the filter expression
filtersArrayArray of NoFilterExpressions

toSQL()

Converts the NoFilters array to a partial SQL statement. It calls the toSQL() method on every NoFilter object within the NoFilters array.

Parameters

None

Class NoFilter : Object

NoFilter is an object with some properties that has an array of NoFilterExpressions hanging off of it.

Properties

NameTypeDescription
columnStringThe column that will be filtered on
logicStringOne of the following values: 'and', 'or'
beginningBooleanIf the NoFilter is the beginning of the filter expression
endBooleanIf the NoFilter is the end of the filter expression
filtersArrayArray of NoFilterExpressions

Methods

toSQL()

Converts the current NoFilter object to a partial SQL statement. It calls the NoFilterExpression toSQL() method for every NoFilterExpression within the filters array.

Parameters

NameTypeDescription
columnStringThe name of the column filter on.
operatorStringOne of the following values: eq, ne, gt, ge, lt, le, contains, startswith
valueAny Primative or Array of Primatives or ObjectsThe vales to filter against.
logicString(Optional) One of the following values: and, or.

Class NoSort : Array

NoSort is an array of NoSortExpression objects.

Properties

NameTypeDescription
lengthNumberNumber of elements in the array.
totalNumberTotal number of rows available given the current filters.
pagedArrayAn array of object sliced on the skip and take parameters passed into the constructor.

Methods

add(column, dir)

Creates and adds a new NoSortExpression into the underlying array that NoSort represents.

Parameters

NameTypeDescription
columnStringThe name of the column filter on.
dirString(Optional) One of the following values: asc, desc.

@interface INoQueryParser

INoQueryParser is a conceptual entity, it does not really exist the reality. This is because JavaScript does not implement interfaces like other languages do. This documentation should be considered a guide for creating query parsers compatible with NoInfoPath.

Overview

INoQueryParser provides a service interface definition for converting a set of NoInfoPath class related to querying data into a given query protocol. An example of this is the ODATA 2.0 specification.

Methods

makeQuery(filters, sort, page)

Parameters
NameTypeDescriptions
filtersNoFilters(Optional) Instance of a NoFilters class
sortNoSort(Optional) Instance of NoSort class
pageNoPage(Optional) Instance of NoPage class
Returns

Object

noQueryParser

Overview

The noQueryParser takes the data property of the options parameter passed to the Kendo DataSources transport.read method. The data object is inspected and its filter, sort, and paging values are converted to NoInfoPath compatible versions.

Methods

parse(options)

Parses provided filter, sort and paging options into NoInfoPath compatible objects. Stores the results internally for future use.

Returns

Any/all filters, sorts or paging data as an array compatible with a call to function.prototype.array.

Properties

None.

noQueryParser : INoQueryParser

Overview

Implements a INoQueryBuilder compatible service that converts NoFilters, NoSort, NoPage into ODATA compatible query object.

@class MockStorage

@class NoStorage

@service noConfig

Overview

The noConfig service downloads the application's config.json and exposes its contents via the noConfig.current property. If the application's server is offline noConfig will try to load config.json from LocalStorage.

Properties

NameTypeDescription
currentobjectexposes the entire download config.json

Methods

fromCache()

Loads the configuration from LocalStorage.

Parameters

none

Returns

String

load(uri)

Loads the conifiguration data from and HTTP endpoint.

Parameters
NameTypeDescription
uristring(optional) A relative or fully qualified location of the configuration file. If not provided the default value is /config.json
Returns

AngularJS::promise

whenReady(uri)

Returns a promise to notify when the configuration has been loaded. If the server is online, whenReady will call load, if not it will try to load it from LocalStorage. If there is no cached version available then an error is returned.

Once the config.json is resolved is it stored on $rootScope as $rootScope.noConfig

Parameters
NameTypeDescription
uristring(optional)A relative or fully qualified location of the configuration file. If not provided the default value is /config.json
Returns

AngularJS::promise

@service noHTTP

Overview

Provides a RESTful compatible HTTP service.

Methods

create(uri, data)

Parameters
NameTypeDescription
uristringunique identifier of the table to operate against
dataobjectthe data to use to create the new obejct in the db

read(resourceURI, query)

update(resourceURI, formdata)

TODO: Implementation required.

destroy(resourceURI, formdata)

TODO: Implementation required.

@class NoDb

Overview

Creates and manages a set of NoTable objects.

@constructor NoDb(tables, queryBuilder)

Parameters
NameTypeDescription
tablesobjectA hash object that contains a collection of table configuration as provided by noDbScema
queryBuilderfunctiona reference to a function that compiles supplied NoFilters, NoSort, and NoPage objects into a query object compatible with the upstream provider.

@class NoTable

Overview

Provides an interface that loosely matches that of the NoTable class provided by noDexie. This to ease the integration with NoInfoPath component that consume data such as noKendo.

@constructor NoTable(tableName, queryBuilder)

Parameters
NameTypeDescription
tableNamestringname of the table that this instance will interact with.
queryBuilderfunctiona reference to a function that compiles supplied NoFilters, NoSort, and NoPage objects into a query object compatible with the upstream provider.

noDbSchema

The noDbSchema service provides access to the database configuration that defines how to configure the local IndexedDB data store.

Properties

NameTypeDescription
storeObjectA hash table compatible with Dexie::store method that is used to configure the database.
tablesObjectA hash table of NoInfoPath database schema definitions
isReadyBooleanReturns true if the size of the tables object is greater than zero

Methods

_processDbJson

Converts the schema received from the noinfopath-rest service and converts it to a Dexie compatible object.

Parameters
NameTypeDescriptions
respObjectThe raw HTTP response received from the noinfopath-rest service

load()

Loads and processes the database schema from the noinfopath-rest service.

Returns

AngularJS::Promise

whenReady

whenReady is used to check if this service has completed its load phase. If it has not is calls the internal load method.

Returns

AngularJS::Promise

noDbSchema

The noDbSchema service provides access to the database configuration that defines how to configure the local IndexedDB data store.

Properties

NameTypeDescription
storeObjectA hash table compatible with Dexie::store method that is used to configure the database.
tablesObjectA hash table of NoInfoPath database schema definitions
isReadyBooleanReturns true if the size of the tables object is greater than zero

NoDbSchema : Class

This provides

Constructors

Constructor()

Usage
var x = new NoDbSchema();
Parameters

None

Methods

createSqlTableStmt(tableName, tableConfig)

Returns a SQL query string that creates a table given the provided tableName and tableConfig

Usage
var x = createSqlTableStmt(tableName, tableConfig);
Parameters
NameTypeDescription
tableNameStringThe name of the table to be created
tableConfigObjectThe schema of the table to be created
Returns

Returns a SQL query string

Properties

NameTypeDescription
queryStringStringReturns a SQL query string that creates a table given the provided tableName and tableConfig
{
	"dbName": "NoInfoPath_dtc_v1",
	"provider": "noIndexedDB",
	"remoteProvider:": "noHTTP",
	"version": 1,
	"schemaSource": {
		"provider": "inline",
		"schema": {
			"store": {
				"NoInfoPath_Changes": "$$ChangeID"
			},
			"tables": {
				"NoInfoPath_Changes": {
					"primaryKey": "ChangeID"
				}
			}
		}
	}
}

NoDbSchemaFactory

Creates unique instances of NoDbSchema based on noDBSchema configuration data.

NOTE: noDbSchema property of noConfig is an array of NoInfoPath data provider configuration objects.

@interface INoQueryBuilder

INoQueryBuilder is a conceptual entity, it does not really exist the reality. This is because JavaScript does not implement interfaces like other languages do. This documentation should be considered as a guide for creating query providers compatible with NoInfoPath.

Overview

INoQueryBuilder provides a service interface definition for converting a set of NoInfoPath class related to querying data into a given query protocol. An example of this is the ODATA 2.0 specification.

Methods

makeQuery(filters, sort, page)

Parameters
NameTypeDescriptions
filtersNoFilters(Optional) Instance of a NoFilters class
sortNoSort(Optional) Instance of NoSort class
pageNoPage(Optional) Instance of NoPage class
Returns

Object

@service noSQLQueryBuilder : INoQueryBuilder

Overview

Implements a INoQueryBuilder compatible service that converts NoFilters, NoSort, NoPage into a WebSQL compatible query string.

createTable(tableName, table)

Parameters

NameTypeDescription
typeStringOne of T|V
tableNameStringThe table's name
tableObjectThe table schema

NoTable

CRUD interface for WebSql

_getOne(rowid)

Parameters

NameTypeDescription
rowidNumber or ObjectWhen a number assume that you are filtering on "rowId". When an Object the object will have a key, and value property.

_exec(sqlExpressionData)

Parameters

NameTypeDescription
sqlExpressionDataObjectAn object with two properties, queryString and valueArray. queryString is the SQL statement that will be executed, and the valueArray is the array of values for the replacement variables within the queryString.

webSqlOperation(operation, noTransaction, data)

Parameters

NameTypeDescription
operationStringEither one of (C|U|D|BD|BC)
noTransactionObjectThe noTransaction object that will commit changes to the NoInfoPath changes table for data synchronization. This parameter is required, but can be null.
dataObjectName Value Pairs

noCreate(data, noTransaction)

Inserts a record into the websql database with the data provided.

Parameters

NameTypeDescription
dataObjectName Value Pairs
noTransactionObjectThe noTransaction object that will commit changes to the NoInfoPath changes table for data synchronization

noRead(NoFilters, NoSort, NoPage)

Reads records from the websql database.

Parameters

NameTypeDescription
NoFiltersObject(Optional) A noInfoPath NoFilters Array
NoSortObject(Optional) A noInfoPath NoSort Object
NoPageObject(Optional) A noInfoPath NoPage Object

noUpdate(data, noTransaction)

Updates a record from the websql database based on the Primary Key of the data provided.

Parameters

NameTypeDescription
dataObjectName Value Pairs
noTransactionObjectThe noTransaction object that will commit changes to the NoInfoPath changes table for data synchronization

noDestroy(data, noTransaction)

Deletes a record from the websql database based on the Primary Key of the data provided.

Parameters

NameTypeDescription
dataObjectName Value Pairs
noTransactionObjectThe noTransaction object that will commit changes to the NoInfoPath changes table for data synchronization

noOne(data)

Reads a record from the websql database based on the Primary Key of the data provided.

Parameters

NameTypeDescription
dataObjectName Value Pairs

noClear()

Delete all rows from the current table.

Returns

AngularJS Promise.

NoView

An in memory representation of complex SQL operation that involes multiple tables and joins, as well as grouping and aggregation functions.

NoView JSON Prototype
{
	"sql": String,
	"primaryKey": String,
	"params": []
}
References

noOne(data)

Reads a record from the websql database based on the Primary Key of the data provided.

Parameters

NameTypeDescription
dataObjectName Value Pairs

noIndexedDB

The noIndexedDB factory creates and configures a new instance of Dexie. Dexie is a wrapper around IndexedDB. noIndexedDB is a Dexie AddOn that extends the query capabilites of Dexie, and exposes a CRUD interface on the WriteableTable class.

Class noDatum

This is a contructor function used by Dexie when creating and returning data objects.

Class noDexie

This is the classed used to construct the Dexie AddOn.

noCreate

Adds a new record to the database. If the primary key is provided in that will be used when adding otherwise a new UUID will be created by Dexie.

Parameters

|Name|Type|Description| |data|Object|An object contains the properties that match the schema for the underlying WriteableTable.

Returns

AngularJS:Promise

noRead

The read operation takes a complex set of parameters that allow for filtering, sorting and paging of data.

Parameters
NameTypeDescriptions
filtersNoFilters(Optional) Any NofilterExpression objects that need to be applied to the the current table.
sortNoSort(Optional) Any NoSortExpression objects that need to be applied to the result set. The will be applied in the order supplied.
pageNoPage(Optional) Paging information, if paging is reqired by the read operation.
Returns

AngularJS::Promise

Internal Values

NameTypeDescription
deferred$q::deferredAn AngularJS deferment object that is used to return a Promise.
_resolveFunctionCall to resolve Dexie::Promise upon successful completion of _applyFilters(). This function is returned while resolving the underlying IDBObjectStore from the table parameter.
_rejectFunctionCall to resolve the Dexie::Promise when an unexpected for un recoverable error occurs during processing.
_storeIDBObjectStoreThis underlying IDBObjectStore that the table parameter represents.
_transIDBTransactionThis is the underlying IDBTransaction that the current object store is bound to.
nonIndexedOperators

This hash table allows for quick access to the operations that can be applied to a property on a target object and the value(s) being filtered on.

NOTE: The "a" parameter will always be the value tested, and "b" will always be the value being filter for.

_applyFilters

This function develops an array of objects that has had all of the filters provided in the original request applied to them. The schema matches the schema of the table parameter.

Parameters
NameTypeDescription
iNofiltersiNoFilterExpressionAn array of filter expressions. Contains both indexed and non-indexed filters
tableDexie::TableA reference to the Dexie::Table being filtered.
Internal variables
NameTypeDescription
deferred$q::deferredAn AngularJS deferment object that is used to return a Promise.
iNoFilterHashCollectionUsed to organize the filters received in the iNoFilters in to a set of indexed and non-indexed filter object The collection is created by a call to _sortOutFilters().
resultsKeysArray\<guid>This will be use to collect the final set of results. It will be an array of keys that will be used to query the final result set.
Returns

AngularJS::Promise (Maybe)

_filterByIndex

This method of filtering goes against a predefined index. Basically we are doing a MapReduce techique angaist each indexed filter we come across. Using the filter parameter provided the index is reduced by matching against the value property of the INoFilterExpression. See the INoFilterExpression for more details.

Parameters

NameTypeDescription
filterINoFilterExpressionA single indexed filter the contains the column, operator, and value to apply to the index.

Returns

AngularJS::Promise

_filterByPrimaryKey -- Being Deprecated

This method of of filterig goes against the IDBObjectStore's primary key.

_filterHasIndex uses the iNoFilter parameter to determine if there is an index available for the give filter. it returns true if there is, false if not.

To determine if and index exists, we look at the table.schema.primKey, and table.schema.indexes properties.

_recurseIndexedFilters

This method of filtering compares the supplied set of filters against each object return in the Dexie colletion. This is a much slower than filtering against an index.

While Dexie supports a put operation which is similar to upsert, we're going with upsert which decides whether an insert or an update is required and calls the appropreiate function.

configure

This function splits up the filters by indexed verses not. The return value is a INoFilterHash.

interface INoFilterHash { indexedFilters: INoFilterExpression nonIndexedFilters: INoFilterExpression }

This function applies the provided sort items to the supplied Dexie:Collection. It should always sort on indexed columns and return a DexieCollection.

NOTE: Need to research how to apply multi-column sorting.

Applies the specified skip and take values to the final Dexie::Collection, if supplied.

Note that this is the function returns the final Array of items based on all of the properties applied prior to this call.

The promise should resolve to a Dexie::Collection that will result in a set of data that matches the supplied filters, reject errors.

The update function expects the key to be within the update object.

Maps to the Dexie.Table.get method.

_extendDexieTables

Class noDatum

This is a contructor function used by Dexie when creating and returning data objects.

noDataSource Service

Provides a generic service that exposes the NoInfoPath data providers' underlying CRUD interface.

"noDataSource": {
       "dataProvider": "noWebSQL",
       "databaseName": "FCFNv2",
       "entityName": "LU_PercentColor",
       "primaryKey": "PercentColorID",
       "queryParser": "noQueryParser",
       "sort":  [{"field": "Percentage", "dir": "asc"}]
   }

resolveFilterValues(filters)

This is more information

Note of some kind

NameTypeDescription
FooNumberDoes something fun.

TODO: Implement support for delayed (waitFor) filter values.

NOTE: If a filter.value is an object and it has a source property set to scope then use the directives scope variable. Otherwise assume source is an injectable.

create(dsConfigKey)

create a new instance of a NoDataSource object configured based on the datasource configuration found in noConfig at the given dsConfigKey location.

Parameters
NameTypeDescription
dsConfigKeyStringThe location in noConfig where the data source's configuration can be found. Can be a complex name like the following. noForms.myForm1.noComponents.foo.noDataSource
Returns

An instance of a NoDataSource object.

0.2.30

9 years ago

0.2.29

9 years ago

0.2.28

9 years ago

0.2.27

9 years ago

0.2.26

9 years ago

0.2.25

9 years ago

0.2.24

9 years ago

0.2.23

9 years ago

0.2.21

9 years ago

0.2.20

9 years ago

0.2.19

9 years ago

0.2.18

9 years ago

0.2.17

9 years ago

0.2.15

9 years ago

0.2.12

9 years ago

0.2.10

9 years ago

0.2.9

9 years ago

0.2.7

9 years ago

0.2.6

9 years ago

0.2.4

9 years ago

0.2.0

9 years ago

0.2.3

9 years ago

0.1.33

9 years ago

0.1.32

9 years ago

0.1.31

9 years ago

0.1.30

9 years ago

0.1.29

9 years ago

0.1.28

9 years ago

0.1.27

9 years ago

0.1.26

9 years ago

0.1.25

9 years ago

0.1.24

9 years ago

0.1.23

9 years ago

0.1.22

9 years ago

0.1.21

9 years ago

0.1.20

9 years ago

0.1.19

9 years ago

0.1.18

9 years ago

0.1.17

9 years ago

0.1.16

9 years ago

0.1.15

9 years ago

0.1.14

9 years ago

0.1.13

9 years ago

0.1.12

9 years ago

0.1.11

9 years ago

0.1.10

9 years ago

0.1.9

9 years ago

0.1.8

9 years ago

0.1.7

9 years ago

0.1.6

9 years ago

0.1.5

9 years ago

0.1.4

9 years ago

0.1.3

9 years ago

0.1.2

9 years ago

0.1.1

9 years ago

0.1.0

9 years ago

0.0.2

9 years ago