{"name":"svelte-query-pocketbase","description":"TanStack Query wrappers around Pocketbase Realtime for Svelte","version":"0.0.1-beta.11","type":"module","dependencies":{"@tanstack/svelte-query":"^4.22.2","immer":"^9.0.19","pocketbase":"^0.11.1","svelte":"^3.54.0"},"devDependencies":{"@changesets/changelog-github":"0.4.8","@changesets/cli":"2.26.0","@commitlint/cli":"17.4.2","@commitlint/config-conventional":"17.4.2","@commitlint/prompt-cli":"17.4.2","@sveltejs/adapter-node":"1.1.4","@sveltejs/kit":"1.3.2","@types/lodash":"4.14.191","@typescript-eslint/eslint-plugin":"5.49.0","@typescript-eslint/parser":"5.49.0","autoprefixer":"10.4.13","eslint":"8.32.0","eslint-config-prettier":"8.6.0","eslint-plugin-svelte3":"4.0.0","husky":"8.0.3","lodash":"4.17.21","postcss":"8.4.21","prettier":"2.8.3","prettier-plugin-svelte":"2.9.0","svelte-check":"3.0.3","tailwindcss":"3.2.4","tslib":"2.5.0","tsup":"6.5.0","typescript":"4.9.4","vite":"4.0.4","vitest":"0.28.3"},"tsup":{"entry":["src/lib/index.ts"],"format":["esm","cjs","iife"],"sourcemap":true,"minify":true,"clean":true,"dts":true},"keywords":["svelte","svelte store","pocketbase","pocketbase realtime","tanstack","tanstack query","realtime"],"exports":{".":"./dist/index.js"},"module":"dist/index.js","types":"dist/index.d.ts","homepage":"https://github.com/goknsh/svelte-query-pocketbase#readme","repository":{"type":"git","url":"git+https://github.com/goknsh/svelte-query-pocketbase.git"},"license":"MIT","author":{"name":"Akaanksh Raj","email":"email@ark.black","url":"https://ark.black"},"publishConfig":{"access":"public"},"scripts":{"dev":"vite dev","build":"svelte-kit sync && tsup","changeset":"changeset","release":"svelte-kit sync && tsup && changeset publish","commit":"commit","check":"svelte-kit sync && svelte-check --tsconfig ./tsconfig.json","check:watch":"svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch","test:unit":"vitest","lint":"prettier --plugin-search-dir . --check . && eslint .","format":"prettier --plugin-search-dir . --write ."},"readme":"# svelte-query-pocketbase\n\nTanStack Query wrappers around Pocketbase Realtime for Svelte.\n\n## Installation\n\n```\nnpm i -D svelte-query-pocketbase\n```\n\n## Record Query\n\nCreates a TanStack Query that updates a Pocketbase record in realtime. View the JSDoc for the relevant functions for more documentation on their available options.\n\n### Simple Example\n\n<details>\n\t<summary>View Code</summary>\n\n```svelte\n<script lang=\"ts\">\n\timport Pocketbase from 'pocketbase';\n\timport { PUBLIC_POCKETBASE_URL } from '$env/static/public';\n\n\t// Types generated from https://github.com/patmood/pocketbase-typegen\n\timport { Collections, type SomeCollectionResponse } from '$lib/collections';\n\n\timport { createRecordQuery } from 'svelte-query-pocketbase';\n\n\tconst pocketbase = new Pocketbase(PUBLIC_POCKETBASE_URL);\n\n\tconst someRecord = createRecordQuery<SomeCollectionResponse>(\n\t\tpocketbase.collection(Collections.SomeCollection),\n\t\t'some_id'\n\t);\n</script>\n\n{#if $someRecord.data}\n\t<p>Fetched record:</p>\n\t<pre>{JSON.stringify($someRecord.data, null, 2)}</pre>\n{:else if $someRecord.error}\n\t{#if $someRecord.error.status === 404}\n\t\t<p>The record couldn't be found in the database.</p>\n\t{:else}\n\t\t<p>Something went wrong.</p>\n\t\t<button on:click={() => $someRecord.refetch()}>Try again</button>\n\t{/if}\n{:else}\n\t<p>Loading...</p>\n{/if}\n```\n\n</details>\n\n### With Query Params\n\n<details>\n\t<summary>View Code</summary>\n\n```svelte\n<script lang=\"ts\">\n\timport Pocketbase from 'pocketbase';\n\timport { PUBLIC_POCKETBASE_URL } from '$env/static/public';\n\n\t// Types generated from https://github.com/patmood/pocketbase-typegen\n\timport { Collections, type SomeCollectionResponse } from '$lib/collections';\n\n\timport { createRecordQuery } from 'svelte-query-pocketbase';\n\n\tconst pocketbase = new Pocketbase(PUBLIC_POCKETBASE_URL);\n\n\tconst someRecord = createRecordQuery<SomeCollectionResponse>(\n\t\tpocketbase.collection(Collections.SomeCollection),\n\t\t'some_id',\n\t\t{ queryParams: { expand: 'some_field' } }\n\t);\n</script>\n\n{#if $someRecord.data}\n\t<p>Fetched record, with some_field expanded:</p>\n\t<pre>{JSON.stringify($someRecord.data, null, 2)}</pre>\n{:else if $someRecord.error}\n\t{#if $someRecord.error.status === 404}\n\t\t<p>The record couldn't be found in the database.</p>\n\t{:else}\n\t\t<p>Something went wrong.</p>\n\t\t<button on:click={() => $someRecord.refetch()}>Try again</button>\n\t{/if}\n{:else}\n\t<p>Loading...</p>\n{/if}\n```\n\n</details>\n\n### Using SSR\n\nRead [TanStack Query's docs on this](https://tanstack.com/query/v4/docs/svelte/ssr) first. The examples below are modified versions of the examples on that page.\n\n#### Using `initialData`\n\n<details>\n\t<summary>View Code</summary>\n\n**src/routes/+page.ts**\n\n```ts\nimport type { PageLoad } from './$types';\n\nimport Pocketbase from 'pocketbase';\nimport { PUBLIC_POCKETBASE_URL } from '$env/static/public';\n\n// Types generated from https://github.com/patmood/pocketbase-typegen\nimport { Collections, type SomeCollectionResponse } from '$lib/collections';\n\nimport { createRecordQueryInitialData } from 'svelte-query-pocketbase';\n\nexport const load: PageLoad = async () => {\n\tconst someIdInitialData = await createRecordQueryInitialData<SomeCollectionResponse>(\n\t\tpocketbase.collection(Collections.SomeCollection),\n\t\t'some_id'\n\t);\n\treturn { someIdInitialData };\n};\n```\n\n**src/routes/+page.svelte**\n\n```svelte\n<script lang=\"ts\">\n\timport Pocketbase from 'pocketbase';\n\timport { PUBLIC_POCKETBASE_URL } from '$env/static/public';\n\n\timport type { PageData } from './$types';\n\texport let data: PageData;\n\n\t// Types generated from https://github.com/patmood/pocketbase-typegen\n\timport { Collections, type SomeCollectionResponse } from '$lib/collections';\n\n\timport { createRecordQuery } from 'svelte-query-pocketbase';\n\n\tconst pocketbase = new Pocketbase(PUBLIC_POCKETBASE_URL);\n\n\tconst someRecord = createRecordQuery<SomeCollectionResponse>(\n\t\tpocketbase.collection(Collections.SomeCollection),\n\t\t'some_id',\n\t\t{\n\t\t\tinitialData: data.someIdInitialData\n\t\t}\n\t);\n</script>\n```\n\n</details>\n\n#### Using `prefetchQuery`\n\n<details>\n\t<summary>View Code</summary>\n\n**src/routes/+layout.ts**\n\n_Same as TanStack Query's docs_\n\n**src/routes/+layout.svelte**\n\n_Same as TanStack Query's docs_\n\n**src/routes/+page.ts**\n\n```ts\nimport type { PageLoad } from './$types';\n\nimport Pocketbase from 'pocketbase';\nimport { PUBLIC_POCKETBASE_URL } from '$env/static/public';\n\n// Types generated from https://github.com/patmood/pocketbase-typegen\nimport { Collections, type SomeCollectionResponse } from '$lib/collections';\n\nimport { createRecordQueryPrefetch } from 'svelte-query-pocketbase';\n\nexport const load: PageLoad = async ({ parent }) => {\n\tconst { queryClient } = await parent();\n\n\t// As long as the same collection, id, and queryParams are supplied to\n\t// `createRecordQueryPrefetch` and `createRecordQuery`, the library will\n\t// generate the same `queryKey`s for both functions, and you need not specify one\n\tawait queryClient.prefetchQuery(\n\t\tcreateRecordQueryPrefetch<SomeCollectionResponse>(\n\t\t\tpocketbase.collection(Collections.SomeCollection),\n\t\t\t'some_id'\n\t\t)\n\t);\n};\n```\n\n**src/routes/+page.svelte**\n\n```svelte\n<script lang=\"ts\">\n\timport Pocketbase from 'pocketbase';\n\timport { PUBLIC_POCKETBASE_URL } from '$env/static/public';\n\n\timport type { PageData } from './$types';\n\texport let data: PageData;\n\n\t// Types generated from https://github.com/patmood/pocketbase-typegen\n\timport { Collections, type SomeCollectionResponse } from '$lib/collections';\n\n\timport { createRecordQuery } from 'svelte-query-pocketbase';\n\n\tconst pocketbase = new Pocketbase(PUBLIC_POCKETBASE_URL);\n\n\t// This data is cached by prefetchQuery in +page.ts so no fetch actually happens here\n\tconst someRecord = createRecordQuery<SomeCollectionResponse>(\n\t\tpocketbase.collection(Collections.SomeCollection),\n\t\t'some_id'\n\t);\n</script>\n```\n\n</details>\n\n## Collection Query\n\nCreates a TanStack Query that updates an array of Pocketbase records in realtime. View the JSDoc for the relevant functions for more documentation on their available options.\n\n### Simple Example\n\n<details>\n\t<summary>View Code</summary>\n\n```svelte\n<script lang=\"ts\">\n\timport Pocketbase from 'pocketbase';\n\timport { PUBLIC_POCKETBASE_URL } from '$env/static/public';\n\n\t// Types generated from https://github.com/patmood/pocketbase-typegen\n\timport { Collections, type SomeCollectionResponse } from '$lib/collections';\n\n\timport { createCollectionQuery } from 'svelte-query-pocketbase';\n\n\tconst pocketbase = new Pocketbase(PUBLIC_POCKETBASE_URL);\n\n\tconst someCollection = createCollectionQuery<SomeCollectionResponse>(\n\t\tpocketbase.collection(Collections.SomeCollection)\n\t);\n</script>\n\n{#if $someCollection.data}\n\t<p>Fetched collection:</p>\n\t<pre>{JSON.stringify($someCollection.data, null, 2)}</pre>\n{:else if $someCollection.error}\n\t{#if $someCollection.error.status === 404}\n\t\t<p>The collection couldn't be found in the database.</p>\n\t{:else}\n\t\t<p>Something went wrong.</p>\n\t\t<button on:click={() => $someCollection.refetch()}>Try again</button>\n\t{/if}\n{:else}\n\t<p>Loading...</p>\n{/if}\n```\n\n</details>\n\n### With Query Params\n\n<details>\n\t<summary>View Code</summary>\n\n```svelte\n<script lang=\"ts\">\n\timport Pocketbase from 'pocketbase';\n\timport { PUBLIC_POCKETBASE_URL } from '$env/static/public';\n\n\t// Types generated from https://github.com/patmood/pocketbase-typegen\n\timport { Collections, type SomeCollectionResponse } from '$lib/collections';\n\n\timport { createCollectionQuery } from 'svelte-query-pocketbase';\n\n\tconst pocketbase = new Pocketbase(PUBLIC_POCKETBASE_URL);\n\n\tconst someCollection = createCollectionQuery<SomeCollectionResponse>(\n\t\tpocketbase.collection(Collections.SomeCollection),\n\t\t{\n\t\t\tqueryParams: {\n\t\t\t\texpand: 'some_field',\n\t\t\t\tsort: '-created', // sort by date created, descending\n\t\t\t\tfilter: 'created >= \"2022-01-01 00:00:00\"'\n\t\t\t},\n\t\t\t// sortFunction and filterFunction are applied after a realtime update is applied\n\t\t\tsortFunction: (a, b) => new Date(a.created) - new Date(b.created) // sort by date created, descending\n\t\t\tfilterFunction: (record) => new Date(record.created) >= new Date(\"2022-01-01 00:00:00\")\n\t\t}\n\t);\n</script>\n\n{#if $someCollection.data}\n\t<p>\n\t\tFetched collection, with some_field expanded, sorted by date created (descending), and filtered\n\t\tby date created after 2022-01-01 00:00:00:\n\t</p>\n\t<pre>{JSON.stringify($someCollection.data, null, 2)}</pre>\n{:else if $someCollection.error}\n\t{#if $someCollection.error.status === 404}\n\t\t<p>The collection couldn't be found in the database.</p>\n\t{:else}\n\t\t<p>Something went wrong.</p>\n\t\t<button on:click={() => $someCollection.refetch()}>Try again</button>\n\t{/if}\n{:else}\n\t<p>Loading...</p>\n{/if}\n```\n\n</details>\n\n### Using SSR\n\nRead [TanStack Query's docs on this](https://tanstack.com/query/v4/docs/svelte/ssr) first. The examples below are modified versions of the examples on that page.\n\n#### Using `initialData`\n\n<details>\n\t<summary>View Code</summary>\n\n**src/routes/+page.ts**\n\n```ts\nimport type { PageLoad } from './$types';\n\nimport Pocketbase from 'pocketbase';\nimport { PUBLIC_POCKETBASE_URL } from '$env/static/public';\n\n// Types generated from https://github.com/patmood/pocketbase-typegen\nimport { Collections, type SomeCollectionResponse } from '$lib/collections';\n\nimport { createCollectionQueryInitialData } from 'svelte-query-pocketbase';\n\nexport const load: PageLoad = async () => {\n\tconst someCollectionInitialData = await createCollectionQueryInitialData<SomeCollectionResponse>(\n\t\tpocketbase.collection(Collections.SomeCollection)\n\t);\n\treturn { someCollectionInitialData };\n};\n```\n\n**src/routes/+page.svelte**\n\n```svelte\n<script lang=\"ts\">\n\timport Pocketbase from 'pocketbase';\n\timport { PUBLIC_POCKETBASE_URL } from '$env/static/public';\n\n\timport type { PageData } from './$types';\n\texport let data: PageData;\n\n\t// Types generated from https://github.com/patmood/pocketbase-typegen\n\timport { Collections, type SomeCollectionResponse } from '$lib/collections';\n\n\timport { createCollectionQuery } from 'svelte-query-pocketbase';\n\n\tconst pocketbase = new Pocketbase(PUBLIC_POCKETBASE_URL);\n\n\tconst someCollection = createCollectionQuery<SomeCollectionResponse>(\n\t\tpocketbase.collection(Collections.SomeCollection),\n\t\t{\n\t\t\tinitialData: data.someCollectionInitialData\n\t\t}\n\t);\n</script>\n```\n\n</details>\n\n#### Using `prefetchQuery`\n\n<details>\n\t<summary>View Code</summary>\n\n**src/routes/+layout.ts**\n\n_Same as TanStack Query's docs_\n\n**src/routes/+layout.svelte**\n\n_Same as TanStack Query's docs_\n\n**src/routes/+page.ts**\n\n```ts\nimport type { PageLoad } from './$types';\n\nimport Pocketbase from 'pocketbase';\nimport { PUBLIC_POCKETBASE_URL } from '$env/static/public';\n\n// Types generated from https://github.com/patmood/pocketbase-typegen\nimport { Collections, type SomeCollectionResponse } from '$lib/collections';\n\nimport { createCollectionQueryPrefetch } from 'svelte-query-pocketbase';\n\nexport const load: PageLoad = async ({ parent }) => {\n\tconst { queryClient } = await parent();\n\n\t// As long as the same collection, id, and queryParams are supplied to\n\t// `createCollectionQueryPrefetch` and `createCollectionQuery`, the library will\n\t// generate the same `queryKey`s for both functions, and you need not specify one\n\tawait queryClient.prefetchQuery(\n\t\tcreateCollectionQueryPrefetch<SomeCollectionResponse>(\n\t\t\tpocketbase.collection(Collections.SomeCollection)\n\t\t)\n\t);\n};\n```\n\n**src/routes/+page.svelte**\n\n```svelte\n<script lang=\"ts\">\n\timport Pocketbase from 'pocketbase';\n\timport { PUBLIC_POCKETBASE_URL } from '$env/static/public';\n\n\timport type { PageData } from './$types';\n\texport let data: PageData;\n\n\t// Types generated from https://github.com/patmood/pocketbase-typegen\n\timport { Collections, type SomeCollectionResponse } from '$lib/collections';\n\n\timport { createCollectionQuery } from 'svelte-query-pocketbase';\n\n\tconst pocketbase = new Pocketbase(PUBLIC_POCKETBASE_URL);\n\n\t// This data is cached by prefetchQuery in +page.ts so no fetch actually happens here\n\tconst someCollection = createCollectionQuery<SomeCollectionResponse>(\n\t\tpocketbase.collection(Collections.SomeCollection)\n\t);\n</script>\n```\n\n</details>\n\n## Infinite Collection Query\n\nCreates a TanStack Infinite Query that updates paginated Pocketbase records in realtime. View the JSDoc for the relevant functions for more documentation on their available options.\n\n### Simple Example\n\n<details>\n\t<summary>View Code</summary>\n\n```svelte\n<script lang=\"ts\">\n\timport Pocketbase from 'pocketbase';\n\timport { PUBLIC_POCKETBASE_URL } from '$env/static/public';\n\n\t// Types generated from https://github.com/patmood/pocketbase-typegen\n\timport { Collections, type SomeCollectionResponse } from '$lib/collections';\n\n\timport { createInfiniteCollectionQuery } from 'svelte-query-pocketbase';\n\n\tconst pocketbase = new Pocketbase(PUBLIC_POCKETBASE_URL);\n\n\tconst someInfiniteCollection = createInfiniteCollectionQuery<SomeCollectionResponse>(\n\t\tpocketbase.collection(Collections.SomeCollection)\n\t);\n</script>\n\n{#if $someInfiniteCollection.data}\n\t<p>Fetched infinite collection:</p>\n\t<pre>{JSON.stringify($someInfiniteCollection.data, null, 2)}</pre>\n\t{#if $someInfiniteCollection.hasNextPage}\n\t\t<button\n\t\t\ton:click={() => $someInfiniteCollection.fetchNextPage()}\n\t\t\tdisabled={$someInfiniteCollection.isFetchingNextPage}\n\t\t\t>{$someInfiniteCollection.isFetchingNextPage\n\t\t\t\t? 'Fetching next page...'\n\t\t\t\t: 'Fetch next page'}</button\n\t\t>\n\t{/if}\n{:else if $someInfiniteCollection.error}\n\t{#if $someInfiniteCollection.error.status === 404}\n\t\t<p>The collection couldn't be found in the database.</p>\n\t{:else}\n\t\t<p>Something went wrong.</p>\n\t\t<button on:click={() => $someInfiniteCollection.refetch()}>Try again</button>\n\t{/if}\n{:else}\n\t<p>Loading...</p>\n{/if}\n```\n\n</details>\n\n### With Query Params\n\n<details>\n\t<summary>View Code</summary>\n\n```svelte\n<script lang=\"ts\">\n\timport Pocketbase from 'pocketbase';\n\timport { PUBLIC_POCKETBASE_URL } from '$env/static/public';\n\n\t// Types generated from https://github.com/patmood/pocketbase-typegen\n\timport { Collections, type SomeCollectionResponse } from '$lib/collections';\n\n\timport { createInfiniteCollectionQuery } from 'svelte-query-pocketbase';\n\n\tconst pocketbase = new Pocketbase(PUBLIC_POCKETBASE_URL);\n\n\tconst someInfiniteCollection = createInfiniteCollectionQuery<SomeCollectionResponse>(\n\t\tpocketbase.collection(Collections.SomeCollection),\n\t\t{\n\t\t\tqueryParams: {\n\t\t\t\texpand: 'some_field',\n\t\t\t\tsort: '-created', // sort by date created, descending\n\t\t\t\tfilter: 'created >= \"2022-01-01 00:00:00\"'\n\t\t\t},\n\t\t\t// sortFunction and filterFunction are applied after a realtime update is applied\n\t\t\tsortFunction: (a, b) => new Date(a.created) - new Date(b.created) // sort by date created, descending\n\t\t\tfilterFunction: (record) => new Date(record.created) >= new Date(\"2022-01-01 00:00:00\")\n\t\t}\n\t);\n</script>\n\n{#if $someInfiniteCollection.data}\n\t<p>\n\t\tFetched infinite collection, with some_field expanded, sorted by date created (descending), and\n\t\tfiltered by date created after 2022-01-01 00:00:00:\n\t</p>\n\t<pre>{JSON.stringify($someInfiniteCollection.data, null, 2)}</pre>\n\t{#if $someInfiniteCollection.hasNextPage}\n\t\t<button\n\t\t\ton:click={() => $someInfiniteCollection.fetchNextPage()}\n\t\t\tdisabled={$someInfiniteCollection.isFetchingNextPage}\n\t\t\t>{$someInfiniteCollection.isFetchingNextPage\n\t\t\t\t? 'Fetching next page...'\n\t\t\t\t: 'Fetch next page'}</button\n\t\t>\n\t{/if}\n{:else if $someInfiniteCollection.error}\n\t{#if $someInfiniteCollection.error.status === 404}\n\t\t<p>The collection couldn't be found in the database.</p>\n\t{:else}\n\t\t<p>Something went wrong.</p>\n\t\t<button on:click={() => $someInfiniteCollection.refetch()}>Try again</button>\n\t{/if}\n{:else}\n\t<p>Loading...</p>\n{/if}\n```\n\n</details>\n\n### Using SSR\n\nRead [TanStack Query's docs on this](https://tanstack.com/query/v4/docs/svelte/ssr) first. The examples below are modified versions of the examples on that page.\n\n#### Using `initialData`\n\n<details>\n\t<summary>View Code</summary>\n\n**src/routes/+page.ts**\n\n```ts\nimport type { PageLoad } from './$types';\n\nimport Pocketbase from 'pocketbase';\nimport { PUBLIC_POCKETBASE_URL } from '$env/static/public';\n\n// Types generated from https://github.com/patmood/pocketbase-typegen\nimport { Collections, type SomeCollectionResponse } from '$lib/collections';\n\nimport { infiniteCollectionQueryInitialData } from 'svelte-query-pocketbase';\n\nexport const load: PageLoad = async () => {\n\tconst someInfiniteCollectionInitialData =\n\t\tawait infiniteCollectionQueryInitialData<SomeCollectionResponse>(\n\t\t\tpocketbase.collection(Collections.SomeCollection)\n\t\t);\n\treturn { someInfiniteCollectionInitialData };\n};\n```\n\n**src/routes/+page.svelte**\n\n```svelte\n<script lang=\"ts\">\n\timport Pocketbase from 'pocketbase';\n\timport { PUBLIC_POCKETBASE_URL } from '$env/static/public';\n\n\timport type { PageData } from './$types';\n\texport let data: PageData;\n\n\t// Types generated from https://github.com/patmood/pocketbase-typegen\n\timport { Collections, type SomeCollectionResponse } from '$lib/collections';\n\n\timport { createInfiniteCollectionQuery } from 'svelte-query-pocketbase';\n\n\tconst pocketbase = new Pocketbase(PUBLIC_POCKETBASE_URL);\n\n\tconst someInfiniteCollection = createInfiniteCollectionQuery<SomeCollectionResponse>(\n\t\tpocketbase.collection(Collections.SomeCollection),\n\t\t{\n\t\t\tinitialData: data.someInfiniteCollectionInitialData\n\t\t}\n\t);\n</script>\n```\n\n</details>\n\n#### Using `prefetchQuery`\n\n<details>\n\t<summary>View Code</summary>\n\n**src/routes/+layout.ts**\n\n_Same as TanStack Query's docs_\n\n**src/routes/+layout.svelte**\n\n_Same as TanStack Query's docs_\n\n**src/routes/+page.ts**\n\n```ts\nimport type { PageLoad } from './$types';\n\nimport Pocketbase from 'pocketbase';\nimport { PUBLIC_POCKETBASE_URL } from '$env/static/public';\n\n// Types generated from https://github.com/patmood/pocketbase-typegen\nimport { Collections, type SomeCollectionResponse } from '$lib/collections';\n\nimport { infiniteCollectionQueryPrefetch } from 'svelte-query-pocketbase';\n\nexport const load: PageLoad = async ({ parent }) => {\n\tconst { queryClient } = await parent();\n\n\t// As long as the same collection, id, and queryParams are supplied to\n\t// `infiniteCollectionQueryPrefetch` and `createCollectionQuery`, the library will\n\t// generate the same `queryKey`s for both functions, and you need not specify one\n\tawait queryClient.prefetchQuery(\n\t\tinfiniteCollectionQueryPrefetch<SomeCollectionResponse>(\n\t\t\tpocketbase.collection(Collections.SomeCollection)\n\t\t)\n\t);\n};\n```\n\n**src/routes/+page.svelte**\n\n```svelte\n<script lang=\"ts\">\n\timport Pocketbase from 'pocketbase';\n\timport { PUBLIC_POCKETBASE_URL } from '$env/static/public';\n\n\timport type { PageData } from './$types';\n\texport let data: PageData;\n\n\t// Types generated from https://github.com/patmood/pocketbase-typegen\n\timport { Collections, type SomeCollectionResponse } from '$lib/collections';\n\n\timport { createInfiniteCollectionQuery } from 'svelte-query-pocketbase';\n\n\tconst pocketbase = new Pocketbase(PUBLIC_POCKETBASE_URL);\n\n\t// This data is cached by prefetchQuery in +page.ts so no fetch actually happens here\n\tconst someInfiniteCollection = createInfiniteCollectionQuery<SomeCollectionResponse>(\n\t\tpocketbase.collection(Collections.SomeCollection)\n\t);\n</script>\n```\n\n</details>\n\n## User Store\n\nSvelte store wrapper around the authenticated Pocketbase user that updates in realtime.\n\n### Using Default Auth Store\n\n<details>\n\t<summary>View Code</summary>\n\n```svelte\n<script lang=\"ts\">\n\timport Pocketbase from 'pocketbase';\n\timport { PUBLIC_POCKETBASE_URL } from '$env/static/public';\n\n\timport { userStore, type KnownUser } from 'svelte-query-pocketbase';\n\n\tconst pocketbase = new Pocketbase(PUBLIC_POCKETBASE_URL);\n\n\tinterface CustomKnownUser extends KnownUser {\n\t\tid: string;\n\t\tname: string;\n\t\tusername: string;\n\t\tavatar?: string;\n\t}\n\n\tconst user = userStore<CustomKnownUser>(pocketbase, (authStore) => ({\n\t\tisLoggedIn: true,\n\t\tid: authStore.model?.id ?? '',\n\t\tavatar: authStore.model?.avatar,\n\t\tusername: authStore.model?.username ?? ''\n\t\tname: authStore.model?.name ?? '',\n\t}));\n</script>\n\n{#if $user.isLoggedIn}\n\t<p>Welcome, {$user.name}:</p>\n\t<pre>{JSON.stringify($user, null, 2)}</pre>\n{:else}\n\t<p>You are not logged in.</p>\n{/if}\n```\n\n</details>\n\n### Using Local Auth Store\n\n<details>\n\t<summary>View Code</summary>\n\n```svelte\n<script lang=\"ts\">\n\timport Pocketbase, { LocalAuthStore } from 'pocketbase';\n\timport { PUBLIC_POCKETBASE_URL } from '$env/static/public';\n\n\timport { userStore, type KnownUser } from 'svelte-query-pocketbase';\n\n\tconst pocketbase = new Pocketbase(PUBLIC_POCKETBASE_URL, new LocalAuthStore(\"authInfo\"));\n\n\tinterface CustomKnownUser extends KnownUser {\n\t\tid: string;\n\t\tname: string;\n\t\tusername: string;\n\t\tavatar?: string;\n\t}\n\n\tconst user = userStore<CustomKnownUser, LocalAuthStore>(pocketbase, (authStore) => ({\n\t\tisLoggedIn: true,\n\t\tid: authStore.model?.id ?? '',\n\t\tavatar: authStore.model?.avatar,\n\t\tusername: authStore.model?.username ?? ''\n\t\tname: authStore.model?.name ?? '',\n\t}));\n</script>\n\n{#if $user.isLoggedIn}\n\t<p>Welcome, {$user.name}:</p>\n\t<pre>{JSON.stringify($user, null, 2)}</pre>\n{:else}\n\t<p>You are not logged in.</p>\n{/if}\n```\n\n</details>\n","readmeFilename":"README.md","bugs":{"url":"https://github.com/goknsh/svelte-query-pocketbase/issues"},"_id":"svelte-query-pocketbase@0.0.1-beta.11","_integrity":"sha512-ofFO8fU1dv1gBEWt0KbA9VXby96w+yXSVsYOlxWW1jB+kzUE/B/tnxRY/vlLzfnP8sNqs2bIxZVYiG1VEjkOLA==","_resolved":"/tmp/f51b1751fd7484ec647068c98cd21e81/svelte-query-pocketbase-0.0.1-beta.11.tgz","_from":"file:svelte-query-pocketbase-0.0.1-beta.11.tgz","_nodeVersion":"18.14.1","_npmVersion":"9.3.1","dist":{"integrity":"sha512-ofFO8fU1dv1gBEWt0KbA9VXby96w+yXSVsYOlxWW1jB+kzUE/B/tnxRY/vlLzfnP8sNqs2bIxZVYiG1VEjkOLA==","shasum":"86ff1ec176cd63d3bdcd3c28f39b841968215a84","tarball":"https://registry.npmjs.org/svelte-query-pocketbase/-/svelte-query-pocketbase-0.0.1-beta.11.tgz","fileCount":11,"unpackedSize":780565,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCID/ivQqm6sYjNZAd8DyDnOl0PkBA4ioUk1ZxubGBmKRtAiEA45rKP2vxyUcK34I+v+2mf7m6/vVcE3D3umWbMjZYHdc="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj/alPACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmoGHQ//Q9/2R8y+Wc+9DWjxmtooPztbZtyCST/+wH0ckeHTn+T/aG0M\r\nzqnyxF7ilOT19G63AKcYibTbszEZnU26bTcd7igwqNL1MIQGHgZT6k17smiF\r\nQThSpfghJF2j8uOPmbs6O9HdV6BWWDQIEmqzoTbYgeU/w1VHF4S9cJDAhIAT\r\nJNkCgsW2bTHHMxPar4JNhxvWDuhR1i+FedL+pWnDUky6EYD4l9RwMQLLFcCq\r\nff0oT/dkLfeJQXjUWHMTs3Yv9Mb7UwawOiOD8Nchg+SyhKyuflArGLvNB0EG\r\nLkYcewF2gLzwbDsLV809eSnX2i+0GbkeLYtZr/zjLWJq4mL9bb8Ys2CiA7N0\r\ntiiyCEr3YlBYzPGfmy3Lt59Wy9v6yPRLQMhLuAB7GSKZUqKRy2Yy/FA1hNhR\r\nMmi/JUVEPeHBJseYfcjAi6ABRzYUtK2tE3cdknFqT74gUs2h8ZA9Bf6acNW8\r\nIMETBQPhZcItF1MiNk09Kua/ZhhrM/t2078nJxbUiYFMuud6+wo2arjXG910\r\n16yfRuxqVJ4J1fnehaVU7QmQJMwZEtHzXIHr1mk677aCZNj5GclRG5eGaoSJ\r\n1MQoZ2GoVaD5aMuXsKkgu/Ulh17D96HiZhlPkDvmX/eQBSq3HDyoPGnkPDl5\r\nSiwTZjGgx6U7eDOLlrtsSbyfq+fb6eBTIyI=\r\n=+wKw\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"goknsh","email":"akaankshraj@gmail.com"},"directories":{},"maintainers":[{"name":"goknsh","email":"akaankshraj@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/svelte-query-pocketbase_0.0.1-beta.11_1677568335492_0.5782777948482616"},"_hasShrinkwrap":false,"deprecated":"Package no longer supported. Contact Support at https://www.npmjs.com/support for more info."}