@contentful/app-sdk 4.10.0-alpha.4 → 4.10.0-alpha.5
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/README.md +9 -0
- package/dist/api.d.ts +3 -3
- package/dist/app.d.ts +3 -3
- package/dist/cf-extension-api.js +1 -1
- package/dist/channel.d.ts +13 -13
- package/dist/cmaAdapter.d.ts +3 -3
- package/dist/dialogs.d.ts +3 -3
- package/dist/editor.d.ts +4 -3
- package/dist/entry.d.ts +4 -3
- package/dist/field-locale.d.ts +29 -23
- package/dist/field.d.ts +24 -22
- package/dist/index.d.ts +7 -7
- package/dist/initialize.d.ts +6 -6
- package/dist/locations.d.ts +3 -3
- package/dist/navigator.d.ts +3 -3
- package/dist/signal.d.ts +15 -14
- package/dist/space.d.ts +3 -3
- package/dist/types/api.types.d.ts +283 -223
- package/dist/types/app.types.d.ts +44 -44
- package/dist/types/cmaClient.types.d.ts +35 -0
- package/dist/types/dialogs.types.d.ts +69 -69
- package/dist/types/entities.d.ts +7 -7
- package/dist/types/entry.types.d.ts +45 -45
- package/dist/types/field-locale.types.d.ts +76 -37
- package/dist/types/field.types.d.ts +113 -61
- package/dist/types/index.d.ts +13 -12
- package/dist/types/navigator.types.d.ts +63 -63
- package/dist/types/space.types.d.ts +272 -272
- package/dist/types/utils.d.ts +82 -70
- package/dist/types/validation-error.d.ts +63 -63
- package/dist/types/window.types.d.ts +17 -17
- package/dist/utils/deferred.d.ts +6 -6
- package/dist/window.d.ts +3 -3
- package/package.json +1 -1
|
@@ -1,69 +1,69 @@
|
|
|
1
|
-
import { SerializedJSONValue } from './utils';
|
|
2
|
-
export interface OpenAlertOptions {
|
|
3
|
-
title: string;
|
|
4
|
-
message: string;
|
|
5
|
-
confirmLabel?: string;
|
|
6
|
-
shouldCloseOnEscapePress?: boolean;
|
|
7
|
-
shouldCloseOnOverlayClick?: boolean;
|
|
8
|
-
}
|
|
9
|
-
export
|
|
10
|
-
cancelLabel?: string;
|
|
11
|
-
intent?: 'primary' | 'positive' | 'negative';
|
|
12
|
-
};
|
|
13
|
-
export interface OpenCustomWidgetOptions {
|
|
14
|
-
id?: string;
|
|
15
|
-
width?: number | 'small' | 'medium' | 'large' | 'fullWidth';
|
|
16
|
-
minHeight?: number | string;
|
|
17
|
-
allowHeightOverflow?: boolean;
|
|
18
|
-
position?: 'center' | 'top';
|
|
19
|
-
title?: string;
|
|
20
|
-
shouldCloseOnOverlayClick?: boolean;
|
|
21
|
-
shouldCloseOnEscapePress?: boolean;
|
|
22
|
-
parameters?: SerializedJSONValue;
|
|
23
|
-
}
|
|
24
|
-
export interface EntityDialogOptions {
|
|
25
|
-
locale?: string;
|
|
26
|
-
contentTypes?: string[];
|
|
27
|
-
min?: number;
|
|
28
|
-
max?: number;
|
|
29
|
-
}
|
|
30
|
-
export interface DialogsAPI {
|
|
31
|
-
/** Opens a simple alert window (which can only be closed). */
|
|
32
|
-
openAlert: (options: OpenAlertOptions) => Promise<boolean>;
|
|
33
|
-
/** Opens a confirmation window. A user can either confirm or cancel the dialog. */
|
|
34
|
-
openConfirm: (options: OpenConfirmOptions) => Promise<boolean>;
|
|
35
|
-
/** Opens a prompt window. A user can either provide a string input or cancel the dialog. */
|
|
36
|
-
openPrompt: (options: OpenConfirmOptions & {
|
|
37
|
-
defaultValue?: string;
|
|
38
|
-
}) => Promise<string | boolean>;
|
|
39
|
-
/** Opens an extension in a dialog. */
|
|
40
|
-
openExtension: (options: OpenCustomWidgetOptions) => Promise<any>;
|
|
41
|
-
/** Opens the current app in a dialog */
|
|
42
|
-
openCurrentApp: (options?: Omit<OpenCustomWidgetOptions, 'id'>) => Promise<any>;
|
|
43
|
-
/** Opens the current app or extension in a dialog */
|
|
44
|
-
openCurrent: (options?: Omit<OpenCustomWidgetOptions, 'id'> | OpenCustomWidgetOptions) => Promise<any>;
|
|
45
|
-
/** Opens a dialog for selecting a single entry. */
|
|
46
|
-
selectSingleEntry: <T = Object>(options?: {
|
|
47
|
-
locale?: string;
|
|
48
|
-
contentTypes?: string[];
|
|
49
|
-
}) => Promise<T | null>;
|
|
50
|
-
/** Opens a dialog for selecting multiple entries. */
|
|
51
|
-
selectMultipleEntries: <T = Object>(options?: {
|
|
52
|
-
locale?: string;
|
|
53
|
-
contentTypes?: string[];
|
|
54
|
-
min?: number;
|
|
55
|
-
max?: number;
|
|
56
|
-
}) => Promise<T[] | null>;
|
|
57
|
-
/** Opens a dialog for selecting a single asset. */
|
|
58
|
-
selectSingleAsset: <T = Object>(options?: {
|
|
59
|
-
locale?: string;
|
|
60
|
-
mimetypeGroups?: string[];
|
|
61
|
-
}) => Promise<T | null>;
|
|
62
|
-
/** Opens a dialog for selecting multiple assets. */
|
|
63
|
-
selectMultipleAssets: <T = Object>(options?: {
|
|
64
|
-
locale?: string;
|
|
65
|
-
min?: number;
|
|
66
|
-
max?: number;
|
|
67
|
-
mimetypeGroups?: string[];
|
|
68
|
-
}) => Promise<T[] | null>;
|
|
69
|
-
}
|
|
1
|
+
import { SerializedJSONValue } from './utils';
|
|
2
|
+
export interface OpenAlertOptions {
|
|
3
|
+
title: string;
|
|
4
|
+
message: string;
|
|
5
|
+
confirmLabel?: string;
|
|
6
|
+
shouldCloseOnEscapePress?: boolean;
|
|
7
|
+
shouldCloseOnOverlayClick?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export type OpenConfirmOptions = OpenAlertOptions & {
|
|
10
|
+
cancelLabel?: string;
|
|
11
|
+
intent?: 'primary' | 'positive' | 'negative';
|
|
12
|
+
};
|
|
13
|
+
export interface OpenCustomWidgetOptions {
|
|
14
|
+
id?: string;
|
|
15
|
+
width?: number | 'small' | 'medium' | 'large' | 'fullWidth';
|
|
16
|
+
minHeight?: number | string;
|
|
17
|
+
allowHeightOverflow?: boolean;
|
|
18
|
+
position?: 'center' | 'top';
|
|
19
|
+
title?: string;
|
|
20
|
+
shouldCloseOnOverlayClick?: boolean;
|
|
21
|
+
shouldCloseOnEscapePress?: boolean;
|
|
22
|
+
parameters?: SerializedJSONValue;
|
|
23
|
+
}
|
|
24
|
+
export interface EntityDialogOptions {
|
|
25
|
+
locale?: string;
|
|
26
|
+
contentTypes?: string[];
|
|
27
|
+
min?: number;
|
|
28
|
+
max?: number;
|
|
29
|
+
}
|
|
30
|
+
export interface DialogsAPI {
|
|
31
|
+
/** Opens a simple alert window (which can only be closed). */
|
|
32
|
+
openAlert: (options: OpenAlertOptions) => Promise<boolean>;
|
|
33
|
+
/** Opens a confirmation window. A user can either confirm or cancel the dialog. */
|
|
34
|
+
openConfirm: (options: OpenConfirmOptions) => Promise<boolean>;
|
|
35
|
+
/** Opens a prompt window. A user can either provide a string input or cancel the dialog. */
|
|
36
|
+
openPrompt: (options: OpenConfirmOptions & {
|
|
37
|
+
defaultValue?: string;
|
|
38
|
+
}) => Promise<string | boolean>;
|
|
39
|
+
/** Opens an extension in a dialog. */
|
|
40
|
+
openExtension: (options: OpenCustomWidgetOptions) => Promise<any>;
|
|
41
|
+
/** Opens the current app in a dialog */
|
|
42
|
+
openCurrentApp: (options?: Omit<OpenCustomWidgetOptions, 'id'>) => Promise<any>;
|
|
43
|
+
/** Opens the current app or extension in a dialog */
|
|
44
|
+
openCurrent: (options?: Omit<OpenCustomWidgetOptions, 'id'> | OpenCustomWidgetOptions) => Promise<any>;
|
|
45
|
+
/** Opens a dialog for selecting a single entry. */
|
|
46
|
+
selectSingleEntry: <T = Object>(options?: {
|
|
47
|
+
locale?: string;
|
|
48
|
+
contentTypes?: string[];
|
|
49
|
+
}) => Promise<T | null>;
|
|
50
|
+
/** Opens a dialog for selecting multiple entries. */
|
|
51
|
+
selectMultipleEntries: <T = Object>(options?: {
|
|
52
|
+
locale?: string;
|
|
53
|
+
contentTypes?: string[];
|
|
54
|
+
min?: number;
|
|
55
|
+
max?: number;
|
|
56
|
+
}) => Promise<T[] | null>;
|
|
57
|
+
/** Opens a dialog for selecting a single asset. */
|
|
58
|
+
selectSingleAsset: <T = Object>(options?: {
|
|
59
|
+
locale?: string;
|
|
60
|
+
mimetypeGroups?: string[];
|
|
61
|
+
}) => Promise<T | null>;
|
|
62
|
+
/** Opens a dialog for selecting multiple assets. */
|
|
63
|
+
selectMultipleAssets: <T = Object>(options?: {
|
|
64
|
+
locale?: string;
|
|
65
|
+
min?: number;
|
|
66
|
+
max?: number;
|
|
67
|
+
mimetypeGroups?: string[];
|
|
68
|
+
}) => Promise<T[] | null>;
|
|
69
|
+
}
|
package/dist/types/entities.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export type { AssetProps as Asset, ContentFields as ContentTypeField, ContentTypeFieldValidation, ContentTypeProps as ContentType, EditorInterfaceProps as EditorInterface, EntryProps as Entry, KeyValueMap, MetadataProps as Metadata, QueryOptions, RoleProps as Role, ScheduledActionProps as ScheduledAction, SpaceMembershipProps as SpaceMembership, TagProps as Tag, TagVisibility, TaskProps as Task, TeamProps as Team, UploadProps as Upload, UserProps as User, WorkflowDefinitionProps as WorkflowDefinition, } from 'contentful-management/types';
|
|
2
|
-
export interface CanonicalRequest {
|
|
3
|
-
method: 'GET' | 'PUT' | 'POST' | 'PATCH' | 'DELETE' | 'HEAD' | 'OPTIONS';
|
|
4
|
-
path: string;
|
|
5
|
-
headers?: Record<string, string>;
|
|
6
|
-
body?: string;
|
|
7
|
-
}
|
|
1
|
+
export type { AssetProps as Asset, ContentFields as ContentTypeField, ContentTypeFieldValidation, ContentTypeProps as ContentType, EditorInterfaceProps as EditorInterface, EntryProps as Entry, KeyValueMap, MetadataProps as Metadata, QueryOptions, RoleProps as Role, ScheduledActionProps as ScheduledAction, SpaceMembershipProps as SpaceMembership, TagProps as Tag, TagVisibility, TaskProps as Task, TeamProps as Team, UploadProps as Upload, UserProps as User, WorkflowDefinitionProps as WorkflowDefinition, } from 'contentful-management/types';
|
|
2
|
+
export interface CanonicalRequest {
|
|
3
|
+
method: 'GET' | 'PUT' | 'POST' | 'PATCH' | 'DELETE' | 'HEAD' | 'OPTIONS';
|
|
4
|
+
path: string;
|
|
5
|
+
headers?: Record<string, string>;
|
|
6
|
+
body?: string;
|
|
7
|
+
}
|
|
@@ -1,45 +1,45 @@
|
|
|
1
|
-
import { Metadata, Task } from './entities';
|
|
2
|
-
import { EntryFieldAPI } from './field.types';
|
|
3
|
-
import { CollectionResponse,
|
|
4
|
-
|
|
5
|
-
export interface TaskInputData {
|
|
6
|
-
assignedToId: string;
|
|
7
|
-
assignedToType?: 'User' | 'Team';
|
|
8
|
-
body: string;
|
|
9
|
-
status: TaskState;
|
|
10
|
-
dueDate?: string;
|
|
11
|
-
}
|
|
12
|
-
/** Allows accessing the Task API for the current entry. */
|
|
13
|
-
export interface TaskAPI {
|
|
14
|
-
getTask(id: string): Promise<Task>;
|
|
15
|
-
getTasks(query?: SearchQuery): Promise<CollectionResponse<Task>>;
|
|
16
|
-
createTask(data: TaskInputData): Promise<Task>;
|
|
17
|
-
updateTask(task: Task): Promise<Task>;
|
|
18
|
-
deleteTask(task: Task): Promise<void>;
|
|
19
|
-
}
|
|
20
|
-
export interface EntryAPI extends TaskAPI {
|
|
21
|
-
/** Returns sys for an entry. */
|
|
22
|
-
getSys: () =>
|
|
23
|
-
/** Publish the entry */
|
|
24
|
-
publish: (options?: {
|
|
25
|
-
skipUiValidation?: boolean;
|
|
26
|
-
}) => Promise<void>;
|
|
27
|
-
/** Unpublish the entry */
|
|
28
|
-
unpublish: () => Promise<void>;
|
|
29
|
-
/** Saves the current changes of the entry */
|
|
30
|
-
save: () => Promise<void>;
|
|
31
|
-
/** Calls the callback with sys every time that sys changes. */
|
|
32
|
-
onSysChanged: (callback: (sys:
|
|
33
|
-
/** Allows to control the values of all other fields in the current entry. */
|
|
34
|
-
fields: {
|
|
35
|
-
[key: string]: EntryFieldAPI;
|
|
36
|
-
};
|
|
37
|
-
/**
|
|
38
|
-
* Optional metadata on an entry
|
|
39
|
-
* @deprecated
|
|
40
|
-
*/
|
|
41
|
-
metadata?: Metadata;
|
|
42
|
-
getMetadata: () => Metadata | undefined;
|
|
43
|
-
onMetadataChanged: (callback: (metadata?: Metadata) => void) => VoidFunction;
|
|
44
|
-
}
|
|
45
|
-
export {};
|
|
1
|
+
import { Metadata, Task } from './entities';
|
|
2
|
+
import { EntryFieldAPI } from './field.types';
|
|
3
|
+
import { CollectionResponse, EntrySys, SearchQuery } from './utils';
|
|
4
|
+
type TaskState = 'active' | 'resolved';
|
|
5
|
+
export interface TaskInputData {
|
|
6
|
+
assignedToId: string;
|
|
7
|
+
assignedToType?: 'User' | 'Team';
|
|
8
|
+
body: string;
|
|
9
|
+
status: TaskState;
|
|
10
|
+
dueDate?: string;
|
|
11
|
+
}
|
|
12
|
+
/** Allows accessing the Task API for the current entry. */
|
|
13
|
+
export interface TaskAPI {
|
|
14
|
+
getTask(id: string): Promise<Task>;
|
|
15
|
+
getTasks(query?: SearchQuery): Promise<CollectionResponse<Task>>;
|
|
16
|
+
createTask(data: TaskInputData): Promise<Task>;
|
|
17
|
+
updateTask(task: Task): Promise<Task>;
|
|
18
|
+
deleteTask(task: Task): Promise<void>;
|
|
19
|
+
}
|
|
20
|
+
export interface EntryAPI extends TaskAPI {
|
|
21
|
+
/** Returns sys for an entry. */
|
|
22
|
+
getSys: () => EntrySys;
|
|
23
|
+
/** Publish the entry */
|
|
24
|
+
publish: (options?: {
|
|
25
|
+
skipUiValidation?: boolean;
|
|
26
|
+
}) => Promise<void>;
|
|
27
|
+
/** Unpublish the entry */
|
|
28
|
+
unpublish: () => Promise<void>;
|
|
29
|
+
/** Saves the current changes of the entry */
|
|
30
|
+
save: () => Promise<void>;
|
|
31
|
+
/** Calls the callback with sys every time that sys changes. */
|
|
32
|
+
onSysChanged: (callback: (sys: EntrySys) => void) => () => void;
|
|
33
|
+
/** Allows to control the values of all other fields in the current entry. */
|
|
34
|
+
fields: {
|
|
35
|
+
[key: string]: EntryFieldAPI;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Optional metadata on an entry
|
|
39
|
+
* @deprecated
|
|
40
|
+
*/
|
|
41
|
+
metadata?: Metadata;
|
|
42
|
+
getMetadata: () => Metadata | undefined;
|
|
43
|
+
onMetadataChanged: (callback: (metadata?: Metadata) => void) => VoidFunction;
|
|
44
|
+
}
|
|
45
|
+
export {};
|
|
@@ -1,37 +1,76 @@
|
|
|
1
|
-
import { ContentTypeFieldValidation } from './entities';
|
|
2
|
-
import type { Items,
|
|
3
|
-
import { ValidationError } from './validation-error';
|
|
4
|
-
|
|
5
|
-
/** The ID of a field is defined in an entry's content type. */
|
|
6
|
-
id: string;
|
|
7
|
-
/** The
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
|
|
11
|
-
/** Indicates if a value for this field is required */
|
|
12
|
-
required: boolean;
|
|
13
|
-
/** A list of validations for this field that are defined in the content type. */
|
|
14
|
-
validations: ContentTypeFieldValidation[];
|
|
15
|
-
/**
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
*
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
*
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
1
|
+
import { ContentTypeFieldValidation } from './entities';
|
|
2
|
+
import type { SerializedJSONValue, FieldType, Items, FieldLinkType } from './utils';
|
|
3
|
+
import { ValidationError } from './validation-error';
|
|
4
|
+
interface FieldAPIBase {
|
|
5
|
+
/** The ID of a field is defined in an entry's content type. */
|
|
6
|
+
id: string;
|
|
7
|
+
/** The name of the field */
|
|
8
|
+
name: string;
|
|
9
|
+
/** The current locale of a field the app is attached to. */
|
|
10
|
+
locale: string;
|
|
11
|
+
/** Indicates if a value for this field is required */
|
|
12
|
+
required: boolean;
|
|
13
|
+
/** A list of validations for this field that are defined in the content type. */
|
|
14
|
+
validations: ContentTypeFieldValidation[];
|
|
15
|
+
/** Gets the current value of the field and locale. */
|
|
16
|
+
getValue: () => any;
|
|
17
|
+
/** Sets the value for the field and locale. */
|
|
18
|
+
setValue: <Value = any>(value: Value) => Promise<SerializedJSONValue | undefined>;
|
|
19
|
+
/** Removes the value for the field and locale. */
|
|
20
|
+
removeValue: () => Promise<void>;
|
|
21
|
+
/** Communicates to the web application if the field is in a valid state or not. */
|
|
22
|
+
setInvalid: (value: boolean) => void;
|
|
23
|
+
/** Calls the callback every time the value of the field is changed by an external event or when setValue() is called.
|
|
24
|
+
* the returned function can be called to remove the handler function
|
|
25
|
+
**/
|
|
26
|
+
onValueChanged: (callback: (value: any) => void) => () => void;
|
|
27
|
+
/**
|
|
28
|
+
* Returns whether the current field is disabled
|
|
29
|
+
*
|
|
30
|
+
* The disabled state can change. To always work with the latest state, use `onIsDisabledChanged`.
|
|
31
|
+
*/
|
|
32
|
+
getIsDisabled(): boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Subscribes to changes to this field's disabled state
|
|
35
|
+
*
|
|
36
|
+
* @param callback Function that is called every time this field's disabled state changes. Called immidiately with the current state.
|
|
37
|
+
* @returns Function to unsubscribe. `callback` won't be called anymore.
|
|
38
|
+
*/
|
|
39
|
+
onIsDisabledChanged: (callback: (isDisabled: boolean) => void) => () => void;
|
|
40
|
+
/**
|
|
41
|
+
* Returns the field's validation errors
|
|
42
|
+
*
|
|
43
|
+
* The schema errors can change. To always work with the latest errors, use `onSchemaErrorsChanged`.
|
|
44
|
+
*/
|
|
45
|
+
getSchemaErrors(): ValidationError[];
|
|
46
|
+
/**
|
|
47
|
+
* Subscribes to schema errors
|
|
48
|
+
*
|
|
49
|
+
* @param callback Function that is called every time the schema errors change. Called immediately with the current errors.
|
|
50
|
+
* @returns Function to unsubscribe. `callback` won't be called anymore.
|
|
51
|
+
*/
|
|
52
|
+
onSchemaErrorsChanged: (callback: (errors: ValidationError[]) => void) => () => void;
|
|
53
|
+
}
|
|
54
|
+
interface BasicFieldAPI extends FieldAPIBase {
|
|
55
|
+
/** Holds the type of the field. */
|
|
56
|
+
type: Exclude<FieldType, 'Array' | 'Link'>;
|
|
57
|
+
}
|
|
58
|
+
interface ArrayFieldAPI extends FieldAPIBase {
|
|
59
|
+
/** Holds the type of the field. */
|
|
60
|
+
type: 'Array';
|
|
61
|
+
/** Defines the shape of array items */
|
|
62
|
+
items: Items;
|
|
63
|
+
}
|
|
64
|
+
interface LinkFieldAPI extends FieldAPIBase {
|
|
65
|
+
/** Holds the type of the field. */
|
|
66
|
+
type: 'Link';
|
|
67
|
+
/** Type of linked resource */
|
|
68
|
+
linkType: FieldLinkType;
|
|
69
|
+
}
|
|
70
|
+
export interface ExhaustiveFieldAPI extends FieldAPIBase {
|
|
71
|
+
type: FieldType;
|
|
72
|
+
items?: Items;
|
|
73
|
+
linkType?: FieldLinkType;
|
|
74
|
+
}
|
|
75
|
+
export type FieldAPI = BasicFieldAPI | ArrayFieldAPI | LinkFieldAPI;
|
|
76
|
+
export {};
|
|
@@ -1,61 +1,113 @@
|
|
|
1
|
-
import { Items,
|
|
2
|
-
import { FieldAPI } from './field-locale.types';
|
|
3
|
-
import { ContentTypeFieldValidation } from './entities';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
value: any;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
type:
|
|
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
|
-
|
|
1
|
+
import { SerializedJSONValue, FieldType, Items, FieldLinkType } from './utils';
|
|
2
|
+
import { FieldAPI } from './field-locale.types';
|
|
3
|
+
import { ContentTypeFieldValidation } from './entities';
|
|
4
|
+
import { ValidationError } from './validation-error';
|
|
5
|
+
interface FieldInfoBase {
|
|
6
|
+
id: string;
|
|
7
|
+
name: string;
|
|
8
|
+
locale: string;
|
|
9
|
+
required: boolean;
|
|
10
|
+
validations: ContentTypeFieldValidation[];
|
|
11
|
+
value: any;
|
|
12
|
+
isDisabled: boolean;
|
|
13
|
+
schemaErrors: ValidationError[];
|
|
14
|
+
}
|
|
15
|
+
interface BasicFieldInfo extends FieldInfoBase {
|
|
16
|
+
type: Exclude<FieldType, 'Array' | 'Link'>;
|
|
17
|
+
}
|
|
18
|
+
interface ArrayFieldInfo extends FieldInfoBase {
|
|
19
|
+
type: 'Array';
|
|
20
|
+
items: Items;
|
|
21
|
+
}
|
|
22
|
+
interface LinkFieldInfo extends FieldInfoBase {
|
|
23
|
+
type: 'Link';
|
|
24
|
+
linkType: FieldLinkType;
|
|
25
|
+
}
|
|
26
|
+
export type FieldInfo = BasicFieldInfo | ArrayFieldInfo | LinkFieldInfo;
|
|
27
|
+
interface EntryFieldInfoBase {
|
|
28
|
+
id: string;
|
|
29
|
+
name: string;
|
|
30
|
+
locales: string[];
|
|
31
|
+
required: boolean;
|
|
32
|
+
validations: ContentTypeFieldValidation[];
|
|
33
|
+
values: {
|
|
34
|
+
[locale: string]: any;
|
|
35
|
+
};
|
|
36
|
+
isDisabled: {
|
|
37
|
+
[locale: string]: boolean;
|
|
38
|
+
};
|
|
39
|
+
schemaErrors: {
|
|
40
|
+
[locale: string]: ValidationError[];
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
interface BasicEntryFieldInfo extends EntryFieldInfoBase {
|
|
44
|
+
type: Exclude<FieldType, 'Array' | 'Link'>;
|
|
45
|
+
}
|
|
46
|
+
interface ArrayEntryFieldInfo extends EntryFieldInfoBase {
|
|
47
|
+
type: 'Array';
|
|
48
|
+
items: Items;
|
|
49
|
+
}
|
|
50
|
+
interface LinkEntryFieldInfo extends EntryFieldInfoBase {
|
|
51
|
+
type: 'Link';
|
|
52
|
+
linkType: FieldLinkType;
|
|
53
|
+
}
|
|
54
|
+
export type EntryFieldInfo = BasicEntryFieldInfo | ArrayEntryFieldInfo | LinkEntryFieldInfo;
|
|
55
|
+
export interface EntryFieldAPIBase {
|
|
56
|
+
/** The ID of a field is defined in an entry's content type. */
|
|
57
|
+
id: string;
|
|
58
|
+
/** The name of the field */
|
|
59
|
+
name: string;
|
|
60
|
+
/** The list of locales for the field. */
|
|
61
|
+
locales: string[];
|
|
62
|
+
/** Indicates if a value for this field is required */
|
|
63
|
+
required: boolean;
|
|
64
|
+
/** A list of validations for this field that are defined in the content type. */
|
|
65
|
+
validations: ContentTypeFieldValidation[];
|
|
66
|
+
/** Gets the current value of the field and locale. */
|
|
67
|
+
getValue: (locale?: string) => any;
|
|
68
|
+
/** Sets the value for the field and locale. */
|
|
69
|
+
setValue: <Value = any>(value: Value, locale?: string) => Promise<SerializedJSONValue | undefined>;
|
|
70
|
+
/** Removes the value for the field and locale. */
|
|
71
|
+
removeValue: (locale?: string) => Promise<void>;
|
|
72
|
+
/** Calls the callback every time the value of the field is changed by an external event or when setValue() is called.
|
|
73
|
+
* the returned function can be called to remove the handler function
|
|
74
|
+
**/
|
|
75
|
+
onValueChanged: {
|
|
76
|
+
(callback: (value: any) => void): () => void;
|
|
77
|
+
(locale: string, callback: (value: any) => void): () => void;
|
|
78
|
+
};
|
|
79
|
+
/** Calls the callback when the disabled status of the field changes.
|
|
80
|
+
* the returned function can be called to remove the handler function
|
|
81
|
+
**/
|
|
82
|
+
onIsDisabledChanged: {
|
|
83
|
+
(callback: (isDisabled: boolean) => void): () => void;
|
|
84
|
+
(locale: string, callback: (isDisabled: boolean) => void): () => void;
|
|
85
|
+
};
|
|
86
|
+
/** Get an instance of FieldAPI for this field, specific to the locale that is
|
|
87
|
+
* passed as an argument
|
|
88
|
+
**/
|
|
89
|
+
getForLocale: (locale: string) => FieldAPI;
|
|
90
|
+
}
|
|
91
|
+
interface BasicEntryFieldAPI extends EntryFieldAPIBase {
|
|
92
|
+
/** Holds the type of the field. */
|
|
93
|
+
type: Exclude<FieldType, 'Array' | 'Link'>;
|
|
94
|
+
}
|
|
95
|
+
interface ArrayEntryFieldAPI extends EntryFieldAPIBase {
|
|
96
|
+
/** Holds the type of the field. */
|
|
97
|
+
type: 'Array';
|
|
98
|
+
/** Defines the shape of array items */
|
|
99
|
+
items: Items;
|
|
100
|
+
}
|
|
101
|
+
interface LinkEntryFieldAPI extends EntryFieldAPIBase {
|
|
102
|
+
/** Holds the type of the field. */
|
|
103
|
+
type: 'Link';
|
|
104
|
+
/** Type of linked resource */
|
|
105
|
+
linkType: FieldLinkType;
|
|
106
|
+
}
|
|
107
|
+
export interface ExhaustiveEntryFieldAPI extends EntryFieldAPIBase {
|
|
108
|
+
type: FieldType;
|
|
109
|
+
items?: Items;
|
|
110
|
+
linkType?: FieldLinkType;
|
|
111
|
+
}
|
|
112
|
+
export type EntryFieldAPI = BasicEntryFieldAPI | ArrayEntryFieldAPI | LinkEntryFieldAPI;
|
|
113
|
+
export {};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
export type {
|
|
2
|
-
export type { AppConfigAPI, AppState, OnConfigureHandler, OnConfigureHandlerReturn, } from './app.types';
|
|
3
|
-
export type { DialogsAPI, EntityDialogOptions, OpenAlertOptions, OpenConfirmOptions, OpenCustomWidgetOptions, } from './dialogs.types';
|
|
4
|
-
export type { Asset, CanonicalRequest, ContentType, ContentTypeField, EditorInterface, Entry, Metadata, Role, ScheduledAction, SpaceMembership, Tag, TagVisibility, Task, Team, User, WorkflowDefinition, } from './entities';
|
|
5
|
-
export type { EntryAPI, TaskAPI, TaskInputData } from './entry.types';
|
|
6
|
-
export type { FieldInfo, EntryFieldInfo, EntryFieldAPI } from './field.types';
|
|
7
|
-
export type { FieldAPI } from './field-locale.types';
|
|
8
|
-
export type { NavigatorAPI, AppPageLocationOptions, NavigatorAPIOptions, NavigatorOpenResponse, NavigatorPageResponse, NavigatorSlideInfo, PageExtensionOptions, } from './navigator.types';
|
|
9
|
-
export type { SpaceAPI } from './space.types';
|
|
10
|
-
export type { SearchQuery, CollectionResponse, ContentEntitySys, ContentEntityType, Items, Link, WithOptionalId, WithId, SerializedJSONValue, } from './utils';
|
|
11
|
-
export type { DateRangeValidationError, InValidationError, LinkContentTypeValidationError, LinkMimetypeGroupValidationError, NotResolvableValidationError, ProhibitRegexpValidationError, RangeValidationError, RegexpValidationError, RequiredValidationError, SizeValidationError, TypeValidationError, UniqueValidationError, UnknownValidationError, ValidationError, } from './validation-error';
|
|
12
|
-
export type { WindowAPI } from './window.types';
|
|
1
|
+
export type { AppExtensionSDK, BaseExtensionSDK, DialogExtensionSDK, EditorExtensionSDK, FieldExtensionSDK, HomeExtensionSDK, KnownSDK, PageExtensionSDK, SidebarExtensionSDK, ConfigAppSDK, BaseAppSDK, DialogAppSDK, EditorAppSDK, FieldAppSDK, HomeAppSDK, KnownAppSDK, PageAppSDK, SidebarAppSDK, AccessAPI, ArchiveableAction, ConnectMessage, ContentTypeAPI, CrudAction, EditorLocaleSettings, IdsAPI, LocalesAPI, LocationAPI, Locations, NotifierAPI, ParametersAPI, PublishableAction, SharedEditorSDK, UserAPI, JSONPatchItem, } from './api.types';
|
|
2
|
+
export type { AppConfigAPI, AppState, OnConfigureHandler, OnConfigureHandlerReturn, } from './app.types';
|
|
3
|
+
export type { DialogsAPI, EntityDialogOptions, OpenAlertOptions, OpenConfirmOptions, OpenCustomWidgetOptions, } from './dialogs.types';
|
|
4
|
+
export type { Asset, CanonicalRequest, ContentType, ContentTypeField, EditorInterface, Entry, Metadata, Role, ScheduledAction, SpaceMembership, Tag, TagVisibility, Task, Team, User, WorkflowDefinition, } from './entities';
|
|
5
|
+
export type { EntryAPI, TaskAPI, TaskInputData } from './entry.types';
|
|
6
|
+
export type { FieldInfo, EntryFieldInfo, EntryFieldAPI } from './field.types';
|
|
7
|
+
export type { FieldAPI } from './field-locale.types';
|
|
8
|
+
export type { NavigatorAPI, AppPageLocationOptions, NavigatorAPIOptions, NavigatorOpenResponse, NavigatorPageResponse, NavigatorSlideInfo, PageExtensionOptions, } from './navigator.types';
|
|
9
|
+
export type { SpaceAPI } from './space.types';
|
|
10
|
+
export type { SearchQuery, CollectionResponse, EntrySys, ContentEntitySys, ContentEntityType, FieldType, FieldLinkType, Items, Link, WithOptionalId, WithId, SerializedJSONValue, } from './utils';
|
|
11
|
+
export type { DateRangeValidationError, InValidationError, LinkContentTypeValidationError, LinkMimetypeGroupValidationError, NotResolvableValidationError, ProhibitRegexpValidationError, RangeValidationError, RegexpValidationError, RequiredValidationError, SizeValidationError, TypeValidationError, UniqueValidationError, UnknownValidationError, ValidationError, } from './validation-error';
|
|
12
|
+
export type { WindowAPI } from './window.types';
|
|
13
|
+
export type { CMAClient } from './cmaClient.types';
|