@arbidocs/react 0.5.135 → 0.5.137

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/facts.js CHANGED
@@ -18,7 +18,10 @@ function useFacts(workspaceId, options) {
18
18
  }
19
19
  function useRefreshFacts() {
20
20
  const qc = useQueryClient();
21
- return () => qc.invalidateQueries({ queryKey: arbiQueryKeys.allFacts() });
21
+ return () => Promise.all([
22
+ qc.invalidateQueries({ queryKey: arbiQueryKeys.allFacts() }),
23
+ qc.invalidateQueries({ queryKey: arbiQueryKeys.allTags() })
24
+ ]);
22
25
  }
23
26
  function useCreateFact(workspaceId) {
24
27
  const arbi = useArbi();
package/dist/facts.js.map CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/facts.ts"],
4
- "sourcesContent": ["/**\n * Workspace facts (notes): a workspace's list, filtered for the timeline or by tag, the writes\n * (create, batch, patch, delete) and the search. List, create and search name their workspace (the\n * one given, else the open one, captured when they are sent); patch and delete act in the fact's\n * own workspace. Every write refreshes every cached list.\n *\n * Requires an `ArbiHost` (with an `arbi`) and a React Query client above it.\n */\n\nimport { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'\nimport type {\n CreateFactRequest,\n CreateFactsRequest,\n FactResponse,\n FactSearchRequest,\n FactSearchResponse,\n ListFactsOptions,\n UpdateFactRequest,\n} from '@arbidocs/sdk/browser'\nimport { useArbi } from './useArbi'\nimport { arbiQueryKeys } from './hooks'\n\n/** The workspace a fact call names: the one given, else the one open now ('' when none is). */\nfunction factWorkspace(arbi: ReturnType<typeof useArbi>, workspaceId?: string | null): string {\n return workspaceId || (arbi.hasWorkspace ? arbi.getWorkspaceId() : '')\n}\n\n/** What a list asks for: the timeline range, or the notes carrying tags or citing a document. */\nexport type FactListFilter = Pick<\n ListFactsOptions,\n 'from' | 'to' | 'datedOnly' | 'tagExtIds' | 'docExtId'\n>\n\n/**\n * The facts of `workspaceId` (default: the open one), newest first, or the filtered ones\n * (`datedOnly` / a range: the timeline, by date; `tagExtIds`: the notes carrying all those tags).\n */\nexport function useFacts(\n workspaceId?: string | null,\n options?: FactListFilter & { enabled?: boolean }\n) {\n const arbi = useArbi()\n const { enabled = true, ...filter } = options ?? {}\n const workspace = factWorkspace(arbi, workspaceId)\n return useQuery({\n queryKey: arbiQueryKeys.factList(workspace, filter),\n // The request names the workspace, so a switch while it runs cannot answer for another.\n queryFn: (): Promise<FactResponse[]> => arbi.facts.list({ ...filter, workspaceId: workspace }),\n enabled: enabled && !!workspace && arbi.hasWorkspace,\n staleTime: 30_000,\n })\n}\n\n/** Refresh every cached fact list after a write. */\nfunction useRefreshFacts() {\n const qc = useQueryClient()\n return () => qc.invalidateQueries({ queryKey: arbiQueryKeys.allFacts() })\n}\n\n/**\n * Add a fact (by hand it is confirmed: typing it is the vouch) to `workspaceId` (the message's or\n * the page's), else to the workspace open when it is sent.\n */\nexport function useCreateFact(workspaceId?: string | null) {\n const arbi = useArbi()\n const refresh = useRefreshFacts()\n return useMutation({\n mutationFn: (body: CreateFactRequest) =>\n arbi.facts.create(body, { workspaceId: factWorkspace(arbi, workspaceId) || undefined }),\n onSuccess: refresh,\n })\n}\n\n/**\n * Add several facts in one all-or-nothing request (an imported chronology, say) to `workspaceId`,\n * else to the workspace open when it is sent.\n */\nexport function useCreateFacts(workspaceId?: string | null) {\n const arbi = useArbi()\n const refresh = useRefreshFacts()\n return useMutation({\n mutationFn: (body: CreateFactsRequest) =>\n arbi.facts.createBatch(body, { workspaceId: factWorkspace(arbi, workspaceId) || undefined }),\n onSuccess: refresh,\n })\n}\n\n/**\n * Patch a fact. A text edit replaces the fact (the old one is kept as history); `shared` and\n * `confirmed` change in place.\n */\nexport function useUpdateFact() {\n const arbi = useArbi()\n const refresh = useRefreshFacts()\n return useMutation({\n mutationFn: ({ factId, patch }: { factId: string; patch: UpdateFactRequest }) =>\n arbi.facts.update(factId, patch),\n onSuccess: refresh,\n })\n}\n\n/** Delete a fact (only where the server allows it: a refused delete fails with its reason). */\nexport function useDeleteFact() {\n const arbi = useArbi()\n const refresh = useRefreshFacts()\n return useMutation({\n mutationFn: (factId: string) => arbi.facts.delete(factId),\n onSuccess: refresh,\n })\n}\n\n/**\n * Search the facts of `workspaceId` (default: the open one), hybrid by default, as the agent's fact\n * recall does. The workspace is captured when the search is sent and named on the request.\n */\nexport function useSearchFacts(workspaceId?: string | null) {\n const arbi = useArbi()\n return useMutation({\n mutationFn: (body: FactSearchRequest): Promise<FactSearchResponse> =>\n arbi.facts.search(body, { workspaceId: factWorkspace(arbi, workspaceId) || undefined }),\n })\n}\n"],
5
- "mappings": "AASA,SAAS,aAAa,UAAU,sBAAsB;AAUtD,SAAS,eAAe;AACxB,SAAS,qBAAqB;AAG9B,SAAS,cAAc,MAAkC,aAAqC;AAC5F,SAAO,gBAAgB,KAAK,eAAe,KAAK,eAAe,IAAI;AACrE;AAYO,SAAS,SACd,aACA,SACA;AACA,QAAM,OAAO,QAAQ;AACrB,QAAM,EAAE,UAAU,MAAM,GAAG,OAAO,IAAI,WAAW,CAAC;AAClD,QAAM,YAAY,cAAc,MAAM,WAAW;AACjD,SAAO,SAAS;AAAA,IACd,UAAU,cAAc,SAAS,WAAW,MAAM;AAAA;AAAA,IAElD,SAAS,MAA+B,KAAK,MAAM,KAAK,EAAE,GAAG,QAAQ,aAAa,UAAU,CAAC;AAAA,IAC7F,SAAS,WAAW,CAAC,CAAC,aAAa,KAAK;AAAA,IACxC,WAAW;AAAA,EACb,CAAC;AACH;AAGA,SAAS,kBAAkB;AACzB,QAAM,KAAK,eAAe;AAC1B,SAAO,MAAM,GAAG,kBAAkB,EAAE,UAAU,cAAc,SAAS,EAAE,CAAC;AAC1E;AAMO,SAAS,cAAc,aAA6B;AACzD,QAAM,OAAO,QAAQ;AACrB,QAAM,UAAU,gBAAgB;AAChC,SAAO,YAAY;AAAA,IACjB,YAAY,CAAC,SACX,KAAK,MAAM,OAAO,MAAM,EAAE,aAAa,cAAc,MAAM,WAAW,KAAK,OAAU,CAAC;AAAA,IACxF,WAAW;AAAA,EACb,CAAC;AACH;AAMO,SAAS,eAAe,aAA6B;AAC1D,QAAM,OAAO,QAAQ;AACrB,QAAM,UAAU,gBAAgB;AAChC,SAAO,YAAY;AAAA,IACjB,YAAY,CAAC,SACX,KAAK,MAAM,YAAY,MAAM,EAAE,aAAa,cAAc,MAAM,WAAW,KAAK,OAAU,CAAC;AAAA,IAC7F,WAAW;AAAA,EACb,CAAC;AACH;AAMO,SAAS,gBAAgB;AAC9B,QAAM,OAAO,QAAQ;AACrB,QAAM,UAAU,gBAAgB;AAChC,SAAO,YAAY;AAAA,IACjB,YAAY,CAAC,EAAE,QAAQ,MAAM,MAC3B,KAAK,MAAM,OAAO,QAAQ,KAAK;AAAA,IACjC,WAAW;AAAA,EACb,CAAC;AACH;AAGO,SAAS,gBAAgB;AAC9B,QAAM,OAAO,QAAQ;AACrB,QAAM,UAAU,gBAAgB;AAChC,SAAO,YAAY;AAAA,IACjB,YAAY,CAAC,WAAmB,KAAK,MAAM,OAAO,MAAM;AAAA,IACxD,WAAW;AAAA,EACb,CAAC;AACH;AAMO,SAAS,eAAe,aAA6B;AAC1D,QAAM,OAAO,QAAQ;AACrB,SAAO,YAAY;AAAA,IACjB,YAAY,CAAC,SACX,KAAK,MAAM,OAAO,MAAM,EAAE,aAAa,cAAc,MAAM,WAAW,KAAK,OAAU,CAAC;AAAA,EAC1F,CAAC;AACH;",
4
+ "sourcesContent": ["/**\n * Workspace facts (notes): a workspace's list, filtered for the timeline or by tag, the writes\n * (create, batch, patch, delete) and the search. List, create and search name their workspace (the\n * one given, else the open one, captured when they are sent); patch and delete act in the fact's\n * own workspace. Every write refreshes every cached fact list and the workspace's tags \u2014 a fact's\n * tags move the `facttag_count` the Tags page reads from the tag list.\n *\n * Requires an `ArbiHost` (with an `arbi`) and a React Query client above it.\n */\n\nimport { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'\nimport type {\n CreateFactRequest,\n CreateFactsRequest,\n FactResponse,\n FactSearchRequest,\n FactSearchResponse,\n ListFactsOptions,\n UpdateFactRequest,\n} from '@arbidocs/sdk/browser'\nimport { useArbi } from './useArbi'\nimport { arbiQueryKeys } from './hooks'\n\n/** The workspace a fact call names: the one given, else the one open now ('' when none is). */\nfunction factWorkspace(arbi: ReturnType<typeof useArbi>, workspaceId?: string | null): string {\n return workspaceId || (arbi.hasWorkspace ? arbi.getWorkspaceId() : '')\n}\n\n/** What a list asks for: the timeline range, or the notes carrying tags or citing a document. */\nexport type FactListFilter = Pick<\n ListFactsOptions,\n 'from' | 'to' | 'datedOnly' | 'tagExtIds' | 'docExtId'\n>\n\n/**\n * The facts of `workspaceId` (default: the open one), newest first, or the filtered ones\n * (`datedOnly` / a range: the timeline, by date; `tagExtIds`: the notes carrying all those tags).\n */\nexport function useFacts(\n workspaceId?: string | null,\n options?: FactListFilter & { enabled?: boolean }\n) {\n const arbi = useArbi()\n const { enabled = true, ...filter } = options ?? {}\n const workspace = factWorkspace(arbi, workspaceId)\n return useQuery({\n queryKey: arbiQueryKeys.factList(workspace, filter),\n // The request names the workspace, so a switch while it runs cannot answer for another.\n queryFn: (): Promise<FactResponse[]> => arbi.facts.list({ ...filter, workspaceId: workspace }),\n enabled: enabled && !!workspace && arbi.hasWorkspace,\n staleTime: 30_000,\n })\n}\n\n/**\n * Refresh every cached fact list after a write, and the tag lists: a fact's tags move the\n * `facttag_count` the Tags page shows, so the workspace's tags must re-read too.\n */\nfunction useRefreshFacts() {\n const qc = useQueryClient()\n return () =>\n Promise.all([\n qc.invalidateQueries({ queryKey: arbiQueryKeys.allFacts() }),\n qc.invalidateQueries({ queryKey: arbiQueryKeys.allTags() }),\n ])\n}\n\n/**\n * Add a fact (by hand it is confirmed: typing it is the vouch) to `workspaceId` (the message's or\n * the page's), else to the workspace open when it is sent.\n */\nexport function useCreateFact(workspaceId?: string | null) {\n const arbi = useArbi()\n const refresh = useRefreshFacts()\n return useMutation({\n mutationFn: (body: CreateFactRequest) =>\n arbi.facts.create(body, { workspaceId: factWorkspace(arbi, workspaceId) || undefined }),\n onSuccess: refresh,\n })\n}\n\n/**\n * Add several facts in one all-or-nothing request (an imported chronology, say) to `workspaceId`,\n * else to the workspace open when it is sent.\n */\nexport function useCreateFacts(workspaceId?: string | null) {\n const arbi = useArbi()\n const refresh = useRefreshFacts()\n return useMutation({\n mutationFn: (body: CreateFactsRequest) =>\n arbi.facts.createBatch(body, { workspaceId: factWorkspace(arbi, workspaceId) || undefined }),\n onSuccess: refresh,\n })\n}\n\n/**\n * Patch a fact. A text edit replaces the fact (the old one is kept as history); `shared` and\n * `confirmed` change in place.\n */\nexport function useUpdateFact() {\n const arbi = useArbi()\n const refresh = useRefreshFacts()\n return useMutation({\n mutationFn: ({ factId, patch }: { factId: string; patch: UpdateFactRequest }) =>\n arbi.facts.update(factId, patch),\n onSuccess: refresh,\n })\n}\n\n/** Delete a fact (only where the server allows it: a refused delete fails with its reason). */\nexport function useDeleteFact() {\n const arbi = useArbi()\n const refresh = useRefreshFacts()\n return useMutation({\n mutationFn: (factId: string) => arbi.facts.delete(factId),\n onSuccess: refresh,\n })\n}\n\n/**\n * Search the facts of `workspaceId` (default: the open one), hybrid by default, as the agent's fact\n * recall does. The workspace is captured when the search is sent and named on the request.\n */\nexport function useSearchFacts(workspaceId?: string | null) {\n const arbi = useArbi()\n return useMutation({\n mutationFn: (body: FactSearchRequest): Promise<FactSearchResponse> =>\n arbi.facts.search(body, { workspaceId: factWorkspace(arbi, workspaceId) || undefined }),\n })\n}\n"],
5
+ "mappings": "AAUA,SAAS,aAAa,UAAU,sBAAsB;AAUtD,SAAS,eAAe;AACxB,SAAS,qBAAqB;AAG9B,SAAS,cAAc,MAAkC,aAAqC;AAC5F,SAAO,gBAAgB,KAAK,eAAe,KAAK,eAAe,IAAI;AACrE;AAYO,SAAS,SACd,aACA,SACA;AACA,QAAM,OAAO,QAAQ;AACrB,QAAM,EAAE,UAAU,MAAM,GA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AAC9B,QAAM,OAAO,QAAQ;AACrB,QAAM,UAAU,gBAAgB;AAChC,SAAO,YAAY;AAAA,IACjB,YAAY,CAAC,WAAmB,KAAK,MAAM,OAAO,MAAM;AAAA,IACxD,WAAW;AAAA,EACb,CAAC;AACH;AAMO,SAAS,eAAe,aAA6B;AAC1D,QAAM,OAAO,QAAQ;AACrB,SAAO,YAAY;AAAA,IACjB,YAAY,CAAC,SACX,KAAK,MAAM,OAAO,MAAM,EAAE,aAAa,cAAc,MAAM,WAAW,KAAK,OAAU,CAAC;AAAA,EAC1F,CAAC;AACH;",
6
6
  "names": []
7
7
  }
package/dist/index.cjs CHANGED
@@ -9687,7 +9687,10 @@ function useFacts(workspaceId, options) {
9687
9687
  }
9688
9688
  function useRefreshFacts() {
9689
9689
  const qc = reactQuery.useQueryClient();
9690
- return () => qc.invalidateQueries({ queryKey: chunkFE6ZSNZE_cjs.arbiQueryKeys.allFacts() });
9690
+ return () => Promise.all([
9691
+ qc.invalidateQueries({ queryKey: chunkFE6ZSNZE_cjs.arbiQueryKeys.allFacts() }),
9692
+ qc.invalidateQueries({ queryKey: chunkFE6ZSNZE_cjs.arbiQueryKeys.allTags() })
9693
+ ]);
9691
9694
  }
9692
9695
  function useCreateFact(workspaceId) {
9693
9696
  const arbi = chunkFE6ZSNZE_cjs.useArbi();