@authhero/cloudflare-adapter 2.36.1 → 2.37.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.
@@ -81,5 +81,18 @@ export interface WfpTenantProvisioningHookOptions {
81
81
  export interface WfpTenantProvisioningHook {
82
82
  onProvision(tenantId: string): Promise<void>;
83
83
  onDeprovision(tenantId: string): Promise<void>;
84
+ /**
85
+ * Re-run provisioning for an already-existing WFP tenant to pull it onto the
86
+ * current bundle + migrations — i.e. an upgrade. Re-uploads the worker
87
+ * script (an upload overwrites), reconciles any migrations not yet applied to
88
+ * the tenant D1, re-runs `syncDefaults`, then rewrites `worker_version`,
89
+ * `bundle_configuration`, and `database_version` so the recorded versions
90
+ * reflect what now runs. Marks `provisioning_state = "pending"` while the
91
+ * upgrade is in flight and `ready` on success (`failed` on error).
92
+ *
93
+ * Throws if the tenant doesn't exist or isn't WFP-provisioned — callers
94
+ * (e.g. a management-API redeploy endpoint) surface that as a 4xx.
95
+ */
96
+ onUpgrade(tenantId: string): Promise<void>;
84
97
  }
85
98
  export declare function createWfpTenantProvisioningHook(options: WfpTenantProvisioningHookOptions): WfpTenantProvisioningHook;
@@ -83,8 +83,26 @@ export interface CloudflareWfpD1ProvisionerOptions {
83
83
  /**
84
84
  * SQL migrations applied in array order to every new tenant D1. Typically
85
85
  * loaded from `@authhero/drizzle`'s shipped migrations via your build tool.
86
+ *
87
+ * The name of the LAST entry is reported back as the tenant's
88
+ * `database_version` (the schema version this bundle targets), so keep the
89
+ * array ordered and the names stable.
86
90
  */
87
91
  migrations: ProvisionerMigration[];
92
+ /**
93
+ * Identifier of the worker image / variant being deployed (e.g.
94
+ * `"authhero-drizzle-d1"`). Recorded verbatim on the tenant row as
95
+ * `bundle_configuration` so the control plane can tell which build a tenant
96
+ * runs. Optional — omit if you don't track image variants.
97
+ */
98
+ bundleConfiguration?: string;
99
+ /**
100
+ * Release tag or git SHA of `tenantWorkerScript`, supplied by the operator
101
+ * at build time. Recorded verbatim on the tenant row as `worker_version` so
102
+ * the control plane can detect when a tenant lags the current build and
103
+ * needs an upgrade. Optional but strongly recommended.
104
+ */
105
+ workerVersion?: string;
88
106
  /**
89
107
  * Resolver that returns the secret values to set on the tenant worker.
90
108
  * Called once per `onProvision`. The provisioner uploads each entry via
@@ -145,6 +163,25 @@ export interface ProvisionResult {
145
163
  d1DatabaseId: string;
146
164
  scriptName: string;
147
165
  d1Name: string;
166
+ /**
167
+ * The worker image / variant that was deployed — echoes back
168
+ * `options.bundleConfiguration` (undefined if not configured). The hook
169
+ * persists it to `tenants.bundle_configuration`.
170
+ */
171
+ bundleConfiguration?: string;
172
+ /**
173
+ * The release tag / git SHA that was deployed — echoes back
174
+ * `options.workerVersion` (undefined if not configured). The hook persists
175
+ * it to `tenants.worker_version`.
176
+ */
177
+ workerVersion?: string;
178
+ /**
179
+ * Name of the latest migration applied to the tenant D1 (the last entry in
180
+ * `options.migrations`), i.e. the schema version the deployed bundle
181
+ * targets. `undefined` when no migrations are configured. The hook persists
182
+ * it to `tenants.database_version`.
183
+ */
184
+ databaseVersion?: string;
148
185
  }
149
186
  /**
150
187
  * What `createCloudflareWfpD1Provisioner` returns — the two lifecycle
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "type": "git",
12
12
  "url": "https://github.com/markusahlstrand/authhero"
13
13
  },
14
- "version": "2.36.1",
14
+ "version": "2.37.1",
15
15
  "files": [
16
16
  "dist"
17
17
  ],
@@ -42,8 +42,8 @@
42
42
  "typescript": "^5.9.3",
43
43
  "vite": "^8.0.14",
44
44
  "vitest": "^4.1.7",
45
- "@authhero/multi-tenancy": "14.25.1",
46
- "authhero": "8.7.2"
45
+ "authhero": "8.8.1",
46
+ "@authhero/multi-tenancy": "14.25.1"
47
47
  },
48
48
  "peerDependencies": {
49
49
  "@authhero/multi-tenancy": "^14.0.0",
@@ -62,8 +62,8 @@
62
62
  "dependencies": {
63
63
  "nanoid": "^5.1.11",
64
64
  "wretch": "^3.0.8",
65
- "@authhero/kysely-adapter": "11.8.11",
66
- "@authhero/adapter-interfaces": "3.2.0"
65
+ "@authhero/adapter-interfaces": "3.3.0",
66
+ "@authhero/kysely-adapter": "11.9.0"
67
67
  },
68
68
  "scripts": {
69
69
  "build": "vite build && tsc -p tsconfig.types.json && rollup -c rollup.dts.config.mjs",