@contentstack/datasync-manager 1.2.2 → 1.2.4
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/.github/workflows/codeql-analysis.yml +68 -0
- package/.github/workflows/jira.yml +28 -0
- package/.github/workflows/sast-scan.yml +11 -0
- package/.github/workflows/sca-scan.yml +15 -0
- package/.github/workflows/secrets-scan.yml +11 -0
- package/.talismanrc +1 -1
- package/CODEOWNERS +1 -1
- package/dist/api.js +1 -0
- package/dist/config.js +1 -0
- package/dist/core/index.js +65 -35
- package/dist/core/inet.js +2 -4
- package/dist/core/plugins.js +1 -0
- package/dist/core/process.js +1 -0
- package/dist/core/q.js +4 -12
- package/dist/core/token-management.js +6 -4
- package/dist/index.js +6 -4
- package/dist/plugins/helper.js +2 -2
- package/dist/plugins/save_rte_markdown_assets/index.js +0 -1
- package/dist/plugins/transform_entries/index.js +0 -1
- package/dist/util/build-paths.js +1 -0
- package/dist/util/fs.js +4 -3
- package/dist/util/index.js +14 -4
- package/dist/util/logger.js +1 -0
- package/dist/util/promise.map.js +1 -0
- package/dist/util/series.js +4 -2
- package/dist/util/unprocessible.js +4 -2
- package/dist/util/validations.js +1 -0
- package/package.json +16 -15
- package/test/dummy/plugins/myplugin1/index.js +0 -1
- package/test/dummy/plugins/myplugin2/index.js +0 -1
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# For most projects, this workflow file will not need changing; you simply need
|
|
2
|
+
# to commit it to your repository.
|
|
3
|
+
#
|
|
4
|
+
# You may wish to alter this file to override the set of languages analyzed,
|
|
5
|
+
# or to provide custom queries or build logic.
|
|
6
|
+
#
|
|
7
|
+
# ******** NOTE ********
|
|
8
|
+
# We have attempted to detect the languages in your repository. Please check
|
|
9
|
+
# the `language` matrix defined below to confirm you have the correct set of
|
|
10
|
+
# supported CodeQL languages.
|
|
11
|
+
#
|
|
12
|
+
name: "CodeQL"
|
|
13
|
+
|
|
14
|
+
on:
|
|
15
|
+
pull_request:
|
|
16
|
+
# The branches below must be a subset of the branches above
|
|
17
|
+
branches: '*'
|
|
18
|
+
|
|
19
|
+
jobs:
|
|
20
|
+
analyze:
|
|
21
|
+
name: Analyze
|
|
22
|
+
runs-on: ubuntu-latest
|
|
23
|
+
permissions:
|
|
24
|
+
actions: read
|
|
25
|
+
contents: read
|
|
26
|
+
security-events: write
|
|
27
|
+
|
|
28
|
+
strategy:
|
|
29
|
+
fail-fast: false
|
|
30
|
+
matrix:
|
|
31
|
+
language: [ 'javascript' ]
|
|
32
|
+
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
|
|
33
|
+
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
|
|
34
|
+
|
|
35
|
+
steps:
|
|
36
|
+
- name: Checkout repository
|
|
37
|
+
uses: actions/checkout@v3
|
|
38
|
+
|
|
39
|
+
# Initializes the CodeQL tools for scanning.
|
|
40
|
+
- name: Initialize CodeQL
|
|
41
|
+
uses: github/codeql-action/init@v2
|
|
42
|
+
with:
|
|
43
|
+
languages: ${{ matrix.language }}
|
|
44
|
+
# If you wish to specify custom queries, you can do so here or in a config file.
|
|
45
|
+
# By default, queries listed here will override any specified in a config file.
|
|
46
|
+
# Prefix the list here with "+" to use these queries and those in the config file.
|
|
47
|
+
|
|
48
|
+
# Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
|
|
49
|
+
# queries: security-extended,security-and-quality
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
|
53
|
+
# If this step fails, then you should remove it and run the build manually (see below)
|
|
54
|
+
- name: Autobuild
|
|
55
|
+
uses: github/codeql-action/autobuild@v2
|
|
56
|
+
|
|
57
|
+
# ℹ️ Command-line programs to run using the OS shell.
|
|
58
|
+
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
|
|
59
|
+
|
|
60
|
+
# If the Autobuild fails above, remove it and uncomment the following three lines.
|
|
61
|
+
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.
|
|
62
|
+
|
|
63
|
+
# - run: |
|
|
64
|
+
# echo "Run, Build Application using script"
|
|
65
|
+
# ./location_of_script_within_repo/buildscript.sh
|
|
66
|
+
|
|
67
|
+
- name: Perform CodeQL Analysis
|
|
68
|
+
uses: github/codeql-action/analyze@v2
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
name: Create JIRA ISSUE
|
|
2
|
+
on:
|
|
3
|
+
pull_request:
|
|
4
|
+
types: [opened]
|
|
5
|
+
jobs:
|
|
6
|
+
security:
|
|
7
|
+
if: ${{ github.actor == 'dependabot[bot]' || github.actor == 'snyk-bot' || contains(github.event.pull_request.head.ref, 'snyk-fix-') || contains(github.event.pull_request.head.ref, 'snyk-upgrade-')}}
|
|
8
|
+
runs-on: ubuntu-latest
|
|
9
|
+
steps:
|
|
10
|
+
- uses: actions/checkout@v2
|
|
11
|
+
- name: Login into JIRA
|
|
12
|
+
uses: atlassian/gajira-login@master
|
|
13
|
+
env:
|
|
14
|
+
JIRA_BASE_URL: ${{ secrets.JIRA_BASE_URL }}
|
|
15
|
+
JIRA_USER_EMAIL: ${{ secrets.JIRA_USER_EMAIL }}
|
|
16
|
+
JIRA_API_TOKEN: ${{ secrets.JIRA_API_TOKEN }}
|
|
17
|
+
- name: Create a JIRA Issue
|
|
18
|
+
id: create
|
|
19
|
+
uses: atlassian/gajira-create@master
|
|
20
|
+
with:
|
|
21
|
+
project: ${{ secrets.JIRA_PROJECT }}
|
|
22
|
+
issuetype: ${{ secrets.JIRA_ISSUE_TYPE }}
|
|
23
|
+
summary: |
|
|
24
|
+
${{ github.event.pull_request.title }}
|
|
25
|
+
description: |
|
|
26
|
+
PR: ${{ github.event.pull_request.html_url }}
|
|
27
|
+
|
|
28
|
+
fields: "${{ secrets.JIRA_FIELDS }}"
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
name: SAST Scan
|
|
2
|
+
on:
|
|
3
|
+
pull_request:
|
|
4
|
+
types: [opened, synchronize, reopened]
|
|
5
|
+
jobs:
|
|
6
|
+
security:
|
|
7
|
+
runs-on: ubuntu-latest
|
|
8
|
+
steps:
|
|
9
|
+
- uses: actions/checkout@v2
|
|
10
|
+
- name: Horusec Scan
|
|
11
|
+
run: docker run -v /var/run/docker.sock:/var/run/docker.sock -v $(pwd):/src horuszup/horusec-cli:latest horusec start -p /src -P $(pwd)
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
name: Source Composition Analysis Scan
|
|
2
|
+
on:
|
|
3
|
+
pull_request:
|
|
4
|
+
types: [opened, synchronize, reopened]
|
|
5
|
+
jobs:
|
|
6
|
+
security:
|
|
7
|
+
runs-on: ubuntu-latest
|
|
8
|
+
steps:
|
|
9
|
+
- uses: actions/checkout@master
|
|
10
|
+
- name: Run Snyk to check for vulnerabilities
|
|
11
|
+
uses: snyk/actions/node@master
|
|
12
|
+
env:
|
|
13
|
+
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
|
|
14
|
+
with:
|
|
15
|
+
args: --all-projects
|
package/.talismanrc
CHANGED
package/CODEOWNERS
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
* @contentstack/security-admin @contentstack/
|
|
1
|
+
* @contentstack/security-admin @contentstack/cli-admin
|
package/dist/api.js
CHANGED
|
@@ -8,6 +8,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
8
8
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
9
9
|
};
|
|
10
10
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.get = exports.init = void 0;
|
|
11
12
|
const debug_1 = __importDefault(require("debug"));
|
|
12
13
|
const https_1 = require("https");
|
|
13
14
|
const path_1 = require("path");
|
package/dist/config.js
CHANGED
package/dist/core/index.js
CHANGED
|
@@ -4,10 +4,20 @@
|
|
|
4
4
|
* Copyright (c) 2019 Contentstack LLC
|
|
5
5
|
* MIT Licensed
|
|
6
6
|
*/
|
|
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); }); }
|
|
9
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
10
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
11
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
12
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
13
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
14
|
+
});
|
|
15
|
+
};
|
|
7
16
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
8
17
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
9
18
|
};
|
|
10
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
exports.unlock = exports.lock = exports.poke = exports.pop = exports.unshift = exports.push = exports.init = void 0;
|
|
11
21
|
const debug_1 = __importDefault(require("debug"));
|
|
12
22
|
const events_1 = require("events");
|
|
13
23
|
const lodash_1 = require("lodash");
|
|
@@ -95,55 +105,73 @@ exports.pop = () => {
|
|
|
95
105
|
/**
|
|
96
106
|
* @description Notifies the sync manager utility to wake up and start syncing..
|
|
97
107
|
*/
|
|
98
|
-
exports.poke = () => {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
108
|
+
exports.poke = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
109
|
+
try {
|
|
110
|
+
debug('Invoked poke');
|
|
111
|
+
logger_1.logger.info('Received \'contentstack sync\' notification');
|
|
112
|
+
if (!flag.lockdown) {
|
|
113
|
+
flag.WQ = true;
|
|
114
|
+
return yield check();
|
|
115
|
+
}
|
|
116
|
+
return null;
|
|
103
117
|
}
|
|
104
|
-
|
|
118
|
+
catch (error) {
|
|
119
|
+
debug('Error [poke]', error);
|
|
120
|
+
throw error;
|
|
121
|
+
}
|
|
122
|
+
});
|
|
105
123
|
/**
|
|
106
124
|
* @description Check's if the status of the app when a new incoming notification is fired
|
|
107
125
|
* @description Starts processing if the 'SQ: false'
|
|
108
126
|
*/
|
|
109
|
-
const check = () => {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
flag.WQ
|
|
113
|
-
|
|
114
|
-
|
|
127
|
+
const check = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
128
|
+
try {
|
|
129
|
+
debug(`Check called. SQ status is ${flag.SQ} and WQ status is ${flag.WQ}`);
|
|
130
|
+
if (!flag.SQ && flag.WQ) {
|
|
131
|
+
flag.WQ = false;
|
|
132
|
+
flag.SQ = true;
|
|
133
|
+
yield sync();
|
|
115
134
|
debug(`Sync completed and SQ flag updated. Cooloff duration is ${config.syncManager.cooloff}`);
|
|
116
135
|
setTimeout(() => {
|
|
117
136
|
flag.SQ = false;
|
|
118
137
|
emitter.emit('check');
|
|
119
138
|
}, config.syncManager.cooloff);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
catch (error) {
|
|
142
|
+
logger_1.logger.error(error);
|
|
143
|
+
debug('Error [check]', error);
|
|
144
|
+
check().then(() => {
|
|
145
|
+
debug('passed [check] error');
|
|
120
146
|
}).catch((error) => {
|
|
121
|
-
|
|
122
|
-
check();
|
|
147
|
+
debug('failed [check] error', error);
|
|
123
148
|
});
|
|
149
|
+
throw error;
|
|
124
150
|
}
|
|
125
|
-
};
|
|
151
|
+
});
|
|
126
152
|
/**
|
|
127
153
|
* @description Gets saved token, builds request object and fires the sync process
|
|
128
154
|
*/
|
|
129
|
-
const sync = () => {
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
155
|
+
const sync = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
156
|
+
try {
|
|
157
|
+
debug('started [sync]');
|
|
158
|
+
const tokenObject = yield token_management_1.getToken();
|
|
159
|
+
debug('tokenObject [sync]', tokenObject);
|
|
160
|
+
const token = tokenObject;
|
|
161
|
+
const request = {
|
|
162
|
+
qs: {
|
|
163
|
+
environment: process.env.SYNC_ENV || Contentstack.environment || 'development',
|
|
164
|
+
limit: config.syncManager.limit,
|
|
165
|
+
[token.name]: token.token,
|
|
166
|
+
},
|
|
167
|
+
};
|
|
168
|
+
return yield fire(request);
|
|
169
|
+
}
|
|
170
|
+
catch (error) {
|
|
171
|
+
debug('Error [sync]', error);
|
|
172
|
+
throw error;
|
|
173
|
+
}
|
|
174
|
+
});
|
|
147
175
|
/**
|
|
148
176
|
* @description Used to lockdown the 'sync' process in case of exceptions
|
|
149
177
|
*/
|
|
@@ -181,6 +209,7 @@ const fire = (req) => {
|
|
|
181
209
|
delete req.qs.sync_token;
|
|
182
210
|
delete req.path;
|
|
183
211
|
const syncResponse = response;
|
|
212
|
+
debug('Response [fire]', syncResponse.items.length);
|
|
184
213
|
if (syncResponse.items.length) {
|
|
185
214
|
return index_1.filterItems(syncResponse, config).then(() => {
|
|
186
215
|
if (syncResponse.items.length === 0) {
|
|
@@ -228,7 +257,7 @@ const fire = (req) => {
|
|
|
228
257
|
entry._content_type = lodash_1.cloneDeep(schemaResponse.content_type);
|
|
229
258
|
Q.push(entry);
|
|
230
259
|
});
|
|
231
|
-
return mapResolve();
|
|
260
|
+
return mapResolve('');
|
|
232
261
|
}
|
|
233
262
|
const err = new Error('Content type ${uid} schema not found!');
|
|
234
263
|
// Illegal content type call
|
|
@@ -259,6 +288,7 @@ const fire = (req) => {
|
|
|
259
288
|
return postProcess(req, syncResponse)
|
|
260
289
|
.then(resolve);
|
|
261
290
|
}).catch((error) => {
|
|
291
|
+
debug('Error [fire]', error);
|
|
262
292
|
if (inet_1.netConnectivityIssues(error)) {
|
|
263
293
|
flag.SQ = false;
|
|
264
294
|
}
|
|
@@ -296,7 +326,7 @@ const postProcess = (req, resp) => {
|
|
|
296
326
|
else {
|
|
297
327
|
if (name === 'sync_token') {
|
|
298
328
|
flag.SQ = false;
|
|
299
|
-
return resolve();
|
|
329
|
+
return resolve('');
|
|
300
330
|
}
|
|
301
331
|
return fire(req)
|
|
302
332
|
.then(resolve)
|
package/dist/core/inet.js
CHANGED
|
@@ -8,6 +8,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
8
8
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
9
9
|
};
|
|
10
10
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.netConnectivityIssues = exports.checkNetConnectivity = exports.init = void 0;
|
|
11
12
|
const debug_1 = __importDefault(require("debug"));
|
|
12
13
|
const dns_socket_1 = __importDefault(require("dns-socket"));
|
|
13
14
|
const events_1 = require("events");
|
|
@@ -65,10 +66,7 @@ exports.checkNetConnectivity = () => {
|
|
|
65
66
|
});
|
|
66
67
|
};
|
|
67
68
|
exports.netConnectivityIssues = (error) => {
|
|
68
|
-
if (error.code === 'ENOTFOUND') {
|
|
69
|
-
return true;
|
|
70
|
-
}
|
|
71
|
-
else if (error.code === 'ETIMEDOUT') {
|
|
69
|
+
if (error.code === 'ENOTFOUND' || error.code === 'ETIMEDOUT') {
|
|
72
70
|
return true;
|
|
73
71
|
}
|
|
74
72
|
return false;
|
package/dist/core/plugins.js
CHANGED
|
@@ -8,6 +8,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
8
8
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
9
9
|
};
|
|
10
10
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.load = void 0;
|
|
11
12
|
const debug_1 = __importDefault(require("debug"));
|
|
12
13
|
const lodash_1 = require("lodash");
|
|
13
14
|
const index_1 = require("../util/index");
|
package/dist/core/process.js
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* MIT Licensed
|
|
6
6
|
*/
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.configure = void 0;
|
|
8
9
|
/**
|
|
9
10
|
* @note 'SIGKILL' cannot have a listener installed, it will unconditionally terminate Node.js on all platforms.
|
|
10
11
|
* @note 'SIGSTOP' cannot have a listener installed.
|
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) :
|
|
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");
|
|
@@ -142,17 +144,7 @@ class Q extends events_1.EventEmitter {
|
|
|
142
144
|
*/
|
|
143
145
|
process(data) {
|
|
144
146
|
notify(data._type, data);
|
|
145
|
-
|
|
146
|
-
case 'publish':
|
|
147
|
-
this.exec(data, data._type);
|
|
148
|
-
break;
|
|
149
|
-
case 'unpublish':
|
|
150
|
-
this.exec(data, data._type);
|
|
151
|
-
break;
|
|
152
|
-
default:
|
|
153
|
-
this.exec(data, data._type);
|
|
154
|
-
break;
|
|
155
|
-
}
|
|
147
|
+
this.exec(data, data._type);
|
|
156
148
|
}
|
|
157
149
|
/**
|
|
158
150
|
* @description Execute and manager current processing item. Calling 'before' and 'after' hooks appropriately
|
|
@@ -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) :
|
|
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.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");
|
|
@@ -27,7 +29,7 @@ let counter = 0;
|
|
|
27
29
|
* @param {String} type - Token type (checkpoint | current)
|
|
28
30
|
*/
|
|
29
31
|
exports.getToken = () => {
|
|
30
|
-
return new Promise((resolve, reject) => __awaiter(
|
|
32
|
+
return new Promise((resolve, reject) => __awaiter(void 0, void 0, void 0, function* () {
|
|
31
33
|
try {
|
|
32
34
|
const config = index_1.getConfig();
|
|
33
35
|
const checkpoint = config.paths.checkpoint;
|
|
@@ -58,7 +60,7 @@ exports.getToken = () => {
|
|
|
58
60
|
*/
|
|
59
61
|
exports.saveToken = (name, token) => {
|
|
60
62
|
debug(`Save token invoked with name: ${name}, token: ${token}`);
|
|
61
|
-
return new Promise((resolve, reject) => __awaiter(
|
|
63
|
+
return new Promise((resolve, reject) => __awaiter(void 0, void 0, void 0, function* () {
|
|
62
64
|
try {
|
|
63
65
|
const config = index_1.getConfig();
|
|
64
66
|
const path = config.paths.token;
|
|
@@ -108,7 +110,7 @@ exports.saveToken = (name, token) => {
|
|
|
108
110
|
* @param {String} token - Token value
|
|
109
111
|
* @param {String} type - Token type
|
|
110
112
|
*/
|
|
111
|
-
exports.saveCheckpoint = (name, token) => __awaiter(
|
|
113
|
+
exports.saveCheckpoint = (name, token) => __awaiter(void 0, void 0, void 0, function* () {
|
|
112
114
|
debug(`Save token invoked with name: ${name}, token: ${token}`);
|
|
113
115
|
const config = index_1.getConfig();
|
|
114
116
|
const path = config.paths.checkpoint;
|
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) :
|
|
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.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,7 +25,7 @@ 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
|
|
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");
|
|
@@ -46,7 +48,7 @@ exports.pop = () => {
|
|
|
46
48
|
index_1.pop();
|
|
47
49
|
};
|
|
48
50
|
exports.getAssetLocation = (asset) => {
|
|
49
|
-
return new Promise((resolve, reject) => __awaiter(
|
|
51
|
+
return new Promise((resolve, reject) => __awaiter(void 0, void 0, void 0, function* () {
|
|
50
52
|
try {
|
|
51
53
|
const assetStoreConfig = assetStore.getConfig();
|
|
52
54
|
const assetConfig = (assetStoreConfig.assetStore) ? assetStoreConfig.assetStore : assetStoreConfig;
|
|
@@ -111,7 +113,7 @@ exports.getConfig = () => {
|
|
|
111
113
|
* @param {object} instance Custom logger instance
|
|
112
114
|
*/
|
|
113
115
|
var logger_2 = require("./util/logger");
|
|
114
|
-
exports
|
|
116
|
+
Object.defineProperty(exports, "setLogger", { enumerable: true, get: function () { return logger_2.setLogger; } });
|
|
115
117
|
/**
|
|
116
118
|
* @public
|
|
117
119
|
* @method start
|
package/dist/plugins/helper.js
CHANGED
|
@@ -57,7 +57,7 @@ exports.buildReferencePaths = (schema, entryReferences = {}, assetReferences = {
|
|
|
57
57
|
this.buildReferencePaths(field.schema, entryReferences, assetReferences, ((parent) ? `${parent}.${field.uid}` : field.uid));
|
|
58
58
|
}
|
|
59
59
|
else if (field.data_type === fieldType.BLOCKS && Array.isArray(field.blocks)) {
|
|
60
|
-
const blockParent =
|
|
60
|
+
const blockParent = parent ? `${parent}.${field.uid}` : `${field.uid}`;
|
|
61
61
|
field.blocks.forEach((block) => {
|
|
62
62
|
if (block && block.schema && Array.isArray(block.schema)) {
|
|
63
63
|
let subBlockParent = `${blockParent}.${block.uid}`;
|
|
@@ -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
|
};
|
|
@@ -3,7 +3,6 @@ const helper = require('../helper');
|
|
|
3
3
|
const index = require('../../index');
|
|
4
4
|
const util = require('../../util/index');
|
|
5
5
|
module.exports = function SaveRteMarkdownAssets() {
|
|
6
|
-
const options = SaveRteMarkdownAssets.options;
|
|
7
6
|
SaveRteMarkdownAssets.beforeSync = (action, data, schema) => {
|
|
8
7
|
return new Promise((resolve, reject) => {
|
|
9
8
|
try {
|
package/dist/util/build-paths.js
CHANGED
package/dist/util/fs.js
CHANGED
|
@@ -9,9 +9,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
9
9
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.mkdir = exports.readFileSync = exports.readFile = exports.writeFile = exports.existsSync = void 0;
|
|
12
13
|
const Debug = require("debug");
|
|
13
14
|
const fs_1 = require("fs");
|
|
14
|
-
exports
|
|
15
|
+
Object.defineProperty(exports, "existsSync", { enumerable: true, get: function () { return fs_1.existsSync; } });
|
|
15
16
|
const mkdirp_1 = __importDefault(require("mkdirp"));
|
|
16
17
|
const path_1 = require("path");
|
|
17
18
|
const write_file_atomic_1 = __importDefault(require("write-file-atomic"));
|
|
@@ -112,9 +113,9 @@ exports.mkdir = (path) => {
|
|
|
112
113
|
* @description exports fs.stat
|
|
113
114
|
*/
|
|
114
115
|
var fs_2 = require("fs");
|
|
115
|
-
exports
|
|
116
|
+
Object.defineProperty(exports, "stat", { enumerable: true, get: function () { return fs_2.stat; } });
|
|
116
117
|
/**
|
|
117
118
|
* @description synchnonous way of creating nested folder directory structure
|
|
118
119
|
*/
|
|
119
120
|
var mkdirp_2 = require("mkdirp");
|
|
120
|
-
exports
|
|
121
|
+
Object.defineProperty(exports, "mkdirpSync", { enumerable: true, get: function () { return mkdirp_2.sync; } });
|
package/dist/util/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) :
|
|
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.getSchema = exports.filterUnwantedKeys = exports.normalizePluginPath = exports.getOrSetRTEMarkdownAssets = exports.getFile = exports.markCheckpoint = exports.formatItems = exports.groupItems = exports.formatSyncFilters = exports.filterItems = void 0;
|
|
19
21
|
const debug_1 = __importDefault(require("debug"));
|
|
20
22
|
const lodash_1 = require("lodash");
|
|
21
23
|
const marked_1 = __importDefault(require("marked"));
|
|
@@ -35,13 +37,17 @@ const assetType = 'sys_assets';
|
|
|
35
37
|
* @param {Object} config - Application config
|
|
36
38
|
* @returns {Promise} Returns a promise
|
|
37
39
|
*/
|
|
38
|
-
exports.filterItems = (response, config) => __awaiter(
|
|
40
|
+
exports.filterItems = (response, config) => __awaiter(void 0, void 0, void 0, function* () {
|
|
39
41
|
const locales = lodash_1.map(config.locales, 'code');
|
|
40
42
|
const filteredObjects = lodash_1.remove(response.items, (item) => {
|
|
41
43
|
// validate item structure. If the structure is not as expected, filter it out
|
|
42
44
|
if (!(validations_1.validateItemStructure(item))) {
|
|
43
45
|
return item;
|
|
44
46
|
}
|
|
47
|
+
// To handle content-type.
|
|
48
|
+
if (!item.data) {
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
45
51
|
// for published items
|
|
46
52
|
if (item.data.publish_details) {
|
|
47
53
|
return locales.indexOf(item.data.publish_details.locale) !== -1;
|
|
@@ -260,7 +266,7 @@ const findAssets = (parentEntry, key, schema, entry, bucket, isFindNotReplace) =
|
|
|
260
266
|
let matches;
|
|
261
267
|
let convertedText;
|
|
262
268
|
if (isMarkdown) {
|
|
263
|
-
convertedText = marked_1.default(entry);
|
|
269
|
+
convertedText = marked_1.default.marked(entry);
|
|
264
270
|
}
|
|
265
271
|
else {
|
|
266
272
|
convertedText = entry;
|
|
@@ -312,7 +318,7 @@ const iterate = (schema, entry, bucket, findNoteReplace, parentKeys) => {
|
|
|
312
318
|
const parentKey = parentKeys[index];
|
|
313
319
|
const subEntry = entry[parentKey];
|
|
314
320
|
if (subEntry && !(lodash_1.isEmpty(subEntry)) && index === (parentKeys.length - 1)) {
|
|
315
|
-
if (subEntry && subEntry
|
|
321
|
+
if (subEntry && subEntry.length) {
|
|
316
322
|
subEntry.forEach((subEntryItem, idx) => {
|
|
317
323
|
// tricky!
|
|
318
324
|
if (!(lodash_1.isEmpty(subEntryItem))) {
|
|
@@ -421,6 +427,10 @@ exports.filterUnwantedKeys = (action, data) => {
|
|
|
421
427
|
// Add option to delete embedded documents
|
|
422
428
|
const filterKeys = (data, unwantedKeys) => {
|
|
423
429
|
for (const key in unwantedKeys) {
|
|
430
|
+
// We need _content_type for handling asset published/unpublished events in entry object (Wherever it is referenced).
|
|
431
|
+
if (key === '_content_type') {
|
|
432
|
+
continue;
|
|
433
|
+
}
|
|
424
434
|
if (unwantedKeys[key] && data.hasOwnProperty(key)) {
|
|
425
435
|
delete data[key];
|
|
426
436
|
}
|
package/dist/util/logger.js
CHANGED
package/dist/util/promise.map.js
CHANGED
package/dist/util/series.js
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
4
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
5
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
6
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) :
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
9
|
});
|
|
9
10
|
};
|
|
10
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
-
exports.series =
|
|
12
|
+
exports.series = void 0;
|
|
13
|
+
exports.series = (promises, output = [], counter = 0) => __awaiter(void 0, void 0, void 0, function* () {
|
|
12
14
|
if (counter === promises.length) {
|
|
13
15
|
return output;
|
|
14
16
|
}
|
|
@@ -6,14 +6,16 @@
|
|
|
6
6
|
* MIT Licensed
|
|
7
7
|
*/
|
|
8
8
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
9
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
9
10
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
10
11
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
11
12
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
12
|
-
function step(result) { result.done ? resolve(result.value) :
|
|
13
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
13
14
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
14
15
|
});
|
|
15
16
|
};
|
|
16
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.saveFilteredItems = exports.saveFailedItems = void 0;
|
|
17
19
|
const index_1 = require("../index");
|
|
18
20
|
const fs_1 = require("./fs");
|
|
19
21
|
const index_2 = require("./index");
|
|
@@ -43,7 +45,7 @@ exports.saveFailedItems = (obj) => {
|
|
|
43
45
|
* @returns {Promise} Returns a promise
|
|
44
46
|
*/
|
|
45
47
|
exports.saveFilteredItems = (items, name, token) => {
|
|
46
|
-
return new Promise((resolve, reject) => __awaiter(
|
|
48
|
+
return new Promise((resolve, reject) => __awaiter(void 0, void 0, void 0, function* () {
|
|
47
49
|
try {
|
|
48
50
|
const config = index_1.getConfig();
|
|
49
51
|
let filename;
|
package/dist/util/validations.js
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* MIT Licensed
|
|
6
6
|
*/
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.validatePlugin = exports.validateItemStructure = exports.validateLogger = exports.validateExternalInput = exports.validateAssetStoreInstance = exports.validateContentStoreInstance = exports.validateListener = exports.validateContentStore = exports.validateAssetStore = exports.validateConfig = void 0;
|
|
8
9
|
const lodash_1 = require("lodash");
|
|
9
10
|
/**
|
|
10
11
|
* @public
|
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentstack/datasync-manager",
|
|
3
3
|
"author": "Contentstack LLC <support@contentstack.com>",
|
|
4
|
-
"version": "1.2.
|
|
4
|
+
"version": "1.2.4",
|
|
5
5
|
"description": "The primary module of Contentstack DataSync. Syncs Contentstack data with your server using Contentstack Sync API",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"debug": "4.
|
|
9
|
-
"dns-socket": "4.2.
|
|
8
|
+
"debug": "^4.3.4",
|
|
9
|
+
"dns-socket": "^4.2.2",
|
|
10
10
|
"lodash": "^4.17.21",
|
|
11
|
-
"marked": "^
|
|
12
|
-
"write-file-atomic": "
|
|
11
|
+
"marked": "^4.1.0",
|
|
12
|
+
"write-file-atomic": "4.0.2"
|
|
13
13
|
},
|
|
14
14
|
"devDependencies": {
|
|
15
15
|
"@semantic-release/commit-analyzer": "^9.0.2",
|
|
@@ -19,21 +19,22 @@
|
|
|
19
19
|
"@types/debug": "0.0.31",
|
|
20
20
|
"@types/jest": "23.3.11",
|
|
21
21
|
"@types/lodash": "4.14.119",
|
|
22
|
+
"@types/marked": "^4.0.7",
|
|
22
23
|
"@types/mkdirp": "0.5.2",
|
|
23
24
|
"@types/nock": "9.3.0",
|
|
24
25
|
"@types/node": "10.12.12",
|
|
25
26
|
"@types/rimraf": "2.0.2",
|
|
26
27
|
"@types/write-file-atomic": "2.1.1",
|
|
27
28
|
"eslint": "^8.14.0",
|
|
28
|
-
"jest": "
|
|
29
|
-
"jest-html-reporter": "^
|
|
30
|
-
"mkdirp": "0.
|
|
31
|
-
"nock": "10.0.6",
|
|
32
|
-
"rimraf": "2.6.2",
|
|
33
|
-
"semantic-release": "^19.0.
|
|
34
|
-
"ts-jest": "
|
|
35
|
-
"tslint": "5.18.0",
|
|
36
|
-
"typescript": "3.
|
|
29
|
+
"jest": "^29.0.3",
|
|
30
|
+
"jest-html-reporter": "^3.7.0",
|
|
31
|
+
"mkdirp": "^1.0.4",
|
|
32
|
+
"nock": "^10.0.6",
|
|
33
|
+
"rimraf": "^2.6.2",
|
|
34
|
+
"semantic-release": "^19.0.5",
|
|
35
|
+
"ts-jest": "^29.0.1",
|
|
36
|
+
"tslint": "^5.18.0",
|
|
37
|
+
"typescript": "^3.9.2"
|
|
37
38
|
},
|
|
38
39
|
"scripts": {
|
|
39
40
|
"clean": "rimraf dist typings coverage .tokens .ledger .checkpoint",
|
|
@@ -65,4 +66,4 @@
|
|
|
65
66
|
"url": "https://github.com/contentstack/datasync-manager/issues"
|
|
66
67
|
},
|
|
67
68
|
"homepage": "https://www.contentstack.com/docs/guide/synchronization/contentstack-datasync"
|
|
68
|
-
}
|
|
69
|
+
}
|