@@ -37,28 +37,59 @@ export function BulkOperation (http, data = {}) {
3737 * 'en'
3838 * ],
3939 * environments: [
40- * '{{env_name}} / env_uid }}'
40+ * '{{env_uid}}'
4141 * ]
4242 * }
4343 * client.stack({ api_key: 'api_key'}).bulkOperation().publish({ details: publishDetails })
4444 * .then((response) => { console.log(response.notice) })
4545 *
46+ * @example
47+ * // Bulk nested publish
48+ * import * as contentstack from '@contentstack/management'
49+ * const client = contentstack.client()
50+ * {
51+ * environments:["{{env_uid}}","{{env_uid}}"],
52+ * locales:["en-us"],
53+ * items:[
54+ * {
55+ * _content_type_uid: '{{content_type_uid}}',
56+ * uid: '{{entry_uid}}'
57+ * },
58+ * {
59+ * _content_type_uid: '{{content_type_uid}}',
60+ * uid: '{{entry_uid}}'
61+ * },
62+ * {
63+ * _content_type_uid: '{{content_type_uid}}',
64+ * uid: '{{entry_uid}}'
65+ * }
66+ * ]
67+ * }
68+ * client.stack({ api_key: 'api_key'}).bulkOperation().publish({ details: publishDetails, is_nested: true })
69+ * .then((response) => { console.log(response.notice) })
70+ *
4671 */
47- this . publish = async ( params = { } ) => {
72+ this . publish = async ( { details , skip_workflow_stage = false , approvals = false , is_nested = false } ) => {
4873 var httpBody = { }
49- if ( params . details ) {
50- httpBody = cloneDeep ( params . details )
74+ if ( details ) {
75+ httpBody = cloneDeep ( details )
5176 }
5277 const headers = {
5378 headers : {
5479 ...cloneDeep ( this . stackHeaders )
5580 }
5681 }
57- if ( params . skip_workflow_stage_check ) {
58- headers . headers . skip_workflow_stage_check = params . skip_workflow_stage_check
82+ if ( is_nested ) {
83+ headers . params = {
84+ nested : true ,
85+ event_type : 'bulk'
86+ }
87+ }
88+ if ( skip_workflow_stage ) {
89+ headers . headers . skip_workflow_stage_check = skip_workflow_stage
5990 }
60- if ( params . approvals ) {
61- headers . headers . approvals = params . approvals
91+ if ( approvals ) {
92+ headers . headers . approvals = approvals
6293 }
6394 return publishUnpublish ( http , '/bulk/publish' , httpBody , headers )
6495 }
@@ -91,28 +122,58 @@ export function BulkOperation (http, data = {}) {
91122 * 'en'
92123 * ],
93124 * environments: [
94- * '{{env_name}} / env_uid }}'
125+ * '{{env_uid}}'
95126 * ]
96127 * }
97128 * client.stack({ api_key: 'api_key'}).bulkOperation().unpublish({ details: publishDetails })
98129 * .then((response) => { console.log(response.notice) })
99130 *
131+ * @example
132+ * // Bulk nested publish
133+ * import * as contentstack from '@contentstack/management'
134+ * const client = contentstack.client()
135+ * {
136+ * environments:["{{env_uid}}","{{env_uid}}"],
137+ * locales:["en-us"],
138+ * items:[
139+ * {
140+ * _content_type_uid: '{{content_type_uid}}',
141+ * uid: '{{entry_uid}}'
142+ * },
143+ * {
144+ * _content_type_uid: '{{content_type_uid}}',
145+ * uid: '{{entry_uid}}'
146+ * },
147+ * {
148+ * _content_type_uid: '{{content_type_uid}}',
149+ * uid: '{{entry_uid}}'
150+ * }
151+ * ]
152+ * }
153+ * client.stack({ api_key: 'api_key'}).bulkOperation().unpublish({ details: publishDetails, is_nested: true })
154+ * .then((response) => { console.log(response.notice) })
100155 */
101- this . unpublish = async ( params = { } ) => {
156+ this . unpublish = async ( { details , skip_workflow_stage = false , approvals = false , is_nested = false } ) => {
102157 var httpBody = { }
103- if ( params . details ) {
104- httpBody = cloneDeep ( params . details )
158+ if ( details ) {
159+ httpBody = cloneDeep ( details )
105160 }
106161 const headers = {
107162 headers : {
108163 ...cloneDeep ( this . stackHeaders )
109164 }
110165 }
111- if ( params . skip_workflow_stage_check ) {
112- headers . headers . skip_workflow_stage_check = params . skip_workflow_stage_check
166+ if ( is_nested ) {
167+ headers . params = {
168+ nested : true ,
169+ event_type : 'bulk'
170+ }
171+ }
172+ if ( skip_workflow_stage ) {
173+ headers . headers . skip_workflow_stage_check = skip_workflow_stage
113174 }
114- if ( params . approvals ) {
115- headers . headers . approvals = params . approvals
175+ if ( approvals ) {
176+ headers . headers . approvals = approvals
116177 }
117178 return publishUnpublish ( http , '/bulk/unpublish' , httpBody , headers )
118179 }
0 commit comments