wrangler 2.6.2 → 2.7.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/bin/wrangler.js +9 -1
- package/miniflare-dist/index.mjs +1 -1
- package/package.json +12 -10
- package/src/__tests__/api-dev.test.ts +65 -36
- package/src/__tests__/api-devregistry.test.js +14 -6
- package/src/__tests__/configuration.test.ts +2 -31
- package/src/__tests__/{d1.test.ts → d1/d1.test.ts} +48 -5
- package/src/__tests__/d1/splitter.test.ts +255 -0
- package/src/__tests__/delete.test.ts +5 -2
- package/src/__tests__/deployments.test.ts +20 -6
- package/src/__tests__/dev.test.tsx +52 -19
- package/src/__tests__/generate.test.ts +7 -4
- package/src/__tests__/helpers/mock-auth-domain.ts +20 -0
- package/src/__tests__/helpers/mock-cfetch.ts +2 -57
- package/src/__tests__/helpers/mock-dialogs.ts +70 -86
- package/src/__tests__/helpers/mock-oauth-flow.ts +64 -49
- package/src/__tests__/helpers/mock-process.ts +8 -13
- package/src/__tests__/helpers/msw/blob-worker.cjs +19 -0
- package/src/__tests__/helpers/msw/read-file-sync.js +61 -0
- package/src/__tests__/index.test.ts +46 -44
- package/src/__tests__/init.test.ts +761 -537
- package/src/__tests__/jest.setup.ts +20 -24
- package/src/__tests__/kv.test.ts +286 -173
- package/src/__tests__/logout.test.ts +1 -1
- package/src/__tests__/metrics.test.ts +5 -7
- package/src/__tests__/middleware.scheduled.test.ts +40 -30
- package/src/__tests__/middleware.test.ts +144 -120
- package/src/__tests__/pages.test.ts +1617 -1161
- package/src/__tests__/publish.test.ts +174 -125
- package/src/__tests__/r2.test.ts +2 -2
- package/src/__tests__/secret.test.ts +183 -126
- package/src/__tests__/tail.test.ts +6 -0
- package/src/__tests__/tsconfig-sanity.ts +12 -0
- package/src/__tests__/tsconfig.json +8 -0
- package/src/__tests__/tsconfig.tsbuildinfo +1 -0
- package/src/__tests__/whoami.test.tsx +1 -96
- package/src/api/dev.ts +78 -41
- package/src/api/index.ts +1 -1
- package/src/{bundle-reporter.tsx → bundle-reporter.ts} +0 -0
- package/src/cfetch/index.ts +0 -2
- package/src/cfetch/internal.ts +6 -15
- package/src/cli.ts +2 -2
- package/src/config/validation.ts +1 -2
- package/src/create-worker-upload-form.ts +2 -2
- package/src/d1/{delete.tsx → delete.ts} +0 -0
- package/src/d1/execute.tsx +8 -37
- package/src/d1/migrations/apply.tsx +29 -19
- package/src/d1/migrations/{index.tsx → index.ts} +0 -0
- package/src/d1/splitter.ts +161 -0
- package/src/d1/{types.tsx → types.ts} +0 -0
- package/src/delete.ts +3 -8
- package/src/deployments.ts +6 -0
- package/src/deprecated/index.ts +2 -295
- package/src/dev/dev.tsx +2 -2
- package/src/dev/{get-local-persistence-path.tsx → get-local-persistence-path.ts} +0 -0
- package/src/dev/local.tsx +16 -4
- package/src/dev/remote.tsx +28 -1
- package/src/dev/start-server.ts +19 -11
- package/src/dev/use-esbuild.ts +1 -1
- package/src/{dev-registry.tsx → dev-registry.ts} +0 -0
- package/src/dev.tsx +21 -2
- package/src/dialogs.ts +136 -0
- package/src/dispatch-namespace.ts +1 -1
- package/src/docs/index.ts +3 -0
- package/src/environment-variables/factory.ts +88 -0
- package/src/environment-variables/misc-variables.ts +30 -0
- package/src/generate/index.ts +300 -0
- package/src/{index.tsx → index.ts} +10 -13
- package/src/init.ts +92 -52
- package/src/jest.d.ts +4 -0
- package/src/logger.ts +15 -3
- package/src/metrics/metrics-config.ts +1 -1
- package/src/miniflare-cli/assets.ts +4 -0
- package/src/miniflare-cli/index.ts +1 -5
- package/src/miniflare-cli/tsconfig.json +9 -0
- package/src/miniflare-cli/tsconfig.tsbuildinfo +1 -0
- package/src/miniflare-cli/types.ts +11 -0
- package/src/pages/{build.tsx → build.ts} +0 -0
- package/src/pages/{deployment-tails.tsx → deployment-tails.ts} +0 -0
- package/src/pages/{dev.tsx → dev.ts} +53 -55
- package/src/pages/functions/buildWorker.ts +1 -1
- package/src/pages/functions/tsconfig.json +8 -0
- package/src/pages/functions/tsconfig.tsbuildinfo +1 -0
- package/src/pages/{functions.tsx → functions.ts} +0 -0
- package/src/pages/{hash.tsx → hash.ts} +0 -0
- package/src/pages/{index.tsx → index.ts} +0 -0
- package/src/pages/projects.tsx +3 -5
- package/src/pages/publish.tsx +5 -4
- package/src/pages/upload.tsx +1 -1
- package/src/publish/publish.ts +9 -7
- package/src/pubsub/{pubsub-commands.tsx → pubsub-commands.ts} +1 -1
- package/src/secret/index.ts +1 -1
- package/src/{sites.tsx → sites.ts} +0 -0
- package/src/tail/index.ts +2 -3
- package/src/tsconfig-sanity.ts +16 -0
- package/src/user/access.ts +0 -1
- package/src/user/auth-variables.ts +113 -0
- package/src/user/choose-account.tsx +1 -31
- package/src/user/index.ts +0 -1
- package/src/user/{user.tsx → user.ts} +107 -73
- package/src/{whoami.tsx → whoami.ts} +37 -71
- package/templates/__tests__/tsconfig-sanity.ts +12 -0
- package/templates/__tests__/tsconfig.json +8 -0
- package/templates/__tests__/tsconfig.tsbuildinfo +1 -0
- package/templates/d1-beta-facade.js +36 -0
- package/templates/facade.d.ts +14 -0
- package/templates/first-party-worker-module-facade.ts +4 -3
- package/templates/format-dev-errors.ts +7 -6
- package/templates/init-tests/test-jest-new-worker.js +3 -5
- package/templates/init-tests/test-vitest-new-worker.js +3 -5
- package/templates/init-tests/test-vitest-new-worker.ts +25 -0
- package/templates/middleware/loader-modules.ts +0 -2
- package/templates/middleware/loader-sw.ts +6 -0
- package/templates/pages-dev-pipeline.ts +4 -1
- package/templates/pages-shim.ts +4 -1
- package/templates/pages-template-plugin.ts +12 -7
- package/templates/serve-static-assets.ts +16 -14
- package/templates/tsconfig-sanity.ts +11 -0
- package/templates/tsconfig.init.json +106 -0
- package/templates/tsconfig.json +5 -103
- package/templates/tsconfig.tsbuildinfo +1 -0
- package/wrangler-dist/cli.d.ts +58 -60
- package/wrangler-dist/cli.js +34440 -55514
- package/wrangler-dist/wasm-sync.wasm +0 -0
- package/src/__tests__/dialogs.test.tsx +0 -40
- package/src/dialogs.tsx +0 -168
- package/src/environment-variables.ts +0 -50
- package/src/user/env-vars.ts +0 -46
|
@@ -214,28 +214,61 @@ import url from "node:url";
|
|
|
214
214
|
import { TextEncoder } from "node:util";
|
|
215
215
|
import TOML from "@iarna/toml";
|
|
216
216
|
import { HostURL } from "@webcontainer/env";
|
|
217
|
-
import { render } from "ink";
|
|
218
|
-
import Table from "ink-table";
|
|
219
|
-
import React from "react";
|
|
220
217
|
import { fetch } from "undici";
|
|
221
218
|
import {
|
|
222
219
|
getConfigCache,
|
|
223
220
|
purgeConfigCaches,
|
|
224
221
|
saveToConfigCache,
|
|
225
222
|
} from "../config-cache";
|
|
223
|
+
import { NoDefaultValueProvided, select } from "../dialogs";
|
|
226
224
|
import { getGlobalWranglerConfigPath } from "../global-wrangler-config-path";
|
|
227
225
|
import { CI } from "../is-ci";
|
|
228
226
|
import isInteractive from "../is-interactive";
|
|
229
227
|
import { logger } from "../logger";
|
|
230
228
|
import openInBrowser from "../open-in-browser";
|
|
231
229
|
import { parseTOML, readFileSync } from "../parse";
|
|
232
|
-
import {
|
|
233
|
-
import {
|
|
230
|
+
import { domainUsesAccess } from "./access";
|
|
231
|
+
import {
|
|
232
|
+
getAuthDomainFromEnv,
|
|
233
|
+
getAuthUrlFromEnv,
|
|
234
|
+
getClientIdFromEnv,
|
|
235
|
+
getCloudflareAccessToken,
|
|
236
|
+
getCloudflareAPITokenFromEnv,
|
|
237
|
+
getCloudflareGlobalAuthEmailFromEnv,
|
|
238
|
+
getCloudflareGlobalAuthKeyFromEnv,
|
|
239
|
+
getRevokeUrlFromEnv,
|
|
240
|
+
getTokenUrlFromEnv,
|
|
241
|
+
} from "./auth-variables";
|
|
242
|
+
import { getAccountChoices } from "./choose-account";
|
|
234
243
|
import { generateAuthUrl } from "./generate-auth-url";
|
|
235
244
|
import { generateRandomState } from "./generate-random-state";
|
|
236
|
-
import type {
|
|
245
|
+
import type { ChooseAccountItem } from "./choose-account";
|
|
237
246
|
import type { ParsedUrlQuery } from "node:querystring";
|
|
238
247
|
|
|
248
|
+
export type ApiCredentials =
|
|
249
|
+
| {
|
|
250
|
+
apiToken: string;
|
|
251
|
+
}
|
|
252
|
+
| {
|
|
253
|
+
authKey: string;
|
|
254
|
+
authEmail: string;
|
|
255
|
+
};
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* Try to read an API token or Global Auth from the environment.
|
|
259
|
+
*/
|
|
260
|
+
export function getAuthFromEnv(): ApiCredentials | undefined {
|
|
261
|
+
const globalApiKey = getCloudflareGlobalAuthKeyFromEnv();
|
|
262
|
+
const globalApiEmail = getCloudflareGlobalAuthEmailFromEnv();
|
|
263
|
+
const apiToken = getCloudflareAPITokenFromEnv();
|
|
264
|
+
|
|
265
|
+
if (globalApiKey && globalApiEmail) {
|
|
266
|
+
return { authKey: globalApiKey, authEmail: globalApiEmail };
|
|
267
|
+
} else if (apiToken) {
|
|
268
|
+
return { apiToken };
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
|
|
239
272
|
/**
|
|
240
273
|
* An implementation of rfc6749#section-4.1 and rfc7636.
|
|
241
274
|
*/
|
|
@@ -330,11 +363,6 @@ export function validateScopeKeys(
|
|
|
330
363
|
return scopes.every((scope) => scope in Scopes);
|
|
331
364
|
}
|
|
332
365
|
|
|
333
|
-
const CLIENT_ID = "54d11594-84e4-41aa-b438-e81b8fa78ee7";
|
|
334
|
-
const AUTH_URL = "https://dash.cloudflare.com/oauth2/auth";
|
|
335
|
-
const TOKEN_URL = "https://dash.cloudflare.com/oauth2/token";
|
|
336
|
-
const REVOKE_URL = "https://dash.cloudflare.com/oauth2/revoke";
|
|
337
|
-
|
|
338
366
|
/**
|
|
339
367
|
* To allow OAuth callbacks in environments such as WebContainer we need to
|
|
340
368
|
* create a host URL which only resolves `localhost` to a WebContainer
|
|
@@ -386,7 +414,7 @@ function getAuthTokens(config?: UserAuthConfig): AuthTokens | undefined {
|
|
|
386
414
|
}
|
|
387
415
|
|
|
388
416
|
/**
|
|
389
|
-
* Run the
|
|
417
|
+
* Run the initialization of the auth state, in the case that something changed.
|
|
390
418
|
*
|
|
391
419
|
* This runs automatically whenever `writeAuthConfigFile` is run, so generally
|
|
392
420
|
* you won't need to call it yourself.
|
|
@@ -625,8 +653,8 @@ export async function getAuthURL(scopes = ScopeKeys): Promise<string> {
|
|
|
625
653
|
});
|
|
626
654
|
|
|
627
655
|
return generateAuthUrl({
|
|
628
|
-
authUrl:
|
|
629
|
-
clientId:
|
|
656
|
+
authUrl: getAuthUrlFromEnv(),
|
|
657
|
+
clientId: getClientIdFromEnv(),
|
|
630
658
|
callbackUrl: CALLBACK_URL,
|
|
631
659
|
scopes,
|
|
632
660
|
stateQueryParam,
|
|
@@ -653,19 +681,14 @@ async function exchangeRefreshTokenForAccessToken(): Promise<AccessContext> {
|
|
|
653
681
|
logger.warn("No refresh token is present.");
|
|
654
682
|
}
|
|
655
683
|
|
|
656
|
-
const
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
const response = await fetch(TOKEN_URL, {
|
|
662
|
-
method: "POST",
|
|
663
|
-
body,
|
|
664
|
-
headers: {
|
|
665
|
-
"Content-Type": "application/x-www-form-urlencoded",
|
|
666
|
-
},
|
|
684
|
+
const params = new URLSearchParams({
|
|
685
|
+
grant_type: "refresh_token",
|
|
686
|
+
refresh_token: LocalState.refreshToken?.value ?? "",
|
|
687
|
+
client_id: getClientIdFromEnv(),
|
|
667
688
|
});
|
|
668
689
|
|
|
690
|
+
const response = await fetchAuthToken(params);
|
|
691
|
+
|
|
669
692
|
if (response.status >= 400) {
|
|
670
693
|
let tokenExchangeResErr = undefined;
|
|
671
694
|
|
|
@@ -743,20 +766,15 @@ async function exchangeAuthCodeForAccessToken(): Promise<AccessContext> {
|
|
|
743
766
|
logger.warn("No authorization grant code is being passed.");
|
|
744
767
|
}
|
|
745
768
|
|
|
746
|
-
const
|
|
747
|
-
`
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
const response = await fetch(TOKEN_URL, {
|
|
754
|
-
method: "POST",
|
|
755
|
-
body,
|
|
756
|
-
headers: {
|
|
757
|
-
"Content-Type": "application/x-www-form-urlencoded",
|
|
758
|
-
},
|
|
769
|
+
const params = new URLSearchParams({
|
|
770
|
+
grant_type: `authorization_code`,
|
|
771
|
+
code: authorizationCode ?? "",
|
|
772
|
+
redirect_uri: CALLBACK_URL,
|
|
773
|
+
client_id: getClientIdFromEnv(),
|
|
774
|
+
code_verifier: codeVerifier,
|
|
759
775
|
});
|
|
776
|
+
|
|
777
|
+
const response = await fetchAuthToken(params);
|
|
760
778
|
if (!response.ok) {
|
|
761
779
|
const { error } = (await response.json()) as { error: string };
|
|
762
780
|
// .catch((_) => ({ error: "invalid_json" }));
|
|
@@ -1038,11 +1056,11 @@ export async function logout(): Promise<void> {
|
|
|
1038
1056
|
}
|
|
1039
1057
|
|
|
1040
1058
|
const body =
|
|
1041
|
-
`client_id=${encodeURIComponent(
|
|
1059
|
+
`client_id=${encodeURIComponent(getClientIdFromEnv())}&` +
|
|
1042
1060
|
`token_type_hint=refresh_token&` +
|
|
1043
1061
|
`token=${encodeURIComponent(LocalState.refreshToken?.value || "")}`;
|
|
1044
1062
|
|
|
1045
|
-
const response = await fetch(
|
|
1063
|
+
const response = await fetch(getRevokeUrlFromEnv(), {
|
|
1046
1064
|
method: "POST",
|
|
1047
1065
|
body,
|
|
1048
1066
|
headers: {
|
|
@@ -1055,11 +1073,11 @@ export async function logout(): Promise<void> {
|
|
|
1055
1073
|
);
|
|
1056
1074
|
}
|
|
1057
1075
|
const body =
|
|
1058
|
-
`client_id=${encodeURIComponent(
|
|
1076
|
+
`client_id=${encodeURIComponent(getClientIdFromEnv())}&` +
|
|
1059
1077
|
`token_type_hint=refresh_token&` +
|
|
1060
1078
|
`token=${encodeURIComponent(LocalState.refreshToken?.value || "")}`;
|
|
1061
1079
|
|
|
1062
|
-
const response = await fetch(
|
|
1080
|
+
const response = await fetch(getRevokeUrlFromEnv(), {
|
|
1063
1081
|
method: "POST",
|
|
1064
1082
|
body,
|
|
1065
1083
|
headers: {
|
|
@@ -1077,8 +1095,7 @@ export function listScopes(message = "💁 Available scopes:"): void {
|
|
|
1077
1095
|
Scope: scope,
|
|
1078
1096
|
Description: Scopes[scope],
|
|
1079
1097
|
}));
|
|
1080
|
-
|
|
1081
|
-
unmount();
|
|
1098
|
+
logger.table(data);
|
|
1082
1099
|
// TODO: maybe a good idea to show usage here
|
|
1083
1100
|
}
|
|
1084
1101
|
|
|
@@ -1097,36 +1114,32 @@ export async function getAccountId(): Promise<string | undefined> {
|
|
|
1097
1114
|
return accounts[0].id;
|
|
1098
1115
|
}
|
|
1099
1116
|
|
|
1100
|
-
|
|
1101
|
-
const
|
|
1102
|
-
(
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1117
|
+
try {
|
|
1118
|
+
const accountID = await select("Select an account", {
|
|
1119
|
+
choices: accounts.map((account) => ({
|
|
1120
|
+
title: account.name,
|
|
1121
|
+
value: account.id,
|
|
1122
|
+
})),
|
|
1123
|
+
});
|
|
1124
|
+
const account = accounts.find(
|
|
1125
|
+
(a) => a.id === accountID
|
|
1126
|
+
) as ChooseAccountItem;
|
|
1127
|
+
saveAccountToCache({ id: account.id, name: account.name });
|
|
1128
|
+
return accountID;
|
|
1129
|
+
} catch (e) {
|
|
1130
|
+
// Did we try to select an account in CI or a non-interactive terminal?
|
|
1131
|
+
if (e instanceof NoDefaultValueProvided) {
|
|
1132
|
+
throw new Error(
|
|
1133
|
+
`More than one account available but unable to select one in non-interactive mode.
|
|
1134
|
+
Please set the appropriate \`account_id\` in your \`wrangler.toml\` file.
|
|
1135
|
+
Available accounts are (\`<name>\`: \`<account_id>\`):
|
|
1136
|
+
${accounts
|
|
1137
|
+
.map((account) => ` \`${account.name}\`: \`${account.id}\``)
|
|
1138
|
+
.join("\n")}`
|
|
1139
|
+
);
|
|
1140
|
+
}
|
|
1141
|
+
throw e;
|
|
1120
1142
|
}
|
|
1121
|
-
|
|
1122
|
-
throw new Error(
|
|
1123
|
-
"More than one account available but unable to select one in non-interactive mode.\n" +
|
|
1124
|
-
`Please set the appropriate \`account_id\` in your \`wrangler.toml\` file.\n` +
|
|
1125
|
-
`Available accounts are ("<name>" - "<id>"):\n` +
|
|
1126
|
-
accounts
|
|
1127
|
-
.map((account) => ` "${account.name}" - "${account.id}")`)
|
|
1128
|
-
.join("\n")
|
|
1129
|
-
);
|
|
1130
1143
|
}
|
|
1131
1144
|
|
|
1132
1145
|
/**
|
|
@@ -1196,3 +1209,24 @@ export function getAccountFromCache():
|
|
|
1196
1209
|
export function getScopes(): Scope[] | undefined {
|
|
1197
1210
|
return LocalState.scopes;
|
|
1198
1211
|
}
|
|
1212
|
+
|
|
1213
|
+
/**
|
|
1214
|
+
* Make a request to the Cloudflare OAuth endpoint to get a token.
|
|
1215
|
+
*
|
|
1216
|
+
* Note that the `body` of the POST request is form-urlencoded so
|
|
1217
|
+
* can be represented by a URLSearchParams object.
|
|
1218
|
+
*/
|
|
1219
|
+
async function fetchAuthToken(body: URLSearchParams) {
|
|
1220
|
+
const headers: Record<string, string> = {
|
|
1221
|
+
"Content-Type": "application/x-www-form-urlencoded",
|
|
1222
|
+
};
|
|
1223
|
+
if (await domainUsesAccess(getAuthDomainFromEnv())) {
|
|
1224
|
+
// We are trying to access the staging API so we need an "access token".
|
|
1225
|
+
headers["Cookie"] = `CF_Authorization=${await getCloudflareAccessToken()}`;
|
|
1226
|
+
}
|
|
1227
|
+
return await fetch(getTokenUrlFromEnv(), {
|
|
1228
|
+
method: "POST",
|
|
1229
|
+
body: body.toString(),
|
|
1230
|
+
headers,
|
|
1231
|
+
});
|
|
1232
|
+
}
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import Table from "ink-table";
|
|
3
|
-
import React, { Fragment } from "react";
|
|
1
|
+
import chalk from "chalk";
|
|
4
2
|
import { fetchListResult, fetchResult } from "./cfetch";
|
|
5
3
|
import { logger } from "./logger";
|
|
6
4
|
import { getAPIToken, getAuthFromEnv, getScopes } from "./user";
|
|
@@ -8,82 +6,50 @@ import { getAPIToken, getAuthFromEnv, getScopes } from "./user";
|
|
|
8
6
|
export async function whoami() {
|
|
9
7
|
logger.log("Getting User settings...");
|
|
10
8
|
const user = await getUserInfo();
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
return user ? (
|
|
17
|
-
<>
|
|
18
|
-
<Email tokenType={user.authType} email={user.email}></Email>
|
|
19
|
-
<Accounts accounts={user.accounts}></Accounts>
|
|
20
|
-
<Permissions
|
|
21
|
-
tokenType={user.authType}
|
|
22
|
-
tokenPermissions={user.tokenPermissions}
|
|
23
|
-
/>
|
|
24
|
-
</>
|
|
25
|
-
) : (
|
|
26
|
-
<Text>You are not authenticated. Please run `wrangler login`.</Text>
|
|
27
|
-
);
|
|
28
|
-
}
|
|
9
|
+
if (user === undefined) {
|
|
10
|
+
return void logger.log(
|
|
11
|
+
"You are not authenticated. Please run `wrangler login`."
|
|
12
|
+
);
|
|
13
|
+
}
|
|
29
14
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
15
|
+
if (user.email !== undefined) {
|
|
16
|
+
logger.log(
|
|
17
|
+
`👋 You are logged in with an ${
|
|
18
|
+
user.authType
|
|
19
|
+
}, associated with the email ${chalk.blue(user.email)}!`
|
|
20
|
+
);
|
|
21
|
+
} else {
|
|
22
|
+
logger.log(
|
|
23
|
+
`👋 You are logged in with an ${user.authType}. Unable to retrieve email for this user. Are you missing the \`User->User Details->Read\` permission?`
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
logger.table(
|
|
27
|
+
user.accounts.map((account) => ({
|
|
28
|
+
"Account Name": account.name,
|
|
29
|
+
"Account ID": account.id,
|
|
30
|
+
}))
|
|
42
31
|
);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
function Accounts(props: { accounts: AccountInfo[] }) {
|
|
46
|
-
const accounts = props.accounts.map((account) => ({
|
|
47
|
-
"Account Name": account.name,
|
|
48
|
-
"Account ID": account.id,
|
|
49
|
-
}));
|
|
50
|
-
return <Table data={accounts}></Table>;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
function Permissions(props: {
|
|
54
|
-
tokenPermissions: string[] | undefined;
|
|
55
|
-
tokenType: string;
|
|
56
|
-
}) {
|
|
57
32
|
const permissions =
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
{permissions.map(([scope, access], index) => (
|
|
68
|
-
<Fragment key={`${scope}${index}`}>
|
|
69
|
-
<Text>
|
|
70
|
-
- {scope} {access && `(${access})`}
|
|
71
|
-
</Text>
|
|
72
|
-
</Fragment>
|
|
73
|
-
))}
|
|
74
|
-
</>
|
|
75
|
-
) : null
|
|
76
|
-
) : (
|
|
77
|
-
<Text>
|
|
78
|
-
🔓 To see token permissions visit
|
|
79
|
-
https://dash.cloudflare.com/profile/api-tokens
|
|
80
|
-
</Text>
|
|
33
|
+
user.tokenPermissions?.map((scope) => scope.split(":")) ?? [];
|
|
34
|
+
|
|
35
|
+
if (user.authType !== "OAuth Token") {
|
|
36
|
+
return void logger.log(
|
|
37
|
+
`🔓 To see token permissions visit https://dash.cloudflare.com/profile/api-tokens`
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
logger.log(
|
|
41
|
+
`🔓 Token Permissions: If scopes are missing, you may need to logout and re-login.`
|
|
81
42
|
);
|
|
43
|
+
logger.log(`Scope (Access)`);
|
|
44
|
+
for (const [scope, access] of permissions) {
|
|
45
|
+
logger.log(`- ${scope} ${access ? `(${access})` : ``}`);
|
|
46
|
+
}
|
|
82
47
|
}
|
|
83
48
|
|
|
49
|
+
type AuthType = "Global API Key" | "API Token" | "OAuth Token";
|
|
84
50
|
export interface UserInfo {
|
|
85
51
|
apiToken: string;
|
|
86
|
-
authType:
|
|
52
|
+
authType: AuthType;
|
|
87
53
|
email: string | undefined;
|
|
88
54
|
accounts: AccountInfo[];
|
|
89
55
|
tokenPermissions: string[] | undefined;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// `@types/node` should be included
|
|
2
|
+
Buffer.from("test");
|
|
3
|
+
|
|
4
|
+
// `@types/jest` should be included
|
|
5
|
+
test("test");
|
|
6
|
+
|
|
7
|
+
// @ts-expect-error `@cloudflare/workers-types` should NOT be included
|
|
8
|
+
const _handler: ExportedHandler = {};
|
|
9
|
+
// @ts-expect-error `@cloudflare/workers-types` should NOT be included
|
|
10
|
+
new HTMLRewriter();
|
|
11
|
+
|
|
12
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"program":{"fileNames":["../../../../node_modules/typescript/lib/lib.es5.d.ts","../../../../node_modules/typescript/lib/lib.es2015.d.ts","../../../../node_modules/typescript/lib/lib.es2016.d.ts","../../../../node_modules/typescript/lib/lib.es2017.d.ts","../../../../node_modules/typescript/lib/lib.es2018.d.ts","../../../../node_modules/typescript/lib/lib.es2019.d.ts","../../../../node_modules/typescript/lib/lib.es2020.d.ts","../../../../node_modules/typescript/lib/lib.es2021.d.ts","../../../../node_modules/typescript/lib/lib.es2022.d.ts","../../../../node_modules/typescript/lib/lib.esnext.d.ts","../../../../node_modules/typescript/lib/lib.es2015.core.d.ts","../../../../node_modules/typescript/lib/lib.es2015.collection.d.ts","../../../../node_modules/typescript/lib/lib.es2015.generator.d.ts","../../../../node_modules/typescript/lib/lib.es2015.iterable.d.ts","../../../../node_modules/typescript/lib/lib.es2015.promise.d.ts","../../../../node_modules/typescript/lib/lib.es2015.proxy.d.ts","../../../../node_modules/typescript/lib/lib.es2015.reflect.d.ts","../../../../node_modules/typescript/lib/lib.es2015.symbol.d.ts","../../../../node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../../../../node_modules/typescript/lib/lib.es2016.array.include.d.ts","../../../../node_modules/typescript/lib/lib.es2017.object.d.ts","../../../../node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","../../../../node_modules/typescript/lib/lib.es2017.string.d.ts","../../../../node_modules/typescript/lib/lib.es2017.intl.d.ts","../../../../node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","../../../../node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts","../../../../node_modules/typescript/lib/lib.es2018.asynciterable.d.ts","../../../../node_modules/typescript/lib/lib.es2018.intl.d.ts","../../../../node_modules/typescript/lib/lib.es2018.promise.d.ts","../../../../node_modules/typescript/lib/lib.es2018.regexp.d.ts","../../../../node_modules/typescript/lib/lib.es2019.array.d.ts","../../../../node_modules/typescript/lib/lib.es2019.object.d.ts","../../../../node_modules/typescript/lib/lib.es2019.string.d.ts","../../../../node_modules/typescript/lib/lib.es2019.symbol.d.ts","../../../../node_modules/typescript/lib/lib.es2020.bigint.d.ts","../../../../node_modules/typescript/lib/lib.es2020.date.d.ts","../../../../node_modules/typescript/lib/lib.es2020.promise.d.ts","../../../../node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts","../../../../node_modules/typescript/lib/lib.es2020.string.d.ts","../../../../node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts","../../../../node_modules/typescript/lib/lib.es2020.intl.d.ts","../../../../node_modules/typescript/lib/lib.es2020.number.d.ts","../../../../node_modules/typescript/lib/lib.es2021.promise.d.ts","../../../../node_modules/typescript/lib/lib.es2021.string.d.ts","../../../../node_modules/typescript/lib/lib.es2021.weakref.d.ts","../../../../node_modules/typescript/lib/lib.es2021.intl.d.ts","../../../../node_modules/typescript/lib/lib.es2022.array.d.ts","../../../../node_modules/typescript/lib/lib.es2022.error.d.ts","../../../../node_modules/typescript/lib/lib.es2022.intl.d.ts","../../../../node_modules/typescript/lib/lib.es2022.object.d.ts","../../../../node_modules/typescript/lib/lib.es2022.sharedmemory.d.ts","../../../../node_modules/typescript/lib/lib.es2022.string.d.ts","../../../../node_modules/typescript/lib/lib.esnext.intl.d.ts","../pages-dev-util.ts","./pages-dev-util.test.ts","./tsconfig-sanity.ts","../../../../node_modules/@types/node/assert.d.ts","../../../../node_modules/@types/node/assert/strict.d.ts","../../../../node_modules/@types/node/globals.d.ts","../../../../node_modules/@types/node/async_hooks.d.ts","../../../../node_modules/@types/node/buffer.d.ts","../../../../node_modules/@types/node/child_process.d.ts","../../../../node_modules/@types/node/cluster.d.ts","../../../../node_modules/@types/node/console.d.ts","../../../../node_modules/@types/node/constants.d.ts","../../../../node_modules/@types/node/crypto.d.ts","../../../../node_modules/@types/node/dgram.d.ts","../../../../node_modules/@types/node/diagnostics_channel.d.ts","../../../../node_modules/@types/node/dns.d.ts","../../../../node_modules/@types/node/dns/promises.d.ts","../../../../node_modules/@types/node/domain.d.ts","../../../../node_modules/@types/node/events.d.ts","../../../../node_modules/@types/node/fs.d.ts","../../../../node_modules/@types/node/fs/promises.d.ts","../../../../node_modules/@types/node/http.d.ts","../../../../node_modules/@types/node/http2.d.ts","../../../../node_modules/@types/node/https.d.ts","../../../../node_modules/@types/node/inspector.d.ts","../../../../node_modules/@types/node/module.d.ts","../../../../node_modules/@types/node/net.d.ts","../../../../node_modules/@types/node/os.d.ts","../../../../node_modules/@types/node/path.d.ts","../../../../node_modules/@types/node/perf_hooks.d.ts","../../../../node_modules/@types/node/process.d.ts","../../../../node_modules/@types/node/punycode.d.ts","../../../../node_modules/@types/node/querystring.d.ts","../../../../node_modules/@types/node/readline.d.ts","../../../../node_modules/@types/node/repl.d.ts","../../../../node_modules/@types/node/stream.d.ts","../../../../node_modules/@types/node/stream/promises.d.ts","../../../../node_modules/@types/node/stream/consumers.d.ts","../../../../node_modules/@types/node/stream/web.d.ts","../../../../node_modules/@types/node/string_decoder.d.ts","../../../../node_modules/@types/node/timers.d.ts","../../../../node_modules/@types/node/timers/promises.d.ts","../../../../node_modules/@types/node/tls.d.ts","../../../../node_modules/@types/node/trace_events.d.ts","../../../../node_modules/@types/node/tty.d.ts","../../../../node_modules/@types/node/url.d.ts","../../../../node_modules/@types/node/util.d.ts","../../../../node_modules/@types/node/v8.d.ts","../../../../node_modules/@types/node/vm.d.ts","../../../../node_modules/@types/node/wasi.d.ts","../../../../node_modules/@types/node/worker_threads.d.ts","../../../../node_modules/@types/node/zlib.d.ts","../../../../node_modules/@types/node/globals.global.d.ts","../../../../node_modules/@types/node/index.d.ts","../../../../node_modules/@types/jest/node_modules/chalk/index.d.ts","../../../../node_modules/@sinclair/typebox/typebox.d.ts","../../../../node_modules/@jest/schemas/build/index.d.ts","../../../../node_modules/@types/jest/node_modules/pretty-format/build/index.d.ts","../../../../node_modules/@types/jest/node_modules/jest-diff/build/index.d.ts","../../../../node_modules/@types/jest/node_modules/jest-matcher-utils/build/index.d.ts","../../../../node_modules/@types/jest/index.d.ts"],"fileInfos":[{"version":"f20c05dbfe50a208301d2a1da37b9931bce0466eb5a1f4fe240971b4ecc82b67","affectsGlobalScope":true},"dc47c4fa66b9b9890cf076304de2a9c5201e94b740cffdf09f87296d877d71f6","7a387c58583dfca701b6c85e0adaf43fb17d590fb16d5b2dc0a2fbd89f35c467","8a12173c586e95f4433e0c6dc446bc88346be73ffe9ca6eec7aa63c8f3dca7f9","5f4e733ced4e129482ae2186aae29fde948ab7182844c3a5a51dd346182c7b06","e6b724280c694a9f588847f754198fb96c43d805f065c3a5b28bbc9594541c84","1fc5ab7a764205c68fa10d381b08417795fc73111d6dd16b5b1ed36badb743d9","746d62152361558ea6d6115cf0da4dd10ede041d14882ede3568bce5dc4b4f1f","d11a03592451da2d1065e09e61f4e2a9bf68f780f4f6623c18b57816a9679d17","aea179452def8a6152f98f63b191b84e7cbd69b0e248c91e61fb2e52328abe8c",{"version":"adb996790133eb33b33aadb9c09f15c2c575e71fb57a62de8bf74dbf59ec7dfb","affectsGlobalScope":true},{"version":"8cc8c5a3bac513368b0157f3d8b31cfdcfe78b56d3724f30f80ed9715e404af8","affectsGlobalScope":true},{"version":"cdccba9a388c2ee3fd6ad4018c640a471a6c060e96f1232062223063b0a5ac6a","affectsGlobalScope":true},{"version":"c5c05907c02476e4bde6b7e76a79ffcd948aedd14b6a8f56e4674221b0417398","affectsGlobalScope":true},{"version":"0d5f52b3174bee6edb81260ebcd792692c32c81fd55499d69531496f3f2b25e7","affectsGlobalScope":true},{"version":"55f400eec64d17e888e278f4def2f254b41b89515d3b88ad75d5e05f019daddd","affectsGlobalScope":true},{"version":"181f1784c6c10b751631b24ce60c7f78b20665db4550b335be179217bacc0d5f","affectsGlobalScope":true},{"version":"3013574108c36fd3aaca79764002b3717da09725a36a6fc02eac386593110f93","affectsGlobalScope":true},{"version":"75ec0bdd727d887f1b79ed6619412ea72ba3c81d92d0787ccb64bab18d261f14","affectsGlobalScope":true},{"version":"3be5a1453daa63e031d266bf342f3943603873d890ab8b9ada95e22389389006","affectsGlobalScope":true},{"version":"17bb1fc99591b00515502d264fa55dc8370c45c5298f4a5c2083557dccba5a2a","affectsGlobalScope":true},{"version":"7ce9f0bde3307ca1f944119f6365f2d776d281a393b576a18a2f2893a2d75c98","affectsGlobalScope":true},{"version":"6a6b173e739a6a99629a8594bfb294cc7329bfb7b227f12e1f7c11bc163b8577","affectsGlobalScope":true},{"version":"81cac4cbc92c0c839c70f8ffb94eb61e2d32dc1c3cf6d95844ca099463cf37ea","affectsGlobalScope":true},{"version":"b0124885ef82641903d232172577f2ceb5d3e60aed4da1153bab4221e1f6dd4e","affectsGlobalScope":true},{"version":"0eb85d6c590b0d577919a79e0084fa1744c1beba6fd0d4e951432fa1ede5510a","affectsGlobalScope":true},{"version":"da233fc1c8a377ba9e0bed690a73c290d843c2c3d23a7bd7ec5cd3d7d73ba1e0","affectsGlobalScope":true},{"version":"d154ea5bb7f7f9001ed9153e876b2d5b8f5c2bb9ec02b3ae0d239ec769f1f2ae","affectsGlobalScope":true},{"version":"bb2d3fb05a1d2ffbca947cc7cbc95d23e1d053d6595391bd325deb265a18d36c","affectsGlobalScope":true},{"version":"c80df75850fea5caa2afe43b9949338ce4e2de086f91713e9af1a06f973872b8","affectsGlobalScope":true},{"version":"9d57b2b5d15838ed094aa9ff1299eecef40b190722eb619bac4616657a05f951","affectsGlobalScope":true},{"version":"6c51b5dd26a2c31dbf37f00cfc32b2aa6a92e19c995aefb5b97a3a64f1ac99de","affectsGlobalScope":true},{"version":"6e7997ef61de3132e4d4b2250e75343f487903ddf5370e7ce33cf1b9db9a63ed","affectsGlobalScope":true},{"version":"2ad234885a4240522efccd77de6c7d99eecf9b4de0914adb9a35c0c22433f993","affectsGlobalScope":true},{"version":"09aa50414b80c023553090e2f53827f007a301bc34b0495bfb2c3c08ab9ad1eb","affectsGlobalScope":true},{"version":"d7f680a43f8cd12a6b6122c07c54ba40952b0c8aa140dcfcf32eb9e6cb028596","affectsGlobalScope":true},{"version":"3787b83e297de7c315d55d4a7c546ae28e5f6c0a361b7a1dcec1f1f50a54ef11","affectsGlobalScope":true},{"version":"e7e8e1d368290e9295ef18ca23f405cf40d5456fa9f20db6373a61ca45f75f40","affectsGlobalScope":true},{"version":"faf0221ae0465363c842ce6aa8a0cbda5d9296940a8e26c86e04cc4081eea21e","affectsGlobalScope":true},{"version":"06393d13ea207a1bfe08ec8d7be562549c5e2da8983f2ee074e00002629d1871","affectsGlobalScope":true},{"version":"775d9c9fd150d5de79e0450f35bc8b8f94ae64e3eb5da12725ff2a649dccc777","affectsGlobalScope":true},{"version":"b248e32ca52e8f5571390a4142558ae4f203ae2f94d5bac38a3084d529ef4e58","affectsGlobalScope":true},{"version":"6c55633c733c8378db65ac3da7a767c3cf2cf3057f0565a9124a16a3a2019e87","affectsGlobalScope":true},{"version":"fb4416144c1bf0323ccbc9afb0ab289c07312214e8820ad17d709498c865a3fe","affectsGlobalScope":true},{"version":"5b0ca94ec819d68d33da516306c15297acec88efeb0ae9e2b39f71dbd9685ef7","affectsGlobalScope":true},{"version":"34c839eaaa6d78c8674ae2c37af2236dee6831b13db7b4ef4df3ec889a04d4f2","affectsGlobalScope":true},{"version":"34478567f8a80171f88f2f30808beb7da15eac0538ae91282dd33dce928d98ed","affectsGlobalScope":true},{"version":"ab7d58e6161a550ff92e5aff755dc37fe896245348332cd5f1e1203479fe0ed1","affectsGlobalScope":true},{"version":"6bda95ea27a59a276e46043b7065b55bd4b316c25e70e29b572958fa77565d43","affectsGlobalScope":true},{"version":"aedb8de1abb2ff1095c153854a6df7deae4a5709c37297f9d6e9948b6806fa66","affectsGlobalScope":true},{"version":"a4da0551fd39b90ca7ce5f68fb55d4dc0c1396d589b612e1902f68ee090aaada","affectsGlobalScope":true},{"version":"11ffe3c281f375fff9ffdde8bbec7669b4dd671905509079f866f2354a788064","affectsGlobalScope":true},{"version":"52d1bb7ab7a3306fd0375c8bff560feed26ed676a5b0457fa8027b563aecb9a4","affectsGlobalScope":true},"0704bdc9e66ede7a2183c419efdbb5f22c195952231e6c0b9cba526df2e8e2a4","5e22f932d1687df8312894052ab0596c3206342cab47a30052908ff6bb37af34","8d4e3c29ce13a2cfc9d60930ae3d109d858f1db924d796c2a58c4f0b56a23c2b","0d5a2ee1fdfa82740e0103389b9efd6bfe145a20018a2da3c02b89666181f4d9","a69c09dbea52352f479d3e7ac949fde3d17b195abe90b045d619f747b38d6d1a",{"version":"92d63add669d18ebc349efbacd88966d6f2ccdddfb1b880b2db98ae3aa7bf7c4","affectsGlobalScope":true},"ccc94049a9841fe47abe5baef6be9a38fc6228807974ae675fb15dc22531b4be",{"version":"9acfe4d1ff027015151ce81d60797b04b52bffe97ad8310bb0ec2e8fd61e1303","affectsGlobalScope":true},"95843d5cfafced8f3f8a5ce57d2335f0bcd361b9483587d12a25e4bd403b8216","afc6e96061af46bcff47246158caee7e056f5288783f2d83d6858cd25be1c565",{"version":"34f5bcac12b36d70304b73de5f5aab3bb91bd9919f984be80579ebcad03a624e","affectsGlobalScope":true},"82408ed3e959ddc60d3e9904481b5a8dc16469928257af22a3f7d1a3bc7fd8c4","2f520601649a893e6a49a8851ebfcf4be8ce090dc1281c2a08a871cb04e8251f","f50c975ab7b50e25a69e3d8a3773894125b44e9698924105f23b812bf7488baf","2b8c764f856a1dd0a9a2bf23e5efddbff157de8138b0754010be561ae5fcaa90","76650408392bf49a8fbf3e2b6b302712a92d76af77b06e2da1cc8077359c4409","0af3121e68297b2247dd331c0d24dba599e50736a7517a5622d5591aae4a3122","6972fca26f6e9bd56197568d4379f99071a90766e06b4fcb5920a0130a9202be",{"version":"4a2628e95962c8ab756121faa3ac2ed348112ff7a87b5c286dd2cc3326546b4c","affectsGlobalScope":true},"80793b2277f31baa199234daed806fff0fb11491d1ebd3357e520c3558063f00","a049a59a02009fc023684fcfaf0ac526fe36c35dcc5d2b7d620c1750ba11b083","196fee5541bfd59699dab615fee2ae7a6f5fe0a6337bcbbfd656ebf1ae329a63","160cc6e3d06938535bc887754afe5798c22d81ce83a9792ebfe2371a70f2ffc2","4b9a003b5c556c96784132945bb41c655ea11273b1917f5c8d0c154dd5fd20dd","a458dc78104cc80048ac24fdc02fe6dce254838094c2f25641b3f954d9721241",{"version":"e8b18c6385ff784228a6f369694fcf1a6b475355ba89090a88de13587a9391d5","affectsGlobalScope":true},"eecd493fc62c4dba3d988e2d7dff63299bf12ab49f5c9021dfef8dcc1ff2089e","abc1c425b2ad6720433f40f1877abfa4223f0f3dd486c9c28c492179ca183cb6","945a841f9a591197154c85386bc5a1467d42d325104bb36db51bc566bbb240be","10c39ce1df102994b47d4bc0c71aa9a6aea76f4651a5ec51914431f50bc883a1",{"version":"8207e7e6db9aa5fc7e61c8f17ba74cf9c115d26f51f91ee93f790815a7ea9dfb","affectsGlobalScope":true},"9f1069b9e2c051737b1f9b4f1baf50e4a63385a6a89c32235549ae87fc3d5492","ee18f2da7a037c6ceeb112a084e485aead9ea166980bf433474559eac1b46553","29c2706fa0cc49a2bd90c83234da33d08bb9554ecec675e91c1f85087f5a5324","0acbf26bf958f9e80c1ffa587b74749d2697b75b484062d36e103c137c562bc3","d7838022c7dab596357a9604b9c6adffe37dc34085ce0779c958ce9545bd7139","1b952304137851e45bc009785de89ada562d9376177c97e37702e39e60c2f1ff",{"version":"806ef4cac3b3d9fa4a48d849c8e084d7c72fcd7b16d76e06049a9ed742ff79c0","affectsGlobalScope":true},"a7971f9fb2a32ec7788ec6cda9d7a33c02023dfe9a62db2030ad1359649d8050","c33a6ea7147af60d8e98f1ac127047f4b0d4e2ce28b8f08ff3de07ca7cc00637",{"version":"b42b47e17b8ece2424ae8039feb944c2e3ba4b262986aebd582e51efbdca93dc","affectsGlobalScope":true},"664d8f2d59164f2e08c543981453893bc7e003e4dfd29651ce09db13e9457980","2408611d9b4146e35d1dbd1f443ccd8e187c74614a54b80300728277529dbf11","998a3de5237518c0b3ac00a11b3b4417affb008aa20aedee52f3fdae3cb86151","ad41008ffe077206e1811fc873f4d9005b5fd7f6ab52bb6118fef600815a5cb4",{"version":"daa2956e185fbca0591cb8cbe075c115301cbac7863092103f2aed6078dfb612","affectsGlobalScope":true},"badae0df9a8016ac36994b0a0e7b82ba6aaa3528e175a8c3cb161e4683eec03e","c3db860bcaaaeb3bbc23f353bbda1f8ab82756c8d5e973bebb3953cb09ea68f2","235a53595bd20b0b0eeb1a29cb2887c67c48375e92f03749b2488fbd46d0b1a0","bc09393cd4cd13f69cf1366d4236fbae5359bb550f0de4e15767e9a91d63dfb1","9c266243b01545e11d2733a55ad02b4c00ecdbda99c561cd1674f96e89cdc958","c71155c05fc76ff948a4759abc1cb9feec036509f500174bc18dad4c7827a60c",{"version":"ab9b9a36e5284fd8d3bf2f7d5fcbc60052f25f27e4d20954782099282c60d23e","affectsGlobalScope":true},"1503a452a67127e5c2da794d1c7c44344d5038373aae16c9b03ac964db159edd","0d14fa22c41fdc7277e6f71473b20ebc07f40f00e38875142335d5b63cdfc9d2","d982cdd2610155b3cbcbfa62ccabcf2d2b739f821518ef113348d160ef0010d9","ffcc5500e77223169833fc6eb59b3a507944a1f89574e0a1276b0ea7fc22c4a4","22f13de9e2fe5f0f4724797abd3d34a1cdd6e47ef81fc4933fea3b8bf4ad524b","e3ba509d3dce019b3190ceb2f3fc88e2610ab717122dabd91a9efaa37804040d","cda0cb09b995489b7f4c57f168cd31b83dcbaa7aad49612734fb3c9c73f6e4f2",{"version":"1de1ad6a1929317171d8cfcd55bb2732257680c1bf89bcd53e1d46a4d8dbda22","affectsGlobalScope":true}],"options":{"allowSyntheticDefaultImports":true,"alwaysStrict":false,"esModuleInterop":true,"jsx":2,"module":1,"skipLibCheck":true,"strict":true,"target":99},"fileIdsList":[[100,109],[100],[100,111,113],[100,111],[100,108,112],[100,110],[57,100],[60,100],[61,66,100],[62,72,73,80,89,99,100],[62,63,72,80,100],[64,100],[65,66,73,81,100],[66,89,96,100],[67,69,72,80,100],[68,100],[69,70,100],[71,72,100],[72,100],[72,73,74,89,99,100],[72,73,74,89,100],[75,80,89,99,100],[72,73,75,76,80,89,96,99,100],[75,77,89,96,99,100],[57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106],[72,78,100],[79,99,100],[69,72,80,89,100],[81,100],[82,100],[60,83,100],[84,98,100,104],[85,100],[86,100],[72,87,100],[87,88,100,102],[72,89,90,91,100],[89,91,100],[89,90,100],[92,100],[93,100],[72,94,95,100],[94,95,100],[66,80,96,100],[97,100],[80,98,100],[61,75,86,99,100],[66,100],[89,100,101],[100,102],[100,103],[61,66,72,74,83,89,99,100,102,104],[89,100,105],[54,100]],"referencedMap":[[110,1],[109,2],[114,3],[108,2],[112,4],[113,5],[111,6],[57,7],[58,7],[60,8],[61,9],[62,10],[63,11],[64,12],[65,13],[66,14],[67,15],[68,16],[69,17],[70,17],[71,18],[72,19],[73,20],[74,21],[59,2],[106,2],[75,22],[76,23],[77,24],[107,25],[78,26],[79,27],[80,28],[81,29],[82,30],[83,31],[84,32],[85,33],[86,34],[87,35],[88,36],[89,37],[91,38],[90,39],[92,40],[93,41],[94,42],[95,43],[96,44],[97,45],[98,46],[99,47],[100,48],[101,49],[102,50],[103,51],[104,52],[105,53],[12,2],[11,2],[2,2],[13,2],[14,2],[15,2],[16,2],[17,2],[18,2],[19,2],[20,2],[3,2],[4,2],[24,2],[21,2],[22,2],[23,2],[25,2],[26,2],[27,2],[5,2],[28,2],[29,2],[30,2],[31,2],[6,2],[32,2],[33,2],[34,2],[35,2],[7,2],[36,2],[41,2],[42,2],[37,2],[38,2],[39,2],[40,2],[8,2],[46,2],[43,2],[44,2],[45,2],[47,2],[9,2],[48,2],[49,2],[50,2],[51,2],[52,2],[1,2],[10,2],[53,2],[55,54],[56,2],[54,2]],"exportedModulesMap":[[110,1],[109,2],[114,3],[108,2],[112,4],[113,5],[111,6],[57,7],[58,7],[60,8],[61,9],[62,10],[63,11],[64,12],[65,13],[66,14],[67,15],[68,16],[69,17],[70,17],[71,18],[72,19],[73,20],[74,21],[59,2],[106,2],[75,22],[76,23],[77,24],[107,25],[78,26],[79,27],[80,28],[81,29],[82,30],[83,31],[84,32],[85,33],[86,34],[87,35],[88,36],[89,37],[91,38],[90,39],[92,40],[93,41],[94,42],[95,43],[96,44],[97,45],[98,46],[99,47],[100,48],[101,49],[102,50],[103,51],[104,52],[105,53],[12,2],[11,2],[2,2],[13,2],[14,2],[15,2],[16,2],[17,2],[18,2],[19,2],[20,2],[3,2],[4,2],[24,2],[21,2],[22,2],[23,2],[25,2],[26,2],[27,2],[5,2],[28,2],[29,2],[30,2],[31,2],[6,2],[32,2],[33,2],[34,2],[35,2],[7,2],[36,2],[41,2],[42,2],[37,2],[38,2],[39,2],[40,2],[8,2],[46,2],[43,2],[44,2],[45,2],[47,2],[9,2],[48,2],[49,2],[50,2],[51,2],[52,2],[1,2],[10,2],[53,2],[55,54],[56,2],[54,2]],"semanticDiagnosticsPerFile":[110,109,114,108,112,113,111,57,58,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,59,106,75,76,77,107,78,79,80,81,82,83,84,85,86,87,88,89,91,90,92,93,94,95,96,97,98,99,100,101,102,103,104,105,12,11,2,13,14,15,16,17,18,19,20,3,4,24,21,22,23,25,26,27,5,28,29,30,31,6,32,33,34,35,7,36,41,42,37,38,39,40,8,46,43,44,45,47,9,48,49,50,51,52,1,10,53,55,56,54],"affectedFilesPendingEmit":[[110,1],[109,1],[114,1],[108,1],[112,1],[113,1],[111,1],[57,1],[58,1],[60,1],[61,1],[62,1],[63,1],[64,1],[65,1],[66,1],[67,1],[68,1],[69,1],[70,1],[71,1],[72,1],[73,1],[74,1],[59,1],[106,1],[75,1],[76,1],[77,1],[107,1],[78,1],[79,1],[80,1],[81,1],[82,1],[83,1],[84,1],[85,1],[86,1],[87,1],[88,1],[89,1],[91,1],[90,1],[92,1],[93,1],[94,1],[95,1],[96,1],[97,1],[98,1],[99,1],[100,1],[101,1],[102,1],[103,1],[104,1],[105,1],[2,1],[3,1],[4,1],[5,1],[6,1],[7,1],[8,1],[9,1],[10,1],[55,1],[56,1],[54,1]]},"version":"4.8.4"}
|
|
@@ -110,6 +110,42 @@ var D1PreparedStatement = class {
|
|
|
110
110
|
this.params = values || [];
|
|
111
111
|
}
|
|
112
112
|
bind(...values) {
|
|
113
|
+
for (var r in values) {
|
|
114
|
+
switch (typeof values[r]) {
|
|
115
|
+
case "number":
|
|
116
|
+
case "string":
|
|
117
|
+
break;
|
|
118
|
+
case "object":
|
|
119
|
+
if (values[r] == null) break;
|
|
120
|
+
if (
|
|
121
|
+
Array.isArray(values[r]) &&
|
|
122
|
+
values[r]
|
|
123
|
+
.map((b) => {
|
|
124
|
+
return typeof b == "number" && b >= 0 && b < 256 ? 1 : 0;
|
|
125
|
+
})
|
|
126
|
+
.indexOf(0) == -1
|
|
127
|
+
)
|
|
128
|
+
break;
|
|
129
|
+
if (values[r] instanceof ArrayBuffer) {
|
|
130
|
+
values[r] = Array.from(new Uint8Array(values[r]));
|
|
131
|
+
break;
|
|
132
|
+
}
|
|
133
|
+
if (ArrayBuffer.isView(values[r])) {
|
|
134
|
+
values[r] = Array.from(values[r]);
|
|
135
|
+
break;
|
|
136
|
+
}
|
|
137
|
+
default:
|
|
138
|
+
throw new Error("D1_TYPE_ERROR", {
|
|
139
|
+
cause: new Error(
|
|
140
|
+
"Type '" +
|
|
141
|
+
typeof values[r] +
|
|
142
|
+
"' not supported for value '" +
|
|
143
|
+
values[r] +
|
|
144
|
+
"'"
|
|
145
|
+
),
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
}
|
|
113
149
|
return new D1PreparedStatement(this.database, this.statement, values);
|
|
114
150
|
}
|
|
115
151
|
async first(colName) {
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
declare module "__ENTRY_POINT__" {
|
|
2
|
+
import type { Middleware } from "./middleware/common";
|
|
3
|
+
const worker: ExportedHandler & { middleware?: Middleware[] };
|
|
4
|
+
export default worker;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
declare module "__KV_ASSET_HANDLER__" {
|
|
8
|
+
export * from "@cloudflare/kv-asset-handler";
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
declare module "__STATIC_CONTENT_MANIFEST" {
|
|
12
|
+
const manifest: string;
|
|
13
|
+
export default manifest;
|
|
14
|
+
}
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
// @ts-ignore entry point will get replaced
|
|
2
1
|
import worker from "__ENTRY_POINT__";
|
|
3
|
-
// @ts-ignore entry point will get replaced
|
|
4
2
|
export * from "__ENTRY_POINT__";
|
|
5
3
|
|
|
6
4
|
type Env = {
|
|
@@ -11,8 +9,11 @@ type Env = {
|
|
|
11
9
|
* Setup globals/vars as required
|
|
12
10
|
*/
|
|
13
11
|
|
|
14
|
-
export default {
|
|
12
|
+
export default <ExportedHandler>{
|
|
15
13
|
async fetch(request: Request, env: Env, ctx: ExecutionContext) {
|
|
14
|
+
if (worker.fetch === undefined) {
|
|
15
|
+
throw new TypeError("Entry point missing `fetch` handler");
|
|
16
|
+
}
|
|
16
17
|
return worker.fetch(request, env, ctx);
|
|
17
18
|
},
|
|
18
19
|
};
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
import Worker from "__ENTRY_POINT__";
|
|
1
|
+
import worker from "__ENTRY_POINT__";
|
|
3
2
|
|
|
4
|
-
// @ts-expect-error
|
|
5
3
|
export * from "__ENTRY_POINT__";
|
|
6
4
|
|
|
7
|
-
export default {
|
|
8
|
-
async fetch(req
|
|
5
|
+
export default <ExportedHandler>{
|
|
6
|
+
async fetch(req, env, ctx) {
|
|
7
|
+
if (worker.fetch === undefined) {
|
|
8
|
+
throw new TypeError("Entry point missing `fetch` handler");
|
|
9
|
+
}
|
|
9
10
|
try {
|
|
10
|
-
return await
|
|
11
|
+
return await worker.fetch(req, env, ctx);
|
|
11
12
|
} catch (err) {
|
|
12
13
|
return new Response(
|
|
13
14
|
`<!DOCTYPE html>
|
|
@@ -4,11 +4,9 @@ describe("Worker", () => {
|
|
|
4
4
|
let worker;
|
|
5
5
|
|
|
6
6
|
beforeAll(async () => {
|
|
7
|
-
worker = await unstable_dev(
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
{ disableExperimentalWarning: true }
|
|
11
|
-
);
|
|
7
|
+
worker = await unstable_dev("src/index.js", {
|
|
8
|
+
experimental: { disableExperimentalWarning: true },
|
|
9
|
+
});
|
|
12
10
|
});
|
|
13
11
|
|
|
14
12
|
afterAll(async () => {
|
|
@@ -5,11 +5,9 @@ describe("Worker", () => {
|
|
|
5
5
|
let worker;
|
|
6
6
|
|
|
7
7
|
beforeAll(async () => {
|
|
8
|
-
worker = await unstable_dev(
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
{ disableExperimentalWarning: true }
|
|
12
|
-
);
|
|
8
|
+
worker = await unstable_dev("src/index.js", {
|
|
9
|
+
experimental: { disableExperimentalWarning: true },
|
|
10
|
+
});
|
|
13
11
|
});
|
|
14
12
|
|
|
15
13
|
afterAll(async () => {
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { unstable_dev } from "wrangler";
|
|
2
|
+
import type { UnstableDevWorker } from "wrangler";
|
|
3
|
+
import { describe, expect, it, beforeAll, afterAll } from "vitest";
|
|
4
|
+
|
|
5
|
+
describe("Worker", () => {
|
|
6
|
+
let worker: UnstableDevWorker;
|
|
7
|
+
|
|
8
|
+
beforeAll(async () => {
|
|
9
|
+
worker = await unstable_dev("src/index.ts", {
|
|
10
|
+
experimental: { disableExperimentalWarning: true },
|
|
11
|
+
});
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
afterAll(async () => {
|
|
15
|
+
await worker.stop();
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it("should return Hello World", async () => {
|
|
19
|
+
const resp = await worker.fetch();
|
|
20
|
+
if (resp) {
|
|
21
|
+
const text = await resp.text();
|
|
22
|
+
expect(text).toMatchInlineSnapshot(`"Hello World!"`);
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
});
|
|
@@ -11,11 +11,9 @@ import {
|
|
|
11
11
|
__facade_register__,
|
|
12
12
|
} from "./common";
|
|
13
13
|
|
|
14
|
-
// @ts-expect-error We'll swap in the entry point during build
|
|
15
14
|
import worker from "__ENTRY_POINT__";
|
|
16
15
|
|
|
17
16
|
// We need to preserve all of the exports from the worker
|
|
18
|
-
// @ts-expect-error We'll swap in the entry point during build
|
|
19
17
|
export * from "__ENTRY_POINT__";
|
|
20
18
|
|
|
21
19
|
class __Facade_ScheduledController__ implements ScheduledController {
|