@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.
Files changed (53) hide show
  1. package/caddy/Caddyfile.production +5 -7
  2. package/caddy/Caddyfile.staging +4 -4
  3. package/dist/adapter.d.ts +3 -3
  4. package/dist/admin-domain.d.ts +8 -0
  5. package/dist/admin-domain.d.ts.map +1 -1
  6. package/dist/admin-domain.js +2 -2
  7. package/dist/admin-domain.js.map +1 -1
  8. package/dist/azure-front-door.d.ts +29 -0
  9. package/dist/azure-front-door.d.ts.map +1 -0
  10. package/dist/azure-front-door.js +32 -0
  11. package/dist/azure-front-door.js.map +1 -0
  12. package/dist/cli.js +69 -20
  13. package/dist/cli.js.map +1 -1
  14. package/dist/default-firewall.d.ts +12 -9
  15. package/dist/default-firewall.d.ts.map +1 -1
  16. package/dist/default-firewall.js +140 -28
  17. package/dist/default-firewall.js.map +1 -1
  18. package/dist/gcloud.d.ts.map +1 -1
  19. package/dist/gcloud.js +3 -0
  20. package/dist/gcloud.js.map +1 -1
  21. package/dist/internal-token.d.ts +9 -0
  22. package/dist/internal-token.d.ts.map +1 -0
  23. package/dist/internal-token.js +23 -0
  24. package/dist/internal-token.js.map +1 -0
  25. package/dist/lifecycle.js +2 -2
  26. package/dist/lifecycle.js.map +1 -1
  27. package/dist/stack-contract.d.ts +34 -13
  28. package/dist/stack-contract.d.ts.map +1 -1
  29. package/dist/stack-contract.js +45 -15
  30. package/dist/stack-contract.js.map +1 -1
  31. package/dist/stack-converge.d.ts +3 -3
  32. package/dist/stack-converge.js +7 -7
  33. package/dist/stack-converge.js.map +1 -1
  34. package/dist/staging-admin.d.ts +79 -0
  35. package/dist/staging-admin.d.ts.map +1 -0
  36. package/dist/staging-admin.js +223 -0
  37. package/dist/staging-admin.js.map +1 -0
  38. package/dist/wizards/gcp.js +15 -13
  39. package/dist/wizards/gcp.js.map +1 -1
  40. package/package.json +3 -4
  41. package/stacks/aws/Pulumi.yaml +3 -3
  42. package/stacks/aws/README.md +4 -28
  43. package/stacks/aws/index.ts +53 -71
  44. package/stacks/azure/Pulumi.yaml +3 -3
  45. package/stacks/azure/README.md +7 -11
  46. package/stacks/azure/index.ts +132 -42
  47. package/stacks/gcp/Pulumi.yaml +3 -3
  48. package/stacks/gcp/README.md +3 -18
  49. package/stacks/aws/build-edge.ts +0 -80
  50. package/stacks/aws/edge-handler-bundle.js +0 -20
  51. package/stacks/aws/edge-handler.ts +0 -86
  52. package/stacks/azure/edge-handler.ts +0 -87
  53. 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
- });