enlace 0.0.0-alpha.4 → 0.0.1-beta.1

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/index.d.mts CHANGED
@@ -1,121 +1,97 @@
1
- type HttpMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
2
- type SchemaMethod = "$get" | "$post" | "$put" | "$patch" | "$delete";
3
- type EnlaceResponse<TData, TError> = {
4
- ok: true;
5
- status: number;
6
- data: TData;
7
- error?: never;
8
- } | {
9
- ok: false;
10
- status: number;
11
- data?: never;
12
- error: TError;
13
- };
14
- type EnlaceOptions = Omit<RequestInit, "method" | "body">;
15
- type FetchExecutor<TOptions = EnlaceOptions, TRequestOptions = RequestOptions<unknown>> = <TData, TError>(baseUrl: string, path: string[], method: HttpMethod, defaultOptions: TOptions, requestOptions?: TRequestOptions) => Promise<EnlaceResponse<TData, TError>>;
16
- type RequestOptions<TBody = never> = {
17
- body?: TBody;
18
- query?: Record<string, string | number | boolean | undefined>;
19
- headers?: HeadersInit;
20
- cache?: RequestCache;
1
+ import { WildcardClient, EnlaceClient, EnlaceResponse, EnlaceOptions } from 'enlace-core';
2
+ export * from 'enlace-core';
3
+
4
+ /** Per-request options for React hooks */
5
+ type ReactRequestOptionsBase = {
6
+ /**
7
+ * Cache tags for caching (GET requests only)
8
+ * This will auto generate tags from the URL path if not provided and autoGenerateTags is enabled.
9
+ * But can be manually specified to override auto-generation.
10
+ * */
11
+ tags?: string[];
12
+ /** Tags to invalidate after mutation (triggers refetch in matching queries) */
13
+ revalidateTags?: string[];
21
14
  };
22
- type MethodDefinition = {
15
+ type ApiClient<TSchema, TOptions = ReactRequestOptionsBase> = unknown extends TSchema ? WildcardClient<TOptions> : EnlaceClient<TSchema, TOptions>;
16
+ type QueryFn<TSchema, TData, TError, TOptions = ReactRequestOptionsBase> = (api: ApiClient<TSchema, TOptions>) => Promise<EnlaceResponse<TData, TError>>;
17
+ type SelectorFn<TSchema, TMethod, TOptions = ReactRequestOptionsBase> = (api: ApiClient<TSchema, TOptions>) => TMethod;
18
+ type HookState = {
19
+ loading: boolean;
20
+ fetching: boolean;
21
+ ok: boolean | undefined;
23
22
  data: unknown;
24
23
  error: unknown;
25
- body?: unknown;
26
24
  };
27
- /**
28
- * Helper to define an endpoint with proper typing.
29
- * Provides cleaner syntax than writing { data, error, body } manually.
30
- *
31
- * @example
32
- * type MyApi = {
33
- * posts: {
34
- * $get: Endpoint<Post[], ApiError>;
35
- * $post: Endpoint<Post, ApiError, CreatePost>; // with body
36
- * _: {
37
- * $get: Endpoint<Post, NotFoundError>;
38
- * };
39
- * };
40
- * };
41
- */
42
- type Endpoint<TData, TError, TBody = never> = [TBody] extends [never] ? {
43
- data: TData;
44
- error: TError;
45
- } : {
25
+ type TrackedCall = {
26
+ path: string[];
27
+ method: string;
28
+ options: unknown;
29
+ };
30
+ declare const HTTP_METHODS: readonly ["get", "post", "put", "patch", "delete"];
31
+ type ExtractData<T> = T extends (...args: any[]) => Promise<EnlaceResponse<infer D, unknown>> ? D : never;
32
+ type ExtractError<T> = T extends (...args: any[]) => Promise<EnlaceResponse<unknown, infer E>> ? E : never;
33
+ /** Discriminated union for hook response state - enables type narrowing on ok check */
34
+ type HookResponseState<TData, TError> = {
35
+ ok: undefined;
36
+ data: undefined;
37
+ error: undefined;
38
+ } | {
39
+ ok: true;
46
40
  data: TData;
41
+ error: undefined;
42
+ } | {
43
+ ok: false;
44
+ data: undefined;
47
45
  error: TError;
48
- body: TBody;
49
- };
50
- type ExtractMethodDef<TSchema, TMethod extends SchemaMethod> = TSchema extends {
51
- [K in TMethod]: infer M;
52
- } ? M extends MethodDefinition ? M : never : never;
53
- type ExtractData<TSchema, TMethod extends SchemaMethod> = ExtractMethodDef<TSchema, TMethod> extends {
54
- data: infer D;
55
- } ? D : never;
56
- type ExtractError<TSchema, TMethod extends SchemaMethod> = ExtractMethodDef<TSchema, TMethod> extends {
57
- error: infer E;
58
- } ? E : never;
59
- type ExtractBody<TSchema, TMethod extends SchemaMethod> = ExtractMethodDef<TSchema, TMethod> extends {
60
- body: infer B;
61
- } ? B : never;
62
- type HasMethod<TSchema, TMethod extends SchemaMethod> = TSchema extends {
63
- [K in TMethod]: MethodDefinition;
64
- } ? true : false;
65
- type MethodFn<TSchema, TMethod extends SchemaMethod, TRequestOptionsBase = object> = HasMethod<TSchema, TMethod> extends true ? ExtractBody<TSchema, TMethod> extends never ? (options?: RequestOptions<never> & TRequestOptionsBase) => Promise<EnlaceResponse<ExtractData<TSchema, TMethod>, ExtractError<TSchema, TMethod>>> : (options: RequestOptions<ExtractBody<TSchema, TMethod>> & TRequestOptionsBase) => Promise<EnlaceResponse<ExtractData<TSchema, TMethod>, ExtractError<TSchema, TMethod>>> : never;
66
- type IsSpecialKey<K> = K extends SchemaMethod | "_" ? true : false;
67
- type StaticPathKeys<TSchema> = {
68
- [K in keyof TSchema as IsSpecialKey<K> extends true ? never : K extends string ? K : never]: TSchema[K];
69
46
  };
70
- type ExtractDynamicSchema<TSchema> = TSchema extends {
71
- _: infer D;
72
- } ? D : never;
73
- type MethodOrPath<TSchema, TMethodName extends string, TSchemaMethod extends SchemaMethod, TRequestOptionsBase = object> = TMethodName extends keyof TSchema ? EnlaceClient<TSchema[TMethodName], TRequestOptionsBase> : MethodFn<TSchema, TSchemaMethod, TRequestOptionsBase>;
74
- type HttpMethods<TSchema, TRequestOptionsBase = object> = {
75
- get: MethodOrPath<TSchema, "get", "$get", TRequestOptionsBase>;
76
- post: MethodOrPath<TSchema, "post", "$post", TRequestOptionsBase>;
77
- put: MethodOrPath<TSchema, "put", "$put", TRequestOptionsBase>;
78
- patch: MethodOrPath<TSchema, "patch", "$patch", TRequestOptionsBase>;
79
- delete: MethodOrPath<TSchema, "delete", "$delete", TRequestOptionsBase>;
80
- };
81
- type DynamicAccess<TSchema, TRequestOptionsBase = object> = ExtractDynamicSchema<TSchema> extends never ? object : {
82
- [key: string]: EnlaceClient<ExtractDynamicSchema<TSchema>, TRequestOptionsBase>;
83
- [key: number]: EnlaceClient<ExtractDynamicSchema<TSchema>, TRequestOptionsBase>;
47
+ /** Result when hook is called with query function (auto-fetch mode) */
48
+ type UseEnlaceQueryResult<TData, TError> = {
49
+ loading: boolean;
50
+ fetching: boolean;
51
+ } & HookResponseState<TData, TError>;
52
+ /** Result when hook is called with method selector (trigger mode) */
53
+ type UseEnlaceSelectorResult<TMethod> = {
54
+ trigger: TMethod;
55
+ loading: boolean;
56
+ fetching: boolean;
57
+ } & HookResponseState<ExtractData<TMethod>, ExtractError<TMethod>>;
58
+
59
+ type EnlaceHookOptions = {
60
+ /**
61
+ * Auto-generate cache tags from URL path for GET requests.
62
+ * e.g., `/posts/1` generates tags `['posts', 'posts/1']`
63
+ * @default true
64
+ */
65
+ autoGenerateTags?: boolean;
66
+ /** Auto-revalidate generated tags after successful mutations. @default true */
67
+ autoRevalidateTags?: boolean;
68
+ /** Time in ms before cached data is considered stale. @default 0 (always stale) */
69
+ staleTime?: number;
84
70
  };
85
- type MethodNameKeys = "get" | "post" | "put" | "patch" | "delete";
86
- type EnlaceClient<TSchema, TRequestOptionsBase = object> = HttpMethods<TSchema, TRequestOptionsBase> & DynamicAccess<TSchema, TRequestOptionsBase> & {
87
- [K in keyof StaticPathKeys<TSchema> as K extends MethodNameKeys ? never : K]: EnlaceClient<TSchema[K], TRequestOptionsBase>;
71
+ type EnlaceHook<TSchema> = {
72
+ <TMethod extends (...args: any[]) => Promise<EnlaceResponse<unknown, unknown>>>(selector: SelectorFn<TSchema, TMethod>): UseEnlaceSelectorResult<TMethod>;
73
+ <TData, TError>(queryFn: QueryFn<TSchema, TData, TError>): UseEnlaceQueryResult<TData, TError>;
88
74
  };
89
- type WildcardMethodFn<TRequestOptionsBase = object> = (options?: RequestOptions<unknown> & TRequestOptionsBase) => Promise<EnlaceResponse<unknown, unknown>>;
90
75
  /**
91
- * Wildcard client type - allows any path access when no schema is provided.
92
- * All methods are available at every level and return unknown types.
93
- */
94
- type WildcardClient<TRequestOptionsBase = object> = {
95
- get: WildcardMethodFn<TRequestOptionsBase>;
96
- post: WildcardMethodFn<TRequestOptionsBase>;
97
- put: WildcardMethodFn<TRequestOptionsBase>;
98
- patch: WildcardMethodFn<TRequestOptionsBase>;
99
- delete: WildcardMethodFn<TRequestOptionsBase>;
100
- } & {
101
- [key: string]: WildcardClient<TRequestOptionsBase>;
102
- [key: number]: WildcardClient<TRequestOptionsBase>;
103
- };
104
-
105
- declare function createProxyHandler<TSchema extends object, TOptions = EnlaceOptions>(baseUrl: string, defaultOptions: TOptions, path?: string[], fetchExecutor?: FetchExecutor<TOptions, RequestOptions<unknown>>): TSchema;
106
-
107
- declare function executeFetch<TData, TError>(baseUrl: string, path: string[], method: HttpMethod, defaultOptions: EnlaceOptions, requestOptions?: RequestOptions<unknown>): Promise<EnlaceResponse<TData, TError>>;
108
-
109
- /**
110
- * Creates an API client.
76
+ * Creates a React hook for making API calls.
77
+ * Called at module level to create a reusable hook.
111
78
  *
112
79
  * @example
113
- * // Typed mode - with schema
114
- * const api = createEnlace<MyApi>('https://api.example.com');
80
+ * const useAPI = createEnlaceHook<ApiSchema>('https://api.com');
115
81
  *
116
- * // Untyped mode - no schema
117
- * const api = createEnlace('https://api.example.com');
82
+ * // Query mode - auto-fetch (auto-tracks changes, no deps array needed)
83
+ * const { loading, data, error } = useAPI((api) => api.posts.get({ query: { userId } }));
84
+ *
85
+ * // Selector mode - typed trigger for lazy calls
86
+ * const { trigger, loading, data, error } = useAPI((api) => api.posts.delete);
87
+ * onClick={() => trigger({ body: { id: 1 } })}
118
88
  */
119
- declare function createEnlace<TSchema = unknown>(baseUrl: string, defaultOptions?: EnlaceOptions): unknown extends TSchema ? WildcardClient : EnlaceClient<TSchema>;
89
+ declare function createEnlaceHook<TSchema = unknown>(baseUrl: string, defaultOptions?: EnlaceOptions, hookOptions?: EnlaceHookOptions): EnlaceHook<TSchema>;
90
+
91
+ type Listener = (tags: string[]) => void;
92
+ declare function invalidateTags(tags: string[]): void;
93
+ declare function onRevalidate(callback: Listener): () => void;
94
+
95
+ declare function clearCache(key?: string): void;
120
96
 
121
- export { type Endpoint, type EnlaceClient, type EnlaceOptions, type EnlaceResponse, type FetchExecutor, type HttpMethod, type MethodDefinition, type RequestOptions, type SchemaMethod, type WildcardClient, createEnlace, createProxyHandler, executeFetch };
97
+ export { type ApiClient, type EnlaceHookOptions, HTTP_METHODS, type HookState, type QueryFn, type ReactRequestOptionsBase, type SelectorFn, type TrackedCall, type UseEnlaceQueryResult, type UseEnlaceSelectorResult, clearCache, createEnlaceHook, invalidateTags, onRevalidate };
package/dist/index.d.ts CHANGED
@@ -1,121 +1,97 @@
1
- type HttpMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
2
- type SchemaMethod = "$get" | "$post" | "$put" | "$patch" | "$delete";
3
- type EnlaceResponse<TData, TError> = {
4
- ok: true;
5
- status: number;
6
- data: TData;
7
- error?: never;
8
- } | {
9
- ok: false;
10
- status: number;
11
- data?: never;
12
- error: TError;
13
- };
14
- type EnlaceOptions = Omit<RequestInit, "method" | "body">;
15
- type FetchExecutor<TOptions = EnlaceOptions, TRequestOptions = RequestOptions<unknown>> = <TData, TError>(baseUrl: string, path: string[], method: HttpMethod, defaultOptions: TOptions, requestOptions?: TRequestOptions) => Promise<EnlaceResponse<TData, TError>>;
16
- type RequestOptions<TBody = never> = {
17
- body?: TBody;
18
- query?: Record<string, string | number | boolean | undefined>;
19
- headers?: HeadersInit;
20
- cache?: RequestCache;
1
+ import { WildcardClient, EnlaceClient, EnlaceResponse, EnlaceOptions } from 'enlace-core';
2
+ export * from 'enlace-core';
3
+
4
+ /** Per-request options for React hooks */
5
+ type ReactRequestOptionsBase = {
6
+ /**
7
+ * Cache tags for caching (GET requests only)
8
+ * This will auto generate tags from the URL path if not provided and autoGenerateTags is enabled.
9
+ * But can be manually specified to override auto-generation.
10
+ * */
11
+ tags?: string[];
12
+ /** Tags to invalidate after mutation (triggers refetch in matching queries) */
13
+ revalidateTags?: string[];
21
14
  };
22
- type MethodDefinition = {
15
+ type ApiClient<TSchema, TOptions = ReactRequestOptionsBase> = unknown extends TSchema ? WildcardClient<TOptions> : EnlaceClient<TSchema, TOptions>;
16
+ type QueryFn<TSchema, TData, TError, TOptions = ReactRequestOptionsBase> = (api: ApiClient<TSchema, TOptions>) => Promise<EnlaceResponse<TData, TError>>;
17
+ type SelectorFn<TSchema, TMethod, TOptions = ReactRequestOptionsBase> = (api: ApiClient<TSchema, TOptions>) => TMethod;
18
+ type HookState = {
19
+ loading: boolean;
20
+ fetching: boolean;
21
+ ok: boolean | undefined;
23
22
  data: unknown;
24
23
  error: unknown;
25
- body?: unknown;
26
24
  };
27
- /**
28
- * Helper to define an endpoint with proper typing.
29
- * Provides cleaner syntax than writing { data, error, body } manually.
30
- *
31
- * @example
32
- * type MyApi = {
33
- * posts: {
34
- * $get: Endpoint<Post[], ApiError>;
35
- * $post: Endpoint<Post, ApiError, CreatePost>; // with body
36
- * _: {
37
- * $get: Endpoint<Post, NotFoundError>;
38
- * };
39
- * };
40
- * };
41
- */
42
- type Endpoint<TData, TError, TBody = never> = [TBody] extends [never] ? {
43
- data: TData;
44
- error: TError;
45
- } : {
25
+ type TrackedCall = {
26
+ path: string[];
27
+ method: string;
28
+ options: unknown;
29
+ };
30
+ declare const HTTP_METHODS: readonly ["get", "post", "put", "patch", "delete"];
31
+ type ExtractData<T> = T extends (...args: any[]) => Promise<EnlaceResponse<infer D, unknown>> ? D : never;
32
+ type ExtractError<T> = T extends (...args: any[]) => Promise<EnlaceResponse<unknown, infer E>> ? E : never;
33
+ /** Discriminated union for hook response state - enables type narrowing on ok check */
34
+ type HookResponseState<TData, TError> = {
35
+ ok: undefined;
36
+ data: undefined;
37
+ error: undefined;
38
+ } | {
39
+ ok: true;
46
40
  data: TData;
41
+ error: undefined;
42
+ } | {
43
+ ok: false;
44
+ data: undefined;
47
45
  error: TError;
48
- body: TBody;
49
- };
50
- type ExtractMethodDef<TSchema, TMethod extends SchemaMethod> = TSchema extends {
51
- [K in TMethod]: infer M;
52
- } ? M extends MethodDefinition ? M : never : never;
53
- type ExtractData<TSchema, TMethod extends SchemaMethod> = ExtractMethodDef<TSchema, TMethod> extends {
54
- data: infer D;
55
- } ? D : never;
56
- type ExtractError<TSchema, TMethod extends SchemaMethod> = ExtractMethodDef<TSchema, TMethod> extends {
57
- error: infer E;
58
- } ? E : never;
59
- type ExtractBody<TSchema, TMethod extends SchemaMethod> = ExtractMethodDef<TSchema, TMethod> extends {
60
- body: infer B;
61
- } ? B : never;
62
- type HasMethod<TSchema, TMethod extends SchemaMethod> = TSchema extends {
63
- [K in TMethod]: MethodDefinition;
64
- } ? true : false;
65
- type MethodFn<TSchema, TMethod extends SchemaMethod, TRequestOptionsBase = object> = HasMethod<TSchema, TMethod> extends true ? ExtractBody<TSchema, TMethod> extends never ? (options?: RequestOptions<never> & TRequestOptionsBase) => Promise<EnlaceResponse<ExtractData<TSchema, TMethod>, ExtractError<TSchema, TMethod>>> : (options: RequestOptions<ExtractBody<TSchema, TMethod>> & TRequestOptionsBase) => Promise<EnlaceResponse<ExtractData<TSchema, TMethod>, ExtractError<TSchema, TMethod>>> : never;
66
- type IsSpecialKey<K> = K extends SchemaMethod | "_" ? true : false;
67
- type StaticPathKeys<TSchema> = {
68
- [K in keyof TSchema as IsSpecialKey<K> extends true ? never : K extends string ? K : never]: TSchema[K];
69
46
  };
70
- type ExtractDynamicSchema<TSchema> = TSchema extends {
71
- _: infer D;
72
- } ? D : never;
73
- type MethodOrPath<TSchema, TMethodName extends string, TSchemaMethod extends SchemaMethod, TRequestOptionsBase = object> = TMethodName extends keyof TSchema ? EnlaceClient<TSchema[TMethodName], TRequestOptionsBase> : MethodFn<TSchema, TSchemaMethod, TRequestOptionsBase>;
74
- type HttpMethods<TSchema, TRequestOptionsBase = object> = {
75
- get: MethodOrPath<TSchema, "get", "$get", TRequestOptionsBase>;
76
- post: MethodOrPath<TSchema, "post", "$post", TRequestOptionsBase>;
77
- put: MethodOrPath<TSchema, "put", "$put", TRequestOptionsBase>;
78
- patch: MethodOrPath<TSchema, "patch", "$patch", TRequestOptionsBase>;
79
- delete: MethodOrPath<TSchema, "delete", "$delete", TRequestOptionsBase>;
80
- };
81
- type DynamicAccess<TSchema, TRequestOptionsBase = object> = ExtractDynamicSchema<TSchema> extends never ? object : {
82
- [key: string]: EnlaceClient<ExtractDynamicSchema<TSchema>, TRequestOptionsBase>;
83
- [key: number]: EnlaceClient<ExtractDynamicSchema<TSchema>, TRequestOptionsBase>;
47
+ /** Result when hook is called with query function (auto-fetch mode) */
48
+ type UseEnlaceQueryResult<TData, TError> = {
49
+ loading: boolean;
50
+ fetching: boolean;
51
+ } & HookResponseState<TData, TError>;
52
+ /** Result when hook is called with method selector (trigger mode) */
53
+ type UseEnlaceSelectorResult<TMethod> = {
54
+ trigger: TMethod;
55
+ loading: boolean;
56
+ fetching: boolean;
57
+ } & HookResponseState<ExtractData<TMethod>, ExtractError<TMethod>>;
58
+
59
+ type EnlaceHookOptions = {
60
+ /**
61
+ * Auto-generate cache tags from URL path for GET requests.
62
+ * e.g., `/posts/1` generates tags `['posts', 'posts/1']`
63
+ * @default true
64
+ */
65
+ autoGenerateTags?: boolean;
66
+ /** Auto-revalidate generated tags after successful mutations. @default true */
67
+ autoRevalidateTags?: boolean;
68
+ /** Time in ms before cached data is considered stale. @default 0 (always stale) */
69
+ staleTime?: number;
84
70
  };
85
- type MethodNameKeys = "get" | "post" | "put" | "patch" | "delete";
86
- type EnlaceClient<TSchema, TRequestOptionsBase = object> = HttpMethods<TSchema, TRequestOptionsBase> & DynamicAccess<TSchema, TRequestOptionsBase> & {
87
- [K in keyof StaticPathKeys<TSchema> as K extends MethodNameKeys ? never : K]: EnlaceClient<TSchema[K], TRequestOptionsBase>;
71
+ type EnlaceHook<TSchema> = {
72
+ <TMethod extends (...args: any[]) => Promise<EnlaceResponse<unknown, unknown>>>(selector: SelectorFn<TSchema, TMethod>): UseEnlaceSelectorResult<TMethod>;
73
+ <TData, TError>(queryFn: QueryFn<TSchema, TData, TError>): UseEnlaceQueryResult<TData, TError>;
88
74
  };
89
- type WildcardMethodFn<TRequestOptionsBase = object> = (options?: RequestOptions<unknown> & TRequestOptionsBase) => Promise<EnlaceResponse<unknown, unknown>>;
90
75
  /**
91
- * Wildcard client type - allows any path access when no schema is provided.
92
- * All methods are available at every level and return unknown types.
93
- */
94
- type WildcardClient<TRequestOptionsBase = object> = {
95
- get: WildcardMethodFn<TRequestOptionsBase>;
96
- post: WildcardMethodFn<TRequestOptionsBase>;
97
- put: WildcardMethodFn<TRequestOptionsBase>;
98
- patch: WildcardMethodFn<TRequestOptionsBase>;
99
- delete: WildcardMethodFn<TRequestOptionsBase>;
100
- } & {
101
- [key: string]: WildcardClient<TRequestOptionsBase>;
102
- [key: number]: WildcardClient<TRequestOptionsBase>;
103
- };
104
-
105
- declare function createProxyHandler<TSchema extends object, TOptions = EnlaceOptions>(baseUrl: string, defaultOptions: TOptions, path?: string[], fetchExecutor?: FetchExecutor<TOptions, RequestOptions<unknown>>): TSchema;
106
-
107
- declare function executeFetch<TData, TError>(baseUrl: string, path: string[], method: HttpMethod, defaultOptions: EnlaceOptions, requestOptions?: RequestOptions<unknown>): Promise<EnlaceResponse<TData, TError>>;
108
-
109
- /**
110
- * Creates an API client.
76
+ * Creates a React hook for making API calls.
77
+ * Called at module level to create a reusable hook.
111
78
  *
112
79
  * @example
113
- * // Typed mode - with schema
114
- * const api = createEnlace<MyApi>('https://api.example.com');
80
+ * const useAPI = createEnlaceHook<ApiSchema>('https://api.com');
115
81
  *
116
- * // Untyped mode - no schema
117
- * const api = createEnlace('https://api.example.com');
82
+ * // Query mode - auto-fetch (auto-tracks changes, no deps array needed)
83
+ * const { loading, data, error } = useAPI((api) => api.posts.get({ query: { userId } }));
84
+ *
85
+ * // Selector mode - typed trigger for lazy calls
86
+ * const { trigger, loading, data, error } = useAPI((api) => api.posts.delete);
87
+ * onClick={() => trigger({ body: { id: 1 } })}
118
88
  */
119
- declare function createEnlace<TSchema = unknown>(baseUrl: string, defaultOptions?: EnlaceOptions): unknown extends TSchema ? WildcardClient : EnlaceClient<TSchema>;
89
+ declare function createEnlaceHook<TSchema = unknown>(baseUrl: string, defaultOptions?: EnlaceOptions, hookOptions?: EnlaceHookOptions): EnlaceHook<TSchema>;
90
+
91
+ type Listener = (tags: string[]) => void;
92
+ declare function invalidateTags(tags: string[]): void;
93
+ declare function onRevalidate(callback: Listener): () => void;
94
+
95
+ declare function clearCache(key?: string): void;
120
96
 
121
- export { type Endpoint, type EnlaceClient, type EnlaceOptions, type EnlaceResponse, type FetchExecutor, type HttpMethod, type MethodDefinition, type RequestOptions, type SchemaMethod, type WildcardClient, createEnlace, createProxyHandler, executeFetch };
97
+ export { type ApiClient, type EnlaceHookOptions, HTTP_METHODS, type HookState, type QueryFn, type ReactRequestOptionsBase, type SelectorFn, type TrackedCall, type UseEnlaceQueryResult, type UseEnlaceSelectorResult, clearCache, createEnlaceHook, invalidateTags, onRevalidate };