@contentful/field-editor-reference 5.30.9 → 5.30.11
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/cjs/common/EntityStore.js +10 -5
- package/dist/cjs/resources/Cards/ResourceCard.spec.js +26 -19
- package/dist/cjs/resources/ExternalResourceCard/ExternalResourceCard.js +1 -7
- package/dist/esm/common/EntityStore.js +10 -5
- package/dist/esm/resources/Cards/ResourceCard.spec.js +26 -19
- package/dist/esm/resources/ExternalResourceCard/ExternalResourceCard.js +1 -7
- package/dist/types/resources/ExternalResourceCard/ExternalResourceCard.d.ts +0 -7
- package/dist/types/types.d.ts +3 -39
- package/package.json +7 -7
|
@@ -117,7 +117,7 @@ const isEntityQueryKey = (queryKey)=>{
|
|
|
117
117
|
async function fetchContentfulEntry({ urn, fetch, options }) {
|
|
118
118
|
const resourceId = urn.split(':', 6)[5];
|
|
119
119
|
const ENTITY_RESOURCE_ID_REGEX = RegExp("^spaces\\/(?<spaceId>[^/]+)(?:\\/environments\\/(?<environmentId>[^/]+))?\\/entries\\/(?<entityId>[^/]+)$");
|
|
120
|
-
const resourceIdMatch = resourceId
|
|
120
|
+
const resourceIdMatch = resourceId?.match(ENTITY_RESOURCE_ID_REGEX);
|
|
121
121
|
if (!resourceIdMatch || !resourceIdMatch?.groups?.spaceId || !resourceIdMatch?.groups?.entityId) {
|
|
122
122
|
throw new Error('Not a valid crn');
|
|
123
123
|
}
|
|
@@ -185,8 +185,11 @@ async function fetchExternalResource({ urn, fetch, options, spaceId, environment
|
|
|
185
185
|
environmentId,
|
|
186
186
|
resourceType,
|
|
187
187
|
urn
|
|
188
|
-
], ({ cmaClient })=>cmaClient.
|
|
189
|
-
|
|
188
|
+
], ({ cmaClient })=>cmaClient.resource.getMany({
|
|
189
|
+
spaceId,
|
|
190
|
+
environmentId,
|
|
191
|
+
resourceTypeId: resourceType,
|
|
192
|
+
query: {
|
|
190
193
|
'sys.urn[in]': urn
|
|
191
194
|
}
|
|
192
195
|
}).then(({ items })=>items[0] ?? null), options),
|
|
@@ -194,8 +197,10 @@ async function fetchExternalResource({ urn, fetch, options, spaceId, environment
|
|
|
194
197
|
'resource-types',
|
|
195
198
|
spaceId,
|
|
196
199
|
environmentId
|
|
197
|
-
], ({ cmaClient })=>(0, _contentfulmanagement.fetchAll)(({ query })=>cmaClient.
|
|
198
|
-
|
|
200
|
+
], ({ cmaClient })=>(0, _contentfulmanagement.fetchAll)(({ query })=>cmaClient.resourceType.getForEnvironment({
|
|
201
|
+
spaceId,
|
|
202
|
+
environmentId,
|
|
203
|
+
query
|
|
199
204
|
}), {}))
|
|
200
205
|
]);
|
|
201
206
|
const resourceTypeEntity = resourceTypes.find((rt)=>rt.sys.id === resourceType);
|
|
@@ -91,17 +91,19 @@ const sdk = {
|
|
|
91
91
|
return Promise.reject(new Error());
|
|
92
92
|
})
|
|
93
93
|
},
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
94
|
+
Locale: {
|
|
95
|
+
getMany: jest.fn().mockResolvedValue({
|
|
96
|
+
items: [
|
|
97
|
+
{
|
|
98
|
+
default: true,
|
|
99
|
+
code: 'en'
|
|
100
|
+
}
|
|
101
|
+
]
|
|
102
|
+
})
|
|
103
|
+
},
|
|
104
|
+
Resource: {
|
|
105
|
+
getMany: jest.fn().mockImplementation(({ spaceId, environmentId, resourceTypeId, query })=>{
|
|
106
|
+
if (spaceId === 'space-id' && environmentId === 'environment-id' && resourceTypeId === resolvableExternalResourceType && query['sys.urn[in]'] === resolvableExternalEntityUrn) {
|
|
105
107
|
return Promise.resolve({
|
|
106
108
|
items: [
|
|
107
109
|
_resourcejson.default
|
|
@@ -113,14 +115,19 @@ const sdk = {
|
|
|
113
115
|
});
|
|
114
116
|
})
|
|
115
117
|
},
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
{
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
118
|
+
ResourceType: {
|
|
119
|
+
getForEnvironment: jest.fn().mockImplementation(({ spaceId, environmentId })=>{
|
|
120
|
+
if (spaceId === 'space-id' && environmentId === 'environment-id') {
|
|
121
|
+
return Promise.resolve({
|
|
122
|
+
items: [
|
|
123
|
+
_resourcetypejson.default
|
|
124
|
+
],
|
|
125
|
+
pages: {}
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
return Promise.resolve({
|
|
129
|
+
items: []
|
|
130
|
+
});
|
|
124
131
|
})
|
|
125
132
|
},
|
|
126
133
|
ScheduledAction: {
|
|
@@ -59,11 +59,6 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
59
59
|
}
|
|
60
60
|
return newObj;
|
|
61
61
|
}
|
|
62
|
-
const defaultProps = {
|
|
63
|
-
isClickable: true,
|
|
64
|
-
hasCardMoveActions: true,
|
|
65
|
-
hasCardRemoveActions: true
|
|
66
|
-
};
|
|
67
62
|
const styles = {
|
|
68
63
|
subtitle: (0, _emotion.css)({
|
|
69
64
|
color: _f36tokens.default.gray600
|
|
@@ -98,7 +93,7 @@ function ExternalResourceCardDescription({ subtitle, description }) {
|
|
|
98
93
|
}, truncatedDescription));
|
|
99
94
|
}
|
|
100
95
|
ExternalResourceCardDescription.displayName = 'ExternalResourceCardDescription';
|
|
101
|
-
function ExternalResourceCard({ info, isClickable, onEdit, onRemove, onMoveTop, onMoveBottom, hasCardEditActions, hasCardMoveActions, hasCardRemoveActions, renderDragHandle, onClick, isSelected }) {
|
|
96
|
+
function ExternalResourceCard({ info, isClickable = true, onEdit, onRemove, onMoveTop, onMoveBottom, hasCardEditActions, hasCardMoveActions = true, hasCardRemoveActions = true, renderDragHandle, onClick, isSelected }) {
|
|
102
97
|
const { resource: entity, resourceType } = info;
|
|
103
98
|
const badge = ExternalEntityBadge(entity.fields.badge);
|
|
104
99
|
return _react.createElement(_f36components.EntryCard, {
|
|
@@ -154,4 +149,3 @@ function ExternalResourceCard({ info, isClickable, onEdit, onRemove, onMoveTop,
|
|
|
154
149
|
description: entity.fields.description
|
|
155
150
|
}));
|
|
156
151
|
}
|
|
157
|
-
ExternalResourceCard.defaultProps = defaultProps;
|
|
@@ -38,7 +38,7 @@ const isEntityQueryKey = (queryKey)=>{
|
|
|
38
38
|
async function fetchContentfulEntry({ urn, fetch, options }) {
|
|
39
39
|
const resourceId = urn.split(':', 6)[5];
|
|
40
40
|
const ENTITY_RESOURCE_ID_REGEX = RegExp("^spaces\\/(?<spaceId>[^/]+)(?:\\/environments\\/(?<environmentId>[^/]+))?\\/entries\\/(?<entityId>[^/]+)$");
|
|
41
|
-
const resourceIdMatch = resourceId
|
|
41
|
+
const resourceIdMatch = resourceId?.match(ENTITY_RESOURCE_ID_REGEX);
|
|
42
42
|
if (!resourceIdMatch || !resourceIdMatch?.groups?.spaceId || !resourceIdMatch?.groups?.entityId) {
|
|
43
43
|
throw new Error('Not a valid crn');
|
|
44
44
|
}
|
|
@@ -106,8 +106,11 @@ async function fetchExternalResource({ urn, fetch, options, spaceId, environment
|
|
|
106
106
|
environmentId,
|
|
107
107
|
resourceType,
|
|
108
108
|
urn
|
|
109
|
-
], ({ cmaClient })=>cmaClient.
|
|
110
|
-
|
|
109
|
+
], ({ cmaClient })=>cmaClient.resource.getMany({
|
|
110
|
+
spaceId,
|
|
111
|
+
environmentId,
|
|
112
|
+
resourceTypeId: resourceType,
|
|
113
|
+
query: {
|
|
111
114
|
'sys.urn[in]': urn
|
|
112
115
|
}
|
|
113
116
|
}).then(({ items })=>items[0] ?? null), options),
|
|
@@ -115,8 +118,10 @@ async function fetchExternalResource({ urn, fetch, options, spaceId, environment
|
|
|
115
118
|
'resource-types',
|
|
116
119
|
spaceId,
|
|
117
120
|
environmentId
|
|
118
|
-
], ({ cmaClient })=>fetchAll(({ query })=>cmaClient.
|
|
119
|
-
|
|
121
|
+
], ({ cmaClient })=>fetchAll(({ query })=>cmaClient.resourceType.getForEnvironment({
|
|
122
|
+
spaceId,
|
|
123
|
+
environmentId,
|
|
124
|
+
query
|
|
120
125
|
}), {}))
|
|
121
126
|
]);
|
|
122
127
|
const resourceTypeEntity = resourceTypes.find((rt)=>rt.sys.id === resourceType);
|
|
@@ -41,17 +41,19 @@ const sdk = {
|
|
|
41
41
|
return Promise.reject(new Error());
|
|
42
42
|
})
|
|
43
43
|
},
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
44
|
+
Locale: {
|
|
45
|
+
getMany: jest.fn().mockResolvedValue({
|
|
46
|
+
items: [
|
|
47
|
+
{
|
|
48
|
+
default: true,
|
|
49
|
+
code: 'en'
|
|
50
|
+
}
|
|
51
|
+
]
|
|
52
|
+
})
|
|
53
|
+
},
|
|
54
|
+
Resource: {
|
|
55
|
+
getMany: jest.fn().mockImplementation(({ spaceId, environmentId, resourceTypeId, query })=>{
|
|
56
|
+
if (spaceId === 'space-id' && environmentId === 'environment-id' && resourceTypeId === resolvableExternalResourceType && query['sys.urn[in]'] === resolvableExternalEntityUrn) {
|
|
55
57
|
return Promise.resolve({
|
|
56
58
|
items: [
|
|
57
59
|
resource
|
|
@@ -63,14 +65,19 @@ const sdk = {
|
|
|
63
65
|
});
|
|
64
66
|
})
|
|
65
67
|
},
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
{
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
68
|
+
ResourceType: {
|
|
69
|
+
getForEnvironment: jest.fn().mockImplementation(({ spaceId, environmentId })=>{
|
|
70
|
+
if (spaceId === 'space-id' && environmentId === 'environment-id') {
|
|
71
|
+
return Promise.resolve({
|
|
72
|
+
items: [
|
|
73
|
+
resourceType
|
|
74
|
+
],
|
|
75
|
+
pages: {}
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
return Promise.resolve({
|
|
79
|
+
items: []
|
|
80
|
+
});
|
|
74
81
|
})
|
|
75
82
|
},
|
|
76
83
|
ScheduledAction: {
|
|
@@ -3,11 +3,6 @@ import { Badge, EntryCard, MenuItem, MenuDivider, Paragraph, Caption } from '@co
|
|
|
3
3
|
import tokens from '@contentful/f36-tokens';
|
|
4
4
|
import { css } from 'emotion';
|
|
5
5
|
import truncate from 'truncate';
|
|
6
|
-
const defaultProps = {
|
|
7
|
-
isClickable: true,
|
|
8
|
-
hasCardMoveActions: true,
|
|
9
|
-
hasCardRemoveActions: true
|
|
10
|
-
};
|
|
11
6
|
const styles = {
|
|
12
7
|
subtitle: css({
|
|
13
8
|
color: tokens.gray600
|
|
@@ -42,7 +37,7 @@ function ExternalResourceCardDescription({ subtitle, description }) {
|
|
|
42
37
|
}, truncatedDescription));
|
|
43
38
|
}
|
|
44
39
|
ExternalResourceCardDescription.displayName = 'ExternalResourceCardDescription';
|
|
45
|
-
export function ExternalResourceCard({ info, isClickable, onEdit, onRemove, onMoveTop, onMoveBottom, hasCardEditActions, hasCardMoveActions, hasCardRemoveActions, renderDragHandle, onClick, isSelected }) {
|
|
40
|
+
export function ExternalResourceCard({ info, isClickable = true, onEdit, onRemove, onMoveTop, onMoveBottom, hasCardEditActions, hasCardMoveActions = true, hasCardRemoveActions = true, renderDragHandle, onClick, isSelected }) {
|
|
46
41
|
const { resource: entity, resourceType } = info;
|
|
47
42
|
const badge = ExternalEntityBadge(entity.fields.badge);
|
|
48
43
|
return React.createElement(EntryCard, {
|
|
@@ -98,4 +93,3 @@ export function ExternalResourceCard({ info, isClickable, onEdit, onRemove, onMo
|
|
|
98
93
|
description: entity.fields.description
|
|
99
94
|
}));
|
|
100
95
|
}
|
|
101
|
-
ExternalResourceCard.defaultProps = defaultProps;
|
|
@@ -17,10 +17,3 @@ export interface ExternalResourceCardProps {
|
|
|
17
17
|
hasCardRemoveActions?: boolean;
|
|
18
18
|
}
|
|
19
19
|
export declare function ExternalResourceCard({ info, isClickable, onEdit, onRemove, onMoveTop, onMoveBottom, hasCardEditActions, hasCardMoveActions, hasCardRemoveActions, renderDragHandle, onClick, isSelected, }: ExternalResourceCardProps): React.JSX.Element;
|
|
20
|
-
export declare namespace ExternalResourceCard {
|
|
21
|
-
var defaultProps: {
|
|
22
|
-
isClickable: boolean;
|
|
23
|
-
hasCardMoveActions: boolean;
|
|
24
|
-
hasCardRemoveActions: boolean;
|
|
25
|
-
};
|
|
26
|
-
}
|
package/dist/types/types.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { NavigatorSlideInfo, ContentEntityType } from '@contentful/app-sdk';
|
|
3
3
|
import { Entry, Asset } from '@contentful/field-editor-shared';
|
|
4
|
+
import { ResourceProps } from 'contentful-management';
|
|
4
5
|
export type { BaseAppSDK, FieldAppSDK, ContentType, ContentTypeField, Link, ContentEntityType, NavigatorSlideInfo, ScheduledAction, } from '@contentful/app-sdk';
|
|
5
|
-
export type { SpaceProps as Space, ResourceLink } from 'contentful-management';
|
|
6
|
+
export type { SpaceProps as Space, ResourceLink, ResourceProps as ExternalResource, SpaceEnvResourceTypeProps as ResourceType, } from 'contentful-management';
|
|
6
7
|
export { Entry, File, Asset } from '@contentful/field-editor-shared';
|
|
7
8
|
export type { ResourceInfo } from './common/EntityStore';
|
|
8
9
|
export type Entity = Entry | Asset;
|
|
@@ -21,44 +22,7 @@ export type AssetLink = {
|
|
|
21
22
|
};
|
|
22
23
|
};
|
|
23
24
|
export type EntityLink = EntryLink | AssetLink;
|
|
24
|
-
type
|
|
25
|
-
sys: {
|
|
26
|
-
type: 'Link';
|
|
27
|
-
linkType: T;
|
|
28
|
-
id: string;
|
|
29
|
-
};
|
|
30
|
-
};
|
|
31
|
-
export type ResourceType = {
|
|
32
|
-
sys: {
|
|
33
|
-
type: 'ResourceType';
|
|
34
|
-
id: string;
|
|
35
|
-
resourceProvider: SysExternalResource<'ResourceProvider'>;
|
|
36
|
-
};
|
|
37
|
-
name: string;
|
|
38
|
-
};
|
|
39
|
-
export interface ExternalResource {
|
|
40
|
-
sys: {
|
|
41
|
-
type: 'Resource';
|
|
42
|
-
urn: string;
|
|
43
|
-
resourceProvider: SysExternalResource<'ResourceProvider'>;
|
|
44
|
-
resourceType: SysExternalResource<'ResourceType'>;
|
|
45
|
-
};
|
|
46
|
-
fields: {
|
|
47
|
-
title: string;
|
|
48
|
-
subtitle?: string;
|
|
49
|
-
description?: string;
|
|
50
|
-
externalUrl?: string;
|
|
51
|
-
badge?: {
|
|
52
|
-
label: string;
|
|
53
|
-
variant: 'negative' | 'positive' | 'primary' | 'secondary' | 'warning';
|
|
54
|
-
};
|
|
55
|
-
image?: {
|
|
56
|
-
url: string;
|
|
57
|
-
altText?: string;
|
|
58
|
-
};
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
export type Resource = Entry | ExternalResource;
|
|
25
|
+
export type Resource = Entry | ResourceProps;
|
|
62
26
|
export type EntityType = 'Entry' | 'Asset' | string;
|
|
63
27
|
export type SysResourceLink<T extends string> = {
|
|
64
28
|
sys: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentful/field-editor-reference",
|
|
3
|
-
"version": "5.30.
|
|
3
|
+
"version": "5.30.11",
|
|
4
4
|
"main": "dist/cjs/index.js",
|
|
5
5
|
"module": "dist/esm/index.js",
|
|
6
6
|
"types": "dist/types/index.d.ts",
|
|
@@ -35,17 +35,17 @@
|
|
|
35
35
|
"tsc": "tsc -p ./ --noEmit"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@contentful/f36-components": "^4.
|
|
39
|
-
"@contentful/f36-icons": "^4.
|
|
38
|
+
"@contentful/f36-components": "^4.70.0",
|
|
39
|
+
"@contentful/f36-icons": "^4.29.0",
|
|
40
40
|
"@contentful/f36-tokens": "^4.0.5",
|
|
41
|
-
"@contentful/field-editor-shared": "^1.6.
|
|
41
|
+
"@contentful/field-editor-shared": "^1.6.3",
|
|
42
42
|
"@contentful/mimetype": "^2.2.29",
|
|
43
43
|
"@dnd-kit/core": "^6.0.8",
|
|
44
44
|
"@dnd-kit/modifiers": "^7.0.0",
|
|
45
45
|
"@dnd-kit/sortable": "^8.0.0",
|
|
46
46
|
"@tanstack/react-query": "^4.3.9",
|
|
47
47
|
"constate": "^3.3.2",
|
|
48
|
-
"contentful-management": "^11.
|
|
48
|
+
"contentful-management": "^11.35.1",
|
|
49
49
|
"emotion": "^10.0.17",
|
|
50
50
|
"lodash": "^4.17.15",
|
|
51
51
|
"moment": "^2.20.0",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"@contentful/app-sdk": "^4.29.0",
|
|
57
|
-
"@contentful/field-editor-test-utils": "^1.5.
|
|
57
|
+
"@contentful/field-editor-test-utils": "^1.5.2",
|
|
58
58
|
"@testing-library/react-hooks": "^8.0.1"
|
|
59
59
|
},
|
|
60
60
|
"peerDependencies": {
|
|
@@ -64,5 +64,5 @@
|
|
|
64
64
|
"publishConfig": {
|
|
65
65
|
"registry": "https://npm.pkg.github.com/"
|
|
66
66
|
},
|
|
67
|
-
"gitHead": "
|
|
67
|
+
"gitHead": "bd1544b7b565d1937307db94aacf889d572ad084"
|
|
68
68
|
}
|