@ai-matrx/associations 0.10.7 → 0.11.0

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/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # Changelog — @ai-matrx/associations
2
2
 
3
+ ## 0.11.0
4
+
5
+ **Filed-under mode** — `direction: "outgoing"` on the primary entity. A thing that is filed under
6
+ containers (a Source under a project, a research topic, a Library) is now a first-class primary:
7
+
8
+ * `PrimaryEntity` is `PrimaryContainerEntity` (the default, `direction?: "incoming"`, a container
9
+ TARGET type — unchanged) or `PrimaryFiledEntity` (`direction: "outgoing"`, any registered token).
10
+ * `useContainerLinks({ …, direction: "outgoing" })` lists the primary's OUTGOING edges (the
11
+ containers it is filed under); `attach` writes `primary → container` as the same role-less edge
12
+ the landing door writes; `detach` / `setPinned` address that edge. A token that is not a
13
+ container type is refused before any write ("… cannot be filed under").
14
+ * `containerLinksArgs(primary)` — the one mapping the faces use, so the direction is never dropped.
15
+ * `AssociationCardGrid` / `AssociationCard` / `AssociationList` / `AttachedItemsSheet` /
16
+ `AssociationPicker` honour it: only container types are offered, counts read "N filed under",
17
+ the picker header reads "File X under a …" (`AssociationPickerProps.filing`).
18
+ * New root export `isAssociationTargetType` and type `AssociationDirection`.
19
+
20
+ Consumer action: none for containers. To show what an entity is filed under, pass
21
+ `{ type, id, orgId, label, direction: "outgoing" }` to `PrimaryEntityProvider`.
22
+
3
23
  ## 0.10.7
4
24
 
5
25
  Regenerated the entity vocabulary from the live registry (998 active tokens):
@@ -595,6 +595,11 @@ interface AssociationPickerProps {
595
595
  ok: boolean;
596
596
  error?: string;
597
597
  }>;
598
+ /**
599
+ * Filed-under mode: the primary is being FILED UNDER the picked items
600
+ * (`primary → item`), so the header says "File … under" not "Attach to".
601
+ */
602
+ filing?: boolean;
598
603
  }
599
604
  /** Per-token picker override map — absent tokens use the generic picker sheet. */
600
605
  type PickerOverrideMap = Partial<Record<EntityTypeToken, ComponentType<AssociationPickerProps>>>;
@@ -1445,6 +1450,37 @@ declare function useAssociations(args: UseAssociationsArgs): UseAssociationsRetu
1445
1450
  */
1446
1451
  declare const useEntityRelationships: typeof useAssociations;
1447
1452
 
1453
+ interface PrimaryEntityBase {
1454
+ id: string;
1455
+ /** Org to stamp on edges created here (org-scoped RLS / counts). */
1456
+ orgId?: string | null;
1457
+ /** Human label for headings (e.g. the org/scope name). */
1458
+ label?: string;
1459
+ }
1460
+ /** A container: its surfaces list what is attached INTO it (the default). */
1461
+ interface PrimaryContainerEntity extends PrimaryEntityBase {
1462
+ /** Container token — must be an association TARGET type. */
1463
+ type: AssociationTargetType;
1464
+ direction?: "incoming";
1465
+ }
1466
+ /**
1467
+ * A thing FILED UNDER containers (e.g. a Source under a project): its
1468
+ * surfaces list its own outgoing edges and "+" files it under a container.
1469
+ */
1470
+ interface PrimaryFiledEntity extends PrimaryEntityBase {
1471
+ /** Any registered entity type — it is the edge SOURCE. */
1472
+ type: EntityTypeToken;
1473
+ direction: "outgoing";
1474
+ }
1475
+ /** The primary entity a surface is anchored to. */
1476
+ type PrimaryEntity = PrimaryContainerEntity | PrimaryFiledEntity;
1477
+ declare function PrimaryEntityProvider({ value, children, }: {
1478
+ value: PrimaryEntity;
1479
+ children: ReactNode;
1480
+ }): react.JSX.Element;
1481
+ /** Read the surrounding primary entity, or null when unprovided. */
1482
+ declare function usePrimaryEntity(): PrimaryEntity | null;
1483
+
1448
1484
  interface ContainerLink {
1449
1485
  /** The edge id (for keys / removal). */
1450
1486
  edgeId: string;
@@ -1458,13 +1494,25 @@ interface ContainerLink {
1458
1494
  /** Per-edge props from `platform.associations.metadata` (e.g. representation). */
1459
1495
  metadata: unknown;
1460
1496
  }
1461
- interface UseContainerLinksArgs {
1462
- /** The primary entity — always an association TARGET (container). */
1463
- containerType: AssociationTargetType;
1497
+ interface UseContainerLinksBase {
1464
1498
  containerId: string | null;
1465
1499
  /** Org to stamp on new edges (for org-scoped RLS / counts). */
1466
1500
  orgId?: string | null;
1467
1501
  }
1502
+ /**
1503
+ * `incoming` (default): the primary is a container (edge TARGET) — links are
1504
+ * what is attached into it. `outgoing`: the primary is filed under containers
1505
+ * (edge SOURCE) — links are the containers it is filed under, and `attach`
1506
+ * writes `primary → container` (the same role-less edge the landing door
1507
+ * writes), refusing tokens that are not container types.
1508
+ */
1509
+ type UseContainerLinksArgs = (UseContainerLinksBase & {
1510
+ containerType: AssociationTargetType;
1511
+ direction?: "incoming";
1512
+ }) | (UseContainerLinksBase & {
1513
+ containerType: EntityTypeToken;
1514
+ direction: "outgoing";
1515
+ });
1468
1516
  interface UseContainerLinksReturn {
1469
1517
  status: ReturnType<typeof useAssociations>["status"];
1470
1518
  error: string | null;
@@ -1496,6 +1544,11 @@ interface UseContainerLinksReturn {
1496
1544
  setPinned: (token: EntityTypeToken, resourceId: string, pinned: boolean, role?: string) => Promise<AssociationWriteResult>;
1497
1545
  }
1498
1546
  declare function useContainerLinks(args: UseContainerLinksArgs): UseContainerLinksReturn;
1547
+ /**
1548
+ * `useContainerLinks` args for a surface's primary entity — the ONE mapping
1549
+ * the faces (card, list) use, so a primary's direction is never dropped.
1550
+ */
1551
+ declare function containerLinksArgs(container: PrimaryEntity | null): UseContainerLinksArgs;
1499
1552
 
1500
1553
  interface AssociationEntitySelectItem {
1501
1554
  id: string;
@@ -1543,23 +1596,6 @@ interface UseAssociationEntitySelectAdapterArgs {
1543
1596
  }
1544
1597
  declare function useAssociationEntitySelectAdapter(args: UseAssociationEntitySelectAdapterArgs): AssociationEntitySelectAdapter;
1545
1598
 
1546
- /** The primary (container) entity a surface is anchored to. */
1547
- interface PrimaryEntity {
1548
- /** Container token — must be an association TARGET type. */
1549
- type: AssociationTargetType;
1550
- id: string;
1551
- /** Org to stamp on edges created here (org-scoped RLS / counts). */
1552
- orgId?: string | null;
1553
- /** Human label for headings (e.g. the org/scope name). */
1554
- label?: string;
1555
- }
1556
- declare function PrimaryEntityProvider({ value, children, }: {
1557
- value: PrimaryEntity;
1558
- children: ReactNode;
1559
- }): react.JSX.Element;
1560
- /** Read the surrounding primary entity, or null when unprovided. */
1561
- declare function usePrimaryEntity(): PrimaryEntity | null;
1562
-
1563
1599
  interface AssociationWindowProps {
1564
1600
  /** Controls mount — callers should also gate their JSX on this. */
1565
1601
  open: boolean;
@@ -1927,4 +1963,4 @@ declare function buildCommentTree(comments: readonly PlatformComment[]): {
1927
1963
  };
1928
1964
  declare function CommentThread({ token, id, orgId, showHeader, className, }: CommentThreadProps): react.JSX.Element;
1929
1965
 
1930
- export { DefaultEntityIcon as $, type AssociationCaptureToolbarProps as A, AssociationCaptureToolbar as B, type CategorySelectProps as C, AssociationCard as D, type EntityDoorsPort as E, AssociationCardGrid as F, AssociationEntitySelect as G, type AssociationEntitySelectAdapter as H, type AssociationEntitySelectItem as I, AssociationList as J, AssociationWindow as K, type AssociationWriteResult as L, AttachedItemsSheet as M, type CaptureAttach as N, type CaptureAttachResult as O, type PickerOverrideMap as P, CaptureToolbarAction as Q, CategorySelect as R, CategoryTagPicker as S, CommentComposer as T, type UniversalAssociationPickerProps as U, type CommentComposerProps as V, type WindowShellPort as W, CommentThread as X, type ContainerLink as Y, type ContainerResourceRow as Z, type ContainerResourcesAdapter as _, type AssociationCardProps as a, type PrimaryEntity as a0, PrimaryEntityProvider as a1, type TagPickerIcon as a2, UniversalAssociationPicker as a3, type UseAssociationEntitySelectAdapterArgs as a4, type UseAssociationsArgs as a5, type UseAssociationsReturn as a6, type UseContainerLinksArgs as a7, type UseContainerLinksReturn as a8, attachedKey as a9, buildCommentTree as aa, useAssociationEntitySelectAdapter as ab, useAssociations as ac, useContainerLinks as ad, useContainerLinksAdapter as ae, useEntityRelationships as af, usePrimaryEntity as ag, type AssociationCardGridProps as b, type AssociationEntitySelectProps as c, type AssociationListProps as d, type AssociationPickerProps as e, type AssociationWindowProps as f, type AttachedItemsSheetProps as g, type CategoryTagPickerProps as h, type CommentThreadProps as i, type AssociationsNotifier as j, type CapturePort as k, type AuthorDisplayPort as l, type AssociationsStore as m, type CategoryMutationResult as n, type CategoryDimension as o, type PlatformCategory as p, type CategoriesEntry as q, type EntityTypeToken as r, type UniversalCandidate as s, type CandidateRecord as t, type PlatformComment as u, type CommentsEntry as v, type CommentMutationResult as w, type EntityDoorProps as x, type EntityRefProps as y, type ContentRole as z };
1966
+ export { DefaultEntityIcon as $, type AssociationCaptureToolbarProps as A, AssociationCaptureToolbar as B, type CategorySelectProps as C, AssociationCard as D, type EntityDoorsPort as E, AssociationCardGrid as F, AssociationEntitySelect as G, type AssociationEntitySelectAdapter as H, type AssociationEntitySelectItem as I, AssociationList as J, AssociationWindow as K, type AssociationWriteResult as L, AttachedItemsSheet as M, type CaptureAttach as N, type CaptureAttachResult as O, type PickerOverrideMap as P, CaptureToolbarAction as Q, CategorySelect as R, CategoryTagPicker as S, CommentComposer as T, type UniversalAssociationPickerProps as U, type CommentComposerProps as V, type WindowShellPort as W, CommentThread as X, type ContainerLink as Y, type ContainerResourceRow as Z, type ContainerResourcesAdapter as _, type AssociationCardProps as a, type PrimaryContainerEntity as a0, type PrimaryEntity as a1, PrimaryEntityProvider as a2, type PrimaryFiledEntity as a3, type TagPickerIcon as a4, UniversalAssociationPicker as a5, type UseAssociationEntitySelectAdapterArgs as a6, type UseAssociationsArgs as a7, type UseAssociationsReturn as a8, type UseContainerLinksArgs as a9, type UseContainerLinksReturn as aa, attachedKey as ab, buildCommentTree as ac, containerLinksArgs as ad, useAssociationEntitySelectAdapter as ae, useAssociations as af, useContainerLinks as ag, useContainerLinksAdapter as ah, useEntityRelationships as ai, usePrimaryEntity as aj, type AssociationCardGridProps as b, type AssociationEntitySelectProps as c, type AssociationListProps as d, type AssociationPickerProps as e, type AssociationWindowProps as f, type AttachedItemsSheetProps as g, type CategoryTagPickerProps as h, type CommentThreadProps as i, type AssociationsNotifier as j, type CapturePort as k, type AuthorDisplayPort as l, type AssociationsStore as m, type CategoryMutationResult as n, type CategoryDimension as o, type PlatformCategory as p, type CategoriesEntry as q, type EntityTypeToken as r, type UniversalCandidate as s, type CandidateRecord as t, type PlatformComment as u, type CommentsEntry as v, type CommentMutationResult as w, type EntityDoorProps as x, type EntityRefProps as y, type ContentRole as z };
@@ -595,6 +595,11 @@ interface AssociationPickerProps {
595
595
  ok: boolean;
596
596
  error?: string;
597
597
  }>;
598
+ /**
599
+ * Filed-under mode: the primary is being FILED UNDER the picked items
600
+ * (`primary → item`), so the header says "File … under" not "Attach to".
601
+ */
602
+ filing?: boolean;
598
603
  }
599
604
  /** Per-token picker override map — absent tokens use the generic picker sheet. */
600
605
  type PickerOverrideMap = Partial<Record<EntityTypeToken, ComponentType<AssociationPickerProps>>>;
@@ -1445,6 +1450,37 @@ declare function useAssociations(args: UseAssociationsArgs): UseAssociationsRetu
1445
1450
  */
1446
1451
  declare const useEntityRelationships: typeof useAssociations;
1447
1452
 
1453
+ interface PrimaryEntityBase {
1454
+ id: string;
1455
+ /** Org to stamp on edges created here (org-scoped RLS / counts). */
1456
+ orgId?: string | null;
1457
+ /** Human label for headings (e.g. the org/scope name). */
1458
+ label?: string;
1459
+ }
1460
+ /** A container: its surfaces list what is attached INTO it (the default). */
1461
+ interface PrimaryContainerEntity extends PrimaryEntityBase {
1462
+ /** Container token — must be an association TARGET type. */
1463
+ type: AssociationTargetType;
1464
+ direction?: "incoming";
1465
+ }
1466
+ /**
1467
+ * A thing FILED UNDER containers (e.g. a Source under a project): its
1468
+ * surfaces list its own outgoing edges and "+" files it under a container.
1469
+ */
1470
+ interface PrimaryFiledEntity extends PrimaryEntityBase {
1471
+ /** Any registered entity type — it is the edge SOURCE. */
1472
+ type: EntityTypeToken;
1473
+ direction: "outgoing";
1474
+ }
1475
+ /** The primary entity a surface is anchored to. */
1476
+ type PrimaryEntity = PrimaryContainerEntity | PrimaryFiledEntity;
1477
+ declare function PrimaryEntityProvider({ value, children, }: {
1478
+ value: PrimaryEntity;
1479
+ children: ReactNode;
1480
+ }): react.JSX.Element;
1481
+ /** Read the surrounding primary entity, or null when unprovided. */
1482
+ declare function usePrimaryEntity(): PrimaryEntity | null;
1483
+
1448
1484
  interface ContainerLink {
1449
1485
  /** The edge id (for keys / removal). */
1450
1486
  edgeId: string;
@@ -1458,13 +1494,25 @@ interface ContainerLink {
1458
1494
  /** Per-edge props from `platform.associations.metadata` (e.g. representation). */
1459
1495
  metadata: unknown;
1460
1496
  }
1461
- interface UseContainerLinksArgs {
1462
- /** The primary entity — always an association TARGET (container). */
1463
- containerType: AssociationTargetType;
1497
+ interface UseContainerLinksBase {
1464
1498
  containerId: string | null;
1465
1499
  /** Org to stamp on new edges (for org-scoped RLS / counts). */
1466
1500
  orgId?: string | null;
1467
1501
  }
1502
+ /**
1503
+ * `incoming` (default): the primary is a container (edge TARGET) — links are
1504
+ * what is attached into it. `outgoing`: the primary is filed under containers
1505
+ * (edge SOURCE) — links are the containers it is filed under, and `attach`
1506
+ * writes `primary → container` (the same role-less edge the landing door
1507
+ * writes), refusing tokens that are not container types.
1508
+ */
1509
+ type UseContainerLinksArgs = (UseContainerLinksBase & {
1510
+ containerType: AssociationTargetType;
1511
+ direction?: "incoming";
1512
+ }) | (UseContainerLinksBase & {
1513
+ containerType: EntityTypeToken;
1514
+ direction: "outgoing";
1515
+ });
1468
1516
  interface UseContainerLinksReturn {
1469
1517
  status: ReturnType<typeof useAssociations>["status"];
1470
1518
  error: string | null;
@@ -1496,6 +1544,11 @@ interface UseContainerLinksReturn {
1496
1544
  setPinned: (token: EntityTypeToken, resourceId: string, pinned: boolean, role?: string) => Promise<AssociationWriteResult>;
1497
1545
  }
1498
1546
  declare function useContainerLinks(args: UseContainerLinksArgs): UseContainerLinksReturn;
1547
+ /**
1548
+ * `useContainerLinks` args for a surface's primary entity — the ONE mapping
1549
+ * the faces (card, list) use, so a primary's direction is never dropped.
1550
+ */
1551
+ declare function containerLinksArgs(container: PrimaryEntity | null): UseContainerLinksArgs;
1499
1552
 
1500
1553
  interface AssociationEntitySelectItem {
1501
1554
  id: string;
@@ -1543,23 +1596,6 @@ interface UseAssociationEntitySelectAdapterArgs {
1543
1596
  }
1544
1597
  declare function useAssociationEntitySelectAdapter(args: UseAssociationEntitySelectAdapterArgs): AssociationEntitySelectAdapter;
1545
1598
 
1546
- /** The primary (container) entity a surface is anchored to. */
1547
- interface PrimaryEntity {
1548
- /** Container token — must be an association TARGET type. */
1549
- type: AssociationTargetType;
1550
- id: string;
1551
- /** Org to stamp on edges created here (org-scoped RLS / counts). */
1552
- orgId?: string | null;
1553
- /** Human label for headings (e.g. the org/scope name). */
1554
- label?: string;
1555
- }
1556
- declare function PrimaryEntityProvider({ value, children, }: {
1557
- value: PrimaryEntity;
1558
- children: ReactNode;
1559
- }): react.JSX.Element;
1560
- /** Read the surrounding primary entity, or null when unprovided. */
1561
- declare function usePrimaryEntity(): PrimaryEntity | null;
1562
-
1563
1599
  interface AssociationWindowProps {
1564
1600
  /** Controls mount — callers should also gate their JSX on this. */
1565
1601
  open: boolean;
@@ -1927,4 +1963,4 @@ declare function buildCommentTree(comments: readonly PlatformComment[]): {
1927
1963
  };
1928
1964
  declare function CommentThread({ token, id, orgId, showHeader, className, }: CommentThreadProps): react.JSX.Element;
1929
1965
 
1930
- export { DefaultEntityIcon as $, type AssociationCaptureToolbarProps as A, AssociationCaptureToolbar as B, type CategorySelectProps as C, AssociationCard as D, type EntityDoorsPort as E, AssociationCardGrid as F, AssociationEntitySelect as G, type AssociationEntitySelectAdapter as H, type AssociationEntitySelectItem as I, AssociationList as J, AssociationWindow as K, type AssociationWriteResult as L, AttachedItemsSheet as M, type CaptureAttach as N, type CaptureAttachResult as O, type PickerOverrideMap as P, CaptureToolbarAction as Q, CategorySelect as R, CategoryTagPicker as S, CommentComposer as T, type UniversalAssociationPickerProps as U, type CommentComposerProps as V, type WindowShellPort as W, CommentThread as X, type ContainerLink as Y, type ContainerResourceRow as Z, type ContainerResourcesAdapter as _, type AssociationCardProps as a, type PrimaryEntity as a0, PrimaryEntityProvider as a1, type TagPickerIcon as a2, UniversalAssociationPicker as a3, type UseAssociationEntitySelectAdapterArgs as a4, type UseAssociationsArgs as a5, type UseAssociationsReturn as a6, type UseContainerLinksArgs as a7, type UseContainerLinksReturn as a8, attachedKey as a9, buildCommentTree as aa, useAssociationEntitySelectAdapter as ab, useAssociations as ac, useContainerLinks as ad, useContainerLinksAdapter as ae, useEntityRelationships as af, usePrimaryEntity as ag, type AssociationCardGridProps as b, type AssociationEntitySelectProps as c, type AssociationListProps as d, type AssociationPickerProps as e, type AssociationWindowProps as f, type AttachedItemsSheetProps as g, type CategoryTagPickerProps as h, type CommentThreadProps as i, type AssociationsNotifier as j, type CapturePort as k, type AuthorDisplayPort as l, type AssociationsStore as m, type CategoryMutationResult as n, type CategoryDimension as o, type PlatformCategory as p, type CategoriesEntry as q, type EntityTypeToken as r, type UniversalCandidate as s, type CandidateRecord as t, type PlatformComment as u, type CommentsEntry as v, type CommentMutationResult as w, type EntityDoorProps as x, type EntityRefProps as y, type ContentRole as z };
1966
+ export { DefaultEntityIcon as $, type AssociationCaptureToolbarProps as A, AssociationCaptureToolbar as B, type CategorySelectProps as C, AssociationCard as D, type EntityDoorsPort as E, AssociationCardGrid as F, AssociationEntitySelect as G, type AssociationEntitySelectAdapter as H, type AssociationEntitySelectItem as I, AssociationList as J, AssociationWindow as K, type AssociationWriteResult as L, AttachedItemsSheet as M, type CaptureAttach as N, type CaptureAttachResult as O, type PickerOverrideMap as P, CaptureToolbarAction as Q, CategorySelect as R, CategoryTagPicker as S, CommentComposer as T, type UniversalAssociationPickerProps as U, type CommentComposerProps as V, type WindowShellPort as W, CommentThread as X, type ContainerLink as Y, type ContainerResourceRow as Z, type ContainerResourcesAdapter as _, type AssociationCardProps as a, type PrimaryContainerEntity as a0, type PrimaryEntity as a1, PrimaryEntityProvider as a2, type PrimaryFiledEntity as a3, type TagPickerIcon as a4, UniversalAssociationPicker as a5, type UseAssociationEntitySelectAdapterArgs as a6, type UseAssociationsArgs as a7, type UseAssociationsReturn as a8, type UseContainerLinksArgs as a9, type UseContainerLinksReturn as aa, attachedKey as ab, buildCommentTree as ac, containerLinksArgs as ad, useAssociationEntitySelectAdapter as ae, useAssociations as af, useContainerLinks as ag, useContainerLinksAdapter as ah, useEntityRelationships as ai, usePrimaryEntity as aj, type AssociationCardGridProps as b, type AssociationEntitySelectProps as c, type AssociationListProps as d, type AssociationPickerProps as e, type AssociationWindowProps as f, type AttachedItemsSheetProps as g, type CategoryTagPickerProps as h, type CommentThreadProps as i, type AssociationsNotifier as j, type CapturePort as k, type AuthorDisplayPort as l, type AssociationsStore as m, type CategoryMutationResult as n, type CategoryDimension as o, type PlatformCategory as p, type CategoriesEntry as q, type EntityTypeToken as r, type UniversalCandidate as s, type CandidateRecord as t, type PlatformComment as u, type CommentsEntry as v, type CommentMutationResult as w, type EntityDoorProps as x, type EntityRefProps as y, type ContentRole as z };
package/dist/index.cjs CHANGED
@@ -26,6 +26,7 @@ __export(src_exports, {
26
26
  ENTITY_TYPE_TOKENS: () => ENTITY_TYPE_TOKENS,
27
27
  REFERENCE_CATEGORY_DISPLAY: () => REFERENCE_CATEGORY_DISPLAY,
28
28
  SCHEMA_DISPLAY: () => SCHEMA_DISPLAY,
29
+ isAssociationTargetType: () => isAssociationTargetType,
29
30
  isAssociationsRpcErr: () => isAssociationsRpcErr,
30
31
  isEntityTypeToken: () => isEntityTypeToken
31
32
  });
@@ -2140,6 +2141,9 @@ var ASSOCIATION_TARGET_TYPES = [
2140
2141
  "rulebook"
2141
2142
  // a Masterwork Rulebook — its Scout interviews attach here (conversation→rulebook, role 'interview')
2142
2143
  ];
2144
+ function isAssociationTargetType(value) {
2145
+ return typeof value === "string" && ASSOCIATION_TARGET_TYPES.includes(value);
2146
+ }
2143
2147
 
2144
2148
  // src/results.ts
2145
2149
  function isAssociationsRpcErr(r) {