@powerhousedao/workflow 6.2.3-dev.33 → 6.2.3-dev.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/BlockSelector-M4p5MOwM.js +7611 -0
- package/dist/browser/BlockSelector-M4p5MOwM.js.map +1 -0
- package/dist/browser/assets/{entry-D62sYiFV.js → entry-DPGDRzne.js} +5 -2
- package/dist/browser/assets/{projection-entry-BGcu_9-p.js → projection-entry-EcOymKPg.js} +42 -6
- package/dist/browser/{connection-form-Br-IM_CW.js → connection-form-Bh7ONQxz.js} +20 -21
- package/dist/browser/connection-form-Bh7ONQxz.js.map +1 -0
- package/dist/browser/{data-tree-CZZkfzSH.js → data-tree-Bicz9eW6.js} +2 -2
- package/dist/browser/{data-tree-CZZkfzSH.js.map → data-tree-Bicz9eW6.js.map} +1 -1
- package/dist/browser/{editor-DjSMG-EP.js → editor-B0YlNGFs.js} +3 -3
- package/dist/browser/{editor-DjSMG-EP.js.map → editor-B0YlNGFs.js.map} +1 -1
- package/dist/browser/{editor-p9gVC4FY.js → editor-CYKLDgER.js} +26 -11
- package/dist/browser/editor-CYKLDgER.js.map +1 -0
- package/dist/browser/{editor-CtErqBMO.js → editor-DgCrC5jt.js} +3 -3
- package/dist/browser/{editor-CtErqBMO.js.map → editor-DgCrC5jt.js.map} +1 -1
- package/dist/browser/editors/connection-editor/module.js +1 -1
- package/dist/browser/editors/workflow-editor/module.js +1 -1
- package/dist/browser/editors/workflow-studio/module.js +1 -1
- package/dist/browser/index.js +3 -2
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/{trigger-text-D-Sh6ZaI.js → trigger-text-DEN9d_Np.js} +4 -4
- package/dist/browser/{trigger-text-D-Sh6ZaI.js.map → trigger-text-DEN9d_Np.js.map} +1 -1
- package/dist/node/BlockSelector-oFCoEF5-.mjs +7615 -0
- package/dist/node/BlockSelector-oFCoEF5-.mjs.map +1 -0
- package/dist/node/{connection-form-Dzn4yM2g.mjs → connection-form-BpEzDxCH.mjs} +20 -21
- package/dist/node/connection-form-BpEzDxCH.mjs.map +1 -0
- package/dist/node/{data-tree-CGfeCLr7.mjs → data-tree-B7JQu1SB.mjs} +2 -2
- package/dist/node/{data-tree-CGfeCLr7.mjs.map → data-tree-B7JQu1SB.mjs.map} +1 -1
- package/dist/node/{editor-CcbIharn.mjs → editor-BM7pThg7.mjs} +3 -3
- package/dist/node/{editor-CcbIharn.mjs.map → editor-BM7pThg7.mjs.map} +1 -1
- package/dist/node/{editor-DWzOzXQC.mjs → editor-CzKE95pe.mjs} +26 -11
- package/dist/node/editor-CzKE95pe.mjs.map +1 -0
- package/dist/node/{editor-Cv2Vn_A-.mjs → editor-UKph34A9.mjs} +3 -3
- package/dist/node/{editor-Cv2Vn_A-.mjs.map → editor-UKph34A9.mjs.map} +1 -1
- package/dist/node/editors/connection-editor/module.mjs +1 -1
- package/dist/node/editors/workflow-editor/module.mjs +1 -1
- package/dist/node/editors/workflow-studio/module.mjs +1 -1
- package/dist/node/index.mjs +3 -2
- package/dist/node/index.mjs.map +1 -1
- package/dist/node/pieces/reactor/descriptor.json +1 -1
- package/dist/node/pieces/reactor/package.json +1 -1
- package/dist/node/{trigger-text-CZEtYmPw.mjs → trigger-text-5wi1Ve6Z.mjs} +4 -4
- package/dist/node/{trigger-text-CZEtYmPw.mjs.map → trigger-text-5wi1Ve6Z.mjs.map} +1 -1
- package/dist/powerhouse.manifest.json +1 -1
- package/dist/types/ai/workflow-tools.d.ts.map +1 -1
- package/dist/types/editors/shared/editor-chrome.d.ts.map +1 -1
- package/dist/types/editors/shared/undo-plan.d.ts +1 -1
- package/dist/types/editors/shared/undo-plan.d.ts.map +1 -1
- package/dist/types/editors/workflow-editor/editor.d.ts.map +1 -1
- package/dist/types/editors/workflow-editor/ui/WorkflowEditorApp.d.ts.map +1 -1
- package/dist/types/editors/workflow-editor/undo-policy.d.ts +3 -0
- package/dist/types/editors/workflow-editor/undo-policy.d.ts.map +1 -0
- package/dist/types/editors/workflow-editor/undo-policy.test.d.ts +2 -0
- package/dist/types/editors/workflow-editor/undo-policy.test.d.ts.map +1 -0
- package/dist/types/scripts/ui-stack.d.ts.map +1 -1
- package/package.json +8 -8
- package/dist/browser/BlockSelector-BQDqIbRZ.js +0 -3053
- package/dist/browser/BlockSelector-BQDqIbRZ.js.map +0 -1
- package/dist/browser/connection-form-Br-IM_CW.js.map +0 -1
- package/dist/browser/editor-p9gVC4FY.js.map +0 -1
- package/dist/node/BlockSelector-C3XYZfPY.mjs +0 -3057
- package/dist/node/BlockSelector-C3XYZfPY.mjs.map +0 -1
- package/dist/node/connection-form-Dzn4yM2g.mjs.map +0 -1
- package/dist/node/editor-DWzOzXQC.mjs.map +0 -1
|
@@ -1,3057 +0,0 @@
|
|
|
1
|
-
import { $ as pinBlock, A as keepPreviousData, B as Subscribable, C as infiniteQueryBehavior, D as focusManager, E as pendingThenable, F as resolveStaleTime, G as BRANCH_BLOCK, H as createRuntimeClient, I as shallowEqualObjects, J as SCHEDULE_TRIGGER, L as shouldThrowError, M as replaceData, N as replaceEqualDeep, O as isServer, P as resolveEnabled, Q as isCoreBlock, R as timeUntilStale, S as hasPreviousPage, T as notifyManager, U as isSyncingError, W as ASSERT_BLOCK, Z as WEBHOOK_TRIGGER, _ as runtimeKeys, a as pieceActionsQuery, b as QueryClient, c as runQuery, d as secretStatQuery, dt as scheduleConfigIssue, g as queryKind, h as blockRefKey, j as noop, k as isValidTimeout, m as SHARED_STALE_MS, n as catalogQuery, o as pieceTriggersQuery, p as RESOLVER_STALE_MS, q as MANUAL_TRIGGER, r as createRuntimeQueryClient, s as runPagesQuery, st as checkTriggerStrategy, tt as stepBlock, u as runsQuery, w as fetchState, x as hasNextPage, z as timeoutManager } from "./runtime-queries-D5EGaCrH.mjs";
|
|
2
|
-
import { Rt as blockKey, zt as compareVersions } from "./module-Dhe5E-VA.mjs";
|
|
3
|
-
import * as React$1 from "react";
|
|
4
|
-
import { Component, Fragment, createContext, useContext, useEffect, useId, useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
|
|
5
|
-
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
-
import { DEFAULT_SWITCHBOARD_URL, parseDriveUrl, subgraphUrlFromGraphqlUrl, useDefaultDrivesUrl, useSelectedDriveSafe, useSyncList } from "@powerhousedao/reactor-browser";
|
|
7
|
-
import { DOCUMENT_SCOPE_ACTION_TYPES } from "@powerhousedao/shared/document-model";
|
|
8
|
-
import { createPortal } from "react-dom";
|
|
9
|
-
//#region ../../node_modules/.pnpm/@tanstack+query-core@5.90.20/node_modules/@tanstack/query-core/build/modern/queryObserver.js
|
|
10
|
-
var QueryObserver = class extends Subscribable {
|
|
11
|
-
constructor(client, options) {
|
|
12
|
-
super();
|
|
13
|
-
this.options = options;
|
|
14
|
-
this.#client = client;
|
|
15
|
-
this.#selectError = null;
|
|
16
|
-
this.#currentThenable = pendingThenable();
|
|
17
|
-
this.bindMethods();
|
|
18
|
-
this.setOptions(options);
|
|
19
|
-
}
|
|
20
|
-
#client;
|
|
21
|
-
#currentQuery = void 0;
|
|
22
|
-
#currentQueryInitialState = void 0;
|
|
23
|
-
#currentResult = void 0;
|
|
24
|
-
#currentResultState;
|
|
25
|
-
#currentResultOptions;
|
|
26
|
-
#currentThenable;
|
|
27
|
-
#selectError;
|
|
28
|
-
#selectFn;
|
|
29
|
-
#selectResult;
|
|
30
|
-
#lastQueryWithDefinedData;
|
|
31
|
-
#staleTimeoutId;
|
|
32
|
-
#refetchIntervalId;
|
|
33
|
-
#currentRefetchInterval;
|
|
34
|
-
#trackedProps = /* @__PURE__ */ new Set();
|
|
35
|
-
bindMethods() {
|
|
36
|
-
this.refetch = this.refetch.bind(this);
|
|
37
|
-
}
|
|
38
|
-
onSubscribe() {
|
|
39
|
-
if (this.listeners.size === 1) {
|
|
40
|
-
this.#currentQuery.addObserver(this);
|
|
41
|
-
if (shouldFetchOnMount(this.#currentQuery, this.options)) this.#executeFetch();
|
|
42
|
-
else this.updateResult();
|
|
43
|
-
this.#updateTimers();
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
onUnsubscribe() {
|
|
47
|
-
if (!this.hasListeners()) this.destroy();
|
|
48
|
-
}
|
|
49
|
-
shouldFetchOnReconnect() {
|
|
50
|
-
return shouldFetchOn(this.#currentQuery, this.options, this.options.refetchOnReconnect);
|
|
51
|
-
}
|
|
52
|
-
shouldFetchOnWindowFocus() {
|
|
53
|
-
return shouldFetchOn(this.#currentQuery, this.options, this.options.refetchOnWindowFocus);
|
|
54
|
-
}
|
|
55
|
-
destroy() {
|
|
56
|
-
this.listeners = /* @__PURE__ */ new Set();
|
|
57
|
-
this.#clearStaleTimeout();
|
|
58
|
-
this.#clearRefetchInterval();
|
|
59
|
-
this.#currentQuery.removeObserver(this);
|
|
60
|
-
}
|
|
61
|
-
setOptions(options) {
|
|
62
|
-
const prevOptions = this.options;
|
|
63
|
-
const prevQuery = this.#currentQuery;
|
|
64
|
-
this.options = this.#client.defaultQueryOptions(options);
|
|
65
|
-
if (this.options.enabled !== void 0 && typeof this.options.enabled !== "boolean" && typeof this.options.enabled !== "function" && typeof resolveEnabled(this.options.enabled, this.#currentQuery) !== "boolean") throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");
|
|
66
|
-
this.#updateQuery();
|
|
67
|
-
this.#currentQuery.setOptions(this.options);
|
|
68
|
-
if (prevOptions._defaulted && !shallowEqualObjects(this.options, prevOptions)) this.#client.getQueryCache().notify({
|
|
69
|
-
type: "observerOptionsUpdated",
|
|
70
|
-
query: this.#currentQuery,
|
|
71
|
-
observer: this
|
|
72
|
-
});
|
|
73
|
-
const mounted = this.hasListeners();
|
|
74
|
-
if (mounted && shouldFetchOptionally(this.#currentQuery, prevQuery, this.options, prevOptions)) this.#executeFetch();
|
|
75
|
-
this.updateResult();
|
|
76
|
-
if (mounted && (this.#currentQuery !== prevQuery || resolveEnabled(this.options.enabled, this.#currentQuery) !== resolveEnabled(prevOptions.enabled, this.#currentQuery) || resolveStaleTime(this.options.staleTime, this.#currentQuery) !== resolveStaleTime(prevOptions.staleTime, this.#currentQuery))) this.#updateStaleTimeout();
|
|
77
|
-
const nextRefetchInterval = this.#computeRefetchInterval();
|
|
78
|
-
if (mounted && (this.#currentQuery !== prevQuery || resolveEnabled(this.options.enabled, this.#currentQuery) !== resolveEnabled(prevOptions.enabled, this.#currentQuery) || nextRefetchInterval !== this.#currentRefetchInterval)) this.#updateRefetchInterval(nextRefetchInterval);
|
|
79
|
-
}
|
|
80
|
-
getOptimisticResult(options) {
|
|
81
|
-
const query = this.#client.getQueryCache().build(this.#client, options);
|
|
82
|
-
const result = this.createResult(query, options);
|
|
83
|
-
if (shouldAssignObserverCurrentProperties(this, result)) {
|
|
84
|
-
this.#currentResult = result;
|
|
85
|
-
this.#currentResultOptions = this.options;
|
|
86
|
-
this.#currentResultState = this.#currentQuery.state;
|
|
87
|
-
}
|
|
88
|
-
return result;
|
|
89
|
-
}
|
|
90
|
-
getCurrentResult() {
|
|
91
|
-
return this.#currentResult;
|
|
92
|
-
}
|
|
93
|
-
trackResult(result, onPropTracked) {
|
|
94
|
-
return new Proxy(result, { get: (target, key) => {
|
|
95
|
-
this.trackProp(key);
|
|
96
|
-
onPropTracked?.(key);
|
|
97
|
-
if (key === "promise") {
|
|
98
|
-
this.trackProp("data");
|
|
99
|
-
if (!this.options.experimental_prefetchInRender && this.#currentThenable.status === "pending") this.#currentThenable.reject(/* @__PURE__ */ new Error("experimental_prefetchInRender feature flag is not enabled"));
|
|
100
|
-
}
|
|
101
|
-
return Reflect.get(target, key);
|
|
102
|
-
} });
|
|
103
|
-
}
|
|
104
|
-
trackProp(key) {
|
|
105
|
-
this.#trackedProps.add(key);
|
|
106
|
-
}
|
|
107
|
-
getCurrentQuery() {
|
|
108
|
-
return this.#currentQuery;
|
|
109
|
-
}
|
|
110
|
-
refetch({ ...options } = {}) {
|
|
111
|
-
return this.fetch({ ...options });
|
|
112
|
-
}
|
|
113
|
-
fetchOptimistic(options) {
|
|
114
|
-
const defaultedOptions = this.#client.defaultQueryOptions(options);
|
|
115
|
-
const query = this.#client.getQueryCache().build(this.#client, defaultedOptions);
|
|
116
|
-
return query.fetch().then(() => this.createResult(query, defaultedOptions));
|
|
117
|
-
}
|
|
118
|
-
fetch(fetchOptions) {
|
|
119
|
-
return this.#executeFetch({
|
|
120
|
-
...fetchOptions,
|
|
121
|
-
cancelRefetch: fetchOptions.cancelRefetch ?? true
|
|
122
|
-
}).then(() => {
|
|
123
|
-
this.updateResult();
|
|
124
|
-
return this.#currentResult;
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
#executeFetch(fetchOptions) {
|
|
128
|
-
this.#updateQuery();
|
|
129
|
-
let promise = this.#currentQuery.fetch(this.options, fetchOptions);
|
|
130
|
-
if (!fetchOptions?.throwOnError) promise = promise.catch(noop);
|
|
131
|
-
return promise;
|
|
132
|
-
}
|
|
133
|
-
#updateStaleTimeout() {
|
|
134
|
-
this.#clearStaleTimeout();
|
|
135
|
-
const staleTime = resolveStaleTime(this.options.staleTime, this.#currentQuery);
|
|
136
|
-
if (isServer || this.#currentResult.isStale || !isValidTimeout(staleTime)) return;
|
|
137
|
-
const timeout = timeUntilStale(this.#currentResult.dataUpdatedAt, staleTime) + 1;
|
|
138
|
-
this.#staleTimeoutId = timeoutManager.setTimeout(() => {
|
|
139
|
-
if (!this.#currentResult.isStale) this.updateResult();
|
|
140
|
-
}, timeout);
|
|
141
|
-
}
|
|
142
|
-
#computeRefetchInterval() {
|
|
143
|
-
return (typeof this.options.refetchInterval === "function" ? this.options.refetchInterval(this.#currentQuery) : this.options.refetchInterval) ?? false;
|
|
144
|
-
}
|
|
145
|
-
#updateRefetchInterval(nextInterval) {
|
|
146
|
-
this.#clearRefetchInterval();
|
|
147
|
-
this.#currentRefetchInterval = nextInterval;
|
|
148
|
-
if (isServer || resolveEnabled(this.options.enabled, this.#currentQuery) === false || !isValidTimeout(this.#currentRefetchInterval) || this.#currentRefetchInterval === 0) return;
|
|
149
|
-
this.#refetchIntervalId = timeoutManager.setInterval(() => {
|
|
150
|
-
if (this.options.refetchIntervalInBackground || focusManager.isFocused()) this.#executeFetch();
|
|
151
|
-
}, this.#currentRefetchInterval);
|
|
152
|
-
}
|
|
153
|
-
#updateTimers() {
|
|
154
|
-
this.#updateStaleTimeout();
|
|
155
|
-
this.#updateRefetchInterval(this.#computeRefetchInterval());
|
|
156
|
-
}
|
|
157
|
-
#clearStaleTimeout() {
|
|
158
|
-
if (this.#staleTimeoutId) {
|
|
159
|
-
timeoutManager.clearTimeout(this.#staleTimeoutId);
|
|
160
|
-
this.#staleTimeoutId = void 0;
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
#clearRefetchInterval() {
|
|
164
|
-
if (this.#refetchIntervalId) {
|
|
165
|
-
timeoutManager.clearInterval(this.#refetchIntervalId);
|
|
166
|
-
this.#refetchIntervalId = void 0;
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
createResult(query, options) {
|
|
170
|
-
const prevQuery = this.#currentQuery;
|
|
171
|
-
const prevOptions = this.options;
|
|
172
|
-
const prevResult = this.#currentResult;
|
|
173
|
-
const prevResultState = this.#currentResultState;
|
|
174
|
-
const prevResultOptions = this.#currentResultOptions;
|
|
175
|
-
const queryInitialState = query !== prevQuery ? query.state : this.#currentQueryInitialState;
|
|
176
|
-
const { state } = query;
|
|
177
|
-
let newState = { ...state };
|
|
178
|
-
let isPlaceholderData = false;
|
|
179
|
-
let data;
|
|
180
|
-
if (options._optimisticResults) {
|
|
181
|
-
const mounted = this.hasListeners();
|
|
182
|
-
const fetchOnMount = !mounted && shouldFetchOnMount(query, options);
|
|
183
|
-
const fetchOptionally = mounted && shouldFetchOptionally(query, prevQuery, options, prevOptions);
|
|
184
|
-
if (fetchOnMount || fetchOptionally) newState = {
|
|
185
|
-
...newState,
|
|
186
|
-
...fetchState(state.data, query.options)
|
|
187
|
-
};
|
|
188
|
-
if (options._optimisticResults === "isRestoring") newState.fetchStatus = "idle";
|
|
189
|
-
}
|
|
190
|
-
let { error, errorUpdatedAt, status } = newState;
|
|
191
|
-
data = newState.data;
|
|
192
|
-
let skipSelect = false;
|
|
193
|
-
if (options.placeholderData !== void 0 && data === void 0 && status === "pending") {
|
|
194
|
-
let placeholderData;
|
|
195
|
-
if (prevResult?.isPlaceholderData && options.placeholderData === prevResultOptions?.placeholderData) {
|
|
196
|
-
placeholderData = prevResult.data;
|
|
197
|
-
skipSelect = true;
|
|
198
|
-
} else placeholderData = typeof options.placeholderData === "function" ? options.placeholderData(this.#lastQueryWithDefinedData?.state.data, this.#lastQueryWithDefinedData) : options.placeholderData;
|
|
199
|
-
if (placeholderData !== void 0) {
|
|
200
|
-
status = "success";
|
|
201
|
-
data = replaceData(prevResult?.data, placeholderData, options);
|
|
202
|
-
isPlaceholderData = true;
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
if (options.select && data !== void 0 && !skipSelect) {
|
|
206
|
-
if (prevResult && data === prevResultState?.data && options.select === this.#selectFn) data = this.#selectResult;
|
|
207
|
-
else try {
|
|
208
|
-
this.#selectFn = options.select;
|
|
209
|
-
data = options.select(data);
|
|
210
|
-
data = replaceData(prevResult?.data, data, options);
|
|
211
|
-
this.#selectResult = data;
|
|
212
|
-
this.#selectError = null;
|
|
213
|
-
} catch (selectError) {
|
|
214
|
-
this.#selectError = selectError;
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
if (this.#selectError) {
|
|
218
|
-
error = this.#selectError;
|
|
219
|
-
data = this.#selectResult;
|
|
220
|
-
errorUpdatedAt = Date.now();
|
|
221
|
-
status = "error";
|
|
222
|
-
}
|
|
223
|
-
const isFetching = newState.fetchStatus === "fetching";
|
|
224
|
-
const isPending = status === "pending";
|
|
225
|
-
const isError = status === "error";
|
|
226
|
-
const isLoading = isPending && isFetching;
|
|
227
|
-
const hasData = data !== void 0;
|
|
228
|
-
const nextResult = {
|
|
229
|
-
status,
|
|
230
|
-
fetchStatus: newState.fetchStatus,
|
|
231
|
-
isPending,
|
|
232
|
-
isSuccess: status === "success",
|
|
233
|
-
isError,
|
|
234
|
-
isInitialLoading: isLoading,
|
|
235
|
-
isLoading,
|
|
236
|
-
data,
|
|
237
|
-
dataUpdatedAt: newState.dataUpdatedAt,
|
|
238
|
-
error,
|
|
239
|
-
errorUpdatedAt,
|
|
240
|
-
failureCount: newState.fetchFailureCount,
|
|
241
|
-
failureReason: newState.fetchFailureReason,
|
|
242
|
-
errorUpdateCount: newState.errorUpdateCount,
|
|
243
|
-
isFetched: newState.dataUpdateCount > 0 || newState.errorUpdateCount > 0,
|
|
244
|
-
isFetchedAfterMount: newState.dataUpdateCount > queryInitialState.dataUpdateCount || newState.errorUpdateCount > queryInitialState.errorUpdateCount,
|
|
245
|
-
isFetching,
|
|
246
|
-
isRefetching: isFetching && !isPending,
|
|
247
|
-
isLoadingError: isError && !hasData,
|
|
248
|
-
isPaused: newState.fetchStatus === "paused",
|
|
249
|
-
isPlaceholderData,
|
|
250
|
-
isRefetchError: isError && hasData,
|
|
251
|
-
isStale: isStale(query, options),
|
|
252
|
-
refetch: this.refetch,
|
|
253
|
-
promise: this.#currentThenable,
|
|
254
|
-
isEnabled: resolveEnabled(options.enabled, query) !== false
|
|
255
|
-
};
|
|
256
|
-
if (this.options.experimental_prefetchInRender) {
|
|
257
|
-
const hasResultData = nextResult.data !== void 0;
|
|
258
|
-
const isErrorWithoutData = nextResult.status === "error" && !hasResultData;
|
|
259
|
-
const finalizeThenableIfPossible = (thenable) => {
|
|
260
|
-
if (isErrorWithoutData) thenable.reject(nextResult.error);
|
|
261
|
-
else if (hasResultData) thenable.resolve(nextResult.data);
|
|
262
|
-
};
|
|
263
|
-
const recreateThenable = () => {
|
|
264
|
-
const pending = this.#currentThenable = nextResult.promise = pendingThenable();
|
|
265
|
-
finalizeThenableIfPossible(pending);
|
|
266
|
-
};
|
|
267
|
-
const prevThenable = this.#currentThenable;
|
|
268
|
-
switch (prevThenable.status) {
|
|
269
|
-
case "pending":
|
|
270
|
-
if (query.queryHash === prevQuery.queryHash) finalizeThenableIfPossible(prevThenable);
|
|
271
|
-
break;
|
|
272
|
-
case "fulfilled":
|
|
273
|
-
if (isErrorWithoutData || nextResult.data !== prevThenable.value) recreateThenable();
|
|
274
|
-
break;
|
|
275
|
-
case "rejected": if (!isErrorWithoutData || nextResult.error !== prevThenable.reason) recreateThenable();
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
return nextResult;
|
|
279
|
-
}
|
|
280
|
-
updateResult() {
|
|
281
|
-
const prevResult = this.#currentResult;
|
|
282
|
-
const nextResult = this.createResult(this.#currentQuery, this.options);
|
|
283
|
-
this.#currentResultState = this.#currentQuery.state;
|
|
284
|
-
this.#currentResultOptions = this.options;
|
|
285
|
-
if (this.#currentResultState.data !== void 0) this.#lastQueryWithDefinedData = this.#currentQuery;
|
|
286
|
-
if (shallowEqualObjects(nextResult, prevResult)) return;
|
|
287
|
-
this.#currentResult = nextResult;
|
|
288
|
-
const shouldNotifyListeners = () => {
|
|
289
|
-
if (!prevResult) return true;
|
|
290
|
-
const { notifyOnChangeProps } = this.options;
|
|
291
|
-
const notifyOnChangePropsValue = typeof notifyOnChangeProps === "function" ? notifyOnChangeProps() : notifyOnChangeProps;
|
|
292
|
-
if (notifyOnChangePropsValue === "all" || !notifyOnChangePropsValue && !this.#trackedProps.size) return true;
|
|
293
|
-
const includedProps = new Set(notifyOnChangePropsValue ?? this.#trackedProps);
|
|
294
|
-
if (this.options.throwOnError) includedProps.add("error");
|
|
295
|
-
return Object.keys(this.#currentResult).some((key) => {
|
|
296
|
-
const typedKey = key;
|
|
297
|
-
return this.#currentResult[typedKey] !== prevResult[typedKey] && includedProps.has(typedKey);
|
|
298
|
-
});
|
|
299
|
-
};
|
|
300
|
-
this.#notify({ listeners: shouldNotifyListeners() });
|
|
301
|
-
}
|
|
302
|
-
#updateQuery() {
|
|
303
|
-
const query = this.#client.getQueryCache().build(this.#client, this.options);
|
|
304
|
-
if (query === this.#currentQuery) return;
|
|
305
|
-
const prevQuery = this.#currentQuery;
|
|
306
|
-
this.#currentQuery = query;
|
|
307
|
-
this.#currentQueryInitialState = query.state;
|
|
308
|
-
if (this.hasListeners()) {
|
|
309
|
-
prevQuery?.removeObserver(this);
|
|
310
|
-
query.addObserver(this);
|
|
311
|
-
}
|
|
312
|
-
}
|
|
313
|
-
onQueryUpdate() {
|
|
314
|
-
this.updateResult();
|
|
315
|
-
if (this.hasListeners()) this.#updateTimers();
|
|
316
|
-
}
|
|
317
|
-
#notify(notifyOptions) {
|
|
318
|
-
notifyManager.batch(() => {
|
|
319
|
-
if (notifyOptions.listeners) this.listeners.forEach((listener) => {
|
|
320
|
-
listener(this.#currentResult);
|
|
321
|
-
});
|
|
322
|
-
this.#client.getQueryCache().notify({
|
|
323
|
-
query: this.#currentQuery,
|
|
324
|
-
type: "observerResultsUpdated"
|
|
325
|
-
});
|
|
326
|
-
});
|
|
327
|
-
}
|
|
328
|
-
};
|
|
329
|
-
function shouldLoadOnMount(query, options) {
|
|
330
|
-
return resolveEnabled(options.enabled, query) !== false && query.state.data === void 0 && !(query.state.status === "error" && options.retryOnMount === false);
|
|
331
|
-
}
|
|
332
|
-
function shouldFetchOnMount(query, options) {
|
|
333
|
-
return shouldLoadOnMount(query, options) || query.state.data !== void 0 && shouldFetchOn(query, options, options.refetchOnMount);
|
|
334
|
-
}
|
|
335
|
-
function shouldFetchOn(query, options, field) {
|
|
336
|
-
if (resolveEnabled(options.enabled, query) !== false && resolveStaleTime(options.staleTime, query) !== "static") {
|
|
337
|
-
const value = typeof field === "function" ? field(query) : field;
|
|
338
|
-
return value === "always" || value !== false && isStale(query, options);
|
|
339
|
-
}
|
|
340
|
-
return false;
|
|
341
|
-
}
|
|
342
|
-
function shouldFetchOptionally(query, prevQuery, options, prevOptions) {
|
|
343
|
-
return (query !== prevQuery || resolveEnabled(prevOptions.enabled, query) === false) && (!options.suspense || query.state.status !== "error") && isStale(query, options);
|
|
344
|
-
}
|
|
345
|
-
function isStale(query, options) {
|
|
346
|
-
return resolveEnabled(options.enabled, query) !== false && query.isStaleByTime(resolveStaleTime(options.staleTime, query));
|
|
347
|
-
}
|
|
348
|
-
function shouldAssignObserverCurrentProperties(observer, optimisticResult) {
|
|
349
|
-
if (!shallowEqualObjects(observer.getCurrentResult(), optimisticResult)) return true;
|
|
350
|
-
return false;
|
|
351
|
-
}
|
|
352
|
-
//#endregion
|
|
353
|
-
//#region ../../node_modules/.pnpm/@tanstack+query-core@5.90.20/node_modules/@tanstack/query-core/build/modern/infiniteQueryObserver.js
|
|
354
|
-
var InfiniteQueryObserver = class extends QueryObserver {
|
|
355
|
-
constructor(client, options) {
|
|
356
|
-
super(client, options);
|
|
357
|
-
}
|
|
358
|
-
bindMethods() {
|
|
359
|
-
super.bindMethods();
|
|
360
|
-
this.fetchNextPage = this.fetchNextPage.bind(this);
|
|
361
|
-
this.fetchPreviousPage = this.fetchPreviousPage.bind(this);
|
|
362
|
-
}
|
|
363
|
-
setOptions(options) {
|
|
364
|
-
super.setOptions({
|
|
365
|
-
...options,
|
|
366
|
-
behavior: infiniteQueryBehavior()
|
|
367
|
-
});
|
|
368
|
-
}
|
|
369
|
-
getOptimisticResult(options) {
|
|
370
|
-
options.behavior = infiniteQueryBehavior();
|
|
371
|
-
return super.getOptimisticResult(options);
|
|
372
|
-
}
|
|
373
|
-
fetchNextPage(options) {
|
|
374
|
-
return this.fetch({
|
|
375
|
-
...options,
|
|
376
|
-
meta: { fetchMore: { direction: "forward" } }
|
|
377
|
-
});
|
|
378
|
-
}
|
|
379
|
-
fetchPreviousPage(options) {
|
|
380
|
-
return this.fetch({
|
|
381
|
-
...options,
|
|
382
|
-
meta: { fetchMore: { direction: "backward" } }
|
|
383
|
-
});
|
|
384
|
-
}
|
|
385
|
-
createResult(query, options) {
|
|
386
|
-
const { state } = query;
|
|
387
|
-
const parentResult = super.createResult(query, options);
|
|
388
|
-
const { isFetching, isRefetching, isError, isRefetchError } = parentResult;
|
|
389
|
-
const fetchDirection = state.fetchMeta?.fetchMore?.direction;
|
|
390
|
-
const isFetchNextPageError = isError && fetchDirection === "forward";
|
|
391
|
-
const isFetchingNextPage = isFetching && fetchDirection === "forward";
|
|
392
|
-
const isFetchPreviousPageError = isError && fetchDirection === "backward";
|
|
393
|
-
const isFetchingPreviousPage = isFetching && fetchDirection === "backward";
|
|
394
|
-
return {
|
|
395
|
-
...parentResult,
|
|
396
|
-
fetchNextPage: this.fetchNextPage,
|
|
397
|
-
fetchPreviousPage: this.fetchPreviousPage,
|
|
398
|
-
hasNextPage: hasNextPage(options, state.data),
|
|
399
|
-
hasPreviousPage: hasPreviousPage(options, state.data),
|
|
400
|
-
isFetchNextPageError,
|
|
401
|
-
isFetchingNextPage,
|
|
402
|
-
isFetchPreviousPageError,
|
|
403
|
-
isFetchingPreviousPage,
|
|
404
|
-
isRefetchError: isRefetchError && !isFetchNextPageError && !isFetchPreviousPageError,
|
|
405
|
-
isRefetching: isRefetching && !isFetchingNextPage && !isFetchingPreviousPage
|
|
406
|
-
};
|
|
407
|
-
}
|
|
408
|
-
};
|
|
409
|
-
//#endregion
|
|
410
|
-
//#region ../../node_modules/.pnpm/@tanstack+query-core@5.90.20/node_modules/@tanstack/query-core/build/modern/queriesObserver.js
|
|
411
|
-
function difference(array1, array2) {
|
|
412
|
-
const excludeSet = new Set(array2);
|
|
413
|
-
return array1.filter((x) => !excludeSet.has(x));
|
|
414
|
-
}
|
|
415
|
-
function replaceAt(array, index, value) {
|
|
416
|
-
const copy = array.slice(0);
|
|
417
|
-
copy[index] = value;
|
|
418
|
-
return copy;
|
|
419
|
-
}
|
|
420
|
-
var QueriesObserver = class extends Subscribable {
|
|
421
|
-
#client;
|
|
422
|
-
#result;
|
|
423
|
-
#queries;
|
|
424
|
-
#options;
|
|
425
|
-
#observers;
|
|
426
|
-
#combinedResult;
|
|
427
|
-
#lastCombine;
|
|
428
|
-
#lastResult;
|
|
429
|
-
#lastQueryHashes;
|
|
430
|
-
#observerMatches = [];
|
|
431
|
-
constructor(client, queries, options) {
|
|
432
|
-
super();
|
|
433
|
-
this.#client = client;
|
|
434
|
-
this.#options = options;
|
|
435
|
-
this.#queries = [];
|
|
436
|
-
this.#observers = [];
|
|
437
|
-
this.#result = [];
|
|
438
|
-
this.setQueries(queries);
|
|
439
|
-
}
|
|
440
|
-
onSubscribe() {
|
|
441
|
-
if (this.listeners.size === 1) this.#observers.forEach((observer) => {
|
|
442
|
-
observer.subscribe((result) => {
|
|
443
|
-
this.#onUpdate(observer, result);
|
|
444
|
-
});
|
|
445
|
-
});
|
|
446
|
-
}
|
|
447
|
-
onUnsubscribe() {
|
|
448
|
-
if (!this.listeners.size) this.destroy();
|
|
449
|
-
}
|
|
450
|
-
destroy() {
|
|
451
|
-
this.listeners = /* @__PURE__ */ new Set();
|
|
452
|
-
this.#observers.forEach((observer) => {
|
|
453
|
-
observer.destroy();
|
|
454
|
-
});
|
|
455
|
-
}
|
|
456
|
-
setQueries(queries, options) {
|
|
457
|
-
this.#queries = queries;
|
|
458
|
-
this.#options = options;
|
|
459
|
-
if (process.env.NODE_ENV !== "production") {
|
|
460
|
-
const queryHashes = queries.map((query) => this.#client.defaultQueryOptions(query).queryHash);
|
|
461
|
-
if (new Set(queryHashes).size !== queryHashes.length) console.warn("[QueriesObserver]: Duplicate Queries found. This might result in unexpected behavior.");
|
|
462
|
-
}
|
|
463
|
-
notifyManager.batch(() => {
|
|
464
|
-
const prevObservers = this.#observers;
|
|
465
|
-
const newObserverMatches = this.#findMatchingObservers(this.#queries);
|
|
466
|
-
newObserverMatches.forEach((match) => match.observer.setOptions(match.defaultedQueryOptions));
|
|
467
|
-
const newObservers = newObserverMatches.map((match) => match.observer);
|
|
468
|
-
const newResult = newObservers.map((observer) => observer.getCurrentResult());
|
|
469
|
-
const hasLengthChange = prevObservers.length !== newObservers.length;
|
|
470
|
-
const hasIndexChange = newObservers.some((observer, index) => observer !== prevObservers[index]);
|
|
471
|
-
const hasStructuralChange = hasLengthChange || hasIndexChange;
|
|
472
|
-
const hasResultChange = hasStructuralChange ? true : newResult.some((result, index) => {
|
|
473
|
-
const prev = this.#result[index];
|
|
474
|
-
return !prev || !shallowEqualObjects(result, prev);
|
|
475
|
-
});
|
|
476
|
-
if (!hasStructuralChange && !hasResultChange) return;
|
|
477
|
-
if (hasStructuralChange) {
|
|
478
|
-
this.#observerMatches = newObserverMatches;
|
|
479
|
-
this.#observers = newObservers;
|
|
480
|
-
}
|
|
481
|
-
this.#result = newResult;
|
|
482
|
-
if (!this.hasListeners()) return;
|
|
483
|
-
if (hasStructuralChange) {
|
|
484
|
-
difference(prevObservers, newObservers).forEach((observer) => {
|
|
485
|
-
observer.destroy();
|
|
486
|
-
});
|
|
487
|
-
difference(newObservers, prevObservers).forEach((observer) => {
|
|
488
|
-
observer.subscribe((result) => {
|
|
489
|
-
this.#onUpdate(observer, result);
|
|
490
|
-
});
|
|
491
|
-
});
|
|
492
|
-
}
|
|
493
|
-
this.#notify();
|
|
494
|
-
});
|
|
495
|
-
}
|
|
496
|
-
getCurrentResult() {
|
|
497
|
-
return this.#result;
|
|
498
|
-
}
|
|
499
|
-
getQueries() {
|
|
500
|
-
return this.#observers.map((observer) => observer.getCurrentQuery());
|
|
501
|
-
}
|
|
502
|
-
getObservers() {
|
|
503
|
-
return this.#observers;
|
|
504
|
-
}
|
|
505
|
-
getOptimisticResult(queries, combine) {
|
|
506
|
-
const matches = this.#findMatchingObservers(queries);
|
|
507
|
-
const result = matches.map((match) => match.observer.getOptimisticResult(match.defaultedQueryOptions));
|
|
508
|
-
const queryHashes = matches.map((match) => match.defaultedQueryOptions.queryHash);
|
|
509
|
-
return [
|
|
510
|
-
result,
|
|
511
|
-
(r) => {
|
|
512
|
-
return this.#combineResult(r ?? result, combine, queryHashes);
|
|
513
|
-
},
|
|
514
|
-
() => {
|
|
515
|
-
return this.#trackResult(result, matches);
|
|
516
|
-
}
|
|
517
|
-
];
|
|
518
|
-
}
|
|
519
|
-
#trackResult(result, matches) {
|
|
520
|
-
return matches.map((match, index) => {
|
|
521
|
-
const observerResult = result[index];
|
|
522
|
-
return !match.defaultedQueryOptions.notifyOnChangeProps ? match.observer.trackResult(observerResult, (accessedProp) => {
|
|
523
|
-
matches.forEach((m) => {
|
|
524
|
-
m.observer.trackProp(accessedProp);
|
|
525
|
-
});
|
|
526
|
-
}) : observerResult;
|
|
527
|
-
});
|
|
528
|
-
}
|
|
529
|
-
#combineResult(input, combine, queryHashes) {
|
|
530
|
-
if (combine) {
|
|
531
|
-
const lastHashes = this.#lastQueryHashes;
|
|
532
|
-
const queryHashesChanged = queryHashes !== void 0 && lastHashes !== void 0 && (lastHashes.length !== queryHashes.length || queryHashes.some((hash, i) => hash !== lastHashes[i]));
|
|
533
|
-
if (!this.#combinedResult || this.#result !== this.#lastResult || queryHashesChanged || combine !== this.#lastCombine) {
|
|
534
|
-
this.#lastCombine = combine;
|
|
535
|
-
this.#lastResult = this.#result;
|
|
536
|
-
if (queryHashes !== void 0) this.#lastQueryHashes = queryHashes;
|
|
537
|
-
this.#combinedResult = replaceEqualDeep(this.#combinedResult, combine(input));
|
|
538
|
-
}
|
|
539
|
-
return this.#combinedResult;
|
|
540
|
-
}
|
|
541
|
-
return input;
|
|
542
|
-
}
|
|
543
|
-
#findMatchingObservers(queries) {
|
|
544
|
-
const prevObserversMap = /* @__PURE__ */ new Map();
|
|
545
|
-
this.#observers.forEach((observer) => {
|
|
546
|
-
const key = observer.options.queryHash;
|
|
547
|
-
if (!key) return;
|
|
548
|
-
const previousObservers = prevObserversMap.get(key);
|
|
549
|
-
if (previousObservers) previousObservers.push(observer);
|
|
550
|
-
else prevObserversMap.set(key, [observer]);
|
|
551
|
-
});
|
|
552
|
-
const observers = [];
|
|
553
|
-
queries.forEach((options) => {
|
|
554
|
-
const defaultedOptions = this.#client.defaultQueryOptions(options);
|
|
555
|
-
const observer = prevObserversMap.get(defaultedOptions.queryHash)?.shift() ?? new QueryObserver(this.#client, defaultedOptions);
|
|
556
|
-
observers.push({
|
|
557
|
-
defaultedQueryOptions: defaultedOptions,
|
|
558
|
-
observer
|
|
559
|
-
});
|
|
560
|
-
});
|
|
561
|
-
return observers;
|
|
562
|
-
}
|
|
563
|
-
#onUpdate(observer, result) {
|
|
564
|
-
const index = this.#observers.indexOf(observer);
|
|
565
|
-
if (index !== -1) {
|
|
566
|
-
this.#result = replaceAt(this.#result, index, result);
|
|
567
|
-
this.#notify();
|
|
568
|
-
}
|
|
569
|
-
}
|
|
570
|
-
#notify() {
|
|
571
|
-
if (this.hasListeners()) {
|
|
572
|
-
const previousResult = this.#combinedResult;
|
|
573
|
-
const newTracked = this.#trackResult(this.#result, this.#observerMatches);
|
|
574
|
-
if (previousResult !== this.#combineResult(newTracked, this.#options?.combine)) notifyManager.batch(() => {
|
|
575
|
-
this.listeners.forEach((listener) => {
|
|
576
|
-
listener(this.#result);
|
|
577
|
-
});
|
|
578
|
-
});
|
|
579
|
-
}
|
|
580
|
-
}
|
|
581
|
-
};
|
|
582
|
-
//#endregion
|
|
583
|
-
//#region ../../node_modules/.pnpm/@tanstack+react-query@5.90.21_react@19.2.6/node_modules/@tanstack/react-query/build/modern/QueryClientProvider.js
|
|
584
|
-
var QueryClientContext = React$1.createContext(void 0);
|
|
585
|
-
var useQueryClient = (queryClient) => {
|
|
586
|
-
const client = React$1.useContext(QueryClientContext);
|
|
587
|
-
if (queryClient) return queryClient;
|
|
588
|
-
if (!client) throw new Error("No QueryClient set, use QueryClientProvider to set one");
|
|
589
|
-
return client;
|
|
590
|
-
};
|
|
591
|
-
//#endregion
|
|
592
|
-
//#region ../../node_modules/.pnpm/@tanstack+react-query@5.90.21_react@19.2.6/node_modules/@tanstack/react-query/build/modern/IsRestoringProvider.js
|
|
593
|
-
var IsRestoringContext = React$1.createContext(false);
|
|
594
|
-
var useIsRestoring = () => React$1.useContext(IsRestoringContext);
|
|
595
|
-
IsRestoringContext.Provider;
|
|
596
|
-
//#endregion
|
|
597
|
-
//#region ../../node_modules/.pnpm/@tanstack+react-query@5.90.21_react@19.2.6/node_modules/@tanstack/react-query/build/modern/QueryErrorResetBoundary.js
|
|
598
|
-
function createValue() {
|
|
599
|
-
let isReset = false;
|
|
600
|
-
return {
|
|
601
|
-
clearReset: () => {
|
|
602
|
-
isReset = false;
|
|
603
|
-
},
|
|
604
|
-
reset: () => {
|
|
605
|
-
isReset = true;
|
|
606
|
-
},
|
|
607
|
-
isReset: () => {
|
|
608
|
-
return isReset;
|
|
609
|
-
}
|
|
610
|
-
};
|
|
611
|
-
}
|
|
612
|
-
var QueryErrorResetBoundaryContext = React$1.createContext(createValue());
|
|
613
|
-
var useQueryErrorResetBoundary = () => React$1.useContext(QueryErrorResetBoundaryContext);
|
|
614
|
-
//#endregion
|
|
615
|
-
//#region ../../node_modules/.pnpm/@tanstack+react-query@5.90.21_react@19.2.6/node_modules/@tanstack/react-query/build/modern/errorBoundaryUtils.js
|
|
616
|
-
var ensurePreventErrorBoundaryRetry = (options, errorResetBoundary, query) => {
|
|
617
|
-
const throwOnError = query?.state.error && typeof options.throwOnError === "function" ? shouldThrowError(options.throwOnError, [query.state.error, query]) : options.throwOnError;
|
|
618
|
-
if (options.suspense || options.experimental_prefetchInRender || throwOnError) {
|
|
619
|
-
if (!errorResetBoundary.isReset()) options.retryOnMount = false;
|
|
620
|
-
}
|
|
621
|
-
};
|
|
622
|
-
var useClearResetErrorBoundary = (errorResetBoundary) => {
|
|
623
|
-
React$1.useEffect(() => {
|
|
624
|
-
errorResetBoundary.clearReset();
|
|
625
|
-
}, [errorResetBoundary]);
|
|
626
|
-
};
|
|
627
|
-
var getHasError = ({ result, errorResetBoundary, throwOnError, query, suspense }) => {
|
|
628
|
-
return result.isError && !errorResetBoundary.isReset() && !result.isFetching && query && (suspense && result.data === void 0 || shouldThrowError(throwOnError, [result.error, query]));
|
|
629
|
-
};
|
|
630
|
-
//#endregion
|
|
631
|
-
//#region ../../node_modules/.pnpm/@tanstack+react-query@5.90.21_react@19.2.6/node_modules/@tanstack/react-query/build/modern/suspense.js
|
|
632
|
-
var ensureSuspenseTimers = (defaultedOptions) => {
|
|
633
|
-
if (defaultedOptions.suspense) {
|
|
634
|
-
const MIN_SUSPENSE_TIME_MS = 1e3;
|
|
635
|
-
const clamp = (value) => value === "static" ? value : Math.max(value ?? MIN_SUSPENSE_TIME_MS, MIN_SUSPENSE_TIME_MS);
|
|
636
|
-
const originalStaleTime = defaultedOptions.staleTime;
|
|
637
|
-
defaultedOptions.staleTime = typeof originalStaleTime === "function" ? (...args) => clamp(originalStaleTime(...args)) : clamp(originalStaleTime);
|
|
638
|
-
if (typeof defaultedOptions.gcTime === "number") defaultedOptions.gcTime = Math.max(defaultedOptions.gcTime, MIN_SUSPENSE_TIME_MS);
|
|
639
|
-
}
|
|
640
|
-
};
|
|
641
|
-
var willFetch = (result, isRestoring) => result.isLoading && result.isFetching && !isRestoring;
|
|
642
|
-
var shouldSuspend = (defaultedOptions, result) => defaultedOptions?.suspense && result.isPending;
|
|
643
|
-
var fetchOptimistic = (defaultedOptions, observer, errorResetBoundary) => observer.fetchOptimistic(defaultedOptions).catch(() => {
|
|
644
|
-
errorResetBoundary.clearReset();
|
|
645
|
-
});
|
|
646
|
-
//#endregion
|
|
647
|
-
//#region ../../node_modules/.pnpm/@tanstack+react-query@5.90.21_react@19.2.6/node_modules/@tanstack/react-query/build/modern/useQueries.js
|
|
648
|
-
function useQueries({ queries, ...options }, queryClient) {
|
|
649
|
-
const client = useQueryClient(queryClient);
|
|
650
|
-
const isRestoring = useIsRestoring();
|
|
651
|
-
const errorResetBoundary = useQueryErrorResetBoundary();
|
|
652
|
-
const defaultedQueries = React$1.useMemo(() => queries.map((opts) => {
|
|
653
|
-
const defaultedOptions = client.defaultQueryOptions(opts);
|
|
654
|
-
defaultedOptions._optimisticResults = isRestoring ? "isRestoring" : "optimistic";
|
|
655
|
-
return defaultedOptions;
|
|
656
|
-
}), [
|
|
657
|
-
queries,
|
|
658
|
-
client,
|
|
659
|
-
isRestoring
|
|
660
|
-
]);
|
|
661
|
-
defaultedQueries.forEach((queryOptions) => {
|
|
662
|
-
ensureSuspenseTimers(queryOptions);
|
|
663
|
-
const query = client.getQueryCache().get(queryOptions.queryHash);
|
|
664
|
-
ensurePreventErrorBoundaryRetry(queryOptions, errorResetBoundary, query);
|
|
665
|
-
});
|
|
666
|
-
useClearResetErrorBoundary(errorResetBoundary);
|
|
667
|
-
const [observer] = React$1.useState(() => new QueriesObserver(client, defaultedQueries, options));
|
|
668
|
-
const [optimisticResult, getCombinedResult, trackResult] = observer.getOptimisticResult(defaultedQueries, options.combine);
|
|
669
|
-
const shouldSubscribe = !isRestoring && options.subscribed !== false;
|
|
670
|
-
React$1.useSyncExternalStore(React$1.useCallback((onStoreChange) => shouldSubscribe ? observer.subscribe(notifyManager.batchCalls(onStoreChange)) : noop, [observer, shouldSubscribe]), () => observer.getCurrentResult(), () => observer.getCurrentResult());
|
|
671
|
-
React$1.useEffect(() => {
|
|
672
|
-
observer.setQueries(defaultedQueries, options);
|
|
673
|
-
}, [
|
|
674
|
-
defaultedQueries,
|
|
675
|
-
options,
|
|
676
|
-
observer
|
|
677
|
-
]);
|
|
678
|
-
const suspensePromises = optimisticResult.some((result, index) => shouldSuspend(defaultedQueries[index], result)) ? optimisticResult.flatMap((result, index) => {
|
|
679
|
-
const opts = defaultedQueries[index];
|
|
680
|
-
if (opts && shouldSuspend(opts, result)) return fetchOptimistic(opts, new QueryObserver(client, opts), errorResetBoundary);
|
|
681
|
-
return [];
|
|
682
|
-
}) : [];
|
|
683
|
-
if (suspensePromises.length > 0) throw Promise.all(suspensePromises);
|
|
684
|
-
const firstSingleResultWhichShouldThrow = optimisticResult.find((result, index) => {
|
|
685
|
-
const query = defaultedQueries[index];
|
|
686
|
-
return query && getHasError({
|
|
687
|
-
result,
|
|
688
|
-
errorResetBoundary,
|
|
689
|
-
throwOnError: query.throwOnError,
|
|
690
|
-
query: client.getQueryCache().get(query.queryHash),
|
|
691
|
-
suspense: query.suspense
|
|
692
|
-
});
|
|
693
|
-
});
|
|
694
|
-
if (firstSingleResultWhichShouldThrow?.error) throw firstSingleResultWhichShouldThrow.error;
|
|
695
|
-
return getCombinedResult(trackResult());
|
|
696
|
-
}
|
|
697
|
-
//#endregion
|
|
698
|
-
//#region ../../node_modules/.pnpm/@tanstack+react-query@5.90.21_react@19.2.6/node_modules/@tanstack/react-query/build/modern/useBaseQuery.js
|
|
699
|
-
function useBaseQuery(options, Observer, queryClient) {
|
|
700
|
-
if (process.env.NODE_ENV !== "production") {
|
|
701
|
-
if (typeof options !== "object" || Array.isArray(options)) throw new Error("Bad argument type. Starting with v5, only the \"Object\" form is allowed when calling query related functions. Please use the error stack to find the culprit call. More info here: https://tanstack.com/query/latest/docs/react/guides/migrating-to-v5#supports-a-single-signature-one-object");
|
|
702
|
-
}
|
|
703
|
-
const isRestoring = useIsRestoring();
|
|
704
|
-
const errorResetBoundary = useQueryErrorResetBoundary();
|
|
705
|
-
const client = useQueryClient(queryClient);
|
|
706
|
-
const defaultedOptions = client.defaultQueryOptions(options);
|
|
707
|
-
client.getDefaultOptions().queries?._experimental_beforeQuery?.(defaultedOptions);
|
|
708
|
-
const query = client.getQueryCache().get(defaultedOptions.queryHash);
|
|
709
|
-
if (process.env.NODE_ENV !== "production") {
|
|
710
|
-
if (!defaultedOptions.queryFn) console.error(`[${defaultedOptions.queryHash}]: No queryFn was passed as an option, and no default queryFn was found. The queryFn parameter is only optional when using a default queryFn. More info here: https://tanstack.com/query/latest/docs/framework/react/guides/default-query-function`);
|
|
711
|
-
}
|
|
712
|
-
defaultedOptions._optimisticResults = isRestoring ? "isRestoring" : "optimistic";
|
|
713
|
-
ensureSuspenseTimers(defaultedOptions);
|
|
714
|
-
ensurePreventErrorBoundaryRetry(defaultedOptions, errorResetBoundary, query);
|
|
715
|
-
useClearResetErrorBoundary(errorResetBoundary);
|
|
716
|
-
const isNewCacheEntry = !client.getQueryCache().get(defaultedOptions.queryHash);
|
|
717
|
-
const [observer] = React$1.useState(() => new Observer(client, defaultedOptions));
|
|
718
|
-
const result = observer.getOptimisticResult(defaultedOptions);
|
|
719
|
-
const shouldSubscribe = !isRestoring && options.subscribed !== false;
|
|
720
|
-
React$1.useSyncExternalStore(React$1.useCallback((onStoreChange) => {
|
|
721
|
-
const unsubscribe = shouldSubscribe ? observer.subscribe(notifyManager.batchCalls(onStoreChange)) : noop;
|
|
722
|
-
observer.updateResult();
|
|
723
|
-
return unsubscribe;
|
|
724
|
-
}, [observer, shouldSubscribe]), () => observer.getCurrentResult(), () => observer.getCurrentResult());
|
|
725
|
-
React$1.useEffect(() => {
|
|
726
|
-
observer.setOptions(defaultedOptions);
|
|
727
|
-
}, [defaultedOptions, observer]);
|
|
728
|
-
if (shouldSuspend(defaultedOptions, result)) throw fetchOptimistic(defaultedOptions, observer, errorResetBoundary);
|
|
729
|
-
if (getHasError({
|
|
730
|
-
result,
|
|
731
|
-
errorResetBoundary,
|
|
732
|
-
throwOnError: defaultedOptions.throwOnError,
|
|
733
|
-
query,
|
|
734
|
-
suspense: defaultedOptions.suspense
|
|
735
|
-
})) throw result.error;
|
|
736
|
-
client.getDefaultOptions().queries?._experimental_afterQuery?.(defaultedOptions, result);
|
|
737
|
-
if (defaultedOptions.experimental_prefetchInRender && !isServer && willFetch(result, isRestoring)) (isNewCacheEntry ? fetchOptimistic(defaultedOptions, observer, errorResetBoundary) : query?.promise)?.catch(noop).finally(() => {
|
|
738
|
-
observer.updateResult();
|
|
739
|
-
});
|
|
740
|
-
return !defaultedOptions.notifyOnChangeProps ? observer.trackResult(result) : result;
|
|
741
|
-
}
|
|
742
|
-
//#endregion
|
|
743
|
-
//#region ../../node_modules/.pnpm/@tanstack+react-query@5.90.21_react@19.2.6/node_modules/@tanstack/react-query/build/modern/useQuery.js
|
|
744
|
-
function useQuery(options, queryClient) {
|
|
745
|
-
return useBaseQuery(options, QueryObserver, queryClient);
|
|
746
|
-
}
|
|
747
|
-
//#endregion
|
|
748
|
-
//#region ../../node_modules/.pnpm/@tanstack+react-query@5.90.21_react@19.2.6/node_modules/@tanstack/react-query/build/modern/useInfiniteQuery.js
|
|
749
|
-
function useInfiniteQuery(options, queryClient) {
|
|
750
|
-
return useBaseQuery(options, InfiniteQueryObserver, queryClient);
|
|
751
|
-
}
|
|
752
|
-
//#endregion
|
|
753
|
-
//#region ../reactor/dist/forwarding-logger-BkwlvD9W.js
|
|
754
|
-
const DRIVE_COLLECTION_PREFIX = "drive.";
|
|
755
|
-
/**
|
|
756
|
-
* Identifies the collection a remote synchronizes. Collections are drive-level
|
|
757
|
-
* abstractions (document-drive and reactor-drive), so a collection id is the
|
|
758
|
-
* drive document id plus the branch it scopes to rather than an opaque string.
|
|
759
|
-
*
|
|
760
|
-
* The canonical string form (`drive.${branch}.${driveId}`) is produced only by
|
|
761
|
-
* `key` and parsed only by `fromKey`; that string is the wire and storage
|
|
762
|
-
* representation and is byte-for-byte identical to the legacy
|
|
763
|
-
* `driveCollectionId(branch, driveId)` output, so existing `document_collections`
|
|
764
|
-
* rows and persisted remotes remain valid without migration.
|
|
765
|
-
*/
|
|
766
|
-
var DriveCollectionId = class DriveCollectionId {
|
|
767
|
-
driveId;
|
|
768
|
-
branch;
|
|
769
|
-
constructor(driveId, branch) {
|
|
770
|
-
this.driveId = driveId;
|
|
771
|
-
this.branch = branch;
|
|
772
|
-
}
|
|
773
|
-
static forDrive(driveId, branch = "main") {
|
|
774
|
-
return new DriveCollectionId(driveId, branch);
|
|
775
|
-
}
|
|
776
|
-
/**
|
|
777
|
-
* The single deserializer for the wire/storage form. `branch` may contain
|
|
778
|
-
* dots, while `driveId` is a dot-free document id, so the drive id is the
|
|
779
|
-
* final dot-delimited segment.
|
|
780
|
-
*/
|
|
781
|
-
static fromKey(key) {
|
|
782
|
-
if (!key.startsWith(DRIVE_COLLECTION_PREFIX)) throw new Error(`Unsupported collection id: ${key}`);
|
|
783
|
-
const rest = key.slice(6);
|
|
784
|
-
const lastDot = rest.lastIndexOf(".");
|
|
785
|
-
if (lastDot === -1 || lastDot === rest.length - 1) throw new Error(`Malformed drive collection id: ${key}`);
|
|
786
|
-
return new DriveCollectionId(rest.slice(lastDot + 1), rest.slice(0, lastDot));
|
|
787
|
-
}
|
|
788
|
-
get key() {
|
|
789
|
-
return `${DRIVE_COLLECTION_PREFIX}${this.branch}.${this.driveId}`;
|
|
790
|
-
}
|
|
791
|
-
toString() {
|
|
792
|
-
return this.key;
|
|
793
|
-
}
|
|
794
|
-
equals(other) {
|
|
795
|
-
return this.driveId === other.driveId && this.branch === other.branch;
|
|
796
|
-
}
|
|
797
|
-
};
|
|
798
|
-
new Set([...DOCUMENT_SCOPE_ACTION_TYPES].filter((type) => type !== "CREATE_DOCUMENT"));
|
|
799
|
-
//#endregion
|
|
800
|
-
//#region editors/shared/DocumentErrorBoundary.tsx
|
|
801
|
-
/** Best-effort message for anything thrown, without stringifying an object. */
|
|
802
|
-
function errorMessage(error) {
|
|
803
|
-
if (error instanceof Error) return error.message;
|
|
804
|
-
if (typeof error === "string") return error;
|
|
805
|
-
return "Unknown error";
|
|
806
|
-
}
|
|
807
|
-
/** Inline "could not load" panel, also used for hook-level (non-thrown) failures. */
|
|
808
|
-
function DocumentLoadError(props) {
|
|
809
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
810
|
-
className: "m-3 rounded border border-solid border-wf-fail/40 bg-wf-fail/10 p-3",
|
|
811
|
-
children: [
|
|
812
|
-
/* @__PURE__ */ jsx("p", {
|
|
813
|
-
className: "text-sm font-medium text-wf-fail",
|
|
814
|
-
children: props.title ?? "This document could not be loaded"
|
|
815
|
-
}),
|
|
816
|
-
props.label ? /* @__PURE__ */ jsx("p", {
|
|
817
|
-
className: "mt-0.5 text-xs text-wf-fail",
|
|
818
|
-
children: props.label
|
|
819
|
-
}) : null,
|
|
820
|
-
props.documentId ? /* @__PURE__ */ jsx("p", {
|
|
821
|
-
className: "mt-0.5 font-mono text-[11px] text-wf-fail",
|
|
822
|
-
children: props.documentId
|
|
823
|
-
}) : null,
|
|
824
|
-
/* @__PURE__ */ jsx("p", {
|
|
825
|
-
className: "mt-1 text-xs text-muted-foreground",
|
|
826
|
-
children: errorMessage(props.error)
|
|
827
|
-
}),
|
|
828
|
-
/* @__PURE__ */ jsxs("div", {
|
|
829
|
-
className: "mt-2 flex gap-2",
|
|
830
|
-
children: [props.onRetry ? /* @__PURE__ */ jsx("button", {
|
|
831
|
-
type: "button",
|
|
832
|
-
className: "rounded border border-solid border-wf-fail/40 px-2 py-0.5 text-xs font-medium text-wf-fail",
|
|
833
|
-
onClick: props.onRetry,
|
|
834
|
-
children: "Retry"
|
|
835
|
-
}) : null, props.onDismiss ? /* @__PURE__ */ jsx("button", {
|
|
836
|
-
type: "button",
|
|
837
|
-
className: "rounded border border-solid border-foreground/15 px-2 py-0.5 text-xs text-muted-foreground",
|
|
838
|
-
onClick: props.onDismiss,
|
|
839
|
-
children: "Dismiss"
|
|
840
|
-
}) : null]
|
|
841
|
-
})
|
|
842
|
-
]
|
|
843
|
-
});
|
|
844
|
-
}
|
|
845
|
-
var DocumentErrorBoundary = class extends Component {
|
|
846
|
-
state = {
|
|
847
|
-
error: void 0,
|
|
848
|
-
attempt: 0
|
|
849
|
-
};
|
|
850
|
-
static getDerivedStateFromError(error) {
|
|
851
|
-
return { error };
|
|
852
|
-
}
|
|
853
|
-
componentDidCatch(error, info) {
|
|
854
|
-
console.error(`Failed to render document ${this.props.documentId ?? "(unknown id)"}:`, error, info.componentStack);
|
|
855
|
-
}
|
|
856
|
-
retry = () => {
|
|
857
|
-
this.setState((state) => ({
|
|
858
|
-
error: void 0,
|
|
859
|
-
attempt: state.attempt + 1
|
|
860
|
-
}));
|
|
861
|
-
};
|
|
862
|
-
dismiss = () => {
|
|
863
|
-
this.setState({ error: void 0 });
|
|
864
|
-
this.props.onDismiss?.();
|
|
865
|
-
};
|
|
866
|
-
render() {
|
|
867
|
-
if (this.state.error !== void 0) return /* @__PURE__ */ jsx(DocumentLoadError, {
|
|
868
|
-
label: this.props.label,
|
|
869
|
-
documentId: this.props.documentId,
|
|
870
|
-
error: this.state.error,
|
|
871
|
-
onRetry: this.retry,
|
|
872
|
-
onDismiss: this.props.onDismiss ? this.dismiss : void 0
|
|
873
|
-
});
|
|
874
|
-
return /* @__PURE__ */ jsx(Fragment, { children: this.props.children }, this.state.attempt);
|
|
875
|
-
}
|
|
876
|
-
};
|
|
877
|
-
//#endregion
|
|
878
|
-
//#region editors/shared/icons.tsx
|
|
879
|
-
const ICON_PATHS = {
|
|
880
|
-
pencil: "M4 20h4L19 9l-4-4L4 16v4zM14 6l4 4",
|
|
881
|
-
trash: "M5 7h14M10 11v6M14 11v6M6 7l1 13h10l1-13M9 7V4h6v3",
|
|
882
|
-
plus: "M12 5v14M5 12h14",
|
|
883
|
-
minus: "M5 12h14",
|
|
884
|
-
list: "M8 6h12M8 12h12M8 18h12M4 6h.01M4 12h.01M4 18h.01",
|
|
885
|
-
play: "M7 5v14l12-7z",
|
|
886
|
-
chevron: "M9 6l6 6-6 6",
|
|
887
|
-
chevronDown: "M6 9l6 6 6-6",
|
|
888
|
-
retry: "M4 12a8 8 0 1 0 2.3-5.7M4 4v4h4",
|
|
889
|
-
back: "M15 6l-6 6 6 6",
|
|
890
|
-
close: "M6 6l12 12M18 6L6 18",
|
|
891
|
-
check: "M5 12l5 5 9-10",
|
|
892
|
-
search: "M11 18a7 7 0 1 0 0-14 7 7 0 0 0 0 14zM20 20l-4-4",
|
|
893
|
-
braces: "M8 4c-2 0-3 1-3 3v2c0 1.5-1 3-2 3 1 0 2 1.5 2 3v2c0 2 1 3 3 3M16 4c2 0 3 1 3 3v2c0 1.5 1 3 2 3-1 0-2 1.5-2 3v2c0 2-1 3-3 3",
|
|
894
|
-
link: "M10 14a4 4 0 0 0 5.7 0l3-3a4 4 0 0 0-5.7-5.7l-1 1M14 10a4 4 0 0 0-5.7 0l-3 3a4 4 0 0 0 5.7 5.7l1-1",
|
|
895
|
-
arrowRight: "M5 12h14M13 6l6 6-6 6",
|
|
896
|
-
alert: "M12 8v5M12 16.5v.01M10.3 4l-7.6 13.2A2 2 0 0 0 4.4 20h15.2a2 2 0 0 0 1.7-2.8L13.7 4a2 2 0 0 0-3.4 0z",
|
|
897
|
-
copy: "M9 9h10v10H9zM5 15V5h10",
|
|
898
|
-
sliders: "M4 7h10M18 7h2M4 17h4M12 17h8M14 5v4M8 15v4",
|
|
899
|
-
eye: "M2.5 12s3.5-6.5 9.5-6.5 9.5 6.5 9.5 6.5-3.5 6.5-9.5 6.5S2.5 12 2.5 12zM12 14.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5z",
|
|
900
|
-
eyeOff: "M3 3l18 18M10.6 5.6A10 10 0 0 1 12 5.5c6 0 9.5 6.5 9.5 6.5a17 17 0 0 1-3 3.7M6.6 6.6C4 8.3 2.5 12 2.5 12s3.5 6.5 9.5 6.5a9.6 9.6 0 0 0 4.4-1M9.9 9.9a3 3 0 0 0 4.2 4.2",
|
|
901
|
-
undo: "M9 14L4 9l5-5M4 9h10a6 6 0 0 1 0 12h-3",
|
|
902
|
-
redo: "M15 14l5-5-5-5M20 9H10a6 6 0 0 0 0 12h3",
|
|
903
|
-
clock: "M12 21a9 9 0 1 0 0-18 9 9 0 0 0 0 18zM12 7v5l3 2",
|
|
904
|
-
bolt: "M13 3L5 13h6l-1 8 8-10h-6l1-8z",
|
|
905
|
-
branch: "M6 4v10M6 14a3 3 0 1 0 0 6 3 3 0 0 0 0-6zM18 4a3 3 0 1 0 0 6 3 3 0 0 0 0-6zM18 10c0 4-6 3-11 6",
|
|
906
|
-
lock: "M6 11h12v9H6zM8.5 11V8a3.5 3.5 0 0 1 7 0v3M12 15v2",
|
|
907
|
-
more: "M5 11a1 1 0 1 0 0 2 1 1 0 0 0 0-2zM12 11a1 1 0 1 0 0 2 1 1 0 0 0 0-2zM19 11a1 1 0 1 0 0 2 1 1 0 0 0 0-2z",
|
|
908
|
-
archive: "M4 5h16v4H4zM6 9v10h12V9M10 13h4"
|
|
909
|
-
};
|
|
910
|
-
function isIconName(name) {
|
|
911
|
-
return typeof name === "string" && name in ICON_PATHS;
|
|
912
|
-
}
|
|
913
|
-
function Icon(props) {
|
|
914
|
-
return /* @__PURE__ */ jsx("svg", {
|
|
915
|
-
"aria-hidden": true,
|
|
916
|
-
viewBox: "0 0 24 24",
|
|
917
|
-
fill: "none",
|
|
918
|
-
stroke: "currentColor",
|
|
919
|
-
strokeWidth: 1.75,
|
|
920
|
-
strokeLinecap: "round",
|
|
921
|
-
strokeLinejoin: "round",
|
|
922
|
-
width: props.size,
|
|
923
|
-
height: props.size,
|
|
924
|
-
className: `shrink-0 ${props.size ? "" : "h-4 w-4"} ${props.className ?? ""}`,
|
|
925
|
-
children: /* @__PURE__ */ jsx("path", { d: ICON_PATHS[props.name] })
|
|
926
|
-
});
|
|
927
|
-
}
|
|
928
|
-
//#endregion
|
|
929
|
-
//#region editors/shared/controls.tsx
|
|
930
|
-
const FOCUS_RING = "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/40";
|
|
931
|
-
const BUTTON_SIZE = {
|
|
932
|
-
sm: "h-7 gap-1 rounded-md px-2 text-xs",
|
|
933
|
-
md: "h-8 gap-1.5 rounded-md px-3 text-[13px]"
|
|
934
|
-
};
|
|
935
|
-
const BUTTON_VARIANT = {
|
|
936
|
-
primary: "bg-primary text-primary-foreground hover:opacity-90",
|
|
937
|
-
secondary: "border border-solid border-foreground/15 bg-card text-foreground hover:bg-accent",
|
|
938
|
-
ghost: "text-muted-foreground hover:bg-accent hover:text-foreground",
|
|
939
|
-
danger: "text-wf-fail hover:bg-wf-fail/10",
|
|
940
|
-
destructive: "bg-wf-fail text-white hover:opacity-90"
|
|
941
|
-
};
|
|
942
|
-
function Button(props) {
|
|
943
|
-
const { variant = "secondary", size = "md", className = "", ...rest } = props;
|
|
944
|
-
return /* @__PURE__ */ jsx("button", {
|
|
945
|
-
type: "button",
|
|
946
|
-
className: `inline-flex shrink-0 items-center font-medium transition-colors disabled:pointer-events-none disabled:opacity-50 ${FOCUS_RING} ${BUTTON_SIZE[size]} ${BUTTON_VARIANT[variant]} ${className}`,
|
|
947
|
-
...rest
|
|
948
|
-
});
|
|
949
|
-
}
|
|
950
|
-
function IconButton(props) {
|
|
951
|
-
const { icon, label, active, className = "", ...rest } = props;
|
|
952
|
-
return /* @__PURE__ */ jsx("button", {
|
|
953
|
-
type: "button",
|
|
954
|
-
title: label,
|
|
955
|
-
"aria-label": label,
|
|
956
|
-
className: `inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md transition-colors disabled:pointer-events-none disabled:opacity-50 ${FOCUS_RING} ${active ? "bg-wf-run/10 text-wf-run" : "text-muted-foreground hover:bg-accent hover:text-foreground"} ${className}`,
|
|
957
|
-
...rest,
|
|
958
|
-
children: /* @__PURE__ */ jsx(Icon, {
|
|
959
|
-
name: icon,
|
|
960
|
-
className: "h-3.5 w-3.5"
|
|
961
|
-
})
|
|
962
|
-
});
|
|
963
|
-
}
|
|
964
|
-
const inputClass = "w-full rounded-md border border-solid border-foreground/15 bg-card px-2.5 text-[13px] text-foreground placeholder:text-muted-foreground/70 transition-colors hover:border-foreground/25 focus:border-ring focus:outline-none focus:ring-2 focus:ring-ring/25 disabled:cursor-not-allowed disabled:opacity-60";
|
|
965
|
-
const textInputClass = `${inputClass} h-9`;
|
|
966
|
-
const textAreaClass = `${inputClass} min-h-20 py-2 leading-relaxed`;
|
|
967
|
-
const invalidClass = "border-wf-warn/70 hover:border-wf-warn";
|
|
968
|
-
/** Label row above a control: name, optional marker, and a trailing action. */
|
|
969
|
-
function FieldLabel(props) {
|
|
970
|
-
const LabelTag = props.htmlFor ? "label" : "span";
|
|
971
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
972
|
-
className: "mb-1.5 flex min-h-6 items-center justify-between gap-2",
|
|
973
|
-
children: [/* @__PURE__ */ jsxs(LabelTag, {
|
|
974
|
-
htmlFor: props.htmlFor,
|
|
975
|
-
className: "flex min-w-0 items-baseline gap-1.5 text-[13px] font-medium text-foreground",
|
|
976
|
-
children: [
|
|
977
|
-
/* @__PURE__ */ jsx("span", {
|
|
978
|
-
className: "truncate",
|
|
979
|
-
children: props.label
|
|
980
|
-
}),
|
|
981
|
-
props.optional ? /* @__PURE__ */ jsx("span", {
|
|
982
|
-
className: "shrink-0 text-xs font-normal text-muted-foreground",
|
|
983
|
-
children: "Optional"
|
|
984
|
-
}) : null,
|
|
985
|
-
props.needsValue ? /* @__PURE__ */ jsx("span", {
|
|
986
|
-
className: "shrink-0 text-xs font-normal text-wf-warn",
|
|
987
|
-
children: "Needs a value"
|
|
988
|
-
}) : null
|
|
989
|
-
]
|
|
990
|
-
}), props.action ? /* @__PURE__ */ jsx("span", {
|
|
991
|
-
className: "flex shrink-0 items-center gap-0.5",
|
|
992
|
-
children: props.action
|
|
993
|
-
}) : null]
|
|
994
|
-
});
|
|
995
|
-
}
|
|
996
|
-
const LONG_HINT = 140;
|
|
997
|
-
/** Help text under a control; long piece descriptions fold to two lines. */
|
|
998
|
-
function Hint(props) {
|
|
999
|
-
const [open, setOpen] = useState(false);
|
|
1000
|
-
const text = props.text;
|
|
1001
|
-
if (text !== void 0) {
|
|
1002
|
-
if (!text.trim()) return null;
|
|
1003
|
-
const long = text.length > LONG_HINT;
|
|
1004
|
-
return /* @__PURE__ */ jsxs("p", {
|
|
1005
|
-
className: "mt-1.5 text-xs leading-relaxed text-muted-foreground",
|
|
1006
|
-
children: [/* @__PURE__ */ jsx("span", {
|
|
1007
|
-
className: long && !open ? "line-clamp-2" : void 0,
|
|
1008
|
-
children: text
|
|
1009
|
-
}), long ? /* @__PURE__ */ jsx("button", {
|
|
1010
|
-
type: "button",
|
|
1011
|
-
className: "mt-0.5 block font-medium text-foreground/70 hover:text-foreground",
|
|
1012
|
-
onClick: () => setOpen((value) => !value),
|
|
1013
|
-
children: open ? "Show less" : "Show more"
|
|
1014
|
-
}) : null]
|
|
1015
|
-
});
|
|
1016
|
-
}
|
|
1017
|
-
return /* @__PURE__ */ jsx("p", {
|
|
1018
|
-
className: "mt-1.5 text-xs leading-relaxed text-muted-foreground",
|
|
1019
|
-
children: props.children
|
|
1020
|
-
});
|
|
1021
|
-
}
|
|
1022
|
-
function FieldError(props) {
|
|
1023
|
-
if (!props.children) return null;
|
|
1024
|
-
return /* @__PURE__ */ jsx("p", {
|
|
1025
|
-
className: "mt-1.5 text-xs text-wf-fail",
|
|
1026
|
-
children: props.children
|
|
1027
|
-
});
|
|
1028
|
-
}
|
|
1029
|
-
function Switch(props) {
|
|
1030
|
-
const id = useId();
|
|
1031
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
1032
|
-
className: "flex items-start justify-between gap-4",
|
|
1033
|
-
children: [/* @__PURE__ */ jsxs("label", {
|
|
1034
|
-
htmlFor: id,
|
|
1035
|
-
className: "min-w-0",
|
|
1036
|
-
children: [/* @__PURE__ */ jsx("span", {
|
|
1037
|
-
className: "block text-[13px] font-medium text-foreground",
|
|
1038
|
-
children: props.label
|
|
1039
|
-
}), props.description ? /* @__PURE__ */ jsx(Hint, { text: props.description }) : null]
|
|
1040
|
-
}), /* @__PURE__ */ jsx("button", {
|
|
1041
|
-
id,
|
|
1042
|
-
type: "button",
|
|
1043
|
-
role: "switch",
|
|
1044
|
-
"aria-checked": props.checked,
|
|
1045
|
-
disabled: props.disabled,
|
|
1046
|
-
className: `relative mt-0.5 inline-flex h-5 w-9 shrink-0 items-center rounded-full transition-colors disabled:opacity-50 ${FOCUS_RING} ${props.checked ? "bg-primary" : "bg-foreground/20"}`,
|
|
1047
|
-
onClick: () => props.onChange(!props.checked),
|
|
1048
|
-
children: /* @__PURE__ */ jsx("span", { className: `inline-block h-4 w-4 rounded-full bg-card shadow-sm transition-transform ${props.checked ? "translate-x-[18px]" : "translate-x-0.5"}` })
|
|
1049
|
-
})]
|
|
1050
|
-
});
|
|
1051
|
-
}
|
|
1052
|
-
function Toggle(props) {
|
|
1053
|
-
return /* @__PURE__ */ jsx("button", {
|
|
1054
|
-
type: "button",
|
|
1055
|
-
role: "switch",
|
|
1056
|
-
"aria-checked": props.checked,
|
|
1057
|
-
"aria-label": props.label,
|
|
1058
|
-
disabled: props.disabled,
|
|
1059
|
-
className: `relative inline-flex h-5 w-9 shrink-0 items-center rounded-full transition-colors disabled:cursor-not-allowed disabled:opacity-50 ${FOCUS_RING} ${props.checked ? "bg-wf-ok" : "bg-foreground/20"}`,
|
|
1060
|
-
onClick: (event) => {
|
|
1061
|
-
event.stopPropagation();
|
|
1062
|
-
props.onChange(!props.checked);
|
|
1063
|
-
},
|
|
1064
|
-
children: /* @__PURE__ */ jsx("span", { className: `inline-block h-4 w-4 rounded-full bg-card shadow-sm transition-transform ${props.checked ? "translate-x-[18px]" : "translate-x-0.5"}` })
|
|
1065
|
-
});
|
|
1066
|
-
}
|
|
1067
|
-
function Tooltip(props) {
|
|
1068
|
-
if (props.enabled === false) return /* @__PURE__ */ jsx(Fragment$1, { children: props.children });
|
|
1069
|
-
const place = props.side === "left" ? "right-full top-1/2 -translate-y-1/2 pr-1.5" : `top-full pt-1.5 ${props.align === "start" ? "left-0" : "right-0"}`;
|
|
1070
|
-
return /* @__PURE__ */ jsxs("span", {
|
|
1071
|
-
className: "group/tip relative inline-flex",
|
|
1072
|
-
children: [props.children, /* @__PURE__ */ jsx("span", {
|
|
1073
|
-
className: `invisible absolute z-50 opacity-0 transition-opacity group-focus-within/tip:visible group-focus-within/tip:opacity-100 group-hover/tip:visible group-hover/tip:opacity-100 ${place}`,
|
|
1074
|
-
children: /* @__PURE__ */ jsx("span", {
|
|
1075
|
-
role: "tooltip",
|
|
1076
|
-
className: "block w-max max-w-64 rounded-md border border-solid border-foreground/10 bg-card px-2.5 py-1.5 text-xs text-foreground shadow-lg",
|
|
1077
|
-
children: props.content
|
|
1078
|
-
})
|
|
1079
|
-
})]
|
|
1080
|
-
});
|
|
1081
|
-
}
|
|
1082
|
-
function Tabs(props) {
|
|
1083
|
-
return /* @__PURE__ */ jsx("div", {
|
|
1084
|
-
role: "tablist",
|
|
1085
|
-
className: "flex gap-4",
|
|
1086
|
-
children: props.tabs.map((tab) => {
|
|
1087
|
-
const selected = tab.value === props.value;
|
|
1088
|
-
return /* @__PURE__ */ jsxs("button", {
|
|
1089
|
-
type: "button",
|
|
1090
|
-
role: "tab",
|
|
1091
|
-
"aria-selected": selected,
|
|
1092
|
-
className: `-mb-px flex items-center gap-1.5 border-b-2 border-solid pb-2 text-[13px] font-medium transition-colors ${FOCUS_RING} ${selected ? "border-foreground text-foreground" : "border-transparent text-muted-foreground hover:text-foreground"}`,
|
|
1093
|
-
onClick: () => props.onChange(tab.value),
|
|
1094
|
-
children: [tab.label, tab.badge]
|
|
1095
|
-
}, tab.value);
|
|
1096
|
-
})
|
|
1097
|
-
});
|
|
1098
|
-
}
|
|
1099
|
-
/** Two or three short, mutually exclusive choices shown side by side. */
|
|
1100
|
-
function Segmented(props) {
|
|
1101
|
-
return /* @__PURE__ */ jsx("div", {
|
|
1102
|
-
role: "radiogroup",
|
|
1103
|
-
className: `flex h-9 w-full items-center gap-0.5 rounded-md bg-muted p-0.5 ${props.invalid ? "ring-1 ring-wf-warn/60" : ""}`,
|
|
1104
|
-
children: props.options.map((option) => {
|
|
1105
|
-
const selected = option.value === props.value;
|
|
1106
|
-
return /* @__PURE__ */ jsx("button", {
|
|
1107
|
-
type: "button",
|
|
1108
|
-
role: "radio",
|
|
1109
|
-
"aria-checked": selected,
|
|
1110
|
-
className: `h-8 min-w-0 flex-1 truncate rounded px-2 text-[13px] transition-colors ${FOCUS_RING} ${selected ? "bg-card font-medium text-foreground shadow-sm" : "text-muted-foreground hover:text-foreground"}`,
|
|
1111
|
-
onClick: () => props.onChange(option.value),
|
|
1112
|
-
children: option.label
|
|
1113
|
-
}, option.value);
|
|
1114
|
-
})
|
|
1115
|
-
});
|
|
1116
|
-
}
|
|
1117
|
-
const SEARCH_THRESHOLD = 7;
|
|
1118
|
-
function Select(props) {
|
|
1119
|
-
const [open, setOpen] = useState(false);
|
|
1120
|
-
const [query, setQuery] = useState("");
|
|
1121
|
-
const [active, setActive] = useState(0);
|
|
1122
|
-
const triggerRef = useRef(null);
|
|
1123
|
-
const popoverRef = useRef(null);
|
|
1124
|
-
const searchRef = useRef(null);
|
|
1125
|
-
const listId = useId();
|
|
1126
|
-
const [position, setPosition] = useState(null);
|
|
1127
|
-
const selected = props.multiple ? props.value : props.value ? [props.value] : [];
|
|
1128
|
-
const selectedSet = new Set(selected);
|
|
1129
|
-
const searchable = props.searchable || Boolean(props.onQueryChange) || props.options.length > SEARCH_THRESHOLD;
|
|
1130
|
-
const needle = query.trim().toLowerCase();
|
|
1131
|
-
const serverSide = Boolean(props.onQueryChange);
|
|
1132
|
-
const visible = useMemo(() => needle && !serverSide ? props.options.filter((option) => `${option.label} ${option.description ?? ""}`.toLowerCase().includes(needle)) : props.options, [
|
|
1133
|
-
needle,
|
|
1134
|
-
props.options,
|
|
1135
|
-
serverSide
|
|
1136
|
-
]);
|
|
1137
|
-
const onQueryChange = props.onQueryChange;
|
|
1138
|
-
const dismiss = () => {
|
|
1139
|
-
setOpen(false);
|
|
1140
|
-
setQuery("");
|
|
1141
|
-
onQueryChange?.("");
|
|
1142
|
-
};
|
|
1143
|
-
const close = () => {
|
|
1144
|
-
dismiss();
|
|
1145
|
-
triggerRef.current?.focus();
|
|
1146
|
-
};
|
|
1147
|
-
const place = () => {
|
|
1148
|
-
const rect = triggerRef.current?.getBoundingClientRect();
|
|
1149
|
-
if (!rect) return;
|
|
1150
|
-
const below = window.innerHeight - rect.bottom - 8;
|
|
1151
|
-
const above = rect.top - 8;
|
|
1152
|
-
const flip = below < 240 && above > below;
|
|
1153
|
-
setPosition({
|
|
1154
|
-
left: rect.left,
|
|
1155
|
-
width: rect.width,
|
|
1156
|
-
top: flip ? void 0 : rect.bottom + 4,
|
|
1157
|
-
bottom: flip ? window.innerHeight - rect.top + 4 : void 0,
|
|
1158
|
-
maxHeight: Math.min(320, flip ? above : below)
|
|
1159
|
-
});
|
|
1160
|
-
};
|
|
1161
|
-
const openList = () => {
|
|
1162
|
-
const index = props.options.findIndex((option) => selectedSet.has(option.value));
|
|
1163
|
-
setActive(Math.max(0, index));
|
|
1164
|
-
setOpen(true);
|
|
1165
|
-
};
|
|
1166
|
-
useLayoutEffect(() => {
|
|
1167
|
-
if (!open) return;
|
|
1168
|
-
place();
|
|
1169
|
-
}, [open]);
|
|
1170
|
-
const placed = position !== null;
|
|
1171
|
-
useEffect(() => {
|
|
1172
|
-
if (open && placed && searchable) searchRef.current?.focus();
|
|
1173
|
-
}, [
|
|
1174
|
-
open,
|
|
1175
|
-
placed,
|
|
1176
|
-
searchable
|
|
1177
|
-
]);
|
|
1178
|
-
useEffect(() => {
|
|
1179
|
-
if (!open) return;
|
|
1180
|
-
const onPointer = (event) => {
|
|
1181
|
-
const target = event.target;
|
|
1182
|
-
if (!popoverRef.current?.contains(target) && !triggerRef.current?.contains(target)) {
|
|
1183
|
-
setOpen(false);
|
|
1184
|
-
setQuery("");
|
|
1185
|
-
onQueryChange?.("");
|
|
1186
|
-
}
|
|
1187
|
-
};
|
|
1188
|
-
window.addEventListener("mousedown", onPointer);
|
|
1189
|
-
window.addEventListener("resize", place);
|
|
1190
|
-
window.addEventListener("scroll", place, true);
|
|
1191
|
-
return () => {
|
|
1192
|
-
window.removeEventListener("mousedown", onPointer);
|
|
1193
|
-
window.removeEventListener("resize", place);
|
|
1194
|
-
window.removeEventListener("scroll", place, true);
|
|
1195
|
-
};
|
|
1196
|
-
}, [
|
|
1197
|
-
open,
|
|
1198
|
-
searchable,
|
|
1199
|
-
onQueryChange
|
|
1200
|
-
]);
|
|
1201
|
-
useEffect(() => {
|
|
1202
|
-
popoverRef.current?.querySelector(`[data-index="${active}"]`)?.scrollIntoView({ block: "nearest" });
|
|
1203
|
-
}, [active]);
|
|
1204
|
-
const choose = (option) => {
|
|
1205
|
-
if (option.disabled) return;
|
|
1206
|
-
if (props.multiple) {
|
|
1207
|
-
props.onChange(selectedSet.has(option.value) ? props.value.filter((value) => value !== option.value) : [...props.value, option.value]);
|
|
1208
|
-
return;
|
|
1209
|
-
}
|
|
1210
|
-
props.onChange(option.value);
|
|
1211
|
-
close();
|
|
1212
|
-
};
|
|
1213
|
-
const onListKey = (event) => {
|
|
1214
|
-
if (event.key === "ArrowDown") {
|
|
1215
|
-
event.preventDefault();
|
|
1216
|
-
setActive((index) => Math.min(visible.length - 1, index + 1));
|
|
1217
|
-
} else if (event.key === "ArrowUp") {
|
|
1218
|
-
event.preventDefault();
|
|
1219
|
-
setActive((index) => Math.max(0, index - 1));
|
|
1220
|
-
} else if (event.key === "Enter") {
|
|
1221
|
-
event.preventDefault();
|
|
1222
|
-
const option = visible[active];
|
|
1223
|
-
if (option) choose(option);
|
|
1224
|
-
} else if (event.key === "Escape") {
|
|
1225
|
-
event.preventDefault();
|
|
1226
|
-
close();
|
|
1227
|
-
} else if (event.key === "Tab") dismiss();
|
|
1228
|
-
};
|
|
1229
|
-
const labels = props.options.filter((option) => selectedSet.has(option.value)).map((option) => option.label);
|
|
1230
|
-
const unknown = selected.filter((value) => !props.options.some((option) => option.value === value));
|
|
1231
|
-
const shown = [...labels, ...unknown];
|
|
1232
|
-
const selectedIcon = props.multiple ? void 0 : props.options.find((option) => option.value === props.value)?.icon;
|
|
1233
|
-
return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsxs("button", {
|
|
1234
|
-
ref: triggerRef,
|
|
1235
|
-
id: props.id,
|
|
1236
|
-
"aria-label": props.ariaLabel,
|
|
1237
|
-
type: "button",
|
|
1238
|
-
role: "combobox",
|
|
1239
|
-
"aria-expanded": open,
|
|
1240
|
-
"aria-controls": open ? listId : void 0,
|
|
1241
|
-
"aria-activedescendant": open && visible.length > 0 ? `${listId}-${active}` : void 0,
|
|
1242
|
-
"aria-haspopup": "listbox",
|
|
1243
|
-
disabled: props.disabled,
|
|
1244
|
-
className: `${textInputClass} flex items-center gap-2 text-left ${props.invalid ? invalidClass : ""} ${open ? "border-ring ring-2 ring-ring/25" : ""}`,
|
|
1245
|
-
onClick: () => open ? close() : openList(),
|
|
1246
|
-
onKeyDown: (event) => {
|
|
1247
|
-
if (open) {
|
|
1248
|
-
onListKey(event);
|
|
1249
|
-
return;
|
|
1250
|
-
}
|
|
1251
|
-
if (event.key === "ArrowDown" || event.key === "Enter" || event.key === " ") {
|
|
1252
|
-
event.preventDefault();
|
|
1253
|
-
openList();
|
|
1254
|
-
}
|
|
1255
|
-
},
|
|
1256
|
-
children: [
|
|
1257
|
-
selectedIcon,
|
|
1258
|
-
/* @__PURE__ */ jsx("span", {
|
|
1259
|
-
className: `min-w-0 flex-1 truncate ${shown.length ? "" : "text-muted-foreground/70"}`,
|
|
1260
|
-
children: shown.length > 0 ? shown.join(", ") : props.loading ? "Loading…" : props.placeholder ?? "Choose…"
|
|
1261
|
-
}),
|
|
1262
|
-
props.multiple && shown.length > 1 ? /* @__PURE__ */ jsx("span", {
|
|
1263
|
-
className: "shrink-0 rounded bg-muted px-1.5 text-[11px] tabular-nums text-muted-foreground",
|
|
1264
|
-
children: shown.length
|
|
1265
|
-
}) : null,
|
|
1266
|
-
/* @__PURE__ */ jsx(Icon, {
|
|
1267
|
-
name: "chevronDown",
|
|
1268
|
-
className: `h-3.5 w-3.5 text-muted-foreground transition-transform ${open ? "rotate-180" : ""}`
|
|
1269
|
-
})
|
|
1270
|
-
]
|
|
1271
|
-
}), open && position ? createPortal(/* @__PURE__ */ jsxs("div", {
|
|
1272
|
-
ref: popoverRef,
|
|
1273
|
-
tabIndex: -1,
|
|
1274
|
-
className: "workflow-select-popover fixed flex flex-col overflow-hidden rounded-lg border border-solid border-foreground/10 bg-popover text-popover-foreground shadow-lg outline-none",
|
|
1275
|
-
style: {
|
|
1276
|
-
left: position.left,
|
|
1277
|
-
width: Math.max(position.width, 220),
|
|
1278
|
-
top: position.top,
|
|
1279
|
-
bottom: position.bottom,
|
|
1280
|
-
maxHeight: position.maxHeight
|
|
1281
|
-
},
|
|
1282
|
-
onKeyDown: onListKey,
|
|
1283
|
-
children: [
|
|
1284
|
-
searchable || props.onRefresh ? /* @__PURE__ */ jsxs("div", {
|
|
1285
|
-
className: "flex items-center gap-1 border-b border-solid border-foreground/10 px-2",
|
|
1286
|
-
children: [searchable ? /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(Icon, {
|
|
1287
|
-
name: "search",
|
|
1288
|
-
className: "h-3.5 w-3.5 text-muted-foreground"
|
|
1289
|
-
}), /* @__PURE__ */ jsx("input", {
|
|
1290
|
-
ref: searchRef,
|
|
1291
|
-
className: "h-9 min-w-0 flex-1 bg-transparent text-[13px] text-foreground placeholder:text-muted-foreground/70 focus:outline-none",
|
|
1292
|
-
placeholder: "Search",
|
|
1293
|
-
value: query,
|
|
1294
|
-
onChange: (event) => {
|
|
1295
|
-
setQuery(event.target.value);
|
|
1296
|
-
setActive(0);
|
|
1297
|
-
props.onQueryChange?.(event.target.value);
|
|
1298
|
-
}
|
|
1299
|
-
})] }) : /* @__PURE__ */ jsx("span", { className: "h-9 flex-1" }), props.onRefresh ? /* @__PURE__ */ jsx(IconButton, {
|
|
1300
|
-
icon: "retry",
|
|
1301
|
-
label: "Reload options",
|
|
1302
|
-
disabled: props.loading,
|
|
1303
|
-
onClick: props.onRefresh
|
|
1304
|
-
}) : null]
|
|
1305
|
-
}) : null,
|
|
1306
|
-
/* @__PURE__ */ jsx("div", {
|
|
1307
|
-
id: listId,
|
|
1308
|
-
role: "listbox",
|
|
1309
|
-
"aria-multiselectable": props.multiple || void 0,
|
|
1310
|
-
className: "min-h-0 flex-1 overflow-y-auto p-1",
|
|
1311
|
-
children: props.loading && props.options.length === 0 ? /* @__PURE__ */ jsx("p", {
|
|
1312
|
-
className: "px-2 py-2 text-[13px] text-muted-foreground",
|
|
1313
|
-
children: "Loading options…"
|
|
1314
|
-
}) : visible.length === 0 ? /* @__PURE__ */ jsx("p", {
|
|
1315
|
-
className: "px-2 py-2 text-[13px] text-muted-foreground",
|
|
1316
|
-
children: needle ? "Nothing matches." : props.emptyText ?? "No options."
|
|
1317
|
-
}) : visible.map((option, index) => {
|
|
1318
|
-
const isSelected = selectedSet.has(option.value);
|
|
1319
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
1320
|
-
id: `${listId}-${index}`,
|
|
1321
|
-
role: "option",
|
|
1322
|
-
"aria-selected": isSelected,
|
|
1323
|
-
"aria-disabled": option.disabled || void 0,
|
|
1324
|
-
"data-index": index,
|
|
1325
|
-
className: `flex cursor-pointer items-center gap-2 rounded-md px-2 py-1.5 text-[13px] ${index === active ? "bg-accent" : ""} ${option.disabled ? "cursor-not-allowed opacity-50" : ""}`,
|
|
1326
|
-
onMouseEnter: () => setActive(index),
|
|
1327
|
-
onMouseDown: (event) => {
|
|
1328
|
-
event.preventDefault();
|
|
1329
|
-
choose(option);
|
|
1330
|
-
},
|
|
1331
|
-
children: [
|
|
1332
|
-
props.multiple ? /* @__PURE__ */ jsx("span", {
|
|
1333
|
-
className: `flex h-4 w-4 shrink-0 items-center justify-center rounded border border-solid ${isSelected ? "border-primary bg-primary text-primary-foreground" : "border-foreground/25"}`,
|
|
1334
|
-
children: isSelected ? /* @__PURE__ */ jsx(Icon, {
|
|
1335
|
-
name: "check",
|
|
1336
|
-
className: "h-3 w-3"
|
|
1337
|
-
}) : null
|
|
1338
|
-
}) : null,
|
|
1339
|
-
option.icon,
|
|
1340
|
-
/* @__PURE__ */ jsxs("span", {
|
|
1341
|
-
className: "min-w-0 flex-1",
|
|
1342
|
-
children: [/* @__PURE__ */ jsx("span", {
|
|
1343
|
-
className: "block truncate",
|
|
1344
|
-
children: option.label
|
|
1345
|
-
}), option.description ? /* @__PURE__ */ jsx("span", {
|
|
1346
|
-
className: "block truncate text-xs text-muted-foreground",
|
|
1347
|
-
children: option.description
|
|
1348
|
-
}) : null]
|
|
1349
|
-
}),
|
|
1350
|
-
!props.multiple && isSelected ? /* @__PURE__ */ jsx(Icon, {
|
|
1351
|
-
name: "check",
|
|
1352
|
-
className: "h-3.5 w-3.5 text-foreground"
|
|
1353
|
-
}) : null
|
|
1354
|
-
]
|
|
1355
|
-
}, option.value);
|
|
1356
|
-
})
|
|
1357
|
-
}),
|
|
1358
|
-
props.actions?.length ? /* @__PURE__ */ jsx("div", {
|
|
1359
|
-
className: "border-t border-solid border-foreground/10 p-1",
|
|
1360
|
-
children: props.actions.map((action) => /* @__PURE__ */ jsxs("button", {
|
|
1361
|
-
type: "button",
|
|
1362
|
-
className: "flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-[13px] text-muted-foreground hover:bg-accent hover:text-foreground",
|
|
1363
|
-
onMouseDown: (event) => {
|
|
1364
|
-
event.preventDefault();
|
|
1365
|
-
dismiss();
|
|
1366
|
-
action.onSelect();
|
|
1367
|
-
},
|
|
1368
|
-
children: [action.icon ? /* @__PURE__ */ jsx(Icon, {
|
|
1369
|
-
name: action.icon,
|
|
1370
|
-
className: "h-3.5 w-3.5"
|
|
1371
|
-
}) : null, action.label]
|
|
1372
|
-
}, action.label))
|
|
1373
|
-
}) : null,
|
|
1374
|
-
!props.multiple && props.clearable && props.value ? /* @__PURE__ */ jsx("div", {
|
|
1375
|
-
className: "border-t border-solid border-foreground/10 p-1",
|
|
1376
|
-
children: /* @__PURE__ */ jsxs("button", {
|
|
1377
|
-
type: "button",
|
|
1378
|
-
className: "flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-[13px] text-muted-foreground hover:bg-accent hover:text-foreground",
|
|
1379
|
-
onMouseDown: (event) => {
|
|
1380
|
-
event.preventDefault();
|
|
1381
|
-
props.onChange("");
|
|
1382
|
-
close();
|
|
1383
|
-
},
|
|
1384
|
-
children: [/* @__PURE__ */ jsx(Icon, {
|
|
1385
|
-
name: "close",
|
|
1386
|
-
className: "h-3.5 w-3.5"
|
|
1387
|
-
}), "Clear selection"]
|
|
1388
|
-
})
|
|
1389
|
-
}) : null
|
|
1390
|
-
]
|
|
1391
|
-
}), document.body) : null] });
|
|
1392
|
-
}
|
|
1393
|
-
function shouldPersistQuery(queryKey) {
|
|
1394
|
-
if (typeof queryKey[0] !== "string") return false;
|
|
1395
|
-
const kind = queryKind(queryKey);
|
|
1396
|
-
if (kind === "catalog") return queryKey.length === 2;
|
|
1397
|
-
if (kind === "form") {
|
|
1398
|
-
const block = queryKey[2];
|
|
1399
|
-
return Array.isArray(block) && block[0] !== "@powerhousedao/piece-core";
|
|
1400
|
-
}
|
|
1401
|
-
return false;
|
|
1402
|
-
}
|
|
1403
|
-
function persistRuntimeQueries(queryClient, url, store, now = Date.now) {
|
|
1404
|
-
if (!store) return {
|
|
1405
|
-
ready: Promise.resolve(),
|
|
1406
|
-
dispose: () => void 0
|
|
1407
|
-
};
|
|
1408
|
-
return {
|
|
1409
|
-
ready: hydrate(queryClient, url, store, now()),
|
|
1410
|
-
dispose: queryClient.getQueryCache().subscribe((event) => {
|
|
1411
|
-
if (event.type !== "updated" || event.action.type !== "success") return;
|
|
1412
|
-
if (event.action.manual) return;
|
|
1413
|
-
const { queryKey, state } = event.query;
|
|
1414
|
-
if (!shouldPersistQuery(queryKey) || state.data === void 0) return;
|
|
1415
|
-
store.save({
|
|
1416
|
-
id: JSON.stringify(queryKey),
|
|
1417
|
-
url: queryKey[0],
|
|
1418
|
-
queryKey,
|
|
1419
|
-
data: state.data,
|
|
1420
|
-
updatedAt: state.dataUpdatedAt,
|
|
1421
|
-
version: 1
|
|
1422
|
-
}).catch(() => void 0);
|
|
1423
|
-
})
|
|
1424
|
-
};
|
|
1425
|
-
}
|
|
1426
|
-
async function hydrate(queryClient, url, store, at) {
|
|
1427
|
-
let entries;
|
|
1428
|
-
try {
|
|
1429
|
-
entries = await store.load(url);
|
|
1430
|
-
} catch {
|
|
1431
|
-
return;
|
|
1432
|
-
}
|
|
1433
|
-
for (const entry of entries) {
|
|
1434
|
-
if (entry.version !== 1 || at - entry.updatedAt > 6048e5 || !shouldPersistQuery(entry.queryKey)) {
|
|
1435
|
-
store.remove(entry.id).catch(() => void 0);
|
|
1436
|
-
continue;
|
|
1437
|
-
}
|
|
1438
|
-
const current = queryClient.getQueryState(entry.queryKey);
|
|
1439
|
-
if (current && current.dataUpdatedAt >= entry.updatedAt) continue;
|
|
1440
|
-
queryClient.setQueryData(entry.queryKey, entry.data, { updatedAt: entry.updatedAt });
|
|
1441
|
-
}
|
|
1442
|
-
}
|
|
1443
|
-
const DB_NAME = "ph-workflow-runtime-cache";
|
|
1444
|
-
const STORE = "queries";
|
|
1445
|
-
function request(req) {
|
|
1446
|
-
return new Promise((resolve, reject) => {
|
|
1447
|
-
req.onsuccess = () => resolve(req.result);
|
|
1448
|
-
req.onerror = () => reject(req.error ?? /* @__PURE__ */ new Error("IndexedDB request failed"));
|
|
1449
|
-
});
|
|
1450
|
-
}
|
|
1451
|
-
function openIdbCacheStore() {
|
|
1452
|
-
const idb = globalThis.indexedDB;
|
|
1453
|
-
if (!idb) return null;
|
|
1454
|
-
let db;
|
|
1455
|
-
const open = () => {
|
|
1456
|
-
db ??= new Promise((resolve, reject) => {
|
|
1457
|
-
const req = idb.open(DB_NAME, 1);
|
|
1458
|
-
req.onupgradeneeded = () => {
|
|
1459
|
-
req.result.createObjectStore(STORE, { keyPath: "id" }).createIndex("url", "url");
|
|
1460
|
-
};
|
|
1461
|
-
req.onsuccess = () => resolve(req.result);
|
|
1462
|
-
req.onerror = () => reject(req.error ?? /* @__PURE__ */ new Error("IndexedDB unavailable"));
|
|
1463
|
-
req.onblocked = () => reject(/* @__PURE__ */ new Error("IndexedDB blocked"));
|
|
1464
|
-
});
|
|
1465
|
-
db.catch(() => db = void 0);
|
|
1466
|
-
return db;
|
|
1467
|
-
};
|
|
1468
|
-
const withStore = async (mode, run) => {
|
|
1469
|
-
return request(run((await open()).transaction(STORE, mode).objectStore(STORE)));
|
|
1470
|
-
};
|
|
1471
|
-
return {
|
|
1472
|
-
load: (url) => withStore("readonly", (store) => store.index("url").getAll(url)),
|
|
1473
|
-
save: (entry) => withStore("readwrite", (store) => store.put(entry)).then(() => void 0),
|
|
1474
|
-
remove: (id) => withStore("readwrite", (store) => store.delete(id)).then(() => void 0)
|
|
1475
|
-
};
|
|
1476
|
-
}
|
|
1477
|
-
//#endregion
|
|
1478
|
-
//#region editors/workflow-editor/ui/piece-source.ts
|
|
1479
|
-
function blockUnavailable(entry) {
|
|
1480
|
-
if (entry.unsupported) return entry.unsupported;
|
|
1481
|
-
if (entry.kind !== "trigger") return void 0;
|
|
1482
|
-
const strategy = checkTriggerStrategy(entry.strategy);
|
|
1483
|
-
return "issue" in strategy ? strategy.issue : void 0;
|
|
1484
|
-
}
|
|
1485
|
-
const PieceSourceContext = createContext(void 0);
|
|
1486
|
-
const PieceSourceProvider = PieceSourceContext.Provider;
|
|
1487
|
-
function usePieceSource() {
|
|
1488
|
-
return useContext(PieceSourceContext);
|
|
1489
|
-
}
|
|
1490
|
-
//#endregion
|
|
1491
|
-
//#region editors/workflow-editor/use-runtime-url.ts
|
|
1492
|
-
const SUBGRAPH_NAME = "workflow-runtime";
|
|
1493
|
-
function baseFromChannelUrl(channelUrl) {
|
|
1494
|
-
try {
|
|
1495
|
-
const url = new URL(channelUrl);
|
|
1496
|
-
url.search = "";
|
|
1497
|
-
url.hash = "";
|
|
1498
|
-
url.pathname = url.pathname.replace(/\/r\/?$/, "");
|
|
1499
|
-
return url.toString();
|
|
1500
|
-
} catch {
|
|
1501
|
-
return;
|
|
1502
|
-
}
|
|
1503
|
-
}
|
|
1504
|
-
function useWorkflowRuntimeUrl() {
|
|
1505
|
-
const [drive] = useSelectedDriveSafe();
|
|
1506
|
-
const remotes = useSyncList();
|
|
1507
|
-
const defaultDrivesUrl = useDefaultDrivesUrl();
|
|
1508
|
-
const driveId = drive?.header.id;
|
|
1509
|
-
return useMemo(() => {
|
|
1510
|
-
let base;
|
|
1511
|
-
if (driveId) {
|
|
1512
|
-
const channelUrl = (remotes.find((entry) => entry.meta.collectionId.equals(DriveCollectionId.forDrive(driveId)))?.channel)?.config.url;
|
|
1513
|
-
if (typeof channelUrl === "string") base = baseFromChannelUrl(channelUrl);
|
|
1514
|
-
}
|
|
1515
|
-
if (!base && defaultDrivesUrl) try {
|
|
1516
|
-
base = parseDriveUrl(defaultDrivesUrl).graphqlEndpoint.replace(/\/r$/, "");
|
|
1517
|
-
} catch {}
|
|
1518
|
-
return subgraphUrlFromGraphqlUrl(base ?? DEFAULT_SWITCHBOARD_URL, SUBGRAPH_NAME);
|
|
1519
|
-
}, [
|
|
1520
|
-
driveId,
|
|
1521
|
-
remotes,
|
|
1522
|
-
defaultDrivesUrl
|
|
1523
|
-
]);
|
|
1524
|
-
}
|
|
1525
|
-
//#endregion
|
|
1526
|
-
//#region editors/workflow-editor/runtime-context.tsx
|
|
1527
|
-
const RuntimeContext = createContext(null);
|
|
1528
|
-
function runtimePieceSource(client, queryClient) {
|
|
1529
|
-
return {
|
|
1530
|
-
loadCatalog: () => queryClient.fetchQuery(catalogQuery(client)),
|
|
1531
|
-
reloadCatalog: () => queryClient.fetchQuery({
|
|
1532
|
-
...catalogQuery(client),
|
|
1533
|
-
staleTime: 0
|
|
1534
|
-
}),
|
|
1535
|
-
loadActions: (packageName) => queryClient.fetchQuery(pieceActionsQuery(client, packageName)),
|
|
1536
|
-
loadTriggers: (packageName) => queryClient.fetchQuery(pieceTriggersQuery(client, packageName)),
|
|
1537
|
-
searchBlocks: (query, limit) => client.searchBlocks(query, limit)
|
|
1538
|
-
};
|
|
1539
|
-
}
|
|
1540
|
-
function RuntimeProvider(props) {
|
|
1541
|
-
const { url } = props;
|
|
1542
|
-
const [queryClient] = useState(createRuntimeQueryClient);
|
|
1543
|
-
const [store] = useState(() => props.store === void 0 ? openIdbCacheStore() : props.store);
|
|
1544
|
-
const client = useMemo(() => createRuntimeClient(url), [url]);
|
|
1545
|
-
useEffect(() => persistRuntimeQueries(queryClient, url, store).dispose, [
|
|
1546
|
-
queryClient,
|
|
1547
|
-
url,
|
|
1548
|
-
store
|
|
1549
|
-
]);
|
|
1550
|
-
const value = useMemo(() => ({
|
|
1551
|
-
client,
|
|
1552
|
-
queryClient
|
|
1553
|
-
}), [client, queryClient]);
|
|
1554
|
-
const pieceSource = useMemo(() => runtimePieceSource(client, queryClient), [client, queryClient]);
|
|
1555
|
-
return /* @__PURE__ */ jsx(RuntimeContext.Provider, {
|
|
1556
|
-
value,
|
|
1557
|
-
children: /* @__PURE__ */ jsx(PieceSourceProvider, {
|
|
1558
|
-
value: pieceSource,
|
|
1559
|
-
children: props.children
|
|
1560
|
-
})
|
|
1561
|
-
});
|
|
1562
|
-
}
|
|
1563
|
-
function WorkflowRuntimeProvider(props) {
|
|
1564
|
-
const url = useWorkflowRuntimeUrl();
|
|
1565
|
-
return /* @__PURE__ */ jsx(RuntimeProvider, {
|
|
1566
|
-
url,
|
|
1567
|
-
children: props.children
|
|
1568
|
-
});
|
|
1569
|
-
}
|
|
1570
|
-
function useRuntime() {
|
|
1571
|
-
const context = useContext(RuntimeContext);
|
|
1572
|
-
if (!context) throw new Error("useRuntime needs a RuntimeProvider");
|
|
1573
|
-
return context;
|
|
1574
|
-
}
|
|
1575
|
-
function usePieceCatalog() {
|
|
1576
|
-
const { client, queryClient } = useRuntime();
|
|
1577
|
-
return useQuery(catalogQuery(client), queryClient);
|
|
1578
|
-
}
|
|
1579
|
-
function useRunsQuery(scope, options = {}) {
|
|
1580
|
-
const { client, queryClient } = useRuntime();
|
|
1581
|
-
return useQuery({
|
|
1582
|
-
...runsQuery(client, scope),
|
|
1583
|
-
enabled: options.active ?? true,
|
|
1584
|
-
refetchInterval: options.pollMs ?? false
|
|
1585
|
-
}, queryClient);
|
|
1586
|
-
}
|
|
1587
|
-
function useRunPagesQuery(scope, options = {}) {
|
|
1588
|
-
const { client, queryClient } = useRuntime();
|
|
1589
|
-
return useInfiniteQuery({
|
|
1590
|
-
...runPagesQuery(client, scope),
|
|
1591
|
-
enabled: options.active ?? true,
|
|
1592
|
-
refetchInterval: options.pollMs ?? false
|
|
1593
|
-
}, queryClient);
|
|
1594
|
-
}
|
|
1595
|
-
function useRunQuery(runId, options = {}) {
|
|
1596
|
-
const { client, queryClient } = useRuntime();
|
|
1597
|
-
return useQuery({
|
|
1598
|
-
...runQuery(client, runId),
|
|
1599
|
-
refetchInterval: (query) => options.pollMs && query.state.data?.endedAt == null ? options.pollMs : false
|
|
1600
|
-
}, queryClient);
|
|
1601
|
-
}
|
|
1602
|
-
function useSecretStat(ref, enabled) {
|
|
1603
|
-
const { client, queryClient } = useRuntime();
|
|
1604
|
-
const query = useQuery({
|
|
1605
|
-
...secretStatQuery(client, ref),
|
|
1606
|
-
enabled,
|
|
1607
|
-
gcTime: 0
|
|
1608
|
-
}, queryClient);
|
|
1609
|
-
if (!enabled) return null;
|
|
1610
|
-
if (query.status === "pending") return void 0;
|
|
1611
|
-
return query.status === "error" ? null : query.data;
|
|
1612
|
-
}
|
|
1613
|
-
function useOAuthRedirectUri() {
|
|
1614
|
-
const { client, queryClient } = useRuntime();
|
|
1615
|
-
return useQuery({
|
|
1616
|
-
queryKey: [client.url, "oauthRedirectUri"],
|
|
1617
|
-
queryFn: () => client.fetchOAuthRedirectUri(),
|
|
1618
|
-
staleTime: Infinity
|
|
1619
|
-
}, queryClient);
|
|
1620
|
-
}
|
|
1621
|
-
function useOAuthAttempt(state) {
|
|
1622
|
-
const { client, queryClient } = useRuntime();
|
|
1623
|
-
const query = useQuery({
|
|
1624
|
-
queryKey: [
|
|
1625
|
-
client.url,
|
|
1626
|
-
"oauthAttempt",
|
|
1627
|
-
state
|
|
1628
|
-
],
|
|
1629
|
-
queryFn: () => client.fetchOAuthAttempt(state),
|
|
1630
|
-
enabled: state !== null,
|
|
1631
|
-
gcTime: 0,
|
|
1632
|
-
refetchInterval: (current) => {
|
|
1633
|
-
if (current.state.status === "error") return false;
|
|
1634
|
-
const data = current.state.data;
|
|
1635
|
-
if (data === null) return false;
|
|
1636
|
-
return data?.status === "OK" || data?.status === "ERROR" ? false : 1e3;
|
|
1637
|
-
}
|
|
1638
|
-
}, queryClient);
|
|
1639
|
-
if (state === null || query.isError) return null;
|
|
1640
|
-
return query.data;
|
|
1641
|
-
}
|
|
1642
|
-
function useRuntimeActions() {
|
|
1643
|
-
const { client, queryClient } = useRuntime();
|
|
1644
|
-
return useMemo(() => {
|
|
1645
|
-
const invalidate = (queryKey) => void queryClient.invalidateQueries({ queryKey });
|
|
1646
|
-
const runsChanged = () => {
|
|
1647
|
-
invalidate(runtimeKeys.allRuns(client.url));
|
|
1648
|
-
invalidate([client.url, "latestRun"]);
|
|
1649
|
-
};
|
|
1650
|
-
const secretSaved = (stat) => {
|
|
1651
|
-
queryClient.setQueryData(runtimeKeys.secret(client.url, stat.ref), stat);
|
|
1652
|
-
return stat;
|
|
1653
|
-
};
|
|
1654
|
-
return {
|
|
1655
|
-
fireWorkflow: (workflowId, payload) => client.fireWorkflow(workflowId, payload).finally(runsChanged),
|
|
1656
|
-
rerunRun: (runId) => client.rerunRun(runId).finally(runsChanged),
|
|
1657
|
-
createSecret: (value, label) => client.createSecret(value, label).then(secretSaved),
|
|
1658
|
-
rotateSecret: (ref, value) => client.rotateSecret(ref, value).then(secretSaved),
|
|
1659
|
-
checkConnection: (connectionId) => client.checkConnection(connectionId).finally(() => invalidate(runtimeKeys.connections(client.url))),
|
|
1660
|
-
connectionsChanged: () => invalidate(runtimeKeys.connections(client.url)),
|
|
1661
|
-
startOAuth: (connectionId, options) => client.startOAuth(connectionId, options)
|
|
1662
|
-
};
|
|
1663
|
-
}, [client, queryClient]);
|
|
1664
|
-
}
|
|
1665
|
-
//#endregion
|
|
1666
|
-
//#region editors/workflow-studio/components/run-format.ts
|
|
1667
|
-
const RUN_STATUSES = [
|
|
1668
|
-
"RUNNING",
|
|
1669
|
-
"SUCCEEDED",
|
|
1670
|
-
"FAILED"
|
|
1671
|
-
];
|
|
1672
|
-
const TONE_TEXT = {
|
|
1673
|
-
ok: "text-wf-ok",
|
|
1674
|
-
fail: "text-wf-fail",
|
|
1675
|
-
warn: "text-wf-warn",
|
|
1676
|
-
run: "text-wf-run",
|
|
1677
|
-
idle: "text-muted-foreground"
|
|
1678
|
-
};
|
|
1679
|
-
const TONE_DOT = {
|
|
1680
|
-
ok: "bg-wf-ok",
|
|
1681
|
-
fail: "bg-wf-fail",
|
|
1682
|
-
warn: "bg-wf-warn",
|
|
1683
|
-
run: "bg-wf-run",
|
|
1684
|
-
idle: "bg-muted-foreground/40"
|
|
1685
|
-
};
|
|
1686
|
-
const RUN_TONE = {
|
|
1687
|
-
SUCCEEDED: "ok",
|
|
1688
|
-
FAILED: "fail",
|
|
1689
|
-
RUNNING: "run",
|
|
1690
|
-
WAITING: "run",
|
|
1691
|
-
PENDING: "idle",
|
|
1692
|
-
PARKED: "warn",
|
|
1693
|
-
CANCELLED: "idle"
|
|
1694
|
-
};
|
|
1695
|
-
const STEP_TONE = {
|
|
1696
|
-
...RUN_TONE,
|
|
1697
|
-
SKIPPED: "idle",
|
|
1698
|
-
REPLAYED: "run"
|
|
1699
|
-
};
|
|
1700
|
-
function runTone(run) {
|
|
1701
|
-
if (run.status === "SUCCEEDED" && (run.warningNotes?.length ?? 0) > 0) return "warn";
|
|
1702
|
-
return toneOf(RUN_TONE, run.status);
|
|
1703
|
-
}
|
|
1704
|
-
function runStatusLabel(run) {
|
|
1705
|
-
const count = run.warningNotes?.length ?? 0;
|
|
1706
|
-
const label = statusLabel(run.status);
|
|
1707
|
-
if (run.status !== "SUCCEEDED" || count === 0) return label;
|
|
1708
|
-
return `${label}, ${count} ${count === 1 ? "warning" : "warnings"}`;
|
|
1709
|
-
}
|
|
1710
|
-
function workflowHealth(status, lastRunStatus, published) {
|
|
1711
|
-
if (!published) return {
|
|
1712
|
-
tone: "idle",
|
|
1713
|
-
hollow: true,
|
|
1714
|
-
label: "Not published yet"
|
|
1715
|
-
};
|
|
1716
|
-
const label = (status === "ENABLED" ? "" : `${statusLabel(status ?? "DISABLED")}, `) + (lastRunStatus ? `last run ${statusLabel(lastRunStatus).toLowerCase()}` : "not run yet");
|
|
1717
|
-
return {
|
|
1718
|
-
tone: toneOf(RUN_TONE, lastRunStatus),
|
|
1719
|
-
hollow: false,
|
|
1720
|
-
label: label.charAt(0).toUpperCase() + label.slice(1)
|
|
1721
|
-
};
|
|
1722
|
-
}
|
|
1723
|
-
const CONNECTION_TONE = {
|
|
1724
|
-
OK: "ok",
|
|
1725
|
-
ERROR: "fail",
|
|
1726
|
-
REVOKED: "fail",
|
|
1727
|
-
UNCONFIGURED: "warn"
|
|
1728
|
-
};
|
|
1729
|
-
function toneOf(map, status) {
|
|
1730
|
-
return (status ? map[status] : void 0) ?? "idle";
|
|
1731
|
-
}
|
|
1732
|
-
function statusLabel(status) {
|
|
1733
|
-
return status.charAt(0) + status.slice(1).toLowerCase();
|
|
1734
|
-
}
|
|
1735
|
-
function formatDuration(startedAt, endedAt) {
|
|
1736
|
-
if (!endedAt) return "…";
|
|
1737
|
-
return formatMs(new Date(endedAt).getTime() - new Date(startedAt).getTime());
|
|
1738
|
-
}
|
|
1739
|
-
function runTimeline(run) {
|
|
1740
|
-
const start = new Date(run.startedAt).getTime();
|
|
1741
|
-
const ends = run.steps.map((step) => step.endedAt ? new Date(step.endedAt).getTime() : 0).concat(run.endedAt ? new Date(run.endedAt).getTime() : 0);
|
|
1742
|
-
const total = Math.max(...ends) - start;
|
|
1743
|
-
const spans = /* @__PURE__ */ new Map();
|
|
1744
|
-
if (total <= 0) return spans;
|
|
1745
|
-
for (const step of run.steps) {
|
|
1746
|
-
if (!step.startedAt || !step.endedAt) continue;
|
|
1747
|
-
const from = new Date(step.startedAt).getTime() - start;
|
|
1748
|
-
const ms = new Date(step.endedAt).getTime() - new Date(step.startedAt).getTime();
|
|
1749
|
-
spans.set(step.stepId, {
|
|
1750
|
-
offset: Math.min(Math.max(from / total, 0), 1),
|
|
1751
|
-
width: Math.min(Math.max(ms / total, 0), 1),
|
|
1752
|
-
ms
|
|
1753
|
-
});
|
|
1754
|
-
}
|
|
1755
|
-
return spans;
|
|
1756
|
-
}
|
|
1757
|
-
function formatMs(ms) {
|
|
1758
|
-
if (ms < 1e3) return `${ms}ms`;
|
|
1759
|
-
const tenths = Math.round(ms / 100);
|
|
1760
|
-
if (tenths < 600) return `${(tenths / 10).toFixed(1)}s`;
|
|
1761
|
-
const seconds = Math.round(ms / 1e3);
|
|
1762
|
-
return `${Math.floor(seconds / 60)}m ${seconds % 60}s`;
|
|
1763
|
-
}
|
|
1764
|
-
function durationMs(startedAt, endedAt) {
|
|
1765
|
-
if (!endedAt) return null;
|
|
1766
|
-
return new Date(endedAt).getTime() - new Date(startedAt).getTime();
|
|
1767
|
-
}
|
|
1768
|
-
function formatWhen(startedAt) {
|
|
1769
|
-
const diff = Date.now() - new Date(startedAt).getTime();
|
|
1770
|
-
if (diff < 6e4) return "just now";
|
|
1771
|
-
if (diff < 36e5) return `${Math.floor(diff / 6e4)}m ago`;
|
|
1772
|
-
if (diff < 864e5) return `${Math.floor(diff / 36e5)}h ago`;
|
|
1773
|
-
return new Date(startedAt).toLocaleDateString();
|
|
1774
|
-
}
|
|
1775
|
-
function formatAbsolute(iso) {
|
|
1776
|
-
return new Date(iso).toLocaleString();
|
|
1777
|
-
}
|
|
1778
|
-
function formatTrigger(kind) {
|
|
1779
|
-
return kind.replace(/[-_]/g, " ").toLowerCase();
|
|
1780
|
-
}
|
|
1781
|
-
function runStats(runs) {
|
|
1782
|
-
const succeeded = runs.filter((run) => run.status === "SUCCEEDED").length;
|
|
1783
|
-
const failed = runs.filter((run) => run.status === "FAILED").length;
|
|
1784
|
-
const finished = succeeded + failed;
|
|
1785
|
-
return {
|
|
1786
|
-
total: runs.length,
|
|
1787
|
-
succeeded,
|
|
1788
|
-
failed,
|
|
1789
|
-
running: runs.filter((run) => run.status === "RUNNING").length,
|
|
1790
|
-
lastRun: runs[0],
|
|
1791
|
-
successRate: finished === 0 ? null : Math.round(succeeded / finished * 100)
|
|
1792
|
-
};
|
|
1793
|
-
}
|
|
1794
|
-
//#endregion
|
|
1795
|
-
//#region editors/workflow-editor/ui/block-meta.ts
|
|
1796
|
-
const CORE_META = {
|
|
1797
|
-
[blockKey(MANUAL_TRIGGER)]: {
|
|
1798
|
-
displayName: "Manual",
|
|
1799
|
-
subtitle: "Trigger",
|
|
1800
|
-
glyph: "▶"
|
|
1801
|
-
},
|
|
1802
|
-
[blockKey(SCHEDULE_TRIGGER)]: {
|
|
1803
|
-
displayName: "Schedule",
|
|
1804
|
-
subtitle: "Trigger",
|
|
1805
|
-
glyph: "◷"
|
|
1806
|
-
},
|
|
1807
|
-
[blockKey(WEBHOOK_TRIGGER)]: {
|
|
1808
|
-
displayName: "Webhook",
|
|
1809
|
-
subtitle: "Trigger",
|
|
1810
|
-
glyph: "⇲"
|
|
1811
|
-
},
|
|
1812
|
-
[blockKey(BRANCH_BLOCK)]: {
|
|
1813
|
-
displayName: "Branch",
|
|
1814
|
-
subtitle: "Core",
|
|
1815
|
-
glyph: "⑂"
|
|
1816
|
-
},
|
|
1817
|
-
[blockKey(ASSERT_BLOCK)]: {
|
|
1818
|
-
displayName: "Assert",
|
|
1819
|
-
subtitle: "Core",
|
|
1820
|
-
glyph: "!"
|
|
1821
|
-
}
|
|
1822
|
-
};
|
|
1823
|
-
function shortPieceName(packageName) {
|
|
1824
|
-
return packageName.split("/").pop()?.replace(/^piece-/, "") ?? "";
|
|
1825
|
-
}
|
|
1826
|
-
const pieceLogos = /* @__PURE__ */ new Map();
|
|
1827
|
-
const pieceNames = /* @__PURE__ */ new Map();
|
|
1828
|
-
const listeners = /* @__PURE__ */ new Set();
|
|
1829
|
-
let logoRevision = 0;
|
|
1830
|
-
function registerPieceLogos(entries) {
|
|
1831
|
-
let changed = false;
|
|
1832
|
-
for (const entry of entries) {
|
|
1833
|
-
if (!entry.name) continue;
|
|
1834
|
-
if (entry.displayName && pieceNames.get(entry.name) !== entry.displayName) {
|
|
1835
|
-
pieceNames.set(entry.name, entry.displayName);
|
|
1836
|
-
changed = true;
|
|
1837
|
-
}
|
|
1838
|
-
if (!entry.logoUrl || pieceLogos.get(entry.name) === entry.logoUrl) continue;
|
|
1839
|
-
pieceLogos.set(entry.name, entry.logoUrl);
|
|
1840
|
-
changed = true;
|
|
1841
|
-
}
|
|
1842
|
-
if (!changed) return;
|
|
1843
|
-
logoRevision += 1;
|
|
1844
|
-
for (const listener of listeners) listener();
|
|
1845
|
-
}
|
|
1846
|
-
function pieceLogo(packageName) {
|
|
1847
|
-
return pieceLogos.get(packageName);
|
|
1848
|
-
}
|
|
1849
|
-
function pieceDisplayName(packageName) {
|
|
1850
|
-
return pieceNames.get(packageName);
|
|
1851
|
-
}
|
|
1852
|
-
const blockNames = /* @__PURE__ */ new Map();
|
|
1853
|
-
const namesRequested = /* @__PURE__ */ new Set();
|
|
1854
|
-
const namesPending = /* @__PURE__ */ new Set();
|
|
1855
|
-
function registerBlockNames(entries) {
|
|
1856
|
-
let changed = false;
|
|
1857
|
-
for (const entry of entries) {
|
|
1858
|
-
const key = blockKey(entry);
|
|
1859
|
-
if (!entry.displayName || blockNames.get(key) === entry.displayName) continue;
|
|
1860
|
-
blockNames.set(key, entry.displayName);
|
|
1861
|
-
changed = true;
|
|
1862
|
-
}
|
|
1863
|
-
if (!changed) return;
|
|
1864
|
-
logoRevision += 1;
|
|
1865
|
-
for (const listener of listeners) listener();
|
|
1866
|
-
}
|
|
1867
|
-
function requestBlockNames(packageName) {
|
|
1868
|
-
if (!namesRequested.has(packageName)) namesPending.add(packageName);
|
|
1869
|
-
}
|
|
1870
|
-
function loadPendingBlockNames(source) {
|
|
1871
|
-
for (const packageName of namesPending) loadBlockNames(source, packageName);
|
|
1872
|
-
namesPending.clear();
|
|
1873
|
-
}
|
|
1874
|
-
function loadBlockNames(source, packageName) {
|
|
1875
|
-
if (namesRequested.has(packageName)) return;
|
|
1876
|
-
namesRequested.add(packageName);
|
|
1877
|
-
Promise.all([source.loadActions(packageName), source.loadTriggers(packageName)]).then(([actions, triggers]) => registerBlockNames([...actions.map((entry) => ({
|
|
1878
|
-
...entry,
|
|
1879
|
-
kind: "action"
|
|
1880
|
-
})), ...triggers.map((entry) => ({
|
|
1881
|
-
...entry,
|
|
1882
|
-
kind: "trigger"
|
|
1883
|
-
}))])).catch(() => namesRequested.delete(packageName));
|
|
1884
|
-
}
|
|
1885
|
-
function subscribePieceLogos(listener) {
|
|
1886
|
-
listeners.add(listener);
|
|
1887
|
-
return () => listeners.delete(listener);
|
|
1888
|
-
}
|
|
1889
|
-
function pieceLogoRevision() {
|
|
1890
|
-
return logoRevision;
|
|
1891
|
-
}
|
|
1892
|
-
const logoMisses = /* @__PURE__ */ new Set();
|
|
1893
|
-
let catalogLoads = /* @__PURE__ */ new WeakMap();
|
|
1894
|
-
const retryTimers = /* @__PURE__ */ new Set();
|
|
1895
|
-
const CATALOG_RETRY_MS = 2e3;
|
|
1896
|
-
function notify() {
|
|
1897
|
-
logoRevision += 1;
|
|
1898
|
-
for (const listener of listeners) listener();
|
|
1899
|
-
}
|
|
1900
|
-
function scheduleRetry(state) {
|
|
1901
|
-
if (state.attempts >= 5) return;
|
|
1902
|
-
const timer = setTimeout(() => {
|
|
1903
|
-
retryTimers.delete(timer);
|
|
1904
|
-
state.load = void 0;
|
|
1905
|
-
notify();
|
|
1906
|
-
}, CATALOG_RETRY_MS * 2 ** (state.attempts - 1));
|
|
1907
|
-
retryTimers.add(timer);
|
|
1908
|
-
}
|
|
1909
|
-
function ensurePieceLogos(source) {
|
|
1910
|
-
if (!source) return Promise.resolve();
|
|
1911
|
-
let state = catalogLoads.get(source);
|
|
1912
|
-
if (!state) {
|
|
1913
|
-
state = { attempts: 0 };
|
|
1914
|
-
catalogLoads.set(source, state);
|
|
1915
|
-
}
|
|
1916
|
-
if (state.load) return state.load;
|
|
1917
|
-
const current = state;
|
|
1918
|
-
const request = current.attempts > 0 && source.reloadCatalog ? source.reloadCatalog() : source.loadCatalog();
|
|
1919
|
-
current.attempts += 1;
|
|
1920
|
-
current.load = request.then((pieces) => {
|
|
1921
|
-
registerPieceLogos(pieces);
|
|
1922
|
-
const listed = new Set(pieces.map((piece) => piece.name));
|
|
1923
|
-
if ([...logoMisses].some((name) => !listed.has(name) && !pieceLogos.has(name))) scheduleRetry(current);
|
|
1924
|
-
}, () => scheduleRetry(current));
|
|
1925
|
-
return current.load;
|
|
1926
|
-
}
|
|
1927
|
-
function blockMeta(block) {
|
|
1928
|
-
const key = blockKey(block);
|
|
1929
|
-
const core = CORE_META[key];
|
|
1930
|
-
if (core) return core;
|
|
1931
|
-
if (isCoreBlock(block)) return {
|
|
1932
|
-
displayName: titleCase(block.name),
|
|
1933
|
-
subtitle: "Core",
|
|
1934
|
-
glyph: "?"
|
|
1935
|
-
};
|
|
1936
|
-
const packageName = block.pieceName;
|
|
1937
|
-
const short = shortPieceName(packageName);
|
|
1938
|
-
const pieceLabel = pieceNames.get(packageName) ?? titleCase(short);
|
|
1939
|
-
const known = blockNames.get(key);
|
|
1940
|
-
if (!known) requestBlockNames(packageName);
|
|
1941
|
-
const logoUrl = pieceLogo(packageName);
|
|
1942
|
-
if (!logoUrl) logoMisses.add(packageName);
|
|
1943
|
-
return {
|
|
1944
|
-
displayName: known ?? titleCase(block.name),
|
|
1945
|
-
subtitle: block.kind === "trigger" ? `${pieceLabel} · Trigger` : pieceLabel,
|
|
1946
|
-
logoUrl,
|
|
1947
|
-
glyph: short.slice(0, 1).toUpperCase() || "?"
|
|
1948
|
-
};
|
|
1949
|
-
}
|
|
1950
|
-
function titleCase(value) {
|
|
1951
|
-
return value.replaceAll(/[-_]/g, " ").replace(/^\w/, (char) => char.toUpperCase());
|
|
1952
|
-
}
|
|
1953
|
-
function usePieceLogos() {
|
|
1954
|
-
const source = usePieceSource();
|
|
1955
|
-
const revision = useSyncExternalStore(subscribePieceLogos, pieceLogoRevision, pieceLogoRevision);
|
|
1956
|
-
useEffect(() => {
|
|
1957
|
-
ensurePieceLogos(source);
|
|
1958
|
-
if (source && namesPending.size > 0) loadPendingBlockNames(source);
|
|
1959
|
-
});
|
|
1960
|
-
return revision;
|
|
1961
|
-
}
|
|
1962
|
-
function useBlockMeta(block) {
|
|
1963
|
-
usePieceLogos();
|
|
1964
|
-
return blockMeta(block);
|
|
1965
|
-
}
|
|
1966
|
-
//#endregion
|
|
1967
|
-
//#region editors/workflow-editor/ui/validation.ts
|
|
1968
|
-
function isEmptyValue(value) {
|
|
1969
|
-
if (value === void 0 || value === null) return true;
|
|
1970
|
-
if (typeof value === "string") return value.trim() === "";
|
|
1971
|
-
if (Array.isArray(value)) return value.length === 0;
|
|
1972
|
-
return false;
|
|
1973
|
-
}
|
|
1974
|
-
function isPropVisible(prop, config) {
|
|
1975
|
-
const rule = prop.showWhen;
|
|
1976
|
-
if (!rule) return true;
|
|
1977
|
-
return rule.oneOf.includes(config[rule.prop] ?? void 0);
|
|
1978
|
-
}
|
|
1979
|
-
function asRecord(config) {
|
|
1980
|
-
return config !== null && typeof config === "object" && !Array.isArray(config) ? config : {};
|
|
1981
|
-
}
|
|
1982
|
-
function missingRequired(props, config) {
|
|
1983
|
-
const record = asRecord(config);
|
|
1984
|
-
return props.filter((prop) => prop.required && prop.type !== "MARKDOWN" && isPropVisible(prop, record) && isEmptyValue(record[prop.name])).map((prop) => prop.displayName);
|
|
1985
|
-
}
|
|
1986
|
-
function resolverInputFor(block, prop, config, connectionId) {
|
|
1987
|
-
const refreshers = (prop.refreshers ?? []).filter((name) => name !== "auth");
|
|
1988
|
-
return {
|
|
1989
|
-
block,
|
|
1990
|
-
propName: prop.name,
|
|
1991
|
-
refreshers: refreshers.map((name) => config[name] ?? null),
|
|
1992
|
-
connectionId: connectionId ?? null
|
|
1993
|
-
};
|
|
1994
|
-
}
|
|
1995
|
-
function settingFor(settings, prop) {
|
|
1996
|
-
return settings?.find((setting) => setting.prop === prop);
|
|
1997
|
-
}
|
|
1998
|
-
function parsePropList(result) {
|
|
1999
|
-
if (!Array.isArray(result)) throw new Error("Unexpected properties result");
|
|
2000
|
-
return result.filter((entry) => entry !== null && typeof entry === "object" && typeof entry.name === "string");
|
|
2001
|
-
}
|
|
2002
|
-
function storedSchema(settings, prop) {
|
|
2003
|
-
const schema = settingFor(settings, prop)?.schema;
|
|
2004
|
-
if (!Array.isArray(schema)) return void 0;
|
|
2005
|
-
return schema.filter((entry) => entry !== null && typeof entry === "object" && typeof entry.name === "string");
|
|
2006
|
-
}
|
|
2007
|
-
function stripOptions(props) {
|
|
2008
|
-
return props.map((prop) => {
|
|
2009
|
-
const { staticOptions: _options, properties, ...rest } = prop;
|
|
2010
|
-
return properties ? {
|
|
2011
|
-
...rest,
|
|
2012
|
-
properties: stripOptions(properties)
|
|
2013
|
-
} : rest;
|
|
2014
|
-
});
|
|
2015
|
-
}
|
|
2016
|
-
function withSetting(settings, prop, patch) {
|
|
2017
|
-
const list = [...settings ?? []];
|
|
2018
|
-
const index = list.findIndex((setting) => setting.prop === prop);
|
|
2019
|
-
const current = index >= 0 ? list[index] : {
|
|
2020
|
-
prop,
|
|
2021
|
-
mode: "MANUAL"
|
|
2022
|
-
};
|
|
2023
|
-
const next = {
|
|
2024
|
-
prop,
|
|
2025
|
-
mode: patch.mode ?? current.mode,
|
|
2026
|
-
schema: "schema" in patch ? patch.schema ?? null : current.schema ?? null
|
|
2027
|
-
};
|
|
2028
|
-
if (index >= 0) list[index] = next;
|
|
2029
|
-
else list.push(next);
|
|
2030
|
-
return list;
|
|
2031
|
-
}
|
|
2032
|
-
function blockMissing(input) {
|
|
2033
|
-
if (input.skip) return [];
|
|
2034
|
-
const { form } = input;
|
|
2035
|
-
if (!form || form === "loading") return null;
|
|
2036
|
-
const record = asRecord(input.config);
|
|
2037
|
-
const missing = [];
|
|
2038
|
-
let unknown = false;
|
|
2039
|
-
if (form.auth === "required" && !input.connectionId) missing.push("Connection");
|
|
2040
|
-
for (const prop of form.props) {
|
|
2041
|
-
if (prop.type === "MARKDOWN" || !isPropVisible(prop, record)) continue;
|
|
2042
|
-
const value = record[prop.name];
|
|
2043
|
-
const bound = settingFor(input.propertySettings, prop.name)?.mode === "EXPRESSION";
|
|
2044
|
-
if (prop.type !== "DYNAMIC" || bound) {
|
|
2045
|
-
if (prop.required && isEmptyValue(value)) missing.push(prop.displayName);
|
|
2046
|
-
continue;
|
|
2047
|
-
}
|
|
2048
|
-
const children = input.resolveDynamic?.(resolverInputFor(input.block, prop, record, input.connectionId)) ?? storedSchema(input.propertySettings, prop.name);
|
|
2049
|
-
if (children === void 0) {
|
|
2050
|
-
unknown = true;
|
|
2051
|
-
continue;
|
|
2052
|
-
}
|
|
2053
|
-
missing.push(...missingRequired(children, value));
|
|
2054
|
-
}
|
|
2055
|
-
if (missing.length > 0) return missing;
|
|
2056
|
-
if (form.display === "schedule") {
|
|
2057
|
-
const issue = scheduleConfigIssue(input.config);
|
|
2058
|
-
if (issue) return [issue.replace(/^Schedule: /, "")];
|
|
2059
|
-
}
|
|
2060
|
-
return unknown ? null : [];
|
|
2061
|
-
}
|
|
2062
|
-
function undeclaredPortIssues(form, outgoingPorts) {
|
|
2063
|
-
const ports = form && form !== "loading" ? form.ports : void 0;
|
|
2064
|
-
if (!ports || !outgoingPorts) return [];
|
|
2065
|
-
return [...new Set(outgoingPorts)].filter((port) => !ports.includes(port)).map((port) => `An edge leaves on "${port}", which this block never takes`);
|
|
2066
|
-
}
|
|
2067
|
-
function workflowReadiness(blocks, hasTrigger) {
|
|
2068
|
-
const firstIncomplete = blocks.find((block) => block.missing && block.missing.length > 0)?.id ?? null;
|
|
2069
|
-
const checking = blocks.some((block) => block.missing === null);
|
|
2070
|
-
return {
|
|
2071
|
-
ready: hasTrigger && !checking && firstIncomplete === null,
|
|
2072
|
-
hasTrigger,
|
|
2073
|
-
firstIncomplete,
|
|
2074
|
-
checking
|
|
2075
|
-
};
|
|
2076
|
-
}
|
|
2077
|
-
//#endregion
|
|
2078
|
-
//#region editors/workflow-editor/ui/design-time.tsx
|
|
2079
|
-
const DesignTimeContext = createContext(null);
|
|
2080
|
-
function DesignTimeProvider(props) {
|
|
2081
|
-
const { service, queryClient, scope } = props;
|
|
2082
|
-
const value = useMemo(() => ({
|
|
2083
|
-
service,
|
|
2084
|
-
queryClient,
|
|
2085
|
-
scope
|
|
2086
|
-
}), [
|
|
2087
|
-
service,
|
|
2088
|
-
queryClient,
|
|
2089
|
-
scope
|
|
2090
|
-
]);
|
|
2091
|
-
return /* @__PURE__ */ jsx(DesignTimeContext.Provider, {
|
|
2092
|
-
value,
|
|
2093
|
-
children: props.children
|
|
2094
|
-
});
|
|
2095
|
-
}
|
|
2096
|
-
function useDesignTime() {
|
|
2097
|
-
return useContext(DesignTimeContext)?.service;
|
|
2098
|
-
}
|
|
2099
|
-
function useDesignTimeScope() {
|
|
2100
|
-
const context = useContext(DesignTimeContext);
|
|
2101
|
-
const [detached] = useState(() => context ? null : {
|
|
2102
|
-
queryClient: new QueryClient(),
|
|
2103
|
-
scope: ""
|
|
2104
|
-
});
|
|
2105
|
-
return context ?? detached;
|
|
2106
|
-
}
|
|
2107
|
-
function messageOf(error) {
|
|
2108
|
-
return error instanceof Error ? error.message : String(error);
|
|
2109
|
-
}
|
|
2110
|
-
function useBlockForm(block) {
|
|
2111
|
-
const { service, queryClient, scope } = useDesignTimeScope();
|
|
2112
|
-
const query = useQuery({
|
|
2113
|
-
queryKey: runtimeKeys.form(scope, block),
|
|
2114
|
-
queryFn: () => service.getBlockForm(block),
|
|
2115
|
-
enabled: Boolean(service),
|
|
2116
|
-
staleTime: SHARED_STALE_MS
|
|
2117
|
-
}, queryClient);
|
|
2118
|
-
if (!service) return { form: null };
|
|
2119
|
-
if (query.data !== void 0) return { form: query.data };
|
|
2120
|
-
if (query.status === "error") return {
|
|
2121
|
-
form: null,
|
|
2122
|
-
error: messageOf(query.error)
|
|
2123
|
-
};
|
|
2124
|
-
return { form: "loading" };
|
|
2125
|
-
}
|
|
2126
|
-
function formQuery(service, scope, block) {
|
|
2127
|
-
return {
|
|
2128
|
-
queryKey: runtimeKeys.form(scope, block),
|
|
2129
|
-
queryFn: () => service.getBlockForm(block),
|
|
2130
|
-
staleTime: SHARED_STALE_MS
|
|
2131
|
-
};
|
|
2132
|
-
}
|
|
2133
|
-
function useBlockFormLoader() {
|
|
2134
|
-
const { service, queryClient, scope } = useDesignTimeScope();
|
|
2135
|
-
return useMemo(() => async (block) => {
|
|
2136
|
-
if (!service) return null;
|
|
2137
|
-
try {
|
|
2138
|
-
return await queryClient.fetchQuery(formQuery(service, scope, block));
|
|
2139
|
-
} catch {
|
|
2140
|
-
return null;
|
|
2141
|
-
}
|
|
2142
|
-
}, [
|
|
2143
|
-
service,
|
|
2144
|
-
queryClient,
|
|
2145
|
-
scope
|
|
2146
|
-
]);
|
|
2147
|
-
}
|
|
2148
|
-
function useCachedBlockForm() {
|
|
2149
|
-
const { queryClient, scope } = useDesignTimeScope();
|
|
2150
|
-
return useMemo(() => (block) => queryClient.getQueryData(runtimeKeys.form(scope, block)), [queryClient, scope]);
|
|
2151
|
-
}
|
|
2152
|
-
function useBlockFormPrefetch() {
|
|
2153
|
-
const { service, queryClient, scope } = useDesignTimeScope();
|
|
2154
|
-
return useMemo(() => (block) => {
|
|
2155
|
-
if (!service) return;
|
|
2156
|
-
queryClient.prefetchQuery(formQuery(service, scope, block));
|
|
2157
|
-
}, [
|
|
2158
|
-
service,
|
|
2159
|
-
queryClient,
|
|
2160
|
-
scope
|
|
2161
|
-
]);
|
|
2162
|
-
}
|
|
2163
|
-
function useBlockForms(blocks) {
|
|
2164
|
-
const { service, queryClient, scope } = useDesignTimeScope();
|
|
2165
|
-
const unique = [...new Map(blocks.map((block) => [blockRefKey(block), block])).values()];
|
|
2166
|
-
const results = useQueries({ queries: unique.map((block) => ({
|
|
2167
|
-
queryKey: runtimeKeys.form(scope, block),
|
|
2168
|
-
queryFn: () => service.getBlockForm(block),
|
|
2169
|
-
enabled: Boolean(service),
|
|
2170
|
-
staleTime: SHARED_STALE_MS
|
|
2171
|
-
})) }, queryClient);
|
|
2172
|
-
const forms = /* @__PURE__ */ new Map();
|
|
2173
|
-
unique.forEach((block, index) => {
|
|
2174
|
-
const query = results[index];
|
|
2175
|
-
forms.set(blockRefKey(block), !service ? null : query.data !== void 0 ? query.data : query.status === "error" ? null : "loading");
|
|
2176
|
-
});
|
|
2177
|
-
return forms;
|
|
2178
|
-
}
|
|
2179
|
-
function useBlockPorts(blocks) {
|
|
2180
|
-
const forms = useBlockForms(blocks);
|
|
2181
|
-
return (block) => {
|
|
2182
|
-
const form = forms.get(blockRefKey(block));
|
|
2183
|
-
return form && form !== "loading" ? form.ports : void 0;
|
|
2184
|
-
};
|
|
2185
|
-
}
|
|
2186
|
-
function keyHash(value) {
|
|
2187
|
-
try {
|
|
2188
|
-
return JSON.stringify(value);
|
|
2189
|
-
} catch {
|
|
2190
|
-
return String(value);
|
|
2191
|
-
}
|
|
2192
|
-
}
|
|
2193
|
-
function useSettled(value, ms) {
|
|
2194
|
-
const hash = keyHash(value);
|
|
2195
|
-
const latest = useRef(value);
|
|
2196
|
-
useEffect(() => {
|
|
2197
|
-
latest.current = value;
|
|
2198
|
-
});
|
|
2199
|
-
const [settled, setSettled] = useState({
|
|
2200
|
-
hash,
|
|
2201
|
-
value
|
|
2202
|
-
});
|
|
2203
|
-
useEffect(() => {
|
|
2204
|
-
if (hash === settled.hash) return;
|
|
2205
|
-
const timer = setTimeout(() => setSettled({
|
|
2206
|
-
hash,
|
|
2207
|
-
value: latest.current
|
|
2208
|
-
}), ms);
|
|
2209
|
-
return () => clearTimeout(timer);
|
|
2210
|
-
}, [
|
|
2211
|
-
hash,
|
|
2212
|
-
settled.hash,
|
|
2213
|
-
ms
|
|
2214
|
-
]);
|
|
2215
|
-
return settled.value;
|
|
2216
|
-
}
|
|
2217
|
-
function useResolvedProp(options) {
|
|
2218
|
-
const { queryClient, scope } = useDesignTimeScope();
|
|
2219
|
-
const input = useSettled(options.input, options.debounceMs);
|
|
2220
|
-
const loadRef = useRef(options);
|
|
2221
|
-
useEffect(() => {
|
|
2222
|
-
loadRef.current = options;
|
|
2223
|
-
});
|
|
2224
|
-
const enabled = Boolean(options.load);
|
|
2225
|
-
const query = useQuery({
|
|
2226
|
-
queryKey: runtimeKeys[options.kind](scope, input),
|
|
2227
|
-
queryFn: async () => {
|
|
2228
|
-
const current = loadRef.current;
|
|
2229
|
-
if (!current.load) throw new Error("No resolver");
|
|
2230
|
-
return current.parse(await current.load());
|
|
2231
|
-
},
|
|
2232
|
-
enabled,
|
|
2233
|
-
staleTime: RESOLVER_STALE_MS
|
|
2234
|
-
}, queryClient);
|
|
2235
|
-
const reload = () => void query.refetch();
|
|
2236
|
-
if (!enabled) return {
|
|
2237
|
-
state: { kind: "idle" },
|
|
2238
|
-
reload
|
|
2239
|
-
};
|
|
2240
|
-
if (query.isFetching) return {
|
|
2241
|
-
state: { kind: "loading" },
|
|
2242
|
-
reload
|
|
2243
|
-
};
|
|
2244
|
-
if (query.status === "error") return {
|
|
2245
|
-
state: {
|
|
2246
|
-
kind: "error",
|
|
2247
|
-
message: messageOf(query.error)
|
|
2248
|
-
},
|
|
2249
|
-
reload
|
|
2250
|
-
};
|
|
2251
|
-
if (query.status === "success") return {
|
|
2252
|
-
state: {
|
|
2253
|
-
kind: "ready",
|
|
2254
|
-
result: query.data
|
|
2255
|
-
},
|
|
2256
|
-
reload
|
|
2257
|
-
};
|
|
2258
|
-
return {
|
|
2259
|
-
state: { kind: "loading" },
|
|
2260
|
-
reload
|
|
2261
|
-
};
|
|
2262
|
-
}
|
|
2263
|
-
function useOptionSearch(options) {
|
|
2264
|
-
const { queryClient, scope } = useDesignTimeScope();
|
|
2265
|
-
const typed = options.query.trim() === "" ? "" : options.query;
|
|
2266
|
-
const settled = useSettled(typed, options.debounceMs);
|
|
2267
|
-
const loadRef = useRef(options);
|
|
2268
|
-
useEffect(() => {
|
|
2269
|
-
loadRef.current = options;
|
|
2270
|
-
});
|
|
2271
|
-
const query = useQuery({
|
|
2272
|
-
queryKey: runtimeKeys.options(scope, {
|
|
2273
|
-
...options.input,
|
|
2274
|
-
searchValue: settled
|
|
2275
|
-
}),
|
|
2276
|
-
queryFn: async () => {
|
|
2277
|
-
const current = loadRef.current;
|
|
2278
|
-
if (!current.load) throw new Error("No resolver");
|
|
2279
|
-
return current.parse(await current.load(settled));
|
|
2280
|
-
},
|
|
2281
|
-
enabled: Boolean(options.load) && settled !== "" && typed !== "",
|
|
2282
|
-
staleTime: RESOLVER_STALE_MS,
|
|
2283
|
-
placeholderData: keepPreviousData
|
|
2284
|
-
}, queryClient);
|
|
2285
|
-
return typed === "" ? null : query.data ?? null;
|
|
2286
|
-
}
|
|
2287
|
-
function getResolvedDynamicProps(queryClient, scope, input) {
|
|
2288
|
-
return queryClient.getQueryData(runtimeKeys.dynamic(scope, input));
|
|
2289
|
-
}
|
|
2290
|
-
function useDynamicPrefetch() {
|
|
2291
|
-
const { service, queryClient, scope } = useDesignTimeScope();
|
|
2292
|
-
return useMemo(() => (input, config) => {
|
|
2293
|
-
if (!service) return;
|
|
2294
|
-
queryClient.prefetchQuery({
|
|
2295
|
-
queryKey: runtimeKeys.dynamic(scope, input),
|
|
2296
|
-
queryFn: () => service.loadOptions(input.block, input.propName, config, input.connectionId ?? void 0).then(parsePropList),
|
|
2297
|
-
staleTime: RESOLVER_STALE_MS
|
|
2298
|
-
});
|
|
2299
|
-
}, [
|
|
2300
|
-
service,
|
|
2301
|
-
queryClient,
|
|
2302
|
-
scope
|
|
2303
|
-
]);
|
|
2304
|
-
}
|
|
2305
|
-
function useDynamicCache() {
|
|
2306
|
-
const { queryClient, scope } = useDesignTimeScope();
|
|
2307
|
-
return useMemo(() => (input) => getResolvedDynamicProps(queryClient, scope, input), [queryClient, scope]);
|
|
2308
|
-
}
|
|
2309
|
-
function useDynamicLookup() {
|
|
2310
|
-
const { queryClient, scope } = useDesignTimeScope();
|
|
2311
|
-
const [version, setVersion] = useState(0);
|
|
2312
|
-
useEffect(() => queryClient.getQueryCache().subscribe((event) => {
|
|
2313
|
-
if (event.type !== "updated") return;
|
|
2314
|
-
const key = event.query.queryKey;
|
|
2315
|
-
if (key[0] === scope && key[1] === "dynamic") setVersion((v) => v + 1);
|
|
2316
|
-
}), [queryClient, scope]);
|
|
2317
|
-
return useMemo(() => (input) => version >= 0 ? getResolvedDynamicProps(queryClient, scope, input) : void 0, [
|
|
2318
|
-
queryClient,
|
|
2319
|
-
scope,
|
|
2320
|
-
version
|
|
2321
|
-
]);
|
|
2322
|
-
}
|
|
2323
|
-
function useRunById(runId) {
|
|
2324
|
-
const { service, queryClient, scope } = useDesignTimeScope();
|
|
2325
|
-
const fetchRun = service?.fetchRun;
|
|
2326
|
-
const query = useQuery({
|
|
2327
|
-
queryKey: runtimeKeys.run(scope, runId ?? ""),
|
|
2328
|
-
queryFn: () => fetchRun(runId),
|
|
2329
|
-
enabled: Boolean(fetchRun && runId),
|
|
2330
|
-
staleTime: Infinity
|
|
2331
|
-
}, queryClient);
|
|
2332
|
-
if (!runId) return null;
|
|
2333
|
-
return query.data;
|
|
2334
|
-
}
|
|
2335
|
-
function useLatestRun(enabled = true) {
|
|
2336
|
-
const { service, queryClient, scope } = useDesignTimeScope();
|
|
2337
|
-
const active = enabled && Boolean(service?.latestRun);
|
|
2338
|
-
const query = useQuery({
|
|
2339
|
-
queryKey: runtimeKeys.latestRun(scope, service?.workflowId ?? ""),
|
|
2340
|
-
queryFn: () => service.latestRun(),
|
|
2341
|
-
enabled: active,
|
|
2342
|
-
staleTime: 0
|
|
2343
|
-
}, queryClient);
|
|
2344
|
-
if (!active) return null;
|
|
2345
|
-
if (query.status === "pending") return { kind: "loading" };
|
|
2346
|
-
return {
|
|
2347
|
-
kind: "ready",
|
|
2348
|
-
run: query.data ?? null
|
|
2349
|
-
};
|
|
2350
|
-
}
|
|
2351
|
-
const SYNC_RETRIES = 5;
|
|
2352
|
-
const SYNC_RETRY_MS = 2e3;
|
|
2353
|
-
function useWebhookEndpoint(enabled) {
|
|
2354
|
-
const { service, queryClient, scope } = useDesignTimeScope();
|
|
2355
|
-
const active = enabled && Boolean(service?.webhookEndpoint);
|
|
2356
|
-
const query = useQuery({
|
|
2357
|
-
queryKey: runtimeKeys.webhook(scope, service?.workflowId ?? ""),
|
|
2358
|
-
queryFn: () => service.webhookEndpoint(),
|
|
2359
|
-
enabled: active,
|
|
2360
|
-
staleTime: 0,
|
|
2361
|
-
gcTime: 0,
|
|
2362
|
-
retry: (failures, error) => isSyncingError(error) && failures < SYNC_RETRIES,
|
|
2363
|
-
retryDelay: SYNC_RETRY_MS
|
|
2364
|
-
}, queryClient);
|
|
2365
|
-
if (query.status === "pending" && isSyncingError(query.failureReason)) return { kind: "syncing" };
|
|
2366
|
-
if (query.status === "error") return {
|
|
2367
|
-
kind: "error",
|
|
2368
|
-
message: messageOf(query.error)
|
|
2369
|
-
};
|
|
2370
|
-
if (query.status === "pending") return { kind: "loading" };
|
|
2371
|
-
return query.data ? {
|
|
2372
|
-
kind: "ready",
|
|
2373
|
-
endpoint: query.data
|
|
2374
|
-
} : { kind: "empty" };
|
|
2375
|
-
}
|
|
2376
|
-
function useConnectionList() {
|
|
2377
|
-
const { service, queryClient, scope } = useDesignTimeScope();
|
|
2378
|
-
const list = service?.listConnections;
|
|
2379
|
-
const options = {
|
|
2380
|
-
queryKey: runtimeKeys.connections(scope, service?.connectionScope ?? null),
|
|
2381
|
-
queryFn: () => list(),
|
|
2382
|
-
staleTime: 0,
|
|
2383
|
-
gcTime: 0
|
|
2384
|
-
};
|
|
2385
|
-
const query = useQuery({
|
|
2386
|
-
...options,
|
|
2387
|
-
enabled: Boolean(list)
|
|
2388
|
-
}, queryClient);
|
|
2389
|
-
return {
|
|
2390
|
-
connections: query.data ?? [],
|
|
2391
|
-
refetch: () => {
|
|
2392
|
-
if (list) query.refetch();
|
|
2393
|
-
},
|
|
2394
|
-
invalidate: () => void queryClient.invalidateQueries({ queryKey: runtimeKeys.connections(scope) }),
|
|
2395
|
-
fetchNow: () => list ? queryClient.fetchQuery({
|
|
2396
|
-
...options,
|
|
2397
|
-
staleTime: 0
|
|
2398
|
-
}) : Promise.resolve([])
|
|
2399
|
-
};
|
|
2400
|
-
}
|
|
2401
|
-
function useTestStepRunner() {
|
|
2402
|
-
const { service, queryClient, scope } = useDesignTimeScope();
|
|
2403
|
-
const test = service?.testStep;
|
|
2404
|
-
if (!test) return void 0;
|
|
2405
|
-
return (stepId) => test(stepId).finally(() => {
|
|
2406
|
-
for (const queryKey of [
|
|
2407
|
-
runtimeKeys.allRuns(scope),
|
|
2408
|
-
[scope, "latestRun"],
|
|
2409
|
-
runtimeKeys.outputTrees(scope)
|
|
2410
|
-
]) queryClient.invalidateQueries({ queryKey });
|
|
2411
|
-
});
|
|
2412
|
-
}
|
|
2413
|
-
function useTestTrigger() {
|
|
2414
|
-
const { service, queryClient, scope } = useDesignTimeScope();
|
|
2415
|
-
const test = service?.testTrigger;
|
|
2416
|
-
if (!test) return void 0;
|
|
2417
|
-
return () => test().finally(() => void queryClient.invalidateQueries({ queryKey: runtimeKeys.outputTrees(scope) }));
|
|
2418
|
-
}
|
|
2419
|
-
var DraftNotSynced = class extends Error {};
|
|
2420
|
-
const DRAFT_SYNC_RETRIES = 10;
|
|
2421
|
-
/**
|
|
2422
|
-
* The piece version each draft block runs, trigger first; `blocks` is the
|
|
2423
|
-
* draft in that order. Empty outside a runtime, or until the runtime answers.
|
|
2424
|
-
*/
|
|
2425
|
-
function useBlockResolutions(workflowId, blocks) {
|
|
2426
|
-
const { service, queryClient, scope } = useDesignTimeScope();
|
|
2427
|
-
const fetchResolutions = service?.blockResolutions;
|
|
2428
|
-
const expected = blocks.map((entry) => `${entry.id}=${blockRefKey(entry.block)}`);
|
|
2429
|
-
return useQuery({
|
|
2430
|
-
queryKey: runtimeKeys.blockResolutions(scope, workflowId, blocks.map((entry) => entry.block)),
|
|
2431
|
-
queryFn: async () => {
|
|
2432
|
-
const resolutions = await fetchResolutions();
|
|
2433
|
-
if (keyHash(resolutions.map((resolution) => `${resolution.stepId}=${blockRefKey(resolution)}`)) !== keyHash(expected)) throw new DraftNotSynced();
|
|
2434
|
-
return resolutions;
|
|
2435
|
-
},
|
|
2436
|
-
enabled: Boolean(fetchResolutions && workflowId),
|
|
2437
|
-
retry: (count, error) => error instanceof DraftNotSynced && count < DRAFT_SYNC_RETRIES,
|
|
2438
|
-
retryDelay: 300,
|
|
2439
|
-
placeholderData: keepPreviousData,
|
|
2440
|
-
staleTime: 0
|
|
2441
|
-
}, queryClient).data ?? EMPTY_RESOLUTIONS;
|
|
2442
|
-
}
|
|
2443
|
-
const EMPTY_RESOLUTIONS = [];
|
|
2444
|
-
//#endregion
|
|
2445
|
-
//#region editors/workflow-editor/ui/version-badge.tsx
|
|
2446
|
-
function resolutionText(resolution) {
|
|
2447
|
-
if (resolution.note) return resolution.note;
|
|
2448
|
-
if (!resolution.resolvedVersion) return `Nothing resolves ${resolution.pieceName} ${resolution.kind} "${resolution.name}"`;
|
|
2449
|
-
const from = resolution.source ? ` from ${resolution.source}` : "";
|
|
2450
|
-
return `Configured with v${resolution.pieceVersion}, runs v${resolution.resolvedVersion}${from}`;
|
|
2451
|
-
}
|
|
2452
|
-
function runsDifferentVersion(resolution) {
|
|
2453
|
-
switch (resolution.match) {
|
|
2454
|
-
case "exact": return false;
|
|
2455
|
-
case "installed": return resolution.resolvedVersion !== resolution.pieceVersion;
|
|
2456
|
-
default: return true;
|
|
2457
|
-
}
|
|
2458
|
-
}
|
|
2459
|
-
function versionBadge(resolution) {
|
|
2460
|
-
if (!resolution || !runsDifferentVersion(resolution)) return null;
|
|
2461
|
-
const title = resolutionText(resolution);
|
|
2462
|
-
if (resolution.match === "missing") return {
|
|
2463
|
-
tone: "fail",
|
|
2464
|
-
label: "Missing",
|
|
2465
|
-
title
|
|
2466
|
-
};
|
|
2467
|
-
return {
|
|
2468
|
-
tone: resolution.match === "fallback" ? "warn" : "neutral",
|
|
2469
|
-
label: `v${resolution.resolvedVersion}`,
|
|
2470
|
-
title
|
|
2471
|
-
};
|
|
2472
|
-
}
|
|
2473
|
-
/** The newer version to offer, when a source has one above the pin. */
|
|
2474
|
-
function updateVersion(resolution) {
|
|
2475
|
-
const { pieceVersion, latestVersion } = resolution ?? {};
|
|
2476
|
-
if (!pieceVersion || !latestVersion) return null;
|
|
2477
|
-
try {
|
|
2478
|
-
return compareVersions(latestVersion, pieceVersion) > 0 ? latestVersion : null;
|
|
2479
|
-
} catch {
|
|
2480
|
-
return null;
|
|
2481
|
-
}
|
|
2482
|
-
}
|
|
2483
|
-
const ResolutionsContext = createContext([]);
|
|
2484
|
-
const DraftBlocksContext = createContext([]);
|
|
2485
|
-
function BlockResolutionsProvider(props) {
|
|
2486
|
-
return /* @__PURE__ */ jsx(DraftBlocksContext.Provider, {
|
|
2487
|
-
value: props.blocks,
|
|
2488
|
-
children: /* @__PURE__ */ jsx(ResolutionsContext.Provider, {
|
|
2489
|
-
value: props.resolutions,
|
|
2490
|
-
children: props.children
|
|
2491
|
-
})
|
|
2492
|
-
});
|
|
2493
|
-
}
|
|
2494
|
-
function useDraftBlocks() {
|
|
2495
|
-
return useContext(DraftBlocksContext);
|
|
2496
|
-
}
|
|
2497
|
-
function useResolution(id, block) {
|
|
2498
|
-
return useContext(ResolutionsContext).find((entry) => entry.stepId === id && entry.pieceName === block.pieceName && entry.pieceVersion === block.pieceVersion && entry.kind === block.kind && entry.name === block.name);
|
|
2499
|
-
}
|
|
2500
|
-
const SUMMARY_TONE = {
|
|
2501
|
-
neutral: "text-muted-foreground hover:text-foreground",
|
|
2502
|
-
warn: "text-wf-warn"
|
|
2503
|
-
};
|
|
2504
|
-
function versionSummary(resolutions) {
|
|
2505
|
-
const differing = resolutions.filter(runsDifferentVersion);
|
|
2506
|
-
if (differing.length === 0) return null;
|
|
2507
|
-
const missing = differing.filter((entry) => entry.match === "missing");
|
|
2508
|
-
const count = missing.length > 0 ? missing.length : differing.length;
|
|
2509
|
-
const noun = count === 1 ? "step" : "steps";
|
|
2510
|
-
return {
|
|
2511
|
-
text: missing.length > 0 ? `${count} ${noun} can't find ${count === 1 ? "its" : "their"} piece` : `${count} ${noun} ${count === 1 ? "runs" : "run"} a different piece version`,
|
|
2512
|
-
tone: differing.some((entry) => entry.match === "fallback" || entry.match === "missing") ? "warn" : "neutral",
|
|
2513
|
-
title: differing.map(resolutionText).join("\n"),
|
|
2514
|
-
firstStepId: (missing.length > 0 ? missing : differing)[0].stepId
|
|
2515
|
-
};
|
|
2516
|
-
}
|
|
2517
|
-
function VersionSummary(props) {
|
|
2518
|
-
const summary = versionSummary(props.resolutions);
|
|
2519
|
-
if (!summary) return null;
|
|
2520
|
-
return /* @__PURE__ */ jsx("button", {
|
|
2521
|
-
type: "button",
|
|
2522
|
-
"data-tone": summary.tone,
|
|
2523
|
-
className: `truncate text-xs underline-offset-2 hover:underline ${SUMMARY_TONE[summary.tone]}`,
|
|
2524
|
-
title: summary.title,
|
|
2525
|
-
onClick: () => props.onSelect(summary.firstStepId),
|
|
2526
|
-
children: summary.text
|
|
2527
|
-
});
|
|
2528
|
-
}
|
|
2529
|
-
//#endregion
|
|
2530
|
-
//#region editors/workflow-editor/ui/BlockSelector.tsx
|
|
2531
|
-
const ROW_LOGO = 24;
|
|
2532
|
-
const CORE_TILE = {
|
|
2533
|
-
[blockKey(MANUAL_TRIGGER)]: {
|
|
2534
|
-
icon: "play",
|
|
2535
|
-
color: "#2563eb"
|
|
2536
|
-
},
|
|
2537
|
-
[blockKey(SCHEDULE_TRIGGER)]: {
|
|
2538
|
-
icon: "clock",
|
|
2539
|
-
color: "#7c3aed"
|
|
2540
|
-
},
|
|
2541
|
-
[blockKey(WEBHOOK_TRIGGER)]: {
|
|
2542
|
-
icon: "bolt",
|
|
2543
|
-
color: "#0891b2"
|
|
2544
|
-
},
|
|
2545
|
-
[blockKey(BRANCH_BLOCK)]: {
|
|
2546
|
-
icon: "branch",
|
|
2547
|
-
color: "#d97706"
|
|
2548
|
-
},
|
|
2549
|
-
[blockKey(ASSERT_BLOCK)]: {
|
|
2550
|
-
icon: "alert",
|
|
2551
|
-
color: "#dc2626"
|
|
2552
|
-
}
|
|
2553
|
-
};
|
|
2554
|
-
function CoreTile(props) {
|
|
2555
|
-
const tile = props.tile;
|
|
2556
|
-
const glyph = Math.round(props.size * (props.bare ? .9 : .55));
|
|
2557
|
-
if (props.bare) return /* @__PURE__ */ jsx("span", {
|
|
2558
|
-
className: "flex shrink-0 items-center justify-center",
|
|
2559
|
-
style: {
|
|
2560
|
-
width: props.size,
|
|
2561
|
-
height: props.size,
|
|
2562
|
-
color: tile.color
|
|
2563
|
-
},
|
|
2564
|
-
children: /* @__PURE__ */ jsx(Icon, {
|
|
2565
|
-
name: tile.icon,
|
|
2566
|
-
size: glyph
|
|
2567
|
-
})
|
|
2568
|
-
});
|
|
2569
|
-
return /* @__PURE__ */ jsx("span", {
|
|
2570
|
-
className: "flex shrink-0 items-center justify-center rounded-[22%] text-white",
|
|
2571
|
-
style: {
|
|
2572
|
-
width: props.size,
|
|
2573
|
-
height: props.size,
|
|
2574
|
-
backgroundColor: tile.color
|
|
2575
|
-
},
|
|
2576
|
-
children: /* @__PURE__ */ jsx(Icon, {
|
|
2577
|
-
name: tile.icon,
|
|
2578
|
-
size: glyph
|
|
2579
|
-
})
|
|
2580
|
-
});
|
|
2581
|
-
}
|
|
2582
|
-
function BlockLogo(props) {
|
|
2583
|
-
const meta = useBlockMeta(props.block);
|
|
2584
|
-
const tile = CORE_TILE[blockKey(props.block)];
|
|
2585
|
-
if (tile) return /* @__PURE__ */ jsx(CoreTile, {
|
|
2586
|
-
tile,
|
|
2587
|
-
size: props.size ?? 36,
|
|
2588
|
-
bare: props.bare
|
|
2589
|
-
});
|
|
2590
|
-
return /* @__PURE__ */ jsx(LogoFrame, {
|
|
2591
|
-
src: meta.logoUrl,
|
|
2592
|
-
alt: meta.displayName,
|
|
2593
|
-
size: props.size ?? 36,
|
|
2594
|
-
glyph: meta.glyph,
|
|
2595
|
-
bare: props.bare
|
|
2596
|
-
});
|
|
2597
|
-
}
|
|
2598
|
-
function GlyphBadge(props) {
|
|
2599
|
-
return /* @__PURE__ */ jsx("div", {
|
|
2600
|
-
className: "flex shrink-0 items-center justify-center rounded-sm border border-solid border-foreground/10 bg-muted/50 text-muted-foreground",
|
|
2601
|
-
style: {
|
|
2602
|
-
width: props.size,
|
|
2603
|
-
height: props.size,
|
|
2604
|
-
fontSize: props.size / 2
|
|
2605
|
-
},
|
|
2606
|
-
children: props.glyph ?? "?"
|
|
2607
|
-
});
|
|
2608
|
-
}
|
|
2609
|
-
function LogoFrame(props) {
|
|
2610
|
-
const [broken, setBroken] = useState(false);
|
|
2611
|
-
useEffect(() => {
|
|
2612
|
-
setBroken(false);
|
|
2613
|
-
}, [props.src]);
|
|
2614
|
-
if (!props.src || broken) return /* @__PURE__ */ jsx(GlyphBadge, {
|
|
2615
|
-
glyph: props.glyph,
|
|
2616
|
-
size: props.size
|
|
2617
|
-
});
|
|
2618
|
-
return /* @__PURE__ */ jsx("div", {
|
|
2619
|
-
className: `flex shrink-0 items-center justify-center ${props.bare ? "" : "dark:rounded-[22%] dark:bg-white dark:p-[var(--logo-pad)]"}`,
|
|
2620
|
-
style: {
|
|
2621
|
-
width: props.size,
|
|
2622
|
-
height: props.size,
|
|
2623
|
-
"--logo-pad": `${Math.round(props.size * .12)}px`
|
|
2624
|
-
},
|
|
2625
|
-
children: /* @__PURE__ */ jsx("img", {
|
|
2626
|
-
src: props.src,
|
|
2627
|
-
alt: props.alt,
|
|
2628
|
-
className: "h-full w-full object-contain drop-shadow-sm",
|
|
2629
|
-
onError: () => setBroken(true)
|
|
2630
|
-
})
|
|
2631
|
-
});
|
|
2632
|
-
}
|
|
2633
|
-
function Row(props) {
|
|
2634
|
-
return /* @__PURE__ */ jsxs("button", {
|
|
2635
|
-
type: "button",
|
|
2636
|
-
className: `group flex w-full items-center gap-2 px-3 py-1.5 text-left ${props.disabled ? "cursor-not-allowed opacity-50" : "hover:bg-muted/50"}`,
|
|
2637
|
-
disabled: props.disabled,
|
|
2638
|
-
onClick: props.onClick,
|
|
2639
|
-
onMouseEnter: props.onHover,
|
|
2640
|
-
onFocus: props.onHover,
|
|
2641
|
-
children: [
|
|
2642
|
-
props.logo,
|
|
2643
|
-
/* @__PURE__ */ jsxs("span", {
|
|
2644
|
-
className: "min-w-0",
|
|
2645
|
-
children: [/* @__PURE__ */ jsx("span", {
|
|
2646
|
-
className: "block truncate text-xs font-medium text-foreground",
|
|
2647
|
-
children: props.label
|
|
2648
|
-
}), /* @__PURE__ */ jsx("span", {
|
|
2649
|
-
className: "block truncate text-[11px] text-muted-foreground/80",
|
|
2650
|
-
children: props.description
|
|
2651
|
-
})]
|
|
2652
|
-
}),
|
|
2653
|
-
props.version ? /* @__PURE__ */ jsxs("span", {
|
|
2654
|
-
className: `ml-auto shrink-0 pl-2 text-[10px] tabular-nums text-muted-foreground/70 ${props.versionNote ? "" : "hidden group-hover:inline group-focus-visible:inline"}`,
|
|
2655
|
-
title: props.versionNote ?? `Pinned to version ${props.version}`,
|
|
2656
|
-
children: ["v", props.version]
|
|
2657
|
-
}) : null
|
|
2658
|
-
]
|
|
2659
|
-
});
|
|
2660
|
-
}
|
|
2661
|
-
function shownVersion(pieceName, version) {
|
|
2662
|
-
return isCoreBlock({ pieceName }) ? void 0 : version;
|
|
2663
|
-
}
|
|
2664
|
-
function useVersionNote(catalog) {
|
|
2665
|
-
const draft = useDraftBlocks();
|
|
2666
|
-
return (piece, version) => {
|
|
2667
|
-
if (!piece || !version) return void 0;
|
|
2668
|
-
const others = [...new Set(draft.filter((block) => block.pieceName === piece && block.pieceVersion !== version).map((block) => `v${block.pieceVersion}`))];
|
|
2669
|
-
if (others.length > 0) return `Other steps of this workflow use ${others.join(", ")}`;
|
|
2670
|
-
const published = catalog?.find((entry) => entry.name === piece)?.publishedVersion;
|
|
2671
|
-
return published && published !== version ? `A local build; v${published} is published` : void 0;
|
|
2672
|
-
};
|
|
2673
|
-
}
|
|
2674
|
-
function SectionLabel(props) {
|
|
2675
|
-
return /* @__PURE__ */ jsx("div", {
|
|
2676
|
-
className: "px-3 pb-0.5 pt-2 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground/60",
|
|
2677
|
-
children: props.children
|
|
2678
|
-
});
|
|
2679
|
-
}
|
|
2680
|
-
const CATEGORY_LABELS = {
|
|
2681
|
-
ARTIFICIAL_INTELLIGENCE: "AI",
|
|
2682
|
-
UNIVERSAL_AI: "AI",
|
|
2683
|
-
PRODUCTIVITY: "Productivity",
|
|
2684
|
-
MARKETING: "Marketing",
|
|
2685
|
-
COMMUNICATION: "Communication",
|
|
2686
|
-
SALES_AND_CRM: "Sales & CRM",
|
|
2687
|
-
DEVELOPER_TOOLS: "Developer tools",
|
|
2688
|
-
CONTENT_AND_FILES: "Content & files",
|
|
2689
|
-
BUSINESS_INTELLIGENCE: "Business intelligence",
|
|
2690
|
-
CORE: "Utilities",
|
|
2691
|
-
FLOW_CONTROL: "Utilities",
|
|
2692
|
-
COMMERCE: "Commerce",
|
|
2693
|
-
FORMS_AND_SURVEYS: "Forms & surveys",
|
|
2694
|
-
ACCOUNTING: "Accounting",
|
|
2695
|
-
CUSTOMER_SUPPORT: "Customer support",
|
|
2696
|
-
PAYMENT_PROCESSING: "Payments",
|
|
2697
|
-
HUMAN_RESOURCES: "HR"
|
|
2698
|
-
};
|
|
2699
|
-
const CORE_CHIP = "Core";
|
|
2700
|
-
const POWERHOUSE_CHIP = "Powerhouse";
|
|
2701
|
-
const AI_CHIP = "AI";
|
|
2702
|
-
function categoryLabel(id) {
|
|
2703
|
-
return CATEGORY_LABELS[id] ?? id.toLowerCase().replaceAll("_", " ").replace(/^\w/, (char) => char.toUpperCase());
|
|
2704
|
-
}
|
|
2705
|
-
function chipsOf(piece) {
|
|
2706
|
-
return new Set(piece.categories.map(categoryLabel));
|
|
2707
|
-
}
|
|
2708
|
-
function orderChips(pieces) {
|
|
2709
|
-
const counts = /* @__PURE__ */ new Map();
|
|
2710
|
-
for (const piece of pieces) for (const chip of chipsOf(piece)) counts.set(chip, (counts.get(chip) ?? 0) + 1);
|
|
2711
|
-
const rest = [...counts.entries()].filter(([chip]) => chip !== AI_CHIP).sort((a, b) => b[1] - a[1] || a[0].localeCompare(b[0])).map(([chip]) => chip);
|
|
2712
|
-
return [
|
|
2713
|
-
CORE_CHIP,
|
|
2714
|
-
POWERHOUSE_CHIP,
|
|
2715
|
-
...counts.has(AI_CHIP) ? [AI_CHIP] : [],
|
|
2716
|
-
...rest
|
|
2717
|
-
];
|
|
2718
|
-
}
|
|
2719
|
-
function PieceEntries(props) {
|
|
2720
|
-
const [entries, setEntries] = useState(null);
|
|
2721
|
-
const [error, setError] = useState(null);
|
|
2722
|
-
const pieceSource = usePieceSource();
|
|
2723
|
-
useEffect(() => {
|
|
2724
|
-
let cancelled = false;
|
|
2725
|
-
(props.mode === "triggers" ? pieceSource?.loadTriggers(props.piece.name) : pieceSource?.loadActions(props.piece.name))?.then((result) => {
|
|
2726
|
-
if (!cancelled) setEntries(result);
|
|
2727
|
-
}).catch((loadError) => {
|
|
2728
|
-
if (!cancelled) setError(loadError instanceof Error ? loadError.message : String(loadError));
|
|
2729
|
-
});
|
|
2730
|
-
return () => {
|
|
2731
|
-
cancelled = true;
|
|
2732
|
-
};
|
|
2733
|
-
}, [
|
|
2734
|
-
props.piece.name,
|
|
2735
|
-
props.mode,
|
|
2736
|
-
pieceSource
|
|
2737
|
-
]);
|
|
2738
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
2739
|
-
className: "max-h-80 overflow-y-auto py-1",
|
|
2740
|
-
children: [/* @__PURE__ */ jsxs("button", {
|
|
2741
|
-
type: "button",
|
|
2742
|
-
className: "flex w-full items-center gap-1 px-3 py-1 text-[11px] text-muted-foreground/80 hover:text-muted-foreground",
|
|
2743
|
-
onClick: props.onBack,
|
|
2744
|
-
children: ["← ", props.piece.displayName]
|
|
2745
|
-
}), error ? /* @__PURE__ */ jsx("div", {
|
|
2746
|
-
className: "px-3 py-2 text-xs text-wf-fail",
|
|
2747
|
-
children: error
|
|
2748
|
-
}) : entries === null ? /* @__PURE__ */ jsx("div", {
|
|
2749
|
-
className: "px-3 py-2 text-xs text-muted-foreground/80",
|
|
2750
|
-
children: "Loading…"
|
|
2751
|
-
}) : entries.map((entry) => {
|
|
2752
|
-
const kind = props.mode === "triggers" ? "trigger" : "action";
|
|
2753
|
-
const unavailable = blockUnavailable({
|
|
2754
|
-
...entry,
|
|
2755
|
-
kind
|
|
2756
|
-
});
|
|
2757
|
-
const block = {
|
|
2758
|
-
pieceName: entry.pieceName,
|
|
2759
|
-
pieceVersion: entry.pieceVersion,
|
|
2760
|
-
kind,
|
|
2761
|
-
name: entry.name
|
|
2762
|
-
};
|
|
2763
|
-
return /* @__PURE__ */ jsx(Row, {
|
|
2764
|
-
logo: /* @__PURE__ */ jsx(LogoFrame, {
|
|
2765
|
-
src: props.piece.logoUrl,
|
|
2766
|
-
alt: props.piece.displayName,
|
|
2767
|
-
size: ROW_LOGO
|
|
2768
|
-
}),
|
|
2769
|
-
label: entry.displayName,
|
|
2770
|
-
description: unavailable ?? entry.description,
|
|
2771
|
-
disabled: unavailable !== void 0,
|
|
2772
|
-
version: shownVersion(entry.pieceName, entry.pieceVersion),
|
|
2773
|
-
versionNote: props.versionNote(props.piece.name, entry.pieceVersion),
|
|
2774
|
-
onHover: unavailable === void 0 ? () => props.onHover(block) : void 0,
|
|
2775
|
-
onClick: () => props.onPick({
|
|
2776
|
-
label: entry.displayName,
|
|
2777
|
-
block,
|
|
2778
|
-
description: entry.description,
|
|
2779
|
-
defaultConfig: {}
|
|
2780
|
-
})
|
|
2781
|
-
}, entry.name);
|
|
2782
|
-
})]
|
|
2783
|
-
});
|
|
2784
|
-
}
|
|
2785
|
-
const SEARCH_MIN_CHARS = 2;
|
|
2786
|
-
const SEARCH_DEBOUNCE_MS = 250;
|
|
2787
|
-
const INDEXING_RETRY_MS = 2e3;
|
|
2788
|
-
function useBlockSearch(query, enabled) {
|
|
2789
|
-
const [state, setState] = useState({ kind: "idle" });
|
|
2790
|
-
const [attempt, setAttempt] = useState(0);
|
|
2791
|
-
const trimmed = query.trim();
|
|
2792
|
-
const active = enabled && trimmed.length >= SEARCH_MIN_CHARS;
|
|
2793
|
-
const search = usePieceSource()?.searchBlocks;
|
|
2794
|
-
useEffect(() => {
|
|
2795
|
-
if (!active || !search) {
|
|
2796
|
-
setState({ kind: "idle" });
|
|
2797
|
-
return;
|
|
2798
|
-
}
|
|
2799
|
-
let alive = true;
|
|
2800
|
-
let retry;
|
|
2801
|
-
const timer = setTimeout(() => {
|
|
2802
|
-
setState((previous) => previous.kind === "done" ? previous : { kind: "loading" });
|
|
2803
|
-
search(trimmed).then((result) => {
|
|
2804
|
-
if (!alive) return;
|
|
2805
|
-
setState({
|
|
2806
|
-
kind: "done",
|
|
2807
|
-
result
|
|
2808
|
-
});
|
|
2809
|
-
if (result.status === "indexing") retry = setTimeout(() => setAttempt((value) => value + 1), INDEXING_RETRY_MS);
|
|
2810
|
-
}, (error) => {
|
|
2811
|
-
if (alive) setState({
|
|
2812
|
-
kind: "error",
|
|
2813
|
-
message: error instanceof Error ? error.message : String(error)
|
|
2814
|
-
});
|
|
2815
|
-
});
|
|
2816
|
-
}, SEARCH_DEBOUNCE_MS);
|
|
2817
|
-
return () => {
|
|
2818
|
-
alive = false;
|
|
2819
|
-
clearTimeout(timer);
|
|
2820
|
-
if (retry) clearTimeout(retry);
|
|
2821
|
-
};
|
|
2822
|
-
}, [
|
|
2823
|
-
active,
|
|
2824
|
-
trimmed,
|
|
2825
|
-
attempt,
|
|
2826
|
-
search
|
|
2827
|
-
]);
|
|
2828
|
-
return active ? state : { kind: "idle" };
|
|
2829
|
-
}
|
|
2830
|
-
function Chip(props) {
|
|
2831
|
-
return /* @__PURE__ */ jsx("button", {
|
|
2832
|
-
type: "button",
|
|
2833
|
-
className: `rounded-full border px-2 py-0.5 text-[10px] font-medium ${props.active ? "border-primary bg-primary text-primary-foreground" : "border-foreground/10 text-muted-foreground hover:border-foreground/25"}`,
|
|
2834
|
-
onClick: props.onClick,
|
|
2835
|
-
children: props.label
|
|
2836
|
-
});
|
|
2837
|
-
}
|
|
2838
|
-
function BlockSelector(props) {
|
|
2839
|
-
const [query, setQuery] = useState("");
|
|
2840
|
-
const [chip, setChip] = useState(null);
|
|
2841
|
-
const [catalog, setCatalog] = useState(null);
|
|
2842
|
-
const [piece, setPiece] = useState(null);
|
|
2843
|
-
const containerRef = useRef(null);
|
|
2844
|
-
useEffect(() => {
|
|
2845
|
-
const handler = (event) => {
|
|
2846
|
-
if (!containerRef.current?.contains(event.target)) props.onClose();
|
|
2847
|
-
};
|
|
2848
|
-
window.addEventListener("mousedown", handler);
|
|
2849
|
-
return () => window.removeEventListener("mousedown", handler);
|
|
2850
|
-
}, [props]);
|
|
2851
|
-
const anySource = usePieceSource();
|
|
2852
|
-
const pieceSource = props.showPieces ? anySource : void 0;
|
|
2853
|
-
const [catalogRound, setCatalogRound] = useState(0);
|
|
2854
|
-
useEffect(() => {
|
|
2855
|
-
if (!anySource) return;
|
|
2856
|
-
let cancelled = false;
|
|
2857
|
-
let timer;
|
|
2858
|
-
const load = (attempt) => {
|
|
2859
|
-
(attempt > 0 && anySource.reloadCatalog ? anySource.reloadCatalog() : anySource.loadCatalog()).then((pieces) => {
|
|
2860
|
-
registerPieceLogos(pieces);
|
|
2861
|
-
if (!cancelled) setCatalog({ pieces });
|
|
2862
|
-
}).catch((error) => {
|
|
2863
|
-
if (cancelled) return;
|
|
2864
|
-
if (attempt + 1 < 5) {
|
|
2865
|
-
timer = setTimeout(() => load(attempt + 1), CATALOG_RETRY_MS * 2 ** attempt);
|
|
2866
|
-
return;
|
|
2867
|
-
}
|
|
2868
|
-
setCatalog({
|
|
2869
|
-
pieces: [],
|
|
2870
|
-
error: error instanceof Error ? error.message : String(error)
|
|
2871
|
-
});
|
|
2872
|
-
});
|
|
2873
|
-
};
|
|
2874
|
-
load(catalogRound > 0 ? 1 : 0);
|
|
2875
|
-
return () => {
|
|
2876
|
-
cancelled = true;
|
|
2877
|
-
clearTimeout(timer);
|
|
2878
|
-
};
|
|
2879
|
-
}, [anySource, catalogRound]);
|
|
2880
|
-
const installed = (name) => catalog?.pieces.find((entry) => entry.name === name)?.version;
|
|
2881
|
-
const versionNote = useVersionNote(catalog?.pieces);
|
|
2882
|
-
const pinned = (preset) => pinBlock(preset.block, installed);
|
|
2883
|
-
const pick = (preset) => {
|
|
2884
|
-
const block = pinned(preset);
|
|
2885
|
-
if (block) props.onPick({
|
|
2886
|
-
...preset,
|
|
2887
|
-
block
|
|
2888
|
-
});
|
|
2889
|
-
};
|
|
2890
|
-
const prefetch = useBlockFormPrefetch();
|
|
2891
|
-
const mode = props.pieceMode ?? "actions";
|
|
2892
|
-
const lowered = query.toLowerCase();
|
|
2893
|
-
const modePieces = useMemo(() => (catalog?.pieces ?? []).filter((entry) => (mode === "triggers" ? entry.triggerCount : entry.actionCount) > 0), [catalog, mode]);
|
|
2894
|
-
const chips = useMemo(() => orderChips(modePieces), [modePieces]);
|
|
2895
|
-
const chipsByPiece = useMemo(() => new Map(modePieces.map((entry) => [entry.name, chipsOf(entry)])), [modePieces]);
|
|
2896
|
-
const inChip = (pieceName) => chip === null || chip === "Core" ? true : chipsByPiece.get(pieceName)?.has(chip) ?? false;
|
|
2897
|
-
const showCatalog = pieceSource !== void 0 && !(chip === "Core" || chip === "Powerhouse");
|
|
2898
|
-
const matching = props.presets.filter((preset) => `${preset.label} ${preset.block.pieceName} ${preset.block.name}`.toLowerCase().includes(lowered));
|
|
2899
|
-
const corePresets = chip === null || chip === "Core" ? matching.filter((preset) => preset.group !== "powerhouse") : [];
|
|
2900
|
-
const powerhousePresets = chip === null || chip === "Powerhouse" ? matching.filter((preset) => preset.group === "powerhouse") : [];
|
|
2901
|
-
const filteredAttach = (props.onAttach ? props.attachSteps ?? [] : []).filter((step) => `${step.name} ${step.key} ${step.pieceName} ${step.actionName}`.toLowerCase().includes(lowered));
|
|
2902
|
-
const filteredPieces = showCatalog ? modePieces.filter((entry) => inChip(entry.name) && `${entry.displayName} ${entry.name} ${entry.description}`.toLowerCase().includes(lowered)) : [];
|
|
2903
|
-
const search = useBlockSearch(query, showCatalog && !piece);
|
|
2904
|
-
const presetRow = (preset) => {
|
|
2905
|
-
const block = pinned(preset);
|
|
2906
|
-
return /* @__PURE__ */ jsx(Row, {
|
|
2907
|
-
logo: /* @__PURE__ */ jsx(BlockLogo, {
|
|
2908
|
-
block: preset.block,
|
|
2909
|
-
size: ROW_LOGO
|
|
2910
|
-
}),
|
|
2911
|
-
label: preset.label,
|
|
2912
|
-
description: block ? preset.description : catalog === null ? "Loading…" : "Not installed on this runtime",
|
|
2913
|
-
disabled: !block,
|
|
2914
|
-
version: shownVersion(preset.block.pieceName, block?.pieceVersion),
|
|
2915
|
-
versionNote: versionNote(preset.block.pieceName, block?.pieceVersion),
|
|
2916
|
-
onHover: block ? () => prefetch(block) : void 0,
|
|
2917
|
-
onClick: () => pick(preset)
|
|
2918
|
-
}, blockKey(preset.block) + preset.label);
|
|
2919
|
-
};
|
|
2920
|
-
const labelPresets = showCatalog || filteredAttach.length > 0 || corePresets.length > 0 && powerhousePresets.length > 0;
|
|
2921
|
-
const wantedKind = mode === "triggers" ? "trigger" : "action";
|
|
2922
|
-
const hits = search.kind === "done" ? search.result.hits.filter((hit) => hit.kind === wantedKind && inChip(hit.pieceName)) : [];
|
|
2923
|
-
const searchActive = search.kind !== "idle";
|
|
2924
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
2925
|
-
ref: containerRef,
|
|
2926
|
-
className: "nodrag nopan nowheel w-80 rounded-md border border-solid border-foreground/10 bg-card shadow-lg",
|
|
2927
|
-
onClick: (event) => event.stopPropagation(),
|
|
2928
|
-
children: [/* @__PURE__ */ jsxs("div", {
|
|
2929
|
-
className: "border-b border-foreground/10 p-2",
|
|
2930
|
-
children: [/* @__PURE__ */ jsx("div", {
|
|
2931
|
-
className: "mb-1 px-1 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground/80",
|
|
2932
|
-
children: props.title
|
|
2933
|
-
}), piece ? null : /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("input", {
|
|
2934
|
-
autoFocus: true,
|
|
2935
|
-
className: "w-full rounded border border-foreground/10 px-2 py-1 text-xs",
|
|
2936
|
-
placeholder: pieceSource ? "Search pieces, actions, triggers…" : "Search…",
|
|
2937
|
-
value: query,
|
|
2938
|
-
onChange: (event) => setQuery(event.target.value)
|
|
2939
|
-
}), pieceSource && catalog && !catalog.error ? /* @__PURE__ */ jsx("div", {
|
|
2940
|
-
className: "mt-1.5 flex flex-wrap gap-1 px-0.5",
|
|
2941
|
-
children: chips.map((label) => /* @__PURE__ */ jsx(Chip, {
|
|
2942
|
-
label,
|
|
2943
|
-
active: chip === label,
|
|
2944
|
-
onClick: () => setChip(chip === label ? null : label)
|
|
2945
|
-
}, label))
|
|
2946
|
-
}) : null] })]
|
|
2947
|
-
}), piece ? /* @__PURE__ */ jsx(PieceEntries, {
|
|
2948
|
-
piece,
|
|
2949
|
-
mode,
|
|
2950
|
-
onPick: pick,
|
|
2951
|
-
onHover: prefetch,
|
|
2952
|
-
onBack: () => setPiece(null),
|
|
2953
|
-
versionNote
|
|
2954
|
-
}) : /* @__PURE__ */ jsxs("div", {
|
|
2955
|
-
className: "max-h-80 overflow-y-auto py-1",
|
|
2956
|
-
children: [
|
|
2957
|
-
filteredAttach.length > 0 ? /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(SectionLabel, { children: "Attach existing step" }), filteredAttach.map((step) => /* @__PURE__ */ jsx(Row, {
|
|
2958
|
-
logo: /* @__PURE__ */ jsx(BlockLogo, {
|
|
2959
|
-
block: stepBlock(step),
|
|
2960
|
-
size: ROW_LOGO
|
|
2961
|
-
}),
|
|
2962
|
-
label: step.name,
|
|
2963
|
-
description: `{{steps.${step.key}}} · detached`,
|
|
2964
|
-
onClick: () => props.onAttach?.(step.id)
|
|
2965
|
-
}, step.id))] }) : null,
|
|
2966
|
-
corePresets.length > 0 && labelPresets ? /* @__PURE__ */ jsx(SectionLabel, { children: "Core" }) : null,
|
|
2967
|
-
corePresets.map(presetRow),
|
|
2968
|
-
powerhousePresets.length > 0 && labelPresets ? /* @__PURE__ */ jsx(SectionLabel, { children: "Powerhouse" }) : null,
|
|
2969
|
-
powerhousePresets.map(presetRow),
|
|
2970
|
-
searchActive ? /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(SectionLabel, { children: mode === "triggers" ? "Triggers" : "Actions & triggers" }), search.kind === "loading" ? /* @__PURE__ */ jsx("div", {
|
|
2971
|
-
className: "px-3 py-1 text-xs text-muted-foreground/80",
|
|
2972
|
-
children: "Searching…"
|
|
2973
|
-
}) : search.kind === "error" ? /* @__PURE__ */ jsx("div", {
|
|
2974
|
-
className: "px-3 py-1 text-xs text-wf-fail",
|
|
2975
|
-
children: search.message
|
|
2976
|
-
}) : /* @__PURE__ */ jsxs(Fragment$1, { children: [hits.map((hit) => {
|
|
2977
|
-
const unavailable = blockUnavailable(hit);
|
|
2978
|
-
const block = {
|
|
2979
|
-
pieceName: hit.pieceName,
|
|
2980
|
-
pieceVersion: hit.pieceVersion,
|
|
2981
|
-
kind: hit.kind,
|
|
2982
|
-
name: hit.name
|
|
2983
|
-
};
|
|
2984
|
-
return /* @__PURE__ */ jsx(Row, {
|
|
2985
|
-
logo: /* @__PURE__ */ jsx(LogoFrame, {
|
|
2986
|
-
src: hit.logoUrl,
|
|
2987
|
-
alt: hit.pieceDisplayName,
|
|
2988
|
-
size: ROW_LOGO
|
|
2989
|
-
}),
|
|
2990
|
-
label: `${hit.displayName} · ${hit.pieceDisplayName}`,
|
|
2991
|
-
description: unavailable ?? (hit.description || hit.pieceDisplayName),
|
|
2992
|
-
disabled: unavailable !== void 0,
|
|
2993
|
-
version: shownVersion(hit.pieceName, hit.pieceVersion),
|
|
2994
|
-
versionNote: versionNote(hit.pieceName, hit.pieceVersion),
|
|
2995
|
-
onHover: unavailable === void 0 ? () => prefetch(block) : void 0,
|
|
2996
|
-
onClick: () => pick({
|
|
2997
|
-
label: hit.displayName,
|
|
2998
|
-
block,
|
|
2999
|
-
description: hit.description,
|
|
3000
|
-
defaultConfig: {}
|
|
3001
|
-
})
|
|
3002
|
-
}, blockKey(block));
|
|
3003
|
-
}), search.result.status === "indexing" ? /* @__PURE__ */ jsx("div", {
|
|
3004
|
-
className: "px-3 py-1 text-xs text-muted-foreground/80",
|
|
3005
|
-
children: "Indexing the catalog… more results appear shortly."
|
|
3006
|
-
}) : search.result.status === "error" ? /* @__PURE__ */ jsx("div", {
|
|
3007
|
-
className: "px-3 py-1 text-xs text-wf-fail",
|
|
3008
|
-
children: search.result.error ?? "Search failed"
|
|
3009
|
-
}) : hits.length === 0 ? /* @__PURE__ */ jsxs("div", {
|
|
3010
|
-
className: "px-3 py-1 text-xs text-muted-foreground/80",
|
|
3011
|
-
children: [
|
|
3012
|
-
"No matching ",
|
|
3013
|
-
wantedKind,
|
|
3014
|
-
"s"
|
|
3015
|
-
]
|
|
3016
|
-
}) : null] })] }) : null,
|
|
3017
|
-
showCatalog ? /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(SectionLabel, { children: "Pieces" }), catalog === null ? /* @__PURE__ */ jsx("div", {
|
|
3018
|
-
className: "px-3 py-2 text-xs text-muted-foreground/80",
|
|
3019
|
-
children: "Loading catalog…"
|
|
3020
|
-
}) : catalog.error ? /* @__PURE__ */ jsxs("div", {
|
|
3021
|
-
className: "flex items-center gap-2 px-3 py-2 text-xs text-wf-fail",
|
|
3022
|
-
children: [/* @__PURE__ */ jsx("span", {
|
|
3023
|
-
className: "min-w-0 flex-1",
|
|
3024
|
-
children: catalog.error
|
|
3025
|
-
}), /* @__PURE__ */ jsx("button", {
|
|
3026
|
-
type: "button",
|
|
3027
|
-
className: "shrink-0 cursor-pointer rounded border border-solid border-foreground/15 bg-card px-1.5 py-0.5 text-foreground hover:border-foreground/25",
|
|
3028
|
-
onClick: () => {
|
|
3029
|
-
setCatalog(null);
|
|
3030
|
-
setCatalogRound((round) => round + 1);
|
|
3031
|
-
},
|
|
3032
|
-
children: "Retry"
|
|
3033
|
-
})]
|
|
3034
|
-
}) : filteredPieces.map((entry) => /* @__PURE__ */ jsx(Row, {
|
|
3035
|
-
logo: /* @__PURE__ */ jsx(LogoFrame, {
|
|
3036
|
-
src: entry.logoUrl,
|
|
3037
|
-
alt: entry.displayName,
|
|
3038
|
-
size: ROW_LOGO
|
|
3039
|
-
}),
|
|
3040
|
-
label: entry.deprecated ? `${entry.displayName} (deprecated)` : entry.displayName,
|
|
3041
|
-
description: entry.unsupported ?? (mode === "triggers" ? `${entry.triggerCount} trigger${entry.triggerCount === 1 ? "" : "s"} · ${entry.description}` : `${entry.actionCount} action${entry.actionCount === 1 ? "" : "s"} · ${entry.description}`),
|
|
3042
|
-
version: shownVersion(entry.name, entry.version),
|
|
3043
|
-
versionNote: versionNote(entry.name, entry.version),
|
|
3044
|
-
onClick: () => setPiece(entry)
|
|
3045
|
-
}, entry.name))] }) : null,
|
|
3046
|
-
corePresets.length + powerhousePresets.length === 0 && filteredPieces.length === 0 && filteredAttach.length === 0 && !searchActive ? /* @__PURE__ */ jsx("div", {
|
|
3047
|
-
className: "px-3 py-2 text-xs text-muted-foreground/80",
|
|
3048
|
-
children: "No matches"
|
|
3049
|
-
}) : null
|
|
3050
|
-
]
|
|
3051
|
-
})]
|
|
3052
|
-
});
|
|
3053
|
-
}
|
|
3054
|
-
//#endregion
|
|
3055
|
-
export { formatDuration as $, isEmptyValue as A, Tooltip as At, blockMeta as B, useOptionSearch as C, Hint as Ct, useTestTrigger as D, Switch as Dt, useTestStepRunner as E, Select as Et, storedSchema as F, isIconName as Ft, CONNECTION_TONE as G, pieceLogo as H, stripOptions as I, DocumentErrorBoundary as It, STEP_TONE as J, RUN_STATUSES as K, undeclaredPortIssues as L, DocumentLoadError as Lt, parsePropList as M, textAreaClass as Mt, resolverInputFor as N, textInputClass as Nt, useWebhookEndpoint as O, Tabs as Ot, settingFor as P, Icon as Pt, formatAbsolute as Q, withSetting as R, errorMessage as Rt, useLatestRun as S, FieldLabel as St, useRunById as T, Segmented as Tt, useBlockMeta as U, pieceDisplayName as V, usePieceLogos as W, TONE_TEXT as X, TONE_DOT as Y, durationMs as Z, useConnectionList as _, useRuntime as _t, resolutionText as a, runTimeline as at, useDynamicLookup as b, Button as bt, useResolution as c, toneOf as ct, useBlockForm as d, useOAuthAttempt as dt, formatMs as et, useBlockFormLoader as f, useOAuthRedirectUri as ft, useCachedBlockForm as g, useRunsQuery as gt, useBlockResolutions as h, useRunQuery as ht, VersionSummary as i, runStatusLabel as it, isPropVisible as j, invalidClass as jt, blockMissing as k, Toggle as kt, versionBadge as l, workflowHealth as lt, useBlockPorts as m, useRunPagesQuery as mt, BlockSelector as n, formatWhen as nt, runsDifferentVersion as o, runTone as ot, useBlockForms as p, usePieceCatalog as pt, RUN_TONE as q, BlockResolutionsProvider as r, runStats as rt, updateVersion as s, statusLabel as st, BlockLogo as t, formatTrigger as tt, DesignTimeProvider as u, WorkflowRuntimeProvider as ut, useDesignTime as v, useRuntimeActions as vt, useResolvedProp as w, IconButton as wt, useDynamicPrefetch as x, FieldError as xt, useDynamicCache as y, useSecretStat as yt, workflowReadiness as z };
|
|
3056
|
-
|
|
3057
|
-
//# sourceMappingURL=BlockSelector-C3XYZfPY.mjs.map
|