contentful 9.2.14 → 9.2.16
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/contentful.browser.js +79 -31
- package/dist/contentful.browser.js.map +1 -1
- package/dist/contentful.browser.min.js +3 -3
- package/dist/contentful.node.js +79 -31
- package/dist/contentful.node.js.map +1 -1
- package/dist/contentful.node.min.js +2 -2
- package/dist/es-modules/contentful.js +17 -16
- package/dist/es-modules/create-contentful-api.js +95 -43
- package/dist/es-modules/create-global-options.js +1 -7
- package/dist/es-modules/entities/asset-key.js +4 -10
- package/dist/es-modules/entities/asset.js +6 -13
- package/dist/es-modules/entities/content-type.js +6 -13
- package/dist/es-modules/entities/entry.js +10 -17
- package/dist/es-modules/entities/index.js +9 -18
- package/dist/es-modules/entities/locale.js +6 -13
- package/dist/es-modules/entities/space.js +3 -8
- package/dist/es-modules/entities/tag.js +6 -13
- package/dist/es-modules/mixins/stringify-safe.js +3 -10
- package/dist/es-modules/paged-sync.js +13 -15
- package/dist/es-modules/utils/normalize-select.js +1 -7
- package/dist/es-modules/utils/validate-timestamp.js +2 -10
- package/package.json +2 -2
|
@@ -1,19 +1,20 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.createClient = createClient;
|
|
7
|
-
var _axios = _interopRequireDefault(require("axios"));
|
|
8
|
-
var _contentfulSdkCore = require("contentful-sdk-core");
|
|
9
|
-
var _createContentfulApi = _interopRequireDefault(require("./create-contentful-api"));
|
|
10
|
-
var _createGlobalOptions = _interopRequireDefault(require("./create-global-options"));
|
|
11
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
1
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
13
2
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
14
3
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
15
4
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
16
5
|
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
6
|
+
/**
|
|
7
|
+
* Contentful Delivery API SDK. Allows you to create instances of a client
|
|
8
|
+
* with access to the Contentful Content Delivery API.
|
|
9
|
+
* @namespace contentful
|
|
10
|
+
* @see ContentfulClientAPI
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import axios from 'axios';
|
|
14
|
+
import { createHttpClient, getUserAgentHeader } from 'contentful-sdk-core';
|
|
15
|
+
import createContentfulApi from './create-contentful-api';
|
|
16
|
+
import createGlobalOptions from './create-global-options';
|
|
17
|
+
|
|
17
18
|
/**
|
|
18
19
|
* Create a client instance
|
|
19
20
|
* @func
|
|
@@ -48,7 +49,7 @@ function _toPrimitive(input, hint) { if (typeof input !== "object" || input ===
|
|
|
48
49
|
* })
|
|
49
50
|
*/
|
|
50
51
|
|
|
51
|
-
function createClient(params) {
|
|
52
|
+
export function createClient(params) {
|
|
52
53
|
if (!params.accessToken) {
|
|
53
54
|
throw new TypeError('Expected parameter accessToken');
|
|
54
55
|
}
|
|
@@ -62,13 +63,13 @@ function createClient(params) {
|
|
|
62
63
|
environment: 'master'
|
|
63
64
|
};
|
|
64
65
|
const config = _objectSpread(_objectSpread({}, defaultConfig), params);
|
|
65
|
-
const userAgentHeader =
|
|
66
|
+
const userAgentHeader = getUserAgentHeader(`contentful.js/${"9.2.16"}`, config.application, config.integration);
|
|
66
67
|
config.headers = _objectSpread(_objectSpread({}, config.headers), {}, {
|
|
67
68
|
'Content-Type': 'application/vnd.contentful.delivery.v1+json',
|
|
68
69
|
'X-Contentful-User-Agent': userAgentHeader
|
|
69
70
|
});
|
|
70
|
-
const http =
|
|
71
|
-
const getGlobalOptions = (
|
|
71
|
+
const http = createHttpClient(axios, config);
|
|
72
|
+
const getGlobalOptions = createGlobalOptions({
|
|
72
73
|
resolveLinks: config.resolveLinks,
|
|
73
74
|
environment: config.environment,
|
|
74
75
|
removeUnresolved: config.removeUnresolved,
|
|
@@ -77,7 +78,7 @@ function createClient(params) {
|
|
|
77
78
|
});
|
|
78
79
|
// Append environment to baseURL
|
|
79
80
|
http.defaults.baseURL = getGlobalOptions().environmentBaseUrl;
|
|
80
|
-
return (
|
|
81
|
+
return createContentfulApi({
|
|
81
82
|
http,
|
|
82
83
|
getGlobalOptions
|
|
83
84
|
});
|
|
@@ -1,20 +1,72 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = createContentfulApi;
|
|
7
|
-
var _contentfulSdkCore = require("contentful-sdk-core");
|
|
8
|
-
var _entities = _interopRequireDefault(require("./entities"));
|
|
9
|
-
var _pagedSync = _interopRequireDefault(require("./paged-sync"));
|
|
10
|
-
var _normalizeSelect = _interopRequireDefault(require("./utils/normalize-select"));
|
|
11
|
-
var _validateTimestamp = _interopRequireDefault(require("./utils/validate-timestamp"));
|
|
12
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
1
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
14
2
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
15
3
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
16
4
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
17
5
|
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
6
|
+
/**
|
|
7
|
+
* Contentful Delivery API Client. Contains methods which allow access to the
|
|
8
|
+
* different kinds of entities present in Contentful (Entries, Assets, etc).
|
|
9
|
+
* @namespace ContentfulClientAPI
|
|
10
|
+
* @see Entities
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* The different kinds of top level entities you can find in Contentful
|
|
15
|
+
* @namespace Entities
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* System metadata. See <a href="https://www.contentful.com/developers/docs/references/content-delivery-api/#/introduction/common-resource-attributes">Common Resource Attributes</a> for more details.
|
|
20
|
+
* @memberof Entities
|
|
21
|
+
* @typedef Sys
|
|
22
|
+
* @prop {string} type
|
|
23
|
+
* @prop {string} id
|
|
24
|
+
* @prop {Entities.Link} space
|
|
25
|
+
* @prop {string} createdAt
|
|
26
|
+
* @prop {string} updatedAt
|
|
27
|
+
* @prop {number} revision
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Link to another entity. See <a href="https://www.contentful.com/developers/docs/concepts/links/">Links</a> for more details.
|
|
32
|
+
* @memberof Entities
|
|
33
|
+
* @typedef Link
|
|
34
|
+
* @prop {string} type - type of this entity. Always link.
|
|
35
|
+
* @prop {string} id
|
|
36
|
+
* @prop {string} linkType - type of this link. If defined, either Entry or Asset
|
|
37
|
+
*/
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Link to another entity in a different space.
|
|
41
|
+
* @memberof Entities
|
|
42
|
+
* @typedef ResourceLink
|
|
43
|
+
* @prop {string} type - type of this entity. Always ResourceLink.
|
|
44
|
+
* @prop {string} urn
|
|
45
|
+
* @prop {string} linkType - type of this link. Always Contentful:Entry
|
|
46
|
+
*/
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* @memberof ContentfulClientAPI
|
|
50
|
+
* @typedef {Object} ClientAPI
|
|
51
|
+
* @prop {function} getSpace
|
|
52
|
+
* @prop {function} getContentType
|
|
53
|
+
* @prop {function} getTag
|
|
54
|
+
* @prop {function} getTags
|
|
55
|
+
* @prop {function} getContentTypes
|
|
56
|
+
* @prop {function} getEntry
|
|
57
|
+
* @prop {function} getEntries
|
|
58
|
+
* @prop {function} getAsset
|
|
59
|
+
* @prop {function} getAssets
|
|
60
|
+
* @prop {function} createAssetKey
|
|
61
|
+
* @prop {function} parseEntries
|
|
62
|
+
* @prop {function} sync
|
|
63
|
+
*/
|
|
64
|
+
|
|
65
|
+
import { createRequestConfig, errorHandler } from 'contentful-sdk-core';
|
|
66
|
+
import entities from './entities';
|
|
67
|
+
import pagedSync from './paged-sync';
|
|
68
|
+
import normalizeSelect from './utils/normalize-select';
|
|
69
|
+
import validateTimestamp from './utils/validate-timestamp';
|
|
18
70
|
const ASSET_KEY_MAX_LIFETIME = 48 * 60 * 60;
|
|
19
71
|
|
|
20
72
|
/**
|
|
@@ -27,36 +79,36 @@ const ASSET_KEY_MAX_LIFETIME = 48 * 60 * 60;
|
|
|
27
79
|
* @prop {Function} getGlobalOptions - Link resolver preconfigured with global setting
|
|
28
80
|
* @return {ClientAPI}
|
|
29
81
|
*/
|
|
30
|
-
function createContentfulApi(_ref) {
|
|
82
|
+
export default function createContentfulApi(_ref) {
|
|
31
83
|
let {
|
|
32
84
|
http,
|
|
33
85
|
getGlobalOptions
|
|
34
86
|
} = _ref;
|
|
35
87
|
const {
|
|
36
88
|
wrapSpace
|
|
37
|
-
} =
|
|
89
|
+
} = entities.space;
|
|
38
90
|
const {
|
|
39
91
|
wrapContentType,
|
|
40
92
|
wrapContentTypeCollection
|
|
41
|
-
} =
|
|
93
|
+
} = entities.contentType;
|
|
42
94
|
const {
|
|
43
95
|
wrapEntry,
|
|
44
96
|
wrapEntryCollection
|
|
45
|
-
} =
|
|
97
|
+
} = entities.entry;
|
|
46
98
|
const {
|
|
47
99
|
wrapAsset,
|
|
48
100
|
wrapAssetCollection
|
|
49
|
-
} =
|
|
101
|
+
} = entities.asset;
|
|
50
102
|
const {
|
|
51
103
|
wrapTag,
|
|
52
104
|
wrapTagCollection
|
|
53
|
-
} =
|
|
105
|
+
} = entities.tag;
|
|
54
106
|
const {
|
|
55
107
|
wrapAssetKey
|
|
56
|
-
} =
|
|
108
|
+
} = entities.assetKey;
|
|
57
109
|
const {
|
|
58
110
|
wrapLocaleCollection
|
|
59
|
-
} =
|
|
111
|
+
} = entities.locale;
|
|
60
112
|
const notFoundError = id => {
|
|
61
113
|
const error = new Error('The resource could not be found.');
|
|
62
114
|
error.sys = {
|
|
@@ -93,7 +145,7 @@ function createContentfulApi(_ref) {
|
|
|
93
145
|
const response = await http.get('/');
|
|
94
146
|
return wrapSpace(response.data);
|
|
95
147
|
} catch (error) {
|
|
96
|
-
|
|
148
|
+
errorHandler(error);
|
|
97
149
|
}
|
|
98
150
|
}
|
|
99
151
|
|
|
@@ -119,7 +171,7 @@ function createContentfulApi(_ref) {
|
|
|
119
171
|
const response = await http.get(`content_types/${id}`);
|
|
120
172
|
return wrapContentType(response.data);
|
|
121
173
|
} catch (error) {
|
|
122
|
-
|
|
174
|
+
errorHandler(error);
|
|
123
175
|
}
|
|
124
176
|
}
|
|
125
177
|
|
|
@@ -143,12 +195,12 @@ function createContentfulApi(_ref) {
|
|
|
143
195
|
let query = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
144
196
|
switchToEnvironment(http);
|
|
145
197
|
try {
|
|
146
|
-
const response = await http.get('content_types',
|
|
198
|
+
const response = await http.get('content_types', createRequestConfig({
|
|
147
199
|
query: query
|
|
148
200
|
}));
|
|
149
201
|
return wrapContentTypeCollection(response.data);
|
|
150
202
|
} catch (error) {
|
|
151
|
-
|
|
203
|
+
errorHandler(error);
|
|
152
204
|
}
|
|
153
205
|
}
|
|
154
206
|
|
|
@@ -184,7 +236,7 @@ function createContentfulApi(_ref) {
|
|
|
184
236
|
throw notFoundError(id);
|
|
185
237
|
}
|
|
186
238
|
} catch (error) {
|
|
187
|
-
|
|
239
|
+
errorHandler(error);
|
|
188
240
|
}
|
|
189
241
|
}
|
|
190
242
|
|
|
@@ -211,9 +263,9 @@ function createContentfulApi(_ref) {
|
|
|
211
263
|
resolveLinks,
|
|
212
264
|
removeUnresolved
|
|
213
265
|
} = getGlobalOptions(query);
|
|
214
|
-
query = (
|
|
266
|
+
query = normalizeSelect(query);
|
|
215
267
|
try {
|
|
216
|
-
const response = await http.get('entries',
|
|
268
|
+
const response = await http.get('entries', createRequestConfig({
|
|
217
269
|
query: query
|
|
218
270
|
}));
|
|
219
271
|
return wrapEntryCollection(response.data, {
|
|
@@ -221,7 +273,7 @@ function createContentfulApi(_ref) {
|
|
|
221
273
|
removeUnresolved
|
|
222
274
|
});
|
|
223
275
|
} catch (error) {
|
|
224
|
-
|
|
276
|
+
errorHandler(error);
|
|
225
277
|
}
|
|
226
278
|
}
|
|
227
279
|
/**
|
|
@@ -244,14 +296,14 @@ function createContentfulApi(_ref) {
|
|
|
244
296
|
async function getAsset(id) {
|
|
245
297
|
let query = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
246
298
|
switchToEnvironment(http);
|
|
247
|
-
query = (
|
|
299
|
+
query = normalizeSelect(query);
|
|
248
300
|
try {
|
|
249
|
-
const response = await http.get(`assets/${id}`,
|
|
301
|
+
const response = await http.get(`assets/${id}`, createRequestConfig({
|
|
250
302
|
query: query
|
|
251
303
|
}));
|
|
252
304
|
return wrapAsset(response.data);
|
|
253
305
|
} catch (error) {
|
|
254
|
-
|
|
306
|
+
errorHandler(error);
|
|
255
307
|
}
|
|
256
308
|
}
|
|
257
309
|
|
|
@@ -274,14 +326,14 @@ function createContentfulApi(_ref) {
|
|
|
274
326
|
async function getAssets() {
|
|
275
327
|
let query = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
276
328
|
switchToEnvironment(http);
|
|
277
|
-
query = (
|
|
329
|
+
query = normalizeSelect(query);
|
|
278
330
|
try {
|
|
279
|
-
const response = await http.get('assets',
|
|
331
|
+
const response = await http.get('assets', createRequestConfig({
|
|
280
332
|
query: query
|
|
281
333
|
}));
|
|
282
334
|
return wrapAssetCollection(response.data);
|
|
283
335
|
} catch (error) {
|
|
284
|
-
|
|
336
|
+
errorHandler(error);
|
|
285
337
|
}
|
|
286
338
|
}
|
|
287
339
|
|
|
@@ -307,7 +359,7 @@ function createContentfulApi(_ref) {
|
|
|
307
359
|
const response = await http.get(`tags/${id}`);
|
|
308
360
|
return wrapTag(response.data);
|
|
309
361
|
} catch (error) {
|
|
310
|
-
|
|
362
|
+
errorHandler(error);
|
|
311
363
|
}
|
|
312
364
|
}
|
|
313
365
|
|
|
@@ -330,14 +382,14 @@ function createContentfulApi(_ref) {
|
|
|
330
382
|
async function getTags() {
|
|
331
383
|
let query = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
332
384
|
switchToEnvironment(http);
|
|
333
|
-
query = (
|
|
385
|
+
query = normalizeSelect(query);
|
|
334
386
|
try {
|
|
335
|
-
const response = await http.get('tags',
|
|
387
|
+
const response = await http.get('tags', createRequestConfig({
|
|
336
388
|
query: query
|
|
337
389
|
}));
|
|
338
390
|
return wrapTagCollection(response.data);
|
|
339
391
|
} catch (error) {
|
|
340
|
-
|
|
392
|
+
errorHandler(error);
|
|
341
393
|
}
|
|
342
394
|
}
|
|
343
395
|
|
|
@@ -362,7 +414,7 @@ function createContentfulApi(_ref) {
|
|
|
362
414
|
try {
|
|
363
415
|
const now = Math.floor(Date.now() / 1000);
|
|
364
416
|
const currentMaxLifetime = now + ASSET_KEY_MAX_LIFETIME;
|
|
365
|
-
(
|
|
417
|
+
validateTimestamp('expiresAt', expiresAt, {
|
|
366
418
|
maximum: currentMaxLifetime,
|
|
367
419
|
now
|
|
368
420
|
});
|
|
@@ -372,7 +424,7 @@ function createContentfulApi(_ref) {
|
|
|
372
424
|
const response = await http.post('asset_keys', params);
|
|
373
425
|
return wrapAssetKey(response.data);
|
|
374
426
|
} catch (error) {
|
|
375
|
-
|
|
427
|
+
errorHandler(error);
|
|
376
428
|
}
|
|
377
429
|
}
|
|
378
430
|
|
|
@@ -396,12 +448,12 @@ function createContentfulApi(_ref) {
|
|
|
396
448
|
let query = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
397
449
|
switchToEnvironment(http);
|
|
398
450
|
try {
|
|
399
|
-
const response = await http.get('locales',
|
|
451
|
+
const response = await http.get('locales', createRequestConfig({
|
|
400
452
|
query: query
|
|
401
453
|
}));
|
|
402
454
|
return wrapLocaleCollection(response.data);
|
|
403
455
|
} catch (error) {
|
|
404
|
-
|
|
456
|
+
errorHandler(error);
|
|
405
457
|
}
|
|
406
458
|
}
|
|
407
459
|
|
|
@@ -448,7 +500,7 @@ function createContentfulApi(_ref) {
|
|
|
448
500
|
removeUnresolved
|
|
449
501
|
} = getGlobalOptions(query);
|
|
450
502
|
switchToEnvironment(http);
|
|
451
|
-
return (
|
|
503
|
+
return pagedSync(http, query, _objectSpread({
|
|
452
504
|
resolveLinks,
|
|
453
505
|
removeUnresolved
|
|
454
506
|
}, options));
|
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = createGlobalOptions;
|
|
7
1
|
/**
|
|
8
2
|
* Link resolution can be set globally, or it can be turned off for the methods
|
|
9
3
|
* which make use of it. The local setting always overrides the global setting.
|
|
@@ -11,7 +5,7 @@ exports.default = createGlobalOptions;
|
|
|
11
5
|
* @param {boolean} globalSetting - Global library setting for link resolution
|
|
12
6
|
* @returns {function} Link resolver method preconfigured with global setting
|
|
13
7
|
*/
|
|
14
|
-
function createGlobalOptions(globalSettings) {
|
|
8
|
+
export default function createGlobalOptions(globalSettings) {
|
|
15
9
|
/**
|
|
16
10
|
* Link resolver method
|
|
17
11
|
* @param {Object} query - regular query object used for collection endpoints
|
|
@@ -1,12 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import copy from 'fast-copy';
|
|
2
|
+
import { toPlainObject, freezeSys } from 'contentful-sdk-core';
|
|
2
3
|
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.wrapAssetKey = wrapAssetKey;
|
|
7
|
-
var _fastCopy = _interopRequireDefault(require("fast-copy"));
|
|
8
|
-
var _contentfulSdkCore = require("contentful-sdk-core");
|
|
9
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
4
|
/**
|
|
11
5
|
* @memberof Entities
|
|
12
6
|
* @typedef AssetKey
|
|
@@ -20,6 +14,6 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
20
14
|
* @param {Object} data - Raw asset key data
|
|
21
15
|
* @return {Asset} Wrapped asset key data
|
|
22
16
|
*/
|
|
23
|
-
function wrapAssetKey(data) {
|
|
24
|
-
return
|
|
17
|
+
export function wrapAssetKey(data) {
|
|
18
|
+
return freezeSys(toPlainObject(copy(data)));
|
|
25
19
|
}
|
|
@@ -1,13 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import copy from 'fast-copy';
|
|
2
|
+
import { toPlainObject, freezeSys } from 'contentful-sdk-core';
|
|
2
3
|
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.wrapAsset = wrapAsset;
|
|
7
|
-
exports.wrapAssetCollection = wrapAssetCollection;
|
|
8
|
-
var _fastCopy = _interopRequireDefault(require("fast-copy"));
|
|
9
|
-
var _contentfulSdkCore = require("contentful-sdk-core");
|
|
10
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
4
|
/**
|
|
12
5
|
* @memberof Entities
|
|
13
6
|
* @typedef Asset
|
|
@@ -29,8 +22,8 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
29
22
|
* @param {Object} data - Raw asset data
|
|
30
23
|
* @return {Asset} Wrapped asset data
|
|
31
24
|
*/
|
|
32
|
-
function wrapAsset(data) {
|
|
33
|
-
return
|
|
25
|
+
export function wrapAsset(data) {
|
|
26
|
+
return freezeSys(toPlainObject(copy(data)));
|
|
34
27
|
}
|
|
35
28
|
|
|
36
29
|
/**
|
|
@@ -48,6 +41,6 @@ function wrapAsset(data) {
|
|
|
48
41
|
* @param {Object} data - Raw asset collection data
|
|
49
42
|
* @return {AssetCollection} Wrapped asset collection data
|
|
50
43
|
*/
|
|
51
|
-
function wrapAssetCollection(data) {
|
|
52
|
-
return
|
|
44
|
+
export function wrapAssetCollection(data) {
|
|
45
|
+
return freezeSys(toPlainObject(copy(data)));
|
|
53
46
|
}
|
|
@@ -1,13 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import copy from 'fast-copy';
|
|
2
|
+
import { toPlainObject, freezeSys } from 'contentful-sdk-core';
|
|
2
3
|
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.wrapContentType = wrapContentType;
|
|
7
|
-
exports.wrapContentTypeCollection = wrapContentTypeCollection;
|
|
8
|
-
var _fastCopy = _interopRequireDefault(require("fast-copy"));
|
|
9
|
-
var _contentfulSdkCore = require("contentful-sdk-core");
|
|
10
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
4
|
/**
|
|
12
5
|
* @memberof Entities
|
|
13
6
|
* @typedef ContentType
|
|
@@ -24,8 +17,8 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
24
17
|
* @param {Object} data - Raw content type data
|
|
25
18
|
* @return {ContentType} Wrapped content type data
|
|
26
19
|
*/
|
|
27
|
-
function wrapContentType(data) {
|
|
28
|
-
return
|
|
20
|
+
export function wrapContentType(data) {
|
|
21
|
+
return freezeSys(toPlainObject(copy(data)));
|
|
29
22
|
}
|
|
30
23
|
|
|
31
24
|
/**
|
|
@@ -43,6 +36,6 @@ function wrapContentType(data) {
|
|
|
43
36
|
* @param {Object} data - Raw content type collection data
|
|
44
37
|
* @return {ContentTypeCollection} Wrapped content type collection data
|
|
45
38
|
*/
|
|
46
|
-
function wrapContentTypeCollection(data) {
|
|
47
|
-
return
|
|
39
|
+
export function wrapContentTypeCollection(data) {
|
|
40
|
+
return freezeSys(toPlainObject(copy(data)));
|
|
48
41
|
}
|
|
@@ -1,15 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
import copy from 'fast-copy';
|
|
2
|
+
import { toPlainObject, freezeSys } from 'contentful-sdk-core';
|
|
3
|
+
import mixinStringifySafe from '../mixins/stringify-safe';
|
|
4
|
+
import resolveResponse from 'contentful-resolve-response';
|
|
2
5
|
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.wrapEntry = wrapEntry;
|
|
7
|
-
exports.wrapEntryCollection = wrapEntryCollection;
|
|
8
|
-
var _fastCopy = _interopRequireDefault(require("fast-copy"));
|
|
9
|
-
var _contentfulSdkCore = require("contentful-sdk-core");
|
|
10
|
-
var _stringifySafe = _interopRequireDefault(require("../mixins/stringify-safe"));
|
|
11
|
-
var _contentfulResolveResponse = _interopRequireDefault(require("contentful-resolve-response"));
|
|
12
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
6
|
/**
|
|
14
7
|
* Types of fields found in an Entry
|
|
15
8
|
* @namespace EntryFields
|
|
@@ -80,8 +73,8 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
80
73
|
* @param {Object} data - Raw entry data
|
|
81
74
|
* @return {Entry} Wrapped entry data
|
|
82
75
|
*/
|
|
83
|
-
function wrapEntry(data) {
|
|
84
|
-
return
|
|
76
|
+
export function wrapEntry(data) {
|
|
77
|
+
return freezeSys(toPlainObject(copy(data)));
|
|
85
78
|
}
|
|
86
79
|
|
|
87
80
|
/**
|
|
@@ -104,17 +97,17 @@ function wrapEntry(data) {
|
|
|
104
97
|
* @param {Object} options - wrapper options
|
|
105
98
|
* @return {EntryCollection} Wrapped entry collection data
|
|
106
99
|
*/
|
|
107
|
-
function wrapEntryCollection(data, _ref) {
|
|
100
|
+
export function wrapEntryCollection(data, _ref) {
|
|
108
101
|
let {
|
|
109
102
|
resolveLinks,
|
|
110
103
|
removeUnresolved
|
|
111
104
|
} = _ref;
|
|
112
|
-
const wrappedData = (
|
|
105
|
+
const wrappedData = mixinStringifySafe(toPlainObject(copy(data)));
|
|
113
106
|
if (resolveLinks) {
|
|
114
|
-
wrappedData.items = (
|
|
107
|
+
wrappedData.items = resolveResponse(wrappedData, {
|
|
115
108
|
removeUnresolved,
|
|
116
109
|
itemEntryPoints: ['fields']
|
|
117
110
|
});
|
|
118
111
|
}
|
|
119
|
-
return
|
|
112
|
+
return freezeSys(wrappedData);
|
|
120
113
|
}
|
|
@@ -1,19 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
var asset = _interopRequireWildcard(require("./asset"));
|
|
10
|
-
var assetKey = _interopRequireWildcard(require("./asset-key"));
|
|
11
|
-
var contentType = _interopRequireWildcard(require("./content-type"));
|
|
12
|
-
var locale = _interopRequireWildcard(require("./locale"));
|
|
13
|
-
var tag = _interopRequireWildcard(require("./tag"));
|
|
14
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
15
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
16
|
-
var _default = {
|
|
1
|
+
import * as space from './space';
|
|
2
|
+
import * as entry from './entry';
|
|
3
|
+
import * as asset from './asset';
|
|
4
|
+
import * as assetKey from './asset-key';
|
|
5
|
+
import * as contentType from './content-type';
|
|
6
|
+
import * as locale from './locale';
|
|
7
|
+
import * as tag from './tag';
|
|
8
|
+
export default {
|
|
17
9
|
space,
|
|
18
10
|
entry,
|
|
19
11
|
asset,
|
|
@@ -21,5 +13,4 @@ var _default = {
|
|
|
21
13
|
contentType,
|
|
22
14
|
locale,
|
|
23
15
|
tag
|
|
24
|
-
};
|
|
25
|
-
exports.default = _default;
|
|
16
|
+
};
|
|
@@ -1,13 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import copy from 'fast-copy';
|
|
2
|
+
import { toPlainObject, freezeSys } from 'contentful-sdk-core';
|
|
2
3
|
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.wrapLocale = wrapLocale;
|
|
7
|
-
exports.wrapLocaleCollection = wrapLocaleCollection;
|
|
8
|
-
var _fastCopy = _interopRequireDefault(require("fast-copy"));
|
|
9
|
-
var _contentfulSdkCore = require("contentful-sdk-core");
|
|
10
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
4
|
/**
|
|
12
5
|
* @memberof Entities
|
|
13
6
|
* @typedef Locale
|
|
@@ -25,8 +18,8 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
25
18
|
* @param {Object} data - Raw locale data
|
|
26
19
|
* @return {Locale} Wrapped locale data
|
|
27
20
|
*/
|
|
28
|
-
function wrapLocale(data) {
|
|
29
|
-
return
|
|
21
|
+
export function wrapLocale(data) {
|
|
22
|
+
return freezeSys(toPlainObject(copy(data)));
|
|
30
23
|
}
|
|
31
24
|
|
|
32
25
|
/**
|
|
@@ -44,6 +37,6 @@ function wrapLocale(data) {
|
|
|
44
37
|
* @param {Object} data - Raw locale collection data
|
|
45
38
|
* @return {LocaleCollection} Wrapped locale collection data
|
|
46
39
|
*/
|
|
47
|
-
function wrapLocaleCollection(data) {
|
|
48
|
-
return
|
|
40
|
+
export function wrapLocaleCollection(data) {
|
|
41
|
+
return freezeSys(toPlainObject(copy(data)));
|
|
49
42
|
}
|
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import { toPlainObject, freezeSys } from 'contentful-sdk-core';
|
|
2
2
|
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.wrapSpace = wrapSpace;
|
|
7
|
-
var _contentfulSdkCore = require("contentful-sdk-core");
|
|
8
3
|
/**
|
|
9
4
|
* @memberof Entities
|
|
10
5
|
* @typedef Space
|
|
@@ -21,6 +16,6 @@ var _contentfulSdkCore = require("contentful-sdk-core");
|
|
|
21
16
|
* @param {Object} data - API response for a Space
|
|
22
17
|
* @return {Space}
|
|
23
18
|
*/
|
|
24
|
-
function wrapSpace(data) {
|
|
25
|
-
return
|
|
19
|
+
export function wrapSpace(data) {
|
|
20
|
+
return freezeSys(toPlainObject(data));
|
|
26
21
|
}
|
|
@@ -1,13 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import copy from 'fast-copy';
|
|
2
|
+
import { toPlainObject, freezeSys } from 'contentful-sdk-core';
|
|
2
3
|
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.wrapTag = wrapTag;
|
|
7
|
-
exports.wrapTagCollection = wrapTagCollection;
|
|
8
|
-
var _fastCopy = _interopRequireDefault(require("fast-copy"));
|
|
9
|
-
var _contentfulSdkCore = require("contentful-sdk-core");
|
|
10
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
4
|
/**
|
|
12
5
|
* @memberof Entities
|
|
13
6
|
* @typedef Tag
|
|
@@ -21,8 +14,8 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
21
14
|
* @param {Object} data - Raw tag data
|
|
22
15
|
* @return {Tag} Wrapped tag data
|
|
23
16
|
*/
|
|
24
|
-
function wrapTag(data) {
|
|
25
|
-
return
|
|
17
|
+
export function wrapTag(data) {
|
|
18
|
+
return freezeSys(toPlainObject(copy(data)));
|
|
26
19
|
}
|
|
27
20
|
|
|
28
21
|
/**
|
|
@@ -40,6 +33,6 @@ function wrapTag(data) {
|
|
|
40
33
|
* @param {Object} data - Raw tag collection data
|
|
41
34
|
* @return {TagCollection} Wrapped tag collection data
|
|
42
35
|
*/
|
|
43
|
-
function wrapTagCollection(data) {
|
|
44
|
-
return
|
|
36
|
+
export function wrapTagCollection(data) {
|
|
37
|
+
return freezeSys(toPlainObject(copy(data)));
|
|
45
38
|
}
|