@adobe/acc-js-sdk 1.0.9 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +27 -0
- package/MIGRATION.md +160 -0
- package/README.md +149 -15
- package/package-lock.json +2 -2
- package/package.json +1 -1
- package/src/application.js +347 -141
- package/src/client.js +77 -60
- package/src/index.js +1 -1
- package/src/soap.js +5 -2
- package/src/util.js +144 -0
- package/src/xtkCaster.js +17 -2
- package/test/application.test.js +1492 -117
- package/test/client.test.js +55 -3
- package/test/soap.test.js +53 -2
- package/test/util.test.js +167 -1
package/src/client.js
CHANGED
|
@@ -96,65 +96,77 @@ const xtkObjectHandler = {
|
|
|
96
96
|
* <code>
|
|
97
97
|
* result = await client.NLWS.xtkSession.getServerTime();
|
|
98
98
|
* </code>
|
|
99
|
+
*
|
|
100
|
+
* To get a handler, call the `clientHandler` function and optionally pass a representation.
|
|
101
|
+
* If no representation is passed (undefined), the representation set at the client level
|
|
102
|
+
* will be used, which is the default behavior.
|
|
103
|
+
* To get a proxy with a specific representation, use NLWS.xml or NMWS.json
|
|
99
104
|
*
|
|
100
105
|
* @private
|
|
101
106
|
* @memberof Campaign
|
|
102
107
|
*/
|
|
103
|
-
const clientHandler = {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
if (
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
const methodNameLC = methodName.toLowerCase();
|
|
125
|
-
methodName = methodName.substr(0, 1).toUpperCase() + methodName.substr(1);
|
|
126
|
-
if (namespace == "xtkSession" && methodNameLC == "logon")
|
|
127
|
-
return callContext.client.logon(argumentsList[0]);
|
|
128
|
-
else if (namespace == "xtkSession" && methodNameLC == "logoff")
|
|
129
|
-
return callContext.client.logoff();
|
|
130
|
-
else if (namespace == "xtkSession" && methodNameLC == "getoption") {
|
|
131
|
-
var promise = callContext.client._callMethod(methodName, callContext, argumentsList);
|
|
132
|
-
return promise.then(function(optionAndValue) {
|
|
133
|
-
const optionName = argumentsList[0];
|
|
134
|
-
client._optionCache.put(optionName, optionAndValue);
|
|
135
|
-
return optionAndValue;
|
|
136
|
-
});
|
|
108
|
+
const clientHandler = (representation) => {
|
|
109
|
+
return {
|
|
110
|
+
get: function(client, namespace) {
|
|
111
|
+
// Force XML or JSON representation (NLWS.xml or NLWS.json)
|
|
112
|
+
if (namespace == "xml") return new Proxy(client, clientHandler("xml"));
|
|
113
|
+
if (namespace == "json") return new Proxy(client, clientHandler("SimpleJson"));
|
|
114
|
+
|
|
115
|
+
return new Proxy({ client:client, namespace:namespace}, {
|
|
116
|
+
get: function(callContext, methodName) {
|
|
117
|
+
callContext.representation = representation;
|
|
118
|
+
if (methodName == ".") return callContext;
|
|
119
|
+
|
|
120
|
+
// get Schema id from namespace (find first upper case letter)
|
|
121
|
+
var schemaId = "";
|
|
122
|
+
for (var i=0; i<namespace.length; i++) {
|
|
123
|
+
const c = namespace[i];
|
|
124
|
+
if (c >='A' && c<='Z') {
|
|
125
|
+
schemaId = schemaId + ":" + c.toLowerCase() + namespace.substr(i+1);
|
|
126
|
+
break;
|
|
127
|
+
}
|
|
128
|
+
schemaId = schemaId + c;
|
|
137
129
|
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
130
|
+
callContext.schemaId = schemaId;
|
|
131
|
+
|
|
132
|
+
const caller = function(thisArg, argumentsList) {
|
|
133
|
+
const callContext = thisArg["."];
|
|
134
|
+
const namespace = callContext.namespace;
|
|
135
|
+
const methodNameLC = methodName.toLowerCase();
|
|
136
|
+
methodName = methodName.substr(0, 1).toUpperCase() + methodName.substr(1);
|
|
137
|
+
if (namespace == "xtkSession" && methodNameLC == "logon")
|
|
138
|
+
return callContext.client.logon(argumentsList[0]);
|
|
139
|
+
else if (namespace == "xtkSession" && methodNameLC == "logoff")
|
|
140
|
+
return callContext.client.logoff();
|
|
141
|
+
else if (namespace == "xtkSession" && methodNameLC == "getoption") {
|
|
142
|
+
var promise = callContext.client._callMethod(methodName, callContext, argumentsList);
|
|
143
|
+
return promise.then(function(optionAndValue) {
|
|
144
|
+
const optionName = argumentsList[0];
|
|
145
|
+
client._optionCache.put(optionName, optionAndValue);
|
|
146
|
+
return optionAndValue;
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
// static method
|
|
150
|
+
var result = callContext.client._callMethod(methodName, callContext, argumentsList);
|
|
151
|
+
return result;
|
|
147
152
|
};
|
|
148
|
-
}
|
|
149
153
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
154
|
+
if (methodName == "create") {
|
|
155
|
+
return function(body) {
|
|
156
|
+
callContext.object = body;
|
|
157
|
+
return new Proxy(callContext, xtkObjectHandler);
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
return new Proxy(caller, {
|
|
162
|
+
apply: function(target, thisArg, argumentsList) {
|
|
163
|
+
return target(thisArg, argumentsList);
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
};
|
|
158
170
|
};
|
|
159
171
|
|
|
160
172
|
// ========================================================================================
|
|
@@ -234,6 +246,8 @@ class Credentials {
|
|
|
234
246
|
* @property {Utils.Transport} transport - Overrides the transport (i.e. HTTP layer)
|
|
235
247
|
* @property {boolean} noStorage - De-activate using of local storage. By default, and in addition to in-memory cache, entities, methods, and options are also persisted in local storage if there is one.
|
|
236
248
|
* @property {Storage} storage - Overrides the storage interface (i.e. LocalStorage)
|
|
249
|
+
* @property {function} refreshClient - An async callback function with the SDK client as parameter, which will be called when the ACC session is expired
|
|
250
|
+
* @property {string} charset - The charset encoding used for http requests. Defaults to UTF-8 since SDK version 1.1.1
|
|
237
251
|
* @memberOf Campaign
|
|
238
252
|
*/
|
|
239
253
|
|
|
@@ -297,6 +311,7 @@ class ConnectionParameters {
|
|
|
297
311
|
}
|
|
298
312
|
this._options._storage = storage;
|
|
299
313
|
this._options.refreshClient = options.refreshClient;
|
|
314
|
+
this._options.charset = options.charset === undefined ? "UTF-8": options.charset;
|
|
300
315
|
}
|
|
301
316
|
|
|
302
317
|
/**
|
|
@@ -474,7 +489,7 @@ class Client {
|
|
|
474
489
|
this._entityCache = new XtkEntityCache(this._storage, `${rootKey}.XtkEntityCache`, connectionParameters._options.entityCacheTTL);
|
|
475
490
|
this._methodCache = new MethodCache(this._storage, `${rootKey}.MethodCache`, connectionParameters._options.methodCacheTTL);
|
|
476
491
|
this._optionCache = new OptionCache(this._storage, `${rootKey}.OptionCache`, connectionParameters._options.optionCacheTTL);
|
|
477
|
-
this.NLWS = new Proxy(this, clientHandler);
|
|
492
|
+
this.NLWS = new Proxy(this, clientHandler());
|
|
478
493
|
|
|
479
494
|
this._transport = connectionParameters._options.transport;
|
|
480
495
|
this._traceAPICalls = connectionParameters._options.traceAPICalls;
|
|
@@ -673,7 +688,9 @@ class Client {
|
|
|
673
688
|
* parameters should be set
|
|
674
689
|
*/
|
|
675
690
|
_prepareSoapCall(urn, method, internal) {
|
|
676
|
-
const soapCall = new SoapMethodCall(this._transport, urn, method,
|
|
691
|
+
const soapCall = new SoapMethodCall(this._transport, urn, method,
|
|
692
|
+
this._sessionToken, this._securityToken,
|
|
693
|
+
this._getUserAgentString(), this._connectionParameters._options.charset);
|
|
677
694
|
soapCall.internal = !!internal;
|
|
678
695
|
return soapCall;
|
|
679
696
|
}
|
|
@@ -1117,7 +1134,7 @@ class Client {
|
|
|
1117
1134
|
throw CampaignException.SOAP_UNKNOWN_METHOD(schemaId, methodName, `Cannot call non-static method '${methodName}' of schema '${schemaId}' : no object was specified`);
|
|
1118
1135
|
|
|
1119
1136
|
const rootName = schemaId.substr(schemaId.indexOf(':') + 1);
|
|
1120
|
-
object = that._fromRepresentation(rootName, object);
|
|
1137
|
+
object = that._fromRepresentation(rootName, object, callContext.representation);
|
|
1121
1138
|
soapCall.writeDocument("document", object);
|
|
1122
1139
|
}
|
|
1123
1140
|
|
|
@@ -1165,7 +1182,7 @@ class Client {
|
|
|
1165
1182
|
const index = xtkschema.indexOf(":");
|
|
1166
1183
|
docName = xtkschema.substr(index+1);
|
|
1167
1184
|
}
|
|
1168
|
-
var xmlValue = that._fromRepresentation(docName, paramValue);
|
|
1185
|
+
var xmlValue = that._fromRepresentation(docName, paramValue, callContext.representation);
|
|
1169
1186
|
if (type == "DOMDocument")
|
|
1170
1187
|
soapCall.writeDocument(paramName, xmlValue);
|
|
1171
1188
|
else
|
|
@@ -1184,7 +1201,7 @@ class Client {
|
|
|
1184
1201
|
// the method is called. This is the new version of the object (in XML form)
|
|
1185
1202
|
const entity = soapCall.getEntity();
|
|
1186
1203
|
if (entity) {
|
|
1187
|
-
callContext.object = that._toRepresentation(entity);
|
|
1204
|
+
callContext.object = that._toRepresentation(entity, callContext.representation);
|
|
1188
1205
|
}
|
|
1189
1206
|
}
|
|
1190
1207
|
|
|
@@ -1215,7 +1232,7 @@ class Client {
|
|
|
1215
1232
|
returnValue = soapCall.getNextDate();
|
|
1216
1233
|
else if (type == "DOMDocument") {
|
|
1217
1234
|
returnValue = soapCall.getNextDocument();
|
|
1218
|
-
returnValue = that._toRepresentation(returnValue);
|
|
1235
|
+
returnValue = that._toRepresentation(returnValue, callContext.representation);
|
|
1219
1236
|
if (schemaId === "xtk:queryDef" && methodName === "ExecuteQuery" && paramName === "output") {
|
|
1220
1237
|
// https://github.com/adobe/acc-js-sdk/issues/3
|
|
1221
1238
|
// Check if query operation is "getIfExists". The "object" variable at this point
|
|
@@ -1235,7 +1252,7 @@ class Client {
|
|
|
1235
1252
|
}
|
|
1236
1253
|
else if (type == "DOMElement") {
|
|
1237
1254
|
returnValue = soapCall.getNextElement();
|
|
1238
|
-
returnValue = that._toRepresentation(returnValue);
|
|
1255
|
+
returnValue = that._toRepresentation(returnValue, callContext.representation);
|
|
1239
1256
|
}
|
|
1240
1257
|
else {
|
|
1241
1258
|
// type can reference a schema element. The naming convension is that the type name
|
|
@@ -1249,7 +1266,7 @@ class Client {
|
|
|
1249
1266
|
if (element.getAttribute("name") == shortTypeName) {
|
|
1250
1267
|
// Type found in schema: Process as a DOM element
|
|
1251
1268
|
returnValue = soapCall.getNextElement();
|
|
1252
|
-
returnValue = that._toRepresentation(returnValue);
|
|
1269
|
+
returnValue = that._toRepresentation(returnValue, callContext.representation);
|
|
1253
1270
|
break;
|
|
1254
1271
|
}
|
|
1255
1272
|
element = DomUtil.getNextSiblingElement(element, "element");
|
package/src/index.js
CHANGED
|
@@ -191,7 +191,7 @@ class SDK {
|
|
|
191
191
|
* Convert a javascript value into an xtk constant with proper quoting
|
|
192
192
|
* @param {any} value the value to convert
|
|
193
193
|
* @param {string} type the xtk type
|
|
194
|
-
* @returns
|
|
194
|
+
* @returns {string} the text literal which can be used in a Xtk expression or condition
|
|
195
195
|
*/
|
|
196
196
|
xtkConstText(value, type) {
|
|
197
197
|
if (!type || type === 'string' || type === 'memo') {
|
package/src/soap.js
CHANGED
|
@@ -78,11 +78,12 @@ const NS_XSD = "http://www.w3.org/2001/XMLSchema";
|
|
|
78
78
|
* @param {string} sessionToken Campaign session token
|
|
79
79
|
* @param {string} securityToken Campaign security token
|
|
80
80
|
* @param {string} userAgentString The user agent string to use for HTTP requests
|
|
81
|
+
* @param {string} charset The charset encoding used for http requests, usually UTF-8
|
|
81
82
|
* @memberof SOAP
|
|
82
83
|
*/
|
|
83
84
|
class SoapMethodCall {
|
|
84
85
|
|
|
85
|
-
constructor(transport, urn, methodName, sessionToken, securityToken, userAgentString) {
|
|
86
|
+
constructor(transport, urn, methodName, sessionToken, securityToken, userAgentString, charset) {
|
|
86
87
|
this.request = undefined; // The HTTP request (object litteral passed to the transport layer)
|
|
87
88
|
this.response = undefined; // The HTTP response object (in case of success)
|
|
88
89
|
|
|
@@ -99,6 +100,7 @@ class SoapMethodCall {
|
|
|
99
100
|
this._sessionToken = sessionToken || "";
|
|
100
101
|
this._securityToken = securityToken || "";
|
|
101
102
|
this._userAgentString = userAgentString;
|
|
103
|
+
this._charset = charset || "";
|
|
102
104
|
|
|
103
105
|
// THe SOAP call being built
|
|
104
106
|
this._doc = undefined; // XML document for SOAP call
|
|
@@ -512,11 +514,12 @@ class SoapMethodCall {
|
|
|
512
514
|
* @returns {Object} an options object describing the HTTP request, with cookies, headers and body
|
|
513
515
|
*/
|
|
514
516
|
_createHTTPRequest(url) {
|
|
517
|
+
|
|
515
518
|
const options = {
|
|
516
519
|
url: url,
|
|
517
520
|
method: 'POST',
|
|
518
521
|
headers: {
|
|
519
|
-
'Content-type':
|
|
522
|
+
'Content-type': `application/soap+xml${this._charset ? ";charset=" + this._charset : ""}`,
|
|
520
523
|
'SoapAction': `${this.urn}#${this.methodName}`,
|
|
521
524
|
'X-Security-Token': this._securityToken
|
|
522
525
|
},
|
package/src/util.js
CHANGED
|
@@ -135,7 +135,151 @@ class Util {
|
|
|
135
135
|
}
|
|
136
136
|
}
|
|
137
137
|
|
|
138
|
+
/**
|
|
139
|
+
* The ArrayMap object is used to access elements as either an array or a map
|
|
140
|
+
*
|
|
141
|
+
* @class
|
|
142
|
+
* @constructor
|
|
143
|
+
* @memberof Utils
|
|
144
|
+
*/
|
|
145
|
+
|
|
146
|
+
class ArrayMap {
|
|
147
|
+
constructor() {
|
|
148
|
+
// List of items, as an ordered array. Use defineProperty to make it non-enumerable
|
|
149
|
+
// and support for for ... in loop to iterate by item key
|
|
150
|
+
Object.defineProperty(this, "_items", {
|
|
151
|
+
value: [],
|
|
152
|
+
writable: false,
|
|
153
|
+
enumerable: false,
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
Object.defineProperty(this, "_map", {
|
|
157
|
+
value: [],
|
|
158
|
+
writable: false,
|
|
159
|
+
enumerable: false,
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
// Number of items. Use defineProperty to make it non-enumerable
|
|
163
|
+
// and support for for ... in loop to iterate by item key
|
|
164
|
+
Object.defineProperty(this, "length", {
|
|
165
|
+
value: 0,
|
|
166
|
+
writable: true,
|
|
167
|
+
enumerable: false,
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
_push(key, value) {
|
|
172
|
+
let isNumKey = false;
|
|
173
|
+
if (key) {
|
|
174
|
+
// reserved keyworkds
|
|
175
|
+
const isReserved = key === "_items" || key === "length" || key === "_push" || key === "forEach" || key === "map" || key === "_map" || key === "get" || key === "find" || key === "flatMap" || key === "filter";
|
|
176
|
+
|
|
177
|
+
// already a child with the name => there's a problem with the schema
|
|
178
|
+
if (!isReserved && this[key]) throw new Error(`Failed to add element '${key}' to ArrayMap. There's already an item with the same name`);
|
|
179
|
+
|
|
180
|
+
// Set key as a enumerable property, so that elements can be accessed by key,
|
|
181
|
+
// but also iterated on with a for ... in loop
|
|
182
|
+
// For compatibility
|
|
183
|
+
if (!isReserved) this[key] = value;
|
|
184
|
+
this._map[key] = value;
|
|
185
|
+
|
|
186
|
+
// Special case where keys are numbers or strings convertible with numbers
|
|
187
|
+
const numKey = +key;
|
|
188
|
+
if (numKey === numKey) {
|
|
189
|
+
// keys is a number. If it matches the current index, then we are good,
|
|
190
|
+
// and we can add the property as an enumerable property
|
|
191
|
+
isNumKey = true;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
if (!isNumKey) {
|
|
196
|
+
// Set the index property so that items can be accessed by array index.
|
|
197
|
+
// However, make it non-enumerable to make sure indexes do not show up in a for .. in loop
|
|
198
|
+
Object.defineProperty(this, this._items.length, {
|
|
199
|
+
value: value,
|
|
200
|
+
writable: false,
|
|
201
|
+
enumerable: false,
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
// Add to array and set length
|
|
205
|
+
this._items.push(value);
|
|
206
|
+
this.length = this._items.length;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* Executes a provided function once for each array element.
|
|
211
|
+
* @param {*} callback Function that is called for every element of the array
|
|
212
|
+
* @param {*} thisArg Optional value to use as this when executing the callback function.
|
|
213
|
+
* @returns a new array
|
|
214
|
+
*/
|
|
215
|
+
forEach(callback, thisArg) {
|
|
216
|
+
return this._items.forEach(callback, thisArg);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* Returns the first element that satisfies the provided testing function. If no values satisfy the testing function, undefined is returned.
|
|
221
|
+
* @param {*} callback Function that is called for every element of the array
|
|
222
|
+
* @param {*} thisArg Optional value to use as this when executing the callback function.
|
|
223
|
+
* @returns the first element matching the testing function
|
|
224
|
+
*/
|
|
225
|
+
find(callback, thisArg) {
|
|
226
|
+
return this._items.find(callback, thisArg);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* creates a new array with all elements that pass the test implemented by the provided function.
|
|
231
|
+
* @param {*} callback Function that is called for every element of the array
|
|
232
|
+
* @param {*} thisArg Optional value to use as this when executing the callback function.
|
|
233
|
+
* @returns an array containing elements passing the test function
|
|
234
|
+
*/
|
|
235
|
+
filter(callback, thisArg) {
|
|
236
|
+
return this._items.filter(callback, thisArg);
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* Get a element by either name (access as a map) or index (access as an array). Returns undefined if the element does not exist or
|
|
241
|
+
* if the array index is out of range.
|
|
242
|
+
* @param {string|number} indexOrKey the name or index of the element
|
|
243
|
+
* @returns the element matching the name or index
|
|
244
|
+
*/
|
|
245
|
+
get(indexOrKey) {
|
|
246
|
+
if (typeof indexOrKey === 'number') return this._items[indexOrKey];
|
|
247
|
+
return this._map[indexOrKey];
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* Creates a new array populated with the results of calling a provided function on every element in the calling array.
|
|
252
|
+
* @param {*} callback Function that is called for every element of the array
|
|
253
|
+
* @param {*} thisArg Optional value to use as this when executing the callback function.
|
|
254
|
+
* @returns a new array
|
|
255
|
+
*/
|
|
256
|
+
map(callback, thisArg) {
|
|
257
|
+
return this._items.map(callback, thisArg);
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* Returns a new array formed by applying a given callback function to each element of the array, and then flattening the result by one level.
|
|
262
|
+
* @param {*} callback Function that is called for every element of the array
|
|
263
|
+
* @param {*} thisArg Optional value to use as this when executing the callback function.
|
|
264
|
+
* @returns a new array
|
|
265
|
+
*/
|
|
266
|
+
flatMap(callback, thisArg) {
|
|
267
|
+
return this._items.flatMap(callback, thisArg);
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* Iterates over all the elements using the for ... of syntax.
|
|
272
|
+
* @returns returns each element one after the other
|
|
273
|
+
*/
|
|
274
|
+
*[Symbol.iterator] () {
|
|
275
|
+
for (const item of this._items) {
|
|
276
|
+
yield item;
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
|
|
138
281
|
// Public expots
|
|
139
282
|
exports.Util = Util;
|
|
283
|
+
exports.ArrayMap = ArrayMap;
|
|
140
284
|
|
|
141
285
|
})();
|
package/src/xtkCaster.js
CHANGED
|
@@ -431,15 +431,30 @@ class XtkCaster {
|
|
|
431
431
|
return timespan;
|
|
432
432
|
}
|
|
433
433
|
|
|
434
|
+
/**
|
|
435
|
+
* Tests if a given type is a date or time type
|
|
436
|
+
* @param {string|number} type the type name
|
|
437
|
+
* @returns {boolean} true if the type is a date and/or time type
|
|
438
|
+
*/
|
|
434
439
|
static isTimeType(type) {
|
|
435
440
|
return type === "datetime" || type === "datetimetz" || type === "datetimenotz" || type === "timestamp" || type === "date" || type === "time" || type === "timespan" || type === 7 || type === 10 || type === 14;
|
|
436
441
|
}
|
|
437
442
|
|
|
438
|
-
|
|
443
|
+
/**
|
|
444
|
+
* Tests if a given type is a string type
|
|
445
|
+
* @param {string|number} type the type name
|
|
446
|
+
* @returns {boolean} true if the type is a string type
|
|
447
|
+
*/
|
|
448
|
+
static isStringType(type) {
|
|
439
449
|
return type === "string" || type === "memo" || type === 6 || type === 12 || type === 13 || type === "blob" || type === "html" || type === "CDATA";
|
|
440
450
|
}
|
|
441
451
|
|
|
442
|
-
|
|
452
|
+
/**
|
|
453
|
+
* Tests if a given type is a numeric type
|
|
454
|
+
* @param {string|number} type the type name
|
|
455
|
+
* @returns {boolean} true if the type is a numeric type
|
|
456
|
+
*/
|
|
457
|
+
static isNumericType(type) {
|
|
443
458
|
return type === "byte" || type === 1 || type === "short" || type === 2 || type === "int" || type === "long" || type === 3 || type === "float" || type === 4 || type === "double" || type === 5 || type === "timespan" || type === 14;
|
|
444
459
|
}
|
|
445
460
|
}
|