@fitzzero/quickdraw-core 1.0.0 → 1.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.
@@ -88,6 +88,96 @@ interface UseSubscriptionResult<TData> {
88
88
  subscribe: () => void;
89
89
  unsubscribe: () => void;
90
90
  }
91
+ /**
92
+ * Options for the useServiceQuery hook.
93
+ */
94
+ interface UseServiceQueryOptions<TResponse> {
95
+ /**
96
+ * Whether to automatically fetch on mount (default: true)
97
+ */
98
+ enabled?: boolean;
99
+ /**
100
+ * How long data stays fresh in milliseconds (default: 5 minutes)
101
+ * During this time, cached data is returned without refetching.
102
+ */
103
+ staleTime?: number;
104
+ /**
105
+ * How long unused data stays in cache in milliseconds (default: 10 minutes)
106
+ * After this time, inactive queries are garbage collected.
107
+ * Note: TanStack Query v5 renamed this to `gcTime`.
108
+ */
109
+ gcTime?: number;
110
+ /**
111
+ * Whether to refetch when component mounts (default: true if data is stale)
112
+ */
113
+ refetchOnMount?: boolean | "always";
114
+ /**
115
+ * Whether to refetch when window regains focus (default: false)
116
+ */
117
+ refetchOnWindowFocus?: boolean | "always";
118
+ /**
119
+ * Force a fresh fetch, bypassing cache (default: false)
120
+ * Useful when you know the cache is invalidated.
121
+ */
122
+ skipCache?: boolean;
123
+ /**
124
+ * Request timeout in milliseconds (default: 10000)
125
+ */
126
+ timeout?: number;
127
+ /**
128
+ * Callback when data is successfully fetched
129
+ */
130
+ onSuccess?: (data: TResponse) => void;
131
+ /**
132
+ * Callback on error
133
+ */
134
+ onError?: (error: string) => void;
135
+ /**
136
+ * Number of retry attempts on failure (default: 1)
137
+ */
138
+ retry?: boolean | number;
139
+ /**
140
+ * Delay between retries in milliseconds
141
+ */
142
+ retryDelay?: number;
143
+ }
144
+ /**
145
+ * Return type for the useServiceQuery hook.
146
+ */
147
+ interface UseServiceQueryResult<TResponse> {
148
+ /**
149
+ * The fetched/cached data, or undefined if not yet loaded.
150
+ */
151
+ data: TResponse | undefined;
152
+ /**
153
+ * True during initial load (no cached data available).
154
+ */
155
+ isLoading: boolean;
156
+ /**
157
+ * True when any fetch is in progress (including background refetch).
158
+ */
159
+ isFetching: boolean;
160
+ /**
161
+ * True if the query has errored.
162
+ */
163
+ isError: boolean;
164
+ /**
165
+ * Error message if the query failed.
166
+ */
167
+ error: string | null;
168
+ /**
169
+ * True if the data is considered stale (past staleTime).
170
+ */
171
+ isStale: boolean;
172
+ /**
173
+ * True if the query has successfully fetched data at least once.
174
+ */
175
+ isSuccess: boolean;
176
+ /**
177
+ * Manually trigger a refetch.
178
+ */
179
+ refetch: () => Promise<TResponse | undefined>;
180
+ }
91
181
  /**
92
182
  * Type helper for defining service methods map on the client.
93
183
  * This mirrors the server-side ServiceMethodMap.
@@ -148,4 +238,4 @@ interface QuickdrawSocketContextValue {
148
238
  subscriptionRegistry: SubscriptionRegistry;
149
239
  }
150
240
 
151
- export type { ClientServiceMethodMap as C, QuickdrawSocketContextValue as Q, SubscriptionDataMap as S, UseServiceOptions as U, QuickdrawProviderProps as a, UseServiceResult as b, UseSubscriptionOptions as c, UseSubscriptionResult as d };
241
+ export type { ClientServiceMethodMap as C, QuickdrawSocketContextValue as Q, SubscriptionDataMap as S, UseServiceOptions as U, QuickdrawProviderProps as a, UseServiceResult as b, UseServiceQueryOptions as c, UseServiceQueryResult as d, UseSubscriptionOptions as e, UseSubscriptionResult as f };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fitzzero/quickdraw-core",
3
- "version": "1.0.0",
3
+ "version": "1.2.0",
4
4
  "description": "Fast fullstack patterns for real-time applications with Socket.io and TanStack Query",
5
5
  "type": "module",
6
6
  "main": "./dist/shared/index.js",
@@ -31,6 +31,17 @@
31
31
  "files": [
32
32
  "dist"
33
33
  ],
34
+ "scripts": {
35
+ "build": "tsup",
36
+ "dev": "tsup --watch",
37
+ "typecheck": "tsc --noEmit",
38
+ "lint": "eslint src --ext .ts,.tsx",
39
+ "lint:fix": "eslint src --ext .ts,.tsx --fix",
40
+ "test": "vitest run",
41
+ "test:watch": "vitest",
42
+ "test:coverage": "vitest run --coverage",
43
+ "prepublishOnly": "pnpm build"
44
+ },
34
45
  "keywords": [
35
46
  "socket.io",
36
47
  "tanstack-query",
@@ -96,15 +107,5 @@
96
107
  },
97
108
  "engines": {
98
109
  "node": ">=20"
99
- },
100
- "scripts": {
101
- "build": "tsup",
102
- "dev": "tsup --watch",
103
- "typecheck": "tsc --noEmit",
104
- "lint": "eslint src --ext .ts,.tsx",
105
- "lint:fix": "eslint src --ext .ts,.tsx --fix",
106
- "test": "vitest run",
107
- "test:watch": "vitest",
108
- "test:coverage": "vitest run --coverage"
109
110
  }
110
- }
111
+ }