Files
yaak-mountain-loop/crates/common/yaak-rpc-schema/bindings/gen_util.ts
T
Gregory SchierandClaude Opus 5 333e3c1653 feat(import): add stable per-resource source keys to the importer contract
Re-importing an edited document currently has no way to tell an updated
request from a new one, because every import mints fresh model IDs. Give
each imported resource a key that identifies its source element instead,
so a later import can match against what it already created.

`ImportResponse` gains an optional `sourceKeys` map, keyed by the resource
IDs plugins already emit. A parallel map keeps `ImportResources` and the
partial TS types unchanged.

Bundled importers emit keys where the format carries them: Postman item
IDs, Insomnia `_id`s, OpenAPI `operationId` (falling back to the route),
and Yaak model IDs. curl has no identity of its own, so it emits none.

Planning derives a key for anything left over, hashed from the model type,
folder ancestry, and name or method+URL, prefixed `fb:` so later code can
tell derived keys from importer-provided ones. These break when the source
document renames or moves a resource, which is accepted.

Keys land in `ImportPlan.source_keys`, keyed by minted model ID so the
mapping stays lossless, ready for the commit step to persist. Nothing
consumes them yet.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-31 11:14:52 -07:00

24 lines
1.3 KiB
TypeScript
Generated

// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { Environment, Folder, GrpcRequest, HttpRequest, WebsocketRequest, Workspace } from "./gen_models";
export type BatchUpsertResult = { workspaces: Array<Workspace>, environments: Array<Environment>, folders: Array<Folder>, httpRequests: Array<HttpRequest>, grpcRequests: Array<GrpcRequest>, websocketRequests: Array<WebsocketRequest>, };
/**
* Where a staged import will be committed.
*
* The destination workspace and optional folder IDs are captured in the plan so the preview describes
* the exact destination that confirmation will use.
*/
export type ImportDestination = { "type": "new_workspace" } | { "type": "existing_workspace", workspaceId: string, folderId?: string, };
export type ImportPlan = { importer: string, destination: ImportDestination, resources: BatchUpsertResult, warnings: Array<ImportPlanWarning>,
/**
* Stable source key for every model in `resources`, keyed by its freshly minted ID.
*
* Committing the plan can persist these so a later import of the same document recognizes
* which models it already created, instead of duplicating them.
*/
sourceKeys: { [key in string]?: string }, };
export type ImportPlanWarning = { title: string, detail: string, };