@blinkk/root-cms 3.0.1-alpha.0 → 3.0.1-alpha.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.
@@ -477,28 +477,33 @@ react-is/cjs/react-is.production.min.js:
477
477
  @tabler/icons-preact/dist/esm/icons/IconArrowBackUp.mjs:
478
478
  @tabler/icons-preact/dist/esm/icons/IconArrowBack.mjs:
479
479
  @tabler/icons-preact/dist/esm/icons/IconArrowLeft.mjs:
480
- @tabler/icons-preact/dist/esm/icons/IconArrowRoundaboutRight.mjs:
480
+ @tabler/icons-preact/dist/esm/icons/IconArrowRight.mjs:
481
481
  @tabler/icons-preact/dist/esm/icons/IconArrowUpRight.mjs:
482
482
  @tabler/icons-preact/dist/esm/icons/IconArrowsHorizontal.mjs:
483
483
  @tabler/icons-preact/dist/esm/icons/IconArrowsVertical.mjs:
484
484
  @tabler/icons-preact/dist/esm/icons/IconBold.mjs:
485
- @tabler/icons-preact/dist/esm/icons/IconBox.mjs:
486
485
  @tabler/icons-preact/dist/esm/icons/IconBraces.mjs:
487
486
  @tabler/icons-preact/dist/esm/icons/IconBracketsAngle.mjs:
487
+ @tabler/icons-preact/dist/esm/icons/IconCalendar.mjs:
488
488
  @tabler/icons-preact/dist/esm/icons/IconCapsuleHorizontal.mjs:
489
489
  @tabler/icons-preact/dist/esm/icons/IconCarrot.mjs:
490
490
  @tabler/icons-preact/dist/esm/icons/IconCheck.mjs:
491
491
  @tabler/icons-preact/dist/esm/icons/IconChevronDown.mjs:
492
+ @tabler/icons-preact/dist/esm/icons/IconChevronRight.mjs:
492
493
  @tabler/icons-preact/dist/esm/icons/IconCircleArrowDown.mjs:
493
494
  @tabler/icons-preact/dist/esm/icons/IconCircleArrowUp.mjs:
494
495
  @tabler/icons-preact/dist/esm/icons/IconCirclePlus.mjs:
495
496
  @tabler/icons-preact/dist/esm/icons/IconClearFormatting.mjs:
496
497
  @tabler/icons-preact/dist/esm/icons/IconClipboardCheck.mjs:
497
498
  @tabler/icons-preact/dist/esm/icons/IconClipboardCopy.mjs:
499
+ @tabler/icons-preact/dist/esm/icons/IconClipboardList.mjs:
498
500
  @tabler/icons-preact/dist/esm/icons/IconClipboard.mjs:
501
+ @tabler/icons-preact/dist/esm/icons/IconClock.mjs:
499
502
  @tabler/icons-preact/dist/esm/icons/IconCloudOff.mjs:
500
503
  @tabler/icons-preact/dist/esm/icons/IconCode.mjs:
504
+ @tabler/icons-preact/dist/esm/icons/IconColumns3.mjs:
501
505
  @tabler/icons-preact/dist/esm/icons/IconCopy.mjs:
506
+ @tabler/icons-preact/dist/esm/icons/IconCornerDownRight.mjs:
502
507
  @tabler/icons-preact/dist/esm/icons/IconCrop.mjs:
503
508
  @tabler/icons-preact/dist/esm/icons/IconDatabase.mjs:
504
509
  @tabler/icons-preact/dist/esm/icons/IconDeviceDesktop.mjs:
@@ -512,7 +517,9 @@ react-is/cjs/react-is.production.min.js:
512
517
  @tabler/icons-preact/dist/esm/icons/IconFileDiff.mjs:
513
518
  @tabler/icons-preact/dist/esm/icons/IconFileDownload.mjs:
514
519
  @tabler/icons-preact/dist/esm/icons/IconFileUpload.mjs:
520
+ @tabler/icons-preact/dist/esm/icons/IconFile.mjs:
515
521
  @tabler/icons-preact/dist/esm/icons/IconFilter.mjs:
522
+ @tabler/icons-preact/dist/esm/icons/IconFlag.mjs:
516
523
  @tabler/icons-preact/dist/esm/icons/IconFolder.mjs:
517
524
  @tabler/icons-preact/dist/esm/icons/IconGitCompare.mjs:
518
525
  @tabler/icons-preact/dist/esm/icons/IconGripVertical.mjs:
@@ -528,6 +535,8 @@ react-is/cjs/react-is.production.min.js:
528
535
  @tabler/icons-preact/dist/esm/icons/IconJson.mjs:
529
536
  @tabler/icons-preact/dist/esm/icons/IconLanguageOff.mjs:
530
537
  @tabler/icons-preact/dist/esm/icons/IconLanguage.mjs:
538
+ @tabler/icons-preact/dist/esm/icons/IconLayoutGrid.mjs:
539
+ @tabler/icons-preact/dist/esm/icons/IconLayoutList.mjs:
531
540
  @tabler/icons-preact/dist/esm/icons/IconLayoutSidebarRightCollapse.mjs:
532
541
  @tabler/icons-preact/dist/esm/icons/IconLayoutSidebarRightExpand.mjs:
533
542
  @tabler/icons-preact/dist/esm/icons/IconLink.mjs:
@@ -539,6 +548,7 @@ react-is/cjs/react-is.production.min.js:
539
548
  @tabler/icons-preact/dist/esm/icons/IconLock.mjs:
540
549
  @tabler/icons-preact/dist/esm/icons/IconLogout.mjs:
541
550
  @tabler/icons-preact/dist/esm/icons/IconMapPin.mjs:
551
+ @tabler/icons-preact/dist/esm/icons/IconMessageCircle.mjs:
542
552
  @tabler/icons-preact/dist/esm/icons/IconMessage.mjs:
543
553
  @tabler/icons-preact/dist/esm/icons/IconMoodLookDown.mjs:
544
554
  @tabler/icons-preact/dist/esm/icons/IconPackage.mjs:
@@ -576,6 +586,8 @@ react-is/cjs/react-is.production.min.js:
576
586
  @tabler/icons-preact/dist/esm/icons/IconTool.mjs:
577
587
  @tabler/icons-preact/dist/esm/icons/IconTrash.mjs:
578
588
  @tabler/icons-preact/dist/esm/icons/IconUnderline.mjs:
589
+ @tabler/icons-preact/dist/esm/icons/IconUserPlus.mjs:
590
+ @tabler/icons-preact/dist/esm/icons/IconUser.mjs:
579
591
  @tabler/icons-preact/dist/esm/icons/IconWorld.mjs:
580
592
  @tabler/icons-preact/dist/esm/icons/IconX.mjs:
581
593
  @tabler/icons-preact/dist/esm/icons/IconCircleCheckFilled.mjs:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blinkk/root-cms",
3
- "version": "3.0.1-alpha.0",
3
+ "version": "3.0.1-alpha.1",
4
4
  "author": "s@blinkk.com",
5
5
  "license": "MIT",
6
6
  "engines": {
@@ -70,10 +70,12 @@
70
70
  "date-fns-tz": "3.2.0",
71
71
  "diff": "8.0.2",
72
72
  "dts-dom": "3.7.0",
73
+ "@mantine/spotlight": "4.2.12",
73
74
  "fnv-plus": "1.3.1",
74
75
  "genkit": "1.26.0",
75
76
  "jsonwebtoken": "9.0.2",
76
77
  "kleur": "4.1.5",
78
+ "minisearch": "7.2.0",
77
79
  "sirv": "2.0.3",
78
80
  "tiny-glob": "0.2.9"
79
81
  },
@@ -106,7 +108,6 @@
106
108
  "@mantine/hooks": "4.2.12",
107
109
  "@mantine/modals": "4.2.12",
108
110
  "@mantine/notifications": "4.2.12",
109
- "@mantine/spotlight": "4.2.12",
110
111
  "@preact/compat": "18.3.1",
111
112
  "@tabler/icons-preact": "3.35.0",
112
113
  "@testing-library/preact": "3.2.4",
@@ -148,10 +149,10 @@
148
149
  "vite": "8.0.3",
149
150
  "vitest": "4.1.2",
150
151
  "yjs": "13.6.27",
151
- "@blinkk/root": "3.0.1-alpha.0"
152
+ "@blinkk/root": "3.0.1-alpha.1"
152
153
  },
153
154
  "peerDependencies": {
154
- "@blinkk/root": "3.0.1-alpha.0",
155
+ "@blinkk/root": "3.0.1-alpha.1",
155
156
  "firebase-admin": ">=11",
156
157
  "firebase-functions": ">=4"
157
158
  },
@@ -1,157 +0,0 @@
1
- import {
2
- RootCMSClient,
3
- getCmsPlugin
4
- } from "./chunk-YMUZ5H5C.js";
5
-
6
- // core/versions.ts
7
- import fs from "fs";
8
- import path from "path";
9
- import { Timestamp } from "firebase-admin/firestore";
10
- import glob from "tiny-glob";
11
- var DOCUMENT_SAVE_OFFSET = 5 * 60 * 1e3;
12
- var VersionsService = class {
13
- constructor(rootConfig) {
14
- this.rootConfig = rootConfig;
15
- const cmsPlugin = getCmsPlugin(rootConfig);
16
- const cmsPluginOptions = cmsPlugin.getConfig();
17
- const projectId = cmsPluginOptions.id || "default";
18
- this.projectId = projectId;
19
- this.db = cmsPlugin.getFirestore();
20
- }
21
- /**
22
- * Saves a version of all documents that have been edited since the last run.
23
- */
24
- async saveVersions() {
25
- const lastRun = await this.getLastRun();
26
- const lastRunWithOffset = lastRun === 0 ? lastRun : lastRun - DOCUMENT_SAVE_OFFSET;
27
- const changedDocs = await this.getDocsModifiedAfter(lastRunWithOffset);
28
- const now = Timestamp.now().toMillis();
29
- const versions = changedDocs.filter((doc) => {
30
- const modifiedAt = doc.sys.modifiedAt.toMillis();
31
- if (modifiedAt > now - DOCUMENT_SAVE_OFFSET) {
32
- return false;
33
- }
34
- const publishedAt = doc.sys.publishedAt?.toMillis?.();
35
- if (publishedAt && Math.abs(publishedAt - modifiedAt) < 5e3) {
36
- return false;
37
- }
38
- return true;
39
- });
40
- if (versions.length > 0) {
41
- this.saveVersionsToFirestore(versions);
42
- }
43
- this.saveLastRun(now);
44
- }
45
- async saveVersionsToFirestore(versions) {
46
- const batch = this.db.batch();
47
- versions.forEach((version) => {
48
- if (!version.collection || !version.slug || !version.sys?.modifiedAt) {
49
- return;
50
- }
51
- const modifiedAtMillis = version.sys.modifiedAt.toMillis();
52
- const versionPath = `Projects/${this.projectId}/Collections/${version.collection}/Drafts/${version.slug}/Versions/${modifiedAtMillis}`;
53
- console.log(versionPath);
54
- const versionRef = this.db.doc(versionPath);
55
- batch.set(versionRef, version);
56
- });
57
- await batch.commit();
58
- console.log(`versions: saved ${versions.length} versions`);
59
- }
60
- /**
61
- * Returns the last time (in millis) saveVersions() was run, or 0 if has
62
- * never been run.
63
- */
64
- async getLastRun() {
65
- const projectDocRef = this.db.collection("Projects").doc(this.projectId);
66
- const projectDoc = await projectDocRef.get();
67
- if (projectDoc.exists) {
68
- const data = projectDoc.data() || {};
69
- const ts = data.versionsLastRun;
70
- if (ts) {
71
- return ts.toMillis();
72
- }
73
- }
74
- return 0;
75
- }
76
- /**
77
- * Saves {versionLastRun: <timestamp>} to the Projects/<projectId> doc.
78
- */
79
- async saveLastRun(millis) {
80
- const ts = Timestamp.fromMillis(millis);
81
- const projectDocRef = this.db.collection("Projects").doc(this.projectId);
82
- await projectDocRef.set({ versionsLastRun: ts }, { merge: true });
83
- }
84
- /**
85
- * Returns a list of all docs that were edited after a certain time.
86
- */
87
- async getDocsModifiedAfter(millis) {
88
- const ts = Timestamp.fromMillis(millis);
89
- const results = [];
90
- const collectionIds = await this.listCollections();
91
- for (const collectionId of collectionIds) {
92
- const collectionPath = `Projects/${this.projectId}/Collections/${collectionId}/Drafts`;
93
- const query = this.db.collection(collectionPath).where("sys.modifiedAt", ">=", ts);
94
- const querySnapshot = await query.get();
95
- querySnapshot.forEach((doc) => {
96
- results.push(doc.data());
97
- });
98
- }
99
- return results;
100
- }
101
- /**
102
- * Returns a list of collection ids for the Root project.
103
- */
104
- async listCollections() {
105
- const collectionsDir = path.join(this.rootConfig.rootDir, "collections");
106
- if (!fs.existsSync(collectionsDir)) {
107
- return [];
108
- }
109
- const collectionIds = [];
110
- const collectionFileNames = await glob("*.schema.ts", {
111
- cwd: collectionsDir
112
- });
113
- collectionFileNames.forEach((filename) => {
114
- collectionIds.push(filename.slice(0, -10));
115
- });
116
- return collectionIds;
117
- }
118
- };
119
-
120
- // core/cron.ts
121
- async function runCronJobs(rootConfig) {
122
- await Promise.all([
123
- runCronJob("publishScheduledDocs", runPublishScheduledDocs, rootConfig),
124
- runCronJob(
125
- "syncScheduledDataSources",
126
- runSyncScheduledDataSources,
127
- rootConfig
128
- ),
129
- runCronJob("saveVersions", runSaveVersions, rootConfig)
130
- ]);
131
- }
132
- async function runCronJob(name, fn, ...args) {
133
- try {
134
- await fn(...args);
135
- } catch (err) {
136
- console.log(`cron failed: ${name}`);
137
- console.error(String(err.stack || err));
138
- throw err;
139
- }
140
- }
141
- async function runPublishScheduledDocs(rootConfig) {
142
- const cmsClient = new RootCMSClient(rootConfig);
143
- await cmsClient.publishScheduledDocs();
144
- await cmsClient.publishScheduledReleases();
145
- }
146
- async function runSyncScheduledDataSources(rootConfig) {
147
- const cmsClient = new RootCMSClient(rootConfig);
148
- await cmsClient.syncScheduledDataSources();
149
- }
150
- async function runSaveVersions(rootConfig) {
151
- const service = new VersionsService(rootConfig);
152
- await service.saveVersions();
153
- }
154
-
155
- export {
156
- runCronJobs
157
- };