Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
83 commits
Select commit Hold shift + click to select a range
f03bed9
Initial commit
uttamukkoji Oct 17, 2019
d8a197c
Stack, User, Role, api added
uttamukkoji Oct 31, 2019
99ec99c
JSDoc, webpack implementation added
uttamukkoji Nov 6, 2019
f63bdeb
webpack added
uttamukkoji Nov 7, 2019
f535c96
Content type, Global fields, Entry, Assets
uttamukkoji Nov 25, 2019
5b33d39
organization module added with test case
uttamukkoji Nov 27, 2019
6cb91f5
Organization test case completed
uttamukkoji Nov 27, 2019
7eb086d
Organization test case completed
uttamukkoji Nov 27, 2019
53668e2
Organization test case completed
uttamukkoji Dec 2, 2019
c65ba18
Added Org Entry Delivery Global fields
uttamukkoji May 8, 2020
bb7e9e5
Entry Contenttype Environment DeliveryToken globalFields Locale added
uttamukkoji May 13, 2020
75e4b15
ContentType Cuircular bug resolved
uttamukkoji May 19, 2020
80bc3f6
Delivery token create functionality added
uttamukkoji Jun 3, 2020
7ba427d
Content type test case added
uttamukkoji Jun 23, 2020
32aa807
delete with params
uttamukkoji Jun 24, 2020
d4bebc2
Extension functionality added
uttamukkoji Jun 25, 2020
8d53648
ContentstackCollection include count issue resolved
uttamukkoji Jun 29, 2020
edce9fd
Webhook implementation and e2e test case completed
uttamukkoji Jul 6, 2020
3c97620
Global Field implementation, Documentation update for Query
uttamukkoji Jul 7, 2020
c34a70b
Releases functionality added
uttamukkoji Jul 21, 2020
c4a8bde
renaming ContentstackHTTPClient
uttamukkoji Jul 21, 2020
14f2214
renaming ContentstackHTTPClient
uttamukkoji Jul 21, 2020
26effb7
Entry publish error resolved
uttamukkoji Jul 22, 2020
fc2595f
Delivery token implementation
uttamukkoji Jul 22, 2020
e35801c
Management token support added to Stack
uttamukkoji Jul 23, 2020
ca72464
Asset and Folder implementation
uttamukkoji Jul 27, 2020
02a65af
Bulk publish and unpublish functionality added
uttamukkoji Jul 27, 2020
c11aa67
Bulk publish and unpublish functionality added
uttamukkoji Jul 27, 2020
5b02b11
Label implemetation added
uttamukkoji Jul 28, 2020
26ea357
entry test case
uttamukkoji Jul 29, 2020
e1ea3b8
entry test case
uttamukkoji Jul 29, 2020
278f002
Read me file and unused package removed
uttamukkoji Jul 30, 2020
77f1b99
Read me file and unused package removed
uttamukkoji Jul 30, 2020
dddadbf
Logout functionality added
uttamukkoji Jul 30, 2020
cda17d3
Environment variable addedgit
uttamukkoji Jul 30, 2020
8760bfb
removed sample
uttamukkoji Jul 30, 2020
7e5ddd3
Response message change from string to object
uttamukkoji Aug 5, 2020
0850e1d
build issue resolved
uttamukkoji Aug 5, 2020
6e041ff
update ignore file
uttamukkoji Aug 5, 2020
07fc429
package for browser update
uttamukkoji Aug 5, 2020
bc3aa47
User agent name from package file
uttamukkoji Aug 5, 2020
5994b12
Package file update & test case for user agent modified
uttamukkoji Aug 5, 2020
fa0b554
Package file update & test case for user agent modified
uttamukkoji Aug 5, 2020
a5b6c1a
Package file update & test case for user agent modified
uttamukkoji Aug 5, 2020
6cc94ee
missing Package added
uttamukkoji Aug 6, 2020
8bfc91d
Read me file documentation changes made
uttamukkoji Aug 6, 2020
9a9810c
read me doc review update
uttamukkoji Aug 6, 2020
6432ca1
Package name and create function sample update
uttamukkoji Aug 11, 2020
a937aea
Package name and create function sample update
uttamukkoji Aug 11, 2020
d872ec8
Package name and create function sample update
uttamukkoji Aug 11, 2020
cc2c957
API Mock folder created
uttamukkoji Aug 27, 2020
41cf07d
Test case updated
uttamukkoji Aug 28, 2020
d0efd63
Documentation update
uttamukkoji Aug 28, 2020
3a703e8
Dist update
uttamukkoji Aug 28, 2020
42d624b
User unit test added
uttamukkoji Aug 28, 2020
6fa0a47
Organization unit test
uttamukkoji Aug 28, 2020
e05d8f9
Stack, organization and role unit test
uttamukkoji Aug 31, 2020
24e58b9
Folder unit test case added
uttamukkoji Sep 1, 2020
aabb182
Extension test case
uttamukkoji Sep 1, 2020
2d68b1c
Release test case
uttamukkoji Sep 1, 2020
137a783
Release test case
uttamukkoji Sep 1, 2020
a47a00a
Asset test case
uttamukkoji Sep 1, 2020
f850de7
Readme update
uttamukkoji Sep 1, 2020
b310dd9
Webhook test case
uttamukkoji Sep 1, 2020
a4b81db
ContentType test case
uttamukkoji Sep 2, 2020
987d699
Global Fields test case
uttamukkoji Sep 2, 2020
6a85e15
Query test case
uttamukkoji Sep 2, 2020
f4095c3
Label test case
uttamukkoji Sep 2, 2020
74e5e48
Environment test case
uttamukkoji Sep 2, 2020
4b96589
Delivery token and Locale test case
uttamukkoji Sep 2, 2020
04eb3bb
Entry test case
uttamukkoji Sep 2, 2020
271a357
Entry import method added
uttamukkoji Sep 2, 2020
8584bff
Protocol configuration added
uttamukkoji Sep 7, 2020
3a2e724
Host test case added
uttamukkoji Sep 7, 2020
a6021b9
readme update
uttamukkoji Sep 9, 2020
08fe188
Updated Documentation sequence
uttamukkoji Sep 9, 2020
c2bee14
JSDoc config update
uttamukkoji Sep 9, 2020
f5cb050
Org doc change
uttamukkoji Sep 14, 2020
26eb414
Retry functionality update
uttamukkoji Sep 15, 2020
d345e0f
retry customBackoff update for not to retry if passed -1
uttamukkoji Sep 15, 2020
86ccde3
Retry condition test case added
uttamukkoji Sep 15, 2020
b152e4e
dist modul update
uttamukkoji Sep 23, 2020
1c742a1
dist modul update
uttamukkoji Sep 23, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .babel-preset.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
var plugins = [
'transform-object-rest-spread',
'lodash',
['inline-replace-variables', {
// Inject version number into code
'__VERSION__': require('./package.json').version
}]
]


function babelConfig () {
return plugins
}
module.exports = babelConfig
34 changes: 34 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"presets": ["@babel/preset-env"],
"plugins": [
["@babel/plugin-transform-runtime", {
"regenerator": true
}]
],
"env": {
"test": {
"presets": [
["@babel/env"]
],
"plugins": ["rewire"],
"sourceMaps": "inline"
},
"es5": {
"presets": [
["@babel/env"]
],
"plugins": [
"add-module-exports",
"@babel/plugin-transform-runtime",
"transform-es2015-modules-commonjs"
]
},
"es-modules": {
"presets": [
["@babel/env", {
"modules": false
}]
]
}
}
}
24 changes: 24 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
module.exports = {
// "env": {
// "browser": true,
// "amd": true
// },
"extends": "standard",
// "globals": {
// "Atomics": "readonly",
// "SharedArrayBuffer": "readonly"
// },
// "parserOptions": {
// "ecmaFeatures": {
// "jsx": true
// },
// "ecmaVersion": 2015,
// "sourceType": "module"
// },
'plugins': [
'standard',
'promise'
],
"rules": {
}
};
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Logs
logs
*.log
*.DS_Store
npm-debug.log*
yarn-debug.log*
yarn-error.log*
Expand Down Expand Up @@ -35,10 +36,14 @@ build/Release
# Dependency directories
node_modules/
jspm_packages/
jsdocs/
mochawesome-report/
coverage/
test/utility/dataFiles/

# TypeScript v1 declaration files
typings/

tsconfig.json
# Optional npm cache directory
.npm

Expand Down
47 changes: 47 additions & 0 deletions .jsdoc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"tags": {
"allowUnknownTags": true,
"dictionaries": ["jsdoc"]
},
"source": {
"include": [
"lib/contentstack.js",
"lib/contentstackClient.js",
"lib/user/index.js",
"lib/organization/index.js",
"lib/stack/index.js",
"lib/stack/contentType/index.js",
"lib/stack/globalField/index.js",
"lib/query/index.js",
"lib/stack/contentType/entry/index.js",
"lib/stack/asset/index.js",
"lib/stack/asset/folders/index.js",
"lib/stack/bulkOperation/index.js",
"lib/stack/extension/index.js",
"lib/stack/release/index.js",
"lib/stack/label/index.js",
"lib/stack/locale/index.js",
"lib/stack/environment/index.js",
"lib/stack/deliveryToken/index.js",
"lib/stack/roles/index.js",
"lib/stack/webhook/index.js"
],
"excludePattern": "(node_modules/|jsdocs)"
},
"templates": {
"cleverLinks": false,
"monospaceLinks": true
},
"opts": {
"destination": "./jsdocs/",
"encoding": "utf8",
"private": true,
"recurse": true,
"template": "./node_modules/docdash",
"sort": false
},
"docdash": {
"static": true,
"sort": false
}
}
17 changes: 17 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
docs-config.json
.idea/
.git/
test/
reports/
contentstack-templates/
jsdocs/
examples/
mocktest.json
Sample
coverage/
mochawesome-report/
.nyc_output/
typings
webpack/
tsconfig.json
.jsdoc.json
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Changelog

## [v1.0.0](https://github.com/contentstack/contentstack-management-javascript/tree/v1.0.0) (2020-09-23)
- Initial release for Contentstack CMA base JS management SDK
114 changes: 113 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,113 @@
# contentstack-management-javascript
[![Contentstack](https://www.contentstack.com/docs/static/images/contentstack.png)](https://www.contentstack.com/)

## Contentstack Management JavaScript SDK

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. All you have to do is build your application frontend, and Contentstack will take care of the rest. [Read More](https://www.contentstack.com/).

This SDK uses the [Content Management API](https://www.contentstack.com/docs/developers/apis/content-management-api/) (CMA). The CMA is used to manage the content of your Contentstack account. This includes creating, updating, deleting, and fetching content of your account. To use the CMA, you will need to authenticate your users with a [Management Token](https://www.contentstack.com/docs/developers/create-tokens/about-management-tokens) or an [Authtoken](https://www.contentstack.com/docs/developers/apis/content-management-api/#how-to-get-authtoken). Read more about it in [Authentication](https://www.contentstack.com/docs/developers/apis/content-management-api/#authentication).

Note: By using CMA, you can execute GET requests for fetching content. However, we strongly recommend that you always use the [Content Delivery API](https://www.contentstack.com/docs/developers/apis/content-delivery-api/) to deliver content to your web or mobile properties.

### Prerequisite

You need Node.js version 10 or above installed on your machine to use the Contentstack JavaScript CMA SDK.

### Installation
#### Node
Install it via npm:
```bash
npm i @contentstack/management
```
To import the SDK, use the following command:
```
import contentstack from ‘@contentstack/management’

contentstackClient = contentstack.client()
```

### Authentication
To use this SDK, you need to authenticate your users by using the Authtoken, credentials, or Management Token (stack-level token).
### Authtoken
An [Authtoken](https://www.contentstack.com/docs/developers/create-tokens/types-of-tokens/#authentication-tokens-authtokens-) is a read-write token used to make authorized CMA requests, and it is a **user-specific** token.
```
contentstackClient = contentstack.client({ authtoken: 'AUTHTOKEN' })
```
### Login
To Login to Contentstack by using credentials, you can use the following lines of code:
```
contentstackClient.login({ email: 'EMAIL', password: 'PASSWORD'})
.then((response) => {
console.log(response.notice)
console.log(response.user)
})
```

### Management Token
[Management Tokens](https://www.contentstack.com/docs/developers/create-tokens/about-management-tokens/) are **stack-level** tokens, with no users attached to them.
```
contentstackClient.stack({ api_key: 'API_KEY', management_token: 'MANAGEMENT_TOKEN' })
.fetch()
.then((stack) => {
console.log(stack)
})
```
### Contentstack Management JavaScript SDK: 5-minute Quickstart
#### Initializing Your SDK:
To use the JavaScript CMA SDK, you need to first initialize it. To do this, use the following code:
```
import contentstack from ‘@contentstack/management’

var contentstackClient = contentstack.client({ authtoken: 'AUTHTOKEN' })
```
#### Fetch Stack Detail
Use the following lines of code to fetch your stack detail using this SDK:
```
contentstackClient.stack({ api_key: 'API_KEY' })
.fetch()
.then((stack) => {
console.log(stack)
})
```

#### Create Entry
To create an entry in a specific content type of a stack, use the following lines of code:
```
var entry = {
title: 'Sample Entry',
url: '/sampleEntry'
}

contentstackClient.stack({ api_key: 'API_KEY' }).contentType('CONTENT_TYPE_UID').entry().create({ entry })
.then((entry) => {
console.log(entry)
})
```

#### Create Asset
The following lines of code can be used to upload assets to your stack:
```
var asset = {
upload: 'path/to/file',
title: 'Asset Title'
}

contentstackClient.stack({ api_key: 'API_KEY' }).asset().create({ asset })
.then((asset) => {
console.log(asset)
})
```

### Helpful Links

- [Contentstack Website](https://www.contentstack.com/)
- [Official Documentation](https://contentstack.com/docs)
- [Content Management API Docs](https://www.contentstack.com/docs/developers/apis/content-management-api)

### The MIT License (MIT)
Copyright © 2012-2020 [Contentstack](https://www.contentstack.com/). All Rights Reserved

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Loading