scribe-cms 0.0.4 → 0.0.6

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 (35) hide show
  1. package/dist/cli/index.cjs +272 -180
  2. package/dist/cli/index.cjs.map +1 -1
  3. package/dist/cli/index.js +272 -181
  4. package/dist/cli/index.js.map +1 -1
  5. package/dist/index.cjs +188 -123
  6. package/dist/index.cjs.map +1 -1
  7. package/dist/index.js +188 -123
  8. package/dist/index.js.map +1 -1
  9. package/dist/runtime.cjs +25 -18
  10. package/dist/runtime.cjs.map +1 -1
  11. package/dist/runtime.js +25 -18
  12. package/dist/runtime.js.map +1 -1
  13. package/dist/src/config/resolve-config.d.ts.map +1 -1
  14. package/dist/src/core/types.d.ts +4 -0
  15. package/dist/src/core/types.d.ts.map +1 -1
  16. package/dist/src/history/record-snapshot.d.ts +11 -0
  17. package/dist/src/history/record-snapshot.d.ts.map +1 -0
  18. package/dist/src/storage/sqlite.d.ts.map +1 -1
  19. package/dist/src/storage/translations.d.ts +14 -21
  20. package/dist/src/storage/translations.d.ts.map +1 -1
  21. package/dist/src/translate/page-translator.d.ts.map +1 -1
  22. package/dist/src/validate/validate-assets.d.ts +20 -0
  23. package/dist/src/validate/validate-assets.d.ts.map +1 -0
  24. package/dist/src/validate/validate-project.d.ts +1 -1
  25. package/dist/src/validate/validate-project.d.ts.map +1 -1
  26. package/dist/src/version.d.ts +4 -0
  27. package/dist/src/version.d.ts.map +1 -0
  28. package/dist/studio/server.cjs +51 -64
  29. package/dist/studio/server.cjs.map +1 -1
  30. package/dist/studio/server.d.ts.map +1 -1
  31. package/dist/studio/server.js +51 -64
  32. package/dist/studio/server.js.map +1 -1
  33. package/package.json +1 -1
  34. package/dist/src/history/record-revision.d.ts +0 -14
  35. package/dist/src/history/record-revision.d.ts.map +0 -1
package/dist/runtime.js CHANGED
@@ -70,6 +70,7 @@ function resolveConfig(input, baseDir) {
70
70
  const projectRoot = path3.resolve(process.cwd(), raw.rootDir);
71
71
  const contentRoot = path3.resolve(projectRoot, raw.contentDir ?? "content");
72
72
  const storePath = path3.resolve(projectRoot, raw.store ?? ".scribe/store.sqlite");
73
+ const assetsPath = raw.assetsDir ? path3.resolve(projectRoot, raw.assetsDir) : void 0;
73
74
  const seenIds = /* @__PURE__ */ new Set();
74
75
  const types = raw.types.map((type) => {
75
76
  if (seenIds.has(type.id)) {
@@ -90,6 +91,7 @@ function resolveConfig(input, baseDir) {
90
91
  const config = {
91
92
  rootDir: contentRoot,
92
93
  storePath,
94
+ assetsPath,
93
95
  locales: [...raw.locales],
94
96
  defaultLocale,
95
97
  localePresets: raw.localePresets,
@@ -409,7 +411,7 @@ function seoFieldsFromEn(enDoc) {
409
411
  redirectTo: enDoc.redirectTo
410
412
  };
411
413
  }
412
- var SCHEMA_VERSION = 3;
414
+ var SCHEMA_VERSION = 4;
413
415
  var MIGRATIONS = [
414
416
  `CREATE TABLE IF NOT EXISTS meta (
415
417
  key TEXT PRIMARY KEY,
@@ -429,20 +431,6 @@ var MIGRATIONS = [
429
431
  )`,
430
432
  `CREATE INDEX IF NOT EXISTS idx_translations_type_locale
431
433
  ON translations(content_type, locale)`,
432
- `CREATE TABLE IF NOT EXISTS revisions (
433
- id INTEGER PRIMARY KEY AUTOINCREMENT,
434
- content_type TEXT NOT NULL,
435
- en_slug TEXT NOT NULL,
436
- locale TEXT,
437
- revision_kind TEXT NOT NULL,
438
- en_hash TEXT NOT NULL,
439
- body_hash TEXT NOT NULL,
440
- created_at TEXT NOT NULL,
441
- model TEXT,
442
- body_preview TEXT
443
- )`,
444
- `CREATE INDEX IF NOT EXISTS idx_revisions_lookup
445
- ON revisions(content_type, en_slug, locale, created_at DESC)`,
446
434
  `CREATE TABLE IF NOT EXISTS slug_aliases (
447
435
  content_type TEXT NOT NULL,
448
436
  canonical_en_slug TEXT NOT NULL,
@@ -459,7 +447,19 @@ var MIGRATIONS = [
459
447
  locale_slug TEXT NOT NULL,
460
448
  captured_at TEXT NOT NULL,
461
449
  PRIMARY KEY (content_type, alias_en_slug, locale)
462
- )`
450
+ )`,
451
+ `CREATE TABLE IF NOT EXISTS en_snapshots (
452
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
453
+ content_type TEXT NOT NULL,
454
+ en_slug TEXT NOT NULL,
455
+ en_hash TEXT NOT NULL,
456
+ frontmatter_json TEXT NOT NULL,
457
+ body TEXT NOT NULL,
458
+ created_at TEXT NOT NULL,
459
+ UNIQUE (content_type, en_slug, en_hash)
460
+ )`,
461
+ `CREATE INDEX IF NOT EXISTS idx_en_snapshots_lookup
462
+ ON en_snapshots(content_type, en_slug, created_at DESC)`
463
463
  ];
464
464
  function resolveStorePath(config) {
465
465
  return config.storePath;
@@ -481,12 +481,19 @@ function addColumnIfMissing(db, table, column, ddlType) {
481
481
  db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${ddlType}`);
482
482
  }
483
483
  }
484
+ function readSchemaVersion(db) {
485
+ const row = db.prepare(`SELECT value FROM meta WHERE key = 'schema_version'`).get();
486
+ return row ? Number.parseInt(row.value, 10) || 0 : 0;
487
+ }
484
488
  function migrate(db) {
489
+ const previousVersion = readSchemaVersion(db);
485
490
  for (const sql of MIGRATIONS) {
486
491
  db.exec(sql);
487
492
  }
488
- addColumnIfMissing(db, "revisions", "frontmatter_json", "TEXT");
489
- addColumnIfMissing(db, "revisions", "body", "TEXT");
493
+ if (previousVersion < 4) {
494
+ db.exec(`DROP TABLE IF EXISTS revisions`);
495
+ }
496
+ addColumnIfMissing(db, "translations", "snapshot_id", "INTEGER");
490
497
  db.prepare(
491
498
  `INSERT INTO meta(key, value) VALUES('schema_version', ?)
492
499
  ON CONFLICT(key) DO UPDATE SET value = excluded.value`