zitejs 0.10.0-start.23 → 0.10.0-start.26
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/cjs/cli.js +1 -1
- package/dist/cjs/dev/signin.d.ts +2 -2
- package/dist/cjs/dev/signin.js +5 -5
- package/dist/cjs/start/provider.d.ts +8 -6
- package/dist/cjs/start/provider.js +102 -41
- package/dist/cjs/start/types.d.ts +57 -13
- package/dist/esm/cli.js +1 -1
- package/dist/esm/dev/signin.d.ts +2 -2
- package/dist/esm/dev/signin.js +6 -6
- package/dist/esm/signin/conformance.js +1 -1
- package/dist/esm/signin/keys.d.ts +3 -7
- package/dist/esm/signin/keys.js +4 -10
- package/dist/esm/start/direct.d.ts +3 -3
- package/dist/esm/start/direct.js +14 -16
- package/dist/esm/start/index.d.ts +1 -1
- package/dist/esm/start/outbound.d.ts +4 -4
- package/dist/esm/start/outbound.js +33 -33
- package/dist/esm/start/pageHead.d.ts +3 -3
- package/dist/esm/start/pageHead.js +3 -8
- package/dist/esm/start/provider.d.ts +8 -6
- package/dist/esm/start/provider.js +100 -39
- package/dist/esm/start/sdk/axios.d.ts +76 -0
- package/dist/esm/start/sdk/axios.js +210 -0
- package/dist/esm/start/sdk/nodeFetch.d.ts +41 -0
- package/dist/esm/start/sdk/nodeFetch.js +33 -0
- package/dist/esm/start/sdk/undici.d.ts +34 -0
- package/dist/esm/start/sdk/undici.js +18 -0
- package/dist/esm/start/sdkPatches.d.ts +22 -0
- package/dist/esm/start/sdkPatches.js +359 -0
- package/dist/esm/start/server.d.ts +3 -3
- package/dist/esm/start/server.js +19 -20
- package/dist/esm/start/types.d.ts +57 -13
- package/dist/esm/start/version.d.ts +1 -1
- package/dist/esm/start/version.js +1 -1
- package/dist/esm/start/vite.js +2 -0
- package/package.json +2 -1
- package/dist/cjs/internal/appToken.d.ts +0 -17
- package/dist/cjs/internal/appToken.js +0 -26
- package/dist/esm/internal/appToken.d.ts +0 -17
- package/dist/esm/internal/appToken.js +0 -22
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What `axios` resolves to inside `@slack/web-api` in a Start server build, as classic's prebundle shims it: the axios
|
|
3
|
+
* surface Slack uses, on workerd's fetch. Real axios's fetch adapter sends Slack's `form-data` upload bodies as the text
|
|
4
|
+
* "[object FormData]". The app's own `axios` stays real axios.
|
|
5
|
+
*/
|
|
6
|
+
type HeaderMap = Record<string, string>;
|
|
7
|
+
type Interceptor<T> = {
|
|
8
|
+
fulfilled: (value: T) => T | Promise<T>;
|
|
9
|
+
rejected?: (error: unknown) => unknown;
|
|
10
|
+
};
|
|
11
|
+
export type AxiosRequestConfig = {
|
|
12
|
+
url?: string;
|
|
13
|
+
baseURL?: string;
|
|
14
|
+
method?: string;
|
|
15
|
+
params?: string | URLSearchParams | Record<string, unknown>;
|
|
16
|
+
data?: unknown;
|
|
17
|
+
headers?: Record<string, unknown>;
|
|
18
|
+
transformRequest?: TransformRequest | TransformRequest[];
|
|
19
|
+
responseType?: "arraybuffer" | "blob" | "text" | "stream" | "json";
|
|
20
|
+
timeout?: number;
|
|
21
|
+
signal?: AbortSignal;
|
|
22
|
+
maxRedirects?: number;
|
|
23
|
+
validateStatus?: (status: number) => boolean;
|
|
24
|
+
[option: string]: unknown;
|
|
25
|
+
};
|
|
26
|
+
type TransformRequest = (data: unknown, headers: HeaderMap) => unknown;
|
|
27
|
+
export type AxiosResponse = {
|
|
28
|
+
data: unknown;
|
|
29
|
+
status: number;
|
|
30
|
+
statusText: string;
|
|
31
|
+
headers: HeaderMap;
|
|
32
|
+
config: AxiosRequestConfig;
|
|
33
|
+
request: RequestInit;
|
|
34
|
+
};
|
|
35
|
+
export declare class AxiosError extends Error {
|
|
36
|
+
readonly code?: string | undefined;
|
|
37
|
+
readonly config?: AxiosRequestConfig | undefined;
|
|
38
|
+
readonly request?: RequestInit | undefined;
|
|
39
|
+
readonly response?: AxiosResponse | undefined;
|
|
40
|
+
readonly isAxiosError = true;
|
|
41
|
+
constructor(message: string, code?: string | undefined, config?: AxiosRequestConfig | undefined, request?: RequestInit | undefined, response?: AxiosResponse | undefined);
|
|
42
|
+
}
|
|
43
|
+
declare class CanceledError extends AxiosError {
|
|
44
|
+
constructor(message?: string);
|
|
45
|
+
}
|
|
46
|
+
declare class InterceptorManager<T> {
|
|
47
|
+
readonly handlers: (Interceptor<T> | null)[];
|
|
48
|
+
use(fulfilled: Interceptor<T>["fulfilled"], rejected?: Interceptor<T>["rejected"]): number;
|
|
49
|
+
eject(id: number): void;
|
|
50
|
+
clear(): void;
|
|
51
|
+
}
|
|
52
|
+
type AxiosInstance = {
|
|
53
|
+
(configOrUrl: string | AxiosRequestConfig, config?: AxiosRequestConfig): Promise<AxiosResponse>;
|
|
54
|
+
defaults: AxiosRequestConfig & {
|
|
55
|
+
headers: Record<string, unknown>;
|
|
56
|
+
};
|
|
57
|
+
interceptors: {
|
|
58
|
+
request: InterceptorManager<AxiosRequestConfig>;
|
|
59
|
+
response: InterceptorManager<AxiosResponse>;
|
|
60
|
+
};
|
|
61
|
+
getUri(config?: AxiosRequestConfig): string;
|
|
62
|
+
request(configOrUrl: string | AxiosRequestConfig, config?: AxiosRequestConfig): Promise<AxiosResponse>;
|
|
63
|
+
get(url: string, config?: AxiosRequestConfig): Promise<AxiosResponse>;
|
|
64
|
+
delete(url: string, config?: AxiosRequestConfig): Promise<AxiosResponse>;
|
|
65
|
+
head(url: string, config?: AxiosRequestConfig): Promise<AxiosResponse>;
|
|
66
|
+
options(url: string, config?: AxiosRequestConfig): Promise<AxiosResponse>;
|
|
67
|
+
post(url: string, data?: unknown, config?: AxiosRequestConfig): Promise<AxiosResponse>;
|
|
68
|
+
put(url: string, data?: unknown, config?: AxiosRequestConfig): Promise<AxiosResponse>;
|
|
69
|
+
patch(url: string, data?: unknown, config?: AxiosRequestConfig): Promise<AxiosResponse>;
|
|
70
|
+
create(config?: AxiosRequestConfig): AxiosInstance;
|
|
71
|
+
isAxiosError(value: unknown): value is AxiosError;
|
|
72
|
+
AxiosError: typeof AxiosError;
|
|
73
|
+
CanceledError: typeof CanceledError;
|
|
74
|
+
};
|
|
75
|
+
declare const axios: AxiosInstance;
|
|
76
|
+
export default axios;
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What `axios` resolves to inside `@slack/web-api` in a Start server build, as classic's prebundle shims it: the axios
|
|
3
|
+
* surface Slack uses, on workerd's fetch. Real axios's fetch adapter sends Slack's `form-data` upload bodies as the text
|
|
4
|
+
* "[object FormData]". The app's own `axios` stays real axios.
|
|
5
|
+
*/
|
|
6
|
+
export class AxiosError extends Error {
|
|
7
|
+
code;
|
|
8
|
+
config;
|
|
9
|
+
request;
|
|
10
|
+
response;
|
|
11
|
+
isAxiosError = true;
|
|
12
|
+
constructor(message, code, config, request, response) {
|
|
13
|
+
super(message);
|
|
14
|
+
this.code = code;
|
|
15
|
+
this.config = config;
|
|
16
|
+
this.request = request;
|
|
17
|
+
this.response = response;
|
|
18
|
+
this.name = "AxiosError";
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
class CanceledError extends AxiosError {
|
|
22
|
+
constructor(message) {
|
|
23
|
+
super(message ?? "canceled", "ERR_CANCELED");
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
// The per-method header buckets axios keeps beside the headers themselves.
|
|
27
|
+
const HEADER_BUCKETS = ["common", "get", "post", "put", "patch", "delete", "head", "options"];
|
|
28
|
+
const isRecord = (value) => typeof value === "object" && value !== null;
|
|
29
|
+
const isNodeFormData = (body) => isRecord(body) && typeof body.getHeaders === "function" && typeof body.getBuffer === "function";
|
|
30
|
+
const buildURL = (url, params) => {
|
|
31
|
+
if (!params)
|
|
32
|
+
return url;
|
|
33
|
+
const entries = typeof params === "string" || params instanceof URLSearchParams
|
|
34
|
+
? new URLSearchParams(params)
|
|
35
|
+
: new URLSearchParams(Object.entries(params).flatMap(([key, value]) => (value === undefined || value === null ? [] : [[key, String(value)]])));
|
|
36
|
+
const query = entries.toString();
|
|
37
|
+
return query ? `${url}${url.includes("?") ? "&" : "?"}${query}` : url;
|
|
38
|
+
};
|
|
39
|
+
const mergeHeaders = (...sources) => {
|
|
40
|
+
const result = {};
|
|
41
|
+
for (const source of sources) {
|
|
42
|
+
if (!source)
|
|
43
|
+
continue;
|
|
44
|
+
const entries = source instanceof Headers ? [...source.entries()] : isRecord(source) ? Object.entries(source) : [];
|
|
45
|
+
for (const [key, value] of entries) {
|
|
46
|
+
if (value !== undefined && value !== null)
|
|
47
|
+
result[key.toLowerCase()] = value;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return result;
|
|
51
|
+
};
|
|
52
|
+
const joinURL = (baseURL, url = "") => baseURL && !url.startsWith("http") ? `${baseURL.replace(/\/$/, "")}/${url.replace(/^\//, "")}` : url;
|
|
53
|
+
const withCharset = (contentType) => (/charset=/i.test(contentType) ? contentType : `${contentType}; charset=utf-8`);
|
|
54
|
+
const dispatchRequest = async (config) => {
|
|
55
|
+
const url = buildURL(joinURL(config.baseURL, config.url), config.params);
|
|
56
|
+
const method = (config.method ?? "GET").toUpperCase();
|
|
57
|
+
const buckets = config.headers ?? {};
|
|
58
|
+
const merged = mergeHeaders(buckets.common, buckets[method.toLowerCase()], buckets);
|
|
59
|
+
const headers = {};
|
|
60
|
+
for (const [key, value] of Object.entries(merged)) {
|
|
61
|
+
if (!HEADER_BUCKETS.includes(key) && !isRecord(value))
|
|
62
|
+
headers[key] = String(value);
|
|
63
|
+
}
|
|
64
|
+
let body = config.data;
|
|
65
|
+
const transforms = config.transformRequest === undefined ? [] : [config.transformRequest].flat();
|
|
66
|
+
for (const transform of transforms)
|
|
67
|
+
body = transform(body, headers);
|
|
68
|
+
if (isNodeFormData(body)) {
|
|
69
|
+
Object.assign(headers, body.getHeaders());
|
|
70
|
+
if (headers["content-type"])
|
|
71
|
+
headers["content-type"] = withCharset(headers["content-type"]);
|
|
72
|
+
body = body.getBuffer();
|
|
73
|
+
}
|
|
74
|
+
else if (typeof body === "string") {
|
|
75
|
+
headers["content-type"] = withCharset(headers["content-type"] ?? "application/x-www-form-urlencoded");
|
|
76
|
+
}
|
|
77
|
+
else if (isRecord(body) &&
|
|
78
|
+
!(body instanceof ArrayBuffer) &&
|
|
79
|
+
!ArrayBuffer.isView(body) &&
|
|
80
|
+
!(body instanceof ReadableStream) &&
|
|
81
|
+
!(body instanceof Blob) &&
|
|
82
|
+
!(body instanceof FormData) &&
|
|
83
|
+
!(body instanceof URLSearchParams)) {
|
|
84
|
+
// As Slack's serializer would: its Web API reads form fields, with anything structured JSON-encoded.
|
|
85
|
+
const params = new URLSearchParams();
|
|
86
|
+
for (const [key, value] of Object.entries(body)) {
|
|
87
|
+
if (value === undefined || value === null)
|
|
88
|
+
continue;
|
|
89
|
+
params.append(key, typeof value === "string" || typeof value === "number" || typeof value === "boolean" ? String(value) : JSON.stringify(value));
|
|
90
|
+
}
|
|
91
|
+
body = params.toString();
|
|
92
|
+
headers["content-type"] ??= "application/x-www-form-urlencoded; charset=utf-8";
|
|
93
|
+
}
|
|
94
|
+
const init = {
|
|
95
|
+
method,
|
|
96
|
+
headers,
|
|
97
|
+
body: method === "GET" || method === "HEAD" ? undefined : body,
|
|
98
|
+
signal: config.signal,
|
|
99
|
+
redirect: config.maxRedirects === 0 ? "manual" : "follow",
|
|
100
|
+
};
|
|
101
|
+
let timer;
|
|
102
|
+
if (config.timeout && config.timeout > 0 && !config.signal) {
|
|
103
|
+
const controller = new AbortController();
|
|
104
|
+
init.signal = controller.signal;
|
|
105
|
+
timer = setTimeout(() => controller.abort(), config.timeout);
|
|
106
|
+
}
|
|
107
|
+
try {
|
|
108
|
+
const res = await fetch(url, init);
|
|
109
|
+
const responseHeaders = {};
|
|
110
|
+
res.headers.forEach((value, key) => {
|
|
111
|
+
responseHeaders[key] = value;
|
|
112
|
+
});
|
|
113
|
+
let data;
|
|
114
|
+
if (config.responseType === "arraybuffer")
|
|
115
|
+
data = await res.arrayBuffer();
|
|
116
|
+
else if (config.responseType === "blob")
|
|
117
|
+
data = await res.blob();
|
|
118
|
+
else if (config.responseType === "text")
|
|
119
|
+
data = await res.text();
|
|
120
|
+
else if (config.responseType === "stream")
|
|
121
|
+
data = res.body;
|
|
122
|
+
else if ((res.headers.get("content-type") ?? "").includes("application/json"))
|
|
123
|
+
data = await res.json();
|
|
124
|
+
else {
|
|
125
|
+
const text = await res.text();
|
|
126
|
+
try {
|
|
127
|
+
data = JSON.parse(text);
|
|
128
|
+
}
|
|
129
|
+
catch {
|
|
130
|
+
data = text;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
const response = { data, status: res.status, statusText: res.statusText, headers: responseHeaders, config, request: init };
|
|
134
|
+
const validateStatus = config.validateStatus ?? ((status) => status >= 200 && status < 300);
|
|
135
|
+
if (!validateStatus(res.status)) {
|
|
136
|
+
throw new AxiosError(`Request failed with status code ${res.status}`, "ERR_BAD_RESPONSE", config, init, response);
|
|
137
|
+
}
|
|
138
|
+
return response;
|
|
139
|
+
}
|
|
140
|
+
catch (error) {
|
|
141
|
+
if (error instanceof AxiosError)
|
|
142
|
+
throw error;
|
|
143
|
+
if (error instanceof Error && error.name === "AbortError")
|
|
144
|
+
throw new AxiosError("timeout exceeded", "ECONNABORTED", config);
|
|
145
|
+
throw new AxiosError(error instanceof Error ? error.message : "Network Error", "ERR_NETWORK", config);
|
|
146
|
+
}
|
|
147
|
+
finally {
|
|
148
|
+
if (timer)
|
|
149
|
+
clearTimeout(timer);
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
class InterceptorManager {
|
|
153
|
+
handlers = [];
|
|
154
|
+
use(fulfilled, rejected) {
|
|
155
|
+
this.handlers.push({ fulfilled, rejected });
|
|
156
|
+
return this.handlers.length - 1;
|
|
157
|
+
}
|
|
158
|
+
eject(id) {
|
|
159
|
+
this.handlers[id] = null;
|
|
160
|
+
}
|
|
161
|
+
clear() {
|
|
162
|
+
this.handlers.length = 0;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
const createInstance = (defaultConfig = {}) => {
|
|
166
|
+
const defaults = { ...defaultConfig, headers: { ...defaultConfig.headers } };
|
|
167
|
+
// Slack clears `defaults.headers.post['Content-Type']`, so every bucket exists.
|
|
168
|
+
for (const bucket of HEADER_BUCKETS)
|
|
169
|
+
defaults.headers[bucket] ??= {};
|
|
170
|
+
const interceptors = { request: new InterceptorManager(), response: new InterceptorManager() };
|
|
171
|
+
const request = async (configOrUrl, config) => {
|
|
172
|
+
const given = typeof configOrUrl === "string" ? { ...config, url: configOrUrl } : { ...configOrUrl };
|
|
173
|
+
let merged = { ...defaults, ...given, headers: mergeHeaders(defaults.headers, given.headers) };
|
|
174
|
+
// As axios: request interceptors run last-registered first. Slack serializes every request body in one.
|
|
175
|
+
for (const interceptor of [...interceptors.request.handlers].reverse()) {
|
|
176
|
+
if (interceptor)
|
|
177
|
+
merged = await interceptor.fulfilled(merged);
|
|
178
|
+
}
|
|
179
|
+
let response = await dispatchRequest(merged);
|
|
180
|
+
for (const interceptor of interceptors.response.handlers) {
|
|
181
|
+
if (interceptor)
|
|
182
|
+
response = await interceptor.fulfilled(response);
|
|
183
|
+
}
|
|
184
|
+
return response;
|
|
185
|
+
};
|
|
186
|
+
const withData = (method) => (url, data, config) => request({ ...config, method, url, data });
|
|
187
|
+
const withoutData = (method) => (url, config) => request({ ...config, method, url });
|
|
188
|
+
return Object.assign(request, {
|
|
189
|
+
defaults,
|
|
190
|
+
interceptors,
|
|
191
|
+
getUri: (config = {}) => {
|
|
192
|
+
const merged = { ...defaults, ...config };
|
|
193
|
+
return buildURL(joinURL(merged.baseURL, merged.url), merged.params);
|
|
194
|
+
},
|
|
195
|
+
request,
|
|
196
|
+
get: withoutData("get"),
|
|
197
|
+
delete: withoutData("delete"),
|
|
198
|
+
head: withoutData("head"),
|
|
199
|
+
options: withoutData("options"),
|
|
200
|
+
post: withData("post"),
|
|
201
|
+
put: withData("put"),
|
|
202
|
+
patch: withData("patch"),
|
|
203
|
+
create: (config = {}) => createInstance({ ...defaults, ...config }),
|
|
204
|
+
isAxiosError: (value) => isRecord(value) && value.isAxiosError === true,
|
|
205
|
+
AxiosError,
|
|
206
|
+
CanceledError,
|
|
207
|
+
});
|
|
208
|
+
};
|
|
209
|
+
const axios = createInstance();
|
|
210
|
+
export default axios;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What `node-fetch` resolves to in a Start server build: workerd's own fetch. node-fetch's Node transport doesn't survive
|
|
3
|
+
* workerd's `node:http`: v2 throws on a POST and v3 never sees a response header, so it hands back gzip bytes.
|
|
4
|
+
*/
|
|
5
|
+
type NodeFetchResponse = Response & {
|
|
6
|
+
buffer(): Promise<Buffer>;
|
|
7
|
+
};
|
|
8
|
+
declare function nodeFetch(input: RequestInfo | URL, init?: RequestInit): Promise<NodeFetchResponse>;
|
|
9
|
+
declare class FetchError extends Error {
|
|
10
|
+
type: string;
|
|
11
|
+
code?: string;
|
|
12
|
+
constructor(message: string, type: string, systemError?: {
|
|
13
|
+
code?: string;
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
declare class AbortError extends Error {
|
|
17
|
+
type: string;
|
|
18
|
+
constructor(message: string);
|
|
19
|
+
}
|
|
20
|
+
declare const isRedirect: (status: number) => boolean;
|
|
21
|
+
declare const Headers: {
|
|
22
|
+
new (init?: HeadersInit): Headers;
|
|
23
|
+
prototype: Headers;
|
|
24
|
+
}, Request: {
|
|
25
|
+
new (input: RequestInfo | URL, init?: RequestInit): Request;
|
|
26
|
+
prototype: Request;
|
|
27
|
+
}, Response: {
|
|
28
|
+
new (body?: BodyInit | null, init?: ResponseInit): Response;
|
|
29
|
+
prototype: Response;
|
|
30
|
+
error(): Response;
|
|
31
|
+
json(data: any, init?: ResponseInit): Response;
|
|
32
|
+
redirect(url: string | URL, status?: number): Response;
|
|
33
|
+
}, Blob: {
|
|
34
|
+
new (blobParts?: BlobPart[], options?: BlobPropertyBag): Blob;
|
|
35
|
+
prototype: Blob;
|
|
36
|
+
}, FormData: {
|
|
37
|
+
new (form?: HTMLFormElement, submitter?: HTMLElement | null): FormData;
|
|
38
|
+
prototype: FormData;
|
|
39
|
+
};
|
|
40
|
+
export default nodeFetch;
|
|
41
|
+
export { AbortError, Blob, FetchError, FormData, Headers, isRedirect, Request, Response };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What `node-fetch` resolves to in a Start server build: workerd's own fetch. node-fetch's Node transport doesn't survive
|
|
3
|
+
* workerd's `node:http`: v2 throws on a POST and v3 never sees a response header, so it hands back gzip bytes.
|
|
4
|
+
*/
|
|
5
|
+
const REDIRECT_STATUSES = new Set([301, 302, 303, 307, 308]);
|
|
6
|
+
// Looked up per call, so zitejs's outbound wrapper sees every request.
|
|
7
|
+
async function nodeFetch(input, init) {
|
|
8
|
+
const res = await globalThis.fetch(input, init);
|
|
9
|
+
// node-fetch 2's body reader, which HubSpot's binary responses call.
|
|
10
|
+
return Object.assign(res, { buffer: async () => Buffer.from(await res.arrayBuffer()) });
|
|
11
|
+
}
|
|
12
|
+
class FetchError extends Error {
|
|
13
|
+
type;
|
|
14
|
+
code;
|
|
15
|
+
constructor(message, type, systemError) {
|
|
16
|
+
super(message);
|
|
17
|
+
this.name = "FetchError";
|
|
18
|
+
this.type = type;
|
|
19
|
+
if (systemError?.code)
|
|
20
|
+
this.code = systemError.code;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
class AbortError extends Error {
|
|
24
|
+
type = "aborted";
|
|
25
|
+
constructor(message) {
|
|
26
|
+
super(message);
|
|
27
|
+
this.name = "AbortError";
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
const isRedirect = (status) => REDIRECT_STATUSES.has(status);
|
|
31
|
+
const { Headers, Request, Response, Blob, FormData } = globalThis;
|
|
32
|
+
export default nodeFetch;
|
|
33
|
+
export { AbortError, Blob, FetchError, FormData, Headers, isRedirect, Request, Response };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What `undici` resolves to inside jsforce (3.13 and later) in a Start server build: the parts of its API jsforce uses, on
|
|
3
|
+
* workerd's fetch. undici's own fetch opens TLS sockets with options workerd's `node:tls` doesn't implement.
|
|
4
|
+
*/
|
|
5
|
+
export declare const fetch: (input: RequestInfo | URL, init?: RequestInit & {
|
|
6
|
+
dispatcher?: unknown;
|
|
7
|
+
}) => Promise<Response>;
|
|
8
|
+
export declare class Agent {
|
|
9
|
+
constructor(_options?: unknown);
|
|
10
|
+
}
|
|
11
|
+
export declare class ProxyAgent extends Agent {
|
|
12
|
+
}
|
|
13
|
+
declare class SocketError extends Error {
|
|
14
|
+
}
|
|
15
|
+
export declare const errors: {
|
|
16
|
+
SocketError: typeof SocketError;
|
|
17
|
+
};
|
|
18
|
+
export declare const Headers: {
|
|
19
|
+
new (init?: HeadersInit): Headers;
|
|
20
|
+
prototype: Headers;
|
|
21
|
+
}, Request: {
|
|
22
|
+
new (input: RequestInfo | URL, init?: RequestInit): Request;
|
|
23
|
+
prototype: Request;
|
|
24
|
+
}, Response: {
|
|
25
|
+
new (body?: BodyInit | null, init?: ResponseInit): Response;
|
|
26
|
+
prototype: Response;
|
|
27
|
+
error(): Response;
|
|
28
|
+
json(data: any, init?: ResponseInit): Response;
|
|
29
|
+
redirect(url: string | URL, status?: number): Response;
|
|
30
|
+
}, FormData: {
|
|
31
|
+
new (form?: HTMLFormElement, submitter?: HTMLElement | null): FormData;
|
|
32
|
+
prototype: FormData;
|
|
33
|
+
};
|
|
34
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What `undici` resolves to inside jsforce (3.13 and later) in a Start server build: the parts of its API jsforce uses, on
|
|
3
|
+
* workerd's fetch. undici's own fetch opens TLS sockets with options workerd's `node:tls` doesn't implement.
|
|
4
|
+
*/
|
|
5
|
+
// Looked up per call, so zitejs's outbound wrapper sees every request. Dispatchers are undici's; workerd has none.
|
|
6
|
+
export const fetch = (input, init) => {
|
|
7
|
+
const { dispatcher: _dispatcher, ...rest } = init ?? {};
|
|
8
|
+
return globalThis.fetch(input, rest);
|
|
9
|
+
};
|
|
10
|
+
export class Agent {
|
|
11
|
+
constructor(_options) { }
|
|
12
|
+
}
|
|
13
|
+
export class ProxyAgent extends Agent {
|
|
14
|
+
}
|
|
15
|
+
class SocketError extends Error {
|
|
16
|
+
}
|
|
17
|
+
export const errors = { SocketError };
|
|
18
|
+
export const { Headers, Request, Response, FormData } = globalThis;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type Plugin } from "vite";
|
|
2
|
+
type Package = {
|
|
3
|
+
name: string;
|
|
4
|
+
version: string;
|
|
5
|
+
dir: string;
|
|
6
|
+
browser?: Record<string, string | false>;
|
|
7
|
+
};
|
|
8
|
+
/** @internal The installed package a module file belongs to, from its innermost `node_modules`. */
|
|
9
|
+
export declare const packageOf: (file: string) => Package | undefined;
|
|
10
|
+
/** @internal googleapis-common's `apirequest.js` with binary multipart uploads fixed; null when its shape has changed. */
|
|
11
|
+
export declare const patchGoogleMultipart: (code: string) => string | null;
|
|
12
|
+
/** @internal jsforce's `request.js` on fetch bodies; null when its shape has changed. */
|
|
13
|
+
export declare const patchJsforceRequest: (code: string) => string | null;
|
|
14
|
+
/** The SDK patches a Start server build needs in workerd, as classic's prebundle applied them. */
|
|
15
|
+
export declare function sdkPatches(): Plugin;
|
|
16
|
+
/** @internal Where a package's `browser` field sends one of its files: a path, false for an empty module, or none. */
|
|
17
|
+
export declare const awsBrowserTarget: (pkg: Package, file: string) => string | false | undefined;
|
|
18
|
+
/** @internal The package a bare specifier names, scoped or not; null for a relative or absolute one. */
|
|
19
|
+
export declare const packageName: (source: string) => string | null;
|
|
20
|
+
/** @internal pdfkit's browser build with a fixed module URL and the 14 standard fonts registered; null when its shape has changed. */
|
|
21
|
+
export declare const patchPdfkitBrowser: (code: string, fontModules: string[]) => string | null;
|
|
22
|
+
export {};
|