@coherentglobal/spark-execute-sdk 0.3.16 → 0.4.1

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/dist/browser.js CHANGED
@@ -6322,7 +6322,7 @@ var Spark = /*#__PURE__*/function () {
6322
6322
  } else if (requestMeta.servicename && requestMeta.transaction_date) {
6323
6323
  model = this.model.filter(function (_ref3) {
6324
6324
  var metaData = _ref3.metaData;
6325
- return metaData.EngineInformation.ServiceName === requestMeta.servicename && new Date(requestMeta.transaction_date) >= new Date(metaData.effectiveStartDate) && new Date(requestMeta.transaction_date) <= new Date(metaData.effectiveEndDate);
6325
+ return metaData.EngineInformation.ServiceName === requestMeta.servicename && new Date(requestMeta.transaction_date) >= new Date(metaData.EffectiveStartDate) && new Date(requestMeta.transaction_date) <= new Date(metaData.EffectiveEndDate);
6326
6326
  });
6327
6327
  if (model.length > 1) {
6328
6328
  return model.sort(function (versionA, versionB) {
@@ -6341,7 +6341,7 @@ var Spark = /*#__PURE__*/function () {
6341
6341
  } else if (requestMeta.service_id && requestMeta.transaction_date) {
6342
6342
  model = this.model.filter(function (_ref5) {
6343
6343
  var metaData = _ref5.metaData;
6344
- return metaData.EngineInformation.ServiceGuid === requestMeta.service_id && new Date(requestMeta.transaction_date) >= new Date(metaData.effectiveStartDate) && new Date(requestMeta.transaction_date) <= new Date(metaData.effectiveEndDate);
6344
+ return metaData.EngineInformation.ServiceGuid === requestMeta.service_id && new Date(requestMeta.transaction_date) >= new Date(metaData.EffectiveStartDate) && new Date(requestMeta.transaction_date) <= new Date(metaData.EffectiveEndDate);
6345
6345
  });
6346
6346
  if (model.length > 1) {
6347
6347
  return model.sort(function (versionA, versionB) {
@@ -6362,7 +6362,7 @@ var Spark = /*#__PURE__*/function () {
6362
6362
  }
6363
6363
  model = this.model.filter(function (_ref6) {
6364
6364
  var metaData = _ref6.metaData;
6365
- return metaData.EngineInformation.ProductName === folder && metaData.EngineInformation.ServiceName === service && new Date(requestMeta.transaction_date) >= new Date(metaData.effectiveStartDate) && new Date(requestMeta.transaction_date) <= new Date(metaData.effectiveEndDate);
6365
+ return metaData.EngineInformation.ProductName === folder && metaData.EngineInformation.ServiceName === service && new Date(requestMeta.transaction_date) >= new Date(metaData.EffectiveStartDate) && new Date(requestMeta.transaction_date) <= new Date(metaData.EffectiveEndDate);
6366
6366
  });
6367
6367
  if (model.length > 1) {
6368
6368
  return model.sort(function (versionA, versionB) {
@@ -6927,7 +6927,7 @@ var rules = Joi.object({
6927
6927
  syntheticKey: [Joi.string().allow(""), Joi["function"]().allow("")],
6928
6928
  // allow fns
6929
6929
  bearerToken: [Joi.string().allow(""), Joi["function"]().allow("")] // allow strings/fns
6930
- }).and("url", "tenant", "authType").required(),
6930
+ }).and("url", "tenant", "authType"),
6931
6931
  nodeGenModels: Joi.array().items(Joi.object({
6932
6932
  versionId: Joi.string(),
6933
6933
  type: Joi.string(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coherentglobal/spark-execute-sdk",
3
- "version": "0.3.16",
3
+ "version": "0.4.1",
4
4
  "description": "",
5
5
  "main": "src/node.js",
6
6
  "browser": "dist/browser.js",
package/src/browser.js CHANGED
@@ -102,9 +102,9 @@ class Spark {
102
102
  ({ metaData }) =>
103
103
  metaData.EngineInformation.ServiceName === requestMeta.servicename &&
104
104
  new Date(requestMeta.transaction_date) >=
105
- new Date(metaData.effectiveStartDate) &&
105
+ new Date(metaData.EffectiveStartDate) &&
106
106
  new Date(requestMeta.transaction_date) <=
107
- new Date(metaData.effectiveEndDate)
107
+ new Date(metaData.EffectiveEndDate)
108
108
  );
109
109
 
110
110
  if (model.length > 1) {
@@ -133,9 +133,9 @@ class Spark {
133
133
  ({ metaData }) =>
134
134
  metaData.EngineInformation.ServiceGuid === requestMeta.service_id &&
135
135
  new Date(requestMeta.transaction_date) >=
136
- new Date(metaData.effectiveStartDate) &&
136
+ new Date(metaData.EffectiveStartDate) &&
137
137
  new Date(requestMeta.transaction_date) <=
138
- new Date(metaData.effectiveEndDate)
138
+ new Date(metaData.EffectiveEndDate)
139
139
  );
140
140
 
141
141
  if (model.length > 1) {
@@ -167,9 +167,9 @@ class Spark {
167
167
  metaData.EngineInformation.ProductName === folder &&
168
168
  metaData.EngineInformation.ServiceName === service &&
169
169
  new Date(requestMeta.transaction_date) >=
170
- new Date(metaData.effectiveStartDate) &&
170
+ new Date(metaData.EffectiveStartDate) &&
171
171
  new Date(requestMeta.transaction_date) <=
172
- new Date(metaData.effectiveEndDate)
172
+ new Date(metaData.EffectiveEndDate)
173
173
  );
174
174
 
175
175
  if (model.length > 1) {
package/src/node.js CHANGED
@@ -33,26 +33,26 @@ class Spark {
33
33
  this.config = this.validateConfig(config)
34
34
  }
35
35
  const {
36
- sparkEndpoint: { syntheticKey, bearerToken, authType, tenant, url },
36
+ // sparkEndpoint: { syntheticKey, bearerToken, authType, tenant, url },
37
37
  nodeGenModels,
38
38
  } = this.config;
39
39
 
40
40
  /**
41
41
  * @private
42
42
  */
43
- this.tenant = tenant;
43
+ this.tenant = "";
44
44
  /**
45
45
  * @private
46
46
  */
47
- this.authType = authType;
47
+ this.authType = "";
48
48
  /**
49
49
  * @private
50
50
  */
51
- this.token = syntheticKey || bearerToken;
51
+ this.token = "";
52
52
  /**
53
53
  * @private
54
54
  */
55
- this.url = url;
55
+ this.url = "";
56
56
  /**
57
57
  * @private
58
58
  */
@@ -61,22 +61,16 @@ class Spark {
61
61
  * @private
62
62
  */
63
63
  this.model = this._models(nodeGenModels);
64
- /**
65
- * @private
66
- */
67
- this.fallbackEnabled = false;
68
64
 
69
65
  /**
70
66
  * @private
71
67
  */
72
68
  this.externalResolver = this._addExternalResolver()
73
- console.log('EX: ', this.externalResolver)
74
69
 
75
70
  /**
76
71
  * @private
77
72
  */
78
- // this.storedConfig = this._storeConfig()
79
- this.priority = ["model", "onlineEndpoint"];
73
+ this.priority = ["model"];
80
74
  }
81
75
 
82
76
  /**
@@ -137,9 +131,9 @@ class Spark {
137
131
  ({ metaData }) =>
138
132
  metaData.EngineInformation.ServiceName === requestMeta.servicename &&
139
133
  new Date(requestMeta.transaction_date) >=
140
- new Date(metaData.effectiveStartDate) &&
134
+ new Date(metaData.EffectiveStartDate) &&
141
135
  new Date(requestMeta.transaction_date) <=
142
- new Date(metaData.effectiveEndDate)
136
+ new Date(metaData.EffectiveEndDate)
143
137
  );
144
138
 
145
139
  if (model.length > 1) {
@@ -168,9 +162,9 @@ class Spark {
168
162
  ({ metaData }) =>
169
163
  metaData.EngineInformation.ServiceGuid === requestMeta.service_id &&
170
164
  new Date(requestMeta.transaction_date) >=
171
- new Date(metaData.effectiveStartDate) &&
165
+ new Date(metaData.EffectiveStartDate) &&
172
166
  new Date(requestMeta.transaction_date) <=
173
- new Date(metaData.effectiveEndDate)
167
+ new Date(metaData.EffectiveEndDate)
174
168
  );
175
169
 
176
170
  if (model.length > 1) {
@@ -202,9 +196,9 @@ class Spark {
202
196
  metaData.EngineInformation.ProductName === folder &&
203
197
  metaData.EngineInformation.ServiceName === service &&
204
198
  new Date(requestMeta.transaction_date) >=
205
- new Date(metaData.effectiveStartDate) &&
199
+ new Date(metaData.EffectiveStartDate) &&
206
200
  new Date(requestMeta.transaction_date) <=
207
- new Date(metaData.effectiveEndDate)
201
+ new Date(metaData.EffectiveEndDate)
208
202
  );
209
203
 
210
204
  if (model.length > 1) {
@@ -268,9 +262,9 @@ class Spark {
268
262
 
269
263
  let response;
270
264
  response = await lookup[this.priority[0]](input, versionID, this);
271
- if (response instanceof Error) {
272
- response = await lookup[this.priority[1]](input, versionID, this);
273
- }
265
+ // if (response instanceof Error) {
266
+ // response = await lookup[this.priority[1]](input, versionID, this);
267
+ // }
274
268
 
275
269
  return response;
276
270
  }
@@ -293,7 +287,7 @@ class Spark {
293
287
  }
294
288
  )
295
289
  const data = serializeObject.serialize({...this.config, externalUuid: this.externalUuid})
296
- template = template.replace("%%config_to_replace%%", new Buffer(data).toString('base64'))
290
+ template = template.replace("%%config_to_replace%%", Buffer.from(data).toString('base64'))
297
291
  fs.writeFileSync(filePath, template)
298
292
  return require.resolve(filePath)
299
293
  }
@@ -323,23 +317,25 @@ class Spark {
323
317
  try {
324
318
  const model = ds._findModel(input.request_meta);
325
319
 
320
+ const versionId = versionID || (model && model?.versionId)
321
+
326
322
  logger.info({
327
323
  EventType: "ExecuteModel",
328
- TextMessage: `Execute uuid: ${model && model?.versionId}`,
324
+ TextMessage: `Execute uuid: ${versionId}`,
329
325
  });
330
326
  if (!(registry instanceof WasmRunner)) {
331
327
  registry = new WasmRunner(undefined, ds.externalResolver, "");
332
328
  }
333
329
 
334
- if (!registry.isExist(versionID)) {
330
+ if (!registry.isExist(versionId)) {
335
331
  await registry.append({
336
- id: versionID,
332
+ id: versionId,
337
333
  url: model?.binary || "",
338
334
  // size,
339
335
  });
340
336
  }
341
337
 
342
- let result = await registry.execute(input, versionID);
338
+ let result = await registry.execute(input, versionId);
343
339
 
344
340
  return result;
345
341
  } catch (err) {
package/src/validate.js CHANGED
@@ -7,7 +7,6 @@ const rules = Joi.object({
7
7
  scheme: ["http", "https"],
8
8
  })
9
9
  .required(),
10
-
11
10
  tenant: Joi.string()
12
11
  .pattern(/^[ A-Za-z0-9_./#&+-]+$/)
13
12
  .required(),
@@ -17,8 +16,7 @@ const rules = Joi.object({
17
16
  syntheticKey: [Joi.string().allow(""), Joi.function().allow("")], // allow fns
18
17
  bearerToken: [Joi.string().allow(""), Joi.function().allow("")], // allow strings/fns
19
18
  })
20
- .and("url", "tenant", "authType")
21
- .required(),
19
+ .and("url", "tenant", "authType"),
22
20
  nodeGenModels: Joi.array()
23
21
  .items(
24
22
  Joi.object({