@codeleap/query 7.0.0 → 7.0.2

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 (48) hide show
  1. package/dist/factors/createQueryManager.js +41 -0
  2. package/dist/factors/createQueryManager.js.map +1 -0
  3. package/dist/factors/createQueryOperations.js +39 -0
  4. package/dist/factors/createQueryOperations.js.map +1 -0
  5. package/dist/factors/index.js +19 -0
  6. package/dist/factors/index.js.map +1 -0
  7. package/dist/index.js +20 -0
  8. package/dist/index.js.map +1 -0
  9. package/dist/lib/Mutations.js +243 -0
  10. package/dist/lib/Mutations.js.map +1 -0
  11. package/dist/lib/QueryClientEnhanced/index.js +199 -0
  12. package/dist/lib/QueryClientEnhanced/index.js.map +1 -0
  13. package/dist/lib/QueryClientEnhanced/types.js +3 -0
  14. package/dist/lib/QueryClientEnhanced/types.js.map +1 -0
  15. package/dist/lib/QueryKeys.js +321 -0
  16. package/dist/lib/QueryKeys.js.map +1 -0
  17. package/dist/lib/QueryManager.d.ts +3 -3
  18. package/dist/lib/QueryManager.js +404 -0
  19. package/dist/lib/QueryManager.js.map +1 -0
  20. package/dist/lib/QueryOperations/index.d.ts +2 -2
  21. package/dist/lib/QueryOperations/index.d.ts.map +1 -1
  22. package/dist/lib/QueryOperations/index.js +288 -0
  23. package/dist/lib/QueryOperations/index.js.map +1 -0
  24. package/dist/lib/QueryOperations/types.js +3 -0
  25. package/dist/lib/QueryOperations/types.js.map +1 -0
  26. package/dist/lib/index.js +22 -0
  27. package/dist/lib/index.js.map +1 -0
  28. package/dist/types/core.js +3 -0
  29. package/dist/types/core.js.map +1 -0
  30. package/dist/types/create.js +3 -0
  31. package/dist/types/create.js.map +1 -0
  32. package/dist/types/delete.js +3 -0
  33. package/dist/types/delete.js.map +1 -0
  34. package/dist/types/index.js +24 -0
  35. package/dist/types/index.js.map +1 -0
  36. package/dist/types/list.js +3 -0
  37. package/dist/types/list.js.map +1 -0
  38. package/dist/types/retrieve.js +3 -0
  39. package/dist/types/retrieve.js.map +1 -0
  40. package/dist/types/update.js +3 -0
  41. package/dist/types/update.js.map +1 -0
  42. package/dist/types/utility.js +3 -0
  43. package/dist/types/utility.js.map +1 -0
  44. package/dist/utils/index.js +18 -0
  45. package/dist/utils/index.js.map +1 -0
  46. package/dist/utils/misc.js +39 -0
  47. package/dist/utils/misc.js.map +1 -0
  48. package/package.json +6 -6
@@ -0,0 +1,288 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.QueryOperations = void 0;
13
+ const react_query_1 = require("@tanstack/react-query");
14
+ const QueryClientEnhanced_1 = require("../QueryClientEnhanced");
15
+ /**
16
+ * Builder class for creating type-safe query and mutation operations
17
+ * @template TMutations - Record type containing all registered mutation functions
18
+ * @template TQueries - Record type containing all registered query functions
19
+ *
20
+ * @description
21
+ * QueryOperations provides a fluent interface for building collections of queries and mutations
22
+ * with full type safety. It acts as a centralized registry for all data operations and provides
23
+ * corresponding React hooks that are automatically typed based on the registered functions.
24
+ *
25
+ * Key features:
26
+ * - Fluent builder pattern for registering operations
27
+ * - Automatic type inference for parameters and return types
28
+ * - Type-safe React hooks generation
29
+ * - Immutable operation registration (returns new instances)
30
+ */
31
+ class QueryOperations {
32
+ /**
33
+ * Creates a new QueryOperations instance
34
+ * @param _options - Configuration options including QueryClient
35
+ * @param _mutations - Record of registered mutation functions (internal)
36
+ * @param _queries - Record of registered query functions (internal)
37
+ */
38
+ constructor(_options, _mutations = {}, _queries = {}) {
39
+ this._options = _options;
40
+ this._mutations = _mutations;
41
+ this._queries = _queries;
42
+ }
43
+ /**
44
+ * Gets all registered mutation functions
45
+ * @returns Readonly record of mutation functions
46
+ */
47
+ get mutations() {
48
+ return this._mutations;
49
+ }
50
+ get queryClient() {
51
+ if (this._options.queryClient instanceof QueryClientEnhanced_1.QueryClientEnhanced) {
52
+ return this._options.queryClient.client;
53
+ }
54
+ return this._options.queryClient;
55
+ }
56
+ /**
57
+ * Gets all registered query functions
58
+ * @returns Readonly record of query functions
59
+ */
60
+ get queries() {
61
+ return this._queries;
62
+ }
63
+ /**
64
+ * Registers a new mutation function
65
+ * @template K - The name/key for the mutation
66
+ * @template T - The input data type for the mutation
67
+ * @template R - The return data type for the mutation
68
+ * @param name - Unique name identifier for the mutation
69
+ * @param fn - The mutation function that performs the operation
70
+ * @returns New QueryOperations instance with the mutation added
71
+ *
72
+ * @example
73
+ * ```typescript
74
+ * const operations = createQueryOperations({ queryClient })
75
+ * .mutation('createUser', async (userData: CreateUserData) => {
76
+ * return api.post('/users', userData)
77
+ * })
78
+ * .mutation('updateUser', async (userData: UpdateUserData) => {
79
+ * return api.put(`/users/${userData.id}`, userData)
80
+ * })
81
+ * ```
82
+ */
83
+ mutation(name, fn) {
84
+ return new QueryOperations(this._options, Object.assign(Object.assign({}, this._mutations), { [name]: fn }), this._queries);
85
+ }
86
+ /**
87
+ * Registers a new query function
88
+ * @template K - The name/key for the query
89
+ * @template T - The parameters type for the query
90
+ * @template R - The return data type for the query
91
+ * @param name - Unique name identifier for the query
92
+ * @param fn - The query function that fetches the data
93
+ * @returns New QueryOperations instance with the query added
94
+ *
95
+ * @example
96
+ * ```typescript
97
+ * const operations = createQueryOperations({ queryClient })
98
+ * .query('getUser', async (userId: string) => {
99
+ * return api.get(`/users/${userId}`)
100
+ * })
101
+ * .query('getUsers', async (filters?: UserFilters) => {
102
+ * return api.get('/users', { params: filters })
103
+ * })
104
+ * ```
105
+ */
106
+ query(name, fn) {
107
+ return new QueryOperations(this._options, this._mutations, Object.assign(Object.assign({}, this._queries), { [name]: fn }));
108
+ }
109
+ /**
110
+ * React hook for executing mutations with full type safety
111
+ * @template K - The mutation key type
112
+ * @param mutationKey - The name of the registered mutation to use
113
+ * @param options - React Query mutation options (excluding mutationFn and mutationKey)
114
+ * @returns React Query mutation object with inferred types
115
+ *
116
+ * @description
117
+ * This hook automatically provides type-safe parameters and return types based on the
118
+ * registered mutation function. It handles error cases and provides proper TypeScript
119
+ * inference for the mutation data and variables.
120
+ *
121
+ * @example
122
+ * ```typescript
123
+ * const createUserMutation = operations.useMutation('createUser', {
124
+ * onSuccess: (user) => {
125
+ * // 'user' is automatically typed as the return type of createUser
126
+ * console.log('Created user:', user.id)
127
+ * }
128
+ * })
129
+ *
130
+ * // Usage - parameters are type-checked
131
+ * createUserMutation.mutate({ name: 'John', email: 'john@example.com' })
132
+ * ```
133
+ */
134
+ useMutation(mutationKey, options) {
135
+ const mutationFn = this._mutations[mutationKey];
136
+ return (0, react_query_1.useMutation)(Object.assign({ mutationKey: this.getMutationKey(mutationKey), mutationFn: (data) => __awaiter(this, void 0, void 0, function* () {
137
+ if (!mutationFn) {
138
+ throw new Error(`Mutation "${String(mutationKey)}" not found`);
139
+ }
140
+ return mutationFn(data);
141
+ }) }, options));
142
+ }
143
+ /**
144
+ * React hook for executing queries with full type safety
145
+ * @template K - The query key type
146
+ * @param queryKey - The name of the registered query to use
147
+ * @param params - Parameters to pass to the query function (optional if query doesn't require params)
148
+ * @param options - React Query options (excluding queryKey and queryFn)
149
+ * @returns React Query query object with inferred types
150
+ *
151
+ * @description
152
+ * This hook automatically provides type-safe parameters and return types based on the
153
+ * registered query function. It generates appropriate query keys and handles parameter
154
+ * validation.
155
+ *
156
+ * @example
157
+ * ```typescript
158
+ * // Query with parameters
159
+ * const userQuery = operations.useQuery('getUser', 'user-123', {
160
+ * enabled: !!userId
161
+ * })
162
+ *
163
+ * // Query without parameters
164
+ * const usersQuery = operations.useQuery('getUsers', undefined, {
165
+ * refetchInterval: 30000
166
+ * })
167
+ *
168
+ * // Query with optional parameters
169
+ * const filteredUsersQuery = operations.useQuery('getUsers', { status: 'active' })
170
+ * ```
171
+ */
172
+ useQuery(queryKey, params, options) {
173
+ const queryFn = this._queries[queryKey];
174
+ return (0, react_query_1.useQuery)(Object.assign({ queryKey: this.getQueryKey(queryKey, params), queryFn: () => __awaiter(this, void 0, void 0, function* () {
175
+ if (!queryFn) {
176
+ throw new Error(`Query "${String(queryKey)}" not found`);
177
+ }
178
+ return queryFn(params);
179
+ }) }, options));
180
+ }
181
+ /**
182
+ * Generates a properly typed query key for React Query
183
+ * @template K - The query key type
184
+ * @param queryKey - The name of the query
185
+ * @param params - Optional parameters for the query
186
+ * @returns Query key array, with params included only when necessary
187
+ *
188
+ * @description
189
+ * This method creates React Query compatible keys that include parameters when present.
190
+ * The return type is conditionally typed based on whether the query requires parameters.
191
+ *
192
+ * @example
193
+ * ```typescript
194
+ * // Returns ['getUser', 'user-123']
195
+ * const keyWithParams = operations.getQueryKey('getUser', 'user-123')
196
+ *
197
+ * // Returns ['getUsers']
198
+ * const keyWithoutParams = operations.getQueryKey('getUsers')
199
+ * ```
200
+ */
201
+ getQueryKey(queryKey, params) {
202
+ return (params !== undefined ? [queryKey, params] : [queryKey]);
203
+ }
204
+ /**
205
+ * Generates a mutation key for React Query
206
+ * @template K - The mutation key type
207
+ * @param mutationKey - The name of the mutation
208
+ * @returns Mutation key array containing only the mutation name
209
+ *
210
+ * @example
211
+ * ```typescript
212
+ * // Returns ['createUser']
213
+ * const mutationKey = operations.getMutationKey('createUser')
214
+ * ```
215
+ */
216
+ getMutationKey(mutationKey) {
217
+ return [mutationKey];
218
+ }
219
+ /**
220
+ * Prefetches a query to populate the cache ahead of time
221
+ * @template K - The query key type
222
+ * @param queryKey - The name of the registered query to prefetch
223
+ * @param params - Parameters to pass to the query function (optional if query doesn't require params)
224
+ * @param options - React Query prefetch options
225
+ * @returns Promise that resolves when the prefetch is complete
226
+ *
227
+ * @example
228
+ * ```typescript
229
+ * // Prefetch user data when hovering over a user link
230
+ * const handleUserHover = async (userId: string) => {
231
+ * await operations.prefetchQuery('getUser', userId, {
232
+ * staleTime: 5 * 60 * 1000 // 5 minutes
233
+ * })
234
+ * }
235
+ *
236
+ * // Prefetch data on route change
237
+ * useEffect(() => {
238
+ * operations.prefetchQuery('getUsers', { status: 'active' })
239
+ * }, [])
240
+ * ```
241
+ */
242
+ prefetchQuery(queryKey, params, options) {
243
+ const prefetchQueryKey = this.getQueryKey(queryKey, params);
244
+ const queryFn = this._queries[queryKey];
245
+ return this.queryClient.prefetchQuery(Object.assign({ queryKey: prefetchQueryKey, queryFn: queryFn }, options));
246
+ }
247
+ /**
248
+ * Retrieves cached query data if it exists
249
+ * @template K - The query key type
250
+ * @template T - The expected return type (defaults to inferred query return type)
251
+ * @param queryKey - The name of the registered query
252
+ * @param params - Parameters used when the query was cached (optional if query doesn't require params)
253
+ * @returns The cached data if it exists, undefined otherwise
254
+ *
255
+ * @example
256
+ * ```typescript
257
+ * // Get cached user data
258
+ * const cachedUser = operations.getQueryData('getUser', 'user-123')
259
+ * if (cachedUser) {
260
+ * console.log('User already in cache:', cachedUser.name)
261
+ * }
262
+ *
263
+ * // Check if users list is cached before showing loading state
264
+ * const cachedUsers = operations.getQueryData('getUsers')
265
+ * const showSkeleton = !cachedUsers
266
+ *
267
+ * // Access cached data in event handlers
268
+ * const handleUserAction = () => {
269
+ * const currentUser = operations.getQueryData('getCurrentUser')
270
+ * if (currentUser?.role === 'admin') {
271
+ * // Perform admin action
272
+ * }
273
+ * }
274
+ * ```
275
+ */
276
+ getQueryData(queryKey, params, options) {
277
+ return __awaiter(this, void 0, void 0, function* () {
278
+ const prefetchQueryKey = this.getQueryKey(queryKey, params);
279
+ const cachedData = this.queryClient.getQueryData(prefetchQueryKey);
280
+ if (!cachedData) {
281
+ yield this.prefetchQuery(queryKey, params, options);
282
+ }
283
+ return this.queryClient.getQueryData(prefetchQueryKey);
284
+ });
285
+ }
286
+ }
287
+ exports.QueryOperations = QueryOperations;
288
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/QueryOperations/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,uDAA+H;AAE/H,gEAA4D;AAE5D;;;;;;;;;;;;;;;GAeG;AACH,MAAa,eAAe;IAI1B;;;;;OAKG;IACH,YACU,QAAgC,EAChC,aAAyB,EAAgB,EACzC,WAAqB,EAAc;QAFnC,aAAQ,GAAR,QAAQ,CAAwB;QAChC,eAAU,GAAV,UAAU,CAA+B;QACzC,aAAQ,GAAR,QAAQ,CAA2B;IACzC,CAAC;IAEL;;;OAGG;IACH,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,UAAU,CAAA;IACxB,CAAC;IAED,IAAI,WAAW;QACb,IAAG,IAAI,CAAC,QAAQ,CAAC,WAAW,YAAY,yCAAmB,EAAE,CAAC;YAC5D,OAAO,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,MAAM,CAAA;QACzC,CAAC;QACD,OAAO,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAA;IAClC,CAAC;IAED;;;OAGG;IACH,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,QAAQ,CAAA;IACtB,CAAC;IAED;;;;;;;;;;;;;;;;;;;OAmBG;IACH,QAAQ,CACN,IAAO,EACP,EAAoB;QAEpB,OAAO,IAAI,eAAe,CACxB,IAAI,CAAC,QAAQ,EACb,gCAAK,IAAI,CAAC,UAAU,KAAE,CAAC,IAAI,CAAC,EAAE,EAAE,GAA8C,EAC9E,IAAI,CAAC,QAAQ,CACd,CAAA;IACH,CAAC;IAED;;;;;;;;;;;;;;;;;;;OAmBG;IACH,KAAK,CACH,IAAO,EACP,EAAiB;QAEjB,OAAO,IAAI,eAAe,CACxB,IAAI,CAAC,QAAQ,EACb,IAAI,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,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAa,CAAA;IAC7E,CAAC;IAED;;;;;;;;;;;OAWG;IACH,cAAc,CAA6B,WAAc;QACvD,OAAO,CAAC,WAAW,CAAa,CAAA;IAClC,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,aAAa,CACX,QAAW,EACX,MAAsC,EACtC,OAAqF;QAErF,MAAM,gBAAgB,GAAG,IAAI,CAAC,WAAW,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAA;QAE3D,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAY,CAAA;QAElD,OAAO,IAAI,CAAC,WAAW,CAAC,aAAa,iBACnC,QAAQ,EAAE,gBAAgB,EAC1B,OAAO,EAAE,OAAO,IACb,OAAO,EACV,CAAA;IACJ,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4BG;IACG,YAAY,CAChB,QAAW,EACX,MAAsC,EACtC,OAAqF;;YAErF,MAAM,gBAAgB,GAAG,IAAI,CAAC,WAAW,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAA;YAE3D,MAAM,UAAU,GAAG,IAAI,CAAC,WAAW,CAAC,YAAY,CAAc,gBAAgB,CAAC,CAAA;YAE/E,IAAI,CAAC,UAAU,EAAE,CAAC;gBAChB,MAAM,IAAI,CAAC,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,CAAA;YACrD,CAAC;YAED,OAAO,IAAI,CAAC,WAAW,CAAC,YAAY,CAAc,gBAAgB,CAAC,CAAA;QACrE,CAAC;KAAA;CACF;AAlVD,0CAkVC"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/lib/QueryOperations/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./QueryClientEnhanced"), exports);
18
+ __exportStar(require("./QueryKeys"), exports);
19
+ __exportStar(require("./Mutations"), exports);
20
+ __exportStar(require("./QueryManager"), exports);
21
+ __exportStar(require("./QueryOperations"), exports);
22
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/lib/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wDAAqC;AACrC,8CAA2B;AAC3B,8CAA2B;AAC3B,iDAA8B;AAC9B,oDAAiC"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=core.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"core.js","sourceRoot":"","sources":["../../src/types/core.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=create.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create.js","sourceRoot":"","sources":["../../src/types/create.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=delete.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"delete.js","sourceRoot":"","sources":["../../src/types/delete.ts"],"names":[],"mappings":""}
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./core"), exports);
18
+ __exportStar(require("./list"), exports);
19
+ __exportStar(require("./utility"), exports);
20
+ __exportStar(require("./retrieve"), exports);
21
+ __exportStar(require("./create"), exports);
22
+ __exportStar(require("./update"), exports);
23
+ __exportStar(require("./delete"), exports);
24
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,yCAAsB;AACtB,yCAAsB;AACtB,4CAAyB;AACzB,6CAA0B;AAC1B,2CAAwB;AACxB,2CAAwB;AACxB,2CAAwB"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=list.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list.js","sourceRoot":"","sources":["../../src/types/list.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=retrieve.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"retrieve.js","sourceRoot":"","sources":["../../src/types/retrieve.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=update.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"update.js","sourceRoot":"","sources":["../../src/types/update.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=utility.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utility.js","sourceRoot":"","sources":["../../src/types/utility.ts"],"names":[],"mappings":""}
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./misc"), exports);
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,yCAAsB"}
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.generateTempId = exports.tempIdPrefix = void 0;
4
+ function uuidV4() {
5
+ function randomHex() {
6
+ return Math.floor(Math.random() * 16).toString(16);
7
+ }
8
+ let uuid = '';
9
+ for (let i = 0; i < 8; i++) {
10
+ uuid += randomHex();
11
+ }
12
+ uuid += '-';
13
+ for (let i = 0; i < 4; i++) {
14
+ uuid += randomHex();
15
+ }
16
+ uuid += '-';
17
+ uuid += '4';
18
+ for (let i = 0; i < 3; i++) {
19
+ uuid += randomHex();
20
+ }
21
+ uuid += '-';
22
+ uuid += ['8', '9', 'a', 'b'][Math.floor(Math.random() * 4)];
23
+ for (let i = 0; i < 3; i++) {
24
+ uuid += randomHex();
25
+ }
26
+ uuid += '-';
27
+ for (let i = 0; i < 12; i++) {
28
+ uuid += randomHex();
29
+ }
30
+ return uuid;
31
+ }
32
+ /** Prefix used on every optimistically-created item id. Check `id.startsWith(tempIdPrefix)` to distinguish placeholder items from server-assigned ids. */
33
+ exports.tempIdPrefix = 'temp-id';
34
+ /** Returns a unique placeholder id for optimistic creates. The format is `temp-id-<uuidv4>` and is guaranteed never to collide with server-assigned ids. */
35
+ const generateTempId = () => {
36
+ return exports.tempIdPrefix + '-' + uuidV4();
37
+ };
38
+ exports.generateTempId = generateTempId;
39
+ //# sourceMappingURL=misc.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"misc.js","sourceRoot":"","sources":["../../src/utils/misc.ts"],"names":[],"mappings":";;;AAAA,SAAS,MAAM;IACb,SAAS,SAAS;QAChB,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IACrD,CAAC;IAED,IAAI,IAAI,GAAG,EAAE,CAAA;IAEb,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QAC3B,IAAI,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
3
+ "version": "7.0.2",
4
+ "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "exports": {
7
7
  ".": {
@@ -22,9 +22,9 @@
22
22
  "directory": "packages/query"
23
23
  },
24
24
  "devDependencies": {
25
- "@codeleap/config": "7.0.0",
26
- "@codeleap/types": "7.0.0",
27
- "@codeleap/utils": "7.0.0",
25
+ "@codeleap/config": "7.0.1",
26
+ "@codeleap/types": "7.0.1",
27
+ "@codeleap/utils": "7.0.1",
28
28
  "ts-node-dev": "1.1.8"
29
29
  },
30
30
  "scripts": {
@@ -32,7 +32,7 @@
32
32
  "typecheck": "bun tsc --noEmit -p ./tsconfig.json"
33
33
  },
34
34
  "peerDependencies": {
35
- "@codeleap/types": "7.0.0",
35
+ "@codeleap/types": "7.0.1",
36
36
  "typescript": "6.0.3",
37
37
  "@tanstack/react-query": "5.100.9"
38
38
  },