@tablecraft-app/plugin-api 0.0.0-stage → 1.2.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/LICENSE +21 -0
- package/README.md +46 -2
- package/dist/catalog.d.ts +112 -0
- package/dist/catalog.js +5 -0
- package/dist/completion.d.ts +109 -0
- package/dist/completion.js +12 -0
- package/dist/errors.d.ts +67 -0
- package/dist/errors.js +124 -0
- package/dist/explain.d.ts +58 -0
- package/dist/explain.js +1 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +16 -0
- package/dist/inspection.d.ts +38 -0
- package/dist/inspection.js +21 -0
- package/dist/keyspace.d.ts +180 -0
- package/dist/keyspace.js +2 -0
- package/dist/manifest.d.ts +200 -0
- package/dist/manifest.js +238 -0
- package/dist/objects.d.ts +140 -0
- package/dist/objects.js +2 -0
- package/dist/plugin.d.ts +565 -0
- package/dist/plugin.js +58 -0
- package/dist/sessions.d.ts +59 -0
- package/dist/sessions.js +2 -0
- package/dist/sql/classify.d.ts +19 -0
- package/dist/sql/classify.js +95 -0
- package/dist/sql/complete.d.ts +23 -0
- package/dist/sql/complete.js +480 -0
- package/dist/sql/explain.d.ts +42 -0
- package/dist/sql/explain.js +108 -0
- package/dist/sql/format.d.ts +26 -0
- package/dist/sql/format.js +117 -0
- package/dist/sql/functions.d.ts +47 -0
- package/dist/sql/functions.js +159 -0
- package/dist/sql/generate.d.ts +22 -0
- package/dist/sql/generate.js +64 -0
- package/dist/sql/index.d.ts +16 -0
- package/dist/sql/index.js +16 -0
- package/dist/sql/inspect.d.ts +10 -0
- package/dist/sql/inspect.js +134 -0
- package/dist/sql/inspectContext.d.ts +78 -0
- package/dist/sql/inspectContext.js +251 -0
- package/dist/sql/inspectResolve.d.ts +6 -0
- package/dist/sql/inspectResolve.js +391 -0
- package/dist/sql/inspectStyle.d.ts +3 -0
- package/dist/sql/inspectStyle.js +384 -0
- package/dist/sql/inspectSyntax.d.ts +10 -0
- package/dist/sql/inspectSyntax.js +179 -0
- package/dist/sql/layout.d.ts +8 -0
- package/dist/sql/layout.js +114 -0
- package/dist/sql/layoutNodes.d.ts +46 -0
- package/dist/sql/layoutNodes.js +317 -0
- package/dist/sql/layoutPrint.d.ts +60 -0
- package/dist/sql/layoutPrint.js +806 -0
- package/dist/sql/layoutWriter.d.ts +21 -0
- package/dist/sql/layoutWriter.js +77 -0
- package/dist/sql/literals.d.ts +28 -0
- package/dist/sql/literals.js +78 -0
- package/dist/sql/namespace.d.ts +41 -0
- package/dist/sql/namespace.js +220 -0
- package/dist/sql/objects.d.ts +42 -0
- package/dist/sql/objects.js +222 -0
- package/dist/sql/parameters.d.ts +20 -0
- package/dist/sql/parameters.js +88 -0
- package/dist/sql/resolution.d.ts +73 -0
- package/dist/sql/resolution.js +192 -0
- package/dist/sql/routines.d.ts +27 -0
- package/dist/sql/routines.js +42 -0
- package/dist/sql/scope.d.ts +117 -0
- package/dist/sql/scope.js +540 -0
- package/dist/sql/select.d.ts +41 -0
- package/dist/sql/select.js +287 -0
- package/dist/sql/signature.d.ts +18 -0
- package/dist/sql/signature.js +137 -0
- package/dist/sql/splitter.d.ts +15 -0
- package/dist/sql/splitter.js +217 -0
- package/dist/sql/suggest.d.ts +6 -0
- package/dist/sql/suggest.js +36 -0
- package/dist/sql/tokens.d.ts +62 -0
- package/dist/sql/tokens.js +227 -0
- package/dist/sql/words.d.ts +23 -0
- package/dist/sql/words.js +72 -0
- package/dist/testing/index.d.ts +274 -0
- package/dist/testing/index.js +2398 -0
- package/dist/tls.d.ts +33 -0
- package/dist/tls.js +118 -0
- package/dist/url.d.ts +54 -0
- package/dist/url.js +228 -0
- package/dist/values.d.ts +44 -0
- package/dist/values.js +44 -0
- package/dist/version.d.ts +22 -0
- package/dist/version.js +29 -0
- package/package.json +42 -4
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import type { Relation } from "./catalog.js";
|
|
2
|
+
/** What the database tree can rename or drop (decision 052). */
|
|
3
|
+
export declare const OBJECT_KINDS: readonly ["table", "view", "materializedView", "sequence", "function", "procedure"];
|
|
4
|
+
export type ObjectKind = (typeof OBJECT_KINDS)[number];
|
|
5
|
+
/** One object in a namespace, named as the catalog names it. */
|
|
6
|
+
export interface CatalogObject {
|
|
7
|
+
readonly kind: ObjectKind;
|
|
8
|
+
readonly name: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* A column of a table design. `original` is the name the column has in the database, null for a
|
|
12
|
+
* column the design adds, so a rename is told apart from a drop and an add.
|
|
13
|
+
*/
|
|
14
|
+
export interface ColumnDesign {
|
|
15
|
+
readonly name: string;
|
|
16
|
+
readonly type: string;
|
|
17
|
+
readonly nullable: boolean;
|
|
18
|
+
/** A SQL expression, written as the column's `DEFAULT` clause takes it; null for none. */
|
|
19
|
+
readonly default: string | null;
|
|
20
|
+
readonly autoIncrement: boolean;
|
|
21
|
+
readonly comment: string | null;
|
|
22
|
+
readonly original: string | null;
|
|
23
|
+
}
|
|
24
|
+
export interface IndexDesign {
|
|
25
|
+
readonly name: string;
|
|
26
|
+
readonly columns: readonly string[];
|
|
27
|
+
readonly unique: boolean;
|
|
28
|
+
/** The index's name in the database, null for one the design adds. */
|
|
29
|
+
readonly original: string | null;
|
|
30
|
+
}
|
|
31
|
+
export interface ForeignKeyDesign {
|
|
32
|
+
readonly name: string;
|
|
33
|
+
readonly columns: readonly string[];
|
|
34
|
+
readonly target: {
|
|
35
|
+
readonly path: readonly string[];
|
|
36
|
+
readonly relation: string;
|
|
37
|
+
readonly columns: readonly string[];
|
|
38
|
+
};
|
|
39
|
+
/** The referential action as the dialect spells it, such as `CASCADE`; null for the default. */
|
|
40
|
+
readonly onDelete: string | null;
|
|
41
|
+
readonly onUpdate: string | null;
|
|
42
|
+
readonly original: string | null;
|
|
43
|
+
}
|
|
44
|
+
export interface CheckDesign {
|
|
45
|
+
readonly name: string;
|
|
46
|
+
readonly expression: string;
|
|
47
|
+
readonly original: string | null;
|
|
48
|
+
}
|
|
49
|
+
/** A table as the Create and Modify Table dialog edits it (decision 052). */
|
|
50
|
+
export interface TableDesign {
|
|
51
|
+
readonly name: string;
|
|
52
|
+
readonly comment: string | null;
|
|
53
|
+
readonly columns: readonly ColumnDesign[];
|
|
54
|
+
/** Column names in key order; empty for no primary key. */
|
|
55
|
+
readonly primaryKey: readonly string[];
|
|
56
|
+
/** The primary key constraint's name in the database, null when the table has none yet. */
|
|
57
|
+
readonly primaryKeyName: string | null;
|
|
58
|
+
readonly indexes: readonly IndexDesign[];
|
|
59
|
+
readonly foreignKeys: readonly ForeignKeyDesign[];
|
|
60
|
+
readonly checks: readonly CheckDesign[];
|
|
61
|
+
}
|
|
62
|
+
/** One change to the catalog of `path`, which the plugin turns into a `DdlScript`. */
|
|
63
|
+
export type ObjectChange = {
|
|
64
|
+
readonly kind: "createTable";
|
|
65
|
+
readonly path: readonly string[];
|
|
66
|
+
readonly design: TableDesign;
|
|
67
|
+
} | {
|
|
68
|
+
readonly kind: "alterTable";
|
|
69
|
+
readonly path: readonly string[];
|
|
70
|
+
readonly relation: string;
|
|
71
|
+
readonly design: TableDesign;
|
|
72
|
+
} | {
|
|
73
|
+
readonly kind: "rename";
|
|
74
|
+
readonly path: readonly string[];
|
|
75
|
+
readonly object: CatalogObject;
|
|
76
|
+
readonly name: string;
|
|
77
|
+
} | {
|
|
78
|
+
readonly kind: "drop";
|
|
79
|
+
readonly path: readonly string[];
|
|
80
|
+
readonly object: CatalogObject;
|
|
81
|
+
readonly cascade: boolean;
|
|
82
|
+
} | {
|
|
83
|
+
readonly kind: "truncate";
|
|
84
|
+
readonly path: readonly string[];
|
|
85
|
+
readonly relation: string;
|
|
86
|
+
readonly cascade: boolean;
|
|
87
|
+
}
|
|
88
|
+
/** A schema or database inside `path`; `path` is empty for a top-level one. */
|
|
89
|
+
| {
|
|
90
|
+
readonly kind: "createNamespace";
|
|
91
|
+
readonly path: readonly string[];
|
|
92
|
+
readonly name: string;
|
|
93
|
+
};
|
|
94
|
+
export type ObjectChangeKind = ObjectChange["kind"];
|
|
95
|
+
/**
|
|
96
|
+
* The statements for one change. The host runs `prepare` and `finish` outside any transaction on
|
|
97
|
+
* the session it opens for the change, `statements` in one transaction when `transactional`, then
|
|
98
|
+
* each of `verify`, which must return no row, before it commits.
|
|
99
|
+
*/
|
|
100
|
+
export interface DdlScript {
|
|
101
|
+
readonly prepare: readonly string[];
|
|
102
|
+
readonly statements: readonly string[];
|
|
103
|
+
readonly verify: readonly string[];
|
|
104
|
+
readonly finish: readonly string[];
|
|
105
|
+
readonly transactional: boolean;
|
|
106
|
+
/** What the preview tells the user before they run it, such as an implicit commit. */
|
|
107
|
+
readonly notes: readonly string[];
|
|
108
|
+
}
|
|
109
|
+
/** What a dialect lets the tree and the table dialog offer; the UI reads these, never a plugin id. */
|
|
110
|
+
export interface ObjectFeatures {
|
|
111
|
+
/** Column types the dialog suggests, most common first. */
|
|
112
|
+
readonly types: readonly string[];
|
|
113
|
+
readonly checks: boolean;
|
|
114
|
+
readonly comments: boolean;
|
|
115
|
+
/** Whether Drop and Truncate take `CASCADE`. */
|
|
116
|
+
readonly cascade: boolean;
|
|
117
|
+
readonly truncate: boolean;
|
|
118
|
+
/** What New ▸ creates inside a namespace, or null when the dialect creates none. */
|
|
119
|
+
readonly namespaceKind: "schema" | "database" | null;
|
|
120
|
+
readonly renamable: readonly ObjectKind[];
|
|
121
|
+
readonly droppable: readonly ObjectKind[];
|
|
122
|
+
}
|
|
123
|
+
/** What the host knows that a script needs: names as the introspector qualifies them, and the table as it is. */
|
|
124
|
+
export interface DdlContext {
|
|
125
|
+
qualifiedName(path: readonly string[], name: string): string;
|
|
126
|
+
/** For `alterTable`, the design of the table as the catalog describes it now; otherwise null. */
|
|
127
|
+
readonly current: TableDesign | null;
|
|
128
|
+
}
|
|
129
|
+
/** Present exactly when the plugin declares `objects` (decision 052). Pure: it never runs SQL. */
|
|
130
|
+
export interface ObjectEditor {
|
|
131
|
+
readonly features: ObjectFeatures;
|
|
132
|
+
/** The design of a described table, every name its `original`. */
|
|
133
|
+
design(relation: Relation): TableDesign;
|
|
134
|
+
/**
|
|
135
|
+
* The statements for `change`; an `alterTable` gets only the ones its difference from
|
|
136
|
+
* `context.current` needs. Throws a `PluginError` coded `statementFailed` saying what to change
|
|
137
|
+
* when the dialect cannot express it.
|
|
138
|
+
*/
|
|
139
|
+
script(change: ObjectChange, context: DdlContext): DdlScript;
|
|
140
|
+
}
|
package/dist/objects.js
ADDED