@progress/jsdo-angular
Advanced tools
Comparing version 5.0.0-2018-04-03-00001 to 5.0.0
"use strict"; | ||
/* | ||
Progress JSDO DataSource for Angular: 5.0.0 | ||
Progress Progress Data Source for Angular: 5.0.0 | ||
@@ -21,3 +21,3 @@ Copyright 2017-2018 Progress Software Corporation and/or its subsidiaries or affiliates. | ||
Progress DataSource class for NativeScript, Angular. This will provide a seamless integration | ||
Progress Data Source class for NativeScript, Angular. This will provide a seamless integration | ||
between OpenEdge (Progress Data Object) with NativeScript. | ||
@@ -50,7 +50,11 @@ | ||
this.jsdo = undefined; | ||
this._data = null; | ||
// useArray === false means that arrays would be flattened | ||
this.useArrays = false; | ||
this.jsdo = options.jsdo; | ||
this._initFromServer = false; | ||
this._isLastResultSetEmpty = false; | ||
this._options = options; | ||
// Turning off autoApplyChanges. Want to explicitly call jsdo.acceptChanges() and rejectChanges() | ||
this.jsdo.autoApplyChanges = false; | ||
this.readLocal = options.readLocal !== undefined ? options.readLocal : false; | ||
// Make sure autoApplyChanges = true | ||
this.jsdo.autoApplyChanges = true; | ||
if (!options.jsdo || !(options.jsdo instanceof jsdo_core_1.progress.data.JSDO)) { | ||
@@ -70,6 +74,160 @@ throw new Error("DataSource: jsdo property must be set to a JSDO instance."); | ||
this._tableRef = this._options.tableRef; | ||
// Find out the name of 'Count' function from Catalog if defined as 'Count' operation | ||
// instead of an INVOKE | ||
if (this._options.countFnName !== undefined) { | ||
if (typeof (this.jsdo[this._options.countFnName]) !== "function") { | ||
throw new Error("Invoke operation '" + | ||
this._options.countFnName + "' for countFnName is not defined."); | ||
} | ||
} | ||
else if (this.jsdo["_resource"].generic.count !== undefined) { | ||
for (var fnName in this.jsdo["_resource"].fn) { | ||
if (this.jsdo["_resource"].generic.count === this.jsdo["_resource"].fn[fnName]["function"]) { | ||
this._options.countFnName = fnName; | ||
break; | ||
} | ||
} | ||
} | ||
this._initConvertTypes(); | ||
} | ||
// _convertStringToDate: | ||
DataSource.prototype._convertStringToDate = function (data, fieldName, targetFieldName) { | ||
var transport = this; | ||
var array, ablType, orig; | ||
if (!targetFieldName) { | ||
targetFieldName = fieldName; | ||
} | ||
// Check if string is <year>-<month>-<day> | ||
array = transport._convertFields._datePattern.exec(data[targetFieldName]) || []; | ||
if (array.length > 0) { | ||
data[targetFieldName] = new Date(parseInt(array[1], 10), parseInt(array[2], 10) - 1, parseInt(array[3], 10)); | ||
} | ||
else { | ||
ablType = transport.jsdo[transport._tableRef]._fields[fieldName.toLowerCase()].ablType; | ||
if (ablType === "DATETIME") { | ||
array = transport._convertFields._dateTimePattern.exec(data[targetFieldName]) || []; | ||
if (array.length > 0) { | ||
// Convert date to local time zone | ||
data[targetFieldName] = new Date(parseInt(array[1], 10), parseInt(array[2], 10) - 1, parseInt(array[3], 10), parseInt(array[4], 10), parseInt(array[5], 10), parseInt(array[6], 10), parseInt(array[7], 10)); | ||
} | ||
} | ||
// Check to see if it was converted | ||
if (typeof (data[targetFieldName]) === "string") { | ||
orig = data[targetFieldName]; | ||
try { | ||
data[targetFieldName] = new Date(data[targetFieldName]); | ||
} | ||
catch (e) { | ||
// Conversion to a date object was not successful | ||
data[targetFieldName] = orig; | ||
console.log("DataSource: Internal Error: _convertStringToDate() could not convert to date object: " + orig); | ||
} | ||
} | ||
} | ||
}; | ||
// _convertDataTypes: | ||
// Converts data types in the specified data record. | ||
// Data record could come from the JSDO or from the Kendo UI DataSource. | ||
// Returns a reference to the record. | ||
// Returns a copy when useArrays is undefined or false. | ||
DataSource.prototype._convertDataTypes = function (data) { | ||
var transport = this; | ||
var i, k, fieldName, schemaInfo, prefixElement, elementName, copy; | ||
// Use transport_jsdo as any to avoid exposing internal JSDO methods | ||
var transport_jsdo = transport.jsdo; | ||
if (!transport.useArrays && transport._convertTypes && (transport._convertFields._arrayFields.length > 0)) { | ||
copy = {}; | ||
transport_jsdo._copyRecord(transport_jsdo._buffers[transport._tableRef], data, copy); | ||
data = copy; | ||
} | ||
if (!transport._convertTypes) { | ||
return data; | ||
} | ||
for (k = 0; k < transport._convertFields._arrayFields.length; k += 1) { | ||
fieldName = transport._convertFields._arrayFields[k]; | ||
if (data[fieldName]) { | ||
schemaInfo = transport.jsdo[transport._tableRef]._fields[fieldName.toLowerCase()]; | ||
prefixElement = transport_jsdo._getArrayField(fieldName); | ||
for (i = 0; i < schemaInfo.maxItems; i += 1) { | ||
// ABL arrays are 1-based | ||
elementName = prefixElement.name + (i + 1); | ||
if (!transport.jsdo[transport._tableRef]._fields[elementName.toLowerCase()]) { | ||
// Skip element if a field with the same name exists | ||
// Extract value from array field into individual field | ||
// Array is removed later | ||
data[elementName] = data[fieldName][i]; | ||
// Convert string DATE fields to JS DATE | ||
if ((schemaInfo.ablType) | ||
&& (schemaInfo.ablType.indexOf("DATE") === 0) && (typeof (data[elementName]) === "string")) { | ||
transport._convertStringToDate(data, fieldName, elementName); | ||
} | ||
} | ||
} | ||
if (!transport.useArrays) { | ||
delete data[fieldName]; | ||
} | ||
} | ||
} | ||
for (k = 0; k < transport._convertFields._dateFields.length; k += 1) { | ||
fieldName = transport._convertFields._dateFields[k]; | ||
if (typeof (data[fieldName]) === "string") { | ||
transport._convertStringToDate(data, fieldName); | ||
} | ||
} | ||
return data; | ||
}; | ||
// _initConvertTypes: | ||
// Initializes transport._convertTypes to indicate whether a conversion of the data is needed | ||
// when it is passed to Kendo UI. | ||
// This operation is currently only needed for date fields that are stored as strings. | ||
// Sets array _dateFields to the fields of date fields to convert. | ||
DataSource.prototype._initConvertTypes = function () { | ||
var transport = this; | ||
var i, schema, fieldName, convertDateFields = false; | ||
var dateFields = [], arrayFields = []; | ||
transport._convertTypes = false; | ||
schema = transport.jsdo[transport._tableRef].getSchema(); | ||
for (i = 0; i < schema.length; i += 1) { | ||
fieldName = schema[i].name; | ||
if (fieldName.length > 0 && fieldName.charAt(0) !== "_") { | ||
if (schema[i].type === "string" && | ||
schema[i].format && | ||
(schema[i].format.indexOf("date") !== -1)) { | ||
dateFields.push(fieldName); | ||
if (!convertDateFields) { | ||
convertDateFields = true; | ||
} | ||
} | ||
else if (!transport.useArrays && schema[i].type === "array") { | ||
arrayFields.push(fieldName); | ||
if (!convertDateFields && schema[i].ablType && | ||
schema[i].ablType.indexOf("DATE") === 0) { | ||
convertDateFields = true; | ||
} | ||
} | ||
} | ||
} | ||
if (dateFields.length > 0 || arrayFields.length > 0) { | ||
transport._convertTypes = true; | ||
// _convertFields: Object containing arrays for each data type to convert | ||
transport._convertFields = {}; | ||
transport._convertFields._arrayFields = []; | ||
transport._convertFields._dateFields = []; | ||
} | ||
if (dateFields.length > 0) { | ||
transport._convertFields._dateFields = dateFields; | ||
} | ||
if (convertDateFields) { | ||
transport._convertFields._datePattern = new RegExp("^([0-9]+)?-([0-9]{2})?-([0-9]{2})?$"); | ||
transport._convertFields._dateTimePattern = new RegExp("^([0-9]+)?-([0-9]{2})?-([0-9]{2})?" + | ||
"T([0-9]{2})?:([0-9]{2})?:([0-9]{2})?.([0-9]{3})?$"); | ||
} | ||
if (arrayFields.length > 0) { | ||
transport._convertFields._arrayFields = arrayFields; | ||
} | ||
}; | ||
/** | ||
* Calls the jsdo.fill() retrieving data from the backend service | ||
* @returns Observable<Array<object>> | ||
* @returns An Observable which includes an Array<Object> followed | ||
* by an attribute for specifying 'total' records | ||
*/ | ||
@@ -81,21 +239,80 @@ DataSource.prototype.read = function (params) { | ||
var filter = {}; | ||
if (params) { | ||
var jsdo = this.jsdo; | ||
var tableRef = this._tableRef; | ||
// If this is a DataSource for a child table, check if read() was performed on parent | ||
if (!this._initFromServer) { | ||
if (jsdo[tableRef]._parent) { | ||
this._initFromServer = (jsdo[jsdo[tableRef]._parent]._data && | ||
(jsdo[jsdo[tableRef]._parent]._data.length > 0)) | ||
|| (jsdo[tableRef]._data instanceof Array && (jsdo[tableRef]._data.length > 0)); | ||
} | ||
else { | ||
this._initFromServer = (jsdo[tableRef]._data instanceof Array) && (jsdo[tableRef]._data.length > 0); | ||
} | ||
} | ||
if (this.readLocal && this._initFromServer) { | ||
return Observable_1.Observable.create(function (observer) { | ||
var data = _this.getJsdoData(); | ||
observer.next({ data: data, total: data.length }); | ||
}); | ||
} | ||
if (params && Object.keys(params).length > 0) { | ||
filter = params; | ||
} | ||
else { | ||
// Initial read() where the params are empty and we are assigning the filter criteria | ||
filter.filter = this._options.filter; | ||
filter.sort = this._options.sort; | ||
filter.top = this._options.top; | ||
filter.skip = this._options.skip; | ||
// If params has no properties, use default values for filter criteria | ||
if (this._options.filter || this._options.sort || this._options.top || this._options.skip) { | ||
filter.filter = this._options.filter; | ||
filter.sort = this._options.sort; | ||
filter.top = this._options.top; | ||
filter.skip = this._options.skip; | ||
} | ||
else { | ||
filter = undefined; | ||
} | ||
} | ||
// tableRef required for multi-table DataSets | ||
filter.tableRef = this._tableRef; | ||
if (filter) { | ||
filter.tableRef = this._tableRef; | ||
} | ||
wrapperPromise = new Promise(function (resolve, reject) { | ||
_this.jsdo.fill(filter) | ||
jsdo.fill(filter) | ||
.then(function (result) { | ||
_this._data = result.jsdo[_this._tableRef].getData(); | ||
resolve(_this._data); | ||
// Verifying the latest resultset value and setting _isLastResultSetEmpty flag if empty | ||
if (result.request.response[_this.jsdo["_dataSetName"]][_this._tableRef] | ||
&& result.request.response[_this.jsdo["_dataSetName"]][_this._tableRef].length === 0) { | ||
_this._isLastResultSetEmpty = true; | ||
} | ||
else if (result.request.response[_this.jsdo["_dataSetName"]] | ||
&& result.request.response[_this.jsdo["_dataSetName"]][_this._tableRef] === undefined) { | ||
_this._isLastResultSetEmpty = true; | ||
} | ||
else if (result.request.response[_this.jsdo["_dataSetName"]][_this._tableRef] | ||
&& result.request.response[_this.jsdo["_dataSetName"]][_this._tableRef].length !== 0) { | ||
_this._isLastResultSetEmpty = false; | ||
} | ||
_this._initFromServer = true; | ||
var data = _this.getJsdoData(); | ||
if ((_this._options.countFnName && _this._options.countFnName !== undefined) | ||
&& !(params.skip === 0 && params.top > data.length)) { // Server-side operations | ||
_this.getRecCount(_this._options.countFnName, { filter: result.request.objParam ? result.request.objParam.filter : undefined }) | ||
.then(function (res) { | ||
if (res === undefined && res == null) { | ||
reject(new Error(_this.normalizeError(res, "Unexpected response from 'Count Function' Operation", ""))); | ||
} | ||
else { | ||
resolve({ data: data, total: res }); | ||
} | ||
}, function (error) { | ||
reject(new Error(_this.normalizeError(error, "Problems invoking getRecCount function", ""))); | ||
}).catch(function (e) { | ||
reject(new Error(_this.normalizeError(e, "Unknown error occurred calling count.", ""))); | ||
}); | ||
} | ||
else { | ||
// Client side operations | ||
resolve({ data: data, total: data.length }); | ||
} | ||
}).catch(function (result) { | ||
reject(new Error(_this.normalizeError(result, "Unknown error occurred calling read."))); | ||
reject(new Error(_this.normalizeError(result, "read", ""))); | ||
}); | ||
@@ -107,11 +324,10 @@ }); | ||
}); | ||
// return Observable.fromPromise(wrapperPromise); | ||
return obs; | ||
}; | ||
/** | ||
* Returns array of record objects from JSDO local memory | ||
* @returns {object} | ||
* Returns array of record objects from local memory | ||
* @returns Array<object> | ||
*/ | ||
DataSource.prototype.getData = function () { | ||
return this.jsdo[this._tableRef].getData(); | ||
return this.getJsdoData(); | ||
}; | ||
@@ -127,4 +343,17 @@ /** | ||
var newRow = {}; | ||
jsRecord = this.jsdo[this._tableRef].add(data); | ||
this._copyRecord(jsRecord.data, newRow); | ||
var saveUseRelationships = this.jsdo.useRelationships; | ||
try { | ||
this.jsdo.useRelationships = false; | ||
jsRecord = this.jsdo[this._tableRef].add(data); | ||
this._copyRecord(jsRecord.data, newRow); | ||
} | ||
catch (error) { | ||
if (this.jsdo.autoApplyChanges) { | ||
this.jsdo[this._tableRef].rejectChanges(); | ||
} | ||
throw error; | ||
} | ||
finally { | ||
this.jsdo.useRelationships = saveUseRelationships; | ||
} | ||
return newRow; | ||
@@ -158,2 +387,3 @@ }; | ||
DataSource.prototype.update = function (data) { | ||
var saveUseRelationships = this.jsdo.useRelationships; | ||
if (!data && (data === undefined || null)) { | ||
@@ -168,10 +398,23 @@ throw new Error("Unexpected signature for update() operation."); | ||
} | ||
jsRecord = this.jsdo[this._tableRef].findById(id); | ||
if (jsRecord) { | ||
// Found a valid record. Lets update now | ||
retVal = jsRecord.assign(data); | ||
try { | ||
this.jsdo.useRelationships = false; | ||
jsRecord = this.jsdo[this._tableRef].findById(id); | ||
if (jsRecord) { | ||
// Found a valid record. Lets update now | ||
retVal = jsRecord.assign(data); | ||
this.jsdo.useRelationships = saveUseRelationships; | ||
} | ||
else { | ||
throw new Error("DataSource.update(): Unable to find record with this id " + id); | ||
} | ||
} | ||
else { | ||
throw new Error("DataSource.update(): Unable to find record with this id " + id); | ||
catch (error) { | ||
if (this.jsdo.autoApplyChanges) { | ||
this.jsdo[this._tableRef].rejectChanges(); | ||
} | ||
throw error; | ||
} | ||
finally { | ||
this.jsdo.useRelationships = saveUseRelationships; | ||
} | ||
return retVal; | ||
@@ -188,2 +431,3 @@ }; | ||
var id = (data && data._id) ? data._id : null; | ||
var saveUseRelationships = this.jsdo.useRelationships; | ||
var jsRecord; | ||
@@ -196,27 +440,25 @@ if (!data && (data === undefined || null)) { | ||
} | ||
jsRecord = this.jsdo[this._tableRef].findById(id); | ||
if (jsRecord) { | ||
// Found a valid record. Lets delete the record | ||
retVal = jsRecord.remove(data); | ||
try { | ||
this.jsdo.useRelationships = false; | ||
jsRecord = this.jsdo[this._tableRef].findById(id); | ||
if (jsRecord) { | ||
// Found a valid record. Lets delete the record | ||
retVal = jsRecord.remove(data); | ||
} | ||
else { | ||
throw new Error("DataSource.remove(): Unable to find record with this id " + id); | ||
} | ||
} | ||
else { | ||
throw new Error("DataSource.remove(): Unable to find record with this id " + id); | ||
catch (error) { | ||
if (this.jsdo.autoApplyChanges) { | ||
this.jsdo[this._tableRef].rejectChanges(); | ||
} | ||
throw error; | ||
} | ||
finally { | ||
this.jsdo.useRelationships = saveUseRelationships; | ||
} | ||
return retVal; | ||
}; | ||
/** | ||
* Accepts any pending changes in the data source. This results in the removal of the | ||
* before-image data. It also clears out any error messages. | ||
*/ | ||
DataSource.prototype.acceptChanges = function () { | ||
this.jsdo[this._tableRef].acceptChanges(); | ||
}; | ||
/** | ||
* Cancels any pending changes in the data source. Deleted rows are restored, | ||
* new rows are removed and updated rows are restored to their initial state. | ||
*/ | ||
DataSource.prototype.cancelChanges = function () { | ||
this.jsdo[this._tableRef].rejectChanges(); | ||
}; | ||
/** | ||
* Returns true if the underlying jsdo has CUD support (create, update, delete operations). | ||
@@ -238,6 +480,5 @@ * If not, it returns false. | ||
* JSDO memory for the current Data Object resource | ||
* @param {boolean} useSubmit Optional parameter. By default points to 'false' where all | ||
* record modifications are sent to server individually. When 'true' is used all record | ||
* modifications are batched together and are sent in single transaction | ||
* @returns {object} Promise | ||
* If jsdo.hasSubmitOperation is false, all record modifications are sent to server individually. | ||
* When 'true', modifications are batched together and sent in single request | ||
* @returns {object} Observable | ||
*/ | ||
@@ -257,3 +498,3 @@ DataSource.prototype.saveChanges = function () { | ||
// Submit case | ||
_this._copyRecord(result.request.xhr.response, responseData); | ||
_this._copyRecord(result.request.response, responseData); | ||
resolve(responseData); | ||
@@ -278,8 +519,13 @@ } | ||
} | ||
else { | ||
reject("Unknown error occurred when calling saveChanges."); | ||
else { // Reject promise if either of above cases are met | ||
reject(new Error(_this | ||
.normalizeError(result, "saveChanges", "Errors occurred while saving Changes."))); | ||
} | ||
} | ||
}).catch(function (result) { | ||
reject(_this.normalizeError(result, "Unknown error occurred when calling saveChanges.")); | ||
if (_this.jsdo.autoApplyChanges) { | ||
_this.jsdo[_this._tableRef].rejectChanges(); | ||
} | ||
reject(new Error(_this | ||
.normalizeError(result, "saveChanges", "Errors occurred while saving Changes."))); | ||
}); | ||
@@ -293,3 +539,82 @@ }); | ||
}; | ||
DataSource.prototype.normalizeError = function (result, defaultMsg) { | ||
/** | ||
* First, retrieves data from JSDO local memory | ||
* Then makes a copy of it, to ensure jsdo memory is only manipulated thru DataSource API | ||
* Returns array of record objects | ||
* @returns Array<object> | ||
*/ | ||
DataSource.prototype.getJsdoData = function () { | ||
var _this = this; | ||
var jsdo = this.jsdo; | ||
var saveUseRelationships = jsdo.useRelationships; | ||
var data; | ||
var copy; | ||
var array; | ||
jsdo.useRelationships = false; | ||
data = jsdo[this._tableRef].getData(); | ||
jsdo.useRelationships = saveUseRelationships; | ||
// Make copy of jsdo data for datasource | ||
if (this._convertTypes) { | ||
array = []; | ||
data.forEach(function (item) { | ||
if (!_this.useArrays && _this._convertFields._arrayFields.length > 0) { | ||
// Use a reference | ||
// _convertDataTypes() will create the copy for this case | ||
copy = item; | ||
} | ||
else { | ||
copy = Object.assign({}, item); | ||
} | ||
copy = _this._convertDataTypes(copy); | ||
array.push(copy); | ||
}); | ||
data = array; | ||
} | ||
else { | ||
data = (data.length > 0 ? data.map(function (item) { return Object.assign({}, item); }) : []); | ||
} | ||
return data; | ||
}; | ||
/** | ||
* This method is used for fetching the 'count' of records from backend | ||
* This method is used as part of read() operation when serverOperations is set by client | ||
* @param {string} name Name of the method pertaining to 'Count' functionality | ||
* @param {any} object Filter object | ||
*/ | ||
DataSource.prototype.getRecCount = function (name, object) { | ||
var _this = this; | ||
var countVal; | ||
var getRecCountPromise; | ||
getRecCountPromise = new Promise(function (resolve, reject) { | ||
_this.jsdo.invoke(name, object) | ||
.then(function (result) { | ||
try { | ||
if (typeof (result.request.response) === "object" | ||
&& Object.keys(result.request.response).length === 1) { | ||
countVal = Object.values(result.request.response)[0]; | ||
if (typeof (countVal) !== "number") { | ||
countVal = undefined; | ||
} | ||
} | ||
resolve(countVal); | ||
} | ||
catch (e) { | ||
reject(new Error(_this.normalizeError(e, "getRecCount", ""))); | ||
} | ||
}).catch(function (result) { | ||
reject(new Error(_this.normalizeError(result, "Error invoking the 'Count' operation", ""))); | ||
}); | ||
}); | ||
return getRecCountPromise; | ||
}; | ||
/** | ||
* This method is called after an error has occurred on a jsdo operation, and is | ||
* used to get an error message. | ||
* @param {any} result Object containing error info returned after execution of jsdo operation | ||
* @param {string} operation String containing operation performed when error occurred | ||
* @param {string} genericMsg If multiple errors are found in result object, if specified, | ||
* this string will be returned. If not specified, first error string will be returned. | ||
* @returns A single error message | ||
*/ | ||
DataSource.prototype.normalizeError = function (result, operation, genericMsg) { | ||
var errorMsg = ""; | ||
@@ -304,3 +629,9 @@ var lastErrors = null; | ||
if (lastErrors.length >= 1) { | ||
errorMsg = lastErrors[0].error; | ||
// If generic message is provided, use that, else we'll just grab first message | ||
if (lastErrors.length > 1 && genericMsg) { | ||
errorMsg = genericMsg; | ||
} | ||
else { | ||
errorMsg = lastErrors[0].error; | ||
} | ||
} | ||
@@ -311,4 +642,4 @@ } | ||
} | ||
if (errorMsg === "" && defaultMsg) { | ||
errorMsg = defaultMsg; | ||
if (errorMsg === "") { | ||
errorMsg = "Unknown error occurred when calling " + operation + "."; | ||
} | ||
@@ -358,17 +689,25 @@ } | ||
var newEntry = source; | ||
var firstKey; | ||
if (Object.keys(target).length === 0) { | ||
this._copyRecord(source, target); | ||
} | ||
else { | ||
firstKey = Object.keys(target)[0]; | ||
if (firstKey) { | ||
// Dataset usecase | ||
if (firstKey !== this._tableRef) { | ||
target[firstKey][this._tableRef].push(newEntry[firstKey][this._tableRef][0]); | ||
var firstKey = Object.keys(source)[0]; | ||
var secondKey = (firstKey) ? Object.keys(source[firstKey])[0] : undefined; | ||
// Delete's on no submit services return empty datasets so | ||
// don't add anything. | ||
if (typeof source[firstKey] !== "undefined" | ||
&& typeof source[firstKey][secondKey] !== "undefined") { | ||
if (Object.keys(target).length === 0) { | ||
this._copyRecord(source, target); | ||
} | ||
else { | ||
firstKey = Object.keys(target)[0]; | ||
// Delete's on no submit services return empty datasets so | ||
// don't add anything. | ||
if (firstKey && typeof target[firstKey][this._tableRef] !== "undefined") { | ||
// Dataset usecase | ||
if (firstKey !== this._tableRef) { | ||
target[firstKey][this._tableRef].push(newEntry[firstKey][this._tableRef][0]); | ||
} | ||
else { // Temp-table usecase | ||
target[this._tableRef].push(newEntry[this._tableRef][0]); | ||
} | ||
return target; | ||
} | ||
else { | ||
target[this._tableRef].push(newEntry[this._tableRef][0]); | ||
} | ||
return target; | ||
} | ||
@@ -375,0 +714,0 @@ } |
{ | ||
"name": "@progress/jsdo-angular", | ||
"version": "5.0.0-2018-04-03-00001", | ||
"description": "The JSDO DataSource is a TypeScript implementation - Progress DataSource class for NativeScript, Angular and Node.js. This will provide a seamless integration between OpenEdge (Progress Data Object) and Angular.", | ||
"version": "5.0.0", | ||
"description": "The Progress Data Source is a TypeScript implementation - Progress Data Source class for NativeScript, Angular. This will provide a seamless integration between OpenEdge (Progress Data Object) with Angular.", | ||
"main": "lib/progress.data.angular.js", | ||
@@ -18,3 +18,3 @@ "files": [ | ||
"type": "git", | ||
"url": "git+https://github.com/CloudDataObject/JSDO.git" | ||
"url": "git+https://github.com/progress/JSDO.git" | ||
}, | ||
@@ -24,20 +24,19 @@ "keywords": [ | ||
"Progress", | ||
"node", | ||
"angular", | ||
"DataSource", | ||
"DataSource for Node" | ||
"Data Source", | ||
"Data Source for Angular" | ||
], | ||
"author": "Progress Software", | ||
"typings": "typings/progress.data.node.d.ts", | ||
"typings": "typings/progress.data.angular.d.ts", | ||
"license": "Apache-2.0", | ||
"bugs": { | ||
"url": "https://github.com/CloudDataObject/JSDO/issues" | ||
"url": "https://github.com/progress/JSDO/issues" | ||
}, | ||
"homepage": "https://github.com/CloudDataObject/JSDO#readme", | ||
"homepage": "https://github.com/progress/JSDO#readme", | ||
"dependencies": { | ||
"@angular/core": "^5.2.1", | ||
"@progress/jsdo-core": "^5.0.0-2018-04-03-00001", | ||
"@progress/jsdo-core": "^5.0.0", | ||
"base-64": "^0.1.0", | ||
"node-localstorage": "^1.3.1", | ||
"rxjs": "^5.5.6", | ||
"xmlhttprequest": "^1.8.0" | ||
"rxjs": "^5.5.6" | ||
}, | ||
@@ -44,0 +43,0 @@ "peerDependencies": {}, |
@@ -1,3 +0,3 @@ | ||
# DataSource for Angular | ||
The DataSource is a TypeScript implementation - Progress DataSource class for NativeScript, Angular. This will provide a seamless integration between OpenEdge (Progress Data Object) with NativeScript and Angular". | ||
# Progress Data Source for Angular | ||
The Progress Data Source is a TypeScript implementation - Progress Data Source class for NativeScript, Angular. This will provide a seamless integration between OpenEdge (Progress Data Object) with NativeScript and Angular". | ||
@@ -7,3 +7,3 @@ ### Documentation | ||
The DataSource can be used by apps built using NativeScript, Angular and Node. | ||
The Data Source can be used by apps built using NativeScript, Angular and Node. | ||
@@ -10,0 +10,0 @@ ### License |
@@ -10,24 +10,32 @@ import { progress } from "@progress/jsdo-core"; | ||
sort?: any; | ||
top?: any; | ||
skip?: any; | ||
mergeMode?: any; | ||
pageSize?: any; | ||
top?: number; | ||
skip?: number; | ||
mergeMode?: number; | ||
readLocal?: boolean; | ||
countFnName?: string; | ||
} | ||
export interface DataResult { | ||
data: Array<object>; | ||
total: number; | ||
} | ||
export declare class DataSource { | ||
jsdo: progress.data.JSDO; | ||
private _data; | ||
readLocal: boolean; | ||
_skipRec: number; | ||
_isLastResultSetEmpty: boolean; | ||
private _options; | ||
private _tableRef; | ||
_skipRec: number; | ||
private _initFromServer; | ||
constructor(options: DataSourceOptions); | ||
/** | ||
* Calls the jsdo.fill() retrieving data from the backend service | ||
* @returns Observable<Array<object>> | ||
* @returns An Observable which includes an Array<Object> followed | ||
* by an attribute for specifying 'total' records | ||
*/ | ||
read(params?: progress.data.FilterOptions): Observable<Array<object>>; | ||
read(params?: progress.data.FilterOptions): Observable<DataResult>; | ||
/** | ||
* Returns array of record objects from JSDO local memory | ||
* @returns {object} | ||
* Returns array of record objects from local memory | ||
* @returns Array<object> | ||
*/ | ||
getData(): Observable<Array<object>>; | ||
getData(): Array<object>; | ||
/** | ||
@@ -62,12 +70,2 @@ * Calls the jsdo.add() method, creating a new record in JSDO memory | ||
/** | ||
* Accepts any pending changes in the data source. This results in the removal of the | ||
* before-image data. It also clears out any error messages. | ||
*/ | ||
acceptChanges(): void; | ||
/** | ||
* Cancels any pending changes in the data source. Deleted rows are restored, | ||
* new rows are removed and updated rows are restored to their initial state. | ||
*/ | ||
cancelChanges(): void; | ||
/** | ||
* Returns true if the underlying jsdo has CUD support (create, update, delete operations). | ||
@@ -85,9 +83,31 @@ * If not, it returns false. | ||
* JSDO memory for the current Data Object resource | ||
* @param {boolean} useSubmit Optional parameter. By default points to 'false' where all | ||
* record modifications are sent to server individually. When 'true' is used all record | ||
* modifications are batched together and are sent in single transaction | ||
* @returns {object} Promise | ||
* If jsdo.hasSubmitOperation is false, all record modifications are sent to server individually. | ||
* When 'true', modifications are batched together and sent in single request | ||
* @returns {object} Observable | ||
*/ | ||
saveChanges(): Observable<Array<object>>; | ||
private normalizeError(result, defaultMsg); | ||
/** | ||
* First, retrieves data from JSDO local memory | ||
* Then makes a copy of it, to ensure jsdo memory is only manipulated thru Data Source API | ||
* Returns array of record objects | ||
* @returns Array<object> | ||
*/ | ||
private getJsdoData(); | ||
/** | ||
* This method is used for fetching the 'count' of records from backend | ||
* This method is used as part of read() operation when serverOperations is set by client | ||
* @param {string} name Name of the method pertaining to 'Count' functionality | ||
* @param {any} object Filter object | ||
*/ | ||
private getRecCount(name, object); | ||
/** | ||
* This method is called after an error has occurred on a jsdo operation, and is | ||
* used to get an error message. | ||
* @param {any} result Object containing error info returned after execution of jsdo operation | ||
* @param {string} operation String containing operation performed when error occurred | ||
* @param {string} genericMsg If multiple errors are found in result object, if specified, | ||
* this string will be returned. If not specified, first error string will be returned. | ||
* @returns A single error message | ||
*/ | ||
private normalizeError(result, operation, genericMsg); | ||
private _copyRecord(source, target); | ||
@@ -94,0 +114,0 @@ /** |
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
49484
4
814
1
- Removednode-localstorage@^1.3.1
- Removedxmlhttprequest@^1.8.0
- Removedgraceful-fs@4.2.11(transitive)
- Removedimurmurhash@0.1.4(transitive)
- Removednode-localstorage@1.3.1(transitive)
- Removedslide@1.1.6(transitive)
- Removedwrite-file-atomic@1.3.4(transitive)
- Removedxmlhttprequest@1.8.0(transitive)
Updated@progress/jsdo-core@^5.0.0