Refresh HiveGrid Cloud reference snapshot

This commit is contained in:
david committed 2026-08-03 15:31:14 +02:00
1 parent 5e99e14772
commit 7f88026f79
5955 files changed
+1177325 -188362

No files matched your search

@@ -35,6 +35,7 @@ import {
cancelTenantSubscriptionProduct as persistCancel,
updateTenantSubscriptionProduct as persistUpdate,
} from "@hivegrid/db/subscriptions.server";
import type { TenantBillingClient } from "@hivegrid/db/subscriptions.server";
const mocks = getMocks();
@@ -51,6 +52,22 @@ describe("tenantSubscriptionProducts db wrapper — cross-replica cache invalida
expect(mocks.clearTenantSubscriptionCache).toHaveBeenCalledWith("tenant-a");
});
it("can defer cache invalidation until the caller's transaction has committed", async () => {
mocks.clearTenantSubscriptionCache.mockClear();
vi.mocked(persistAdd).mockClear();
vi.mocked(persistAdd).mockResolvedValueOnce({
tenantSubscription: { tenantId: "tenant-a" },
} as Awaited<ReturnType<typeof persistAdd>>);
const transactionClient = {} as TenantBillingClient;
const input = {} as Parameters<typeof addTenantSubscriptionProduct>[0];
await addTenantSubscriptionProduct(input, { invalidateCache: false, client: transactionClient });
expect(persistAdd).toHaveBeenCalledWith(input, transactionClient);
expect(mocks.clearTenantSubscriptionCache).not.toHaveBeenCalled();
});
it("updateTenantSubscriptionProduct publishes a cross-replica invalidation for the tenant", async () => {
mocks.clearTenantSubscriptionCache.mockClear();
vi.mocked(persistUpdate).mockResolvedValueOnce({
@@ -5,6 +5,7 @@ import {
type TenantSubscriptionProductCreateInput,
type TenantSubscriptionProductUpdateInput,
type TenantSubscriptionProductCancelInput,
type TenantBillingClient,
} from "@hivegrid/db/subscriptions.server";
import { clearTenantSubscriptionCache } from "~/utils/services/.server/subscriptionService";
@@ -19,11 +20,16 @@ export {
type TenantSubscriptionProductWithTenant,
} from "@hivegrid/db/subscriptions.server";
export async function addTenantSubscriptionProduct(data: TenantSubscriptionProductCreateInput) {
const item = await persistTenantSubscriptionProduct(data);
export async function addTenantSubscriptionProduct(
data: TenantSubscriptionProductCreateInput,
options: { invalidateCache?: boolean; client?: TenantBillingClient } = {}
) {
const item = await persistTenantSubscriptionProduct(data, options.client);
// Cross-replica purge: clearTenantSubscriptionCache publishes on the
// subscription pub/sub channel so peer web replicas drop their L1 too.
clearTenantSubscriptionCache(item.tenantSubscription.tenantId);
if (options.invalidateCache !== false) {
clearTenantSubscriptionCache(item.tenantSubscription.tenantId);
}
return item;
}