@caelo-cms/provisioning 0.10.40 → 0.10.42
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/caddy/Caddyfile.production +5 -7
- package/caddy/Caddyfile.staging +4 -4
- package/dist/adapter.d.ts +3 -3
- package/dist/admin-domain.d.ts +8 -0
- package/dist/admin-domain.d.ts.map +1 -1
- package/dist/admin-domain.js +2 -2
- package/dist/admin-domain.js.map +1 -1
- package/dist/azure-front-door.d.ts +29 -0
- package/dist/azure-front-door.d.ts.map +1 -0
- package/dist/azure-front-door.js +32 -0
- package/dist/azure-front-door.js.map +1 -0
- package/dist/cli.js +69 -20
- package/dist/cli.js.map +1 -1
- package/dist/default-firewall.d.ts +12 -9
- package/dist/default-firewall.d.ts.map +1 -1
- package/dist/default-firewall.js +140 -28
- package/dist/default-firewall.js.map +1 -1
- package/dist/gcloud.d.ts.map +1 -1
- package/dist/gcloud.js +3 -0
- package/dist/gcloud.js.map +1 -1
- package/dist/internal-token.d.ts +9 -0
- package/dist/internal-token.d.ts.map +1 -0
- package/dist/internal-token.js +23 -0
- package/dist/internal-token.js.map +1 -0
- package/dist/lifecycle.js +2 -2
- package/dist/lifecycle.js.map +1 -1
- package/dist/stack-contract.d.ts +34 -13
- package/dist/stack-contract.d.ts.map +1 -1
- package/dist/stack-contract.js +45 -15
- package/dist/stack-contract.js.map +1 -1
- package/dist/stack-converge.d.ts +3 -3
- package/dist/stack-converge.js +7 -7
- package/dist/stack-converge.js.map +1 -1
- package/dist/staging-admin.d.ts +79 -0
- package/dist/staging-admin.d.ts.map +1 -0
- package/dist/staging-admin.js +223 -0
- package/dist/staging-admin.js.map +1 -0
- package/dist/wizards/gcp.js +15 -13
- package/dist/wizards/gcp.js.map +1 -1
- package/package.json +3 -4
- package/stacks/aws/Pulumi.yaml +3 -3
- package/stacks/aws/README.md +4 -28
- package/stacks/aws/index.ts +53 -71
- package/stacks/azure/Pulumi.yaml +3 -3
- package/stacks/azure/README.md +7 -11
- package/stacks/azure/index.ts +132 -42
- package/stacks/gcp/Pulumi.yaml +3 -3
- package/stacks/gcp/README.md +3 -18
- package/stacks/aws/build-edge.ts +0 -80
- package/stacks/aws/edge-handler-bundle.js +0 -20
- package/stacks/aws/edge-handler.ts +0 -86
- package/stacks/azure/edge-handler.ts +0 -87
- package/stacks/gcp/edge-handler.ts +0 -105
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: MPL-2.0
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Caelo GCP edge-router — Cloud Run HTTP handler.
|
|
5
|
-
*
|
|
6
|
-
* Imports the SAME `routeRequest` from `@caelo-cms/edge-router` that the
|
|
7
|
-
* P13 self-hosted Caddy gateway, the AWS Lambda@Edge function, and the
|
|
8
|
-
* future Azure Front Door rules engine use. The byte-identity test in
|
|
9
|
-
* packages/edge-router/src/index.test.ts asserts a fixed corpus of
|
|
10
|
-
* (visitorId, manifestVersion, experimentId) tuples produces identical
|
|
11
|
-
* variant labels across every runtime.
|
|
12
|
-
*
|
|
13
|
-
* Differences from AWS L@E:
|
|
14
|
-
* - Cloud Run has full network egress (we fetch the manifest from GCS
|
|
15
|
-
* on a TTL-cached schedule rather than bundling at deploy time).
|
|
16
|
-
* - Cloud Run can set response headers directly (no companion handler).
|
|
17
|
-
* - Logs flow via `console.log(JSON.stringify(...))` to Cloud Logging,
|
|
18
|
-
* where the project sink filters `jsonPayload.kind="ab_assignment"`
|
|
19
|
-
* and ships to BigQuery.
|
|
20
|
-
*
|
|
21
|
-
* This file is meant to be the entry of a Cloud Run container; the
|
|
22
|
-
* operator's image build step (`gcloud builds submit`) bundles it
|
|
23
|
-
* together with the static-output bucket as the upstream for non-API
|
|
24
|
-
* routes. v1 ships the source; the build pipeline lands in P15
|
|
25
|
-
* review-pass.
|
|
26
|
-
*/
|
|
27
|
-
|
|
28
|
-
import { EMPTY_MANIFEST, type RoutingManifest, routeRequest } from "@caelo-cms/edge-router";
|
|
29
|
-
|
|
30
|
-
const STATIC_BUCKET = process.env.STATIC_BUCKET ?? "";
|
|
31
|
-
// P15 hot-fix #1 — distinct filename from the deploy manifest. The
|
|
32
|
-
// static-generator writes `routing-manifest.json` (deploy provenance)
|
|
33
|
-
// AND `ab-routing.json` (edge-router shape — RoutingManifest).
|
|
34
|
-
const MANIFEST_OBJECT = process.env.MANIFEST_OBJECT ?? "ab-routing.json";
|
|
35
|
-
const MANIFEST_REFRESH_MS = 30_000;
|
|
36
|
-
const COOKIE_NAME = "caelo_visitor_id";
|
|
37
|
-
|
|
38
|
-
let manifestCache: { value: RoutingManifest; loadedAt: number } = {
|
|
39
|
-
value: EMPTY_MANIFEST,
|
|
40
|
-
loadedAt: 0,
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
async function fetchManifest(): Promise<RoutingManifest> {
|
|
44
|
-
if (Date.now() - manifestCache.loadedAt < MANIFEST_REFRESH_MS) {
|
|
45
|
-
return manifestCache.value;
|
|
46
|
-
}
|
|
47
|
-
if (!STATIC_BUCKET) return EMPTY_MANIFEST;
|
|
48
|
-
try {
|
|
49
|
-
const url = `https://storage.googleapis.com/${STATIC_BUCKET}/${MANIFEST_OBJECT}`;
|
|
50
|
-
const r = await fetch(url, { signal: AbortSignal.timeout(2000) });
|
|
51
|
-
if (!r.ok) return manifestCache.value; // keep stale on transient failure
|
|
52
|
-
const m = (await r.json()) as RoutingManifest;
|
|
53
|
-
manifestCache = { value: m, loadedAt: Date.now() };
|
|
54
|
-
return m;
|
|
55
|
-
} catch {
|
|
56
|
-
return manifestCache.value;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
function readCookie(header: string | null, name: string): string | null {
|
|
61
|
-
if (!header) return null;
|
|
62
|
-
for (const pair of header.split(/;\s*/)) {
|
|
63
|
-
const eq = pair.indexOf("=");
|
|
64
|
-
if (eq < 0) continue;
|
|
65
|
-
if (pair.slice(0, eq) === name) return decodeURIComponent(pair.slice(eq + 1));
|
|
66
|
-
}
|
|
67
|
-
return null;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Cloud Run HTTP handler. Cloud Run accepts any web framework with a
|
|
72
|
-
* standard fetch-style handler; v1 uses Bun's native server for
|
|
73
|
-
* portability with the rest of the Caelo runtime.
|
|
74
|
-
*/
|
|
75
|
-
const port = Number(process.env.PORT ?? 8080);
|
|
76
|
-
Bun.serve({
|
|
77
|
-
port,
|
|
78
|
-
async fetch(req: Request): Promise<Response> {
|
|
79
|
-
const url = new URL(req.url);
|
|
80
|
-
const manifest = await fetchManifest();
|
|
81
|
-
const visitorIdCookie = readCookie(req.headers.get("cookie"), COOKIE_NAME);
|
|
82
|
-
const decision = routeRequest(manifest, {
|
|
83
|
-
pathname: url.pathname,
|
|
84
|
-
visitorIdCookie,
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
if (decision.logEntry) {
|
|
88
|
-
console.log(JSON.stringify(decision.logEntry));
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
// Edge-router's job is to redirect; the static origin (GCS bucket)
|
|
92
|
-
// serves the rewritten path. 307 keeps method semantics intact (a
|
|
93
|
-
// non-GET hitting an experiment page would otherwise lose its body).
|
|
94
|
-
const target = new URL(url.toString());
|
|
95
|
-
target.pathname = decision.rewritePathname;
|
|
96
|
-
const headers = new Headers({
|
|
97
|
-
Location: target.toString(),
|
|
98
|
-
"Cache-Control": "no-store, private",
|
|
99
|
-
// Set the cookie for the next request. Long max-age so visitor
|
|
100
|
-
// assignment persists across the experiment lifetime.
|
|
101
|
-
"Set-Cookie": `${COOKIE_NAME}=${encodeURIComponent(decision.setVisitorId)}; Path=/; Max-Age=31536000; SameSite=Lax; Secure; HttpOnly`,
|
|
102
|
-
});
|
|
103
|
-
return new Response(null, { status: 307, headers });
|
|
104
|
-
},
|
|
105
|
-
});
|