@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,152 @@
|
|
|
1
|
+
//#region src/cacheIdentity.ts
|
|
2
|
+
var e = /^(utm_[a-z]+|fbclid|gclid|dclid|msclkid|mc_[a-z]+|_ga|_gl|ref)$/i, t = (e) => {
|
|
3
|
+
let t = 2166136261;
|
|
4
|
+
for (let n of e) t ^= n.codePointAt(0) ?? 0, t = Math.imul(t, 16777619) >>> 0;
|
|
5
|
+
return t.toString(36);
|
|
6
|
+
}, n = (e) => new Map((e ?? "").split(";").map((e) => e.trim()).filter((e) => e.includes("=")).map((e) => [e.slice(0, e.indexOf("=")).trim(), e.slice(e.indexOf("=") + 1).trim()])), r = (e, t) => t.startsWith("cookie:") ? n(e.headers.cookie).get(t.slice(7)) : e.headers[t.toLowerCase()], i = (e) => {
|
|
7
|
+
if (!e.startsWith("/") || /%2f|%5c|%25|%00/i.test(e) || e.includes("\\")) return null;
|
|
8
|
+
let t;
|
|
9
|
+
try {
|
|
10
|
+
t = decodeURIComponent(e);
|
|
11
|
+
} catch {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
let n = t.split("/").slice(1);
|
|
15
|
+
return n.some((e, t) => e === "." || e === ".." || e === "" && t < n.length - 1) ? null : `/${n.map((e) => encodeURIComponent(e)).join("/")}`;
|
|
16
|
+
}, a = (e, t) => {
|
|
17
|
+
if (t === void 0 || t === "") return e.fallback;
|
|
18
|
+
if (e.values.includes(t)) return t;
|
|
19
|
+
let n = t.split(",").map((e) => e.split(";")[0].trim()).filter((e) => e !== "");
|
|
20
|
+
for (let t of n) {
|
|
21
|
+
let n = e.values.find((e) => e.toLowerCase() === t.toLowerCase());
|
|
22
|
+
if (n !== void 0) return n;
|
|
23
|
+
let r = e.values.find((e) => e.toLowerCase().split("-")[0] === t.toLowerCase().split("-")[0]);
|
|
24
|
+
if (r !== void 0) return r;
|
|
25
|
+
}
|
|
26
|
+
return e.fallback;
|
|
27
|
+
}, o = (e, t) => {
|
|
28
|
+
switch (e.type) {
|
|
29
|
+
case "string": return t.length <= (e.maxLength ?? 200) ? t : null;
|
|
30
|
+
case "int": {
|
|
31
|
+
if (!/^-?\d{1,9}$/.test(t)) return null;
|
|
32
|
+
let n = Number(t);
|
|
33
|
+
return e.min !== void 0 && n < e.min || e.max !== void 0 && n > e.max ? null : String(n);
|
|
34
|
+
}
|
|
35
|
+
case "enum": return e.values.includes(t) ? t : null;
|
|
36
|
+
}
|
|
37
|
+
}, s = (e) => [
|
|
38
|
+
e.locale,
|
|
39
|
+
e.audience,
|
|
40
|
+
e.consent
|
|
41
|
+
].reduce((e, t) => e * (t?.values.length ?? 1), 1) * (e.query ?? []).reduce((e, t) => e * (t.type === "enum" ? t.values.length + 1 : t.type === "int" && t.min !== void 0 && t.max !== void 0 ? t.max - t.min + 2 : 1), 1), c = (n, c, l) => {
|
|
42
|
+
let u = [], d = (e, t) => ({
|
|
43
|
+
cacheable: !1,
|
|
44
|
+
reason: e,
|
|
45
|
+
detail: t,
|
|
46
|
+
cacheControl: "private, no-store",
|
|
47
|
+
explain: u
|
|
48
|
+
}), f = c.method.toUpperCase();
|
|
49
|
+
if (f !== "GET" && f !== "HEAD") return d("method", `${f} is never shared-cached`);
|
|
50
|
+
if (c.headers.authorization !== void 0) return d("credential", "the request carries authorization");
|
|
51
|
+
for (let e of n.credentials ?? []) if (r(c, e) !== void 0) return d("credential", `the request carries ${e}`);
|
|
52
|
+
let p = i(c.path);
|
|
53
|
+
if (p === null) return d("path", `the path ${c.path.slice(0, 120)} has no single canonical form`);
|
|
54
|
+
let m = s(n), h = n.cardinalityBudget ?? 64;
|
|
55
|
+
if (m > h) return d("budget", `${m} variants exceed the budget of ${h}`);
|
|
56
|
+
let g = c.host.toLowerCase().replace(/:(80|443)$/, "");
|
|
57
|
+
u.push({
|
|
58
|
+
dimension: "host",
|
|
59
|
+
included: !0,
|
|
60
|
+
value: g,
|
|
61
|
+
why: "the site and domain binding"
|
|
62
|
+
}), u.push({
|
|
63
|
+
dimension: "path",
|
|
64
|
+
included: !0,
|
|
65
|
+
value: p,
|
|
66
|
+
why: "canonical encoding"
|
|
67
|
+
});
|
|
68
|
+
let _ = new Map((n.query ?? []).map((e) => [e.name, e])), v = [];
|
|
69
|
+
for (let [t, n] of new URLSearchParams(c.query)) {
|
|
70
|
+
let r = _.get(t);
|
|
71
|
+
if (r === void 0) {
|
|
72
|
+
u.push({
|
|
73
|
+
dimension: `query:${t}`,
|
|
74
|
+
included: !1,
|
|
75
|
+
value: n,
|
|
76
|
+
why: e.test(t) ? "tracking parameter" : "not declared by the route"
|
|
77
|
+
});
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
let i = o(r, n);
|
|
81
|
+
i === null || i === "" || i === String(r.default ?? "") ? u.push({
|
|
82
|
+
dimension: `query:${t}`,
|
|
83
|
+
included: !1,
|
|
84
|
+
value: n,
|
|
85
|
+
why: i === null ? "not a valid value" : "empty or the default"
|
|
86
|
+
}) : v.some(([e]) => e === t) || (v.push([t, i]), u.push({
|
|
87
|
+
dimension: `query:${t}`,
|
|
88
|
+
included: !0,
|
|
89
|
+
value: i,
|
|
90
|
+
why: `declared ${r.type}`
|
|
91
|
+
}));
|
|
92
|
+
}
|
|
93
|
+
v.sort(([e], [t]) => e.localeCompare(t));
|
|
94
|
+
let y = [], b = (e, t) => {
|
|
95
|
+
if (t === void 0) return null;
|
|
96
|
+
let n = r(c, t.from), i = a(t, n);
|
|
97
|
+
return u.push({
|
|
98
|
+
dimension: e,
|
|
99
|
+
included: !0,
|
|
100
|
+
value: i,
|
|
101
|
+
why: n === void 0 ? `not given: ${t.fallback}` : `from ${t.from}, one of ${t.values.length}`
|
|
102
|
+
}), t.from.startsWith("cookie:") ? y.includes("cookie") || y.push("cookie") : y.push(t.from), i;
|
|
103
|
+
}, x = b("locale", n.locale), S = b("audience", n.audience), C = b("consent", n.consent);
|
|
104
|
+
u.push({
|
|
105
|
+
dimension: "checkpoint",
|
|
106
|
+
included: !0,
|
|
107
|
+
value: l.checkpoint,
|
|
108
|
+
why: "the publication this answer belongs to"
|
|
109
|
+
});
|
|
110
|
+
let w = [
|
|
111
|
+
"v1",
|
|
112
|
+
g,
|
|
113
|
+
p,
|
|
114
|
+
v.map(([e, t]) => `${e}=${t}`).join("&"),
|
|
115
|
+
`locale=${x ?? ""}`,
|
|
116
|
+
`audience=${S ?? ""}`,
|
|
117
|
+
`consent=${C ?? ""}`,
|
|
118
|
+
`checkpoint=${l.checkpoint}`
|
|
119
|
+
].join("|");
|
|
120
|
+
return {
|
|
121
|
+
cacheable: !0,
|
|
122
|
+
key: w,
|
|
123
|
+
fingerprint: t(w),
|
|
124
|
+
vary: y,
|
|
125
|
+
purge: {
|
|
126
|
+
route: n.route,
|
|
127
|
+
tags: [...new Set(l.tags ?? [])].sort()
|
|
128
|
+
},
|
|
129
|
+
variants: m,
|
|
130
|
+
explain: u
|
|
131
|
+
};
|
|
132
|
+
}, l = (e) => {
|
|
133
|
+
let t = (e["cache-control"] ?? "").toLowerCase();
|
|
134
|
+
return e["set-cookie"] === void 0 && !/\b(private|no-store)\b/.test(t);
|
|
135
|
+
}, u = (e, t, n) => {
|
|
136
|
+
if (!t.cacheable) return { "cache-control": t.cacheControl };
|
|
137
|
+
let r = n.staleWhileRevalidate === void 0 ? "" : `, stale-while-revalidate=${n.staleWhileRevalidate}`, i = `public, max-age=0, s-maxage=${n.maxAge}${r}`, a = t.vary.length === 0 ? {} : { vary: t.vary.join(", ") }, o = { "x-cache-identity": t.fingerprint };
|
|
138
|
+
return e === "fastly" ? {
|
|
139
|
+
"cache-control": "public, max-age=0",
|
|
140
|
+
"surrogate-control": `max-age=${n.maxAge}${r}`,
|
|
141
|
+
"surrogate-key": t.purge.tags.join(" "),
|
|
142
|
+
...a,
|
|
143
|
+
...o
|
|
144
|
+
} : {
|
|
145
|
+
"cache-control": i,
|
|
146
|
+
"cache-tag": t.purge.tags.join(","),
|
|
147
|
+
...a,
|
|
148
|
+
...o
|
|
149
|
+
};
|
|
150
|
+
};
|
|
151
|
+
//#endregion
|
|
152
|
+
export { c as compileCacheIdentity, s as contractVariants, u as edgeHeaders, l as sharedCacheable };
|
package/dist/changes.js
ADDED
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
import { ChangeFeedUnavailable as e, SiteStateUnavailable as t } from "./errors.js";
|
|
2
|
+
import { asTyped as n } from "./effectForm.js";
|
|
3
|
+
import { lockSiteState as r } from "./siteState.js";
|
|
4
|
+
import { and as i, eq as a, generateId as o, gt as s, id as c, integer as l, isNull as u, lte as d, table as f, text as p, timestamp as m } from "@voltro/database";
|
|
5
|
+
import { tenant as h } from "@voltro/plugin-multitenancy/mixin";
|
|
6
|
+
//#region src/changes.ts
|
|
7
|
+
var g = "cms_changes", _ = "_voltro_cms_change_heads", v = "00000000000000000000", y = f(_, {
|
|
8
|
+
id: c({ prefix: "cseq" }),
|
|
9
|
+
site: p().maxLength(64),
|
|
10
|
+
environment: p().maxLength(64),
|
|
11
|
+
position: p().maxLength(20).default(v),
|
|
12
|
+
generation: p().maxLength(20).default(v),
|
|
13
|
+
releaseId: p().maxLength(64).nullable()
|
|
14
|
+
}).with(h()).unique("cms_change_heads_scope", [
|
|
15
|
+
"tenantId",
|
|
16
|
+
"site",
|
|
17
|
+
"environment"
|
|
18
|
+
]), b = (t) => {
|
|
19
|
+
if (!t.tenantId || !t.site || !t.environment) throw new e({ reason: "scope" });
|
|
20
|
+
return i(a("tenantId", t.tenantId), a("site", t.site), a("environment", t.environment));
|
|
21
|
+
}, x = (t) => {
|
|
22
|
+
if (typeof t != "string" || !/^[0-9]{20}$/.test(t)) throw new e({ reason: "migration" });
|
|
23
|
+
return t;
|
|
24
|
+
}, S = (t) => {
|
|
25
|
+
let n = (BigInt(x(t)) + 1n).toString();
|
|
26
|
+
if (n.length > 20) throw new e({ reason: "exhausted" });
|
|
27
|
+
return n.padStart(20, "0");
|
|
28
|
+
}, C = async (n, i) => {
|
|
29
|
+
let a = b(i);
|
|
30
|
+
try {
|
|
31
|
+
await r(n, i);
|
|
32
|
+
} catch (n) {
|
|
33
|
+
throw n instanceof t ? new e({ reason: n.reason === "scope" || n.reason === "state" ? "scope" : "migration" }) : n;
|
|
34
|
+
}
|
|
35
|
+
let s = {
|
|
36
|
+
table: _,
|
|
37
|
+
predicate: a,
|
|
38
|
+
lock: "update",
|
|
39
|
+
order: [],
|
|
40
|
+
take: 1,
|
|
41
|
+
skip: void 0,
|
|
42
|
+
projection: void 0
|
|
43
|
+
}, [c] = await n.query(s);
|
|
44
|
+
if (c !== void 0) return c;
|
|
45
|
+
let l = o({
|
|
46
|
+
kind: "typeid",
|
|
47
|
+
prefix: "cseq"
|
|
48
|
+
}, _);
|
|
49
|
+
if (l === null) throw Error("Change feed head requires a generated ID");
|
|
50
|
+
await n.insertIgnore(_, {
|
|
51
|
+
id: l,
|
|
52
|
+
...i,
|
|
53
|
+
position: v,
|
|
54
|
+
generation: v,
|
|
55
|
+
releaseId: null
|
|
56
|
+
}, { conflictColumns: [
|
|
57
|
+
"tenantId",
|
|
58
|
+
"site",
|
|
59
|
+
"environment"
|
|
60
|
+
] });
|
|
61
|
+
let [u] = await n.query(s);
|
|
62
|
+
if (u === void 0) throw new e({ reason: "scope" });
|
|
63
|
+
return u;
|
|
64
|
+
}, w = (e, t, n, r) => e.query({
|
|
65
|
+
...r === void 0 ? {} : { lock: r },
|
|
66
|
+
table: g,
|
|
67
|
+
predicate: i(b(t), u("position")),
|
|
68
|
+
order: [{
|
|
69
|
+
column: "id",
|
|
70
|
+
direction: "asc"
|
|
71
|
+
}],
|
|
72
|
+
take: n,
|
|
73
|
+
skip: void 0,
|
|
74
|
+
projection: ["id"]
|
|
75
|
+
}), T = async (t, n) => {
|
|
76
|
+
let r = await C(t, n), i = x(r.position), a = 0;
|
|
77
|
+
for (;;) {
|
|
78
|
+
let r = await w(t, n, 500);
|
|
79
|
+
if (r.length === 0) break;
|
|
80
|
+
if (a === 0 && i !== v) throw new e({ reason: "migration" });
|
|
81
|
+
for (let e of r) i = S(i), await t.update(g, String(e.id), { position: i }), a++;
|
|
82
|
+
}
|
|
83
|
+
return a > 0 && await t.update(_, String(r.id), { position: i }), a;
|
|
84
|
+
}, E = f(g, {
|
|
85
|
+
id: c({ prefix: "cchg" }),
|
|
86
|
+
site: p().maxLength(64),
|
|
87
|
+
environment: p().maxLength(64),
|
|
88
|
+
locale: p().maxLength(64),
|
|
89
|
+
contentType: p().maxLength(64),
|
|
90
|
+
documentId: p().maxLength(64),
|
|
91
|
+
variantId: p().maxLength(64),
|
|
92
|
+
action: p().oneOf(["published", "unpublished"]),
|
|
93
|
+
revision: l().nullable(),
|
|
94
|
+
releaseId: p().nullable(),
|
|
95
|
+
at: m(),
|
|
96
|
+
position: p().maxLength(20).nullable()
|
|
97
|
+
}).with(h()).index("cms_changes_by_position", [
|
|
98
|
+
"tenantId",
|
|
99
|
+
"site",
|
|
100
|
+
"environment",
|
|
101
|
+
"position"
|
|
102
|
+
]).index("cms_changes_by_variant_position", [
|
|
103
|
+
"tenantId",
|
|
104
|
+
"site",
|
|
105
|
+
"environment",
|
|
106
|
+
"contentType",
|
|
107
|
+
"variantId",
|
|
108
|
+
"locale",
|
|
109
|
+
"position"
|
|
110
|
+
]), D = async (t, n, r, i, a, o = {}) => {
|
|
111
|
+
let s = r.tenantId;
|
|
112
|
+
if (typeof s != "string" || s === "") throw new e({ reason: "scope" });
|
|
113
|
+
let c = {
|
|
114
|
+
tenantId: s,
|
|
115
|
+
site: i.site,
|
|
116
|
+
environment: i.environment
|
|
117
|
+
}, l = await L(t, c, null);
|
|
118
|
+
if (n.changeFeed !== !0) return;
|
|
119
|
+
if ((await w(t, c, 1)).length > 0) throw new e({ reason: "migration" });
|
|
120
|
+
let u = S(l.position);
|
|
121
|
+
await t.update(_, String(l.id), { position: u }), await t.insert(g, {
|
|
122
|
+
site: i.site,
|
|
123
|
+
environment: i.environment,
|
|
124
|
+
locale: i.locale,
|
|
125
|
+
contentType: n.name,
|
|
126
|
+
documentId: String(r.documentId),
|
|
127
|
+
variantId: String(r.id),
|
|
128
|
+
action: a,
|
|
129
|
+
revision: a === "published" && typeof r.revision == "number" ? r.revision : null,
|
|
130
|
+
releaseId: o.releaseId ?? null,
|
|
131
|
+
at: /* @__PURE__ */ new Date(),
|
|
132
|
+
position: u,
|
|
133
|
+
tenantId: s
|
|
134
|
+
});
|
|
135
|
+
}, O = (e) => e instanceof Date ? e.getTime() : typeof e == "string" ? Date.parse(e) : Number(e), k = async (t, n, r) => {
|
|
136
|
+
await C(t, r), await A(t, r);
|
|
137
|
+
let o = 0;
|
|
138
|
+
for (let c of n) {
|
|
139
|
+
if (c.changeFeed !== !0) continue;
|
|
140
|
+
let n;
|
|
141
|
+
for (;;) {
|
|
142
|
+
let l = await t.query({
|
|
143
|
+
table: `${c.name}_published`,
|
|
144
|
+
predicate: i(b(r), a("status", "archived"), ...n === void 0 ? [] : [s("id", n)]),
|
|
145
|
+
order: [{
|
|
146
|
+
column: "id",
|
|
147
|
+
direction: "asc"
|
|
148
|
+
}],
|
|
149
|
+
take: 500,
|
|
150
|
+
skip: void 0,
|
|
151
|
+
projection: void 0
|
|
152
|
+
});
|
|
153
|
+
if (l.length === 0) break;
|
|
154
|
+
for (let n of l) {
|
|
155
|
+
let s = n.locale;
|
|
156
|
+
if (typeof s != "string" || s === "") throw new e({ reason: "scope" });
|
|
157
|
+
let [l] = await t.query({
|
|
158
|
+
table: g,
|
|
159
|
+
predicate: i(b(r), a("contentType", c.name), a("variantId", String(n.id)), a("locale", s)),
|
|
160
|
+
order: [{
|
|
161
|
+
column: "position",
|
|
162
|
+
direction: "desc"
|
|
163
|
+
}],
|
|
164
|
+
take: 1,
|
|
165
|
+
skip: void 0,
|
|
166
|
+
projection: void 0
|
|
167
|
+
});
|
|
168
|
+
l !== void 0 && x(l.position), l?.action !== "unpublished" && (await D(t, c, n, {
|
|
169
|
+
site: r.site,
|
|
170
|
+
environment: r.environment,
|
|
171
|
+
locale: s
|
|
172
|
+
}, "unpublished"), o++);
|
|
173
|
+
}
|
|
174
|
+
n = String(l[l.length - 1].id);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
return o;
|
|
178
|
+
}, A = async (t, n, r) => {
|
|
179
|
+
if ((await w(t, n, 1, r)).length > 0) throw new e({ reason: "migration" });
|
|
180
|
+
}, j = async (t, n, r) => {
|
|
181
|
+
let [o] = await t.query({
|
|
182
|
+
table: g,
|
|
183
|
+
predicate: i(b(n), a("id", r)),
|
|
184
|
+
order: [],
|
|
185
|
+
take: 1,
|
|
186
|
+
skip: void 0,
|
|
187
|
+
projection: ["position"]
|
|
188
|
+
});
|
|
189
|
+
if (o === void 0) throw new e({ reason: "cursor" });
|
|
190
|
+
return x(o.position);
|
|
191
|
+
}, M = (e) => ({
|
|
192
|
+
id: String(e.id),
|
|
193
|
+
at: O(e.at),
|
|
194
|
+
locale: String(e.locale),
|
|
195
|
+
contentType: String(e.contentType),
|
|
196
|
+
documentId: String(e.documentId),
|
|
197
|
+
variantId: String(e.variantId),
|
|
198
|
+
action: e.action === "unpublished" ? "unpublished" : "published",
|
|
199
|
+
revision: typeof e.revision == "number" ? e.revision : null,
|
|
200
|
+
releaseId: typeof e.releaseId == "string" ? e.releaseId : null
|
|
201
|
+
}), N = async (e, t, n) => {
|
|
202
|
+
await A(e, t, n);
|
|
203
|
+
let [r] = await e.query({
|
|
204
|
+
...n === void 0 ? {} : { lock: n },
|
|
205
|
+
table: g,
|
|
206
|
+
predicate: b(t),
|
|
207
|
+
order: [{
|
|
208
|
+
column: "position",
|
|
209
|
+
direction: "desc"
|
|
210
|
+
}],
|
|
211
|
+
take: 1,
|
|
212
|
+
skip: void 0,
|
|
213
|
+
projection: ["id", "position"]
|
|
214
|
+
});
|
|
215
|
+
return r === void 0 ? null : (x(r.position), String(r.id));
|
|
216
|
+
}, P = (e, t) => N(e, t), F = (e, t) => N(e, t, "update"), I = (t) => {
|
|
217
|
+
let n = t.releaseId;
|
|
218
|
+
if (n !== null && (typeof n != "string" || n.length === 0)) throw new e({ reason: "migration" });
|
|
219
|
+
return n;
|
|
220
|
+
}, L = async (e, t, n) => {
|
|
221
|
+
let r = await C(e, t), i = S(r.generation);
|
|
222
|
+
return await e.update(_, String(r.id), {
|
|
223
|
+
generation: i,
|
|
224
|
+
releaseId: n
|
|
225
|
+
}), {
|
|
226
|
+
...r,
|
|
227
|
+
generation: i,
|
|
228
|
+
releaseId: n
|
|
229
|
+
};
|
|
230
|
+
}, R = async (e, t) => {
|
|
231
|
+
await L(e, t, null);
|
|
232
|
+
}, z = async (e, t) => {
|
|
233
|
+
let n = await C(e, t);
|
|
234
|
+
return {
|
|
235
|
+
generation: x(n.generation),
|
|
236
|
+
releaseId: I(n),
|
|
237
|
+
checkpoint: await F(e, t)
|
|
238
|
+
};
|
|
239
|
+
}, B = async (t, n, r) => {
|
|
240
|
+
if (r.trim().length === 0) throw new e({ reason: "scope" });
|
|
241
|
+
return {
|
|
242
|
+
generation: x((await L(t, n, r)).generation),
|
|
243
|
+
releaseId: r,
|
|
244
|
+
checkpoint: await F(t, n)
|
|
245
|
+
};
|
|
246
|
+
}, V = async (e, t, n = 50) => {
|
|
247
|
+
await A(e, t);
|
|
248
|
+
let r = await e.query({
|
|
249
|
+
table: g,
|
|
250
|
+
predicate: b(t),
|
|
251
|
+
order: [{
|
|
252
|
+
column: "position",
|
|
253
|
+
direction: "desc"
|
|
254
|
+
}],
|
|
255
|
+
take: Math.max(1, Math.min(1e3, Math.floor(n))),
|
|
256
|
+
skip: void 0,
|
|
257
|
+
projection: void 0
|
|
258
|
+
});
|
|
259
|
+
for (let e of r) x(e.position);
|
|
260
|
+
return r.map(M);
|
|
261
|
+
}, H = async (t, n, r = {}) => {
|
|
262
|
+
let o = b(n), c = Math.max(1, Math.min(1e3, Math.floor(r.limit ?? 100)));
|
|
263
|
+
await A(t, n);
|
|
264
|
+
let l = r.after === void 0 ? void 0 : await j(t, n, r.after), u = r.through === void 0 ? void 0 : await j(t, n, r.through);
|
|
265
|
+
if (l !== void 0 && u !== void 0 && l > u) throw new e({ reason: "cursor" });
|
|
266
|
+
let f = new Date((r.now ?? Date.now()) - (r.settleMs ?? 2e3)), p = await t.query({
|
|
267
|
+
table: g,
|
|
268
|
+
predicate: i(o, ...l === void 0 ? [] : [s("position", l)], ...u === void 0 ? [] : [d("position", u)], ...Object.entries(r.filter ?? {}).map(([e, t]) => a(e, t))),
|
|
269
|
+
order: [{
|
|
270
|
+
column: "position",
|
|
271
|
+
direction: "asc"
|
|
272
|
+
}],
|
|
273
|
+
take: c,
|
|
274
|
+
skip: void 0,
|
|
275
|
+
projection: void 0
|
|
276
|
+
});
|
|
277
|
+
for (let e of p) x(e.position);
|
|
278
|
+
let m = r.settleMs === 0 ? -1 : p.findIndex((e) => O(e.at) >= f.getTime()), h = (m < 0 ? p : p.slice(0, m)).map(M);
|
|
279
|
+
return {
|
|
280
|
+
items: h,
|
|
281
|
+
next: h.length > 0 ? h[h.length - 1].id : r.after ?? null
|
|
282
|
+
};
|
|
283
|
+
}, U = async (e, t, n) => {
|
|
284
|
+
let r = await e.query({
|
|
285
|
+
table: g,
|
|
286
|
+
predicate: i(a("site", n.site), a("environment", n.environment), a("locale", n.locale), a("contentType", t.contentType), a("documentId", t.documentId)),
|
|
287
|
+
order: [{
|
|
288
|
+
column: "position",
|
|
289
|
+
direction: "asc"
|
|
290
|
+
}],
|
|
291
|
+
take: void 0,
|
|
292
|
+
skip: void 0,
|
|
293
|
+
projection: void 0
|
|
294
|
+
}), o = [];
|
|
295
|
+
for (let e of r) {
|
|
296
|
+
let t = new Date(O(e.at)).toISOString(), n = o[o.length - 1];
|
|
297
|
+
n !== void 0 && n.to === null && (n.to = t), e.action === "published" && typeof e.revision == "number" && o.push({
|
|
298
|
+
revision: e.revision,
|
|
299
|
+
releaseId: typeof e.releaseId == "string" ? e.releaseId : null,
|
|
300
|
+
from: t,
|
|
301
|
+
to: null
|
|
302
|
+
});
|
|
303
|
+
}
|
|
304
|
+
return o;
|
|
305
|
+
}, W = (...t) => n(() => H(...t), e), G = (...t) => n(() => P(...t), e), K = (...t) => n(() => V(...t), e), q = (...e) => n(() => U(...e)), J = (...t) => n(() => D(...t), e), Y = (...t) => n(() => T(...t), e), X = (...t) => n(() => k(...t), e);
|
|
306
|
+
//#endregion
|
|
307
|
+
export { g as CMS_CHANGES_TABLE, _ as CMS_CHANGE_HEADS_TABLE, B as activatePublicationRelease, y as cmsChangeHeadsTable, E as cmsChangesTable, T as initializeChangeFeed, Y as initializeChangeFeedEffect, R as invalidatePublicationRelease, C as lockPublicationStream, P as readChangeCheckpoint, G as readChangeCheckpointEffect, H as readChanges, W as readChangesEffect, z as readPublicationBoundary, F as readPublicationCheckpoint, V as readRecentChanges, K as readRecentChangesEffect, k as reconcileArchivedPublications, X as reconcileArchivedPublicationsEffect, D as recordChange, J as recordChangeEffect, U as revisionTimeline, q as revisionTimelineEffect };
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
import { buildTree as e } from "./tree.js";
|
|
2
|
+
import { hadAddress as t, redirectTarget as n } from "./redirects.js";
|
|
3
|
+
import { usedBy as r } from "./references.js";
|
|
4
|
+
import { verifyPreviewToken as i } from "./preview.js";
|
|
5
|
+
import { and as a, eq as o, gt as s, gte as c, lt as l, lte as u, neq as d } from "@voltro/database";
|
|
6
|
+
//#region src/cmsContext.ts
|
|
7
|
+
var f = (e, t, n) => {
|
|
8
|
+
switch (t) {
|
|
9
|
+
case "=": return o(e, n);
|
|
10
|
+
case "!=": return d(e, n);
|
|
11
|
+
case "<": return l(e, n);
|
|
12
|
+
case "<=": return u(e, n);
|
|
13
|
+
case ">": return s(e, n);
|
|
14
|
+
case ">=": return c(e, n);
|
|
15
|
+
}
|
|
16
|
+
}, p = (e) => {
|
|
17
|
+
let t = e.excludeArchived ? [...e.predicates, d("status", "archived")] : e.predicates, n = t.length === 0 ? void 0 : t.length === 1 ? t[0] : a(...t);
|
|
18
|
+
return {
|
|
19
|
+
table: e.table,
|
|
20
|
+
predicate: n,
|
|
21
|
+
order: e.order,
|
|
22
|
+
take: e.take,
|
|
23
|
+
skip: e.skip,
|
|
24
|
+
projection: void 0
|
|
25
|
+
};
|
|
26
|
+
}, m = (e, t) => ({
|
|
27
|
+
where(n, r, i) {
|
|
28
|
+
return m(e, {
|
|
29
|
+
...t,
|
|
30
|
+
predicates: [...t.predicates, f(n, r, i)]
|
|
31
|
+
});
|
|
32
|
+
},
|
|
33
|
+
orderBy(n, r = "asc") {
|
|
34
|
+
return m(e, {
|
|
35
|
+
...t,
|
|
36
|
+
order: [...t.order, {
|
|
37
|
+
column: n,
|
|
38
|
+
direction: r
|
|
39
|
+
}]
|
|
40
|
+
});
|
|
41
|
+
},
|
|
42
|
+
limit(n) {
|
|
43
|
+
return m(e, {
|
|
44
|
+
...t,
|
|
45
|
+
take: n
|
|
46
|
+
});
|
|
47
|
+
},
|
|
48
|
+
offset(n) {
|
|
49
|
+
return m(e, {
|
|
50
|
+
...t,
|
|
51
|
+
skip: n
|
|
52
|
+
});
|
|
53
|
+
},
|
|
54
|
+
async all() {
|
|
55
|
+
return e.query(p(t));
|
|
56
|
+
},
|
|
57
|
+
async one() {
|
|
58
|
+
return (await e.query(p({
|
|
59
|
+
...t,
|
|
60
|
+
take: 1
|
|
61
|
+
})))[0] ?? null;
|
|
62
|
+
},
|
|
63
|
+
async page(n, r) {
|
|
64
|
+
let i = Math.max(1, Math.floor(n)), a = r === void 0 ? t.predicates : [...t.predicates, s("id", r)], o = await e.query(p({
|
|
65
|
+
...t,
|
|
66
|
+
predicates: a,
|
|
67
|
+
order: [{
|
|
68
|
+
column: "id",
|
|
69
|
+
direction: "asc"
|
|
70
|
+
}],
|
|
71
|
+
take: i + 1,
|
|
72
|
+
skip: void 0
|
|
73
|
+
})), c = o.slice(0, i);
|
|
74
|
+
return {
|
|
75
|
+
items: c,
|
|
76
|
+
next: o.length > i ? String(c[c.length - 1]?.id) : null
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
}), h = (s, c, l, u) => {
|
|
80
|
+
let f = [
|
|
81
|
+
o("site", l.site),
|
|
82
|
+
o("environment", l.environment),
|
|
83
|
+
o("locale", l.locale)
|
|
84
|
+
], p = new Map(c.map((e) => [e.name, e])), h = (e) => {
|
|
85
|
+
let t = p.get(e);
|
|
86
|
+
if (!t) throw Error(`cms.contentType('${e}'): unknown content type. Register it via defineContentType and pass it to cmsContext / createCmsClient.`);
|
|
87
|
+
return t;
|
|
88
|
+
}, g = async (e, t, n) => (await s.query({
|
|
89
|
+
table: `${e}_published`,
|
|
90
|
+
predicate: a(o("site", l.site), o("environment", l.environment), o("locale", t), d("status", "archived"), ...Object.entries(n).map(([e, t]) => o(e, t))),
|
|
91
|
+
order: [],
|
|
92
|
+
take: 1,
|
|
93
|
+
skip: void 0,
|
|
94
|
+
projection: void 0
|
|
95
|
+
}))[0] ?? null, _ = (e, t, n) => s.query({
|
|
96
|
+
table: `${e}_published`,
|
|
97
|
+
predicate: a(o("site", l.site), o("environment", l.environment), o("locale", t), d("status", "archived"), ...Object.entries(n).map(([e, t]) => o(e, t))),
|
|
98
|
+
order: [],
|
|
99
|
+
take: void 0,
|
|
100
|
+
skip: void 0,
|
|
101
|
+
projection: void 0
|
|
102
|
+
}), v = async (t, n, r) => {
|
|
103
|
+
let i = h(t).tree;
|
|
104
|
+
if (i === void 0) throw Error(`cms.tree('${t}'): the content type declares no tree. Add tree: { parent, segment } to it.`);
|
|
105
|
+
let a = [];
|
|
106
|
+
for (let e of /* @__PURE__ */ new Set([n, ...r.fallback ?? []])) for (let i of await _(t, e, r.filter ?? {})) a.push({
|
|
107
|
+
row: i,
|
|
108
|
+
locale: e,
|
|
109
|
+
fallback: e !== n
|
|
110
|
+
});
|
|
111
|
+
return e(a, i);
|
|
112
|
+
}, y = {
|
|
113
|
+
async usedBy(e, t) {
|
|
114
|
+
return h(e), r(s, {
|
|
115
|
+
type: e,
|
|
116
|
+
documentId: t
|
|
117
|
+
}, l);
|
|
118
|
+
},
|
|
119
|
+
async tree(e, t = {}) {
|
|
120
|
+
return v(e, l.locale, t);
|
|
121
|
+
},
|
|
122
|
+
async route(e, t, r = {}) {
|
|
123
|
+
let i = await v(e, l.locale, r), a = i.nodes.find((e) => e.path === t);
|
|
124
|
+
if (a !== void 0) return {
|
|
125
|
+
node: a,
|
|
126
|
+
tree: i,
|
|
127
|
+
via: "path"
|
|
128
|
+
};
|
|
129
|
+
for (let n of r.fallback ?? []) {
|
|
130
|
+
if (n === l.locale) continue;
|
|
131
|
+
let a = (await v(e, n, {
|
|
132
|
+
...r,
|
|
133
|
+
fallback: []
|
|
134
|
+
})).nodes.find((e) => e.path === t);
|
|
135
|
+
if (a === void 0) continue;
|
|
136
|
+
let o = i.nodes.find((e) => e.documentId === a.documentId);
|
|
137
|
+
return o === void 0 ? null : {
|
|
138
|
+
node: o,
|
|
139
|
+
tree: i,
|
|
140
|
+
via: "fallback"
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
let o = r.filter?.tenantId;
|
|
144
|
+
for (let a of /* @__PURE__ */ new Set([l.locale, ...r.fallback ?? []])) {
|
|
145
|
+
let r = await n(s, e, t, {
|
|
146
|
+
...l,
|
|
147
|
+
locale: a
|
|
148
|
+
}, o), c = r === null ? void 0 : i.nodes.find((e) => e.documentId === r);
|
|
149
|
+
if (c !== void 0) return {
|
|
150
|
+
node: c,
|
|
151
|
+
tree: i,
|
|
152
|
+
via: "redirect"
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
return null;
|
|
156
|
+
},
|
|
157
|
+
async gone(e, n, r = {}) {
|
|
158
|
+
if (await y.route(e, n, r) !== null) return !1;
|
|
159
|
+
let i = r.filter?.tenantId;
|
|
160
|
+
for (let a of /* @__PURE__ */ new Set([l.locale, ...r.fallback ?? []])) if (await t(s, e, n, {
|
|
161
|
+
...l,
|
|
162
|
+
locale: a
|
|
163
|
+
}, i)) return !0;
|
|
164
|
+
return !1;
|
|
165
|
+
},
|
|
166
|
+
async resolve(e, t) {
|
|
167
|
+
h(e);
|
|
168
|
+
let n = t.filter ?? {}, r = {
|
|
169
|
+
...n,
|
|
170
|
+
[t.key.field]: t.key.value
|
|
171
|
+
}, i = l.locale, a = await g(e, i, r);
|
|
172
|
+
if (a !== null) return {
|
|
173
|
+
row: a,
|
|
174
|
+
locale: i,
|
|
175
|
+
requestedLocale: i,
|
|
176
|
+
fallback: !1
|
|
177
|
+
};
|
|
178
|
+
for (let a of t.fallback ?? []) {
|
|
179
|
+
if (a === i) continue;
|
|
180
|
+
let t = await g(e, a, r);
|
|
181
|
+
if (t === null) continue;
|
|
182
|
+
let o = await g(e, i, {
|
|
183
|
+
...n,
|
|
184
|
+
documentId: t.documentId
|
|
185
|
+
});
|
|
186
|
+
return o === null ? {
|
|
187
|
+
row: t,
|
|
188
|
+
locale: a,
|
|
189
|
+
requestedLocale: i,
|
|
190
|
+
fallback: !0
|
|
191
|
+
} : {
|
|
192
|
+
row: o,
|
|
193
|
+
locale: i,
|
|
194
|
+
requestedLocale: i,
|
|
195
|
+
fallback: !1
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
return null;
|
|
199
|
+
},
|
|
200
|
+
contentType(e) {
|
|
201
|
+
return h(e), m(s, {
|
|
202
|
+
table: `${e}_published`,
|
|
203
|
+
predicates: f,
|
|
204
|
+
order: [],
|
|
205
|
+
take: void 0,
|
|
206
|
+
skip: void 0,
|
|
207
|
+
excludeArchived: !0
|
|
208
|
+
});
|
|
209
|
+
},
|
|
210
|
+
async preview(e, t, n) {
|
|
211
|
+
h(e);
|
|
212
|
+
let r = n ? i(n, u ? { secret: u } : {}) : null, c = r !== null && r.type === e && r.id === t ? `${e}_drafts` : `${e}_published`;
|
|
213
|
+
return (await s.query({
|
|
214
|
+
table: c,
|
|
215
|
+
predicate: a(o("id", t), ...f),
|
|
216
|
+
order: [],
|
|
217
|
+
take: 1,
|
|
218
|
+
skip: void 0,
|
|
219
|
+
projection: void 0
|
|
220
|
+
}))[0] ?? null;
|
|
221
|
+
}
|
|
222
|
+
};
|
|
223
|
+
return y;
|
|
224
|
+
}, g = (e, t, n) => h(e, t, n.scope, n.secret), _ = (e) => h(e.store, e.types, e.scope, e.secret), v = (e) => {
|
|
225
|
+
if (e.cms === void 0) throw Error("useCms: `ctx.cms` is not set. Build it with cmsContext(store, types, { scope }) and attach it to your AppContext (or use createCmsClient at build time).");
|
|
226
|
+
return e.cms;
|
|
227
|
+
};
|
|
228
|
+
//#endregion
|
|
229
|
+
export { g as cmsContext, _ as createCmsClient, v as useCms };
|