nvent 0.4.4 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/module.d.mts +4 -185
- package/dist/module.json +3 -3
- package/dist/module.mjs +451 -257
- package/dist/runtime/adapters/base/index.d.ts +6 -0
- package/dist/runtime/adapters/base/index.js +1 -0
- package/dist/runtime/adapters/base/store-validator.d.ts +48 -0
- package/dist/runtime/adapters/base/store-validator.js +147 -0
- package/dist/runtime/adapters/builtin/file-queue.d.ts +67 -0
- package/dist/runtime/adapters/builtin/file-queue.js +499 -0
- package/dist/runtime/adapters/builtin/file-store.d.ts +32 -0
- package/dist/runtime/adapters/builtin/file-store.js +206 -0
- package/dist/runtime/adapters/builtin/file-stream.d.ts +39 -0
- package/dist/runtime/adapters/builtin/file-stream.js +56 -0
- package/dist/runtime/adapters/builtin/index.d.ts +10 -0
- package/dist/runtime/adapters/builtin/index.js +5 -0
- package/dist/runtime/adapters/builtin/memory-queue.d.ts +52 -0
- package/dist/runtime/adapters/builtin/memory-queue.js +243 -0
- package/dist/runtime/adapters/builtin/memory-store.d.ts +68 -0
- package/dist/runtime/adapters/builtin/memory-store.js +333 -0
- package/dist/runtime/adapters/builtin/memory-stream.d.ts +21 -0
- package/dist/runtime/adapters/builtin/memory-stream.js +56 -0
- package/dist/runtime/adapters/factory.d.ts +31 -0
- package/dist/runtime/adapters/factory.js +134 -0
- package/dist/runtime/adapters/index.d.ts +8 -0
- package/dist/runtime/adapters/index.js +3 -0
- package/dist/runtime/adapters/interfaces/index.d.ts +11 -0
- package/dist/runtime/adapters/interfaces/index.js +3 -0
- package/dist/runtime/adapters/interfaces/queue.d.ts +150 -0
- package/dist/runtime/adapters/interfaces/store.d.ts +297 -0
- package/dist/runtime/adapters/interfaces/stream.d.ts +62 -0
- package/dist/runtime/adapters/registry.d.ts +85 -0
- package/dist/runtime/adapters/registry.js +161 -0
- package/dist/runtime/config/index.d.ts +29 -0
- package/dist/runtime/config/index.js +175 -0
- package/dist/runtime/config/types.d.ts +397 -0
- package/dist/runtime/config/types.js +0 -0
- package/dist/runtime/{server-utils/events → events}/eventBus.d.ts +1 -1
- package/dist/runtime/events/types.d.ts +145 -0
- package/dist/runtime/events/types.js +0 -0
- package/dist/runtime/events/utils/scheduleTrigger.d.ts +8 -0
- package/dist/runtime/events/utils/scheduleTrigger.js +69 -0
- package/dist/runtime/events/utils/stallDetector.d.ts +140 -0
- package/dist/runtime/events/utils/stallDetector.js +436 -0
- package/dist/runtime/events/utils/triggerRuntime.d.ts +58 -0
- package/dist/runtime/events/utils/triggerRuntime.js +212 -0
- package/dist/runtime/{server-utils/events → events}/wiring/flowWiring.d.ts +12 -11
- package/dist/runtime/events/wiring/flowWiring.js +1020 -0
- package/dist/runtime/events/wiring/registry.d.ts +19 -0
- package/dist/runtime/events/wiring/registry.js +35 -0
- package/dist/runtime/events/wiring/stateWiring.d.ts +37 -0
- package/dist/runtime/events/wiring/stateWiring.js +92 -0
- package/dist/runtime/events/wiring/streamWiring.d.ts +36 -0
- package/dist/runtime/events/wiring/streamWiring.js +156 -0
- package/dist/runtime/events/wiring/triggerWiring.d.ts +21 -0
- package/dist/runtime/events/wiring/triggerWiring.js +412 -0
- package/dist/runtime/nitro/plugins/00.adapters.d.ts +14 -0
- package/dist/runtime/nitro/plugins/00.adapters.js +73 -0
- package/dist/runtime/nitro/plugins/02.workers.js +63 -0
- package/dist/runtime/nitro/plugins/03.triggers.d.ts +12 -0
- package/dist/runtime/nitro/plugins/03.triggers.js +55 -0
- package/dist/runtime/nitro/routes/webhook.await.d.ts +23 -0
- package/dist/runtime/nitro/routes/webhook.await.js +90 -0
- package/dist/runtime/nitro/routes/webhook.trigger.d.ts +69 -0
- package/dist/runtime/nitro/routes/webhook.trigger.js +64 -0
- package/dist/runtime/nitro/utils/adapters.d.ts +66 -0
- package/dist/runtime/nitro/utils/adapters.js +51 -0
- package/dist/runtime/nitro/utils/awaitPatterns/event.d.ts +15 -0
- package/dist/runtime/nitro/utils/awaitPatterns/event.js +120 -0
- package/dist/runtime/nitro/utils/awaitPatterns/index.d.ts +28 -0
- package/dist/runtime/nitro/utils/awaitPatterns/index.js +55 -0
- package/dist/runtime/nitro/utils/awaitPatterns/schedule.d.ts +16 -0
- package/dist/runtime/nitro/utils/awaitPatterns/schedule.js +78 -0
- package/dist/runtime/nitro/utils/awaitPatterns/time.d.ts +15 -0
- package/dist/runtime/nitro/utils/awaitPatterns/time.js +67 -0
- package/dist/runtime/nitro/utils/awaitPatterns/webhook.d.ts +15 -0
- package/dist/runtime/nitro/utils/awaitPatterns/webhook.js +120 -0
- package/dist/runtime/nitro/utils/defineFunction.d.ts +10 -0
- package/dist/runtime/nitro/utils/defineFunction.js +17 -0
- package/dist/runtime/nitro/utils/defineFunctionConfig.d.ts +310 -0
- package/dist/runtime/nitro/utils/defineFunctionConfig.js +3 -0
- package/dist/runtime/nitro/utils/defineHooks.d.ts +41 -0
- package/dist/runtime/nitro/utils/defineHooks.js +6 -0
- package/dist/runtime/nitro/utils/registerAdapter.d.ts +59 -0
- package/dist/runtime/nitro/utils/registerAdapter.js +13 -0
- package/dist/runtime/nitro/utils/useAwait.d.ts +71 -0
- package/dist/runtime/nitro/utils/useAwait.js +139 -0
- package/dist/runtime/{server-utils → nitro}/utils/useEventManager.d.ts +2 -2
- package/dist/runtime/{server-utils → nitro}/utils/useEventManager.js +1 -1
- package/dist/runtime/nitro/utils/useFlow.d.ts +68 -0
- package/dist/runtime/nitro/utils/useFlow.js +226 -0
- package/dist/runtime/nitro/utils/useHookRegistry.d.ts +34 -0
- package/dist/runtime/nitro/utils/useHookRegistry.js +25 -0
- package/dist/runtime/{server-utils → nitro}/utils/useNventLogger.js +2 -2
- package/dist/runtime/nitro/utils/useRunContext.d.ts +6 -0
- package/dist/runtime/nitro/utils/useRunContext.js +102 -0
- package/dist/runtime/nitro/utils/useStreamTopics.d.ts +83 -0
- package/dist/runtime/nitro/utils/useStreamTopics.js +94 -0
- package/dist/runtime/nitro/utils/useTrigger.d.ts +150 -0
- package/dist/runtime/nitro/utils/useTrigger.js +320 -0
- package/dist/runtime/scheduler/index.d.ts +33 -0
- package/dist/runtime/scheduler/index.js +38 -0
- package/dist/runtime/scheduler/scheduler.d.ts +113 -0
- package/dist/runtime/scheduler/scheduler.js +623 -0
- package/dist/runtime/scheduler/types.d.ts +116 -0
- package/dist/runtime/scheduler/types.js +0 -0
- package/dist/runtime/tsconfig.json +8 -0
- package/dist/runtime/worker/node/runner.d.ts +53 -0
- package/dist/runtime/worker/node/runner.js +327 -0
- package/dist/types.d.mts +2 -2
- package/package.json +16 -46
- package/LICENSE +0 -21
- package/README.md +0 -389
- package/dist/runtime/app/assets/vueflow.css +0 -1
- package/dist/runtime/app/components/ConfirmDialog.d.vue.ts +0 -33
- package/dist/runtime/app/components/ConfirmDialog.vue +0 -121
- package/dist/runtime/app/components/ConfirmDialog.vue.d.ts +0 -33
- package/dist/runtime/app/components/FlowDiagram.d.vue.ts +0 -64
- package/dist/runtime/app/components/FlowDiagram.vue +0 -338
- package/dist/runtime/app/components/FlowDiagram.vue.d.ts +0 -64
- package/dist/runtime/app/components/FlowNodeCard.d.vue.ts +0 -29
- package/dist/runtime/app/components/FlowNodeCard.vue +0 -156
- package/dist/runtime/app/components/FlowNodeCard.vue.d.ts +0 -29
- package/dist/runtime/app/components/FlowRunOverview.d.vue.ts +0 -9
- package/dist/runtime/app/components/FlowRunOverview.vue +0 -291
- package/dist/runtime/app/components/FlowRunOverview.vue.d.ts +0 -9
- package/dist/runtime/app/components/FlowRunStatusBadge.d.vue.ts +0 -14
- package/dist/runtime/app/components/FlowRunStatusBadge.vue +0 -60
- package/dist/runtime/app/components/FlowRunStatusBadge.vue.d.ts +0 -14
- package/dist/runtime/app/components/FlowRunTimeline.d.vue.ts +0 -12
- package/dist/runtime/app/components/FlowRunTimeline.vue +0 -127
- package/dist/runtime/app/components/FlowRunTimeline.vue.d.ts +0 -12
- package/dist/runtime/app/components/FlowScheduleDialog.d.vue.ts +0 -16
- package/dist/runtime/app/components/FlowScheduleDialog.vue +0 -226
- package/dist/runtime/app/components/FlowScheduleDialog.vue.d.ts +0 -16
- package/dist/runtime/app/components/FlowSchedulesList.d.vue.ts +0 -12
- package/dist/runtime/app/components/FlowSchedulesList.vue +0 -99
- package/dist/runtime/app/components/FlowSchedulesList.vue.d.ts +0 -12
- package/dist/runtime/app/components/JobScheduling.d.vue.ts +0 -6
- package/dist/runtime/app/components/JobScheduling.vue +0 -203
- package/dist/runtime/app/components/JobScheduling.vue.d.ts +0 -6
- package/dist/runtime/app/components/ListItem.d.vue.ts +0 -23
- package/dist/runtime/app/components/ListItem.vue +0 -70
- package/dist/runtime/app/components/ListItem.vue.d.ts +0 -23
- package/dist/runtime/app/components/QueueConfigDetails.d.vue.ts +0 -45
- package/dist/runtime/app/components/QueueConfigDetails.vue +0 -412
- package/dist/runtime/app/components/QueueConfigDetails.vue.d.ts +0 -45
- package/dist/runtime/app/components/StatCounter.d.vue.ts +0 -9
- package/dist/runtime/app/components/StatCounter.vue +0 -25
- package/dist/runtime/app/components/StatCounter.vue.d.ts +0 -9
- package/dist/runtime/app/components/TimelineList.d.vue.ts +0 -7
- package/dist/runtime/app/components/TimelineList.vue +0 -210
- package/dist/runtime/app/components/TimelineList.vue.d.ts +0 -7
- package/dist/runtime/app/components/nhealth/component-router.d.vue.ts +0 -46
- package/dist/runtime/app/components/nhealth/component-router.vue +0 -26
- package/dist/runtime/app/components/nhealth/component-router.vue.d.ts +0 -46
- package/dist/runtime/app/components/nhealth/component-shell.d.vue.ts +0 -24
- package/dist/runtime/app/components/nhealth/component-shell.vue +0 -89
- package/dist/runtime/app/components/nhealth/component-shell.vue.d.ts +0 -24
- package/dist/runtime/app/composables/useAnalyzedFlows.d.ts +0 -14
- package/dist/runtime/app/composables/useAnalyzedFlows.js +0 -8
- package/dist/runtime/app/composables/useComponentRouter.d.ts +0 -38
- package/dist/runtime/app/composables/useComponentRouter.js +0 -240
- package/dist/runtime/app/composables/useFlowRunTimeline.d.ts +0 -80
- package/dist/runtime/app/composables/useFlowRunTimeline.js +0 -68
- package/dist/runtime/app/composables/useFlowRuns.d.ts +0 -18
- package/dist/runtime/app/composables/useFlowRuns.js +0 -32
- package/dist/runtime/app/composables/useFlowRunsInfinite.d.ts +0 -24
- package/dist/runtime/app/composables/useFlowRunsInfinite.js +0 -123
- package/dist/runtime/app/composables/useFlowRunsPolling.d.ts +0 -9
- package/dist/runtime/app/composables/useFlowRunsPolling.js +0 -33
- package/dist/runtime/app/composables/useFlowState.d.ts +0 -125
- package/dist/runtime/app/composables/useFlowState.js +0 -211
- package/dist/runtime/app/composables/useFlowWebSocket.d.ts +0 -27
- package/dist/runtime/app/composables/useFlowWebSocket.js +0 -205
- package/dist/runtime/app/composables/useFlowsNavigation.d.ts +0 -10
- package/dist/runtime/app/composables/useFlowsNavigation.js +0 -58
- package/dist/runtime/app/composables/useQueueJobs.d.ts +0 -26
- package/dist/runtime/app/composables/useQueueJobs.js +0 -20
- package/dist/runtime/app/composables/useQueueUpdates.d.ts +0 -26
- package/dist/runtime/app/composables/useQueueUpdates.js +0 -122
- package/dist/runtime/app/composables/useQueues.d.ts +0 -45
- package/dist/runtime/app/composables/useQueues.js +0 -26
- package/dist/runtime/app/composables/useQueuesLive.d.ts +0 -19
- package/dist/runtime/app/composables/useQueuesLive.js +0 -143
- package/dist/runtime/app/pages/flows/index.d.vue.ts +0 -3
- package/dist/runtime/app/pages/flows/index.vue +0 -645
- package/dist/runtime/app/pages/flows/index.vue.d.ts +0 -3
- package/dist/runtime/app/pages/index.d.vue.ts +0 -3
- package/dist/runtime/app/pages/index.vue +0 -34
- package/dist/runtime/app/pages/index.vue.d.ts +0 -3
- package/dist/runtime/app/pages/queues/index.d.vue.ts +0 -3
- package/dist/runtime/app/pages/queues/index.vue +0 -229
- package/dist/runtime/app/pages/queues/index.vue.d.ts +0 -3
- package/dist/runtime/app/pages/queues/job.d.vue.ts +0 -3
- package/dist/runtime/app/pages/queues/job.vue +0 -262
- package/dist/runtime/app/pages/queues/job.vue.d.ts +0 -3
- package/dist/runtime/app/pages/queues/jobs.d.vue.ts +0 -3
- package/dist/runtime/app/pages/queues/jobs.vue +0 -291
- package/dist/runtime/app/pages/queues/jobs.vue.d.ts +0 -3
- package/dist/runtime/app/plugins/vueflow.client.d.ts +0 -2
- package/dist/runtime/app/plugins/vueflow.client.js +0 -11
- package/dist/runtime/constants.d.ts +0 -11
- package/dist/runtime/constants.js +0 -11
- package/dist/runtime/schema.d.ts +0 -37
- package/dist/runtime/schema.js +0 -20
- package/dist/runtime/server/api/_flows/[name]/clear-history.delete.d.ts +0 -10
- package/dist/runtime/server/api/_flows/[name]/clear-history.delete.js +0 -44
- package/dist/runtime/server/api/_flows/[name]/runs.get.d.ts +0 -7
- package/dist/runtime/server/api/_flows/[name]/runs.get.js +0 -53
- package/dist/runtime/server/api/_flows/[name]/schedule.post.js +0 -57
- package/dist/runtime/server/api/_flows/[name]/schedules/[id].delete.d.ts +0 -2
- package/dist/runtime/server/api/_flows/[name]/schedules/[id].delete.js +0 -42
- package/dist/runtime/server/api/_flows/[name]/schedules.get.d.ts +0 -2
- package/dist/runtime/server/api/_flows/[name]/schedules.get.js +0 -48
- package/dist/runtime/server/api/_flows/[name]/start.post.d.ts +0 -2
- package/dist/runtime/server/api/_flows/[name]/start.post.js +0 -9
- package/dist/runtime/server/api/_flows/index.get.d.ts +0 -6
- package/dist/runtime/server/api/_flows/index.get.js +0 -5
- package/dist/runtime/server/api/_flows/ws.d.ts +0 -60
- package/dist/runtime/server/api/_flows/ws.js +0 -188
- package/dist/runtime/server/api/_queues/[name]/job/[id].get.d.ts +0 -2
- package/dist/runtime/server/api/_queues/[name]/job/[id].get.js +0 -9
- package/dist/runtime/server/api/_queues/[name]/job/index.get.d.ts +0 -2
- package/dist/runtime/server/api/_queues/[name]/job/index.get.js +0 -18
- package/dist/runtime/server/api/_queues/index.get.d.ts +0 -2
- package/dist/runtime/server/api/_queues/index.get.js +0 -63
- package/dist/runtime/server/api/_queues/ws.d.ts +0 -48
- package/dist/runtime/server/api/_queues/ws.js +0 -205
- package/dist/runtime/server/plugins/00.event-store.d.ts +0 -13
- package/dist/runtime/server/plugins/00.event-store.js +0 -16
- package/dist/runtime/server/plugins/flow-management.d.ts +0 -13
- package/dist/runtime/server/plugins/flow-management.js +0 -65
- package/dist/runtime/server/plugins/queue-management.d.ts +0 -2
- package/dist/runtime/server/plugins/queue-management.js +0 -27
- package/dist/runtime/server/plugins/state-cleanup.d.ts +0 -11
- package/dist/runtime/server/plugins/state-cleanup.js +0 -93
- package/dist/runtime/server/plugins/worker-management.d.ts +0 -2
- package/dist/runtime/server/plugins/worker-management.js +0 -33
- package/dist/runtime/server/tsconfig.json +0 -3
- package/dist/runtime/server-utils/events/adapters/fileAdapter.d.ts +0 -2
- package/dist/runtime/server-utils/events/adapters/fileAdapter.js +0 -382
- package/dist/runtime/server-utils/events/adapters/memoryAdapter.d.ts +0 -2
- package/dist/runtime/server-utils/events/adapters/memoryAdapter.js +0 -171
- package/dist/runtime/server-utils/events/adapters/redis/redisAdapter.d.ts +0 -2
- package/dist/runtime/server-utils/events/adapters/redis/redisAdapter.js +0 -348
- package/dist/runtime/server-utils/events/adapters/redis/redisPubSubGateway.d.ts +0 -30
- package/dist/runtime/server-utils/events/adapters/redis/redisPubSubGateway.js +0 -82
- package/dist/runtime/server-utils/events/eventStoreFactory.d.ts +0 -19
- package/dist/runtime/server-utils/events/eventStoreFactory.js +0 -44
- package/dist/runtime/server-utils/events/streamNames.d.ts +0 -17
- package/dist/runtime/server-utils/events/streamNames.js +0 -17
- package/dist/runtime/server-utils/events/types.d.ts +0 -63
- package/dist/runtime/server-utils/events/wiring/flowWiring.js +0 -409
- package/dist/runtime/server-utils/events/wiring/registry.d.ts +0 -10
- package/dist/runtime/server-utils/events/wiring/registry.js +0 -24
- package/dist/runtime/server-utils/queue/adapters/bullmq.d.ts +0 -18
- package/dist/runtime/server-utils/queue/adapters/bullmq.js +0 -164
- package/dist/runtime/server-utils/queue/queueFactory.d.ts +0 -3
- package/dist/runtime/server-utils/queue/queueFactory.js +0 -10
- package/dist/runtime/server-utils/queue/types.d.ts +0 -47
- package/dist/runtime/server-utils/state/adapters/redis.d.ts +0 -2
- package/dist/runtime/server-utils/state/adapters/redis.js +0 -42
- package/dist/runtime/server-utils/state/stateFactory.d.ts +0 -3
- package/dist/runtime/server-utils/state/stateFactory.js +0 -17
- package/dist/runtime/server-utils/state/types.d.ts +0 -23
- package/dist/runtime/server-utils/utils/defineQueueConfig.d.ts +0 -154
- package/dist/runtime/server-utils/utils/defineQueueConfig.js +0 -2
- package/dist/runtime/server-utils/utils/defineQueueWorker.d.ts +0 -10
- package/dist/runtime/server-utils/utils/defineQueueWorker.js +0 -17
- package/dist/runtime/server-utils/utils/useEventStore.d.ts +0 -20
- package/dist/runtime/server-utils/utils/useEventStore.js +0 -119
- package/dist/runtime/server-utils/utils/useFlowEngine.d.ts +0 -9
- package/dist/runtime/server-utils/utils/useFlowEngine.js +0 -44
- package/dist/runtime/server-utils/utils/useLogs.d.ts +0 -41
- package/dist/runtime/server-utils/utils/useLogs.js +0 -74
- package/dist/runtime/server-utils/utils/useQueue.d.ts +0 -31
- package/dist/runtime/server-utils/utils/useQueue.js +0 -24
- package/dist/runtime/server-utils/worker/adapter.d.ts +0 -4
- package/dist/runtime/server-utils/worker/adapter.js +0 -66
- package/dist/runtime/server-utils/worker/runner/node.d.ts +0 -27
- package/dist/runtime/server-utils/worker/runner/node.js +0 -196
- package/dist/runtime/types.d.ts +0 -132
- /package/dist/runtime/{server-utils/events/types.js → adapters/interfaces/queue.js} +0 -0
- /package/dist/runtime/{server-utils/queue/types.js → adapters/interfaces/store.js} +0 -0
- /package/dist/runtime/{server-utils/state/types.js → adapters/interfaces/stream.js} +0 -0
- /package/dist/runtime/{server-utils/events → events}/eventBus.js +0 -0
- /package/dist/runtime/{server/plugins/00.ws-lifecycle.d.ts → nitro/plugins/01.ws-lifecycle.d.ts} +0 -0
- /package/dist/runtime/{server/plugins/00.ws-lifecycle.js → nitro/plugins/01.ws-lifecycle.js} +0 -0
- /package/dist/runtime/{server/api/_flows/[name]/schedule.post.d.ts → nitro/plugins/02.workers.d.ts} +0 -0
- /package/dist/runtime/{server-utils → nitro}/utils/useNventLogger.d.ts +0 -0
- /package/dist/runtime/{server-utils → nitro}/utils/wsPeerManager.d.ts +0 -0
- /package/dist/runtime/{server-utils → nitro}/utils/wsPeerManager.js +0 -0
- /package/dist/runtime/{python → worker/python}/get_config.py +0 -0
|
@@ -1,240 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
computed,
|
|
3
|
-
inject,
|
|
4
|
-
provide,
|
|
5
|
-
shallowRef,
|
|
6
|
-
useRoute,
|
|
7
|
-
useRouter,
|
|
8
|
-
watch,
|
|
9
|
-
defineAsyncComponent
|
|
10
|
-
} from "#imports";
|
|
11
|
-
export function useComponentRouter(opts) {
|
|
12
|
-
const CTX_KEY = "component-router";
|
|
13
|
-
if (!opts || !("routes" in opts) || !opts.routes) {
|
|
14
|
-
const key = opts?.provideKey ?? CTX_KEY;
|
|
15
|
-
const ctx = inject(key, null);
|
|
16
|
-
if (!ctx) {
|
|
17
|
-
console.warn(
|
|
18
|
-
"[useComponentRouter] No parent router context found. Ensure a parent uses useComponentRouter with routes or wrap children in <component-router>."
|
|
19
|
-
);
|
|
20
|
-
const emptyRoute = shallowRef({ path: "", params: {}, query: {} });
|
|
21
|
-
const warnNav = async (_p) => console.warn(
|
|
22
|
-
"[useComponentRouter] push/replace called without a parent router context."
|
|
23
|
-
);
|
|
24
|
-
const noopMake = (p, _params) => p;
|
|
25
|
-
const noopHref = (p, _params) => p;
|
|
26
|
-
return {
|
|
27
|
-
route: emptyRoute,
|
|
28
|
-
push: warnNav,
|
|
29
|
-
replace: warnNav,
|
|
30
|
-
makePath: noopMake,
|
|
31
|
-
makeHref: noopHref,
|
|
32
|
-
pushTo: async (p, _params) => warnNav(p),
|
|
33
|
-
replaceTo: async (p, _params) => warnNav(p),
|
|
34
|
-
component: void 0
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
return ctx;
|
|
38
|
-
}
|
|
39
|
-
const props = {
|
|
40
|
-
routes: Array.isArray(opts.routes) ? opts.routes : Object.entries(opts.routes || {}).map(([path, component2]) => ({
|
|
41
|
-
path,
|
|
42
|
-
component: component2
|
|
43
|
-
})),
|
|
44
|
-
base: opts.base ?? "fp",
|
|
45
|
-
mode: opts.mode ?? "query",
|
|
46
|
-
initial: opts.initial,
|
|
47
|
-
provideKey: opts.provideKey ?? CTX_KEY,
|
|
48
|
-
debug: opts.debug === true
|
|
49
|
-
};
|
|
50
|
-
const nuxtRoute = useRoute();
|
|
51
|
-
const nuxtRouter = useRouter();
|
|
52
|
-
const component = shallowRef(null);
|
|
53
|
-
const route = shallowRef({
|
|
54
|
-
path: "",
|
|
55
|
-
params: {},
|
|
56
|
-
query: {}
|
|
57
|
-
});
|
|
58
|
-
const dbg = (...args) => {
|
|
59
|
-
if (props.debug) console.info("[component-router]", ...args);
|
|
60
|
-
};
|
|
61
|
-
function esc(text) {
|
|
62
|
-
return text.replace(/([.+*?=^!${}()[\]|\\])/g, "\\$1");
|
|
63
|
-
}
|
|
64
|
-
function compilePattern(path) {
|
|
65
|
-
const keys = [];
|
|
66
|
-
const dyn = /\/:([^/]+)/g;
|
|
67
|
-
let last = 0;
|
|
68
|
-
let pattern = "";
|
|
69
|
-
let m;
|
|
70
|
-
while (m = dyn.exec(path)) {
|
|
71
|
-
pattern += esc(path.slice(last, m.index));
|
|
72
|
-
keys.push(m[1]);
|
|
73
|
-
pattern += "/([^/]+)";
|
|
74
|
-
last = m.index + m[0].length;
|
|
75
|
-
}
|
|
76
|
-
pattern += esc(path.slice(last));
|
|
77
|
-
const regex = new RegExp("^" + pattern + "$");
|
|
78
|
-
dbg("compiled", { path, pattern, regex, keys });
|
|
79
|
-
return { regex, keys };
|
|
80
|
-
}
|
|
81
|
-
const records = computed(
|
|
82
|
-
() => props.routes.map((r) => {
|
|
83
|
-
const { regex, keys } = compilePattern(r.path);
|
|
84
|
-
return { ...r, regex, keys };
|
|
85
|
-
})
|
|
86
|
-
);
|
|
87
|
-
function matchPath(path) {
|
|
88
|
-
dbg("matchPath", path);
|
|
89
|
-
for (const r of records.value) {
|
|
90
|
-
const m = r.regex.exec(path);
|
|
91
|
-
dbg(" try", r.path, r.regex, !!m);
|
|
92
|
-
if (m) {
|
|
93
|
-
const params = {};
|
|
94
|
-
r.keys.forEach(
|
|
95
|
-
(k, i) => params[k] = decodeURIComponent(m[i + 1] || "")
|
|
96
|
-
);
|
|
97
|
-
return { record: r, params };
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
return null;
|
|
101
|
-
}
|
|
102
|
-
function setCurrent(path) {
|
|
103
|
-
dbg("setCurrent", path);
|
|
104
|
-
const m = matchPath(path) || matchPath(props.routes[0]?.path || "/");
|
|
105
|
-
if (!m) return;
|
|
106
|
-
component.value = m.record.component;
|
|
107
|
-
const [pathOnly, queryString] = path.split("?");
|
|
108
|
-
const queryParams = {};
|
|
109
|
-
if (queryString) {
|
|
110
|
-
const params = new URLSearchParams(queryString);
|
|
111
|
-
params.forEach((value, key) => {
|
|
112
|
-
queryParams[key] = value;
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
route.value = {
|
|
116
|
-
path: pathOnly || path,
|
|
117
|
-
params: m.params,
|
|
118
|
-
query: queryParams
|
|
119
|
-
// Only use query params from the current path, not from nuxtRoute
|
|
120
|
-
};
|
|
121
|
-
dbg("current", route.value);
|
|
122
|
-
}
|
|
123
|
-
function readFromHost() {
|
|
124
|
-
if (props.mode === "query") {
|
|
125
|
-
const p = nuxtRoute.query?.[props.base];
|
|
126
|
-
dbg("readFromHost(query)", p);
|
|
127
|
-
return typeof p === "string" ? p : null;
|
|
128
|
-
}
|
|
129
|
-
if (props.mode === "hash") {
|
|
130
|
-
const h = (typeof window !== "undefined" ? window.location.hash : "") || "";
|
|
131
|
-
const key = `#${props.base}=`;
|
|
132
|
-
const idx = h.indexOf(key);
|
|
133
|
-
dbg("readFromHost(hash)", h);
|
|
134
|
-
return idx >= 0 ? h.slice(idx + key.length) : null;
|
|
135
|
-
}
|
|
136
|
-
return null;
|
|
137
|
-
}
|
|
138
|
-
async function writeToHost(path, replace2 = false) {
|
|
139
|
-
dbg("writeToHost", path, { replace: replace2, mode: props.mode });
|
|
140
|
-
if (props.mode === "query") {
|
|
141
|
-
const [pathOnly, queryString] = path.split("?");
|
|
142
|
-
const pathQuery = {};
|
|
143
|
-
if (queryString) {
|
|
144
|
-
const params = new URLSearchParams(queryString);
|
|
145
|
-
params.forEach((value, key) => {
|
|
146
|
-
pathQuery[key] = value;
|
|
147
|
-
});
|
|
148
|
-
}
|
|
149
|
-
const nextQuery = { [props.base]: pathOnly, ...pathQuery };
|
|
150
|
-
if (nuxtRoute.query?.[props.base] === pathOnly && !queryString) {
|
|
151
|
-
setCurrent(path);
|
|
152
|
-
return;
|
|
153
|
-
}
|
|
154
|
-
await (replace2 ? nuxtRouter.replace({ query: nextQuery }) : nuxtRouter.push({ query: nextQuery }));
|
|
155
|
-
return;
|
|
156
|
-
}
|
|
157
|
-
if (props.mode === "hash" && typeof window !== "undefined") {
|
|
158
|
-
const key = `#${props.base}=`;
|
|
159
|
-
const nextHash = key + path;
|
|
160
|
-
if (window.location.hash !== nextHash) {
|
|
161
|
-
if (replace2) {
|
|
162
|
-
const url = window.location.href.replace(/#.*/, "") + nextHash;
|
|
163
|
-
window.history.replaceState(null, "", url);
|
|
164
|
-
} else {
|
|
165
|
-
window.location.hash = nextHash;
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
setCurrent(path);
|
|
169
|
-
return;
|
|
170
|
-
}
|
|
171
|
-
setCurrent(path);
|
|
172
|
-
}
|
|
173
|
-
async function push(path) {
|
|
174
|
-
await writeToHost(path, false);
|
|
175
|
-
}
|
|
176
|
-
async function replace(path) {
|
|
177
|
-
await writeToHost(path, true);
|
|
178
|
-
}
|
|
179
|
-
function makePath(patternOrPath, params) {
|
|
180
|
-
const hasDyn = /:[^/]+/.test(patternOrPath);
|
|
181
|
-
if (!hasDyn) return patternOrPath;
|
|
182
|
-
const replaced = patternOrPath.replace(/:([^/]+)/g, (_m, key) => {
|
|
183
|
-
const v = params?.[key];
|
|
184
|
-
return encodeURIComponent(v == null ? "" : String(v));
|
|
185
|
-
});
|
|
186
|
-
return replaced.replace(/\/{2,}/g, "/");
|
|
187
|
-
}
|
|
188
|
-
function makeHref(patternOrPath, params) {
|
|
189
|
-
const path = makePath(patternOrPath, params);
|
|
190
|
-
if (props.mode === "query") return `?${props.base}=${path}`;
|
|
191
|
-
if (props.mode === "hash") return `#${props.base}=${path}`;
|
|
192
|
-
return path;
|
|
193
|
-
}
|
|
194
|
-
async function pushTo(patternOrPath, params) {
|
|
195
|
-
const path = makePath(patternOrPath, params);
|
|
196
|
-
await push(path);
|
|
197
|
-
}
|
|
198
|
-
async function replaceTo(patternOrPath, params) {
|
|
199
|
-
const path = makePath(patternOrPath, params);
|
|
200
|
-
await replace(path);
|
|
201
|
-
}
|
|
202
|
-
const exposed = { push, replace, route, makePath, makeHref, pushTo, replaceTo };
|
|
203
|
-
provide(props.provideKey, exposed);
|
|
204
|
-
const initialPath = readFromHost() || props.initial || props.routes[0]?.path || "/";
|
|
205
|
-
dbg("init", { initialPath });
|
|
206
|
-
writeToHost(initialPath, true);
|
|
207
|
-
watch(
|
|
208
|
-
() => ({
|
|
209
|
-
q: nuxtRoute.query?.[props.base],
|
|
210
|
-
h: typeof window !== "undefined" ? window.location.hash : ""
|
|
211
|
-
}),
|
|
212
|
-
() => {
|
|
213
|
-
const path = readFromHost();
|
|
214
|
-
dbg("watch change detected ->", path);
|
|
215
|
-
if (path) setCurrent(path);
|
|
216
|
-
}
|
|
217
|
-
);
|
|
218
|
-
return { component, route, push, replace, makePath, makeHref, pushTo, replaceTo };
|
|
219
|
-
}
|
|
220
|
-
export default useComponentRouter;
|
|
221
|
-
export function createComponentRoutes(glob, options) {
|
|
222
|
-
const base = options?.base || "";
|
|
223
|
-
const toPath = (key) => {
|
|
224
|
-
let p = key.replace(/^\.\//, "/").replace(/\.(vue|tsx?|jsx?)$/, "");
|
|
225
|
-
p = p.replace(/\/index$/, "");
|
|
226
|
-
p = p.replace(/\[(.+?)\]/g, ":$1");
|
|
227
|
-
if (!p.startsWith("/")) p = "/" + p;
|
|
228
|
-
if (base) {
|
|
229
|
-
const b = base.startsWith("/") ? base : "/" + base;
|
|
230
|
-
p = (b + (p === "/" ? "" : p)).replace(/\/+/, "/");
|
|
231
|
-
}
|
|
232
|
-
return p || "/";
|
|
233
|
-
};
|
|
234
|
-
return Object.entries(glob).map(([key, loader]) => ({
|
|
235
|
-
path: toPath(key),
|
|
236
|
-
component: defineAsyncComponent(
|
|
237
|
-
() => loader().then((m) => m.default || m)
|
|
238
|
-
)
|
|
239
|
-
}));
|
|
240
|
-
}
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import { type Ref } from 'vue';
|
|
2
|
-
/**
|
|
3
|
-
* Composable for managing a single flow run's timeline and state
|
|
4
|
-
*
|
|
5
|
-
* Simple approach: No HMR persistence, rely on component lifecycle + URL state
|
|
6
|
-
* - URL preserves flowId/runId across HMR
|
|
7
|
-
* - Component remounts after HMR with correct state
|
|
8
|
-
* - Fresh WebSocket connection on each mount = clean, predictable behavior
|
|
9
|
-
*/
|
|
10
|
-
export declare function useFlowRunTimeline(flowId: Ref<string>, runId: Ref<string>): {
|
|
11
|
-
flowState: {
|
|
12
|
-
events: Ref<import("~~/.nuxt/imports").EventRecord[], import("~~/.nuxt/imports").EventRecord[]>;
|
|
13
|
-
state: import("vue").ComputedRef<import("~~/.nuxt/imports").FlowState>;
|
|
14
|
-
addEvent: (event: import("~~/.nuxt/imports").EventRecord) => void;
|
|
15
|
-
addEvents: (newEvents: import("~~/.nuxt/imports").EventRecord[]) => void;
|
|
16
|
-
reset: (newEvents?: import("~~/.nuxt/imports").EventRecord[]) => void;
|
|
17
|
-
isRunning: import("vue").ComputedRef<boolean>;
|
|
18
|
-
isCompleted: import("vue").ComputedRef<boolean>;
|
|
19
|
-
isFailed: import("vue").ComputedRef<boolean>;
|
|
20
|
-
stepList: import("vue").ComputedRef<{
|
|
21
|
-
status: "pending" | "running" | "completed" | "failed" | "retrying" | "waiting" | "timeout";
|
|
22
|
-
attempt: number;
|
|
23
|
-
startedAt?: string;
|
|
24
|
-
completedAt?: string;
|
|
25
|
-
error?: string;
|
|
26
|
-
awaitType?: "time" | "event" | "trigger";
|
|
27
|
-
awaitData?: any;
|
|
28
|
-
result?: any;
|
|
29
|
-
key: string;
|
|
30
|
-
}[]>;
|
|
31
|
-
runningSteps: import("vue").ComputedRef<{
|
|
32
|
-
status: "pending" | "running" | "completed" | "failed" | "retrying" | "waiting" | "timeout";
|
|
33
|
-
attempt: number;
|
|
34
|
-
startedAt?: string;
|
|
35
|
-
completedAt?: string;
|
|
36
|
-
error?: string;
|
|
37
|
-
awaitType?: "time" | "event" | "trigger";
|
|
38
|
-
awaitData?: any;
|
|
39
|
-
result?: any;
|
|
40
|
-
key: string;
|
|
41
|
-
}[]>;
|
|
42
|
-
waitingSteps: import("vue").ComputedRef<{
|
|
43
|
-
status: "pending" | "running" | "completed" | "failed" | "retrying" | "waiting" | "timeout";
|
|
44
|
-
attempt: number;
|
|
45
|
-
startedAt?: string;
|
|
46
|
-
completedAt?: string;
|
|
47
|
-
error?: string;
|
|
48
|
-
awaitType?: "time" | "event" | "trigger";
|
|
49
|
-
awaitData?: any;
|
|
50
|
-
result?: any;
|
|
51
|
-
key: string;
|
|
52
|
-
}[]>;
|
|
53
|
-
failedSteps: import("vue").ComputedRef<{
|
|
54
|
-
status: "pending" | "running" | "completed" | "failed" | "retrying" | "waiting" | "timeout";
|
|
55
|
-
attempt: number;
|
|
56
|
-
startedAt?: string;
|
|
57
|
-
completedAt?: string;
|
|
58
|
-
error?: string;
|
|
59
|
-
awaitType?: "time" | "event" | "trigger";
|
|
60
|
-
awaitData?: any;
|
|
61
|
-
result?: any;
|
|
62
|
-
key: string;
|
|
63
|
-
}[]>;
|
|
64
|
-
completedSteps: import("vue").ComputedRef<{
|
|
65
|
-
status: "pending" | "running" | "completed" | "failed" | "retrying" | "waiting" | "timeout";
|
|
66
|
-
attempt: number;
|
|
67
|
-
startedAt?: string;
|
|
68
|
-
completedAt?: string;
|
|
69
|
-
error?: string;
|
|
70
|
-
awaitType?: "time" | "event" | "trigger";
|
|
71
|
-
awaitData?: any;
|
|
72
|
-
result?: any;
|
|
73
|
-
key: string;
|
|
74
|
-
}[]>;
|
|
75
|
-
};
|
|
76
|
-
isConnected: import("vue").ComputedRef<boolean>;
|
|
77
|
-
isReconnecting: import("vue").ComputedRef<boolean>;
|
|
78
|
-
loadRun: () => Promise<void>;
|
|
79
|
-
stopStream: () => void;
|
|
80
|
-
};
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import { useFlowWebSocket } from "./useFlowWebSocket.js";
|
|
2
|
-
import { useFlowState } from "./useFlowState.js";
|
|
3
|
-
import { computed, nextTick, onBeforeUnmount, watch } from "vue";
|
|
4
|
-
export function useFlowRunTimeline(flowId, runId) {
|
|
5
|
-
const flowState = useFlowState();
|
|
6
|
-
const flowWs = useFlowWebSocket();
|
|
7
|
-
const startStream = () => {
|
|
8
|
-
if (import.meta.server) return;
|
|
9
|
-
if (!flowId.value || !runId.value) {
|
|
10
|
-
return;
|
|
11
|
-
}
|
|
12
|
-
flowWs.subscribe({
|
|
13
|
-
flowName: flowId.value,
|
|
14
|
-
runId: runId.value,
|
|
15
|
-
onEvent: (eventData) => {
|
|
16
|
-
if (eventData?.record) {
|
|
17
|
-
flowState.addEvent(eventData.record);
|
|
18
|
-
}
|
|
19
|
-
},
|
|
20
|
-
onHistory: (events) => {
|
|
21
|
-
for (const eventData of events) {
|
|
22
|
-
if (eventData?.record) {
|
|
23
|
-
flowState.addEvent(eventData.record);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
}, {
|
|
28
|
-
autoReconnect: true,
|
|
29
|
-
maxRetries: 5,
|
|
30
|
-
baseDelayMs: 500,
|
|
31
|
-
maxDelayMs: 5e3,
|
|
32
|
-
onError: (err) => {
|
|
33
|
-
console.warn("[FlowRunTimeline] WebSocket error:", err);
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
};
|
|
37
|
-
const stopStream = () => {
|
|
38
|
-
if (import.meta.server) return;
|
|
39
|
-
flowWs.stop();
|
|
40
|
-
};
|
|
41
|
-
const loadRun = async () => {
|
|
42
|
-
if (!runId.value) return;
|
|
43
|
-
flowState.reset();
|
|
44
|
-
await nextTick();
|
|
45
|
-
startStream();
|
|
46
|
-
};
|
|
47
|
-
watch(runId, async (newRunId, oldRunId) => {
|
|
48
|
-
if (oldRunId && oldRunId !== newRunId) {
|
|
49
|
-
stopStream();
|
|
50
|
-
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
51
|
-
}
|
|
52
|
-
if (newRunId) {
|
|
53
|
-
await loadRun();
|
|
54
|
-
} else {
|
|
55
|
-
stopStream();
|
|
56
|
-
}
|
|
57
|
-
}, { immediate: true });
|
|
58
|
-
onBeforeUnmount(() => {
|
|
59
|
-
stopStream();
|
|
60
|
-
});
|
|
61
|
-
return {
|
|
62
|
-
flowState,
|
|
63
|
-
isConnected: computed(() => flowWs.connected.value),
|
|
64
|
-
isReconnecting: computed(() => flowWs.reconnecting.value),
|
|
65
|
-
loadRun,
|
|
66
|
-
stopStream
|
|
67
|
-
};
|
|
68
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { type Ref } from '#imports';
|
|
2
|
-
import type { FetchError } from 'ofetch';
|
|
3
|
-
interface FlowRun {
|
|
4
|
-
id: string;
|
|
5
|
-
[key: string]: any;
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
* Composable for fetching and managing flow runs
|
|
9
|
-
* Simple approach: Fresh fetch on every refresh, no stale cache
|
|
10
|
-
* Client-only to avoid hydration mismatches
|
|
11
|
-
*/
|
|
12
|
-
export declare function useFlowRuns(flowId: Ref<string>): {
|
|
13
|
-
runs: Ref<FlowRun[] | null | undefined>;
|
|
14
|
-
refresh: () => Promise<void>;
|
|
15
|
-
status: Ref<'idle' | 'pending' | 'success' | 'error'>;
|
|
16
|
-
error: Ref<FetchError | null | undefined>;
|
|
17
|
-
};
|
|
18
|
-
export {};
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { ref, watch, useFetch } from "#imports";
|
|
2
|
-
export function useFlowRuns(flowId) {
|
|
3
|
-
const refreshCounter = ref(0);
|
|
4
|
-
const { data: runs, refresh: _refresh, status, error } = useFetch(
|
|
5
|
-
() => `/api/_flows/${encodeURIComponent(flowId.value)}/runs?_t=${refreshCounter.value}`,
|
|
6
|
-
{
|
|
7
|
-
immediate: false,
|
|
8
|
-
watch: false,
|
|
9
|
-
// Disable automatic watch to prevent SSR execution
|
|
10
|
-
server: false
|
|
11
|
-
// Client-only to avoid hydration issues
|
|
12
|
-
// Don't use a key - this prevents Nuxt from caching across calls
|
|
13
|
-
}
|
|
14
|
-
);
|
|
15
|
-
const refresh = async () => {
|
|
16
|
-
refreshCounter.value++;
|
|
17
|
-
await _refresh();
|
|
18
|
-
};
|
|
19
|
-
watch(flowId, (newFlow, oldFlow) => {
|
|
20
|
-
if (import.meta.client && newFlow) {
|
|
21
|
-
if (newFlow !== oldFlow || !runs.value) {
|
|
22
|
-
refresh();
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
}, { immediate: true });
|
|
26
|
-
return {
|
|
27
|
-
runs,
|
|
28
|
-
refresh,
|
|
29
|
-
status,
|
|
30
|
-
error
|
|
31
|
-
};
|
|
32
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { type Ref } from '#imports';
|
|
2
|
-
/**
|
|
3
|
-
* Composable for infinite scroll flow runs with pagination
|
|
4
|
-
*/
|
|
5
|
-
export declare function useFlowRunsInfinite(flowId: Ref<string>): {
|
|
6
|
-
items: import("vue").ComputedRef<{
|
|
7
|
-
id: string;
|
|
8
|
-
flowName: string;
|
|
9
|
-
status: "running" | "completed" | "failed" | "unknown";
|
|
10
|
-
createdAt: string;
|
|
11
|
-
startedAt?: string | undefined;
|
|
12
|
-
completedAt?: string | undefined;
|
|
13
|
-
stepCount: number;
|
|
14
|
-
completedSteps: number;
|
|
15
|
-
}[]>;
|
|
16
|
-
total: import("vue").ComputedRef<number>;
|
|
17
|
-
loading: import("vue").ComputedRef<boolean>;
|
|
18
|
-
hasMore: import("vue").ComputedRef<boolean>;
|
|
19
|
-
error: import("vue").ComputedRef<Error | null>;
|
|
20
|
-
loadMore: () => void;
|
|
21
|
-
refresh: () => Promise<void>;
|
|
22
|
-
checkForNewRuns: () => Promise<void>;
|
|
23
|
-
reset: () => void;
|
|
24
|
-
};
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
import { ref, computed, watch } from "#imports";
|
|
2
|
-
export function useFlowRunsInfinite(flowId) {
|
|
3
|
-
const items = ref([]);
|
|
4
|
-
const total = ref(0);
|
|
5
|
-
const offset = ref(0);
|
|
6
|
-
const limit = 50;
|
|
7
|
-
const loading = ref(false);
|
|
8
|
-
const hasMore = ref(true);
|
|
9
|
-
const error = ref(null);
|
|
10
|
-
const newestRunId = ref(null);
|
|
11
|
-
const reset = () => {
|
|
12
|
-
items.value = [];
|
|
13
|
-
total.value = 0;
|
|
14
|
-
offset.value = 0;
|
|
15
|
-
hasMore.value = true;
|
|
16
|
-
error.value = null;
|
|
17
|
-
newestRunId.value = null;
|
|
18
|
-
};
|
|
19
|
-
const fetchPage = async (resetData = false) => {
|
|
20
|
-
if (!flowId.value || loading.value) return;
|
|
21
|
-
if (resetData) {
|
|
22
|
-
reset();
|
|
23
|
-
}
|
|
24
|
-
if (!hasMore.value && !resetData) return;
|
|
25
|
-
try {
|
|
26
|
-
loading.value = true;
|
|
27
|
-
error.value = null;
|
|
28
|
-
const response = await $fetch(
|
|
29
|
-
`/api/_flows/${encodeURIComponent(flowId.value)}/runs`,
|
|
30
|
-
{
|
|
31
|
-
query: {
|
|
32
|
-
limit,
|
|
33
|
-
offset: resetData ? 0 : offset.value,
|
|
34
|
-
_t: Date.now()
|
|
35
|
-
// Cache busting
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
);
|
|
39
|
-
if (resetData) {
|
|
40
|
-
items.value = response.items;
|
|
41
|
-
offset.value = response.items.length;
|
|
42
|
-
if (response.items.length > 0) {
|
|
43
|
-
newestRunId.value = response.items[0].id;
|
|
44
|
-
}
|
|
45
|
-
} else {
|
|
46
|
-
items.value.push(...response.items);
|
|
47
|
-
offset.value += response.items.length;
|
|
48
|
-
}
|
|
49
|
-
total.value = response.total;
|
|
50
|
-
hasMore.value = response.hasMore;
|
|
51
|
-
} catch (err) {
|
|
52
|
-
console.error("[useFlowRunsInfinite] fetch error:", err);
|
|
53
|
-
error.value = err instanceof Error ? err : new Error(String(err));
|
|
54
|
-
} finally {
|
|
55
|
-
loading.value = false;
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
const loadMore = () => {
|
|
59
|
-
if (!loading.value && hasMore.value) {
|
|
60
|
-
fetchPage(false);
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
const refresh = async () => {
|
|
64
|
-
await fetchPage(true);
|
|
65
|
-
};
|
|
66
|
-
const checkForNewRuns = async () => {
|
|
67
|
-
if (!flowId.value || loading.value) return;
|
|
68
|
-
try {
|
|
69
|
-
const response = await $fetch(
|
|
70
|
-
`/api/_flows/${encodeURIComponent(flowId.value)}/runs`,
|
|
71
|
-
{
|
|
72
|
-
query: {
|
|
73
|
-
limit: Math.max(items.value.length, 10),
|
|
74
|
-
// Fetch at least as many as we have loaded
|
|
75
|
-
offset: 0,
|
|
76
|
-
_t: Date.now()
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
);
|
|
80
|
-
if (response.items.length === 0) return;
|
|
81
|
-
const latestRunId = response.items[0].id;
|
|
82
|
-
const updatedItems = [...items.value];
|
|
83
|
-
const newRuns = [];
|
|
84
|
-
for (const freshRun of response.items) {
|
|
85
|
-
const existingIndex = updatedItems.findIndex((r) => r.id === freshRun.id);
|
|
86
|
-
if (existingIndex >= 0) {
|
|
87
|
-
updatedItems[existingIndex] = freshRun;
|
|
88
|
-
} else {
|
|
89
|
-
newRuns.push(freshRun);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
if (newRuns.length > 0) {
|
|
93
|
-
items.value = [...newRuns, ...updatedItems];
|
|
94
|
-
newestRunId.value = latestRunId;
|
|
95
|
-
} else {
|
|
96
|
-
items.value = updatedItems;
|
|
97
|
-
}
|
|
98
|
-
total.value = response.total;
|
|
99
|
-
if (!newestRunId.value) {
|
|
100
|
-
newestRunId.value = latestRunId;
|
|
101
|
-
}
|
|
102
|
-
} catch (err) {
|
|
103
|
-
console.error("[useFlowRunsInfinite] checkForNewRuns error:", err);
|
|
104
|
-
}
|
|
105
|
-
};
|
|
106
|
-
watch(flowId, (newFlow, oldFlow) => {
|
|
107
|
-
if (import.meta.client && newFlow && newFlow !== oldFlow) {
|
|
108
|
-
refresh();
|
|
109
|
-
}
|
|
110
|
-
}, { immediate: true });
|
|
111
|
-
return {
|
|
112
|
-
items: computed(() => items.value),
|
|
113
|
-
total: computed(() => total.value),
|
|
114
|
-
loading: computed(() => loading.value),
|
|
115
|
-
hasMore: computed(() => hasMore.value),
|
|
116
|
-
error: computed(() => error.value),
|
|
117
|
-
loadMore,
|
|
118
|
-
refresh,
|
|
119
|
-
checkForNewRuns,
|
|
120
|
-
// For polling - prepends new runs without resetting
|
|
121
|
-
reset
|
|
122
|
-
};
|
|
123
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { type Ref } from '#imports';
|
|
2
|
-
/**
|
|
3
|
-
* Composable for auto-polling flow runs list
|
|
4
|
-
* Polls continuously to keep the list fresh
|
|
5
|
-
*/
|
|
6
|
-
export declare function useFlowRunsPolling(refresh: () => Promise<void>, shouldPoll: Ref<boolean>, intervalMs?: number): {
|
|
7
|
-
pause: () => void;
|
|
8
|
-
resume: () => void;
|
|
9
|
-
};
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { watch, onBeforeUnmount } from "#imports";
|
|
2
|
-
export function useFlowRunsPolling(refresh, shouldPoll, intervalMs = 3e3) {
|
|
3
|
-
let intervalId = null;
|
|
4
|
-
const pause = () => {
|
|
5
|
-
if (intervalId) {
|
|
6
|
-
clearInterval(intervalId);
|
|
7
|
-
intervalId = null;
|
|
8
|
-
}
|
|
9
|
-
};
|
|
10
|
-
const resume = () => {
|
|
11
|
-
if (!intervalId) {
|
|
12
|
-
intervalId = setInterval(async () => {
|
|
13
|
-
if (shouldPoll.value) {
|
|
14
|
-
await refresh();
|
|
15
|
-
}
|
|
16
|
-
}, intervalMs);
|
|
17
|
-
}
|
|
18
|
-
};
|
|
19
|
-
watch(shouldPoll, (should) => {
|
|
20
|
-
if (should) {
|
|
21
|
-
resume();
|
|
22
|
-
} else {
|
|
23
|
-
pause();
|
|
24
|
-
}
|
|
25
|
-
}, { immediate: true });
|
|
26
|
-
onBeforeUnmount(() => {
|
|
27
|
-
pause();
|
|
28
|
-
});
|
|
29
|
-
return {
|
|
30
|
-
pause,
|
|
31
|
-
resume
|
|
32
|
-
};
|
|
33
|
-
}
|