@netlify/cache 1.7.0 → 1.7.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.
@@ -78,17 +78,15 @@ var allowedProtocols = /* @__PURE__ */ new Set(["http:", "https:"]);
78
78
  var discardedHeaders = /* @__PURE__ */ new Set(["cookie", "content-encoding", "content-length"]);
79
79
  var getInternalHeaders = Symbol("getInternalHeaders");
80
80
  var serializeResourceHeaders = Symbol("serializeResourceHeaders");
81
- var _base64Encode, _getContext, _logger, _name, _userAgent;
81
+ var _base64Encode, _getContext, _name, _userAgent;
82
82
  var NetlifyCache = class {
83
- constructor({ base64Encode, getContext, logger, name, userAgent }) {
83
+ constructor({ base64Encode, getContext, name, userAgent }) {
84
84
  __privateAdd(this, _base64Encode, void 0);
85
85
  __privateAdd(this, _getContext, void 0);
86
- __privateAdd(this, _logger, void 0);
87
86
  __privateAdd(this, _name, void 0);
88
87
  __privateAdd(this, _userAgent, void 0);
89
88
  __privateSet(this, _base64Encode, base64Encode);
90
89
  __privateSet(this, _getContext, getContext);
91
- __privateSet(this, _logger, logger);
92
90
  __privateSet(this, _name, name);
93
91
  __privateSet(this, _userAgent, userAgent);
94
92
  }
@@ -171,7 +169,6 @@ var NetlifyCache = class {
171
169
  return res ? [res] : [];
172
170
  }
173
171
  async put(request, response) {
174
- var _a;
175
172
  if (!response.ok) {
176
173
  throw new TypeError(`Cannot cache response with status ${response.status}.`);
177
174
  }
@@ -203,13 +200,12 @@ var NetlifyCache = class {
203
200
  if (!cacheResponse.ok) {
204
201
  const errorDetail = cacheResponse.headers.get(ErrorDetail) ?? "";
205
202
  const errorMessage = ERROR_CODES[errorDetail] || GENERIC_ERROR;
206
- (_a = __privateGet(this, _logger)) == null ? void 0 : _a.call(this, `Failed to write to the cache: ${errorMessage}`);
203
+ context.logger?.(`Failed to write to the cache: ${errorMessage}`);
207
204
  }
208
205
  }
209
206
  };
210
207
  _base64Encode = new WeakMap();
211
208
  _getContext = new WeakMap();
212
- _logger = new WeakMap();
213
209
  _name = new WeakMap();
214
210
  _userAgent = new WeakMap();
215
211
  var extractAndValidateURL = (input) => {
@@ -1,5 +1,5 @@
1
- import { E as EnvironmentOptions } from '../cache-089d07a0.js';
2
- export { B as Base64Encoder, N as NetlifyCache, O as Operation, R as RequestContextFactory } from '../cache-089d07a0.js';
1
+ import { E as EnvironmentOptions } from '../cache-7af07baa.js';
2
+ export { B as Base64Encoder, N as NetlifyCache, O as Operation, R as RequestContextFactory } from '../cache-7af07baa.js';
3
3
 
4
4
  declare class NetlifyCacheStorage {
5
5
  #private;
@@ -1,5 +1,5 @@
1
- import { E as EnvironmentOptions } from '../cache-089d07a0.js';
2
- export { B as Base64Encoder, N as NetlifyCache, O as Operation, R as RequestContextFactory } from '../cache-089d07a0.js';
1
+ import { E as EnvironmentOptions } from '../cache-7af07baa.js';
2
+ export { B as Base64Encoder, N as NetlifyCache, O as Operation, R as RequestContextFactory } from '../cache-7af07baa.js';
3
3
 
4
4
  declare class NetlifyCacheStorage {
5
5
  #private;
@@ -51,17 +51,15 @@ var allowedProtocols = /* @__PURE__ */ new Set(["http:", "https:"]);
51
51
  var discardedHeaders = /* @__PURE__ */ new Set(["cookie", "content-encoding", "content-length"]);
52
52
  var getInternalHeaders = Symbol("getInternalHeaders");
53
53
  var serializeResourceHeaders = Symbol("serializeResourceHeaders");
54
- var _base64Encode, _getContext, _logger, _name, _userAgent;
54
+ var _base64Encode, _getContext, _name, _userAgent;
55
55
  var NetlifyCache = class {
56
- constructor({ base64Encode, getContext, logger, name, userAgent }) {
56
+ constructor({ base64Encode, getContext, name, userAgent }) {
57
57
  __privateAdd(this, _base64Encode, void 0);
58
58
  __privateAdd(this, _getContext, void 0);
59
- __privateAdd(this, _logger, void 0);
60
59
  __privateAdd(this, _name, void 0);
61
60
  __privateAdd(this, _userAgent, void 0);
62
61
  __privateSet(this, _base64Encode, base64Encode);
63
62
  __privateSet(this, _getContext, getContext);
64
- __privateSet(this, _logger, logger);
65
63
  __privateSet(this, _name, name);
66
64
  __privateSet(this, _userAgent, userAgent);
67
65
  }
@@ -144,7 +142,6 @@ var NetlifyCache = class {
144
142
  return res ? [res] : [];
145
143
  }
146
144
  async put(request, response) {
147
- var _a;
148
145
  if (!response.ok) {
149
146
  throw new TypeError(`Cannot cache response with status ${response.status}.`);
150
147
  }
@@ -176,13 +173,12 @@ var NetlifyCache = class {
176
173
  if (!cacheResponse.ok) {
177
174
  const errorDetail = cacheResponse.headers.get(ErrorDetail) ?? "";
178
175
  const errorMessage = ERROR_CODES[errorDetail] || GENERIC_ERROR;
179
- (_a = __privateGet(this, _logger)) == null ? void 0 : _a.call(this, `Failed to write to the cache: ${errorMessage}`);
176
+ context.logger?.(`Failed to write to the cache: ${errorMessage}`);
180
177
  }
181
178
  }
182
179
  };
183
180
  _base64Encode = new WeakMap();
184
181
  _getContext = new WeakMap();
185
- _logger = new WeakMap();
186
182
  _name = new WeakMap();
187
183
  _userAgent = new WeakMap();
188
184
  var extractAndValidateURL = (input) => {
@@ -3,7 +3,6 @@ type Logger = (...args: any[]) => void;
3
3
  interface EnvironmentOptions {
4
4
  base64Encode: Base64Encoder;
5
5
  getContext: RequestContextFactory;
6
- logger?: Logger;
7
6
  userAgent?: string;
8
7
  }
9
8
  declare enum Operation {
@@ -16,6 +15,7 @@ type RequestContextFactory = (options: {
16
15
  }) => RequestContext | null;
17
16
  interface RequestContext {
18
17
  host: string;
18
+ logger?: Logger;
19
19
  token: string;
20
20
  url: string;
21
21
  }
@@ -27,7 +27,7 @@ declare const getInternalHeaders: unique symbol;
27
27
  declare const serializeResourceHeaders: unique symbol;
28
28
  declare class NetlifyCache implements Cache {
29
29
  #private;
30
- constructor({ base64Encode, getContext, logger, name, userAgent }: NetlifyCacheOptions);
30
+ constructor({ base64Encode, getContext, name, userAgent }: NetlifyCacheOptions);
31
31
  private [getInternalHeaders];
32
32
  private [serializeResourceHeaders];
33
33
  add(request: RequestInfo): Promise<void>;
package/dist/main.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { N as NetlifyCache } from './cache-089d07a0.js';
1
+ import { N as NetlifyCache } from './cache-7af07baa.js';
2
2
 
3
3
  interface CacheSettings {
4
4
  /**
package/dist/main.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { N as NetlifyCache } from './cache-089d07a0.js';
1
+ import { N as NetlifyCache } from './cache-7af07baa.js';
2
2
 
3
3
  interface CacheSettings {
4
4
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netlify/cache",
3
- "version": "1.7.0",
3
+ "version": "1.7.1",
4
4
  "description": "TypeScript utilities for interacting with the Netlify cache",
5
5
  "type": "module",
6
6
  "engines": {