contentful-management 11.33.0 → 11.35.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 +929 -191
- package/dist/contentful-management.browser.js.map +1 -1
- package/dist/contentful-management.browser.min.js +1 -1
- package/dist/contentful-management.node.js +841 -147
- 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 +4 -0
- package/dist/es-modules/adapters/REST/endpoints/resource-type.js +23 -0
- package/dist/es-modules/adapters/REST/endpoints/resource.js +5 -0
- package/dist/es-modules/contentful-management.js +1 -1
- package/dist/es-modules/create-environment-api.js +78 -0
- package/dist/es-modules/entities/index.js +4 -0
- package/dist/es-modules/entities/resource-provider.js +41 -0
- package/dist/es-modules/entities/resource-type.js +93 -0
- package/dist/es-modules/entities/resource.js +7 -0
- package/dist/es-modules/plain/entities/resource-type.js +1 -0
- package/dist/es-modules/plain/entities/resource.js +1 -0
- package/dist/es-modules/plain/plain-client.js +10 -0
- package/dist/typings/adapters/REST/endpoints/index.d.ts +4 -0
- package/dist/typings/adapters/REST/endpoints/resource-type.d.ts +6 -0
- package/dist/typings/adapters/REST/endpoints/resource.d.ts +2 -0
- package/dist/typings/common-types.d.ts +49 -0
- package/dist/typings/constants/editor-interface-defaults/controls-defaults.d.ts +1 -1
- package/dist/typings/create-environment-api.d.ts +50 -0
- package/dist/typings/entities/index.d.ts +4 -0
- package/dist/typings/entities/resource-provider.d.ts +5 -1
- package/dist/typings/entities/resource-type.d.ts +52 -0
- package/dist/typings/entities/resource.d.ts +36 -0
- package/dist/typings/export-types.d.ts +2 -0
- package/dist/typings/plain/common-types.d.ts +5 -1
- package/dist/typings/plain/entities/resource-type.d.ts +14 -0
- package/dist/typings/plain/entities/resource.d.ts +38 -0
- package/package.json +1 -1
|
@@ -35,7 +35,9 @@ import * as AccessToken from './access-token';
|
|
|
35
35
|
import * as PreviewApiKey from './preview-api-key';
|
|
36
36
|
import * as Release from './release';
|
|
37
37
|
import * as ReleaseAction from './release-action';
|
|
38
|
+
import * as Resource from './resource';
|
|
38
39
|
import * as ResourceProvider from './resource-provider';
|
|
40
|
+
import * as ResourceType from './resource-type';
|
|
39
41
|
import * as Role from './role';
|
|
40
42
|
import * as ScheduledAction from './scheduled-action';
|
|
41
43
|
import * as Snapshot from './snapshot';
|
|
@@ -94,7 +96,9 @@ export default {
|
|
|
94
96
|
PreviewApiKey,
|
|
95
97
|
Release,
|
|
96
98
|
ReleaseAction,
|
|
99
|
+
Resource,
|
|
97
100
|
ResourceProvider,
|
|
101
|
+
ResourceType,
|
|
98
102
|
Role,
|
|
99
103
|
ScheduledAction,
|
|
100
104
|
Snapshot,
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import * as raw from './raw';
|
|
2
|
+
import copy from 'fast-copy';
|
|
3
|
+
const getBaseUrl = params => `/organizations/${params.organizationId}/app_definitions/${params.appDefinitionId}/resource_provider/resource_types`;
|
|
4
|
+
const getEntityUrl = params => `${getBaseUrl(params)}/${params.resourceTypeId}`;
|
|
5
|
+
const getSpaceEnvUrl = params => `/spaces/${params.spaceId}/environments/${params.environmentId}/resource_types`;
|
|
6
|
+
export const get = (http, params) => {
|
|
7
|
+
return raw.get(http, getEntityUrl(params));
|
|
8
|
+
};
|
|
9
|
+
export const upsert = (http, params, rawData, headers) => {
|
|
10
|
+
const data = copy(rawData);
|
|
11
|
+
return raw.put(http, getEntityUrl(params), data, {
|
|
12
|
+
headers
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
export const del = (http, params) => {
|
|
16
|
+
return raw.del(http, getEntityUrl(params));
|
|
17
|
+
};
|
|
18
|
+
export const getMany = (http, params) => {
|
|
19
|
+
return raw.get(http, getBaseUrl(params));
|
|
20
|
+
};
|
|
21
|
+
export const getForEnvironment = (http, params) => {
|
|
22
|
+
return raw.get(http, getSpaceEnvUrl(params));
|
|
23
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import * as raw from './raw';
|
|
2
|
+
const getBaseUrl = params => `/spaces/${params.spaceId}/environments/${params.environmentId}/resource_types/${params.resourceTypeId}/resources`;
|
|
3
|
+
export const getMany = (http, params) => raw.get(http, getBaseUrl(params), {
|
|
4
|
+
params: params.query
|
|
5
|
+
});
|
|
@@ -46,7 +46,7 @@ function createClient(params, opts = {}) {
|
|
|
46
46
|
const sdkMain = opts.type === 'plain' ? 'contentful-management-plain.js' : 'contentful-management.js';
|
|
47
47
|
const userAgent = getUserAgentHeader(
|
|
48
48
|
// @ts-expect-error
|
|
49
|
-
`${sdkMain}/${"11.
|
|
49
|
+
`${sdkMain}/${"11.35.0"}`, params.application, params.integration, params.feature);
|
|
50
50
|
const adapter = createAdapter(_objectSpread(_objectSpread({}, params), {}, {
|
|
51
51
|
userAgent
|
|
52
52
|
}));
|
|
@@ -78,6 +78,12 @@ export default function createEnvironmentApi(makeRequest) {
|
|
|
78
78
|
const {
|
|
79
79
|
wrapAppAccessToken
|
|
80
80
|
} = entities.appAccessToken;
|
|
81
|
+
const {
|
|
82
|
+
wrapResourceTypesForEnvironmentCollection
|
|
83
|
+
} = entities.resourceType;
|
|
84
|
+
const {
|
|
85
|
+
wrapResourceCollection
|
|
86
|
+
} = entities.resource;
|
|
81
87
|
return {
|
|
82
88
|
/**
|
|
83
89
|
* Deletes the environment
|
|
@@ -2249,6 +2255,78 @@ export default function createEnvironmentApi(makeRequest) {
|
|
|
2249
2255
|
environmentId: raw.sys.id
|
|
2250
2256
|
})
|
|
2251
2257
|
}).then(data => wrapEnvironmentTemplateInstallationCollection(makeRequest, data));
|
|
2258
|
+
},
|
|
2259
|
+
/**
|
|
2260
|
+
* Gets a collection of all resource types based on native external references app installations in the environment
|
|
2261
|
+
* @param query - BasicCursorPaginationOptions
|
|
2262
|
+
* @return Promise for a collection of ResourceTypes
|
|
2263
|
+
* ```javascript
|
|
2264
|
+
* const contentful = require('contentful-management')
|
|
2265
|
+
*
|
|
2266
|
+
* const client = contentful.createClient({
|
|
2267
|
+
* accessToken: '<content_management_api_key>'
|
|
2268
|
+
* })
|
|
2269
|
+
*
|
|
2270
|
+
* client.getSpace('<space_id>')
|
|
2271
|
+
* .then((space) => space.getEnvironment('<environment_id>'))
|
|
2272
|
+
* .then((environment) => environment.getResourceTypes({limit: 10}))
|
|
2273
|
+
* .then((installations) => console.log(installations.items))
|
|
2274
|
+
* .catch(console.error)
|
|
2275
|
+
* ```
|
|
2276
|
+
*/
|
|
2277
|
+
async getResourceTypes(query) {
|
|
2278
|
+
const raw = this.toPlainObject();
|
|
2279
|
+
return makeRequest({
|
|
2280
|
+
entityType: 'ResourceType',
|
|
2281
|
+
action: 'getForEnvironment',
|
|
2282
|
+
params: {
|
|
2283
|
+
query,
|
|
2284
|
+
spaceId: raw.sys.space.sys.id,
|
|
2285
|
+
environmentId: raw.sys.id
|
|
2286
|
+
}
|
|
2287
|
+
}).then(data => wrapResourceTypesForEnvironmentCollection(makeRequest, data));
|
|
2288
|
+
},
|
|
2289
|
+
/**
|
|
2290
|
+
* Gets a collection of all resources for a given resource type based on native external references app installations in the environment
|
|
2291
|
+
* @param resourceTypeId - Id of the resourceType to get its resources
|
|
2292
|
+
* @param query - Either LookupQuery options with 'sys.urn[in]' param or a Search query with 'query' param, in both cases you can add pagination options
|
|
2293
|
+
* @return Promise for a collection of Resources for a given resourceTypeId
|
|
2294
|
+
* ```javascript
|
|
2295
|
+
* const contentful = require('contentful-management')
|
|
2296
|
+
*
|
|
2297
|
+
* const client = contentful.createClient({
|
|
2298
|
+
* accessToken: '<content_management_api_key>'
|
|
2299
|
+
* })
|
|
2300
|
+
*
|
|
2301
|
+
* // Search Query
|
|
2302
|
+
* client.getSpace('<space_id>')
|
|
2303
|
+
* .then((space) => space.getEnvironment('<environment_id>'))
|
|
2304
|
+
* // <search_query> is a string you want to search for in the external resources
|
|
2305
|
+
* .then((environment) => environment.getResourcesForResourceType('<resource_type_id>', {query: '<search_query>', limit: 10}))
|
|
2306
|
+
* .then((installations) => console.log(installations.items))
|
|
2307
|
+
* .catch(console.error)
|
|
2308
|
+
*
|
|
2309
|
+
* // Lookup query
|
|
2310
|
+
*
|
|
2311
|
+
* client.getSpace('<space_id>')
|
|
2312
|
+
* .then((space) => space.getEnvironment('<environment_id>'))
|
|
2313
|
+
* .then((environment) => environment.getResourcesForResourceType('<resource_type_id>', {'sys.urn[in]': '<resource_urn1>,<resource_urn2>', limit: 10}))
|
|
2314
|
+
* .then((installations) => console.log(installations.items))
|
|
2315
|
+
* .catch(console.error)
|
|
2316
|
+
* ```
|
|
2317
|
+
*/
|
|
2318
|
+
async getResourcesForResourceType(resourceTypeId, query) {
|
|
2319
|
+
const raw = this.toPlainObject();
|
|
2320
|
+
return makeRequest({
|
|
2321
|
+
entityType: 'Resource',
|
|
2322
|
+
action: 'getMany',
|
|
2323
|
+
params: {
|
|
2324
|
+
query,
|
|
2325
|
+
spaceId: raw.sys.space.sys.id,
|
|
2326
|
+
environmentId: raw.sys.id,
|
|
2327
|
+
resourceTypeId
|
|
2328
|
+
}
|
|
2329
|
+
}).then(data => wrapResourceCollection(makeRequest, data));
|
|
2252
2330
|
}
|
|
2253
2331
|
};
|
|
2254
2332
|
}
|
|
@@ -53,6 +53,8 @@ import * as workflowDefinition from './workflow-definition';
|
|
|
53
53
|
import * as concept from './concept';
|
|
54
54
|
import * as conceptScheme from './concept-scheme';
|
|
55
55
|
import * as resourceProvider from './resource-provider';
|
|
56
|
+
import * as resourceType from './resource-type';
|
|
57
|
+
import * as resource from './resource';
|
|
56
58
|
export default {
|
|
57
59
|
accessToken,
|
|
58
60
|
appAction,
|
|
@@ -91,6 +93,8 @@ export default {
|
|
|
91
93
|
release,
|
|
92
94
|
releaseAction,
|
|
93
95
|
resourceProvider,
|
|
96
|
+
resourceType,
|
|
97
|
+
resource,
|
|
94
98
|
role,
|
|
95
99
|
scheduledAction,
|
|
96
100
|
snapshot,
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import { toPlainObject, freezeSys } from 'contentful-sdk-core';
|
|
2
2
|
import copy from 'fast-copy';
|
|
3
3
|
import enhanceWithMethods from '../enhance-with-methods';
|
|
4
|
+
import entities from '.';
|
|
4
5
|
/**
|
|
5
6
|
* @private
|
|
6
7
|
*/
|
|
7
8
|
function createResourceProviderApi(makeRequest) {
|
|
9
|
+
const {
|
|
10
|
+
wrapResourceType
|
|
11
|
+
} = entities.resourceType;
|
|
8
12
|
return {
|
|
9
13
|
/**
|
|
10
14
|
* Sends an update to the server with any changes made to the object's properties
|
|
@@ -60,6 +64,43 @@ function createResourceProviderApi(makeRequest) {
|
|
|
60
64
|
action: 'delete',
|
|
61
65
|
params: getParams(data)
|
|
62
66
|
});
|
|
67
|
+
},
|
|
68
|
+
getResourceType: function getResourceType(id) {
|
|
69
|
+
return makeRequest({
|
|
70
|
+
entityType: 'ResourceType',
|
|
71
|
+
action: 'get',
|
|
72
|
+
params: {
|
|
73
|
+
organizationId: this.sys.organization.sys.id,
|
|
74
|
+
appDefinitionId: this.sys.appDefinition.sys.id,
|
|
75
|
+
resourceTypeId: id
|
|
76
|
+
}
|
|
77
|
+
}).then(data => wrapResourceType(makeRequest, data));
|
|
78
|
+
},
|
|
79
|
+
upsertResourceType: function upsertResourceType(id, data) {
|
|
80
|
+
return makeRequest({
|
|
81
|
+
entityType: 'ResourceType',
|
|
82
|
+
action: 'upsert',
|
|
83
|
+
params: {
|
|
84
|
+
organizationId: this.sys.organization.sys.id,
|
|
85
|
+
appDefinitionId: this.sys.appDefinition.sys.id,
|
|
86
|
+
resourceTypeId: id
|
|
87
|
+
},
|
|
88
|
+
headers: {},
|
|
89
|
+
payload: data
|
|
90
|
+
}).then(data => wrapResourceType(makeRequest, data));
|
|
91
|
+
},
|
|
92
|
+
getResourceTypes: function getResourceTypes() {
|
|
93
|
+
return makeRequest({
|
|
94
|
+
entityType: 'ResourceType',
|
|
95
|
+
action: 'getMany',
|
|
96
|
+
params: {
|
|
97
|
+
organizationId: this.sys.organization.sys.id,
|
|
98
|
+
appDefinitionId: this.sys.appDefinition.sys.id
|
|
99
|
+
}
|
|
100
|
+
}).then(data => {
|
|
101
|
+
data.items = data.items.map(item => wrapResourceType(makeRequest, item));
|
|
102
|
+
return data;
|
|
103
|
+
});
|
|
63
104
|
}
|
|
64
105
|
};
|
|
65
106
|
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { toPlainObject, freezeSys } from 'contentful-sdk-core';
|
|
2
|
+
import copy from 'fast-copy';
|
|
3
|
+
import enhanceWithMethods from '../enhance-with-methods';
|
|
4
|
+
import { wrapCursorPaginatedCollection } from '../common-utils';
|
|
5
|
+
const publicResourceTypeFields = ['name'];
|
|
6
|
+
/**
|
|
7
|
+
* @private
|
|
8
|
+
*/
|
|
9
|
+
function createResourceTypeApi(makeRequest) {
|
|
10
|
+
return {
|
|
11
|
+
/**
|
|
12
|
+
* Sends an update to the server with any changes made to the object's properties
|
|
13
|
+
* @return Object returned from the server with updated changes.
|
|
14
|
+
* @example ```javascript
|
|
15
|
+
* const contentful = require('contentful-management')
|
|
16
|
+
*
|
|
17
|
+
* const client = contentful.createClient({
|
|
18
|
+
* accessToken: '<content_management_api_key>'
|
|
19
|
+
* })
|
|
20
|
+
*
|
|
21
|
+
* client.getOrganization('<org_id>')
|
|
22
|
+
* .then((org) => org.getAppDefinition('<app_def_id>'))
|
|
23
|
+
* .then((appDefinition) => appDefinition.getResourceType())
|
|
24
|
+
* .then((resourceType) => {
|
|
25
|
+
* resourceType.name = '<new_name>'
|
|
26
|
+
* return resourceType.upsert()
|
|
27
|
+
* })
|
|
28
|
+
* .catch(console.error)
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
upsert: function upsert() {
|
|
32
|
+
const data = this.toPlainObject();
|
|
33
|
+
return makeRequest({
|
|
34
|
+
entityType: 'ResourceType',
|
|
35
|
+
action: 'upsert',
|
|
36
|
+
params: getParams(data),
|
|
37
|
+
headers: {},
|
|
38
|
+
payload: getUpsertParams(data)
|
|
39
|
+
}).then(data => wrapResourceType(makeRequest, data));
|
|
40
|
+
},
|
|
41
|
+
/**
|
|
42
|
+
* Deletes this object on the server.
|
|
43
|
+
* @return Promise for the deletion. It contains no data, but the Promise error case should be handled.
|
|
44
|
+
* @example ```javascript
|
|
45
|
+
* const contentful = require('contentful-management')
|
|
46
|
+
*
|
|
47
|
+
* const client = contentful.createClient({
|
|
48
|
+
* accessToken: '<content_management_api_key>'
|
|
49
|
+
* })
|
|
50
|
+
*
|
|
51
|
+
* client.getOrganization('<org_id>')
|
|
52
|
+
* .then((org) => org.getAppDefinition('<app_def_id>'))
|
|
53
|
+
* .then((appDefinition) => appDefinition.getResourceType())
|
|
54
|
+
* .then((resourceType) => resourceType.delete())
|
|
55
|
+
* .catch(console.error)
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
delete: function del() {
|
|
59
|
+
const data = this.toPlainObject();
|
|
60
|
+
return makeRequest({
|
|
61
|
+
entityType: 'ResourceType',
|
|
62
|
+
action: 'delete',
|
|
63
|
+
params: getParams(data)
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
const getParams = data => ({
|
|
69
|
+
organizationId: data.sys.organization.sys.id,
|
|
70
|
+
appDefinitionId: data.sys.appDefinition.sys.id,
|
|
71
|
+
resourceTypeId: data.sys.id
|
|
72
|
+
});
|
|
73
|
+
const getUpsertParams = data => ({
|
|
74
|
+
name: data.name,
|
|
75
|
+
defaultFieldMapping: data.defaultFieldMapping
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* @private
|
|
80
|
+
* @param makeRequest - function to make requests via an adapter
|
|
81
|
+
* @param data - Raw Resource Type data
|
|
82
|
+
* @return Wrapped Resource Type data
|
|
83
|
+
*/
|
|
84
|
+
export function wrapResourceType(makeRequest, data) {
|
|
85
|
+
const resourceType = toPlainObject(copy(data));
|
|
86
|
+
const ResourceTypeWithMethods = enhanceWithMethods(resourceType, createResourceTypeApi(makeRequest));
|
|
87
|
+
return freezeSys(ResourceTypeWithMethods);
|
|
88
|
+
}
|
|
89
|
+
export function wrapResourceTypeforEnvironment(makeRequest, data) {
|
|
90
|
+
const resourceType = toPlainObject(data);
|
|
91
|
+
return freezeSys(resourceType);
|
|
92
|
+
}
|
|
93
|
+
export const wrapResourceTypesForEnvironmentCollection = wrapCursorPaginatedCollection(wrapResourceTypeforEnvironment);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { wrapCursorPaginatedCollection } from '../common-utils';
|
|
2
|
+
import { freezeSys, toPlainObject } from 'contentful-sdk-core';
|
|
3
|
+
export function wrapResource(makeRequest, data) {
|
|
4
|
+
const resource = toPlainObject(data);
|
|
5
|
+
return freezeSys(resource);
|
|
6
|
+
}
|
|
7
|
+
export const wrapResourceCollection = wrapCursorPaginatedCollection(wrapResource);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -374,11 +374,21 @@ export const createPlainClient = (makeRequest, defaults) => {
|
|
|
374
374
|
upsert: wrap(wrapParams, 'AppInstallation', 'upsert'),
|
|
375
375
|
delete: wrap(wrapParams, 'AppInstallation', 'delete')
|
|
376
376
|
},
|
|
377
|
+
resource: {
|
|
378
|
+
getMany: wrap(wrapParams, 'Resource', 'getMany')
|
|
379
|
+
},
|
|
377
380
|
resourceProvider: {
|
|
378
381
|
get: wrap(wrapParams, 'ResourceProvider', 'get'),
|
|
379
382
|
upsert: wrap(wrapParams, 'ResourceProvider', 'upsert'),
|
|
380
383
|
delete: wrap(wrapParams, 'ResourceProvider', 'delete')
|
|
381
384
|
},
|
|
385
|
+
resourceType: {
|
|
386
|
+
get: wrap(wrapParams, 'ResourceType', 'get'),
|
|
387
|
+
getMany: wrap(wrapParams, 'ResourceType', 'getMany'),
|
|
388
|
+
upsert: wrap(wrapParams, 'ResourceType', 'upsert'),
|
|
389
|
+
delete: wrap(wrapParams, 'ResourceType', 'delete'),
|
|
390
|
+
getForEnvironment: wrap(wrapParams, 'ResourceType', 'getForEnvironment')
|
|
391
|
+
},
|
|
382
392
|
extension: {
|
|
383
393
|
get: wrap(wrapParams, 'Extension', 'get'),
|
|
384
394
|
getMany: wrap(wrapParams, 'Extension', 'getMany'),
|
|
@@ -35,7 +35,9 @@ import * as AccessToken from './access-token';
|
|
|
35
35
|
import * as PreviewApiKey from './preview-api-key';
|
|
36
36
|
import * as Release from './release';
|
|
37
37
|
import * as ReleaseAction from './release-action';
|
|
38
|
+
import * as Resource from './resource';
|
|
38
39
|
import * as ResourceProvider from './resource-provider';
|
|
40
|
+
import * as ResourceType from './resource-type';
|
|
39
41
|
import * as Role from './role';
|
|
40
42
|
import * as ScheduledAction from './scheduled-action';
|
|
41
43
|
import * as Snapshot from './snapshot';
|
|
@@ -94,7 +96,9 @@ declare const _default: {
|
|
|
94
96
|
PreviewApiKey: typeof PreviewApiKey;
|
|
95
97
|
Release: typeof Release;
|
|
96
98
|
ReleaseAction: typeof ReleaseAction;
|
|
99
|
+
Resource: typeof Resource;
|
|
97
100
|
ResourceProvider: typeof ResourceProvider;
|
|
101
|
+
ResourceType: typeof ResourceType;
|
|
98
102
|
Role: typeof Role;
|
|
99
103
|
ScheduledAction: typeof ScheduledAction;
|
|
100
104
|
Snapshot: typeof Snapshot;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { RestEndpoint } from '../types';
|
|
2
|
+
export declare const get: RestEndpoint<'ResourceType', 'get'>;
|
|
3
|
+
export declare const upsert: RestEndpoint<'ResourceType', 'upsert'>;
|
|
4
|
+
export declare const del: RestEndpoint<'ResourceType', 'delete'>;
|
|
5
|
+
export declare const getMany: RestEndpoint<'ResourceType', 'getMany'>;
|
|
6
|
+
export declare const getForEnvironment: RestEndpoint<'ResourceType', 'getForEnvironment'>;
|
|
@@ -59,6 +59,8 @@ import type { AppAccessTokenProps, CreateAppAccessTokenProps } from './entities/
|
|
|
59
59
|
import type { ConceptProps, CreateConceptProps } from './entities/concept';
|
|
60
60
|
import type { ConceptSchemeProps, CreateConceptSchemeProps } from './entities/concept-scheme';
|
|
61
61
|
import type { ResourceProviderProps, UpsertResourceProviderProps } from './entities/resource-provider';
|
|
62
|
+
import type { ResourceTypeProps, SpaceEnvResourceTypeProps, UpsertResourceTypeProps } from './entities/resource-type';
|
|
63
|
+
import type { ResourceProps, ResourceQueryOptions } from './entities/resource';
|
|
62
64
|
export interface DefaultElements<TPlainObject extends object = object> {
|
|
63
65
|
toPlainObject(): TPlainObject;
|
|
64
66
|
}
|
|
@@ -377,9 +379,15 @@ type MRInternal<UA extends boolean> = {
|
|
|
377
379
|
(opts: MROpts<'ReleaseAction', 'get', UA>): MRReturn<'ReleaseAction', 'get'>;
|
|
378
380
|
(opts: MROpts<'ReleaseAction', 'getMany', UA>): MRReturn<'ReleaseAction', 'getMany'>;
|
|
379
381
|
(opts: MROpts<'ReleaseAction', 'queryForRelease', UA>): MRReturn<'ReleaseAction', 'queryForRelease'>;
|
|
382
|
+
(opts: MROpts<'Resource', 'getMany', UA>): MRReturn<'Resource', 'getMany'>;
|
|
380
383
|
(opts: MROpts<'ResourceProvider', 'get', UA>): MRReturn<'ResourceProvider', 'get'>;
|
|
381
384
|
(opts: MROpts<'ResourceProvider', 'upsert', UA>): MRReturn<'ResourceProvider', 'upsert'>;
|
|
382
385
|
(opts: MROpts<'ResourceProvider', 'delete', UA>): MRReturn<'ResourceProvider', 'delete'>;
|
|
386
|
+
(opts: MROpts<'ResourceType', 'get', UA>): MRReturn<'ResourceType', 'get'>;
|
|
387
|
+
(opts: MROpts<'ResourceType', 'upsert', UA>): MRReturn<'ResourceType', 'upsert'>;
|
|
388
|
+
(opts: MROpts<'ResourceType', 'delete', UA>): MRReturn<'ResourceType', 'delete'>;
|
|
389
|
+
(opts: MROpts<'ResourceType', 'getForEnvironment', UA>): MRReturn<'ResourceType', 'getForEnvironment'>;
|
|
390
|
+
(opts: MROpts<'ResourceType', 'getMany', UA>): MRReturn<'ResourceType', 'getMany'>;
|
|
383
391
|
(opts: MROpts<'Role', 'get', UA>): MRReturn<'Role', 'get'>;
|
|
384
392
|
(opts: MROpts<'Role', 'getMany', UA>): MRReturn<'Role', 'getMany'>;
|
|
385
393
|
(opts: MROpts<'Role', 'getManyForOrganization', UA>): MRReturn<'Role', 'getManyForOrganization'>;
|
|
@@ -508,6 +516,15 @@ export interface Adapter {
|
|
|
508
516
|
* @private
|
|
509
517
|
*/
|
|
510
518
|
export type MRActions = {
|
|
519
|
+
Resource: {
|
|
520
|
+
getMany: {
|
|
521
|
+
params: GetResourceParams & {
|
|
522
|
+
query?: ResourceQueryOptions;
|
|
523
|
+
};
|
|
524
|
+
headers?: RawAxiosRequestHeaders;
|
|
525
|
+
return: CursorPaginatedCollectionProp<ResourceProps>;
|
|
526
|
+
};
|
|
527
|
+
};
|
|
511
528
|
ResourceProvider: {
|
|
512
529
|
get: {
|
|
513
530
|
params: GetResourceProviderParams;
|
|
@@ -524,6 +541,32 @@ export type MRActions = {
|
|
|
524
541
|
return: any;
|
|
525
542
|
};
|
|
526
543
|
};
|
|
544
|
+
ResourceType: {
|
|
545
|
+
get: {
|
|
546
|
+
params: GetResourceTypeParams;
|
|
547
|
+
return: ResourceTypeProps;
|
|
548
|
+
};
|
|
549
|
+
getMany: {
|
|
550
|
+
params: Omit<GetResourceTypeParams, 'resourceTypeId'>;
|
|
551
|
+
return: CollectionProp<ResourceTypeProps>;
|
|
552
|
+
};
|
|
553
|
+
upsert: {
|
|
554
|
+
params: GetResourceTypeParams;
|
|
555
|
+
payload: UpsertResourceTypeProps;
|
|
556
|
+
headers?: RawAxiosRequestHeaders;
|
|
557
|
+
return: ResourceTypeProps;
|
|
558
|
+
};
|
|
559
|
+
delete: {
|
|
560
|
+
params: GetResourceTypeParams;
|
|
561
|
+
return: any;
|
|
562
|
+
};
|
|
563
|
+
getForEnvironment: {
|
|
564
|
+
params: GetSpaceEnvironmentParams & {
|
|
565
|
+
query?: BasicCursorPaginationOptions;
|
|
566
|
+
};
|
|
567
|
+
return: CursorPaginatedCollectionProp<SpaceEnvResourceTypeProps>;
|
|
568
|
+
};
|
|
569
|
+
};
|
|
527
570
|
Http: {
|
|
528
571
|
get: {
|
|
529
572
|
params: {
|
|
@@ -2378,6 +2421,12 @@ export type GetUserUIConfigParams = GetUIConfigParams;
|
|
|
2378
2421
|
export type GetResourceProviderParams = GetOrganizationParams & {
|
|
2379
2422
|
appDefinitionId: string;
|
|
2380
2423
|
};
|
|
2424
|
+
export type GetResourceTypeParams = GetResourceProviderParams & {
|
|
2425
|
+
resourceTypeId: string;
|
|
2426
|
+
};
|
|
2427
|
+
export type GetResourceParams = GetSpaceEnvironmentParams & {
|
|
2428
|
+
resourceTypeId: string;
|
|
2429
|
+
};
|
|
2381
2430
|
export type QueryParams = {
|
|
2382
2431
|
query?: QueryOptions;
|
|
2383
2432
|
};
|
|
@@ -91,7 +91,7 @@ export declare const FIELD_TYPES: Array<keyof typeof INTERNAL_TO_API>;
|
|
|
91
91
|
* - Assets
|
|
92
92
|
* - File
|
|
93
93
|
*/
|
|
94
|
-
export declare function toInternalFieldType(api: Partial<ContentFields>): "File" | "Entries" | "Boolean" | "Symbol" | "Number" | "Asset" | "Entry" | "Text" | "RichText" | "Integer" | "Date" | "Object" | "Location" | "
|
|
94
|
+
export declare function toInternalFieldType(api: Partial<ContentFields>): "File" | "Entries" | "Boolean" | "Symbol" | "Number" | "Asset" | "Entry" | "Resource" | "Text" | "RichText" | "Integer" | "Date" | "Object" | "Location" | "Symbols" | "Assets" | "Resources" | undefined;
|
|
95
95
|
export declare const DEFAULTS_WIDGET: {
|
|
96
96
|
Text: {
|
|
97
97
|
widgetId: string;
|
|
@@ -15,6 +15,7 @@ import type { CreateExtensionProps } from './entities/extension';
|
|
|
15
15
|
import type { CreateLocaleProps } from './entities/locale';
|
|
16
16
|
import type { TagVisibility } from './entities/tag';
|
|
17
17
|
import type { CreateAppAccessTokenProps } from './entities/app-access-token';
|
|
18
|
+
import type { ResourceQueryOptions } from './entities/resource';
|
|
18
19
|
/**
|
|
19
20
|
* @private
|
|
20
21
|
*/
|
|
@@ -1489,4 +1490,53 @@ export default function createEnvironmentApi(makeRequest: MakeRequest): {
|
|
|
1489
1490
|
getEnvironmentTemplateInstallations(environmentTemplateId: string, { installationId, ...query }?: BasicCursorPaginationOptions & {
|
|
1490
1491
|
installationId?: string;
|
|
1491
1492
|
}): Promise<import("./common-types").CursorPaginatedCollection<import("./entities/environment-template-installation").EnvironmentTemplateInstallation, import("./entities/environment-template-installation").EnvironmentTemplateInstallationProps>>;
|
|
1493
|
+
/**
|
|
1494
|
+
* Gets a collection of all resource types based on native external references app installations in the environment
|
|
1495
|
+
* @param query - BasicCursorPaginationOptions
|
|
1496
|
+
* @return Promise for a collection of ResourceTypes
|
|
1497
|
+
* ```javascript
|
|
1498
|
+
* const contentful = require('contentful-management')
|
|
1499
|
+
*
|
|
1500
|
+
* const client = contentful.createClient({
|
|
1501
|
+
* accessToken: '<content_management_api_key>'
|
|
1502
|
+
* })
|
|
1503
|
+
*
|
|
1504
|
+
* client.getSpace('<space_id>')
|
|
1505
|
+
* .then((space) => space.getEnvironment('<environment_id>'))
|
|
1506
|
+
* .then((environment) => environment.getResourceTypes({limit: 10}))
|
|
1507
|
+
* .then((installations) => console.log(installations.items))
|
|
1508
|
+
* .catch(console.error)
|
|
1509
|
+
* ```
|
|
1510
|
+
*/
|
|
1511
|
+
getResourceTypes(query?: BasicCursorPaginationOptions): Promise<import("./common-types").CursorPaginatedCollectionProp<import("./export-types").SpaceEnvResourceTypeProps>>;
|
|
1512
|
+
/**
|
|
1513
|
+
* Gets a collection of all resources for a given resource type based on native external references app installations in the environment
|
|
1514
|
+
* @param resourceTypeId - Id of the resourceType to get its resources
|
|
1515
|
+
* @param query - Either LookupQuery options with 'sys.urn[in]' param or a Search query with 'query' param, in both cases you can add pagination options
|
|
1516
|
+
* @return Promise for a collection of Resources for a given resourceTypeId
|
|
1517
|
+
* ```javascript
|
|
1518
|
+
* const contentful = require('contentful-management')
|
|
1519
|
+
*
|
|
1520
|
+
* const client = contentful.createClient({
|
|
1521
|
+
* accessToken: '<content_management_api_key>'
|
|
1522
|
+
* })
|
|
1523
|
+
*
|
|
1524
|
+
* // Search Query
|
|
1525
|
+
* client.getSpace('<space_id>')
|
|
1526
|
+
* .then((space) => space.getEnvironment('<environment_id>'))
|
|
1527
|
+
* // <search_query> is a string you want to search for in the external resources
|
|
1528
|
+
* .then((environment) => environment.getResourcesForResourceType('<resource_type_id>', {query: '<search_query>', limit: 10}))
|
|
1529
|
+
* .then((installations) => console.log(installations.items))
|
|
1530
|
+
* .catch(console.error)
|
|
1531
|
+
*
|
|
1532
|
+
* // Lookup query
|
|
1533
|
+
*
|
|
1534
|
+
* client.getSpace('<space_id>')
|
|
1535
|
+
* .then((space) => space.getEnvironment('<environment_id>'))
|
|
1536
|
+
* .then((environment) => environment.getResourcesForResourceType('<resource_type_id>', {'sys.urn[in]': '<resource_urn1>,<resource_urn2>', limit: 10}))
|
|
1537
|
+
* .then((installations) => console.log(installations.items))
|
|
1538
|
+
* .catch(console.error)
|
|
1539
|
+
* ```
|
|
1540
|
+
*/
|
|
1541
|
+
getResourcesForResourceType(resourceTypeId: string, query?: ResourceQueryOptions): Promise<import("./common-types").CursorPaginatedCollectionProp<import("./entities/resource").ResourceProps>>;
|
|
1492
1542
|
};
|
|
@@ -53,6 +53,8 @@ import * as workflowDefinition from './workflow-definition';
|
|
|
53
53
|
import * as concept from './concept';
|
|
54
54
|
import * as conceptScheme from './concept-scheme';
|
|
55
55
|
import * as resourceProvider from './resource-provider';
|
|
56
|
+
import * as resourceType from './resource-type';
|
|
57
|
+
import * as resource from './resource';
|
|
56
58
|
declare const _default: {
|
|
57
59
|
accessToken: typeof accessToken;
|
|
58
60
|
appAction: typeof appAction;
|
|
@@ -91,6 +93,8 @@ declare const _default: {
|
|
|
91
93
|
release: typeof release;
|
|
92
94
|
releaseAction: typeof releaseAction;
|
|
93
95
|
resourceProvider: typeof resourceProvider;
|
|
96
|
+
resourceType: typeof resourceType;
|
|
97
|
+
resource: typeof resource;
|
|
94
98
|
role: typeof role;
|
|
95
99
|
scheduledAction: typeof scheduledAction;
|
|
96
100
|
snapshot: typeof snapshot;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { BasicMetaSysProps, DefaultElements, MakeRequest, SysLink } from '../common-types';
|
|
1
|
+
import type { BasicMetaSysProps, CollectionProp, DefaultElements, MakeRequest, SysLink } from '../common-types';
|
|
2
|
+
import type { ResourceType, UpsertResourceTypeProps } from './resource-type';
|
|
2
3
|
export type ResourceProviderProps = {
|
|
3
4
|
/**
|
|
4
5
|
* System metadata
|
|
@@ -24,6 +25,9 @@ export type UpsertResourceProviderProps = Omit<ResourceProviderProps, 'sys'> & {
|
|
|
24
25
|
export interface ResourceProvider extends ResourceProviderProps, DefaultElements<ResourceProviderProps> {
|
|
25
26
|
upsert(): Promise<ResourceProvider>;
|
|
26
27
|
delete(): Promise<void>;
|
|
28
|
+
upsertResourceType(id: string, data: UpsertResourceTypeProps): Promise<ResourceType>;
|
|
29
|
+
getResourceType(id: string): Promise<ResourceType>;
|
|
30
|
+
getResourceTypes(): Promise<CollectionProp<ResourceType>>;
|
|
27
31
|
}
|
|
28
32
|
/**
|
|
29
33
|
* @private
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { BasicMetaSysProps, CursorPaginatedCollectionProp, DefaultElements, MakeRequest, SysLink } from '../common-types';
|
|
2
|
+
export type ResourceTypeProps = {
|
|
3
|
+
/**
|
|
4
|
+
* System metadata
|
|
5
|
+
*/
|
|
6
|
+
sys: Omit<BasicMetaSysProps, 'version'> & {
|
|
7
|
+
appDefinition: SysLink;
|
|
8
|
+
resourceProvider: SysLink;
|
|
9
|
+
organization: SysLink;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Resource Type name
|
|
13
|
+
*/
|
|
14
|
+
name: string;
|
|
15
|
+
/**
|
|
16
|
+
* Resource Type defaultFieldMapping
|
|
17
|
+
*/
|
|
18
|
+
defaultFieldMapping: {
|
|
19
|
+
title: string;
|
|
20
|
+
subtitle?: string;
|
|
21
|
+
description?: string;
|
|
22
|
+
externalUrl?: string;
|
|
23
|
+
image?: {
|
|
24
|
+
url: string;
|
|
25
|
+
altText?: string;
|
|
26
|
+
};
|
|
27
|
+
badge?: {
|
|
28
|
+
label: string;
|
|
29
|
+
variant: string;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
declare const publicResourceTypeFields: readonly ["name"];
|
|
34
|
+
type OptionalSysFields = 'createdAt' | 'createdBy' | 'updatedAt' | 'updatedBy' | 'appDefinition' | 'organization';
|
|
35
|
+
export type SpaceEnvResourceTypeProps = Pick<ResourceTypeProps, typeof publicResourceTypeFields[number]> & {
|
|
36
|
+
sys: Partial<Pick<ResourceTypeProps['sys'], OptionalSysFields>> & Omit<ResourceTypeProps['sys'], OptionalSysFields>;
|
|
37
|
+
};
|
|
38
|
+
export type UpsertResourceTypeProps = Omit<ResourceTypeProps, 'sys'>;
|
|
39
|
+
export interface ResourceType extends ResourceTypeProps, DefaultElements<ResourceTypeProps> {
|
|
40
|
+
upsert(): Promise<ResourceType>;
|
|
41
|
+
delete(): Promise<void>;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* @private
|
|
45
|
+
* @param makeRequest - function to make requests via an adapter
|
|
46
|
+
* @param data - Raw Resource Type data
|
|
47
|
+
* @return Wrapped Resource Type data
|
|
48
|
+
*/
|
|
49
|
+
export declare function wrapResourceType(makeRequest: MakeRequest, data: ResourceTypeProps): ResourceType;
|
|
50
|
+
export declare function wrapResourceTypeforEnvironment(makeRequest: MakeRequest, data: SpaceEnvResourceTypeProps): SpaceEnvResourceTypeProps;
|
|
51
|
+
export declare const wrapResourceTypesForEnvironmentCollection: (makeRequest: MakeRequest, data: CursorPaginatedCollectionProp<SpaceEnvResourceTypeProps>) => CursorPaginatedCollectionProp<SpaceEnvResourceTypeProps>;
|
|
52
|
+
export {};
|