Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 2 additions & 1 deletion lib/core/concurrency-queue.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ export function ConcurrencyQueue ({ axios, config }) {
// Cool down the running requests
delay(wait, response.status === 401)
error.config.retryCount = networkError

// deepcode ignore Ssrf: URL is dynamic
return axios(updateRequestConfig(error, retryErrorType, wait))
}
if (this.config.retryCondition && this.config.retryCondition(error)) {
Expand Down Expand Up @@ -234,6 +234,7 @@ export function ConcurrencyQueue ({ axios, config }) {
error.config.retryCount = retryCount
return new Promise(function (resolve) {
return setTimeout(function () {
// deepcode ignore Ssrf: URL is dynamic
return resolve(axios(updateRequestConfig(error, retryErrorType, delaytime)))
}, delaytime)
})
Expand Down
9 changes: 8 additions & 1 deletion lib/entity.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,11 @@ export const exportObject = ({ http }) => {

export const query = ({ http, wrapperCollection }) => {
return function (params = {}) {
const headers = {
...cloneDeep(this.stackHeaders)
}
if (this.organization_uid) {
headers.organization_uid = this.organization_uid
if (!params.query) {
params.query = {}
}
Expand All @@ -128,7 +132,7 @@ export const query = ({ http, wrapperCollection }) => {
if (this.content_type_uid) {
params.content_type_uid = this.content_type_uid
}
return Query(http, this.urlPath, params, this.stackHeaders, wrapperCollection)
return Query(http, this.urlPath, params, headers, wrapperCollection)
}
}

Expand Down Expand Up @@ -212,6 +216,9 @@ export const fetch = (http, type, params = {}) => {
...cloneDeep(param)
}
} || {}
if (this.organization_uid) {
headers.headers.organization_uid = this.organization_uid
}

const response = await http.get(this.urlPath, headers)
if (response.data) {
Expand Down
136 changes: 67 additions & 69 deletions lib/organization/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ export function Organization (http, data) {
*
*/
this.fetch = fetch(http, 'organization')

if ((this.org_roles && (this.org_roles.filter(function (role) { return role.admin === true }).length > 0)) || (this.owner && this.owner === true) || (this.is_owner && this.is_owner === true)) {
/**
/**
* @description The Get all stacks in an organization call fetches the list of all stacks in an Organization.
* @memberof Organization
* @func stacks
Expand All @@ -53,20 +51,20 @@ export function Organization (http, data) {
* .then((collection) => console.log(collection))
*
*/
this.stacks = async (param) => {
try {
const response = await http.get(`${this.urlPath}/stacks`, { params: param })
if (response.data) {
return new ContentstackCollection(response, http, null, StackCollection)
} else {
return error(response)
}
} catch (err) {
return error(err)
this.stacks = async (param) => {
try {
const response = await http.get(`${this.urlPath}/stacks`, { params: param })
if (response.data) {
return new ContentstackCollection(response, http, null, StackCollection)
} else {
return error(response)
}
} catch (err) {
return error(err)
}
}

/**
/**
* @description The Transfer organization ownership call transfers the ownership of an Organization to another user.
* @memberof Organization
* @func transferOwnership
Expand All @@ -80,20 +78,20 @@ export function Organization (http, data) {
* .then((response) => console.log(response.notice))
*
*/
this.transferOwnership = async (email) => {
try {
const response = await http.post(`${this.urlPath}/transfer_ownership`, { transfer_to: email })
if (response.data) {
return response.data
} else {
return error(response)
}
} catch (err) {
return error(err)
this.transferOwnership = async (email) => {
try {
const response = await http.post(`${this.urlPath}/transfer_ownership`, { transfer_to: email })
if (response.data) {
return response.data
} else {
return error(response)
}
} catch (err) {
return error(err)
}
}

/**
/**
* @description The Add users to organization call allows you to send invitations to add users to your organization. Only the owner or the admin of the organization can add users.
* @memberof Organization
* @func addUser
Expand All @@ -106,20 +104,20 @@ export function Organization (http, data) {
* .then((response) => console.log(response))
*
*/
this.addUser = async (data) => {
try {
const response = await http.post(`${this.urlPath}/share`, { share: { ...data } })
if (response.data) {
return new ContentstackCollection(response, http, null, UserCollection)
} else {
return error(response)
}
} catch (err) {
return error(err)
this.addUser = async (data) => {
try {
const response = await http.post(`${this.urlPath}/share`, { share: { ...data } })
if (response.data) {
return new ContentstackCollection(response, http, null, UserCollection)
} else {
return error(response)
}
} catch (err) {
return error(err)
}
}

/**
/**
* @description The Get all organization invitations call gives you a list of all the Organization invitations.
* @memberof Organization
* @func getInvitations
Expand All @@ -132,20 +130,20 @@ export function Organization (http, data) {
* .then((response) => console.log(response.notice))
*
*/
this.getInvitations = async (param) => {
try {
const response = await http.get(`${this.urlPath}/share`, { params: param })
if (response.data) {
return new ContentstackCollection(response, http, null, UserCollection)
} else {
return error(response)
}
} catch (err) {
return error(err)
this.getInvitations = async (param) => {
try {
const response = await http.get(`${this.urlPath}/share`, { params: param })
if (response.data) {
return new ContentstackCollection(response, http, null, UserCollection)
} else {
return error(response)
}
} catch (err) {
return error(err)
}
}

/**
/**
* @description The Resend pending organization invitation call allows you to resend Organization invitations to users who have not yet accepted the earlier invitation.
* @memberof Organization
* @func resendInvitition
Expand All @@ -158,20 +156,20 @@ export function Organization (http, data) {
* .then((response) => console.log(response.notice))
*
*/
this.resendInvitation = async (invitationUid) => {
try {
const response = await http.get(`${this.urlPath}/${invitationUid}/resend_invitation`)
if (response.data) {
return response.data
} else {
return error(response)
}
} catch (err) {
return error(err)
this.resendInvitation = async (invitationUid) => {
try {
const response = await http.get(`${this.urlPath}/${invitationUid}/resend_invitation`)
if (response.data) {
return response.data
} else {
return error(response)
}
} catch (err) {
return error(err)
}
}

/**
/**
* @description A role is a collection of permissions that will be applicable to all the users who are assigned this role.
* @memberof Organization
* @func roles
Expand All @@ -190,19 +188,19 @@ export function Organization (http, data) {
* .then((roles) => console.log(roles))
*
*/
this.roles = async (param) => {
try {
const response = await http.get(`${this.urlPath}/roles`, { params: param })
if (response.data) {
return new ContentstackCollection(response, http, null, RoleCollection)
} else {
return error(response)
}
} catch (err) {
return error(err)
this.roles = async (param) => {
try {
const response = await http.get(`${this.urlPath}/roles`, { params: param })
if (response.data) {
return new ContentstackCollection(response, http, null, RoleCollection)
} else {
return error(response)
}
} catch (err) {
return error(err)
}
}

/**
* @description Market place application information
* @memberof Organization
Expand All @@ -229,7 +227,7 @@ export function Organization (http, data) {
* @param {Int} skip The ‘skip’ parameter will skip a specific number of organizations in the output.
* @param {String} asc The ‘asc’ parameter allows you to sort the list of organizations in the ascending order with respect to the value of a specific field.
* @param {String} desc The ‘desc’ parameter allows you to sort the list of Organizations in the descending order with respect to the value of a specific field.
* @param {Boolean}include_count The ‘include_count’ parameter returns the total number of organizations related to the user.
* @param {Boolean}include_count The ‘include_count’ parameter returns the total number of organizations related to the user.
* @param {String} typeahead The typeahead parameter is a type of filter that allows you to perform a name-based search on all organizations based on the value provided.
* @returns {ContentstackCollection} Result collection of content of specified module.
* @example
Expand Down
1 change: 0 additions & 1 deletion lib/stack/branch/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ export function Branch (http, data = {}) {
*
*/
this.fetch = fetch(http, 'branch')

} else {
/**
* @description The Create a Branch call creates a new branch in a particular stack of your Contentstack account.
Expand Down
15 changes: 7 additions & 8 deletions lib/stack/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,6 @@ export function Stack (http, data) {
return new Extension(http, data)
}


/**
* @description Workflow is a tool that allows you to streamline the process of content creation and publishing, and lets you manage the content lifecycle of your project smoothly.
* @param {String} workflowUid The UID of the Workflow you want to get details.
Expand Down Expand Up @@ -435,7 +434,7 @@ export function Stack (http, data) {
}

/**
* @description The Update User Role API Request updates the roles of an existing user account.
* @description The Update User Role API Request updates the roles of an existing user account.
* This API Request will override the existing roles assigned to a user
* @memberof Stack
* @func updateUsersRoles
Expand All @@ -447,20 +446,20 @@ export function Stack (http, data) {
* const users = {
* user_uid: ['role_uid_1', 'role_uid_2' ]
* }
*
*
* client.stack({ api_key: 'api_key'}).updateUsersRoles(users)
* .then((response) => console.log(response.notice))
*
*/
this.updateUsersRoles = async (users) => {
try {
const response = await http.post(`${this.urlPath}/users/roles`,
const response = await http.post(`${this.urlPath}/users/roles`,
{ users },
{
headers: {
...cloneDeep(this.stackHeaders)
}
})
headers: {
...cloneDeep(this.stackHeaders)
}
})
if (response.data) {
return UserCollection(http, response.data.stack)
} else {
Expand Down
20 changes: 10 additions & 10 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@contentstack/management",
"version": "1.6.0",
"version": "1.6.1",
"description": "The Content Management API is used to manage the content of your Contentstack account",
"main": "./dist/node/contentstack-management.js",
"browser": "./dist/web/contentstack-management.js",
Expand Down
Loading