@adobe/acc-js-sdk 1.1.62 → 1.2.0

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.
Files changed (61) hide show
  1. package/.cursor/commands/opsx-apply.md +152 -0
  2. package/.cursor/commands/opsx-archive.md +157 -0
  3. package/.cursor/commands/opsx-explore.md +173 -0
  4. package/.cursor/commands/opsx-propose.md +106 -0
  5. package/.cursor/skills/openspec-apply-change/SKILL.md +156 -0
  6. package/.cursor/skills/openspec-archive-change/SKILL.md +114 -0
  7. package/.cursor/skills/openspec-explore/SKILL.md +288 -0
  8. package/.cursor/skills/openspec-propose/SKILL.md +110 -0
  9. package/.eslintrc.js +2 -2
  10. package/.github/prompts/opsx-apply.prompt.md +149 -0
  11. package/.github/prompts/opsx-archive.prompt.md +154 -0
  12. package/.github/prompts/opsx-explore.prompt.md +170 -0
  13. package/.github/prompts/opsx-propose.prompt.md +103 -0
  14. package/.github/skills/openspec-apply-change/SKILL.md +156 -0
  15. package/.github/skills/openspec-archive-change/SKILL.md +114 -0
  16. package/.github/skills/openspec-explore/SKILL.md +288 -0
  17. package/.github/skills/openspec-propose/SKILL.md +110 -0
  18. package/.github/workflows/codeql-analysis.yml +5 -4
  19. package/.github/workflows/npm-publish.yml +3 -3
  20. package/AGENTS.md +117 -0
  21. package/CLAUDE.md +2 -0
  22. package/MIGRATION.md +10 -0
  23. package/README.md +6 -2
  24. package/ai-docs/coding-rules.md +95 -0
  25. package/ai-docs/tech-stack.md +43 -0
  26. package/babel.config.js +5 -0
  27. package/docs/changeLog.html +28 -2
  28. package/docs/checkList.html +2 -2
  29. package/docs/quickstart.html +2 -1
  30. package/docs/release.html +1 -1
  31. package/openspec/config.yaml +20 -0
  32. package/package-lock.json +6055 -4036
  33. package/package.json +9 -7
  34. package/src/AGENTS.md +98 -0
  35. package/src/CLAUDE.md +2 -0
  36. package/src/application.js +637 -637
  37. package/src/cache.js +133 -133
  38. package/src/cacheRefresher.js +190 -190
  39. package/src/campaign.js +532 -532
  40. package/src/client.js +1539 -1537
  41. package/src/crypto.js +52 -52
  42. package/src/domUtil.js +346 -346
  43. package/src/entityAccessor.js +61 -61
  44. package/src/index.js +83 -83
  45. package/src/methodCache.js +69 -69
  46. package/src/optionCache.js +26 -26
  47. package/src/soap.js +321 -322
  48. package/src/testUtil.js +13 -13
  49. package/src/transport.js +70 -70
  50. package/src/util.js +147 -147
  51. package/src/web/bundler.js +5 -5
  52. package/src/xtkCaster.js +258 -258
  53. package/src/xtkEntityCache.js +34 -34
  54. package/src/xtkJob.js +185 -185
  55. package/test/AGENTS.md +37 -0
  56. package/test/CLAUDE.md +2 -0
  57. package/test/cacheRefresher.test.js +7 -0
  58. package/test/client.test.js +90 -78
  59. package/test/jest.config.js +6 -0
  60. package/test/observability.test.js +6 -1
  61. package/test/xtkJob.test.js +2 -2
package/src/xtkCaster.js CHANGED
@@ -10,22 +10,22 @@ OF ANY KIND, either express or implied. See the License for the specific languag
10
10
  governing permissions and limitations under the License.
11
11
  */
12
12
  (function() {
13
- "use strict";
13
+ "use strict";
14
14
 
15
- const { Util } = require('./util.js');
15
+ const { Util } = require('./util.js');
16
16
 
17
- /**********************************************************************************
17
+ /**********************************************************************************
18
18
  *
19
19
  * Helper class to cast values to and from their Xtk versions
20
20
  *
21
21
  *********************************************************************************/
22
- const { CampaignException } = require('./campaign.js');
22
+ const { CampaignException } = require('./campaign.js');
23
23
 
24
- /**
24
+ /**
25
25
  * @namespace Campaign
26
26
  */
27
27
 
28
- /**
28
+ /**
29
29
  * Campaign XTK types
30
30
  *
31
31
  *
@@ -64,12 +64,12 @@ const { Util } = require('./util.js');
64
64
  * @memberof Campaign
65
65
  */
66
66
 
67
- /**
67
+ /**
68
68
  * @memberof Campaign
69
69
  * @class
70
70
  * @constructor
71
71
  */
72
- class XtkCaster {
72
+ class XtkCaster {
73
73
 
74
74
  /**
75
75
  * Helpers to convert between JavaScript data types and Campaign XTK data types
@@ -86,51 +86,51 @@ class XtkCaster {
86
86
  */
87
87
  // See "variant" element in xtk:common srcSchema
88
88
  static _variantStorageAttribute(type) {
89
- if (type === null || type === undefined) return null;
90
- switch(type) {
91
- case 0: // FIELD_NONE
92
- case "":
93
- return null;
94
- case 6: // FIELD_SZ
95
- case "string":
96
- case "uuid":
97
- case "int64":
98
- case "primarykey":
99
- return "stringValue";
100
- case 12: // FIELD_MEMO
101
- case 13: // FIELD_MEMOSHORT
102
- case "blob":
103
- case "html":
104
- case "memo":
105
- case "CDATA":
106
- return "memoValue";
107
- case 1: // FIELD_BYTE
108
- case "byte":
109
- case 2: // FIELD_SHORT
110
- case "short":
111
- case 3: // FIELD_LONG
112
- case "int":
113
- case "long":
114
- case "timespan":
115
- case 15: // FIELD_BOOLEAN
116
- case "boolean":
117
- return "longValue";
118
- case 4: // FIELD_FLOAT
119
- case 5: // FIELD_DOUBLE
120
- case "float":
121
- case "double":
122
- return "doubleValue";
123
- case 7: // FIELD_DATETIME
124
- case "datetime":
125
- case "datetimetz":
126
- case "datetimenotz":
127
- case 10: // FIELD_DATE
128
- case "date":
129
- return "timeStampValue";
130
- default: {
131
- throw CampaignException.BAD_PARAMETER("type", type, `Cannot get variant storage attribute name for type '${type}'`);
132
- }
133
- }
89
+ if (type === null || type === undefined) return null;
90
+ switch(type) {
91
+ case 0: // FIELD_NONE
92
+ case "":
93
+ return null;
94
+ case 6: // FIELD_SZ
95
+ case "string":
96
+ case "uuid":
97
+ case "int64":
98
+ case "primarykey":
99
+ return "stringValue";
100
+ case 12: // FIELD_MEMO
101
+ case 13: // FIELD_MEMOSHORT
102
+ case "blob":
103
+ case "html":
104
+ case "memo":
105
+ case "CDATA":
106
+ return "memoValue";
107
+ case 1: // FIELD_BYTE
108
+ case "byte":
109
+ case 2: // FIELD_SHORT
110
+ case "short":
111
+ case 3: // FIELD_LONG
112
+ case "int":
113
+ case "long":
114
+ case "timespan":
115
+ case 15: // FIELD_BOOLEAN
116
+ case "boolean":
117
+ return "longValue";
118
+ case 4: // FIELD_FLOAT
119
+ case 5: // FIELD_DOUBLE
120
+ case "float":
121
+ case "double":
122
+ return "doubleValue";
123
+ case 7: // FIELD_DATETIME
124
+ case "datetime":
125
+ case "datetimetz":
126
+ case "datetimenotz":
127
+ case 10: // FIELD_DATE
128
+ case "date":
129
+ return "timeStampValue";
130
+ default: {
131
+ throw CampaignException.BAD_PARAMETER("type", type, `Cannot get variant storage attribute name for type '${type}'`);
132
+ }
133
+ }
134
134
  }
135
135
 
136
136
  /**
@@ -141,72 +141,72 @@ class XtkCaster {
141
141
  * @returns {*} the value casted to the requested type, following XTK rules
142
142
  */
143
143
  static as(value, type) {
144
- switch(type) {
145
- case 0: // FIELD_NONE
146
- case "": {
147
- return value;
148
- }
149
- case 6: // FIELD_SZ
150
- case 12: // FIELD_MEMO
151
- case 13: // FIELD_MEMOSHORT
152
- case "string":
153
- case "memo":
154
- case "uuid":
155
- case "blob":
156
- case "html":
157
- case "CDATA": {
158
- return this.asString(value);
159
- }
160
- case 1: // FIELD_BYTE
161
- case "byte": {
162
- return this.asByte(value);
163
- }
164
- case 2: // FIELD_SHORT
165
- case "short": {
166
- return this.asShort(value);
167
- }
168
- case 3: // FIELD_LONG
169
- case "int":
170
- case "long": {
171
- return this.asLong(value);
172
- }
173
- case "int64": {
174
- return this.asInt64(value);
175
- }
176
- case 4: // FIELD_FLOAT
177
- case 5: // FIELD_DOUBLE
178
- case "float":
179
- case "double": {
180
- return this.asNumber(value);
181
- }
182
- case 15: // FIELD_BOOLEAN
183
- case "boolean": {
184
- return this.asBoolean(value);
185
- }
186
- case 7: // FIELD_DATETIME
187
- case "datetime":
188
- case "datetimetz":
189
- case "datetimenotz": {
190
- return this.asTimestamp(value);
191
- }
192
- case 10: // FIELD_DATE
193
- case "date": {
194
- return this.asDate(value);
195
- }
196
- case "array": {
197
- return this.asArray(value);
198
- }
199
- case 14: // FIELD_TIMESPAN
200
- case "timespan": {
201
- return this.asTimespan(value);
202
- }
203
- case "primarykey": {
204
- return this.asPrimaryKey(value);
205
- }
206
- default: {
207
- throw CampaignException.BAD_PARAMETER("type", type, `Cannot convert value type='${type}', value='${value}'`);
208
- }
209
- }
144
+ switch(type) {
145
+ case 0: // FIELD_NONE
146
+ case "": {
147
+ return value;
148
+ }
149
+ case 6: // FIELD_SZ
150
+ case 12: // FIELD_MEMO
151
+ case 13: // FIELD_MEMOSHORT
152
+ case "string":
153
+ case "memo":
154
+ case "uuid":
155
+ case "blob":
156
+ case "html":
157
+ case "CDATA": {
158
+ return this.asString(value);
159
+ }
160
+ case 1: // FIELD_BYTE
161
+ case "byte": {
162
+ return this.asByte(value);
163
+ }
164
+ case 2: // FIELD_SHORT
165
+ case "short": {
166
+ return this.asShort(value);
167
+ }
168
+ case 3: // FIELD_LONG
169
+ case "int":
170
+ case "long": {
171
+ return this.asLong(value);
172
+ }
173
+ case "int64": {
174
+ return this.asInt64(value);
175
+ }
176
+ case 4: // FIELD_FLOAT
177
+ case 5: // FIELD_DOUBLE
178
+ case "float":
179
+ case "double": {
180
+ return this.asNumber(value);
181
+ }
182
+ case 15: // FIELD_BOOLEAN
183
+ case "boolean": {
184
+ return this.asBoolean(value);
185
+ }
186
+ case 7: // FIELD_DATETIME
187
+ case "datetime":
188
+ case "datetimetz":
189
+ case "datetimenotz": {
190
+ return this.asTimestamp(value);
191
+ }
192
+ case 10: // FIELD_DATE
193
+ case "date": {
194
+ return this.asDate(value);
195
+ }
196
+ case "array": {
197
+ return this.asArray(value);
198
+ }
199
+ case 14: // FIELD_TIMESPAN
200
+ case "timespan": {
201
+ return this.asTimespan(value);
202
+ }
203
+ case "primarykey": {
204
+ return this.asPrimaryKey(value);
205
+ }
206
+ default: {
207
+ throw CampaignException.BAD_PARAMETER("type", type, `Cannot convert value type='${type}', value='${value}'`);
208
+ }
209
+ }
210
210
  }
211
211
 
212
212
  /**
@@ -216,29 +216,29 @@ class XtkCaster {
216
216
  * @return {string} a string value, guaranteed to be valid
217
217
  */
218
218
  static asString(value) {
219
- if (value === null || value === undefined) return "";
220
- if (value != value || value === Number.POSITIVE_INFINITY || value === Number.NEGATIVE_INFINITY) return "";
221
- if (value instanceof Date) {
222
- if (isNaN(value.getTime()))
223
- return ""; // Invalid JavaScript date
224
- return value.toISOString();
219
+ if (value === null || value === undefined) return "";
220
+ if (value != value || value === Number.POSITIVE_INFINITY || value === Number.NEGATIVE_INFINITY) return "";
221
+ if (value instanceof Date) {
222
+ if (isNaN(value.getTime()))
223
+ return ""; // Invalid JavaScript date
224
+ return value.toISOString();
225
+ }
226
+ if ((typeof value) == "object") {
227
+ if (XtkCaster.isPrimaryKey(value)) {
228
+ let result = value.schemaId;
229
+ for (let i=0; i<value.values.length; i++) {
230
+ result = result + "|";
231
+ let item = value.values[i];
232
+ if (item === null || item === undefined) continue;
233
+ if (typeof item !== "string") item = XtkCaster.asString(item);
234
+ const escaped = item.replace(/\|/g, "\\|").replace(/"/g, "\\\""); // escape | and " chars
235
+ result = result + escaped;
236
+ }
237
+ return result;
225
238
  }
226
- if ((typeof value) == "object") {
227
- if (XtkCaster.isPrimaryKey(value)) {
228
- let result = value.schemaId;
229
- for (let i=0; i<value.values.length; i++) {
230
- result = result + "|";
231
- let item = value.values[i];
232
- if (item === null || item === undefined) continue;
233
- if (typeof item !== "string") item = XtkCaster.asString(item);
234
- const escaped = item.replace(/\|/g, "\\|").replace(/\"/g, "\\\""); // escape | and " chars
235
- result = result + escaped;
236
- }
237
- return result;
238
- }
239
- return "";
240
- }
241
- return value.toString();
239
+ return "";
240
+ }
241
+ return value.toString();
242
242
  }
243
243
 
244
244
  /**
@@ -249,15 +249,15 @@ class XtkCaster {
249
249
  * @return {boolean} a boolean value, guaranteed to be true or false
250
250
  */
251
251
  static asBoolean(value, defaultValue) {
252
- if (defaultValue === undefined) defaultValue = false;
253
- if (value === null || value === undefined) return defaultValue;
254
- if (value === true || value === false) return value;
255
- var stringValue = value.toString().toLowerCase().trim();
256
- if (stringValue === "false" || stringValue === "") return false;
257
- if (stringValue === "true") return true;
258
- var intValue = parseInt(value, 10);
259
- if (isNaN(intValue)) return false;
260
- return intValue !== 0;
252
+ if (defaultValue === undefined) defaultValue = false;
253
+ if (value === null || value === undefined) return defaultValue;
254
+ if (value === true || value === false) return value;
255
+ var stringValue = value.toString().toLowerCase().trim();
256
+ if (stringValue === "false" || stringValue === "") return false;
257
+ if (stringValue === "true") return true;
258
+ var intValue = parseInt(value, 10);
259
+ if (isNaN(intValue)) return false;
260
+ return intValue !== 0;
261
261
  }
262
262
 
263
263
  /**
@@ -266,14 +266,14 @@ class XtkCaster {
266
266
  * @param {*} value is the raw value to convert
267
267
  * @return {number} a numercial value, guaranteed to be valid and in the [-128, 127] range
268
268
  */
269
- static asByte(value) {
270
- var number = this.asNumber(value);
271
- if( number ) {
272
- number = Math.round(number);
273
- if( number < -128) number = -128;
274
- if( number > 127) number = 127;
275
- }
276
- return number;
269
+ static asByte(value) {
270
+ var number = this.asNumber(value);
271
+ if( number ) {
272
+ number = Math.round(number);
273
+ if( number < -128) number = -128;
274
+ if( number > 127) number = 127;
275
+ }
276
+ return number;
277
277
  }
278
278
 
279
279
  /**
@@ -283,13 +283,13 @@ class XtkCaster {
283
283
  * @return {number} a numercial value, guaranteed to be valid and in the [-32768, 32767] range
284
284
  */
285
285
  static asShort(value) {
286
- var number = this.asNumber(value);
287
- if( number ) {
288
- number = Math.round(number);
289
- if( number < -32768) number = -32768;
290
- if( number > 32767) number = 32767;
291
- }
292
- return number;
286
+ var number = this.asNumber(value);
287
+ if( number ) {
288
+ number = Math.round(number);
289
+ if( number < -32768) number = -32768;
290
+ if( number > 32767) number = 32767;
291
+ }
292
+ return number;
293
293
  }
294
294
 
295
295
  /**
@@ -299,13 +299,13 @@ class XtkCaster {
299
299
  * @return {number} a numercial value, guaranteed to be valid and in the [-2147483648, 2147483647] range
300
300
  */
301
301
  static asLong(value) {
302
- var number = this.asNumber(value);
303
- if( number ) {
304
- number = Math.round(number);
305
- if( number < -2147483648) number = -2147483648;
306
- if( number > 2147483647) number = 2147483647;
307
- }
308
- return number;
302
+ var number = this.asNumber(value);
303
+ if( number ) {
304
+ number = Math.round(number);
305
+ if( number < -2147483648) number = -2147483648;
306
+ if( number > 2147483647) number = 2147483647;
307
+ }
308
+ return number;
309
309
  }
310
310
 
311
311
  /**
@@ -316,14 +316,14 @@ class XtkCaster {
316
316
  * @return {string} a string value representing the number
317
317
  */
318
318
  static asInt64(value) {
319
- if (value === null || value === undefined || value === "") return "0";
320
- if (isNaN(value) || value === Number.POSITIVE_INFINITY || value === Number.NEGATIVE_INFINITY) return "0";
321
- if ((typeof value) == "object") return "0";
322
- if ((typeof value) == "boolean") return value ? "1" : "0";
323
- var number = String(value).trim();
324
- if (number.indexOf(".") != -1) return "0";
325
- if (number == "") return "0";
326
- return number;
319
+ if (value === null || value === undefined || value === "") return "0";
320
+ if (isNaN(value) || value === Number.POSITIVE_INFINITY || value === Number.NEGATIVE_INFINITY) return "0";
321
+ if ((typeof value) == "object") return "0";
322
+ if ((typeof value) == "boolean") return value ? "1" : "0";
323
+ var number = String(value).trim();
324
+ if (number.indexOf(".") != -1) return "0";
325
+ if (number == "") return "0";
326
+ return number;
327
327
  }
328
328
 
329
329
  /**
@@ -333,7 +333,7 @@ class XtkCaster {
333
333
  * @return {number} a numercial value, guaranteed to be valid
334
334
  */
335
335
  static asFloat(value) {
336
- return this.asNumber(value);
336
+ return this.asNumber(value);
337
337
  }
338
338
 
339
339
  /**
@@ -343,7 +343,7 @@ class XtkCaster {
343
343
  * @return {number} a numercial value, guaranteed to be valid
344
344
  */
345
345
  static asDouble(value) {
346
- return this.asNumber(value);
346
+ return this.asNumber(value);
347
347
  }
348
348
 
349
349
  /**
@@ -353,11 +353,11 @@ class XtkCaster {
353
353
  * @return {number} a numercial value, guaranteed to be valid
354
354
  */
355
355
  static asNumber(value) {
356
- if (value === null || value === undefined || value === "") return 0;
357
- if (isNaN(value) || value === Number.POSITIVE_INFINITY || value === Number.NEGATIVE_INFINITY) return 0;
358
- if ((typeof value) == "object") return 0;
359
- var number = +value;
360
- return number;
356
+ if (value === null || value === undefined || value === "") return 0;
357
+ if (isNaN(value) || value === Number.POSITIVE_INFINITY || value === Number.NEGATIVE_INFINITY) return 0;
358
+ if ((typeof value) == "object") return 0;
359
+ var number = +value;
360
+ return number;
361
361
  }
362
362
 
363
363
  /**
@@ -366,8 +366,8 @@ class XtkCaster {
366
366
  * @param {*} value is the raw value to convert
367
367
  * @return {Date} the timestamp, possibly null
368
368
  */
369
- static asDatetime(value) {
370
- return this.asTimestamp(value);
369
+ static asDatetime(value) {
370
+ return this.asTimestamp(value);
371
371
  }
372
372
 
373
373
  /**
@@ -377,32 +377,32 @@ class XtkCaster {
377
377
  * @return {Date} the timestamp, possibly null
378
378
  */
379
379
  static asTimestamp(value) {
380
- if (value === null || value === undefined) return null;
381
- if ((typeof value) == "string") value = value.trim();
382
- if (value === "" || value === true || value === false) return null;
383
- if (value !== value || value === Number.POSITIVE_INFINITY || value === Number.NEGATIVE_INFINITY) return null;
384
-
385
- var timestamp = null;
386
- if (value instanceof Date)
387
- timestamp = value;
380
+ if (value === null || value === undefined) return null;
381
+ if ((typeof value) == "string") value = value.trim();
382
+ if (value === "" || value === true || value === false) return null;
383
+ if (value !== value || value === Number.POSITIVE_INFINITY || value === Number.NEGATIVE_INFINITY) return null;
384
+
385
+ var timestamp = null;
386
+ if (value instanceof Date)
387
+ timestamp = value;
388
388
  // Number to timestamp -> Consider as number of seconds since epoch
389
- else if ((typeof value) == "number") {
390
- timestamp = new Date(0);
391
- timestamp.setUTCSeconds(value);
389
+ else if ((typeof value) == "number") {
390
+ timestamp = new Date(0);
391
+ timestamp.setUTCSeconds(value);
392
+ }
393
+ else {
394
+ var number = +value;
395
+ if (number === number){
396
+ timestamp = new Date(0);
397
+ timestamp.setUTCSeconds(value);
392
398
  }
393
- else {
394
- var number = +value;
395
- if (number === number){
396
- timestamp = new Date(0);
397
- timestamp.setUTCSeconds(value);
398
- }
399
- // Parse ISO string. Example: "2018-11-18 01:00:04.690Z"
400
- else if ((typeof value) == "string") {
401
- timestamp = new Date(value);
402
- }
399
+ // Parse ISO string. Example: "2018-11-18 01:00:04.690Z"
400
+ else if ((typeof value) == "string") {
401
+ timestamp = new Date(value);
403
402
  }
404
- if (!timestamp || isNaN(timestamp.getTime())) return null;
405
- return timestamp;
403
+ }
404
+ if (!timestamp || isNaN(timestamp.getTime())) return null;
405
+ return timestamp;
406
406
  }
407
407
 
408
408
  /**
@@ -412,14 +412,14 @@ class XtkCaster {
412
412
  * @return {Date} a date
413
413
  */
414
414
  static asDate(value) {
415
- var timestamp = this.asTimestamp(value);
416
- if (timestamp) {
417
- timestamp.setUTCHours(0);
418
- timestamp.setUTCMinutes(0);
419
- timestamp.setUTCSeconds(0);
420
- timestamp.setUTCMilliseconds(0);
421
- }
422
- return timestamp;
415
+ var timestamp = this.asTimestamp(value);
416
+ if (timestamp) {
417
+ timestamp.setUTCHours(0);
418
+ timestamp.setUTCMinutes(0);
419
+ timestamp.setUTCSeconds(0);
420
+ timestamp.setUTCMilliseconds(0);
421
+ }
422
+ return timestamp;
423
423
  }
424
424
 
425
425
  /**
@@ -429,10 +429,10 @@ class XtkCaster {
429
429
  * @param {*} value is the raw value to convert
430
430
  * @return {Array} a array
431
431
  */
432
- static asArray(value) {
433
- if (value === null || value === undefined) return [];
434
- if (Util.isArray(value)) return value;
435
- return [value];
432
+ static asArray(value) {
433
+ if (value === null || value === undefined) return [];
434
+ if (Util.isArray(value)) return value;
435
+ return [value];
436
436
  }
437
437
 
438
438
  /**
@@ -441,13 +441,13 @@ class XtkCaster {
441
441
  * @returns is the time span, in seconds
442
442
  */
443
443
  static asTimespan(value) {
444
- if (value === null || value === undefined) return 0;
445
- if ((typeof value) == "string") value = value.trim();
446
- if (value === "" || value === true || value === false) return 0;
447
- if (value !== value || value === Number.POSITIVE_INFINITY || value === Number.NEGATIVE_INFINITY) return 0;
448
- // Number to timespan -> Consider as number of seconds
449
- var timespan = XtkCaster.asLong(value);
450
- return timespan;
444
+ if (value === null || value === undefined) return 0;
445
+ if ((typeof value) == "string") value = value.trim();
446
+ if (value === "" || value === true || value === false) return 0;
447
+ if (value !== value || value === Number.POSITIVE_INFINITY || value === Number.NEGATIVE_INFINITY) return 0;
448
+ // Number to timespan -> Consider as number of seconds
449
+ var timespan = XtkCaster.asLong(value);
450
+ return timespan;
451
451
  }
452
452
 
453
453
  /**
@@ -456,27 +456,27 @@ class XtkCaster {
456
456
  * @param {*} value is the raw value to convert
457
457
  * @return {PrimaryKey} a primary key
458
458
  */
459
- static asPrimaryKey(value) {
460
- if (value === null || value === undefined) return undefined;
461
- if (this.isPrimaryKey(value)) return value;
462
- value = value.toString();
463
- let index = value.indexOf('|');
464
- if (index <= 0) return undefined; // no schema id or empty schema id
465
- const primaryKey = {
466
- schemaId: value.substring(0, index),
467
- values: []
468
- };
469
- value = value.substring(index+1) + "|";
470
- let start = 0;
471
- for(var i=0; i<value.length; i++) {
472
- const c = value[i];
473
- if (c === '\\') { i = i + 1; continue; } // escaped char
474
- if (c === '|') {
475
- primaryKey.values.push(value.substring(start, i).replace(/\\/g, ""));
476
- start = i + 1;
477
- }
459
+ static asPrimaryKey(value) {
460
+ if (value === null || value === undefined) return undefined;
461
+ if (this.isPrimaryKey(value)) return value;
462
+ value = value.toString();
463
+ let index = value.indexOf('|');
464
+ if (index <= 0) return undefined; // no schema id or empty schema id
465
+ const primaryKey = {
466
+ schemaId: value.substring(0, index),
467
+ values: []
468
+ };
469
+ value = value.substring(index+1) + "|";
470
+ let start = 0;
471
+ for(var i=0; i<value.length; i++) {
472
+ const c = value[i];
473
+ if (c === '\\') { i = i + 1; continue; } // escaped char
474
+ if (c === '|') {
475
+ primaryKey.values.push(value.substring(start, i).replace(/\\/g, ""));
476
+ start = i + 1;
478
477
  }
479
- return primaryKey;
478
+ }
479
+ return primaryKey;
480
480
  }
481
481
 
482
482
  /**
@@ -485,7 +485,7 @@ class XtkCaster {
485
485
  * @returns {boolean} true if the type is a date and/or time type
486
486
  */
487
487
  static isTimeType(type) {
488
- return type === "datetime" || type === "datetimetz" || type === "datetimenotz" || type === "timestamp" || type === "date" || type === "time" || type === "timespan" || type === 7 || type === 10 || type === 14;
488
+ return type === "datetime" || type === "datetimetz" || type === "datetimenotz" || type === "timestamp" || type === "date" || type === "time" || type === "timespan" || type === 7 || type === 10 || type === 14;
489
489
  }
490
490
 
491
491
  /**
@@ -494,7 +494,7 @@ class XtkCaster {
494
494
  * @returns {boolean} true if the type is a string type
495
495
  */
496
496
  static isStringType(type) {
497
- return type === "string" || type === "memo" || type === 6 || type === 12 || type === 13 || type === "blob" || type === "html" || type === "CDATA";
497
+ return type === "string" || type === "memo" || type === 6 || type === 12 || type === 13 || type === "blob" || type === "html" || type === "CDATA";
498
498
  }
499
499
 
500
500
  /**
@@ -503,7 +503,7 @@ class XtkCaster {
503
503
  * @returns {boolean} true if the type is a numeric type
504
504
  */
505
505
  static isNumericType(type) {
506
- 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;
506
+ 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;
507
507
  }
508
508
 
509
509
  /**
@@ -512,12 +512,12 @@ class XtkCaster {
512
512
  * @returns true or false depending on whether the object is a primary key or not
513
513
  */
514
514
  static isPrimaryKey(value) {
515
- if (!value) return false;
516
- return !!(value.schemaId && value.values && Util.isArray(value.values));
515
+ if (!value) return false;
516
+ return !!(value.schemaId && value.values && Util.isArray(value.values));
517
517
  }
518
- }
518
+ }
519
519
 
520
520
 
521
- exports.XtkCaster = XtkCaster;
521
+ exports.XtkCaster = XtkCaster;
522
522
 
523
523
  })();