@floegence/redevplugin-ui 0.1.6 → 0.2.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/LICENSE +21 -0
- package/dist/contracts.gen.d.ts +130 -0
- package/dist/contracts.gen.js +145 -0
- package/dist/errors.d.ts +12 -0
- package/dist/errors.js +69 -0
- package/dist/http.d.ts +30 -0
- package/dist/http.js +45 -0
- package/dist/index.d.ts +1 -724
- package/dist/index.js +1 -875
- package/dist/local-import.d.ts +3 -1
- package/dist/local-import.js +13 -57
- package/dist/opaque-surface-policy.gen.d.ts +34 -0
- package/dist/opaque-surface-policy.gen.js +207 -0
- package/dist/platform.d.ts +466 -0
- package/dist/platform.js +142 -0
- package/dist/plugin.d.ts +2 -0
- package/dist/plugin.js +1 -0
- package/dist/surface-scope.d.ts +8 -0
- package/dist/surface-scope.js +31 -0
- package/dist/surface.d.ts +328 -0
- package/dist/surface.js +2073 -0
- package/dist/trusted-parent.d.ts +7 -0
- package/dist/trusted-parent.js +5 -0
- package/package.json +10 -1
|
@@ -0,0 +1,466 @@
|
|
|
1
|
+
import { type FetchLike } from "./http.js";
|
|
2
|
+
import type { PluginSurfaceHostBootstrap, PluginTrustedMethodResult } from "./surface.js";
|
|
3
|
+
import { type PluginSurfaceScope } from "./surface-scope.js";
|
|
4
|
+
export type PluginPlatformClientOptions = {
|
|
5
|
+
fetch?: FetchLike;
|
|
6
|
+
apiBaseURL?: string;
|
|
7
|
+
surfaceScope?: PluginSurfaceScope;
|
|
8
|
+
};
|
|
9
|
+
export type PluginCatalogRecord = Record<string, unknown>;
|
|
10
|
+
export type PluginCatalogResult = {
|
|
11
|
+
plugins?: PluginCatalogRecord[];
|
|
12
|
+
[key: string]: unknown;
|
|
13
|
+
};
|
|
14
|
+
export type PluginCompatibilityMatrix = {
|
|
15
|
+
redevplugin_go_version: string;
|
|
16
|
+
redevplugin_ui_version: string;
|
|
17
|
+
redevplugin_runtime_version: string;
|
|
18
|
+
plugin_ui_protocol_version: string;
|
|
19
|
+
plugin_host_protocol_version: string;
|
|
20
|
+
rust_ipc_version: string;
|
|
21
|
+
wasm_abi_version: string;
|
|
22
|
+
manifest_schema_version: string;
|
|
23
|
+
package_signature_schema_version: string;
|
|
24
|
+
release_metadata_schema_version: string;
|
|
25
|
+
source_policy_schema_version: string;
|
|
26
|
+
source_revocations_schema_version: string;
|
|
27
|
+
token_ticket_schema_version: string;
|
|
28
|
+
bridge_schema_version: string;
|
|
29
|
+
opaque_surface_document_schema_version: string;
|
|
30
|
+
opaque_surface_transport_schema_version: string;
|
|
31
|
+
target_classifier_version: string;
|
|
32
|
+
network_grant_schema_version: string;
|
|
33
|
+
plugin_platform_openapi_version: string;
|
|
34
|
+
compatibility_schema_version: string;
|
|
35
|
+
release_manifest_schema_version: string;
|
|
36
|
+
worker_invocation_schema_version: string;
|
|
37
|
+
error_codes_schema_version: string;
|
|
38
|
+
contract_registry_version: string;
|
|
39
|
+
[key: string]: unknown;
|
|
40
|
+
};
|
|
41
|
+
export type PluginContractArtifact = {
|
|
42
|
+
id: string;
|
|
43
|
+
path: string;
|
|
44
|
+
version: string;
|
|
45
|
+
sha256: string;
|
|
46
|
+
[key: string]: unknown;
|
|
47
|
+
};
|
|
48
|
+
export type PluginCompatibilityManifest = {
|
|
49
|
+
schema_version: string;
|
|
50
|
+
matrix: PluginCompatibilityMatrix;
|
|
51
|
+
contracts: PluginContractArtifact[];
|
|
52
|
+
[key: string]: unknown;
|
|
53
|
+
};
|
|
54
|
+
export type PluginTrustState = "verified" | "unsigned_local" | "untrusted" | "needs_review" | "trust_unavailable" | "blocked_security";
|
|
55
|
+
export type PluginEnableState = "disabled" | "enabled" | "disabled_by_policy";
|
|
56
|
+
export type PluginRetainedDataRecordState = "retained" | "expired" | "bound" | "deleted" | "delete_failed_retryable";
|
|
57
|
+
export type PluginRetainedDataState = "none" | PluginRetainedDataRecordState;
|
|
58
|
+
export type PluginTrustHashSet = {
|
|
59
|
+
package_sha256: string;
|
|
60
|
+
manifest_sha256: string;
|
|
61
|
+
entries_sha256: string;
|
|
62
|
+
};
|
|
63
|
+
export type PluginVerifiedSignature = {
|
|
64
|
+
algorithm: string;
|
|
65
|
+
key_id: string;
|
|
66
|
+
};
|
|
67
|
+
export type PluginTrustAssessment = {
|
|
68
|
+
trust_state: PluginTrustState | string;
|
|
69
|
+
reason_codes?: string[];
|
|
70
|
+
verified_hashes: PluginTrustHashSet;
|
|
71
|
+
verified_signature?: PluginVerifiedSignature;
|
|
72
|
+
trust_assessment_epoch?: string;
|
|
73
|
+
policy_epoch?: string;
|
|
74
|
+
revocation_epoch?: string;
|
|
75
|
+
metadata?: Record<string, string>;
|
|
76
|
+
};
|
|
77
|
+
export type PluginLocalImportProvenance = {
|
|
78
|
+
import_id: string;
|
|
79
|
+
distribution: "local_import" | string;
|
|
80
|
+
policy_epoch: string;
|
|
81
|
+
unsigned_policy: "dev_only" | "review_required" | "block" | string;
|
|
82
|
+
assessed_at: string;
|
|
83
|
+
};
|
|
84
|
+
export type PluginVersionRecord = {
|
|
85
|
+
version: string;
|
|
86
|
+
active_fingerprint: string;
|
|
87
|
+
package_hash: string;
|
|
88
|
+
manifest_hash: string;
|
|
89
|
+
entries_hash: string;
|
|
90
|
+
trust_state: PluginTrustState | string;
|
|
91
|
+
trust_assessment: PluginTrustAssessment;
|
|
92
|
+
source_policy_snapshot_hash?: string;
|
|
93
|
+
source_policy_snapshot?: Record<string, unknown>;
|
|
94
|
+
local_import_provenance?: PluginLocalImportProvenance;
|
|
95
|
+
metadata?: Record<string, string>;
|
|
96
|
+
[key: string]: unknown;
|
|
97
|
+
};
|
|
98
|
+
export type PluginRecord = {
|
|
99
|
+
plugin_instance_id: string;
|
|
100
|
+
publisher_id?: string;
|
|
101
|
+
plugin_id: string;
|
|
102
|
+
version: string;
|
|
103
|
+
active_fingerprint: string;
|
|
104
|
+
package_hash?: string;
|
|
105
|
+
manifest_hash?: string;
|
|
106
|
+
entries_hash?: string;
|
|
107
|
+
trust_state: PluginTrustState | string;
|
|
108
|
+
trust_assessment: PluginTrustAssessment;
|
|
109
|
+
source_policy_snapshot_hash?: string;
|
|
110
|
+
source_policy_snapshot?: Record<string, unknown>;
|
|
111
|
+
local_import_provenance?: PluginLocalImportProvenance;
|
|
112
|
+
enable_state: PluginEnableState | string;
|
|
113
|
+
disabled_reason?: string;
|
|
114
|
+
retained_data_state?: PluginRetainedDataState | string;
|
|
115
|
+
policy_revision?: number;
|
|
116
|
+
management_revision?: number;
|
|
117
|
+
revoke_epoch?: number;
|
|
118
|
+
manifest?: Record<string, unknown>;
|
|
119
|
+
package_entries?: Array<Record<string, unknown>>;
|
|
120
|
+
version_history?: PluginVersionRecord[];
|
|
121
|
+
installed_at?: string;
|
|
122
|
+
enabled_at?: string;
|
|
123
|
+
updated_at?: string;
|
|
124
|
+
deleted_at?: string;
|
|
125
|
+
metadata?: Record<string, string>;
|
|
126
|
+
[key: string]: unknown;
|
|
127
|
+
};
|
|
128
|
+
export type PluginPackageHashSet = {
|
|
129
|
+
package_sha256: string;
|
|
130
|
+
manifest_sha256: string;
|
|
131
|
+
entries_sha256: string;
|
|
132
|
+
};
|
|
133
|
+
export type PluginReleaseRef = {
|
|
134
|
+
source_id: string;
|
|
135
|
+
release_metadata_ref: string;
|
|
136
|
+
release_metadata_sha256: string;
|
|
137
|
+
publisher_id: string;
|
|
138
|
+
plugin_id: string;
|
|
139
|
+
version: string;
|
|
140
|
+
expected_hashes: PluginPackageHashSet;
|
|
141
|
+
};
|
|
142
|
+
export type PluginInstallReleaseRefRequest = {
|
|
143
|
+
release_ref: PluginReleaseRef;
|
|
144
|
+
plugin_instance_id?: string;
|
|
145
|
+
plugin_state_version: 0;
|
|
146
|
+
};
|
|
147
|
+
export type PluginUpdateReleaseRefRequest = {
|
|
148
|
+
plugin_instance_id: string;
|
|
149
|
+
release_ref: PluginReleaseRef;
|
|
150
|
+
plugin_state_version: number;
|
|
151
|
+
};
|
|
152
|
+
export type PluginDowngradeRequest = {
|
|
153
|
+
plugin_instance_id: string;
|
|
154
|
+
version?: string;
|
|
155
|
+
package_hash?: string;
|
|
156
|
+
plugin_state_version: number;
|
|
157
|
+
};
|
|
158
|
+
export type PluginEnableRequest = {
|
|
159
|
+
plugin_instance_id: string;
|
|
160
|
+
plugin_state_version: number;
|
|
161
|
+
};
|
|
162
|
+
export type PluginDisableRequest = {
|
|
163
|
+
plugin_instance_id: string;
|
|
164
|
+
plugin_state_version: number;
|
|
165
|
+
reason?: string;
|
|
166
|
+
};
|
|
167
|
+
export type PluginUninstallRequest = {
|
|
168
|
+
plugin_instance_id: string;
|
|
169
|
+
plugin_state_version: number;
|
|
170
|
+
delete_data: boolean;
|
|
171
|
+
};
|
|
172
|
+
export type PluginOpenSurfaceRequest = {
|
|
173
|
+
plugin_instance_id: string;
|
|
174
|
+
surface_id: string;
|
|
175
|
+
surface_instance_id?: string;
|
|
176
|
+
plugin_state_version: number;
|
|
177
|
+
};
|
|
178
|
+
export type PluginSurfaceScopeRevokeResult = {
|
|
179
|
+
revoked_surface_count: number;
|
|
180
|
+
};
|
|
181
|
+
export type PluginSurfaceBootstrapResult = {
|
|
182
|
+
plugin_id: string;
|
|
183
|
+
plugin_instance_id: string;
|
|
184
|
+
plugin_version: string;
|
|
185
|
+
surface_id: string;
|
|
186
|
+
surface_instance_id: string;
|
|
187
|
+
active_fingerprint: string;
|
|
188
|
+
entry_path: string;
|
|
189
|
+
entry_sha256: string;
|
|
190
|
+
asset_session_nonce: string;
|
|
191
|
+
plugin_state_version: number;
|
|
192
|
+
revoke_epoch: number;
|
|
193
|
+
runtime_generation_id: string;
|
|
194
|
+
asset_ticket: string;
|
|
195
|
+
asset_ticket_id: string;
|
|
196
|
+
bridge_nonce: string;
|
|
197
|
+
issued_at: string;
|
|
198
|
+
expires_at: string;
|
|
199
|
+
};
|
|
200
|
+
export declare function toPluginSurfaceHostBootstrap(value: PluginSurfaceBootstrapResult): PluginSurfaceHostBootstrap;
|
|
201
|
+
export type PluginRuntimeTarget = {
|
|
202
|
+
os?: string;
|
|
203
|
+
arch?: string;
|
|
204
|
+
};
|
|
205
|
+
export type PluginRuntimeStartRequest = {
|
|
206
|
+
target?: PluginRuntimeTarget;
|
|
207
|
+
};
|
|
208
|
+
export type PluginRuntimeHealth = {
|
|
209
|
+
runtime_instance_id: string;
|
|
210
|
+
runtime_generation_id: string;
|
|
211
|
+
runtime_version?: string;
|
|
212
|
+
rust_ipc_version?: string;
|
|
213
|
+
wasm_abi_version?: string;
|
|
214
|
+
ready: boolean;
|
|
215
|
+
};
|
|
216
|
+
export type PluginRuntimeStopResult = {
|
|
217
|
+
stopped: boolean;
|
|
218
|
+
};
|
|
219
|
+
export type PluginRuntimeRefreshResult = {
|
|
220
|
+
refreshed_plugins: PluginRecord[];
|
|
221
|
+
};
|
|
222
|
+
export type PluginSettingsField = {
|
|
223
|
+
key: string;
|
|
224
|
+
type: string;
|
|
225
|
+
label: string;
|
|
226
|
+
scope: string;
|
|
227
|
+
default?: unknown;
|
|
228
|
+
secret_ref?: string;
|
|
229
|
+
options?: string[];
|
|
230
|
+
validation?: Record<string, unknown>;
|
|
231
|
+
};
|
|
232
|
+
export type PluginSettingsSchema = {
|
|
233
|
+
plugin_instance_id: string;
|
|
234
|
+
schema_version: number;
|
|
235
|
+
migration?: Record<string, unknown>;
|
|
236
|
+
fields: PluginSettingsField[];
|
|
237
|
+
settings_revision: number;
|
|
238
|
+
};
|
|
239
|
+
export type PluginSettingsSnapshot = {
|
|
240
|
+
plugin_instance_id: string;
|
|
241
|
+
schema_version: number;
|
|
242
|
+
settings_revision: number;
|
|
243
|
+
values: Record<string, unknown>;
|
|
244
|
+
updated_at: string;
|
|
245
|
+
};
|
|
246
|
+
export type PluginOperationRecord = {
|
|
247
|
+
operation_id: string;
|
|
248
|
+
plugin_id?: string;
|
|
249
|
+
plugin_instance_id: string;
|
|
250
|
+
method: string;
|
|
251
|
+
effect?: string;
|
|
252
|
+
execution: string;
|
|
253
|
+
surface_instance_id?: string;
|
|
254
|
+
session_channel_id_hash?: string;
|
|
255
|
+
bridge_channel_id?: string;
|
|
256
|
+
status: string;
|
|
257
|
+
disable_behavior?: string;
|
|
258
|
+
uninstall_behavior?: string;
|
|
259
|
+
reason?: string;
|
|
260
|
+
created_at: string;
|
|
261
|
+
updated_at: string;
|
|
262
|
+
cancel_requested_at?: string;
|
|
263
|
+
orphaned_at?: string;
|
|
264
|
+
};
|
|
265
|
+
export type PluginOperationList = {
|
|
266
|
+
operations?: PluginOperationRecord[];
|
|
267
|
+
[key: string]: unknown;
|
|
268
|
+
};
|
|
269
|
+
export type PluginIntentRecord = {
|
|
270
|
+
plugin_id: string;
|
|
271
|
+
plugin_instance_id: string;
|
|
272
|
+
publisher_id: string;
|
|
273
|
+
display_name: string;
|
|
274
|
+
version: string;
|
|
275
|
+
active_fingerprint: string;
|
|
276
|
+
intent_id: string;
|
|
277
|
+
method: string;
|
|
278
|
+
effect: string;
|
|
279
|
+
execution: string;
|
|
280
|
+
payload_schema?: Record<string, unknown>;
|
|
281
|
+
};
|
|
282
|
+
export type PluginIntentList = {
|
|
283
|
+
intents?: PluginIntentRecord[];
|
|
284
|
+
[key: string]: unknown;
|
|
285
|
+
};
|
|
286
|
+
export type PluginIntentListOptions = {
|
|
287
|
+
intent_id?: string;
|
|
288
|
+
plugin_instance_id?: string;
|
|
289
|
+
};
|
|
290
|
+
export type PluginIntentInvokeRequest = {
|
|
291
|
+
plugin_instance_id?: string;
|
|
292
|
+
intent_id: string;
|
|
293
|
+
params?: Record<string, unknown>;
|
|
294
|
+
};
|
|
295
|
+
export type PluginPermissionGrant = {
|
|
296
|
+
plugin_instance_id: string;
|
|
297
|
+
permission_id: string;
|
|
298
|
+
granted_by?: string;
|
|
299
|
+
granted_at?: string;
|
|
300
|
+
revoked_by?: string;
|
|
301
|
+
revoked_at?: string;
|
|
302
|
+
reason?: string;
|
|
303
|
+
expires_at?: string;
|
|
304
|
+
[key: string]: unknown;
|
|
305
|
+
};
|
|
306
|
+
export type PluginPermissionList = {
|
|
307
|
+
permissions?: PluginPermissionGrant[];
|
|
308
|
+
[key: string]: unknown;
|
|
309
|
+
};
|
|
310
|
+
export type PluginPermissionGrantRequest = {
|
|
311
|
+
plugin_instance_id: string;
|
|
312
|
+
permission_id: string;
|
|
313
|
+
granted_by?: string;
|
|
314
|
+
expires_at?: string;
|
|
315
|
+
};
|
|
316
|
+
export type PluginPermissionRevokeRequest = {
|
|
317
|
+
plugin_instance_id: string;
|
|
318
|
+
permission_id: string;
|
|
319
|
+
revoked_by?: string;
|
|
320
|
+
reason?: string;
|
|
321
|
+
};
|
|
322
|
+
export type PluginDataExportRequest = {
|
|
323
|
+
plugin_instance_id: string;
|
|
324
|
+
include_secrets?: boolean;
|
|
325
|
+
};
|
|
326
|
+
export type PluginDataExportResult = {
|
|
327
|
+
archive_ref?: string;
|
|
328
|
+
settings_archive_ref?: string;
|
|
329
|
+
};
|
|
330
|
+
export type PluginDataImportRequest = {
|
|
331
|
+
plugin_instance_id: string;
|
|
332
|
+
archive_ref?: string;
|
|
333
|
+
settings_archive_ref?: string;
|
|
334
|
+
delete_existing?: boolean;
|
|
335
|
+
};
|
|
336
|
+
export type PluginRetainedDataRecord = {
|
|
337
|
+
retained_id: string;
|
|
338
|
+
source_plugin_instance_id: string;
|
|
339
|
+
bound_plugin_instance_id?: string;
|
|
340
|
+
publisher_id: string;
|
|
341
|
+
plugin_id: string;
|
|
342
|
+
version: string;
|
|
343
|
+
package_hash: string;
|
|
344
|
+
manifest_hash: string;
|
|
345
|
+
state: PluginRetainedDataRecordState | string;
|
|
346
|
+
storage_retained?: boolean;
|
|
347
|
+
settings_retained?: boolean;
|
|
348
|
+
usage_bytes?: number;
|
|
349
|
+
delete_after?: string;
|
|
350
|
+
delete_error?: string;
|
|
351
|
+
metadata?: Record<string, string>;
|
|
352
|
+
retained_at?: string;
|
|
353
|
+
updated_at?: string;
|
|
354
|
+
bound_at?: string;
|
|
355
|
+
deleted_at?: string;
|
|
356
|
+
last_accessed_at?: string;
|
|
357
|
+
[key: string]: unknown;
|
|
358
|
+
};
|
|
359
|
+
export type PluginRetainedDataListOptions = {
|
|
360
|
+
publisher_id?: string;
|
|
361
|
+
plugin_id?: string;
|
|
362
|
+
source_plugin_instance_id?: string;
|
|
363
|
+
state?: PluginRetainedDataRecordState | string;
|
|
364
|
+
};
|
|
365
|
+
export type PluginRetainedDataList = {
|
|
366
|
+
retained_data?: PluginRetainedDataRecord[];
|
|
367
|
+
[key: string]: unknown;
|
|
368
|
+
};
|
|
369
|
+
export type PluginRetainedDataBindRequest = {
|
|
370
|
+
retained_id: string;
|
|
371
|
+
target_plugin_instance_id: string;
|
|
372
|
+
};
|
|
373
|
+
export type PluginRetainedDataCleanupRequest = {
|
|
374
|
+
retry_failed?: boolean;
|
|
375
|
+
max_records?: number;
|
|
376
|
+
};
|
|
377
|
+
export type PluginRetainedDataCleanupResult = {
|
|
378
|
+
deleted?: PluginRetainedDataRecord[];
|
|
379
|
+
failed?: PluginRetainedDataRecord[];
|
|
380
|
+
[key: string]: unknown;
|
|
381
|
+
};
|
|
382
|
+
export type PluginSecretRefRequest = {
|
|
383
|
+
plugin_instance_id: string;
|
|
384
|
+
secret_ref: string;
|
|
385
|
+
scope: string;
|
|
386
|
+
};
|
|
387
|
+
export type PluginAuditEvent = {
|
|
388
|
+
type: string;
|
|
389
|
+
plugin_id?: string;
|
|
390
|
+
plugin_instance_id?: string;
|
|
391
|
+
occurred_at?: string;
|
|
392
|
+
details?: Record<string, unknown>;
|
|
393
|
+
[key: string]: unknown;
|
|
394
|
+
};
|
|
395
|
+
export type PluginAuditEventList = {
|
|
396
|
+
audit_events?: PluginAuditEvent[];
|
|
397
|
+
[key: string]: unknown;
|
|
398
|
+
};
|
|
399
|
+
export type PluginAuditListOptions = {
|
|
400
|
+
plugin_id?: string;
|
|
401
|
+
plugin_instance_id?: string;
|
|
402
|
+
type?: string;
|
|
403
|
+
limit?: number;
|
|
404
|
+
};
|
|
405
|
+
export type PluginDiagnosticEvent = {
|
|
406
|
+
type: string;
|
|
407
|
+
severity?: string;
|
|
408
|
+
plugin_id?: string;
|
|
409
|
+
plugin_instance_id?: string;
|
|
410
|
+
surface_instance_id?: string;
|
|
411
|
+
occurred_at?: string;
|
|
412
|
+
details?: Record<string, unknown>;
|
|
413
|
+
[key: string]: unknown;
|
|
414
|
+
};
|
|
415
|
+
export type PluginDiagnosticEventList = {
|
|
416
|
+
diagnostic_events?: PluginDiagnosticEvent[];
|
|
417
|
+
[key: string]: unknown;
|
|
418
|
+
};
|
|
419
|
+
export type PluginDiagnosticListOptions = {
|
|
420
|
+
plugin_id?: string;
|
|
421
|
+
plugin_instance_id?: string;
|
|
422
|
+
surface_instance_id?: string;
|
|
423
|
+
type?: string;
|
|
424
|
+
severity?: string;
|
|
425
|
+
limit?: number;
|
|
426
|
+
};
|
|
427
|
+
export declare class PluginPlatformClient {
|
|
428
|
+
#private;
|
|
429
|
+
constructor(options?: PluginPlatformClientOptions);
|
|
430
|
+
catalog(): Promise<PluginCatalogResult>;
|
|
431
|
+
getCompatibility(): Promise<PluginCompatibilityManifest>;
|
|
432
|
+
installReleaseRef(request: PluginInstallReleaseRefRequest): Promise<PluginRecord>;
|
|
433
|
+
updateReleaseRef(request: PluginUpdateReleaseRefRequest): Promise<PluginRecord>;
|
|
434
|
+
downgradePlugin(request: PluginDowngradeRequest): Promise<PluginRecord>;
|
|
435
|
+
enablePlugin(request: PluginEnableRequest): Promise<PluginRecord>;
|
|
436
|
+
disablePlugin(request: PluginDisableRequest): Promise<PluginRecord>;
|
|
437
|
+
uninstallPlugin(request: PluginUninstallRequest): Promise<PluginRecord>;
|
|
438
|
+
openSurface(request: PluginOpenSurfaceRequest): Promise<PluginSurfaceBootstrapResult>;
|
|
439
|
+
revokeSurfaceScope(): Promise<PluginSurfaceScopeRevokeResult>;
|
|
440
|
+
startRuntime(request?: PluginRuntimeStartRequest): Promise<PluginRuntimeHealth>;
|
|
441
|
+
stopRuntime(): Promise<PluginRuntimeStopResult>;
|
|
442
|
+
refreshEnabledRuntimeState(): Promise<PluginRuntimeRefreshResult>;
|
|
443
|
+
runtimeHealth(): Promise<PluginRuntimeHealth>;
|
|
444
|
+
getSettingsSchema(pluginInstanceId: string): Promise<PluginSettingsSchema>;
|
|
445
|
+
getSettings(pluginInstanceId: string): Promise<PluginSettingsSnapshot>;
|
|
446
|
+
patchSettings(pluginInstanceId: string, values: Record<string, unknown>): Promise<PluginSettingsSnapshot>;
|
|
447
|
+
listOperations(pluginInstanceId?: string): Promise<PluginOperationList>;
|
|
448
|
+
getOperation(operationId: string): Promise<PluginOperationRecord>;
|
|
449
|
+
cancelOperation(operationId: string, reason?: string): Promise<PluginOperationRecord>;
|
|
450
|
+
listIntents(options?: PluginIntentListOptions): Promise<PluginIntentList>;
|
|
451
|
+
invokeIntent<T = unknown>(request: PluginIntentInvokeRequest): Promise<PluginTrustedMethodResult<T>>;
|
|
452
|
+
exportData(request: PluginDataExportRequest): Promise<PluginDataExportResult>;
|
|
453
|
+
importData(request: PluginDataImportRequest): Promise<Record<string, unknown>>;
|
|
454
|
+
listRetainedData(options?: PluginRetainedDataListOptions): Promise<PluginRetainedDataList>;
|
|
455
|
+
deleteRetainedData(retainedId: string): Promise<PluginRetainedDataRecord>;
|
|
456
|
+
bindRetainedData(request: PluginRetainedDataBindRequest): Promise<PluginRetainedDataRecord>;
|
|
457
|
+
cleanupExpiredRetainedData(request?: PluginRetainedDataCleanupRequest): Promise<PluginRetainedDataCleanupResult>;
|
|
458
|
+
listPermissions(pluginInstanceId?: string, activeOnly?: boolean): Promise<PluginPermissionList>;
|
|
459
|
+
grantPermission(request: PluginPermissionGrantRequest): Promise<PluginPermissionGrant>;
|
|
460
|
+
revokePermission(request: PluginPermissionRevokeRequest): Promise<PluginPermissionGrant>;
|
|
461
|
+
bindSecret(request: PluginSecretRefRequest): Promise<Record<string, unknown>>;
|
|
462
|
+
testSecret(request: PluginSecretRefRequest): Promise<Record<string, unknown>>;
|
|
463
|
+
deleteSecret(request: PluginSecretRefRequest): Promise<Record<string, unknown>>;
|
|
464
|
+
listAuditEvents(options?: PluginAuditListOptions): Promise<PluginAuditEventList>;
|
|
465
|
+
listDiagnosticEvents(options?: PluginDiagnosticListOptions): Promise<PluginDiagnosticEventList>;
|
|
466
|
+
}
|
package/dist/platform.js
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { defaultFetch, readHostEnvelope, trimTrailingSlash } from "./http.js";
|
|
2
|
+
import { defaultPluginSurfaceScope, disposePluginSurfaceScope, } from "./surface-scope.js";
|
|
3
|
+
export function toPluginSurfaceHostBootstrap(value) {
|
|
4
|
+
return {
|
|
5
|
+
pluginId: value.plugin_id,
|
|
6
|
+
pluginInstanceId: value.plugin_instance_id,
|
|
7
|
+
pluginVersion: value.plugin_version,
|
|
8
|
+
surfaceId: value.surface_id,
|
|
9
|
+
surfaceInstanceId: value.surface_instance_id,
|
|
10
|
+
activeFingerprint: value.active_fingerprint,
|
|
11
|
+
bridgeNonce: value.bridge_nonce,
|
|
12
|
+
entryPath: value.entry_path,
|
|
13
|
+
entrySHA256: value.entry_sha256,
|
|
14
|
+
assetTicket: value.asset_ticket,
|
|
15
|
+
assetSessionNonce: value.asset_session_nonce,
|
|
16
|
+
pluginStateVersion: value.plugin_state_version,
|
|
17
|
+
revokeEpoch: value.revoke_epoch,
|
|
18
|
+
runtimeGenerationId: value.runtime_generation_id,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
export class PluginPlatformClient {
|
|
22
|
+
#fetch;
|
|
23
|
+
#apiBaseURL;
|
|
24
|
+
#surfaceScope;
|
|
25
|
+
constructor(options = {}) {
|
|
26
|
+
this.#fetch = options.fetch ?? defaultFetch();
|
|
27
|
+
this.#apiBaseURL = trimTrailingSlash(options.apiBaseURL ?? "");
|
|
28
|
+
this.#surfaceScope = options.surfaceScope ?? defaultPluginSurfaceScope;
|
|
29
|
+
}
|
|
30
|
+
catalog() { return this.#getJSON("/_redevplugin/api/plugins/catalog"); }
|
|
31
|
+
getCompatibility() { return this.#getJSON("/_redevplugin/api/plugins/platform/compatibility"); }
|
|
32
|
+
installReleaseRef(request) { return this.#postJSON("/_redevplugin/api/plugins/install-release-ref", request); }
|
|
33
|
+
updateReleaseRef(request) { return this.#mutatePlugin("/_redevplugin/api/plugins/update-release-ref", request); }
|
|
34
|
+
downgradePlugin(request) { return this.#mutatePlugin("/_redevplugin/api/plugins/downgrade", request); }
|
|
35
|
+
enablePlugin(request) { return this.#postJSON("/_redevplugin/api/plugins/enable", request); }
|
|
36
|
+
disablePlugin(request) { return this.#mutatePlugin("/_redevplugin/api/plugins/disable", request); }
|
|
37
|
+
uninstallPlugin(request) { return this.#mutatePlugin("/_redevplugin/api/plugins/uninstall", request); }
|
|
38
|
+
openSurface(request) { return this.#postJSON("/_redevplugin/api/plugins/surfaces/open", request); }
|
|
39
|
+
async revokeSurfaceScope() {
|
|
40
|
+
try {
|
|
41
|
+
return await this.#postJSON("/_redevplugin/api/plugins/surfaces/revoke-scope", {});
|
|
42
|
+
}
|
|
43
|
+
finally {
|
|
44
|
+
disposePluginSurfaceScope(this.#surfaceScope);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
startRuntime(request = {}) { return this.#postJSON("/_redevplugin/api/plugins/runtime/start", request); }
|
|
48
|
+
async stopRuntime() {
|
|
49
|
+
try {
|
|
50
|
+
return await this.#postJSON("/_redevplugin/api/plugins/runtime/stop", {});
|
|
51
|
+
}
|
|
52
|
+
finally {
|
|
53
|
+
disposePluginSurfaceScope(this.#surfaceScope);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
refreshEnabledRuntimeState() { return this.#postJSON("/_redevplugin/api/plugins/runtime/refresh-enabled", {}); }
|
|
57
|
+
runtimeHealth() { return this.#getJSON("/_redevplugin/api/plugins/runtime/health"); }
|
|
58
|
+
getSettingsSchema(pluginInstanceId) { return this.#getJSON(`/_redevplugin/api/plugins/${encodeURIComponent(pluginInstanceId)}/settings/schema`); }
|
|
59
|
+
getSettings(pluginInstanceId) { return this.#getJSON(`/_redevplugin/api/plugins/${encodeURIComponent(pluginInstanceId)}/settings`); }
|
|
60
|
+
patchSettings(pluginInstanceId, values) { return this.#patchJSON(`/_redevplugin/api/plugins/${encodeURIComponent(pluginInstanceId)}/settings`, { values }); }
|
|
61
|
+
listOperations(pluginInstanceId) { return this.#getJSON(`/_redevplugin/api/plugins/operations${pluginInstanceId ? `?plugin_instance_id=${encodeURIComponent(pluginInstanceId)}` : ""}`); }
|
|
62
|
+
getOperation(operationId) { return this.#getJSON(`/_redevplugin/api/plugins/operations/${encodeURIComponent(operationId)}`); }
|
|
63
|
+
cancelOperation(operationId, reason) { return this.#postJSON(`/_redevplugin/api/plugins/operations/${encodeURIComponent(operationId)}/cancel`, reason ? { reason } : {}); }
|
|
64
|
+
listIntents(options = {}) {
|
|
65
|
+
const params = new URLSearchParams();
|
|
66
|
+
if (options.intent_id)
|
|
67
|
+
params.set("intent_id", options.intent_id);
|
|
68
|
+
if (options.plugin_instance_id)
|
|
69
|
+
params.set("plugin_instance_id", options.plugin_instance_id);
|
|
70
|
+
const query = params.toString();
|
|
71
|
+
return this.#getJSON(`/_redevplugin/api/plugins/intents${query ? `?${query}` : ""}`);
|
|
72
|
+
}
|
|
73
|
+
invokeIntent(request) {
|
|
74
|
+
return this.#postJSON("/_redevplugin/api/plugins/intents/invoke", request);
|
|
75
|
+
}
|
|
76
|
+
exportData(request) { return this.#postJSON("/_redevplugin/api/plugins/data/export", request); }
|
|
77
|
+
importData(request) { return this.#postJSON("/_redevplugin/api/plugins/data/import", request); }
|
|
78
|
+
listRetainedData(options = {}) {
|
|
79
|
+
const params = new URLSearchParams();
|
|
80
|
+
if (options.publisher_id)
|
|
81
|
+
params.set("publisher_id", options.publisher_id);
|
|
82
|
+
if (options.plugin_id)
|
|
83
|
+
params.set("plugin_id", options.plugin_id);
|
|
84
|
+
if (options.source_plugin_instance_id)
|
|
85
|
+
params.set("source_plugin_instance_id", options.source_plugin_instance_id);
|
|
86
|
+
if (options.state)
|
|
87
|
+
params.set("state", options.state);
|
|
88
|
+
const query = params.toString();
|
|
89
|
+
return this.#getJSON(`/_redevplugin/api/plugins/retained-data${query ? `?${query}` : ""}`);
|
|
90
|
+
}
|
|
91
|
+
deleteRetainedData(retainedId) { return this.#postJSON("/_redevplugin/api/plugins/retained-data/delete", { retained_id: retainedId }); }
|
|
92
|
+
bindRetainedData(request) { return this.#postJSON("/_redevplugin/api/plugins/retained-data/bind", request); }
|
|
93
|
+
cleanupExpiredRetainedData(request = {}) { return this.#postJSON("/_redevplugin/api/plugins/retained-data/cleanup-expired", request); }
|
|
94
|
+
listPermissions(pluginInstanceId, activeOnly) {
|
|
95
|
+
const params = new URLSearchParams();
|
|
96
|
+
if (pluginInstanceId)
|
|
97
|
+
params.set("plugin_instance_id", pluginInstanceId);
|
|
98
|
+
if (activeOnly != null)
|
|
99
|
+
params.set("active_only", activeOnly ? "true" : "false");
|
|
100
|
+
const query = params.toString();
|
|
101
|
+
return this.#getJSON(`/_redevplugin/api/plugins/permissions${query ? `?${query}` : ""}`);
|
|
102
|
+
}
|
|
103
|
+
grantPermission(request) { return this.#postJSON("/_redevplugin/api/plugins/permissions/grant", request); }
|
|
104
|
+
revokePermission(request) { return this.#postJSON("/_redevplugin/api/plugins/permissions/revoke", request); }
|
|
105
|
+
bindSecret(request) { return this.#postJSON("/_redevplugin/api/plugins/secrets/bind", request); }
|
|
106
|
+
testSecret(request) { return this.#postJSON("/_redevplugin/api/plugins/secrets/test", request); }
|
|
107
|
+
deleteSecret(request) { return this.#postJSON("/_redevplugin/api/plugins/secrets/delete", request); }
|
|
108
|
+
listAuditEvents(options = {}) { return this.#getJSON(`/_redevplugin/api/plugins/audit${queryString(options)}`); }
|
|
109
|
+
listDiagnosticEvents(options = {}) { return this.#getJSON(`/_redevplugin/api/plugins/diagnostics${queryString(options)}`); }
|
|
110
|
+
#getJSON(path) { return this.#requestJSON("GET", path); }
|
|
111
|
+
#postJSON(path, body) { return this.#requestJSON("POST", path, body); }
|
|
112
|
+
#patchJSON(path, body) { return this.#requestJSON("PATCH", path, body); }
|
|
113
|
+
async #mutatePlugin(path, request) {
|
|
114
|
+
try {
|
|
115
|
+
return await this.#postJSON(path, request);
|
|
116
|
+
}
|
|
117
|
+
finally {
|
|
118
|
+
disposePluginSurfaceScope(this.#surfaceScope, request.plugin_instance_id);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
async #requestJSON(method, path, body) {
|
|
122
|
+
const headers = { "Accept": "application/json" };
|
|
123
|
+
if (body !== undefined)
|
|
124
|
+
headers["Content-Type"] = "application/json";
|
|
125
|
+
const response = await this.#fetch(this.#apiBaseURL + path, {
|
|
126
|
+
method,
|
|
127
|
+
headers,
|
|
128
|
+
body: body === undefined ? undefined : JSON.stringify(body),
|
|
129
|
+
credentials: "same-origin",
|
|
130
|
+
});
|
|
131
|
+
return readHostEnvelope(response, "PLUGIN_PLATFORM_REQUEST_FAILED");
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
function queryString(values) {
|
|
135
|
+
const params = new URLSearchParams();
|
|
136
|
+
for (const [key, value] of Object.entries(values)) {
|
|
137
|
+
if (value != null && value !== "")
|
|
138
|
+
params.set(key, String(value));
|
|
139
|
+
}
|
|
140
|
+
const query = params.toString();
|
|
141
|
+
return query ? `?${query}` : "";
|
|
142
|
+
}
|
package/dist/plugin.d.ts
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { PluginBridgeClient } from "./surface.js";
|
|
2
|
+
export type { BridgeLifecycleEvent, MessagePortLike, PluginBridgeClientOptions, PluginJSONObject, PluginJSONValue, PluginMethodResult, PluginStreamEvent, PluginUIActionEvent, PluginUIAttributeValue, PluginUIVNode, } from "./surface.js";
|
package/dist/plugin.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { PluginBridgeClient } from "./surface.js";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare class PluginSurfaceScope {
|
|
2
|
+
private constructor();
|
|
3
|
+
static create(): PluginSurfaceScope;
|
|
4
|
+
}
|
|
5
|
+
export declare function createPluginSurfaceScope(): PluginSurfaceScope;
|
|
6
|
+
export declare const defaultPluginSurfaceScope: PluginSurfaceScope;
|
|
7
|
+
export declare function registerPluginSurface(scope: PluginSurfaceScope, pluginInstanceId: string, dispose: () => void): () => void;
|
|
8
|
+
export declare function disposePluginSurfaceScope(scope: PluginSurfaceScope, pluginInstanceId?: string): void;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
const registrations = new WeakMap();
|
|
2
|
+
export class PluginSurfaceScope {
|
|
3
|
+
constructor() {
|
|
4
|
+
registrations.set(this, new Map());
|
|
5
|
+
}
|
|
6
|
+
static create() {
|
|
7
|
+
return new PluginSurfaceScope();
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
export function createPluginSurfaceScope() {
|
|
11
|
+
return PluginSurfaceScope.create();
|
|
12
|
+
}
|
|
13
|
+
export const defaultPluginSurfaceScope = createPluginSurfaceScope();
|
|
14
|
+
export function registerPluginSurface(scope, pluginInstanceId, dispose) {
|
|
15
|
+
const state = registrations.get(scope);
|
|
16
|
+
if (!state)
|
|
17
|
+
throw new TypeError("Plugin surface scope is invalid");
|
|
18
|
+
const registration = Symbol(pluginInstanceId);
|
|
19
|
+
state.set(registration, { pluginInstanceId, dispose });
|
|
20
|
+
return () => state.delete(registration);
|
|
21
|
+
}
|
|
22
|
+
export function disposePluginSurfaceScope(scope, pluginInstanceId) {
|
|
23
|
+
const state = registrations.get(scope);
|
|
24
|
+
if (!state)
|
|
25
|
+
throw new TypeError("Plugin surface scope is invalid");
|
|
26
|
+
const selected = [...state.entries()].filter(([, registration]) => pluginInstanceId === undefined || registration.pluginInstanceId === pluginInstanceId);
|
|
27
|
+
for (const [key] of selected)
|
|
28
|
+
state.delete(key);
|
|
29
|
+
for (const [, registration] of selected)
|
|
30
|
+
registration.dispose();
|
|
31
|
+
}
|