@vef-framework/core 2.0.11 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (152) hide show
  1. package/dist/cjs/_internal/_rolldown/runtime.cjs +1 -0
  2. package/dist/cjs/ai/index.cjs +1 -0
  3. package/dist/cjs/api/client.cjs +1 -1
  4. package/dist/cjs/api/constants.cjs +1 -1
  5. package/dist/cjs/api/helpers.cjs +1 -1
  6. package/dist/cjs/api/index.cjs +1 -1
  7. package/dist/cjs/auth/helpers.cjs +1 -1
  8. package/dist/cjs/auth/index.cjs +1 -1
  9. package/dist/cjs/context/api-client.cjs +1 -1
  10. package/dist/cjs/context/app.cjs +1 -1
  11. package/dist/cjs/context/context-selector.cjs +1 -1
  12. package/dist/cjs/context/disabled.cjs +1 -1
  13. package/dist/cjs/context/index.cjs +1 -1
  14. package/dist/cjs/dnd/index.cjs +1 -1
  15. package/dist/cjs/http/client.cjs +1 -1
  16. package/dist/cjs/http/constants.cjs +1 -0
  17. package/dist/cjs/http/errors.cjs +1 -1
  18. package/dist/cjs/http/helpers.cjs +1 -1
  19. package/dist/cjs/http/index.cjs +1 -1
  20. package/dist/cjs/immer/index.cjs +1 -1
  21. package/dist/cjs/index.cjs +1 -1
  22. package/dist/cjs/motion/features.cjs +1 -1
  23. package/dist/cjs/motion/index.cjs +1 -1
  24. package/dist/cjs/motion/motion-provider.cjs +1 -1
  25. package/dist/cjs/query/constants.cjs +1 -1
  26. package/dist/cjs/query/helpers.cjs +1 -1
  27. package/dist/cjs/query/hooks.cjs +1 -1
  28. package/dist/cjs/query/index.cjs +1 -1
  29. package/dist/cjs/sse/client.cjs +1 -0
  30. package/dist/cjs/sse/helpers.cjs +1 -0
  31. package/dist/cjs/sse/index.cjs +1 -0
  32. package/dist/cjs/state/index.cjs +1 -1
  33. package/dist/cjs/state-machine/index.cjs +1 -1
  34. package/dist/cjs/store/bound.cjs +1 -1
  35. package/dist/cjs/store/index.cjs +1 -1
  36. package/dist/cjs/store/unbound.cjs +1 -3
  37. package/dist/cjs/store/use-deep.cjs +1 -1
  38. package/dist/es/ai/index.js +3 -0
  39. package/dist/es/api/client.js +72 -147
  40. package/dist/es/api/constants.js +14 -7
  41. package/dist/es/api/helpers.js +7 -6
  42. package/dist/es/api/index.js +4 -8
  43. package/dist/es/auth/helpers.js +9 -9
  44. package/dist/es/auth/index.js +2 -4
  45. package/dist/es/context/api-client.js +21 -17
  46. package/dist/es/context/app.js +8 -8
  47. package/dist/es/context/context-selector.js +38 -50
  48. package/dist/es/context/disabled.js +9 -9
  49. package/dist/es/context/index.js +5 -13
  50. package/dist/es/dnd/index.js +8 -30
  51. package/dist/es/http/client.js +186 -359
  52. package/dist/es/http/constants.js +5 -0
  53. package/dist/es/http/errors.js +10 -15
  54. package/dist/es/http/helpers.js +8 -11
  55. package/dist/es/http/index.js +5 -11
  56. package/dist/es/immer/index.js +6 -15
  57. package/dist/es/index.js +27 -122
  58. package/dist/es/motion/features.js +3 -4
  59. package/dist/es/motion/index.js +5 -11
  60. package/dist/es/motion/motion-provider.js +22 -21
  61. package/dist/es/query/constants.js +5 -4
  62. package/dist/es/query/helpers.js +40 -54
  63. package/dist/es/query/hooks.js +18 -28
  64. package/dist/es/query/index.js +4 -14
  65. package/dist/es/sse/client.js +121 -0
  66. package/dist/es/sse/helpers.js +8 -0
  67. package/dist/es/sse/index.js +3 -0
  68. package/dist/es/state/index.js +3 -11
  69. package/dist/es/state-machine/index.js +13 -14
  70. package/dist/es/store/bound.js +18 -33
  71. package/dist/es/store/index.js +6 -11
  72. package/dist/es/store/unbound.js +43 -50
  73. package/dist/es/store/use-deep.js +12 -11
  74. package/dist/types/ai/index.d.ts +6 -0
  75. package/dist/types/api/client.d.ts +15 -35
  76. package/dist/types/api/constants.d.ts +7 -3
  77. package/dist/types/api/index.d.ts +1 -1
  78. package/dist/types/auth/helpers.d.ts +5 -5
  79. package/dist/types/auth/index.d.ts +2 -2
  80. package/dist/types/common/index.d.ts +1 -1
  81. package/dist/types/common/types.d.ts +3 -0
  82. package/dist/types/context/api-client.d.ts +9 -10
  83. package/dist/types/context/app.d.ts +9 -1
  84. package/dist/types/context/context-selector.d.ts +7 -19
  85. package/dist/types/context/disabled.d.ts +2 -2
  86. package/dist/types/context/index.d.ts +3 -2
  87. package/dist/types/context/types.d.ts +0 -1
  88. package/dist/types/dnd/index.d.ts +4 -2
  89. package/dist/types/http/client.d.ts +39 -71
  90. package/dist/types/http/constants.d.ts +24 -0
  91. package/dist/types/http/index.d.ts +2 -1
  92. package/dist/types/index.d.ts +4 -2
  93. package/dist/types/motion/index.d.ts +2 -2
  94. package/dist/types/motion/motion-provider.d.ts +8 -3
  95. package/dist/types/query/helpers.d.ts +1 -4
  96. package/dist/types/query/hooks.d.ts +6 -45
  97. package/dist/types/query/types.d.ts +12 -12
  98. package/dist/types/src/ai/index.d.ts +6 -0
  99. package/dist/types/src/api/client.d.ts +55 -0
  100. package/dist/types/src/api/constants.d.ts +12 -0
  101. package/dist/types/src/api/helpers.d.ts +9 -0
  102. package/dist/types/src/api/index.d.ts +4 -0
  103. package/dist/types/src/api/types.d.ts +48 -0
  104. package/dist/types/src/auth/helpers.d.ts +11 -0
  105. package/dist/types/src/auth/index.d.ts +2 -0
  106. package/dist/types/src/auth/types.d.ts +1 -0
  107. package/dist/types/src/common/index.d.ts +1 -0
  108. package/dist/types/src/common/types.d.ts +98 -0
  109. package/dist/types/src/context/api-client.d.ts +17 -0
  110. package/dist/types/src/context/app.d.ts +12 -0
  111. package/dist/types/src/context/context-selector.d.ts +32 -0
  112. package/dist/types/src/context/disabled.d.ts +9 -0
  113. package/dist/types/src/context/index.d.ts +6 -0
  114. package/dist/types/src/context/types.d.ts +26 -0
  115. package/dist/types/src/dnd/index.d.ts +8 -0
  116. package/dist/types/src/http/client.d.ts +112 -0
  117. package/dist/types/src/http/constants.d.ts +24 -0
  118. package/dist/types/src/http/errors.d.ts +14 -0
  119. package/dist/types/src/http/helpers.d.ts +17 -0
  120. package/dist/types/src/http/index.d.ts +5 -0
  121. package/dist/types/src/http/types.d.ts +101 -0
  122. package/dist/types/src/immer/index.d.ts +2 -0
  123. package/dist/types/src/index.d.ts +16 -0
  124. package/dist/types/src/motion/features.d.ts +1 -0
  125. package/dist/types/src/motion/index.d.ts +4 -0
  126. package/dist/types/src/motion/motion-provider.d.ts +10 -0
  127. package/dist/types/src/query/constants.d.ts +1 -0
  128. package/dist/types/src/query/helpers.d.ts +7 -0
  129. package/dist/types/src/query/hooks.d.ts +27 -0
  130. package/dist/types/src/query/index.d.ts +4 -0
  131. package/dist/types/src/query/types.d.ts +51 -0
  132. package/dist/types/src/sse/client.d.ts +16 -0
  133. package/dist/types/src/sse/helpers.d.ts +9 -0
  134. package/dist/types/src/sse/index.d.ts +3 -0
  135. package/dist/types/src/sse/types.d.ts +98 -0
  136. package/dist/types/src/state/index.d.ts +1 -0
  137. package/dist/types/src/state-machine/index.d.ts +15 -0
  138. package/dist/types/src/store/bound.d.ts +28 -0
  139. package/dist/types/src/store/index.d.ts +5 -0
  140. package/dist/types/src/store/types.d.ts +50 -0
  141. package/dist/types/src/store/unbound.d.ts +26 -0
  142. package/dist/types/src/store/use-deep.d.ts +8 -0
  143. package/dist/types/sse/client.d.ts +16 -0
  144. package/dist/types/sse/helpers.d.ts +9 -0
  145. package/dist/types/sse/index.d.ts +3 -0
  146. package/dist/types/sse/types.d.ts +98 -0
  147. package/dist/types/state-machine/index.d.ts +2 -1
  148. package/dist/types/store/unbound.d.ts +6 -6
  149. package/dist/types/store/use-deep.d.ts +4 -3
  150. package/package.json +18 -16
  151. package/dist/cjs/common/index.cjs +0 -1
  152. package/dist/es/common/index.js +0 -1
@@ -1,11 +1,6 @@
1
- import { createPersistedStore as o, createStore as t } from "./bound.js";
2
- import { createComponentStore as m } from "./unbound.js";
3
- import { useDeep as f } from "./use-deep.js";
4
- import { useShallow as x } from "zustand/shallow";
5
- export {
6
- m as createComponentStore,
7
- o as createPersistedStore,
8
- t as createStore,
9
- f as useDeep,
10
- x as useShallow
11
- };
1
+ /*! @vef-framework/core v2.1.0 made by Venus | 2026-03-27T07:13:02.254Z */
2
+ import "./bound.js";
3
+ import "./unbound.js";
4
+ import "./use-deep.js";
5
+ import { useShallow as e } from "zustand/shallow";
6
+ export { e as useShallow };
@@ -1,51 +1,44 @@
1
- import { jsx as S } from "@emotion/react/jsx-runtime";
2
- import { isPlainObject as d, mergeWith as v } from "@vef-framework/shared";
3
- import { useIsomorphicLayoutEffect as x } from "motion/react";
4
- import { createContext as g, useRef as u, use as R } from "react";
5
- import { createStore as y, useStore as C } from "zustand";
6
- import { subscribeWithSelector as b } from "zustand/middleware";
7
- import { immer as w } from "zustand/middleware/immer";
8
- const a = /* @__PURE__ */ new Map();
9
- function M(i, m) {
10
- const s = `${i}StoreContext`;
11
- let r = a.get(s);
12
- r || (r = g(null), r.displayName = s, a.set(s, r));
13
- function l(e) {
14
- const { children: o } = e, t = u(null), n = u(!1), c = u(void 0);
15
- return c.current = e.initialState, (!t.current || !n.current) && (t.current = y()(
16
- b(
17
- w(m)
18
- )
19
- ), n.current = !0), x(() => {
20
- d(c.current) && t.current && t.current.setState((h) => {
21
- v(
22
- h,
23
- c.current,
24
- !0
25
- );
26
- });
27
- }, []), /* @__PURE__ */ S(r, { value: t.current, children: o });
28
- }
29
- function f() {
30
- const e = R(r);
31
- if (!e) {
32
- const o = process.env.NODE_ENV === "development", t = `${i}Store is not found in the React context, please check if the store is wrapped in a ${i}StoreProvider`, n = o ? `
33
-
34
- Dev hint: If you're seeing this error after hot reload, it might be a React Fast Refresh issue. Try refreshing the page.` : "";
35
- throw new Error(t + n);
36
- }
37
- return e;
38
- }
39
- function p(e) {
40
- const o = f();
41
- return C(o, e);
42
- }
43
- return {
44
- StoreProvider: l,
45
- useStoreApi: f,
46
- useStore: p
47
- };
1
+ /*! @vef-framework/core v2.1.0 made by Venus | 2026-03-27T07:13:02.254Z */
2
+ import { isPlainObject as e, mergeWith as t } from "@vef-framework/shared";
3
+ import { createContext as n, use as r, useRef as i } from "react";
4
+ import { jsx as a } from "@emotion/react/jsx-runtime";
5
+ import { useIsomorphicLayoutEffect as o } from "motion/react";
6
+ import { createStore as s, useStore as c } from "zustand";
7
+ import { subscribeWithSelector as l } from "zustand/middleware";
8
+ import { immer as u } from "zustand/middleware/immer";
9
+ //#region src/store/unbound.tsx
10
+ var d = /* @__PURE__ */ new Map();
11
+ function f(f, p) {
12
+ let m = `${f}StoreContext`, h = d.get(m);
13
+ h || (h = n(null), h.displayName = m, d.set(m, h));
14
+ let g = h;
15
+ function _({ children: n, initialState: r }) {
16
+ let c = i(null), d = i(!1), f = i(r);
17
+ return f.current = r, (!c.current || !d.current) && (c.current = s()(l(u(p))), d.current = !0), o(() => {
18
+ !e(f.current) || !c.current || c.current.setState((e) => {
19
+ t(e, f.current, !0);
20
+ });
21
+ }, []), /* @__PURE__ */ a(g, {
22
+ value: c.current,
23
+ children: n
24
+ });
25
+ }
26
+ function v() {
27
+ let e = r(g);
28
+ if (!e) {
29
+ let e = `${f}Store is not found in the React context. Ensure the component is wrapped in ${f}StoreProvider.`;
30
+ throw Error(e + "");
31
+ }
32
+ return e;
33
+ }
34
+ function y(e) {
35
+ return c(v(), e);
36
+ }
37
+ return {
38
+ StoreProvider: _,
39
+ useStoreApi: v,
40
+ useStore: y
41
+ };
48
42
  }
49
- export {
50
- M as createComponentStore
51
- };
43
+ //#endregion
44
+ export { f as createComponentStore };
@@ -1,12 +1,13 @@
1
- import { isDeepEqual as u } from "@vef-framework/shared";
2
- import { useRef as o } from "react";
3
- function f(t) {
4
- const e = o(null);
5
- return (n) => {
6
- const r = t(n);
7
- return u(e.current, r) ? e.current : e.current = r;
8
- };
1
+ /*! @vef-framework/core v2.1.0 made by Venus | 2026-03-27T07:13:02.254Z */
2
+ import { isDeepEqual as e } from "@vef-framework/shared";
3
+ import { useRef as t } from "react";
4
+ //#region src/store/use-deep.ts
5
+ function n(n) {
6
+ let r = t(null);
7
+ return (t) => {
8
+ let i = n(t);
9
+ return e(r.current, i) ? r.current : (r.current = i, i);
10
+ };
9
11
  }
10
- export {
11
- f as useDeep
12
- };
12
+ //#endregion
13
+ export { n as useDeep };
@@ -0,0 +1,6 @@
1
+ export { DefaultChatTransport, TextStreamChatTransport, type ChatTransport } from 'ai';
2
+ export type { DataUIPart, DynamicToolUIPart, FileUIPart, ReasoningUIPart, SourceDocumentUIPart, SourceUrlUIPart, StepStartUIPart, TextUIPart, ToolUIPart, UIMessage, UIMessageChunk, UIMessagePart } from 'ai';
3
+ export type { UIToolInvocation, UITools } from 'ai';
4
+ export { getToolName, getToolOrDynamicToolName } from 'ai';
5
+ export { isDataUIPart, isFileUIPart, isReasoningUIPart, isTextUIPart, isToolOrDynamicToolUIPart, isToolUIPart } from 'ai';
6
+ export { isDeepEqualData, parsePartialJson } from 'ai';
@@ -2,66 +2,46 @@ import { FetchQueryOptions, MutationOptions, QueryClient, QueryMeta } from '@tan
2
2
  import { Awaitable, Except, If, IsNever, IsOptional } from '@vef-framework/shared';
3
3
  import { HttpClient } from '../http';
4
4
  import { ApiClientOptions, MutationFunction, QueryFunction, QueryKey } from './types';
5
- import { QUERY_CLIENT } from './constants';
5
+ import { HTTP_CLIENT, QUERY_CLIENT } from './constants';
6
6
  /**
7
- * The API client.
7
+ * API client that combines HttpClient and QueryClient for data fetching.
8
8
  */
9
9
  export declare class ApiClient {
10
10
  #private;
11
11
  /**
12
- * The query client.
12
+ * Access the underlying QueryClient.
13
13
  */
14
14
  get [QUERY_CLIENT](): QueryClient;
15
15
  /**
16
- * Creates a new API client.
17
- *
18
- * @param options - The options for the API client.
16
+ * Access the underlying HttpClient.
19
17
  */
18
+ get [HTTP_CLIENT](): Readonly<HttpClient>;
20
19
  constructor(options: ApiClientOptions);
21
20
  /**
22
- * Creates a new query function.
23
- *
24
- * @param key - The key of the query function.
25
- * @param factory - The factory function.
26
- * @returns The query function.
21
+ * Create a proxied HttpClient that injects the current abort signal.
22
+ */
23
+ private createProxiedHttpClient;
24
+ /**
25
+ * Create a query function with automatic signal injection.
27
26
  */
28
27
  createQueryFn<TResult = unknown, TParams = never, TPageParam = never>(key: string, factory: (http: Readonly<HttpClient>) => (queryParams: TParams, pageParam: TPageParam, meta?: QueryMeta) => Awaitable<TResult>): QueryFunction<TResult, TParams, TPageParam>;
29
28
  /**
30
- * Creates a new mutation function.
31
- *
32
- * @param key - The key of the mutation function.
33
- * @param factory - The factory function.
34
- * @returns The mutation function.
29
+ * Create a mutation function.
35
30
  */
36
31
  createMutationFn<TResult = unknown, TParams = never>(key: string, factory: (http: Readonly<HttpClient>) => (params: TParams) => Awaitable<TResult>): MutationFunction<TResult, TParams>;
37
32
  /**
38
- * Fetches a query.
39
- *
40
- * @param options - The options for the query.
41
- * @returns The result of the query.
33
+ * Fetch a query and return the result.
42
34
  */
43
35
  fetchQuery<TQueryFnData = unknown, TData = TQueryFnData, TParams = unknown, TPageParam = never>(options: Except<FetchQueryOptions<TQueryFnData, Error, TData, QueryKey<TParams>, TPageParam>, "queryHash" | "queryKeyHashFn">): Promise<TData>;
44
36
  /**
45
- * Prefetches a query and stores the result in cache.
46
- *
47
- * @param options - The options for the query.
48
- * @returns A promise that resolves when the prefetch is complete.
37
+ * Prefetch a query and store the result in cache.
49
38
  */
50
39
  prefetchQuery<TQueryFnData = unknown, TData = TQueryFnData, TParams = unknown, TPageParam = never>(options: Except<FetchQueryOptions<TQueryFnData, Error, TData, QueryKey<TParams>, TPageParam>, "queryHash" | "queryKeyHashFn">): Promise<void>;
51
40
  /**
52
- * Executes a mutation outside of React components.
41
+ * Execute a mutation imperatively outside of React components.
53
42
  *
54
- * This method allows you to execute mutations imperatively without using the `useMutation` hook.
55
43
  * Useful for scenarios like login flows, event handlers, or any code outside React components.
56
- *
57
- * @template TData - The type of data returned by the mutation
58
- * @template TParams - The type of parameters passed to the mutation function
59
- * @template TOnMutateResult - The type of result returned by onMutate callback
60
- *
61
- * @param options - The mutation options including mutationFn, onSuccess, onError, etc.
62
- * @param variables - The variables to pass to the mutation function. Omit this argument when the mutation does not require parameters.
63
- * @remarks This reuses TanStack Query's imperative mutation execution so lifecycle callbacks (onMutate, onSuccess, etc.) still fire.
64
- * @returns A promise that resolves with the mutation result
44
+ * Lifecycle callbacks (onMutate, onSuccess, etc.) still fire.
65
45
  */
66
46
  executeMutation<TData = unknown, TParams = unknown, TOnMutateResult = unknown>({ mutationFn, params, ...options }: Except<MutationOptions<TData, Error, TParams, TOnMutateResult>, "mutationKey" | "mutationFn"> & {
67
47
  mutationFn: MutationFunction<TData, TParams>;
@@ -1,8 +1,12 @@
1
1
  /**
2
- * The proxied methods.
2
+ * HTTP methods that should have the abort signal injected.
3
3
  */
4
- export declare const PROXIED_METHODS: string[];
4
+ export declare const PROXIED_METHODS: Set<string>;
5
5
  /**
6
- * The symbol for the query client.
6
+ * Symbol for accessing the query client.
7
7
  */
8
8
  export declare const QUERY_CLIENT: unique symbol;
9
+ /**
10
+ * Symbol for accessing the HTTP client.
11
+ */
12
+ export declare const HTTP_CLIENT: unique symbol;
@@ -1,4 +1,4 @@
1
1
  export { ApiClient } from './client';
2
- export { QUERY_CLIENT } from './constants';
2
+ export { HTTP_CLIENT, QUERY_CLIENT } from './constants';
3
3
  export { createApiClient } from './helpers';
4
4
  export type * from './types';
@@ -1,11 +1,11 @@
1
1
  import { MaybeArray } from '@vef-framework/shared';
2
- import { PermissionCheckMode } from './types';
2
+ import { PermissionCheckMode } from './types.js';
3
3
  /**
4
4
  * Check if the user is authorized to access the resource identified by the permission token.
5
5
  *
6
- * @param hasPermission - The function to check if the user has the permission to access the resource identified by the token.
7
- * @param permTokens - The permission tokens to check.
8
- * @param checkMode - The check mode to use.
9
- * @returns Whether the user is authorized to access the resource identified by the permission token.
6
+ * @param hasPermission - Function to check if the user has a specific permission token.
7
+ * @param permTokens - Single token or array of tokens to check. If nullish, returns true (no permission required).
8
+ * @param checkMode - "any" requires at least one token match, "all" requires all tokens to match.
9
+ * @returns True if the user has the required permission(s), false otherwise.
10
10
  */
11
11
  export declare function checkPermission(hasPermission: (token: string) => boolean, permTokens?: MaybeArray<string>, checkMode?: PermissionCheckMode): boolean;
@@ -1,2 +1,2 @@
1
- export { checkPermission } from './helpers';
2
- export type * from './types';
1
+ export { checkPermission } from './helpers.js';
2
+ export type * from './types.js';
@@ -1 +1 @@
1
- export type * from './types';
1
+ export type * from './types.js';
@@ -6,11 +6,13 @@ import { AnyObject, EmptyObject, Except, Key } from '@vef-framework/shared';
6
6
  export interface PaginationParams {
7
7
  /**
8
8
  * The page number, starting from 1
9
+ *
9
10
  * @default 1
10
11
  */
11
12
  page?: number;
12
13
  /**
13
14
  * The number of items per page
15
+ *
14
16
  * @default 15
15
17
  */
16
18
  size?: number;
@@ -48,6 +50,7 @@ export type DataOption<T = EmptyObject, M extends AnyObject = AnyObject> = T & {
48
50
  value: Key;
49
51
  /**
50
52
  * Whether the option is disabled
53
+ *
51
54
  * @default false
52
55
  */
53
56
  disabled?: boolean;
@@ -1,18 +1,17 @@
1
- import { MaybeNull, SetFieldType } from '@vef-framework/shared';
2
- import { ComponentProps, Context } from 'react';
1
+ import { PropsWithChildren } from 'react';
3
2
  import { ApiClient } from '../api';
4
- declare const Context: Context<MaybeNull<ApiClient>>;
3
+ interface ApiClientProviderProps extends PropsWithChildren {
4
+ value: ApiClient;
5
+ }
5
6
  /**
6
- * The provider for the API client.
7
- *
8
- * @param props - The props for the provider.
9
- * @returns The provider for the API client.
7
+ * Provider for the API client context.
8
+ * Wraps children with both ApiClient context and React Query's QueryClientProvider.
10
9
  */
11
- export declare function ApiClientProvider({ value, children }: SetFieldType<ComponentProps<typeof Context.Provider>, "value", ApiClient>): import("@emotion/react/jsx-runtime").JSX.Element;
10
+ export declare function ApiClientProvider({ value, children }: ApiClientProviderProps): React.JSX.Element;
12
11
  /**
13
- * The hook for the API client.
12
+ * Hook to access the API client from context.
14
13
  *
15
- * @returns The API client.
14
+ * @throws Error if used outside of ApiClientProvider.
16
15
  */
17
16
  export declare function useApiClient(): ApiClient;
18
17
  export {};
@@ -1,4 +1,12 @@
1
1
  import { AppContext } from './types';
2
- import { Provider } from 'react';
2
+ import { Context, Provider } from 'react';
3
+ declare const AppContext: Context<AppContext>;
4
+ /**
5
+ * Provider for the VEF app context.
6
+ */
3
7
  export declare const AppContextProvider: Provider<AppContext>;
8
+ /**
9
+ * Hook to access the VEF app context.
10
+ */
4
11
  export declare function useAppContext(): AppContext;
12
+ export {};
@@ -1,44 +1,32 @@
1
1
  import { ComponentType, PropsWithChildren } from 'react';
2
2
  /**
3
- * Props for the selector context provider component
3
+ * Props for the selector context provider component.
4
4
  */
5
5
  export interface SelectorContextProviderProps<TValue> extends PropsWithChildren {
6
- /**
7
- * The value to provide to child components
8
- */
9
6
  value: TValue;
10
7
  }
11
8
  /**
12
- * Context hook interface with optional selector support
9
+ * Context hook interface with optional selector support.
13
10
  */
14
11
  export interface UseSelectorContext<in out TValue> {
15
12
  /**
16
- * Use context without selector, returns the full value
13
+ * Returns the full context value.
17
14
  */
18
15
  <TStrictValue extends TValue = TValue>(): TStrictValue;
19
16
  /**
20
- * Use context with selector, returns the selected portion of the value
17
+ * Returns the selected portion of the context value.
21
18
  */
22
19
  <TStrictValue extends TValue = TValue, TSelected = TStrictValue>(selector: (value: TStrictValue) => TSelected): NoInfer<TSelected>;
23
20
  }
24
21
  /**
25
- * Result of creating a selector context
22
+ * Result of creating a selector context.
26
23
  */
27
24
  export interface SelectorContextResult<TValue> {
28
- /**
29
- * Provider component to wrap child components
30
- */
31
25
  Provider: ComponentType<SelectorContextProviderProps<TValue>>;
32
- /**
33
- * Hook to access context value with optional selector
34
- */
35
26
  useContext: UseSelectorContext<TValue>;
36
27
  }
37
28
  /**
38
- * Creates a context with selector support
39
- * Allows consuming components to select specific parts of the context value for optimal re-rendering
40
- *
41
- * @param defaultValue - The default value for the context
42
- * @returns An object containing the Provider component and useContext hook
29
+ * Creates a context with selector support for optimal re-rendering.
30
+ * Consuming components can select specific parts of the context value.
43
31
  */
44
32
  export declare function createContextWithSelector<TValue>(defaultValue: TValue): SelectorContextResult<TValue>;
@@ -1,9 +1,9 @@
1
1
  import { Provider } from 'react';
2
2
  /**
3
- * A hook to get the disabled state.
3
+ * Hook to access the disabled state from context.
4
4
  */
5
5
  export declare function useDisabled(): boolean;
6
6
  /**
7
- * A provider to provide the disabled state.
7
+ * Provider for the disabled state context.
8
8
  */
9
9
  export declare const DisabledProvider: Provider<boolean>;
@@ -1,5 +1,6 @@
1
1
  export { ApiClientProvider, useApiClient } from './api-client';
2
2
  export { AppContextProvider, useAppContext } from './app';
3
- export { createContextWithSelector, type SelectorContextProviderProps, type SelectorContextResult, type UseSelectorContext } from './context-selector';
3
+ export type { SelectorContextProviderProps, SelectorContextResult, UseSelectorContext } from './context-selector';
4
+ export { createContextWithSelector } from './context-selector';
4
5
  export { DisabledProvider, useDisabled } from './disabled';
5
- export type * from './types';
6
+ export type { AppContext } from './types';
@@ -11,7 +11,6 @@ export interface AppContext {
11
11
  * ```ts
12
12
  * const isAuthorized = hasPermission("user:query");
13
13
  * ```
14
- *
15
14
  * @param token - The permission token.
16
15
  * @returns Whether the user has the permission to access the resource identified by the token.
17
16
  */
@@ -1,6 +1,8 @@
1
1
  export { AxisModifier, restrictShapeToBoundingRectangle, RestrictToHorizontalAxis, RestrictToVerticalAxis, SnapModifier } from '@dnd-kit/abstract/modifiers';
2
2
  export { RestrictToElement, RestrictToWindow } from '@dnd-kit/dom/modifiers';
3
3
  export { arrayMove as moveArrayItem, move as moveDragItem, arraySwap as swapArrayItem, swap as swapDragItem } from '@dnd-kit/helpers';
4
- export { DragDropProvider, DragOverlay, KeyboardSensor, PointerSensor, useDragDropMonitor, useDraggable, useDroppable, type DragDropEventHandlers, type DragDropEvents } from '@dnd-kit/react';
4
+ export type { DragDropEventHandlers, DragDropEvents } from '@dnd-kit/react';
5
+ export { DragDropProvider, DragOverlay, KeyboardSensor, PointerSensor, useDragDropMonitor, useDraggable, useDroppable } from '@dnd-kit/react';
5
6
  export { useSortable } from '@dnd-kit/react/sortable';
6
- export { DragDropContext, Draggable, Droppable, type DragDropContextProps, type DraggableChildrenFn, type DraggableId, type DraggableLocation, type DraggableProps, type DraggableProvided, type DraggableProvidedDraggableProps, type DraggableProvidedDragHandleProps, type DraggableRubric, type DraggableStateSnapshot, type DroppableId, type DroppableProps, type DroppableProvided, type DroppableProvidedProps, type DroppableStateSnapshot, type DropResult, type OnBeforeCaptureResponder, type OnBeforeDragStartResponder, type OnDragEndResponder, type OnDragStartResponder, type OnDragUpdateResponder } from '@hello-pangea/dnd';
7
+ export type { DragDropContextProps, DraggableChildrenFn, DraggableId, DraggableLocation, DraggableProps, DraggableProvided, DraggableProvidedDraggableProps, DraggableProvidedDragHandleProps, DraggableRubric, DraggableStateSnapshot, DroppableId, DroppableProps, DroppableProvided, DroppableProvidedProps, DroppableStateSnapshot, DropResult, OnBeforeCaptureResponder, OnBeforeDragStartResponder, OnDragEndResponder, OnDragStartResponder, OnDragUpdateResponder } from '@hello-pangea/dnd';
8
+ export { DragDropContext, Draggable, Droppable } from '@hello-pangea/dnd';
@@ -1,13 +1,5 @@
1
1
  import { AxiosProgressEvent } from 'axios';
2
2
  import { ApiResult, HttpClientOptions, RequestOptions } from './types';
3
- /**
4
- * The header name for the skip authentication.
5
- */
6
- export declare const skipAuthenticationHeader = "X-Skip-Authentication";
7
- /**
8
- * The header value for the skip authentication.
9
- */
10
- export declare const skipAuthenticationValue = "1";
11
3
  /**
12
4
  * The HTTP client.
13
5
  */
@@ -16,113 +8,93 @@ export declare class HttpClient {
16
8
  constructor(options: HttpClientOptions);
17
9
  private initInterceptors;
18
10
  /**
19
- * Check if the code belongs to the target.
20
- *
21
- * @param code - The code.
22
- * @param target - The target.
23
- * @returns The result.
11
+ * Check if the code matches the target code(s).
24
12
  */
25
- private isBelongsTo;
13
+ private matchesCode;
26
14
  /**
27
- * Handle the request.
28
- *
29
- * @param config - The axios request config.
30
- * @returns The axios request config.
15
+ * Handle the request interceptor.
31
16
  */
32
17
  private handleRequest;
33
18
  /**
34
- * Handle the request error.
35
- *
36
- * @param error - The axios error.
19
+ * Handle the request error interceptor.
37
20
  */
38
21
  private handleRequestError;
39
22
  /**
40
- * Handle the response.
41
- *
42
- * @param response - The axios response.
43
- * @returns The axios response.
23
+ * Handle the response interceptor.
44
24
  */
45
25
  private handleResponse;
46
26
  /**
47
- * Handle the response error.
48
- *
49
- * @param error - The axios error.
27
+ * Handle the response error interceptor.
50
28
  */
51
29
  private handleResponseError;
52
30
  /**
53
- * Injects access token into request Authorization header.
54
- *
55
- * @param config - The axios request config.
31
+ * Handle 401 unauthorized response.
56
32
  */
57
- private setAccessToken;
33
+ private handleUnauthorized;
58
34
  /**
59
- * Replace the path parameters in the URL.
60
- *
61
- * @param config - The axios request config.
62
- * @returns The axios request config.
35
+ * Log info message using configured handler or console.
36
+ */
37
+ private logInfo;
38
+ /**
39
+ * Log warning message using configured handler or console.
40
+ */
41
+ private logWarning;
42
+ /**
43
+ * Log error message using configured handler or console.
44
+ */
45
+ private logError;
46
+ /**
47
+ * Inject access token into request Authorization header.
48
+ */
49
+ private injectAccessToken;
50
+ /**
51
+ * Replace path parameters in the URL (e.g., /users/:id -> /users/123).
63
52
  */
64
53
  private replacePathParams;
65
54
  /**
66
- * Try to refresh the token using the provided refresh callback.
55
+ * Ensure the token is refreshed. Can be called proactively by external code
56
+ * (e.g., fetch-based SSE) to refresh token before/after request.
67
57
  *
58
+ * @param triggerCallback - Whether to trigger onUnauthenticated callback on failure.
68
59
  * @returns True if token refresh succeeded, false otherwise.
69
60
  */
61
+ ensureTokenRefreshed(triggerCallback?: boolean): Promise<boolean>;
62
+ /**
63
+ * Try to refresh the token using the provided refresh callback.
64
+ */
70
65
  private tryRefreshToken;
71
66
  /**
72
- * Retry the request.
73
- *
74
- * @param config - The axios request config.
75
- * @returns The axios response.
67
+ * Retry the request with refreshed token.
76
68
  */
77
69
  private retryRequest;
78
70
  /**
79
- * Get the resource.
80
- *
81
- * @param url - The url.
82
- * @param options - The options for the request.
83
- * @returns The response data.
71
+ * GET request.
84
72
  */
85
73
  get<R = unknown, P = unknown>(url: string, options?: RequestOptions & {
86
74
  params?: P;
87
75
  }): Promise<ApiResult<R>>;
88
76
  /**
89
- * Post the resource.
90
- *
91
- * @param url - The url.
92
- * @param options - The options for the request.
93
- * @returns The response data.
77
+ * POST request.
94
78
  */
95
79
  post<R = unknown, D = unknown, P = unknown>(url: string, options?: RequestOptions & {
96
80
  data?: D;
97
81
  params?: P;
98
82
  }): Promise<ApiResult<R>>;
99
83
  /**
100
- * Update the resource.
101
- *
102
- * @param url - The url.
103
- * @param options - The options for the request.
104
- * @returns The response data.
84
+ * PUT request.
105
85
  */
106
86
  put<R = unknown, D = unknown, P = unknown>(url: string, options?: RequestOptions & {
107
87
  data?: D;
108
88
  params?: P;
109
89
  }): Promise<ApiResult<R>>;
110
90
  /**
111
- * Delete the resource.
112
- *
113
- * @param url - The url.
114
- * @param options - The options for the request.
115
- * @returns The response data.
91
+ * DELETE request.
116
92
  */
117
93
  delete<R = unknown, P = unknown>(url: string, options?: RequestOptions & {
118
94
  params?: P;
119
95
  }): Promise<ApiResult<R>>;
120
96
  /**
121
- * Upload the file.
122
- *
123
- * @param url - The url.
124
- * @param options - The options for the request.
125
- * @returns The response data.
97
+ * Upload file via multipart/form-data.
126
98
  */
127
99
  upload<R = unknown, P = unknown>(url: string, options?: RequestOptions & {
128
100
  params?: P;
@@ -130,11 +102,7 @@ export declare class HttpClient {
130
102
  onProgress?: (event: AxiosProgressEvent) => void;
131
103
  }): Promise<ApiResult<R>>;
132
104
  /**
133
- * Download the file.
134
- *
135
- * @param url - The url.
136
- * @param options - The options for the request.
137
- * @returns The response data.
105
+ * Download file as blob and trigger browser download.
138
106
  */
139
107
  download<P = unknown>(url: string, options?: RequestOptions & {
140
108
  params?: P;