@contentstack/datasync-mongodb-sdk 1.0.9-beta.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.
Files changed (70) hide show
  1. package/.github/workflows/codeql-analysis.yml +68 -0
  2. package/.github/workflows/jira.yml +33 -0
  3. package/.github/workflows/release.yml +77 -0
  4. package/.github/workflows/sast-scan.yml +11 -0
  5. package/.github/workflows/sca-scan.yml +15 -0
  6. package/.talismanrc +4 -0
  7. package/CODEOWNERS +1 -0
  8. package/LICENCE +21 -0
  9. package/README.md +191 -0
  10. package/SECURITY.md +27 -0
  11. package/contentstack-datasync-mongodb-sdk-1.0.9-beta.1.tgz +0 -0
  12. package/dist/config.js +47 -0
  13. package/dist/index.js +42 -0
  14. package/dist/stack.js +2272 -0
  15. package/dist/util.js +86 -0
  16. package/docs/fonts/OpenSans-Bold-webfont.eot +0 -0
  17. package/docs/fonts/OpenSans-Bold-webfont.svg +1830 -0
  18. package/docs/fonts/OpenSans-Bold-webfont.woff +0 -0
  19. package/docs/fonts/OpenSans-BoldItalic-webfont.eot +0 -0
  20. package/docs/fonts/OpenSans-BoldItalic-webfont.svg +1830 -0
  21. package/docs/fonts/OpenSans-BoldItalic-webfont.woff +0 -0
  22. package/docs/fonts/OpenSans-Italic-webfont.eot +0 -0
  23. package/docs/fonts/OpenSans-Italic-webfont.svg +1830 -0
  24. package/docs/fonts/OpenSans-Italic-webfont.woff +0 -0
  25. package/docs/fonts/OpenSans-Light-webfont.eot +0 -0
  26. package/docs/fonts/OpenSans-Light-webfont.svg +1831 -0
  27. package/docs/fonts/OpenSans-Light-webfont.woff +0 -0
  28. package/docs/fonts/OpenSans-LightItalic-webfont.eot +0 -0
  29. package/docs/fonts/OpenSans-LightItalic-webfont.svg +1835 -0
  30. package/docs/fonts/OpenSans-LightItalic-webfont.woff +0 -0
  31. package/docs/fonts/OpenSans-Regular-webfont.eot +0 -0
  32. package/docs/fonts/OpenSans-Regular-webfont.svg +1831 -0
  33. package/docs/fonts/OpenSans-Regular-webfont.woff +0 -0
  34. package/docs/global.html +7520 -0
  35. package/docs/global.html#Stack +1070 -0
  36. package/docs/index.html +291 -0
  37. package/docs/index.js.html +92 -0
  38. package/docs/scripts/linenumber.js +25 -0
  39. package/docs/scripts/prettify/Apache-License-2.0.txt +202 -0
  40. package/docs/scripts/prettify/lang-css.js +2 -0
  41. package/docs/stack.js.html +2244 -0
  42. package/docs/styles/jsdoc-default.css +358 -0
  43. package/docs/styles/prettify-jsdoc.css +111 -0
  44. package/docs/styles/prettify-tomorrow.css +132 -0
  45. package/example/index.js +56 -0
  46. package/package.json +59 -0
  47. package/test/comparison-operators.ts +257 -0
  48. package/test/conditional-operators.ts +106 -0
  49. package/test/config.ts +12 -0
  50. package/test/core.ts +333 -0
  51. package/test/count.ts +98 -0
  52. package/test/data/assets.ts +35 -0
  53. package/test/data/author.ts +168 -0
  54. package/test/data/blog.ts +138 -0
  55. package/test/data/category.ts +20 -0
  56. package/test/data/content_types.ts +164 -0
  57. package/test/data/products.ts +64 -0
  58. package/test/expressions.ts +108 -0
  59. package/test/include-exclude.ts +176 -0
  60. package/test/logical-operators.ts +140 -0
  61. package/test/projections.ts +109 -0
  62. package/test/queries.ts +143 -0
  63. package/test/references.ts +162 -0
  64. package/test/skip-limit.ts +150 -0
  65. package/test/sorting.ts +177 -0
  66. package/tslint.json +45 -0
  67. package/typings/config.d.ts +42 -0
  68. package/typings/index.d.ts +36 -0
  69. package/typings/stack.d.ts +1097 -0
  70. package/typings/util.d.ts +28 -0
@@ -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,33 @@
1
+ name: Create JIRA ISSUE
2
+ on:
3
+ pull_request:
4
+ types: [opened]
5
+ jobs:
6
+ security-jira:
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
+ Snyk | Vulnerability | ${{ github.event.repository.name }} | ${{ github.event.pull_request.title }}
25
+ description: |
26
+ PR: ${{ github.event.pull_request.html_url }}
27
+
28
+ fields: "${{ secrets.JIRA_FIELDS }}"
29
+ - name: Transition issue
30
+ uses: atlassian/gajira-transition@v3
31
+ with:
32
+ issue: ${{ steps.create.outputs.issue }}
33
+ transition: ${{ secrets.JIRA_TRANSITION }}
@@ -0,0 +1,77 @@
1
+ name: Release
2
+
3
+ on:
4
+ push:
5
+ branches: [feat/2326-npm-publish]
6
+
7
+ jobs:
8
+ build:
9
+ runs-on: ubuntu-latest
10
+ steps:
11
+ # Checkout the repository
12
+ - name: Checkout repository
13
+ uses: actions/checkout@v4
14
+
15
+ # Setup Node.js environment
16
+ - name: Setup Node.js
17
+ uses: actions/setup-node@v4
18
+ with:
19
+ node-version: "22.x"
20
+
21
+ # Install dependencies
22
+ - name: Install dependencies
23
+ run: npm install
24
+
25
+ # Fetch package details (name and version)
26
+ - name: Get package details
27
+ id: package
28
+ uses: codex-team/action-nodejs-package-info@v1.1
29
+
30
+ # Install npm-pack-all to create a package archive
31
+ - name: Install npm-pack-all
32
+ run: npm install npm-pack-all
33
+
34
+ # Pack the package into a .tgz archive
35
+ - name: Pack the npm package
36
+ run: node node_modules/.bin/npm-pack-all
37
+
38
+ # Publish the package to npm
39
+ - name: Publish to npm
40
+ id: publish_npm
41
+ uses: JS-DevTools/npm-publish@v3
42
+ with:
43
+ token: ${{ secrets.NPM_TOKEN }}
44
+ access: public # Uncomment this line if you want to publish the package as public for first time
45
+
46
+ # Auto-tag the new version if a change is detected
47
+ - name: Auto-tag new version
48
+ id: update_tag
49
+ uses: Klemensas/action-autotag@stable
50
+ with:
51
+ GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
52
+ tag_prefix: "v"
53
+
54
+ # Create a new GitHub Release
55
+ - name: Create GitHub Release
56
+ if: steps.update_tag.outputs.tagname != ''
57
+ uses: actions/create-release@v1
58
+ id: create_release
59
+ env:
60
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
61
+ with:
62
+ tag_name: ${{ steps.update_tag.outputs.tagname }}
63
+ release_name: Release ${{ steps.update_tag.outputs.tagname }}
64
+ draft: false
65
+ prerelease: false
66
+
67
+ # Upload the packaged .tgz file as a release asset
68
+ - name: Upload Release Asset
69
+ if: steps.update_tag.outputs.tagname != ''
70
+ uses: actions/upload-release-asset@v1
71
+ env:
72
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
73
+ with:
74
+ upload_url: ${{ steps.create_release.outputs.upload_url }}
75
+ asset_path: "./contentstack-datasync-mongodb-sdk-${{ steps.package.outputs.version }}.tgz"
76
+ asset_name: "contentstack-datasync-mongodb-sdk-${{ steps.package.outputs.version }}.tgz"
77
+ asset_content_type: application/tgz
@@ -0,0 +1,11 @@
1
+ name: SAST Scan
2
+ on:
3
+ pull_request:
4
+ types: [opened, synchronize, reopened]
5
+ jobs:
6
+ security-sast:
7
+ runs-on: ubuntu-latest
8
+ steps:
9
+ - uses: actions/checkout@v2
10
+ - name: Semgrep Scan
11
+ run: docker run -v /var/run/docker.sock:/var/run/docker.sock -v "${PWD}:/src" returntocorp/semgrep semgrep scan --config auto
@@ -0,0 +1,15 @@
1
+ name: Source Composition Analysis Scan
2
+ on:
3
+ pull_request:
4
+ types: [opened, synchronize, reopened]
5
+ jobs:
6
+ security-sca:
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 --fail-on=all
package/.talismanrc ADDED
@@ -0,0 +1,4 @@
1
+ fileignoreconfig:
2
+ - filename: package-lock.json
3
+ checksum: a618ae6c113021eef425f224f1dfd7066b15af1a45249ea063a193517ce5a92f
4
+ version: ""
package/CODEOWNERS ADDED
@@ -0,0 +1 @@
1
+ * @contentstack/security-admin
package/LICENCE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License
2
+
3
+ Copyright (c) 2025 Contentstack LLC <https://www.contentstack.com/>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,191 @@
1
+ [![Contentstack](https://www.contentstack.com/docs/static/images/contentstack.png)](https://www.contentstack.com/)
2
+
3
+ Contentstack is a headless CMS with an API-first approach. It is a CMS that developers can use to build powerful cross-platform applications in their favorite languages. Build your application frontend, and Contentstack will take care of the rest. [Read More](https://www.contentstack.com/).
4
+
5
+ ## Contentstack DataSync MongoDB SDK
6
+
7
+ [Contentstack DataSync](https://www.contentstack.com/docs/guide/synchronization/contentstack-datasync) provides MongoDB SDK to query applications that have locally stored contents in mongodb. Given below is the detailed guide and helpful resources to get started.
8
+
9
+ ### Prerequisite
10
+
11
+ - Nodejs, v20+
12
+ - MongoDB, v3.6 or higher
13
+ - You should have the data synced through [Contentstack DataSync](https://www.contentstack.com/docs/guide/synchronization/contentstack-datasync)
14
+
15
+ **Note**
16
+ For optimal performance, we recommend that you add indexes on the following keys of your collections
17
+ - `_content_type_uid: 1`
18
+ - `uid: 1`
19
+ - `locale: 1`
20
+ <!-- Since by default, the contents are sorted in descending order on 'updated_at' key -->
21
+ - `updated_at: -1`
22
+
23
+ ### Configuration
24
+
25
+ |Property|Type|Default value|Description|
26
+ |--|--|--|--|
27
+ |dbName|string|contentstack-persistent-db|**Optional** The MongoDB database name|
28
+ |collection|string|contents|**Optional** MongoDB database's collection names|
29
+ |url|string|mongodb://localhost:27017 |**Optional.** The MongoDB connection URI|
30
+ |limit|number|100|**Optional.** Caps the total no of objects returned in a single call|
31
+ |skip|number|0|**Optional.** Number of objects skipped before the result is returned|
32
+ | indexes | object |**[see config below](https://github.com/contentstack/datasync-content-store-mongodb#detailed-configs)** |**Optional.** Option to create db indexes via configuration|
33
+ |projections|object|**[see config below](https://github.com/contentstack/datasync-content-store-mongodb#detailed-configs)** |**Optional.** Mongodb projections. Keys provided here would be displayed/filtered out when fetching the result|
34
+ |options|object|**[see config below](https://github.com/contentstack/datasync-content-store-mongodb#detailed-configs)** |**Optional.** MongoDB connection options [Ref.](http://mongodb.github.io/node-mongodb-native/3.1/api/MongoClient.html) for more info|
35
+ |referenceDepth|number|2|**Optional** The default nested-reference-field depth that'd be considered when calling .includeReferences(). This can be overridden by passing a numerical argument to .includeReferences(4)|
36
+
37
+ ### Config Overview
38
+
39
+ Here's an overview of the SDK's configurable properties
40
+
41
+ ```ts
42
+ {
43
+ contentStore: {
44
+ collection: {
45
+ asset: 'contents',
46
+ entry: 'contents',
47
+ schema: 'content_types',
48
+ },
49
+ dbName: 'contentstack-db',
50
+ indexes: {
51
+ _content_type_uid: 1,
52
+ locale: 1,
53
+ uid: 1,
54
+ updated_at: -1,
55
+ },
56
+ limit: 100,
57
+ locale: 'en-us',
58
+ // http://mongodb.github.io/node-mongodb-native/3.1/api/MongoClient.html
59
+ options: {
60
+ autoReconnect: true,
61
+ connectTimeoutMS: 15000,
62
+ keepAlive: true,
63
+ noDelay: true,
64
+ reconnectInterval: 1000,
65
+ reconnectTries: 20,
66
+ useNewUrlParser: true,
67
+ },
68
+ projections: {
69
+ _content_type_uid: 0,
70
+ _id: 0,
71
+ },
72
+ referenceDepth: 2,
73
+ skip: 0,
74
+ url: 'mongodb://localhost:27017',
75
+ },
76
+ }
77
+ ```
78
+
79
+ ### Sample SDK Query
80
+
81
+ Here's a sample SDK query to get started.
82
+
83
+ Learn more on how to query using datasync-mongodb-sdk [here](https://contentstack.github.io/datasync-mongodb-sdk/).
84
+
85
+ ```ts
86
+ import { Contentstack } from 'datasync-mongodb-sdk'
87
+ const Stack = Contentstack.Stack(config)
88
+
89
+ Stack.connect()
90
+ .then(() => {
91
+ return Stack.contentType('blog')
92
+ .entries()
93
+ .language('en-gb') // Optional. If not provided, defaults to en-us
94
+ .include(['authors'])
95
+ .includeCount()
96
+ .includeContentType()
97
+ .queryReferences({'authors.firstName': 'R.R. Martin'})
98
+ .then((result) => {
99
+ // Your result would be
100
+ // {
101
+ // entries: [...], // All entries, who's first name is R.R. Martin
102
+ // content_type_uid: 'blog',
103
+ // locale: 'es-es',
104
+ // content_type: {...}, // Blog content type's schema
105
+ // count: 3, // Total count of blog content type
106
+ // }
107
+ })
108
+ })
109
+ .catch((error) => {
110
+ // handle errors..
111
+ })
112
+ ```
113
+ > Important: You need to call .connect(), to initiate SDK queries!
114
+
115
+ Once you have initialized the SDK, you can start querying on mongodb
116
+
117
+ ### Querying
118
+ - Notes
119
+ - By default, 'content_type_uid' and 'locale' keys as part of the response.
120
+ - If `.language()` is not provided, then the 1st language, provided in `config.defaultLocale` would be considered.
121
+ - If querying for a single entry/asset (using `.entry()` OR `.findOne()`), the result will be an object i.e. `{ entry: {} }`, if the entry or asset is not found, `{ entry: null }` will be returned.
122
+ - Querying multiple entries, would return `{ entries: [ {...} ] }`.
123
+ - By default, all entry responses would include their referred assets. If `.excludeReferences()` is called, no references (including assets) would **not** be returned in the response.
124
+
125
+ - Query a single entry
126
+ ```ts
127
+ // Sample 1. Returns the 1st entry that matches query filters
128
+ Stack.contentType('blog')
129
+ .entry() // OR .asset()
130
+ .find()
131
+ .then((result) => {
132
+ // Response
133
+ // result = {
134
+ // entry: any | null,
135
+ // content_type_uid: string,
136
+ // locale: string,
137
+ // }
138
+ })
139
+ .catch(reject)
140
+
141
+ // Sample 2. Returns the 1st entry that matches query filters
142
+ Stack.contentType('blogs')
143
+ .entries() // for .assets()
144
+ .findOne()
145
+ .then((result) => {
146
+ // Response
147
+ // result = {
148
+ // entry: any | null,
149
+ // content_type_uid: string,
150
+ // locale: string,
151
+ // }
152
+ })
153
+ .catch(reject)
154
+ ```
155
+
156
+ - Querying a set of entries, assets or content types
157
+ ```ts
158
+ Stack.contentType('blog')
159
+ .entries() // for .assets()
160
+ .includeCount()
161
+ .find()
162
+ .then((result) => {
163
+ // Response
164
+ // result = {
165
+ // entry: any | null,
166
+ // content_type_uid: string,
167
+ // count: number,
168
+ // locale: string,
169
+ // }
170
+ })
171
+ .catch(reject)
172
+ ```
173
+
174
+ ## Advanced Queries
175
+
176
+ In order to learn more about advance queries please refer the API documentation, [here](https://contentstack.github.io/datasync-mongodb-sdk/).
177
+
178
+ ### Further Reading
179
+
180
+ - [Getting started with Contentstack DataSync](https://www.contentstack.com/docs/guide/synchronization/contentstack-datasync)
181
+ - [Contentstack DataSync](https://www.contentstack.com/docs/guide/synchronization/contentstack-datasync/configuration-files-for-contentstack-datasync) doc lists the configuration for different modules
182
+
183
+ ### Support and Feature requests
184
+
185
+ If you have any issues working with the library, please file an issue [here](https://github.com/contentstack/datasync-mongodb-sdk/issues) at Github.
186
+
187
+ You can send us an e-mail at [support@contentstack.com](mailto:support@contentstack.com) if you have any support or feature requests. Our support team is available 24/7 on the intercom. You can always get in touch and give us an opportunity to serve you better!
188
+
189
+ ### License
190
+
191
+ This repository is published under the [MIT license](LICENSE).
package/SECURITY.md ADDED
@@ -0,0 +1,27 @@
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/dist/config.js ADDED
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ /*!
3
+ * Contentstack DataSync Mongodb SDK
4
+ * Copyright (c) 2019 Contentstack LLC
5
+ * MIT Licensed
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.config = void 0;
9
+ exports.config = {
10
+ contentStore: {
11
+ collection: {
12
+ asset: 'contents',
13
+ entry: 'contents',
14
+ schema: 'content_types',
15
+ },
16
+ dbName: 'contentstack-db',
17
+ indexes: {
18
+ _content_type_uid: 1,
19
+ locale: 1,
20
+ uid: 1,
21
+ updated_at: -1,
22
+ },
23
+ internal: {
24
+ types: {
25
+ assets: '_assets',
26
+ content_types: '_content_types',
27
+ references: '_references',
28
+ },
29
+ },
30
+ limit: 100,
31
+ locale: 'en-us',
32
+ // http://mongodb.github.io/node-mongodb-native/3.1/api/MongoClient.html
33
+ options: {
34
+ connectTimeoutMS: 15000,
35
+ // keepAlive: true, // The keepAlive option was deprecated in the Node.js Driver starting from version 5.3. In version 6.0 of the driver, the keepAlive option is permanently set to true
36
+ noDelay: true,
37
+ useNewUrlParser: true,
38
+ },
39
+ projections: {
40
+ _content_type_uid: 0,
41
+ _id: 0,
42
+ },
43
+ referenceDepth: 2,
44
+ skip: 0,
45
+ url: 'mongodb://localhost:27017',
46
+ },
47
+ };
package/dist/index.js ADDED
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ /*!
3
+ * Contentstack DataSync Mongodb SDK
4
+ * Copyright (c) 2019 Contentstack LLC
5
+ * MIT Licensed
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.Contentstack = void 0;
9
+ const stack_1 = require("./stack");
10
+ /**
11
+ * @class Stack
12
+ * @description Initialize an instance of `Stack`
13
+ * @api public
14
+ * @example
15
+ * const Stack = Contentstack.Stack({
16
+ * contentStore: {
17
+ * baseDir: '../../dev-contents'
18
+ * },
19
+ * locales: [
20
+ * {
21
+ * code: 'en-us',
22
+ * relative_url_prefix: '/'
23
+ * }
24
+ * ]
25
+ * })
26
+ *
27
+ * @returns {Stack} Returns Stack method, which's used to create an instance of Stack
28
+ */
29
+ class Contentstack {
30
+ /**
31
+ * @public
32
+ * @method Stack
33
+ * @summary Initialize Stack instance
34
+ * @param {object} config Stack config
35
+ * @param {object} db Existing db connection
36
+ * @returns {Stack} - Returns an instance of `Stack`
37
+ */
38
+ static Stack(config, db) {
39
+ return new stack_1.Stack(config, db);
40
+ }
41
+ }
42
+ exports.Contentstack = Contentstack;