@coherentglobal/spark-execute-sdk 0.3.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.
- package/.babelrc +12 -0
- package/.eslintrc.json +21 -0
- package/.github/workflows/build-publish.yml +46 -0
- package/.prettierrc +0 -0
- package/README.md +92 -0
- package/dist/browser.js +6925 -0
- package/examples/UsingBearerTokenFNAsync/bearerTokenExample.js +22 -0
- package/examples/UsingBearerTokenFNAsync/config.js +88 -0
- package/examples/UsingBearerTokenFNAsync/index.html +205 -0
- package/examples/UsingBearerTokenFNAsync/modelCInput.json +15 -0
- package/examples/UsingBearerTokenFNAsync/models/Model_C.zip +0 -0
- package/examples/UsingBearerTokenString/bearerTokenExample.js +22 -0
- package/examples/UsingBearerTokenString/config.js +182 -0
- package/examples/UsingBearerTokenString/index.html +191 -0
- package/examples/UsingBearerTokenString/modelCInput.json +15 -0
- package/examples/UsingBearerTokenString/models/Model_C.zip +0 -0
- package/examples/UsingSyntheticKeyFNAsync/bearerTokenExample.js +22 -0
- package/examples/UsingSyntheticKeyFNAsync/config.js +195 -0
- package/examples/UsingSyntheticKeyFNAsync/index.html +205 -0
- package/examples/UsingSyntheticKeyFNAsync/modelCInput.json +15 -0
- package/examples/UsingSyntheticKeyFNAsync/models/Model_C.zip +0 -0
- package/examples/UsingSyntheticKeyString/bearerTokenExample.js +22 -0
- package/examples/UsingSyntheticKeyString/config.js +181 -0
- package/examples/UsingSyntheticKeyString/index.html +192 -0
- package/examples/UsingSyntheticKeyString/modelCInput.json +15 -0
- package/examples/UsingSyntheticKeyString/models/Model_C.zip +0 -0
- package/examples/asyncFunctionModel/config.js +96 -0
- package/examples/asyncFunctionModel/modelCInput.json +15 -0
- package/examples/asyncFunctionModel/models/Model_C.zip +0 -0
- package/examples/asyncFunctionModel/node.js +125 -0
- package/examples/asyncFunctionModel/tool.js +17 -0
- package/examples/base64Model/config.js +96 -0
- package/examples/base64Model/modelCInput.json +15 -0
- package/examples/base64Model/models/Model_C.zip +0 -0
- package/examples/base64Model/node.js +125 -0
- package/examples/base64Model/tool.js +17 -0
- package/examples/base64modelBrowser/config.js +96 -0
- package/examples/base64modelBrowser/index.html +194 -0
- package/examples/base64modelBrowser/modelCInput.json +15 -0
- package/examples/base64modelBrowser/models/Model_C.zip +0 -0
- package/examples/base64modelBrowser/models/base64model.txt +1 -0
- package/examples/base64modelBrowser/node.js +126 -0
- package/examples/base64modelBrowser/tool.js +17 -0
- package/examples/binary/config.js +96 -0
- package/examples/binary/modelCInput.json +15 -0
- package/examples/binary/models/Model_C.zip +0 -0
- package/examples/binary/models/binary.txt +1 -0
- package/examples/binary/node.js +131 -0
- package/examples/binary/tool.js +18 -0
- package/examples/functionModel/config.js +96 -0
- package/examples/functionModel/modelCInput.json +15 -0
- package/examples/functionModel/models/Model_C.zip +0 -0
- package/examples/functionModel/node.js +138 -0
- package/examples/functionModel/tool.js +17 -0
- package/examples/nodejs/node.js +250 -0
- package/examples/nodejs/test_models/Archive.zip +0 -0
- package/examples/nodejs/test_models/BlackScholes.zip +0 -0
- package/examples/nodejs/test_models/Model_A.zip +0 -0
- package/examples/nodejs/test_models/Par7.zip +0 -0
- package/package.json +79 -0
- package/src/browser.js +198 -0
- package/src/error.js +87 -0
- package/src/helpers/utils.js +79 -0
- package/src/logger.js +3 -0
- package/src/models.js +26 -0
- package/src/node.js +254 -0
- package/src/resolver/externalResolver.js +118 -0
- package/src/services/entityStore.js +260 -0
- package/src/services/resolver.js +134 -0
- package/src/services/spark.js +80 -0
- package/src/tenant_resolver/externalResolver_coherent.js +118 -0
- package/src/tenant_resolver/externalResolver_test.js +118 -0
- package/src/validate.js +38 -0
- package/test/config.test.js +124 -0
- package/test/mock-data/dummy-config.json +102 -0
- package/test/mock-data/valid.json +21 -0
- package/test/spark-sdk.test.js +28 -0
- package/tsconfig.json +105 -0
- package/types/browser.d.ts +72 -0
- package/types/browser.d.ts.map +1 -0
- package/types/error.d.ts +42 -0
- package/types/error.d.ts.map +1 -0
- package/types/helpers/utils.d.ts +11 -0
- package/types/helpers/utils.d.ts.map +1 -0
- package/types/logger.d.ts +3 -0
- package/types/logger.d.ts.map +1 -0
- package/types/models.d.ts +8 -0
- package/types/models.d.ts.map +1 -0
- package/types/node.d.ts +78 -0
- package/types/node.d.ts.map +1 -0
- package/types/resolver/externalResolver.d.ts +2 -0
- package/types/resolver/externalResolver.d.ts.map +1 -0
- package/types/services/entityStore.d.ts +51 -0
- package/types/services/entityStore.d.ts.map +1 -0
- package/types/services/resolver.d.ts +20 -0
- package/types/services/resolver.d.ts.map +1 -0
- package/types/services/spark.d.ts +6 -0
- package/types/services/spark.d.ts.map +1 -0
- package/types/tenant_resolver/externalResolver_coherent.d.ts +2 -0
- package/types/tenant_resolver/externalResolver_coherent.d.ts.map +1 -0
- package/types/tenant_resolver/externalResolver_test.d.ts +2 -0
- package/types/tenant_resolver/externalResolver_test.d.ts.map +1 -0
- package/types/validate.d.ts +4 -0
- package/types/validate.d.ts.map +1 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"request_data": {
|
|
3
|
+
"inputs": {
|
|
4
|
+
"Input": 1
|
|
5
|
+
}
|
|
6
|
+
},
|
|
7
|
+
"request_meta": {
|
|
8
|
+
"version_id": "0211e8f0-9988-4514-a761-9782db6700ce",
|
|
9
|
+
"call_purpose": "Spark - API Tester",
|
|
10
|
+
"source_system": "SPARK",
|
|
11
|
+
"correlation_id": "",
|
|
12
|
+
"requested_output": null,
|
|
13
|
+
"service_category": ""
|
|
14
|
+
}
|
|
15
|
+
}
|
|
Binary file
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
console.log("SPARK START: ");
|
|
2
|
+
|
|
3
|
+
const Spark = require("../../src/node.js");
|
|
4
|
+
const modelC = require("./modelCInput.json");
|
|
5
|
+
|
|
6
|
+
const fs = require("fs");
|
|
7
|
+
const location = "./models/Model_C.zip";
|
|
8
|
+
|
|
9
|
+
const file = fs.readFileSync(location);
|
|
10
|
+
|
|
11
|
+
// generate base64
|
|
12
|
+
const data = file.toString("base64");
|
|
13
|
+
const buffer = Buffer.from(data, "base64");
|
|
14
|
+
|
|
15
|
+
const getModel = () => {
|
|
16
|
+
return buffer;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const config = {
|
|
20
|
+
sparkEndpoint: {
|
|
21
|
+
url: "https://spark.dev.coherent.global",
|
|
22
|
+
tenant: "coherent",
|
|
23
|
+
authType: "bearerToken",
|
|
24
|
+
bearerToken: "",
|
|
25
|
+
},
|
|
26
|
+
nodeGenModels: [
|
|
27
|
+
{
|
|
28
|
+
versionId: "0211e8f0-9988-4514-a761-9782db6700ce",
|
|
29
|
+
type: "function",
|
|
30
|
+
binary: getModel,
|
|
31
|
+
metaData: {
|
|
32
|
+
id: "7156c7a4-8a81-4d83-ac7f-a54ce02009da",
|
|
33
|
+
url: "/docstore/api/v1/documents/versions/tokens/ItHPu2LY%2F626xeFbg%2BlSskCRy0%2FKjVp0H4uIcJmX%2BH0ehoZgRGXefIcHwR9PuX7kKHk3ywjoy6hVqkIDPWn4jAcsDN07VXdys0%2Fi4LdSxmtKGKF8IT9f%2FZZWRGWTmNWQ9SweGfiT7xc5N2%2BC9aTmlySAtACZkcdYDpsKtSuhvSJrRrSkzlt9Ra4TPBXTaokPfGR6VzK%2FMKM%2B3y3aXt3sT0P5EIRF%2BtMrVmpwmTTGva8%3D/Model_C.c1engine",
|
|
34
|
+
EngineInformation: {
|
|
35
|
+
FileSize: 4885,
|
|
36
|
+
Author: "francisc.camillo@coherent.global",
|
|
37
|
+
ProductName: "ExecuteSDK",
|
|
38
|
+
Revision: "1.0.0",
|
|
39
|
+
Description: null,
|
|
40
|
+
FileMD5Hash: "3E9395DB32F0E8430BD8865DDA53753C",
|
|
41
|
+
UniversalFileHash: null,
|
|
42
|
+
ReleaseDate: "2022-08-23T13:06:52.786Z",
|
|
43
|
+
ServiceName: "Model_C",
|
|
44
|
+
NoOfInstance: 1,
|
|
45
|
+
UploaderEmail: "francisc.camillo@coherent.global",
|
|
46
|
+
DefaultEngineType: "NodeGen",
|
|
47
|
+
OriginalFileName: "Model_C.xlsx",
|
|
48
|
+
SizeOfUploadedFile: 4885,
|
|
49
|
+
ReleaseNote: null,
|
|
50
|
+
IsTypeScriptFile: false,
|
|
51
|
+
IsJsSheetEngineGenerated: false,
|
|
52
|
+
EngineUpgradeType: "minor",
|
|
53
|
+
PublicAPI: true,
|
|
54
|
+
FileGuid: "42efc880-91f1-4928-88cc-b29b68327f26",
|
|
55
|
+
ServiceGuid: "bcc2f47d-0682-4d2b-9174-5b01f903ee6b",
|
|
56
|
+
ServiceVersionGuid: "0211e8f0-9988-4514-a761-9782db6700ce",
|
|
57
|
+
BaseUrl: "https://excel.dev.coherent.global",
|
|
58
|
+
Tenant: "coherent",
|
|
59
|
+
AllowToStoreHistory: true,
|
|
60
|
+
CalcMode: "AUTO",
|
|
61
|
+
ForceInputsWriteBeforeCalcModeChanges: true,
|
|
62
|
+
Provenance: null,
|
|
63
|
+
VersionLabel: "Model_C",
|
|
64
|
+
ExplainerType: "",
|
|
65
|
+
IsXParameter: false,
|
|
66
|
+
XParameterSetVersionId: "",
|
|
67
|
+
VersionUpgradeAssert: "OFF",
|
|
68
|
+
},
|
|
69
|
+
XInputTable: [
|
|
70
|
+
{
|
|
71
|
+
"Input Name": "Input",
|
|
72
|
+
Description: null,
|
|
73
|
+
Address: "C2",
|
|
74
|
+
},
|
|
75
|
+
],
|
|
76
|
+
XOutputTable: [
|
|
77
|
+
{
|
|
78
|
+
"Output Name": "Output1",
|
|
79
|
+
Description: null,
|
|
80
|
+
Address: "C3",
|
|
81
|
+
},
|
|
82
|
+
],
|
|
83
|
+
FormsService: null,
|
|
84
|
+
StaticService: null,
|
|
85
|
+
VersionId: "0211e8f0-9988-4514-a761-9782db6700ce",
|
|
86
|
+
created: "2022-08-23T13:06:55.017422Z",
|
|
87
|
+
effectiveStartDate: "2009-12-31T16:00:00Z",
|
|
88
|
+
effectiveEndDate: "2119-12-31T16:00:00Z",
|
|
89
|
+
path: "/products/ExecuteSDK/productfactory/engines/Model_C/Model_C.c1engine",
|
|
90
|
+
privacyLevel: "Private",
|
|
91
|
+
dateTime1: "2009-12-31T16:00:00Z",
|
|
92
|
+
dateTime2: "2119-12-31T16:00:00Z",
|
|
93
|
+
status1: "nodegen",
|
|
94
|
+
status2: "Model_C.xlsx",
|
|
95
|
+
email1: null,
|
|
96
|
+
email2: null,
|
|
97
|
+
amount1: 4885,
|
|
98
|
+
amount2: 9184,
|
|
99
|
+
amount3: null,
|
|
100
|
+
type: "EngineDocument",
|
|
101
|
+
policyNumber: "francisc.camillo@coherent.global",
|
|
102
|
+
name1: "Model_C",
|
|
103
|
+
name2: "Model_C.c1engine",
|
|
104
|
+
otherString1: "1.0.0",
|
|
105
|
+
otherString2: "EngineFile",
|
|
106
|
+
referenceId: "ExecuteSDK~Model_C.c1engine",
|
|
107
|
+
disposition: null,
|
|
108
|
+
productName: "ExecuteSDK",
|
|
109
|
+
content: null,
|
|
110
|
+
latestVersionId: "0211e8f0-9988-4514-a761-9782db6700ce",
|
|
111
|
+
},
|
|
112
|
+
},
|
|
113
|
+
],
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
let spark;
|
|
117
|
+
try {
|
|
118
|
+
spark = new Spark(config);
|
|
119
|
+
} catch (err) {
|
|
120
|
+
console.log("ERR: ", err);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
const modelToTest = "0211e8f0-9988-4514-a761-9782db6700ce"; // Model C
|
|
124
|
+
const dataInput = modelC;
|
|
125
|
+
|
|
126
|
+
async function execute() {
|
|
127
|
+
console.log("Reached");
|
|
128
|
+
try {
|
|
129
|
+
let result = await spark.execute(dataInput);
|
|
130
|
+
|
|
131
|
+
console.log("Final Result", result);
|
|
132
|
+
return result;
|
|
133
|
+
} catch (err) {
|
|
134
|
+
console.log("No model found", err);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
(async () => await execute())();
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const fs = require('fs')
|
|
2
|
+
const location = "./models/Model_C.zip"
|
|
3
|
+
|
|
4
|
+
const file = fs.readFileSync(location)
|
|
5
|
+
|
|
6
|
+
// generate base64
|
|
7
|
+
const data = file.toString('base64')
|
|
8
|
+
const buffer = Buffer.from(data, 'base64')
|
|
9
|
+
const uint = new Uint8Array(buffer)
|
|
10
|
+
console.log(uint)
|
|
11
|
+
// fs.writeFileSync('./models/base64model.txt', data)
|
|
12
|
+
|
|
13
|
+
// generate blob
|
|
14
|
+
// const blob = atob(data)
|
|
15
|
+
// fs.writeFileSync('./models/blobmodel.txt', blob)
|
|
16
|
+
|
|
17
|
+
|