@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,28 @@
|
|
|
1
|
+
import { PublicRouteRegistryUnavailable as e } from "./publicRouteRegistry.js";
|
|
2
|
+
import { ChangeFeedUnavailable as t, SiteStateUnavailable as n } from "./errors.js";
|
|
3
|
+
import { asTyped as r } from "./effectForm.js";
|
|
4
|
+
import { compilePublicRouteRegistryDefinition as i, compilePublicRouteRouting as a } from "./publicRouteRegistryDefinition.js";
|
|
5
|
+
import { bindInitialPublicRouteDefinition as o } from "./publicRouteRegistryBinding.js";
|
|
6
|
+
//#region src/initializePublicRoutes.ts
|
|
7
|
+
var s = (t) => {
|
|
8
|
+
try {
|
|
9
|
+
return i({
|
|
10
|
+
types: t.types,
|
|
11
|
+
site: t.site,
|
|
12
|
+
app: t.code,
|
|
13
|
+
routing: a(t.routing, t.routeDiscovery, t.code)
|
|
14
|
+
});
|
|
15
|
+
} catch (t) {
|
|
16
|
+
throw t instanceof e ? t : new e({ reason: "definition" });
|
|
17
|
+
}
|
|
18
|
+
}, c = (i, a, c, l = {}) => r(async () => {
|
|
19
|
+
if (i.savepoint === void 0) throw new e({ reason: "configuration" });
|
|
20
|
+
let t = s(c);
|
|
21
|
+
return { revision: (await i.savepoint(() => o(i, a, {
|
|
22
|
+
expectedRevision: 0,
|
|
23
|
+
definition: t,
|
|
24
|
+
now: l.now ?? Date.now()
|
|
25
|
+
}))).revision };
|
|
26
|
+
}, e, t, n);
|
|
27
|
+
//#endregion
|
|
28
|
+
export { s as compileCmsPublicRouteDeclaration, c as initializeCmsPublicRoutes };
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { publicRouteRegistryFail as e } from "./publicRouteRegistry.js";
|
|
2
|
+
import { compileSiteDelivery as t } from "./siteDelivery.js";
|
|
3
|
+
import { queryPublicRouteIntegrity as n } from "./publicRouteIntegrity.js";
|
|
4
|
+
import { copyOutputActivationScope as r } from "./outputActivation.js";
|
|
5
|
+
import { readContentModificationTime as i } from "./contentValues.js";
|
|
6
|
+
import { readPublicRouteBinding as a } from "./publicRouteRegistryBinding.js";
|
|
7
|
+
import { and as o, eq as s, gt as c } from "@voltro/database";
|
|
8
|
+
//#region src/liveContentRouteView.ts
|
|
9
|
+
var l = (e) => typeof e == "string" && e.length > 0, u = async (u, d) => {
|
|
10
|
+
let f;
|
|
11
|
+
try {
|
|
12
|
+
f = r(d);
|
|
13
|
+
} catch {
|
|
14
|
+
return e("scope");
|
|
15
|
+
}
|
|
16
|
+
let p = await a(u, f);
|
|
17
|
+
if (p === null) return e("configuration");
|
|
18
|
+
let m = t(p.definition.site), h = new Set(p.definition.types.map((e) => e.name)), g = new Set(m.contentLocales), _ = (t, n) => !h.has(t) || !g.has(n) ? e("scope") : o(s("tenantId", f.tenantId), s("site", f.site), s("environment", f.environment), s("locale", n), s("status", "published")), v = (t, n) => {
|
|
19
|
+
if (![
|
|
20
|
+
t.id,
|
|
21
|
+
t.documentId,
|
|
22
|
+
t.revisionId
|
|
23
|
+
].every(l) || !Number.isSafeInteger(t.revision) || Number(t.revision) < 1 || t.tenantId !== f.tenantId || t.site !== f.site || t.environment !== f.environment || t.locale !== n || t.status !== "published") return e("state");
|
|
24
|
+
let r = i(t.updatedAt);
|
|
25
|
+
return r.ok ? {
|
|
26
|
+
content: t,
|
|
27
|
+
modifiedAt: r.value
|
|
28
|
+
} : e("state");
|
|
29
|
+
};
|
|
30
|
+
return {
|
|
31
|
+
binding: p,
|
|
32
|
+
site: m,
|
|
33
|
+
view: {
|
|
34
|
+
read: async (t, r, i) => {
|
|
35
|
+
if (!l(i)) return e("state");
|
|
36
|
+
let a = await n(u, {
|
|
37
|
+
table: t + "_published",
|
|
38
|
+
predicate: o(_(t, r), s("documentId", i)),
|
|
39
|
+
lock: "update",
|
|
40
|
+
order: [],
|
|
41
|
+
take: 2,
|
|
42
|
+
skip: void 0,
|
|
43
|
+
projection: void 0
|
|
44
|
+
});
|
|
45
|
+
if (a.length > 1) return e("state");
|
|
46
|
+
let c = a[0];
|
|
47
|
+
return c === void 0 ? null : c.documentId === i ? v(c, r) : e("state");
|
|
48
|
+
},
|
|
49
|
+
page: async (t, r, i) => {
|
|
50
|
+
if (i !== void 0 && (!l(i) || i.length > 256)) return e("bounds");
|
|
51
|
+
let a = await n(u, {
|
|
52
|
+
table: t + "_published",
|
|
53
|
+
predicate: o(_(t, r), ...i === void 0 ? [] : [c("id", i)]),
|
|
54
|
+
lock: "update",
|
|
55
|
+
order: [{
|
|
56
|
+
column: "id",
|
|
57
|
+
direction: "asc"
|
|
58
|
+
}],
|
|
59
|
+
take: 201,
|
|
60
|
+
skip: void 0,
|
|
61
|
+
projection: void 0
|
|
62
|
+
}), s = i ?? "";
|
|
63
|
+
for (let t of a) {
|
|
64
|
+
if (v(t, r), String(t.id) <= s) return e("state");
|
|
65
|
+
s = String(t.id);
|
|
66
|
+
}
|
|
67
|
+
return {
|
|
68
|
+
items: a.slice(0, 200),
|
|
69
|
+
next: a.length > 200 ? String(a[199].id) : null
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
//#endregion
|
|
76
|
+
export { u as readLiveContentRouteView };
|
package/dist/media.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { asTyped as e } from "./effectForm.js";
|
|
2
|
+
//#region src/media.ts
|
|
3
|
+
var t = (e) => Object.entries(e.fields).filter(([, e]) => e.kind === "media").map(([e]) => e), n = async (e, t, r) => {
|
|
4
|
+
if (t == null) return t;
|
|
5
|
+
switch (e.kind) {
|
|
6
|
+
case "media": return typeof t == "string" ? await r(t) ?? t : t;
|
|
7
|
+
case "array": {
|
|
8
|
+
let i = e.element;
|
|
9
|
+
return i === void 0 || !Array.isArray(t) ? t : Promise.all(t.map((e) => n(i, e, r)));
|
|
10
|
+
}
|
|
11
|
+
case "struct": {
|
|
12
|
+
let i = e.struct;
|
|
13
|
+
if (i === void 0 || typeof t != "object" || Array.isArray(t)) return t;
|
|
14
|
+
let a = t, o = { ...a };
|
|
15
|
+
for (let [e, t] of Object.entries(i)) e in a && (o[e] = await n(t, a[e], r));
|
|
16
|
+
return o;
|
|
17
|
+
}
|
|
18
|
+
default: return t;
|
|
19
|
+
}
|
|
20
|
+
}, r = async (e, t, r) => {
|
|
21
|
+
let i = { ...t };
|
|
22
|
+
for (let [a, o] of Object.entries(e.fields)) {
|
|
23
|
+
let e = o;
|
|
24
|
+
(e.kind === "media" || e.kind === "array" || e.kind === "struct") && a in t && (i[a] = await n(e, t[a], r));
|
|
25
|
+
}
|
|
26
|
+
return i;
|
|
27
|
+
}, i = async (e, t, n) => Promise.all(t.map((t) => r(e, t, n))), a = (e) => t(e), o = (...t) => e(() => r(...t)), s = (...t) => e(() => i(...t));
|
|
28
|
+
//#endregion
|
|
29
|
+
export { a as mediaFields, r as resolveMedia, i as resolveMediaAll, s as resolveMediaAllEffect, o as resolveMediaEffect };
|
package/dist/metrics.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { fnv1a as e } from "./fieldSchema.js";
|
|
2
|
+
//#region src/metrics.ts
|
|
3
|
+
var t = (e) => JSON.stringify([
|
|
4
|
+
e.id,
|
|
5
|
+
e.formula,
|
|
6
|
+
e.unit,
|
|
7
|
+
[...e.scope].sort(),
|
|
8
|
+
e.freshness,
|
|
9
|
+
[...e.quality].sort(),
|
|
10
|
+
[...e.drill].sort()
|
|
11
|
+
]), n = (n) => {
|
|
12
|
+
if (!Number.isInteger(n.version) || n.version < 1) throw Error(`metric '${n.id}': version must be a positive integer`);
|
|
13
|
+
return {
|
|
14
|
+
...n,
|
|
15
|
+
fingerprint: e(t(n))
|
|
16
|
+
};
|
|
17
|
+
}, r = (e, t) => {
|
|
18
|
+
let n = new Map(t.map((e) => [e.id, e]));
|
|
19
|
+
return e.filter((e) => {
|
|
20
|
+
let t = n.get(e.id);
|
|
21
|
+
return t !== void 0 && t.version === e.version && t.fingerprint !== e.fingerprint;
|
|
22
|
+
}).map((e) => e.id);
|
|
23
|
+
}, i = (e, t) => {
|
|
24
|
+
let n = /* @__PURE__ */ new Map(), r = 0;
|
|
25
|
+
for (let { day: i, value: a } of t) {
|
|
26
|
+
let t = Date.parse(`${i}T23:59:59.999Z`), o = e.find((e) => Date.parse(e.from) <= t && (e.to === null || Date.parse(e.to) > t));
|
|
27
|
+
if (o === void 0) {
|
|
28
|
+
r += a;
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
let s = n.get(o) ?? {
|
|
32
|
+
value: 0,
|
|
33
|
+
days: 0
|
|
34
|
+
};
|
|
35
|
+
s.value += a, s.days += 1, n.set(o, s);
|
|
36
|
+
}
|
|
37
|
+
return {
|
|
38
|
+
shares: [...n.entries()].map(([e, t]) => ({
|
|
39
|
+
...e,
|
|
40
|
+
...t
|
|
41
|
+
})).sort((e, t) => Date.parse(e.from) - Date.parse(t.from)),
|
|
42
|
+
unattributed: r
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
//#endregion
|
|
46
|
+
export { i as attributeToRevisions, n as defineMetric, r as metricVersionDrift };
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import { asTyped as e } from "./effectForm.js";
|
|
2
|
+
import { MIGRATION_STAGES as t } from "./migrationStages.js";
|
|
3
|
+
import { and as n, eq as r, id as i, table as a, text as o, timestamp as s } from "@voltro/database";
|
|
4
|
+
import { tenant as c } from "@voltro/plugin-multitenancy/mixin";
|
|
5
|
+
//#region src/migration.ts
|
|
6
|
+
var l = "cms_migration_stages", u = "cms_migration_records", d = a(l, {
|
|
7
|
+
id: i({ prefix: "cmst" }),
|
|
8
|
+
source: o().maxLength(200),
|
|
9
|
+
stage: o().oneOf([...t]),
|
|
10
|
+
ownerId: o().nullable(),
|
|
11
|
+
status: o().oneOf(["open", "passed"]),
|
|
12
|
+
note: o().nullable(),
|
|
13
|
+
evidenceUri: o().nullable(),
|
|
14
|
+
passedBy: o().nullable(),
|
|
15
|
+
passedAt: s().nullable()
|
|
16
|
+
}).with(c()).unique("cms_migration_stages_once", [
|
|
17
|
+
"tenantId",
|
|
18
|
+
"source",
|
|
19
|
+
"stage"
|
|
20
|
+
]), f = a(u, {
|
|
21
|
+
id: i({ prefix: "cmrc" }),
|
|
22
|
+
source: o().maxLength(200),
|
|
23
|
+
sourceKey: o().maxLength(200),
|
|
24
|
+
sourceType: o().maxLength(64),
|
|
25
|
+
result: o().oneOf([
|
|
26
|
+
"created",
|
|
27
|
+
"already",
|
|
28
|
+
"skipped",
|
|
29
|
+
"failed"
|
|
30
|
+
]),
|
|
31
|
+
targetType: o().maxLength(64).nullable(),
|
|
32
|
+
targetDocumentId: o().maxLength(64).nullable(),
|
|
33
|
+
transformation: o().nullable(),
|
|
34
|
+
conflict: o().nullable(),
|
|
35
|
+
loss: o().nullable(),
|
|
36
|
+
recordedAt: s()
|
|
37
|
+
}).with(c()).unique("cms_migration_records_once", [
|
|
38
|
+
"tenantId",
|
|
39
|
+
"source",
|
|
40
|
+
"sourceKey"
|
|
41
|
+
]), p = (e, t) => ({
|
|
42
|
+
stage: e,
|
|
43
|
+
ownerId: typeof t?.ownerId == "string" ? t.ownerId : null,
|
|
44
|
+
status: t?.status === "passed" ? "passed" : "open",
|
|
45
|
+
note: typeof t?.note == "string" ? t.note : null,
|
|
46
|
+
evidenceUri: typeof t?.evidenceUri == "string" ? t.evidenceUri : null,
|
|
47
|
+
passedBy: typeof t?.passedBy == "string" ? t.passedBy : null,
|
|
48
|
+
passedAt: t?.passedAt instanceof Date ? t.passedAt : t?.passedAt ? new Date(String(t.passedAt)) : null
|
|
49
|
+
}), m = async (e, n) => {
|
|
50
|
+
let i = await e.query({
|
|
51
|
+
table: l,
|
|
52
|
+
predicate: r("source", n),
|
|
53
|
+
order: [],
|
|
54
|
+
take: void 0,
|
|
55
|
+
skip: void 0,
|
|
56
|
+
projection: void 0
|
|
57
|
+
});
|
|
58
|
+
return t.map((e) => p(e, i.find((t) => t.stage === e)));
|
|
59
|
+
}, h = async (e, t, i) => (await e.query({
|
|
60
|
+
table: l,
|
|
61
|
+
predicate: n(r("source", t), r("stage", i)),
|
|
62
|
+
order: [],
|
|
63
|
+
take: 1,
|
|
64
|
+
skip: void 0,
|
|
65
|
+
projection: void 0
|
|
66
|
+
}))[0], g = async (e, t, n, r, i) => {
|
|
67
|
+
let a = await h(e, t, n);
|
|
68
|
+
return a?.status === "passed" ? {
|
|
69
|
+
ok: !1,
|
|
70
|
+
reason: "passed"
|
|
71
|
+
} : (a === void 0 ? await e.insert(l, {
|
|
72
|
+
source: t,
|
|
73
|
+
stage: n,
|
|
74
|
+
ownerId: r,
|
|
75
|
+
status: "open",
|
|
76
|
+
note: null,
|
|
77
|
+
evidenceUri: null,
|
|
78
|
+
passedBy: null,
|
|
79
|
+
passedAt: null,
|
|
80
|
+
...i === null ? {} : { tenantId: i }
|
|
81
|
+
}) : await e.update(l, String(a.id), { ownerId: r }), { ok: !0 });
|
|
82
|
+
}, _ = async (e, n, r, i, a = /* @__PURE__ */ new Date()) => {
|
|
83
|
+
let o = await m(e, n), s = o.find((e) => e.stage === r);
|
|
84
|
+
if (s.status === "passed") return {
|
|
85
|
+
ok: !1,
|
|
86
|
+
reason: "passed"
|
|
87
|
+
};
|
|
88
|
+
if (s.ownerId === null) return {
|
|
89
|
+
ok: !1,
|
|
90
|
+
reason: "noOwner"
|
|
91
|
+
};
|
|
92
|
+
if (s.ownerId !== i.actorId) return {
|
|
93
|
+
ok: !1,
|
|
94
|
+
reason: "notOwner"
|
|
95
|
+
};
|
|
96
|
+
let c = i.note.trim();
|
|
97
|
+
if (c === "" || c.length > 1e3) return {
|
|
98
|
+
ok: !1,
|
|
99
|
+
reason: "noNote"
|
|
100
|
+
};
|
|
101
|
+
let u = o.slice(0, t.indexOf(r)).find((e) => e.status !== "passed");
|
|
102
|
+
if (u !== void 0) return {
|
|
103
|
+
ok: !1,
|
|
104
|
+
reason: "earlierOpen",
|
|
105
|
+
stage: u.stage
|
|
106
|
+
};
|
|
107
|
+
if (i.gate === !1) return {
|
|
108
|
+
ok: !1,
|
|
109
|
+
reason: "gateNotMet"
|
|
110
|
+
};
|
|
111
|
+
let d = await h(e, n, r);
|
|
112
|
+
return await e.update(l, String(d.id), {
|
|
113
|
+
status: "passed",
|
|
114
|
+
note: c,
|
|
115
|
+
evidenceUri: i.evidenceUri?.trim() ? i.evidenceUri.trim().slice(0, 500) : null,
|
|
116
|
+
passedBy: i.actorId,
|
|
117
|
+
passedAt: a
|
|
118
|
+
}), { ok: !0 };
|
|
119
|
+
}, v = async (e, n, r) => {
|
|
120
|
+
let i = t.slice(t.indexOf(r)), a = 0;
|
|
121
|
+
for (let t of i) {
|
|
122
|
+
let r = await h(e, n, t);
|
|
123
|
+
r?.status === "passed" && (await e.update(l, String(r.id), {
|
|
124
|
+
status: "open",
|
|
125
|
+
passedBy: null,
|
|
126
|
+
passedAt: null
|
|
127
|
+
}), a++);
|
|
128
|
+
}
|
|
129
|
+
return a;
|
|
130
|
+
}, y = async (e, t, i, a, o = /* @__PURE__ */ new Date()) => {
|
|
131
|
+
for (let s of i) {
|
|
132
|
+
let i = {
|
|
133
|
+
sourceType: s.sourceType,
|
|
134
|
+
result: s.result,
|
|
135
|
+
targetType: s.targetType ?? null,
|
|
136
|
+
targetDocumentId: s.targetDocumentId ?? null,
|
|
137
|
+
transformation: s.transformation ?? null,
|
|
138
|
+
conflict: s.conflict ?? null,
|
|
139
|
+
loss: s.loss ?? null,
|
|
140
|
+
recordedAt: o
|
|
141
|
+
}, [c] = await e.query({
|
|
142
|
+
table: u,
|
|
143
|
+
predicate: n(r("source", t), r("sourceKey", s.sourceKey)),
|
|
144
|
+
order: [],
|
|
145
|
+
take: 1,
|
|
146
|
+
skip: void 0,
|
|
147
|
+
projection: void 0
|
|
148
|
+
});
|
|
149
|
+
c === void 0 ? await e.insert(u, {
|
|
150
|
+
source: t,
|
|
151
|
+
sourceKey: s.sourceKey,
|
|
152
|
+
...i,
|
|
153
|
+
...a === null ? {} : { tenantId: a }
|
|
154
|
+
}) : await e.update(u, String(c.id), c.result === "created" && s.result === "already" ? { recordedAt: o } : i);
|
|
155
|
+
}
|
|
156
|
+
}, b = async (e, t, n = 200) => {
|
|
157
|
+
let i = await e.query({
|
|
158
|
+
table: u,
|
|
159
|
+
predicate: r("source", t),
|
|
160
|
+
order: [{
|
|
161
|
+
column: "sourceKey",
|
|
162
|
+
direction: "asc"
|
|
163
|
+
}],
|
|
164
|
+
take: void 0,
|
|
165
|
+
skip: void 0,
|
|
166
|
+
projection: void 0
|
|
167
|
+
}), a = (e) => typeof e == "string" && e !== "" ? e : null, o = i.map((e) => ({
|
|
168
|
+
sourceKey: String(e.sourceKey),
|
|
169
|
+
sourceType: String(e.sourceType),
|
|
170
|
+
result: String(e.result),
|
|
171
|
+
targetType: a(e.targetType),
|
|
172
|
+
targetDocumentId: a(e.targetDocumentId),
|
|
173
|
+
transformation: a(e.transformation),
|
|
174
|
+
conflict: a(e.conflict),
|
|
175
|
+
loss: a(e.loss),
|
|
176
|
+
recordedAt: e.recordedAt instanceof Date ? e.recordedAt : new Date(String(e.recordedAt))
|
|
177
|
+
})), s = {
|
|
178
|
+
created: 0,
|
|
179
|
+
already: 0,
|
|
180
|
+
skipped: 0,
|
|
181
|
+
failed: 0
|
|
182
|
+
};
|
|
183
|
+
for (let e of o) s[e.result]++;
|
|
184
|
+
let c = (e) => Number(e.conflict !== null || e.loss !== null);
|
|
185
|
+
return {
|
|
186
|
+
counts: s,
|
|
187
|
+
withConflict: o.filter((e) => e.conflict !== null).length,
|
|
188
|
+
withLoss: o.filter((e) => e.loss !== null).length,
|
|
189
|
+
records: [...o].sort((e, t) => c(t) - c(e)).slice(0, n)
|
|
190
|
+
};
|
|
191
|
+
}, x = (...t) => e(() => m(...t)), S = (...t) => e(() => g(...t)), C = (...t) => e(() => _(...t)), w = (...t) => e(() => v(...t)), T = (...t) => e(() => y(...t)), E = (...t) => e(() => b(...t));
|
|
192
|
+
//#endregion
|
|
193
|
+
export { u as CMS_MIGRATION_RECORDS_TABLE, l as CMS_MIGRATION_STAGES_TABLE, t as MIGRATION_STAGES, f as cmsMigrationRecordsTable, d as cmsMigrationStagesTable, b as migrationLedger, E as migrationLedgerEffect, m as migrationStages, x as migrationStagesEffect, _ as passStage, C as passStageEffect, y as recordMigrationRecords, T as recordMigrationRecordsEffect, v as reopenStage, w as reopenStageEffect, g as setStageOwner, S as setStageOwnerEffect };
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import { copyOutputActivationScope as e, createOutputActivationSet as t, outputActivationHash as n } from "./outputActivation.js";
|
|
2
|
+
import { verifyBuildSnapshot as r } from "./buildSnapshot.js";
|
|
3
|
+
import { readSnapshotAppExecution as i } from "./snapshotAppExecution.js";
|
|
4
|
+
import { readStaticPathSetEvidence as a } from "./staticPathSetStore.js";
|
|
5
|
+
import { makeOutputActivationAdmission as o } from "./outputDeployment.js";
|
|
6
|
+
import { CmsOutputDeploymentUnavailable as s, createCmsOutputDeploymentAuthority as c, createCmsOutputDeployments as l } from "./outputDeploymentService.js";
|
|
7
|
+
import { OUTPUT_ACTIVATION_TARGETS as u } from "./outputActivationTargetTable.js";
|
|
8
|
+
import { readOutputActivationTarget as d, retainOutputActivationTarget as f } from "./outputActivationTarget.js";
|
|
9
|
+
import { and as p, eq as m } from "@voltro/database";
|
|
10
|
+
import { canonicalJson as h } from "@voltro/protocol";
|
|
11
|
+
//#region src/nativeOutputDeploymentService.ts
|
|
12
|
+
var g = (e) => {
|
|
13
|
+
throw new s({ reason: e });
|
|
14
|
+
}, _ = (e, t) => h(e) === h(t), v = (e) => typeof e?.id != "string" || !/^[A-Za-z0-9_-]{1,64}$/.test(e.id) || !(e.material instanceof Uint8Array) || e.material.byteLength < 32 ? g("configuration") : {
|
|
15
|
+
id: e.id,
|
|
16
|
+
material: new Uint8Array(e.material)
|
|
17
|
+
}, y = (s) => {
|
|
18
|
+
let h = s.store, y = e(s.scope), b = s.now ?? Date.now, x = s.pathKeys.map(v), S = v(s.key), C = Object.keys(s.regions).sort(), w = s.quorum;
|
|
19
|
+
if (x.length < 1 || x.length > 64 || new Set(x.map((e) => e.id)).size !== x.length || C.length < 1 || C.length > 64 || !Number.isSafeInteger(w) || w < 1 || w > C.length) return g("configuration");
|
|
20
|
+
let T = Object.fromEntries(C.map((e) => {
|
|
21
|
+
let t = s.regions[e];
|
|
22
|
+
return !/^[A-Za-z0-9_-]{1,64}$/.test(e) || [
|
|
23
|
+
"stage",
|
|
24
|
+
"verify",
|
|
25
|
+
"readArtifacts",
|
|
26
|
+
"readRoutes"
|
|
27
|
+
].some((e) => typeof t[e] != "function") ? g("configuration") : [e, {
|
|
28
|
+
key: v(t.key),
|
|
29
|
+
verificationKeys: (t.verificationKeys ?? []).map(v),
|
|
30
|
+
stage: t.stage.bind(t),
|
|
31
|
+
verify: t.verify.bind(t),
|
|
32
|
+
readArtifacts: t.readArtifacts.bind(t),
|
|
33
|
+
readRoutes: t.readRoutes.bind(t)
|
|
34
|
+
}];
|
|
35
|
+
})), { boundary: E, transaction: D } = c(h, y, b), O = async (e, t, a) => {
|
|
36
|
+
if (typeof a != "string" || !/^[A-Za-z0-9_-]{1,64}$/.test(a)) return g("input");
|
|
37
|
+
let o = await r(e, y, t, b()), s = await i(e, y, o), c = s.definitions.value, l = (e) => o.manifest.parts.find((t) => t.part === e) ?? g("integrity"), u = n({
|
|
38
|
+
domain: "voltro.cms.output.schema/v1",
|
|
39
|
+
pin: l("schema")
|
|
40
|
+
}), d = n({
|
|
41
|
+
domain: "voltro.cms.output.bindings/v1",
|
|
42
|
+
components: l("components"),
|
|
43
|
+
projection: l("projection"),
|
|
44
|
+
frontend: c.frontend
|
|
45
|
+
}), f = n({
|
|
46
|
+
domain: "voltro.cms.output.cache-key/v1",
|
|
47
|
+
schemaDigest: u,
|
|
48
|
+
bindingsDigest: d,
|
|
49
|
+
site: c.site,
|
|
50
|
+
routing: c.routing,
|
|
51
|
+
consentPurposes: c.consentPurposes
|
|
52
|
+
});
|
|
53
|
+
return {
|
|
54
|
+
snapshot: {
|
|
55
|
+
id: o.id,
|
|
56
|
+
digest: o.digest,
|
|
57
|
+
releaseId: o.manifest.publication.releaseId ?? g("state"),
|
|
58
|
+
publicationGeneration: o.manifest.publication.generation
|
|
59
|
+
},
|
|
60
|
+
app: {
|
|
61
|
+
deploymentId: a,
|
|
62
|
+
inputsId: s.inputsId,
|
|
63
|
+
executionId: s.executionId,
|
|
64
|
+
contractVersion: 1,
|
|
65
|
+
schemaDigest: u,
|
|
66
|
+
bindingsDigest: d,
|
|
67
|
+
cacheKeyDigest: f
|
|
68
|
+
},
|
|
69
|
+
renderPolicyDigest: l("policies").digest
|
|
70
|
+
};
|
|
71
|
+
}, k = async (e, t) => await d(e, y, t) ?? g("state"), A = async (e, t) => {
|
|
72
|
+
let n = await O(e, t.set.manifest.snapshot, t.set.manifest.app.deploymentId);
|
|
73
|
+
return !_(n.app, t.set.manifest.app) || !_(n.snapshot, t.set.manifest.snapshot) || n.renderPolicyDigest !== t.set.manifest.renderPolicyDigest ? g("changed") : n;
|
|
74
|
+
}, j = o({
|
|
75
|
+
pathKeys: x,
|
|
76
|
+
use: s.use.bind(s),
|
|
77
|
+
now: b,
|
|
78
|
+
verifyArtifacts: async (e, t) => {
|
|
79
|
+
let n = await k(e, t.id);
|
|
80
|
+
if (!_(n.set, t)) return g("changed");
|
|
81
|
+
let r;
|
|
82
|
+
for (let e of n.outputs) {
|
|
83
|
+
let n = T[e.region] ?? g("regions");
|
|
84
|
+
await n.verify(t, e.outputId);
|
|
85
|
+
let i = await n.readArtifacts(t, e.outputId);
|
|
86
|
+
if (r !== void 0 && !_(r, i)) return g("integrity");
|
|
87
|
+
r = i;
|
|
88
|
+
}
|
|
89
|
+
if (r === void 0) return g("regions");
|
|
90
|
+
let i = [];
|
|
91
|
+
for (let r of n.pathSets) {
|
|
92
|
+
let n = t.manifest.paths.find((e) => e.host === r.host) ?? g("integrity");
|
|
93
|
+
i.push(await a(e, y, {
|
|
94
|
+
id: r.jobId,
|
|
95
|
+
digest: n.setId
|
|
96
|
+
}, x));
|
|
97
|
+
}
|
|
98
|
+
return {
|
|
99
|
+
...r,
|
|
100
|
+
pathSets: i
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
return {
|
|
105
|
+
...l({
|
|
106
|
+
store: h,
|
|
107
|
+
scope: y,
|
|
108
|
+
key: S,
|
|
109
|
+
...s.verificationKeys === void 0 ? {} : { verificationKeys: s.verificationKeys },
|
|
110
|
+
now: b,
|
|
111
|
+
readSet: async (e, t) => (await k(e, t)).set,
|
|
112
|
+
readDeployment: async (e, t) => {
|
|
113
|
+
let n = await e.query({
|
|
114
|
+
table: u,
|
|
115
|
+
predicate: p(m("tenantId", y.tenantId), m("site", y.site), m("environment", y.environment), m("deploymentId", t)),
|
|
116
|
+
order: [],
|
|
117
|
+
take: 2,
|
|
118
|
+
skip: void 0,
|
|
119
|
+
projection: ["targetId"]
|
|
120
|
+
});
|
|
121
|
+
if (n.length !== 1 || typeof n[0].targetId != "string") return g("state");
|
|
122
|
+
let r = await A(e, await k(e, n[0].targetId));
|
|
123
|
+
return {
|
|
124
|
+
app: r.app,
|
|
125
|
+
renderPolicyDigest: r.renderPolicyDigest
|
|
126
|
+
};
|
|
127
|
+
},
|
|
128
|
+
admit: j,
|
|
129
|
+
readRoutes: (e, t) => (T[t.region] ?? g("regions")).readRoutes(e, t.outputId),
|
|
130
|
+
regions: Object.fromEntries(C.map((e) => {
|
|
131
|
+
let t = T[e];
|
|
132
|
+
return [e, {
|
|
133
|
+
key: t.key,
|
|
134
|
+
verificationKeys: t.verificationKeys,
|
|
135
|
+
verify: async (n, r, i) => {
|
|
136
|
+
if ((await k(n, r.id)).outputs.find((t) => t.region === e)?.outputId !== i) return g("regions");
|
|
137
|
+
await t.verify(r, i);
|
|
138
|
+
}
|
|
139
|
+
}];
|
|
140
|
+
}))
|
|
141
|
+
}),
|
|
142
|
+
prepare: (e) => {
|
|
143
|
+
let r = structuredClone(e);
|
|
144
|
+
return E(async (e) => {
|
|
145
|
+
let i = await D(r.credential, e, async (e) => {
|
|
146
|
+
let i = await O(e, r.snapshot, r.deploymentId);
|
|
147
|
+
if (!Array.isArray(r.pathSets) || r.pathSets.length < 1 || r.pathSets.length > 256) return g("input");
|
|
148
|
+
let o = [...r.pathSets].sort((e, t) => e.host < t.host ? -1 : +(e.host > t.host)), s = [];
|
|
149
|
+
for (let t of o) {
|
|
150
|
+
let n = await a(e, y, {
|
|
151
|
+
id: t.jobId,
|
|
152
|
+
digest: t.digest
|
|
153
|
+
}, x);
|
|
154
|
+
s.push({
|
|
155
|
+
host: t.host,
|
|
156
|
+
setId: n.set.id,
|
|
157
|
+
count: n.set.manifest.count
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
let c = {
|
|
161
|
+
version: 2,
|
|
162
|
+
scope: y,
|
|
163
|
+
...i,
|
|
164
|
+
paths: s,
|
|
165
|
+
artifacts: r.artifacts,
|
|
166
|
+
regions: {
|
|
167
|
+
required: C,
|
|
168
|
+
quorum: w
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
return {
|
|
172
|
+
set: t({
|
|
173
|
+
...c,
|
|
174
|
+
cacheNamespace: n({
|
|
175
|
+
domain: "voltro.cms.output.namespace/v1",
|
|
176
|
+
manifest: c
|
|
177
|
+
})
|
|
178
|
+
}),
|
|
179
|
+
pathSets: o.map(({ host: e, jobId: t }) => ({
|
|
180
|
+
host: e,
|
|
181
|
+
jobId: t
|
|
182
|
+
}))
|
|
183
|
+
};
|
|
184
|
+
}), o = [];
|
|
185
|
+
for (let t of C) {
|
|
186
|
+
e.throwIfAborted();
|
|
187
|
+
let n = await T[t].stage(i.set);
|
|
188
|
+
e.throwIfAborted(), await T[t].verify(i.set, n.outputId), o.push({
|
|
189
|
+
region: t,
|
|
190
|
+
outputId: n.outputId
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
return D(r.credential, e, async (e) => {
|
|
194
|
+
let t = {
|
|
195
|
+
...i,
|
|
196
|
+
outputs: o
|
|
197
|
+
};
|
|
198
|
+
return await A(e, t), f(e, y, t, x);
|
|
199
|
+
});
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
};
|
|
203
|
+
};
|
|
204
|
+
//#endregion
|
|
205
|
+
export { y as createCmsNativeOutputDeployments };
|