{"version":3,"sources":["../../src/generated/spaces.ts"],"sourcesContent":["// GENERATED by scripts/codegen-prototype/generate.mjs — DO NOT EDIT.\n// Source of truth: descriptors.spaces.mjs\n// Family: spaces — Space management (the space-manager app) — UI_AS_APPS_SPEC §5.\n\nimport { invoke } from '../catalog';\n\nconst withTry = <Args extends unknown[], R, E extends string>(\n  fn: (...args: Args) => Promise<R>,\n  fallback: E,\n): ((...args: Args) => Promise<R>) & { try: (...args: Args) => Promise<{ ok: true; value: R } | { ok: false; code: E }> } =>\n  Object.assign(fn, {\n    try: async (...args: Args) => {\n      try {\n        return { ok: true as const, value: await fn(...args) };\n      } catch (e) {\n        return { ok: false as const, code: (e as { code?: E }).code ?? fallback };\n      }\n    },\n  });\n\n/** A collaborator's role on a shared space: full `owner`, read-write `writer`, or read-only `reader`. */\nexport type Role =\n  | 'owner'\n  | 'writer'\n  | 'reader';\n\n/** Summary of a space, as returned by {@link listSpaces}. */\nexport interface SpaceInfo {\n  spaceId: string;\n  role?: Role;\n  owner?: string;\n  name?: string;\n}\n\n/** A member of a space (for the share/manage UI). */\nexport interface Member {\n  /** The **grantee** — `user:{uid}` | `group:{gid}`. This is the canonical name (core_concepts §4: \"principal\" is reserved for the authority context; a space member is a *grantee*). The host populates this on every member row. */\n  grantee: string;\n  /** @deprecated Use {@link Member.grantee}. Kept as an alias (same value) for back-compat during the `principal`→`grantee` migration; will be removed in a future major. The host still populates both. */\n  principal: string;\n  role: Role;\n  login?: string;\n  avatarUrl?: string;\n}\n\n/** A handle resolved to a principal (handle → who). */\nexport interface ResolvedUser {\n  uid: string;\n  login: string;\n  avatarUrl?: string;\n}\n\n/** One durable grant an app holds, for the §8.11 capability audit view. */\nexport interface GrantRecord {\n  /** The app's provider-qualified **program** identity (AA-01 `appKey`). The DEFAULT program keys to the bare `provider__namespace__repository`; a NAMED mini-app appends a fourth `enc()`-escaped component (`provider__namespace__repository__name`) so its grants isolate from the repo's other programs. Host-supplied — the app never builds this key. */\n  appKey: string;\n  spaceId: string;\n  /** Universal mount id (§3.5). */\n  mountId: string;\n  subtree?: string;\n  mode: 'ro' | 'rw';\n  name?: string;\n}\n\n/** A pending invitation to a space (pull-based sharing, FILE_SHARING_SPEC §6.4). It grants NO access until accepted — the recipient accepts it from their inbox ({@link listMyInvites} → {@link acceptInvite}), materializing membership. The display fields (`name`/`login`/`avatarUrl`) are untrusted for rendering. */\nexport interface Invite {\n  spaceId: string;\n  /** The invitee's uid — carried so the owner's pending list can {@link revokeInvite}(spaceId, uid). */\n  uid: string;\n  role: Role;\n  owner: string;\n  name?: string;\n  invitedBy: string;\n  /** epoch ms (server-stamped); absent until the write settles. */\n  invitedAt?: number;\n  login?: string;\n  avatarUrl?: string;\n}\n\nexport type ListSpacesError =\n  'auth-required' | 'cancelled' | 'forbidden' | 'not-found' | 'unsupported-scheme' | 'unknown';\n\n/**\n * List spaces you can access — all of them, or just those bound to this app.\n *\n * Capability: `spaces:app`. Catalog name: `spaces:list`.\n * @throws `Error & { code: ListSpacesError }` on host refusal.\n */\nexport const listSpaces = withTry<[opts?: { app?: boolean }], SpaceInfo[], ListSpacesError>(\n  (opts: { app?: boolean } = {}): Promise<SpaceInfo[]> =>\n    invoke<SpaceInfo[]>(\"spaces:list\", opts),\n  'unknown',\n);\n\nexport type ListAllSpacesError =\n  'auth-required' | 'cancelled' | 'forbidden' | 'not-found' | 'unsupported-scheme' | 'unknown';\n\n/**\n * Enumerate ALL the user's spaces (not just this app's).\n *\n * Capability: `spaces:user`. Catalog name: `spaces:listAll`.\n * @throws `Error & { code: ListAllSpacesError }` on host refusal.\n */\nexport const listAllSpaces = withTry<[], SpaceInfo[], ListAllSpacesError>(\n  (): Promise<SpaceInfo[]> =>\n    invoke<SpaceInfo[]>(\"spaces:listAll\", {}),\n  'unknown',\n);\n\nexport type GetSpaceMembersError =\n  'auth-required' | 'cancelled' | 'forbidden' | 'not-found' | 'unsupported-scheme' | 'unknown';\n\n/**\n * Read a space's members one-shot.\n *\n * Capability: `spaces:admin`. Catalog name: `spaces:members`.\n * @throws `Error & { code: GetSpaceMembersError }` on host refusal.\n */\nexport const getSpaceMembers = withTry<[string], Member[], GetSpaceMembersError>(\n  (spaceId: string): Promise<Member[]> =>\n    invoke<Member[]>(\"spaces:members\", { spaceId }),\n  'unknown',\n);\n\nexport type InviteToSpaceError =\n  'auth-required' | 'cancelled' | 'forbidden' | 'not-found' | 'unsupported-scheme' | 'unknown' | 'quota-exceeded';\n\n/**\n * Invite a user (by provider handle) to a space at a role. The host resolves\n * the handle, so the app never sees other users' uids except the one it\n * invited. Pull-based (FILE_SHARING_SPEC §6.4): this writes an INVITATION,\n * not membership — the recipient must {@link acceptInvite}. Re-inviting an\n * already-invited/member user is idempotent.\n *\n * Capability: `spaces:admin`. Catalog name: `spaces:invite`.\n * @throws `Error & { code: InviteToSpaceError }` on host refusal.\n */\nexport const inviteToSpace = withTry<[string, string, Role], void, InviteToSpaceError>(\n  async (spaceId: string, login: string, role: Role): Promise<void> => { await invoke<void>(\"spaces:invite\", { spaceId, login, role }); },\n  'unknown',\n);\n\nexport type UnshareSpaceError =\n  'auth-required' | 'cancelled' | 'forbidden' | 'not-found' | 'unsupported-scheme' | 'unknown' | 'conflict';\n\n/**\n * Remove a member from a space. Refused if it would orphan the space\n * (owner-lockout, T41).\n *\n * Capability: `spaces:admin`. Catalog name: `spaces:unshare`.\n * @throws `Error & { code: UnshareSpaceError }` on host refusal.\n */\nexport const unshareSpace = withTry<[string, string], void, UnshareSpaceError>(\n  async (spaceId: string, uid: string): Promise<void> => { await invoke<void>(\"spaces:unshare\", { spaceId, uid }); },\n  'unknown',\n);\n\nexport type SetSpaceRoleError =\n  'auth-required' | 'cancelled' | 'forbidden' | 'not-found' | 'unsupported-scheme' | 'unknown' | 'conflict';\n\n/**\n * Change a member's role. Refused if it would drop the sole owner\n * (owner-lockout, T41).\n *\n * Capability: `spaces:admin`. Catalog name: `spaces:setRole`.\n * @throws `Error & { code: SetSpaceRoleError }` on host refusal.\n */\nexport const setSpaceRole = withTry<[string, string, Role], void, SetSpaceRoleError>(\n  async (spaceId: string, uid: string, role: Role): Promise<void> => { await invoke<void>(\"spaces:setRole\", { spaceId, uid, role }); },\n  'unknown',\n);\n\nexport type LookupUserError =\n  'auth-required' | 'cancelled' | 'forbidden' | 'not-found' | 'unsupported-scheme' | 'unknown';\n\n/**\n * Resolve a provider handle to a principal (for the invite flow).\n * Rate-limited host-side.\n *\n * Capability: `spaces:admin`. Catalog name: `spaces:lookupUser`.\n * @throws `Error & { code: LookupUserError }` on host refusal.\n */\nexport const lookupUser = withTry<[string], ResolvedUser, LookupUserError>(\n  (login: string): Promise<ResolvedUser> =>\n    invoke<ResolvedUser>(\"spaces:lookupUser\", { login }),\n  'unknown',\n);\n\nexport type ListGrantsError =\n  'auth-required' | 'cancelled' | 'forbidden' | 'not-found' | 'unsupported-scheme' | 'unknown';\n\n/**\n * Enumerate every (app, mount) grant the user holds — the audit view\n * (§8.11). Elevated.\n *\n * Capability: `spaces:admin`. Catalog name: `spaces:grants`.\n * @throws `Error & { code: ListGrantsError }` on host refusal.\n */\nexport const listGrants = withTry<[], GrantRecord[], ListGrantsError>(\n  (): Promise<GrantRecord[]> =>\n    invoke<GrantRecord[]>(\"spaces:grants\", {}),\n  'unknown',\n);\n\nexport type RevokeGrantError =\n  'auth-required' | 'cancelled' | 'forbidden' | 'not-found' | 'unsupported-scheme' | 'unknown';\n\n/**\n * Revoke one app's grant on a space — durable (the app can't re-mount) plus\n * a best-effort live teardown. Elevated.\n *\n * Capability: `spaces:admin`. Catalog name: `spaces:revokeGrant`.\n * @throws `Error & { code: RevokeGrantError }` on host refusal.\n */\nexport const revokeGrant = withTry<[string, string], void, RevokeGrantError>(\n  async (appKey: string, spaceId: string): Promise<void> => { await invoke<void>(\"spaces:revokeGrant\", { appKey, spaceId }); },\n  'unknown',\n);\n\nexport type ListPendingInvitesError =\n  'auth-required' | 'cancelled' | 'forbidden' | 'not-found' | 'unsupported-scheme' | 'unknown';\n\n/**\n * The owner's outstanding invitations for a space.\n *\n * Capability: `spaces:admin`. Catalog name: `spaces:pendingInvites`.\n * @throws `Error & { code: ListPendingInvitesError }` on host refusal.\n */\nexport const listPendingInvites = withTry<[string], Invite[], ListPendingInvitesError>(\n  (spaceId: string): Promise<Invite[]> =>\n    invoke<Invite[]>(\"spaces:pendingInvites\", { spaceId }),\n  'unknown',\n);\n\nexport type RevokeInviteError =\n  'auth-required' | 'cancelled' | 'forbidden' | 'not-found' | 'unsupported-scheme' | 'unknown';\n\n/**\n * Withdraw a pending invitation (distinct from {@link unshareSpace}, which\n * removes an ACCEPTED member).\n *\n * Capability: `spaces:admin`. Catalog name: `spaces:revokeInvite`.\n * @throws `Error & { code: RevokeInviteError }` on host refusal.\n */\nexport const revokeInvite = withTry<[string, string], void, RevokeInviteError>(\n  async (spaceId: string, uid: string): Promise<void> => { await invoke<void>(\"spaces:revokeInvite\", { spaceId, uid }); },\n  'unknown',\n);\n\nexport type ListMyInvitesError =\n  'auth-required' | 'cancelled' | 'forbidden' | 'not-found' | 'unsupported-scheme' | 'unknown';\n\n/**\n * The caller's OWN invitation inbox.\n *\n * Capability: `spaces:user`. Catalog name: `spaces:listInvites`.\n * @throws `Error & { code: ListMyInvitesError }` on host refusal.\n */\nexport const listMyInvites = withTry<[], Invite[], ListMyInvitesError>(\n  (): Promise<Invite[]> =>\n    invoke<Invite[]>(\"spaces:listInvites\", {}),\n  'unknown',\n);\n\nexport type AcceptInviteError =\n  'auth-required' | 'cancelled' | 'forbidden' | 'not-found' | 'unsupported-scheme' | 'unknown';\n\n/**\n * Accept an invitation: materialize your membership at the invited role and\n * clear the invite. An invitation the caller doesn't hold rejects with\n * `forbidden` (indistinguishable from a nonexistent space; no existence\n * oracle).\n *\n * Capability: `spaces:user`. Catalog name: `spaces:acceptInvite`.\n * @throws `Error & { code: AcceptInviteError }` on host refusal.\n */\nexport const acceptInvite = withTry<[string], void, AcceptInviteError>(\n  async (spaceId: string): Promise<void> => { await invoke<void>(\"spaces:acceptInvite\", { spaceId }); },\n  'unknown',\n);\n\nexport type DeclineInviteError =\n  'auth-required' | 'cancelled' | 'forbidden' | 'not-found' | 'unsupported-scheme' | 'unknown';\n\n/**\n * Decline (dismiss) an invitation from your inbox; writes no membership.\n *\n * Capability: `spaces:user`. Catalog name: `spaces:declineInvite`.\n * @throws `Error & { code: DeclineInviteError }` on host refusal.\n */\nexport const declineInvite = withTry<[string], void, DeclineInviteError>(\n  async (spaceId: string): Promise<void> => { await invoke<void>(\"spaces:declineInvite\", { spaceId }); },\n  'unknown',\n);\n\nexport type DeleteSpaceError =\n  'auth-required' | 'cancelled' | 'forbidden' | 'not-found' | 'unsupported-scheme' | 'unknown';\n\n/**\n * Soft-delete a space you own (FILE_SHARING_SPEC §6.2): sets the tombstone,\n * so every member’s live mount falls within one snapshot and the space lists\n * nowhere. Membership is retained — undo it with {@link restoreSpace} from\n * the surface that just deleted (there is no \"recently deleted\" list). Not a\n * hard delete: the space’s content is not destroyed by this call.\n *\n * Capability: `spaces:admin`. Catalog name: `spaces:delete`.\n * @throws `Error & { code: DeleteSpaceError }` on host refusal.\n */\nexport const deleteSpace = withTry<[string], void, DeleteSpaceError>(\n  async (spaceId: string): Promise<void> => { await invoke<void>(\"spaces:delete\", { spaceId, confirm: true }); },\n  'unknown',\n);\n\nexport type RestoreSpaceError =\n  'auth-required' | 'cancelled' | 'forbidden' | 'not-found' | 'unsupported-scheme' | 'unknown';\n\n/**\n * Undo a {@link deleteSpace}: clears the §6.2 tombstone, and every retained\n * member’s access returns with no re-share fan-out. Reachable only while you\n * still hold the space id — the deleting surface does.\n *\n * Capability: `spaces:admin`. Catalog name: `spaces:restore`.\n * @throws `Error & { code: RestoreSpaceError }` on host refusal.\n */\nexport const restoreSpace = withTry<[string], void, RestoreSpaceError>(\n  async (spaceId: string): Promise<void> => { await invoke<void>(\"spaces:restore\", { spaceId, confirm: true }); },\n  'unknown',\n);\n\nexport type LeaveSpaceError =\n  'auth-required' | 'cancelled' | 'forbidden' | 'not-found' | 'unsupported-scheme' | 'unknown' | 'owner-lockout';\n\n/**\n * Remove YOURSELF from a space (FILE_SHARING_SPEC §9.7): your membership and\n * flattened access go in one batch, and live mounts fall through the same\n * watch as an unshare. The anchor owner cannot leave — they {@link\n * deleteSpace} instead — and a leave that would drop the last owner is\n * refused; both surface as `owner-lockout`.\n *\n * Capability: `spaces:user`. Catalog name: `spaces:leave`.\n * @throws `Error & { code: LeaveSpaceError }` on host refusal.\n */\nexport const leaveSpace = withTry<[string], void, LeaveSpaceError>(\n  async (spaceId: string): Promise<void> => { await invoke<void>(\"spaces:leave\", { spaceId, confirm: true }); },\n  'unknown',\n);\n\nexport type RenameSpaceError =\n  'auth-required' | 'cancelled' | 'forbidden' | 'not-found' | 'unsupported-scheme' | 'unknown' | 'invalid-params';\n\n/**\n * Rename a space you own (FILE_SHARING_SPEC §9.7). The name is trimmed\n * host-side and bounded (non-empty, at most the platform\n * MAX_SPACE_NAME_LENGTH); an over-long or empty name fails validation with\n * `invalid-params` before any write.\n *\n * Capability: `spaces:admin`. Catalog name: `spaces:rename`.\n * @throws `Error & { code: RenameSpaceError }` on host refusal.\n */\nexport const renameSpace = withTry<[string, string], void, RenameSpaceError>(\n  async (spaceId: string, name: string): Promise<void> => { await invoke<void>(\"spaces:rename\", { spaceId, name }); },\n  'unknown',\n);\n\nexport type ConvertSpaceToSharedError =\n  'auth-required' | 'cancelled' | 'forbidden' | 'not-found' | 'unsupported-scheme' | 'unknown';\n\n/**\n * Convert a personal space to shared (R3-259) — the deliberate, ONE-WAY\n * conversion. Only the owner may call it; the irreversibility disclosure is\n * host-drawn chrome. Converting an already-shared space is a no-op.\n *\n * Capability: `spaces:admin`. Catalog name: `spaces:convertToShared`.\n * @throws `Error & { code: ConvertSpaceToSharedError }` on host refusal.\n */\nexport const convertSpaceToShared = withTry<[string], void, ConvertSpaceToSharedError>(\n  async (spaceId: string): Promise<void> => { await invoke<void>(\"spaces:convertToShared\", { spaceId, confirm: true }); },\n  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