fix(host): derive the picker capability union from a merge-extensible map

ds-review-bot round 1: the seam documented a merge-extensible union but
shipped a closed alias, and the gateway schema rejected any kind beyond
dialog/browse — a third backend could neither implement the seam nor be
advertised. The union now derives from an augmentable DirectoryPickerCapabilities
map, host.describe.directoryPicker preserves unknown wire kinds, and the
browse fixture applies listDirectory's root special case so creating under
'/' no longer mints a '//name' identity.
This commit is contained in:
creatixchu
2026-07-28 17:09:43 +08:00
parent 716d3ca636
commit c565022c8a
11 changed files with 51 additions and 12 deletions
+12 -2
View File
@@ -73,8 +73,18 @@ export interface DirectoryPickerBrowseCapability {
createDirectory(path: string, name: string): Promise<string>
}
/** Union of interaction shapes a backend can provide (merge-extensible: grows with backends). */
export type DirectoryPickerCapability = DirectoryPickerDialogCapability | DirectoryPickerBrowseCapability
/**
* Merge-extensible registry of interaction shapes keyed by capability kind: a
* new backend declaration-merges its shape here (the entry's `kind` literal
* must equal its key) instead of editing this package.
*/
export interface DirectoryPickerCapabilities {
dialog: DirectoryPickerDialogCapability
browse: DirectoryPickerBrowseCapability
}
/** Union of interaction shapes a backend can provide, derived from the merge-extensible {@link DirectoryPickerCapabilities} map. */
export type DirectoryPickerCapability = DirectoryPickerCapabilities[keyof DirectoryPickerCapabilities]
/** Closed failure vocabulary of the browse primitives (mirrored onto the wire by consumers). */
export type DirectoryPickerErrorCode = 'directory-unreadable' | 'directory-exists' | 'directory-create-failed'