@contentstack/datasync-manager 2.0.0 → 2.0.1
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/LICENSE +1 -1
- package/dist/api.js +4 -2
- package/dist/core/q.js +4 -2
- package/dist/util/index.js +1 -1
- package/dist/util/validations.js +2 -2
- package/package.json +6 -1
- package/.github/ISSUE_TEMPLATE/bug_report.md +0 -31
- package/.github/ISSUE_TEMPLATE/feature_request.md +0 -20
- package/.github/workflows/codeql-analysis.yml +0 -68
- package/.github/workflows/jira.yml +0 -28
- package/.github/workflows/release.yml +0 -53
- package/.github/workflows/sast-scan.yml +0 -11
- package/.github/workflows/sca-scan.yml +0 -15
- package/.github/workflows/secrets-scan.yml +0 -11
- package/.releaserc +0 -9
- package/.talismanrc +0 -4
- package/CODEOWNERS +0 -1
- package/SECURITY.md +0 -27
- package/example/config.js +0 -60
- package/example/index.js +0 -30
- package/test/api.ts +0 -152
- package/test/core/filteredItems.ts +0 -58
- package/test/core/index.ts +0 -18
- package/test/core/inet.ts +0 -23
- package/test/core/q.ts +0 -42
- package/test/core/sync.ts +0 -19
- package/test/core/token-management.ts +0 -40
- package/test/dummy/api-responses/404.ts +0 -3
- package/test/dummy/api-responses/content-type.ts +0 -30
- package/test/dummy/api-responses/delete-asset.ts +0 -9
- package/test/dummy/api-responses/delete-content-type.ts +0 -6
- package/test/dummy/api-responses/delete-entry.ts +0 -9
- package/test/dummy/api-responses/delete.ts +0 -32
- package/test/dummy/api-responses/empty.ts +0 -7
- package/test/dummy/api-responses/entries.ts +0 -31
- package/test/dummy/api-responses/filter-items.ts +0 -32
- package/test/dummy/api-responses/global-field.ts +0 -175
- package/test/dummy/api-responses/markdown-content-type.ts +0 -202
- package/test/dummy/api-responses/markdown-entries.ts +0 -56
- package/test/dummy/api-responses/mixed.ts +0 -77
- package/test/dummy/api-responses/publish-asset.ts +0 -14
- package/test/dummy/api-responses/publish-entry.ts +0 -14
- package/test/dummy/api-responses/publish.ts +0 -35
- package/test/dummy/api-responses/references-content-type-2.ts +0 -240
- package/test/dummy/api-responses/references-content-type.ts +0 -272
- package/test/dummy/api-responses/references-entries.ts +0 -156
- package/test/dummy/api-responses/unpublish-asset.ts +0 -9
- package/test/dummy/api-responses/unpublish-entry.ts +0 -9
- package/test/dummy/api-responses/unpublish.ts +0 -26
- package/test/dummy/config.ts +0 -34
- package/test/dummy/connector-listener-instances.ts +0 -69
- package/test/dummy/filter-items.ts +0 -32
- package/test/dummy/plugins/myplugin1/index.js +0 -20
- package/test/dummy/plugins/myplugin2/index.js +0 -20
- package/test/dummy/references-content-type.ts +0 -340
- package/test/dummy/references-entry-expected.ts +0 -161
- package/test/dummy/references-entry.ts +0 -95
- package/test/index.ts +0 -330
- package/test/util/fs.ts +0 -92
- package/test/util/index.ts +0 -157
- package/test/util/log-save-filtered-items.ts +0 -42
- package/test/util/validations.ts +0 -158
- package/tslint.json +0 -53
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
The MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c)
|
|
3
|
+
Copyright (c) 2023 Contentstack LLC <https://www.contentstack.com/>
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
package/dist/api.js
CHANGED
|
@@ -28,9 +28,11 @@ const init = (contentstack) => {
|
|
|
28
28
|
Contentstack.headers = {
|
|
29
29
|
'X-User-Agent': `datasync-manager/v${packageInfo.version}`,
|
|
30
30
|
'access_token': Contentstack.deliveryToken,
|
|
31
|
-
'api_key': Contentstack.apiKey
|
|
32
|
-
branch: Contentstack.branch,
|
|
31
|
+
'api_key': Contentstack.apiKey
|
|
33
32
|
};
|
|
33
|
+
if (Contentstack.branch) {
|
|
34
|
+
Contentstack.headers['branch'] = Contentstack.branch;
|
|
35
|
+
}
|
|
34
36
|
if (Contentstack.MAX_RETRY_LIMIT) {
|
|
35
37
|
MAX_RETRY_LIMIT = Contentstack.MAX_RETRY_LIMIT;
|
|
36
38
|
}
|
package/dist/core/q.js
CHANGED
|
@@ -164,7 +164,8 @@ class Q extends events_1.EventEmitter {
|
|
|
164
164
|
const locale = data.locale;
|
|
165
165
|
const uid = data.uid;
|
|
166
166
|
const branch = (0, index_2.getConfig)().contentstack.branch;
|
|
167
|
-
|
|
167
|
+
if (branch)
|
|
168
|
+
data.branch = branch;
|
|
168
169
|
if (data.hasOwnProperty('_checkpoint')) {
|
|
169
170
|
checkpoint = data._checkpoint;
|
|
170
171
|
delete data._checkpoint;
|
|
@@ -211,7 +212,8 @@ class Q extends events_1.EventEmitter {
|
|
|
211
212
|
yield this.contentStore[action](data);
|
|
212
213
|
debug(`Completed '${action}' on connector successfully!`);
|
|
213
214
|
if (typeof schema !== 'undefined') {
|
|
214
|
-
|
|
215
|
+
if (branch)
|
|
216
|
+
schema.branch = branch;
|
|
215
217
|
yield this.contentStore.updateContentType(schema);
|
|
216
218
|
}
|
|
217
219
|
debug('Connector instance called successfully!');
|
package/dist/util/index.js
CHANGED
|
@@ -324,7 +324,7 @@ const iterate = (schema, entry, bucket, findNoteReplace, parentKeys) => {
|
|
|
324
324
|
const parentKey = parentKeys[index];
|
|
325
325
|
const subEntry = entry[parentKey];
|
|
326
326
|
if (subEntry && !((0, lodash_1.isEmpty)(subEntry)) && index === (parentKeys.length - 1)) {
|
|
327
|
-
if (subEntry && subEntry.length) {
|
|
327
|
+
if (subEntry instanceof Array && subEntry.length) {
|
|
328
328
|
subEntry.forEach((subEntryItem, idx) => {
|
|
329
329
|
// tricky!
|
|
330
330
|
if (!((0, lodash_1.isEmpty)(subEntryItem))) {
|
package/dist/util/validations.js
CHANGED
|
@@ -22,8 +22,8 @@ const validateConfig = (config) => {
|
|
|
22
22
|
throw new Error(`Config '${key}' key cannot be undefined`);
|
|
23
23
|
}
|
|
24
24
|
});
|
|
25
|
-
if (typeof config.contentstack !== 'object' || !config.contentstack.apiKey || !config.contentstack.deliveryToken
|
|
26
|
-
throw new Error('Config \'contentstack\' should be of type object and have \'apiKey\', \'token\'
|
|
25
|
+
if (typeof config.contentstack !== 'object' || !config.contentstack.apiKey || !config.contentstack.deliveryToken) {
|
|
26
|
+
throw new Error('Config \'contentstack\' should be of type object and have \'apiKey\', \'token\'');
|
|
27
27
|
}
|
|
28
28
|
if (config.queue) {
|
|
29
29
|
if (config.queue.resume_threshold >= config.queue.pause_threshold) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentstack/datasync-manager",
|
|
3
3
|
"author": "Contentstack LLC <support@contentstack.com>",
|
|
4
|
-
"version": "2.0.
|
|
4
|
+
"version": "2.0.1",
|
|
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": {
|
|
@@ -57,6 +57,11 @@
|
|
|
57
57
|
"DataSync",
|
|
58
58
|
"utility"
|
|
59
59
|
],
|
|
60
|
+
"files": [
|
|
61
|
+
"/dist",
|
|
62
|
+
"/typings",
|
|
63
|
+
"/npm-shrinkwrap.json"
|
|
64
|
+
],
|
|
60
65
|
"repository": {
|
|
61
66
|
"type": "git",
|
|
62
67
|
"url": "git+https://github.com/contentstack/datasync-manager"
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: Bug report
|
|
3
|
-
about: Create a report to help us improve
|
|
4
|
-
title: "[BUG]"
|
|
5
|
-
labels: bug
|
|
6
|
-
assignees: iyerrama29, ninadhatkar
|
|
7
|
-
|
|
8
|
-
---
|
|
9
|
-
|
|
10
|
-
**Describe the bug**
|
|
11
|
-
A clear and concise description of what the bug is.
|
|
12
|
-
|
|
13
|
-
**To Reproduce**
|
|
14
|
-
Steps to reproduce the behavior:
|
|
15
|
-
1. Setup
|
|
16
|
-
2. Configuration info (except api_key/tokens)
|
|
17
|
-
3. Content type schema & entry details / asset details (if possible)
|
|
18
|
-
4. Copy paste the error in detail
|
|
19
|
-
|
|
20
|
-
**Expected behavior**
|
|
21
|
-
A clear and concise description of what you expected to happen.
|
|
22
|
-
|
|
23
|
-
**Screenshots**
|
|
24
|
-
If applicable, add screenshots to help explain your problem.
|
|
25
|
-
|
|
26
|
-
**Desktop (please complete the following information):**
|
|
27
|
-
- OS: [e.g. iOS]
|
|
28
|
-
- Version [e.g. 22]
|
|
29
|
-
|
|
30
|
-
**Additional context**
|
|
31
|
-
Add any other context about the problem here.
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: Feature request
|
|
3
|
-
about: Suggest an idea for this project
|
|
4
|
-
title: "[FEATURE]"
|
|
5
|
-
labels: enhancement
|
|
6
|
-
assignees: iyerrama29, ninadhatkar
|
|
7
|
-
|
|
8
|
-
---
|
|
9
|
-
|
|
10
|
-
**Is your feature request related to a problem? Please describe.**
|
|
11
|
-
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
|
12
|
-
|
|
13
|
-
**Describe the solution you'd like**
|
|
14
|
-
A clear and concise description of what you want to happen.
|
|
15
|
-
|
|
16
|
-
**Describe alternatives you've considered**
|
|
17
|
-
A clear and concise description of any alternative solutions or features you've considered.
|
|
18
|
-
|
|
19
|
-
**Additional context**
|
|
20
|
-
Add any other context or screenshots about the feature request here.
|
|
@@ -1,68 +0,0 @@
|
|
|
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
|
|
@@ -1,28 +0,0 @@
|
|
|
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 }}"
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
name: Release
|
|
2
|
-
on:
|
|
3
|
-
push:
|
|
4
|
-
branches:
|
|
5
|
-
- master
|
|
6
|
-
jobs:
|
|
7
|
-
build:
|
|
8
|
-
name: Build and upload
|
|
9
|
-
runs-on: ubuntu-latest
|
|
10
|
-
steps:
|
|
11
|
-
- name: Checkout
|
|
12
|
-
uses: actions/checkout@v2
|
|
13
|
-
with:
|
|
14
|
-
fetch-depth: 0
|
|
15
|
-
- name: Setup Node.js
|
|
16
|
-
uses: actions/setup-node@v1
|
|
17
|
-
with:
|
|
18
|
-
node-version: 12
|
|
19
|
-
- name: Install dependencies
|
|
20
|
-
run: npm install
|
|
21
|
-
- name: Build
|
|
22
|
-
run: npm run build-ts
|
|
23
|
-
- name: Upload dist
|
|
24
|
-
uses: actions/upload-artifact@v3
|
|
25
|
-
with:
|
|
26
|
-
name: dist
|
|
27
|
-
path: dist
|
|
28
|
-
|
|
29
|
-
release:
|
|
30
|
-
name: Download dist and release
|
|
31
|
-
runs-on: ubuntu-latest
|
|
32
|
-
needs: build
|
|
33
|
-
steps:
|
|
34
|
-
- name: Checkout
|
|
35
|
-
uses: actions/checkout@v2
|
|
36
|
-
with:
|
|
37
|
-
fetch-depth: 0
|
|
38
|
-
- name: Setup Node.js
|
|
39
|
-
uses: actions/setup-node@v1
|
|
40
|
-
with:
|
|
41
|
-
node-version: 12
|
|
42
|
-
- name: Install dependencies
|
|
43
|
-
run: npm install
|
|
44
|
-
- name: Download dist
|
|
45
|
-
uses: actions/download-artifact@v3
|
|
46
|
-
with:
|
|
47
|
-
name: dist
|
|
48
|
-
run: ls dist
|
|
49
|
-
- name: Release
|
|
50
|
-
env:
|
|
51
|
-
GH_TOKEN: ${{ secrets.GH_TOKEN }}
|
|
52
|
-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
53
|
-
run: npx semantic-release
|
|
@@ -1,11 +0,0 @@
|
|
|
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)
|
|
@@ -1,15 +0,0 @@
|
|
|
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/.releaserc
DELETED
package/.talismanrc
DELETED
package/CODEOWNERS
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
* @contentstack/security-admin @contentstack/cli-admin
|
package/SECURITY.md
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
## Security
|
|
2
|
-
|
|
3
|
-
Contentstack takes the security of our software products and services seriously, which includes all source code repositories managed through our GitHub organizations.
|
|
4
|
-
|
|
5
|
-
If you believe you have found a security vulnerability in any Contentstack-owned repository, please report it to us as described below.
|
|
6
|
-
|
|
7
|
-
## Reporting Security Issues
|
|
8
|
-
|
|
9
|
-
**Please do not report security vulnerabilities through public GitHub issues.**
|
|
10
|
-
|
|
11
|
-
Send email to [security@contentstack.com](mailto:security@contentstack.com).
|
|
12
|
-
|
|
13
|
-
You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message.
|
|
14
|
-
|
|
15
|
-
Please include the requested information listed below (as much as you can provide) to help us better understand the nature and scope of the possible issue:
|
|
16
|
-
|
|
17
|
-
- Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.)
|
|
18
|
-
- Full paths of source file(s) related to the manifestation of the issue
|
|
19
|
-
- The location of the affected source code (tag/branch/commit or direct URL)
|
|
20
|
-
- Any special configuration required to reproduce the issue
|
|
21
|
-
- Step-by-step instructions to reproduce the issue
|
|
22
|
-
- Proof-of-concept or exploit code (if possible)
|
|
23
|
-
- Impact of the issue, including how an attacker might exploit the issue
|
|
24
|
-
|
|
25
|
-
This information will help us triage your report more quickly.
|
|
26
|
-
|
|
27
|
-
[https://www.contentstack.com/trust/](https://www.contentstack.com/trust/)
|
package/example/config.js
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
contentstack: {
|
|
3
|
-
apiKey: '',
|
|
4
|
-
deliveryToken: ''
|
|
5
|
-
},
|
|
6
|
-
contentStore: {
|
|
7
|
-
dbName: 'contentstack',
|
|
8
|
-
collectionName: 'development'
|
|
9
|
-
},
|
|
10
|
-
assetStore: {
|
|
11
|
-
baseDir: './_development_contents'
|
|
12
|
-
},
|
|
13
|
-
plugins: [
|
|
14
|
-
{
|
|
15
|
-
disabled: false,
|
|
16
|
-
name: '_cs_internal_transform_entries',
|
|
17
|
-
// path: '',
|
|
18
|
-
options: {
|
|
19
|
-
// other overrides...
|
|
20
|
-
},
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
disabled: false,
|
|
24
|
-
name: '_cs_internal_transform_schemas',
|
|
25
|
-
options: {
|
|
26
|
-
logAssetPaths: true,
|
|
27
|
-
logReferencePaths: true,
|
|
28
|
-
// other overrides...
|
|
29
|
-
},
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
disabled: false,
|
|
33
|
-
name: '_cs_internal_save_rte_markdown_assets',
|
|
34
|
-
options: {
|
|
35
|
-
// other overrides...
|
|
36
|
-
},
|
|
37
|
-
},
|
|
38
|
-
],
|
|
39
|
-
syncManager: {
|
|
40
|
-
inet: {
|
|
41
|
-
dns: '8.8.8.8',
|
|
42
|
-
host: 'google.com',
|
|
43
|
-
port: 53,
|
|
44
|
-
retries: 2,
|
|
45
|
-
retryTimeout: 3 * 1000,
|
|
46
|
-
retryIncrement: 1 * 1000,
|
|
47
|
-
timeout: 6 * 1000,
|
|
48
|
-
type: 'A',
|
|
49
|
-
},
|
|
50
|
-
processTimeout: 0
|
|
51
|
-
},
|
|
52
|
-
// filtering now available!
|
|
53
|
-
// syncManager: {
|
|
54
|
-
// filters: {
|
|
55
|
-
// content_type_uid: ['authors'],
|
|
56
|
-
// locale: ['en-us'],
|
|
57
|
-
// action: ['publish']
|
|
58
|
-
// }
|
|
59
|
-
// }
|
|
60
|
-
}
|
package/example/index.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
const assetStore = require('@contentstack/datasync-asset-store-filesystem')
|
|
2
|
-
//const contentStore = require('@contentstack/datasync-content-store-mongodb')
|
|
3
|
-
|
|
4
|
-
const contentStore = require('@contentstack/datasync-content-store-filesystem')
|
|
5
|
-
const listener = require('@contentstack/webhook-listener')
|
|
6
|
-
const syncManager = require('../dist/index')
|
|
7
|
-
const config = require('./config')
|
|
8
|
-
|
|
9
|
-
syncManager.setAssetStore(assetStore)
|
|
10
|
-
syncManager.setContentStore(contentStore)
|
|
11
|
-
syncManager.setListener(listener)
|
|
12
|
-
syncManager.setConfig(config)
|
|
13
|
-
|
|
14
|
-
syncManager.start().then(() => {
|
|
15
|
-
console.log('Sync utility started successfully!')
|
|
16
|
-
}).catch(console.error)
|
|
17
|
-
|
|
18
|
-
syncManager.notifications
|
|
19
|
-
.on('publish', (obj) => {
|
|
20
|
-
// console.log('SYNC-PUBLISH: ', obj)
|
|
21
|
-
})
|
|
22
|
-
.on('unpublish', (obj) => {
|
|
23
|
-
// console.log('SYNC-UNPUBLISH: ', obj)
|
|
24
|
-
})
|
|
25
|
-
.on('delete', (obj) => {
|
|
26
|
-
// console.log('SYNC-DELETE: ', obj)
|
|
27
|
-
})
|
|
28
|
-
.on('error', (obj) => {
|
|
29
|
-
// console.log('SYNC-ERROR: ', obj)
|
|
30
|
-
})
|
package/test/api.ts
DELETED
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import { readFileSync } from 'fs'
|
|
3
|
-
import { cloneDeep, merge } from 'lodash'
|
|
4
|
-
import nock from 'nock'
|
|
5
|
-
import { join } from 'path'
|
|
6
|
-
import { get, init } from '../src/api'
|
|
7
|
-
import { config as internalConfig } from '../src/config'
|
|
8
|
-
import { setLogger } from '../src/util/logger'
|
|
9
|
-
import { response as emptyResponse } from './dummy/api-responses/empty'
|
|
10
|
-
import { response as publishResponse } from './dummy/api-responses/publish'
|
|
11
|
-
import { config as mockConfig } from './dummy/config'
|
|
12
|
-
|
|
13
|
-
const packageInfo: any = JSON.parse(readFileSync(join(__dirname, '..', 'package.json'), 'utf-8'))
|
|
14
|
-
|
|
15
|
-
beforeEach(() => {
|
|
16
|
-
const configs = cloneDeep(merge({}, internalConfig, mockConfig))
|
|
17
|
-
init(configs.contentstack)
|
|
18
|
-
|
|
19
|
-
nock('https://api.localhost.io', {
|
|
20
|
-
reqheaders: {
|
|
21
|
-
'access_token': 'dummyDeliveryToken',
|
|
22
|
-
'api_key': 'dummyApiKey',
|
|
23
|
-
'x-user-agent': `datasync-manager/v${packageInfo.version}`,
|
|
24
|
-
},
|
|
25
|
-
})
|
|
26
|
-
.get('/200')
|
|
27
|
-
// .query({sync_token: 'dummySyncToken', environment: 'test', limit: 100})
|
|
28
|
-
.reply(200, publishResponse)
|
|
29
|
-
|
|
30
|
-
nock('https://api.localhost.io', {
|
|
31
|
-
reqheaders: {
|
|
32
|
-
'access_token': 'dummyDeliveryToken',
|
|
33
|
-
'api_key': 'dummyApiKey',
|
|
34
|
-
'x-user-agent': `datasync-manager/v${packageInfo.version}`,
|
|
35
|
-
},
|
|
36
|
-
})
|
|
37
|
-
.get('/200')
|
|
38
|
-
.query({pagination_token: 'publish-token', environment: 'test', limit: 100})
|
|
39
|
-
.reply(200, emptyResponse)
|
|
40
|
-
|
|
41
|
-
nock('https://api.localhost.io', {
|
|
42
|
-
reqheaders: {
|
|
43
|
-
'access_token': 'dummyDeliveryToken',
|
|
44
|
-
'api_key': 'dummyApiKey',
|
|
45
|
-
'x-user-agent': `datasync-manager/v${packageInfo.version}`,
|
|
46
|
-
},
|
|
47
|
-
})
|
|
48
|
-
.get('/429')
|
|
49
|
-
.reply(429, emptyResponse)
|
|
50
|
-
|
|
51
|
-
nock('https://api.localhost.io', {
|
|
52
|
-
reqheaders: {
|
|
53
|
-
'access_token': 'dummyDeliveryToken',
|
|
54
|
-
'api_key': 'dummyApiKey',
|
|
55
|
-
'x-user-agent': `datasync-manager/v${packageInfo.version}`,
|
|
56
|
-
},
|
|
57
|
-
})
|
|
58
|
-
.get('/500')
|
|
59
|
-
.reply(500, publishResponse)
|
|
60
|
-
|
|
61
|
-
nock('https://api.localhost.io', {
|
|
62
|
-
reqheaders: {
|
|
63
|
-
'access_token': 'dummyDeliveryToken',
|
|
64
|
-
'api_key': 'dummyApiKey',
|
|
65
|
-
'x-user-agent': `datasync-manager/v${packageInfo.version}`,
|
|
66
|
-
},
|
|
67
|
-
})
|
|
68
|
-
.get('/retry-exceeded')
|
|
69
|
-
.reply(500, emptyResponse)
|
|
70
|
-
|
|
71
|
-
nock('https://api.localhost.io', {
|
|
72
|
-
reqheaders: {
|
|
73
|
-
'access_token': 'dummyDeliveryToken',
|
|
74
|
-
'api_key': 'dummyApiKey',
|
|
75
|
-
'x-user-agent': `datasync-manager/v${packageInfo.version}`,
|
|
76
|
-
},
|
|
77
|
-
})
|
|
78
|
-
.get('/unknown-status')
|
|
79
|
-
.reply(199, {
|
|
80
|
-
key: 'unknown reject',
|
|
81
|
-
})
|
|
82
|
-
})
|
|
83
|
-
|
|
84
|
-
describe('test api - get()', () => {
|
|
85
|
-
beforeAll(() => {
|
|
86
|
-
setLogger()
|
|
87
|
-
})
|
|
88
|
-
|
|
89
|
-
test('status 200: without errors', () => {
|
|
90
|
-
const request = {
|
|
91
|
-
path: '/200',
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
return get(request).then((response) => {
|
|
95
|
-
expect(response).toHaveProperty('items')
|
|
96
|
-
}).catch((error) => {
|
|
97
|
-
expect(error)
|
|
98
|
-
})
|
|
99
|
-
})
|
|
100
|
-
|
|
101
|
-
test('status 429: rate limit error', () => {
|
|
102
|
-
const request = {
|
|
103
|
-
path: '/429',
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
return get(request).then((response) => {
|
|
107
|
-
expect(response).toBe({})
|
|
108
|
-
}).catch((error) => {
|
|
109
|
-
expect(error)
|
|
110
|
-
})
|
|
111
|
-
})
|
|
112
|
-
|
|
113
|
-
test('server error', () => {
|
|
114
|
-
const request = {
|
|
115
|
-
path: '/500',
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
return get(request).then((response) => {
|
|
119
|
-
expect(response).toBe({})
|
|
120
|
-
}).catch((error) => {
|
|
121
|
-
console.error(error)
|
|
122
|
-
expect(error)
|
|
123
|
-
})
|
|
124
|
-
})
|
|
125
|
-
|
|
126
|
-
test('retry exceeded', () => {
|
|
127
|
-
const request = {
|
|
128
|
-
path: '/retry-exceeded',
|
|
129
|
-
}
|
|
130
|
-
const err = new Error('Max retry limit exceeded!')
|
|
131
|
-
return get(request, 9).then((response) => {
|
|
132
|
-
expect(response).toBe({})
|
|
133
|
-
}).catch((error) => {
|
|
134
|
-
expect(error).toMatchObject(err)
|
|
135
|
-
})
|
|
136
|
-
})
|
|
137
|
-
|
|
138
|
-
// test('unknown status', () => {
|
|
139
|
-
// const request = {
|
|
140
|
-
// path: '/unknown-status',
|
|
141
|
-
// }
|
|
142
|
-
// // const rej = {
|
|
143
|
-
// // key: 'unknown reject',
|
|
144
|
-
// // }
|
|
145
|
-
|
|
146
|
-
// // expect(get(request)).rejects.toHaveProperty('key')
|
|
147
|
-
// return get(request).catch((error) => {
|
|
148
|
-
// expect(error).toHaveProperty('key')
|
|
149
|
-
// })
|
|
150
|
-
// })
|
|
151
|
-
|
|
152
|
-
})
|