@tablecraft-app/plugin-api 1.6.0 → 1.7.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/explain.d.ts +6 -0
- package/dist/index.d.ts +1 -1
- package/dist/plugin.d.ts +13 -0
- package/dist/testing/index.js +19 -0
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/dist/explain.d.ts
CHANGED
|
@@ -26,6 +26,12 @@ export interface PlanNode {
|
|
|
26
26
|
/** Everything else the dialect reports about the step, in its order. */
|
|
27
27
|
readonly properties: readonly PlanProperty[];
|
|
28
28
|
readonly children: readonly PlanNode[];
|
|
29
|
+
/**
|
|
30
|
+
* What a reviewer should notice about the step, one sentence each, such as a full table scan or
|
|
31
|
+
* estimates made without statistics (decision 130). The host marks the step and lists each
|
|
32
|
+
* distinct sentence once. Absent or empty when there is nothing to say.
|
|
33
|
+
*/
|
|
34
|
+
readonly warnings?: readonly string[];
|
|
29
35
|
}
|
|
30
36
|
/** What `Session.explain` answers. */
|
|
31
37
|
export interface ExplainedPlan {
|
package/dist/index.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export { KEY_TYPES, type KeyApplied, type KeyApplyOptions, type KeyBytes, type K
|
|
|
7
7
|
export { OBJECT_KINDS, type CatalogObject, type CheckDesign, type ColumnDesign, type DdlContext, type DdlScript, type ForeignKeyDesign, type IndexDesign, type ObjectChange, type ObjectChangeKind, type ObjectEditor, type ObjectFeatures, type ObjectKind, type TableDesign, } from "./objects.js";
|
|
8
8
|
export { BRAND_ID, brandSchema, CONNECTION_FIELD_GROUPS, CONNECTION_FIELD_KINDS, CONNECTION_URL_FORMS, CONNECTION_URL_PARTS, connectionFieldSchema, connectionUrlSchema, MANIFEST_FILE, networkSpecSchema, pluginManifestSchema, TLS_FIELD_ROLES, tlsSpecSchema, type Brand, type ConnectionField, type ConnectionFieldGroup, type ConnectionFieldKind, type ConnectionUrl, type ConnectionUrlForm, type ConnectionUrlPart, type NetworkSpec, type PluginManifest, type TlsFieldRole, type TlsSpec, } from "./manifest.js";
|
|
9
9
|
export { ConnectionUrlError, formatConnectionUrl, parseConnectionUrl, type ConnectionForm, type ConnectionUrlSpec, type ConnectionValue, type ParsedConnectionUrl, } from "./url.js";
|
|
10
|
-
export { type BoundStatement, CAPABILITIES, type Capability, type Column, type ColumnOrigin, type CommandLanguage, type CommandReply, type ConnectOptions, type DatasourcePlugin, type ExecuteOptions, type ExecuteResult, type FormatOptions, FORMAT_STYLES, type FormatStyle, GENERATED_STATEMENTS, type GeneratedStatement, IMPORT_KINDS, type ImportKind, type InferredColumn, type InsertRow, type InsertTarget, KEYWORD_CASES, type NamespaceSwitch, NODE_ALL_PRIMARIES, NODE_AUTO, NODE_ROLES, type NodeRole, type ServerInfo, type ServerInfoSection, type ServerNode, type ServerTimeout, type SlowCommand, switchableTo, type NewColumn, type KeywordCase, PARAMETER_STYLES, type ParameterStyle, type ParameterValue, type RoutineArgument, type RoutineCall, type Row, type SavepointStatements, type SelectSource, omittedMessages, SERVER_MESSAGE_LEVELS, SERVER_MESSAGE_LIMIT, type ServerMessage, type ServerMessageLevel, type SqlParameter, type Session, type SqlLanguage, STATEMENT_KINDS, type StatementClass, type StatementKind, type StatementSpan, type StatementStream, type StreamedStatement, type TlsInfo, TRANSACTION_MODES, type TransactionMode, type Transactions, } from "./plugin.js";
|
|
10
|
+
export { type BoundStatement, CAPABILITIES, type Capability, type Column, type ColumnOrigin, type CommandLanguage, type CommandReply, type ConnectOptions, type DatasourcePlugin, type ExecuteOptions, type ExecuteResult, type FormatOptions, FORMAT_STYLES, type FormatStyle, GENERATED_STATEMENTS, type GeneratedStatement, IMPORT_KINDS, type ImportKind, type InferredColumn, type InsertRow, type InsertTarget, KEYWORD_CASES, type NamespaceSwitch, NODE_ALL_PRIMARIES, NODE_AUTO, NODE_ROLES, type NodeRole, type ServerInfo, type ServerInfoSection, type ServerNode, type ServerTimeout, type CancelReach, type SlowCommand, switchableTo, type NewColumn, type KeywordCase, PARAMETER_STYLES, type ParameterStyle, type ParameterValue, type RoutineArgument, type RoutineCall, type Row, type SavepointStatements, type SelectSource, omittedMessages, SERVER_MESSAGE_LEVELS, SERVER_MESSAGE_LIMIT, type ServerMessage, type ServerMessageLevel, type SqlParameter, type Session, type SqlLanguage, STATEMENT_KINDS, type StatementClass, type StatementKind, type StatementSpan, type StatementStream, type StreamedStatement, type TlsInfo, TRANSACTION_MODES, type TransactionMode, type Transactions, } from "./plugin.js";
|
|
11
11
|
export { SERVER_SESSION_STATES, type ServerSession, type ServerSessionState, type SessionListing, type SessionMonitor, type SessionTarget, } from "./sessions.js";
|
|
12
12
|
export { TLS_CHAIN_CODES, TLS_HOST_CODE, homeExpanded, tlsFailureMessage, tlsFileMessage, tlsKeyIsEncrypted, tlsKeyMessage, type TlsVerification, } from "./tls.js";
|
|
13
13
|
export { BYTES_PREVIEW_LENGTH, toBytesValue, toWireInteger, toWireValue, type WireValueOptions, type BigIntValue, type BytesValue, type DateValue, type JsonValue, type TypeClass, type WireValue, } from "./values.js";
|
package/dist/plugin.d.ts
CHANGED
|
@@ -148,6 +148,17 @@ export interface ServerTimeout {
|
|
|
148
148
|
*/
|
|
149
149
|
readonly counts: "statement" | "serverWork";
|
|
150
150
|
}
|
|
151
|
+
/** How `cancel` stops a running statement on this server (decision 131). */
|
|
152
|
+
export interface CancelReach {
|
|
153
|
+
/** What the plugin sends, for people: `KILL QUERY`, `pg_cancel_backend`, `CLIENT UNBLOCK`. */
|
|
154
|
+
readonly method: string;
|
|
155
|
+
/**
|
|
156
|
+
* `statement`: the server stops the work. `connection`: the plugin drops its connection and the
|
|
157
|
+
* server may keep running the statement. `blockingCommands`: only commands waiting on the server
|
|
158
|
+
* (Redis `BLPOP`) are stopped; the rest run to their end.
|
|
159
|
+
*/
|
|
160
|
+
readonly reaches: "statement" | "connection" | "blockingCommands";
|
|
161
|
+
}
|
|
151
162
|
/** `ExecuteOptions.node`: the plugin routes the command by its keys (decision 114). */
|
|
152
163
|
export declare const NODE_AUTO = "auto";
|
|
153
164
|
/** `ExecuteOptions.node`: the command runs once on every primary (decision 114). */
|
|
@@ -312,6 +323,8 @@ export interface Session {
|
|
|
312
323
|
* version has no such setting.
|
|
313
324
|
*/
|
|
314
325
|
readonly serverTimeout?: ServerTimeout | null;
|
|
326
|
+
/** Optional, only with `cancel`: how this session's cancel reaches the server, read once at connect. */
|
|
327
|
+
readonly cancelReach?: CancelReach;
|
|
315
328
|
}
|
|
316
329
|
/** What a TLS handshake agreed, as Node's socket names it: `TLSv1.3`, `TLS_AES_256_GCM_SHA384`. */
|
|
317
330
|
export interface TlsInfo {
|
package/dist/testing/index.js
CHANGED
|
@@ -179,6 +179,7 @@ const SLEEP_SECONDS = 30;
|
|
|
179
179
|
const CANCEL_DELAY_MS = 500;
|
|
180
180
|
/** Well under `SLEEP_SECONDS`, so a cancel that did nothing fails the test instead of passing late. */
|
|
181
181
|
const CANCEL_DEADLINE_MS = 10_000;
|
|
182
|
+
const CANCEL_REACHES = ["statement", "connection", "blockingCommands"];
|
|
182
183
|
/** The limit the `serverTimeout` cases ask for; servers check theirs about every 100 ms. */
|
|
183
184
|
const SERVER_LIMIT_MS = 1500;
|
|
184
185
|
/** Far past `SERVER_LIMIT_MS`, so a limit that did nothing fails the test instead of passing late. */
|
|
@@ -2161,6 +2162,24 @@ export function runPluginContract(plugin, fixture) {
|
|
|
2161
2162
|
await expectAlive(session);
|
|
2162
2163
|
});
|
|
2163
2164
|
});
|
|
2165
|
+
it("givenCancelReach_whenSessionOpens_thenMethodNamedAndReachKnown", async () => {
|
|
2166
|
+
await withSession(plugin, fixture, (session) => {
|
|
2167
|
+
const reach = session.cancelReach;
|
|
2168
|
+
if (reach === undefined)
|
|
2169
|
+
return Promise.resolve();
|
|
2170
|
+
expect(reach.method).toMatch(/\S/);
|
|
2171
|
+
expect(CANCEL_REACHES).toContain(reach.reaches);
|
|
2172
|
+
return Promise.resolve();
|
|
2173
|
+
});
|
|
2174
|
+
});
|
|
2175
|
+
});
|
|
2176
|
+
describe.runIf(!plugin.capabilities.includes("cancel"))("no cancel", () => {
|
|
2177
|
+
it("givenNoCancel_whenSessionOpens_thenNoCancelReach", async () => {
|
|
2178
|
+
await withSession(plugin, fixture, (session) => {
|
|
2179
|
+
expect(session.cancelReach).toBeUndefined();
|
|
2180
|
+
return Promise.resolve();
|
|
2181
|
+
});
|
|
2182
|
+
});
|
|
2164
2183
|
});
|
|
2165
2184
|
describe.runIf(plugin.capabilities.includes("serverTimeout"))("serverTimeout", () => {
|
|
2166
2185
|
function slowRead(seconds) {
|
package/dist/version.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* The plugin contract's version, by semver (decision 106): a host loads a plugin built for the same
|
|
3
3
|
* major and an older or equal minor. Typed `string` so a bump does not change the API report.
|
|
4
4
|
*/
|
|
5
|
-
export const API_VERSION = "1.
|
|
5
|
+
export const API_VERSION = "1.7.0";
|
|
6
6
|
const SEMVER = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/;
|
|
7
7
|
/** `major.minor.patch` and nothing else; pre-release and build tags are not accepted. */
|
|
8
8
|
export function parseVersion(text) {
|