@octabits-io/nuxt-ui-kit 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +151 -0
- package/dist/ai/index.d.ts +255 -0
- package/dist/ai/index.js +389 -0
- package/dist/dates/index.d.ts +42 -0
- package/dist/dates/index.js +108 -0
- package/dist/index.d.ts +453 -0
- package/dist/index.js +526 -0
- package/dist/zod/index.d.ts +24 -0
- package/dist/zod/index.js +17 -0
- package/package.json +102 -0
- package/src/components/AiResultReviewCard.vue +67 -0
- package/src/components/ConfirmDialog.vue +60 -0
- package/src/components/DateInput.vue +66 -0
- package/src/components/DateRangeInput.vue +651 -0
- package/src/components/PeriodDisplay.vue +76 -0
- package/src/components/SubSidebar.vue +85 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 The Octabits Authors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
# @octabits-io/nuxt-ui-kit
|
|
2
|
+
|
|
3
|
+
Frontend kit for Nuxt/Vue admin SPAs. Ships **factory-style seams** — the app
|
|
4
|
+
keeps thin plugin/store/middleware files and wires the kit into them; the kit
|
|
5
|
+
never touches Nuxt APIs (`defineNuxtPlugin`, `navigateTo`, `useRuntimeConfig`)
|
|
6
|
+
itself, so it has no Nuxt dependency, only `vue`.
|
|
7
|
+
|
|
8
|
+
## What's inside
|
|
9
|
+
|
|
10
|
+
- **OIDC session harness** (`oidc-client-ts` peer)
|
|
11
|
+
- `createUserManagerFactory({ getConfig, scope, … })` — lazy `UserManager`
|
|
12
|
+
singleton bound to `localStorage`
|
|
13
|
+
- `removeStaleOidcKeys`, `isUnrecoverableRenewError`
|
|
14
|
+
- `createLoginRedirector` — signin redirect carrying the current path as
|
|
15
|
+
returnUrl, with a `/login?redirect=` fallback
|
|
16
|
+
- `attachSessionLifecycleHandlers` — classifies silent-renew failures /
|
|
17
|
+
token expiry / back-channel signout into `notify` + `onSessionLost` +
|
|
18
|
+
login-redirect callbacks; copy and toasts stay in the app
|
|
19
|
+
- `ZITADEL_ORG_PROJECT_SCOPE` / `ZITADEL_REFRESH_TOKEN_ALLOWED_SCOPE`
|
|
20
|
+
presets (Zitadel restricts refresh-grant scopes — see the constant's docs)
|
|
21
|
+
- `seedAuthBypassSession` — dev/E2E bypass with an unconditional
|
|
22
|
+
production-build refusal (`isProductionBuild` is a required argument)
|
|
23
|
+
- **Auth session store core** — `createAuthSessionCore` returns the setup body
|
|
24
|
+
(`user`/`checkAuth`/`login`/`handleCallback`/`logout`, silent-renew retry,
|
|
25
|
+
`id_token_hint` logout) for the app's own `defineStore('auth', …)`
|
|
26
|
+
- **Route guard builder** — `createAuthGuard` returns a handler yielding a
|
|
27
|
+
redirect target or `undefined`; per-app policy (org validation, role gates)
|
|
28
|
+
goes in the `afterAuthenticated` hook
|
|
29
|
+
- **Eden Treaty client factory** (`@elysiajs/eden` peer) —
|
|
30
|
+
`createTreatyClientFactory<App>` (lazy singleton, bearer injection,
|
|
31
|
+
`parseDate: false` by default to keep ISO-date strings string-typed on the
|
|
32
|
+
wire), plus `createAccessTokenProvider` and `resolveApiBaseUrl`
|
|
33
|
+
- **Org store core** — `createOrgStoreCore<TOrg>` (granted orgs, slug-keyed
|
|
34
|
+
selection, persistence, lost-access revocation) for the app's own store
|
|
35
|
+
- **API error → i18n** — `createApiErrorMessenger({ t, te })`: maps
|
|
36
|
+
`{ key, message }` bodies and validation errors to user-facing strings via
|
|
37
|
+
the `errors.*` / `validation.fields.*` / `validation.messages.*` key
|
|
38
|
+
convention; unwraps Eden `{ value }` envelopes
|
|
39
|
+
- **Confirm dialog** — promise-based `useConfirm()` + singleton state, with a
|
|
40
|
+
`./components/ConfirmDialog.vue` renderer (`common.cancel`/`common.confirm`
|
|
41
|
+
i18n defaults, `zIndexClass` prop for stacking above slideovers)
|
|
42
|
+
- **Generic primitives** — `useDirtyTracking` (deep-compare form dirty state),
|
|
43
|
+
`usePagination` (offset pagination with `queryParams`),
|
|
44
|
+
`./components/SubSidebar.vue` (responsive list/detail layout — desktop
|
|
45
|
+
column, mobile slideover, `selectionQueryKey` auto-close)
|
|
46
|
+
- **`./zod`** (`zod` peer) — `setupZodLocaleSync`: keep Zod's built-in error
|
|
47
|
+
messages in the active UI language
|
|
48
|
+
- **`./dates`** (`date-fns` peer) — `Period`/`calculateDays`/`shiftIso`,
|
|
49
|
+
`useDateRangeInput`, and `createDateFormatter({ getLocale })` (the engine of
|
|
50
|
+
an app-side `useDateFormat`), plus source-shipped `./components/DateInput.vue`,
|
|
51
|
+
`DateRangeInput.vue` (travel/booking end-date semantics, blocked dates via
|
|
52
|
+
props, injected `availabilityCheck`), and `PeriodDisplay.vue`
|
|
53
|
+
- **`./ai`** — frontend AI-workflow engine: `useAiWorkflow` /
|
|
54
|
+
`useAiWorkflowGuard` (poll-driven state over injected transport),
|
|
55
|
+
`createAiProgressCore` (cross-page tracking + completion/applied signals —
|
|
56
|
+
the setup body of the app's progress store), `useAiCardState`,
|
|
57
|
+
`useActiveAiWorkflowProbe`, `createWorkflowRegistry`, and
|
|
58
|
+
`./components/AiResultReviewCard.vue`; dialog/float shells stay in the app
|
|
59
|
+
(thin views over this state, registry- and router-coupled)
|
|
60
|
+
|
|
61
|
+
## Components ship as source
|
|
62
|
+
|
|
63
|
+
`./components/*.vue` files are published as **`.vue` source** — the consumer's
|
|
64
|
+
Vite compiles them. They use only explicit imports (`@nuxt/ui/components/*.vue`,
|
|
65
|
+
`vue-i18n`, `vue-router`), so no auto-import configuration is required, and
|
|
66
|
+
they import kit composables from the **package root (self-reference)** so
|
|
67
|
+
module-scoped singleton state (the confirm dialog) is shared with feature
|
|
68
|
+
code. Register them under your app's own names with one-line re-exports:
|
|
69
|
+
|
|
70
|
+
```ts
|
|
71
|
+
// app/components/AppSubSidebar.ts
|
|
72
|
+
export { default } from '@octabits-io/nuxt-ui-kit/components/SubSidebar.vue'
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Wiring examples (Nuxt)
|
|
76
|
+
|
|
77
|
+
### Auth + API client
|
|
78
|
+
|
|
79
|
+
```ts
|
|
80
|
+
// app/plugins/10.oidc.client.ts
|
|
81
|
+
export const getUserManager = createUserManagerFactory({
|
|
82
|
+
getConfig: () => ({ issuerUrl, clientId }), // runtime config lookup
|
|
83
|
+
scope: ZITADEL_ORG_PROJECT_SCOPE,
|
|
84
|
+
refreshTokenAllowedScope: ZITADEL_REFRESH_TOKEN_ALLOWED_SCOPE,
|
|
85
|
+
})
|
|
86
|
+
export default defineNuxtPlugin((nuxtApp) => {
|
|
87
|
+
attachSessionLifecycleHandlers(getUserManager(), {
|
|
88
|
+
redirectToLogin: createLoginRedirector({ getUserManager }),
|
|
89
|
+
onSessionLost: () => useAuthStore().$patch({ user: null }),
|
|
90
|
+
notify: (notice) => toast.add(/* map notice.kind to your copy */),
|
|
91
|
+
})
|
|
92
|
+
})
|
|
93
|
+
|
|
94
|
+
// app/composables/useApi.ts
|
|
95
|
+
const getClient = createTreatyClientFactory<App>({
|
|
96
|
+
getBaseUrl: () => resolveApiBaseUrl({ configuredUrl, isProductionBuild: import.meta.env.PROD, devFallbackPort: 3002 }),
|
|
97
|
+
getAccessToken: createAccessTokenProvider(getUserManager),
|
|
98
|
+
})
|
|
99
|
+
|
|
100
|
+
// app/stores/auth.ts
|
|
101
|
+
export const useAuthStore = defineStore('auth', () =>
|
|
102
|
+
createAuthSessionCore({ getUserManager, mapUser: defaultAuthUserMapper }))
|
|
103
|
+
|
|
104
|
+
// app/middleware/auth.global.ts
|
|
105
|
+
const guard = createAuthGuard({ ensureAuthenticated, afterAuthenticated: appPolicy })
|
|
106
|
+
export default defineNuxtRouteMiddleware(async (to) => {
|
|
107
|
+
const target = await guard(to)
|
|
108
|
+
if (target) return navigateTo(target)
|
|
109
|
+
})
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### Errors, confirm, formatting
|
|
113
|
+
|
|
114
|
+
```ts
|
|
115
|
+
// app/composables/useApiError.ts — bind your i18n instance
|
|
116
|
+
export function useApiError() {
|
|
117
|
+
const { t, te } = useI18n()
|
|
118
|
+
return createApiErrorMessenger({ t: key => t(key), te: key => te(key) })
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// anywhere — the ConfirmDialog.vue renderer must be mounted once in a layout
|
|
122
|
+
const { confirm } = useConfirm()
|
|
123
|
+
if (await confirm({ title: t('owners.delete.title'), dangerous: true })) { /* … */ }
|
|
124
|
+
|
|
125
|
+
// app/composables/useDateFormat.ts
|
|
126
|
+
export function useDateFormat() {
|
|
127
|
+
const { locale } = useI18n()
|
|
128
|
+
return createDateFormatter({ getLocale: () => locale.value })
|
|
129
|
+
}
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
### AI workflows
|
|
133
|
+
|
|
134
|
+
```ts
|
|
135
|
+
// app/stores/aiProgress.ts — transport injected, signals consumed by pages
|
|
136
|
+
export const useAiProgressStore = defineStore('ai-progress', () =>
|
|
137
|
+
createAiProgressCore<AiDialogRequest>({
|
|
138
|
+
fetchWorkflowStatus: async (id) => {
|
|
139
|
+
const { data, error } = await api.ai.workflows({ id }).get()
|
|
140
|
+
return error || !data ? null : data
|
|
141
|
+
},
|
|
142
|
+
}))
|
|
143
|
+
|
|
144
|
+
// a page — rehydrate on mount, refuse duplicate triggers
|
|
145
|
+
const ai = useAiWorkflowGuard<MyOutput>({
|
|
146
|
+
checkFn: fetchLatestWorkflow,
|
|
147
|
+
pollFn: fetchLatestWorkflow,
|
|
148
|
+
onCompleted: (wf) => showReview(wf.output),
|
|
149
|
+
})
|
|
150
|
+
await ai.trigger(() => api.ai.workflows.post({ type: 'listing-fields' }))
|
|
151
|
+
```
|
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
import { MaybeRef, MaybeRefOrGetter, Ref } from "vue";
|
|
2
|
+
//#region src/ai/types.d.ts
|
|
3
|
+
type AiWorkflowStatus = 'pending' | 'running' | 'completed' | 'failed' | 'cancelled';
|
|
4
|
+
type AiWorkflowStepStatus = 'pending' | 'running' | 'completed' | 'failed' | 'skipped';
|
|
5
|
+
interface AiWorkflowStepData {
|
|
6
|
+
id: number;
|
|
7
|
+
key: string;
|
|
8
|
+
type: string;
|
|
9
|
+
status: AiWorkflowStepStatus;
|
|
10
|
+
dependencies: string[];
|
|
11
|
+
input?: unknown | null;
|
|
12
|
+
output?: unknown | null;
|
|
13
|
+
error?: string | null;
|
|
14
|
+
startedAt?: string | null;
|
|
15
|
+
completedAt?: string | null;
|
|
16
|
+
}
|
|
17
|
+
interface AiWorkflowData<TOutput = unknown> {
|
|
18
|
+
id: number;
|
|
19
|
+
type: string;
|
|
20
|
+
status: AiWorkflowStatus;
|
|
21
|
+
input: unknown;
|
|
22
|
+
output: TOutput | null;
|
|
23
|
+
error: string | null;
|
|
24
|
+
entityRef: string | null;
|
|
25
|
+
totalSteps: number;
|
|
26
|
+
completedSteps: number;
|
|
27
|
+
failedSteps: number;
|
|
28
|
+
steps: AiWorkflowStepData[];
|
|
29
|
+
createdAt: string;
|
|
30
|
+
startedAt: string | null;
|
|
31
|
+
completedAt: string | null;
|
|
32
|
+
appliedAt: string | null;
|
|
33
|
+
}
|
|
34
|
+
declare function isTerminalStatus(status: AiWorkflowStatus): boolean;
|
|
35
|
+
declare function isActiveStatus(status: AiWorkflowStatus): boolean;
|
|
36
|
+
//#endregion
|
|
37
|
+
//#region src/ai/useAiWorkflow.d.ts
|
|
38
|
+
interface UseAiWorkflowOptions<TOutput> {
|
|
39
|
+
/** Polling interval in milliseconds (default: 2000) */
|
|
40
|
+
interval?: number;
|
|
41
|
+
/** Called when workflow completes successfully */
|
|
42
|
+
onCompleted?: (workflow: AiWorkflowData<TOutput>) => void;
|
|
43
|
+
/** Called when workflow fails */
|
|
44
|
+
onFailed?: (workflow: AiWorkflowData<TOutput>) => void;
|
|
45
|
+
/** Called when workflow is cancelled */
|
|
46
|
+
onCancelled?: (workflow: AiWorkflowData<TOutput>) => void;
|
|
47
|
+
}
|
|
48
|
+
type PollFn<TOutput> = () => Promise<AiWorkflowData<TOutput> | null>;
|
|
49
|
+
/**
|
|
50
|
+
* Poll-driven AI-workflow state: `start(pollFn)` fetches immediately and then
|
|
51
|
+
* polls until the workflow reaches a terminal status, firing the matching
|
|
52
|
+
* callback. The poll function is injected — the engine is transport-agnostic.
|
|
53
|
+
*/
|
|
54
|
+
declare function useAiWorkflow<TOutput = unknown>(options?: UseAiWorkflowOptions<TOutput>): {
|
|
55
|
+
workflow: import("vue").ShallowRef<AiWorkflowData<TOutput> | null, AiWorkflowData<TOutput> | null>;
|
|
56
|
+
isLoading: import("vue").Ref<boolean, boolean>;
|
|
57
|
+
isPolling: import("vue").Ref<boolean, boolean>;
|
|
58
|
+
status: import("vue").ComputedRef<AiWorkflowStatus | null>;
|
|
59
|
+
progress: import("vue").ComputedRef<number>;
|
|
60
|
+
isCompleted: import("vue").ComputedRef<boolean>;
|
|
61
|
+
isFailed: import("vue").ComputedRef<boolean>;
|
|
62
|
+
isCancelled: import("vue").ComputedRef<boolean>;
|
|
63
|
+
isTerminal: import("vue").ComputedRef<boolean>;
|
|
64
|
+
isActive: import("vue").ComputedRef<boolean>;
|
|
65
|
+
output: import("vue").ComputedRef<TOutput | null>;
|
|
66
|
+
error: import("vue").ComputedRef<string | null>;
|
|
67
|
+
start: (pollFn: PollFn<TOutput>) => void;
|
|
68
|
+
stop: () => void;
|
|
69
|
+
cancel: (cancelFn: () => Promise<void>) => Promise<void>;
|
|
70
|
+
refresh: () => Promise<void>;
|
|
71
|
+
setWorkflow: (data: AiWorkflowData<TOutput>) => void;
|
|
72
|
+
};
|
|
73
|
+
type UseAiWorkflowReturn<TOutput> = ReturnType<typeof useAiWorkflow<TOutput>>;
|
|
74
|
+
//#endregion
|
|
75
|
+
//#region src/ai/useAiWorkflowGuard.d.ts
|
|
76
|
+
interface UseAiWorkflowGuardOptions<TOutput> extends UseAiWorkflowOptions<TOutput> {
|
|
77
|
+
/** Check for existing active workflow on mount. Returns the workflow data or null. */
|
|
78
|
+
checkFn: () => Promise<AiWorkflowData<TOutput> | null>;
|
|
79
|
+
/** Poll function used for ongoing status checks (typically same endpoint as checkFn) */
|
|
80
|
+
pollFn: PollFn<TOutput>;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* useAiWorkflow plus a mount-time re-hydration check (resume polling a
|
|
84
|
+
* workflow that is already running) and a `trigger` that refuses to start a
|
|
85
|
+
* duplicate while one is active. All transport is injected.
|
|
86
|
+
*/
|
|
87
|
+
declare function useAiWorkflowGuard<TOutput = unknown>(options: UseAiWorkflowGuardOptions<TOutput>): {
|
|
88
|
+
workflow: import("vue").ShallowRef<AiWorkflowData<TOutput> | null, AiWorkflowData<TOutput> | null>;
|
|
89
|
+
isLoading: import("vue").Ref<boolean, boolean>;
|
|
90
|
+
isPolling: import("vue").Ref<boolean, boolean>;
|
|
91
|
+
status: import("vue").ComputedRef<AiWorkflowStatus | null>;
|
|
92
|
+
progress: import("vue").ComputedRef<number>;
|
|
93
|
+
isCompleted: import("vue").ComputedRef<boolean>;
|
|
94
|
+
isFailed: import("vue").ComputedRef<boolean>;
|
|
95
|
+
isCancelled: import("vue").ComputedRef<boolean>;
|
|
96
|
+
isTerminal: import("vue").ComputedRef<boolean>;
|
|
97
|
+
isActive: import("vue").ComputedRef<boolean>;
|
|
98
|
+
output: import("vue").ComputedRef<TOutput | null>;
|
|
99
|
+
error: import("vue").ComputedRef<string | null>;
|
|
100
|
+
start: (pollFn: PollFn<TOutput>) => void;
|
|
101
|
+
stop: () => void;
|
|
102
|
+
cancel: (cancelFn: () => Promise<void>) => Promise<void>;
|
|
103
|
+
refresh: () => Promise<void>;
|
|
104
|
+
setWorkflow: (data: AiWorkflowData<TOutput>) => void;
|
|
105
|
+
isChecking: import("vue").Ref<boolean, boolean>;
|
|
106
|
+
trigger: (triggerFn: () => Promise<void>) => Promise<boolean>;
|
|
107
|
+
};
|
|
108
|
+
type UseAiWorkflowGuardReturn<TOutput> = ReturnType<typeof useAiWorkflowGuard<TOutput>>;
|
|
109
|
+
//#endregion
|
|
110
|
+
//#region src/ai/progressCore.d.ts
|
|
111
|
+
interface TrackedWorkflow {
|
|
112
|
+
workflowId: number;
|
|
113
|
+
workflowType: string;
|
|
114
|
+
entityRef: string | null;
|
|
115
|
+
entityId?: number;
|
|
116
|
+
status: AiWorkflowStatus;
|
|
117
|
+
progress: number;
|
|
118
|
+
totalSteps: number;
|
|
119
|
+
completedSteps: number;
|
|
120
|
+
dismissed: boolean;
|
|
121
|
+
}
|
|
122
|
+
interface AiWorkflowStatusSnapshot {
|
|
123
|
+
status: AiWorkflowStatus;
|
|
124
|
+
totalSteps: number;
|
|
125
|
+
completedSteps: number;
|
|
126
|
+
}
|
|
127
|
+
interface AiProgressCoreOptions {
|
|
128
|
+
/** Fetch the current status of one workflow; `null` skips this cycle. */
|
|
129
|
+
fetchWorkflowStatus: (workflowId: number) => Promise<AiWorkflowStatusSnapshot | null>;
|
|
130
|
+
/** Poll cadence while any tracked workflow is active. Default 3000ms. */
|
|
131
|
+
intervalMs?: number;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Cross-page AI-workflow progress tracking — the setup body of an app's
|
|
135
|
+
* progress store (`defineStore('ai-progress', () => createAiProgressCore(…))`).
|
|
136
|
+
* Tracks triggered workflows, polls the active ones through the injected
|
|
137
|
+
* fetch, and exposes `completionSignal` / `appliedSignal` counters pages watch
|
|
138
|
+
* to refresh their data. The dialog-request channel is generic over the app's
|
|
139
|
+
* request shape (typically `{ definition, entityId?, entityRef?, workflowId? }`).
|
|
140
|
+
*/
|
|
141
|
+
declare function createAiProgressCore<TDialogRequest>(options: AiProgressCoreOptions): {
|
|
142
|
+
trackedWorkflows: Ref<{
|
|
143
|
+
workflowId: number;
|
|
144
|
+
workflowType: string;
|
|
145
|
+
entityRef: string | null;
|
|
146
|
+
entityId?: number;
|
|
147
|
+
status: AiWorkflowStatus;
|
|
148
|
+
progress: number;
|
|
149
|
+
totalSteps: number;
|
|
150
|
+
completedSteps: number;
|
|
151
|
+
dismissed: boolean;
|
|
152
|
+
}[], TrackedWorkflow[] | {
|
|
153
|
+
workflowId: number;
|
|
154
|
+
workflowType: string;
|
|
155
|
+
entityRef: string | null;
|
|
156
|
+
entityId?: number;
|
|
157
|
+
status: AiWorkflowStatus;
|
|
158
|
+
progress: number;
|
|
159
|
+
totalSteps: number;
|
|
160
|
+
completedSteps: number;
|
|
161
|
+
dismissed: boolean;
|
|
162
|
+
}[]>;
|
|
163
|
+
activeWorkflows: import("vue").ComputedRef<{
|
|
164
|
+
workflowId: number;
|
|
165
|
+
workflowType: string;
|
|
166
|
+
entityRef: string | null;
|
|
167
|
+
entityId?: number;
|
|
168
|
+
status: AiWorkflowStatus;
|
|
169
|
+
progress: number;
|
|
170
|
+
totalSteps: number;
|
|
171
|
+
completedSteps: number;
|
|
172
|
+
dismissed: boolean;
|
|
173
|
+
}[]>;
|
|
174
|
+
hasActive: import("vue").ComputedRef<boolean>;
|
|
175
|
+
completionSignal: Ref<number, number>;
|
|
176
|
+
appliedSignal: Ref<number, number>;
|
|
177
|
+
dialogRequest: Ref<TDialogRequest | null, TDialogRequest | null>;
|
|
178
|
+
track: (workflowId: number, workflowType: string, entityRef: string | null, entityId?: number) => void;
|
|
179
|
+
dismiss: (workflowId: number) => void;
|
|
180
|
+
markApplied: (workflowId: number) => void;
|
|
181
|
+
untrack: (workflowId: number) => void;
|
|
182
|
+
getByEntityRef: (entityRef: string) => TrackedWorkflow | undefined;
|
|
183
|
+
openDialog: (request: TDialogRequest) => void;
|
|
184
|
+
closeDialog: () => void;
|
|
185
|
+
pollActive: () => Promise<void>;
|
|
186
|
+
reset: () => void;
|
|
187
|
+
};
|
|
188
|
+
type AiProgressCore<TDialogRequest> = ReturnType<typeof createAiProgressCore<TDialogRequest>>;
|
|
189
|
+
//#endregion
|
|
190
|
+
//#region src/ai/useAiCardState.d.ts
|
|
191
|
+
/** The slice of the progress store the card state machine needs. */
|
|
192
|
+
interface AiProgressLike {
|
|
193
|
+
getByEntityRef: (entityRef: string) => TrackedWorkflow | undefined;
|
|
194
|
+
dismiss: (workflowId: number) => void;
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Shared state machine for AI trigger/suggestion cards. Derives the card
|
|
198
|
+
* phase from the workflow tracked in the (injected) progress store for the
|
|
199
|
+
* given entityRef.
|
|
200
|
+
*/
|
|
201
|
+
declare function useAiCardState(store: AiProgressLike, entityRef: MaybeRefOrGetter<string>, hasActiveWorkflow?: MaybeRefOrGetter<boolean | undefined>): {
|
|
202
|
+
trackedWorkflow: import("vue").ComputedRef<TrackedWorkflow | undefined>;
|
|
203
|
+
cardState: import("vue").ComputedRef<"active" | "failed" | "idle">;
|
|
204
|
+
failedWorkflow: import("vue").ComputedRef<TrackedWorkflow | null>;
|
|
205
|
+
dismissFailure: () => void;
|
|
206
|
+
};
|
|
207
|
+
//#endregion
|
|
208
|
+
//#region src/ai/useActiveAiWorkflowProbe.d.ts
|
|
209
|
+
interface ActiveAiWorkflowProbeOptions {
|
|
210
|
+
/** The entity the probe watches; `undefined` disables checking. */
|
|
211
|
+
entityRef: MaybeRef<string | undefined>;
|
|
212
|
+
/** Report whether an active workflow exists for the entity; `null` = unknown (keep last). */
|
|
213
|
+
fetchHasActive: (entityRef: string) => Promise<boolean | null>;
|
|
214
|
+
/** Poll cadence while a workflow is active. Default 3000ms. */
|
|
215
|
+
intervalMs?: number;
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* "Is something already running for this entity?" probe: checks on mount and
|
|
219
|
+
* whenever the entity changes, then polls while active so trigger buttons can
|
|
220
|
+
* disable themselves. Transport is injected.
|
|
221
|
+
*/
|
|
222
|
+
declare function useActiveAiWorkflowProbe(options: ActiveAiWorkflowProbeOptions): {
|
|
223
|
+
hasActive: import("vue").Ref<boolean, boolean>;
|
|
224
|
+
isChecking: import("vue").Ref<boolean, boolean>;
|
|
225
|
+
refresh: () => Promise<void>;
|
|
226
|
+
};
|
|
227
|
+
//#endregion
|
|
228
|
+
//#region src/ai/registry.d.ts
|
|
229
|
+
/**
|
|
230
|
+
* Typed workflow-type registry — the app owns its definition shape (trigger
|
|
231
|
+
* API context, dynamic components, label keys); the kit owns registration and
|
|
232
|
+
* label lookup.
|
|
233
|
+
*/
|
|
234
|
+
interface WorkflowRegistryOptions {
|
|
235
|
+
/**
|
|
236
|
+
* Label-key fallbacks for types that have no registered definition
|
|
237
|
+
* (e.g. usage-only rows like embedding jobs).
|
|
238
|
+
*/
|
|
239
|
+
extraLabelKeys?: Record<string, string>;
|
|
240
|
+
}
|
|
241
|
+
declare function createWorkflowRegistry<TDefinition extends {
|
|
242
|
+
type: string;
|
|
243
|
+
labelKey: string;
|
|
244
|
+
}>(options?: WorkflowRegistryOptions): {
|
|
245
|
+
register: (definition: TDefinition) => void;
|
|
246
|
+
get: (type: string) => TDefinition | undefined;
|
|
247
|
+
getAll: () => TDefinition[];
|
|
248
|
+
getLabel: (type: string, t: (key: string) => string) => string;
|
|
249
|
+
};
|
|
250
|
+
type WorkflowRegistry<TDefinition extends {
|
|
251
|
+
type: string;
|
|
252
|
+
labelKey: string;
|
|
253
|
+
}> = ReturnType<typeof createWorkflowRegistry<TDefinition>>;
|
|
254
|
+
//#endregion
|
|
255
|
+
export { type ActiveAiWorkflowProbeOptions, type AiProgressCore, type AiProgressCoreOptions, type AiProgressLike, type AiWorkflowData, type AiWorkflowStatus, type AiWorkflowStatusSnapshot, type AiWorkflowStepData, type AiWorkflowStepStatus, type PollFn, type TrackedWorkflow, type UseAiWorkflowGuardOptions, type UseAiWorkflowGuardReturn, type UseAiWorkflowOptions, type UseAiWorkflowReturn, type WorkflowRegistry, type WorkflowRegistryOptions, createAiProgressCore, createWorkflowRegistry, isActiveStatus, isTerminalStatus, useActiveAiWorkflowProbe, useAiCardState, useAiWorkflow, useAiWorkflowGuard };
|