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
@@ -0,0 +1,66 @@
|
||||
import { describe, expect, test } from "vitest";
|
||||
|
||||
import { applySparseFields, parsePublicApiListQuery, publicApiResources, serializePublicApiCursor } from "./resources.js";
|
||||
|
||||
describe("public API resources", () => {
|
||||
test("parses bounded cursor list queries", () => {
|
||||
const cursor = serializePublicApiCursor({ fieldValue: "2026-07-03T00:00:00.000Z", id: "row_1" });
|
||||
const result = parsePublicApiListQuery(
|
||||
publicApiResources.contacts,
|
||||
new URLSearchParams({
|
||||
limit: "25",
|
||||
cursor,
|
||||
sort: "updatedAt.asc",
|
||||
fields: "displayName,email",
|
||||
q: "Meyer",
|
||||
updatedSince: "2026-07-01T00:00:00.000Z",
|
||||
}),
|
||||
);
|
||||
|
||||
expect(result).toMatchObject({
|
||||
ok: true,
|
||||
value: {
|
||||
limit: 25,
|
||||
cursor: { fieldValue: "2026-07-03T00:00:00.000Z", id: "row_1" },
|
||||
sort: { field: "updatedAt", direction: "asc" },
|
||||
fields: ["displayName", "email"],
|
||||
filters: { q: "Meyer" },
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
test("rejects unsupported sparse fields and embeds", () => {
|
||||
expect(parsePublicApiListQuery(publicApiResources.contacts, new URLSearchParams({ fields: "passwordHash" }))).toMatchObject({
|
||||
ok: false,
|
||||
code: "invalid_fields",
|
||||
});
|
||||
expect(parsePublicApiListQuery(publicApiResources.contacts, new URLSearchParams({ embed: "secrets" }))).toMatchObject({
|
||||
ok: false,
|
||||
code: "invalid_embed",
|
||||
});
|
||||
});
|
||||
|
||||
test("rejects cursor payloads with non-date sort values", () => {
|
||||
const cursor = serializePublicApiCursor({ fieldValue: "not-a-date", id: "row_1" });
|
||||
|
||||
expect(parsePublicApiListQuery(publicApiResources.contacts, new URLSearchParams({ cursor }))).toMatchObject({
|
||||
ok: false,
|
||||
code: "invalid_cursor",
|
||||
});
|
||||
});
|
||||
|
||||
test("keeps id and requested embeds in sparse fieldsets", () => {
|
||||
expect(
|
||||
applySparseFields(
|
||||
{ id: "deal_1", name: "Deal", email: "a@example.test", pipeline: { id: "pipeline_1" } },
|
||||
["email"],
|
||||
publicApiResources.deals.defaultFields,
|
||||
["pipeline"],
|
||||
),
|
||||
).toEqual({
|
||||
email: "a@example.test",
|
||||
id: "deal_1",
|
||||
pipeline: { id: "pipeline_1" },
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user