@coherentglobal/spark-execute-sdk 0.8.1 → 0.8.3

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/README.md CHANGED
@@ -94,7 +94,7 @@ const config = {
94
94
  Instantiate the Model Class.
95
95
 
96
96
  ```js
97
- const Spark = new Spark(config);
97
+ const spark = new Spark(config);
98
98
  ```
99
99
 
100
100
  ### Execute
@@ -104,7 +104,7 @@ const Spark = new Spark(config);
104
104
  Perform the calculation. The sdk will use the request_meta.version_uuid of input argument to locate the model
105
105
 
106
106
  ```js
107
- const response = await Spark.execute(input).catch((err) => {
107
+ const response = await spark.execute(input).catch((err) => {
108
108
  // Do something here
109
109
  });
110
110
  ```
@@ -112,7 +112,7 @@ const response = await Spark.execute(input).catch((err) => {
112
112
  or
113
113
 
114
114
  ```js
115
- const response = await Spark.execute(input, version_id).catch((err) => {
115
+ const response = await spark.execute(input, version_id).catch((err) => {
116
116
  // Do something here
117
117
  });
118
118
  ```
@@ -122,7 +122,7 @@ const response = await Spark.execute(input, version_id).catch((err) => {
122
122
  Perform the calculation with cancellationToken. The sdk will use the request_meta.version_uuid of input argument to locate the model
123
123
 
124
124
  ```js
125
- const execute = Spark.executeWithCancellationToken(input)
125
+ const execute = spark.executeWithCancellationToken(input)
126
126
 
127
127
  // Cancel the execution (best effort)
128
128
  execute.cancellationToken.cancel()
@@ -139,7 +139,7 @@ execute.response.then((result) => {
139
139
  or
140
140
 
141
141
  ```js
142
- const execute = Spark.executeWithCancellationToken(input)
142
+ const execute = spark.executeWithCancellationToken(input)
143
143
 
144
144
  // Cancel the execution (best effort)
145
145
  execute.cancellationToken.cancel()
package/dist/browser.js CHANGED
@@ -12022,7 +12022,7 @@ var Spark = /*#__PURE__*/function () {
12022
12022
  * @param {object} config
12023
12023
  */
12024
12024
  function Spark(config) {
12025
- var _this$config$sparkEnd, _this$config, _this$config$sparkEnd2, _this$config2, _ref, _this$config$sparkEnd3, _this$config3, _this$config4, _this$config$sparkEnd4, _this$config5, _this$config6, _this$config7, _this$config8;
12025
+ var _this$config$sparkEnd, _this$config, _this$config$sparkEnd2, _this$config2, _ref, _this$config$sparkEnd3, _this$config3, _this$config4, _this$config$sparkEnd4, _this$config5, _this$config6, _this$config7, _this$config8, _this$config9;
12026
12026
  var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
12027
12027
  (0, _classCallCheck2["default"])(this, Spark);
12028
12028
  /**
@@ -12071,13 +12071,13 @@ var Spark = /*#__PURE__*/function () {
12071
12071
  /**
12072
12072
  * @private
12073
12073
  */
12074
- this.model = this._models((_this$config6 = this.config) === null || _this$config6 === void 0 ? void 0 : _this$config6.nodeGenModels);
12074
+ this.model = this._models(((_this$config6 = this.config) === null || _this$config6 === void 0 ? void 0 : _this$config6.nodegenModels) || ((_this$config7 = this.config) === null || _this$config7 === void 0 ? void 0 : _this$config7.nodeGenModels));
12075
12075
  this.modelCount = 0;
12076
12076
  this._offlinePreventCleanupModels = [];
12077
12077
  this._offlineLastExecution = {};
12078
12078
  this._offlineLastExecuting = {};
12079
- this.offlineMaxService = ((_this$config7 = this.config) === null || _this$config7 === void 0 ? void 0 : _this$config7.offlineMaxService) || parseInt(process.env.OFFLINE_MAX_SERVICE) || 20;
12080
- this.timeout = ((_this$config8 = this.config) === null || _this$config8 === void 0 ? void 0 : _this$config8.timeout) || parseInt(process.env.TIMEOUT_MS) || 60000;
12079
+ this.offlineMaxService = ((_this$config8 = this.config) === null || _this$config8 === void 0 ? void 0 : _this$config8.offlineMaxService) || parseInt(process.env.OFFLINE_MAX_SERVICE) || 20;
12080
+ this.timeout = ((_this$config9 = this.config) === null || _this$config9 === void 0 ? void 0 : _this$config9.timeout) || parseInt(process.env.TIMEOUT_MS) || 60000;
12081
12081
  }
12082
12082
  (0, _createClass2["default"])(Spark, [{
12083
12083
  key: "log",
@@ -12144,7 +12144,7 @@ var Spark = /*#__PURE__*/function () {
12144
12144
  eventType: "spark.validateconfig.startend.error",
12145
12145
  duration: _end - start
12146
12146
  });
12147
- throw new Error("ValidationError: ".concat(message));
12147
+ throw new Error("SDK Setup ValidationError: ".concat(message));
12148
12148
  }
12149
12149
  }
12150
12150
  /**
@@ -12209,7 +12209,7 @@ var Spark = /*#__PURE__*/function () {
12209
12209
  */
12210
12210
  }, {
12211
12211
  key: "execute",
12212
- value: function () {
12212
+ value: (function () {
12213
12213
  var _execute = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(input, version_id, cancellationToken) {
12214
12214
  var _input$request_meta, _input$request_meta2;
12215
12215
  var versionID, lookup, response;
@@ -12251,7 +12251,7 @@ var Spark = /*#__PURE__*/function () {
12251
12251
  return _execute.apply(this, arguments);
12252
12252
  }
12253
12253
  return execute;
12254
- }()
12254
+ }())
12255
12255
  }, {
12256
12256
  key: "offlineModel",
12257
12257
  value: function () {
@@ -12271,14 +12271,18 @@ var Spark = /*#__PURE__*/function () {
12271
12271
  MAX_RETRY,
12272
12272
  error,
12273
12273
  duration,
12274
+ result,
12274
12275
  xcallChainId,
12275
12276
  appendedInput,
12276
- result,
12277
12277
  _model$metaData$Engin5,
12278
12278
  _model$metaData5,
12279
12279
  _model$metaData$Engin6,
12280
12280
  _model$metaData6,
12281
12281
  start,
12282
+ _model$metaData$Engin7,
12283
+ _model$metaData7,
12284
+ _model$metaData$Engin8,
12285
+ _model$metaData8,
12282
12286
  _args3 = arguments;
12283
12287
  return _regenerator["default"].wrap(function _callee3$(_context3) {
12284
12288
  while (1) switch (_context3.prev = _context3.next) {
@@ -12475,25 +12479,44 @@ var Spark = /*#__PURE__*/function () {
12475
12479
  _context3.next = 24;
12476
12480
  break;
12477
12481
  case 50:
12478
- _context3.next = 59;
12482
+ if (!(retry > MAX_RETRY && result)) {
12483
+ _context3.next = 57;
12484
+ break;
12485
+ }
12486
+ this._registry.remove(versionId);
12487
+ console.log('Reappend failed model');
12488
+ _context3.next = 55;
12489
+ return this._registry.append({
12490
+ id: versionId,
12491
+ url: model.binary,
12492
+ meta: {
12493
+ folder_name: (_model$metaData$Engin7 = model === null || model === void 0 || (_model$metaData7 = model.metaData) === null || _model$metaData7 === void 0 || (_model$metaData7 = _model$metaData7.EngineInformation) === null || _model$metaData7 === void 0 ? void 0 : _model$metaData7.ProductName) !== null && _model$metaData$Engin7 !== void 0 ? _model$metaData$Engin7 : "",
12494
+ service_name: (_model$metaData$Engin8 = model === null || model === void 0 || (_model$metaData8 = model.metaData) === null || _model$metaData8 === void 0 || (_model$metaData8 = _model$metaData8.EngineInformation) === null || _model$metaData8 === void 0 ? void 0 : _model$metaData8.ServiceName) !== null && _model$metaData$Engin8 !== void 0 ? _model$metaData$Engin8 : ""
12495
+ }
12496
+ });
12497
+ case 55:
12498
+ this._offlineLastExecuting[versionId] = false;
12499
+ return _context3.abrupt("return", result);
12500
+ case 57:
12501
+ _context3.next = 66;
12479
12502
  break;
12480
- case 52:
12481
- _context3.prev = 52;
12503
+ case 59:
12504
+ _context3.prev = 59;
12482
12505
  _context3.t0 = _context3["catch"](2);
12483
12506
  this._offlineLastExecution[versionId] = Date.now();
12484
12507
  this._offlineLastExecuting[versionId] = false;
12485
12508
  if (!(_context3.t0 instanceof ModelExecuteCancelled)) {
12486
- _context3.next = 58;
12509
+ _context3.next = 65;
12487
12510
  break;
12488
12511
  }
12489
12512
  throw new WasmRunnerErrors.ExecuteCancelled(versionId);
12490
- case 58:
12513
+ case 65:
12491
12514
  return _context3.abrupt("return", _context3.t0);
12492
- case 59:
12515
+ case 66:
12493
12516
  case "end":
12494
12517
  return _context3.stop();
12495
12518
  }
12496
- }, _callee3, this, [[2, 52]]);
12519
+ }, _callee3, this, [[2, 59]]);
12497
12520
  }));
12498
12521
  function offlineModel(_x4, _x5, _x6) {
12499
12522
  return _offlineModel.apply(this, arguments);
@@ -12951,7 +12974,7 @@ var findModel = function findModel(requestMeta, nodegenModels) {
12951
12974
  }).reverse();
12952
12975
  }
12953
12976
  } else {
12954
- throw new Error("Model not found. requestMeta: " + JSON.stringify(requestMeta));
12977
+ throw new Error("SDK Setup Error: Model not found. requestMeta: " + JSON.stringify(requestMeta));
12955
12978
  }
12956
12979
  if (model.length === 0) {
12957
12980
  throw new WasmRunnerErrors.MissingModelError(requestMeta === null || requestMeta === void 0 ? void 0 : requestMeta.version_id);
@@ -13016,7 +13039,7 @@ var getAuthHeaders = function getAuthHeaders(token, authType, tenant) {
13016
13039
  } else if (authType === "bearerToken") {
13017
13040
  authHeaders.authorization = "Bearer ".concat(token);
13018
13041
  } else {
13019
- throw new Error("Invalid auth type ".concat(authType));
13042
+ throw new Error("Authentication Error: Invalid auth type ".concat(authType));
13020
13043
  }
13021
13044
  return authHeaders;
13022
13045
  };
@@ -13258,6 +13281,20 @@ module.exports = processModels;
13258
13281
  "use strict";
13259
13282
 
13260
13283
  var Joi = require("joi");
13284
+ modelConfig = Joi.array().items(Joi.object({
13285
+ versionId: Joi.string(),
13286
+ type: Joi.string(),
13287
+ binary: [Joi.string().allow(""), Joi["function"]().allow(""), Joi.object({
13288
+ servicename: Joi.string(),
13289
+ wasm: Joi.string(),
13290
+ js: Joi.string(),
13291
+ data: Joi.string()
13292
+ })],
13293
+ binaryPath: Joi.string(),
13294
+ metaData: Joi.object(),
13295
+ replica: Joi.number().integer().min(1),
13296
+ preventCleanup: Joi["boolean"]()
13297
+ }));
13261
13298
  var rules = Joi.object({
13262
13299
  replica: Joi.number().integer().min(1),
13263
13300
  sparkEndpoint: Joi.object({
@@ -13270,25 +13307,13 @@ var rules = Joi.object({
13270
13307
  // allow fns
13271
13308
  bearerToken: [Joi.string().allow(""), Joi["function"]().allow("")] // allow strings/fns
13272
13309
  }).and("url", "tenant", "authType"),
13273
- nodeGenModels: Joi.array().items(Joi.object({
13274
- versionId: Joi.string(),
13275
- type: Joi.string(),
13276
- binary: [Joi.string().allow(""), Joi["function"]().allow(""), Joi.object({
13277
- servicename: Joi.string(),
13278
- wasm: Joi.string(),
13279
- js: Joi.string(),
13280
- data: Joi.string()
13281
- })],
13282
- binaryPath: Joi.string(),
13283
- metaData: Joi.object(),
13284
- replica: Joi.number().integer().min(1),
13285
- preventCleanup: Joi["boolean"]()
13286
- })).required(),
13310
+ nodegenModels: modelConfig,
13311
+ nodeGenModels: modelConfig,
13287
13312
  // externalUuid: Joi.string().allow(),
13288
13313
  // xParameters: Joi.array().items(),
13289
13314
  // xCallCallback: Joi.func()
13290
13315
  timeout: Joi.number().integer().min(1) // in ms
13291
- }).required();
13316
+ }).xor('nodeGenModels', 'nodegenModels').required();
13292
13317
  var validate = function validate(config) {
13293
13318
  var isValidConfig = rules.validate(config);
13294
13319
  return isValidConfig;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coherentglobal/spark-execute-sdk",
3
- "version": "0.8.1",
3
+ "version": "0.8.3",
4
4
  "description": "Coherent Spark Execute SDK for Node.js and Browser",
5
5
  "main": "src/node.js",
6
6
  "browser": "dist/browser.js",
@@ -8,8 +8,8 @@
8
8
  "scripts": {
9
9
  "build": "npm run build:types && npm run bundle:full && npm run bundle:min",
10
10
  "build:types": "tsc --declaration",
11
- "bundle:full": "browserify src/browser.js --standalone Spark > dist/browser.js",
12
- "bundle:min": "browserify src/browser.js --standalone Spark | uglifyjs --compress --mangle --comments false > lib/sparkexecute.min.js",
11
+ "bundle:full": "mkdir -p dist && browserify src/browser.js --standalone Spark > dist/browser.js",
12
+ "bundle:min": "mkdir -p lib && browserify src/browser.js --standalone Spark | uglifyjs --compress --mangle --comments false > lib/sparkexecute.min.js",
13
13
  "test": "npx mocha --bail --exit --recursive --timeout 100000 --reporter nyan",
14
14
  "cover": "nyc --check-coverage --reporter=lcov --lines 65 mocha --bail --exit --recursive --timeout 100000"
15
15
  },
@@ -19,13 +19,17 @@
19
19
  "directories": {
20
20
  "test": "test"
21
21
  },
22
+ "files": [
23
+ "types/",
24
+ "src/"
25
+ ],
22
26
  "keywords": [],
23
27
  "author": "",
24
28
  "license": "ISC",
25
29
  "dependencies": {
26
30
  "@coherentglobal/wasm-runner": "^0.0.102",
27
31
  "@types/node": "^18.7.18",
28
- "axios": "^0.27.2",
32
+ "axios": "^1.6.7",
29
33
  "fs": "^0.0.1-security",
30
34
  "got": "^11.8.6",
31
35
  "http-status-codes": "^2.2.0",
package/src/browser.js CHANGED
@@ -61,7 +61,7 @@ class Spark {
61
61
  /**
62
62
  * @private
63
63
  */
64
- this.model = this._models(this.config?.nodeGenModels);
64
+ this.model = this._models(this.config?.nodegenModels || this.config?.nodeGenModels);
65
65
 
66
66
  this.modelCount = 0;
67
67
  this._offlinePreventCleanupModels = [];
@@ -126,7 +126,7 @@ class Spark {
126
126
  eventType: "spark.validateconfig.startend.error",
127
127
  duration: end - start,
128
128
  });
129
- throw new Error(`ValidationError: ${message}`);
129
+ throw new Error(`SDK Setup ValidationError: ${message}`);
130
130
  }
131
131
  }
132
132
  /**
@@ -216,6 +216,7 @@ class Spark {
216
216
  if (!input?.request_meta) {
217
217
  input.request_meta = {};
218
218
  }
219
+
219
220
  if (versionID) {
220
221
  input.request_meta.version_id = versionId;
221
222
  }
@@ -302,7 +303,7 @@ class Spark {
302
303
  this._registry = new WasmRunner(undefined, callback, "");
303
304
  }
304
305
 
305
- while(this._offlineLastExecuting[versionId]) {
306
+ while (this._offlineLastExecuting[versionId]) {
306
307
  await utils.sleep(10);
307
308
  }
308
309
 
@@ -319,10 +320,10 @@ class Spark {
319
320
  service_name: model?.metaData?.EngineInformation?.ServiceName ?? "",
320
321
  },
321
322
  });
322
-
323
+
323
324
  this.modelCount = this.modelCount + 1;
324
325
 
325
- if(model && model.preventCleanup) {
326
+ if (model && model.preventCleanup) {
326
327
  this._offlinePreventCleanupModels.push(model?.versionId)
327
328
  }
328
329
  }
@@ -332,10 +333,11 @@ class Spark {
332
333
  let error = true;
333
334
  let duration = 0;
334
335
 
336
+ let result;
335
337
  while (error && retry <= MAX_RETRY) {
336
338
  const xcallChainId = xcallTracker.issueXcallChainId();
337
339
  const appendedInput = utils.appendingContext(tenant, input, null, null, xcallChainId, true);
338
- const result = await this._registry.execute(
340
+ result = await this._registry.execute(
339
341
  appendedInput,
340
342
  versionId,
341
343
  () => { },
@@ -384,17 +386,34 @@ class Spark {
384
386
  return result;
385
387
  }
386
388
  }
389
+
390
+ if (retry > MAX_RETRY && result) {
391
+ this._registry.remove(versionId);
392
+ console.log('Reappend failed model');
393
+ await this._registry.append({
394
+ id: versionId,
395
+ url: model.binary,
396
+ meta: {
397
+ folder_name:
398
+ model?.metaData?.EngineInformation?.ProductName ?? "",
399
+ service_name:
400
+ model?.metaData?.EngineInformation?.ServiceName ?? "",
401
+ },
402
+ });
403
+ this._offlineLastExecuting[versionId] = false;
404
+ return result
405
+ }
387
406
  } catch (err) {
388
407
  this._offlineLastExecution[versionId] = Date.now();
389
408
  this._offlineLastExecuting[versionId] = false;
390
- if(err instanceof ModelExecuteCancelled) {
409
+ if (err instanceof ModelExecuteCancelled) {
391
410
  throw new WasmRunnerErrors.ExecuteCancelled(versionId);
392
411
  }
393
412
  return err;
394
413
  }
395
414
  }
396
415
 
397
- async _cleanUp () {
416
+ async _cleanUp() {
398
417
  let nonExecuteModel = [];
399
418
  Object.keys(this._offlineLastExecuting).forEach((key) => {
400
419
  if (this._offlineLastExecuting[key] === false && this._offlinePreventCleanupModels.find(m => m === key) === undefined) { // key !== 'cf3c7e5a-2f3b-4c79-81b9-7e4b174258cd' && key !== 'a167da91-afa6-4579-bd22-09752a30b57b') {
package/src/findModels.js CHANGED
@@ -188,7 +188,7 @@ const findModel = (requestMeta, nodegenModels) => {
188
188
  }
189
189
  } else {
190
190
  throw new Error(
191
- "Model not found. requestMeta: " + JSON.stringify(requestMeta)
191
+ "SDK Setup Error: Model not found. requestMeta: " + JSON.stringify(requestMeta)
192
192
  );
193
193
  }
194
194
 
@@ -60,7 +60,7 @@ const getAuthHeaders = (token, authType, tenant) => {
60
60
  } else if (authType === "bearerToken") {
61
61
  authHeaders.authorization = `Bearer ${token}`;
62
62
  } else {
63
- throw new Error(`Invalid auth type ${authType}`);
63
+ throw new Error(`Authentication Error: Invalid auth type ${authType}`);
64
64
  }
65
65
 
66
66
  return authHeaders;
package/src/node.js CHANGED
@@ -89,7 +89,12 @@ class Spark {
89
89
  /**
90
90
  * @private
91
91
  */
92
- this.model = this._models(this.config?.nodeGenModels);
92
+ this.model = this._models(this.config?.nodegenModels || this.config?.nodeGenModels);
93
+
94
+ /**
95
+ * @private
96
+ */
97
+ this.nodegenModel = this.config?.nodegenModels || this.config?.nodeGenModels
93
98
 
94
99
  /**
95
100
  * @private
@@ -130,11 +135,11 @@ class Spark {
130
135
  } else {
131
136
  const message = JSON.stringify(error.details);
132
137
  logger.error({
133
- EventType: 'ValidationError',
138
+ EventType: 'SDK.ValidationError',
134
139
  InstanceId: this.instanceid,
135
- TextMessage: message,
140
+ TextMessage: `SDK Validation Error: ${message}`,
136
141
  });
137
- throw new Error(`ValidationError: ${message}`);
142
+ throw new Error(`SDK Setup Error: ValidationError: ${message}`);
138
143
  }
139
144
  }
140
145
 
@@ -184,10 +189,10 @@ class Spark {
184
189
  break;
185
190
  }
186
191
  } catch (err) {
187
- logger.info({
188
- EventType: 'ExecuteModel.ERROR',
192
+ logger.error({
193
+ EventType: 'SDK.ExecuteModel.ERROR',
189
194
  InstanceId: this.instanceid,
190
- TextMessage: `Error while executing uuid: ${versionID} using priority:${this.priority[i]}`,
195
+ TextMessage: `SDK Execution Error: Error while executing uuid: ${versionID} using priority:${this.priority[i]}`,
191
196
  });
192
197
  error = err;
193
198
  }
@@ -261,8 +266,8 @@ class Spark {
261
266
  if (!this.isSerializedConfig) {
262
267
  const config = { ...this.config };
263
268
 
264
- if (config.nodeGenModels) {
265
- config.nodeGenModels.forEach((m) => {
269
+ if (this.nodegenModel) {
270
+ this.nodegenModel.forEach((m) => {
266
271
  if (m.binary) {
267
272
  const filePath = path.join(
268
273
  __dirname,
@@ -322,7 +327,7 @@ class Spark {
322
327
 
323
328
  _storeConfig() {
324
329
  fs.writeFileSync('config.json', JSON.stringify(this.config), () =>
325
- console.err(err)
330
+ logger.error(err)
326
331
  );
327
332
  return require.resolve('config.json');
328
333
  }
@@ -369,6 +374,7 @@ class Spark {
369
374
  // async remove(versionId) {}
370
375
 
371
376
  async offlineModel(input, versionID, tenant = 'default', cancellationToken) {
377
+ console.log('offlineModel', versionID, tenant)
372
378
  let versionId;
373
379
  try {
374
380
  const start = Date.now();
@@ -382,6 +388,15 @@ class Spark {
382
388
  Input: input,
383
389
  });
384
390
  input.callid = callid;
391
+
392
+ if(versionID) {
393
+ if(!input.request_meta) {
394
+ input.request_meta = {}
395
+ }
396
+
397
+ input.request_meta.version_id = versionID
398
+ }
399
+
385
400
  const model = findModel(input.request_meta, this.model);
386
401
 
387
402
  versionId = versionID || (model && model?.versionId);
@@ -446,6 +461,7 @@ class Spark {
446
461
  TextMessage: `Execute uuid: ${versionId}`,
447
462
  });
448
463
  this._offlineLastExecuting[versionId] = true;
464
+
449
465
  let result = await this._registry.execute(
450
466
  input,
451
467
  versionId,
@@ -476,7 +492,7 @@ class Spark {
476
492
  TimeStamp: Date.now(),
477
493
  EventType: 'SDK.OfflineModelExecutionError',
478
494
  InstanceId: this.instanceid,
479
- TextMessage: err.message,
495
+ TextMessage: `SDK Offline Model Execution Error: ${err.message}`,
480
496
  });
481
497
  if (err instanceof ModelExecuteCancelled) {
482
498
  throw new WasmRunnerErrors.ExecuteCancelled(versionId);
@@ -217,9 +217,9 @@ const sparkServiceVersionOne = async (requestData, context) => {
217
217
  } catch (err) {
218
218
  logger.error({
219
219
  eventType: "SDK.XCall.SparkService",
220
- msg: `WASMSERVER:DISPATCH_TYPE.SPARK_SERVICE ERROR: Request body is malform JSON ${JSON.stringify(requestData.request_body)}`,
220
+ msg: `Model Error: WASMSERVER:DISPATCH_TYPE.SPARK_SERVICE ERROR: Request body is malform JSON ${JSON.stringify(requestData.request_body)}`,
221
221
  });
222
- throw new Error(`Downstream Request body is malform JSON ${JSON.stringify(requestData.request_body)}`)
222
+ throw new Error(`Model Error: Downstream Request body is malform JSON ${JSON.stringify(requestData.request_body)}`)
223
223
  }
224
224
 
225
225
  const options = {};
package/src/validate.js CHANGED
@@ -1,5 +1,27 @@
1
1
  const Joi = require("joi");
2
2
 
3
+ modelConfig = Joi.array()
4
+ .items(
5
+ Joi.object({
6
+ versionId: Joi.string(),
7
+ type: Joi.string(),
8
+ binary: [
9
+ Joi.string().allow(""),
10
+ Joi.function().allow(""),
11
+ Joi.object({
12
+ servicename: Joi.string(),
13
+ wasm: Joi.string(),
14
+ js: Joi.string(),
15
+ data: Joi.string(),
16
+ }),
17
+ ],
18
+ binaryPath: Joi.string(),
19
+ metaData: Joi.object(),
20
+ replica: Joi.number().integer().min(1),
21
+ preventCleanup: Joi.boolean(),
22
+ })
23
+ )
24
+
3
25
  const rules = Joi.object({
4
26
  replica: Joi.number().integer().min(1),
5
27
  sparkEndpoint: Joi.object({
@@ -17,33 +39,13 @@ const rules = Joi.object({
17
39
  syntheticKey: [Joi.string().allow(""), Joi.function().allow("")], // allow fns
18
40
  bearerToken: [Joi.string().allow(""), Joi.function().allow("")], // allow strings/fns
19
41
  }).and("url", "tenant", "authType"),
20
- nodeGenModels: Joi.array()
21
- .items(
22
- Joi.object({
23
- versionId: Joi.string(),
24
- type: Joi.string(),
25
- binary: [
26
- Joi.string().allow(""),
27
- Joi.function().allow(""),
28
- Joi.object({
29
- servicename: Joi.string(),
30
- wasm: Joi.string(),
31
- js: Joi.string(),
32
- data: Joi.string(),
33
- }),
34
- ],
35
- binaryPath: Joi.string(),
36
- metaData: Joi.object(),
37
- replica: Joi.number().integer().min(1),
38
- preventCleanup: Joi.boolean(),
39
- })
40
- )
41
- .required(),
42
+ nodegenModels: modelConfig,
43
+ nodeGenModels: modelConfig,
42
44
  // externalUuid: Joi.string().allow(),
43
45
  // xParameters: Joi.array().items(),
44
46
  // xCallCallback: Joi.func()
45
47
  timeout: Joi.number().integer().min(1), // in ms
46
- }).required();
48
+ }).xor('nodeGenModels', 'nodegenModels').required();
47
49
 
48
50
  const validate = (config) => {
49
51
  const isValidConfig = rules.validate(config);
@@ -1 +1 @@
1
- {"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../src/browser.js"],"names":[],"mappings":";AAOA;IACE,iDAA2C;IAE3C;;OAEG;IACH,oBAFW,MAAM,gBA6DhB;IA1DC;;OAEG;IACH,kBAA0B;IAMxB,YAAyB;IAG3B;;OAEG;IACH,eAAyC;IAEzC;;OAEG;IACH,eAAsD;IACtD;;OAEG;IACH,iBAA0D;IAC1D;;OAEG;IACH,cAGI;IACJ;;OAEG;IACH,YAAgD;IAChD;;OAEG;IACH,qBAA2C;IAE3C;;OAEG;IACH,iBAA2C;IAE3C;;OAEG;IACH,cAAqD;IAErD,mBAAmB;IACnB,oCAAsC;IACtC,0BAA+B;IAC/B,0BAA+B;IAE/B,uBAA0G;IAC1G,aAAgF;IAGlF,oBAEC;IAED;;;;OAIG;IACH,iBAHW,MAAM,GACJ,MAAM,CAuBlB;IACD;;;;OAIG;IACH,uBAHW,MAAM,GACJ,MAAM,CAsBlB;IACD;;;;OAIG;IACH,cAHW,MAAM,GACJ,OAAO,CAOnB;IAED,wDASC;IAED;;;;;;OAMG;IACH,oCAJW,MAAM,sDAiBhB;IAED;;;;;;;OAOG;IACH,eALW,MAAM,4DAGJ,MAAM,CA0BlB;IAED,0HAwLC;IAED,0BA0BC;IAED,8DA6DC;CACF"}
1
+ {"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../src/browser.js"],"names":[],"mappings":";AAOA;IACE,iDAA2C;IAE3C;;OAEG;IACH,oBAFW,MAAM,gBA6DhB;IA1DC;;OAEG;IACH,kBAA0B;IAMxB,YAAyB;IAG3B;;OAEG;IACH,eAAyC;IAEzC;;OAEG;IACH,eAAsD;IACtD;;OAEG;IACH,iBAA0D;IAC1D;;OAEG;IACH,cAGI;IACJ;;OAEG;IACH,YAAgD;IAChD;;OAEG;IACH,qBAA2C;IAE3C;;OAEG;IACH,iBAA2C;IAE3C;;OAEG;IACH,cAAmF;IAEnF,mBAAmB;IACnB,oCAAsC;IACtC,0BAA+B;IAC/B,0BAA+B;IAE/B,uBAA0G;IAC1G,aAAgF;IAGlF,oBAEC;IAED;;;;OAIG;IACH,iBAHW,MAAM,GACJ,MAAM,CAuBlB;IACD;;;;OAIG;IACH,uBAHW,MAAM,GACJ,MAAM,CAsBlB;IACD;;;;OAIG;IACH,cAHW,MAAM,GACJ,OAAO,CAOnB;IAED,wDASC;IAED;;;;;;OAMG;IACH,oCAJW,MAAM,sDAiBhB;IAED;;;;;;;OAOG;IACH,eALW,MAAM,4DAGJ,MAAM,CA0BlB;IAED,0HA2MC;IAED,0BA0BC;IAED,8DA6DC;CACF"}
package/types/node.d.ts CHANGED
@@ -42,6 +42,10 @@ declare class Spark {
42
42
  * @private
43
43
  */
44
44
  private model;
45
+ /**
46
+ * @private
47
+ */
48
+ private nodegenModel;
45
49
  /**
46
50
  * @private
47
51
  */
@@ -1 +1 @@
1
- {"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../src/node.js"],"names":[],"mappings":";AAiBA;IACE,iDAA2C;IAE3C;;OAEG;IACH,oBAFW,MAAM,+CA+EhB;IA5EC;;OAEG;IACH,kBAA0B;IAGxB,SAAsB;IAGxB;;OAEG;IACH,mBAC4D;IAU1D,eAAsB;IAMxB,aAAwC;IAExC,uBAA0G;IAE1G,aAAgF;IAEhF;;OAEG;IACH,eAAsD;IACtD;;OAEG;IACH,iBAA0D;IAC1D;;OAEG;IACH,cAGI;IACJ;;OAEG;IACH,YAAgD;IAChD;;OAEG;IACH,qBAA2C;IAC3C;;OAEG;IACH,cAAqD;IAErD;;OAEG;IACH,yBAAmD;IAEnD;;OAEG;IACH,iBAAkD;IAClD,mBAAmB;IACnB,0BAA+B;IAC/B,0BAA+B;IAC/B,oCAAsC;IAGxC;;;;OAIG;IACH,iBAHW,MAAM,GACJ,MAAM,CAOlB;IAED;;;;OAIG;IACH,uBAHW,MAAM,GACJ,MAAM,CAelB;IAED,0CASC;IAED;;;;;;;OAOG;IACH,eALW,MAAM,uFAGJ,MAAM,CAsClB;IAED;;;;;;OAMG;IACH,oCAJW,MAAM,sDAiBhB;IAED,+BAiFC;IAED,wDAYC;IAED,uBAKC;IAED,0BA0BC;IAED;;OAEG;IAGH,0KAyGC;IAGD;;;;;;;OAOG;IACH,2BANW,MAAM,aACN,MAAM,iDAEN,iBAAiB,gBAiF3B;CACF"}
1
+ {"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../src/node.js"],"names":[],"mappings":";AAmBA;IACE,iDAA2C;IAE3C;;OAEG;IACH,oBAFW,MAAM,+CAwFhB;IArFC;;OAEG;IACH,kBAA0B;IAGxB,SAAsB;IAGxB;;OAEG;IACH,mBAC4D;IAU1D,eAAsB;IAMxB,aAAwC;IAExC,uBAGI;IAEJ,aACmE;IAEnE;;OAEG;IACH,eAAsD;IACtD;;OAEG;IACH,iBAA0D;IAC1D;;OAEG;IACH,cAGI;IACJ;;OAEG;IACH,YAAgD;IAChD;;OAEG;IACH,qBAA2C;IAC3C;;OAEG;IACH,cAAmF;IAEnF;;OAEG;IACH,qBAA4E;IAE5E;;OAEG;IACH,yBAAmD;IAEnD;;OAEG;IACH,iBAAkD;IAClD,mBAAmB;IACnB,0BAA+B;IAC/B,0BAA+B;IAC/B,oCAAsC;IAGxC;;;;OAIG;IACH,iBAHW,MAAM,GACJ,MAAM,CAOlB;IAED;;;;OAIG;IACH,uBAHW,MAAM,GACJ,MAAM,CAelB;IAED,0CASC;IAED;;;;;;;OAOG;IACH,eALW,MAAM,uFAGJ,MAAM,CA2ClB;IAED;;;;;;OAMG;IACH,oCAJW,MAAM,sDAiBhB;IAED,+BAkFC;IAED,wDAYC;IAED,uBAKC;IAED,0BAkCC;IAED;;OAEG;IAGH,0KA8HC;IAED;;;;;;;OAOG;IACH,2BANW,MAAM,aACN,MAAM,iDAEN,iBAAiB,gBAsF3B;CACF"}
@@ -36,8 +36,8 @@ export function getFromTempUrl(url: string, headers: any): Buffer;
36
36
  *
37
37
  * @returns
38
38
  */
39
- export function downloadModelFile(url: any, versionUuid: string, headers: any): Promise<any>;
40
- export function downloadModel(versionUuid: any, token: any): Promise<any>;
39
+ export function downloadModelFile(url: any, versionUuid: string, headers: any): Promise<string>;
40
+ export function downloadModel(versionUuid: any, token: any): Promise<string>;
41
41
  export function getParameterSet(versionUuid: any, tenant: any, token: any): Promise<any>;
42
42
  export function getParameterSetById(versionUuid: any, token: any, tenant?: string): Promise<any>;
43
43
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"entityStore.d.ts","sourceRoot":"","sources":["../../src/services/entityStore.js"],"names":[],"mappings":"AAgEA;;;;;;;;;;GAUG;AACH,yFAqBC;AAvDD;;;;;;;;;;GAUG;AACH,2DAFa,MAAM,CAYlB;AA+DD;;;;;;;;;;;;;GAaG;AACH,6FAuBC;AAqCD,0EAWC;AAMD,yFAeC;AArID,iGAuBC;AAgHD;;;;;;GAMG;AACH,0FAoBC"}
1
+ {"version":3,"file":"entityStore.d.ts","sourceRoot":"","sources":["../../src/services/entityStore.js"],"names":[],"mappings":"AAgEA;;;;;;;;;;GAUG;AACH,yFAqBC;AAvDD;;;;;;;;;;GAUG;AACH,2DAFa,MAAM,CAYlB;AA+DD;;;;;;;;;;;;;GAaG;AACH,gGAuBC;AAqCD,6EAWC;AAMD,yFAeC;AArID,iGAuBC;AAgHD;;;;;;GAMG;AACH,0FAoBC"}
@@ -1 +1 @@
1
- {"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../src/validate.js"],"names":[],"mappings":";AA+CA,kEAGC"}
1
+ {"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../src/validate.js"],"names":[],"mappings":";AAiDA,kEAGC"}
package/.babelrc DELETED
@@ -1,12 +0,0 @@
1
- {
2
- "presets": [
3
- [
4
- "@babel/preset-env",
5
- {
6
- "targets": {
7
- "esmodules": true
8
- }
9
- }
10
- ]
11
- ]
12
- }
package/.eslintrc.json DELETED
@@ -1,21 +0,0 @@
1
- {
2
- "extends": [
3
- "airbnb/base",
4
- "prettier",
5
- "plugin:node/recommended",
6
- "plugin:mocha/recommended"
7
- ],
8
- "parserOptions": {
9
- "ecmaVersion": 2020
10
- },
11
- "plugins": ["prettier", "mocha"],
12
- "rules": {
13
- "prettier/prettier": "error",
14
- "no-unused-vars": "warn",
15
- "no-console": "off",
16
- "func-names": "off",
17
- "no-process-exit": "off",
18
- "object-shorthand": "off",
19
- "class-methods-use-this": "off"
20
- }
21
- }
package/.prettierrc DELETED
File without changes
@@ -1,2 +0,0 @@
1
- export function sparkService(requestData: any, context: any): Promise<string>;
2
- //# sourceMappingURL=externalResolver_coherent.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"externalResolver_coherent.d.ts","sourceRoot":"","sources":["../../src/tenant_resolver/externalResolver_coherent.js"],"names":[],"mappings":"AAkDgB,8EAkEb"}
@@ -1,2 +0,0 @@
1
- export function sparkService(requestData: any, context: any): Promise<string>;
2
- //# sourceMappingURL=externalResolver_test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"externalResolver_test.d.ts","sourceRoot":"","sources":["../../src/tenant_resolver/externalResolver_test.js"],"names":[],"mappings":"AAkDgB,8EAkEb"}