@archont561/qgis-sdk-bridge 0.1.1 → 0.2.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/README.md +35 -23
- package/dist/bridge.d.ts +205 -0
- package/dist/bridge.js +32 -0
- package/dist/host.d.ts +157 -0
- package/dist/host.js +433 -0
- package/dist/index.d.ts +22 -1
- package/dist/index.js +28 -160
- package/dist/react.d.ts +217 -0
- package/dist/react.js +196 -0
- package/dist/shared/chunk-0fknax6w.js +207 -0
- package/dist/shared/chunk-a7bjgeve.js +422 -0
- package/dist/testing.d.ts +109 -0
- package/dist/testing.js +323 -0
- package/package.json +29 -1
package/README.md
CHANGED
|
@@ -1,42 +1,54 @@
|
|
|
1
1
|
# @archont561/qgis-sdk-bridge
|
|
2
2
|
|
|
3
|
-
**TypeScript
|
|
3
|
+
**TypeScript client for QGIS plugin interfaces hosted in `QWebEngineView`.**
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
The companion to [`qgis-sdk`](https://pypi.org/project/qgis-sdk/): a correlated
|
|
6
|
+
transport client with subscriptions, the curated host namespaces, and the
|
|
7
|
+
contract a generated per-plugin client is built on. Every exported error begins
|
|
8
|
+
with `QgisSdk` and carries a stable wire `code`.
|
|
6
9
|
|
|
7
|
-
>
|
|
10
|
+
> Experimental. `0.1.1` on npm carries the description parser, the safe-integer
|
|
11
|
+
> wire bounds and the error hierarchy; `0.2.0`, which ships with the Python
|
|
12
|
+
> `0.3.0` milestone, adds `./bridge`, `./host`, the generated clients shown
|
|
13
|
+
> below, the optional `./react` bindings and the `./testing` harness.
|
|
8
14
|
|
|
9
15
|
## Installation
|
|
10
16
|
|
|
11
|
-
Install from [npm](https://www.npmjs.com/package/@archont561/qgis-sdk-bridge) or [GitHub Packages](https://github.com/Archont561/qgis-sdk/pkgs/npm/qgis-sdk-bridge):
|
|
12
|
-
|
|
13
17
|
```sh
|
|
14
18
|
bun add @archont561/qgis-sdk-bridge
|
|
15
|
-
# or with npm:
|
|
16
19
|
npm install @archont561/qgis-sdk-bridge
|
|
17
20
|
```
|
|
18
21
|
|
|
19
|
-
##
|
|
22
|
+
## Example
|
|
20
23
|
|
|
21
24
|
```ts
|
|
22
|
-
import {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
25
|
+
import { BridgeClient } from "@archont561/qgis-sdk-bridge/bridge";
|
|
26
|
+
import { createHost } from "@archont561/qgis-sdk-bridge/host";
|
|
27
|
+
|
|
28
|
+
const client = new BridgeClient({
|
|
29
|
+
send: (message) => channel.send(JSON.stringify(message)),
|
|
30
|
+
subscribe: (listener) => {
|
|
31
|
+
channel.onmessage = (text: string) => listener(JSON.parse(text));
|
|
32
|
+
return () => {
|
|
33
|
+
channel.onmessage = null;
|
|
34
|
+
};
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
const host = createHost(client);
|
|
39
|
+
const page = await host.layers.list({ limit: 20 });
|
|
35
40
|
```
|
|
36
41
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
42
|
+
A plugin's own operations come from the client `qgis-sdk bridge generate`
|
|
43
|
+
renders from its Python declarations.
|
|
44
|
+
|
|
45
|
+
## Documentation
|
|
46
|
+
|
|
47
|
+
- [TypeScript bridge guide](https://github.com/Archont561/qgis-sdk/blob/main/backlog/docs/guides/doc-13%20-%20qgis-sdk-bridge-TypeScript-package-guide.md) -
|
|
48
|
+
exports, the transport client, host namespaces, generated clients, streams,
|
|
49
|
+
the React bindings and testing against a scripted host.
|
|
50
|
+
- [Python package guide](https://github.com/Archont561/qgis-sdk/blob/main/backlog/docs/guides/doc-12%20-%20qgis-sdk-Python-package-guide.md) -
|
|
51
|
+
the host half of every surface above.
|
|
40
52
|
|
|
41
53
|
## License
|
|
42
54
|
|
package/dist/bridge.d.ts
ADDED
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base class for expected SDK errors across the bridge boundary.
|
|
3
|
+
*/
|
|
4
|
+
declare class QgisSdkError extends Error {
|
|
5
|
+
readonly code: string;
|
|
6
|
+
constructor(message: string, code?: string);
|
|
7
|
+
}
|
|
8
|
+
declare const BRIDGE_PROTOCOL_VERSION: 1;
|
|
9
|
+
declare const MAX_CALL_ID_LENGTH: number;
|
|
10
|
+
/** A failure reply, as the host serialized it. */
|
|
11
|
+
interface BridgeFailure {
|
|
12
|
+
readonly code: string;
|
|
13
|
+
readonly message: string;
|
|
14
|
+
}
|
|
15
|
+
/** A reply to one invocation: exactly one of `value` or `error` is present. */
|
|
16
|
+
type InvokeReply = {
|
|
17
|
+
readonly protocol: 1;
|
|
18
|
+
readonly call_id: string;
|
|
19
|
+
readonly ok: true;
|
|
20
|
+
readonly value: unknown;
|
|
21
|
+
} | {
|
|
22
|
+
readonly protocol: 1;
|
|
23
|
+
readonly call_id: string;
|
|
24
|
+
readonly ok: false;
|
|
25
|
+
readonly error: BridgeFailure;
|
|
26
|
+
};
|
|
27
|
+
/** The kinds of event a stream may carry; only `progress` may be coalesced. */
|
|
28
|
+
type StreamEventKind2 = "data" | "progress" | "state";
|
|
29
|
+
/** Why a subscription stopped. */
|
|
30
|
+
type StreamTerminalKind = "complete" | "error" | "cancelled" | "gap" | "disposed";
|
|
31
|
+
/** One event on a subscription. */
|
|
32
|
+
interface BridgeStreamEvent {
|
|
33
|
+
readonly kind: StreamEventKind2;
|
|
34
|
+
readonly payload: unknown;
|
|
35
|
+
}
|
|
36
|
+
/** The end of a subscription, as the host described it. */
|
|
37
|
+
interface BridgeStreamTerminal {
|
|
38
|
+
readonly kind: StreamTerminalKind;
|
|
39
|
+
readonly message?: string;
|
|
40
|
+
readonly dropped?: number;
|
|
41
|
+
}
|
|
42
|
+
/** A frame carrying one event. */
|
|
43
|
+
interface BridgeEventFrame {
|
|
44
|
+
readonly protocol: 1;
|
|
45
|
+
readonly subscription_id: string;
|
|
46
|
+
readonly seq: number;
|
|
47
|
+
readonly event: BridgeStreamEvent;
|
|
48
|
+
}
|
|
49
|
+
/** The frame that ends a subscription. */
|
|
50
|
+
interface BridgeTerminalFrame {
|
|
51
|
+
readonly protocol: 1;
|
|
52
|
+
readonly subscription_id: string;
|
|
53
|
+
readonly seq: number;
|
|
54
|
+
readonly terminal: BridgeStreamTerminal;
|
|
55
|
+
}
|
|
56
|
+
/** Anything the host may send for a subscription. */
|
|
57
|
+
type BridgeStreamFrame = BridgeEventFrame | BridgeTerminalFrame;
|
|
58
|
+
/** The transport a client speaks through; a QWebChannel adapter or a script. */
|
|
59
|
+
interface WireTransport {
|
|
60
|
+
send(message: unknown): void;
|
|
61
|
+
subscribe(listener: (message: unknown) => void): () => void;
|
|
62
|
+
}
|
|
63
|
+
/** Options for {@link BridgeClient}. */
|
|
64
|
+
interface BridgeClientOptions {
|
|
65
|
+
readonly timeoutMs?: number;
|
|
66
|
+
}
|
|
67
|
+
/** Options for one invocation. */
|
|
68
|
+
interface InvokeOptions {
|
|
69
|
+
readonly signal?: AbortSignal;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* An envelope or reply does not match the versioned bridge protocol.
|
|
73
|
+
*/
|
|
74
|
+
declare class QgisSdkBridgeProtocolError extends QgisSdkError {
|
|
75
|
+
constructor(message: string);
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* The host did not answer in time. The call may still have run, so this is an
|
|
79
|
+
* unknown outcome: retrying automatically is forbidden, deciding is the caller's.
|
|
80
|
+
*/
|
|
81
|
+
declare class QgisSdkBridgeTimeoutError extends QgisSdkError {
|
|
82
|
+
readonly callId: string;
|
|
83
|
+
constructor(callId: string, timeoutMs: number);
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* The caller aborted locally. Distinct from the host cancelling the operation,
|
|
87
|
+
* which arrives as a failure reply carrying the `cancelled` code.
|
|
88
|
+
*/
|
|
89
|
+
declare class QgisSdkBridgeAbortedError extends QgisSdkError {
|
|
90
|
+
readonly callId: string;
|
|
91
|
+
constructor(callId: string);
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* The client was closed, so pending calls can no longer be answered.
|
|
95
|
+
*/
|
|
96
|
+
declare class QgisSdkBridgeClosedError extends QgisSdkError {
|
|
97
|
+
constructor();
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* A subscription's frames were not the sequence the host promised.
|
|
101
|
+
*
|
|
102
|
+
* The client does not try to reassemble: a missed frame is a fact about the
|
|
103
|
+
* subscription, not something to paper over.
|
|
104
|
+
*/
|
|
105
|
+
declare class QgisSdkBridgeSequenceError extends QgisSdkError {
|
|
106
|
+
readonly subscriptionId: string;
|
|
107
|
+
readonly expected: number;
|
|
108
|
+
readonly received: number;
|
|
109
|
+
constructor(subscriptionId: string, expected: number, received: number);
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* The subscription ended with a terminal frame the caller may want to inspect.
|
|
113
|
+
*/
|
|
114
|
+
declare class QgisSdkBridgeStreamEndedError extends QgisSdkError {
|
|
115
|
+
readonly subscriptionId: string;
|
|
116
|
+
readonly terminal: BridgeStreamTerminal;
|
|
117
|
+
constructor(subscriptionId: string, terminal: BridgeStreamTerminal);
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* The host refused or failed the operation; `failure.code` is the contract.
|
|
121
|
+
*/
|
|
122
|
+
declare class QgisSdkBridgeRemoteError extends QgisSdkError {
|
|
123
|
+
readonly failure: BridgeFailure;
|
|
124
|
+
readonly callId: string;
|
|
125
|
+
constructor(callId: string, failure: BridgeFailure);
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Parse one reply, refusing anything the host could not legitimately have sent.
|
|
129
|
+
*/
|
|
130
|
+
declare function parseInvokeReply(raw: unknown): InvokeReply;
|
|
131
|
+
/**
|
|
132
|
+
* Parse one stream frame, refusing anything the host could not legitimately
|
|
133
|
+
* have sent.
|
|
134
|
+
*
|
|
135
|
+
* Exactly one of `event` and `terminal` has to be present: a frame that carries
|
|
136
|
+
* both leaves the client guessing which one wins, and a client that guesses is
|
|
137
|
+
* a client that will eventually deliver an event after the end of a stream.
|
|
138
|
+
*/
|
|
139
|
+
declare function parseStreamFrame(raw: unknown): BridgeStreamFrame;
|
|
140
|
+
/** Callbacks a subscription reports through. */
|
|
141
|
+
interface SubscriptionHandlers {
|
|
142
|
+
readonly onEvent?: (event: BridgeStreamEvent) => void;
|
|
143
|
+
readonly onTerminal?: (terminal: BridgeStreamTerminal) => void;
|
|
144
|
+
}
|
|
145
|
+
/** A live subscription, as the caller holds it. */
|
|
146
|
+
interface BridgeSubscription {
|
|
147
|
+
readonly id: string;
|
|
148
|
+
readonly closed: boolean;
|
|
149
|
+
close(): void;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Correlate invocations with replies over an injected transport.
|
|
153
|
+
*
|
|
154
|
+
* The client never retries: a timeout, an abort and a closed client are three
|
|
155
|
+
* different answers, and each is reported as itself.
|
|
156
|
+
*/
|
|
157
|
+
declare class BridgeClient {
|
|
158
|
+
private readonly transport;
|
|
159
|
+
private readonly timeoutMs;
|
|
160
|
+
private readonly pending;
|
|
161
|
+
private readonly subscriptions;
|
|
162
|
+
private readonly disposals;
|
|
163
|
+
private readonly unsubscribe;
|
|
164
|
+
private counter;
|
|
165
|
+
private closed;
|
|
166
|
+
private unmatched;
|
|
167
|
+
private breaks;
|
|
168
|
+
private lastProtocolError;
|
|
169
|
+
constructor(transport: WireTransport, options?: BridgeClientOptions);
|
|
170
|
+
/** Whether {@link close} has run; a closed client answers nothing. */
|
|
171
|
+
get isClosed(): boolean;
|
|
172
|
+
/** Replies that named no pending call: a late duplicate, or a stray message. */
|
|
173
|
+
get unmatchedReplies(): number;
|
|
174
|
+
/** Number of calls still waiting for a reply. */
|
|
175
|
+
get pendingCalls(): number;
|
|
176
|
+
/**
|
|
177
|
+
* Invoke one operation and settle with its value or with a typed failure.
|
|
178
|
+
*/
|
|
179
|
+
invoke(operation: string, payload?: Readonly<Record<string, unknown>>, options?: InvokeOptions): Promise<unknown>;
|
|
180
|
+
/**
|
|
181
|
+
* Open a subscription and resolve once the host has acknowledged it.
|
|
182
|
+
*
|
|
183
|
+
* Frames are matched to the subscription by id and by sequence; a frame that
|
|
184
|
+
* does not continue the sequence ends the subscription instead of being
|
|
185
|
+
* delivered out of order.
|
|
186
|
+
*/
|
|
187
|
+
subscribe(operation: string, payload?: Readonly<Record<string, unknown>>, handlers?: SubscriptionHandlers, options?: InvokeOptions): Promise<BridgeSubscription>;
|
|
188
|
+
/** Subscriptions still open; a leak check for callers and tests. */
|
|
189
|
+
get activeSubscriptions(): readonly string[];
|
|
190
|
+
/** Frames that did not continue their subscription's sequence. */
|
|
191
|
+
get sequenceBreaks(): number;
|
|
192
|
+
private send;
|
|
193
|
+
/**
|
|
194
|
+
* Refuse further calls, reject what is still pending, and stop listening.
|
|
195
|
+
*/
|
|
196
|
+
close(): void;
|
|
197
|
+
private settle;
|
|
198
|
+
private handle;
|
|
199
|
+
private handleFrame;
|
|
200
|
+
private endSubscription;
|
|
201
|
+
private disposeSubscription;
|
|
202
|
+
/** The last malformed message this client refused, if any. */
|
|
203
|
+
get protocolError(): Error | null;
|
|
204
|
+
}
|
|
205
|
+
export { BRIDGE_PROTOCOL_VERSION, BridgeClient, BridgeClientOptions, BridgeEventFrame, BridgeFailure, BridgeStreamEvent, BridgeStreamFrame, BridgeStreamTerminal, BridgeSubscription, BridgeTerminalFrame, InvokeOptions, InvokeReply, MAX_CALL_ID_LENGTH, QgisSdkBridgeAbortedError, QgisSdkBridgeClosedError, QgisSdkBridgeProtocolError, QgisSdkBridgeRemoteError, QgisSdkBridgeSequenceError, QgisSdkBridgeStreamEndedError, QgisSdkBridgeTimeoutError, StreamEventKind2 as StreamEventKind, StreamTerminalKind, SubscriptionHandlers, WireTransport, parseInvokeReply, parseStreamFrame };
|
package/dist/bridge.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BRIDGE_PROTOCOL_VERSION2,
|
|
3
|
+
MAX_CALL_ID_LENGTH2,
|
|
4
|
+
QgisSdkBridgeProtocolError2,
|
|
5
|
+
QgisSdkBridgeTimeoutError2,
|
|
6
|
+
QgisSdkBridgeAbortedError2,
|
|
7
|
+
QgisSdkBridgeClosedError2,
|
|
8
|
+
QgisSdkBridgeSequenceError2,
|
|
9
|
+
QgisSdkBridgeStreamEndedError2,
|
|
10
|
+
QgisSdkBridgeRemoteError2,
|
|
11
|
+
parseInvokeReply2,
|
|
12
|
+
parseStreamFrame2,
|
|
13
|
+
BridgeClient2
|
|
14
|
+
} from "./shared/chunk-a7bjgeve.js";
|
|
15
|
+
import"./shared/chunk-0fknax6w.js";
|
|
16
|
+
export {
|
|
17
|
+
BRIDGE_PROTOCOL_VERSION2 as BRIDGE_PROTOCOL_VERSION,
|
|
18
|
+
BridgeClient2 as BridgeClient,
|
|
19
|
+
MAX_CALL_ID_LENGTH2 as MAX_CALL_ID_LENGTH,
|
|
20
|
+
QgisSdkBridgeAbortedError2 as QgisSdkBridgeAbortedError,
|
|
21
|
+
QgisSdkBridgeClosedError2 as QgisSdkBridgeClosedError,
|
|
22
|
+
QgisSdkBridgeProtocolError2 as QgisSdkBridgeProtocolError,
|
|
23
|
+
QgisSdkBridgeRemoteError2 as QgisSdkBridgeRemoteError,
|
|
24
|
+
QgisSdkBridgeSequenceError2 as QgisSdkBridgeSequenceError,
|
|
25
|
+
QgisSdkBridgeStreamEndedError2 as QgisSdkBridgeStreamEndedError,
|
|
26
|
+
QgisSdkBridgeTimeoutError2 as QgisSdkBridgeTimeoutError,
|
|
27
|
+
parseInvokeReply2 as parseInvokeReply,
|
|
28
|
+
parseStreamFrame2 as parseStreamFrame
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
//# debugId=AD799C3C82BFFC4664756E2164756E21
|
|
32
|
+
//# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFtdLAogICJzb3VyY2VzQ29udGVudCI6IFsKICBdLAogICJtYXBwaW5ncyI6ICIiLAogICJkZWJ1Z0lkIjogIkFENzk5QzNDODJCRkZDNDY2NDc1NkUyMTY0NzU2RTIxIiwKICAibmFtZXMiOiBbXQp9
|
package/dist/host.d.ts
ADDED
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
declare const HOST_ID = "qgis.host";
|
|
2
|
+
declare const HOST_FINGERPRINT = "sha256:f96bdf1046434de3c5eae01efb34c8ad2bcd1cf241a3dc42f6c4b613dc7d7d6f";
|
|
3
|
+
declare const HOST_SCHEMA_VERSION = 1;
|
|
4
|
+
/** Every declared operation id, so a name can be checked, not guessed. */
|
|
5
|
+
declare const HOST_OPERATIONS: readonly ["files.export", "layers.get", "layers.list", "layers.open_vector", "network.fetch", "notifications.info", "project.layer_ids", "settings.get", "styles.apply"];
|
|
6
|
+
type HostOperationId = (typeof HOST_OPERATIONS)[number];
|
|
7
|
+
interface HostInvokeOptions {
|
|
8
|
+
readonly signal?: AbortSignal;
|
|
9
|
+
}
|
|
10
|
+
/** The client this module wraps: anything with a correlated invoke. */
|
|
11
|
+
interface HostClientLike {
|
|
12
|
+
invoke(operation: string, payload?: Readonly<Record<string, unknown>>, options?: HostInvokeOptions): Promise<unknown>;
|
|
13
|
+
subscribe(operation: string, payload?: Readonly<Record<string, unknown>>, handlers?: HostStreamHandlers<{
|
|
14
|
+
readonly kind: "data" | "progress" | "state";
|
|
15
|
+
readonly payload: unknown;
|
|
16
|
+
}>, options?: HostInvokeOptions): Promise<HostStreamHandle>;
|
|
17
|
+
}
|
|
18
|
+
/** How a stream ended; `dropped` is only present for a gap. */
|
|
19
|
+
interface HostStreamTerminal {
|
|
20
|
+
readonly kind: "complete" | "error" | "cancelled" | "gap" | "disposed";
|
|
21
|
+
readonly message?: string;
|
|
22
|
+
readonly dropped?: number;
|
|
23
|
+
}
|
|
24
|
+
/** What a stream reports: typed events, then exactly one end. */
|
|
25
|
+
interface HostStreamHandlers<E> {
|
|
26
|
+
readonly onEvent?: (event: E) => void;
|
|
27
|
+
readonly onTerminal?: (terminal: HostStreamTerminal) => void;
|
|
28
|
+
}
|
|
29
|
+
/** A live stream, as the caller holds it. */
|
|
30
|
+
interface HostStreamHandle {
|
|
31
|
+
readonly id: string;
|
|
32
|
+
readonly closed: boolean;
|
|
33
|
+
close(): void;
|
|
34
|
+
}
|
|
35
|
+
/** An argument or a response that does not match its declared schema. */
|
|
36
|
+
declare class HostContractError extends Error {
|
|
37
|
+
readonly operation: string;
|
|
38
|
+
constructor(operation: string, message: string);
|
|
39
|
+
}
|
|
40
|
+
interface ExportRequest {
|
|
41
|
+
readonly content: string;
|
|
42
|
+
readonly file: FileRef;
|
|
43
|
+
}
|
|
44
|
+
interface ExportResult {
|
|
45
|
+
readonly bytes_written: number;
|
|
46
|
+
readonly name: string;
|
|
47
|
+
}
|
|
48
|
+
interface FetchRequest {
|
|
49
|
+
readonly auth_config?: string;
|
|
50
|
+
readonly body?: string;
|
|
51
|
+
readonly headers?: readonly HttpHeader[];
|
|
52
|
+
readonly method?: "GET" | "HEAD" | "POST" | "PUT" | "PATCH" | "DELETE" | "OPTIONS";
|
|
53
|
+
readonly timeout_seconds?: number;
|
|
54
|
+
readonly url: string;
|
|
55
|
+
}
|
|
56
|
+
interface FileRef {
|
|
57
|
+
readonly id: string;
|
|
58
|
+
readonly kind: "file";
|
|
59
|
+
readonly name?: string;
|
|
60
|
+
readonly operations?: readonly ("read" | "write")[];
|
|
61
|
+
}
|
|
62
|
+
interface HttpHeader {
|
|
63
|
+
readonly name: string;
|
|
64
|
+
readonly value: string;
|
|
65
|
+
}
|
|
66
|
+
interface IdPage {
|
|
67
|
+
readonly items: readonly string[];
|
|
68
|
+
readonly next_cursor?: string;
|
|
69
|
+
readonly truncated: boolean;
|
|
70
|
+
}
|
|
71
|
+
interface LayerPage {
|
|
72
|
+
readonly items: readonly VectorLayerInfo[];
|
|
73
|
+
readonly next_cursor?: string;
|
|
74
|
+
readonly truncated: boolean;
|
|
75
|
+
}
|
|
76
|
+
interface LayerRequest {
|
|
77
|
+
readonly layer_id: string;
|
|
78
|
+
}
|
|
79
|
+
interface NetworkFetchData {
|
|
80
|
+
readonly base64: string | null;
|
|
81
|
+
readonly headers: readonly HttpHeader[];
|
|
82
|
+
readonly reason: string;
|
|
83
|
+
readonly status_code: number;
|
|
84
|
+
readonly text: string | null;
|
|
85
|
+
readonly url: string;
|
|
86
|
+
}
|
|
87
|
+
interface NotificationsInfoRequest {
|
|
88
|
+
readonly message: string;
|
|
89
|
+
}
|
|
90
|
+
interface OpenVectorRequest {
|
|
91
|
+
readonly file: FileRef;
|
|
92
|
+
}
|
|
93
|
+
interface PageRequest {
|
|
94
|
+
readonly cursor?: string;
|
|
95
|
+
readonly limit?: number;
|
|
96
|
+
}
|
|
97
|
+
interface SettingsGetRequest {
|
|
98
|
+
readonly default?: string | null;
|
|
99
|
+
readonly key: string;
|
|
100
|
+
}
|
|
101
|
+
interface StylesApplyRequest {
|
|
102
|
+
readonly layer_id: string;
|
|
103
|
+
readonly style: string;
|
|
104
|
+
}
|
|
105
|
+
interface VectorLayerInfo {
|
|
106
|
+
readonly crs: string | null;
|
|
107
|
+
readonly field_names: readonly string[];
|
|
108
|
+
readonly geometry_type: "point" | "line" | "polygon" | "none";
|
|
109
|
+
readonly id: string;
|
|
110
|
+
readonly name: string;
|
|
111
|
+
}
|
|
112
|
+
declare function ExportRequest(value: unknown, strict?: boolean): value is ExportRequest;
|
|
113
|
+
declare function ExportResult(value: unknown, strict?: boolean): value is ExportResult;
|
|
114
|
+
declare function FetchRequest(value: unknown, strict?: boolean): value is FetchRequest;
|
|
115
|
+
declare function IdPage(value: unknown, strict?: boolean): value is IdPage;
|
|
116
|
+
declare function LayerPage(value: unknown, strict?: boolean): value is LayerPage;
|
|
117
|
+
declare function LayerRequest(value: unknown, strict?: boolean): value is LayerRequest;
|
|
118
|
+
declare function NetworkFetchData(value: unknown, strict?: boolean): value is NetworkFetchData;
|
|
119
|
+
declare function NotificationsInfoRequest(value: unknown, strict?: boolean): value is NotificationsInfoRequest;
|
|
120
|
+
declare function OpenVectorRequest(value: unknown, strict?: boolean): value is OpenVectorRequest;
|
|
121
|
+
declare function PageRequest(value: unknown, strict?: boolean): value is PageRequest;
|
|
122
|
+
declare function SettingsGetRequest(value: unknown, strict?: boolean): value is SettingsGetRequest;
|
|
123
|
+
declare function StylesApplyRequest(value: unknown, strict?: boolean): value is StylesApplyRequest;
|
|
124
|
+
/** One event of `network.fetch`, narrowed by its kind. */
|
|
125
|
+
type NetworkFetchEvent = {
|
|
126
|
+
readonly kind: "data";
|
|
127
|
+
readonly payload: NetworkFetchData;
|
|
128
|
+
};
|
|
129
|
+
declare function NetworkFetchEvent(value: unknown, strict?: boolean): value is NetworkFetchEvent;
|
|
130
|
+
/** Every operation this surface declares, as callable methods. */
|
|
131
|
+
interface HostOperations {
|
|
132
|
+
readonly files: {
|
|
133
|
+
readonly export: (input: ExportRequest, options?: HostInvokeOptions) => Promise<ExportResult>;
|
|
134
|
+
};
|
|
135
|
+
readonly layers: {
|
|
136
|
+
readonly get: (input: LayerRequest, options?: HostInvokeOptions) => Promise<VectorLayerInfo>;
|
|
137
|
+
readonly list: (input?: PageRequest, options?: HostInvokeOptions) => Promise<LayerPage>;
|
|
138
|
+
readonly open_vector: (input: OpenVectorRequest, options?: HostInvokeOptions) => Promise<VectorLayerInfo>;
|
|
139
|
+
};
|
|
140
|
+
readonly network: {
|
|
141
|
+
readonly fetch: (input: FetchRequest, handlers: HostStreamHandlers<NetworkFetchEvent>, options?: HostInvokeOptions) => Promise<HostStreamHandle>;
|
|
142
|
+
};
|
|
143
|
+
readonly notifications: {
|
|
144
|
+
readonly info: (input: NotificationsInfoRequest, options?: HostInvokeOptions) => Promise<null>;
|
|
145
|
+
};
|
|
146
|
+
readonly project: {
|
|
147
|
+
readonly layer_ids: (input?: PageRequest, options?: HostInvokeOptions) => Promise<IdPage>;
|
|
148
|
+
};
|
|
149
|
+
readonly settings: {
|
|
150
|
+
readonly get: (input: SettingsGetRequest, options?: HostInvokeOptions) => Promise<string | null>;
|
|
151
|
+
};
|
|
152
|
+
readonly styles: {
|
|
153
|
+
readonly apply: (input: StylesApplyRequest, options?: HostInvokeOptions) => Promise<null>;
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
declare function createHost(client: HostClientLike): HostOperations;
|
|
157
|
+
export { ExportRequest, ExportResult, FetchRequest, FileRef, HOST_FINGERPRINT, HOST_ID, HOST_OPERATIONS, HOST_SCHEMA_VERSION, HostClientLike, HostContractError, HostInvokeOptions, HostOperationId, HostOperations, HostStreamHandle, HostStreamHandlers, HostStreamTerminal, HttpHeader, IdPage, LayerPage, LayerRequest, NetworkFetchData, NetworkFetchEvent, NotificationsInfoRequest, OpenVectorRequest, PageRequest, SettingsGetRequest, StylesApplyRequest, VectorLayerInfo, createHost };
|