mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-14 20:21:09 +02:00
New shared package enabling bidirectional links between records across apps (e.g. todo→calendar, task→file). Each link creates a forward+reverse pair sharing a pairId for efficient queries from both sides. Stored in dedicated IndexedDB (manacore-links), synced via mana-sync. Includes: types, store, mutations, reactive queries, cached display data resolvers, ManaLinkBadge and ManaLinkList UI components. Integrates into Todo app as first consumer — link store initialized in layout, ManaLinkList rendered in TaskEditModal. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
40 lines
1,004 B
TypeScript
40 lines
1,004 B
TypeScript
/**
|
|
* ManaLink — Local-First Store
|
|
*
|
|
* Creates a shared IndexedDB database ('manacore-links') that all apps
|
|
* can read from. Links are synced to the server via mana-sync.
|
|
*/
|
|
|
|
import { createLocalStore } from '@manacore/local-store';
|
|
import type { LocalManaLink } from './types.js';
|
|
|
|
const SYNC_SERVER_URL =
|
|
(typeof window !== 'undefined' &&
|
|
(window as unknown as { __PUBLIC_SYNC_SERVER_URL__?: string }).__PUBLIC_SYNC_SERVER_URL__) ||
|
|
(typeof import.meta !== 'undefined' && import.meta.env?.PUBLIC_SYNC_SERVER_URL) ||
|
|
'http://localhost:3050';
|
|
|
|
export const linkLocalStore = createLocalStore({
|
|
appId: 'links',
|
|
collections: [
|
|
{
|
|
name: 'links',
|
|
indexes: [
|
|
'pairId',
|
|
'direction',
|
|
'sourceApp',
|
|
'sourceId',
|
|
'targetApp',
|
|
'targetId',
|
|
'linkType',
|
|
'[sourceApp+sourceId]',
|
|
'[sourceApp+sourceCollection+sourceId]',
|
|
],
|
|
},
|
|
],
|
|
sync: {
|
|
serverUrl: SYNC_SERVER_URL,
|
|
},
|
|
});
|
|
|
|
export const linkCollection = linkLocalStore.collection<LocalManaLink>('links');
|