langchain 0.2.17 → 0.3.0-rc.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/dist/agents/executor.cjs +11 -0
- package/dist/agents/executor.d.ts +2 -0
- package/dist/agents/executor.js +11 -0
- package/dist/agents/openai_functions/index.cjs +2 -2
- package/dist/agents/openai_functions/index.js +2 -2
- package/dist/agents/react/output_parser.cjs +3 -2
- package/dist/agents/react/output_parser.js +3 -2
- package/dist/chains/combine_documents/stuff.cjs +2 -2
- package/dist/chains/combine_documents/stuff.js +2 -2
- package/dist/chains/conversational_retrieval_chain.cjs +1 -1
- package/dist/chains/conversational_retrieval_chain.d.ts +1 -1
- package/dist/chains/conversational_retrieval_chain.js +1 -1
- package/dist/chains/llm_chain.cjs +1 -1
- package/dist/chains/llm_chain.d.ts +1 -1
- package/dist/chains/llm_chain.js +1 -1
- package/dist/chains/openai_functions/openapi.cjs +3 -1
- package/dist/chains/openai_functions/openapi.js +3 -1
- package/dist/chains/retrieval_qa.cjs +1 -1
- package/dist/chains/retrieval_qa.d.ts +1 -1
- package/dist/chains/retrieval_qa.js +1 -1
- package/dist/load/import_constants.cjs +2 -39
- package/dist/load/import_constants.js +2 -39
- package/dist/load/import_map.cjs +2 -3
- package/dist/load/import_map.d.ts +0 -1
- package/dist/load/import_map.js +0 -1
- package/dist/smith/config.d.ts +1 -5
- package/package.json +35 -858
- package/dist/document_loaders/fs/chatgpt.cjs +0 -90
- package/dist/document_loaders/fs/chatgpt.d.ts +0 -8
- package/dist/document_loaders/fs/chatgpt.js +0 -86
- package/dist/document_loaders/fs/csv.cjs +0 -73
- package/dist/document_loaders/fs/csv.d.ts +0 -65
- package/dist/document_loaders/fs/csv.js +0 -69
- package/dist/document_loaders/fs/docx.cjs +0 -58
- package/dist/document_loaders/fs/docx.d.ts +0 -25
- package/dist/document_loaders/fs/docx.js +0 -54
- package/dist/document_loaders/fs/epub.cjs +0 -103
- package/dist/document_loaders/fs/epub.d.ts +0 -33
- package/dist/document_loaders/fs/epub.js +0 -99
- package/dist/document_loaders/fs/notion.cjs +0 -26
- package/dist/document_loaders/fs/notion.d.ts +0 -12
- package/dist/document_loaders/fs/notion.js +0 -22
- package/dist/document_loaders/fs/obsidian.cjs +0 -247
- package/dist/document_loaders/fs/obsidian.d.ts +0 -28
- package/dist/document_loaders/fs/obsidian.js +0 -240
- package/dist/document_loaders/fs/openai_whisper_audio.cjs +0 -49
- package/dist/document_loaders/fs/openai_whisper_audio.d.ts +0 -23
- package/dist/document_loaders/fs/openai_whisper_audio.js +0 -45
- package/dist/document_loaders/fs/pdf.cjs +0 -148
- package/dist/document_loaders/fs/pdf.d.ts +0 -49
- package/dist/document_loaders/fs/pdf.js +0 -144
- package/dist/document_loaders/fs/pptx.cjs +0 -46
- package/dist/document_loaders/fs/pptx.d.ts +0 -25
- package/dist/document_loaders/fs/pptx.js +0 -42
- package/dist/document_loaders/fs/srt.cjs +0 -57
- package/dist/document_loaders/fs/srt.d.ts +0 -32
- package/dist/document_loaders/fs/srt.js +0 -50
- package/dist/document_loaders/fs/unstructured.cjs +0 -338
- package/dist/document_loaders/fs/unstructured.d.ts +0 -125
- package/dist/document_loaders/fs/unstructured.js +0 -333
- package/dist/document_loaders/web/apify_dataset.cjs +0 -130
- package/dist/document_loaders/web/apify_dataset.d.ts +0 -85
- package/dist/document_loaders/web/apify_dataset.js +0 -126
- package/dist/document_loaders/web/assemblyai.cjs +0 -200
- package/dist/document_loaders/web/assemblyai.d.ts +0 -95
- package/dist/document_loaders/web/assemblyai.js +0 -193
- package/dist/document_loaders/web/azure_blob_storage_container.cjs +0 -73
- package/dist/document_loaders/web/azure_blob_storage_container.d.ts +0 -46
- package/dist/document_loaders/web/azure_blob_storage_container.js +0 -69
- package/dist/document_loaders/web/azure_blob_storage_file.cjs +0 -124
- package/dist/document_loaders/web/azure_blob_storage_file.d.ts +0 -53
- package/dist/document_loaders/web/azure_blob_storage_file.js +0 -97
- package/dist/document_loaders/web/browserbase.cjs +0 -93
- package/dist/document_loaders/web/browserbase.d.ts +0 -48
- package/dist/document_loaders/web/browserbase.js +0 -86
- package/dist/document_loaders/web/cheerio.cjs +0 -118
- package/dist/document_loaders/web/cheerio.d.ts +0 -77
- package/dist/document_loaders/web/cheerio.js +0 -114
- package/dist/document_loaders/web/college_confidential.cjs +0 -41
- package/dist/document_loaders/web/college_confidential.d.ts +0 -25
- package/dist/document_loaders/web/college_confidential.js +0 -37
- package/dist/document_loaders/web/confluence.cjs +0 -190
- package/dist/document_loaders/web/confluence.d.ts +0 -114
- package/dist/document_loaders/web/confluence.js +0 -186
- package/dist/document_loaders/web/couchbase.cjs +0 -95
- package/dist/document_loaders/web/couchbase.d.ts +0 -32
- package/dist/document_loaders/web/couchbase.js +0 -91
- package/dist/document_loaders/web/figma.cjs +0 -102
- package/dist/document_loaders/web/figma.d.ts +0 -82
- package/dist/document_loaders/web/figma.js +0 -98
- package/dist/document_loaders/web/firecrawl.cjs +0 -95
- package/dist/document_loaders/web/firecrawl.d.ts +0 -50
- package/dist/document_loaders/web/firecrawl.js +0 -88
- package/dist/document_loaders/web/gitbook.cjs +0 -110
- package/dist/document_loaders/web/gitbook.d.ts +0 -55
- package/dist/document_loaders/web/gitbook.js +0 -106
- package/dist/document_loaders/web/github.cjs +0 -615
- package/dist/document_loaders/web/github.d.ts +0 -203
- package/dist/document_loaders/web/github.js +0 -608
- package/dist/document_loaders/web/hn.cjs +0 -90
- package/dist/document_loaders/web/hn.d.ts +0 -42
- package/dist/document_loaders/web/hn.js +0 -86
- package/dist/document_loaders/web/imsdb.cjs +0 -44
- package/dist/document_loaders/web/imsdb.d.ts +0 -23
- package/dist/document_loaders/web/imsdb.js +0 -40
- package/dist/document_loaders/web/notionapi.cjs +0 -404
- package/dist/document_loaders/web/notionapi.d.ts +0 -133
- package/dist/document_loaders/web/notionapi.js +0 -392
- package/dist/document_loaders/web/notiondb.cjs +0 -199
- package/dist/document_loaders/web/notiondb.d.ts +0 -56
- package/dist/document_loaders/web/notiondb.js +0 -195
- package/dist/document_loaders/web/pdf.cjs +0 -140
- package/dist/document_loaders/web/pdf.d.ts +0 -35
- package/dist/document_loaders/web/pdf.js +0 -136
- package/dist/document_loaders/web/playwright.cjs +0 -89
- package/dist/document_loaders/web/playwright.d.ts +0 -58
- package/dist/document_loaders/web/playwright.js +0 -85
- package/dist/document_loaders/web/puppeteer.cjs +0 -139
- package/dist/document_loaders/web/puppeteer.d.ts +0 -82
- package/dist/document_loaders/web/puppeteer.js +0 -135
- package/dist/document_loaders/web/recursive_url.cjs +0 -198
- package/dist/document_loaders/web/recursive_url.d.ts +0 -33
- package/dist/document_loaders/web/recursive_url.js +0 -194
- package/dist/document_loaders/web/s3.cjs +0 -164
- package/dist/document_loaders/web/s3.d.ts +0 -78
- package/dist/document_loaders/web/s3.js +0 -137
- package/dist/document_loaders/web/searchapi.cjs +0 -150
- package/dist/document_loaders/web/searchapi.d.ts +0 -76
- package/dist/document_loaders/web/searchapi.js +0 -146
- package/dist/document_loaders/web/serpapi.cjs +0 -127
- package/dist/document_loaders/web/serpapi.d.ts +0 -62
- package/dist/document_loaders/web/serpapi.js +0 -123
- package/dist/document_loaders/web/sitemap.cjs +0 -118
- package/dist/document_loaders/web/sitemap.d.ts +0 -41
- package/dist/document_loaders/web/sitemap.js +0 -114
- package/dist/document_loaders/web/sonix_audio.cjs +0 -68
- package/dist/document_loaders/web/sonix_audio.d.ts +0 -36
- package/dist/document_loaders/web/sonix_audio.js +0 -64
- package/dist/document_loaders/web/sort_xyz_blockchain.cjs +0 -157
- package/dist/document_loaders/web/sort_xyz_blockchain.d.ts +0 -78
- package/dist/document_loaders/web/sort_xyz_blockchain.js +0 -153
- package/dist/document_loaders/web/youtube.cjs +0 -116
- package/dist/document_loaders/web/youtube.d.ts +0 -55
- package/dist/document_loaders/web/youtube.js +0 -112
- package/dist/experimental/chrome_ai/app/dist/bundle.cjs +0 -1250
- package/dist/experimental/chrome_ai/app/dist/bundle.d.ts +0 -1
- package/dist/experimental/chrome_ai/app/dist/bundle.js +0 -1249
- package/dist/experimental/tools/pyinterpreter.cjs +0 -248
- package/dist/experimental/tools/pyinterpreter.d.ts +0 -18
- package/dist/experimental/tools/pyinterpreter.js +0 -244
- package/dist/retrievers/self_query/chroma.cjs +0 -48
- package/dist/retrievers/self_query/chroma.d.ts +0 -26
- package/dist/retrievers/self_query/chroma.js +0 -44
- package/dist/retrievers/self_query/pinecone.cjs +0 -47
- package/dist/retrievers/self_query/pinecone.d.ts +0 -26
- package/dist/retrievers/self_query/pinecone.js +0 -43
- package/dist/retrievers/self_query/supabase.cjs +0 -278
- package/dist/retrievers/self_query/supabase.d.ts +0 -109
- package/dist/retrievers/self_query/supabase.js +0 -274
- package/dist/retrievers/self_query/supabase_utils.cjs +0 -264
- package/dist/retrievers/self_query/supabase_utils.d.ts +0 -101
- package/dist/retrievers/self_query/supabase_utils.js +0 -259
- package/dist/retrievers/self_query/vectara.cjs +0 -143
- package/dist/retrievers/self_query/vectara.d.ts +0 -42
- package/dist/retrievers/self_query/vectara.js +0 -139
- package/dist/retrievers/self_query/weaviate.cjs +0 -201
- package/dist/retrievers/self_query/weaviate.d.ts +0 -99
- package/dist/retrievers/self_query/weaviate.js +0 -197
- package/dist/types/assemblyai-types.cjs +0 -2
- package/dist/types/assemblyai-types.d.ts +0 -4
- package/dist/types/assemblyai-types.js +0 -1
- package/document_loaders/fs/chatgpt.cjs +0 -1
- package/document_loaders/fs/chatgpt.d.cts +0 -1
- package/document_loaders/fs/chatgpt.d.ts +0 -1
- package/document_loaders/fs/chatgpt.js +0 -1
- package/document_loaders/fs/csv.cjs +0 -1
- package/document_loaders/fs/csv.d.cts +0 -1
- package/document_loaders/fs/csv.d.ts +0 -1
- package/document_loaders/fs/csv.js +0 -1
- package/document_loaders/fs/docx.cjs +0 -1
- package/document_loaders/fs/docx.d.cts +0 -1
- package/document_loaders/fs/docx.d.ts +0 -1
- package/document_loaders/fs/docx.js +0 -1
- package/document_loaders/fs/epub.cjs +0 -1
- package/document_loaders/fs/epub.d.cts +0 -1
- package/document_loaders/fs/epub.d.ts +0 -1
- package/document_loaders/fs/epub.js +0 -1
- package/document_loaders/fs/notion.cjs +0 -1
- package/document_loaders/fs/notion.d.cts +0 -1
- package/document_loaders/fs/notion.d.ts +0 -1
- package/document_loaders/fs/notion.js +0 -1
- package/document_loaders/fs/obsidian.cjs +0 -1
- package/document_loaders/fs/obsidian.d.cts +0 -1
- package/document_loaders/fs/obsidian.d.ts +0 -1
- package/document_loaders/fs/obsidian.js +0 -1
- package/document_loaders/fs/openai_whisper_audio.cjs +0 -1
- package/document_loaders/fs/openai_whisper_audio.d.cts +0 -1
- package/document_loaders/fs/openai_whisper_audio.d.ts +0 -1
- package/document_loaders/fs/openai_whisper_audio.js +0 -1
- package/document_loaders/fs/pdf.cjs +0 -1
- package/document_loaders/fs/pdf.d.cts +0 -1
- package/document_loaders/fs/pdf.d.ts +0 -1
- package/document_loaders/fs/pdf.js +0 -1
- package/document_loaders/fs/pptx.cjs +0 -1
- package/document_loaders/fs/pptx.d.cts +0 -1
- package/document_loaders/fs/pptx.d.ts +0 -1
- package/document_loaders/fs/pptx.js +0 -1
- package/document_loaders/fs/srt.cjs +0 -1
- package/document_loaders/fs/srt.d.cts +0 -1
- package/document_loaders/fs/srt.d.ts +0 -1
- package/document_loaders/fs/srt.js +0 -1
- package/document_loaders/fs/unstructured.cjs +0 -1
- package/document_loaders/fs/unstructured.d.cts +0 -1
- package/document_loaders/fs/unstructured.d.ts +0 -1
- package/document_loaders/fs/unstructured.js +0 -1
- package/document_loaders/web/apify_dataset.cjs +0 -1
- package/document_loaders/web/apify_dataset.d.cts +0 -1
- package/document_loaders/web/apify_dataset.d.ts +0 -1
- package/document_loaders/web/apify_dataset.js +0 -1
- package/document_loaders/web/assemblyai.cjs +0 -1
- package/document_loaders/web/assemblyai.d.cts +0 -1
- package/document_loaders/web/assemblyai.d.ts +0 -1
- package/document_loaders/web/assemblyai.js +0 -1
- package/document_loaders/web/azure_blob_storage_container.cjs +0 -1
- package/document_loaders/web/azure_blob_storage_container.d.cts +0 -1
- package/document_loaders/web/azure_blob_storage_container.d.ts +0 -1
- package/document_loaders/web/azure_blob_storage_container.js +0 -1
- package/document_loaders/web/azure_blob_storage_file.cjs +0 -1
- package/document_loaders/web/azure_blob_storage_file.d.cts +0 -1
- package/document_loaders/web/azure_blob_storage_file.d.ts +0 -1
- package/document_loaders/web/azure_blob_storage_file.js +0 -1
- package/document_loaders/web/browserbase.cjs +0 -1
- package/document_loaders/web/browserbase.d.cts +0 -1
- package/document_loaders/web/browserbase.d.ts +0 -1
- package/document_loaders/web/browserbase.js +0 -1
- package/document_loaders/web/cheerio.cjs +0 -1
- package/document_loaders/web/cheerio.d.cts +0 -1
- package/document_loaders/web/cheerio.d.ts +0 -1
- package/document_loaders/web/cheerio.js +0 -1
- package/document_loaders/web/college_confidential.cjs +0 -1
- package/document_loaders/web/college_confidential.d.cts +0 -1
- package/document_loaders/web/college_confidential.d.ts +0 -1
- package/document_loaders/web/college_confidential.js +0 -1
- package/document_loaders/web/confluence.cjs +0 -1
- package/document_loaders/web/confluence.d.cts +0 -1
- package/document_loaders/web/confluence.d.ts +0 -1
- package/document_loaders/web/confluence.js +0 -1
- package/document_loaders/web/couchbase.cjs +0 -1
- package/document_loaders/web/couchbase.d.cts +0 -1
- package/document_loaders/web/couchbase.d.ts +0 -1
- package/document_loaders/web/couchbase.js +0 -1
- package/document_loaders/web/figma.cjs +0 -1
- package/document_loaders/web/figma.d.cts +0 -1
- package/document_loaders/web/figma.d.ts +0 -1
- package/document_loaders/web/figma.js +0 -1
- package/document_loaders/web/firecrawl.cjs +0 -1
- package/document_loaders/web/firecrawl.d.cts +0 -1
- package/document_loaders/web/firecrawl.d.ts +0 -1
- package/document_loaders/web/firecrawl.js +0 -1
- package/document_loaders/web/gitbook.cjs +0 -1
- package/document_loaders/web/gitbook.d.cts +0 -1
- package/document_loaders/web/gitbook.d.ts +0 -1
- package/document_loaders/web/gitbook.js +0 -1
- package/document_loaders/web/github.cjs +0 -1
- package/document_loaders/web/github.d.cts +0 -1
- package/document_loaders/web/github.d.ts +0 -1
- package/document_loaders/web/github.js +0 -1
- package/document_loaders/web/hn.cjs +0 -1
- package/document_loaders/web/hn.d.cts +0 -1
- package/document_loaders/web/hn.d.ts +0 -1
- package/document_loaders/web/hn.js +0 -1
- package/document_loaders/web/imsdb.cjs +0 -1
- package/document_loaders/web/imsdb.d.cts +0 -1
- package/document_loaders/web/imsdb.d.ts +0 -1
- package/document_loaders/web/imsdb.js +0 -1
- package/document_loaders/web/notionapi.cjs +0 -1
- package/document_loaders/web/notionapi.d.cts +0 -1
- package/document_loaders/web/notionapi.d.ts +0 -1
- package/document_loaders/web/notionapi.js +0 -1
- package/document_loaders/web/notiondb.cjs +0 -1
- package/document_loaders/web/notiondb.d.cts +0 -1
- package/document_loaders/web/notiondb.d.ts +0 -1
- package/document_loaders/web/notiondb.js +0 -1
- package/document_loaders/web/pdf.cjs +0 -1
- package/document_loaders/web/pdf.d.cts +0 -1
- package/document_loaders/web/pdf.d.ts +0 -1
- package/document_loaders/web/pdf.js +0 -1
- package/document_loaders/web/playwright.cjs +0 -1
- package/document_loaders/web/playwright.d.cts +0 -1
- package/document_loaders/web/playwright.d.ts +0 -1
- package/document_loaders/web/playwright.js +0 -1
- package/document_loaders/web/puppeteer.cjs +0 -1
- package/document_loaders/web/puppeteer.d.cts +0 -1
- package/document_loaders/web/puppeteer.d.ts +0 -1
- package/document_loaders/web/puppeteer.js +0 -1
- package/document_loaders/web/recursive_url.cjs +0 -1
- package/document_loaders/web/recursive_url.d.cts +0 -1
- package/document_loaders/web/recursive_url.d.ts +0 -1
- package/document_loaders/web/recursive_url.js +0 -1
- package/document_loaders/web/s3.cjs +0 -1
- package/document_loaders/web/s3.d.cts +0 -1
- package/document_loaders/web/s3.d.ts +0 -1
- package/document_loaders/web/s3.js +0 -1
- package/document_loaders/web/searchapi.cjs +0 -1
- package/document_loaders/web/searchapi.d.cts +0 -1
- package/document_loaders/web/searchapi.d.ts +0 -1
- package/document_loaders/web/searchapi.js +0 -1
- package/document_loaders/web/serpapi.cjs +0 -1
- package/document_loaders/web/serpapi.d.cts +0 -1
- package/document_loaders/web/serpapi.d.ts +0 -1
- package/document_loaders/web/serpapi.js +0 -1
- package/document_loaders/web/sitemap.cjs +0 -1
- package/document_loaders/web/sitemap.d.cts +0 -1
- package/document_loaders/web/sitemap.d.ts +0 -1
- package/document_loaders/web/sitemap.js +0 -1
- package/document_loaders/web/sonix_audio.cjs +0 -1
- package/document_loaders/web/sonix_audio.d.cts +0 -1
- package/document_loaders/web/sonix_audio.d.ts +0 -1
- package/document_loaders/web/sonix_audio.js +0 -1
- package/document_loaders/web/sort_xyz_blockchain.cjs +0 -1
- package/document_loaders/web/sort_xyz_blockchain.d.cts +0 -1
- package/document_loaders/web/sort_xyz_blockchain.d.ts +0 -1
- package/document_loaders/web/sort_xyz_blockchain.js +0 -1
- package/document_loaders/web/youtube.cjs +0 -1
- package/document_loaders/web/youtube.d.cts +0 -1
- package/document_loaders/web/youtube.d.ts +0 -1
- package/document_loaders/web/youtube.js +0 -1
- package/experimental/tools/pyinterpreter.cjs +0 -1
- package/experimental/tools/pyinterpreter.d.cts +0 -1
- package/experimental/tools/pyinterpreter.d.ts +0 -1
- package/experimental/tools/pyinterpreter.js +0 -1
- package/memory/index.cjs +0 -1
- package/memory/index.d.cts +0 -1
- package/memory/index.d.ts +0 -1
- package/memory/index.js +0 -1
- package/retrievers/self_query/chroma.cjs +0 -1
- package/retrievers/self_query/chroma.d.cts +0 -1
- package/retrievers/self_query/chroma.d.ts +0 -1
- package/retrievers/self_query/chroma.js +0 -1
- package/retrievers/self_query/pinecone.cjs +0 -1
- package/retrievers/self_query/pinecone.d.cts +0 -1
- package/retrievers/self_query/pinecone.d.ts +0 -1
- package/retrievers/self_query/pinecone.js +0 -1
- package/retrievers/self_query/supabase.cjs +0 -1
- package/retrievers/self_query/supabase.d.cts +0 -1
- package/retrievers/self_query/supabase.d.ts +0 -1
- package/retrievers/self_query/supabase.js +0 -1
- package/retrievers/self_query/vectara.cjs +0 -1
- package/retrievers/self_query/vectara.d.cts +0 -1
- package/retrievers/self_query/vectara.d.ts +0 -1
- package/retrievers/self_query/vectara.js +0 -1
- package/retrievers/self_query/weaviate.cjs +0 -1
- package/retrievers/self_query/weaviate.d.cts +0 -1
- package/retrievers/self_query/weaviate.d.ts +0 -1
- package/retrievers/self_query/weaviate.js +0 -1
|
@@ -1,274 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
-
import { isFilterEmpty, isFloat, isInt, isObject, isString, BaseTranslator, Comparators, Operators, } from "@langchain/core/structured_query";
|
|
3
|
-
import { ProxyParamsDuplicator, convertObjectFilterToStructuredQuery, } from "./supabase_utils.js";
|
|
4
|
-
import { logVersion020MigrationWarning } from "../../util/entrypoint_deprecation.js";
|
|
5
|
-
/* #__PURE__ */ logVersion020MigrationWarning({
|
|
6
|
-
oldEntrypointName: "retrievers/self_query/supabase",
|
|
7
|
-
newEntrypointName: "structured_query/supabase",
|
|
8
|
-
newPackageName: "@langchain/community",
|
|
9
|
-
});
|
|
10
|
-
/**
|
|
11
|
-
* A specialized translator designed to work with Supabase, extending the
|
|
12
|
-
* BaseTranslator class. It translates structured queries into a format
|
|
13
|
-
* that can be understood by the Supabase database.
|
|
14
|
-
* @example
|
|
15
|
-
* ```typescript
|
|
16
|
-
* const selfQueryRetriever = new SelfQueryRetriever({
|
|
17
|
-
* llm: new ChatOpenAI(),
|
|
18
|
-
* vectorStore: new SupabaseVectorStore(),
|
|
19
|
-
* documentContents: "Brief summary of a movie",
|
|
20
|
-
* attributeInfo: [],
|
|
21
|
-
* structuredQueryTranslator: new SupabaseTranslator(),
|
|
22
|
-
* });
|
|
23
|
-
*
|
|
24
|
-
* const queryResult = await selfQueryRetriever.getRelevantDocuments(
|
|
25
|
-
* "Which movies are directed by Greta Gerwig?",
|
|
26
|
-
* );
|
|
27
|
-
* ```
|
|
28
|
-
*/
|
|
29
|
-
export class SupabaseTranslator extends BaseTranslator {
|
|
30
|
-
constructor() {
|
|
31
|
-
super(...arguments);
|
|
32
|
-
Object.defineProperty(this, "allowedOperators", {
|
|
33
|
-
enumerable: true,
|
|
34
|
-
configurable: true,
|
|
35
|
-
writable: true,
|
|
36
|
-
value: [Operators.and, Operators.or]
|
|
37
|
-
});
|
|
38
|
-
Object.defineProperty(this, "allowedComparators", {
|
|
39
|
-
enumerable: true,
|
|
40
|
-
configurable: true,
|
|
41
|
-
writable: true,
|
|
42
|
-
value: [
|
|
43
|
-
Comparators.eq,
|
|
44
|
-
Comparators.ne,
|
|
45
|
-
Comparators.gt,
|
|
46
|
-
Comparators.gte,
|
|
47
|
-
Comparators.lt,
|
|
48
|
-
Comparators.lte,
|
|
49
|
-
]
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
formatFunction() {
|
|
53
|
-
throw new Error("Not implemented");
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Returns a function that applies the appropriate comparator operation on
|
|
57
|
-
* the attribute and value provided. The function returned is used to
|
|
58
|
-
* filter data in a Supabase database.
|
|
59
|
-
* @param comparator The comparator to be used in the operation.
|
|
60
|
-
* @returns A function that applies the comparator operation on the attribute and value provided.
|
|
61
|
-
*/
|
|
62
|
-
getComparatorFunction(comparator) {
|
|
63
|
-
switch (comparator) {
|
|
64
|
-
case Comparators.eq: {
|
|
65
|
-
return (attr, value) => (rpc) => rpc.eq(this.buildColumnName(attr, value), value);
|
|
66
|
-
}
|
|
67
|
-
case Comparators.ne: {
|
|
68
|
-
return (attr, value) => (rpc) => rpc.neq(this.buildColumnName(attr, value), value);
|
|
69
|
-
}
|
|
70
|
-
case Comparators.gt: {
|
|
71
|
-
return (attr, value) => (rpc) => rpc.gt(this.buildColumnName(attr, value), value);
|
|
72
|
-
}
|
|
73
|
-
case Comparators.gte: {
|
|
74
|
-
return (attr, value) => (rpc) => rpc.gte(this.buildColumnName(attr, value), value);
|
|
75
|
-
}
|
|
76
|
-
case Comparators.lt: {
|
|
77
|
-
return (attr, value) => (rpc) => rpc.lt(this.buildColumnName(attr, value), value);
|
|
78
|
-
}
|
|
79
|
-
case Comparators.lte: {
|
|
80
|
-
return (attr, value) => (rpc) => rpc.lte(this.buildColumnName(attr, value), value);
|
|
81
|
-
}
|
|
82
|
-
default: {
|
|
83
|
-
throw new Error("Unknown comparator");
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* Builds a column name based on the attribute and value provided. The
|
|
89
|
-
* column name is used in filtering data in a Supabase database.
|
|
90
|
-
* @param attr The attribute to be used in the column name.
|
|
91
|
-
* @param value The value to be used in the column name.
|
|
92
|
-
* @param includeType Whether to include the data type in the column name.
|
|
93
|
-
* @returns The built column name.
|
|
94
|
-
*/
|
|
95
|
-
buildColumnName(attr, value, includeType = true) {
|
|
96
|
-
let column = "";
|
|
97
|
-
if (isString(value)) {
|
|
98
|
-
column = `metadata->>${attr}`;
|
|
99
|
-
}
|
|
100
|
-
else if (isInt(value)) {
|
|
101
|
-
column = `metadata->${attr}${includeType ? "::int" : ""}`;
|
|
102
|
-
}
|
|
103
|
-
else if (isFloat(value)) {
|
|
104
|
-
column = `metadata->${attr}${includeType ? "::float" : ""}`;
|
|
105
|
-
}
|
|
106
|
-
else {
|
|
107
|
-
throw new Error("Data type not supported");
|
|
108
|
-
}
|
|
109
|
-
return column;
|
|
110
|
-
}
|
|
111
|
-
/**
|
|
112
|
-
* Visits an operation and returns a string representation of it. This is
|
|
113
|
-
* used in translating a structured query into a format that can be
|
|
114
|
-
* understood by Supabase.
|
|
115
|
-
* @param operation The operation to be visited.
|
|
116
|
-
* @returns A string representation of the operation.
|
|
117
|
-
*/
|
|
118
|
-
visitOperationAsString(operation) {
|
|
119
|
-
const { args } = operation;
|
|
120
|
-
if (!args) {
|
|
121
|
-
return "";
|
|
122
|
-
}
|
|
123
|
-
return args
|
|
124
|
-
?.reduce((acc, arg) => {
|
|
125
|
-
if (arg.exprName === "Comparison") {
|
|
126
|
-
acc.push(this.visitComparisonAsString(arg));
|
|
127
|
-
}
|
|
128
|
-
else if (arg.exprName === "Operation") {
|
|
129
|
-
const { operator: innerOperator } = arg;
|
|
130
|
-
acc.push(`${innerOperator}(${this.visitOperationAsString(arg)})`);
|
|
131
|
-
}
|
|
132
|
-
return acc;
|
|
133
|
-
}, [])
|
|
134
|
-
.join(",");
|
|
135
|
-
}
|
|
136
|
-
/**
|
|
137
|
-
* Visits an operation and returns a function that applies the operation
|
|
138
|
-
* on a Supabase database. This is used in translating a structured query
|
|
139
|
-
* into a format that can be understood by Supabase.
|
|
140
|
-
* @param operation The operation to be visited.
|
|
141
|
-
* @returns A function that applies the operation on a Supabase database.
|
|
142
|
-
*/
|
|
143
|
-
visitOperation(operation) {
|
|
144
|
-
const { operator, args } = operation;
|
|
145
|
-
if (this.allowedOperators.includes(operator)) {
|
|
146
|
-
if (operator === Operators.and) {
|
|
147
|
-
if (!args) {
|
|
148
|
-
return (rpc) => rpc;
|
|
149
|
-
}
|
|
150
|
-
const filter = (rpc) => args.reduce((acc, arg) => {
|
|
151
|
-
const filter = arg.accept(this);
|
|
152
|
-
return filter(acc);
|
|
153
|
-
}, rpc);
|
|
154
|
-
return filter;
|
|
155
|
-
}
|
|
156
|
-
else if (operator === Operators.or) {
|
|
157
|
-
return (rpc) => rpc.or(this.visitOperationAsString(operation));
|
|
158
|
-
}
|
|
159
|
-
else {
|
|
160
|
-
throw new Error("Unknown operator");
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
else {
|
|
164
|
-
throw new Error("Operator not allowed");
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
/**
|
|
168
|
-
* Visits a comparison and returns a string representation of it. This is
|
|
169
|
-
* used in translating a structured query into a format that can be
|
|
170
|
-
* understood by Supabase.
|
|
171
|
-
* @param comparison The comparison to be visited.
|
|
172
|
-
* @returns A string representation of the comparison.
|
|
173
|
-
*/
|
|
174
|
-
visitComparisonAsString(comparison) {
|
|
175
|
-
let { value } = comparison;
|
|
176
|
-
const { comparator: _comparator, attribute } = comparison;
|
|
177
|
-
let comparator = _comparator;
|
|
178
|
-
if (comparator === Comparators.ne) {
|
|
179
|
-
comparator = "neq";
|
|
180
|
-
}
|
|
181
|
-
if (Array.isArray(value)) {
|
|
182
|
-
value = `(${value
|
|
183
|
-
.map((v) => {
|
|
184
|
-
if (typeof v === "string" && /[,()]/.test(v))
|
|
185
|
-
return `"${v}"`;
|
|
186
|
-
return v;
|
|
187
|
-
})
|
|
188
|
-
.join(",")})`;
|
|
189
|
-
}
|
|
190
|
-
return `${this.buildColumnName(attribute, value, false)}.${comparator}.${value}}`;
|
|
191
|
-
}
|
|
192
|
-
/**
|
|
193
|
-
* Visits a comparison and returns a function that applies the comparison
|
|
194
|
-
* on a Supabase database. This is used in translating a structured query
|
|
195
|
-
* into a format that can be understood by Supabase.
|
|
196
|
-
* @param comparison The comparison to be visited.
|
|
197
|
-
* @returns A function that applies the comparison on a Supabase database.
|
|
198
|
-
*/
|
|
199
|
-
visitComparison(comparison) {
|
|
200
|
-
const { comparator, attribute, value } = comparison;
|
|
201
|
-
if (this.allowedComparators.includes(comparator)) {
|
|
202
|
-
const comparatorFunction = this.getComparatorFunction(comparator);
|
|
203
|
-
return comparatorFunction(attribute, value);
|
|
204
|
-
}
|
|
205
|
-
else {
|
|
206
|
-
throw new Error("Comparator not allowed");
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
/**
|
|
210
|
-
* Visits a structured query and returns a function that applies the query
|
|
211
|
-
* on a Supabase database. This is used in translating a structured query
|
|
212
|
-
* into a format that can be understood by Supabase.
|
|
213
|
-
* @param query The structured query to be visited.
|
|
214
|
-
* @returns A function that applies the query on a Supabase database.
|
|
215
|
-
*/
|
|
216
|
-
visitStructuredQuery(query) {
|
|
217
|
-
if (!query.filter) {
|
|
218
|
-
return {};
|
|
219
|
-
}
|
|
220
|
-
const filterFunction = query.filter?.accept(this);
|
|
221
|
-
return { filter: filterFunction ?? {} };
|
|
222
|
-
}
|
|
223
|
-
/**
|
|
224
|
-
* Merges two filters into one. The merged filter can be used to filter
|
|
225
|
-
* data in a Supabase database.
|
|
226
|
-
* @param defaultFilter The default filter to be merged.
|
|
227
|
-
* @param generatedFilter The generated filter to be merged.
|
|
228
|
-
* @param mergeType The type of merge to be performed. It can be 'and', 'or', or 'replace'.
|
|
229
|
-
* @returns The merged filter.
|
|
230
|
-
*/
|
|
231
|
-
mergeFilters(defaultFilter, generatedFilter, mergeType = "and") {
|
|
232
|
-
if (isFilterEmpty(defaultFilter) && isFilterEmpty(generatedFilter)) {
|
|
233
|
-
return undefined;
|
|
234
|
-
}
|
|
235
|
-
if (isFilterEmpty(defaultFilter) || mergeType === "replace") {
|
|
236
|
-
if (isFilterEmpty(generatedFilter)) {
|
|
237
|
-
return undefined;
|
|
238
|
-
}
|
|
239
|
-
return generatedFilter;
|
|
240
|
-
}
|
|
241
|
-
if (isFilterEmpty(generatedFilter)) {
|
|
242
|
-
if (mergeType === "and") {
|
|
243
|
-
return undefined;
|
|
244
|
-
}
|
|
245
|
-
return defaultFilter;
|
|
246
|
-
}
|
|
247
|
-
let myDefaultFilter = defaultFilter;
|
|
248
|
-
if (isObject(defaultFilter)) {
|
|
249
|
-
const { filter } = this.visitStructuredQuery(convertObjectFilterToStructuredQuery(defaultFilter));
|
|
250
|
-
// just in case the built filter is empty somehow
|
|
251
|
-
if (isFilterEmpty(filter)) {
|
|
252
|
-
if (isFilterEmpty(generatedFilter)) {
|
|
253
|
-
return undefined;
|
|
254
|
-
}
|
|
255
|
-
return generatedFilter;
|
|
256
|
-
}
|
|
257
|
-
myDefaultFilter = filter;
|
|
258
|
-
}
|
|
259
|
-
// After this point, myDefaultFilter will always be SupabaseFilterRPCCall
|
|
260
|
-
if (mergeType === "or") {
|
|
261
|
-
return (rpc) => {
|
|
262
|
-
const defaultFlattenedParams = ProxyParamsDuplicator.getFlattenedParams(rpc, myDefaultFilter);
|
|
263
|
-
const generatedFlattenedParams = ProxyParamsDuplicator.getFlattenedParams(rpc, generatedFilter);
|
|
264
|
-
return rpc.or(`${defaultFlattenedParams},${generatedFlattenedParams}`);
|
|
265
|
-
};
|
|
266
|
-
}
|
|
267
|
-
else if (mergeType === "and") {
|
|
268
|
-
return (rpc) => generatedFilter(myDefaultFilter(rpc));
|
|
269
|
-
}
|
|
270
|
-
else {
|
|
271
|
-
throw new Error("Unknown merge type");
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
}
|
|
@@ -1,264 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.convertObjectFilterToStructuredQuery = exports.ProxyParamsDuplicator = void 0;
|
|
4
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
5
|
-
const structured_query_1 = require("@langchain/core/structured_query");
|
|
6
|
-
/**
|
|
7
|
-
* Utility class used to duplicate parameters for a proxy object,
|
|
8
|
-
* specifically designed to work with `SupabaseFilter` objects. It
|
|
9
|
-
* contains methods to handle different types of operations such as "or",
|
|
10
|
-
* "filter", "in", "contains", "textSearch", "match", "not", and default
|
|
11
|
-
* operations.
|
|
12
|
-
*/
|
|
13
|
-
class ProxyParamsDuplicator {
|
|
14
|
-
constructor() {
|
|
15
|
-
Object.defineProperty(this, "duplicationAllowedOps", {
|
|
16
|
-
enumerable: true,
|
|
17
|
-
configurable: true,
|
|
18
|
-
writable: true,
|
|
19
|
-
value: [
|
|
20
|
-
"eq",
|
|
21
|
-
"neq",
|
|
22
|
-
"lt",
|
|
23
|
-
"lte",
|
|
24
|
-
"gt",
|
|
25
|
-
"gte",
|
|
26
|
-
"like",
|
|
27
|
-
"ilike",
|
|
28
|
-
"or",
|
|
29
|
-
"in",
|
|
30
|
-
"contains",
|
|
31
|
-
"match",
|
|
32
|
-
"not",
|
|
33
|
-
"textSearch",
|
|
34
|
-
"filter",
|
|
35
|
-
]
|
|
36
|
-
});
|
|
37
|
-
Object.defineProperty(this, "values", {
|
|
38
|
-
enumerable: true,
|
|
39
|
-
configurable: true,
|
|
40
|
-
writable: true,
|
|
41
|
-
value: []
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Creates a proxy handler for a `SupabaseFilter` object. The handler
|
|
46
|
-
* intercepts get operations and applies specific logic based on the
|
|
47
|
-
* property being accessed.
|
|
48
|
-
* @returns A proxy handler for a `SupabaseFilter` object.
|
|
49
|
-
*/
|
|
50
|
-
buildProxyHandler() {
|
|
51
|
-
const proxyHandler = {
|
|
52
|
-
get: (target, prop, receiver) => {
|
|
53
|
-
if (typeof target[prop] === "function") {
|
|
54
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
55
|
-
return (...args) => {
|
|
56
|
-
if (this.duplicationAllowedOps.includes(String(prop))) {
|
|
57
|
-
switch (String(prop)) {
|
|
58
|
-
case "or":
|
|
59
|
-
// args[0]: filters, args[1]: { foreignTable }
|
|
60
|
-
this.addOrClause(args[0], args[1]);
|
|
61
|
-
break;
|
|
62
|
-
case "filter":
|
|
63
|
-
// args[0]: column, args[1]: operator, args[2]: value
|
|
64
|
-
this.addFilterClause(args[0], args[1], args[2]);
|
|
65
|
-
break;
|
|
66
|
-
case "in":
|
|
67
|
-
// args[0]: column, args[1]: values
|
|
68
|
-
this.addInClause(args[0], args[1]);
|
|
69
|
-
break;
|
|
70
|
-
case "contains":
|
|
71
|
-
// args[0]: column, args[1]: value
|
|
72
|
-
this.addContainsClause(args[0], args[1]);
|
|
73
|
-
break;
|
|
74
|
-
case "textSearch":
|
|
75
|
-
// args[0]: column, args[1]: query, args[2]: { config, type }
|
|
76
|
-
this.addTextSearchClause(args[0], args[1], args[2]);
|
|
77
|
-
break;
|
|
78
|
-
case "match":
|
|
79
|
-
// args[0]: query
|
|
80
|
-
this.addMatchClause(args[0]);
|
|
81
|
-
break;
|
|
82
|
-
case "not":
|
|
83
|
-
// args[0]: column, args[1]: operator, args[2]: value
|
|
84
|
-
this.addNotClause(args[0], args[1], args[2]);
|
|
85
|
-
break;
|
|
86
|
-
default:
|
|
87
|
-
// args[0]: column, args[1]: value
|
|
88
|
-
this.addDefaultOpClause(prop, args[0], args[1]);
|
|
89
|
-
}
|
|
90
|
-
return new Proxy(target, proxyHandler);
|
|
91
|
-
}
|
|
92
|
-
else {
|
|
93
|
-
throw new Error("Filter operation not supported for 'or' mergeFiltersOperator");
|
|
94
|
-
}
|
|
95
|
-
};
|
|
96
|
-
}
|
|
97
|
-
else {
|
|
98
|
-
return Reflect.get(target, prop, receiver);
|
|
99
|
-
}
|
|
100
|
-
},
|
|
101
|
-
};
|
|
102
|
-
return proxyHandler;
|
|
103
|
-
}
|
|
104
|
-
/**
|
|
105
|
-
* Removes type annotations from a value string.
|
|
106
|
-
* @param value The value string to clean.
|
|
107
|
-
* @returns The cleaned value string.
|
|
108
|
-
*/
|
|
109
|
-
removeType(value) {
|
|
110
|
-
let cleanedValue = value;
|
|
111
|
-
if (cleanedValue.includes("::float")) {
|
|
112
|
-
cleanedValue = cleanedValue.replace("::float", "");
|
|
113
|
-
}
|
|
114
|
-
if (cleanedValue.includes("::int")) {
|
|
115
|
-
cleanedValue = cleanedValue.replace("::int", "");
|
|
116
|
-
}
|
|
117
|
-
return cleanedValue;
|
|
118
|
-
}
|
|
119
|
-
/**
|
|
120
|
-
* Adds a default operation clause to the values array.
|
|
121
|
-
* @param prop The operation property.
|
|
122
|
-
* @param column The column to apply the operation to.
|
|
123
|
-
* @param value The value for the operation.
|
|
124
|
-
*/
|
|
125
|
-
addDefaultOpClause(prop, column, value) {
|
|
126
|
-
this.values.push([this.removeType(column), `${String(prop)}.${value}`]);
|
|
127
|
-
}
|
|
128
|
-
/**
|
|
129
|
-
* Adds an 'or' clause to the values array.
|
|
130
|
-
* @param filters The filters for the 'or' clause.
|
|
131
|
-
* @param foreignTable Optional foreign table for the 'or' clause.
|
|
132
|
-
*/
|
|
133
|
-
addOrClause(filters, { foreignTable } = {}) {
|
|
134
|
-
const key = foreignTable ? `${foreignTable}.or` : "or";
|
|
135
|
-
this.values.push([this.removeType(key), `(${filters})`]);
|
|
136
|
-
}
|
|
137
|
-
/**
|
|
138
|
-
* Adds a 'filter' clause to the values array.
|
|
139
|
-
* @param column The column to apply the filter to.
|
|
140
|
-
* @param operator The operator for the filter.
|
|
141
|
-
* @param value The value for the filter.
|
|
142
|
-
*/
|
|
143
|
-
addFilterClause(column, operator, value) {
|
|
144
|
-
this.values.push([this.removeType(column), `${operator}.${value}`]);
|
|
145
|
-
}
|
|
146
|
-
/**
|
|
147
|
-
* Adds an 'in' clause to the values array.
|
|
148
|
-
* @param column The column to apply the 'in' clause to.
|
|
149
|
-
* @param values The values for the 'in' clause.
|
|
150
|
-
*/
|
|
151
|
-
addInClause(column, values) {
|
|
152
|
-
const cleanedValues = values
|
|
153
|
-
.map((s) => {
|
|
154
|
-
if (typeof s === "string" && /[,()]/.test(s))
|
|
155
|
-
return `"${s}"`;
|
|
156
|
-
else
|
|
157
|
-
return `${s}`;
|
|
158
|
-
})
|
|
159
|
-
.join(",");
|
|
160
|
-
this.values.push([this.removeType(column), `in.(${cleanedValues})`]);
|
|
161
|
-
}
|
|
162
|
-
/**
|
|
163
|
-
* Adds a 'contains' clause to the values array.
|
|
164
|
-
* @param column The column to apply the 'contains' clause to.
|
|
165
|
-
* @param value The value for the 'contains' clause.
|
|
166
|
-
*/
|
|
167
|
-
addContainsClause(column, value) {
|
|
168
|
-
if (typeof value === "string") {
|
|
169
|
-
this.values.push([this.removeType(column), `cs.${value}`]);
|
|
170
|
-
}
|
|
171
|
-
else if (Array.isArray(value)) {
|
|
172
|
-
this.values.push([this.removeType(column), `cs.{${value.join(",")}}`]);
|
|
173
|
-
}
|
|
174
|
-
else {
|
|
175
|
-
this.values.push([
|
|
176
|
-
this.removeType(column),
|
|
177
|
-
`cs.${JSON.stringify(value)}`,
|
|
178
|
-
]);
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
/**
|
|
182
|
-
* Adds a 'textSearch' clause to the values array.
|
|
183
|
-
* @param column The column to apply the 'textSearch' clause to.
|
|
184
|
-
* @param query The query for the 'textSearch' clause.
|
|
185
|
-
* @param config Optional configuration for the 'textSearch' clause.
|
|
186
|
-
* @param type Optional type for the 'textSearch' clause.
|
|
187
|
-
*/
|
|
188
|
-
addTextSearchClause(column, query, { config, type, } = {}) {
|
|
189
|
-
let typePart = "";
|
|
190
|
-
if (type === "plain") {
|
|
191
|
-
typePart = "pl";
|
|
192
|
-
}
|
|
193
|
-
else if (type === "phrase") {
|
|
194
|
-
typePart = "ph";
|
|
195
|
-
}
|
|
196
|
-
else if (type === "websearch") {
|
|
197
|
-
typePart = "w";
|
|
198
|
-
}
|
|
199
|
-
const configPart = config === undefined ? "" : `(${config})`;
|
|
200
|
-
this.values.push([
|
|
201
|
-
this.removeType(column),
|
|
202
|
-
`${typePart}fts${configPart}.${query}`,
|
|
203
|
-
]);
|
|
204
|
-
}
|
|
205
|
-
/**
|
|
206
|
-
* Adds a 'not' clause to the values array.
|
|
207
|
-
* @param column The column to apply the 'not' clause to.
|
|
208
|
-
* @param operator The operator for the 'not' clause.
|
|
209
|
-
* @param value The value for the 'not' clause.
|
|
210
|
-
*/
|
|
211
|
-
addNotClause(column, operator, value) {
|
|
212
|
-
this.values.push([column, `not.${operator}.${value}`]);
|
|
213
|
-
}
|
|
214
|
-
/**
|
|
215
|
-
* Adds a 'match' clause to the values array.
|
|
216
|
-
* @param query The query for the 'match' clause.
|
|
217
|
-
*/
|
|
218
|
-
addMatchClause(query) {
|
|
219
|
-
Object.entries(query).forEach(([column, value]) => {
|
|
220
|
-
this.values.push([column, `eq.${value}`]);
|
|
221
|
-
});
|
|
222
|
-
}
|
|
223
|
-
/**
|
|
224
|
-
* Returns the flattened parameters as a string.
|
|
225
|
-
* @returns The flattened parameters as a string.
|
|
226
|
-
*/
|
|
227
|
-
flattenedParams() {
|
|
228
|
-
const mapped = this.values.map(([k, v]) => `${k}.${v}`);
|
|
229
|
-
if (mapped.length === 1)
|
|
230
|
-
return mapped[0];
|
|
231
|
-
return `and(${mapped.join(",")})`;
|
|
232
|
-
}
|
|
233
|
-
/**
|
|
234
|
-
* Gets flattened parameters from a `SupabaseFilter` and a
|
|
235
|
-
* `SupabaseFilterRPCCall`.
|
|
236
|
-
* @param rpc The `SupabaseFilter` object.
|
|
237
|
-
* @param filter The `SupabaseFilterRPCCall` object.
|
|
238
|
-
* @returns The flattened parameters as a string.
|
|
239
|
-
*/
|
|
240
|
-
static getFlattenedParams(
|
|
241
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
242
|
-
rpc,
|
|
243
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
244
|
-
filter) {
|
|
245
|
-
const proxiedDuplicator = new ProxyParamsDuplicator();
|
|
246
|
-
const proxiedRpc = new Proxy(rpc, proxiedDuplicator.buildProxyHandler());
|
|
247
|
-
void filter(proxiedRpc);
|
|
248
|
-
return proxiedDuplicator.flattenedParams();
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
exports.ProxyParamsDuplicator = ProxyParamsDuplicator;
|
|
252
|
-
/**
|
|
253
|
-
* Converts a `SupabaseMetadata` object into a `StructuredQuery` object.
|
|
254
|
-
* The function creates a new `StructuredQuery` object and uses the
|
|
255
|
-
* `Operation` and `Comparison` classes to build the query.
|
|
256
|
-
*/
|
|
257
|
-
function convertObjectFilterToStructuredQuery(
|
|
258
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
259
|
-
objFilter) {
|
|
260
|
-
return new structured_query_1.StructuredQuery("", new structured_query_1.Operation(structured_query_1.Operators.and, Object.entries(objFilter).map(
|
|
261
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
262
|
-
([column, value]) => new structured_query_1.Comparison(structured_query_1.Comparators.eq, column, value))));
|
|
263
|
-
}
|
|
264
|
-
exports.convertObjectFilterToStructuredQuery = convertObjectFilterToStructuredQuery;
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import { StructuredQuery } from "@langchain/core/structured_query";
|
|
2
|
-
/**
|
|
3
|
-
* Utility class used to duplicate parameters for a proxy object,
|
|
4
|
-
* specifically designed to work with `SupabaseFilter` objects. It
|
|
5
|
-
* contains methods to handle different types of operations such as "or",
|
|
6
|
-
* "filter", "in", "contains", "textSearch", "match", "not", and default
|
|
7
|
-
* operations.
|
|
8
|
-
*/
|
|
9
|
-
export declare class ProxyParamsDuplicator {
|
|
10
|
-
duplicationAllowedOps: string[];
|
|
11
|
-
values: [string, string][];
|
|
12
|
-
/**
|
|
13
|
-
* Creates a proxy handler for a `SupabaseFilter` object. The handler
|
|
14
|
-
* intercepts get operations and applies specific logic based on the
|
|
15
|
-
* property being accessed.
|
|
16
|
-
* @returns A proxy handler for a `SupabaseFilter` object.
|
|
17
|
-
*/
|
|
18
|
-
buildProxyHandler(): ProxyHandler<any>;
|
|
19
|
-
/**
|
|
20
|
-
* Removes type annotations from a value string.
|
|
21
|
-
* @param value The value string to clean.
|
|
22
|
-
* @returns The cleaned value string.
|
|
23
|
-
*/
|
|
24
|
-
removeType(value: string): string;
|
|
25
|
-
/**
|
|
26
|
-
* Adds a default operation clause to the values array.
|
|
27
|
-
* @param prop The operation property.
|
|
28
|
-
* @param column The column to apply the operation to.
|
|
29
|
-
* @param value The value for the operation.
|
|
30
|
-
*/
|
|
31
|
-
addDefaultOpClause(prop: string, column: string, value: unknown): void;
|
|
32
|
-
/**
|
|
33
|
-
* Adds an 'or' clause to the values array.
|
|
34
|
-
* @param filters The filters for the 'or' clause.
|
|
35
|
-
* @param foreignTable Optional foreign table for the 'or' clause.
|
|
36
|
-
*/
|
|
37
|
-
addOrClause(filters: string, { foreignTable }?: {
|
|
38
|
-
foreignTable?: string;
|
|
39
|
-
}): void;
|
|
40
|
-
/**
|
|
41
|
-
* Adds a 'filter' clause to the values array.
|
|
42
|
-
* @param column The column to apply the filter to.
|
|
43
|
-
* @param operator The operator for the filter.
|
|
44
|
-
* @param value The value for the filter.
|
|
45
|
-
*/
|
|
46
|
-
addFilterClause(column: string, operator: string, value: unknown): void;
|
|
47
|
-
/**
|
|
48
|
-
* Adds an 'in' clause to the values array.
|
|
49
|
-
* @param column The column to apply the 'in' clause to.
|
|
50
|
-
* @param values The values for the 'in' clause.
|
|
51
|
-
*/
|
|
52
|
-
addInClause(column: string, values: unknown[]): void;
|
|
53
|
-
/**
|
|
54
|
-
* Adds a 'contains' clause to the values array.
|
|
55
|
-
* @param column The column to apply the 'contains' clause to.
|
|
56
|
-
* @param value The value for the 'contains' clause.
|
|
57
|
-
*/
|
|
58
|
-
addContainsClause(column: string, value: unknown): void;
|
|
59
|
-
/**
|
|
60
|
-
* Adds a 'textSearch' clause to the values array.
|
|
61
|
-
* @param column The column to apply the 'textSearch' clause to.
|
|
62
|
-
* @param query The query for the 'textSearch' clause.
|
|
63
|
-
* @param config Optional configuration for the 'textSearch' clause.
|
|
64
|
-
* @param type Optional type for the 'textSearch' clause.
|
|
65
|
-
*/
|
|
66
|
-
addTextSearchClause(column: string, query: string[], { config, type, }?: {
|
|
67
|
-
config?: string;
|
|
68
|
-
type?: "plain" | "phrase" | "websearch";
|
|
69
|
-
}): void;
|
|
70
|
-
/**
|
|
71
|
-
* Adds a 'not' clause to the values array.
|
|
72
|
-
* @param column The column to apply the 'not' clause to.
|
|
73
|
-
* @param operator The operator for the 'not' clause.
|
|
74
|
-
* @param value The value for the 'not' clause.
|
|
75
|
-
*/
|
|
76
|
-
addNotClause(column: string, operator: string, value: unknown): void;
|
|
77
|
-
/**
|
|
78
|
-
* Adds a 'match' clause to the values array.
|
|
79
|
-
* @param query The query for the 'match' clause.
|
|
80
|
-
*/
|
|
81
|
-
addMatchClause(query: Record<string, unknown>): void;
|
|
82
|
-
/**
|
|
83
|
-
* Returns the flattened parameters as a string.
|
|
84
|
-
* @returns The flattened parameters as a string.
|
|
85
|
-
*/
|
|
86
|
-
flattenedParams(): string;
|
|
87
|
-
/**
|
|
88
|
-
* Gets flattened parameters from a `SupabaseFilter` and a
|
|
89
|
-
* `SupabaseFilterRPCCall`.
|
|
90
|
-
* @param rpc The `SupabaseFilter` object.
|
|
91
|
-
* @param filter The `SupabaseFilterRPCCall` object.
|
|
92
|
-
* @returns The flattened parameters as a string.
|
|
93
|
-
*/
|
|
94
|
-
static getFlattenedParams(rpc: any, filter: any): string;
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* Converts a `SupabaseMetadata` object into a `StructuredQuery` object.
|
|
98
|
-
* The function creates a new `StructuredQuery` object and uses the
|
|
99
|
-
* `Operation` and `Comparison` classes to build the query.
|
|
100
|
-
*/
|
|
101
|
-
export declare function convertObjectFilterToStructuredQuery(objFilter: any): StructuredQuery;
|