@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/README.md +123 -0
- package/dist/index.cjs +357 -0
- package/dist/index.d.cts +247 -0
- package/dist/index.d.ts +247 -263
- package/dist/index.js +216 -131
- package/package.json +17 -25
- package/dist/index.umd.cjs +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,263 +1,247 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}, void];
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}];
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
},
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
id: string;
|
|
77
|
-
}, void];
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
}, void];
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
declare
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
|
|
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
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
readonly
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
path
|
|
198
|
-
query
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
declare class
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
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 };
|