@coherentglobal/spark-execute-sdk 0.3.7 → 0.3.8
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 +28 -4
- package/examples/UsingBearerTokenFNAsync/index.html +1 -0
- package/examples/functionModel/index.html +217 -0
- package/examples/functionModel/models/{Model_C.zip → 0211e8f0-9988-4514-a761-9782db6700ce.zip} +0 -0
- package/examples/functionModel/node.js +2 -2
- package/package.json +3 -2
- package/src/models.js +12 -3
- package/tsconfig.json +3 -1
- package/types/models.d.ts.map +1 -1
package/dist/browser.js
CHANGED
|
@@ -6544,6 +6544,8 @@ module.exports = {
|
|
|
6544
6544
|
"use strict";
|
|
6545
6545
|
|
|
6546
6546
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
6547
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
6548
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
6547
6549
|
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
6548
6550
|
/**
|
|
6549
6551
|
*
|
|
@@ -6563,16 +6565,38 @@ var processModels = function processModels(nodegen) {
|
|
|
6563
6565
|
data: Buffer.from(nodegen.binary.data, "base64")
|
|
6564
6566
|
};
|
|
6565
6567
|
nodegen.binary = model;
|
|
6566
|
-
console.log("NODE: ", nodegen.binary);
|
|
6567
6568
|
} else {
|
|
6568
6569
|
var _model = Buffer.from(nodegen.binary, "base64");
|
|
6569
6570
|
nodegen.binary = _model;
|
|
6570
|
-
console.log("NODE: ", nodegen.binary);
|
|
6571
6571
|
}
|
|
6572
6572
|
break;
|
|
6573
6573
|
case "function":
|
|
6574
6574
|
var func = nodegen.binary;
|
|
6575
|
-
|
|
6575
|
+
if (func.constructor.name === "AsyncFunction") {
|
|
6576
|
+
(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
|
|
6577
|
+
var model;
|
|
6578
|
+
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
6579
|
+
while (1) {
|
|
6580
|
+
switch (_context.prev = _context.next) {
|
|
6581
|
+
case 0:
|
|
6582
|
+
_context.next = 2;
|
|
6583
|
+
return func();
|
|
6584
|
+
case 2:
|
|
6585
|
+
nodegen.binary = _context.sent;
|
|
6586
|
+
model = Buffer.from(nodegen.binary, "base64");
|
|
6587
|
+
nodegen.binary = model;
|
|
6588
|
+
case 5:
|
|
6589
|
+
case "end":
|
|
6590
|
+
return _context.stop();
|
|
6591
|
+
}
|
|
6592
|
+
}
|
|
6593
|
+
}, _callee);
|
|
6594
|
+
}))();
|
|
6595
|
+
} else {
|
|
6596
|
+
nodegen.binary = func();
|
|
6597
|
+
var _model2 = Buffer.from(nodegen.binary, "base64");
|
|
6598
|
+
nodegen.binary = _model2;
|
|
6599
|
+
}
|
|
6576
6600
|
default:
|
|
6577
6601
|
break;
|
|
6578
6602
|
}
|
|
@@ -6581,7 +6605,7 @@ var processModels = function processModels(nodegen) {
|
|
|
6581
6605
|
module.exports = processModels;
|
|
6582
6606
|
|
|
6583
6607
|
}).call(this)}).call(this,require("buffer").Buffer)
|
|
6584
|
-
},{"@babel/runtime/helpers/interopRequireDefault":9,"@babel/runtime/helpers/typeof":15,"buffer":24}],46:[function(require,module,exports){
|
|
6608
|
+
},{"@babel/runtime/helpers/asyncToGenerator":2,"@babel/runtime/helpers/interopRequireDefault":9,"@babel/runtime/helpers/typeof":15,"@babel/runtime/regenerator":17,"buffer":24}],46:[function(require,module,exports){
|
|
6585
6609
|
"use strict";
|
|
6586
6610
|
|
|
6587
6611
|
var Joi = require("joi");
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
6
|
+
<meta name="theme-color" content="#000000" />
|
|
7
|
+
<meta name="Demo" content="Demo App" />
|
|
8
|
+
<title>Spark Execute SDK Demo App</title>
|
|
9
|
+
|
|
10
|
+
</head>
|
|
11
|
+
<body>
|
|
12
|
+
<h1>Spark Execute SDK Demo</h1>
|
|
13
|
+
|
|
14
|
+
<br /><br />
|
|
15
|
+
<label>Payload:</label><br />
|
|
16
|
+
<textarea
|
|
17
|
+
id="myTextarea"
|
|
18
|
+
rows="20"
|
|
19
|
+
cols="100"
|
|
20
|
+
type="text"
|
|
21
|
+
onChange="handleChange()"
|
|
22
|
+
></textarea>
|
|
23
|
+
<br /><br />
|
|
24
|
+
<button id="calcButton" onClick="handleSubmit()" >Run Calc</button
|
|
25
|
+
><br /><br />
|
|
26
|
+
<label>Logs:</label><br /><br />
|
|
27
|
+
<p id="logsP"></p>
|
|
28
|
+
<br /><br />
|
|
29
|
+
<label>Response Data:</label><br /><br />
|
|
30
|
+
<textarea
|
|
31
|
+
disabled
|
|
32
|
+
rows="20"
|
|
33
|
+
cols="100"
|
|
34
|
+
type="text"
|
|
35
|
+
id="responseP"
|
|
36
|
+
></textarea>
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
<script src="../../dist/browser.js"></script>
|
|
41
|
+
<script>
|
|
42
|
+
const modelpath = "./models/0211e8f0-9988-4514-a761-9782db6700ce.zip"
|
|
43
|
+
|
|
44
|
+
const getModel = async () => {
|
|
45
|
+
const result = await fetch(modelpath)
|
|
46
|
+
.then(response => response.blob())
|
|
47
|
+
.then( blob => {
|
|
48
|
+
return blobToBase64(blob)
|
|
49
|
+
.then((base64String) => {
|
|
50
|
+
return base64String.split(",")[1];
|
|
51
|
+
});
|
|
52
|
+
})
|
|
53
|
+
return result;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const blobToBase64 = (blob) => {
|
|
57
|
+
return new Promise((resolve, _) => {
|
|
58
|
+
const reader = new FileReader();
|
|
59
|
+
reader.onloadend = () => resolve(reader.result);
|
|
60
|
+
reader.readAsDataURL(blob);
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const config = {
|
|
65
|
+
sparkEndpoint: {
|
|
66
|
+
url: "https://spark.dev.coherent.global",
|
|
67
|
+
tenant: "coherent",
|
|
68
|
+
authType: "bearerToken",
|
|
69
|
+
bearerToken: ""
|
|
70
|
+
},
|
|
71
|
+
nodeGenModels: [
|
|
72
|
+
{
|
|
73
|
+
versionId: "0211e8f0-9988-4514-a761-9782db6700ce",
|
|
74
|
+
type: "function",
|
|
75
|
+
binary: getModel,
|
|
76
|
+
metaData:{
|
|
77
|
+
"id": "7156c7a4-8a81-4d83-ac7f-a54ce02009da",
|
|
78
|
+
"url": "/docstore/api/v1/documents/versions/tokens/ItHPu2LY%2F626xeFbg%2BlSskCRy0%2FKjVp0H4uIcJmX%2BH0ehoZgRGXefIcHwR9PuX7kKHk3ywjoy6hVqkIDPWn4jAcsDN07VXdys0%2Fi4LdSxmtKGKF8IT9f%2FZZWRGWTmNWQ9SweGfiT7xc5N2%2BC9aTmlySAtACZkcdYDpsKtSuhvSJrRrSkzlt9Ra4TPBXTaokPfGR6VzK%2FMKM%2B3y3aXt3sT0P5EIRF%2BtMrVmpwmTTGva8%3D/Model_C.c1engine",
|
|
79
|
+
"EngineInformation": {
|
|
80
|
+
"FileSize": 4885,
|
|
81
|
+
"Author": "francisc.camillo@coherent.global",
|
|
82
|
+
"ProductName": "ExecuteSDK",
|
|
83
|
+
"Revision": "1.0.0",
|
|
84
|
+
"Description": null,
|
|
85
|
+
"FileMD5Hash": "3E9395DB32F0E8430BD8865DDA53753C",
|
|
86
|
+
"UniversalFileHash": null,
|
|
87
|
+
"ReleaseDate": "2022-08-23T13:06:52.786Z",
|
|
88
|
+
"ServiceName": "Model_C",
|
|
89
|
+
"NoOfInstance": 1,
|
|
90
|
+
"UploaderEmail": "francisc.camillo@coherent.global",
|
|
91
|
+
"DefaultEngineType": "NodeGen",
|
|
92
|
+
"OriginalFileName": "Model_C.xlsx",
|
|
93
|
+
"SizeOfUploadedFile": 4885,
|
|
94
|
+
"ReleaseNote": null,
|
|
95
|
+
"IsTypeScriptFile": false,
|
|
96
|
+
"IsJsSheetEngineGenerated": false,
|
|
97
|
+
"EngineUpgradeType": "minor",
|
|
98
|
+
"PublicAPI": true,
|
|
99
|
+
"FileGuid": "42efc880-91f1-4928-88cc-b29b68327f26",
|
|
100
|
+
"ServiceGuid": "bcc2f47d-0682-4d2b-9174-5b01f903ee6b",
|
|
101
|
+
"ServiceVersionGuid": "0211e8f0-9988-4514-a761-9782db6700ce",
|
|
102
|
+
"BaseUrl": "https://excel.dev.coherent.global",
|
|
103
|
+
"Tenant": "coherent",
|
|
104
|
+
"AllowToStoreHistory": true,
|
|
105
|
+
"CalcMode": "AUTO",
|
|
106
|
+
"ForceInputsWriteBeforeCalcModeChanges": true,
|
|
107
|
+
"Provenance": null,
|
|
108
|
+
"VersionLabel": "Model_C",
|
|
109
|
+
"ExplainerType": "",
|
|
110
|
+
"IsXParameter": false,
|
|
111
|
+
"XParameterSetVersionId": "",
|
|
112
|
+
"VersionUpgradeAssert": "OFF"
|
|
113
|
+
},
|
|
114
|
+
"XInputTable": [
|
|
115
|
+
{
|
|
116
|
+
"Input Name": "Input",
|
|
117
|
+
"Description": null,
|
|
118
|
+
"Address": "C2"
|
|
119
|
+
}
|
|
120
|
+
],
|
|
121
|
+
"XOutputTable": [
|
|
122
|
+
{
|
|
123
|
+
"Output Name": "Output1",
|
|
124
|
+
"Description": null,
|
|
125
|
+
"Address": "C3"
|
|
126
|
+
}
|
|
127
|
+
],
|
|
128
|
+
"FormsService": null,
|
|
129
|
+
"StaticService": null,
|
|
130
|
+
"VersionId": "0211e8f0-9988-4514-a761-9782db6700ce"
|
|
131
|
+
,
|
|
132
|
+
"created": "2022-08-23T13:06:55.017422Z",
|
|
133
|
+
"effectiveStartDate": "2009-12-31T16:00:00Z",
|
|
134
|
+
"effectiveEndDate": "2119-12-31T16:00:00Z",
|
|
135
|
+
"path": "/products/ExecuteSDK/productfactory/engines/Model_C/Model_C.c1engine",
|
|
136
|
+
"privacyLevel": "Private",
|
|
137
|
+
"dateTime1": "2009-12-31T16:00:00Z",
|
|
138
|
+
"dateTime2": "2119-12-31T16:00:00Z",
|
|
139
|
+
"status1": "nodegen",
|
|
140
|
+
"status2": "Model_C.xlsx",
|
|
141
|
+
"email1": null,
|
|
142
|
+
"email2": null,
|
|
143
|
+
"amount1": 4885,
|
|
144
|
+
"amount2": 9184,
|
|
145
|
+
"amount3": null,
|
|
146
|
+
"type": "EngineDocument",
|
|
147
|
+
"policyNumber": "francisc.camillo@coherent.global",
|
|
148
|
+
"name1": "Model_C",
|
|
149
|
+
"name2": "Model_C.c1engine",
|
|
150
|
+
"otherString1": "1.0.0",
|
|
151
|
+
"otherString2": "EngineFile",
|
|
152
|
+
"referenceId": "ExecuteSDK~Model_C.c1engine",
|
|
153
|
+
"disposition": null,
|
|
154
|
+
"productName": "ExecuteSDK",
|
|
155
|
+
"content": null,
|
|
156
|
+
"latestVersionId": "0211e8f0-9988-4514-a761-9782db6700ce"
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
]
|
|
160
|
+
}
|
|
161
|
+
const dataInput2 = {
|
|
162
|
+
"request_data": {
|
|
163
|
+
"inputs": {
|
|
164
|
+
"Input": 1
|
|
165
|
+
}
|
|
166
|
+
},
|
|
167
|
+
"request_meta": {
|
|
168
|
+
"version_id": "0211e8f0-9988-4514-a761-9782db6700ce",
|
|
169
|
+
"call_purpose": "Spark - API Tester",
|
|
170
|
+
"source_system": "SPARK",
|
|
171
|
+
"correlation_id": "",
|
|
172
|
+
"requested_output": null,
|
|
173
|
+
"service_category": ""
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
document.getElementById("myTextarea").value = JSON.stringify(dataInput2);
|
|
178
|
+
|
|
179
|
+
var spark = new Spark(config);
|
|
180
|
+
console.log("INITIALIZE SPARK", spark)
|
|
181
|
+
|
|
182
|
+
async function handleSubmit() {
|
|
183
|
+
const input = document.getElementById("myTextarea").value
|
|
184
|
+
const payload = JSON.parse(input);
|
|
185
|
+
const start = new Date();
|
|
186
|
+
try {
|
|
187
|
+
let res = await execute(payload);
|
|
188
|
+
const consumed = new Date - start;
|
|
189
|
+
document.getElementById(
|
|
190
|
+
"logsP"
|
|
191
|
+
).innerHTML = `\nComputation Time Consumed: ${consumed} ms\n`;
|
|
192
|
+
document.getElementById("responseP").innerHTML = `\n${JSON.stringify(
|
|
193
|
+
res,
|
|
194
|
+
null,
|
|
195
|
+
2
|
|
196
|
+
)}\n`;
|
|
197
|
+
console.log("RES", res)
|
|
198
|
+
} catch (err) {
|
|
199
|
+
console.log("ERROR", err)
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
// load();
|
|
203
|
+
async function execute(input) {
|
|
204
|
+
let result = await spark.execute(input);
|
|
205
|
+
return result;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
function handleChange() {
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
</script>
|
|
213
|
+
</body>
|
|
214
|
+
|
|
215
|
+
</html>
|
|
216
|
+
|
|
217
|
+
|
package/examples/functionModel/models/{Model_C.zip → 0211e8f0-9988-4514-a761-9782db6700ce.zip}
RENAMED
|
File without changes
|
|
@@ -4,7 +4,7 @@ const Spark = require("../../src/node.js");
|
|
|
4
4
|
const modelC = require("./modelCInput.json");
|
|
5
5
|
|
|
6
6
|
const fs = require("fs");
|
|
7
|
-
const location = "./models/
|
|
7
|
+
const location = "./models/0211e8f0-9988-4514-a761-9782db6700ce.zip";
|
|
8
8
|
|
|
9
9
|
const file = fs.readFileSync(location);
|
|
10
10
|
|
|
@@ -13,7 +13,7 @@ const data = file.toString("base64");
|
|
|
13
13
|
const buffer = Buffer.from(data, "base64");
|
|
14
14
|
|
|
15
15
|
const getModel = () => {
|
|
16
|
-
return
|
|
16
|
+
return data;
|
|
17
17
|
};
|
|
18
18
|
|
|
19
19
|
const config = {
|
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coherentglobal/spark-execute-sdk",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.8",
|
|
4
4
|
"description": "",
|
|
5
|
-
"
|
|
5
|
+
"main": "src/node.js",
|
|
6
6
|
"browser": "dist/browser.js",
|
|
7
|
+
"types": "types/node.d.ts",
|
|
7
8
|
"scripts": {
|
|
8
9
|
"build:types": "tsc --declaration",
|
|
9
10
|
"bundle:full": "browserify src/browser.js --standalone Spark > dist/browser.js",
|
package/src/models.js
CHANGED
|
@@ -17,16 +17,25 @@ const processModels = (nodegen) => {
|
|
|
17
17
|
};
|
|
18
18
|
|
|
19
19
|
nodegen.binary = model;
|
|
20
|
-
console.log("NODE: ", nodegen.binary);
|
|
21
20
|
} else {
|
|
22
21
|
const model = Buffer.from(nodegen.binary, "base64");
|
|
23
22
|
nodegen.binary = model;
|
|
24
|
-
console.log("NODE: ", nodegen.binary);
|
|
25
23
|
}
|
|
26
24
|
break;
|
|
27
25
|
case "function":
|
|
28
26
|
const func = nodegen.binary;
|
|
29
|
-
|
|
27
|
+
|
|
28
|
+
if (func.constructor.name === "AsyncFunction") {
|
|
29
|
+
(async () => {
|
|
30
|
+
nodegen.binary = await func();
|
|
31
|
+
const model = Buffer.from(nodegen.binary, "base64");
|
|
32
|
+
nodegen.binary = model;
|
|
33
|
+
})();
|
|
34
|
+
} else {
|
|
35
|
+
nodegen.binary = func();
|
|
36
|
+
const model = Buffer.from(nodegen.binary, "base64");
|
|
37
|
+
nodegen.binary = model;
|
|
38
|
+
}
|
|
30
39
|
default:
|
|
31
40
|
break;
|
|
32
41
|
}
|
package/tsconfig.json
CHANGED
|
@@ -31,7 +31,9 @@
|
|
|
31
31
|
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
|
|
32
32
|
// "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
|
|
33
33
|
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
|
|
34
|
-
|
|
34
|
+
"typeRoots": [
|
|
35
|
+
"./types/**/*"
|
|
36
|
+
] /* Specify multiple folders that act like './node_modules/@types'. */,
|
|
35
37
|
// "types": [], /* Specify type package names to be included without being referenced in a source file. */
|
|
36
38
|
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
|
|
37
39
|
// "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */
|
package/types/models.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"models.d.ts","sourceRoot":"","sources":["../src/models.js"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"models.d.ts","sourceRoot":"","sources":["../src/models.js"],"names":[],"mappings":";AAAA;;;;GAIG;AACH,wCAHW,MAAM,UAyChB"}
|