Update hivegrid-cloud reference to latest main
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e98d38e716
commit
7b21524c86
3781 files changed
+373484
-225607
No files matched your search
@@ -224,13 +224,10 @@ describe("openApiDocument", () => {
|
||||
["/v1/workspaces/{tenantId}/invites", "post"],
|
||||
["/v1/workspaces/{tenantId}/invites/{inviteId}/accept", "post"],
|
||||
["/v1/workspaces/{tenantId}/invites/{inviteId}/revoke", "post"],
|
||||
["/v1/entities/{entity}/rows", "post"],
|
||||
["/v1/entities/{entity}/rows/{rowId}", "patch"],
|
||||
["/v1/relationships", "post"],
|
||||
["/v1/ai/upload", "post"],
|
||||
["/v1/support/inbound-email", "post"],
|
||||
["/v1/email-sequences/mailjet/webhooks", "post"],
|
||||
["/v1/billing/stripe/webhooks", "post"],
|
||||
["/v1/billing/mollie/webhooks", "post"],
|
||||
["/v1/events/webhooks/attempts/{id}", "post"],
|
||||
] as const;
|
||||
|
||||
@@ -268,12 +265,7 @@ describe("openApiDocument", () => {
|
||||
["/v1/analytics/admin", "get"],
|
||||
["/v1/accounts", "get"],
|
||||
["/v1/accounts/{id}", "get"],
|
||||
["/v1/entities/{entity}/rows", "get"],
|
||||
["/v1/workspaces/{tenantId}/invites", "get"],
|
||||
["/v1/entities/{entity}/rows/{rowId}", "get"],
|
||||
["/v1/entities/{entity}/rows/{rowId}", "delete"],
|
||||
["/v1/relationships/{id}", "get"],
|
||||
["/v1/relationships/{id}", "delete"],
|
||||
["/v1/exports/{exportJobId}/download-url", "get"],
|
||||
] as const;
|
||||
|
||||
@@ -326,13 +318,13 @@ describe("openApiDocument", () => {
|
||||
expect(serializedLoginRateLimitSchema).not.toMatch(
|
||||
/email|password|credential|account|token|api[-_ ]?key|[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}|secret|Bearer\s+[A-Za-z0-9._~+/-]{12,}/i
|
||||
);
|
||||
expect(openApiDocument.paths["/v1/auth/login"].post.responses["200"].description).toContain("HttpOnly RJ_api_session cookie");
|
||||
expect(openApiDocument.paths["/v1/auth/refresh-token"].post.responses["200"].description).toContain("HttpOnly RJ_api_session cookie");
|
||||
expect(openApiDocument.paths["/v1/auth/login"].post.responses["200"].description).toContain("HttpOnly hivegrid_api_session cookie");
|
||||
expect(openApiDocument.paths["/v1/auth/refresh-token"].post.responses["200"].description).toContain("HttpOnly hivegrid_api_session cookie");
|
||||
expect(openApiDocument.paths["/v1/auth/logout"].post).toMatchObject({
|
||||
operationId: "logoutApiSession",
|
||||
security: [{ apiSessionBearer: [] }],
|
||||
responses: {
|
||||
"200": { description: expect.stringContaining("clears the HttpOnly RJ_api_session cookie") },
|
||||
"200": { description: expect.stringContaining("clears the HttpOnly hivegrid_api_session cookie") },
|
||||
"401": { description: expect.stringContaining("invalid") },
|
||||
},
|
||||
});
|
||||
@@ -374,22 +366,6 @@ describe("openApiDocument", () => {
|
||||
},
|
||||
},
|
||||
});
|
||||
expect(openApiDocument.paths["/v1/relationships"].post.requestBody.content["application/json"].schema).toMatchObject({
|
||||
additionalProperties: true,
|
||||
required: ["parent", "child"],
|
||||
properties: {
|
||||
parent: { type: "string", minLength: 1 },
|
||||
child: { type: "string", minLength: 1 },
|
||||
},
|
||||
});
|
||||
expect(openApiDocument.paths["/v1/entities/{entity}/rows"].post.requestBody.content["application/json"].schema).toMatchObject({
|
||||
type: "object",
|
||||
additionalProperties: true,
|
||||
});
|
||||
expect(openApiDocument.paths["/v1/entities/{entity}/rows/{rowId}"].patch.requestBody.content["application/json"].schema).toMatchObject({
|
||||
type: "object",
|
||||
additionalProperties: true,
|
||||
});
|
||||
expect(JSON.stringify(openApiDocument)).not.toMatch(/(?:sk|pk)_(?:live|test)_[A-Za-z0-9]+|jwt_secret|secret_[A-Za-z0-9]+|Bearer\s+[A-Za-z0-9._~+/-]{12,}/i);
|
||||
});
|
||||
|
||||
@@ -402,7 +378,7 @@ describe("openApiDocument", () => {
|
||||
expect(openApiDocument.paths["/v1/analytics/public"].get.security).toEqual([{ analyticsTokenHeader: [] }]);
|
||||
});
|
||||
|
||||
test("documents service credential gates for export download and legacy entity detail endpoints", () => {
|
||||
test("documents service credential gates for export download endpoints", () => {
|
||||
const serviceCredentialOperations = [
|
||||
["/v1/exports/{exportJobId}/download-url", "get"],
|
||||
] as const;
|
||||
@@ -433,20 +409,6 @@ describe("openApiDocument", () => {
|
||||
});
|
||||
expect(documentedOperation).not.toHaveProperty("x-api-key-permissions");
|
||||
}
|
||||
|
||||
const entityDetailOperation = openApiDocument.paths["/v1/entities/{entity}"].get;
|
||||
expect(entityDetailOperation.security).toEqual([{ bearerAuth: [] }]);
|
||||
expect(entityDetailOperation.parameters).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({ name: "tenantId", in: "query", required: false }),
|
||||
expect.objectContaining({ name: "x-tenant-id", in: "header", required: false }),
|
||||
expect.objectContaining({ name: "x-account-id", in: "header", required: false }),
|
||||
])
|
||||
);
|
||||
expect(entityDetailOperation.responses["401"]).toMatchObject({
|
||||
headers: { "x-request-id": { schema: { type: "string" } } },
|
||||
});
|
||||
expect(entityDetailOperation).not.toHaveProperty("x-api-key-permissions");
|
||||
});
|
||||
|
||||
test("documents notification SSE stream contract and redaction boundaries", () => {
|
||||
@@ -457,8 +419,8 @@ describe("openApiDocument", () => {
|
||||
description: expect.stringContaining("tenant/user scoped notification delivery diagnostics"),
|
||||
security: [{ bearerAuth: [] }],
|
||||
parameters: [
|
||||
{ name: "x-toolctrl-tenant-id", in: "header", required: false, schema: { type: "string", minLength: 1 } },
|
||||
{ name: "x-toolctrl-user-id", in: "header", required: false, schema: { type: "string", minLength: 1 } },
|
||||
{ name: "x-hivegrid-tenant-id", in: "header", required: false, schema: { type: "string", minLength: 1 } },
|
||||
{ name: "x-hivegrid-user-id", in: "header", required: false, schema: { type: "string", minLength: 1 } },
|
||||
{ name: "tenantId", in: "query", required: false, deprecated: true, schema: { type: "string", minLength: 1 } },
|
||||
{ name: "userId", in: "query", required: false, deprecated: true, schema: { type: "string", minLength: 1 } },
|
||||
expect.objectContaining({
|
||||
@@ -559,9 +521,38 @@ describe("openApiDocument", () => {
|
||||
security: [{ apiKeyHeader: [] }],
|
||||
});
|
||||
|
||||
expect(openApiDocument.paths["/v1/billing/stripe/webhooks"].post).toMatchObject({
|
||||
operationId: "receiveStripeBillingWebhook",
|
||||
security: [{ stripeWebhookSignature: [] }],
|
||||
expect(openApiDocument.paths["/v1/contacts"].get).toMatchObject({
|
||||
operationId: "listPublicApiContacts",
|
||||
security: [{ apiKeyHeader: [] }],
|
||||
parameters: expect.arrayContaining([
|
||||
expect.objectContaining({ name: "x-api-key", in: "header", required: true }),
|
||||
expect.objectContaining({ name: "limit", in: "query" }),
|
||||
expect.objectContaining({ name: "cursor", in: "query" }),
|
||||
expect.objectContaining({ name: "fields", in: "query" }),
|
||||
]),
|
||||
responses: {
|
||||
"200": expect.objectContaining({
|
||||
description: expect.stringContaining("contacts"),
|
||||
}),
|
||||
"400": expect.any(Object),
|
||||
"401": expect.any(Object),
|
||||
"402": expect.any(Object),
|
||||
},
|
||||
});
|
||||
expect(openApiDocument.paths["/v1/leads"].get!.parameters).toEqual(
|
||||
expect.arrayContaining([expect.objectContaining({ name: "embed", description: expect.stringContaining("leadSource") })]),
|
||||
);
|
||||
|
||||
expect(openApiDocument.paths["/v1/billing/mollie/webhooks"].post).toMatchObject({
|
||||
operationId: "receiveMollieBillingWebhook",
|
||||
security: [],
|
||||
requestBody: {
|
||||
content: {
|
||||
"application/x-www-form-urlencoded": {
|
||||
schema: expect.objectContaining({ required: ["id"] }),
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
expect(openApiDocument.paths["/v1/email-sequences/mailjet/webhooks"].post).toMatchObject({
|
||||
operationId: "receiveEmailSequenceMailjetWebhook",
|
||||
@@ -861,7 +852,8 @@ describe("openApiDocument", () => {
|
||||
"apiSessionBearer",
|
||||
"bearerAuth",
|
||||
"mailjetWebhookAuth",
|
||||
"stripeWebhookSignature",
|
||||
"webhookHmac",
|
||||
"webhookTokenHeader",
|
||||
]);
|
||||
|
||||
expect(openApiDocument.components.securitySchemes.bearerAuth).toMatchObject({
|
||||
@@ -887,12 +879,6 @@ describe("openApiDocument", () => {
|
||||
scheme: "basic",
|
||||
description: expect.stringContaining("HTTP Basic-Auth"),
|
||||
});
|
||||
expect(openApiDocument.components.securitySchemes.stripeWebhookSignature).toMatchObject({
|
||||
type: "apiKey",
|
||||
in: "header",
|
||||
name: "stripe-signature",
|
||||
description: expect.stringContaining("Stripe webhook signature"),
|
||||
});
|
||||
expect(openApiDocument.components.securitySchemes.analyticsTokenHeader).toMatchObject({
|
||||
type: "apiKey",
|
||||
in: "header",
|
||||
@@ -908,69 +894,7 @@ describe("openApiDocument", () => {
|
||||
}
|
||||
});
|
||||
|
||||
test("documents idempotency for protected mutating entity-row and relationship operations only", () => {
|
||||
const idempotentOperations = [
|
||||
["/v1/entities/{entity}/rows", "post"],
|
||||
["/v1/entities/{entity}/rows/{rowId}", "patch"],
|
||||
["/v1/entities/{entity}/rows/{rowId}", "delete"],
|
||||
["/v1/relationships", "post"],
|
||||
["/v1/relationships/{id}", "delete"],
|
||||
] as const;
|
||||
|
||||
const conflictResponses = idempotentOperations.map(([path, method]) => {
|
||||
const documentedOperation = (openApiDocument.paths[path] as unknown as Record<typeof method, { parameters: Array<Record<string, unknown>>; responses: Record<string, unknown>; "x-idempotency-key": unknown }>)[method];
|
||||
expect(documentedOperation["x-idempotency-key"], `${path} ${method} should require an idempotency key`).toBe("required");
|
||||
expect(documentedOperation.parameters).toContainEqual(
|
||||
expect.objectContaining({
|
||||
name: "Idempotency-Key",
|
||||
in: "header",
|
||||
required: true,
|
||||
description: expect.stringContaining("Fingerprints are redacted"),
|
||||
schema: { type: "string", minLength: 1 },
|
||||
})
|
||||
);
|
||||
expect(documentedOperation.responses["409"], `${path} ${method} should document idempotency conflicts`).toMatchObject({
|
||||
description: expect.stringContaining("different redacted request fingerprint"),
|
||||
headers: { "x-request-id": { schema: { type: "string" } } },
|
||||
content: {
|
||||
"application/json": {
|
||||
schema: {
|
||||
properties: {
|
||||
error: {
|
||||
properties: {
|
||||
code: { enum: ["idempotency_key_conflict"] },
|
||||
message: { type: "string" },
|
||||
requestId: { type: "string" },
|
||||
},
|
||||
required: ["code", "message", "requestId"],
|
||||
},
|
||||
},
|
||||
required: ["error"],
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
expect(documentedOperation.responses["400"], `${path} ${method} should document missing idempotency keys`).toMatchObject({
|
||||
content: {
|
||||
"application/json": {
|
||||
schema: {
|
||||
properties: {
|
||||
error: {
|
||||
properties: {
|
||||
code: { enum: expect.arrayContaining(["idempotency_key_required"]) },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
return documentedOperation.responses["409"];
|
||||
});
|
||||
|
||||
expect(new Set(conflictResponses).size).toBe(1);
|
||||
expect(JSON.stringify(conflictResponses)).not.toMatch(/(?:sk|pk)_(?:live|test)_[A-Za-z0-9]+|secret_[A-Za-z0-9]+|Bearer\s+[A-Za-z0-9._~+/-]{12,}|x-api-key/i);
|
||||
|
||||
test("does not advertise idempotency for unsupported mutating operations", () => {
|
||||
const unsupportedMutatingOperations = [
|
||||
["/v1/auth/login", "post"],
|
||||
["/v1/auth/refresh-token", "post"],
|
||||
@@ -978,6 +902,7 @@ describe("openApiDocument", () => {
|
||||
["/v1/ai/upload", "post"],
|
||||
["/v1/support/inbound-email", "post"],
|
||||
["/v1/email-sequences/mailjet/webhooks", "post"],
|
||||
["/v1/billing/mollie/webhooks", "post"],
|
||||
["/v1/analytics/events", "post"],
|
||||
["/v1/analytics/page-views", "post"],
|
||||
["/v1/events/webhooks/attempts/{id}", "post"],
|
||||
@@ -990,39 +915,4 @@ describe("openApiDocument", () => {
|
||||
expect(documentedOperation.parameters ?? []).not.toContainEqual(expect.objectContaining({ name: "Idempotency-Key" }));
|
||||
}
|
||||
});
|
||||
|
||||
test("documents scoped API-key operation permissions", () => {
|
||||
const scopedOperations = [
|
||||
["/v1/entities/{entity}/rows", "get", "read"],
|
||||
["/v1/entities/{entity}/rows", "post", "create"],
|
||||
["/v1/entities/{entity}/rows/{rowId}", "get", "read"],
|
||||
["/v1/entities/{entity}/rows/{rowId}", "patch", "update"],
|
||||
["/v1/entities/{entity}/rows/{rowId}", "delete", "delete"],
|
||||
["/v1/relationships", "post", "create"],
|
||||
["/v1/relationships/{id}", "get", "read"],
|
||||
["/v1/relationships/{id}", "delete", "delete"],
|
||||
] as const;
|
||||
|
||||
for (const [path, method, operation] of scopedOperations) {
|
||||
const documentedOperation = (openApiDocument.paths[path] as unknown as Record<typeof method, { security: unknown; responses: Record<string, unknown>; "x-api-key-permissions": { entityPermissions?: Array<{ entity: unknown; operation: unknown }>; [key: string]: unknown } }>)[method];
|
||||
expect(documentedOperation.security).toEqual([{ bearerAuth: [] }, { apiKeyHeader: [] }]);
|
||||
expect(documentedOperation.responses).toHaveProperty("403");
|
||||
expect(documentedOperation["x-api-key-permissions"]).toMatchObject({
|
||||
credential: "apiKeyHeader",
|
||||
tenant: { source: "query", name: "tenantId" },
|
||||
});
|
||||
|
||||
if (path.startsWith("/v1/entities")) {
|
||||
expect(documentedOperation["x-api-key-permissions"]).toMatchObject({
|
||||
entity: { source: "path", name: "entity" },
|
||||
operation,
|
||||
});
|
||||
} else {
|
||||
expect(documentedOperation["x-api-key-permissions"].entityPermissions).toEqual([
|
||||
{ entity: { source: "relationship.parentEntity" }, operation },
|
||||
{ entity: { source: "relationship.childEntity" }, operation },
|
||||
]);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user