Skip to content

Commit 750d8f5

Browse files
committed
Package name and create function sample update
1 parent 15a5024 commit 750d8f5

23 files changed

Lines changed: 237 additions & 169 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Changelog
2+
3+
## [v1.0.0](https://github.com/contentstack/contentstack-management-javascript/tree/v1.0.0) (2020-07-11)
4+
- Initial release for Contentstack CMA base JS management SDK

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ You need Node.js version 10 or above installed on your machine to use the Conten
1616
#### Node
1717
Install it via npm:
1818
```bash
19-
npm i contentstack-management
19+
npm i @contentstack/management
2020
```
2121
To import the SDK, use the following command:
2222
```
23-
import contentstack from ‘@contentstack/contentstack-management’
23+
import contentstack from ‘@contentstack/management’
2424
```
2525
To initialize the SDK, you will need to pass ```axios``` instance as follows:
2626
```
@@ -59,7 +59,7 @@ contentstackClient.stack('API_KEY', 'MANAGEMENT_TOKEN')
5959
#### Initializing Your SDK:
6060
To use the JavaScript CMA SDK, you need to first initialize it. To do this, use the following code:
6161
```
62-
import contentstack from ‘@contentstack/contentstack-management’
62+
import contentstack from ‘@contentstack/management’
6363
import axios from 'axios'
6464
6565
var contentstackClient = contentstack.client(axios, { authtoken: 'AUTHTOKEN' })

lib/contentstack.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import packages from '../package.json'
2323
* @prop {string} params.integration - Integration name and version e.g react/version
2424
* @returns Contentstack.Client
2525
* @example
26-
* import * as contentstack from 'contentstack'
26+
* import * as contentstack from '@contentstack/management'
2727
* const client = contentstack.client({
2828
*
2929
* })

lib/contentstackClient.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export default function contentstackClient ({ http }) {
1818
* @prop {string} paramters.token - token for user to login
1919
* @returns {Promise}
2020
* @example
21-
* import * as contentstack from 'contentstack'
21+
* import * as contentstack from '@contentstack/management'
2222
* const client = contentstack.client({})
2323
*
2424
* client.login({ email: <emailid>, password: <password> })
@@ -43,7 +43,7 @@ export default function contentstackClient ({ http }) {
4343
* @func getUser
4444
* @returns {Promise}
4545
* @example
46-
* import * as contentstack from 'contentstack'
46+
* import * as contentstack from '@contentstack/management'
4747
* const client = contentstack.client({})
4848
*
4949
* client.getUser()
@@ -64,34 +64,34 @@ export default function contentstackClient ({ http }) {
6464
* @returns {Stack} Instance of Stack
6565
*
6666
* @example
67-
* import * as contentstack from 'contentstack'
67+
* import * as contentstack from '@contentstack/management'
6868
* const client = contentstack.client({})
69-
*
70-
* client.stack().create({name: 'My New Stack'}, { organization_uid: 'org_uid' })
69+
* const stack = {name: 'My New Stack'}
70+
* client.stack().create({ stack }, { organization_uid: 'org_uid' })
7171
* .then((stack) => console.log(stack))
7272
*
7373
* @example
74-
* import * as contentstack from 'contentstack'
74+
* import * as contentstack from '@contentstack/management'
7575
* const client = contentstack.client({})
7676
*
7777
* client.stack('api_key').fetch()
7878
* .then((stack) => console.log(stack))
7979
*
8080
* @example
81-
* import * as contentstack from 'contentstack'
81+
* import * as contentstack from '@contentstack/management'
8282
* const client = contentstack.client({})
8383
*
8484
* client.stack('api_key', 'management_token').fetch()
8585
* .then((stack) => console.log(stack))
8686
*
8787
*/
88-
function stack (apiKey = null, managmentToken = null) {
88+
function stack (apiKey = null, managementToken = null) {
8989
var stack = {}
9090
if (apiKey && apiKey !== undefined) {
9191
stack.api_key = apiKey
9292
}
93-
if (managmentToken && managmentToken !== undefined) {
94-
stack.authorization = managmentToken
93+
if (managementToken && managementToken !== undefined) {
94+
stack.authorization = managementToken
9595
}
9696
return new Stack(http, { stack })
9797
}
@@ -104,14 +104,14 @@ export default function contentstackClient ({ http }) {
104104
* @returns {Organization} Instance of Organization.
105105
*
106106
* @example
107-
* import * as contentstack from 'contentstack'
107+
* import * as contentstack from '@contentstack/management'
108108
* const client = contentstack.client({})
109109
*
110110
* client.organization().query().find()
111111
* .then((organization) => console.log(organization))
112112
*
113113
* @example
114-
* import * as contentstack from 'contentstack'
114+
* import * as contentstack from '@contentstack/management'
115115
* const client = contentstack.client({})
116116
*
117117
* client.organization('org_uid').fetch()
@@ -130,7 +130,7 @@ export default function contentstackClient ({ http }) {
130130
* @returns {Object} Response object.
131131
*
132132
* @example
133-
* import * as contentstack from 'contentstack'
133+
* import * as contentstack from '@contentstack/management'
134134
* const client = contentstack.client({})
135135
* const notice = client.logout()
136136
*

lib/organization/index.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export function Organization (http, data) {
2323
* @param {Int} include_plan The include_plan parameter includes the details of the plan that the organization has subscribed to.
2424
* @returns {Promise<Organization.Organization>} Promise for Organization instance
2525
* @example
26-
* import * as contentstack from 'contentstack'
26+
* import * as contentstack from '@contentstack/management'
2727
* const client = contentstack.client({})
2828
*
2929
* client.organization('organization_uid).fetch()
@@ -45,7 +45,7 @@ export function Organization (http, data) {
4545
* @param {String} typeahead The type head contains value to be included in search.
4646
* @returns {ContentstackCollection} Instance of ContentstackCollection.
4747
* @example
48-
* import * as contentstack from 'contentstack'
48+
* import * as contentstack from '@contentstack/management'
4949
* const client = contentstack.client({})
5050
*
5151
* client.organization('organization_uid).stacks({ include_count: true })
@@ -72,7 +72,7 @@ export function Organization (http, data) {
7272
* @param {String} email The email address of the user to whom you wish to transfer the ownership of the organization.
7373
* @returns {Object} Response Object.
7474
* @example
75-
* import * as contentstack from 'contentstack'
75+
* import * as contentstack from '@contentstack/management'
7676
* const client = contentstack.client({})
7777
*
7878
* client.stack('api_key').transferOwnership('emailId')
@@ -98,7 +98,7 @@ export function Organization (http, data) {
9898
* @func addUser
9999
* @returns {ContentstackCollection} ContentstackCollection of instance.
100100
* @example
101-
* import * as contentstack from 'contentstack'
101+
* import * as contentstack from '@contentstack/management'
102102
* const client = contentstack.client({})
103103
*
104104
* client.organization('organization_uid).addUser({ users: { 'abc@test.com': ['org_uid1', 'org_uid2' ]}, stacks: { 'abc@test.com': { 'api_key1': [ 'stack_role_id' ] } } })
@@ -124,7 +124,7 @@ export function Organization (http, data) {
124124
* @func getInvitations
125125
* @returns {String} Success message of invitation send.
126126
* @example
127-
* import * as contentstack from 'contentstack'
127+
* import * as contentstack from '@contentstack/management'
128128
* const client = contentstack.client({})
129129
*
130130
* client.organization('organization_uid).getInvitations()
@@ -150,7 +150,7 @@ export function Organization (http, data) {
150150
* @func resendInvitition
151151
* @returns {Object} Response Object.
152152
* @example
153-
* import * as contentstack from 'contentstack'
153+
* import * as contentstack from '@contentstack/management'
154154
* const client = contentstack.client({})
155155
*
156156
* client.organization('organization_uid).resendInvitition('invitation_uid')
@@ -182,7 +182,7 @@ export function Organization (http, data) {
182182
* @param {Boolean} include_stack_roles The Include stack roles will return stack details in roles.
183183
* @returns {Array<Role>} Array of Role instance
184184
* @example
185-
* import * as contentstack from 'contentstack'
185+
* import * as contentstack from '@contentstack/management'
186186
* const client = contentstack.client({})
187187
*
188188
* client.organization('organization_uid).roles()
@@ -215,7 +215,7 @@ export function Organization (http, data) {
215215
* @param {String} typeahead The type head contains value to be included in search.
216216
* @returns {ContentstackCollection} Result collection of content of specified module.
217217
* @example
218-
* import * as contentstack from 'contentstack'
218+
* import * as contentstack from '@contentstack/management'
219219
* const client = contentstack.client({})
220220
*
221221
* client.organization().fetchAll()

lib/query/index.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ export default function Query (http, urlPath, param, stackHeaders = null, wrappe
1616
* @description This method will fetch content of query on specified module.
1717
* @returns {ContentstackCollection} Result collection of content of specified module.
1818
* @example All Stack
19-
* import * as contentstack from 'contentstack'
19+
* import * as contentstack from '@contentstack/management'
2020
* const client = contentstack.client({})
2121
*
2222
* client.stack().query().find()
2323
* .then((collection) => console.log(collection))
2424
*
2525
* @example Query on stack
26-
* import * as contentstack from 'contentstack'
26+
* import * as contentstack from '@contentstack/management'
2727
* const client = contentstack.client({})
2828
*
2929
* client.stack().query( { query: { name: 'Stack name' } }).find()
@@ -46,14 +46,14 @@ export default function Query (http, urlPath, param, stackHeaders = null, wrappe
4646
* @description This method will fetch count of content for query on specified module.
4747
* @returns {Object} Result is Object of content of specified module.
4848
* @example All Stack
49-
* import * as contentstack from 'contentstack'
49+
* import * as contentstack from '@contentstack/management'
5050
* const client = contentstack.client({})
5151
*
5252
* client.stack().query().count()
5353
* .then((response) => console.log(response))
5454
*
5555
* @example Query on Asset
56-
* import * as contentstack from 'contentstack'
56+
* import * as contentstack from '@contentstack/management'
5757
* const client = contentstack.client({})
5858
*
5959
* client.stack('api_key').query({ query: { title: 'Stack name' } }).count()
@@ -80,14 +80,14 @@ export default function Query (http, urlPath, param, stackHeaders = null, wrappe
8080
* @description This method will fetch content of query on specified module.
8181
* @returns {ContentstackCollection} Result content of specified module.
8282
* @example Stack
83-
* import * as contentstack from 'contentstack'
83+
* import * as contentstack from '@contentstack/management'
8484
* const client = contentstack.client({})
8585
*
8686
* client.stack().query().findOne()
8787
* .then((collection) => console.log(collection))
8888
*
8989
* @example Query on stack
90-
* import * as contentstack from 'contentstack'
90+
* import * as contentstack from '@contentstack/management'
9191
* const client = contentstack.client({})
9292
*
9393
* client.stack().query({ query: { title: 'Stack name' } }).findOne()

lib/stack/asset/folders/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ export function Folder (http, data = {}) {
2121
* @returns {Promise<Folder.Folder>} Promise for Folder instance
2222
*
2323
* @example
24-
* import * as contentstack from 'contentstack'
24+
* import * as contentstack from '@contentstack/management'
2525
* const client = contentstack.client({})
26-
*
27-
* client.stack().asset().folders().create({name: 'My New contentType'})
26+
* const asset = {name: 'My New contentType'}
27+
* client.stack().asset().folders().create({ asset })
2828
* .then((folder) => console.log(folder))
2929
*/
3030
this.create = create({ http: http })

lib/stack/asset/index.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export function Asset (http, data = {}) {
3333
* @func update
3434
* @returns {Promise<Asset.Asset>} Promise for Asset instance
3535
* @example
36-
* import * as contentstack from 'contentstack'
36+
* import * as contentstack from '@contentstack/management'
3737
* const client = contentstack.client({})
3838
*
3939
* client.stack('api_key').asset('uid').fetch()
@@ -53,7 +53,7 @@ export function Asset (http, data = {}) {
5353
* @func delete
5454
* @returns {Object} Response Object.
5555
* @example
56-
* import * as contentstack from 'contentstack'
56+
* import * as contentstack from '@contentstack/management'
5757
* const client = contentstack.client({})
5858
*
5959
* client.stack('api_key').asset('uid').delete()
@@ -67,7 +67,7 @@ export function Asset (http, data = {}) {
6767
* @func fetch
6868
* @returns {Promise<Asset.Asset>} Promise for Asset instance
6969
* @example
70-
* import * as contentstack from 'contentstack'
70+
* import * as contentstack from '@contentstack/management'
7171
* const client = contentstack.client({})
7272
*
7373
* client.stack('api_key').asset('uid').fetch()
@@ -82,7 +82,7 @@ export function Asset (http, data = {}) {
8282
* @func fetch
8383
* @returns {Promise<Asset.Asset>} Promise for Asset instance
8484
* @example
85-
* import * as contentstack from 'contentstack'
85+
* import * as contentstack from '@contentstack/management'
8686
* const client = contentstack.client({})
8787
*
8888
* const asset = {
@@ -111,7 +111,7 @@ export function Asset (http, data = {}) {
111111
* @func publish
112112
* @returns {Promise<Object>} Response Object.
113113
* @example
114-
* import * as contentstack from 'contentstack'
114+
* import * as contentstack from '@contentstack/management'
115115
* const client = contentstack.client({})
116116
*
117117
* const asset = {
@@ -135,7 +135,7 @@ export function Asset (http, data = {}) {
135135
* @func unpublish
136136
* @returns {Promise<Object>} Response Object.
137137
* @example
138-
* import * as contentstack from 'contentstack'
138+
* import * as contentstack from '@contentstack/management'
139139
* const client = contentstack.client({})
140140
*
141141
* const asset = {
@@ -160,7 +160,7 @@ export function Asset (http, data = {}) {
160160
* @returns {Promise<Folder.Folder>} Promise for Entry instance
161161
*
162162
* @example
163-
* import * as contentstack from 'contentstack'
163+
* import * as contentstack from '@contentstack/management'
164164
* const client = contentstack.client({})
165165
*/
166166
this.folder = () => {
@@ -175,7 +175,7 @@ export function Asset (http, data = {}) {
175175
* @returns {Promise<Asset.Asset>} Promise for Asset instance
176176
*
177177
* @example
178-
* import * as contentstack from 'contentstack'
178+
* import * as contentstack from '@contentstack/management'
179179
* const client = contentstack.client({})
180180
*
181181
* const asset = {
@@ -184,7 +184,7 @@ export function Asset (http, data = {}) {
184184
* description: 'Desc'
185185
* }
186186
*
187-
* client.stack('api_key').asset().create(asset)
187+
* client.stack('api_key').asset().create({ asset })
188188
* .then((asset) => console.log(asset))
189189
*/
190190
this.create = async function (data, params) {
@@ -208,7 +208,7 @@ export function Asset (http, data = {}) {
208208
* @returns {Array<Asset>} Array of Asset.
209209
*
210210
* @example
211-
* import * as contentstack from 'contentstack'
211+
* import * as contentstack from '@contentstack/management'
212212
* const client = contentstack.client({})
213213
*
214214
* client.stack().asset().query({ query: { filename: 'Asset Name' } }).find()

lib/stack/bulkOperation/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export function BulkOperation (http, data = {}) {
1717
* @param {Boolean} params.skip_workflow_stage_check Set this to 'true' to publish the entries that are at a workflow stage where they satisfy the applied publish rules.
1818
* @param {Boolean} params.approvals Set this to 'true' to publish the entries that do not require an approval to be published.
1919
* @example
20-
* import * as contentstack from 'contentstack'
20+
* import * as contentstack from '@contentstack/management'
2121
* const client = contentstack.client({})
2222
*
2323
* const publishDetails = {
@@ -71,7 +71,7 @@ export function BulkOperation (http, data = {}) {
7171
* @param {Boolean} params.skip_workflow_stage_check Set this to 'true' to publish the entries that are at a workflow stage where they satisfy the applied publish rules.
7272
* @param {Boolean} params.approvals Set this to 'true' to publish the entries that do not require an approval to be published.
7373
* @example
74-
* import * as contentstack from 'contentstack'
74+
* import * as contentstack from '@contentstack/management'
7575
* const client = contentstack.client({})
7676
*
7777
* const publishDetails = {
@@ -123,7 +123,7 @@ export function BulkOperation (http, data = {}) {
123123
* @returns {Promise<String>} Success message
124124
* @param {Boolean} params.details - Set this with details specifing the content type UIDs, entry UIDs or asset UIDs, and locales of which the entries or assets you want to delete.
125125
* @example
126-
* import * as contentstack from 'contentstack'
126+
* import * as contentstack from '@contentstack/management'
127127
* const client = contentstack.client({})
128128
*
129129
* const publishDetails = {

0 commit comments

Comments
 (0)