@tablecraft-app/plugin-api 1.2.0 → 1.3.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 +1 -1
- package/dist/keyspace.d.ts +12 -0
- package/dist/plugin.d.ts +13 -2
- package/dist/testing/index.d.ts +14 -1
- package/dist/testing/index.js +11 -0
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ export { COMPLETION_KINDS, type CompletionCatalog, type CompletionItem, type Com
|
|
|
3
3
|
export { INSPECTION_IDS, type InspectionId, type InspectionRequest, type Problem, PROBLEM_SEVERITIES, type ProblemSeverity, type QuickFix, type TextEdit, } from "./inspection.js";
|
|
4
4
|
export { ConflictError, DefinitionNotFoundError, type ErrorPosition, errorPositionOf, isPluginError, isTlsSettingsError, offsetOfPosition, PLUGIN_ERROR_CODES, PluginError, type PluginErrorCode, type PluginErrorOptions, TlsSettingsError, } from "./errors.js";
|
|
5
5
|
export { type ExplainedPlan, type Explainability, type ExplainOptions, type PlanNode, type PlanProperty, } from "./explain.js";
|
|
6
|
-
export { KEY_TYPES, type KeyApplied, type KeyApplyOptions, type KeyBytes, type KeyChange, type KeyContents, type KeyDatabase, type KeyDetails, type KeyExpiry, type KeyInfo, type KeyName, type KeyReadRequest, type KeyScan, type KeyScanRequest, type Keyspace, type KeyType, } from "./keyspace.js";
|
|
6
|
+
export { KEY_TYPES, type KeyApplied, type KeyApplyOptions, type KeyBytes, type KeyChange, type KeyContents, type KeyDatabase, type KeyDetails, type KeyExpiry, type KeyInfo, type KeyName, type KeyReadRequest, type KeyScan, type KeyScanRequest, type KeySource, type Keyspace, type KeyType, } from "./keyspace.js";
|
|
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 { CONNECTION_FIELD_GROUPS, CONNECTION_FIELD_KINDS, CONNECTION_URL_FORMS, CONNECTION_URL_PARTS, connectionFieldSchema, connectionUrlSchema, MANIFEST_FILE, networkSpecSchema, pluginManifestSchema, TLS_FIELD_ROLES, tlsSpecSchema, 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";
|
package/dist/keyspace.d.ts
CHANGED
|
@@ -15,6 +15,18 @@ export interface KeyBytes {
|
|
|
15
15
|
}
|
|
16
16
|
/** A key's name: bytes, since a key may be any binary string. */
|
|
17
17
|
export type KeyName = KeyBytes;
|
|
18
|
+
/**
|
|
19
|
+
* The one key a command's reply was read from (decision 119), so the host can open the key or
|
|
20
|
+
* edit the reply as the key. `whole` is true when the reply holds the entire key, such as
|
|
21
|
+
* `HGETALL` or `LRANGE k 0 -1`; its columns are then the ones `Keyspace.read` gives that type,
|
|
22
|
+
* without positions a key tab adds (a zset's `#`), and a string's is one `value` column.
|
|
23
|
+
*/
|
|
24
|
+
export interface KeySource {
|
|
25
|
+
readonly database: number;
|
|
26
|
+
readonly key: KeyName;
|
|
27
|
+
readonly type: KeyType;
|
|
28
|
+
readonly whole: boolean;
|
|
29
|
+
}
|
|
18
30
|
/** One logical database of the keyspace: Redis' `db0`–`db15`, or the one database of a cluster. */
|
|
19
31
|
export interface KeyDatabase {
|
|
20
32
|
readonly index: number;
|
package/dist/plugin.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type { Introspector, Namespace, Relation, Routine } from "./catalog.js";
|
|
|
3
3
|
import type { CompletionCatalog, CompletionRequest, CompletionResult, Declaration, ResolveRequest, SignatureHelp } from "./completion.js";
|
|
4
4
|
import type { ExplainedPlan, Explainability, ExplainOptions } from "./explain.js";
|
|
5
5
|
import type { InspectionRequest, Problem } from "./inspection.js";
|
|
6
|
-
import type { Keyspace } from "./keyspace.js";
|
|
6
|
+
import type { KeySource, Keyspace } from "./keyspace.js";
|
|
7
7
|
import type { ObjectEditor } from "./objects.js";
|
|
8
8
|
import type { SessionMonitor } from "./sessions.js";
|
|
9
9
|
import type { TypeClass, WireValue } from "./values.js";
|
|
@@ -58,16 +58,27 @@ export interface ExecuteResult {
|
|
|
58
58
|
readonly messages?: readonly ServerMessage[];
|
|
59
59
|
/**
|
|
60
60
|
* A command's one-value answer, such as a status, a number or a string (decision 112): the
|
|
61
|
-
* console shows it in Output and opens no result
|
|
61
|
+
* console shows it in Output and opens no result unless it is `read`. Only a `commands` plugin sets it, and then
|
|
62
62
|
* `columns` and `rows` are empty.
|
|
63
63
|
*/
|
|
64
64
|
readonly reply?: CommandReply;
|
|
65
|
+
/**
|
|
66
|
+
* The one key the command read, when it read exactly one (decision 119); absent for writes,
|
|
67
|
+
* keyless and multi-key commands. Only a `keyValue` plugin sets it.
|
|
68
|
+
*/
|
|
69
|
+
readonly source?: KeySource;
|
|
65
70
|
}
|
|
66
71
|
/** A scalar reply to a command (decision 112). */
|
|
67
72
|
export interface CommandReply {
|
|
68
73
|
readonly value: WireValue;
|
|
69
74
|
/** The reply as the server's own client prints it: `"Ann"`, `(integer) 5`, `(nil)`, `OK`. */
|
|
70
75
|
readonly text: string;
|
|
76
|
+
/**
|
|
77
|
+
* The reply is a value read, such as a bulk string from `GET` or `HGET` or the nil of a missing
|
|
78
|
+
* one (decision 119): the console opens it as a one-row `value` result besides Output. Absent
|
|
79
|
+
* for statuses, numbers and errors, which stay in Output.
|
|
80
|
+
*/
|
|
81
|
+
readonly read?: boolean;
|
|
71
82
|
}
|
|
72
83
|
/** How serious a `ServerMessage` is, from the server's own word for it. */
|
|
73
84
|
export declare const SERVER_MESSAGE_LEVELS: readonly ["error", "warning", "notice", "info"];
|
package/dist/testing/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { z, type DatasourcePlugin, type KeyChange, type KeyContents, type KeyType, type PluginManifest, type Routine, type RoutineArgument, type Row, type ServerMessage } from "@tablecraft-app/plugin-api";
|
|
1
|
+
import { z, type DatasourcePlugin, type KeyChange, type KeyContents, type KeySource, type KeyType, type PluginManifest, type Routine, type RoutineArgument, type Row, type ServerMessage } from "@tablecraft-app/plugin-api";
|
|
2
2
|
export interface ContractFixture {
|
|
3
3
|
/** The plugin's parsed `table-craft-plugin.json`, whose connection form the suite checks. */
|
|
4
4
|
readonly manifest: PluginManifest;
|
|
@@ -201,6 +201,19 @@ export interface KeyspaceFixture {
|
|
|
201
201
|
};
|
|
202
202
|
/** A scratch key the suite creates, changes and removes. */
|
|
203
203
|
readonly edit: KeyEditFixture;
|
|
204
|
+
/**
|
|
205
|
+
* Commands run in a console and the key each reply names as its source, null for none
|
|
206
|
+
* (decision 119): one that reads a whole key, one that reads part of one, and one that reads
|
|
207
|
+
* several. Without it the reply-source tests are skipped.
|
|
208
|
+
*/
|
|
209
|
+
readonly sources?: readonly KeySourceFixture[];
|
|
210
|
+
}
|
|
211
|
+
/** A command and the source its reply names (decision 119). */
|
|
212
|
+
export interface KeySourceFixture {
|
|
213
|
+
readonly command: string;
|
|
214
|
+
readonly source: KeySource | null;
|
|
215
|
+
/** The reply is a value read, which the console opens as a one-row result. */
|
|
216
|
+
readonly read?: boolean;
|
|
204
217
|
}
|
|
205
218
|
/** How the suite changes one element of a scratch key and reads it back (decision 115). */
|
|
206
219
|
export interface KeyEditFixture {
|
package/dist/testing/index.js
CHANGED
|
@@ -1934,6 +1934,17 @@ export function runPluginContract(plugin, fixture) {
|
|
|
1934
1934
|
expect(cursor).toBeNull();
|
|
1935
1935
|
return { keys, batches };
|
|
1936
1936
|
}
|
|
1937
|
+
it.runIf(fixture.keyspace?.sources !== undefined)("givenSingleKeyRead_whenExecute_thenReplyNamesItsSourceKey", async () => {
|
|
1938
|
+
await withSession(plugin, fixture, async (session) => {
|
|
1939
|
+
for (const expected of keyspaceFixture().sources ?? []) {
|
|
1940
|
+
const result = await session.execute(expected.command);
|
|
1941
|
+
await collect(result.rows);
|
|
1942
|
+
expect(result.source ?? null, expected.command).toEqual(expected.source);
|
|
1943
|
+
if (expected.read !== undefined)
|
|
1944
|
+
expect(result.reply?.read ?? false, expected.command).toBe(expected.read);
|
|
1945
|
+
}
|
|
1946
|
+
});
|
|
1947
|
+
});
|
|
1937
1948
|
it("givenKeyspace_whenDatabases_thenFixtureDatabaseCountedAndOneCurrent", async () => {
|
|
1938
1949
|
await withSession(plugin, fixture, async (session) => {
|
|
1939
1950
|
const databases = await keyspaceOf(session).databases();
|
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.3.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) {
|