@tideworthy/tidysites-platform 0.2.0 → 0.2.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/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.2.1
4
+
5
+ - Fix: `POST /_tidy/fill` failed every upsert with "internal error" because the content-only seed document carried a numeric version; the seed format's version is the string "1". The document is now validated before it is applied, so a shape problem answers 400 with the validator's paths. 0.2.0's fill route is unusable for writes; removals worked.
6
+
3
7
  ## 0.2.0
4
8
 
5
9
  - New route `POST /_tidy/fill`: real content over the template's sample content. Settings, entries upserted by slug with field-level merge over the existing entry, `$ref` and `$media` resolved as in a seed, and a `remove` list for sample entries the fill did not replace. Client gains `fill()`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tideworthy/tidysites-platform",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "The Tidysites platform integration for EmDash sites: bootstrap, sessions, maintenance, health, and publish hooks under /_tidy/*.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -11,6 +11,7 @@ import { getDb } from "emdash/runtime";
11
11
  import { loadSeed } from "emdash/seed";
12
12
  import { VALID_SCOPES, generatePrefixedToken } from "@emdash-cms/auth";
13
13
  import type { Deps } from "./handlers";
14
+ import { HttpError } from "./http";
14
15
  import { createEmdashStore } from "./store";
15
16
 
16
17
  export { workerEnv } from "./env";
@@ -63,7 +64,13 @@ export async function buildDeps(): Promise<Deps> {
63
64
  merged[collection].push({ ...e, data: existing ? { ...current, ...e.data } : e.data });
64
65
  }
65
66
  }
66
- const r = await applySeed(db, { version: 1, content: merged } as unknown as Parameters<typeof applySeed>[1], { includeContent: true, onConflict: "update", ...storageOpt });
67
+ // The seed format's version is the string "1"; applySeed validates the
68
+ // document first and a shape problem comes back as a 400 with the
69
+ // validator's paths instead of a bare 500.
70
+ const doc = { version: "1", content: merged };
71
+ const v = validateSeed(doc);
72
+ if (!v.valid) throw new HttpError(400, "invalid content", v.errors);
73
+ const r = await applySeed(db, doc as unknown as Parameters<typeof applySeed>[1], { includeContent: true, onConflict: "update", ...storageOpt });
67
74
  return { created: r.content?.created ?? 0, updated: r.content?.updated ?? 0, media: r.media?.created ?? 0 };
68
75
  }
69
76
  },
package/src/version.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  /** Kept in step with package.json by the release checklist in MAINTAINING.md. */
2
- export const VERSION = "0.2.0";
2
+ export const VERSION = "0.2.1";
3
3
  export const PLUGIN_ID = "tidy-platform";