contentful 11.11.1 → 11.12.0

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/README.md CHANGED
@@ -340,12 +340,13 @@ When initialising a client, you will receive an instance of the [`ContentfulClie
340
340
 
341
341
  #### Entries
342
342
 
343
- | Chain | Modifier |
344
- | -------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
345
- | _none (default)_ | Returns entries in a single locale. Resolvable linked entries will be inlined while unresolvable links will be kept as link objects. [Read more on link resolution](ADVANCED.md#link-resolution) |
346
- | `withAllLocales` | Returns entries in all locales. |
347
- | `withoutLinkResolution` | All linked entries will be rendered as link objects. [Read more on link resolution](ADVANCED.md#link-resolution) |
348
- | `withoutUnresolvableLinks` | If linked entries are not resolvable, the corresponding link objects are removed from the response. |
343
+ | Chain | Modifier |
344
+ | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
345
+ | _none (default)_ | Returns entries in a single locale. Resolvable linked entries will be inlined while unresolvable links will be kept as link objects. [Read more on link resolution](ADVANCED.md#link-resolution) |
346
+ | `withAllLocales` | Returns entries in all locales. |
347
+ | `withoutLinkResolution` | All linked entries will be rendered as link objects. [Read more on link resolution](ADVANCED.md#link-resolution) |
348
+ | `withoutUnresolvableLinks` | If linked entries are not resolvable, the corresponding link objects are removed from the response. |
349
+ | `withLocaleBasedPublishing` | Fetched entries & assets will be returned with only content from published locales. |
349
350
 
350
351
  ##### Example
351
352
 
@@ -10009,7 +10009,8 @@ var contentful = (function (exports) {
10009
10009
  options = _args9.length > 2 && _args9[2] !== undefined ? _args9[2] : {
10010
10010
  withAllLocales: false,
10011
10011
  withoutLinkResolution: false,
10012
- withoutUnresolvableLinks: false
10012
+ withoutUnresolvableLinks: false,
10013
+ withLocaleBasedPublishing: false
10013
10014
  };
10014
10015
  withAllLocales = options.withAllLocales;
10015
10016
  validateLocaleParam(query, withAllLocales);
@@ -10085,7 +10086,8 @@ var contentful = (function (exports) {
10085
10086
  options = _args11.length > 1 && _args11[1] !== undefined ? _args11[1] : {
10086
10087
  withAllLocales: false,
10087
10088
  withoutLinkResolution: false,
10088
- withoutUnresolvableLinks: false
10089
+ withoutUnresolvableLinks: false,
10090
+ withLocaleBasedPublishing: false
10089
10091
  };
10090
10092
  withAllLocales = options.withAllLocales;
10091
10093
  validateLocaleParam(query, withAllLocales);
@@ -10114,35 +10116,42 @@ var contentful = (function (exports) {
10114
10116
  }
10115
10117
  function _internalGetEntries() {
10116
10118
  _internalGetEntries = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee12(query, options) {
10117
- var withoutLinkResolution, withoutUnresolvableLinks, entries;
10119
+ var withoutLinkResolution, withoutUnresolvableLinks, withLocaleBasedPublishing, baseConfig, config, entries;
10118
10120
  return _regeneratorRuntime.wrap(function _callee12$(_context12) {
10119
10121
  while (1) switch (_context12.prev = _context12.next) {
10120
10122
  case 0:
10121
- withoutLinkResolution = options.withoutLinkResolution, withoutUnresolvableLinks = options.withoutUnresolvableLinks;
10123
+ withoutLinkResolution = options.withoutLinkResolution, withoutUnresolvableLinks = options.withoutUnresolvableLinks, withLocaleBasedPublishing = options.withLocaleBasedPublishing;
10122
10124
  _context12.prev = 1;
10123
- _context12.next = 4;
10125
+ baseConfig = createRequestConfig({
10126
+ query: prepareQuery(query)
10127
+ });
10128
+ config = baseConfig;
10129
+ if (withLocaleBasedPublishing) {
10130
+ config.headers = Object.assign(Object.assign({}, config.headers), {
10131
+ 'X-Contentful-Locale-Based-Publishing': true
10132
+ });
10133
+ }
10134
+ _context12.next = 7;
10124
10135
  return get({
10125
10136
  context: 'environment',
10126
10137
  path: maybeEnableTimelinePreview('entries'),
10127
- config: createRequestConfig({
10128
- query: prepareQuery(query)
10129
- })
10138
+ config: config
10130
10139
  });
10131
- case 4:
10140
+ case 7:
10132
10141
  entries = _context12.sent;
10133
10142
  return _context12.abrupt("return", resolveCircular(entries, {
10134
10143
  resolveLinks: !withoutLinkResolution,
10135
10144
  removeUnresolved: withoutUnresolvableLinks !== null && withoutUnresolvableLinks !== void 0 ? withoutUnresolvableLinks : false
10136
10145
  }));
10137
- case 8:
10138
- _context12.prev = 8;
10146
+ case 11:
10147
+ _context12.prev = 11;
10139
10148
  _context12.t0 = _context12["catch"](1);
10140
10149
  errorHandler(_context12.t0);
10141
- case 11:
10150
+ case 14:
10142
10151
  case "end":
10143
10152
  return _context12.stop();
10144
10153
  }
10145
- }, _callee12, null, [[1, 8]]);
10154
+ }, _callee12, null, [[1, 11]]);
10146
10155
  }));
10147
10156
  return _internalGetEntries.apply(this, arguments);
10148
10157
  }
@@ -10226,7 +10235,8 @@ var contentful = (function (exports) {
10226
10235
  options = _args16.length > 1 && _args16[1] !== undefined ? _args16[1] : {
10227
10236
  withAllLocales: false,
10228
10237
  withoutLinkResolution: false,
10229
- withoutUnresolvableLinks: false
10238
+ withoutUnresolvableLinks: false,
10239
+ withLocaleBasedPublishing: false
10230
10240
  };
10231
10241
  withAllLocales = options.withAllLocales;
10232
10242
  validateLocaleParam(query, withAllLocales);
@@ -10234,7 +10244,7 @@ var contentful = (function (exports) {
10234
10244
  localeSpecificQuery = withAllLocales ? Object.assign(Object.assign({}, query), {
10235
10245
  locale: '*'
10236
10246
  }) : query;
10237
- return _context16.abrupt("return", internalGetAssets(localeSpecificQuery));
10247
+ return _context16.abrupt("return", internalGetAssets(localeSpecificQuery, options));
10238
10248
  case 6:
10239
10249
  case "end":
10240
10250
  return _context16.stop();
@@ -10243,35 +10253,44 @@ var contentful = (function (exports) {
10243
10253
  }));
10244
10254
  return _makeGetAssets.apply(this, arguments);
10245
10255
  }
10246
- function internalGetAsset(_x15, _x16) {
10256
+ function internalGetAsset(_x15, _x16, _x17) {
10247
10257
  return _internalGetAsset.apply(this, arguments);
10248
10258
  }
10249
10259
  function _internalGetAsset() {
10250
- _internalGetAsset = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee17(id, query) {
10260
+ _internalGetAsset = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee17(id, query, options) {
10261
+ var withLocaleBasedPublishing, baseConfig, config;
10251
10262
  return _regeneratorRuntime.wrap(function _callee17$(_context17) {
10252
10263
  while (1) switch (_context17.prev = _context17.next) {
10253
10264
  case 0:
10254
- _context17.prev = 0;
10265
+ withLocaleBasedPublishing = options.withLocaleBasedPublishing;
10266
+ _context17.prev = 1;
10267
+ baseConfig = createRequestConfig({
10268
+ query: prepareQuery(query)
10269
+ });
10270
+ config = baseConfig;
10271
+ if (withLocaleBasedPublishing) {
10272
+ config.headers = Object.assign(Object.assign({}, config.headers), {
10273
+ 'X-Contentful-Locale-Based-Publishing': true
10274
+ });
10275
+ }
10255
10276
  return _context17.abrupt("return", get({
10256
10277
  context: 'environment',
10257
10278
  path: maybeEnableTimelinePreview("assets/".concat(id)),
10258
- config: createRequestConfig({
10259
- query: prepareQuery(query)
10260
- })
10279
+ config: config
10261
10280
  }));
10262
- case 4:
10263
- _context17.prev = 4;
10264
- _context17.t0 = _context17["catch"](0);
10281
+ case 8:
10282
+ _context17.prev = 8;
10283
+ _context17.t0 = _context17["catch"](1);
10265
10284
  errorHandler(_context17.t0);
10266
- case 7:
10285
+ case 11:
10267
10286
  case "end":
10268
10287
  return _context17.stop();
10269
10288
  }
10270
- }, _callee17, null, [[0, 4]]);
10289
+ }, _callee17, null, [[1, 8]]);
10271
10290
  }));
10272
10291
  return _internalGetAsset.apply(this, arguments);
10273
10292
  }
10274
- function makeGetAsset(_x17, _x18) {
10293
+ function makeGetAsset(_x18, _x19) {
10275
10294
  return _makeGetAsset.apply(this, arguments);
10276
10295
  }
10277
10296
  function _makeGetAsset() {
@@ -10286,7 +10305,8 @@ var contentful = (function (exports) {
10286
10305
  options = _args18.length > 2 && _args18[2] !== undefined ? _args18[2] : {
10287
10306
  withAllLocales: false,
10288
10307
  withoutLinkResolution: false,
10289
- withoutUnresolvableLinks: false
10308
+ withoutUnresolvableLinks: false,
10309
+ withLocaleBasedPublishing: false
10290
10310
  };
10291
10311
  withAllLocales = options.withAllLocales;
10292
10312
  validateLocaleParam(query, withAllLocales);
@@ -10294,7 +10314,7 @@ var contentful = (function (exports) {
10294
10314
  localeSpecificQuery = withAllLocales ? Object.assign(Object.assign({}, query), {
10295
10315
  locale: '*'
10296
10316
  }) : query;
10297
- return _context18.abrupt("return", internalGetAsset(id, localeSpecificQuery));
10317
+ return _context18.abrupt("return", internalGetAsset(id, localeSpecificQuery, options));
10298
10318
  case 6:
10299
10319
  case "end":
10300
10320
  return _context18.stop();
@@ -10303,35 +10323,44 @@ var contentful = (function (exports) {
10303
10323
  }));
10304
10324
  return _makeGetAsset.apply(this, arguments);
10305
10325
  }
10306
- function internalGetAssets(_x19) {
10326
+ function internalGetAssets(_x20, _x21) {
10307
10327
  return _internalGetAssets.apply(this, arguments);
10308
10328
  }
10309
10329
  function _internalGetAssets() {
10310
- _internalGetAssets = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee19(query) {
10330
+ _internalGetAssets = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee19(query, options) {
10331
+ var withLocaleBasedPublishing, baseConfig, config;
10311
10332
  return _regeneratorRuntime.wrap(function _callee19$(_context19) {
10312
10333
  while (1) switch (_context19.prev = _context19.next) {
10313
10334
  case 0:
10314
- _context19.prev = 0;
10335
+ withLocaleBasedPublishing = options.withLocaleBasedPublishing;
10336
+ _context19.prev = 1;
10337
+ baseConfig = createRequestConfig({
10338
+ query: prepareQuery(query)
10339
+ });
10340
+ config = baseConfig;
10341
+ if (withLocaleBasedPublishing) {
10342
+ config.headers = Object.assign(Object.assign({}, config.headers), {
10343
+ 'X-Contentful-Locale-Based-Publishing': true
10344
+ });
10345
+ }
10315
10346
  return _context19.abrupt("return", get({
10316
10347
  context: 'environment',
10317
10348
  path: maybeEnableTimelinePreview('assets'),
10318
- config: createRequestConfig({
10319
- query: prepareQuery(query)
10320
- })
10349
+ config: config
10321
10350
  }));
10322
- case 4:
10323
- _context19.prev = 4;
10324
- _context19.t0 = _context19["catch"](0);
10351
+ case 8:
10352
+ _context19.prev = 8;
10353
+ _context19.t0 = _context19["catch"](1);
10325
10354
  errorHandler(_context19.t0);
10326
- case 7:
10355
+ case 11:
10327
10356
  case "end":
10328
10357
  return _context19.stop();
10329
10358
  }
10330
- }, _callee19, null, [[0, 4]]);
10359
+ }, _callee19, null, [[1, 8]]);
10331
10360
  }));
10332
10361
  return _internalGetAssets.apply(this, arguments);
10333
10362
  }
10334
- function getTag(_x20) {
10363
+ function getTag(_x22) {
10335
10364
  return _getTag.apply(this, arguments);
10336
10365
  }
10337
10366
  function _getTag() {
@@ -10378,7 +10407,7 @@ var contentful = (function (exports) {
10378
10407
  }));
10379
10408
  return _getTags.apply(this, arguments);
10380
10409
  }
10381
- function createAssetKey(_x21) {
10410
+ function createAssetKey(_x23) {
10382
10411
  return _createAssetKey.apply(this, arguments);
10383
10412
  }
10384
10413
  function _createAssetKey() {
@@ -10439,7 +10468,7 @@ var contentful = (function (exports) {
10439
10468
  }));
10440
10469
  return _getLocales.apply(this, arguments);
10441
10470
  }
10442
- function sync(_x22) {
10471
+ function sync(_x24) {
10443
10472
  return _sync.apply(this, arguments);
10444
10473
  }
10445
10474
  function _sync() {
@@ -10461,7 +10490,7 @@ var contentful = (function (exports) {
10461
10490
  }));
10462
10491
  return _sync.apply(this, arguments);
10463
10492
  }
10464
- function makePagedSync(_x23, _x24) {
10493
+ function makePagedSync(_x25, _x26) {
10465
10494
  return _makePagedSync.apply(this, arguments);
10466
10495
  }
10467
10496
  function _makePagedSync() {
@@ -10475,7 +10504,8 @@ var contentful = (function (exports) {
10475
10504
  options = _args25.length > 2 && _args25[2] !== undefined ? _args25[2] : {
10476
10505
  withAllLocales: false,
10477
10506
  withoutLinkResolution: false,
10478
- withoutUnresolvableLinks: false
10507
+ withoutUnresolvableLinks: false,
10508
+ withLocaleBasedPublishing: false
10479
10509
  };
10480
10510
  validateResolveLinksParam(query);
10481
10511
  validateRemoveUnresolvedParam(query);
@@ -10496,8 +10526,7 @@ var contentful = (function (exports) {
10496
10526
  function makeParseEntries(data) {
10497
10527
  var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
10498
10528
  withoutLinkResolution: false,
10499
- withoutUnresolvableLinks: false
10500
- };
10529
+ withoutUnresolvableLinks: false};
10501
10530
  return internalParseEntries(data, options);
10502
10531
  }
10503
10532
  function internalParseEntries(data, options) {
@@ -10512,7 +10541,7 @@ var contentful = (function (exports) {
10512
10541
  var query = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
10513
10542
  return internalGetConceptScheme(id, query);
10514
10543
  }
10515
- function internalGetConceptScheme(_x25) {
10544
+ function internalGetConceptScheme(_x27) {
10516
10545
  return _internalGetConceptScheme.apply(this, arguments);
10517
10546
  }
10518
10547
  function _internalGetConceptScheme() {
@@ -10582,7 +10611,7 @@ var contentful = (function (exports) {
10582
10611
  var query = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
10583
10612
  return internalGetConcept(id, query);
10584
10613
  }
10585
- function internalGetConcept(_x26) {
10614
+ function internalGetConcept(_x28) {
10586
10615
  return _internalGetConcept.apply(this, arguments);
10587
10616
  }
10588
10617
  function _internalGetConcept() {
@@ -10652,7 +10681,7 @@ var contentful = (function (exports) {
10652
10681
  var query = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
10653
10682
  return internalGetConceptAncestors(id, query);
10654
10683
  }
10655
- function internalGetConceptAncestors(_x27) {
10684
+ function internalGetConceptAncestors(_x29) {
10656
10685
  return _internalGetConceptAncestors.apply(this, arguments);
10657
10686
  }
10658
10687
  function _internalGetConceptAncestors() {
@@ -10687,7 +10716,7 @@ var contentful = (function (exports) {
10687
10716
  var query = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
10688
10717
  return internalGetConceptDescendants(id, query);
10689
10718
  }
10690
- function internalGetConceptDescendants(_x28) {
10719
+ function internalGetConceptDescendants(_x30) {
10691
10720
  return _internalGetConceptDescendants.apply(this, arguments);
10692
10721
  }
10693
10722
  /*
@@ -10779,6 +10808,13 @@ var contentful = (function (exports) {
10779
10808
  }));
10780
10809
  }
10781
10810
  });
10811
+ Object.defineProperty(response, 'withLocaleBasedPublishing', {
10812
+ get: function get() {
10813
+ return makeInnerClient(Object.assign(Object.assign({}, options), {
10814
+ withLocaleBasedPublishing: true
10815
+ }));
10816
+ }
10817
+ });
10782
10818
  return Object.create(response);
10783
10819
  }
10784
10820
  var makeClient = function makeClient(_ref2) {
@@ -10796,28 +10832,40 @@ var contentful = (function (exports) {
10796
10832
  }, {
10797
10833
  withoutLinkResolution: false,
10798
10834
  withAllLocales: false,
10799
- withoutUnresolvableLinks: false
10835
+ withoutUnresolvableLinks: false,
10836
+ withLocaleBasedPublishing: false
10800
10837
  });
10801
10838
  return Object.assign(Object.assign({}, client), {
10802
10839
  get withAllLocales() {
10803
10840
  return makeInnerClient({
10804
10841
  withAllLocales: true,
10805
10842
  withoutLinkResolution: false,
10806
- withoutUnresolvableLinks: false
10843
+ withoutUnresolvableLinks: false,
10844
+ withLocaleBasedPublishing: false
10807
10845
  });
10808
10846
  },
10809
10847
  get withoutLinkResolution() {
10810
10848
  return makeInnerClient({
10811
10849
  withAllLocales: false,
10812
10850
  withoutLinkResolution: true,
10813
- withoutUnresolvableLinks: false
10851
+ withoutUnresolvableLinks: false,
10852
+ withLocaleBasedPublishing: false
10814
10853
  });
10815
10854
  },
10816
10855
  get withoutUnresolvableLinks() {
10817
10856
  return makeInnerClient({
10818
10857
  withAllLocales: false,
10819
10858
  withoutLinkResolution: false,
10820
- withoutUnresolvableLinks: true
10859
+ withoutUnresolvableLinks: true,
10860
+ withLocaleBasedPublishing: false
10861
+ });
10862
+ },
10863
+ get withLocaleBasedPublishing() {
10864
+ return makeInnerClient({
10865
+ withAllLocales: false,
10866
+ withoutLinkResolution: false,
10867
+ withoutUnresolvableLinks: false,
10868
+ withLocaleBasedPublishing: true
10821
10869
  });
10822
10870
  }
10823
10871
  });