@w6w/embed 0.1.0 → 0.2.0

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.
Files changed (148) hide show
  1. package/README.md +231 -4
  2. package/dist/ConfirmModal-RLbZT5_k.js +181 -0
  3. package/dist/ConfirmModal-RLbZT5_k.js.map +1 -0
  4. package/dist/CreateFunctionModal-DRsFx-FB.js +221 -0
  5. package/dist/CreateFunctionModal-DRsFx-FB.js.map +1 -0
  6. package/dist/DocumentFormModal-BExK1V-B.js +89 -0
  7. package/dist/DocumentFormModal-BExK1V-B.js.map +1 -0
  8. package/dist/ImportSpecModal-BDQIf6rg.js +136 -0
  9. package/dist/ImportSpecModal-BDQIf6rg.js.map +1 -0
  10. package/dist/W6WEmbedProvider.d.ts +22 -4
  11. package/dist/WorkflowEditor-DlbVv6Fs.js +854 -0
  12. package/dist/WorkflowEditor-DlbVv6Fs.js.map +1 -0
  13. package/dist/api-calls--JHyif6a.js +107 -0
  14. package/dist/api-calls--JHyif6a.js.map +1 -0
  15. package/dist/apps-1FNUwbGv.js +77 -0
  16. package/dist/apps-1FNUwbGv.js.map +1 -0
  17. package/dist/callables-3mFrMVG_.js +151 -0
  18. package/dist/callables-3mFrMVG_.js.map +1 -0
  19. package/dist/chrome/index.d.ts +6 -0
  20. package/dist/chrome/workspace.d.ts +29 -1
  21. package/dist/coerce-input-BicYr7nc.js +139 -0
  22. package/dist/coerce-input-BicYr7nc.js.map +1 -0
  23. package/dist/connections-CjjYeRqb.js +78 -0
  24. package/dist/connections-CjjYeRqb.js.map +1 -0
  25. package/dist/document-sources-C0grrtdq.js +86 -0
  26. package/dist/document-sources-C0grrtdq.js.map +1 -0
  27. package/dist/draft/index.d.ts +3 -1
  28. package/dist/draft/use-callable-draft.d.ts +65 -0
  29. package/dist/draft/workflow-save.d.ts +3 -0
  30. package/dist/draft.mjs +9 -5
  31. package/dist/draft.mjs.map +1 -1
  32. package/dist/editor/CallableEditorFrame.d.ts +33 -0
  33. package/dist/editor/EditorShell.d.ts +16 -0
  34. package/dist/editor/EndpointCards.d.ts +56 -0
  35. package/dist/editor/EndpointEditor.d.ts +26 -0
  36. package/dist/editor/FunctionEditor.d.ts +21 -0
  37. package/dist/editor/InputListEditor.d.ts +29 -0
  38. package/dist/editor/TargetSelector.d.ts +30 -0
  39. package/dist/editor/TargetSelector.types.d.ts +62 -0
  40. package/dist/editor/editor-apps.d.ts +8 -2
  41. package/dist/editor/types.d.ts +57 -0
  42. package/dist/editor-apps-BdenSV1o.js +95 -0
  43. package/dist/editor-apps-BdenSV1o.js.map +1 -0
  44. package/dist/editor-tools-RxmY5iyi.js +1279 -0
  45. package/dist/editor-tools-RxmY5iyi.js.map +1 -0
  46. package/dist/editor.mjs +2 -2166
  47. package/dist/editor.mjs.map +1 -1
  48. package/dist/editors/DocumentEditor.d.ts +20 -0
  49. package/dist/editors/doc-format.d.ts +3 -0
  50. package/dist/editors.d.ts +12 -0
  51. package/dist/editors.mjs +1313 -0
  52. package/dist/editors.mjs.map +1 -0
  53. package/dist/embed-status.d.ts +20 -0
  54. package/dist/endpoints-B2ynbZo-.js +227 -0
  55. package/dist/endpoints-B2ynbZo-.js.map +1 -0
  56. package/dist/forms/CreateEndpointModal.d.ts +54 -0
  57. package/dist/forms/CreateFunctionModal.d.ts +55 -0
  58. package/dist/forms/DocumentFormModal.d.ts +8 -0
  59. package/dist/forms/SecretsManager.d.ts +12 -0
  60. package/dist/forms/VarsManager.d.ts +29 -0
  61. package/dist/forms.d.ts +6 -0
  62. package/dist/forms.mjs +407 -0
  63. package/dist/forms.mjs.map +1 -0
  64. package/dist/index.d.ts +3 -1
  65. package/dist/index.mjs +153 -50
  66. package/dist/index.mjs.map +1 -1
  67. package/dist/lib/callable-record.d.ts +21 -0
  68. package/dist/lib/coerce-input.d.ts +6 -0
  69. package/dist/lib/endpoint-editor.d.ts +23 -0
  70. package/dist/lib/index.d.ts +7 -0
  71. package/dist/lib/input-coverage.d.ts +28 -0
  72. package/dist/lib/input-seeding.d.ts +67 -0
  73. package/dist/lib/rail-settings.d.ts +3 -3
  74. package/dist/lib/recent-activity.d.ts +128 -0
  75. package/dist/lib/target-fields.d.ts +168 -0
  76. package/dist/lib/workflow-blank.d.ts +2 -0
  77. package/dist/lib.mjs +70 -48
  78. package/dist/lib.mjs.map +1 -1
  79. package/dist/lists/ActivitySummary.d.ts +29 -0
  80. package/dist/lists/CallableKindList.d.ts +34 -0
  81. package/dist/lists/ConnectionDetail.d.ts +17 -0
  82. package/dist/lists/ConnectionList.d.ts +16 -0
  83. package/dist/lists/DocumentList.d.ts +29 -0
  84. package/dist/lists/EndpointList.d.ts +19 -0
  85. package/dist/lists/FunctionList.d.ts +18 -0
  86. package/dist/lists/ReliabilityBoard.d.ts +23 -0
  87. package/dist/lists/RunHistory.d.ts +11 -0
  88. package/dist/lists/ServiceDetail.d.ts +20 -0
  89. package/dist/lists/WorkflowList.d.ts +19 -0
  90. package/dist/lists/vendor-history.d.ts +40 -0
  91. package/dist/lists.d.ts +20 -0
  92. package/dist/lists.mjs +1185 -0
  93. package/dist/lists.mjs.map +1 -0
  94. package/dist/project-context-BiCjv_E3.js +25 -0
  95. package/dist/project-context-BiCjv_E3.js.map +1 -0
  96. package/dist/project-context.d.ts +15 -1
  97. package/dist/rail/CallableRail.d.ts +12 -0
  98. package/dist/rail/CallableWorkspace.d.ts +16 -0
  99. package/dist/rail/SettingsTool.d.ts +7 -1
  100. package/dist/rail/settings-sections.d.ts +2 -2
  101. package/dist/rail-settings-XYGToh00.js +111 -0
  102. package/dist/rail-settings-XYGToh00.js.map +1 -0
  103. package/dist/rail.d.ts +11 -0
  104. package/dist/rail.mjs +35 -0
  105. package/dist/rail.mjs.map +1 -0
  106. package/dist/repos/api-calls.d.ts +4 -0
  107. package/dist/repos/apps.d.ts +14 -0
  108. package/dist/repos/callables.d.ts +91 -0
  109. package/dist/repos/connections.d.ts +33 -0
  110. package/dist/repos/dashboard.d.ts +4 -0
  111. package/dist/repos/endpoints.d.ts +125 -0
  112. package/dist/repos/functions.d.ts +79 -0
  113. package/dist/repos/index.d.ts +10 -0
  114. package/dist/repos/reliability.d.ts +42 -0
  115. package/dist/repos/saved-tests.d.ts +46 -0
  116. package/dist/repos/spec-export.d.ts +23 -0
  117. package/dist/repos/workflows.d.ts +138 -0
  118. package/dist/repos.mjs +174 -88
  119. package/dist/repos.mjs.map +1 -1
  120. package/dist/settings-rail--GdRMusb.js +33 -0
  121. package/dist/settings-rail--GdRMusb.js.map +1 -0
  122. package/dist/slug-C4ktDPdy.js +315 -0
  123. package/dist/slug-C4ktDPdy.js.map +1 -0
  124. package/dist/spec-export-Cf3VQSQS.js +176 -0
  125. package/dist/spec-export-Cf3VQSQS.js.map +1 -0
  126. package/dist/spec-import-CjmxyZDR.js +465 -0
  127. package/dist/spec-import-CjmxyZDR.js.map +1 -0
  128. package/dist/step-tests-CivICmTq.js +18 -0
  129. package/dist/step-tests-CivICmTq.js.map +1 -0
  130. package/dist/trigger-preview-VPkrryDl.js +120 -0
  131. package/dist/trigger-preview-VPkrryDl.js.map +1 -0
  132. package/dist/use-callable-draft-zHLpcr-b.js +271 -0
  133. package/dist/use-callable-draft-zHLpcr-b.js.map +1 -0
  134. package/dist/{use-workflow-draft-oI02dsP-.js → use-workflow-draft-DzAyUeA6.js} +48 -46
  135. package/dist/use-workflow-draft-DzAyUeA6.js.map +1 -0
  136. package/dist/vault-BSEWhMYC.js +117 -0
  137. package/dist/vault-BSEWhMYC.js.map +1 -0
  138. package/dist/workflow-blank-DyL3_RUA.js +14 -0
  139. package/dist/workflow-blank-DyL3_RUA.js.map +1 -0
  140. package/package.json +34 -5
  141. package/src/styles.css +408 -1
  142. package/dist/project-context-Dbk0Gr1K.js +0 -16
  143. package/dist/project-context-Dbk0Gr1K.js.map +0 -1
  144. package/dist/slug-ByKQgxrf.js +0 -642
  145. package/dist/slug-ByKQgxrf.js.map +0 -1
  146. package/dist/spec-import-HgO7ZkLZ.js +0 -898
  147. package/dist/spec-import-HgO7ZkLZ.js.map +0 -1
  148. package/dist/use-workflow-draft-oI02dsP-.js.map +0 -1
@@ -0,0 +1,151 @@
1
+ import { useQueryClient as a, useMutation as l, useQuery as f } from "@tanstack/react-query";
2
+ import { u as s } from "./client-context-CX61Bgw-.js";
3
+ const y = {
4
+ function: (e) => ["function", e],
5
+ endpoint: (e) => ["endpoint", e],
6
+ workflow: (e) => ["workflow", e]
7
+ };
8
+ function w(e, n) {
9
+ return y[e](n);
10
+ }
11
+ function C(e, n, t) {
12
+ e.invalidateQueries({ queryKey: n }), e.invalidateQueries({ queryKey: t });
13
+ }
14
+ const c = {
15
+ function: "functions",
16
+ endpoint: "endpoints",
17
+ workflow: "workflows"
18
+ }, d = {
19
+ function: () => ["functions"],
20
+ endpoint: () => ["endpoints"],
21
+ workflow: (e) => ["workflows", e]
22
+ };
23
+ function Q(e) {
24
+ return c[e];
25
+ }
26
+ function b(e, n) {
27
+ const t = c[e];
28
+ return n === void 0 ? t : `${t}/${n}`;
29
+ }
30
+ function p(e, n) {
31
+ return `/${c[e]}/${n}`;
32
+ }
33
+ function S(e, n) {
34
+ return `${b(e, n)}/history`;
35
+ }
36
+ function u(e, n) {
37
+ return d[e](n);
38
+ }
39
+ function h(e, n, t) {
40
+ switch (n) {
41
+ case "function":
42
+ return e.console.functions.list();
43
+ case "endpoint":
44
+ return e.console.endpoints.list();
45
+ case "workflow":
46
+ return e.workflows.list({ project: t });
47
+ }
48
+ }
49
+ function k(e, n, t) {
50
+ switch (n) {
51
+ case "function":
52
+ return e.console.functions.get(t);
53
+ case "endpoint":
54
+ return e.console.endpoints.get(t);
55
+ case "workflow":
56
+ return e.console.workflows.get(t);
57
+ }
58
+ }
59
+ function m(e, n, t, o) {
60
+ switch (n) {
61
+ case "function":
62
+ return e.console.functions.upsert(t).then((r) => ({ id: r.id, key: r.key }));
63
+ case "endpoint":
64
+ return e.console.endpoints.upsert(t).then((r) => ({ id: r.endpoint.id, key: r.endpoint.key }));
65
+ case "workflow": {
66
+ const r = o == null ? void 0 : o.project;
67
+ return r ? e.console.workflows.upsert(t, { project: r }).then((i) => ({
68
+ id: i.workflow.id,
69
+ key: i.workflow.key ?? ""
70
+ })) : Promise.reject(new Error("No project selected yet."));
71
+ }
72
+ }
73
+ }
74
+ function q(e, n, t) {
75
+ switch (n) {
76
+ case "function":
77
+ case "endpoint":
78
+ return e.request({
79
+ method: "POST",
80
+ path: `${p(n, encodeURIComponent(t))}/archive`
81
+ });
82
+ case "workflow":
83
+ return e.console.workflows.archive(t);
84
+ }
85
+ }
86
+ function v(e, n, t) {
87
+ switch (n) {
88
+ case "function":
89
+ case "endpoint":
90
+ return e.request({ method: "DELETE", path: p(n, encodeURIComponent(t)) });
91
+ case "workflow":
92
+ return e.console.workflows.delete(t);
93
+ }
94
+ }
95
+ function L(e, n = !0, t) {
96
+ const o = s();
97
+ return f({
98
+ queryKey: u(e, t),
99
+ queryFn: () => h(o, e, t),
100
+ enabled: n
101
+ });
102
+ }
103
+ function R(e, n, t = !0) {
104
+ const o = s();
105
+ return f({
106
+ queryKey: w(e, n),
107
+ queryFn: () => k(o, e, n),
108
+ enabled: t
109
+ });
110
+ }
111
+ function $(e, n) {
112
+ const t = s(), o = a();
113
+ return l({
114
+ mutationFn: (r) => m(t, e, r, n),
115
+ onSuccess: (r) => C(o, u(e), w(e, r.id))
116
+ });
117
+ }
118
+ function g(e) {
119
+ const n = s(), t = a();
120
+ return l({
121
+ mutationFn: (o) => q(n, e, o),
122
+ onSuccess: () => t.invalidateQueries({ queryKey: u(e) })
123
+ });
124
+ }
125
+ function F(e) {
126
+ const n = s(), t = a();
127
+ return l({
128
+ mutationFn: (o) => v(n, e, o),
129
+ onSuccess: () => t.invalidateQueries({ queryKey: u(e) })
130
+ });
131
+ }
132
+ export {
133
+ q as a,
134
+ S as b,
135
+ Q as c,
136
+ w as d,
137
+ u as e,
138
+ p as f,
139
+ b as g,
140
+ v as h,
141
+ k as i,
142
+ C as j,
143
+ L as k,
144
+ h as l,
145
+ R as m,
146
+ F as n,
147
+ $ as o,
148
+ m as s,
149
+ g as u
150
+ };
151
+ //# sourceMappingURL=callables-3mFrMVG_.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"callables-3mFrMVG_.js","sources":["../src/lib/callable-kind.ts","../src/lib/save-invalidation.ts","../src/repos/callables.ts"],"sourcesContent":["/**\n * The three callable kinds and the single-resource query key per kind.\n *\n * Moved verbatim out of Studio's `repos/callables.ts` (`CallableKind`, `callableKey` and the one\n * pure table `callableKey` closes over, `RESOURCE_KEY`) so `repos/versions.ts` — which ships in\n * this package for all three kind arms — can invalidate a definition by key without importing a\n * Studio module. `repos/callables.ts` imports these from `@w6w/embed/repos` and does NOT re-export\n * them. No React, no client: loadable by `node --test`.\n */\n\n/** The three kinds the callable repos are total over. */\nexport type CallableKind = \"function\" | \"endpoint\" | \"workflow\";\n\n/** The single-resource key's own prefix — byte-identical to `functionKey`/`endpointKey`/\n * `workflowKey`. */\nconst RESOURCE_KEY: Record<CallableKind, (id: string) => readonly unknown[]> = {\n function: (id) => [\"function\", id],\n endpoint: (id) => [\"endpoint\", id],\n workflow: (id) => [\"workflow\", id],\n};\n\n/** `GET /<coll>/:id`'s own query key — the literal `lib/save-invalidation.ts` invalidates. */\nexport function callableKey(kind: CallableKind, id: string): readonly unknown[] {\n return RESOURCE_KEY[kind](id);\n}\n","/**\n * Shared invalidation for a whole-definition save (T3.1.1). `useSaveFunctionMutation` and\n * `useSaveEndpointMutation` (`src/repos/functions.ts`, `src/repos/endpoints.ts`) both route their\n * `onSuccess` through this one helper rather than inlining the two `invalidateQueries` calls at\n * each site — so a save invalidates the LIST key (both list pages and the editor depend on it)\n * *and* the saved resource's own single-resource key (`functionKey(id)` / `endpointKey(id)`),\n * never just the list.\n *\n * No value imports on purpose: `node --test` throws `ERR_UNKNOWN_FILE_EXTENSION` on anything that\n * reaches the `@w6w/ui` / `Layout.tsx` import graph, and `src/repos/*.ts` reaches it through\n * `../api/apiClient.tsx` (JSX). This module has none of that, so it is loadable by `node --test`\n * directly — see `src/lib/alias-rail.ts`'s docstring for the same reasoning.\n */\n\nexport interface QueryInvalidator {\n invalidateQueries(filters: { queryKey: readonly unknown[] }): unknown;\n}\n\n/**\n * Invalidate the list key, then the saved resource's own key. List first: both keys are\n * invalidated regardless of order, but the order is asserted (see the unit test) so a future edit\n * that drops one call is a diff a reviewer can spot in a single line.\n */\nexport function invalidateSavedCallable(\n qc: QueryInvalidator,\n listKey: readonly unknown[],\n callableKey: readonly unknown[],\n): void {\n qc.invalidateQueries({ queryKey: listKey });\n qc.invalidateQueries({ queryKey: callableKey });\n}\n","import { useMutation, useQuery, useQueryClient } from \"@tanstack/react-query\";\nimport type { W6WClient } from \"@w6w/sdk\";\nimport { useEmbedClient } from \"../draft/client-context.ts\";\n/**\n * The kind-parametrised resource repo (T4.2.1, `building-blocks.F3.md` §F-3) — ONE module\n * answering \"list / get / save / archive / delete a resource of kind K\" for all three kinds,\n * instead of `functions.ts`/`endpoints.ts`/`workflows.ts` each restating the same five shapes with\n * their own key builder.\n *\n * **Mirrors `src/repos/versions.ts`'s `COLLECTION_PATH: Record<VersionsKind, …>` idiom**: every\n * per-kind fact is a TOTAL `Record` whose arms are all named explicitly, never a string\n * pluralisation rule — a typo'd suffix would silently send one kind's requests at another kind's\n * collection (that module's own docblock gives the reasoning in full). The two tables that are\n * genuinely per-kind *data* — the collection segment and the two query-key shapes — are `Record`s;\n * the three calls whose SIGNATURE differs per kind (get's return shape, save's envelope key,\n * archive/delete's SDK-vs-escape-hatch split) are `switch`es with every arm named and no\n * `default:`, so a fourth kind is a compile error rather than a silent fall-through.\n *\n * **Query keys are byte-identical to the ones this repo replaces** — `[\"functions\"]`,\n * `[\"function\", id]`, `[\"endpoints\"]`, `[\"endpoint\", id]`, `[\"workflows\", project]`,\n * `[\"workflow\", id]` — because `lib/save-invalidation.ts`, `lib/spec-import-invalidation.ts` and\n * `repos/versions.ts`'s revert arm all invalidate those literals through helpers that take a key,\n * not a hook. A renamed key here would leave a saved resource's page showing its pre-save draft,\n * invisible to `tsc` and to every page guard (this is `spec-import-invalidation.ts`'s own\n * argument, restated for the whole family).\n *\n * `repos/functions.ts` stays as the Function-bound facade over this module — every existing\n * importer (`ui/rail/SettingsTool.tsx`, `ui/rail/AliasesTool.tsx`, `ui/rail/ErrorHandlingTool.tsx`,\n * `components/TargetSelector.tsx`, `components/FunctionIdentityModal.tsx`, `api/w6wApiFacade.tsx`)\n * keeps its import and its call shape; only where the code lives changed.\n */\nimport { type CallableKind, callableKey } from \"../lib/callable-kind.ts\";\nimport { invalidateSavedCallable } from \"../lib/save-invalidation.ts\";\n\n/** `<coll>` — the wire contract's own path segment per kind, every arm named explicitly\n * (never derived by string pluralisation), mirroring `versions.ts`'s `COLLECTION_PATH`. */\nconst COLLECTION_PATH: Record<CallableKind, \"functions\" | \"endpoints\" | \"workflows\"> = {\n function: \"functions\",\n endpoint: \"endpoints\",\n workflow: \"workflows\",\n};\n\n/**\n * The LIST query key per kind — byte-identical to `functionsKey`, `endpointsKey` and\n * `workflowsKey(project)`. A function per kind, not a literal, because the Workflow arm is\n * genuinely project-scoped (`repos/workflows.ts`'s own note: `[\"workflows\", undefined]` and\n * `[\"workflows\", \"prj_x\"]` are DIFFERENT cache entries, deliberately).\n */\nconst LIST_KEY: Record<CallableKind, (project?: string) => readonly unknown[]> = {\n function: () => [\"functions\"],\n endpoint: () => [\"endpoints\"],\n workflow: (project) => [\"workflows\", project],\n};\n\n/**\n * The structural minimum every list row of every kind satisfies — what the shared list chrome\n * (`pages/CallablePage.tsx`) renders and the Settings rail reads by id. Kind-specific widening\n * (`archivedAt`, an Endpoint's `status`/`incomplete`) stays in the kind's own facade, which is\n * where the comment explaining \"the SDK does not know this column yet\" belongs.\n */\nexport interface CallableRow {\n id: string;\n /** `null` for a Workflow that has no key of its own yet (`WorkflowSummary`'s own\n * type) — never coerced to `\"\"` here, so the list renders exactly what the server sent. */\n key: string | null;\n displayName?: string | null;\n description?: string | null;\n archivedAt?: string | null;\n}\n\n/** `<coll>` for a kind — the wire segment AND (studio mirrors the wire) the route segment. */\nexport function callableCollection(kind: CallableKind): string {\n return COLLECTION_PATH[kind];\n}\n\n/** The studio route for a kind, or for one of its resources: `\"functions\"`, `\"functions/fn_x\"`. */\nexport function callableRoute(kind: CallableKind, id?: string): string {\n const collection = COLLECTION_PATH[kind];\n return id === undefined ? collection : `${collection}/${id}`;\n}\n\n/** The wire path for one resource: `/functions/fn_x`. */\nexport function callablePath(kind: CallableKind, id: string): string {\n return `/${COLLECTION_PATH[kind]}/${id}`;\n}\n\n/** The studio route for one resource's History tab/page (T2.3.1/T2.4.1):\n * `\"functions/fn_x/history\"`. A sibling of {@link callableRoute}, not a\n * hand-written string per call site. */\nexport function callableHistoryRoute(kind: CallableKind, id: string): string {\n return `${callableRoute(kind, id)}/history`;\n}\n\n/** `GET /<coll>`'s own query key — the literal `lib/spec-import-invalidation.ts` invalidates. */\nexport function callableListKey(kind: CallableKind, project?: string): readonly unknown[] {\n return LIST_KEY[kind](project);\n}\n\n/**\n * `GET /<coll>`. A `switch`, not a table: the three SDK calls return three different summary\n * types, and the union is what the shared chrome consumes structurally.\n */\nexport function listCallables(\n client: W6WClient,\n kind: CallableKind,\n project?: string,\n): Promise<CallableRow[]> {\n switch (kind) {\n case \"function\":\n return client.console.functions.list();\n case \"endpoint\":\n return client.console.endpoints.list();\n case \"workflow\":\n return client.workflows.list({ project });\n }\n}\n\n/**\n * `GET /<coll>/:id`, each arm returning exactly what that kind's existing repo function returns —\n * Function's `{...function, valid}` splice, Endpoint's `{endpoint, invokeUrl, …}` envelope,\n * Workflow's three-field body — never re-shaped here. The return type is the honest `unknown`:\n * the per-kind reader in the kind's own facade is what narrows it.\n */\nexport function getCallable(client: W6WClient, kind: CallableKind, id: string): Promise<unknown> {\n switch (kind) {\n case \"function\":\n return client.console.functions.get(id);\n case \"endpoint\":\n return client.console.endpoints.get(id);\n case \"workflow\":\n return client.console.workflows.get(id);\n }\n}\n\n/**\n * `POST /<coll>`, normalised to the one thing EVERY caller of a save needs — the saved resource's\n * id and key, for the invalidation below and for a create modal's own \"created\" callback. The two\n * envelopes (`{endpoint: {id, key}}`, `{workflow: {id, key}}`) and the flat one (`{id, key}`) are\n * unwrapped in the arm that knows its own shape, so no caller outside this module ever has to.\n *\n * Workflow refuses without a `project` for the same reason `repos/workflows.ts`'s own save does:\n * a missing project on a WRITE lands the definition in the account's default project instead of\n * the one the operator is looking at.\n */\nexport function saveCallable(\n client: W6WClient,\n kind: CallableKind,\n definition: unknown,\n options?: { project?: string },\n): Promise<{ id: string; key: string }> {\n switch (kind) {\n case \"function\":\n return client.console.functions\n .upsert(definition as never)\n .then((saved) => ({ id: saved.id, key: saved.key }));\n case \"endpoint\":\n return client.console.endpoints\n .upsert(definition as never)\n .then((saved) => ({ id: saved.endpoint.id, key: saved.endpoint.key }));\n case \"workflow\": {\n const project = options?.project;\n if (!project) return Promise.reject(new Error(\"No project selected yet.\"));\n return client.console.workflows.upsert(definition, { project }).then((saved) => ({\n id: saved.workflow.id,\n key: saved.workflow.key ?? \"\",\n }));\n }\n }\n}\n\n/**\n * `POST /<coll>/:id/archive`. Function and Endpoint go through the plain `apiClient.request()`\n * escape hatch (T4.1.1/A7/D-I0-7: no typed `@w6w/sdk` method exists, and adding one would drag\n * `packages/wrappers` into this task's scope for an internal route); Workflow keeps the typed\n * `console.workflows.archive` it has had since the rail's DangerZone landed.\n */\nexport function archiveCallable(\n client: W6WClient,\n kind: CallableKind,\n id: string,\n): Promise<unknown> {\n switch (kind) {\n case \"function\":\n case \"endpoint\":\n return client.request({\n method: \"POST\",\n path: `${callablePath(kind, encodeURIComponent(id))}/archive`,\n });\n case \"workflow\":\n return client.console.workflows.archive(id);\n }\n}\n\n/** `DELETE /<coll>/:id` — same split, and the same reasoning, as {@link archiveCallable}. */\nexport function deleteCallable(\n client: W6WClient,\n kind: CallableKind,\n id: string,\n): Promise<unknown> {\n switch (kind) {\n case \"function\":\n case \"endpoint\":\n return client.request({ method: \"DELETE\", path: callablePath(kind, encodeURIComponent(id)) });\n case \"workflow\":\n return client.console.workflows.delete(id);\n }\n}\n\n/**\n * `useQuery` over {@link listCallables}, keyed by {@link callableListKey}. Generic over the row\n * type so a kind's own facade can narrow it to that kind's widened summary (Function's\n * `archivedAt`, Endpoint's `status`/`incomplete`) without a cast at the call site.\n */\nexport function useCallableListQuery<Row extends CallableRow = CallableRow>(\n kind: CallableKind,\n enabled = true,\n project?: string,\n) {\n const apiClient = useEmbedClient();\n return useQuery<Row[]>({\n queryKey: callableListKey(kind, project),\n queryFn: () => listCallables(apiClient, kind, project) as Promise<Row[]>,\n enabled,\n });\n}\n\n/** `useQuery` over {@link getCallable}, keyed by {@link callableKey}. */\nexport function useCallableQuery<Def = unknown>(kind: CallableKind, id: string, enabled = true) {\n const apiClient = useEmbedClient();\n return useQuery<Def>({\n queryKey: callableKey(kind, id),\n queryFn: () => getCallable(apiClient, kind, id) as Promise<Def>,\n enabled,\n });\n}\n\n/**\n * `useMutation` over {@link saveCallable}. `onSuccess` routes through the SAME\n * `invalidateSavedCallable` helper every save in studio already uses, with the SAME two keys —\n * the list AND the saved resource — so the Function arm's invalidation is the one\n * `repos/functions.ts` performs today, byte for byte.\n */\nexport function useSaveCallableMutation(kind: CallableKind, options?: { project?: string }) {\n const apiClient = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (definition: unknown) => saveCallable(apiClient, kind, definition, options),\n onSuccess: (saved) =>\n invalidateSavedCallable(qc, callableListKey(kind), callableKey(kind, saved.id)),\n });\n}\n\n/** `useMutation` over {@link archiveCallable} — the list key, so the row's archived badge\n * refreshes and the rail's Delete control appears in Archive's place. */\nexport function useArchiveCallableMutation(kind: CallableKind) {\n const apiClient = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (id: string) => archiveCallable(apiClient, kind, id),\n onSuccess: () => qc.invalidateQueries({ queryKey: callableListKey(kind) }),\n });\n}\n\n/** `useMutation` over {@link deleteCallable}. */\nexport function useDeleteCallableMutation(kind: CallableKind) {\n const apiClient = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (id: string) => deleteCallable(apiClient, kind, id),\n onSuccess: () => qc.invalidateQueries({ queryKey: callableListKey(kind) }),\n });\n}\n"],"names":["RESOURCE_KEY","id","callableKey","kind","invalidateSavedCallable","qc","listKey","COLLECTION_PATH","LIST_KEY","project","callableCollection","callableRoute","collection","callablePath","callableHistoryRoute","callableListKey","listCallables","client","getCallable","saveCallable","definition","options","saved","archiveCallable","deleteCallable","useCallableListQuery","enabled","apiClient","useEmbedClient","useQuery","useCallableQuery","useSaveCallableMutation","useQueryClient","useMutation","useArchiveCallableMutation","useDeleteCallableMutation"],"mappings":";;AAeA,MAAMA,IAAyE;AAAA,EAC7E,UAAU,CAACC,MAAO,CAAC,YAAYA,CAAE;AAAA,EACjC,UAAU,CAACA,MAAO,CAAC,YAAYA,CAAE;AAAA,EACjC,UAAU,CAACA,MAAO,CAAC,YAAYA,CAAE;AACnC;AAGO,SAASC,EAAYC,GAAoBF,GAAgC;AAC9E,SAAOD,EAAaG,CAAI,EAAEF,CAAE;AAC9B;ACDO,SAASG,EACdC,GACAC,GACAJ,GACM;AACN,EAAAG,EAAG,kBAAkB,EAAE,UAAUC,EAAA,CAAS,GAC1CD,EAAG,kBAAkB,EAAE,UAAUH,EAAA,CAAa;AAChD;ACMA,MAAMK,IAAiF;AAAA,EACrF,UAAU;AAAA,EACV,UAAU;AAAA,EACV,UAAU;AACZ,GAQMC,IAA2E;AAAA,EAC/E,UAAU,MAAM,CAAC,WAAW;AAAA,EAC5B,UAAU,MAAM,CAAC,WAAW;AAAA,EAC5B,UAAU,CAACC,MAAY,CAAC,aAAaA,CAAO;AAC9C;AAmBO,SAASC,EAAmBP,GAA4B;AAC7D,SAAOI,EAAgBJ,CAAI;AAC7B;AAGO,SAASQ,EAAcR,GAAoBF,GAAqB;AACrE,QAAMW,IAAaL,EAAgBJ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,EAAYC,GAAMF,CAAE;AAAA,IAC9B,SAAS,MAAMiB,EAAYS,GAAWxB,GAAMF,CAAE;AAAA,IAC9C,SAAAyB;AAAA,EAAA,CACD;AACH;AAQO,SAASK,EAAwB5B,GAAoBkB,GAAgC;AAC1F,QAAMM,IAAYC,EAAA,GACZvB,IAAK2B,EAAA;AACX,SAAOC,EAAY;AAAA,IACjB,YAAY,CAACb,MAAwBD,EAAaQ,GAAWxB,GAAMiB,GAAYC,CAAO;AAAA,IACtF,WAAW,CAACC,MACVlB,EAAwBC,GAAIU,EAAgBZ,CAAI,GAAGD,EAAYC,GAAMmB,EAAM,EAAE,CAAC;AAAA,EAAA,CACjF;AACH;AAIO,SAASY,EAA2B/B,GAAoB;AAC7D,QAAMwB,IAAYC,EAAA,GACZvB,IAAK2B,EAAA;AACX,SAAOC,EAAY;AAAA,IACjB,YAAY,CAAChC,MAAesB,EAAgBI,GAAWxB,GAAMF,CAAE;AAAA,IAC/D,WAAW,MAAMI,EAAG,kBAAkB,EAAE,UAAUU,EAAgBZ,CAAI,EAAA,CAAG;AAAA,EAAA,CAC1E;AACH;AAGO,SAASgC,EAA0BhC,GAAoB;AAC5D,QAAMwB,IAAYC,EAAA,GACZvB,IAAK2B,EAAA;AACX,SAAOC,EAAY;AAAA,IACjB,YAAY,CAAChC,MAAeuB,EAAeG,GAAWxB,GAAMF,CAAE;AAAA,IAC9D,WAAW,MAAMI,EAAG,kBAAkB,EAAE,UAAUU,EAAgBZ,CAAI,EAAA,CAAG;AAAA,EAAA,CAC1E;AACH;"}
@@ -34,3 +34,9 @@ export { ErrorHandlerSection, errorHandlingTool } from '../rail/ErrorHandlingToo
34
34
  export type { ErrorHandlerKind, ErrorHandlerSectionProps } from '../rail/ErrorHandlingTool.tsx';
35
35
  export { ProjectExpressionScope, useProjectExpressionOptions } from '../rail/ExpressionScope.tsx';
36
36
  export { editorRailTools } from '../rail/editor-tools.ts';
37
+ export { TargetSelector } from '../editor/TargetSelector.tsx';
38
+ export type { TargetKind, TargetSelectorProps, TargetValue, } from '../editor/TargetSelector.types.ts';
39
+ export { InputListEditor } from '../editor/InputListEditor.tsx';
40
+ export type { InputListEditorProps } from '../editor/InputListEditor.tsx';
41
+ export { CallableEditorFrame } from '../editor/CallableEditorFrame.tsx';
42
+ export type { CallableEditorFrameProps } from '../editor/CallableEditorFrame.tsx';
@@ -16,6 +16,15 @@ export type WorkspaceCallable = {
16
16
  key?: string;
17
17
  inputs?: readonly SnippetInput[];
18
18
  alias?: string;
19
+ /**
20
+ * The Function's / Endpoint's run-level error policy and its writer, published by an
21
+ * editor that owns the definition buffer (`useCallableDraft`) so the rail's Error handling
22
+ * tool edits and saves THAT buffer (pending edits ride along) instead of racing it. Same
23
+ * ⚠️ as the workflow arm: `onPolicyChange` MUST be referentially stable
24
+ * (`useCallableDraft`'s is).
25
+ */
26
+ policy?: CallablePolicy;
27
+ onPolicyChange?: (policy: CallablePolicy) => void;
19
28
  } | {
20
29
  kind: "endpoint";
21
30
  id: string;
@@ -26,6 +35,15 @@ export type WorkspaceCallable = {
26
35
  urlForm?: "id" | "key";
27
36
  alias?: string;
28
37
  inputs?: readonly SnippetInput[];
38
+ /**
39
+ * The Function's / Endpoint's run-level error policy and its writer, published by an
40
+ * editor that owns the definition buffer (`useCallableDraft`) so the rail's Error handling
41
+ * tool edits and saves THAT buffer (pending edits ride along) instead of racing it. Same
42
+ * ⚠️ as the workflow arm: `onPolicyChange` MUST be referentially stable
43
+ * (`useCallableDraft`'s is).
44
+ */
45
+ policy?: CallablePolicy;
46
+ onPolicyChange?: (policy: CallablePolicy) => void;
29
47
  } | {
30
48
  kind: "workflow";
31
49
  id: string;
@@ -58,9 +76,19 @@ export type WorkspaceCallable = {
58
76
  /** Derived from {@link WorkspaceCallable}, never redeclared — the arm a
59
77
  * `RailTool.isAvailable`/route wrapper narrows on. */
60
78
  export type WorkspaceKind = Exclude<WorkspaceCallable, null>["kind"];
61
- export declare function WorkspaceProvider({ children }: {
79
+ /**
80
+ * Two layers: `base` (a prop — the host-owned `{kind, id}` a `<CallableWorkspace>` publishes) and
81
+ * an override (what a mounted page publishes with `useWorkspace`). The override wins while it is
82
+ * set; when its publisher unmounts it is cleared and the base is shown again — never empty. With no
83
+ * `base` (Studio's layout, the editor's own nested provider) the behaviour is exactly the old
84
+ * single-slot one: override or `null`.
85
+ */
86
+ export declare function WorkspaceProvider({ children, base, }: {
62
87
  children: ReactNode;
88
+ base?: WorkspaceCallable;
63
89
  }): import("react").JSX.Element;
90
+ /** Non-throwing probe: is there an enclosing {@link WorkspaceProvider}? */
91
+ export declare function useHasWorkspace(): boolean;
64
92
  /** Publisher. Compute during render, effect-write, clear on unmount. */
65
93
  export declare function useWorkspace(resource: WorkspaceCallable): void;
66
94
  /** Reader — used by the rail and by every tool `Panel`. Throws outside the provider. */
@@ -0,0 +1,139 @@
1
+ function y(n) {
2
+ return n.kind === "action" ? "" : n.kind === "endpoint" ? n.endpoint : n.kind === "function" ? n.function : n.workflow;
3
+ }
4
+ function q(n) {
5
+ return n.kind === "action" ? !!(n.uses.app && n.uses.action) : !!y(n);
6
+ }
7
+ function I(n) {
8
+ return n ? n.kind === "function" ? { kind: "function", function: n.function } : n.kind === "workflow" ? { kind: "workflow", workflow: n.workflow } : { kind: "action", uses: n.uses, with: n.with } : { kind: "action", uses: { app: "", action: "", connection: null }, with: {} };
9
+ }
10
+ function F(n) {
11
+ return n.kind === "action" ? { uses: n.uses, with: n.with ?? {} } : { ...n, with: {} };
12
+ }
13
+ function g(n) {
14
+ return n.map((e) => {
15
+ const t = {
16
+ key: e.key,
17
+ label: e.label ?? e.key,
18
+ type: e.type ?? "string",
19
+ required: e.required,
20
+ default: e.default
21
+ };
22
+ return e.showIf !== void 0 && (t.showIf = e.showIf), t;
23
+ });
24
+ }
25
+ function S(n, e) {
26
+ var u, s;
27
+ const t = Array.isArray(n == null ? void 0 : n.steps) ? n.steps : [], i = /* @__PURE__ */ new Set(), r = [];
28
+ for (const o of t) {
29
+ const c = (u = o == null ? void 0 : o.uses) == null ? void 0 : u.app;
30
+ if (typeof c != "string" || !e.isTriggerApp(c)) continue;
31
+ const p = e.asFieldDefs((s = o == null ? void 0 : o.with) == null ? void 0 : s.fields);
32
+ for (const d of p) {
33
+ const f = d.key;
34
+ typeof f != "string" || f.trim() === "" || i.has(f) || (i.add(f), r.push({ key: f, label: f, type: d.type ?? "string", required: d.required }));
35
+ }
36
+ }
37
+ return r;
38
+ }
39
+ const h = ["string", "text", "number", "boolean", "json", "secret"];
40
+ function T(n) {
41
+ return n.rows.length === 0 && !n.touched;
42
+ }
43
+ function k(n) {
44
+ return h.includes(n) ? n : "string";
45
+ }
46
+ function N(n, e) {
47
+ const t = new Set(n.map((r) => r.key)), i = [];
48
+ for (const r of e) {
49
+ const u = r.key;
50
+ typeof u != "string" || u.trim() === "" || t.has(u) || (t.add(u), i.push({
51
+ key: u,
52
+ label: r.label ?? u,
53
+ type: k(r.type),
54
+ required: !!r.required
55
+ }));
56
+ }
57
+ return i.length === 0 ? n : [...n, ...i];
58
+ }
59
+ function m(n, e) {
60
+ const t = n.showIf;
61
+ if (!t) return !0;
62
+ const i = e(t.field);
63
+ return t.equals !== void 0 ? i === t.equals : t.in ? t.in.some((r) => r === i) : t.notIn ? !t.notIn.some((r) => r === i) : t.truthy !== void 0 ? t.truthy ? !!i : !i : !0;
64
+ }
65
+ function b(n) {
66
+ return n == null ? !1 : typeof n == "string" ? n.trim() !== "" : !0;
67
+ }
68
+ function a(n, e, t) {
69
+ const i = new Set(n.map((s) => s.key)), r = (s) => {
70
+ var o;
71
+ return (t == null ? void 0 : t[s]) !== void 0 ? t[s] : (o = e.find((c) => c.key === s)) == null ? void 0 : o.default;
72
+ }, u = [];
73
+ for (const s of e) {
74
+ if (!s.required) continue;
75
+ const o = s.key;
76
+ typeof o != "string" || o.trim() === "" || i.has(o) || u.includes(o) || m(s, r) && (b(s.default) || u.push(o));
77
+ }
78
+ return u;
79
+ }
80
+ function j(n, e) {
81
+ if (!(e.emptyMeansPassthrough && n.length === 0))
82
+ return n;
83
+ }
84
+ function w(n) {
85
+ return n == null ? !1 : typeof n == "string" ? n.trim() !== "" : typeof n == "object" && "type" in n && n.type === "expr" ? !0 : typeof n == "object";
86
+ }
87
+ function l(n) {
88
+ const e = [];
89
+ for (const t of Object.keys(n))
90
+ w(n[t]) && e.push({ key: t, label: t, type: "string" });
91
+ return e;
92
+ }
93
+ function v(n) {
94
+ const { target: e, rows: t, fields: i } = n;
95
+ return e.kind === "action" ? e.with === void 0 ? [] : a(l(e.with), i, e.with) : t.length === 0 ? [] : a(t, i);
96
+ }
97
+ function A(n) {
98
+ return n.impl ? a(
99
+ l(n.impl.with ?? {}),
100
+ n.fields,
101
+ n.impl.with ?? {}
102
+ ) : n.fields.filter((e) => e.required).map((e) => e.key);
103
+ }
104
+ function B(n, e) {
105
+ if (e !== "")
106
+ switch (n) {
107
+ case "number": {
108
+ const t = Number(e);
109
+ return Number.isNaN(t) ? e : t;
110
+ }
111
+ case "boolean":
112
+ return e === "true";
113
+ case "json":
114
+ try {
115
+ return JSON.parse(e);
116
+ } catch {
117
+ return e;
118
+ }
119
+ default:
120
+ return e;
121
+ }
122
+ }
123
+ export {
124
+ h as I,
125
+ j as a,
126
+ y as b,
127
+ B as c,
128
+ F as d,
129
+ A as e,
130
+ S as f,
131
+ a as g,
132
+ I as i,
133
+ N as m,
134
+ g as p,
135
+ T as s,
136
+ q as t,
137
+ v as u
138
+ };
139
+ //# sourceMappingURL=coerce-input-BicYr7nc.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"coerce-input-BicYr7nc.js","sources":["../src/lib/target-fields.ts","../src/lib/input-seeding.ts","../src/lib/input-coverage.ts","../src/lib/coerce-input.ts"],"sourcesContent":["/**\n * Pure helpers shared by `TargetSelector`'s three arms (rfcs/endpoint.md\n * :339-347 — `EndpointTarget = CallableRef | ActionTarget`) and by\n * `EndpointsPage`'s save gate.\n *\n * Pure and testable by design, mirroring `workflow-validity.ts`'s shape:\n * `@w6w/ui`'s `package.json` `exports[\".\"]` resolves to raw `./src/index.ts`,\n * which re-exports `.tsx` files, so `node --test` throws\n * `ERR_UNKNOWN_FILE_EXTENSION` the moment anything here imports `@w6w/ui` or\n * `@w6w/ui/flow` — even type-only. So this module declares its own local\n * structural (`*Like`) types instead of importing the real ones from\n * `../api/types.ts`, and `isTriggerApp`/`asFieldDefs` (the workflow arm's only\n * dependency on `@w6w/ui/flow`) are **caller-injected** — `TargetSelector.tsx`\n * (unaffected by the JSX constraint) imports the real ones and passes them in.\n */\n\n/** The four arms `EndpointTarget` can take; a Function's `impl` takes the\n * first three (D-8) — `\"endpoint\"` is alias-only, never legal for `Fn.impl`. */\nexport type TargetKind = \"action\" | \"function\" | \"workflow\" | \"endpoint\";\n\n/** The `action` arm — same `{ uses, with }` shape a Function's `impl` carries. */\nexport interface ActionTargetLike {\n kind: \"action\";\n uses: { app: string; action: string; connection?: string | null };\n with?: Record<string, unknown>;\n}\n\n/** The `function`/`workflow` arms — a bare ref, one hop to a CallableRef. */\nexport type CallableTargetLike =\n | { kind: \"function\"; function: string }\n | { kind: \"workflow\"; workflow: string };\n\n/** The `endpoint` arm — a bare ref to another Endpoint. Alias-only (plan.md\n * §2a): legal for `AliasDef.target`, never for an Endpoint's own `target`\n * (the server refuses it — `admin/endpoints.ts`'s `validateDefinition`). */\nexport interface EndpointRefTargetLike {\n kind: \"endpoint\";\n endpoint: string;\n}\n\n/** The full local mirror of `EndpointTarget` this module operates on. */\nexport type TargetLike = ActionTargetLike | CallableTargetLike | EndpointRefTargetLike;\n\n/**\n * The action arm of a Function's `impl` — today's `FunctionImplLike` shape,\n * plus the two fields D-8 adds: `kind?: \"action\"` (absent means \"action\",\n * unchanged for every Function stored before the union existed) and\n * `outputMap?` (mirrors the action arm's own adapter-out pass, already on\n * `FnActionImpl`/`FunctionActionImpl`).\n */\nexport interface ActionImplLike {\n kind?: \"action\";\n uses: { app: string; action: string; connection?: string | null };\n with?: Record<string, unknown>;\n outputMap?: Record<string, unknown>;\n}\n\n/**\n * A Function's `impl` (D-8, `rfcs/function.md` as amended by TC2) — bound to\n * one app Action, or to another Function/Workflow via `CallableTargetLike`\n * (reused verbatim, never a fourth local mirror), intersected with the same\n * `with`/`outputMap` adapter pair the action arm carries — field-for-field\n * `FnCallableImpl = CallableRef & {with?; outputMap?}` (TC2's pinned type).\n */\nexport type FunctionImplLike =\n | ActionImplLike\n | (CallableTargetLike & { with?: Record<string, unknown>; outputMap?: Record<string, unknown> });\n\n/** A declared action/function param, just enough of it for the projector. */\nexport interface ParamLike {\n key: string;\n label?: string;\n type?: string;\n required?: boolean;\n default?: unknown;\n showIf?: ShowIfPredicate;\n}\n\n/** Visibility predicate — mirroring ActionParam.showIf from @w6w/ui. */\nexport interface ShowIfPredicate {\n field: string;\n equals?: unknown;\n in?: unknown[];\n notIn?: unknown[];\n truthy?: boolean;\n}\n\n/** One field of a manual/webhook trigger's `with.fields` (`@w6w/ui/flow`'s `TriggerFieldDef`). */\nexport interface TriggerFieldDefLike {\n key?: string;\n type?: string;\n default?: unknown;\n required?: boolean;\n}\n\n/** A workflow graph step, just enough of it for the trigger-field union (A6). */\nexport interface WorkflowStepLike {\n uses?: { app?: string };\n with?: Record<string, unknown>;\n}\n\n/** A workflow definition, just enough of it for the trigger-field union. */\nexport interface WorkflowLike {\n steps?: unknown;\n}\n\n/** Everything `fieldsFromWorkflow` needs from `@w6w/ui/flow` but cannot import itself. */\nexport interface WorkflowFieldCtx {\n /** `@w6w/ui/flow`'s `isTriggerApp`, injected by the JSX caller. */\n isTriggerApp: (app: string) => boolean;\n /** `@w6w/ui/flow`'s `asFieldDefs`, injected by the JSX caller. */\n asFieldDefs: (fields: unknown) => TriggerFieldDefLike[];\n}\n\n/** One field of the normalized list `TargetSelector` resolves to (A5). */\nexport interface TargetField {\n key: string;\n label: string;\n type: string;\n required?: boolean;\n default?: unknown;\n showIf?: ShowIfPredicate;\n}\n\n/** One row of an input-contract list (`FunctionInput`/`EndpointInput`'s common shape). */\nexport interface InputRowLike {\n key: string;\n label: string;\n type: string;\n required?: boolean;\n}\n\n/** The concrete ref (`fn_…` / `wf_…` / `ep_…`) a CallableRef/endpoint target\n * currently points at, `\"\"` for `action`. */\nexport function targetRef(target: TargetLike): string {\n if (target.kind === \"action\") return \"\";\n if (target.kind === \"endpoint\") return target.endpoint;\n return target.kind === \"function\" ? target.function : target.workflow;\n}\n\n/** Is the target fully chosen? An action needs both halves of its `uses` pair (A9). */\nexport function targetIsBound(target: TargetLike): boolean {\n if (target.kind === \"action\") return Boolean(target.uses.app && target.uses.action);\n return Boolean(targetRef(target));\n}\n\n/**\n * Adapt a Function's `impl` into the shape `TargetSelector` consumes (D-8):\n * an action impl to the `action` arm exactly as before; a CallableRef impl maps\n * its `kind`/`function`|`workflow` across UNCHANGED — deliberately dropping\n * `with`/`outputMap`, which `TargetLike`'s CallableRef arm has no slot for (they\n * survive on `draft.impl` itself; `targetToImpl` restores a default `with` on\n * the way back, so `implToTarget(targetToImpl(x))` round-trips `x`). An\n * absent impl still yields the empty action target.\n */\nexport function implToTarget(\n impl: FunctionImplLike | undefined,\n): ActionTargetLike | CallableTargetLike {\n // Draft functions have no impl yet; return an empty target\n if (!impl) {\n return { kind: \"action\", uses: { app: \"\", action: \"\", connection: null }, with: {} };\n }\n if (impl.kind === \"function\") return { kind: \"function\", function: impl.function };\n if (impl.kind === \"workflow\") return { kind: \"workflow\", workflow: impl.workflow };\n return { kind: \"action\", uses: impl.uses, with: impl.with };\n}\n\n/**\n * Inverse of {@link implToTarget}, over the widened D-8 domain. Never yields\n * `with: undefined` on EITHER arm — A10: `invoke-function.ts`'s\n * `resolveWith(impl.with, …)` call is unconditional and shared by both arms\n * (the CallableRef arm has its own `with` adapter pass onto the callee's inputs,\n * unlike `uncoveredForEndpoint`'s P3), so an unmapped `with` must still be\n * `{}`, not absent, on a CallableRef impl too.\n */\nexport function targetToImpl(target: ActionTargetLike | CallableTargetLike): FunctionImplLike {\n if (target.kind === \"action\") {\n return { uses: target.uses, with: target.with ?? {} };\n }\n return { ...target, with: {} };\n}\n\n/** Project a list of action/function params into the normalized `TargetField[]` (A5). */\nexport function paramsToFields(params: ParamLike[]): TargetField[] {\n return params.map((p) => {\n const field: TargetField = {\n key: p.key,\n label: p.label ?? p.key,\n type: p.type ?? \"string\",\n required: p.required,\n default: p.default,\n };\n if (p.showIf !== undefined) {\n field.showIf = p.showIf;\n }\n return field;\n });\n}\n\n/**\n * A6: project every manual/webhook-trigger step's `with.fields` from a raw\n * workflow graph into the union of `TargetField`s, keyed by `key`, first\n * occurrence wins, order stable (planner D-2: the server broadcasts one\n * `input` object to every trigger identically). A webhook/scheduler step that\n * declares `methods`/`auth` but no `fields` contributes nothing — by reading\n * `with.fields`, not a special case. Unnamed/blank keys are skipped. `default`\n * is not carried for this arm (A5). A missing/garbage graph, or one whose\n * `isTriggerApp` predicate matches nothing, yields `[]` — never a throw.\n */\nexport function fieldsFromWorkflow(\n workflow: WorkflowLike | null | undefined,\n ctx: WorkflowFieldCtx,\n): TargetField[] {\n const steps = Array.isArray(workflow?.steps) ? (workflow.steps as WorkflowStepLike[]) : [];\n const seen = new Set<string>();\n const out: TargetField[] = [];\n for (const step of steps) {\n const app = step?.uses?.app;\n if (typeof app !== \"string\" || !ctx.isTriggerApp(app)) continue;\n const defs = ctx.asFieldDefs(step?.with?.fields);\n for (const def of defs) {\n const key = def.key;\n if (typeof key !== \"string\" || key.trim() === \"\" || seen.has(key)) continue;\n seen.add(key);\n out.push({ key, label: key, type: def.type ?? \"string\", required: def.required });\n }\n }\n return out;\n}\n","/**\n * The seeding/coverage logic behind the shared `InputListEditor` (T3.2.1):\n * filling a Function/Endpoint's declared input list from the picked target's\n * resolved fields (`TargetSelector`'s A5/A7, `target-fields.ts`), and\n * flagging what a later target change no longer covers.\n *\n * **The policy (HITL-1, pinned).** Seed only when the input list is empty\n * AND the user has not touched it; once touched (any add/update/remove via\n * the row editor), a later target change never rewrites the list — it only\n * flags the required keys the new target no longer covers. This is the only\n * policy that cannot destroy typed work, and the flag is what T3.2.2's save\n * gate consumes.\n *\n * **Supersedes `target-fields.ts`'s `seedRowsFromFields`** — T3.1.1's\n * declared v1 stopgap (seed-a-wholly-empty-list-once, no touched/merge\n * concept). That symbol is deleted from `target-fields.ts`, not duplicated;\n * this module is its one home.\n *\n * **The pass-through guard** (the finding most likely to cause a silent\n * regression): the server dispatches an Endpoint's `action` arm on\n * `target.with === undefined` (`invoke-endpoint.ts:136-143`) — `{}` is\n * truthy, so an empty `with` does NOT pass through. `EndpointDef.input` (the\n * declared list this module seeds) is a SEPARATE field the server never\n * reads for dispatch at all, but the round-trip must still agree:\n * {@link inputsForSave} returns `undefined` (never `[]`) for an empty,\n * pass-through-mode list, so a previously authored pass-through Endpoint\n * opens and re-saves unchanged. A Function has no pass-through mode —\n * `emptyMeansPassthrough: false` never returns `undefined`, matching\n * `FunctionDef.inputs`'s non-nullable wire type (`draft.inputs.map` would\n * throw on `undefined`).\n *\n * Pure, React-free, `.ts`, no value import of `@w6w/ui` — mirrors\n * `workflow-validity.ts`/`target-fields.ts`'s shape so `node --test` can\n * load it directly (`@w6w/ui`'s barrel re-exports `.tsx`, which Node's\n * type-stripping cannot parse). `INPUT_TYPES` lives here rather than in\n * `InputListEditor.tsx` because this module's own seeding logic needs it.\n */\n\nimport type { TargetField } from \"./target-fields.ts\";\n\n/** The input-row types the two builders offer (`ActionParam`'s subset). */\nexport const INPUT_TYPES = [\"string\", \"text\", \"number\", \"boolean\", \"json\", \"secret\"] as const;\n\n/**\n * One row of an input-contract list — `FunctionInput`/`EndpointInput`'s\n * common shape (`../api/types.ts`), mirrored locally so this pure module\n * never imports a value from a `.tsx`-reexporting barrel. Structurally\n * identical to both wire types, so a page's `draft.inputs`/`draft.input`\n * needs no cast at the `InputListEditor` boundary in either direction.\n */\nexport interface InputRow {\n key: string;\n label: string;\n type: string;\n required?: boolean;\n default?: unknown;\n hint?: string;\n}\n\n/**\n * Is there a wholly empty, still-untouched list to seed? Any manual edit —\n * add, update or remove, via the row editor's own `onChange` — makes the\n * list the user's forever after (HITL-1); the seeding effect itself must\n * never be what sets `touched`.\n */\nexport function shouldSeed(args: { rows: InputRow[]; touched: boolean }): boolean {\n return args.rows.length === 0 && !args.touched;\n}\n\n/**\n * `type` is the field's own type when {@link INPUT_TYPES} declares it,\n * otherwise `\"string\"` — an unlisted type (`section`, `select`, …) would\n * otherwise render a `<select>` with no matching `<option>` and silently\n * change the value.\n */\nfunction normalizeType(type: string): string {\n return (INPUT_TYPES as readonly string[]).includes(type) ? type : \"string\";\n}\n\n/**\n * `rows` plus one appended row per `fields` key not already present, in\n * field order. **Never modifies or removes an existing row, never\n * re-orders.** A seeded row is\n * `{ key, label: field.label ?? field.key, type, required: Boolean(field.required) }`\n * and nothing else — `default`/`hint` are deliberately not copied, because\n * the row editor cannot show or remove them and they would become invisible\n * state on the saved definition. Fields with a missing/blank key are\n * skipped; a duplicate key (in `fields`, or already present in `rows`)\n * seeds once.\n */\nexport function mergeSeed(rows: InputRow[], fields: TargetField[]): InputRow[] {\n const seen = new Set(rows.map((r) => r.key));\n const appended: InputRow[] = [];\n for (const field of fields) {\n const key = field.key;\n if (typeof key !== \"string\" || key.trim() === \"\" || seen.has(key)) continue;\n seen.add(key);\n appended.push({\n key,\n label: field.label ?? key,\n type: normalizeType(field.type),\n required: Boolean(field.required),\n });\n }\n return appended.length === 0 ? rows : [...rows, ...appended];\n}\n\n/**\n * Is `field` visible under the given effective-value lookup?\n * Implements `packages/ui/src/ParamsForm.tsx:20-29`'s `isParamVisible`\n * predicate, honouring all four arms (`equals`, `in`, `notIn`, `truthy`).\n */\nfunction isFieldVisible(field: TargetField, effective: (key: string) => unknown): boolean {\n const c = field.showIf;\n if (!c) return true;\n const v = effective(c.field);\n if (c.equals !== undefined) return v === c.equals;\n if (c.in) return c.in.some((x) => x === v);\n if (c.notIn) return !c.notIn.some((x) => x === v);\n if (c.truthy !== undefined) return c.truthy ? !!v : !v;\n return true;\n}\n\n/**\n * Does `default` satisfy \"usable\"? A usable default can stand in for an\n * explicitly mapped value — `false` and `0` are usable, `undefined`/`null`\n * and whitespace-only strings are not.\n * Implements the `v === undefined || v === null` / `v.trim() !== \"\"`\n * rejection from `packages/ui/src/StepBuilderModal.tsx:706-707`.\n */\nfunction hasUsableDefault(d: unknown): boolean {\n if (d === undefined || d === null) return false;\n if (typeof d === \"string\") return d.trim() !== \"\";\n return true;\n}\n\n/**\n * The required field keys `fields` declares that no row in `rows` covers,\n * in field order — what a target change leaves for the operator to notice\n * once the list is the user's (HITL-1) and can no longer be auto-filled.\n * Informational here: T3.2.2's save gate is what turns this into a block,\n * and imports this same predicate rather than forking a second copy of it.\n *\n * Skips a required field that is currently hidden by its own `showIf` or\n * that declares a usable `default` — mirroring\n * `packages/ui/src/StepBuilderModal.tsx:686-711`'s `requiredParamsFilled`.\n * `values` is the `with` mapping; omitting it leaves existing callers'\n * behaviour unchanged apart from the two new skips.\n */\nexport function uncoveredRequiredKeys(\n rows: InputRow[],\n fields: TargetField[],\n values?: Record<string, unknown>,\n): string[] {\n const covered = new Set(rows.map((r) => r.key));\n const effective = (key: string) =>\n values?.[key] !== undefined ? values[key] : fields.find((f) => f.key === key)?.default;\n const out: string[] = [];\n for (const field of fields) {\n if (!field.required) continue;\n const key = field.key;\n if (typeof key !== \"string\" || key.trim() === \"\" || covered.has(key) || out.includes(key)) {\n continue;\n }\n if (!isFieldVisible(field, effective)) continue;\n if (hasUsableDefault(field.default)) continue;\n out.push(key);\n }\n return out;\n}\n\n/**\n * The write-back both pages route their input list through (see the module\n * docstring's pass-through guard). The overloads let a call site that\n * passes the literal `emptyMeansPassthrough: false` (every Function save)\n * keep a non-nullable return type at compile time, matching\n * `FunctionDef.inputs`'s wire shape without a cast.\n */\nexport function inputsForSave(rows: InputRow[], opts: { emptyMeansPassthrough: false }): InputRow[];\nexport function inputsForSave(\n rows: InputRow[],\n opts: { emptyMeansPassthrough: boolean },\n): InputRow[] | undefined;\nexport function inputsForSave(\n rows: InputRow[],\n opts: { emptyMeansPassthrough: boolean },\n): InputRow[] | undefined {\n if (opts.emptyMeansPassthrough && rows.length === 0) return undefined;\n return rows;\n}\n","/**\n * The **save gate**'s arm dispatch (T3.2.2): given a picked target, decide\n * *which* key set counts as \"feeding\" its required fields — and when the\n * question does not apply at all — then hand the actual set difference to\n * {@link uncoveredRequiredKeys}.\n *\n * **This module deliberately owns no coverage rule of its own.**\n * `uncoveredRequiredKeys` lives in `./input-seeding.ts` because T3.2.1's\n * `InputListEditor` *renders* the uncovered-required flag from it. Two copies\n * of one coverage rule would drift, and the user would see a flag with no\n * block or a block with no flag. Everything below is dispatch: pick the\n * covered set, or skip.\n *\n * ## The five cases, each anchored to the line that decides it at runtime\n *\n * | # | case | gate |\n * |---|---|---|\n * | P1 | Endpoint, `action` arm, `target.with === undefined` | **skipped** — pass-through |\n * | P2 | Endpoint, `action` arm, `target.with` is an object (**incl. `{}`**) | required params must be non-blank cells of `with` |\n * | P3 | Endpoint, `function`/`workflow` arm, declared `input` list empty | **skipped** — no `with` mechanism exists on these arms |\n * | P4 | Endpoint, `function`/`workflow` arm, declared list non-empty | required target keys must appear as declared row keys |\n * | P5 | **Function**, always | required params must be non-blank cells of `impl.with` |\n *\n * P1 is `=== undefined` **only**. `bll/invoke-endpoint.ts:136-143` dispatches\n * `target.with ? resolveWith(…) : input.input`, and `{}` is truthy — so an\n * empty object does **not** pass through, and treating it as if it did would\n * ship exactly the unfed-required-field bug this gate exists to block. The\n * consequence, stated rather than fixed: `EndpointsPage`'s picker writes\n * `with: built.with ?? {}`, so an action-arm **pass-through Endpoint can no\n * longer be authored through the UI at all** — it can only be opened and\n * re-saved. That was already true server-side before this gate existed\n * (`FOLLOWUPS.md`).\n *\n * P1/P2 key on `target.with` and **never** on the declared list. That matters\n * because T3.2.1 made a deliberately emptied Endpoint list save `input`\n * *absent* rather than `[]` — so \"emptied\" and \"never declared\" are\n * indistinguishable on the wire, and a gate that read pass-through off the\n * list's emptiness would misread one for the other. P3's skip is justified by\n * the *absence of a `with` mechanism* on the callable arms, where the payload\n * always passes through by key identity, not by the list being empty.\n *\n * P5 has no skip: `bll/invoke-function.ts:101-107` calls\n * `resolveWith(impl.with, …)` unconditionally, so a Function has no\n * pass-through mode. With **no action chosen** the field list is empty and\n * coverage is vacuously satisfied, which is what preserves the deliberate\n * save-gate asymmetry — `FunctionsPage` stays saveable incomplete (its\n * `valid`/incomplete badge is the signal), while `EndpointsPage` keeps its\n * separate `targetIsBound` term.\n *\n * ## Known limitation — this gate is CLIENT-SIDE ONLY\n *\n * A determined API caller can still `POST /functions` or `POST /endpoints`\n * with a malformed definition. Both server `validateDefinition`s are\n * structural only (`api/functions.ts:26-37` checks the *types* of\n * `impl.uses.app`/`action`; `api/endpoints.ts:109-154` checks `target.kind`\n * plus its ref/uses fields and the `exposure.security` shape) — neither\n * invokes anything nor looks at coverage, so a dangling ref or an unmapped\n * required param stores fine and fails only at invoke time. Closing that is a\n * server-side write, a boundary expansion out of scope for this node; it is\n * stated here rather than papered over.\n *\n * Pure, React-free, `.ts`, no import of `@w6w/ui` — directly or transitively.\n * `./target-fields.ts`, `./input-seeding.ts` and `./with-mapping.ts` are all\n * `@w6w/ui`-free by the same design (`workflow-validity.ts`'s header explains\n * the wall: the barrel re-exports `.tsx`, which `node --test` cannot parse).\n * The normalized field list therefore arrives as a plain array parameter,\n * resolved by the caller — `TargetSelector`'s `onResolved` — exactly as\n * `workflow-validity.ts:69`'s injected `ValidityContext` does.\n */\n\nimport { type InputRow, uncoveredRequiredKeys } from \"./input-seeding.ts\";\nimport type { FunctionImplLike, TargetField, TargetLike } from \"./target-fields.ts\";\n\n/**\n * Check if a `with` mapping value is considered \"fed\" (non-empty).\n * A cell is \"fed\" when it contains a non-empty value:\n * - ExprValue objects are always considered fed (they have meaningful content)\n * - Strings are fed if non-blank after trimming\n * - Everything else (null, undefined, empty string) is not fed\n */\nfunction isFedValue(v: unknown): boolean {\n if (v == null) return false;\n if (typeof v === \"string\") return v.trim() !== \"\";\n if (typeof v === \"object\" && \"type\" in v && v.type === \"expr\") return true;\n // Legacy `{ \"$\": path }` format or any other object is considered fed\n return typeof v === \"object\";\n}\n\n/**\n * The mapping cells that actually feed something, shaped as the covered rows\n * {@link uncoveredRequiredKeys} diffs against. A cell is \"fed\" when it\n * contains a non-empty value — a whitespace-only literal maps nothing, and\n * `updateWith` deletes a cleared key outright.\n */\nfunction coveredRowsFromWith(withBlock: Record<string, unknown>): InputRow[] {\n const rows: InputRow[] = [];\n for (const key of Object.keys(withBlock)) {\n if (!isFedValue(withBlock[key])) continue;\n rows.push({ key, label: key, type: \"string\" });\n }\n return rows;\n}\n\n/**\n * The required target-field keys an Endpoint does **not** feed — P1–P4 above.\n * Empty means saveable as far as coverage is concerned; `EndpointsPage`'s own\n * `targetIsBound`/`key` terms are separate and survive unchanged.\n *\n * `fields` is the target's normalized field list as `TargetSelector` resolved\n * it. While a target's detail is still loading it is `[]`, so the gate is\n * vacuous until the fields arrive — this fails **open**, deliberately: an\n * unresolvable target (a deleted app, a failed fetch) must never trap an\n * author in a form they cannot save.\n */\nexport function uncoveredForEndpoint(args: {\n target: TargetLike;\n rows: InputRow[];\n fields: TargetField[];\n}): string[] {\n const { target, rows, fields } = args;\n if (target.kind === \"action\") {\n if (target.with === undefined) return []; // P1 — pass-through, nothing to check\n return uncoveredRequiredKeys(coveredRowsFromWith(target.with), fields, target.with); // P2\n }\n if (rows.length === 0) return []; // P3 — the callable arms have no `with` mechanism\n return uncoveredRequiredKeys(rows, fields); // P4 — key-name identity\n}\n\n/**\n * The required action-param keys a Function's `impl.with` does not map — P5.\n * No skip arm: a Function has no pass-through mode. An unbound Function\n * resolves to an empty `fields`, so this returns `[]` and the Functions save\n * gate keeps allowing a deliberately incomplete save.\n */\nexport function uncoveredForFunction(args: {\n impl: FunctionImplLike | undefined;\n fields: TargetField[];\n}): string[] {\n // Draft functions have no impl yet; no fields are covered\n if (!args.impl) {\n return args.fields.filter((f) => f.required).map((f) => f.key);\n }\n return uncoveredRequiredKeys(\n coveredRowsFromWith(args.impl.with ?? {}),\n args.fields,\n args.impl.with ?? {},\n );\n}\n","/**\n * Coerce a text field's value to the canonical input's declared type, for a callable's test-invoke\n * form. Empty ⇒ undefined (the field is omitted from the payload). Unparseable `number`/`json` text\n * is passed through raw, so the server's own validation names the problem.\n */\nexport function coerceInput(type: string, raw: string): unknown {\n if (raw === \"\") return undefined;\n switch (type) {\n case \"number\": {\n const n = Number(raw);\n return Number.isNaN(n) ? raw : n;\n }\n case \"boolean\":\n return raw === \"true\";\n case \"json\":\n try {\n return JSON.parse(raw);\n } catch {\n return raw;\n }\n default:\n return raw;\n }\n}\n"],"names":["targetRef","target","targetIsBound","implToTarget","impl","targetToImpl","paramsToFields","params","p","field","fieldsFromWorkflow","workflow","ctx","_a","_b","steps","seen","out","step","app","defs","def","key","INPUT_TYPES","shouldSeed","args","normalizeType","type","mergeSeed","rows","fields","appended","isFieldVisible","effective","c","v","x","hasUsableDefault","d","uncoveredRequiredKeys","values","covered","r","f","inputsForSave","opts","isFedValue","coveredRowsFromWith","withBlock","uncoveredForEndpoint","uncoveredForFunction","coerceInput","raw","n"],"mappings":"AAsIO,SAASA,EAAUC,GAA4B;AACpD,SAAIA,EAAO,SAAS,WAAiB,KACjCA,EAAO,SAAS,aAAmBA,EAAO,WACvCA,EAAO,SAAS,aAAaA,EAAO,WAAWA,EAAO;AAC/D;AAGO,SAASC,EAAcD,GAA6B;AACzD,SAAIA,EAAO,SAAS,WAAiB,GAAQA,EAAO,KAAK,OAAOA,EAAO,KAAK,UACrE,EAAQD,EAAUC,CAAM;AACjC;AAWO,SAASE,EACdC,GACuC;AAEvC,SAAKA,IAGDA,EAAK,SAAS,aAAmB,EAAE,MAAM,YAAY,UAAUA,EAAK,SAAA,IACpEA,EAAK,SAAS,aAAmB,EAAE,MAAM,YAAY,UAAUA,EAAK,SAAA,IACjE,EAAE,MAAM,UAAU,MAAMA,EAAK,MAAM,MAAMA,EA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/C,SAAOO;AACT;AAaO,SAASoB,EAAqBxB,GAIxB;AACX,QAAM,EAAE,QAAAxB,GAAQ,MAAA4B,GAAM,QAAAC,EAAA,IAAWL;AACjC,SAAIxB,EAAO,SAAS,WACdA,EAAO,SAAS,SAAkB,CAAA,IAC/BsC,EAAsBQ,EAAoB9C,EAAO,IAAI,GAAG6B,GAAQ7B,EAAO,IAAI,IAEhF4B,EAAK,WAAW,IAAU,CAAA,IACvBU,EAAsBV,GAAMC,CAAM;AAC3C;AAQO,SAASoB,EAAqBzB,GAGxB;AAEX,SAAKA,EAAK,OAGHc;AAAA,IACLQ,EAAoBtB,EAAK,KAAK,QAAQ,CAAA,CAAE;AAAA,IACxCA,EAAK;AAAA,IACLA,EAAK,KAAK,QAAQ,CAAA;AAAA,EAAC,IALZA,EAAK,OAAO,OAAO,CAACkB,MAAMA,EAAE,QAAQ,EAAE,IAAI,CAACA,MAAMA,EAAE,GAAG;AAOjE;AC9IO,SAASQ,EAAYxB,GAAcyB,GAAsB;AAC9D,MAAIA,MAAQ;AACZ,YAAQzB,GAAA;AAAA,MACN,KAAK,UAAU;AACb,cAAM0B,IAAI,OAAOD,CAAG;AACpB,eAAO,OAAO,MAAMC,CAAC,IAAID,IAAMC;AAAA,MACjC;AAAA,MACA,KAAK;AACH,eAAOD,MAAQ;AAAA,MACjB,KAAK;AACH,YAAI;AACF,iBAAO,KAAK,MAAMA,CAAG;AAAA,QACvB,QAAQ;AACN,iBAAOA;AAAA,QACT;AAAA,MACF;AACE,eAAOA;AAAA,IAAA;AAEb;"}
@@ -0,0 +1,78 @@
1
+ import { useQuery as s, useQueryClient as i, useMutation as u } from "@tanstack/react-query";
2
+ import { u as o } from "./client-context-CX61Bgw-.js";
3
+ const y = (n) => ["app-connections", n];
4
+ function l(n, e) {
5
+ return n.console.connections.listForApp(e);
6
+ }
7
+ function F(n, e = !0) {
8
+ const t = o();
9
+ return s({
10
+ queryKey: y(n),
11
+ queryFn: () => l(t, n),
12
+ enabled: e
13
+ });
14
+ }
15
+ const c = ["connections"];
16
+ function f(n) {
17
+ return n.connections.list();
18
+ }
19
+ function Q() {
20
+ const n = o();
21
+ return s({ queryKey: c, queryFn: () => f(n) });
22
+ }
23
+ const r = (n) => ["connection", n];
24
+ function p(n, e) {
25
+ return n.console.connections.get(e);
26
+ }
27
+ function m(n) {
28
+ const e = o();
29
+ return s({ queryKey: r(n), queryFn: () => p(e, n) });
30
+ }
31
+ function d(n, e, t) {
32
+ return n.console.connections.create(e, t);
33
+ }
34
+ function q(n, e, t) {
35
+ return n.console.connections.update(e, t);
36
+ }
37
+ function v(n) {
38
+ const e = o(), t = i();
39
+ return u({
40
+ mutationFn: (a) => q(e, n, a),
41
+ onSuccess: () => {
42
+ t.invalidateQueries({ queryKey: c }), t.invalidateQueries({ queryKey: r(n) });
43
+ }
44
+ });
45
+ }
46
+ function A(n) {
47
+ const e = o(), t = i();
48
+ return u({
49
+ mutationFn: () => e.console.connections.test(n),
50
+ onSuccess: () => {
51
+ t.invalidateQueries({ queryKey: r(n) }), t.invalidateQueries({ queryKey: c });
52
+ }
53
+ });
54
+ }
55
+ function M() {
56
+ const n = o(), e = i();
57
+ return u({
58
+ mutationFn: (t) => n.console.connections.delete(t),
59
+ onSuccess: () => e.invalidateQueries({ queryKey: c })
60
+ });
61
+ }
62
+ export {
63
+ y as a,
64
+ c as b,
65
+ r as c,
66
+ d,
67
+ l as e,
68
+ m as f,
69
+ p as g,
70
+ F as h,
71
+ Q as i,
72
+ M as j,
73
+ A as k,
74
+ f as l,
75
+ v as m,
76
+ q as u
77
+ };
78
+ //# sourceMappingURL=connections-CjjYeRqb.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connections-CjjYeRqb.js","sources":["../src/repos/connections.ts"],"sourcesContent":["/**\n * The connections-for-one-app repo — the Target selector's connection picker.\n *\n * Moved from Studio's `repos/connections.ts` (B-3a); the Studio file re-exports these names. The\n * client comes from `useEmbedClient()`. D-12e moved the rest of the file here (list, single,\n * create, update, test, delete); Studio's `repos/connections.ts` is now a pure re-export shim.\n */\nimport { useMutation, useQuery, useQueryClient } from \"@tanstack/react-query\";\nimport type { ConnectionSummary, W6WClient } from \"@w6w/sdk\";\nimport type { ConnectionTestResult } from \"@w6w/sdk/console\";\nimport { useEmbedClient } from \"../draft/client-context.ts\";\n\nexport type { ConnectionSummary } from \"@w6w/sdk\";\n\nexport const connectionsForAppKey = (appId: string) => [\"app-connections\", appId] as const;\n\nexport function listConnectionsForApp(\n client: W6WClient,\n appId: string,\n): Promise<ConnectionSummary[]> {\n return client.console.connections.listForApp(appId);\n}\n\n/**\n * `enabled` defaults to `true`. `TargetSelector` passes `app !== \"\"` — its original\n * pre-migration guard, preserved exactly.\n */\nexport function useConnectionsForAppQuery(appId: string, enabled = true) {\n const client = useEmbedClient();\n return useQuery({\n queryKey: connectionsForAppKey(appId),\n queryFn: () => listConnectionsForApp(client, appId),\n enabled,\n });\n}\n\n// ── connections (list, all apps) ──────────────────────────────────────\n// BASE partner surface — client.connections.list() already exists. There is no\n// console.connections.list(); do NOT route this one through client.console.connections.\n\nexport const connectionsKey = [\"connections\"] as const;\n\nexport function listConnections(client: W6WClient): Promise<ConnectionSummary[]> {\n return client.connections.list();\n}\n\nexport function useConnectionsQuery() {\n const client = useEmbedClient();\n return useQuery({ queryKey: connectionsKey, queryFn: () => listConnections(client) });\n}\n\n// ── connection (single) ───────────────────────────────────────────────\n\nexport const connectionKey = (id: string) => [\"connection\", id] as const;\n\nexport function getConnection(client: W6WClient, id: string): Promise<ConnectionSummary> {\n return client.console.connections.get(id);\n}\n\nexport function useConnectionQuery(id: string) {\n const client = useEmbedClient();\n return useQuery({ queryKey: connectionKey(id), queryFn: () => getConnection(client, id) });\n}\n\n// ── create / update (plain fetchers) ──────────────────────────────────\n\nexport function createConnection(\n client: W6WClient,\n appId: string,\n body: {\n authKey: string;\n credential: Record<string, unknown>;\n displayName?: string;\n profile?: Record<string, unknown>;\n },\n): Promise<ConnectionSummary> {\n return client.console.connections.create(appId, body);\n}\n\n/** The write `W6WEmbedProvider` hands the ui adapter as `updateConnection` (the SDK adapter has none). */\nexport function updateConnection(\n client: W6WClient,\n id: string,\n body: { displayName?: string; credential?: Record<string, unknown> },\n): Promise<ConnectionSummary> {\n return client.console.connections.update(id, body);\n}\n\n// ── mutations ────────────────────────────────────────────────────────\n\nexport function useUpdateConnectionMutation(connectionId: string) {\n const client = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (body: { displayName?: string; credential?: Record<string, unknown> }) =>\n updateConnection(client, connectionId, body),\n onSuccess: () => {\n qc.invalidateQueries({ queryKey: connectionsKey });\n qc.invalidateQueries({ queryKey: connectionKey(connectionId) });\n },\n });\n}\n\nexport function useTestConnectionMutation(connectionId: string) {\n const client = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (): Promise<ConnectionTestResult> => client.console.connections.test(connectionId),\n onSuccess: () => {\n qc.invalidateQueries({ queryKey: connectionKey(connectionId) });\n qc.invalidateQueries({ queryKey: connectionsKey });\n },\n });\n}\n\nexport function useDeleteConnectionMutation() {\n const client = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (id: string) => client.console.connections.delete(id),\n onSuccess: () => qc.invalidateQueries({ queryKey: connectionsKey }),\n });\n}\n"],"names":["connectionsForAppKey","appId","listConnectionsForApp","client","useConnectionsForAppQuery","enabled","useEmbedClient","useQuery","connectionsKey","listConnections","useConnectionsQuery","connectionKey","id","getConnection","useConnectionQuery","createConnection","body","updateConnection","useUpdateConnectionMutation","connectionId","qc","useQueryClient","useMutation","useTestConnectionMutation","useDeleteConnectionMutation"],"mappings":";;AAcO,MAAMA,IAAuB,CAACC,MAAkB,CAAC,mBAAmBA,CAAK;AAEzE,SAASC,EACdC,GACAF,GAC8B;AAC9B,SAAOE,EAAO,QAAQ,YAAY,WAAWF,CAAK;AACpD;AAMO,SAASG,EAA0BH,GAAeI,IAAU,IAAM;AACvE,QAAMF,IAASG,EAAA;AACf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,IAAKC,EAAA;AACX,SAAOC,EAAY;AAAA,IACjB,YAAY,MAAqCnB,EAAO,QAAQ,YAAY,KAAKgB,CAAY;AAAA,IAC7F,WAAW,MAAM;AACf,MAAAC,EAAG,kBAAkB,EAAE,UAAUT,EAAcQ,CAAY,GAAG,GAC9DC,EAAG,kBAAkB,EAAE,UAAUZ,EAAA,CAAgB;AAAA,IACnD;AAAA,EAAA,CACD;AACH;AAEO,SAASgB,IAA8B;AAC5C,QAAMrB,IAASG,EAAA,GACTc,IAAKC,EAAA;AACX,SAAOC,EAAY;AAAA,IACjB,YAAY,CAACV,MAAeT,EAAO,QAAQ,YAAY,OAAOS,CAAE;AAAA,IAChE,WAAW,MAAMQ,EAAG,kBAAkB,EAAE,UAAUZ,GAAgB;AAAA,EAAA,CACnE;AACH;"}
@@ -0,0 +1,86 @@
1
+ import { parse as u } from "yaml";
2
+ function a(e) {
3
+ if (!e) return !1;
4
+ switch (e.kind) {
5
+ case "function":
6
+ case "endpoint":
7
+ case "workflow":
8
+ return !0;
9
+ default:
10
+ return !1;
11
+ }
12
+ }
13
+ function f(e) {
14
+ if (!e) return null;
15
+ switch (e.kind) {
16
+ case "function":
17
+ return { kind: "function", id: e.id, key: e.key, inputs: e.inputs, alias: e.alias };
18
+ case "endpoint":
19
+ return {
20
+ kind: "endpoint",
21
+ id: e.id,
22
+ key: e.key,
23
+ invokeUrl: e.invokeUrl,
24
+ invokeUrlByKey: e.invokeUrlByKey,
25
+ urlForm: e.urlForm,
26
+ alias: e.alias,
27
+ inputs: e.inputs
28
+ };
29
+ case "workflow":
30
+ return { kind: "workflow", id: e.id, displayName: e.label, key: e.key };
31
+ default:
32
+ return null;
33
+ }
34
+ }
35
+ function k({
36
+ resource: e,
37
+ target: n,
38
+ hasAdapter: r
39
+ }) {
40
+ return (n.kind === "function" || n.kind === "workflow") && n.kind === e.kind && n.id === e.id ? r ? "warn" : "block" : "allow";
41
+ }
42
+ function o(e) {
43
+ let n;
44
+ if (e.format === "json")
45
+ try {
46
+ n = JSON.parse(e.content);
47
+ } catch {
48
+ return null;
49
+ }
50
+ else if (e.format === "yaml")
51
+ try {
52
+ n = u(e.content);
53
+ } catch {
54
+ return null;
55
+ }
56
+ else
57
+ return null;
58
+ return typeof n != "object" || n === null || Array.isArray(n) ? null : n;
59
+ }
60
+ function d(e) {
61
+ return e.map((n) => {
62
+ const r = o(n);
63
+ if (!r) return { key: n.key };
64
+ const i = Object.keys(r);
65
+ return i.length > 0 ? { key: n.key, fields: i.map((t) => ({ key: t })) } : { key: n.key };
66
+ });
67
+ }
68
+ function y(e) {
69
+ const n = {};
70
+ for (const r of e) {
71
+ n[`documents.${r.key}`] = r.content;
72
+ const i = o(r);
73
+ if (i)
74
+ for (const [t, l] of Object.entries(i))
75
+ n[`documents.${r.key}.${t}`] = l;
76
+ }
77
+ return n;
78
+ }
79
+ export {
80
+ y as d,
81
+ k as e,
82
+ a as i,
83
+ d as p,
84
+ f as t
85
+ };
86
+ //# sourceMappingURL=document-sources-C0grrtdq.js.map