zudello-integration-sdk 1.0.87 → 1.0.89

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-integration-sdk",
3
- "version": "1.0.87",
3
+ "version": "1.0.89",
4
4
  "description": "Zudello Integrations SDK",
5
5
  "main": "./src/index.js",
6
6
  "repository": {
package/src/sdk/Base.js CHANGED
@@ -28,7 +28,7 @@ class BaseSDK {
28
28
  this.apiInstance = new ApiInstance()
29
29
  this.validator = new Validator()
30
30
  this.responseHandler = new ResponseHandler()
31
- this.logger = new Logger()
31
+ this.logger = Logger.init()
32
32
 
33
33
  this.organizationUUID = config.envs.ORGANIZATION_UUID
34
34
  this.teamUUID = config.envs.TEAM_UUID
@@ -43,6 +43,7 @@ module.exports = {
43
43
  // GLOBAL ENVS
44
44
  ZUDELLO_API_URL: process.env.ZUDELLO_API_URL,
45
45
  PAUSE_PROCESS_EXIT_CODE: process.env.PAUSE_PROCESS_EXIT_CODE,
46
+ SKIP_SYNC: process.env.SKIP_SYNC,
46
47
 
47
48
  // AWS ENVS
48
49
  AWS_ACCESS_KEY_ID: process.env.AWS_ACCESS_KEY_ID,
@@ -7,7 +7,7 @@ const Logger = require('./logger')
7
7
  class DatasetHelper {
8
8
  constructor(data = null, uuid = null) {
9
9
  this.zudello = new Zudello()
10
- this.logger = new Logger()
10
+ this.logger = Logger.init()
11
11
 
12
12
  this.data = data
13
13
  this.uuid = uuid
@@ -8,7 +8,7 @@ const config = require('./config')
8
8
  class FormHelper {
9
9
  constructor(data) {
10
10
  this.apiInstance = new ApiInstance()
11
- this.logger = new Logger()
11
+ this.logger = Logger.init()
12
12
 
13
13
  this.teamUUID = config.envs.TEAM_UUID
14
14
  this.apiURL = config.envs.ZUDELLO_API_URL
@@ -18,6 +18,14 @@ class GlobalState {
18
18
  this._registerAutoSync()
19
19
  }
20
20
 
21
+ static init() {
22
+ if (!GlobalState._instance) {
23
+ GlobalState._instance = new GlobalState()
24
+ }
25
+
26
+ return GlobalState._instance
27
+ }
28
+
21
29
  _loadState () {
22
30
  try {
23
31
  this.globalState = JSON.parse(config.envs.GLOBAL_STATE || '{}')
@@ -48,7 +56,7 @@ class GlobalState {
48
56
  }
49
57
 
50
58
  async sync () {
51
- if (this._synced) {
59
+ if (this._synced || config.envs.SKIP_SYNC) {
52
60
  return
53
61
  }
54
62
 
@@ -17,6 +17,14 @@ class Logger {
17
17
  this._registerAutoSync()
18
18
  }
19
19
 
20
+ static init() {
21
+ if (!Logger._instance) {
22
+ Logger._instance = new Logger()
23
+ }
24
+
25
+ return Logger._instance
26
+ }
27
+
20
28
  _registerAutoSync() {
21
29
  const syncOnExit = async () => {
22
30
  if (this._synced) {
@@ -151,11 +159,11 @@ class Logger {
151
159
  }
152
160
 
153
161
  async sync() {
154
- if (this._synced) {
162
+ if (this._synced || config.envs.SKIP_SYNC) {
155
163
  return
156
164
  }
157
165
 
158
- const globalStateClass = new GlobalState()
166
+ const globalStateClass = GlobalState.init()
159
167
  await appendJsonArray(config.envs.AWS_BUCKET, globalStateClass.globalState.logFilePath, this.getLogs())
160
168
  }
161
169
  }
@@ -138,7 +138,7 @@ class Metadata {
138
138
  }
139
139
 
140
140
  async sync() {
141
- if (this._synced) {
141
+ if (this._synced || config.envs.SKIP_SYNC) {
142
142
  return
143
143
  }
144
144
 
@@ -7,7 +7,7 @@ const Logger = require('./logger')
7
7
  class ModelHelper {
8
8
  constructor(data = null, model = null, uuid = null) {
9
9
  this.zudello = new Zudello()
10
- this.logger = new Logger()
10
+ this.logger = Logger.init()
11
11
 
12
12
  this.modelData = data
13
13
  this.model = model
@@ -8,7 +8,7 @@ const config = require('./config')
8
8
  class ResponseHelper {
9
9
  constructor(data) {
10
10
  this.apiInstance = new ApiInstance()
11
- this.logger = new Logger()
11
+ this.logger = Logger.init()
12
12
 
13
13
  this.teamUUID = config.envs.TEAM_UUID
14
14
  this.apiURL = config.envs.ZUDELLO_API_URL
package/src/utils/tags.js CHANGED
@@ -61,7 +61,7 @@ class Tags {
61
61
  }
62
62
 
63
63
  async sync() {
64
- if (this._synced) {
64
+ if (this._synced || config.envs.SKIP_SYNC) {
65
65
  return
66
66
  }
67
67