fix(core): token writes keep their actor in history but are user-owned in field_sources
fieldOwner(actor) maps every non-plugin actor to "user" wherever field_sources is written (entries, engagements, list ownership from history), so syncs never overwrite a field an API token edited. authenticateAppToken also returns the token name; revokeAppToken reports whether it revoked; listSuggestions queries the canonical work id. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e3a759d768
commit
aa8e4db070
6 files changed
+110
-18
No files matched your search
@@ -12,6 +12,15 @@ import { restoreListFromHistory } from "./lists.ts";
|
||||
/** Who made a change. Plugin actors are `plugin:<pluginId>:<connectionId>`; API tokens are `token:<name>`. */
|
||||
export type Actor = "user" | `plugin:${string}:${string}` | `token:${string}`;
|
||||
|
||||
/**
|
||||
* Who owns a field in `field_sources` after `actor` writes it. Only plugin actors keep their name; the user,
|
||||
* through the UI or an API token, is always `"user"`, so syncs never overwrite a field a script edited.
|
||||
* History rows keep the full actor.
|
||||
*/
|
||||
export function fieldOwner(actor: string): string {
|
||||
return actor.startsWith("plugin:") ? actor : "user";
|
||||
}
|
||||
|
||||
/** User-layer entities that write `user_history`. */
|
||||
export type HistoryEntity = "entry" | "engagement" | "copy" | "list";
|
||||
|
||||
|
||||
Reference in new issue
Block a user