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
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
# Changelog

## [v1.2.2](https://github.com/contentstack/contentstack-management-javascript/tree/v1.2.2) (2021-05-26)
- Bug Fix
- Organization Specific get all Stack: Get Stack for specific organization from org_uid
- Resolved: Entry Publish and Update not work after find function
- Resolved: Workflow update issue on fetchAll function
- Document Update
- `update` Entry example code update

## [v1.2.1](https://github.com/contentstack/contentstack-management-javascript/tree/v1.2.1) (2021-03-19)
- Bug Fix
- User get details: Include organization functions for `is_owner` of the organization
Expand Down
6 changes: 3 additions & 3 deletions dist/es-modules/contentstack.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ import httpClient from './core/contentstackHTTPClient.js';
* import * as contentstack from '@contentstack/management'
* const client = contentstack.client({ maxRequests: 5 })
*
* @prop {boolean=} params.retryOnError - Optional boolean for retry on failuer. Default is true
* @prop {boolean=} params.retryOnError - Optional boolean for retry on failure. Default is true
* @example //Set the `retryOnError` to false
* import * as contentstack from '@contentstack/management'
* const client = contentstack.client({ retryOnError: false })
Expand All @@ -59,7 +59,7 @@ import httpClient from './core/contentstackHTTPClient.js';
* import * as contentstack from '@contentstack/management'
* const client = contentstack.client({ retryLimit: 2 })
*
* @prop {number=} params.retryDelay - The number of miliseconds to use for operation retries. Default is 300ms
* @prop {number=} params.retryDelay - The number of milliseconds to use for operation retries. Default is 300ms
* @example //Set the `retryDelay` to 500ms
* import * as contentstack from '@contentstack/management'
* const client = contentstack.client({ retryDelay: 500 })
Expand Down Expand Up @@ -98,7 +98,7 @@ import httpClient from './core/contentstackHTTPClient.js';
* const client = contentstack.client({ maxContentLength: 1024 ** 3 })
*
* @prop {number=} params.maxBodyLength - Optional maximum body length in bytes (default: 10 MB)
* @example //Set the `maxContentLength` to 1024 ** 2 * 10 // 10 MB
* @example //Set the `maxBodyLength` to 1024 ** 2 * 10 // 10 MB
* import * as contentstack from '@contentstack/management'
* const client = contentstack.client({ maxBodyLength: 1024 ** 2 * 10 })
*
Expand Down
3 changes: 3 additions & 0 deletions dist/es-modules/contentstackCollection.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";

/**
* @namespace ContentstackCollection
*/
var ContentstackCollection = function ContentstackCollection(response, http) {
var stackHeaders = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
var wrapperCollection = arguments.length > 3 ? arguments[3] : undefined;
Expand Down
68 changes: 66 additions & 2 deletions dist/es-modules/entity.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
import error from './core/contentstackError';
import cloneDeep from 'lodash/cloneDeep';
import Query from './query/index';
import ContentstackCollection from './contentstackCollection';
export var publish = function publish(http, type) {
return /*#__PURE__*/function () {
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(_ref) {
Expand Down Expand Up @@ -197,7 +198,7 @@ export var create = function create(_ref8) {
break;
}

return _context5.abrupt("return", new this.constructor(http, parseData(response, this.stackHeaders)));
return _context5.abrupt("return", new this.constructor(http, parseData(response, this.stackHeaders, this.content_type_uid)));

case 9:
throw error(response);
Expand Down Expand Up @@ -249,7 +250,7 @@ export var exportObject = function exportObject(_ref10) {
break;
}

return _context6.abrupt("return", new this.constructor(http, parseData(response, this.stackHeaders)));
return _context6.abrupt("return", new this.constructor(http, parseData(response, this.stackHeaders, this.content_type_uid)));

case 9:
throw error(response);
Expand Down Expand Up @@ -283,9 +284,17 @@ export var query = function query(_ref12) {
var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};

if (this.organization_uid) {
if (!params.query) {
params.query = {};
}

params.query['org_uid'] = this.organization_uid;
}

if (this.content_type_uid) {
params.content_type_uid = this.content_type_uid;
}

return Query(http, this.urlPath, params, this.stackHeaders, wrapperCollection);
};
};
Expand Down Expand Up @@ -455,6 +464,61 @@ export var fetch = function fetch(http, type) {
}, _callee9, this, [[1, 14]]);
}));
};
export var fetchAll = function fetchAll(http, wrapperCollection) {
return /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10() {
var params,
headers,
response,
_args10 = arguments;
return _regeneratorRuntime.wrap(function _callee10$(_context10) {
while (1) {
switch (_context10.prev = _context10.next) {
case 0:
params = _args10.length > 0 && _args10[0] !== undefined ? _args10[0] : {};
headers = {};

if (this.stackHeaders) {
headers.headers = this.stackHeaders;
}

if (params) {
headers.params = _objectSpread({}, cloneDeep(params));
}

_context10.prev = 4;
_context10.next = 7;
return http.get(this.urlPath, headers);

case 7:
response = _context10.sent;

if (!response.data) {
_context10.next = 12;
break;
}

return _context10.abrupt("return", new ContentstackCollection(response, http, this.stackHeaders, wrapperCollection));

case 12:
throw error(response);

case 13:
_context10.next = 18;
break;

case 15:
_context10.prev = 15;
_context10.t0 = _context10["catch"](4);
throw error(_context10.t0);

case 18:
case "end":
return _context10.stop();
}
}
}, _callee10, this, [[4, 15]]);
}));
};
export function parseData(response, stackHeaders, contentTypeUID) {
var data = response.data || {};

Expand Down
53 changes: 3 additions & 50 deletions dist/es-modules/organization/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va

import cloneDeep from 'lodash/cloneDeep';
import error from '../core/contentstackError';
import { fetch } from '../entity';
import { fetch, fetchAll } from '../entity';
import ContentstackCollection from '../contentstackCollection';
import { RoleCollection } from '../stack/roles';
import { StackCollection } from '../stack';
Expand Down Expand Up @@ -448,61 +448,14 @@ export function Organization(http, data) {
* .then((collection) => console.log(collection))
*
*/
this.fetchAll = /*#__PURE__*/function () {
var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(parmas) {
var response;
return _regeneratorRuntime.wrap(function _callee7$(_context7) {
while (1) {
switch (_context7.prev = _context7.next) {
case 0:
_context7.prev = 0;
_context7.next = 3;
return http.get(_this.urlPath, {
params: parmas
});

case 3:
response = _context7.sent;

if (!response.data) {
_context7.next = 8;
break;
}

return _context7.abrupt("return", new ContentstackCollection(response, http, null, OrganizationCollection));

case 8:
throw error(response);

case 9:
_context7.next = 14;
break;

case 11:
_context7.prev = 11;
_context7.t0 = _context7["catch"](0);
throw error(_context7.t0);

case 14:
case "end":
return _context7.stop();
}
}
}, _callee7, null, [[0, 11]]);
}));

return function (_x7) {
return _ref7.apply(this, arguments);
};
}();
this.fetchAll = fetchAll(http, OrganizationCollection);
}
}
export function OrganizationCollection(http, data) {
var obj = cloneDeep(data.organizations || []);
var organizationCollection = obj.map(function (userdata) {
return obj.map(function (userdata) {
return new Organization(http, {
organization: userdata
});
});
return organizationCollection;
}
47 changes: 31 additions & 16 deletions dist/es-modules/query/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,14 @@ export default function Query(http, urlPath, param) {
headers.headers = stackHeaders;
}

var contentTypeUid = null;

if (param) {
if (param.content_type_uid) {
contentTypeUid = param.content_type_uid;
delete param.content_type_uid;
}

headers.params = _objectSpread({}, cloneDeep(param));
}
/**
Expand Down Expand Up @@ -56,30 +63,34 @@ export default function Query(http, urlPath, param) {
response = _context.sent;

if (!response.data) {
_context.next = 8;
_context.next = 9;
break;
}

if (contentTypeUid) {
response.data.content_type_uid = contentTypeUid;
}

return _context.abrupt("return", new ContentstackCollection(response, http, stackHeaders, wrapperCollection));

case 8:
case 9:
throw error(response);

case 9:
_context.next = 14;
case 10:
_context.next = 15;
break;

case 11:
_context.prev = 11;
case 12:
_context.prev = 12;
_context.t0 = _context["catch"](0);
throw error(_context.t0);

case 14:
case 15:
case "end":
return _context.stop();
}
}
}, _callee, null, [[0, 11]]);
}, _callee, null, [[0, 12]]);
}));

return function find() {
Expand Down Expand Up @@ -191,30 +202,34 @@ export default function Query(http, urlPath, param) {
response = _context3.sent;

if (!response.data) {
_context3.next = 10;
_context3.next = 11;
break;
}

if (contentTypeUid) {
response.data.content_type_uid = contentTypeUid;
}

return _context3.abrupt("return", new ContentstackCollection(response, http, stackHeaders, wrapperCollection));

case 10:
case 11:
throw error(response);

case 11:
_context3.next = 16;
case 12:
_context3.next = 17;
break;

case 13:
_context3.prev = 13;
case 14:
_context3.prev = 14;
_context3.t0 = _context3["catch"](2);
throw error(_context3.t0);

case 16:
case 17:
case "end":
return _context3.stop();
}
}
}, _callee3, null, [[2, 13]]);
}, _callee3, null, [[2, 14]]);
}));

return function findOne() {
Expand Down
16 changes: 8 additions & 8 deletions dist/es-modules/stack/contentType/entry/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export function Entry(http, data) {
* .then((entry) => {
* entry.title = 'My New Entry'
* entry.description = 'Entry description'
* return Entry.update()
* return entry.update()
* })
* .then((entry) => console.log(entry))
*
Expand Down Expand Up @@ -145,13 +145,13 @@ export function Entry(http, data) {
* @example
* import * as contentstack from '@contentstack/management'
* const client = contentstack.client()
*
*
* const publishing_rule = {
* "uid": "blt9b9253297f117e84",
* "action": "publish", //(‘publish’, ‘unpublish’, or ’both’)
* "status": 1, //(this could be ‘0’ for Approval Requested, ‘1’ for ‘Approval Accepted’, and ‘-1’ for ‘Approval Rejected’),
* "notify": false,
* "comment": "Please review this."
* "uid": "blt9b9253297f117e84",
* "action": "publish" //(‘publish’, ‘unpublish’, or ’both’)
* "status": 1, //(this could be ‘0’ for Approval Requested, ‘1’ for ‘Approval Accepted’, and ‘-1’ for ‘Approval Rejected’),
* "notify": false,
* comment": "Please review this."
* }
* client.stack({ api_key: 'api_key'}).contentType('content_type_uid').entry('uid').publishRequest({ publishing_rule, locale: 'en-us'})
* .then((response) => console.log(response.notice))
Expand Down Expand Up @@ -348,7 +348,7 @@ export function EntryCollection(http, data) {
var entryCollection = obj.map(function (entry) {
return new Entry(http, {
entry: entry,
content_type_uid: 'uid',
content_type_uid: data.content_type_uid,
stackHeaders: data.stackHeaders
});
});
Expand Down
7 changes: 5 additions & 2 deletions dist/es-modules/stack/deliveryToken/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import cloneDeep from 'lodash/cloneDeep';
import { create, update, deleteEntity, fetch, query } from '../../entity'; // import ContentstackCollection from '../../contentstackCollection'
// import error from '../../core/contentstackError'
import { create, update, deleteEntity, fetch, query } from '../../entity';
/**
* Delivery tokens provide read-only access to the associated environments. Read more about <a href='https://www.contentstack.com/docs/developers/create-tokens/about-delivery-tokens'>DeliveryToken</a>.
* @namespace DeliveryToken
*/

export function DeliveryToken(http) {
var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
Expand Down
5 changes: 5 additions & 0 deletions dist/es-modules/stack/environment/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import cloneDeep from 'lodash/cloneDeep';
import { create, update, deleteEntity, fetch, query } from '../../entity';
/**
* A publishing environment corresponds to one or more deployment servers or a content delivery destination where the entries need to be published. Read more about <a href='https://www.contentstack.com/docs/developers/set-up-environments'>Environment</a>.
* @namespace Environment
* */

export function Environment(http) {
var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
this.stackHeaders = data.stackHeaders;
Expand Down
Loading