contentful-management 11.45.0 → 11.46.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/contentful-management.browser.js +567 -149
- package/dist/contentful-management.browser.js.map +1 -1
- package/dist/contentful-management.browser.min.js +1 -1
- package/dist/contentful-management.node.js +519 -146
- 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/index.js +2 -0
- package/dist/es-modules/adapters/REST/endpoints/oauth-application.js +142 -0
- package/dist/es-modules/adapters/REST/make-request.js +28 -0
- package/dist/es-modules/adapters/REST/rest-adapter.js +5 -21
- package/dist/es-modules/contentful-management.js +2 -1
- package/dist/es-modules/create-contentful-api.js +87 -0
- package/dist/es-modules/entities/index.js +2 -0
- package/dist/es-modules/entities/oauth-application.js +62 -0
- package/dist/es-modules/plain/entities/oauth-application.js +1 -0
- package/dist/es-modules/plain/plain-client.js +7 -0
- package/dist/typings/adapters/REST/endpoints/index.d.ts +2 -0
- package/dist/typings/adapters/REST/endpoints/oauth-application.d.ts +122 -0
- package/dist/typings/adapters/REST/make-request.d.ts +7 -0
- package/dist/typings/adapters/REST/rest-adapter.d.ts +1 -1
- package/dist/typings/common-types.d.ts +39 -0
- package/dist/typings/contentful-management.d.ts +2 -0
- package/dist/typings/create-contentful-api.d.ts +62 -6
- package/dist/typings/entities/index.d.ts +2 -0
- package/dist/typings/entities/oauth-application.d.ts +56 -0
- package/dist/typings/export-types.d.ts +1 -0
- package/dist/typings/plain/common-types.d.ts +4 -2
- package/dist/typings/plain/entities/oauth-application.d.ts +90 -0
- package/package.json +1 -1
|
@@ -33,6 +33,7 @@ import * as Locale from './locale';
|
|
|
33
33
|
import * as Organization from './organization';
|
|
34
34
|
import * as OrganizationInvitation from './organization-invitation';
|
|
35
35
|
import * as OrganizationMembership from './organization-membership';
|
|
36
|
+
import * as OAuthApplication from './oauth-application';
|
|
36
37
|
import * as PersonalAccessToken from './personal-access-token';
|
|
37
38
|
import * as PreviewApiKey from './preview-api-key';
|
|
38
39
|
import * as Release from './release';
|
|
@@ -96,6 +97,7 @@ export default {
|
|
|
96
97
|
Organization,
|
|
97
98
|
OrganizationInvitation,
|
|
98
99
|
OrganizationMembership,
|
|
100
|
+
OAuthApplication,
|
|
99
101
|
PersonalAccessToken,
|
|
100
102
|
AccessToken,
|
|
101
103
|
PreviewApiKey,
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import * as raw from './raw';
|
|
2
|
+
/**
|
|
3
|
+
* Retrieves details of a specific OAuth application. by its unique user ID and oauth application ID.
|
|
4
|
+
*
|
|
5
|
+
* @param {AxiosInstance} http - An Axios HTTP client instance.
|
|
6
|
+
* @param {Object} params - Parameters for the request.
|
|
7
|
+
* @param {string} params.userId - The unique user ID of the user.
|
|
8
|
+
* @param {string} params.oauthApplicationId - The unique application ID of the OAuth application.
|
|
9
|
+
* @returns {Promise<OAuthApplicationProps>} A Promise that resolves with the retrieved OAuth Application.
|
|
10
|
+
* @example ```javascript
|
|
11
|
+
* const contentful = require('contentful-management')
|
|
12
|
+
*
|
|
13
|
+
* const plainClient = contentful.createClient(
|
|
14
|
+
* {
|
|
15
|
+
* accessToken: '<content_management_api_key>'
|
|
16
|
+
* },
|
|
17
|
+
* { type: 'plain' }
|
|
18
|
+
* )
|
|
19
|
+
* plainClient.get({userId: 'TestUserId', oauthApplicationId: 'TestOAuthAppId'})
|
|
20
|
+
* .then(oauthApplication => console.log(oauthApplication))
|
|
21
|
+
* .catch(console.error)
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export const get = (http, params) => {
|
|
25
|
+
return raw.get(http, `/users/${params.userId}/oauth_applications/${params.oauthApplicationId}`);
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Retrieves a list of OAuth applications associated with the current user.
|
|
30
|
+
*
|
|
31
|
+
* @param {AxiosInstance} http - An Axios HTTP client instance.
|
|
32
|
+
* @param {Object} params - Parameters for the request.
|
|
33
|
+
* @param {string} params.userId - The unique user ID of the user.
|
|
34
|
+
* @param {QueryParams} params - Query parameters to filter and customize the request.
|
|
35
|
+
* @returns {Promise<CursorPaginatedCollectionProp<OAuthApplicationProps>>} A Promise that resolves with a collection of oauth application properties.
|
|
36
|
+
* @example ```javascript
|
|
37
|
+
* const contentful = require('contentful-management')
|
|
38
|
+
*
|
|
39
|
+
* const plainClient = contentful.createClient(
|
|
40
|
+
* {
|
|
41
|
+
* accessToken: '<content_management_api_key>'
|
|
42
|
+
* },
|
|
43
|
+
* { type: 'plain' }
|
|
44
|
+
* )
|
|
45
|
+
* plainClient.getManyForUser({userId: 'TestUserId'})
|
|
46
|
+
* .then(result => console.log(result.items))
|
|
47
|
+
* .catch(console.error)
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
export const getManyForUser = (http, params) => {
|
|
51
|
+
return raw.get(http, `/users/${params.userId}/oauth_applications`, {
|
|
52
|
+
params: params.query
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Creates a new OAuth application for current authenticated user.
|
|
58
|
+
*
|
|
59
|
+
* @param {AxiosInstance} http - Axios instance for making the HTTP request.
|
|
60
|
+
* @param {Object} params - Parameters for the request.
|
|
61
|
+
* @param {string} params.userId - The unique user ID of the user.
|
|
62
|
+
* @param {RawAxiosRequestHeaders} [headers] - Optional HTTP headers for the request.
|
|
63
|
+
* @returns {Promise<OAuthApplicationProps>} A Promise that resolves with the created oauth application.
|
|
64
|
+
* @example ```javascript
|
|
65
|
+
* const contentful = require('contentful-management')
|
|
66
|
+
*
|
|
67
|
+
* const plainClient = contentful.createClient(
|
|
68
|
+
* {
|
|
69
|
+
* accessToken: '<content_management_api_key>',
|
|
70
|
+
* },
|
|
71
|
+
* { type: 'plain' }
|
|
72
|
+
* )
|
|
73
|
+
* plainClient.create(
|
|
74
|
+
* {userId: 'TestUserId'},
|
|
75
|
+
* {name: 'Test-Name', description: 'Test-Desc', scopes: ['content_management_manage'], redirectUri: 'https://redirect.uri.com', confidential: true}
|
|
76
|
+
* )
|
|
77
|
+
* .then(oauthApplication => console.log(oauthApplication))
|
|
78
|
+
* .catch(console.error)
|
|
79
|
+
* ```
|
|
80
|
+
*/
|
|
81
|
+
export const create = (http, params, rawData, headers) => {
|
|
82
|
+
return raw.post(http, `/users/${params.userId}/oauth_applications`, rawData, {
|
|
83
|
+
headers
|
|
84
|
+
});
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Updates details of a specific OAuth application.
|
|
89
|
+
*
|
|
90
|
+
* @param {AxiosInstance} http - The Axios HTTP client instance.
|
|
91
|
+
* @param {Object} params - The parameters for updating oauth application.
|
|
92
|
+
* @param {string} params.userId - The unique user ID of the user.
|
|
93
|
+
* @param {string} params.oauthApplicationId - The unique application ID of the OAuth application.
|
|
94
|
+
* @returns {Promise<OAuthApplicationProps>} A Promise that resolves with the updated oauth application.
|
|
95
|
+
* @example ```javascript
|
|
96
|
+
* const contentful = require('contentful-management')
|
|
97
|
+
*
|
|
98
|
+
* const plainClient = contentful.createClient(
|
|
99
|
+
* {
|
|
100
|
+
* accessToken: '<content_management_api_key>'
|
|
101
|
+
* },
|
|
102
|
+
* { type: 'plain' }
|
|
103
|
+
* )
|
|
104
|
+
* plainClient.update(
|
|
105
|
+
* {userId: 'TestUserId', oauthApplicationId: 'TestOAuthAppId'},
|
|
106
|
+
* {name: 'Test-Name', description: 'Test-Desc', scope: ['content_management_manage'], redirectUri: 'https://redirect.uri.com', confidential: true}
|
|
107
|
+
* )
|
|
108
|
+
* .then(oauthApplication => console.log(oauthApplication))
|
|
109
|
+
* .catch(console.error)
|
|
110
|
+
* ```
|
|
111
|
+
*/
|
|
112
|
+
export const update = (http, params, rawData, headers) => {
|
|
113
|
+
return raw.put(http, `/users/${params.userId}/oauth_applications/${params.oauthApplicationId}`, rawData, {
|
|
114
|
+
headers
|
|
115
|
+
});
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Deletes a specific OAuth application.
|
|
120
|
+
*
|
|
121
|
+
* @param {AxiosInstance} http - The Axios HTTP client instance.
|
|
122
|
+
* @param {Object} params - The parameters for deleting oauth application.
|
|
123
|
+
* @param {string} params.userId - The unique user ID of the user.
|
|
124
|
+
* @param {string} params.oauthApplicationId - The unique application ID of the OAuth application.
|
|
125
|
+
* @returns {Promise<void>}
|
|
126
|
+
* @example ```javascript
|
|
127
|
+
* const contentful = require('contentful-management')
|
|
128
|
+
*
|
|
129
|
+
* const plainClient = contentful.createClient(
|
|
130
|
+
* {
|
|
131
|
+
* accessToken: '<content_management_api_key>'
|
|
132
|
+
* },
|
|
133
|
+
* { type: 'plain' }
|
|
134
|
+
* )
|
|
135
|
+
* plainClient.del({userId: 'TestUserId', oauthApplicationId: 'TestOAuthAppId'}) })
|
|
136
|
+
* .then(result => console.log(result.items))
|
|
137
|
+
* .catch(console.error)
|
|
138
|
+
* ```
|
|
139
|
+
*/
|
|
140
|
+
export const del = (http, params) => {
|
|
141
|
+
return raw.del(http, `/users/${params.userId}/oauth_applications/${params.oauthApplicationId}`);
|
|
142
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
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 endpoints from './endpoints';
|
|
7
|
+
export const makeRequest = async ({
|
|
8
|
+
axiosInstance,
|
|
9
|
+
entityType,
|
|
10
|
+
action: actionInput,
|
|
11
|
+
params,
|
|
12
|
+
payload,
|
|
13
|
+
headers,
|
|
14
|
+
userAgent
|
|
15
|
+
}) => {
|
|
16
|
+
var _endpoints$entityType;
|
|
17
|
+
// `delete` is a reserved keyword. Therefore, the methods are called `del`.
|
|
18
|
+
const action = actionInput === 'delete' ? 'del' : actionInput;
|
|
19
|
+
const endpoint = // eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
20
|
+
// @ts-ignore
|
|
21
|
+
(_endpoints$entityType = endpoints[entityType]) === null || _endpoints$entityType === void 0 ? void 0 : _endpoints$entityType[action];
|
|
22
|
+
if (endpoint === undefined) {
|
|
23
|
+
throw new Error('Unknown endpoint');
|
|
24
|
+
}
|
|
25
|
+
return await endpoint(axiosInstance, params, payload, _objectSpread(_objectSpread({}, headers), userAgent ? {
|
|
26
|
+
'X-Contentful-User-Agent': userAgent
|
|
27
|
+
} : {}));
|
|
28
|
+
};
|
|
@@ -6,7 +6,7 @@ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e =
|
|
|
6
6
|
import axios from 'axios';
|
|
7
7
|
import { createHttpClient } from 'contentful-sdk-core';
|
|
8
8
|
import copy from 'fast-copy';
|
|
9
|
-
import
|
|
9
|
+
import { makeRequest } from './make-request';
|
|
10
10
|
/**
|
|
11
11
|
* @private
|
|
12
12
|
*/
|
|
@@ -34,25 +34,9 @@ export class RestAdapter {
|
|
|
34
34
|
} : {}), this.params.headers)
|
|
35
35
|
}));
|
|
36
36
|
}
|
|
37
|
-
async makeRequest({
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
payload,
|
|
42
|
-
headers,
|
|
43
|
-
userAgent
|
|
44
|
-
}) {
|
|
45
|
-
var _endpoints$entityType;
|
|
46
|
-
// `delete` is a reserved keyword. Therefore, the methods are called `del`.
|
|
47
|
-
const action = actionInput === 'delete' ? 'del' : actionInput;
|
|
48
|
-
const endpoint = // eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
49
|
-
// @ts-ignore
|
|
50
|
-
(_endpoints$entityType = endpoints[entityType]) === null || _endpoints$entityType === void 0 ? void 0 : _endpoints$entityType[action];
|
|
51
|
-
if (endpoint === undefined) {
|
|
52
|
-
throw new Error('Unknown endpoint');
|
|
53
|
-
}
|
|
54
|
-
return await endpoint(this.axiosInstance, params, payload, _objectSpread(_objectSpread({}, headers), userAgent ? {
|
|
55
|
-
'X-Contentful-User-Agent': userAgent
|
|
56
|
-
} : {}));
|
|
37
|
+
async makeRequest(opts) {
|
|
38
|
+
return makeRequest(_objectSpread(_objectSpread({}, opts), {}, {
|
|
39
|
+
axiosInstance: this.axiosInstance
|
|
40
|
+
}));
|
|
57
41
|
}
|
|
58
42
|
}
|
|
@@ -19,6 +19,7 @@ export { fetchAll } from './plain/pagination-helper';
|
|
|
19
19
|
export { isDraft, isPublished, isUpdated } from './plain/checks';
|
|
20
20
|
export { createClient };
|
|
21
21
|
export { RestAdapter } from './adapters/REST/rest-adapter';
|
|
22
|
+
export { makeRequest } from './adapters/REST/make-request';
|
|
22
23
|
export { editorInterfaceDefaults };
|
|
23
24
|
export * from './export-types';
|
|
24
25
|
|
|
@@ -46,7 +47,7 @@ function createClient(params, opts = {}) {
|
|
|
46
47
|
const sdkMain = opts.type === 'plain' ? 'contentful-management-plain.js' : 'contentful-management.js';
|
|
47
48
|
const userAgent = getUserAgentHeader(
|
|
48
49
|
// @ts-expect-error
|
|
49
|
-
`${sdkMain}/${"11.
|
|
50
|
+
`${sdkMain}/${"11.46.0"}`, params.application, params.integration, params.feature);
|
|
50
51
|
const adapter = createAdapter(_objectSpread(_objectSpread({}, params), {}, {
|
|
51
52
|
userAgent
|
|
52
53
|
}));
|
|
@@ -36,6 +36,10 @@ export default function createClientApi(makeRequest) {
|
|
|
36
36
|
wrapEnvironmentTemplate,
|
|
37
37
|
wrapEnvironmentTemplateCollection
|
|
38
38
|
} = entities.environmentTemplate;
|
|
39
|
+
const {
|
|
40
|
+
wrapOAuthApplication,
|
|
41
|
+
wrapOAuthApplicationCollection
|
|
42
|
+
} = entities.oauthApplication;
|
|
39
43
|
return {
|
|
40
44
|
/**
|
|
41
45
|
* Gets all environment templates for a given organization with the lasted version
|
|
@@ -286,6 +290,89 @@ export default function createClientApi(makeRequest) {
|
|
|
286
290
|
params
|
|
287
291
|
}).then(data => wrapUser(makeRequest, data));
|
|
288
292
|
},
|
|
293
|
+
/**
|
|
294
|
+
*
|
|
295
|
+
* @param params
|
|
296
|
+
* @returns Promise of a OAuthApplication
|
|
297
|
+
* @example ```javascript
|
|
298
|
+
* const contentful = require('contentful-management')
|
|
299
|
+
*
|
|
300
|
+
* const client = contentful.createClient({
|
|
301
|
+
* accessToken: '<content_management_api_key>'
|
|
302
|
+
* })
|
|
303
|
+
*
|
|
304
|
+
* client.getOAuthApplication({
|
|
305
|
+
* userId: '<user_id>'
|
|
306
|
+
* oauthApplicationId: '<oauth_application_id>'
|
|
307
|
+
* }).then(oauthApplication => console.log(oauthApplication))
|
|
308
|
+
* .catch(console.error)
|
|
309
|
+
*/
|
|
310
|
+
getOAuthApplication: function getOAuthApplication(params) {
|
|
311
|
+
const {
|
|
312
|
+
userId
|
|
313
|
+
} = params;
|
|
314
|
+
return makeRequest({
|
|
315
|
+
entityType: 'OAuthApplication',
|
|
316
|
+
action: 'get',
|
|
317
|
+
params
|
|
318
|
+
}).then(data => wrapOAuthApplication(makeRequest, data, userId));
|
|
319
|
+
},
|
|
320
|
+
/**
|
|
321
|
+
*
|
|
322
|
+
* @param params
|
|
323
|
+
* @returns Promise of list of user's OAuthApplications
|
|
324
|
+
* @example ```javascript
|
|
325
|
+
* const contentful = require('contentful-management')
|
|
326
|
+
*
|
|
327
|
+
* const client = contentful.createClient({
|
|
328
|
+
* accessToken: '<content_management_api_key>'
|
|
329
|
+
* })
|
|
330
|
+
*
|
|
331
|
+
* client.getOAuthApplications({
|
|
332
|
+
* userId: '<user_id>'}).then(oauthApplications => console.log(oauthApplications))
|
|
333
|
+
* .catch(console.error)
|
|
334
|
+
*/
|
|
335
|
+
getOAuthApplications: function getOAuthApplications(params) {
|
|
336
|
+
const {
|
|
337
|
+
userId
|
|
338
|
+
} = params;
|
|
339
|
+
return makeRequest({
|
|
340
|
+
entityType: 'OAuthApplication',
|
|
341
|
+
action: 'getManyForUser',
|
|
342
|
+
params
|
|
343
|
+
}).then(data => wrapOAuthApplicationCollection(makeRequest, data, userId));
|
|
344
|
+
},
|
|
345
|
+
/**
|
|
346
|
+
*
|
|
347
|
+
* @param params
|
|
348
|
+
* @returns Promise of a new OAuth application.
|
|
349
|
+
* @example ```javascript
|
|
350
|
+
* const contentful = require('contentful-management')
|
|
351
|
+
*
|
|
352
|
+
* const client = contentful.createClient({
|
|
353
|
+
* accessToken: '<content_management_api_key>'
|
|
354
|
+
* })
|
|
355
|
+
*
|
|
356
|
+
* client.createOAuthApplication({
|
|
357
|
+
* userId: '<user_id>'},
|
|
358
|
+
* { name: '<name>',
|
|
359
|
+
* description: '<description>',
|
|
360
|
+
* scopes: ['scope'],
|
|
361
|
+
* redirectUri: '<redirectUri>',
|
|
362
|
+
* confidential: '<true/false>'}).then(oauthApplications => console.log(oauthApplications))
|
|
363
|
+
* .catch(console.error)
|
|
364
|
+
*/
|
|
365
|
+
createOAuthApplication: function createOAuthApplication(params, rawData) {
|
|
366
|
+
const {
|
|
367
|
+
userId
|
|
368
|
+
} = params;
|
|
369
|
+
return makeRequest({
|
|
370
|
+
entityType: 'OAuthApplication',
|
|
371
|
+
action: 'create',
|
|
372
|
+
params,
|
|
373
|
+
payload: rawData
|
|
374
|
+
}).then(data => wrapOAuthApplication(makeRequest, data, userId));
|
|
375
|
+
},
|
|
289
376
|
/**
|
|
290
377
|
* Gets App Definition
|
|
291
378
|
* @return Promise for App Definition
|
|
@@ -26,6 +26,7 @@ import * as extension from './extension';
|
|
|
26
26
|
import * as func from './function';
|
|
27
27
|
import * as functionLog from './function-log';
|
|
28
28
|
import * as locale from './locale';
|
|
29
|
+
import * as oauthApplication from './oauth-application';
|
|
29
30
|
import * as organization from './organization';
|
|
30
31
|
import * as organizationInvitation from './organization-invitation';
|
|
31
32
|
import * as organizationMembership from './organization-membership';
|
|
@@ -89,6 +90,7 @@ export default {
|
|
|
89
90
|
func,
|
|
90
91
|
functionLog,
|
|
91
92
|
locale,
|
|
93
|
+
oauthApplication,
|
|
92
94
|
organization,
|
|
93
95
|
organizationInvitation,
|
|
94
96
|
organizationMembership,
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { freezeSys, toPlainObject } from 'contentful-sdk-core';
|
|
2
|
+
import enhanceWithMethods from '../enhance-with-methods';
|
|
3
|
+
import copy from 'fast-copy';
|
|
4
|
+
import { wrapCursorPaginatedCollection } from '../common-utils';
|
|
5
|
+
export let ScopeValues = /*#__PURE__*/function (ScopeValues) {
|
|
6
|
+
ScopeValues["Read"] = "content_management_read";
|
|
7
|
+
ScopeValues["Manage"] = "content_management_manage";
|
|
8
|
+
return ScopeValues;
|
|
9
|
+
}({});
|
|
10
|
+
/**
|
|
11
|
+
* @private
|
|
12
|
+
*/
|
|
13
|
+
function createOAuthApplicationApi(makeRequest, userId) {
|
|
14
|
+
const getParams = data => ({
|
|
15
|
+
userId,
|
|
16
|
+
oauthApplicationId: data.sys.id
|
|
17
|
+
});
|
|
18
|
+
return {
|
|
19
|
+
/**
|
|
20
|
+
* Updates an OAuth application
|
|
21
|
+
* @return Promise for the updated OAuth application
|
|
22
|
+
*/
|
|
23
|
+
async update() {
|
|
24
|
+
const raw = this.toPlainObject();
|
|
25
|
+
return makeRequest({
|
|
26
|
+
entityType: 'OAuthApplication',
|
|
27
|
+
action: 'update',
|
|
28
|
+
params: getParams(raw),
|
|
29
|
+
payload: raw
|
|
30
|
+
});
|
|
31
|
+
},
|
|
32
|
+
/**
|
|
33
|
+
* Deletes an OAuth application
|
|
34
|
+
* @return Promise for the deleted OAuth application
|
|
35
|
+
*/
|
|
36
|
+
async delete() {
|
|
37
|
+
const raw = this.toPlainObject();
|
|
38
|
+
return makeRequest({
|
|
39
|
+
entityType: 'OAuthApplication',
|
|
40
|
+
action: 'delete',
|
|
41
|
+
params: getParams(raw)
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* @private
|
|
49
|
+
* @param makeRequest - function to make requests via an adapter
|
|
50
|
+
* @param data - Raw OAuth application data
|
|
51
|
+
* @return Wrapped OAuth application data
|
|
52
|
+
*/
|
|
53
|
+
export function wrapOAuthApplication(makeRequest, data, userId) {
|
|
54
|
+
const oauthApplication = toPlainObject(copy(data));
|
|
55
|
+
const oauthApplicationWithMethods = enhanceWithMethods(oauthApplication, createOAuthApplicationApi(makeRequest, userId));
|
|
56
|
+
return freezeSys(oauthApplicationWithMethods);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* @private
|
|
61
|
+
*/
|
|
62
|
+
export const wrapOAuthApplicationCollection = wrapCursorPaginatedCollection(wrapOAuthApplication);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -455,6 +455,13 @@ export const createPlainClient = (makeRequest, defaults) => {
|
|
|
455
455
|
update: wrap(wrapParams, 'OrganizationMembership', 'update'),
|
|
456
456
|
delete: wrap(wrapParams, 'OrganizationMembership', 'delete')
|
|
457
457
|
},
|
|
458
|
+
oauthApplication: {
|
|
459
|
+
get: wrap(wrapParams, 'OAuthApplication', 'get'),
|
|
460
|
+
getManyForUser: wrap(wrapParams, 'OAuthApplication', 'getManyForUser'),
|
|
461
|
+
update: wrap(wrapParams, 'OAuthApplication', 'update'),
|
|
462
|
+
delete: wrap(wrapParams, 'OAuthApplication', 'delete'),
|
|
463
|
+
create: wrap(wrapParams, 'OAuthApplication', 'create')
|
|
464
|
+
},
|
|
458
465
|
spaceMember: {
|
|
459
466
|
get: wrap(wrapParams, 'SpaceMember', 'get'),
|
|
460
467
|
getMany: wrap(wrapParams, 'SpaceMember', 'getMany')
|
|
@@ -33,6 +33,7 @@ import * as Locale from './locale';
|
|
|
33
33
|
import * as Organization from './organization';
|
|
34
34
|
import * as OrganizationInvitation from './organization-invitation';
|
|
35
35
|
import * as OrganizationMembership from './organization-membership';
|
|
36
|
+
import * as OAuthApplication from './oauth-application';
|
|
36
37
|
import * as PersonalAccessToken from './personal-access-token';
|
|
37
38
|
import * as PreviewApiKey from './preview-api-key';
|
|
38
39
|
import * as Release from './release';
|
|
@@ -96,6 +97,7 @@ declare const _default: {
|
|
|
96
97
|
Organization: typeof Organization;
|
|
97
98
|
OrganizationInvitation: typeof OrganizationInvitation;
|
|
98
99
|
OrganizationMembership: typeof OrganizationMembership;
|
|
100
|
+
OAuthApplication: typeof OAuthApplication;
|
|
99
101
|
PersonalAccessToken: typeof PersonalAccessToken;
|
|
100
102
|
AccessToken: typeof AccessToken;
|
|
101
103
|
PreviewApiKey: typeof PreviewApiKey;
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import type { RestEndpoint } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Retrieves details of a specific OAuth application. by its unique user ID and oauth application ID.
|
|
4
|
+
*
|
|
5
|
+
* @param {AxiosInstance} http - An Axios HTTP client instance.
|
|
6
|
+
* @param {Object} params - Parameters for the request.
|
|
7
|
+
* @param {string} params.userId - The unique user ID of the user.
|
|
8
|
+
* @param {string} params.oauthApplicationId - The unique application ID of the OAuth application.
|
|
9
|
+
* @returns {Promise<OAuthApplicationProps>} A Promise that resolves with the retrieved OAuth Application.
|
|
10
|
+
* @example ```javascript
|
|
11
|
+
* const contentful = require('contentful-management')
|
|
12
|
+
*
|
|
13
|
+
* const plainClient = contentful.createClient(
|
|
14
|
+
* {
|
|
15
|
+
* accessToken: '<content_management_api_key>'
|
|
16
|
+
* },
|
|
17
|
+
* { type: 'plain' }
|
|
18
|
+
* )
|
|
19
|
+
* plainClient.get({userId: 'TestUserId', oauthApplicationId: 'TestOAuthAppId'})
|
|
20
|
+
* .then(oauthApplication => console.log(oauthApplication))
|
|
21
|
+
* .catch(console.error)
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export declare const get: RestEndpoint<'OAuthApplication', 'get'>;
|
|
25
|
+
/**
|
|
26
|
+
* Retrieves a list of OAuth applications associated with the current user.
|
|
27
|
+
*
|
|
28
|
+
* @param {AxiosInstance} http - An Axios HTTP client instance.
|
|
29
|
+
* @param {Object} params - Parameters for the request.
|
|
30
|
+
* @param {string} params.userId - The unique user ID of the user.
|
|
31
|
+
* @param {QueryParams} params - Query parameters to filter and customize the request.
|
|
32
|
+
* @returns {Promise<CursorPaginatedCollectionProp<OAuthApplicationProps>>} A Promise that resolves with a collection of oauth application properties.
|
|
33
|
+
* @example ```javascript
|
|
34
|
+
* const contentful = require('contentful-management')
|
|
35
|
+
*
|
|
36
|
+
* const plainClient = contentful.createClient(
|
|
37
|
+
* {
|
|
38
|
+
* accessToken: '<content_management_api_key>'
|
|
39
|
+
* },
|
|
40
|
+
* { type: 'plain' }
|
|
41
|
+
* )
|
|
42
|
+
* plainClient.getManyForUser({userId: 'TestUserId'})
|
|
43
|
+
* .then(result => console.log(result.items))
|
|
44
|
+
* .catch(console.error)
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
export declare const getManyForUser: RestEndpoint<'OAuthApplication', 'getManyForUser'>;
|
|
48
|
+
/**
|
|
49
|
+
* Creates a new OAuth application for current authenticated user.
|
|
50
|
+
*
|
|
51
|
+
* @param {AxiosInstance} http - Axios instance for making the HTTP request.
|
|
52
|
+
* @param {Object} params - Parameters for the request.
|
|
53
|
+
* @param {string} params.userId - The unique user ID of the user.
|
|
54
|
+
* @param {RawAxiosRequestHeaders} [headers] - Optional HTTP headers for the request.
|
|
55
|
+
* @returns {Promise<OAuthApplicationProps>} A Promise that resolves with the created oauth application.
|
|
56
|
+
* @example ```javascript
|
|
57
|
+
* const contentful = require('contentful-management')
|
|
58
|
+
*
|
|
59
|
+
* const plainClient = contentful.createClient(
|
|
60
|
+
* {
|
|
61
|
+
* accessToken: '<content_management_api_key>',
|
|
62
|
+
* },
|
|
63
|
+
* { type: 'plain' }
|
|
64
|
+
* )
|
|
65
|
+
* plainClient.create(
|
|
66
|
+
* {userId: 'TestUserId'},
|
|
67
|
+
* {name: 'Test-Name', description: 'Test-Desc', scopes: ['content_management_manage'], redirectUri: 'https://redirect.uri.com', confidential: true}
|
|
68
|
+
* )
|
|
69
|
+
* .then(oauthApplication => console.log(oauthApplication))
|
|
70
|
+
* .catch(console.error)
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
export declare const create: RestEndpoint<'OAuthApplication', 'create'>;
|
|
74
|
+
/**
|
|
75
|
+
* Updates details of a specific OAuth application.
|
|
76
|
+
*
|
|
77
|
+
* @param {AxiosInstance} http - The Axios HTTP client instance.
|
|
78
|
+
* @param {Object} params - The parameters for updating oauth application.
|
|
79
|
+
* @param {string} params.userId - The unique user ID of the user.
|
|
80
|
+
* @param {string} params.oauthApplicationId - The unique application ID of the OAuth application.
|
|
81
|
+
* @returns {Promise<OAuthApplicationProps>} A Promise that resolves with the updated oauth application.
|
|
82
|
+
* @example ```javascript
|
|
83
|
+
* const contentful = require('contentful-management')
|
|
84
|
+
*
|
|
85
|
+
* const plainClient = contentful.createClient(
|
|
86
|
+
* {
|
|
87
|
+
* accessToken: '<content_management_api_key>'
|
|
88
|
+
* },
|
|
89
|
+
* { type: 'plain' }
|
|
90
|
+
* )
|
|
91
|
+
* plainClient.update(
|
|
92
|
+
* {userId: 'TestUserId', oauthApplicationId: 'TestOAuthAppId'},
|
|
93
|
+
* {name: 'Test-Name', description: 'Test-Desc', scope: ['content_management_manage'], redirectUri: 'https://redirect.uri.com', confidential: true}
|
|
94
|
+
* )
|
|
95
|
+
* .then(oauthApplication => console.log(oauthApplication))
|
|
96
|
+
* .catch(console.error)
|
|
97
|
+
* ```
|
|
98
|
+
*/
|
|
99
|
+
export declare const update: RestEndpoint<'OAuthApplication', 'update'>;
|
|
100
|
+
/**
|
|
101
|
+
* Deletes a specific OAuth application.
|
|
102
|
+
*
|
|
103
|
+
* @param {AxiosInstance} http - The Axios HTTP client instance.
|
|
104
|
+
* @param {Object} params - The parameters for deleting oauth application.
|
|
105
|
+
* @param {string} params.userId - The unique user ID of the user.
|
|
106
|
+
* @param {string} params.oauthApplicationId - The unique application ID of the OAuth application.
|
|
107
|
+
* @returns {Promise<void>}
|
|
108
|
+
* @example ```javascript
|
|
109
|
+
* const contentful = require('contentful-management')
|
|
110
|
+
*
|
|
111
|
+
* const plainClient = contentful.createClient(
|
|
112
|
+
* {
|
|
113
|
+
* accessToken: '<content_management_api_key>'
|
|
114
|
+
* },
|
|
115
|
+
* { type: 'plain' }
|
|
116
|
+
* )
|
|
117
|
+
* plainClient.del({userId: 'TestUserId', oauthApplicationId: 'TestOAuthAppId'}) })
|
|
118
|
+
* .then(result => console.log(result.items))
|
|
119
|
+
* .catch(console.error)
|
|
120
|
+
* ```
|
|
121
|
+
*/
|
|
122
|
+
export declare const del: RestEndpoint<'OAuthApplication', 'delete'>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { AxiosInstance } from 'contentful-sdk-core';
|
|
2
|
+
import type { MakeRequestOptions } from '../../common-types';
|
|
3
|
+
type makeAxiosRequest = MakeRequestOptions & {
|
|
4
|
+
axiosInstance: AxiosInstance;
|
|
5
|
+
};
|
|
6
|
+
export declare const makeRequest: <R>({ axiosInstance, entityType, action: actionInput, params, payload, headers, userAgent, }: makeAxiosRequest) => Promise<R>;
|
|
7
|
+
export {};
|
|
@@ -21,5 +21,5 @@ export declare class RestAdapter implements Adapter {
|
|
|
21
21
|
private readonly params;
|
|
22
22
|
private readonly axiosInstance;
|
|
23
23
|
constructor(params: RestAdapterParams);
|
|
24
|
-
makeRequest<R>(
|
|
24
|
+
makeRequest<R>(opts: MakeRequestOptions): Promise<R>;
|
|
25
25
|
}
|
|
@@ -60,6 +60,7 @@ import type { UserUIConfigProps } from './entities/user-ui-config';
|
|
|
60
60
|
import type { CompleteWorkflowParams, CreateWorkflowParams, CreateWorkflowProps, DeleteWorkflowParams, WorkflowProps, WorkflowQueryOptions } from './entities/workflow';
|
|
61
61
|
import type { CreateWorkflowDefinitionParams, CreateWorkflowDefinitionProps, DeleteWorkflowDefinitionParams, WorkflowDefinitionProps, WorkflowDefinitionQueryOptions } from './entities/workflow-definition';
|
|
62
62
|
import type { WorkflowsChangelogEntryProps, WorkflowsChangelogQueryOptions } from './entities/workflows-changelog-entry';
|
|
63
|
+
import type { CreateOAuthApplicationProps, OAuthApplicationProps, UpdateOAuthApplicationProps } from './entities/oauth-application';
|
|
63
64
|
import type { FunctionLogProps } from './entities/function-log';
|
|
64
65
|
export interface DefaultElements<TPlainObject extends object = object> {
|
|
65
66
|
toPlainObject(): TPlainObject;
|
|
@@ -406,6 +407,11 @@ type MRInternal<UA extends boolean> = {
|
|
|
406
407
|
(opts: MROpts<'AccessToken', 'createPersonalAccessToken', UA>): MRReturn<'AccessToken', 'createPersonalAccessToken'>;
|
|
407
408
|
(opts: MROpts<'AccessToken', 'revoke', UA>): MRReturn<'AccessToken', 'revoke'>;
|
|
408
409
|
(opts: MROpts<'AccessToken', 'getManyForOrganization', UA>): MRReturn<'AccessToken', 'getManyForOrganization'>;
|
|
410
|
+
(opts: MROpts<'OAuthApplication', 'get', UA>): MRReturn<'OAuthApplication', 'get'>;
|
|
411
|
+
(opts: MROpts<'OAuthApplication', 'getManyForUser', UA>): MRReturn<'OAuthApplication', 'getManyForUser'>;
|
|
412
|
+
(opts: MROpts<'OAuthApplication', 'create', UA>): MRReturn<'OAuthApplication', 'create'>;
|
|
413
|
+
(opts: MROpts<'OAuthApplication', 'update', UA>): MRReturn<'OAuthApplication', 'update'>;
|
|
414
|
+
(opts: MROpts<'OAuthApplication', 'delete', UA>): MRReturn<'OAuthApplication', 'delete'>;
|
|
409
415
|
(opts: MROpts<'PreviewApiKey', 'get', UA>): MRReturn<'PreviewApiKey', 'get'>;
|
|
410
416
|
(opts: MROpts<'PreviewApiKey', 'getMany', UA>): MRReturn<'PreviewApiKey', 'getMany'>;
|
|
411
417
|
(opts: MROpts<'Release', 'archive', UA>): MRReturn<'Release', 'archive'>;
|
|
@@ -1662,6 +1668,32 @@ export type MRActions = {
|
|
|
1662
1668
|
return: CollectionProp<AccessTokenProps>;
|
|
1663
1669
|
};
|
|
1664
1670
|
};
|
|
1671
|
+
OAuthApplication: {
|
|
1672
|
+
get: {
|
|
1673
|
+
params: GetOAuthApplicationParams;
|
|
1674
|
+
return: OAuthApplicationProps;
|
|
1675
|
+
};
|
|
1676
|
+
getManyForUser: {
|
|
1677
|
+
params: GetUserParams & QueryParams;
|
|
1678
|
+
return: CursorPaginatedCollectionProp<OAuthApplicationProps>;
|
|
1679
|
+
};
|
|
1680
|
+
create: {
|
|
1681
|
+
params: GetUserParams;
|
|
1682
|
+
payload: CreateOAuthApplicationProps;
|
|
1683
|
+
headers?: RawAxiosRequestHeaders;
|
|
1684
|
+
return: OAuthApplicationProps;
|
|
1685
|
+
};
|
|
1686
|
+
update: {
|
|
1687
|
+
params: GetOAuthApplicationParams;
|
|
1688
|
+
payload: UpdateOAuthApplicationProps;
|
|
1689
|
+
headers?: RawAxiosRequestHeaders;
|
|
1690
|
+
return: OAuthApplicationProps;
|
|
1691
|
+
};
|
|
1692
|
+
delete: {
|
|
1693
|
+
params: GetOAuthApplicationParams;
|
|
1694
|
+
return: void;
|
|
1695
|
+
};
|
|
1696
|
+
};
|
|
1665
1697
|
PreviewApiKey: {
|
|
1666
1698
|
get: {
|
|
1667
1699
|
params: GetSpaceParams & {
|
|
@@ -2563,6 +2595,13 @@ export type CursorBasedParams = CursorPaginationXORParams;
|
|
|
2563
2595
|
export type AcceptsQueryParams = {
|
|
2564
2596
|
query?: AcceptsQueryOptions;
|
|
2565
2597
|
};
|
|
2598
|
+
export type GetOAuthApplicationParams = {
|
|
2599
|
+
userId: string;
|
|
2600
|
+
oauthApplicationId: string;
|
|
2601
|
+
};
|
|
2602
|
+
export type GetUserParams = {
|
|
2603
|
+
userId: string;
|
|
2604
|
+
};
|
|
2566
2605
|
export declare enum ScheduledActionReferenceFilters {
|
|
2567
2606
|
contentTypeAnnotationNotIn = "sys.contentType.metadata.annotations.ContentType[nin]"
|
|
2568
2607
|
}
|