@vercel/functions 3.1.3 → 3.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/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # @vercel/functions
2
2
 
3
+ ## 3.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Add new API for invalidateBySrcImage and dangerouslyDeleteBySrcImage ([#14111](https://github.com/vercel/vercel/pull/14111))
8
+
9
+ ## 3.1.4
10
+
11
+ ### Patch Changes
12
+
13
+ - Updated dependencies [[`bcf9c18da437d9566eeff1fdaedb11abb00c080c`](https://github.com/vercel/vercel/commit/bcf9c18da437d9566eeff1fdaedb11abb00c080c)]:
14
+ - @vercel/oidc@3.0.3
15
+
3
16
  ## 3.1.3
4
17
 
5
18
  ### Patch Changes
@@ -8,11 +8,44 @@ Vercel Cache Purge APIs.
8
8
 
9
9
  ### Properties
10
10
 
11
+ - [dangerouslyDeleteBySrcImage](index.PurgeApi.md#dangerouslydeletebysrcimage)
11
12
  - [dangerouslyDeleteByTag](index.PurgeApi.md#dangerouslydeletebytag)
13
+ - [invalidateBySrcImage](index.PurgeApi.md#invalidatebysrcimage)
12
14
  - [invalidateByTag](index.PurgeApi.md#invalidatebytag)
13
15
 
14
16
  ## Properties
15
17
 
18
+ ### dangerouslyDeleteBySrcImage
19
+
20
+ • **dangerouslyDeleteBySrcImage**: (`src`: `string` \| `string`[], `options?`: [`DangerouslyDeleteOptions`](index.DangerouslyDeleteOptions.md)) => [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`\>
21
+
22
+ #### Type declaration
23
+
24
+ ▸ (`src`, `options?`): [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`\>
25
+
26
+ Given a source image, delete all of its transformed images after a specified revalidation deadline.
27
+ If accessed prior to the revalidation deadline, the stale transformed image will be served and a background task will be triggered. After the revalidation deadline is reached, the transformed image will be deleted.
28
+ The default revalidation deadline is 0 and the content will be deleted immediately.
29
+
30
+ ##### Parameters
31
+
32
+ | Name | Type | Description |
33
+ | :--------- | :-------------------------------------------------------------- | :----------------------------------------------------------------- |
34
+ | `src` | `string` \| `string`[] | The source image to delete. |
35
+ | `options?` | [`DangerouslyDeleteOptions`](index.DangerouslyDeleteOptions.md) | The options for the delete that specify the revalidation deadline. |
36
+
37
+ ##### Returns
38
+
39
+ [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`\>
40
+
41
+ A promise that resolves when the delete is complete.
42
+
43
+ #### Defined in
44
+
45
+ [packages/functions/src/purge/types.ts:54](https://github.com/vercel/vercel/blob/main/packages/functions/src/purge/types.ts#L54)
46
+
47
+ ---
48
+
16
49
  ### dangerouslyDeleteByTag
17
50
 
18
51
  • **dangerouslyDeleteByTag**: (`tag`: `string` \| `string`[], `options?`: [`DangerouslyDeleteOptions`](index.DangerouslyDeleteOptions.md)) => [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`\>
@@ -44,6 +77,35 @@ A promise that resolves when the delete is complete.
44
77
 
45
78
  ---
46
79
 
80
+ ### invalidateBySrcImage
81
+
82
+ • **invalidateBySrcImage**: (`src`: `string` \| `string`[]) => [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`\>
83
+
84
+ #### Type declaration
85
+
86
+ ▸ (`src`): [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`\>
87
+
88
+ Given a source image, invalidate all of its transformed images by marking them as stale.
89
+ On the next access, the stale transformed image will be served and a background task will transform the source image.
90
+
91
+ ##### Parameters
92
+
93
+ | Name | Type | Description |
94
+ | :---- | :--------------------- | :------------------------------ |
95
+ | `src` | `string` \| `string`[] | The source image to invalidate. |
96
+
97
+ ##### Returns
98
+
99
+ [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`\>
100
+
101
+ A promise that resolves when the invalidate is complete.
102
+
103
+ #### Defined in
104
+
105
+ [packages/functions/src/purge/types.ts:43](https://github.com/vercel/vercel/blob/main/packages/functions/src/purge/types.ts#L43)
106
+
107
+ ---
108
+
47
109
  ### invalidateByTag
48
110
 
49
111
  • **invalidateByTag**: (`tag`: `string` \| `string`[]) => [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`\>
@@ -13,11 +13,13 @@
13
13
  ### Functions
14
14
 
15
15
  - [attachDatabasePool](index.md#attachdatabasepool)
16
+ - [dangerouslyDeleteBySrcImage](index.md#dangerouslydeletebysrcimage)
16
17
  - [dangerouslyDeleteByTag](index.md#dangerouslydeletebytag)
17
18
  - [experimental_attachDatabasePool](index.md#experimental_attachdatabasepool)
18
19
  - [geolocation](index.md#geolocation)
19
20
  - [getCache](index.md#getcache)
20
21
  - [getEnv](index.md#getenv)
22
+ - [invalidateBySrcImage](index.md#invalidatebysrcimage)
21
23
  - [invalidateByTag](index.md#invalidatebytag)
22
24
  - [ipAddress](index.md#ipaddress)
23
25
  - [next](index.md#next)
@@ -60,6 +62,27 @@ attachDatabasePool(pgPool);
60
62
 
61
63
  ---
62
64
 
65
+ ### dangerouslyDeleteBySrcImage
66
+
67
+ ▸ **dangerouslyDeleteBySrcImage**(`src`, `options?`): [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`\>
68
+
69
+ #### Parameters
70
+
71
+ | Name | Type |
72
+ | :--------- | :---------------------------------------------------------------------------- |
73
+ | `src` | `string` \| `string`[] |
74
+ | `options?` | [`DangerouslyDeleteOptions`](../interfaces/index.DangerouslyDeleteOptions.md) |
75
+
76
+ #### Returns
77
+
78
+ [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`\>
79
+
80
+ #### Defined in
81
+
82
+ [packages/functions/src/purge/index.ts:28](https://github.com/vercel/vercel/blob/main/packages/functions/src/purge/index.ts#L28)
83
+
84
+ ---
85
+
63
86
  ### dangerouslyDeleteByTag
64
87
 
65
88
  ▸ **dangerouslyDeleteByTag**(`tag`, `options?`): [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`\>
@@ -77,7 +100,7 @@ attachDatabasePool(pgPool);
77
100
 
78
101
  #### Defined in
79
102
 
80
- [packages/functions/src/purge/index.ts:13](https://github.com/vercel/vercel/blob/main/packages/functions/src/purge/index.ts#L13)
103
+ [packages/functions/src/purge/index.ts:12](https://github.com/vercel/vercel/blob/main/packages/functions/src/purge/index.ts#L12)
81
104
 
82
105
  ---
83
106
 
@@ -238,6 +261,26 @@ https://vercel.com/docs/projects/environment-variables/system-environment-variab
238
261
 
239
262
  ---
240
263
 
264
+ ### invalidateBySrcImage
265
+
266
+ ▸ **invalidateBySrcImage**(`src`): [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`\>
267
+
268
+ #### Parameters
269
+
270
+ | Name | Type |
271
+ | :---- | :--------------------- |
272
+ | `src` | `string` \| `string`[] |
273
+
274
+ #### Returns
275
+
276
+ [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`\>
277
+
278
+ #### Defined in
279
+
280
+ [packages/functions/src/purge/index.ts:23](https://github.com/vercel/vercel/blob/main/packages/functions/src/purge/index.ts#L23)
281
+
282
+ ---
283
+
241
284
  ### invalidateByTag
242
285
 
243
286
  ▸ **invalidateByTag**(`tag`): [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`\>
@@ -254,7 +297,7 @@ https://vercel.com/docs/projects/environment-variables/system-environment-variab
254
297
 
255
298
  #### Defined in
256
299
 
257
- [packages/functions/src/purge/index.ts:5](https://github.com/vercel/vercel/blob/main/packages/functions/src/purge/index.ts#L5)
300
+ [packages/functions/src/purge/index.ts:4](https://github.com/vercel/vercel/blob/main/packages/functions/src/purge/index.ts#L4)
258
301
 
259
302
  ---
260
303
 
package/index.d.ts CHANGED
@@ -6,5 +6,5 @@ export { rewrite, next } from './middleware';
6
6
  export { getCache } from './cache';
7
7
  export { attachDatabasePool, experimental_attachDatabasePool, } from './db-connections';
8
8
  export type { RuntimeCache } from './cache/types';
9
- export { invalidateByTag, dangerouslyDeleteByTag } from './purge';
9
+ export { invalidateByTag, dangerouslyDeleteByTag, invalidateBySrcImage, dangerouslyDeleteBySrcImage, } from './purge';
10
10
  export type { PurgeApi, DangerouslyDeleteOptions } from './purge/types';
package/index.js CHANGED
@@ -19,11 +19,13 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
19
19
  var src_exports = {};
20
20
  __export(src_exports, {
21
21
  attachDatabasePool: () => import_db_connections.attachDatabasePool,
22
+ dangerouslyDeleteBySrcImage: () => import_purge.dangerouslyDeleteBySrcImage,
22
23
  dangerouslyDeleteByTag: () => import_purge.dangerouslyDeleteByTag,
23
24
  experimental_attachDatabasePool: () => import_db_connections.experimental_attachDatabasePool,
24
25
  geolocation: () => import_headers.geolocation,
25
26
  getCache: () => import_cache.getCache,
26
27
  getEnv: () => import_get_env.getEnv,
28
+ invalidateBySrcImage: () => import_purge.invalidateBySrcImage,
27
29
  invalidateByTag: () => import_purge.invalidateByTag,
28
30
  ipAddress: () => import_headers.ipAddress,
29
31
  next: () => import_middleware.next,
@@ -41,11 +43,13 @@ var import_purge = require("./purge");
41
43
  // Annotate the CommonJS export names for ESM import in node:
42
44
  0 && (module.exports = {
43
45
  attachDatabasePool,
46
+ dangerouslyDeleteBySrcImage,
44
47
  dangerouslyDeleteByTag,
45
48
  experimental_attachDatabasePool,
46
49
  geolocation,
47
50
  getCache,
48
51
  getEnv,
52
+ invalidateBySrcImage,
49
53
  invalidateByTag,
50
54
  ipAddress,
51
55
  next,
package/package.json CHANGED
@@ -30,7 +30,7 @@
30
30
  "require": "./middleware.js"
31
31
  }
32
32
  },
33
- "version": "3.1.3",
33
+ "version": "3.2.0",
34
34
  "repository": {
35
35
  "directory": "packages/functions",
36
36
  "type": "git",
@@ -72,7 +72,7 @@
72
72
  "access": "public"
73
73
  },
74
74
  "dependencies": {
75
- "@vercel/oidc": "3.0.2"
75
+ "@vercel/oidc": "3.0.3"
76
76
  },
77
77
  "scripts": {
78
78
  "pretest": "pnpm run build:code",
package/purge/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { DangerouslyDeleteOptions } from './types';
2
- export * from './types';
3
2
  export declare const invalidateByTag: (tag: string | string[]) => Promise<void>;
4
3
  export declare const dangerouslyDeleteByTag: (tag: string | string[], options?: DangerouslyDeleteOptions) => Promise<void>;
4
+ export declare const invalidateBySrcImage: (src: string | string[]) => Promise<void>;
5
+ export declare const dangerouslyDeleteBySrcImage: (src: string | string[], options?: DangerouslyDeleteOptions) => Promise<void>;
package/purge/index.js CHANGED
@@ -15,16 +15,16 @@ var __copyProps = (to, from, except, desc) => {
15
15
  }
16
16
  return to;
17
17
  };
18
- var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
19
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
19
  var purge_exports = {};
21
20
  __export(purge_exports, {
21
+ dangerouslyDeleteBySrcImage: () => dangerouslyDeleteBySrcImage,
22
22
  dangerouslyDeleteByTag: () => dangerouslyDeleteByTag,
23
+ invalidateBySrcImage: () => invalidateBySrcImage,
23
24
  invalidateByTag: () => invalidateByTag
24
25
  });
25
26
  module.exports = __toCommonJS(purge_exports);
26
27
  var import_get_context = require("../get-context");
27
- __reExport(purge_exports, require("./types"), module.exports);
28
28
  const invalidateByTag = (tag) => {
29
29
  const api = (0, import_get_context.getContext)().purge;
30
30
  if (api) {
@@ -39,9 +39,18 @@ const dangerouslyDeleteByTag = (tag, options) => {
39
39
  }
40
40
  return Promise.resolve();
41
41
  };
42
+ const invalidateBySrcImage = (src) => {
43
+ const api = (0, import_get_context.getContext)().purge;
44
+ return api ? api.invalidateBySrcImage(src) : Promise.resolve();
45
+ };
46
+ const dangerouslyDeleteBySrcImage = (src, options) => {
47
+ const api = (0, import_get_context.getContext)().purge;
48
+ return api ? api.dangerouslyDeleteBySrcImage(src, options) : Promise.resolve();
49
+ };
42
50
  // Annotate the CommonJS export names for ESM import in node:
43
51
  0 && (module.exports = {
52
+ dangerouslyDeleteBySrcImage,
44
53
  dangerouslyDeleteByTag,
45
- invalidateByTag,
46
- ...require("./types")
54
+ invalidateBySrcImage,
55
+ invalidateByTag
47
56
  });
package/purge/types.d.ts CHANGED
@@ -27,4 +27,22 @@ export interface PurgeApi {
27
27
  * @returns A promise that resolves when the delete is complete.
28
28
  */
29
29
  dangerouslyDeleteByTag: (tag: string | string[], options?: DangerouslyDeleteOptions) => Promise<void>;
30
+ /**
31
+ * Given a source image, invalidate all of its transformed images by marking them as stale.
32
+ * On the next access, the stale transformed image will be served and a background task will transform the source image.
33
+ *
34
+ * @param src The source image to invalidate.
35
+ * @returns A promise that resolves when the invalidate is complete.
36
+ */
37
+ invalidateBySrcImage: (src: string | string[]) => Promise<void>;
38
+ /**
39
+ * Given a source image, delete all of its transformed images after a specified revalidation deadline.
40
+ * If accessed prior to the revalidation deadline, the stale transformed image will be served and a background task will be triggered. After the revalidation deadline is reached, the transformed image will be deleted.
41
+ * The default revalidation deadline is 0 and the content will be deleted immediately.
42
+ *
43
+ * @param src The source image to delete.
44
+ * @param options The options for the delete that specify the revalidation deadline.
45
+ * @returns A promise that resolves when the delete is complete.
46
+ */
47
+ dangerouslyDeleteBySrcImage: (src: string | string[], options?: DangerouslyDeleteOptions) => Promise<void>;
30
48
  }