@blinkk/root-cms 3.0.1 → 3.0.3
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/dist/app.js +5 -5
- package/dist/{chunk-KGAUXTJ6.js → chunk-7Z5IRD2G.js} +176 -83
- package/dist/{chunk-2BSW7SIH.js → chunk-N4K6ICFR.js} +4 -4
- package/dist/{chunk-BGTUWIV6.js → chunk-PNLLZXVY.js} +4 -4
- package/dist/{chunk-C245C557.js → chunk-RXWDB3K4.js} +3 -3
- package/dist/{chunk-XLX37FRL.js → chunk-TEKMLYXS.js} +3 -4
- package/dist/cli/cli.d.ts +12 -0
- package/dist/cli/docs.d.ts +49 -0
- package/dist/cli/export.d.ts +11 -0
- package/dist/cli/generate-types.d.ts +6 -0
- package/dist/cli/import.d.ts +13 -0
- package/dist/cli/init-firebase.d.ts +7 -0
- package/dist/cli/utils.d.ts +27 -0
- package/dist/cli.js +10 -10
- package/dist/client.js +1 -1
- package/dist/core/ai-tools.d.ts +156 -0
- package/dist/core/ai.d.ts +330 -0
- package/dist/core/api.d.ts +21 -0
- package/dist/core/app.d.ts +16 -0
- package/dist/core/checks-translations.d.ts +13 -0
- package/dist/core/checks.d.ts +48 -0
- package/dist/core/client.d.ts +715 -0
- package/dist/core/core.d.ts +5 -0
- package/dist/core/cron.d.ts +19 -0
- package/dist/core/csv.d.ts +5 -0
- package/dist/core/functions.d.ts +9 -0
- package/dist/core/plugin.d.ts +357 -0
- package/dist/{project.d.ts → core/project.d.ts} +8 -12
- package/dist/core/richtext.d.ts +101 -0
- package/dist/{core.d.ts → core/route.d.ts} +13 -66
- package/dist/core/runtime.d.ts +46 -0
- package/dist/{schema-Db_xODoi.d.ts → core/schema.d.ts} +47 -100
- package/dist/core/search-extract.d.ts +70 -0
- package/dist/core/search-index.d.ts +182 -0
- package/dist/core/search-query.d.ts +68 -0
- package/dist/core/security.d.ts +6 -0
- package/dist/core/server-version.d.ts +5 -0
- package/dist/core/services-notifications.d.ts +57 -0
- package/dist/core/services.d.ts +44 -0
- package/dist/core/sse.d.ts +10 -0
- package/dist/core/translations-manager.d.ts +187 -0
- package/dist/core/translations.d.ts +83 -0
- package/dist/core/url-safety.d.ts +19 -0
- package/dist/core/validation.d.ts +30 -0
- package/dist/core/values.d.ts +9 -0
- package/dist/core/versions.d.ts +48 -0
- package/dist/core.js +1 -1
- package/dist/edit-M4PN4SGX.js +7 -0
- package/dist/functions.js +4 -4
- package/dist/{generate-types-SPV7I3A5.js → generate-types-JWIG4QVI.js} +1 -1
- package/dist/plugin.js +124 -129
- package/dist/shared/marshal.d.ts +68 -0
- package/dist/shared/objects.d.ts +9 -0
- package/dist/shared/richtext.d.ts +74 -0
- package/dist/shared/safe-json.d.ts +11 -0
- package/dist/shared/sanitize.d.ts +12 -0
- package/dist/shared/slug.d.ts +19 -0
- package/dist/shared/sse.d.ts +16 -0
- package/dist/shared/strings.d.ts +23 -0
- package/dist/ui/AIPage-2LUC2PWC.js +1 -0
- package/dist/ui/AssetsPage-PODV4QAB.js +1 -0
- package/dist/ui/CollectionPage-4DMKW5YB.js +1 -0
- package/dist/ui/ComparePage-JMJE5A5Y.js +1 -0
- package/dist/ui/DataPage-MVLZT2BU.js +1 -0
- package/dist/ui/DataSourcePage-4RPBXRI2.js +1 -0
- package/dist/ui/DocTranslationsPage-XJSPKGVX.js +1 -0
- package/dist/ui/DocumentPage-R2PVNG24.js +1 -0
- package/dist/ui/EditDataSourcePage-3SHAARNL.js +1 -0
- package/dist/ui/EditReleasePage-G5VW2OGW.js +1 -0
- package/dist/ui/ImageEditorDialog-4H665KK2.js +81 -0
- package/dist/ui/ImageEditorDialog-4H665KK2.js.LEGAL.txt +17 -0
- package/dist/ui/LogsPage-K6KYEG2P.js +1 -0
- package/dist/ui/NewDataSourcePage-O2VQEOJG.js +1 -0
- package/dist/ui/NewReleasePage-RSVS32RZ.js +1 -0
- package/dist/ui/NotFoundPage-ZYD5ILG6.js +1 -0
- package/dist/ui/ProjectPage-X3YQBWL4.js +1 -0
- package/dist/ui/ReleasePage-FJHHXNNB.js +1 -0
- package/dist/ui/ReleasesPage-VGWIBNEZ.js +1 -0
- package/dist/ui/SettingsPage-C4RXOQ6T.js +1 -0
- package/dist/ui/SidebarToolsPage-ZBOKPEMP.js +1 -0
- package/dist/ui/TaskPage-BQ4OX5WN.js +1 -0
- package/dist/ui/TasksPage-3IGQYVYS.js +1 -0
- package/dist/ui/TranslationsArbPage-GGHCWPQL.js +2 -0
- package/dist/ui/TranslationsEditPage-E2BCMKYV.js +1 -0
- package/dist/ui/TranslationsPage-MC4O4ZNI.js +162 -0
- package/dist/ui/ai-tools-5E5ELLZX.js +1 -0
- package/dist/ui/chunk-3IYZCUPI.js +1 -0
- package/dist/ui/chunk-4KE2SZKH.js +1 -0
- package/dist/ui/chunk-4W73RW5I.js +1 -0
- package/dist/ui/chunk-54DVDYU6.js +1 -0
- package/dist/ui/chunk-5MV6XVGA.js +1 -0
- package/dist/ui/chunk-62UWGWON.js +1 -0
- package/dist/ui/chunk-6IFGKSIE.js +1 -0
- package/dist/ui/chunk-767BAQ53.js +1 -0
- package/dist/ui/chunk-AFWBSIPL.js +1 -0
- package/dist/ui/chunk-AL3TN2KI.js +1 -0
- package/dist/ui/chunk-B6BLDN24.js +141 -0
- package/dist/ui/chunk-B6BLDN24.js.LEGAL.txt +106 -0
- package/dist/ui/chunk-BZIRGB4W.js +1 -0
- package/dist/ui/chunk-C5NH23G4.js +3 -0
- package/dist/ui/chunk-CGCKJFL4.js +1 -0
- package/dist/ui/chunk-DEGMKEHP.js +1 -0
- package/dist/ui/chunk-DTMZLUNY.js +15 -0
- package/dist/ui/chunk-DTMZLUNY.js.LEGAL.txt +237 -0
- package/dist/ui/chunk-DUJYIOLE.js +5 -0
- package/dist/ui/chunk-E2RCCK2T.js +1 -0
- package/dist/ui/chunk-EGEB6N4J.js +22 -0
- package/dist/ui/chunk-EGEB6N4J.js.LEGAL.txt +1059 -0
- package/dist/ui/chunk-GXSAEPU3.js +1 -0
- package/dist/ui/chunk-HHMG665Z.js +1 -0
- package/dist/ui/chunk-HKINZLMW.js +84 -0
- package/dist/ui/chunk-HLMBCVRX.js +1 -0
- package/dist/ui/chunk-HRGYNHZ3.js +1 -0
- package/dist/ui/chunk-I6ICVKEC.js +1 -0
- package/dist/ui/chunk-IU36W2TB.js +1 -0
- package/dist/ui/chunk-JDW4UORS.js +1 -0
- package/dist/ui/chunk-JHBAMPGB.js +1 -0
- package/dist/ui/chunk-JYFLU7DM.js +19 -0
- package/dist/ui/chunk-JZFTZ4X4.js +87 -0
- package/dist/ui/chunk-JZFTZ4X4.js.LEGAL.txt +9 -0
- package/dist/ui/chunk-KFAZBEPV.js +1 -0
- package/dist/ui/chunk-KKEWCXVV.js +1 -0
- package/dist/ui/chunk-KUCVLANF.js +1 -0
- package/dist/ui/chunk-KYDOSLTO.js +1 -0
- package/dist/ui/chunk-L4RHGQUG.js +1 -0
- package/dist/ui/chunk-MDUBCXU2.js +1 -0
- package/dist/ui/chunk-NXQVLOTK.js +1 -0
- package/dist/ui/chunk-NZHF733K.js +7 -0
- package/dist/ui/chunk-NZHF733K.js.LEGAL.txt +146 -0
- package/dist/ui/chunk-ONTGW2VA.js +1 -0
- package/dist/ui/chunk-ORXEMIQC.js +1 -0
- package/dist/ui/chunk-PHBMVORG.js +1 -0
- package/dist/ui/chunk-PJA7YP4A.js +1 -0
- package/dist/ui/chunk-PVAE643M.js +1 -0
- package/dist/ui/chunk-PWKJDYE2.js +1 -0
- package/dist/ui/chunk-RSVO46S3.js +1 -0
- package/dist/ui/chunk-SKEP5WYH.js +10 -0
- package/dist/ui/chunk-SKEP5WYH.js.LEGAL.txt +176 -0
- package/dist/ui/chunk-SQRKKWRG.js +3 -0
- package/dist/ui/chunk-UEON4JAT.js +1 -0
- package/dist/ui/chunk-V7S4IAGB.js +1 -0
- package/dist/ui/chunk-VMT7JFAM.js +1 -0
- package/dist/ui/chunk-W3BJ2EZX.js +1 -0
- package/dist/ui/chunk-W3HIZQ4Z.js +1 -0
- package/dist/ui/chunk-X2WHBGTP.js +1 -0
- package/dist/ui/chunk-XOQ3KDSR.js +3 -0
- package/dist/ui/chunk-YDO2EDVY.js +1 -0
- package/dist/ui/chunk-YFA6U2CV.js +1 -0
- package/dist/ui/gcs-L33FIRZU.js +1 -0
- package/dist/ui/prerender-Q4YSDCPB.js +1 -0
- package/dist/ui/signin.js +1 -1
- package/dist/ui/ui.css +1 -1
- package/dist/ui/ui.js +1 -630
- package/dist/ui/ui.js.LEGAL.txt +19 -732
- package/package.json +20 -20
- package/dist/client-1puwLgNx.d.ts +0 -1552
- package/dist/client.d.ts +0 -5
- package/dist/edit-MT4B37QK.js +0 -7
- package/dist/functions.d.ts +0 -13
- package/dist/plugin.d.ts +0 -5
- package/dist/richtext.d.ts +0 -104
package/dist/plugin.js
CHANGED
|
@@ -6,30 +6,31 @@ import {
|
|
|
6
6
|
generatePublishMessage,
|
|
7
7
|
getAiConfig,
|
|
8
8
|
getServerVersion,
|
|
9
|
+
mergeIncomingMessage,
|
|
9
10
|
normalizeExecutionMode,
|
|
10
11
|
runChatStream,
|
|
11
12
|
runEditObjectStream,
|
|
12
13
|
serializeAiConfig,
|
|
13
14
|
summarizeDiff,
|
|
14
15
|
translateString
|
|
15
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-7Z5IRD2G.js";
|
|
16
17
|
import {
|
|
17
18
|
runCronJobs
|
|
18
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-PNLLZXVY.js";
|
|
19
20
|
import {
|
|
20
21
|
SearchIndexService
|
|
21
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-RXWDB3K4.js";
|
|
22
23
|
import {
|
|
23
24
|
RootCMSClient,
|
|
24
25
|
parseDocId,
|
|
25
26
|
unmarshalData
|
|
26
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-N4K6ICFR.js";
|
|
27
28
|
import "./chunk-MLKGABMK.js";
|
|
28
29
|
|
|
29
30
|
// core/plugin.ts
|
|
30
|
-
import { promises as fs2 } from "fs";
|
|
31
|
-
import path2 from "path";
|
|
32
|
-
import { fileURLToPath } from "url";
|
|
31
|
+
import { promises as fs2 } from "node:fs";
|
|
32
|
+
import path2 from "node:path";
|
|
33
|
+
import { fileURLToPath } from "node:url";
|
|
33
34
|
import { viteSsrLoadModule } from "@blinkk/root/node";
|
|
34
35
|
import bodyParser from "body-parser";
|
|
35
36
|
import {
|
|
@@ -55,8 +56,8 @@ var SSEEvent = {
|
|
|
55
56
|
};
|
|
56
57
|
|
|
57
58
|
// core/api.ts
|
|
58
|
-
import { promises as fs } from "fs";
|
|
59
|
-
import path from "path";
|
|
59
|
+
import { promises as fs } from "node:fs";
|
|
60
|
+
import path from "node:path";
|
|
60
61
|
import { multipartMiddleware } from "@blinkk/root/middleware";
|
|
61
62
|
|
|
62
63
|
// core/csv.ts
|
|
@@ -79,8 +80,8 @@ function csvToArray(csvString) {
|
|
|
79
80
|
}
|
|
80
81
|
|
|
81
82
|
// core/url-safety.ts
|
|
82
|
-
import {
|
|
83
|
-
import {
|
|
83
|
+
import { lookup } from "node:dns/promises";
|
|
84
|
+
import { isIP } from "node:net";
|
|
84
85
|
var PRIVATE_HOSTNAMES = /* @__PURE__ */ new Set([
|
|
85
86
|
"localhost",
|
|
86
87
|
"metadata",
|
|
@@ -159,7 +160,7 @@ async function assertPublicHttpUrl(input, options) {
|
|
|
159
160
|
}
|
|
160
161
|
return parsed;
|
|
161
162
|
}
|
|
162
|
-
let addresses
|
|
163
|
+
let addresses;
|
|
163
164
|
try {
|
|
164
165
|
addresses = await lookup(hostname, { all: true, verbatim: true });
|
|
165
166
|
} catch (err) {
|
|
@@ -684,7 +685,7 @@ function api(server, options) {
|
|
|
684
685
|
}
|
|
685
686
|
const store = new ChatStore(cmsClient, req.user.email);
|
|
686
687
|
const requestedChatId = typeof body.chatId === "string" ? body.chatId.trim() : "";
|
|
687
|
-
let chatId
|
|
688
|
+
let chatId;
|
|
688
689
|
let storedMessages = [];
|
|
689
690
|
let existingTitle = "";
|
|
690
691
|
if (requestedChatId) {
|
|
@@ -714,7 +715,10 @@ function api(server, options) {
|
|
|
714
715
|
}
|
|
715
716
|
let messages;
|
|
716
717
|
if (body.message && typeof body.message === "object") {
|
|
717
|
-
messages =
|
|
718
|
+
messages = mergeIncomingMessage(
|
|
719
|
+
storedMessages,
|
|
720
|
+
body.message
|
|
721
|
+
);
|
|
718
722
|
} else if (Array.isArray(body.messages) && body.messages.length > 0) {
|
|
719
723
|
messages = body.messages;
|
|
720
724
|
} else {
|
|
@@ -747,127 +751,118 @@ function api(server, options) {
|
|
|
747
751
|
}
|
|
748
752
|
}
|
|
749
753
|
});
|
|
750
|
-
server.use(
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
res.status(400).json({ success: false, error: "BAD_REQUEST" });
|
|
755
|
-
return;
|
|
756
|
-
}
|
|
757
|
-
if (!req.user?.email) {
|
|
758
|
-
res.status(401).json({ success: false, error: "UNAUTHORIZED" });
|
|
759
|
-
return;
|
|
760
|
-
}
|
|
761
|
-
const aiConfig = getAiConfig(req.rootConfig);
|
|
762
|
-
if (!aiConfig) {
|
|
763
|
-
res.status(404).json({ success: false, error: "AI_NOT_CONFIGURED" });
|
|
764
|
-
return;
|
|
765
|
-
}
|
|
766
|
-
const body = req.body || {};
|
|
767
|
-
const messages = body.messages || [];
|
|
768
|
-
if (!Array.isArray(messages) || messages.length === 0) {
|
|
769
|
-
res.status(400).json({ success: false, error: "MISSING_MESSAGES" });
|
|
770
|
-
return;
|
|
771
|
-
}
|
|
772
|
-
const model = findModel(aiConfig, body.modelId);
|
|
773
|
-
if (!model) {
|
|
774
|
-
res.status(400).json({ success: false, error: "UNKNOWN_MODEL" });
|
|
775
|
-
return;
|
|
776
|
-
}
|
|
777
|
-
const editCmsClient = new RootCMSClient(req.rootConfig);
|
|
778
|
-
try {
|
|
779
|
-
const role = await editCmsClient.getUserRole(req.user.email);
|
|
780
|
-
if (!role) {
|
|
781
|
-
res.status(403).json({ success: false, error: "FORBIDDEN" });
|
|
782
|
-
return;
|
|
783
|
-
}
|
|
784
|
-
} catch (err) {
|
|
785
|
-
console.error("failed to resolve user role:", err);
|
|
786
|
-
res.status(500).json({ success: false, error: "UNKNOWN" });
|
|
787
|
-
return;
|
|
788
|
-
}
|
|
789
|
-
try {
|
|
790
|
-
const streamResponse = await runEditObjectStream({
|
|
791
|
-
rootConfig: req.rootConfig,
|
|
792
|
-
cmsClient: editCmsClient,
|
|
793
|
-
user: req.user.email,
|
|
794
|
-
config: aiConfig,
|
|
795
|
-
model,
|
|
796
|
-
messages,
|
|
797
|
-
editData: body.editData,
|
|
798
|
-
loadCollection: (collectionId) => getCollectionSchema(req, collectionId),
|
|
799
|
-
loadAllCollections: async () => (await options.getRenderer(req)).getCollections()
|
|
800
|
-
});
|
|
801
|
-
await pipeWebResponse(streamResponse, res);
|
|
802
|
-
} catch (err) {
|
|
803
|
-
console.error(err.stack || err);
|
|
804
|
-
if (!res.headersSent) {
|
|
805
|
-
res.status(500).json({ success: false, error: err.message || "UNKNOWN" });
|
|
806
|
-
} else {
|
|
807
|
-
res.end();
|
|
808
|
-
}
|
|
809
|
-
}
|
|
754
|
+
server.use("/cms/api/ai.edit_object", async (req, res) => {
|
|
755
|
+
if (req.method !== "POST") {
|
|
756
|
+
res.status(400).json({ success: false, error: "BAD_REQUEST" });
|
|
757
|
+
return;
|
|
810
758
|
}
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
async (req, res) => {
|
|
815
|
-
if (!req.user?.email) {
|
|
816
|
-
res.status(401).json({ success: false, error: "UNAUTHORIZED" });
|
|
817
|
-
return;
|
|
818
|
-
}
|
|
819
|
-
const cmsClient = new RootCMSClient(req.rootConfig);
|
|
820
|
-
const store = new ChatStore(cmsClient, req.user.email);
|
|
821
|
-
try {
|
|
822
|
-
const chats = await store.listChats({ limit: req.body?.limit });
|
|
823
|
-
res.status(200).json({
|
|
824
|
-
success: true,
|
|
825
|
-
chats: chats.map((c) => ({
|
|
826
|
-
id: c.id,
|
|
827
|
-
title: c.title,
|
|
828
|
-
modelId: c.modelId,
|
|
829
|
-
createdAt: c.createdAt.toMillis(),
|
|
830
|
-
modifiedAt: c.modifiedAt.toMillis()
|
|
831
|
-
}))
|
|
832
|
-
});
|
|
833
|
-
} catch (err) {
|
|
834
|
-
console.error(err.stack || err);
|
|
835
|
-
res.status(500).json({ success: false, error: "UNKNOWN" });
|
|
836
|
-
}
|
|
759
|
+
if (!req.user?.email) {
|
|
760
|
+
res.status(401).json({ success: false, error: "UNAUTHORIZED" });
|
|
761
|
+
return;
|
|
837
762
|
}
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
763
|
+
const aiConfig = getAiConfig(req.rootConfig);
|
|
764
|
+
if (!aiConfig) {
|
|
765
|
+
res.status(404).json({ success: false, error: "AI_NOT_CONFIGURED" });
|
|
766
|
+
return;
|
|
767
|
+
}
|
|
768
|
+
const body = req.body || {};
|
|
769
|
+
const messages = body.messages || [];
|
|
770
|
+
if (!Array.isArray(messages) || messages.length === 0) {
|
|
771
|
+
res.status(400).json({ success: false, error: "MISSING_MESSAGES" });
|
|
772
|
+
return;
|
|
773
|
+
}
|
|
774
|
+
const model = findModel(aiConfig, body.modelId);
|
|
775
|
+
if (!model) {
|
|
776
|
+
res.status(400).json({ success: false, error: "UNKNOWN_MODEL" });
|
|
777
|
+
return;
|
|
778
|
+
}
|
|
779
|
+
const editCmsClient = new RootCMSClient(req.rootConfig);
|
|
780
|
+
try {
|
|
781
|
+
const role = await editCmsClient.getUserRole(req.user.email);
|
|
782
|
+
if (!role) {
|
|
783
|
+
res.status(403).json({ success: false, error: "FORBIDDEN" });
|
|
849
784
|
return;
|
|
850
785
|
}
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
786
|
+
} catch (err) {
|
|
787
|
+
console.error("failed to resolve user role:", err);
|
|
788
|
+
res.status(500).json({ success: false, error: "UNKNOWN" });
|
|
789
|
+
return;
|
|
790
|
+
}
|
|
791
|
+
try {
|
|
792
|
+
const streamResponse = await runEditObjectStream({
|
|
793
|
+
rootConfig: req.rootConfig,
|
|
794
|
+
cmsClient: editCmsClient,
|
|
795
|
+
user: req.user.email,
|
|
796
|
+
config: aiConfig,
|
|
797
|
+
model,
|
|
798
|
+
messages,
|
|
799
|
+
editData: body.editData,
|
|
800
|
+
loadCollection: (collectionId) => getCollectionSchema(req, collectionId),
|
|
801
|
+
loadAllCollections: async () => (await options.getRenderer(req)).getCollections()
|
|
802
|
+
});
|
|
803
|
+
await pipeWebResponse(streamResponse, res);
|
|
804
|
+
} catch (err) {
|
|
805
|
+
console.error(err.stack || err);
|
|
806
|
+
if (!res.headersSent) {
|
|
807
|
+
res.status(500).json({ success: false, error: err.message || "UNKNOWN" });
|
|
808
|
+
} else {
|
|
809
|
+
res.end();
|
|
857
810
|
}
|
|
811
|
+
}
|
|
812
|
+
});
|
|
813
|
+
server.use("/cms/api/ai.chats.list", async (req, res) => {
|
|
814
|
+
if (!req.user?.email) {
|
|
815
|
+
res.status(401).json({ success: false, error: "UNAUTHORIZED" });
|
|
816
|
+
return;
|
|
817
|
+
}
|
|
818
|
+
const cmsClient = new RootCMSClient(req.rootConfig);
|
|
819
|
+
const store = new ChatStore(cmsClient, req.user.email);
|
|
820
|
+
try {
|
|
821
|
+
const chats = await store.listChats({ limit: req.body?.limit });
|
|
858
822
|
res.status(200).json({
|
|
859
823
|
success: true,
|
|
860
|
-
|
|
861
|
-
id:
|
|
862
|
-
title:
|
|
863
|
-
modelId:
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
}
|
|
824
|
+
chats: chats.map((c) => ({
|
|
825
|
+
id: c.id,
|
|
826
|
+
title: c.title,
|
|
827
|
+
modelId: c.modelId,
|
|
828
|
+
createdAt: c.createdAt.toMillis(),
|
|
829
|
+
modifiedAt: c.modifiedAt.toMillis()
|
|
830
|
+
}))
|
|
868
831
|
});
|
|
832
|
+
} catch (err) {
|
|
833
|
+
console.error(err.stack || err);
|
|
834
|
+
res.status(500).json({ success: false, error: "UNKNOWN" });
|
|
869
835
|
}
|
|
870
|
-
);
|
|
836
|
+
});
|
|
837
|
+
server.use("/cms/api/ai.chats.get", async (req, res) => {
|
|
838
|
+
if (!req.user?.email) {
|
|
839
|
+
res.status(401).json({ success: false, error: "UNAUTHORIZED" });
|
|
840
|
+
return;
|
|
841
|
+
}
|
|
842
|
+
const id = String(req.body?.id || "").trim();
|
|
843
|
+
if (!id) {
|
|
844
|
+
res.status(400).json({ success: false, error: "MISSING_ID" });
|
|
845
|
+
return;
|
|
846
|
+
}
|
|
847
|
+
const cmsClient = new RootCMSClient(req.rootConfig);
|
|
848
|
+
const store = new ChatStore(cmsClient, req.user.email);
|
|
849
|
+
const chat = await store.getChat(id);
|
|
850
|
+
if (!chat) {
|
|
851
|
+
res.status(404).json({ success: false, error: "NOT_FOUND" });
|
|
852
|
+
return;
|
|
853
|
+
}
|
|
854
|
+
res.status(200).json({
|
|
855
|
+
success: true,
|
|
856
|
+
chat: {
|
|
857
|
+
id: chat.id,
|
|
858
|
+
title: chat.title,
|
|
859
|
+
modelId: chat.modelId,
|
|
860
|
+
messages: chat.messages,
|
|
861
|
+
createdAt: chat.createdAt.toMillis(),
|
|
862
|
+
modifiedAt: chat.modifiedAt.toMillis()
|
|
863
|
+
}
|
|
864
|
+
});
|
|
865
|
+
});
|
|
871
866
|
server.use(
|
|
872
867
|
"/cms/api/ai.chats.delete",
|
|
873
868
|
async (req, res) => {
|
|
@@ -955,7 +950,7 @@ function api(server, options) {
|
|
|
955
950
|
let collectionSchema = null;
|
|
956
951
|
try {
|
|
957
952
|
collectionSchema = await getCollectionSchema(req, collectionId);
|
|
958
|
-
} catch
|
|
953
|
+
} catch {
|
|
959
954
|
}
|
|
960
955
|
try {
|
|
961
956
|
const result = await check.run({
|
|
@@ -1073,7 +1068,7 @@ function sse(server) {
|
|
|
1073
1068
|
sseClients.forEach((res) => {
|
|
1074
1069
|
try {
|
|
1075
1070
|
res.write(message);
|
|
1076
|
-
} catch
|
|
1071
|
+
} catch {
|
|
1077
1072
|
sseClients.delete(res);
|
|
1078
1073
|
}
|
|
1079
1074
|
});
|
|
@@ -1754,7 +1749,7 @@ function cmsPlugin(options) {
|
|
|
1754
1749
|
if (process.env.NODE_ENV === "development" && options.watch !== false) {
|
|
1755
1750
|
plugin.onFileChange = (eventName, filepath) => {
|
|
1756
1751
|
if (filepath.endsWith(".schema.ts")) {
|
|
1757
|
-
import("./generate-types-
|
|
1752
|
+
import("./generate-types-JWIG4QVI.js").then((generateTypesModule) => {
|
|
1758
1753
|
const generateTypes = generateTypesModule.generateTypes;
|
|
1759
1754
|
generateTypes();
|
|
1760
1755
|
});
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared marshaling utilities for converting between plain arrays and
|
|
3
|
+
* Firestore-friendly "ArrayObject" format. These are pure functions with no
|
|
4
|
+
* Firebase dependency so they can run on both client and server.
|
|
5
|
+
*
|
|
6
|
+
* Rich text fields (detected by having `time`, `version`, and `blocks`
|
|
7
|
+
* properties) are returned as-is without any marshalling.
|
|
8
|
+
*/
|
|
9
|
+
export interface ArrayObject {
|
|
10
|
+
[key: string]: any;
|
|
11
|
+
_array: string[];
|
|
12
|
+
}
|
|
13
|
+
export interface ArrayObjectPathError {
|
|
14
|
+
/** The path segment where resolution failed. */
|
|
15
|
+
path: string;
|
|
16
|
+
/** Human-readable error message. */
|
|
17
|
+
message: string;
|
|
18
|
+
/** Expected path segment or current data shape. */
|
|
19
|
+
expected?: string;
|
|
20
|
+
/** Actual path segment or current data shape. */
|
|
21
|
+
received?: any;
|
|
22
|
+
}
|
|
23
|
+
export type ArrayObjectPathResult = {
|
|
24
|
+
ok: true;
|
|
25
|
+
path: string;
|
|
26
|
+
segments: string[];
|
|
27
|
+
} | {
|
|
28
|
+
ok: false;
|
|
29
|
+
error: ArrayObjectPathError;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Returns true if `data` looks like an already-marshaled ArrayObject (has an
|
|
33
|
+
* `_array` key that is a string[]).
|
|
34
|
+
*/
|
|
35
|
+
export declare function isArrayObject(data: any): data is ArrayObject;
|
|
36
|
+
/**
|
|
37
|
+
* Converts a user-facing CMS path with array indices into the stored
|
|
38
|
+
* Firestore path that uses ArrayObject keys.
|
|
39
|
+
*/
|
|
40
|
+
export declare function resolveArrayObjectPath(data: any, path: string): ArrayObjectPathResult;
|
|
41
|
+
/**
|
|
42
|
+
* Returns true if `data` looks like a rich text data object (EditorJS format
|
|
43
|
+
* with `time`, `version`, and `blocks` properties).
|
|
44
|
+
*/
|
|
45
|
+
export declare function isRichTextData(data: any): boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Recursively marshals data for Firestore storage:
|
|
48
|
+
* - Plain arrays are converted to ArrayObject format.
|
|
49
|
+
* - Rich text data (EditorJS format) is returned as-is without marshalling.
|
|
50
|
+
* - Items with an `_arrayKey` property use that as their key in the object.
|
|
51
|
+
*
|
|
52
|
+
* Accepts an optional `isTimestamp` predicate to handle Timestamp-like objects.
|
|
53
|
+
*/
|
|
54
|
+
export declare function marshalData(data: any, options?: {
|
|
55
|
+
isTimestamp?: (v: any) => boolean;
|
|
56
|
+
}): any;
|
|
57
|
+
/**
|
|
58
|
+
* Recursively unmarshals data from Firestore format:
|
|
59
|
+
* - ArrayObjects (objects with `_array`) are converted back to plain arrays.
|
|
60
|
+
* - Timestamp-like objects (with a `toMillis` method) are converted to millis.
|
|
61
|
+
*
|
|
62
|
+
* Accepts an optional `isTimestamp` predicate and `toValue` converter for
|
|
63
|
+
* handling Timestamp-like objects.
|
|
64
|
+
*/
|
|
65
|
+
export declare function unmarshalData(data: any, options?: {
|
|
66
|
+
isTimestamp?: (v: any) => boolean;
|
|
67
|
+
timestampToValue?: (v: any) => any;
|
|
68
|
+
}): any;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare function isObject(data: any): boolean;
|
|
2
|
+
/**
|
|
3
|
+
* Recursively sets data to an object using dot notation, e.g.
|
|
4
|
+
* ```
|
|
5
|
+
* setDeepKey({}, 'foo.bar', 'value');
|
|
6
|
+
* // => {foo: {bar: 'value'}}
|
|
7
|
+
* ```
|
|
8
|
+
*/
|
|
9
|
+
export declare function setDeepKey(data: any, deepKey: string, value: any): any;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
export type RichTextBlock = RichTextParagraphBlock | RichTextHeadingBlock | RichTextListBlock | RichTextTableBlock | RichTextImageBlock | RichTextHtmlBlock | RichTextCustomBlock;
|
|
2
|
+
export interface RichTextInlineComponent {
|
|
3
|
+
type: string;
|
|
4
|
+
data?: Record<string, any>;
|
|
5
|
+
}
|
|
6
|
+
export type RichTextInlineComponentsMap = Record<string, RichTextInlineComponent>;
|
|
7
|
+
export interface RichTextParagraphBlock {
|
|
8
|
+
type: 'paragraph';
|
|
9
|
+
data?: {
|
|
10
|
+
text?: string;
|
|
11
|
+
components?: RichTextInlineComponentsMap;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
export interface RichTextHeadingBlock {
|
|
15
|
+
type: 'heading';
|
|
16
|
+
data?: {
|
|
17
|
+
level?: number;
|
|
18
|
+
text?: string;
|
|
19
|
+
components?: RichTextInlineComponentsMap;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
export interface RichTextListItem {
|
|
23
|
+
content?: string;
|
|
24
|
+
itemsType?: 'orderedList' | 'unorderedList';
|
|
25
|
+
items?: RichTextListItem[];
|
|
26
|
+
components?: RichTextInlineComponentsMap;
|
|
27
|
+
}
|
|
28
|
+
export interface RichTextListBlock {
|
|
29
|
+
type: 'orderedList' | 'unorderedList';
|
|
30
|
+
data?: {
|
|
31
|
+
style?: 'ordered' | 'unordered';
|
|
32
|
+
items?: RichTextListItem[];
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
export interface RichTextTableCell {
|
|
36
|
+
blocks: RichTextBlock[];
|
|
37
|
+
type: 'header' | 'data';
|
|
38
|
+
}
|
|
39
|
+
export interface RichTextTableRow {
|
|
40
|
+
cells: RichTextTableCell[];
|
|
41
|
+
}
|
|
42
|
+
export interface RichTextTableBlock {
|
|
43
|
+
type: 'table';
|
|
44
|
+
data?: {
|
|
45
|
+
rows?: RichTextTableRow[];
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
export interface RichTextImageBlock {
|
|
49
|
+
type: 'image';
|
|
50
|
+
data?: {
|
|
51
|
+
file?: {
|
|
52
|
+
url: string;
|
|
53
|
+
width: string | number;
|
|
54
|
+
height: string | number;
|
|
55
|
+
alt: string;
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
export interface RichTextHtmlBlock {
|
|
60
|
+
type: 'html';
|
|
61
|
+
data?: {
|
|
62
|
+
html?: string;
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
export interface RichTextCustomBlock<TypeName = string, DataType = any> {
|
|
66
|
+
type: TypeName;
|
|
67
|
+
data?: DataType;
|
|
68
|
+
}
|
|
69
|
+
export interface RichTextData {
|
|
70
|
+
blocks: RichTextBlock[];
|
|
71
|
+
time: number;
|
|
72
|
+
version: string;
|
|
73
|
+
}
|
|
74
|
+
export declare function testValidRichTextData(data: RichTextData | unknown): boolean;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `JSON.stringify` does not escape characters that have meaning to an HTML
|
|
3
|
+
* parser, so a value containing `</script>` (or U+2028 / U+2029, which the
|
|
4
|
+
* JS spec treats as line terminators) embedded inside an inline `<script>`
|
|
5
|
+
* tag can break out of the script element and execute as HTML. This helper
|
|
6
|
+
* escapes those characters so the result is safe to interpolate into a
|
|
7
|
+
* `<script>` body.
|
|
8
|
+
*
|
|
9
|
+
* https://html.spec.whatwg.org/multipage/scripting.html#restrictions-for-contents-of-script-elements
|
|
10
|
+
*/
|
|
11
|
+
export declare function serializeJsonForScript(value: unknown): string;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sanitizes a string of HTML intended for inline formatting contexts
|
|
3
|
+
* (paragraph text, list items, headings). Strips scripts, event handlers
|
|
4
|
+
* and unsafe URL schemes; allows only inline formatting tags.
|
|
5
|
+
*/
|
|
6
|
+
export declare function sanitizeInlineHtml(html: string): string;
|
|
7
|
+
/**
|
|
8
|
+
* Sanitizes a string of HTML intended for block contexts (markdown output,
|
|
9
|
+
* arbitrary HTML blocks). Permits block-level structure (lists, tables,
|
|
10
|
+
* headings) in addition to inline formatting.
|
|
11
|
+
*/
|
|
12
|
+
export declare function sanitizeBlockHtml(html: string): string;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export declare function isSlugValid(slug: string, pattern?: string | RegExp): boolean;
|
|
2
|
+
/**
|
|
3
|
+
* Returns a human-readable error message explaining why a slug is invalid, or
|
|
4
|
+
* an empty string if the slug is valid.
|
|
5
|
+
*/
|
|
6
|
+
export declare function getSlugError(slug: string, pattern?: string | RegExp): string;
|
|
7
|
+
/**
|
|
8
|
+
* Normalizes a user-entered slug value into one appropriate for the CMS.
|
|
9
|
+
*
|
|
10
|
+
* In order to keep the slugs "flat" within firestore, nested paths use a double
|
|
11
|
+
* dash separator. For example, a URL like "/about/foo" should have a slug like
|
|
12
|
+
* "about--foo".
|
|
13
|
+
*
|
|
14
|
+
* Transformations include:
|
|
15
|
+
* Remove leading and trailing space
|
|
16
|
+
* Remove leading and trailing slash
|
|
17
|
+
* Replace '/' with '--', e.g. 'foo/bar' -> 'foo--bar'
|
|
18
|
+
*/
|
|
19
|
+
export declare function normalizeSlug(slug: string): string;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export declare const SSEEvent: {
|
|
2
|
+
/**
|
|
3
|
+
* First connection event.
|
|
4
|
+
*/
|
|
5
|
+
CONNECTED: string;
|
|
6
|
+
/**
|
|
7
|
+
* Changes to any .schema.ts file.
|
|
8
|
+
*/
|
|
9
|
+
SCHEMA_CHANGED: string;
|
|
10
|
+
};
|
|
11
|
+
export interface SSEConnectedEvent {
|
|
12
|
+
serverVersion: string;
|
|
13
|
+
}
|
|
14
|
+
export interface SSESchemaChangedEvent {
|
|
15
|
+
file: string;
|
|
16
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared utility functions for handling strings.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Cleans a source string for use in translations. Performs the following:
|
|
6
|
+
* - Removes any leading/trailing whitespace
|
|
7
|
+
* - Removes spaces at the end of any line (including )
|
|
8
|
+
*/
|
|
9
|
+
export declare function normalizeStr(str: string): string;
|
|
10
|
+
/**
|
|
11
|
+
* Returns a hash fingerprint for a string.
|
|
12
|
+
*
|
|
13
|
+
* Note that this hash function is meant to be fast and collision-free for use
|
|
14
|
+
* in a hash map, but is not intended for cryptographic purposes. For these
|
|
15
|
+
* reasons `FNV-1a` is used here.
|
|
16
|
+
*
|
|
17
|
+
* NOTE: farmhash-modern was previously tested here, but had issues with
|
|
18
|
+
* cjs/esm imports. A purejs implementation should be used here that can run on
|
|
19
|
+
* the server and in the browser.
|
|
20
|
+
*
|
|
21
|
+
* @see https://www.npmjs.com/package/fnv-plus
|
|
22
|
+
*/
|
|
23
|
+
export declare function hashStr(str: string): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as o}from"./chunk-JYFLU7DM.js";import"./chunk-PHBMVORG.js";import"./chunk-JZFTZ4X4.js";import"./chunk-HKINZLMW.js";import"./chunk-SKEP5WYH.js";import"./chunk-YDO2EDVY.js";import{a,b as i}from"./chunk-UEON4JAT.js";import"./chunk-5MV6XVGA.js";import"./chunk-EGEB6N4J.js";import"./chunk-AL3TN2KI.js";import{Ha as t}from"./chunk-NZHF733K.js";import"./chunk-KUCVLANF.js";import"./chunk-DTMZLUNY.js";import"./chunk-PVAE643M.js";function n(r){return a("AI"),t(i,{children:t(o,{variant:"page",initialChatId:r.chatId})})}export{n as AIPage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{k as _}from"./chunk-6IFGKSIE.js";import"./chunk-CGCKJFL4.js";import{a as f}from"./chunk-VMT7JFAM.js";import"./chunk-SKEP5WYH.js";import{a as h}from"./chunk-PJA7YP4A.js";import"./chunk-AFWBSIPL.js";import"./chunk-XOQ3KDSR.js";import"./chunk-62UWGWON.js";import"./chunk-I6ICVKEC.js";import{a as m}from"./chunk-HLMBCVRX.js";import"./chunk-ORXEMIQC.js";import{a as F,b as v}from"./chunk-UEON4JAT.js";import"./chunk-5MV6XVGA.js";import"./chunk-EGEB6N4J.js";import{f as p}from"./chunk-AL3TN2KI.js";import{Ga as u,Ha as a,W as r,a as t,ea as d,j as n,mb as c,oa as g}from"./chunk-NZHF733K.js";import"./chunk-KUCVLANF.js";import"./chunk-DTMZLUNY.js";import"./chunk-PVAE643M.js";n();n();function x(e){let[l,i]=t(e.value||null),[w,A]=t(null);e.value!==void 0&&e.value!==l&&i(e.value);let P=s=>{i(s),e.onChange&&e.onChange(s)},b={type:"file",label:""};return a("div",{className:p("FileUploader",e.className),children:a(_,{field:e.field||b,value:l,setValue:P,loadingState:w,setLoadingState:A,variant:e.variant,showNamingOptions:e.showNamingOptions,accept:e.accept,allowEditing:e.allowEditing})})}function J(){F("Assets");let[e,l]=t(null),i=e?.gcsPath?`https://storage.googleapis.com${e.gcsPath}`:"";return a(v,{children:a("div",{className:"AssetsPage","data-testid":"assets-page",children:[a("div",{className:"AssetsPage__header",children:[a(f,{size:"h1",children:"Assets"}),a(m,{as:"p",children:"Upload assets to the project's GCS bucket."})]}),a(h,{className:"AssetsPage__content",children:[a(x,{value:e,onChange:l,showNamingOptions:!0,accept:["*/*"],allowEditing:!1,className:"AssetsPage__uploader"}),e&&i&&a("div",{className:"AssetsPage__urlGroup",children:[a(o,{label:"GCS URL",url:i}),a(o,{label:"Google Image Service URL",url:e.src})]}),e&&!i&&a("div",{className:"AssetsPage__urlGroup",children:a(o,{url:e.src})}),e&&a(d,{variant:"outline",fullWidth:!0,onClick:()=>l(null),mt:"md",children:"Upload another file"})]})]})})}function o(e){return a("div",{className:"AssetsPage__urlRow",children:[e.label&&a("div",{className:"AssetsPage__urlRow__label",children:e.label}),a("div",{className:"AssetsPage__urlRow__input",children:[a(g,{readOnly:!0,value:e.url,autosize:!0,minRows:1,size:"xs",radius:"xs",onClick:l=>l.target.select(),styles:{root:{flex:1,minWidth:0}}}),a(y,{url:e.url})]})]})}function y(e){let[l,i]=t(!1);return a(u,{label:l?"Copied!":"Copy URL",position:"top",withArrow:!0,children:a(r,{variant:"default",size:"lg",onClick:()=>{navigator.clipboard.writeText(e.url).then(()=>{i(!0),setTimeout(()=>i(!1),2e3)})},children:a(c,{size:16})})})}export{J as AssetsPage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as U}from"./chunk-W3BJ2EZX.js";import{h as B}from"./chunk-GXSAEPU3.js";import{a as D,e as S,j as z}from"./chunk-NXQVLOTK.js";import{c as O,e as I}from"./chunk-3IYZCUPI.js";import"./chunk-RSVO46S3.js";import"./chunk-54DVDYU6.js";import{a as w}from"./chunk-X2WHBGTP.js";import{b as E,c as P}from"./chunk-ONTGW2VA.js";import"./chunk-4KE2SZKH.js";import{a as A}from"./chunk-L4RHGQUG.js";import"./chunk-HRGYNHZ3.js";import"./chunk-W3HIZQ4Z.js";import"./chunk-JDW4UORS.js";import"./chunk-YDO2EDVY.js";import{a as j}from"./chunk-PJA7YP4A.js";import"./chunk-AFWBSIPL.js";import"./chunk-XOQ3KDSR.js";import"./chunk-62UWGWON.js";import"./chunk-I6ICVKEC.js";import"./chunk-HLMBCVRX.js";import"./chunk-ORXEMIQC.js";import{a as R,b as $}from"./chunk-UEON4JAT.js";import{b as h}from"./chunk-5MV6XVGA.js";import"./chunk-EGEB6N4J.js";import{d as k}from"./chunk-AL3TN2KI.js";import{Aa as N,Da as L,Ha as o,V as y,a as x,c as T,db as u,ea as C,j as M}from"./chunk-NZHF733K.js";import{d as f}from"./chunk-KUCVLANF.js";import"./chunk-DTMZLUNY.js";import"./chunk-PVAE643M.js";M();function p(e){let{route:i}=k(),l=window.__ROOT_CTX.rootConfig.projectId;R(e.collection?e.collection:"Content"),T(()=>{let a=window.__ROOT_CTX.collections,s=`root-cms::${l}::last_collection`;if(e.collection)window.localStorage.setItem(s,e.collection);else{let t=window.localStorage.getItem(s);if(t&&a[t]){i(`/cms/content/${t}`);return}if(window.__ROOT_CTX.collections.Pages){i("/cms/content/Pages");return}let _=Object.keys(window.__ROOT_CTX.collections)||[];if(_.length>0){let d=_[0];i(`/cms/content/${d}`);return}console.warn("no collections")}},[e.collection,l]);let n=window.__ROOT_CTX.collections;return o($,{children:o("div",{className:"CollectionPage",children:o("div",{className:"CollectionPage__layout",children:[o("div",{className:"CollectionPage__side",children:o(U,{collections:n,activeCollectionId:e.collection,projectId:l})}),o("div",{className:"CollectionPage__main",children:e.collection&&o(p.Collection,{collection:e.collection},e.collection)})]})})})}p.Collection=e=>{let{roles:i}=A(),l=window.firebase.user.email||"",n=E(i,l),[a,s]=w(`root::CollectionPage:${e.collection}:orderBy`,"modifiedAt"),[t,_]=w(`root::CollectionPage:${e.collection}:showArchived`,!1),[d,r]=x(!1),m=window.__ROOT_CTX.collections[e.collection];if(!m)return route("/cms/content"),o(f,{});let v=[{value:"slug",label:"A-Z"},{value:"slugDesc",label:"Z-A"},{value:"newest",label:"Newest"},{value:"oldest",label:"Oldest"},{value:"modifiedAt",label:"Last modified"},...m.sortOptions?.map(g=>({value:g.id,label:g.label}))||[]],[c,X,b]=S(e.collection,{orderBy:a,includeArchived:t});return o(f,{children:[o(z,{collection:e.collection,opened:d,onClose:()=>r(!1)}),o("div",{className:"CollectionPage__collection",children:o("div",{className:"CollectionPage__collection__docsTab",children:[!c&&o("div",{className:"CollectionPage__collection__docsTab__header",children:[o("div",{className:"CollectionPage__collection__docsTab__header__title",children:m.name||e.collection}),o("div",{className:"CollectionPage__collection__docsTab__controls",children:[o("div",{className:"CollectionPage__collection__docsTab__controls__showArchived",children:o(L,{size:"sm",color:"dark",label:"Show archived:",checked:t,onChange:g=>_(!!g.currentTarget.checked)})}),o("div",{className:"CollectionPage__collection__docsTab__controls__sort",children:[o("div",{className:"CollectionPage__collection__docsTab__controls__sort__label",children:"Sort:"}),o(N,{size:"xs",value:a,onChange:g=>s(g||"modifiedAt"),data:v})]}),o("div",{className:"CollectionPage__collection__docsTab__controls__newDoc",children:o(P,{label:"You don't have access to create new documents",condition:!n,children:o(C,{color:"dark",size:"xs",leftIcon:o(u,{size:16}),onClick:()=>r(!0),disabled:!n,children:"New"})})})]})]}),o(j,{className:"CollectionPage__collection__docsTab__content",children:c?o("div",{className:"CollectionPage__collection__docsTab__content__loading",children:o(y,{color:"gray",size:"xl"})}):b.length===0?o("div",{class:"CollectionPage__collection__docsEmpty",children:[o("div",{class:"CollectionPage__collection__docsEmpty__title",children:"Collection is empty."}),o("div",{class:"CollectionPage__collection__docsEmpty__button",children:o(P,{label:"You don't have access to create new documents",condition:!n,children:o(C,{color:"dark",size:"xs",leftIcon:o(u,{size:16}),onClick:()=>r(!0),disabled:!n,children:"New"})})})]}):o(p.DocsList,{collection:e.collection,docs:b,reloadDocs:()=>X()})})]})})]})};p.DocsList=e=>{let i=e.collection,l=window.__ROOT_CTX.collections[e.collection];if(!l)throw new Error(`could not find collection: ${i}`);let n=!!l.url,a=e.docs||[];function s(t){return n?D({collectionId:i,slug:t}):""}return o("div",{className:"CollectionPage__collection__docsList",children:a.map(t=>{let _=`/cms/content/${i}/${t.slug}`,d=s(t.slug),r=t.fields||{},m=h(r,l.preview?.title||"meta.title"),v=h(r,l.preview?.image||"meta.image")||l.preview?.defaultImage;return o("div",{className:"CollectionPage__collection__docsList__doc",children:[o("div",{className:"CollectionPage__collection__docsList__doc__image",children:o("a",{href:_,children:o(I,{file:v,width:120,height:90,withPlaceholder:!v?.src})})}),o("a",{className:"CollectionPage__collection__docsList__doc__content",href:_,children:[o("div",{className:"CollectionPage__collection__docsList__doc__content__header",children:[o("div",{className:"CollectionPage__collection__docsList__doc__content__header__docId",children:t.id}),o(O,{doc:t})]}),o("div",{className:"CollectionPage__collection__docsList__doc__content__title",children:m||"[UNTITLED]"}),n&&d&&o("div",{className:"CollectionPage__collection__docsList__doc__content__url",children:d})]}),o("div",{className:"CollectionPage__collection__docsList__doc__controls",children:o(B,{docId:t.id,data:t,onAction:c=>{(c.action==="archive"||c.action==="copy"||c.action==="unarchive"||c.action==="delete"||c.action==="unpublish"||c.action==="locked"||c.action==="unlocked")&&e.reloadDocs()}})})]},t.id)})})};export{p as CollectionPage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b as s}from"./chunk-YFA6U2CV.js";import"./chunk-JZFTZ4X4.js";import"./chunk-AFWBSIPL.js";import"./chunk-XOQ3KDSR.js";import"./chunk-HLMBCVRX.js";import"./chunk-ORXEMIQC.js";import{a as d,b as m}from"./chunk-UEON4JAT.js";import"./chunk-5MV6XVGA.js";import"./chunk-EGEB6N4J.js";import{d as t}from"./chunk-AL3TN2KI.js";import{Ha as a,g as i,j as p}from"./chunk-NZHF733K.js";import"./chunk-KUCVLANF.js";import"./chunk-DTMZLUNY.js";import"./chunk-PVAE643M.js";p();function h(){let{query:r}=t();d("Compare");let o=i(()=>n(r.left||""),[r.left]),e=i(()=>n(r.right||""),[r.right]);return a(m,{children:a("div",{className:"ComparePage",children:o&&e?a(s,{className:"ComparePage__diff",left:o,right:e}):a("div",{className:"ComparePage__error",children:"Invalid params, double check query params."})})})}function n(r){let[o,e]=String(r).split("@");return o&&e?{docId:o,versionId:e}:null}export{h as ComparePage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as m}from"./chunk-KKEWCXVV.js";import"./chunk-CGCKJFL4.js";import{a as P}from"./chunk-VMT7JFAM.js";import{a as T}from"./chunk-X2WHBGTP.js";import{b as y,c as w}from"./chunk-ONTGW2VA.js";import{b as v}from"./chunk-4KE2SZKH.js";import{a as x}from"./chunk-L4RHGQUG.js";import"./chunk-W3HIZQ4Z.js";import{a as k}from"./chunk-PJA7YP4A.js";import"./chunk-I6ICVKEC.js";import{a as p}from"./chunk-HLMBCVRX.js";import{b as u}from"./chunk-ORXEMIQC.js";import{a as A,b as B}from"./chunk-UEON4JAT.js";import"./chunk-EGEB6N4J.js";import"./chunk-AL3TN2KI.js";import{Da as b,Ea as D,Ga as i,Ha as e,Kc as S,V as g,W as f,a as d,c as h,ca as s,ea as _,g as c,j as G}from"./chunk-NZHF733K.js";import"./chunk-KUCVLANF.js";import"./chunk-DTMZLUNY.js";import"./chunk-PVAE643M.js";G();var z={transition:"pop"};function O(a){let o=a.dataSource;return N(o.archivedAt)?e(i,{...z,label:`Archived ${L(o.archivedAt)} by ${o.archivedBy}`,children:e(s,{size:"xs",color:"gray",variant:"filled",children:"Archived"})}):N(o.publishedAt)?e(i,{...z,label:`Published ${L(o.publishedAt)} by ${o.publishedBy}`,children:e(s,{size:"xs",variant:"gradient",gradient:{from:"teal",to:"lime",deg:105},children:"Published"})}):e(s,{size:"xs",variant:"gradient",gradient:{from:"indigo",to:"cyan"},children:"Unpublished"})}function N(a){return!!(a&&a.toMillis)}function L(a){return a?.toMillis?u(a.toMillis()):u(new Date().getTime())}function E(){A("Data Sources");let{roles:a}=x(),o=window.firebase.user.email||"",r=y(a,o);return e(B,{children:e("div",{className:"DataPage",children:[e("div",{className:"DataPage__header",children:[e(P,{size:"h1",children:"Data Sources"}),e(p,{as:"p",children:"Add data sources to sync data from external services, like Google Sheets."}),e("div",{className:"DataPage__header__buttons",children:e(w,{label:"You don't have access to create new data sources",condition:!r,children:e(_,{component:"a",color:"blue",size:"xs",href:"/cms/data/new",disabled:!r,style:r?void 0:{pointerEvents:"none"},children:"New data source"})})})]}),e(E.DataSourcesTable,{})]})})}E.DataSourcesTable=()=>{let[a,o]=d(!0),[r,I]=d([]),[l,$]=T("root::DataPage:showArchived",!1),C=t=>!!t&&t.startsWith("https://docs.google.com/spreadsheets/");async function M(){let t=await v();I(t),o(!1)}let H=c(()=>r.some(t=>!!t.archivedAt),[r]),n=c(()=>r.filter(t=>{let U=!!t.archivedAt;return l?!0:!U}),[r,l]);return h(()=>{M()},[]),e("div",{className:"DataPage__DataSourcesTable",children:[!a&&H&&e("div",{className:"DataPage__DataSourcesTable__filters",children:e(b,{size:"sm",color:"dark",label:"Show archived",checked:l,onChange:t=>$(!!t.currentTarget.checked)})}),e(k,{children:[a&&e(g,{color:"gray",size:"xl"}),!a&&n.length>0&&e(D,{verticalSpacing:"xs",striped:!0,highlightOnHover:!0,fontSize:"xs",children:[e("thead",{children:e("tr",{children:[e("th",{children:"id"}),e("th",{children:"description"}),e("th",{children:"type"}),e("th",{children:"url"}),e("th",{children:"status"}),e("th",{children:"last synced"}),e("th",{children:"last published"})]})}),e("tbody",{children:n.map(t=>e("tr",{children:[e("td",{children:e("a",{href:`/cms/data/${t.id}`,children:t.id})}),e("td",{children:t.description||""}),e("td",{children:t.type}),e("td",{children:C(t.url)?e("div",{className:"DataPage__DataSourcesTable__url",children:[e(i,{label:"Open spreadsheet",children:e(f,{component:"a",href:t.url,target:"_blank",rel:"noreferrer",variant:"filled",color:"green",size:"sm","aria-label":"Open spreadsheet",children:e(S,{size:16,stroke:"2.25"})})}),e("a",{className:"DataPage__DataSourcesTable__url__text",href:t.url,target:"_blank",rel:"noreferrer",children:t.url})]}):t.url||""}),e("td",{children:e(O,{dataSource:t})}),e("td",{children:e(m,{dataSource:t,action:"sync"})}),e("td",{children:e(m,{dataSource:t,action:"publish"})})]},t.id))})]}),!a&&n.length===0&&e(p,{as:"p",children:"No data sources found for this filter."})]})]})};export{E as DataPage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as f}from"./chunk-KKEWCXVV.js";import"./chunk-CGCKJFL4.js";import{a as g}from"./chunk-VMT7JFAM.js";import"./chunk-ONTGW2VA.js";import{c as T,d as N}from"./chunk-4KE2SZKH.js";import"./chunk-L4RHGQUG.js";import"./chunk-W3HIZQ4Z.js";import{a as h}from"./chunk-PJA7YP4A.js";import"./chunk-I6ICVKEC.js";import{a as A}from"./chunk-HLMBCVRX.js";import"./chunk-ORXEMIQC.js";import{a as W,b as H}from"./chunk-UEON4JAT.js";import"./chunk-EGEB6N4J.js";import"./chunk-AL3TN2KI.js";import{Dc as k,Ea as D,Ga as p,Ha as a,Kc as z,V as b,W as m,a as _,c as y,da as v,ea as x,j as B,oa as P,pa as w}from"./chunk-NZHF733K.js";import"./chunk-KUCVLANF.js";import"./chunk-DTMZLUNY.js";import"./chunk-PVAE643M.js";B();function r(t){W(`Data Source: ${t.id}`);let[o,l]=_(!0),[e,u]=_(null),[n,c]=_(null),i=t.id;async function d(){let s=await T(i);if(u(s),s){let I=await N(i,{mode:"draft"});c(I)}l(!1)}y(()=>{d()},[]);function S(s){s==="sync"&&d()}return a(H,{children:a("div",{className:"DataSourcePage",children:[a("div",{className:"DataSourcePage__header",children:[a(v,{className:"DataSourcePage__header__breadcrumbs",children:[a("a",{href:"/cms/data",children:"Data"}),a("div",{children:i})]}),a("div",{className:"DataSourcePage__header__titleWrap",children:[a(g,{size:"h1",children:["Data Source: ",i]}),a("div",{className:"DataSourcePage__header__controls",children:a(p,{label:"Configure",children:a(m,{component:"a",href:`/cms/data/${t.id}/edit`,children:a(k,{size:24,stroke:"1.5"})})})})]}),e?.description&&a(A,{as:"p",children:e.description})]}),e&&a(r.SyncStatus,{dataSource:e,onAction:S}),o?a(b,{color:"gray",size:"xl"}):e?a(r.DataSection,{dataSource:e,data:n}):a("div",{className:"DataSourcePage__notFound",children:"Not Found"})]})})}r.SyncStatus=t=>{let o=t.dataSource;return a("div",{className:"DataSourcePage__SyncStatus",children:[a(g,{size:"h2",children:"Status"}),a(h,{className:"DataSourcePage__SyncStatus__content",children:a(D,{verticalSpacing:"xs",striped:!0,highlightOnHover:!0,fontSize:"xs",children:[a("thead",{children:a("tr",{children:[a("th",{children:"last synced"}),a("th",{children:"last published"})]})}),a("tbody",{children:a("tr",{children:[a("td",{children:a(f,{dataSource:o,action:"sync",onAction:()=>{t.onAction&&t.onAction("sync")}})}),a("td",{children:a(f,{dataSource:o,action:"publish"})})]})})]})})]})};r.DataSection=t=>{let{data:o,headers:l}=t.data||{},e=t.dataSource;if(!o)return null;let u=e.dataFormat||"map";if(e.type==="gsheet"){let n=l,c=[];if(u==="array")c=o;else if(u==="map"){let i=o;if(!n){let d=new Set;i.forEach(S=>{for(let s in S)s&&d.add(s)}),n=Array.from(d)}i.forEach(d=>{c.push(n.map(S=>d[S]||""))})}return a(r.DataSectionWrap,{dataSource:e,children:a(r.DataTable,{headers:n,rows:c})})}return e.type==="http"?a(r.DataSectionWrap,{dataSource:e,children:a(r.DefaultDataDisplay,{data:o})}):(console.log(`unsupported data type: ${e.type}`),null)};r.DataSectionWrap=t=>a("div",{className:"DataSourcePage__DataSection",children:[a("div",{className:"DataSourcePage__DataSection__header",children:[a(g,{size:"h2",children:"Data"}),a("div",{className:"DataSourcePage__DataSection__header__actions",children:[t.dataSource.url?.startsWith("https://docs.google.com/spreadsheets/")&&a(p,{label:"Open spreadsheet",children:a(m,{component:"a",href:t.dataSource.url,target:"_blank",variant:"filled",color:"green",children:a(z,{size:16,stroke:"2.25"})})}),t.dataSource.previewUrl&&a(x,{component:"a",variant:"default",size:"xs",href:t.dataSource.previewUrl,target:"_blank",children:"Preview"})]})]}),a(h,{className:"DataSourcePage__DataSection__content",children:t.children})]});r.DataTable=t=>{let o=t.headers||[],l=t.rows||[];return a("div",{className:"DataSourcePage__DataTable",children:a(D,{className:"DataSourcePage__DataTable__table",verticalSpacing:"xs",striped:!0,highlightOnHover:!0,fontSize:"xs",children:[o.length>0&&a("thead",{children:a("tr",{children:o.map(e=>a("th",{children:e},e))})}),a("tbody",{children:l.map((e,u)=>a("tr",{children:e.map((n,c)=>a("td",{children:n},c))},u))})]})})};r.DefaultDataDisplay=t=>{let o=t.data;return typeof o=="object"?a(w,{value:JSON.stringify(o,null,2),minRows:20,maxRows:100}):a(P,{value:String(o),minRows:12,maxRows:100})};export{r as DataSourcePage};
|