contentful-management 11.59.0 → 11.60.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/README.md +12 -0
- package/dist/contentful-management.browser.js +511 -55
- package/dist/contentful-management.browser.js.map +1 -1
- package/dist/contentful-management.browser.min.js +1 -1
- package/dist/contentful-management.node.js +453 -55
- package/dist/contentful-management.node.js.map +1 -1
- package/dist/contentful-management.node.min.js +1 -1
- package/dist/es-modules/adapters/REST/endpoints/asset.js +35 -0
- package/dist/es-modules/adapters/REST/endpoints/entry.js +19 -0
- package/dist/es-modules/adapters/REST/endpoints/index.js +4 -0
- package/dist/es-modules/adapters/REST/endpoints/release-asset.js +176 -0
- package/dist/es-modules/adapters/REST/endpoints/release-entry.js +54 -0
- package/dist/es-modules/adapters/REST/endpoints/release.js +24 -0
- package/dist/es-modules/contentful-management.js +1 -1
- package/dist/es-modules/plain/plain-client.js +33 -0
- package/dist/typings/adapters/REST/endpoints/index.d.ts +4 -0
- package/dist/typings/adapters/REST/endpoints/release-asset.d.ts +9 -0
- package/dist/typings/adapters/REST/endpoints/release-entry.d.ts +7 -0
- package/dist/typings/common-types.d.ts +212 -9
- package/dist/typings/create-entry-api.d.ts +1 -1
- package/dist/typings/create-environment-api.d.ts +4 -4
- package/dist/typings/entities/asset.d.ts +3 -3
- package/dist/typings/entities/entry.d.ts +3 -3
- package/dist/typings/entities/release.d.ts +18 -1
- package/dist/typings/export-types.d.ts +1 -1
- package/dist/typings/plain/common-types.d.ts +81 -11
- package/dist/typings/plain/wrappers/wrap.d.ts +2 -0
- package/package.json +5 -1
|
@@ -13,7 +13,11 @@ import { getUploadHttpClient } from '../../../upload-http-client';
|
|
|
13
13
|
import * as raw from './raw';
|
|
14
14
|
import { create as createUpload } from './upload';
|
|
15
15
|
import { normalizeSelect } from './utils';
|
|
16
|
+
import * as releaseAsset from './release-asset';
|
|
16
17
|
export const get = (http, params, rawData, headers) => {
|
|
18
|
+
if (params.releaseId) {
|
|
19
|
+
return releaseAsset.get(http, params);
|
|
20
|
+
}
|
|
17
21
|
return raw.get(http, `/spaces/${params.spaceId}/environments/${params.environmentId}/assets/${params.assetId}`, {
|
|
18
22
|
params: normalizeSelect(params.query),
|
|
19
23
|
headers: headers ? _objectSpread({}, headers) : undefined
|
|
@@ -26,6 +30,9 @@ export const getPublished = (http, params, rawData, headers) => {
|
|
|
26
30
|
});
|
|
27
31
|
};
|
|
28
32
|
export const getMany = (http, params, rawData, headers) => {
|
|
33
|
+
if (params.releaseId) {
|
|
34
|
+
return releaseAsset.getMany(http, params);
|
|
35
|
+
}
|
|
29
36
|
return raw.get(http, `/spaces/${params.spaceId}/environments/${params.environmentId}/assets`, {
|
|
30
37
|
params: normalizeSelect(params.query),
|
|
31
38
|
headers: headers ? _objectSpread({}, headers) : undefined
|
|
@@ -33,6 +40,9 @@ export const getMany = (http, params, rawData, headers) => {
|
|
|
33
40
|
};
|
|
34
41
|
export const update = (http, params, rawData, headers) => {
|
|
35
42
|
var _rawData$sys$version;
|
|
43
|
+
if (params.releaseId) {
|
|
44
|
+
return releaseAsset.update(http, params, rawData, headers !== null && headers !== void 0 ? headers : {});
|
|
45
|
+
}
|
|
36
46
|
const data = copy(rawData);
|
|
37
47
|
delete data.sys;
|
|
38
48
|
return raw.put(http, `/spaces/${params.spaceId}/environments/${params.environmentId}/assets/${params.assetId}`, data, {
|
|
@@ -85,14 +95,23 @@ export const unarchive = (http, params) => {
|
|
|
85
95
|
return raw.del(http, `/spaces/${params.spaceId}/environments/${params.environmentId}/assets/${params.assetId}/archived`);
|
|
86
96
|
};
|
|
87
97
|
export const create = (http, params, rawData) => {
|
|
98
|
+
if (params.releaseId) {
|
|
99
|
+
return releaseAsset.create(http, params, rawData, {});
|
|
100
|
+
}
|
|
88
101
|
const data = copy(rawData);
|
|
89
102
|
return raw.post(http, `/spaces/${params.spaceId}/environments/${params.environmentId}/assets`, data);
|
|
90
103
|
};
|
|
91
104
|
export const createWithId = (http, params, rawData) => {
|
|
105
|
+
if (params.releaseId) {
|
|
106
|
+
return releaseAsset.createWithId(http, params, rawData, {});
|
|
107
|
+
}
|
|
92
108
|
const data = copy(rawData);
|
|
93
109
|
return raw.put(http, `/spaces/${params.spaceId}/environments/${params.environmentId}/assets/${params.assetId}`, data);
|
|
94
110
|
};
|
|
95
111
|
export const createFromFiles = async (http, params, data) => {
|
|
112
|
+
if (params.releaseId) {
|
|
113
|
+
return releaseAsset.createFromFiles(http, params, data, {});
|
|
114
|
+
}
|
|
96
115
|
const httpUpload = getUploadHttpClient(http, {
|
|
97
116
|
uploadTimeout: params.uploadTimeout
|
|
98
117
|
});
|
|
@@ -175,6 +194,16 @@ export const processForLocale = async (http, _ref) => {
|
|
|
175
194
|
} = {}
|
|
176
195
|
} = _ref,
|
|
177
196
|
params = _objectWithoutProperties(_ref, _excluded);
|
|
197
|
+
if (asset.sys.release) {
|
|
198
|
+
return releaseAsset.processForLocale(http, _objectSpread({
|
|
199
|
+
asset: asset,
|
|
200
|
+
locale,
|
|
201
|
+
options: {
|
|
202
|
+
processingCheckRetries,
|
|
203
|
+
processingCheckWait
|
|
204
|
+
}
|
|
205
|
+
}, params));
|
|
206
|
+
}
|
|
178
207
|
return raw.put(http, `/spaces/${params.spaceId}/environments/${params.environmentId}/assets/${asset.sys.id}/files/${locale}/process`, null, {
|
|
179
208
|
headers: {
|
|
180
209
|
'X-Contentful-Version': asset.sys.version
|
|
@@ -199,6 +228,12 @@ export const processForAllLocales = async (http, _ref2) => {
|
|
|
199
228
|
options = {}
|
|
200
229
|
} = _ref2,
|
|
201
230
|
params = _objectWithoutProperties(_ref2, _excluded2);
|
|
231
|
+
if (asset.sys.release) {
|
|
232
|
+
return releaseAsset.processForAllLocales(http, _objectSpread({
|
|
233
|
+
asset: asset,
|
|
234
|
+
options
|
|
235
|
+
}, params));
|
|
236
|
+
}
|
|
202
237
|
const locales = Object.keys(asset.fields.file || {});
|
|
203
238
|
let mostUpToDateAssetVersion = asset;
|
|
204
239
|
|
|
@@ -5,8 +5,12 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
|
|
|
5
5
|
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
6
6
|
import copy from 'fast-copy';
|
|
7
7
|
import * as raw from './raw';
|
|
8
|
+
import * as releaseEntry from './release-entry';
|
|
8
9
|
import { normalizeSelect } from './utils';
|
|
9
10
|
export const get = (http, params, rawData, headers) => {
|
|
11
|
+
if (params.releaseId) {
|
|
12
|
+
return releaseEntry.get(http, params);
|
|
13
|
+
}
|
|
10
14
|
return raw.get(http, `/spaces/${params.spaceId}/environments/${params.environmentId}/entries/${params.entryId}`, {
|
|
11
15
|
params: normalizeSelect(params.query),
|
|
12
16
|
headers: _objectSpread({}, headers)
|
|
@@ -19,12 +23,18 @@ export const getPublished = (http, params, rawData, headers) => {
|
|
|
19
23
|
});
|
|
20
24
|
};
|
|
21
25
|
export const getMany = (http, params, rawData, headers) => {
|
|
26
|
+
if (params.releaseId) {
|
|
27
|
+
return releaseEntry.getMany(http, params);
|
|
28
|
+
}
|
|
22
29
|
return raw.get(http, `/spaces/${params.spaceId}/environments/${params.environmentId}/entries`, {
|
|
23
30
|
params: normalizeSelect(params.query),
|
|
24
31
|
headers: _objectSpread({}, headers)
|
|
25
32
|
});
|
|
26
33
|
};
|
|
27
34
|
export const patch = (http, params, data, headers) => {
|
|
35
|
+
if (params.releaseId) {
|
|
36
|
+
return releaseEntry.patch(http, params, data, headers !== null && headers !== void 0 ? headers : {});
|
|
37
|
+
}
|
|
28
38
|
return raw.patch(http, `/spaces/${params.spaceId}/environments/${params.environmentId}/entries/${params.entryId}`, data, {
|
|
29
39
|
headers: _objectSpread({
|
|
30
40
|
'X-Contentful-Version': params.version,
|
|
@@ -34,6 +44,9 @@ export const patch = (http, params, data, headers) => {
|
|
|
34
44
|
};
|
|
35
45
|
export const update = (http, params, rawData, headers) => {
|
|
36
46
|
var _rawData$sys$version;
|
|
47
|
+
if (params.releaseId) {
|
|
48
|
+
return releaseEntry.update(http, params, rawData, headers !== null && headers !== void 0 ? headers : {});
|
|
49
|
+
}
|
|
37
50
|
const data = copy(rawData);
|
|
38
51
|
delete data.sys;
|
|
39
52
|
return raw.put(http, `/spaces/${params.spaceId}/environments/${params.environmentId}/entries/${params.entryId}`, data, {
|
|
@@ -86,6 +99,9 @@ export const unarchive = (http, params) => {
|
|
|
86
99
|
return raw.del(http, `/spaces/${params.spaceId}/environments/${params.environmentId}/entries/${params.entryId}/archived`);
|
|
87
100
|
};
|
|
88
101
|
export const create = (http, params, rawData) => {
|
|
102
|
+
if (params.releaseId) {
|
|
103
|
+
return releaseEntry.create(http, params, rawData, {});
|
|
104
|
+
}
|
|
89
105
|
const data = copy(rawData);
|
|
90
106
|
return raw.post(http, `/spaces/${params.spaceId}/environments/${params.environmentId}/entries`, data, {
|
|
91
107
|
headers: {
|
|
@@ -94,6 +110,9 @@ export const create = (http, params, rawData) => {
|
|
|
94
110
|
});
|
|
95
111
|
};
|
|
96
112
|
export const createWithId = (http, params, rawData) => {
|
|
113
|
+
if (params.releaseId) {
|
|
114
|
+
return releaseEntry.createWithId(http, params, rawData, {});
|
|
115
|
+
}
|
|
97
116
|
const data = copy(rawData);
|
|
98
117
|
return raw.put(http, `/spaces/${params.spaceId}/environments/${params.environmentId}/entries/${params.entryId}`, data, {
|
|
99
118
|
headers: {
|
|
@@ -39,6 +39,8 @@ import * as OAuthApplication from './oauth-application';
|
|
|
39
39
|
import * as PersonalAccessToken from './personal-access-token';
|
|
40
40
|
import * as PreviewApiKey from './preview-api-key';
|
|
41
41
|
import * as Release from './release';
|
|
42
|
+
import * as ReleaseAsset from './release-asset';
|
|
43
|
+
import * as ReleaseEntry from './release-entry';
|
|
42
44
|
import * as ReleaseAction from './release-action';
|
|
43
45
|
import * as Resource from './resource';
|
|
44
46
|
import * as ResourceProvider from './resource-provider';
|
|
@@ -106,6 +108,8 @@ export default {
|
|
|
106
108
|
AccessToken,
|
|
107
109
|
PreviewApiKey,
|
|
108
110
|
Release,
|
|
111
|
+
ReleaseAsset,
|
|
112
|
+
ReleaseEntry,
|
|
109
113
|
ReleaseAction,
|
|
110
114
|
Resource,
|
|
111
115
|
ResourceProvider,
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
const _excluded = ["asset", "locale", "options"],
|
|
2
|
+
_excluded2 = ["asset", "options"];
|
|
3
|
+
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
|
|
4
|
+
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
|
5
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
6
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
7
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
8
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
9
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
10
|
+
import { errorHandler } from 'contentful-sdk-core';
|
|
11
|
+
import copy from 'fast-copy';
|
|
12
|
+
import { getUploadHttpClient } from '../../../upload-http-client';
|
|
13
|
+
import * as raw from './raw';
|
|
14
|
+
import { create as createUpload } from './upload';
|
|
15
|
+
import { normalizeSelect } from './utils';
|
|
16
|
+
export const get = (http, params, rawData, headers) => {
|
|
17
|
+
return raw.get(http, `/spaces/${params.spaceId}/environments/${params.environmentId}/releases/${params.releaseId}/assets/${params.assetId}`, {
|
|
18
|
+
params: normalizeSelect(params.query),
|
|
19
|
+
headers: headers ? _objectSpread({}, headers) : undefined
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
export const getMany = (http, params, rawData, headers) => {
|
|
23
|
+
return raw.get(http, `/spaces/${params.spaceId}/environments/${params.environmentId}/releases/${params.releaseId}/assets`, {
|
|
24
|
+
params: normalizeSelect(params.query),
|
|
25
|
+
headers: headers ? _objectSpread({}, headers) : undefined
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
export const update = (http, params, rawData, headers) => {
|
|
29
|
+
var _rawData$sys$version;
|
|
30
|
+
const data = copy(rawData);
|
|
31
|
+
delete data.sys;
|
|
32
|
+
return raw.put(http, `/spaces/${params.spaceId}/environments/${params.environmentId}/releases/${params.releaseId}/assets/${params.assetId}`, data, {
|
|
33
|
+
headers: _objectSpread({
|
|
34
|
+
'X-Contentful-Version': (_rawData$sys$version = rawData.sys.version) !== null && _rawData$sys$version !== void 0 ? _rawData$sys$version : 0
|
|
35
|
+
}, headers)
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
export const create = (http, params, rawData, headers) => {
|
|
39
|
+
const data = copy(rawData);
|
|
40
|
+
return raw.post(http, `/spaces/${params.spaceId}/environments/${params.environmentId}/releases/${params.releaseId}/assets`, data, {
|
|
41
|
+
headers
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
export const createWithId = (http, params, rawData, headers) => {
|
|
45
|
+
const data = copy(rawData);
|
|
46
|
+
return raw.put(http, `/spaces/${params.spaceId}/environments/${params.environmentId}/releases/${params.releaseId}/assets/${params.assetId}`, data, {
|
|
47
|
+
headers
|
|
48
|
+
});
|
|
49
|
+
};
|
|
50
|
+
export const createFromFiles = async (http, params, data) => {
|
|
51
|
+
const httpUpload = getUploadHttpClient(http, {
|
|
52
|
+
uploadTimeout: params.uploadTimeout
|
|
53
|
+
});
|
|
54
|
+
const {
|
|
55
|
+
file
|
|
56
|
+
} = data.fields;
|
|
57
|
+
return Promise.all(Object.keys(file).map(async locale => {
|
|
58
|
+
const {
|
|
59
|
+
contentType,
|
|
60
|
+
fileName
|
|
61
|
+
} = file[locale];
|
|
62
|
+
return createUpload(httpUpload, params, file[locale]).then(upload => {
|
|
63
|
+
return {
|
|
64
|
+
[locale]: {
|
|
65
|
+
contentType,
|
|
66
|
+
fileName,
|
|
67
|
+
uploadFrom: {
|
|
68
|
+
sys: {
|
|
69
|
+
type: 'Link',
|
|
70
|
+
linkType: 'Upload',
|
|
71
|
+
id: upload.sys.id
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
});
|
|
77
|
+
})).then(uploads => {
|
|
78
|
+
const file = uploads.reduce((fieldsData, upload) => _objectSpread(_objectSpread({}, fieldsData), upload), {});
|
|
79
|
+
const asset = _objectSpread(_objectSpread({}, data), {}, {
|
|
80
|
+
fields: _objectSpread(_objectSpread({}, data.fields), {}, {
|
|
81
|
+
file
|
|
82
|
+
})
|
|
83
|
+
});
|
|
84
|
+
return create(http, params, asset, {});
|
|
85
|
+
}).catch(errorHandler);
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Asset processing
|
|
90
|
+
*/
|
|
91
|
+
|
|
92
|
+
const ASSET_PROCESSING_CHECK_WAIT = 3000;
|
|
93
|
+
const ASSET_PROCESSING_CHECK_RETRIES = 10;
|
|
94
|
+
async function checkIfAssetHasUrl(http, params, {
|
|
95
|
+
resolve,
|
|
96
|
+
reject,
|
|
97
|
+
locale,
|
|
98
|
+
processingCheckWait = ASSET_PROCESSING_CHECK_WAIT,
|
|
99
|
+
processingCheckRetries = ASSET_PROCESSING_CHECK_RETRIES,
|
|
100
|
+
checkCount = 0
|
|
101
|
+
}) {
|
|
102
|
+
return get(http, params).then(asset => {
|
|
103
|
+
if (asset.fields.file[locale].url) {
|
|
104
|
+
resolve(asset);
|
|
105
|
+
} else if (checkCount === processingCheckRetries) {
|
|
106
|
+
const error = new Error();
|
|
107
|
+
error.name = 'AssetProcessingTimeout';
|
|
108
|
+
error.message = 'Asset is taking longer then expected to process.';
|
|
109
|
+
reject(error);
|
|
110
|
+
} else {
|
|
111
|
+
checkCount++;
|
|
112
|
+
setTimeout(() => checkIfAssetHasUrl(http, params, {
|
|
113
|
+
resolve: resolve,
|
|
114
|
+
reject: reject,
|
|
115
|
+
locale: locale,
|
|
116
|
+
checkCount: checkCount,
|
|
117
|
+
processingCheckWait,
|
|
118
|
+
processingCheckRetries
|
|
119
|
+
}), processingCheckWait);
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
export const processForLocale = async (http, _ref) => {
|
|
124
|
+
let {
|
|
125
|
+
asset,
|
|
126
|
+
locale,
|
|
127
|
+
options: {
|
|
128
|
+
processingCheckRetries,
|
|
129
|
+
processingCheckWait
|
|
130
|
+
} = {}
|
|
131
|
+
} = _ref,
|
|
132
|
+
params = _objectWithoutProperties(_ref, _excluded);
|
|
133
|
+
return raw.put(http, `/spaces/${params.spaceId}/environments/${params.environmentId}/releases/${asset.sys.release.sys.id}/assets/${asset.sys.id}/files/${locale}/process`, null, {
|
|
134
|
+
headers: {
|
|
135
|
+
'X-Contentful-Version': asset.sys.version
|
|
136
|
+
}
|
|
137
|
+
}).then(() => {
|
|
138
|
+
return new Promise((resolve, reject) => checkIfAssetHasUrl(http, {
|
|
139
|
+
spaceId: params.spaceId,
|
|
140
|
+
environmentId: params.environmentId,
|
|
141
|
+
assetId: asset.sys.id,
|
|
142
|
+
releaseId: asset.sys.release.sys.id
|
|
143
|
+
}, {
|
|
144
|
+
resolve,
|
|
145
|
+
reject,
|
|
146
|
+
locale,
|
|
147
|
+
processingCheckWait,
|
|
148
|
+
processingCheckRetries
|
|
149
|
+
}));
|
|
150
|
+
});
|
|
151
|
+
};
|
|
152
|
+
export const processForAllLocales = async (http, _ref2) => {
|
|
153
|
+
let {
|
|
154
|
+
asset,
|
|
155
|
+
options = {}
|
|
156
|
+
} = _ref2,
|
|
157
|
+
params = _objectWithoutProperties(_ref2, _excluded2);
|
|
158
|
+
const locales = Object.keys(asset.fields.file || {});
|
|
159
|
+
let mostUpToDateAssetVersion = asset;
|
|
160
|
+
|
|
161
|
+
// Let all the locales process
|
|
162
|
+
// Since they all resolve at different times,
|
|
163
|
+
// we need to pick the last resolved value
|
|
164
|
+
// to reflect the most recent state
|
|
165
|
+
const allProcessingLocales = locales.map(locale => processForLocale(http, _objectSpread(_objectSpread({}, params), {}, {
|
|
166
|
+
asset,
|
|
167
|
+
locale,
|
|
168
|
+
options
|
|
169
|
+
})).then(result => {
|
|
170
|
+
// Side effect of always setting the most up to date asset version
|
|
171
|
+
// The last one to call this will be the last one that finished
|
|
172
|
+
// and thus the most up to date
|
|
173
|
+
mostUpToDateAssetVersion = result;
|
|
174
|
+
}));
|
|
175
|
+
return Promise.all(allProcessingLocales).then(() => mostUpToDateAssetVersion);
|
|
176
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
2
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
3
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
4
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
5
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
6
|
+
import copy from 'fast-copy';
|
|
7
|
+
import * as raw from './raw';
|
|
8
|
+
import { normalizeSelect } from './utils';
|
|
9
|
+
export const get = (http, params, rawData, headers) => {
|
|
10
|
+
return raw.get(http, `/spaces/${params.spaceId}/environments/${params.environmentId}/releases/${params.releaseId}/entries/${params.entryId}`, {
|
|
11
|
+
params: normalizeSelect(params.query),
|
|
12
|
+
headers: _objectSpread({}, headers)
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
export const getMany = (http, params, rawData, headers) => {
|
|
16
|
+
return raw.get(http, `/spaces/${params.spaceId}/environments/${params.environmentId}/releases/${params.releaseId}/entries`, {
|
|
17
|
+
params: normalizeSelect(params.query),
|
|
18
|
+
headers: _objectSpread({}, headers)
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
export const update = (http, params, rawData, headers) => {
|
|
22
|
+
var _rawData$sys$version;
|
|
23
|
+
const data = copy(rawData);
|
|
24
|
+
delete data.sys;
|
|
25
|
+
return raw.put(http, `/spaces/${params.spaceId}/environments/${params.environmentId}/releases/${params.releaseId}/entries/${params.entryId}`, data, {
|
|
26
|
+
headers: _objectSpread({
|
|
27
|
+
'X-Contentful-Version': (_rawData$sys$version = rawData.sys.version) !== null && _rawData$sys$version !== void 0 ? _rawData$sys$version : 0
|
|
28
|
+
}, headers)
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
export const patch = (http, params, data, headers) => {
|
|
32
|
+
return raw.patch(http, `/spaces/${params.spaceId}/environments/${params.environmentId}/releases/${params.releaseId}/entries/${params.entryId}`, data, {
|
|
33
|
+
headers: _objectSpread({
|
|
34
|
+
'X-Contentful-Version': params.version,
|
|
35
|
+
'Content-Type': 'application/json-patch+json'
|
|
36
|
+
}, headers)
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
export const create = (http, params, rawData, headers) => {
|
|
40
|
+
const data = copy(rawData);
|
|
41
|
+
return raw.post(http, `/spaces/${params.spaceId}/environments/${params.environmentId}/releases/${params.releaseId}/entries`, data, {
|
|
42
|
+
headers: _objectSpread({
|
|
43
|
+
'X-Contentful-Content-Type': params.contentTypeId
|
|
44
|
+
}, headers)
|
|
45
|
+
});
|
|
46
|
+
};
|
|
47
|
+
export const createWithId = (http, params, rawData, headers) => {
|
|
48
|
+
const data = copy(rawData);
|
|
49
|
+
return raw.put(http, `/spaces/${params.spaceId}/environments/${params.environmentId}/releases/${params.releaseId}/entries/${params.entryId}`, data, {
|
|
50
|
+
headers: _objectSpread({
|
|
51
|
+
'X-Contentful-Content-Type': params.contentTypeId
|
|
52
|
+
}, headers)
|
|
53
|
+
});
|
|
54
|
+
};
|
|
@@ -8,14 +8,38 @@ export const get = (http, params) => {
|
|
|
8
8
|
return raw.get(http, `/spaces/${params.spaceId}/environments/${params.environmentId}/releases/${params.releaseId}`);
|
|
9
9
|
};
|
|
10
10
|
export const query = (http, params) => {
|
|
11
|
+
var _ref, _params$query$sysSch, _params$query;
|
|
12
|
+
// Set the schema version in the query if provided in params or query options
|
|
13
|
+
const releaseSchemaVersion = (_ref = (_params$query$sysSch = (_params$query = params.query) === null || _params$query === void 0 ? void 0 : _params$query['sys.schemaVersion']) !== null && _params$query$sysSch !== void 0 ? _params$query$sysSch : params.releaseSchemaVersion) !== null && _ref !== void 0 ? _ref : undefined;
|
|
14
|
+
if (releaseSchemaVersion !== undefined) {
|
|
15
|
+
params.query = _objectSpread(_objectSpread({}, params.query), {}, {
|
|
16
|
+
'sys.schemaVersion': releaseSchemaVersion
|
|
17
|
+
});
|
|
18
|
+
}
|
|
11
19
|
return raw.get(http, `/spaces/${params.spaceId}/environments/${params.environmentId}/releases`, {
|
|
12
20
|
params: params.query
|
|
13
21
|
});
|
|
14
22
|
};
|
|
15
23
|
export const create = (http, params, payload) => {
|
|
24
|
+
var _payload$sys$schemaVe, _payload$sys;
|
|
25
|
+
const releaseSchemaVersion = (_payload$sys$schemaVe = (_payload$sys = payload.sys) === null || _payload$sys === void 0 ? void 0 : _payload$sys.schemaVersion) !== null && _payload$sys$schemaVe !== void 0 ? _payload$sys$schemaVe : params.releaseSchemaVersion;
|
|
26
|
+
if (releaseSchemaVersion === 'Release.v2') {
|
|
27
|
+
payload.sys = _objectSpread(_objectSpread({}, payload.sys), {}, {
|
|
28
|
+
type: 'Release',
|
|
29
|
+
schemaVersion: 'Release.v2'
|
|
30
|
+
});
|
|
31
|
+
}
|
|
16
32
|
return raw.post(http, `/spaces/${params.spaceId}/environments/${params.environmentId}/releases`, payload);
|
|
17
33
|
};
|
|
18
34
|
export const update = (http, params, payload, headers) => {
|
|
35
|
+
var _payload$sys$schemaVe2, _payload$sys2;
|
|
36
|
+
const releaseSchemaVersion = (_payload$sys$schemaVe2 = (_payload$sys2 = payload.sys) === null || _payload$sys2 === void 0 ? void 0 : _payload$sys2.schemaVersion) !== null && _payload$sys$schemaVe2 !== void 0 ? _payload$sys$schemaVe2 : params.releaseSchemaVersion;
|
|
37
|
+
if (releaseSchemaVersion === 'Release.v2') {
|
|
38
|
+
payload.sys = _objectSpread(_objectSpread({}, payload.sys), {}, {
|
|
39
|
+
type: 'Release',
|
|
40
|
+
schemaVersion: 'Release.v2'
|
|
41
|
+
});
|
|
42
|
+
}
|
|
19
43
|
return raw.put(http, `/spaces/${params.spaceId}/environments/${params.environmentId}/releases/${params.releaseId}`, payload, {
|
|
20
44
|
headers: _objectSpread({
|
|
21
45
|
'X-Contentful-Version': params.version
|
|
@@ -47,7 +47,7 @@ function createClient(params, opts = {}) {
|
|
|
47
47
|
const sdkMain = opts.type === 'plain' ? 'contentful-management-plain.js' : 'contentful-management.js';
|
|
48
48
|
const userAgent = getUserAgentHeader(
|
|
49
49
|
// @ts-expect-error
|
|
50
|
-
`${sdkMain}/${"11.
|
|
50
|
+
`${sdkMain}/${"11.60.1"}`, params.application, params.integration, params.feature);
|
|
51
51
|
const adapter = createAdapter(_objectSpread(_objectSpread({}, params), {}, {
|
|
52
52
|
userAgent
|
|
53
53
|
}));
|
|
@@ -346,6 +346,39 @@ export const createPlainClient = (makeRequest, defaults) => {
|
|
|
346
346
|
getManyForOrganization: wrap(wrapParams, 'Usage', 'getManyForOrganization')
|
|
347
347
|
},
|
|
348
348
|
release: {
|
|
349
|
+
asset: {
|
|
350
|
+
get: wrap(wrapParams, 'ReleaseAsset', 'get'),
|
|
351
|
+
getMany: wrap(wrapParams, 'ReleaseAsset', 'getMany'),
|
|
352
|
+
update: wrap(wrapParams, 'ReleaseAsset', 'update'),
|
|
353
|
+
create: wrap(wrapParams, 'ReleaseAsset', 'create'),
|
|
354
|
+
createWithId: wrap(wrapParams, 'ReleaseAsset', 'createWithId'),
|
|
355
|
+
createFromFiles: wrap(wrapParams, 'ReleaseAsset', 'createFromFiles'),
|
|
356
|
+
processForAllLocales: (params, asset, options) => makeRequest({
|
|
357
|
+
entityType: 'ReleaseAsset',
|
|
358
|
+
action: 'processForAllLocales',
|
|
359
|
+
params: _objectSpread(_objectSpread({}, _objectSpread(_objectSpread({}, defaults), params)), {}, {
|
|
360
|
+
options,
|
|
361
|
+
asset
|
|
362
|
+
})
|
|
363
|
+
}),
|
|
364
|
+
processForLocale: (params, asset, locale, options) => makeRequest({
|
|
365
|
+
entityType: 'ReleaseAsset',
|
|
366
|
+
action: 'processForLocale',
|
|
367
|
+
params: _objectSpread(_objectSpread({}, _objectSpread(_objectSpread({}, defaults), params)), {}, {
|
|
368
|
+
locale,
|
|
369
|
+
asset,
|
|
370
|
+
options
|
|
371
|
+
})
|
|
372
|
+
})
|
|
373
|
+
},
|
|
374
|
+
entry: {
|
|
375
|
+
get: wrap(wrapParams, 'ReleaseEntry', 'get'),
|
|
376
|
+
getMany: wrap(wrapParams, 'ReleaseEntry', 'getMany'),
|
|
377
|
+
update: wrap(wrapParams, 'ReleaseEntry', 'update'),
|
|
378
|
+
patch: wrap(wrapParams, 'ReleaseEntry', 'patch'),
|
|
379
|
+
create: wrap(wrapParams, 'ReleaseEntry', 'create'),
|
|
380
|
+
createWithId: wrap(wrapParams, 'ReleaseEntry', 'createWithId')
|
|
381
|
+
},
|
|
349
382
|
archive: wrap(wrapParams, 'Release', 'archive'),
|
|
350
383
|
get: wrap(wrapParams, 'Release', 'get'),
|
|
351
384
|
query: wrap(wrapParams, 'Release', 'query'),
|
|
@@ -39,6 +39,8 @@ import * as OAuthApplication from './oauth-application';
|
|
|
39
39
|
import * as PersonalAccessToken from './personal-access-token';
|
|
40
40
|
import * as PreviewApiKey from './preview-api-key';
|
|
41
41
|
import * as Release from './release';
|
|
42
|
+
import * as ReleaseAsset from './release-asset';
|
|
43
|
+
import * as ReleaseEntry from './release-entry';
|
|
42
44
|
import * as ReleaseAction from './release-action';
|
|
43
45
|
import * as Resource from './resource';
|
|
44
46
|
import * as ResourceProvider from './resource-provider';
|
|
@@ -106,6 +108,8 @@ declare const _default: {
|
|
|
106
108
|
AccessToken: typeof AccessToken;
|
|
107
109
|
PreviewApiKey: typeof PreviewApiKey;
|
|
108
110
|
Release: typeof Release;
|
|
111
|
+
ReleaseAsset: typeof ReleaseAsset;
|
|
112
|
+
ReleaseEntry: typeof ReleaseEntry;
|
|
109
113
|
ReleaseAction: typeof ReleaseAction;
|
|
110
114
|
Resource: typeof Resource;
|
|
111
115
|
ResourceProvider: typeof ResourceProvider;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { RestEndpoint } from '../types';
|
|
2
|
+
export declare const get: RestEndpoint<'ReleaseAsset', 'get'>;
|
|
3
|
+
export declare const getMany: RestEndpoint<'ReleaseAsset', 'getMany'>;
|
|
4
|
+
export declare const update: RestEndpoint<'ReleaseAsset', 'update'>;
|
|
5
|
+
export declare const create: RestEndpoint<'ReleaseAsset', 'create'>;
|
|
6
|
+
export declare const createWithId: RestEndpoint<'ReleaseAsset', 'createWithId'>;
|
|
7
|
+
export declare const createFromFiles: RestEndpoint<'ReleaseAsset', 'createFromFiles'>;
|
|
8
|
+
export declare const processForLocale: RestEndpoint<'ReleaseAsset', 'processForLocale'>;
|
|
9
|
+
export declare const processForAllLocales: RestEndpoint<'ReleaseAsset', 'processForAllLocales'>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { RestEndpoint } from '../types';
|
|
2
|
+
export declare const get: RestEndpoint<'ReleaseEntry', 'get'>;
|
|
3
|
+
export declare const getMany: RestEndpoint<'ReleaseEntry', 'getMany'>;
|
|
4
|
+
export declare const update: RestEndpoint<'ReleaseEntry', 'update'>;
|
|
5
|
+
export declare const patch: RestEndpoint<'ReleaseEntry', 'patch'>;
|
|
6
|
+
export declare const create: RestEndpoint<'ReleaseEntry', 'create'>;
|
|
7
|
+
export declare const createWithId: RestEndpoint<'ReleaseEntry', 'createWithId'>;
|