@coherentglobal/spark-execute-sdk 0.4.0 → 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 +4 -4
- package/package.json +1 -1
- package/src/browser.js +6 -6
- package/src/node.js +22 -25
- package/src/validate.js +1 -3
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.
|
|
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.
|
|
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.
|
|
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")
|
|
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
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.
|
|
105
|
+
new Date(metaData.EffectiveStartDate) &&
|
|
106
106
|
new Date(requestMeta.transaction_date) <=
|
|
107
|
-
new Date(metaData.
|
|
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.
|
|
136
|
+
new Date(metaData.EffectiveStartDate) &&
|
|
137
137
|
new Date(requestMeta.transaction_date) <=
|
|
138
|
-
new Date(metaData.
|
|
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.
|
|
170
|
+
new Date(metaData.EffectiveStartDate) &&
|
|
171
171
|
new Date(requestMeta.transaction_date) <=
|
|
172
|
-
new Date(metaData.
|
|
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 =
|
|
43
|
+
this.tenant = "";
|
|
44
44
|
/**
|
|
45
45
|
* @private
|
|
46
46
|
*/
|
|
47
|
-
this.authType =
|
|
47
|
+
this.authType = "";
|
|
48
48
|
/**
|
|
49
49
|
* @private
|
|
50
50
|
*/
|
|
51
|
-
this.token =
|
|
51
|
+
this.token = "";
|
|
52
52
|
/**
|
|
53
53
|
* @private
|
|
54
54
|
*/
|
|
55
|
-
this.url =
|
|
55
|
+
this.url = "";
|
|
56
56
|
/**
|
|
57
57
|
* @private
|
|
58
58
|
*/
|
|
@@ -61,10 +61,6 @@ 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
|
|
@@ -74,8 +70,7 @@ class Spark {
|
|
|
74
70
|
/**
|
|
75
71
|
* @private
|
|
76
72
|
*/
|
|
77
|
-
|
|
78
|
-
this.priority = ["model", "onlineEndpoint"];
|
|
73
|
+
this.priority = ["model"];
|
|
79
74
|
}
|
|
80
75
|
|
|
81
76
|
/**
|
|
@@ -136,9 +131,9 @@ class Spark {
|
|
|
136
131
|
({ metaData }) =>
|
|
137
132
|
metaData.EngineInformation.ServiceName === requestMeta.servicename &&
|
|
138
133
|
new Date(requestMeta.transaction_date) >=
|
|
139
|
-
new Date(metaData.
|
|
134
|
+
new Date(metaData.EffectiveStartDate) &&
|
|
140
135
|
new Date(requestMeta.transaction_date) <=
|
|
141
|
-
new Date(metaData.
|
|
136
|
+
new Date(metaData.EffectiveEndDate)
|
|
142
137
|
);
|
|
143
138
|
|
|
144
139
|
if (model.length > 1) {
|
|
@@ -167,9 +162,9 @@ class Spark {
|
|
|
167
162
|
({ metaData }) =>
|
|
168
163
|
metaData.EngineInformation.ServiceGuid === requestMeta.service_id &&
|
|
169
164
|
new Date(requestMeta.transaction_date) >=
|
|
170
|
-
new Date(metaData.
|
|
165
|
+
new Date(metaData.EffectiveStartDate) &&
|
|
171
166
|
new Date(requestMeta.transaction_date) <=
|
|
172
|
-
new Date(metaData.
|
|
167
|
+
new Date(metaData.EffectiveEndDate)
|
|
173
168
|
);
|
|
174
169
|
|
|
175
170
|
if (model.length > 1) {
|
|
@@ -201,9 +196,9 @@ class Spark {
|
|
|
201
196
|
metaData.EngineInformation.ProductName === folder &&
|
|
202
197
|
metaData.EngineInformation.ServiceName === service &&
|
|
203
198
|
new Date(requestMeta.transaction_date) >=
|
|
204
|
-
new Date(metaData.
|
|
199
|
+
new Date(metaData.EffectiveStartDate) &&
|
|
205
200
|
new Date(requestMeta.transaction_date) <=
|
|
206
|
-
new Date(metaData.
|
|
201
|
+
new Date(metaData.EffectiveEndDate)
|
|
207
202
|
);
|
|
208
203
|
|
|
209
204
|
if (model.length > 1) {
|
|
@@ -267,9 +262,9 @@ class Spark {
|
|
|
267
262
|
|
|
268
263
|
let response;
|
|
269
264
|
response = await lookup[this.priority[0]](input, versionID, this);
|
|
270
|
-
if (response instanceof Error) {
|
|
271
|
-
|
|
272
|
-
}
|
|
265
|
+
// if (response instanceof Error) {
|
|
266
|
+
// response = await lookup[this.priority[1]](input, versionID, this);
|
|
267
|
+
// }
|
|
273
268
|
|
|
274
269
|
return response;
|
|
275
270
|
}
|
|
@@ -292,7 +287,7 @@ class Spark {
|
|
|
292
287
|
}
|
|
293
288
|
)
|
|
294
289
|
const data = serializeObject.serialize({...this.config, externalUuid: this.externalUuid})
|
|
295
|
-
template = template.replace("%%config_to_replace%%",
|
|
290
|
+
template = template.replace("%%config_to_replace%%", Buffer.from(data).toString('base64'))
|
|
296
291
|
fs.writeFileSync(filePath, template)
|
|
297
292
|
return require.resolve(filePath)
|
|
298
293
|
}
|
|
@@ -322,23 +317,25 @@ class Spark {
|
|
|
322
317
|
try {
|
|
323
318
|
const model = ds._findModel(input.request_meta);
|
|
324
319
|
|
|
320
|
+
const versionId = versionID || (model && model?.versionId)
|
|
321
|
+
|
|
325
322
|
logger.info({
|
|
326
323
|
EventType: "ExecuteModel",
|
|
327
|
-
TextMessage: `Execute uuid: ${
|
|
324
|
+
TextMessage: `Execute uuid: ${versionId}`,
|
|
328
325
|
});
|
|
329
326
|
if (!(registry instanceof WasmRunner)) {
|
|
330
327
|
registry = new WasmRunner(undefined, ds.externalResolver, "");
|
|
331
328
|
}
|
|
332
329
|
|
|
333
|
-
if (!registry.isExist(
|
|
330
|
+
if (!registry.isExist(versionId)) {
|
|
334
331
|
await registry.append({
|
|
335
|
-
id:
|
|
332
|
+
id: versionId,
|
|
336
333
|
url: model?.binary || "",
|
|
337
334
|
// size,
|
|
338
335
|
});
|
|
339
336
|
}
|
|
340
337
|
|
|
341
|
-
let result = await registry.execute(input,
|
|
338
|
+
let result = await registry.execute(input, versionId);
|
|
342
339
|
|
|
343
340
|
return result;
|
|
344
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({
|