@vercel/functions 3.7.6 → 3.8.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,19 @@
1
1
  # @vercel/functions
2
2
 
3
+ ## 3.8.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 8fb6c4f: Adds getDeadline
8
+
9
+ ## 3.7.7
10
+
11
+ ### Patch Changes
12
+
13
+ - 6d7fbfa: Bump all workspace packages to trigger a full publish from vercel-internal.
14
+ - Updated dependencies [6d7fbfa]
15
+ - @vercel/oidc@3.8.2
16
+
3
17
  ## 3.7.6
4
18
 
5
19
  ### Patch Changes
package/deadline.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Returns the shared invocation deadline for the
3
+ * current function invocation, as a Date object.
4
+ */
5
+ export declare function getDeadline(): Date | undefined;
package/deadline.js ADDED
@@ -0,0 +1,39 @@
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 deadline_exports = {};
20
+ __export(deadline_exports, {
21
+ getDeadline: () => getDeadline
22
+ });
23
+ module.exports = __toCommonJS(deadline_exports);
24
+ var import_get_context = require("./get-context");
25
+ function getDeadline() {
26
+ const deadline = (0, import_get_context.getContext)().deadline;
27
+ if (deadline === void 0) {
28
+ return void 0;
29
+ }
30
+ const date = new Date(deadline);
31
+ if (isNaN(date.getTime())) {
32
+ return void 0;
33
+ }
34
+ return date;
35
+ }
36
+ // Annotate the CommonJS export names for ESM import in node:
37
+ 0 && (module.exports = {
38
+ getDeadline
39
+ });
@@ -33,6 +33,7 @@
33
33
  - [experimental_upgradeWebSocket](functions/experimental_upgradeWebSocket.md)
34
34
  - [geolocation](functions/geolocation.md)
35
35
  - [getCache](functions/getCache.md)
36
+ - [getDeadline](functions/getDeadline.md)
36
37
  - [getEnv](functions/getEnv.md)
37
38
  - [invalidateBySrcImage](functions/invalidateBySrcImage.md)
38
39
  - [invalidateByTag](functions/invalidateByTag.md)
@@ -0,0 +1,16 @@
1
+ [**@vercel/functions**](../../README.md)
2
+
3
+ ***
4
+
5
+ # Function: getDeadline()
6
+
7
+ > **getDeadline**(): [`Date`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date) \| `undefined`
8
+
9
+ Defined in: [packages/functions/src/deadline.ts:7](https://github.com/vercel/vercel/blob/main/packages/functions/src/deadline.ts#L7)
10
+
11
+ Returns the shared invocation deadline for the
12
+ current function invocation, as a Date object.
13
+
14
+ ## Returns
15
+
16
+ [`Date`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date) \| `undefined`
package/get-context.d.ts CHANGED
@@ -5,6 +5,7 @@ import { PurgeApi } from './purge/types';
5
5
  import { AddCacheTagApi } from './addcachetag/types';
6
6
  type Context = {
7
7
  waitUntil?: (promise: Promise<unknown>) => void;
8
+ deadline?: string;
8
9
  cache?: RuntimeCache;
9
10
  purge?: PurgeApi;
10
11
  addCacheTag?: AddCacheTagApi;
package/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  export type { Request, Geo } from './headers';
2
2
  export { geolocation, ipAddress } from './headers';
3
3
  export { getEnv } from './get-env';
4
+ export { getDeadline } from './deadline';
4
5
  export { waitUntil } from './wait-until';
5
6
  export { rewrite, next } from './middleware';
6
7
  export { getCache } from './cache';
package/index.js CHANGED
@@ -26,6 +26,7 @@ __export(src_exports, {
26
26
  experimental_upgradeWebSocket: () => import_websocket.experimental_upgradeWebSocket,
27
27
  geolocation: () => import_headers.geolocation,
28
28
  getCache: () => import_cache.getCache,
29
+ getDeadline: () => import_deadline.getDeadline,
29
30
  getEnv: () => import_get_env.getEnv,
30
31
  invalidateBySrcImage: () => import_purge.invalidateBySrcImage,
31
32
  invalidateByTag: () => import_purge.invalidateByTag,
@@ -37,6 +38,7 @@ __export(src_exports, {
37
38
  module.exports = __toCommonJS(src_exports);
38
39
  var import_headers = require("./headers");
39
40
  var import_get_env = require("./get-env");
41
+ var import_deadline = require("./deadline");
40
42
  var import_wait_until = require("./wait-until");
41
43
  var import_middleware = require("./middleware");
42
44
  var import_cache = require("./cache");
@@ -54,6 +56,7 @@ var import_websocket = require("./websocket");
54
56
  experimental_upgradeWebSocket,
55
57
  geolocation,
56
58
  getCache,
59
+ getDeadline,
57
60
  getEnv,
58
61
  invalidateBySrcImage,
59
62
  invalidateByTag,
package/package.json CHANGED
@@ -30,7 +30,7 @@
30
30
  "require": "./middleware.js"
31
31
  }
32
32
  },
33
- "version": "3.7.6",
33
+ "version": "3.8.0",
34
34
  "repository": {
35
35
  "directory": "packages/functions",
36
36
  "type": "git",
@@ -77,7 +77,7 @@
77
77
  "access": "public"
78
78
  },
79
79
  "dependencies": {
80
- "@vercel/oidc": "3.8.1"
80
+ "@vercel/oidc": "3.8.2"
81
81
  },
82
82
  "scripts": {
83
83
  "pretest": "pnpm run build:code",