@w6w/embed 0.2.24 → 0.2.27
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/dist/{CreateFunctionModal-DScxp_LN.js → CreateFunctionModal-B3LpcuI9.js} +2 -2
- package/dist/{CreateFunctionModal-DScxp_LN.js.map → CreateFunctionModal-B3LpcuI9.js.map} +1 -1
- package/dist/DocumentFormModal-DieWYFi4.js +175 -0
- package/dist/DocumentFormModal-DieWYFi4.js.map +1 -0
- package/dist/{ImportSpecModal-Cpzp8ndt.js → ImportSpecModal-xwTzj4KB.js} +22 -21
- package/dist/{ImportSpecModal-Cpzp8ndt.js.map → ImportSpecModal-xwTzj4KB.js.map} +1 -1
- package/dist/ModelRoutesManager-DtByS4mE.js +422 -0
- package/dist/ModelRoutesManager-DtByS4mE.js.map +1 -0
- package/dist/{WorkflowEditor-LesBKjb2.js → WorkflowEditor-CvWkVmFn.js} +6 -6
- package/dist/{WorkflowEditor-LesBKjb2.js.map → WorkflowEditor-CvWkVmFn.js.map} +1 -1
- package/dist/ai-keys-D676ly41.js +53 -0
- package/dist/ai-keys-D676ly41.js.map +1 -0
- package/dist/{apps-CYUgEfGf.js → apps-FMcQfyL2.js} +2 -2
- package/dist/{apps-CYUgEfGf.js.map → apps-FMcQfyL2.js.map} +1 -1
- package/dist/chrome/ImportSpecModal.d.ts +2 -0
- package/dist/credentials-4Nf2GfMc.js +212 -0
- package/dist/credentials-4Nf2GfMc.js.map +1 -0
- package/dist/editor-apps-HEOclsxL.js +152 -0
- package/dist/{editor-apps-LZmDWMqf.js.map → editor-apps-HEOclsxL.js.map} +1 -1
- package/dist/{editor-tools-DHyWiG21.js → editor-tools-CVYTsVFN.js} +326 -326
- package/dist/editor-tools-CVYTsVFN.js.map +1 -0
- package/dist/editor.mjs +1 -1
- package/dist/editors.mjs +11 -11
- package/dist/{endpoints-DSRo1Lc5.js → endpoints-DArAqoLT.js} +15 -15
- package/dist/endpoints-DArAqoLT.js.map +1 -0
- package/dist/forms/ModelRoutesManager.d.ts +8 -0
- package/dist/forms.mjs +128 -133
- package/dist/forms.mjs.map +1 -1
- package/dist/index.mjs +14 -14
- package/dist/lib/callable-descriptors.d.ts +1 -1
- package/dist/lib/document-upload.d.ts +8 -0
- package/dist/lists/ConnectionList.d.ts +3 -1
- package/dist/lists/CredentialCreate.d.ts +25 -0
- package/dist/lists/CredentialDetail.d.ts +5 -1
- package/dist/lists/CredentialList.d.ts +3 -1
- package/dist/lists/MyAiKeys.d.ts +5 -0
- package/dist/lists/TagChips.d.ts +4 -0
- package/dist/lists.d.ts +4 -0
- package/dist/lists.mjs +1703 -1107
- package/dist/lists.mjs.map +1 -1
- package/dist/models-CI0vLJ6o.js +346 -0
- package/dist/models-CI0vLJ6o.js.map +1 -0
- package/dist/rail.mjs +1 -1
- package/dist/repos/ai-keys.d.ts +14 -0
- package/dist/repos/credentials.d.ts +28 -14
- package/dist/repos/index.d.ts +1 -0
- package/dist/repos/models.d.ts +53 -4
- package/dist/repos.mjs +223 -204
- package/dist/repos.mjs.map +1 -1
- package/dist/{spec-export-DGigBUsP.js → spec-export-DMMET5VM.js} +2 -2
- package/dist/{spec-export-DGigBUsP.js.map → spec-export-DMMET5VM.js.map} +1 -1
- package/dist/{spec-import-SWOonsNr.js → spec-import-0B6oUewa.js} +5 -5
- package/dist/{spec-import-SWOonsNr.js.map → spec-import-0B6oUewa.js.map} +1 -1
- package/dist/{workflows-BK6IM4if.js → workflows-Dz8LMjnt.js} +37 -34
- package/dist/workflows-Dz8LMjnt.js.map +1 -0
- package/package.json +5 -5
- package/src/styles.css +23 -0
- package/dist/DocumentFormModal-Br4s8wmi.js +0 -89
- package/dist/DocumentFormModal-Br4s8wmi.js.map +0 -1
- package/dist/ModelRoutesManager-Bv6qefnq.js +0 -345
- package/dist/ModelRoutesManager-Bv6qefnq.js.map +0 -1
- package/dist/credentials-Cn92LGhJ.js +0 -171
- package/dist/credentials-Cn92LGhJ.js.map +0 -1
- package/dist/editor-apps-LZmDWMqf.js +0 -152
- package/dist/editor-tools-DHyWiG21.js.map +0 -1
- package/dist/endpoints-DSRo1Lc5.js.map +0 -1
- package/dist/models-CK1KHd39.js +0 -311
- package/dist/models-CK1KHd39.js.map +0 -1
- package/dist/workflows-BK6IM4if.js.map +0 -1
package/dist/repos.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"repos.mjs","sources":["../src/repos/agents-studio-agents.ts","../src/repos/agents-studio-assets.ts"],"sourcesContent":["/**\n * The Agents Studio repo — agent drafts, ready-only skill/context pickers, model routes,\n * agent settings and storage bindings over `@w6w/sdk` (`agents.*`, `skills.*`, `context.*`,\n * `console.storage.*`). Query-key factory + react-query hooks, mirroring `documents.ts`.\n *\n * Agents are DRAFTS: `runnable` is always `false` (A22). A save sends the body `revision` and\n * the precondition header from the loaded `updatedAt`; a 409 is surfaced as a typed\n * {@linkcode AgentConflictError} and is never retried or overwritten (A18).\n */\nimport { useMutation, useQuery, useQueryClient } from \"@tanstack/react-query\";\nimport {\n path,\n type Agent,\n type AgentTool,\n ApiError,\n type ContextEntry,\n type ContextPin,\n type CreateAgentInput,\n type SkillPin,\n type SkillVersion,\n type UpdateAgentInput,\n type W6WClient,\n} from \"@w6w/sdk\";\nimport { useEmbedClient } from \"../draft/client-context.ts\";\nimport { listModelRoutes } from \"./models.ts\";\n\nexport type {\n Agent,\n AgentTool,\n ContextEntry,\n ContextPin,\n CreateAgentInput,\n SkillPin,\n SkillVersion,\n UpdateAgentInput,\n};\n\n/** Thrown by {@linkcode updateAgent} on a 409: the draft changed elsewhere. Never overwrites. */\nexport class AgentConflictError extends Error {\n readonly kind = \"conflict\" as const;\n /** The server's current revision, when the error body carried one. */\n readonly currentRevision: number | null;\n readonly cause: ApiError;\n constructor(cause: ApiError) {\n super(\"This agent changed elsewhere — reload to see the latest version.\");\n this.name = \"AgentConflictError\";\n this.cause = cause;\n this.currentRevision = currentRevisionOf(cause.raw);\n }\n}\n\nfunction currentRevisionOf(raw: unknown): number | null {\n const o = raw as {\n revision?: unknown;\n error?: { revision?: unknown; details?: { revision?: unknown } };\n } | null;\n const v = o?.revision ?? o?.error?.revision ?? o?.error?.details?.revision;\n return typeof v === \"number\" ? v : null;\n}\n\n/** True for a {@linkcode AgentConflictError}. */\nexport function isAgentConflict(e: unknown): e is AgentConflictError {\n return e instanceof AgentConflictError;\n}\n\nexport const agentsKey = (includeArchived = false) => [\"agents\", { includeArchived }] as const;\nexport const agentKey = (id: string) => [\"agents\", \"detail\", id] as const;\nexport const agentSkillVersionsKey = (skillId: string) =>\n [\"agents\", \"skill-versions\", skillId] as const;\nexport const agentSkillsKey = () => [\"agents\", \"skills\"] as const;\nexport const agentContextKey = () => [\"agents\", \"context\"] as const;\nexport const agentContextEntriesKey = (collectionId: string) =>\n [\"agents\", \"context-entries\", collectionId] as const;\nexport const agentAllContextEntriesKey = () => [\"agents\", \"context-entries-all\"] as const;\nexport const agentModelRoutesKey = (projectId?: string) =>\n [\"agents\", \"model-routes\", projectId] as const;\nexport const agentSettingsKey = () => [\"agent-settings\"] as const;\nexport const storageBindingsKey = () => [\"agent-settings\", \"storage-bindings\"] as const;\n\n/** Save an agent: `revision` in the body, `updatedAt` as the precondition header; 409 → conflict. */\nexport async function updateAgent(\n client: W6WClient,\n id: string,\n patch: Omit<UpdateAgentInput, \"revision\">,\n loaded: Pick<Agent, \"revision\" | \"updatedAt\">,\n): Promise<Agent> {\n try {\n return await client.agents.update(\n id,\n { ...patch, revision: loaded.revision },\n { ifUnmodifiedSince: loaded.updatedAt },\n );\n } catch (e) {\n if (e instanceof ApiError && e.status === 409) throw new AgentConflictError(e);\n throw e;\n }\n}\n\n/** Readiness of a pin against the ready-only picker lists. */\nexport type PinState = \"ready\" | \"unavailable\";\n\n/** A skill pin is `ready` only when its version is among the ready versions of its skill. */\nexport function skillPinState(\n pin: SkillPin,\n readyVersions: readonly SkillVersion[] | undefined,\n): PinState {\n return readyVersions?.some((v) => v.id === pin.skillVersionId && v.skillId === pin.skillId)\n ? \"ready\"\n : \"unavailable\";\n}\n\n/** A context pin is `ready` only when its entry is listed, unarchived, at the pinned version. */\nexport function contextPinState(\n pin: ContextPin,\n entries: readonly ContextEntry[] | undefined,\n): PinState {\n return entries?.some((e) => e.assetVersionId === pin.assetVersionId && e.archivedAt == null)\n ? \"ready\"\n : \"unavailable\";\n}\n\n/** Picker options: ready (listed, unarchived) context entries only. */\nexport function readyContextEntries(entries: readonly ContextEntry[]): ContextEntry[] {\n return entries.filter((e) => e.archivedAt == null);\n}\n\nexport function useAgentsQuery(includeArchived = false) {\n const client = useEmbedClient();\n return useQuery({\n queryKey: agentsKey(includeArchived),\n queryFn: () => client.agents.list({ includeArchived }),\n });\n}\n\nexport function useAgentQuery(id: string | undefined) {\n const client = useEmbedClient();\n return useQuery({\n queryKey: agentKey(id ?? \"\"),\n enabled: !!id,\n queryFn: () => client.agents.get(id as string),\n });\n}\n\nexport function useCreateAgent() {\n const client = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (input: CreateAgentInput) => client.agents.create(input),\n onSuccess: () => qc.invalidateQueries({ queryKey: [\"agents\"] }),\n });\n}\n\nexport function useUpdateAgent(id: string) {\n const client = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (v: {\n patch: Omit<UpdateAgentInput, \"revision\">;\n loaded: Pick<Agent, \"revision\" | \"updatedAt\">;\n }) => updateAgent(client, id, v.patch, v.loaded),\n onSuccess: (agent) => {\n qc.setQueryData(agentKey(id), agent);\n return qc.invalidateQueries({ queryKey: [\"agents\"] });\n },\n });\n}\n\nexport function useArchiveAgent() {\n const client = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (id: string) => client.agents.archive(id),\n onSuccess: () => qc.invalidateQueries({ queryKey: [\"agents\"] }),\n });\n}\n\nexport function useAgentSkillsQuery() {\n const client = useEmbedClient();\n return useQuery({ queryKey: agentSkillsKey(), queryFn: () => client.skills.list() });\n}\n\nexport function useAgentSkillVersionsQuery(skillId: string | undefined) {\n const client = useEmbedClient();\n return useQuery({\n queryKey: agentSkillVersionsKey(skillId ?? \"\"),\n enabled: !!skillId,\n queryFn: () => client.skills.versions(skillId as string),\n });\n}\n\nexport function useAgentContextCollectionsQuery() {\n const client = useEmbedClient();\n return useQuery({ queryKey: agentContextKey(), queryFn: () => client.context.list() });\n}\n\nexport function useAgentContextEntriesQuery(collectionId: string | undefined) {\n const client = useEmbedClient();\n return useQuery({\n queryKey: agentContextEntriesKey(collectionId ?? \"\"),\n enabled: !!collectionId,\n queryFn: () => client.context.entries.list(collectionId as string),\n });\n}\n\n/** Every doc visible to the caller (collection-less included) — the pin picker's source. */\nexport function useAgentAllContextEntriesQuery() {\n const client = useEmbedClient();\n return useQuery({\n queryKey: agentAllContextEntriesKey(),\n queryFn: () => client.contextEntries.list({}),\n });\n}\n\nexport function useAgentModelRoutesQuery(projectId?: string) {\n const client = useEmbedClient();\n return useQuery({\n queryKey: agentModelRoutesKey(projectId),\n enabled: projectId != null,\n queryFn: () => listModelRoutes(client, projectId as string),\n });\n}\n\nexport function useAgentSettingsQuery() {\n const client = useEmbedClient();\n return useQuery({\n queryKey: agentSettingsKey(),\n queryFn: () => client.console.storage.settings.get(),\n });\n}\n\nexport function usePatchAgentSettings() {\n const client = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (patch: Parameters<W6WClient[\"console\"][\"storage\"][\"settings\"][\"patch\"]>[0]) =>\n client.console.storage.settings.patch(patch),\n onSuccess: (s) => {\n qc.setQueryData(agentSettingsKey(), s);\n },\n });\n}\n\nexport function useStorageBindingsQuery() {\n const client = useEmbedClient();\n return useQuery({\n queryKey: storageBindingsKey(),\n queryFn: () => client.console.storage.bindings.list(),\n });\n}\n\n// ── the agent Test box (POST /agents/:id/test) ───────────────────────────────\n\n/** One message of a Test conversation, as the model contract has it. */\nexport interface AgentTestTurn {\n role: \"user\" | \"assistant\";\n content: unknown;\n}\n\nexport interface AgentTestRequest {\n project: string;\n message: string;\n /** The `turns` of earlier answers, so a follow-up keeps the conversation. */\n history?: AgentTestTurn[];\n /** Unsaved form state laid over the stored agent. */\n draft?: {\n instructions?: string;\n modelRouteId?: string | null;\n modelOptions?: Record<string, unknown>;\n tools?: AgentTool[];\n };\n}\n\nexport interface AgentTestToolCall {\n tool: string;\n input: Record<string, unknown>;\n ok: boolean;\n /** The tool's output, or the error message when `ok` is false. */\n output: unknown;\n}\n\nexport interface AgentTestResult {\n text: string;\n turns: AgentTestTurn[];\n toolCalls: AgentTestToolCall[];\n model: string | null;\n rounds: number;\n usage: { inputTokens: number; outputTokens: number };\n finishReason: string | null;\n}\n\n/**\n * Run the agent once on a message through the server's agent runtime — the same one a workflow's\n * \"Run agent\" step uses, so tools run there (fixed values resolved server-side, only the AI fields\n * passed on). Real, billed model and tool calls. Through `client.request` (Studio-internal route).\n */\nexport async function testAgent(\n client: W6WClient,\n id: string,\n body: AgentTestRequest,\n): Promise<AgentTestResult> {\n const res = await client.request<AgentTestResult>({\n method: \"POST\",\n path: path`/agents/${id}/test`,\n body,\n });\n return res.body;\n}\n\nexport function useTestAgentMutation(id: string) {\n const client = useEmbedClient();\n return useMutation({ mutationFn: (body: AgentTestRequest) => testAgent(client, id, body) });\n}\n","/**\n * Agents Studio asset hooks — skills, context collections/entries and stored asset files over\n * `W6WClient`'s `skills.*`, `context.*` and `assets.*` (react-query, same shape as `vars.ts`).\n *\n * These are tenant/account-scoped (no `project` is sent). Uploads are byte-mode: the caller\n * hashes and PUTs the same bytes (see Studio's `agents-studio/upload.ts`); this module only\n * wraps the single-call operations.\n */\nimport { useMutation, useQuery, useQueryClient } from \"@tanstack/react-query\";\nimport type {\n AssetUploadCreateInput,\n CreateContextCollectionInput,\n CreateStandaloneContextEntryInput,\n UpdateContextEntryInput,\n} from \"@w6w/sdk\";\nimport { useEmbedClient } from \"../draft/client-context.ts\";\n\nexport const skillsKey = (includeArchived = false) => [\"skills\", { includeArchived }] as const;\nexport const skillKey = (id: string) => [\"skills\", id] as const;\nexport const skillVersionsKey = (id: string) => [\"skills\", id, \"versions\"] as const;\nexport const contextCollectionsKey = (includeArchived = false) =>\n [\"context-collections\", { includeArchived }] as const;\nexport const contextCollectionKey = (id: string) => [\"context-collections\", id] as const;\nexport const contextEntriesKey = (id: string, includeArchived = false) =>\n [\"context-collections\", id, \"entries\", { includeArchived }] as const;\nexport const allContextEntriesKey = (includeArchived = false) =>\n [\"context-entries\", { includeArchived }] as const;\nexport const assetVersionsKey = (id: string) => [\"assets\", id, \"versions\"] as const;\nexport const assetFilesKey = (id: string, versionId: string) =>\n [\"assets\", id, \"versions\", versionId, \"files\"] as const;\n\n// ── Skills ──────────────────────────────────────────────────────────────────────────────────\n\nexport function useSkillsQuery(includeArchived = false) {\n const client = useEmbedClient();\n return useQuery({\n queryKey: skillsKey(includeArchived),\n queryFn: () => client.skills.list({ includeArchived }),\n });\n}\n\nexport function useSkillQuery(id: string | undefined) {\n const client = useEmbedClient();\n return useQuery({\n queryKey: skillKey(id ?? \"\"),\n enabled: id != null,\n queryFn: () => client.skills.get(id as string),\n });\n}\n\nexport function useSkillVersionsQuery(id: string | undefined) {\n const client = useEmbedClient();\n return useQuery({\n queryKey: skillVersionsKey(id ?? \"\"),\n enabled: id != null,\n queryFn: () => client.skills.versions(id as string),\n });\n}\n\nexport function useArchiveSkillMutation() {\n const client = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (id: string) => client.skills.archive(id),\n onSuccess: () => qc.invalidateQueries({ queryKey: [\"skills\"] }),\n });\n}\n\n// ── Context collections + entries ───────────────────────────────────────────────────────────\n\nexport function useContextCollectionsQuery(includeArchived = false) {\n const client = useEmbedClient();\n return useQuery({\n queryKey: contextCollectionsKey(includeArchived),\n queryFn: () => client.context.list({ includeArchived }),\n });\n}\n\nexport function useContextCollectionQuery(id: string | undefined) {\n const client = useEmbedClient();\n return useQuery({\n queryKey: contextCollectionKey(id ?? \"\"),\n enabled: id != null,\n queryFn: () => client.context.get(id as string),\n });\n}\n\nexport function useCreateContextCollectionMutation() {\n const client = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (input: CreateContextCollectionInput) => client.context.create(input),\n onSuccess: () => qc.invalidateQueries({ queryKey: [\"context-collections\"] }),\n });\n}\n\nexport function useContextEntriesQuery(collectionId: string | undefined, includeArchived = false) {\n const client = useEmbedClient();\n return useQuery({\n queryKey: contextEntriesKey(collectionId ?? \"\", includeArchived),\n enabled: collectionId != null,\n queryFn: () => client.context.entries.list(collectionId as string, { includeArchived }),\n });\n}\n\n/** Edit-as-new-version: `PUT` creates the next version; `ifUnmodifiedSince` guards a stale edit. */\nexport function useUpdateContextEntryMutation() {\n const client = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (v: {\n collectionId: string;\n entryId: string;\n input: UpdateContextEntryInput;\n ifUnmodifiedSince?: string;\n }) =>\n client.context.entries.update(v.collectionId, v.entryId, v.input, {\n ifUnmodifiedSince: v.ifUnmodifiedSince,\n }),\n onSuccess: (_r, v) => {\n qc.invalidateQueries({ queryKey: [\"context-collections\", v.collectionId] });\n qc.invalidateQueries({ queryKey: [\"assets\"] });\n },\n });\n}\n\n// ── Collection-independent entries (`client.contextEntries.*`) ──────────────────────────────\n\n/** Every doc visible to the caller, whether or not it is in a collection. */\nexport function useAllContextEntriesQuery(includeArchived = false) {\n const client = useEmbedClient();\n return useQuery({\n queryKey: allContextEntriesKey(includeArchived),\n queryFn: () => client.contextEntries.list({ includeArchived }),\n });\n}\n\n/** Invalidate the all-docs list and, per affected collection, its entries list. */\nfunction invalidateEntries(qc: ReturnType<typeof useQueryClient>, collectionIds: string[] = []) {\n qc.invalidateQueries({ queryKey: [\"context-entries\"] });\n for (const id of collectionIds) qc.invalidateQueries({ queryKey: contextEntriesKey(id) });\n}\n\n/** Create a text doc, private unless `collectionIds` / `visibility` say otherwise. */\nexport function useCreateContextEntryMutation() {\n const client = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (input: CreateStandaloneContextEntryInput) => client.contextEntries.create(input),\n onSuccess: (_r, v) => invalidateEntries(qc, v.collectionIds),\n });\n}\n\nexport function useAddEntryToCollectionMutation() {\n const client = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (v: { entryId: string; collectionId: string }) =>\n client.contextEntries.addToCollection(v.entryId, v.collectionId),\n onSuccess: (_r, v) => invalidateEntries(qc, [v.collectionId]),\n });\n}\n\nexport function useRemoveEntryFromCollectionMutation() {\n const client = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (v: { entryId: string; collectionId: string }) =>\n client.contextEntries.removeFromCollection(v.entryId, v.collectionId),\n onSuccess: (_r, v) => invalidateEntries(qc, [v.collectionId]),\n });\n}\n\n// ── Asset versions, files, downloads ────────────────────────────────────────────────────────\n\nexport function useAssetVersionsQuery(assetId: string | undefined) {\n const client = useEmbedClient();\n return useQuery({\n queryKey: assetVersionsKey(assetId ?? \"\"),\n enabled: assetId != null,\n queryFn: () => client.assets.versions(assetId as string),\n });\n}\n\nexport function useAssetFilesQuery(assetId: string | undefined, versionId: string | undefined) {\n const client = useEmbedClient();\n return useQuery({\n queryKey: assetFilesKey(assetId ?? \"\", versionId ?? \"\"),\n enabled: assetId != null && versionId != null,\n queryFn: () => client.assets.files(assetId as string, versionId as string),\n });\n}\n\n/** Exact bytes of one file. A mutation (not a query): downloads are user-triggered, never cached. */\nexport function useDownloadAssetFileMutation() {\n const client = useEmbedClient();\n return useMutation({\n mutationFn: (v: { assetId: string; versionId: string; fileId: string }) =>\n client.assets.content(v.assetId, v.versionId, v.fileId),\n });\n}\n\n/** One version as a store-only ZIP. */\nexport function useDownloadAssetArchiveMutation() {\n const client = useEmbedClient();\n return useMutation({\n mutationFn: (v: { assetId: string; versionId: string }) =>\n client.assets.archiveDownload(v.assetId, v.versionId),\n });\n}\n\nexport function useArchiveAssetMutation() {\n const client = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (id: string) => client.assets.archive(id),\n onSuccess: () => qc.invalidateQueries({ queryKey: [\"assets\"] }),\n });\n}\n\n// ── Upload (resumable, byte-mode) ───────────────────────────────────────────────────────────\n\nexport function useCreateAssetUploadMutation() {\n const client = useEmbedClient();\n return useMutation({\n mutationFn: (input: AssetUploadCreateInput) => client.assets.uploads.create(input),\n });\n}\n\nexport function usePutAssetUploadEntryMutation() {\n const client = useEmbedClient();\n return useMutation({\n mutationFn: (v: { uploadId: string; index: number; bytes: Uint8Array }) =>\n client.assets.uploads.putEntry(v.uploadId, v.index, v.bytes),\n });\n}\n\n/** Publishing a version changes skills, context and assets alike — invalidate all three. */\nexport function useFinalizeAssetUploadMutation() {\n const client = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (uploadId: string) => client.assets.uploads.finalize(uploadId),\n onSuccess: () => {\n qc.invalidateQueries({ queryKey: [\"skills\"] });\n qc.invalidateQueries({ queryKey: [\"context-collections\"] });\n qc.invalidateQueries({ queryKey: [\"assets\"] });\n },\n });\n}\n\nexport function useAbortAssetUploadMutation() {\n const client = useEmbedClient();\n return useMutation({ mutationFn: (uploadId: string) => client.assets.uploads.abort(uploadId) });\n}\n"],"names":["AgentConflictError","cause","__publicField","currentRevisionOf","raw","o","v","_a","_c","_b","isAgentConflict","agentsKey","includeArchived","agentKey","id","agentSkillVersionsKey","skillId","agentSkillsKey","agentContextKey","agentContextEntriesKey","collectionId","agentAllContextEntriesKey","agentModelRoutesKey","projectId","agentSettingsKey","storageBindingsKey","updateAgent","client","patch","loaded","e","ApiError","skillPinState","pin","readyVersions","contextPinState","entries","readyContextEntries","useAgentsQuery","useEmbedClient","useQuery","useAgentQuery","useCreateAgent","qc","useQueryClient","useMutation","input","useUpdateAgent","agent","useArchiveAgent","useAgentSkillsQuery","useAgentSkillVersionsQuery","useAgentContextCollectionsQuery","useAgentContextEntriesQuery","useAgentAllContextEntriesQuery","useAgentModelRoutesQuery","listModelRoutes","useAgentSettingsQuery","usePatchAgentSettings","useStorageBindingsQuery","testAgent","body","path","useTestAgentMutation","skillsKey","skillKey","skillVersionsKey","contextCollectionsKey","contextCollectionKey","contextEntriesKey","allContextEntriesKey","assetVersionsKey","assetFilesKey","versionId","useSkillsQuery","useSkillQuery","useSkillVersionsQuery","useArchiveSkillMutation","useContextCollectionsQuery","useContextCollectionQuery","useCreateContextCollectionMutation","useContextEntriesQuery","useUpdateContextEntryMutation","_r","useAllContextEntriesQuery","invalidateEntries","collectionIds","useCreateContextEntryMutation","useAddEntryToCollectionMutation","useRemoveEntryFromCollectionMutation","useAssetVersionsQuery","assetId","useAssetFilesQuery","useDownloadAssetFileMutation","useDownloadAssetArchiveMutation","useArchiveAssetMutation","useCreateAssetUploadMutation","usePutAssetUploadEntryMutation","useFinalizeAssetUploadMutation","uploadId","useAbortAssetUploadMutation"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAsCO,MAAMA,UAA2B,MAAM;AAAA,EAK5C,YAAYC,GAAiB;AAC3B,UAAM,kEAAkE;AALjE,IAAAC,EAAA,cAAO;AAEP;AAAA,IAAAA,EAAA;AACA,IAAAA,EAAA;AAGP,SAAK,OAAO,sBACZ,KAAK,QAAQD,GACb,KAAK,kBAAkBE,EAAkBF,EAAM,GAAG;AAAA,EACpD;AACF;AAEA,SAASE,EAAkBC,GAA6B;;AACtD,QAAMC,IAAID,GAIJE,KAAID,KAAA,gBAAAA,EAAG,eAAYE,IAAAF,KAAA,gBAAAA,EAAG,UAAH,gBAAAE,EAAU,eAAYC,KAAAC,IAAAJ,KAAA,gBAAAA,EAAG,UAAH,gBAAAI,EAAU,YAAV,gBAAAD,EAAmB;AAClE,SAAO,OAAOF,KAAM,WAAWA,IAAI;AACrC;AAGO,SAASI,EAAgB,GAAqC;AACnE,SAAO,aAAaV;AACtB;AAEO,MAAMW,IAAY,CAACC,IAAkB,OAAU,CAAC,UAAU,EAAE,iBAAAA,GAAiB,GACvEC,IAAW,CAACC,MAAe,CAAC,UAA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AA;AACX,SAAOC,EAAY;AAAA,IACjB,YAAY,CAACsD,MAAqBxE,EAAO,OAAO,QAAQ,SAASwE,CAAQ;AAAA,IACzE,WAAW,MAAM;AACf,MAAAxD,EAAG,kBAAkB,EAAE,UAAU,CAAC,QAAQ,GAAG,GAC7CA,EAAG,kBAAkB,EAAE,UAAU,CAAC,qBAAqB,GAAG,GAC1DA,EAAG,kBAAkB,EAAE,UAAU,CAAC,QAAQ,GAAG;AAAA,IAC/C;AAAA,EAAA,CACD;AACH;AAEO,SAASyD,KAA8B;AAC5C,QAAMzE,IAASY,EAAA;AACf,SAAOM,EAAY,EAAE,YAAY,CAACsD,MAAqBxE,EAAO,OAAO,QAAQ,MAAMwE,CAAQ,GAAG;AAChG;"}
|
|
1
|
+
{"version":3,"file":"repos.mjs","sources":["../src/repos/agents-studio-agents.ts","../src/repos/agents-studio-assets.ts"],"sourcesContent":["/**\n * The Agents Studio repo — agent drafts, ready-only skill/context pickers, model routes,\n * agent settings and storage bindings over `@w6w/sdk` (`agents.*`, `skills.*`, `context.*`,\n * `console.storage.*`). Query-key factory + react-query hooks, mirroring `documents.ts`.\n *\n * Agents are DRAFTS: `runnable` is always `false` (A22). A save sends the body `revision` and\n * the precondition header from the loaded `updatedAt`; a 409 is surfaced as a typed\n * {@linkcode AgentConflictError} and is never retried or overwritten (A18).\n */\nimport { useMutation, useQuery, useQueryClient } from \"@tanstack/react-query\";\nimport {\n path,\n type Agent,\n type AgentTool,\n ApiError,\n type ContextEntry,\n type ContextPin,\n type CreateAgentInput,\n type SkillPin,\n type SkillVersion,\n type UpdateAgentInput,\n type W6WClient,\n} from \"@w6w/sdk\";\nimport { useEmbedClient } from \"../draft/client-context.ts\";\nimport { listModelRoutes } from \"./models.ts\";\n\nexport type {\n Agent,\n AgentTool,\n ContextEntry,\n ContextPin,\n CreateAgentInput,\n SkillPin,\n SkillVersion,\n UpdateAgentInput,\n};\n\n/** Thrown by {@linkcode updateAgent} on a 409: the draft changed elsewhere. Never overwrites. */\nexport class AgentConflictError extends Error {\n readonly kind = \"conflict\" as const;\n /** The server's current revision, when the error body carried one. */\n readonly currentRevision: number | null;\n readonly cause: ApiError;\n constructor(cause: ApiError) {\n super(\"This agent changed elsewhere — reload to see the latest version.\");\n this.name = \"AgentConflictError\";\n this.cause = cause;\n this.currentRevision = currentRevisionOf(cause.raw);\n }\n}\n\nfunction currentRevisionOf(raw: unknown): number | null {\n const o = raw as {\n revision?: unknown;\n error?: { revision?: unknown; details?: { revision?: unknown } };\n } | null;\n const v = o?.revision ?? o?.error?.revision ?? o?.error?.details?.revision;\n return typeof v === \"number\" ? v : null;\n}\n\n/** True for a {@linkcode AgentConflictError}. */\nexport function isAgentConflict(e: unknown): e is AgentConflictError {\n return e instanceof AgentConflictError;\n}\n\nexport const agentsKey = (includeArchived = false) => [\"agents\", { includeArchived }] as const;\nexport const agentKey = (id: string) => [\"agents\", \"detail\", id] as const;\nexport const agentSkillVersionsKey = (skillId: string) =>\n [\"agents\", \"skill-versions\", skillId] as const;\nexport const agentSkillsKey = () => [\"agents\", \"skills\"] as const;\nexport const agentContextKey = () => [\"agents\", \"context\"] as const;\nexport const agentContextEntriesKey = (collectionId: string) =>\n [\"agents\", \"context-entries\", collectionId] as const;\nexport const agentAllContextEntriesKey = () => [\"agents\", \"context-entries-all\"] as const;\nexport const agentModelRoutesKey = (projectId?: string) =>\n [\"agents\", \"model-routes\", projectId] as const;\nexport const agentSettingsKey = () => [\"agent-settings\"] as const;\nexport const storageBindingsKey = () => [\"agent-settings\", \"storage-bindings\"] as const;\n\n/** Save an agent: `revision` in the body, `updatedAt` as the precondition header; 409 → conflict. */\nexport async function updateAgent(\n client: W6WClient,\n id: string,\n patch: Omit<UpdateAgentInput, \"revision\">,\n loaded: Pick<Agent, \"revision\" | \"updatedAt\">,\n): Promise<Agent> {\n try {\n return await client.agents.update(\n id,\n { ...patch, revision: loaded.revision },\n { ifUnmodifiedSince: loaded.updatedAt },\n );\n } catch (e) {\n if (e instanceof ApiError && e.status === 409) throw new AgentConflictError(e);\n throw e;\n }\n}\n\n/** Readiness of a pin against the ready-only picker lists. */\nexport type PinState = \"ready\" | \"unavailable\";\n\n/** A skill pin is `ready` only when its version is among the ready versions of its skill. */\nexport function skillPinState(\n pin: SkillPin,\n readyVersions: readonly SkillVersion[] | undefined,\n): PinState {\n return readyVersions?.some((v) => v.id === pin.skillVersionId && v.skillId === pin.skillId)\n ? \"ready\"\n : \"unavailable\";\n}\n\n/** A context pin is `ready` only when its entry is listed, unarchived, at the pinned version. */\nexport function contextPinState(\n pin: ContextPin,\n entries: readonly ContextEntry[] | undefined,\n): PinState {\n return entries?.some((e) => e.assetVersionId === pin.assetVersionId && e.archivedAt == null)\n ? \"ready\"\n : \"unavailable\";\n}\n\n/** Picker options: ready (listed, unarchived) context entries only. */\nexport function readyContextEntries(entries: readonly ContextEntry[]): ContextEntry[] {\n return entries.filter((e) => e.archivedAt == null);\n}\n\nexport function useAgentsQuery(includeArchived = false) {\n const client = useEmbedClient();\n return useQuery({\n queryKey: agentsKey(includeArchived),\n queryFn: () => client.agents.list({ includeArchived }),\n });\n}\n\nexport function useAgentQuery(id: string | undefined) {\n const client = useEmbedClient();\n return useQuery({\n queryKey: agentKey(id ?? \"\"),\n enabled: !!id,\n queryFn: () => client.agents.get(id as string),\n });\n}\n\nexport function useCreateAgent() {\n const client = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (input: CreateAgentInput) => client.agents.create(input),\n onSuccess: () => qc.invalidateQueries({ queryKey: [\"agents\"] }),\n });\n}\n\nexport function useUpdateAgent(id: string) {\n const client = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (v: {\n patch: Omit<UpdateAgentInput, \"revision\">;\n loaded: Pick<Agent, \"revision\" | \"updatedAt\">;\n }) => updateAgent(client, id, v.patch, v.loaded),\n onSuccess: (agent) => {\n qc.setQueryData(agentKey(id), agent);\n return qc.invalidateQueries({ queryKey: [\"agents\"] });\n },\n });\n}\n\nexport function useArchiveAgent() {\n const client = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (id: string) => client.agents.archive(id),\n onSuccess: () => qc.invalidateQueries({ queryKey: [\"agents\"] }),\n });\n}\n\nexport function useAgentSkillsQuery() {\n const client = useEmbedClient();\n return useQuery({ queryKey: agentSkillsKey(), queryFn: () => client.skills.list() });\n}\n\nexport function useAgentSkillVersionsQuery(skillId: string | undefined) {\n const client = useEmbedClient();\n return useQuery({\n queryKey: agentSkillVersionsKey(skillId ?? \"\"),\n enabled: !!skillId,\n queryFn: () => client.skills.versions(skillId as string),\n });\n}\n\nexport function useAgentContextCollectionsQuery() {\n const client = useEmbedClient();\n return useQuery({ queryKey: agentContextKey(), queryFn: () => client.context.list() });\n}\n\nexport function useAgentContextEntriesQuery(collectionId: string | undefined) {\n const client = useEmbedClient();\n return useQuery({\n queryKey: agentContextEntriesKey(collectionId ?? \"\"),\n enabled: !!collectionId,\n queryFn: () => client.context.entries.list(collectionId as string),\n });\n}\n\n/** Every doc visible to the caller (collection-less included) — the pin picker's source. */\nexport function useAgentAllContextEntriesQuery() {\n const client = useEmbedClient();\n return useQuery({\n queryKey: agentAllContextEntriesKey(),\n queryFn: () => client.contextEntries.list({}),\n });\n}\n\nexport function useAgentModelRoutesQuery(projectId?: string) {\n const client = useEmbedClient();\n return useQuery({\n queryKey: agentModelRoutesKey(projectId),\n enabled: projectId != null,\n queryFn: () => listModelRoutes(client, projectId as string),\n });\n}\n\nexport function useAgentSettingsQuery() {\n const client = useEmbedClient();\n return useQuery({\n queryKey: agentSettingsKey(),\n queryFn: () => client.console.storage.settings.get(),\n });\n}\n\nexport function usePatchAgentSettings() {\n const client = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (patch: Parameters<W6WClient[\"console\"][\"storage\"][\"settings\"][\"patch\"]>[0]) =>\n client.console.storage.settings.patch(patch),\n onSuccess: (s) => {\n qc.setQueryData(agentSettingsKey(), s);\n },\n });\n}\n\nexport function useStorageBindingsQuery() {\n const client = useEmbedClient();\n return useQuery({\n queryKey: storageBindingsKey(),\n queryFn: () => client.console.storage.bindings.list(),\n });\n}\n\n// ── the agent Test box (POST /agents/:id/test) ───────────────────────────────\n\n/** One message of a Test conversation, as the model contract has it. */\nexport interface AgentTestTurn {\n role: \"user\" | \"assistant\";\n content: unknown;\n}\n\nexport interface AgentTestRequest {\n project: string;\n message: string;\n /** The `turns` of earlier answers, so a follow-up keeps the conversation. */\n history?: AgentTestTurn[];\n /** Unsaved form state laid over the stored agent. */\n draft?: {\n instructions?: string;\n modelRouteId?: string | null;\n modelOptions?: Record<string, unknown>;\n tools?: AgentTool[];\n };\n}\n\nexport interface AgentTestToolCall {\n tool: string;\n input: Record<string, unknown>;\n ok: boolean;\n /** The tool's output, or the error message when `ok` is false. */\n output: unknown;\n}\n\nexport interface AgentTestResult {\n text: string;\n turns: AgentTestTurn[];\n toolCalls: AgentTestToolCall[];\n model: string | null;\n rounds: number;\n usage: { inputTokens: number; outputTokens: number };\n finishReason: string | null;\n}\n\n/**\n * Run the agent once on a message through the server's agent runtime — the same one a workflow's\n * \"Run agent\" step uses, so tools run there (fixed values resolved server-side, only the AI fields\n * passed on). Real, billed model and tool calls. Through `client.request` (Studio-internal route).\n */\nexport async function testAgent(\n client: W6WClient,\n id: string,\n body: AgentTestRequest,\n): Promise<AgentTestResult> {\n const res = await client.request<AgentTestResult>({\n method: \"POST\",\n path: path`/agents/${id}/test`,\n body,\n });\n return res.body;\n}\n\nexport function useTestAgentMutation(id: string) {\n const client = useEmbedClient();\n return useMutation({ mutationFn: (body: AgentTestRequest) => testAgent(client, id, body) });\n}\n","/**\n * Agents Studio asset hooks — skills, context collections/entries and stored asset files over\n * `W6WClient`'s `skills.*`, `context.*` and `assets.*` (react-query, same shape as `vars.ts`).\n *\n * These are tenant/account-scoped (no `project` is sent). Uploads are byte-mode: the caller\n * hashes and PUTs the same bytes (see Studio's `agents-studio/upload.ts`); this module only\n * wraps the single-call operations.\n */\nimport { useMutation, useQuery, useQueryClient } from \"@tanstack/react-query\";\nimport type {\n AssetUploadCreateInput,\n CreateContextCollectionInput,\n CreateStandaloneContextEntryInput,\n UpdateContextEntryInput,\n} from \"@w6w/sdk\";\nimport { useEmbedClient } from \"../draft/client-context.ts\";\n\nexport const skillsKey = (includeArchived = false) => [\"skills\", { includeArchived }] as const;\nexport const skillKey = (id: string) => [\"skills\", id] as const;\nexport const skillVersionsKey = (id: string) => [\"skills\", id, \"versions\"] as const;\nexport const contextCollectionsKey = (includeArchived = false) =>\n [\"context-collections\", { includeArchived }] as const;\nexport const contextCollectionKey = (id: string) => [\"context-collections\", id] as const;\nexport const contextEntriesKey = (id: string, includeArchived = false) =>\n [\"context-collections\", id, \"entries\", { includeArchived }] as const;\nexport const allContextEntriesKey = (includeArchived = false) =>\n [\"context-entries\", { includeArchived }] as const;\nexport const assetVersionsKey = (id: string) => [\"assets\", id, \"versions\"] as const;\nexport const assetFilesKey = (id: string, versionId: string) =>\n [\"assets\", id, \"versions\", versionId, \"files\"] as const;\n\n// ── Skills ──────────────────────────────────────────────────────────────────────────────────\n\nexport function useSkillsQuery(includeArchived = false) {\n const client = useEmbedClient();\n return useQuery({\n queryKey: skillsKey(includeArchived),\n queryFn: () => client.skills.list({ includeArchived }),\n });\n}\n\nexport function useSkillQuery(id: string | undefined) {\n const client = useEmbedClient();\n return useQuery({\n queryKey: skillKey(id ?? \"\"),\n enabled: id != null,\n queryFn: () => client.skills.get(id as string),\n });\n}\n\nexport function useSkillVersionsQuery(id: string | undefined) {\n const client = useEmbedClient();\n return useQuery({\n queryKey: skillVersionsKey(id ?? \"\"),\n enabled: id != null,\n queryFn: () => client.skills.versions(id as string),\n });\n}\n\nexport function useArchiveSkillMutation() {\n const client = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (id: string) => client.skills.archive(id),\n onSuccess: () => qc.invalidateQueries({ queryKey: [\"skills\"] }),\n });\n}\n\n// ── Context collections + entries ───────────────────────────────────────────────────────────\n\nexport function useContextCollectionsQuery(includeArchived = false) {\n const client = useEmbedClient();\n return useQuery({\n queryKey: contextCollectionsKey(includeArchived),\n queryFn: () => client.context.list({ includeArchived }),\n });\n}\n\nexport function useContextCollectionQuery(id: string | undefined) {\n const client = useEmbedClient();\n return useQuery({\n queryKey: contextCollectionKey(id ?? \"\"),\n enabled: id != null,\n queryFn: () => client.context.get(id as string),\n });\n}\n\nexport function useCreateContextCollectionMutation() {\n const client = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (input: CreateContextCollectionInput) => client.context.create(input),\n onSuccess: () => qc.invalidateQueries({ queryKey: [\"context-collections\"] }),\n });\n}\n\nexport function useContextEntriesQuery(collectionId: string | undefined, includeArchived = false) {\n const client = useEmbedClient();\n return useQuery({\n queryKey: contextEntriesKey(collectionId ?? \"\", includeArchived),\n enabled: collectionId != null,\n queryFn: () => client.context.entries.list(collectionId as string, { includeArchived }),\n });\n}\n\n/** Edit-as-new-version: `PUT` creates the next version; `ifUnmodifiedSince` guards a stale edit. */\nexport function useUpdateContextEntryMutation() {\n const client = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (v: {\n collectionId: string;\n entryId: string;\n input: UpdateContextEntryInput;\n ifUnmodifiedSince?: string;\n }) =>\n client.context.entries.update(v.collectionId, v.entryId, v.input, {\n ifUnmodifiedSince: v.ifUnmodifiedSince,\n }),\n onSuccess: (_r, v) => {\n qc.invalidateQueries({ queryKey: [\"context-collections\", v.collectionId] });\n qc.invalidateQueries({ queryKey: [\"assets\"] });\n },\n });\n}\n\n// ── Collection-independent entries (`client.contextEntries.*`) ──────────────────────────────\n\n/** Every doc visible to the caller, whether or not it is in a collection. */\nexport function useAllContextEntriesQuery(includeArchived = false) {\n const client = useEmbedClient();\n return useQuery({\n queryKey: allContextEntriesKey(includeArchived),\n queryFn: () => client.contextEntries.list({ includeArchived }),\n });\n}\n\n/** Invalidate the all-docs list and, per affected collection, its entries list. */\nfunction invalidateEntries(qc: ReturnType<typeof useQueryClient>, collectionIds: string[] = []) {\n qc.invalidateQueries({ queryKey: [\"context-entries\"] });\n for (const id of collectionIds) qc.invalidateQueries({ queryKey: contextEntriesKey(id) });\n}\n\n/** Create a text doc, private unless `collectionIds` / `visibility` say otherwise. */\nexport function useCreateContextEntryMutation() {\n const client = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (input: CreateStandaloneContextEntryInput) => client.contextEntries.create(input),\n onSuccess: (_r, v) => invalidateEntries(qc, v.collectionIds),\n });\n}\n\nexport function useAddEntryToCollectionMutation() {\n const client = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (v: { entryId: string; collectionId: string }) =>\n client.contextEntries.addToCollection(v.entryId, v.collectionId),\n onSuccess: (_r, v) => invalidateEntries(qc, [v.collectionId]),\n });\n}\n\nexport function useRemoveEntryFromCollectionMutation() {\n const client = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (v: { entryId: string; collectionId: string }) =>\n client.contextEntries.removeFromCollection(v.entryId, v.collectionId),\n onSuccess: (_r, v) => invalidateEntries(qc, [v.collectionId]),\n });\n}\n\n// ── Asset versions, files, downloads ────────────────────────────────────────────────────────\n\nexport function useAssetVersionsQuery(assetId: string | undefined) {\n const client = useEmbedClient();\n return useQuery({\n queryKey: assetVersionsKey(assetId ?? \"\"),\n enabled: assetId != null,\n queryFn: () => client.assets.versions(assetId as string),\n });\n}\n\nexport function useAssetFilesQuery(assetId: string | undefined, versionId: string | undefined) {\n const client = useEmbedClient();\n return useQuery({\n queryKey: assetFilesKey(assetId ?? \"\", versionId ?? \"\"),\n enabled: assetId != null && versionId != null,\n queryFn: () => client.assets.files(assetId as string, versionId as string),\n });\n}\n\n/** Exact bytes of one file. A mutation (not a query): downloads are user-triggered, never cached. */\nexport function useDownloadAssetFileMutation() {\n const client = useEmbedClient();\n return useMutation({\n mutationFn: (v: { assetId: string; versionId: string; fileId: string }) =>\n client.assets.content(v.assetId, v.versionId, v.fileId),\n });\n}\n\n/** One version as a store-only ZIP. */\nexport function useDownloadAssetArchiveMutation() {\n const client = useEmbedClient();\n return useMutation({\n mutationFn: (v: { assetId: string; versionId: string }) =>\n client.assets.archiveDownload(v.assetId, v.versionId),\n });\n}\n\nexport function useArchiveAssetMutation() {\n const client = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (id: string) => client.assets.archive(id),\n onSuccess: () => qc.invalidateQueries({ queryKey: [\"assets\"] }),\n });\n}\n\n// ── Upload (resumable, byte-mode) ───────────────────────────────────────────────────────────\n\nexport function useCreateAssetUploadMutation() {\n const client = useEmbedClient();\n return useMutation({\n mutationFn: (input: AssetUploadCreateInput) => client.assets.uploads.create(input),\n });\n}\n\nexport function usePutAssetUploadEntryMutation() {\n const client = useEmbedClient();\n return useMutation({\n mutationFn: (v: { uploadId: string; index: number; bytes: Uint8Array }) =>\n client.assets.uploads.putEntry(v.uploadId, v.index, v.bytes),\n });\n}\n\n/** Publishing a version changes skills, context and assets alike — invalidate all three. */\nexport function useFinalizeAssetUploadMutation() {\n const client = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (uploadId: string) => client.assets.uploads.finalize(uploadId),\n onSuccess: () => {\n qc.invalidateQueries({ queryKey: [\"skills\"] });\n qc.invalidateQueries({ queryKey: [\"context-collections\"] });\n qc.invalidateQueries({ queryKey: [\"assets\"] });\n },\n });\n}\n\nexport function useAbortAssetUploadMutation() {\n const client = useEmbedClient();\n return useMutation({ mutationFn: (uploadId: string) => client.assets.uploads.abort(uploadId) });\n}\n"],"names":["AgentConflictError","cause","__publicField","currentRevisionOf","raw","o","v","_a","_c","_b","isAgentConflict","agentsKey","includeArchived","agentKey","id","agentSkillVersionsKey","skillId","agentSkillsKey","agentContextKey","agentContextEntriesKey","collectionId","agentAllContextEntriesKey","agentModelRoutesKey","projectId","agentSettingsKey","storageBindingsKey","updateAgent","client","patch","loaded","e","ApiError","skillPinState","pin","readyVersions","contextPinState","entries","readyContextEntries","useAgentsQuery","useEmbedClient","useQuery","useAgentQuery","useCreateAgent","qc","useQueryClient","useMutation","input","useUpdateAgent","agent","useArchiveAgent","useAgentSkillsQuery","useAgentSkillVersionsQuery","useAgentContextCollectionsQuery","useAgentContextEntriesQuery","useAgentAllContextEntriesQuery","useAgentModelRoutesQuery","listModelRoutes","useAgentSettingsQuery","usePatchAgentSettings","useStorageBindingsQuery","testAgent","body","path","useTestAgentMutation","skillsKey","skillKey","skillVersionsKey","contextCollectionsKey","contextCollectionKey","contextEntriesKey","allContextEntriesKey","assetVersionsKey","assetFilesKey","versionId","useSkillsQuery","useSkillQuery","useSkillVersionsQuery","useArchiveSkillMutation","useContextCollectionsQuery","useContextCollectionQuery","useCreateContextCollectionMutation","useContextEntriesQuery","useUpdateContextEntryMutation","_r","useAllContextEntriesQuery","invalidateEntries","collectionIds","useCreateContextEntryMutation","useAddEntryToCollectionMutation","useRemoveEntryFromCollectionMutation","useAssetVersionsQuery","assetId","useAssetFilesQuery","useDownloadAssetFileMutation","useDownloadAssetArchiveMutation","useArchiveAssetMutation","useCreateAssetUploadMutation","usePutAssetUploadEntryMutation","useFinalizeAssetUploadMutation","uploadId","useAbortAssetUploadMutation"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAsCO,MAAMA,UAA2B,MAAM;AAAA,EAK5C,YAAYC,GAAiB;AAC3B,UAAM,kEAAkE;AALjE,IAAAC,EAAA,cAAO;AAEP;AAAA,IAAAA,EAAA;AACA,IAAAA,EAAA;AAGP,SAAK,OAAO,sBACZ,KAAK,QAAQD,GACb,KAAK,kBAAkBE,EAAkBF,EAAM,GAAG;AAAA,EACpD;AACF;AAEA,SAASE,EAAkBC,GAA6B;;AACtD,QAAMC,IAAID,GAIJE,KAAID,KAAA,gBAAAA,EAAG,eAAYE,IAAAF,KAAA,gBAAAA,EAAG,UAAH,gBAAAE,EAAU,eAAYC,KAAAC,IAAAJ,KAAA,gBAAAA,EAAG,UAAH,gBAAAI,EAA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C,QAAMtE,IAASY,EAAA;AACf,SAAOM,EAAY;AAAA,IACjB,YAAY,CAACvC,MACXqB,EAAO,OAAO,QAAQ,SAASrB,EAAE,UAAUA,EAAE,OAAOA,EAAE,KAAK;AAAA,EAAA,CAC9D;AACH;AAGO,SAAS4F,KAAiC;AAC/C,QAAMvE,IAASY,EAAA,GACTI,IAAKC,EAAA;AACX,SAAOC,EAAY;AAAA,IACjB,YAAY,CAACsD,MAAqBxE,EAAO,OAAO,QAAQ,SAASwE,CAAQ;AAAA,IACzE,WAAW,MAAM;AACf,MAAAxD,EAAG,kBAAkB,EAAE,UAAU,CAAC,QAAQ,GAAG,GAC7CA,EAAG,kBAAkB,EAAE,UAAU,CAAC,qBAAqB,GAAG,GAC1DA,EAAG,kBAAkB,EAAE,UAAU,CAAC,QAAQ,GAAG;AAAA,IAC/C;AAAA,EAAA,CACD;AACH;AAEO,SAASyD,KAA8B;AAC5C,QAAMzE,IAASY,EAAA;AACf,SAAOM,EAAY,EAAE,YAAY,CAACsD,MAAqBxE,EAAO,OAAO,QAAQ,MAAMwE,CAAQ,GAAG;AAChG;"}
|
|
@@ -2,7 +2,7 @@ import { useQueryClient as c, useMutation as l, useQuery as w } from "@tanstack/
|
|
|
2
2
|
import { path as u } from "@w6w/sdk";
|
|
3
3
|
import { u as i } from "./client-context-CX61Bgw-.js";
|
|
4
4
|
import { i as y, a as d } from "./callables-tOlflvbl.js";
|
|
5
|
-
import { o as p, a2 as b } from "./workflows-
|
|
5
|
+
import { o as p, a2 as b } from "./workflows-Dz8LMjnt.js";
|
|
6
6
|
const h = (t) => d("endpoint", t), m = (t) => d("function", t), a = {
|
|
7
7
|
function: "functions",
|
|
8
8
|
workflow: "workflows",
|
|
@@ -186,4 +186,4 @@ export {
|
|
|
186
186
|
N as u,
|
|
187
187
|
$ as v
|
|
188
188
|
};
|
|
189
|
-
//# sourceMappingURL=spec-export-
|
|
189
|
+
//# sourceMappingURL=spec-export-DMMET5VM.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spec-export-DGigBUsP.js","sources":["../src/repos/versions.ts","../src/repos/constants.ts","../src/repos/spec-export.ts"],"sourcesContent":["/**\n * The `/<collection>/:id/{publish,versions,enable,disable}` repo (T3.1.1) — the Settings rail's\n * read-only version-history browser plus Publish and Enable/Disable. A NEW file, mirroring\n * `src/repos/spec-export.ts` in full: kept out of `repos/functions.ts` / `repos/workflows.ts` /\n * `repos/endpoints.ts` so this node never collides with any of them on the same file, exactly the\n * reason `spec-export.ts`'s own docblock gives for the sibling `/spec` route.\n *\n * **Workflow and Function arms go through the public `@w6w/sdk` methods** (`listVersions`,\n * `getVersion`, `publish`, `revert`, `enable`, `disable`, and `workflows.runVersion`), never\n * `apiClient.console.*`. Each hook dispatches with an explicit per-kind `switch` over LITERAL\n * receivers (`apiClient.workflows.publish(id)`, `apiClient.functions.publish(id)`) and no `default:`\n * — the same reasoning `COLLECTION_PATH` and `useRevertMutation` give against derived dispatch.\n *\n * **Two arms deliberately stay on `W6WClient.request<T>()`:** the ENDPOINT arm of every hook\n * (R-5: endpoint versions have no SDK method — intentionally excluded from the public surface),\n * and the FUNCTION arm of {@link useInvokeVersionMutation} (F-P4: `VersionHistoryModal` renders the\n * raw invocation frame, but `functions.runVersion` unwraps the output like `functions.run`, so the\n * SDK method would drop the frame; follow-up F-6).\n *\n * Every query below is gated on the CALLER'S OWN `enabled` flag, ANDed with `kind !== null` and\n * `id !== \"\"` — never on mount alone (`packages/studio/.ai/PLANNER.md` fact 11): a hook that fires\n * unconditionally against an unresolved `null`/`\"\"` argument 404s once and, because `main.tsx`\n * sets `retry: false` and an unchanged query key never re-fetches, never self-corrects. Opening\n * the Settings panel must issue ZERO `/versions` requests; only opening its History section (or\n * `WorkflowsPage.tsx`'s own editor, a separate call site with its own gate) flips `enabled`.\n *\n * T5.3.1 (project.md Phase 2, Amendments #5/#6): a version can now be reverted to and invoked\n * directly, superseding the earlier \"read-only history, restore out of scope\" pin. `useRevertMutation`\n * overwrites the LIVE resource's `definition` with the archived version's content — never its\n * `key`/address (HITL-4's pinned default) — and does post a `definition` back, by design.\n * `useInvokeVersionMutation` runs that ARCHIVED version's own definition, not the live one, which is\n * exactly why it exists as a separate call from the live invoke/run routes `functions.ts`/\n * `endpoints.ts`/`workflows.ts` already expose.\n */\nimport { useMutation, useQuery, useQueryClient } from \"@tanstack/react-query\";\nimport { path } from \"@w6w/sdk\";\nimport { useEmbedClient } from \"../draft/client-context.ts\";\nimport { callableKey } from \"../lib/callable-kind.ts\";\nimport { historyKeys } from \"../lib/history-query.ts\";\nimport { invalidateSavedCallable } from \"../lib/save-invalidation.ts\";\nimport { workflowKey } from \"./workflows.ts\";\n\n/** The Endpoint / Function single-resource keys the revert arm invalidates: the same\n * `callableKey(\"<kind>\", id)` Studio's `repos/endpoints.ts` / `repos/functions.ts` export as\n * `endpointKey` / `functionKey` (byte-identical `[\"endpoint\", id]` / `[\"function\", id]`). */\nconst endpointKey = (id: string) => callableKey(\"endpoint\", id);\nconst functionKey = (id: string) => callableKey(\"function\", id);\n\n/** The three kinds the wire contract's version-history routes exist for — `connection` has none\n * (see `hasVersionHistory`, `../lib/rail-settings.ts`). */\nexport type VersionsKind = \"function\" | \"workflow\" | \"endpoint\";\n\n/** `<coll>` — the wire contract's own path segment for each kind, every one of the three arms\n * named explicitly (never derived by string pluralization), mirroring `specCollectionForKind`'s\n * own reasoning (`../lib/rail-settings.ts:69`): a typo'd suffix rule would silently send one\n * kind's requests at another kind's collection. */\nconst COLLECTION_PATH: Record<VersionsKind, \"functions\" | \"workflows\" | \"endpoints\"> = {\n function: \"functions\",\n workflow: \"workflows\",\n endpoint: \"endpoints\",\n};\n\n/** One row of `GET /<coll>/:id/versions`'s `versions` array — newest first, per the wire contract. */\nexport interface VersionSummary {\n versionNumber: number;\n createdAt: string;\n createdBy: string | null;\n isCurrentPublished: boolean;\n}\n\n/** `GET /<coll>/:id/versions`'s full 200 body. */\nexport interface VersionsEnvelope {\n enabled: boolean;\n currentPublishedVersion: number | null;\n versions: VersionSummary[];\n}\n\n/** `GET /<coll>/:id/versions/:n`'s `version` field — `definition` is the redacted stored\n * definition for THIS query; {@link useRevertMutation} is what posts a version's definition\n * back onto the live resource, and {@link useInvokeVersionMutation} is what runs it. */\nexport interface VersionDetail {\n versionNumber: number;\n createdAt: string;\n createdBy: string | null;\n isCurrentPublished: boolean;\n definition: Record<string, unknown>;\n}\n\n/** `POST /<coll>/:id/publish`'s 200 body. */\nexport interface PublishResult {\n version: {\n kind: string;\n callableId: string;\n versionNumber: number;\n createdAt: string;\n createdBy: string | null;\n };\n currentPublishedVersion: number;\n}\n\n/** `POST /<coll>/:id/versions/:n/revert`'s 200 body. */\nexport interface RevertResult {\n reverted: {\n kind: string;\n callableId: string;\n versionNumber: number;\n };\n}\n\n/** `<coll>` per kind ends its live invoke/run route in `/invoke` (Function, Endpoint) or `/run`\n * (Workflow, matching that kind's existing unversioned route) — every arm named explicitly\n * (never derived by suffix rule), mirroring `COLLECTION_PATH`'s own reasoning above: a derived\n * rule would silently send one kind's requests at the wrong verb. */\nconst VERSION_INVOKE_VERB: Record<VersionsKind, \"invoke\" | \"run\"> = {\n function: \"invoke\",\n endpoint: \"invoke\",\n workflow: \"run\",\n};\n\nexport function versionsKey(kind: VersionsKind | null, id: string) {\n return [\"versions\", kind, id] as const;\n}\n\nexport function versionKey(kind: VersionsKind | null, id: string, versionNumber: number | null) {\n return [\"version\", kind, id, versionNumber] as const;\n}\n\n/**\n * `GET /<collection>/:id/versions`. Never fires on mount — `enabled` is the caller's own flag\n * (the Settings panel's History-open state, or `WorkflowsPage.tsx`'s own editor-open gate), ANDed\n * with `kind !== null` and `id !== \"\"`, exactly `useSpecQuery`'s shape (`spec-export.ts:45-57`).\n */\nexport function useVersionsQuery(kind: VersionsKind | null, id: string, enabled: boolean) {\n const apiClient = useEmbedClient();\n return useQuery({\n queryKey: versionsKey(kind, id),\n queryFn: async (): Promise<VersionsEnvelope> => {\n switch (kind as VersionsKind) {\n case \"workflow\":\n return await apiClient.workflows.listVersions(id);\n case \"function\":\n return await apiClient.functions.listVersions(id);\n case \"endpoint\": {\n // R-5: no SDK method for endpoint versions.\n const res = await apiClient.request<VersionsEnvelope>({\n method: \"GET\",\n path: path`/${COLLECTION_PATH.endpoint}/${id}/versions`,\n });\n return res.body;\n }\n }\n },\n enabled: enabled && kind !== null && id !== \"\",\n });\n}\n\n/**\n * `GET /<collection>/:id/versions/:n`. Same gating shape as {@link useVersionsQuery}, plus\n * `versionNumber !== null` — the modal opens this only once a row has been clicked.\n */\nexport function useVersionQuery(\n kind: VersionsKind | null,\n id: string,\n versionNumber: number | null,\n enabled: boolean,\n) {\n const apiClient = useEmbedClient();\n return useQuery({\n queryKey: versionKey(kind, id, versionNumber),\n queryFn: async (): Promise<VersionDetail> => {\n // The SDK's `getVersion` already unwraps the `{ version }` envelope.\n const n = versionNumber as number;\n switch (kind as VersionsKind) {\n case \"workflow\":\n return (await apiClient.workflows.getVersion(id, n)) as VersionDetail;\n case \"function\":\n return (await apiClient.functions.getVersion(id, n)) as VersionDetail;\n case \"endpoint\": {\n // R-5: no SDK method for endpoint versions.\n const res = await apiClient.request<{ version: VersionDetail }>({\n method: \"GET\",\n path: path`/${COLLECTION_PATH.endpoint}/${id}/versions/${String(n)}`,\n });\n return res.body.version;\n }\n }\n },\n enabled: enabled && kind !== null && id !== \"\" && versionNumber !== null,\n });\n}\n\n/**\n * `POST /<collection>/:id/publish`. `kind` is fixed per hook instance — the caller already knows\n * which kind it is publishing (the rail's `ctx.kind`, or `WorkflowsPage.tsx`'s hardcoded\n * `\"workflow\"`) — and `mutate(id)` supplies the resource. `onSuccess` invalidates the SAME\n * `[\"versions\", kind, id]` key {@link useVersionsQuery} reads, so the panel's published pointer\n * and version list are fresh without a reload (A3), mirroring `useSaveFunctionMutation`'s\n * `onSuccess` shape (`./functions.ts`).\n */\nexport function usePublishMutation(kind: VersionsKind) {\n const apiClient = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (id: string): Promise<PublishResult> => {\n switch (kind) {\n case \"workflow\":\n return await apiClient.workflows.publish(id);\n case \"function\":\n return await apiClient.functions.publish(id);\n case \"endpoint\": {\n // R-5: no SDK method for endpoint versions.\n const res = await apiClient.request<PublishResult>({\n method: \"POST\",\n path: path`/${COLLECTION_PATH.endpoint}/${id}/publish`,\n });\n return res.body;\n }\n }\n },\n onSuccess: (_result, id) => {\n return qc.invalidateQueries({ queryKey: versionsKey(kind, id) });\n },\n });\n}\n\n/**\n * `POST /<collection>/:id/{enable,disable}`. One mutation for both — the wire contract is two\n * routes distinguished only by which one is called, so `vars.enabled` picks the path segment\n * rather than this module carrying two near-identical mutations. `onSuccess` invalidates the same\n * key {@link usePublishMutation} does, for the same reason.\n */\nexport function useSetEnabledMutation(kind: VersionsKind) {\n const apiClient = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: { id: string; enabled: boolean }): Promise<{ enabled: boolean }> => {\n // The SDK's `enable`/`disable` return void; the hook's result stays `{ enabled }`.\n switch (kind) {\n case \"workflow\":\n if (vars.enabled) await apiClient.workflows.enable(vars.id);\n else await apiClient.workflows.disable(vars.id);\n return { enabled: vars.enabled };\n case \"function\":\n if (vars.enabled) await apiClient.functions.enable(vars.id);\n else await apiClient.functions.disable(vars.id);\n return { enabled: vars.enabled };\n case \"endpoint\": {\n // R-5: no SDK method for endpoint versions.\n const res = await apiClient.request<{ enabled: boolean }>({\n method: \"POST\",\n path: path`/${COLLECTION_PATH.endpoint}/${vars.id}/${vars.enabled ? \"enable\" : \"disable\"}`,\n });\n return res.body;\n }\n }\n },\n onSuccess: (_result, vars) => {\n qc.invalidateQueries({ queryKey: versionsKey(kind, vars.id) });\n },\n });\n}\n\n/**\n * `POST /<collection>/:id/versions/:n/revert`, no body — overwrites the LIVE resource's\n * `definition` with the archived version's content, preserving its `key`/address (HITL-4's\n * pinned default; see the module docblock). This is the first mutation in this family that\n * changes `definition` rather than merely appending to or flipping a flag on the version history\n * (`usePublishMutation`/`useSetEnabledMutation` above do neither), so `onSuccess` invalidates\n * BOTH `versionsKey(kind, id)` (the same key those two invalidate) AND the kind's own\n * definition-edit key — via the shared `invalidateSavedCallable` helper\n * `useSaveFunctionMutation`/`useSaveEndpointMutation` already route through\n * (`../lib/save-invalidation.ts`) — or the page a user reverted FROM keeps showing the\n * pre-revert draft until a manual reload. The definition key is picked by a `switch` naming all\n * three arms explicitly, with no `default:` — the same reasoning `COLLECTION_PATH`'s own docblock\n * gives: a derived rule would silently send one kind at another kind's key.\n */\nexport function useRevertMutation(kind: VersionsKind) {\n const apiClient = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: { id: string; versionNumber: number }): Promise<RevertResult> => {\n // The SDK's `revert` unwraps `{ reverted }`; the hook re-wraps it to keep its result shape.\n switch (kind) {\n case \"workflow\":\n return { reverted: await apiClient.workflows.revert(vars.id, vars.versionNumber) };\n case \"function\":\n return { reverted: await apiClient.functions.revert(vars.id, vars.versionNumber) };\n case \"endpoint\": {\n // R-5: no SDK method for endpoint versions.\n const res = await apiClient.request<RevertResult>({\n method: \"POST\",\n path: path`/${COLLECTION_PATH.endpoint}/${vars.id}/versions/${String(vars.versionNumber)}/revert`,\n });\n return res.body;\n }\n }\n },\n onSuccess: (_result, vars) => {\n let definitionKey: readonly unknown[];\n switch (kind) {\n case \"function\":\n definitionKey = functionKey(vars.id);\n break;\n case \"workflow\":\n definitionKey = workflowKey(vars.id);\n break;\n case \"endpoint\":\n definitionKey = endpointKey(vars.id);\n break;\n }\n invalidateSavedCallable(qc, versionsKey(kind, vars.id), definitionKey);\n },\n });\n}\n\n/**\n * `POST /<collection>/:id/versions/:n/{invoke,run}`, an EMPTY JSON body — identical to that\n * kind's unversioned invoke/run route's success body, except the requested version's OWN\n * `impl`/definition runs instead of the live one (T5.3.1's wire contract table). Unlike\n * {@link useRevertMutation}, invoking changes no resource state, so it invalidates History ONLY\n * (`onSettled`, `historyKeys.root` — a version run is a run, failed ones included, like every other\n * run path) and no resource query — the caller (`VersionHistoryModal`) renders the mutation's own `data`/`error` state\n * directly, and that state is naturally cleared whenever the modal remounts for a different\n * version (`SettingsTool.tsx`'s `openVersion` gate fully unmounts/remounts it, never leaves it\n * mounted across a prop change).\n */\nexport function useInvokeVersionMutation(kind: VersionsKind) {\n const apiClient = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: {\n id: string;\n versionNumber: number;\n }): Promise<Record<string, unknown>> => {\n // The workflow arm moves to `workflows.runVersion`. The FUNCTION arm (F-P4 / F-6) and the\n // ENDPOINT arm (R-5) stay on `request()`: this hook's caller renders the raw invocation\n // frame, and `functions.runVersion` unwraps the output like `functions.run` — it would drop\n // the frame. The workflow arm returns only `{ runId, status }`, as the raw body did.\n if (kind === \"workflow\") {\n const run = await apiClient.workflows.runVersion(vars.id, vars.versionNumber, {});\n // Project back to the server's own run-start body: the SDK adds `steps`/`terminal`/\n // `httpStatus`, and `VersionHistoryModal` prints this value verbatim as JSON.\n return { runId: run.runId, status: run.status };\n }\n const res = await apiClient.request<Record<string, unknown>>({\n method: \"POST\",\n path: path`/${COLLECTION_PATH[kind]}/${vars.id}/versions/${String(vars.versionNumber)}/${VERSION_INVOKE_VERB[kind]}`,\n body: {},\n });\n return res.body;\n },\n onSettled: () => qc.invalidateQueries({ queryKey: historyKeys.root }),\n });\n}\n","/**\n * The `constants` domain repo — account-level, read-only values set by an\n * administrator and referenced as `{{ const.<name> }}`. There is no write\n * route; the server derives the account from the token.\n */\nimport { useQuery } from \"@tanstack/react-query\";\nimport { useEmbedClient } from \"../draft/client-context.ts\";\n\nexport interface Constant {\n name: string;\n type: \"string\" | \"number\" | \"boolean\" | \"json\";\n value: unknown;\n description: string;\n /** Computed by the server (e.g. `account_id`), not stored. */\n derived: boolean;\n}\n\n/** Query key for the constants list. */\nexport function constantsKey() {\n return [\"constants\"] as const;\n}\n\n/** The account's constants (read-only). */\nexport function useConstantsQuery() {\n const apiClient = useEmbedClient();\n return useQuery({\n queryKey: constantsKey(),\n queryFn: async () => {\n const res = await apiClient.request<{ constants: Constant[] }>({\n method: \"GET\",\n path: \"/constants\",\n });\n return res.body.constants;\n },\n });\n}\n","/**\n * The `/<collection>/:id/spec` export repo (T3.3.1) — the Settings rail's Export\n * button. A NEW file, deliberately kept out of `repos/functions.ts` /\n * `repos/endpoints.ts` (T3.1.1 owns both), exactly as T3.2.1 put `/spec/import` in\n * its own `repos/spec-import.ts` for the same reason — the two nodes never\n * collide on the same file.\n *\n * **Goes through `W6WClient.request<T>()`, never `apiClient.console.*`.** There\n * is no SDK method for this route, exactly as `repos/spec-import.ts`'s own\n * docblock records for the sibling `/spec/import` route.\n *\n * `useSpecQuery` is gated on the caller's `enabled` flag (the export modal's own\n * open state) AND `collection !== null` — never on `ctx.kind` alone, and never\n * on mount: the contract pins that opening the Settings panel must issue ZERO\n * `/spec` requests, and exactly one fires per Export click.\n */\nimport { useQuery } from \"@tanstack/react-query\";\nimport { path } from \"@w6w/sdk\";\nimport { useEmbedClient } from \"../draft/client-context.ts\";\n\n/** The collections that carry a `/spec` export route — `specCollectionForKind`\n * (`../lib/rail-settings.ts`) is the sole producer of this type's values. */\nexport type SpecCollection = \"functions\" | \"endpoints\" | \"workflows\";\n\n/**\n * Mirrors T2.1.1's `SpecDocument`, also mirrored by `repos/spec-import.ts`'s\n * `SpecImportDocument` for the sibling import route: the portable document a\n * `GET /<kind>/:id/spec` export produces. Not a bare `FunctionDef`/`EndpointDef`\n * — `id` is deleted server-side (`admin/spec.ts:96-108`) and connection/var\n * references ride as re-bindable `rebind` entries, never live ids.\n */\nexport interface SpecDocument {\n specVersion: string;\n kind: \"function\" | \"endpoint\" | \"workflow\";\n callable: Record<string, unknown>;\n rebind: unknown[];\n}\n\n/**\n * `GET /<collection>/:id/spec`. `collection` is `null` for a kind the Export\n * button never renders on (`specCollectionForKind`'s `connection`\n * arm) — passing `null` disables the query regardless of `enabled`, so a\n * caller need not re-derive that guard itself.\n */\nexport function useSpecQuery(collection: SpecCollection | null, id: string, enabled: boolean) {\n const apiClient = useEmbedClient();\n return useQuery({\n queryKey: [\"spec\", collection, id],\n queryFn: async () => {\n const res = await apiClient.request<{ spec: SpecDocument }>({\n method: \"GET\",\n path: path`/${collection as SpecCollection}/${id}/spec`,\n });\n return res.body.spec;\n },\n enabled: enabled && collection !== null,\n });\n}\n"],"names":["endpointKey","id","callableKey","functionKey","COLLECTION_PATH","VERSION_INVOKE_VERB","versionsKey","kind","versionKey","versionNumber","useVersionsQuery","enabled","apiClient","useEmbedClient","useQuery","path","useVersionQuery","n","usePublishMutation","qc","useQueryClient","useMutation","_result","useSetEnabledMutation","vars","useRevertMutation","definitionKey","workflowKey","invalidateSavedCallable","useInvokeVersionMutation","run","historyKeys","constantsKey","useConstantsQuery","useSpecQuery","collection"],"mappings":";;;;;AA6CA,MAAMA,IAAc,CAACC,MAAeC,EAAY,YAAYD,CAAE,GACxDE,IAAc,CAACF,MAAeC,EAAY,YAAYD,CAAE,GAUxDG,IAAiF;AAAA,EACrF,UAAU;AAAA,EACV,UAAU;AAAA,EACV,UAAU;AACZ,GAqDMC,IAA8D;AAAA,EAClE,UAAU;AAAA,EACV,UAAU;AAAA,EACV,UAAU;AACZ;AAEO,SAASC,EAAYC,GAA2BN,GAAY;AACjE,SAAO,CAAC,YAAYM,GAAMN,CAAE;AAC9B;AAEO,SAASO,EAAWD,GAA2BN,GAAYQ,GAA8B;AAC9F,SAAO,CAAC,WAAWF,GAAMN,GAAIQ,CAAa;AAC5C;AAOO,SAASC,EAAiBH,GAA2BN,GAAYU,GAAkB;AACxF,QAAMC,IAAYC,EAAA;AAClB,SAAOC,EAAS;AAAA,IACd,UAAUR,EAAYC,GAAMN,CAAE;AAAA,IAC9B,SAAS,YAAuC;AAC9C,cAAQM,GAAA;AAAA,QACN,KAAK;AACH,iBAAO,MAAMK,EAAU,UAAU,aAAaX,CAAE;AAAA,QAClD,KAAK;AACH,iBAAO,MAAMW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AAA,QAClH,MAAM,CAAA;AAAA,MAAC,CACR,GACU;AAAA,IACb;AAAA,IACA,WAAW,MAAMY,EAAG,kBAAkB,EAAE,UAAUY,EAAY,MAAM;AAAA,EAAA,CACrE;AACH;AC/UO,SAASC,IAAe;AAC7B,SAAO,CAAC,WAAW;AACrB;AAGO,SAASC,IAAoB;AAClC,QAAMrB,IAAYC,EAAA;AAClB,SAAOC,EAAS;AAAA,IACd,UAAUkB,EAAA;AAAA,IACV,SAAS,aACK,MAAMpB,EAAU,QAAmC;AAAA,MAC7D,QAAQ;AAAA,MACR,MAAM;AAAA,IAAA,CACP,GACU,KAAK;AAAA,EAClB,CACD;AACH;ACSO,SAASsB,EAAaC,GAAmClC,GAAYU,GAAkB;AAC5F,QAAMC,IAAYC,EAAA;AAClB,SAAOC,EAAS;AAAA,IACd,UAAU,CAAC,QAAQqB,GAAYlC,CAAE;AAAA,IACjC,SAAS,aACK,MAAMW,EAAU,QAAgC;AAAA,MAC1D,QAAQ;AAAA,MACR,MAAMG,KAAQoB,CAA4B,IAAIlC,CAAE;AAAA,IAAA,CACjD,GACU,KAAK;AAAA,IAElB,SAASU,KAAWwB,MAAe;AAAA,EAAA,CACpC;AACH;"}
|
|
1
|
+
{"version":3,"file":"spec-export-DMMET5VM.js","sources":["../src/repos/versions.ts","../src/repos/constants.ts","../src/repos/spec-export.ts"],"sourcesContent":["/**\n * The `/<collection>/:id/{publish,versions,enable,disable}` repo (T3.1.1) — the Settings rail's\n * read-only version-history browser plus Publish and Enable/Disable. A NEW file, mirroring\n * `src/repos/spec-export.ts` in full: kept out of `repos/functions.ts` / `repos/workflows.ts` /\n * `repos/endpoints.ts` so this node never collides with any of them on the same file, exactly the\n * reason `spec-export.ts`'s own docblock gives for the sibling `/spec` route.\n *\n * **Workflow and Function arms go through the public `@w6w/sdk` methods** (`listVersions`,\n * `getVersion`, `publish`, `revert`, `enable`, `disable`, and `workflows.runVersion`), never\n * `apiClient.console.*`. Each hook dispatches with an explicit per-kind `switch` over LITERAL\n * receivers (`apiClient.workflows.publish(id)`, `apiClient.functions.publish(id)`) and no `default:`\n * — the same reasoning `COLLECTION_PATH` and `useRevertMutation` give against derived dispatch.\n *\n * **Two arms deliberately stay on `W6WClient.request<T>()`:** the ENDPOINT arm of every hook\n * (R-5: endpoint versions have no SDK method — intentionally excluded from the public surface),\n * and the FUNCTION arm of {@link useInvokeVersionMutation} (F-P4: `VersionHistoryModal` renders the\n * raw invocation frame, but `functions.runVersion` unwraps the output like `functions.run`, so the\n * SDK method would drop the frame; follow-up F-6).\n *\n * Every query below is gated on the CALLER'S OWN `enabled` flag, ANDed with `kind !== null` and\n * `id !== \"\"` — never on mount alone (`packages/studio/.ai/PLANNER.md` fact 11): a hook that fires\n * unconditionally against an unresolved `null`/`\"\"` argument 404s once and, because `main.tsx`\n * sets `retry: false` and an unchanged query key never re-fetches, never self-corrects. Opening\n * the Settings panel must issue ZERO `/versions` requests; only opening its History section (or\n * `WorkflowsPage.tsx`'s own editor, a separate call site with its own gate) flips `enabled`.\n *\n * T5.3.1 (project.md Phase 2, Amendments #5/#6): a version can now be reverted to and invoked\n * directly, superseding the earlier \"read-only history, restore out of scope\" pin. `useRevertMutation`\n * overwrites the LIVE resource's `definition` with the archived version's content — never its\n * `key`/address (HITL-4's pinned default) — and does post a `definition` back, by design.\n * `useInvokeVersionMutation` runs that ARCHIVED version's own definition, not the live one, which is\n * exactly why it exists as a separate call from the live invoke/run routes `functions.ts`/\n * `endpoints.ts`/`workflows.ts` already expose.\n */\nimport { useMutation, useQuery, useQueryClient } from \"@tanstack/react-query\";\nimport { path } from \"@w6w/sdk\";\nimport { useEmbedClient } from \"../draft/client-context.ts\";\nimport { callableKey } from \"../lib/callable-kind.ts\";\nimport { historyKeys } from \"../lib/history-query.ts\";\nimport { invalidateSavedCallable } from \"../lib/save-invalidation.ts\";\nimport { workflowKey } from \"./workflows.ts\";\n\n/** The Endpoint / Function single-resource keys the revert arm invalidates: the same\n * `callableKey(\"<kind>\", id)` Studio's `repos/endpoints.ts` / `repos/functions.ts` export as\n * `endpointKey` / `functionKey` (byte-identical `[\"endpoint\", id]` / `[\"function\", id]`). */\nconst endpointKey = (id: string) => callableKey(\"endpoint\", id);\nconst functionKey = (id: string) => callableKey(\"function\", id);\n\n/** The three kinds the wire contract's version-history routes exist for — `connection` has none\n * (see `hasVersionHistory`, `../lib/rail-settings.ts`). */\nexport type VersionsKind = \"function\" | \"workflow\" | \"endpoint\";\n\n/** `<coll>` — the wire contract's own path segment for each kind, every one of the three arms\n * named explicitly (never derived by string pluralization), mirroring `specCollectionForKind`'s\n * own reasoning (`../lib/rail-settings.ts:69`): a typo'd suffix rule would silently send one\n * kind's requests at another kind's collection. */\nconst COLLECTION_PATH: Record<VersionsKind, \"functions\" | \"workflows\" | \"endpoints\"> = {\n function: \"functions\",\n workflow: \"workflows\",\n endpoint: \"endpoints\",\n};\n\n/** One row of `GET /<coll>/:id/versions`'s `versions` array — newest first, per the wire contract. */\nexport interface VersionSummary {\n versionNumber: number;\n createdAt: string;\n createdBy: string | null;\n isCurrentPublished: boolean;\n}\n\n/** `GET /<coll>/:id/versions`'s full 200 body. */\nexport interface VersionsEnvelope {\n enabled: boolean;\n currentPublishedVersion: number | null;\n versions: VersionSummary[];\n}\n\n/** `GET /<coll>/:id/versions/:n`'s `version` field — `definition` is the redacted stored\n * definition for THIS query; {@link useRevertMutation} is what posts a version's definition\n * back onto the live resource, and {@link useInvokeVersionMutation} is what runs it. */\nexport interface VersionDetail {\n versionNumber: number;\n createdAt: string;\n createdBy: string | null;\n isCurrentPublished: boolean;\n definition: Record<string, unknown>;\n}\n\n/** `POST /<coll>/:id/publish`'s 200 body. */\nexport interface PublishResult {\n version: {\n kind: string;\n callableId: string;\n versionNumber: number;\n createdAt: string;\n createdBy: string | null;\n };\n currentPublishedVersion: number;\n}\n\n/** `POST /<coll>/:id/versions/:n/revert`'s 200 body. */\nexport interface RevertResult {\n reverted: {\n kind: string;\n callableId: string;\n versionNumber: number;\n };\n}\n\n/** `<coll>` per kind ends its live invoke/run route in `/invoke` (Function, Endpoint) or `/run`\n * (Workflow, matching that kind's existing unversioned route) — every arm named explicitly\n * (never derived by suffix rule), mirroring `COLLECTION_PATH`'s own reasoning above: a derived\n * rule would silently send one kind's requests at the wrong verb. */\nconst VERSION_INVOKE_VERB: Record<VersionsKind, \"invoke\" | \"run\"> = {\n function: \"invoke\",\n endpoint: \"invoke\",\n workflow: \"run\",\n};\n\nexport function versionsKey(kind: VersionsKind | null, id: string) {\n return [\"versions\", kind, id] as const;\n}\n\nexport function versionKey(kind: VersionsKind | null, id: string, versionNumber: number | null) {\n return [\"version\", kind, id, versionNumber] as const;\n}\n\n/**\n * `GET /<collection>/:id/versions`. Never fires on mount — `enabled` is the caller's own flag\n * (the Settings panel's History-open state, or `WorkflowsPage.tsx`'s own editor-open gate), ANDed\n * with `kind !== null` and `id !== \"\"`, exactly `useSpecQuery`'s shape (`spec-export.ts:45-57`).\n */\nexport function useVersionsQuery(kind: VersionsKind | null, id: string, enabled: boolean) {\n const apiClient = useEmbedClient();\n return useQuery({\n queryKey: versionsKey(kind, id),\n queryFn: async (): Promise<VersionsEnvelope> => {\n switch (kind as VersionsKind) {\n case \"workflow\":\n return await apiClient.workflows.listVersions(id);\n case \"function\":\n return await apiClient.functions.listVersions(id);\n case \"endpoint\": {\n // R-5: no SDK method for endpoint versions.\n const res = await apiClient.request<VersionsEnvelope>({\n method: \"GET\",\n path: path`/${COLLECTION_PATH.endpoint}/${id}/versions`,\n });\n return res.body;\n }\n }\n },\n enabled: enabled && kind !== null && id !== \"\",\n });\n}\n\n/**\n * `GET /<collection>/:id/versions/:n`. Same gating shape as {@link useVersionsQuery}, plus\n * `versionNumber !== null` — the modal opens this only once a row has been clicked.\n */\nexport function useVersionQuery(\n kind: VersionsKind | null,\n id: string,\n versionNumber: number | null,\n enabled: boolean,\n) {\n const apiClient = useEmbedClient();\n return useQuery({\n queryKey: versionKey(kind, id, versionNumber),\n queryFn: async (): Promise<VersionDetail> => {\n // The SDK's `getVersion` already unwraps the `{ version }` envelope.\n const n = versionNumber as number;\n switch (kind as VersionsKind) {\n case \"workflow\":\n return (await apiClient.workflows.getVersion(id, n)) as VersionDetail;\n case \"function\":\n return (await apiClient.functions.getVersion(id, n)) as VersionDetail;\n case \"endpoint\": {\n // R-5: no SDK method for endpoint versions.\n const res = await apiClient.request<{ version: VersionDetail }>({\n method: \"GET\",\n path: path`/${COLLECTION_PATH.endpoint}/${id}/versions/${String(n)}`,\n });\n return res.body.version;\n }\n }\n },\n enabled: enabled && kind !== null && id !== \"\" && versionNumber !== null,\n });\n}\n\n/**\n * `POST /<collection>/:id/publish`. `kind` is fixed per hook instance — the caller already knows\n * which kind it is publishing (the rail's `ctx.kind`, or `WorkflowsPage.tsx`'s hardcoded\n * `\"workflow\"`) — and `mutate(id)` supplies the resource. `onSuccess` invalidates the SAME\n * `[\"versions\", kind, id]` key {@link useVersionsQuery} reads, so the panel's published pointer\n * and version list are fresh without a reload (A3), mirroring `useSaveFunctionMutation`'s\n * `onSuccess` shape (`./functions.ts`).\n */\nexport function usePublishMutation(kind: VersionsKind) {\n const apiClient = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (id: string): Promise<PublishResult> => {\n switch (kind) {\n case \"workflow\":\n return await apiClient.workflows.publish(id);\n case \"function\":\n return await apiClient.functions.publish(id);\n case \"endpoint\": {\n // R-5: no SDK method for endpoint versions.\n const res = await apiClient.request<PublishResult>({\n method: \"POST\",\n path: path`/${COLLECTION_PATH.endpoint}/${id}/publish`,\n });\n return res.body;\n }\n }\n },\n onSuccess: (_result, id) => {\n return qc.invalidateQueries({ queryKey: versionsKey(kind, id) });\n },\n });\n}\n\n/**\n * `POST /<collection>/:id/{enable,disable}`. One mutation for both — the wire contract is two\n * routes distinguished only by which one is called, so `vars.enabled` picks the path segment\n * rather than this module carrying two near-identical mutations. `onSuccess` invalidates the same\n * key {@link usePublishMutation} does, for the same reason.\n */\nexport function useSetEnabledMutation(kind: VersionsKind) {\n const apiClient = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: { id: string; enabled: boolean }): Promise<{ enabled: boolean }> => {\n // The SDK's `enable`/`disable` return void; the hook's result stays `{ enabled }`.\n switch (kind) {\n case \"workflow\":\n if (vars.enabled) await apiClient.workflows.enable(vars.id);\n else await apiClient.workflows.disable(vars.id);\n return { enabled: vars.enabled };\n case \"function\":\n if (vars.enabled) await apiClient.functions.enable(vars.id);\n else await apiClient.functions.disable(vars.id);\n return { enabled: vars.enabled };\n case \"endpoint\": {\n // R-5: no SDK method for endpoint versions.\n const res = await apiClient.request<{ enabled: boolean }>({\n method: \"POST\",\n path: path`/${COLLECTION_PATH.endpoint}/${vars.id}/${vars.enabled ? \"enable\" : \"disable\"}`,\n });\n return res.body;\n }\n }\n },\n onSuccess: (_result, vars) => {\n qc.invalidateQueries({ queryKey: versionsKey(kind, vars.id) });\n },\n });\n}\n\n/**\n * `POST /<collection>/:id/versions/:n/revert`, no body — overwrites the LIVE resource's\n * `definition` with the archived version's content, preserving its `key`/address (HITL-4's\n * pinned default; see the module docblock). This is the first mutation in this family that\n * changes `definition` rather than merely appending to or flipping a flag on the version history\n * (`usePublishMutation`/`useSetEnabledMutation` above do neither), so `onSuccess` invalidates\n * BOTH `versionsKey(kind, id)` (the same key those two invalidate) AND the kind's own\n * definition-edit key — via the shared `invalidateSavedCallable` helper\n * `useSaveFunctionMutation`/`useSaveEndpointMutation` already route through\n * (`../lib/save-invalidation.ts`) — or the page a user reverted FROM keeps showing the\n * pre-revert draft until a manual reload. The definition key is picked by a `switch` naming all\n * three arms explicitly, with no `default:` — the same reasoning `COLLECTION_PATH`'s own docblock\n * gives: a derived rule would silently send one kind at another kind's key.\n */\nexport function useRevertMutation(kind: VersionsKind) {\n const apiClient = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: { id: string; versionNumber: number }): Promise<RevertResult> => {\n // The SDK's `revert` unwraps `{ reverted }`; the hook re-wraps it to keep its result shape.\n switch (kind) {\n case \"workflow\":\n return { reverted: await apiClient.workflows.revert(vars.id, vars.versionNumber) };\n case \"function\":\n return { reverted: await apiClient.functions.revert(vars.id, vars.versionNumber) };\n case \"endpoint\": {\n // R-5: no SDK method for endpoint versions.\n const res = await apiClient.request<RevertResult>({\n method: \"POST\",\n path: path`/${COLLECTION_PATH.endpoint}/${vars.id}/versions/${String(vars.versionNumber)}/revert`,\n });\n return res.body;\n }\n }\n },\n onSuccess: (_result, vars) => {\n let definitionKey: readonly unknown[];\n switch (kind) {\n case \"function\":\n definitionKey = functionKey(vars.id);\n break;\n case \"workflow\":\n definitionKey = workflowKey(vars.id);\n break;\n case \"endpoint\":\n definitionKey = endpointKey(vars.id);\n break;\n }\n invalidateSavedCallable(qc, versionsKey(kind, vars.id), definitionKey);\n },\n });\n}\n\n/**\n * `POST /<collection>/:id/versions/:n/{invoke,run}`, an EMPTY JSON body — identical to that\n * kind's unversioned invoke/run route's success body, except the requested version's OWN\n * `impl`/definition runs instead of the live one (T5.3.1's wire contract table). Unlike\n * {@link useRevertMutation}, invoking changes no resource state, so it invalidates History ONLY\n * (`onSettled`, `historyKeys.root` — a version run is a run, failed ones included, like every other\n * run path) and no resource query — the caller (`VersionHistoryModal`) renders the mutation's own `data`/`error` state\n * directly, and that state is naturally cleared whenever the modal remounts for a different\n * version (`SettingsTool.tsx`'s `openVersion` gate fully unmounts/remounts it, never leaves it\n * mounted across a prop change).\n */\nexport function useInvokeVersionMutation(kind: VersionsKind) {\n const apiClient = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: {\n id: string;\n versionNumber: number;\n }): Promise<Record<string, unknown>> => {\n // The workflow arm moves to `workflows.runVersion`. The FUNCTION arm (F-P4 / F-6) and the\n // ENDPOINT arm (R-5) stay on `request()`: this hook's caller renders the raw invocation\n // frame, and `functions.runVersion` unwraps the output like `functions.run` — it would drop\n // the frame. The workflow arm returns only `{ runId, status }`, as the raw body did.\n if (kind === \"workflow\") {\n const run = await apiClient.workflows.runVersion(vars.id, vars.versionNumber, {});\n // Project back to the server's own run-start body: the SDK adds `steps`/`terminal`/\n // `httpStatus`, and `VersionHistoryModal` prints this value verbatim as JSON.\n return { runId: run.runId, status: run.status };\n }\n const res = await apiClient.request<Record<string, unknown>>({\n method: \"POST\",\n path: path`/${COLLECTION_PATH[kind]}/${vars.id}/versions/${String(vars.versionNumber)}/${VERSION_INVOKE_VERB[kind]}`,\n body: {},\n });\n return res.body;\n },\n onSettled: () => qc.invalidateQueries({ queryKey: historyKeys.root }),\n });\n}\n","/**\n * The `constants` domain repo — account-level, read-only values set by an\n * administrator and referenced as `{{ const.<name> }}`. There is no write\n * route; the server derives the account from the token.\n */\nimport { useQuery } from \"@tanstack/react-query\";\nimport { useEmbedClient } from \"../draft/client-context.ts\";\n\nexport interface Constant {\n name: string;\n type: \"string\" | \"number\" | \"boolean\" | \"json\";\n value: unknown;\n description: string;\n /** Computed by the server (e.g. `account_id`), not stored. */\n derived: boolean;\n}\n\n/** Query key for the constants list. */\nexport function constantsKey() {\n return [\"constants\"] as const;\n}\n\n/** The account's constants (read-only). */\nexport function useConstantsQuery() {\n const apiClient = useEmbedClient();\n return useQuery({\n queryKey: constantsKey(),\n queryFn: async () => {\n const res = await apiClient.request<{ constants: Constant[] }>({\n method: \"GET\",\n path: \"/constants\",\n });\n return res.body.constants;\n },\n });\n}\n","/**\n * The `/<collection>/:id/spec` export repo (T3.3.1) — the Settings rail's Export\n * button. A NEW file, deliberately kept out of `repos/functions.ts` /\n * `repos/endpoints.ts` (T3.1.1 owns both), exactly as T3.2.1 put `/spec/import` in\n * its own `repos/spec-import.ts` for the same reason — the two nodes never\n * collide on the same file.\n *\n * **Goes through `W6WClient.request<T>()`, never `apiClient.console.*`.** There\n * is no SDK method for this route, exactly as `repos/spec-import.ts`'s own\n * docblock records for the sibling `/spec/import` route.\n *\n * `useSpecQuery` is gated on the caller's `enabled` flag (the export modal's own\n * open state) AND `collection !== null` — never on `ctx.kind` alone, and never\n * on mount: the contract pins that opening the Settings panel must issue ZERO\n * `/spec` requests, and exactly one fires per Export click.\n */\nimport { useQuery } from \"@tanstack/react-query\";\nimport { path } from \"@w6w/sdk\";\nimport { useEmbedClient } from \"../draft/client-context.ts\";\n\n/** The collections that carry a `/spec` export route — `specCollectionForKind`\n * (`../lib/rail-settings.ts`) is the sole producer of this type's values. */\nexport type SpecCollection = \"functions\" | \"endpoints\" | \"workflows\";\n\n/**\n * Mirrors T2.1.1's `SpecDocument`, also mirrored by `repos/spec-import.ts`'s\n * `SpecImportDocument` for the sibling import route: the portable document a\n * `GET /<kind>/:id/spec` export produces. Not a bare `FunctionDef`/`EndpointDef`\n * — `id` is deleted server-side (`admin/spec.ts:96-108`) and connection/var\n * references ride as re-bindable `rebind` entries, never live ids.\n */\nexport interface SpecDocument {\n specVersion: string;\n kind: \"function\" | \"endpoint\" | \"workflow\";\n callable: Record<string, unknown>;\n rebind: unknown[];\n}\n\n/**\n * `GET /<collection>/:id/spec`. `collection` is `null` for a kind the Export\n * button never renders on (`specCollectionForKind`'s `connection`\n * arm) — passing `null` disables the query regardless of `enabled`, so a\n * caller need not re-derive that guard itself.\n */\nexport function useSpecQuery(collection: SpecCollection | null, id: string, enabled: boolean) {\n const apiClient = useEmbedClient();\n return useQuery({\n queryKey: [\"spec\", collection, id],\n queryFn: async () => {\n const res = await apiClient.request<{ spec: SpecDocument }>({\n method: \"GET\",\n path: path`/${collection as SpecCollection}/${id}/spec`,\n });\n return res.body.spec;\n },\n enabled: enabled && collection !== null,\n });\n}\n"],"names":["endpointKey","id","callableKey","functionKey","COLLECTION_PATH","VERSION_INVOKE_VERB","versionsKey","kind","versionKey","versionNumber","useVersionsQuery","enabled","apiClient","useEmbedClient","useQuery","path","useVersionQuery","n","usePublishMutation","qc","useQueryClient","useMutation","_result","useSetEnabledMutation","vars","useRevertMutation","definitionKey","workflowKey","invalidateSavedCallable","useInvokeVersionMutation","run","historyKeys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SAAOC,EAAS;AAAA,IACd,UAAU,CAAC,QAAQqB,GAAYlC,CAAE;AAAA,IACjC,SAAS,aACK,MAAMW,EAAU,QAAgC;AAAA,MAC1D,QAAQ;AAAA,MACR,MAAMG,KAAQoB,CAA4B,IAAIlC,CAAE;AAAA,IAAA,CACjD,GACU,KAAK;AAAA,IAElB,SAASU,KAAWwB,MAAe;AAAA,EAAA,CACpC;AACH;"}
|
|
@@ -99,9 +99,9 @@ function P(e, t) {
|
|
|
99
99
|
});
|
|
100
100
|
}
|
|
101
101
|
export {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
102
|
+
M as a,
|
|
103
|
+
K as b,
|
|
104
|
+
Q as c,
|
|
105
105
|
l as d,
|
|
106
106
|
a as e,
|
|
107
107
|
y as f,
|
|
@@ -111,6 +111,6 @@ export {
|
|
|
111
111
|
j,
|
|
112
112
|
F as k,
|
|
113
113
|
D as l,
|
|
114
|
-
|
|
114
|
+
P as u
|
|
115
115
|
};
|
|
116
|
-
//# sourceMappingURL=spec-import-
|
|
116
|
+
//# sourceMappingURL=spec-import-0B6oUewa.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spec-import-SWOonsNr.js","sources":["../src/repos/documents.ts","../src/repos/spec-import.ts"],"sourcesContent":["/**\n * The `documents` domain repo — wraps `@w6w/sdk`'s `client.documents.*` in\n * react-query (HITL-6). `QueryClientProvider` (`main.tsx`) stays the actual\n * cache; this module only centralizes the query-key factory and the\n * `queryFn`/`mutationFn` pairs so every page reads documents the same way.\n *\n * Documents are project-scoped (`documents.ts`'s `DocumentOptions.project`);\n * every mutation here invalidates the unscoped `[\"documents\"]` key, which\n * prefix-matches every project-scoped query key produced by\n * {@linkcode documentsKey} — the same invalidation shape `DocumentsPage.tsx`\n * used before this migration.\n */\nimport { useMutation, useQuery, useQueryClient } from \"@tanstack/react-query\";\nimport { path, type Doc, type DocumentCreateInput, type DocumentPatch } from \"@w6w/sdk\";\nimport { useEmbedClient } from \"../draft/client-context.ts\";\n\n/**\n * T1.1.1's wire shape for one document, pinned here ahead of that node\n * merging (this node is dispatched speculatively against it — see this\n * task's contract). `shared` and the six `source*`/`syncedAt` fields are all\n * additive over the SDK's own `Doc`, so a locally-created document simply\n * carries them as `null` (or `false` for `shared`) rather than omitting\n * them. Do not rename a field — the server produces these names verbatim.\n */\nexport interface DocWithProvenance extends Doc {\n shared: boolean;\n /** \"owner/name\" of the bound repository this document was pulled from. */\n sourceRepo: string | null;\n /** Repo-relative file path the document was pulled from. */\n sourcePath: string | null;\n /** The pulled file's content hash — NOT a commit SHA. */\n sourceSha: string | null;\n /** The repository's HEAD commit SHA at pull time — NOT a content hash. */\n sourceRefSha: string | null;\n /** Web link to the file; may be absent even when the rest of provenance is set. */\n sourceUrl: string | null;\n /** ISO-8601. Stamped at the document's last actual change, not at every sync. */\n syncedAt: string | null;\n}\n\n/**\n * Which provenance state `DocumentDetailPage.tsx`'s \"Source\" card should\n * render for `doc`. `shared` (not `sourceRepo`) is the gate: a shared\n * document whose provenance columns haven't been stamped yet (any document\n * synced before this feature shipped, until its next real-content sync —\n * tier-1 \"unchanged\" syncs never restamp provenance) is still shared, and\n * must say so, distinct from a genuinely private document.\n *\n * - `\"private\"` — `doc.shared` is false. No card.\n * - `\"pending\"` — shared, but `sourceRepo` hasn't been stamped yet.\n * - `\"synced\"` — shared, with full provenance available.\n */\nexport function documentProvenanceState(doc: DocWithProvenance): \"private\" | \"pending\" | \"synced\" {\n if (!doc.shared) return \"private\";\n return doc.sourceRepo == null ? \"pending\" : \"synced\";\n}\n\n/** Query key for a documents list, optionally scoped to a project. */\nexport function documentsKey(projectId?: string) {\n return [\"documents\", projectId] as const;\n}\n\n/**\n * Query key for a single document, scoped to a project (mirrors\n * {@linkcode useDocumentsQuery}'s fix at :72-79/:80-87 below — `projectId`\n * belongs in the key itself, not just the `queryFn`, so a render where the\n * key was cached under `projectId === undefined` genuinely changes key once\n * `ProjectContext` resolves the real one, instead of reusing the same cache\n * entry — and its `retry: false` wrong-project 404 — forever). Still sits\n * under the bare `[\"documents\"]` prefix every mutation below invalidates, so\n * an edit/delete refreshes this page too — `\"detail\"` keeps it from\n * colliding with {@linkcode documentsKey}'s own `[\"documents\", projectId]`\n * shape.\n */\nexport function documentKey(id: string, projectId?: string) {\n return [\"documents\", \"detail\", id, projectId] as const;\n}\n\n/**\n * A single document by id, cast to {@link DocWithProvenance} (D-5): the SDK's\n * `Doc` doesn't model T1.1.1's provenance fields yet, and this repo is not\n * the place to fork or extend `@w6w/sdk` (D-4). The `project` option is\n * passed exactly as {@linkcode useDocumentsQuery} passes it — a document in a\n * non-default project 404s without it. `enabled` defaults `true` to preserve\n * that unscoped fallback for a caller that genuinely wants it — same as\n * {@linkcode useDocumentsQuery}'s own `enabled` doc comment below — a\n * project-scoped page should instead pass `enabled: projectId != null` so it\n * never queries (and never renders) against the wrong project while\n * `ProjectContext`'s own project list is still resolving.\n */\nexport function useDocumentQuery(id: string, projectId?: string, enabled = true) {\n const apiClient = useEmbedClient();\n return useQuery({\n queryKey: documentKey(id, projectId),\n queryFn: async () =>\n (await apiClient.documents.get(id, { project: projectId })) as DocWithProvenance,\n enabled,\n });\n}\n\n/**\n * The current project's documents (or the tenant default when unscoped).\n * `enabled` defaults `true` to preserve that unscoped fallback for a caller\n * that genuinely wants it — a project-scoped page should instead pass\n * `enabled: projectId != null` so it never queries (and never renders)\n * against the wrong project while `ProjectContext`'s own project list is\n * still resolving.\n */\nexport function useDocumentsQuery(projectId?: string, enabled = true) {\n const apiClient = useEmbedClient();\n return useQuery({\n queryKey: documentsKey(projectId),\n // Cast to DocWithProvenance[], same as useDocumentQuery above: the wire\n // response already carries `shared`/`source*`/`syncedAt` (repo.list()\n // serializes every document the same way repo.get() does), but the SDK's\n // own `Doc` type doesn't declare them yet (D-5). Without this cast,\n // DocumentsPage.tsx's list rows have no type-visible way to branch on\n // `d.shared` the way DocumentDetailPage.tsx already does.\n queryFn: async () =>\n (await apiClient.documents.list({ project: projectId })) as DocWithProvenance[],\n enabled,\n });\n}\n\nexport function useCreateDocumentMutation() {\n const apiClient = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (vars: { input: DocumentCreateInput; project?: string }) =>\n apiClient.documents.create(vars.input, { project: vars.project }),\n onSuccess: () => qc.invalidateQueries({ queryKey: [\"documents\"] }),\n });\n}\n\nexport function useUpdateDocumentMutation() {\n const apiClient = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (vars: { id: string; patch: DocumentPatch; project?: string }) =>\n apiClient.documents.update(vars.id, vars.patch, { project: vars.project }),\n onSuccess: () => qc.invalidateQueries({ queryKey: [\"documents\"] }),\n });\n}\n\nexport function useDeleteDocumentMutation() {\n const apiClient = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (vars: { id: string; project?: string }) =>\n apiClient.documents.delete(vars.id, { project: vars.project }),\n onSuccess: () => qc.invalidateQueries({ queryKey: [\"documents\"] }),\n });\n}\n\n/**\n * Re-pulls a shared document from its bound repository (\"Sync\" button, T2.1.4)\n * — `POST /documents/:id/sync` (T3.1.1). No SDK method exists for this route\n * yet (D-4/D-5), so this goes through `apiClient.request()` directly, same\n * escape hatch `repo-sync.ts`'s `useSyncRepoNowMutation` uses. The document\n * routes are project-scoped by QUERY param, not a path segment (unlike\n * `repo-binding`'s `/projects/:id/...` shape), so `project` travels in\n * `query`, mirroring {@linkcode useDocumentQuery}'s own `{ project: … }` use.\n */\nexport function useSyncDocumentMutation() {\n const apiClient = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (vars: { id: string; project?: string }) =>\n apiClient.request<{ document: DocWithProvenance }>({\n method: \"POST\",\n path: path`/documents/${vars.id}/sync`,\n query: { project: vars.project },\n }),\n onSuccess: () => qc.invalidateQueries({ queryKey: [\"documents\"] }),\n });\n}\n","/**\n * The `/spec/import` repo (T3.2.1). A NEW file, deliberately kept out of\n * `repos/functions.ts` / `repos/endpoints.ts` (T3.1.1 owns both) so the two\n * nodes never collide on the same file.\n *\n * **Every operation here goes through `W6WClient.request<T>()`, never\n * `apiClient.console.*`.** `T2.1.2`'s `inputs.touch` has no\n * `packages/wrappers` entry — there is no SDK method for this route — so\n * `request()` is the client's public escape hatch, exactly as\n * `repos/vars.ts`'s own docblock explains for the same reason.\n *\n * The posted `document` is forwarded to the server as-is (spread, never edited):\n * this module adds only `project` (and, on import, `selections`) beside it, validates nothing, and — this is the mechanism pin note 1\n * of the contract states from the side a wrong implementation must break —\n * never falls back to the sibling whole-definition save mutation\n * `FunctionIdentityModal.tsx` uses, on any response. `/spec/import` is where\n * the server-side sealed-secret walker lives (T2.1.2 §B runs\n * `assertNoSecretEnvelopes` over the WHOLE supplied body before any write);\n * a \"helpful\" fallback to that other write path would route a pasted\n * document straight around that check.\n *\n * T1.2.1 generalizes this over all three kinds: `onSuccess` invalidates the\n * ONE list key the imported document's own kind reads (`result.kind`, which\n * the server always echoes), never an unconditional `functionsKey`. The\n * decision of which key that is lives in `../lib/spec-import-invalidation.ts`\n * (a pure, `node --test`-loadable module). The three list keys are INJECTED by the host\n * (`listKeys`): Studio's `functionsKey`/`endpointsKey` live in its own `repos/callables`.\n */\nimport { useMutation, useQueryClient } from \"@tanstack/react-query\";\nimport { useEmbedClient } from \"../draft/client-context.ts\";\nimport type { PreviewDependency, Selection, SpecDependency } from \"../lib/import-bindings.ts\";\nimport {\n type SpecImportListKeys,\n invalidateImportedCallable,\n} from \"../lib/spec-import-invalidation.ts\";\n\n/**\n * Mirrors `T2.1.1`'s `SpecDocument` (`T2.1.1.contract.md:134-141`): the\n * portable document a `GET /<kind>/:id/spec` export produces and this\n * route consumes. Not a bare `FunctionDef` — connection/var references ride\n * as re-bindable `rebind` entries, never live ids.\n */\nexport interface SpecImportDocument {\n specVersion: string;\n kind: \"function\" | \"endpoint\" | \"workflow\";\n callable: Record<string, unknown>;\n rebind: unknown[];\n}\n\n/** One reference site's outcome (T2.1.2 §E's `SpecImportReferenceReport`). */\nexport interface SpecImportReferenceReport {\n path: string;\n kind: string;\n resolved: boolean;\n /** Present only when `resolved` is `true`. */\n boundTo?: string;\n /** Present only when `resolved` is `false`. */\n reason?: string;\n}\n\n/** The `201` body `POST /spec/import` returns (T2.1.2 §E). */\nexport interface SpecImportResult {\n kind: \"function\" | \"endpoint\" | \"workflow\";\n callable: { id: string; key?: string; name?: string };\n references: SpecImportReferenceReport[];\n dependencies?: ImportDependencyStatus[];\n}\n\n/** IF-1 `POST /spec/preview` result: one entry per dependency, with server options + suggestion. */\nexport interface PreviewResult {\n kind: \"function\" | \"endpoint\" | \"workflow\";\n dependencies: PreviewDependency[];\n references?: SpecImportReferenceReport[];\n}\n\n/** One dependency's outcome in the import result (IF-1 `dependencies` status[]). */\nexport interface ImportDependencyStatus {\n key: string;\n kind?: SpecDependency[\"kind\"];\n name?: string;\n status: \"bound\" | \"created\" | \"unconfigured\" | string;\n boundTo?: string;\n reason?: string;\n}\n\n/** The preview request body: the document plus the host project, sent explicitly. */\nexport function buildPreviewBody(\n document: Record<string, unknown>,\n project: string | undefined,\n): Record<string, unknown> {\n return { ...document, project };\n}\n\n/** The import request body: the preview body plus the FULL selections map (`unconfigured` included). */\nexport function buildImportBody(\n document: Record<string, unknown>,\n project: string | undefined,\n selections: Record<string, Selection>,\n): Record<string, unknown> {\n return { ...buildPreviewBody(document, project), selections };\n}\n\n/**\n * `POST /spec/preview` (IF-1). Read-only on the server; a failure rejects the mutation and the\n * caller blocks Create — there is NO fallback to posting the document verbatim to `/spec/import`.\n */\nexport function useSpecPreviewMutation(project: string | undefined) {\n const apiClient = useEmbedClient();\n return useMutation({\n mutationFn: async (document: Record<string, unknown>) => {\n const res = await apiClient.request<PreviewResult>({\n method: \"POST\",\n path: \"/spec/preview\",\n body: buildPreviewBody(document, project),\n });\n return res.body;\n },\n });\n}\n\n/**\n * `POST /spec/import`. Success is always `201` — including a partially\n * resolved import (T2.1.2 §E: \"report, never fail silently\"). This mutation\n * resolves on ANY `201`; branching on `references.every(r => r.resolved)` is\n * the caller's job (A5), never this repo's.\n *\n * `project` is the caller's current project — only the workflow arm reads it\n * (`listKeys.workflowsKey(project)`), but every caller passes it uniformly rather than branching on kind itself; see\n * `../lib/spec-import-invalidation.ts` for why the key differs by kind.\n */\nexport function useImportSpecMutation(project: string | undefined, listKeys: SpecImportListKeys) {\n const apiClient = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (input: {\n document: Record<string, unknown>;\n selections: Record<string, Selection>;\n }) => {\n const res = await apiClient.request<SpecImportResult>({\n method: \"POST\",\n path: \"/spec/import\",\n body: buildImportBody(input.document, project, input.selections),\n });\n return res.body;\n },\n // A row exists in every `201` outcome (T2.1.2 §E creates it even when\n // some references stayed unresolved), so the list is stale either way —\n // but ONLY the list the imported kind actually belongs to (AC-3): the\n // unconditional `functionsKey` this used to invalidate left an imported\n // Endpoint or Workflow's own list stale while pointlessly invalidating\n // Functions.\n onSuccess: (result) => invalidateImportedCallable(qc, result.kind, listKeys, project),\n });\n}\n"],"names":["documentProvenanceState","doc","documentsKey","projectId","documentKey","id","useDocumentQuery","enabled","apiClient","useEmbedClient","useQuery","useDocumentsQuery","useCreateDocumentMutation","qc","useQueryClient","useMutation","vars","useUpdateDocumentMutation","useDeleteDocumentMutation","useSyncDocumentMutation","path","buildPreviewBody","document","project","buildImportBody","selections","useSpecPreviewMutation","useImportSpecMutation","listKeys","input","result","invalidateImportedCallable"],"mappings":";;;;AAoDO,SAASA,EAAwBC,GAA0D;AAChG,SAAKA,EAAI,SACFA,EAAI,cAAc,OAAO,YAAY,WADpB;AAE1B;AAGO,SAASC,EAAaC,GAAoB;AAC/C,SAAO,CAAC,aAAaA,CAAS;AAChC;AAcO,SAASC,EAAYC,GAAYF,GAAoB;AAC1D,SAAO,CAAC,aAAa,UAAUE,GAAIF,CAAS;AAC9C;AAcO,SAASG,EAAiBD,GAAYF,GAAoBI,IAAU,IAAM;AAC/E,QAAMC,IAAYC,EAAA;AAClB,SAAO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
+
{"version":3,"file":"spec-import-0B6oUewa.js","sources":["../src/repos/documents.ts","../src/repos/spec-import.ts"],"sourcesContent":["/**\n * The `documents` domain repo — wraps `@w6w/sdk`'s `client.documents.*` in\n * react-query (HITL-6). `QueryClientProvider` (`main.tsx`) stays the actual\n * cache; this module only centralizes the query-key factory and the\n * `queryFn`/`mutationFn` pairs so every page reads documents the same way.\n *\n * Documents are project-scoped (`documents.ts`'s `DocumentOptions.project`);\n * every mutation here invalidates the unscoped `[\"documents\"]` key, which\n * prefix-matches every project-scoped query key produced by\n * {@linkcode documentsKey} — the same invalidation shape `DocumentsPage.tsx`\n * used before this migration.\n */\nimport { useMutation, useQuery, useQueryClient } from \"@tanstack/react-query\";\nimport { path, type Doc, type DocumentCreateInput, type DocumentPatch } from \"@w6w/sdk\";\nimport { useEmbedClient } from \"../draft/client-context.ts\";\n\n/**\n * T1.1.1's wire shape for one document, pinned here ahead of that node\n * merging (this node is dispatched speculatively against it — see this\n * task's contract). `shared` and the six `source*`/`syncedAt` fields are all\n * additive over the SDK's own `Doc`, so a locally-created document simply\n * carries them as `null` (or `false` for `shared`) rather than omitting\n * them. Do not rename a field — the server produces these names verbatim.\n */\nexport interface DocWithProvenance extends Doc {\n shared: boolean;\n /** \"owner/name\" of the bound repository this document was pulled from. */\n sourceRepo: string | null;\n /** Repo-relative file path the document was pulled from. */\n sourcePath: string | null;\n /** The pulled file's content hash — NOT a commit SHA. */\n sourceSha: string | null;\n /** The repository's HEAD commit SHA at pull time — NOT a content hash. */\n sourceRefSha: string | null;\n /** Web link to the file; may be absent even when the rest of provenance is set. */\n sourceUrl: string | null;\n /** ISO-8601. Stamped at the document's last actual change, not at every sync. */\n syncedAt: string | null;\n}\n\n/**\n * Which provenance state `DocumentDetailPage.tsx`'s \"Source\" card should\n * render for `doc`. `shared` (not `sourceRepo`) is the gate: a shared\n * document whose provenance columns haven't been stamped yet (any document\n * synced before this feature shipped, until its next real-content sync —\n * tier-1 \"unchanged\" syncs never restamp provenance) is still shared, and\n * must say so, distinct from a genuinely private document.\n *\n * - `\"private\"` — `doc.shared` is false. No card.\n * - `\"pending\"` — shared, but `sourceRepo` hasn't been stamped yet.\n * - `\"synced\"` — shared, with full provenance available.\n */\nexport function documentProvenanceState(doc: DocWithProvenance): \"private\" | \"pending\" | \"synced\" {\n if (!doc.shared) return \"private\";\n return doc.sourceRepo == null ? \"pending\" : \"synced\";\n}\n\n/** Query key for a documents list, optionally scoped to a project. */\nexport function documentsKey(projectId?: string) {\n return [\"documents\", projectId] as const;\n}\n\n/**\n * Query key for a single document, scoped to a project (mirrors\n * {@linkcode useDocumentsQuery}'s fix at :72-79/:80-87 below — `projectId`\n * belongs in the key itself, not just the `queryFn`, so a render where the\n * key was cached under `projectId === undefined` genuinely changes key once\n * `ProjectContext` resolves the real one, instead of reusing the same cache\n * entry — and its `retry: false` wrong-project 404 — forever). Still sits\n * under the bare `[\"documents\"]` prefix every mutation below invalidates, so\n * an edit/delete refreshes this page too — `\"detail\"` keeps it from\n * colliding with {@linkcode documentsKey}'s own `[\"documents\", projectId]`\n * shape.\n */\nexport function documentKey(id: string, projectId?: string) {\n return [\"documents\", \"detail\", id, projectId] as const;\n}\n\n/**\n * A single document by id, cast to {@link DocWithProvenance} (D-5): the SDK's\n * `Doc` doesn't model T1.1.1's provenance fields yet, and this repo is not\n * the place to fork or extend `@w6w/sdk` (D-4). The `project` option is\n * passed exactly as {@linkcode useDocumentsQuery} passes it — a document in a\n * non-default project 404s without it. `enabled` defaults `true` to preserve\n * that unscoped fallback for a caller that genuinely wants it — same as\n * {@linkcode useDocumentsQuery}'s own `enabled` doc comment below — a\n * project-scoped page should instead pass `enabled: projectId != null` so it\n * never queries (and never renders) against the wrong project while\n * `ProjectContext`'s own project list is still resolving.\n */\nexport function useDocumentQuery(id: string, projectId?: string, enabled = true) {\n const apiClient = useEmbedClient();\n return useQuery({\n queryKey: documentKey(id, projectId),\n queryFn: async () =>\n (await apiClient.documents.get(id, { project: projectId })) as DocWithProvenance,\n enabled,\n });\n}\n\n/**\n * The current project's documents (or the tenant default when unscoped).\n * `enabled` defaults `true` to preserve that unscoped fallback for a caller\n * that genuinely wants it — a project-scoped page should instead pass\n * `enabled: projectId != null` so it never queries (and never renders)\n * against the wrong project while `ProjectContext`'s own project list is\n * still resolving.\n */\nexport function useDocumentsQuery(projectId?: string, enabled = true) {\n const apiClient = useEmbedClient();\n return useQuery({\n queryKey: documentsKey(projectId),\n // Cast to DocWithProvenance[], same as useDocumentQuery above: the wire\n // response already carries `shared`/`source*`/`syncedAt` (repo.list()\n // serializes every document the same way repo.get() does), but the SDK's\n // own `Doc` type doesn't declare them yet (D-5). Without this cast,\n // DocumentsPage.tsx's list rows have no type-visible way to branch on\n // `d.shared` the way DocumentDetailPage.tsx already does.\n queryFn: async () =>\n (await apiClient.documents.list({ project: projectId })) as DocWithProvenance[],\n enabled,\n });\n}\n\nexport function useCreateDocumentMutation() {\n const apiClient = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (vars: { input: DocumentCreateInput; project?: string }) =>\n apiClient.documents.create(vars.input, { project: vars.project }),\n onSuccess: () => qc.invalidateQueries({ queryKey: [\"documents\"] }),\n });\n}\n\nexport function useUpdateDocumentMutation() {\n const apiClient = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (vars: { id: string; patch: DocumentPatch; project?: string }) =>\n apiClient.documents.update(vars.id, vars.patch, { project: vars.project }),\n onSuccess: () => qc.invalidateQueries({ queryKey: [\"documents\"] }),\n });\n}\n\nexport function useDeleteDocumentMutation() {\n const apiClient = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (vars: { id: string; project?: string }) =>\n apiClient.documents.delete(vars.id, { project: vars.project }),\n onSuccess: () => qc.invalidateQueries({ queryKey: [\"documents\"] }),\n });\n}\n\n/**\n * Re-pulls a shared document from its bound repository (\"Sync\" button, T2.1.4)\n * — `POST /documents/:id/sync` (T3.1.1). No SDK method exists for this route\n * yet (D-4/D-5), so this goes through `apiClient.request()` directly, same\n * escape hatch `repo-sync.ts`'s `useSyncRepoNowMutation` uses. The document\n * routes are project-scoped by QUERY param, not a path segment (unlike\n * `repo-binding`'s `/projects/:id/...` shape), so `project` travels in\n * `query`, mirroring {@linkcode useDocumentQuery}'s own `{ project: … }` use.\n */\nexport function useSyncDocumentMutation() {\n const apiClient = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (vars: { id: string; project?: string }) =>\n apiClient.request<{ document: DocWithProvenance }>({\n method: \"POST\",\n path: path`/documents/${vars.id}/sync`,\n query: { project: vars.project },\n }),\n onSuccess: () => qc.invalidateQueries({ queryKey: [\"documents\"] }),\n });\n}\n","/**\n * The `/spec/import` repo (T3.2.1). A NEW file, deliberately kept out of\n * `repos/functions.ts` / `repos/endpoints.ts` (T3.1.1 owns both) so the two\n * nodes never collide on the same file.\n *\n * **Every operation here goes through `W6WClient.request<T>()`, never\n * `apiClient.console.*`.** `T2.1.2`'s `inputs.touch` has no\n * `packages/wrappers` entry — there is no SDK method for this route — so\n * `request()` is the client's public escape hatch, exactly as\n * `repos/vars.ts`'s own docblock explains for the same reason.\n *\n * The posted `document` is forwarded to the server as-is (spread, never edited):\n * this module adds only `project` (and, on import, `selections`) beside it, validates nothing, and — this is the mechanism pin note 1\n * of the contract states from the side a wrong implementation must break —\n * never falls back to the sibling whole-definition save mutation\n * `FunctionIdentityModal.tsx` uses, on any response. `/spec/import` is where\n * the server-side sealed-secret walker lives (T2.1.2 §B runs\n * `assertNoSecretEnvelopes` over the WHOLE supplied body before any write);\n * a \"helpful\" fallback to that other write path would route a pasted\n * document straight around that check.\n *\n * T1.2.1 generalizes this over all three kinds: `onSuccess` invalidates the\n * ONE list key the imported document's own kind reads (`result.kind`, which\n * the server always echoes), never an unconditional `functionsKey`. The\n * decision of which key that is lives in `../lib/spec-import-invalidation.ts`\n * (a pure, `node --test`-loadable module). The three list keys are INJECTED by the host\n * (`listKeys`): Studio's `functionsKey`/`endpointsKey` live in its own `repos/callables`.\n */\nimport { useMutation, useQueryClient } from \"@tanstack/react-query\";\nimport { useEmbedClient } from \"../draft/client-context.ts\";\nimport type { PreviewDependency, Selection, SpecDependency } from \"../lib/import-bindings.ts\";\nimport {\n type SpecImportListKeys,\n invalidateImportedCallable,\n} from \"../lib/spec-import-invalidation.ts\";\n\n/**\n * Mirrors `T2.1.1`'s `SpecDocument` (`T2.1.1.contract.md:134-141`): the\n * portable document a `GET /<kind>/:id/spec` export produces and this\n * route consumes. Not a bare `FunctionDef` — connection/var references ride\n * as re-bindable `rebind` entries, never live ids.\n */\nexport interface SpecImportDocument {\n specVersion: string;\n kind: \"function\" | \"endpoint\" | \"workflow\";\n callable: Record<string, unknown>;\n rebind: unknown[];\n}\n\n/** One reference site's outcome (T2.1.2 §E's `SpecImportReferenceReport`). */\nexport interface SpecImportReferenceReport {\n path: string;\n kind: string;\n resolved: boolean;\n /** Present only when `resolved` is `true`. */\n boundTo?: string;\n /** Present only when `resolved` is `false`. */\n reason?: string;\n}\n\n/** The `201` body `POST /spec/import` returns (T2.1.2 §E). */\nexport interface SpecImportResult {\n kind: \"function\" | \"endpoint\" | \"workflow\";\n callable: { id: string; key?: string; name?: string };\n references: SpecImportReferenceReport[];\n dependencies?: ImportDependencyStatus[];\n}\n\n/** IF-1 `POST /spec/preview` result: one entry per dependency, with server options + suggestion. */\nexport interface PreviewResult {\n kind: \"function\" | \"endpoint\" | \"workflow\";\n dependencies: PreviewDependency[];\n references?: SpecImportReferenceReport[];\n}\n\n/** One dependency's outcome in the import result (IF-1 `dependencies` status[]). */\nexport interface ImportDependencyStatus {\n key: string;\n kind?: SpecDependency[\"kind\"];\n name?: string;\n status: \"bound\" | \"created\" | \"unconfigured\" | string;\n boundTo?: string;\n reason?: string;\n}\n\n/** The preview request body: the document plus the host project, sent explicitly. */\nexport function buildPreviewBody(\n document: Record<string, unknown>,\n project: string | undefined,\n): Record<string, unknown> {\n return { ...document, project };\n}\n\n/** The import request body: the preview body plus the FULL selections map (`unconfigured` included). */\nexport function buildImportBody(\n document: Record<string, unknown>,\n project: string | undefined,\n selections: Record<string, Selection>,\n): Record<string, unknown> {\n return { ...buildPreviewBody(document, project), selections };\n}\n\n/**\n * `POST /spec/preview` (IF-1). Read-only on the server; a failure rejects the mutation and the\n * caller blocks Create — there is NO fallback to posting the document verbatim to `/spec/import`.\n */\nexport function useSpecPreviewMutation(project: string | undefined) {\n const apiClient = useEmbedClient();\n return useMutation({\n mutationFn: async (document: Record<string, unknown>) => {\n const res = await apiClient.request<PreviewResult>({\n method: \"POST\",\n path: \"/spec/preview\",\n body: buildPreviewBody(document, project),\n });\n return res.body;\n },\n });\n}\n\n/**\n * `POST /spec/import`. Success is always `201` — including a partially\n * resolved import (T2.1.2 §E: \"report, never fail silently\"). This mutation\n * resolves on ANY `201`; branching on `references.every(r => r.resolved)` is\n * the caller's job (A5), never this repo's.\n *\n * `project` is the caller's current project — only the workflow arm reads it\n * (`listKeys.workflowsKey(project)`), but every caller passes it uniformly rather than branching on kind itself; see\n * `../lib/spec-import-invalidation.ts` for why the key differs by kind.\n */\nexport function useImportSpecMutation(project: string | undefined, listKeys: SpecImportListKeys) {\n const apiClient = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (input: {\n document: Record<string, unknown>;\n selections: Record<string, Selection>;\n }) => {\n const res = await apiClient.request<SpecImportResult>({\n method: \"POST\",\n path: \"/spec/import\",\n body: buildImportBody(input.document, project, input.selections),\n });\n return res.body;\n },\n // A row exists in every `201` outcome (T2.1.2 §E creates it even when\n // some references stayed unresolved), so the list is stale either way —\n // but ONLY the list the imported kind actually belongs to (AC-3): the\n // unconditional `functionsKey` this used to invalidate left an imported\n // Endpoint or Workflow's own list stale while pointlessly invalidating\n // Functions.\n onSuccess: (result) => invalidateImportedCallable(qc, result.kind, listKeys, project),\n });\n}\n"],"names":["documentProvenanceState","doc","documentsKey","projectId","documentKey","id","useDocumentQuery","enabled","apiClient","useEmbedClient","useQuery","useDocumentsQuery","useCreateDocumentMutation","qc","useQueryClient","useMutation","vars","useUpdateDocumentMutation","useDeleteDocumentMutation","useSyncDocumentMutation","path","buildPreviewBody","document","project","buildImportBody","selections","useSpecPreviewMutation","useImportSpecMutation","listKeys","input","result","invalidateImportedCallable"],"mappings":";;;;AAoDO,SAASA,EAAwBC,GAA0D;AAChG,SAAKA,EAAI,SACFA,EAAI,cAAc,OAAO,YAAY,WADpB;AAE1B;AAGO,SAASC,EAAaC,GAAoB;AAC/C,SAAO,CAAC,aAAaA,CAAS;AAChC;AAcO,SAASC,EAAYC,GAAYF,GAAoB;AAC1D,SAAO,CAAC,aAAa,UAAUE,GAAIF,CAAS;AAC9C;AAcO,SAASG,EAAiBD,GAAYF,GAAoBI,IAAU,IAAM;AAC/E,QAAMC,IAAYC,EAAA;AAClB,SAAOC,EAAS;AAAA,IACd,UAAUN,EAAYC,GAAIF,CAAS;AAAA,IACnC,SAAS,YACN,MAAMK,EAAU,UAAU,IAAIH,GAAI,EAAE,SAASF,GAAW;AAAA,IAC3D,SAAAI;AAAA,EAAA,CACD;AACH;AAUO,SAASI,EAAkBR,GAAoBI,IAAU,IAAM;AACpE,QAAMC,IAAYC,EAAA;AAClB,SAAOC,EAAS;AAAA,IACd,UAAUR,EAAaC,CAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAOhC,SAAS,YACN,MAAMK,EAAU,UAAU,KAAK,EAAE,SAASL,GAAW;AAAA,IACxD,SAAAI;AAAA,EAAA,CACD;AACH;AAEO,SAASK,IAA4B;AAC1C,QAAMJ,IAAYC,EAAA,GACZI,IAAKC,EAAA;AACX,SAAOC,EAAY;AAAA,IACjB,YAAY,CAACC,MACXR,EAAU,UAAU,OAAOQ,EAAK,OAAO,EAAE,SAASA,EAAK,QAAA,CAAS;AAAA,IAClE,WAAW,MAAMH,EAAG,kBAAkB,EAAE,UAAU,CAAC,WAAW,EAAA,CAAG;AAAA,EAAA,CAClE;AACH;AAEO,SAASI,IAA4B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