contentful-management 12.0.0-beta.1 → 12.0.0-beta.3
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 +3 -0
- package/dist/cjs/adapters/REST/endpoints/access-token.cjs +136 -0
- package/dist/cjs/adapters/REST/endpoints/ai-action-invocation.cjs +9 -0
- package/dist/cjs/adapters/REST/endpoints/ai-action.cjs +53 -0
- package/dist/cjs/adapters/REST/endpoints/api-key.cjs +48 -0
- package/dist/cjs/adapters/REST/endpoints/app-access-token.cjs +9 -0
- package/dist/cjs/adapters/REST/endpoints/app-action-call.cjs +65 -0
- package/dist/cjs/adapters/REST/endpoints/app-action.cjs +42 -0
- package/dist/cjs/adapters/REST/endpoints/app-bundle.cjs +39 -0
- package/dist/cjs/adapters/REST/endpoints/app-definition.cjs +47 -0
- package/dist/cjs/adapters/REST/endpoints/app-details.cjs +17 -0
- package/dist/cjs/adapters/REST/endpoints/app-event-subscription.cjs +17 -0
- package/dist/cjs/adapters/REST/endpoints/app-installation.cjs +42 -0
- package/dist/cjs/adapters/REST/endpoints/app-key.cjs +21 -0
- package/dist/cjs/adapters/REST/endpoints/app-signed-request.cjs +9 -0
- package/dist/cjs/adapters/REST/endpoints/app-signing-secret.cjs +17 -0
- package/dist/cjs/adapters/REST/endpoints/app-upload.cjs +28 -0
- package/dist/cjs/adapters/REST/endpoints/asset-key.cjs +34 -0
- package/dist/cjs/adapters/REST/endpoints/asset.cjs +185 -0
- package/dist/cjs/adapters/REST/endpoints/bulk-action.cjs +21 -0
- package/dist/cjs/adapters/REST/endpoints/comment.cjs +92 -0
- package/dist/cjs/adapters/REST/endpoints/concept-scheme.cjs +44 -0
- package/dist/cjs/adapters/REST/endpoints/concept.cjs +65 -0
- package/dist/cjs/adapters/REST/endpoints/content-type.cjs +56 -0
- package/dist/cjs/adapters/REST/endpoints/editor-interface.cjs +24 -0
- package/dist/cjs/adapters/REST/endpoints/entry.cjs +104 -0
- package/dist/cjs/adapters/REST/endpoints/environment-alias.cjs +44 -0
- package/dist/cjs/adapters/REST/endpoints/environment-template-installation.cjs +23 -0
- package/dist/cjs/adapters/REST/endpoints/environment-template.cjs +49 -0
- package/dist/cjs/adapters/REST/endpoints/environment.cjs +47 -0
- package/dist/cjs/adapters/REST/endpoints/extension.cjs +44 -0
- package/dist/cjs/adapters/REST/endpoints/function-log.cjs +23 -0
- package/dist/cjs/adapters/REST/endpoints/function.cjs +25 -0
- package/dist/cjs/adapters/REST/endpoints/http.cjs +29 -0
- package/dist/cjs/adapters/REST/endpoints/index.cjs +139 -0
- package/dist/cjs/adapters/REST/endpoints/locale.cjs +37 -0
- package/dist/cjs/adapters/REST/endpoints/oauth-application.cjs +147 -0
- package/dist/cjs/adapters/REST/endpoints/organization-invitation.cjs +23 -0
- package/dist/cjs/adapters/REST/endpoints/organization-membership.cjs +32 -0
- package/dist/cjs/adapters/REST/endpoints/organization.cjs +28 -0
- package/dist/cjs/adapters/REST/endpoints/personal-access-token.cjs +37 -0
- package/dist/cjs/adapters/REST/endpoints/preview-api-key.cjs +15 -0
- package/dist/cjs/adapters/REST/endpoints/raw.cjs +44 -0
- package/dist/cjs/adapters/REST/endpoints/release-action.cjs +21 -0
- package/dist/cjs/adapters/REST/endpoints/release.cjs +61 -0
- package/dist/cjs/adapters/REST/endpoints/resource-provider.cjs +18 -0
- package/dist/cjs/adapters/REST/endpoints/resource-type.cjs +30 -0
- package/dist/cjs/adapters/REST/endpoints/resource.cjs +10 -0
- package/dist/cjs/adapters/REST/endpoints/role.cjs +48 -0
- package/dist/cjs/adapters/REST/endpoints/scheduled-action.cjs +44 -0
- package/dist/cjs/adapters/REST/endpoints/snapshot.cjs +30 -0
- package/dist/cjs/adapters/REST/endpoints/space-member.cjs +11 -0
- package/dist/cjs/adapters/REST/endpoints/space-membership.cjs +60 -0
- package/dist/cjs/adapters/REST/endpoints/space.cjs +34 -0
- package/dist/cjs/adapters/REST/endpoints/tag.cjs +37 -0
- package/dist/cjs/adapters/REST/endpoints/task.cjs +40 -0
- package/dist/cjs/adapters/REST/endpoints/team-membership.cjs +35 -0
- package/dist/cjs/adapters/REST/endpoints/team-space-membership.cjs +46 -0
- package/dist/cjs/adapters/REST/endpoints/team.cjs +36 -0
- package/dist/cjs/adapters/REST/endpoints/ui-config.cjs +22 -0
- package/dist/cjs/adapters/REST/endpoints/upload-credentials.cjs +16 -0
- package/dist/cjs/adapters/REST/endpoints/upload.cjs +42 -0
- package/dist/cjs/adapters/REST/endpoints/usage.cjs +17 -0
- package/dist/cjs/adapters/REST/endpoints/user-ui-config.cjs +22 -0
- package/dist/cjs/adapters/REST/endpoints/user.cjs +27 -0
- package/dist/cjs/adapters/REST/endpoints/utils.cjs +20 -0
- package/dist/cjs/adapters/REST/endpoints/webhook.cjs +98 -0
- package/dist/cjs/adapters/REST/endpoints/workflow-definition.cjs +41 -0
- package/dist/cjs/adapters/REST/endpoints/workflow.cjs +49 -0
- package/dist/cjs/adapters/REST/endpoints/workflows-changelog.cjs +11 -0
- package/dist/cjs/adapters/REST/make-request.cjs +19 -0
- package/dist/cjs/adapters/REST/rest-adapter.cjs +32 -0
- package/dist/cjs/common-types.cjs +6 -0
- package/dist/cjs/common-utils.cjs +38 -0
- package/dist/cjs/constants/editor-interface-defaults/controls-defaults.cjs +161 -0
- package/dist/cjs/constants/editor-interface-defaults/editors-defaults.cjs +40 -0
- package/dist/cjs/constants/editor-interface-defaults/index.cjs +14 -0
- package/dist/cjs/constants/editor-interface-defaults/sidebar-defaults.cjs +71 -0
- package/dist/cjs/constants/editor-interface-defaults/types.cjs +18 -0
- package/dist/cjs/create-adapter.cjs +21 -0
- package/dist/cjs/create-app-definition-api.cjs +254 -0
- package/dist/cjs/create-contentful-api.cjs +592 -0
- package/dist/cjs/create-entry-api.cjs +481 -0
- package/dist/cjs/create-environment-api.cjs +2403 -0
- package/dist/cjs/create-environment-template-api.cjs +270 -0
- package/dist/cjs/create-organization-api.cjs +1136 -0
- package/dist/cjs/create-space-api.cjs +1591 -0
- package/dist/cjs/create-ui-config-api.cjs +55 -0
- package/dist/cjs/create-user-ui-config-api.cjs +55 -0
- package/dist/cjs/enhance-with-methods.cjs +26 -0
- package/dist/cjs/entities/access-token.cjs +36 -0
- package/dist/cjs/entities/ai-action-invocation.cjs +46 -0
- package/dist/cjs/entities/ai-action.cjs +94 -0
- package/dist/cjs/entities/api-key.cjs +59 -0
- package/dist/cjs/entities/app-access-token.cjs +17 -0
- package/dist/cjs/entities/app-action-call.cjs +67 -0
- package/dist/cjs/entities/app-action.cjs +48 -0
- package/dist/cjs/entities/app-bundle.cjs +48 -0
- package/dist/cjs/entities/app-definition.cjs +29 -0
- package/dist/cjs/entities/app-details.cjs +39 -0
- package/dist/cjs/entities/app-event-subscription.cjs +34 -0
- package/dist/cjs/entities/app-installation.cjs +55 -0
- package/dist/cjs/entities/app-key.cjs +44 -0
- package/dist/cjs/entities/app-signed-request.cjs +17 -0
- package/dist/cjs/entities/app-signing-secret.cjs +34 -0
- package/dist/cjs/entities/app-upload.cjs +47 -0
- package/dist/cjs/entities/asset-key.cjs +17 -0
- package/dist/cjs/entities/asset.cjs +124 -0
- package/dist/cjs/entities/bulk-action.cjs +60 -0
- package/dist/cjs/entities/comment.cjs +63 -0
- package/dist/cjs/entities/concept-scheme.cjs +2 -0
- package/dist/cjs/entities/concept.cjs +2 -0
- package/dist/cjs/entities/content-type.cjs +120 -0
- package/dist/cjs/entities/editor-interface.cjs +50 -0
- package/dist/cjs/entities/entry.cjs +27 -0
- package/dist/cjs/entities/environment-alias.cjs +58 -0
- package/dist/cjs/entities/environment-template-installation.cjs +23 -0
- package/dist/cjs/entities/environment-template.cjs +18 -0
- package/dist/cjs/entities/environment.cjs +34 -0
- package/dist/cjs/entities/extension.cjs +54 -0
- package/dist/cjs/entities/function-log.cjs +26 -0
- package/dist/cjs/entities/function.cjs +66 -0
- package/dist/cjs/entities/index.cjs +131 -0
- package/dist/cjs/entities/locale.cjs +57 -0
- package/dist/cjs/entities/oauth-application.cjs +66 -0
- package/dist/cjs/entities/organization-invitation.cjs +17 -0
- package/dist/cjs/entities/organization-membership.cjs +53 -0
- package/dist/cjs/entities/organization.cjs +32 -0
- package/dist/cjs/entities/personal-access-token.cjs +36 -0
- package/dist/cjs/entities/preview-api-key.cjs +31 -0
- package/dist/cjs/entities/release-action.cjs +55 -0
- package/dist/cjs/entities/release.cjs +111 -0
- package/dist/cjs/entities/resource-provider.cjs +139 -0
- package/dist/cjs/entities/resource-type.cjs +98 -0
- package/dist/cjs/entities/resource.cjs +13 -0
- package/dist/cjs/entities/role.cjs +53 -0
- package/dist/cjs/entities/scheduled-action.cjs +154 -0
- package/dist/cjs/entities/snapshot.cjs +36 -0
- package/dist/cjs/entities/space-member.cjs +23 -0
- package/dist/cjs/entities/space-membership.cjs +53 -0
- package/dist/cjs/entities/space.cjs +33 -0
- package/dist/cjs/entities/tag.cjs +56 -0
- package/dist/cjs/entities/task.cjs +57 -0
- package/dist/cjs/entities/team-membership.cjs +54 -0
- package/dist/cjs/entities/team-space-membership.cjs +53 -0
- package/dist/cjs/entities/team.cjs +53 -0
- package/dist/cjs/entities/ui-config.cjs +20 -0
- package/dist/cjs/entities/upload.cjs +38 -0
- package/dist/cjs/entities/usage.cjs +25 -0
- package/dist/cjs/entities/user-ui-config.cjs +20 -0
- package/dist/cjs/entities/user.cjs +28 -0
- package/dist/cjs/entities/webhook.cjs +77 -0
- package/dist/cjs/entities/workflow-definition.cjs +79 -0
- package/dist/cjs/index.cjs +65 -0
- package/dist/cjs/methods/action.cjs +53 -0
- package/dist/cjs/methods/content-type.cjs +51 -0
- package/dist/cjs/methods/utils.cjs +11 -0
- package/dist/cjs/plain/as-iterator.cjs +32 -0
- package/dist/cjs/plain/checks.cjs +15 -0
- package/dist/cjs/plain/pagination-helper.cjs +56 -0
- package/dist/cjs/plain/plain-client.cjs +516 -0
- package/dist/cjs/plain/wrappers/wrap.cjs +26 -0
- package/dist/cjs/upload-http-client.cjs +17 -0
- package/dist/contentful-management.browser.js +50 -34
- package/dist/contentful-management.browser.min.js +1 -1
- package/dist/contentful-management.cjs +35 -19
- package/dist/esm/create-contentful-api.js +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/plain/plain-client.js +1 -1
- package/dist/stats-browser-min.html +1 -1
- package/package.json +6 -6
- package/types.d.ts +0 -1
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var tslib = require('tslib');
|
|
4
|
+
var contentfulSdkCore = require('contentful-sdk-core');
|
|
5
|
+
var copy = require('fast-copy');
|
|
6
|
+
var uploadHttpClient = require('../../../upload-http-client.js');
|
|
7
|
+
var raw = require('./raw.js');
|
|
8
|
+
var upload = require('./upload.js');
|
|
9
|
+
var utils = require('./utils.js');
|
|
10
|
+
|
|
11
|
+
const get = (http, params, rawData, headers) => {
|
|
12
|
+
return raw.get(http, `/spaces/${params.spaceId}/environments/${params.environmentId}/assets/${params.assetId}`, {
|
|
13
|
+
params: utils.normalizeSelect(params.query),
|
|
14
|
+
headers: headers ? Object.assign({}, headers) : undefined,
|
|
15
|
+
});
|
|
16
|
+
};
|
|
17
|
+
const getPublished = (http, params, rawData, headers) => {
|
|
18
|
+
return raw.get(http, `/spaces/${params.spaceId}/environments/${params.environmentId}/public/assets`, {
|
|
19
|
+
params: utils.normalizeSelect(params.query),
|
|
20
|
+
headers: headers ? Object.assign({}, headers) : undefined,
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
const getMany = (http, params, rawData, headers) => {
|
|
24
|
+
return raw.get(http, `/spaces/${params.spaceId}/environments/${params.environmentId}/assets`, {
|
|
25
|
+
params: utils.normalizeSelect(params.query),
|
|
26
|
+
headers: headers ? Object.assign({}, headers) : undefined,
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
const update = (http, params, rawData, headers) => {
|
|
30
|
+
var _a;
|
|
31
|
+
const data = copy(rawData);
|
|
32
|
+
delete data.sys;
|
|
33
|
+
return raw.put(http, `/spaces/${params.spaceId}/environments/${params.environmentId}/assets/${params.assetId}`, data, {
|
|
34
|
+
headers: Object.assign({ 'X-Contentful-Version': (_a = rawData.sys.version) !== null && _a !== void 0 ? _a : 0 }, headers),
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
const del = (http, params) => {
|
|
38
|
+
return raw.del(http, `/spaces/${params.spaceId}/environments/${params.environmentId}/assets/${params.assetId}`);
|
|
39
|
+
};
|
|
40
|
+
const publish = (http, params, rawData) => {
|
|
41
|
+
var _a, _b;
|
|
42
|
+
const payload = ((_a = params.locales) === null || _a === void 0 ? void 0 : _a.length) ? { add: { fields: { '*': params.locales } } } : null;
|
|
43
|
+
return raw.put(http, `/spaces/${params.spaceId}/environments/${params.environmentId}/assets/${params.assetId}/published`, payload, {
|
|
44
|
+
headers: {
|
|
45
|
+
'X-Contentful-Version': (_b = rawData.sys.version) !== null && _b !== void 0 ? _b : 0,
|
|
46
|
+
},
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
const unpublish = (http, params, rawData) => {
|
|
50
|
+
var _a;
|
|
51
|
+
if ((_a = params.locales) === null || _a === void 0 ? void 0 : _a.length) {
|
|
52
|
+
const payload = { remove: { fields: { '*': params.locales } } };
|
|
53
|
+
return raw.put(http, `/spaces/${params.spaceId}/environments/${params.environmentId}/assets/${params.assetId}/published`, payload, {
|
|
54
|
+
headers: {
|
|
55
|
+
'X-Contentful-Version': rawData === null || rawData === void 0 ? void 0 : rawData.sys.version,
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
return raw.del(http, `/spaces/${params.spaceId}/environments/${params.environmentId}/assets/${params.assetId}/published`);
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
const archive = (http, params) => {
|
|
64
|
+
return raw.put(http, `/spaces/${params.spaceId}/environments/${params.environmentId}/assets/${params.assetId}/archived`);
|
|
65
|
+
};
|
|
66
|
+
const unarchive = (http, params) => {
|
|
67
|
+
return raw.del(http, `/spaces/${params.spaceId}/environments/${params.environmentId}/assets/${params.assetId}/archived`);
|
|
68
|
+
};
|
|
69
|
+
const create = (http, params, rawData) => {
|
|
70
|
+
const data = copy(rawData);
|
|
71
|
+
return raw.post(http, `/spaces/${params.spaceId}/environments/${params.environmentId}/assets`, data);
|
|
72
|
+
};
|
|
73
|
+
const createWithId = (http, params, rawData) => {
|
|
74
|
+
const data = copy(rawData);
|
|
75
|
+
return raw.put(http, `/spaces/${params.spaceId}/environments/${params.environmentId}/assets/${params.assetId}`, data);
|
|
76
|
+
};
|
|
77
|
+
const createFromFiles = async (http, params, data) => {
|
|
78
|
+
const httpUpload = uploadHttpClient.getUploadHttpClient(http, { uploadTimeout: params.uploadTimeout });
|
|
79
|
+
const { file } = data.fields;
|
|
80
|
+
return Promise.all(Object.keys(file).map(async (locale) => {
|
|
81
|
+
const { contentType, fileName } = file[locale];
|
|
82
|
+
return upload.create(httpUpload, params, file[locale]).then((upload) => {
|
|
83
|
+
return {
|
|
84
|
+
[locale]: {
|
|
85
|
+
contentType,
|
|
86
|
+
fileName,
|
|
87
|
+
uploadFrom: {
|
|
88
|
+
sys: {
|
|
89
|
+
type: 'Link',
|
|
90
|
+
linkType: 'Upload',
|
|
91
|
+
id: upload.sys.id,
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
};
|
|
96
|
+
});
|
|
97
|
+
}))
|
|
98
|
+
.then((uploads) => {
|
|
99
|
+
const file = uploads.reduce((fieldsData, upload) => (Object.assign(Object.assign({}, fieldsData), upload)), {});
|
|
100
|
+
const asset = Object.assign(Object.assign({}, data), { fields: Object.assign(Object.assign({}, data.fields), { file }) });
|
|
101
|
+
return create(http, params, asset);
|
|
102
|
+
})
|
|
103
|
+
.catch(contentfulSdkCore.errorHandler);
|
|
104
|
+
};
|
|
105
|
+
/**
|
|
106
|
+
* Asset processing
|
|
107
|
+
*/
|
|
108
|
+
const ASSET_PROCESSING_CHECK_WAIT = 3000;
|
|
109
|
+
const ASSET_PROCESSING_CHECK_RETRIES = 10;
|
|
110
|
+
async function checkIfAssetHasUrl(http, params, { resolve, reject, locale, processingCheckWait = ASSET_PROCESSING_CHECK_WAIT, processingCheckRetries = ASSET_PROCESSING_CHECK_RETRIES, checkCount = 0, }) {
|
|
111
|
+
return get(http, params).then((asset) => {
|
|
112
|
+
if (asset.fields.file[locale].url) {
|
|
113
|
+
resolve(asset);
|
|
114
|
+
}
|
|
115
|
+
else if (checkCount === processingCheckRetries) {
|
|
116
|
+
const error = new Error();
|
|
117
|
+
error.name = 'AssetProcessingTimeout';
|
|
118
|
+
error.message = 'Asset is taking longer then expected to process.';
|
|
119
|
+
reject(error);
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
checkCount++;
|
|
123
|
+
setTimeout(() => checkIfAssetHasUrl(http, params, {
|
|
124
|
+
resolve: resolve,
|
|
125
|
+
reject: reject,
|
|
126
|
+
locale: locale,
|
|
127
|
+
checkCount: checkCount,
|
|
128
|
+
processingCheckWait,
|
|
129
|
+
processingCheckRetries,
|
|
130
|
+
}), processingCheckWait);
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
const processForLocale = async (http, _a) => {
|
|
135
|
+
var { asset, locale, options: { processingCheckRetries, processingCheckWait } = {} } = _a, params = tslib.__rest(_a, ["asset", "locale", "options"]);
|
|
136
|
+
return raw.put(http, `/spaces/${params.spaceId}/environments/${params.environmentId}/assets/${asset.sys.id}/files/${locale}/process`, null, {
|
|
137
|
+
headers: {
|
|
138
|
+
'X-Contentful-Version': asset.sys.version,
|
|
139
|
+
},
|
|
140
|
+
})
|
|
141
|
+
.then(() => {
|
|
142
|
+
return new Promise((resolve, reject) => checkIfAssetHasUrl(http, {
|
|
143
|
+
spaceId: params.spaceId,
|
|
144
|
+
environmentId: params.environmentId,
|
|
145
|
+
assetId: asset.sys.id,
|
|
146
|
+
}, {
|
|
147
|
+
resolve,
|
|
148
|
+
reject,
|
|
149
|
+
locale,
|
|
150
|
+
processingCheckWait,
|
|
151
|
+
processingCheckRetries,
|
|
152
|
+
}));
|
|
153
|
+
});
|
|
154
|
+
};
|
|
155
|
+
const processForAllLocales = async (http, _a) => {
|
|
156
|
+
var { asset, options = {} } = _a, params = tslib.__rest(_a, ["asset", "options"]);
|
|
157
|
+
const locales = Object.keys(asset.fields.file || {});
|
|
158
|
+
let mostUpToDateAssetVersion = asset;
|
|
159
|
+
// Let all the locales process
|
|
160
|
+
// Since they all resolve at different times,
|
|
161
|
+
// we need to pick the last resolved value
|
|
162
|
+
// to reflect the most recent state
|
|
163
|
+
const allProcessingLocales = locales.map((locale) => processForLocale(http, Object.assign(Object.assign({}, params), { asset, locale, options })).then((result) => {
|
|
164
|
+
// Side effect of always setting the most up to date asset version
|
|
165
|
+
// The last one to call this will be the last one that finished
|
|
166
|
+
// and thus the most up to date
|
|
167
|
+
mostUpToDateAssetVersion = result;
|
|
168
|
+
}));
|
|
169
|
+
return Promise.all(allProcessingLocales).then(() => mostUpToDateAssetVersion);
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
exports.archive = archive;
|
|
173
|
+
exports.create = create;
|
|
174
|
+
exports.createFromFiles = createFromFiles;
|
|
175
|
+
exports.createWithId = createWithId;
|
|
176
|
+
exports.del = del;
|
|
177
|
+
exports.get = get;
|
|
178
|
+
exports.getMany = getMany;
|
|
179
|
+
exports.getPublished = getPublished;
|
|
180
|
+
exports.processForAllLocales = processForAllLocales;
|
|
181
|
+
exports.processForLocale = processForLocale;
|
|
182
|
+
exports.publish = publish;
|
|
183
|
+
exports.unarchive = unarchive;
|
|
184
|
+
exports.unpublish = unpublish;
|
|
185
|
+
exports.update = update;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var raw = require('./raw.js');
|
|
4
|
+
|
|
5
|
+
const get = (http, params) => {
|
|
6
|
+
return raw.get(http, `/spaces/${params.spaceId}/environments/${params.environmentId}/bulk_actions/actions/${params.bulkActionId}`);
|
|
7
|
+
};
|
|
8
|
+
const publish = (http, params, payload) => {
|
|
9
|
+
return raw.post(http, `/spaces/${params.spaceId}/environments/${params.environmentId}/bulk_actions/publish`, payload);
|
|
10
|
+
};
|
|
11
|
+
const unpublish = (http, params, payload) => {
|
|
12
|
+
return raw.post(http, `/spaces/${params.spaceId}/environments/${params.environmentId}/bulk_actions/unpublish`, payload);
|
|
13
|
+
};
|
|
14
|
+
const validate = (http, params, payload) => {
|
|
15
|
+
return raw.post(http, `/spaces/${params.spaceId}/environments/${params.environmentId}/bulk_actions/validate`, payload);
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
exports.get = get;
|
|
19
|
+
exports.publish = publish;
|
|
20
|
+
exports.unpublish = unpublish;
|
|
21
|
+
exports.validate = validate;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var tslib = require('tslib');
|
|
4
|
+
var copy = require('fast-copy');
|
|
5
|
+
var raw = require('./raw.js');
|
|
6
|
+
var utils = require('./utils.js');
|
|
7
|
+
|
|
8
|
+
const VERSION_HEADER = 'X-Contentful-Version';
|
|
9
|
+
const BODY_FORMAT_HEADER = 'x-contentful-comment-body-format';
|
|
10
|
+
const PARENT_ENTITY_REFERENCE_HEADER = 'x-contentful-parent-entity-reference';
|
|
11
|
+
const PARENT_COMMENT_ID_HEADER = 'x-contentful-parent-id';
|
|
12
|
+
const getSpaceEnvBaseUrl = (params) => `/spaces/${params.spaceId}/environments/${params.environmentId}`;
|
|
13
|
+
const getEntityCommentUrl = (params) => `${getEntityBaseUrl(params)}/${params.commentId}`;
|
|
14
|
+
function getParentPlural(parentEntityType) {
|
|
15
|
+
switch (parentEntityType) {
|
|
16
|
+
case 'ContentType':
|
|
17
|
+
return 'content_types';
|
|
18
|
+
case 'Entry':
|
|
19
|
+
return 'entries';
|
|
20
|
+
case 'Workflow':
|
|
21
|
+
return 'workflows';
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Comments can be added to a content type, an entry, and a workflow. Workflow comments requires a version
|
|
26
|
+
* to be set as part of the URL path. Workflow comments only support `create` (with
|
|
27
|
+
* versionized URL) and `getMany` (without version). The API might support more methods
|
|
28
|
+
* in the future with new use cases being discovered.
|
|
29
|
+
*/
|
|
30
|
+
const getEntityBaseUrl = (paramsOrg) => {
|
|
31
|
+
const params = 'entryId' in paramsOrg
|
|
32
|
+
? {
|
|
33
|
+
spaceId: paramsOrg.spaceId,
|
|
34
|
+
environmentId: paramsOrg.environmentId,
|
|
35
|
+
parentEntityType: 'Entry',
|
|
36
|
+
parentEntityId: paramsOrg.entryId,
|
|
37
|
+
}
|
|
38
|
+
: paramsOrg;
|
|
39
|
+
const { parentEntityId, parentEntityType } = params;
|
|
40
|
+
const parentPlural = getParentPlural(parentEntityType);
|
|
41
|
+
const versionPath = 'parentEntityVersion' in params ? `/versions/${params.parentEntityVersion}` : '';
|
|
42
|
+
return `${getSpaceEnvBaseUrl(params)}/${parentPlural}/${parentEntityId}${versionPath}/comments`;
|
|
43
|
+
};
|
|
44
|
+
const get = (http, params) => raw.get(http, getEntityCommentUrl(params), {
|
|
45
|
+
headers: params.bodyFormat === 'rich-text'
|
|
46
|
+
? {
|
|
47
|
+
[BODY_FORMAT_HEADER]: params.bodyFormat,
|
|
48
|
+
}
|
|
49
|
+
: {},
|
|
50
|
+
});
|
|
51
|
+
const getMany = (http, params) => raw.get(http, getEntityBaseUrl(params), {
|
|
52
|
+
params: utils.normalizeSelect(params.query),
|
|
53
|
+
headers: params.bodyFormat === 'rich-text'
|
|
54
|
+
? {
|
|
55
|
+
[BODY_FORMAT_HEADER]: params.bodyFormat,
|
|
56
|
+
}
|
|
57
|
+
: {},
|
|
58
|
+
});
|
|
59
|
+
const create = (http, params, rawData) => {
|
|
60
|
+
const data = copy(rawData);
|
|
61
|
+
return raw.post(http, getEntityBaseUrl(params), data, {
|
|
62
|
+
headers: Object.assign(Object.assign(Object.assign({}, (typeof rawData.body !== 'string' ? { [BODY_FORMAT_HEADER]: 'rich-text' } : {})), ('parentEntityReference' in params && params.parentEntityReference
|
|
63
|
+
? { [PARENT_ENTITY_REFERENCE_HEADER]: params.parentEntityReference }
|
|
64
|
+
: {})), (params.parentCommentId ? { [PARENT_COMMENT_ID_HEADER]: params.parentCommentId } : {})),
|
|
65
|
+
});
|
|
66
|
+
};
|
|
67
|
+
const update = (http, params, rawData, headers) => {
|
|
68
|
+
var _a;
|
|
69
|
+
const data = copy(rawData);
|
|
70
|
+
delete data.sys;
|
|
71
|
+
return raw.put(http, getEntityCommentUrl(params), data, {
|
|
72
|
+
headers: Object.assign(Object.assign({ [VERSION_HEADER]: (_a = rawData.sys.version) !== null && _a !== void 0 ? _a : 0 }, (typeof rawData.body !== 'string' ? { [BODY_FORMAT_HEADER]: 'rich-text' } : {})), headers),
|
|
73
|
+
});
|
|
74
|
+
};
|
|
75
|
+
const del = (http, _a) => {
|
|
76
|
+
var { version } = _a, params = tslib.__rest(_a, ["version"]);
|
|
77
|
+
return raw.del(http, getEntityCommentUrl(params), {
|
|
78
|
+
headers: { [VERSION_HEADER]: version },
|
|
79
|
+
});
|
|
80
|
+
};
|
|
81
|
+
// Add a deprecation notice. But `getAll` may never be removed for app compatibility reasons.
|
|
82
|
+
/**
|
|
83
|
+
* @deprecated use `getMany` instead.
|
|
84
|
+
*/
|
|
85
|
+
const getAll = getMany;
|
|
86
|
+
|
|
87
|
+
exports.create = create;
|
|
88
|
+
exports.del = del;
|
|
89
|
+
exports.get = get;
|
|
90
|
+
exports.getAll = getAll;
|
|
91
|
+
exports.getMany = getMany;
|
|
92
|
+
exports.update = update;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var raw = require('./raw.js');
|
|
4
|
+
|
|
5
|
+
function basePath(orgId) {
|
|
6
|
+
return `/organizations/${orgId}/taxonomy/concept-schemes`;
|
|
7
|
+
}
|
|
8
|
+
const get = (http, params) => raw.get(http, `${basePath(params.organizationId)}/${params.conceptSchemeId}`);
|
|
9
|
+
const del = (http, params, headers) => raw.del(http, `${basePath(params.organizationId)}/${params.conceptSchemeId}`, {
|
|
10
|
+
headers: Object.assign({ 'X-Contentful-Version': params.version }, headers),
|
|
11
|
+
});
|
|
12
|
+
const getMany = (http, params) => {
|
|
13
|
+
var _a, _b, _c;
|
|
14
|
+
const url = (_b = (_a = params.query) === null || _a === void 0 ? void 0 : _a.pageUrl) !== null && _b !== void 0 ? _b : basePath(params.organizationId);
|
|
15
|
+
return raw.get(http, url, {
|
|
16
|
+
params: ((_c = params.query) === null || _c === void 0 ? void 0 : _c.pageUrl) ? {} : params.query,
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
const getTotal = (http, params) => raw.get(http, `${basePath(params.organizationId)}/total`);
|
|
20
|
+
const create = (http, params, data) => {
|
|
21
|
+
return raw.post(http, basePath(params.organizationId), data);
|
|
22
|
+
};
|
|
23
|
+
const createWithId = (http, params, data) => {
|
|
24
|
+
return raw.put(http, `${basePath(params.organizationId)}/${params.conceptSchemeId}`, data);
|
|
25
|
+
};
|
|
26
|
+
const patch = (http, params, data, headers) => {
|
|
27
|
+
return raw.patch(http, `${basePath(params.organizationId)}/${params.conceptSchemeId}`, data, {
|
|
28
|
+
headers: Object.assign({ 'X-Contentful-Version': params.version, 'Content-Type': 'application/json-patch+json' }, headers),
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
const update = (http, params, data, headers) => {
|
|
32
|
+
return raw.put(http, `${basePath(params.organizationId)}/${params.conceptSchemeId}`, data, {
|
|
33
|
+
headers: Object.assign({ 'X-Contentful-Version': params.version }, headers),
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
exports.create = create;
|
|
38
|
+
exports.createWithId = createWithId;
|
|
39
|
+
exports.del = del;
|
|
40
|
+
exports.get = get;
|
|
41
|
+
exports.getMany = getMany;
|
|
42
|
+
exports.getTotal = getTotal;
|
|
43
|
+
exports.patch = patch;
|
|
44
|
+
exports.update = update;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var raw = require('./raw.js');
|
|
4
|
+
|
|
5
|
+
function basePath(organizationId) {
|
|
6
|
+
return `/organizations/${organizationId}/taxonomy/concepts`;
|
|
7
|
+
}
|
|
8
|
+
const create = (http, params, data) => {
|
|
9
|
+
return raw.post(http, basePath(params.organizationId), data);
|
|
10
|
+
};
|
|
11
|
+
const createWithId = (http, params, data) => {
|
|
12
|
+
return raw.put(http, `${basePath(params.organizationId)}/${params.conceptId}`, data);
|
|
13
|
+
};
|
|
14
|
+
const patch = (http, params, data, headers) => {
|
|
15
|
+
return raw.patch(http, `${basePath(params.organizationId)}/${params.conceptId}`, data, {
|
|
16
|
+
headers: Object.assign({ 'X-Contentful-Version': params.version, 'Content-Type': 'application/json-patch+json' }, headers),
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
const update = (http, params, data, headers) => {
|
|
20
|
+
return raw.put(http, `${basePath(params.organizationId)}/${params.conceptId}`, data, {
|
|
21
|
+
headers: Object.assign({ 'X-Contentful-Version': params.version }, headers),
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
const get = (http, params) => raw.get(http, `${basePath(params.organizationId)}/${params.conceptId}`);
|
|
25
|
+
const del = (http, params, headers) => {
|
|
26
|
+
var _a;
|
|
27
|
+
return raw.del(http, `${basePath(params.organizationId)}/${params.conceptId}`, {
|
|
28
|
+
headers: Object.assign({ 'X-Contentful-Version': (_a = params.version) !== null && _a !== void 0 ? _a : 0 }, headers),
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
const getMany = (http, params) => {
|
|
32
|
+
const { url, queryParams } = cursorBasedCollection('', params);
|
|
33
|
+
return raw.get(http, url, {
|
|
34
|
+
params: queryParams,
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
const getDescendants = (http, params) => {
|
|
38
|
+
const { url, queryParams } = cursorBasedCollection(`/${params.conceptId}/descendants`, params);
|
|
39
|
+
return raw.get(http, url, { params: queryParams });
|
|
40
|
+
};
|
|
41
|
+
const getAncestors = (http, params) => {
|
|
42
|
+
const { url, queryParams } = cursorBasedCollection(`/${params.conceptId}/ancestors`, params);
|
|
43
|
+
return raw.get(http, url, { params: queryParams });
|
|
44
|
+
};
|
|
45
|
+
const getTotal = (http, params) => raw.get(http, `${basePath(params.organizationId)}/total`);
|
|
46
|
+
function cursorBasedCollection(path, params) {
|
|
47
|
+
var _a, _b;
|
|
48
|
+
return ((_a = params.query) === null || _a === void 0 ? void 0 : _a.pageUrl)
|
|
49
|
+
? { url: (_b = params.query) === null || _b === void 0 ? void 0 : _b.pageUrl, queryParams: {} }
|
|
50
|
+
: {
|
|
51
|
+
url: `${basePath(params.organizationId)}${path}`,
|
|
52
|
+
queryParams: params.query || {},
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
exports.create = create;
|
|
57
|
+
exports.createWithId = createWithId;
|
|
58
|
+
exports.del = del;
|
|
59
|
+
exports.get = get;
|
|
60
|
+
exports.getAncestors = getAncestors;
|
|
61
|
+
exports.getDescendants = getDescendants;
|
|
62
|
+
exports.getMany = getMany;
|
|
63
|
+
exports.getTotal = getTotal;
|
|
64
|
+
exports.patch = patch;
|
|
65
|
+
exports.update = update;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var copy = require('fast-copy');
|
|
4
|
+
var raw = require('./raw.js');
|
|
5
|
+
var utils = require('./utils.js');
|
|
6
|
+
|
|
7
|
+
const getBaseUrl = (params) => `/spaces/${params.spaceId}/environments/${params.environmentId}/content_types`;
|
|
8
|
+
const getContentTypeUrl = (params) => getBaseUrl(params) + `/${params.contentTypeId}`;
|
|
9
|
+
const get = (http, params, headers) => {
|
|
10
|
+
return raw.get(http, getContentTypeUrl(params), {
|
|
11
|
+
params: utils.normalizeSelect(params.query),
|
|
12
|
+
headers,
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
const getMany = (http, params, headers) => {
|
|
16
|
+
return raw.get(http, getBaseUrl(params), {
|
|
17
|
+
params: params.query,
|
|
18
|
+
headers,
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
const create = (http, params, rawData, headers) => {
|
|
22
|
+
const data = copy(rawData);
|
|
23
|
+
return raw.post(http, getBaseUrl(params), data, { headers });
|
|
24
|
+
};
|
|
25
|
+
const createWithId = (http, params, rawData, headers) => {
|
|
26
|
+
const data = copy(rawData);
|
|
27
|
+
return raw.put(http, getContentTypeUrl(params), data, { headers });
|
|
28
|
+
};
|
|
29
|
+
const update = (http, params, rawData, headers) => {
|
|
30
|
+
var _a;
|
|
31
|
+
const data = copy(rawData);
|
|
32
|
+
delete data.sys;
|
|
33
|
+
return raw.put(http, getContentTypeUrl(params), data, {
|
|
34
|
+
headers: Object.assign({ 'X-Contentful-Version': (_a = rawData.sys.version) !== null && _a !== void 0 ? _a : 0 }, headers),
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
const del = (http, params, headers) => {
|
|
38
|
+
return raw.del(http, getContentTypeUrl(params), { headers });
|
|
39
|
+
};
|
|
40
|
+
const publish = (http, params, rawData, headers) => {
|
|
41
|
+
return raw.put(http, getContentTypeUrl(params) + '/published', null, {
|
|
42
|
+
headers: Object.assign({ 'X-Contentful-Version': rawData.sys.version }, headers),
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
const unpublish = (http, params, headers) => {
|
|
46
|
+
return raw.del(http, getContentTypeUrl(params) + '/published', { headers });
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
exports.create = create;
|
|
50
|
+
exports.createWithId = createWithId;
|
|
51
|
+
exports.del = del;
|
|
52
|
+
exports.get = get;
|
|
53
|
+
exports.getMany = getMany;
|
|
54
|
+
exports.publish = publish;
|
|
55
|
+
exports.unpublish = unpublish;
|
|
56
|
+
exports.update = update;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var copy = require('fast-copy');
|
|
4
|
+
var raw = require('./raw.js');
|
|
5
|
+
|
|
6
|
+
const getBaseUrl = (params) => `/spaces/${params.spaceId}/environments/${params.environmentId}/content_types/${params.contentTypeId}/editor_interface`;
|
|
7
|
+
const get = (http, params) => {
|
|
8
|
+
return raw.get(http, getBaseUrl(params));
|
|
9
|
+
};
|
|
10
|
+
const getMany = (http, params) => {
|
|
11
|
+
return raw.get(http, `/spaces/${params.spaceId}/environments/${params.environmentId}/editor_interfaces`);
|
|
12
|
+
};
|
|
13
|
+
const update = (http, params, rawData, headers) => {
|
|
14
|
+
var _a;
|
|
15
|
+
const data = copy(rawData);
|
|
16
|
+
delete data.sys;
|
|
17
|
+
return raw.put(http, getBaseUrl(params), data, {
|
|
18
|
+
headers: Object.assign({ 'X-Contentful-Version': (_a = rawData.sys.version) !== null && _a !== void 0 ? _a : 0 }, headers),
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
exports.get = get;
|
|
23
|
+
exports.getMany = getMany;
|
|
24
|
+
exports.update = update;
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var copy = require('fast-copy');
|
|
4
|
+
var raw = require('./raw.js');
|
|
5
|
+
var utils = require('./utils.js');
|
|
6
|
+
|
|
7
|
+
const get = (http, params, rawData, headers) => {
|
|
8
|
+
return raw.get(http, `/spaces/${params.spaceId}/environments/${params.environmentId}/entries/${params.entryId}`, {
|
|
9
|
+
params: utils.normalizeSelect(params.query),
|
|
10
|
+
headers: Object.assign({}, headers),
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
const getPublished = (http, params, rawData, headers) => {
|
|
14
|
+
return raw.get(http, `/spaces/${params.spaceId}/environments/${params.environmentId}/public/entries`, {
|
|
15
|
+
params: utils.normalizeSelect(params.query),
|
|
16
|
+
headers: Object.assign({}, headers),
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
const getMany = (http, params, rawData, headers) => {
|
|
20
|
+
return raw.get(http, `/spaces/${params.spaceId}/environments/${params.environmentId}/entries`, {
|
|
21
|
+
params: utils.normalizeSelect(params.query),
|
|
22
|
+
headers: Object.assign({}, headers),
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
const patch = (http, params, data, headers) => {
|
|
26
|
+
return raw.patch(http, `/spaces/${params.spaceId}/environments/${params.environmentId}/entries/${params.entryId}`, data, {
|
|
27
|
+
headers: Object.assign({ 'X-Contentful-Version': params.version, 'Content-Type': 'application/json-patch+json' }, headers),
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
const update = (http, params, rawData, headers) => {
|
|
31
|
+
var _a;
|
|
32
|
+
const data = copy(rawData);
|
|
33
|
+
delete data.sys;
|
|
34
|
+
return raw.put(http, `/spaces/${params.spaceId}/environments/${params.environmentId}/entries/${params.entryId}`, data, {
|
|
35
|
+
headers: Object.assign({ 'X-Contentful-Version': (_a = rawData.sys.version) !== null && _a !== void 0 ? _a : 0 }, headers),
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
const del = (http, params) => {
|
|
39
|
+
return raw.del(http, `/spaces/${params.spaceId}/environments/${params.environmentId}/entries/${params.entryId}`);
|
|
40
|
+
};
|
|
41
|
+
const publish = (http, params, rawData) => {
|
|
42
|
+
var _a;
|
|
43
|
+
const payload = ((_a = params.locales) === null || _a === void 0 ? void 0 : _a.length) ? { add: { fields: { '*': params.locales } } } : null;
|
|
44
|
+
return raw.put(http, `/spaces/${params.spaceId}/environments/${params.environmentId}/entries/${params.entryId}/published`, payload, {
|
|
45
|
+
headers: {
|
|
46
|
+
'X-Contentful-Version': rawData.sys.version,
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
};
|
|
50
|
+
const unpublish = (http, params, rawData) => {
|
|
51
|
+
var _a;
|
|
52
|
+
if ((_a = params.locales) === null || _a === void 0 ? void 0 : _a.length) {
|
|
53
|
+
const payload = { remove: { fields: { '*': params.locales } } };
|
|
54
|
+
return raw.put(http, `/spaces/${params.spaceId}/environments/${params.environmentId}/entries/${params.entryId}/published`, payload, {
|
|
55
|
+
headers: {
|
|
56
|
+
'X-Contentful-Version': rawData === null || rawData === void 0 ? void 0 : rawData.sys.version,
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
return raw.del(http, `/spaces/${params.spaceId}/environments/${params.environmentId}/entries/${params.entryId}/published`);
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
const archive = (http, params) => {
|
|
65
|
+
return raw.put(http, `/spaces/${params.spaceId}/environments/${params.environmentId}/entries/${params.entryId}/archived`);
|
|
66
|
+
};
|
|
67
|
+
const unarchive = (http, params) => {
|
|
68
|
+
return raw.del(http, `/spaces/${params.spaceId}/environments/${params.environmentId}/entries/${params.entryId}/archived`);
|
|
69
|
+
};
|
|
70
|
+
const create = (http, params, rawData) => {
|
|
71
|
+
const data = copy(rawData);
|
|
72
|
+
return raw.post(http, `/spaces/${params.spaceId}/environments/${params.environmentId}/entries`, data, {
|
|
73
|
+
headers: {
|
|
74
|
+
'X-Contentful-Content-Type': params.contentTypeId,
|
|
75
|
+
},
|
|
76
|
+
});
|
|
77
|
+
};
|
|
78
|
+
const createWithId = (http, params, rawData) => {
|
|
79
|
+
const data = copy(rawData);
|
|
80
|
+
return raw.put(http, `/spaces/${params.spaceId}/environments/${params.environmentId}/entries/${params.entryId}`, data, {
|
|
81
|
+
headers: {
|
|
82
|
+
'X-Contentful-Content-Type': params.contentTypeId,
|
|
83
|
+
},
|
|
84
|
+
});
|
|
85
|
+
};
|
|
86
|
+
const references = (http, params) => {
|
|
87
|
+
const { spaceId, environmentId, entryId, include } = params;
|
|
88
|
+
const level = include || 2;
|
|
89
|
+
return raw.get(http, `/spaces/${spaceId}/environments/${environmentId}/entries/${entryId}/references?include=${level}`);
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
exports.archive = archive;
|
|
93
|
+
exports.create = create;
|
|
94
|
+
exports.createWithId = createWithId;
|
|
95
|
+
exports.del = del;
|
|
96
|
+
exports.get = get;
|
|
97
|
+
exports.getMany = getMany;
|
|
98
|
+
exports.getPublished = getPublished;
|
|
99
|
+
exports.patch = patch;
|
|
100
|
+
exports.publish = publish;
|
|
101
|
+
exports.references = references;
|
|
102
|
+
exports.unarchive = unarchive;
|
|
103
|
+
exports.unpublish = unpublish;
|
|
104
|
+
exports.update = update;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var copy = require('fast-copy');
|
|
4
|
+
var raw = require('./raw.js');
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Urls
|
|
8
|
+
*/
|
|
9
|
+
const getBaseUrl = (params) => `/spaces/${params.spaceId}/environment_aliases`;
|
|
10
|
+
const getEnvironmentAliasUrl = (params) => getBaseUrl(params) + `/${params.environmentAliasId}`;
|
|
11
|
+
/**
|
|
12
|
+
* Endpoints
|
|
13
|
+
*/
|
|
14
|
+
const get = (http, params) => {
|
|
15
|
+
return raw.get(http, getEnvironmentAliasUrl(params));
|
|
16
|
+
};
|
|
17
|
+
const getMany = (http, params) => {
|
|
18
|
+
return raw.get(http, getBaseUrl(params), {
|
|
19
|
+
params: params.query,
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
const createWithId = (http, params, rawData, headers) => {
|
|
23
|
+
const data = copy(rawData);
|
|
24
|
+
return raw.put(http, getEnvironmentAliasUrl(params), data, {
|
|
25
|
+
headers: headers,
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
const update = (http, params, rawData, headers) => {
|
|
29
|
+
var _a;
|
|
30
|
+
const data = copy(rawData);
|
|
31
|
+
delete data.sys;
|
|
32
|
+
return raw.put(http, getEnvironmentAliasUrl(params), data, {
|
|
33
|
+
headers: Object.assign(Object.assign({}, headers), { 'X-Contentful-Version': (_a = rawData.sys.version) !== null && _a !== void 0 ? _a : 0 }),
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
const del = (http, params) => {
|
|
37
|
+
return raw.del(http, getEnvironmentAliasUrl(params));
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
exports.createWithId = createWithId;
|
|
41
|
+
exports.del = del;
|
|
42
|
+
exports.get = get;
|
|
43
|
+
exports.getMany = getMany;
|
|
44
|
+
exports.update = update;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var tslib = require('tslib');
|
|
4
|
+
var raw = require('./raw.js');
|
|
5
|
+
|
|
6
|
+
const apiPath = (organizationId, ...pathSegments) => `/organizations/${organizationId}/environment_templates/` + pathSegments.join('/');
|
|
7
|
+
const getMany = (http, _a, headers) => {
|
|
8
|
+
var { organizationId, environmentTemplateId, spaceId, environmentId } = _a, paginationProps = tslib.__rest(_a, ["organizationId", "environmentTemplateId", "spaceId", "environmentId"]);
|
|
9
|
+
return raw.get(http, apiPath(organizationId, environmentTemplateId, 'template_installations'), {
|
|
10
|
+
params: Object.assign(Object.assign(Object.assign({}, paginationProps), (environmentId && { 'environment.sys.id': environmentId })), (spaceId && { 'space.sys.id': spaceId })),
|
|
11
|
+
headers,
|
|
12
|
+
});
|
|
13
|
+
};
|
|
14
|
+
const getForEnvironment = (http, _a, headers) => {
|
|
15
|
+
var { spaceId, environmentId, environmentTemplateId, installationId } = _a, paginationProps = tslib.__rest(_a, ["spaceId", "environmentId", "environmentTemplateId", "installationId"]);
|
|
16
|
+
return raw.get(http, `/spaces/${spaceId}/environments/${environmentId}/template_installations/${environmentTemplateId}`, {
|
|
17
|
+
params: Object.assign(Object.assign({}, (installationId && { 'sys.id': installationId })), paginationProps),
|
|
18
|
+
headers,
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
exports.getForEnvironment = getForEnvironment;
|
|
23
|
+
exports.getMany = getMany;
|