@w6w/embed 0.2.30 → 0.2.32

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 (67) hide show
  1. package/dist/{CreateFunctionModal-CCYi9deY.js → CreateFunctionModal-glk2zg1r.js} +28 -27
  2. package/dist/{CreateFunctionModal-CCYi9deY.js.map → CreateFunctionModal-glk2zg1r.js.map} +1 -1
  3. package/dist/{DocumentFormModal-B3VudaLb.js → DocumentFormModal-Cw85R4wk.js} +2 -2
  4. package/dist/{DocumentFormModal-B3VudaLb.js.map → DocumentFormModal-Cw85R4wk.js.map} +1 -1
  5. package/dist/{ImportSpecModal-C-B8Jwxk.js → ImportSpecModal-fU5RsVTa.js} +2 -2
  6. package/dist/{ImportSpecModal-C-B8Jwxk.js.map → ImportSpecModal-fU5RsVTa.js.map} +1 -1
  7. package/dist/WorkflowEditor-C7oudiIb.js +1169 -0
  8. package/dist/WorkflowEditor-C7oudiIb.js.map +1 -0
  9. package/dist/callable-record-Bhxim8C1.js +14 -0
  10. package/dist/callable-record-Bhxim8C1.js.map +1 -0
  11. package/dist/callables-B49tS2vv.js +297 -0
  12. package/dist/callables-B49tS2vv.js.map +1 -0
  13. package/dist/{document-sources-DNmBojx6.js → document-sources-Khcw2zB5.js} +16 -16
  14. package/dist/document-sources-Khcw2zB5.js.map +1 -0
  15. package/dist/draft.mjs +1 -1
  16. package/dist/editor/WorkflowEditor.d.ts +2 -1
  17. package/dist/editor/WorkflowInputsModal.d.ts +12 -0
  18. package/dist/editor/WorkflowVariablesEditor.d.ts +1 -1
  19. package/dist/{editor-tools-BIAW-wzt.js → editor-tools-Dn7TgCP4.js} +566 -486
  20. package/dist/editor-tools-Dn7TgCP4.js.map +1 -0
  21. package/dist/editor.mjs +1 -1
  22. package/dist/editors.mjs +81 -80
  23. package/dist/editors.mjs.map +1 -1
  24. package/dist/endpoints-zOuwci2U.js +136 -0
  25. package/dist/endpoints-zOuwci2U.js.map +1 -0
  26. package/dist/fields-CXHRR5eK.js +28 -0
  27. package/dist/fields-CXHRR5eK.js.map +1 -0
  28. package/dist/forms.mjs +1 -1
  29. package/dist/index.mjs +91 -91
  30. package/dist/index.mjs.map +1 -1
  31. package/dist/lib/callable-duplicate.d.ts +26 -0
  32. package/dist/lib/settings-rail.d.ts +12 -0
  33. package/dist/lib/variable-preview.d.ts +6 -0
  34. package/dist/lib.mjs +41 -40
  35. package/dist/lib.mjs.map +1 -1
  36. package/dist/lists/CallableKindList.d.ts +4 -1
  37. package/dist/lists/CallableRowParts.d.ts +5 -0
  38. package/dist/lists/CredentialDetail.d.ts +2 -0
  39. package/dist/lists/CredentialFields.d.ts +1 -1
  40. package/dist/lists/EndpointList.d.ts +2 -1
  41. package/dist/lists/WorkflowList.d.ts +2 -1
  42. package/dist/lists.mjs +1509 -1421
  43. package/dist/lists.mjs.map +1 -1
  44. package/dist/rail.mjs +1 -1
  45. package/dist/repos/callables.d.ts +23 -0
  46. package/dist/repos/fields.d.ts +4 -1
  47. package/dist/repos.mjs +242 -239
  48. package/dist/settings-rail-gUU2ZbSw.js +36 -0
  49. package/dist/settings-rail-gUU2ZbSw.js.map +1 -0
  50. package/dist/{spec-import-FygyV8sy.js → spec-import-CGPqUUjN.js} +2 -2
  51. package/dist/{spec-import-FygyV8sy.js.map → spec-import-CGPqUUjN.js.map} +1 -1
  52. package/dist/{use-callable-draft-DCauHt5o.js → use-callable-draft-w4tDTYcb.js} +8 -7
  53. package/dist/{use-callable-draft-DCauHt5o.js.map → use-callable-draft-w4tDTYcb.js.map} +1 -1
  54. package/package.json +3 -3
  55. package/src/styles.css +174 -40
  56. package/dist/WorkflowEditor-8NAcpjO_.js +0 -1140
  57. package/dist/WorkflowEditor-8NAcpjO_.js.map +0 -1
  58. package/dist/callables-tOlflvbl.js +0 -151
  59. package/dist/callables-tOlflvbl.js.map +0 -1
  60. package/dist/document-sources-DNmBojx6.js.map +0 -1
  61. package/dist/editor-tools-BIAW-wzt.js.map +0 -1
  62. package/dist/endpoints-DArAqoLT.js +0 -233
  63. package/dist/endpoints-DArAqoLT.js.map +0 -1
  64. package/dist/fields-DvS8XZFc.js +0 -21
  65. package/dist/fields-DvS8XZFc.js.map +0 -1
  66. package/dist/settings-rail--GdRMusb.js +0 -33
  67. package/dist/settings-rail--GdRMusb.js.map +0 -1
@@ -0,0 +1,136 @@
1
+ import { useQueryClient as c, useMutation as s } from "@tanstack/react-query";
2
+ import { path as d } from "@w6w/sdk";
3
+ import { u as a } from "./client-context-CX61Bgw-.js";
4
+ import { a as l, c as f, p, r as m, u as b, q as F, i as r, v as M } from "./callables-B49tS2vv.js";
5
+ import "@w6w/sdk/console";
6
+ const h = f("function"), w = "2";
7
+ function Q(n) {
8
+ return n.console.functions.list();
9
+ }
10
+ function K(n = !0) {
11
+ return F("function", n);
12
+ }
13
+ const v = (n) => l("function", n);
14
+ function O(n, t) {
15
+ return n.console.functions.get(t);
16
+ }
17
+ function T(n, t = !0) {
18
+ return b("function", n, t);
19
+ }
20
+ function g() {
21
+ return M("function");
22
+ }
23
+ function A() {
24
+ const n = a(), t = c();
25
+ return s({
26
+ mutationFn: (i) => n.console.functions.upsert(i.definition, {
27
+ ifUnmodifiedSince: i.ifUnmodifiedSince
28
+ }),
29
+ onSuccess: (i) => r(t, h, v(i.id))
30
+ });
31
+ }
32
+ function E(n, t, i, e) {
33
+ const u = { inputs: i };
34
+ return (e == null ? void 0 : e.allowUnpublished) === !0 && (u.allowUnpublished = !0), n.request({
35
+ method: "POST",
36
+ path: d`/functions/${t}/invoke`,
37
+ body: u
38
+ }).then(({ body: o }) => ({
39
+ output: o.output,
40
+ invocationId: o.invocationId,
41
+ status: o.status,
42
+ durationMs: o.durationMs
43
+ }));
44
+ }
45
+ function D() {
46
+ const n = a();
47
+ return s({
48
+ mutationFn: (t) => E(n, t.id, t.inputs, { allowUnpublished: !0 })
49
+ });
50
+ }
51
+ function _() {
52
+ return p("function");
53
+ }
54
+ function P() {
55
+ return m("function");
56
+ }
57
+ function x(n) {
58
+ return n.status !== void 0 ? n.status !== "ready" : n.incomplete === !0;
59
+ }
60
+ const G = "2", S = f("endpoint");
61
+ function L(n = !0) {
62
+ return F("endpoint", n);
63
+ }
64
+ function R(n, t) {
65
+ return n.console.endpoints.get(t);
66
+ }
67
+ const y = (n) => l("endpoint", n);
68
+ function V(n, t = !0) {
69
+ return b("endpoint", n, t);
70
+ }
71
+ function $() {
72
+ const n = a(), t = c();
73
+ return s({
74
+ // Same widening as `getEndpoint` — the save's 201 carries `invokeUrls[]` too.
75
+ mutationFn: (i) => n.console.endpoints.upsert(i),
76
+ onSuccess: (i) => r(t, S, y(i.endpoint.id))
77
+ });
78
+ }
79
+ function j() {
80
+ const n = a(), t = c();
81
+ return s({
82
+ mutationFn: (i) => n.console.endpoints.upsert(i.definition, {
83
+ ifUnmodifiedSince: i.ifUnmodifiedSince
84
+ }),
85
+ onSuccess: (i) => r(t, S, y(i.endpoint.id))
86
+ });
87
+ }
88
+ function C(n, t, i, e) {
89
+ const u = { input: i };
90
+ return (e == null ? void 0 : e.allowUnpublished) === !0 && (u.allowUnpublished = !0), n.request({
91
+ method: "POST",
92
+ path: d`/endpoints/${t}/invoke`,
93
+ body: u
94
+ }).then((o) => o.body);
95
+ }
96
+ function z() {
97
+ const n = a();
98
+ return s({
99
+ mutationFn: (t) => C(n, t.id, t.input, { allowUnpublished: !0 })
100
+ });
101
+ }
102
+ function B() {
103
+ return p("endpoint");
104
+ }
105
+ function H() {
106
+ return m("endpoint");
107
+ }
108
+ export {
109
+ G as E,
110
+ w as F,
111
+ $ as a,
112
+ K as b,
113
+ g as c,
114
+ S as d,
115
+ y as e,
116
+ v as f,
117
+ h as g,
118
+ R as h,
119
+ O as i,
120
+ C as j,
121
+ E as k,
122
+ x as l,
123
+ Q as m,
124
+ B as n,
125
+ _ as o,
126
+ H as p,
127
+ P as q,
128
+ V as r,
129
+ T as s,
130
+ j as t,
131
+ L as u,
132
+ A as v,
133
+ z as w,
134
+ D as x
135
+ };
136
+ //# sourceMappingURL=endpoints-zOuwci2U.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"endpoints-zOuwci2U.js","sources":["../src/repos/functions.ts","../src/repos/endpoints.ts"],"sourcesContent":["import { useMutation, useQueryClient } from \"@tanstack/react-query\";\nimport { path, type W6WClient } from \"@w6w/sdk\";\nimport type { FunctionSummary as SdkFunctionSummary } from \"@w6w/sdk/console\";\nimport { useEmbedClient } from \"../draft/client-context.ts\";\n/**\n * The Function-bound facade over the kind-parametrised repo (`src/repos/callables.ts`, T4.2.1).\n *\n * Everything here that is not Function-specific is one line delegating to `callables.ts` with\n * `\"function\"` bound in — the list/get queries, the save mutation, archive and delete — so the\n * Function arm of every kind-wide behaviour has exactly ONE implementation to fix. What stays is\n * what only a Function has: the `manifestVersion: \"2\"` literal, the SDK's Function type re-exports,\n * the `valid`-carrying summary widening, and the run-plane invoke (`client.request`)\n * that no other kind's page uses.\n *\n * The delegations keep their original names and call shapes on purpose: `ui/rail/SettingsTool.tsx`,\n * `ui/rail/AliasesTool.tsx`, `ui/rail/ErrorHandlingTool.tsx`, `components/TargetSelector.tsx`,\n * `components/FunctionIdentityModal.tsx` and `api/w6wApiFacade.tsx` all import from here, and this\n * node moves no behaviour — only where the code lives.\n */\nimport { callableKey } from \"../lib/callable-kind.ts\";\nimport { invalidateSavedCallable } from \"../lib/save-invalidation.ts\";\nimport {\n callableListKey,\n useArchiveCallableMutation,\n useCallableListQuery,\n useCallableQuery,\n useDeleteCallableMutation,\n useSaveCallableMutation,\n} from \"./callables.ts\";\n\nexport type {\n FunctionDef,\n FunctionImpl,\n FunctionInput,\n FunctionOutputField,\n} from \"@w6w/sdk/console\";\n\n/** A Function list row — the SDK's own summary (it carries `archivedAt` since W-12). */\nexport type FunctionSummary = SdkFunctionSummary;\n\n/** The list key {@link useFunctionsQuery} reads — `callables.ts`'s own\n * `callableListKey(\"function\")`, kept as a named export because\n * `lib/spec-import-invalidation.ts` invalidates it by value. */\nexport const functionsKey = callableListKey(\"function\");\n\n/** Function definitions carry `manifestVersion: \"2\"` - the one literal, shared\n * by the editor's blank draft and the create modal's first POST. */\nexport const FUNCTION_MANIFEST_VERSION = \"2\";\n\nexport function listFunctions(client: W6WClient) {\n return client.console.functions.list();\n}\n\nexport function useFunctionsQuery(enabled = true) {\n return useCallableListQuery<FunctionSummary>(\"function\", enabled);\n}\n\nexport const functionKey = (id: string) => callableKey(\"function\", id);\n\n/** The Function arm's own reader: the SDK's typed `get`, whose `{...function, valid}` splice is\n * what `FunctionEditor` hydrates its draft from (pin 5 — the server computes `valid`; studio\n * never reimplements the check). */\nexport function getFunction(client: W6WClient, id: string) {\n return client.console.functions.get(id);\n}\n\nexport function useFunctionQuery(id: string, enabled = true) {\n return useCallableQuery<Awaited<ReturnType<typeof getFunction>>>(\"function\", id, enabled);\n}\n\nexport function useSaveFunctionMutation() {\n return useSaveCallableMutation(\"function\");\n}\n\n/**\n * The GUARDED Function save: `console.functions.upsert(definition, {ifUnmodifiedSince})`, so a\n * save made from a stale copy answers `409 function_stale` instead of overwriting the newer one.\n * `ifUnmodifiedSince` is REQUIRED in the variables (pass `null` to opt out explicitly) so a call\n * site cannot forget the token; it is the `updatedAt` of the copy the definition was edited from\n * (`callableRecord(\"function\", …).updatedAt`). Same invalidation as {@link useSaveFunctionMutation}\n * (list + the saved resource's key); resolves `{id, key, updatedAt}`. Additive: the unguarded\n * hook's `mutate(definition)` shape is unchanged.\n */\nexport function useGuardedSaveFunctionMutation() {\n const apiClient = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (vars: { definition: unknown; ifUnmodifiedSince: string | null }) =>\n apiClient.console.functions.upsert(vars.definition as never, {\n ifUnmodifiedSince: vars.ifUnmodifiedSince,\n }),\n onSuccess: (saved) => invalidateSavedCallable(qc, functionsKey, functionKey(saved.id)),\n });\n}\n\n/**\n * One test invoke's result: the Function's own output, plus the platform's\n * record of the attempt.\n *\n * The two are kept apart rather than merged because they answer different\n * questions, and merging them is what the invocation envelope exists to stop:\n * a vendor payload reading `{\"statusCode\": 202}` is SendGrid describing its own\n * request, while `status` here is whether w6w considered the call a success.\n * The frame fields are optional — an older server sends only the output.\n */\nexport interface FunctionInvokeResult {\n output: unknown;\n invocationId?: string;\n status?: string;\n durationMs?: number;\n}\n\n/**\n * `POST /functions/:id/invoke` through the `client.request` escape hatch (D2: no wrappers change).\n * The route answers the invocation frame `{ kind: \"function\", output, invocationId, status,\n * durationMs }`. `allowUnpublished: true` is sent ONLY when the caller opts in (the editor's Test\n * invoke hook); every other caller keeps the publish gate, so the key is absent otherwise.\n */\nexport function invokeFunction(\n client: W6WClient,\n id: string,\n inputs: Record<string, unknown>,\n opts?: { allowUnpublished?: boolean },\n): Promise<FunctionInvokeResult> {\n const body: Record<string, unknown> = { inputs };\n if (opts?.allowUnpublished === true) body.allowUnpublished = true;\n return client\n .request<Record<string, unknown>>({\n method: \"POST\",\n path: path`/functions/${id}/invoke`,\n body,\n })\n .then(({ body: res }) => ({\n output: res.output,\n invocationId: res.invocationId as string | undefined,\n status: res.status as string | undefined,\n durationMs: res.durationMs as number | undefined,\n }));\n}\n\nexport function useInvokeFunctionMutation() {\n const apiClient = useEmbedClient();\n return useMutation({\n mutationFn: (vars: { id: string; inputs: Record<string, unknown> }) =>\n invokeFunction(apiClient, vars.id, vars.inputs, { allowUnpublished: true }),\n });\n}\n\n/**\n * T4.1.1/A7/D-I0-7: `POST /functions/:id/archive`, `DELETE /functions/:id` — the Function arm of\n * `callables.ts`'s generic pair (the plain `apiClient.request()` escape hatch, NOT a typed\n * `@w6w/sdk` method, which would drag `packages/wrappers` into this task's scope for two internal\n * routes). Both invalidate `functionsKey`, so the list's `archivedAt` refreshes and the rail's\n * Delete control appears in Archive's place.\n */\nexport function useArchiveFunctionMutation() {\n return useArchiveCallableMutation(\"function\");\n}\n\nexport function useDeleteFunctionMutation() {\n return useDeleteCallableMutation(\"function\");\n}\n","import { useMutation, useQueryClient } from \"@tanstack/react-query\";\nimport { path, type W6WClient } from \"@w6w/sdk\";\nimport type {\n EndpointInvokeResult,\n EndpointDef as SdkEndpointDef,\n EndpointSummary as SdkEndpointSummary,\n EndpointTarget as SdkEndpointTarget,\n} from \"@w6w/sdk/console\";\n/**\n * The Endpoint-bound facade over the kind-parametrised repo (`src/repos/callables.ts`, T4.2.2).\n *\n * Everything here that is not Endpoint-specific is one line delegating to `callables.ts` with\n * `\"endpoint\"` bound in — the list/get queries, archive and delete — so the Endpoint arm of every\n * kind-wide behaviour has exactly ONE implementation to fix (the shape `repos/functions.ts` took in\n * T4.2.1, and the \"keep the facade's exports\" rule that module documents). What stays is what only\n * an Endpoint has: the `manifestVersion: \"2\"` literal, the SDK's Endpoint type re-exports, the\n * `status`/`incomplete`/`archivedAt`-carrying summary widening with its one reader\n * {@link isEndpointDraft}, the server-rendered `invokeUrls[]` widening, the synchronous invoke\n * (`client.console.endpoints.invoke`), and the SAVE — whose 201 carries those `invokeUrls[]` back to\n * the editor's URL card, which is why its `mutationFn` is the one arm the generic `saveCallable`\n * cannot serve.\n *\n * The delegations keep their original names and call shapes on purpose: `ui/rail/SettingsTool.tsx`,\n * `ui/rail/AliasesTool.tsx`, `ui/rail/ErrorHandlingTool.tsx`, `components/TargetSelector.tsx`,\n * `components/EndpointIdentityModal.tsx`, `repos/versions.ts` (the revert arm's `endpointKey`) and\n * `repos/spec-import.ts` (`endpointsKey`) all import from here, and this node moves no behaviour —\n * only where the code lives. The two key exports stay byte-identical because both are the builders\n * `callables.ts` already documents as frozen (`[\"endpoints\"]`, `[\"endpoint\", id]`).\n */\nimport { callableKey } from \"../lib/callable-kind.ts\";\nimport { invalidateSavedCallable } from \"../lib/save-invalidation.ts\";\n\nexport type {\n ActionTarget,\n CallableRef,\n CallableOnError,\n ErrorHandlerTarget,\n EndpointAuthMode,\n EndpointInput,\n EndpointInvokeResult,\n EndpointSecurity,\n EndpointTarget,\n ErrorReroute,\n Exposure,\n RetryPolicy,\n} from \"@w6w/sdk/console\";\nexport { SECRET_MASK } from \"@w6w/sdk/console\";\nimport { useEmbedClient } from \"../draft/client-context.ts\";\nimport {\n callableListKey,\n useArchiveCallableMutation,\n useCallableListQuery,\n useCallableQuery,\n useDeleteCallableMutation,\n} from \"./callables.ts\";\n\n/** An Endpoint's OWN target: the alias-only `endpoint` arm excluded, mirroring the\n * server fence in admin/endpoints.ts's validateDefinition. Aliases use the full union\n * (`EndpointTarget`, re-exported above verbatim). */\nexport type EndpointOwnTarget = Exclude<SdkEndpointTarget, { kind: \"endpoint\" }>;\nexport type EndpointDef = Omit<SdkEndpointDef, \"target\"> & { target: EndpointOwnTarget };\n\n/**\n * One entry of the `invokeUrls[]` array the server renders on `GET\n * /endpoints/:id` and the `POST /endpoints` 201 (T3.4.1, `admin/endpoints.ts`'s\n * `InvokeUrlEntry` — the shapes are kept in sync by hand, not shared, because\n * `@w6w/sdk` does not type this field yet: it is server-fresh and\n * `packages/wrappers` publishes in lockstep at one `VERSION` across four\n * languages, outside this project's boundary (HITL-10). `entries[0]` is always\n * the platform entry; every entry after it is one of the tenant's domains.\n * `default` mirrors the tenant's stored default domain and, since D-S1\n * (intake T-0.2), it is what CHOOSES the open-on entry: absent an\n * in-session pick, the URL card opens on whichever entry carries it,\n * falling back to `entries[0]` only when no entry does. `resolves` is a\n * static host comparison the server already made; the client never\n * re-derives it.\n */\nexport interface InvokeUrlOption {\n domain: string;\n default: boolean;\n url: string;\n urlByKey?: string;\n resolves: boolean;\n}\n\n/** The two SDK-typed URL fields, widened with the untyped `invokeUrls[]`\n * array — the ONE seam `getEndpoint`, the save mutation and the editor's own\n * 201 read all widen through, so `EndpointsPage.tsx` never casts. */\ntype WithInvokeUrls = {\n invokeUrl: string;\n invokeUrlByKey?: string;\n invokeUrls?: InvokeUrlOption[];\n};\n\n/** An Endpoint list row — the SDK's own summary (`status`, `incomplete` and `archivedAt` are\n * on it since W-12), read for draft-ness only through {@link isEndpointDraft}. */\nexport type EndpointSummary = SdkEndpointSummary;\n\n/** Is this row a draft — not authorised to dispatch (HITL-7/HITL-8,\n * `rfcs/endpoint.md` § Amendment — 2026-08-14b)? Prefers the server's `status`\n * field (`!== \"ready\"`), falling back to the older `incomplete` boolean only\n * when `status` is absent (a server that has not shipped it yet). The sole\n * reader of both fields in studio; every \"unfinished\" UI decision (the\n * list's tag, and any future one) calls this rather than reading either\n * field inline. */\nexport function isEndpointDraft(ep: Pick<EndpointSummary, \"status\" | \"incomplete\">): boolean {\n return ep.status !== undefined ? ep.status !== \"ready\" : ep.incomplete === true;\n}\n\n/** Endpoint definitions carry `manifestVersion: \"2\"` — the one literal, shared\n * by the editor's blank draft and the create modal's first POST. */\nexport const ENDPOINT_MANIFEST_VERSION = \"2\";\n\n/** The list key {@link useEndpointsQuery} reads — `callables.ts`'s own\n * `callableListKey(\"endpoint\")` (byte-identical `[\"endpoints\"]`), kept as a named export because\n * `repos/spec-import.ts` invalidates it by value. */\nexport const endpointsKey = callableListKey(\"endpoint\");\n\nexport function useEndpointsQuery(enabled = true) {\n return useCallableListQuery<EndpointSummary>(\"endpoint\", enabled);\n}\n\n/** Fetch one Endpoint. Widens the SDK's return once — the server sends\n * `invokeUrls[]` (T3.4.1) that `@w6w/sdk`'s typed `get()` does not know about\n * yet; see {@link WithInvokeUrls}. */\nexport function getEndpoint(\n client: W6WClient,\n id: string,\n): Promise<{ endpoint: EndpointDef } & WithInvokeUrls> {\n return client.console.endpoints.get(id) as Promise<{ endpoint: EndpointDef } & WithInvokeUrls>;\n}\n\n/** The single-resource key — `callables.ts`'s own `callableKey(\"endpoint\", id)` (byte-identical\n * `[\"endpoint\", id]`), kept as a named export because `repos/versions.ts`'s revert arm invalidates\n * it by value. */\nexport const endpointKey = (id: string) => callableKey(\"endpoint\", id);\n\n/** `TargetSelector`'s `endpoint` arm needs one Endpoint's own `input` contract\n * to project into fields — mirrors `useFunctionQuery`/`useWorkflowQuery`\n * (`repos/functions.ts`/`repos/workflows.ts`) exactly. */\nexport function useEndpointQuery(id: string, enabled = true) {\n return useCallableQuery<Awaited<ReturnType<typeof getEndpoint>>>(\"endpoint\", id, enabled);\n}\n\n/**\n * The Endpoint arm's SAVE — the one delegated name whose `mutationFn` is NOT `callables.ts`'s\n * `saveCallable`: that helper normalises every kind's success envelope down to `{id, key}` for the\n * invalidation below, while this kind's 201 also carries the fresh server-rendered `invokeUrl`/\n * `invokeUrlByKey`/`invokeUrls[]` the editor's URL card renders from (`onSaveSuccess` in\n * `EndpointsPage.tsx`). Its KEYS and its invalidation, though, are the generic pair's — so the\n * \"which keys does an Endpoint save refresh\" answer still has one home.\n */\nexport function useSaveEndpointMutation() {\n const apiClient = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n // Same widening as `getEndpoint` — the save's 201 carries `invokeUrls[]` too.\n mutationFn: (definition: unknown) =>\n apiClient.console.endpoints.upsert(definition as never) as Promise<\n { endpoint: { id: string; key: string } } & WithInvokeUrls\n >,\n onSuccess: (saved) => invalidateSavedCallable(qc, endpointsKey, endpointKey(saved.endpoint.id)),\n });\n}\n\n/**\n * The GUARDED Endpoint save: `console.endpoints.upsert(definition, {ifUnmodifiedSince})`, so a\n * save from a stale copy answers `409 endpoint_stale`. Variables and invalidation as\n * {@link useSaveEndpointMutation}'s, plus the required token (`null` opts out explicitly; it is\n * `callableRecord(\"endpoint\", …).updatedAt`, the envelope's TOP-LEVEL `updatedAt`). Resolves the\n * verbatim upsert body (`{endpoint:{id,key}, invokeUrl, …, updatedAt}`). Additive: the unguarded\n * hook's `mutate(definition)` shape is unchanged.\n */\nexport function useGuardedSaveEndpointMutation() {\n const apiClient = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (vars: { definition: unknown; ifUnmodifiedSince: string | null }) =>\n apiClient.console.endpoints.upsert(vars.definition as never, {\n ifUnmodifiedSince: vars.ifUnmodifiedSince,\n }) as Promise<{ endpoint: { id: string; key: string }; updatedAt: string } & WithInvokeUrls>,\n onSuccess: (saved) => invalidateSavedCallable(qc, endpointsKey, endpointKey(saved.endpoint.id)),\n });\n}\n\n/**\n * `POST /endpoints/:id/invoke` through `client.request` (D2). Answers `{ kind, output }`, or a 202\n * `{ kind: \"workflow\", runId }` (success). `allowUnpublished: true` only when the caller opts in.\n */\nexport function invokeEndpoint(\n client: W6WClient,\n id: string,\n input: Record<string, unknown>,\n opts?: { allowUnpublished?: boolean },\n): Promise<EndpointInvokeResult> {\n const body: Record<string, unknown> = { input };\n if (opts?.allowUnpublished === true) body.allowUnpublished = true;\n return client\n .request<EndpointInvokeResult>({\n method: \"POST\",\n path: path`/endpoints/${id}/invoke`,\n body,\n })\n .then((res) => res.body as EndpointInvokeResult);\n}\n\nexport function useInvokeEndpointMutation() {\n const apiClient = useEmbedClient();\n return useMutation({\n mutationFn: (vars: { id: string; input: Record<string, unknown> }) =>\n invokeEndpoint(apiClient, vars.id, vars.input, { allowUnpublished: true }),\n });\n}\n\n/**\n * T4.1.1/A7/D-I0-7: `POST /endpoints/:id/archive` — the Endpoint arm of `callables.ts`'s generic\n * pair (the plain `apiClient.request()` escape hatch, NOT a typed `@w6w/sdk` method, which would\n * drag `packages/wrappers` into this task's scope for one internal route). Invalidates\n * `endpointsKey`, so the list's `archivedAt` refreshes and the rail's Delete control appears in\n * Archive's place.\n */\nexport function useArchiveEndpointMutation() {\n return useArchiveCallableMutation(\"endpoint\");\n}\n\n/** `DELETE /endpoints/:id` — the Endpoint arm of the same generic pair. */\nexport function useDeleteEndpointMutation() {\n return useDeleteCallableMutation(\"endpoint\");\n}\n"],"names":["functionsKey","callableListKey","FUNCTION_MANIFEST_VERSION","listFunctions","client","useFunctionsQuery","enabled","useCallableListQuery","functionKey","id","callableKey","getFunction","useFunctionQuery","useCallableQuery","useSaveFunctionMutation","useSaveCallableMutation","useGuardedSaveFunctionMutation","apiClient","useEmbedClient","qc","useQueryClient","useMutation","vars","saved","invalidateSavedCallable","invokeFunction","inputs","opts","body","path","res","useInvokeFunctionMutation","useArchiveFunctionMutation","useArchiveCallableMutation","useDeleteFunctionMutation","useDeleteCallableMutation","isEndpointDraft","ep","ENDPOINT_MANIFEST_VERSION","endpointsKey","useEndpointsQuery","getEndpoint","endpointKey","useEndpointQuery","useSaveEndpointMutation","definition","useGuardedSaveEndpointMutation","invokeEndpoint","input","useInvokeEndpointMutation","useArchiveEndpointMutation","useDeleteEndpointMutation"],"mappings":"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"}
@@ -0,0 +1,28 @@
1
+ import { path as n, ApiError as c } from "@w6w/sdk";
2
+ function l(t, i, s, e, r) {
3
+ return a(t, n`/apps/${i}/actions/${s}/fields`, e, r);
4
+ }
5
+ function u(t, i, s, e, r) {
6
+ return a(t, n`/apps/${i}/triggers/${s}/fields`, e, r);
7
+ }
8
+ async function a(t, i, s, e) {
9
+ try {
10
+ return (await t.request({
11
+ method: "POST",
12
+ path: i,
13
+ body: s,
14
+ signal: e == null ? void 0 : e.signal
15
+ })).body;
16
+ } catch (r) {
17
+ if (r instanceof c && r.status === 424)
18
+ return {
19
+ fields: Object.fromEntries(s.fields.map((o) => [o, { error: r.message }]))
20
+ };
21
+ throw r;
22
+ }
23
+ }
24
+ export {
25
+ u as a,
26
+ l as r
27
+ };
28
+ //# sourceMappingURL=fields-CXHRR5eK.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fields-CXHRR5eK.js","sources":["../src/repos/fields.ts"],"sourcesContent":["import type { W6WClient } from \"@w6w/sdk\";\nimport { path, ApiError } from \"@w6w/sdk\";\n/**\n * Dynamic-field resolution — `POST /apps/:id/actions/:key/fields` (and a trigger's subscription\n * form, `POST /apps/:id/triggers/:key/fields`) over `client.request()`.\n * A 424 (the vendor lookup failed) becomes a per-field error result so one bad lookup does not\n * blank the form; every other failure (400/403/404/network/abort) rethrows for the ui to handle.\n */\n\n/**\n * Structural mirror of ui's `W6WApi.resolveActionFields` shapes (this barrel may not import\n * `@w6w/ui`); the facade/UiBridge assignment typechecks against W6WApi structurally.\n */\nexport interface ResolveActionFieldsBody {\n connectionId: string;\n version?: string;\n reason: \"init\" | \"change\";\n form: Record<string, unknown>;\n previous?: Record<string, unknown>;\n changed?: string[];\n fields: string[];\n unresolved: string[];\n}\nexport interface ResolveActionFieldsResult {\n fields: Record<\n string,\n { options?: { value: string | number; label: string; description?: string }[]; error?: string }\n >;\n}\nexport interface ResolveActionFieldsOpts {\n signal?: AbortSignal;\n}\n\nexport function resolveActionFields(\n client: W6WClient,\n appId: string,\n actionKey: string,\n body: ResolveActionFieldsBody,\n opts?: ResolveActionFieldsOpts,\n): Promise<ResolveActionFieldsResult> {\n return postFields(client, path`/apps/${appId}/actions/${actionKey}/fields`, body, opts);\n}\n\n/** A trigger's subscription form: the same body, answers and 424 handling as an action's. */\nexport function resolveTriggerFields(\n client: W6WClient,\n appId: string,\n triggerKey: string,\n body: ResolveActionFieldsBody,\n opts?: ResolveActionFieldsOpts,\n): Promise<ResolveActionFieldsResult> {\n return postFields(client, path`/apps/${appId}/triggers/${triggerKey}/fields`, body, opts);\n}\n\nasync function postFields(\n client: W6WClient,\n url: string,\n body: ResolveActionFieldsBody,\n opts?: ResolveActionFieldsOpts,\n): Promise<ResolveActionFieldsResult> {\n try {\n const res = await client.request<ResolveActionFieldsResult>({\n method: \"POST\",\n path: url,\n body,\n signal: opts?.signal,\n });\n return res.body;\n } catch (err) {\n if (err instanceof ApiError && err.status === 424) {\n return {\n fields: Object.fromEntries(body.fields.map((k) => [k, { error: err.message }])),\n };\n }\n throw err;\n }\n}\n"],"names":["resolveActionFields","client","appId","actionKey","body","opts","postFields","path","resolveTriggerFields","triggerKey","url","err","ApiError","k"],"mappings":";AAiCO,SAASA,EACdC,GACAC,GACAC,GACAC,GACAC,GACoC;AACpC,SAAOC,EAAWL,GAAQM,UAAaL,CAAK,YAAYC,CAAS,WAAWC,GAAMC,CAAI;AACxF;AAGO,SAASG,EACdP,GACAC,GACAO,GACAL,GACAC,GACoC;AACpC,SAAOC,EAAWL,GAAQM,UAAaL,CAAK,aAAaO,CAAU,WAAWL,GAAMC,CAAI;AAC1F;AAEA,eAAeC,EACbL,GACAS,GACAN,GACAC,GACoC;AACpC,MAAI;AAOF,YANY,MAAMJ,EAAO,QAAmC;AAAA,MAC1D,QAAQ;AAAA,MACR,MAAMS;AAAA,MACN,MAAAN;AAAA,MACA,QAAQC,KAAA,gBAAAA,EAAM;AAAA,IAAA,CACf,GACU;AAAA,EACb,SAASM,GAAK;AACZ,QAAIA,aAAeC,KAAYD,EAAI,WAAW;AAC5C,aAAO;AAAA,QACL,QAAQ,OAAO,YAAYP,EAAK,OAAO,IAAI,CAACS,MAAM,CAACA,GAAG,EAAE,OAAOF,EAAI,QAAA,CAAS,CAAC,CAAC;AAAA,MAAA;AAGlF,UAAMA;AAAA,EACR;AACF;"}
package/dist/forms.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import { C as _e, a as Je } from "./CreateFunctionModal-CCYi9deY.js";
2
+ import { C as _e, a as Je } from "./CreateFunctionModal-glk2zg1r.js";
3
3
  import { jsx as t, jsxs as l, Fragment as te } from "react/jsx-runtime";
4
4
  import { ApiError as I } from "@w6w/sdk";
5
5
  import { EmptyState as A, DataTable as P, RowActionsMenu as U, useEnterSubmit as T, BudgetMeter as ie } from "@w6w/ui";
package/dist/index.mjs CHANGED
@@ -1,130 +1,130 @@
1
1
  "use client";
2
- import { jsx as c, jsxs as N } from "react/jsx-runtime";
2
+ import { jsx as l, jsxs as N } from "react/jsx-runtime";
3
3
  import { QueryClientProvider as O, QueryClient as G, useQuery as z } from "@tanstack/react-query";
4
4
  import { W6WProvider as J, useW6WClient as P, useW6WSession as H, createW6WUiAdapter as V } from "@w6w/react";
5
5
  import { W6WUIProvider as X } from "@w6w/ui";
6
- import { useState as j, useRef as x, useEffect as w, useCallback as R, useMemo as v, useContext as Y, createContext as Z } from "react";
6
+ import { useState as v, useRef as x, useEffect as j, useCallback as F, useMemo as g, useContext as Y, createContext as Z } from "react";
7
7
  import { E as _ } from "./client-context-CX61Bgw-.js";
8
8
  import { c as ee, D as te } from "./draft-registry-YF0tqNN0.js";
9
9
  import { E as re, a as oe } from "./project-context-Tvp-La7A.js";
10
- import { b as Ne } from "./project-context-Tvp-La7A.js";
11
- import { j as ne } from "./connections-CzsCyIxY.js";
12
- import { D as se } from "./credentials-4Nf2GfMc.js";
10
+ import { b as Oe } from "./project-context-Tvp-La7A.js";
11
+ import { j as se } from "./connections-CzsCyIxY.js";
12
+ import { D as ne } from "./credentials-4Nf2GfMc.js";
13
13
  import { e as ie, c as ue } from "./data-stores-UeQvwVCa.js";
14
- import { r as ae } from "./fields-DvS8XZFc.js";
14
+ import { r as ae, a as le } from "./fields-CXHRR5eK.js";
15
15
  import { l as ce } from "./models-CI0vLJ6o.js";
16
- import { path as q } from "@w6w/sdk";
17
- import { s as le, t as de, J as fe } from "./workflows-Dz8LMjnt.js";
18
- import { E as pe } from "./theme-context-E2ZhlXDX.js";
19
- class me extends Error {
20
- constructor(s) {
21
- super("The w6w API rejected the embed session token (401).", { cause: s }), this.name = "EmbedAuthError";
16
+ import { path as T } from "@w6w/sdk";
17
+ import { s as de, t as fe, J as pe } from "./workflows-Dz8LMjnt.js";
18
+ import { E as me } from "./theme-context-E2ZhlXDX.js";
19
+ class ye extends Error {
20
+ constructor(n) {
21
+ super("The w6w API rejected the embed session token (401).", { cause: n }), this.name = "EmbedAuthError";
22
22
  }
23
23
  }
24
- function ye(n, s, e) {
24
+ function he(s, n, e) {
25
25
  if (e) return { status: "error", error: e };
26
- switch (n) {
26
+ switch (s) {
27
27
  case "ready":
28
28
  case "renewing":
29
29
  return { status: "ready", error: null };
30
30
  case "error":
31
- return { status: "error", error: s };
31
+ return { status: "error", error: n };
32
32
  case "loading":
33
33
  case "expired":
34
34
  return { status: "connecting", error: null };
35
35
  }
36
36
  }
37
- async function he(n, s) {
38
- return (await n.request({
37
+ async function be(s, n) {
38
+ return (await s.request({
39
39
  method: "POST",
40
- path: q`/subscriptions/${s}/listen`,
40
+ path: T`/subscriptions/${n}/listen`,
41
41
  body: {}
42
42
  })).body;
43
43
  }
44
- async function be(n, s, e, i) {
45
- return (await n.request({
44
+ async function ve(s, n, e, i) {
45
+ return (await s.request({
46
46
  method: "GET",
47
- path: q`/subscriptions/${s}/listen/${e}`,
47
+ path: T`/subscriptions/${n}/listen/${e}`,
48
48
  query: { wait: String((i == null ? void 0 : i.waitSeconds) ?? 0) },
49
49
  signal: i == null ? void 0 : i.signal
50
50
  })).body.session;
51
51
  }
52
- async function je(n, s, e) {
53
- await n.request({
52
+ async function je(s, n, e) {
53
+ await s.request({
54
54
  method: "DELETE",
55
- path: q`/subscriptions/${s}/listen/${e}`
55
+ path: T`/subscriptions/${n}/listen/${e}`
56
56
  });
57
57
  }
58
- function I() {
58
+ function R() {
59
59
  return new G({
60
60
  defaultOptions: { queries: { retry: !1, refetchOnWindowFocus: !1 } }
61
61
  });
62
62
  }
63
- function we({ children: n }) {
64
- return /* @__PURE__ */ c(_, { client: P(), children: n });
63
+ function ge({ children: s }) {
64
+ return /* @__PURE__ */ l(_, { client: P(), children: s });
65
65
  }
66
- function ve({ theme: n, children: s }) {
67
- const e = P(), i = oe(), a = v(() => {
66
+ function we({ theme: s, children: n }) {
67
+ const e = P(), i = oe(), a = g(() => {
68
68
  const t = V(e);
69
- return typeof t.updateConnection != "function" && (t.updateConnection = (r, o) => ne(e, r, o)), se(t, e), typeof t.listModelRoutes != "function" && (t.listModelRoutes = async (r) => {
69
+ return typeof t.updateConnection != "function" && (t.updateConnection = (r, o) => se(e, r, o)), ne(t, e), typeof t.listModelRoutes != "function" && (t.listModelRoutes = async (r) => {
70
70
  const o = r || i;
71
- return o ? (await ce(e, o)).map((f) => ({ name: f.name, model: f.modelId, status: f.status })) : [];
71
+ return o ? (await ce(e, o)).map((c) => ({ name: c.name, model: c.modelId, status: c.status })) : [];
72
72
  }), typeof t.listDataStores != "function" && (t.listDataStores = async (r) => {
73
73
  const o = r || i;
74
74
  return o ? ie(e, o) : [];
75
75
  }), typeof t.listDataStoreEntries != "function" && (t.listDataStoreEntries = async (r, o) => {
76
76
  const u = o.project || i;
77
77
  return u ? ue(e, u, r, o) : { items: [] };
78
- }), typeof t.loadNodeSamples != "function" && (t.loadNodeSamples = (r) => le(e, r)), typeof t.loadTestInputs != "function" && (t.loadTestInputs = (r) => de(e, r)), typeof t.saveTestInput != "function" && (t.saveTestInput = (r, o, u) => fe(e, r, o, u)), typeof t.resolveActionFields != "function" && (t.resolveActionFields = (r, o, u, f) => ae(e, r, o, u, f)), typeof t.startWebhookListen != "function" && (t.startWebhookListen = (r) => he(e, r), t.pollWebhookListen = (r, o, u) => be(e, r, o, u), t.stopWebhookListen = (r, o) => je(e, r, o)), t;
78
+ }), typeof t.loadNodeSamples != "function" && (t.loadNodeSamples = (r) => de(e, r)), typeof t.loadTestInputs != "function" && (t.loadTestInputs = (r) => fe(e, r)), typeof t.saveTestInput != "function" && (t.saveTestInput = (r, o, u) => pe(e, r, o, u)), typeof t.resolveActionFields != "function" && (t.resolveActionFields = (r, o, u, c) => ae(e, r, o, u, c)), typeof t.resolveTriggerFields != "function" && (t.resolveTriggerFields = (r, o, u, c) => le(e, r, o, u, c)), typeof t.startWebhookListen != "function" && (t.startWebhookListen = (r) => be(e, r), t.pollWebhookListen = (r, o, u) => ve(e, r, o, u), t.stopWebhookListen = (r, o) => je(e, r, o)), t;
79
79
  }, [e, i]);
80
- return /* @__PURE__ */ c(X, { api: a, theme: n, children: /* @__PURE__ */ c(pe.Provider, { value: n, children: s }) });
80
+ return /* @__PURE__ */ l(X, { api: a, theme: s, children: /* @__PURE__ */ l(me.Provider, { value: s, children: n }) });
81
81
  }
82
- const F = Z({ status: "connecting", error: null });
83
- function $e() {
84
- return Y(F);
82
+ const I = Z({ status: "connecting", error: null });
83
+ function Ke() {
84
+ return Y(I);
85
85
  }
86
86
  function Ee({
87
- eager: n,
88
- authError: s,
87
+ eager: s,
88
+ authError: n,
89
89
  onAcquire: e,
90
90
  children: i
91
91
  }) {
92
92
  const { status: a, error: t, refresh: r } = H();
93
- w(() => {
94
- n && r();
95
- }, [n, r]), w(() => {
93
+ j(() => {
94
+ s && r();
95
+ }, [s, r]), j(() => {
96
96
  (a === "loading" || a === "renewing") && e();
97
97
  }, [a, e]);
98
- const o = v(
99
- () => ye(a, t, s),
100
- [a, t, s]
98
+ const o = g(
99
+ () => he(a, t, n),
100
+ [a, t, n]
101
101
  );
102
- return /* @__PURE__ */ c(F.Provider, { value: o, children: i });
102
+ return /* @__PURE__ */ l(I.Provider, { value: o, children: i });
103
103
  }
104
104
  function Ce({
105
- identityKey: n,
106
- enabled: s,
105
+ identityKey: s,
106
+ enabled: n,
107
107
  onState: e
108
108
  }) {
109
109
  const i = P(), a = z({
110
110
  queryKey: ["w6w-embed", "default-project"],
111
- enabled: s,
111
+ enabled: n,
112
112
  queryFn: async () => {
113
- const y = (await i.projects.list()).find((l) => l.isDefault === !0);
113
+ const y = (await i.projects.list()).find((d) => d.isDefault === !0);
114
114
  if (!y) throw new Error("The account has no default project.");
115
115
  return y.id;
116
116
  }
117
- }), { isError: t, error: r, data: o } = a, u = v(
117
+ }), { isError: t, error: r, data: o } = a, u = g(
118
118
  () => t ? { project: null, status: "error", error: r } : o !== void 0 ? { project: o, status: "ready" } : { project: null, status: "resolving" },
119
119
  [t, r, o]
120
120
  );
121
- return w(() => {
122
- e(n, u);
123
- }, [n, u, e]), null;
121
+ return j(() => {
122
+ e(s, u);
123
+ }, [s, u, e]), null;
124
124
  }
125
- function Ke({
126
- apiOrigin: n,
127
- getSession: s,
125
+ function Qe({
126
+ apiOrigin: s,
127
+ getSession: n,
128
128
  identityKey: e,
129
129
  fallback: i = null,
130
130
  eager: a = !1,
@@ -132,52 +132,52 @@ function Ke({
132
132
  ready: r,
133
133
  project: o,
134
134
  fetch: u,
135
- children: f
135
+ children: c
136
136
  }) {
137
- const [y] = j(ee), [l, L] = j(() => ({
137
+ const [y] = v(ee), [d, L] = v(() => ({
138
138
  identityKey: e,
139
- queryClient: I()
140
- })), M = e !== l.identityKey, D = x({ apiOrigin: n, project: o, getSession: s });
141
- M || (D.current = { apiOrigin: n, project: o, getSession: s });
142
- const E = D.current, k = x(E.getSession);
143
- k.current = E.getSession;
144
- const [U] = j(() => () => k.current());
145
- w(() => {
146
- if (e === l.identityKey) return;
139
+ queryClient: R()
140
+ })), M = e !== d.identityKey, q = x({ apiOrigin: s, project: o, getSession: n });
141
+ M || (q.current = { apiOrigin: s, project: o, getSession: n });
142
+ const w = q.current, D = x(w.getSession);
143
+ D.current = w.getSession;
144
+ const [U] = v(() => () => D.current());
145
+ j(() => {
146
+ if (e === d.identityKey) return;
147
147
  let p = !1;
148
- const d = () => {
149
- p || L({ identityKey: e, queryClient: I() });
148
+ const f = () => {
149
+ p || L({ identityKey: e, queryClient: R() });
150
150
  };
151
- return l.identityKey === null ? (d(), () => {
151
+ return d.identityKey === null ? (f(), () => {
152
152
  p = !0;
153
- }) : (y.flushAll().then(d, d), () => {
153
+ }) : (y.flushAll().then(f, f), () => {
154
154
  p = !0;
155
155
  });
156
- }, [e, l.identityKey, y]);
157
- const C = l.queryClient;
158
- w(() => () => C.clear(), [C]);
159
- const [S, $] = j(null), K = R((p, d) => {
156
+ }, [e, d.identityKey, y]);
157
+ const E = d.queryClient;
158
+ j(() => () => E.clear(), [E]);
159
+ const [C, $] = v(null), K = F((p, f) => {
160
160
  $(
161
- (b) => b && b.key === p && b.state.project === d.project && b.state.status === d.status && b.state.error === d.error ? b : { key: p, state: d }
161
+ (b) => b && b.key === p && b.state.project === f.project && b.state.status === f.status && b.state.error === f.error ? b : { key: p, state: f }
162
162
  );
163
- }, []), [g, A] = j(null), Q = v(() => {
164
- const p = l.queryClient;
165
- return (d) => {
166
- A({ key: p, error: new me(d) });
163
+ }, []), [S, k] = v(null), Q = g(() => {
164
+ const p = d.queryClient;
165
+ return (f) => {
166
+ k({ key: p, error: new ye(f) });
167
167
  };
168
- }, [l.queryClient]), B = R(() => A(null), []), h = l.identityKey, m = E.project, W = typeof m == "object" && m !== null && !Array.isArray(m) && m.use === "default", T = v(() => typeof m == "string" ? { project: m, status: "ready" } : W ? S && S.key === h ? S.state : { project: null, status: "resolving" } : { project: null, status: "ready" }, [m, W, S, h]);
169
- return h === null ? i : /* @__PURE__ */ c(te, { registry: y, children: /* @__PURE__ */ c(O, { client: C, children: /* @__PURE__ */ N(
168
+ }, [d.queryClient]), B = F(() => k(null), []), h = d.identityKey, m = w.project, W = typeof m == "object" && m !== null && !Array.isArray(m) && m.use === "default", A = g(() => typeof m == "string" ? { project: m, status: "ready" } : W ? C && C.key === h ? C.state : { project: null, status: "resolving" } : { project: null, status: "ready" }, [m, W, C, h]);
169
+ return h === null ? i : /* @__PURE__ */ l(te, { registry: y, children: /* @__PURE__ */ l(O, { client: E, children: /* @__PURE__ */ N(
170
170
  J,
171
171
  {
172
- baseUrl: E.apiOrigin,
172
+ baseUrl: w.apiOrigin,
173
173
  getSession: U,
174
174
  identityKey: h,
175
175
  ready: r,
176
- project: T.project ?? void 0,
176
+ project: A.project ?? void 0,
177
177
  fetch: u,
178
178
  onUnauthorized: Q,
179
179
  children: [
180
- W ? /* @__PURE__ */ c(
180
+ W ? /* @__PURE__ */ l(
181
181
  Ce,
182
182
  {
183
183
  identityKey: h,
@@ -185,13 +185,13 @@ function Ke({
185
185
  onState: K
186
186
  }
187
187
  ) : null,
188
- /* @__PURE__ */ c(re.Provider, { value: T, children: /* @__PURE__ */ c(
188
+ /* @__PURE__ */ l(re.Provider, { value: A, children: /* @__PURE__ */ l(
189
189
  Ee,
190
190
  {
191
191
  eager: a,
192
- authError: g && g.key === C ? g.error : null,
192
+ authError: S && S.key === E ? S.error : null,
193
193
  onAcquire: B,
194
- children: /* @__PURE__ */ c(we, { children: /* @__PURE__ */ c(ve, { theme: t, children: f }) })
194
+ children: /* @__PURE__ */ l(ge, { children: /* @__PURE__ */ l(we, { theme: t, children: c }) })
195
195
  }
196
196
  ) })
197
197
  ]
@@ -199,9 +199,9 @@ function Ke({
199
199
  ) }, h) });
200
200
  }
201
201
  export {
202
- me as EmbedAuthError,
203
- Ke as W6WEmbedProvider,
204
- Ne as useEmbedProject,
205
- $e as useEmbedStatus
202
+ ye as EmbedAuthError,
203
+ Qe as W6WEmbedProvider,
204
+ Oe as useEmbedProject,
205
+ Ke as useEmbedStatus
206
206
  };
207
207
  //# sourceMappingURL=index.mjs.map