@contentstack/datasync-manager 1.2.3 → 2.0.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/dist/core/q.js CHANGED
@@ -5,10 +5,11 @@
5
5
  * MIT Licensed
6
6
  */
7
7
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
8
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
8
9
  return new (P || (P = Promise))(function (resolve, reject) {
9
10
  function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
10
11
  function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
11
- function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
12
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
12
13
  step((generator = generator.apply(thisArg, _arguments || [])).next());
13
14
  });
14
15
  };
@@ -16,6 +17,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
16
17
  return (mod && mod.__esModule) ? mod : { "default": mod };
17
18
  };
18
19
  Object.defineProperty(exports, "__esModule", { value: true });
20
+ exports.notifications = exports.Q = void 0;
19
21
  const debug_1 = __importDefault(require("debug"));
20
22
  const events_1 = require("events");
21
23
  const lodash_1 = require("lodash");
@@ -26,7 +28,8 @@ const series_1 = require("../util/series");
26
28
  const unprocessible_1 = require("../util/unprocessible");
27
29
  const plugins_1 = require("./plugins");
28
30
  const token_management_1 = require("./token-management");
29
- const debug = debug_1.default('q');
31
+ const index_2 = require("../index");
32
+ const debug = (0, debug_1.default)('q');
30
33
  const notifications = new events_1.EventEmitter();
31
34
  exports.notifications = notifications;
32
35
  let instance = null;
@@ -45,7 +48,7 @@ class Q extends events_1.EventEmitter {
45
48
  constructor(contentStore, assetStore, config) {
46
49
  if (!instance && contentStore && assetStore && config) {
47
50
  super();
48
- this.pluginInstances = plugins_1.load(config);
51
+ this.pluginInstances = (0, plugins_1.load)(config);
49
52
  this.contentStore = contentStore;
50
53
  this.syncManager = config.syncManager;
51
54
  this.iLock = false;
@@ -64,7 +67,7 @@ class Q extends events_1.EventEmitter {
64
67
  this.q.unshift(data);
65
68
  if (this.q.length > this.syncManager.queue.pause_threshold) {
66
69
  this.iLock = true;
67
- _1.lock();
70
+ (0, _1.lock)();
68
71
  }
69
72
  debug(`Content type '${data._content_type_uid}' received for '${data._type}'`);
70
73
  this.emit('next');
@@ -77,7 +80,7 @@ class Q extends events_1.EventEmitter {
77
80
  this.q.push(data);
78
81
  if (this.q.length > this.syncManager.queue.pause_threshold) {
79
82
  this.iLock = true;
80
- _1.lock();
83
+ (0, _1.lock)();
81
84
  }
82
85
  debug(`Content type '${data._content_type_uid}' received for '${data._type}'`);
83
86
  this.emit('next');
@@ -94,9 +97,9 @@ class Q extends events_1.EventEmitter {
94
97
  logger_1.logger.error(obj);
95
98
  debug(`Error handler called with ${JSON.stringify(obj)}`);
96
99
  if (typeof obj.checkpoint !== 'undefined') {
97
- yield token_management_1.saveToken(obj.checkpoint.name, obj.checkpoint.token);
100
+ yield (0, token_management_1.saveToken)(obj.checkpoint.name, obj.checkpoint.token);
98
101
  }
99
- yield unprocessible_1.saveFailedItems(obj);
102
+ yield (0, unprocessible_1.saveFailedItems)(obj);
100
103
  this.inProgress = false;
101
104
  this.emit('next');
102
105
  }
@@ -119,7 +122,7 @@ class Q extends events_1.EventEmitter {
119
122
  return __awaiter(this, void 0, void 0, function* () {
120
123
  try {
121
124
  if (this.iLock && this.q.length < this.syncManager.queue.resume_threshold) {
122
- _1.unlock(true);
125
+ (0, _1.unlock)(true);
123
126
  this.iLock = false;
124
127
  }
125
128
  debug(`Calling 'next'. In progress status is ${this.inProgress}, and Q length is ${this.q.length}`);
@@ -160,6 +163,8 @@ class Q extends events_1.EventEmitter {
160
163
  const contentType = data._content_type_uid;
161
164
  const locale = data.locale;
162
165
  const uid = data.uid;
166
+ const branch = (0, index_2.getConfig)().contentstack.branch;
167
+ data.branch = branch;
163
168
  if (data.hasOwnProperty('_checkpoint')) {
164
169
  checkpoint = data._checkpoint;
165
170
  delete data._checkpoint;
@@ -172,29 +177,29 @@ class Q extends events_1.EventEmitter {
172
177
  const afterSyncPlugins = [];
173
178
  let transformedData;
174
179
  let transformedSchema;
175
- let { schema } = index_1.getSchema(action, data);
176
- data = index_1.filterUnwantedKeys(action, data);
180
+ let { schema } = (0, index_1.getSchema)(action, data);
181
+ data = (0, index_1.filterUnwantedKeys)(action, data);
177
182
  if (typeof schema !== 'undefined') {
178
- schema = index_1.filterUnwantedKeys(action, schema);
183
+ schema = (0, index_1.filterUnwantedKeys)(action, schema);
179
184
  }
180
185
  logger_1.logger.log(`${type}: { content_type: '${contentType}', ${(locale) ? `locale: '${locale}',` : ''} uid: '${uid}'} is in progress`);
181
186
  this.pluginInstances.internal.beforeSync.forEach((method) => {
182
187
  beforeSyncInternalPlugins.push(() => method(action, data, schema));
183
188
  });
184
- yield series_1.series(beforeSyncInternalPlugins);
189
+ yield (0, series_1.series)(beforeSyncInternalPlugins);
185
190
  if (this.syncManager.pluginTransformations) {
186
191
  transformedData = data;
187
192
  transformedSchema = schema;
188
193
  }
189
194
  else {
190
- transformedData = lodash_1.cloneDeep(data);
191
- transformedSchema = lodash_1.cloneDeep(schema);
195
+ transformedData = (0, lodash_1.cloneDeep)(data);
196
+ transformedSchema = (0, lodash_1.cloneDeep)(schema);
192
197
  }
193
198
  if (this.syncManager.serializePlugins) {
194
199
  this.pluginInstances.external.beforeSync.forEach((method) => {
195
200
  beforeSyncPlugins.push(() => method(action, transformedData, transformedSchema));
196
201
  });
197
- yield series_1.series(beforeSyncPlugins);
202
+ yield (0, series_1.series)(beforeSyncPlugins);
198
203
  }
199
204
  else {
200
205
  this.pluginInstances.external.beforeSync.forEach((method) => {
@@ -206,6 +211,7 @@ class Q extends events_1.EventEmitter {
206
211
  yield this.contentStore[action](data);
207
212
  debug(`Completed '${action}' on connector successfully!`);
208
213
  if (typeof schema !== 'undefined') {
214
+ schema.branch = branch;
209
215
  yield this.contentStore.updateContentType(schema);
210
216
  }
211
217
  debug('Connector instance called successfully!');
@@ -213,7 +219,7 @@ class Q extends events_1.EventEmitter {
213
219
  this.pluginInstances.external.afterSync.forEach((method) => {
214
220
  afterSyncPlugins.push(() => method(action, transformedData, transformedSchema));
215
221
  });
216
- yield series_1.series(afterSyncPlugins);
222
+ yield (0, series_1.series)(afterSyncPlugins);
217
223
  }
218
224
  else {
219
225
  this.pluginInstances.external.afterSync.forEach((method) => {
@@ -222,7 +228,7 @@ class Q extends events_1.EventEmitter {
222
228
  yield Promise.all(afterSyncPlugins);
223
229
  }
224
230
  if (typeof checkpoint !== 'undefined') {
225
- yield token_management_1.saveToken(checkpoint.name, checkpoint.token);
231
+ yield (0, token_management_1.saveToken)(checkpoint.name, checkpoint.token);
226
232
  }
227
233
  debug('After action plugins executed successfully!');
228
234
  logger_1.logger.log(`${type}: { content_type: '${contentType}', ${(locale) ? `locale: '${locale}',` : ''} uid: '${uid}'} was completed successfully!`);
@@ -5,10 +5,11 @@
5
5
  * MIT Licensed
6
6
  */
7
7
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
8
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
8
9
  return new (P || (P = Promise))(function (resolve, reject) {
9
10
  function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
10
11
  function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
11
- function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
12
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
12
13
  step((generator = generator.apply(thisArg, _arguments || [])).next());
13
14
  });
14
15
  };
@@ -16,31 +17,32 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
16
17
  return (mod && mod.__esModule) ? mod : { "default": mod };
17
18
  };
18
19
  Object.defineProperty(exports, "__esModule", { value: true });
20
+ exports.saveCheckpoint = exports.saveToken = exports.getToken = void 0;
19
21
  const debug_1 = __importDefault(require("debug"));
20
22
  const index_1 = require("../index");
21
23
  const fs_1 = require("../util/fs");
22
24
  const index_2 = require("../util/index");
23
- const debug = debug_1.default('token-management');
25
+ const debug = (0, debug_1.default)('token-management');
24
26
  let counter = 0;
25
27
  /**
26
28
  * @description Returns 'token details' based on 'token type'
27
29
  * @param {String} type - Token type (checkpoint | current)
28
30
  */
29
- exports.getToken = () => {
30
- return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
31
+ const getToken = () => {
32
+ return new Promise((resolve, reject) => __awaiter(void 0, void 0, void 0, function* () {
31
33
  try {
32
- const config = index_1.getConfig();
34
+ const config = (0, index_1.getConfig)();
33
35
  const checkpoint = config.paths.checkpoint;
34
36
  const token = config.paths.token;
35
37
  let data = {};
36
- if (fs_1.existsSync(checkpoint)) {
38
+ if ((0, fs_1.existsSync)(checkpoint)) {
37
39
  debug(`Checkpoint read: ${checkpoint}`);
38
- const contents = yield fs_1.readFile(checkpoint);
40
+ const contents = yield (0, fs_1.readFile)(checkpoint);
39
41
  data = JSON.parse(contents);
40
42
  }
41
- else if (fs_1.existsSync(token)) {
43
+ else if ((0, fs_1.existsSync)(token)) {
42
44
  debug(`Token read: ${token}`);
43
- const contents = yield fs_1.readFile(token);
45
+ const contents = yield (0, fs_1.readFile)(token);
44
46
  data = JSON.parse(contents);
45
47
  }
46
48
  return resolve(data);
@@ -50,17 +52,18 @@ exports.getToken = () => {
50
52
  }
51
53
  }));
52
54
  };
55
+ exports.getToken = getToken;
53
56
  /**
54
57
  * @description Saves token details
55
58
  * @param {String} name - Name of the token
56
59
  * @param {String} token - Token value
57
60
  * @param {String} type - Token type
58
61
  */
59
- exports.saveToken = (name, token) => {
62
+ const saveToken = (name, token) => {
60
63
  debug(`Save token invoked with name: ${name}, token: ${token}`);
61
- return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
64
+ return new Promise((resolve, reject) => __awaiter(void 0, void 0, void 0, function* () {
62
65
  try {
63
- const config = index_1.getConfig();
66
+ const config = (0, index_1.getConfig)();
64
67
  const path = config.paths.token;
65
68
  const data = {
66
69
  name,
@@ -68,7 +71,7 @@ exports.saveToken = (name, token) => {
68
71
  token,
69
72
  };
70
73
  // write token information @path
71
- yield fs_1.writeFile(path, JSON.stringify(data));
74
+ yield (0, fs_1.writeFile)(path, JSON.stringify(data));
72
75
  const obj = {
73
76
  name,
74
77
  timestamp: new Date().toISOString(),
@@ -81,42 +84,44 @@ exports.saveToken = (name, token) => {
81
84
  else {
82
85
  filename = `${config.paths.ledger}.${counter}`;
83
86
  }
84
- const file = yield index_2.getFile(filename, () => {
87
+ const file = yield (0, index_2.getFile)(filename, () => {
85
88
  counter++;
86
89
  return `${config.paths.ledger}-${counter}`;
87
90
  });
88
- debug(`ledger file: ${file} exists?(${fs_1.existsSync(file)})`);
89
- if (!fs_1.existsSync(file)) {
90
- yield fs_1.writeFile(file, JSON.stringify([obj]));
91
+ debug(`ledger file: ${file} exists?(${(0, fs_1.existsSync)(file)})`);
92
+ if (!(0, fs_1.existsSync)(file)) {
93
+ yield (0, fs_1.writeFile)(file, JSON.stringify([obj]));
91
94
  }
92
95
  else {
93
- const ledger = yield fs_1.readFile(file);
96
+ const ledger = yield (0, fs_1.readFile)(file);
94
97
  const ledgerDetails = JSON.parse(ledger);
95
98
  ledgerDetails.splice(0, 0, obj);
96
- yield fs_1.writeFile(file, JSON.stringify(ledgerDetails));
99
+ yield (0, fs_1.writeFile)(file, JSON.stringify(ledgerDetails));
97
100
  }
98
- return resolve();
101
+ return resolve('');
99
102
  }
100
103
  catch (error) {
101
104
  return reject(error);
102
105
  }
103
106
  }));
104
107
  };
108
+ exports.saveToken = saveToken;
105
109
  /**
106
110
  * @description Saves token details
107
111
  * @param {String} name - Name of the token
108
112
  * @param {String} token - Token value
109
113
  * @param {String} type - Token type
110
114
  */
111
- exports.saveCheckpoint = (name, token) => __awaiter(this, void 0, void 0, function* () {
115
+ const saveCheckpoint = (name, token) => __awaiter(void 0, void 0, void 0, function* () {
112
116
  debug(`Save token invoked with name: ${name}, token: ${token}`);
113
- const config = index_1.getConfig();
117
+ const config = (0, index_1.getConfig)();
114
118
  const path = config.paths.checkpoint;
115
119
  const data = {
116
120
  name,
117
121
  timestamp: new Date().toISOString(),
118
122
  token,
119
123
  };
120
- yield fs_1.writeFile(path, JSON.stringify(data));
124
+ yield (0, fs_1.writeFile)(path, JSON.stringify(data));
121
125
  return;
122
126
  });
127
+ exports.saveCheckpoint = saveCheckpoint;
package/dist/index.js CHANGED
@@ -5,10 +5,11 @@
5
5
  * MIT Licensed
6
6
  */
7
7
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
8
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
8
9
  return new (P || (P = Promise))(function (resolve, reject) {
9
10
  function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
10
11
  function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
11
- function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
12
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
12
13
  step((generator = generator.apply(thisArg, _arguments || [])).next());
13
14
  });
14
15
  };
@@ -16,6 +17,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
16
17
  return (mod && mod.__esModule) ? mod : { "default": mod };
17
18
  };
18
19
  Object.defineProperty(exports, "__esModule", { value: true });
20
+ exports.debugNotifications = exports.start = exports.notifications = exports.setLogger = exports.getConfig = exports.setConfig = exports.setListener = exports.setAssetStore = exports.setContentStore = exports.getAssetLocation = exports.pop = exports.unshift = exports.push = void 0;
19
21
  const debug_1 = __importDefault(require("debug"));
20
22
  const lodash_1 = require("lodash");
21
23
  const config_1 = require("./config");
@@ -23,30 +25,33 @@ const index_1 = require("./core/index");
23
25
  const inet_1 = require("./core/inet");
24
26
  const process_1 = require("./core/process");
25
27
  const q_1 = require("./core/q");
26
- exports.notifications = q_1.notifications;
28
+ Object.defineProperty(exports, "notifications", { enumerable: true, get: function () { return q_1.notifications; } });
27
29
  const build_paths_1 = require("./util/build-paths");
28
30
  const index_2 = require("./util/index");
29
31
  const logger_1 = require("./util/logger");
30
32
  const validations_1 = require("./util/validations");
31
- const debug = debug_1.default('sm:index');
33
+ const debug = (0, debug_1.default)('sm:index');
32
34
  let assetStoreInstance;
33
35
  let appConfig = {};
34
36
  let contentStore;
35
37
  let assetStore;
36
38
  let listener;
37
- exports.push = (data) => {
38
- validations_1.validateExternalInput(data);
39
- index_1.push(data);
39
+ const push = (data) => {
40
+ (0, validations_1.validateExternalInput)(data);
41
+ (0, index_1.push)(data);
40
42
  };
41
- exports.unshift = (data) => {
42
- validations_1.validateExternalInput(data);
43
- index_1.unshift(data);
43
+ exports.push = push;
44
+ const unshift = (data) => {
45
+ (0, validations_1.validateExternalInput)(data);
46
+ (0, index_1.unshift)(data);
44
47
  };
45
- exports.pop = () => {
46
- index_1.pop();
48
+ exports.unshift = unshift;
49
+ const pop = () => {
50
+ (0, index_1.pop)();
47
51
  };
48
- exports.getAssetLocation = (asset) => {
49
- return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
52
+ exports.pop = pop;
53
+ const getAssetLocation = (asset) => {
54
+ return new Promise((resolve, reject) => __awaiter(void 0, void 0, void 0, function* () {
50
55
  try {
51
56
  const assetStoreConfig = assetStore.getConfig();
52
57
  const assetConfig = (assetStoreConfig.assetStore) ? assetStoreConfig.assetStore : assetStoreConfig;
@@ -58,52 +63,58 @@ exports.getAssetLocation = (asset) => {
58
63
  }
59
64
  }));
60
65
  };
66
+ exports.getAssetLocation = getAssetLocation;
61
67
  /**
62
68
  * @public
63
69
  * @method setContentStore
64
70
  * @summary Register content store
65
71
  * @param {object} instance Content store instance
66
72
  */
67
- exports.setContentStore = (instance) => {
73
+ const setContentStore = (instance) => {
68
74
  contentStore = instance;
69
75
  };
76
+ exports.setContentStore = setContentStore;
70
77
  /**
71
78
  * @public
72
79
  * @method setAssetStore
73
80
  * @summary Register asset store
74
81
  * @param {object} instance Asset store instance
75
82
  */
76
- exports.setAssetStore = (instance) => {
83
+ const setAssetStore = (instance) => {
77
84
  assetStore = instance;
78
85
  };
86
+ exports.setAssetStore = setAssetStore;
79
87
  /**
80
88
  * @public
81
89
  * @method setListener
82
90
  * @summary Register listener
83
91
  * @param {object} instance Listener instance
84
92
  */
85
- exports.setListener = (instance) => {
86
- validations_1.validateListener(instance);
93
+ const setListener = (instance) => {
94
+ (0, validations_1.validateListener)(instance);
87
95
  listener = instance;
88
96
  };
97
+ exports.setListener = setListener;
89
98
  /**
90
99
  * @public
91
100
  * @method setConfig
92
101
  * @summary Sets the application's configuration
93
102
  * @param {object} config Application config
94
103
  */
95
- exports.setConfig = (config) => {
104
+ const setConfig = (config) => {
96
105
  appConfig = config;
97
106
  };
107
+ exports.setConfig = setConfig;
98
108
  /**
99
109
  * @public
100
110
  * @method getConfig
101
111
  * @summary Returns the application's configuration
102
112
  * @returns {object} Application config
103
113
  */
104
- exports.getConfig = () => {
114
+ const getConfig = () => {
105
115
  return appConfig;
106
116
  };
117
+ exports.getConfig = getConfig;
107
118
  /**
108
119
  * @public
109
120
  * @method setLogger
@@ -111,7 +122,7 @@ exports.getConfig = () => {
111
122
  * @param {object} instance Custom logger instance
112
123
  */
113
124
  var logger_2 = require("./util/logger");
114
- exports.setLogger = logger_2.setLogger;
125
+ Object.defineProperty(exports, "setLogger", { enumerable: true, get: function () { return logger_2.setLogger; } });
115
126
  /**
116
127
  * @public
117
128
  * @method start
@@ -122,37 +133,37 @@ exports.setLogger = logger_2.setLogger;
122
133
  * @param {object} config Optional application config overrides
123
134
  * @returns {Promise} Returns a promise
124
135
  */
125
- exports.start = (config = {}) => {
136
+ const start = (config = {}) => {
126
137
  return new Promise((resolve, reject) => {
127
138
  try {
128
- validations_1.validateAssetStore(assetStore);
129
- validations_1.validateContentStore(contentStore);
130
- validations_1.validateListener(listener);
131
- appConfig = lodash_1.merge({}, config_1.config, appConfig, config);
132
- validations_1.validateConfig(appConfig);
133
- appConfig.paths = build_paths_1.buildConfigPaths();
139
+ (0, validations_1.validateAssetStore)(assetStore);
140
+ (0, validations_1.validateContentStore)(contentStore);
141
+ (0, validations_1.validateListener)(listener);
142
+ appConfig = (0, lodash_1.merge)({}, config_1.config, appConfig, config);
143
+ (0, validations_1.validateConfig)(appConfig);
144
+ appConfig.paths = (0, build_paths_1.buildConfigPaths)();
134
145
  // since logger is singleton, if previously set, it'll return that isnstance!
135
- logger_1.setLogger();
136
- process_1.configure();
146
+ (0, logger_1.setLogger)();
147
+ (0, process_1.configure)();
137
148
  return assetStore.start(appConfig).then((assetInstance) => {
138
149
  debug('Asset store instance has returned successfully!');
139
- validations_1.validateAssetStoreInstance(assetInstance);
150
+ (0, validations_1.validateAssetStoreInstance)(assetInstance);
140
151
  assetStoreInstance = assetInstance;
141
152
  return contentStore.start(assetInstance, appConfig);
142
153
  }).then((contentStoreInstance) => {
143
154
  debug('Content store instance has returned successfully!');
144
- validations_1.validateContentStoreInstance(contentStoreInstance);
145
- appConfig = index_2.formatSyncFilters(appConfig);
146
- return index_1.init(contentStoreInstance, assetStoreInstance);
155
+ (0, validations_1.validateContentStoreInstance)(contentStoreInstance);
156
+ appConfig = (0, index_2.formatSyncFilters)(appConfig);
157
+ return (0, index_1.init)(contentStoreInstance, assetStoreInstance);
147
158
  }).then(() => {
148
159
  debug('Sync Manager initiated successfully!');
149
160
  listener.register(index_1.poke);
150
161
  // start checking for inet 10 secs after the app has started
151
- inet_1.init();
162
+ (0, inet_1.init)();
152
163
  return listener.start(appConfig);
153
164
  }).then(() => {
154
165
  logger_1.logger.info('Contentstack sync utility started successfully!');
155
- return resolve();
166
+ return resolve('');
156
167
  }).catch(reject);
157
168
  }
158
169
  catch (error) {
@@ -160,19 +171,21 @@ exports.start = (config = {}) => {
160
171
  }
161
172
  });
162
173
  };
174
+ exports.start = start;
163
175
  /**
164
176
  * @public
165
177
  * @method debugNotifications
166
178
  * @param {object} item Item being processed
167
179
  * @returns {void}
168
180
  */
169
- exports.debugNotifications = (action) => {
181
+ const debugNotifications = (action) => {
170
182
  return (item) => {
171
183
  debug(`Notifications: ${action} - ${JSON.stringify(item)}`);
172
184
  };
173
185
  };
186
+ exports.debugNotifications = debugNotifications;
174
187
  q_1.notifications
175
- .on('publish', exports.debugNotifications('publish'))
176
- .on('unpublish', exports.debugNotifications('unpublish'))
177
- .on('delete', exports.debugNotifications('delete'))
178
- .on('error', exports.debugNotifications('error'));
188
+ .on('publish', (0, exports.debugNotifications)('publish'))
189
+ .on('unpublish', (0, exports.debugNotifications)('unpublish'))
190
+ .on('delete', (0, exports.debugNotifications)('delete'))
191
+ .on('error', (0, exports.debugNotifications)('error'));
@@ -191,5 +191,5 @@ exports.buildAssetObject = (asset, locale, entry_uid, content_type_uid) => {
191
191
  throw new Error('Unable to determine fine name.\n' + JSON.stringify(matches));
192
192
  }
193
193
  asset.filename = matches[5];
194
- return Object.assign({ _content_type_uid: '_assets' }, asset, { _type: 'publish', entry_content_type: content_type_uid, entry_reffered_in: entry_uid, locale, uid: asset.uid });
194
+ return Object.assign(Object.assign({ _content_type_uid: '_assets' }, asset), { _type: 'publish', entry_content_type: content_type_uid, entry_reffered_in: entry_uid, locale, uid: asset.uid });
195
195
  };
@@ -5,40 +5,42 @@
5
5
  * MIT Licensed
6
6
  */
7
7
  Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.buildConfigPaths = void 0;
8
9
  const path_1 = require("path");
9
10
  /**
10
11
  * @description Builds application's config paths where data is stored
11
12
  * @returns {Object} Returns config paths
12
13
  */
13
- exports.buildConfigPaths = () => {
14
- const baseDir = path_1.resolve(path_1.join(__dirname, '..', '..', '..', '..'));
14
+ const buildConfigPaths = () => {
15
+ const baseDir = (0, path_1.resolve)((0, path_1.join)(__dirname, '..', '..', '..', '..'));
15
16
  let pluginPath;
16
17
  let tokenPath;
17
18
  if (process.env.PLUGIN_PATH) {
18
- if (!path_1.isAbsolute(process.env.PLUGIN_PATH)) {
19
- pluginPath = path_1.join(baseDir, process.env.PLUGIN_PATH);
19
+ if (!(0, path_1.isAbsolute)(process.env.PLUGIN_PATH)) {
20
+ pluginPath = (0, path_1.join)(baseDir, process.env.PLUGIN_PATH);
20
21
  }
21
22
  else {
22
23
  pluginPath = process.env.PLUGIN_PATH;
23
24
  }
24
25
  }
25
26
  if (process.env.TOKEN_PATH) {
26
- if (!path_1.isAbsolute(process.env.TOKEN_PATH)) {
27
- tokenPath = path_1.join(baseDir, process.env.TOKEN_PATH);
27
+ if (!(0, path_1.isAbsolute)(process.env.TOKEN_PATH)) {
28
+ tokenPath = (0, path_1.join)(baseDir, process.env.TOKEN_PATH);
28
29
  }
29
30
  else {
30
31
  tokenPath = process.env.TOKEN_PATH;
31
32
  }
32
33
  }
33
34
  const paths = {
34
- baseDir: path_1.resolve(path_1.join(__dirname, '..', '..')),
35
- checkpoint: path_1.resolve(path_1.join(tokenPath || path_1.join(baseDir, '..'), '.checkpoint')),
36
- failed: path_1.resolve(path_1.join(tokenPath || path_1.join(baseDir, '..'), 'unprocessible', 'failed')),
37
- filtered: path_1.resolve(path_1.join(tokenPath || path_1.join(baseDir, '..'), 'unprocessible', 'filtered')),
38
- ledger: path_1.resolve(path_1.join(tokenPath || path_1.join(baseDir, '..'), '.ledger')),
39
- plugin: path_1.resolve(path_1.join(pluginPath || path_1.join(baseDir, '..'), 'plugins')),
40
- token: path_1.resolve(path_1.join(tokenPath || path_1.join(baseDir, '..'), '.token')),
41
- unprocessibleDir: path_1.resolve(path_1.join(tokenPath || baseDir, 'unprocessible')),
35
+ baseDir: (0, path_1.resolve)((0, path_1.join)(__dirname, '..', '..')),
36
+ checkpoint: (0, path_1.resolve)((0, path_1.join)(tokenPath || (0, path_1.join)(baseDir, '..'), '.checkpoint')),
37
+ failed: (0, path_1.resolve)((0, path_1.join)(tokenPath || (0, path_1.join)(baseDir, '..'), 'unprocessible', 'failed')),
38
+ filtered: (0, path_1.resolve)((0, path_1.join)(tokenPath || (0, path_1.join)(baseDir, '..'), 'unprocessible', 'filtered')),
39
+ ledger: (0, path_1.resolve)((0, path_1.join)(tokenPath || (0, path_1.join)(baseDir, '..'), '.ledger')),
40
+ plugin: (0, path_1.resolve)((0, path_1.join)(pluginPath || (0, path_1.join)(baseDir, '..'), 'plugins')),
41
+ token: (0, path_1.resolve)((0, path_1.join)(tokenPath || (0, path_1.join)(baseDir, '..'), '.token')),
42
+ unprocessibleDir: (0, path_1.resolve)((0, path_1.join)(tokenPath || baseDir, 'unprocessible')),
42
43
  };
43
44
  return paths;
44
45
  };
46
+ exports.buildConfigPaths = buildConfigPaths;