@ethlete/query 5.33.0 → 5.33.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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @ethlete/query
2
2
 
3
+ ## 5.33.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [`2991beb`](https://github.com/ethlete-io/ethdk/commit/2991beb64d12e3f2341c47ce1cdf954aa00000c0) Thanks [@TomTomB](https://github.com/TomTomB)! - Cleanup secure queries after logout
8
+
3
9
  ## 5.33.0
4
10
 
5
11
  ### Minor Changes
@@ -2973,6 +2973,7 @@ const createAuthProviderQuery = (config, authProviderConfig) => {
2973
2973
  };
2974
2974
  const createBearerAuthProvider = (options) => {
2975
2975
  const route = injectRoute();
2976
+ const client = inject(options.queryClientRef);
2976
2977
  const cookieEnabled = signal(options.cookie === undefined ? false : (options.cookie.enabled ?? true));
2977
2978
  const cookieOptions = {
2978
2979
  expiresInDays: 30,
@@ -3085,6 +3086,7 @@ const createBearerAuthProvider = (options) => {
3085
3086
  tokenRefreshQuery?.query.reset();
3086
3087
  selectRoleQuery?.query.reset();
3087
3088
  latestNonInternalQuery.set(null);
3089
+ client.repository.unbindAllSecure();
3088
3090
  };
3089
3091
  const enableCookie = () => {
3090
3092
  if (isDevMode() && !options.cookie) {
@@ -4251,7 +4253,7 @@ const setupQueryExecuteState = () => {
4251
4253
  };
4252
4254
  };
4253
4255
  const queryExecute = (options) => {
4254
- const { executeOptions, args, executeState, options: runQueryOptions, internalOptions: internalRunQueryOptions, transformResponse, } = options;
4256
+ const { executeOptions, args, executeState, options: runQueryOptions, internalOptions: internalRunQueryOptions, transformResponse, isSecure, } = options;
4255
4257
  const { deps, state, creator, creatorInternals, queryConfig } = executeOptions;
4256
4258
  const { key, request } = deps.client.repository.request({
4257
4259
  route: creatorInternals.route,
@@ -4263,6 +4265,7 @@ const queryExecute = (options) => {
4263
4265
  previousKey: executeState.previousKey(),
4264
4266
  internalRunQueryOptions,
4265
4267
  runQueryOptions,
4268
+ isSecure,
4266
4269
  });
4267
4270
  executeState.previousKey.set(key);
4268
4271
  const responseSignal = transformResponse ? computed(() => transformResponse(request.response())) : request.response;
@@ -4353,7 +4356,7 @@ const createQueryRepository = (config) => {
4353
4356
  if (shouldCache && key) {
4354
4357
  const cacheEntry = cache.get(key);
4355
4358
  if (cacheEntry) {
4356
- bind(key, options.destroyRef, cacheEntry.request);
4359
+ bind(key, options.destroyRef, cacheEntry.request, options.isSecure ?? false);
4357
4360
  if (!runQueryOptions?.allowCache || cacheEntry.request.isStale()) {
4358
4361
  cacheEntry.request.execute({ allowCache: runQueryOptions?.allowCache });
4359
4362
  }
@@ -4373,7 +4376,7 @@ const createQueryRepository = (config) => {
4373
4376
  });
4374
4377
  request.execute();
4375
4378
  if (shouldCache && key) {
4376
- bind(key, options.destroyRef, request);
4379
+ bind(key, options.destroyRef, request, options.isSecure ?? false);
4377
4380
  }
4378
4381
  return { key, request };
4379
4382
  };
@@ -4390,7 +4393,17 @@ const createQueryRepository = (config) => {
4390
4393
  }
4391
4394
  return true;
4392
4395
  };
4393
- const bind = (key, destroyRef, request) => {
4396
+ const unbindAllSecure = () => {
4397
+ for (const [key, cacheEntry] of cache.entries()) {
4398
+ if (cacheEntry.isSecure) {
4399
+ for (const destroyRef of cacheEntry.consumers.keys()) {
4400
+ unbind(key, destroyRef);
4401
+ }
4402
+ cache.delete(key);
4403
+ }
4404
+ }
4405
+ };
4406
+ const bind = (key, destroyRef, request, isSecure) => {
4394
4407
  const destroyListener = destroyRef.onDestroy(() => unbind(key, destroyRef));
4395
4408
  const cacheEntry = cache.get(key);
4396
4409
  if (cacheEntry) {
@@ -4402,12 +4415,14 @@ const createQueryRepository = (config) => {
4402
4415
  cache.set(key, {
4403
4416
  consumers,
4404
4417
  request,
4418
+ isSecure,
4405
4419
  });
4406
4420
  }
4407
4421
  };
4408
4422
  const repository = {
4409
4423
  request,
4410
4424
  unbind,
4425
+ unbindAllSecure,
4411
4426
  };
4412
4427
  return repository;
4413
4428
  };
@@ -4506,6 +4521,7 @@ const createSecureExecuteFn = (executeOptions) => {
4506
4521
  executeState,
4507
4522
  args: updatedArgs,
4508
4523
  options: runOptions,
4524
+ isSecure: true,
4509
4525
  });
4510
4526
  };
4511
4527
  const exec = (executeArgs) => {