@contentful/field-editor-shared 2.17.2-canary.25 → 2.17.2-canary.4
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.
|
@@ -43,10 +43,13 @@ function useContentTypes(source) {
|
|
|
43
43
|
const queryClient = (0, _queryClient.useQueryClient)();
|
|
44
44
|
const spaceId = 'ids' in source ? source.ids.space : '';
|
|
45
45
|
const environmentId = 'ids' in source ? source.ids.environmentAlias ?? source.ids.environment : '';
|
|
46
|
-
const
|
|
46
|
+
const queryKey = (0, _react.useMemo)(()=>(0, _queryKeys.createGetManyContentTypesKey)(spaceId, environmentId, {
|
|
47
47
|
limit: 1000
|
|
48
|
-
}), [
|
|
49
|
-
|
|
48
|
+
}), [
|
|
49
|
+
spaceId,
|
|
50
|
+
environmentId
|
|
51
|
+
]);
|
|
52
|
+
const { data: contentTypes = [] } = (0, _queryClient.useQuery)(queryKey, async ()=>{
|
|
50
53
|
const allContentTypes = [];
|
|
51
54
|
const limit = 1000;
|
|
52
55
|
let skip = 0;
|
|
@@ -73,19 +76,17 @@ function useContentTypes(source) {
|
|
|
73
76
|
}
|
|
74
77
|
const unsubscribe = navigator.onSlideInNavigation(({ oldSlideLevel, newSlideLevel })=>{
|
|
75
78
|
if (oldSlideLevel > newSlideLevel) {
|
|
76
|
-
void queryClient.invalidateQueries(
|
|
79
|
+
void queryClient.invalidateQueries(queryKey);
|
|
77
80
|
}
|
|
78
81
|
});
|
|
79
82
|
return unsubscribe;
|
|
80
83
|
}, [
|
|
81
84
|
navigator,
|
|
82
85
|
queryClient,
|
|
83
|
-
|
|
84
|
-
environmentId,
|
|
85
|
-
queryParams
|
|
86
|
+
queryKey
|
|
86
87
|
]);
|
|
87
88
|
const invalidate = ()=>{
|
|
88
|
-
return queryClient.invalidateQueries(
|
|
89
|
+
return queryClient.invalidateQueries(queryKey);
|
|
89
90
|
};
|
|
90
91
|
return {
|
|
91
92
|
contentTypes,
|
package/dist/cjs/queryClient.js
CHANGED
|
@@ -71,6 +71,7 @@ try {
|
|
|
71
71
|
useHostQueryClient = rq.useQueryClient;
|
|
72
72
|
} catch {}
|
|
73
73
|
const clientContext = /*#__PURE__*/ _react.createContext(undefined);
|
|
74
|
+
let sharedQueryClientInstance;
|
|
74
75
|
function useMaybeHostQueryClient() {
|
|
75
76
|
try {
|
|
76
77
|
return useHostQueryClient();
|
|
@@ -89,18 +90,21 @@ function useQueryClient() {
|
|
|
89
90
|
if (!RQQueryClient) {
|
|
90
91
|
throw new Error('@tanstack/react-query is required to use QueryClient. Please install it as a dependency: npm install @tanstack/react-query');
|
|
91
92
|
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
93
|
+
if (!sharedQueryClientInstance) {
|
|
94
|
+
sharedQueryClientInstance = new RQQueryClient({
|
|
95
|
+
defaultOptions: {
|
|
96
|
+
queries: {
|
|
97
|
+
useErrorBoundary: false,
|
|
98
|
+
refetchOnWindowFocus: false,
|
|
99
|
+
refetchOnReconnect: true,
|
|
100
|
+
refetchOnMount: false,
|
|
101
|
+
staleTime: Infinity,
|
|
102
|
+
retry: false
|
|
103
|
+
}
|
|
101
104
|
}
|
|
102
|
-
}
|
|
103
|
-
}
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
return sharedQueryClientInstance;
|
|
104
108
|
}, [
|
|
105
109
|
client,
|
|
106
110
|
hostClient
|
|
@@ -22,10 +22,13 @@ export function useContentTypes(source) {
|
|
|
22
22
|
const queryClient = useQueryClient();
|
|
23
23
|
const spaceId = 'ids' in source ? source.ids.space : '';
|
|
24
24
|
const environmentId = 'ids' in source ? source.ids.environmentAlias ?? source.ids.environment : '';
|
|
25
|
-
const
|
|
25
|
+
const queryKey = useMemo(()=>createGetManyContentTypesKey(spaceId, environmentId, {
|
|
26
26
|
limit: 1000
|
|
27
|
-
}), [
|
|
28
|
-
|
|
27
|
+
}), [
|
|
28
|
+
spaceId,
|
|
29
|
+
environmentId
|
|
30
|
+
]);
|
|
31
|
+
const { data: contentTypes = [] } = useQuery(queryKey, async ()=>{
|
|
29
32
|
const allContentTypes = [];
|
|
30
33
|
const limit = 1000;
|
|
31
34
|
let skip = 0;
|
|
@@ -52,19 +55,17 @@ export function useContentTypes(source) {
|
|
|
52
55
|
}
|
|
53
56
|
const unsubscribe = navigator.onSlideInNavigation(({ oldSlideLevel, newSlideLevel })=>{
|
|
54
57
|
if (oldSlideLevel > newSlideLevel) {
|
|
55
|
-
void queryClient.invalidateQueries(
|
|
58
|
+
void queryClient.invalidateQueries(queryKey);
|
|
56
59
|
}
|
|
57
60
|
});
|
|
58
61
|
return unsubscribe;
|
|
59
62
|
}, [
|
|
60
63
|
navigator,
|
|
61
64
|
queryClient,
|
|
62
|
-
|
|
63
|
-
environmentId,
|
|
64
|
-
queryParams
|
|
65
|
+
queryKey
|
|
65
66
|
]);
|
|
66
67
|
const invalidate = ()=>{
|
|
67
|
-
return queryClient.invalidateQueries(
|
|
68
|
+
return queryClient.invalidateQueries(queryKey);
|
|
68
69
|
};
|
|
69
70
|
return {
|
|
70
71
|
contentTypes,
|
package/dist/esm/queryClient.js
CHANGED
|
@@ -9,6 +9,7 @@ try {
|
|
|
9
9
|
useHostQueryClient = rq.useQueryClient;
|
|
10
10
|
} catch {}
|
|
11
11
|
const clientContext = /*#__PURE__*/ React.createContext(undefined);
|
|
12
|
+
let sharedQueryClientInstance;
|
|
12
13
|
function useMaybeHostQueryClient() {
|
|
13
14
|
try {
|
|
14
15
|
return useHostQueryClient();
|
|
@@ -27,18 +28,21 @@ export function useQueryClient() {
|
|
|
27
28
|
if (!RQQueryClient) {
|
|
28
29
|
throw new Error('@tanstack/react-query is required to use QueryClient. Please install it as a dependency: npm install @tanstack/react-query');
|
|
29
30
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
31
|
+
if (!sharedQueryClientInstance) {
|
|
32
|
+
sharedQueryClientInstance = new RQQueryClient({
|
|
33
|
+
defaultOptions: {
|
|
34
|
+
queries: {
|
|
35
|
+
useErrorBoundary: false,
|
|
36
|
+
refetchOnWindowFocus: false,
|
|
37
|
+
refetchOnReconnect: true,
|
|
38
|
+
refetchOnMount: false,
|
|
39
|
+
staleTime: Infinity,
|
|
40
|
+
retry: false
|
|
41
|
+
}
|
|
39
42
|
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
return sharedQueryClientInstance;
|
|
42
46
|
}, [
|
|
43
47
|
client,
|
|
44
48
|
hostClient
|
|
@@ -5,6 +5,9 @@ export declare function useQuery<TQueryFnData = unknown, TError = unknown, TData
|
|
|
5
5
|
/**
|
|
6
6
|
* Provides access to a query client either by sharing an existing client or
|
|
7
7
|
* creating a new one.
|
|
8
|
+
*
|
|
9
|
+
* @param client - Optional QueryClient instance. When provided (e.g., in tests),
|
|
10
|
+
* it takes priority over any host client or singleton.
|
|
8
11
|
*/
|
|
9
12
|
export declare function SharedQueryClientProvider({ children, client: providedClient, }: React.PropsWithChildren<{
|
|
10
13
|
client?: QueryClient;
|
|
@@ -1,14 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Query key factories
|
|
2
|
+
* Query key factories for React Query cache management.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
* When updating, check the corresponding file in user_interface repository.
|
|
4
|
+
* These factories provide consistent query keys across the application.
|
|
6
5
|
*/
|
|
7
6
|
/**
|
|
8
7
|
* Creates a query key for fetching a single entry.
|
|
9
|
-
* Matches the structure used in user_interface for cache sharing.
|
|
10
|
-
*
|
|
11
|
-
* Source: https://github.com/contentful/user_interface/blob/main/src/javascripts/core/react-query/cma/entry/useGetEntry.ts
|
|
12
8
|
*
|
|
13
9
|
* @param spaceId - The space ID
|
|
14
10
|
* @param environmentId - The environment ID
|
|
@@ -18,9 +14,6 @@
|
|
|
18
14
|
export declare const createGetEntryKey: (spaceId: string, environmentId: string, entryId: string) => string[];
|
|
19
15
|
/**
|
|
20
16
|
* Creates a query key for fetching a single asset.
|
|
21
|
-
* Matches the structure used in user_interface for cache sharing.
|
|
22
|
-
*
|
|
23
|
-
* Source: https://github.com/contentful/user_interface/blob/main/src/javascripts/core/react-query/cma/asset/useGetAsset.ts
|
|
24
17
|
*
|
|
25
18
|
* @param spaceId - The space ID
|
|
26
19
|
* @param environmentId - The environment ID
|
|
@@ -30,9 +23,6 @@ export declare const createGetEntryKey: (spaceId: string, environmentId: string,
|
|
|
30
23
|
export declare const createGetAssetKey: (spaceId: string, environmentId: string, assetId: string) => string[];
|
|
31
24
|
/**
|
|
32
25
|
* Creates a query key for fetching a single space.
|
|
33
|
-
* Matches the structure used in user_interface for cache sharing.
|
|
34
|
-
*
|
|
35
|
-
* Source: https://github.com/contentful/user_interface/blob/main/src/javascripts/core/react-query/cma/space/useGetSpace.ts
|
|
36
26
|
*
|
|
37
27
|
* @param spaceId - The space ID to fetch
|
|
38
28
|
* @returns Query key array for React Query
|
|
@@ -40,9 +30,6 @@ export declare const createGetAssetKey: (spaceId: string, environmentId: string,
|
|
|
40
30
|
export declare const createGetSpaceKey: (spaceId: string) => string[];
|
|
41
31
|
/**
|
|
42
32
|
* Creates a query key for fetching multiple locales.
|
|
43
|
-
* Matches the structure used in user_interface for cache sharing.
|
|
44
|
-
*
|
|
45
|
-
* Source: https://github.com/contentful/user_interface/blob/main/src/javascripts/core/react-query/cma/locale/useGetManyLocales.ts
|
|
46
33
|
*
|
|
47
34
|
* @param spaceId - The space ID
|
|
48
35
|
* @param environmentId - The environment ID
|
|
@@ -52,9 +39,6 @@ export declare const createGetSpaceKey: (spaceId: string) => string[];
|
|
|
52
39
|
export declare const createGetManyLocalesKey: (spaceId: string, environmentId: string, params?: Record<string, unknown>) => (string | Record<string, unknown>)[];
|
|
53
40
|
/**
|
|
54
41
|
* Creates a query key for fetching a single content type.
|
|
55
|
-
* Matches the structure used in user_interface for cache sharing.
|
|
56
|
-
*
|
|
57
|
-
* Source: https://github.com/contentful/user_interface/blob/main/src/javascripts/core/react-query/cma/contentType/useGetContentType.ts
|
|
58
42
|
*
|
|
59
43
|
* @param spaceId - The space ID
|
|
60
44
|
* @param environmentId - The environment ID
|
|
@@ -64,9 +48,6 @@ export declare const createGetManyLocalesKey: (spaceId: string, environmentId: s
|
|
|
64
48
|
export declare const createGetContentTypeKey: (spaceId: string, environmentId: string, contentTypeId: string) => string[];
|
|
65
49
|
/**
|
|
66
50
|
* Creates a query key for fetching multiple content types.
|
|
67
|
-
* Matches the structure used in user_interface for cache sharing.
|
|
68
|
-
*
|
|
69
|
-
* Source: https://github.com/contentful/user_interface/blob/main/src/javascripts/core/react-query/cma/contentType/useGetManyContentTypes.ts
|
|
70
51
|
*
|
|
71
52
|
* @param spaceId - The space ID
|
|
72
53
|
* @param environmentId - The environment ID
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentful/field-editor-shared",
|
|
3
|
-
"version": "2.17.2-canary.
|
|
3
|
+
"version": "2.17.2-canary.4+7e408d64",
|
|
4
4
|
"main": "dist/cjs/index.js",
|
|
5
5
|
"module": "dist/esm/index.js",
|
|
6
6
|
"types": "dist/types/index.d.ts",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@contentful/app-sdk": "^4.42.0",
|
|
40
|
-
"@contentful/field-editor-test-utils": "^1.7.
|
|
40
|
+
"@contentful/field-editor-test-utils": "^1.7.1-canary.79+7e408d64",
|
|
41
41
|
"@lingui/core": "5.3.0",
|
|
42
42
|
"@tanstack/react-query": "^4.3.9",
|
|
43
43
|
"@testing-library/react": "16.3.0"
|
|
@@ -67,5 +67,5 @@
|
|
|
67
67
|
"publishConfig": {
|
|
68
68
|
"registry": "https://npm.pkg.github.com/"
|
|
69
69
|
},
|
|
70
|
-
"gitHead": "
|
|
70
|
+
"gitHead": "7e408d64fabf2933a3c698a4ad104293a24f19a1"
|
|
71
71
|
}
|