@wtfalch/foundry 0.68.2 → 0.68.3

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.
@@ -49,7 +49,9 @@ export const APPS_DB_ROUTE_APPLIED_SCOPE_KEY = 'apps_db_route_applied';
49
49
  export const appsDbHostname = (org) => hyperdriveHostname(org, APPS_DB_ENTRY_KEY, workerAppApex(org));
50
50
  /** The applied marker: the tunnel hostname and the server it reaches. A route recorded with the hostname alone (the old Postgres server) differs, so it is planned again. */
51
51
  export const appsDbRouteMarker = (org) => `${appsDbHostname(org)}|${appsDbName(org)}`;
52
- const routeKeys = remoteDatabaseKeys(APPS_DB_ENTRY_KEY);
52
+ // Read on use, not at load: `./audit` loaded first reaches this module before `worker-app.ts` has set
53
+ // APPS_DB_ENTRY_KEY (a cycle), and a top-level read then throws (0.68.2).
54
+ const routeKeys = () => remoteDatabaseKeys(APPS_DB_ENTRY_KEY);
53
55
  /**
54
56
  * Pure. `apply` once the company's apps are on and everything the route needs is recorded or planned;
55
57
  * `retire` when they went off and the route is still recorded. Anything missing is blocked, not planned
@@ -67,10 +69,10 @@ export function planAppsDbRoute(org, recordedIds, plannedSteps, options) {
67
69
  action: { system: 'cloudflare', kind: 'apps-db-route', key: org.id, desired },
68
70
  step: { description, destroys: desired.mode === 'retire', migrates: false },
69
71
  });
70
- const recordedRoute = Boolean(recordedIds[routeKeys.route] ||
71
- recordedIds[routeKeys.access] ||
72
- recordedIds[routeKeys.token] ||
73
- recordedIds[routeKeys.undelivered] ||
72
+ const recordedRoute = Boolean(recordedIds[routeKeys().route] ||
73
+ recordedIds[routeKeys().access] ||
74
+ recordedIds[routeKeys().token] ||
75
+ recordedIds[routeKeys().undelivered] ||
74
76
  recordedIds[APPS_DB_ROUTE_APPLIED_SCOPE_KEY]);
75
77
  if (!appsOn(org)) {
76
78
  if (!recordedRoute)
@@ -93,7 +95,7 @@ export function planAppsDbRoute(org, recordedIds, plannedSteps, options) {
93
95
  return block('the host supplies no Access, tunnel, DNS or zone port');
94
96
  if (!options.canHoldSecrets)
95
97
  return block('the host cannot hold secrets');
96
- const lost = recordedIds[routeKeys.undelivered];
98
+ const lost = recordedIds[routeKeys().undelivered];
97
99
  if (lost) {
98
100
  return block(`service token ${lost} was created but its secret was never saved, so it cannot be used. To start over, turn apps off and apply (that removes the route and clears this note), delete the token ${lost} in Cloudflare Zero Trust if it is still listed, then turn apps on again`);
99
101
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wtfalch/foundry",
3
- "version": "0.68.2",
3
+ "version": "0.68.3",
4
4
  "description": "Foundry's SDK: the declared org's types, the plan and apply contracts, and the state store's interface.",
5
5
  "repository": {
6
6
  "type": "git",