@ai-matrx/associations 0.9.33 → 0.10.1
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 +6 -0
- package/dist/{CommentThread-CaUsmcYj.d.cts → CommentThread-D1rzo_pu.d.cts} +43 -35
- package/dist/{CommentThread-CaUsmcYj.d.ts → CommentThread-D1rzo_pu.d.ts} +43 -35
- package/dist/core/index.cjs +62 -51
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.cts +12 -2
- package/dist/core/index.d.ts +12 -2
- package/dist/core/index.js +62 -51
- package/dist/core/index.js.map +1 -1
- package/dist/index.cjs +6 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +59 -33
- package/dist/index.d.ts +59 -33
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -1
- package/dist/react/index.cjs +4 -2
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.d.cts +2 -2
- package/dist/react/index.d.ts +2 -2
- package/dist/react/index.js +4 -2
- package/dist/react/index.js.map +1 -1
- package/dist/react/lazy/index.d.cts +1 -1
- package/dist/react/lazy/index.d.ts +1 -1
- package/package.json +10 -10
package/dist/core/index.cjs
CHANGED
|
@@ -933,6 +933,8 @@ var ENTITY_TYPE_METADATA = {
|
|
|
933
933
|
"template_context_items": { token: "template_context_items", schema: "context", table: "template_context_items", label: "Template Context Items", baseTier: 1, isComponent: false, isModule: false, isListed: false, scopeable: true, category: null, referencePickable: false, titleColumn: null, contentRole: null, referenceCategory: null },
|
|
934
934
|
"template_scope_types": { token: "template_scope_types", schema: "context", table: "template_scope_types", label: "Template Scope Types", baseTier: 1, isComponent: false, isModule: false, isListed: false, scopeable: true, category: null, referencePickable: false, titleColumn: null, contentRole: null, referenceCategory: null },
|
|
935
935
|
"templates": { token: "templates", schema: "context", table: "templates", label: "Templates", baseTier: 1, isComponent: false, isModule: false, isListed: false, scopeable: true, category: null, referencePickable: false, titleColumn: null, contentRole: null, referenceCategory: null },
|
|
936
|
+
"test_handset_inbox": { token: "test_handset_inbox", schema: "communication", table: "test_handset_inbox", label: "Test Handset Inbox", baseTier: 1, isComponent: false, isModule: false, isListed: false, scopeable: true, category: null, referencePickable: false, titleColumn: null, contentRole: null, referenceCategory: null },
|
|
937
|
+
"test_handset_verification": { token: "test_handset_verification", schema: "communication", table: "test_handset_verification", label: "Test Handset Verification", baseTier: 1, isComponent: false, isModule: false, isListed: false, scopeable: true, category: null, referencePickable: false, titleColumn: null, contentRole: null, referenceCategory: null },
|
|
936
938
|
"thread": { token: "thread", schema: "workspace", table: "threads", label: "Thread", baseTier: 1, isComponent: false, isModule: false, isListed: false, scopeable: true, category: null, referencePickable: true, titleColumn: "title", contentRole: null, referenceCategory: null },
|
|
937
939
|
"tool": { token: "tool", schema: "tool", table: "definition", label: "Tool", baseTier: 1, isComponent: false, isModule: false, isListed: false, scopeable: true, category: "Tools", referencePickable: true, titleColumn: "name", contentRole: null, referenceCategory: null },
|
|
938
940
|
"tool_binding": { token: "tool_binding", schema: "tool", table: "binding", label: "Tool binding", baseTier: 1, isComponent: true, isModule: false, isListed: false, scopeable: true, category: null, referencePickable: false, titleColumn: null, contentRole: null, referenceCategory: null },
|
|
@@ -1926,6 +1928,8 @@ var ENTITY_TYPE_TOKENS = [
|
|
|
1926
1928
|
"template_context_items",
|
|
1927
1929
|
"template_scope_types",
|
|
1928
1930
|
"templates",
|
|
1931
|
+
"test_handset_inbox",
|
|
1932
|
+
"test_handset_verification",
|
|
1929
1933
|
"thread",
|
|
1930
1934
|
"tool",
|
|
1931
1935
|
"tool_binding",
|
|
@@ -3195,31 +3199,7 @@ function createTitlesService(deps, candidates) {
|
|
|
3195
3199
|
|
|
3196
3200
|
// src/core/entityRows.ts
|
|
3197
3201
|
function createEntityRowsService(deps, titles) {
|
|
3198
|
-
const { dataSource,
|
|
3199
|
-
function tableFor(token, schema, table) {
|
|
3200
|
-
if (schema && schema !== "public") {
|
|
3201
|
-
if (!dataSource.schema) {
|
|
3202
|
-
const error = `dataSource has no schema() capability \u2014 entity-row writes for "${token}" (${schema}.${table}) need a table-capable dataSource (a real supabase-js client)`;
|
|
3203
|
-
errorSink({
|
|
3204
|
-
code: "datasource_missing_table_capability",
|
|
3205
|
-
message: `[entityRows] ${error}`,
|
|
3206
|
-
context: { token, schema, table }
|
|
3207
|
-
});
|
|
3208
|
-
return { ok: false, error };
|
|
3209
|
-
}
|
|
3210
|
-
return { ok: true, query: dataSource.schema(schema).from(table) };
|
|
3211
|
-
}
|
|
3212
|
-
if (!dataSource.from) {
|
|
3213
|
-
const error = `dataSource has no from() capability \u2014 entity-row writes for "${token}" need a table-capable dataSource (a real supabase-js client)`;
|
|
3214
|
-
errorSink({
|
|
3215
|
-
code: "datasource_missing_table_capability",
|
|
3216
|
-
message: `[entityRows] ${error}`,
|
|
3217
|
-
context: { token, schema, table }
|
|
3218
|
-
});
|
|
3219
|
-
return { ok: false, error };
|
|
3220
|
-
}
|
|
3221
|
-
return { ok: true, query: dataSource.from(table) };
|
|
3222
|
-
}
|
|
3202
|
+
const { dataSource, registry, errorSink } = deps;
|
|
3223
3203
|
function requireTitleColumn(token, op) {
|
|
3224
3204
|
const info = registry.getEntityInfo(token);
|
|
3225
3205
|
if (!info.titleColumn) {
|
|
@@ -3231,43 +3211,68 @@ function createEntityRowsService(deps, titles) {
|
|
|
3231
3211
|
});
|
|
3232
3212
|
return { ok: false, error };
|
|
3233
3213
|
}
|
|
3234
|
-
return { ok: true
|
|
3214
|
+
return { ok: true };
|
|
3235
3215
|
}
|
|
3236
3216
|
return {
|
|
3237
3217
|
/**
|
|
3238
|
-
*
|
|
3239
|
-
*
|
|
3240
|
-
*
|
|
3241
|
-
*
|
|
3218
|
+
* Create one row of `token`'s backing table named `title`, through
|
|
3219
|
+
* `public.entity_row_create`. The door stamps `created_by` from `auth.uid()`,
|
|
3220
|
+
* checks the caller can act in the organization, and refuses machinery tokens and
|
|
3221
|
+
* tables with no organization by name. Returns the new row's id + title. The
|
|
3222
|
+
* caller wires associations afterwards — this layer never writes edges.
|
|
3242
3223
|
*/
|
|
3243
3224
|
async createEntityRow(token, args) {
|
|
3244
3225
|
const gate = requireTitleColumn(token, "creating rows");
|
|
3245
3226
|
if (!gate.ok) return gate;
|
|
3246
|
-
const info = registry.getEntityInfo(token);
|
|
3247
3227
|
const title = args.title.trim();
|
|
3248
3228
|
if (!title) return { ok: false, error: "Name is required" };
|
|
3229
|
+
const extras = Object.keys(args.extraColumns ?? {});
|
|
3230
|
+
if (extras.length > 0) {
|
|
3231
|
+
const error = `A new ${registry.getEntityInfo(token).label} cannot be created here with ${extras.join(", ")}: the shared create door writes the name, the owner and the organization and nothing else. Create it with this feature's own create service, then attach it.`;
|
|
3232
|
+
errorSink({
|
|
3233
|
+
code: "entity_row_extra_columns_unsupported",
|
|
3234
|
+
message: `[createEntityRow] extraColumns are not writable through entity_row_create for "${token}": ${extras.join(", ")}`,
|
|
3235
|
+
context: { token, extras }
|
|
3236
|
+
});
|
|
3237
|
+
return { ok: false, error };
|
|
3238
|
+
}
|
|
3239
|
+
if (!args.orgId) {
|
|
3240
|
+
const error = `Name the organization this ${registry.getEntityInfo(token).label} belongs to.`;
|
|
3241
|
+
errorSink({
|
|
3242
|
+
code: "entity_row_missing_organization",
|
|
3243
|
+
message: `[createEntityRow] no organization supplied for "${token}"; entity_row_create requires one`,
|
|
3244
|
+
context: { token }
|
|
3245
|
+
});
|
|
3246
|
+
return { ok: false, error };
|
|
3247
|
+
}
|
|
3249
3248
|
try {
|
|
3250
|
-
const
|
|
3251
|
-
|
|
3252
|
-
|
|
3253
|
-
|
|
3254
|
-
|
|
3255
|
-
...info.ownerColumn ? { [info.ownerColumn]: userId } : {},
|
|
3256
|
-
...info.orgColumn && args.orgId ? { [info.orgColumn]: args.orgId } : {},
|
|
3257
|
-
...args.extraColumns ?? {}
|
|
3258
|
-
};
|
|
3259
|
-
const { data, error } = await table.query.insert(row).select("id").single();
|
|
3249
|
+
const { data, error } = await dataSource.rpc("entity_row_create", {
|
|
3250
|
+
p_token: token,
|
|
3251
|
+
p_title: title,
|
|
3252
|
+
p_organization_id: args.orgId
|
|
3253
|
+
});
|
|
3260
3254
|
if (error) {
|
|
3261
3255
|
errorSink({
|
|
3262
3256
|
code: "entity_row_insert_failed",
|
|
3263
|
-
message: `[createEntityRow]
|
|
3257
|
+
message: `[createEntityRow] entity_row_create failed for "${token}": ${error.message}`,
|
|
3264
3258
|
context: { token, detail: error }
|
|
3265
3259
|
});
|
|
3266
3260
|
return { ok: false, error: error.message };
|
|
3267
3261
|
}
|
|
3268
|
-
const
|
|
3269
|
-
|
|
3270
|
-
|
|
3262
|
+
const row = data;
|
|
3263
|
+
if (!row || typeof row.id !== "string" || !row.id) {
|
|
3264
|
+
const msg = "The create door returned no record.";
|
|
3265
|
+
errorSink({
|
|
3266
|
+
code: "entity_row_insert_failed",
|
|
3267
|
+
message: `[createEntityRow] entity_row_create returned no id for "${token}"`,
|
|
3268
|
+
context: { token, detail: data }
|
|
3269
|
+
});
|
|
3270
|
+
return { ok: false, error: msg };
|
|
3271
|
+
}
|
|
3272
|
+
const id = row.id;
|
|
3273
|
+
const named = typeof row.title === "string" && row.title ? row.title : title;
|
|
3274
|
+
titles.prime(token, id, named);
|
|
3275
|
+
return { ok: true, data: { id, title: named } };
|
|
3271
3276
|
} catch (e) {
|
|
3272
3277
|
const msg = e instanceof Error ? e.message : "Failed to create";
|
|
3273
3278
|
errorSink({
|
|
@@ -3278,21 +3283,27 @@ function createEntityRowsService(deps, titles) {
|
|
|
3278
3283
|
return { ok: false, error: msg };
|
|
3279
3284
|
}
|
|
3280
3285
|
},
|
|
3281
|
-
/**
|
|
3286
|
+
/**
|
|
3287
|
+
* Rename one row of `token`'s table through `public.entity_row_rename`. The door
|
|
3288
|
+
* decides on the one ladder — the row's author, `editor` on the row, or a platform
|
|
3289
|
+
* admin — and answers "there is no such thing here" rather than telling a caller
|
|
3290
|
+
* that somebody else's row exists.
|
|
3291
|
+
*/
|
|
3282
3292
|
async renameEntityRow(token, id, title) {
|
|
3283
3293
|
const gate = requireTitleColumn(token, "renaming rows");
|
|
3284
3294
|
if (!gate.ok) return gate;
|
|
3285
|
-
const info = registry.getEntityInfo(token);
|
|
3286
3295
|
const trimmed = title.trim();
|
|
3287
3296
|
if (!trimmed) return { ok: false, error: "Name is required" };
|
|
3288
3297
|
try {
|
|
3289
|
-
const
|
|
3290
|
-
|
|
3291
|
-
|
|
3298
|
+
const { error } = await dataSource.rpc("entity_row_rename", {
|
|
3299
|
+
p_token: token,
|
|
3300
|
+
p_id: id,
|
|
3301
|
+
p_title: trimmed
|
|
3302
|
+
});
|
|
3292
3303
|
if (error) {
|
|
3293
3304
|
errorSink({
|
|
3294
3305
|
code: "entity_row_update_failed",
|
|
3295
|
-
message: `[renameEntityRow]
|
|
3306
|
+
message: `[renameEntityRow] entity_row_rename failed for "${token}": ${error.message}`,
|
|
3296
3307
|
context: { token, id, detail: error }
|
|
3297
3308
|
});
|
|
3298
3309
|
return { ok: false, error: error.message };
|