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

@@ -34,6 +34,9 @@ import type { IdempotencyStorageClient } from "./store.js";
type JsonValue = null | boolean | number | string | JsonValue[] | { [key: string]: JsonValue };
type PersistedEntry = {
tenantId: string | null;
partitionKey: string;
systemOwned: boolean;
scope: string;
key: string;
requestHash: string;
@@ -51,8 +54,8 @@ function hex(value: string): string {
return Buffer.from(value, "utf8").toString("hex");
}
function suffixFor(scope: string, key: string): string {
return `${KEY_PREFIX}:${hex(scope)}:${hex(key)}`;
function suffixFor(partitionKey: string, scope: string, key: string): string {
return `${KEY_PREFIX}:${hex(partitionKey)}:${hex(scope)}:${hex(key)}`;
}
function ttlSecondsUntil(expiresAt: number | null, now: () => number): number | undefined {
@@ -101,10 +104,15 @@ export function createSharedStoreIdempotencyStorageClient(
return {
idempotencyKey: {
async findUnique({ where }) {
const { scope, key } = where.idempotency_key_scope_key;
const entry = await readEntry(suffixFor(scope, key));
const { partitionKey, scope, key } = where.idempotency_key_partition_scope_key;
const entry = await readEntry(suffixFor(partitionKey, scope, key));
if (!entry) return null;
return {
tenantId: entry.tenantId,
partitionKey: entry.partitionKey,
systemOwned: entry.systemOwned,
scope: entry.scope,
key: entry.key,
requestHash: entry.requestHash,
responseStatus: entry.responseStatus,
responseBody: entry.responseBody ?? null,
@@ -117,6 +125,9 @@ export function createSharedStoreIdempotencyStorageClient(
async create({ data }) {
const expiresAt = data.expiresAt ? data.expiresAt.getTime() : null;
const entry: PersistedEntry = {
tenantId: data.tenantId,
partitionKey: data.partitionKey,
systemOwned: data.systemOwned,
scope: data.scope,
key: data.key,
requestHash: data.requestHash,
@@ -127,7 +138,7 @@ export function createSharedStoreIdempotencyStorageClient(
expiresAt,
};
const ttlSeconds = ttlSecondsUntil(expiresAt, now);
const written = await store.set(suffixFor(data.scope, data.key), JSON.stringify(entry), {
const written = await store.set(suffixFor(data.partitionKey, data.scope, data.key), JSON.stringify(entry), {
nx: true,
...(ttlSeconds !== undefined ? { ttlSeconds } : {}),
});
@@ -139,8 +150,8 @@ export function createSharedStoreIdempotencyStorageClient(
},
async update({ where, data }) {
const { scope, key } = where.idempotency_key_scope_key;
const suffix = suffixFor(scope, key);
const { partitionKey, scope, key } = where.idempotency_key_partition_scope_key;
const suffix = suffixFor(partitionKey, scope, key);
const existing = await readEntry(suffix);
if (!existing) {
throw new Error("Idempotency key reservation not found.");
@@ -161,8 +172,8 @@ export function createSharedStoreIdempotencyStorageClient(
const where = args?.where;
// Targeted single-key delete — no scan needed.
if (where?.scope && where?.key) {
const suffix = suffixFor(where.scope, where.key);
if (where?.partitionKey && where.scope && where.key) {
const suffix = suffixFor(where.partitionKey, where.scope, where.key);
if (where.expiresAt?.lte) {
const entry = await readEntry(suffix);
const cutoff = where.expiresAt.lte.getTime();
@@ -179,6 +190,7 @@ export function createSharedStoreIdempotencyStorageClient(
// by TTL so this stays cheap; it is never on the request hot path.
const cutoff = where?.expiresAt?.lte ? where.expiresAt.lte.getTime() : null;
for await (const { suffix, entry } of iterateEntries()) {
if (where?.partitionKey && entry.partitionKey !== where.partitionKey) continue;
if (where?.scope && entry.scope !== where.scope) continue;
if (where?.key && entry.key !== where.key) continue;
if (cutoff !== null && !(entry.expiresAt !== null && entry.expiresAt <= cutoff)) continue;
@@ -187,9 +199,11 @@ export function createSharedStoreIdempotencyStorageClient(
},
async count(args) {
const partitionKey = args?.where?.partitionKey;
const scope = args?.where?.scope;
let total = 0;
for await (const { entry } of iterateEntries()) {
if (partitionKey && entry.partitionKey !== partitionKey) continue;
if (scope && entry.scope !== scope) continue;
total += 1;
}