@vercel/client 18.13.0-snapshot-224301946cd2 → 18.13.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/dist/deploy.js +41 -28
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -0
- package/dist/types.d.ts +16 -0
- package/dist/utils/gzip-request-body.d.ts +5 -0
- package/dist/utils/gzip-request-body.js +4 -2
- package/package.json +2 -2
package/dist/deploy.js
CHANGED
|
@@ -26,6 +26,13 @@ var import_ready_state = require("./utils/ready-state");
|
|
|
26
26
|
var import_check_deployment_status = require("./check-deployment-status");
|
|
27
27
|
var import_utils = require("./utils");
|
|
28
28
|
var import_gzip_request_body = require("./utils/gzip-request-body");
|
|
29
|
+
function quietly(callback) {
|
|
30
|
+
try {
|
|
31
|
+
return callback();
|
|
32
|
+
} catch {
|
|
33
|
+
return void 0;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
29
36
|
function hasEnvValues({ env, build }) {
|
|
30
37
|
return [env, build?.env].some(
|
|
31
38
|
(values) => values && Object.keys(values).length > 0
|
|
@@ -45,53 +52,59 @@ async function* postDeployment(files, clientOptions, deploymentOptions, gzipRequ
|
|
|
45
52
|
deploymentOptions.customEnvironmentSlugOrId = deploymentOptions.target;
|
|
46
53
|
deploymentOptions.target = void 0;
|
|
47
54
|
}
|
|
48
|
-
const requestDeployment = async (
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
clientOptions.token,
|
|
52
|
-
{
|
|
53
|
-
method: "POST",
|
|
54
|
-
headers: {
|
|
55
|
-
Accept: "application/json",
|
|
56
|
-
"Content-Type": "application/json",
|
|
57
|
-
...requestBody.headers
|
|
58
|
-
},
|
|
59
|
-
body: requestBody.body,
|
|
60
|
-
apiUrl: clientOptions.apiUrl,
|
|
61
|
-
userAgent: clientOptions.userAgent,
|
|
62
|
-
dispatcher: clientOptions.dispatcher,
|
|
63
|
-
getAuthHeaders: clientOptions.getAuthHeaders
|
|
64
|
-
}
|
|
55
|
+
const requestDeployment = async (json, allowGzip) => {
|
|
56
|
+
const onDone = quietly(
|
|
57
|
+
() => clientOptions.onCreationRequest?.(Buffer.byteLength(json))
|
|
65
58
|
);
|
|
59
|
+
const requestBody = await gzipRequestBodies.encode(json, allowGzip);
|
|
60
|
+
const { bytes, decodedBytes, gzip } = requestBody;
|
|
61
|
+
if (gzip) {
|
|
62
|
+
debug(`Sending a gzip request body (${bytes} of ${decodedBytes} bytes)`);
|
|
63
|
+
}
|
|
64
|
+
let response;
|
|
65
|
+
try {
|
|
66
|
+
response = await (0, import_utils.fetchApi)(
|
|
67
|
+
`${apiDeployments}${(0, import_query_string.generateQueryString)(clientOptions)}`,
|
|
68
|
+
clientOptions.token,
|
|
69
|
+
{
|
|
70
|
+
method: "POST",
|
|
71
|
+
headers: {
|
|
72
|
+
Accept: "application/json",
|
|
73
|
+
"Content-Type": "application/json",
|
|
74
|
+
...requestBody.headers
|
|
75
|
+
},
|
|
76
|
+
body: requestBody.body,
|
|
77
|
+
apiUrl: clientOptions.apiUrl,
|
|
78
|
+
userAgent: clientOptions.userAgent,
|
|
79
|
+
dispatcher: clientOptions.dispatcher,
|
|
80
|
+
getAuthHeaders: clientOptions.getAuthHeaders
|
|
81
|
+
}
|
|
82
|
+
);
|
|
83
|
+
} finally {
|
|
84
|
+
const status = response?.status;
|
|
85
|
+
quietly(() => onDone?.({ bytes, decodedBytes, gzip, status }));
|
|
86
|
+
}
|
|
66
87
|
let deployment = void 0;
|
|
67
88
|
try {
|
|
68
89
|
deployment = await response.json();
|
|
69
90
|
} catch (_error) {
|
|
70
91
|
}
|
|
71
|
-
return { response, deployment };
|
|
92
|
+
return { requestBody, response, deployment };
|
|
72
93
|
};
|
|
73
94
|
const sendDeployment = async (preparedFiles) => {
|
|
74
95
|
const json = JSON.stringify({
|
|
75
96
|
...deploymentOptions,
|
|
76
97
|
files: preparedFiles
|
|
77
98
|
});
|
|
78
|
-
|
|
99
|
+
let { requestBody, response, deployment } = await requestDeployment(
|
|
79
100
|
json,
|
|
80
101
|
!hasEnvValues(deploymentOptions)
|
|
81
102
|
);
|
|
82
|
-
if (requestBody.gzip) {
|
|
83
|
-
debug(
|
|
84
|
-
`Sending a gzip request body (${requestBody.bytes} of ${requestBody.decodedBytes} bytes)`
|
|
85
|
-
);
|
|
86
|
-
}
|
|
87
|
-
let { response, deployment } = await requestDeployment(requestBody);
|
|
88
103
|
if (gzipRequestBodies.settle(requestBody, response, deployment?.error?.code)) {
|
|
89
104
|
debug(
|
|
90
105
|
`The API refused the gzip request body with status ${response.status}. Sending it uncompressed`
|
|
91
106
|
);
|
|
92
|
-
({ response, deployment } = await requestDeployment(
|
|
93
|
-
await gzipRequestBodies.encode(json, false)
|
|
94
|
-
));
|
|
107
|
+
({ response, deployment } = await requestDeployment(json, false));
|
|
95
108
|
}
|
|
96
109
|
if (deployment === void 0) {
|
|
97
110
|
throw new Error("Invalid JSON response");
|
package/dist/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export { checkDeploymentStatus } from './check-deployment-status';
|
|
|
3
3
|
export { inspectDeploymentFiles } from './inspect-deployment-files';
|
|
4
4
|
export { getVercelIgnore, buildFileTree, isVercelStateFile, } from './utils/index';
|
|
5
5
|
export { DPOP_CLOCK_SKEW_TOLERANCE_SECONDS, getDpopServerTime, shouldResendDpopRequest, } from './utils/dpop';
|
|
6
|
+
export { MIN_GZIP_BYTES } from './utils/gzip-request-body';
|
|
6
7
|
export declare const createDeployment: (clientOptions: import("./types").VercelClientOptions, deploymentOptions?: import("./types").DeploymentOptions | Promise<import("./types").DeploymentOptions>) => AsyncIterableIterator<{
|
|
7
8
|
type: import("./types").DeploymentEventType;
|
|
8
9
|
payload: any;
|
package/dist/index.js
CHANGED
|
@@ -30,6 +30,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
var src_exports = {};
|
|
31
31
|
__export(src_exports, {
|
|
32
32
|
DPOP_CLOCK_SKEW_TOLERANCE_SECONDS: () => import_dpop.DPOP_CLOCK_SKEW_TOLERANCE_SECONDS,
|
|
33
|
+
MIN_GZIP_BYTES: () => import_gzip_request_body.MIN_GZIP_BYTES,
|
|
33
34
|
buildFileTree: () => import_utils.buildFileTree,
|
|
34
35
|
checkDeploymentStatus: () => import_check_deployment_status.checkDeploymentStatus,
|
|
35
36
|
continueDeployment: () => import_continue.continueDeployment,
|
|
@@ -47,12 +48,14 @@ var import_check_deployment_status = require("./check-deployment-status");
|
|
|
47
48
|
var import_inspect_deployment_files = require("./inspect-deployment-files");
|
|
48
49
|
var import_utils = require("./utils/index");
|
|
49
50
|
var import_dpop = require("./utils/dpop");
|
|
51
|
+
var import_gzip_request_body = require("./utils/gzip-request-body");
|
|
50
52
|
__reExport(src_exports, require("./errors"), module.exports);
|
|
51
53
|
__reExport(src_exports, require("./types"), module.exports);
|
|
52
54
|
const createDeployment = (0, import_create_deployment.default)();
|
|
53
55
|
// Annotate the CommonJS export names for ESM import in node:
|
|
54
56
|
0 && (module.exports = {
|
|
55
57
|
DPOP_CLOCK_SKEW_TOLERANCE_SECONDS,
|
|
58
|
+
MIN_GZIP_BYTES,
|
|
56
59
|
buildFileTree,
|
|
57
60
|
checkDeploymentStatus,
|
|
58
61
|
continueDeployment,
|
package/dist/types.d.ts
CHANGED
|
@@ -44,6 +44,16 @@ export interface GetAuthHeaders {
|
|
|
44
44
|
get(name: string): string | null;
|
|
45
45
|
}) => void;
|
|
46
46
|
}
|
|
47
|
+
/** A deployment creation request that ended. */
|
|
48
|
+
export interface CreationRequest {
|
|
49
|
+
/** The byte length of the request body as sent. */
|
|
50
|
+
bytes: number;
|
|
51
|
+
/** The byte length of the body before compression. */
|
|
52
|
+
decodedBytes: number;
|
|
53
|
+
gzip: boolean;
|
|
54
|
+
/** The response status. Not set when there was no response. */
|
|
55
|
+
status?: number;
|
|
56
|
+
}
|
|
47
57
|
export interface VercelClientOptions {
|
|
48
58
|
token: string;
|
|
49
59
|
/**
|
|
@@ -92,6 +102,12 @@ export interface VercelClientOptions {
|
|
|
92
102
|
* that the user later continues the deployment with an API call.
|
|
93
103
|
*/
|
|
94
104
|
manual?: boolean;
|
|
105
|
+
/**
|
|
106
|
+
* Called before each deployment creation request, to measure it, with the
|
|
107
|
+
* byte length of the body before compression. The function that it returns
|
|
108
|
+
* is called when the request ends.
|
|
109
|
+
*/
|
|
110
|
+
onCreationRequest?: (decodedBytes: number) => ((request: CreationRequest) => void) | void;
|
|
95
111
|
/**
|
|
96
112
|
* Aborted with a `DeploymentAliasAssignedEvent` when an existing deployment
|
|
97
113
|
* event stream observes alias assignment.
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A smaller body is not compressed. This size is about what fits in the first
|
|
3
|
+
* packets of a connection, so compression can't shorten the upload of less.
|
|
4
|
+
*/
|
|
5
|
+
export declare const MIN_GZIP_BYTES: number;
|
|
1
6
|
export interface RequestBody {
|
|
2
7
|
body: string | Buffer;
|
|
3
8
|
headers: Record<string, string>;
|
|
@@ -18,7 +18,8 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
var gzip_request_body_exports = {};
|
|
20
20
|
__export(gzip_request_body_exports, {
|
|
21
|
-
GzipRequestBodies: () => GzipRequestBodies
|
|
21
|
+
GzipRequestBodies: () => GzipRequestBodies,
|
|
22
|
+
MIN_GZIP_BYTES: () => MIN_GZIP_BYTES
|
|
22
23
|
});
|
|
23
24
|
module.exports = __toCommonJS(gzip_request_body_exports);
|
|
24
25
|
var import_node_util = require("node:util");
|
|
@@ -91,5 +92,6 @@ function acceptsGzip(response) {
|
|
|
91
92
|
}
|
|
92
93
|
// Annotate the CommonJS export names for ESM import in node:
|
|
93
94
|
0 && (module.exports = {
|
|
94
|
-
GzipRequestBodies
|
|
95
|
+
GzipRequestBodies,
|
|
96
|
+
MIN_GZIP_BYTES
|
|
95
97
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vercel/client",
|
|
3
|
-
"version": "18.13.0
|
|
3
|
+
"version": "18.13.0",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"typings": "dist/index.d.ts",
|
|
6
6
|
"homepage": "https://vercel.com",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"querystring": "^0.2.0",
|
|
38
38
|
"sleep-promise": "8.0.1",
|
|
39
39
|
"tar-fs": "1.16.3",
|
|
40
|
-
"@vercel/build-utils": "15.7.0
|
|
40
|
+
"@vercel/build-utils": "15.7.0",
|
|
41
41
|
"@vercel/routing-utils": "6.6.1",
|
|
42
42
|
"@vercel/error-utils": "2.2.1"
|
|
43
43
|
},
|