zudello-execute-local 1.1.43 → 1.1.45

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zudello-execute-local",
3
- "version": "1.1.43",
3
+ "version": "1.1.45",
4
4
  "description": "Zudello Execute tool for local runs",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -29,7 +29,7 @@
29
29
  "xml2js": "^0.6.2",
30
30
  "yargs": "^17.7.2",
31
31
  "zudello-integration-sdk": "^1.0.95",
32
- "zudello-integration-sdk-v1": "1.0.87"
32
+ "zudello-integration-sdk-v1": "1.0.91"
33
33
  },
34
34
  "overrides": {
35
35
  "e2b": {
@@ -1,4 +1,25 @@
1
1
  const { NodeVM, makeResolverFromLegacyOptions } = require('vm2')
2
+ const path = require('path')
3
+ const fs = require('fs')
4
+
5
+ const createSdkMock = (sdkOverridePath) => {
6
+ if (!sdkOverridePath) {
7
+ return {}
8
+ }
9
+
10
+ const absoluteSdkPath = path.resolve(sdkOverridePath)
11
+
12
+ if (!fs.existsSync(absoluteSdkPath)) {
13
+ console.warn(`[WARN] INTEGRATION_SDK_PATH does not exist: ${absoluteSdkPath}`)
14
+ return {}
15
+ }
16
+
17
+ console.log(`[INFO] Using SDK override path: ${absoluteSdkPath}`)
18
+
19
+ return {
20
+ 'zudello-integration-sdk-v1': require(absoluteSdkPath)
21
+ }
22
+ }
2
23
 
3
24
  const connectionSdkMapping = {
4
25
  netsuite: [{
@@ -149,10 +170,17 @@ const connectionSdkMapping = {
149
170
  variable: 'SunSystems',
150
171
  class: 'SunSystemsSDK',
151
172
  isExternal: true
152
- }]
173
+ }],
174
+ unleashed: [{
175
+ variable: 'Unleashed',
176
+ class: 'UnleashedSDK',
177
+ isExternal: true
178
+ }],
153
179
  }
154
180
 
155
181
  const initiateNodeVM = (dirNamePath) => {
182
+ const sdkOverridePath = process.env.INTEGRATION_SDK_PATH
183
+
156
184
  return new NodeVM({
157
185
  console: 'inherit',
158
186
  sandbox: {
@@ -170,7 +198,7 @@ const initiateNodeVM = (dirNamePath) => {
170
198
  ],
171
199
  },
172
200
  builtin: ['https'],
173
- root: dirNamePath,
201
+ root: [dirNamePath],
174
202
  import: [
175
203
  'lodash',
176
204
  'performance-now',
@@ -180,6 +208,7 @@ const initiateNodeVM = (dirNamePath) => {
180
208
  'zudello-integration-sdk-v1',
181
209
  ],
182
210
  mock: {
211
+ ...createSdkMock(sdkOverridePath),
183
212
  fs: {
184
213
  readFileSync() {
185
214
  return 'Nice try!'
@@ -208,7 +237,8 @@ const runScript = async (handler, source, object, loggerMode, dirNamePath, dirNa
208
237
 
209
238
  const classesInUse = [
210
239
  'Logger', 'Message', 'Metadata', 'Tags', 'AI', 'FileBucket', 'EDIBucket', 'Trigger', 'Properties', 'MiscHelper',
211
- 'ModelHelper', 'DatasetHelper', 'S3Client', 'Auth', 'ZudelloSDK', 'ZudelloAuthSDK', 'ZudelloStoreSDK'
240
+ 'ModelHelper', 'DatasetHelper', 'S3Client', 'Auth', 'ZudelloSDK', 'ZudelloAuthSDK', 'ZudelloStoreSDK',
241
+ 'ClickHouse', 'Checkpoint'
212
242
  ]
213
243
 
214
244
  const initAuth = `
@@ -269,6 +299,7 @@ const runScript = async (handler, source, object, loggerMode, dirNamePath, dirNa
269
299
  let File
270
300
  let EDI
271
301
  let triggerNode
302
+ let clickhouse
272
303
 
273
304
  if (auth) {
274
305
  message = new Message(auth.getApiInstance(), auth.teamUUID)
@@ -276,8 +307,22 @@ const runScript = async (handler, source, object, loggerMode, dirNamePath, dirNa
276
307
  File = new FileBucket(auth.getApiInstance(), auth.teamUUID)
277
308
  EDI = new EDIBucket(auth.getApiInstance(), auth.teamUUID)
278
309
  triggerNode = new Trigger(auth.getApiInstance(), auth.teamUUID)
310
+ clickhouse = new ClickHouse(auth.getApiInstance(), auth.teamUUID)
311
+ metadata.init({
312
+ apiInstance: auth.getApiInstance(),
313
+ apiURL: '${authData.api_url}',
314
+ teamUUID: auth.teamUUID,
315
+ triggerUUID: ${process.env.TRIGGER_UUID ? `'${process.env.TRIGGER_UUID}'` : 'null'},
316
+ connectionUUID: ${externalConnectionUUID ? `'${externalConnectionUUID}'` : 'null'}
317
+ })
279
318
  }
280
319
 
320
+ const checkpoint = new Checkpoint({
321
+ logger,
322
+ metadata,
323
+ s3Config: {}
324
+ })
325
+
281
326
  ${source}
282
327
 
283
328
  const startTime = now()
@@ -327,4 +372,4 @@ const runScript = async (handler, source, object, loggerMode, dirNamePath, dirNa
327
372
 
328
373
  module.exports = {
329
374
  runScript
330
- }
375
+ }