@contentful/field-editor-reference 4.6.10 → 5.0.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/CHANGELOG.md CHANGED
@@ -3,6 +3,18 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [5.0.0](https://github.com/contentful/field-editors/compare/@contentful/field-editor-reference@4.6.10...@contentful/field-editor-reference@5.0.0) (2022-08-18)
7
+
8
+ ### Features
9
+
10
+ - moving new entity store in [TOL-282] ([#1214](https://github.com/contentful/field-editors/issues/1214)) ([2ad4f64](https://github.com/contentful/field-editors/commit/2ad4f643296dbf48802410382a9a055de18a15de))
11
+
12
+ ### BREAKING CHANGES
13
+
14
+ - useEntities is no longer export from the reference editor package. Use useEntity or useEntityLoader instead
15
+
16
+ Co-authored-by: Ahmed T. Ali <ah.tajelsir@gmail.com>
17
+
6
18
  ## [4.6.10](https://github.com/contentful/field-editors/compare/@contentful/field-editor-reference@4.6.9...@contentful/field-editor-reference@4.6.10) (2022-08-09)
7
19
 
8
20
  ### Bug Fixes
@@ -2,7 +2,7 @@
2
2
  import { File } from '../../types';
3
3
  export declare function renderAssetInfo(props: {
4
4
  entityFile: File;
5
- }): ("" | JSX.Element)[];
5
+ }): any[];
6
6
  export declare function renderActions(props: {
7
7
  onEdit?: () => void;
8
8
  onRemove?: () => void;
@@ -1,12 +1,62 @@
1
- import * as React from 'react';
2
- import { BaseExtensionSDK, ContentType, Resource, Space } from '../types';
1
+ import React from 'react';
2
+ import { BaseExtensionSDK } from '@contentful/app-sdk';
3
+ import { Asset, ContentType, Entry, Resource, ResourceType, Space, ScheduledAction } from '../types';
3
4
  export declare type ResourceInfo<R extends Resource = Resource> = {
4
5
  resource: R;
5
6
  defaultLocaleCode: string;
6
7
  contentType: ContentType;
7
8
  space: Space;
8
9
  };
9
- declare const EntityProvider: React.FC<{
10
+ declare type EntityStoreProps = {
10
11
  sdk: BaseExtensionSDK;
11
- }>, useEntities: any;
12
- export { EntityProvider, useEntities };
12
+ queryConcurrency?: number;
13
+ };
14
+ declare type GetOptions = {
15
+ priority?: number;
16
+ };
17
+ declare type GetEntityOptions = GetOptions & {
18
+ spaceId?: string;
19
+ environmentId?: string;
20
+ };
21
+ declare type UseEntityOptions = GetEntityOptions & {
22
+ enabled?: boolean;
23
+ };
24
+ declare type QueryEntityResult<E> = Promise<E>;
25
+ declare type GetResourceOptions = GetOptions;
26
+ declare type QueryResourceResult<R extends Resource = Resource> = QueryEntityResult<ResourceInfo<R>>;
27
+ declare type UseResourceOptions = GetResourceOptions & {
28
+ enabled?: boolean;
29
+ };
30
+ declare type UseEntityResult<E> = {
31
+ status: 'idle';
32
+ data: never;
33
+ } | {
34
+ status: 'loading';
35
+ data: never;
36
+ } | {
37
+ status: 'error';
38
+ data: never;
39
+ } | {
40
+ status: 'success';
41
+ data: E;
42
+ };
43
+ declare type FetchableEntityType = 'Entry' | 'Asset';
44
+ declare type FetchableEntity = Entry | Asset;
45
+ export declare class UnsupportedError extends Error {
46
+ isUnsupportedError: boolean;
47
+ constructor(message: string);
48
+ }
49
+ export declare function isUnsupportedError(value: unknown): value is UnsupportedError;
50
+ declare const useEntityLoader: () => {
51
+ getResource: <R extends Resource = Resource>(resourceType: ResourceType, urn: string, options?: GetOptions | undefined) => QueryResourceResult<R>;
52
+ getEntity: <E extends FetchableEntity>(entityType: FetchableEntityType, entityId: string, options?: GetEntityOptions | undefined) => QueryEntityResult<E>;
53
+ getEntityScheduledActions: (entityType: FetchableEntityType, entityId: string, options?: GetEntityOptions | undefined) => QueryEntityResult<ScheduledAction[]>;
54
+ };
55
+ export declare function useEntity<E extends FetchableEntity>(entityType: FetchableEntityType, entityId: string, options?: UseEntityOptions): UseEntityResult<E>;
56
+ export declare function useResource(resourceType: ResourceType, urn: string, options?: UseResourceOptions): {
57
+ status: "loading" | "error" | "success";
58
+ data: ResourceInfo<Resource> | undefined;
59
+ error: unknown;
60
+ };
61
+ declare function EntityProvider({ children, ...props }: React.PropsWithChildren<EntityStoreProps>): JSX.Element;
62
+ export { EntityProvider, useEntityLoader };
@@ -1,7 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import { FieldConnector } from '@contentful/field-editor-shared';
3
- import { Action, ActionLabels, FieldExtensionSDK, ViewType } from '../types';
4
3
  import type { LinkActionsProps } from '../components';
4
+ import { Action, ActionLabels, FieldExtensionSDK, ViewType } from '../types';
5
5
  import { CustomCardRenderer, RenderCustomMissingEntityCard } from './customCardTypes';
6
6
  export interface ReferenceEditorProps {
7
7
  /**
@@ -9,7 +9,7 @@ export declare function useAccessApi(accessApi: AccessAPI & Partial<ExtendedAcce
9
9
  <T = Object>(action: CrudAction, entity: T | "ContentType" | import("@contentful/app-sdk").ContentType | "Asset" | "Entry"): Promise<boolean>;
10
10
  <T_1 = Object>(action: PublishableAction, entity: T_1 | "ContentType" | import("@contentful/app-sdk").ContentType | "Asset" | "Entry"): Promise<boolean>;
11
11
  <T_2 = Object>(action: ArchiveableAction, entity: T_2 | "Asset" | "Entry"): Promise<boolean>;
12
- (action: "update", entity: import("@contentful/app-sdk").Entry<Record<string, any>> | import("@contentful/app-sdk").Task | import("@contentful/app-sdk").Asset, patch: import("@contentful/app-sdk").JSONPatchItem[]): Promise<boolean>;
12
+ (action: "update", entity: import("@contentful/app-sdk").Entry<import("contentful-management").KeyValueMap> | import("@contentful/app-sdk").Task | import("@contentful/app-sdk").Asset, patch: import("@contentful/app-sdk").JSONPatchItem[]): Promise<boolean>;
13
13
  };
14
14
  canPerformActionOnEntryOfType: (action: EntryAction, contentTypeId: string) => Promise<boolean>;
15
15
  };
@@ -8,7 +8,7 @@ export declare function createEntity(props: {
8
8
  entity?: undefined;
9
9
  slide?: undefined;
10
10
  } | {
11
- entity: Entry<Entry<Record<string, any>>> | undefined;
11
+ entity: Entry<Entry<import("contentful-management").KeyValueMap>> | undefined;
12
12
  slide: import("@contentful/app-sdk/dist/types/navigator.types").NavigatorSlideInfo | undefined;
13
13
  } | {
14
14
  entity: Asset | undefined;
@@ -18,9 +18,9 @@ export declare function selectSingleEntity(props: {
18
18
  sdk: FieldExtensionSDK;
19
19
  entityType: ContentEntityType;
20
20
  editorPermissions: EditorPermissions;
21
- }): Promise<Entry<Record<string, any>> | null>;
21
+ }): Promise<Entry<import("contentful-management").KeyValueMap> | null>;
22
22
  export declare function selectMultipleEntities(props: {
23
23
  sdk: FieldExtensionSDK;
24
24
  entityType: ContentEntityType;
25
25
  editorPermissions: EditorPermissions;
26
- }): Promise<Entry<Record<string, any>>[] | null>;
26
+ }): Promise<Entry<import("contentful-management").KeyValueMap>[] | null>;