@voltro/cms 0.86.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 +5321 -0
- package/README.md +138 -0
- package/THIRD-PARTY-NOTICES.md +860 -221
- package/dist/RichDocumentView.js +81 -36
- package/dist/aiCandidates.js +3 -3
- 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/availability.js +19 -16
- package/dist/blueprint.js +75 -75
- 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 +71 -70
- package/dist/changes.js +279 -62
- package/dist/consent.js +5 -5
- 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 +117 -100
- package/dist/contentValues.js +18 -0
- package/dist/copies.js +3 -3
- package/dist/domainHost.js +7 -0
- package/dist/domains.js +81 -87
- package/dist/draftTexts.js +37 -37
- package/dist/duplicates.js +23 -23
- package/dist/environmentAliases.js +138 -0
- package/dist/environments.js +107 -69
- package/dist/errors.js +54 -14
- package/dist/experiments.js +7 -7
- package/dist/frontendBindings.js +99 -0
- package/dist/frontendMedia.js +18 -0
- package/dist/index.d.ts +760 -47
- package/dist/index.js +89 -73
- package/dist/initializePublicRoutes.js +28 -0
- package/dist/liveContentRouteView.js +76 -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/privateCmsTransport.js +76 -0
- package/dist/privateNativeRouteReservation.js +10 -0
- package/dist/promotion.js +68 -59
- 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 +8 -8
- package/dist/reconfigurePublicRoutes.js +41 -0
- package/dist/redirects.js +104 -73
- package/dist/referenceGraph.js +15 -14
- package/dist/references.js +2 -2
- package/dist/release.js +177 -141
- package/dist/renderReadAuthority.js +43 -0
- package/dist/renderReadGrant.js +137 -0
- package/dist/review.js +28 -28
- package/dist/richDocument.js +54 -24
- 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 +36 -36
- package/dist/seo.js +1 -1
- package/dist/series.js +11 -11
- package/dist/share.js +13 -13
- 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/tree.js +9 -9
- package/dist/validation.js +53 -53
- package/dist/web.d.ts +709 -7
- package/dist/web.js +50 -33
- package/dist/workflow.js +8 -8
- package/dist/write.js +250 -225
- package/package.json +20 -6
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { readVerifiedSnapshotResource as e } from "./buildSnapshot.js";
|
|
2
|
+
import { copySnapshotPresentationValue as t } from "./snapshotPresentation.js";
|
|
3
|
+
import { admitSnapshotPublicDocument as n } from "./snapshotPublicAccess.js";
|
|
4
|
+
import { SnapshotRouteReadUnavailable as r } from "./snapshotRouteAdmission.js";
|
|
5
|
+
import { projectSnapshotDocument as i } from "./snapshotDocumentProjection.js";
|
|
6
|
+
import { readSnapshotRouteContext as a } from "./snapshotRouteRead.js";
|
|
7
|
+
import { readAdmittedSnapshotBindingContext as o } from "./snapshotBindingRead.js";
|
|
8
|
+
import { readAdmittedSnapshotFieldPlan as s } from "./snapshotFieldPlan.js";
|
|
9
|
+
import { canonicalJson as c } from "@voltro/runtime";
|
|
10
|
+
//#region src/snapshotReferenceRead.ts
|
|
11
|
+
var l = () => {
|
|
12
|
+
throw new r({ reason: "binding" });
|
|
13
|
+
}, u = (e) => !Array.isArray(e) || e.length === 0 || e.length > 128 || e.some((e) => typeof e == "number" ? !Number.isSafeInteger(e) || e < 0 : typeof e != "string" || e.length === 0 || e.length > 256) ? l() : [...e], d = async (e, t, n, r, i) => {
|
|
14
|
+
let a = await f(e, t, n, r, i);
|
|
15
|
+
return a === null ? null : p(e, t, n, a, i);
|
|
16
|
+
}, f = async (e, t, n, r, i) => {
|
|
17
|
+
let a = u(r);
|
|
18
|
+
return (await s(e, t, n, i)).references.find((e) => c(e.path) === c(a)) ?? null;
|
|
19
|
+
}, p = async (t, r, a, o, s) => {
|
|
20
|
+
let c = await n(t, r, a.snapshot, o.targetType, a.output.localeId, o.targetDocumentId, s);
|
|
21
|
+
if (c === null) return null;
|
|
22
|
+
let l = c.chain[0], u = (await e(t, r, a.snapshot, "schema", `type:${o.targetType}`)).value, d = await i(t, r, a.snapshot, o.targetType, l, u, s, a.output.presentation);
|
|
23
|
+
return {
|
|
24
|
+
snapshot: a.snapshot,
|
|
25
|
+
document: l,
|
|
26
|
+
binding: a.binding,
|
|
27
|
+
routeId: a.routeId,
|
|
28
|
+
components: d.components,
|
|
29
|
+
output: {
|
|
30
|
+
contentType: o.targetType,
|
|
31
|
+
localeId: a.output.localeId,
|
|
32
|
+
requestedLocale: c.requestedLocale,
|
|
33
|
+
sourceLocale: l.locale,
|
|
34
|
+
fallback: l.locale !== c.requestedLocale,
|
|
35
|
+
values: d.values,
|
|
36
|
+
presentation: d.presentation
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
}, m = async (e, n, r, i, s) => {
|
|
40
|
+
let c = {
|
|
41
|
+
...i,
|
|
42
|
+
presentation: t(i.presentation)
|
|
43
|
+
}, f = s.now ?? Date.now();
|
|
44
|
+
if (!Array.isArray(c.references) || c.references.length > 16) return l();
|
|
45
|
+
let p = c.references.map(u), m = {
|
|
46
|
+
tenantId: n.tenantId,
|
|
47
|
+
site: n.site,
|
|
48
|
+
environment: n.environment
|
|
49
|
+
}, h = await a(e, m, r, c, {
|
|
50
|
+
...s,
|
|
51
|
+
now: f
|
|
52
|
+
});
|
|
53
|
+
if (h === null) return null;
|
|
54
|
+
let g = c.binding === void 0 ? {
|
|
55
|
+
...h,
|
|
56
|
+
routeId: h.output.routeId
|
|
57
|
+
} : await o(e, m, h, c.binding, f);
|
|
58
|
+
for (let t of p) {
|
|
59
|
+
if (g === null) return null;
|
|
60
|
+
g = await d(e, m, g, t, f);
|
|
61
|
+
}
|
|
62
|
+
return g;
|
|
63
|
+
}, h = async (...e) => !Array.isArray(e[3].references) || e[3].references.length === 0 ? l() : m(...e);
|
|
64
|
+
//#endregion
|
|
65
|
+
export { d as readAdmittedSnapshotReferenceContext, f as readAdmittedSnapshotReferenceUse, p as readPlannedSnapshotReferenceContext, h as readSnapshotReferenceContext, m as readSnapshotReferenceSourceContext };
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { readPublicationBoundary as e } from "./changes.js";
|
|
2
|
+
import { readCapturedPublication as t } from "./publicationState.js";
|
|
3
|
+
import { copySnapshotResource as n } from "./buildSnapshot.js";
|
|
4
|
+
import { CMS_RELEASES_TABLE as r, CMS_RELEASE_ITEMS_TABLE as i } from "./release.js";
|
|
5
|
+
import { Schema as a } from "effect";
|
|
6
|
+
import { and as o, eq as s, gt as c } from "@voltro/database";
|
|
7
|
+
//#region src/snapshotRelease.ts
|
|
8
|
+
var l = class extends a.TaggedError()("SnapshotReleaseUnavailable", { reason: a.Literals([
|
|
9
|
+
"scope",
|
|
10
|
+
"release",
|
|
11
|
+
"checkpoint",
|
|
12
|
+
"item"
|
|
13
|
+
]) }) {}, u = (e) => {
|
|
14
|
+
throw new l({ reason: e });
|
|
15
|
+
}, d = (e) => typeof e == "string" && e.trim().length > 0, f = (e) => e === null || d(e), p = (a, l, p, m = Date.now()) => {
|
|
16
|
+
let h = {
|
|
17
|
+
tenantId: l.tenantId,
|
|
18
|
+
site: l.site,
|
|
19
|
+
environment: l.environment
|
|
20
|
+
};
|
|
21
|
+
return ![
|
|
22
|
+
h.tenantId,
|
|
23
|
+
h.site,
|
|
24
|
+
h.environment,
|
|
25
|
+
p
|
|
26
|
+
].every(d) || !Number.isSafeInteger(m) ? u("scope") : {
|
|
27
|
+
format: "voltro.cms.release/v1",
|
|
28
|
+
entries: async function* (l) {
|
|
29
|
+
let g = await e(a, h);
|
|
30
|
+
if (g.generation !== l.generation || g.releaseId !== p || l.releaseId !== p || g.checkpoint !== l.checkpoint) return u("checkpoint");
|
|
31
|
+
let [_] = await a.query({
|
|
32
|
+
table: r,
|
|
33
|
+
predicate: o(s("tenantId", h.tenantId), s("site", h.site), s("environment", h.environment), s("id", p)),
|
|
34
|
+
lock: "update",
|
|
35
|
+
order: [],
|
|
36
|
+
take: 1,
|
|
37
|
+
skip: void 0,
|
|
38
|
+
projection: void 0
|
|
39
|
+
});
|
|
40
|
+
if (_ === void 0 || _.publicationGeneration !== l.generation || _.publicationCheckpoint !== l.checkpoint || _.status !== "published" || !d(_.name) || !f(_.rollbackOf)) return u("release");
|
|
41
|
+
let v = _.publishedAt instanceof Date ? _.publishedAt.getTime() : typeof _.publishedAt == "string" ? Date.parse(_.publishedAt) : NaN;
|
|
42
|
+
if (!Number.isSafeInteger(v) || v > m) return u("release");
|
|
43
|
+
yield n({
|
|
44
|
+
key: "release",
|
|
45
|
+
value: {
|
|
46
|
+
id: p,
|
|
47
|
+
name: _.name,
|
|
48
|
+
...h,
|
|
49
|
+
publishedAt: v,
|
|
50
|
+
rollbackOf: _.rollbackOf,
|
|
51
|
+
publication: { ...l }
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
let y;
|
|
55
|
+
for (;;) {
|
|
56
|
+
let e = await a.query({
|
|
57
|
+
table: i,
|
|
58
|
+
predicate: o(s("tenantId", h.tenantId), s("releaseId", p), ...y === void 0 ? [] : [c("id", y)]),
|
|
59
|
+
lock: "update",
|
|
60
|
+
order: [{
|
|
61
|
+
column: "id",
|
|
62
|
+
direction: "asc"
|
|
63
|
+
}],
|
|
64
|
+
take: 128,
|
|
65
|
+
skip: void 0,
|
|
66
|
+
projection: void 0
|
|
67
|
+
});
|
|
68
|
+
if (e.length === 0) break;
|
|
69
|
+
for (let r of e) {
|
|
70
|
+
if (![
|
|
71
|
+
r.id,
|
|
72
|
+
r.contentType,
|
|
73
|
+
r.variantId,
|
|
74
|
+
r.locale
|
|
75
|
+
].every(d) || !Number.isSafeInteger(r.position) || Number(r.position) < 0 || !f(r.previousRevisionId) || !(r.action === "publish" ? d(r.revisionId) : r.action === "unpublish" && r.revisionId === null)) return u("item");
|
|
76
|
+
let e = await t(a, h, l.id, String(r.contentType), String(r.locale), String(r.variantId), m);
|
|
77
|
+
if (r.action === "publish" ? e?.revisionId !== r.revisionId : e !== null) return u("item");
|
|
78
|
+
yield n({
|
|
79
|
+
key: `item:${String(r.id)}`,
|
|
80
|
+
value: {
|
|
81
|
+
id: r.id,
|
|
82
|
+
contentType: r.contentType,
|
|
83
|
+
variantId: r.variantId,
|
|
84
|
+
locale: r.locale,
|
|
85
|
+
action: r.action,
|
|
86
|
+
revisionId: r.revisionId,
|
|
87
|
+
previousRevisionId: r.previousRevisionId,
|
|
88
|
+
position: r.position,
|
|
89
|
+
inherited: r.inherited ?? null
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
y = String(e[e.length - 1].id);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
};
|
|
98
|
+
//#endregion
|
|
99
|
+
export { l as SnapshotReleaseUnavailable, p as snapshotReleaseSource };
|
|
@@ -0,0 +1,361 @@
|
|
|
1
|
+
import { cmsPublicBuildMeta as e, encodeCmsPublicBuildIdentity as t } from "./publicBuild.js";
|
|
2
|
+
import { copySnapshotPresentationValue as n } from "./snapshotPresentation.js";
|
|
3
|
+
import { copySnapshotContentIdentity as r } from "./snapshotContentIdentity.js";
|
|
4
|
+
import { verifyRetainedSnapshotRoutes as i, verifySnapshotAppExecution as a } from "./snapshotAppExecution.js";
|
|
5
|
+
import { copySnapshotCodeSeo as o } from "./snapshotCodeSeo.js";
|
|
6
|
+
import { readSnapshotBindingMediaBatch as s, readSnapshotReferenceMediaBatch as c, readSnapshotRouteMediaBatch as ee } from "./snapshotMediaRead.js";
|
|
7
|
+
import { readSnapshotRenderRoute as l } from "./snapshotRouteDispatch.js";
|
|
8
|
+
import { snapshotRenderDependencies as te } from "./snapshotRenderDependencies.js";
|
|
9
|
+
import { snapshotTreeDependencies as ne } from "./snapshotTreeDependencies.js";
|
|
10
|
+
import { Effect as re, Schema as u, Stream as d } from "effect";
|
|
11
|
+
import { createHash as f } from "node:crypto";
|
|
12
|
+
import { canonicalJson as p } from "@voltro/runtime";
|
|
13
|
+
import { encodeNativeFormCapture as ie } from "@voltro/protocol";
|
|
14
|
+
//#region src/snapshotRender.ts
|
|
15
|
+
var m = class extends u.TaggedError()("SnapshotRenderUnavailable", { reason: u.Literals(["output", "changed"]) }) {}, h = (e) => {
|
|
16
|
+
throw new m({ reason: e });
|
|
17
|
+
}, g = (e) => f("sha256").update(p(e)).digest("hex"), _ = async (u, m, _, v, y) => {
|
|
18
|
+
let b = { ...m }, x = {
|
|
19
|
+
id: _.id,
|
|
20
|
+
digest: _.digest
|
|
21
|
+
}, S = {
|
|
22
|
+
...v,
|
|
23
|
+
presentation: n(v.presentation)
|
|
24
|
+
}, C = y.keys.map((e) => ({
|
|
25
|
+
id: e.id,
|
|
26
|
+
material: new Uint8Array(e.material)
|
|
27
|
+
})), w = y.output === void 0 ? void 0 : {
|
|
28
|
+
...y.output,
|
|
29
|
+
use: { ...y.output.use }
|
|
30
|
+
}, T = y.execution.run.bind(y.execution), E = y.now ?? Date.now, D = () => u.transactional((e) => l(e, b, x, S, {
|
|
31
|
+
keys: C,
|
|
32
|
+
now: E()
|
|
33
|
+
})), O = await D();
|
|
34
|
+
if (O === null) return null;
|
|
35
|
+
if (await i(O, T), O.context === void 0) return h("output");
|
|
36
|
+
let k = O.definitions.value.consentPurposes, A = w === void 0 ? null : await w.provider.begin();
|
|
37
|
+
try {
|
|
38
|
+
let n = [], i = O.owner === "cms" ? O.seo : null, l = [], m = Object.create(null), _ = Object.create(null), v = [];
|
|
39
|
+
if (O.owner === "cms") {
|
|
40
|
+
v.push({
|
|
41
|
+
source: null,
|
|
42
|
+
selections: O.media,
|
|
43
|
+
media: l
|
|
44
|
+
});
|
|
45
|
+
for (let [e, t] of Object.entries(O.bindings)) {
|
|
46
|
+
if (t === null) {
|
|
47
|
+
m[e] = null;
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
let n = [];
|
|
51
|
+
m[e] = {
|
|
52
|
+
content: r(t.content),
|
|
53
|
+
context: O.context,
|
|
54
|
+
sourceLocale: t.output.sourceLocale,
|
|
55
|
+
fallback: t.output.fallback,
|
|
56
|
+
values: t.output.values,
|
|
57
|
+
media: n,
|
|
58
|
+
presentation: t.output.presentation,
|
|
59
|
+
consentPurposes: k
|
|
60
|
+
}, v.push({
|
|
61
|
+
source: e,
|
|
62
|
+
selections: t.media,
|
|
63
|
+
media: n
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
for (let [e, t] of Object.entries(O.referenceGraph.nodes)) {
|
|
67
|
+
let n = [];
|
|
68
|
+
_[e] = {
|
|
69
|
+
content: r(t.fields.content),
|
|
70
|
+
context: O.context,
|
|
71
|
+
sourceLocale: t.output.sourceLocale,
|
|
72
|
+
fallback: t.output.fallback,
|
|
73
|
+
values: t.output.values,
|
|
74
|
+
media: n,
|
|
75
|
+
presentation: t.output.presentation,
|
|
76
|
+
consentPurposes: k
|
|
77
|
+
}, v.push({
|
|
78
|
+
source: e,
|
|
79
|
+
reference: t.selection,
|
|
80
|
+
selections: t.fields.media,
|
|
81
|
+
media: n
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
let y = [], j = [], M = /* @__PURE__ */ new Set();
|
|
86
|
+
if (v.some((e) => e.selections.length > 0)) {
|
|
87
|
+
if (A === null || w === void 0 || w.use.channel !== O.context.channel) return h("output");
|
|
88
|
+
let e = {
|
|
89
|
+
keys: C,
|
|
90
|
+
now: E,
|
|
91
|
+
maxBytes: w.maxBytes,
|
|
92
|
+
use: w.use
|
|
93
|
+
};
|
|
94
|
+
for (let t of v) {
|
|
95
|
+
if (t.selections.length === 0) continue;
|
|
96
|
+
let r = () => t.reference === void 0 ? t.source === null ? ee(u, w.custody, b, x, S, t.selections, e) : s(u, w.custody, b, x, {
|
|
97
|
+
...S,
|
|
98
|
+
binding: t.source
|
|
99
|
+
}, t.selections, e) : c(u, w.custody, b, x, {
|
|
100
|
+
...S,
|
|
101
|
+
...t.reference
|
|
102
|
+
}, t.selections, e), i = await r();
|
|
103
|
+
if (i.length !== t.selections.length) return h("output");
|
|
104
|
+
let a = i.map(({ stream: e, ...t }) => t);
|
|
105
|
+
for (let e = 0; e < i.length; e++) {
|
|
106
|
+
let r = t.selections[e], { stream: a, ...o } = i[e];
|
|
107
|
+
y.push({
|
|
108
|
+
...o,
|
|
109
|
+
source: t.source,
|
|
110
|
+
selection: r,
|
|
111
|
+
use: w.use
|
|
112
|
+
});
|
|
113
|
+
let s = `__voltro/media/${x.digest}/${g(O.route.routeId)}/${o.binaryId}`, c = {
|
|
114
|
+
path: s,
|
|
115
|
+
digest: o.checksum,
|
|
116
|
+
size: o.size,
|
|
117
|
+
contentType: o.contentType
|
|
118
|
+
};
|
|
119
|
+
M.has(s) ? await re.runPromise(d.runDrain(a)) : (await A.write(c, d.toAsyncIterable(a)), n.push(c), M.add(s)), t.media.push({
|
|
120
|
+
...r,
|
|
121
|
+
url: "/" + s,
|
|
122
|
+
contentType: o.contentType
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
j.push(async () => {
|
|
126
|
+
let e = (await r()).map(({ stream: e, ...t }) => t);
|
|
127
|
+
if (p(e) !== p(a)) return h("changed");
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
if (O.owner === "cms" && O.image !== null) {
|
|
132
|
+
let e = l.find((e) => e.output.kind === "original" && p(e.fieldPath) === p(O.image.fieldPath));
|
|
133
|
+
if (e === void 0 || i === null || ![
|
|
134
|
+
"image/png",
|
|
135
|
+
"image/jpeg",
|
|
136
|
+
"image/webp",
|
|
137
|
+
"image/avif",
|
|
138
|
+
"image/gif"
|
|
139
|
+
].includes(e.contentType)) return h("output");
|
|
140
|
+
i = {
|
|
141
|
+
...i,
|
|
142
|
+
social: {
|
|
143
|
+
...i.social,
|
|
144
|
+
image: {
|
|
145
|
+
url: new URL(e.url, O.image.origin).href,
|
|
146
|
+
contentType: e.contentType
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
let N = async () => {
|
|
152
|
+
for (let e of j) await e();
|
|
153
|
+
}, P = O.owner === "code" ? O.route.code : O.page, F = O.owner === "cms" ? {
|
|
154
|
+
version: P === null ? 2 : 6,
|
|
155
|
+
context: O.context,
|
|
156
|
+
presentation: O.presentation,
|
|
157
|
+
consentPurposes: k,
|
|
158
|
+
sourceLocale: O.route.sourceLocale,
|
|
159
|
+
fallback: O.route.fallback,
|
|
160
|
+
path: O.route.path,
|
|
161
|
+
values: O.route.values,
|
|
162
|
+
...P === null ? {} : {
|
|
163
|
+
content: r(O.content ?? h("output")),
|
|
164
|
+
seo: i,
|
|
165
|
+
media: l,
|
|
166
|
+
bindings: m
|
|
167
|
+
}
|
|
168
|
+
} : null, I = {
|
|
169
|
+
version: 4,
|
|
170
|
+
addresses: O.owner === "cms" ? O.addressGraph.map((e) => ({
|
|
171
|
+
source: e.source,
|
|
172
|
+
fieldPath: e.fieldPath,
|
|
173
|
+
path: e.target?.output.path ?? null
|
|
174
|
+
})) : [],
|
|
175
|
+
nodes: _,
|
|
176
|
+
edges: O.owner === "cms" ? O.referenceGraph.edges : []
|
|
177
|
+
}, L = P !== null && O.web !== void 0 && (O.owner === "cms" || O.publicCode), R = P === null ? F : {
|
|
178
|
+
version: O.owner === "cms" ? L ? 9 : 7 : L ? 5 : 3,
|
|
179
|
+
file: P.file,
|
|
180
|
+
path: O.route.path,
|
|
181
|
+
locale: O.context.languageTag,
|
|
182
|
+
trees: O.trees,
|
|
183
|
+
...F === null ? {
|
|
184
|
+
context: O.context,
|
|
185
|
+
presentation: O.presentation,
|
|
186
|
+
consentPurposes: k
|
|
187
|
+
} : {
|
|
188
|
+
delivery: F,
|
|
189
|
+
references: I
|
|
190
|
+
},
|
|
191
|
+
...L ? { web: {
|
|
192
|
+
...O.web,
|
|
193
|
+
renderedAt: O.capturedAt,
|
|
194
|
+
source: ie(t({
|
|
195
|
+
version: 1,
|
|
196
|
+
snapshotDigest: x.digest,
|
|
197
|
+
inputsId: O.inputsId,
|
|
198
|
+
executionId: O.executionId
|
|
199
|
+
}), g(O.presentation))
|
|
200
|
+
} } : {}
|
|
201
|
+
}, z = P === null ? "render" : O.owner === "code" ? "__voltro_renderPage" : "__voltro_renderCmsPage", B = P !== null && O.owner === "cms" ? [{
|
|
202
|
+
tag: "cms.snapshot.route",
|
|
203
|
+
inputDigest: g({ path: O.route.path }),
|
|
204
|
+
valueDigest: g(F)
|
|
205
|
+
}] : [], V = await T({
|
|
206
|
+
inputsId: O.inputsId,
|
|
207
|
+
executionId: O.executionId,
|
|
208
|
+
exportName: z,
|
|
209
|
+
inputJson: p(R)
|
|
210
|
+
}), H, U, W = null, G = null, K = null, q = null;
|
|
211
|
+
if (P !== null) {
|
|
212
|
+
if (V.value === null || typeof V.value != "object" || Array.isArray(V.value)) return h("output");
|
|
213
|
+
let e = V.value, t = O.owner === "cms" ? (L ? "document," : "") + "file,head,html,locale,observations,path,pattern,reads,version" + (L ? ",web" : "") : (L ? "document," : "") + "file,head,html,locale,path,pattern,reads," + (L ? "seo," : "") + "version" + (L ? ",web" : "");
|
|
214
|
+
if (Object.keys(e).sort().join(",") !== t || e.version !== (O.owner === "cms" ? L ? 9 : 7 : L ? 5 : 3) || e.file !== P.file || e.path !== O.route.path || e.pattern !== P.pattern || e.locale !== O.context.languageTag || typeof e.html != "string" || typeof e.head != "string") return h("output");
|
|
215
|
+
if (L) {
|
|
216
|
+
if (typeof e.document != "string" || p(e.web) !== p(O.web)) return h("output");
|
|
217
|
+
if (W = e.document, O.owner === "code") try {
|
|
218
|
+
G = o(e.seo);
|
|
219
|
+
} catch {
|
|
220
|
+
return h("output");
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
if (!Array.isArray(e.reads) || O.owner === "cms" && p(e.reads.slice(0, 1)) !== p(B)) return h("output");
|
|
224
|
+
let n;
|
|
225
|
+
try {
|
|
226
|
+
let t = ne({
|
|
227
|
+
reads: O.owner === "cms" ? e.reads.slice(1) : e.reads,
|
|
228
|
+
trees: O.trees,
|
|
229
|
+
owner: O.owner,
|
|
230
|
+
snapshotDigest: x.digest,
|
|
231
|
+
inputsId: O.inputsId,
|
|
232
|
+
executionId: O.executionId,
|
|
233
|
+
routeId: O.route.routeId,
|
|
234
|
+
path: O.route.path,
|
|
235
|
+
context: O.context
|
|
236
|
+
});
|
|
237
|
+
q = t.graph, n = t.references;
|
|
238
|
+
} catch {
|
|
239
|
+
return h("output");
|
|
240
|
+
}
|
|
241
|
+
if (O.owner === "cms") {
|
|
242
|
+
if (O.content === null) return h("output");
|
|
243
|
+
try {
|
|
244
|
+
K = te({
|
|
245
|
+
referenceReads: n,
|
|
246
|
+
references: I,
|
|
247
|
+
referenceGraph: O.referenceGraph,
|
|
248
|
+
addressGraph: O.addressGraph,
|
|
249
|
+
observations: e.observations,
|
|
250
|
+
data: F,
|
|
251
|
+
fields: O.dependencies,
|
|
252
|
+
frontend: O.definitions.value.frontend,
|
|
253
|
+
snapshotDigest: x.digest,
|
|
254
|
+
inputsId: O.inputsId,
|
|
255
|
+
executionId: O.executionId,
|
|
256
|
+
routeId: O.route.routeId,
|
|
257
|
+
content: O.content,
|
|
258
|
+
bindings: O.bindings,
|
|
259
|
+
assets: y
|
|
260
|
+
});
|
|
261
|
+
} catch {
|
|
262
|
+
return h("output");
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
B = e.reads, H = e.html, U = e.head;
|
|
266
|
+
} else {
|
|
267
|
+
if (typeof V.value != "string") return h("output");
|
|
268
|
+
H = V.value, U = "";
|
|
269
|
+
}
|
|
270
|
+
if (W !== null) {
|
|
271
|
+
let t = W.indexOf("</head>");
|
|
272
|
+
if (t < 0 || W.indexOf("</head>", t + 7) >= 0 || /<meta\b[^>]*\bname\s*=\s*["']voltro:cms-build["']/i.test(W.slice(0, t))) return h("output");
|
|
273
|
+
let n = e({
|
|
274
|
+
version: 1,
|
|
275
|
+
snapshotDigest: x.digest,
|
|
276
|
+
inputsId: O.inputsId,
|
|
277
|
+
executionId: O.executionId
|
|
278
|
+
});
|
|
279
|
+
W = W.slice(0, t) + n + W.slice(t), U += "\n" + n;
|
|
280
|
+
}
|
|
281
|
+
if (Buffer.byteLength(H) + Buffer.byteLength(U) + (W === null ? 0 : Buffer.byteLength(W)) > 4194304) return h("output");
|
|
282
|
+
let ae = a(O, z, R, V), J = await D();
|
|
283
|
+
if (J === null || p(J) !== p(O)) return h("changed");
|
|
284
|
+
await N();
|
|
285
|
+
let Y = {
|
|
286
|
+
version: L ? O.owner === "code" ? 13 : 12 : 10,
|
|
287
|
+
owner: O.owner,
|
|
288
|
+
...L ? { pageFile: P?.file ?? h("output") } : {},
|
|
289
|
+
reads: B,
|
|
290
|
+
dependencies: K,
|
|
291
|
+
queryDependencies: q,
|
|
292
|
+
web: O.web ?? null,
|
|
293
|
+
...G === null ? {} : { codeSeoDigest: g(G) },
|
|
294
|
+
presentation: O.presentation,
|
|
295
|
+
consentPurposes: k,
|
|
296
|
+
documentDigest: W === null ? null : f("sha256").update(W).digest("hex"),
|
|
297
|
+
snapshotId: x.id,
|
|
298
|
+
snapshotDigest: x.digest,
|
|
299
|
+
consumerId: S.consumerId,
|
|
300
|
+
buildId: S.buildId,
|
|
301
|
+
routeId: O.route.routeId,
|
|
302
|
+
path: O.route.path,
|
|
303
|
+
contentDigest: O.owner === "cms" ? g(O.route.values) : null,
|
|
304
|
+
inputDigest: g(R),
|
|
305
|
+
outputDigest: g({
|
|
306
|
+
html: H,
|
|
307
|
+
head: U,
|
|
308
|
+
document: W,
|
|
309
|
+
...G === null ? {} : { codeSeo: G }
|
|
310
|
+
}),
|
|
311
|
+
inputsId: O.inputsId,
|
|
312
|
+
executionId: O.executionId,
|
|
313
|
+
runnerDigest: ae.runnerDigest
|
|
314
|
+
};
|
|
315
|
+
if (A === null) return {
|
|
316
|
+
html: H,
|
|
317
|
+
head: U,
|
|
318
|
+
document: W,
|
|
319
|
+
receipt: Y
|
|
320
|
+
};
|
|
321
|
+
let X = [["body.html", H], ["head.html", U]];
|
|
322
|
+
W !== null && X.push(["document.html", W]);
|
|
323
|
+
for (let [e, t] of X) {
|
|
324
|
+
let r = Buffer.from(t), i = {
|
|
325
|
+
path: e,
|
|
326
|
+
size: r.byteLength,
|
|
327
|
+
digest: f("sha256").update(r).digest("hex"),
|
|
328
|
+
contentType: "text/html"
|
|
329
|
+
};
|
|
330
|
+
await A.write(i, (async function* () {
|
|
331
|
+
yield r;
|
|
332
|
+
})()), n.push(i);
|
|
333
|
+
}
|
|
334
|
+
let Z = await D();
|
|
335
|
+
if (Z === null || p(Z) !== p(O)) return h("changed");
|
|
336
|
+
await N();
|
|
337
|
+
let Q = {
|
|
338
|
+
receipt: Y,
|
|
339
|
+
assets: y,
|
|
340
|
+
...G === null ? {} : { codeSeo: G }
|
|
341
|
+
}, $ = await A.seal(Q), oe = g({
|
|
342
|
+
version: 1,
|
|
343
|
+
subject: Q,
|
|
344
|
+
files: n.sort((e, t) => e.path < t.path ? -1 : +(e.path > t.path))
|
|
345
|
+
});
|
|
346
|
+
if ($.id !== oe) return h("output");
|
|
347
|
+
await N();
|
|
348
|
+
let se = await D();
|
|
349
|
+
return se === null || p(se) !== p(O) ? h("changed") : {
|
|
350
|
+
html: H,
|
|
351
|
+
head: U,
|
|
352
|
+
document: W,
|
|
353
|
+
receipt: Y,
|
|
354
|
+
output: $
|
|
355
|
+
};
|
|
356
|
+
} catch (e) {
|
|
357
|
+
throw await A?.abort(), e;
|
|
358
|
+
}
|
|
359
|
+
};
|
|
360
|
+
//#endregion
|
|
361
|
+
export { m as SnapshotRenderUnavailable, _ as renderSnapshotRoute };
|