@siteping/adapter-kit 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +32 -0
- package/dist/chunk-YQHAD24P.js +97 -0
- package/dist/chunk-YQHAD24P.js.map +1 -0
- package/dist/errors.d.cts +41 -0
- package/dist/errors.d.ts +41 -0
- package/dist/filters.d.cts +33 -0
- package/dist/filters.d.ts +33 -0
- package/dist/i18n.d.cts +67 -0
- package/dist/i18n.d.ts +67 -0
- package/dist/index.cjs +256 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +170 -0
- package/dist/index.js.map +1 -0
- package/dist/schema.d.cts +263 -0
- package/dist/schema.d.ts +263 -0
- package/dist/screenshot-storage.d.cts +61 -0
- package/dist/screenshot-storage.d.ts +61 -0
- package/dist/siteping-core-testing.d.cts +40 -0
- package/dist/siteping-core-testing.d.ts +40 -0
- package/dist/siteping-core.d.cts +16 -0
- package/dist/siteping-core.d.ts +16 -0
- package/dist/store-helpers.d.cts +87 -0
- package/dist/store-helpers.d.ts +87 -0
- package/dist/testing.cjs +484 -0
- package/dist/testing.cjs.map +1 -0
- package/dist/testing.d.cts +1 -0
- package/dist/testing.d.ts +1 -0
- package/dist/testing.js +433 -0
- package/dist/testing.js.map +1 -0
- package/dist/type-utils.d.cts +58 -0
- package/dist/type-utils.d.ts +58 -0
- package/dist/types.d.cts +840 -0
- package/dist/types.d.ts +840 -0
- package/dist/wire.d.cts +35 -0
- package/dist/wire.d.ts +35 -0
- package/package.json +77 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/testing.ts","../../core/src/testing.ts","../../core/src/type-utils.ts","../../core/src/types.ts"],"sourcesContent":["/**\n * The `SitepingStore` conformance suite, published for third-party adapter\n * authors (requires `vitest` — an optional peer dependency of this\n * package).\n *\n * @example\n * ```ts\n * import { testSitepingStore } from \"@siteping/adapter-kit/testing\";\n * import { DrizzleStore } from \"../src/index.js\";\n *\n * testSitepingStore(() => new DrizzleStore(db));\n * ```\n */\n\nexport type { StoreConformanceOptions } from \"@siteping/core/testing\";\nexport { testSitepingStore } from \"@siteping/core/testing\";\n","/**\n * Shared conformance test suite for `SitepingStore` implementations.\n *\n * Adapters import this and run it with their store factory to verify they\n * satisfy the full store contract — no need to write the same 40+ tests\n * from scratch.\n *\n * @example\n * ```ts\n * import { testSitepingStore } from '@siteping/core/testing'\n * import { DrizzleStore } from '../src/index.js'\n *\n * testSitepingStore(() => new DrizzleStore(db))\n * ```\n */\n\nimport { beforeEach, describe, expect, it } from \"vitest\";\nimport type { DiagnosticsSnapshot, FeedbackCreateInput, SitepingStore } from \"./types.js\";\nimport { isStoreDuplicate, StoreNotFoundError } from \"./types.js\";\n\n// ---------------------------------------------------------------------------\n// Test fixture\n// ---------------------------------------------------------------------------\n\nfunction createInput(overrides?: Partial<FeedbackCreateInput>): FeedbackCreateInput {\n return {\n projectName: \"test-project\",\n type: \"bug\",\n message: \"Something is broken\",\n status: \"open\",\n url: \"https://example.com\",\n viewport: \"1920x1080\",\n userAgent: \"Mozilla/5.0\",\n authorName: \"Alice\",\n authorEmail: \"alice@test.com\",\n clientId: `client-${Date.now()}-${Math.random()}`,\n annotations: [\n {\n cssSelector: \"div.main\",\n xpath: \"/html/body/div\",\n textSnippet: \"Hello\",\n elementTag: \"DIV\",\n elementId: \"main\",\n textPrefix: \"before\",\n textSuffix: \"after\",\n fingerprint: \"3:1:abc\",\n neighborText: \"sibling\",\n xPct: 0.1,\n yPct: 0.2,\n wPct: 0.5,\n hPct: 0.3,\n scrollX: 0,\n scrollY: 100,\n viewportW: 1920,\n viewportH: 1080,\n devicePixelRatio: 2,\n },\n ],\n ...overrides,\n };\n}\n\nconst MINIMAL_ANNOTATION = {\n cssSelector: \"div\",\n xpath: \"/div\",\n textSnippet: \"\",\n elementTag: \"DIV\",\n textPrefix: \"\",\n textSuffix: \"\",\n fingerprint: \"1:0:x\",\n neighborText: \"\",\n xPct: 0,\n yPct: 0,\n wPct: 1,\n hPct: 1,\n scrollX: 0,\n scrollY: 0,\n viewportW: 1920,\n viewportH: 1080,\n devicePixelRatio: 1,\n};\n\n// ---------------------------------------------------------------------------\n// Conformance suite\n// ---------------------------------------------------------------------------\n\n/** Tuning knobs for backends whose documented contract legitimately varies. */\nexport interface StoreConformanceOptions {\n /**\n * How `createFeedback` reacts to a duplicate `clientId` — both are valid\n * per the `SitepingStore` contract:\n * - `\"return\"` (default): idempotently return the existing record.\n * - `\"throw\"`: throw `StoreDuplicateError` (matched via `isStoreDuplicate`).\n */\n duplicateBehavior?: \"return\" | \"throw\" | undefined;\n /**\n * Whether `search` matches case-insensitively. Defaults to `true` (the\n * in-memory pipeline's behavior). Set to `false` for SQL backends whose\n * collation is case-sensitive — the suite then only asserts same-case\n * substring matching.\n */\n caseInsensitiveSearch?: boolean | undefined;\n}\n\n/**\n * Run the full `SitepingStore` conformance test suite.\n *\n * @param factory — called before each test to create a fresh, empty store instance. May be async.\n * @param options — contract variations, see {@link StoreConformanceOptions}.\n */\nexport function testSitepingStore(\n factory: () => SitepingStore | Promise<SitepingStore>,\n options?: StoreConformanceOptions,\n): void {\n const duplicateBehavior = options?.duplicateBehavior ?? \"return\";\n const caseInsensitiveSearch = options?.caseInsensitiveSearch ?? true;\n\n describe(\"SitepingStore conformance\", () => {\n let store: SitepingStore;\n\n beforeEach(async () => {\n store = await factory();\n });\n\n // ------------------------------------------------------------------\n // createFeedback\n // ------------------------------------------------------------------\n\n describe(\"createFeedback\", () => {\n it(\"creates a feedback and returns a FeedbackRecord\", async () => {\n const record = await store.createFeedback(createInput());\n\n expect(record.id).toBeDefined();\n expect(record.projectName).toBe(\"test-project\");\n expect(record.type).toBe(\"bug\");\n expect(record.message).toBe(\"Something is broken\");\n expect(record.status).toBe(\"open\");\n expect(record.resolvedAt).toBeNull();\n expect(record.createdAt).toBeInstanceOf(Date);\n expect(record.updatedAt).toBeInstanceOf(Date);\n });\n\n it(\"creates annotations with feedbackId reference\", async () => {\n const record = await store.createFeedback(createInput());\n\n expect(record.annotations).toHaveLength(1);\n const [ann] = record.annotations;\n expect(ann).toBeDefined();\n expect(ann?.id).toBeDefined();\n expect(ann?.feedbackId).toBe(record.id);\n expect(ann?.cssSelector).toBe(\"div.main\");\n expect(ann?.xPct).toBe(0.1);\n expect(ann?.elementId).toBe(\"main\");\n expect(ann?.createdAt).toBeInstanceOf(Date);\n });\n\n it(\"sets elementId to null when undefined in input\", async () => {\n const record = await store.createFeedback(createInput({ annotations: [{ ...MINIMAL_ANNOTATION }] }));\n expect(record.annotations[0]?.elementId).toBeNull();\n });\n\n it(\"persists anchorKey when provided\", async () => {\n const record = await store.createFeedback(\n createInput({\n annotations: [\n {\n ...MINIMAL_ANNOTATION,\n cssSelector: \"section\",\n xpath: \"/section\",\n textSnippet: \"Services\",\n elementTag: \"SECTION\",\n anchorKey: \"order-card.services\",\n },\n ],\n }),\n );\n expect(record.annotations[0]?.anchorKey).toBe(\"order-card.services\");\n });\n\n it(\"persists anchorKey as null when omitted\", async () => {\n const record = await store.createFeedback(createInput());\n expect(record.annotations[0]?.anchorKey).toBeNull();\n });\n\n it(\"persists screenshotUrl as null when no data URL is provided\", async () => {\n const record = await store.createFeedback(createInput());\n expect(record.screenshotUrl).toBeNull();\n });\n\n it(\"persists the screenshot data URL inline when no external storage is configured\", async () => {\n // Stores without external storage (memory, localStorage) keep the\n // data URL as-is. Adapter-prisma with a `screenshotStorage` replaces\n // it with the remote URL — that path is covered by adapter-prisma tests.\n const dataUrl = \"data:image/jpeg;base64,/9j/4AAQ\"; // truncated but valid prefix\n const record = await store.createFeedback(createInput({ screenshotDataUrl: dataUrl }));\n expect(record.screenshotUrl).toBe(dataUrl);\n });\n\n it(\"persists screenshotRegion verbatim when provided\", async () => {\n const region = { xPct: 0.1234, yPct: 0.5678, wPct: 0.25, hPct: 0.125 };\n const record = await store.createFeedback(createInput({ screenshotRegion: region }));\n expect(record.screenshotRegion).toEqual(region);\n });\n\n it(\"persists screenshotRegion as null when omitted\", async () => {\n const record = await store.createFeedback(createInput());\n expect(record.screenshotRegion).toBeNull();\n });\n\n it(\"persists diagnostics verbatim when provided\", async () => {\n const diagnostics: DiagnosticsSnapshot = {\n console: [{ level: \"error\", timestamp: \"2026-01-01T00:00:00.000Z\", message: \"boom\" }],\n network: [\n {\n url: \"https://api.test/things\",\n method: \"GET\",\n status: 500,\n durationMs: 123,\n timestamp: \"2026-01-01T00:00:01.000Z\",\n },\n ],\n };\n const record = await store.createFeedback(createInput({ diagnostics }));\n expect(record.diagnostics).toEqual(diagnostics);\n });\n\n it(\"persists diagnostics as null when omitted\", async () => {\n const record = await store.createFeedback(createInput());\n expect(record.diagnostics).toBeNull();\n });\n\n if (duplicateBehavior === \"return\") {\n it(\"deduplicates by clientId (idempotent)\", async () => {\n const input = createInput({ clientId: \"same-id\" });\n const first = await store.createFeedback(input);\n const second = await store.createFeedback(input);\n\n expect(second.id).toBe(first.id);\n const { total } = await store.getFeedbacks({ projectName: \"test-project\" });\n expect(total).toBe(1);\n });\n } else {\n it(\"throws StoreDuplicateError on duplicate clientId\", async () => {\n const input = createInput({ clientId: \"same-id\" });\n await store.createFeedback(input);\n await expect(store.createFeedback(input)).rejects.toSatisfy(isStoreDuplicate);\n\n const { total } = await store.getFeedbacks({ projectName: \"test-project\" });\n expect(total).toBe(1);\n });\n }\n\n it(\"stores newest feedbacks first\", async () => {\n const a = await store.createFeedback(createInput({ message: \"first\" }));\n const b = await store.createFeedback(createInput({ message: \"second\" }));\n const { feedbacks } = await store.getFeedbacks({ projectName: \"test-project\" });\n expect(feedbacks[0]?.id).toBe(b.id);\n expect(feedbacks[1]?.id).toBe(a.id);\n });\n\n it(\"generates unique IDs across calls\", async () => {\n const a = await store.createFeedback(createInput());\n const b = await store.createFeedback(createInput());\n expect(a.id).not.toBe(b.id);\n });\n\n it(\"creates feedbacks with no annotations\", async () => {\n const record = await store.createFeedback(createInput({ annotations: [] }));\n expect(record.annotations).toHaveLength(0);\n });\n });\n\n // ------------------------------------------------------------------\n // getFeedbacks\n // ------------------------------------------------------------------\n\n describe(\"getFeedbacks\", () => {\n it(\"returns empty array when no feedbacks\", async () => {\n const result = await store.getFeedbacks({ projectName: \"test-project\" });\n expect(result.feedbacks).toHaveLength(0);\n expect(result.total).toBe(0);\n });\n\n it(\"filters by projectName\", async () => {\n await store.createFeedback(createInput({ projectName: \"a\" }));\n await store.createFeedback(createInput({ projectName: \"b\" }));\n\n const result = await store.getFeedbacks({ projectName: \"a\" });\n expect(result.total).toBe(1);\n expect(result.feedbacks[0]?.projectName).toBe(\"a\");\n });\n\n it(\"filters by type\", async () => {\n await store.createFeedback(createInput({ type: \"bug\" }));\n await store.createFeedback(createInput({ type: \"question\" }));\n\n const result = await store.getFeedbacks({ projectName: \"test-project\", type: \"bug\" });\n expect(result.feedbacks).toHaveLength(1);\n expect(result.feedbacks[0]?.type).toBe(\"bug\");\n });\n\n it(\"filters by status\", async () => {\n const fb = await store.createFeedback(createInput());\n await store.updateFeedback(fb.id, { status: \"resolved\", resolvedAt: new Date() });\n await store.createFeedback(createInput());\n\n const result = await store.getFeedbacks({ projectName: \"test-project\", status: \"open\" });\n expect(result.feedbacks).toHaveLength(1);\n });\n\n it(\"filters by status in_progress\", async () => {\n const fb = await store.createFeedback(createInput());\n await store.updateFeedback(fb.id, { status: \"in_progress\", resolvedAt: null });\n await store.createFeedback(createInput());\n\n const result = await store.getFeedbacks({ projectName: \"test-project\", status: \"in_progress\" });\n expect(result.feedbacks).toHaveLength(1);\n expect(result.feedbacks[0]?.status).toBe(\"in_progress\");\n });\n\n it(\"filters by status wont_fix\", async () => {\n const fb = await store.createFeedback(createInput());\n await store.updateFeedback(fb.id, { status: \"wont_fix\", resolvedAt: new Date() });\n await store.createFeedback(createInput());\n\n const result = await store.getFeedbacks({ projectName: \"test-project\", status: \"wont_fix\" });\n expect(result.feedbacks).toHaveLength(1);\n expect(result.feedbacks[0]?.status).toBe(\"wont_fix\");\n });\n\n it(\"filters by a statuses bucket (any of the listed values)\", async () => {\n const open = await store.createFeedback(createInput());\n const prog = await store.createFeedback(createInput());\n await store.updateFeedback(prog.id, { status: \"in_progress\", resolvedAt: null });\n const resolved = await store.createFeedback(createInput());\n await store.updateFeedback(resolved.id, { status: \"resolved\", resolvedAt: new Date() });\n\n const result = await store.getFeedbacks({\n projectName: \"test-project\",\n statuses: [\"open\", \"in_progress\"],\n });\n expect(result.total).toBe(2);\n expect(result.feedbacks.map((f) => f.id).sort()).toEqual([open.id, prog.id].sort());\n });\n\n it(\"paginates a statuses bucket with the correct total\", async () => {\n for (let i = 0; i < 3; i++) {\n const fb = await store.createFeedback(createInput());\n await store.updateFeedback(fb.id, { status: \"in_progress\", resolvedAt: null });\n }\n // A closed record that must never appear in the open bucket.\n const closed = await store.createFeedback(createInput());\n await store.updateFeedback(closed.id, { status: \"resolved\", resolvedAt: new Date() });\n\n const page1 = await store.getFeedbacks({\n projectName: \"test-project\",\n statuses: [\"open\", \"in_progress\"],\n page: 1,\n limit: 2,\n });\n expect(page1.total).toBe(3);\n expect(page1.feedbacks).toHaveLength(2);\n\n const page2 = await store.getFeedbacks({\n projectName: \"test-project\",\n statuses: [\"open\", \"in_progress\"],\n page: 2,\n limit: 2,\n });\n expect(page2.total).toBe(3);\n expect(page2.feedbacks).toHaveLength(1);\n });\n\n it(\"prefers statuses over status when both are set\", async () => {\n await store.createFeedback(createInput());\n const prog = await store.createFeedback(createInput());\n await store.updateFeedback(prog.id, { status: \"in_progress\", resolvedAt: null });\n\n // `status: \"open\"` alone would exclude the in_progress record, but the\n // `statuses` bucket wins — both records match.\n const result = await store.getFeedbacks({\n projectName: \"test-project\",\n status: \"open\",\n statuses: [\"open\", \"in_progress\"],\n });\n expect(result.total).toBe(2);\n });\n\n it(\"ignores an empty statuses array (no status filter)\", async () => {\n await store.createFeedback(createInput());\n const prog = await store.createFeedback(createInput());\n await store.updateFeedback(prog.id, { status: \"in_progress\", resolvedAt: null });\n\n const result = await store.getFeedbacks({ projectName: \"test-project\", statuses: [] });\n expect(result.total).toBe(2);\n });\n\n it(\"filters by search (same-case substring)\", async () => {\n await store.createFeedback(createInput({ message: \"Button is broken\" }));\n await store.createFeedback(createInput({ message: \"Layout looks great\" }));\n\n const result = await store.getFeedbacks({ projectName: \"test-project\", search: \"broken\" });\n expect(result.feedbacks).toHaveLength(1);\n expect(result.feedbacks[0]?.message).toBe(\"Button is broken\");\n });\n\n if (caseInsensitiveSearch) {\n it(\"filters by search (case-insensitive)\", async () => {\n await store.createFeedback(createInput({ message: \"Button is broken\" }));\n await store.createFeedback(createInput({ message: \"Layout looks great\" }));\n\n const result = await store.getFeedbacks({ projectName: \"test-project\", search: \"BROKEN\" });\n expect(result.feedbacks).toHaveLength(1);\n expect(result.feedbacks[0]?.message).toBe(\"Button is broken\");\n });\n }\n\n it(\"filters by exact url\", async () => {\n await store.createFeedback(createInput({ url: \"https://app.test/orders/42\" }));\n await store.createFeedback(createInput({ url: \"https://app.test/dashboard\" }));\n\n const result = await store.getFeedbacks({ projectName: \"test-project\", url: \"https://app.test/dashboard\" });\n expect(result.feedbacks).toHaveLength(1);\n expect(result.feedbacks[0]?.url).toBe(\"https://app.test/dashboard\");\n });\n\n it(\"filters by urlPattern\", async () => {\n await store.createFeedback(createInput({ url: \"https://app.test/orders/42\", urlPattern: \"/orders/:id\" }));\n await store.createFeedback(createInput({ url: \"https://app.test/orders/99\", urlPattern: \"/orders/:id\" }));\n await store.createFeedback(createInput({ url: \"https://app.test/dashboard\", urlPattern: \"/dashboard\" }));\n\n const result = await store.getFeedbacks({ projectName: \"test-project\", urlPattern: \"/orders/:id\" });\n expect(result.feedbacks).toHaveLength(2);\n });\n\n it(\"persists urlPattern as null when omitted from input\", async () => {\n const record = await store.createFeedback(createInput());\n expect(record.urlPattern).toBeNull();\n });\n\n it(\"paginates correctly\", async () => {\n for (let i = 0; i < 5; i++) {\n await store.createFeedback(createInput());\n }\n\n const page1 = await store.getFeedbacks({ projectName: \"test-project\", page: 1, limit: 2 });\n expect(page1.feedbacks).toHaveLength(2);\n expect(page1.total).toBe(5);\n\n const page3 = await store.getFeedbacks({ projectName: \"test-project\", page: 3, limit: 2 });\n expect(page3.feedbacks).toHaveLength(1);\n });\n\n it(\"caps limit at 100\", async () => {\n // 105 records so a limit above the cap actually exercises it.\n for (let i = 0; i < 105; i++) {\n await store.createFeedback(createInput({ annotations: [] }));\n }\n const result = await store.getFeedbacks({ projectName: \"test-project\", limit: 200 });\n expect(result.total).toBe(105);\n expect(result.feedbacks).toHaveLength(100);\n });\n });\n\n // ------------------------------------------------------------------\n // findByClientId\n // ------------------------------------------------------------------\n\n describe(\"findByClientId\", () => {\n it(\"returns the record when found\", async () => {\n const created = await store.createFeedback(createInput({ clientId: \"find-me\" }));\n const found = await store.findByClientId(\"find-me\");\n expect(found).not.toBeNull();\n expect(found?.id).toBe(created.id);\n });\n\n it(\"returns null when not found\", async () => {\n expect(await store.findByClientId(\"nope\")).toBeNull();\n });\n });\n\n // ------------------------------------------------------------------\n // updateFeedback\n // ------------------------------------------------------------------\n\n describe(\"updateFeedback\", () => {\n it(\"updates status to resolved with resolvedAt\", async () => {\n const fb = await store.createFeedback(createInput());\n const resolvedAt = new Date();\n const updated = await store.updateFeedback(fb.id, { status: \"resolved\", resolvedAt });\n\n expect(updated.status).toBe(\"resolved\");\n expect(updated.resolvedAt).toEqual(resolvedAt);\n expect(updated.updatedAt.getTime()).toBeGreaterThanOrEqual(fb.updatedAt.getTime());\n });\n\n it(\"updates status to in_progress with resolvedAt null\", async () => {\n const fb = await store.createFeedback(createInput());\n const updated = await store.updateFeedback(fb.id, { status: \"in_progress\", resolvedAt: null });\n\n expect(updated.status).toBe(\"in_progress\");\n expect(updated.resolvedAt).toBeNull();\n });\n\n it(\"updates status to wont_fix with the given resolvedAt\", async () => {\n const fb = await store.createFeedback(createInput());\n const resolvedAt = new Date();\n const updated = await store.updateFeedback(fb.id, { status: \"wont_fix\", resolvedAt });\n\n expect(updated.status).toBe(\"wont_fix\");\n expect(updated.resolvedAt).toEqual(resolvedAt);\n });\n\n it(\"throws StoreNotFoundError for unknown id\", async () => {\n await expect(store.updateFeedback(\"unknown\", { status: \"resolved\", resolvedAt: new Date() })).rejects.toThrow(\n StoreNotFoundError,\n );\n });\n\n it(\"can reopen a closed feedback\", async () => {\n const fb = await store.createFeedback(createInput());\n await store.updateFeedback(fb.id, { status: \"resolved\", resolvedAt: new Date() });\n const reopened = await store.updateFeedback(fb.id, { status: \"open\", resolvedAt: null });\n expect(reopened.status).toBe(\"open\");\n expect(reopened.resolvedAt).toBeNull();\n\n await store.updateFeedback(fb.id, { status: \"wont_fix\", resolvedAt: new Date() });\n const reopenedAgain = await store.updateFeedback(fb.id, { status: \"open\", resolvedAt: null });\n expect(reopenedAgain.status).toBe(\"open\");\n expect(reopenedAgain.resolvedAt).toBeNull();\n });\n });\n\n // ------------------------------------------------------------------\n // deleteFeedback\n // ------------------------------------------------------------------\n\n describe(\"deleteFeedback\", () => {\n it(\"removes the feedback\", async () => {\n const fb = await store.createFeedback(createInput());\n await store.deleteFeedback(fb.id);\n const { total } = await store.getFeedbacks({ projectName: \"test-project\" });\n expect(total).toBe(0);\n });\n\n it(\"throws StoreNotFoundError for unknown id\", async () => {\n await expect(store.deleteFeedback(\"unknown\")).rejects.toThrow(StoreNotFoundError);\n });\n });\n\n // ------------------------------------------------------------------\n // deleteAllFeedbacks\n // ------------------------------------------------------------------\n\n describe(\"deleteAllFeedbacks\", () => {\n it(\"removes all feedbacks for a project but keeps others\", async () => {\n await store.createFeedback(createInput({ projectName: \"delete-me\" }));\n await store.createFeedback(createInput({ projectName: \"delete-me\" }));\n await store.createFeedback(createInput({ projectName: \"keep-me\" }));\n\n await store.deleteAllFeedbacks(\"delete-me\");\n\n expect((await store.getFeedbacks({ projectName: \"delete-me\" })).total).toBe(0);\n expect((await store.getFeedbacks({ projectName: \"keep-me\" })).total).toBe(1);\n });\n\n it(\"is a no-op when project has no feedbacks\", async () => {\n await expect(store.deleteAllFeedbacks(\"nonexistent\")).resolves.toBeUndefined();\n });\n });\n\n // ------------------------------------------------------------------\n // verifyProjectOwnership (optional contract member)\n // ------------------------------------------------------------------\n\n describe(\"verifyProjectOwnership\", () => {\n it(\"returns true for the owning project, false otherwise (when implemented)\", async () => {\n // Optional member — stores without it skip the assertion but the\n // test still runs, so implementing it later is covered automatically.\n if (!store.verifyProjectOwnership) return;\n\n const fb = await store.createFeedback(createInput({ projectName: \"owner\" }));\n await expect(store.verifyProjectOwnership(fb.id, \"owner\")).resolves.toBe(true);\n await expect(store.verifyProjectOwnership(fb.id, \"intruder\")).resolves.toBe(false);\n await expect(store.verifyProjectOwnership(\"unknown-id\", \"owner\")).resolves.toBe(false);\n });\n });\n });\n}\n","/**\n * General-purpose TypeScript utility types used across `@siteping/*`.\n *\n * These are kept dependency-free and re-exported from the package entry\n * so adapters and integrators can rely on the same primitives the core\n * uses internally.\n */\n\n/**\n * Force TypeScript to expand a computed type into a flat object literal in\n * tooltips and error messages. Purely cosmetic — same structural type, just\n * easier to read.\n *\n * @example\n * type Raw = Omit<FeedbackRecord, \"annotations\"> & { annotations: number };\n * type Pretty = Prettify<Raw>; // displayed as a flat object\n */\nexport type Prettify<T> = { [K in keyof T]: T[K] } & {};\n\n/**\n * Returns `Y` when `A` is exactly assignable to `B` and vice-versa,\n * otherwise `N`. Powers compile-time equality assertions.\n */\nexport type IfEquals<A, B, Y = true, N = false> =\n (<T>() => T extends A ? 1 : 2) extends <T>() => T extends B ? 1 : 2 ? Y : N;\n\n/**\n * Compile-time exact-type guard — resolves to `true` when `Actual` and\n * `Expected` are identical, `never` otherwise. Assign the result to a\n * `const _lock: AssertEqual<A, B> = true;` so any drift becomes a compile\n * error at the declaration site.\n */\nexport type AssertEqual<Actual, Expected> = IfEquals<Actual, Expected, true, never>;\n\n/**\n * JSON-serialized shape of `T` — the wire form produced by `Response.json()`\n * / `JSON.stringify`: `Date` becomes ISO `string` (nullability preserved),\n * arrays are serialized element-wise, everything else is untouched.\n *\n * Used to derive the `*Response` API types from the `*Record` store types so\n * the two can never drift: add a field to `FeedbackRecord` and\n * `FeedbackResponse` follows automatically.\n */\nexport type Serialized<T> = {\n [K in keyof T]: T[K] extends Date\n ? string\n : T[K] extends Date | null\n ? string | null\n : T[K] extends (infer U)[]\n ? Serialized<U>[]\n : T[K];\n};\n\n/**\n * Type guard that narrows `value` to a non-null `Record<PropertyKey, unknown>`.\n * Useful when validating arbitrary inputs before reading fields.\n */\nexport function isRecord(value: unknown): value is Record<PropertyKey, unknown> {\n return typeof value === \"object\" && value !== null;\n}\n\n/**\n * Returns true when `value` is an object that exposes the requested key.\n * Type-narrows `value` so the property can be accessed without further\n * casting — a strictly typed replacement for `\"k\" in obj`.\n *\n * Named after the standardised `Object.hasOwn` helper rather than the\n * legacy `Object.prototype.hasOwnProperty`, which the linter forbids\n * shadowing.\n */\nexport function hasOwn<K extends PropertyKey>(value: unknown, key: K): value is Record<K, unknown> {\n return isRecord(value) && key in value;\n}\n","import { type AssertEqual, hasOwn, type Prettify, type Serialized } from \"./type-utils.js\";\n\n// ---------------------------------------------------------------------------\n// Config\n// ---------------------------------------------------------------------------\n\n/** FAB anchor — bottom-corner placement supported by the widget. */\nexport type SitepingPosition = \"bottom-right\" | \"bottom-left\";\n\n/** Visual theme — `auto` resolves to `light` or `dark` via system preference. */\nexport type SitepingTheme = \"light\" | \"dark\" | \"auto\";\n\n/** Built-in UI locales shipped with the widget. */\nexport const BUILTIN_LOCALES = [\"en\", \"fr\", \"de\", \"es\", \"it\", \"pt\", \"ru\"] as const;\nexport type BuiltinLocale = (typeof BUILTIN_LOCALES)[number];\n\n/**\n * Locale identifier accepted by the widget. Built-in locales are kept as\n * literal strings so editors auto-complete them, but arbitrary BCP-47 tags\n * are also accepted (custom dictionaries registered via `registerLocale`).\n */\nexport type SitepingLocale = BuiltinLocale | (string & {});\n\n/**\n * Reasons reported through `SitepingConfig.onSkip` — production environment,\n * mobile viewport, or server-side rendering (no `window`/`document`).\n */\nexport type SitepingSkipReason = \"production\" | \"mobile\" | \"ssr\";\n\n/** Per-channel + per-buffer-size diagnostics configuration. */\nexport interface DiagnosticsCaptureOptions {\n console?: boolean | undefined;\n network?: boolean | undefined;\n maxConsoleEntries?: number | undefined;\n maxNetworkEntries?: number | undefined;\n}\n\n/** Identity payload supplied by the host application — bypasses the modal. */\nexport interface SitepingIdentity {\n name: string;\n email: string;\n}\n\n/** Deep-link configuration — controls how a feedback id is read from the URL. */\nexport interface SitepingDeepLinkOptions {\n /** Query parameter name carrying the feedback id. Defaults to `\"siteping\"`. */\n param?: string | undefined;\n}\n\n/**\n * Extra request headers for HTTP mode — a static map, or a factory (sync or\n * async) invoked once per request to produce fresh values (e.g. a short-lived\n * session token).\n */\nexport type SitepingHeadersOption =\n | Record<string, string>\n | (() => Record<string, string> | Promise<Record<string, string>>);\n\n/**\n * Options shared by both widget modes (HTTP and direct store).\n *\n * Do not use this type directly — use {@link SitepingConfig}, the\n * discriminated union that adds the mode-specific fields.\n */\nexport interface SitepingBaseConfig {\n /** Required — project identifier used to scope feedbacks */\n projectName: string;\n /** FAB position — defaults to 'bottom-right' */\n position?: SitepingPosition | undefined;\n /**\n * Show the \"toggle markers visibility\" item in the FAB radial menu.\n * Defaults to `true` (current behavior). Set to `false` to hide that\n * item entirely — useful for hosts that always want markers visible\n * (e.g. dedicated review tools) or that find the eye icon redundant\n * when no marker is on screen.\n *\n * Hiding the item also removes its keyboard navigation slot — the\n * remaining two items still respond to ArrowUp/ArrowDown/Home/End.\n * The marker-visibility state itself is unaffected; markers stay\n * visible (the previous default state) and `annotations:toggle` is\n * simply never emitted from the FAB.\n */\n showAnnotationsToggle?: boolean | undefined;\n /** Accent color for the widget UI — defaults to '#0066ff' */\n accentColor?: string | undefined;\n /**\n * Render the widget even when it would normally be skipped — this bypasses\n * BOTH the production-environment guard AND the mobile-viewport guard.\n * It does NOT bypass the SSR guard: without `window`/`document` the widget\n * never renders and `onSkip(\"ssr\")` fires instead.\n * Defaults to false. Use it for dedicated review tools, staging environments,\n * or responsive testing where you always want the widget present.\n */\n forceShow?: boolean | undefined;\n /**\n * Minimum viewport width (px) at or above which the widget renders. Below it,\n * the widget is skipped and `onSkip(\"mobile\")` fires. Defaults to `768`.\n *\n * Set lower (e.g. `0`) to allow narrow/mobile viewports, or use `forceShow`\n * to bypass the viewport check entirely.\n */\n minViewportWidth?: number | undefined;\n /** Enable debug logging of lifecycle events — defaults to false */\n debug?: boolean | undefined;\n /** Color theme — defaults to 'light' */\n theme?: SitepingTheme | undefined;\n /** UI locale — defaults to 'en'. Built-in: en, fr, de, es, it, pt (Brazilian), ru. Any other string falls back to English. */\n locale?: SitepingLocale | undefined;\n /**\n * Returns the current page scope for annotations and panel filtering.\n * Called on initial markers load and on `instance.refresh()`.\n *\n * Default: `{ url: window.location.pathname, urlPattern: null }` — annotations\n * are scoped strictly to the current pathname.\n *\n * Apps with parameterized routes (e.g. React Router) should return both the\n * concrete URL and the route template (e.g. `/orders/:orderId`) so the panel\n * can offer a \"this type of page\" filter that groups feedbacks by template.\n */\n getPageScope?: (() => PageScope) | undefined;\n /**\n * When true (default), the widget filters initial markers and panel results\n * by `feedback.url === scope.url`, so annotations created on one page never\n * leak to other pages — even if their CSS selector accidentally matches.\n * Set to `false` to revert to the legacy project-wide behavior.\n */\n scopeAnnotationsByUrl?: boolean | undefined;\n /**\n * Capture a JPEG screenshot of the annotated area on submit. Defaults to\n * `false` — opt-in because:\n *\n * - it adds runtime weight (~40 KB gzip dynamic chunk for html2canvas,\n * loaded only on first capture),\n * - it embeds page content in the feedback (privacy/GDPR consideration —\n * inform end users in your widget host UI when enabling).\n *\n * `html2canvas` ships as a regular dependency of `@siteping/widget` so the\n * dynamic import always resolves; you don't need to install anything extra.\n *\n * **Masking sensitive elements:** add `data-siteping-ignore=\"true\"` to any\n * element you do NOT want captured (password fields, credit-card forms,\n * API tokens shown in the UI, etc.). The capture predicate skips matching\n * elements *and their descendants*. Do this BEFORE turning on screenshots\n * in production — once a feedback is saved, the screenshot is in your DB\n * (or object storage) regardless of what was on the page.\n */\n enableScreenshot?: boolean | undefined;\n /**\n * Enable right-click (`contextmenu`) to instantly open the comment composer\n * at the cursor location. When enabled, a document-level listener intercepts\n * right-clicks, prevents the browser's native context menu, and enters the\n * annotation flow anchored to the element under the cursor. Defaults to\n * `false` — the browser's native context menu is never hijacked unless the\n * host explicitly opts in.\n *\n * Keyboard-triggered context menus (≣ Menu key, Shift+F10) always get the\n * native menu; only mouse right-click and touch/pen long-press open the\n * composer.\n *\n * **Modifier-key escape hatch:** holding Shift, Ctrl, Alt, or Meta while\n * right-clicking always falls through to the native context menu, giving\n * users (and devtools) an escape hatch regardless of this setting.\n *\n * Right-clicks on SitePing's own UI (FAB, panel, markers, popup) are\n * ignored — the native menu is shown as expected.\n *\n * Note: on Android, `contextmenu` fires on long-press. The widget already\n * hides below `minViewportWidth` (default 768 px), but tablets above that\n * threshold will trigger this flow on long-press.\n */\n enableRightClickComment?: boolean | undefined;\n /**\n * Capture the last few `console.*` calls and failed network requests\n * (HTTP >= 400 or network error) at the moment a feedback is submitted.\n *\n * Lets reviewers replay the technical context that led to the report —\n * stack traces, 500 responses, dead third-party scripts. Great for the\n * \"the page just doesn't work\" feedback that contains zero detail.\n *\n * - `true` — capture with defaults (50 console / 20 network entries).\n * - `false` (default) — no capture, no monkey-patching.\n * - object — per-channel toggles + custom buffer sizes.\n *\n * **Privacy considerations:** console messages may contain anything the\n * host page logs, including user data. Failed network requests record the\n * URL (with query string) but never the response body. Inform end users\n * before enabling in environments where they might log sensitive values.\n */\n captureDiagnostics?: boolean | DiagnosticsCaptureOptions | undefined;\n /** Called when the widget is skipped (production mode, mobile viewport, SSR — no DOM) */\n onSkip?: (reason: SitepingSkipReason) => void;\n /**\n * Auto-focus a specific annotation when its ID appears in the URL query\n * string. Lets hosts deeplink directly into a feedback from external\n * systems (Zammad tickets, Slack notifications, dashboard rows).\n *\n * When enabled, the widget reads the configured query parameter from\n * `window.location.search` right after the initial markers load. If the\n * value matches a visible feedback ID, the widget scrolls the annotation\n * into view, pins its highlight, and pulses the marker — the same visual\n * affordance a marker click produces.\n *\n * - `false` / `undefined` (default): no URL parsing. Existing behavior\n * unchanged, no host URL inspection.\n * - `true`: enabled with default query parameter name `siteping`.\n * - object: enabled with a custom parameter name. Use this to avoid\n * clashes with host-app query keys.\n *\n * Only the initial load triggers focus. Subsequent URL changes (SPA\n * navigation, `history.pushState`, hash updates) are ignored —\n * deliberate, to avoid surprising re-scrolls during normal browsing.\n * Hosts that need re-focus on route change can call\n * `instance.focusFeedback(id)` explicitly.\n */\n deepLink?: boolean | SitepingDeepLinkOptions | undefined;\n /**\n * Automatically re-fetch feedbacks when the page changes during client-side\n * (SPA) navigation. Enabled by default.\n *\n * The widget is normally mounted once (singleton) inside a persistent layout\n * — e.g. a Next.js App Router `layout.tsx`, which does NOT remount on\n * client-side navigation. Without this, init runs a single time and both the\n * panel list and the page markers stay frozen on the page where the widget\n * first mounted. With it on, the widget patches the History API\n * (`pushState`/`replaceState`, which SPA routers call instead of triggering\n * `popstate`) and listens for `popstate`/`hashchange`, then re-fetches when\n * the scope key (`getPageScope().url` + template) actually changes.\n *\n * This re-fetches data only — it deliberately does NOT re-focus or re-scroll\n * to an annotation (deep-link focus stays initial-load only; see `deepLink`),\n * so normal browsing is never interrupted by a surprise scroll.\n *\n * - `true` (default) — watch navigation and re-fetch on route change.\n * - `false` — never touch the History API; hosts drive updates manually via\n * `instance.refresh()`.\n */\n watchNavigation?: boolean | undefined;\n /**\n * Pre-fill author identity from the host application — typically the\n * currently signed-in user. When set, the widget uses these values\n * directly and never shows the identity modal, even on first feedback.\n *\n * Use case: SSO-integrated apps where the end user is already\n * authenticated by the host. Avoids the awkward \"enter your name and\n * email\" prompt for users the host already knows.\n *\n * When unset (default), the widget falls back to localStorage and shows\n * the modal on first feedback as before — existing behavior unchanged.\n *\n * Note: `config.identity` is **not** persisted to localStorage. It is\n * read at widget init time, not on every render. Hosts that need live\n * identity updates after sign-in/sign-out should currently remount the\n * widget (e.g. via a React `key` on the wrapping component). See\n * https://github.com/NeosiaNexus/SitePing/issues/85 for tracking a\n * future enhancement that propagates identity updates without a remount.\n */\n identity?: SitepingIdentity | undefined;\n\n // Events\n /** Called when the feedback panel is opened. */\n onOpen?: (() => void) | undefined;\n /** Called when the feedback panel is closed. */\n onClose?: (() => void) | undefined;\n /** Called after a feedback is successfully submitted. */\n onFeedbackSent?: ((feedback: FeedbackResponse) => void) | undefined;\n /**\n * Called when a feedback API call fails.\n *\n * The widget always emits a `SitepingError` (or a subclass:\n * `SitepingNetworkError`, `SitepingValidationError`, `SitepingAuthError`)\n * for HTTP-mode failures — host apps can `instanceof` to drive retry\n * logic, or read `error.code` (`\"NETWORK\" | \"VALIDATION\" | \"AUTH\" |\n * \"SERVER\"`) and `error.retryable`. The type is widened to `Error` so\n * direct-store callers can still surface raw errors without breaking the\n * contract.\n */\n onError?: ((error: Error) => void) | undefined;\n /** Called when the user starts drawing an annotation. */\n onAnnotationStart?: (() => void) | undefined;\n /** Called when the user finishes drawing an annotation. */\n onAnnotationEnd?: (() => void) | undefined;\n}\n\n/**\n * HTTP mode — the widget talks to a server endpoint backed by a store\n * adapter (e.g. `@siteping/adapter-prisma` request handlers).\n */\nexport interface SitepingHttpConfig extends SitepingBaseConfig {\n /** HTTP endpoint that receives feedbacks (e.g. '/api/siteping'). */\n endpoint: string;\n /**\n * Convenience auth for HTTP mode — sent as `Authorization: Bearer <apiKey>`\n * on every request to `endpoint`.\n *\n * **WARNING: the widget runs in every visitor's browser, so a static key\n * configured here is public** — anyone can read it from your page source\n * and replay it against your API. Only use `apiKey` for internal tools\n * already behind your own login. On public sites, prefer `headers` with a\n * per-request factory returning a short-lived session token.\n */\n apiKey?: string | undefined;\n /**\n * Extra headers for every HTTP-mode request — a static map, or a factory\n * (sync or async) called once per request (e.g. to fetch a fresh session\n * token). Merged over the widget's generated headers, so an explicit\n * `Authorization` entry overrides `apiKey`. A throwing/rejecting factory\n * fails the request like a network error.\n */\n headers?: SitepingHeadersOption | undefined;\n /** Not available in HTTP mode — use either `endpoint` or `store`, never both. */\n store?: never;\n}\n\n/**\n * Store mode — the widget talks to a `SitepingStore` directly in the\n * browser, no server needed (demos, prototypes, localStorage persistence).\n */\nexport interface SitepingStoreConfig extends SitepingBaseConfig {\n /** Direct store for client-side mode. Bypasses HTTP entirely. */\n store: SitepingStore;\n /** Not available in store mode — use either `endpoint` or `store`, never both. */\n endpoint?: never;\n /** HTTP-mode only — meaningless without an `endpoint`. */\n apiKey?: never;\n /** HTTP-mode only — meaningless without an `endpoint`. */\n headers?: never;\n}\n\n/**\n * Configuration options for the Siteping widget.\n *\n * A discriminated union over the two transport modes: pass `endpoint`\n * (HTTP mode, optionally with `apiKey`/`headers`) **or** `store` (direct\n * client-side mode) — never both, never neither. Invalid combinations are\n * compile errors instead of runtime warnings.\n */\nexport type SitepingConfig = SitepingHttpConfig | SitepingStoreConfig;\n\n/** Instance returned by initSiteping() with lifecycle methods. */\nexport interface SitepingInstance {\n /** Remove the widget from the DOM and clean up all listeners. */\n destroy: () => void;\n /** Open the panel programmatically */\n open: () => void;\n /** Close the panel */\n close: () => void;\n /** Reload feedbacks from server */\n refresh: () => void;\n /**\n * Scroll the matching annotation into view, pin its highlight, and\n * pulse its marker. Returns `true` when a visible feedback matched the\n * given ID, `false` otherwise (unknown ID, feedback on another URL when\n * `scopeAnnotationsByUrl` filtered it out, or markers not yet loaded).\n *\n * Counterpart to the `deepLink` config option for hosts that prefer to\n * drive focus from JS (e.g., a notification click handler) instead of a\n * URL query parameter.\n */\n focusFeedback: (feedbackId: string) => boolean;\n /** Subscribe to a public widget event */\n on: <K extends keyof SitepingPublicEvents>(event: K, listener: SitepingPublicEventListener<K>) => SitepingUnsubscribe;\n /** Unsubscribe from a public widget event */\n off: <K extends keyof SitepingPublicEvents>(event: K, listener: SitepingPublicEventListener<K>) => void;\n}\n\n/** Listener signature for a single `SitepingPublicEvents` key. */\nexport type SitepingPublicEventListener<K extends keyof SitepingPublicEvents> = (\n ...args: SitepingPublicEvents[K]\n) => void;\n\n/** Disposer returned by `SitepingInstance.on` — call once to detach the listener. */\nexport type SitepingUnsubscribe = () => void;\n\n/** Events exposed to consumers via SitepingInstance.on / .off */\nexport interface SitepingPublicEvents {\n \"feedback:sent\": [FeedbackResponse];\n \"feedback:deleted\": [FeedbackResponse[\"id\"]];\n /**\n * A feedback API call failed. Same payload contract as\n * `SitepingConfig.onError` — a `SitepingError` subclass in HTTP mode,\n * possibly a raw `Error` in store mode.\n */\n \"feedback:error\": [Error];\n \"panel:open\": [];\n \"panel:close\": [];\n /** The user started drawing an annotation. */\n \"annotation:start\": [];\n /** The user finished drawing an annotation. */\n \"annotation:end\": [];\n}\n\n// ---------------------------------------------------------------------------\n// Feedback\n// ---------------------------------------------------------------------------\n\n/** Single source of truth for feedback types — used by both TS types and Zod schemas. */\nexport const FEEDBACK_TYPES = [\"question\", \"change\", \"bug\", \"other\"] as const;\nexport type FeedbackType = (typeof FEEDBACK_TYPES)[number];\n\n/** Single source of truth for feedback statuses. */\nexport const FEEDBACK_STATUSES = [\"open\", \"in_progress\", \"resolved\", \"wont_fix\"] as const;\nexport type FeedbackStatus = (typeof FEEDBACK_STATUSES)[number];\n\n/**\n * Terminal statuses — the feedback needs no further action. `resolvedAt` is\n * the closure timestamp: set when a feedback enters a closed status, null\n * while it is open or in progress. The derivation happens at the edge (HTTP\n * handler, dashboard) — store adapters persist whatever they are given.\n */\nexport const CLOSED_FEEDBACK_STATUSES = [\"resolved\", \"wont_fix\"] as const;\n/** A terminal status — `resolved` or `wont_fix`. */\nexport type ClosedFeedbackStatus = (typeof CLOSED_FEEDBACK_STATUSES)[number];\n\n/** Non-terminal statuses — the feedback still needs attention. */\nexport const OPEN_FEEDBACK_STATUSES = [\"open\", \"in_progress\"] as const;\n/** A non-terminal status — `open` or `in_progress`. */\nexport type OpenFeedbackStatus = (typeof OPEN_FEEDBACK_STATUSES)[number];\n\n// Adding a fifth status without assigning it to exactly one bucket is a\n// compile error here.\nconst _statusBucketsCoverAll: AssertEqual<OpenFeedbackStatus | ClosedFeedbackStatus, FeedbackStatus> = true;\nvoid _statusBucketsCoverAll;\n\n/** Whether a status is terminal (`resolved` or `wont_fix`). Narrows the status type. */\nexport function isClosedStatus(status: FeedbackStatus): status is ClosedFeedbackStatus {\n return (CLOSED_FEEDBACK_STATUSES as readonly FeedbackStatus[]).includes(status);\n}\n\n/**\n * Page scope returned by `SitepingConfig.getPageScope()`.\n *\n * - `url`: concrete page identifier — usually `window.location.pathname`,\n * used as the strict scope for marker rendering.\n * - `urlPattern`: optional parameterized template (e.g. `/orders/:orderId`)\n * used by the panel's \"this type of page\" filter to group feedbacks across\n * instances of the same page kind.\n */\nexport interface PageScope {\n url: string;\n urlPattern: string | null;\n}\n\n// ---------------------------------------------------------------------------\n// Abstract Store — adapter pattern\n// ---------------------------------------------------------------------------\n\n/** Input for creating a feedback record in the store. */\nexport interface FeedbackCreateInput {\n projectName: string;\n type: FeedbackType;\n message: string;\n status: FeedbackStatus;\n url: string;\n /**\n * Optional parameterized URL template (e.g. `/orders/:orderId`) for the page\n * where the feedback was created. Allows the panel to filter feedbacks by\n * \"this type of page\" across different instances. Null when the host did not\n * provide a `getPageScope` callback or the route has no template.\n */\n urlPattern?: string | null | undefined;\n viewport: string;\n userAgent: string;\n authorName: string;\n authorEmail: string;\n clientId: string;\n annotations: AnnotationCreateInput[];\n /**\n * Base64 JPEG `data:` URL captured by the widget at submit time.\n *\n * Adapters with a configured `ScreenshotStorage` are expected to upload\n * this and persist the returned URL on `FeedbackRecord.screenshotUrl`.\n * Adapters without storage may persist the data URL inline (memory /\n * localStorage / dev) — the widget then renders it directly.\n */\n screenshotDataUrl?: string | null | undefined;\n /**\n * Where the client's annotation rect sits within the screenshot image,\n * as fractions [0, 1] of the image dimensions. Present when the widget\n * captured context around the drawn rect; null for legacy captures that\n * were cropped exactly to the rect (dashboards then render the image\n * without an overlay).\n */\n screenshotRegion?: ScreenshotRegion | null | undefined;\n /**\n * Optional console + failed-network snapshot captured by the widget when\n * `SitepingConfig.captureDiagnostics` is enabled. Stored as JSON on\n * `FeedbackRecord.diagnostics` so reviewers can replay the context.\n */\n diagnostics?: DiagnosticsSnapshot | null | undefined;\n}\n\n/** Input for a single annotation when creating a feedback. */\nexport interface AnnotationCreateInput {\n cssSelector: string;\n xpath: string;\n textSnippet: string;\n elementTag: string;\n elementId?: string | undefined;\n textPrefix: string;\n textSuffix: string;\n fingerprint: string;\n neighborText: string;\n /**\n * Semantic anchor identifier from the closest ancestor's `data-feedback-anchor`\n * attribute. When set, this is the most stable re-anchoring signal because\n * hosts deliberately place these on layout/section roots that survive DOM\n * refactors and viewport changes. Null when no semantic ancestor exists.\n */\n anchorKey?: string | null | undefined;\n xPct: number;\n yPct: number;\n wPct: number;\n hPct: number;\n scrollX: number;\n scrollY: number;\n viewportW: number;\n viewportH: number;\n devicePixelRatio: number;\n}\n\n/** Query parameters for fetching feedbacks. */\nexport interface FeedbackQuery {\n projectName: string;\n type?: FeedbackType | undefined;\n /** Exact single-status filter. For \"any of a set\" (bucket) semantics, use `statuses`. */\n status?: FeedbackStatus | undefined;\n /**\n * Filter to feedbacks whose status is any of the listed values — bucket\n * semantics used by the panel's binary tabs (e.g. \"Open\" passes\n * `[\"open\", \"in_progress\"]`). When both `status` and `statuses` are set,\n * `statuses` wins. An empty array is treated as absent (no status filter).\n */\n statuses?: readonly FeedbackStatus[] | undefined;\n search?: string | undefined;\n page?: number | undefined;\n limit?: number | undefined;\n /**\n * Filter to feedbacks created on this exact URL (path). Used by the panel's\n * \"this page\" filter and by the markers loader to keep page scopes isolated.\n */\n url?: string | undefined;\n /**\n * Filter to feedbacks created on this URL pattern (e.g. `/orders/:orderId`).\n * Used by the panel's \"this type of page\" filter to group feedbacks across\n * different concrete instances of the same template.\n */\n urlPattern?: string | undefined;\n}\n\n/**\n * Update payload for patching a feedback.\n *\n * A discriminated union encoding the closure invariant: a feedback entering\n * a closed status carries its closure timestamp, an open one carries `null`.\n * `{ status: \"resolved\", resolvedAt: null }` is a compile error instead of a\n * silent data bug. Build it from a plain `FeedbackStatus` with\n * {@link toFeedbackUpdate}.\n */\nexport type FeedbackUpdateInput =\n | { status: OpenFeedbackStatus; resolvedAt: null }\n | { status: ClosedFeedbackStatus; resolvedAt: Date };\n\n/**\n * Derive the {@link FeedbackUpdateInput} for a status change — the closure\n * timestamp is stamped for closed statuses and cleared otherwise. This is\n * the edge derivation described on {@link CLOSED_FEEDBACK_STATUSES}; store\n * adapters persist the result verbatim.\n */\nexport function toFeedbackUpdate(status: FeedbackStatus, closedAt: Date = new Date()): FeedbackUpdateInput {\n return isClosedStatus(status) ? { status, resolvedAt: closedAt } : { status, resolvedAt: null };\n}\n\n/** A persisted feedback record returned by the store. */\nexport interface FeedbackRecord {\n id: string;\n type: FeedbackType;\n message: string;\n status: FeedbackStatus;\n projectName: string;\n url: string;\n /**\n * Parameterized URL template the feedback was created on.\n * Null for legacy records or hosts without `getPageScope`.\n */\n urlPattern: string | null;\n authorName: string;\n authorEmail: string;\n viewport: string;\n userAgent: string;\n clientId: string;\n resolvedAt: Date | null;\n createdAt: Date;\n updatedAt: Date;\n annotations: AnnotationRecord[];\n /**\n * URL the widget renders as `<img src>`. Either an `https://...` from a\n * configured `ScreenshotStorage`, or a `data:image/jpeg;base64,...` URL\n * inline-persisted by adapters without storage. Null when no screenshot\n * was captured (legacy records, capture failed, or host disabled it).\n */\n screenshotUrl: string | null;\n /**\n * Annotation rect position within the screenshot image, as fractions of\n * its dimensions. Null for legacy captures cropped exactly to the rect.\n */\n screenshotRegion: ScreenshotRegion | null;\n /**\n * Console + failed-network snapshot captured at submit time. Null when\n * diagnostics weren't enabled on the widget side.\n */\n diagnostics: DiagnosticsSnapshot | null;\n}\n\n/** A persisted annotation record returned by the store. */\nexport interface AnnotationRecord {\n id: string;\n feedbackId: string;\n cssSelector: string;\n xpath: string;\n textSnippet: string;\n elementTag: string;\n elementId: string | null;\n textPrefix: string;\n textSuffix: string;\n fingerprint: string;\n neighborText: string;\n /**\n * Semantic anchor identifier from `data-feedback-anchor`. Null for legacy\n * annotations or those drawn outside any anchored region.\n */\n anchorKey: string | null;\n xPct: number;\n yPct: number;\n wPct: number;\n hPct: number;\n scrollX: number;\n scrollY: number;\n viewportW: number;\n viewportH: number;\n devicePixelRatio: number;\n createdAt: Date;\n}\n\n// ---------------------------------------------------------------------------\n// Store errors — throw these from adapter implementations\n// ---------------------------------------------------------------------------\n\n/**\n * Thrown when a record is not found during update or delete.\n *\n * Handlers translate this to HTTP 404. Adapters MUST throw this (not\n * ORM-specific errors) so the handler layer remains ORM-agnostic.\n */\nexport class StoreNotFoundError extends Error {\n readonly code = \"STORE_NOT_FOUND\" as const;\n constructor(message = \"Record not found\") {\n super(message);\n this.name = \"StoreNotFoundError\";\n }\n}\n\n/**\n * Thrown when a unique constraint is violated (e.g. duplicate `clientId`).\n *\n * Handlers use this to return the existing record instead of failing.\n */\nexport class StoreDuplicateError extends Error {\n readonly code = \"STORE_DUPLICATE\" as const;\n constructor(message = \"Duplicate record\") {\n super(message);\n this.name = \"StoreDuplicateError\";\n }\n}\n\n/**\n * Thrown when a store accepts a mutation but cannot persist it — e.g.\n * `localStorage` is full (QuotaExceededError). Adapters MUST throw this rather\n * than swallow the failure, so callers learn the write was lost instead of\n * seeing a phantom success.\n */\nexport class StorePersistenceError extends Error {\n readonly code = \"STORE_PERSISTENCE\" as const;\n constructor(message = \"Failed to persist store mutation\", options?: ErrorOptions) {\n super(message, options);\n this.name = \"StorePersistenceError\";\n }\n}\n\n/** Shape of any ORM error that carries a Prisma-style `code` field. */\ntype CodedError<C extends string = string> = { code: C };\n\nfunction hasErrorCode<C extends string>(error: unknown, code: C): error is CodedError<C> {\n return hasOwn(error, \"code\") && error.code === code;\n}\n\n/** Type guard — works for `StoreNotFoundError` and ORM-specific equivalents (e.g. Prisma P2025). */\nexport function isStoreNotFound(error: unknown): error is StoreNotFoundError | CodedError<\"P2025\"> {\n if (error instanceof StoreNotFoundError) return true;\n // Backwards compat: Prisma's P2025\n return hasErrorCode(error, \"P2025\");\n}\n\n/** Type guard — works for `StoreDuplicateError` and ORM-specific equivalents (e.g. Prisma P2002). */\nexport function isStoreDuplicate(error: unknown): error is StoreDuplicateError | CodedError<\"P2002\"> {\n if (error instanceof StoreDuplicateError) return true;\n // Backwards compat: Prisma's P2002\n return hasErrorCode(error, \"P2002\");\n}\n\n/**\n * Type guard for `StorePersistenceError`. Matches on the stable `code` field\n * in addition to `instanceof`: every consumer package bundles its own copy of\n * core (tsup `noExternal`), so an instance thrown by one package fails an\n * `instanceof` check against another package's class identity.\n */\nexport function isStorePersistence(error: unknown): error is StorePersistenceError | CodedError<\"STORE_PERSISTENCE\"> {\n if (error instanceof StorePersistenceError) return true;\n return hasErrorCode(error, \"STORE_PERSISTENCE\");\n}\n\n// ---------------------------------------------------------------------------\n// Store helpers — shared conversion logic for adapters\n// ---------------------------------------------------------------------------\n\n/** Flatten a widget `AnnotationPayload` (nested anchor + rect) into a flat `AnnotationCreateInput`. */\nexport function flattenAnnotation(ann: AnnotationPayload): AnnotationCreateInput {\n return {\n cssSelector: ann.anchor.cssSelector,\n xpath: ann.anchor.xpath,\n textSnippet: ann.anchor.textSnippet,\n elementTag: ann.anchor.elementTag,\n elementId: ann.anchor.elementId,\n textPrefix: ann.anchor.textPrefix,\n textSuffix: ann.anchor.textSuffix,\n fingerprint: ann.anchor.fingerprint,\n neighborText: ann.anchor.neighborText,\n anchorKey: ann.anchor.anchorKey ?? null,\n xPct: ann.rect.xPct,\n yPct: ann.rect.yPct,\n wPct: ann.rect.wPct,\n hPct: ann.rect.hPct,\n scrollX: ann.scrollX,\n scrollY: ann.scrollY,\n viewportW: ann.viewportW,\n viewportH: ann.viewportH,\n devicePixelRatio: ann.devicePixelRatio,\n };\n}\n\n// ---------------------------------------------------------------------------\n// Abstract Store — adapter pattern\n// ---------------------------------------------------------------------------\n\n/** Paginated result returned by `SitepingStore.getFeedbacks`. */\nexport interface FeedbackPage {\n feedbacks: FeedbackRecord[];\n total: number;\n}\n\n/**\n * Abstract storage interface for Siteping.\n *\n * Any adapter (Prisma, Drizzle, raw SQL, localStorage, etc.) implements this\n * interface. The HTTP handler and widget `StoreClient` operate against\n * `SitepingStore`, decoupled from the storage backend.\n *\n * ## Error contract\n *\n * - **`updateFeedback` / `deleteFeedback`**: throw `StoreNotFoundError` when\n * the record does not exist.\n * - **`createFeedback`**: either return the existing record on duplicate\n * `clientId` (idempotent) or throw `StoreDuplicateError`. The handler\n * handles both patterns.\n * - **All mutations**: when a write is accepted but cannot be persisted\n * (e.g. storage quota), throw `StorePersistenceError` instead of reporting\n * a phantom success. Detect it with `isStorePersistence`.\n * - Other methods should not throw on empty results — return empty arrays or `null`.\n */\nexport interface SitepingStore {\n /** Create a feedback with its annotations. Idempotent on `clientId` — return existing record on duplicate, or throw `StoreDuplicateError`. Throws `StorePersistenceError` when the write cannot be persisted. */\n createFeedback(data: FeedbackCreateInput): Promise<FeedbackRecord>;\n /** Paginated query with optional filters. Returns empty array (not error) when no results. */\n getFeedbacks(query: FeedbackQuery): Promise<FeedbackPage>;\n /** Lookup by client-generated UUID. Returns `null` (not error) when not found. */\n findByClientId(clientId: string): Promise<FeedbackRecord | null>;\n /** Update status/resolvedAt. Throws `StoreNotFoundError` if `id` does not exist, `StorePersistenceError` when the write cannot be persisted. */\n updateFeedback(id: string, data: FeedbackUpdateInput): Promise<FeedbackRecord>;\n /** Delete a single record. Throws `StoreNotFoundError` if `id` does not exist, `StorePersistenceError` when the write cannot be persisted. */\n deleteFeedback(id: string): Promise<void>;\n /** Bulk delete all feedbacks for a project. No-op (not error) if none exist. Throws `StorePersistenceError` when the write cannot be persisted. */\n deleteAllFeedbacks(projectName: string): Promise<void>;\n /**\n * Optional — return `true` when the record with `id` belongs to\n * `projectName`, `false` otherwise (including when it does not exist).\n *\n * HTTP handlers use this to reject cross-project PATCH/DELETE requests.\n * Implement it whenever your store serves multiple projects; when absent,\n * handlers skip the ownership check and rely on `id` alone.\n */\n verifyProjectOwnership?(id: string, projectName: string): Promise<boolean>;\n}\n\n/** Payload sent from the widget to the server when submitting feedback. */\nexport interface FeedbackPayload {\n projectName: string;\n type: FeedbackType;\n message: string;\n url: string;\n /**\n * Parameterized URL template (e.g. `/orders/:orderId`) supplied by\n * `SitepingConfig.getPageScope()`. Null when the host did not provide one.\n */\n urlPattern?: string | null | undefined;\n viewport: string;\n userAgent: string;\n authorName: string;\n authorEmail: string;\n annotations: AnnotationPayload[];\n /** Client-generated UUID for deduplication */\n clientId: string;\n /**\n * Base64 JPEG `data:` URL of the annotated area. Captured by the widget\n * when `enableScreenshot: true` is set in `SitepingConfig`. Null when\n * disabled or when capture failed silently.\n */\n screenshotDataUrl?: string | null | undefined;\n /**\n * Annotation rect position within the screenshot image — see\n * `ScreenshotRegion`. Null/absent when no screenshot was captured or the\n * capture predates contextual framing.\n */\n screenshotRegion?: ScreenshotRegion | null | undefined;\n /**\n * Snapshot of the last few console messages and failed network requests\n * captured at submit time when `captureDiagnostics` is enabled.\n */\n diagnostics?: DiagnosticsSnapshot | null | undefined;\n}\n\n/** Single source of truth for console diagnostic severity levels. */\nexport const CONSOLE_DIAGNOSTIC_LEVELS = [\"log\", \"info\", \"warn\", \"error\"] as const;\n/** Severity levels persisted in `ConsoleDiagnosticEntry`. */\nexport type ConsoleDiagnosticLevel = (typeof CONSOLE_DIAGNOSTIC_LEVELS)[number];\n\n/** A single console entry captured by `ConsoleBuffer`. */\nexport interface ConsoleDiagnosticEntry {\n level: ConsoleDiagnosticLevel;\n /** ISO 8601 timestamp captured at log time. */\n timestamp: string;\n /** Best-effort string representation of the original console args. */\n message: string;\n}\n\n/** A single failed network request captured by `NetworkBuffer`. */\nexport interface NetworkDiagnosticEntry {\n url: string;\n method: string;\n /** HTTP status; 0 when the request never reached the server. */\n status: number;\n /** End-to-end duration in ms. */\n durationMs: number;\n /** ISO 8601 timestamp at the moment the request was initiated. */\n timestamp: string;\n}\n\n/**\n * Diagnostics captured by the widget when `captureDiagnostics` is enabled.\n *\n * Both arrays are bounded (default: 50 console / 20 network). Adapters that\n * support diagnostics should persist this as a JSON blob alongside the\n * feedback so reviewers can replay the context that led to the report.\n */\nexport interface DiagnosticsSnapshot {\n console: ConsoleDiagnosticEntry[];\n network: NetworkDiagnosticEntry[];\n}\n\n// ---------------------------------------------------------------------------\n// Annotation — multi-selector anchoring (Hypothesis / W3C Web Annotation)\n// ---------------------------------------------------------------------------\n\n/** DOM anchoring data for re-attaching annotations to page elements. */\nexport interface AnchorData {\n /** CSS selector generated by @medv/finder — primary anchor */\n cssSelector: string;\n /** XPath — fallback 1 */\n xpath: string;\n /** First ~120 chars of element innerText — empty string if none */\n textSnippet: string;\n /** Tag name for validation (e.g. \"DIV\", \"SECTION\") */\n elementTag: string;\n /** Element id attribute if available — most stable */\n elementId?: string | undefined;\n /** ~32 chars of text before this element in document flow (disambiguation) */\n textPrefix: string;\n /** ~32 chars of text after this element in document flow (disambiguation) */\n textSuffix: string;\n /** Structural fingerprint: \"childCount:siblingIdx:attrHash\" */\n fingerprint: string;\n /** Text content of adjacent sibling elements (context) */\n neighborText: string;\n /**\n * Semantic anchor identifier from the closest ancestor's `data-feedback-anchor`\n * attribute. When set, this is the highest-priority re-anchoring signal —\n * hosts deliberately place these on layout/section roots that survive\n * viewport changes and DOM refactors.\n */\n anchorKey?: string | null | undefined;\n}\n\n/**\n * Where the client's annotation rect sits within the captured screenshot,\n * as fractions [0, 1] of the image dimensions. The widget captures context\n * around the drawn rect and records the rect's position here so dashboards\n * can re-render the annotation on top of the image. Survives downscaling\n * (fractions are resolution-independent).\n */\nexport interface ScreenshotRegion {\n /** X offset of the rect as fraction of image width — [0, 1] */\n xPct: number;\n /** Y offset of the rect as fraction of image height — [0, 1] */\n yPct: number;\n /** Rect width as fraction of image width — [0, 1] */\n wPct: number;\n /** Rect height as fraction of image height — [0, 1] */\n hPct: number;\n}\n\n/** Drawn rectangle coordinates as percentages relative to the anchor element. */\nexport interface RectData {\n /** X offset as fraction of anchor element width — must be in range [0, 1] */\n xPct: number;\n /** Y offset as fraction of anchor element height — must be in range [0, 1] */\n yPct: number;\n /** Width as fraction of anchor element width — must be in range [0, 1] */\n wPct: number;\n /** Height as fraction of anchor element height — must be in range [0, 1] */\n hPct: number;\n}\n\n/** Annotation data sent as part of a feedback submission. */\nexport interface AnnotationPayload {\n anchor: AnchorData;\n rect: RectData;\n scrollX: number;\n scrollY: number;\n viewportW: number;\n viewportH: number;\n devicePixelRatio: number;\n}\n\n// ---------------------------------------------------------------------------\n// API responses\n// ---------------------------------------------------------------------------\n\n/**\n * Feedback record as returned by the API — derived from\n * {@link FeedbackRecord}: dates are serialized to ISO strings and `clientId`\n * is omitted (server-side dedup concern, never exposed on the wire). Adding\n * a field to `FeedbackRecord` updates this type automatically.\n *\n * Note: `authorEmail` may be an empty string — HTTP adapters redact it for\n * unauthenticated requests; the full value requires a Bearer-authenticated\n * request.\n */\nexport type FeedbackResponse = Prettify<Serialized<Omit<FeedbackRecord, \"clientId\">>>;\n\n/**\n * Annotation record as returned by the API — {@link AnnotationRecord} with\n * `createdAt` serialized to an ISO string.\n */\nexport type AnnotationResponse = Prettify<Serialized<AnnotationRecord>>;\n\n/** Paginated `FeedbackResponse` shape returned by the API. */\nexport interface FeedbackResponseList {\n feedbacks: FeedbackResponse[];\n total: number;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACgBA,oBAAiD;;;ACyC1C,SAAS,SAAS,OAAuD;AAC9E,SAAO,OAAO,UAAU,YAAY,UAAU;AAChD;AAWO,SAAS,OAA8B,OAAgB,KAAqC;AACjG,SAAO,SAAS,KAAK,KAAK,OAAO;AACnC;;;ACqkBO,IAAM,qBAAN,cAAiC,MAAM;AAAA,EACnC,OAAO;AAAA,EAChB,YAAY,UAAU,oBAAoB;AACxC,UAAM,O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CAAC,EAAE,SAAS,KAAK,KAAK;AAAA,MACvF,CAAC;AAAA,IACH,CAAC;AAAA,EACH,CAAC;AACH;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { StoreConformanceOptions, testSitepingStore } from './siteping-core-testing.cjs';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { StoreConformanceOptions, testSitepingStore } from './siteping-core-testing.js';
|
package/dist/testing.js
ADDED
|
@@ -0,0 +1,433 @@
|
|
|
1
|
+
import {
|
|
2
|
+
StoreNotFoundError,
|
|
3
|
+
isStoreDuplicate
|
|
4
|
+
} from "./chunk-YQHAD24P.js";
|
|
5
|
+
|
|
6
|
+
// ../core/src/testing.ts
|
|
7
|
+
import { beforeEach, describe, expect, it } from "vitest";
|
|
8
|
+
function createInput(overrides) {
|
|
9
|
+
return {
|
|
10
|
+
projectName: "test-project",
|
|
11
|
+
type: "bug",
|
|
12
|
+
message: "Something is broken",
|
|
13
|
+
status: "open",
|
|
14
|
+
url: "https://example.com",
|
|
15
|
+
viewport: "1920x1080",
|
|
16
|
+
userAgent: "Mozilla/5.0",
|
|
17
|
+
authorName: "Alice",
|
|
18
|
+
authorEmail: "alice@test.com",
|
|
19
|
+
clientId: `client-${Date.now()}-${Math.random()}`,
|
|
20
|
+
annotations: [
|
|
21
|
+
{
|
|
22
|
+
cssSelector: "div.main",
|
|
23
|
+
xpath: "/html/body/div",
|
|
24
|
+
textSnippet: "Hello",
|
|
25
|
+
elementTag: "DIV",
|
|
26
|
+
elementId: "main",
|
|
27
|
+
textPrefix: "before",
|
|
28
|
+
textSuffix: "after",
|
|
29
|
+
fingerprint: "3:1:abc",
|
|
30
|
+
neighborText: "sibling",
|
|
31
|
+
xPct: 0.1,
|
|
32
|
+
yPct: 0.2,
|
|
33
|
+
wPct: 0.5,
|
|
34
|
+
hPct: 0.3,
|
|
35
|
+
scrollX: 0,
|
|
36
|
+
scrollY: 100,
|
|
37
|
+
viewportW: 1920,
|
|
38
|
+
viewportH: 1080,
|
|
39
|
+
devicePixelRatio: 2
|
|
40
|
+
}
|
|
41
|
+
],
|
|
42
|
+
...overrides
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
var MINIMAL_ANNOTATION = {
|
|
46
|
+
cssSelector: "div",
|
|
47
|
+
xpath: "/div",
|
|
48
|
+
textSnippet: "",
|
|
49
|
+
elementTag: "DIV",
|
|
50
|
+
textPrefix: "",
|
|
51
|
+
textSuffix: "",
|
|
52
|
+
fingerprint: "1:0:x",
|
|
53
|
+
neighborText: "",
|
|
54
|
+
xPct: 0,
|
|
55
|
+
yPct: 0,
|
|
56
|
+
wPct: 1,
|
|
57
|
+
hPct: 1,
|
|
58
|
+
scrollX: 0,
|
|
59
|
+
scrollY: 0,
|
|
60
|
+
viewportW: 1920,
|
|
61
|
+
viewportH: 1080,
|
|
62
|
+
devicePixelRatio: 1
|
|
63
|
+
};
|
|
64
|
+
function testSitepingStore(factory, options) {
|
|
65
|
+
const duplicateBehavior = options?.duplicateBehavior ?? "return";
|
|
66
|
+
const caseInsensitiveSearch = options?.caseInsensitiveSearch ?? true;
|
|
67
|
+
describe("SitepingStore conformance", () => {
|
|
68
|
+
let store;
|
|
69
|
+
beforeEach(async () => {
|
|
70
|
+
store = await factory();
|
|
71
|
+
});
|
|
72
|
+
describe("createFeedback", () => {
|
|
73
|
+
it("creates a feedback and returns a FeedbackRecord", async () => {
|
|
74
|
+
const record = await store.createFeedback(createInput());
|
|
75
|
+
expect(record.id).toBeDefined();
|
|
76
|
+
expect(record.projectName).toBe("test-project");
|
|
77
|
+
expect(record.type).toBe("bug");
|
|
78
|
+
expect(record.message).toBe("Something is broken");
|
|
79
|
+
expect(record.status).toBe("open");
|
|
80
|
+
expect(record.resolvedAt).toBeNull();
|
|
81
|
+
expect(record.createdAt).toBeInstanceOf(Date);
|
|
82
|
+
expect(record.updatedAt).toBeInstanceOf(Date);
|
|
83
|
+
});
|
|
84
|
+
it("creates annotations with feedbackId reference", async () => {
|
|
85
|
+
const record = await store.createFeedback(createInput());
|
|
86
|
+
expect(record.annotations).toHaveLength(1);
|
|
87
|
+
const [ann] = record.annotations;
|
|
88
|
+
expect(ann).toBeDefined();
|
|
89
|
+
expect(ann?.id).toBeDefined();
|
|
90
|
+
expect(ann?.feedbackId).toBe(record.id);
|
|
91
|
+
expect(ann?.cssSelector).toBe("div.main");
|
|
92
|
+
expect(ann?.xPct).toBe(0.1);
|
|
93
|
+
expect(ann?.elementId).toBe("main");
|
|
94
|
+
expect(ann?.createdAt).toBeInstanceOf(Date);
|
|
95
|
+
});
|
|
96
|
+
it("sets elementId to null when undefined in input", async () => {
|
|
97
|
+
const record = await store.createFeedback(createInput({ annotations: [{ ...MINIMAL_ANNOTATION }] }));
|
|
98
|
+
expect(record.annotations[0]?.elementId).toBeNull();
|
|
99
|
+
});
|
|
100
|
+
it("persists anchorKey when provided", async () => {
|
|
101
|
+
const record = await store.createFeedback(
|
|
102
|
+
createInput({
|
|
103
|
+
annotations: [
|
|
104
|
+
{
|
|
105
|
+
...MINIMAL_ANNOTATION,
|
|
106
|
+
cssSelector: "section",
|
|
107
|
+
xpath: "/section",
|
|
108
|
+
textSnippet: "Services",
|
|
109
|
+
elementTag: "SECTION",
|
|
110
|
+
anchorKey: "order-card.services"
|
|
111
|
+
}
|
|
112
|
+
]
|
|
113
|
+
})
|
|
114
|
+
);
|
|
115
|
+
expect(record.annotations[0]?.anchorKey).toBe("order-card.services");
|
|
116
|
+
});
|
|
117
|
+
it("persists anchorKey as null when omitted", async () => {
|
|
118
|
+
const record = await store.createFeedback(createInput());
|
|
119
|
+
expect(record.annotations[0]?.anchorKey).toBeNull();
|
|
120
|
+
});
|
|
121
|
+
it("persists screenshotUrl as null when no data URL is provided", async () => {
|
|
122
|
+
const record = await store.createFeedback(createInput());
|
|
123
|
+
expect(record.screenshotUrl).toBeNull();
|
|
124
|
+
});
|
|
125
|
+
it("persists the screenshot data URL inline when no external storage is configured", async () => {
|
|
126
|
+
const dataUrl = "data:image/jpeg;base64,/9j/4AAQ";
|
|
127
|
+
const record = await store.createFeedback(createInput({ screenshotDataUrl: dataUrl }));
|
|
128
|
+
expect(record.screenshotUrl).toBe(dataUrl);
|
|
129
|
+
});
|
|
130
|
+
it("persists screenshotRegion verbatim when provided", async () => {
|
|
131
|
+
const region = { xPct: 0.1234, yPct: 0.5678, wPct: 0.25, hPct: 0.125 };
|
|
132
|
+
const record = await store.createFeedback(createInput({ screenshotRegion: region }));
|
|
133
|
+
expect(record.screenshotRegion).toEqual(region);
|
|
134
|
+
});
|
|
135
|
+
it("persists screenshotRegion as null when omitted", async () => {
|
|
136
|
+
const record = await store.createFeedback(createInput());
|
|
137
|
+
expect(record.screenshotRegion).toBeNull();
|
|
138
|
+
});
|
|
139
|
+
it("persists diagnostics verbatim when provided", async () => {
|
|
140
|
+
const diagnostics = {
|
|
141
|
+
console: [{ level: "error", timestamp: "2026-01-01T00:00:00.000Z", message: "boom" }],
|
|
142
|
+
network: [
|
|
143
|
+
{
|
|
144
|
+
url: "https://api.test/things",
|
|
145
|
+
method: "GET",
|
|
146
|
+
status: 500,
|
|
147
|
+
durationMs: 123,
|
|
148
|
+
timestamp: "2026-01-01T00:00:01.000Z"
|
|
149
|
+
}
|
|
150
|
+
]
|
|
151
|
+
};
|
|
152
|
+
const record = await store.createFeedback(createInput({ diagnostics }));
|
|
153
|
+
expect(record.diagnostics).toEqual(diagnostics);
|
|
154
|
+
});
|
|
155
|
+
it("persists diagnostics as null when omitted", async () => {
|
|
156
|
+
const record = await store.createFeedback(createInput());
|
|
157
|
+
expect(record.diagnostics).toBeNull();
|
|
158
|
+
});
|
|
159
|
+
if (duplicateBehavior === "return") {
|
|
160
|
+
it("deduplicates by clientId (idempotent)", async () => {
|
|
161
|
+
const input = createInput({ clientId: "same-id" });
|
|
162
|
+
const first = await store.createFeedback(input);
|
|
163
|
+
const second = await store.createFeedback(input);
|
|
164
|
+
expect(second.id).toBe(first.id);
|
|
165
|
+
const { total } = await store.getFeedbacks({ projectName: "test-project" });
|
|
166
|
+
expect(total).toBe(1);
|
|
167
|
+
});
|
|
168
|
+
} else {
|
|
169
|
+
it("throws StoreDuplicateError on duplicate clientId", async () => {
|
|
170
|
+
const input = createInput({ clientId: "same-id" });
|
|
171
|
+
await store.createFeedback(input);
|
|
172
|
+
await expect(store.createFeedback(input)).rejects.toSatisfy(isStoreDuplicate);
|
|
173
|
+
const { total } = await store.getFeedbacks({ projectName: "test-project" });
|
|
174
|
+
expect(total).toBe(1);
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
it("stores newest feedbacks first", async () => {
|
|
178
|
+
const a = await store.createFeedback(createInput({ message: "first" }));
|
|
179
|
+
const b = await store.createFeedback(createInput({ message: "second" }));
|
|
180
|
+
const { feedbacks } = await store.getFeedbacks({ projectName: "test-project" });
|
|
181
|
+
expect(feedbacks[0]?.id).toBe(b.id);
|
|
182
|
+
expect(feedbacks[1]?.id).toBe(a.id);
|
|
183
|
+
});
|
|
184
|
+
it("generates unique IDs across calls", async () => {
|
|
185
|
+
const a = await store.createFeedback(createInput());
|
|
186
|
+
const b = await store.createFeedback(createInput());
|
|
187
|
+
expect(a.id).not.toBe(b.id);
|
|
188
|
+
});
|
|
189
|
+
it("creates feedbacks with no annotations", async () => {
|
|
190
|
+
const record = await store.createFeedback(createInput({ annotations: [] }));
|
|
191
|
+
expect(record.annotations).toHaveLength(0);
|
|
192
|
+
});
|
|
193
|
+
});
|
|
194
|
+
describe("getFeedbacks", () => {
|
|
195
|
+
it("returns empty array when no feedbacks", async () => {
|
|
196
|
+
const result = await store.getFeedbacks({ projectName: "test-project" });
|
|
197
|
+
expect(result.feedbacks).toHaveLength(0);
|
|
198
|
+
expect(result.total).toBe(0);
|
|
199
|
+
});
|
|
200
|
+
it("filters by projectName", async () => {
|
|
201
|
+
await store.createFeedback(createInput({ projectName: "a" }));
|
|
202
|
+
await store.createFeedback(createInput({ projectName: "b" }));
|
|
203
|
+
const result = await store.getFeedbacks({ projectName: "a" });
|
|
204
|
+
expect(result.total).toBe(1);
|
|
205
|
+
expect(result.feedbacks[0]?.projectName).toBe("a");
|
|
206
|
+
});
|
|
207
|
+
it("filters by type", async () => {
|
|
208
|
+
await store.createFeedback(createInput({ type: "bug" }));
|
|
209
|
+
await store.createFeedback(createInput({ type: "question" }));
|
|
210
|
+
const result = await store.getFeedbacks({ projectName: "test-project", type: "bug" });
|
|
211
|
+
expect(result.feedbacks).toHaveLength(1);
|
|
212
|
+
expect(result.feedbacks[0]?.type).toBe("bug");
|
|
213
|
+
});
|
|
214
|
+
it("filters by status", async () => {
|
|
215
|
+
const fb = await store.createFeedback(createInput());
|
|
216
|
+
await store.updateFeedback(fb.id, { status: "resolved", resolvedAt: /* @__PURE__ */ new Date() });
|
|
217
|
+
await store.createFeedback(createInput());
|
|
218
|
+
const result = await store.getFeedbacks({ projectName: "test-project", status: "open" });
|
|
219
|
+
expect(result.feedbacks).toHaveLength(1);
|
|
220
|
+
});
|
|
221
|
+
it("filters by status in_progress", async () => {
|
|
222
|
+
const fb = await store.createFeedback(createInput());
|
|
223
|
+
await store.updateFeedback(fb.id, { status: "in_progress", resolvedAt: null });
|
|
224
|
+
await store.createFeedback(createInput());
|
|
225
|
+
const result = await store.getFeedbacks({ projectName: "test-project", status: "in_progress" });
|
|
226
|
+
expect(result.feedbacks).toHaveLength(1);
|
|
227
|
+
expect(result.feedbacks[0]?.status).toBe("in_progress");
|
|
228
|
+
});
|
|
229
|
+
it("filters by status wont_fix", async () => {
|
|
230
|
+
const fb = await store.createFeedback(createInput());
|
|
231
|
+
await store.updateFeedback(fb.id, { status: "wont_fix", resolvedAt: /* @__PURE__ */ new Date() });
|
|
232
|
+
await store.createFeedback(createInput());
|
|
233
|
+
const result = await store.getFeedbacks({ projectName: "test-project", status: "wont_fix" });
|
|
234
|
+
expect(result.feedbacks).toHaveLength(1);
|
|
235
|
+
expect(result.feedbacks[0]?.status).toBe("wont_fix");
|
|
236
|
+
});
|
|
237
|
+
it("filters by a statuses bucket (any of the listed values)", async () => {
|
|
238
|
+
const open = await store.createFeedback(createInput());
|
|
239
|
+
const prog = await store.createFeedback(createInput());
|
|
240
|
+
await store.updateFeedback(prog.id, { status: "in_progress", resolvedAt: null });
|
|
241
|
+
const resolved = await store.createFeedback(createInput());
|
|
242
|
+
await store.updateFeedback(resolved.id, { status: "resolved", resolvedAt: /* @__PURE__ */ new Date() });
|
|
243
|
+
const result = await store.getFeedbacks({
|
|
244
|
+
projectName: "test-project",
|
|
245
|
+
statuses: ["open", "in_progress"]
|
|
246
|
+
});
|
|
247
|
+
expect(result.total).toBe(2);
|
|
248
|
+
expect(result.feedbacks.map((f) => f.id).sort()).toEqual([open.id, prog.id].sort());
|
|
249
|
+
});
|
|
250
|
+
it("paginates a statuses bucket with the correct total", async () => {
|
|
251
|
+
for (let i = 0; i < 3; i++) {
|
|
252
|
+
const fb = await store.createFeedback(createInput());
|
|
253
|
+
await store.updateFeedback(fb.id, { status: "in_progress", resolvedAt: null });
|
|
254
|
+
}
|
|
255
|
+
const closed = await store.createFeedback(createInput());
|
|
256
|
+
await store.updateFeedback(closed.id, { status: "resolved", resolvedAt: /* @__PURE__ */ new Date() });
|
|
257
|
+
const page1 = await store.getFeedbacks({
|
|
258
|
+
projectName: "test-project",
|
|
259
|
+
statuses: ["open", "in_progress"],
|
|
260
|
+
page: 1,
|
|
261
|
+
limit: 2
|
|
262
|
+
});
|
|
263
|
+
expect(page1.total).toBe(3);
|
|
264
|
+
expect(page1.feedbacks).toHaveLength(2);
|
|
265
|
+
const page2 = await store.getFeedbacks({
|
|
266
|
+
projectName: "test-project",
|
|
267
|
+
statuses: ["open", "in_progress"],
|
|
268
|
+
page: 2,
|
|
269
|
+
limit: 2
|
|
270
|
+
});
|
|
271
|
+
expect(page2.total).toBe(3);
|
|
272
|
+
expect(page2.feedbacks).toHaveLength(1);
|
|
273
|
+
});
|
|
274
|
+
it("prefers statuses over status when both are set", async () => {
|
|
275
|
+
await store.createFeedback(createInput());
|
|
276
|
+
const prog = await store.createFeedback(createInput());
|
|
277
|
+
await store.updateFeedback(prog.id, { status: "in_progress", resolvedAt: null });
|
|
278
|
+
const result = await store.getFeedbacks({
|
|
279
|
+
projectName: "test-project",
|
|
280
|
+
status: "open",
|
|
281
|
+
statuses: ["open", "in_progress"]
|
|
282
|
+
});
|
|
283
|
+
expect(result.total).toBe(2);
|
|
284
|
+
});
|
|
285
|
+
it("ignores an empty statuses array (no status filter)", async () => {
|
|
286
|
+
await store.createFeedback(createInput());
|
|
287
|
+
const prog = await store.createFeedback(createInput());
|
|
288
|
+
await store.updateFeedback(prog.id, { status: "in_progress", resolvedAt: null });
|
|
289
|
+
const result = await store.getFeedbacks({ projectName: "test-project", statuses: [] });
|
|
290
|
+
expect(result.total).toBe(2);
|
|
291
|
+
});
|
|
292
|
+
it("filters by search (same-case substring)", async () => {
|
|
293
|
+
await store.createFeedback(createInput({ message: "Button is broken" }));
|
|
294
|
+
await store.createFeedback(createInput({ message: "Layout looks great" }));
|
|
295
|
+
const result = await store.getFeedbacks({ projectName: "test-project", search: "broken" });
|
|
296
|
+
expect(result.feedbacks).toHaveLength(1);
|
|
297
|
+
expect(result.feedbacks[0]?.message).toBe("Button is broken");
|
|
298
|
+
});
|
|
299
|
+
if (caseInsensitiveSearch) {
|
|
300
|
+
it("filters by search (case-insensitive)", async () => {
|
|
301
|
+
await store.createFeedback(createInput({ message: "Button is broken" }));
|
|
302
|
+
await store.createFeedback(createInput({ message: "Layout looks great" }));
|
|
303
|
+
const result = await store.getFeedbacks({ projectName: "test-project", search: "BROKEN" });
|
|
304
|
+
expect(result.feedbacks).toHaveLength(1);
|
|
305
|
+
expect(result.feedbacks[0]?.message).toBe("Button is broken");
|
|
306
|
+
});
|
|
307
|
+
}
|
|
308
|
+
it("filters by exact url", async () => {
|
|
309
|
+
await store.createFeedback(createInput({ url: "https://app.test/orders/42" }));
|
|
310
|
+
await store.createFeedback(createInput({ url: "https://app.test/dashboard" }));
|
|
311
|
+
const result = await store.getFeedbacks({ projectName: "test-project", url: "https://app.test/dashboard" });
|
|
312
|
+
expect(result.feedbacks).toHaveLength(1);
|
|
313
|
+
expect(result.feedbacks[0]?.url).toBe("https://app.test/dashboard");
|
|
314
|
+
});
|
|
315
|
+
it("filters by urlPattern", async () => {
|
|
316
|
+
await store.createFeedback(createInput({ url: "https://app.test/orders/42", urlPattern: "/orders/:id" }));
|
|
317
|
+
await store.createFeedback(createInput({ url: "https://app.test/orders/99", urlPattern: "/orders/:id" }));
|
|
318
|
+
await store.createFeedback(createInput({ url: "https://app.test/dashboard", urlPattern: "/dashboard" }));
|
|
319
|
+
const result = await store.getFeedbacks({ projectName: "test-project", urlPattern: "/orders/:id" });
|
|
320
|
+
expect(result.feedbacks).toHaveLength(2);
|
|
321
|
+
});
|
|
322
|
+
it("persists urlPattern as null when omitted from input", async () => {
|
|
323
|
+
const record = await store.createFeedback(createInput());
|
|
324
|
+
expect(record.urlPattern).toBeNull();
|
|
325
|
+
});
|
|
326
|
+
it("paginates correctly", async () => {
|
|
327
|
+
for (let i = 0; i < 5; i++) {
|
|
328
|
+
await store.createFeedback(createInput());
|
|
329
|
+
}
|
|
330
|
+
const page1 = await store.getFeedbacks({ projectName: "test-project", page: 1, limit: 2 });
|
|
331
|
+
expect(page1.feedbacks).toHaveLength(2);
|
|
332
|
+
expect(page1.total).toBe(5);
|
|
333
|
+
const page3 = await store.getFeedbacks({ projectName: "test-project", page: 3, limit: 2 });
|
|
334
|
+
expect(page3.feedbacks).toHaveLength(1);
|
|
335
|
+
});
|
|
336
|
+
it("caps limit at 100", async () => {
|
|
337
|
+
for (let i = 0; i < 105; i++) {
|
|
338
|
+
await store.createFeedback(createInput({ annotations: [] }));
|
|
339
|
+
}
|
|
340
|
+
const result = await store.getFeedbacks({ projectName: "test-project", limit: 200 });
|
|
341
|
+
expect(result.total).toBe(105);
|
|
342
|
+
expect(result.feedbacks).toHaveLength(100);
|
|
343
|
+
});
|
|
344
|
+
});
|
|
345
|
+
describe("findByClientId", () => {
|
|
346
|
+
it("returns the record when found", async () => {
|
|
347
|
+
const created = await store.createFeedback(createInput({ clientId: "find-me" }));
|
|
348
|
+
const found = await store.findByClientId("find-me");
|
|
349
|
+
expect(found).not.toBeNull();
|
|
350
|
+
expect(found?.id).toBe(created.id);
|
|
351
|
+
});
|
|
352
|
+
it("returns null when not found", async () => {
|
|
353
|
+
expect(await store.findByClientId("nope")).toBeNull();
|
|
354
|
+
});
|
|
355
|
+
});
|
|
356
|
+
describe("updateFeedback", () => {
|
|
357
|
+
it("updates status to resolved with resolvedAt", async () => {
|
|
358
|
+
const fb = await store.createFeedback(createInput());
|
|
359
|
+
const resolvedAt = /* @__PURE__ */ new Date();
|
|
360
|
+
const updated = await store.updateFeedback(fb.id, { status: "resolved", resolvedAt });
|
|
361
|
+
expect(updated.status).toBe("resolved");
|
|
362
|
+
expect(updated.resolvedAt).toEqual(resolvedAt);
|
|
363
|
+
expect(updated.updatedAt.getTime()).toBeGreaterThanOrEqual(fb.updatedAt.getTime());
|
|
364
|
+
});
|
|
365
|
+
it("updates status to in_progress with resolvedAt null", async () => {
|
|
366
|
+
const fb = await store.createFeedback(createInput());
|
|
367
|
+
const updated = await store.updateFeedback(fb.id, { status: "in_progress", resolvedAt: null });
|
|
368
|
+
expect(updated.status).toBe("in_progress");
|
|
369
|
+
expect(updated.resolvedAt).toBeNull();
|
|
370
|
+
});
|
|
371
|
+
it("updates status to wont_fix with the given resolvedAt", async () => {
|
|
372
|
+
const fb = await store.createFeedback(createInput());
|
|
373
|
+
const resolvedAt = /* @__PURE__ */ new Date();
|
|
374
|
+
const updated = await store.updateFeedback(fb.id, { status: "wont_fix", resolvedAt });
|
|
375
|
+
expect(updated.status).toBe("wont_fix");
|
|
376
|
+
expect(updated.resolvedAt).toEqual(resolvedAt);
|
|
377
|
+
});
|
|
378
|
+
it("throws StoreNotFoundError for unknown id", async () => {
|
|
379
|
+
await expect(store.updateFeedback("unknown", { status: "resolved", resolvedAt: /* @__PURE__ */ new Date() })).rejects.toThrow(
|
|
380
|
+
StoreNotFoundError
|
|
381
|
+
);
|
|
382
|
+
});
|
|
383
|
+
it("can reopen a closed feedback", async () => {
|
|
384
|
+
const fb = await store.createFeedback(createInput());
|
|
385
|
+
await store.updateFeedback(fb.id, { status: "resolved", resolvedAt: /* @__PURE__ */ new Date() });
|
|
386
|
+
const reopened = await store.updateFeedback(fb.id, { status: "open", resolvedAt: null });
|
|
387
|
+
expect(reopened.status).toBe("open");
|
|
388
|
+
expect(reopened.resolvedAt).toBeNull();
|
|
389
|
+
await store.updateFeedback(fb.id, { status: "wont_fix", resolvedAt: /* @__PURE__ */ new Date() });
|
|
390
|
+
const reopenedAgain = await store.updateFeedback(fb.id, { status: "open", resolvedAt: null });
|
|
391
|
+
expect(reopenedAgain.status).toBe("open");
|
|
392
|
+
expect(reopenedAgain.resolvedAt).toBeNull();
|
|
393
|
+
});
|
|
394
|
+
});
|
|
395
|
+
describe("deleteFeedback", () => {
|
|
396
|
+
it("removes the feedback", async () => {
|
|
397
|
+
const fb = await store.createFeedback(createInput());
|
|
398
|
+
await store.deleteFeedback(fb.id);
|
|
399
|
+
const { total } = await store.getFeedbacks({ projectName: "test-project" });
|
|
400
|
+
expect(total).toBe(0);
|
|
401
|
+
});
|
|
402
|
+
it("throws StoreNotFoundError for unknown id", async () => {
|
|
403
|
+
await expect(store.deleteFeedback("unknown")).rejects.toThrow(StoreNotFoundError);
|
|
404
|
+
});
|
|
405
|
+
});
|
|
406
|
+
describe("deleteAllFeedbacks", () => {
|
|
407
|
+
it("removes all feedbacks for a project but keeps others", async () => {
|
|
408
|
+
await store.createFeedback(createInput({ projectName: "delete-me" }));
|
|
409
|
+
await store.createFeedback(createInput({ projectName: "delete-me" }));
|
|
410
|
+
await store.createFeedback(createInput({ projectName: "keep-me" }));
|
|
411
|
+
await store.deleteAllFeedbacks("delete-me");
|
|
412
|
+
expect((await store.getFeedbacks({ projectName: "delete-me" })).total).toBe(0);
|
|
413
|
+
expect((await store.getFeedbacks({ projectName: "keep-me" })).total).toBe(1);
|
|
414
|
+
});
|
|
415
|
+
it("is a no-op when project has no feedbacks", async () => {
|
|
416
|
+
await expect(store.deleteAllFeedbacks("nonexistent")).resolves.toBeUndefined();
|
|
417
|
+
});
|
|
418
|
+
});
|
|
419
|
+
describe("verifyProjectOwnership", () => {
|
|
420
|
+
it("returns true for the owning project, false otherwise (when implemented)", async () => {
|
|
421
|
+
if (!store.verifyProjectOwnership) return;
|
|
422
|
+
const fb = await store.createFeedback(createInput({ projectName: "owner" }));
|
|
423
|
+
await expect(store.verifyProjectOwnership(fb.id, "owner")).resolves.toBe(true);
|
|
424
|
+
await expect(store.verifyProjectOwnership(fb.id, "intruder")).resolves.toBe(false);
|
|
425
|
+
await expect(store.verifyProjectOwnership("unknown-id", "owner")).resolves.toBe(false);
|
|
426
|
+
});
|
|
427
|
+
});
|
|
428
|
+
});
|
|
429
|
+
}
|
|
430
|
+
export {
|
|
431
|
+
testSitepingStore
|
|
432
|
+
};
|
|
433
|
+
//# sourceMappingURL=testing.js.map
|