@contello/extension 8.21.0 → 8.21.2

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/index.d.ts CHANGED
@@ -1,263 +1,247 @@
1
- declare class ContelloClient<D, O extends ContelloClientChildMethods, R extends ContelloClientParentMethods> {
2
- protected channel: ExtensionChannel<O, R>;
3
- protected projectId: string;
4
- private resizeObserver?;
5
- private targetOrigin;
6
- data?: D;
7
- private dialogs;
8
- constructor(targetOrigin: string, channelId: string, projectId: string, debug: boolean);
9
- connect(): Promise<void>;
10
- ready(): Promise<R["ready"][1]>;
11
- getAuthToken(): Promise<string>;
12
- createProjectUrl(): string;
13
- private createEntityEntryUrl;
14
- createSingletonEntityUrl(referenceName: string): string;
15
- createEntityDetailUrl(referenceName: string, params: ContelloEntityDetailParams): string;
16
- /**
17
- * @deprecated Use createEntityDetailUrl instead
18
- */
19
- createEntityUrl(referenceName: string, entityId: string): string;
20
- createExtensionUrl(referenceName: string, params?: {
21
- path?: string[];
22
- query?: {
23
- [prop: string]: string;
24
- };
25
- }): string;
26
- navigate(url: string): Promise<R["navigate"][1]>;
27
- displayNotification(type: 'success' | 'error', message: string): Promise<R["displayNotification"][1]>;
28
- openDialog<D, T>(options: ContelloDialogOptions<D>): ContelloDialogRef<D, T>;
29
- private listenForResize;
30
- private getWindowHeight;
31
- private getDialogController;
32
- }
33
-
34
- export declare interface ContelloClientChildMethods extends ContelloMethods {
35
- dialogConnect: [{
36
- id: string;
37
- }, void];
38
- dialogReady: [{
39
- id: string;
40
- }, void];
41
- dialogComplete: [{
42
- id: string;
43
- value: any;
44
- }, void];
45
- }
46
-
47
- export declare interface ContelloClientParentMethods extends ContelloMethods {
48
- connect: [void, {
49
- connected: boolean;
50
- data: any;
51
- }];
52
- resize: [{
53
- height: number;
54
- }, void];
55
- ready: [{
56
- height: number;
57
- }, void];
58
- getAuthToken: [void, {
59
- token: string;
60
- }];
61
- navigate: [{
62
- url: string;
63
- }, void];
64
- displayNotification: [{
65
- message: string;
66
- type: 'success' | 'error';
67
- }, void];
68
- openDialog: [{
69
- url: string;
70
- width: number;
71
- data: any;
72
- }, {
73
- id: string;
74
- }];
75
- closeDialog: [{
76
- id: string;
77
- }, void];
78
- complete: [{
79
- value: any;
80
- }, void];
81
- }
82
-
83
- export declare class ContelloCustomProperty extends ContelloClient<void, ContelloCustomPropertyChildMethods, ContelloCustomPropertyParentMethods> {
84
- static connect(options: ContelloCustomPropertyOptions): Promise<ContelloCustomProperty>;
85
- validate: () => boolean;
86
- newValue: (value: string) => void;
87
- constructor(targetOrigin: string, channelId: string, applicationId: string, debug: boolean);
88
- getValue(): Promise<string>;
89
- setValue(value: string): Promise<void>;
90
- getValueByPath(path: string): Promise<any>;
91
- setValueByPath(path: string, value: any): Promise<void>;
92
- }
93
-
94
- export declare interface ContelloCustomPropertyChildMethods extends ContelloClientChildMethods {
95
- validate: [void, {
96
- valid: boolean;
97
- }];
98
- newValue: [{
99
- value: string;
100
- }, void];
101
- }
102
-
103
- declare interface ContelloCustomPropertyOptions {
104
- trustedOrigins: string[];
105
- validator?: () => boolean;
106
- newValue?: (value: any) => void;
107
- }
108
-
109
- export declare interface ContelloCustomPropertyParentMethods extends ContelloClientParentMethods {
110
- getValue: [void, {
111
- value: string;
112
- }];
113
- setValue: [{
114
- value: string;
115
- valid: boolean;
116
- }, void];
117
- getValueByPath: [{
118
- path: string;
119
- }, {
120
- value: any;
121
- }];
122
- setValueByPath: [{
123
- path: string;
124
- value: any;
125
- }, void];
126
- }
127
-
128
- export declare class ContelloDialog<D, T> extends ContelloClient<D, any, any> {
129
- static connect<D, T>({ trustedOrigins }: {
130
- trustedOrigins: string[];
131
- }): Promise<ContelloDialog<D, T>>;
132
- constructor(targetOrigin: string, channelId: string, applicationId: string, debug: boolean);
133
- close(value?: T): Promise<any>;
134
- }
135
-
136
- declare interface ContelloDialogOptions<D> {
137
- url: string;
138
- width?: number;
139
- data?: D;
140
- }
141
-
142
- declare interface ContelloDialogParams<D, T> {
143
- channel: ExtensionChannel<any, any>;
144
- options: ContelloDialogOptions<D>;
145
- controller: {
146
- connected: Deferred<void>;
147
- ready: Deferred<void>;
148
- complete: Deferred<T>;
149
- close: () => void;
150
- };
151
- }
152
-
153
- export declare class ContelloDialogRef<D, T> {
154
- private _id?;
155
- readonly open: Promise<void>;
156
- readonly connected: Promise<void>;
157
- readonly ready: Promise<void>;
158
- readonly complete: Promise<T>;
159
- readonly close: () => void;
160
- constructor({ channel, options, controller }: ContelloDialogParams<D, T>);
161
- get id(): string | undefined;
162
- }
163
-
164
- declare type ContelloEntityDetailParams = {
165
- mode: 'create';
166
- } | {
167
- mode: 'edit';
168
- id: string;
169
- } | {
170
- mode: 'clone';
171
- id: string;
172
- };
173
-
174
- export declare class ContelloExtension extends ContelloClient<void, ContelloExtensionChildMethods, ContelloExtensionParentMethods> {
175
- static connect({ trustedOrigins }: ContelloExtensionOptions): Promise<ContelloExtension>;
176
- constructor(targetOrigin: string, channelId: string, applicationId: string, debug: boolean);
177
- getUrlData(): Promise<{
178
- path: ContelloExtensionPath;
179
- query: ContelloExtensionQuery;
180
- }>;
181
- setBreadcrumbs(breadcrumbs: ContelloExtensionBreadcrumb[]): Promise<void>;
182
- }
183
-
184
- export declare interface ContelloExtensionBreadcrumb {
185
- label: string;
186
- url?: string;
187
- }
188
-
189
- export declare type ContelloExtensionChildMethods = ContelloClientChildMethods;
190
-
191
- declare interface ContelloExtensionOptions {
192
- trustedOrigins: string[];
193
- }
194
-
195
- export declare interface ContelloExtensionParentMethods extends ContelloClientParentMethods {
196
- getUrlData: [void, {
197
- path: ContelloExtensionPath;
198
- query: ContelloExtensionQuery;
199
- }];
200
- setBreadcrumbs: [{
201
- breadcrumbs: ContelloExtensionBreadcrumb[];
202
- }, void];
203
- }
204
-
205
- export declare type ContelloExtensionPath = string[];
206
-
207
- export declare interface ContelloExtensionQuery {
208
- [prop: string]: string;
209
- }
210
-
211
- export declare interface ContelloMethods {
212
- [prop: string]: [unknown, unknown];
213
- }
214
-
215
- declare class Deferred<T> {
216
- resolve: (value?: T) => void;
217
- reject: (reason?: any) => void;
218
- promise: Promise<T>;
219
- }
220
-
221
- export declare class ExtensionChannel<OWN extends ContelloMethods, REMOTE extends ContelloMethods> {
222
- private params;
223
- handlers: Map<any, any>;
224
- listeners: Map<string, Handler<any, any>>;
225
- private targetWindow;
226
- private channelId;
227
- private targetOrigin;
228
- private isParent;
229
- constructor(params: {
230
- debug: boolean;
231
- });
232
- populateChannelId(): string;
233
- connectParent(targetOrigin: string, channelId: string): void;
234
- connectChild(targetWindow: Window): void;
235
- getChannelId(): string;
236
- getIsDebug(): boolean;
237
- getTargetOrigin(): string;
238
- getTargetWindow(): Window;
239
- private connect;
240
- disconnect(): void;
241
- private handler;
242
- respond(request: ExtensionEvent, payload: ExtensionEventPayload): void;
243
- respondError(request: ExtensionEvent, error: any): void;
244
- on<M extends keyof OWN>(method: M, handler: Handler<OWN[M][0], OWN[M][1]>): void;
245
- call<M extends keyof REMOTE>(method: M, message?: REMOTE[M][0]): Promise<REMOTE[M][1]>;
246
- send(data: ExtensionEvent): void;
247
- private createChannelId;
248
- private createRequestId;
249
- }
250
-
251
- declare interface ExtensionEvent<T extends ExtensionEventPayload = ExtensionEventPayload> {
252
- channelId: string;
253
- requestId: string;
254
- method: string;
255
- payload?: T;
256
- error?: string;
257
- }
258
-
259
- declare type ExtensionEventPayload = object;
260
-
261
- declare type Handler<REQ, RES> = (msg: REQ) => RES | Promise<RES>;
262
-
263
- export { }
1
+ interface ContelloMethods {
2
+ [prop: string]: [unknown, unknown];
3
+ }
4
+ interface ContelloClientParentMethods extends ContelloMethods {
5
+ connect: [void, {
6
+ connected: boolean;
7
+ data: any;
8
+ }];
9
+ resize: [{
10
+ height: number;
11
+ }, void];
12
+ ready: [{
13
+ height: number;
14
+ }, void];
15
+ getAuthToken: [void, {
16
+ token: string;
17
+ }];
18
+ navigate: [{
19
+ url: string;
20
+ }, void];
21
+ displayNotification: [{
22
+ message: string;
23
+ type: 'success' | 'error';
24
+ }, void];
25
+ openDialog: [{
26
+ url: string;
27
+ width: number;
28
+ data: any;
29
+ }, {
30
+ id: string;
31
+ }];
32
+ closeDialog: [{
33
+ id: string;
34
+ }, void];
35
+ complete: [{
36
+ value: any;
37
+ }, void];
38
+ }
39
+ interface ContelloCustomPropertyParentMethods extends ContelloClientParentMethods {
40
+ getValue: [void, {
41
+ value: string;
42
+ }];
43
+ setValue: [{
44
+ value: string;
45
+ valid: boolean;
46
+ }, void];
47
+ getValueByPath: [{
48
+ path: string;
49
+ }, {
50
+ value: any;
51
+ }];
52
+ setValueByPath: [{
53
+ path: string;
54
+ value: any;
55
+ }, void];
56
+ }
57
+ type ContelloExtensionPath = string[];
58
+ interface ContelloExtensionQuery {
59
+ [prop: string]: string;
60
+ }
61
+ interface ContelloExtensionBreadcrumb {
62
+ label: string;
63
+ url?: string;
64
+ }
65
+ interface ContelloExtensionParentMethods extends ContelloClientParentMethods {
66
+ getUrlData: [void, {
67
+ path: ContelloExtensionPath;
68
+ query: ContelloExtensionQuery;
69
+ }];
70
+ setBreadcrumbs: [{
71
+ breadcrumbs: ContelloExtensionBreadcrumb[];
72
+ }, void];
73
+ }
74
+ interface ContelloClientChildMethods extends ContelloMethods {
75
+ dialogConnect: [{
76
+ id: string;
77
+ }, void];
78
+ dialogReady: [{
79
+ id: string;
80
+ }, void];
81
+ dialogComplete: [{
82
+ id: string;
83
+ value: any;
84
+ }, void];
85
+ }
86
+ interface ContelloCustomPropertyChildMethods extends ContelloClientChildMethods {
87
+ validate: [void, {
88
+ valid: boolean;
89
+ }];
90
+ newValue: [{
91
+ value: string;
92
+ }, void];
93
+ }
94
+ type ContelloExtensionChildMethods = ContelloClientChildMethods;
95
+
96
+ type ExtensionEventPayload = object;
97
+ interface ExtensionEvent<T extends ExtensionEventPayload = ExtensionEventPayload> {
98
+ channelId: string;
99
+ requestId: string;
100
+ method: string;
101
+ payload?: T;
102
+ error?: string;
103
+ }
104
+
105
+ type Handler<REQ, RES> = (msg: REQ) => RES | Promise<RES>;
106
+ declare class ExtensionChannel<OWN extends ContelloMethods, REMOTE extends ContelloMethods> {
107
+ private params;
108
+ handlers: Map<any, any>;
109
+ listeners: Map<string, Handler<any, any>>;
110
+ private targetWindow;
111
+ private channelId;
112
+ private targetOrigin;
113
+ private isParent;
114
+ constructor(params: {
115
+ debug: boolean;
116
+ });
117
+ populateChannelId(): string;
118
+ connectParent(targetOrigin: string, channelId: string): void;
119
+ connectChild(targetWindow: Window): void;
120
+ getChannelId(): string;
121
+ getIsDebug(): boolean;
122
+ getTargetOrigin(): string;
123
+ getTargetWindow(): Window;
124
+ private connect;
125
+ disconnect(): void;
126
+ private handler;
127
+ respond(request: ExtensionEvent, payload: ExtensionEventPayload): void;
128
+ respondError(request: ExtensionEvent, error: any): void;
129
+ on<M extends keyof OWN>(method: M, handler: Handler<OWN[M][0], OWN[M][1]>): void;
130
+ call<M extends keyof REMOTE>(method: M, message?: REMOTE[M][0]): Promise<REMOTE[M][1]>;
131
+ send(data: ExtensionEvent): void;
132
+ private createChannelId;
133
+ private createRequestId;
134
+ }
135
+
136
+ declare class Deferred<T> {
137
+ resolve: (value?: T) => void;
138
+ reject: (reason?: any) => void;
139
+ promise: Promise<T>;
140
+ }
141
+
142
+ interface ContelloDialogParams<D, T> {
143
+ channel: ExtensionChannel<any, any>;
144
+ options: ContelloDialogOptions<D>;
145
+ controller: {
146
+ connected: Deferred<void>;
147
+ ready: Deferred<void>;
148
+ complete: Deferred<T>;
149
+ close: () => void;
150
+ };
151
+ }
152
+ interface ContelloDialogOptions<D> {
153
+ url: string;
154
+ width?: number;
155
+ data?: D;
156
+ }
157
+ declare class ContelloDialogRef<D, T> {
158
+ private _id?;
159
+ readonly open: Promise<void>;
160
+ readonly connected: Promise<void>;
161
+ readonly ready: Promise<void>;
162
+ readonly complete: Promise<T>;
163
+ readonly close: () => void;
164
+ constructor({ channel, options, controller }: ContelloDialogParams<D, T>);
165
+ get id(): string | undefined;
166
+ }
167
+
168
+ type ContelloEntityDetailParams = {
169
+ mode: 'create';
170
+ } | {
171
+ mode: 'edit';
172
+ id: string;
173
+ } | {
174
+ mode: 'clone';
175
+ id: string;
176
+ };
177
+ declare class ContelloClient<D, O extends ContelloClientChildMethods, R extends ContelloClientParentMethods> {
178
+ protected channel: ExtensionChannel<O, R>;
179
+ protected projectId: string;
180
+ private resizeObserver?;
181
+ private targetOrigin;
182
+ data?: D;
183
+ private dialogs;
184
+ constructor(targetOrigin: string, channelId: string, projectId: string, debug: boolean);
185
+ connect(): Promise<void>;
186
+ ready(): Promise<R["ready"][1]>;
187
+ getAuthToken(): Promise<string>;
188
+ createProjectUrl(): string;
189
+ private createEntityEntryUrl;
190
+ createSingletonEntityUrl(referenceName: string): string;
191
+ createEntityDetailUrl(referenceName: string, params: ContelloEntityDetailParams): string;
192
+ /**
193
+ * @deprecated Use createEntityDetailUrl instead
194
+ */
195
+ createEntityUrl(referenceName: string, entityId: string): string;
196
+ createExtensionUrl(referenceName: string, params?: {
197
+ path?: string[];
198
+ query?: {
199
+ [prop: string]: string;
200
+ };
201
+ }): string;
202
+ navigate(url: string): Promise<R["navigate"][1]>;
203
+ displayNotification(type: 'success' | 'error', message: string): Promise<R["displayNotification"][1]>;
204
+ openDialog<D, T>(options: ContelloDialogOptions<D>): ContelloDialogRef<D, T>;
205
+ private listenForResize;
206
+ private getWindowHeight;
207
+ private getDialogController;
208
+ }
209
+
210
+ interface ContelloCustomPropertyOptions {
211
+ trustedOrigins: string[];
212
+ validator?: () => boolean;
213
+ newValue?: (value: any) => void;
214
+ }
215
+ declare class ContelloCustomProperty extends ContelloClient<void, ContelloCustomPropertyChildMethods, ContelloCustomPropertyParentMethods> {
216
+ static connect(options: ContelloCustomPropertyOptions): Promise<ContelloCustomProperty>;
217
+ validate: () => boolean;
218
+ newValue: (value: string) => void;
219
+ constructor(targetOrigin: string, channelId: string, applicationId: string, debug: boolean);
220
+ getValue(): Promise<string>;
221
+ setValue(value: string): Promise<void>;
222
+ getValueByPath(path: string): Promise<any>;
223
+ setValueByPath(path: string, value: any): Promise<void>;
224
+ }
225
+
226
+ declare class ContelloDialog<D, T> extends ContelloClient<D, any, any> {
227
+ static connect<D, T>({ trustedOrigins }: {
228
+ trustedOrigins: string[];
229
+ }): Promise<ContelloDialog<D, T>>;
230
+ constructor(targetOrigin: string, channelId: string, applicationId: string, debug: boolean);
231
+ close(value?: T): Promise<any>;
232
+ }
233
+
234
+ interface ContelloExtensionOptions {
235
+ trustedOrigins: string[];
236
+ }
237
+ declare class ContelloExtension extends ContelloClient<void, ContelloExtensionChildMethods, ContelloExtensionParentMethods> {
238
+ static connect({ trustedOrigins }: ContelloExtensionOptions): Promise<ContelloExtension>;
239
+ constructor(targetOrigin: string, channelId: string, applicationId: string, debug: boolean);
240
+ getUrlData(): Promise<{
241
+ path: ContelloExtensionPath;
242
+ query: ContelloExtensionQuery;
243
+ }>;
244
+ setBreadcrumbs(breadcrumbs: ContelloExtensionBreadcrumb[]): Promise<void>;
245
+ }
246
+
247
+ export { type ContelloClientChildMethods, type ContelloClientParentMethods, ContelloCustomProperty, type ContelloCustomPropertyChildMethods, type ContelloCustomPropertyParentMethods, ContelloDialog, ContelloDialogRef, ContelloExtension, type ContelloExtensionBreadcrumb, type ContelloExtensionChildMethods, type ContelloExtensionParentMethods, type ContelloExtensionPath, type ContelloExtensionQuery, type ContelloMethods, ExtensionChannel };