diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml new file mode 100644 index 00000000..4f827b78 --- /dev/null +++ b/.github/workflows/npm-publish.yml @@ -0,0 +1,34 @@ +# This workflow will publish a package to GitHub Packages when a release is created +# For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages + +name: Publish package to NPM repository +on: + release: + types: [created] + +jobs: + publish-npm: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: '12.x' + registry-url: 'https://registry.npmjs.org' + - run: npm ci + - run: npm publish + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + publish-git: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: '12.x' + registry-url: 'https://npm.pkg.github.com' + scope: '@contentstack' + - run: npm ci + - run: npm publish + env: + NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.npmignore b/.npmignore index 76233980..25dfaf2f 100644 --- a/.npmignore +++ b/.npmignore @@ -22,4 +22,5 @@ docdash-template/ .babel-preset.js .eslintrc.js .talismanrc -lib/ \ No newline at end of file +lib/ +.github \ No newline at end of file diff --git a/lib/contentstack.js b/lib/contentstack.js index 4668d10b..3cba4fe5 100644 --- a/lib/contentstack.js +++ b/lib/contentstack.js @@ -34,6 +34,16 @@ import httpClient from './core/contentstackHTTPClient.js' * import * as contentstack from '@contentstack/management' * const client = contentstack.client({ headers: { 'headerkey': 'value'} }) * + * @prop {string=} params.authtoken - Optional Authtoken is a read-write token used to make authorized CMA requests, but it is a user-specific token. + * @example //Set the `authtoken` + * import * as contentstack from '@contentstack/management' + * const client = contentstack.client({ authtoken: 'value' }) + * + * @prop {string=} params.authorization - Optional authorization token is a read-write token used to make authorized CMA requests, but it is a user-specific token. + * @example //Set the `authorization` + * import * as contentstack from '@contentstack/management' + * const client = contentstack.client({ authorization: 'Bearer ' }) + * * @prop {number=} params.timeout - Optional number of milliseconds before the request times out. Default is 30000ms * @example //Set the `timeout` to 50000ms * import * as contentstack from '@contentstack/management' @@ -132,6 +142,9 @@ export function client (params = {}) { if (params.authtoken) { requiredHeaders.authtoken = params.authtoken } + if (params.authorization) { + requiredHeaders.authorization = params.authorization + } params = { ...defaultParameter, ...clonedeep(params) diff --git a/lib/stack/asset/index.js b/lib/stack/asset/index.js index 92d770d1..6de9eb9d 100644 --- a/lib/stack/asset/index.js +++ b/lib/stack/asset/index.js @@ -217,11 +217,52 @@ export function Asset (http, data = {}) { * import * as contentstack from '@contentstack/management' * const client = contentstack.client() * - * client.stack().asset().query({ query: { filename: 'Asset Name' } }).find() + * client.stack({ api_key: 'api_key'}).asset().query({ query: { filename: 'Asset Name' } }).find() * .then((asset) => console.log(asset)) */ this.query = query({ http: http, wrapperCollection: AssetCollection }) } + /** + * @description The Download function will get downloadable file in specified format. + * @memberof Asset + * @func download + * @returns {Array} Array of Asset. + * @param {*} param.url The url for the asset to download + * @param {*} param.responseType Optional parameter to specify the response type. + * @example + * + * import * as contentstack from '@contentstack/management' + * const client = contentstack.client() + * + * client.stack({ api_key: 'api_key'}).asset('uid').fetch() + * .then((asset) => asset.download({responseType: 'blob'})) + * .then((response) => // Write response data to destination file. ) + * @example + * + * import * as contentstack from '@contentstack/management' + * const client = contentstack.client() + * + * client.stack({ api_key: 'api_key'}).asset().download({url: 'asset_url_to_download', responseType: 'blob'}) + * .then((response) => // Write response data to destination file. ) + */ + this.download = async function ({ url, responseType, params }) { + try { + const headers = { + headers: { + ...params, + ...cloneDeep(this.stackHeaders) + }, + responseType + } || { responseType } + const requestUrl = url || this.url + if (!requestUrl || requestUrl === undefined) { + throw new Error('Asset URL can not be empty') + } + return http.get(requestUrl, headers) + } catch (err) { + throw error(err) + } + } return this } diff --git a/lib/stack/contentType/entry/index.js b/lib/stack/contentType/entry/index.js index d08fbb78..7bfad62a 100644 --- a/lib/stack/contentType/entry/index.js +++ b/lib/stack/contentType/entry/index.js @@ -58,6 +58,34 @@ export function Entry (http, data) { * }) * .then((entry) => console.log(entry)) * + * @example + * // To update entry with asset field + * import * as contentstack from '@contentstack/management' + * const client = contentstack.client() + * + * client.stack({ api_key: 'api_key'}).contentType('content_type_uid').entry('uid').fetch() + * .then((entry) => { + * entry.title = 'My New Entry' + * entry.file = entry.file.uid // for single asset pass asset uid to entry asset field value + * entry.multiple_file = ['asset_uid_1', 'asset_uid_2'] // for multiple asset pass array of asset uid to entry asset field values + * return entry.update({ locale: 'en-at' }) + * }) + * .then((entry) => console.log(entry)) + * + * @example + * // To update entry with reference field + * import * as contentstack from '@contentstack/management' + * const client = contentstack.client() + * + * client.stack({ api_key: 'api_key'}).contentType('content_type_uid').entry('uid').fetch() + * .then((entry) => { + * entry.title = 'My New Entry' + * entry.reference = entry.reference.uid // for single reference pass reference uid to entry reference field value + * entry.multiple_reference = ['reference_uid_1', 'reference_uid_2'] // for multiple reference pass array of reference uid to entry reference field values + * entry.multiple_content_type_reference = [{_content_type_uid: 'content_type_uid_1', uid: 'reference_uid_1'}, {_content_type_uid: 'content_type_uid_2', uid: 'reference_uid_2'}] // for multiple reference pass array of reference uid to entry reference field values + * return entry.update({ locale: 'en-at' }) + * }) + * .then((entry) => console.log(entry)) */ this.update = update(http, 'entry') @@ -185,6 +213,58 @@ export function Entry (http, data) { throw error(err) } } + + /** + * @description The Set Entry Workflow Stage request allows you to either set a particular workflow stage of an entry or update the workflow stage details of an entry. + * @memberof Entry + * @func setWorkflowStage + * @returns {Promise} Response Object. + * @param {Object} publishing_rule Details for the publish request + * @param {String} locale Enter the code of the locale that the entry belongs to. + * @example + * import * as contentstack from '@contentstack/management' + * const client = contentstack.client() + * + * const workflow_stage = { + * "comment": "Workflow Comment", + * "due_date": "Thu Dec 01 2018", + * "notify": false, + * "uid": "workflow_stage_uid", + * "assigned_to": [{ + * "uid": "user_uid", + * "name": "Username", + * "email": "user_email_id" + * }], + * "assigned_by_roles": [{ + * "uid": "role_uid", + * "name": "Role name" + * }] + * } + * client.stack({ api_key: 'api_key'}).contentType('content_type_uid').entry('uid').setWorkflowStage({ workflow_stage, locale: 'en-us'}) + * .then((response) => console.log(response.notice)); + */ + this.setWorkflowStage = async ({ workflow_stage, locale }) => { + const publishDetails = { + workflow: { workflow_stage } + } + const headers = {} + if (this.stackHeaders) { + headers.headers = this.stackHeaders + } + headers.params = { + locale + } + try { + const response = await http.post(`${this.urlPath}/workflow`, publishDetails, headers) + if (response.data) { + return response.data + } else { + throw error(response) + } + } catch (err) { + throw error(err) + } + } } else { /** * @description The Create an entry call creates a new entry for the selected content type. @@ -197,7 +277,12 @@ export function Entry (http, data) { * const client = contentstack.client() * const entry = { * title: 'Sample Entry', - * url: '/sampleEntry' + * url: '/sampleEntry', + * file: 'asset_uid', // for single asset pass asset uid to entry asset field value + * multiple_file = ['asset_uid_1', 'asset_uid_2'], // for multiple asset pass array of asset uid to entry asset field values + * reference: reference.uid, // for single reference pass reference uid to entry reference field value + * multiple_reference: ['reference_uid_1', 'reference_uid_2'], // for multiple reference pass array of reference uid to entry reference field values + * multiple_content_type_reference: [{_content_type_uid: 'content_type_uid_1', uid: 'reference_uid_1'}, {_content_type_uid: 'content_type_uid_2', uid: 'reference_uid_2'}] // for multiple reference pass array of reference uid to entry reference field values * } * client.stack().contentType('content_type_uid').entry().create({ entry }) * .then((entry) => console.log(entry)) @@ -239,7 +324,7 @@ export function Entry (http, data) { * client.stack({ api_key: 'api_key'}).contentType('content_type_uid').entry() * .import({ * entry: 'path/to/file.json', - * overright: true + * overwrite: true * }) * .then((entry) => console.log(entry)) * diff --git a/lib/stack/index.js b/lib/stack/index.js index 9abaf62c..7f55f5d1 100644 --- a/lib/stack/index.js +++ b/lib/stack/index.js @@ -434,6 +434,43 @@ export function Stack (http, data) { } } + /** + * @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 + * @param {*} users object containing userId and array of roles to assign user. + * @returns {Object} Response Object. + * @example + * import * as contentstack from '@contentstack/management' + * const client = contentstack.client() + * 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`, + { users }, + { + headers: { + ...cloneDeep(this.stackHeaders) + } + }) + if (response.data) { + return UserCollection(http, response.data.stack) + } else { + return error(response) + } + } catch (err) { + return error(err) + } + } + /** * @description The Transfer stack ownership to other users call sends the specified user an email invitation for accepting the ownership of a particular stack. * @memberof Stack diff --git a/package.json b/package.json index a0a39ee7..90f80222 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@contentstack/management", - "version": "1.3.1", + "version": "1.4.0", "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", diff --git a/test/api/asset-test.js b/test/api/asset-test.js index 1f8975df..78f91fce 100644 --- a/test/api/asset-test.js +++ b/test/api/asset-test.js @@ -1,7 +1,7 @@ import path from 'path' import { expect } from 'chai' import { describe, it, setup } from 'mocha' -import { jsonReader } from '../utility/fileOperations/readwrite' +import { jsonReader, writeDownloadedFile } from '../utility/fileOperations/readwrite' import { contentstackClient } from '../utility/ContentstackClient.js' var client = {} @@ -10,6 +10,7 @@ var stack = {} var folderUID = '' var assetUID = '' var publishAssetUID = '' +var assetURL = '' describe('Assets api Test', () => { setup(() => { const user = jsonReader('loggedinuser.json') @@ -27,6 +28,7 @@ describe('Assets api Test', () => { makeAsset().create(asset) .then((asset) => { assetUID = asset.uid + assetURL = asset.url expect(asset.uid).to.be.not.equal(null) expect(asset.url).to.be.not.equal(null) expect(asset.filename).to.be.equal('customUpload.html') @@ -38,6 +40,22 @@ describe('Assets api Test', () => { .catch(done) }) + it('Download asset from URL.', done => { + makeAsset().download({ url: assetURL, responseType: 'stream' }) + .then((response) => { + writeDownloadedFile(response, 'asset1') + done() + }).catch(done) + }) + it('Download asset from fetch details ', done => { + makeAsset(assetUID).fetch() + .then((asset) => asset.download({ responseType: 'stream' })) + .then((response) => { + writeDownloadedFile(response, 'asset2') + done() + }).catch(done) + }) + it('Create folder ', done => { makeAsset().folder().create({ asset: { name: 'Sample Folder' } }) .then((asset) => { diff --git a/test/typescript/asset.ts b/test/typescript/asset.ts index ba697828..0c15de5e 100644 --- a/test/typescript/asset.ts +++ b/test/typescript/asset.ts @@ -4,7 +4,7 @@ import path from "path"; var assetUID = '' var folderUID = '' var publishAssetUID = '' - +var assetURL = '' export function createAsset(stack: Stack) { describe('Asset create', () => { test('Asset Upload', done => { @@ -17,6 +17,7 @@ export function createAsset(stack: Stack) { stack.asset().create(asset) .then((asset) => { assetUID = asset.uid + assetURL = asset.url expect(asset.uid).to.be.not.equal(null) expect(asset.url).to.be.not.equal(null) expect(asset.filename).to.be.equal('customUpload.html') @@ -67,6 +68,27 @@ export function createAsset(stack: Stack) { }) } +export function downloadAsset(stack: Stack) { + describe('Asset download', () => { + test('Download asset from url', done => { + stack.asset().download({url: assetURL, responseType: 'stream'}) + .then((_) => { + done() + }) + .catch(done) + }) + + test('Download asset from uid', done => { + stack.asset(assetUID).fetch() + .then((asset) => asset.download({responseType: 'stream'})) + .then((_) => { + done() + }) + .catch(done) + }) + }) +} + export function replaceAsset(stack: Stack) { describe('Asset replace', () => { test('Replace Asset', done => { diff --git a/test/typescript/index.test.ts b/test/typescript/index.test.ts index 757856a0..ea6d4a15 100644 --- a/test/typescript/index.test.ts +++ b/test/typescript/index.test.ts @@ -5,7 +5,7 @@ import * as dotenv from 'dotenv' import { shareStack, stacks, stackTest, unshareStack } from './stack'; import { contentType, createContentType, queryContentType } from './contentType'; import { createEntry, getEntries, importEntry, publishUnpublishEntry } from './entry'; -import { createAsset, deleteAsset, getAssets, publishUnpublishAsset, queryOnAsset, replaceAsset } from './asset'; +import { createAsset, deleteAsset, downloadAsset, getAssets, publishUnpublishAsset, queryOnAsset, replaceAsset } from './asset'; import { createGlobalField, globalField, queryGlobalField } from './globalField'; import { createBranch, deleteBranch, queryBranch } from './branch'; import { createBranchAlias, deleteBranchAlias, queryBranchAlias } from './branchAlias'; @@ -76,6 +76,7 @@ describe('Typescript API test', () => { importEntry(stack) createAsset(stack) + downloadAsset(stack) replaceAsset(stack) getAssets(stack) publishUnpublishAsset(stack) diff --git a/test/unit/entry-test.js b/test/unit/entry-test.js index 51fc1a22..f5e2af26 100644 --- a/test/unit/entry-test.js +++ b/test/unit/entry-test.js @@ -290,6 +290,38 @@ describe('Contentstack Entry test', () => { .catch(done) }) + it('Entry set Workflow stage test', done => { + var mock = new MockAdapter(Axios); + + mock.post('/content_types/content_type_uid/entries/UID/workflow').reply(200, { + ...noticeMock + }) + + const workflow_stage = { + uid: 'uid', + comment: 'Please review this.', + due_date: 'Thu Dec 01 2018', + notify: true, + assigned_to: [{ + uid: "user_uid", + name: "Username", + email: "user_email_id" + }], + assigned_by_roles: [{ + uid: "role_uid", + name: "Role name" + }] + } + + makeEntry({entry: { ...systemUidMock }}) + .setWorkflowStage({workflow_stage, locale: 'en-us'}) + .then((response) => { + expect(response.notice).to.be.equal(noticeMock.notice) + done() + }) + .catch(done) + }) + it('Entry publish request test', done => { var mock = new MockAdapter(Axios) mock.onPost('/content_types/content_type_uid/entries/UID/workflow').reply(200, { diff --git a/test/unit/stack-test.js b/test/unit/stack-test.js index 78a0de9b..ce3306b8 100644 --- a/test/unit/stack-test.js +++ b/test/unit/stack-test.js @@ -31,6 +31,7 @@ describe('Contentstack Stack test', () => { expect(stack.release).to.be.equal(undefined) expect(stack.bulkOperation).to.be.equal(undefined) expect(stack.users).to.be.equal(undefined) + expect(stack.updateUsersRoles).to.be.equal(undefined) expect(stack.transferOwnership).to.be.equal(undefined) expect(stack.settings).to.be.equal(undefined) expect(stack.resetSettings).to.be.equal(undefined) @@ -66,6 +67,7 @@ describe('Contentstack Stack test', () => { expect(stack.release).to.be.equal(undefined) expect(stack.bulkOperation).to.be.equal(undefined) expect(stack.users).to.be.equal(undefined) + expect(stack.updateUsersRoles).to.be.equal(undefined) expect(stack.transferOwnership).to.be.equal(undefined) expect(stack.settings).to.be.equal(undefined) expect(stack.resetSettings).to.be.equal(undefined) @@ -101,6 +103,7 @@ describe('Contentstack Stack test', () => { expect(stack.release).to.be.equal(undefined) expect(stack.bulkOperation).to.be.equal(undefined) expect(stack.users).to.be.equal(undefined) + expect(stack.updateUsersRoles).to.be.equal(undefined) expect(stack.transferOwnership).to.be.equal(undefined) expect(stack.settings).to.be.equal(undefined) expect(stack.resetSettings).to.be.equal(undefined) @@ -136,6 +139,7 @@ describe('Contentstack Stack test', () => { expect(stack.release).to.be.equal(undefined) expect(stack.bulkOperation).to.be.equal(undefined) expect(stack.users).to.be.equal(undefined) + expect(stack.updateUsersRoles).to.be.equal(undefined) expect(stack.transferOwnership).to.be.equal(undefined) expect(stack.settings).to.be.equal(undefined) expect(stack.resetSettings).to.be.equal(undefined) @@ -171,6 +175,7 @@ describe('Contentstack Stack test', () => { expect(stack.release).to.be.equal(undefined) expect(stack.bulkOperation).to.be.equal(undefined) expect(stack.users).to.be.equal(undefined) + expect(stack.updateUsersRoles).to.be.equal(undefined) expect(stack.transferOwnership).to.be.equal(undefined) expect(stack.settings).to.be.equal(undefined) expect(stack.resetSettings).to.be.equal(undefined) @@ -208,6 +213,7 @@ describe('Contentstack Stack test', () => { expect(stack.release).to.not.equal(undefined) expect(stack.bulkOperation).to.not.equal(undefined) expect(stack.users).to.not.equal(undefined) + expect(stack.updateUsersRoles).to.not.equal(undefined) expect(stack.transferOwnership).to.not.equal(undefined) expect(stack.settings).to.not.equal(undefined) expect(stack.resetSettings).to.not.equal(undefined) @@ -245,6 +251,7 @@ describe('Contentstack Stack test', () => { expect(stack.release).to.not.equal(undefined) expect(stack.bulkOperation).to.not.equal(undefined) expect(stack.users).to.not.equal(undefined) + expect(stack.updateUsersRoles).to.not.equal(undefined) expect(stack.transferOwnership).to.not.equal(undefined) expect(stack.settings).to.not.equal(undefined) expect(stack.resetSettings).to.not.equal(undefined) @@ -282,6 +289,7 @@ describe('Contentstack Stack test', () => { expect(stack.release).to.not.equal(undefined) expect(stack.bulkOperation).to.not.equal(undefined) expect(stack.users).to.not.equal(undefined) + expect(stack.updateUsersRoles).to.not.equal(undefined) expect(stack.transferOwnership).to.not.equal(undefined) expect(stack.settings).to.not.equal(undefined) expect(stack.resetSettings).to.not.equal(undefined) @@ -320,6 +328,7 @@ describe('Contentstack Stack test', () => { expect(stack.release).to.not.equal(undefined) expect(stack.bulkOperation).to.not.equal(undefined) expect(stack.users).to.not.equal(undefined) + expect(stack.updateUsersRoles).to.not.equal(undefined) expect(stack.transferOwnership).to.not.equal(undefined) expect(stack.settings).to.not.equal(undefined) expect(stack.resetSettings).to.not.equal(undefined) @@ -835,6 +844,24 @@ describe('Contentstack Stack test', () => { }) .catch(done) }) + it('Update users roles in Stack test', done => { + const mock = new MockAdapter(Axios) + mock.onGet('/stacks').reply(200, { + notice: "The roles were applied successfully.", + }) + makeStack({ + stack: { + api_key: 'stack_api_key' + } + }) + .updateUsersRoles({ user_id: ['role1', 'role2']}) + .then((response) => { + expect(response.notice).to.be.equal(noticeMock.notice) + done() + }) + .catch(done) + }) + it('Stack transfer ownership test', done => { const mock = new MockAdapter(Axios) diff --git a/test/utility/fileOperations/readwrite.js b/test/utility/fileOperations/readwrite.js index 9fcf40cc..c06fe895 100644 --- a/test/utility/fileOperations/readwrite.js +++ b/test/utility/fileOperations/readwrite.js @@ -27,3 +27,9 @@ function ensureDirectoryExistence (filePath) { fs.mkdirSync(dirname) } } + +export function writeDownloadedFile (response, fileName) { + const filePath = path.resolve(dataFiles, fileName) + ensureDirectoryExistence(`${dataFiles}${fileName}`) + response.data.pipe(fs.createWriteStream(filePath)) +} diff --git a/types/contentstackCollection.d.ts b/types/contentstackCollection.d.ts index da6dc238..07d6dff0 100644 --- a/types/contentstackCollection.d.ts +++ b/types/contentstackCollection.d.ts @@ -11,3 +11,8 @@ export interface EntryCollection extends ContentstackCollection { schema?: object content_Type?: object } + +export type AssetResponseType = + | 'arraybuffer' + | 'blob' + | 'stream'; \ No newline at end of file diff --git a/types/stack/asset/index.d.ts b/types/stack/asset/index.d.ts index 17fd72f5..7ad405c9 100644 --- a/types/stack/asset/index.d.ts +++ b/types/stack/asset/index.d.ts @@ -1,3 +1,4 @@ +import { AssetResponseType } from "../../contentstackCollection"; import { AnyProperty, SystemFields } from "../../utility/fields"; import { Queryable, SystemFunction } from "../../utility/operations"; import { Publishable } from "../../utility/publish"; @@ -6,11 +7,13 @@ import { Folder, Folders } from "./folder"; export interface Asset extends Publishable, Unpublishable, SystemFields, SystemFunction { replace(param: AssetData): Promise + download(data: {responseType: AssetResponseType, param?: AnyProperty}): Promise } export interface Assets extends Queryable { folder(): Folders folder(uid: string): Folder + download(data: {url: string, responseType: AssetResponseType, param?: AnyProperty}): Promise } export interface AssetData extends AnyProperty { diff --git a/types/stack/contentType/entry.d.ts b/types/stack/contentType/entry.d.ts index 4f21a3de..77e3d4bf 100644 --- a/types/stack/contentType/entry.d.ts +++ b/types/stack/contentType/entry.d.ts @@ -1,3 +1,4 @@ +import { Response } from "../../contentstackCollection"; import { AnyProperty, SystemFields } from "../../utility/fields"; import { Queryable, SystemFunction } from "../../utility/operations"; import { Publishable } from "../../utility/publish"; @@ -5,6 +6,7 @@ import { Unpublishable } from "../../utility/unpublish"; export interface Entry extends Publishable, Unpublishable, SystemFields, SystemFunction { + setWorkflowStage(data: { workflow_stage: WorkflowStage, locale?:string}): Promise } export interface Entries extends Queryable { @@ -14,4 +16,13 @@ export interface Entries extends Queryable { export interface EntryData extends AnyProperty { title: string url?: string +} + +export interface WorkflowStage extends AnyProperty { + uid: string + comment: string + due_date?: string + notify?: boolean + assign_to?: Array + assigned_by_roles?: Array } \ No newline at end of file diff --git a/types/stack/contentType/index.d.ts b/types/stack/contentType/index.d.ts index 07b2e0a0..cd8deebc 100644 --- a/types/stack/contentType/index.d.ts +++ b/types/stack/contentType/index.d.ts @@ -8,7 +8,7 @@ export interface ContentType extends SystemFields, SystemFunction { } export interface ContentTypes extends Queryable { - import({content_type: string}): Promise + import(data: {content_type: string}): Promise generateUid(name: string): string } diff --git a/types/stack/deliveryToken/index.ts b/types/stack/deliveryToken/index.ts index 37e1410a..2cf2bda4 100644 --- a/types/stack/deliveryToken/index.ts +++ b/types/stack/deliveryToken/index.ts @@ -17,5 +17,11 @@ export interface Scope { module: string environments?: Array locales?: Array - acl: any + acl: ACL +} +export interface ACL extends AnyProperty { + read?: boolean + write?: boolean + create?: boolean + update?: boolean } \ No newline at end of file diff --git a/types/stack/globalField/index.d.ts b/types/stack/globalField/index.d.ts index 9a887ca9..c47faeee 100644 --- a/types/stack/globalField/index.d.ts +++ b/types/stack/globalField/index.d.ts @@ -7,7 +7,7 @@ export interface GlobalField extends SystemFields, SystemFunction { } export interface GlobalFields extends Queryable { - import({global_field: string}): Promise + import(data: {global_field: string}): Promise } export interface GlobalFieldData extends AnyProperty { diff --git a/types/stack/index.d.ts b/types/stack/index.d.ts index 5c41cec7..90a6d66a 100644 --- a/types/stack/index.d.ts +++ b/types/stack/index.d.ts @@ -18,8 +18,9 @@ import { Webhook, Webhooks } from "./webhook"; import { Workflow, Workflows } from "./workflow"; export interface StackConfig { - api_key?:string + api_key:string management_token?: string + branch_uid?: string } export interface StackDetails { @@ -62,7 +63,7 @@ export interface Stack extends SystemFields { deliveryToken(uid: string): DeliveryToken extension(): Extensions - extension(uid): Extension + extension(uid: string): Extension workflow(): Workflows workflow(uid: string): Workflow @@ -79,7 +80,8 @@ export interface Stack extends SystemFields { bulkOperation(): BulkOperation user(): Promise> - transferOwnership(email): Promise + updateUsersRoles(users: AnyProperty): Promise + transferOwnership(email: string): Promise settings(): Promise resetSettings(): Promise addSettings(stackVariables: AnyProperty): Promise diff --git a/types/stack/roles/index.d.ts b/types/stack/roles/index.d.ts deleted file mode 100644 index 91b6fd6f..00000000 --- a/types/stack/roles/index.d.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { AnyProperty, SystemFields } from "../../utility/fields"; -import { Queryable, SystemFunction } from "../../utility/operations"; - -export interface Role extends SystemFields, SystemFunction { -} - -export interface Roles extends Queryable { - fetchAll(param?: AnyProperty): Promise> -} - -export interface RoleData extends AnyProperty { - name: string - description: string - rules: Array -} - -export interface Rule extends AnyProperty { - module: string - environments: Array - locales: Array - acl: ACL -} - -export interface ACL extends AnyProperty { - read?: boolean - write?: boolean - create?: boolean - update?: boolean -} \ No newline at end of file diff --git a/types/stack/workflow/index.d.ts b/types/stack/workflow/index.d.ts index a82de925..3b7d04c5 100644 --- a/types/stack/workflow/index.d.ts +++ b/types/stack/workflow/index.d.ts @@ -1,3 +1,4 @@ +import { ContentstackCollection } from "../../contentstackCollection"; import { AnyProperty, SystemFields } from "../../utility/fields"; import { Creatable, SystemFunction } from "../../utility/operations"; import { PublishRule, PublishRules } from "./publishRules"; diff --git a/types/stack/workflow/publishRules.d.ts b/types/stack/workflow/publishRules.d.ts index 8d7affcb..71d646a9 100644 --- a/types/stack/workflow/publishRules.d.ts +++ b/types/stack/workflow/publishRules.d.ts @@ -1,10 +1,11 @@ +import { ContentstackCollection } from "../../contentstackCollection"; import { AnyProperty, SystemFields } from "../../utility/fields"; import { Creatable, SystemFunction } from "../../utility/operations"; -export interface PublishRule extends SystemFields, SystemFunction { +export interface PublishRule extends SystemFields, SystemFunction { } -export interface PublishRules extends Creatable { +export interface PublishRules extends Creatable { fetchAll(param?: AnyProperty): Promise> }