@vercel/functions 3.1.4 → 3.3.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 +12 -0
- package/addcachetag/index.d.ts +1 -0
- package/addcachetag/index.js +35 -0
- package/addcachetag/types.d.ts +12 -0
- package/addcachetag/types.js +16 -0
- package/docs/interfaces/index.AddCacheTagApi.md +39 -0
- package/docs/interfaces/index.PurgeApi.md +62 -0
- package/docs/modules/index.md +67 -2
- package/get-context.d.ts +2 -0
- package/index.d.ts +3 -1
- package/index.js +7 -0
- package/package.json +1 -1
- package/purge/index.d.ts +2 -1
- package/purge/index.js +13 -4
- package/purge/types.d.ts +18 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @vercel/functions
|
|
2
2
|
|
|
3
|
+
## 3.3.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Introduce Vercel AddCacheTag API: addCacheTag ([#14096](https://github.com/vercel/vercel/pull/14096))
|
|
8
|
+
|
|
9
|
+
## 3.2.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- Add new API for invalidateBySrcImage and dangerouslyDeleteBySrcImage ([#14111](https://github.com/vercel/vercel/pull/14111))
|
|
14
|
+
|
|
3
15
|
## 3.1.4
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const addCacheTag: (tag: string | string[]) => Promise<void>;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var addcachetag_exports = {};
|
|
20
|
+
__export(addcachetag_exports, {
|
|
21
|
+
addCacheTag: () => addCacheTag
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(addcachetag_exports);
|
|
24
|
+
var import_get_context = require("../get-context");
|
|
25
|
+
const addCacheTag = (tag) => {
|
|
26
|
+
const api = (0, import_get_context.getContext)().addCacheTag;
|
|
27
|
+
if (api) {
|
|
28
|
+
return api.addCacheTag(tag);
|
|
29
|
+
}
|
|
30
|
+
return Promise.resolve();
|
|
31
|
+
};
|
|
32
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
33
|
+
0 && (module.exports = {
|
|
34
|
+
addCacheTag
|
|
35
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vercel AddCacheTag API.
|
|
3
|
+
*/
|
|
4
|
+
export interface AddCacheTagApi {
|
|
5
|
+
/**
|
|
6
|
+
* Add one or more tags to the cache content
|
|
7
|
+
*
|
|
8
|
+
* @param tag One or more tags to add to the cache content.
|
|
9
|
+
* @returns A promise that resolves when the tag is added.
|
|
10
|
+
*/
|
|
11
|
+
addCacheTag: (tag: string | string[]) => Promise<void>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
var types_exports = {};
|
|
16
|
+
module.exports = __toCommonJS(types_exports);
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# Interface: AddCacheTagApi
|
|
2
|
+
|
|
3
|
+
[index](../modules/index.md).AddCacheTagApi
|
|
4
|
+
|
|
5
|
+
Vercel AddCacheTag API.
|
|
6
|
+
|
|
7
|
+
## Table of contents
|
|
8
|
+
|
|
9
|
+
### Properties
|
|
10
|
+
|
|
11
|
+
- [addCacheTag](index.AddCacheTagApi.md#addcachetag)
|
|
12
|
+
|
|
13
|
+
## Properties
|
|
14
|
+
|
|
15
|
+
### addCacheTag
|
|
16
|
+
|
|
17
|
+
• **addCacheTag**: (`tag`: `string` \| `string`[]) => [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`\>
|
|
18
|
+
|
|
19
|
+
#### Type declaration
|
|
20
|
+
|
|
21
|
+
▸ (`tag`): [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`\>
|
|
22
|
+
|
|
23
|
+
Add one or more tags to the cache content
|
|
24
|
+
|
|
25
|
+
##### Parameters
|
|
26
|
+
|
|
27
|
+
| Name | Type | Description |
|
|
28
|
+
| :---- | :--------------------- | :-------------------------------------------- |
|
|
29
|
+
| `tag` | `string` \| `string`[] | One or more tags to add to the cache content. |
|
|
30
|
+
|
|
31
|
+
##### Returns
|
|
32
|
+
|
|
33
|
+
[`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`\>
|
|
34
|
+
|
|
35
|
+
A promise that resolves when the tag is added.
|
|
36
|
+
|
|
37
|
+
#### Defined in
|
|
38
|
+
|
|
39
|
+
[packages/functions/src/addcachetag/types.ts:11](https://github.com/vercel/vercel/blob/main/packages/functions/src/addcachetag/types.ts#L11)
|
|
@@ -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`\>
|
package/docs/modules/index.md
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
### Interfaces
|
|
6
6
|
|
|
7
|
+
- [AddCacheTagApi](../interfaces/index.AddCacheTagApi.md)
|
|
7
8
|
- [DangerouslyDeleteOptions](../interfaces/index.DangerouslyDeleteOptions.md)
|
|
8
9
|
- [Geo](../interfaces/index.Geo.md)
|
|
9
10
|
- [PurgeApi](../interfaces/index.PurgeApi.md)
|
|
@@ -12,12 +13,15 @@
|
|
|
12
13
|
|
|
13
14
|
### Functions
|
|
14
15
|
|
|
16
|
+
- [addCacheTag](index.md#addcachetag)
|
|
15
17
|
- [attachDatabasePool](index.md#attachdatabasepool)
|
|
18
|
+
- [dangerouslyDeleteBySrcImage](index.md#dangerouslydeletebysrcimage)
|
|
16
19
|
- [dangerouslyDeleteByTag](index.md#dangerouslydeletebytag)
|
|
17
20
|
- [experimental_attachDatabasePool](index.md#experimental_attachdatabasepool)
|
|
18
21
|
- [geolocation](index.md#geolocation)
|
|
19
22
|
- [getCache](index.md#getcache)
|
|
20
23
|
- [getEnv](index.md#getenv)
|
|
24
|
+
- [invalidateBySrcImage](index.md#invalidatebysrcimage)
|
|
21
25
|
- [invalidateByTag](index.md#invalidatebytag)
|
|
22
26
|
- [ipAddress](index.md#ipaddress)
|
|
23
27
|
- [next](index.md#next)
|
|
@@ -26,6 +30,26 @@
|
|
|
26
30
|
|
|
27
31
|
## Functions
|
|
28
32
|
|
|
33
|
+
### addCacheTag
|
|
34
|
+
|
|
35
|
+
▸ **addCacheTag**(`tag`): [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`\>
|
|
36
|
+
|
|
37
|
+
#### Parameters
|
|
38
|
+
|
|
39
|
+
| Name | Type |
|
|
40
|
+
| :---- | :--------------------- |
|
|
41
|
+
| `tag` | `string` \| `string`[] |
|
|
42
|
+
|
|
43
|
+
#### Returns
|
|
44
|
+
|
|
45
|
+
[`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`\>
|
|
46
|
+
|
|
47
|
+
#### Defined in
|
|
48
|
+
|
|
49
|
+
[packages/functions/src/addcachetag/index.ts:3](https://github.com/vercel/vercel/blob/main/packages/functions/src/addcachetag/index.ts#L3)
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
29
53
|
### attachDatabasePool
|
|
30
54
|
|
|
31
55
|
▸ **attachDatabasePool**(`dbPool`): `void`
|
|
@@ -60,6 +84,27 @@ attachDatabasePool(pgPool);
|
|
|
60
84
|
|
|
61
85
|
---
|
|
62
86
|
|
|
87
|
+
### dangerouslyDeleteBySrcImage
|
|
88
|
+
|
|
89
|
+
▸ **dangerouslyDeleteBySrcImage**(`src`, `options?`): [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`\>
|
|
90
|
+
|
|
91
|
+
#### Parameters
|
|
92
|
+
|
|
93
|
+
| Name | Type |
|
|
94
|
+
| :--------- | :---------------------------------------------------------------------------- |
|
|
95
|
+
| `src` | `string` \| `string`[] |
|
|
96
|
+
| `options?` | [`DangerouslyDeleteOptions`](../interfaces/index.DangerouslyDeleteOptions.md) |
|
|
97
|
+
|
|
98
|
+
#### Returns
|
|
99
|
+
|
|
100
|
+
[`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`\>
|
|
101
|
+
|
|
102
|
+
#### Defined in
|
|
103
|
+
|
|
104
|
+
[packages/functions/src/purge/index.ts:28](https://github.com/vercel/vercel/blob/main/packages/functions/src/purge/index.ts#L28)
|
|
105
|
+
|
|
106
|
+
---
|
|
107
|
+
|
|
63
108
|
### dangerouslyDeleteByTag
|
|
64
109
|
|
|
65
110
|
▸ **dangerouslyDeleteByTag**(`tag`, `options?`): [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`\>
|
|
@@ -77,7 +122,7 @@ attachDatabasePool(pgPool);
|
|
|
77
122
|
|
|
78
123
|
#### Defined in
|
|
79
124
|
|
|
80
|
-
[packages/functions/src/purge/index.ts:
|
|
125
|
+
[packages/functions/src/purge/index.ts:12](https://github.com/vercel/vercel/blob/main/packages/functions/src/purge/index.ts#L12)
|
|
81
126
|
|
|
82
127
|
---
|
|
83
128
|
|
|
@@ -238,6 +283,26 @@ https://vercel.com/docs/projects/environment-variables/system-environment-variab
|
|
|
238
283
|
|
|
239
284
|
---
|
|
240
285
|
|
|
286
|
+
### invalidateBySrcImage
|
|
287
|
+
|
|
288
|
+
▸ **invalidateBySrcImage**(`src`): [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`\>
|
|
289
|
+
|
|
290
|
+
#### Parameters
|
|
291
|
+
|
|
292
|
+
| Name | Type |
|
|
293
|
+
| :---- | :--------------------- |
|
|
294
|
+
| `src` | `string` \| `string`[] |
|
|
295
|
+
|
|
296
|
+
#### Returns
|
|
297
|
+
|
|
298
|
+
[`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`\>
|
|
299
|
+
|
|
300
|
+
#### Defined in
|
|
301
|
+
|
|
302
|
+
[packages/functions/src/purge/index.ts:23](https://github.com/vercel/vercel/blob/main/packages/functions/src/purge/index.ts#L23)
|
|
303
|
+
|
|
304
|
+
---
|
|
305
|
+
|
|
241
306
|
### invalidateByTag
|
|
242
307
|
|
|
243
308
|
▸ **invalidateByTag**(`tag`): [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`void`\>
|
|
@@ -254,7 +319,7 @@ https://vercel.com/docs/projects/environment-variables/system-environment-variab
|
|
|
254
319
|
|
|
255
320
|
#### Defined in
|
|
256
321
|
|
|
257
|
-
[packages/functions/src/purge/index.ts:
|
|
322
|
+
[packages/functions/src/purge/index.ts:4](https://github.com/vercel/vercel/blob/main/packages/functions/src/purge/index.ts#L4)
|
|
258
323
|
|
|
259
324
|
---
|
|
260
325
|
|
package/get-context.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { RuntimeCache } from './cache/types';
|
|
2
2
|
import { PurgeApi } from './purge/types';
|
|
3
|
+
import { AddCacheTagApi } from './addcachetag/types';
|
|
3
4
|
type Context = {
|
|
4
5
|
waitUntil?: (promise: Promise<unknown>) => void;
|
|
5
6
|
cache?: RuntimeCache;
|
|
6
7
|
purge?: PurgeApi;
|
|
8
|
+
addCacheTag?: AddCacheTagApi;
|
|
7
9
|
headers?: Record<string, string>;
|
|
8
10
|
};
|
|
9
11
|
export declare const SYMBOL_FOR_REQ_CONTEXT: unique symbol;
|
package/index.d.ts
CHANGED
|
@@ -6,5 +6,7 @@ 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';
|
|
11
|
+
export { addCacheTag } from './addcachetag';
|
|
12
|
+
export type { AddCacheTagApi } from './addcachetag/types';
|
package/index.js
CHANGED
|
@@ -18,12 +18,15 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
var src_exports = {};
|
|
20
20
|
__export(src_exports, {
|
|
21
|
+
addCacheTag: () => import_addcachetag.addCacheTag,
|
|
21
22
|
attachDatabasePool: () => import_db_connections.attachDatabasePool,
|
|
23
|
+
dangerouslyDeleteBySrcImage: () => import_purge.dangerouslyDeleteBySrcImage,
|
|
22
24
|
dangerouslyDeleteByTag: () => import_purge.dangerouslyDeleteByTag,
|
|
23
25
|
experimental_attachDatabasePool: () => import_db_connections.experimental_attachDatabasePool,
|
|
24
26
|
geolocation: () => import_headers.geolocation,
|
|
25
27
|
getCache: () => import_cache.getCache,
|
|
26
28
|
getEnv: () => import_get_env.getEnv,
|
|
29
|
+
invalidateBySrcImage: () => import_purge.invalidateBySrcImage,
|
|
27
30
|
invalidateByTag: () => import_purge.invalidateByTag,
|
|
28
31
|
ipAddress: () => import_headers.ipAddress,
|
|
29
32
|
next: () => import_middleware.next,
|
|
@@ -38,14 +41,18 @@ var import_middleware = require("./middleware");
|
|
|
38
41
|
var import_cache = require("./cache");
|
|
39
42
|
var import_db_connections = require("./db-connections");
|
|
40
43
|
var import_purge = require("./purge");
|
|
44
|
+
var import_addcachetag = require("./addcachetag");
|
|
41
45
|
// Annotate the CommonJS export names for ESM import in node:
|
|
42
46
|
0 && (module.exports = {
|
|
47
|
+
addCacheTag,
|
|
43
48
|
attachDatabasePool,
|
|
49
|
+
dangerouslyDeleteBySrcImage,
|
|
44
50
|
dangerouslyDeleteByTag,
|
|
45
51
|
experimental_attachDatabasePool,
|
|
46
52
|
geolocation,
|
|
47
53
|
getCache,
|
|
48
54
|
getEnv,
|
|
55
|
+
invalidateBySrcImage,
|
|
49
56
|
invalidateByTag,
|
|
50
57
|
ipAddress,
|
|
51
58
|
next,
|
package/package.json
CHANGED
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
|
-
|
|
46
|
-
|
|
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
|
}
|