@coherentglobal/spark-execute-sdk 0.8.3 → 0.8.5
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 +425 -100
- package/dist/browser.js +2530 -5625
- package/package.json +31 -6
- package/src/browser.js +59 -10
- package/src/findModels.js +6 -6
- package/src/helpers/utils.js +5 -2
- package/src/node.js +51 -2
- package/types/browser.d.ts +5 -0
- package/types/browser.d.ts.map +1 -1
- package/types/helpers/utils.d.ts +2 -2
- package/types/helpers/utils.d.ts.map +1 -1
- package/types/logger.d.ts +2 -1
- package/types/node.d.ts +4 -0
- package/types/node.d.ts.map +1 -1
- package/src/services/entityStore.js +0 -271
- package/src/services/spark.js +0 -80
- package/types/services/entityStore.d.ts +0 -51
- package/types/services/entityStore.d.ts.map +0 -1
- package/types/services/spark.d.ts +0 -6
- package/types/services/spark.d.ts.map +0 -1
package/src/services/spark.js
DELETED
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
const got = require("got");
|
|
2
|
-
const fs = require("fs");
|
|
3
|
-
const path = require("path");
|
|
4
|
-
// const { isPathExist } = require("../utils");
|
|
5
|
-
const config = require("../config");
|
|
6
|
-
|
|
7
|
-
const DEFAULT_CACHE = 600; // 5 minutes
|
|
8
|
-
const tenantConfigCache = new Map();
|
|
9
|
-
|
|
10
|
-
const configDir = path.join(__dirname, "/tenant_config");
|
|
11
|
-
|
|
12
|
-
async function fetchTenantConfig(tenant, authHeaders) {
|
|
13
|
-
/* istanbul ignore next */
|
|
14
|
-
// if (!(await isPathExist(configDir))) {
|
|
15
|
-
// await fs.promises.mkdir(configDir, { mode: 0o750 });
|
|
16
|
-
// }
|
|
17
|
-
|
|
18
|
-
const { sparkUrl } = config();
|
|
19
|
-
|
|
20
|
-
try {
|
|
21
|
-
const key = tenant;
|
|
22
|
-
if (tenantConfigCache.has(key)) {
|
|
23
|
-
const cache = tenantConfigCache.get(key);
|
|
24
|
-
|
|
25
|
-
if (cache.expire_at > Date.now()) {
|
|
26
|
-
return;
|
|
27
|
-
} else {
|
|
28
|
-
/* istanbul ignore next */
|
|
29
|
-
tenantConfigCache.delete(key);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const options = {
|
|
34
|
-
headers: authHeaders,
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
const url = new URL(
|
|
38
|
-
"/api/v1/config/GetAllSparkConfiguration",
|
|
39
|
-
sparkUrl
|
|
40
|
-
).toString();
|
|
41
|
-
|
|
42
|
-
const response = await got.get(url, options).json();
|
|
43
|
-
|
|
44
|
-
const { data } = response;
|
|
45
|
-
|
|
46
|
-
const { ApiDetails: apidetails } = data;
|
|
47
|
-
|
|
48
|
-
const cache = {
|
|
49
|
-
expire_at: Date.now() + DEFAULT_CACHE,
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
tenantConfigCache.set(key, cache);
|
|
53
|
-
await fs.promises.writeFile(
|
|
54
|
-
path.join(configDir, `${tenant}_config.json`),
|
|
55
|
-
JSON.stringify({
|
|
56
|
-
config: {
|
|
57
|
-
apidetails,
|
|
58
|
-
},
|
|
59
|
-
})
|
|
60
|
-
);
|
|
61
|
-
return cache;
|
|
62
|
-
} catch (err) {
|
|
63
|
-
throw new Error(err.message);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
async function getConfig(tenant) {
|
|
68
|
-
const configPath = path.join(configDir, `${tenant}_config.json`);
|
|
69
|
-
if (fs.existsSync(configPath)) {
|
|
70
|
-
return JSON.parse(await fs.promises.readFile(configPath));
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
throw new Error(`Tenant: ${tenant} config is empty`);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
module.exports = {
|
|
77
|
-
fetchTenantConfig,
|
|
78
|
-
getConfig,
|
|
79
|
-
configDir,
|
|
80
|
-
};
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Fetch documnet using Document Version Id.
|
|
3
|
-
*
|
|
4
|
-
* @param {String} versionUuid
|
|
5
|
-
* Document Version Id.
|
|
6
|
-
*
|
|
7
|
-
* @param {String} token
|
|
8
|
-
* Keycloak token.
|
|
9
|
-
*
|
|
10
|
-
* @returns
|
|
11
|
-
*/
|
|
12
|
-
export function getDocumentByVersionId(versionUuid: string, token: string): Promise<any>;
|
|
13
|
-
/**
|
|
14
|
-
* Fetch Temporary file.
|
|
15
|
-
*
|
|
16
|
-
* @param {String} url
|
|
17
|
-
* Temporary blob download url.
|
|
18
|
-
*
|
|
19
|
-
* @param {String} token
|
|
20
|
-
* Keycloak Token.
|
|
21
|
-
*
|
|
22
|
-
* @returns {Buffer}
|
|
23
|
-
*/
|
|
24
|
-
export function getFromTempUrl(url: string, headers: any): Buffer;
|
|
25
|
-
/**
|
|
26
|
-
* Save Temporary file.
|
|
27
|
-
*
|
|
28
|
-
* @param {String} versionUuid
|
|
29
|
-
* Document version ID.
|
|
30
|
-
*
|
|
31
|
-
* @param {Buffer} content
|
|
32
|
-
* Temporary file content.
|
|
33
|
-
*
|
|
34
|
-
* @param {String} token
|
|
35
|
-
* Keycloak token.
|
|
36
|
-
*
|
|
37
|
-
* @returns
|
|
38
|
-
*/
|
|
39
|
-
export function downloadModelFile(url: any, versionUuid: string, headers: any): Promise<string>;
|
|
40
|
-
export function downloadModel(versionUuid: any, token: any): Promise<string>;
|
|
41
|
-
export function getParameterSet(versionUuid: any, tenant: any, token: any): Promise<any>;
|
|
42
|
-
export function getParameterSetById(versionUuid: any, token: any, tenant?: string): Promise<any>;
|
|
43
|
-
/**
|
|
44
|
-
*
|
|
45
|
-
* @param {*} folder
|
|
46
|
-
* @param {*} model
|
|
47
|
-
*
|
|
48
|
-
* https://excel.dev.coherent.global/api/filemanager/GetFolderDocs?folderPath=/products/FJ%20Test/productfactory/engines/DownstreamService_example
|
|
49
|
-
*/
|
|
50
|
-
export function getModelViaFolder(folder: any, model: any, headers: any): Promise<string>;
|
|
51
|
-
//# sourceMappingURL=entityStore.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
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 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"spark.d.ts","sourceRoot":"","sources":["../../src/services/spark.js"],"names":[],"mappings":"AAWA;;eAqDC;AAED,qDAOC;AAhED,+BAAyD"}
|