@envelop/response-cache-cloudflare-kv 6.1.1 → 6.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.
package/LICENSE CHANGED
@@ -1,6 +1,8 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2020 Dotan Simha
3
+ Copyright (c) 2018-2020 Graphcool
4
+ Copyright (c) 2020-2021 Prisma
5
+ Copyright (c) 2021- The Guild
4
6
 
5
7
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
8
  of this software and associated documentation files (the "Software"), to deal
package/cjs/cache-key.js CHANGED
@@ -6,9 +6,7 @@ function buildOperationKey(operationId, keyPrefix = undefined) {
6
6
  if (keyPrefix) {
7
7
  return `${keyPrefix}:operation:${operationId}`;
8
8
  }
9
- else {
10
- return `operation:${operationId}`;
11
- }
9
+ return `operation:${operationId}`;
12
10
  }
13
11
  function buildEntityKey(entityTypename, entityId = undefined, keyPrefix = undefined) {
14
12
  let finalKey = keyPrefix ? `${keyPrefix}:` : '';
package/cjs/index.js CHANGED
@@ -14,11 +14,11 @@ const set_js_1 = require("./set.js");
14
14
  * @returns A cache object that can be passed to envelop's `useResponseCache` plugin
15
15
  */
16
16
  function createKvCache(config) {
17
- if (config.cacheReadTTL && config.cacheReadTTL < 60000) {
17
+ if (config.cacheReadTTL && config.cacheReadTTL < 60_000) {
18
18
  // eslint-disable-next-line no-console
19
19
  console.warn('Cloudflare KV cacheReadTTL must be at least 60000 (60 seconds). Using default value of 60000 instead.');
20
20
  }
21
- const computedTtlInSeconds = Math.max(Math.floor((config.cacheReadTTL ?? 60000) / 1000), 60); // KV TTL must be at least 60 seconds
21
+ const computedTtlInSeconds = Math.max(Math.floor((config.cacheReadTTL ?? 60_000) / 1000), 60); // KV TTL must be at least 60 seconds
22
22
  return function KVCacheFactory(ctx) {
23
23
  return {
24
24
  get(id) {
package/cjs/invalidate.js CHANGED
@@ -18,8 +18,7 @@ kvPromiseCollection, KV, keyPrefix) {
18
18
  const entityKey = (0, cache_key_js_1.buildEntityKey)(entity.typename, entity.id, keyPrefix);
19
19
  for await (const kvKey of getAllKvKeysForPrefix(entityKey, KV)) {
20
20
  if (kvKey.metadata?.operationKey) {
21
- kvPromiseCollection.push(KV.delete(kvKey.metadata?.operationKey));
22
- kvPromiseCollection.push(KV.delete(kvKey.name));
21
+ kvPromiseCollection.push(KV.delete(kvKey.metadata?.operationKey), KV.delete(kvKey.name));
23
22
  }
24
23
  }
25
24
  }
package/esm/cache-key.js CHANGED
@@ -2,9 +2,7 @@ export function buildOperationKey(operationId, keyPrefix = undefined) {
2
2
  if (keyPrefix) {
3
3
  return `${keyPrefix}:operation:${operationId}`;
4
4
  }
5
- else {
6
- return `operation:${operationId}`;
7
- }
5
+ return `operation:${operationId}`;
8
6
  }
9
7
  export function buildEntityKey(entityTypename, entityId = undefined, keyPrefix = undefined) {
10
8
  let finalKey = keyPrefix ? `${keyPrefix}:` : '';
package/esm/index.js CHANGED
@@ -11,11 +11,11 @@ import { set } from './set.js';
11
11
  * @returns A cache object that can be passed to envelop's `useResponseCache` plugin
12
12
  */
13
13
  export function createKvCache(config) {
14
- if (config.cacheReadTTL && config.cacheReadTTL < 60000) {
14
+ if (config.cacheReadTTL && config.cacheReadTTL < 60_000) {
15
15
  // eslint-disable-next-line no-console
16
16
  console.warn('Cloudflare KV cacheReadTTL must be at least 60000 (60 seconds). Using default value of 60000 instead.');
17
17
  }
18
- const computedTtlInSeconds = Math.max(Math.floor((config.cacheReadTTL ?? 60000) / 1000), 60); // KV TTL must be at least 60 seconds
18
+ const computedTtlInSeconds = Math.max(Math.floor((config.cacheReadTTL ?? 60_000) / 1000), 60); // KV TTL must be at least 60 seconds
19
19
  return function KVCacheFactory(ctx) {
20
20
  return {
21
21
  get(id) {
package/esm/invalidate.js CHANGED
@@ -13,8 +13,7 @@ kvPromiseCollection, KV, keyPrefix) {
13
13
  const entityKey = buildEntityKey(entity.typename, entity.id, keyPrefix);
14
14
  for await (const kvKey of getAllKvKeysForPrefix(entityKey, KV)) {
15
15
  if (kvKey.metadata?.operationKey) {
16
- kvPromiseCollection.push(KV.delete(kvKey.metadata?.operationKey));
17
- kvPromiseCollection.push(KV.delete(kvKey.name));
16
+ kvPromiseCollection.push(KV.delete(kvKey.metadata?.operationKey), KV.delete(kvKey.name));
18
17
  }
19
18
  }
20
19
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@envelop/response-cache-cloudflare-kv",
3
- "version": "6.1.1",
3
+ "version": "6.2.0",
4
4
  "sideEffects": false,
5
5
  "peerDependenciesMeta": {
6
6
  "@cloudflare/workers-types": {
@@ -9,16 +9,16 @@
9
9
  },
10
10
  "peerDependencies": {
11
11
  "@cloudflare/workers-types": "^4.20231121.0",
12
- "@envelop/response-cache": "^9.1.1",
13
- "graphql": "^14.0.0 || ^15.0.0 || ^16.0.0"
12
+ "graphql": "^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0",
13
+ "@envelop/response-cache": "^9.2.0"
14
14
  },
15
15
  "dependencies": {
16
16
  "tslib": "^2.6.2"
17
17
  },
18
18
  "repository": {
19
19
  "type": "git",
20
- "url": "https://github.com/graphql-hive/envelop.git",
21
- "directory": "packages/plugins/response-cache-cloudflare-kv"
20
+ "url": "https://github.com/graphql-hive/graphql-yoga.git",
21
+ "directory": "packages/envelop/plugins/response-cache-cloudflare-kv"
22
22
  },
23
23
  "author": {
24
24
  "name": "Adishwar Rishi",
@@ -1,4 +1,4 @@
1
- import { KVNamespace } from '@cloudflare/workers-types';
1
+ import type { KVNamespace } from '@cloudflare/workers-types';
2
2
  import type { CacheEntityRecord } from '@envelop/response-cache';
3
3
  export declare function invalidate(entities: Iterable<CacheEntityRecord>, KV: KVNamespace, keyPrefix?: string): Promise<void>;
4
4
  export declare function invalidateCacheEntityRecord(entity: CacheEntityRecord,
@@ -1,4 +1,4 @@
1
- import { KVNamespace } from '@cloudflare/workers-types';
1
+ import type { KVNamespace } from '@cloudflare/workers-types';
2
2
  import type { CacheEntityRecord } from '@envelop/response-cache';
3
3
  export declare function invalidate(entities: Iterable<CacheEntityRecord>, KV: KVNamespace, keyPrefix?: string): Promise<void>;
4
4
  export declare function invalidateCacheEntityRecord(entity: CacheEntityRecord,
package/typings/set.d.cts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { ExecutionResult } from 'graphql';
2
- import { KVNamespace } from '@cloudflare/workers-types';
2
+ import type { KVNamespace } from '@cloudflare/workers-types';
3
3
  import type { CacheEntityRecord } from '@envelop/response-cache';
4
4
  export declare function set(
5
5
  /** id/hash of the operation */
package/typings/set.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { ExecutionResult } from 'graphql';
2
- import { KVNamespace } from '@cloudflare/workers-types';
2
+ import type { KVNamespace } from '@cloudflare/workers-types';
3
3
  import type { CacheEntityRecord } from '@envelop/response-cache';
4
4
  export declare function set(
5
5
  /** id/hash of the operation */