@voltro/cms 0.85.0 → 0.87.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +5987 -0
- package/README.md +138 -0
- package/THIRD-PARTY-NOTICES.md +864 -253
- package/dist/ContentForm.js +282 -0
- package/dist/RichDocumentEditor.js +550 -0
- package/dist/RichDocumentView.js +177 -0
- package/dist/RichTextSurface.js +135 -0
- package/dist/aiCandidates.js +199 -0
- package/dist/aiOperations.js +152 -0
- package/dist/applicationBuildSnapshotService.js +101 -0
- package/dist/assetRenditions.js +102 -0
- package/dist/assetRevision.js +46 -0
- package/dist/assetUseRights.js +72 -0
- package/dist/audiences.js +31 -0
- package/dist/availability.js +124 -0
- package/dist/blueprint.js +166 -0
- package/dist/build.d.ts +3063 -0
- package/dist/build.js +37 -0
- package/dist/buildApplicationAdmission.js +16 -0
- package/dist/buildApplicationCatalog.js +136 -0
- package/dist/buildApplicationCatalogTable.js +24 -0
- package/dist/buildApplicationRest.js +99 -0
- package/dist/buildApplicationUpload.js +111 -0
- package/dist/buildSnapshot.js +401 -0
- package/dist/buildSnapshotApplicationPin.js +32 -0
- package/dist/buildSnapshotRest.js +210 -0
- package/dist/buildSnapshotService.js +265 -0
- package/dist/buildSnapshotTables.js +25 -0
- package/dist/bulk.js +282 -0
- package/dist/cacheIdentity.js +152 -0
- package/dist/changes.js +307 -0
- package/dist/cmsContext.js +229 -0
- package/dist/collections.js +224 -0
- package/dist/consent.js +29 -0
- package/dist/contentLocations.js +53 -0
- package/dist/contentProjection.js +83 -0
- package/dist/contentRouteIdentity.js +13 -0
- package/dist/contentRouteMaterializer.js +97 -0
- package/dist/contentRouteTypes.js +39 -0
- package/dist/contentSeo.js +189 -0
- package/dist/contentTreePath.js +60 -0
- package/dist/contentType.js +208 -0
- package/dist/contentValues.js +18 -0
- package/dist/contentfulImport.js +162 -0
- package/dist/copies.js +89 -0
- package/dist/cutover.js +202 -0
- package/dist/deliveryChecks.js +138 -0
- package/dist/domainHost.js +7 -0
- package/dist/domains.js +139 -0
- package/dist/draftTexts.js +164 -0
- package/dist/duplicates.js +78 -0
- package/dist/edgePurge.js +69 -0
- package/dist/editHistory.js +113 -0
- package/dist/effectForm.js +11 -0
- package/dist/environmentAliases.js +138 -0
- package/dist/environments.js +147 -0
- package/dist/errors.js +107 -0
- package/dist/experiments.js +528 -0
- package/dist/exposure.js +28 -0
- package/dist/extensionManifest.js +81 -0
- package/dist/extensions.js +314 -0
- package/dist/fieldSchema.js +199 -0
- package/dist/formStrings.js +74 -0
- package/dist/frontendBindings.js +99 -0
- package/dist/frontendMedia.js +18 -0
- package/dist/glossary.js +73 -0
- package/dist/history.js +54 -0
- package/dist/htmlImport.js +297 -0
- package/dist/index.d.ts +771 -54
- package/dist/index.js +89 -6082
- package/dist/initializePublicRoutes.js +28 -0
- package/dist/liveContentRouteView.js +76 -0
- package/dist/media.js +29 -0
- package/dist/metrics.js +46 -0
- package/dist/migration.js +193 -0
- package/dist/migrationStages.js +13 -0
- package/dist/nativeOutputDeploymentService.js +205 -0
- package/dist/outputActivation.js +234 -0
- package/dist/outputActivationOrigin.js +51 -0
- package/dist/outputActivationStore.js +411 -0
- package/dist/outputActivationTables.js +11 -0
- package/dist/outputActivationTarget.js +81 -0
- package/dist/outputActivationTargetTable.js +25 -0
- package/dist/outputDeployment.js +174 -0
- package/dist/outputDeploymentRest.js +168 -0
- package/dist/outputDeploymentService.js +241 -0
- package/dist/outputRouteGraph.js +177 -0
- package/dist/outputSafetyArtifact.js +147 -0
- package/dist/outputTargetRest.js +62 -0
- package/dist/pathSegmentEncoding.js +4 -0
- package/dist/presenceAnchors.js +68 -0
- package/dist/preview.js +31 -0
- package/dist/privateCmsTransport.js +76 -0
- package/dist/privateNativeRouteReservation.js +10 -0
- package/dist/promotion.js +116 -0
- package/dist/publicBuild.js +90 -0
- package/dist/publicBuildRest.js +98 -0
- package/dist/publicBuildService.js +63 -0
- package/dist/publicOutputHttp.js +129 -0
- package/dist/publicOutputService.js +287 -0
- package/dist/publicPresentation.js +17 -0
- package/dist/publicRouteDispositionAdmission.js +38 -0
- package/dist/publicRouteHistoryStore.js +12 -0
- package/dist/publicRouteHistoryView.js +34 -0
- package/dist/publicRouteIntegrity.js +5 -0
- package/dist/publicRouteMutation.js +6 -0
- package/dist/publicRouteNamespace.js +134 -0
- package/dist/publicRoutePublication.js +36 -0
- package/dist/publicRouteRegistry.js +17 -0
- package/dist/publicRouteRegistryBinding.js +194 -0
- package/dist/publicRouteRegistryDefinition.js +76 -0
- package/dist/publicRouteSitePublication.js +40 -0
- package/dist/publicRouteTables.js +13 -0
- package/dist/publicRouteUrl.js +18 -0
- package/dist/publicationSeo.js +52 -0
- package/dist/publicationState.js +296 -0
- package/dist/quality.js +188 -0
- package/dist/reconfigurePublicRoutes.js +41 -0
- package/dist/recurrence.js +78 -0
- package/dist/redirects.js +130 -0
- package/dist/referenceGraph.js +224 -0
- package/dist/references.js +173 -0
- package/dist/release.js +241 -0
- package/dist/renderReadAuthority.js +43 -0
- package/dist/renderReadGrant.js +137 -0
- package/dist/rest.js +52 -0
- package/dist/review.js +160 -0
- package/dist/richDocument.js +521 -0
- package/dist/richInline.js +100 -0
- package/dist/routeDispositionGraph.js +44 -0
- package/dist/routeDispositionRest.js +51 -0
- package/dist/routeDispositionService.js +73 -0
- package/dist/routeDispositionStore.js +289 -0
- package/dist/routeDispositionTables.js +5 -0
- package/dist/routeDispositions.js +91 -0
- package/dist/routeHistoryStorage.js +320 -0
- package/dist/routeHistoryStore.js +12 -0
- package/dist/schedule.js +80 -0
- package/dist/search.js +148 -0
- package/dist/selectionIntent.js +164 -0
- package/dist/seo.js +31 -0
- package/dist/series.js +105 -0
- package/dist/share.js +112 -0
- package/dist/siteBindings.js +159 -0
- package/dist/siteBuildCandidate.js +104 -0
- package/dist/siteDelivery.js +115 -0
- package/dist/siteState.js +47 -0
- package/dist/snapshotAddressGraph.js +55 -0
- package/dist/snapshotAddressRead.js +73 -0
- package/dist/snapshotAppConsumer.js +71 -0
- package/dist/snapshotAppExecution.js +102 -0
- package/dist/snapshotApplication.js +75 -0
- package/dist/snapshotApprovedRouteDispositions.js +44 -0
- package/dist/snapshotAssetAssembly.js +70 -0
- package/dist/snapshotAssetAssemblyRest.js +50 -0
- package/dist/snapshotBindingRead.js +61 -0
- package/dist/snapshotCodeSeo.js +29 -0
- package/dist/snapshotComponent.js +34 -0
- package/dist/snapshotComponentSource.js +24 -0
- package/dist/snapshotConsumer.js +87 -0
- package/dist/snapshotContentIdentity.js +10 -0
- package/dist/snapshotDefinitions.js +264 -0
- package/dist/snapshotDocumentAssembly.js +193 -0
- package/dist/snapshotDocumentAssemblyRest.js +84 -0
- package/dist/snapshotDocumentProjection.js +202 -0
- package/dist/snapshotDocumentTransfer.js +35 -0
- package/dist/snapshotDocumentTransferRest.js +80 -0
- package/dist/snapshotDomains.js +56 -0
- package/dist/snapshotEnvironment.js +31 -0
- package/dist/snapshotFieldPlan.js +85 -0
- package/dist/snapshotFrontend.js +103 -0
- package/dist/snapshotLink.js +8 -0
- package/dist/snapshotMedia.js +111 -0
- package/dist/snapshotMediaCapture.js +246 -0
- package/dist/snapshotMediaFields.js +225 -0
- package/dist/snapshotMediaRead.js +185 -0
- package/dist/snapshotMediaReader.js +13 -0
- package/dist/snapshotObservation.js +16 -0
- package/dist/snapshotObservedRouteHistory.js +34 -0
- package/dist/snapshotOutputTransfer.js +78 -0
- package/dist/snapshotPageLoader.js +7 -0
- package/dist/snapshotPageSeo.js +59 -0
- package/dist/snapshotPathLocale.js +15 -0
- package/dist/snapshotPresentation.js +86 -0
- package/dist/snapshotPresentationPolicy.js +12 -0
- package/dist/snapshotProjection.js +119 -0
- package/dist/snapshotPublicAccess.js +161 -0
- package/dist/snapshotPublicRouteHistory.js +40 -0
- package/dist/snapshotReadAdmission.js +38 -0
- package/dist/snapshotRedirectOutput.js +151 -0
- package/dist/snapshotRedirectTargets.js +24 -0
- package/dist/snapshotRedirects.js +132 -0
- package/dist/snapshotReference.js +8 -0
- package/dist/snapshotReferenceAddress.js +10 -0
- package/dist/snapshotReferenceGraph.js +79 -0
- package/dist/snapshotReferenceRead.js +65 -0
- package/dist/snapshotRelease.js +99 -0
- package/dist/snapshotRender.js +361 -0
- package/dist/snapshotRenderDependencies.js +178 -0
- package/dist/snapshotRenditions.js +88 -0
- package/dist/snapshotRichDocument.js +62 -0
- package/dist/snapshotRoleTransfer.js +106 -0
- package/dist/snapshotRoleTransferRest.js +99 -0
- package/dist/snapshotRouteAdmission.js +71 -0
- package/dist/snapshotRouteDispatch.js +111 -0
- package/dist/snapshotRouteDispositionPlan.js +73 -0
- package/dist/snapshotRouteRead.js +43 -0
- package/dist/snapshotRoutes.js +79 -0
- package/dist/snapshotRouting.js +113 -0
- package/dist/snapshotSeo.js +179 -0
- package/dist/snapshotSeoControls.js +101 -0
- package/dist/snapshotSeoDocumentInventory.js +115 -0
- package/dist/snapshotSeoDocuments.js +129 -0
- package/dist/snapshotSeoMerge.js +85 -0
- package/dist/snapshotSeoMetadata.js +137 -0
- package/dist/snapshotSeoOutput.js +173 -0
- package/dist/snapshotSeoPathSets.js +105 -0
- package/dist/snapshotSeoRead.js +88 -0
- package/dist/snapshotSite.js +128 -0
- package/dist/snapshotSitemapFiles.js +36 -0
- package/dist/snapshotTreeDependencies.js +58 -0
- package/dist/snapshotTreeLoader.js +10 -0
- package/dist/snapshotTreeRead.js +158 -0
- package/dist/staticPathSet.js +177 -0
- package/dist/staticPathSetRest.js +129 -0
- package/dist/staticPathSetService.js +249 -0
- package/dist/staticPathSetStore.js +338 -0
- package/dist/stewardship.js +146 -0
- package/dist/taxonomy.js +36 -0
- package/dist/team.js +103 -0
- package/dist/templates.js +106 -0
- package/dist/trackChanges.js +197 -0
- package/dist/translation.js +64 -0
- package/dist/tree.js +87 -0
- package/dist/usage.js +50 -0
- package/dist/validation.js +192 -0
- package/dist/visualEditing.js +60 -0
- package/dist/web.d.ts +709 -7
- package/dist/web.js +50 -2
- package/dist/workflow.js +322 -0
- package/dist/write.js +419 -0
- package/dist/xliff.js +325 -0
- package/package.json +20 -6
- package/dist/presenceAnchors-4iHAVQB3.js +0 -4367
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import { ContentValidationFailed as e } from "./errors.js";
|
|
2
|
+
import { normalizeRichDocument as t, richDocumentProblems as n } from "./richDocument.js";
|
|
3
|
+
import { normalizeTerms as r, taxonomyValue as i } from "./taxonomy.js";
|
|
4
|
+
import { documentHasChanges as a } from "./trackChanges.js";
|
|
5
|
+
//#region src/validation.ts
|
|
6
|
+
var o = /* @__PURE__ */ new Set([
|
|
7
|
+
"status",
|
|
8
|
+
"publishAt",
|
|
9
|
+
"unpublishAt",
|
|
10
|
+
"revisionId",
|
|
11
|
+
"revision",
|
|
12
|
+
"documentId",
|
|
13
|
+
"site",
|
|
14
|
+
"environment",
|
|
15
|
+
"locale",
|
|
16
|
+
"tenantId",
|
|
17
|
+
"createdAt",
|
|
18
|
+
"updatedAt",
|
|
19
|
+
"createdBy",
|
|
20
|
+
"updatedBy"
|
|
21
|
+
]), s = (e, t, n) => ({
|
|
22
|
+
field: e,
|
|
23
|
+
rule: t,
|
|
24
|
+
message: n
|
|
25
|
+
}), c = (e) => typeof e == "object" && !!e && !Array.isArray(e), l = (e) => e instanceof Date ? !Number.isNaN(e.getTime()) : typeof e == "string" && !Number.isNaN(new Date(e).getTime()), u = (e, t, n) => {
|
|
26
|
+
let r = [];
|
|
27
|
+
return t.maxLength !== void 0 && n.length > t.maxLength && r.push(s(e, "maxLength", `exceeds maxLength(${t.maxLength}) — got ${n.length} characters`)), t.pattern !== void 0 && !new RegExp(t.pattern).test(n) && r.push(s(e, "pattern", `does not match pattern /${t.pattern}/`)), r;
|
|
28
|
+
}, d = (e, r, i) => {
|
|
29
|
+
switch (r.kind) {
|
|
30
|
+
case "string":
|
|
31
|
+
case "media":
|
|
32
|
+
case "reference": return typeof i == "string" ? u(e, r, i) : [s(e, "type", `expected a string, got ${typeof i}`)];
|
|
33
|
+
case "number": return typeof i != "number" || !Number.isFinite(i) ? [s(e, "type", "expected a finite number")] : r.fraction !== !0 && !Number.isInteger(i) ? [s(e, "integer", "expected a whole number (declare Schema.Fraction for fractions)")] : [];
|
|
34
|
+
case "boolean": return typeof i == "boolean" ? [] : [s(e, "type", `expected a boolean, got ${typeof i}`)];
|
|
35
|
+
case "date":
|
|
36
|
+
case "datetime": return l(i) ? [] : [s(e, "type", "expected a Date or a parseable date string")];
|
|
37
|
+
case "literal": {
|
|
38
|
+
let t = r.literals ?? [];
|
|
39
|
+
return typeof i != "string" || !t.includes(i) ? [s(e, "literal", `expected one of: ${t.join(", ")}`)] : [];
|
|
40
|
+
}
|
|
41
|
+
case "richText": {
|
|
42
|
+
let a = r.richText ?? {}, o = t(i), l = n(e, o, a).map((e) => s(e.path, e.rule, e.message)), u = new Map((a.profile?.components ?? []).map((e) => [e.id, e]));
|
|
43
|
+
return (c(o) && Array.isArray(o.blocks) ? o.blocks : []).forEach((t, n) => {
|
|
44
|
+
if (!c(t) || t.type !== "component" || !c(t.props)) return;
|
|
45
|
+
let r = u.get(String(t.componentId));
|
|
46
|
+
r !== void 0 && l.push(...f(`${e}.blocks[${n}].props`, r.props, t.props, `component '${r.id}'`, !0));
|
|
47
|
+
}), l;
|
|
48
|
+
}
|
|
49
|
+
case "array": {
|
|
50
|
+
if (!Array.isArray(i)) return [s(e, "type", "expected an array")];
|
|
51
|
+
let t = r.element;
|
|
52
|
+
if (t === void 0) return [];
|
|
53
|
+
let n = [];
|
|
54
|
+
return i.forEach((r, i) => n.push(...d(`${e}[${i}]`, t, r))), n;
|
|
55
|
+
}
|
|
56
|
+
case "struct": return c(i) ? f(e, r.struct ?? {}, i, "struct", !1) : [s(e, "type", "expected an object")];
|
|
57
|
+
case "components": {
|
|
58
|
+
if (!Array.isArray(i)) return [s(e, "type", "expected a list of components")];
|
|
59
|
+
let t = new Map((r.components ?? []).map((e) => [e.id, e])), n = [], a = /* @__PURE__ */ new Set();
|
|
60
|
+
return i.forEach((r, i) => {
|
|
61
|
+
let o = `${e}[${i}]`;
|
|
62
|
+
if (!c(r)) {
|
|
63
|
+
n.push(s(o, "type", "expected a component instance"));
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
let l = r.instanceId;
|
|
67
|
+
typeof l != "string" || l === "" ? n.push(s(`${o}.instanceId`, "required", "missing instance id")) : a.has(l) ? n.push(s(`${o}.instanceId`, "unique", `instance '${l}' appears twice`)) : a.add(l);
|
|
68
|
+
let u = t.get(String(r.componentId));
|
|
69
|
+
if (u === void 0) {
|
|
70
|
+
n.push(s(`${o}.componentId`, "unknown", `'${String(r.componentId)}' is not a component this field allows`));
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
let d = r.props;
|
|
74
|
+
c(d) ? n.push(...f(`${o}.props`, u.props, d, `component '${u.id}'`, !0)) : n.push(s(`${o}.props`, "type", "expected an object"));
|
|
75
|
+
}), n;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}, f = (e, t, n, r, i) => {
|
|
79
|
+
let a = [];
|
|
80
|
+
for (let [r, o] of Object.entries(t)) {
|
|
81
|
+
let t = n[r];
|
|
82
|
+
t == null || i && t === "" ? o.isOptional || a.push(s(`${e}.${r}`, "required", "missing required field")) : a.push(...d(`${e}.${r}`, o, t));
|
|
83
|
+
}
|
|
84
|
+
for (let i of Object.keys(n)) i in t || a.push(s(`${e}.${i}`, "unknown", `not a declared field of this ${r}`));
|
|
85
|
+
return a;
|
|
86
|
+
}, p = (e, t) => {
|
|
87
|
+
let n = [];
|
|
88
|
+
for (let [r, i] of Object.entries(e.fields)) {
|
|
89
|
+
let e = t[r];
|
|
90
|
+
e == null ? i.isOptional || n.push(s(r, "required", "missing required field")) : n.push(...d(r, i, e));
|
|
91
|
+
}
|
|
92
|
+
let i = t.id;
|
|
93
|
+
i !== void 0 && typeof i != "string" && n.push(s("id", "type", "expected a string id"));
|
|
94
|
+
for (let r of Object.keys(t)) r === "id" || r in e.fields || o.has(r) || n.push(s(r, "unknown", `'${r}' is not a declared field of '${e.name}'`));
|
|
95
|
+
let a = e.taxonomy;
|
|
96
|
+
if (a !== void 0 && (a.unknown ?? "refuse") === "refuse" && Array.isArray(t[a.field])) {
|
|
97
|
+
let { unknown: e } = r(a, t[a.field]);
|
|
98
|
+
e.length > 0 && n.push(s(a.field, "taxonomy", `not in the vocabulary: ${e.join(", ")}`));
|
|
99
|
+
}
|
|
100
|
+
return n;
|
|
101
|
+
}, m = (e, t) => [...Object.entries(e.fields).filter(([e, n]) => {
|
|
102
|
+
let r = t[e];
|
|
103
|
+
return n.publishRequired === !0 && (r == null || typeof r == "string" && r.trim() === "");
|
|
104
|
+
}).map(([e]) => s(e, "requiredToPublish", "needed before publishing")), ...Object.entries(e.fields).filter(([e, n]) => {
|
|
105
|
+
let r = t[e];
|
|
106
|
+
return n.kind === "richText" && c(r) && Array.isArray(r.blocks) && a(r);
|
|
107
|
+
}).map(([e]) => s(e, "pendingChanges", "accept or reject the suggested changes first"))], h = (t, n) => {
|
|
108
|
+
let r = p(t, n);
|
|
109
|
+
if (r.length > 0) throw new e({
|
|
110
|
+
contentType: t.name,
|
|
111
|
+
violations: r
|
|
112
|
+
});
|
|
113
|
+
}, g = (e, n) => {
|
|
114
|
+
let r = { ...n }, a = e.taxonomy;
|
|
115
|
+
a !== void 0 && Array.isArray(r[a.field]) && (r[a.field] = i(a, r[a.field]));
|
|
116
|
+
for (let t of e.derivedFields) {
|
|
117
|
+
let n = e.fields[t]?.derived;
|
|
118
|
+
n !== void 0 && (r[t] = n.transform(r[n.source], r));
|
|
119
|
+
}
|
|
120
|
+
for (let [n, i] of Object.entries(e.fields)) i.kind === "richText" && r[n] !== void 0 && r[n] !== null && (r[n] = _(i, t(r[n], i.richText?.profile)));
|
|
121
|
+
for (let [t, n] of Object.entries(e.fields)) n.kind === "components" && Array.isArray(r[t]) && (r[t] = v(n.components ?? [], r[t]));
|
|
122
|
+
return r;
|
|
123
|
+
}, _ = (e, t) => {
|
|
124
|
+
let n = e.richText?.profile?.components ?? [];
|
|
125
|
+
return n.length === 0 || !c(t) || !Array.isArray(t.blocks) ? t : {
|
|
126
|
+
...t,
|
|
127
|
+
blocks: t.blocks.map((e) => {
|
|
128
|
+
if (!c(e) || e.type !== "component") return e;
|
|
129
|
+
let [t] = v(n, [{
|
|
130
|
+
...e,
|
|
131
|
+
instanceId: e.id
|
|
132
|
+
}]);
|
|
133
|
+
return t === void 0 || t.fingerprint === void 0 ? e : {
|
|
134
|
+
...e,
|
|
135
|
+
props: t.props,
|
|
136
|
+
fingerprint: t.fingerprint
|
|
137
|
+
};
|
|
138
|
+
})
|
|
139
|
+
};
|
|
140
|
+
}, v = (e, t) => {
|
|
141
|
+
let n = new Map(e.map((e) => [e.id, e]));
|
|
142
|
+
return t.map((e) => {
|
|
143
|
+
if (!c(e)) return e;
|
|
144
|
+
let t = n.get(String(e.componentId)), r = typeof e.instanceId == "string" && e.instanceId !== "" ? e.instanceId : x();
|
|
145
|
+
if (t === void 0) return {
|
|
146
|
+
...e,
|
|
147
|
+
instanceId: r
|
|
148
|
+
};
|
|
149
|
+
let i = c(e.props) ? e.props : {}, a = typeof e.fingerprint == "string" ? e.fingerprint : null, o = a !== null && a !== t.fingerprint ? t.migrations?.[a] : void 0;
|
|
150
|
+
o !== void 0 && (i = o(i));
|
|
151
|
+
let s = Object.fromEntries(Object.entries(i).map(([e, n]) => {
|
|
152
|
+
let r = t.props[e];
|
|
153
|
+
return [e, r?.kind === "components" && Array.isArray(n) ? v(r.components ?? [], n) : n];
|
|
154
|
+
}));
|
|
155
|
+
return {
|
|
156
|
+
...e,
|
|
157
|
+
instanceId: r,
|
|
158
|
+
props: s,
|
|
159
|
+
fingerprint: t.fingerprint
|
|
160
|
+
};
|
|
161
|
+
});
|
|
162
|
+
}, y = (e, t) => {
|
|
163
|
+
let n = [], r = (e, t, i) => {
|
|
164
|
+
if (e.kind !== "components" || !Array.isArray(t)) return;
|
|
165
|
+
let a = new Map((e.components ?? []).map((e) => [e.id, e]));
|
|
166
|
+
t.forEach((e, t) => {
|
|
167
|
+
if (!c(e)) return;
|
|
168
|
+
let o = a.get(String(e.componentId));
|
|
169
|
+
if (o === void 0) return;
|
|
170
|
+
let s = typeof e.fingerprint == "string" ? e.fingerprint : null;
|
|
171
|
+
s !== o.fingerprint && (s === null || o.migrations?.[s] === void 0) && n.push({
|
|
172
|
+
path: `${i}[${t}]`,
|
|
173
|
+
componentId: o.id,
|
|
174
|
+
fingerprint: s
|
|
175
|
+
});
|
|
176
|
+
let l = c(e.props) ? e.props : {};
|
|
177
|
+
for (let [e, n] of Object.entries(o.props)) r(n, l[e], `${i}[${t}].props.${e}`);
|
|
178
|
+
});
|
|
179
|
+
};
|
|
180
|
+
for (let [n, i] of Object.entries(e.fields)) r(i, t[n], n);
|
|
181
|
+
return n;
|
|
182
|
+
}, b = (e) => {
|
|
183
|
+
let t = [];
|
|
184
|
+
for (let [n, r] of Object.entries(e.fixtures ?? {})) t.push(...f(`fixtures.${n}`, e.props, r, `component '${e.id}'`, !0));
|
|
185
|
+
for (let [n, r] of Object.entries(e.variants ?? {})) {
|
|
186
|
+
let i = Object.fromEntries(Object.entries(e.props).filter(([e]) => e in r));
|
|
187
|
+
t.push(...f(`variants.${n}`, i, r, `component '${e.id}'`, !0));
|
|
188
|
+
}
|
|
189
|
+
return t;
|
|
190
|
+
}, x = () => `cins_${globalThis.crypto.randomUUID().replaceAll("-", "")}`;
|
|
191
|
+
//#endregion
|
|
192
|
+
export { g as applyDerivations, b as componentExampleViolations, p as contentViolations, x as newInstanceId, m as publishViolations, y as staleComponents, h as validateContent };
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
//#region src/visualEditing.ts
|
|
2
|
+
var e = "voltro.cms.visual/1", t = () => Array.from(globalThis.crypto.getRandomValues(/* @__PURE__ */ new Uint8Array(16)), (e) => e.toString(16).padStart(2, "0")).join(""), n = /^[A-Za-z_][A-Za-z0-9_]*(\.\d+)?$/, r = (e, t) => {
|
|
3
|
+
if (e.origin !== t.origin) return null;
|
|
4
|
+
let n = e.data;
|
|
5
|
+
if (typeof n != "object" || !n) return null;
|
|
6
|
+
let r = n;
|
|
7
|
+
return r.protocol === "voltro.cms.visual/1" && typeof r.nonce == "string" && r.nonce === t.nonce ? r : null;
|
|
8
|
+
}, i = (t, i) => {
|
|
9
|
+
let a = r(t, i);
|
|
10
|
+
if (a === null) return null;
|
|
11
|
+
let o = {
|
|
12
|
+
protocol: e,
|
|
13
|
+
nonce: i.nonce
|
|
14
|
+
};
|
|
15
|
+
return a.kind === "ready" ? {
|
|
16
|
+
...o,
|
|
17
|
+
kind: "ready"
|
|
18
|
+
} : typeof a.path != "string" || !n.test(a.path) ? null : a.kind === "select" ? {
|
|
19
|
+
...o,
|
|
20
|
+
kind: "select",
|
|
21
|
+
path: a.path
|
|
22
|
+
} : a.kind === "move" && Number.isInteger(a.to) && a.to >= 0 ? {
|
|
23
|
+
...o,
|
|
24
|
+
kind: "move",
|
|
25
|
+
path: a.path,
|
|
26
|
+
to: a.to
|
|
27
|
+
} : null;
|
|
28
|
+
}, a = (t, n) => {
|
|
29
|
+
let i = r(t, n);
|
|
30
|
+
return i === null || i.kind !== "values" || typeof i.values != "object" || i.values === null || Array.isArray(i.values) ? null : {
|
|
31
|
+
protocol: e,
|
|
32
|
+
nonce: n.nonce,
|
|
33
|
+
kind: "values",
|
|
34
|
+
values: i.values
|
|
35
|
+
};
|
|
36
|
+
}, o = (t, n) => ({
|
|
37
|
+
protocol: e,
|
|
38
|
+
nonce: t.nonce,
|
|
39
|
+
...n
|
|
40
|
+
}), s = (e) => ({ "data-cms-source": e }), c = (e) => {
|
|
41
|
+
let t = e;
|
|
42
|
+
return (typeof t?.closest == "function" ? t.closest("[data-cms-source]") : null)?.getAttribute("data-cms-source") ?? null;
|
|
43
|
+
}, l = (e) => {
|
|
44
|
+
let [t = "", n] = e.split(".");
|
|
45
|
+
return n === void 0 ? { field: t } : {
|
|
46
|
+
field: t,
|
|
47
|
+
index: Number(n)
|
|
48
|
+
};
|
|
49
|
+
}, u = (e, t, n) => {
|
|
50
|
+
let r = Math.max(0, Math.min(e.length - 1, n));
|
|
51
|
+
if (t < 0 || t >= e.length || t === r) return e;
|
|
52
|
+
let i = [...e], [a] = i.splice(t, 1);
|
|
53
|
+
return i.splice(r, 0, a), i;
|
|
54
|
+
}, d = (e, t) => {
|
|
55
|
+
if (!n.test(t)) return null;
|
|
56
|
+
let { field: r, index: i } = l(t), a = e.querySelector(`[data-cms-field="${r}"]`);
|
|
57
|
+
return a === null || i === void 0 ? a : a.querySelectorAll("[data-cms-components] > [data-cms-component]")[i] ?? null;
|
|
58
|
+
};
|
|
59
|
+
//#endregion
|
|
60
|
+
export { e as VISUAL_EDITING_PROTOCOL, d as formPartOf, u as moveEntry, t as newVisualNonce, l as parseSourcePath, a as readEditorMessage, i as readPreviewMessage, s as sourceAttributes, c as sourcePathOf, o as visualMessage };
|