@tanstack/db
Version:
A reactive client store for building super fast apps on sync
1 lines • 2.2 kB
Source Map (JSON)
{"version":3,"file":"parent-routes.cjs","sources":["../../../../src/query/compiler/parent-routes.ts"],"sourcesContent":["import { filter, join as joinOperator, map } from '@tanstack/db-ivm'\nimport type { KeyedStream } from '../../types.js'\n\nconst PARENT_ROUTE_CROSS_KEY = `__tanstack_parent_route_cross__`\n\nexport function crossJoinParentRoutes(\n input: KeyedStream,\n parentKeyStream: KeyedStream,\n assemble: (\n rowKey: unknown,\n row: unknown,\n correlationKey: unknown,\n parentContext: unknown,\n ) => [unknown, unknown],\n): KeyedStream {\n // Recursive sources need their route before a correlation field is always\n // available. The constant key intentionally creates one copy of each input\n // row per active route; callers filter those copies once the field is visible.\n const rows: any = input.pipe(\n map(([rowKey, row]) => [PARENT_ROUTE_CROSS_KEY, [rowKey, row]]),\n )\n const routes: any = parentKeyStream.pipe(\n map(([correlationKey, parentContext]) => [\n PARENT_ROUTE_CROSS_KEY,\n [correlationKey, parentContext],\n ]),\n )\n\n return rows.pipe(\n joinOperator(routes, `inner`),\n filter(([, [rowSide, routeSide]]: any) =>\n Boolean(rowSide != null && routeSide != null),\n ),\n map(([, [rowSide, routeSide]]: any) => {\n const [rowKey, row] = rowSide\n const [correlationKey, parentContext] = routeSide\n return assemble(rowKey, row, correlationKey, parentContext)\n }),\n ) as KeyedStream\n}\n"],"names":["map","joinOperator","filter"],"mappings":";;;AAGA,MAAM,yBAAyB;AAExB,SAAS,sBACd,OACA,iBACA,UAMa;AAIb,QAAM,OAAY,MAAM;AAAA,IACtBA,UAAI,CAAC,CAAC,QAAQ,GAAG,MAAM,CAAC,wBAAwB,CAAC,QAAQ,GAAG,CAAC,CAAC;AAAA,EAAA;AAEhE,QAAM,SAAc,gBAAgB;AAAA,IAClCA,MAAAA,IAAI,CAAC,CAAC,gBAAgB,aAAa,MAAM;AAAA,MACvC;AAAA,MACA,CAAC,gBAAgB,aAAa;AAAA,IAAA,CAC/B;AAAA,EAAA;AAGH,SAAO,KAAK;AAAA,IACVC,WAAa,QAAQ,OAAO;AAAA,IAC5BC,MAAAA;AAAAA,MAAO,CAAC,CAAA,EAAG,CAAC,SAAS,SAAS,CAAC,MAC7B,QAAQ,WAAW,QAAQ,aAAa,IAAI;AAAA,IAAA;AAAA,IAE9CF,MAAAA,IAAI,CAAC,CAAA,EAAG,CAAC,SAAS,SAAS,CAAC,MAAW;AACrC,YAAM,CAAC,QAAQ,GAAG,IAAI;AACtB,YAAM,CAAC,gBAAgB,aAAa,IAAI;AACxC,aAAO,SAAS,QAAQ,KAAK,gBAAgB,aAAa;AAAA,IAC5D,CAAC;AAAA,EAAA;AAEL;;"}