@ai-matrx/associations 0.2.0 → 0.4.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.
@@ -589,6 +589,19 @@ interface AssociationsStore {
589
589
  };
590
590
  /** Merge more host overlay entries in (icons/routes/candidate loaders). */
591
591
  registerEntityOverlay: EntityRegistry["registerEntityOverlay"];
592
+ /**
593
+ * The bound scream seam (W3, additive): /react surfaces route their loud
594
+ * recoveries here (the originals' console.error sites) without a second
595
+ * sink binding. Same function the host passed at construction.
596
+ */
597
+ errorSink: AssociationsConfig["errorSink"];
598
+ /**
599
+ * The bound identity port (W3, additive): /react hooks that FILTER by the
600
+ * current user (candidate owner scoping) read it leniently; write paths
601
+ * keep going through the services, where `requireUserId` failures stay
602
+ * loud. Same object the host passed at construction.
603
+ */
604
+ identity: AssociationsConfig["identity"];
592
605
  }
593
606
  /**
594
607
  * Build the one store a host binds. REQUIRED ports (dataSource / identity /
@@ -645,4 +658,22 @@ declare function isMembershipMetadata(metadata: unknown): boolean;
645
658
  */
646
659
  declare function isContentSourceEdge(sourceType: string, metadata?: unknown): boolean;
647
660
 
648
- 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 };
661
+ interface CategoryHierarchyItem {
662
+ category: PlatformCategory;
663
+ depth: 0 | 1;
664
+ parent: PlatformCategory | null;
665
+ displayName: string;
666
+ }
667
+ interface CategoryHierarchy {
668
+ items: CategoryHierarchyItem[];
669
+ roots: PlatformCategory[];
670
+ hasHierarchy: boolean;
671
+ }
672
+ /**
673
+ * Turns the RPC's ordered flat rows into the canonical two-level display order.
674
+ * Flat facets retain their exact input order. Invalid/orphaned rows remain
675
+ * visible at the root; the database guard prevents new ones from being made.
676
+ */
677
+ declare function buildCategoryHierarchy(categories: PlatformCategory[]): CategoryHierarchy;
678
+
679
+ export { type AddAssociationArgs, 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 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, createEntityRegistry, createEntityRowsService, createFavoritesService, createRpcResultHelpers, createTitlesService, entityTitleCacheKey, err, firstError, isContentRole, isContentSourceEdge, isMembershipMetadata, isTransportFailure, isUuid, ok, resolveEntityToken };
@@ -589,6 +589,19 @@ interface AssociationsStore {
589
589
  };
590
590
  /** Merge more host overlay entries in (icons/routes/candidate loaders). */
591
591
  registerEntityOverlay: EntityRegistry["registerEntityOverlay"];
592
+ /**
593
+ * The bound scream seam (W3, additive): /react surfaces route their loud
594
+ * recoveries here (the originals' console.error sites) without a second
595
+ * sink binding. Same function the host passed at construction.
596
+ */
597
+ errorSink: AssociationsConfig["errorSink"];
598
+ /**
599
+ * The bound identity port (W3, additive): /react hooks that FILTER by the
600
+ * current user (candidate owner scoping) read it leniently; write paths
601
+ * keep going through the services, where `requireUserId` failures stay
602
+ * loud. Same object the host passed at construction.
603
+ */
604
+ identity: AssociationsConfig["identity"];
592
605
  }
593
606
  /**
594
607
  * Build the one store a host binds. REQUIRED ports (dataSource / identity /
@@ -645,4 +658,22 @@ declare function isMembershipMetadata(metadata: unknown): boolean;
645
658
  */
646
659
  declare function isContentSourceEdge(sourceType: string, metadata?: unknown): boolean;
647
660
 
648
- 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 };
661
+ interface CategoryHierarchyItem {
662
+ category: PlatformCategory;
663
+ depth: 0 | 1;
664
+ parent: PlatformCategory | null;
665
+ displayName: string;
666
+ }
667
+ interface CategoryHierarchy {
668
+ items: CategoryHierarchyItem[];
669
+ roots: PlatformCategory[];
670
+ hasHierarchy: boolean;
671
+ }
672
+ /**
673
+ * Turns the RPC's ordered flat rows into the canonical two-level display order.
674
+ * Flat facets retain their exact input order. Invalid/orphaned rows remain
675
+ * visible at the root; the database guard prevents new ones from being made.
676
+ */
677
+ declare function buildCategoryHierarchy(categories: PlatformCategory[]): CategoryHierarchy;
678
+
679
+ export { type AddAssociationArgs, 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 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, createEntityRegistry, createEntityRowsService, createFavoritesService, createRpcResultHelpers, createTitlesService, entityTitleCacheKey, err, firstError, isContentRole, isContentSourceEdge, isMembershipMetadata, isTransportFailure, isUuid, ok, resolveEntityToken };
@@ -423,6 +423,7 @@ var ENTITY_TYPE_METADATA = {
423
423
  "platform_actor_session": { token: "platform_actor_session", schema: "platform", table: "actor_session", label: "Actor session", baseTier: 1, isComponent: false, isModule: false, isListed: false, scopeable: true, category: null, referencePickable: false, titleColumn: null, contentRole: null, referenceCategory: null },
424
424
  "platform_actor_token": { token: "platform_actor_token", schema: "platform", table: "actor_token", label: "Actor token", baseTier: 1, isComponent: false, isModule: false, isListed: false, scopeable: true, category: null, referencePickable: false, titleColumn: null, contentRole: null, referenceCategory: null },
425
425
  "platform_actor_token_event": { token: "platform_actor_token_event", schema: "platform", table: "actor_token_event", label: "Actor token event", baseTier: 1, isComponent: false, isModule: false, isListed: false, scopeable: true, category: null, referencePickable: false, titleColumn: null, contentRole: null, referenceCategory: null },
426
+ "platform_continued_access": { token: "platform_continued_access", schema: "platform", table: "continued_access", label: "Continued Access", baseTier: 1, isComponent: false, isModule: false, isListed: false, scopeable: true, category: null, referencePickable: false, titleColumn: null, contentRole: null, referenceCategory: null },
426
427
  "platform_outcome_event": { token: "platform_outcome_event", schema: "platform", table: "outcome_event", label: "Outcome Event", baseTier: 1, isComponent: false, isModule: false, isListed: true, scopeable: true, category: null, referencePickable: false, titleColumn: null, contentRole: null, referenceCategory: null },
427
428
  "platform_outsider_consumer": { token: "platform_outsider_consumer", schema: "platform", table: "outsider_consumer", label: "Outsider consumer", baseTier: 1, isComponent: false, isModule: false, isListed: false, scopeable: true, category: null, referencePickable: false, titleColumn: null, contentRole: null, referenceCategory: null },
428
429
  "platform_saved_view": { token: "platform_saved_view", schema: "platform", table: "saved_view", label: "Saved view", baseTier: 1, isComponent: false, isModule: false, isListed: true, scopeable: true, category: null, referencePickable: false, titleColumn: null, contentRole: null, referenceCategory: null },
@@ -451,6 +452,7 @@ var ENTITY_TYPE_METADATA = {
451
452
  "research_tag": { token: "research_tag", schema: "research", table: "rs_tag", label: "Research Tag", baseTier: 1, isComponent: true, isModule: false, isListed: false, scopeable: true, category: null, referencePickable: false, titleColumn: "name", contentRole: null, referenceCategory: null },
452
453
  "research_template": { token: "research_template", schema: "research", table: "rs_template", label: "Research Template", baseTier: 1, isComponent: false, isModule: false, isListed: false, scopeable: true, category: null, referencePickable: true, titleColumn: "name", contentRole: null, referenceCategory: null },
453
454
  "research_topic": { token: "research_topic", schema: "research", table: "rs_topic", label: "Research Topic", baseTier: 1, isComponent: false, isModule: false, isListed: false, scopeable: true, category: null, referencePickable: true, titleColumn: "name", contentRole: null, referenceCategory: null },
455
+ "route_manifest_entry": { token: "route_manifest_entry", schema: "platform", table: "route_manifest", label: "Route Manifest Entry", baseTier: 1, isComponent: false, isModule: false, isListed: false, scopeable: true, category: null, referencePickable: false, titleColumn: null, contentRole: null, referenceCategory: null },
454
456
  "rulebook": { token: "rulebook", schema: "platform", table: "rulebook", label: "Rulebook", baseTier: 1, isComponent: false, isModule: false, isListed: true, scopeable: true, category: "Knowledge", referencePickable: true, titleColumn: "name", contentRole: "source", referenceCategory: null },
455
457
  "sandbox_instance": { token: "sandbox_instance", schema: "public", table: "sandbox_instances", label: "Sandbox Instance", baseTier: 1, isComponent: false, isModule: false, isListed: false, scopeable: true, category: null, referencePickable: false, titleColumn: null, contentRole: null, referenceCategory: null },
456
458
  "sch_agent_task": { token: "sch_agent_task", schema: "scheduler", table: "sch_agent_task", label: "Agent Task Config", baseTier: 1, isComponent: true, isModule: false, isListed: false, scopeable: true, category: null, referencePickable: false, titleColumn: null, contentRole: null, referenceCategory: null },
@@ -529,6 +531,7 @@ var ENTITY_TYPE_METADATA = {
529
531
  "seo_topic": { token: "seo_topic", schema: "seo", table: "topic", label: "SEO Topic", baseTier: 1, isComponent: false, isModule: false, isListed: false, scopeable: true, category: "seo", referencePickable: true, titleColumn: "name", contentRole: null, referenceCategory: null },
530
532
  "seo_web_analytics_daily": { token: "seo_web_analytics_daily", schema: "seo", table: "web_analytics_daily", label: "Web Analytics Daily", baseTier: 1, isComponent: true, isModule: false, isListed: false, scopeable: true, category: "marketing", referencePickable: false, titleColumn: null, contentRole: null, referenceCategory: null },
531
533
  "shared_canvas_item": { token: "shared_canvas_item", schema: "canvas", table: "shared_canvas_items", label: "Shared Canvas Item", baseTier: 1, isComponent: false, isModule: false, isListed: false, scopeable: true, category: null, referencePickable: true, titleColumn: "title", contentRole: null, referenceCategory: null },
534
+ "short_link": { token: "short_link", schema: "platform", table: "short_links", label: "Short Link", baseTier: 1, isComponent: false, isModule: false, isListed: false, scopeable: true, category: null, referencePickable: false, titleColumn: null, contentRole: null, referenceCategory: null },
532
535
  "skill": { token: "skill", schema: "skill", table: "definition", label: "Skill", baseTier: 1, isComponent: false, isModule: false, isListed: false, scopeable: true, category: "Skills", referencePickable: true, titleColumn: "label", contentRole: "utility", referenceCategory: null },
533
536
  "skill_render_definition": { token: "skill_render_definition", schema: "skill", table: "render_definition", label: "Skill Render Definition", baseTier: 1, isComponent: false, isModule: false, isListed: false, scopeable: true, category: "Skills", referencePickable: true, titleColumn: "label", contentRole: null, referenceCategory: null },
534
537
  "sms_consent": { token: "sms_consent", schema: "communication", table: "sms_consent", label: "SMS Consent", baseTier: 1, isComponent: false, isModule: false, isListed: false, scopeable: true, category: null, referencePickable: false, titleColumn: null, contentRole: null, referenceCategory: null },
@@ -1076,6 +1079,7 @@ var ENTITY_TYPE_TOKENS = [
1076
1079
  "platform_actor_session",
1077
1080
  "platform_actor_token",
1078
1081
  "platform_actor_token_event",
1082
+ "platform_continued_access",
1079
1083
  "platform_outcome_event",
1080
1084
  "platform_outsider_consumer",
1081
1085
  "platform_saved_view",
@@ -1104,6 +1108,7 @@ var ENTITY_TYPE_TOKENS = [
1104
1108
  "research_tag",
1105
1109
  "research_template",
1106
1110
  "research_topic",
1111
+ "route_manifest_entry",
1107
1112
  "rulebook",
1108
1113
  "sandbox_instance",
1109
1114
  "sch_agent_task",
@@ -1182,6 +1187,7 @@ var ENTITY_TYPE_TOKENS = [
1182
1187
  "seo_topic",
1183
1188
  "seo_web_analytics_daily",
1184
1189
  "shared_canvas_item",
1190
+ "short_link",
1185
1191
  "skill",
1186
1192
  "skill_render_definition",
1187
1193
  "sms_consent",
@@ -2967,7 +2973,9 @@ function createAssociationsStore(config) {
2967
2973
  helpers,
2968
2974
  registry,
2969
2975
  services: { associations, categories },
2970
- registerEntityOverlay: registry.registerEntityOverlay
2976
+ registerEntityOverlay: registry.registerEntityOverlay,
2977
+ errorSink,
2978
+ identity: config.identity
2971
2979
  };
2972
2980
  }
2973
2981
 
@@ -3136,6 +3144,70 @@ function isContentSourceEdge(sourceType, metadata) {
3136
3144
  if (isMembershipMetadata(metadata)) return false;
3137
3145
  return true;
3138
3146
  }
3147
+
3148
+ // src/core/categoryHierarchy.ts
3149
+ function buildCategoryHierarchy(categories) {
3150
+ const byId = new Map(categories.map((category) => [category.id, category]));
3151
+ const hasHierarchy = categories.some(
3152
+ (category) => category.parentId !== null && byId.has(category.parentId)
3153
+ );
3154
+ if (!hasHierarchy) {
3155
+ return {
3156
+ items: categories.map((category) => ({
3157
+ category,
3158
+ depth: 0,
3159
+ parent: null,
3160
+ displayName: category.name
3161
+ })),
3162
+ roots: categories.filter((category) => category.parentId === null),
3163
+ hasHierarchy: false
3164
+ };
3165
+ }
3166
+ const roots = categories.filter(
3167
+ (category) => category.parentId === null || !byId.has(category.parentId)
3168
+ );
3169
+ const childrenByParent = /* @__PURE__ */ new Map();
3170
+ for (const category of categories) {
3171
+ if (!category.parentId || !byId.has(category.parentId)) continue;
3172
+ const children = childrenByParent.get(category.parentId) ?? [];
3173
+ children.push(category);
3174
+ childrenByParent.set(category.parentId, children);
3175
+ }
3176
+ const items = [];
3177
+ const seen = /* @__PURE__ */ new Set();
3178
+ for (const root of roots) {
3179
+ items.push({
3180
+ category: root,
3181
+ depth: 0,
3182
+ parent: null,
3183
+ displayName: root.name
3184
+ });
3185
+ seen.add(root.id);
3186
+ for (const child of childrenByParent.get(root.id) ?? []) {
3187
+ items.push({
3188
+ category: child,
3189
+ depth: 1,
3190
+ parent: root,
3191
+ displayName: `${root.name} / ${child.name}`
3192
+ });
3193
+ seen.add(child.id);
3194
+ }
3195
+ }
3196
+ for (const category of categories) {
3197
+ if (seen.has(category.id)) continue;
3198
+ items.push({
3199
+ category,
3200
+ depth: 0,
3201
+ parent: null,
3202
+ displayName: category.name
3203
+ });
3204
+ }
3205
+ return {
3206
+ items,
3207
+ roots: categories.filter((category) => category.parentId === null),
3208
+ hasHierarchy: true
3209
+ };
3210
+ }
3139
3211
  export {
3140
3212
  DEFAULT_ORG_COLUMN,
3141
3213
  DEFAULT_OWNER_COLUMN,
@@ -3143,6 +3215,7 @@ export {
3143
3215
  SELF_TEST_MISSING_RPC,
3144
3216
  assertDemandedSchema,
3145
3217
  associationsKey,
3218
+ buildCategoryHierarchy,
3146
3219
  createAssociationGuards,
3147
3220
  createAssociationHelpers,
3148
3221
  createAssociationsService,