@adminide-stack/yantra-mobile 12.0.167-alpha.0 → 12.0.167
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/lib/assets/kinds/character.webp +0 -0
- package/lib/assets/kinds/image.webp +0 -0
- package/lib/assets/kinds/video.webp +0 -0
- package/lib/assets/kinds/website.webp +0 -0
- package/lib/bridge/handlers/NavigationBridgeHandler.js +3 -2
- package/lib/bridge/handlers/NavigationBridgeHandler.js.map +1 -1
- package/lib/components/CustomDrawer.js +6 -2
- package/lib/components/CustomDrawer.js.map +1 -1
- package/lib/features/agent-chat/NativeAgentChat.js +17 -3
- package/lib/features/agent-chat/NativeAgentChat.js.map +1 -1
- package/lib/features/chat/ApprovalCard.js +8 -2
- package/lib/features/chat/ApprovalCard.js.map +1 -1
- package/lib/features/chat/AskUserCard.js +5 -3
- package/lib/features/chat/AskUserCard.js.map +1 -1
- package/lib/features/chat/ComposerModeSwitch.js +147 -0
- package/lib/features/chat/ComposerModeSwitch.js.map +1 -0
- package/lib/features/templates/__tests__/buildKinds.test.ts +54 -0
- package/lib/features/templates/__tests__/buildTemplateCards.test.ts +58 -6
- package/lib/features/templates/__tests__/templateSuggestion.test.ts +30 -0
- package/lib/features/templates/buildKinds.js +114 -0
- package/lib/features/templates/buildKinds.js.map +1 -0
- package/lib/features/templates/buildKinds.ts +189 -0
- package/lib/features/templates/buildTemplateCards.js +63 -18
- package/lib/features/templates/buildTemplateCards.js.map +1 -1
- package/lib/features/templates/buildTemplateCards.ts +88 -18
- package/lib/features/templates/index.ts +2 -0
- package/lib/features/templates/templateSuggestion.js +34 -0
- package/lib/features/templates/templateSuggestion.js.map +1 -0
- package/lib/features/templates/templateSuggestion.ts +57 -0
- package/lib/features/webbuilder/WebBuilderExperience.js +188 -28
- package/lib/features/webbuilder/WebBuilderExperience.js.map +1 -1
- package/lib/features/webbuilder/approvalsLink.js +6 -0
- package/lib/features/webbuilder/approvalsLink.js.map +1 -0
- package/lib/features/webbuilder/buildFragments.js +19 -4
- package/lib/features/webbuilder/buildFragments.js.map +1 -1
- package/lib/features/webbuilder/components/CloudSheet.js +18 -5
- package/lib/features/webbuilder/components/CloudSheet.js.map +1 -1
- package/lib/features/webbuilder/components/CodeView.js +7 -3
- package/lib/features/webbuilder/components/CodeView.js.map +1 -1
- package/lib/features/webbuilder/components/DomainFinder.js +263 -0
- package/lib/features/webbuilder/components/DomainFinder.js.map +1 -0
- package/lib/features/webbuilder/components/DraftsSheet.js +298 -0
- package/lib/features/webbuilder/components/DraftsSheet.js.map +1 -0
- package/lib/features/webbuilder/components/ImageEditPanel.js +266 -0
- package/lib/features/webbuilder/components/ImageEditPanel.js.map +1 -0
- package/lib/features/webbuilder/components/MentionMenu.js +155 -0
- package/lib/features/webbuilder/components/MentionMenu.js.map +1 -0
- package/lib/features/webbuilder/components/NotesSheet.js +138 -0
- package/lib/features/webbuilder/components/NotesSheet.js.map +1 -0
- package/lib/features/webbuilder/components/PreviewFrame.js.map +1 -1
- package/lib/features/webbuilder/components/ProjectChat.js +17 -3
- package/lib/features/webbuilder/components/ProjectChat.js.map +1 -1
- package/lib/features/webbuilder/components/PublishSheet.js +200 -15
- package/lib/features/webbuilder/components/PublishSheet.js.map +1 -1
- package/lib/features/webbuilder/components/ShareSheet.js +48 -6
- package/lib/features/webbuilder/components/ShareSheet.js.map +1 -1
- package/lib/features/webbuilder/components/SiteCopyProgress.js +169 -0
- package/lib/features/webbuilder/components/SiteCopyProgress.js.map +1 -0
- package/lib/features/webbuilder/components/SiteStatusSheet.js +145 -2
- package/lib/features/webbuilder/components/SiteStatusSheet.js.map +1 -1
- package/lib/features/webbuilder/drafts.js +167 -0
- package/lib/features/webbuilder/drafts.js.map +1 -0
- package/lib/features/webbuilder/maskPng.js +113 -0
- package/lib/features/webbuilder/maskPng.js.map +1 -0
- package/lib/features/webbuilder/previewProbe.js.map +1 -1
- package/lib/features/webbuilder/stepLabels.js +21 -1
- package/lib/features/webbuilder/stepLabels.js.map +1 -1
- package/lib/features/webbuilder/web/chat/mentions.js +106 -0
- package/lib/features/webbuilder/web/chat/mentions.js.map +1 -0
- package/lib/features/webbuilder/web/chat/siteCopy.js +121 -0
- package/lib/features/webbuilder/web/chat/siteCopy.js.map +1 -0
- package/lib/features/webbuilder/web/code/imageEdit.js +30 -0
- package/lib/features/webbuilder/web/code/imageEdit.js.map +1 -0
- package/lib/features/webbuilder/web/design/linkedDesign.js +26 -0
- package/lib/features/webbuilder/web/design/linkedDesign.js.map +1 -0
- package/lib/features/webbuilder/web/project/buildLink.js +3 -0
- package/lib/features/webbuilder/web/project/buildLink.js.map +1 -0
- package/lib/features/webbuilder/web/project/drafts.js +57 -0
- package/lib/features/webbuilder/web/project/drafts.js.map +1 -0
- package/lib/features/webbuilder/web/project/navHistory.js +7 -0
- package/lib/features/webbuilder/web/project/navHistory.js.map +1 -0
- package/lib/features/webbuilder/web/project/serverSettings.js +15 -4
- package/lib/features/webbuilder/web/project/serverSettings.js.map +1 -1
- package/lib/features/webbuilder/web/publish/domainShop.js +79 -0
- package/lib/features/webbuilder/web/publish/domainShop.js.map +1 -0
- package/lib/features/webbuilder/web/publish/publishRequest.js +11 -0
- package/lib/features/webbuilder/web/publish/publishRequest.js.map +1 -0
- package/lib/features/webbuilder/web/publish/review/freshness.js +13 -0
- package/lib/features/webbuilder/web/publish/review/freshness.js.map +1 -0
- package/lib/features/webbuilder/web/publish/review/ignores.js +94 -0
- package/lib/features/webbuilder/web/publish/review/ignores.js.map +1 -0
- package/lib/features/webbuilder/web/publish/review/seo.js +230 -0
- package/lib/features/webbuilder/web/publish/review/seo.js.map +1 -0
- package/lib/features/webbuilder/web/publish/siteHealth.js +27 -3
- package/lib/features/webbuilder/web/publish/siteHealth.js.map +1 -1
- package/lib/features/webbuilder/web/publish/siteInsights.js +120 -3
- package/lib/features/webbuilder/web/publish/siteInsights.js.map +1 -1
- package/lib/features/webbuilder/web/sharing/shareLink.js +9 -0
- package/lib/features/webbuilder/web/sharing/shareLink.js.map +1 -0
- package/lib/features/webbuilder/web/webServices.js +1 -1
- package/lib/features/webbuilder/web/webServices.js.map +1 -1
- package/lib/hooks/useMarketplaceTemplateCards.js +3 -4
- package/lib/hooks/useMarketplaceTemplateCards.js.map +1 -1
- package/lib/hooks/useMarketplaceTemplateGroups.js +12 -5
- package/lib/hooks/useMarketplaceTemplateGroups.js.map +1 -1
- package/lib/hooks/useTemplatesResourceUri.js +12 -0
- package/lib/hooks/useTemplatesResourceUri.js.map +1 -0
- package/lib/screens/Chat/index.js +4 -22
- package/lib/screens/Chat/index.js.map +1 -1
- package/lib/screens/Home/HomeScreen.js +165 -179
- package/lib/screens/Home/HomeScreen.js.map +1 -1
- package/lib/screens/Home/components/BuildKindPicker.js +248 -0
- package/lib/screens/Home/components/BuildKindPicker.js.map +1 -0
- package/lib/screens/Home/components/BuildTemplatesSection.js +556 -117
- package/lib/screens/Home/components/BuildTemplatesSection.js.map +1 -1
- package/lib/screens/Home/components/KindThumb.js +444 -0
- package/lib/screens/Home/components/KindThumb.js.map +1 -0
- package/lib/screens/Home/components/TemplateSuggestionBanner.js +73 -0
- package/lib/screens/Home/components/TemplateSuggestionBanner.js.map +1 -0
- package/lib/screens/Home/components/buildTheme.js +68 -0
- package/lib/screens/Home/components/buildTheme.js.map +1 -0
- package/lib/screens/WebBuilder/index.js +11 -1
- package/lib/screens/WebBuilder/index.js.map +1 -1
- package/lib/screens/WebBuilder/nativeWebBuilderRedirect.js +55 -0
- package/lib/screens/WebBuilder/nativeWebBuilderRedirect.js.map +1 -0
- package/lib/screens/WebBuilderNative/codeWorkspaceApi.js +4 -0
- package/lib/screens/WebBuilderNative/codeWorkspaceApi.js.map +1 -1
- package/lib/screens/WebBuilderNative/index.js +31 -4
- package/lib/screens/WebBuilderNative/index.js.map +1 -1
- package/lib/screens/WebBuilderNative/useWebBuilderHost.js +1 -0
- package/lib/screens/WebBuilderNative/useWebBuilderHost.js.map +1 -1
- package/lib/screens/WebBuilderNative/webbuilderTransport.js +5 -5
- package/lib/screens/WebBuilderNative/webbuilderTransport.js.map +1 -1
- package/package.json +4 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"drafts.js","sources":["../../../../../src/features/webbuilder/web/project/drafts.ts"],"sourcesContent":["/**\n * Drafts: try changes on a copy of the project, then accept them into it (Lovable's \"Drafts\"). Pure.\n *\n * A draft is its own sandbox booted from a snapshot of the project's. Page-creator keeps the list\n * (`settings.drafts`, open ones only reach the page) and guarantees a draft never becomes the project's\n * build by itself: the agent's records in it are skipped, publishing it is refused, and only Accept moves\n * the project there. The page shows a draft by swapping the open project's sandbox for the draft's, so the\n * preview, code, visual edits and AI turns all work in the copy.\n */\nimport type { WebBuilderArtifact } from '../types';\n\nexport const DRAFT_NAME_MAX = 60;\nexport const MAX_OPEN_DRAFTS = 5;\n\nexport interface ProjectDraft {\n id: string;\n name: string;\n sandboxId: string;\n previewUrl: string | null;\n baseSandboxId: string | null;\n baseHead: string | null;\n createdBy: string | null;\n createdAt: string;\n}\n\nconst DRAFT_ID_RE = /^d_[A-Za-z0-9_-]{4,64}$/;\nconst SANDBOX_ID_RE = /^[A-Za-z0-9_-]{4,128}$/;\nconst SHA_RE = /^[a-f0-9]{7,40}$/i;\n\nexport function normalizeDraftName(raw: unknown): string | null {\n if (typeof raw !== 'string') return null;\n const name = raw\n .replace(/[\\u0000-\\u001F\\u007F]/g, ' ')\n .replace(/\\s+/g, ' ')\n .trim()\n .slice(0, DRAFT_NAME_MAX);\n return name || null;\n}\n\nconst httpsOrNull = (raw: unknown): string | null => {\n if (typeof raw !== 'string') return null;\n try {\n const u = new URL(raw);\n return u.protocol === 'https:' ? u.toString().replace(/\\/$/, '') : null;\n } catch {\n return null;\n }\n};\n\n/** The server's open drafts, re-validated; oldest first. */\nexport function normalizeDrafts(raw: unknown): ProjectDraft[] {\n if (!Array.isArray(raw)) return [];\n const out: ProjectDraft[] = [];\n const seen = new Set<string>();\n for (const d of raw) {\n if (!d || typeof d !== 'object') continue;\n const r = d as Record<string, unknown>;\n const id = typeof r.id === 'string' ? r.id : '';\n const sandboxId = typeof r.sandboxId === 'string' ? r.sandboxId : '';\n const name = normalizeDraftName(r.name);\n if (!DRAFT_ID_RE.test(id) || !SANDBOX_ID_RE.test(sandboxId) || !name || seen.has(id)) continue;\n seen.add(id);\n out.push({\n id,\n name,\n sandboxId,\n previewUrl: httpsOrNull(r.previewUrl),\n baseSandboxId:\n typeof r.baseSandboxId === 'string' && SANDBOX_ID_RE.test(r.baseSandboxId) ? r.baseSandboxId : null,\n baseHead: typeof r.baseHead === 'string' && SHA_RE.test(r.baseHead) ? r.baseHead.toLowerCase() : null,\n createdBy: typeof r.createdBy === 'string' && r.createdBy ? r.createdBy : null,\n createdAt: typeof r.createdAt === 'string' && !Number.isNaN(Date.parse(r.createdAt)) ? r.createdAt : '',\n });\n }\n return out;\n}\n\n/** \"Draft 1\", \"Draft 2\"... the first number no open draft uses. */\nexport function suggestDraftName(existing: ReadonlyArray<Pick<ProjectDraft, 'name'>>): string {\n const taken = new Set(existing.map((d) => d.name.toLowerCase()));\n for (let n = 1; ; n++) if (!taken.has(`draft ${n}`)) return `Draft ${n}`;\n}\n\n/** The project as shown while one of its drafts is open: the draft's sandbox and preview, marked as a draft. */\nexport function draftArtifact<T extends WebBuilderArtifact>(project: T, draft: ProjectDraft): T {\n return {\n ...project,\n sandboxId: draft.sandboxId,\n url: draft.previewUrl ?? project.url,\n // The project's restore point is not the draft's: never offered to the agent as a way back.\n snapshotId: null,\n draft: { id: draft.id, name: draft.name, projectSandboxId: project.sandboxId ?? null },\n };\n}\n\n/** The hidden note on every turn in a draft: change only the copy, never make it the project's build. */\nexport function draftTurnNote(draft: { name: string }, sandboxId: string | null | undefined): string {\n return `[Draft] This turn works in the draft \"${draft.name}\"${\n sandboxId ? ` (sandbox ${sandboxId})` : ''\n }: a copy of the project the user is trying out. Change only that sandbox. Do not publish it, do not record it as the project's build, and do not boot a new sandbox if it is gone (say so instead). The user accepts the draft into the project when they are happy with it.`;\n}\n\n/**\n * The project changed after the draft was copied (its HEAD moved): accepting the draft replaces those changes.\n * Unknown either way (no recorded base, no current head): false, nothing to warn about.\n */\nexport function projectChangedSinceDraft(\n draft: Pick<ProjectDraft, 'baseHead'>,\n projectHead: string | null | undefined,\n): boolean {\n const base = (draft.baseHead || '').toLowerCase();\n const head = (projectHead || '').toLowerCase();\n if (!base || !head) return false;\n return !(head.startsWith(base) || base.startsWith(head));\n}\n"],"names":[],"mappings":"AAUO,MAAM,cAAiB,GAAA;AACvB,MAAM,eAAkB,GAAA;AAW/B,MAAM,WAAc,GAAA,yBAAA;AACpB,MAAM,aAAgB,GAAA,wBAAA;AACtB,MAAM,MAAS,GAAA,mBAAA;AACR,SAAS,mBAAmB,GAA6B,EAAA;AAC9D,EAAI,IAAA,OAAO,GAAQ,KAAA,QAAA,EAAiB,OAAA,IAAA;AACpC,EAAA,MAAM,IAAO,GAAA,GAAA,CAAI,OAAQ,CAAA,wBAAA,EAA0B,GAAG,CAAE,CAAA,OAAA,CAAQ,MAAQ,EAAA,GAAG,CAAE,CAAA,IAAA,EAAO,CAAA,KAAA,CAAM,GAAG,cAAc,CAAA;AAC3G,EAAA,OAAO,IAAQ,IAAA,IAAA;AACjB;AACA,MAAM,WAAA,GAAc,CAAC,GAAgC,KAAA;AACnD,EAAI,IAAA,OAAO,GAAQ,KAAA,QAAA,EAAiB,OAAA,IAAA;AACpC,EAAI,IAAA;AACF,IAAM,MAAA,CAAA,GAAI,IAAI,GAAA,CAAI,GAAG,CAAA;AACrB,IAAO,OAAA,CAAA,CAAE,aAAa,QAAW,GAAA,CAAA,CAAE,UAAW,CAAA,OAAA,CAAQ,KAAO,EAAA,EAAE,CAAI,GAAA,IAAA;AAAA,GAC7D,CAAA,OAAA,CAAA,EAAA;AACN,IAAO,OAAA,IAAA;AAAA;AAEX,CAAA;AAGO,SAAS,gBAAgB,GAA8B,EAAA;AAC5D,EAAA,IAAI,CAAC,KAAM,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
|
+
const BUILD_PARAM = "build";
|
|
2
|
+
function withBuildParam(href, key) {
|
|
3
|
+
const url = new URL(href);
|
|
4
|
+
if (key) url.searchParams.set(BUILD_PARAM, key);
|
|
5
|
+
else url.searchParams.delete(BUILD_PARAM);
|
|
6
|
+
return url.toString();
|
|
7
|
+
}export{BUILD_PARAM,withBuildParam};//# sourceMappingURL=navHistory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"navHistory.js","sources":["../../../../../src/features/webbuilder/web/project/navHistory.ts"],"sourcesContent":["/**\n * Browser Back/Forward for the surface: opening a build from Home adds one history entry\n * (`?build=<key>`), switching builds replaces it, and leaving the build goes back to Home's entry.\n * Pure: the page applies the step to `window.history`.\n */\n\nexport const BUILD_PARAM = 'build';\n\n/** Our marker on a history entry (kept beside whatever the host router stored there). */\nexport interface BuildEntryState {\n wbBuild?: string;\n /** Read by the mobile shell's native back. */\n yantraWbPreview?: boolean;\n}\n\nexport type NavStep =\n | { kind: 'none' }\n /** Home's entry drops `?build`, then a new entry for the build. */\n | { kind: 'push'; key: string }\n /** The current entry now shows another build (or the same one under its new key). */\n | { kind: 'replace'; key: string }\n /** Leave the build's entry: the browser lands on Home's. */\n | { kind: 'back' }\n /** Home with a stale `?build` in the URL (no entry of ours): just clean the URL. */\n | { kind: 'clean' };\n\nexport function entryBuildKey(state: unknown): string | null {\n const v = state && typeof state === 'object' ? (state as BuildEntryState).wbBuild : undefined;\n return typeof v === 'string' && v ? v : null;\n}\n\nexport function urlBuildKey(href: string): string | null {\n try {\n return new URL(href).searchParams.get(BUILD_PARAM) || null;\n } catch {\n return null;\n }\n}\n\nexport function withBuildParam(href: string, key: string | null): string {\n const url = new URL(href);\n if (key) url.searchParams.set(BUILD_PARAM, key);\n else url.searchParams.delete(BUILD_PARAM);\n return url.toString();\n}\n\nexport function withBuildEntry(state: unknown, key: string | null): BuildEntryState & Record<string, unknown> {\n const base = state && typeof state === 'object' ? { ...(state as Record<string, unknown>) } : {};\n delete base.wbBuild;\n delete base.yantraWbPreview;\n return key ? { ...base, wbBuild: key, yantraWbPreview: true } : base;\n}\n\n/** What to do to the history so it matches the open build (`openKey`, null on Home). */\nexport function navStep(o: { openKey: string | null; entryKey: string | null; urlKey: string | null }): NavStep {\n const { openKey, entryKey, urlKey } = o;\n if (openKey) {\n if (!entryKey) return { kind: 'push', key: openKey };\n if (entryKey !== openKey || urlKey !== openKey) return { kind: 'replace', key: openKey };\n return { kind: 'none' };\n }\n if (entryKey) return { kind: 'back' };\n if (urlKey) return { kind: 'clean' };\n return { kind: 'none' };\n}\n"],"names":[],"mappings":"AAMO,MAAM,WAAc,GAAA;AAoCX,SAAA,cAAA,CAAe,MAAc,GAA4B,EAAA;AACvE,EAAM,MAAA,GAAA,GAAM,IAAI,GAAA,CAAI,IAAI,CAAA;AACxB,EAAA,IAAI,GAAK,EAAA,GAAA,CAAI,YAAa,CAAA,GAAA,CAAI,aAAa,GAAG,CAAA;AAAA,OAAO,GAAA,CAAI,YAAa,CAAA,MAAA,CAAO,WAAW,CAAA;AACxF,EAAA,OAAO,IAAI,QAAS,EAAA;AACtB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {normalizeProjectKnowledge,normalizeProjectTitle}from'./projectSettings.js';import {parseRestorePoint}from'./restorePoint.js';import {toDesignDirection}from'../design/directions.js';var __defProp = Object.defineProperty;
|
|
1
|
+
import {normalizeProjectKnowledge,normalizeProjectTitle}from'./projectSettings.js';import {parseRestorePoint}from'./restorePoint.js';import {toDesignDirection}from'../design/directions.js';import {toLinkedDesign}from'../design/linkedDesign.js';import {normalizeReviewIgnores}from'../publish/review/ignores.js';import {normalizeDrafts}from'./drafts.js';var __defProp = Object.defineProperty;
|
|
2
2
|
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
3
3
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
4
4
|
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
@@ -14,6 +14,10 @@ var __spreadValues = (a, b) => {
|
|
|
14
14
|
}
|
|
15
15
|
return a;
|
|
16
16
|
};
|
|
17
|
+
const PROJECT_NOTES_MAX = 2e4;
|
|
18
|
+
function normalizeProjectNotes(text) {
|
|
19
|
+
return String(text != null ? text : "").replace(/\r\n?/g, "\n").trim().slice(0, PROJECT_NOTES_MAX);
|
|
20
|
+
}
|
|
17
21
|
const IMPORT_KINDS = ["vite", "next", "unknown"];
|
|
18
22
|
function toImportKind(raw) {
|
|
19
23
|
const k = String(raw != null ? raw : "");
|
|
@@ -131,7 +135,7 @@ function parseServerProjectSettings(raw) {
|
|
|
131
135
|
const r = asObject(raw);
|
|
132
136
|
if (!r) return null;
|
|
133
137
|
const cred = String((_a = r.secretsCredentialId) != null ? _a : "").trim();
|
|
134
|
-
return {
|
|
138
|
+
return __spreadValues(__spreadValues(__spreadValues({
|
|
135
139
|
title: normalizeProjectTitle(typeof r.title === "string" ? r.title : ""),
|
|
136
140
|
instructions: normalizeProjectKnowledge(typeof r.instructions === "string" ? r.instructions : ""),
|
|
137
141
|
secretsCredentialId: OBJECT_ID_RE.test(cred) ? cred : null,
|
|
@@ -140,8 +144,15 @@ function parseServerProjectSettings(raw) {
|
|
|
140
144
|
database: asObject(r.database),
|
|
141
145
|
designDirection: toDesignDirection(asObject(r.designDirection)),
|
|
142
146
|
importedFrom: normalizeImportedFrom(r.importedFrom),
|
|
147
|
+
linkedDesign: toLinkedDesign(r.linkedDesign),
|
|
143
148
|
restorePoint: parseRestorePoint(asObject(r.restorePoint))
|
|
144
|
-
}
|
|
149
|
+
}, "notes" in r ? {
|
|
150
|
+
notes: normalizeProjectNotes(typeof r.notes === "string" ? r.notes : "")
|
|
151
|
+
} : {}), Array.isArray(r.reviewIgnores) ? {
|
|
152
|
+
reviewIgnores: normalizeReviewIgnores(r.reviewIgnores)
|
|
153
|
+
} : {}), Array.isArray(r.drafts) ? {
|
|
154
|
+
drafts: normalizeDrafts(r.drafts)
|
|
155
|
+
} : {});
|
|
145
156
|
}
|
|
146
157
|
function normalizeImportedFrom(raw) {
|
|
147
158
|
const r = asObject(raw);
|
|
@@ -154,4 +165,4 @@ function normalizeImportedFrom(raw) {
|
|
|
154
165
|
repoUrl,
|
|
155
166
|
at
|
|
156
167
|
};
|
|
157
|
-
}export{IMPORT_KINDS,MAX_INTEGRATIONS,PROJECT_SETTINGS_QUERY,normalizeBranch,normalizeGithubRepoUrl,normalizeGithubSettings,normalizeImportedFrom,normalizeIntegrations,parseServerProjectSettings,readSettingsUpdateReply,toImportKind};//# sourceMappingURL=serverSettings.js.map
|
|
168
|
+
}export{IMPORT_KINDS,MAX_INTEGRATIONS,PROJECT_NOTES_MAX,PROJECT_SETTINGS_QUERY,normalizeBranch,normalizeGithubRepoUrl,normalizeGithubSettings,normalizeImportedFrom,normalizeIntegrations,normalizeProjectNotes,parseServerProjectSettings,readSettingsUpdateReply,toImportKind};//# sourceMappingURL=serverSettings.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serverSettings.js","sources":["../../../../../src/features/webbuilder/web/project/serverSettings.ts"],"sourcesContent":["/**\n * Phase 5 §3/§7: per-project settings stored on the server (channel\n * `settings`) through `aiCodeProjectSettings` / `aiCodeUpdateProjectSettings`.\n * Pure: GraphQL documents, parsing, validation and the local -> server merge\n * and migration rules. The transport lives in `projectSettingsSync.ts`.\n *\n * The server never returns keys; nothing here ever holds one.\n */\n\nimport { PROJECT_KNOWLEDGE_MAX, normalizeProjectKnowledge, normalizeProjectTitle } from './projectSettings';\nimport { parseRestorePoint, type RestorePoint } from './restorePoint';\nimport { toDesignDirection, type DesignDirection } from '../design/directions';\n\n/** W28: one integration added to the site (Phase 5 spec §2). */\nexport interface ProjectIntegration {\n connectorId: string;\n title: string;\n credentialId?: string;\n purpose?: string;\n}\n\n/** W29: GitHub sync settings; the `last*` / `syncBranch` fields are written by the pipeline. */\nexport interface ProjectGithubSettings {\n repoUrl: string;\n branch: string;\n sync: boolean;\n lastPulledAt?: string | null;\n lastPushedAt?: string | null;\n /** Set when the repo diverged: our changes went to this branch instead (spec §4). */\n syncBranch?: string | null;\n lastCommit?: string | null;\n}\n\nexport interface ServerProjectSettings {\n title: string | null;\n instructions: string;\n secretsCredentialId: string | null;\n integrations: ProjectIntegration[];\n github: ProjectGithubSettings | null;\n /** W25 (stream D shows it): `{ provisioned, slug, url, status }` or null. */\n database: Record<string, unknown> | null;\n /** G4: the style direction picked before the first build; later edits keep its tokens. */\n designDirection?: DesignDirection | null;\n importedFrom?: ProjectImportedFrom | null;\n /** The latest restore point the server recorded (read-only; never sent in a patch). */\n restorePoint?: RestorePoint | null;\n}\n\nexport const IMPORT_KINDS = ['vite', 'next', 'unknown'] as const;\nexport type ImportKind = (typeof IMPORT_KINDS)[number];\n\n/** Kinds stored with a builder prefix (\"<builder>-vite\", \"<builder>-tanstack\") all run as Vite apps. */\nexport function toImportKind(raw: unknown): ImportKind | null {\n const k = String(raw ?? '');\n if ((IMPORT_KINDS as readonly string[]).includes(k)) return k as ImportKind;\n return /^[a-z]+-(vite|tanstack)$/.test(k) ? 'vite' : null;\n}\n\n/** Where an imported project came from; the server stamps `at`. */\nexport interface ProjectImportedFrom {\n kind: ImportKind;\n repoUrl: string;\n at: string;\n}\n\nexport const DATABASE_MODES = ['auto', 'yantra', 'none'] as const;\nexport type DatabaseMode = (typeof DATABASE_MODES)[number];\n\n/** The fields `aiCodeUpdateProjectSettings` accepts (spec §3). */\nexport interface ProjectSettingsPatch {\n title?: string | null;\n instructions?: string;\n secretsCredentialId?: string | null;\n integrations?: ProjectIntegration[];\n github?: { repoUrl: string; branch: string; sync: boolean } | null;\n designDirection?: DesignDirection | null;\n importedFrom?: { kind: ImportKind; repoUrl: string };\n database?: { mode: DatabaseMode };\n}\n\nexport const PROJECT_SETTINGS_QUERY = `query WebbuilderProjectSettings($channelId: String!) {\n aiCodeProjectSettings(channelId: $channelId)\n}`;\n\nexport const UPDATE_PROJECT_SETTINGS_MUTATION = `mutation WebbuilderUpdateProjectSettings($channelId: String!, $input: JSON!) {\n aiCodeUpdateProjectSettings(channelId: $channelId, input: $input)\n}`;\n\nexport const MAX_INTEGRATIONS = 20;\nconst PURPOSE_MAX = 300;\n\n/** The server doesn't have the field yet (P5 not deployed): fall back to localStorage, silently. */\nexport function isSchemaMissingError(errors: ReadonlyArray<{ message?: string }> | null | undefined): boolean {\n return Boolean(\n errors?.some((e) =>\n /Cannot query field|Unknown (argument|type)|is not defined by type|Unknown field/i.test(\n String(e?.message || ''),\n ),\n ),\n );\n}\n\n/** A JSON scalar may arrive as an object or a JSON string. */\nfunction asObject(raw: unknown): Record<string, unknown> | null {\n let v = raw;\n if (typeof v === 'string') {\n try {\n v = JSON.parse(v);\n } catch {\n return null;\n }\n }\n return v && typeof v === 'object' && !Array.isArray(v) ? (v as Record<string, unknown>) : null;\n}\n\nconst CONNECTOR_ID_RE = /^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/;\nconst OBJECT_ID_RE = /^[A-Za-z0-9_-]{6,64}$/;\n\nfunction oneLine(text: unknown, max: number): string {\n const t = String(text ?? '')\n .replace(/[\\u0000-\\u001f\\u007f]+/g, ' ')\n .replace(/\\s+/g, ' ')\n .trim();\n return t.length > max ? t.slice(0, max).trim() : t;\n}\n\n/** Valid, de-duplicated (by connectorId, last wins) integrations, at most 20. */\nexport function normalizeIntegrations(raw: unknown): ProjectIntegration[] {\n if (!Array.isArray(raw)) return [];\n const byId = new Map<string, ProjectIntegration>();\n for (const item of raw) {\n if (!item || typeof item !== 'object') continue;\n const r = item as Record<string, unknown>;\n const connectorId = String(r.connectorId ?? '').trim();\n if (!CONNECTOR_ID_RE.test(connectorId)) continue;\n const title = normalizeProjectTitle(String(r.title ?? '')) || connectorId;\n const credentialId = String(r.credentialId ?? '').trim();\n const purpose = oneLine(r.purpose, PURPOSE_MAX);\n byId.delete(connectorId);\n byId.set(connectorId, {\n connectorId,\n title,\n ...(OBJECT_ID_RE.test(credentialId) ? { credentialId } : {}),\n ...(purpose ? { purpose } : {}),\n });\n }\n return [...byId.values()].slice(-MAX_INTEGRATIONS);\n}\n\n/** `https://github.com/<owner>/<repo>` (no `.git`, no credentials), or null. */\nexport function normalizeGithubRepoUrl(raw: unknown): string | null {\n const s = String(raw ?? '').trim();\n if (!s) return null;\n try {\n const u = new URL(s);\n if (u.protocol !== 'https:' || u.hostname.toLowerCase() !== 'github.com' || u.username || u.password)\n return null;\n const [owner, repo] = u.pathname\n .replace(/\\.git$/i, '')\n .split('/')\n .filter(Boolean);\n if (!owner || !repo || !/^[A-Za-z0-9-]{1,39}$/.test(owner) || !/^[A-Za-z0-9._-]{1,100}$/.test(repo))\n return null;\n return `https://github.com/${owner}/${repo}`;\n } catch {\n return null;\n }\n}\n\n/** A safe git branch name, or null. */\nexport function normalizeBranch(raw: unknown): string | null {\n const b = String(raw ?? '').trim();\n if (!/^[A-Za-z0-9._/-]{1,100}$/.test(b)) return null;\n if (\n b.startsWith('-') ||\n b.startsWith('/') ||\n b.endsWith('/') ||\n b.endsWith('.lock') ||\n b.includes('..') ||\n b.includes('//')\n ) {\n return null;\n }\n return b;\n}\n\nfunction isoOrNull(raw: unknown): string | null {\n const s = typeof raw === 'string' ? raw.trim() : '';\n return s && !Number.isNaN(new Date(s).getTime()) ? s : null;\n}\n\nexport function normalizeGithubSettings(raw: unknown): ProjectGithubSettings | null {\n const r = asObject(raw);\n if (!r) return null;\n const repoUrl = normalizeGithubRepoUrl(r.repoUrl);\n if (!repoUrl) return null;\n return {\n repoUrl,\n branch: normalizeBranch(r.branch) || 'main',\n sync: r.sync === true,\n lastPulledAt: isoOrNull(r.lastPulledAt),\n lastPushedAt: isoOrNull(r.lastPushedAt),\n syncBranch: normalizeBranch(r.syncBranch),\n lastCommit: typeof r.lastCommit === 'string' && /^[0-9a-f]{7,40}$/i.test(r.lastCommit) ? r.lastCommit : null,\n };\n}\n\nexport function emptyServerSettings(): ServerProjectSettings {\n return { title: null, instructions: '', secretsCredentialId: null, integrations: [], github: null, database: null };\n}\n\n/** One shape with optional fields (native: no strict null checks, see `DataResult`). */\nexport interface SettingsUpdateReply {\n ok: boolean;\n settings?: unknown;\n error?: string;\n}\n\nconst SETTINGS_NOT_SAVED = 'The settings could not be saved.';\n\n/**\n * `aiCodeUpdateProjectSettings` answers `{ ok: true, settings }` or\n * `{ ok: false, errors: string[] }`, never the settings themselves. Anything\n * else counts as a failure, so a refused save is never reported as saved.\n */\nexport function readSettingsUpdateReply(raw: unknown): SettingsUpdateReply {\n const r = asObject(raw);\n if (r?.ok === true) return { ok: true, settings: r.settings ?? null };\n if (r?.ok === false) {\n const errors = Array.isArray(r.errors) ? r.errors.map((e) => String(e ?? '').trim()).filter(Boolean) : [];\n return { ok: false, error: errors.join('; ') || SETTINGS_NOT_SAVED };\n }\n return { ok: false, error: SETTINGS_NOT_SAVED };\n}\n\n/** `aiCodeProjectSettings` -> a validated settings object (null when the reply isn't one). */\nexport function parseServerProjectSettings(raw: unknown): ServerProjectSettings | null {\n const r = asObject(raw);\n if (!r) return null;\n const cred = String(r.secretsCredentialId ?? '').trim();\n return {\n title: normalizeProjectTitle(typeof r.title === 'string' ? r.title : ''),\n instructions: normalizeProjectKnowledge(typeof r.instructions === 'string' ? r.instructions : ''),\n secretsCredentialId: OBJECT_ID_RE.test(cred) ? cred : null,\n integrations: normalizeIntegrations(r.integrations),\n github: normalizeGithubSettings(r.github),\n database: asObject(r.database),\n designDirection: toDesignDirection(asObject(r.designDirection)),\n importedFrom: normalizeImportedFrom(r.importedFrom),\n restorePoint: parseRestorePoint(asObject(r.restorePoint)),\n };\n}\n\nexport function normalizeImportedFrom(raw: unknown): ProjectImportedFrom | null {\n const r = asObject(raw);\n const repoUrl = normalizeGithubRepoUrl(r?.repoUrl);\n const at = isoOrNull(r?.at);\n const kind = toImportKind(r?.kind);\n if (!r || !repoUrl || !at || !kind) return null;\n return { kind, repoUrl, at };\n}\n\n/** Validates a patch before it is sent; drops what the server would refuse. */\nexport function sanitizePatch(patch: ProjectSettingsPatch): ProjectSettingsPatch {\n const out: ProjectSettingsPatch = {};\n if ('title' in patch) out.title = normalizeProjectTitle(patch.title ?? '');\n if ('instructions' in patch)\n out.instructions = normalizeProjectKnowledge(patch.instructions).slice(0, PROJECT_KNOWLEDGE_MAX);\n if ('secretsCredentialId' in patch) {\n const c = String(patch.secretsCredentialId ?? '').trim();\n out.secretsCredentialId = OBJECT_ID_RE.test(c) ? c : null;\n }\n if ('integrations' in patch) out.integrations = normalizeIntegrations(patch.integrations);\n if ('github' in patch) {\n const g = patch.github ? normalizeGithubSettings(patch.github) : null;\n out.github = g ? { repoUrl: g.repoUrl, branch: g.branch, sync: g.sync } : null;\n }\n if ('designDirection' in patch)\n out.designDirection = patch.designDirection ? toDesignDirection(patch.designDirection) : null;\n if (patch.importedFrom) {\n const repoUrl = normalizeGithubRepoUrl(patch.importedFrom.repoUrl);\n const kind = toImportKind(patch.importedFrom.kind);\n if (repoUrl && kind) out.importedFrom = { kind, repoUrl };\n }\n if (patch.database && DATABASE_MODES.includes(patch.database.mode)) out.database = { mode: patch.database.mode };\n return out;\n}\n\n/** Apply a (sanitized) patch to settings we already hold. */\nexport function applyPatch(base: ServerProjectSettings | null, patch: ProjectSettingsPatch): ServerProjectSettings {\n const s = { ...(base ?? emptyServerSettings()) };\n if ('title' in patch) s.title = patch.title ?? null;\n if ('instructions' in patch) s.instructions = patch.instructions ?? '';\n if ('secretsCredentialId' in patch) s.secretsCredentialId = patch.secretsCredentialId ?? null;\n if ('integrations' in patch) s.integrations = patch.integrations ?? [];\n if ('designDirection' in patch) s.designDirection = patch.designDirection ?? null;\n if ('github' in patch) {\n s.github = patch.github\n ? {\n ...(s.github && s.github.repoUrl === patch.github.repoUrl ? s.github : {}),\n ...patch.github,\n }\n : null;\n }\n return s;\n}\n\nexport interface LocalProjectValues {\n title: string | null;\n instructions: string;\n}\n\n/**\n * The values the surface shows and sends.\n * - Server not loaded (unavailable, offline, not yet fetched): the local values.\n * - Server loaded, not yet migrated: the server's value where it has one, else the local one.\n * - Server loaded and migrated: the server is the truth (an empty server value\n * is a deliberate clear, possibly from another browser).\n */\nexport function mergeProjectSettings(\n server: ServerProjectSettings | null,\n local: LocalProjectValues,\n migrated: boolean,\n): LocalProjectValues {\n if (!server) return { title: local.title, instructions: local.instructions };\n if (migrated) return { title: server.title, instructions: server.instructions };\n return {\n title: server.title || local.title,\n instructions: server.instructions || local.instructions,\n };\n}\n\n/**\n * The one-time upload of values that so far lived only in this browser: the\n * local value for each field the server doesn't have yet. Null when nothing\n * needs uploading (the caller then just marks the project migrated).\n */\nexport function migrationPatch(local: LocalProjectValues, server: ServerProjectSettings): ProjectSettingsPatch | null {\n const patch: ProjectSettingsPatch = {};\n const title = normalizeProjectTitle(local.title ?? '');\n const instructions = normalizeProjectKnowledge(local.instructions);\n if (title && !server.title) patch.title = title;\n if (instructions && !server.instructions) patch.instructions = instructions;\n return Object.keys(patch).length ? patch : null;\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;AA8CO,MAAM,YAAe,GAAA,CAAC,MAAQ,EAAA,MAAA,EAAQ,SAAS;AAI/C,SAAS,aAAa,GAAiC,EAAA;AAC5D,EAAM,MAAA,CAAA,GAAI,MAAO,CAAA,GAAA,IAAA,IAAA,GAAA,GAAA,GAAO,EAAE,CAAA;AAC1B,EAAA,IAAK,YAAmC,CAAA,QAAA,CAAS,CAAC,CAAA,EAAU,OAAA,CAAA;AAC5D,EAAA,OAAO,0BAA2B,CAAA,IAAA,CAAK,CAAC,CAAA,GAAI,MAAS,GAAA,IAAA;AACvD;AA+BO,MAAM,sBAAyB,GAAA,CAAA;AAAA;AAAA,CAAA;AAM/B,MAAM,gBAAmB,GAAA;AAChC,MAAM,WAAc,GAAA,GAAA;AAUpB,SAAS,SAAS,GAA8C,EAAA;AAC9D,EAAA,IAAI,CAAI,GAAA,GAAA;AACR,EAAI,IAAA,OAAO,MAAM,QAAU,EAAA;AACzB,IAAI,IAAA;AACF,MAAI,CAAA,GAAA,IAAA,CAAK,MAAM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AA,CAAA,CAAE,YAAY,CAAA;AAAA,IAClD,YAAc,EAAA,iBAAA,CAAkB,QAAS,CAAA,CAAA,CAAE,YAAY,CAAC;AAAA,GAC1D;AACF;AACO,SAAS,sBAAsB,GAA0C,EAAA;AAC9E,EAAM,MAAA,CAAA,GAAI,SAAS,GAAG,CAAA;AACtB,EAAM,MAAA,OAAA,GAAU,sBAAuB,CAAA,CAAA,IAAA,IAAA,GAAA,MAAA,GAAA,CAAA,CAAG,OAAO,CAAA;AACjD,EAAM,MAAA,EAAA,GAAK,SAAU,CAAA,CAAA,IAAA,IAAA,GAAA,MAAA,GAAA,CAAA,CAAG,EAAE,CAAA;AAC1B,EAAM,MAAA,IAAA,GAAO,YAAa,CAAA,CAAA,IAAA,IAAA,GAAA,MAAA,GAAA,CAAA,CAAG,IAAI,CAAA;AACjC,EAAI,IAAA,CAAC,KAAK,CAAC,OAAA,IAAW,CAAC,EAAM,IAAA,CAAC,MAAa,OAAA,IAAA;AAC3C,EAAO,OAAA;AAAA,IACL,IAAA;AAAA,IACA,OAAA;AAAA,IACA;AAAA,GACF;AACF"}
|
|
1
|
+
{"version":3,"file":"serverSettings.js","sources":["../../../../../src/features/webbuilder/web/project/serverSettings.ts"],"sourcesContent":["/**\n * Phase 5 §3/§7: per-project settings stored on the server (channel\n * `settings`) through `aiCodeProjectSettings` / `aiCodeUpdateProjectSettings`.\n * Pure: GraphQL documents, parsing, validation and the local -> server merge\n * and migration rules. The transport lives in `projectSettingsSync.ts`.\n *\n * The server never returns keys; nothing here ever holds one.\n */\n\nimport { PROJECT_KNOWLEDGE_MAX, normalizeProjectKnowledge, normalizeProjectTitle } from './projectSettings';\nimport { parseRestorePoint, type RestorePoint } from './restorePoint';\nimport { toDesignDirection, type DesignDirection } from '../design/directions';\nimport { toLinkedDesign, type LinkedDesign } from '../design/linkedDesign';\nimport { ignoresPatch, normalizeReviewIgnores, type ReviewIgnore } from '../publish/review/ignores';\nimport { normalizeDrafts, type ProjectDraft } from './drafts';\n\n/** W28: one integration added to the site (Phase 5 spec §2). */\nexport interface ProjectIntegration {\n connectorId: string;\n title: string;\n credentialId?: string;\n purpose?: string;\n}\n\n/** W29: GitHub sync settings; the `last*` / `syncBranch` fields are written by the pipeline. */\nexport interface ProjectGithubSettings {\n repoUrl: string;\n branch: string;\n sync: boolean;\n lastPulledAt?: string | null;\n lastPushedAt?: string | null;\n /** Set when the repo diverged: our changes went to this branch instead (spec §4). */\n syncBranch?: string | null;\n lastCommit?: string | null;\n}\n\nexport interface ServerProjectSettings {\n title: string | null;\n instructions: string;\n secretsCredentialId: string | null;\n integrations: ProjectIntegration[];\n github: ProjectGithubSettings | null;\n /** W25 (stream D shows it): `{ provisioned, slug, url, status }` or null. */\n database: Record<string, unknown> | null;\n /** G4: the style direction picked before the first build; later edits keep its tokens. */\n designDirection?: DesignDirection | null;\n importedFrom?: ProjectImportedFrom | null;\n /** The design this project is bound to, and the versions the two last agreed on (`../design/linkedDesign.ts`). */\n linkedDesign?: LinkedDesign | null;\n /** The latest restore point the server recorded (read-only; never sent in a patch). */\n restorePoint?: RestorePoint | null;\n /** The team's notes (undefined: a server that does not keep them yet). */\n notes?: string;\n /** Review findings and ideas set aside (undefined: a server that does not keep them yet). */\n reviewIgnores?: ReviewIgnore[];\n /** Open drafts (read-only here: created, accepted, renamed and deleted through the sandbox proxy). */\n drafts?: ProjectDraft[];\n}\n\n/** Notes the team keeps beside the chat; the server's limit. */\nexport const PROJECT_NOTES_MAX = 20_000;\n\nexport function normalizeProjectNotes(text: string | null | undefined): string {\n return String(text ?? '')\n .replace(/\\r\\n?/g, '\\n')\n .trim()\n .slice(0, PROJECT_NOTES_MAX);\n}\n\nexport const IMPORT_KINDS = ['vite', 'next', 'unknown'] as const;\nexport type ImportKind = (typeof IMPORT_KINDS)[number];\n\n/** Kinds stored with a builder prefix (\"<builder>-vite\", \"<builder>-tanstack\") all run as Vite apps. */\nexport function toImportKind(raw: unknown): ImportKind | null {\n const k = String(raw ?? '');\n if ((IMPORT_KINDS as readonly string[]).includes(k)) return k as ImportKind;\n return /^[a-z]+-(vite|tanstack)$/.test(k) ? 'vite' : null;\n}\n\n/** Where an imported project came from; the server stamps `at`. */\nexport interface ProjectImportedFrom {\n kind: ImportKind;\n repoUrl: string;\n at: string;\n}\n\nexport const DATABASE_MODES = ['auto', 'yantra', 'none'] as const;\nexport type DatabaseMode = (typeof DATABASE_MODES)[number];\n\n/** The fields `aiCodeUpdateProjectSettings` accepts (spec §3). */\nexport interface ProjectSettingsPatch {\n title?: string | null;\n instructions?: string;\n secretsCredentialId?: string | null;\n integrations?: ProjectIntegration[];\n github?: { repoUrl: string; branch: string; sync: boolean } | null;\n designDirection?: DesignDirection | null;\n importedFrom?: { kind: ImportKind; repoUrl: string };\n /** Null unbinds the project from its design; the design itself is never touched. */\n linkedDesign?: LinkedDesign | null;\n database?: { mode: DatabaseMode };\n notes?: string;\n /** The whole list; the server stamps who and when. */\n reviewIgnores?: ReviewIgnore[];\n}\n\nexport const PROJECT_SETTINGS_QUERY = `query WebbuilderProjectSettings($channelId: String!) {\n aiCodeProjectSettings(channelId: $channelId)\n}`;\n\nexport const UPDATE_PROJECT_SETTINGS_MUTATION = `mutation WebbuilderUpdateProjectSettings($channelId: String!, $input: JSON!) {\n aiCodeUpdateProjectSettings(channelId: $channelId, input: $input)\n}`;\n\nexport const MAX_INTEGRATIONS = 20;\nconst PURPOSE_MAX = 300;\n\n/** The server doesn't have the field yet (P5 not deployed): fall back to localStorage, silently. */\nexport function isSchemaMissingError(errors: ReadonlyArray<{ message?: string }> | null | undefined): boolean {\n return Boolean(\n errors?.some((e) =>\n /Cannot query field|Unknown (argument|type)|is not defined by type|Unknown field/i.test(\n String(e?.message || ''),\n ),\n ),\n );\n}\n\n/** A JSON scalar may arrive as an object or a JSON string. */\nfunction asObject(raw: unknown): Record<string, unknown> | null {\n let v = raw;\n if (typeof v === 'string') {\n try {\n v = JSON.parse(v);\n } catch {\n return null;\n }\n }\n return v && typeof v === 'object' && !Array.isArray(v) ? (v as Record<string, unknown>) : null;\n}\n\nconst CONNECTOR_ID_RE = /^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/;\nconst OBJECT_ID_RE = /^[A-Za-z0-9_-]{6,64}$/;\n\nfunction oneLine(text: unknown, max: number): string {\n const t = String(text ?? '')\n .replace(/[\\u0000-\\u001f\\u007f]+/g, ' ')\n .replace(/\\s+/g, ' ')\n .trim();\n return t.length > max ? t.slice(0, max).trim() : t;\n}\n\n/** Valid, de-duplicated (by connectorId, last wins) integrations, at most 20. */\nexport function normalizeIntegrations(raw: unknown): ProjectIntegration[] {\n if (!Array.isArray(raw)) return [];\n const byId = new Map<string, ProjectIntegration>();\n for (const item of raw) {\n if (!item || typeof item !== 'object') continue;\n const r = item as Record<string, unknown>;\n const connectorId = String(r.connectorId ?? '').trim();\n if (!CONNECTOR_ID_RE.test(connectorId)) continue;\n const title = normalizeProjectTitle(String(r.title ?? '')) || connectorId;\n const credentialId = String(r.credentialId ?? '').trim();\n const purpose = oneLine(r.purpose, PURPOSE_MAX);\n byId.delete(connectorId);\n byId.set(connectorId, {\n connectorId,\n title,\n ...(OBJECT_ID_RE.test(credentialId) ? { credentialId } : {}),\n ...(purpose ? { purpose } : {}),\n });\n }\n return [...byId.values()].slice(-MAX_INTEGRATIONS);\n}\n\n/** `https://github.com/<owner>/<repo>` (no `.git`, no credentials), or null. */\nexport function normalizeGithubRepoUrl(raw: unknown): string | null {\n const s = String(raw ?? '').trim();\n if (!s) return null;\n try {\n const u = new URL(s);\n if (u.protocol !== 'https:' || u.hostname.toLowerCase() !== 'github.com' || u.username || u.password)\n return null;\n const [owner, repo] = u.pathname\n .replace(/\\.git$/i, '')\n .split('/')\n .filter(Boolean);\n if (!owner || !repo || !/^[A-Za-z0-9-]{1,39}$/.test(owner) || !/^[A-Za-z0-9._-]{1,100}$/.test(repo))\n return null;\n return `https://github.com/${owner}/${repo}`;\n } catch {\n return null;\n }\n}\n\n/** A safe git branch name, or null. */\nexport function normalizeBranch(raw: unknown): string | null {\n const b = String(raw ?? '').trim();\n if (!/^[A-Za-z0-9._/-]{1,100}$/.test(b)) return null;\n if (\n b.startsWith('-') ||\n b.startsWith('/') ||\n b.endsWith('/') ||\n b.endsWith('.lock') ||\n b.includes('..') ||\n b.includes('//')\n ) {\n return null;\n }\n return b;\n}\n\nfunction isoOrNull(raw: unknown): string | null {\n const s = typeof raw === 'string' ? raw.trim() : '';\n return s && !Number.isNaN(new Date(s).getTime()) ? s : null;\n}\n\nexport function normalizeGithubSettings(raw: unknown): ProjectGithubSettings | null {\n const r = asObject(raw);\n if (!r) return null;\n const repoUrl = normalizeGithubRepoUrl(r.repoUrl);\n if (!repoUrl) return null;\n return {\n repoUrl,\n branch: normalizeBranch(r.branch) || 'main',\n sync: r.sync === true,\n lastPulledAt: isoOrNull(r.lastPulledAt),\n lastPushedAt: isoOrNull(r.lastPushedAt),\n syncBranch: normalizeBranch(r.syncBranch),\n lastCommit: typeof r.lastCommit === 'string' && /^[0-9a-f]{7,40}$/i.test(r.lastCommit) ? r.lastCommit : null,\n };\n}\n\nexport function emptyServerSettings(): ServerProjectSettings {\n return { title: null, instructions: '', secretsCredentialId: null, integrations: [], github: null, database: null };\n}\n\n/** One shape with optional fields (native: no strict null checks, see `DataResult`). */\nexport interface SettingsUpdateReply {\n ok: boolean;\n settings?: unknown;\n error?: string;\n}\n\nconst SETTINGS_NOT_SAVED = 'The settings could not be saved.';\n\n/**\n * `aiCodeUpdateProjectSettings` answers `{ ok: true, settings }` or\n * `{ ok: false, errors: string[] }`, never the settings themselves. Anything\n * else counts as a failure, so a refused save is never reported as saved.\n */\nexport function readSettingsUpdateReply(raw: unknown): SettingsUpdateReply {\n const r = asObject(raw);\n if (r?.ok === true) return { ok: true, settings: r.settings ?? null };\n if (r?.ok === false) {\n const errors = Array.isArray(r.errors) ? r.errors.map((e) => String(e ?? '').trim()).filter(Boolean) : [];\n return { ok: false, error: errors.join('; ') || SETTINGS_NOT_SAVED };\n }\n return { ok: false, error: SETTINGS_NOT_SAVED };\n}\n\n/** `aiCodeProjectSettings` -> a validated settings object (null when the reply isn't one). */\nexport function parseServerProjectSettings(raw: unknown): ServerProjectSettings | null {\n const r = asObject(raw);\n if (!r) return null;\n const cred = String(r.secretsCredentialId ?? '').trim();\n return {\n title: normalizeProjectTitle(typeof r.title === 'string' ? r.title : ''),\n instructions: normalizeProjectKnowledge(typeof r.instructions === 'string' ? r.instructions : ''),\n secretsCredentialId: OBJECT_ID_RE.test(cred) ? cred : null,\n integrations: normalizeIntegrations(r.integrations),\n github: normalizeGithubSettings(r.github),\n database: asObject(r.database),\n designDirection: toDesignDirection(asObject(r.designDirection)),\n importedFrom: normalizeImportedFrom(r.importedFrom),\n linkedDesign: toLinkedDesign(r.linkedDesign),\n restorePoint: parseRestorePoint(asObject(r.restorePoint)),\n ...('notes' in r ? { notes: normalizeProjectNotes(typeof r.notes === 'string' ? r.notes : '') } : {}),\n ...(Array.isArray(r.reviewIgnores) ? { reviewIgnores: normalizeReviewIgnores(r.reviewIgnores) } : {}),\n ...(Array.isArray(r.drafts) ? { drafts: normalizeDrafts(r.drafts) } : {}),\n };\n}\n\nexport function normalizeImportedFrom(raw: unknown): ProjectImportedFrom | null {\n const r = asObject(raw);\n const repoUrl = normalizeGithubRepoUrl(r?.repoUrl);\n const at = isoOrNull(r?.at);\n const kind = toImportKind(r?.kind);\n if (!r || !repoUrl || !at || !kind) return null;\n return { kind, repoUrl, at };\n}\n\n/** Validates a patch before it is sent; drops what the server would refuse. */\nexport function sanitizePatch(patch: ProjectSettingsPatch): ProjectSettingsPatch {\n const out: ProjectSettingsPatch = {};\n if ('title' in patch) out.title = normalizeProjectTitle(patch.title ?? '');\n if ('instructions' in patch)\n out.instructions = normalizeProjectKnowledge(patch.instructions).slice(0, PROJECT_KNOWLEDGE_MAX);\n if ('secretsCredentialId' in patch) {\n const c = String(patch.secretsCredentialId ?? '').trim();\n out.secretsCredentialId = OBJECT_ID_RE.test(c) ? c : null;\n }\n if ('integrations' in patch) out.integrations = normalizeIntegrations(patch.integrations);\n if ('github' in patch) {\n const g = patch.github ? normalizeGithubSettings(patch.github) : null;\n out.github = g ? { repoUrl: g.repoUrl, branch: g.branch, sync: g.sync } : null;\n }\n if ('designDirection' in patch)\n out.designDirection = patch.designDirection ? toDesignDirection(patch.designDirection) : null;\n if (patch.importedFrom) {\n const repoUrl = normalizeGithubRepoUrl(patch.importedFrom.repoUrl);\n const kind = toImportKind(patch.importedFrom.kind);\n if (repoUrl && kind) out.importedFrom = { kind, repoUrl };\n }\n if ('linkedDesign' in patch) out.linkedDesign = patch.linkedDesign ? toLinkedDesign(patch.linkedDesign) : null;\n if (patch.database && DATABASE_MODES.includes(patch.database.mode)) out.database = { mode: patch.database.mode };\n if ('notes' in patch) out.notes = normalizeProjectNotes(patch.notes);\n if ('reviewIgnores' in patch) out.reviewIgnores = ignoresPatch(patch.reviewIgnores ?? []);\n return out;\n}\n\n/** Apply a (sanitized) patch to settings we already hold. */\nexport function applyPatch(base: ServerProjectSettings | null, patch: ProjectSettingsPatch): ServerProjectSettings {\n const s = { ...(base ?? emptyServerSettings()) };\n if ('title' in patch) s.title = patch.title ?? null;\n if ('instructions' in patch) s.instructions = patch.instructions ?? '';\n if ('secretsCredentialId' in patch) s.secretsCredentialId = patch.secretsCredentialId ?? null;\n if ('integrations' in patch) s.integrations = patch.integrations ?? [];\n if ('designDirection' in patch) s.designDirection = patch.designDirection ?? null;\n if ('linkedDesign' in patch) s.linkedDesign = patch.linkedDesign ?? null;\n if ('notes' in patch) s.notes = patch.notes ?? '';\n if ('reviewIgnores' in patch) {\n // Until the server answers: unchanged entries keep their stamps, new ones are dated now.\n const before = new Map((s.reviewIgnores ?? []).map((r) => [r.key, r] as const));\n const at = new Date().toISOString();\n s.reviewIgnores = (patch.reviewIgnores ?? []).map((r) => {\n const old = before.get(r.key);\n return old && old.reason === r.reason && (old.note ?? '') === (r.note ?? '') ? old : { ...r, at };\n });\n }\n if ('github' in patch) {\n s.github = patch.github\n ? {\n ...(s.github && s.github.repoUrl === patch.github.repoUrl ? s.github : {}),\n ...patch.github,\n }\n : null;\n }\n return s;\n}\n\nexport interface LocalProjectValues {\n title: string | null;\n instructions: string;\n}\n\n/**\n * The values the surface shows and sends.\n * - Server not loaded (unavailable, offline, not yet fetched): the local values.\n * - Server loaded, not yet migrated: the server's value where it has one, else the local one.\n * - Server loaded and migrated: the server is the truth (an empty server value\n * is a deliberate clear, possibly from another browser).\n */\nexport function mergeProjectSettings(\n server: ServerProjectSettings | null,\n local: LocalProjectValues,\n migrated: boolean,\n): LocalProjectValues {\n if (!server) return { title: local.title, instructions: local.instructions };\n if (migrated) return { title: server.title, instructions: server.instructions };\n return {\n title: server.title || local.title,\n instructions: server.instructions || local.instructions,\n };\n}\n\n/**\n * The one-time upload of values that so far lived only in this browser: the\n * local value for each field the server doesn't have yet. Null when nothing\n * needs uploading (the caller then just marks the project migrated).\n */\nexport function migrationPatch(local: LocalProjectValues, server: ServerProjectSettings): ProjectSettingsPatch | null {\n const patch: ProjectSettingsPatch = {};\n const title = normalizeProjectTitle(local.title ?? '');\n const instructions = normalizeProjectKnowledge(local.instructions);\n if (title && !server.title) patch.title = title;\n if (instructions && !server.instructions) patch.instructions = instructions;\n return Object.keys(patch).length ? patch : null;\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;AA2DO,MAAM,iBAAoB,GAAA;AAC1B,SAAS,sBAAsB,IAAyC,EAAA;AAC7E,EAAA,OAAO,MAAO,CAAA,IAAA,IAAA,IAAA,GAAA,IAAA,GAAQ,EAAE,CAAA,CAAE,OAAQ,CAAA,QAAA,EAAU,IAAI,CAAA,CAAE,IAAK,EAAA,CAAE,KAAM,CAAA,CAAA,EAAG,iBAAiB,CAAA;AACrF;AACO,MAAM,YAAe,GAAA,CAAC,MAAQ,EAAA,MAAA,EAAQ,SAAS;AAI/C,SAAS,aAAa,GAAiC,EAAA;AAC5D,EAAM,MAAA,CAAA,GAAI,MAAO,CAAA,G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AAuB,CAAA,CAAA,IAAA,IAAA,GAAA,MAAA,GAAA,CAAA,CAAG,OAAO,CAAA;AACjD,EAAM,MAAA,EAAA,GAAK,SAAU,CAAA,CAAA,IAAA,IAAA,GAAA,MAAA,GAAA,CAAA,CAAG,EAAE,CAAA;AAC1B,EAAM,MAAA,IAAA,GAAO,YAAa,CAAA,CAAA,IAAA,IAAA,GAAA,MAAA,GAAA,CAAA,CAAG,IAAI,CAAA;AACjC,EAAI,IAAA,CAAC,KAAK,CAAC,OAAA,IAAW,CAAC,EAAM,IAAA,CAAC,MAAa,OAAA,IAAA;AAC3C,EAAO,OAAA;AAAA,IACL,IAAA;AAAA,IACA,OAAA;AAAA,IACA;AAAA,GACF;AACF"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import {actionFields,isUnknownActionError}from'./actionErrors.js';var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
3
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
4
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
+
var __spreadValues = (a, b) => {
|
|
7
|
+
for (var prop in b || (b = {}))
|
|
8
|
+
if (__hasOwnProp.call(b, prop))
|
|
9
|
+
__defNormalProp(a, prop, b[prop]);
|
|
10
|
+
if (__getOwnPropSymbols)
|
|
11
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
12
|
+
if (__propIsEnum.call(b, prop))
|
|
13
|
+
__defNormalProp(a, prop, b[prop]);
|
|
14
|
+
}
|
|
15
|
+
return a;
|
|
16
|
+
};
|
|
17
|
+
const DOMAIN_RE = /^[a-z0-9.-]{4,253}$/;
|
|
18
|
+
const num = (v) => typeof v === "number" && Number.isFinite(v) && v >= 0 ? v : void 0;
|
|
19
|
+
function parseDomainSearch(data) {
|
|
20
|
+
const d = actionFields(data);
|
|
21
|
+
const offers = (Array.isArray(d.domains) ? d.domains : []).filter((o) => Boolean(o) && typeof o === "object").filter((o) => typeof o.domain === "string" && DOMAIN_RE.test(o.domain)).map((o) => __spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues({
|
|
22
|
+
domain: String(o.domain),
|
|
23
|
+
available: o.available === true
|
|
24
|
+
}, typeof o.reason === "string" ? {
|
|
25
|
+
reason: o.reason
|
|
26
|
+
} : {}), typeof o.tier === "string" ? {
|
|
27
|
+
tier: o.tier
|
|
28
|
+
} : {}), num(o.price) !== void 0 ? {
|
|
29
|
+
price: num(o.price)
|
|
30
|
+
} : {}), num(o.renewal) !== void 0 ? {
|
|
31
|
+
renewal: num(o.renewal)
|
|
32
|
+
} : {}), typeof o.currency === "string" && /^[A-Z]{3}$/.test(o.currency) ? {
|
|
33
|
+
currency: o.currency
|
|
34
|
+
} : {})).slice(0, 20);
|
|
35
|
+
return {
|
|
36
|
+
offers,
|
|
37
|
+
canBuy: d.canBuy === true
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
function domainFailure(result) {
|
|
41
|
+
var _a;
|
|
42
|
+
if (isUnknownActionError(result)) return "not-available";
|
|
43
|
+
const d = actionFields(result.data);
|
|
44
|
+
const code = String(d.errorCode || ((_a = result.data) == null ? void 0 : _a.errorCode) || "");
|
|
45
|
+
const text = result.error || "";
|
|
46
|
+
if (d.needsCredential || code === "CREDENTIAL_REQUIRED" || /\[CREDENTIAL_REQUIRED\]/.test(text)) return "needs-cloudflare";
|
|
47
|
+
if (code === "PLATFORM_NOT_CONFIGURED" || /\[PLATFORM_NOT_CONFIGURED\]/.test(text)) return "platform";
|
|
48
|
+
return "error";
|
|
49
|
+
}
|
|
50
|
+
function formatYearly(price, currency, locale) {
|
|
51
|
+
if (price === void 0) return "price unknown";
|
|
52
|
+
try {
|
|
53
|
+
return `${new Intl.NumberFormat(locale, {
|
|
54
|
+
style: "currency",
|
|
55
|
+
currency: currency || "USD"
|
|
56
|
+
}).format(price)}/yr`;
|
|
57
|
+
} catch (e) {
|
|
58
|
+
return `${price.toFixed(2)} ${currency || ""}/yr`.replace(" /yr", "/yr");
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
function offerReason(o) {
|
|
62
|
+
if (o.available && (!o.tier || o.tier === "standard")) return null;
|
|
63
|
+
if (o.available) return "Premium name: not sold here";
|
|
64
|
+
switch (o.reason) {
|
|
65
|
+
case "domain_unavailable":
|
|
66
|
+
return "Taken";
|
|
67
|
+
case "extension_not_supported_via_api":
|
|
68
|
+
case "extension_not_supported":
|
|
69
|
+
return "This ending is not sold here yet";
|
|
70
|
+
case "extension_disallows_registration":
|
|
71
|
+
return "Not open for registration";
|
|
72
|
+
default:
|
|
73
|
+
return "Not available";
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
function purchaseConfirmText(o, locale) {
|
|
77
|
+
const renews = o.renewal !== void 0 && o.renewal !== o.price ? ` It renews at ${formatYearly(o.renewal, o.currency, locale)}.` : "";
|
|
78
|
+
return `Buy ${o.domain} for ${formatYearly(o.price, o.currency, locale)} on your Cloudflare account? Cloudflare charges your payment method and registers the domain in your name. Purchases are non-refundable.${renews} Auto-renew starts off: turn it on in Cloudflare to keep the domain.`;
|
|
79
|
+
}export{domainFailure,formatYearly,offerReason,parseDomainSearch,purchaseConfirmText};//# sourceMappingURL=domainShop.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"domainShop.js","sources":["../../../../../src/features/webbuilder/web/publish/domainShop.ts"],"sourcesContent":["/**\n * \"Find a domain\" in the Domains sheet: names with their yearly price, bought on the person's own Cloudflare\n * account (yantra-webbuilder WEBBUILDER_DOMAIN_SEARCH / _BUY, Cloudflare Registrar). Pure.\n */\nimport { actionFields, isUnknownActionError } from './actionErrors';\n\n/** A sandbox action's answer (web `canvas/types`). */\ninterface SandboxActionResult {\n successful: boolean;\n data?: Record<string, unknown>;\n error?: string | null;\n}\n\nexport interface DomainOffer {\n domain: string;\n available: boolean;\n reason?: string;\n tier?: string;\n price?: number;\n renewal?: number;\n currency?: string;\n}\n\nexport interface DomainSearchView {\n offers: DomainOffer[];\n /** The person's own Cloudflare account is connected: buying is possible here. */\n canBuy: boolean;\n}\n\nexport type DomainActionFailure = 'not-available' | 'needs-cloudflare' | 'platform' | 'error';\n\nconst DOMAIN_RE = /^[a-z0-9.-]{4,253}$/;\nconst num = (v: unknown): number | undefined => (typeof v === 'number' && Number.isFinite(v) && v >= 0 ? v : undefined);\n\nexport function parseDomainSearch(data: Record<string, unknown> | null | undefined): DomainSearchView {\n const d = actionFields(data);\n const offers = (Array.isArray(d.domains) ? d.domains : [])\n .filter((o): o is Record<string, unknown> => Boolean(o) && typeof o === 'object')\n .filter((o) => typeof o.domain === 'string' && DOMAIN_RE.test(o.domain))\n .map((o) => ({\n domain: String(o.domain),\n available: o.available === true,\n ...(typeof o.reason === 'string' ? { reason: o.reason } : {}),\n ...(typeof o.tier === 'string' ? { tier: o.tier } : {}),\n ...(num(o.price) !== undefined ? { price: num(o.price) } : {}),\n ...(num(o.renewal) !== undefined ? { renewal: num(o.renewal) } : {}),\n ...(typeof o.currency === 'string' && /^[A-Z]{3}$/.test(o.currency) ? { currency: o.currency } : {}),\n }))\n .slice(0, 20);\n return { offers, canBuy: d.canBuy === true };\n}\n\n/** What a failed search or purchase means for the sheet. */\nexport function domainFailure(result: Pick<SandboxActionResult, 'error' | 'data'>): DomainActionFailure {\n if (isUnknownActionError(result)) return 'not-available';\n const d = actionFields(result.data);\n const code = String(d.errorCode || (result.data as Record<string, unknown> | undefined)?.errorCode || '');\n const text = result.error || '';\n if (d.needsCredential || code === 'CREDENTIAL_REQUIRED' || /\\[CREDENTIAL_REQUIRED\\]/.test(text))\n return 'needs-cloudflare';\n if (code === 'PLATFORM_NOT_CONFIGURED' || /\\[PLATFORM_NOT_CONFIGURED\\]/.test(text)) return 'platform';\n return 'error';\n}\n\n/** \"$10.46/yr\", \"€9.00/yr\"; \"price unknown\" when the registry did not say. */\nexport function formatYearly(price: number | undefined, currency: string | undefined, locale?: string): string {\n if (price === undefined) return 'price unknown';\n try {\n return `${new Intl.NumberFormat(locale, { style: 'currency', currency: currency || 'USD' }).format(price)}/yr`;\n } catch {\n return `${price.toFixed(2)} ${currency || ''}/yr`.replace(' /yr', '/yr');\n }\n}\n\n/** Why a name cannot be bought, in plain words. */\nexport function offerReason(o: Pick<DomainOffer, 'available' | 'reason' | 'tier'>): string | null {\n if (o.available && (!o.tier || o.tier === 'standard')) return null;\n if (o.available) return 'Premium name: not sold here';\n switch (o.reason) {\n case 'domain_unavailable':\n return 'Taken';\n case 'extension_not_supported_via_api':\n case 'extension_not_supported':\n return 'This ending is not sold here yet';\n case 'extension_disallows_registration':\n return 'Not open for registration';\n default:\n return 'Not available';\n }\n}\n\n/** The one-paragraph confirmation before a non-refundable purchase. */\nexport function purchaseConfirmText(o: DomainOffer, locale?: string): string {\n const renews =\n o.renewal !== undefined && o.renewal !== o.price\n ? ` It renews at ${formatYearly(o.renewal, o.currency, locale)}.`\n : '';\n return (\n `Buy ${o.domain} for ${formatYearly(o.price, o.currency, locale)} on your Cloudflare account? ` +\n `Cloudflare charges your payment method and registers the domain in your name. Purchases are non-refundable.${renews} ` +\n 'Auto-renew starts off: turn it on in Cloudflare to keep the domain.'\n );\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;AA2BA,MAAM,SAAY,GAAA,qBAAA;AAClB,MAAM,GAAM,GAAA,CAAC,CAAmC,KAAA,OAAO,CAAM,KAAA,QAAA,IAAY,MAAO,CAAA,QAAA,CAAS,CAAC,CAAA,IAAK,CAAK,IAAA,CAAA,GAAI,CAAI,GAAA,MAAA;AACrG,SAAS,kBAAkB,IAAoE,EAAA;AACpG,EAAM,MAAA,CAAA,GAAI,aAAa,IAAI,CAAA;AAC3B,EAAA,MAAM,MAAU,GAAA,CAAA,KAAA,CAAM,OAAQ,CAAA,CAAA,CAAE,OAAO,CAAI,G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A,IAAA,KAAS,aAAoB,OAAA,IAAA;AAC9D,EAAI,IAAA,CAAA,CAAE,WAAkB,OAAA,6BAAA;AACxB,EAAA,QAAQ,EAAE,MAAQ;AAAA,IAChB,KAAK,oBAAA;AACH,MAAO,OAAA,OAAA;AAAA,IACT,KAAK,iCAAA;AAAA,IACL,KAAK,yBAAA;AACH,MAAO,OAAA,kCAAA;AAAA,IACT,KAAK,kCAAA;AACH,MAAO,OAAA,2BAAA;AAAA,IACT;AACE,MAAO,OAAA,eAAA;AAAA;AAEb;AAGgB,SAAA,mBAAA,CAAoB,GAAgB,MAAyB,EAAA;AAC3E,EAAA,MAAM,SAAS,CAAE,CAAA,OAAA,KAAY,MAAa,IAAA,CAAA,CAAE,YAAY,CAAE,CAAA,KAAA,GAAQ,CAAiB,cAAA,EAAA,YAAA,CAAa,EAAE,OAAS,EAAA,CAAA,CAAE,QAAU,EAAA,MAAM,CAAC,CAAM,CAAA,CAAA,GAAA,EAAA;AACpI,EAAA,OAAO,CAAO,IAAA,EAAA,CAAA,CAAE,MAAM,CAAA,KAAA,EAAQ,YAAa,CAAA,CAAA,CAAE,KAAO,EAAA,CAAA,CAAE,QAAU,EAAA,MAAM,CAAC,CAAA,wIAAA,EAAgJ,MAAM,CAAA,oEAAA,CAAA;AAC/N"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
const PUBLISH_REQUEST_PREFIX = "Publish request:";
|
|
2
|
+
const PUBLISH_REQUEST_NOTE_MAX = 500;
|
|
3
|
+
function publishRequestComment(note) {
|
|
4
|
+
const extra = String(note != null ? note : "").replace(/\s+/g, " ").trim().slice(0, PUBLISH_REQUEST_NOTE_MAX);
|
|
5
|
+
return {
|
|
6
|
+
text: `${PUBLISH_REQUEST_PREFIX} please publish the latest changes.${extra ? ` ${extra}` : ""}`,
|
|
7
|
+
route: "/",
|
|
8
|
+
x: 0.5,
|
|
9
|
+
y: 0.04
|
|
10
|
+
};
|
|
11
|
+
}export{PUBLISH_REQUEST_NOTE_MAX,PUBLISH_REQUEST_PREFIX,publishRequestComment};//# sourceMappingURL=publishRequest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"publishRequest.js","sources":["../../../../../src/features/webbuilder/web/publish/publishRequest.ts"],"sourcesContent":["/**\n * \"Ask to publish\" for people who can look but not publish (viewers). The request is a comment on the\n * project, which viewers may post and owners already see, so it needs nothing new on the server. Pure.\n */\n/** A new comment on the project (web `comments.ts`): text, the page and where on it. */\nexport interface NewCommentInput {\n text: string;\n route: string;\n x: number;\n y: number;\n}\n\nexport const PUBLISH_REQUEST_PREFIX = 'Publish request:';\nexport const PUBLISH_REQUEST_NOTE_MAX = 500;\n\n/** The comment that carries the request: on the home page, pinned near the top. */\nexport function publishRequestComment(note: string | null | undefined): NewCommentInput {\n const extra = String(note ?? '')\n .replace(/\\s+/g, ' ')\n .trim()\n .slice(0, PUBLISH_REQUEST_NOTE_MAX);\n return {\n text: `${PUBLISH_REQUEST_PREFIX} please publish the latest changes.${extra ? ` ${extra}` : ''}`,\n route: '/',\n x: 0.5,\n y: 0.04,\n };\n}\n\n/** A comment that is a publish request (so the list can mark it). */\nexport function isPublishRequest(text: string | null | undefined): boolean {\n return String(text ?? '').startsWith(PUBLISH_REQUEST_PREFIX);\n}\n"],"names":[],"mappings":"AAWO,MAAM,sBAAyB,GAAA;AAC/B,MAAM,wBAA2B,GAAA;AAGjC,SAAS,sBAAsB,IAAkD,EAAA;AACtF,EAAA,MAAM,KAAQ,GAAA,MAAA,CAAO,IAAQ,IAAA,IAAA,GAAA,IAAA,GAAA,EAAE,CAAE,CAAA,OAAA,CAAQ,MAAQ,EAAA,GAAG,CAAE,CAAA,IAAA,EAAO,CAAA,KAAA,CAAM,GAAG,wBAAwB,CAAA;AAC9F,EAAO,OAAA;AAAA,IACL,IAAA,EAAM,GAAG,sBAAsB,CAAA,mCAAA,EAAsC,QAAQ,CAAI,CAAA,EAAA,KAAK,KAAK,EAAE,CAAA,CAAA;AAAA,IAC7F,KAAO,EAAA,GAAA;AAAA,IACP,CAAG,EAAA,GAAA;AAAA,IACH,CAAG,EAAA;AAAA,GACL;AACF"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const STALE_AFTER_DAYS = 7;
|
|
2
|
+
const DAY = 864e5;
|
|
3
|
+
function checkAge(ranAt, now = Date.now()) {
|
|
4
|
+
const t = ranAt ? Date.parse(ranAt) : NaN;
|
|
5
|
+
if (!Number.isFinite(t) || t - now > 6e4) return null;
|
|
6
|
+
const days = Math.max(0, Math.floor((now - t) / DAY));
|
|
7
|
+
const text = days === 0 ? "Checked today" : days === 1 ? "Checked yesterday" : `Checked ${days} days ago`;
|
|
8
|
+
return {
|
|
9
|
+
days,
|
|
10
|
+
text,
|
|
11
|
+
stale: days >= STALE_AFTER_DAYS
|
|
12
|
+
};
|
|
13
|
+
}export{STALE_AFTER_DAYS,checkAge};//# sourceMappingURL=freshness.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"freshness.js","sources":["../../../../../../src/features/webbuilder/web/publish/review/freshness.ts"],"sourcesContent":["/** How old the shown checks are. Packages get new security advisories after a site ships, so old checks go stale. Pure. */\n\nexport const STALE_AFTER_DAYS = 7;\nconst DAY = 86_400_000;\n\nexport interface CheckAge {\n days: number;\n /** \"Checked today\", \"Checked yesterday\", \"Checked 9 days ago\". */\n text: string;\n stale: boolean;\n}\n\n/** Null for a missing or unreadable time (or one in the future by more than a minute: a clock problem, not a check). */\nexport function checkAge(ranAt: string | null | undefined, now: number = Date.now()): CheckAge | null {\n const t = ranAt ? Date.parse(ranAt) : NaN;\n if (!Number.isFinite(t) || t - now > 60_000) return null;\n const days = Math.max(0, Math.floor((now - t) / DAY));\n const text = days === 0 ? 'Checked today' : days === 1 ? 'Checked yesterday' : `Checked ${days} days ago`;\n return { days, text, stale: days >= STALE_AFTER_DAYS };\n}\n"],"names":[],"mappings":"AAEO,MAAM,gBAAmB,GAAA;AAChC,MAAM,GAAM,GAAA,KAAA;AASL,SAAS,QAAS,CAAA,KAAA,EAAkC,GAAc,GAAA,IAAA,CAAK,KAAwB,EAAA;AACpG,EAAA,MAAM,CAAI,GAAA,KAAA,GAAQ,IAAK,CAAA,KAAA,CAAM,KAAK,CAAI,GAAA,GAAA;AACtC,EAAI,IAAA,CAAC,OAAO,QAAS,CAAA,CAAC,KAAK,CAAI,GAAA,GAAA,GAAM,KAAe,OAAA,IAAA;AACpD,EAAM,MAAA,IAAA,GAAO,KAAK,GAAI,CAAA,CAAA,EAAG,KAAK,KAAO,CAAA,CAAA,GAAA,GAAM,CAAK,IAAA,GAAG,CAAC,CAAA;AACpD,EAAM,MAAA,IAAA,GAAO,SAAS,CAAI,GAAA,eAAA,GAAkB,SAAS,CAAI,GAAA,mBAAA,GAAsB,WAAW,IAAI,CAAA,SAAA,CAAA;AAC9F,EAAO,OAAA;AAAA,IACL,IAAA;AAAA,IACA,IAAA;AAAA,IACA,OAAO,IAAQ,IAAA;AAAA,GACjB;AACF"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
const IGNORE_REASONS = ["false-positive", "accepted-risk", "not-relevant", "later", "other"];
|
|
21
|
+
const IGNORE_REASON_LABEL = {
|
|
22
|
+
"false-positive": "Not a real problem",
|
|
23
|
+
"accepted-risk": "We accept the risk",
|
|
24
|
+
"not-relevant": "Doesn't apply to this site",
|
|
25
|
+
later: "We'll do it later",
|
|
26
|
+
other: "Other"
|
|
27
|
+
};
|
|
28
|
+
const MAX_IGNORE_NOTE = 300;
|
|
29
|
+
const REVIEW_KEY_RE = /^[a-z]{2,12}:[A-Za-z0-9_.:/-]{1,160}$/;
|
|
30
|
+
const isReason = (v) => IGNORE_REASONS.includes(v);
|
|
31
|
+
function canIgnoreKey(key) {
|
|
32
|
+
return REVIEW_KEY_RE.test(key);
|
|
33
|
+
}
|
|
34
|
+
function normalizeReviewIgnores(raw) {
|
|
35
|
+
if (!Array.isArray(raw)) return [];
|
|
36
|
+
const byKey = /* @__PURE__ */ new Map();
|
|
37
|
+
for (const item of raw) {
|
|
38
|
+
if (!item || typeof item !== "object") continue;
|
|
39
|
+
const r = item;
|
|
40
|
+
const key = typeof r.key === "string" ? r.key.trim() : "";
|
|
41
|
+
if (!canIgnoreKey(key) || !isReason(r.reason)) continue;
|
|
42
|
+
const note = typeof r.note === "string" ? r.note.replace(/\s+/g, " ").trim().slice(0, MAX_IGNORE_NOTE) : "";
|
|
43
|
+
const at = typeof r.at === "string" && !Number.isNaN(Date.parse(r.at)) ? r.at : void 0;
|
|
44
|
+
byKey.delete(key);
|
|
45
|
+
byKey.set(key, __spreadValues(__spreadValues(__spreadValues({
|
|
46
|
+
key,
|
|
47
|
+
reason: r.reason
|
|
48
|
+
}, note ? {
|
|
49
|
+
note
|
|
50
|
+
} : {}), typeof r.by === "string" && r.by ? {
|
|
51
|
+
by: r.by
|
|
52
|
+
} : {}), at ? {
|
|
53
|
+
at
|
|
54
|
+
} : {}));
|
|
55
|
+
}
|
|
56
|
+
return [...byKey.values()].slice(-200);
|
|
57
|
+
}
|
|
58
|
+
function ignoreFor(list, key) {
|
|
59
|
+
var _a;
|
|
60
|
+
return (_a = list.find((i) => i.key === key)) != null ? _a : null;
|
|
61
|
+
}
|
|
62
|
+
function withIgnore(list, entry, now = /* @__PURE__ */ new Date()) {
|
|
63
|
+
var _a;
|
|
64
|
+
if (!canIgnoreKey(entry.key) || !isReason(entry.reason)) return [...list];
|
|
65
|
+
const note = ((_a = entry.note) != null ? _a : "").replace(/\s+/g, " ").trim().slice(0, MAX_IGNORE_NOTE);
|
|
66
|
+
const next = list.filter((i) => i.key !== entry.key);
|
|
67
|
+
next.push(__spreadProps(__spreadValues({
|
|
68
|
+
key: entry.key,
|
|
69
|
+
reason: entry.reason
|
|
70
|
+
}, note ? {
|
|
71
|
+
note
|
|
72
|
+
} : {}), {
|
|
73
|
+
at: now.toISOString()
|
|
74
|
+
}));
|
|
75
|
+
return next.slice(-200);
|
|
76
|
+
}
|
|
77
|
+
function withoutIgnore(list, key) {
|
|
78
|
+
return list.filter((i) => i.key !== key);
|
|
79
|
+
}
|
|
80
|
+
function ignoresPatch(list) {
|
|
81
|
+
return normalizeReviewIgnores(list).map(({
|
|
82
|
+
key,
|
|
83
|
+
reason,
|
|
84
|
+
note
|
|
85
|
+
}) => __spreadValues({
|
|
86
|
+
key,
|
|
87
|
+
reason
|
|
88
|
+
}, note ? {
|
|
89
|
+
note
|
|
90
|
+
} : {}));
|
|
91
|
+
}
|
|
92
|
+
function ignoreSummary(entry) {
|
|
93
|
+
return [IGNORE_REASON_LABEL[entry.reason], entry.note].filter(Boolean).join(" \xB7 ");
|
|
94
|
+
}export{IGNORE_REASONS,IGNORE_REASON_LABEL,MAX_IGNORE_NOTE,REVIEW_KEY_RE,canIgnoreKey,ignoreFor,ignoreSummary,ignoresPatch,normalizeReviewIgnores,withIgnore,withoutIgnore};//# sourceMappingURL=ignores.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ignores.js","sources":["../../../../../../src/features/webbuilder/web/publish/review/ignores.ts"],"sourcesContent":["/**\n * Review items the team set aside, with why: a security warning that is a false positive, an SEO check\n * that does not apply, a growth idea for later. Pure.\n *\n * Stored per project in the settings (`reviewIgnores`, page-creator validates the same rules), so everyone\n * on the project sees the same list. Critical findings are never set aside here: they stop a publish, and\n * only the owner's \"Publish anyway\" goes past them.\n */\n\nexport const IGNORE_REASONS = ['false-positive', 'accepted-risk', 'not-relevant', 'later', 'other'] as const;\nexport type IgnoreReason = (typeof IGNORE_REASONS)[number];\n\nexport const IGNORE_REASON_LABEL: Record<IgnoreReason, string> = {\n 'false-positive': 'Not a real problem',\n 'accepted-risk': 'We accept the risk',\n 'not-relevant': \"Doesn't apply to this site\",\n later: \"We'll do it later\",\n other: 'Other',\n};\n\nexport const MAX_IGNORES = 200;\nexport const MAX_IGNORE_NOTE = 300;\n\n/** \"report:npm-audit\", \"seo:og\", \"lint:<key>\", \"opp:faq\": the same rule the server applies. */\nexport const REVIEW_KEY_RE = /^[a-z]{2,12}:[A-Za-z0-9_.:/-]{1,160}$/;\n\nexport interface ReviewIgnore {\n key: string;\n reason: IgnoreReason;\n note?: string;\n /** Who set it aside (from the server). */\n by?: string | null;\n /** When (ISO). */\n at?: string;\n}\n\nconst isReason = (v: unknown): v is IgnoreReason => (IGNORE_REASONS as readonly unknown[]).includes(v);\n\nexport function canIgnoreKey(key: string): boolean {\n return REVIEW_KEY_RE.test(key);\n}\n\n/** A stored or received list, cleaned: known reasons, valid keys, one entry per key (the last wins). */\nexport function normalizeReviewIgnores(raw: unknown): ReviewIgnore[] {\n if (!Array.isArray(raw)) return [];\n const byKey = new Map<string, ReviewIgnore>();\n for (const item of raw) {\n if (!item || typeof item !== 'object') continue;\n const r = item as Record<string, unknown>;\n const key = typeof r.key === 'string' ? r.key.trim() : '';\n if (!canIgnoreKey(key) || !isReason(r.reason)) continue;\n const note = typeof r.note === 'string' ? r.note.replace(/\\s+/g, ' ').trim().slice(0, MAX_IGNORE_NOTE) : '';\n const at = typeof r.at === 'string' && !Number.isNaN(Date.parse(r.at)) ? r.at : undefined;\n byKey.delete(key);\n byKey.set(key, {\n key,\n reason: r.reason,\n ...(note ? { note } : {}),\n ...(typeof r.by === 'string' && r.by ? { by: r.by } : {}),\n ...(at ? { at } : {}),\n });\n }\n return [...byKey.values()].slice(-MAX_IGNORES);\n}\n\n/** The entry for a key, or null. */\nexport function ignoreFor(list: ReadonlyArray<ReviewIgnore>, key: string): ReviewIgnore | null {\n return list.find((i) => i.key === key) ?? null;\n}\n\n/** Set one item aside (replacing an earlier entry for it); refused keys leave the list as it was. */\nexport function withIgnore(\n list: ReadonlyArray<ReviewIgnore>,\n entry: { key: string; reason: IgnoreReason; note?: string },\n now: Date = new Date(),\n): ReviewIgnore[] {\n if (!canIgnoreKey(entry.key) || !isReason(entry.reason)) return [...list];\n const note = (entry.note ?? '').replace(/\\s+/g, ' ').trim().slice(0, MAX_IGNORE_NOTE);\n const next = list.filter((i) => i.key !== entry.key);\n next.push({ key: entry.key, reason: entry.reason, ...(note ? { note } : {}), at: now.toISOString() });\n return next.slice(-MAX_IGNORES);\n}\n\nexport function withoutIgnore(list: ReadonlyArray<ReviewIgnore>, key: string): ReviewIgnore[] {\n return list.filter((i) => i.key !== key);\n}\n\n/** What is sent to the server: who and when are the server's to stamp. */\nexport function ignoresPatch(\n list: ReadonlyArray<ReviewIgnore>,\n): Array<{ key: string; reason: IgnoreReason; note?: string }> {\n return normalizeReviewIgnores(list).map(({ key, reason, note }) => ({ key, reason, ...(note ? { note } : {}) }));\n}\n\n/** \"Not a real problem · Sam's note\" for the set-aside row. */\nexport function ignoreSummary(entry: ReviewIgnore): string {\n return [IGNORE_REASON_LABEL[entry.reason], entry.note].filter(Boolean).join(' · ');\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;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