You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Entry variants: `contentType(...).entry(...).variants(variantUidOrUids, branchName?)` — optional second argument sets the CMA `branch` header for that variants scope (branch UID or alias). First argument accepts a variant UID string or an array of UIDs (comma-separated in the request path). Omitting `branchName` preserves previous behavior.
7
+
- Entry variants: added `variants(uid).publish()` and `variants(uid).unpublish()`, calling the entry publish/unpublish endpoints with the variant payload nested under `entry`.
8
+
-`publish()`/`unpublish()` (entry and entry variants) accept optional `headers` and `params`, merged into the underlying HTTP request.
9
+
- Test
10
+
- Unit tests and sanity API tests for entry variants with an explicit branch, and for the new variant `publish()`/`unpublish()` methods.
Copy file name to clipboardExpand all lines: lib/stack/contentType/entry/index.js
+45-7Lines changed: 45 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -285,22 +285,60 @@ export function Entry (http, data) {
285
285
* @description The variants call returns a Variants instance for managing variants of an entry.
286
286
* @memberof Entry
287
287
* @func variants
288
-
* @param {String=} uid - Variant UID. If not provided, returns Variants instance for querying all variants.
288
+
* @param {string|string[]=} variantUidOrUids - Variant UID, list of UIDs (comma-separated in the path), or omit to query all variants.
289
+
* @param {string=} branchName - Optional branch UID or alias for this variants scope (sent as the branch header). Omit to use the stack default branch.
289
290
* @returns {Variants} Instance of Variants.
290
291
* @example
291
292
* import * as contentstack from '@contentstack/management'
@@ -121,6 +133,88 @@ export function Variants (http, data) {
121
133
returnerror(err)
122
134
}
123
135
}
136
+
137
+
/**
138
+
* @description Publishes via the entry publish endpoint (POST .../entries/{entry_uid}/publish). Pass `publishDetails` as the object nested under `entry` (environments, locales, variants, variant_rules, etc.). Optional `headers` and `params` are merged into the HTTP request.
139
+
* @memberof Variants
140
+
* @func publish
141
+
* @param {Object} options
142
+
* @param {Object} options.publishDetails - Payload for the `entry` property (e.g. environments, locales, variants, variant_rules).
143
+
* @param {String|null} [options.locale] - Top-level `locale` on the request body.
144
+
* @param {Number|null} [options.version] - Top-level `version` on the request body.
145
+
* @param {String|null} [options.scheduledAt] - Top-level `scheduled_at` (ISO) on the request body.
146
+
* @param {Object} [options.headers={}] - Extra request headers merged with stack headers.
147
+
* @param {Object} [options.params={}] - Query string parameters for the request.
148
+
* @returns {Promise<Object>} Response data (e.g. notice, job_id).
149
+
* @example
150
+
* import * as contentstack from '@contentstack/management'
* @description Unpublishes via the entry unpublish endpoint (POST .../entries/{entry_uid}/unpublish). Pass `publishDetails` as the object nested under `entry`. Optional `headers` and `params` are merged into the HTTP request.
186
+
* @memberof Variants
187
+
* @func unpublish
188
+
* @param {Object} options
189
+
* @param {Object} options.publishDetails - Payload for the `entry` property (e.g. environments, locales, variants).
190
+
* @param {String|null} [options.locale] - Top-level `locale` on the request body.
191
+
* @param {Number|null} [options.version] - Top-level `version` on the request body.
192
+
* @param {String|null} [options.scheduledAt] - Top-level `scheduled_at` (ISO) on the request body.
193
+
* @param {Object} [options.headers={}] - Extra request headers merged with stack headers.
194
+
* @param {Object} [options.params={}] - Query string parameters for the request.
195
+
* @returns {Promise<Object>} Response data (e.g. notice, job_id).
0 commit comments