@contentful/field-editor-reference 6.13.13 → 6.13.14

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.
@@ -386,31 +386,32 @@ const [InternalServiceProvider, useFetch, useEntityLoader, useCurrentIds] = (0,
386
386
  currentEnvironmentId,
387
387
  isReleaseRequestError
388
388
  ]);
389
- const getEntityScheduledActions = (0, _react.useCallback)(function getEntityScheduledActions(entityType, entityId, options) {
389
+ const getEntityScheduledActions = (0, _react.useCallback)(function getEntityScheduledActions(_, entityId, options) {
390
390
  if (releaseId) {
391
391
  return new Promise((resolve)=>resolve([]));
392
392
  }
393
- const fixedEntityCacheId = 'scheduledActionEntityId';
394
- const maxScheduledActions = 500;
393
+ const maxScheduledActions = 1000;
395
394
  const spaceId = options?.spaceId ?? currentSpaceId;
396
395
  const environmentId = options?.environmentId ?? currentEnvironmentId;
396
+ const query = {
397
+ 'environment.sys.id': environmentId,
398
+ 'sys.status': 'scheduled',
399
+ 'entity.sys.linkType[in]': 'Entry,Asset',
400
+ order: '-scheduledFor.datetime',
401
+ limit: maxScheduledActions
402
+ };
397
403
  const queryKey = [
398
- 'scheduled-actions',
399
- entityType,
400
- fixedEntityCacheId,
404
+ 'spaces',
401
405
  spaceId,
402
- environmentId,
403
- releaseId
406
+ 'scheduled_actions',
407
+ {
408
+ query
409
+ }
404
410
  ];
405
411
  return fetch(queryKey, async ({ cmaClient })=>{
406
412
  const response = await cmaClient.scheduledActions.getMany({
407
413
  spaceId,
408
- query: {
409
- 'environment.sys.id': environmentId,
410
- 'sys.status[in]': 'scheduled',
411
- order: 'scheduledFor.datetime',
412
- limit: maxScheduledActions
413
- }
414
+ query
414
415
  });
415
416
  return response.items;
416
417
  }, options).then((items)=>items.filter((action)=>action.entity.sys.id === entityId));
@@ -63,12 +63,21 @@ function _interop_require_wildcard(obj, nodeInterop) {
63
63
  return newObj;
64
64
  }
65
65
  const clientContext = /*#__PURE__*/ _react.createContext(undefined);
66
+ function useMaybeHostQueryClient() {
67
+ try {
68
+ return (0, _reactquery.useQueryClient)();
69
+ } catch {
70
+ return undefined;
71
+ }
72
+ }
66
73
  function useQueryClient() {
67
74
  const client = _react.useContext(clientContext);
75
+ const hostClient = useMaybeHostQueryClient();
68
76
  return _react.useMemo(()=>{
69
77
  if (client) {
70
78
  return client;
71
79
  }
80
+ if (hostClient) return hostClient;
72
81
  return new _reactquery.QueryClient({
73
82
  defaultOptions: {
74
83
  queries: {
@@ -82,7 +91,8 @@ function useQueryClient() {
82
91
  }
83
92
  });
84
93
  }, [
85
- client
94
+ client,
95
+ hostClient
86
96
  ]);
87
97
  }
88
98
  const useQuery = (key, fn, opt)=>{
@@ -298,31 +298,32 @@ const [InternalServiceProvider, useFetch, useEntityLoader, useCurrentIds] = cons
298
298
  currentEnvironmentId,
299
299
  isReleaseRequestError
300
300
  ]);
301
- const getEntityScheduledActions = useCallback(function getEntityScheduledActions(entityType, entityId, options) {
301
+ const getEntityScheduledActions = useCallback(function getEntityScheduledActions(_, entityId, options) {
302
302
  if (releaseId) {
303
303
  return new Promise((resolve)=>resolve([]));
304
304
  }
305
- const fixedEntityCacheId = 'scheduledActionEntityId';
306
- const maxScheduledActions = 500;
305
+ const maxScheduledActions = 1000;
307
306
  const spaceId = options?.spaceId ?? currentSpaceId;
308
307
  const environmentId = options?.environmentId ?? currentEnvironmentId;
308
+ const query = {
309
+ 'environment.sys.id': environmentId,
310
+ 'sys.status': 'scheduled',
311
+ 'entity.sys.linkType[in]': 'Entry,Asset',
312
+ order: '-scheduledFor.datetime',
313
+ limit: maxScheduledActions
314
+ };
309
315
  const queryKey = [
310
- 'scheduled-actions',
311
- entityType,
312
- fixedEntityCacheId,
316
+ 'spaces',
313
317
  spaceId,
314
- environmentId,
315
- releaseId
318
+ 'scheduled_actions',
319
+ {
320
+ query
321
+ }
316
322
  ];
317
323
  return fetch(queryKey, async ({ cmaClient })=>{
318
324
  const response = await cmaClient.scheduledActions.getMany({
319
325
  spaceId,
320
- query: {
321
- 'environment.sys.id': environmentId,
322
- 'sys.status[in]': 'scheduled',
323
- order: 'scheduledFor.datetime',
324
- limit: maxScheduledActions
325
- }
326
+ query
326
327
  });
327
328
  return response.items;
328
329
  }, options).then((items)=>items.filter((action)=>action.entity.sys.id === entityId));
@@ -1,12 +1,21 @@
1
1
  import * as React from 'react';
2
- import { QueryClient, useQuery as useRQ } from '@tanstack/react-query';
2
+ import { QueryClient, useQuery as useRQ, useQueryClient as useHostQueryClient } from '@tanstack/react-query';
3
3
  const clientContext = /*#__PURE__*/ React.createContext(undefined);
4
+ function useMaybeHostQueryClient() {
5
+ try {
6
+ return useHostQueryClient();
7
+ } catch {
8
+ return undefined;
9
+ }
10
+ }
4
11
  export function useQueryClient() {
5
12
  const client = React.useContext(clientContext);
13
+ const hostClient = useMaybeHostQueryClient();
6
14
  return React.useMemo(()=>{
7
15
  if (client) {
8
16
  return client;
9
17
  }
18
+ if (hostClient) return hostClient;
10
19
  return new QueryClient({
11
20
  defaultOptions: {
12
21
  queries: {
@@ -20,7 +29,8 @@ export function useQueryClient() {
20
29
  }
21
30
  });
22
31
  }, [
23
- client
32
+ client,
33
+ hostClient
24
34
  ]);
25
35
  }
26
36
  export const useQuery = (key, fn, opt)=>{
@@ -83,7 +83,7 @@ export declare function isFunctionInvocationError(value: unknown): value is Func
83
83
  declare const useEntityLoader: () => {
84
84
  getResource: <R extends Resource = Resource>(resourceType: string, urn: string, options?: GetResourceOptions) => QueryResourceResult<R>;
85
85
  getEntity: <E extends FetchableEntity>(entityType: FetchableEntityType, entityId: string, releaseId?: string, options?: GetEntityOptions) => QueryEntityResult<E>;
86
- getEntityScheduledActions: (entityType: FetchableEntityType, entityId: string, options?: GetEntityOptions) => QueryEntityResult<ScheduledAction[]>;
86
+ getEntityScheduledActions: (_: FetchableEntityType, entityId: string, options?: GetEntityOptions) => QueryEntityResult<ScheduledAction[]>;
87
87
  getResourceProvider: (organizationId: string, appDefinitionId: string) => QueryEntityResult<ResourceProvider>;
88
88
  };
89
89
  export declare function useEntity<E extends FetchableEntity>(entityType: FetchableEntityType, entityId: string, options?: Omit<UseEntityOptions, 'releaseId'>): UseEntityResult<E>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contentful/field-editor-reference",
3
- "version": "6.13.13",
3
+ "version": "6.13.14",
4
4
  "main": "dist/cjs/index.js",
5
5
  "module": "dist/esm/index.js",
6
6
  "types": "dist/types/index.d.ts",
@@ -67,5 +67,5 @@
67
67
  "publishConfig": {
68
68
  "registry": "https://npm.pkg.github.com/"
69
69
  },
70
- "gitHead": "5e69589554e4e8e0870f08886848dc13434573ca"
70
+ "gitHead": "43023e9b8123777e95bcfc1a28d23aff16d36782"
71
71
  }