From 94a04495edf635cf11d3424177902abeb9887e18 Mon Sep 17 00:00:00 2001 From: raj pandey Date: Tue, 25 Nov 2025 14:39:53 +0530 Subject: [PATCH 01/13] Fix: Fixed the JSDoc strings --- lib/contentstack.js | 15 ++- lib/contentstackClient.js | 33 ++--- lib/contentstackCollection.js | 7 ++ lib/core/concurrency-queue.js | 25 ++++ lib/core/contentstackError.js | 11 +- lib/core/oauthHandler.js | 63 ++++++---- lib/entity.js | 139 ++++++++++++++++++++++ lib/organization/index.js | 66 +++++----- lib/organization/teams/teamUsers/index.js | 17 ++- lib/stack/auditlog/index.js | 10 +- lib/stack/branch/compare.js | 18 +-- lib/stack/branch/index.js | 2 +- lib/stack/branchAlias/index.js | 12 +- lib/stack/bulkOperation/index.js | 20 ++-- lib/stack/contentType/index.js | 7 +- lib/stack/deliveryToken/index.js | 10 +- lib/stack/environment/index.js | 10 +- lib/stack/extension/index.js | 13 +- lib/stack/globalField/index.js | 10 +- lib/stack/index.js | 24 ++-- lib/stack/label/index.js | 4 +- lib/stack/locale/index.js | 17 +-- lib/stack/managementToken/index.js | 6 +- lib/stack/release/index.js | 20 ++-- lib/stack/release/items/index.js | 26 ++-- lib/stack/roles/index.js | 4 +- lib/stack/taxonomy/index.js | 10 +- lib/stack/taxonomy/terms/index.js | 40 ++++--- lib/stack/variantGroup/index.js | 27 +++-- lib/stack/variantGroup/variants/index.js | 27 +++-- lib/stack/variants/index.js | 27 ++--- lib/stack/webhook/index.js | 38 ++++-- lib/stack/workflow/index.js | 44 +++---- lib/stack/workflow/publishRules/index.js | 18 +-- lib/user/index.js | 32 +++-- 35 files changed, 548 insertions(+), 304 deletions(-) diff --git a/lib/contentstack.js b/lib/contentstack.js index 09ccff70..641b99a3 100644 --- a/lib/contentstack.js +++ b/lib/contentstack.js @@ -18,7 +18,10 @@ import httpClient from './core/contentstackHTTPClient.js' * const client = contentstack.client() * * @param {object} params - Client initialization parameters - * @param {Object=} param.proxy - + * @param {Object=} params.proxy - Proxy configuration object for HTTP requests + * @param {string=} params.region - Region for API endpoint (NA, EU, AU, AZURE_NA, AZURE_EU, GCP_NA, GCP_EU) + * @param {string=} params.feature - Feature identifier for user agent + * @param {string=} params.refreshToken - Refresh token for OAuth authentication * @prop {string=} params.endpoint - API endpoint that a service will talk to * @example //Set the `endpoint` to 'https://api.contentstack.io:{port}/{version}' * import * as contentstack from '@contentstack/management' @@ -39,7 +42,7 @@ import httpClient from './core/contentstackHTTPClient.js' * import * as contentstack from '@contentstack/management' * const client = contentstack.client({ authtoken: 'value' }) * - * @prop {string=} params.early_access - Optional early_access is a token used for early access of new features in CMA requests. + * @prop {Array=} params.early_access - Optional array of early access tokens used for early access of new features in CMA requests. * @example //Set the `early_access` * import * as contentstack from '@contentstack/management' * const client = contentstack.client({ early_access: ['ea1', 'ea2'] }) @@ -158,7 +161,13 @@ import httpClient from './core/contentstackHTTPClient.js' * * @prop {string=} params.application - Application name and version e.g myApp/version * @prop {string=} params.integration - Integration name and version e.g react/version - * @returns Contentstack.Client + * @prop {string=} params.region - API region. Valid values: 'na', 'eu', 'au', 'azure_na', 'azure_eu', 'gcp_na', 'gcp_eu' (default: 'na') + * @example //Set the `region` to 'eu' + * import * as contentstack from '@contentstack/management' + * const client = contentstack.client({ region: 'eu' }) + * + * @prop {string=} params.feature - Feature identifier for user agent header + * @returns {ContentstackClient} Instance of ContentstackClient */ export function client (params = {}) { let defaultHostName = getRegionEndpoint('na') diff --git a/lib/contentstackClient.js b/lib/contentstackClient.js index 7eb7594e..b7acdecd 100644 --- a/lib/contentstackClient.js +++ b/lib/contentstackClient.js @@ -19,7 +19,8 @@ export default function contentstackClient ({ http }) { * @prop {string} parameters.password - password for user to login * @prop {string} parameters.tfa_token - tfa token for user to login (2FA token) * @prop {string} parameters.mfaSecret - TOTP secret key for generating 2FA token - * @returns {Promise} + * @param {Object=} params - Optional request parameters + * @returns {Promise} Promise for login response * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client() @@ -59,7 +60,8 @@ export default function contentstackClient ({ http }) { * The information returned includes details of the stacks owned by and shared with the specified user account. * @memberof ContentstackClient * @func getUser - * @returns {Promise} + * @param {Object=} params - Optional request parameters + * @returns {Promise} Promise for User instance * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client() @@ -78,10 +80,11 @@ export default function contentstackClient ({ http }) { * @description Get Stack instance. A stack is a space that stores the content of a project. * @memberof ContentstackClient * @func stack - * @param {String} api_key - Stack API Key - * @param {String} management_token - Management token for Stack. - * @param {String} branch_name - Branch name or alias to access specific branch. Default is master. - * @returns {Stack} Instance of Stack + * @param {Object=} params - Stack initialization parameters + * @prop {String} params.api_key - Stack API Key + * @prop {String} params.management_token - Management token for Stack. + * @prop {String} params.branch_uid - Branch UID or alias to access specific branch. Default is master. + * @returns {Stack} Instance of Stack. * * @example * import * as contentstack from '@contentstack/management' @@ -121,7 +124,7 @@ export default function contentstackClient ({ http }) { * @description Organization is the top-level entity in the hierarchy of Contentstack, consisting of stacks and stack resources, and users. * @memberof ContentstackClient * @func organization - * @param {String} uid - Organization UID. + * @param {String=} uid - Organization UID. If not provided, returns organization instance for querying all organizations. * @returns {Organization} Instance of Organization. * * @example @@ -152,7 +155,7 @@ export default function contentstackClient ({ http }) { * @memberof ContentstackClient * @param {String} authtoken - Authtoken to logout from. * @func logout - * @returns {Object} Response object. + * @returns {Promise} Promise for response object. * * @example * import * as contentstack from '@contentstack/management' @@ -195,13 +198,13 @@ export default function contentstackClient ({ http }) { * @memberof ContentstackClient * @func oauth * @param {Object} parameters - oauth parameters - * @prop {string} parameters.appId - appId of the application - * @prop {string} parameters.clientId - clientId of the application - * @prop {string} parameters.clientId - clientId of the application - * @prop {string} parameters.responseType - responseType - * @prop {string} parameters.scope - scope - * @prop {string} parameters.clientSecret - clientSecret of the application - * @returns {OAuthHandler} Instance of OAuthHandler + * @prop {string=} parameters.appId - appId of the application (default: '6400aa06db64de001a31c8a9') + * @prop {string=} parameters.clientId - clientId of the application (default: 'Ie0FEfTzlfAHL4xM') + * @prop {string=} parameters.redirectUri - redirect URI for OAuth callback (default: 'http://localhost:8184') + * @prop {string=} parameters.responseType - responseType (default: 'code') + * @prop {string=} parameters.scope - scope + * @prop {string=} parameters.clientSecret - clientSecret of the application + * @returns {OAuthHandler} Instance of OAuthHandler. * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client() diff --git a/lib/contentstackCollection.js b/lib/contentstackCollection.js index f61a8645..805a2773 100644 --- a/lib/contentstackCollection.js +++ b/lib/contentstackCollection.js @@ -2,6 +2,13 @@ * @namespace ContentstackCollection */ export default class ContentstackCollection { + /** + * Creates a ContentstackCollection instance. + * @param {Object} response - HTTP response object. + * @param {Object} http - HTTP client instance. + * @param {Object=} stackHeaders - Stack headers to include in data. + * @param {Function=} wrapperCollection - Collection wrapper function to transform items. + */ constructor (response, http, stackHeaders = null, wrapperCollection) { const data = response.data || {} if (stackHeaders) { diff --git a/lib/core/concurrency-queue.js b/lib/core/concurrency-queue.js index 747713d5..453e29e5 100644 --- a/lib/core/concurrency-queue.js +++ b/lib/core/concurrency-queue.js @@ -18,6 +18,31 @@ const defaultConfig = { delayMs: null // Delay in milliseconds before making each request } +/** + * Creates a concurrency queue manager for Axios requests with retry logic and rate limiting. + * @param {Object} options - Configuration options. + * @param {Object} options.axios - Axios instance to manage. + * @param {Object=} options.config - Queue configuration options. + * @param {number=} options.config.maxRequests - Maximum concurrent requests, defaults to 5. + * @param {number=} options.config.retryLimit - Maximum retry attempts for errors, defaults to 5. + * @param {number=} options.config.retryDelay - Delay between retries in milliseconds, defaults to 300. + * @param {boolean=} options.config.retryOnError - Enable retry on error, defaults to true. + * @param {boolean=} options.config.retryOnNetworkFailure - Enable retry on network failures, defaults to true. + * @param {boolean=} options.config.retryOnDnsFailure - Enable retry on DNS failures, defaults to true. + * @param {boolean=} options.config.retryOnSocketFailure - Enable retry on socket failures, defaults to true. + * @param {boolean=} options.config.retryOnHttpServerError - Enable retry on HTTP 5xx errors, defaults to true. + * @param {number=} options.config.maxNetworkRetries - Maximum network retry attempts, defaults to 3. + * @param {number=} options.config.networkRetryDelay - Base delay for network retries in milliseconds, defaults to 100. + * @param {string=} options.config.networkBackoffStrategy - Backoff strategy ('exponential' or 'fixed'), defaults to 'exponential'. + * @param {number=} options.config.delayMs - Delay before each request in milliseconds. + * @param {Function=} options.config.retryCondition - Custom function to determine if error can be retried. + * @param {Function=} options.config.logHandler - Log handler function. + * @param {Function=} options.config.refreshToken - Token refresh function. + * @param {string=} options.config.authtoken - Auth token. + * @param {string=} options.config.authorization - Authorization token. + * @returns {Object} ConcurrencyQueue instance with request/response interceptors attached to Axios. + * @throws {Error} If axios instance is not provided or configuration is invalid. + */ export function ConcurrencyQueue ({ axios, config }) { if (!axios) { throw Error('Axios instance is not present') diff --git a/lib/core/contentstackError.js b/lib/core/contentstackError.js index 89a51b03..bd7e4dd5 100644 --- a/lib/core/contentstackError.js +++ b/lib/core/contentstackError.js @@ -1,4 +1,13 @@ - +/** + * Formats and throws an error from an HTTP error response. + * @param {Object} errorResponse - Error response object from HTTP request. + * @param {Object} errorResponse.config - Request configuration object. + * @param {Object} errorResponse.response - HTTP response object. + * @param {number} errorResponse.response.status - HTTP status code. + * @param {string} errorResponse.response.statusText - HTTP status text. + * @param {Object} errorResponse.response.data - Response data containing error details. + * @throws {Error} Formatted error object with request and response details. + */ export default function error (errorResponse) { const config = errorResponse.config const response = errorResponse.response diff --git a/lib/core/oauthHandler.js b/lib/core/oauthHandler.js index aa46c8f5..71cac609 100644 --- a/lib/core/oauthHandler.js +++ b/lib/core/oauthHandler.js @@ -3,14 +3,14 @@ import errorFormatter from './contentstackError' /** * @description OAuthHandler class to handle OAuth authorization and token management * @class OAuthHandler - * @param {any} axiosInstance - * @param {any} appId - * @param {any} clientId - * @param {any} redirectUri - * @param {any} responseType='code' - * @param {any} clientSecret - * @param {any} scope=[] - * @returns {OAuthHandler} OAuthHandler instance + * @param {Object} axiosInstance - Axios HTTP client instance. + * @param {string=} appId - Application ID, defaults to '6400aa06db64de001a31c8a9'. + * @param {string=} clientId - Client ID, defaults to 'Ie0FEfTzlfAHL4xM'. + * @param {string=} redirectUri - Redirect URI for OAuth callback, defaults to 'http://localhost:8184'. + * @param {string=} clientSecret - Client secret. If provided, PKCE will be skipped. + * @param {string=} responseType - Response type, defaults to 'code'. + * @param {Array=} scope - OAuth scope array, defaults to []. + * @returns {OAuthHandler} OAuthHandler instance. * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client(); @@ -80,7 +80,8 @@ export default class OAuthHandler { * @description Authorize the user by redirecting to the OAuth provider's authorization page * @memberof OAuthHandler * @func authorize - * @returns {any} Authorization URL + * @async + * @returns {Promise} Promise that resolves to authorization URL * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client(); @@ -114,8 +115,9 @@ export default class OAuthHandler { * @description Exchange the authorization code for an access token * @memberof OAuthHandler * @func exchangeCodeForToken - * @param {any} code - Authorization code received from the OAuth provider - * @returns {any} Token data + * @async + * @param {string} code - Authorization code received from the OAuth provider + * @returns {Promise} Promise that resolves to token data object * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client(); @@ -155,9 +157,10 @@ export default class OAuthHandler { * @description Refreshes the access token using the provided refresh token or the one stored in the axios instance. * @memberof OAuthHandler * @func refreshAccessToken + * @async * @param {string|null} [providedRefreshToken=null] - The refresh token to use for refreshing the access token. If not provided, the stored refresh token will be used. - * @returns {Promise} - A promise that resolves to the response data containing the new access token, refresh token, and expiry time. - * @throws {Error} - Throws an error if no refresh token is available or if the token refresh request fails. + * @returns {Promise} A promise that resolves to the response data containing the new access token, refresh token, and expiry time. + * @throws {Error} Throws an error if no refresh token is available or if the token refresh request fails. * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client(); @@ -196,8 +199,9 @@ export default class OAuthHandler { * @description Logs out the user by revoking the OAuth app authorization * @memberof OAuthHandler * @func logout - * @returns {Promise} - A promise that resolves to a success message if the logout was successful. - * @throws {Error} - Throws an error if the logout request fails. + * @async + * @returns {Promise} A promise that resolves to a success message if the logout was successful. + * @throws {Error} Throws an error if the logout request fails. * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client(); @@ -219,7 +223,7 @@ export default class OAuthHandler { * @description Get the current access token * @memberof OAuthHandler * @func getAccessToken - * @returns {any} + * @returns {string|undefined} Current access token or undefined if not set. * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client(); @@ -294,7 +298,8 @@ export default class OAuthHandler { * @description Set the access token in the axios instance * @memberof OAuthHandler * @func setAccessToken - * @param {*} token + * @param {string} token - Access token to set. + * @throws {Error} Throws an error if token is not provided. * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client(); @@ -312,7 +317,8 @@ export default class OAuthHandler { * @description Set the refresh token in the axios instance * @memberof OAuthHandler * @func setRefreshToken - * @param {*} token + * @param {string} token - Refresh token to set. + * @throws {Error} Throws an error if token is not provided. * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client(); @@ -330,7 +336,8 @@ export default class OAuthHandler { * @description Set the organization UID in the axios instance * @memberof OAuthHandler * @func setOrganizationUID - * @param {*} organizationUID + * @param {string} organizationUID - Organization UID to set. + * @throws {Error} Throws an error if organizationUID is not provided. * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client(); @@ -348,7 +355,8 @@ export default class OAuthHandler { * @description Set the user UID in the axios instance * @memberof OAuthHandler * @func setUserUID - * @param {*} userUID + * @param {string} userUID - User UID to set. + * @throws {Error} Throws an error if userUID is not provided. * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client(); @@ -366,7 +374,8 @@ export default class OAuthHandler { * @description Set the token expiry time in the axios instance * @memberof OAuthHandler * @func setTokenExpiryTime - * @param {*} expiryTime + * @param {number} expiryTime - Token expiry time (timestamp in milliseconds). + * @throws {Error} Throws an error if expiryTime is not provided. * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client(); @@ -386,8 +395,8 @@ export default class OAuthHandler { * @func handleRedirect * @async * @param {string} url - The URL to handle after the OAuth authorization - * @returns {Promise} - A promise that resolves if the redirect URL is successfully handled - * @throws {Error} - Throws an error if the authorization code is not found in the redirect URL + * @returns {Promise} A promise that resolves if the redirect URL is successfully handled + * @throws {Error} Throws an error if the authorization code is not found in the redirect URL * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client(); @@ -413,7 +422,8 @@ export default class OAuthHandler { * @description Get the OAuth app authorization for the current user * @memberof OAuthHandler * @func getOauthAppAuthorization - * @returns {any} + * @async + * @returns {Promise} Promise that resolves to authorization UID */ async getOauthAppAuthorization () { const headers = { @@ -448,8 +458,9 @@ export default class OAuthHandler { * @description Revoke the OAuth app authorization for the current user * @memberof OAuthHandler * @func revokeOauthAppAuthorization - * @param {any} authorizationId - * @returns {any} + * @async + * @param {string} authorizationId - Authorization ID to revoke + * @returns {Promise} Promise that resolves to response data */ async revokeOauthAppAuthorization (authorizationId) { if (authorizationId?.length > 1) { diff --git a/lib/entity.js b/lib/entity.js index dc5742b7..6bd45e4c 100644 --- a/lib/entity.js +++ b/lib/entity.js @@ -3,6 +3,15 @@ import cloneDeep from 'lodash/cloneDeep' import Query from './query/index' import ContentstackCollection from './contentstackCollection' +/** + * Creates a publish function for the specified entity type. + * @param {Object} http - HTTP client instance. + * @param {string} type - Entity type (e.g., 'entry', 'asset'). + * @returns {Function} Async function that publishes an entity. + * @example + * const publishFn = publish(http, 'entry') + * await publishFn.call(entryInstance, { publishDetails: {...}, locale: 'en-us' }) + */ export const publish = (http, type) => { return async function ({ publishDetails, locale = null, version = null, scheduledAt = null }) { const url = this.urlPath + '/publish' @@ -17,6 +26,15 @@ export const publish = (http, type) => { } } +/** + * Creates an unpublish function for the specified entity type. + * @param {Object} http - HTTP client instance. + * @param {string} type - Entity type (e.g., 'entry', 'asset'). + * @returns {Function} Async function that unpublishes an entity. + * @example + * const unpublishFn = unpublish(http, 'entry') + * await unpublishFn.call(entryInstance, { publishDetails: {...}, locale: 'en-us' }) + */ export const unpublish = (http, type) => { return async function ({ publishDetails, locale = null, version = null, scheduledAt = null }) { const url = this.urlPath + '/unpublish' @@ -31,6 +49,19 @@ export const unpublish = (http, type) => { } } +/** + * Internal helper function to handle publish/unpublish operations. + * @param {Object} http - HTTP client instance. + * @param {string} url - API endpoint URL. + * @param {Object} httpBody - Request body object. + * @param {Object} headers - Request headers. + * @param {string|null} locale - Locale code. + * @param {number|null} version - Version number. + * @param {string|null} scheduledAt - Scheduled date/time in ISO format. + * @returns {Promise} Promise that resolves to response data. + * @async + * @private + */ export const publishUnpublish = async (http, url, httpBody, headers, locale = null, version = null, scheduledAt = null) => { if (locale !== null) { httpBody.locale = locale @@ -69,6 +100,18 @@ export const publishUnpublish = async (http, url, httpBody, headers, locale = nu } } +/** + * Uploads a file using form data. + * @param {Object} options - Upload options. + * @param {Object} options.http - HTTP client instance. + * @param {string} options.urlPath - API endpoint path. + * @param {Object} options.stackHeaders - Stack headers. + * @param {Function} options.formData - Function that returns FormData instance. + * @param {Object=} options.params - Optional query parameters. + * @param {string=} options.method - HTTP method ('POST' or 'PUT'), defaults to 'POST'. + * @returns {Promise} Promise that resolves to response data. + * @async + */ export const upload = async ({ http, urlPath, stackHeaders, formData, params, method = 'POST' }) => { const headers = { headers: { @@ -85,6 +128,16 @@ export const upload = async ({ http, urlPath, stackHeaders, formData, params, me } } +/** + * Creates a create function for entity instances. + * @param {Object} options - Create options. + * @param {Object} options.http - HTTP client instance. + * @param {Object=} options.params - Optional default parameters. + * @returns {Function} Async function that creates an entity. + * @example + * const createFn = create({ http }) + * await createFn.call(entityInstance, { entity: {...} }) + */ export const create = ({ http, params }) => { return async function (data, param) { this.stackHeaders = { @@ -121,6 +174,17 @@ export const create = ({ http, params }) => { } } +/** + * Creates a query function for entity instances. + * @param {Object} options - Query options. + * @param {Object} options.http - HTTP client instance. + * @param {Function=} options.wrapperCollection - Collection wrapper function. + * @param {string=} options.apiVersion - API version to use. + * @returns {Function} Function that returns a query builder object. + * @example + * const queryFn = query({ http, wrapperCollection: EntityCollection }) + * const queryBuilder = queryFn.call(entityInstance, { query: {...} }) + */ export const query = ({ http, wrapperCollection, apiVersion }) => { return function (params = {}) { const headers = { @@ -142,6 +206,16 @@ export const query = ({ http, wrapperCollection, apiVersion }) => { } } +/** + * Creates an update function for entity instances. + * @param {Object} http - HTTP client instance. + * @param {string} type - Entity type (e.g., 'entry', 'asset'). + * @param {Object=} params - Optional default parameters. + * @returns {Function} Async function that updates an entity. + * @example + * const updateFn = update(http, 'entry') + * await updateFn.call(entryInstance, { locale: 'en-us' }) + */ export const update = (http, type, params = {}) => { return async function (param = {}) { let updateData = {} @@ -183,6 +257,16 @@ export const update = (http, type, params = {}) => { } } +/** + * Creates a delete function for entity instances. + * @param {Object} http - HTTP client instance. + * @param {boolean=} force - Whether to force delete, defaults to false. + * @param {Object=} params - Optional default parameters. + * @returns {Function} Async function that deletes an entity. + * @example + * const deleteFn = deleteEntity(http, false) + * await deleteFn.call(entityInstance, {}) + */ export const deleteEntity = (http, force = false, params = {}) => { return async function (param = {}) { try { @@ -214,6 +298,16 @@ export const deleteEntity = (http, force = false, params = {}) => { } } +/** + * Creates a fetch function for entity instances. + * @param {Object} http - HTTP client instance. + * @param {string} type - Entity type (e.g., 'entry', 'asset'). + * @param {Object=} params - Optional default parameters. + * @returns {Function} Async function that fetches an entity. + * @example + * const fetchFn = fetch(http, 'entry') + * await fetchFn.call(entryInstance, { version: 1 }) + */ export const fetch = (http, type, params = {}) => { return async function (param = {}) { try { @@ -241,6 +335,17 @@ export const fetch = (http, type, params = {}) => { } } } + +/** + * Creates a fetchAll function for entity instances. + * @param {Object} http - HTTP client instance. + * @param {Function=} wrapperCollection - Collection wrapper function. + * @param {Object=} params - Optional default parameters. + * @returns {Function} Async function that fetches all entities. + * @example + * const fetchAllFn = fetchAll(http, EntityCollection) + * await fetchAllFn.call(entityInstance, { limit: 10 }) + */ export const fetchAll = (http, wrapperCollection, params = {}) => { return async function (param = {}) { const headers = { @@ -263,6 +368,15 @@ export const fetchAll = (http, wrapperCollection, params = {}) => { } } +/** + * Parses response data and adds stack headers and metadata. + * @param {Object} response - HTTP response object. + * @param {Object} stackHeaders - Stack headers to add to data. + * @param {string=} contentTypeUID - Content type UID. + * @param {string=} taxonomyUid - Taxonomy UID. + * @param {Object} http - HTTP client instance. + * @returns {Object} Parsed data object with stack headers. + */ export function parseData (response, stackHeaders, contentTypeUID, taxonomyUid, http) { const data = response.data || {} if (stackHeaders && 'api_version' in stackHeaders) { @@ -286,6 +400,15 @@ export function parseData (response, stackHeaders, contentTypeUID, taxonomyUid, return data } +/** + * Performs a GET request with branch and stack header data. + * @param {Object} http - HTTP client instance. + * @param {string} url - API endpoint URL. + * @param {Object} params - Query parameters. + * @param {Object} data - Data object containing branches and stackHeaders. + * @returns {Promise} Promise that resolves to response data. + * @async + */ export async function get (http, url, params, data) { const headers = { params: { @@ -308,6 +431,17 @@ export async function get (http, url, params, data) { } } +/** + * Creates a move function for entity instances. + * @param {Object} http - HTTP client instance. + * @param {string} type - Entity type (e.g., 'entry', 'asset'). + * @param {boolean=} force - Whether to force move, defaults to false. + * @param {Object=} params - Optional default parameters. + * @returns {Function} Async function that moves an entity. + * @example + * const moveFn = move(http, 'entry', false) + * await moveFn.call(entryInstance, { parent_uid: 'new_parent' }) + */ export const move = (http, type, force = false, params = {}) => { return async function (param = {}) { try { @@ -344,6 +478,11 @@ function isAsset (data) { return (!!element.file_size || !!element.content_type) && !!element.uid } +/** + * Recursively cleans asset objects in data, replacing full asset objects with their UIDs. + * @param {Object|Array} data - Data object or array containing asset references. + * @returns {Object|Array} Data with asset objects replaced by UIDs. + */ export function cleanAssets (data) { if (data && typeof data === 'object') { const keys = Object.keys(data) diff --git a/lib/organization/index.js b/lib/organization/index.js index 49c26fa8..289032a0 100644 --- a/lib/organization/index.js +++ b/lib/organization/index.js @@ -21,13 +21,13 @@ export function Organization (http, data) { * @description The teams call fetches teams details. * @memberof Organization * @func teams - * @returns {Promise} Promise for Organization instance + * @returns {Teams} Instance of Teams. * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client() * * client.organization('organization_uid').teams('teamsUid').fetch() - * .then((organization) => console.log(organization)) + * .then((team) => console.log(team)) * */ this.teams = (teamUid = null) => { @@ -41,7 +41,7 @@ export function Organization (http, data) { * @description The fetch Organization call fetches Organization details. * @memberof Organization * @func fetch - * @param {Int} include_plan The include_plan parameter includes the details of the plan that the organization has subscribed to. + * @param {Boolean} include_plan The include_plan parameter includes the details of the plan that the organization has subscribed to. * @returns {Promise} Promise for Organization instance * @example * import * as contentstack from '@contentstack/management' @@ -56,13 +56,15 @@ export function Organization (http, data) { * @description The Get all stacks in an organization call fetches the list of all stacks in an Organization. * @memberof Organization * @func stacks - * @param {Int} limit The limit parameter will return a specific number of stacks in the output. - * @param {Int} skip The skip parameter will skip a specific number of stacks in the output. - * @param {String} asc When fetching stacks, you can sort them in the ascending order with respect to the value of a specific field in the response body. - * @param {String} desc When fetching stacks, you can sort them in the decending order with respect to the value of a specific field in the response body. - * @param {Boolean} include_count To retrieve the count of stack. - * @param {String} typeahead The type head contains value to be included in search. - * @returns {ContentstackCollection} Instance of ContentstackCollection. + * @async + * @param {Object=} param - Query parameters. + * @prop {Number=} param.limit - The limit parameter will return a specific number of stacks in the output. + * @prop {Number=} param.skip - The skip parameter will skip a specific number of stacks in the output. + * @prop {String=} param.asc - When fetching stacks, you can sort them in the ascending order with respect to the value of a specific field in the response body. + * @prop {String=} param.desc - When fetching stacks, you can sort them in descending order with respect to the value of a specific field in the response body. + * @prop {Boolean=} param.include_count - To retrieve the count of stack. + * @prop {String=} param.typeahead - The typeahead contains value to be included in search. + * @returns {Promise} Promise for ContentstackCollection instance. * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client() @@ -88,8 +90,9 @@ export function Organization (http, data) { * @description The Transfer organization ownership call transfers the ownership of an Organization to another user. * @memberof Organization * @func transferOwnership + * @async * @param {String} email The email address of the user to whom you wish to transfer the ownership of the organization. - * @returns {Object} Response Object. + * @returns {Promise} Response Object. * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client() @@ -115,7 +118,8 @@ export function Organization (http, data) { * @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 - * @returns {ContentstackCollection} ContentstackCollection of instance. + * @async + * @returns {Promise} Promise for ContentstackCollection instance. * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client() @@ -141,7 +145,8 @@ export function Organization (http, data) { * @description The Get all organization invitations call gives you a list of all the Organization invitations. * @memberof Organization * @func getInvitations - * @returns {String} Success message of invitation send. + * @async + * @returns {Promise} Promise for ContentstackCollection instance. * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client() @@ -166,13 +171,14 @@ export function Organization (http, data) { /** * @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 - * @returns {Object} Response Object. + * @func resendInvitation + * @async + * @returns {Promise} Response Object. * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client() * - * client.organization('organization_uid').resendInvitition('invitation_uid') + * client.organization('organization_uid').resendInvitation('invitation_uid') * .then((response) => console.log(response.notice)) * */ @@ -193,13 +199,15 @@ export function Organization (http, data) { * @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 - * @param {Int} limit The limit parameter will return a specific number of roles in the output. - * @param {Int} skip The skip parameter will skip a specific number of roles in the output. - * @param {String} asc When fetching roles, you can sort them in the ascending order with respect to the value of a specific field in the response body. - * @param {String} desc When fetching roles, you can sort them in the decending order with respect to the value of a specific field in the response body. - * @param {Boolean}include_count To retrieve the count of roles. - * @param {Boolean} include_stack_roles The Include stack roles will return stack details in roles. - * @returns {Array} Array of Role instance + * @async + * @param {Object=} param - Query parameters. + * @prop {Number=} param.limit - The limit parameter will return a specific number of roles in the output. + * @prop {Number=} param.skip - The skip parameter will skip a specific number of roles in the output. + * @prop {String=} param.asc - When fetching roles, you can sort them in the ascending order with respect to the value of a specific field in the response body. + * @prop {String=} param.desc - When fetching roles, you can sort them in descending order with respect to the value of a specific field in the response body. + * @prop {Boolean=} param.include_count - To retrieve the count of roles. + * @prop {Boolean=} param.include_stack_roles - The Include stack roles will return stack details in roles. + * @returns {Promise} Promise for ContentstackCollection instance. * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client() @@ -225,13 +233,13 @@ export function Organization (http, data) { * @description The Get all organizations call lists all organizations related to the system user in the order that they were created. * @memberof Organization * @func fetchAll - * @param {Int} limit TThe ‘limit’ parameter will return a specific number of organizations in the output. - * @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 {Number} limit - The 'limit' parameter will return a specific number of organizations in the output. + * @param {Number} 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 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 {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. + * @returns {Promise} Promise for ContentstackCollection instance. * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client() diff --git a/lib/organization/teams/teamUsers/index.js b/lib/organization/teams/teamUsers/index.js index ff0636d9..77bcfa9f 100644 --- a/lib/organization/teams/teamUsers/index.js +++ b/lib/organization/teams/teamUsers/index.js @@ -30,33 +30,32 @@ export function TeamUsers (http, data) { this.urlPath = `/organizations/${data.organizationUid}/teams/${data.teamUid}/users` /** - * @description The Add teamUser call is used to add an user the team. + * @description The Add teamUser call is used to add a user to the team. * @memberof TeamUsers * @func add - * @returns {Promise} Response Object. + * @returns {Promise} Promise for TeamUsers instance * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client() * const usersMail = { * emails: ['emailId1','emailId2' ] * } - * client.organization('organizationUid').teams('teamUid').teamUsers('userId').add(usersMail) + * client.organization('organizationUid').teams('teamUid').teamUsers().add(usersMail) * .then((response) => console.log(response)) * */ this.add = create({ http }) /** - * @description The Query on teamUser will allow to fetch details of all teamUsers. + * @description The fetchAll on teamUser will allow to fetch details of all teamUsers. * @memberof TeamUsers - * @func query - * @returns {Promise} Response Object. + * @func fetchAll + * @returns {ContentstackCollection} Instance of ContentstackCollection. * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client() - * const usersMail = { - * emails: ['emailId1','emailId2' ]} - * client.organization('organizationUid').teams('teamUid').teamUsers('userId').query().find() + * + * client.organization('organizationUid').teams('teamUid').teamUsers().fetchAll() * .then((response) => console.log(response)) * */ diff --git a/lib/stack/auditlog/index.js b/lib/stack/auditlog/index.js index ed27a020..1ec9a437 100644 --- a/lib/stack/auditlog/index.js +++ b/lib/stack/auditlog/index.js @@ -17,7 +17,7 @@ export function AuditLog (http, data = {}) { * @description The fetch AuditLog call fetches AuditLog details. * @memberof AuditLog * @func fetch - * @returns {Promise} Promise for Branch instance + * @returns {Promise} Promise for AuditLog instance * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client() @@ -46,12 +46,12 @@ export function AuditLog (http, data = {}) { } } else { /** - * @description The Get all AuditLog request retrieves the details of all the Branch of a stack. + * @description The Get all AuditLog request retrieves the details of all the AuditLog entries of a stack. * @memberof AuditLog * @func fetchAll - * @param {Int} limit The limit parameter will return a specific number of Branch in the output. - * @param {Int} skip The skip parameter will skip a specific number of Branch in the output. - * @param {Boolean}include_count To retrieve the count of Branch. + * @param {Int} limit The limit parameter will return a specific number of AuditLog entries in the output. + * @param {Int} skip The skip parameter will skip a specific number of AuditLog entries in the output. + * @param {Boolean} include_count - To retrieve the count of AuditLog entries. * @returns {ContentstackCollection} Result collection of content of specified module. * @example * import * as contentstack from '@contentstack/management' diff --git a/lib/stack/branch/compare.js b/lib/stack/branch/compare.js index 4d10e526..df0f29e9 100644 --- a/lib/stack/branch/compare.js +++ b/lib/stack/branch/compare.js @@ -18,8 +18,8 @@ export function Compare (http, data = {}) { * const client = contentstack.client() * * client.stack({ api_key: 'api_key'}).branch('branch_uid').compare('compare_branch_uid').all({skip: 0, limit: 100}) - * .then(response) - * .catch(error) + * .then((response) => console.log(response)) + * .catch((error) => console.error(error)) * */ this.all = async (params = {}) => { @@ -36,9 +36,9 @@ export function Compare (http, data = {}) { * import * as contentstack from '@contentstack/management' * const client = contentstack.client() * - * client.stack({ api_key: 'api_key'}).branch('branch_uid').compare().all({skip: 0, limit: 100}) - * .then(response) - * .catch(error) + * client.stack({ api_key: 'api_key'}).branch('branch_uid').compare('compare_branch_uid').contentTypes({skip: 0, limit: 100}) + * .then((response) => console.log(response)) + * .catch((error) => console.error(error)) * */ this.contentTypes = async (params = {}) => { @@ -51,7 +51,7 @@ export function Compare (http, data = {}) { } /** - * @description Compare allows you compare any or specific ContentType or GlobalFields. + * @description Compare allows you to compare any or specific ContentType or GlobalFields. * @memberof Compare * @func globalFields * @param {string} params.uid Optional uid for Global Field to compare. @@ -60,9 +60,9 @@ export function Compare (http, data = {}) { * import * as contentstack from '@contentstack/management' * const client = contentstack.client() * - * client.stack({ api_key: 'api_key'}).branch('branch_uid').compare().all({skip: 0, limit: 100}) - * .then(response) - * .catch(error) + * client.stack({ api_key: 'api_key'}).branch('branch_uid').compare('compare_branch_uid').globalFields({skip: 0, limit: 100}) + * .then((response) => console.log(response)) + * .catch((error) => console.error(error)) * */ this.globalFields = async (params = {}) => { diff --git a/lib/stack/branch/index.js b/lib/stack/branch/index.js index 28f1378a..80e1cdb1 100644 --- a/lib/stack/branch/index.js +++ b/lib/stack/branch/index.js @@ -49,7 +49,7 @@ export function Branch (http, data = {}) { this.fetch = fetch(http, 'branch') /** - * @description Compare allows you compare any or specific ContentType or GlobalFields. + * @description Compare allows you to compare any or specific ContentType or GlobalFields. * @memberof Branch * @func compare * @returns {Compare} Instance of Compare. diff --git a/lib/stack/branchAlias/index.js b/lib/stack/branchAlias/index.js index 9ebd1c0d..298aee1b 100644 --- a/lib/stack/branchAlias/index.js +++ b/lib/stack/branchAlias/index.js @@ -17,7 +17,7 @@ export function BranchAlias (http, data = {}) { /** * @description The Update BranchAlias call lets you update the name of an existing BranchAlias. * @memberof BranchAlias - * @func update + * @func createOrUpdate * @returns {Promise} Promise for Branch instance * @example * import * as contentstack from '@contentstack/management' @@ -93,13 +93,13 @@ export function BranchAlias (http, data = {}) { } } else { /** - * @description The Get all BranchAlias request retrieves the details of all the Branch of a stack. + * @description The Get all BranchAlias request retrieves the details of all the BranchAlias of a stack. * @memberof BranchAlias * @func fetchAll - * @param {Int} limit The limit parameter will return a specific number of Branch in the output. - * @param {Int} skip The skip parameter will skip a specific number of Branch in the output. - * @param {Boolean}include_count To retrieve the count of Branch. - * @returns {ContentstackCollection} Result collection of content of specified module. + * @param {Number} limit The limit parameter will return a specific number of BranchAlias in the output. + * @param {Number} skip The skip parameter will skip a specific number of BranchAlias in the output. + * @param {Boolean} include_count - To retrieve the count of BranchAlias. + * @returns {Promise} Promise for ContentstackCollection instance. * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client() diff --git a/lib/stack/bulkOperation/index.js b/lib/stack/bulkOperation/index.js index 18fa9778..175591e2 100644 --- a/lib/stack/bulkOperation/index.js +++ b/lib/stack/bulkOperation/index.js @@ -131,9 +131,9 @@ export function BulkOperation (http, data = {}) { * @memberof BulkOperation * @func publish * @returns {Promise} Response Object. - * @param {Boolean} params.details - Set this with details containing 'entries', 'assets', 'locales', and 'environments' to which you want to publish the entries or assets. - * @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. - * @param {Boolean} params.approvals Set this to 'true' to publish the entries that do not require an approval to be published. + * @param {Object} params.details - Set this with details containing 'entries', 'assets', 'locales', and 'environments' to which you want to publish the entries or assets. + * @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. + * @param {Boolean} params.approvals - Set this to 'true' to publish the entries that do not require an approval to be published. * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client() @@ -230,9 +230,9 @@ export function BulkOperation (http, data = {}) { * @memberof BulkOperation * @func unpublish * @returns {Promise} Response Object. - * @param {Boolean} params.details - Set this with details containing 'entries', 'assets', 'locales', and 'environments' to which you want to unpublish the entries or assets. If you do not specify a source locale, the entries or assets will be unpublished in the master locale automatically. - * @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. - * @param {Boolean} params.approvals Set this to 'true' to publish the entries that do not require an approval to be published. + * @param {Object} params.details - Set this with details containing 'entries', 'assets', 'locales', and 'environments' to which you want to unpublish the entries or assets. If you do not specify a source locale, the entries or assets will be unpublished in the master locale automatically. + * @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. + * @param {Boolean} params.approvals - Set this to 'true' to publish the entries that do not require an approval to be published. * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client() @@ -263,7 +263,7 @@ export function BulkOperation (http, data = {}) { * // Bulk nested publish * import * as contentstack from '@contentstack/management' * const client = contentstack.client() - * { + * const publishDetails = { * environments:["{{env_uid}}","{{env_uid}}"], * locales:["en-us"], * items:[ @@ -327,7 +327,7 @@ export function BulkOperation (http, data = {}) { * @memberof BulkOperation * @func delete * @returns {Promise} Success message - * @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. + * @param {Object} params.details - Set this with details specifying the content type UIDs, entry UIDs or asset UIDs, and locales of which the entries or assets you want to delete. * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client() @@ -362,11 +362,11 @@ export function BulkOperation (http, data = {}) { } /** - * The Delete entries and assets in bulk request allows you to delete multiple entries and assets at the same time. + * The Update workflow stage for entries in bulk request allows you to update workflow stages for multiple entries at the same time. * @memberof BulkOperation * @func update * @returns {Promise} Success message - * @param {Boolean} updateBody - 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 update. + * @param {Object} updateBody - Set this with details specifying the content type UIDs, entry UIDs or asset UIDs, and locales of which the entries or assets you want to update. * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client() diff --git a/lib/stack/contentType/index.js b/lib/stack/contentType/index.js index 3f9e9c1c..00d9acec 100644 --- a/lib/stack/contentType/index.js +++ b/lib/stack/contentType/index.js @@ -125,7 +125,8 @@ export function ContentType (http, data = {}) { * @memberof ContentType * @func fetch * @returns {Promise} Promise for ContentType instance - * @param {Int} version Enter the unique ID of the content type of which you want to retrieve the details. The UID is generated based on the title of the content type. The unique ID of a content type is unique across a stack. + * @param {Object=} param - Query parameters + * @prop {Int} param.version - Enter the version number of the content type you want to retrieve. * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client() @@ -138,8 +139,8 @@ export function ContentType (http, data = {}) { /** * @description Content type defines the structure or schema of a page or a section of your web or mobile property. - * @param {String} uid The UID of the ContentType you want to get details. - * @returns {ContenType} Instace of ContentType. + * @param {String} uid - The UID of the ContentType you want to get details. + * @returns {Entry} Instance of Entry. * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client() diff --git a/lib/stack/deliveryToken/index.js b/lib/stack/deliveryToken/index.js index 12f8ac10..50ba9541 100644 --- a/lib/stack/deliveryToken/index.js +++ b/lib/stack/deliveryToken/index.js @@ -23,8 +23,8 @@ export function DeliveryToken (http, data = {}) { * * client.stack({ api_key: 'api_key'}).deliveryToken('delivery_token_uid').fetch() * .then((deliveryToken) => { - * deliveryToken.title = 'My New Content Type' - * deliveryToken.description = 'Content Type description' + * deliveryToken.name = 'My New Delivery Token' + * deliveryToken.description = 'Delivery Token description' * return deliveryToken.update() * }) * .then((deliveryToken) => console.log(deliveryToken)) @@ -104,15 +104,15 @@ export function DeliveryToken (http, data = {}) { this.create = create({ http: http }) /** - * @description The ‘Get all deliveryToken’ request returns comprehensive information about all deliveryToken created in a stack. + * @description The 'Get all deliveryToken' request returns comprehensive information about all deliveryToken created in a stack. * @memberof DeliveryToken * @func query - * @returns {ContentstackCollection} Instance of ContentstackCollection. + * @returns {Object} Query builder object with find(), count(), and findOne() methods. * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client() * - * client.stack().deliveryToken().query({ query: { name: 'token_name' } })).find() + * client.stack().deliveryToken().query({ query: { name: 'token_name' } }).find() * .then((contentstackCollection) => console.log(contentstackCollection)) */ this.query = query({ http: http, wrapperCollection: DeliveryTokenCollection }) diff --git a/lib/stack/environment/index.js b/lib/stack/environment/index.js index e6d40241..38814b1e 100644 --- a/lib/stack/environment/index.js +++ b/lib/stack/environment/index.js @@ -23,8 +23,8 @@ export function Environment (http, data = {}) { * * client.stack({ api_key: 'api_key'}).environment('uid').fetch() * .then((environment) => { - * environment.title = 'My New Content Type' - * environment.description = 'Content Type description' + * environment.name = 'My New Environment' + * environment.description = 'Environment description' * return environment.update() * }) * .then((environment) => console.log(environment)) @@ -91,17 +91,17 @@ export function Environment (http, data = {}) { this.create = create({ http: http }) /** - * @description The Query on GlobalField will allow to fetch details of all or specific GlobalField + * @description The Query on Environment will allow to fetch details of all or specific Environment. * @memberof Environment * @func query - * @returns {Array} Array of GlobalField. + * @returns {ContentstackCollection} Instance of ContentstackCollection. * * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client() * * client.stack({ api_key: 'api_key'}).environment().query({ query: { name: 'Environment Name' } }).find() - * .then((globalFields) => console.log(globalFields)) + * .then((environments) => console.log(environments)) */ this.query = query({ http: http, wrapperCollection: EnvironmentCollection }) } diff --git a/lib/stack/extension/index.js b/lib/stack/extension/index.js index c6ada9d2..fb3c8f6f 100644 --- a/lib/stack/extension/index.js +++ b/lib/stack/extension/index.js @@ -75,16 +75,14 @@ export function Extension (http, data = {}) { * * const extension = { * upload: 'path/to/file', - * title: 'Title', * tags: [ * 'tag1', * 'tag2' * ], * data_type: 'text', - * title: 'Old Extension', * multiple: false, * config: {}, - * type: 'Type of extenstion you want to create widget/dashboard/field' + * type: 'Type of extension you want to create widget/dashboard/field' * } * * client.stack({ api_key: 'api_key'}).extension().upload(extension) @@ -130,17 +128,18 @@ export function Extension (http, data = {}) { this.create = create({ http: http }) /** - * @description The Query on Content Type will allow to fetch details of all or specific Content Type + * @description The Query on Extension will allow to fetch details of all or specific Extensions. * @memberof Extension * @func query - * @param {Boolean} include_count Set this to 'true' to include in response the total count of content types available in your stack. - * @returns {Array} Array of ContentTyoe. + * @param {Object} params - URI parameters + * @prop {Object} params.query - Queries that you can use to fetch filtered results for extensions. + * @returns {ContentstackCollection} Instance of ContentstackCollection. * * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client() * - * client.stack().extension().query({ query={"type":"field"}}) + * client.stack().extension().query({ query: { type: "field" } }).find() * .then((extensions) => console.log(extensions)) */ this.query = query({ http: http, wrapperCollection: ExtensionCollection }) diff --git a/lib/stack/globalField/index.js b/lib/stack/globalField/index.js index 57192ea6..dcd8c45c 100644 --- a/lib/stack/globalField/index.js +++ b/lib/stack/globalField/index.js @@ -79,7 +79,7 @@ export function GlobalField (http, data = {}) { * @returns {Promise} Promise for GlobalField instance * * @example - * import * as contentstac k from '@contentstack/management' + * import * as contentstack from '@contentstack/management' * const client = contentstack.client() * const global_field = { * title: 'First', @@ -96,10 +96,12 @@ export function GlobalField (http, data = {}) { this.create = create({ http: http }) /** - * @description The Query on GlobalField will allow to fetch details of all or specific GlobalField + * @description The Query on GlobalField will allow to fetch details of all or specific GlobalField. * @memberof GlobalField * @func query - * @returns {Array} Array of GlobalField. + * @param {Object} params - Query parameters + * @prop {Object} params.query - Queries that you can use to fetch filtered results. + * @returns {ContentstackCollection} Instance of ContentstackCollection. * * @example * import * as contentstack from '@contentstack/management' @@ -115,6 +117,8 @@ export function GlobalField (http, data = {}) { * @memberof GlobalField * @func import * @param {String} data.global_field path to file + * @param {Object=} params - Optional request parameters + * @param {Object=} headers - Optional request headers * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client() diff --git a/lib/stack/index.js b/lib/stack/index.js index f4a4984c..ee800f3b 100644 --- a/lib/stack/index.js +++ b/lib/stack/index.js @@ -148,7 +148,8 @@ export function Stack (http, data) { } /** * @description Global field defines the structure or schema of a page or a section of your web or mobile property. - * @param {String} uid The UID of the Global field you want to get details. + * @param {String|Object=} uidOrOptions The UID of the Global field or options object + * @param {Object=} option Optional configuration object (e.g., { branch: 'branch_uid' }) * @returns {GlobalField} Instance of Global field. * @example * import * as contentstack from '@contentstack/management' @@ -194,7 +195,7 @@ export function Stack (http, data) { /** * @description Environment corresponds to one or more deployment servers or a content delivery destination where the entries need to be published. - * @param {String} uid The UID of the Environment you want to get details. + * @param {String} environmentUid The name or UID of the Environment you want to get details. * @returns {Environment} Instance of Environment. * @example * import * as contentstack from '@contentstack/management' @@ -216,7 +217,7 @@ export function Stack (http, data) { /** * @description Branch corresponds to Stack branch. - * @param {String} + * @param {String} branchUid - The UID of the branch * @returns {Branch} * * @example @@ -240,7 +241,7 @@ export function Stack (http, data) { /** * @description Branch corresponds to Stack branch. - * @param {String} + * @param {String} branchUid - The UID of the branch alias * @returns {BranchAlias} * * @example @@ -674,7 +675,7 @@ export function Stack (http, data) { * @memberof Stack * @func share * @param {Array} emails - Email ID of the user with whom you wish to share the stack - * @param {Array} roles - The role uid that you wish to assign the user. + * @param {Object} roles - The roles object mapping email addresses to role UIDs. Example: { "[email protected]": [ "role_uid" ] } * @returns {Object} Response Object. * * @example @@ -825,7 +826,7 @@ export function Stack (http, data) { /** * @description Audit log displays a record of all the activities performed in a stack and helps you keep a track of all published items, updates, deletes, and current status of the existing content. - * @param {String} + * @param {String} logItemUid - The UID of the log item * @returns {AuditLog} * * @example @@ -866,11 +867,12 @@ export function Stack (http, data) { * @description The Query on Stack will allow to fetch details of all or specific Stack. * @memberof Stack * @func query - * @param {Boolean} include_collaborators Set this parameter to 'true' to include the details of the stack collaborators. - * @param {Boolean} include_stack_variablesSet this to 'true' to display the stack variables. Stack variables are extra information about the stack, such as the description, format of date, format of time, and so on. Users can include or exclude stack variables in the response. - * @param {Boolean} include_discrete_variables Set this to 'true' to view the access token of your stack. - * @param {Boolean} include_count Set this to 'true' to include in the response the total count of the stacks owned by or shared with a user account. - * @param {Object} query Queries that you can use to fetch filtered results. + * @param {Object} params - Query parameters + * @prop {Boolean} params.include_collaborators - Set this parameter to 'true' to include the details of the stack collaborators. + * @prop {Boolean} params.include_stack_variables - Set this to 'true' to display the stack variables. Stack variables are extra information about the stack, such as the description, format of date, format of time, and so on. Users can include or exclude stack variables in the response. + * @prop {Boolean} params.include_discrete_variables - Set this to 'true' to view the access token of your stack. + * @prop {Boolean} params.include_count - Set this to 'true' to include in the response the total count of the stacks owned by or shared with a user account. + * @prop {Object} params.query - Queries that you can use to fetch filtered results. * @returns {ContentstackCollection} Instance of ContentstackCollection. * * @example diff --git a/lib/stack/label/index.js b/lib/stack/label/index.js index 66c66355..71f42e4a 100644 --- a/lib/stack/label/index.js +++ b/lib/stack/label/index.js @@ -28,7 +28,7 @@ export function Label (http, data) { * * client.stack({ api_key: 'api_key'}).label('label_uid').fetch() * .then((label) => { - * label.name = 'My New Content Type' + * label.name = 'My New Label' * return label.update() * }) * .then((label) => console.log(label)) @@ -66,7 +66,7 @@ export function Label (http, data) { this.fetch = fetch(http, 'label') } else { /** - * @description The Create an label call creates a new label. + * @description The Create a label call creates a new label in a particular stack of your Contentstack account. * @memberof Label * @func create * @returns {Promise} Promise for Label instance diff --git a/lib/stack/locale/index.js b/lib/stack/locale/index.js index 6edafa45..ec00a9f2 100644 --- a/lib/stack/locale/index.js +++ b/lib/stack/locale/index.js @@ -51,7 +51,8 @@ export function Locale (http, data = {}) { * @memberof Locale * @func fetch * @returns {Promise} Promise for Locale instance - * @param {Int} version Enter the unique ID of the content type of which you want to retrieve the details. The UID is generated based on the title of the content type. The unique ID of a content type is unique across a stack. + * @param {Object=} param - Query parameters + * @prop {Int} param.version - Enter the version number of the locale you want to retrieve. * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client() @@ -63,7 +64,7 @@ export function Locale (http, data = {}) { this.fetch = fetch(http, 'locale') } else { /** - * @description The Create a content type call creates a new content type in a particular stack of your Contentstack account. + * @description The Create a Locale call creates a new locale in a particular stack of your Contentstack account. * @memberof Locale * @func create * @returns {Promise} Promise for Locale instance @@ -72,23 +73,25 @@ export function Locale (http, data = {}) { * import * as contentstack from '@contentstack/management' * const client = contentstack.client() * - * client.stack().locale().create({ locale: { code: 'en-at' } ) + * client.stack().locale().create({ locale: { code: 'en-at' } }) * .then((locale) => console.log(locale)) */ this.create = create({ http: http }) /** - * @description The Query on Content Type will allow to fetch details of all or specific Content Type + * @description The Query on Locale will allow you to fetch details of all or specific Locales. * @memberof Locale * @func query - * @param {Boolean} include_count Set this to 'true' to include in response the total count of content types available in your stack. - * @returns {Array} Array of ContentTyoe. + * @param {Object} params - Query parameters + * @prop {Boolean} params.include_count - Set this to 'true' to include in response the total count of locales available in your stack. + * @prop {Object} params.query - Queries that you can use to fetch filtered results. + * @returns {Object} Query builder object with find(), count(), and findOne() methods. * * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client() * - * client.stack(api_key).locale().query({ query: { code: 'locale-code' } }).find() + * client.stack({ api_key: 'api_key' }).locale().query({ query: { code: 'locale-code' } }).find() * .then((locales) => console.log(locales)) */ this.query = query({ http: http, wrapperCollection: LocaleCollection }) diff --git a/lib/stack/managementToken/index.js b/lib/stack/managementToken/index.js index d8b455e6..5a051c02 100644 --- a/lib/stack/managementToken/index.js +++ b/lib/stack/managementToken/index.js @@ -2,7 +2,7 @@ import cloneDeep from 'lodash/cloneDeep' import { create, update, deleteEntity, fetch, query } from '../../entity' /** - * Management tokens provide read-only access to the associated environments. Read more about ManagementToken. + * Management tokens provide read-write access to the associated environments. Read more about ManagementToken. * @namespace ManagementToken */ export function ManagementToken (http, data = {}) { @@ -22,7 +22,7 @@ export function ManagementToken (http, data = {}) { * * client.stack({ api_key: 'api_key'}).managementToken('management_token_uid').fetch() * .then((managementToken) => { - * managementToken.title = 'My New management token' + * managementToken.name = 'My New management token' * managementToken.description = 'management token description' * return managementToken.update() * }) @@ -95,7 +95,7 @@ export function ManagementToken (http, data = {}) { * import * as contentstack from '@contentstack/management' * const client = contentstack.client() * - * client.stack().managementToken().query({ query: { name: 'token_name' } })).find() + * client.stack().managementToken().query({ query: { name: 'token_name' } }).find() * .then((contentstackCollection) => console.log(contentstackCollection)) */ this.query = query({ http: http, wrapperCollection: ManagementTokenCollection }) diff --git a/lib/stack/release/index.js b/lib/stack/release/index.js index 7bac8ac6..fcb332ce 100644 --- a/lib/stack/release/index.js +++ b/lib/stack/release/index.js @@ -10,7 +10,7 @@ import error from '../../core/contentstackError' import { ReleaseItem, ReleaseItemCollection } from './items' /** * @description You can pin a set of entries and assets (along with the deploy action, i.e., publish/unpublish) to a ‘release’, and then deploy this release to an environment. - * This will publish/unpublish all the the items of the release to the specified environment. Read more about Releases. + * This will publish/unpublish all the items of the release to the specified environment. Read more about Releases. * @namespace Release */ @@ -33,7 +33,7 @@ export function Release (http, data = {}) { * import * as contentstack from '@contentstack/management' * const client = contentstack.client() * - * const relase = { + * const release = { * name: "Release Name", * description: "2018-12-12", * locked: false, @@ -115,11 +115,11 @@ export function Release (http, data = {}) { * @description The Deploy a Release request deploys a specific Release to specific environment(s) and locale(s). * @memberof Release * @func deploy - * @returns {Object} Response Object. + * @returns {Promise} Response Object. * @param {Array} environments - environment(s) on which the Release should be deployed. * @param {Array} locales - locale(s) on which the Release should be deployed. * @param {String} action - action on which the Release should be deployed. - * @param {String} scheduledAt - scheudle time for the Release to deploy. + * @param {String} scheduledAt - Schedule time for the Release to deploy. * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client() @@ -216,14 +216,14 @@ export function Release (http, data = {}) { this.create = create({ http: http }) /** - * @description The Query on release will allow to fetch details of all or specific Releases. + * @description The Query on Release will allow you to fetch details of all or specific Releases. * @memberof Release * @func query - * @param {Boolean} param.include_countThe ‘include_count’ parameter includes the count of total number of releases in your stack, along with the details of each release. - * @param {Boolean} param.include_items_count The ‘include_items_count’ parameter returns the total number of items in a specific release. - * @param {Int} param.limit The ‘limit’ parameter will return a specific number of releases in the output. - * @param {Int} param.skip The ‘skip’ parameter will skip a specific number of releases in the response. - * @returns {Array} Array of Release. + * @param {Boolean} param.include_count The 'include_count' parameter includes the count of total number of releases in your stack, along with the details of each release. + * @param {Boolean} param.include_items_count The 'include_items_count' parameter returns the total number of items in a specific release. + * @param {Number} param.limit The 'limit' parameter will return a specific number of releases in the output. + * @param {Number} param.skip The 'skip' parameter will skip a specific number of releases in the response. + * @returns {Object} Query builder object with find(), count(), and findOne() methods. * * @example * import * as contentstack from '@contentstack/management' diff --git a/lib/stack/release/items/index.js b/lib/stack/release/items/index.js index f9e0d26e..94a50690 100644 --- a/lib/stack/release/items/index.js +++ b/lib/stack/release/items/index.js @@ -18,18 +18,18 @@ export function ReleaseItem (http, data = {}) { * @description The Delete method request deletes one or more items (entries and/or assets) from a specific Release. * @memberof ReleaseItem * @func delete - * @param {Object} param.items Add multiple items to a Release - * @param {Object} param.items Add multiple items to a Release - * @returns {Object} Response Object. + * @param {Object} param - Parameters object + * @prop {Array} param.items - Array of items to delete from release + * @returns {Promise} Response Object. * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client() * // To delete all the items from release - * client.stack({ api_key: 'api_key'}).release('release_uid').delete() + * client.stack({ api_key: 'api_key'}).release('release_uid').item().delete() * .then((response) => console.log(response.notice)) * * @example - * // Delete specific items from delete + * // Delete specific items from release * import * as contentstack from '@contentstack/management' * const client = contentstack.client() * @@ -49,7 +49,7 @@ export function ReleaseItem (http, data = {}) { * action: "publish" * } * ] - * client.stack({ api_key: 'api_key'}).release('release_uid').delete({items}) + * client.stack({ api_key: 'api_key'}).release('release_uid').item().delete({items}) * .then((response) => console.log(response.notice)) */ this.delete = async (params) => { @@ -85,12 +85,12 @@ export function ReleaseItem (http, data = {}) { throw error(response) } } catch (err) { - throw error(err) + error(err) } } /** - * @description The Create method allows you to add an one or more items items (entry or asset) to a Release. + * @description The Create method allows you to add one or more items (entry or asset) to a Release. * @memberof ReleaseItem * @func create * @param {Object} param.item Add a single item to a Release @@ -170,10 +170,10 @@ export function ReleaseItem (http, data = {}) { * @description The Get all items in a Release request retrieves a list of all items (entries and assets) that are part of a specific Release. * @memberof ReleaseItem * @func findAll - * @returns {Promise} Promise for ContentType instance - * @param {Boolean} param.include_count ‘include_count’ parameter includes the count of total number of items in Release, along with the details of each items. - * @param {Int} param.limit The ‘limit’ parameter will return a specific number of release items in the output. - * @param {Int} param.skip The ‘skip’ parameter will skip a specific number of release items in the response. + * @param {Boolean} param.include_count 'include_count' parameter includes the count of total number of items in Release, along with the details of each items. + * @returns {Promise} Promise for ContentstackCollection instance + * @param {Number} param.limit The 'limit' parameter will return a specific number of release items in the output. + * @param {Number} param.skip The 'skip' parameter will skip a specific number of release items in the response. * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client() @@ -205,7 +205,7 @@ export function ReleaseItem (http, data = {}) { } /** - * The move request allows you to move multiple items within a release. + * @description The move request allows you to move multiple items within a release. * @memberof ReleaseItem * @func move * @returns {Promise} Response Object. diff --git a/lib/stack/roles/index.js b/lib/stack/roles/index.js index 483440ad..4f8b87c0 100644 --- a/lib/stack/roles/index.js +++ b/lib/stack/roles/index.js @@ -1,7 +1,7 @@ import cloneDeep from 'lodash/cloneDeep' import { create, update, deleteEntity, fetch, query, fetchAll } from '../../entity' /** - * A role is a collection of permissions that will be applicable to all the users who are assigned this role. Read more about Roles. + * A role is a collection of permissions that will be applicable to all the users who are assigned this role. Read more about Roles. * @namespace Role */ export function Role (http, data) { @@ -145,7 +145,7 @@ export function Role (http, data) { * import * as contentstack from '@contentstack/management' * const client = contentstack.client() * - * client.stack({ api_key: 'api_key'}).role().query({ query: { filename: 'Asset Name' } }).find() + * client.stack({ api_key: 'api_key'}).role().query({ query: { name: 'Role Name' } }).find() * .then((role) => console.log(role)) */ this.query = query({ http: http, wrapperCollection: RoleCollection }) diff --git a/lib/stack/taxonomy/index.js b/lib/stack/taxonomy/index.js index 13533619..5e083193 100644 --- a/lib/stack/taxonomy/index.js +++ b/lib/stack/taxonomy/index.js @@ -145,7 +145,7 @@ export function Taxonomy (http, data = {}) { * import * as contentstack from '@contentstack/management' * const client = contentstack.client() * - * client.stack({ api_key: 'api_key'}).taxonomy('taxonomy_UID').localize({taxonomy: data}, {locale: 'hi-in'}) + * client.stack({ api_key: 'api_key'}).taxonomy('taxonomy_UID').localize({ taxonomy: data }, { locale: 'hi-in' }) * .then((taxonomy) => console.log(taxonomy)) * */ @@ -187,8 +187,8 @@ export function Taxonomy (http, data = {}) { * name: 'taxonomy testing', * description: 'Description for Taxonomy testing' * } - * client.stack({ api_key: 'api_key'}).taxonomy().create({taxonomy}) - * .then(taxonomy) => console.log(taxonomy) + * client.stack({ api_key: 'api_key'}).taxonomy().create({ taxonomy }) + * .then((taxonomy) => console.log(taxonomy)) * */ this.create = create({ http }) @@ -206,12 +206,12 @@ export function Taxonomy (http, data = {}) { * const client = contentstack.client() * * client.stack().taxonomy().query().find() - * .then((taxonomies) => console.log(taxonomies) + * .then((taxonomies) => console.log(taxonomies)) */ this.query = query({ http: http, wrapperCollection: TaxonomyCollection }) /** - * @description The 'Import taxonomy' import a single entry by uploading JSON or CSV files. + * @description The 'Import taxonomy' call imports a taxonomy by uploading JSON or CSV files. * @memberof Taxonomy * @func import * @param {String} data.taxonomy path to file diff --git a/lib/stack/taxonomy/terms/index.js b/lib/stack/taxonomy/terms/index.js index a35764ce..f90455dc 100644 --- a/lib/stack/taxonomy/terms/index.js +++ b/lib/stack/taxonomy/terms/index.js @@ -10,6 +10,10 @@ import { } from '../../../entity' import error from '../../../core/contentstackError' +/** + * Terms are individual items within a taxonomy that allow you to organize and categorize content. + * @namespace Terms + */ export function Terms (http, data) { this.stackHeaders = data.stackHeaders this.taxonomy_uid = data.taxonomy_uid @@ -20,7 +24,7 @@ export function Terms (http, data) { this.urlPath = `/taxonomies/${this.taxonomy_uid}/terms/${this.uid}` /** - * @description The Update terms call is used to update an existing term. + * @description The Update term call is used to update an existing term. * @memberof Terms * @func update * @returns {Promise} Promise for Terms instance @@ -39,10 +43,10 @@ export function Terms (http, data) { this.update = update(http, 'term') /** - * @description The Delete terms call is used to delete an existing term. + * @description The Delete term call is used to delete an existing term. * @memberof Terms * @func delete - * @returns {Promise} Response Object. + * @returns {Object} Response Object. * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client() @@ -54,7 +58,7 @@ export function Terms (http, data) { this.delete = deleteEntity(http) /** - * @description The Fetch terms call is used to fetch an existing term. + * @description The Fetch term call is used to fetch an existing term. * @memberof Terms * @func fetch * @returns {Promise} Promise for Terms instance @@ -72,7 +76,7 @@ export function Terms (http, data) { * @description The ancestors call is used to get all the ancestor terms of an existing term. * @memberof Terms * @func ancestors - * @returns {Promise} Promise for Terms instance + * @returns {Promise} Promise for ancestors data * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client() @@ -95,10 +99,10 @@ export function Terms (http, data) { } /** - * @description The move call is used to existing term. + * @description The descendants call gets all descendant terms of an existing term. * @memberof Terms * @func descendants - * @returns {Promise} Promise for Terms instance + * @returns {Promise} Promise for descendants data * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client() @@ -123,7 +127,7 @@ export function Terms (http, data) { /** * @description The move call is used to update the parent uid. * @memberof Terms - * @func anscestors + * @func move * @returns {Promise} Promise for Terms instance * @example * import * as contentstack from '@contentstack/management' @@ -180,7 +184,7 @@ export function Terms (http, data) { * import * as contentstack from '@contentstack/management' * const client = contentstack.client() * - * client.stack({ api_key: 'api_key'}).taxonomy('taxonomy_UID').terms('term_uid').localize({term: data}, {locale: 'hi-in'}) + * client.stack({ api_key: 'api_key'}).taxonomy('taxonomy_UID').terms('term_uid').localize({ term: data }, { locale: 'hi-in' }) * .then((term) => console.log(term)) * */ @@ -201,7 +205,7 @@ export function Terms (http, data) { } } else { /** - * @description The Create terms call is used to create a terms. + * @description The Create term call creates a new term in a taxonomy. * @memberof Terms * @func create * @returns {Promise} Promise for Terms instance @@ -213,26 +217,26 @@ export function Terms (http, data) { * name: 'terms testing', * description: 'Description for terms testing' * } - * client.stack({ api_key: 'api_key'}).terms().create({terms}) - * .then(terms) => console.log(terms) + * client.stack({ api_key: 'api_key'}).terms().create({ terms }) + * .then((terms) => console.log(terms)) * */ this.create = create({ http }) /** - * @description The Query on Terms will allow to fetch details of all Terms. + * @description The Query on Terms will allow you to fetch details of all Terms. * @memberof Terms * @param {Object} params - URI parameters * @prop {Object} params.query - Queries that you can use to fetch filtered results. * @func query - * @returns {Array} Array of Terms. + * @returns {Object} Query builder object with find(), count(), and findOne() methods. * * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client() * * client.stack().terms().query().find() - * .then((terms) => console.log(terms) + * .then((terms) => console.log(terms)) */ this.query = query({ http: http, wrapperCollection: TermsCollection }) } @@ -240,13 +244,13 @@ export function Terms (http, data) { * @description The Search terms call is used to search a term. * @memberof Terms * @func search - * @returns {Promise} Promise for Terms instance + * @returns {Promise} Promise for search results * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client() * const term_string = '' - * client.stack({ api_key: 'api_key'}).terms().search(term_string) - * .then(terms) => console.log(terms) + * client.stack({ api_key: 'api_key'}).taxonomy('taxonomy_uid').terms().search(term_string) + * .then((terms) => console.log(terms)) * */ this.search = async (term = '', params = {}) => { diff --git a/lib/stack/variantGroup/index.js b/lib/stack/variantGroup/index.js index 36e0f5be..50248d38 100644 --- a/lib/stack/variantGroup/index.js +++ b/lib/stack/variantGroup/index.js @@ -4,7 +4,7 @@ import { Variants } from './variants/index' import error from '../../core/contentstackError' /** - * Contentstack has a sophisticated multilingual capability. It allows you to create and publish entries in any language. This feature allows you to set up multilingual websites and cater to a wide variety of audience by serving content in their local language(s). Read more about VariantGroups. + * VariantGroups allow you to group a collection of variants within a stack. Using variant groups you can organize variants that need to work together. Read more about VariantGroups. * @namespace VariantGroup */ @@ -24,7 +24,7 @@ export function VariantGroup (http, data = {}) { * import * as contentstack from '@contentstack/management' * const client = contentstack.client() * const up_data = {name: 'update name'} - * client.stack({ api_key: 'api_key'}).VariantGroup('variant_group_uid').update(up_data) + * client.stack({ api_key: 'api_key'}).variantGroup('variant_group_uid').update(up_data) * .then((variant_group) => console.log(variant_group)) * */ @@ -55,21 +55,21 @@ export function VariantGroup (http, data = {}) { * import * as contentstack from '@contentstack/management' * const client = contentstack.client() * - * client.stack({ api_key: 'api_key'}).VariantGroup('variant_group_uid').delete() + * client.stack({ api_key: 'api_key'}).variantGroup('variant_group_uid').delete() * .then((response) => console.log(response.notice)) */ this.delete = deleteEntity(http) /** - * @description Content type defines the structure or schema of a page or a section of your web or mobile property. - * @param {String} uid The UID of the ContentType you want to get details. - * @returns {ContenType} Instace of ContentType. + * @description The variants method returns a Variants instance for managing variants within this variant group. + * @param {String} uid The UID of the variant you want to get details. + * @returns {Variants} Instance of Variants. * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client() * - * client.stack({ api_key: 'api_key'}).VariantGroup('variant_group_uid').variants('variant_uid').fetch() - * .then((Variants) => console.log(Variants)) + * client.stack({ api_key: 'api_key'}).variantGroup('variant_group_uid').variants('variant_uid').fetch() + * .then((variants) => console.log(variants)) */ this.variants = (uid = null) => { const data = { stackHeaders: this.stackHeaders } @@ -96,7 +96,7 @@ export function VariantGroup (http, data = {}) { * ], * "uid": "iphone_color_white", // optional * } - * client.stack().VariantGroup().create({ variant_group } ) + * client.stack().variantGroup().create({ variant_group }) * .then((variant_group) => console.log(variant_group)) */ this.create = async (data) => { @@ -119,17 +119,18 @@ export function VariantGroup (http, data = {}) { } /** - * @description The Query on Variant Groups will allow to fetch details of all or specific Variant Groups + * @description The Query on Variant Groups will allow to fetch details of all or specific Variant Groups. * @memberof VariantGroup * @func query - * @param {Boolean} include_count Set this to 'true' to include in response the total count of content types available in your stack. - * @returns {Array} Array of ContentTyoe. + * @param {Object} params - URI parameters + * @prop {Object} params.query - Queries that you can use to fetch filtered results for variant groups. + * @returns {Array} Array of VariantGroup. * * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client() * - * client.stack(api_key).VariantGroup().query({ query: { code: 'variant_group-code' } }).find() + * client.stack({ api_key: 'api_key' }).variantGroup().query({ query: { code: 'variant_group-code' } }).find() * .then((variant_groups) => console.log(variant_groups)) */ this.query = query({ http: http, wrapperCollection: VariantGroupCollection }) diff --git a/lib/stack/variantGroup/variants/index.js b/lib/stack/variantGroup/variants/index.js index 31cd2871..6fbad66e 100644 --- a/lib/stack/variantGroup/variants/index.js +++ b/lib/stack/variantGroup/variants/index.js @@ -3,7 +3,7 @@ import { query, deleteEntity } from '../../../entity' import error from '../../../core/contentstackError' /** - * Contentstack has a sophisticated multilingual capability. It allows you to create and publish entries in any language. This feature allows you to set up multilingual websites and cater to a wide variety of audience by serving content in their local language(s). Read more about VariantGroups. + * Variants within a variant group allow you to manage individual variants that belong to a specific variant group. Read more about Variants. * @namespace Variants */ @@ -24,7 +24,7 @@ export function Variants (http, data = {}) { * import * as contentstack from '@contentstack/management' * const client = contentstack.client() * const data = { "name": "Update name" } - * client.stack({ api_key: 'api_key'}).VariantGroup('variant_group_uid').variants('variant_uid').update(data) + * client.stack({ api_key: 'api_key'}).variantGroup('variant_group_uid').variants('variant_uid').update(data) * .then((variants) => console.log(variants)) * */ @@ -52,12 +52,12 @@ export function Variants (http, data = {}) { * @memberof Variants * @func fetch * @returns {Promise} Promise for Variants instance - * @param {Int} version Enter the unique ID of the content type of which you want to retrieve the details. The UID is generated based on the title of the content type. The unique ID of a content type is unique across a stack. + * @param {Object} param - Query parameters for fetching variant details * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client() * - * client.stack({ api_key: 'api_key'}).VariantGroup('variant_group_uid').variants('variant_uid').fetch() + * client.stack({ api_key: 'api_key'}).variantGroup('variant_group_uid').variants('variant_uid').fetch() * .then((variants) => console.log(variants)) * */ @@ -83,20 +83,20 @@ export function Variants (http, data = {}) { /** * @description The Delete Variant call is used to delete an existing Variant permanently from your Stack. - * @memberof VariantGroup + * @memberof Variants * @func delete * @returns {Object} Response Object. * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client() * - * client.stack({ api_key: 'api_key'}).VariantGroup('variant_group_uid').variants('variant_uid').delete() + * client.stack({ api_key: 'api_key'}).variantGroup('variant_group_uid').variants('variant_uid').delete() * .then((response) => console.log(response.notice)) */ this.delete = deleteEntity(http) } else { /** - * @description The Create a variant group call creates a new variant group in a particular stack of your Contentstack account. + * @description The Create a variant call creates a new variant in a particular variant group. * @memberof Variants * @func create * @returns {Promise} Promise for Variants instance @@ -114,7 +114,7 @@ export function Variants (http, data = {}) { * "variant_short_uid": "variantShort_uid1" * }, * } - * client.stack().VariantGroup('variant_group_uid').variants().create({ data } ) + * client.stack().variantGroup('variant_group_uid').variants().create({ data }) * .then((variants) => console.log(variants)) */ this.create = async (data) => { @@ -137,18 +137,19 @@ export function Variants (http, data = {}) { } /** - * @description The Query on Variant Groups will allow to fetch details of all or specific Variant Groups + * @description The Query on Variants will allow to fetch details of all or specific Variants. * @memberof Variants * @func query - * @param {Boolean} include_count Set this to 'true' to include in response the total count of content types available in your stack. - * @returns {Array} Array of ContentTyoe. + * @param {Object} params - URI parameters + * @prop {Object} params.query - Queries that you can use to fetch filtered results for variants. + * @returns {ContentstackCollection} Instance of ContentstackCollection. * * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client() - * client.stack(api_key).VariantGroup('variant_group_uid').variants().query({ query: { name: 'white' } }).find() - * .then((variant_groups) => console.log(variant_groups)) + * client.stack({ api_key: 'api_key' }).variantGroup('variant_group_uid').variants().query({ query: { name: 'white' } }).find() + * .then((variants) => console.log(variants)) */ this.query = query({ http: http, wrapperCollection: VariantsCollection }) } diff --git a/lib/stack/variants/index.js b/lib/stack/variants/index.js index f0171724..f87596fd 100644 --- a/lib/stack/variants/index.js +++ b/lib/stack/variants/index.js @@ -5,7 +5,7 @@ import { } from '../../entity' import error from '../../core/contentstackError' /** - * Variantss allow you to group a collection of content within a stack. Using variants you can group content types that need to work together. Read more about Variantss. + * Variants allow you to group a collection of content within a stack. Using variants you can group content types that need to work together. Read more about Variants. * @namespace Variants */ export function Variants (http, data) { @@ -17,7 +17,7 @@ export function Variants (http, data) { this.urlPath += `/${this.uid}` /** - * @description The Delete variants call is used to delete a specific variants. + * @description The Delete variant call is used to delete a specific variant. * @memberof Variants * @func delete * @returns {Object} Response Object. @@ -31,7 +31,7 @@ export function Variants (http, data) { this.delete = deleteEntity(http) /** - * @description The fetch Variants returns information about a particular variants of a stack. + * @description The fetch Variant returns information about a particular variant of a stack. * @memberof Variants * @func fetch * @returns {Promise} Promise for Variants instance @@ -64,7 +64,7 @@ export function Variants (http, data) { } } else { /** - * @description The Create an variants call creates a new variants. + * @description The Create a variant call creates a new variant in a particular stack of your Contentstack account. * @memberof Variants * @func create * @returns {Promise} Promise for Variants instance @@ -80,8 +80,8 @@ export function Variants (http, data) { * "experience_short_uid": "expShortUid1", * "project_uid": "project_uid1", * "variant_short_uid": "variantShort_uid1" - * }, * } + * } * client.stack().variants().create({ variants }) * .then((variants) => console.log(variants)) */ @@ -105,12 +105,12 @@ export function Variants (http, data) { } /** - * @description The Query on Variants will allow to fetch details of all or specific Variants. + * @description The Query on Variants will allow you to fetch details of all or specific Variants. * @memberof Variants * @param {Object} params - URI parameters * @prop {Object} params.query - Queries that you can use to fetch filtered results. * @func query - * @returns {Array} Array of Variants. + * @returns {Object} Query builder object with find(), count(), and findOne() methods. * * @example * import * as contentstack from '@contentstack/management' @@ -122,19 +122,18 @@ export function Variants (http, data) { this.query = query({ http: http, wrapperCollection: VariantsCollection }) /** - * @description The fetchByUIDs on Variants will allow to fetch details of specific Variants UID. + * @description The fetchByUIDs call allows you to fetch details of specific Variants by their UIDs. * @memberof Variants - * @param {Object} params - URI parameters - * @prop {Object} params.query - fetchByUIDs that you can use to fetch filtered results. - * @func query - * @returns {Array} Array of Variants. + * @param {Array} variantUids - Array of variant UIDs to fetch + * @func fetchByUIDs + * @returns {Promise} Promise for variants data * * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client() * - * client.stack().variants().fetchByUIDs(['uid1','uid2']).find() - * .then((variants) => console.log(variants)) + * client.stack().variants().fetchByUIDs(['uid1','uid2']) + * .then((variants) => console.log(variants)) */ this.fetchByUIDs = async (variantUids) => { try { diff --git a/lib/stack/webhook/index.js b/lib/stack/webhook/index.js index c04f67f4..3d2834f6 100644 --- a/lib/stack/webhook/index.js +++ b/lib/stack/webhook/index.js @@ -63,7 +63,8 @@ export function Webhook (http, data = {}) { * @memberof Webhook * @func fetch * @returns {Promise} Promise for Webhook instance - * @param {Int} version Enter the unique ID of the content type of which you want to retrieve the details. The UID is generated based on the title of the content type. The unique ID of a content type is unique across a stack. + * @param {Object=} param - Query parameters + * @prop {Int} param.version - Enter the version number of the webhook you want to retrieve. * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client() @@ -75,11 +76,14 @@ export function Webhook (http, data = {}) { this.fetch = fetch(http, 'webhook') /** - * @description The Get executions of a webhook call will provide the execution details of a specific webhook, which includes the execution UID. + * @description The Get executions of a webhook call provides the execution details of a specific webhook, which includes the execution UID. * @memberof Webhook - * @returns {Promise} JSON response for webhook execution * @func executions - * @param {*} param.skip - to skip number of data + * @async + * @param {Object=} params - Query parameters. + * @prop {Number=} params.skip - To skip number of data. + * @prop {Number=} params.limit - To limit number of results. + * @returns {Promise} Response object for webhook execution * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client() @@ -110,8 +114,12 @@ export function Webhook (http, data = {}) { } /** - * + * @description The Retry webhook execution call retries a failed webhook execution. + * @memberof Webhook + * @func retry + * @async * @param {String} executionUid execution UID that you receive when you execute the 'Get executions of webhooks' call. + * @returns {Promise} Response Object. */ this.retry = async (executionUid) => { const headers = {} @@ -165,12 +173,13 @@ export function Webhook (http, data = {}) { * @description The Get all Webhook call lists all Webhooks from Stack. * @memberof Webhook * @func fetchAll - * @param {Int} limit The limit parameter will return a specific number of webhooks in the output. - * @param {Int} skip The skip parameter will skip a specific number of webhooks in the output. - * @param {String} asc When fetching webhooks, you can sort them in the ascending order with respect to the value of a specific field in the response body. - * @param {String} desc When fetching webhooks, you can sort them in the decending order with respect to the value of a specific field in the response body. - * @param {Boolean}include_count To retrieve the count of webhooks. - * @returns {ContentstackCollection} Result collection of content of specified module. + * @param {Object=} param - Query parameters. + * @prop {Number=} param.limit - The limit parameter will return a specific number of webhooks in the output. + * @prop {Number=} param.skip - The skip parameter will skip a specific number of webhooks in the output. + * @prop {String=} param.asc - When fetching webhooks, you can sort them in the ascending order with respect to the value of a specific field in the response body. + * @prop {String=} param.desc - When fetching webhooks, you can sort them in the descending order with respect to the value of a specific field in the response body. + * @prop {Boolean=} param.include_count - To retrieve the count of webhooks. + * @returns {Promise} Promise for ContentstackCollection instance. * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client() @@ -186,13 +195,16 @@ export function Webhook (http, data = {}) { * @description The 'Import Webhook' section consists of the following two requests that will help you to import new Webhooks or update existing ones by uploading JSON files. * @memberof Webhook * @func import - * @param {String} data.webhook path to file + * @async + * @param {Object} data - Import data object. + * @prop {string} data.webhook - Path to webhook file. + * @returns {Promise} Promise for Webhook instance * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client() * * const data = { - * webhook: 'path/to/file.png', + * webhook: 'path/to/file.json', * } * // Import a Webhook * client.stack({ api_key: 'api_key'}).webhook().import(data) diff --git a/lib/stack/workflow/index.js b/lib/stack/workflow/index.js index 7eb48a08..901631e7 100644 --- a/lib/stack/workflow/index.js +++ b/lib/stack/workflow/index.js @@ -135,7 +135,7 @@ export function Workflow (http, data = {}) { this.contentType = (contentTypeUID) => { if (contentTypeUID) { /** - * @description The Delete Workflow call is used to delete an existing Workflow permanently from your Stack. + * @description The Get Publish Rules call retrieves publish rules for a content type. * @memberof Workflow * @func getPublishRules * @returns {Object} Returns Object. @@ -188,30 +188,32 @@ export function Workflow (http, data = {}) { * const client = contentstack.client() * * const workflow = { - *"workflow_stages": [ - * { - * "color": "#2196f3", - * "SYS_ACL": { - * "roles": { - * "uids": [] - * }, - * "users": { - * "uids": [ + * workflow_stages: [ + * { + * color: "#2196f3", + * SYS_ACL: { + * roles: { + * uids: [] + * }, + * users: { + * uids: [ * "$all" * ] * }, - * "others": {} + * others: {} * }, - * "next_available_stages": [ + * next_available_stages: [ * "$all" * ], - * "allStages": true, - * "allUsers": true, - * "specificStages": false, - * "specificUsers": false, - * "entry_lock": "$none", //assign any one of the assign any one of the ($none/$others/$all) - * "name": "Review" - * }, + * allStages: true, + * allUsers: true, + * specificStages: false, + * specificUsers: false, + * entry_lock: "$none", + * name: "Review" + * } + * ] + * } * { * "color": "#74ba76", * "SYS_ACL": { @@ -256,7 +258,7 @@ export function Workflow (http, data = {}) { * @func fetchAll * @param {Int} limit The limit parameter will return a specific number of Workflows in the output. * @param {Int} skip The skip parameter will skip a specific number of Workflows in the output. - * @param {Boolean}include_count To retrieve the count of Workflows. + * @param {Boolean} include_count - To retrieve the count of Workflows. * @returns {ContentstackCollection} Result collection of content of specified module. * @example * import * as contentstack from '@contentstack/management' @@ -273,7 +275,7 @@ export function Workflow (http, data = {}) { * @memberof Workflow * @func publishRule * @param {Int} ruleUid The UID of the Publish rules you want to get details. - * @returns {PublishRules} Instace of PublishRules. + * @returns {PublishRules} Instance of PublishRules. * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client() diff --git a/lib/stack/workflow/publishRules/index.js b/lib/stack/workflow/publishRules/index.js index 4bc2341e..0ad2eb71 100644 --- a/lib/stack/workflow/publishRules/index.js +++ b/lib/stack/workflow/publishRules/index.js @@ -8,7 +8,7 @@ import { } from '../../../entity' /** - * PublishRules 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. Read more about PublishRuless and Publish Rules. + * PublishRules 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. Read more about PublishRules and Publish Rules. * @namespace PublishRules */ @@ -22,7 +22,7 @@ export function PublishRules (http, data = {}) { /** * @description The Update Publish Rules request allows you to add a publish rules stage or update the details of the existing stages of a publish rules. - * @memberof Publish Rules + * @memberof PublishRules * @func update * @returns {Promise} Promise for Publish Rules instance * @example @@ -42,7 +42,7 @@ export function PublishRules (http, data = {}) { /** * @description The Delete Publish Rules call is used to delete an existing Publish Rules permanently from your Stack. - * @memberof Publish Rules + * @memberof PublishRules * @func delete * @returns {Object} Response Object. * @example @@ -56,7 +56,7 @@ export function PublishRules (http, data = {}) { /** * @description The fetch publish rules retrieves the comprehensive details of a specific Publish Rules of a stack. - * @memberof Publish Rules + * @memberof PublishRules * @func fetch * @returns {Promise} Promise for Publish Rules instance * @example @@ -70,7 +70,7 @@ export function PublishRules (http, data = {}) { this.fetch = fetch(http, 'publishing_rule') } else { /** - * @description The Create Publish Rules request allows you to create publish rules for the publish rules of a stack. + * @description The Create Publish Rules request allows you to create publish rules for a stack. * @memberof PublishRules * @func create * @returns {Promise} Promise for PublishRules instance @@ -86,8 +86,8 @@ export function PublishRules (http, data = {}) { * "environment": "environment_uid", * "approvers": { * "users": ["user_uid"], - * "roles": ["role_uid"] - * "publish rules_stage": "publish rules_stage_uid", + * "roles": ["role_uid"], + * "publish_rules_stage": "publish_rules_stage_uid", * "disable_approver_publishing": false * } * client.stack().publishRules().create({ publishing_rule }) @@ -97,12 +97,12 @@ export function PublishRules (http, data = {}) { /** * @description The Get all Publish Rules request retrieves the details of all the Publish rules of a workflow. - * @memberof Publish Rules + * @memberof PublishRules * @func fetchAll * @param {String} content_types Enter a comma-separated list of content type UIDs for filtering publish rules on its basis. * @param {Int} limit The limit parameter will return a specific number of Publish Rules in the output. * @param {Int} skip The skip parameter will skip a specific number of Publish Rules in the output. - * @param {Boolean}include_count To retrieve the count of Publish Rules. + * @param {Boolean} include_count To retrieve the count of Publish Rules. * @returns {ContentstackCollection} Result collection of content of specified module. * @example * import * as contentstack from '@contentstack/management' diff --git a/lib/user/index.js b/lib/user/index.js index 980d72d4..aa527ee4 100644 --- a/lib/user/index.js +++ b/lib/user/index.js @@ -25,7 +25,7 @@ export function User (http, data) { * .then((user) => { * user.first_name = 'FirstName' * user.last_name = 'LastName' - * user.company = 'Role description' + * user.company = 'Company Name' * return user.update() * }) * .then((user) => console.log(user)) @@ -76,6 +76,10 @@ export function User (http, data) { * @description The Reset password call sends a request for resetting the password of your Contentstack account. * @memberof User * @func resetPassword + * @param {Object} credentials - Password reset credentials. + * @prop {string} credentials.resetPasswordToken - Reset password token. + * @prop {string} credentials.password - New password. + * @prop {string} credentials.passwordConfirm - Password confirmation. * @returns {Object} Response Object. * @example * import * as contentstack from '@contentstack/management' @@ -83,18 +87,18 @@ export function User (http, data) { * * client.stack({ api_key: 'api_key'}).getUser() * .then((user) => { - * return user.resetPassword({ 'resetToken', 'new_password', 'new_password' }) + * return user.resetPassword({ resetPasswordToken: 'token', password: 'new_password', passwordConfirm: 'new_password' }) * }) * .then((response) => console.log(response.notice)) * */ this.resetPassword = function ({ resetPasswordToken, password, passwordConfirm }) { - return http.post('/user/reset_password', { user: - { - reset_password_token: resetPasswordToken, - password: password, - password_confirmation: passwordConfirm - } + return http.post('/user/reset_password', { + user: { + reset_password_token: resetPasswordToken, + password: password, + password_confirmation: passwordConfirm + } }) .then((response) => { return response.data @@ -109,11 +113,13 @@ export function User (http, data) { * @description The Get all Tasks request retrieves a list of all tasks assigned to you. * @memberof User * @func getTasks - * @param {Object} query Enter the actual query that will be executed to retrieve the tasks. This query should be in JSON format. - * @param {Object} sort Enter the field UID on the basis of which you want to sort your tasks. - * @param {Int} limit Enter the maximum number of tasks that you want to retrieve in the response. - * @param {Int} skip Enter the number of tasks to be skipped. - * @returns {Object} Response Object. + * @async + * @param {Object} params - Query parameters + * @prop {Object} params.query - Enter the actual query that will be executed to retrieve the tasks. This query should be in JSON format. + * @prop {Object} params.sort - Enter the field UID on the basis of which you want to sort your tasks. + * @prop {Int} params.limit - Enter the maximum number of tasks that you want to retrieve in the response. + * @prop {Int} params.skip - Enter the number of tasks to be skipped. + * @returns {Promise} Response Object. * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client() From 3360ccef86fc202c8c24a345f843d512d9cbc2f9 Mon Sep 17 00:00:00 2001 From: raj pandey Date: Tue, 25 Nov 2025 14:49:21 +0530 Subject: [PATCH 02/13] Fixed the other modules jsdoc --- lib/organization/teams/index.js | 40 +++++++++------- .../teams/stackRoleMappings/index.js | 13 +++--- lib/organization/teams/teamUsers/index.js | 8 ++-- lib/query/index.js | 9 ++-- lib/stack/asset/folders/index.js | 16 +++---- lib/stack/asset/index.js | 32 +++++++------ lib/stack/auditlog/index.js | 8 ++-- lib/stack/branch/compare.js | 6 +-- lib/stack/branch/index.js | 13 +++--- lib/stack/branch/mergeQueue.js | 4 +- lib/stack/bulkOperation/index.js | 4 +- lib/stack/contentType/index.js | 39 ++++++++++------ lib/stack/index.js | 46 +++++++++++-------- 13 files changed, 135 insertions(+), 103 deletions(-) diff --git a/lib/organization/teams/index.js b/lib/organization/teams/index.js index 1c2fa066..b978393c 100644 --- a/lib/organization/teams/index.js +++ b/lib/organization/teams/index.js @@ -18,10 +18,16 @@ export function Teams (http, data) { this.urlPath = `/organizations/${this.organizationUid}/teams/${this.uid}` /** - * @description The update call on team will allow to update details of team. + * @description The update call allows you to update details of a team. * @memberof Teams * @func update - * @returns {Promise} Response Object. + * @async + * @param {Object} updateData - Team update data. + * @prop {string} updateData.name - Team name. + * @prop {Array} updateData.users - Array of user objects with email property. + * @prop {string} updateData.organizationRole - Organization role UID. + * @prop {Array} updateData.stackRoleMapping - Stack role mappings. + * @returns {Promise} Response Object. * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client() @@ -35,7 +41,7 @@ export function Teams (http, data) { * organizationRole: 'blt09e5dfced326aaea', * stackRoleMapping: [] * } - * client.organization(s'organizationUid').teams('teamUid').update(updateData) + * client.organization('organizationUid').teams('teamUid').update(updateData) * .then((response) => console.log(response)) * */ @@ -51,10 +57,10 @@ export function Teams (http, data) { } /** - * @description The delete call on team will delete the existing team. + * @description The delete call deletes an existing team. * @memberof Teams * @func delete - * @returns {Promise} Response Object. + * @returns {Promise} Response Object. * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client() @@ -65,10 +71,10 @@ export function Teams (http, data) { this.delete = deleteEntity(http) /** - * @description The fetch call on team will delete the existing team. + * @description The fetch call fetches the existing team details. * @memberof Teams * @func fetch - * @returns {Promise} Response Object. + * @returns {Promise} Promise for Teams instance * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client() @@ -79,10 +85,10 @@ export function Teams (http, data) { this.fetch = fetch(http, 'team') /** - * @description The users call on team will get users details. + * @description The teamUsers call returns a TeamUsers instance for managing team users. * @memberof Teams - * @func users - * @returns {Promise} Response Object. + * @func teamUsers + * @returns {TeamUsers} Instance of TeamUsers. * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client() @@ -100,10 +106,10 @@ export function Teams (http, data) { } /** - * @description The stackRoleMappings call on team will get the stack role Mapping. + * @description The stackRoleMappings call returns a StackRoleMappings instance for managing stack role mappings. * @memberof Teams - * @func users - * @returns {Promise} Response Object. + * @func stackRoleMappings + * @returns {StackRoleMappings} Instance of StackRoleMappings. * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client() @@ -121,10 +127,10 @@ export function Teams (http, data) { } } else { /** - * @description The fetch call on team will delete the existing team. + * @description The create call creates a new team. * @memberof Teams * @func create - * @returns {Promise} Response Object. + * @returns {Promise} Promise for Teams instance * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client() @@ -142,10 +148,10 @@ export function Teams (http, data) { this.create = create({ http }) /** - * @description The fetchAll on team will allow to fetch details of all teams. + * @description The fetchAll call allows you to fetch details of all teams. * @memberof Teams * @func fetchAll - * @returns {Promise} Response Object. + * @returns {Promise} Promise for ContentstackCollection instance. * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client() diff --git a/lib/organization/teams/stackRoleMappings/index.js b/lib/organization/teams/stackRoleMappings/index.js index 235bc996..b2302cca 100644 --- a/lib/organization/teams/stackRoleMappings/index.js +++ b/lib/organization/teams/stackRoleMappings/index.js @@ -17,7 +17,8 @@ export function StackRoleMappings (http, data) { * @description The update stackRoleMappings call is used to update the roles. * @memberof StackRoleMappings * @func update - * @returns {Promise} Response Object. + * @param {Object} updateData - The data to update stack role mappings + * @returns {Promise} Response Object. * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client() @@ -45,7 +46,7 @@ export function StackRoleMappings (http, data) { * @description The delete stackRoleMappings call is used to delete the roles. * @memberof StackRoleMappings * @func delete - * @returns {Promise} Response Object. + * @returns {Promise} Response Object. * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client() @@ -60,13 +61,13 @@ export function StackRoleMappings (http, data) { * @description The add stackRoleMappings call is used to add the roles. * @memberof StackRoleMappings * @func add - * @returns {Promise} Response Object. + * @returns {Promise} Response Object. * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client() * * const addRole = { - * 'stackApiKey: 'stackApiKey', + * 'stackApiKey': 'stackApiKey', * 'roles': [ * 'role_uid' * ] @@ -89,12 +90,12 @@ export function StackRoleMappings (http, data) { * @description The fetchAll stackRoleMappings call is used to fetchAll the roles. * @memberof StackRoleMappings * @func fetchAll - * @returns {Promise} Response Object. + * @returns {Promise} Response Object. * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client() * - * client.organization('organizationUid').teams('teamUid').stackRoleMappings().fetchAll + * client.organization('organizationUid').teams('teamUid').stackRoleMappings().fetchAll() * .then((response) => console.log(response)) */ this.fetchAll = async () => { diff --git a/lib/organization/teams/teamUsers/index.js b/lib/organization/teams/teamUsers/index.js index 77bcfa9f..6eec7548 100644 --- a/lib/organization/teams/teamUsers/index.js +++ b/lib/organization/teams/teamUsers/index.js @@ -16,7 +16,7 @@ export function TeamUsers (http, data) { * @description The Remove teamUser call is used to remove an existing user of that team. * @memberof TeamUsers * @func remove - * @returns {Promise} Response Object. + * @returns {Promise} Response Object. * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client() @@ -33,7 +33,7 @@ export function TeamUsers (http, data) { * @description The Add teamUser call is used to add a user to the team. * @memberof TeamUsers * @func add - * @returns {Promise} Promise for TeamUsers instance + * @returns {Promise} Response Object. * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client() @@ -47,10 +47,10 @@ export function TeamUsers (http, data) { this.add = create({ http }) /** - * @description The fetchAll on teamUser will allow to fetch details of all teamUsers. + * @description The fetchAll call allows you to fetch details of all team users. * @memberof TeamUsers * @func fetchAll - * @returns {ContentstackCollection} Instance of ContentstackCollection. + * @returns {Promise} Promise for ContentstackCollection instance. * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client() diff --git a/lib/query/index.js b/lib/query/index.js index 45b48ed1..ce0d890f 100644 --- a/lib/query/index.js +++ b/lib/query/index.js @@ -19,7 +19,8 @@ export default function Query (http, urlPath, param, stackHeaders = null, wrappe } /** * @description This method will fetch content of query on specified module. - * @returns {ContentstackCollection} Result collection of content of specified module. + * @async + * @returns {Promise} Promise for ContentstackCollection instance. * @example All Stack * import * as contentstack from '@contentstack/management' * const client = contentstack.client() @@ -52,7 +53,8 @@ export default function Query (http, urlPath, param, stackHeaders = null, wrappe } /** * @description This method will fetch count of content for query on specified module. - * @returns {Object} Result is Object of content of specified module. + * @async + * @returns {Promise} Promise for count result. * @example All Stack * import * as contentstack from '@contentstack/management' * const client = contentstack.client() @@ -86,7 +88,8 @@ export default function Query (http, urlPath, param, stackHeaders = null, wrappe } /** * @description This method will fetch content of query on specified module. - * @returns {ContentstackCollection} Result content of specified module. + * @async + * @returns {Promise} Promise for ContentstackCollection instance. * @example Stack * import * as contentstack from '@contentstack/management' * const client = contentstack.client() diff --git a/lib/stack/asset/folders/index.js b/lib/stack/asset/folders/index.js index 2e11536d..048ebac9 100644 --- a/lib/stack/asset/folders/index.js +++ b/lib/stack/asset/folders/index.js @@ -25,7 +25,7 @@ export function Folder (http, data = {}) { * @description The Update Folder call lets you update the name and description of an existing Folder. * @memberof Folder * @func update - * @returns {Promise} Promise for Folder instance + * @returns {Promise} Promise for Folder instance * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client() @@ -41,10 +41,10 @@ export function Folder (http, data = {}) { this.update = update(http, 'asset') /** - * @description The Delete folder call will delete an existing folder from the stack. + * @description The Delete folder call deletes an existing folder from the stack. * @memberof Folder * @func delete - * @returns {Object} Response Object. + * @returns {Promise} Response Object. * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client() @@ -55,10 +55,10 @@ export function Folder (http, data = {}) { this.delete = deleteEntity(http) /** - * @description The fetch an asset call returns comprehensive information about a specific version of an asset of a stack. + * @description The fetch folder call returns comprehensive information about a specific folder. * @memberof Folder * @func fetch - * @returns {Promise} Promise for Folder instance + * @returns {Promise} Promise for Folder instance * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client() @@ -70,15 +70,15 @@ export function Folder (http, data = {}) { this.fetch = fetch(http, 'asset') } else { /** - * @description The Create a folder into the assets. + * @description The Create a folder call creates a new folder in the assets. * @memberof Folder * @func create - * @returns {Promise} Promise for Folder instance + * @returns {Promise} Promise for Folder instance * * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client() - * const asset = {name: 'My New contentType'} + * const asset = {name: 'My New Folder'} * client.stack().asset().folder().create({ asset }) * .then((folder) => console.log(folder)) */ diff --git a/lib/stack/asset/index.js b/lib/stack/asset/index.js index 0cbcb519..69e81484 100644 --- a/lib/stack/asset/index.js +++ b/lib/stack/asset/index.js @@ -31,7 +31,7 @@ export function Asset (http, data = {}) { * @description The Update Asset call lets you update the name and description of an existing Asset. * @memberof Asset * @func update - * @returns {Promise} Promise for Asset instance + * @returns {Promise} Promise for Asset instance * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client() @@ -48,10 +48,10 @@ export function Asset (http, data = {}) { this.update = update(http, 'asset') /** - * @description The Delete asset call will delete an existing asset from the stack. + * @description The Delete asset call deletes an existing asset from the stack. * @memberof Asset * @func delete - * @returns {Object} Response Object. + * @returns {Promise} Response Object. * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client() @@ -65,7 +65,7 @@ export function Asset (http, data = {}) { * @description The fetch an asset call returns comprehensive information about a specific version of an asset of a stack. * @memberof Asset * @func fetch - * @returns {Promise} Promise for Asset instance + * @returns {Promise} Promise for Asset instance * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client() @@ -80,7 +80,8 @@ export function Asset (http, data = {}) { * @description The Replace asset call will replace an existing asset with another file on the stack. * @memberof Asset * @func replace - * @returns {Promise} Promise for Asset instance + * @async + * @returns {Promise} Promise for Asset instance * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client() @@ -130,7 +131,7 @@ export function Asset (http, data = {}) { this.publish = publish(http, 'asset') /** - * @description The Replace asset call will replace an existing asset with another file on the stack. + * @description The Unpublish an asset call is used to unpublish a specific version of an asset from the desired environment either immediately or at a later date/time. * @memberof Asset * @func unpublish * @returns {Promise} Response Object. @@ -156,8 +157,9 @@ export function Asset (http, data = {}) { /** * @description The References function will get all the references for the asset. * @memberof Asset - * @func references - * @returns {Promise} Array of references. + * @func getReferences + * @async + * @returns {Promise} Promise for references data. * @param {Object} param - Query parameters * @example * client.stack({ api_key: 'api_key'}).asset('uid').getReferences({ include_publish_details: true }) @@ -183,10 +185,10 @@ export function Asset (http, data = {}) { } } else { /** - * @description The Folder allows to fetch and create folders in assets. + * @description The Folder method allows you to fetch and create folders in assets. * @memberof Asset * @func folder - * @returns {Promise} Promise for Entry instance + * @returns {Folder} Instance of Folder. * * @example * import * as contentstack from '@contentstack/management' @@ -207,7 +209,8 @@ export function Asset (http, data = {}) { * @description The Create an asset call creates a new asset. * @memberof Asset * @func create - * @returns {Promise} Promise for Asset instance + * @async + * @returns {Promise} Promise for Asset instance * * @example * import * as contentstack from '@contentstack/management' @@ -235,12 +238,12 @@ export function Asset (http, data = {}) { } } /** - * @description The Query on Asset will allow to fetch details of all or specific Asset. + * @description The Query on Asset will allow you to fetch details of all or specific Assets. * @memberof Asset * @param {Object} params - URI parameters * @prop {Object} params.query - Queries that you can use to fetch filtered results. * @func query - * @returns {Array} Array of Asset. + * @returns {Object} Query builder object with find(), count(), and findOne() methods. * * @example * import * as contentstack from '@contentstack/management' @@ -255,7 +258,8 @@ export function Asset (http, data = {}) { * @description The Download function will get downloadable file in specified format. * @memberof Asset * @func download - * @returns {Array} Array of Asset. + * @async + * @returns {Promise} Promise for download response. * @param {*} param.url The url for the asset to download * @param {*} param.responseType Optional parameter to specify the response type. * @example diff --git a/lib/stack/auditlog/index.js b/lib/stack/auditlog/index.js index 1ec9a437..e2ffa04f 100644 --- a/lib/stack/auditlog/index.js +++ b/lib/stack/auditlog/index.js @@ -17,7 +17,7 @@ export function AuditLog (http, data = {}) { * @description The fetch AuditLog call fetches AuditLog details. * @memberof AuditLog * @func fetch - * @returns {Promise} Promise for AuditLog instance + * @returns {Promise} Promise for AuditLog data * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client() @@ -49,10 +49,10 @@ export function AuditLog (http, data = {}) { * @description The Get all AuditLog request retrieves the details of all the AuditLog entries of a stack. * @memberof AuditLog * @func fetchAll - * @param {Int} limit The limit parameter will return a specific number of AuditLog entries in the output. - * @param {Int} skip The skip parameter will skip a specific number of AuditLog entries in the output. + * @param {Number} limit The limit parameter will return a specific number of AuditLog entries in the output. + * @param {Number} skip The skip parameter will skip a specific number of AuditLog entries in the output. * @param {Boolean} include_count - To retrieve the count of AuditLog entries. - * @returns {ContentstackCollection} Result collection of content of specified module. + * @returns {Promise} Promise for ContentstackCollection instance. * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client() diff --git a/lib/stack/branch/compare.js b/lib/stack/branch/compare.js index df0f29e9..640a9f32 100644 --- a/lib/stack/branch/compare.js +++ b/lib/stack/branch/compare.js @@ -12,7 +12,7 @@ export function Compare (http, data = {}) { * @description List of content types and global fields that exist in only one branch or are different between the two branches. * @memberof Compare * @func all - * @returns {Promise} Promise for response. + * @returns {Promise} Promise for comparison data. * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client() @@ -31,7 +31,7 @@ export function Compare (http, data = {}) { * @memberof Compare * @func contentTypes * @param {string} params.uid Optional uid for Content Type to compare. - * @returns {Promise} Promise for response. + * @returns {Promise} Promise for comparison data. * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client() @@ -55,7 +55,7 @@ export function Compare (http, data = {}) { * @memberof Compare * @func globalFields * @param {string} params.uid Optional uid for Global Field to compare. - * @returns {Promise} Promise for response. + * @returns {Promise} Promise for comparison data. * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client() diff --git a/lib/stack/branch/index.js b/lib/stack/branch/index.js index 80e1cdb1..4cec755a 100644 --- a/lib/stack/branch/index.js +++ b/lib/stack/branch/index.js @@ -23,7 +23,7 @@ export function Branch (http, data = {}) { * @description The Delete Branch call is used to delete an existing Branch permanently from your Stack. * @memberof Branch * @func delete - * @returns {Object} Response Object. + * @returns {Promise} Response Object. * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client() @@ -37,7 +37,7 @@ export function Branch (http, data = {}) { * @description The fetch Branch call fetches Branch details. * @memberof Branch * @func fetch - * @returns {Promise} Promise for Branch instance + * @returns {Promise} Promise for Branch instance * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client() @@ -75,7 +75,7 @@ export function Branch (http, data = {}) { * @description The Create a Branch call creates a new branch in a particular stack of your Contentstack account. * @memberof Branch * @func create - * @returns {Promise} Promise for Branch instance + * @returns {Promise} Promise for Branch instance * * @example * import * as contentstack from '@contentstack/management' @@ -90,10 +90,10 @@ export function Branch (http, data = {}) { this.create = create({ http: http }) /** - * @description The 'Get all Branch' request returns comprehensive information about branch created in a Stack. + * @description The 'Get all Branch' request returns comprehensive information about branches created in a Stack. * @memberof Branch * @func query - * @returns {Promise} Promise for ContentstackCollection instance + * @returns {Object} Query builder object with find(), count(), and findOne() methods. * * @example * import * as contentstack from '@contentstack/management' @@ -108,7 +108,8 @@ export function Branch (http, data = {}) { * @description Merge allows user to merge branches in a Stack. * @memberof Branch * @func merge - * @returns {Object} Response Object + * @async + * @returns {Promise} Response Object. * * @example * import * as contentstack from '@contentstack/management' diff --git a/lib/stack/branch/mergeQueue.js b/lib/stack/branch/mergeQueue.js index 7851405c..31db03f6 100644 --- a/lib/stack/branch/mergeQueue.js +++ b/lib/stack/branch/mergeQueue.js @@ -9,7 +9,7 @@ export function MergeQueue (http, data = {}) { * @description Fetch function gets the status of a merge job and it's configuration details. * @memberof MergeQueue * @func fetch - * @returns {Promise} Promise for response. + * @returns {Promise} Promise for merge queue data. * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client() @@ -28,7 +28,7 @@ export function MergeQueue (http, data = {}) { * @description Find function lists all recent merge jobs. * @memberof MergeQueue * @func find - * @returns {Promise} Promise for response. + * @returns {Promise} Promise for merge queue data. * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client() diff --git a/lib/stack/bulkOperation/index.js b/lib/stack/bulkOperation/index.js index 175591e2..27a6fbf6 100644 --- a/lib/stack/bulkOperation/index.js +++ b/lib/stack/bulkOperation/index.js @@ -326,8 +326,8 @@ export function BulkOperation (http, data = {}) { * The Delete entries and assets in bulk request allows you to delete multiple entries and assets at the same time. * @memberof BulkOperation * @func delete - * @returns {Promise} Success message * @param {Object} params.details - Set this with details specifying the content type UIDs, entry UIDs or asset UIDs, and locales of which the entries or assets you want to delete. + * @returns {Promise} Response Object. * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client() @@ -365,8 +365,8 @@ export function BulkOperation (http, data = {}) { * The Update workflow stage for entries in bulk request allows you to update workflow stages for multiple entries at the same time. * @memberof BulkOperation * @func update - * @returns {Promise} Success message * @param {Object} updateBody - Set this with details specifying the content type UIDs, entry UIDs or asset UIDs, and locales of which the entries or assets you want to update. + * @returns {Promise} Response Object. * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client() diff --git a/lib/stack/contentType/index.js b/lib/stack/contentType/index.js index 00d9acec..aaa2b0e5 100644 --- a/lib/stack/contentType/index.js +++ b/lib/stack/contentType/index.js @@ -30,7 +30,7 @@ export function ContentType (http, data = {}) { * You can also update the JSON schema of a content type, including fields and different features associated with the content type. * @memberof ContentType * @func update - * @returns {Promise} Promise for ContentType instance + * @returns {Promise} Promise for ContentType instance * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client() @@ -50,8 +50,10 @@ export function ContentType (http, data = {}) { * @description The Update ContentType call lets you update the name and description of an existing ContentType. * You can also update the JSON schema of a content type, including fields and different features associated with the content type. * @memberof ContentType - * @func update - * @returns {Promise} Promise for ContentType instance + * @func updateCT + * @async + * @param {Object} config - Content type configuration object containing the content_type object with updated fields. + * @returns {Promise} Response Object. * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client() @@ -86,8 +88,8 @@ export function ContentType (http, data = {}) { * } * } * client.stack({ api_key: 'api_key'}).contentType('content_type_uid').updateCT(data) - * .then((contentType) => { - console.log(contentType) + * .then((response) => { + * console.log(response) * }) */ this.updateCT = async (config) => { @@ -110,7 +112,7 @@ export function ContentType (http, data = {}) { * @description The Delete ContentType call is used to delete an existing ContentType permanently from your Stack. * @memberof ContentType * @func delete - * @returns {Object} Response Object. + * @returns {Promise} Response Object. * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client() @@ -124,7 +126,7 @@ export function ContentType (http, data = {}) { * @description The fetch ContentType call fetches ContentType details. * @memberof ContentType * @func fetch - * @returns {Promise} Promise for ContentType instance + * @returns {Promise} Promise for ContentType instance * @param {Object=} param - Query parameters * @prop {Int} param.version - Enter the version number of the content type you want to retrieve. * @example @@ -138,15 +140,17 @@ export function ContentType (http, data = {}) { this.fetch = fetch(http, 'content_type') /** - * @description Content type defines the structure or schema of a page or a section of your web or mobile property. - * @param {String} uid - The UID of the ContentType you want to get details. + * @description Entry defines the actual piece of content created using one of the defined content types. + * @param {String=} uid - The UID of the Entry you want to get details. + * @param {Object} options - Optional configuration object. + * @prop {string} options.api_version - API version to use for the request. * @returns {Entry} Instance of Entry. * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client() * * client.stack({ api_key: 'api_key'}).contentType('content_type_uid').entry('entry_uid').fetch() - * .then((contentType) => console.log(contentType)) + * .then((entry) => console.log(entry)) */ this.entry = (uid = null, options = {}) => { const data = { stackHeaders: this.stackHeaders } @@ -163,7 +167,8 @@ export function ContentType (http, data = {}) { /** * @description References call will fetch all the content types in which a specified content type is referenced. - * @returns {Promise} Promise for ContenttypeReferences + * @async + * @returns {Promise} Promise for ContentType references * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client() @@ -218,7 +223,7 @@ export function ContentType (http, data = {}) { * @description The Create a content type call creates a new content type in a particular stack of your Contentstack account. * @memberof ContentType * @func create - * @returns {Promise} Promise for ContentType instance + * @returns {Promise} Promise for ContentType instance * * @example * import * as contentstack from '@contentstack/management' @@ -230,11 +235,11 @@ export function ContentType (http, data = {}) { this.create = create({ http: http }) /** - * @description The Query on Content Type will allow to fetch details of all or specific Content Type + * @description The Query on Content Type will allow you to fetch details of all or specific Content Types. * @memberof ContentType * @func query * @param {Boolean} include_count Set this to 'true' to include in response the total count of content types available in your stack. - * @returns {Array} Array of ContentTyoe. + * @returns {Object} Query builder object with find(), count(), and findOne() methods. * * @example * import * as contentstack from '@contentstack/management' @@ -249,7 +254,11 @@ export function ContentType (http, data = {}) { * @description The Import a content type call imports a content type into a stack. * @memberof ContentType * @func import - * @param {String} data.content_type path to file + * @async + * @param {Object} data - Import data object. + * @prop {string} data.content_type - Path to content type file. + * @param {Object=} params - Optional request parameters. + * @returns {Promise} Promise for ContentType instance * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client() diff --git a/lib/stack/index.js b/lib/stack/index.js index ee800f3b..f614e680 100644 --- a/lib/stack/index.js +++ b/lib/stack/index.js @@ -50,7 +50,7 @@ export function Stack (http, data) { * @description The Update stack call lets you update the name and description of an existing stack. * @memberof Stack * @func update - * @returns {Promise} Promise for Stack instance + * @returns {Promise} Promise for Stack instance * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client() @@ -70,7 +70,7 @@ export function Stack (http, data) { * @description The fetch stack call fetches stack details. * @memberof Stack * @func fetch - * @returns {Promise} Promise for Stack instance + * @returns {Promise} Promise for Stack instance * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client() @@ -218,7 +218,7 @@ export function Stack (http, data) { /** * @description Branch corresponds to Stack branch. * @param {String} branchUid - The UID of the branch - * @returns {Branch} + * @returns {Branch} Instance of Branch. * * @example * import * as contentstack from '@contentstack/management' @@ -242,7 +242,7 @@ export function Stack (http, data) { /** * @description Branch corresponds to Stack branch. * @param {String} branchUid - The UID of the branch alias - * @returns {BranchAlias} + * @returns {BranchAlias} Instance of BranchAlias. * * @example * import * as contentstack from '@contentstack/management' @@ -478,7 +478,8 @@ export function Stack (http, data) { * @description The Get all users of a stack call fetches the list of all users of a particular stack * @memberof Stack * @func users - * @returns {Array} Array of User's including owner of Stack + * @async + * @returns {Promise} Promise for array of User instances * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client() @@ -512,8 +513,9 @@ export function Stack (http, data) { * 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. + * @async + * @param {Object>} data - Object containing userId as key and array of role UIDs as value. + * @returns {Promise} Response Object. * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client() @@ -548,8 +550,9 @@ export function Stack (http, data) { * @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 * @func transferOwnership + * @async * @param {String} email The email address of the user to whom you wish to transfer the ownership of the stack. - * @returns {Object} Response Object. + * @returns {Promise} Response Object. * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client() @@ -580,7 +583,8 @@ export function Stack (http, data) { * @description The Get stack settings call retrieves the configuration settings of an existing stack. * @memberof Stack * @func settings - * @returns {Object} Configuration settings of stack. + * @async + * @returns {Promise} Promise for configuration settings of stack. * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client() @@ -609,7 +613,8 @@ export function Stack (http, data) { * @description The Reset stack settings call resets your stack to default settings, and additionally, lets you add parameters to or modify the settings of an existing stack. * @memberof Stack * @func resetSettings - * @returns {Object} Configuration settings of stack. + * @async + * @returns {Promise} Promise for configuration settings of stack. * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client() @@ -638,7 +643,8 @@ export function Stack (http, data) { * @description The Add stack settings call lets you add settings for an existing stack. * @memberof Stack * @func addSettings - * @returns {Object} Configuration settings of stack. + * @async + * @returns {Promise} Promise for configuration settings of stack. * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client() @@ -674,9 +680,10 @@ export function Stack (http, data) { * @description The Share a stack call shares a stack with the specified user to collaborate on the stack. * @memberof Stack * @func share + * @async * @param {Array} emails - Email ID of the user with whom you wish to share the stack * @param {Object} roles - The roles object mapping email addresses to role UIDs. Example: { "[email protected]": [ "role_uid" ] } - * @returns {Object} Response Object. + * @returns {Promise} Response Object. * * @example * import * as contentstack from '@contentstack/management' @@ -706,8 +713,9 @@ export function Stack (http, data) { * @description The Unshare a stack call unshares a stack with a user and removes the user account from the list of collaborators. * @memberof Stack * @func unShare + * @async * @param {String} email The email ID of the user from whom you wish to unshare the stack. - * @returns {Object} Response Object. + * @returns {Promise} Response Object. * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client() @@ -813,13 +821,13 @@ export function Stack (http, data) { * @description The delete stack call lets you delete the stack. * @memberof Stack * @func delete - * @returns {Promise} Promise for Stack instance + * @returns {Promise} Response Object. * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client() * * client.stack({ api_key: 'api_key'}).delete() - * .then((stack) => console.log(stack)) + * .then((response) => console.log(response.notice)) * */ this.delete = deleteEntity(http) @@ -827,7 +835,7 @@ export function Stack (http, data) { /** * @description Audit log displays a record of all the activities performed in a stack and helps you keep a track of all published items, updates, deletes, and current status of the existing content. * @param {String} logItemUid - The UID of the log item - * @returns {AuditLog} + * @returns {AuditLog} Instance of AuditLog. * * @example * import * as contentstack from '@contentstack/management' @@ -852,7 +860,7 @@ export function Stack (http, data) { * @description The Create stack call creates a new stack in your Contentstack account. * @memberof Stack * @func create - * @returns {Promise} Promise for Stack instance + * @returns {Promise} Promise for Stack instance * * @example * import * as contentstack from '@contentstack/management' @@ -864,7 +872,7 @@ export function Stack (http, data) { this.create = create({ http: http, params: this.organization_uid ? { organization_uid: this.organization_uid } : null }) /** - * @description The Query on Stack will allow to fetch details of all or specific Stack. + * @description The Query on Stack will allow you to fetch details of all or specific Stacks. * @memberof Stack * @func query * @param {Object} params - Query parameters @@ -873,7 +881,7 @@ export function Stack (http, data) { * @prop {Boolean} params.include_discrete_variables - Set this to 'true' to view the access token of your stack. * @prop {Boolean} params.include_count - Set this to 'true' to include in the response the total count of the stacks owned by or shared with a user account. * @prop {Object} params.query - Queries that you can use to fetch filtered results. - * @returns {ContentstackCollection} Instance of ContentstackCollection. + * @returns {Object} Query builder object with find(), count(), and findOne() methods. * * @example * import * as contentstack from '@contentstack/management' From 922f08b080c51d13ce71b37c065944c7fa353ff3 Mon Sep 17 00:00:00 2001 From: raj pandey Date: Tue, 25 Nov 2025 15:02:56 +0530 Subject: [PATCH 03/13] Fixed JSDoc String --- lib/stack/contentType/entry/index.js | 81 +++++++++------- lib/stack/contentType/entry/variants/index.js | 27 +++--- lib/stack/environment/index.js | 12 +-- lib/stack/extension/index.js | 17 ++-- lib/stack/globalField/index.js | 23 +++-- lib/stack/label/index.js | 12 +-- lib/stack/managementToken/index.js | 12 +-- lib/stack/roles/index.js | 18 ++-- lib/stack/taxonomy/index.js | 40 ++++++-- lib/stack/variantGroup/index.js | 8 +- lib/stack/variantGroup/variants/index.js | 20 ++-- lib/stack/workflow/index.js | 96 ++++++++++--------- lib/stack/workflow/publishRules/index.js | 24 ++--- 13 files changed, 216 insertions(+), 174 deletions(-) diff --git a/lib/stack/contentType/entry/index.js b/lib/stack/contentType/entry/index.js index 4beec04a..922bf42e 100644 --- a/lib/stack/contentType/entry/index.js +++ b/lib/stack/contentType/entry/index.js @@ -34,11 +34,12 @@ export function Entry (http, data) { this.urlPath = `/content_types/${this.content_type_uid}/entries/${this.uid}` /** - * @description The Create an entry call creates a new entry for the selected content type. + * @description The Update an entry call updates an existing entry for the selected content type. * @memberof Entry * @func update - * @param locale - Locale code to localized entry - * @returns {Promise} Promise for Entry instance + * @param {Object=} param - Optional parameters. + * @prop {string=} param.locale - Locale code for localized entry. + * @returns {Promise} Promise for Entry instance * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client() @@ -99,7 +100,7 @@ export function Entry (http, data) { * @description The Delete an entry call is used to delete a specific entry from a content type. * @memberof Entry * @func delete - * @returns {Object} Response Object. + * @returns {Promise} Response Object. * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client() @@ -113,11 +114,12 @@ export function Entry (http, data) { * @description The fetch Entry call fetches Entry details. * @memberof Entry * @func fetch - * @param {Int} version Enter the version number of the entry that you want to retrieve. However, to retrieve a specific version of an entry, you need to keep the environment parameter blank. - * @param {Int} locale Enter the code of the language of which the entries need to be included. Only the entries published in this locale will be displayed. - * @param {Int} include_workflow Enter 'true' to include the workflow details of the entry. - * @param {Int} include_publish_details Enter 'true' to include the publish details of the entry. - * @returns {Promise} Promise for Entry instance + * @param {Object=} param - Query parameters. + * @prop {Number=} param.version - Enter the version number of the entry that you want to retrieve. However, to retrieve a specific version of an entry, you need to keep the environment parameter blank. + * @prop {String=} param.locale - Enter the code of the language of which the entries need to be included. Only the entries published in this locale will be displayed. + * @prop {Boolean=} param.include_workflow - Enter 'true' to include the workflow details of the entry. + * @prop {Boolean=} param.include_publish_details - Enter 'true' to include the publish details of the entry. + * @returns {Promise} Promise for Entry instance * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client() @@ -129,7 +131,7 @@ export function Entry (http, data) { this.fetch = fetch(http, 'entry') /** - * @description The Publish an asset call is used to publish a specific version of an asset on the desired environment either immediately or at a later date/time. + * @description The Publish an entry call is used to publish a specific version of an entry on the desired environment either immediately or at a later date/time. * @memberof Entry * @func publish * @returns {Promise} Response Object. @@ -153,7 +155,7 @@ export function Entry (http, data) { this.publish = publish(http, 'entry') /** - * @description The Replace asset call will replace an existing asset with another file on the stack. + * @description The Unpublish an entry call is used to unpublish a specific version of an entry from the desired environment either immediately or at a later date/time. * @memberof Entry * @func unpublish * @returns {Promise} Response Object. @@ -180,6 +182,7 @@ export function Entry (http, data) { * @description This multipurpose request allows you to either send a publish request or accept/reject a received publish request. * @memberof Entry * @func publishRequest + * @async * @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. @@ -226,6 +229,7 @@ export function Entry (http, data) { * @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 + * @async * @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. @@ -277,17 +281,17 @@ export function Entry (http, data) { } /** - * @description The variants requestan entry call is used to fetch a specific entry with variants from a content type. + * @description The variants call returns a Variants instance for managing variants of an entry. * @memberof Entry * @func variants - * @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. + * @param {String=} uid - Variant UID. If not provided, returns Variants instance for querying all variants. + * @returns {Variants} Instance of Variants. * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client() - * client.stack({ api_key: 'api_key'}).contentType('content_type_uid').entry('uid').variants('uid').fetch() - * .then((response) => console.log(response.notice)); + * const variants = client.stack({ api_key: 'api_key'}).contentType('content_type_uid').entry('uid').variants('uid') + * variants.fetch() + * .then((response) => console.log(response)); */ this.variants = (uid = null) => { const data = { stackHeaders: this.stackHeaders } @@ -300,10 +304,13 @@ export function Entry (http, data) { } /** - * @description The includeVariants an entry call is used to fetch a specific base entry with variants from a content type. - * @memberof Variants + * @description The includeVariants call is used to fetch a specific base entry with variants from a content type. + * @memberof Entry * @func includeVariants - * @returns {Object} Response Object. + * @async + * @param {string|boolean} include_variant - Whether to include variants. + * @param {string=} variants_uid - Optional variant UID. + * @returns {Promise} Response Object. * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client() @@ -338,9 +345,10 @@ export function Entry (http, data) { } /** - * @description The get locales request allows to get the languages of an entry. + * @description The get locales request allows you to get the languages of an entry. * @memberof Entry * @func locales + * @async * @returns {Promise} Response Object. * client.stack({ api_key: 'api_key'}).contentType('content_type_uid').entry('uid').locales() * .then((response) => console.log(response)); @@ -363,9 +371,10 @@ export function Entry (http, data) { } /** - * @description The get references request allows to get the references of an entry. + * @description The get references request allows you to get the references of an entry. * @memberof Entry * @func references + * @async * @returns {Promise} Response Object. * @example 1 * client.stack({ api_key: 'api_key'}).contentType('content_type_uid').entry('uid').references() @@ -395,17 +404,17 @@ export function Entry (http, data) { * @description The Create an entry call creates a new entry for the selected content type. * @memberof Entry * @func create - * @returns {Promise} Promise for Entry instance + * @returns {Promise} Promise for Entry instance * * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client() - * const entry = { + * const entry = { * title: 'Sample Entry', * 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_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 * } @@ -415,14 +424,14 @@ export function Entry (http, data) { this.create = create({ http: http }) /** - * @description The Query on Entry will allow to fetch details of all or specific Entry + * @description The Query on Entry will allow you to fetch details of all or specific Entries. * @memberof Entry * @func query - * @param {Int} locale Enter the code of the language of which the entries need to be included. Only the entries published in this locale will be displayed. - * @param {Int} include_workflow Enter 'true' to include the workflow details of the entry. - * @param {Int} include_publish_details Enter 'true' to include the publish details of the entry. + * @param {String} locale Enter the code of the language of which the entries need to be included. Only the entries published in this locale will be displayed. + * @param {Boolean} include_workflow Enter 'true' to include the workflow details of the entry. + * @param {Boolean} include_publish_details Enter 'true' to include the publish details of the entry. * @param {Object} query Queries that you can use to fetch filtered results. - * @returns {Array} Array of Entry. + * @returns {Object} Query builder object with find(), count(), and findOne() methods. * * @example * import * as contentstack from '@contentstack/management' @@ -438,10 +447,12 @@ export function Entry (http, data) { * @description The Import Entry calls given below help you to import entries by uploading JSON files. * @memberof Entry * @func import - * @param {String} entry Select the JSON file of the entry that you wish to import. - * @param {String} locale Enter the code of the language to import the entry of that particular language. - * @param {Boolean} overwrite Select 'true' to replace an existing entry with the imported entry file. - * + * @async + * @param {Object} data - Import data object. + * @prop {string} data.entry - Path to the JSON file of the entry that you wish to import. + * @prop {string=} data.locale - Enter the code of the language to import the entry of that particular language. + * @prop {boolean=} data.overwrite - Select 'true' to replace an existing entry with the imported entry file. + * @returns {Promise} Promise for Entry instance * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client() diff --git a/lib/stack/contentType/entry/variants/index.js b/lib/stack/contentType/entry/variants/index.js index ae6eb29a..9c651558 100644 --- a/lib/stack/contentType/entry/variants/index.js +++ b/lib/stack/contentType/entry/variants/index.js @@ -7,7 +7,7 @@ import { from '../../../../entity' import error from '../../../../core/contentstackError' /** - * An variants is the actual piece of content created using one of the defined content types. Read more about Entries. + * Variants allow you to create variant versions of entries within a content type. Read more about Variants. * @namespace Variants */ export function Variants (http, data) { @@ -16,10 +16,10 @@ export function Variants (http, data) { if (data && data.variants_uid) { this.urlPath += `/${this.variants_uid}` /** - * @description The Create an variants call creates a new variants for the selected content type. + * @description The Update a variant call updates an existing variant for the selected content type. * @memberof Variants * @func update - * @returns {Promise} Promise for Variants instance + * @returns {Promise} Response Object. * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client() @@ -58,10 +58,10 @@ export function Variants (http, data) { } /** - * @description The Delete an variants call is used to delete a specific variants from a content type. + * @description The Delete a variant call is used to delete a specific variant from a content type. * @memberof Variants * @func delete - * @returns {Object} Response Object. + * @returns {Promise} Response Object. * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client() @@ -75,7 +75,7 @@ export function Variants (http, data) { * @description The fetch Variants call fetches Variants details. * @memberof Variants * @func fetch - * @returns {Promise} Promise for Variants instance + * @returns {Promise} Promise for Variants instance * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client() @@ -87,10 +87,10 @@ export function Variants (http, data) { this.fetch = fetch(http, 'variants') /** - * @description The version Variants call fetches Variants version details. + * @description The versions call fetches variant version details. * @memberof Variants * @func versions - * @returns {Promise} Promise for Variants instance + * @returns {Promise} Promise for variant versions data * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client() @@ -117,19 +117,20 @@ export function Variants (http, data) { } } else { /** - * @description The Query on Variants will allow to fetch details of all or specific Variants + * @description The Query on Variants will allow you to fetch details of all or specific Variants. * @memberof Variants * @func query - * @param {Int} locale Enter the code of the language of which the entries need to be included. Only the entries published in this locale will be displayed. - * @param {Object} query Queries that you can use to fetch filtered results. - * @returns {Array} Array of Variants. + * @param {Object} params - Query parameters + * @prop {Int} params.locale Enter the code of the language of which the variants need to be included. + * @prop {Object} params.query Queries that you can use to fetch filtered results. + * @returns {Object} Query builder object with find(), count(), and findOne() methods. * * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client() * * client.stack().contentType('content_type_uid').entry('entry_uid').variants().query({ query: { title: 'Variants title' } }).find() - * .then((entries) => console.log(entries)) + * .then((variants) => console.log(variants)) */ this.query = query({ http: http, wrapperCollection: VariantsCollection }) } diff --git a/lib/stack/environment/index.js b/lib/stack/environment/index.js index 38814b1e..8c84f7d6 100644 --- a/lib/stack/environment/index.js +++ b/lib/stack/environment/index.js @@ -16,7 +16,7 @@ export function Environment (http, data = {}) { * @description The Update Environment call lets you update the name and description of an existing Environment. * @memberof Environment * @func update - * @returns {Promise} Promise for Environment instance + * @returns {Promise} Promise for Environment instance * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client() @@ -36,7 +36,7 @@ export function Environment (http, data = {}) { * @description The Delete Environment call is used to delete an existing Environment permanently from your Stack. * @memberof Environment * @func delete - * @returns {Object} Response Object. + * @returns {Promise} Response Object. * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client() @@ -50,7 +50,7 @@ export function Environment (http, data = {}) { * @description The fetch Environment call fetches Environment details. * @memberof Environment * @func fetch - * @returns {Promise} Promise for Environment instance + * @returns {Promise} Promise for Environment instance * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client() @@ -65,7 +65,7 @@ export function Environment (http, data = {}) { * @description The Create a Environment call creates a new environment in a particular stack of your Contentstack account. * @memberof Environment * @func create - * @returns {Promise} Promise for Environment instance + * @returns {Promise} Promise for Environment instance * * @example * import * as contentstack from '@contentstack/management' @@ -91,10 +91,10 @@ export function Environment (http, data = {}) { this.create = create({ http: http }) /** - * @description The Query on Environment will allow to fetch details of all or specific Environment. + * @description The Query on Environment will allow you to fetch details of all or specific Environments. * @memberof Environment * @func query - * @returns {ContentstackCollection} Instance of ContentstackCollection. + * @returns {Object} Query builder object with find(), count(), and findOne() methods. * * @example * import * as contentstack from '@contentstack/management' diff --git a/lib/stack/extension/index.js b/lib/stack/extension/index.js index fb3c8f6f..082cc90c 100644 --- a/lib/stack/extension/index.js +++ b/lib/stack/extension/index.js @@ -19,7 +19,7 @@ export function Extension (http, data = {}) { * @description The Update Extension call lets you update an existing Extension. * @memberof Extension * @func update - * @returns {Promise} Promise for Extension instance. + * @returns {Promise} Promise for Extension instance. * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client() @@ -38,7 +38,7 @@ export function Extension (http, data = {}) { * @description The Delete Extension call is used to delete an existing Extension permanently from your Stack. * @memberof Extension * @func delete - * @returns {Object} Response Object. + * @returns {Promise} Response Object. * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client() @@ -52,7 +52,7 @@ export function Extension (http, data = {}) { * @description The fetch Extension call fetches Extension details. * @memberof Extension * @func fetch - * @returns {Promise} Promise for Extension instance + * @returns {Promise} Promise for Extension instance * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client() @@ -67,7 +67,10 @@ export function Extension (http, data = {}) { * @description The Upload is used to upload a new custom widget, custom field, dashboard Widget to a stack. * @memberof Extension * @func upload - * @returns {Promise} Promise for Extension instance + * @async + * @param {Object} data - Extension data object. + * @param {Object=} params - Optional query parameters. + * @returns {Promise} Promise for Extension instance * * @example * import * as contentstack from '@contentstack/management' @@ -104,7 +107,7 @@ export function Extension (http, data = {}) { * @description The Create a extension call creates a new extension in a particular stack of your Contentstack account. * @memberof Extension * @func create - * @returns {Promise} Promise for Extension instance + * @returns {Promise} Promise for Extension instance * * @example * import * as contentstack from '@contentstack/management' @@ -128,12 +131,12 @@ export function Extension (http, data = {}) { this.create = create({ http: http }) /** - * @description The Query on Extension will allow to fetch details of all or specific Extensions. + * @description The Query on Extension will allow you to fetch details of all or specific Extensions. * @memberof Extension * @func query * @param {Object} params - URI parameters * @prop {Object} params.query - Queries that you can use to fetch filtered results for extensions. - * @returns {ContentstackCollection} Instance of ContentstackCollection. + * @returns {Object} Query builder object with find(), count(), and findOne() methods. * * @example * import * as contentstack from '@contentstack/management' diff --git a/lib/stack/globalField/index.js b/lib/stack/globalField/index.js index dcd8c45c..8370a3e7 100644 --- a/lib/stack/globalField/index.js +++ b/lib/stack/globalField/index.js @@ -5,7 +5,7 @@ import FormData from 'form-data' import { createReadStream } from 'fs' /** - * GlobalField defines the structure or schema of a page or a section of your web or mobile property. To create global Fields for your application, you are required to first create a gloabl field. Read more about Global Fields. + * GlobalField defines the structure or schema of a page or a section of your web or mobile property. To create global Fields for your application, you are required to first create a global field. Read more about Global Fields. * @namespace GlobalField */ @@ -27,7 +27,7 @@ export function GlobalField (http, data = {}) { * @description The Update GlobalField call lets you update the name and description of an existing GlobalField. * @memberof GlobalField * @func update - * @returns {Promise} Promise for GlobalField instance + * @returns {Promise} Promise for GlobalField instance * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client() @@ -47,7 +47,7 @@ export function GlobalField (http, data = {}) { * @description The Delete GlobalField call is used to delete an existing GlobalField permanently from your Stack. * @memberof GlobalField * @func delete - * @returns {Object} Response Object. + * @returns {Promise} Response Object. * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client() @@ -61,7 +61,7 @@ export function GlobalField (http, data = {}) { * @description The fetch GlobalField call fetches GlobalField details. * @memberof GlobalField * @func fetch - * @returns {Promise} Promise for GlobalField instance + * @returns {Promise} Promise for GlobalField instance * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client() @@ -76,7 +76,7 @@ export function GlobalField (http, data = {}) { * @description The Create a GlobalField call creates a new globalField in a particular stack of your Contentstack account. * @memberof GlobalField * @func create - * @returns {Promise} Promise for GlobalField instance + * @returns {Promise} Promise for GlobalField instance * * @example * import * as contentstack from '@contentstack/management' @@ -96,12 +96,12 @@ export function GlobalField (http, data = {}) { this.create = create({ http: http }) /** - * @description The Query on GlobalField will allow to fetch details of all or specific GlobalField. + * @description The Query on GlobalField will allow you to fetch details of all or specific GlobalFields. * @memberof GlobalField * @func query * @param {Object} params - Query parameters * @prop {Object} params.query - Queries that you can use to fetch filtered results. - * @returns {ContentstackCollection} Instance of ContentstackCollection. + * @returns {Object} Query builder object with find(), count(), and findOne() methods. * * @example * import * as contentstack from '@contentstack/management' @@ -116,9 +116,12 @@ export function GlobalField (http, data = {}) { * @description The Import a global field call imports a global field into a stack. * @memberof GlobalField * @func import - * @param {String} data.global_field path to file - * @param {Object=} params - Optional request parameters - * @param {Object=} headers - Optional request headers + * @async + * @param {Object} data - Import data object. + * @prop {string} data.global_field - Path to global field file. + * @param {Object=} params - Optional request parameters. + * @param {Object=} headers - Optional request headers. + * @returns {Promise} Promise for GlobalField instance * @example * import * as contentstack from '@contentstack/management' * const client = contentstack.client() diff --git a/lib/stack/label/index.js b/lib/stack/label/index.js index 71f42e4a..0cee2cf3 100644 --- a/lib/stack/label/index.js +++ b/lib/stack/label/index.js @@ -21,7 +21,7 @@ export function Label (http, data) { * @description The Update label call is used to update an existing label. * @memberof Label * @func update - * @returns {Promise} Promise for Label instance + * @returns {Promise