@loopstack/loopstack-studio 0.33.0 → 0.35.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 (146) hide show
  1. package/dist/app/EnvironmentEmbedRoot.js +17 -25
  2. package/dist/components/layout/StudioSidebar.js +34 -34
  3. package/dist/components/messages/CompletionMessagePaper.js +25 -29
  4. package/dist/events/api-client-events.js +13 -1
  5. package/dist/events/index.js +1 -0
  6. package/dist/features/code-explorer/components/FileTabsBarBase.js +1 -1
  7. package/dist/features/code-explorer/index.js +0 -3
  8. package/dist/features/dashboard/AppLauncher.js +111 -64
  9. package/dist/features/debug/components/WorkflowFlowViewer.js +2 -1
  10. package/dist/features/debug/components/workflow-flow/WorkflowGraph.js +2 -1
  11. package/dist/features/documents/DocumentRenderer.js +42 -42
  12. package/dist/features/documents/components/DocumentList.js +1 -1
  13. package/dist/features/documents/document-details/DocumentDetails.js +0 -5
  14. package/dist/features/documents/renderers/DocumentFormRenderer.js +13 -12
  15. package/dist/features/documents/renderers/LinkMessageRenderer.js +2 -1
  16. package/dist/features/documents/renderers/useDocumentTransition.js +3 -2
  17. package/dist/features/feature-registry/FeatureRegistryProvider.js +17 -18
  18. package/dist/features/feature-registry/available-features.js +3 -2
  19. package/dist/features/feature-registry/index.js +1 -1
  20. package/dist/features/file-explorer/components/FileExplorerPanel.js +64 -43
  21. package/dist/features/file-explorer/components/FileTabsBar.js +1 -1
  22. package/dist/features/file-explorer/components/FileTree.js +1 -1
  23. package/dist/features/file-explorer/file-explorer-feature.js +15 -7
  24. package/dist/features/file-explorer/hooks/useFileExplorer.js +41 -34
  25. package/dist/features/file-explorer/index.js +1 -1
  26. package/dist/features/file-explorer/providers/FileExplorerProvider.js +91 -89
  27. package/dist/features/git/components/WorkbenchGitPanel.js +7 -10
  28. package/dist/features/git/hooks/useGit.js +55 -57
  29. package/dist/features/health/LocalHealthCheck.js +46 -47
  30. package/dist/features/oauth/OAuthPromptRenderer.js +6 -5
  31. package/dist/features/runs/Runs.js +3 -2
  32. package/dist/features/secrets/components/WorkbenchSecretsPanel.js +1 -1
  33. package/dist/features/secrets/renderers/SecretInputRenderer.js +3 -2
  34. package/dist/features/workbench/Workbench.js +16 -16
  35. package/dist/features/workbench/WorkflowItem.js +5 -8
  36. package/dist/features/workbench/components/NewRunDialog.js +173 -171
  37. package/dist/features/workbench/components/PreviewEmptyState.js +1 -1
  38. package/dist/features/workbench/components/WorkbenchIconSidebar.js +1 -1
  39. package/dist/features/workbench/components/WorkbenchRunsPanel.js +2 -1
  40. package/dist/features/workbench/components/WorkbenchSidebarShell.js +3 -3
  41. package/dist/features/workbench/components/WorkflowForms.js +1 -1
  42. package/dist/features/workbench/components/WorkflowHistoryItem.js +2 -1
  43. package/dist/features/workbench/components/buttons/WorkflowButtons.js +8 -14
  44. package/dist/features/workbench/hooks/useLlmStreamingDocuments.js +65 -132
  45. package/dist/features/workbench/hooks/useWorkflowData.js +8 -6
  46. package/dist/features/workbench/index.js +1 -1
  47. package/dist/features/workspaces/Workspaces.js +5 -3
  48. package/dist/features/workspaces/components/CreateWorkspace.js +7 -5
  49. package/dist/features/workspaces/components/ExecutionTimeline.js +69 -65
  50. package/dist/features/workspaces/components/WorkflowRunForm.js +6 -4
  51. package/dist/features/workspaces/components/WorkspaceHomePage.js +1 -1
  52. package/dist/hooks/index.js +5 -5
  53. package/dist/hooks/useAuth.js +14 -53
  54. package/dist/hooks/useConfig.js +13 -37
  55. package/dist/hooks/useDocuments.js +5 -30
  56. package/dist/hooks/useEnvironments.js +34 -24
  57. package/dist/hooks/useProcessor.js +2 -31
  58. package/dist/hooks/useSecrets.js +71 -53
  59. package/dist/hooks/useWorkflows.js +43 -172
  60. package/dist/hooks/useWorkspaces.js +24 -130
  61. package/dist/index.d.ts +137 -481
  62. package/dist/index.js +15 -17
  63. package/dist/loopstack-studio.css +1 -1
  64. package/dist/packages/client/dist/client.js +35 -0
  65. package/dist/packages/client/dist/http.js +47 -0
  66. package/dist/packages/client/dist/index.js +15 -0
  67. package/dist/packages/client/dist/queries/query-keys.js +94 -0
  68. package/dist/packages/client/dist/queries/query-options.js +97 -0
  69. package/dist/packages/client/dist/resources/auth.js +10 -0
  70. package/dist/packages/client/dist/resources/config.js +11 -0
  71. package/dist/packages/client/dist/resources/dashboard.js +4 -0
  72. package/dist/packages/client/dist/resources/documents.js +7 -0
  73. package/dist/packages/client/dist/resources/processor.js +7 -0
  74. package/dist/packages/client/dist/resources/workflows.js +13 -0
  75. package/dist/packages/client/dist/resources/workspaces.js +12 -0
  76. package/dist/packages/client/dist/stream/invalidations.js +20 -0
  77. package/dist/packages/client/dist/stream/llm-reducer.js +65 -0
  78. package/dist/packages/client/dist/stream/sse-parser.js +40 -0
  79. package/dist/packages/client/dist/stream/stream.js +147 -0
  80. package/dist/packages/contracts/dist/events/client-message-base.schema.js +6 -0
  81. package/dist/packages/contracts/dist/events/client-message.schema.js +24 -0
  82. package/dist/packages/contracts/dist/events/index.js +6 -0
  83. package/dist/packages/contracts/dist/events/llm-events.schema.js +44 -0
  84. package/dist/packages/contracts/dist/events/stream-events.schema.js +4 -0
  85. package/dist/packages/contracts/dist/events/workflow-events.schema.js +20 -0
  86. package/dist/packages/contracts/dist/events/workspace-events.schema.js +5 -0
  87. package/dist/packages/contracts/dist/types/types/ui-message.type.js +39 -0
  88. package/dist/packages/react/dist/hooks/mutations.js +175 -0
  89. package/dist/packages/react/dist/hooks/queries.js +139 -0
  90. package/dist/packages/react/dist/hooks/use-live-invalidation.js +39 -0
  91. package/dist/packages/react/dist/hooks/use-llm-stream.js +18 -0
  92. package/dist/packages/react/dist/index.js +5 -0
  93. package/dist/packages/react/dist/provider.js +15 -0
  94. package/dist/pages/DashboardPage.js +2 -1
  95. package/dist/pages/DebugWorkflowDetailsPage.js +2 -1
  96. package/dist/pages/DebugWorkflowsPage.js +2 -1
  97. package/dist/pages/EmbedWorkbenchPage.js +50 -43
  98. package/dist/pages/PreviewWorkbenchPage.js +60 -59
  99. package/dist/pages/StudioLandingPage.js +1 -1
  100. package/dist/pages/WorkbenchPage.js +53 -47
  101. package/dist/pages/WorkflowDebugPage.js +3 -2
  102. package/dist/pages/WorkspacePage.js +42 -27
  103. package/dist/pages/WorkspaceRunsPage.js +36 -27
  104. package/dist/providers/LoopstackClientProvider.js +31 -0
  105. package/dist/services/createApiClient.js +9 -3
  106. package/dist/services/index.js +0 -1
  107. package/dist/services/reporting-fetch.js +13 -0
  108. package/package.json +4 -3
  109. package/dist/api/auth.js +0 -10
  110. package/dist/api/client.js +0 -13
  111. package/dist/api/config.js +0 -11
  112. package/dist/api/dashboard.js +0 -4
  113. package/dist/api/documents.js +0 -7
  114. package/dist/api/environments.js +0 -8
  115. package/dist/api/index.js +0 -28
  116. package/dist/api/processor.js +0 -7
  117. package/dist/api/secrets.js +0 -16
  118. package/dist/api/workflows.js +0 -15
  119. package/dist/api/workspaces.js +0 -12
  120. package/dist/events/sse-client-events.js +0 -13
  121. package/dist/features/code-explorer/CodeExplorer.js +0 -6
  122. package/dist/features/code-explorer/components/CodeExplorerTree.js +0 -6
  123. package/dist/features/code-explorer/components/FileTabsBar.js +0 -4
  124. package/dist/features/code-explorer/providers/CodeExplorerProvider.js +0 -5
  125. package/dist/features/file-explorer/api/files.js +0 -7
  126. package/dist/features/git/api/git.js +0 -9
  127. package/dist/hooks/query-keys.js +0 -145
  128. package/dist/hooks/useApi.js +0 -15
  129. package/dist/hooks/useFiles.js +0 -3
  130. package/dist/node_modules/lodash/_Symbol.js +0 -7
  131. package/dist/node_modules/lodash/_baseGetTag.js +0 -13
  132. package/dist/node_modules/lodash/_baseTrim.js +0 -11
  133. package/dist/node_modules/lodash/_freeGlobal.js +0 -6
  134. package/dist/node_modules/lodash/_getRawTag.js +0 -17
  135. package/dist/node_modules/lodash/_objectToString.js +0 -10
  136. package/dist/node_modules/lodash/_root.js +0 -8
  137. package/dist/node_modules/lodash/_trimmedEndIndex.js +0 -11
  138. package/dist/node_modules/lodash/debounce.js +0 -53
  139. package/dist/node_modules/lodash/isObject.js +0 -10
  140. package/dist/node_modules/lodash/isObjectLike.js +0 -9
  141. package/dist/node_modules/lodash/isSymbol.js +0 -12
  142. package/dist/node_modules/lodash/now.js +0 -10
  143. package/dist/node_modules/lodash/toNumber.js +0 -22
  144. package/dist/providers/InvalidationEventsProvider.js +0 -41
  145. package/dist/providers/SseProvider.js +0 -37
  146. package/dist/services/eventEmitter.js +0 -12
@@ -1,7 +1,9 @@
1
+ import { useAppsConfig } from "../../../packages/react/dist/hooks/queries.js";
2
+ import { useStartWorkflow } from "../../../packages/react/dist/hooks/mutations.js";
3
+ import "../../../hooks/useConfig.js";
1
4
  import { useStudio } from "../../../providers/StudioProvider.js";
2
- import { useAppsConfig } from "../../../hooks/useConfig.js";
3
5
  import ErrorSnackbar_default from "../../../components/feedback/ErrorSnackbar.js";
4
- import { useStartWorkflow } from "../../../hooks/useProcessor.js";
6
+ import "../../../hooks/useProcessor.js";
5
7
  import ArgumentsView_default from "./workflow-form/ArgumentsView.js";
6
8
  import SelectionView_default from "./workflow-form/SelectionView.js";
7
9
  import { c } from "react/compiler-runtime";
@@ -84,11 +86,11 @@ var WorkflowRunForm_default = (a) => {
84
86
  }), !1), o[24] = g.workflowName, o[25] = F);
85
87
  let I = F, L;
86
88
  o[26] !== u || o[27] !== O || o[28] !== f || o[29] !== l.id ? (L = (e, r) => {
87
- O && f.mutate({ payload: {
89
+ O && f.mutate({
88
90
  workflowName: O.workflowName,
89
91
  workspaceId: l.id,
90
92
  args: r ?? {}
91
- } }, { onSuccess: (e) => void u.navigateToWorkflow(e.workflowId) });
93
+ }, { onSuccess: (e) => void u.navigateToWorkflow(e.workflowId) });
92
94
  }, o[26] = u, o[27] = O, o[28] = f, o[29] = l.id, o[30] = L) : L = o[30];
93
95
  let R = L, z;
94
96
  o[31] !== j || o[32] !== R || o[33] !== I ? (z = () => {
@@ -1,5 +1,5 @@
1
- import "../../../providers/StudioProvider.js";
2
1
  import "../../../hooks/useWorkflows.js";
2
+ import "../../../providers/StudioProvider.js";
3
3
  import "../../../components/ui/button.js";
4
4
  import "../../../components/feedback/ErrorSnackbar.js";
5
5
  import "../../../hooks/useProcessor.js";
@@ -1,7 +1,7 @@
1
- import { getAppTypesCacheKey, getAvailableEnvironmentsCacheKey, getChildWorkflowsCacheKey, getDashboardStatsCacheKey, getDocumentCacheKey, getDocumentsCacheKey, getFileContentCacheKey, getFileTreeCacheKey, getGitLogCacheKey, getGitRemoteCacheKey, getGitStatusCacheKey, getHealthCacheKey, getMeCacheKey, getSecretsCacheKey, getStudioAppsCacheKey, getToolConfigCacheKey, getToolConfigsCacheKey, getWorkflowCacheKey, getWorkflowConfigCacheKey, getWorkflowSourceCacheKey, getWorkflowStatusCacheKey, getWorkflowTypesCacheKey, getWorkflowsCacheKey, getWorkspaceCacheKey, getWorkspacesCacheKey } from "./query-keys.js";
2
- import { useApiClient } from "./useApi.js";
3
1
  import { useIsMobile } from "./use-mobile.js";
4
- import { useAppsConfig, useAvailableEnvironments, useDocumentConfigs } from "./useConfig.js";
2
+ import { useAppsConfig, useAvailableEnvironments, useWorkflow, useWorkflowCheckpoints, useWorkflowSource, useWorkflowStatus, useWorkspace } from "../packages/react/dist/hooks/queries.js";
3
+ import { useBatchDeleteWorkspaces, useCreateWorkflow, useCreateWorkspace, useDeleteWorkflow, useDeleteWorkspace, useSetFavouriteWorkspace, useUpdateWorkflow, useUpdateWorkspace } from "../packages/react/dist/hooks/mutations.js";
4
+ import { useDocumentConfigs } from "./useConfig.js";
5
5
  import { useReplaceEnvironments, useResetEnvironment, useWorkspaceEnvironments } from "./useEnvironments.js";
6
- import { useBatchDeleteWorkflows, useChildWorkflows, useCreateWorkflow, useDeleteWorkflow, useFilterWorkflows, useUpdateWorkflow, useWorkflow, useWorkflowCheckpoints, useWorkflowConfigByName, useWorkflowSource, useWorkflowStatus } from "./useWorkflows.js";
7
- import { useBatchDeleteWorkspaces, useCreateWorkspace, useDeleteWorkspace, useFilterWorkspaces, useSetFavouriteWorkspace, useUpdateWorkspace, useWorkspace } from "./useWorkspaces.js";
6
+ import { useBatchDeleteWorkflows, useChildWorkflows, useFilterWorkflows, useWorkflowConfigByName } from "./useWorkflows.js";
7
+ import { useFilterWorkspaces } from "./useWorkspaces.js";
@@ -1,58 +1,19 @@
1
- import { getHealthCacheKey, getMeCacheKey } from "./query-keys.js";
2
- import { useApiClient } from "./useApi.js";
1
+ import { useMe, useWorkerHealth } from "../packages/react/dist/hooks/queries.js";
2
+ import { useHubLogin, useRefreshSession } from "../packages/react/dist/hooks/mutations.js";
3
+ import "../packages/react/dist/index.js";
3
4
  import { c } from "react/compiler-runtime";
4
- import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
5
- function useMe(e) {
6
- let i = c(8), o = e === void 0 ? !0 : e, { envKey: s, api: l } = useApiClient(), u;
7
- i[0] === s ? u = i[1] : (u = getMeCacheKey(s), i[0] = s, i[1] = u);
8
- let d;
9
- i[2] === l ? d = i[3] : (d = () => l.auth.me(), i[2] = l, i[3] = d);
10
- let f;
11
- return i[4] !== o || i[5] !== u || i[6] !== d ? (f = {
12
- queryKey: u,
13
- queryFn: d,
14
- retry: !1,
5
+ function useMe$1(r) {
6
+ let i = c(2), a = r === void 0 ? !0 : r, o;
7
+ return i[0] === a ? o = i[1] : (o = {
15
8
  staleTime: 3e5,
16
- enabled: o
17
- }, i[4] = o, i[5] = u, i[6] = d, i[7] = f) : f = i[7], useQuery(f);
9
+ enabled: a
10
+ }, i[0] = a, i[1] = o), useMe(o);
18
11
  }
19
- function useGetHealthInfo(r) {
20
- let i = c(8), o = r === void 0 ? !0 : r, { envKey: s, api: l } = useApiClient(), u;
21
- i[0] === s ? u = i[1] : (u = getHealthCacheKey(s), i[0] = s, i[1] = u);
22
- let d;
23
- i[2] === l ? d = i[3] : (d = () => l.auth.getInfo(), i[2] = l, i[3] = d);
24
- let f;
25
- return i[4] !== o || i[5] !== u || i[6] !== d ? (f = {
26
- queryKey: u,
27
- queryFn: d,
12
+ function useGetHealthInfo(e) {
13
+ let i = c(2), a = e === void 0 ? !0 : e, o;
14
+ return i[0] === a ? o = i[1] : (o = {
28
15
  staleTime: 3e5,
29
- enabled: o
30
- }, i[4] = o, i[5] = u, i[6] = d, i[7] = f) : f = i[7], useQuery(f);
16
+ enabled: a
17
+ }, i[0] = a, i[1] = o), useWorkerHealth(o);
31
18
  }
32
- function useWorkerAuth() {
33
- let a = c(8), { envKey: s, api: l } = useApiClient(), u = useQueryClient(), d;
34
- a[0] === l ? d = a[1] : (d = (e) => l.auth.hubLogin(e), a[0] = l, a[1] = d);
35
- let f;
36
- a[2] !== s || a[3] !== u ? (f = () => {
37
- u.invalidateQueries({ queryKey: getMeCacheKey(s) }), u.invalidateQueries({ queryKey: getHealthCacheKey(s) });
38
- }, a[2] = s, a[3] = u, a[4] = f) : f = a[4];
39
- let p;
40
- return a[5] !== d || a[6] !== f ? (p = {
41
- mutationFn: d,
42
- onSuccess: f
43
- }, a[5] = d, a[6] = f, a[7] = p) : p = a[7], useMutation(p);
44
- }
45
- function useWorkerAuthTokenRefresh() {
46
- let a = c(8), { envKey: s, api: l } = useApiClient(), u = useQueryClient(), d;
47
- a[0] === l ? d = a[1] : (d = () => l.auth.refresh(), a[0] = l, a[1] = d);
48
- let f;
49
- a[2] !== s || a[3] !== u ? (f = () => {
50
- u.invalidateQueries({ queryKey: getMeCacheKey(s) }), u.invalidateQueries({ queryKey: getHealthCacheKey(s) });
51
- }, a[2] = s, a[3] = u, a[4] = f) : f = a[4];
52
- let p;
53
- return a[5] !== d || a[6] !== f ? (p = {
54
- mutationFn: d,
55
- onSuccess: f
56
- }, a[5] = d, a[6] = f, a[7] = p) : p = a[7], useMutation(p);
57
- }
58
- export { useGetHealthInfo, useMe, useWorkerAuth, useWorkerAuthTokenRefresh };
19
+ export { useGetHealthInfo, useMe$1 as useMe };
@@ -1,46 +1,22 @@
1
- import { getAvailableEnvironmentsCacheKey, getStudioAppsCacheKey } from "./query-keys.js";
2
- import { useApiClient } from "./useApi.js";
1
+ import { useAppsConfig, useAvailableEnvironments } from "../packages/react/dist/hooks/queries.js";
2
+ import "../packages/react/dist/index.js";
3
3
  import { c } from "react/compiler-runtime";
4
4
  import { useMemo } from "react";
5
- import { useQuery } from "@tanstack/react-query";
6
- function useAppsConfig() {
7
- let e = c(7), { envKey: a, api: o } = useApiClient(), s;
8
- e[0] === a ? s = e[1] : (s = getStudioAppsCacheKey(a), e[0] = a, e[1] = s);
9
- let l;
10
- e[2] === o ? l = e[3] : (l = () => o.config.getApps(), e[2] = o, e[3] = l);
11
- let u;
12
- return e[4] !== s || e[5] !== l ? (u = {
13
- queryKey: s,
14
- queryFn: l
15
- }, e[4] = s, e[5] = l, e[6] = u) : u = e[6], useQuery(u);
16
- }
17
- function useAvailableEnvironments(n) {
18
- let a = c(8), { envKey: o, api: s } = useApiClient(), l;
19
- a[0] === o ? l = a[1] : (l = getAvailableEnvironmentsCacheKey(o), a[0] = o, a[1] = l);
20
- let u;
21
- a[2] === s ? u = a[3] : (u = () => s.config.getAvailableEnvironments(), a[2] = s, a[3] = u);
22
- let d = n?.enabled ?? !0, f;
23
- return a[4] !== l || a[5] !== u || a[6] !== d ? (f = {
24
- queryKey: l,
25
- queryFn: u,
26
- enabled: d
27
- }, a[4] = l, a[5] = u, a[6] = d, a[7] = f) : f = a[7], useQuery(f);
28
- }
29
5
  function useDocumentConfigs() {
30
- let e = c(2), { data: n } = useAppsConfig(), r;
31
- if (e[0] !== n) {
6
+ let t = c(2), { data: r } = useAppsConfig(), i;
7
+ if (t[0] !== r) {
32
8
  bb0: {
33
9
  let e = /* @__PURE__ */ new Map();
34
- if (!n?.length) {
35
- r = e;
10
+ if (!r?.length) {
11
+ i = e;
36
12
  break bb0;
37
13
  }
38
- let i = n[0].documents ?? [];
39
- for (let n of i) e.set(n.documentName, n);
40
- r = e;
14
+ let t = r[0].documents ?? [];
15
+ for (let n of t) e.set(n.documentName, n);
16
+ i = e;
41
17
  }
42
- e[0] = n, e[1] = r;
43
- } else r = e[1];
44
- return r;
18
+ t[0] = r, t[1] = i;
19
+ } else i = t[1];
20
+ return i;
45
21
  }
46
- export { useAppsConfig, useAvailableEnvironments, useDocumentConfigs };
22
+ export { useDocumentConfigs };
@@ -1,34 +1,9 @@
1
- import { getDocumentsCacheKey } from "./query-keys.js";
2
- import { useApiClient } from "./useApi.js";
1
+ import { useWorkflowDocuments } from "../packages/react/dist/hooks/queries.js";
2
+ import "../packages/react/dist/index.js";
3
3
  import { c } from "react/compiler-runtime";
4
- import { useQuery } from "@tanstack/react-query";
5
- function useFilterDocuments(a) {
6
- let o = c(15), { envKey: s, api: l } = useApiClient(), u;
7
- o[0] === a ? u = o[1] : (u = JSON.stringify({
8
- workflowId: a,
9
- isInvalidated: !1
10
- }), o[0] = a, o[1] = u);
11
- let d;
12
- o[2] === Symbol.for("react.memo_cache_sentinel") ? (d = JSON.stringify([{
13
- field: "index",
14
- order: "ASC"
15
- }]), o[2] = d) : d = o[2];
16
- let f;
17
- o[3] === u ? f = o[4] : (f = {
18
- filter: u,
19
- sortBy: d
20
- }, o[3] = u, o[4] = f);
21
- let p = f, m;
22
- o[5] !== s || o[6] !== a ? (m = getDocumentsCacheKey(s, a), o[5] = s, o[6] = a, o[7] = m) : m = o[7];
23
- let h;
24
- o[8] !== l || o[9] !== p ? (h = () => l.documents.getAll(p), o[8] = l, o[9] = p, o[10] = h) : h = o[10];
25
- let g = !!a, _;
26
- return o[11] !== m || o[12] !== h || o[13] !== g ? (_ = {
27
- queryKey: m,
28
- queryFn: h,
29
- select: _temp,
30
- enabled: g
31
- }, o[11] = m, o[12] = h, o[13] = g, o[14] = _) : _ = o[14], useQuery(_);
4
+ function useFilterDocuments(r) {
5
+ let i = c(1), a;
6
+ return i[0] === Symbol.for("react.memo_cache_sentinel") ? (a = { select: _temp }, i[0] = a) : a = i[0], useWorkflowDocuments(r, a);
32
7
  }
33
8
  function _temp(e) {
34
9
  return e.data;
@@ -1,33 +1,43 @@
1
- import { useApiClient } from "./useApi.js";
1
+ import { useLoopstackClient } from "../packages/react/dist/provider.js";
2
+ import "../packages/react/dist/index.js";
2
3
  import { c } from "react/compiler-runtime";
3
4
  import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
4
- function useWorkspaceEnvironments(n) {
5
- let i = c(9), { api: a } = useApiClient(), o;
6
- i[0] === n ? o = i[1] : (o = ["workspace-environments", n], i[0] = n, i[1] = o);
7
- let s;
8
- i[2] !== a || i[3] !== n ? (s = () => a.environments.getByWorkspace(n), i[2] = a, i[3] = n, i[4] = s) : s = i[4];
9
- let l = !!n, u;
10
- return i[5] !== o || i[6] !== s || i[7] !== l ? (u = {
11
- queryKey: o,
12
- queryFn: s,
13
- enabled: l
14
- }, i[5] = o, i[6] = s, i[7] = l, i[8] = u) : u = i[8], useQuery(u);
5
+ var environmentsPath = (e) => `/api/v1/workspaces/${e}/environments`;
6
+ function useWorkspaceEnvironments(r) {
7
+ let a = c(10), o = useLoopstackClient(), s;
8
+ a[0] !== o.envKey || a[1] !== r ? (s = [
9
+ "workspace-environments",
10
+ o.envKey,
11
+ r
12
+ ], a[0] = o.envKey, a[1] = r, a[2] = s) : s = a[2];
13
+ let l;
14
+ a[3] !== o.http || a[4] !== r ? (l = () => o.http.get(environmentsPath(r)), a[3] = o.http, a[4] = r, a[5] = l) : l = a[5];
15
+ let u = !!r, d;
16
+ return a[6] !== s || a[7] !== l || a[8] !== u ? (d = {
17
+ queryKey: s,
18
+ queryFn: l,
19
+ enabled: u
20
+ }, a[6] = s, a[7] = l, a[8] = u, a[9] = d) : d = a[9], useQuery(d);
15
21
  }
16
22
  function useReplaceEnvironments() {
17
- let r = c(7), { api: a } = useApiClient(), o = useQueryClient(), s;
18
- r[0] === a ? s = r[1] : (s = (e) => a.environments.replaceEnvironments(e.workspaceId, e.environments), r[0] = a, r[1] = s);
19
- let l;
20
- r[2] === o ? l = r[3] : (l = (e, t) => {
21
- o.invalidateQueries({ queryKey: ["workspace-environments", t.workspaceId] });
22
- }, r[2] = o, r[3] = l);
23
+ let i = c(8), o = useLoopstackClient(), s = useQueryClient(), l;
24
+ i[0] === o ? l = i[1] : (l = (e) => o.http.put(environmentsPath(e.workspaceId), e.environments), i[0] = o, i[1] = l);
23
25
  let u;
24
- return r[4] !== s || r[5] !== l ? (u = {
25
- mutationFn: s,
26
- onSuccess: l
27
- }, r[4] = s, r[5] = l, r[6] = u) : u = r[6], useMutation(u);
26
+ i[2] !== o || i[3] !== s ? (u = (e, n) => {
27
+ s.invalidateQueries({ queryKey: [
28
+ "workspace-environments",
29
+ o.envKey,
30
+ n.workspaceId
31
+ ] });
32
+ }, i[2] = o, i[3] = s, i[4] = u) : u = i[4];
33
+ let d;
34
+ return i[5] !== l || i[6] !== u ? (d = {
35
+ mutationFn: l,
36
+ onSuccess: u
37
+ }, i[5] = l, i[6] = u, i[7] = d) : d = i[7], useMutation(d);
28
38
  }
29
39
  function useResetEnvironment() {
30
- let r = c(2), { api: i } = useApiClient(), a;
31
- return r[0] === i ? a = r[1] : (a = { mutationFn: (e) => i.environments.resetEnvironment(e) }, r[0] = i, r[1] = a), useMutation(a);
40
+ let i = c(2), a = useLoopstackClient(), o;
41
+ return i[0] === a ? o = i[1] : (o = { mutationFn: (e) => a.http.post(`${environmentsPath(e.workspaceId)}/${e.slotId}/reset`) }, i[0] = a, i[1] = o), useMutation(o);
32
42
  }
33
43
  export { useReplaceEnvironments, useResetEnvironment, useWorkspaceEnvironments };
@@ -1,31 +1,2 @@
1
- import { getWorkflowsCacheKey } from "./query-keys.js";
2
- import { useApiClient } from "./useApi.js";
3
- import { c } from "react/compiler-runtime";
4
- import { useMutation, useQueryClient } from "@tanstack/react-query";
5
- function useRunWorkflow() {
6
- let a = c(8), { envKey: o, api: s } = useApiClient(), l = useQueryClient(), u;
7
- a[0] === s ? u = a[1] : (u = (e) => s.processor.runWorkflow(e), a[0] = s, a[1] = u);
8
- let d;
9
- a[2] !== o || a[3] !== l ? (d = () => {
10
- l.invalidateQueries({ queryKey: getWorkflowsCacheKey(o) });
11
- }, a[2] = o, a[3] = l, a[4] = d) : d = a[4];
12
- let f;
13
- return a[5] !== u || a[6] !== d ? (f = {
14
- mutationFn: u,
15
- onSuccess: d
16
- }, a[5] = u, a[6] = d, a[7] = f) : f = a[7], useMutation(f);
17
- }
18
- function useStartWorkflow() {
19
- let a = c(8), { envKey: o, api: s } = useApiClient(), l = useQueryClient(), u;
20
- a[0] === s ? u = a[1] : (u = (e) => s.processor.startWorkflow(e), a[0] = s, a[1] = u);
21
- let d;
22
- a[2] !== o || a[3] !== l ? (d = () => {
23
- l.invalidateQueries({ queryKey: getWorkflowsCacheKey(o) });
24
- }, a[2] = o, a[3] = l, a[4] = d) : d = a[4];
25
- let f;
26
- return a[5] !== u || a[6] !== d ? (f = {
27
- mutationFn: u,
28
- onSuccess: d
29
- }, a[5] = u, a[6] = d, a[7] = f) : f = a[7], useMutation(f);
30
- }
31
- export { useRunWorkflow, useStartWorkflow };
1
+ import { useRunWorkflow, useStartWorkflow } from "../packages/react/dist/hooks/mutations.js";
2
+ import "../packages/react/dist/index.js";
@@ -1,69 +1,87 @@
1
- import { getSecretsCacheKey } from "./query-keys.js";
2
- import { useApiClient } from "./useApi.js";
1
+ import { useLoopstackClient } from "../packages/react/dist/provider.js";
2
+ import { queryKeys } from "../packages/client/dist/queries/query-keys.js";
3
+ import "../packages/client/dist/index.js";
4
+ import "../packages/react/dist/index.js";
3
5
  import { c } from "react/compiler-runtime";
4
6
  import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
5
- function useWorkspaceSecrets(r) {
6
- let a = c(10), { envKey: o, api: s } = useApiClient(), l;
7
- a[0] !== o || a[1] !== r ? (l = getSecretsCacheKey(o, r), a[0] = o, a[1] = r, a[2] = l) : l = a[2];
8
- let u;
9
- a[3] !== s || a[4] !== r ? (u = () => s.secrets.getByWorkspaceId({ workspaceId: r }), a[3] = s, a[4] = r, a[5] = u) : u = a[5];
10
- let d = !!r, f;
11
- return a[6] !== l || a[7] !== u || a[8] !== d ? (f = {
12
- queryKey: l,
13
- queryFn: u,
14
- enabled: d
15
- }, a[6] = l, a[7] = u, a[8] = d, a[9] = f) : f = a[9], useQuery(f);
7
+ var secretsPath = (e) => `/api/v1/workspaces/${e}/secrets`;
8
+ function useWorkspaceSecrets(a) {
9
+ let s = c(10), u = useLoopstackClient(), d;
10
+ s[0] !== u.envKey || s[1] !== a ? (d = queryKeys.secrets(u.envKey, a), s[0] = u.envKey, s[1] = a, s[2] = d) : d = s[2];
11
+ let f;
12
+ s[3] !== u.http || s[4] !== a ? (f = () => u.http.get(secretsPath(a)), s[3] = u.http, s[4] = a, s[5] = f) : f = s[5];
13
+ let p = !!a, m;
14
+ return s[6] !== d || s[7] !== f || s[8] !== p ? (m = {
15
+ queryKey: d,
16
+ queryFn: f,
17
+ enabled: p
18
+ }, s[6] = d, s[7] = f, s[8] = p, s[9] = m) : m = s[9], useQuery(m);
19
+ }
20
+ function useApplySecret() {
21
+ let a = c(3), o = useLoopstackClient(), l = useQueryClient(), u;
22
+ return a[0] !== o.envKey || a[1] !== l ? (u = (e, i) => {
23
+ l.setQueryData(queryKeys.secrets(o.envKey, e), (e) => {
24
+ if (!e) return e;
25
+ let r = e.findIndex((e) => e.id === i.id);
26
+ if (r === -1) return [...e, i].sort(_temp);
27
+ let a = [...e];
28
+ return a[r] = i, a;
29
+ });
30
+ }, a[0] = o.envKey, a[1] = l, a[2] = u) : u = a[2], u;
31
+ }
32
+ function _temp(e, r) {
33
+ return e.key.localeCompare(r.key);
16
34
  }
17
35
  function useCreateSecret() {
18
- let i = c(8), { envKey: o, api: s } = useApiClient(), l = useQueryClient(), u;
19
- i[0] === s ? u = i[1] : (u = (e) => s.secrets.create(e), i[0] = s, i[1] = u);
20
- let d;
21
- i[2] !== o || i[3] !== l ? (d = (t, n) => {
22
- l.invalidateQueries({ queryKey: getSecretsCacheKey(o, n.workspaceId) });
23
- }, i[2] = o, i[3] = l, i[4] = d) : d = i[4];
36
+ let r = c(7), o = useLoopstackClient(), s = useApplySecret(), u;
37
+ r[0] === o ? u = r[1] : (u = (e) => o.http.post(secretsPath(e.workspaceId), {
38
+ key: e.key,
39
+ value: e.value
40
+ }), r[0] = o, r[1] = u);
24
41
  let f;
25
- return i[5] !== u || i[6] !== d ? (f = {
42
+ r[2] === s ? f = r[3] : (f = (e, r) => s(r.workspaceId, e), r[2] = s, r[3] = f);
43
+ let p;
44
+ return r[4] !== u || r[5] !== f ? (p = {
26
45
  mutationFn: u,
27
- onSuccess: d
28
- }, i[5] = u, i[6] = d, i[7] = f) : f = i[7], useMutation(f);
46
+ onSuccess: f
47
+ }, r[4] = u, r[5] = f, r[6] = p) : p = r[6], useMutation(p);
29
48
  }
30
- function useUpdateSecret() {
31
- let i = c(8), { envKey: o, api: s } = useApiClient(), l = useQueryClient(), u;
32
- i[0] === s ? u = i[1] : (u = (e) => s.secrets.update(e), i[0] = s, i[1] = u);
33
- let d;
34
- i[2] !== o || i[3] !== l ? (d = (t, n) => {
35
- l.invalidateQueries({ queryKey: getSecretsCacheKey(o, n.workspaceId) });
36
- }, i[2] = o, i[3] = l, i[4] = d) : d = i[4];
49
+ function useUpsertSecret() {
50
+ let r = c(7), o = useLoopstackClient(), s = useApplySecret(), u;
51
+ r[0] === o ? u = r[1] : (u = (e) => o.http.put(`${secretsPath(e.workspaceId)}/upsert`, {
52
+ key: e.key,
53
+ value: e.value
54
+ }), r[0] = o, r[1] = u);
37
55
  let f;
38
- return i[5] !== u || i[6] !== d ? (f = {
56
+ r[2] === s ? f = r[3] : (f = (e, r) => s(r.workspaceId, e), r[2] = s, r[3] = f);
57
+ let p;
58
+ return r[4] !== u || r[5] !== f ? (p = {
39
59
  mutationFn: u,
40
- onSuccess: d
41
- }, i[5] = u, i[6] = d, i[7] = f) : f = i[7], useMutation(f);
60
+ onSuccess: f
61
+ }, r[4] = u, r[5] = f, r[6] = p) : p = r[6], useMutation(p);
42
62
  }
43
- function useUpsertSecret() {
44
- let i = c(8), { envKey: o, api: s } = useApiClient(), l = useQueryClient(), u;
45
- i[0] === s ? u = i[1] : (u = (e) => s.secrets.upsert(e), i[0] = s, i[1] = u);
46
- let d;
47
- i[2] !== o || i[3] !== l ? (d = (t, n) => {
48
- l.invalidateQueries({ queryKey: getSecretsCacheKey(o, n.workspaceId) });
49
- }, i[2] = o, i[3] = l, i[4] = d) : d = i[4];
63
+ function useUpdateSecret() {
64
+ let r = c(7), o = useLoopstackClient(), s = useApplySecret(), u;
65
+ r[0] === o ? u = r[1] : (u = (e) => o.http.put(`${secretsPath(e.workspaceId)}/${e.id}`, { value: e.value }), r[0] = o, r[1] = u);
50
66
  let f;
51
- return i[5] !== u || i[6] !== d ? (f = {
67
+ r[2] === s ? f = r[3] : (f = (e, r) => s(r.workspaceId, e), r[2] = s, r[3] = f);
68
+ let p;
69
+ return r[4] !== u || r[5] !== f ? (p = {
52
70
  mutationFn: u,
53
- onSuccess: d
54
- }, i[5] = u, i[6] = d, i[7] = f) : f = i[7], useMutation(f);
71
+ onSuccess: f
72
+ }, r[4] = u, r[5] = f, r[6] = p) : p = r[6], useMutation(p);
55
73
  }
56
74
  function useDeleteSecret() {
57
- let i = c(8), { envKey: o, api: s } = useApiClient(), l = useQueryClient(), u;
58
- i[0] === s ? u = i[1] : (u = (e) => s.secrets.delete(e), i[0] = s, i[1] = u);
59
- let d;
60
- i[2] !== o || i[3] !== l ? (d = (t, n) => {
61
- l.invalidateQueries({ queryKey: getSecretsCacheKey(o, n.workspaceId) });
62
- }, i[2] = o, i[3] = l, i[4] = d) : d = i[4];
63
- let f;
64
- return i[5] !== u || i[6] !== d ? (f = {
65
- mutationFn: u,
66
- onSuccess: d
67
- }, i[5] = u, i[6] = d, i[7] = f) : f = i[7], useMutation(f);
75
+ let o = c(8), u = useLoopstackClient(), d = useQueryClient(), f;
76
+ o[0] === u ? f = o[1] : (f = (e) => u.http.delete(`${secretsPath(e.workspaceId)}/${e.id}`), o[0] = u, o[1] = f);
77
+ let p;
78
+ o[2] !== u || o[3] !== d ? (p = (e, i) => {
79
+ d.setQueryData(queryKeys.secrets(u.envKey, i.workspaceId), (e) => e?.filter((e) => e.id !== i.id));
80
+ }, o[2] = u, o[3] = d, o[4] = p) : p = o[4];
81
+ let m;
82
+ return o[5] !== f || o[6] !== p ? (m = {
83
+ mutationFn: f,
84
+ onSuccess: p
85
+ }, o[5] = f, o[6] = p, o[7] = m) : m = o[7], useMutation(m);
68
86
  }
69
87
  export { useCreateSecret, useDeleteSecret, useUpdateSecret, useUpsertSecret, useWorkspaceSecrets };