langchain 0.2.19 → 0.3.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 +9 -9
- package/dist/agents/chat/index.cjs +1 -1
- package/dist/agents/chat/index.d.ts +1 -1
- package/dist/agents/chat/index.js +1 -1
- package/dist/agents/chat_convo/index.cjs +1 -1
- package/dist/agents/chat_convo/index.d.ts +1 -1
- package/dist/agents/chat_convo/index.js +1 -1
- package/dist/agents/mrkl/index.cjs +1 -1
- package/dist/agents/mrkl/index.d.ts +1 -1
- package/dist/agents/mrkl/index.js +1 -1
- package/dist/agents/openai_functions/index.cjs +3 -3
- package/dist/agents/openai_functions/index.d.ts +1 -1
- package/dist/agents/openai_functions/index.js +3 -3
- package/dist/agents/structured_chat/index.cjs +1 -1
- package/dist/agents/structured_chat/index.d.ts +1 -1
- package/dist/agents/structured_chat/index.js +1 -1
- package/dist/agents/xml/index.cjs +1 -1
- package/dist/agents/xml/index.d.ts +1 -1
- package/dist/agents/xml/index.js +1 -1
- package/dist/chains/combine_documents/stuff.cjs +2 -2
- package/dist/chains/combine_documents/stuff.js +2 -2
- package/dist/chains/load.cjs +1 -1
- package/dist/chains/load.d.ts +1 -1
- package/dist/chains/load.js +1 -1
- package/dist/chains/openai_functions/structured_output.cjs +2 -2
- package/dist/chains/openai_functions/structured_output.d.ts +2 -2
- package/dist/chains/openai_functions/structured_output.js +2 -2
- package/dist/chains/serde.d.ts +12 -12
- package/dist/experimental/plan_and_execute/agent_executor.cjs +1 -1
- package/dist/experimental/plan_and_execute/agent_executor.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/output_parsers/openai_tools.cjs +2 -4
- package/dist/output_parsers/openai_tools.d.ts +8 -3
- package/dist/output_parsers/openai_tools.js +2 -4
- package/dist/retrievers/multi_query.d.ts +1 -0
- package/dist/smith/config.d.ts +1 -5
- package/package.json +31 -854
- 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/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,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;
|
|
@@ -1,259 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
-
import { Comparators, Comparison, Operation, Operators, StructuredQuery, } from "@langchain/core/structured_query";
|
|
3
|
-
/**
|
|
4
|
-
* Utility class used to duplicate parameters for a proxy object,
|
|
5
|
-
* specifically designed to work with `SupabaseFilter` objects. It
|
|
6
|
-
* contains methods to handle different types of operations such as "or",
|
|
7
|
-
* "filter", "in", "contains", "textSearch", "match", "not", and default
|
|
8
|
-
* operations.
|
|
9
|
-
*/
|
|
10
|
-
export class ProxyParamsDuplicator {
|
|
11
|
-
constructor() {
|
|
12
|
-
Object.defineProperty(this, "duplicationAllowedOps", {
|
|
13
|
-
enumerable: true,
|
|
14
|
-
configurable: true,
|
|
15
|
-
writable: true,
|
|
16
|
-
value: [
|
|
17
|
-
"eq",
|
|
18
|
-
"neq",
|
|
19
|
-
"lt",
|
|
20
|
-
"lte",
|
|
21
|
-
"gt",
|
|
22
|
-
"gte",
|
|
23
|
-
"like",
|
|
24
|
-
"ilike",
|
|
25
|
-
"or",
|
|
26
|
-
"in",
|
|
27
|
-
"contains",
|
|
28
|
-
"match",
|
|
29
|
-
"not",
|
|
30
|
-
"textSearch",
|
|
31
|
-
"filter",
|
|
32
|
-
]
|
|
33
|
-
});
|
|
34
|
-
Object.defineProperty(this, "values", {
|
|
35
|
-
enumerable: true,
|
|
36
|
-
configurable: true,
|
|
37
|
-
writable: true,
|
|
38
|
-
value: []
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Creates a proxy handler for a `SupabaseFilter` object. The handler
|
|
43
|
-
* intercepts get operations and applies specific logic based on the
|
|
44
|
-
* property being accessed.
|
|
45
|
-
* @returns A proxy handler for a `SupabaseFilter` object.
|
|
46
|
-
*/
|
|
47
|
-
buildProxyHandler() {
|
|
48
|
-
const proxyHandler = {
|
|
49
|
-
get: (target, prop, receiver) => {
|
|
50
|
-
if (typeof target[prop] === "function") {
|
|
51
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
52
|
-
return (...args) => {
|
|
53
|
-
if (this.duplicationAllowedOps.includes(String(prop))) {
|
|
54
|
-
switch (String(prop)) {
|
|
55
|
-
case "or":
|
|
56
|
-
// args[0]: filters, args[1]: { foreignTable }
|
|
57
|
-
this.addOrClause(args[0], args[1]);
|
|
58
|
-
break;
|
|
59
|
-
case "filter":
|
|
60
|
-
// args[0]: column, args[1]: operator, args[2]: value
|
|
61
|
-
this.addFilterClause(args[0], args[1], args[2]);
|
|
62
|
-
break;
|
|
63
|
-
case "in":
|
|
64
|
-
// args[0]: column, args[1]: values
|
|
65
|
-
this.addInClause(args[0], args[1]);
|
|
66
|
-
break;
|
|
67
|
-
case "contains":
|
|
68
|
-
// args[0]: column, args[1]: value
|
|
69
|
-
this.addContainsClause(args[0], args[1]);
|
|
70
|
-
break;
|
|
71
|
-
case "textSearch":
|
|
72
|
-
// args[0]: column, args[1]: query, args[2]: { config, type }
|
|
73
|
-
this.addTextSearchClause(args[0], args[1], args[2]);
|
|
74
|
-
break;
|
|
75
|
-
case "match":
|
|
76
|
-
// args[0]: query
|
|
77
|
-
this.addMatchClause(args[0]);
|
|
78
|
-
break;
|
|
79
|
-
case "not":
|
|
80
|
-
// args[0]: column, args[1]: operator, args[2]: value
|
|
81
|
-
this.addNotClause(args[0], args[1], args[2]);
|
|
82
|
-
break;
|
|
83
|
-
default:
|
|
84
|
-
// args[0]: column, args[1]: value
|
|
85
|
-
this.addDefaultOpClause(prop, args[0], args[1]);
|
|
86
|
-
}
|
|
87
|
-
return new Proxy(target, proxyHandler);
|
|
88
|
-
}
|
|
89
|
-
else {
|
|
90
|
-
throw new Error("Filter operation not supported for 'or' mergeFiltersOperator");
|
|
91
|
-
}
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
else {
|
|
95
|
-
return Reflect.get(target, prop, receiver);
|
|
96
|
-
}
|
|
97
|
-
},
|
|
98
|
-
};
|
|
99
|
-
return proxyHandler;
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* Removes type annotations from a value string.
|
|
103
|
-
* @param value The value string to clean.
|
|
104
|
-
* @returns The cleaned value string.
|
|
105
|
-
*/
|
|
106
|
-
removeType(value) {
|
|
107
|
-
let cleanedValue = value;
|
|
108
|
-
if (cleanedValue.includes("::float")) {
|
|
109
|
-
cleanedValue = cleanedValue.replace("::float", "");
|
|
110
|
-
}
|
|
111
|
-
if (cleanedValue.includes("::int")) {
|
|
112
|
-
cleanedValue = cleanedValue.replace("::int", "");
|
|
113
|
-
}
|
|
114
|
-
return cleanedValue;
|
|
115
|
-
}
|
|
116
|
-
/**
|
|
117
|
-
* Adds a default operation clause to the values array.
|
|
118
|
-
* @param prop The operation property.
|
|
119
|
-
* @param column The column to apply the operation to.
|
|
120
|
-
* @param value The value for the operation.
|
|
121
|
-
*/
|
|
122
|
-
addDefaultOpClause(prop, column, value) {
|
|
123
|
-
this.values.push([this.removeType(column), `${String(prop)}.${value}`]);
|
|
124
|
-
}
|
|
125
|
-
/**
|
|
126
|
-
* Adds an 'or' clause to the values array.
|
|
127
|
-
* @param filters The filters for the 'or' clause.
|
|
128
|
-
* @param foreignTable Optional foreign table for the 'or' clause.
|
|
129
|
-
*/
|
|
130
|
-
addOrClause(filters, { foreignTable } = {}) {
|
|
131
|
-
const key = foreignTable ? `${foreignTable}.or` : "or";
|
|
132
|
-
this.values.push([this.removeType(key), `(${filters})`]);
|
|
133
|
-
}
|
|
134
|
-
/**
|
|
135
|
-
* Adds a 'filter' clause to the values array.
|
|
136
|
-
* @param column The column to apply the filter to.
|
|
137
|
-
* @param operator The operator for the filter.
|
|
138
|
-
* @param value The value for the filter.
|
|
139
|
-
*/
|
|
140
|
-
addFilterClause(column, operator, value) {
|
|
141
|
-
this.values.push([this.removeType(column), `${operator}.${value}`]);
|
|
142
|
-
}
|
|
143
|
-
/**
|
|
144
|
-
* Adds an 'in' clause to the values array.
|
|
145
|
-
* @param column The column to apply the 'in' clause to.
|
|
146
|
-
* @param values The values for the 'in' clause.
|
|
147
|
-
*/
|
|
148
|
-
addInClause(column, values) {
|
|
149
|
-
const cleanedValues = values
|
|
150
|
-
.map((s) => {
|
|
151
|
-
if (typeof s === "string" && /[,()]/.test(s))
|
|
152
|
-
return `"${s}"`;
|
|
153
|
-
else
|
|
154
|
-
return `${s}`;
|
|
155
|
-
})
|
|
156
|
-
.join(",");
|
|
157
|
-
this.values.push([this.removeType(column), `in.(${cleanedValues})`]);
|
|
158
|
-
}
|
|
159
|
-
/**
|
|
160
|
-
* Adds a 'contains' clause to the values array.
|
|
161
|
-
* @param column The column to apply the 'contains' clause to.
|
|
162
|
-
* @param value The value for the 'contains' clause.
|
|
163
|
-
*/
|
|
164
|
-
addContainsClause(column, value) {
|
|
165
|
-
if (typeof value === "string") {
|
|
166
|
-
this.values.push([this.removeType(column), `cs.${value}`]);
|
|
167
|
-
}
|
|
168
|
-
else if (Array.isArray(value)) {
|
|
169
|
-
this.values.push([this.removeType(column), `cs.{${value.join(",")}}`]);
|
|
170
|
-
}
|
|
171
|
-
else {
|
|
172
|
-
this.values.push([
|
|
173
|
-
this.removeType(column),
|
|
174
|
-
`cs.${JSON.stringify(value)}`,
|
|
175
|
-
]);
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
/**
|
|
179
|
-
* Adds a 'textSearch' clause to the values array.
|
|
180
|
-
* @param column The column to apply the 'textSearch' clause to.
|
|
181
|
-
* @param query The query for the 'textSearch' clause.
|
|
182
|
-
* @param config Optional configuration for the 'textSearch' clause.
|
|
183
|
-
* @param type Optional type for the 'textSearch' clause.
|
|
184
|
-
*/
|
|
185
|
-
addTextSearchClause(column, query, { config, type, } = {}) {
|
|
186
|
-
let typePart = "";
|
|
187
|
-
if (type === "plain") {
|
|
188
|
-
typePart = "pl";
|
|
189
|
-
}
|
|
190
|
-
else if (type === "phrase") {
|
|
191
|
-
typePart = "ph";
|
|
192
|
-
}
|
|
193
|
-
else if (type === "websearch") {
|
|
194
|
-
typePart = "w";
|
|
195
|
-
}
|
|
196
|
-
const configPart = config === undefined ? "" : `(${config})`;
|
|
197
|
-
this.values.push([
|
|
198
|
-
this.removeType(column),
|
|
199
|
-
`${typePart}fts${configPart}.${query}`,
|
|
200
|
-
]);
|
|
201
|
-
}
|
|
202
|
-
/**
|
|
203
|
-
* Adds a 'not' clause to the values array.
|
|
204
|
-
* @param column The column to apply the 'not' clause to.
|
|
205
|
-
* @param operator The operator for the 'not' clause.
|
|
206
|
-
* @param value The value for the 'not' clause.
|
|
207
|
-
*/
|
|
208
|
-
addNotClause(column, operator, value) {
|
|
209
|
-
this.values.push([column, `not.${operator}.${value}`]);
|
|
210
|
-
}
|
|
211
|
-
/**
|
|
212
|
-
* Adds a 'match' clause to the values array.
|
|
213
|
-
* @param query The query for the 'match' clause.
|
|
214
|
-
*/
|
|
215
|
-
addMatchClause(query) {
|
|
216
|
-
Object.entries(query).forEach(([column, value]) => {
|
|
217
|
-
this.values.push([column, `eq.${value}`]);
|
|
218
|
-
});
|
|
219
|
-
}
|
|
220
|
-
/**
|
|
221
|
-
* Returns the flattened parameters as a string.
|
|
222
|
-
* @returns The flattened parameters as a string.
|
|
223
|
-
*/
|
|
224
|
-
flattenedParams() {
|
|
225
|
-
const mapped = this.values.map(([k, v]) => `${k}.${v}`);
|
|
226
|
-
if (mapped.length === 1)
|
|
227
|
-
return mapped[0];
|
|
228
|
-
return `and(${mapped.join(",")})`;
|
|
229
|
-
}
|
|
230
|
-
/**
|
|
231
|
-
* Gets flattened parameters from a `SupabaseFilter` and a
|
|
232
|
-
* `SupabaseFilterRPCCall`.
|
|
233
|
-
* @param rpc The `SupabaseFilter` object.
|
|
234
|
-
* @param filter The `SupabaseFilterRPCCall` object.
|
|
235
|
-
* @returns The flattened parameters as a string.
|
|
236
|
-
*/
|
|
237
|
-
static getFlattenedParams(
|
|
238
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
239
|
-
rpc,
|
|
240
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
241
|
-
filter) {
|
|
242
|
-
const proxiedDuplicator = new ProxyParamsDuplicator();
|
|
243
|
-
const proxiedRpc = new Proxy(rpc, proxiedDuplicator.buildProxyHandler());
|
|
244
|
-
void filter(proxiedRpc);
|
|
245
|
-
return proxiedDuplicator.flattenedParams();
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
/**
|
|
249
|
-
* Converts a `SupabaseMetadata` object into a `StructuredQuery` object.
|
|
250
|
-
* The function creates a new `StructuredQuery` object and uses the
|
|
251
|
-
* `Operation` and `Comparison` classes to build the query.
|
|
252
|
-
*/
|
|
253
|
-
export function convertObjectFilterToStructuredQuery(
|
|
254
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
255
|
-
objFilter) {
|
|
256
|
-
return new StructuredQuery("", new Operation(Operators.and, Object.entries(objFilter).map(
|
|
257
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
258
|
-
([column, value]) => new Comparison(Comparators.eq, column, value))));
|
|
259
|
-
}
|