@supawatch/target-json-schema 0.8.0 → 0.9.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.
Files changed (2) hide show
  1. package/dist/index.js +5 -1
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -23,6 +23,10 @@ function schemaFor(runtime) {
23
23
  case "array":
24
24
  return { type: "array", items: schemaFor(runtime.element) };
25
25
  case "enum":
26
+ // draft-07 requires enum arrays to be non-empty; a zero-label
27
+ // enum accepts nothing, which "not anything" encodes.
28
+ if (runtime.labels.length === 0)
29
+ return { not: {} };
26
30
  return { enum: runtime.labels };
27
31
  }
28
32
  }
@@ -30,7 +34,7 @@ function fieldSchema(col) {
30
34
  const base = schemaFor(col.runtime);
31
35
  if (!col.nullable)
32
36
  return base;
33
- if (Object.keys(base).length === 0 || !("type" in base) && !("enum" in base)) {
37
+ if (Object.keys(base).length === 0) {
34
38
  return base; // accept-anything already includes null
35
39
  }
36
40
  return { anyOf: [base, { type: "null" }] };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@supawatch/target-json-schema",
3
- "version": "0.8.0",
3
+ "version": "0.9.0",
4
4
  "description": "Draft-07 JSON Schemas generated from live Postgres by supawatch, Ajv-verified against real rows.",
5
5
  "keywords": [
6
6
  "supabase",
@@ -35,7 +35,7 @@
35
35
  ],
36
36
  "dependencies": {
37
37
  "ajv": "^8.17.0",
38
- "@supawatch/core": "0.8.0"
38
+ "@supawatch/core": "0.9.0"
39
39
  },
40
40
  "devDependencies": {
41
41
  "@types/node": "^22.20.1",