@ai-matrx/associations 0.9.32 → 0.10.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.
- package/CHANGELOG.md +6 -0
- package/dist/{CommentThread-BSgSGSzO.d.cts → CommentThread-B0aryGyN.d.cts} +38 -34
- package/dist/{CommentThread-BSgSGSzO.d.ts → CommentThread-B0aryGyN.d.ts} +38 -34
- package/dist/core/index.cjs +64 -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 +64 -51
- package/dist/core/index.js.map +1 -1
- package/dist/index.cjs +8 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +75 -33
- package/dist/index.d.ts +75 -33
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -1
- package/dist/react/index.cjs +3 -0
- 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 +3 -0
- 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 +3 -3
package/dist/core/index.d.cts
CHANGED
|
@@ -372,9 +372,19 @@ type EntityRowResult = {
|
|
|
372
372
|
interface CreateEntityRowArgs {
|
|
373
373
|
/** The new row's human name — written to the registry `titleColumn`. */
|
|
374
374
|
title: string;
|
|
375
|
-
/**
|
|
375
|
+
/**
|
|
376
|
+
* The organization the new row belongs to. REQUIRED by
|
|
377
|
+
* `public.entity_row_create`: every creatable token's table carries
|
|
378
|
+
* `organization_id`, and the door refuses a row with nobody owning it.
|
|
379
|
+
*/
|
|
376
380
|
orgId?: string | null;
|
|
377
|
-
/**
|
|
381
|
+
/**
|
|
382
|
+
* 🚨 NO LONGER WRITABLE THROUGH THIS SERVICE (DOORS-ONLY-4). The door writes the
|
|
383
|
+
* name, the owner and the organization and nothing else, so a non-empty value here
|
|
384
|
+
* is REFUSED with the columns named rather than dropped on the floor. A token whose
|
|
385
|
+
* table needs more than a name is created by its own feature's create service; this
|
|
386
|
+
* generic path then only renames it.
|
|
387
|
+
*/
|
|
378
388
|
extraColumns?: Record<string, unknown>;
|
|
379
389
|
}
|
|
380
390
|
interface EntityRowsServiceApi {
|
package/dist/core/index.d.ts
CHANGED
|
@@ -372,9 +372,19 @@ type EntityRowResult = {
|
|
|
372
372
|
interface CreateEntityRowArgs {
|
|
373
373
|
/** The new row's human name — written to the registry `titleColumn`. */
|
|
374
374
|
title: string;
|
|
375
|
-
/**
|
|
375
|
+
/**
|
|
376
|
+
* The organization the new row belongs to. REQUIRED by
|
|
377
|
+
* `public.entity_row_create`: every creatable token's table carries
|
|
378
|
+
* `organization_id`, and the door refuses a row with nobody owning it.
|
|
379
|
+
*/
|
|
376
380
|
orgId?: string | null;
|
|
377
|
-
/**
|
|
381
|
+
/**
|
|
382
|
+
* 🚨 NO LONGER WRITABLE THROUGH THIS SERVICE (DOORS-ONLY-4). The door writes the
|
|
383
|
+
* name, the owner and the organization and nothing else, so a non-empty value here
|
|
384
|
+
* is REFUSED with the columns named rather than dropped on the floor. A token whose
|
|
385
|
+
* table needs more than a name is created by its own feature's create service; this
|
|
386
|
+
* generic path then only renames it.
|
|
387
|
+
*/
|
|
378
388
|
extraColumns?: Record<string, unknown>;
|
|
379
389
|
}
|
|
380
390
|
interface EntityRowsServiceApi {
|
package/dist/core/index.js
CHANGED
|
@@ -570,6 +570,7 @@ var ENTITY_TYPE_METADATA = {
|
|
|
570
570
|
"mandate": { token: "mandate", schema: "mandate", table: "definition", label: "Mandate Definition (new)", baseTier: 1, isComponent: false, isModule: false, isListed: true, scopeable: true, category: null, referencePickable: false, titleColumn: null, contentRole: null, referenceCategory: null },
|
|
571
571
|
"mandate_advance_batch_row": { token: "mandate_advance_batch_row", schema: "mandate", table: "advance_batch_row", label: "Pin advance batch row", baseTier: 1, isComponent: false, isModule: false, isListed: false, scopeable: true, category: null, referencePickable: false, titleColumn: null, contentRole: null, referenceCategory: null },
|
|
572
572
|
"mandate_binding": { token: "mandate_binding", schema: "mandate", table: "binding", label: "Mandate Binding (new)", baseTier: 1, isComponent: false, isModule: false, isListed: true, scopeable: true, category: null, referencePickable: false, titleColumn: null, contentRole: null, referenceCategory: null },
|
|
573
|
+
"mandate_goal_clauses": { token: "mandate_goal_clauses", schema: "mandate", table: "goal_clauses", label: "Mandate Goal Clauses", baseTier: 1, isComponent: false, isModule: false, isListed: false, scopeable: true, category: null, referencePickable: false, titleColumn: null, contentRole: null, referenceCategory: null },
|
|
573
574
|
"mandate_observation": { token: "mandate_observation", schema: "mandate", table: "observation", label: "Mandate Observation", baseTier: 1, isComponent: true, isModule: false, isListed: false, scopeable: true, category: null, referencePickable: false, titleColumn: null, contentRole: null, referenceCategory: null },
|
|
574
575
|
"mandate_reference": { token: "mandate_reference", schema: "mandate", table: "reference", label: "Mandate Reference", baseTier: 1, isComponent: false, isModule: false, isListed: false, scopeable: true, category: null, referencePickable: false, titleColumn: null, contentRole: null, referenceCategory: null },
|
|
575
576
|
"mandate_scan": { token: "mandate_scan", schema: "mandate", table: "scan", label: "Mandate Scan", baseTier: 1, isComponent: false, isModule: false, isListed: false, scopeable: true, category: null, referencePickable: false, titleColumn: null, contentRole: null, referenceCategory: null },
|
|
@@ -616,6 +617,7 @@ var ENTITY_TYPE_METADATA = {
|
|
|
616
617
|
"notification_event_override": { token: "notification_event_override", schema: "communication", table: "notification_event_override", label: "Notification Event Override", baseTier: 1, isComponent: false, isModule: false, isListed: false, scopeable: true, category: null, referencePickable: false, titleColumn: null, contentRole: null, referenceCategory: null },
|
|
617
618
|
"notification_event_type": { token: "notification_event_type", schema: "communication", table: "notification_event_type", label: "Notification Event Type", baseTier: 1, isComponent: false, isModule: false, isListed: false, scopeable: true, category: null, referencePickable: false, titleColumn: null, contentRole: null, referenceCategory: null },
|
|
618
619
|
"notification_preference": { token: "notification_preference", schema: "communication", table: "notification_preference", label: "Notification Preference", baseTier: 1, isComponent: false, isModule: false, isListed: false, scopeable: true, category: null, referencePickable: false, titleColumn: null, contentRole: null, referenceCategory: null },
|
|
620
|
+
"notification_submission": { token: "notification_submission", schema: "communication", table: "notification_submission", label: "Self notification submission", baseTier: 1, isComponent: false, isModule: false, isListed: false, scopeable: true, category: null, referencePickable: false, titleColumn: null, contentRole: null, referenceCategory: null },
|
|
619
621
|
"notify_outsider_door_baseline": { token: "notify_outsider_door_baseline", schema: "hr", table: "notify_outsider_door_baseline", label: "Notify Outsider Door Baseline", baseTier: 1, isComponent: false, isModule: false, isListed: false, scopeable: true, category: null, referencePickable: false, titleColumn: null, contentRole: null, referenceCategory: null },
|
|
620
622
|
"oauth_handoff_claim": { token: "oauth_handoff_claim", schema: "platform", table: "_oauth_handoff_claim", label: "Oauth Handoff Claim", baseTier: 1, isComponent: false, isModule: false, isListed: false, scopeable: true, category: null, referencePickable: false, titleColumn: null, contentRole: null, referenceCategory: null },
|
|
621
623
|
"opinion_clusters": { token: "opinion_clusters", schema: "legal", table: "opinion_clusters", label: "Opinion Clusters", baseTier: 1, isComponent: false, isModule: false, isListed: false, scopeable: true, category: null, referencePickable: false, titleColumn: null, contentRole: null, referenceCategory: null },
|
|
@@ -664,6 +666,7 @@ var ENTITY_TYPE_METADATA = {
|
|
|
664
666
|
"plan_node_artifact": { token: "plan_node_artifact", schema: "plan", table: "node_artifact", label: "Plan Node Artifact", baseTier: 1, isComponent: true, isModule: false, isListed: false, scopeable: true, category: null, referencePickable: false, titleColumn: null, contentRole: null, referenceCategory: null },
|
|
665
667
|
"plan_node_step": { token: "plan_node_step", schema: "plan", table: "node_step", label: "Plan Node Step", baseTier: 1, isComponent: true, isModule: false, isListed: false, scopeable: true, category: null, referencePickable: false, titleColumn: null, contentRole: null, referenceCategory: null },
|
|
666
668
|
"plan_profile": { token: "plan_profile", schema: "plan", table: "profile", label: "Plan Vertical Profile", baseTier: 1, isComponent: false, isModule: false, isListed: false, scopeable: true, category: null, referencePickable: false, titleColumn: "vertical", contentRole: null, referenceCategory: null },
|
|
669
|
+
"platform_action_request": { token: "platform_action_request", schema: "platform", table: "action_request", label: "Action Request", baseTier: 1, isComponent: false, isModule: false, isListed: false, scopeable: true, category: null, referencePickable: false, titleColumn: null, contentRole: null, referenceCategory: null },
|
|
667
670
|
"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 },
|
|
668
671
|
"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 },
|
|
669
672
|
"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 },
|
|
@@ -1560,6 +1563,7 @@ var ENTITY_TYPE_TOKENS = [
|
|
|
1560
1563
|
"mandate",
|
|
1561
1564
|
"mandate_advance_batch_row",
|
|
1562
1565
|
"mandate_binding",
|
|
1566
|
+
"mandate_goal_clauses",
|
|
1563
1567
|
"mandate_observation",
|
|
1564
1568
|
"mandate_reference",
|
|
1565
1569
|
"mandate_scan",
|
|
@@ -1606,6 +1610,7 @@ var ENTITY_TYPE_TOKENS = [
|
|
|
1606
1610
|
"notification_event_override",
|
|
1607
1611
|
"notification_event_type",
|
|
1608
1612
|
"notification_preference",
|
|
1613
|
+
"notification_submission",
|
|
1609
1614
|
"notify_outsider_door_baseline",
|
|
1610
1615
|
"oauth_handoff_claim",
|
|
1611
1616
|
"opinion_clusters",
|
|
@@ -1654,6 +1659,7 @@ var ENTITY_TYPE_TOKENS = [
|
|
|
1654
1659
|
"plan_node_artifact",
|
|
1655
1660
|
"plan_node_step",
|
|
1656
1661
|
"plan_profile",
|
|
1662
|
+
"platform_action_request",
|
|
1657
1663
|
"platform_actor_session",
|
|
1658
1664
|
"platform_actor_token",
|
|
1659
1665
|
"platform_actor_token_event",
|
|
@@ -3137,31 +3143,7 @@ function createTitlesService(deps, candidates) {
|
|
|
3137
3143
|
|
|
3138
3144
|
// src/core/entityRows.ts
|
|
3139
3145
|
function createEntityRowsService(deps, titles) {
|
|
3140
|
-
const { dataSource,
|
|
3141
|
-
function tableFor(token, schema, table) {
|
|
3142
|
-
if (schema && schema !== "public") {
|
|
3143
|
-
if (!dataSource.schema) {
|
|
3144
|
-
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)`;
|
|
3145
|
-
errorSink({
|
|
3146
|
-
code: "datasource_missing_table_capability",
|
|
3147
|
-
message: `[entityRows] ${error}`,
|
|
3148
|
-
context: { token, schema, table }
|
|
3149
|
-
});
|
|
3150
|
-
return { ok: false, error };
|
|
3151
|
-
}
|
|
3152
|
-
return { ok: true, query: dataSource.schema(schema).from(table) };
|
|
3153
|
-
}
|
|
3154
|
-
if (!dataSource.from) {
|
|
3155
|
-
const error = `dataSource has no from() capability \u2014 entity-row writes for "${token}" need a table-capable dataSource (a real supabase-js client)`;
|
|
3156
|
-
errorSink({
|
|
3157
|
-
code: "datasource_missing_table_capability",
|
|
3158
|
-
message: `[entityRows] ${error}`,
|
|
3159
|
-
context: { token, schema, table }
|
|
3160
|
-
});
|
|
3161
|
-
return { ok: false, error };
|
|
3162
|
-
}
|
|
3163
|
-
return { ok: true, query: dataSource.from(table) };
|
|
3164
|
-
}
|
|
3146
|
+
const { dataSource, registry, errorSink } = deps;
|
|
3165
3147
|
function requireTitleColumn(token, op) {
|
|
3166
3148
|
const info = registry.getEntityInfo(token);
|
|
3167
3149
|
if (!info.titleColumn) {
|
|
@@ -3173,43 +3155,68 @@ function createEntityRowsService(deps, titles) {
|
|
|
3173
3155
|
});
|
|
3174
3156
|
return { ok: false, error };
|
|
3175
3157
|
}
|
|
3176
|
-
return { ok: true
|
|
3158
|
+
return { ok: true };
|
|
3177
3159
|
}
|
|
3178
3160
|
return {
|
|
3179
3161
|
/**
|
|
3180
|
-
*
|
|
3181
|
-
*
|
|
3182
|
-
*
|
|
3183
|
-
*
|
|
3162
|
+
* Create one row of `token`'s backing table named `title`, through
|
|
3163
|
+
* `public.entity_row_create`. The door stamps `created_by` from `auth.uid()`,
|
|
3164
|
+
* checks the caller can act in the organization, and refuses machinery tokens and
|
|
3165
|
+
* tables with no organization by name. Returns the new row's id + title. The
|
|
3166
|
+
* caller wires associations afterwards — this layer never writes edges.
|
|
3184
3167
|
*/
|
|
3185
3168
|
async createEntityRow(token, args) {
|
|
3186
3169
|
const gate = requireTitleColumn(token, "creating rows");
|
|
3187
3170
|
if (!gate.ok) return gate;
|
|
3188
|
-
const info = registry.getEntityInfo(token);
|
|
3189
3171
|
const title = args.title.trim();
|
|
3190
3172
|
if (!title) return { ok: false, error: "Name is required" };
|
|
3173
|
+
const extras = Object.keys(args.extraColumns ?? {});
|
|
3174
|
+
if (extras.length > 0) {
|
|
3175
|
+
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.`;
|
|
3176
|
+
errorSink({
|
|
3177
|
+
code: "entity_row_extra_columns_unsupported",
|
|
3178
|
+
message: `[createEntityRow] extraColumns are not writable through entity_row_create for "${token}": ${extras.join(", ")}`,
|
|
3179
|
+
context: { token, extras }
|
|
3180
|
+
});
|
|
3181
|
+
return { ok: false, error };
|
|
3182
|
+
}
|
|
3183
|
+
if (!args.orgId) {
|
|
3184
|
+
const error = `Name the organization this ${registry.getEntityInfo(token).label} belongs to.`;
|
|
3185
|
+
errorSink({
|
|
3186
|
+
code: "entity_row_missing_organization",
|
|
3187
|
+
message: `[createEntityRow] no organization supplied for "${token}"; entity_row_create requires one`,
|
|
3188
|
+
context: { token }
|
|
3189
|
+
});
|
|
3190
|
+
return { ok: false, error };
|
|
3191
|
+
}
|
|
3191
3192
|
try {
|
|
3192
|
-
const
|
|
3193
|
-
|
|
3194
|
-
|
|
3195
|
-
|
|
3196
|
-
|
|
3197
|
-
...info.ownerColumn ? { [info.ownerColumn]: userId } : {},
|
|
3198
|
-
...info.orgColumn && args.orgId ? { [info.orgColumn]: args.orgId } : {},
|
|
3199
|
-
...args.extraColumns ?? {}
|
|
3200
|
-
};
|
|
3201
|
-
const { data, error } = await table.query.insert(row).select("id").single();
|
|
3193
|
+
const { data, error } = await dataSource.rpc("entity_row_create", {
|
|
3194
|
+
p_token: token,
|
|
3195
|
+
p_title: title,
|
|
3196
|
+
p_organization_id: args.orgId
|
|
3197
|
+
});
|
|
3202
3198
|
if (error) {
|
|
3203
3199
|
errorSink({
|
|
3204
3200
|
code: "entity_row_insert_failed",
|
|
3205
|
-
message: `[createEntityRow]
|
|
3201
|
+
message: `[createEntityRow] entity_row_create failed for "${token}": ${error.message}`,
|
|
3206
3202
|
context: { token, detail: error }
|
|
3207
3203
|
});
|
|
3208
3204
|
return { ok: false, error: error.message };
|
|
3209
3205
|
}
|
|
3210
|
-
const
|
|
3211
|
-
|
|
3212
|
-
|
|
3206
|
+
const row = data;
|
|
3207
|
+
if (!row || typeof row.id !== "string" || !row.id) {
|
|
3208
|
+
const msg = "The create door returned no record.";
|
|
3209
|
+
errorSink({
|
|
3210
|
+
code: "entity_row_insert_failed",
|
|
3211
|
+
message: `[createEntityRow] entity_row_create returned no id for "${token}"`,
|
|
3212
|
+
context: { token, detail: data }
|
|
3213
|
+
});
|
|
3214
|
+
return { ok: false, error: msg };
|
|
3215
|
+
}
|
|
3216
|
+
const id = row.id;
|
|
3217
|
+
const named = typeof row.title === "string" && row.title ? row.title : title;
|
|
3218
|
+
titles.prime(token, id, named);
|
|
3219
|
+
return { ok: true, data: { id, title: named } };
|
|
3213
3220
|
} catch (e) {
|
|
3214
3221
|
const msg = e instanceof Error ? e.message : "Failed to create";
|
|
3215
3222
|
errorSink({
|
|
@@ -3220,21 +3227,27 @@ function createEntityRowsService(deps, titles) {
|
|
|
3220
3227
|
return { ok: false, error: msg };
|
|
3221
3228
|
}
|
|
3222
3229
|
},
|
|
3223
|
-
/**
|
|
3230
|
+
/**
|
|
3231
|
+
* Rename one row of `token`'s table through `public.entity_row_rename`. The door
|
|
3232
|
+
* decides on the one ladder — the row's author, `editor` on the row, or a platform
|
|
3233
|
+
* admin — and answers "there is no such thing here" rather than telling a caller
|
|
3234
|
+
* that somebody else's row exists.
|
|
3235
|
+
*/
|
|
3224
3236
|
async renameEntityRow(token, id, title) {
|
|
3225
3237
|
const gate = requireTitleColumn(token, "renaming rows");
|
|
3226
3238
|
if (!gate.ok) return gate;
|
|
3227
|
-
const info = registry.getEntityInfo(token);
|
|
3228
3239
|
const trimmed = title.trim();
|
|
3229
3240
|
if (!trimmed) return { ok: false, error: "Name is required" };
|
|
3230
3241
|
try {
|
|
3231
|
-
const
|
|
3232
|
-
|
|
3233
|
-
|
|
3242
|
+
const { error } = await dataSource.rpc("entity_row_rename", {
|
|
3243
|
+
p_token: token,
|
|
3244
|
+
p_id: id,
|
|
3245
|
+
p_title: trimmed
|
|
3246
|
+
});
|
|
3234
3247
|
if (error) {
|
|
3235
3248
|
errorSink({
|
|
3236
3249
|
code: "entity_row_update_failed",
|
|
3237
|
-
message: `[renameEntityRow]
|
|
3250
|
+
message: `[renameEntityRow] entity_row_rename failed for "${token}": ${error.message}`,
|
|
3238
3251
|
context: { token, id, detail: error }
|
|
3239
3252
|
});
|
|
3240
3253
|
return { ok: false, error: error.message };
|