@plank-cms/plank 0.24.3 → 0.25.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.
@@ -12,7 +12,7 @@
12
12
  href="https://fonts.googleapis.com/css2?family=Google+Sans:ital,opsz,wght@0,17..18,400..700;1,17..18,400..700&display=swap"
13
13
  rel="stylesheet"
14
14
  />
15
- <script type="module" crossorigin src="/admin/assets/index-DcMspdw2.js"></script>
15
+ <script type="module" crossorigin src="/admin/assets/index-BlWGZ3Y_.js"></script>
16
16
  <link rel="stylesheet" crossorigin href="/admin/assets/index-BSi0iXTe.css">
17
17
  </head>
18
18
  <body>
package/dist/index.js CHANGED
@@ -7,7 +7,7 @@ import { randomBytes } from "crypto";
7
7
  import { resolve, join } from "path";
8
8
  import fs from "fs-extra";
9
9
  import { execa } from "execa";
10
- var PACKAGE_VERSION = "0.24.3";
10
+ var PACKAGE_VERSION = "0.25.0";
11
11
  function generateSecret() {
12
12
  return randomBytes(32).toString("hex");
13
13
  }
@@ -101,7 +101,7 @@ import { dirname, join as join2, resolve as resolve2 } from "path";
101
101
  async function start() {
102
102
  config({ path: resolve2(process.cwd(), ".env") });
103
103
  process.env.PLANK_ADMIN_DIST = join2(dirname(fileURLToPath(import.meta.url)), "admin");
104
- const { start: startServer } = await import("./server-KRX65XUC.js");
104
+ const { start: startServer } = await import("./server-ESNIHORP.js");
105
105
  await startServer();
106
106
  }
107
107
 
@@ -0,0 +1,2 @@
1
+ ALTER TABLE plank_content_types
2
+ ADD COLUMN IF NOT EXISTS preview_enabled BOOLEAN NOT NULL DEFAULT TRUE;
@@ -204,6 +204,7 @@ function rowToContentType(row) {
204
204
  name: row.name,
205
205
  slug: row.slug,
206
206
  kind: row.kind,
207
+ previewEnabled: row.preview_enabled,
207
208
  tableName: row.table_name,
208
209
  fields: row.fields,
209
210
  isDefault: row.is_default,
@@ -220,16 +221,24 @@ async function findContentTypeBySlug(slug) {
220
221
  return rows[0] ? rowToContentType(rows[0]) : null;
221
222
  }
222
223
  async function saveContentType(contentType) {
223
- const { rows } = await pool_default.query(`INSERT INTO plank_content_types (id, name, slug, kind, table_name, fields)
224
- VALUES ($1, $2, $3, $4, $5, $6)
225
- RETURNING *`, [createId(), contentType.name, contentType.slug, contentType.kind ?? "collection", contentType.tableName, JSON.stringify(contentType.fields)]);
224
+ const { rows } = await pool_default.query(`INSERT INTO plank_content_types (id, name, slug, kind, preview_enabled, table_name, fields)
225
+ VALUES ($1, $2, $3, $4, $5, $6, $7)
226
+ RETURNING *`, [
227
+ createId(),
228
+ contentType.name,
229
+ contentType.slug,
230
+ contentType.kind ?? "collection",
231
+ contentType.previewEnabled ?? true,
232
+ contentType.tableName,
233
+ JSON.stringify(contentType.fields)
234
+ ]);
226
235
  return rowToContentType(rows[0]);
227
236
  }
228
237
  async function updateContentType(slug, contentType) {
229
238
  const { rows } = await pool_default.query(`UPDATE plank_content_types
230
- SET name = $1, fields = $2, updated_at = NOW()
231
- WHERE slug = $3
232
- RETURNING *`, [contentType.name, JSON.stringify(contentType.fields), slug]);
239
+ SET name = $1, fields = $2, preview_enabled = $3, updated_at = NOW()
240
+ WHERE slug = $4
241
+ RETURNING *`, [contentType.name, JSON.stringify(contentType.fields), contentType.previewEnabled ?? true, slug]);
233
242
  return rowToContentType(rows[0]);
234
243
  }
235
244
  async function setDefaultContentType(slug) {
@@ -2977,6 +2986,7 @@ var ContentTypeSchema = z2.object({
2977
2986
  name: z2.string().min(1),
2978
2987
  slug: z2.string().regex(/^[a-z][a-z0-9-]*$/, "Slug must be lowercase with hyphens"),
2979
2988
  tableName: z2.string().regex(/^[a-z][a-z0-9_]*$/, "Table name must be lowercase with underscores"),
2989
+ previewEnabled: z2.boolean().default(true),
2980
2990
  fields: z2.array(FieldSchema)
2981
2991
  });
2982
2992
  var CreateContentTypeSchema = ContentTypeSchema.extend({
@@ -3628,7 +3638,9 @@ var createEntry = async (req, res) => {
3628
3638
  }));
3629
3639
  res.status(201).json(normalizeNavigationFields(rows[0], ct.fields));
3630
3640
  triggerWebhooks("entry.created", { content_type: req.params.slug, entry_id: rows[0].id });
3631
- triggerPreviewSyncWebhook({ contentType: req.params.slug, entry: rows[0] });
3641
+ if (ct.previewEnabled !== false) {
3642
+ triggerPreviewSyncWebhook({ contentType: req.params.slug, entry: rows[0] });
3643
+ }
3632
3644
  };
3633
3645
  var getSingleEntry = async (req, res) => {
3634
3646
  const ct = await findContentTypeBySlug(req.params.slug);
@@ -3722,7 +3734,9 @@ var updateEntry = async (req, res) => {
3722
3734
  }));
3723
3735
  res.json(normalizeNavigationFields(rows[0], ct.fields));
3724
3736
  triggerWebhooks("entry.updated", { content_type: req.params.slug, entry_id: req.params.id });
3725
- triggerPreviewSyncWebhook({ contentType: req.params.slug, entry: rows[0] });
3737
+ if (ct.previewEnabled !== false) {
3738
+ triggerPreviewSyncWebhook({ contentType: req.params.slug, entry: rows[0] });
3739
+ }
3726
3740
  };
3727
3741
  var SNAPSHOT_EXCLUDED = [
3728
3742
  "'id'",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plank-cms/plank",
3
- "version": "0.24.3",
3
+ "version": "0.25.0",
4
4
  "description": "Self-hosted headless CMS. Deploy in minutes on your own infrastructure.",
5
5
  "type": "module",
6
6
  "files": [
@@ -55,9 +55,9 @@
55
55
  "devDependencies": {
56
56
  "@types/fs-extra": "^11.0.4",
57
57
  "tsup": "^8.5.0",
58
- "@plank-cms/core": "0.24.3",
59
- "@plank-cms/schema": "0.24.3",
60
- "@plank-cms/db": "0.24.3"
58
+ "@plank-cms/schema": "0.25.0",
59
+ "@plank-cms/core": "0.25.0",
60
+ "@plank-cms/db": "0.25.0"
61
61
  },
62
62
  "scripts": {
63
63
  "build": "tsup",