Update hivegrid-cloud reference to latest main

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
davidandClaude Fable 5 committed 2026-07-08 16:15:37 +02:00
1 parent e98d38e716
commit 7b21524c86
3781 files changed
+373484 -225607

No files matched your search

@@ -61,15 +61,6 @@ function createApiKeyLogClient(): LegacyApiKeyLogWriterClient & LegacyApiKeyRead
deleteMany: vi.fn().mockResolvedValue({ count: 1 }),
findMany: vi.fn().mockResolvedValue([]),
},
apiKeyEntity: {
create: vi.fn().mockResolvedValue({}),
deleteMany: vi.fn().mockResolvedValue({ count: 1 }),
},
entity: {
findMany: vi.fn().mockImplementation(({ where }: { where: { id: { in: string[] } } }) => {
return Promise.resolve(where.id.in.map((id) => ({ id })));
}),
},
apiKeyLog: {
create: vi.fn().mockResolvedValue({ id: "log_1" }),
findMany: vi.fn().mockResolvedValue([]),
@@ -157,8 +148,8 @@ describe("legacy API key log writes", () => {
alias: "Production",
expires: null,
tenantId: "tenant_1",
createdByUserId: "user_1",
active: true,
entities: [],
tenant: { id: "tenant_1", name: "Acme", slug: "acme", deactivatedReason: null },
_count: { apiKeyLogs: 0 },
};
@@ -328,7 +319,6 @@ describe("legacy API key log writes", () => {
active: false,
key,
},
[{ entityId: "entity_1", create: true, read: true, update: false, delete: false }],
client,
"hash-secret",
),
@@ -349,52 +339,6 @@ describe("legacy API key log writes", () => {
}),
});
expect(vi.mocked(client.apiKey.create).mock.calls[0]?.[0].data.hashedAt).toBeInstanceOf(Date);
expect(client.apiKeyEntity.create).toHaveBeenCalledWith({
data: {
apiKeyId: "api_key_1",
entityId: "entity_1",
create: true,
read: true,
update: false,
delete: false,
},
});
expect(client.entity.findMany).toHaveBeenCalledWith({
where: {
id: { in: ["entity_1"] },
active: true,
hasApi: true,
type: { in: ["app", "all"] },
},
select: { id: true },
});
});
it("rejects API key entity scopes outside tenant API-eligible entities", async () => {
const client = createApiKeyLogClient();
vi.mocked(client.entity.findMany).mockResolvedValue([{ id: "entity_allowed" }]);
await expect(
createLegacyApiKey(
{
tenantId: "tenant_1",
createdByUserId: "user_1",
alias: "Production",
expires: null,
active: true,
key: "api_test_plaintext_secret",
},
[
{ entityId: "entity_allowed", create: true, read: true, update: false, delete: false },
{ entityId: "entity_admin", create: true, read: true, update: true, delete: true },
],
client,
"hash-secret",
),
).rejects.toThrow("API key entity scope is not allowed");
expect(client.apiKey.create).not.toHaveBeenCalled();
expect(client.apiKeyEntity.create).not.toHaveBeenCalled();
});
it("derives stable and distinct API key hashes", () => {
@@ -531,8 +475,9 @@ describe("legacy API key log writes", () => {
alias: "Production",
expires: null,
tenantId: "tenant_1",
createdByUserId: "user_1",
active: true,
entities: [],
scopes: ["public_api:read"],
tenant: { id: "tenant_1", name: "Acme", slug: "acme", deactivatedReason: null },
};
vi.mocked(client.apiKey.findFirst).mockImplementation(({ where }) => {
@@ -553,7 +498,7 @@ describe("legacy API key log writes", () => {
}));
});
it("updates API keys and replaces entity permissions", async () => {
it("updates API keys and reloads the persisted record", async () => {
const client = createApiKeyLogClient();
const expires = new Date("2026-05-01T00:00:00.000Z");
vi.mocked(client.apiKey.findFirst).mockResolvedValue({ id: "api_key_1", tenantId: "tenant_1", key: "updated-secret" } as never);
@@ -567,7 +512,6 @@ describe("legacy API key log writes", () => {
expires,
active: true,
},
[{ entityId: "entity_1", create: false, read: true, update: true, delete: false }],
client,
),
).resolves.toEqual({ id: "api_key_1", tenantId: "tenant_1", key: "updated-secret" });
@@ -581,22 +525,6 @@ describe("legacy API key log writes", () => {
active: true,
},
});
expect(client.apiKeyEntity.deleteMany).toHaveBeenCalledWith({
where: {
apiKeyId: "api_key_1",
apiKey: { tenantId: "tenant_1" },
},
});
expect(client.apiKeyEntity.create).toHaveBeenCalledWith({
data: {
apiKeyId: "api_key_1",
entityId: "entity_1",
create: false,
read: true,
update: true,
delete: false,
},
});
expect(client.apiKey.findFirst).toHaveBeenCalledWith({
where: { id: "api_key_1", tenantId: "tenant_1" },
});
@@ -628,8 +556,9 @@ describe("legacy API key log writes", () => {
alias: "Production",
expires: null,
tenantId: "tenant_1",
createdByUserId: "user_1",
active: true,
entities: [],
scopes: ["public_api:read"],
tenant: { id: "tenant_1", name: "Acme", slug: "acme", deactivatedReason: null },
};
vi.mocked(client.apiKey.findFirst).mockResolvedValue(apiKey);
@@ -643,8 +572,9 @@ describe("legacy API key log writes", () => {
alias: true,
expires: true,
tenantId: true,
createdByUserId: true,
active: true,
entities: { select: { create: true, read: true, update: true, delete: true, entityId: true } },
scopes: true,
tenant: { select: { id: true, name: true, slug: true, deactivatedReason: true } },
},
});
@@ -675,8 +605,9 @@ describe("legacy API key log writes", () => {
alias: "Production",
expires: null,
tenantId: "tenant_1",
createdByUserId: "user_1",
active: true,
entities: [],
scopes: ["public_api:read"],
tenant: { id: "tenant_1", name: "Acme", slug: "acme", deactivatedReason: null },
};
vi.mocked(client.apiKey.findFirst).mockResolvedValueOnce(null).mockResolvedValueOnce(apiKey);
@@ -719,8 +650,9 @@ describe("legacy API key log writes", () => {
alias: "Production",
expires: null,
tenantId: "tenant_1",
createdByUserId: "user_1",
active: true,
entities: [],
scopes: ["public_api:read"],
tenant: { id: "tenant_1", name: "Acme", slug: "acme", deactivatedReason: null },
};
vi.mocked(client.apiKey.findFirst).mockRejectedValueOnce(new Error("hash index unavailable")).mockResolvedValueOnce(apiKey);