contentful-management 11.45.1 → 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.
Files changed (29) hide show
  1. package/dist/contentful-management.browser.js +567 -149
  2. package/dist/contentful-management.browser.js.map +1 -1
  3. package/dist/contentful-management.browser.min.js +1 -1
  4. package/dist/contentful-management.node.js +519 -146
  5. package/dist/contentful-management.node.js.map +1 -1
  6. package/dist/contentful-management.node.min.js +1 -1
  7. package/dist/es-modules/adapters/REST/endpoints/index.js +2 -0
  8. package/dist/es-modules/adapters/REST/endpoints/oauth-application.js +142 -0
  9. package/dist/es-modules/adapters/REST/make-request.js +28 -0
  10. package/dist/es-modules/adapters/REST/rest-adapter.js +5 -21
  11. package/dist/es-modules/contentful-management.js +2 -1
  12. package/dist/es-modules/create-contentful-api.js +87 -0
  13. package/dist/es-modules/entities/index.js +2 -0
  14. package/dist/es-modules/entities/oauth-application.js +62 -0
  15. package/dist/es-modules/plain/entities/oauth-application.js +1 -0
  16. package/dist/es-modules/plain/plain-client.js +7 -0
  17. package/dist/typings/adapters/REST/endpoints/index.d.ts +2 -0
  18. package/dist/typings/adapters/REST/endpoints/oauth-application.d.ts +122 -0
  19. package/dist/typings/adapters/REST/make-request.d.ts +7 -0
  20. package/dist/typings/adapters/REST/rest-adapter.d.ts +1 -1
  21. package/dist/typings/common-types.d.ts +39 -0
  22. package/dist/typings/contentful-management.d.ts +2 -0
  23. package/dist/typings/create-contentful-api.d.ts +62 -6
  24. package/dist/typings/entities/index.d.ts +2 -0
  25. package/dist/typings/entities/oauth-application.d.ts +56 -0
  26. package/dist/typings/export-types.d.ts +1 -0
  27. package/dist/typings/plain/common-types.d.ts +2 -0
  28. package/dist/typings/plain/entities/oauth-application.d.ts +90 -0
  29. package/package.json +1 -1
@@ -17,6 +17,8 @@ export { isDraft, isPublished, isUpdated } from './plain/checks';
17
17
  export type { PlainClientAPI } from './plain/common-types';
18
18
  export { createClient };
19
19
  export { RestAdapter } from './adapters/REST/rest-adapter';
20
+ export type { RestAdapterParams } from './adapters/REST/rest-adapter';
21
+ export { makeRequest } from './adapters/REST/make-request';
20
22
  export { editorInterfaceDefaults };
21
23
  export type PlainClientDefaultParams = DefaultParams;
22
24
  export * from './export-types';
@@ -1,4 +1,4 @@
1
- import type { Collection, MakeRequest, PaginationQueryParams, QueryOptions, QueryParams, GetAppDefinitionParams, CursorPaginatedCollection, GetEnvironmentTemplateParams, BasicCursorPaginationOptions } from './common-types';
1
+ import type { Collection, MakeRequest, PaginationQueryParams, QueryOptions, QueryParams, GetAppDefinitionParams, CursorPaginatedCollection, GetEnvironmentTemplateParams, BasicCursorPaginationOptions, GetOAuthApplicationParams, GetUserParams } from './common-types';
2
2
  import type { Organization, OrganizationProps } from './entities/organization';
3
3
  import type { CreatePersonalAccessTokenProps } from './entities/personal-access-token';
4
4
  import type { Space, SpaceProps } from './entities/space';
@@ -7,6 +7,7 @@ import type { UsageQuery } from './entities/usage';
7
7
  import type { UserProps } from './entities/user';
8
8
  import type { CreateEnvironmentTemplateProps, EnvironmentTemplate, EnvironmentTemplateProps } from './entities/environment-template';
9
9
  import type { RawAxiosRequestConfig } from 'axios';
10
+ import type { CreateOAuthApplicationProps, OAuthApplication, OAuthApplicationProps } from './export-types';
10
11
  export type ClientAPI = ReturnType<typeof createClientApi>;
11
12
  type CreateSpaceProps = Omit<SpaceProps, 'sys'> & {
12
13
  defaultLocale?: string;
@@ -182,6 +183,61 @@ export default function createClientApi(makeRequest: MakeRequest): {
182
183
  * ```
183
184
  */
184
185
  getCurrentUser: <T = UserProps>(params?: QueryParams) => Promise<T>;
186
+ /**
187
+ *
188
+ * @param params
189
+ * @returns Promise of a OAuthApplication
190
+ * @example ```javascript
191
+ * const contentful = require('contentful-management')
192
+ *
193
+ * const client = contentful.createClient({
194
+ * accessToken: '<content_management_api_key>'
195
+ * })
196
+ *
197
+ * client.getOAuthApplication({
198
+ * userId: '<user_id>'
199
+ * oauthApplicationId: '<oauth_application_id>'
200
+ * }).then(oauthApplication => console.log(oauthApplication))
201
+ * .catch(console.error)
202
+ */
203
+ getOAuthApplication: (params: GetOAuthApplicationParams) => Promise<OAuthApplicationProps>;
204
+ /**
205
+ *
206
+ * @param params
207
+ * @returns Promise of list of user's OAuthApplications
208
+ * @example ```javascript
209
+ * const contentful = require('contentful-management')
210
+ *
211
+ * const client = contentful.createClient({
212
+ * accessToken: '<content_management_api_key>'
213
+ * })
214
+ *
215
+ * client.getOAuthApplications({
216
+ * userId: '<user_id>'}).then(oauthApplications => console.log(oauthApplications))
217
+ * .catch(console.error)
218
+ */
219
+ getOAuthApplications: (params: GetUserParams & QueryParams) => Promise<CursorPaginatedCollection<OAuthApplication, OAuthApplicationProps>>;
220
+ /**
221
+ *
222
+ * @param params
223
+ * @returns Promise of a new OAuth application.
224
+ * @example ```javascript
225
+ * const contentful = require('contentful-management')
226
+ *
227
+ * const client = contentful.createClient({
228
+ * accessToken: '<content_management_api_key>'
229
+ * })
230
+ *
231
+ * client.createOAuthApplication({
232
+ * userId: '<user_id>'},
233
+ * { name: '<name>',
234
+ * description: '<description>',
235
+ * scopes: ['scope'],
236
+ * redirectUri: '<redirectUri>',
237
+ * confidential: '<true/false>'}).then(oauthApplications => console.log(oauthApplications))
238
+ * .catch(console.error)
239
+ */
240
+ createOAuthApplication: (params: GetUserParams, rawData: CreateOAuthApplicationProps) => Promise<OAuthApplicationProps>;
185
241
  /**
186
242
  * Gets App Definition
187
243
  * @return Promise for App Definition
@@ -223,7 +279,7 @@ export default function createClientApi(makeRequest: MakeRequest): {
223
279
  * .catch(console.error)
224
280
  * ```
225
281
  */
226
- createPersonalAccessToken: (data: CreatePersonalAccessTokenProps) => Promise<import("./entities/personal-access-token").PersonalAccessToken>;
282
+ createPersonalAccessToken: (data: CreatePersonalAccessTokenProps) => Promise<import("./export-types").PersonalAccessToken>;
227
283
  /**
228
284
  * @deprecated - use getAccessToken instead
229
285
  *
@@ -242,7 +298,7 @@ export default function createClientApi(makeRequest: MakeRequest): {
242
298
  * .catch(console.error)
243
299
  * ```
244
300
  */
245
- getPersonalAccessToken: (tokenId: string) => Promise<import("./entities/personal-access-token").PersonalAccessToken>;
301
+ getPersonalAccessToken: (tokenId: string) => Promise<import("./export-types").PersonalAccessToken>;
246
302
  /**
247
303
  * @deprecated - use getAccessTokens instead
248
304
  *
@@ -260,7 +316,7 @@ export default function createClientApi(makeRequest: MakeRequest): {
260
316
  * .catch(console.error)
261
317
  * ```
262
318
  */
263
- getPersonalAccessTokens: () => Promise<Collection<import("./entities/personal-access-token").PersonalAccessToken, import("./entities/personal-access-token").PersonalAccessTokenProps>>;
319
+ getPersonalAccessTokens: () => Promise<Collection<import("./export-types").PersonalAccessToken, import("./export-types").PersonalAccessTokenProps>>;
264
320
  /**
265
321
  * Gets a users access token
266
322
  * @param data - users access token config
@@ -335,7 +391,7 @@ export default function createClientApi(makeRequest: MakeRequest): {
335
391
  * .catch(console.error)
336
392
  * ```
337
393
  */
338
- getOrganizationUsage: (organizationId: string, query?: QueryOptions) => Promise<Collection<import("./entities/usage").Usage, import("./entities/usage").UsageProps>>;
394
+ getOrganizationUsage: (organizationId: string, query?: QueryOptions) => Promise<Collection<import("./export-types").Usage, import("./export-types").UsageProps>>;
339
395
  /**
340
396
  * Get organization usage grouped by space and metric
341
397
  *
@@ -361,7 +417,7 @@ export default function createClientApi(makeRequest: MakeRequest): {
361
417
  * .catch(console.error)
362
418
  * ```
363
419
  */
364
- getSpaceUsage: (organizationId: string, query?: UsageQuery) => Promise<Collection<import("./entities/usage").Usage, import("./entities/usage").UsageProps>>;
420
+ getSpaceUsage: (organizationId: string, query?: UsageQuery) => Promise<Collection<import("./export-types").Usage, import("./export-types").UsageProps>>;
365
421
  /**
366
422
  * Make a custom request to the Contentful management API's /spaces endpoint
367
423
  * @param opts - axios request options (https://github.com/mzabriskie/axios)
@@ -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 @@ declare const _default: {
89
90
  func: typeof func;
90
91
  functionLog: typeof functionLog;
91
92
  locale: typeof locale;
93
+ oauthApplication: typeof oauthApplication;
92
94
  organization: typeof organization;
93
95
  organizationInvitation: typeof organizationInvitation;
94
96
  organizationMembership: typeof organizationMembership;
@@ -0,0 +1,56 @@
1
+ import type { BasicMetaSysProps, DefaultElements, MakeRequest } from '../common-types';
2
+ type OAuthApplicationSysProps = BasicMetaSysProps & {
3
+ lastUsedAt: string | null;
4
+ };
5
+ export declare enum ScopeValues {
6
+ Read = "content_management_read",
7
+ Manage = "content_management_manage"
8
+ }
9
+ export type OAuthApplicationProps = {
10
+ name: string;
11
+ description: string;
12
+ clientId: string;
13
+ clientSecret: string;
14
+ redirectUri: string;
15
+ scopes: ScopeValues[];
16
+ confidential: boolean;
17
+ sys: OAuthApplicationSysProps;
18
+ };
19
+ export type CreateOAuthApplicationProps = {
20
+ name: string;
21
+ description: string;
22
+ redirectUri: string;
23
+ scopes: ScopeValues[];
24
+ confidential: boolean;
25
+ };
26
+ export type UpdateOAuthApplicationProps = {
27
+ name?: string;
28
+ description?: string;
29
+ redirectUri?: string;
30
+ scopes?: ScopeValues[];
31
+ confidential?: boolean;
32
+ };
33
+ export interface OAuthApplication extends OAuthApplicationProps, DefaultElements<OAuthApplicationProps> {
34
+ /**
35
+ * Deletes an OAuth application
36
+ * @return Promise for the deleted OAuth application
37
+ */
38
+ delete(): Promise<void>;
39
+ /**
40
+ * Updates an OAuth application
41
+ * @return Promise for the updated OAuth application
42
+ */
43
+ update(): Promise<OAuthApplicationProps>;
44
+ }
45
+ /**
46
+ * @private
47
+ * @param makeRequest - function to make requests via an adapter
48
+ * @param data - Raw OAuth application data
49
+ * @return Wrapped OAuth application data
50
+ */
51
+ export declare function wrapOAuthApplication(makeRequest: MakeRequest, data: OAuthApplicationProps, userId: string): OAuthApplication;
52
+ /**
53
+ * @private
54
+ */
55
+ export declare const wrapOAuthApplicationCollection: (makeRequest: MakeRequest, data: import("../common-types").CursorPaginatedCollectionProp<OAuthApplicationProps>, userId: string) => import("../common-types").CursorPaginatedCollection<OAuthApplication, OAuthApplicationProps>;
56
+ export {};
@@ -30,6 +30,7 @@ export type { FieldType } from './entities/field-type';
30
30
  export type { FunctionProps } from './entities/function';
31
31
  export type { CreateLocaleProps, Locale, LocaleProps } from './entities/locale';
32
32
  export type { Organization, OrganizationProp, OrganizationProps } from './entities/organization';
33
+ export type { OAuthApplication, OAuthApplicationProps, CreateOAuthApplicationProps, } from './entities/oauth-application';
33
34
  export type { CreateOrganizationInvitationProps, OrganizationInvitation, OrganizationInvitationProps, } from './entities/organization-invitation';
34
35
  export type { OrganizationMembership, OrganizationMembershipProps, } from './entities/organization-membership';
35
36
  export type { CreatePersonalAccessTokenProps, PersonalAccessToken, PersonalAccessTokenProp, PersonalAccessTokenProps, } from './entities/personal-access-token';
@@ -63,6 +63,7 @@ import type { WorkflowPlainClientAPI } from './entities/workflow';
63
63
  import type { WorkflowDefinitionPlainClientAPI } from './entities/workflow-definition';
64
64
  import type { WorkflowsChangelogPlainClientAPI } from './entities/workflows-changelog';
65
65
  import type { DefaultParams, OptionalDefaults } from './wrappers/wrap';
66
+ import type { OAuthApplicationPlainClientAPI } from './entities/oauth-application';
66
67
  import type { FunctionLogPlainClientAPI } from './entities/function-log';
67
68
  export type PlainClientAPI = {
68
69
  raw: {
@@ -377,4 +378,5 @@ export type PlainClientAPI = {
377
378
  workflowDefinition: WorkflowDefinitionPlainClientAPI;
378
379
  workflow: WorkflowPlainClientAPI;
379
380
  workflowsChangelog: WorkflowsChangelogPlainClientAPI;
381
+ oauthApplication: OAuthApplicationPlainClientAPI;
380
382
  };
@@ -0,0 +1,90 @@
1
+ import type { RawAxiosRequestHeaders } from 'axios';
2
+ import type { GetOAuthApplicationParams, QueryParams, CursorPaginatedCollectionProp, GetUserParams } from '../../common-types';
3
+ import type { OptionalDefaults } from '../wrappers/wrap';
4
+ import type { CreateOAuthApplicationProps, OAuthApplicationProps, UpdateOAuthApplicationProps } from '../../entities/oauth-application';
5
+ export type OAuthApplicationPlainClientAPI = {
6
+ /**
7
+ * Retrieves a list of OAuth applications associated with the current user.
8
+ * @param userId the user ID
9
+ * @returns A collection of oauth applications
10
+ * @throws if the request fails, or the user is not found
11
+ * @example
12
+ * ```javascript
13
+ * const oauthApplication = await client.oauthApplication.getManyForUser({
14
+ * userId: '<user_id>',
15
+ * query: {
16
+ * limit: 10,
17
+ * }
18
+ * })
19
+ * ```
20
+ */
21
+ getManyForUser(params: OptionalDefaults<GetUserParams & QueryParams>): Promise<CursorPaginatedCollectionProp<OAuthApplicationProps>>;
22
+ /**
23
+ * Retrieves details of a specific OAuth application.
24
+ * @param userId the user ID
25
+ * @param oauthApplicationId the OAuth application ID
26
+ * @returns the requested OAuth Application
27
+ * @throws if the request fails, or the OAuth Application or user are not found
28
+ * @example
29
+ * ```javascript
30
+ * const oauthApplication = await client.oauthApplication.get({
31
+ * userId: '<user_id>',
32
+ * oauthApplicationId: '<oauth_application_id>'
33
+ * })
34
+ * ```
35
+ */
36
+ get(params: OptionalDefaults<GetOAuthApplicationParams>): Promise<OAuthApplicationProps>;
37
+ /**
38
+ * Creates a new OAuth application.
39
+ * @param userId the user ID
40
+ * @param rawData the oauth application payload
41
+ * @returns the created OAuth Application
42
+ * @throws if the request fails, or the user is not found
43
+ * @example
44
+ * ```javascript
45
+ * const oauthApplication = await client.oauthApplication.create({
46
+ * userId: '<user_id>',
47
+ * }, {
48
+ * name: 'Test-Name',
49
+ * description: 'Test-Desc',
50
+ * scopes: ['content_management_manage'],
51
+ * redirectUri: 'https://redirect.uri.com',
52
+ * confidential: true
53
+ * }
54
+ * ```
55
+ */
56
+ create(params: OptionalDefaults<GetUserParams>, rawData: CreateOAuthApplicationProps, headers?: RawAxiosRequestHeaders): Promise<OAuthApplicationProps>;
57
+ /**
58
+ * Updates details of a specific OAuth application.
59
+ * @param params the user and oauth application IDs
60
+ * @param rawData the oauth application payload
61
+ * @returns the updated oauth application
62
+ * @throws if the request fails, or the user or oauth application are not found
63
+ * @example
64
+ * ```javascript
65
+ *
66
+ * const oauthApplication = await client.oauthApplication.update({
67
+ * userId: '<user_id>',
68
+ * oauthApplicationId: '<oauth_application_id>'
69
+ * }, {
70
+ * ...oauthApplication,
71
+ * name: 'Update Test-Name',
72
+ * description: 'Update Test-Desc',
73
+ * })
74
+ * ```
75
+ */
76
+ update(params: OptionalDefaults<GetOAuthApplicationParams>, rawData: UpdateOAuthApplicationProps, headers?: RawAxiosRequestHeaders): Promise<OAuthApplicationProps>;
77
+ /**
78
+ * Deletes a specific OAuth application.
79
+ * @param params the user and oauth application IDs
80
+ * @throws if the request fails, or the user or oauth application are not found
81
+ * @example
82
+ * ```javascript
83
+ * await client.oauthApplication.delete({
84
+ * userId: '<user_id>',
85
+ * oauthApplicationId: '<oauth_application_id>'
86
+ * })
87
+ * ```
88
+ */
89
+ delete(params: OptionalDefaults<GetOAuthApplicationParams>): Promise<void>;
90
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "contentful-management",
3
- "version": "11.45.1",
3
+ "version": "11.46.0",
4
4
  "description": "Client for Contentful's Content Management API",
5
5
  "homepage": "https://www.contentful.com/developers/documentation/content-management-api/",
6
6
  "main": "./dist/contentful-management.node.js",