@ai-matrx/协会
在AI Matrx平台上连接两个实体的方法: 关联边缘, 类别、最爱/最近和生成的实体类型词汇-已运出 matrx 客户端或企业应用程序安装的软件包.
包件装有"根"、"无头" /core,反应绑定
/react,以及软件包拥有的懒惰反应条目 /react/lazy: 服务
止住点 守卫 永不扔出结果漏斗 注册合并引擎,
可分解缓存商店、钩子和关联面相(卡、列表、,
拾取器、附件项目表、抓取工具栏)。 下面的一切
计划是有约束力的——它是包裹的产品.
import {
type EntityTypeToken, // generated from platform.entity_types
ENTITY_TYPE_METADATA, // per-token schema/table/label/titleColumn/contentRole
isEntityTypeToken, // runtime guard, narrows to the union
type AssociationEdge, // one assoc_for_entity row (both directions)
type AssociationsRpcResult, // the never-throw result envelope
type DemandedRpcName, // the 27-function demanded RPC surface
type AssociationsConfig, // the seven ports a host binds
} from "@ai-matrx/associations";
import {
createAssociationsStore, // the ONE runtime object a host constructs
} from "@ai-matrx/associations/core";
const store = createAssociationsStore({
dataSource: supabase, // structural subset of SupabaseClient
identity: { requireUserId }, // throws when unauthenticated
errorSink: (e) => report(e), // OPTIONAL — default screams to console
entityOverlay: { file: { hrefFor: (id) => `/files/f/${id}` } }, // optional
});
await store.load("task", taskId); // lazy, deduped, subscribable
store.getEdges("task", taskId); // sync, stable idle default
await store.add({ sourceType: "note", sourceId, targetType: "task", targetId });
store.titles.prime("task", taskId, "Renamed");
await store.favorites.setFavorite("note", noteId, true);
// There is NO boot check to call (0.9.0). A database that cannot answer a
// demanded function says so at the first real call: PostgREST returns
// PGRST202 and the package screams `demanded_schema_violation` with a remedy.
useContainerLinks({ containerType, containerId, orgId }) 是犬科动物
容器侧反相 API. 内容 attach, (中文(简体) ), detach,以及 setPinned 全部操作
瞄准精确的角色合格边缘; setPinned 保存了边缘的另一个
元数据字段. AssociationCardGrid 默认 AssociationList
适配器在没有主机接线的情况下曝光这些相同的操作.
// /react — the banner'd React binding (peer: react >=18;
// @ai-matrx/design-system is a real dependency — the faces' chrome
// installs automatically). Bind ONCE:
import {
AssociationsProvider,
useAssociations, // the seven hooks keep the app originals' exact signatures
AssociationCardGrid, // + AssociationCard / AssociationList / pickers / capture toolbar
PrimaryEntityProvider,
} from "@ai-matrx/associations/react";
<AssociationsProvider
store={store} // the /core store from createAssociationsStore
notifier={toastAdapter} // optional — absent warns once, failures still hit errorSink
windowShell={windowAdapter} // optional — absent uses the package's OWN draggable window
capture={{ uploadFile }} // optional — bind ONE primitive, get the whole upload flow
pickerOverrides={{ file: FilePickerWindowAdapter }} // optional — the in-package picker is the default
entityDoors={{ EntityRef, DoorControls, UnresolvedRef }} // optional — hrefFor anchors by default
>
<PrimaryEntityProvider value={{ type: "organization", id, orgId, label }}>
<AssociationCardGrid />
</PrimaryEntityProvider>
</AssociationsProvider>;
有 Tailwind 语义符号的面相样式(bg-card, (中文(简体) ),
text-muted-foreground,...):将此软件包注册为 Tailwind v4 源
消费应用( e)@source "../node_modules/@ai-matrx/associations/dist"(中文(简体) )
同样的方式 @ai-matrx/design-system 文档.
要求的策略
这个软件包是 感觉就像Python一样 matrx-* 软件包: 没有
适应你的数据库 它需要我们的 一个不会搞我们计划的消费者
不是这个包裹的消费者。 它没有DDL(DB平台拥有;管理)
消费者利用我们的基础设施;它以三种方式满足需求:
文档(此处),键入(DemandedRpcSignatures,由活的 DB 生成),
并尖叫着第一个真正的电话(PGRST202~) demanded_schema_violation, (中文(简体) ),
(有补救措施)。 每一次侵犯
尖叫,永不堕落。 。 。 .
- 边缘.
platform.associations(source_type, source_id, target_type, target_id, organization_id, label, metadata, role, position, created_by, created_at, deleted_at, …)- 一个多形态的桌子,在5个圆顶上独一无二(source_type, source_id, target_type, target_id, role)NULLS NOT DISTINCT。 。 。 . 类型列为 FK- 校验platform.entity_types.token。 。 。 . - 仅限RPC. 客户持有 无赠款 {\fn黑体\fs22\bord1\shad0\3aHBE\4aH00\fscx67\fscy66\2cHFFFFFF\3cH808080}就放在桌子上 {\fn黑体\fs22\bord1\shad0\3aHBE\4aH00\fscx67\fscy66\2cHFFFFFF\3cH808080}你觉得呢? 每一次行动都会发生
通过安全保卫局的27个职能
DEMANDED_RPC_NAMES(单位:千美元)assoc_*×8,conversation_file*×3,agent_resource_*×2,cat_*×5,ues_*×4,reference_search_candidates,W6评论家族cmt_*×4). 那些读者只吃活的associations_live视图,所以墓碑语义学(一个被废弃的实体) 柔和地移动它的边缘;恢复它们) 由建筑支撑——这个 软件包从不写.is("deleted_at", null)过滤器。 DB的遗产assoc_link编号 :assoc_list编号 :assoc_unlink三重奏是故意不要求的. - 方向是登记拥有的:小-大. 资源是 资源
目标容器
task → organization, (中文(简体) ),file → scope) (中文(简体) ). DB 触发器trg_associations_auto_orient拒绝倒转的写出—— 此软件包 显示该错误的逐字字, 并且永远不会为您翻出一个边缘 . - 联系从来不是赠款. 无障碍生活
iam.permissions编号 :iam.memberships. 唯一被认可的协会-接入桥是DB-侧 运输platform.association_types.conveys_max− 可达到性)。 这个 软件包制作 零准入决定。 。 。 . - 缺失的函数尖叫. 任何需要的RPC地图上的PGREST PGRST202
页:1
demanded_schema_violation结果代码并总是到达您的 错误Sink:没有我们计划的数据库会产生一个毫不含糊的尖叫,而不是 一个神秘的祝酒词.
符号词汇——写作严格,读作宽容
EntityTypeToken 镜像 platform.entity_types 1:1(651个活化符号),
由 pnpm gen:entity-types 在这个包裹里。 扭曲策略 :
- 写作是STRICT 对照已安装的词汇表: 此版本的符号
在Postgres之前的密码里 并不知道警卫的失败
缺少 DB 类型。 问题在于
pnpm up @ai-matrx/associations(登记更改) 船舶为 补丁释放从来没有一个生弦扩大. - 读取是TOLERANT: 边缘带有一个符号 知道通过倒置(默认图标、原始标签、没有门) 坠毁.
港口 -- -- 需要两个港口,其余港口为防御港口
一个 AssociationsConfig,每个主机绑定一次。 仅 dataSource 联合国
结构子集 SupabaseClient 回答要求的保护责任)和
identity 需要建造,因为没有它们
是你的应用程序的身份 没有软件包能发明它们.
其它所有船只都属于工作默认(C23——你超越了港口,你从不) 必须填满:
| 端口 | 未绑定时默认 |
|---|---|
errorSink | createDefaultErrorSink() - 标记 console.error 每个事件; 宣布 ONCE 不约束任何汇并指定补救. |
windowShell | DefaultWindowShell ——真正可拖放/可换放/可最大可换放/可换放/可换放/可换放/可换放/可换放/可换放/非模式窗口;640px下为全宽底卡. 仅为真实窗口 MANAGER( 盘点对接, 工作空间持续性) 装入此端口 . |
capture | 捆绑 uploadFile(file, { folderPath, visibility }) 和包 传输文件输入,拖放,批量,摊位监督 和每一个响亮的结果。 捆绑 requestUpload 而当你拥有更丰富的管道。 没有路的芯片永远不会被制成. |
pickerOverrides | 包装 AssociationPicker 服务每个符号(地址列表、搜索、附件/调试、创建-当时关联页脚). |
entityDoors | DoorControlsSlot 使一个真正的标签 target="_blank" 从上下文起锚 hrefFor无路可走的标志 只会成为无路可走的门. |
entityOverlay | 公约栏,默认图标, ${label}s没有门. |
notifier | 通过出错Sink发出警告,每一次用户提示失败仍然会到达出错Sink. (没有土司堆栈船:土司表面需要一个主机挂起的根,所以"默认"就是这个套件存在的无声无息的去防止. ) |
authorDisplay | cmt_list'非正常的作者字段,然后是"未知的用户"——永远不空白. |
代码分割——软件包拥有它
导入重脸从 @ai-matrx/associations/react/lazy 每个
第一次变形时就到达了自己的地段 没有 next/dynamic,没有 ssr: false, (中文(简体) ),
没有主机胶水 :
import { AssociationCardGrid } from "@ai-matrx/associations/react/lazy";
对于连接到端口的HOST组件,请使用同一接缝:
windowShell: {
Window: lazyWindowShell(() => import("./hostWindow").then((m) => m.HostWindow)),
},
pickerOverrides: {
file: lazyPickerOverride(() => import("./hostPicker").then((m) => m.HostPicker)),
},
每件拾取器应装订 useAssociationPickerBridge(props) 页:1
它的附着/调试写作——它带有响亮的部分结果、拒绝和
创建但无附件的报表,所以一个覆盖永远不会重新执行它们.
版本
被马特克丝重新占有 latest (单位:千美元)workspace:* 活塞内单体)
——从未被钉住。 登记符号更改 / 重新生成 / 补丁 .
合同变更 − 每套小/主要.
许可证
麻省理工学院