Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

Remove upstash search

Rafi2a94e42dde31
diff --git a/apps/web/.env.example b/apps/web/.env.example
index 71c7d9f6c0..0ba7e2c1e7 100644
--- a/apps/web/.env.example
+++ b/apps/web/.env.example
@@ -24,16 +24,11 @@ UPSTASH_REDIS_REST_URL=
UPSTASH_REDIS_REST_TOKEN=
# Full-text partner search
-# Supported values: upstash-redis, upstash-search, turbopuffer
+# Supported values: upstash-redis, turbopuffer
PARTNER_SEARCH_PROVIDER=
PARTNER_SEARCH_INDEX_NAME=partner-search-v1
-PARTNER_UPSTASH_SEARCH_INDEX_NAME=partner-search-v1
PARTNER_SEARCH_DEBUG=false
-# Required when PARTNER_SEARCH_PROVIDER=upstash-search
-UPSTASH_SEARCH_REST_URL=
-UPSTASH_SEARCH_REST_TOKEN=
-
# Required when PARTNER_SEARCH_PROVIDER=turbopuffer
TURBOPUFFER_API_KEY=
TURBOPUFFER_REGION=aws-us-east-1
diff --git a/apps/web/lib/api/partners/search/provider.ts b/apps/web/lib/api/partners/search/provider.ts
index 0b71af6bb1..ee0ae81684 100644
--- a/apps/web/lib/api/partners/search/provider.ts
+++ b/apps/web/lib/api/partners/search/provider.ts
@@ -1,11 +1,9 @@
import { createTurbopufferPartnerSearchProvider } from "./providers/turbopuffer";
import { createUpstashRedisPartnerSearchProvider } from "./providers/upstash-redis";
-import { createUpstashSearchPartnerSearchProvider } from "./providers/upstash-search";
import type { PartnerSearchProvider } from "./types";
const PARTNER_SEARCH_PROVIDER_NAMES = [
"upstash-redis",
- "upstash-search",
"turbopuffer",
] as const;
@@ -17,7 +15,6 @@ const providerFactories: Record<
() => PartnerSearchProvider
> = {
"upstash-redis": createUpstashRedisPartnerSearchProvider,
- "upstash-search": createUpstashSearchPartnerSearchProvider,
turbopuffer: createTurbopufferPartnerSearchProvider,
};
diff --git a/apps/web/lib/api/partners/search/providers/shared.ts b/apps/web/lib/api/partners/search/providers/shared.ts
index fc2fece416..451b566c05 100644
--- a/apps/web/lib/api/partners/search/providers/shared.ts
+++ b/apps/web/lib/api/partners/search/providers/shared.ts
@@ -5,7 +5,7 @@ const NGRAM_SIZE = 3;
/**
* Three-character tokens, which is what lets a partial email match without a
* leading-wildcard query. Providers package these differently — Redis Search
- * requires each one as a separate `$eq`, Upstash Search takes them as a single
+ * requires each one as a separate `$eq`, Turbopuffer takes them as a single
* query string — so this returns the tokens and leaves the packaging to them.
*/
function toNgrams(value: string): string[] {
diff --git a/apps/web/lib/api/partners/search/providers/upstash-search.ts b/apps/web/lib/api/partners/search/providers/upstash-search.ts
deleted file mode 100644
index 145c991be9..0000000000
--- a/apps/web/lib/api/partners/search/providers/upstash-search.ts
+++ /dev/null
@@ -1,307 +0,0 @@
-import { chunk } from "@dub/utils";
-import { Search } from "@upstash/search";
-import { normalizePartnerSearchQuery } from "../searchable-values";
-import type {
- PartnerSearchCandidateQuery,
- PartnerSearchDocument,
- PartnerSearchProvider,
-} from "../types";
-import { validatePartnerSearchCandidateLimit } from "../types";
-import { withQueryDeadline, withTransientRetry } from "./resilience";
-import {
- getEmailNgrams,
- getQueryNgrams,
- logPartnerSearchDebug,
- resolveIndexName,
-} from "./shared";
-
-const DEFAULT_INDEX_NAME = "partner-search-v1";
-const WRITE_BATCH_SIZE = 100;
-const DELETE_BATCH_SIZE = 1_000;
-const WAIT_FOR_INDEXING_TIMEOUT_MS = 30_000;
-const WAIT_FOR_INDEXING_POLL_MS = 100;
-const QUERY_OPERATION_TIMEOUT_MS = 1_000;
-
-interface UpstashSearchContent extends Record<string, unknown> {
- partnerId: string;
- name: string;
- email: string;
- companyName: string;
- description: string;
- platforms: string;
- links: string;
- emailNgrams: string;
-}
-
-interface UpstashSearchMetadata extends Record<string, unknown> {
- programId: string;
-}
-
-interface UpstashSearchResult {
- id: string;
- content: UpstashSearchContent;
- metadata?: UpstashSearchMetadata;
- score: number;
-}
-
-interface UpstashSearchIndexClient {
- search(params: {
- query: string;
- limit: number;
- filter: string;
- reranking: boolean;
- semanticWeight: number;
- inputEnrichment: boolean;
- }): Promise<UpstashSearchResult[]>;
- upsert(
- documents:
- | {
- id: string;
- content: UpstashSearchContent;
- metadata: UpstashSearchMetadata;
- }
- | {
- id: string;
- content: UpstashSearchContent;
- metadata: UpstashSearchMetadata;
- }[],
- ): Promise<string>;
- delete(documentIds: string[]): Promise<{ deleted: number }>;
- range(params: {
- cursor: string;
- limit: number;
- }): Promise<{ nextCursor: string; documents: { id: string }[] }>;
- info(): Promise<{ pendingDocumentCount: number; documentCount: number }>;
- deleteIndex(): Promise<string>;
-}
-
-interface CreateUpstashSearchPartnerSearchProviderOptions {
- searchIndex?: UpstashSearchIndexClient;
- indexName?: string;
-}
-
-function getIndexName(indexName?: string): string {
- return resolveIndexName(
- [
- indexName,
- process.env.PARTNER_UPSTASH_SEARCH_INDEX_NAME,
- process.env.PARTNER_SEARCH_INDEX_NAME,
- ],
- DEFAULT_INDEX_NAME,
- );
-}
-
-function createSearchIndex(indexName: string): UpstashSearchIndexClient {
- const url = process.env.UPSTASH_SEARCH_REST_URL;
- const token = process.env.UPSTASH_SEARCH_REST_TOKEN;
-
- if (!url || !token) {
- throw new Error(
- "UPSTASH_SEARCH_REST_URL and UPSTASH_SEARCH_REST_TOKEN are required for partner search.",
- );
- }
-
- const client = new Search({ url, token, retry: false });
- return client.index<UpstashSearchContent, UpstashSearchMetadata>(indexName);
-}
-
-function truncate(value: string | null, maxLength: number): string {
- return value?.slice(0, maxLength) ?? "";
-}
-
-function joinValues(values: string[], maxLength: number): string {
- return truncate(values.join(" "), maxLength);
-}
-
-function serializeUpstashSearchDocument(document: PartnerSearchDocument) {
- // Upstash Search limits searchable content to 4,096 characters. Give each
- // assignment field its own budget so a long description cannot crowd out
- // platforms, links, or the email n-grams used for partial email matching.
- const content: UpstashSearchContent = {
- partnerId: truncate(document.partnerId, 50),
- name: truncate(document.name, 200),
- email: truncate(normalizePartnerSearchQuery(document.email ?? ""), 320),
- companyName: truncate(document.companyName, 200),
- description: truncate(document.description, 700),
- platforms: joinValues(
- [...document.platformTypes, ...document.platformIdentifiers],
- 500,
- ),
- links: joinValues(
- [
- ...document.linkDomains,
- ...document.linkKeys,
- ...document.shortLinks,
- ...document.destinationUrls,
- ],
- 850,
- ),
- emailNgrams: truncate(getEmailNgrams(document.email), 800),
- };
-
- // Program scope is the only metadata Search needs. The database applies
- // status, group, tag, country, metric, and sorting constraints after it
- // receives the relevance-ranked enrollment IDs.
- const metadata: UpstashSearchMetadata = { programId: document.programId };
-
- return { id: document.id, content, metadata };
-}
-
-function quoteFilterValue(value: string): string {
- return JSON.stringify(value);
-}
-
-function buildUpstashSearchFilter(programId: string): string {
- return `@metadata.programId = ${quoteFilterValue(programId)}`;
-}
-
-function mergeSearchResults(
- standardResults: UpstashSearchResult[],
- emailResults: UpstashSearchResult[],
-): UpstashSearchResult[] {
- const resultsById = new Map<string, UpstashSearchResult>();
-
- for (const result of [...standardResults, ...emailResults]) {
- const existing = resultsById.get(result.id);
- if (!existing || result.score > existing.score) {
- resultsById.set(result.id, result);
- }
- }
-
- return Array.from(resultsById.values()).sort(
- (left, right) =>
- right.score - left.score || left.id.localeCompare(right.id),
- );
-}
-
-export async function deleteUpstashSearchPartnerSearchIndex({
- searchIndex,
- indexName,
-}: CreateUpstashSearchPartnerSearchProviderOptions = {}) {
- const resolvedIndexName = getIndexName(indexName);
- const index = searchIndex ?? createSearchIndex(resolvedIndexName);
- const { documentCount } = await withTransientRetry(() => index.info());
-
- // Delete the logical index instead of resetting its documents. The next
- // backfill recreates the index automatically when it writes the first
- // document.
- await withTransientRetry(() => index.deleteIndex());
-
- return { indexName: resolvedIndexName, documentCount };
-}
-
-export function createUpstashSearchPartnerSearchProvider({
- searchIndex,
- indexName,
-}: CreateUpstashSearchPartnerSearchProviderOptions = {}): PartnerSearchProvider {
- const resolvedIndexName = getIndexName(indexName);
- const index = searchIndex ?? createSearchIndex(resolvedIndexName);
-
- async function findSearchCandidates({
- programId,
- query,
- limit,
- }: PartnerSearchCandidateQuery): Promise<UpstashSearchResult[]> {
- const normalizedQuery = normalizePartnerSearchQuery(query);
- const filter = buildUpstashSearchFilter(programId);
- const searchParams = {
- limit,
- filter,
- reranking: false,
- // This table needs literal full-text matching rather than related results
- // that happen to be semantically similar to a name, email, or URL.
- semanticWeight: 0,
- inputEnrichment: false,
- };
- const queryNgrams = getQueryNgrams(normalizedQuery);
-
- const [standardResults, rawEmailResults] = await withQueryDeadline(
- () =>
- Promise.all([
- index.search({ ...searchParams, query: normalizedQuery }),
- // Upstash Search takes the n-grams as one query string, unlike Redis
- // Search which needs each as a separate condition.
- queryNgrams.length > 0
- ? index.search({ ...searchParams, query: queryNgrams.join(" ") })
- : Promise.resolve([]),
- ]),
- QUERY_OPERATION_TIMEOUT_MS,
- );
-
- const emailResults = rawEmailResults.filter(({ content }) =>
- content.email.includes(normalizedQuery),
- );
- return mergeSearchResults(standardResults, emailResults);
- }
-
- return {
- async searchCandidates({ programId, query, limit }) {
- validatePartnerSearchCandidateLimit(limit);
- const candidates = await findSearchCandidates({
- programId,
- query,
- limit,
- });
- const hits = candidates.slice(0, limit).map(({ id, score }) => ({
- id,
- score,
- }));
-
- logPartnerSearchDebug("Upstash Search", {
- indexName: resolvedIndexName,
- operation: "searchCandidates",
- query: { programId, query, limit },
- resultCount: hits.length,
- hits,
- });
-
- return { hits };
- },
-
- async waitForIndexing() {
- const deadline = Date.now() + WAIT_FOR_INDEXING_TIMEOUT_MS;
- while (Date.now() < deadline) {
- const { pendingDocumentCount } = await withTransientRetry(() =>
- index.info(),
- );
- if (pendingDocumentCount === 0) {
- return;
- }
- await new Promise((resolve) =>
- setTimeout(resolve, WAIT_FOR_INDEXING_POLL_MS),
- );
- }
-
- throw new Error(
- `Partner search waitForIndexing timed out after ${WAIT_FOR_INDEXING_TIMEOUT_MS}ms.`,
- );
- },
-
- async upsert(documents) {
- for (const documentBatch of chunk(documents, WRITE_BATCH_SIZE)) {
- await withTransientRetry(() =>
- index.upsert(documentBatch.map(serializeUpstashSearchDocument)),
- );
- }
- },
-
- async delete(documentIds) {
- for (const documentIdBatch of chunk(documentIds, DELETE_BATCH_SIZE)) {
- await withTransientRetry(() => index.delete(documentIdBatch));
- }
- },
-
- async listDocumentIds({ cursor, limit }) {
- const { nextCursor, documents } = await withTransientRetry(() =>
- index.range({ cursor: cursor ?? "0", limit }),
- );
-
- // An empty nextCursor means the range is exhausted. The SDK types it as a
- // plain string, so the sentinel is not visible from the signature.
- return {
- documentIds: documents.map(({ id }) => id),
- cursor: nextCursor === "" ? null : nextCursor,
- };
- },
- };
-}
diff --git a/apps/web/lib/api/partners/search/reconcile.ts b/apps/web/lib/api/partners/search/reconcile.ts
index e0c6897112..e2c6591b69 100644
--- a/apps/web/lib/api/partners/search/reconcile.ts
+++ b/apps/web/lib/api/partners/search/reconcile.ts
@@ -28,7 +28,7 @@ interface ReconcilePartnerSearchIndexOptions {
*
* This sweeps the whole index rather than one program, because neither provider
* can enumerate documents by program: Redis keys are prefixed by index name
- * only, and Upstash Search ranges over document IDs. Scoping to a program would
+ * only, and Turbopuffer pages over document IDs. Scoping to a program would
* mean reading every document's body just to discard most of them.
*/
export async function reconcilePartnerSearchIndex({
diff --git a/apps/web/package.json b/apps/web/package.json
index a8bef1d60f..308e676570 100644
--- a/apps/web/package.json
+++ b/apps/web/package.json
@@ -61,7 +61,6 @@
"@upstash/qstash": "^2.11.0",
"@upstash/ratelimit": "^2.0.6",
"@upstash/redis": "^1.38.2",
- "@upstash/search": "^0.1.7",
"@upstash/vector": "^1.2.2",
"@upstash/workflow": "^1.3.0",
"@vercel/edge-config": "^0.4.1",
diff --git a/apps/web/scripts/partners/backfill-partner-search.ts b/apps/web/scripts/partners/backfill-partner-search.ts
index 1e8c11e5dc..f945d7cfaa 100644
--- a/apps/web/scripts/partners/backfill-partner-search.ts
+++ b/apps/web/scripts/partners/backfill-partner-search.ts
@@ -99,7 +99,7 @@ async function main() {
}
// Redis Search indexes have an explicit schema and must exist before the
- // backfill starts. Upstash Search creates its index on the first upsert.
+ // backfill starts. Turbopuffer creates its namespace on the first upsert.
if (providerName === "upstash-redis") {
await createUpstashRedisPartnerSearchIndex();
}
diff --git a/apps/web/scripts/partners/create-partner-search-index.ts b/apps/web/scripts/partners/create-partner-search-index.ts
index d68a3e6c74..819fd84b4b 100644
--- a/apps/web/scripts/partners/create-partner-search-index.ts
+++ b/apps/web/scripts/partners/create-partner-search-index.ts
@@ -12,7 +12,7 @@ async function main() {
// schema from the first write, so this is a no-op for them — spelled out per
// provider rather than falling through, so a new provider cannot silently
// land on the Redis path.
- if (providerName === "upstash-search" || providerName === "turbopuffer") {
+ if (providerName === "turbopuffer") {
console.log(
`${providerName} creates the partner search index on the first backfill upsert.`,
);
diff --git a/apps/web/scripts/partners/delete-partner-search-index.ts b/apps/web/scripts/partners/delete-partner-search-index.ts
index 069985187a..e74c1b0b4f 100644
--- a/apps/web/scripts/partners/delete-partner-search-index.ts
+++ b/apps/web/scripts/partners/delete-partner-search-index.ts
@@ -1,6 +1,5 @@
import { getPartnerSearchProviderName } from "@/lib/api/partners/search";
import { deleteTurbopufferPartnerSearchNamespace } from "@/lib/api/partners/search/providers/turbopuffer";
-import { deleteUpstashSearchPartnerSearchIndex } from "@/lib/api/partners/search/providers/upstash-search";
import { chunk } from "@dub/utils";
import { Redis } from "@upstash/redis";
import "dotenv-flow/config";
@@ -103,16 +102,6 @@ async function main() {
throw new Error("PARTNER_SEARCH_PROVIDER is not configured.");
}
- if (providerName === "upstash-search") {
- const { documentCount } = await deleteUpstashSearchPartnerSearchIndex({
- indexName,
- });
- console.log(
- `Partner search cleanup complete: ${documentCount.toLocaleString()} documents removed from ${indexName}.`,
- );
- return;
- }
-
if (providerName === "turbopuffer") {
await deleteTurbopufferPartnerSearchNamespace({ namespaceName: indexName });
console.log(`Partner search cleanup complete: emptied ${indexName}.`);
diff --git a/apps/web/tests/partners/upstash-search-partner-search-provider.test.ts b/apps/web/tests/partners/upstash-search-partner-search-provider.test.ts
deleted file mode 100644
index cc44306c3d..0000000000
--- a/apps/web/tests/partners/upstash-search-partner-search-provider.test.ts
+++ /dev/null
@@ -1,282 +0,0 @@
-import { type PartnerSearchDocument } from "@/lib/api/partners/search";
-import {
- createUpstashSearchPartnerSearchProvider,
- deleteUpstashSearchPartnerSearchIndex,
-} from "@/lib/api/partners/search/providers/upstash-search";
-import { beforeEach, describe, expect, it, vi } from "vitest";
-
-const document: PartnerSearchDocument = {
- id: "pge_test",
- programId: "prog_test",
- partnerId: "pn_test",
- name: "Rafi Hasan",
- email: "[email protected]",
- companyName: "Dub Partners",
- description: "Developer tools educator",
- platformTypes: ["website", "youtube", "twitter"],
- platformIdentifiers: ["rafi.dev", "@rafi-youtube", "@rafi-on-x"],
- linkDomains: ["dub.sh"],
- linkKeys: ["rafi"],
- shortLinks: ["https://dub.sh/rafi"],
- destinationUrls: ["https://example.com/referrals/rafi"],
-};
-
-const mocks = vi.hoisted(() => ({
- delete: vi.fn(),
- deleteIndex: vi.fn(),
- info: vi.fn(),
- range: vi.fn(),
- search: vi.fn(),
- upsert: vi.fn(),
-}));
-
-function createSearchIndexMock() {
- return {
- delete: mocks.delete,
- deleteIndex: mocks.deleteIndex,
- info: mocks.info,
- range: mocks.range,
- search: mocks.search,
- upsert: mocks.upsert,
- };
-}
-
-function getSearchResult(
- overrides: {
- id?: string;
- name?: string;
- email?: string;
- score?: number;
- } = {},
-) {
- return {
- id: overrides.id ?? document.id,
- content: {
- partnerId: document.partnerId,
- name: overrides.name ?? document.name,
- email: overrides.email ?? document.email!,
- companyName: document.companyName!,
- description: document.description!,
- platforms: document.platformIdentifiers.join(" "),
- links: document.destinationUrls.join(" "),
- emailNgrams: "exa xam amp",
- },
- metadata: {
- programId: document.programId,
- },
- score: overrides.score ?? 0.9,
- };
-}
-
-describe("Upstash Search partner search provider", () => {
- beforeEach(() => {
- vi.clearAllMocks();
- mocks.delete.mockResolvedValue({ deleted: 0 });
- mocks.info.mockResolvedValue({
- documentCount: 0,
- pendingDocumentCount: 0,
- });
- mocks.deleteIndex.mockResolvedValue("Success");
- mocks.search.mockResolvedValue([]);
- mocks.upsert.mockResolvedValue("Success");
- });
-
- it("stores every searchable assignment field within the content limit", async () => {
- const provider = createUpstashSearchPartnerSearchProvider({
- searchIndex: createSearchIndexMock(),
- indexName: "test-index",
- });
-
- await provider.upsert([
- {
- ...document,
- description: "description ".repeat(1_000),
- destinationUrls: [`https://example.com/${"path/".repeat(1_000)}`],
- },
- ]);
-
- const indexedDocument = mocks.upsert.mock.calls[0]![0][0];
- expect(JSON.stringify(indexedDocument.content).length).toBeLessThan(4_096);
- expect(indexedDocument.content).toEqual(
- expect.objectContaining({
- name: document.name,
- partnerId: document.partnerId,
- email: document.email,
- companyName: document.companyName,
- platforms: expect.stringContaining("rafi-on-x"),
- links: expect.stringContaining("dub.sh"),
- emailNgrams: expect.stringContaining("exa"),
- }),
- );
- expect(indexedDocument.metadata).toEqual({
- programId: document.programId,
- });
- });
-
- it("adds an exact email n-gram search for partial email matches", async () => {
- const emailResult = getSearchResult();
- mocks.search.mockImplementation(async ({ query }: { query: string }) =>
- query === "exa xam amp" ? [emailResult] : [],
- );
- const provider = createUpstashSearchPartnerSearchProvider({
- searchIndex: createSearchIndexMock(),
- indexName: "test-index",
- });
-
- await expect(
- provider.searchCandidates({
- programId: document.programId,
- query: "examp",
- limit: 10,
- }),
- ).resolves.toEqual({
- hits: [
- {
- id: document.id,
- score: emailResult.score,
- },
- ],
- });
-
- expect(mocks.search).toHaveBeenCalledTimes(2);
- expect(mocks.search).toHaveBeenCalledWith(
- expect.objectContaining({
- query: "examp",
- inputEnrichment: false,
- reranking: false,
- semanticWeight: 0,
- }),
- );
- expect(mocks.search).toHaveBeenCalledWith(
- expect.objectContaining({ query: "exa xam amp" }),
- );
- expect(mocks.search.mock.calls[0]![0].filter).toContain(
- '@metadata.programId = "prog_test"',
- );
- });
-
- it("returns relevance results without requiring a complete match set", async () => {
- mocks.search.mockResolvedValue(
- Array.from({ length: 100 }, (_, index) =>
- getSearchResult({
- id: `pge_${index}`,
- score: 1 - index / 100,
- }),
- ),
- );
- const provider = createUpstashSearchPartnerSearchProvider({
- searchIndex: createSearchIndexMock(),
- indexName: "test-index",
- });
-
- const result = await provider.searchCandidates({
- programId: document.programId,
- query: "drew moore",
- limit: 10,
- });
-
- expect(result.hits).toHaveLength(10);
- expect(result.hits[0]).toEqual(
- expect.objectContaining({ id: "pge_0", score: 1 }),
- );
- expect(mocks.search).toHaveBeenCalledWith(
- expect.objectContaining({ query: "drew moore", limit: 10 }),
- );
- });
-
- it("waits until pending documents finish indexing", async () => {
- vi.useFakeTimers();
- mocks.info
- .mockResolvedValueOnce({ documentCount: 1, pendingDocumentCount: 1 })
- .mockResolvedValueOnce({ documentCount: 2, pendingDocumentCount: 0 });
- const provider = createUpstashSearchPartnerSearchProvider({
- searchIndex: createSearchIndexMock(),
- indexName: "test-index",
- });
-
- try {
- const result = provider.waitForIndexing();
- await vi.advanceTimersByTimeAsync(100);
- await expect(result).resolves.toBeUndefined();
- expect(mocks.info).toHaveBeenCalledTimes(2);
- } finally {
- vi.useRealTimers();
- }
- });
-
- it("deletes the logical index in one operation", async () => {
- mocks.info.mockResolvedValue({
- documentCount: 100_005,
- pendingDocumentCount: 0,
- });
-
- await expect(
- deleteUpstashSearchPartnerSearchIndex({
- searchIndex: createSearchIndexMock(),
- indexName: "test-index",
- }),
- ).resolves.toEqual({
- indexName: "test-index",
- documentCount: 100_005,
- });
- expect(mocks.deleteIndex).toHaveBeenCalledOnce();
- });
-
- it("enumerates document IDs and reports an empty cursor as null", async () => {
- const provider = createUpstashSearchPartnerSearchProvider({
- searchIndex: createSearchIndexMock(),
- indexName: "test-index",
- });
- mocks.range.mockResolvedValue({
- nextCursor: "",
- documents: [{ id: "pge_one" }, { id: "pge_two" }],
- });
-
- const page = await provider.listDocumentIds({ limit: 500 });
-
- expect(mocks.range).toHaveBeenCalledWith({ cursor: "0", limit: 500 });
- expect(page).toEqual({
- documentIds: ["pge_one", "pge_two"],
- cursor: null,
- });
- });
-
- it("passes a live cursor through unchanged", async () => {
- const provider = createUpstashSearchPartnerSearchProvider({
- searchIndex: createSearchIndexMock(),
- indexName: "test-index",
- });
- mocks.range.mockResolvedValue({
- nextCursor: "next",
- documents: [{ id: "pge_one" }],
- });
-
- await expect(
- provider.listDocumentIds({ cursor: "prev", limit: 10 }),
- ).resolves.toEqual({ documentIds: ["pge_one"], cursor: "next" });
- expect(mocks.range).toHaveBeenCalledWith({ cursor: "prev", limit: 10 });
- });
-
- it.each([
- ["blank", ""],
- ["whitespace", " "],
- ])(
- "falls back to the default index when the env var is %s",
- async (_l, value) => {
- vi.stubEnv("PARTNER_UPSTASH_SEARCH_INDEX_NAME", value);
- vi.stubEnv("PARTNER_SEARCH_INDEX_NAME", value);
- mocks.info.mockResolvedValue({
- documentCount: 0,
- pendingDocumentCount: 0,
- });
- mocks.deleteIndex.mockResolvedValue("Success");
-
- const { indexName } = await deleteUpstashSearchPartnerSearchIndex({
- searchIndex: createSearchIndexMock(),
- });
-
- expect(indexName).toBe("partner-search-v1");
- vi.unstubAllEnvs();
- },
- );
-});
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 10d7b33b80..0a40d31b34 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -161,9 +161,6 @@ importers:
'@upstash/redis':
specifier: ^1.38.2
version: 1.38.2
- '@upstash/search':
- specifier: ^0.1.7
- version: 0.1.7
'@upstash/vector':
specifier: ^1.2.2
version: 1.2.2
@@ -6048,9 +6045,6 @@ packages:
'@upstash/[email protected]':
resolution: {integrity: sha512-RZ+JaRCVIS+ZTGnjOnDMr+/0aqDxsBb5rV6aW+Pys4SGELwr5lwE3UbLHRCHqMQ5Ulxj0b/CFBHfbmE175Otog==}
- '@upstash/[email protected]':
- resolution: {integrity: sha512-rgJ52TP0eUPLFo4K6TZtiC7qICbJnEwkT+TqaDI1vN8/Hk6qidgNC9dpnUUXCiqfwogty1rlSyBhYfk6PRgXjA==}
-
'@upstash/[email protected]':
resolution: {integrity: sha512-ptQ9xnxtKqmpNK52PCcHCszlPOLxIBfjsv7ty8RoF95pkjctS9rSjTQ3Pl9bx5VFbpDj+0dMXw88WLt6swDkgQ==}
@@ -19798,10 +19792,6 @@ snapshots:
dependencies:
uncrypto: 0.1.3
- '@upstash/[email protected]':
- dependencies:
- '@upstash/vector': 1.2.2
-
'@upstash/[email protected]': {}