@tablecraft-app/plugin-postgres 1.20.0 → 1.24.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 CHANGED
@@ -10902,12 +10902,17 @@ var connectionFieldSchema = strictObject({
10902
10902
  group: _enum(CONNECTION_FIELD_GROUPS).optional(),
10903
10903
  secret: boolean().optional(),
10904
10904
  /**
10905
- * Draw the field only while the `select` or `checkbox` named by `key` holds `equals` (plan 058);
10906
- * a hidden field is neither checked nor required.
10905
+ * Draw the field only while the `select` or `checkbox` named by `key` holds `equals`, or one of
10906
+ * them when it is a list of a select's values (plans 058, 133); a hidden field is neither checked
10907
+ * nor required.
10907
10908
  */
10908
10909
  visibleWhen: strictObject({
10909
10910
  key: string$1().regex(FIELD_KEY),
10910
- equals: union([string$1(), boolean()])
10911
+ equals: union([
10912
+ string$1(),
10913
+ boolean(),
10914
+ array(string$1()).min(1)
10915
+ ])
10911
10916
  }).optional()
10912
10917
  });
10913
10918
  /** `server`: `scheme://user:password@host:port/database?params`; `file`: a path, bare or as a URL. */
@@ -11019,13 +11024,23 @@ function tlsFieldsDeclared(connection) {
11019
11024
  return field !== void 0 && tlsFieldFits(role, field, tls);
11020
11025
  });
11021
11026
  }
11022
- /** Every `visibleWhen` names another field of the form, a `select` or a `checkbox`. */
11027
+ function visibleWhenFits(equals, source) {
11028
+ if (source.kind === "checkbox") return typeof equals === "boolean";
11029
+ if (source.kind !== "select" || typeof equals === "boolean") return false;
11030
+ if (typeof equals === "string") return true;
11031
+ const values = new Set((source.options ?? []).map((option) => option.value));
11032
+ return equals.every((value) => values.has(value));
11033
+ }
11034
+ /**
11035
+ * Every `visibleWhen` names another field of the form, a `select` or a `checkbox`; a list of values
11036
+ * names only a select's declared options.
11037
+ */
11023
11038
  function visibilityFieldsDeclared(connection) {
11024
11039
  return connection.fields.every((field) => {
11025
11040
  const condition = field.visibleWhen;
11026
11041
  if (condition === void 0) return true;
11027
11042
  const source = connection.fields.find((candidate) => candidate.key === condition.key);
11028
- return source !== void 0 && source !== field && (source.kind === "select" || source.kind === "checkbox") && typeof condition.equals === (source.kind === "checkbox" ? "boolean" : "string");
11043
+ return source !== void 0 && source !== field && visibleWhenFits(condition.equals, source);
11029
11044
  });
11030
11045
  }
11031
11046
  /** Every scheme `url.sets` keys is one of `url.schemes`, and every value it sets is a declared field's. */
@@ -11068,7 +11083,7 @@ strictObject({
11068
11083
  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",
11069
11084
  path: ["tls"]
11070
11085
  }).refine(visibilityFieldsDeclared, {
11071
- 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",
11086
+ 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 or a list holding a value the select does not offer",
11072
11087
  path: ["fields"]
11073
11088
  }).refine(urlSetsDeclared, {
11074
11089
  message: "url.sets names a scheme the url does not list, or a field the form does not declare",
@@ -23376,13 +23391,13 @@ var AlignedPrinter = class {
23376
23391
  } else this.inline(writer, clause, false);
23377
23392
  }
23378
23393
  }
23379
- #rows(writer, nodes, column) {
23394
+ #rows(writer, nodes, column, leadSpace = true) {
23380
23395
  const { parts, commas } = splitTop(nodes, COMMA$1);
23381
23396
  const saved = writer.indent;
23382
23397
  writer.indent = column;
23383
23398
  parts.forEach((part, at) => {
23384
23399
  if (at > 0) writer.newline(column);
23385
- this.inline(writer, part, at === 0);
23400
+ this.inline(writer, part, at === 0 && leadSpace);
23386
23401
  const comma = commas[at];
23387
23402
  if (comma !== void 0) writer.tok(comma, comma.text, false);
23388
23403
  });
@@ -23417,7 +23432,8 @@ var AlignedPrinter = class {
23417
23432
  let previous = null;
23418
23433
  for (const node of nodes) {
23419
23434
  const space = previous === null ? leadSpace : this.#spaceBetween(previous, node, options);
23420
- this.node(writer, node, space, options);
23435
+ if (isWord(previous ?? void 0, "IN") && node.type === "group" && options.preserve !== true) this.#inList(writer, node, space);
23436
+ else this.node(writer, node, space, options);
23421
23437
  previous = node;
23422
23438
  }
23423
23439
  }
@@ -23432,6 +23448,16 @@ var AlignedPrinter = class {
23432
23448
  else this.inline(writer, group.children, false, { preserve: options.preserve ?? false });
23433
23449
  writer.tok(group.close, group.close.text, false);
23434
23450
  }
23451
+ /** Two or more values after `IN` go one per line under the first, whatever the width (decision 147). */
23452
+ #inList(writer, group, space) {
23453
+ if (isSubquery(group) || splitTop(group.children, COMMA$1).parts.length < 2) {
23454
+ this.#group(writer, group, space, {});
23455
+ return;
23456
+ }
23457
+ writer.tok(group.open, group.open.text, space);
23458
+ this.#rows(writer, group.children, writer.column, false);
23459
+ writer.tok(group.close, group.close.text, false);
23460
+ }
23435
23461
  /** Inline when it fits `CASE_INLINE_LIMIT`; else `WHEN` / `ELSE` one per line under `CASE`, `END` at its column (rule 14). */
23436
23462
  #case(writer, node, space) {
23437
23463
  const start = writer.column + (space ? 1 : 0);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tablecraft-app/plugin-postgres",
3
- "version": "1.20.0",
3
+ "version": "1.24.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",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "id": "postgres",
3
3
  "name": "PostgreSQL",
4
- "version": "1.20.0",
4
+ "version": "1.24.0",
5
5
  "apiVersion": "1.9.0",
6
6
  "entry": "index.js",
7
7
  "capabilities": [