@tablecraft-app/plugin-postgres 1.2.2 → 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/index.js +74 -15
- package/package.json +2 -2
- package/table-craft-plugin.json +2 -2
package/index.js
CHANGED
|
@@ -10819,7 +10819,11 @@ var CAPABILITIES$1 = [
|
|
|
10819
10819
|
"objects",
|
|
10820
10820
|
"serverMessages",
|
|
10821
10821
|
"sessions",
|
|
10822
|
-
"routineCall"
|
|
10822
|
+
"routineCall",
|
|
10823
|
+
"commands",
|
|
10824
|
+
"keyValue",
|
|
10825
|
+
"nodes",
|
|
10826
|
+
"serverInfo"
|
|
10823
10827
|
];
|
|
10824
10828
|
/** The message that stands for the ones past `SERVER_MESSAGE_LIMIT`. */
|
|
10825
10829
|
function omittedMessages(count) {
|
|
@@ -10887,8 +10891,28 @@ var connectionFieldSchema = strictObject({
|
|
|
10887
10891
|
label: string$1().min(1)
|
|
10888
10892
|
})).min(1).optional(),
|
|
10889
10893
|
group: _enum(CONNECTION_FIELD_GROUPS).optional(),
|
|
10890
|
-
secret: boolean().optional()
|
|
10894
|
+
secret: boolean().optional(),
|
|
10895
|
+
/**
|
|
10896
|
+
* Draw the field only while the `select` or `checkbox` named by `key` holds `equals` (plan 058);
|
|
10897
|
+
* a hidden field is neither checked nor required.
|
|
10898
|
+
*/
|
|
10899
|
+
visibleWhen: strictObject({
|
|
10900
|
+
key: string$1().regex(FIELD_KEY),
|
|
10901
|
+
equals: union([string$1(), boolean()])
|
|
10902
|
+
}).optional()
|
|
10891
10903
|
});
|
|
10904
|
+
/** `server`: `scheme://user:password@host:port/database?params`; `file`: a path, bare or as a URL. */
|
|
10905
|
+
var CONNECTION_URL_FORMS = ["server", "file"];
|
|
10906
|
+
/** The pieces of a connection URL a field can take; `path` belongs to the `file` form. */
|
|
10907
|
+
var CONNECTION_URL_PARTS = [
|
|
10908
|
+
"host",
|
|
10909
|
+
"port",
|
|
10910
|
+
"database",
|
|
10911
|
+
"user",
|
|
10912
|
+
"password",
|
|
10913
|
+
"path"
|
|
10914
|
+
];
|
|
10915
|
+
var URL_SCHEME = /^[a-z][a-z0-9+.-]*$/;
|
|
10892
10916
|
/**
|
|
10893
10917
|
* How a connection URL maps onto the form's fields (decision 055), so the host parses and writes
|
|
10894
10918
|
* one without running plugin code. `parts` names the field each piece of the URL fills; a query
|
|
@@ -10897,21 +10921,23 @@ var connectionFieldSchema = strictObject({
|
|
|
10897
10921
|
*/
|
|
10898
10922
|
var connectionUrlSchema = strictObject({
|
|
10899
10923
|
/** Without `://`; the first is the one the host writes. */
|
|
10900
|
-
schemes: array(string$1().regex(
|
|
10901
|
-
form: _enum(
|
|
10902
|
-
parts: partialRecord(_enum(
|
|
10903
|
-
"host",
|
|
10904
|
-
"port",
|
|
10905
|
-
"database",
|
|
10906
|
-
"user",
|
|
10907
|
-
"password",
|
|
10908
|
-
"path"
|
|
10909
|
-
]), string$1().regex(FIELD_KEY)),
|
|
10924
|
+
schemes: array(string$1().regex(URL_SCHEME, { message: "expected a lower-case URL scheme" })).min(1),
|
|
10925
|
+
form: _enum(CONNECTION_URL_FORMS),
|
|
10926
|
+
parts: partialRecord(_enum(CONNECTION_URL_PARTS), string$1().regex(FIELD_KEY)),
|
|
10910
10927
|
params: array(strictObject({
|
|
10911
10928
|
name: string$1().min(1),
|
|
10912
10929
|
key: string$1().regex(FIELD_KEY),
|
|
10913
10930
|
values: record(string$1(), string$1()).optional()
|
|
10914
|
-
})).optional()
|
|
10931
|
+
})).optional(),
|
|
10932
|
+
/**
|
|
10933
|
+
* Field values a scheme implies, keyed by scheme, such as `rediss` setting the TLS mode (plan
|
|
10934
|
+
* 058). A pasted URL fills them; a written URL takes the first scheme whose values the config holds.
|
|
10935
|
+
*/
|
|
10936
|
+
sets: record(string$1().regex(URL_SCHEME), record(string$1().regex(FIELD_KEY), union([
|
|
10937
|
+
string$1(),
|
|
10938
|
+
number$1(),
|
|
10939
|
+
boolean()
|
|
10940
|
+
]))).optional()
|
|
10915
10941
|
});
|
|
10916
10942
|
/**
|
|
10917
10943
|
* Which fields hold the server's address (decision 070), so the host can open an SSH tunnel and
|
|
@@ -10979,6 +11005,24 @@ function tlsFieldsDeclared(connection) {
|
|
|
10979
11005
|
return field !== void 0 && tlsFieldFits(role, field, tls);
|
|
10980
11006
|
});
|
|
10981
11007
|
}
|
|
11008
|
+
/** Every `visibleWhen` names another field of the form, a `select` or a `checkbox`. */
|
|
11009
|
+
function visibilityFieldsDeclared(connection) {
|
|
11010
|
+
return connection.fields.every((field) => {
|
|
11011
|
+
const condition = field.visibleWhen;
|
|
11012
|
+
if (condition === void 0) return true;
|
|
11013
|
+
const source = connection.fields.find((candidate) => candidate.key === condition.key);
|
|
11014
|
+
return source !== void 0 && source !== field && (source.kind === "select" || source.kind === "checkbox") && typeof condition.equals === (source.kind === "checkbox" ? "boolean" : "string");
|
|
11015
|
+
});
|
|
11016
|
+
}
|
|
11017
|
+
/** Every scheme `url.sets` keys is one of `url.schemes`, and every value it sets is a declared field's. */
|
|
11018
|
+
function urlSetsDeclared(connection) {
|
|
11019
|
+
const url = connection.url;
|
|
11020
|
+
if (url?.sets === void 0) return true;
|
|
11021
|
+
return Object.entries(url.sets).every(([scheme, values]) => url.schemes.includes(scheme) && Object.keys(values).every((key) => connection.fields.some((field) => field.key === key)));
|
|
11022
|
+
}
|
|
11023
|
+
function includesAny(capabilities, ...wanted) {
|
|
11024
|
+
return wanted.some((capability) => capabilities.includes(capability));
|
|
11025
|
+
}
|
|
10982
11026
|
strictObject({
|
|
10983
11027
|
id: string$1().regex(PLUGIN_ID$1, { message: "expected lower-case letters, digits and dashes" }),
|
|
10984
11028
|
name: string$1().min(1),
|
|
@@ -11002,7 +11046,22 @@ strictObject({
|
|
|
11002
11046
|
}).refine(tlsFieldsDeclared, {
|
|
11003
11047
|
message: "tls names a field the form does not declare or one of the wrong kind: mode a select offering every verify mode, files of kind file, the passphrase a secret password",
|
|
11004
11048
|
path: ["tls"]
|
|
11049
|
+
}).refine(visibilityFieldsDeclared, {
|
|
11050
|
+
message: "visibleWhen names a field the form does not declare, the field itself, or one that is not a select or checkbox, or compares it with a value of the wrong type",
|
|
11051
|
+
path: ["fields"]
|
|
11052
|
+
}).refine(urlSetsDeclared, {
|
|
11053
|
+
message: "url.sets names a scheme the url does not list, or a field the form does not declare",
|
|
11054
|
+
path: ["url"]
|
|
11005
11055
|
})
|
|
11056
|
+
}).refine((manifest) => !(manifest.capabilities.includes("commands") && manifest.capabilities.includes("sql")), {
|
|
11057
|
+
message: "the commands and sql capabilities exclude each other",
|
|
11058
|
+
path: ["capabilities"]
|
|
11059
|
+
}).refine((manifest) => !manifest.capabilities.includes("keyValue") || manifest.capabilities.includes("commands"), {
|
|
11060
|
+
message: "the keyValue capability requires commands",
|
|
11061
|
+
path: ["capabilities"]
|
|
11062
|
+
}).refine((manifest) => !includesAny(manifest.capabilities, "nodes", "serverInfo") || includesAny(manifest.capabilities, "sql", "commands"), {
|
|
11063
|
+
message: "the nodes and serverInfo capabilities require sql or commands",
|
|
11064
|
+
path: ["capabilities"]
|
|
11006
11065
|
}).refine((manifest) => !manifest.capabilities.includes("ddl") || manifest.capabilities.includes("schemaTree"), {
|
|
11007
11066
|
message: "the ddl capability requires schemaTree",
|
|
11008
11067
|
path: ["capabilities"]
|
|
@@ -11021,8 +11080,8 @@ strictObject({
|
|
|
11021
11080
|
}).refine((manifest) => !manifest.capabilities.includes("objects") || manifest.capabilities.includes("sql") && manifest.capabilities.includes("schemaTree"), {
|
|
11022
11081
|
message: "the objects capability requires sql and schemaTree",
|
|
11023
11082
|
path: ["capabilities"]
|
|
11024
|
-
}).refine((manifest) => !manifest.capabilities.includes("sessions") || manifest.capabilities
|
|
11025
|
-
message: "the sessions capability requires sql and schemaTree",
|
|
11083
|
+
}).refine((manifest) => !manifest.capabilities.includes("sessions") || includesAny(manifest.capabilities, "sql", "commands") && includesAny(manifest.capabilities, "schemaTree", "keyValue"), {
|
|
11084
|
+
message: "the sessions capability requires sql or commands, and schemaTree or keyValue",
|
|
11026
11085
|
path: ["capabilities"]
|
|
11027
11086
|
}).refine((manifest) => !manifest.capabilities.includes("routineCall") || manifest.capabilities.includes("sql") && manifest.capabilities.includes("schemaTree"), {
|
|
11028
11087
|
message: "the routineCall capability requires sql and schemaTree",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tablecraft-app/plugin-postgres",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "The PostgreSQL datasource plugin for TableCraft, downloaded by the app when a data source needs it.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -24,6 +24,6 @@
|
|
|
24
24
|
},
|
|
25
25
|
"tableCraft": {
|
|
26
26
|
"id": "postgres",
|
|
27
|
-
"apiVersion": "1.
|
|
27
|
+
"apiVersion": "1.2.0"
|
|
28
28
|
}
|
|
29
29
|
}
|