@ai-matrx/associations 0.3.0 → 0.5.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.
@@ -1,4 +1,4 @@
1
- import { EntityOverlayMap, EntityTypeToken, EntityOverlayEntry, ErrorSink, AssociationsRpcError, AssociationsDataSource, AssociationsIdentity, AssociationTargetType, AssociationsRpcResult, AssociationEdge, AssociationTargetEdge, AssociationSourceEdge, CategoryDimension, PlatformCategory, UserStateKind, UserEntityState, AssociationsEntry, CategoriesEntry, AssociationsConfig } from '../index.cjs';
1
+ import { EntityOverlayMap, EntityTypeToken, EntityOverlayEntry, ErrorSink, AssociationsRpcError, AssociationsDataSource, AssociationsIdentity, AssociationTargetType, AssociationsRpcResult, AssociationEdge, AssociationTargetEdge, AssociationSourceEdge, CategoryDimension, PlatformCategory, UserStateKind, UserEntityState, PlatformComment, AssociationsEntry, CategoriesEntry, CommentsEntry, AssociationsConfig } from '../index.cjs';
2
2
  import 'react';
3
3
 
4
4
  /** The universal ownership column post-2026-reorg. */
@@ -474,6 +474,28 @@ interface AssociationHelpersApi {
474
474
  }
475
475
  declare function createAssociationHelpers(service: AssociationsServiceApi): AssociationHelpersApi;
476
476
 
477
+ interface AddCommentArgs {
478
+ /** Registered entity-type token the comment hangs on (writes-strict, C18). */
479
+ entityType: string;
480
+ entityId: string;
481
+ body: string;
482
+ /** Reply target — an existing comment's id. Top-level when omitted. */
483
+ parentId?: string | null;
484
+ /** Org override; the RPC resolves task-org/personal-org when omitted. */
485
+ orgId?: string | null;
486
+ }
487
+ interface CommentsServiceApi {
488
+ listForEntity(entityType: string, entityId: string): Promise<AssociationsRpcResult<{
489
+ comments: PlatformComment[];
490
+ }>>;
491
+ add(args: AddCommentArgs): Promise<AssociationsRpcResult<{
492
+ id: string;
493
+ }>>;
494
+ edit(id: string, body: string): Promise<AssociationsRpcResult<null>>;
495
+ remove(id: string): Promise<AssociationsRpcResult<null>>;
496
+ }
497
+ declare function createCommentsService(deps: CoreDeps): CommentsServiceApi;
498
+
477
499
  /** Cache key for one association endpoint. */
478
500
  declare function associationsKey(type: string, id: string): string;
479
501
  interface AssociationWriteResult {
@@ -488,6 +510,12 @@ interface CategoryMutationResult {
488
510
  id?: string;
489
511
  error?: string;
490
512
  }
513
+ interface CommentMutationResult {
514
+ ok: boolean;
515
+ /** Set on a successful `addComment`. */
516
+ id?: string;
517
+ error?: string;
518
+ }
491
519
  interface AssociationsStore {
492
520
  /** Stable, sync read of one endpoint's entry (idle default when uncached). */
493
521
  getEdges(type: string, id: string): AssociationsEntry;
@@ -531,7 +559,7 @@ interface AssociationsStore {
531
559
  }): Promise<AssociationWriteResult>;
532
560
  /** Reset one endpoint to idle and notify its subscribers. */
533
561
  invalidate(type: string, id: string): void;
534
- /** Reset every association endpoint AND every category facet. */
562
+ /** Reset every association endpoint, category facet, and comment thread. */
535
563
  invalidateAll(): void;
536
564
  getCategories(dimension: CategoryDimension): CategoriesEntry;
537
565
  loadCategories(dimension: CategoryDimension, opts?: {
@@ -566,6 +594,41 @@ interface AssociationsStore {
566
594
  dimension: CategoryDimension;
567
595
  id: string;
568
596
  }): Promise<CategoryMutationResult>;
597
+ /** Stable, sync read of one entity's comment thread (idle when uncached). */
598
+ getComments(type: string, id: string): CommentsEntry;
599
+ /**
600
+ * Lazy load of every comment on `${type}:${id}` (oldest→newest; thread by
601
+ * `parentId`). Deduped per key; `status === "ready"` short-circuits unless
602
+ * `force`.
603
+ */
604
+ loadComments(type: string, id: string, opts?: {
605
+ force?: boolean;
606
+ }): Promise<void>;
607
+ /** External-store contract for one entity's comment thread. */
608
+ subscribeComments(key: string, cb: () => void): () => void;
609
+ /** Post a comment (or a reply); on success force-reloads the thread. */
610
+ addComment(args: {
611
+ entityType: string;
612
+ entityId: string;
613
+ body: string;
614
+ parentId?: string | null;
615
+ orgId?: string | null;
616
+ }): Promise<CommentMutationResult>;
617
+ /** Edit a comment body (author-only in the RPC); reloads the thread. */
618
+ editComment(args: {
619
+ entityType: string;
620
+ entityId: string;
621
+ id: string;
622
+ body: string;
623
+ }): Promise<CommentMutationResult>;
624
+ /** Soft-delete a comment (author/org member in the RPC); reloads the thread. */
625
+ deleteComment(args: {
626
+ entityType: string;
627
+ entityId: string;
628
+ id: string;
629
+ }): Promise<CommentMutationResult>;
630
+ /** Reset one entity's comment thread to idle and notify its subscribers. */
631
+ invalidateComments(type: string, id: string): void;
569
632
  /** Batched title resolution + the session cache + prime. */
570
633
  titles: TitlesServiceApi;
571
634
  /** Per-user favorite/pinned/hidden state (`ues_*`). */
@@ -586,6 +649,7 @@ interface AssociationsStore {
586
649
  services: {
587
650
  associations: AssociationsServiceApi;
588
651
  categories: CategoriesServiceApi;
652
+ comments: CommentsServiceApi;
589
653
  };
590
654
  /** Merge more host overlay entries in (icons/routes/candidate loaders). */
591
655
  registerEntityOverlay: EntityRegistry["registerEntityOverlay"];
@@ -658,4 +722,22 @@ declare function isMembershipMetadata(metadata: unknown): boolean;
658
722
  */
659
723
  declare function isContentSourceEdge(sourceType: string, metadata?: unknown): boolean;
660
724
 
661
- export { type AddAssociationArgs, type AssertDemandedSchemaOptions, type AssociationGuards, type AssociationHelpersApi, type AssociationWriteResult, type AssociationsServiceApi, type AssociationsStore, type CandidateRecord, type CandidatesResult, type CandidatesServiceApi, type CategoriesServiceApi, type CategoryMutationResult, type ContainerRef, type ContentRole, type ConversationFileLink, type CoreDeps, type CreateEntityRowArgs, DEFAULT_ORG_COLUMN, DEFAULT_OWNER_COLUMN, type DemandedSchemaReport, type EdgeAttrs, type EdgeSpec, type EntityInfo, type EntityRef, type EntityRegistry, type EntityRowResult, type EntityRowsServiceApi, type FavoritesServiceApi, type ListCandidatesArgs, NON_CONTENT_SOURCE_TYPES, type PgErrorMapper, type RpcResultHelpers, SELF_TEST_MISSING_RPC, type SearchAcrossTokensArgs, type TitlesServiceApi, type UniversalCandidate, assertDemandedSchema, associationsKey, createAssociationGuards, createAssociationHelpers, createAssociationsService, createAssociationsStore, createCandidatesService, createCategoriesService, createEntityRegistry, createEntityRowsService, createFavoritesService, createRpcResultHelpers, createTitlesService, entityTitleCacheKey, err, firstError, isContentRole, isContentSourceEdge, isMembershipMetadata, isTransportFailure, isUuid, ok, resolveEntityToken };
725
+ interface CategoryHierarchyItem {
726
+ category: PlatformCategory;
727
+ depth: 0 | 1;
728
+ parent: PlatformCategory | null;
729
+ displayName: string;
730
+ }
731
+ interface CategoryHierarchy {
732
+ items: CategoryHierarchyItem[];
733
+ roots: PlatformCategory[];
734
+ hasHierarchy: boolean;
735
+ }
736
+ /**
737
+ * Turns the RPC's ordered flat rows into the canonical two-level display order.
738
+ * Flat facets retain their exact input order. Invalid/orphaned rows remain
739
+ * visible at the root; the database guard prevents new ones from being made.
740
+ */
741
+ declare function buildCategoryHierarchy(categories: PlatformCategory[]): CategoryHierarchy;
742
+
743
+ export { type AddAssociationArgs, type AddCommentArgs, type AssertDemandedSchemaOptions, type AssociationGuards, type AssociationHelpersApi, type AssociationWriteResult, type AssociationsServiceApi, type AssociationsStore, type CandidateRecord, type CandidatesResult, type CandidatesServiceApi, type CategoriesServiceApi, type CategoryHierarchy, type CategoryHierarchyItem, type CategoryMutationResult, type CommentMutationResult, type CommentsServiceApi, type ContainerRef, type ContentRole, type ConversationFileLink, type CoreDeps, type CreateEntityRowArgs, DEFAULT_ORG_COLUMN, DEFAULT_OWNER_COLUMN, type DemandedSchemaReport, type EdgeAttrs, type EdgeSpec, type EntityInfo, type EntityRef, type EntityRegistry, type EntityRowResult, type EntityRowsServiceApi, type FavoritesServiceApi, type ListCandidatesArgs, NON_CONTENT_SOURCE_TYPES, type PgErrorMapper, type RpcResultHelpers, SELF_TEST_MISSING_RPC, type SearchAcrossTokensArgs, type TitlesServiceApi, type UniversalCandidate, assertDemandedSchema, associationsKey, buildCategoryHierarchy, createAssociationGuards, createAssociationHelpers, createAssociationsService, createAssociationsStore, createCandidatesService, createCategoriesService, createCommentsService, createEntityRegistry, createEntityRowsService, createFavoritesService, createRpcResultHelpers, createTitlesService, entityTitleCacheKey, err, firstError, isContentRole, isContentSourceEdge, isMembershipMetadata, isTransportFailure, isUuid, ok, resolveEntityToken };
@@ -1,4 +1,4 @@
1
- import { EntityOverlayMap, EntityTypeToken, EntityOverlayEntry, ErrorSink, AssociationsRpcError, AssociationsDataSource, AssociationsIdentity, AssociationTargetType, AssociationsRpcResult, AssociationEdge, AssociationTargetEdge, AssociationSourceEdge, CategoryDimension, PlatformCategory, UserStateKind, UserEntityState, AssociationsEntry, CategoriesEntry, AssociationsConfig } from '../index.js';
1
+ import { EntityOverlayMap, EntityTypeToken, EntityOverlayEntry, ErrorSink, AssociationsRpcError, AssociationsDataSource, AssociationsIdentity, AssociationTargetType, AssociationsRpcResult, AssociationEdge, AssociationTargetEdge, AssociationSourceEdge, CategoryDimension, PlatformCategory, UserStateKind, UserEntityState, PlatformComment, AssociationsEntry, CategoriesEntry, CommentsEntry, AssociationsConfig } from '../index.js';
2
2
  import 'react';
3
3
 
4
4
  /** The universal ownership column post-2026-reorg. */
@@ -474,6 +474,28 @@ interface AssociationHelpersApi {
474
474
  }
475
475
  declare function createAssociationHelpers(service: AssociationsServiceApi): AssociationHelpersApi;
476
476
 
477
+ interface AddCommentArgs {
478
+ /** Registered entity-type token the comment hangs on (writes-strict, C18). */
479
+ entityType: string;
480
+ entityId: string;
481
+ body: string;
482
+ /** Reply target — an existing comment's id. Top-level when omitted. */
483
+ parentId?: string | null;
484
+ /** Org override; the RPC resolves task-org/personal-org when omitted. */
485
+ orgId?: string | null;
486
+ }
487
+ interface CommentsServiceApi {
488
+ listForEntity(entityType: string, entityId: string): Promise<AssociationsRpcResult<{
489
+ comments: PlatformComment[];
490
+ }>>;
491
+ add(args: AddCommentArgs): Promise<AssociationsRpcResult<{
492
+ id: string;
493
+ }>>;
494
+ edit(id: string, body: string): Promise<AssociationsRpcResult<null>>;
495
+ remove(id: string): Promise<AssociationsRpcResult<null>>;
496
+ }
497
+ declare function createCommentsService(deps: CoreDeps): CommentsServiceApi;
498
+
477
499
  /** Cache key for one association endpoint. */
478
500
  declare function associationsKey(type: string, id: string): string;
479
501
  interface AssociationWriteResult {
@@ -488,6 +510,12 @@ interface CategoryMutationResult {
488
510
  id?: string;
489
511
  error?: string;
490
512
  }
513
+ interface CommentMutationResult {
514
+ ok: boolean;
515
+ /** Set on a successful `addComment`. */
516
+ id?: string;
517
+ error?: string;
518
+ }
491
519
  interface AssociationsStore {
492
520
  /** Stable, sync read of one endpoint's entry (idle default when uncached). */
493
521
  getEdges(type: string, id: string): AssociationsEntry;
@@ -531,7 +559,7 @@ interface AssociationsStore {
531
559
  }): Promise<AssociationWriteResult>;
532
560
  /** Reset one endpoint to idle and notify its subscribers. */
533
561
  invalidate(type: string, id: string): void;
534
- /** Reset every association endpoint AND every category facet. */
562
+ /** Reset every association endpoint, category facet, and comment thread. */
535
563
  invalidateAll(): void;
536
564
  getCategories(dimension: CategoryDimension): CategoriesEntry;
537
565
  loadCategories(dimension: CategoryDimension, opts?: {
@@ -566,6 +594,41 @@ interface AssociationsStore {
566
594
  dimension: CategoryDimension;
567
595
  id: string;
568
596
  }): Promise<CategoryMutationResult>;
597
+ /** Stable, sync read of one entity's comment thread (idle when uncached). */
598
+ getComments(type: string, id: string): CommentsEntry;
599
+ /**
600
+ * Lazy load of every comment on `${type}:${id}` (oldest→newest; thread by
601
+ * `parentId`). Deduped per key; `status === "ready"` short-circuits unless
602
+ * `force`.
603
+ */
604
+ loadComments(type: string, id: string, opts?: {
605
+ force?: boolean;
606
+ }): Promise<void>;
607
+ /** External-store contract for one entity's comment thread. */
608
+ subscribeComments(key: string, cb: () => void): () => void;
609
+ /** Post a comment (or a reply); on success force-reloads the thread. */
610
+ addComment(args: {
611
+ entityType: string;
612
+ entityId: string;
613
+ body: string;
614
+ parentId?: string | null;
615
+ orgId?: string | null;
616
+ }): Promise<CommentMutationResult>;
617
+ /** Edit a comment body (author-only in the RPC); reloads the thread. */
618
+ editComment(args: {
619
+ entityType: string;
620
+ entityId: string;
621
+ id: string;
622
+ body: string;
623
+ }): Promise<CommentMutationResult>;
624
+ /** Soft-delete a comment (author/org member in the RPC); reloads the thread. */
625
+ deleteComment(args: {
626
+ entityType: string;
627
+ entityId: string;
628
+ id: string;
629
+ }): Promise<CommentMutationResult>;
630
+ /** Reset one entity's comment thread to idle and notify its subscribers. */
631
+ invalidateComments(type: string, id: string): void;
569
632
  /** Batched title resolution + the session cache + prime. */
570
633
  titles: TitlesServiceApi;
571
634
  /** Per-user favorite/pinned/hidden state (`ues_*`). */
@@ -586,6 +649,7 @@ interface AssociationsStore {
586
649
  services: {
587
650
  associations: AssociationsServiceApi;
588
651
  categories: CategoriesServiceApi;
652
+ comments: CommentsServiceApi;
589
653
  };
590
654
  /** Merge more host overlay entries in (icons/routes/candidate loaders). */
591
655
  registerEntityOverlay: EntityRegistry["registerEntityOverlay"];
@@ -658,4 +722,22 @@ declare function isMembershipMetadata(metadata: unknown): boolean;
658
722
  */
659
723
  declare function isContentSourceEdge(sourceType: string, metadata?: unknown): boolean;
660
724
 
661
- export { type AddAssociationArgs, type AssertDemandedSchemaOptions, type AssociationGuards, type AssociationHelpersApi, type AssociationWriteResult, type AssociationsServiceApi, type AssociationsStore, type CandidateRecord, type CandidatesResult, type CandidatesServiceApi, type CategoriesServiceApi, type CategoryMutationResult, type ContainerRef, type ContentRole, type ConversationFileLink, type CoreDeps, type CreateEntityRowArgs, DEFAULT_ORG_COLUMN, DEFAULT_OWNER_COLUMN, type DemandedSchemaReport, type EdgeAttrs, type EdgeSpec, type EntityInfo, type EntityRef, type EntityRegistry, type EntityRowResult, type EntityRowsServiceApi, type FavoritesServiceApi, type ListCandidatesArgs, NON_CONTENT_SOURCE_TYPES, type PgErrorMapper, type RpcResultHelpers, SELF_TEST_MISSING_RPC, type SearchAcrossTokensArgs, type TitlesServiceApi, type UniversalCandidate, assertDemandedSchema, associationsKey, createAssociationGuards, createAssociationHelpers, createAssociationsService, createAssociationsStore, createCandidatesService, createCategoriesService, createEntityRegistry, createEntityRowsService, createFavoritesService, createRpcResultHelpers, createTitlesService, entityTitleCacheKey, err, firstError, isContentRole, isContentSourceEdge, isMembershipMetadata, isTransportFailure, isUuid, ok, resolveEntityToken };
725
+ interface CategoryHierarchyItem {
726
+ category: PlatformCategory;
727
+ depth: 0 | 1;
728
+ parent: PlatformCategory | null;
729
+ displayName: string;
730
+ }
731
+ interface CategoryHierarchy {
732
+ items: CategoryHierarchyItem[];
733
+ roots: PlatformCategory[];
734
+ hasHierarchy: boolean;
735
+ }
736
+ /**
737
+ * Turns the RPC's ordered flat rows into the canonical two-level display order.
738
+ * Flat facets retain their exact input order. Invalid/orphaned rows remain
739
+ * visible at the root; the database guard prevents new ones from being made.
740
+ */
741
+ declare function buildCategoryHierarchy(categories: PlatformCategory[]): CategoryHierarchy;
742
+
743
+ export { type AddAssociationArgs, type AddCommentArgs, type AssertDemandedSchemaOptions, type AssociationGuards, type AssociationHelpersApi, type AssociationWriteResult, type AssociationsServiceApi, type AssociationsStore, type CandidateRecord, type CandidatesResult, type CandidatesServiceApi, type CategoriesServiceApi, type CategoryHierarchy, type CategoryHierarchyItem, type CategoryMutationResult, type CommentMutationResult, type CommentsServiceApi, type ContainerRef, type ContentRole, type ConversationFileLink, type CoreDeps, type CreateEntityRowArgs, DEFAULT_ORG_COLUMN, DEFAULT_OWNER_COLUMN, type DemandedSchemaReport, type EdgeAttrs, type EdgeSpec, type EntityInfo, type EntityRef, type EntityRegistry, type EntityRowResult, type EntityRowsServiceApi, type FavoritesServiceApi, type ListCandidatesArgs, NON_CONTENT_SOURCE_TYPES, type PgErrorMapper, type RpcResultHelpers, SELF_TEST_MISSING_RPC, type SearchAcrossTokensArgs, type TitlesServiceApi, type UniversalCandidate, assertDemandedSchema, associationsKey, buildCategoryHierarchy, createAssociationGuards, createAssociationHelpers, createAssociationsService, createAssociationsStore, createCandidatesService, createCategoriesService, createCommentsService, createEntityRegistry, createEntityRowsService, createFavoritesService, createRpcResultHelpers, createTitlesService, entityTitleCacheKey, err, firstError, isContentRole, isContentSourceEdge, isMembershipMetadata, isTransportFailure, isUuid, ok, resolveEntityToken };