@w6w/embed 0.2.26 → 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-VdYN1QeZ.js → ImportSpecModal-xwTzj4KB.js} +2 -2
- package/dist/{ImportSpecModal-VdYN1QeZ.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-CGKoeSG7.js → WorkflowEditor-CvWkVmFn.js} +2 -2
- package/dist/{WorkflowEditor-CGKoeSG7.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/credentials-4Nf2GfMc.js +212 -0
- package/dist/credentials-4Nf2GfMc.js.map +1 -0
- package/dist/{editor-tools-Brw0cv2F.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 +7 -7
- 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 +16 -16
- package/dist/lib/callable-descriptors.d.ts +1 -1
- package/dist/lib/document-upload.d.ts +8 -0
- package/dist/lists/MyAiKeys.d.ts +5 -0
- package/dist/lists/TagChips.d.ts +4 -0
- package/dist/lists.d.ts +2 -0
- package/dist/lists.mjs +1589 -1166
- 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 +14 -14
- package/dist/repos/index.d.ts +1 -0
- package/dist/repos/models.d.ts +53 -4
- package/dist/repos.mjs +177 -162
- package/dist/repos.mjs.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/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-CMR_wEvx.js +0 -196
- package/dist/credentials-CMR_wEvx.js.map +0 -1
- package/dist/editor-tools-Brw0cv2F.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/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,GAA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ASY,EAAA,GACTI,IAAKC,EAAA;AACX,SAAOC,EAAY;AAAA,IACjB,YAAY,CAAC/B,MAAea,EAAO,OAAO,QAAQb,CAAE;AAAA,IACpD,WAAW,MAAM6B,EAAG,kBAAkB,EAAE,UAAU,CAAC,QAAQ,EAAA,CAAG;AAAA,EAAA,CAC/D;AACH;AAIO,SAASqD,KAA+B;AAC7C,QAAMrE,IAASY,EAAA;AACf,SAAOM,EAAY;AAAA,IACjB,YAAY,CAACC,MAAkCnB,EAAO,OAAO,QAAQ,OAAOmB,CAAK;AAAA,EAAA,CAClF;AACH;AAEO,SAASmD,KAAiC;AAC/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;"}
|
|
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,UAAU,UAAUA,CAAE,GAClDC,IAAwB,CAACC,MACpC,CAAC,UAAU,kBAAkBA,CAAO,GACzBC,IAAiB,MAAM,CAAC,UAAU,QAAQ,GAC1CC,IAAkB,MAAM,CAAC,UAAU,SAAS,GAC5CC,IAAyB,CAACC,MACrC,CAAC,UAAU,mBAAmBA,CAAY,GAC/BC,IAA4B,MAAM,CAAC,UAAU,qBAAqB,GAClEC,IAAsB,CAACC,MAClC,CAAC,UAAU,gBAAgBA,CAAS,GACzBC,IAAmB,MAAM,CAAC,gBAAgB,GAC1CC,IAAqB,MAAM,CAAC,kBAAkB,kBAAkB;AAG7E,e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,YAAY,CAACsD,MAAqBxE,EAAO,OAAO,QAAQ,MAAMwE,CAAQ,GAAG;AAChG;"}
|
|
@@ -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,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,G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R,MAAMY,eAAkBJ,EAAK,EAAE;AAAA,MAC/B,OAAO,EAAE,SAASA,EAAK,QAAA;AAAA,IAAQ,CAChC;AAAA,IACH,WAAW,MAAMH,EAAG,kBAAkB,EAAE,UAAU,CAAC,WAAW,EAAA,CAAG;AAAA,EAAA,CAClE;AACH;ACzFO,SAASQ,EACdC,GACAC,GACyB;AACzB,SAAO,EAAE,GAAGD,GAAU,SAAAC,EAAA;AACxB;AAGO,SAASC,EACdF,GACAC,GACAE,GACyB;AACzB,SAAO,EAAE,GAAGJ,EAAiBC,GAAUC,CAAO,GAAG,YAAAE,EAAA;AACnD;AAMO,SAASC,EAAuBH,GAA6B;AAClE,QAAMf,IAAYC,EAAA;AAClB,SAAOM,EAAY;AAAA,IACjB,YAAY,OAAOO,OACL,MAAMd,EAAU,QAAuB;AAAA,MACjD,QAAQ;AAAA,MACR,MAAM;AAAA,MACN,MAAMa,EAAiBC,GAAUC,CAAO;AAAA,IAAA,CACzC,GACU;AAAA,EACb,CACD;AACH;AAYO,SAASI,EAAsBJ,GAA6BK,GAA8B;AAC/F,QAAMpB,IAAYC,EAAA,GACZI,IAAKC,EAAA;AACX,SAAOC,EAAY;AAAA,IACjB,YAAY,OAAOc,OAIL,MAAMrB,EAAU,QAA0B;AAAA,MACpD,QAAQ;AAAA,MACR,MAAM;AAAA,MACN,MAAMgB,EAAgBK,EAAM,UAAUN,GAASM,EAAM,UAAU;AAAA,IAAA,CAChE,GACU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAQb,WAAW,CAACC,MAAWC,EAA2BlB,GAAIiB,EAAO,MAAMF,GAAUL,CAAO;AAAA,EAAA,CACrF;AACH;"}
|
|
1
|
+
{"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":";;;;A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AOC,EAAY;AAAA,IACjB,YAAY,OAAOc,OAIL,MAAMrB,EAAU,QAA0B;AAAA,MACpD,QAAQ;AAAA,MACR,MAAM;AAAA,MACN,MAAMgB,EAAgBK,EAAM,UAAUN,GAASM,EAAM,UAAU;AAAA,IAAA,CAChE,GACU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAQb,WAAW,CAACC,MAAWC,EAA2BlB,GAAIiB,EAAO,MAAMF,GAAUL,CAAO;AAAA,EAAA,CACrF;AACH;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@w6w/embed",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.27",
|
|
4
4
|
"description": "Embed w6w's managed editor and providers in a host React app.",
|
|
5
5
|
"license": "FSL-1.1-ALv2",
|
|
6
6
|
"repository": {
|
|
@@ -73,10 +73,10 @@
|
|
|
73
73
|
},
|
|
74
74
|
"dependencies": {
|
|
75
75
|
"@tanstack/react-query": "^5.62.7",
|
|
76
|
-
"@w6w/react": "^0.
|
|
77
|
-
"@w6w/sdk": "^0.
|
|
78
|
-
"@w6w/expr": "^0.1.
|
|
79
|
-
"@w6w/ui": "^0.2.
|
|
76
|
+
"@w6w/react": "^0.10.0",
|
|
77
|
+
"@w6w/sdk": "^0.10.0",
|
|
78
|
+
"@w6w/expr": "^0.1.4",
|
|
79
|
+
"@w6w/ui": "^0.2.63",
|
|
80
80
|
"yaml": "^2.4.2"
|
|
81
81
|
},
|
|
82
82
|
"peerDependencies": {
|
package/src/styles.css
CHANGED
|
@@ -1408,3 +1408,26 @@
|
|
|
1408
1408
|
.w6w-embed-root .w6w-list-item-title :not(.tag) + .tag {
|
|
1409
1409
|
margin-left: var(--w6w-sp-1);
|
|
1410
1410
|
}
|
|
1411
|
+
|
|
1412
|
+
/* Keep model names readable inside the settings dialog. */
|
|
1413
|
+
.w6w-embed-root .model-catalog-table {
|
|
1414
|
+
table-layout: fixed;
|
|
1415
|
+
}
|
|
1416
|
+
.w6w-embed-root .model-catalog-identity {
|
|
1417
|
+
display: grid;
|
|
1418
|
+
gap: var(--w6w-sp-1);
|
|
1419
|
+
overflow-wrap: anywhere;
|
|
1420
|
+
}
|
|
1421
|
+
.w6w-embed-root .model-catalog-name {
|
|
1422
|
+
display: flex;
|
|
1423
|
+
flex-wrap: wrap;
|
|
1424
|
+
align-items: center;
|
|
1425
|
+
gap: var(--w6w-sp-2);
|
|
1426
|
+
}
|
|
1427
|
+
.w6w-embed-root .model-catalog-name strong {
|
|
1428
|
+
font-size: var(--w6w-fs-sm);
|
|
1429
|
+
}
|
|
1430
|
+
.w6w-embed-root .model-catalog-limits {
|
|
1431
|
+
display: grid;
|
|
1432
|
+
gap: var(--w6w-sp-1);
|
|
1433
|
+
}
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import { jsxs as a, jsx as t } from "react/jsx-runtime";
|
|
2
|
-
import { ApiError as k } from "@w6w/sdk";
|
|
3
|
-
import { useEnterSubmit as x, JsonEditor as D, YamlEditor as A, CodeEditor as F } from "@w6w/ui";
|
|
4
|
-
import { useState as o } from "react";
|
|
5
|
-
import { M as w } from "./ConfirmModal-Pv2-A_3U.js";
|
|
6
|
-
import { u as K, a as O } from "./spec-import-SWOonsNr.js";
|
|
7
|
-
const P = ["text", "markdown", "yaml", "html", "json"];
|
|
8
|
-
function $(e) {
|
|
9
|
-
var y, N, j, p;
|
|
10
|
-
const r = !!e.initial, [c, S] = o(((y = e.initial) == null ? void 0 : y.key) ?? ""), [i, E] = o(((N = e.initial) == null ? void 0 : N.format) ?? "text"), [l, s] = o(((j = e.initial) == null ? void 0 : j.content) ?? ""), [d, M] = o(((p = e.initial) == null ? void 0 : p.description) ?? ""), [v, m] = o(null), b = K(), g = O(), u = b.isPending || g.isPending;
|
|
11
|
-
function C() {
|
|
12
|
-
if (m(null), e.project == null) {
|
|
13
|
-
m("No project selected: nothing was saved.");
|
|
14
|
-
return;
|
|
15
|
-
}
|
|
16
|
-
const n = {
|
|
17
|
-
onSuccess: () => e.onSaved(),
|
|
18
|
-
onError: (h) => m((h instanceof k, h.message))
|
|
19
|
-
};
|
|
20
|
-
if (e.initial) {
|
|
21
|
-
g.mutate(
|
|
22
|
-
{ id: e.initial.id, patch: { content: l, format: i, description: d }, project: e.project },
|
|
23
|
-
n
|
|
24
|
-
);
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
b.mutate(
|
|
28
|
-
{ input: { key: c.trim(), content: l, format: i, description: d }, project: e.project },
|
|
29
|
-
n
|
|
30
|
-
);
|
|
31
|
-
}
|
|
32
|
-
const f = x(C, { enabled: !!c.trim() && !u });
|
|
33
|
-
return /* @__PURE__ */ a(
|
|
34
|
-
w,
|
|
35
|
-
{
|
|
36
|
-
title: e.initial ? `Edit ${e.initial.key}` : "Add document",
|
|
37
|
-
onClose: e.onClose,
|
|
38
|
-
children: [
|
|
39
|
-
/* @__PURE__ */ a("div", { className: "modal-body", children: [
|
|
40
|
-
/* @__PURE__ */ a("label", { className: "field", children: [
|
|
41
|
-
/* @__PURE__ */ t("span", { children: "Key" }),
|
|
42
|
-
/* @__PURE__ */ t(
|
|
43
|
-
"input",
|
|
44
|
-
{
|
|
45
|
-
type: "text",
|
|
46
|
-
value: c,
|
|
47
|
-
disabled: r,
|
|
48
|
-
onChange: (n) => S(n.target.value),
|
|
49
|
-
placeholder: "e.g. welcome-email",
|
|
50
|
-
...f
|
|
51
|
-
}
|
|
52
|
-
),
|
|
53
|
-
!r && /* @__PURE__ */ t("span", { className: "hint", children: "A unique name to reference this document by." })
|
|
54
|
-
] }),
|
|
55
|
-
/* @__PURE__ */ a("label", { className: "field", children: [
|
|
56
|
-
/* @__PURE__ */ t("span", { children: "Format" }),
|
|
57
|
-
/* @__PURE__ */ t("select", { value: i, onChange: (n) => E(n.target.value), children: P.map((n) => /* @__PURE__ */ t("option", { value: n, children: n }, n)) })
|
|
58
|
-
] }),
|
|
59
|
-
/* @__PURE__ */ a("div", { className: "field", children: [
|
|
60
|
-
/* @__PURE__ */ t("span", { children: "Content" }),
|
|
61
|
-
i === "json" ? /* @__PURE__ */ t(D, { value: l, onChange: s, "aria-label": "Content" }) : i === "yaml" ? /* @__PURE__ */ t(A, { value: l, onChange: s, "aria-label": "Content" }) : /* @__PURE__ */ t(F, { value: l, onChange: s, "aria-label": "Content" })
|
|
62
|
-
] }),
|
|
63
|
-
/* @__PURE__ */ a("label", { className: "field", children: [
|
|
64
|
-
/* @__PURE__ */ t("span", { children: "Description" }),
|
|
65
|
-
/* @__PURE__ */ t(
|
|
66
|
-
"input",
|
|
67
|
-
{
|
|
68
|
-
type: "text",
|
|
69
|
-
value: d,
|
|
70
|
-
onChange: (n) => M(n.target.value),
|
|
71
|
-
placeholder: "Optional",
|
|
72
|
-
...f
|
|
73
|
-
}
|
|
74
|
-
)
|
|
75
|
-
] }),
|
|
76
|
-
v && /* @__PURE__ */ t("div", { className: "result error", children: v })
|
|
77
|
-
] }),
|
|
78
|
-
/* @__PURE__ */ a("div", { className: "modal-actions", children: [
|
|
79
|
-
/* @__PURE__ */ t("button", { type: "button", className: "btn ghost", onClick: e.onClose, children: "Cancel" }),
|
|
80
|
-
/* @__PURE__ */ t("button", { type: "button", className: "btn", disabled: !c.trim() || u, onClick: C, children: u ? "Saving…" : r ? "Save changes" : "Save document" })
|
|
81
|
-
] })
|
|
82
|
-
]
|
|
83
|
-
}
|
|
84
|
-
);
|
|
85
|
-
}
|
|
86
|
-
export {
|
|
87
|
-
$ as D
|
|
88
|
-
};
|
|
89
|
-
//# sourceMappingURL=DocumentFormModal-Br4s8wmi.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"DocumentFormModal-Br4s8wmi.js","sources":["../src/forms/DocumentFormModal.tsx"],"sourcesContent":["/**\n * Create/edit modal for a document (internal: not exported from `@w6w/embed/forms`). Content is\n * stored verbatim in whatever format is selected, with no parsing or validation. The key is\n * immutable once set, so an edit never sends it.\n */\nimport { ApiError } from \"@w6w/sdk\";\nimport type { Doc, DocFormat } from \"@w6w/sdk\";\nimport { CodeEditor, JsonEditor, YamlEditor, useEnterSubmit } from \"@w6w/ui\";\nimport { useState } from \"react\";\nimport { Modal } from \"../chrome/Modal.tsx\";\nimport { useCreateDocumentMutation, useUpdateDocumentMutation } from \"../repos/documents.ts\";\n\nconst FORMATS: readonly DocFormat[] = [\"text\", \"markdown\", \"yaml\", \"html\", \"json\"];\n\nexport function DocumentFormModal(props: {\n initial?: Doc;\n /** The resolved project, or `null` (none yet): a save is refused, never sent project-less. */\n project: string | null;\n onClose: () => void;\n onSaved: () => void;\n}) {\n const isEdit = !!props.initial;\n const [key, setKey] = useState(props.initial?.key ?? \"\");\n const [format, setFormat] = useState<DocFormat>(props.initial?.format ?? \"text\");\n const [content, setContent] = useState(props.initial?.content ?? \"\");\n const [description, setDescription] = useState(props.initial?.description ?? \"\");\n const [error, setError] = useState<string | null>(null);\n\n const createMut = useCreateDocumentMutation();\n const updateMut = useUpdateDocumentMutation();\n const saving = createMut.isPending || updateMut.isPending;\n\n function save() {\n setError(null);\n if (props.project == null) {\n setError(\"No project selected: nothing was saved.\");\n return;\n }\n const onSettled = {\n onSuccess: () => props.onSaved(),\n onError: (e: unknown) => setError(e instanceof ApiError ? e.message : (e as Error).message),\n };\n if (props.initial) {\n updateMut.mutate(\n { id: props.initial.id, patch: { content, format, description }, project: props.project },\n onSettled,\n );\n return;\n }\n createMut.mutate(\n { input: { key: key.trim(), content, format, description }, project: props.project },\n onSettled,\n );\n }\n\n const enterSubmit = useEnterSubmit(save, { enabled: !!key.trim() && !saving });\n\n return (\n <Modal\n title={props.initial ? `Edit ${props.initial.key}` : \"Add document\"}\n onClose={props.onClose}\n >\n <div className=\"modal-body\">\n <label className=\"field\">\n <span>Key</span>\n <input\n type=\"text\"\n value={key}\n disabled={isEdit}\n onChange={(e) => setKey(e.target.value)}\n placeholder=\"e.g. welcome-email\"\n {...enterSubmit}\n />\n {!isEdit && <span className=\"hint\">A unique name to reference this document by.</span>}\n </label>\n\n <label className=\"field\">\n <span>Format</span>\n <select value={format} onChange={(e) => setFormat(e.target.value as DocFormat)}>\n {FORMATS.map((f) => (\n <option key={f} value={f}>\n {f}\n </option>\n ))}\n </select>\n </label>\n\n {/* A `div`, not a `label`: none of JsonEditor/YamlEditor/CodeEditor render a native\n control for a label to name; each carries its own `aria-label` instead. */}\n <div className=\"field\">\n <span>Content</span>\n {format === \"json\" ? (\n <JsonEditor value={content} onChange={setContent} aria-label=\"Content\" />\n ) : format === \"yaml\" ? (\n <YamlEditor value={content} onChange={setContent} aria-label=\"Content\" />\n ) : (\n <CodeEditor value={content} onChange={setContent} aria-label=\"Content\" />\n )}\n </div>\n\n <label className=\"field\">\n <span>Description</span>\n <input\n type=\"text\"\n value={description}\n onChange={(e) => setDescription(e.target.value)}\n placeholder=\"Optional\"\n {...enterSubmit}\n />\n </label>\n\n {error && <div className=\"result error\">{error}</div>}\n </div>\n <div className=\"modal-actions\">\n <button type=\"button\" className=\"btn ghost\" onClick={props.onClose}>\n Cancel\n </button>\n <button type=\"button\" className=\"btn\" disabled={!key.trim() || saving} onClick={save}>\n {saving ? \"Saving…\" : isEdit ? \"Save changes\" : \"Save document\"}\n </button>\n </div>\n </Modal>\n );\n}\n"],"names":["FORMATS","DocumentFormModal","props","isEdit","key","setKey","useState","_a","format","setFormat","_b","content","setContent","_c","description","setDescription","_d","error","setError","createMut","useCreateDocumentMutation","updateMut","useUpdateDocumentMutation","saving","save","onSettled","e","ApiError","enterSubmit","useEnterSubmit","jsxs","Modal","jsx","f","JsonEditor","YamlEditor","CodeEditor"],"mappings":";;;;;;AAYA,MAAMA,IAAgC,CAAC,QAAQ,YAAY,QAAQ,QAAQ,MAAM;AAE1E,SAASC,EAAkBC,GAM/B;;AACD,QAAMC,IAAS,CAAC,CAACD,EAAM,SACjB,CAACE,GAAKC,CAAM,IAAIC,IAASC,IAAAL,EAAM,YAAN,gBAAAK,EAAe,QAAO,EAAE,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