@ai-matrx/associations 0.8.9 → 0.9.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.
@@ -69,185 +69,12 @@ module.exports = __toCommonJS(react_exports);
69
69
 
70
70
  // src/react/context.tsx
71
71
  var import_react = require("react");
72
-
73
- // src/demanded-rpcs.generated.ts
74
- var DEMANDED_RPC_NAMES = [
75
- "assoc_add",
76
- "assoc_remove",
77
- "assoc_set_targets",
78
- "assoc_remove_for_entity",
79
- "assoc_for_entity",
80
- "assoc_for_targets",
81
- "assoc_for_sources",
82
- "assoc_members_visible",
83
- "conversation_file_add",
84
- "conversation_file_remove",
85
- "conversation_files",
86
- "agent_resource_add",
87
- "agent_resource_remove",
88
- "cat_list",
89
- "cat_create",
90
- "cat_update",
91
- "cat_reparent",
92
- "cat_delete",
93
- "ues_set",
94
- "ues_list",
95
- "ues_get_bulk",
96
- "ues_touch",
97
- "reference_search_candidates",
98
- "cmt_list",
99
- "cmt_add",
100
- "cmt_edit",
101
- "cmt_delete"
102
- ];
103
-
104
- // src/core/assertDemandedSchema.ts
105
- var BAD_UUID = "__not_a_uuid__";
106
- var SELF_TEST_MISSING_RPC = "assoc_probe_self_test_missing_fn";
107
- var PROBE_ARGS = {
108
- // edges — writes
109
- assoc_add: {
110
- p_source_type: "note",
111
- p_source_id: BAD_UUID,
112
- p_target_type: "task",
113
- p_target_id: BAD_UUID
114
- },
115
- assoc_remove: {
116
- p_source_type: "note",
117
- p_source_id: BAD_UUID,
118
- p_target_type: "task",
119
- p_target_id: BAD_UUID
120
- },
121
- assoc_set_targets: {
122
- p_source_type: "note",
123
- p_source_id: BAD_UUID,
124
- p_target_type: "task",
125
- p_target_ids: [BAD_UUID]
126
- },
127
- assoc_remove_for_entity: { p_type: "note", p_id: BAD_UUID },
128
- // edges — reads
129
- assoc_for_entity: { p_type: "note", p_id: BAD_UUID },
130
- assoc_for_targets: { p_target_type: "task", p_target_ids: [BAD_UUID] },
131
- assoc_for_sources: { p_source_type: "note", p_source_ids: [BAD_UUID] },
132
- assoc_members_visible: { p_target_type: "task", p_target_ids: [BAD_UUID] },
133
- // conversation files
134
- conversation_file_add: {
135
- p_conversation_id: BAD_UUID,
136
- p_file_id: BAD_UUID
137
- },
138
- conversation_file_remove: {
139
- p_conversation_id: BAD_UUID,
140
- p_file_id: BAD_UUID
141
- },
142
- conversation_files: { p_conversation_id: BAD_UUID },
143
- // agent resources
144
- agent_resource_add: {
145
- p_agent_id: BAD_UUID,
146
- p_source_type: "note",
147
- p_source_id: BAD_UUID
148
- },
149
- agent_resource_remove: {
150
- p_agent_id: BAD_UUID,
151
- p_source_type: "note",
152
- p_source_id: BAD_UUID
153
- },
154
- // categories
155
- cat_list: {},
156
- cat_create: { p_dimension: "", p_name: "", p_org_id: BAD_UUID },
157
- cat_update: { p_category_id: BAD_UUID, p_name: "__probe__" },
158
- cat_reparent: { p_category_id: BAD_UUID },
159
- cat_delete: { p_category_id: BAD_UUID },
160
- // favorites / recents
161
- ues_set: { p_entity_type: "__probe__", p_entity_id: BAD_UUID },
162
- ues_list: {},
163
- ues_get_bulk: { p_entity_type: "__probe__", p_entity_ids: [BAD_UUID] },
164
- ues_touch: { p_entity_type: "__probe__", p_entity_id: BAD_UUID },
165
- // candidates
166
- reference_search_candidates: { p_token: "__probe__", p_limit: 1 },
167
- // comments (W6) — every fn takes a uuid arg, so the unparseable sentinel
168
- // guarantees 22P02 before any SECURITY DEFINER body runs (no write occurs).
169
- cmt_list: { p_entity_type: "__probe__", p_entity_id: BAD_UUID },
170
- cmt_add: {
171
- p_entity_type: "__probe__",
172
- p_entity_id: BAD_UUID,
173
- p_body: "__probe__"
174
- },
175
- cmt_edit: { p_id: BAD_UUID, p_body: "__probe__" },
176
- cmt_delete: { p_id: BAD_UUID }
177
- };
178
- function isMissingFunctionError(error) {
179
- if (!error || typeof error !== "object") return false;
180
- return error.code === "PGRST202";
181
- }
182
- async function assertDemandedSchema(dataSource, options = {}) {
183
- const { selfTest = false, concurrency = 6, throwOnViolation = true } = options;
184
- const names = [...DEMANDED_RPC_NAMES];
185
- if (selfTest) names.push(SELF_TEST_MISSING_RPC);
186
- const missing = [];
187
- const unreachable = [];
188
- const answered = [];
189
- let cursor = 0;
190
- async function worker() {
191
- while (cursor < names.length) {
192
- const fn = names[cursor];
193
- cursor += 1;
194
- if (!fn) continue;
195
- const args = fn === SELF_TEST_MISSING_RPC ? {} : PROBE_ARGS[fn];
196
- try {
197
- const { error } = await dataSource.rpc(fn, args);
198
- if (error == null) answered.push(fn);
199
- else if (isMissingFunctionError(error)) missing.push(fn);
200
- else answered.push(fn);
201
- } catch (e) {
202
- unreachable.push({ fn, error: e });
203
- }
204
- }
205
- }
206
- await Promise.all(
207
- Array.from({ length: Math.min(concurrency, names.length) }, worker)
208
- );
209
- if (selfTest) {
210
- const selfTestMissing = missing.includes(SELF_TEST_MISSING_RPC);
211
- const idx = missing.indexOf(SELF_TEST_MISSING_RPC);
212
- if (idx >= 0) missing.splice(idx, 1);
213
- const answeredIdx = answered.indexOf(SELF_TEST_MISSING_RPC);
214
- if (answeredIdx >= 0) answered.splice(answeredIdx, 1);
215
- if (!selfTestMissing) {
216
- throw new Error(
217
- `assertDemandedSchema self-test FAILED: the fabricated function "${SELF_TEST_MISSING_RPC}" did not come back as missing (PGRST202). This probe cannot currently fail, so its green result proves nothing \u2014 the dataSource is swallowing or faking errors.`
218
- );
219
- }
220
- }
221
- if (unreachable.length > 0) {
222
- throw new Error(
223
- `assertDemandedSchema could not complete: ${unreachable.length} probe call(s) failed to reach the database (${unreachable.map((u) => u.fn).join(", ")}). This is NOT a schema verdict \u2014 fix connectivity and re-run.`
224
- );
225
- }
226
- const ok = missing.length === 0;
227
- const report = { ok, missing, unreachable, answered };
228
- if (!ok && throwOnViolation) {
229
- throw new Error(
230
- `DEMANDED SCHEMA VIOLATION: the database this dataSource points at cannot answer ${missing.length} demanded @ai-matrx/associations function(s): ${missing.join(", ")}. This package demands the AI Matrx platform schema (README \xA7 The demanded schema); a database without it is not this package's database.`
231
- );
232
- }
233
- return report;
234
- }
235
-
236
- // src/react/context.tsx
237
72
  var import_jsx_runtime = require("react/jsx-runtime");
238
73
  var AssociationsReactContext = (0, import_react.createContext)(
239
74
  null
240
75
  );
241
- function isDevelopmentBuild() {
242
- try {
243
- return typeof process !== "undefined" && true;
244
- } catch {
245
- return false;
246
- }
247
- }
248
76
  function AssociationsProvider({
249
77
  store,
250
- probeSchema,
251
78
  notifier,
252
79
  windowShell,
253
80
  capture,
@@ -257,28 +84,6 @@ function AssociationsProvider({
257
84
  children
258
85
  }) {
259
86
  const notifierWarned = (0, import_react.useRef)(false);
260
- const shouldProbe = probeSchema ?? isDevelopmentBuild();
261
- (0, import_react.useEffect)(() => {
262
- if (!shouldProbe) return;
263
- let stale = false;
264
- void (async () => {
265
- try {
266
- await assertDemandedSchema(store.dataSource);
267
- } catch (error) {
268
- if (stale) return;
269
- store.errorSink({
270
- code: "demanded_schema_violation",
271
- message: error instanceof Error ? error.message : "assertDemandedSchema failed",
272
- context: {
273
- remedy: "Run the platform.associations schema (README \xA7 The demanded schema) on the database this dataSource points at."
274
- }
275
- });
276
- }
277
- })();
278
- return () => {
279
- stale = true;
280
- };
281
- }, [shouldProbe, store]);
282
87
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
283
88
  AssociationsReactContext.Provider,
284
89
  {
@@ -487,7 +292,9 @@ var ENTITY_TYPE_TOKENS = [
487
292
  "context_item_value",
488
293
  "conversation",
489
294
  "conversation_value",
295
+ "credential_attachment",
490
296
  "credential_item",
297
+ "credential_mutation_receipt",
491
298
  "crm_address",
492
299
  "crm_affiliation",
493
300
  "crm_blocklist_entry",