@tablecraft-app/plugin-etcd 1.20.0 → 1.23.0-beta.1

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
@@ -5592,12 +5592,17 @@ var connectionFieldSchema = strictObject({
5592
5592
  group: _enum(CONNECTION_FIELD_GROUPS).optional(),
5593
5593
  secret: boolean().optional(),
5594
5594
  /**
5595
- * Draw the field only while the `select` or `checkbox` named by `key` holds `equals` (plan 058);
5596
- * a hidden field is neither checked nor required.
5595
+ * Draw the field only while the `select` or `checkbox` named by `key` holds `equals`, or one of
5596
+ * them when it is a list of a select's values (plans 058, 133); a hidden field is neither checked
5597
+ * nor required.
5597
5598
  */
5598
5599
  visibleWhen: strictObject({
5599
5600
  key: string().regex(FIELD_KEY),
5600
- equals: union([string(), boolean()])
5601
+ equals: union([
5602
+ string(),
5603
+ boolean(),
5604
+ array(string()).min(1)
5605
+ ])
5601
5606
  }).optional()
5602
5607
  });
5603
5608
  /** `server`: `scheme://user:password@host:port/database?params`; `file`: a path, bare or as a URL. */
@@ -5709,13 +5714,23 @@ function tlsFieldsDeclared(connection) {
5709
5714
  return field !== void 0 && tlsFieldFits(role, field, tls);
5710
5715
  });
5711
5716
  }
5712
- /** Every `visibleWhen` names another field of the form, a `select` or a `checkbox`. */
5717
+ function visibleWhenFits(equals, source) {
5718
+ if (source.kind === "checkbox") return typeof equals === "boolean";
5719
+ if (source.kind !== "select" || typeof equals === "boolean") return false;
5720
+ if (typeof equals === "string") return true;
5721
+ const values = new Set((source.options ?? []).map((option) => option.value));
5722
+ return equals.every((value) => values.has(value));
5723
+ }
5724
+ /**
5725
+ * Every `visibleWhen` names another field of the form, a `select` or a `checkbox`; a list of values
5726
+ * names only a select's declared options.
5727
+ */
5713
5728
  function visibilityFieldsDeclared(connection) {
5714
5729
  return connection.fields.every((field) => {
5715
5730
  const condition = field.visibleWhen;
5716
5731
  if (condition === void 0) return true;
5717
5732
  const source = connection.fields.find((candidate) => candidate.key === condition.key);
5718
- return source !== void 0 && source !== field && (source.kind === "select" || source.kind === "checkbox") && typeof condition.equals === (source.kind === "checkbox" ? "boolean" : "string");
5733
+ return source !== void 0 && source !== field && visibleWhenFits(condition.equals, source);
5719
5734
  });
5720
5735
  }
5721
5736
  /** Every scheme `url.sets` keys is one of `url.schemes`, and every value it sets is a declared field's. */
@@ -5758,7 +5773,7 @@ strictObject({
5758
5773
  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",
5759
5774
  path: ["tls"]
5760
5775
  }).refine(visibilityFieldsDeclared, {
5761
- 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",
5776
+ 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",
5762
5777
  path: ["fields"]
5763
5778
  }).refine(urlSetsDeclared, {
5764
5779
  message: "url.sets names a scheme the url does not list, or a field the form does not declare",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tablecraft-app/plugin-etcd",
3
- "version": "1.20.0",
3
+ "version": "1.23.0-beta.1",
4
4
  "description": "The etcd 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": "etcd",
3
3
  "name": "etcd",
4
- "version": "1.20.0",
4
+ "version": "1.23.0",
5
5
  "apiVersion": "1.9.0",
6
6
  "entry": "index.js",
7
7
  "capabilities": [
@@ -45,13 +45,27 @@
45
45
  {
46
46
  "key": "user",
47
47
  "label": "Username",
48
- "kind": "text"
48
+ "kind": "text",
49
+ "visibleWhen": {
50
+ "key": "authMode",
51
+ "equals": [
52
+ "password",
53
+ "auto"
54
+ ]
55
+ }
49
56
  },
50
57
  {
51
58
  "key": "password",
52
59
  "label": "Password",
53
60
  "kind": "password",
54
- "secret": true
61
+ "secret": true,
62
+ "visibleWhen": {
63
+ "key": "authMode",
64
+ "equals": [
65
+ "password",
66
+ "auto"
67
+ ]
68
+ }
55
69
  },
56
70
  {
57
71
  "key": "endpoints",