@archont561/qgis-sdk 0.3.0 → 0.5.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/dist/index.d.ts CHANGED
@@ -1,106 +1,73 @@
1
+ import { 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 } from "./shared/chunk-wtv4vt4q.js";
2
+ import { HostInvokeOptions2, AlgorithmInfo2, AlgorithmSummary2, FileRef2, OutputInfo2, ParameterInfo2, ProviderInfo2, RunOutput2, RunResult2, VectorLayerInfo2, HostOperations2 } from "./shared/chunk-7tgzmz0m.js";
3
+ import { OperationShape2, StreamShape2, OperationMap2, StreamMap2, BridgeSchema2, OperationsOf2, StreamsOf2, defineBridgeSchema2, QgisSdkOptions2, StreamHandlers2, StreamHandle2, OperationMethod2, StreamMethod2, QgisSdkHostTheme2, QgisSdkHost2, QgisSdkCore2, OperationTree2, StreamTree2, QGIS_SDK_MEMBERS2, QgisSdk2 } from "./shared/chunk-a33y575v.js";
4
+ import { DeclaredSchema2, ValidateOptions2, ContractDirection2, SerializedContractError2, QgisSdkContractError2, validateAgainstSchema2, QgisSdkStoreError2, StoreListener2, Store2, OperationState2, Operation2, OperationStore2, StreamTerminalLike2, StreamHandleLike2, StreamHandlersLike2, Stream2, StreamState2, stableKey2, StreamStore2, FormFieldKind2, FormField2, labelFor2, schemaFields2, FormValues2, FormState2, FormOptions2, FormStore2, formStore2, HostQueryState2, HostQueryLoader2, HostQueryStore2, LayersQueryOptions2, layersQuery2, layerFieldsQuery2 } from "./shared/chunk-3zscfm3y.js";
5
+ import { QgisSdkError2 } from "./shared/chunk-pdj2fxjb.js";
6
+ /** A layer input: the id of a layer the host owns, or a ref the view holds. */
7
+ type LayerRef = string | FileRef2;
8
+ /** Where an output goes: a writable ref, or `null` to let the host allocate one. */
9
+ type Destination = FileRef2 | null;
10
+ /** `"xmin,xmax,ymin,ymax [crs]"` as QGIS writes it, or the four numbers. */
11
+ type Extent = string | readonly [number, number, number, number];
12
+ /** `"x,y [crs]"` or the two numbers. */
13
+ type PointValue = string | readonly [number, number];
14
+ /** `[lower, upper]`. */
15
+ type RangeValue = readonly [number, number];
1
16
  /**
2
- * Public 0.1.0 contract, wire-limit, and error primitives for the QGIS SDK bridge.
3
- *
4
- * Mirrors the QGIS-free `qgis_sdk.models` and `qgis_sdk.declarations`
5
- * (`schema_version = 1`) contracts without importing browser or Qt globals.
6
- */
7
- declare const MAX_SAFE_INTEGER: number;
8
- declare const MIN_SAFE_INTEGER: number;
9
- declare const PLUGIN_DESCRIPTION_SCHEMA_VERSION: 1;
10
- type ValidationDirection = "request" | "result";
11
- interface SerializedValidationIssue {
12
- readonly path: (string | number)[];
13
- readonly code: string;
14
- }
15
- interface SerializedContractValidationError {
16
- readonly code: string;
17
- readonly direction: ValidationDirection;
18
- readonly issues: SerializedValidationIssue[];
19
- }
20
- interface ActionDescription {
21
- readonly id: string;
22
- readonly title: string;
23
- readonly handler: string;
24
- readonly request: Readonly<Record<string, unknown>>;
25
- readonly result: Readonly<Record<string, unknown>>;
26
- }
27
- /** The event kinds a stream may declare; the frame carries the same three. */
28
- type StreamEventKind = "data" | "progress" | "state";
29
- /**
30
- * A declared stream (decision-28): a request in, one payload schema per
31
- * declared event kind out. There is no `result`: the reply to a subscription is
32
- * the protocol's acknowledgement, not something an author declares.
33
- */
34
- interface StreamDescription {
35
- readonly id: string;
36
- readonly title: string;
37
- readonly handler: string;
38
- readonly request: Readonly<Record<string, unknown>>;
39
- readonly events: Readonly<Partial<Record<StreamEventKind, Readonly<Record<string, unknown>>>>>;
40
- }
41
- interface PluginDescription {
42
- readonly schema_version: 1;
43
- readonly id: string;
44
- readonly title: string;
45
- readonly actions: readonly ActionDescription[];
46
- /** Declared streams; a description from a host that predates them is empty. */
47
- readonly streams: readonly StreamDescription[];
48
- }
49
- /**
50
- * Return whether `value` is a finite integer within the JavaScript-safe wire range.
51
- */
52
- declare function isSafeJsonInteger(value: unknown): value is number;
53
- /**
54
- * Base class for expected SDK errors across the bridge boundary.
55
- */
56
- declare class QgisSdkError extends Error {
57
- readonly code: string;
58
- constructor(message: string, code?: string);
59
- }
60
- /**
61
- * An operation attempted to use an already disposed owner scope.
17
+ * What a generated `AlgorithmRegistry` is: params and result per algorithm id.
18
+ * Spelled as a mapped constraint over the registry itself so an `interface`
19
+ * (which has no implicit index signature) satisfies it.
62
20
  */
63
- declare class QgisSdkScopeClosedError extends QgisSdkError {
64
- constructor();
21
+ type AlgorithmRegistryLike<R> = { readonly [K in keyof R] : {
22
+ readonly params: object;
23
+ readonly result: object;
24
+ } };
25
+ /** The part of a `QgisSdk` (or anything else) `runAlgorithm` needs. */
26
+ interface AlgorithmHost {
27
+ readonly host: Pick<HostOperations2, "algorithms">;
65
28
  }
66
- /**
67
- * The selected runtime does not offer an explicitly requested capability.
68
- */
69
- declare class QgisSdkUnsupportedCapabilityError extends QgisSdkError {
70
- readonly capability: string;
71
- constructor(capability: string);
29
+ /** One run as the page sees it: the outputs by name, plus the reply as it crossed. */
30
+ interface AlgorithmRun<Result extends object> {
31
+ readonly algorithm: string;
32
+ readonly outputs: Result;
33
+ readonly raw: RunResult2;
72
34
  }
73
35
  /**
74
- * A declaration cannot be represented or parsed in the versioned contract.
36
+ * Run `id` with `params` through `qgis.host.algorithms.run` and reshape the
37
+ * reply: a `vector` output becomes its `VectorLayerInfo`, a `file` output its
38
+ * `FileRef`, a `value` output the scalar - keyed by output name, which is what
39
+ * the generated `...Result` interfaces declare.
40
+ *
41
+ * Both type parameters are meant to be bound by the generated module's own
42
+ * `runAlgorithm`; calling this one directly needs them spelled out.
75
43
  */
76
- declare class QgisSdkDeclarationError extends QgisSdkError {
44
+ declare function runAlgorithm<
45
+ R extends AlgorithmRegistryLike<R>,
46
+ K extends keyof R & string
47
+ >(qgis: AlgorithmHost, id: K, params: R[K]["params"], options?: HostInvokeOptions2): Promise<AlgorithmRun<R[K]["result"]>>;
48
+ /** Unwrap a tagged output list into `{ [name]: layer | ref | value }`. */
49
+ declare function outputsByName(outputs: readonly RunOutput2[]): Record<string, VectorLayerInfo2 | FileRef2 | string | number | boolean | null | undefined>;
50
+ /** The web view did not provide a usable channel. */
51
+ declare class QgisSdkWebChannelError extends QgisSdkError2 {
77
52
  constructor(message: string);
78
53
  }
79
- /**
80
- * Safe, structured location and category for a rejected contract value.
81
- */
82
- declare class QgisSdkValidationIssue {
83
- readonly path: readonly (string | number)[];
84
- readonly code: string;
85
- constructor(path: readonly (string | number)[], code: string);
86
- toJSON(): SerializedValidationIssue;
54
+ /** The transport {@link createWebChannelTransport} returns. */
55
+ interface WebChannelTransport extends WireTransport2 {
56
+ /** Resolves once the channel object answered; rejects when it never will. */
57
+ readonly ready: Promise<void>;
58
+ /** Stop forwarding messages; sends after this throw. */
59
+ close(): void;
87
60
  }
61
+ /** True inside a QGIS web view, where Qt injected its transport and script. */
62
+ declare function insideQgis(): boolean;
88
63
  /**
89
- * A request or result did not satisfy its declared wire contract.
90
- */
91
- declare class QgisSdkContractValidationError extends QgisSdkError {
92
- readonly direction: ValidationDirection;
93
- readonly issues: readonly QgisSdkValidationIssue[];
94
- constructor(direction: ValidationDirection, issues: readonly QgisSdkValidationIssue[]);
95
- toJSON(): SerializedContractValidationError;
96
- }
97
- /**
98
- * Return whether `value` is a non-null, non-array object: the shape every wire
99
- * envelope, description and event payload must have before its fields are read.
100
- */
101
- declare function isPlainRecord(value: unknown): value is Record<string, unknown>;
102
- /**
103
- * Parse and validate a version 1 `PluginDescription` emitted by `describe_plugin`.
64
+ * Connect to the channel object `objectName` and return a transport on it.
65
+ *
66
+ * Throws {@link QgisSdkWebChannelError} synchronously outside a QGIS web view,
67
+ * so a page learns in its first statement that it has no host to talk to.
68
+ * Inside one, messages sent before the channel is ready are queued and
69
+ * delivered in order once it is; `ready` rejects (and queued sends are
70
+ * dropped) when the host registered no object under that name.
104
71
  */
105
- declare function parsePluginDescription(input: string | Readonly<Record<string, unknown>>): PluginDescription;
106
- export { ActionDescription, MAX_SAFE_INTEGER, MIN_SAFE_INTEGER, PLUGIN_DESCRIPTION_SCHEMA_VERSION, PluginDescription, QgisSdkContractValidationError, QgisSdkDeclarationError, QgisSdkError, QgisSdkScopeClosedError, QgisSdkUnsupportedCapabilityError, QgisSdkValidationIssue, SerializedContractValidationError, SerializedValidationIssue, StreamDescription, StreamEventKind, ValidationDirection, isPlainRecord, isSafeJsonInteger, parsePluginDescription };
72
+ declare function createWebChannelTransport(objectName?: string): WebChannelTransport;
73
+ export { ActionDescription2 as ActionDescription, AlgorithmHost, AlgorithmInfo2 as AlgorithmInfo, AlgorithmRegistryLike, AlgorithmRun, AlgorithmSummary2 as AlgorithmSummary, BRIDGE_PROTOCOL_VERSION2 as BRIDGE_PROTOCOL_VERSION, BridgeClient2 as BridgeClient, BridgeClientOptions2 as BridgeClientOptions, BridgeEventFrame2 as BridgeEventFrame, BridgeFailure2 as BridgeFailure, BridgeSchema2 as BridgeSchema, BridgeStreamEvent2 as BridgeStreamEvent, BridgeStreamFrame2 as BridgeStreamFrame, BridgeStreamTerminal2 as BridgeStreamTerminal, BridgeSubscription2 as BridgeSubscription, BridgeTerminalFrame2 as BridgeTerminalFrame, ContractDirection2 as ContractDirection, DeclaredSchema2 as DeclaredSchema, Destination, Extent, FileRef2 as FileRef, FormField2 as FormField, FormFieldKind2 as FormFieldKind, FormOptions2 as FormOptions, FormState2 as FormState, FormStore2 as FormStore, FormValues2 as FormValues, HostInvokeOptions2 as HostInvokeOptions, HostQueryLoader2 as HostQueryLoader, HostQueryState2 as HostQueryState, HostQueryStore2 as HostQueryStore, InvokeOptions2 as InvokeOptions, InvokeReply2 as InvokeReply, LayerRef, LayersQueryOptions2 as LayersQueryOptions, MAX_CALL_ID_LENGTH2 as MAX_CALL_ID_LENGTH, MAX_SAFE_INTEGER2 as MAX_SAFE_INTEGER, MIN_SAFE_INTEGER2 as MIN_SAFE_INTEGER, Operation2 as Operation, OperationMap2 as OperationMap, OperationMethod2 as OperationMethod, OperationShape2 as OperationShape, OperationState2 as OperationState, OperationStore2 as OperationStore, OperationTree2 as OperationTree, OperationsOf2 as OperationsOf, OutputInfo2 as OutputInfo, PLUGIN_DESCRIPTION_SCHEMA_VERSION2 as PLUGIN_DESCRIPTION_SCHEMA_VERSION, ParameterInfo2 as ParameterInfo, PluginDescription2 as PluginDescription, PointValue, ProviderInfo2 as ProviderInfo, QGIS_SDK_MEMBERS2 as QGIS_SDK_MEMBERS, QgisSdk2 as QgisSdk, QgisSdkBridgeAbortedError2 as QgisSdkBridgeAbortedError, QgisSdkBridgeClosedError2 as QgisSdkBridgeClosedError, QgisSdkBridgeProtocolError2 as QgisSdkBridgeProtocolError, QgisSdkBridgeRemoteError2 as QgisSdkBridgeRemoteError, QgisSdkBridgeSequenceError2 as QgisSdkBridgeSequenceError, QgisSdkBridgeStreamEndedError2 as QgisSdkBridgeStreamEndedError, QgisSdkBridgeTimeoutError2 as QgisSdkBridgeTimeoutError, QgisSdkContractError2 as QgisSdkContractError, QgisSdkContractValidationError2 as QgisSdkContractValidationError, QgisSdkCore2 as QgisSdkCore, QgisSdkDeclarationError2 as QgisSdkDeclarationError, QgisSdkError2 as QgisSdkError, QgisSdkHost2 as QgisSdkHost, QgisSdkHostTheme2 as QgisSdkHostTheme, QgisSdkOptions2 as QgisSdkOptions, QgisSdkStoreError2 as QgisSdkStoreError, QgisSdkValidationIssue2 as QgisSdkValidationIssue, QgisSdkWebChannelError, RangeValue, RunOutput2 as RunOutput, RunResult2 as RunResult, SerializedContractError2 as SerializedContractError, SerializedContractValidationError2 as SerializedContractValidationError, SerializedValidationIssue2 as SerializedValidationIssue, Store2 as Store, StoreListener2 as StoreListener, Stream2 as Stream, StreamDescription2 as StreamDescription, StreamEventKind2 as StreamEventKind, StreamHandle2 as StreamHandle, StreamHandleLike2 as StreamHandleLike, StreamHandlers2 as StreamHandlers, StreamHandlersLike2 as StreamHandlersLike, StreamMap2 as StreamMap, StreamMethod2 as StreamMethod, StreamShape2 as StreamShape, StreamState2 as StreamState, StreamStore2 as StreamStore, StreamTerminalKind2 as StreamTerminalKind, StreamTerminalLike2 as StreamTerminalLike, StreamTree2 as StreamTree, StreamsOf2 as StreamsOf, SubscriptionHandlers2 as SubscriptionHandlers, ValidateOptions2 as ValidateOptions, ValidationDirection2 as ValidationDirection, VectorLayerInfo2 as VectorLayerInfo, WebChannelTransport, WireTransport2 as WireTransport, createWebChannelTransport, defineBridgeSchema2 as defineBridgeSchema, formStore2 as formStore, insideQgis, isSafeJsonInteger2 as isSafeJsonInteger, labelFor2 as labelFor, layerFieldsQuery2 as layerFieldsQuery, layersQuery2 as layersQuery, outputsByName, parseInvokeReply2 as parseInvokeReply, parsePluginDescription2 as parsePluginDescription, parseStreamFrame2 as parseStreamFrame, runAlgorithm, schemaFields2 as schemaFields, stableKey2 as stableKey, validateAgainstSchema2 as validateAgainstSchema };