[{"data":1,"prerenderedAt":7673},["ShallowReactive",2],{"content-query-LE3780Fo6E":3,"related-posts-/blog/nuxt-and-cloudflare-vectorize-setting-up-d1-drizzle-and-workers-ai-/blog/nuxt-cloudflare-vectorize-semantic-matching-/blog/build-and-deploy-nuxt3-static-site-with-pinia-and-stripe-checkout-on-firebase":7656},{"_path":4,"_dir":5,"_draft":6,"_partial":6,"_locale":7,"title":8,"description":9,"layout":10,"date":11,"intro":9,"preview_image":12,"featured_image":13,"openGraph":14,"datePublished":11,"dateModified":11,"breadcrumbs":20,"related":24,"body":28,"_type":7650,"_id":7651,"_source":7652,"_file":7653,"_stem":7654,"_extension":7655},"/blog/nuxt-cloudflare-queues-and-vectorize-data-sync-pipeline","blog",false,"en","Nuxt & Cloudflare Queues: Building a Data Sync Pipeline using Vectorize","Learn how to handle background tasks in a standalone Nuxt application using Cloudflare Queues. We will populate a Cloudflare Vectorize index through a Nitro task and a Nitro Plugin to handle the queue messages.","article","2025-12-20","/nuxt-cloudflare-queues-data-sync-pipeline/nuxt-cloudflare-queues-data-sync-pipeline.webp","/nuxt-cloudflare-queues-data-sync-pipeline/nuxt-cloudflare-queues-data-sync-pipeline_featured.webp",{"image":15},{"url":16,"width":17,"height":18,"type":19},"/images/og/nuxt-cloudflare-queues-data-sync-pipeline.png",1200,630,"image/png",[21],{"title":22,"url":23},"Blog","/blog/",[25,26,27],"/blog/nuxt-and-cloudflare-vectorize-setting-up-d1-drizzle-and-workers-ai","/blog/nuxt-cloudflare-vectorize-semantic-matching","/blog/build-and-deploy-nuxt3-static-site-with-pinia-and-stripe-checkout-on-firebase",{"type":29,"children":30,"toc":7639},"root",[31,41,76,81,116,133,140,153,167,172,193,248,261,307,334,375,380,421,426,549,555,600,609,619,624,637,868,881,893,1046,1058,1156,1176,1189,3176,3181,3186,3191,3197,3202,3207,3220,3227,3235,3240,3272,3284,3386,3391,3397,3410,3513,3525,3895,3907,4927,4932,4948,4954,4960,4972,4984,4996,5993,6005,6010,6022,6613,6619,6624,6636,6979,6992,6997,7066,7071,7589,7593,7597,7603,7615,7628,7633],{"type":32,"tag":33,"props":34,"children":35},"element","p",{},[36],{"type":32,"tag":37,"props":38,"children":40},"img",{"alt":8,"height":18,"src":39,"title":8,"width":17},"/images/blog/articles/nuxt-cloudflare-queues-data-sync-pipeline/nuxt-cloudflare-queues-data-sync-pipeline.webp",[],{"type":32,"tag":33,"props":42,"children":43},{},[44,47,54,56,65,67,74],{"type":45,"value":46},"text","Continuing from the ",{"type":32,"tag":48,"props":49,"children":51},"a",{"href":50},"/blog/nuxt-and-cloudflare-vectorize-setting-up-d1-drizzle-and-workers-ai/",[52],{"type":45,"value":53},"last article",{"type":45,"value":55},", we’ve already deployed our AI-powered real estate listing demo Nuxt application to Cloudflare, including the D1 database and AI Workers binding. In this article, we will set up ",{"type":32,"tag":48,"props":57,"children":62},{"href":58,"rel":59,"target":61},"https://www.cloudflare.com/en-gb/developer-platform/products/vectorize/",[60],"nofollow","_blank",[63],{"type":45,"value":64},"Cloudflare Vectorize",{"type":45,"value":66}," and implement a ",{"type":32,"tag":48,"props":68,"children":71},{"href":69,"rel":70,"target":61},"https://www.cloudflare.com/en-gb/developer-platform/products/cloudflare-queues/",[60],[72],{"type":45,"value":73},"Cloudflare Queue",{"type":45,"value":75}," to populate the Vector store with embeddings for our locations.",{"type":32,"tag":33,"props":77,"children":78},{},[79],{"type":45,"value":80},"This article is the second part of the Nuxt & Cloudflare AI Vector Pipeline Series, a three-part series.",{"type":32,"tag":82,"props":83,"children":84},"ul",{},[85,96,105],{"type":32,"tag":86,"props":87,"children":88},"li",{},[89,91],{"type":45,"value":90},"Part one - ",{"type":32,"tag":48,"props":92,"children":93},{"href":50},[94],{"type":45,"value":95},"Nuxt & Cloudflare Vectorize: Setting up D1, Drizzle, and Workers AI",{"type":32,"tag":86,"props":97,"children":98},{},[99],{"type":32,"tag":100,"props":101,"children":102},"strong",{},[103],{"type":45,"value":104},"Part two - Nuxt & Cloudflare Queues: Building a Data Sync Pipeline using Vectorize",{"type":32,"tag":86,"props":106,"children":107},{},[108,110],{"type":45,"value":109},"Part three - ",{"type":32,"tag":48,"props":111,"children":113},{"href":112},"/blog/nuxt-cloudflare-vectorize-semantic-matching/",[114],{"type":45,"value":115},"Implementing semantic matching in Nuxt with Cloudflare Vectorize",{"type":32,"tag":33,"props":117,"children":118},{},[119,121,131],{"type":45,"value":120},"The code for the entire demo application is publicly available on ",{"type":32,"tag":48,"props":122,"children":125},{"href":123,"rel":124},"https://github.com/keithmifsud/nuxt-data-sync-pipeline-with-cloudflare-cron-queues-and-ai-vectorize-demo",[60],[126],{"type":32,"tag":100,"props":127,"children":128},{},[129],{"type":45,"value":130},"GitHub: Nuxt & Cloudflare AI Vector Pipeline Series",{"type":45,"value":132}," - give it a ⭐.",{"type":32,"tag":134,"props":135,"children":137},"h2",{"id":136},"create-a-vector-index-on-cloudflare-vectorize-and-bind-it-to-our-nuxt-application",[138],{"type":45,"value":139},"Create a vector index on Cloudflare Vectorize and bind it to our Nuxt application",{"type":32,"tag":33,"props":141,"children":142},{},[143,145,151],{"type":45,"value":144},"As briefly ",{"type":32,"tag":48,"props":146,"children":148},{"href":147},"/blog/nuxt-and-cloudflare-vectorize-setting-up-d1-drizzle-and-workers-ai/#cloudflare-workers-ai",[149],{"type":45,"value":150},"explained in the previous article",{"type":45,"value":152},", Vectorize is Cloudflare’s native vector store. A vector store is essentially a database designed to hold text embeddings and index them for fast querying. Text embeddings are numeric representations (lists of numbers) that AI models use to read and understand data. Feel free to ask in comments below if my subtle explanation of Vectorize and vector stores leads to more questions - I know it's too broad 😆.",{"type":32,"tag":33,"props":154,"children":155},{},[156,158,165],{"type":45,"value":157},"Cloudflare’s Workers AI supports several embedding models; we will use ",{"type":32,"tag":159,"props":160,"children":162},"code",{"className":161},[],[163],{"type":45,"value":164},"@cf/baai/bge-m3",{"type":45,"value":166}," because of my experience with it on similar projects and its multilingual support, which is ideal for semantic matching use cases.",{"type":32,"tag":33,"props":168,"children":169},{},[170],{"type":45,"value":171},"We will use Wrangler CLI to create the vector index on Cloudflare and bind it to the project through Wrangler’s config so we can build the index with the locations’ text embeddings later.",{"type":32,"tag":33,"props":173,"children":174},{},[175,177,183,185,191],{"type":45,"value":176},"To use the ",{"type":32,"tag":159,"props":178,"children":180},{"className":179},[],[181],{"type":45,"value":182},"bge-m3",{"type":45,"value":184}," embedding model, we need to specify a dimension of ",{"type":32,"tag":159,"props":186,"children":188},{"className":187},[],[189],{"type":45,"value":190},"1024",{"type":45,"value":192},". Run:",{"type":32,"tag":194,"props":195,"children":200},"pre",{"className":196,"code":197,"language":198,"meta":199,"style":199},"language-shell shiki shiki-themes monokai","npx wrangler vectorize create locations-index --dimensions=1024 --metric=cosine\n","shell","",[201],{"type":32,"tag":159,"props":202,"children":203},{"__ignoreMap":199},[204],{"type":32,"tag":205,"props":206,"children":209},"span",{"class":207,"line":208},"line",1,[210,216,222,227,232,237,243],{"type":32,"tag":205,"props":211,"children":213},{"style":212},"--shiki-default:#A6E22E",[214],{"type":45,"value":215},"npx",{"type":32,"tag":205,"props":217,"children":219},{"style":218},"--shiki-default:#E6DB74",[220],{"type":45,"value":221}," wrangler",{"type":32,"tag":205,"props":223,"children":224},{"style":218},[225],{"type":45,"value":226}," vectorize",{"type":32,"tag":205,"props":228,"children":229},{"style":218},[230],{"type":45,"value":231}," create",{"type":32,"tag":205,"props":233,"children":234},{"style":218},[235],{"type":45,"value":236}," locations-index",{"type":32,"tag":205,"props":238,"children":240},{"style":239},"--shiki-default:#AE81FF",[241],{"type":45,"value":242}," --dimensions=1024",{"type":32,"tag":205,"props":244,"children":245},{"style":239},[246],{"type":45,"value":247}," --metric=cosine\n",{"type":32,"tag":33,"props":249,"children":250},{},[251,253,259],{"type":45,"value":252},"and add the bindings in ",{"type":32,"tag":159,"props":254,"children":256},{"className":255},[],[257],{"type":45,"value":258},"/wrangler.toml",{"type":45,"value":260},":",{"type":32,"tag":194,"props":262,"children":266},{"className":263,"code":264,"language":265,"meta":199,"style":199},"language-toml shiki shiki-themes monokai","[[vectorize]]\nbinding = \"VECTORIZE\"\nindex_name = \"locations-index\"\n","toml",[267],{"type":32,"tag":159,"props":268,"children":269},{"__ignoreMap":199},[270,279,293],{"type":32,"tag":205,"props":271,"children":272},{"class":207,"line":208},[273],{"type":32,"tag":205,"props":274,"children":276},{"style":275},"--shiki-default:#F8F8F2",[277],{"type":45,"value":278},"[[vectorize]]\n",{"type":32,"tag":205,"props":280,"children":282},{"class":207,"line":281},2,[283,288],{"type":32,"tag":205,"props":284,"children":285},{"style":275},[286],{"type":45,"value":287},"binding = ",{"type":32,"tag":205,"props":289,"children":290},{"style":218},[291],{"type":45,"value":292},"\"VECTORIZE\"\n",{"type":32,"tag":205,"props":294,"children":296},{"class":207,"line":295},3,[297,302],{"type":32,"tag":205,"props":298,"children":299},{"style":275},[300],{"type":45,"value":301},"index_name = ",{"type":32,"tag":205,"props":303,"children":304},{"style":218},[305],{"type":45,"value":306},"\"locations-index\"\n",{"type":32,"tag":33,"props":308,"children":309},{},[310,312,318,320,325,327,332],{"type":45,"value":311},"Now that we've created the location vector index, we need to enable filtering on our metadata. While upserts work automatically based on ID, we must explicitly index ",{"type":32,"tag":159,"props":313,"children":315},{"className":314},[],[316],{"type":45,"value":317},"locationId",{"type":45,"value":319}," so we can ",{"type":32,"tag":100,"props":321,"children":322},{},[323],{"type":45,"value":324},"filter search results",{"type":45,"value":326}," or ",{"type":32,"tag":100,"props":328,"children":329},{},[330],{"type":45,"value":331},"delete obsolete records",{"type":45,"value":333}," by their location ID in the future.",{"type":32,"tag":194,"props":335,"children":337},{"className":196,"code":336,"language":198,"meta":199,"style":199},"npx wrangler vectorize create-metadata-index locations-index --property-name=locationId --type=string\n",[338],{"type":32,"tag":159,"props":339,"children":340},{"__ignoreMap":199},[341],{"type":32,"tag":205,"props":342,"children":343},{"class":207,"line":208},[344,348,352,356,361,365,370],{"type":32,"tag":205,"props":345,"children":346},{"style":212},[347],{"type":45,"value":215},{"type":32,"tag":205,"props":349,"children":350},{"style":218},[351],{"type":45,"value":221},{"type":32,"tag":205,"props":353,"children":354},{"style":218},[355],{"type":45,"value":226},{"type":32,"tag":205,"props":357,"children":358},{"style":218},[359],{"type":45,"value":360}," create-metadata-index",{"type":32,"tag":205,"props":362,"children":363},{"style":218},[364],{"type":45,"value":236},{"type":32,"tag":205,"props":366,"children":367},{"style":239},[368],{"type":45,"value":369}," --property-name=locationId",{"type":32,"tag":205,"props":371,"children":372},{"style":239},[373],{"type":45,"value":374}," --type=string\n",{"type":32,"tag":33,"props":376,"children":377},{},[378],{"type":45,"value":379},"We can now build our code and deploy it to make sure Vectorize is being used, and the index is created:",{"type":32,"tag":194,"props":381,"children":383},{"className":196,"code":382,"language":198,"meta":199,"style":199},"pnpm run build\nnpx wrangler deploy\n",[384],{"type":32,"tag":159,"props":385,"children":386},{"__ignoreMap":199},[387,405],{"type":32,"tag":205,"props":388,"children":389},{"class":207,"line":208},[390,395,400],{"type":32,"tag":205,"props":391,"children":392},{"style":212},[393],{"type":45,"value":394},"pnpm",{"type":32,"tag":205,"props":396,"children":397},{"style":218},[398],{"type":45,"value":399}," run",{"type":32,"tag":205,"props":401,"children":402},{"style":218},[403],{"type":45,"value":404}," build\n",{"type":32,"tag":205,"props":406,"children":407},{"class":207,"line":281},[408,412,416],{"type":32,"tag":205,"props":409,"children":410},{"style":212},[411],{"type":45,"value":215},{"type":32,"tag":205,"props":413,"children":414},{"style":218},[415],{"type":45,"value":221},{"type":32,"tag":205,"props":417,"children":418},{"style":218},[419],{"type":45,"value":420}," deploy\n",{"type":32,"tag":33,"props":422,"children":423},{},[424],{"type":45,"value":425},"The CLI output should show that our worker has access to Vectorize and AI (which we previously added):",{"type":32,"tag":194,"props":427,"children":429},{"className":196,"code":428,"language":198,"meta":199,"style":199},"Your Worker has access to the following bindings:\nBinding                               Resource             \nenv.DB (property-sync-db)             D1 Database          \nenv.VECTORIZE (locations-index)       Vectorize Index      \nenv.ASSETS                            Assets\nenv.AI                                AI   \n",[430],{"type":32,"tag":159,"props":431,"children":432},{"__ignoreMap":199},[433,476,494,507,521,535],{"type":32,"tag":205,"props":434,"children":435},{"class":207,"line":208},[436,441,446,451,456,461,466,471],{"type":32,"tag":205,"props":437,"children":438},{"style":212},[439],{"type":45,"value":440},"Your",{"type":32,"tag":205,"props":442,"children":443},{"style":218},[444],{"type":45,"value":445}," Worker",{"type":32,"tag":205,"props":447,"children":448},{"style":218},[449],{"type":45,"value":450}," has",{"type":32,"tag":205,"props":452,"children":453},{"style":218},[454],{"type":45,"value":455}," access",{"type":32,"tag":205,"props":457,"children":458},{"style":218},[459],{"type":45,"value":460}," to",{"type":32,"tag":205,"props":462,"children":463},{"style":218},[464],{"type":45,"value":465}," the",{"type":32,"tag":205,"props":467,"children":468},{"style":218},[469],{"type":45,"value":470}," following",{"type":32,"tag":205,"props":472,"children":473},{"style":218},[474],{"type":45,"value":475}," bindings:\n",{"type":32,"tag":205,"props":477,"children":478},{"class":207,"line":281},[479,484,489],{"type":32,"tag":205,"props":480,"children":481},{"style":212},[482],{"type":45,"value":483},"Binding",{"type":32,"tag":205,"props":485,"children":486},{"style":218},[487],{"type":45,"value":488},"                               Resource",{"type":32,"tag":205,"props":490,"children":491},{"style":275},[492],{"type":45,"value":493},"             \n",{"type":32,"tag":205,"props":495,"children":496},{"class":207,"line":295},[497,502],{"type":32,"tag":205,"props":498,"children":499},{"style":212},[500],{"type":45,"value":501},"env.DB",{"type":32,"tag":205,"props":503,"children":504},{"style":275},[505],{"type":45,"value":506}," (property-sync-db)             D1 Database          \n",{"type":32,"tag":205,"props":508,"children":510},{"class":207,"line":509},4,[511,516],{"type":32,"tag":205,"props":512,"children":513},{"style":212},[514],{"type":45,"value":515},"env.VECTORIZE",{"type":32,"tag":205,"props":517,"children":518},{"style":275},[519],{"type":45,"value":520}," (locations-index)       Vectorize Index      \n",{"type":32,"tag":205,"props":522,"children":524},{"class":207,"line":523},5,[525,530],{"type":32,"tag":205,"props":526,"children":527},{"style":212},[528],{"type":45,"value":529},"env.ASSETS",{"type":32,"tag":205,"props":531,"children":532},{"style":218},[533],{"type":45,"value":534},"                            Assets\n",{"type":32,"tag":205,"props":536,"children":538},{"class":207,"line":537},6,[539,544],{"type":32,"tag":205,"props":540,"children":541},{"style":212},[542],{"type":45,"value":543},"env.AI",{"type":32,"tag":205,"props":545,"children":546},{"style":218},[547],{"type":45,"value":548},"                                AI\n",{"type":32,"tag":134,"props":550,"children":552},{"id":551},"upserting-vectors-using-cloudflare-workers-ai-and-vectorize",[553],{"type":45,"value":554},"Upserting vectors using Cloudflare Workers AI and Vectorize",{"type":32,"tag":33,"props":556,"children":557},{},[558,560,566,568,574,576,582,584,590,592,598],{"type":45,"value":559},"We will use a simple repository pattern for Cloudflare Vectorize, allowing us to easily swap implementations if needed. This sounds like overkill for such a small demo application, right? I recently avoided a substantial amount of time wasted when NuxtHub announced they’re deprecating their AI features. I was building a similar feature using ",{"type":32,"tag":159,"props":561,"children":563},{"className":562},[],[564],{"type":45,"value":565},"hubAi()",{"type":45,"value":567}," and ",{"type":32,"tag":159,"props":569,"children":571},{"className":570},[],[572],{"type":45,"value":573},"hubVectorize()",{"type":45,"value":575}," from NuxtHub’s core module, but I had to refactor it before I finished. Thanks to my use of the repository pattern, I only had to swap the repository implementation from ",{"type":32,"tag":159,"props":577,"children":579},{"className":578},[],[580],{"type":45,"value":581},"NuxthubVectorAIRepository",{"type":45,"value":583}," to ",{"type":32,"tag":159,"props":585,"children":587},{"className":586},[],[588],{"type":45,"value":589},"CloudflareVectorAIRepository",{"type":45,"value":591}," as, all other code was bound to the ",{"type":32,"tag":159,"props":593,"children":595},{"className":594},[],[596],{"type":45,"value":597},"VectorAIRepository",{"type":45,"value":599}," interface.",{"type":32,"tag":601,"props":602,"children":603},"blockquote",{},[604],{"type":32,"tag":33,"props":605,"children":606},{},[607],{"type":45,"value":608},"💡 I don’t see anything wrong with enforcing a Repository Pattern throughout the application. I also don’t see anything wrong with using the pattern for only some specific dependencies. In this case. I know that there’s a chance we will need to change the Vector and AI implementations, but changing the ORM (Drizzle) implementation is less likely. Let me know in the comments below your thoughts on the Repository Pattern in Nuxt.",{"type":32,"tag":610,"props":611,"children":618},"cta-section",{":sub-link":612,"button-text":613,"link":614,"sub-link-text":615,"text":616,"title":617},"/services/nuxt-consultant/","Get in touch","/contact","Nuxt consultant","Don't let the infrastructure details slow you down. I help your team cut through the complexity and ship a solid, scalable Nuxt application.","Need to launch your Nuxt project?",[],{"type":32,"tag":33,"props":620,"children":621},{},[622],{"type":45,"value":623},"I will go into detail about Queues and Handlers in the next section of this article. For now, we just need to know that the vectorisation of the location data will be queued, and that a queue handler will depend on a Location Vector Repository. Let’s add this dependency.",{"type":32,"tag":33,"props":625,"children":626},{},[627,629,635],{"type":45,"value":628},"Create ",{"type":32,"tag":159,"props":630,"children":632},{"className":631},[],[633],{"type":45,"value":634},"/server/utils/queueHandlers/repositories/LocationVectorRepository.ts",{"type":45,"value":636}," with:",{"type":32,"tag":194,"props":638,"children":642},{"className":639,"code":640,"language":641,"meta":199,"style":199},"language-typescript shiki shiki-themes monokai","import { Location } from '~~/server/database/types'\n\nexport interface LocationVectorRepository {\n\n  /**\n   * Upserts locations into the Vector Store.\n   *\n   * @param locations - An array of Location objects to be upserted.\n   * @returns A promise that resolves to the number of locations upserted.\n   */\n  upsertLocations (\n    locations: Location[],\n  ): Promise\u003Cnumber>;\n}\n\n","typescript",[643],{"type":32,"tag":159,"props":644,"children":645},{"__ignoreMap":199},[646,670,679,704,711,720,728,737,761,779,788,802,826,859],{"type":32,"tag":205,"props":647,"children":648},{"class":207,"line":208},[649,655,660,665],{"type":32,"tag":205,"props":650,"children":652},{"style":651},"--shiki-default:#F92672",[653],{"type":45,"value":654},"import",{"type":32,"tag":205,"props":656,"children":657},{"style":275},[658],{"type":45,"value":659}," { Location } ",{"type":32,"tag":205,"props":661,"children":662},{"style":651},[663],{"type":45,"value":664},"from",{"type":32,"tag":205,"props":666,"children":667},{"style":218},[668],{"type":45,"value":669}," '~~/server/database/types'\n",{"type":32,"tag":205,"props":671,"children":672},{"class":207,"line":281},[673],{"type":32,"tag":205,"props":674,"children":676},{"emptyLinePlaceholder":675},true,[677],{"type":45,"value":678},"\n",{"type":32,"tag":205,"props":680,"children":681},{"class":207,"line":295},[682,687,693,699],{"type":32,"tag":205,"props":683,"children":684},{"style":651},[685],{"type":45,"value":686},"export",{"type":32,"tag":205,"props":688,"children":690},{"style":689},"--shiki-default:#66D9EF;--shiki-default-font-style:italic",[691],{"type":45,"value":692}," interface",{"type":32,"tag":205,"props":694,"children":696},{"style":695},"--shiki-default:#A6E22E;--shiki-default-text-decoration:underline",[697],{"type":45,"value":698}," LocationVectorRepository",{"type":32,"tag":205,"props":700,"children":701},{"style":275},[702],{"type":45,"value":703}," {\n",{"type":32,"tag":205,"props":705,"children":706},{"class":207,"line":509},[707],{"type":32,"tag":205,"props":708,"children":709},{"emptyLinePlaceholder":675},[710],{"type":45,"value":678},{"type":32,"tag":205,"props":712,"children":713},{"class":207,"line":523},[714],{"type":32,"tag":205,"props":715,"children":717},{"style":716},"--shiki-default:#88846F",[718],{"type":45,"value":719},"  /**\n",{"type":32,"tag":205,"props":721,"children":722},{"class":207,"line":537},[723],{"type":32,"tag":205,"props":724,"children":725},{"style":716},[726],{"type":45,"value":727},"   * Upserts locations into the Vector Store.\n",{"type":32,"tag":205,"props":729,"children":731},{"class":207,"line":730},7,[732],{"type":32,"tag":205,"props":733,"children":734},{"style":716},[735],{"type":45,"value":736},"   *\n",{"type":32,"tag":205,"props":738,"children":740},{"class":207,"line":739},8,[741,746,751,756],{"type":32,"tag":205,"props":742,"children":743},{"style":716},[744],{"type":45,"value":745},"   * ",{"type":32,"tag":205,"props":747,"children":748},{"style":689},[749],{"type":45,"value":750},"@param",{"type":32,"tag":205,"props":752,"children":753},{"style":275},[754],{"type":45,"value":755}," locations",{"type":32,"tag":205,"props":757,"children":758},{"style":716},[759],{"type":45,"value":760}," - An array of Location objects to be upserted.\n",{"type":32,"tag":205,"props":762,"children":764},{"class":207,"line":763},9,[765,769,774],{"type":32,"tag":205,"props":766,"children":767},{"style":716},[768],{"type":45,"value":745},{"type":32,"tag":205,"props":770,"children":771},{"style":689},[772],{"type":45,"value":773},"@returns",{"type":32,"tag":205,"props":775,"children":776},{"style":716},[777],{"type":45,"value":778}," A promise that resolves to the number of locations upserted.\n",{"type":32,"tag":205,"props":780,"children":782},{"class":207,"line":781},10,[783],{"type":32,"tag":205,"props":784,"children":785},{"style":716},[786],{"type":45,"value":787},"   */\n",{"type":32,"tag":205,"props":789,"children":791},{"class":207,"line":790},11,[792,797],{"type":32,"tag":205,"props":793,"children":794},{"style":212},[795],{"type":45,"value":796},"  upsertLocations",{"type":32,"tag":205,"props":798,"children":799},{"style":275},[800],{"type":45,"value":801}," (\n",{"type":32,"tag":205,"props":803,"children":805},{"class":207,"line":804},12,[806,812,816,821],{"type":32,"tag":205,"props":807,"children":809},{"style":808},"--shiki-default:#FD971F;--shiki-default-font-style:italic",[810],{"type":45,"value":811},"    locations",{"type":32,"tag":205,"props":813,"children":814},{"style":651},[815],{"type":45,"value":260},{"type":32,"tag":205,"props":817,"children":818},{"style":695},[819],{"type":45,"value":820}," Location",{"type":32,"tag":205,"props":822,"children":823},{"style":275},[824],{"type":45,"value":825},"[],\n",{"type":32,"tag":205,"props":827,"children":829},{"class":207,"line":828},13,[830,835,839,844,849,854],{"type":32,"tag":205,"props":831,"children":832},{"style":275},[833],{"type":45,"value":834},"  )",{"type":32,"tag":205,"props":836,"children":837},{"style":651},[838],{"type":45,"value":260},{"type":32,"tag":205,"props":840,"children":841},{"style":695},[842],{"type":45,"value":843}," Promise",{"type":32,"tag":205,"props":845,"children":846},{"style":275},[847],{"type":45,"value":848},"\u003C",{"type":32,"tag":205,"props":850,"children":851},{"style":689},[852],{"type":45,"value":853},"number",{"type":32,"tag":205,"props":855,"children":856},{"style":275},[857],{"type":45,"value":858},">;\n",{"type":32,"tag":205,"props":860,"children":862},{"class":207,"line":861},14,[863],{"type":32,"tag":205,"props":864,"children":865},{"style":275},[866],{"type":45,"value":867},"}\n",{"type":32,"tag":33,"props":869,"children":870},{},[871,873,879],{"type":45,"value":872},"And install the following types from Cloudflare Workers if you haven’t already: ",{"type":32,"tag":159,"props":874,"children":876},{"className":875},[],[877],{"type":45,"value":878},"pnpm install @cloudflare/workers-types",{"type":45,"value":880},".",{"type":32,"tag":33,"props":882,"children":883},{},[884,886,892],{"type":45,"value":885},"Database types in ",{"type":32,"tag":159,"props":887,"children":889},{"className":888},[],[890],{"type":45,"value":891},"/server/database/types.ts",{"type":45,"value":260},{"type":32,"tag":194,"props":894,"children":896},{"className":639,"code":895,"language":641,"meta":199,"style":199},"import * as schema from './schema';\n\nexport type Location = typeof schema.locations.$inferSelect;\n\nexport type Agent = typeof schema.agents.$inferSelect;\n\nexport type Property = typeof schema.properties.$inferSelect;\n\n",[897],{"type":32,"tag":159,"props":898,"children":899},{"__ignoreMap":199},[900,936,943,974,981,1010,1017],{"type":32,"tag":205,"props":901,"children":902},{"class":207,"line":208},[903,907,912,917,922,926,931],{"type":32,"tag":205,"props":904,"children":905},{"style":651},[906],{"type":45,"value":654},{"type":32,"tag":205,"props":908,"children":909},{"style":239},[910],{"type":45,"value":911}," *",{"type":32,"tag":205,"props":913,"children":914},{"style":651},[915],{"type":45,"value":916}," as",{"type":32,"tag":205,"props":918,"children":919},{"style":275},[920],{"type":45,"value":921}," schema ",{"type":32,"tag":205,"props":923,"children":924},{"style":651},[925],{"type":45,"value":664},{"type":32,"tag":205,"props":927,"children":928},{"style":218},[929],{"type":45,"value":930}," './schema'",{"type":32,"tag":205,"props":932,"children":933},{"style":275},[934],{"type":45,"value":935},";\n",{"type":32,"tag":205,"props":937,"children":938},{"class":207,"line":281},[939],{"type":32,"tag":205,"props":940,"children":941},{"emptyLinePlaceholder":675},[942],{"type":45,"value":678},{"type":32,"tag":205,"props":944,"children":945},{"class":207,"line":295},[946,950,955,959,964,969],{"type":32,"tag":205,"props":947,"children":948},{"style":651},[949],{"type":45,"value":686},{"type":32,"tag":205,"props":951,"children":952},{"style":689},[953],{"type":45,"value":954}," type",{"type":32,"tag":205,"props":956,"children":957},{"style":695},[958],{"type":45,"value":820},{"type":32,"tag":205,"props":960,"children":961},{"style":651},[962],{"type":45,"value":963}," =",{"type":32,"tag":205,"props":965,"children":966},{"style":651},[967],{"type":45,"value":968}," typeof",{"type":32,"tag":205,"props":970,"children":971},{"style":275},[972],{"type":45,"value":973}," schema.locations.$inferSelect;\n",{"type":32,"tag":205,"props":975,"children":976},{"class":207,"line":509},[977],{"type":32,"tag":205,"props":978,"children":979},{"emptyLinePlaceholder":675},[980],{"type":45,"value":678},{"type":32,"tag":205,"props":982,"children":983},{"class":207,"line":523},[984,988,992,997,1001,1005],{"type":32,"tag":205,"props":985,"children":986},{"style":651},[987],{"type":45,"value":686},{"type":32,"tag":205,"props":989,"children":990},{"style":689},[991],{"type":45,"value":954},{"type":32,"tag":205,"props":993,"children":994},{"style":695},[995],{"type":45,"value":996}," Agent",{"type":32,"tag":205,"props":998,"children":999},{"style":651},[1000],{"type":45,"value":963},{"type":32,"tag":205,"props":1002,"children":1003},{"style":651},[1004],{"type":45,"value":968},{"type":32,"tag":205,"props":1006,"children":1007},{"style":275},[1008],{"type":45,"value":1009}," schema.agents.$inferSelect;\n",{"type":32,"tag":205,"props":1011,"children":1012},{"class":207,"line":537},[1013],{"type":32,"tag":205,"props":1014,"children":1015},{"emptyLinePlaceholder":675},[1016],{"type":45,"value":678},{"type":32,"tag":205,"props":1018,"children":1019},{"class":207,"line":730},[1020,1024,1028,1033,1037,1041],{"type":32,"tag":205,"props":1021,"children":1022},{"style":651},[1023],{"type":45,"value":686},{"type":32,"tag":205,"props":1025,"children":1026},{"style":689},[1027],{"type":45,"value":954},{"type":32,"tag":205,"props":1029,"children":1030},{"style":695},[1031],{"type":45,"value":1032}," Property",{"type":32,"tag":205,"props":1034,"children":1035},{"style":651},[1036],{"type":45,"value":963},{"type":32,"tag":205,"props":1038,"children":1039},{"style":651},[1040],{"type":45,"value":968},{"type":32,"tag":205,"props":1042,"children":1043},{"style":275},[1044],{"type":45,"value":1045}," schema.properties.$inferSelect;\n",{"type":32,"tag":33,"props":1047,"children":1048},{},[1049,1051,1057],{"type":45,"value":1050},"AI types in ",{"type":32,"tag":159,"props":1052,"children":1054},{"className":1053},[],[1055],{"type":45,"value":1056},"/server/types/ai-models.ts",{"type":45,"value":260},{"type":32,"tag":194,"props":1059,"children":1061},{"className":639,"code":1060,"language":641,"meta":199,"style":199},"export interface BGEEmbeddingResponse {\n  data?: number[][];\n  response?: number[][];\n  shape?: number[];\n}\n",[1062],{"type":32,"tag":159,"props":1063,"children":1064},{"__ignoreMap":199},[1065,1085,1108,1128,1149],{"type":32,"tag":205,"props":1066,"children":1067},{"class":207,"line":208},[1068,1072,1076,1081],{"type":32,"tag":205,"props":1069,"children":1070},{"style":651},[1071],{"type":45,"value":686},{"type":32,"tag":205,"props":1073,"children":1074},{"style":689},[1075],{"type":45,"value":692},{"type":32,"tag":205,"props":1077,"children":1078},{"style":695},[1079],{"type":45,"value":1080}," BGEEmbeddingResponse",{"type":32,"tag":205,"props":1082,"children":1083},{"style":275},[1084],{"type":45,"value":703},{"type":32,"tag":205,"props":1086,"children":1087},{"class":207,"line":281},[1088,1093,1098,1103],{"type":32,"tag":205,"props":1089,"children":1090},{"style":275},[1091],{"type":45,"value":1092},"  data",{"type":32,"tag":205,"props":1094,"children":1095},{"style":651},[1096],{"type":45,"value":1097},"?:",{"type":32,"tag":205,"props":1099,"children":1100},{"style":689},[1101],{"type":45,"value":1102}," number",{"type":32,"tag":205,"props":1104,"children":1105},{"style":275},[1106],{"type":45,"value":1107},"[][];\n",{"type":32,"tag":205,"props":1109,"children":1110},{"class":207,"line":295},[1111,1116,1120,1124],{"type":32,"tag":205,"props":1112,"children":1113},{"style":275},[1114],{"type":45,"value":1115},"  response",{"type":32,"tag":205,"props":1117,"children":1118},{"style":651},[1119],{"type":45,"value":1097},{"type":32,"tag":205,"props":1121,"children":1122},{"style":689},[1123],{"type":45,"value":1102},{"type":32,"tag":205,"props":1125,"children":1126},{"style":275},[1127],{"type":45,"value":1107},{"type":32,"tag":205,"props":1129,"children":1130},{"class":207,"line":509},[1131,1136,1140,1144],{"type":32,"tag":205,"props":1132,"children":1133},{"style":275},[1134],{"type":45,"value":1135},"  shape",{"type":32,"tag":205,"props":1137,"children":1138},{"style":651},[1139],{"type":45,"value":1097},{"type":32,"tag":205,"props":1141,"children":1142},{"style":689},[1143],{"type":45,"value":1102},{"type":32,"tag":205,"props":1145,"children":1146},{"style":275},[1147],{"type":45,"value":1148},"[];\n",{"type":32,"tag":205,"props":1150,"children":1151},{"class":207,"line":523},[1152],{"type":32,"tag":205,"props":1153,"children":1154},{"style":275},[1155],{"type":45,"value":867},{"type":32,"tag":33,"props":1157,"children":1158},{},[1159,1161,1167,1169,1175],{"type":45,"value":1160},"We can now finally implement the ",{"type":32,"tag":159,"props":1162,"children":1164},{"className":1163},[],[1165],{"type":45,"value":1166},"upsertLocations()",{"type":45,"value":1168}," method in our Cloudflare implementation of the ",{"type":32,"tag":159,"props":1170,"children":1172},{"className":1171},[],[1173],{"type":45,"value":1174},"LocationVectorRepository",{"type":45,"value":599},{"type":32,"tag":33,"props":1177,"children":1178},{},[1179,1181,1187],{"type":45,"value":1180},"Let’s start by creating the repository class in ",{"type":32,"tag":159,"props":1182,"children":1184},{"className":1183},[],[1185],{"type":45,"value":1186},"/server/repositories/cloudflare/CloudflareVectorAIRepository.ts",{"type":45,"value":1188}," and add the following contents:",{"type":32,"tag":194,"props":1190,"children":1192},{"className":639,"code":1191,"language":641,"meta":199,"style":199},"import {\n  LocationVectorRepository,\n} from '~~/server/utils/queueHandlers/repositories/LocationVectorRepository'\nimport { Location } from '~~/server/database/types'\nimport type { Ai, VectorizeIndex } from '@cloudflare/workers-types'\nimport { BGEEmbeddingResponse } from '~~/server/types/ai-models'\n\nexport class CloudflareVectorAIRepository implements LocationVectorRepository {\n\n  constructor (\n    private readonly vectorIndex: VectorizeIndex,\n    private readonly ai: Ai,\n  ) {\n\n    if (!vectorIndex) {\n      throw new Error(\n        'Missing Vectorize binding.')\n    }\n\n    if (!ai) {\n      throw new Error('Missing AI binding.')\n    }\n  }\n\n  /**\n   * Upserts the given locations into the vector index.\n   *\n   * @param locations\n   */\n  public async upsertLocations (locations: Location[]): Promise\u003Cnumber> {\n\n    if (locations.length === 0) {\n      return 0\n    }\n\n    const AI_BATCH_SIZE = 10\n    let successfulUpserts = 0\n\n    for (let i = 0; i \u003C locations.length; i += AI_BATCH_SIZE) {\n      const batch = locations.slice(i, i + AI_BATCH_SIZE)\n\n      try {\n        const textsToEmbed = batch.map((location) =>\n          this.buildTextForEmbedding(location),\n        )\n\n        const vectors = await this.embedTextBatch(textsToEmbed)\n\n        const vectorObjects = batch.map((location, idx) => {\n          const vector = vectors[idx]\n          if (!vector) return null\n          return {\n            id: location.id,\n            values: vector,\n            metadata: {\n              locationId: location.id,\n            },\n          }\n        }).filter((obj): obj is NonNullable\u003Ctypeof obj> => obj !== null)\n\n        if (vectorObjects.length > 0) {\n          const result = await this.vectorIndex.upsert(vectorObjects)\n          console.log('[Repo] Upsert result:', JSON.stringify(result))\n          successfulUpserts += vectorObjects.length\n        }\n      } catch (error) {\n        console.error(\n          `[CloudflareVectorAIRepository] Failed to process batch starting at index ${i}`,\n          error,\n        )\n      }\n    }\n    return successfulUpserts\n  }\n\n  /**\n   * Embeds a batch of texts using the BGE-M3 model.\n   *\n   * @param texts\n   * @private\n   */\n  private async embedTextBatch (texts: string[]): Promise\u003Cnumber[][]> {\n    const response = (await this.ai.run(\n      '@cf/baai/bge-m3', {\n        text: texts,\n        response_format: 'embedding_vector',\n      },\n    )) as BGEEmbeddingResponse\n\n    const vectors = response.data ?? response.response\n\n    if (!vectors) throw new Error('BGE-M3 invalid response')\n\n    return vectors\n  }\n\n  /**\n   * Builds the text representation for embedding from a Location.\n   *\n   * @param location\n   * @private\n   */\n  private buildTextForEmbedding (location: Location): string {\n    return `${location.name} | ${location.postcodes.join(', ')}`\n  }\n\n}\n\n",[1193],{"type":32,"tag":159,"props":1194,"children":1195},{"__ignoreMap":199},[1196,1207,1215,1232,1251,1276,1297,1304,1335,1342,1354,1386,1415,1423,1430,1454,1478,1492,1501,1509,1530,1560,1568,1577,1585,1593,1602,1610,1627,1635,1697,1705,1733,1747,1755,1763,1787,1809,1817,1872,1915,1923,1936,1984,2008,2017,2025,2066,2074,2130,2153,2185,2198,2207,2216,2225,2234,2243,2252,2336,2344,2371,2411,2449,2467,2476,2495,2513,2546,2555,2563,2572,2580,2594,2602,2610,2618,2627,2635,2652,2665,2673,2734,2778,2792,2801,2819,2828,2847,2855,2886,2894,2941,2949,2962,2970,2978,2986,2995,3003,3020,3032,3040,3085,3152,3160,3168],{"type":32,"tag":205,"props":1197,"children":1198},{"class":207,"line":208},[1199,1203],{"type":32,"tag":205,"props":1200,"children":1201},{"style":651},[1202],{"type":45,"value":654},{"type":32,"tag":205,"props":1204,"children":1205},{"style":275},[1206],{"type":45,"value":703},{"type":32,"tag":205,"props":1208,"children":1209},{"class":207,"line":281},[1210],{"type":32,"tag":205,"props":1211,"children":1212},{"style":275},[1213],{"type":45,"value":1214},"  LocationVectorRepository,\n",{"type":32,"tag":205,"props":1216,"children":1217},{"class":207,"line":295},[1218,1223,1227],{"type":32,"tag":205,"props":1219,"children":1220},{"style":275},[1221],{"type":45,"value":1222},"} ",{"type":32,"tag":205,"props":1224,"children":1225},{"style":651},[1226],{"type":45,"value":664},{"type":32,"tag":205,"props":1228,"children":1229},{"style":218},[1230],{"type":45,"value":1231}," '~~/server/utils/queueHandlers/repositories/LocationVectorRepository'\n",{"type":32,"tag":205,"props":1233,"children":1234},{"class":207,"line":509},[1235,1239,1243,1247],{"type":32,"tag":205,"props":1236,"children":1237},{"style":651},[1238],{"type":45,"value":654},{"type":32,"tag":205,"props":1240,"children":1241},{"style":275},[1242],{"type":45,"value":659},{"type":32,"tag":205,"props":1244,"children":1245},{"style":651},[1246],{"type":45,"value":664},{"type":32,"tag":205,"props":1248,"children":1249},{"style":218},[1250],{"type":45,"value":669},{"type":32,"tag":205,"props":1252,"children":1253},{"class":207,"line":523},[1254,1258,1262,1267,1271],{"type":32,"tag":205,"props":1255,"children":1256},{"style":651},[1257],{"type":45,"value":654},{"type":32,"tag":205,"props":1259,"children":1260},{"style":651},[1261],{"type":45,"value":954},{"type":32,"tag":205,"props":1263,"children":1264},{"style":275},[1265],{"type":45,"value":1266}," { Ai, VectorizeIndex } ",{"type":32,"tag":205,"props":1268,"children":1269},{"style":651},[1270],{"type":45,"value":664},{"type":32,"tag":205,"props":1272,"children":1273},{"style":218},[1274],{"type":45,"value":1275}," '@cloudflare/workers-types'\n",{"type":32,"tag":205,"props":1277,"children":1278},{"class":207,"line":537},[1279,1283,1288,1292],{"type":32,"tag":205,"props":1280,"children":1281},{"style":651},[1282],{"type":45,"value":654},{"type":32,"tag":205,"props":1284,"children":1285},{"style":275},[1286],{"type":45,"value":1287}," { BGEEmbeddingResponse } ",{"type":32,"tag":205,"props":1289,"children":1290},{"style":651},[1291],{"type":45,"value":664},{"type":32,"tag":205,"props":1293,"children":1294},{"style":218},[1295],{"type":45,"value":1296}," '~~/server/types/ai-models'\n",{"type":32,"tag":205,"props":1298,"children":1299},{"class":207,"line":730},[1300],{"type":32,"tag":205,"props":1301,"children":1302},{"emptyLinePlaceholder":675},[1303],{"type":45,"value":678},{"type":32,"tag":205,"props":1305,"children":1306},{"class":207,"line":739},[1307,1311,1316,1321,1326,1331],{"type":32,"tag":205,"props":1308,"children":1309},{"style":651},[1310],{"type":45,"value":686},{"type":32,"tag":205,"props":1312,"children":1313},{"style":689},[1314],{"type":45,"value":1315}," class",{"type":32,"tag":205,"props":1317,"children":1318},{"style":695},[1319],{"type":45,"value":1320}," CloudflareVectorAIRepository",{"type":32,"tag":205,"props":1322,"children":1323},{"style":651},[1324],{"type":45,"value":1325}," implements",{"type":32,"tag":205,"props":1327,"children":1329},{"style":1328},"--shiki-default:#A6E22E;--shiki-default-font-style:italic;--shiki-default-text-decoration:underline",[1330],{"type":45,"value":698},{"type":32,"tag":205,"props":1332,"children":1333},{"style":275},[1334],{"type":45,"value":703},{"type":32,"tag":205,"props":1336,"children":1337},{"class":207,"line":763},[1338],{"type":32,"tag":205,"props":1339,"children":1340},{"emptyLinePlaceholder":675},[1341],{"type":45,"value":678},{"type":32,"tag":205,"props":1343,"children":1344},{"class":207,"line":781},[1345,1350],{"type":32,"tag":205,"props":1346,"children":1347},{"style":689},[1348],{"type":45,"value":1349},"  constructor",{"type":32,"tag":205,"props":1351,"children":1352},{"style":275},[1353],{"type":45,"value":801},{"type":32,"tag":205,"props":1355,"children":1356},{"class":207,"line":790},[1357,1362,1367,1372,1376,1381],{"type":32,"tag":205,"props":1358,"children":1359},{"style":651},[1360],{"type":45,"value":1361},"    private",{"type":32,"tag":205,"props":1363,"children":1364},{"style":651},[1365],{"type":45,"value":1366}," readonly",{"type":32,"tag":205,"props":1368,"children":1369},{"style":808},[1370],{"type":45,"value":1371}," vectorIndex",{"type":32,"tag":205,"props":1373,"children":1374},{"style":651},[1375],{"type":45,"value":260},{"type":32,"tag":205,"props":1377,"children":1378},{"style":695},[1379],{"type":45,"value":1380}," VectorizeIndex",{"type":32,"tag":205,"props":1382,"children":1383},{"style":275},[1384],{"type":45,"value":1385},",\n",{"type":32,"tag":205,"props":1387,"children":1388},{"class":207,"line":804},[1389,1393,1397,1402,1406,1411],{"type":32,"tag":205,"props":1390,"children":1391},{"style":651},[1392],{"type":45,"value":1361},{"type":32,"tag":205,"props":1394,"children":1395},{"style":651},[1396],{"type":45,"value":1366},{"type":32,"tag":205,"props":1398,"children":1399},{"style":808},[1400],{"type":45,"value":1401}," ai",{"type":32,"tag":205,"props":1403,"children":1404},{"style":651},[1405],{"type":45,"value":260},{"type":32,"tag":205,"props":1407,"children":1408},{"style":695},[1409],{"type":45,"value":1410}," Ai",{"type":32,"tag":205,"props":1412,"children":1413},{"style":275},[1414],{"type":45,"value":1385},{"type":32,"tag":205,"props":1416,"children":1417},{"class":207,"line":828},[1418],{"type":32,"tag":205,"props":1419,"children":1420},{"style":275},[1421],{"type":45,"value":1422},"  ) {\n",{"type":32,"tag":205,"props":1424,"children":1425},{"class":207,"line":861},[1426],{"type":32,"tag":205,"props":1427,"children":1428},{"emptyLinePlaceholder":675},[1429],{"type":45,"value":678},{"type":32,"tag":205,"props":1431,"children":1433},{"class":207,"line":1432},15,[1434,1439,1444,1449],{"type":32,"tag":205,"props":1435,"children":1436},{"style":651},[1437],{"type":45,"value":1438},"    if",{"type":32,"tag":205,"props":1440,"children":1441},{"style":275},[1442],{"type":45,"value":1443}," (",{"type":32,"tag":205,"props":1445,"children":1446},{"style":651},[1447],{"type":45,"value":1448},"!",{"type":32,"tag":205,"props":1450,"children":1451},{"style":275},[1452],{"type":45,"value":1453},"vectorIndex) {\n",{"type":32,"tag":205,"props":1455,"children":1457},{"class":207,"line":1456},16,[1458,1463,1468,1473],{"type":32,"tag":205,"props":1459,"children":1460},{"style":651},[1461],{"type":45,"value":1462},"      throw",{"type":32,"tag":205,"props":1464,"children":1465},{"style":651},[1466],{"type":45,"value":1467}," new",{"type":32,"tag":205,"props":1469,"children":1470},{"style":212},[1471],{"type":45,"value":1472}," Error",{"type":32,"tag":205,"props":1474,"children":1475},{"style":275},[1476],{"type":45,"value":1477},"(\n",{"type":32,"tag":205,"props":1479,"children":1481},{"class":207,"line":1480},17,[1482,1487],{"type":32,"tag":205,"props":1483,"children":1484},{"style":218},[1485],{"type":45,"value":1486},"        'Missing Vectorize binding.'",{"type":32,"tag":205,"props":1488,"children":1489},{"style":275},[1490],{"type":45,"value":1491},")\n",{"type":32,"tag":205,"props":1493,"children":1495},{"class":207,"line":1494},18,[1496],{"type":32,"tag":205,"props":1497,"children":1498},{"style":275},[1499],{"type":45,"value":1500},"    }\n",{"type":32,"tag":205,"props":1502,"children":1504},{"class":207,"line":1503},19,[1505],{"type":32,"tag":205,"props":1506,"children":1507},{"emptyLinePlaceholder":675},[1508],{"type":45,"value":678},{"type":32,"tag":205,"props":1510,"children":1512},{"class":207,"line":1511},20,[1513,1517,1521,1525],{"type":32,"tag":205,"props":1514,"children":1515},{"style":651},[1516],{"type":45,"value":1438},{"type":32,"tag":205,"props":1518,"children":1519},{"style":275},[1520],{"type":45,"value":1443},{"type":32,"tag":205,"props":1522,"children":1523},{"style":651},[1524],{"type":45,"value":1448},{"type":32,"tag":205,"props":1526,"children":1527},{"style":275},[1528],{"type":45,"value":1529},"ai) {\n",{"type":32,"tag":205,"props":1531,"children":1533},{"class":207,"line":1532},21,[1534,1538,1542,1546,1551,1556],{"type":32,"tag":205,"props":1535,"children":1536},{"style":651},[1537],{"type":45,"value":1462},{"type":32,"tag":205,"props":1539,"children":1540},{"style":651},[1541],{"type":45,"value":1467},{"type":32,"tag":205,"props":1543,"children":1544},{"style":212},[1545],{"type":45,"value":1472},{"type":32,"tag":205,"props":1547,"children":1548},{"style":275},[1549],{"type":45,"value":1550},"(",{"type":32,"tag":205,"props":1552,"children":1553},{"style":218},[1554],{"type":45,"value":1555},"'Missing AI binding.'",{"type":32,"tag":205,"props":1557,"children":1558},{"style":275},[1559],{"type":45,"value":1491},{"type":32,"tag":205,"props":1561,"children":1563},{"class":207,"line":1562},22,[1564],{"type":32,"tag":205,"props":1565,"children":1566},{"style":275},[1567],{"type":45,"value":1500},{"type":32,"tag":205,"props":1569,"children":1571},{"class":207,"line":1570},23,[1572],{"type":32,"tag":205,"props":1573,"children":1574},{"style":275},[1575],{"type":45,"value":1576},"  }\n",{"type":32,"tag":205,"props":1578,"children":1580},{"class":207,"line":1579},24,[1581],{"type":32,"tag":205,"props":1582,"children":1583},{"emptyLinePlaceholder":675},[1584],{"type":45,"value":678},{"type":32,"tag":205,"props":1586,"children":1588},{"class":207,"line":1587},25,[1589],{"type":32,"tag":205,"props":1590,"children":1591},{"style":716},[1592],{"type":45,"value":719},{"type":32,"tag":205,"props":1594,"children":1596},{"class":207,"line":1595},26,[1597],{"type":32,"tag":205,"props":1598,"children":1599},{"style":716},[1600],{"type":45,"value":1601},"   * Upserts the given locations into the vector index.\n",{"type":32,"tag":205,"props":1603,"children":1605},{"class":207,"line":1604},27,[1606],{"type":32,"tag":205,"props":1607,"children":1608},{"style":716},[1609],{"type":45,"value":736},{"type":32,"tag":205,"props":1611,"children":1613},{"class":207,"line":1612},28,[1614,1618,1622],{"type":32,"tag":205,"props":1615,"children":1616},{"style":716},[1617],{"type":45,"value":745},{"type":32,"tag":205,"props":1619,"children":1620},{"style":689},[1621],{"type":45,"value":750},{"type":32,"tag":205,"props":1623,"children":1624},{"style":275},[1625],{"type":45,"value":1626}," locations\n",{"type":32,"tag":205,"props":1628,"children":1630},{"class":207,"line":1629},29,[1631],{"type":32,"tag":205,"props":1632,"children":1633},{"style":716},[1634],{"type":45,"value":787},{"type":32,"tag":205,"props":1636,"children":1638},{"class":207,"line":1637},30,[1639,1644,1649,1654,1658,1663,1667,1671,1676,1680,1684,1688,1692],{"type":32,"tag":205,"props":1640,"children":1641},{"style":651},[1642],{"type":45,"value":1643},"  public",{"type":32,"tag":205,"props":1645,"children":1646},{"style":651},[1647],{"type":45,"value":1648}," async",{"type":32,"tag":205,"props":1650,"children":1651},{"style":212},[1652],{"type":45,"value":1653}," upsertLocations",{"type":32,"tag":205,"props":1655,"children":1656},{"style":275},[1657],{"type":45,"value":1443},{"type":32,"tag":205,"props":1659,"children":1660},{"style":808},[1661],{"type":45,"value":1662},"locations",{"type":32,"tag":205,"props":1664,"children":1665},{"style":651},[1666],{"type":45,"value":260},{"type":32,"tag":205,"props":1668,"children":1669},{"style":695},[1670],{"type":45,"value":820},{"type":32,"tag":205,"props":1672,"children":1673},{"style":275},[1674],{"type":45,"value":1675},"[])",{"type":32,"tag":205,"props":1677,"children":1678},{"style":651},[1679],{"type":45,"value":260},{"type":32,"tag":205,"props":1681,"children":1682},{"style":695},[1683],{"type":45,"value":843},{"type":32,"tag":205,"props":1685,"children":1686},{"style":275},[1687],{"type":45,"value":848},{"type":32,"tag":205,"props":1689,"children":1690},{"style":689},[1691],{"type":45,"value":853},{"type":32,"tag":205,"props":1693,"children":1694},{"style":275},[1695],{"type":45,"value":1696},"> {\n",{"type":32,"tag":205,"props":1698,"children":1700},{"class":207,"line":1699},31,[1701],{"type":32,"tag":205,"props":1702,"children":1703},{"emptyLinePlaceholder":675},[1704],{"type":45,"value":678},{"type":32,"tag":205,"props":1706,"children":1708},{"class":207,"line":1707},32,[1709,1713,1718,1723,1728],{"type":32,"tag":205,"props":1710,"children":1711},{"style":651},[1712],{"type":45,"value":1438},{"type":32,"tag":205,"props":1714,"children":1715},{"style":275},[1716],{"type":45,"value":1717}," (locations.length ",{"type":32,"tag":205,"props":1719,"children":1720},{"style":651},[1721],{"type":45,"value":1722},"===",{"type":32,"tag":205,"props":1724,"children":1725},{"style":239},[1726],{"type":45,"value":1727}," 0",{"type":32,"tag":205,"props":1729,"children":1730},{"style":275},[1731],{"type":45,"value":1732},") {\n",{"type":32,"tag":205,"props":1734,"children":1736},{"class":207,"line":1735},33,[1737,1742],{"type":32,"tag":205,"props":1738,"children":1739},{"style":651},[1740],{"type":45,"value":1741},"      return",{"type":32,"tag":205,"props":1743,"children":1744},{"style":239},[1745],{"type":45,"value":1746}," 0\n",{"type":32,"tag":205,"props":1748,"children":1750},{"class":207,"line":1749},34,[1751],{"type":32,"tag":205,"props":1752,"children":1753},{"style":275},[1754],{"type":45,"value":1500},{"type":32,"tag":205,"props":1756,"children":1758},{"class":207,"line":1757},35,[1759],{"type":32,"tag":205,"props":1760,"children":1761},{"emptyLinePlaceholder":675},[1762],{"type":45,"value":678},{"type":32,"tag":205,"props":1764,"children":1766},{"class":207,"line":1765},36,[1767,1772,1777,1782],{"type":32,"tag":205,"props":1768,"children":1769},{"style":689},[1770],{"type":45,"value":1771},"    const",{"type":32,"tag":205,"props":1773,"children":1774},{"style":275},[1775],{"type":45,"value":1776}," AI_BATCH_SIZE ",{"type":32,"tag":205,"props":1778,"children":1779},{"style":651},[1780],{"type":45,"value":1781},"=",{"type":32,"tag":205,"props":1783,"children":1784},{"style":239},[1785],{"type":45,"value":1786}," 10\n",{"type":32,"tag":205,"props":1788,"children":1790},{"class":207,"line":1789},37,[1791,1796,1801,1805],{"type":32,"tag":205,"props":1792,"children":1793},{"style":689},[1794],{"type":45,"value":1795},"    let",{"type":32,"tag":205,"props":1797,"children":1798},{"style":275},[1799],{"type":45,"value":1800}," successfulUpserts ",{"type":32,"tag":205,"props":1802,"children":1803},{"style":651},[1804],{"type":45,"value":1781},{"type":32,"tag":205,"props":1806,"children":1807},{"style":239},[1808],{"type":45,"value":1746},{"type":32,"tag":205,"props":1810,"children":1812},{"class":207,"line":1811},38,[1813],{"type":32,"tag":205,"props":1814,"children":1815},{"emptyLinePlaceholder":675},[1816],{"type":45,"value":678},{"type":32,"tag":205,"props":1818,"children":1820},{"class":207,"line":1819},39,[1821,1826,1830,1835,1840,1844,1848,1853,1857,1862,1867],{"type":32,"tag":205,"props":1822,"children":1823},{"style":651},[1824],{"type":45,"value":1825},"    for",{"type":32,"tag":205,"props":1827,"children":1828},{"style":275},[1829],{"type":45,"value":1443},{"type":32,"tag":205,"props":1831,"children":1832},{"style":689},[1833],{"type":45,"value":1834},"let",{"type":32,"tag":205,"props":1836,"children":1837},{"style":275},[1838],{"type":45,"value":1839}," i ",{"type":32,"tag":205,"props":1841,"children":1842},{"style":651},[1843],{"type":45,"value":1781},{"type":32,"tag":205,"props":1845,"children":1846},{"style":239},[1847],{"type":45,"value":1727},{"type":32,"tag":205,"props":1849,"children":1850},{"style":275},[1851],{"type":45,"value":1852},"; i ",{"type":32,"tag":205,"props":1854,"children":1855},{"style":651},[1856],{"type":45,"value":848},{"type":32,"tag":205,"props":1858,"children":1859},{"style":275},[1860],{"type":45,"value":1861}," locations.length; i ",{"type":32,"tag":205,"props":1863,"children":1864},{"style":651},[1865],{"type":45,"value":1866},"+=",{"type":32,"tag":205,"props":1868,"children":1869},{"style":275},[1870],{"type":45,"value":1871}," AI_BATCH_SIZE) {\n",{"type":32,"tag":205,"props":1873,"children":1875},{"class":207,"line":1874},40,[1876,1881,1886,1890,1895,1900,1905,1910],{"type":32,"tag":205,"props":1877,"children":1878},{"style":689},[1879],{"type":45,"value":1880},"      const",{"type":32,"tag":205,"props":1882,"children":1883},{"style":275},[1884],{"type":45,"value":1885}," batch ",{"type":32,"tag":205,"props":1887,"children":1888},{"style":651},[1889],{"type":45,"value":1781},{"type":32,"tag":205,"props":1891,"children":1892},{"style":275},[1893],{"type":45,"value":1894}," locations.",{"type":32,"tag":205,"props":1896,"children":1897},{"style":212},[1898],{"type":45,"value":1899},"slice",{"type":32,"tag":205,"props":1901,"children":1902},{"style":275},[1903],{"type":45,"value":1904},"(i, i ",{"type":32,"tag":205,"props":1906,"children":1907},{"style":651},[1908],{"type":45,"value":1909},"+",{"type":32,"tag":205,"props":1911,"children":1912},{"style":275},[1913],{"type":45,"value":1914}," AI_BATCH_SIZE)\n",{"type":32,"tag":205,"props":1916,"children":1918},{"class":207,"line":1917},41,[1919],{"type":32,"tag":205,"props":1920,"children":1921},{"emptyLinePlaceholder":675},[1922],{"type":45,"value":678},{"type":32,"tag":205,"props":1924,"children":1926},{"class":207,"line":1925},42,[1927,1932],{"type":32,"tag":205,"props":1928,"children":1929},{"style":651},[1930],{"type":45,"value":1931},"      try",{"type":32,"tag":205,"props":1933,"children":1934},{"style":275},[1935],{"type":45,"value":703},{"type":32,"tag":205,"props":1937,"children":1939},{"class":207,"line":1938},43,[1940,1945,1950,1954,1959,1964,1969,1974,1979],{"type":32,"tag":205,"props":1941,"children":1942},{"style":689},[1943],{"type":45,"value":1944},"        const",{"type":32,"tag":205,"props":1946,"children":1947},{"style":275},[1948],{"type":45,"value":1949}," textsToEmbed ",{"type":32,"tag":205,"props":1951,"children":1952},{"style":651},[1953],{"type":45,"value":1781},{"type":32,"tag":205,"props":1955,"children":1956},{"style":275},[1957],{"type":45,"value":1958}," batch.",{"type":32,"tag":205,"props":1960,"children":1961},{"style":212},[1962],{"type":45,"value":1963},"map",{"type":32,"tag":205,"props":1965,"children":1966},{"style":275},[1967],{"type":45,"value":1968},"((",{"type":32,"tag":205,"props":1970,"children":1971},{"style":808},[1972],{"type":45,"value":1973},"location",{"type":32,"tag":205,"props":1975,"children":1976},{"style":275},[1977],{"type":45,"value":1978},") ",{"type":32,"tag":205,"props":1980,"children":1981},{"style":689},[1982],{"type":45,"value":1983},"=>\n",{"type":32,"tag":205,"props":1985,"children":1987},{"class":207,"line":1986},44,[1988,1994,1998,2003],{"type":32,"tag":205,"props":1989,"children":1991},{"style":1990},"--shiki-default:#FD971F",[1992],{"type":45,"value":1993},"          this",{"type":32,"tag":205,"props":1995,"children":1996},{"style":275},[1997],{"type":45,"value":880},{"type":32,"tag":205,"props":1999,"children":2000},{"style":212},[2001],{"type":45,"value":2002},"buildTextForEmbedding",{"type":32,"tag":205,"props":2004,"children":2005},{"style":275},[2006],{"type":45,"value":2007},"(location),\n",{"type":32,"tag":205,"props":2009,"children":2011},{"class":207,"line":2010},45,[2012],{"type":32,"tag":205,"props":2013,"children":2014},{"style":275},[2015],{"type":45,"value":2016},"        )\n",{"type":32,"tag":205,"props":2018,"children":2020},{"class":207,"line":2019},46,[2021],{"type":32,"tag":205,"props":2022,"children":2023},{"emptyLinePlaceholder":675},[2024],{"type":45,"value":678},{"type":32,"tag":205,"props":2026,"children":2028},{"class":207,"line":2027},47,[2029,2033,2038,2042,2047,2052,2056,2061],{"type":32,"tag":205,"props":2030,"children":2031},{"style":689},[2032],{"type":45,"value":1944},{"type":32,"tag":205,"props":2034,"children":2035},{"style":275},[2036],{"type":45,"value":2037}," vectors ",{"type":32,"tag":205,"props":2039,"children":2040},{"style":651},[2041],{"type":45,"value":1781},{"type":32,"tag":205,"props":2043,"children":2044},{"style":651},[2045],{"type":45,"value":2046}," await",{"type":32,"tag":205,"props":2048,"children":2049},{"style":1990},[2050],{"type":45,"value":2051}," this",{"type":32,"tag":205,"props":2053,"children":2054},{"style":275},[2055],{"type":45,"value":880},{"type":32,"tag":205,"props":2057,"children":2058},{"style":212},[2059],{"type":45,"value":2060},"embedTextBatch",{"type":32,"tag":205,"props":2062,"children":2063},{"style":275},[2064],{"type":45,"value":2065},"(textsToEmbed)\n",{"type":32,"tag":205,"props":2067,"children":2069},{"class":207,"line":2068},48,[2070],{"type":32,"tag":205,"props":2071,"children":2072},{"emptyLinePlaceholder":675},[2073],{"type":45,"value":678},{"type":32,"tag":205,"props":2075,"children":2077},{"class":207,"line":2076},49,[2078,2082,2087,2091,2095,2099,2103,2107,2112,2117,2121,2126],{"type":32,"tag":205,"props":2079,"children":2080},{"style":689},[2081],{"type":45,"value":1944},{"type":32,"tag":205,"props":2083,"children":2084},{"style":275},[2085],{"type":45,"value":2086}," vectorObjects ",{"type":32,"tag":205,"props":2088,"children":2089},{"style":651},[2090],{"type":45,"value":1781},{"type":32,"tag":205,"props":2092,"children":2093},{"style":275},[2094],{"type":45,"value":1958},{"type":32,"tag":205,"props":2096,"children":2097},{"style":212},[2098],{"type":45,"value":1963},{"type":32,"tag":205,"props":2100,"children":2101},{"style":275},[2102],{"type":45,"value":1968},{"type":32,"tag":205,"props":2104,"children":2105},{"style":808},[2106],{"type":45,"value":1973},{"type":32,"tag":205,"props":2108,"children":2109},{"style":275},[2110],{"type":45,"value":2111},", ",{"type":32,"tag":205,"props":2113,"children":2114},{"style":808},[2115],{"type":45,"value":2116},"idx",{"type":32,"tag":205,"props":2118,"children":2119},{"style":275},[2120],{"type":45,"value":1978},{"type":32,"tag":205,"props":2122,"children":2123},{"style":689},[2124],{"type":45,"value":2125},"=>",{"type":32,"tag":205,"props":2127,"children":2128},{"style":275},[2129],{"type":45,"value":703},{"type":32,"tag":205,"props":2131,"children":2133},{"class":207,"line":2132},50,[2134,2139,2144,2148],{"type":32,"tag":205,"props":2135,"children":2136},{"style":689},[2137],{"type":45,"value":2138},"          const",{"type":32,"tag":205,"props":2140,"children":2141},{"style":275},[2142],{"type":45,"value":2143}," vector ",{"type":32,"tag":205,"props":2145,"children":2146},{"style":651},[2147],{"type":45,"value":1781},{"type":32,"tag":205,"props":2149,"children":2150},{"style":275},[2151],{"type":45,"value":2152}," vectors[idx]\n",{"type":32,"tag":205,"props":2154,"children":2156},{"class":207,"line":2155},51,[2157,2162,2166,2170,2175,2180],{"type":32,"tag":205,"props":2158,"children":2159},{"style":651},[2160],{"type":45,"value":2161},"          if",{"type":32,"tag":205,"props":2163,"children":2164},{"style":275},[2165],{"type":45,"value":1443},{"type":32,"tag":205,"props":2167,"children":2168},{"style":651},[2169],{"type":45,"value":1448},{"type":32,"tag":205,"props":2171,"children":2172},{"style":275},[2173],{"type":45,"value":2174},"vector) ",{"type":32,"tag":205,"props":2176,"children":2177},{"style":651},[2178],{"type":45,"value":2179},"return",{"type":32,"tag":205,"props":2181,"children":2182},{"style":239},[2183],{"type":45,"value":2184}," null\n",{"type":32,"tag":205,"props":2186,"children":2188},{"class":207,"line":2187},52,[2189,2194],{"type":32,"tag":205,"props":2190,"children":2191},{"style":651},[2192],{"type":45,"value":2193},"          return",{"type":32,"tag":205,"props":2195,"children":2196},{"style":275},[2197],{"type":45,"value":703},{"type":32,"tag":205,"props":2199,"children":2201},{"class":207,"line":2200},53,[2202],{"type":32,"tag":205,"props":2203,"children":2204},{"style":275},[2205],{"type":45,"value":2206},"            id: location.id,\n",{"type":32,"tag":205,"props":2208,"children":2210},{"class":207,"line":2209},54,[2211],{"type":32,"tag":205,"props":2212,"children":2213},{"style":275},[2214],{"type":45,"value":2215},"            values: vector,\n",{"type":32,"tag":205,"props":2217,"children":2219},{"class":207,"line":2218},55,[2220],{"type":32,"tag":205,"props":2221,"children":2222},{"style":275},[2223],{"type":45,"value":2224},"            metadata: {\n",{"type":32,"tag":205,"props":2226,"children":2228},{"class":207,"line":2227},56,[2229],{"type":32,"tag":205,"props":2230,"children":2231},{"style":275},[2232],{"type":45,"value":2233},"              locationId: location.id,\n",{"type":32,"tag":205,"props":2235,"children":2237},{"class":207,"line":2236},57,[2238],{"type":32,"tag":205,"props":2239,"children":2240},{"style":275},[2241],{"type":45,"value":2242},"            },\n",{"type":32,"tag":205,"props":2244,"children":2246},{"class":207,"line":2245},58,[2247],{"type":32,"tag":205,"props":2248,"children":2249},{"style":275},[2250],{"type":45,"value":2251},"          }\n",{"type":32,"tag":205,"props":2253,"children":2255},{"class":207,"line":2254},59,[2256,2261,2266,2270,2275,2280,2284,2289,2294,2299,2303,2308,2313,2317,2322,2327,2332],{"type":32,"tag":205,"props":2257,"children":2258},{"style":275},[2259],{"type":45,"value":2260},"        }).",{"type":32,"tag":205,"props":2262,"children":2263},{"style":212},[2264],{"type":45,"value":2265},"filter",{"type":32,"tag":205,"props":2267,"children":2268},{"style":275},[2269],{"type":45,"value":1968},{"type":32,"tag":205,"props":2271,"children":2272},{"style":808},[2273],{"type":45,"value":2274},"obj",{"type":32,"tag":205,"props":2276,"children":2277},{"style":275},[2278],{"type":45,"value":2279},")",{"type":32,"tag":205,"props":2281,"children":2282},{"style":651},[2283],{"type":45,"value":260},{"type":32,"tag":205,"props":2285,"children":2286},{"style":808},[2287],{"type":45,"value":2288}," obj",{"type":32,"tag":205,"props":2290,"children":2291},{"style":651},[2292],{"type":45,"value":2293}," is",{"type":32,"tag":205,"props":2295,"children":2296},{"style":695},[2297],{"type":45,"value":2298}," NonNullable",{"type":32,"tag":205,"props":2300,"children":2301},{"style":275},[2302],{"type":45,"value":848},{"type":32,"tag":205,"props":2304,"children":2305},{"style":651},[2306],{"type":45,"value":2307},"typeof",{"type":32,"tag":205,"props":2309,"children":2310},{"style":275},[2311],{"type":45,"value":2312}," obj> ",{"type":32,"tag":205,"props":2314,"children":2315},{"style":689},[2316],{"type":45,"value":2125},{"type":32,"tag":205,"props":2318,"children":2319},{"style":275},[2320],{"type":45,"value":2321}," obj ",{"type":32,"tag":205,"props":2323,"children":2324},{"style":651},[2325],{"type":45,"value":2326},"!==",{"type":32,"tag":205,"props":2328,"children":2329},{"style":239},[2330],{"type":45,"value":2331}," null",{"type":32,"tag":205,"props":2333,"children":2334},{"style":275},[2335],{"type":45,"value":1491},{"type":32,"tag":205,"props":2337,"children":2339},{"class":207,"line":2338},60,[2340],{"type":32,"tag":205,"props":2341,"children":2342},{"emptyLinePlaceholder":675},[2343],{"type":45,"value":678},{"type":32,"tag":205,"props":2345,"children":2347},{"class":207,"line":2346},61,[2348,2353,2358,2363,2367],{"type":32,"tag":205,"props":2349,"children":2350},{"style":651},[2351],{"type":45,"value":2352},"        if",{"type":32,"tag":205,"props":2354,"children":2355},{"style":275},[2356],{"type":45,"value":2357}," (vectorObjects.length ",{"type":32,"tag":205,"props":2359,"children":2360},{"style":651},[2361],{"type":45,"value":2362},">",{"type":32,"tag":205,"props":2364,"children":2365},{"style":239},[2366],{"type":45,"value":1727},{"type":32,"tag":205,"props":2368,"children":2369},{"style":275},[2370],{"type":45,"value":1732},{"type":32,"tag":205,"props":2372,"children":2374},{"class":207,"line":2373},62,[2375,2379,2384,2388,2392,2396,2401,2406],{"type":32,"tag":205,"props":2376,"children":2377},{"style":689},[2378],{"type":45,"value":2138},{"type":32,"tag":205,"props":2380,"children":2381},{"style":275},[2382],{"type":45,"value":2383}," result ",{"type":32,"tag":205,"props":2385,"children":2386},{"style":651},[2387],{"type":45,"value":1781},{"type":32,"tag":205,"props":2389,"children":2390},{"style":651},[2391],{"type":45,"value":2046},{"type":32,"tag":205,"props":2393,"children":2394},{"style":1990},[2395],{"type":45,"value":2051},{"type":32,"tag":205,"props":2397,"children":2398},{"style":275},[2399],{"type":45,"value":2400},".vectorIndex.",{"type":32,"tag":205,"props":2402,"children":2403},{"style":212},[2404],{"type":45,"value":2405},"upsert",{"type":32,"tag":205,"props":2407,"children":2408},{"style":275},[2409],{"type":45,"value":2410},"(vectorObjects)\n",{"type":32,"tag":205,"props":2412,"children":2414},{"class":207,"line":2413},63,[2415,2420,2425,2429,2434,2439,2444],{"type":32,"tag":205,"props":2416,"children":2417},{"style":275},[2418],{"type":45,"value":2419},"          console.",{"type":32,"tag":205,"props":2421,"children":2422},{"style":212},[2423],{"type":45,"value":2424},"log",{"type":32,"tag":205,"props":2426,"children":2427},{"style":275},[2428],{"type":45,"value":1550},{"type":32,"tag":205,"props":2430,"children":2431},{"style":218},[2432],{"type":45,"value":2433},"'[Repo] Upsert result:'",{"type":32,"tag":205,"props":2435,"children":2436},{"style":275},[2437],{"type":45,"value":2438},", JSON.",{"type":32,"tag":205,"props":2440,"children":2441},{"style":212},[2442],{"type":45,"value":2443},"stringify",{"type":32,"tag":205,"props":2445,"children":2446},{"style":275},[2447],{"type":45,"value":2448},"(result))\n",{"type":32,"tag":205,"props":2450,"children":2452},{"class":207,"line":2451},64,[2453,2458,2462],{"type":32,"tag":205,"props":2454,"children":2455},{"style":275},[2456],{"type":45,"value":2457},"          successfulUpserts ",{"type":32,"tag":205,"props":2459,"children":2460},{"style":651},[2461],{"type":45,"value":1866},{"type":32,"tag":205,"props":2463,"children":2464},{"style":275},[2465],{"type":45,"value":2466}," vectorObjects.length\n",{"type":32,"tag":205,"props":2468,"children":2470},{"class":207,"line":2469},65,[2471],{"type":32,"tag":205,"props":2472,"children":2473},{"style":275},[2474],{"type":45,"value":2475},"        }\n",{"type":32,"tag":205,"props":2477,"children":2479},{"class":207,"line":2478},66,[2480,2485,2490],{"type":32,"tag":205,"props":2481,"children":2482},{"style":275},[2483],{"type":45,"value":2484},"      } ",{"type":32,"tag":205,"props":2486,"children":2487},{"style":651},[2488],{"type":45,"value":2489},"catch",{"type":32,"tag":205,"props":2491,"children":2492},{"style":275},[2493],{"type":45,"value":2494}," (error) {\n",{"type":32,"tag":205,"props":2496,"children":2498},{"class":207,"line":2497},67,[2499,2504,2509],{"type":32,"tag":205,"props":2500,"children":2501},{"style":275},[2502],{"type":45,"value":2503},"        console.",{"type":32,"tag":205,"props":2505,"children":2506},{"style":212},[2507],{"type":45,"value":2508},"error",{"type":32,"tag":205,"props":2510,"children":2511},{"style":275},[2512],{"type":45,"value":1477},{"type":32,"tag":205,"props":2514,"children":2516},{"class":207,"line":2515},68,[2517,2522,2527,2532,2537,2542],{"type":32,"tag":205,"props":2518,"children":2519},{"style":218},[2520],{"type":45,"value":2521},"          `[CloudflareVectorAIRepository] Failed to process batch starting at index ",{"type":32,"tag":205,"props":2523,"children":2524},{"style":651},[2525],{"type":45,"value":2526},"${",{"type":32,"tag":205,"props":2528,"children":2529},{"style":275},[2530],{"type":45,"value":2531},"i",{"type":32,"tag":205,"props":2533,"children":2534},{"style":651},[2535],{"type":45,"value":2536},"}",{"type":32,"tag":205,"props":2538,"children":2539},{"style":218},[2540],{"type":45,"value":2541},"`",{"type":32,"tag":205,"props":2543,"children":2544},{"style":275},[2545],{"type":45,"value":1385},{"type":32,"tag":205,"props":2547,"children":2549},{"class":207,"line":2548},69,[2550],{"type":32,"tag":205,"props":2551,"children":2552},{"style":275},[2553],{"type":45,"value":2554},"          error,\n",{"type":32,"tag":205,"props":2556,"children":2558},{"class":207,"line":2557},70,[2559],{"type":32,"tag":205,"props":2560,"children":2561},{"style":275},[2562],{"type":45,"value":2016},{"type":32,"tag":205,"props":2564,"children":2566},{"class":207,"line":2565},71,[2567],{"type":32,"tag":205,"props":2568,"children":2569},{"style":275},[2570],{"type":45,"value":2571},"      }\n",{"type":32,"tag":205,"props":2573,"children":2575},{"class":207,"line":2574},72,[2576],{"type":32,"tag":205,"props":2577,"children":2578},{"style":275},[2579],{"type":45,"value":1500},{"type":32,"tag":205,"props":2581,"children":2583},{"class":207,"line":2582},73,[2584,2589],{"type":32,"tag":205,"props":2585,"children":2586},{"style":651},[2587],{"type":45,"value":2588},"    return",{"type":32,"tag":205,"props":2590,"children":2591},{"style":275},[2592],{"type":45,"value":2593}," successfulUpserts\n",{"type":32,"tag":205,"props":2595,"children":2597},{"class":207,"line":2596},74,[2598],{"type":32,"tag":205,"props":2599,"children":2600},{"style":275},[2601],{"type":45,"value":1576},{"type":32,"tag":205,"props":2603,"children":2605},{"class":207,"line":2604},75,[2606],{"type":32,"tag":205,"props":2607,"children":2608},{"emptyLinePlaceholder":675},[2609],{"type":45,"value":678},{"type":32,"tag":205,"props":2611,"children":2613},{"class":207,"line":2612},76,[2614],{"type":32,"tag":205,"props":2615,"children":2616},{"style":716},[2617],{"type":45,"value":719},{"type":32,"tag":205,"props":2619,"children":2621},{"class":207,"line":2620},77,[2622],{"type":32,"tag":205,"props":2623,"children":2624},{"style":716},[2625],{"type":45,"value":2626},"   * Embeds a batch of texts using the BGE-M3 model.\n",{"type":32,"tag":205,"props":2628,"children":2630},{"class":207,"line":2629},78,[2631],{"type":32,"tag":205,"props":2632,"children":2633},{"style":716},[2634],{"type":45,"value":736},{"type":32,"tag":205,"props":2636,"children":2638},{"class":207,"line":2637},79,[2639,2643,2647],{"type":32,"tag":205,"props":2640,"children":2641},{"style":716},[2642],{"type":45,"value":745},{"type":32,"tag":205,"props":2644,"children":2645},{"style":689},[2646],{"type":45,"value":750},{"type":32,"tag":205,"props":2648,"children":2649},{"style":275},[2650],{"type":45,"value":2651}," texts\n",{"type":32,"tag":205,"props":2653,"children":2655},{"class":207,"line":2654},80,[2656,2660],{"type":32,"tag":205,"props":2657,"children":2658},{"style":716},[2659],{"type":45,"value":745},{"type":32,"tag":205,"props":2661,"children":2662},{"style":689},[2663],{"type":45,"value":2664},"@private\n",{"type":32,"tag":205,"props":2666,"children":2668},{"class":207,"line":2667},81,[2669],{"type":32,"tag":205,"props":2670,"children":2671},{"style":716},[2672],{"type":45,"value":787},{"type":32,"tag":205,"props":2674,"children":2676},{"class":207,"line":2675},82,[2677,2682,2686,2691,2695,2700,2704,2709,2713,2717,2721,2725,2729],{"type":32,"tag":205,"props":2678,"children":2679},{"style":651},[2680],{"type":45,"value":2681},"  private",{"type":32,"tag":205,"props":2683,"children":2684},{"style":651},[2685],{"type":45,"value":1648},{"type":32,"tag":205,"props":2687,"children":2688},{"style":212},[2689],{"type":45,"value":2690}," embedTextBatch",{"type":32,"tag":205,"props":2692,"children":2693},{"style":275},[2694],{"type":45,"value":1443},{"type":32,"tag":205,"props":2696,"children":2697},{"style":808},[2698],{"type":45,"value":2699},"texts",{"type":32,"tag":205,"props":2701,"children":2702},{"style":651},[2703],{"type":45,"value":260},{"type":32,"tag":205,"props":2705,"children":2706},{"style":689},[2707],{"type":45,"value":2708}," string",{"type":32,"tag":205,"props":2710,"children":2711},{"style":275},[2712],{"type":45,"value":1675},{"type":32,"tag":205,"props":2714,"children":2715},{"style":651},[2716],{"type":45,"value":260},{"type":32,"tag":205,"props":2718,"children":2719},{"style":695},[2720],{"type":45,"value":843},{"type":32,"tag":205,"props":2722,"children":2723},{"style":275},[2724],{"type":45,"value":848},{"type":32,"tag":205,"props":2726,"children":2727},{"style":689},[2728],{"type":45,"value":853},{"type":32,"tag":205,"props":2730,"children":2731},{"style":275},[2732],{"type":45,"value":2733},"[][]> {\n",{"type":32,"tag":205,"props":2735,"children":2737},{"class":207,"line":2736},83,[2738,2742,2747,2751,2755,2760,2764,2769,2774],{"type":32,"tag":205,"props":2739,"children":2740},{"style":689},[2741],{"type":45,"value":1771},{"type":32,"tag":205,"props":2743,"children":2744},{"style":275},[2745],{"type":45,"value":2746}," response ",{"type":32,"tag":205,"props":2748,"children":2749},{"style":651},[2750],{"type":45,"value":1781},{"type":32,"tag":205,"props":2752,"children":2753},{"style":275},[2754],{"type":45,"value":1443},{"type":32,"tag":205,"props":2756,"children":2757},{"style":651},[2758],{"type":45,"value":2759},"await",{"type":32,"tag":205,"props":2761,"children":2762},{"style":1990},[2763],{"type":45,"value":2051},{"type":32,"tag":205,"props":2765,"children":2766},{"style":275},[2767],{"type":45,"value":2768},".ai.",{"type":32,"tag":205,"props":2770,"children":2771},{"style":212},[2772],{"type":45,"value":2773},"run",{"type":32,"tag":205,"props":2775,"children":2776},{"style":275},[2777],{"type":45,"value":1477},{"type":32,"tag":205,"props":2779,"children":2781},{"class":207,"line":2780},84,[2782,2787],{"type":32,"tag":205,"props":2783,"children":2784},{"style":218},[2785],{"type":45,"value":2786},"      '@cf/baai/bge-m3'",{"type":32,"tag":205,"props":2788,"children":2789},{"style":275},[2790],{"type":45,"value":2791},", {\n",{"type":32,"tag":205,"props":2793,"children":2795},{"class":207,"line":2794},85,[2796],{"type":32,"tag":205,"props":2797,"children":2798},{"style":275},[2799],{"type":45,"value":2800},"        text: texts,\n",{"type":32,"tag":205,"props":2802,"children":2804},{"class":207,"line":2803},86,[2805,2810,2815],{"type":32,"tag":205,"props":2806,"children":2807},{"style":275},[2808],{"type":45,"value":2809},"        response_format: ",{"type":32,"tag":205,"props":2811,"children":2812},{"style":218},[2813],{"type":45,"value":2814},"'embedding_vector'",{"type":32,"tag":205,"props":2816,"children":2817},{"style":275},[2818],{"type":45,"value":1385},{"type":32,"tag":205,"props":2820,"children":2822},{"class":207,"line":2821},87,[2823],{"type":32,"tag":205,"props":2824,"children":2825},{"style":275},[2826],{"type":45,"value":2827},"      },\n",{"type":32,"tag":205,"props":2829,"children":2831},{"class":207,"line":2830},88,[2832,2837,2842],{"type":32,"tag":205,"props":2833,"children":2834},{"style":275},[2835],{"type":45,"value":2836},"    )) ",{"type":32,"tag":205,"props":2838,"children":2839},{"style":651},[2840],{"type":45,"value":2841},"as",{"type":32,"tag":205,"props":2843,"children":2844},{"style":695},[2845],{"type":45,"value":2846}," BGEEmbeddingResponse\n",{"type":32,"tag":205,"props":2848,"children":2850},{"class":207,"line":2849},89,[2851],{"type":32,"tag":205,"props":2852,"children":2853},{"emptyLinePlaceholder":675},[2854],{"type":45,"value":678},{"type":32,"tag":205,"props":2856,"children":2858},{"class":207,"line":2857},90,[2859,2863,2867,2871,2876,2881],{"type":32,"tag":205,"props":2860,"children":2861},{"style":689},[2862],{"type":45,"value":1771},{"type":32,"tag":205,"props":2864,"children":2865},{"style":275},[2866],{"type":45,"value":2037},{"type":32,"tag":205,"props":2868,"children":2869},{"style":651},[2870],{"type":45,"value":1781},{"type":32,"tag":205,"props":2872,"children":2873},{"style":275},[2874],{"type":45,"value":2875}," response.data ",{"type":32,"tag":205,"props":2877,"children":2878},{"style":651},[2879],{"type":45,"value":2880},"??",{"type":32,"tag":205,"props":2882,"children":2883},{"style":275},[2884],{"type":45,"value":2885}," response.response\n",{"type":32,"tag":205,"props":2887,"children":2889},{"class":207,"line":2888},91,[2890],{"type":32,"tag":205,"props":2891,"children":2892},{"emptyLinePlaceholder":675},[2893],{"type":45,"value":678},{"type":32,"tag":205,"props":2895,"children":2897},{"class":207,"line":2896},92,[2898,2902,2906,2910,2915,2920,2924,2928,2932,2937],{"type":32,"tag":205,"props":2899,"children":2900},{"style":651},[2901],{"type":45,"value":1438},{"type":32,"tag":205,"props":2903,"children":2904},{"style":275},[2905],{"type":45,"value":1443},{"type":32,"tag":205,"props":2907,"children":2908},{"style":651},[2909],{"type":45,"value":1448},{"type":32,"tag":205,"props":2911,"children":2912},{"style":275},[2913],{"type":45,"value":2914},"vectors) ",{"type":32,"tag":205,"props":2916,"children":2917},{"style":651},[2918],{"type":45,"value":2919},"throw",{"type":32,"tag":205,"props":2921,"children":2922},{"style":651},[2923],{"type":45,"value":1467},{"type":32,"tag":205,"props":2925,"children":2926},{"style":212},[2927],{"type":45,"value":1472},{"type":32,"tag":205,"props":2929,"children":2930},{"style":275},[2931],{"type":45,"value":1550},{"type":32,"tag":205,"props":2933,"children":2934},{"style":218},[2935],{"type":45,"value":2936},"'BGE-M3 invalid response'",{"type":32,"tag":205,"props":2938,"children":2939},{"style":275},[2940],{"type":45,"value":1491},{"type":32,"tag":205,"props":2942,"children":2944},{"class":207,"line":2943},93,[2945],{"type":32,"tag":205,"props":2946,"children":2947},{"emptyLinePlaceholder":675},[2948],{"type":45,"value":678},{"type":32,"tag":205,"props":2950,"children":2952},{"class":207,"line":2951},94,[2953,2957],{"type":32,"tag":205,"props":2954,"children":2955},{"style":651},[2956],{"type":45,"value":2588},{"type":32,"tag":205,"props":2958,"children":2959},{"style":275},[2960],{"type":45,"value":2961}," vectors\n",{"type":32,"tag":205,"props":2963,"children":2965},{"class":207,"line":2964},95,[2966],{"type":32,"tag":205,"props":2967,"children":2968},{"style":275},[2969],{"type":45,"value":1576},{"type":32,"tag":205,"props":2971,"children":2973},{"class":207,"line":2972},96,[2974],{"type":32,"tag":205,"props":2975,"children":2976},{"emptyLinePlaceholder":675},[2977],{"type":45,"value":678},{"type":32,"tag":205,"props":2979,"children":2981},{"class":207,"line":2980},97,[2982],{"type":32,"tag":205,"props":2983,"children":2984},{"style":716},[2985],{"type":45,"value":719},{"type":32,"tag":205,"props":2987,"children":2989},{"class":207,"line":2988},98,[2990],{"type":32,"tag":205,"props":2991,"children":2992},{"style":716},[2993],{"type":45,"value":2994},"   * Builds the text representation for embedding from a Location.\n",{"type":32,"tag":205,"props":2996,"children":2998},{"class":207,"line":2997},99,[2999],{"type":32,"tag":205,"props":3000,"children":3001},{"style":716},[3002],{"type":45,"value":736},{"type":32,"tag":205,"props":3004,"children":3006},{"class":207,"line":3005},100,[3007,3011,3015],{"type":32,"tag":205,"props":3008,"children":3009},{"style":716},[3010],{"type":45,"value":745},{"type":32,"tag":205,"props":3012,"children":3013},{"style":689},[3014],{"type":45,"value":750},{"type":32,"tag":205,"props":3016,"children":3017},{"style":275},[3018],{"type":45,"value":3019}," location\n",{"type":32,"tag":205,"props":3021,"children":3023},{"class":207,"line":3022},101,[3024,3028],{"type":32,"tag":205,"props":3025,"children":3026},{"style":716},[3027],{"type":45,"value":745},{"type":32,"tag":205,"props":3029,"children":3030},{"style":689},[3031],{"type":45,"value":2664},{"type":32,"tag":205,"props":3033,"children":3035},{"class":207,"line":3034},102,[3036],{"type":32,"tag":205,"props":3037,"children":3038},{"style":716},[3039],{"type":45,"value":787},{"type":32,"tag":205,"props":3041,"children":3043},{"class":207,"line":3042},103,[3044,3048,3053,3057,3061,3065,3069,3073,3077,3081],{"type":32,"tag":205,"props":3045,"children":3046},{"style":651},[3047],{"type":45,"value":2681},{"type":32,"tag":205,"props":3049,"children":3050},{"style":212},[3051],{"type":45,"value":3052}," buildTextForEmbedding",{"type":32,"tag":205,"props":3054,"children":3055},{"style":275},[3056],{"type":45,"value":1443},{"type":32,"tag":205,"props":3058,"children":3059},{"style":808},[3060],{"type":45,"value":1973},{"type":32,"tag":205,"props":3062,"children":3063},{"style":651},[3064],{"type":45,"value":260},{"type":32,"tag":205,"props":3066,"children":3067},{"style":695},[3068],{"type":45,"value":820},{"type":32,"tag":205,"props":3070,"children":3071},{"style":275},[3072],{"type":45,"value":2279},{"type":32,"tag":205,"props":3074,"children":3075},{"style":651},[3076],{"type":45,"value":260},{"type":32,"tag":205,"props":3078,"children":3079},{"style":689},[3080],{"type":45,"value":2708},{"type":32,"tag":205,"props":3082,"children":3083},{"style":275},[3084],{"type":45,"value":703},{"type":32,"tag":205,"props":3086,"children":3088},{"class":207,"line":3087},104,[3089,3093,3098,3102,3107,3111,3116,3120,3125,3130,3134,3139,3143,3147],{"type":32,"tag":205,"props":3090,"children":3091},{"style":651},[3092],{"type":45,"value":2588},{"type":32,"tag":205,"props":3094,"children":3095},{"style":218},[3096],{"type":45,"value":3097}," `",{"type":32,"tag":205,"props":3099,"children":3100},{"style":651},[3101],{"type":45,"value":2526},{"type":32,"tag":205,"props":3103,"children":3104},{"style":275},[3105],{"type":45,"value":3106},"location.name",{"type":32,"tag":205,"props":3108,"children":3109},{"style":651},[3110],{"type":45,"value":2536},{"type":32,"tag":205,"props":3112,"children":3113},{"style":218},[3114],{"type":45,"value":3115}," | ",{"type":32,"tag":205,"props":3117,"children":3118},{"style":651},[3119],{"type":45,"value":2526},{"type":32,"tag":205,"props":3121,"children":3122},{"style":275},[3123],{"type":45,"value":3124},"location.postcodes.",{"type":32,"tag":205,"props":3126,"children":3127},{"style":212},[3128],{"type":45,"value":3129},"join",{"type":32,"tag":205,"props":3131,"children":3132},{"style":275},[3133],{"type":45,"value":1550},{"type":32,"tag":205,"props":3135,"children":3136},{"style":218},[3137],{"type":45,"value":3138},"', '",{"type":32,"tag":205,"props":3140,"children":3141},{"style":275},[3142],{"type":45,"value":2279},{"type":32,"tag":205,"props":3144,"children":3145},{"style":651},[3146],{"type":45,"value":2536},{"type":32,"tag":205,"props":3148,"children":3149},{"style":218},[3150],{"type":45,"value":3151},"`\n",{"type":32,"tag":205,"props":3153,"children":3155},{"class":207,"line":3154},105,[3156],{"type":32,"tag":205,"props":3157,"children":3158},{"style":275},[3159],{"type":45,"value":1576},{"type":32,"tag":205,"props":3161,"children":3163},{"class":207,"line":3162},106,[3164],{"type":32,"tag":205,"props":3165,"children":3166},{"emptyLinePlaceholder":675},[3167],{"type":45,"value":678},{"type":32,"tag":205,"props":3169,"children":3171},{"class":207,"line":3170},107,[3172],{"type":32,"tag":205,"props":3173,"children":3174},{"style":275},[3175],{"type":45,"value":867},{"type":32,"tag":33,"props":3177,"children":3178},{},[3179],{"type":45,"value":3180},"The repository requires Cloudflare’s Vector Index and AI bindings in its constructor. We will resolve these from Cloudflare’s environment in the queue handler later.",{"type":32,"tag":33,"props":3182,"children":3183},{},[3184],{"type":45,"value":3185},"The upsert locations method takes a list of locations from our database, builds text embeddings for each location in batches of 10, maps them to vector objects with the index metadata, and then upserts the vector objects to the vector store.",{"type":32,"tag":33,"props":3187,"children":3188},{},[3189],{"type":45,"value":3190},"I’m intentionally excluding unit and integration tests from this demo application for brevity. Before we can test this repository end-to-end, we need to set up our Cloudflare Queue.",{"type":32,"tag":134,"props":3192,"children":3194},{"id":3193},"how-to-dispatch-and-handle-cloudflare-queues-in-nuxt",[3195],{"type":45,"value":3196},"How to dispatch and handle Cloudflare Queues in Nuxt",{"type":32,"tag":33,"props":3198,"children":3199},{},[3200],{"type":45,"value":3201},"Queues allow us to process tasks in the background, which is essential for decoupling long-running operations from user requests. Like most queue services, Cloudflare Queues includes features such as batching and retries.",{"type":32,"tag":33,"props":3203,"children":3204},{},[3205],{"type":45,"value":3206},"In our Nuxt application, we will implement this in two parts:",{"type":32,"tag":82,"props":3208,"children":3209},{},[3210,3215],{"type":32,"tag":86,"props":3211,"children":3212},{},[3213],{"type":45,"value":3214},"The Producer (Nitro Task): We will dispatch messages containing just the Location ID from our database. To be efficient, we will use sendBatch to dispatch up to ten IDs at a time.",{"type":32,"tag":86,"props":3216,"children":3217},{},[3218],{"type":45,"value":3219},"The Consumer (Nitro Plugin): We will listen for these messages within the same Nuxt application (running as a Cloudflare Worker) using a Nitro plugin to process the data.",{"type":32,"tag":3221,"props":3222,"children":3224},"h3",{"id":3223},"create-a-cloudflare-queue-and-bind-the-producer-and-consumer-to-the-same-nuxt-application",[3225],{"type":45,"value":3226},"Create a Cloudflare Queue and bind the producer and consumer to the same Nuxt application",{"type":32,"tag":601,"props":3228,"children":3229},{},[3230],{"type":32,"tag":33,"props":3231,"children":3232},{},[3233],{"type":45,"value":3234},"⚠️ Cloudflare Queues are only available on paid Worker Plans. Currently at $5 per month, plus extra usage charges.",{"type":32,"tag":33,"props":3236,"children":3237},{},[3238],{"type":45,"value":3239},"We can create the vector sync queue using Wrangler CLI:",{"type":32,"tag":194,"props":3241,"children":3243},{"className":196,"code":3242,"language":198,"meta":199,"style":199},"npx wrangler queues create vector-sync-queue\n",[3244],{"type":32,"tag":159,"props":3245,"children":3246},{"__ignoreMap":199},[3247],{"type":32,"tag":205,"props":3248,"children":3249},{"class":207,"line":208},[3250,3254,3258,3263,3267],{"type":32,"tag":205,"props":3251,"children":3252},{"style":212},[3253],{"type":45,"value":215},{"type":32,"tag":205,"props":3255,"children":3256},{"style":218},[3257],{"type":45,"value":221},{"type":32,"tag":205,"props":3259,"children":3260},{"style":218},[3261],{"type":45,"value":3262}," queues",{"type":32,"tag":205,"props":3264,"children":3265},{"style":218},[3266],{"type":45,"value":231},{"type":32,"tag":205,"props":3268,"children":3269},{"style":218},[3270],{"type":45,"value":3271}," vector-sync-queue\n",{"type":32,"tag":33,"props":3273,"children":3274},{},[3275,3277,3282],{"type":45,"value":3276},"And add the bindings in ",{"type":32,"tag":159,"props":3278,"children":3280},{"className":3279},[],[3281],{"type":45,"value":258},{"type":45,"value":3283}," similar to:",{"type":32,"tag":194,"props":3285,"children":3287},{"className":263,"code":3286,"language":265,"meta":199,"style":199},"[[queues.producers]]\nqueue = \"vector-sync-queue\"\nbinding = \"VECTOR_SYNC_QUEUE\"\n\n[[queues.consumers]]\nqueue = \"vector-sync-queue\"\nmax_batch_size = 10    # Recommended: Process 10 vectors at a time\nmax_batch_timeout = 5  # Wait up to 5s to fill a batch\n",[3288],{"type":32,"tag":159,"props":3289,"children":3290},{"__ignoreMap":199},[3291,3299,3312,3324,3331,3339,3350,3368],{"type":32,"tag":205,"props":3292,"children":3293},{"class":207,"line":208},[3294],{"type":32,"tag":205,"props":3295,"children":3296},{"style":275},[3297],{"type":45,"value":3298},"[[queues.producers]]\n",{"type":32,"tag":205,"props":3300,"children":3301},{"class":207,"line":281},[3302,3307],{"type":32,"tag":205,"props":3303,"children":3304},{"style":275},[3305],{"type":45,"value":3306},"queue = ",{"type":32,"tag":205,"props":3308,"children":3309},{"style":218},[3310],{"type":45,"value":3311},"\"vector-sync-queue\"\n",{"type":32,"tag":205,"props":3313,"children":3314},{"class":207,"line":295},[3315,3319],{"type":32,"tag":205,"props":3316,"children":3317},{"style":275},[3318],{"type":45,"value":287},{"type":32,"tag":205,"props":3320,"children":3321},{"style":218},[3322],{"type":45,"value":3323},"\"VECTOR_SYNC_QUEUE\"\n",{"type":32,"tag":205,"props":3325,"children":3326},{"class":207,"line":509},[3327],{"type":32,"tag":205,"props":3328,"children":3329},{"emptyLinePlaceholder":675},[3330],{"type":45,"value":678},{"type":32,"tag":205,"props":3332,"children":3333},{"class":207,"line":523},[3334],{"type":32,"tag":205,"props":3335,"children":3336},{"style":275},[3337],{"type":45,"value":3338},"[[queues.consumers]]\n",{"type":32,"tag":205,"props":3340,"children":3341},{"class":207,"line":537},[3342,3346],{"type":32,"tag":205,"props":3343,"children":3344},{"style":275},[3345],{"type":45,"value":3306},{"type":32,"tag":205,"props":3347,"children":3348},{"style":218},[3349],{"type":45,"value":3311},{"type":32,"tag":205,"props":3351,"children":3352},{"class":207,"line":730},[3353,3358,3363],{"type":32,"tag":205,"props":3354,"children":3355},{"style":275},[3356],{"type":45,"value":3357},"max_batch_size = ",{"type":32,"tag":205,"props":3359,"children":3360},{"style":239},[3361],{"type":45,"value":3362},"10",{"type":32,"tag":205,"props":3364,"children":3365},{"style":716},[3366],{"type":45,"value":3367},"    # Recommended: Process 10 vectors at a time\n",{"type":32,"tag":205,"props":3369,"children":3370},{"class":207,"line":739},[3371,3376,3381],{"type":32,"tag":205,"props":3372,"children":3373},{"style":275},[3374],{"type":45,"value":3375},"max_batch_timeout = ",{"type":32,"tag":205,"props":3377,"children":3378},{"style":239},[3379],{"type":45,"value":3380},"5",{"type":32,"tag":205,"props":3382,"children":3383},{"style":716},[3384],{"type":45,"value":3385},"  # Wait up to 5s to fill a batch\n",{"type":32,"tag":33,"props":3387,"children":3388},{},[3389],{"type":45,"value":3390},"Once you build and deploy, Cloudflare automatically configures your Nuxt Worker to act as the consumer for this queue.",{"type":32,"tag":3221,"props":3392,"children":3394},{"id":3393},"dispatch-to-a-cloudflare-queue-from-a-nuxt-application-through-a-nitro-task",[3395],{"type":45,"value":3396},"Dispatch to a Cloudflare Queue from a Nuxt application through a Nitro Task",{"type":32,"tag":33,"props":3398,"children":3399},{},[3400,3402,3408],{"type":45,"value":3401},"Next, we will write a Nitro Task that dispatches messages to our newly created queue. If you’re not following along from the ",{"type":32,"tag":48,"props":3403,"children":3405},{"href":3404},"/blog/nuxt-and-cloudflare-vectorize-setting-up-d1-drizzle-and-workers-ai/#drizzle-db-schema-on-cloudflare-d1",[3406],{"type":45,"value":3407},"previous article",{"type":45,"value":3409},", make sure you add Nitro’s experimental tasks and async context to Nuxt’s config:",{"type":32,"tag":194,"props":3411,"children":3413},{"className":639,"code":3412,"language":641,"meta":199,"style":199}," nitro: {\n\n    preset: 'cloudflare_module',\n\n    experimental: {\n      tasks: true,\n      asyncContext: true,\n    },\n  },\n",[3414],{"type":32,"tag":159,"props":3415,"children":3416},{"__ignoreMap":199},[3417,3425,3432,3449,3456,3464,3481,3497,3505],{"type":32,"tag":205,"props":3418,"children":3419},{"class":207,"line":208},[3420],{"type":32,"tag":205,"props":3421,"children":3422},{"style":275},[3423],{"type":45,"value":3424}," nitro: {\n",{"type":32,"tag":205,"props":3426,"children":3427},{"class":207,"line":281},[3428],{"type":32,"tag":205,"props":3429,"children":3430},{"emptyLinePlaceholder":675},[3431],{"type":45,"value":678},{"type":32,"tag":205,"props":3433,"children":3434},{"class":207,"line":295},[3435,3440,3445],{"type":32,"tag":205,"props":3436,"children":3437},{"style":275},[3438],{"type":45,"value":3439},"    preset: ",{"type":32,"tag":205,"props":3441,"children":3442},{"style":218},[3443],{"type":45,"value":3444},"'cloudflare_module'",{"type":32,"tag":205,"props":3446,"children":3447},{"style":275},[3448],{"type":45,"value":1385},{"type":32,"tag":205,"props":3450,"children":3451},{"class":207,"line":509},[3452],{"type":32,"tag":205,"props":3453,"children":3454},{"emptyLinePlaceholder":675},[3455],{"type":45,"value":678},{"type":32,"tag":205,"props":3457,"children":3458},{"class":207,"line":523},[3459],{"type":32,"tag":205,"props":3460,"children":3461},{"style":275},[3462],{"type":45,"value":3463},"    experimental: {\n",{"type":32,"tag":205,"props":3465,"children":3466},{"class":207,"line":537},[3467,3472,3477],{"type":32,"tag":205,"props":3468,"children":3469},{"style":275},[3470],{"type":45,"value":3471},"      tasks: ",{"type":32,"tag":205,"props":3473,"children":3474},{"style":239},[3475],{"type":45,"value":3476},"true",{"type":32,"tag":205,"props":3478,"children":3479},{"style":275},[3480],{"type":45,"value":1385},{"type":32,"tag":205,"props":3482,"children":3483},{"class":207,"line":730},[3484,3489,3493],{"type":32,"tag":205,"props":3485,"children":3486},{"style":275},[3487],{"type":45,"value":3488},"      asyncContext: ",{"type":32,"tag":205,"props":3490,"children":3491},{"style":239},[3492],{"type":45,"value":3476},{"type":32,"tag":205,"props":3494,"children":3495},{"style":275},[3496],{"type":45,"value":1385},{"type":32,"tag":205,"props":3498,"children":3499},{"class":207,"line":739},[3500],{"type":32,"tag":205,"props":3501,"children":3502},{"style":275},[3503],{"type":45,"value":3504},"    },\n",{"type":32,"tag":205,"props":3506,"children":3507},{"class":207,"line":763},[3508],{"type":32,"tag":205,"props":3509,"children":3510},{"style":275},[3511],{"type":45,"value":3512},"  },\n",{"type":32,"tag":33,"props":3514,"children":3515},{},[3516,3518,3524],{"type":45,"value":3517},"Let’s first add some types in ",{"type":32,"tag":159,"props":3519,"children":3521},{"className":3520},[],[3522],{"type":45,"value":3523},"/server/types/queues.ts",{"type":45,"value":260},{"type":32,"tag":194,"props":3526,"children":3528},{"className":639,"code":3527,"language":641,"meta":199,"style":199},"import type {\n  Ai,\n  Queue,\n  VectorizeIndex,\n  D1Database,\n  ExecutionContext,\n} from '@cloudflare/workers-types'\n\nexport interface CloudflareEnv {\n  AI: Ai;\n  VECTORIZE: VectorizeIndex;\n  VECTOR_SYNC_QUEUE: Queue;\n  DB: D1Database\n\n  [key: string]: unknown;\n}\n\nexport interface VectorSyncQueueMessageBody {\n  locationId: string;\n}\n\nexport interface CloudflareTaskContext {\n  cloudflare: {\n    env: CloudflareEnv;\n    context: ExecutionContext;\n  };\n}\n\n",[3529],{"type":32,"tag":159,"props":3530,"children":3531},{"__ignoreMap":199},[3532,3547,3555,3563,3571,3579,3587,3602,3609,3629,3649,3669,3690,3707,3714,3735,3742,3749,3769,3789,3796,3803,3823,3839,3859,3880,3888],{"type":32,"tag":205,"props":3533,"children":3534},{"class":207,"line":208},[3535,3539,3543],{"type":32,"tag":205,"props":3536,"children":3537},{"style":651},[3538],{"type":45,"value":654},{"type":32,"tag":205,"props":3540,"children":3541},{"style":651},[3542],{"type":45,"value":954},{"type":32,"tag":205,"props":3544,"children":3545},{"style":275},[3546],{"type":45,"value":703},{"type":32,"tag":205,"props":3548,"children":3549},{"class":207,"line":281},[3550],{"type":32,"tag":205,"props":3551,"children":3552},{"style":275},[3553],{"type":45,"value":3554},"  Ai,\n",{"type":32,"tag":205,"props":3556,"children":3557},{"class":207,"line":295},[3558],{"type":32,"tag":205,"props":3559,"children":3560},{"style":275},[3561],{"type":45,"value":3562},"  Queue,\n",{"type":32,"tag":205,"props":3564,"children":3565},{"class":207,"line":509},[3566],{"type":32,"tag":205,"props":3567,"children":3568},{"style":275},[3569],{"type":45,"value":3570},"  VectorizeIndex,\n",{"type":32,"tag":205,"props":3572,"children":3573},{"class":207,"line":523},[3574],{"type":32,"tag":205,"props":3575,"children":3576},{"style":275},[3577],{"type":45,"value":3578},"  D1Database,\n",{"type":32,"tag":205,"props":3580,"children":3581},{"class":207,"line":537},[3582],{"type":32,"tag":205,"props":3583,"children":3584},{"style":275},[3585],{"type":45,"value":3586},"  ExecutionContext,\n",{"type":32,"tag":205,"props":3588,"children":3589},{"class":207,"line":730},[3590,3594,3598],{"type":32,"tag":205,"props":3591,"children":3592},{"style":275},[3593],{"type":45,"value":1222},{"type":32,"tag":205,"props":3595,"children":3596},{"style":651},[3597],{"type":45,"value":664},{"type":32,"tag":205,"props":3599,"children":3600},{"style":218},[3601],{"type":45,"value":1275},{"type":32,"tag":205,"props":3603,"children":3604},{"class":207,"line":739},[3605],{"type":32,"tag":205,"props":3606,"children":3607},{"emptyLinePlaceholder":675},[3608],{"type":45,"value":678},{"type":32,"tag":205,"props":3610,"children":3611},{"class":207,"line":763},[3612,3616,3620,3625],{"type":32,"tag":205,"props":3613,"children":3614},{"style":651},[3615],{"type":45,"value":686},{"type":32,"tag":205,"props":3617,"children":3618},{"style":689},[3619],{"type":45,"value":692},{"type":32,"tag":205,"props":3621,"children":3622},{"style":695},[3623],{"type":45,"value":3624}," CloudflareEnv",{"type":32,"tag":205,"props":3626,"children":3627},{"style":275},[3628],{"type":45,"value":703},{"type":32,"tag":205,"props":3630,"children":3631},{"class":207,"line":781},[3632,3637,3641,3645],{"type":32,"tag":205,"props":3633,"children":3634},{"style":275},[3635],{"type":45,"value":3636},"  AI",{"type":32,"tag":205,"props":3638,"children":3639},{"style":651},[3640],{"type":45,"value":260},{"type":32,"tag":205,"props":3642,"children":3643},{"style":695},[3644],{"type":45,"value":1410},{"type":32,"tag":205,"props":3646,"children":3647},{"style":275},[3648],{"type":45,"value":935},{"type":32,"tag":205,"props":3650,"children":3651},{"class":207,"line":790},[3652,3657,3661,3665],{"type":32,"tag":205,"props":3653,"children":3654},{"style":275},[3655],{"type":45,"value":3656},"  VECTORIZE",{"type":32,"tag":205,"props":3658,"children":3659},{"style":651},[3660],{"type":45,"value":260},{"type":32,"tag":205,"props":3662,"children":3663},{"style":695},[3664],{"type":45,"value":1380},{"type":32,"tag":205,"props":3666,"children":3667},{"style":275},[3668],{"type":45,"value":935},{"type":32,"tag":205,"props":3670,"children":3671},{"class":207,"line":804},[3672,3677,3681,3686],{"type":32,"tag":205,"props":3673,"children":3674},{"style":275},[3675],{"type":45,"value":3676},"  VECTOR_SYNC_QUEUE",{"type":32,"tag":205,"props":3678,"children":3679},{"style":651},[3680],{"type":45,"value":260},{"type":32,"tag":205,"props":3682,"children":3683},{"style":695},[3684],{"type":45,"value":3685}," Queue",{"type":32,"tag":205,"props":3687,"children":3688},{"style":275},[3689],{"type":45,"value":935},{"type":32,"tag":205,"props":3691,"children":3692},{"class":207,"line":828},[3693,3698,3702],{"type":32,"tag":205,"props":3694,"children":3695},{"style":275},[3696],{"type":45,"value":3697},"  DB",{"type":32,"tag":205,"props":3699,"children":3700},{"style":651},[3701],{"type":45,"value":260},{"type":32,"tag":205,"props":3703,"children":3704},{"style":695},[3705],{"type":45,"value":3706}," D1Database\n",{"type":32,"tag":205,"props":3708,"children":3709},{"class":207,"line":861},[3710],{"type":32,"tag":205,"props":3711,"children":3712},{"emptyLinePlaceholder":675},[3713],{"type":45,"value":678},{"type":32,"tag":205,"props":3715,"children":3716},{"class":207,"line":1432},[3717,3722,3726,3731],{"type":32,"tag":205,"props":3718,"children":3719},{"style":275},[3720],{"type":45,"value":3721},"  [key: string]",{"type":32,"tag":205,"props":3723,"children":3724},{"style":651},[3725],{"type":45,"value":260},{"type":32,"tag":205,"props":3727,"children":3728},{"style":689},[3729],{"type":45,"value":3730}," unknown",{"type":32,"tag":205,"props":3732,"children":3733},{"style":275},[3734],{"type":45,"value":935},{"type":32,"tag":205,"props":3736,"children":3737},{"class":207,"line":1456},[3738],{"type":32,"tag":205,"props":3739,"children":3740},{"style":275},[3741],{"type":45,"value":867},{"type":32,"tag":205,"props":3743,"children":3744},{"class":207,"line":1480},[3745],{"type":32,"tag":205,"props":3746,"children":3747},{"emptyLinePlaceholder":675},[3748],{"type":45,"value":678},{"type":32,"tag":205,"props":3750,"children":3751},{"class":207,"line":1494},[3752,3756,3760,3765],{"type":32,"tag":205,"props":3753,"children":3754},{"style":651},[3755],{"type":45,"value":686},{"type":32,"tag":205,"props":3757,"children":3758},{"style":689},[3759],{"type":45,"value":692},{"type":32,"tag":205,"props":3761,"children":3762},{"style":695},[3763],{"type":45,"value":3764}," VectorSyncQueueMessageBody",{"type":32,"tag":205,"props":3766,"children":3767},{"style":275},[3768],{"type":45,"value":703},{"type":32,"tag":205,"props":3770,"children":3771},{"class":207,"line":1503},[3772,3777,3781,3785],{"type":32,"tag":205,"props":3773,"children":3774},{"style":275},[3775],{"type":45,"value":3776},"  locationId",{"type":32,"tag":205,"props":3778,"children":3779},{"style":651},[3780],{"type":45,"value":260},{"type":32,"tag":205,"props":3782,"children":3783},{"style":689},[3784],{"type":45,"value":2708},{"type":32,"tag":205,"props":3786,"children":3787},{"style":275},[3788],{"type":45,"value":935},{"type":32,"tag":205,"props":3790,"children":3791},{"class":207,"line":1511},[3792],{"type":32,"tag":205,"props":3793,"children":3794},{"style":275},[3795],{"type":45,"value":867},{"type":32,"tag":205,"props":3797,"children":3798},{"class":207,"line":1532},[3799],{"type":32,"tag":205,"props":3800,"children":3801},{"emptyLinePlaceholder":675},[3802],{"type":45,"value":678},{"type":32,"tag":205,"props":3804,"children":3805},{"class":207,"line":1562},[3806,3810,3814,3819],{"type":32,"tag":205,"props":3807,"children":3808},{"style":651},[3809],{"type":45,"value":686},{"type":32,"tag":205,"props":3811,"children":3812},{"style":689},[3813],{"type":45,"value":692},{"type":32,"tag":205,"props":3815,"children":3816},{"style":695},[3817],{"type":45,"value":3818}," CloudflareTaskContext",{"type":32,"tag":205,"props":3820,"children":3821},{"style":275},[3822],{"type":45,"value":703},{"type":32,"tag":205,"props":3824,"children":3825},{"class":207,"line":1570},[3826,3831,3835],{"type":32,"tag":205,"props":3827,"children":3828},{"style":275},[3829],{"type":45,"value":3830},"  cloudflare",{"type":32,"tag":205,"props":3832,"children":3833},{"style":651},[3834],{"type":45,"value":260},{"type":32,"tag":205,"props":3836,"children":3837},{"style":275},[3838],{"type":45,"value":703},{"type":32,"tag":205,"props":3840,"children":3841},{"class":207,"line":1579},[3842,3847,3851,3855],{"type":32,"tag":205,"props":3843,"children":3844},{"style":275},[3845],{"type":45,"value":3846},"    env",{"type":32,"tag":205,"props":3848,"children":3849},{"style":651},[3850],{"type":45,"value":260},{"type":32,"tag":205,"props":3852,"children":3853},{"style":695},[3854],{"type":45,"value":3624},{"type":32,"tag":205,"props":3856,"children":3857},{"style":275},[3858],{"type":45,"value":935},{"type":32,"tag":205,"props":3860,"children":3861},{"class":207,"line":1587},[3862,3867,3871,3876],{"type":32,"tag":205,"props":3863,"children":3864},{"style":275},[3865],{"type":45,"value":3866},"    context",{"type":32,"tag":205,"props":3868,"children":3869},{"style":651},[3870],{"type":45,"value":260},{"type":32,"tag":205,"props":3872,"children":3873},{"style":695},[3874],{"type":45,"value":3875}," ExecutionContext",{"type":32,"tag":205,"props":3877,"children":3878},{"style":275},[3879],{"type":45,"value":935},{"type":32,"tag":205,"props":3881,"children":3882},{"class":207,"line":1595},[3883],{"type":32,"tag":205,"props":3884,"children":3885},{"style":275},[3886],{"type":45,"value":3887},"  };\n",{"type":32,"tag":205,"props":3889,"children":3890},{"class":207,"line":1604},[3891],{"type":32,"tag":205,"props":3892,"children":3893},{"style":275},[3894],{"type":45,"value":867},{"type":32,"tag":33,"props":3896,"children":3897},{},[3898,3900,3906],{"type":45,"value":3899},"And create ",{"type":32,"tag":159,"props":3901,"children":3903},{"className":3902},[],[3904],{"type":45,"value":3905},"/server/tasks/build-location-embeddings.ts",{"type":45,"value":636},{"type":32,"tag":194,"props":3908,"children":3910},{"className":639,"code":3909,"language":641,"meta":199,"style":199},"import { drizzle } from 'drizzle-orm/d1'\nimport * as schema from '~~/server/database/schema'\nimport type { D1Database, Queue } from '@cloudflare/workers-types'\nimport { CloudflareTaskContext } from '~~/server/types/queues'\n\nexport default defineTask({\n  meta: {\n    name: 'build-location-embeddings',\n    description: 'Queues all location IDs for vector embedding',\n  },\n  async run(event) {\n    const context = event.context as CloudflareTaskContext\n    const env = context.cloudflare?.env\n\n    if (!env?.DB) {\n      return { error: 'DB binding not found.' }\n    }\n    const db = drizzle(env.DB as D1Database, { schema })\n\n    // Queue Init\n    const queue = env.VECTOR_SYNC_QUEUE as Queue\n    if (!queue) {\n      return { error: 'Queue binding (VECTOR_SYNC_QUEUE) not found.' }\n    }\n\n    try {\n      const allLocations = await db.query.locations.findMany({\n        columns: { id: true },\n      })\n\n      if (allLocations.length === 0) return { result: 'No locations found in DB.' }\n\n      const total = allLocations.length\n      console.log(`[Task] Found ${total} locations. Dispatching to queue...`)\n\n      const messages = allLocations.map((location) => ({\n        body: { locationId: location.id },\n      }))\n\n      const CHUNK_SIZE = 10\n      for (let i = 0; i \u003C messages.length; i += CHUNK_SIZE) {\n        const batch = messages.slice(i, i + CHUNK_SIZE)\n        await queue.sendBatch(batch)\n      }\n\n      return {\n        result: `Dispatched ${total} locations to VECTOR_SYNC_QUEUE.`,\n      }\n    } catch (error: any) {\n      console.error('[Task] Error during queue dispatch:', error)\n      return { error: error.message || 'Unknown error occurred.' }\n    }\n  },\n})\n\n",[3911],{"type":32,"tag":159,"props":3912,"children":3913},{"__ignoreMap":199},[3914,3935,3963,3987,4008,4015,4037,4045,4062,4079,4086,4111,4141,4162,4169,4189,4211,4218,4258,4265,4273,4303,4323,4343,4350,4357,4369,4403,4420,4428,4435,4478,4485,4506,4549,4556,4602,4610,4618,4625,4645,4695,4732,4755,4762,4769,4780,4814,4821,4854,4879,4905,4912,4919],{"type":32,"tag":205,"props":3915,"children":3916},{"class":207,"line":208},[3917,3921,3926,3930],{"type":32,"tag":205,"props":3918,"children":3919},{"style":651},[3920],{"type":45,"value":654},{"type":32,"tag":205,"props":3922,"children":3923},{"style":275},[3924],{"type":45,"value":3925}," { drizzle } ",{"type":32,"tag":205,"props":3927,"children":3928},{"style":651},[3929],{"type":45,"value":664},{"type":32,"tag":205,"props":3931,"children":3932},{"style":218},[3933],{"type":45,"value":3934}," 'drizzle-orm/d1'\n",{"type":32,"tag":205,"props":3936,"children":3937},{"class":207,"line":281},[3938,3942,3946,3950,3954,3958],{"type":32,"tag":205,"props":3939,"children":3940},{"style":651},[3941],{"type":45,"value":654},{"type":32,"tag":205,"props":3943,"children":3944},{"style":239},[3945],{"type":45,"value":911},{"type":32,"tag":205,"props":3947,"children":3948},{"style":651},[3949],{"type":45,"value":916},{"type":32,"tag":205,"props":3951,"children":3952},{"style":275},[3953],{"type":45,"value":921},{"type":32,"tag":205,"props":3955,"children":3956},{"style":651},[3957],{"type":45,"value":664},{"type":32,"tag":205,"props":3959,"children":3960},{"style":218},[3961],{"type":45,"value":3962}," '~~/server/database/schema'\n",{"type":32,"tag":205,"props":3964,"children":3965},{"class":207,"line":295},[3966,3970,3974,3979,3983],{"type":32,"tag":205,"props":3967,"children":3968},{"style":651},[3969],{"type":45,"value":654},{"type":32,"tag":205,"props":3971,"children":3972},{"style":651},[3973],{"type":45,"value":954},{"type":32,"tag":205,"props":3975,"children":3976},{"style":275},[3977],{"type":45,"value":3978}," { D1Database, Queue } ",{"type":32,"tag":205,"props":3980,"children":3981},{"style":651},[3982],{"type":45,"value":664},{"type":32,"tag":205,"props":3984,"children":3985},{"style":218},[3986],{"type":45,"value":1275},{"type":32,"tag":205,"props":3988,"children":3989},{"class":207,"line":509},[3990,3994,3999,4003],{"type":32,"tag":205,"props":3991,"children":3992},{"style":651},[3993],{"type":45,"value":654},{"type":32,"tag":205,"props":3995,"children":3996},{"style":275},[3997],{"type":45,"value":3998}," { CloudflareTaskContext } ",{"type":32,"tag":205,"props":4000,"children":4001},{"style":651},[4002],{"type":45,"value":664},{"type":32,"tag":205,"props":4004,"children":4005},{"style":218},[4006],{"type":45,"value":4007}," '~~/server/types/queues'\n",{"type":32,"tag":205,"props":4009,"children":4010},{"class":207,"line":523},[4011],{"type":32,"tag":205,"props":4012,"children":4013},{"emptyLinePlaceholder":675},[4014],{"type":45,"value":678},{"type":32,"tag":205,"props":4016,"children":4017},{"class":207,"line":537},[4018,4022,4027,4032],{"type":32,"tag":205,"props":4019,"children":4020},{"style":651},[4021],{"type":45,"value":686},{"type":32,"tag":205,"props":4023,"children":4024},{"style":651},[4025],{"type":45,"value":4026}," default",{"type":32,"tag":205,"props":4028,"children":4029},{"style":212},[4030],{"type":45,"value":4031}," defineTask",{"type":32,"tag":205,"props":4033,"children":4034},{"style":275},[4035],{"type":45,"value":4036},"({\n",{"type":32,"tag":205,"props":4038,"children":4039},{"class":207,"line":730},[4040],{"type":32,"tag":205,"props":4041,"children":4042},{"style":275},[4043],{"type":45,"value":4044},"  meta: {\n",{"type":32,"tag":205,"props":4046,"children":4047},{"class":207,"line":739},[4048,4053,4058],{"type":32,"tag":205,"props":4049,"children":4050},{"style":275},[4051],{"type":45,"value":4052},"    name: ",{"type":32,"tag":205,"props":4054,"children":4055},{"style":218},[4056],{"type":45,"value":4057},"'build-location-embeddings'",{"type":32,"tag":205,"props":4059,"children":4060},{"style":275},[4061],{"type":45,"value":1385},{"type":32,"tag":205,"props":4063,"children":4064},{"class":207,"line":763},[4065,4070,4075],{"type":32,"tag":205,"props":4066,"children":4067},{"style":275},[4068],{"type":45,"value":4069},"    description: ",{"type":32,"tag":205,"props":4071,"children":4072},{"style":218},[4073],{"type":45,"value":4074},"'Queues all location IDs for vector embedding'",{"type":32,"tag":205,"props":4076,"children":4077},{"style":275},[4078],{"type":45,"value":1385},{"type":32,"tag":205,"props":4080,"children":4081},{"class":207,"line":781},[4082],{"type":32,"tag":205,"props":4083,"children":4084},{"style":275},[4085],{"type":45,"value":3512},{"type":32,"tag":205,"props":4087,"children":4088},{"class":207,"line":790},[4089,4094,4098,4102,4107],{"type":32,"tag":205,"props":4090,"children":4091},{"style":651},[4092],{"type":45,"value":4093},"  async",{"type":32,"tag":205,"props":4095,"children":4096},{"style":212},[4097],{"type":45,"value":399},{"type":32,"tag":205,"props":4099,"children":4100},{"style":275},[4101],{"type":45,"value":1550},{"type":32,"tag":205,"props":4103,"children":4104},{"style":808},[4105],{"type":45,"value":4106},"event",{"type":32,"tag":205,"props":4108,"children":4109},{"style":275},[4110],{"type":45,"value":1732},{"type":32,"tag":205,"props":4112,"children":4113},{"class":207,"line":804},[4114,4118,4123,4127,4132,4136],{"type":32,"tag":205,"props":4115,"children":4116},{"style":689},[4117],{"type":45,"value":1771},{"type":32,"tag":205,"props":4119,"children":4120},{"style":275},[4121],{"type":45,"value":4122}," context ",{"type":32,"tag":205,"props":4124,"children":4125},{"style":651},[4126],{"type":45,"value":1781},{"type":32,"tag":205,"props":4128,"children":4129},{"style":275},[4130],{"type":45,"value":4131}," event.context ",{"type":32,"tag":205,"props":4133,"children":4134},{"style":651},[4135],{"type":45,"value":2841},{"type":32,"tag":205,"props":4137,"children":4138},{"style":695},[4139],{"type":45,"value":4140}," CloudflareTaskContext\n",{"type":32,"tag":205,"props":4142,"children":4143},{"class":207,"line":828},[4144,4148,4153,4157],{"type":32,"tag":205,"props":4145,"children":4146},{"style":689},[4147],{"type":45,"value":1771},{"type":32,"tag":205,"props":4149,"children":4150},{"style":275},[4151],{"type":45,"value":4152}," env ",{"type":32,"tag":205,"props":4154,"children":4155},{"style":651},[4156],{"type":45,"value":1781},{"type":32,"tag":205,"props":4158,"children":4159},{"style":275},[4160],{"type":45,"value":4161}," context.cloudflare?.env\n",{"type":32,"tag":205,"props":4163,"children":4164},{"class":207,"line":861},[4165],{"type":32,"tag":205,"props":4166,"children":4167},{"emptyLinePlaceholder":675},[4168],{"type":45,"value":678},{"type":32,"tag":205,"props":4170,"children":4171},{"class":207,"line":1432},[4172,4176,4180,4184],{"type":32,"tag":205,"props":4173,"children":4174},{"style":651},[4175],{"type":45,"value":1438},{"type":32,"tag":205,"props":4177,"children":4178},{"style":275},[4179],{"type":45,"value":1443},{"type":32,"tag":205,"props":4181,"children":4182},{"style":651},[4183],{"type":45,"value":1448},{"type":32,"tag":205,"props":4185,"children":4186},{"style":275},[4187],{"type":45,"value":4188},"env?.DB) {\n",{"type":32,"tag":205,"props":4190,"children":4191},{"class":207,"line":1456},[4192,4196,4201,4206],{"type":32,"tag":205,"props":4193,"children":4194},{"style":651},[4195],{"type":45,"value":1741},{"type":32,"tag":205,"props":4197,"children":4198},{"style":275},[4199],{"type":45,"value":4200}," { error: ",{"type":32,"tag":205,"props":4202,"children":4203},{"style":218},[4204],{"type":45,"value":4205},"'DB binding not found.'",{"type":32,"tag":205,"props":4207,"children":4208},{"style":275},[4209],{"type":45,"value":4210}," }\n",{"type":32,"tag":205,"props":4212,"children":4213},{"class":207,"line":1480},[4214],{"type":32,"tag":205,"props":4215,"children":4216},{"style":275},[4217],{"type":45,"value":1500},{"type":32,"tag":205,"props":4219,"children":4220},{"class":207,"line":1494},[4221,4225,4230,4234,4239,4244,4248,4253],{"type":32,"tag":205,"props":4222,"children":4223},{"style":689},[4224],{"type":45,"value":1771},{"type":32,"tag":205,"props":4226,"children":4227},{"style":275},[4228],{"type":45,"value":4229}," db ",{"type":32,"tag":205,"props":4231,"children":4232},{"style":651},[4233],{"type":45,"value":1781},{"type":32,"tag":205,"props":4235,"children":4236},{"style":212},[4237],{"type":45,"value":4238}," drizzle",{"type":32,"tag":205,"props":4240,"children":4241},{"style":275},[4242],{"type":45,"value":4243},"(env.DB ",{"type":32,"tag":205,"props":4245,"children":4246},{"style":651},[4247],{"type":45,"value":2841},{"type":32,"tag":205,"props":4249,"children":4250},{"style":695},[4251],{"type":45,"value":4252}," D1Database",{"type":32,"tag":205,"props":4254,"children":4255},{"style":275},[4256],{"type":45,"value":4257},", { schema })\n",{"type":32,"tag":205,"props":4259,"children":4260},{"class":207,"line":1503},[4261],{"type":32,"tag":205,"props":4262,"children":4263},{"emptyLinePlaceholder":675},[4264],{"type":45,"value":678},{"type":32,"tag":205,"props":4266,"children":4267},{"class":207,"line":1511},[4268],{"type":32,"tag":205,"props":4269,"children":4270},{"style":716},[4271],{"type":45,"value":4272},"    // Queue Init\n",{"type":32,"tag":205,"props":4274,"children":4275},{"class":207,"line":1532},[4276,4280,4285,4289,4294,4298],{"type":32,"tag":205,"props":4277,"children":4278},{"style":689},[4279],{"type":45,"value":1771},{"type":32,"tag":205,"props":4281,"children":4282},{"style":275},[4283],{"type":45,"value":4284}," queue ",{"type":32,"tag":205,"props":4286,"children":4287},{"style":651},[4288],{"type":45,"value":1781},{"type":32,"tag":205,"props":4290,"children":4291},{"style":275},[4292],{"type":45,"value":4293}," env.VECTOR_SYNC_QUEUE ",{"type":32,"tag":205,"props":4295,"children":4296},{"style":651},[4297],{"type":45,"value":2841},{"type":32,"tag":205,"props":4299,"children":4300},{"style":695},[4301],{"type":45,"value":4302}," Queue\n",{"type":32,"tag":205,"props":4304,"children":4305},{"class":207,"line":1562},[4306,4310,4314,4318],{"type":32,"tag":205,"props":4307,"children":4308},{"style":651},[4309],{"type":45,"value":1438},{"type":32,"tag":205,"props":4311,"children":4312},{"style":275},[4313],{"type":45,"value":1443},{"type":32,"tag":205,"props":4315,"children":4316},{"style":651},[4317],{"type":45,"value":1448},{"type":32,"tag":205,"props":4319,"children":4320},{"style":275},[4321],{"type":45,"value":4322},"queue) {\n",{"type":32,"tag":205,"props":4324,"children":4325},{"class":207,"line":1570},[4326,4330,4334,4339],{"type":32,"tag":205,"props":4327,"children":4328},{"style":651},[4329],{"type":45,"value":1741},{"type":32,"tag":205,"props":4331,"children":4332},{"style":275},[4333],{"type":45,"value":4200},{"type":32,"tag":205,"props":4335,"children":4336},{"style":218},[4337],{"type":45,"value":4338},"'Queue binding (VECTOR_SYNC_QUEUE) not found.'",{"type":32,"tag":205,"props":4340,"children":4341},{"style":275},[4342],{"type":45,"value":4210},{"type":32,"tag":205,"props":4344,"children":4345},{"class":207,"line":1579},[4346],{"type":32,"tag":205,"props":4347,"children":4348},{"style":275},[4349],{"type":45,"value":1500},{"type":32,"tag":205,"props":4351,"children":4352},{"class":207,"line":1587},[4353],{"type":32,"tag":205,"props":4354,"children":4355},{"emptyLinePlaceholder":675},[4356],{"type":45,"value":678},{"type":32,"tag":205,"props":4358,"children":4359},{"class":207,"line":1595},[4360,4365],{"type":32,"tag":205,"props":4361,"children":4362},{"style":651},[4363],{"type":45,"value":4364},"    try",{"type":32,"tag":205,"props":4366,"children":4367},{"style":275},[4368],{"type":45,"value":703},{"type":32,"tag":205,"props":4370,"children":4371},{"class":207,"line":1604},[4372,4376,4381,4385,4389,4394,4399],{"type":32,"tag":205,"props":4373,"children":4374},{"style":689},[4375],{"type":45,"value":1880},{"type":32,"tag":205,"props":4377,"children":4378},{"style":275},[4379],{"type":45,"value":4380}," allLocations ",{"type":32,"tag":205,"props":4382,"children":4383},{"style":651},[4384],{"type":45,"value":1781},{"type":32,"tag":205,"props":4386,"children":4387},{"style":651},[4388],{"type":45,"value":2046},{"type":32,"tag":205,"props":4390,"children":4391},{"style":275},[4392],{"type":45,"value":4393}," db.query.locations.",{"type":32,"tag":205,"props":4395,"children":4396},{"style":212},[4397],{"type":45,"value":4398},"findMany",{"type":32,"tag":205,"props":4400,"children":4401},{"style":275},[4402],{"type":45,"value":4036},{"type":32,"tag":205,"props":4404,"children":4405},{"class":207,"line":1612},[4406,4411,4415],{"type":32,"tag":205,"props":4407,"children":4408},{"style":275},[4409],{"type":45,"value":4410},"        columns: { id: ",{"type":32,"tag":205,"props":4412,"children":4413},{"style":239},[4414],{"type":45,"value":3476},{"type":32,"tag":205,"props":4416,"children":4417},{"style":275},[4418],{"type":45,"value":4419}," },\n",{"type":32,"tag":205,"props":4421,"children":4422},{"class":207,"line":1629},[4423],{"type":32,"tag":205,"props":4424,"children":4425},{"style":275},[4426],{"type":45,"value":4427},"      })\n",{"type":32,"tag":205,"props":4429,"children":4430},{"class":207,"line":1637},[4431],{"type":32,"tag":205,"props":4432,"children":4433},{"emptyLinePlaceholder":675},[4434],{"type":45,"value":678},{"type":32,"tag":205,"props":4436,"children":4437},{"class":207,"line":1699},[4438,4443,4448,4452,4456,4460,4464,4469,4474],{"type":32,"tag":205,"props":4439,"children":4440},{"style":651},[4441],{"type":45,"value":4442},"      if",{"type":32,"tag":205,"props":4444,"children":4445},{"style":275},[4446],{"type":45,"value":4447}," (allLocations.length ",{"type":32,"tag":205,"props":4449,"children":4450},{"style":651},[4451],{"type":45,"value":1722},{"type":32,"tag":205,"props":4453,"children":4454},{"style":239},[4455],{"type":45,"value":1727},{"type":32,"tag":205,"props":4457,"children":4458},{"style":275},[4459],{"type":45,"value":1978},{"type":32,"tag":205,"props":4461,"children":4462},{"style":651},[4463],{"type":45,"value":2179},{"type":32,"tag":205,"props":4465,"children":4466},{"style":275},[4467],{"type":45,"value":4468}," { result: ",{"type":32,"tag":205,"props":4470,"children":4471},{"style":218},[4472],{"type":45,"value":4473},"'No locations found in DB.'",{"type":32,"tag":205,"props":4475,"children":4476},{"style":275},[4477],{"type":45,"value":4210},{"type":32,"tag":205,"props":4479,"children":4480},{"class":207,"line":1707},[4481],{"type":32,"tag":205,"props":4482,"children":4483},{"emptyLinePlaceholder":675},[4484],{"type":45,"value":678},{"type":32,"tag":205,"props":4486,"children":4487},{"class":207,"line":1735},[4488,4492,4497,4501],{"type":32,"tag":205,"props":4489,"children":4490},{"style":689},[4491],{"type":45,"value":1880},{"type":32,"tag":205,"props":4493,"children":4494},{"style":275},[4495],{"type":45,"value":4496}," total ",{"type":32,"tag":205,"props":4498,"children":4499},{"style":651},[4500],{"type":45,"value":1781},{"type":32,"tag":205,"props":4502,"children":4503},{"style":275},[4504],{"type":45,"value":4505}," allLocations.length\n",{"type":32,"tag":205,"props":4507,"children":4508},{"class":207,"line":1749},[4509,4514,4518,4522,4527,4531,4536,4540,4545],{"type":32,"tag":205,"props":4510,"children":4511},{"style":275},[4512],{"type":45,"value":4513},"      console.",{"type":32,"tag":205,"props":4515,"children":4516},{"style":212},[4517],{"type":45,"value":2424},{"type":32,"tag":205,"props":4519,"children":4520},{"style":275},[4521],{"type":45,"value":1550},{"type":32,"tag":205,"props":4523,"children":4524},{"style":218},[4525],{"type":45,"value":4526},"`[Task] Found ",{"type":32,"tag":205,"props":4528,"children":4529},{"style":651},[4530],{"type":45,"value":2526},{"type":32,"tag":205,"props":4532,"children":4533},{"style":275},[4534],{"type":45,"value":4535},"total",{"type":32,"tag":205,"props":4537,"children":4538},{"style":651},[4539],{"type":45,"value":2536},{"type":32,"tag":205,"props":4541,"children":4542},{"style":218},[4543],{"type":45,"value":4544}," locations. Dispatching to queue...`",{"type":32,"tag":205,"props":4546,"children":4547},{"style":275},[4548],{"type":45,"value":1491},{"type":32,"tag":205,"props":4550,"children":4551},{"class":207,"line":1757},[4552],{"type":32,"tag":205,"props":4553,"children":4554},{"emptyLinePlaceholder":675},[4555],{"type":45,"value":678},{"type":32,"tag":205,"props":4557,"children":4558},{"class":207,"line":1765},[4559,4563,4568,4572,4577,4581,4585,4589,4593,4597],{"type":32,"tag":205,"props":4560,"children":4561},{"style":689},[4562],{"type":45,"value":1880},{"type":32,"tag":205,"props":4564,"children":4565},{"style":275},[4566],{"type":45,"value":4567}," messages ",{"type":32,"tag":205,"props":4569,"children":4570},{"style":651},[4571],{"type":45,"value":1781},{"type":32,"tag":205,"props":4573,"children":4574},{"style":275},[4575],{"type":45,"value":4576}," allLocations.",{"type":32,"tag":205,"props":4578,"children":4579},{"style":212},[4580],{"type":45,"value":1963},{"type":32,"tag":205,"props":4582,"children":4583},{"style":275},[4584],{"type":45,"value":1968},{"type":32,"tag":205,"props":4586,"children":4587},{"style":808},[4588],{"type":45,"value":1973},{"type":32,"tag":205,"props":4590,"children":4591},{"style":275},[4592],{"type":45,"value":1978},{"type":32,"tag":205,"props":4594,"children":4595},{"style":689},[4596],{"type":45,"value":2125},{"type":32,"tag":205,"props":4598,"children":4599},{"style":275},[4600],{"type":45,"value":4601}," ({\n",{"type":32,"tag":205,"props":4603,"children":4604},{"class":207,"line":1789},[4605],{"type":32,"tag":205,"props":4606,"children":4607},{"style":275},[4608],{"type":45,"value":4609},"        body: { locationId: location.id },\n",{"type":32,"tag":205,"props":4611,"children":4612},{"class":207,"line":1811},[4613],{"type":32,"tag":205,"props":4614,"children":4615},{"style":275},[4616],{"type":45,"value":4617},"      }))\n",{"type":32,"tag":205,"props":4619,"children":4620},{"class":207,"line":1819},[4621],{"type":32,"tag":205,"props":4622,"children":4623},{"emptyLinePlaceholder":675},[4624],{"type":45,"value":678},{"type":32,"tag":205,"props":4626,"children":4627},{"class":207,"line":1874},[4628,4632,4637,4641],{"type":32,"tag":205,"props":4629,"children":4630},{"style":689},[4631],{"type":45,"value":1880},{"type":32,"tag":205,"props":4633,"children":4634},{"style":275},[4635],{"type":45,"value":4636}," CHUNK_SIZE ",{"type":32,"tag":205,"props":4638,"children":4639},{"style":651},[4640],{"type":45,"value":1781},{"type":32,"tag":205,"props":4642,"children":4643},{"style":239},[4644],{"type":45,"value":1786},{"type":32,"tag":205,"props":4646,"children":4647},{"class":207,"line":1917},[4648,4653,4657,4661,4665,4669,4673,4677,4681,4686,4690],{"type":32,"tag":205,"props":4649,"children":4650},{"style":651},[4651],{"type":45,"value":4652},"      for",{"type":32,"tag":205,"props":4654,"children":4655},{"style":275},[4656],{"type":45,"value":1443},{"type":32,"tag":205,"props":4658,"children":4659},{"style":689},[4660],{"type":45,"value":1834},{"type":32,"tag":205,"props":4662,"children":4663},{"style":275},[4664],{"type":45,"value":1839},{"type":32,"tag":205,"props":4666,"children":4667},{"style":651},[4668],{"type":45,"value":1781},{"type":32,"tag":205,"props":4670,"children":4671},{"style":239},[4672],{"type":45,"value":1727},{"type":32,"tag":205,"props":4674,"children":4675},{"style":275},[4676],{"type":45,"value":1852},{"type":32,"tag":205,"props":4678,"children":4679},{"style":651},[4680],{"type":45,"value":848},{"type":32,"tag":205,"props":4682,"children":4683},{"style":275},[4684],{"type":45,"value":4685}," messages.length; i ",{"type":32,"tag":205,"props":4687,"children":4688},{"style":651},[4689],{"type":45,"value":1866},{"type":32,"tag":205,"props":4691,"children":4692},{"style":275},[4693],{"type":45,"value":4694}," CHUNK_SIZE) {\n",{"type":32,"tag":205,"props":4696,"children":4697},{"class":207,"line":1925},[4698,4702,4706,4710,4715,4719,4723,4727],{"type":32,"tag":205,"props":4699,"children":4700},{"style":689},[4701],{"type":45,"value":1944},{"type":32,"tag":205,"props":4703,"children":4704},{"style":275},[4705],{"type":45,"value":1885},{"type":32,"tag":205,"props":4707,"children":4708},{"style":651},[4709],{"type":45,"value":1781},{"type":32,"tag":205,"props":4711,"children":4712},{"style":275},[4713],{"type":45,"value":4714}," messages.",{"type":32,"tag":205,"props":4716,"children":4717},{"style":212},[4718],{"type":45,"value":1899},{"type":32,"tag":205,"props":4720,"children":4721},{"style":275},[4722],{"type":45,"value":1904},{"type":32,"tag":205,"props":4724,"children":4725},{"style":651},[4726],{"type":45,"value":1909},{"type":32,"tag":205,"props":4728,"children":4729},{"style":275},[4730],{"type":45,"value":4731}," CHUNK_SIZE)\n",{"type":32,"tag":205,"props":4733,"children":4734},{"class":207,"line":1938},[4735,4740,4745,4750],{"type":32,"tag":205,"props":4736,"children":4737},{"style":651},[4738],{"type":45,"value":4739},"        await",{"type":32,"tag":205,"props":4741,"children":4742},{"style":275},[4743],{"type":45,"value":4744}," queue.",{"type":32,"tag":205,"props":4746,"children":4747},{"style":212},[4748],{"type":45,"value":4749},"sendBatch",{"type":32,"tag":205,"props":4751,"children":4752},{"style":275},[4753],{"type":45,"value":4754},"(batch)\n",{"type":32,"tag":205,"props":4756,"children":4757},{"class":207,"line":1986},[4758],{"type":32,"tag":205,"props":4759,"children":4760},{"style":275},[4761],{"type":45,"value":2571},{"type":32,"tag":205,"props":4763,"children":4764},{"class":207,"line":2010},[4765],{"type":32,"tag":205,"props":4766,"children":4767},{"emptyLinePlaceholder":675},[4768],{"type":45,"value":678},{"type":32,"tag":205,"props":4770,"children":4771},{"class":207,"line":2019},[4772,4776],{"type":32,"tag":205,"props":4773,"children":4774},{"style":651},[4775],{"type":45,"value":1741},{"type":32,"tag":205,"props":4777,"children":4778},{"style":275},[4779],{"type":45,"value":703},{"type":32,"tag":205,"props":4781,"children":4782},{"class":207,"line":2027},[4783,4788,4793,4797,4801,4805,4810],{"type":32,"tag":205,"props":4784,"children":4785},{"style":275},[4786],{"type":45,"value":4787},"        result: ",{"type":32,"tag":205,"props":4789,"children":4790},{"style":218},[4791],{"type":45,"value":4792},"`Dispatched ",{"type":32,"tag":205,"props":4794,"children":4795},{"style":651},[4796],{"type":45,"value":2526},{"type":32,"tag":205,"props":4798,"children":4799},{"style":275},[4800],{"type":45,"value":4535},{"type":32,"tag":205,"props":4802,"children":4803},{"style":651},[4804],{"type":45,"value":2536},{"type":32,"tag":205,"props":4806,"children":4807},{"style":218},[4808],{"type":45,"value":4809}," locations to VECTOR_SYNC_QUEUE.`",{"type":32,"tag":205,"props":4811,"children":4812},{"style":275},[4813],{"type":45,"value":1385},{"type":32,"tag":205,"props":4815,"children":4816},{"class":207,"line":2068},[4817],{"type":32,"tag":205,"props":4818,"children":4819},{"style":275},[4820],{"type":45,"value":2571},{"type":32,"tag":205,"props":4822,"children":4823},{"class":207,"line":2076},[4824,4829,4833,4837,4841,4845,4850],{"type":32,"tag":205,"props":4825,"children":4826},{"style":275},[4827],{"type":45,"value":4828},"    } ",{"type":32,"tag":205,"props":4830,"children":4831},{"style":651},[4832],{"type":45,"value":2489},{"type":32,"tag":205,"props":4834,"children":4835},{"style":275},[4836],{"type":45,"value":1443},{"type":32,"tag":205,"props":4838,"children":4839},{"style":808},[4840],{"type":45,"value":2508},{"type":32,"tag":205,"props":4842,"children":4843},{"style":651},[4844],{"type":45,"value":260},{"type":32,"tag":205,"props":4846,"children":4847},{"style":689},[4848],{"type":45,"value":4849}," any",{"type":32,"tag":205,"props":4851,"children":4852},{"style":275},[4853],{"type":45,"value":1732},{"type":32,"tag":205,"props":4855,"children":4856},{"class":207,"line":2132},[4857,4861,4865,4869,4874],{"type":32,"tag":205,"props":4858,"children":4859},{"style":275},[4860],{"type":45,"value":4513},{"type":32,"tag":205,"props":4862,"children":4863},{"style":212},[4864],{"type":45,"value":2508},{"type":32,"tag":205,"props":4866,"children":4867},{"style":275},[4868],{"type":45,"value":1550},{"type":32,"tag":205,"props":4870,"children":4871},{"style":218},[4872],{"type":45,"value":4873},"'[Task] Error during queue dispatch:'",{"type":32,"tag":205,"props":4875,"children":4876},{"style":275},[4877],{"type":45,"value":4878},", error)\n",{"type":32,"tag":205,"props":4880,"children":4881},{"class":207,"line":2155},[4882,4886,4891,4896,4901],{"type":32,"tag":205,"props":4883,"children":4884},{"style":651},[4885],{"type":45,"value":1741},{"type":32,"tag":205,"props":4887,"children":4888},{"style":275},[4889],{"type":45,"value":4890}," { error: error.message ",{"type":32,"tag":205,"props":4892,"children":4893},{"style":651},[4894],{"type":45,"value":4895},"||",{"type":32,"tag":205,"props":4897,"children":4898},{"style":218},[4899],{"type":45,"value":4900}," 'Unknown error occurred.'",{"type":32,"tag":205,"props":4902,"children":4903},{"style":275},[4904],{"type":45,"value":4210},{"type":32,"tag":205,"props":4906,"children":4907},{"class":207,"line":2187},[4908],{"type":32,"tag":205,"props":4909,"children":4910},{"style":275},[4911],{"type":45,"value":1500},{"type":32,"tag":205,"props":4913,"children":4914},{"class":207,"line":2200},[4915],{"type":32,"tag":205,"props":4916,"children":4917},{"style":275},[4918],{"type":45,"value":3512},{"type":32,"tag":205,"props":4920,"children":4921},{"class":207,"line":2209},[4922],{"type":32,"tag":205,"props":4923,"children":4924},{"style":275},[4925],{"type":45,"value":4926},"})\n",{"type":32,"tag":33,"props":4928,"children":4929},{},[4930],{"type":45,"value":4931},"Now that the dispatcher is done. We can trigger the Nitro task from CLI, DevTools, CRON, or programmatically. Since Cloudflare’s Workers AI runs on remote infrastructure, we will build an API endpoint that triggers the Nitro task programmatically after we implement the listener and handler.",{"type":32,"tag":601,"props":4933,"children":4934},{},[4935],{"type":32,"tag":33,"props":4936,"children":4937},{},[4938,4940,4946],{"type":45,"value":4939},"💡There are several ways you can safely test Cloudflare’s AI without touching the production environment. You can create bindings specific to a staging environment and also use the ",{"type":32,"tag":159,"props":4941,"children":4943},{"className":4942},[],[4944],{"type":45,"value":4945},"getPlatformProxy()",{"type":45,"value":4947}," wrangler function in tests.",{"type":32,"tag":610,"props":4949,"children":4953},{":sub-link":612,"button-text":4950,"link":614,"sub-link-text":615,"text":4951,"title":4952},"Discuss your architecture","Building distributed systems on Cloudflare is powerful, but easy to mess up. I help teams architect resilient workflows that scale without the headaches.","Facing complex Nuxt decisions?",[],{"type":32,"tag":3221,"props":4955,"children":4957},{"id":4956},"listen-and-handle-cloudflare-queue-messages-from-a-nuxt-application-using-a-nitro-plugin",[4958],{"type":45,"value":4959},"Listen and handle Cloudflare Queue messages from a Nuxt application using a Nitro Plugin",{"type":32,"tag":33,"props":4961,"children":4962},{},[4963,4965,4970],{"type":45,"value":4964},"With the queue dispatcher completed, we now need a Nitro Plugin to listen to the dispatched queue and handle it. In the ",{"type":32,"tag":48,"props":4966,"children":4967},{"href":112},[4968],{"type":45,"value":4969},"next part of this article series",{"type":45,"value":4971},", we will use another queue to synchronise the Agents’ listings. To avoid a massive queue handler class, we will split the listener and handler code.",{"type":32,"tag":33,"props":4973,"children":4974},{},[4975,4977,4982],{"type":45,"value":4976},"The following is the handler that depends on the ",{"type":32,"tag":159,"props":4978,"children":4980},{"className":4979},[],[4981],{"type":45,"value":1174},{"type":45,"value":4983}," interface we declared earlier.",{"type":32,"tag":33,"props":4985,"children":4986},{},[4987,4989,4995],{"type":45,"value":4988},"Create the handler in ",{"type":32,"tag":159,"props":4990,"children":4992},{"className":4991},[],[4993],{"type":45,"value":4994},"/server/utils/queueHandlers/VectorSyncQueueHandler.ts",{"type":45,"value":636},{"type":32,"tag":194,"props":4997,"children":4999},{"className":639,"code":4998,"language":641,"meta":199,"style":199},"import {\n  LocationVectorRepository,\n} from '~~/server/utils/queueHandlers/repositories/LocationVectorRepository'\nimport { Location } from '~~/server/database/types'\nimport * as schema from '~~/server/database/schema'\nimport { drizzle } from 'drizzle-orm/d1'\nimport { inArray } from 'drizzle-orm'\nimport type { D1Database, MessageBatch } from '@cloudflare/workers-types'\nimport type {\n  VectorSyncQueueMessageBody,\n  CloudflareEnv,\n} from '~~/server/types/queues'\n\nexport class VectorSyncQueueHandler {\n\n  constructor (\n    private readonly locationVectorRepository: LocationVectorRepository,\n  ) {}\n\n  public async handle (\n    batch: MessageBatch\u003CVectorSyncQueueMessageBody>,\n    env: CloudflareEnv,\n  ): Promise\u003Cvoid> {\n\n    const messages = batch.messages\n    const db = drizzle(env.DB as D1Database, { schema })\n\n    // Extract Unique IDs\n    const locationIds = new Set\u003Cstring>()\n    for (const message of messages) {\n      if (message.body?.locationId) {\n        locationIds.add(message.body.locationId)\n      }\n    }\n\n    if (locationIds.size === 0) {\n      console.log('[Vector Sync Handler] No valid locationIds found in batch.')\n      return\n    }\n\n    try {\n      const ids = Array.from(locationIds)\n\n      // Fetch Data\n      const locationsToUpsert: Location[] = await db.query.locations.findMany({\n        where: inArray(schema.locations.id, ids),\n      })\n\n      if (locationsToUpsert.length > 0) {\n        // Update Vector Index\n        await this.locationVectorRepository.upsertLocations(locationsToUpsert)\n        console.log(\n          `[Vector Sync Handler] Successfully processed ${locationsToUpsert.length} locations.`)\n      }\n\n    } catch (error: any) {\n      console.error('[Vector Sync Handler] Error:', error.message)\n      // Throwing error triggers Cloudflare's automatic queue retry logic\n      throw error\n    }\n  }\n}\n\n",[5000],{"type":32,"tag":159,"props":5001,"children":5002},{"__ignoreMap":199},[5003,5014,5021,5036,5055,5082,5101,5122,5146,5161,5169,5177,5192,5199,5219,5226,5237,5265,5273,5280,5300,5331,5350,5378,5385,5405,5440,5447,5455,5494,5525,5537,5555,5562,5569,5576,5600,5624,5632,5639,5646,5657,5687,5694,5702,5747,5765,5772,5779,5803,5811,5837,5852,5882,5889,5896,5927,5952,5960,5972,5979,5986],{"type":32,"tag":205,"props":5004,"children":5005},{"class":207,"line":208},[5006,5010],{"type":32,"tag":205,"props":5007,"children":5008},{"style":651},[5009],{"type":45,"value":654},{"type":32,"tag":205,"props":5011,"children":5012},{"style":275},[5013],{"type":45,"value":703},{"type":32,"tag":205,"props":5015,"children":5016},{"class":207,"line":281},[5017],{"type":32,"tag":205,"props":5018,"children":5019},{"style":275},[5020],{"type":45,"value":1214},{"type":32,"tag":205,"props":5022,"children":5023},{"class":207,"line":295},[5024,5028,5032],{"type":32,"tag":205,"props":5025,"children":5026},{"style":275},[5027],{"type":45,"value":1222},{"type":32,"tag":205,"props":5029,"children":5030},{"style":651},[5031],{"type":45,"value":664},{"type":32,"tag":205,"props":5033,"children":5034},{"style":218},[5035],{"type":45,"value":1231},{"type":32,"tag":205,"props":5037,"children":5038},{"class":207,"line":509},[5039,5043,5047,5051],{"type":32,"tag":205,"props":5040,"children":5041},{"style":651},[5042],{"type":45,"value":654},{"type":32,"tag":205,"props":5044,"children":5045},{"style":275},[5046],{"type":45,"value":659},{"type":32,"tag":205,"props":5048,"children":5049},{"style":651},[5050],{"type":45,"value":664},{"type":32,"tag":205,"props":5052,"children":5053},{"style":218},[5054],{"type":45,"value":669},{"type":32,"tag":205,"props":5056,"children":5057},{"class":207,"line":523},[5058,5062,5066,5070,5074,5078],{"type":32,"tag":205,"props":5059,"children":5060},{"style":651},[5061],{"type":45,"value":654},{"type":32,"tag":205,"props":5063,"children":5064},{"style":239},[5065],{"type":45,"value":911},{"type":32,"tag":205,"props":5067,"children":5068},{"style":651},[5069],{"type":45,"value":916},{"type":32,"tag":205,"props":5071,"children":5072},{"style":275},[5073],{"type":45,"value":921},{"type":32,"tag":205,"props":5075,"children":5076},{"style":651},[5077],{"type":45,"value":664},{"type":32,"tag":205,"props":5079,"children":5080},{"style":218},[5081],{"type":45,"value":3962},{"type":32,"tag":205,"props":5083,"children":5084},{"class":207,"line":537},[5085,5089,5093,5097],{"type":32,"tag":205,"props":5086,"children":5087},{"style":651},[5088],{"type":45,"value":654},{"type":32,"tag":205,"props":5090,"children":5091},{"style":275},[5092],{"type":45,"value":3925},{"type":32,"tag":205,"props":5094,"children":5095},{"style":651},[5096],{"type":45,"value":664},{"type":32,"tag":205,"props":5098,"children":5099},{"style":218},[5100],{"type":45,"value":3934},{"type":32,"tag":205,"props":5102,"children":5103},{"class":207,"line":730},[5104,5108,5113,5117],{"type":32,"tag":205,"props":5105,"children":5106},{"style":651},[5107],{"type":45,"value":654},{"type":32,"tag":205,"props":5109,"children":5110},{"style":275},[5111],{"type":45,"value":5112}," { inArray } ",{"type":32,"tag":205,"props":5114,"children":5115},{"style":651},[5116],{"type":45,"value":664},{"type":32,"tag":205,"props":5118,"children":5119},{"style":218},[5120],{"type":45,"value":5121}," 'drizzle-orm'\n",{"type":32,"tag":205,"props":5123,"children":5124},{"class":207,"line":739},[5125,5129,5133,5138,5142],{"type":32,"tag":205,"props":5126,"children":5127},{"style":651},[5128],{"type":45,"value":654},{"type":32,"tag":205,"props":5130,"children":5131},{"style":651},[5132],{"type":45,"value":954},{"type":32,"tag":205,"props":5134,"children":5135},{"style":275},[5136],{"type":45,"value":5137}," { D1Database, MessageBatch } ",{"type":32,"tag":205,"props":5139,"children":5140},{"style":651},[5141],{"type":45,"value":664},{"type":32,"tag":205,"props":5143,"children":5144},{"style":218},[5145],{"type":45,"value":1275},{"type":32,"tag":205,"props":5147,"children":5148},{"class":207,"line":763},[5149,5153,5157],{"type":32,"tag":205,"props":5150,"children":5151},{"style":651},[5152],{"type":45,"value":654},{"type":32,"tag":205,"props":5154,"children":5155},{"style":651},[5156],{"type":45,"value":954},{"type":32,"tag":205,"props":5158,"children":5159},{"style":275},[5160],{"type":45,"value":703},{"type":32,"tag":205,"props":5162,"children":5163},{"class":207,"line":781},[5164],{"type":32,"tag":205,"props":5165,"children":5166},{"style":275},[5167],{"type":45,"value":5168},"  VectorSyncQueueMessageBody,\n",{"type":32,"tag":205,"props":5170,"children":5171},{"class":207,"line":790},[5172],{"type":32,"tag":205,"props":5173,"children":5174},{"style":275},[5175],{"type":45,"value":5176},"  CloudflareEnv,\n",{"type":32,"tag":205,"props":5178,"children":5179},{"class":207,"line":804},[5180,5184,5188],{"type":32,"tag":205,"props":5181,"children":5182},{"style":275},[5183],{"type":45,"value":1222},{"type":32,"tag":205,"props":5185,"children":5186},{"style":651},[5187],{"type":45,"value":664},{"type":32,"tag":205,"props":5189,"children":5190},{"style":218},[5191],{"type":45,"value":4007},{"type":32,"tag":205,"props":5193,"children":5194},{"class":207,"line":828},[5195],{"type":32,"tag":205,"props":5196,"children":5197},{"emptyLinePlaceholder":675},[5198],{"type":45,"value":678},{"type":32,"tag":205,"props":5200,"children":5201},{"class":207,"line":861},[5202,5206,5210,5215],{"type":32,"tag":205,"props":5203,"children":5204},{"style":651},[5205],{"type":45,"value":686},{"type":32,"tag":205,"props":5207,"children":5208},{"style":689},[5209],{"type":45,"value":1315},{"type":32,"tag":205,"props":5211,"children":5212},{"style":695},[5213],{"type":45,"value":5214}," VectorSyncQueueHandler",{"type":32,"tag":205,"props":5216,"children":5217},{"style":275},[5218],{"type":45,"value":703},{"type":32,"tag":205,"props":5220,"children":5221},{"class":207,"line":1432},[5222],{"type":32,"tag":205,"props":5223,"children":5224},{"emptyLinePlaceholder":675},[5225],{"type":45,"value":678},{"type":32,"tag":205,"props":5227,"children":5228},{"class":207,"line":1456},[5229,5233],{"type":32,"tag":205,"props":5230,"children":5231},{"style":689},[5232],{"type":45,"value":1349},{"type":32,"tag":205,"props":5234,"children":5235},{"style":275},[5236],{"type":45,"value":801},{"type":32,"tag":205,"props":5238,"children":5239},{"class":207,"line":1480},[5240,5244,5248,5253,5257,5261],{"type":32,"tag":205,"props":5241,"children":5242},{"style":651},[5243],{"type":45,"value":1361},{"type":32,"tag":205,"props":5245,"children":5246},{"style":651},[5247],{"type":45,"value":1366},{"type":32,"tag":205,"props":5249,"children":5250},{"style":808},[5251],{"type":45,"value":5252}," locationVectorRepository",{"type":32,"tag":205,"props":5254,"children":5255},{"style":651},[5256],{"type":45,"value":260},{"type":32,"tag":205,"props":5258,"children":5259},{"style":695},[5260],{"type":45,"value":698},{"type":32,"tag":205,"props":5262,"children":5263},{"style":275},[5264],{"type":45,"value":1385},{"type":32,"tag":205,"props":5266,"children":5267},{"class":207,"line":1494},[5268],{"type":32,"tag":205,"props":5269,"children":5270},{"style":275},[5271],{"type":45,"value":5272},"  ) {}\n",{"type":32,"tag":205,"props":5274,"children":5275},{"class":207,"line":1503},[5276],{"type":32,"tag":205,"props":5277,"children":5278},{"emptyLinePlaceholder":675},[5279],{"type":45,"value":678},{"type":32,"tag":205,"props":5281,"children":5282},{"class":207,"line":1511},[5283,5287,5291,5296],{"type":32,"tag":205,"props":5284,"children":5285},{"style":651},[5286],{"type":45,"value":1643},{"type":32,"tag":205,"props":5288,"children":5289},{"style":651},[5290],{"type":45,"value":1648},{"type":32,"tag":205,"props":5292,"children":5293},{"style":212},[5294],{"type":45,"value":5295}," handle",{"type":32,"tag":205,"props":5297,"children":5298},{"style":275},[5299],{"type":45,"value":801},{"type":32,"tag":205,"props":5301,"children":5302},{"class":207,"line":1532},[5303,5308,5312,5317,5321,5326],{"type":32,"tag":205,"props":5304,"children":5305},{"style":808},[5306],{"type":45,"value":5307},"    batch",{"type":32,"tag":205,"props":5309,"children":5310},{"style":651},[5311],{"type":45,"value":260},{"type":32,"tag":205,"props":5313,"children":5314},{"style":695},[5315],{"type":45,"value":5316}," MessageBatch",{"type":32,"tag":205,"props":5318,"children":5319},{"style":275},[5320],{"type":45,"value":848},{"type":32,"tag":205,"props":5322,"children":5323},{"style":695},[5324],{"type":45,"value":5325},"VectorSyncQueueMessageBody",{"type":32,"tag":205,"props":5327,"children":5328},{"style":275},[5329],{"type":45,"value":5330},">,\n",{"type":32,"tag":205,"props":5332,"children":5333},{"class":207,"line":1562},[5334,5338,5342,5346],{"type":32,"tag":205,"props":5335,"children":5336},{"style":808},[5337],{"type":45,"value":3846},{"type":32,"tag":205,"props":5339,"children":5340},{"style":651},[5341],{"type":45,"value":260},{"type":32,"tag":205,"props":5343,"children":5344},{"style":695},[5345],{"type":45,"value":3624},{"type":32,"tag":205,"props":5347,"children":5348},{"style":275},[5349],{"type":45,"value":1385},{"type":32,"tag":205,"props":5351,"children":5352},{"class":207,"line":1570},[5353,5357,5361,5365,5369,5374],{"type":32,"tag":205,"props":5354,"children":5355},{"style":275},[5356],{"type":45,"value":834},{"type":32,"tag":205,"props":5358,"children":5359},{"style":651},[5360],{"type":45,"value":260},{"type":32,"tag":205,"props":5362,"children":5363},{"style":695},[5364],{"type":45,"value":843},{"type":32,"tag":205,"props":5366,"children":5367},{"style":275},[5368],{"type":45,"value":848},{"type":32,"tag":205,"props":5370,"children":5371},{"style":689},[5372],{"type":45,"value":5373},"void",{"type":32,"tag":205,"props":5375,"children":5376},{"style":275},[5377],{"type":45,"value":1696},{"type":32,"tag":205,"props":5379,"children":5380},{"class":207,"line":1579},[5381],{"type":32,"tag":205,"props":5382,"children":5383},{"emptyLinePlaceholder":675},[5384],{"type":45,"value":678},{"type":32,"tag":205,"props":5386,"children":5387},{"class":207,"line":1587},[5388,5392,5396,5400],{"type":32,"tag":205,"props":5389,"children":5390},{"style":689},[5391],{"type":45,"value":1771},{"type":32,"tag":205,"props":5393,"children":5394},{"style":275},[5395],{"type":45,"value":4567},{"type":32,"tag":205,"props":5397,"children":5398},{"style":651},[5399],{"type":45,"value":1781},{"type":32,"tag":205,"props":5401,"children":5402},{"style":275},[5403],{"type":45,"value":5404}," batch.messages\n",{"type":32,"tag":205,"props":5406,"children":5407},{"class":207,"line":1595},[5408,5412,5416,5420,5424,5428,5432,5436],{"type":32,"tag":205,"props":5409,"children":5410},{"style":689},[5411],{"type":45,"value":1771},{"type":32,"tag":205,"props":5413,"children":5414},{"style":275},[5415],{"type":45,"value":4229},{"type":32,"tag":205,"props":5417,"children":5418},{"style":651},[5419],{"type":45,"value":1781},{"type":32,"tag":205,"props":5421,"children":5422},{"style":212},[5423],{"type":45,"value":4238},{"type":32,"tag":205,"props":5425,"children":5426},{"style":275},[5427],{"type":45,"value":4243},{"type":32,"tag":205,"props":5429,"children":5430},{"style":651},[5431],{"type":45,"value":2841},{"type":32,"tag":205,"props":5433,"children":5434},{"style":695},[5435],{"type":45,"value":4252},{"type":32,"tag":205,"props":5437,"children":5438},{"style":275},[5439],{"type":45,"value":4257},{"type":32,"tag":205,"props":5441,"children":5442},{"class":207,"line":1604},[5443],{"type":32,"tag":205,"props":5444,"children":5445},{"emptyLinePlaceholder":675},[5446],{"type":45,"value":678},{"type":32,"tag":205,"props":5448,"children":5449},{"class":207,"line":1612},[5450],{"type":32,"tag":205,"props":5451,"children":5452},{"style":716},[5453],{"type":45,"value":5454},"    // Extract Unique IDs\n",{"type":32,"tag":205,"props":5456,"children":5457},{"class":207,"line":1629},[5458,5462,5467,5471,5475,5480,5484,5489],{"type":32,"tag":205,"props":5459,"children":5460},{"style":689},[5461],{"type":45,"value":1771},{"type":32,"tag":205,"props":5463,"children":5464},{"style":275},[5465],{"type":45,"value":5466}," locationIds ",{"type":32,"tag":205,"props":5468,"children":5469},{"style":651},[5470],{"type":45,"value":1781},{"type":32,"tag":205,"props":5472,"children":5473},{"style":651},[5474],{"type":45,"value":1467},{"type":32,"tag":205,"props":5476,"children":5477},{"style":212},[5478],{"type":45,"value":5479}," Set",{"type":32,"tag":205,"props":5481,"children":5482},{"style":275},[5483],{"type":45,"value":848},{"type":32,"tag":205,"props":5485,"children":5486},{"style":689},[5487],{"type":45,"value":5488},"string",{"type":32,"tag":205,"props":5490,"children":5491},{"style":275},[5492],{"type":45,"value":5493},">()\n",{"type":32,"tag":205,"props":5495,"children":5496},{"class":207,"line":1637},[5497,5501,5505,5510,5515,5520],{"type":32,"tag":205,"props":5498,"children":5499},{"style":651},[5500],{"type":45,"value":1825},{"type":32,"tag":205,"props":5502,"children":5503},{"style":275},[5504],{"type":45,"value":1443},{"type":32,"tag":205,"props":5506,"children":5507},{"style":689},[5508],{"type":45,"value":5509},"const",{"type":32,"tag":205,"props":5511,"children":5512},{"style":275},[5513],{"type":45,"value":5514}," message ",{"type":32,"tag":205,"props":5516,"children":5517},{"style":651},[5518],{"type":45,"value":5519},"of",{"type":32,"tag":205,"props":5521,"children":5522},{"style":275},[5523],{"type":45,"value":5524}," messages) {\n",{"type":32,"tag":205,"props":5526,"children":5527},{"class":207,"line":1699},[5528,5532],{"type":32,"tag":205,"props":5529,"children":5530},{"style":651},[5531],{"type":45,"value":4442},{"type":32,"tag":205,"props":5533,"children":5534},{"style":275},[5535],{"type":45,"value":5536}," (message.body?.locationId) {\n",{"type":32,"tag":205,"props":5538,"children":5539},{"class":207,"line":1707},[5540,5545,5550],{"type":32,"tag":205,"props":5541,"children":5542},{"style":275},[5543],{"type":45,"value":5544},"        locationIds.",{"type":32,"tag":205,"props":5546,"children":5547},{"style":212},[5548],{"type":45,"value":5549},"add",{"type":32,"tag":205,"props":5551,"children":5552},{"style":275},[5553],{"type":45,"value":5554},"(message.body.locationId)\n",{"type":32,"tag":205,"props":5556,"children":5557},{"class":207,"line":1735},[5558],{"type":32,"tag":205,"props":5559,"children":5560},{"style":275},[5561],{"type":45,"value":2571},{"type":32,"tag":205,"props":5563,"children":5564},{"class":207,"line":1749},[5565],{"type":32,"tag":205,"props":5566,"children":5567},{"style":275},[5568],{"type":45,"value":1500},{"type":32,"tag":205,"props":5570,"children":5571},{"class":207,"line":1757},[5572],{"type":32,"tag":205,"props":5573,"children":5574},{"emptyLinePlaceholder":675},[5575],{"type":45,"value":678},{"type":32,"tag":205,"props":5577,"children":5578},{"class":207,"line":1765},[5579,5583,5588,5592,5596],{"type":32,"tag":205,"props":5580,"children":5581},{"style":651},[5582],{"type":45,"value":1438},{"type":32,"tag":205,"props":5584,"children":5585},{"style":275},[5586],{"type":45,"value":5587}," (locationIds.size ",{"type":32,"tag":205,"props":5589,"children":5590},{"style":651},[5591],{"type":45,"value":1722},{"type":32,"tag":205,"props":5593,"children":5594},{"style":239},[5595],{"type":45,"value":1727},{"type":32,"tag":205,"props":5597,"children":5598},{"style":275},[5599],{"type":45,"value":1732},{"type":32,"tag":205,"props":5601,"children":5602},{"class":207,"line":1789},[5603,5607,5611,5615,5620],{"type":32,"tag":205,"props":5604,"children":5605},{"style":275},[5606],{"type":45,"value":4513},{"type":32,"tag":205,"props":5608,"children":5609},{"style":212},[5610],{"type":45,"value":2424},{"type":32,"tag":205,"props":5612,"children":5613},{"style":275},[5614],{"type":45,"value":1550},{"type":32,"tag":205,"props":5616,"children":5617},{"style":218},[5618],{"type":45,"value":5619},"'[Vector Sync Handler] No valid locationIds found in batch.'",{"type":32,"tag":205,"props":5621,"children":5622},{"style":275},[5623],{"type":45,"value":1491},{"type":32,"tag":205,"props":5625,"children":5626},{"class":207,"line":1811},[5627],{"type":32,"tag":205,"props":5628,"children":5629},{"style":651},[5630],{"type":45,"value":5631},"      return\n",{"type":32,"tag":205,"props":5633,"children":5634},{"class":207,"line":1819},[5635],{"type":32,"tag":205,"props":5636,"children":5637},{"style":275},[5638],{"type":45,"value":1500},{"type":32,"tag":205,"props":5640,"children":5641},{"class":207,"line":1874},[5642],{"type":32,"tag":205,"props":5643,"children":5644},{"emptyLinePlaceholder":675},[5645],{"type":45,"value":678},{"type":32,"tag":205,"props":5647,"children":5648},{"class":207,"line":1917},[5649,5653],{"type":32,"tag":205,"props":5650,"children":5651},{"style":651},[5652],{"type":45,"value":4364},{"type":32,"tag":205,"props":5654,"children":5655},{"style":275},[5656],{"type":45,"value":703},{"type":32,"tag":205,"props":5658,"children":5659},{"class":207,"line":1925},[5660,5664,5669,5673,5678,5682],{"type":32,"tag":205,"props":5661,"children":5662},{"style":689},[5663],{"type":45,"value":1880},{"type":32,"tag":205,"props":5665,"children":5666},{"style":275},[5667],{"type":45,"value":5668}," ids ",{"type":32,"tag":205,"props":5670,"children":5671},{"style":651},[5672],{"type":45,"value":1781},{"type":32,"tag":205,"props":5674,"children":5675},{"style":275},[5676],{"type":45,"value":5677}," Array.",{"type":32,"tag":205,"props":5679,"children":5680},{"style":212},[5681],{"type":45,"value":664},{"type":32,"tag":205,"props":5683,"children":5684},{"style":275},[5685],{"type":45,"value":5686},"(locationIds)\n",{"type":32,"tag":205,"props":5688,"children":5689},{"class":207,"line":1938},[5690],{"type":32,"tag":205,"props":5691,"children":5692},{"emptyLinePlaceholder":675},[5693],{"type":45,"value":678},{"type":32,"tag":205,"props":5695,"children":5696},{"class":207,"line":1986},[5697],{"type":32,"tag":205,"props":5698,"children":5699},{"style":716},[5700],{"type":45,"value":5701},"      // Fetch Data\n",{"type":32,"tag":205,"props":5703,"children":5704},{"class":207,"line":2010},[5705,5709,5714,5718,5722,5727,5731,5735,5739,5743],{"type":32,"tag":205,"props":5706,"children":5707},{"style":689},[5708],{"type":45,"value":1880},{"type":32,"tag":205,"props":5710,"children":5711},{"style":275},[5712],{"type":45,"value":5713}," locationsToUpsert",{"type":32,"tag":205,"props":5715,"children":5716},{"style":651},[5717],{"type":45,"value":260},{"type":32,"tag":205,"props":5719,"children":5720},{"style":695},[5721],{"type":45,"value":820},{"type":32,"tag":205,"props":5723,"children":5724},{"style":275},[5725],{"type":45,"value":5726},"[] ",{"type":32,"tag":205,"props":5728,"children":5729},{"style":651},[5730],{"type":45,"value":1781},{"type":32,"tag":205,"props":5732,"children":5733},{"style":651},[5734],{"type":45,"value":2046},{"type":32,"tag":205,"props":5736,"children":5737},{"style":275},[5738],{"type":45,"value":4393},{"type":32,"tag":205,"props":5740,"children":5741},{"style":212},[5742],{"type":45,"value":4398},{"type":32,"tag":205,"props":5744,"children":5745},{"style":275},[5746],{"type":45,"value":4036},{"type":32,"tag":205,"props":5748,"children":5749},{"class":207,"line":2019},[5750,5755,5760],{"type":32,"tag":205,"props":5751,"children":5752},{"style":275},[5753],{"type":45,"value":5754},"        where: ",{"type":32,"tag":205,"props":5756,"children":5757},{"style":212},[5758],{"type":45,"value":5759},"inArray",{"type":32,"tag":205,"props":5761,"children":5762},{"style":275},[5763],{"type":45,"value":5764},"(schema.locations.id, ids),\n",{"type":32,"tag":205,"props":5766,"children":5767},{"class":207,"line":2027},[5768],{"type":32,"tag":205,"props":5769,"children":5770},{"style":275},[5771],{"type":45,"value":4427},{"type":32,"tag":205,"props":5773,"children":5774},{"class":207,"line":2068},[5775],{"type":32,"tag":205,"props":5776,"children":5777},{"emptyLinePlaceholder":675},[5778],{"type":45,"value":678},{"type":32,"tag":205,"props":5780,"children":5781},{"class":207,"line":2076},[5782,5786,5791,5795,5799],{"type":32,"tag":205,"props":5783,"children":5784},{"style":651},[5785],{"type":45,"value":4442},{"type":32,"tag":205,"props":5787,"children":5788},{"style":275},[5789],{"type":45,"value":5790}," (locationsToUpsert.length ",{"type":32,"tag":205,"props":5792,"children":5793},{"style":651},[5794],{"type":45,"value":2362},{"type":32,"tag":205,"props":5796,"children":5797},{"style":239},[5798],{"type":45,"value":1727},{"type":32,"tag":205,"props":5800,"children":5801},{"style":275},[5802],{"type":45,"value":1732},{"type":32,"tag":205,"props":5804,"children":5805},{"class":207,"line":2132},[5806],{"type":32,"tag":205,"props":5807,"children":5808},{"style":716},[5809],{"type":45,"value":5810},"        // Update Vector Index\n",{"type":32,"tag":205,"props":5812,"children":5813},{"class":207,"line":2155},[5814,5818,5822,5827,5832],{"type":32,"tag":205,"props":5815,"children":5816},{"style":651},[5817],{"type":45,"value":4739},{"type":32,"tag":205,"props":5819,"children":5820},{"style":1990},[5821],{"type":45,"value":2051},{"type":32,"tag":205,"props":5823,"children":5824},{"style":275},[5825],{"type":45,"value":5826},".locationVectorRepository.",{"type":32,"tag":205,"props":5828,"children":5829},{"style":212},[5830],{"type":45,"value":5831},"upsertLocations",{"type":32,"tag":205,"props":5833,"children":5834},{"style":275},[5835],{"type":45,"value":5836},"(locationsToUpsert)\n",{"type":32,"tag":205,"props":5838,"children":5839},{"class":207,"line":2187},[5840,5844,5848],{"type":32,"tag":205,"props":5841,"children":5842},{"style":275},[5843],{"type":45,"value":2503},{"type":32,"tag":205,"props":5845,"children":5846},{"style":212},[5847],{"type":45,"value":2424},{"type":32,"tag":205,"props":5849,"children":5850},{"style":275},[5851],{"type":45,"value":1477},{"type":32,"tag":205,"props":5853,"children":5854},{"class":207,"line":2200},[5855,5860,5864,5869,5873,5878],{"type":32,"tag":205,"props":5856,"children":5857},{"style":218},[5858],{"type":45,"value":5859},"          `[Vector Sync Handler] Successfully processed ",{"type":32,"tag":205,"props":5861,"children":5862},{"style":651},[5863],{"type":45,"value":2526},{"type":32,"tag":205,"props":5865,"children":5866},{"style":275},[5867],{"type":45,"value":5868},"locationsToUpsert.length",{"type":32,"tag":205,"props":5870,"children":5871},{"style":651},[5872],{"type":45,"value":2536},{"type":32,"tag":205,"props":5874,"children":5875},{"style":218},[5876],{"type":45,"value":5877}," locations.`",{"type":32,"tag":205,"props":5879,"children":5880},{"style":275},[5881],{"type":45,"value":1491},{"type":32,"tag":205,"props":5883,"children":5884},{"class":207,"line":2209},[5885],{"type":32,"tag":205,"props":5886,"children":5887},{"style":275},[5888],{"type":45,"value":2571},{"type":32,"tag":205,"props":5890,"children":5891},{"class":207,"line":2218},[5892],{"type":32,"tag":205,"props":5893,"children":5894},{"emptyLinePlaceholder":675},[5895],{"type":45,"value":678},{"type":32,"tag":205,"props":5897,"children":5898},{"class":207,"line":2227},[5899,5903,5907,5911,5915,5919,5923],{"type":32,"tag":205,"props":5900,"children":5901},{"style":275},[5902],{"type":45,"value":4828},{"type":32,"tag":205,"props":5904,"children":5905},{"style":651},[5906],{"type":45,"value":2489},{"type":32,"tag":205,"props":5908,"children":5909},{"style":275},[5910],{"type":45,"value":1443},{"type":32,"tag":205,"props":5912,"children":5913},{"style":808},[5914],{"type":45,"value":2508},{"type":32,"tag":205,"props":5916,"children":5917},{"style":651},[5918],{"type":45,"value":260},{"type":32,"tag":205,"props":5920,"children":5921},{"style":689},[5922],{"type":45,"value":4849},{"type":32,"tag":205,"props":5924,"children":5925},{"style":275},[5926],{"type":45,"value":1732},{"type":32,"tag":205,"props":5928,"children":5929},{"class":207,"line":2236},[5930,5934,5938,5942,5947],{"type":32,"tag":205,"props":5931,"children":5932},{"style":275},[5933],{"type":45,"value":4513},{"type":32,"tag":205,"props":5935,"children":5936},{"style":212},[5937],{"type":45,"value":2508},{"type":32,"tag":205,"props":5939,"children":5940},{"style":275},[5941],{"type":45,"value":1550},{"type":32,"tag":205,"props":5943,"children":5944},{"style":218},[5945],{"type":45,"value":5946},"'[Vector Sync Handler] Error:'",{"type":32,"tag":205,"props":5948,"children":5949},{"style":275},[5950],{"type":45,"value":5951},", error.message)\n",{"type":32,"tag":205,"props":5953,"children":5954},{"class":207,"line":2245},[5955],{"type":32,"tag":205,"props":5956,"children":5957},{"style":716},[5958],{"type":45,"value":5959},"      // Throwing error triggers Cloudflare's automatic queue retry logic\n",{"type":32,"tag":205,"props":5961,"children":5962},{"class":207,"line":2254},[5963,5967],{"type":32,"tag":205,"props":5964,"children":5965},{"style":651},[5966],{"type":45,"value":1462},{"type":32,"tag":205,"props":5968,"children":5969},{"style":275},[5970],{"type":45,"value":5971}," error\n",{"type":32,"tag":205,"props":5973,"children":5974},{"class":207,"line":2338},[5975],{"type":32,"tag":205,"props":5976,"children":5977},{"style":275},[5978],{"type":45,"value":1500},{"type":32,"tag":205,"props":5980,"children":5981},{"class":207,"line":2346},[5982],{"type":32,"tag":205,"props":5983,"children":5984},{"style":275},[5985],{"type":45,"value":1576},{"type":32,"tag":205,"props":5987,"children":5988},{"class":207,"line":2373},[5989],{"type":32,"tag":205,"props":5990,"children":5991},{"style":275},[5992],{"type":45,"value":867},{"type":32,"tag":33,"props":5994,"children":5995},{},[5996,5998,6003],{"type":45,"value":5997},"The handler class above loops through the queue messages, retrieves the full location data from our D1 database, and uses the ",{"type":32,"tag":159,"props":5999,"children":6001},{"className":6000},[],[6002],{"type":45,"value":1174},{"type":45,"value":6004}," to upsert the data into the Cloudflare Vectorize store.",{"type":32,"tag":33,"props":6006,"children":6007},{},[6008],{"type":45,"value":6009},"Finally, we need a Nitro Plugin to hook into and thus listen to Cloudflare Queues. The plugin will be the entry point for all dispatched Cloudflare Queues and will delegate the specific handler based on the queue name.",{"type":32,"tag":33,"props":6011,"children":6012},{},[6013,6015,6021],{"type":45,"value":6014},"Create the plugin at ",{"type":32,"tag":159,"props":6016,"children":6018},{"className":6017},[],[6019],{"type":45,"value":6020},"/server/plugins/queue-handler.ts",{"type":45,"value":636},{"type":32,"tag":194,"props":6023,"children":6025},{"className":639,"code":6024,"language":641,"meta":199,"style":199},"import { VectorSyncQueueHandler } from '~~/server/utils/queueHandlers/VectorSyncQueueHandler'\nimport { CloudflareVectorAIRepository } from '~~/server/repositories/cloudflare/CloudflareVectorAIRepository'\nimport type { VectorSyncQueueMessageBody, CloudflareEnv } from '~~/server/types/queues'\nimport type { MessageBatch } from '@cloudflare/workers-types'\n\nexport default defineNitroPlugin((nitroApp) => {\n  nitroApp.hooks.hook('cloudflare:queue', async (payload) => {\n    const batch = payload.batch\n    const env = payload.env as CloudflareEnv\n\n    if (batch.queue === 'vector-sync-queue') {\n      console.log(`[Queue] Received batch of ${batch.messages.length} for ${batch.queue}`)\n\n      try {\n        const repo = new CloudflareVectorAIRepository(env.VECTORIZE, env.AI)\n        const handler = new VectorSyncQueueHandler(repo)\n\n        await handler.handle(\n          batch as MessageBatch\u003CVectorSyncQueueMessageBody>,\n          env\n        )\n\n      } catch (error: any) {\n        console.error('[Queue] Error processing batch:', error)\n        // This will trigger a retry as per the wrangler.toml queue settings\n        throw error\n      }\n    }\n  })\n})\n\n",[6026],{"type":32,"tag":159,"props":6027,"children":6028},{"__ignoreMap":199},[6029,6050,6071,6095,6119,6126,6163,6215,6235,6264,6271,6296,6355,6362,6373,6402,6431,6438,6459,6487,6495,6502,6509,6540,6564,6572,6584,6591,6598,6606],{"type":32,"tag":205,"props":6030,"children":6031},{"class":207,"line":208},[6032,6036,6041,6045],{"type":32,"tag":205,"props":6033,"children":6034},{"style":651},[6035],{"type":45,"value":654},{"type":32,"tag":205,"props":6037,"children":6038},{"style":275},[6039],{"type":45,"value":6040}," { VectorSyncQueueHandler } ",{"type":32,"tag":205,"props":6042,"children":6043},{"style":651},[6044],{"type":45,"value":664},{"type":32,"tag":205,"props":6046,"children":6047},{"style":218},[6048],{"type":45,"value":6049}," '~~/server/utils/queueHandlers/VectorSyncQueueHandler'\n",{"type":32,"tag":205,"props":6051,"children":6052},{"class":207,"line":281},[6053,6057,6062,6066],{"type":32,"tag":205,"props":6054,"children":6055},{"style":651},[6056],{"type":45,"value":654},{"type":32,"tag":205,"props":6058,"children":6059},{"style":275},[6060],{"type":45,"value":6061}," { CloudflareVectorAIRepository } ",{"type":32,"tag":205,"props":6063,"children":6064},{"style":651},[6065],{"type":45,"value":664},{"type":32,"tag":205,"props":6067,"children":6068},{"style":218},[6069],{"type":45,"value":6070}," '~~/server/repositories/cloudflare/CloudflareVectorAIRepository'\n",{"type":32,"tag":205,"props":6072,"children":6073},{"class":207,"line":295},[6074,6078,6082,6087,6091],{"type":32,"tag":205,"props":6075,"children":6076},{"style":651},[6077],{"type":45,"value":654},{"type":32,"tag":205,"props":6079,"children":6080},{"style":651},[6081],{"type":45,"value":954},{"type":32,"tag":205,"props":6083,"children":6084},{"style":275},[6085],{"type":45,"value":6086}," { VectorSyncQueueMessageBody, CloudflareEnv } ",{"type":32,"tag":205,"props":6088,"children":6089},{"style":651},[6090],{"type":45,"value":664},{"type":32,"tag":205,"props":6092,"children":6093},{"style":218},[6094],{"type":45,"value":4007},{"type":32,"tag":205,"props":6096,"children":6097},{"class":207,"line":509},[6098,6102,6106,6111,6115],{"type":32,"tag":205,"props":6099,"children":6100},{"style":651},[6101],{"type":45,"value":654},{"type":32,"tag":205,"props":6103,"children":6104},{"style":651},[6105],{"type":45,"value":954},{"type":32,"tag":205,"props":6107,"children":6108},{"style":275},[6109],{"type":45,"value":6110}," { MessageBatch } ",{"type":32,"tag":205,"props":6112,"children":6113},{"style":651},[6114],{"type":45,"value":664},{"type":32,"tag":205,"props":6116,"children":6117},{"style":218},[6118],{"type":45,"value":1275},{"type":32,"tag":205,"props":6120,"children":6121},{"class":207,"line":523},[6122],{"type":32,"tag":205,"props":6123,"children":6124},{"emptyLinePlaceholder":675},[6125],{"type":45,"value":678},{"type":32,"tag":205,"props":6127,"children":6128},{"class":207,"line":537},[6129,6133,6137,6142,6146,6151,6155,6159],{"type":32,"tag":205,"props":6130,"children":6131},{"style":651},[6132],{"type":45,"value":686},{"type":32,"tag":205,"props":6134,"children":6135},{"style":651},[6136],{"type":45,"value":4026},{"type":32,"tag":205,"props":6138,"children":6139},{"style":212},[6140],{"type":45,"value":6141}," defineNitroPlugin",{"type":32,"tag":205,"props":6143,"children":6144},{"style":275},[6145],{"type":45,"value":1968},{"type":32,"tag":205,"props":6147,"children":6148},{"style":808},[6149],{"type":45,"value":6150},"nitroApp",{"type":32,"tag":205,"props":6152,"children":6153},{"style":275},[6154],{"type":45,"value":1978},{"type":32,"tag":205,"props":6156,"children":6157},{"style":689},[6158],{"type":45,"value":2125},{"type":32,"tag":205,"props":6160,"children":6161},{"style":275},[6162],{"type":45,"value":703},{"type":32,"tag":205,"props":6164,"children":6165},{"class":207,"line":730},[6166,6171,6176,6180,6185,6189,6194,6198,6203,6207,6211],{"type":32,"tag":205,"props":6167,"children":6168},{"style":275},[6169],{"type":45,"value":6170},"  nitroApp.hooks.",{"type":32,"tag":205,"props":6172,"children":6173},{"style":212},[6174],{"type":45,"value":6175},"hook",{"type":32,"tag":205,"props":6177,"children":6178},{"style":275},[6179],{"type":45,"value":1550},{"type":32,"tag":205,"props":6181,"children":6182},{"style":218},[6183],{"type":45,"value":6184},"'cloudflare:queue'",{"type":32,"tag":205,"props":6186,"children":6187},{"style":275},[6188],{"type":45,"value":2111},{"type":32,"tag":205,"props":6190,"children":6191},{"style":651},[6192],{"type":45,"value":6193},"async",{"type":32,"tag":205,"props":6195,"children":6196},{"style":275},[6197],{"type":45,"value":1443},{"type":32,"tag":205,"props":6199,"children":6200},{"style":808},[6201],{"type":45,"value":6202},"payload",{"type":32,"tag":205,"props":6204,"children":6205},{"style":275},[6206],{"type":45,"value":1978},{"type":32,"tag":205,"props":6208,"children":6209},{"style":689},[6210],{"type":45,"value":2125},{"type":32,"tag":205,"props":6212,"children":6213},{"style":275},[6214],{"type":45,"value":703},{"type":32,"tag":205,"props":6216,"children":6217},{"class":207,"line":739},[6218,6222,6226,6230],{"type":32,"tag":205,"props":6219,"children":6220},{"style":689},[6221],{"type":45,"value":1771},{"type":32,"tag":205,"props":6223,"children":6224},{"style":275},[6225],{"type":45,"value":1885},{"type":32,"tag":205,"props":6227,"children":6228},{"style":651},[6229],{"type":45,"value":1781},{"type":32,"tag":205,"props":6231,"children":6232},{"style":275},[6233],{"type":45,"value":6234}," payload.batch\n",{"type":32,"tag":205,"props":6236,"children":6237},{"class":207,"line":763},[6238,6242,6246,6250,6255,6259],{"type":32,"tag":205,"props":6239,"children":6240},{"style":689},[6241],{"type":45,"value":1771},{"type":32,"tag":205,"props":6243,"children":6244},{"style":275},[6245],{"type":45,"value":4152},{"type":32,"tag":205,"props":6247,"children":6248},{"style":651},[6249],{"type":45,"value":1781},{"type":32,"tag":205,"props":6251,"children":6252},{"style":275},[6253],{"type":45,"value":6254}," payload.env ",{"type":32,"tag":205,"props":6256,"children":6257},{"style":651},[6258],{"type":45,"value":2841},{"type":32,"tag":205,"props":6260,"children":6261},{"style":695},[6262],{"type":45,"value":6263}," CloudflareEnv\n",{"type":32,"tag":205,"props":6265,"children":6266},{"class":207,"line":781},[6267],{"type":32,"tag":205,"props":6268,"children":6269},{"emptyLinePlaceholder":675},[6270],{"type":45,"value":678},{"type":32,"tag":205,"props":6272,"children":6273},{"class":207,"line":790},[6274,6278,6283,6287,6292],{"type":32,"tag":205,"props":6275,"children":6276},{"style":651},[6277],{"type":45,"value":1438},{"type":32,"tag":205,"props":6279,"children":6280},{"style":275},[6281],{"type":45,"value":6282}," (batch.queue ",{"type":32,"tag":205,"props":6284,"children":6285},{"style":651},[6286],{"type":45,"value":1722},{"type":32,"tag":205,"props":6288,"children":6289},{"style":218},[6290],{"type":45,"value":6291}," 'vector-sync-queue'",{"type":32,"tag":205,"props":6293,"children":6294},{"style":275},[6295],{"type":45,"value":1732},{"type":32,"tag":205,"props":6297,"children":6298},{"class":207,"line":804},[6299,6303,6307,6311,6316,6320,6325,6329,6334,6338,6343,6347,6351],{"type":32,"tag":205,"props":6300,"children":6301},{"style":275},[6302],{"type":45,"value":4513},{"type":32,"tag":205,"props":6304,"children":6305},{"style":212},[6306],{"type":45,"value":2424},{"type":32,"tag":205,"props":6308,"children":6309},{"style":275},[6310],{"type":45,"value":1550},{"type":32,"tag":205,"props":6312,"children":6313},{"style":218},[6314],{"type":45,"value":6315},"`[Queue] Received batch of ",{"type":32,"tag":205,"props":6317,"children":6318},{"style":651},[6319],{"type":45,"value":2526},{"type":32,"tag":205,"props":6321,"children":6322},{"style":275},[6323],{"type":45,"value":6324},"batch.messages.length",{"type":32,"tag":205,"props":6326,"children":6327},{"style":651},[6328],{"type":45,"value":2536},{"type":32,"tag":205,"props":6330,"children":6331},{"style":218},[6332],{"type":45,"value":6333}," for ",{"type":32,"tag":205,"props":6335,"children":6336},{"style":651},[6337],{"type":45,"value":2526},{"type":32,"tag":205,"props":6339,"children":6340},{"style":275},[6341],{"type":45,"value":6342},"batch.queue",{"type":32,"tag":205,"props":6344,"children":6345},{"style":651},[6346],{"type":45,"value":2536},{"type":32,"tag":205,"props":6348,"children":6349},{"style":218},[6350],{"type":45,"value":2541},{"type":32,"tag":205,"props":6352,"children":6353},{"style":275},[6354],{"type":45,"value":1491},{"type":32,"tag":205,"props":6356,"children":6357},{"class":207,"line":828},[6358],{"type":32,"tag":205,"props":6359,"children":6360},{"emptyLinePlaceholder":675},[6361],{"type":45,"value":678},{"type":32,"tag":205,"props":6363,"children":6364},{"class":207,"line":861},[6365,6369],{"type":32,"tag":205,"props":6366,"children":6367},{"style":651},[6368],{"type":45,"value":1931},{"type":32,"tag":205,"props":6370,"children":6371},{"style":275},[6372],{"type":45,"value":703},{"type":32,"tag":205,"props":6374,"children":6375},{"class":207,"line":1432},[6376,6380,6385,6389,6393,6397],{"type":32,"tag":205,"props":6377,"children":6378},{"style":689},[6379],{"type":45,"value":1944},{"type":32,"tag":205,"props":6381,"children":6382},{"style":275},[6383],{"type":45,"value":6384}," repo ",{"type":32,"tag":205,"props":6386,"children":6387},{"style":651},[6388],{"type":45,"value":1781},{"type":32,"tag":205,"props":6390,"children":6391},{"style":651},[6392],{"type":45,"value":1467},{"type":32,"tag":205,"props":6394,"children":6395},{"style":212},[6396],{"type":45,"value":1320},{"type":32,"tag":205,"props":6398,"children":6399},{"style":275},[6400],{"type":45,"value":6401},"(env.VECTORIZE, env.AI)\n",{"type":32,"tag":205,"props":6403,"children":6404},{"class":207,"line":1456},[6405,6409,6414,6418,6422,6426],{"type":32,"tag":205,"props":6406,"children":6407},{"style":689},[6408],{"type":45,"value":1944},{"type":32,"tag":205,"props":6410,"children":6411},{"style":275},[6412],{"type":45,"value":6413}," handler ",{"type":32,"tag":205,"props":6415,"children":6416},{"style":651},[6417],{"type":45,"value":1781},{"type":32,"tag":205,"props":6419,"children":6420},{"style":651},[6421],{"type":45,"value":1467},{"type":32,"tag":205,"props":6423,"children":6424},{"style":212},[6425],{"type":45,"value":5214},{"type":32,"tag":205,"props":6427,"children":6428},{"style":275},[6429],{"type":45,"value":6430},"(repo)\n",{"type":32,"tag":205,"props":6432,"children":6433},{"class":207,"line":1480},[6434],{"type":32,"tag":205,"props":6435,"children":6436},{"emptyLinePlaceholder":675},[6437],{"type":45,"value":678},{"type":32,"tag":205,"props":6439,"children":6440},{"class":207,"line":1494},[6441,6445,6450,6455],{"type":32,"tag":205,"props":6442,"children":6443},{"style":651},[6444],{"type":45,"value":4739},{"type":32,"tag":205,"props":6446,"children":6447},{"style":275},[6448],{"type":45,"value":6449}," handler.",{"type":32,"tag":205,"props":6451,"children":6452},{"style":212},[6453],{"type":45,"value":6454},"handle",{"type":32,"tag":205,"props":6456,"children":6457},{"style":275},[6458],{"type":45,"value":1477},{"type":32,"tag":205,"props":6460,"children":6461},{"class":207,"line":1503},[6462,6467,6471,6475,6479,6483],{"type":32,"tag":205,"props":6463,"children":6464},{"style":275},[6465],{"type":45,"value":6466},"          batch ",{"type":32,"tag":205,"props":6468,"children":6469},{"style":651},[6470],{"type":45,"value":2841},{"type":32,"tag":205,"props":6472,"children":6473},{"style":695},[6474],{"type":45,"value":5316},{"type":32,"tag":205,"props":6476,"children":6477},{"style":275},[6478],{"type":45,"value":848},{"type":32,"tag":205,"props":6480,"children":6481},{"style":695},[6482],{"type":45,"value":5325},{"type":32,"tag":205,"props":6484,"children":6485},{"style":275},[6486],{"type":45,"value":5330},{"type":32,"tag":205,"props":6488,"children":6489},{"class":207,"line":1511},[6490],{"type":32,"tag":205,"props":6491,"children":6492},{"style":275},[6493],{"type":45,"value":6494},"          env\n",{"type":32,"tag":205,"props":6496,"children":6497},{"class":207,"line":1532},[6498],{"type":32,"tag":205,"props":6499,"children":6500},{"style":275},[6501],{"type":45,"value":2016},{"type":32,"tag":205,"props":6503,"children":6504},{"class":207,"line":1562},[6505],{"type":32,"tag":205,"props":6506,"children":6507},{"emptyLinePlaceholder":675},[6508],{"type":45,"value":678},{"type":32,"tag":205,"props":6510,"children":6511},{"class":207,"line":1570},[6512,6516,6520,6524,6528,6532,6536],{"type":32,"tag":205,"props":6513,"children":6514},{"style":275},[6515],{"type":45,"value":2484},{"type":32,"tag":205,"props":6517,"children":6518},{"style":651},[6519],{"type":45,"value":2489},{"type":32,"tag":205,"props":6521,"children":6522},{"style":275},[6523],{"type":45,"value":1443},{"type":32,"tag":205,"props":6525,"children":6526},{"style":808},[6527],{"type":45,"value":2508},{"type":32,"tag":205,"props":6529,"children":6530},{"style":651},[6531],{"type":45,"value":260},{"type":32,"tag":205,"props":6533,"children":6534},{"style":689},[6535],{"type":45,"value":4849},{"type":32,"tag":205,"props":6537,"children":6538},{"style":275},[6539],{"type":45,"value":1732},{"type":32,"tag":205,"props":6541,"children":6542},{"class":207,"line":1579},[6543,6547,6551,6555,6560],{"type":32,"tag":205,"props":6544,"children":6545},{"style":275},[6546],{"type":45,"value":2503},{"type":32,"tag":205,"props":6548,"children":6549},{"style":212},[6550],{"type":45,"value":2508},{"type":32,"tag":205,"props":6552,"children":6553},{"style":275},[6554],{"type":45,"value":1550},{"type":32,"tag":205,"props":6556,"children":6557},{"style":218},[6558],{"type":45,"value":6559},"'[Queue] Error processing batch:'",{"type":32,"tag":205,"props":6561,"children":6562},{"style":275},[6563],{"type":45,"value":4878},{"type":32,"tag":205,"props":6565,"children":6566},{"class":207,"line":1587},[6567],{"type":32,"tag":205,"props":6568,"children":6569},{"style":716},[6570],{"type":45,"value":6571},"        // This will trigger a retry as per the wrangler.toml queue settings\n",{"type":32,"tag":205,"props":6573,"children":6574},{"class":207,"line":1595},[6575,6580],{"type":32,"tag":205,"props":6576,"children":6577},{"style":651},[6578],{"type":45,"value":6579},"        throw",{"type":32,"tag":205,"props":6581,"children":6582},{"style":275},[6583],{"type":45,"value":5971},{"type":32,"tag":205,"props":6585,"children":6586},{"class":207,"line":1604},[6587],{"type":32,"tag":205,"props":6588,"children":6589},{"style":275},[6590],{"type":45,"value":2571},{"type":32,"tag":205,"props":6592,"children":6593},{"class":207,"line":1612},[6594],{"type":32,"tag":205,"props":6595,"children":6596},{"style":275},[6597],{"type":45,"value":1500},{"type":32,"tag":205,"props":6599,"children":6600},{"class":207,"line":1629},[6601],{"type":32,"tag":205,"props":6602,"children":6603},{"style":275},[6604],{"type":45,"value":6605},"  })\n",{"type":32,"tag":205,"props":6607,"children":6608},{"class":207,"line":1637},[6609],{"type":32,"tag":205,"props":6610,"children":6611},{"style":275},[6612],{"type":45,"value":4926},{"type":32,"tag":134,"props":6614,"children":6616},{"id":6615},"populating-the-cloudflare-vectorize-index-from-our-nuxt-application",[6617],{"type":45,"value":6618},"Populating the Cloudflare Vectorize index from our Nuxt application",{"type":32,"tag":33,"props":6620,"children":6621},{},[6622],{"type":45,"value":6623},"We’ve built everything we need to populate the vector store with our location data, and we’re now ready for the most exciting part of this article.",{"type":32,"tag":33,"props":6625,"children":6626},{},[6627,6629,6635],{"type":45,"value":6628},"We will use an API endpoint to run it remotely. Create ",{"type":32,"tag":159,"props":6630,"children":6632},{"className":6631},[],[6633],{"type":45,"value":6634},"/server/api/internals/tasks/build-location-embeddings.get.ts",{"type":45,"value":636},{"type":32,"tag":194,"props":6637,"children":6639},{"className":639,"code":6638,"language":641,"meta":199,"style":199},"export default defineEventHandler(async (event) => {\n\n  const config = useRuntimeConfig();\n\n  if (getHeader(event, 'x-secret') !== config.internalApiSecret) {\n    throw createError({ statusCode: 401, statusMessage: 'Unauthorized' });\n  }\n\n  const result = await runTask(\n    'build-location-embeddings',\n    {\n      payload: {},\n      context: {\n        cloudflare: event.context.cloudflare\n      }\n    }\n  );\n\n  return {\n    status: 'Build Location Embeddings Task Triggered',\n    result,\n  };\n\n})\n",[6640],{"type":32,"tag":159,"props":6641,"children":6642},{"__ignoreMap":199},[6643,6687,6694,6721,6728,6768,6806,6813,6820,6848,6860,6868,6876,6884,6892,6899,6906,6914,6921,6933,6950,6958,6965,6972],{"type":32,"tag":205,"props":6644,"children":6645},{"class":207,"line":208},[6646,6650,6654,6659,6663,6667,6671,6675,6679,6683],{"type":32,"tag":205,"props":6647,"children":6648},{"style":651},[6649],{"type":45,"value":686},{"type":32,"tag":205,"props":6651,"children":6652},{"style":651},[6653],{"type":45,"value":4026},{"type":32,"tag":205,"props":6655,"children":6656},{"style":212},[6657],{"type":45,"value":6658}," defineEventHandler",{"type":32,"tag":205,"props":6660,"children":6661},{"style":275},[6662],{"type":45,"value":1550},{"type":32,"tag":205,"props":6664,"children":6665},{"style":651},[6666],{"type":45,"value":6193},{"type":32,"tag":205,"props":6668,"children":6669},{"style":275},[6670],{"type":45,"value":1443},{"type":32,"tag":205,"props":6672,"children":6673},{"style":808},[6674],{"type":45,"value":4106},{"type":32,"tag":205,"props":6676,"children":6677},{"style":275},[6678],{"type":45,"value":1978},{"type":32,"tag":205,"props":6680,"children":6681},{"style":689},[6682],{"type":45,"value":2125},{"type":32,"tag":205,"props":6684,"children":6685},{"style":275},[6686],{"type":45,"value":703},{"type":32,"tag":205,"props":6688,"children":6689},{"class":207,"line":281},[6690],{"type":32,"tag":205,"props":6691,"children":6692},{"emptyLinePlaceholder":675},[6693],{"type":45,"value":678},{"type":32,"tag":205,"props":6695,"children":6696},{"class":207,"line":295},[6697,6702,6707,6711,6716],{"type":32,"tag":205,"props":6698,"children":6699},{"style":689},[6700],{"type":45,"value":6701},"  const",{"type":32,"tag":205,"props":6703,"children":6704},{"style":275},[6705],{"type":45,"value":6706}," config ",{"type":32,"tag":205,"props":6708,"children":6709},{"style":651},[6710],{"type":45,"value":1781},{"type":32,"tag":205,"props":6712,"children":6713},{"style":212},[6714],{"type":45,"value":6715}," useRuntimeConfig",{"type":32,"tag":205,"props":6717,"children":6718},{"style":275},[6719],{"type":45,"value":6720},"();\n",{"type":32,"tag":205,"props":6722,"children":6723},{"class":207,"line":509},[6724],{"type":32,"tag":205,"props":6725,"children":6726},{"emptyLinePlaceholder":675},[6727],{"type":45,"value":678},{"type":32,"tag":205,"props":6729,"children":6730},{"class":207,"line":523},[6731,6736,6740,6745,6750,6755,6759,6763],{"type":32,"tag":205,"props":6732,"children":6733},{"style":651},[6734],{"type":45,"value":6735},"  if",{"type":32,"tag":205,"props":6737,"children":6738},{"style":275},[6739],{"type":45,"value":1443},{"type":32,"tag":205,"props":6741,"children":6742},{"style":212},[6743],{"type":45,"value":6744},"getHeader",{"type":32,"tag":205,"props":6746,"children":6747},{"style":275},[6748],{"type":45,"value":6749},"(event, ",{"type":32,"tag":205,"props":6751,"children":6752},{"style":218},[6753],{"type":45,"value":6754},"'x-secret'",{"type":32,"tag":205,"props":6756,"children":6757},{"style":275},[6758],{"type":45,"value":1978},{"type":32,"tag":205,"props":6760,"children":6761},{"style":651},[6762],{"type":45,"value":2326},{"type":32,"tag":205,"props":6764,"children":6765},{"style":275},[6766],{"type":45,"value":6767}," config.internalApiSecret) {\n",{"type":32,"tag":205,"props":6769,"children":6770},{"class":207,"line":537},[6771,6776,6781,6786,6791,6796,6801],{"type":32,"tag":205,"props":6772,"children":6773},{"style":651},[6774],{"type":45,"value":6775},"    throw",{"type":32,"tag":205,"props":6777,"children":6778},{"style":212},[6779],{"type":45,"value":6780}," createError",{"type":32,"tag":205,"props":6782,"children":6783},{"style":275},[6784],{"type":45,"value":6785},"({ statusCode: ",{"type":32,"tag":205,"props":6787,"children":6788},{"style":239},[6789],{"type":45,"value":6790},"401",{"type":32,"tag":205,"props":6792,"children":6793},{"style":275},[6794],{"type":45,"value":6795},", statusMessage: ",{"type":32,"tag":205,"props":6797,"children":6798},{"style":218},[6799],{"type":45,"value":6800},"'Unauthorized'",{"type":32,"tag":205,"props":6802,"children":6803},{"style":275},[6804],{"type":45,"value":6805}," });\n",{"type":32,"tag":205,"props":6807,"children":6808},{"class":207,"line":730},[6809],{"type":32,"tag":205,"props":6810,"children":6811},{"style":275},[6812],{"type":45,"value":1576},{"type":32,"tag":205,"props":6814,"children":6815},{"class":207,"line":739},[6816],{"type":32,"tag":205,"props":6817,"children":6818},{"emptyLinePlaceholder":675},[6819],{"type":45,"value":678},{"type":32,"tag":205,"props":6821,"children":6822},{"class":207,"line":763},[6823,6827,6831,6835,6839,6844],{"type":32,"tag":205,"props":6824,"children":6825},{"style":689},[6826],{"type":45,"value":6701},{"type":32,"tag":205,"props":6828,"children":6829},{"style":275},[6830],{"type":45,"value":2383},{"type":32,"tag":205,"props":6832,"children":6833},{"style":651},[6834],{"type":45,"value":1781},{"type":32,"tag":205,"props":6836,"children":6837},{"style":651},[6838],{"type":45,"value":2046},{"type":32,"tag":205,"props":6840,"children":6841},{"style":212},[6842],{"type":45,"value":6843}," runTask",{"type":32,"tag":205,"props":6845,"children":6846},{"style":275},[6847],{"type":45,"value":1477},{"type":32,"tag":205,"props":6849,"children":6850},{"class":207,"line":781},[6851,6856],{"type":32,"tag":205,"props":6852,"children":6853},{"style":218},[6854],{"type":45,"value":6855},"    'build-location-embeddings'",{"type":32,"tag":205,"props":6857,"children":6858},{"style":275},[6859],{"type":45,"value":1385},{"type":32,"tag":205,"props":6861,"children":6862},{"class":207,"line":790},[6863],{"type":32,"tag":205,"props":6864,"children":6865},{"style":275},[6866],{"type":45,"value":6867},"    {\n",{"type":32,"tag":205,"props":6869,"children":6870},{"class":207,"line":804},[6871],{"type":32,"tag":205,"props":6872,"children":6873},{"style":275},[6874],{"type":45,"value":6875},"      payload: {},\n",{"type":32,"tag":205,"props":6877,"children":6878},{"class":207,"line":828},[6879],{"type":32,"tag":205,"props":6880,"children":6881},{"style":275},[6882],{"type":45,"value":6883},"      context: {\n",{"type":32,"tag":205,"props":6885,"children":6886},{"class":207,"line":861},[6887],{"type":32,"tag":205,"props":6888,"children":6889},{"style":275},[6890],{"type":45,"value":6891},"        cloudflare: event.context.cloudflare\n",{"type":32,"tag":205,"props":6893,"children":6894},{"class":207,"line":1432},[6895],{"type":32,"tag":205,"props":6896,"children":6897},{"style":275},[6898],{"type":45,"value":2571},{"type":32,"tag":205,"props":6900,"children":6901},{"class":207,"line":1456},[6902],{"type":32,"tag":205,"props":6903,"children":6904},{"style":275},[6905],{"type":45,"value":1500},{"type":32,"tag":205,"props":6907,"children":6908},{"class":207,"line":1480},[6909],{"type":32,"tag":205,"props":6910,"children":6911},{"style":275},[6912],{"type":45,"value":6913},"  );\n",{"type":32,"tag":205,"props":6915,"children":6916},{"class":207,"line":1494},[6917],{"type":32,"tag":205,"props":6918,"children":6919},{"emptyLinePlaceholder":675},[6920],{"type":45,"value":678},{"type":32,"tag":205,"props":6922,"children":6923},{"class":207,"line":1503},[6924,6929],{"type":32,"tag":205,"props":6925,"children":6926},{"style":651},[6927],{"type":45,"value":6928},"  return",{"type":32,"tag":205,"props":6930,"children":6931},{"style":275},[6932],{"type":45,"value":703},{"type":32,"tag":205,"props":6934,"children":6935},{"class":207,"line":1511},[6936,6941,6946],{"type":32,"tag":205,"props":6937,"children":6938},{"style":275},[6939],{"type":45,"value":6940},"    status: ",{"type":32,"tag":205,"props":6942,"children":6943},{"style":218},[6944],{"type":45,"value":6945},"'Build Location Embeddings Task Triggered'",{"type":32,"tag":205,"props":6947,"children":6948},{"style":275},[6949],{"type":45,"value":1385},{"type":32,"tag":205,"props":6951,"children":6952},{"class":207,"line":1532},[6953],{"type":32,"tag":205,"props":6954,"children":6955},{"style":275},[6956],{"type":45,"value":6957},"    result,\n",{"type":32,"tag":205,"props":6959,"children":6960},{"class":207,"line":1562},[6961],{"type":32,"tag":205,"props":6962,"children":6963},{"style":275},[6964],{"type":45,"value":3887},{"type":32,"tag":205,"props":6966,"children":6967},{"class":207,"line":1570},[6968],{"type":32,"tag":205,"props":6969,"children":6970},{"emptyLinePlaceholder":675},[6971],{"type":45,"value":678},{"type":32,"tag":205,"props":6973,"children":6974},{"class":207,"line":1579},[6975],{"type":32,"tag":205,"props":6976,"children":6977},{"style":275},[6978],{"type":45,"value":4926},{"type":32,"tag":33,"props":6980,"children":6981},{},[6982,6984,6990],{"type":45,"value":6983},"This endpoint triggers our Nitro Task programatically using the ",{"type":32,"tag":159,"props":6985,"children":6987},{"className":6986},[],[6988],{"type":45,"value":6989},"runTask()",{"type":45,"value":6991}," function. Notice we’re using the internal API secret we added as an environment variable to the Cloudflare Worker in the previous article. Also good to note that we’re setting the context to use Cloudflare’s context, since the Nitro Task depends on Cloudflare’s D1 database and the Vector Sync Queue.",{"type":32,"tag":33,"props":6993,"children":6994},{},[6995],{"type":45,"value":6996},"With the API endpoint added, go ahead, deploy and test:",{"type":32,"tag":194,"props":6998,"children":7002},{"className":6999,"code":7000,"language":7001,"meta":199,"style":199},"language-bash shiki shiki-themes monokai","pnpm run build\nnpx wrangler deploy\n\ncurl -H \"x-secret: [YOUR_SECRET]\" \"https://[YOUR_WORKER_URL]/api/internals/tasks/build-location-embeddings\"\n","bash",[7003],{"type":32,"tag":159,"props":7004,"children":7005},{"__ignoreMap":199},[7006,7021,7036,7043],{"type":32,"tag":205,"props":7007,"children":7008},{"class":207,"line":208},[7009,7013,7017],{"type":32,"tag":205,"props":7010,"children":7011},{"style":212},[7012],{"type":45,"value":394},{"type":32,"tag":205,"props":7014,"children":7015},{"style":218},[7016],{"type":45,"value":399},{"type":32,"tag":205,"props":7018,"children":7019},{"style":218},[7020],{"type":45,"value":404},{"type":32,"tag":205,"props":7022,"children":7023},{"class":207,"line":281},[7024,7028,7032],{"type":32,"tag":205,"props":7025,"children":7026},{"style":212},[7027],{"type":45,"value":215},{"type":32,"tag":205,"props":7029,"children":7030},{"style":218},[7031],{"type":45,"value":221},{"type":32,"tag":205,"props":7033,"children":7034},{"style":218},[7035],{"type":45,"value":420},{"type":32,"tag":205,"props":7037,"children":7038},{"class":207,"line":295},[7039],{"type":32,"tag":205,"props":7040,"children":7041},{"emptyLinePlaceholder":675},[7042],{"type":45,"value":678},{"type":32,"tag":205,"props":7044,"children":7045},{"class":207,"line":509},[7046,7051,7056,7061],{"type":32,"tag":205,"props":7047,"children":7048},{"style":212},[7049],{"type":45,"value":7050},"curl",{"type":32,"tag":205,"props":7052,"children":7053},{"style":239},[7054],{"type":45,"value":7055}," -H",{"type":32,"tag":205,"props":7057,"children":7058},{"style":218},[7059],{"type":45,"value":7060}," \"x-secret: [YOUR_SECRET]\"",{"type":32,"tag":205,"props":7062,"children":7063},{"style":218},[7064],{"type":45,"value":7065}," \"https://[YOUR_WORKER_URL]/api/internals/tasks/build-location-embeddings\"\n",{"type":32,"tag":33,"props":7067,"children":7068},{},[7069],{"type":45,"value":7070},"In your Cloudflare worker dashboard, you can see the endpoint trigger and then the queue. We can also verify that the vector index is populated through Wrangler, but you need to wait a couple of minutes for the queue to be processed.",{"type":32,"tag":194,"props":7072,"children":7074},{"className":6999,"code":7073,"language":7001,"meta":199,"style":199},"npx wrangler vectorize info locations-index\n\n# Should return something like:\n\n ⛅️ wrangler 4.53.0\n───────────────────\n📋 Fetching index info...\n┌────────────┬─────────────┬──────────────────────────────────────┬──────────────────────────┐\n│ dimensions │ vectorCount │ processedUpToMutation                │ processedUpToDatetime    │\n├────────────┼─────────────┼──────────────────────────────────────┼──────────────────────────┤\n│ 1024       │ 4           │ aa21b6a6-e25f-4b1c-afa8-98846e801ec6 │ 2025-12-08T09:47:59.146Z │\n└────────────┴─────────────┴──────────────────────────────────────┴──────────────────────────┘\n\nnpx wrangler vectorize list-vectors locations-index\n\n# Should list the Location ID:\n\n ⛅️ wrangler 4.53.0\n───────────────────\n📋 Listing vectors in index 'locations-index'...\n┌───┬──────────────────────────────────────┐\n│ # │ Vector ID                            │\n├───┼──────────────────────────────────────┤\n│ 1 │ 1e212fe9-3994-4c7a-a90f-22df3fdee8d5 │\n├───┼──────────────────────────────────────┤\n│ 2 │ 0168e16d-0571-466d-809b-d717e58d7cab │\n├───┼──────────────────────────────────────┤\n│ 3 │ 1818d8a6-baf1-4780-b6d7-a8e6f45b3369 │\n├───┼──────────────────────────────────────┤\n│ 4 │ 76d29d74-5dfe-4a46-b15d-802e976d5250 │\n└───┴──────────────────────────────────────┘\n\nShowing 4 of 4 total vectors\n\n",[7075],{"type":32,"tag":159,"props":7076,"children":7077},{"__ignoreMap":199},[7078,7103,7110,7118,7125,7142,7150,7173,7181,7228,7236,7282,7290,7297,7321,7328,7336,7343,7358,7365,7396,7404,7416,7424,7449,7456,7481,7488,7513,7520,7544,7552,7559],{"type":32,"tag":205,"props":7079,"children":7080},{"class":207,"line":208},[7081,7085,7089,7093,7098],{"type":32,"tag":205,"props":7082,"children":7083},{"style":212},[7084],{"type":45,"value":215},{"type":32,"tag":205,"props":7086,"children":7087},{"style":218},[7088],{"type":45,"value":221},{"type":32,"tag":205,"props":7090,"children":7091},{"style":218},[7092],{"type":45,"value":226},{"type":32,"tag":205,"props":7094,"children":7095},{"style":218},[7096],{"type":45,"value":7097}," info",{"type":32,"tag":205,"props":7099,"children":7100},{"style":218},[7101],{"type":45,"value":7102}," locations-index\n",{"type":32,"tag":205,"props":7104,"children":7105},{"class":207,"line":281},[7106],{"type":32,"tag":205,"props":7107,"children":7108},{"emptyLinePlaceholder":675},[7109],{"type":45,"value":678},{"type":32,"tag":205,"props":7111,"children":7112},{"class":207,"line":295},[7113],{"type":32,"tag":205,"props":7114,"children":7115},{"style":716},[7116],{"type":45,"value":7117},"# Should return something like:\n",{"type":32,"tag":205,"props":7119,"children":7120},{"class":207,"line":509},[7121],{"type":32,"tag":205,"props":7122,"children":7123},{"emptyLinePlaceholder":675},[7124],{"type":45,"value":678},{"type":32,"tag":205,"props":7126,"children":7127},{"class":207,"line":523},[7128,7133,7137],{"type":32,"tag":205,"props":7129,"children":7130},{"style":212},[7131],{"type":45,"value":7132}," ⛅️",{"type":32,"tag":205,"props":7134,"children":7135},{"style":218},[7136],{"type":45,"value":221},{"type":32,"tag":205,"props":7138,"children":7139},{"style":239},[7140],{"type":45,"value":7141}," 4.53.0\n",{"type":32,"tag":205,"props":7143,"children":7144},{"class":207,"line":537},[7145],{"type":32,"tag":205,"props":7146,"children":7147},{"style":212},[7148],{"type":45,"value":7149},"───────────────────\n",{"type":32,"tag":205,"props":7151,"children":7152},{"class":207,"line":730},[7153,7158,7163,7168],{"type":32,"tag":205,"props":7154,"children":7155},{"style":212},[7156],{"type":45,"value":7157},"📋",{"type":32,"tag":205,"props":7159,"children":7160},{"style":218},[7161],{"type":45,"value":7162}," Fetching",{"type":32,"tag":205,"props":7164,"children":7165},{"style":218},[7166],{"type":45,"value":7167}," index",{"type":32,"tag":205,"props":7169,"children":7170},{"style":218},[7171],{"type":45,"value":7172}," info...\n",{"type":32,"tag":205,"props":7174,"children":7175},{"class":207,"line":739},[7176],{"type":32,"tag":205,"props":7177,"children":7178},{"style":212},[7179],{"type":45,"value":7180},"┌────────────┬─────────────┬──────────────────────────────────────┬──────────────────────────┐\n",{"type":32,"tag":205,"props":7182,"children":7183},{"class":207,"line":763},[7184,7189,7194,7199,7204,7208,7213,7218,7223],{"type":32,"tag":205,"props":7185,"children":7186},{"style":212},[7187],{"type":45,"value":7188},"│",{"type":32,"tag":205,"props":7190,"children":7191},{"style":218},[7192],{"type":45,"value":7193}," dimensions",{"type":32,"tag":205,"props":7195,"children":7196},{"style":218},[7197],{"type":45,"value":7198}," │",{"type":32,"tag":205,"props":7200,"children":7201},{"style":218},[7202],{"type":45,"value":7203}," vectorCount",{"type":32,"tag":205,"props":7205,"children":7206},{"style":218},[7207],{"type":45,"value":7198},{"type":32,"tag":205,"props":7209,"children":7210},{"style":218},[7211],{"type":45,"value":7212}," processedUpToMutation",{"type":32,"tag":205,"props":7214,"children":7215},{"style":218},[7216],{"type":45,"value":7217},"                │",{"type":32,"tag":205,"props":7219,"children":7220},{"style":218},[7221],{"type":45,"value":7222}," processedUpToDatetime",{"type":32,"tag":205,"props":7224,"children":7225},{"style":218},[7226],{"type":45,"value":7227},"    │\n",{"type":32,"tag":205,"props":7229,"children":7230},{"class":207,"line":781},[7231],{"type":32,"tag":205,"props":7232,"children":7233},{"style":212},[7234],{"type":45,"value":7235},"├────────────┼─────────────┼──────────────────────────────────────┼──────────────────────────┤\n",{"type":32,"tag":205,"props":7237,"children":7238},{"class":207,"line":790},[7239,7243,7248,7253,7258,7263,7268,7272,7277],{"type":32,"tag":205,"props":7240,"children":7241},{"style":212},[7242],{"type":45,"value":7188},{"type":32,"tag":205,"props":7244,"children":7245},{"style":239},[7246],{"type":45,"value":7247}," 1024",{"type":32,"tag":205,"props":7249,"children":7250},{"style":218},[7251],{"type":45,"value":7252},"       │",{"type":32,"tag":205,"props":7254,"children":7255},{"style":239},[7256],{"type":45,"value":7257}," 4",{"type":32,"tag":205,"props":7259,"children":7260},{"style":218},[7261],{"type":45,"value":7262},"           │",{"type":32,"tag":205,"props":7264,"children":7265},{"style":218},[7266],{"type":45,"value":7267}," aa21b6a6-e25f-4b1c-afa8-98846e801ec6",{"type":32,"tag":205,"props":7269,"children":7270},{"style":218},[7271],{"type":45,"value":7198},{"type":32,"tag":205,"props":7273,"children":7274},{"style":218},[7275],{"type":45,"value":7276}," 2025-12-08T09:47:59.146Z",{"type":32,"tag":205,"props":7278,"children":7279},{"style":218},[7280],{"type":45,"value":7281}," │\n",{"type":32,"tag":205,"props":7283,"children":7284},{"class":207,"line":804},[7285],{"type":32,"tag":205,"props":7286,"children":7287},{"style":212},[7288],{"type":45,"value":7289},"└────────────┴─────────────┴──────────────────────────────────────┴──────────────────────────┘\n",{"type":32,"tag":205,"props":7291,"children":7292},{"class":207,"line":828},[7293],{"type":32,"tag":205,"props":7294,"children":7295},{"emptyLinePlaceholder":675},[7296],{"type":45,"value":678},{"type":32,"tag":205,"props":7298,"children":7299},{"class":207,"line":861},[7300,7304,7308,7312,7317],{"type":32,"tag":205,"props":7301,"children":7302},{"style":212},[7303],{"type":45,"value":215},{"type":32,"tag":205,"props":7305,"children":7306},{"style":218},[7307],{"type":45,"value":221},{"type":32,"tag":205,"props":7309,"children":7310},{"style":218},[7311],{"type":45,"value":226},{"type":32,"tag":205,"props":7313,"children":7314},{"style":218},[7315],{"type":45,"value":7316}," list-vectors",{"type":32,"tag":205,"props":7318,"children":7319},{"style":218},[7320],{"type":45,"value":7102},{"type":32,"tag":205,"props":7322,"children":7323},{"class":207,"line":1432},[7324],{"type":32,"tag":205,"props":7325,"children":7326},{"emptyLinePlaceholder":675},[7327],{"type":45,"value":678},{"type":32,"tag":205,"props":7329,"children":7330},{"class":207,"line":1456},[7331],{"type":32,"tag":205,"props":7332,"children":7333},{"style":716},[7334],{"type":45,"value":7335},"# Should list the Location ID:\n",{"type":32,"tag":205,"props":7337,"children":7338},{"class":207,"line":1480},[7339],{"type":32,"tag":205,"props":7340,"children":7341},{"emptyLinePlaceholder":675},[7342],{"type":45,"value":678},{"type":32,"tag":205,"props":7344,"children":7345},{"class":207,"line":1494},[7346,7350,7354],{"type":32,"tag":205,"props":7347,"children":7348},{"style":212},[7349],{"type":45,"value":7132},{"type":32,"tag":205,"props":7351,"children":7352},{"style":218},[7353],{"type":45,"value":221},{"type":32,"tag":205,"props":7355,"children":7356},{"style":239},[7357],{"type":45,"value":7141},{"type":32,"tag":205,"props":7359,"children":7360},{"class":207,"line":1503},[7361],{"type":32,"tag":205,"props":7362,"children":7363},{"style":212},[7364],{"type":45,"value":7149},{"type":32,"tag":205,"props":7366,"children":7367},{"class":207,"line":1511},[7368,7372,7377,7382,7387,7391],{"type":32,"tag":205,"props":7369,"children":7370},{"style":212},[7371],{"type":45,"value":7157},{"type":32,"tag":205,"props":7373,"children":7374},{"style":218},[7375],{"type":45,"value":7376}," Listing",{"type":32,"tag":205,"props":7378,"children":7379},{"style":218},[7380],{"type":45,"value":7381}," vectors",{"type":32,"tag":205,"props":7383,"children":7384},{"style":218},[7385],{"type":45,"value":7386}," in",{"type":32,"tag":205,"props":7388,"children":7389},{"style":218},[7390],{"type":45,"value":7167},{"type":32,"tag":205,"props":7392,"children":7393},{"style":218},[7394],{"type":45,"value":7395}," 'locations-index'...\n",{"type":32,"tag":205,"props":7397,"children":7398},{"class":207,"line":1532},[7399],{"type":32,"tag":205,"props":7400,"children":7401},{"style":212},[7402],{"type":45,"value":7403},"┌───┬──────────────────────────────────────┐\n",{"type":32,"tag":205,"props":7405,"children":7406},{"class":207,"line":1562},[7407,7411],{"type":32,"tag":205,"props":7408,"children":7409},{"style":212},[7410],{"type":45,"value":7188},{"type":32,"tag":205,"props":7412,"children":7413},{"style":716},[7414],{"type":45,"value":7415}," # │ Vector ID                            │\n",{"type":32,"tag":205,"props":7417,"children":7418},{"class":207,"line":1570},[7419],{"type":32,"tag":205,"props":7420,"children":7421},{"style":212},[7422],{"type":45,"value":7423},"├───┼──────────────────────────────────────┤\n",{"type":32,"tag":205,"props":7425,"children":7426},{"class":207,"line":1579},[7427,7431,7436,7440,7445],{"type":32,"tag":205,"props":7428,"children":7429},{"style":212},[7430],{"type":45,"value":7188},{"type":32,"tag":205,"props":7432,"children":7433},{"style":239},[7434],{"type":45,"value":7435}," 1",{"type":32,"tag":205,"props":7437,"children":7438},{"style":218},[7439],{"type":45,"value":7198},{"type":32,"tag":205,"props":7441,"children":7442},{"style":218},[7443],{"type":45,"value":7444}," 1e212fe9-3994-4c7a-a90f-22df3fdee8d5",{"type":32,"tag":205,"props":7446,"children":7447},{"style":218},[7448],{"type":45,"value":7281},{"type":32,"tag":205,"props":7450,"children":7451},{"class":207,"line":1587},[7452],{"type":32,"tag":205,"props":7453,"children":7454},{"style":212},[7455],{"type":45,"value":7423},{"type":32,"tag":205,"props":7457,"children":7458},{"class":207,"line":1595},[7459,7463,7468,7472,7477],{"type":32,"tag":205,"props":7460,"children":7461},{"style":212},[7462],{"type":45,"value":7188},{"type":32,"tag":205,"props":7464,"children":7465},{"style":239},[7466],{"type":45,"value":7467}," 2",{"type":32,"tag":205,"props":7469,"children":7470},{"style":218},[7471],{"type":45,"value":7198},{"type":32,"tag":205,"props":7473,"children":7474},{"style":218},[7475],{"type":45,"value":7476}," 0168e16d-0571-466d-809b-d717e58d7cab",{"type":32,"tag":205,"props":7478,"children":7479},{"style":218},[7480],{"type":45,"value":7281},{"type":32,"tag":205,"props":7482,"children":7483},{"class":207,"line":1604},[7484],{"type":32,"tag":205,"props":7485,"children":7486},{"style":212},[7487],{"type":45,"value":7423},{"type":32,"tag":205,"props":7489,"children":7490},{"class":207,"line":1612},[7491,7495,7500,7504,7509],{"type":32,"tag":205,"props":7492,"children":7493},{"style":212},[7494],{"type":45,"value":7188},{"type":32,"tag":205,"props":7496,"children":7497},{"style":239},[7498],{"type":45,"value":7499}," 3",{"type":32,"tag":205,"props":7501,"children":7502},{"style":218},[7503],{"type":45,"value":7198},{"type":32,"tag":205,"props":7505,"children":7506},{"style":218},[7507],{"type":45,"value":7508}," 1818d8a6-baf1-4780-b6d7-a8e6f45b3369",{"type":32,"tag":205,"props":7510,"children":7511},{"style":218},[7512],{"type":45,"value":7281},{"type":32,"tag":205,"props":7514,"children":7515},{"class":207,"line":1629},[7516],{"type":32,"tag":205,"props":7517,"children":7518},{"style":212},[7519],{"type":45,"value":7423},{"type":32,"tag":205,"props":7521,"children":7522},{"class":207,"line":1637},[7523,7527,7531,7535,7540],{"type":32,"tag":205,"props":7524,"children":7525},{"style":212},[7526],{"type":45,"value":7188},{"type":32,"tag":205,"props":7528,"children":7529},{"style":239},[7530],{"type":45,"value":7257},{"type":32,"tag":205,"props":7532,"children":7533},{"style":218},[7534],{"type":45,"value":7198},{"type":32,"tag":205,"props":7536,"children":7537},{"style":218},[7538],{"type":45,"value":7539}," 76d29d74-5dfe-4a46-b15d-802e976d5250",{"type":32,"tag":205,"props":7541,"children":7542},{"style":218},[7543],{"type":45,"value":7281},{"type":32,"tag":205,"props":7545,"children":7546},{"class":207,"line":1699},[7547],{"type":32,"tag":205,"props":7548,"children":7549},{"style":212},[7550],{"type":45,"value":7551},"└───┴──────────────────────────────────────┘\n",{"type":32,"tag":205,"props":7553,"children":7554},{"class":207,"line":1707},[7555],{"type":32,"tag":205,"props":7556,"children":7557},{"emptyLinePlaceholder":675},[7558],{"type":45,"value":678},{"type":32,"tag":205,"props":7560,"children":7561},{"class":207,"line":1735},[7562,7567,7571,7576,7580,7585],{"type":32,"tag":205,"props":7563,"children":7564},{"style":212},[7565],{"type":45,"value":7566},"Showing",{"type":32,"tag":205,"props":7568,"children":7569},{"style":239},[7570],{"type":45,"value":7257},{"type":32,"tag":205,"props":7572,"children":7573},{"style":218},[7574],{"type":45,"value":7575}," of",{"type":32,"tag":205,"props":7577,"children":7578},{"style":239},[7579],{"type":45,"value":7257},{"type":32,"tag":205,"props":7581,"children":7582},{"style":218},[7583],{"type":45,"value":7584}," total",{"type":32,"tag":205,"props":7586,"children":7587},{"style":218},[7588],{"type":45,"value":2961},{"type":32,"tag":7590,"props":7591,"children":7592},"newsletter-form",{},[],{"type":32,"tag":7594,"props":7595,"children":7596},"br",{},[],{"type":32,"tag":134,"props":7598,"children":7600},{"id":7599},"moving-forward-with-implementing-our-semantic-matching-feature",[7601],{"type":45,"value":7602},"Moving forward with implementing our Semantic Matching feature",{"type":32,"tag":33,"props":7604,"children":7605},{},[7606,7608,7613],{"type":45,"value":7607},"The final part of this Nuxt & Cloudflare AI Vector Pipeline Series is where the magic happens: we will ",{"type":32,"tag":48,"props":7609,"children":7610},{"href":112},[7611],{"type":45,"value":7612},"implement the location semantic matching",{"type":45,"value":7614}," to tie everything together.",{"type":32,"tag":33,"props":7616,"children":7617},{},[7618,7620,7626],{"type":45,"value":7619},"I hope you’re enjoying this series! As always, feel free to ask questions in the comments below or on social media. Please do share this with anyone you think might find it useful, and ",{"type":32,"tag":48,"props":7621,"children":7623},{"href":7622},"/subscribe/",[7624],{"type":45,"value":7625},"subscribe",{"type":45,"value":7627}," if you’d like me to email you when I prepare more code examples and articles.",{"type":32,"tag":33,"props":7629,"children":7630},{},[7631],{"type":45,"value":7632},"Peace ✌🏽",{"type":32,"tag":7634,"props":7635,"children":7636},"style",{},[7637],{"type":45,"value":7638},"html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}",{"title":199,"searchDepth":281,"depth":281,"links":7640},[7641,7642,7643,7648,7649],{"id":136,"depth":281,"text":139},{"id":551,"depth":281,"text":554},{"id":3193,"depth":281,"text":3196,"children":7644},[7645,7646,7647],{"id":3223,"depth":295,"text":3226},{"id":3393,"depth":295,"text":3396},{"id":4956,"depth":295,"text":4959},{"id":6615,"depth":281,"text":6618},{"id":7599,"depth":281,"text":7602},"markdown","content:blog:11.nuxt-cloudflare-queues-and-vectorize-data-sync-pipeline:index.md","content","blog/11.nuxt-cloudflare-queues-and-vectorize-data-sync-pipeline/index.md","blog/11.nuxt-cloudflare-queues-and-vectorize-data-sync-pipeline/index","md",[7657,7663,7668],{"_path":26,"title":7658,"date":7659,"preview_image":7660,"featured_image":7661,"_id":7662},"Implementing Semantic Matching in Nuxt with Cloudflare Vectorize","2025-12-21","/nuxt-cloudflare-vectorize-semantic-matching/nuxt-cloudflare-vectorize-semantic-matching.webp","/nuxt-cloudflare-vectorize-semantic-matching/nuxt-cloudflare-vectorize-semantic-matching_featured.webp","content:blog:12.nuxt-cloudflare-vectorize-semantic-matching:index.md",{"_path":25,"title":95,"date":7664,"preview_image":7665,"featured_image":7666,"_id":7667},"2025-12-19","/nuxt-cloudflare-vectorize-d1-drizzle-setup/nuxt-cloudflare-vectorize-d1-drizzle-setup.webp","/nuxt-cloudflare-vectorize-d1-drizzle-setup/nuxt-cloudflare-vectorize-d1-drizzle-setup_featured.webp","content:blog:10.nuxt-and-cloudflare-vectorize-setting-up-d1-drizzle-and-workers-ai:index.md",{"_path":27,"title":7669,"date":7670,"preview_image":7671,"_id":7672},"Build and deploy a static online shop with Nuxt3 using Pinia Store and Stripe Checkout to Firebase","2022-11-13","/build-and-deploy-nuxt3-static-site-with-pinia-and-stripe-checkout-on-firebase/nuxt3-static-shop.png","content:blog:9.build-and-deploy-nuxt3-static-site-with-pinia-and-stripe-checkout-on-firebase:index.md",1776233981219]