@agilesyndrome/cf-genai-base 1.0.0 → 1.0.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agilesyndrome/cf-genai-base",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./src/index.js",
package/src/core.js CHANGED
@@ -36,7 +36,7 @@ export function createD1(env, { who = "system:read" } = {}) {
36
36
  },
37
37
  async batch(statements) {
38
38
  auditD1(who, "BATCH");
39
- return db.batch(statements);
39
+ return typeof db.batch === "function" ? db.batch(statements) : Promise.all(statements.map((statement) => statement.run()));
40
40
  },
41
41
  };
42
42
  }
package/src/index.js CHANGED
@@ -3,7 +3,7 @@
3
3
  * Site code owns domain routes and data; this owns lifecycle and edge concerns.
4
4
  */
5
5
  import { ensureScopes, ensureUser, hasScope, listAuthorizationScopes, listAuthorizationUsers, listUserGrants, replaceUserGrants } from "./authorization.js";
6
- import { getCircuitBreaker, listCircuitBreakers, listHealthchecks, listFeatureHealth, registerFeatureManifests, requestActor, setCircuitBreaker, updateHealthcheck } from "./core.js";
6
+ import { getCircuitBreaker, evaluateCircuitBreaker, listCircuitBreakers, listHealthchecks, listFeatureHealth, registerFeatureManifests, requestActor, setCircuitBreaker, updateHealthcheck } from "./core.js";
7
7
  export * from "./core.js";
8
8
  export function createWorker({ fetch, scheduled, auth, authorize, scopes = [], scopeRoutes = [], middleware = [], features = [], health, boot, metrics, security = true }) {
9
9
  if (typeof fetch !== "function") throw new TypeError("createWorker requires a fetch handler");
@@ -20,7 +20,7 @@ export function createWorker({ fetch, scheduled, auth, authorize, scopes = [], s
20
20
  if (boot) await boot(env, { request, ctx });
21
21
  const url = new URL(request.url);
22
22
  const state = Object.create(null);
23
- if (env?.DB && features.some((feature) => typeof feature?.healthcheck === "function" || feature?.healthchecks?.length || feature?.healthChecks?.length || feature?.circuitBreakers?.length || feature?.circuit_breakers?.length)) ctx?.waitUntil?.(registerFeatureManifests(env, features, { who: "system:update" }).catch((error) => console.error("[EventLog] feature manifest registration failed", error)));
23
+ if (env?.DB && features.some((feature) => typeof feature?.healthcheck === "function" || feature?.healthchecks?.length || feature?.healthChecks?.length || feature?.circuitBreakers?.length || feature?.circuit_breakers?.length)) ctx?.waitUntil?.(registerFeatureManifests(env, features, { who: "system:update" }).then(() => listCircuitBreakers(env, { who: "system:update" }).then((breakers) => Promise.all(breakers.filter(Boolean).map((breaker) => evaluateCircuitBreaker(env, breaker.id, { who: "system:update" }))))).catch((error) => console.error("[EventLog] feature manifest registration failed", error)));
24
24
  const dispatch = async (index, currentRequest = request) => {
25
25
  const layer = chain[index];
26
26
  if (!layer) {