@archont561/qgis-sdk 0.3.0 → 0.4.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,67 @@
1
- /**
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;
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 "./shared/chunk-khemhx86.js";
3
+ import { OperationShape2, StreamShape2, OperationMap2, StreamMap2, BridgeSchema2, OperationsOf2, StreamsOf2, defineBridgeSchema2 } from "./shared/chunk-jjx14tgd.js";
4
+ import { QgisSdkOptions2, StreamHandlers2, StreamHandle2, OperationMethod2, StreamMethod2, QgisSdkHost2, QgisSdkCore2, OperationTree2, StreamTree2, QGIS_SDK_MEMBERS2, QgisSdk2 } from "./shared/chunk-tmca1ynt.js";
5
+ import { QgisSdkError2 } from "./shared/chunk-pdj2fxjb.js";
6
+ /** One schema of the declared dialect, as the description carries it. */
7
+ type DeclaredSchema = Readonly<Record<string, unknown>>;
8
+ /** Options for {@link validateAgainstSchema}. */
9
+ interface ValidateOptions {
10
+ /** Ignore properties the schema does not name (results and events). */
11
+ readonly allowUnknown?: boolean;
12
+ /** Where the value sits, prefixed to every issue's path. */
13
+ readonly path?: readonly (string | number)[];
14
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 {
15
+ /** Which side of a call a contract issue belongs to. */
16
+ type ContractDirection = "request" | "result" | "event";
17
+ /** The JSON form of {@link QgisSdkContractError}. */
18
+ interface SerializedContractError {
57
19
  readonly code: string;
58
- constructor(message: string, code?: string);
20
+ readonly operation: string;
21
+ readonly direction: ContractDirection;
22
+ readonly issues: SerializedValidationIssue2[];
59
23
  }
60
24
  /**
61
- * An operation attempted to use an already disposed owner scope.
62
- */
63
- declare class QgisSdkScopeClosedError extends QgisSdkError {
64
- constructor();
65
- }
66
- /**
67
- * The selected runtime does not offer an explicitly requested capability.
25
+ * An argument, a reply or an event does not match the declared contract.
26
+ *
27
+ * The code is the one both languages use for this category, so a page that
28
+ * already matches `contract_validation_failed` needs no second branch.
68
29
  */
69
- declare class QgisSdkUnsupportedCapabilityError extends QgisSdkError {
70
- readonly capability: string;
71
- constructor(capability: string);
30
+ declare class QgisSdkContractError extends QgisSdkError2 {
31
+ readonly operation: string;
32
+ readonly direction: ContractDirection;
33
+ readonly issues: readonly QgisSdkValidationIssue2[];
34
+ constructor(operation: string, direction: ContractDirection, issues: readonly QgisSdkValidationIssue2[]);
35
+ toJSON(): SerializedContractError;
72
36
  }
73
37
  /**
74
- * A declaration cannot be represented or parsed in the versioned contract.
38
+ * Return every issue `value` has against `schema`; an empty array is a match.
39
+ *
40
+ * Throws {@link QgisSdkDeclarationError} when `schema` leaves the declared
41
+ * dialect, because that is a fault in the declaration, never in the value.
75
42
  */
76
- declare class QgisSdkDeclarationError extends QgisSdkError {
43
+ declare function validateAgainstSchema(value: unknown, schema: DeclaredSchema, options?: ValidateOptions): QgisSdkValidationIssue2[];
44
+ /** The web view did not provide a usable channel. */
45
+ declare class QgisSdkWebChannelError extends QgisSdkError2 {
77
46
  constructor(message: string);
78
47
  }
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;
87
- }
88
- /**
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;
48
+ /** The transport {@link createWebChannelTransport} returns. */
49
+ interface WebChannelTransport extends WireTransport2 {
50
+ /** Resolves once the channel object answered; rejects when it never will. */
51
+ readonly ready: Promise<void>;
52
+ /** Stop forwarding messages; sends after this throw. */
53
+ close(): void;
96
54
  }
55
+ /** True inside a QGIS web view, where Qt injected its transport and script. */
56
+ declare function insideQgis(): boolean;
97
57
  /**
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`.
58
+ * Connect to the channel object `objectName` and return a transport on it.
59
+ *
60
+ * Throws {@link QgisSdkWebChannelError} synchronously outside a QGIS web view,
61
+ * so a page learns in its first statement that it has no host to talk to.
62
+ * Inside one, messages sent before the channel is ready are queued and
63
+ * delivered in order once it is; `ready` rejects (and queued sends are
64
+ * dropped) when the host registered no object under that name.
104
65
  */
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 };
66
+ declare function createWebChannelTransport(objectName?: string): WebChannelTransport;
67
+ export { ActionDescription2 as ActionDescription, 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, ContractDirection, DeclaredSchema, InvokeOptions2 as InvokeOptions, InvokeReply2 as InvokeReply, MAX_CALL_ID_LENGTH2 as MAX_CALL_ID_LENGTH, MAX_SAFE_INTEGER2 as MAX_SAFE_INTEGER, MIN_SAFE_INTEGER2 as MIN_SAFE_INTEGER, OperationMap2 as OperationMap, OperationMethod2 as OperationMethod, OperationShape2 as OperationShape, OperationTree2 as OperationTree, OperationsOf2 as OperationsOf, PLUGIN_DESCRIPTION_SCHEMA_VERSION2 as PLUGIN_DESCRIPTION_SCHEMA_VERSION, PluginDescription2 as PluginDescription, 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, QgisSdkContractError, QgisSdkContractValidationError2 as QgisSdkContractValidationError, QgisSdkCore2 as QgisSdkCore, QgisSdkDeclarationError2 as QgisSdkDeclarationError, QgisSdkError2 as QgisSdkError, QgisSdkHost2 as QgisSdkHost, QgisSdkOptions2 as QgisSdkOptions, QgisSdkValidationIssue2 as QgisSdkValidationIssue, QgisSdkWebChannelError, SerializedContractError, SerializedContractValidationError2 as SerializedContractValidationError, SerializedValidationIssue2 as SerializedValidationIssue, StreamDescription2 as StreamDescription, StreamEventKind2 as StreamEventKind, StreamHandle2 as StreamHandle, StreamHandlers2 as StreamHandlers, StreamMap2 as StreamMap, StreamMethod2 as StreamMethod, StreamShape2 as StreamShape, StreamTerminalKind2 as StreamTerminalKind, StreamTree2 as StreamTree, StreamsOf2 as StreamsOf, SubscriptionHandlers2 as SubscriptionHandlers, ValidateOptions, ValidationDirection2 as ValidationDirection, WebChannelTransport, WireTransport2 as WireTransport, createWebChannelTransport, defineBridgeSchema2 as defineBridgeSchema, insideQgis, isSafeJsonInteger2 as isSafeJsonInteger, parseInvokeReply2 as parseInvokeReply, parsePluginDescription2 as parsePluginDescription, parseStreamFrame2 as parseStreamFrame, validateAgainstSchema };