@archont561/qgis-sdk 0.4.0 → 0.6.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.
@@ -1,9 +1,9 @@
1
1
  import { QgisSdkError2 } from "./chunk-pdj2fxjb.js";
2
2
  declare const HOST_ID2 = "qgis.host";
3
- declare const HOST_FINGERPRINT2 = "sha256:f96bdf1046434de3c5eae01efb34c8ad2bcd1cf241a3dc42f6c4b613dc7d7d6f";
3
+ declare const HOST_FINGERPRINT2 = "sha256:16790dc8c4d77ef5b5f22636702e913f3d6fb63275d0ae3e5a4ca6e8001a9abd";
4
4
  declare const HOST_SCHEMA_VERSION2 = 1;
5
5
  /** Every declared operation id, so a name can be checked, not guessed. */
6
- declare const HOST_OPERATIONS2: readonly ["files.export", "layers.get", "layers.list", "layers.open_vector", "network.fetch", "notifications.info", "project.layer_ids", "settings.get", "styles.apply"];
6
+ declare const HOST_OPERATIONS2: readonly ["algorithms.describe", "algorithms.list", "algorithms.providers", "algorithms.run", "files.export", "layers.get", "layers.list", "layers.open_vector", "network.fetch", "notifications.info", "project.layer_ids", "settings.get", "styles.apply"];
7
7
  type HostOperationId2 = (typeof HOST_OPERATIONS2)[number];
8
8
  interface HostInvokeOptions2 {
9
9
  readonly signal?: AbortSignal;
@@ -38,6 +38,39 @@ declare class QgisSdkHostContractError2 extends QgisSdkError2 {
38
38
  readonly operation: string;
39
39
  constructor(operation: string, message: string);
40
40
  }
41
+ interface AlgorithmInfo2 {
42
+ readonly deprecated: boolean;
43
+ readonly group: string;
44
+ readonly group_id: string;
45
+ readonly help: string;
46
+ readonly id: string;
47
+ readonly label: string;
48
+ readonly name: string;
49
+ readonly outputs: readonly OutputInfo2[];
50
+ readonly parameters: readonly ParameterInfo2[];
51
+ readonly provider: string;
52
+ }
53
+ interface AlgorithmListRequest2 {
54
+ readonly cursor?: string;
55
+ readonly limit?: number;
56
+ readonly provider?: string;
57
+ }
58
+ interface AlgorithmPage2 {
59
+ readonly items: readonly AlgorithmSummary2[];
60
+ readonly next_cursor?: string;
61
+ readonly truncated: boolean;
62
+ }
63
+ interface AlgorithmRequest2 {
64
+ readonly algorithm_id: string;
65
+ }
66
+ interface AlgorithmSummary2 {
67
+ readonly deprecated: boolean;
68
+ readonly group: string;
69
+ readonly id: string;
70
+ readonly label: string;
71
+ readonly name: string;
72
+ readonly provider: string;
73
+ }
41
74
  interface ExportRequest2 {
42
75
  readonly content: string;
43
76
  readonly file: FileRef2;
@@ -56,7 +89,7 @@ interface FetchRequest2 {
56
89
  }
57
90
  interface FileRef2 {
58
91
  readonly id: string;
59
- readonly kind: "file";
92
+ readonly kind: "file" | "directory";
60
93
  readonly name?: string;
61
94
  readonly operations?: readonly ("read" | "write")[];
62
95
  }
@@ -91,10 +124,58 @@ interface NotificationsInfoRequest2 {
91
124
  interface OpenVectorRequest2 {
92
125
  readonly file: FileRef2;
93
126
  }
127
+ interface OutputInfo2 {
128
+ readonly kind: string;
129
+ readonly label: string;
130
+ readonly name: string;
131
+ }
94
132
  interface PageRequest2 {
95
133
  readonly cursor?: string;
96
134
  readonly limit?: number;
97
135
  }
136
+ interface ParameterInfo2 {
137
+ readonly advanced: boolean;
138
+ readonly default_json: string | null;
139
+ readonly description: string;
140
+ readonly destination: boolean;
141
+ readonly extension: string | null;
142
+ readonly hidden: boolean;
143
+ readonly kind: string;
144
+ readonly label: string;
145
+ readonly maximum: number | null;
146
+ readonly minimum: number | null;
147
+ readonly multiple: boolean;
148
+ readonly name: string;
149
+ readonly number_type: string | null;
150
+ readonly optional: boolean;
151
+ readonly options: readonly string[];
152
+ readonly required: boolean;
153
+ }
154
+ interface ProviderInfo2 {
155
+ readonly id: string;
156
+ readonly label: string;
157
+ readonly version: string;
158
+ }
159
+ interface ProviderPage2 {
160
+ readonly items: readonly ProviderInfo2[];
161
+ readonly next_cursor?: string;
162
+ readonly truncated: boolean;
163
+ }
164
+ interface RunAlgorithmRequest2 {
165
+ readonly algorithm_id: string;
166
+ readonly params: Record<string, unknown>;
167
+ }
168
+ interface RunOutput2 {
169
+ readonly file?: FileRef2;
170
+ readonly kind: "vector" | "file" | "value";
171
+ readonly layer?: VectorLayerInfo2;
172
+ readonly name: string;
173
+ readonly value?: string | number | boolean | null;
174
+ }
175
+ interface RunResult2 {
176
+ readonly algorithm: string;
177
+ readonly outputs: readonly RunOutput2[];
178
+ }
98
179
  interface SettingsGetRequest2 {
99
180
  readonly default?: string | null;
100
181
  readonly key: string;
@@ -110,6 +191,10 @@ interface VectorLayerInfo2 {
110
191
  readonly id: string;
111
192
  readonly name: string;
112
193
  }
194
+ declare function AlgorithmInfo2(value: unknown, strict?: boolean): value is AlgorithmInfo2;
195
+ declare function AlgorithmListRequest2(value: unknown, strict?: boolean): value is AlgorithmListRequest2;
196
+ declare function AlgorithmPage2(value: unknown, strict?: boolean): value is AlgorithmPage2;
197
+ declare function AlgorithmRequest2(value: unknown, strict?: boolean): value is AlgorithmRequest2;
113
198
  declare function ExportRequest2(value: unknown, strict?: boolean): value is ExportRequest2;
114
199
  declare function ExportResult2(value: unknown, strict?: boolean): value is ExportResult2;
115
200
  declare function FetchRequest2(value: unknown, strict?: boolean): value is FetchRequest2;
@@ -120,6 +205,9 @@ declare function NetworkFetchData2(value: unknown, strict?: boolean): value is N
120
205
  declare function NotificationsInfoRequest2(value: unknown, strict?: boolean): value is NotificationsInfoRequest2;
121
206
  declare function OpenVectorRequest2(value: unknown, strict?: boolean): value is OpenVectorRequest2;
122
207
  declare function PageRequest2(value: unknown, strict?: boolean): value is PageRequest2;
208
+ declare function ProviderPage2(value: unknown, strict?: boolean): value is ProviderPage2;
209
+ declare function RunAlgorithmRequest2(value: unknown, strict?: boolean): value is RunAlgorithmRequest2;
210
+ declare function RunResult2(value: unknown, strict?: boolean): value is RunResult2;
123
211
  declare function SettingsGetRequest2(value: unknown, strict?: boolean): value is SettingsGetRequest2;
124
212
  declare function StylesApplyRequest2(value: unknown, strict?: boolean): value is StylesApplyRequest2;
125
213
  /** One event of `network.fetch`, narrowed by its kind. */
@@ -130,6 +218,12 @@ type NetworkFetchEvent2 = {
130
218
  declare function NetworkFetchEvent2(value: unknown, strict?: boolean): value is NetworkFetchEvent2;
131
219
  /** Every operation this surface declares, as callable methods. */
132
220
  interface HostOperations2 {
221
+ readonly algorithms: {
222
+ readonly describe: (input: AlgorithmRequest2, options?: HostInvokeOptions2) => Promise<AlgorithmInfo2>;
223
+ readonly list: (input?: AlgorithmListRequest2, options?: HostInvokeOptions2) => Promise<AlgorithmPage2>;
224
+ readonly providers: (input?: PageRequest2, options?: HostInvokeOptions2) => Promise<ProviderPage2>;
225
+ readonly run: (input: RunAlgorithmRequest2, options?: HostInvokeOptions2) => Promise<RunResult2>;
226
+ };
133
227
  readonly files: {
134
228
  readonly export: (input: ExportRequest2, options?: HostInvokeOptions2) => Promise<ExportResult2>;
135
229
  };
@@ -155,4 +249,4 @@ interface HostOperations2 {
155
249
  };
156
250
  }
157
251
  declare function createHost2(client: HostClientLike2): HostOperations2;
158
- export { HOST_ID2, HOST_FINGERPRINT2, HOST_SCHEMA_VERSION2, HOST_OPERATIONS2, HostOperationId2, HostInvokeOptions2, HostClientLike2, HostStreamTerminal2, HostStreamHandlers2, HostStreamHandle2, QgisSdkHostContractError2, ExportRequest2, ExportResult2, FetchRequest2, FileRef2, HttpHeader2, IdPage2, LayerPage2, LayerRequest2, NetworkFetchData2, NotificationsInfoRequest2, OpenVectorRequest2, PageRequest2, SettingsGetRequest2, StylesApplyRequest2, VectorLayerInfo2, NetworkFetchEvent2, HostOperations2, createHost2 };
252
+ export { HOST_ID2, HOST_FINGERPRINT2, HOST_SCHEMA_VERSION2, HOST_OPERATIONS2, HostOperationId2, HostInvokeOptions2, HostClientLike2, HostStreamTerminal2, HostStreamHandlers2, HostStreamHandle2, QgisSdkHostContractError2, AlgorithmInfo2, AlgorithmListRequest2, AlgorithmPage2, AlgorithmRequest2, AlgorithmSummary2, ExportRequest2, ExportResult2, FetchRequest2, FileRef2, HttpHeader2, IdPage2, LayerPage2, LayerRequest2, NetworkFetchData2, NotificationsInfoRequest2, OpenVectorRequest2, OutputInfo2, PageRequest2, ParameterInfo2, ProviderInfo2, ProviderPage2, RunAlgorithmRequest2, RunOutput2, RunResult2, SettingsGetRequest2, StylesApplyRequest2, VectorLayerInfo2, NetworkFetchEvent2, HostOperations2, createHost2 };
@@ -70,7 +70,7 @@ declare class QgisSdkContractValidationError2 extends QgisSdkError2 {
70
70
  toJSON(): SerializedContractValidationError2;
71
71
  }
72
72
  /**
73
- * Parse and validate a version 1 `PluginDescription` emitted by `describe_plugin`.
73
+ * Parse and validate a version 1 `PluginDescription` emitted by `describe(app)`.
74
74
  */
75
75
  declare function parsePluginDescription2(input: string | Readonly<Record<string, unknown>>): PluginDescription2;
76
76
  declare const BRIDGE_PROTOCOL_VERSION2: 1;
@@ -134,75 +134,6 @@ interface BridgeClientOptions2 {
134
134
  interface InvokeOptions2 {
135
135
  readonly signal?: AbortSignal;
136
136
  }
137
- /**
138
- * An envelope or reply does not match the versioned bridge protocol.
139
- */
140
- declare class QgisSdkBridgeProtocolError2 extends QgisSdkError2 {
141
- constructor(message: string);
142
- }
143
- /**
144
- * The host did not answer in time. The call may still have run, so this is an
145
- * unknown outcome: retrying automatically is forbidden, deciding is the caller's.
146
- */
147
- declare class QgisSdkBridgeTimeoutError2 extends QgisSdkError2 {
148
- readonly callId: string;
149
- constructor(callId: string, timeoutMs: number);
150
- }
151
- /**
152
- * The caller aborted locally. Distinct from the host cancelling the operation,
153
- * which arrives as a failure reply carrying the `cancelled` code.
154
- */
155
- declare class QgisSdkBridgeAbortedError2 extends QgisSdkError2 {
156
- readonly callId: string;
157
- constructor(callId: string);
158
- }
159
- /**
160
- * The client was closed, so pending calls can no longer be answered.
161
- */
162
- declare class QgisSdkBridgeClosedError2 extends QgisSdkError2 {
163
- constructor();
164
- }
165
- /**
166
- * A subscription's frames were not the sequence the host promised.
167
- *
168
- * The client does not try to reassemble: a missed frame is a fact about the
169
- * subscription, not something to paper over.
170
- */
171
- declare class QgisSdkBridgeSequenceError2 extends QgisSdkError2 {
172
- readonly subscriptionId: string;
173
- readonly expected: number;
174
- readonly received: number;
175
- constructor(subscriptionId: string, expected: number, received: number);
176
- }
177
- /**
178
- * The subscription ended with a terminal frame the caller may want to inspect.
179
- */
180
- declare class QgisSdkBridgeStreamEndedError2 extends QgisSdkError2 {
181
- readonly subscriptionId: string;
182
- readonly terminal: BridgeStreamTerminal2;
183
- constructor(subscriptionId: string, terminal: BridgeStreamTerminal2);
184
- }
185
- /**
186
- * The host refused or failed the operation; `failure.code` is the contract.
187
- */
188
- declare class QgisSdkBridgeRemoteError2 extends QgisSdkError2 {
189
- readonly failure: BridgeFailure2;
190
- readonly callId: string;
191
- constructor(callId: string, failure: BridgeFailure2);
192
- }
193
- /**
194
- * Parse one reply, refusing anything the host could not legitimately have sent.
195
- */
196
- declare function parseInvokeReply2(raw: unknown): InvokeReply2;
197
- /**
198
- * Parse one stream frame, refusing anything the host could not legitimately
199
- * have sent.
200
- *
201
- * Exactly one of `event` and `terminal` has to be present: a frame that carries
202
- * both leaves the client guessing which one wins, and a client that guesses is
203
- * a client that will eventually deliver an event after the end of a stream.
204
- */
205
- declare function parseStreamFrame2(raw: unknown): BridgeStreamFrame2;
206
137
  /** Callbacks a subscription reports through. */
207
138
  interface SubscriptionHandlers2 {
208
139
  readonly onEvent?: (event: BridgeStreamEvent2) => void;
@@ -277,4 +208,53 @@ declare class BridgeClient2 {
277
208
  /** The last malformed message this client refused, if any. */
278
209
  get protocolError(): Error | null;
279
210
  }
280
- export { MAX_SAFE_INTEGER2, MIN_SAFE_INTEGER2, PLUGIN_DESCRIPTION_SCHEMA_VERSION2, ValidationDirection2, SerializedValidationIssue2, SerializedContractValidationError2, ActionDescription2, StreamEventKind2, StreamDescription2, PluginDescription2, isSafeJsonInteger2, QgisSdkDeclarationError2, QgisSdkValidationIssue2, QgisSdkContractValidationError2, parsePluginDescription2, BRIDGE_PROTOCOL_VERSION2, MAX_CALL_ID_LENGTH2, BridgeFailure2, InvokeReply2, StreamTerminalKind2, BridgeStreamEvent2, BridgeStreamTerminal2, BridgeEventFrame2, BridgeTerminalFrame2, BridgeStreamFrame2, WireTransport2, BridgeClientOptions2, InvokeOptions2, QgisSdkBridgeProtocolError2, QgisSdkBridgeTimeoutError2, QgisSdkBridgeAbortedError2, QgisSdkBridgeClosedError2, QgisSdkBridgeSequenceError2, QgisSdkBridgeStreamEndedError2, QgisSdkBridgeRemoteError2, parseInvokeReply2, parseStreamFrame2, SubscriptionHandlers2, BridgeSubscription2, BridgeClient2 };
211
+ /**
212
+ * An envelope or reply does not match the versioned bridge protocol.
213
+ */
214
+ declare class QgisSdkBridgeProtocolError2 extends QgisSdkError2 {
215
+ constructor(message: string);
216
+ }
217
+ /**
218
+ * The host did not answer in time. The call may still have run, so this is an
219
+ * unknown outcome: retrying automatically is forbidden, deciding is the caller's.
220
+ */
221
+ declare class QgisSdkBridgeTimeoutError2 extends QgisSdkError2 {
222
+ readonly callId: string;
223
+ constructor(callId: string, timeoutMs: number);
224
+ }
225
+ /**
226
+ * The caller aborted locally. Distinct from the host cancelling the operation,
227
+ * which arrives as a failure reply carrying the `cancelled` code.
228
+ */
229
+ declare class QgisSdkBridgeAbortedError2 extends QgisSdkError2 {
230
+ readonly callId: string;
231
+ constructor(callId: string);
232
+ }
233
+ /**
234
+ * The client was closed, so pending calls can no longer be answered.
235
+ */
236
+ declare class QgisSdkBridgeClosedError2 extends QgisSdkError2 {
237
+ constructor();
238
+ }
239
+ /**
240
+ * The host refused or failed the operation; `failure.code` is the contract.
241
+ */
242
+ declare class QgisSdkBridgeRemoteError2 extends QgisSdkError2 {
243
+ readonly failure: BridgeFailure2;
244
+ readonly callId: string;
245
+ constructor(callId: string, failure: BridgeFailure2);
246
+ }
247
+ /**
248
+ * Parse one reply, refusing anything the host could not legitimately have sent.
249
+ */
250
+ declare function parseInvokeReply2(raw: unknown): InvokeReply2;
251
+ /**
252
+ * Parse one stream frame, refusing anything the host could not legitimately
253
+ * have sent.
254
+ *
255
+ * Exactly one of `event` and `terminal` has to be present: a frame that carries
256
+ * both leaves the client guessing which one wins, and a client that guesses is
257
+ * a client that will eventually deliver an event after the end of a stream.
258
+ */
259
+ declare function parseStreamFrame2(raw: unknown): BridgeStreamFrame2;
260
+ export { MAX_SAFE_INTEGER2, MIN_SAFE_INTEGER2, PLUGIN_DESCRIPTION_SCHEMA_VERSION2, ValidationDirection2, SerializedValidationIssue2, SerializedContractValidationError2, ActionDescription2, StreamEventKind2, StreamDescription2, PluginDescription2, isSafeJsonInteger2, QgisSdkDeclarationError2, QgisSdkValidationIssue2, QgisSdkContractValidationError2, parsePluginDescription2, BRIDGE_PROTOCOL_VERSION2, MAX_CALL_ID_LENGTH2, BridgeFailure2, InvokeReply2, StreamTerminalKind2, BridgeStreamEvent2, BridgeStreamTerminal2, BridgeEventFrame2, BridgeTerminalFrame2, BridgeStreamFrame2, WireTransport2, BridgeClientOptions2, InvokeOptions2, SubscriptionHandlers2, BridgeSubscription2, BridgeClient2, QgisSdkBridgeProtocolError2, QgisSdkBridgeTimeoutError2, QgisSdkBridgeAbortedError2, QgisSdkBridgeClosedError2, QgisSdkBridgeRemoteError2, parseInvokeReply2, parseStreamFrame2 };
@@ -0,0 +1,342 @@
1
+ import { SerializedValidationIssue2, ActionDescription2, QgisSdkValidationIssue2 } from "./chunk-8c12nwme.js";
2
+ import { HostOperationId2, VectorLayerInfo2 } from "./chunk-7tgzmz0m.js";
3
+ import { OperationShape2, QgisSdkHost2, QgisSdkCore2 } from "./chunk-nwz8n14x.js";
4
+ import { QgisSdkError2 } from "./chunk-pdj2fxjb.js";
5
+ /** A store was built or driven outside the shape it needs. */
6
+ declare class QgisSdkStoreError2 extends QgisSdkError2 {
7
+ constructor(message: string);
8
+ }
9
+ /** What a listener receives: the whole snapshot, never a diff. */
10
+ type StoreListener2<T> = (snapshot: T) => void;
11
+ /**
12
+ * The contract every store honours, and the one `useSyncExternalStore`,
13
+ * Vue's `shallowRef` wiring and Svelte's `$store` all read.
14
+ */
15
+ interface Store2<T> {
16
+ /** The current value; the same object until the next change. Bound. */
17
+ readonly getSnapshot: () => T;
18
+ /**
19
+ * Call `listener` now and after every change; the returned function
20
+ * stops the calls. Bound. Svelte passes a second `invalidate` argument,
21
+ * which is ignored.
22
+ */
23
+ readonly subscribe: (listener: StoreListener2<T>) => () => void;
24
+ }
25
+ declare abstract class BaseStore<T> implements Store2<T> {
26
+ private snapshot;
27
+ private readonly listeners;
28
+ protected constructor(initial: T);
29
+ readonly getSnapshot: () => T;
30
+ readonly subscribe: (listener: StoreListener2<T>) => (() => void);
31
+ protected publish(next: T): void;
32
+ }
33
+ /** One schema of the declared dialect, as the description carries it. */
34
+ type DeclaredSchema2 = Readonly<Record<string, unknown>>;
35
+ /** Options for {@link validateAgainstSchema}. */
36
+ interface ValidateOptions2 {
37
+ /** Ignore properties the schema does not name (results and events). */
38
+ readonly allowUnknown?: boolean;
39
+ /** Where the value sits, prefixed to every issue's path. */
40
+ readonly path?: readonly (string | number)[];
41
+ }
42
+ /** Which side of a call a contract issue belongs to. */
43
+ type ContractDirection2 = "request" | "result" | "event";
44
+ /** The JSON form of {@link QgisSdkContractError}. */
45
+ interface SerializedContractError2 {
46
+ readonly code: string;
47
+ readonly operation: string;
48
+ readonly direction: ContractDirection2;
49
+ readonly issues: SerializedValidationIssue2[];
50
+ }
51
+ /**
52
+ * An argument, a reply or an event does not match the declared contract.
53
+ *
54
+ * The code is the one both languages use for this category, so a page that
55
+ * already matches `contract_validation_failed` needs no second branch.
56
+ */
57
+ declare class QgisSdkContractError2 extends QgisSdkError2 {
58
+ readonly operation: string;
59
+ readonly direction: ContractDirection2;
60
+ readonly issues: readonly QgisSdkValidationIssue2[];
61
+ constructor(operation: string, direction: ContractDirection2, issues: readonly QgisSdkValidationIssue2[]);
62
+ toJSON(): SerializedContractError2;
63
+ }
64
+ /**
65
+ * Return every issue `value` has against `schema`; an empty array is a match.
66
+ *
67
+ * Throws {@link QgisSdkDeclarationError} when `schema` leaves the declared
68
+ * dialect, because that is a fault in the declaration, never in the value.
69
+ */
70
+ declare function validateAgainstSchema2(value: unknown, schema: DeclaredSchema2, options?: ValidateOptions2): QgisSdkValidationIssue2[];
71
+ /** Where one invocation stands. */
72
+ type OperationState2<R> = {
73
+ readonly status: "idle";
74
+ } | {
75
+ readonly status: "pending";
76
+ } | {
77
+ readonly status: "ok";
78
+ readonly value: R;
79
+ } | {
80
+ readonly status: "error";
81
+ readonly error: Error;
82
+ };
83
+ /** An operation member of a generated map: input, optional signal, promise. */
84
+ type Operation2<
85
+ I,
86
+ R
87
+ > = (input: I, options?: {
88
+ readonly signal?: AbortSignal;
89
+ }) => Promise<R>;
90
+ /**
91
+ * Run one generated operation.
92
+ *
93
+ * `run` resolves with the value, or with `undefined` when the call failed,
94
+ * was aborted or was superseded by a later run - the state carries the error,
95
+ * so the promise never rejects into an event handler. Only the latest run can
96
+ * change the state. `abort` ends the in-flight call locally (the host may
97
+ * still run it); `reset` aborts and returns to `idle`. The methods are bound,
98
+ * so they can be passed around without the store.
99
+ */
100
+ declare class OperationStore2<
101
+ I,
102
+ R
103
+ > extends BaseStore<OperationState2<R>> {
104
+ private readonly operation;
105
+ private generation;
106
+ private controller;
107
+ constructor(operation: Operation2<I, R>);
108
+ readonly abort: () => void;
109
+ readonly reset: () => void;
110
+ readonly run: (input: I) => Promise<R | undefined>;
111
+ }
112
+ /**
113
+ * The input families a declared request can ask for: the same names the
114
+ * Python `qgis_sdk.ui` catalogue draws, so a form on either side of the
115
+ * bridge renders one declaration the same way.
116
+ */
117
+ type FormFieldKind2 = "text" | "integer" | "number" | "boolean" | "choice" | "layer" | "crs" | "metres" | "file" | "directory" | "field" | "range" | "colour";
118
+ /** One input of a declared action, as a page should render it. */
119
+ interface FormField2 {
120
+ readonly name: string;
121
+ /** `buffer_distance` -> `Buffer distance`. */
122
+ readonly label: string;
123
+ readonly kind: FormFieldKind2;
124
+ readonly required: boolean;
125
+ readonly nullable: boolean;
126
+ /** The `enum` of a `choice` field; empty otherwise. */
127
+ readonly choices: readonly unknown[];
128
+ /** Bounds, a parent input, picker filters: what the kind needs beyond a name. */
129
+ readonly details: Readonly<Record<string, unknown>>;
130
+ /** The property schema the value is validated against. */
131
+ readonly schema: DeclaredSchema2;
132
+ }
133
+ /** Render a field name as a label. */
134
+ declare function labelFor2(name: string): string;
135
+ /**
136
+ * The fields of a declared request schema, in declaration order: the
137
+ * TypeScript twin of `qgis_sdk.ui.schema_fields`.
138
+ */
139
+ declare function schemaFields2(schema: DeclaredSchema2, owner?: string): readonly FormField2[];
140
+ /** The values a form holds: one entry per field the user or the schema set. */
141
+ type FormValues2 = Readonly<Record<string, unknown>>;
142
+ /** Where one form stands. */
143
+ interface FormState2<R> {
144
+ readonly values: FormValues2;
145
+ /** Every issue the current values have against the request schema. */
146
+ readonly issues: readonly QgisSdkValidationIssue2[];
147
+ /** The first issue code per field name, for a label to show. */
148
+ readonly errors: Readonly<Record<string, string>>;
149
+ readonly valid: boolean;
150
+ /** A value changed since construction or the last `reset`. */
151
+ readonly dirty: boolean;
152
+ /** `submit` was attempted since construction or the last `reset`. */
153
+ readonly submitted: boolean;
154
+ /** The latest submission, as an operation store reports it. */
155
+ readonly submission: OperationState2<R>;
156
+ }
157
+ /** Options for {@link FormStore}. */
158
+ interface FormOptions2 {
159
+ /** Values to start from; the declared dialect has no defaults of its own. */
160
+ readonly initial?: FormValues2;
161
+ }
162
+ type RequestOf<
163
+ O,
164
+ K extends keyof O
165
+ > = O[K] extends OperationShape2 ? O[K]["request"] : never;
166
+ type ResultOf<
167
+ O,
168
+ K extends keyof O
169
+ > = O[K] extends OperationShape2 ? O[K]["result"] : never;
170
+ /**
171
+ * Bind the request of one declared action to its schema.
172
+ *
173
+ * The fields come from the declaration, so a page renders `form.fields`
174
+ * instead of guessing; `set` coerces what an `<input>` yields (`"3"` for a
175
+ * numeric field, `""` for an unset one) and re-validates; `submit` refuses
176
+ * invalid values without a call and otherwise runs the operation through an
177
+ * {@link OperationStore}, whose state is `submission`.
178
+ */
179
+ declare class FormStore2<
180
+ Req extends object,
181
+ R
182
+ > extends BaseStore<FormState2<R>> {
183
+ readonly id: string;
184
+ readonly title: string;
185
+ readonly fields: readonly FormField2[];
186
+ private readonly byName;
187
+ private readonly request;
188
+ private readonly initial;
189
+ private readonly operation;
190
+ private readonly unsubscribe;
191
+ constructor(qgis: QgisSdkCore2<unknown, unknown>, id: string, options?: FormOptions2);
192
+ /** The declaration the form was built from, for a page that renders more. */
193
+ static describe(qgis: QgisSdkCore2<unknown, unknown>, id: string): ActionDescription2 | undefined;
194
+ private static defaults;
195
+ private static evaluate;
196
+ /** Set one field; `undefined` unsets it. */
197
+ readonly set: (name: string, value: unknown) => void;
198
+ /** Set several fields at once. */
199
+ readonly setValues: (changes: FormValues2) => void;
200
+ /** The declared field, for a renderer working from a name. */
201
+ field(name: string): FormField2;
202
+ /** Back to the initial values and an idle submission; aborts a call in flight. */
203
+ readonly reset: () => void;
204
+ /** Abort a submission in flight; the values stay. */
205
+ readonly abort: () => void;
206
+ /**
207
+ * Validate, then run the action with the current values. Resolves with the
208
+ * result, or `undefined` when the values are invalid (no call is made) or
209
+ * the call failed, was aborted or superseded - `submission` says which.
210
+ */
211
+ readonly submit: () => Promise<R | undefined>;
212
+ /** Stop following the submission; for an adapter tearing the form down. */
213
+ dispose(): void;
214
+ }
215
+ /**
216
+ * The form for `qgis.<id>`, typed from the schema: the request names the
217
+ * fields, the result types the submission.
218
+ */
219
+ declare function formStore2<
220
+ O,
221
+ K extends keyof O & string
222
+ >(qgis: QgisSdkCore2<O, unknown>, id: K, options?: FormOptions2): FormStore2<RequestOf<O, K> & object, ResultOf<O, K>>;
223
+ /** Where one host query stands. */
224
+ type HostQueryState2<T> = {
225
+ readonly status: "idle";
226
+ } | {
227
+ readonly status: "loading";
228
+ } | {
229
+ readonly status: "ok";
230
+ readonly value: T;
231
+ } | {
232
+ readonly status: "error";
233
+ readonly error: Error;
234
+ } | {
235
+ /** The handshake did not grant `operation`; no call was made. */
236
+ readonly status: "refused";
237
+ readonly operation: HostOperationId2;
238
+ readonly message: string;
239
+ };
240
+ /** What a host query runs once the grant is confirmed. */
241
+ type HostQueryLoader2<T> = (host: QgisSdkHost2, options: {
242
+ readonly signal: AbortSignal;
243
+ }) => Promise<T>;
244
+ /**
245
+ * Read the curated host surface, grant first.
246
+ *
247
+ * `refresh` waits for the handshake, then - when `qgis.host.granted` lacks
248
+ * the operation the query needs - settles on `refused` without a call, so a
249
+ * page can show "ask the plugin author for `layers.read`" instead of a
250
+ * `not_authorized` fault. Otherwise the loader runs with latest-wins
251
+ * semantics like an operation store.
252
+ */
253
+ declare class HostQueryStore2<T> extends BaseStore<HostQueryState2<T>> {
254
+ private readonly qgis;
255
+ readonly operation: HostOperationId2;
256
+ private readonly loader;
257
+ private generation;
258
+ private controller;
259
+ constructor(qgis: QgisSdkCore2<unknown, unknown>, operation: HostOperationId2, loader: HostQueryLoader2<T>);
260
+ readonly abort: () => void;
261
+ readonly reset: () => void;
262
+ readonly refresh: () => Promise<T | undefined>;
263
+ }
264
+ /** Options for {@link layersQuery}. */
265
+ interface LayersQueryOptions2 {
266
+ /** Items per page while following `next_cursor`; the host's default otherwise. */
267
+ readonly pageSize?: number;
268
+ }
269
+ /**
270
+ * Every vector layer of the project, following `layers.list` pages to the
271
+ * end: what a layer picker binds to. Needs the `layers.read` grant.
272
+ */
273
+ declare function layersQuery2(qgis: QgisSdkCore2<unknown, unknown>, options?: LayersQueryOptions2): HostQueryStore2<readonly VectorLayerInfo2[]>;
274
+ /**
275
+ * The field names of one vector layer, for a `field` input whose `of` names
276
+ * a layer input: `layers.get` under the `layers.read` grant. A layer's CRS is
277
+ * on the same reply; a project CRS query is not on the wire yet.
278
+ */
279
+ declare function layerFieldsQuery2(qgis: QgisSdkCore2<unknown, unknown>, layerId: string): HostQueryStore2<readonly string[]>;
280
+ /** How a stream ended, as the generated module reports it. */
281
+ interface StreamTerminalLike2 {
282
+ readonly kind: string;
283
+ readonly message?: string;
284
+ readonly dropped?: number;
285
+ }
286
+ /** The handle a generated stream member resolves with. */
287
+ interface StreamHandleLike2 {
288
+ readonly id: string;
289
+ readonly closed: boolean;
290
+ close(): void;
291
+ }
292
+ /** Handlers for a stream, as a generated module types them. */
293
+ interface StreamHandlersLike2<E> {
294
+ readonly onEvent?: (event: E) => void;
295
+ readonly onTerminal?: (terminal: StreamTerminalLike2) => void;
296
+ }
297
+ /** A stream member of a generated map. */
298
+ type Stream2<
299
+ I,
300
+ E
301
+ > = (input: I, handlers: StreamHandlersLike2<E>, options?: {
302
+ readonly signal?: AbortSignal;
303
+ }) => Promise<StreamHandleLike2>;
304
+ /** Where one subscription stands. */
305
+ interface StreamState2<E> {
306
+ /** `idle` with a null input, `failed` when the host refused to open it. */
307
+ readonly status: "idle" | "opening" | "open" | "ended" | "failed";
308
+ readonly lastEvent: E | null;
309
+ readonly terminal: StreamTerminalLike2 | null;
310
+ readonly error: Error | null;
311
+ }
312
+ /**
313
+ * Return a key that is equal for two inputs with the same content, whatever
314
+ * the order their fields were written in.
315
+ */
316
+ declare function stableKey2(value: unknown): string;
317
+ /**
318
+ * Hold one generated stream open while its input is non-null.
319
+ *
320
+ * `setInput` follows the *content* of the input: a new object with the same
321
+ * fields changes nothing, a different one closes the old stream and opens a
322
+ * new one, `null` closes it. Handlers are read fresh on every frame, so
323
+ * `setHandlers` with a new closure reopens nothing. `close` is safe before the
324
+ * host has acknowledged the stream: the handle is closed the moment it
325
+ * arrives.
326
+ */
327
+ declare class StreamStore2<
328
+ I,
329
+ E
330
+ > extends BaseStore<StreamState2<E>> {
331
+ private readonly open;
332
+ private handlers;
333
+ private key;
334
+ private cancel;
335
+ constructor(open: Stream2<I, E>, handlers?: StreamHandlersLike2<E>);
336
+ /** Replace the handlers the next frames reach; nothing reopens. */
337
+ setHandlers(handlers: StreamHandlersLike2<E>): void;
338
+ readonly setInput: (input: I | null) => void;
339
+ readonly close: () => void;
340
+ private start;
341
+ }
342
+ export { QgisSdkStoreError2, StoreListener2, Store2, DeclaredSchema2, ValidateOptions2, ContractDirection2, SerializedContractError2, QgisSdkContractError2, validateAgainstSchema2, OperationState2, Operation2, OperationStore2, FormFieldKind2, FormField2, labelFor2, schemaFields2, FormValues2, FormState2, FormOptions2, FormStore2, formStore2, HostQueryState2, HostQueryLoader2, HostQueryStore2, LayersQueryOptions2, layersQuery2, layerFieldsQuery2, StreamTerminalLike2, StreamHandleLike2, StreamHandlersLike2, Stream2, StreamState2, stableKey2, StreamStore2 };