UNPKG

@tanstack/react-db

Version:

React integration for @tanstack/db

1 lines • 1.37 kB
{"version":3,"file":"source-id-bindings.cjs","names":["getPreparedLiveQuerySources"],"sources":["../../src/source-id-bindings.ts"],"sourcesContent":["import { getPreparedLiveQuerySources } from '@tanstack/db'\nimport type { DbClient } from '@tanstack/db'\n\n/**\n * Reports a descriptor source that no DbClient bound, naming the provider a\n * React tree needs. Returns `undefined` when a client can bind descriptors.\n */\nexport function getUnboundDescriptorReporter(\n client: DbClient | undefined,\n hookName: string,\n): ((alias: string) => never) | undefined {\n if (client) return undefined\n return (alias) => {\n throw new Error(\n `[${hookName}] Collection descriptor \"${alias}\" requires a DbClient when the query is consumed. Wrap this component in <DbProvider client={client}> or use a concrete Collection.`,\n )\n }\n}\n\nexport function getPreparedSources(\n preparedValue: unknown,\n client: DbClient | undefined,\n hookName: string,\n): Array<{ id: string }> {\n return getPreparedLiveQuerySources(\n preparedValue,\n getUnboundDescriptorReporter(client, hookName),\n )\n}\n"],"mappings":";;;;;;AAOA,SAAgB,6BACd,QACA,UACwC;CACxC,IAAI,QAAQ,OAAO,KAAA;CACnB,QAAQ,UAAU;EAChB,MAAM,IAAI,MACR,IAAI,SAAS,2BAA2B,MAAM,oIAChD;CACF;AACF;AAEA,SAAgB,mBACd,eACA,QACA,UACuB;CACvB,QAAA,GAAOA,aAAAA,4BAAAA,CACL,eACA,6BAA6B,QAAQ,QAAQ,CAC/C;AACF"}