-
Notifications
You must be signed in to change notification settings - Fork 31
/
space.ts
81 lines (64 loc) · 1.7 KB
/
space.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import { ContentType, SpaceAPI } from './types'
import { Channel } from './channel'
const spaceMethods: Array<keyof SpaceAPI> = [
'getContentType',
'getEntry',
'getEntrySnapshots',
'getAsset',
'getEditorInterface',
'getPublishedEntries',
'getPublishedAssets',
'getContentTypes',
'getEntries',
'getEditorInterfaces',
'getAssets',
'createContentType',
'createEntry',
'createAsset',
'updateContentType',
'updateEntry',
'updateAsset',
'deleteContentType',
'deleteEntry',
'deleteAsset',
'publishEntry',
'publishAsset',
'unpublishEntry',
'unpublishAsset',
'archiveEntry',
'archiveAsset',
'unarchiveEntry',
'unarchiveAsset',
'createUpload',
'processAsset',
'waitUntilAssetProcessed',
'getUsers',
'getAllScheduledActions',
'getEntityScheduledActions',
'signRequest',
'createTag',
'readTags',
'updateTag',
'deleteTag',
'getTeams',
]
export default function createSpace(
channel: Channel,
initialContentTypes: ContentType[],
): SpaceAPI {
const space = {} as SpaceAPI
spaceMethods.forEach((methodName) => {
space[methodName] = function (...args: any[]) {
console.warn(
`You called ${String(
methodName,
)} on the Space API. Since version 4.0.0 the Space API and its methods are deprecated, and they will be removed from version 5.0.0 on. We recommend that you use the CMA client instead. See https://www.contentful.com/developers/docs/extensibility/app-framework/sdk/#using-the-contentful-management-library for more details.`,
)
return channel.call('callSpaceMethod', methodName, args)
} as any
})
space.getCachedContentTypes = () => {
return [...initialContentTypes]
}
return space
}