contentful-export 8.0.4 → 8.1.0-exo.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -80,6 +80,7 @@ function runContentfulExport(params) {
80
80
  skipRoles: options.skipRoles,
81
81
  skipTags: options.skipTags,
82
82
  stripTags: options.stripTags,
83
+ includeExperienceOrchestration: options.includeExperienceOrchestration,
83
84
  listrOptions,
84
85
  queryEntries: options.queryEntries,
85
86
  queryAssets: options.queryAssets
@@ -30,6 +30,7 @@ function parseOptions(params) {
30
30
  skipTags: false,
31
31
  stripTags: false,
32
32
  maxAllowedLimit: 1000,
33
+ includeExperienceOrchestration: false,
33
34
  saveFile: true,
34
35
  useVerboseRenderer: false,
35
36
  rawProxy: false
@@ -31,6 +31,7 @@ function getFullSourceSpace({
31
31
  includeDrafts,
32
32
  includeArchived,
33
33
  maxAllowedLimit,
34
+ includeExperienceOrchestration,
34
35
  listrOptions,
35
36
  queryEntries,
36
37
  queryAssets
@@ -148,6 +149,102 @@ function getFullSourceSpace({
148
149
  });
149
150
  }),
150
151
  skip: () => skipRoles || environmentId !== 'master' && 'Roles can only be exported from master environment'
152
+ }, {
153
+ title: 'Fetching Design Tokens data',
154
+ task: (0, _contentfulBatchLibs.wrapTask)(async ctx => {
155
+ try {
156
+ ctx.data.designTokens = await cursorPagedGet({
157
+ client,
158
+ spaceId,
159
+ environmentId,
160
+ method: 'designToken.getMany'
161
+ });
162
+ } catch (err) {
163
+ _contentfulBatchLibs.logEmitter.emit('warning', `Skipping Design Tokens export: ${err.message}`);
164
+ ctx.data.designTokens = [];
165
+ }
166
+ }),
167
+ skip: () => !includeExperienceOrchestration
168
+ }, {
169
+ title: 'Fetching Component Types data',
170
+ task: (0, _contentfulBatchLibs.wrapTask)(async ctx => {
171
+ try {
172
+ ctx.data.componentTypes = await cursorPagedGet({
173
+ client,
174
+ spaceId,
175
+ environmentId,
176
+ method: 'componentType.getMany'
177
+ });
178
+ } catch (err) {
179
+ _contentfulBatchLibs.logEmitter.emit('warning', `Skipping Component Types export: ${err.message}`);
180
+ ctx.data.componentTypes = [];
181
+ }
182
+ }),
183
+ skip: () => !includeExperienceOrchestration
184
+ }, {
185
+ title: 'Fetching Templates data',
186
+ task: (0, _contentfulBatchLibs.wrapTask)(async ctx => {
187
+ try {
188
+ ctx.data.templates = await cursorPagedGet({
189
+ client,
190
+ spaceId,
191
+ environmentId,
192
+ method: 'template.getMany'
193
+ });
194
+ } catch (err) {
195
+ _contentfulBatchLibs.logEmitter.emit('warning', `Skipping Templates export: ${err.message}`);
196
+ ctx.data.templates = [];
197
+ }
198
+ }),
199
+ skip: () => !includeExperienceOrchestration
200
+ }, {
201
+ title: 'Fetching Data Assemblies data',
202
+ task: (0, _contentfulBatchLibs.wrapTask)(async ctx => {
203
+ try {
204
+ ctx.data.dataAssemblies = await cursorPagedGet({
205
+ client,
206
+ spaceId,
207
+ environmentId,
208
+ method: 'dataAssembly.getMany'
209
+ });
210
+ } catch (err) {
211
+ _contentfulBatchLibs.logEmitter.emit('warning', `Skipping Data Assemblies export: ${err.message}`);
212
+ ctx.data.dataAssemblies = [];
213
+ }
214
+ }),
215
+ skip: () => !includeExperienceOrchestration
216
+ }, {
217
+ title: 'Fetching Fragments data',
218
+ task: (0, _contentfulBatchLibs.wrapTask)(async ctx => {
219
+ try {
220
+ ctx.data.fragments = await cursorPagedGet({
221
+ client,
222
+ spaceId,
223
+ environmentId,
224
+ method: 'fragment.getMany'
225
+ });
226
+ } catch (err) {
227
+ _contentfulBatchLibs.logEmitter.emit('warning', `Skipping Fragments export: ${err.message}`);
228
+ ctx.data.fragments = [];
229
+ }
230
+ }),
231
+ skip: () => !includeExperienceOrchestration
232
+ }, {
233
+ title: 'Fetching Experiences data',
234
+ task: (0, _contentfulBatchLibs.wrapTask)(async ctx => {
235
+ try {
236
+ ctx.data.experiences = await cursorPagedGet({
237
+ client,
238
+ spaceId,
239
+ environmentId,
240
+ method: 'experience.getMany'
241
+ });
242
+ } catch (err) {
243
+ _contentfulBatchLibs.logEmitter.emit('warning', `Skipping Experiences export: ${err.message}`);
244
+ ctx.data.experiences = [];
245
+ }
246
+ }),
247
+ skip: () => !includeExperienceOrchestration
151
248
  }], listrOptions);
152
249
  }
153
250
  function getEditorInterfaces(contentTypes) {
@@ -166,6 +263,37 @@ function getEditorInterfaces(contentTypes) {
166
263
  });
167
264
  }
168
265
 
266
+ /**
267
+ * Gets all ExO entities using cursor-based pagination (pageNext/pagePrev tokens).
268
+ * ExO list endpoints do not support skip-based pagination or the order param.
269
+ */
270
+ async function cursorPagedGet({
271
+ client,
272
+ spaceId,
273
+ environmentId,
274
+ method
275
+ }) {
276
+ const [entity, operation] = method.split('.');
277
+ const allItems = [];
278
+ let pageNext = null;
279
+ do {
280
+ var _response$pages$next, _response$pages;
281
+ const query = {
282
+ spaceId,
283
+ environmentId,
284
+ limit: pageLimit
285
+ };
286
+ if (pageNext) {
287
+ query.pageNext = pageNext;
288
+ }
289
+ const response = await client[entity][operation](query);
290
+ allItems.push(...response.items);
291
+ _contentfulBatchLibs.logEmitter.emit('info', `Fetched ${allItems.length} ${entity} items`);
292
+ pageNext = (_response$pages$next = (_response$pages = response.pages) === null || _response$pages === void 0 ? void 0 : _response$pages.next) !== null && _response$pages$next !== void 0 ? _response$pages$next : null;
293
+ } while (pageNext);
294
+ return allItems;
295
+ }
296
+
169
297
  /**
170
298
  * Gets all the existing entities based on pagination parameters.
171
299
  * The first call will have no aggregated response. Subsequent calls will
@@ -103,6 +103,10 @@ var _default = exports.default = _yargs.default.version(_package.default.version
103
103
  describe: 'Display progress in new lines instead of displaying a busy spinner and the status in the same line. Useful for CI.',
104
104
  type: 'boolean',
105
105
  default: false
106
+ }).option('include-experience-orchestration', {
107
+ describe: 'Include Experience Orchestration entities (Component Types, Templates, Data Assemblies, Fragments, Experiences, Design Tokens). Requires exo_m1 entitlement on the source space.',
108
+ type: 'boolean',
109
+ default: false
106
110
  }).option('header', {
107
111
  alias: 'H',
108
112
  type: 'string',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "contentful-export",
3
- "version": "8.0.4",
3
+ "version": "8.1.0-exo.1",
4
4
  "description": "this tool allows you to export a space to a JSON dump",
5
5
  "main": "dist/index.js",
6
6
  "types": "types.d.ts",
@@ -111,7 +111,7 @@
111
111
  "prerelease": true
112
112
  },
113
113
  {
114
- "name": "exo",
114
+ "name": "feat/exo",
115
115
  "channel": "exo",
116
116
  "prerelease": "exo"
117
117
  }
@@ -144,7 +144,6 @@
144
144
  ]
145
145
  },
146
146
  "overrides": {
147
- "cross-spawn": "^7.0.6",
148
- "undici": "^6.27.0"
147
+ "cross-spawn": "^7.0.6"
149
148
  }
150
149
  }
package/types.d.ts CHANGED
@@ -28,9 +28,10 @@ export interface Options {
28
28
  skipWebhooks?: boolean;
29
29
  skipTags?: boolean;
30
30
  useVerboseRenderer?: boolean;
31
+ includeExperienceOrchestration?: boolean;
31
32
  }
32
33
 
33
- type ContentfulExportField = 'contentTypes' | 'entries' | 'assets' | 'locales' | 'tags' | 'webhooks' | 'roles' | 'editorInterfaces';
34
+ type ContentfulExportField = 'contentTypes' | 'entries' | 'assets' | 'locales' | 'tags' | 'webhooks' | 'roles' | 'editorInterfaces' | 'designTokens' | 'componentTypes' | 'templates' | 'dataAssemblies' | 'fragments' | 'experiences';
34
35
 
35
36
  declare const runContentfulExport: (params: Options) => Promise<Record<ContentfulExportField, unknown[]>>
36
37
  export default runContentfulExport