wrangler 4.136.3 → 4.138.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.
@@ -43784,7 +43784,7 @@ var require_snapshot_utils = __commonJS({
43784
43784
  var require_snapshot_recorder = __commonJS({
43785
43785
  "../../node_modules/.pnpm/undici@7.29.0/node_modules/undici/lib/mock/snapshot-recorder.js"(exports$1, module2) {
43786
43786
  init_import_meta_url();
43787
- var { writeFile: writeFile18, readFile: readFile24, mkdir: mkdir9 } = __require("fs/promises");
43787
+ var { writeFile: writeFile18, readFile: readFile24, mkdir: mkdir10 } = __require("fs/promises");
43788
43788
  var { dirname: dirname28, resolve: resolve35 } = __require("path");
43789
43789
  var { setTimeout: setTimeout9, clearTimeout: clearTimeout2 } = __require("timers");
43790
43790
  var { InvalidArgumentError, UndiciError } = require_errors();
@@ -44023,7 +44023,7 @@ var require_snapshot_recorder = __commonJS({
44023
44023
  throw new InvalidArgumentError("Snapshot path is required");
44024
44024
  }
44025
44025
  const resolvedPath2 = resolve35(path107);
44026
- await mkdir9(dirname28(resolvedPath2), { recursive: true });
44026
+ await mkdir10(dirname28(resolvedPath2), { recursive: true });
44027
44027
  const data = Array.from(this.#snapshots.entries()).map(([hash2, snapshot]) => ({
44028
44028
  hash: hash2,
44029
44029
  snapshot
@@ -58235,7 +58235,7 @@ var require_update_check = __commonJS({
58235
58235
  var { tmpdir: tmpdir2 } = __require("os");
58236
58236
  var registryUrl = require_registry_url();
58237
58237
  var writeFile18 = promisify9(fs38.writeFile);
58238
- var mkdir9 = promisify9(fs38.mkdir);
58238
+ var mkdir10 = promisify9(fs38.mkdir);
58239
58239
  var readFile24 = promisify9(fs38.readFile);
58240
58240
  var compareVersions = /* @__PURE__ */ __name((a8, b11) => a8.localeCompare(b11, "en-US", { numeric: true }), "compareVersions");
58241
58241
  var encode5 = /* @__PURE__ */ __name((value) => encodeURIComponent(value).replace(/^%40/, "@"), "encode");
@@ -58243,7 +58243,7 @@ var require_update_check = __commonJS({
58243
58243
  const rootDir2 = tmpdir2();
58244
58244
  const subDir = join48(rootDir2, "update-check");
58245
58245
  if (!fs38.existsSync(subDir)) {
58246
- await mkdir9(subDir);
58246
+ await mkdir10(subDir);
58247
58247
  }
58248
58248
  let name2 = `${details.name}-${distTag}.json`;
58249
58249
  if (details.scope) {
@@ -59401,6 +59401,18 @@ var init_worker_name = __esm({
59401
59401
  __name(getWorkerNameFromProject, "getWorkerNameFromProject");
59402
59402
  }
59403
59403
  });
59404
+
59405
+ // ../workers-utils/src/zod-format.ts
59406
+ function formatZodError(error53) {
59407
+ return external_exports.prettifyError(error53);
59408
+ }
59409
+ var init_zod_format = __esm({
59410
+ "../workers-utils/src/zod-format.ts"() {
59411
+ init_import_meta_url();
59412
+ init_zod();
59413
+ __name(formatZodError, "formatZodError");
59414
+ }
59415
+ });
59404
59416
  function toUrlPath(filePath) {
59405
59417
  assert38__default.default(
59406
59418
  !/^[a-z]:/i.test(filePath),
@@ -60383,6 +60395,7 @@ var init_src = __esm({
60383
60395
  init_route_utils();
60384
60396
  init_package_manager();
60385
60397
  init_worker_name();
60398
+ init_zod_format();
60386
60399
  init_url_path();
60387
60400
  init_d1_migrations();
60388
60401
  friendlyBindingNames2 = friendlyBindingNames;
@@ -62157,7 +62170,6 @@ var init_esm2 = __esm({
62157
62170
  // ../deploy-helpers/src/shared/context.ts
62158
62171
  function initDeployHelpersContext(ctx) {
62159
62172
  logger = ctx.logger;
62160
- createCloudflareClient = ctx.createCloudflareClient;
62161
62173
  fetchResult = ctx.fetchResult;
62162
62174
  fetchListResult = ctx.fetchListResult;
62163
62175
  fetchPagedListResult = ctx.fetchPagedListResult;
@@ -62166,7 +62178,7 @@ function initDeployHelpersContext(ctx) {
62166
62178
  prompt = ctx.prompt;
62167
62179
  select = ctx.select;
62168
62180
  }
62169
- var logger, createCloudflareClient, fetchResult, fetchListResult, fetchPagedListResult, confirm, prompt, select;
62181
+ var logger, fetchResult, fetchListResult, fetchPagedListResult, confirm, prompt, select;
62170
62182
  var init_context = __esm({
62171
62183
  "../deploy-helpers/src/shared/context.ts"() {
62172
62184
  init_import_meta_url();
@@ -62179,7 +62191,7 @@ var name, version2;
62179
62191
  var init_package = __esm({
62180
62192
  "package.json"() {
62181
62193
  name = "wrangler";
62182
- version2 = "4.136.3";
62194
+ version2 = "4.138.0";
62183
62195
  }
62184
62196
  });
62185
62197
 
@@ -124310,6 +124322,41 @@ function solveChallenge(challenge) {
124310
124322
  solution: { checkpoints: encodeCheckpoints(checkpoints) }
124311
124323
  };
124312
124324
  }
124325
+ function getResponseErrorCode(body) {
124326
+ if (typeof body !== "object" || body === null || !("errors" in body)) {
124327
+ return void 0;
124328
+ }
124329
+ const { errors } = body;
124330
+ if (!Array.isArray(errors) || errors.length === 0) {
124331
+ return void 0;
124332
+ }
124333
+ const [error53] = errors;
124334
+ if (typeof error53 !== "object" || error53 === null || !("code" in error53)) {
124335
+ return void 0;
124336
+ }
124337
+ return typeof error53.code === "number" ? error53.code : void 0;
124338
+ }
124339
+ async function getEventAccountError(response) {
124340
+ let body;
124341
+ try {
124342
+ body = await response.json();
124343
+ } catch {
124344
+ return void 0;
124345
+ }
124346
+ const errorCode = getResponseErrorCode(body);
124347
+ if (errorCode === void 0) {
124348
+ return void 0;
124349
+ }
124350
+ const eventError = EVENT_ACCOUNT_ERRORS.get(errorCode);
124351
+ if (!eventError) {
124352
+ return void 0;
124353
+ }
124354
+ const options = { telemetryMessage: eventError.telemetryMessage };
124355
+ if (eventError.fatal) {
124356
+ return new FatalError(eventError.message, options);
124357
+ }
124358
+ return new UserError(eventError.message, options);
124359
+ }
124313
124360
  function getTemporaryPreviewUrl() {
124314
124361
  return `${getCloudflareApiBaseUrl(COMPLIANCE_REGION_CONFIG_PUBLIC)}/provisioning/previews`;
124315
124362
  }
@@ -124371,7 +124418,7 @@ async function requestPowSolution(logger7) {
124371
124418
  logger7.log("Solving proof-of-work challenge\u2026");
124372
124419
  return solveChallenge({ challengeToken, seed, k: k7, g: g7 });
124373
124420
  }
124374
- async function createTemporaryPreviewAccount(logger7) {
124421
+ async function createTemporaryPreviewAccount(logger7, request4) {
124375
124422
  const pow = await requestPowSolution(logger7);
124376
124423
  const response = await (0, import_undici3.fetch)(getTemporaryPreviewUrl(), {
124377
124424
  method: "POST",
@@ -124381,10 +124428,17 @@ async function createTemporaryPreviewAccount(logger7) {
124381
124428
  privacyPolicy: TEMPORARY_TERMS_URLS.privacyPolicy,
124382
124429
  acceptTermsOfService: "yes",
124383
124430
  challengeToken: pow.challengeToken,
124384
- solution: pow.solution
124431
+ solution: pow.solution,
124432
+ ...request4?.eventCode ? { eventCode: request4.eventCode } : {}
124385
124433
  })
124386
124434
  });
124387
124435
  if (!response.ok) {
124436
+ if (request4?.eventCode) {
124437
+ const eventError = await getEventAccountError(response);
124438
+ if (eventError) {
124439
+ throw eventError;
124440
+ }
124441
+ }
124388
124442
  throw new FatalError(
124389
124443
  `Failed to create a temporary preview account (${response.status} ${response.statusText}).`,
124390
124444
  { telemetryMessage: "deploy temporary account create failed" }
@@ -124406,12 +124460,21 @@ async function createTemporaryPreviewAccount(logger7) {
124406
124460
  const accountExpiresAt = previewAccount?.account?.expiresAt;
124407
124461
  const claimUrl = previewAccount?.claim?.url;
124408
124462
  const claimExpiresAt = previewAccount?.claim?.expiresAt;
124463
+ const eventCodeAccepted = previewAccount?.eventCodeAccepted;
124409
124464
  if (accountId === void 0 || accountName === void 0 || apiToken === void 0 || accountExpiresAt === void 0 || claimUrl === void 0 || claimExpiresAt === void 0) {
124410
124465
  throw new FatalError(
124411
124466
  "Failed to create a temporary preview account because the response was missing required fields.",
124412
124467
  { telemetryMessage: "deploy temporary account response incomplete" }
124413
124468
  );
124414
124469
  }
124470
+ if (request4?.eventCode && eventCodeAccepted !== true) {
124471
+ throw new FatalError(
124472
+ "Failed to create a temporary preview account because the response did not acknowledge the event code.",
124473
+ {
124474
+ telemetryMessage: "deploy temporary event acknowledgement missing"
124475
+ }
124476
+ );
124477
+ }
124415
124478
  return {
124416
124479
  account: {
124417
124480
  id: accountId,
@@ -124430,6 +124493,14 @@ async function getOrCreateTemporaryPreviewAccount(options) {
124430
124493
  options.storage
124431
124494
  );
124432
124495
  if (cachedPreviewAccount) {
124496
+ if (options.request?.eventCode) {
124497
+ throw new UserError(
124498
+ "A temporary account is already cached. Rerun without --event-code to reuse it, or run `wrangler logout` and retry to create an account for this event.",
124499
+ {
124500
+ telemetryMessage: "deploy temporary event cache conflict"
124501
+ }
124502
+ );
124503
+ }
124433
124504
  return { account: cachedPreviewAccount, cached: true };
124434
124505
  }
124435
124506
  const termsAccepted = await options.prompt(
@@ -124442,7 +124513,8 @@ async function getOrCreateTemporaryPreviewAccount(options) {
124442
124513
  });
124443
124514
  }
124444
124515
  const temporaryPreviewAccount = await createTemporaryPreviewAccount(
124445
- options.logger
124516
+ options.logger,
124517
+ options.request
124446
124518
  );
124447
124519
  options.storage.write(temporaryPreviewAccount);
124448
124520
  return { account: temporaryPreviewAccount, cached: false };
@@ -125276,7 +125348,7 @@ function createOAuthFlow(ctx) {
125276
125348
  __name2(getStorage, "getStorage");
125277
125349
  const getClientId = /* @__PURE__ */ __name2(() => typeof ctx.clientId === "function" ? ctx.clientId() : ctx.clientId, "getClientId");
125278
125350
  const consent = ctx.consent;
125279
- let temporaryAllowed = false;
125351
+ let temporaryRequest;
125280
125352
  let activeTemporaryAccount;
125281
125353
  const redirectUrl = new URL(ctx.redirectUri);
125282
125354
  const defaultCallbackHost = redirectUrl.hostname;
@@ -125511,14 +125583,14 @@ function createOAuthFlow(ctx) {
125511
125583
  }
125512
125584
  __name(requireApiTokenInternal, "requireApiTokenInternal");
125513
125585
  __name2(requireApiTokenInternal, "requireApiTokenInternal");
125514
- function setTemporaryAllowed2(allowed) {
125515
- temporaryAllowed = allowed && ctx.temporary !== void 0;
125586
+ function setTemporaryAllowed2(allowed, request4) {
125587
+ temporaryRequest = allowed && ctx.temporary !== void 0 ? request4 ?? {} : void 0;
125516
125588
  activeTemporaryAccount = void 0;
125517
125589
  }
125518
125590
  __name(setTemporaryAllowed2, "setTemporaryAllowed");
125519
125591
  __name2(setTemporaryAllowed2, "setTemporaryAllowed");
125520
125592
  function isTemporaryAllowed() {
125521
- return temporaryAllowed;
125593
+ return temporaryRequest !== void 0;
125522
125594
  }
125523
125595
  __name(isTemporaryAllowed, "isTemporaryAllowed");
125524
125596
  __name2(isTemporaryAllowed, "isTemporaryAllowed");
@@ -125536,7 +125608,8 @@ function createOAuthFlow(ctx) {
125536
125608
  }
125537
125609
  const result = await getOrCreateTemporaryPreviewAccount({
125538
125610
  ...ctx.temporary,
125539
- logger: ctx.logger
125611
+ logger: ctx.logger,
125612
+ ...temporaryRequest ? { request: temporaryRequest } : {}
125540
125613
  });
125541
125614
  activeTemporaryAccount = result.account;
125542
125615
  return result;
@@ -126931,9 +127004,9 @@ function scrubEncryptedCredentials(options) {
126931
127004
  }
126932
127005
  return { backendAvailable: false, encryptedFileExisted };
126933
127006
  }
126934
- var import_undici3, hasWarnedAboutDeprecatedV1ApiToken, getCloudflareAPITokenFromEnv, getCloudflareGlobalAuthKeyFromEnv, getCloudflareGlobalAuthEmailFromEnv, ACCOUNT_ID_PATTERN, getAuthDomainFromEnv, getAuthUrlFromEnv, getTokenUrlFromEnv, getRevokeUrlFromEnv, readCloudflareAccountIdFromEnv, DEVICE_AUTH_PATH, getAccessClientIdFromEnv, getAccessClientSecretFromEnv, getCfAuthorizationTokenFromEnv, getCloudflareAuthUseKeyringFromEnv, headersCache, usesAccessCache, RECOMMENDED_CODE_VERIFIER_LENGTH, RECOMMENDED_STATE_LENGTH, PKCE_CHARSET, generateVerificationUrl, generateAuthUrl, POW_MAX_ITERATIONS, TEMPORARY_TERMS_URLS, TEMPORARY_TERMS_PROMPT, TEMPORARY_TERMS_NOTICE, TEMPORARY_TERMS_ERROR, esm_default3, ErrorOAuth2, ErrorUnknown, ErrorNoAuthCode, ErrorInvalidReturnedStateParam, ErrorInvalidJson, ErrorInvalidScope, ErrorInvalidRequest, ErrorInvalidToken, ErrorAuthenticationGrant, ErrorUnauthorizedClient, ErrorAccessDenied, ErrorUnsupportedResponseType, ErrorServerError, ErrorTemporarilyUnavailable, ErrorAccessTokenResponse, ErrorInvalidClient, ErrorInvalidGrant, ErrorUnsupportedGrantType, DEVICE_FLOW_MAX_DURATION_SECONDS, DEVICE_FLOW_MIN_POLL_INTERVAL_SECONDS, RESERVED_PROFILE_NAMES, DATE_TIME_RE2, TomlDate2, TomlError2, INT_REGEX2, FLOAT_REGEX2, LEADING_ZERO2, KEY_PART_RE2, BARE_KEY2, dist_default2, FILE_FORMATS, USER_AUTH_CONFIG_PATH, FileCredentialStore, KEY_LENGTH_BYTES, IV_LENGTH_BYTES, TAG_LENGTH_BYTES, ALGORITHM_LABEL, CIPHER_NAME, EncryptedFileCredentialStore, PINNED_KEYRING_VERSION, npmRunner, cachedBindingPathByDir, entryFactoryOverride, runner, cachedProbeResult, LinuxSecretToolKeyProvider, SECURITY_EXIT_ITEM_NOT_FOUND, runner2, MacSecurityKeyProvider, NapiKeyringKeyProvider, testProviderFactory, sessionFlags;
126935
- var init_chunk_4CJO23DA = __esm({
126936
- "../workers-auth/dist/chunk-4CJO23DA.mjs"() {
127007
+ var import_undici3, hasWarnedAboutDeprecatedV1ApiToken, getCloudflareAPITokenFromEnv, getCloudflareGlobalAuthKeyFromEnv, getCloudflareGlobalAuthEmailFromEnv, ACCOUNT_ID_PATTERN, getAuthDomainFromEnv, getAuthUrlFromEnv, getTokenUrlFromEnv, getRevokeUrlFromEnv, readCloudflareAccountIdFromEnv, DEVICE_AUTH_PATH, getAccessClientIdFromEnv, getAccessClientSecretFromEnv, getCfAuthorizationTokenFromEnv, getCloudflareAuthUseKeyringFromEnv, headersCache, usesAccessCache, RECOMMENDED_CODE_VERIFIER_LENGTH, RECOMMENDED_STATE_LENGTH, PKCE_CHARSET, generateVerificationUrl, generateAuthUrl, POW_MAX_ITERATIONS, TEMPORARY_TERMS_URLS, TEMPORARY_TERMS_PROMPT, TEMPORARY_TERMS_NOTICE, TEMPORARY_TERMS_ERROR, EVENT_ACCOUNT_ERRORS, esm_default3, ErrorOAuth2, ErrorUnknown, ErrorNoAuthCode, ErrorInvalidReturnedStateParam, ErrorInvalidJson, ErrorInvalidScope, ErrorInvalidRequest, ErrorInvalidToken, ErrorAuthenticationGrant, ErrorUnauthorizedClient, ErrorAccessDenied, ErrorUnsupportedResponseType, ErrorServerError, ErrorTemporarilyUnavailable, ErrorAccessTokenResponse, ErrorInvalidClient, ErrorInvalidGrant, ErrorUnsupportedGrantType, DEVICE_FLOW_MAX_DURATION_SECONDS, DEVICE_FLOW_MIN_POLL_INTERVAL_SECONDS, RESERVED_PROFILE_NAMES, DATE_TIME_RE2, TomlDate2, TomlError2, INT_REGEX2, FLOAT_REGEX2, LEADING_ZERO2, KEY_PART_RE2, BARE_KEY2, dist_default2, FILE_FORMATS, USER_AUTH_CONFIG_PATH, FileCredentialStore, KEY_LENGTH_BYTES, IV_LENGTH_BYTES, TAG_LENGTH_BYTES, ALGORITHM_LABEL, CIPHER_NAME, EncryptedFileCredentialStore, PINNED_KEYRING_VERSION, npmRunner, cachedBindingPathByDir, entryFactoryOverride, runner, cachedProbeResult, LinuxSecretToolKeyProvider, SECURITY_EXIT_ITEM_NOT_FOUND, runner2, MacSecurityKeyProvider, NapiKeyringKeyProvider, testProviderFactory, sessionFlags;
127008
+ var init_chunk_XLADBZ7F = __esm({
127009
+ "../workers-auth/dist/chunk-XLADBZ7F.mjs"() {
126937
127010
  init_import_meta_url();
126938
127011
  init_chunk_O6YSETKJ();
126939
127012
  init_src();
@@ -127056,6 +127129,62 @@ var init_chunk_4CJO23DA = __esm({
127056
127129
  TEMPORARY_TERMS_PROMPT = `You must accept Cloudflare's Terms of Service (${TEMPORARY_TERMS_URLS.termsOfService}) and Privacy Policy (${TEMPORARY_TERMS_URLS.privacyPolicy}) in order to continue. By typing "yes", you agree to these terms. Type "yes" to continue.`;
127057
127130
  TEMPORARY_TERMS_NOTICE = `Continuing means you accept Cloudflare's Terms of Service (${TEMPORARY_TERMS_URLS.termsOfService}) and Privacy Policy (${TEMPORARY_TERMS_URLS.privacyPolicy}).`;
127058
127131
  TEMPORARY_TERMS_ERROR = `You must accept Cloudflare's Terms of Service (${TEMPORARY_TERMS_URLS.termsOfService}) and Privacy Policy (${TEMPORARY_TERMS_URLS.privacyPolicy}) to use --temporary.`;
127132
+ EVENT_ACCOUNT_ERRORS = /* @__PURE__ */ new Map([
127133
+ [
127134
+ 1035,
127135
+ {
127136
+ message: "The event code is malformed. Check it and try again.",
127137
+ telemetryMessage: "deploy temporary event code invalid"
127138
+ }
127139
+ ],
127140
+ [
127141
+ 1036,
127142
+ {
127143
+ message: "The event code was not found. Check it and try again.",
127144
+ telemetryMessage: "deploy temporary event not found"
127145
+ }
127146
+ ],
127147
+ [
127148
+ 1037,
127149
+ {
127150
+ message: "This event has not started yet.",
127151
+ telemetryMessage: "deploy temporary event not started"
127152
+ }
127153
+ ],
127154
+ [
127155
+ 1038,
127156
+ {
127157
+ message: "This event has ended.",
127158
+ telemetryMessage: "deploy temporary event expired"
127159
+ }
127160
+ ],
127161
+ [
127162
+ 1039,
127163
+ {
127164
+ message: "This event is disabled. Contact the event organizer.",
127165
+ telemetryMessage: "deploy temporary event disabled"
127166
+ }
127167
+ ],
127168
+ [
127169
+ 1040,
127170
+ {
127171
+ message: "This event has no temporary accounts remaining.",
127172
+ telemetryMessage: "deploy temporary event exhausted"
127173
+ }
127174
+ ],
127175
+ [
127176
+ 1041,
127177
+ {
127178
+ message: "The event account could not be prepared. Try again later or contact the event organizer.",
127179
+ telemetryMessage: "deploy temporary event provisioning unavailable",
127180
+ fatal: true
127181
+ }
127182
+ ]
127183
+ ]);
127184
+ __name(getResponseErrorCode, "getResponseErrorCode");
127185
+ __name2(getResponseErrorCode, "getResponseErrorCode");
127186
+ __name(getEventAccountError, "getEventAccountError");
127187
+ __name2(getEventAccountError, "getEventAccountError");
127059
127188
  __name(getTemporaryPreviewUrl, "getTemporaryPreviewUrl");
127060
127189
  __name2(getTemporaryPreviewUrl, "getTemporaryPreviewUrl");
127061
127190
  __name(getTemporaryPreviewChallengeUrl, "getTemporaryPreviewChallengeUrl");
@@ -128006,7 +128135,7 @@ ${codeblock}`, options);
128006
128135
  var init_dist2 = __esm({
128007
128136
  "../workers-auth/dist/index.mjs"() {
128008
128137
  init_import_meta_url();
128009
- init_chunk_4CJO23DA();
128138
+ init_chunk_XLADBZ7F();
128010
128139
  }
128011
128140
  });
128012
128141
  function createPreferences(getConfigPath2) {
@@ -128364,8 +128493,8 @@ Run \`${descriptor.commands.whoami}\` to check your current authentication statu
128364
128493
  }
128365
128494
  __name(getCredentialStore2, "getCredentialStore");
128366
128495
  __name2(getCredentialStore2, "getCredentialStore");
128367
- function setTemporaryAllowed2(allowed) {
128368
- oauthFlow.setTemporaryAllowed(allowed);
128496
+ function setTemporaryAllowed2(allowed, request4) {
128497
+ oauthFlow.setTemporaryAllowed(allowed, request4);
128369
128498
  }
128370
128499
  __name(setTemporaryAllowed2, "setTemporaryAllowed");
128371
128500
  __name2(setTemporaryAllowed2, "setTemporaryAllowed");
@@ -128914,10 +129043,10 @@ function createAuthConfigFileHelpers(deps) {
128914
129043
  };
128915
129044
  }
128916
129045
  var millisecondsInMinute, minutesInYear, minutesInMonth, minutesInDay, constructFromSymbol, defaultOptions2, formatDistanceLocale, formatDistance, dateFormats, timeFormats, dateTimeFormats, formatLong, formatRelativeLocale, formatRelative, eraValues, quarterValues, monthValues, dayValues, dayPeriodValues, formattingDayPeriodValues, ordinalNumber, localize, matchOrdinalNumberPattern, parseOrdinalNumberPattern, matchEraPatterns, parseEraPatterns, matchQuarterPatterns, parseQuarterPatterns, matchMonthPatterns, parseMonthPatterns, matchDayPatterns, parseDayPatterns, matchDayPeriodPatterns, parseDayPeriodPatterns, match, enUS, MEMBERSHIPS_INACCESSIBLE_CODES, DIRECTORY_BINDINGS_FILE, ENCRYPTED_PROFILE_CONFIG_EXTENSION;
128917
- var init_chunk_A6F4WXCF = __esm({
128918
- "../workers-auth/dist/chunk-A6F4WXCF.mjs"() {
129046
+ var init_chunk_3U6VZT7T = __esm({
129047
+ "../workers-auth/dist/chunk-3U6VZT7T.mjs"() {
128919
129048
  init_import_meta_url();
128920
- init_chunk_4CJO23DA();
129049
+ init_chunk_XLADBZ7F();
128921
129050
  init_chunk_O6YSETKJ();
128922
129051
  init_src();
128923
129052
  __name(createPreferences, "createPreferences");
@@ -129431,7 +129560,7 @@ var DefaultScopes, DefaultScopeKeys, WRANGLER_KEYRING_SERVICE_NAME, WRANGLER_CLI
129431
129560
  var init_wrangler = __esm({
129432
129561
  "../workers-auth/dist/wrangler/index.mjs"() {
129433
129562
  init_import_meta_url();
129434
- init_chunk_A6F4WXCF();
129563
+ init_chunk_3U6VZT7T();
129435
129564
  init_chunk_O6YSETKJ();
129436
129565
  init_src();
129437
129566
  DefaultScopes = {
@@ -134717,8 +134846,8 @@ function getActiveProfile() {
134717
134846
  function getCredentialStore() {
134718
134847
  return auth.getCredentialStore();
134719
134848
  }
134720
- function setTemporaryAllowed(allowed) {
134721
- auth.setTemporaryAllowed(allowed);
134849
+ function setTemporaryAllowed(allowed, request4) {
134850
+ auth.setTemporaryAllowed(allowed, request4);
134722
134851
  }
134723
134852
  function getAuthFromEnv2() {
134724
134853
  return getAuthFromEnv();
@@ -134848,7 +134977,7 @@ async function logResponse(response) {
134848
134977
  logger2.debugWithSanitization("RESPONSE:", jsonText);
134849
134978
  logger2.debug("-- END CF API RESPONSE");
134850
134979
  }
134851
- function createCloudflareClient2(complianceConfig) {
134980
+ function createCloudflareClient(complianceConfig) {
134852
134981
  return new cloudflare_default({
134853
134982
  fetch: /* @__PURE__ */ __name(async (url4, init4) => {
134854
134983
  const request4 = new import_undici4.Request(url4, { ...init4, duplex: "half" });
@@ -135023,7 +135152,7 @@ var init_internal = __esm({
135023
135152
  init_user3();
135024
135153
  __name(logRequest, "logRequest");
135025
135154
  __name(logResponse, "logResponse");
135026
- __name(createCloudflareClient2, "createCloudflareClient");
135155
+ __name(createCloudflareClient, "createCloudflareClient");
135027
135156
  __name(performApiFetch, "performApiFetch");
135028
135157
  __name(fetchInternal, "fetchInternal");
135029
135158
  __name(cloneHeaders2, "cloneHeaders");
@@ -135170,7 +135299,6 @@ var init_cfetch2 = __esm({
135170
135299
  function initApiDeployHelpersContext() {
135171
135300
  initDeployHelpersContext({
135172
135301
  logger: logger2,
135173
- createCloudflareClient: createCloudflareClient2,
135174
135302
  fetchResult: fetchResult2,
135175
135303
  fetchListResult: fetchListResult2,
135176
135304
  fetchPagedListResult: fetchPagedListResult2,
@@ -135185,7 +135313,6 @@ var init_deploy_helpers_context = __esm({
135185
135313
  init_import_meta_url();
135186
135314
  init_context();
135187
135315
  init_cfetch2();
135188
- init_internal();
135189
135316
  init_dialogs();
135190
135317
  init_logger2();
135191
135318
  __name(initApiDeployHelpersContext, "initApiDeployHelpersContext");
@@ -159412,9 +159539,13 @@ async function getWorkersDevSubdomainIfAccessible(complianceConfig, accountId, o
159412
159539
  return "unauthorizedError" in result ? void 0 : result.subdomain;
159413
159540
  }
159414
159541
  async function getWorkerSubdomain(complianceConfig, accountId, workerName) {
159415
- const worker = await createCloudflareClient(
159416
- complianceConfig
159417
- ).workers.beta.workers.get(workerName, { account_id: accountId });
159542
+ const worker = await retryOnAPIFailure(
159543
+ () => fetchResult(
159544
+ complianceConfig,
159545
+ `/accounts/${accountId}/workers/workers/${workerName}`
159546
+ ),
159547
+ logger
159548
+ );
159418
159549
  return {
159419
159550
  ...worker.subdomain,
159420
159551
  enabled: worker.subdomain.enabled ?? false,
@@ -170823,6 +170954,7 @@ var init_types3 = __esm({
170823
170954
  "none"
170824
170955
  ]).optional(),
170825
170956
  not_found_handling: external_exports.enum(["single-page-application", "404-page", "none"]).optional(),
170957
+ base_path: external_exports.string().optional(),
170826
170958
  redirects: RedirectsSchema,
170827
170959
  headers: HeadersSchema,
170828
170960
  has_static_routing: external_exports.boolean().optional(),
@@ -178887,7 +179019,7 @@ var CF_KEYRING_SERVICE_NAME, CF_CLI_NAME, CF_DISPLAY_NAME, CF_OAUTH_CALLBACK_URL
178887
179019
  var init_cf = __esm({
178888
179020
  "../workers-auth/dist/cf/index.mjs"() {
178889
179021
  init_import_meta_url();
178890
- init_chunk_A6F4WXCF();
179022
+ init_chunk_3U6VZT7T();
178891
179023
  init_chunk_O6YSETKJ();
178892
179024
  init_src();
178893
179025
  CF_KEYRING_SERVICE_NAME = "cloudflare";
@@ -179892,7 +180024,7 @@ var init_dist14 = __esm({
179892
180024
  init_wrapper();
179893
180025
  init_create_worker_upload_form();
179894
180026
  import_undici13 = __toESM(require_undici(), 1);
179895
- version3 = "0.0.31";
180027
+ version3 = "0.0.33";
179896
180028
  NoDefaultValueProvided2 = class extends UserError {
179897
180029
  static {
179898
180030
  __name(this, "NoDefaultValueProvided");
@@ -180457,10 +180589,6 @@ function convertToolingConfig(parsed) {
180457
180589
  local_protocol: parsed.dev.localProtocol,
180458
180590
  upstream_protocol: parsed.dev.upstreamProtocol,
180459
180591
  host: parsed.dev.host,
180460
- // `dev.types` is intentionally NOT mapped — it is consumed
180461
- // separately via the `types` field on `LoadNewConfigResult`, not
180462
- // threaded through `RawConfig`. The legacy `config.dev.generate_types`
180463
- // gate is not used when `--experimental-new-config` is on.
180464
180592
  enable_containers: parsed.dev.enableContainers,
180465
180593
  container_engine: parsed.dev.containerEngine
180466
180594
  };
@@ -180481,7 +180609,7 @@ var init_convert = __esm({
180481
180609
  });
180482
180610
 
180483
180611
  // src/experimental-config/schema.ts
180484
- var RuleSchema, BuildSchema, PythonModulesSchema, DevSchema, WranglerConfigSchema, WRANGLER_CONFIG_SUPPORTED_KEYS, WORKER_CONFIG_FIELD_HINTS;
180612
+ var RuleSchema, BuildSchema, PythonModulesSchema, TypesSchema, DevSchema, WranglerConfigSchema, WRANGLER_CONFIG_SUPPORTED_KEYS, WORKER_CONFIG_FIELD_HINTS;
180485
180613
  var init_schema2 = __esm({
180486
180614
  "src/experimental-config/schema.ts"() {
180487
180615
  init_import_meta_url();
@@ -180507,6 +180635,10 @@ var init_schema2 = __esm({
180507
180635
  PythonModulesSchema = strictObject({
180508
180636
  exclude: array(string2()).optional()
180509
180637
  });
180638
+ TypesSchema = strictObject({
180639
+ generate: boolean2().optional(),
180640
+ includeRuntime: boolean2().optional()
180641
+ });
180510
180642
  DevSchema = strictObject({
180511
180643
  ip: string2().optional(),
180512
180644
  port: number2().optional(),
@@ -180515,10 +180647,6 @@ var init_schema2 = __esm({
180515
180647
  localProtocol: _enum2(["http", "https"]).optional(),
180516
180648
  upstreamProtocol: _enum2(["http", "https"]).optional(),
180517
180649
  host: string2().optional(),
180518
- types: strictObject({
180519
- generate: boolean2().optional(),
180520
- includeRuntime: boolean2().optional()
180521
- }).optional(),
180522
180650
  enableContainers: boolean2().optional(),
180523
180651
  containerEngine: string2().optional()
180524
180652
  });
@@ -180542,6 +180670,7 @@ var init_schema2 = __esm({
180542
180670
  uploadSourceMaps: boolean2().optional(),
180543
180671
  build: BuildSchema.optional(),
180544
180672
  assetsDirectory: string2().optional(),
180673
+ types: TypesSchema.optional(),
180545
180674
  dev: DevSchema.optional(),
180546
180675
  sendMetrics: boolean2().optional()
180547
180676
  });
@@ -180648,8 +180777,8 @@ ${formatWranglerConfigZodError(parsed.error)}`,
180648
180777
  );
180649
180778
  const rawConfig = mergeRawConfigs(rawWorkerConfig, rawWranglerConfig);
180650
180779
  const types14 = {
180651
- generate: parsedWranglerConfig?.data.dev?.types?.generate ?? true,
180652
- includeRuntime: parsedWranglerConfig?.data.dev?.types?.includeRuntime ?? true
180780
+ generate: parsedWranglerConfig?.data.types?.generate ?? true,
180781
+ includeRuntime: parsedWranglerConfig?.data.types?.includeRuntime ?? true
180653
180782
  };
180654
180783
  const dependencies = new Set(configResult.dependencies);
180655
180784
  if (wranglerConfigResult) {
@@ -180680,15 +180809,6 @@ function mergeRawConfigs(worker, tooling) {
180680
180809
  function dottedPath(issuePath) {
180681
180810
  return issuePath.filter((p8) => typeof p8 !== "symbol").join(".");
180682
180811
  }
180683
- function formatZodError(err) {
180684
- if (!err.issues || err.issues.length === 0) {
180685
- return err.message ?? "Unknown validation error";
180686
- }
180687
- return err.issues.map((issue2) => {
180688
- const dotted = dottedPath(issue2.path);
180689
- return dotted ? ` \u2022 ${dotted}: ${issue2.message}` : ` \u2022 ${issue2.message}`;
180690
- }).join("\n");
180691
- }
180692
180812
  function formatWranglerConfigZodError(err) {
180693
180813
  if (!err.issues || err.issues.length === 0) {
180694
180814
  return err.message ?? "Unknown validation error";
@@ -180721,7 +180841,6 @@ var init_load = __esm({
180721
180841
  __name(loadNewConfig, "loadNewConfig");
180722
180842
  __name(mergeRawConfigs, "mergeRawConfigs");
180723
180843
  __name(dottedPath, "dottedPath");
180724
- __name(formatZodError, "formatZodError");
180725
180844
  __name(formatWranglerConfigZodError, "formatWranglerConfigZodError");
180726
180845
  }
180727
180846
  });
@@ -181586,6 +181705,7 @@ async function readNewConfig(args, options = {}) {
181586
181705
  return {
181587
181706
  config: config2,
181588
181707
  parsedConfig: loaded.parsedConfig,
181708
+ cloudflareConfigPath: loaded.cloudflareConfigPath,
181589
181709
  mode: loaded.mode,
181590
181710
  dependencies: loaded.dependencies,
181591
181711
  types: loaded.types
@@ -205572,17 +205692,16 @@ async function regenerateNewConfigTypes(options) {
205572
205692
  }
205573
205693
  let existing;
205574
205694
  try {
205575
- existing = await fs$1.readFile(DEFAULT_WORKERS_TYPES_FILE_PATH, "utf-8");
205695
+ existing = await fs$1.readFile(NEW_CONFIG_TYPES_OUTPUT_PATH, "utf-8");
205576
205696
  } catch {
205577
205697
  }
205578
205698
  let content;
205579
205699
  try {
205580
- const outputDir = path28__namespace.default.dirname(
205581
- path28__namespace.default.resolve(DEFAULT_WORKERS_TYPES_FILE_PATH)
205582
- );
205583
- const relativeConfigPath = "./" + path28__namespace.default.relative(outputDir, options.cloudflareConfigPath);
205700
+ const outputDir = path28__namespace.default.dirname(path28__namespace.default.resolve(NEW_CONFIG_TYPES_OUTPUT_PATH));
205701
+ const relativeConfigPath = path28__namespace.default.relative(outputDir, options.cloudflareConfigPath).replaceAll("\\", "/");
205702
+ const configImportPath = relativeConfigPath.startsWith(".") ? relativeConfigPath : `./${relativeConfigPath}`;
205584
205703
  content = generateTypes({
205585
- configPath: relativeConfigPath,
205704
+ configPath: configImportPath,
205586
205705
  packageName: "wrangler/experimental-config"
205587
205706
  });
205588
205707
  if (options.types.includeRuntime) {
@@ -205606,22 +205725,26 @@ ${runtimeTypes}`;
205606
205725
  return;
205607
205726
  }
205608
205727
  try {
205609
- await fs$1.writeFile(DEFAULT_WORKERS_TYPES_FILE_PATH, content);
205728
+ await fs$1.mkdir(path28__namespace.default.dirname(NEW_CONFIG_TYPES_OUTPUT_PATH), {
205729
+ recursive: true
205730
+ });
205731
+ await fs$1.writeFile(NEW_CONFIG_TYPES_OUTPUT_PATH, content);
205610
205732
  logger2.log(
205611
- `\u{1F4DD} Regenerated ${path28__namespace.default.relative(process.cwd(), DEFAULT_WORKERS_TYPES_FILE_NAME)} from ${path28__namespace.default.relative(process.cwd(), options.cloudflareConfigPath)}.`
205733
+ `\u{1F4DD} Regenerated ${NEW_CONFIG_TYPES_OUTPUT_PATH} from ${path28__namespace.default.relative(process.cwd(), options.cloudflareConfigPath)}.`
205612
205734
  );
205613
205735
  } catch (e11) {
205614
205736
  logger2.error(e11);
205615
205737
  }
205616
205738
  }
205739
+ var NEW_CONFIG_TYPES_OUTPUT_PATH;
205617
205740
  var init_new_config = __esm({
205618
205741
  "src/type-generation/new-config.ts"() {
205619
205742
  init_import_meta_url();
205620
205743
  init_dist3();
205621
205744
  init_src5();
205622
205745
  init_logger2();
205623
- init_helpers4();
205624
205746
  init_runtime2();
205747
+ NEW_CONFIG_TYPES_OUTPUT_PATH = ".cloudflare/types/index.d.ts";
205625
205748
  __name(regenerateNewConfigTypes, "regenerateNewConfigTypes");
205626
205749
  }
205627
205750
  });
@@ -206488,9 +206611,9 @@ var init_ConfigController = __esm({
206488
206611
  await this.#configWatcher?.close();
206489
206612
  this.#configWatcher = void 0;
206490
206613
  }
206491
- if (newConfig && fileConfig.configPath) {
206614
+ if (newConfig) {
206492
206615
  await regenerateNewConfigTypes({
206493
- cloudflareConfigPath: fileConfig.configPath,
206616
+ cloudflareConfigPath: newConfig.cloudflareConfigPath,
206494
206617
  workerConfig: newConfig.parsedConfig.worker,
206495
206618
  types: newConfig.types
206496
206619
  });
@@ -213062,10 +213185,13 @@ async function writeBuildOutput({
213062
213185
  env: env6,
213063
213186
  isPreview: isPreview2 = false
213064
213187
  }) {
213065
- const { config: config2, parsedConfig, mode } = await readNewConfig(
213066
- { env: env6 },
213067
- { isPreview: isPreview2 }
213068
- );
213188
+ const newConfig = await readNewConfig({ env: env6 }, { isPreview: isPreview2 });
213189
+ await regenerateNewConfigTypes({
213190
+ cloudflareConfigPath: newConfig.cloudflareConfigPath,
213191
+ workerConfig: newConfig.parsedConfig.worker,
213192
+ types: newConfig.types
213193
+ });
213194
+ const { config: config2, parsedConfig, mode } = newConfig;
213069
213195
  const { buildProps, assetsOptions } = await mergeBuildOutputProps(config2);
213070
213196
  const root = process.cwd();
213071
213197
  let buildResult;
@@ -213113,6 +213239,7 @@ var init_write_build_output = __esm({
213113
213239
  init_maybe_build_worker();
213114
213240
  init_merge_config_args();
213115
213241
  init_logger2();
213242
+ init_new_config();
213116
213243
  __name(writeBuildOutput, "writeBuildOutput");
213117
213244
  }
213118
213245
  });
@@ -229248,8 +229375,11 @@ function createHandler2(def, argv) {
229248
229375
  RESOURCES_PROVISION: args.experimentalProvision ?? false,
229249
229376
  AUTOCREATE_RESOURCES: args.experimentalAutoCreate
229250
229377
  };
229378
+ const temporaryAllowed = def.behaviour?.supportTemporary === true && Boolean(args.temporary);
229379
+ const eventCode = "eventCode" in args && typeof args.eventCode === "string" ? args.eventCode : void 0;
229251
229380
  setTemporaryAllowed(
229252
- def.behaviour?.supportTemporary === true && Boolean(args.temporary)
229381
+ temporaryAllowed,
229382
+ temporaryAllowed && eventCode ? { eventCode } : void 0
229253
229383
  );
229254
229384
  await run(experimentalFlags, async () => {
229255
229385
  const config2 = def.behaviour?.provideConfig ?? true ? newConfigEnabled ? (await readNewConfig(args, {
@@ -229308,7 +229438,6 @@ function createHandler2(def, argv) {
229308
229438
  try {
229309
229439
  initDeployHelpersContext({
229310
229440
  logger: logger2,
229311
- createCloudflareClient: createCloudflareClient2,
229312
229441
  fetchResult: fetchResult2,
229313
229442
  fetchListResult: fetchListResult2,
229314
229443
  fetchPagedListResult: fetchPagedListResult2,
@@ -229318,7 +229447,7 @@ function createHandler2(def, argv) {
229318
229447
  select: select2
229319
229448
  });
229320
229449
  const result = await def.handler(args, {
229321
- sdk: createCloudflareClient2(config2),
229450
+ sdk: createCloudflareClient(config2),
229322
229451
  config: config2,
229323
229452
  errors: { UserError, FatalError },
229324
229453
  logger: logger2,
@@ -230094,103 +230223,102 @@ function normalizeSqlLineEndings(sql) {
230094
230223
  }
230095
230224
  function splitSqlIntoStatements(sql) {
230096
230225
  const statements = [];
230097
- let str = "";
230098
- const compoundStatementStack = [];
230099
- const iterator = sql[Symbol.iterator]();
230100
- let next = iterator.next();
230101
- while (!next.done) {
230102
- const char = next.value;
230103
- if (compoundStatementStack[0]?.(str + char)) {
230104
- compoundStatementStack.shift();
230105
- }
230106
- switch (char) {
230107
- case `'`:
230108
- case `"`:
230109
- case "`":
230110
- str += char + consumeUntilMarker(iterator, char);
230111
- break;
230112
- case `$`: {
230113
- const dollarQuote = "$" + consumeWhile(iterator, isDollarQuoteIdentifier);
230114
- str += dollarQuote;
230115
- if (dollarQuote.endsWith("$")) {
230116
- str += consumeUntilMarker(iterator, dollarQuote);
230117
- }
230118
- break;
230226
+ let start = 0;
230227
+ while (start < sql.length) {
230228
+ const { end, hasUsefulToken } = findCompleteStatementEnd(sql, start);
230229
+ if (end === void 0) {
230230
+ if (hasUsefulToken) {
230231
+ statements.push(sql.slice(start).trim());
230119
230232
  }
230120
- case `-`:
230121
- next = iterator.next();
230122
- if (!next.done && next.value === "-") {
230123
- consumeUntilMarker(iterator, "\n");
230124
- str += "\n";
230125
- break;
230126
- } else {
230127
- str += char;
230128
- continue;
230129
- }
230130
- case `/`:
230131
- next = iterator.next();
230132
- if (!next.done && next.value === "*") {
230133
- consumeUntilMarker(iterator, "*/");
230134
- break;
230135
- } else {
230136
- str += char;
230137
- continue;
230138
- }
230139
- case `;`:
230140
- if (compoundStatementStack.length === 0) {
230141
- statements.push(str);
230142
- str = "";
230143
- } else {
230144
- str += char;
230145
- }
230146
- break;
230147
- default:
230148
- str += char;
230149
- break;
230233
+ break;
230150
230234
  }
230151
- if (isCompoundStatementStart(str)) {
230152
- compoundStatementStack.unshift(isCompoundStatementEnd);
230235
+ const statement = sql.slice(start, end - 1).trim();
230236
+ if (hasUsefulToken && statement.length > 0) {
230237
+ statements.push(statement);
230153
230238
  }
230154
- next = iterator.next();
230239
+ start = end;
230155
230240
  }
230156
- statements.push(str);
230157
- return statements.map((statement) => statement.trim()).filter((statement) => statement.length > 0);
230241
+ return statements;
230158
230242
  }
230159
- function consumeWhile(iterator, predicate, window2 = 16) {
230160
- let next = iterator.next();
230161
- let str = "";
230162
- let tail = "";
230163
- while (!next.done) {
230164
- str += next.value;
230165
- tail = (tail + next.value).slice(-window2);
230166
- if (!predicate(tail)) {
230167
- break;
230168
- }
230169
- next = iterator.next();
230243
+ function findCompleteStatementEnd(sql, start) {
230244
+ let state3 = "INVALID";
230245
+ let hasUsefulToken = false;
230246
+ for (let index = start; index < sql.length; index++) {
230247
+ const char = sql[index];
230248
+ let token;
230249
+ if (char === ";") {
230250
+ token = "tkSEMI";
230251
+ } else if (char === " " || char === "\r" || char === " " || char === "\n" || char === "\f") {
230252
+ token = "tkWS";
230253
+ } else if (char === "/" && sql[index + 1] === "*") {
230254
+ const end = sql.indexOf("*/", index + 2);
230255
+ if (end === -1) {
230256
+ return { end: void 0, hasUsefulToken };
230257
+ }
230258
+ index = end + 1;
230259
+ token = "tkWS";
230260
+ } else if (char === "-" && sql[index + 1] === "-") {
230261
+ const end = sql.indexOf("\n", index + 2);
230262
+ if (end === -1) {
230263
+ return { end: void 0, hasUsefulToken };
230264
+ }
230265
+ index = end;
230266
+ token = "tkWS";
230267
+ } else if (char === "[") {
230268
+ const end = sql.indexOf("]", index + 1);
230269
+ if (end === -1) {
230270
+ return { end: void 0, hasUsefulToken: true };
230271
+ }
230272
+ index = end;
230273
+ token = "tkOTHER";
230274
+ } else if (char === "'" || char === '"' || char === "`") {
230275
+ const end = sql.indexOf(char, index + 1);
230276
+ if (end === -1) {
230277
+ return { end: void 0, hasUsefulToken: true };
230278
+ }
230279
+ index = end;
230280
+ token = "tkOTHER";
230281
+ } else if (isIdentifierChar(char)) {
230282
+ const identifierStart = index;
230283
+ while (index + 1 < sql.length && isIdentifierChar(sql[index + 1])) {
230284
+ index++;
230285
+ }
230286
+ token = classifyIdentifier(sql.slice(identifierStart, index + 1));
230287
+ } else {
230288
+ token = "tkOTHER";
230289
+ }
230290
+ hasUsefulToken ||= token !== "tkSEMI" && token !== "tkWS";
230291
+ state3 = getNextState(state3, token);
230292
+ if (state3 === "START") {
230293
+ return { end: index + 1, hasUsefulToken };
230294
+ }
230295
+ }
230296
+ return { end: void 0, hasUsefulToken };
230297
+ }
230298
+ function getNextState(state3, token) {
230299
+ return transitions[state3][token];
230300
+ }
230301
+ function isIdentifierChar(char) {
230302
+ return /[A-Za-z0-9_$\u0080-\uffff]/.test(char);
230303
+ }
230304
+ function classifyIdentifier(identifier) {
230305
+ switch (identifier.toLowerCase()) {
230306
+ case "explain":
230307
+ return "tkEXPLAIN";
230308
+ case "create":
230309
+ return "tkCREATE";
230310
+ case "temp":
230311
+ case "temporary":
230312
+ return "tkTEMP";
230313
+ case "trigger":
230314
+ return "tkTRIGGER";
230315
+ case "end":
230316
+ return "tkEND";
230317
+ default:
230318
+ return "tkOTHER";
230170
230319
  }
230171
- return str;
230172
- }
230173
- function consumeUntilMarker(iterator, endMarker) {
230174
- return consumeWhile(
230175
- iterator,
230176
- (str) => !str.endsWith(endMarker),
230177
- endMarker.length
230178
- );
230179
- }
230180
- function isDollarQuoteIdentifier(str) {
230181
- const lastChar = str.slice(-1);
230182
- return (
230183
- // The $ marks the end of the identifier
230184
- lastChar !== "$" && // we allow numbers, underscore and letters with diacritical marks
230185
- (/[0-9_]/i.test(lastChar) || lastChar.toLowerCase() !== lastChar.toUpperCase())
230186
- );
230187
- }
230188
- function isCompoundStatementStart(str) {
230189
- return /\s(BEGIN|CASE)\s$/i.test(str);
230190
- }
230191
- function isCompoundStatementEnd(str) {
230192
- return /\sEND[;\s]$/i.test(str);
230193
230320
  }
230321
+ var transitions;
230194
230322
  var init_splitter = __esm({
230195
230323
  "src/d1/splitter.ts"() {
230196
230324
  init_import_meta_url();
@@ -230199,11 +230327,92 @@ var init_splitter = __esm({
230199
230327
  __name(splitSqlQuery, "splitSqlQuery");
230200
230328
  __name(normalizeSqlLineEndings, "normalizeSqlLineEndings");
230201
230329
  __name(splitSqlIntoStatements, "splitSqlIntoStatements");
230202
- __name(consumeWhile, "consumeWhile");
230203
- __name(consumeUntilMarker, "consumeUntilMarker");
230204
- __name(isDollarQuoteIdentifier, "isDollarQuoteIdentifier");
230205
- __name(isCompoundStatementStart, "isCompoundStatementStart");
230206
- __name(isCompoundStatementEnd, "isCompoundStatementEnd");
230330
+ transitions = {
230331
+ INVALID: {
230332
+ tkSEMI: "START",
230333
+ tkWS: "INVALID",
230334
+ tkOTHER: "NORMAL",
230335
+ tkEXPLAIN: "EXPLAIN",
230336
+ tkCREATE: "CREATE",
230337
+ tkTEMP: "NORMAL",
230338
+ tkTRIGGER: "NORMAL",
230339
+ tkEND: "NORMAL"
230340
+ },
230341
+ START: {
230342
+ tkSEMI: "START",
230343
+ tkWS: "START",
230344
+ tkOTHER: "NORMAL",
230345
+ tkEXPLAIN: "EXPLAIN",
230346
+ tkCREATE: "CREATE",
230347
+ tkTEMP: "NORMAL",
230348
+ tkTRIGGER: "NORMAL",
230349
+ tkEND: "NORMAL"
230350
+ },
230351
+ NORMAL: {
230352
+ tkSEMI: "START",
230353
+ tkWS: "NORMAL",
230354
+ tkOTHER: "NORMAL",
230355
+ tkEXPLAIN: "NORMAL",
230356
+ tkCREATE: "NORMAL",
230357
+ tkTEMP: "NORMAL",
230358
+ tkTRIGGER: "NORMAL",
230359
+ tkEND: "NORMAL"
230360
+ },
230361
+ EXPLAIN: {
230362
+ tkSEMI: "START",
230363
+ tkWS: "EXPLAIN",
230364
+ tkOTHER: "EXPLAIN",
230365
+ tkEXPLAIN: "NORMAL",
230366
+ tkCREATE: "CREATE",
230367
+ tkTEMP: "NORMAL",
230368
+ tkTRIGGER: "NORMAL",
230369
+ tkEND: "NORMAL"
230370
+ },
230371
+ CREATE: {
230372
+ tkSEMI: "START",
230373
+ tkWS: "CREATE",
230374
+ tkOTHER: "NORMAL",
230375
+ tkEXPLAIN: "NORMAL",
230376
+ tkCREATE: "NORMAL",
230377
+ tkTEMP: "CREATE",
230378
+ tkTRIGGER: "TRIGGER",
230379
+ tkEND: "NORMAL"
230380
+ },
230381
+ TRIGGER: {
230382
+ tkSEMI: "SEMI",
230383
+ tkWS: "TRIGGER",
230384
+ tkOTHER: "TRIGGER",
230385
+ tkEXPLAIN: "TRIGGER",
230386
+ tkCREATE: "TRIGGER",
230387
+ tkTEMP: "TRIGGER",
230388
+ tkTRIGGER: "TRIGGER",
230389
+ tkEND: "TRIGGER"
230390
+ },
230391
+ SEMI: {
230392
+ tkSEMI: "SEMI",
230393
+ tkWS: "SEMI",
230394
+ tkOTHER: "TRIGGER",
230395
+ tkEXPLAIN: "TRIGGER",
230396
+ tkCREATE: "TRIGGER",
230397
+ tkTEMP: "TRIGGER",
230398
+ tkTRIGGER: "TRIGGER",
230399
+ tkEND: "END"
230400
+ },
230401
+ END: {
230402
+ tkSEMI: "START",
230403
+ tkWS: "END",
230404
+ tkOTHER: "TRIGGER",
230405
+ tkEXPLAIN: "TRIGGER",
230406
+ tkCREATE: "TRIGGER",
230407
+ tkTEMP: "TRIGGER",
230408
+ tkTRIGGER: "TRIGGER",
230409
+ tkEND: "TRIGGER"
230410
+ }
230411
+ };
230412
+ __name(findCompleteStatementEnd, "findCompleteStatementEnd");
230413
+ __name(getNextState, "getNextState");
230414
+ __name(isIdentifierChar, "isIdentifierChar");
230415
+ __name(classifyIdentifier, "classifyIdentifier");
230207
230416
  }
230208
230417
  });
230209
230418
  async function executeSql({
@@ -251523,7 +251732,7 @@ var require_lib5 = __commonJS({
251523
251732
  return isInAstralSet(code2, astralIdentifierStartCodes);
251524
251733
  }
251525
251734
  __name(isIdentifierStart, "isIdentifierStart");
251526
- function isIdentifierChar(code2) {
251735
+ function isIdentifierChar2(code2) {
251527
251736
  if (code2 < 48) return code2 === 36;
251528
251737
  if (code2 < 58) return true;
251529
251738
  if (code2 < 65) return false;
@@ -251535,7 +251744,7 @@ var require_lib5 = __commonJS({
251535
251744
  }
251536
251745
  return isInAstralSet(code2, astralIdentifierStartCodes) || isInAstralSet(code2, astralIdentifierCodes);
251537
251746
  }
251538
- __name(isIdentifierChar, "isIdentifierChar");
251747
+ __name(isIdentifierChar2, "isIdentifierChar");
251539
251748
  var reservedWords = {
251540
251749
  keyword: ["break", "case", "catch", "continue", "debugger", "default", "do", "else", "finally", "for", "function", "if", "return", "switch", "throw", "try", "var", "const", "while", "with", "new", "this", "super", "class", "extends", "export", "import", "null", "true", "false", "in", "instanceof", "typeof", "void", "delete"],
251541
251750
  strict: ["implements", "interface", "let", "package", "private", "protected", "public", "static", "yield"],
@@ -253254,7 +253463,7 @@ var require_lib5 = __commonJS({
253254
253463
  if (mods.includes(char)) {
253255
253464
  this.raise(Errors.DuplicateRegExpFlags, nextPos());
253256
253465
  }
253257
- } else if (isIdentifierChar(cp5) || cp5 === 92) {
253466
+ } else if (isIdentifierChar2(cp5) || cp5 === 92) {
253258
253467
  this.raise(Errors.MalformedRegExpFlags, nextPos());
253259
253468
  } else {
253260
253469
  break;
@@ -253442,13 +253651,13 @@ var require_lib5 = __commonJS({
253442
253651
  }
253443
253652
  while (this.state.pos < this.length) {
253444
253653
  const ch2 = this.codePointAtPos(this.state.pos);
253445
- if (isIdentifierChar(ch2)) {
253654
+ if (isIdentifierChar2(ch2)) {
253446
253655
  this.state.pos += ch2 <= 65535 ? 1 : 2;
253447
253656
  } else if (ch2 === 92) {
253448
253657
  this.state.containsEsc = true;
253449
253658
  word += this.input.slice(chunkStart, this.state.pos);
253450
253659
  const escStart = this.state.curPosition();
253451
- const identifierCheck = this.state.pos === start ? isIdentifierStart : isIdentifierChar;
253660
+ const identifierCheck = this.state.pos === start ? isIdentifierStart : isIdentifierChar2;
253452
253661
  if (this.input.charCodeAt(++this.state.pos) !== 117) {
253453
253662
  this.raise(Errors.MissingUnicodeEscape, this.state.curPosition());
253454
253663
  chunkStart = this.state.pos - 1;
@@ -253806,7 +254015,7 @@ var require_lib5 = __commonJS({
253806
254015
  const nameEnd = nameStart + name2.length;
253807
254016
  if (this.input.slice(nameStart, nameEnd) === name2) {
253808
254017
  const nextCh = this.input.charCodeAt(nameEnd);
253809
- return !(isIdentifierChar(nextCh) || (nextCh & 64512) === 55296);
254018
+ return !(isIdentifierChar2(nextCh) || (nextCh & 64512) === 55296);
253810
254019
  }
253811
254020
  return false;
253812
254021
  }
@@ -256877,7 +257086,7 @@ var require_lib5 = __commonJS({
256877
257086
  const start = this.state.pos;
256878
257087
  do {
256879
257088
  ch2 = this.input.charCodeAt(++this.state.pos);
256880
- } while (isIdentifierChar(ch2) || ch2 === 45);
257089
+ } while (isIdentifierChar2(ch2) || ch2 === 45);
256881
257090
  this.finishToken(141, this.input.slice(start, this.state.pos));
256882
257091
  }
256883
257092
  jsxParseIdentifier() {
@@ -262469,7 +262678,7 @@ var require_lib5 = __commonJS({
262469
262678
  keywordRelationalOperator.lastIndex = pos;
262470
262679
  if (keywordRelationalOperator.test(this.input)) {
262471
262680
  const endCh = this.codePointAtPos(keywordRelationalOperator.lastIndex);
262472
- if (!isIdentifierChar(endCh) && endCh !== 92) {
262681
+ if (!isIdentifierChar2(endCh) && endCh !== 92) {
262473
262682
  return false;
262474
262683
  }
262475
262684
  }
@@ -287210,15 +287419,32 @@ function assertNonConfigured(details) {
287210
287419
  "Error: expected the current project not to be already configured"
287211
287420
  );
287212
287421
  }
287422
+ function isExpectedFileSystemError(error53) {
287423
+ return typeof error53 === "object" && error53 !== null && "code" in error53 && (error53.code === "ENOENT" || error53.code === "ENOTDIR" || error53.code === "EACCES" || error53.code === "EPERM");
287424
+ }
287425
+ async function getPathStats(path107) {
287426
+ try {
287427
+ return await fs$1.stat(path107);
287428
+ } catch (error53) {
287429
+ if (isExpectedFileSystemError(error53)) {
287430
+ return void 0;
287431
+ }
287432
+ throw error53;
287433
+ }
287434
+ }
287213
287435
  async function hasIndexHtml(dir2) {
287214
- const children = await fs$1.readdir(dir2);
287215
- for (const child of children) {
287216
- const stats = await fs$1.stat(path28.join(dir2, child));
287217
- if (stats.isFile() && child === "index.html") {
287218
- return true;
287436
+ const stats = await getPathStats(path28.join(dir2, "index.html"));
287437
+ if (!stats?.isFile()) {
287438
+ return false;
287439
+ }
287440
+ try {
287441
+ return (await fs$1.readdir(dir2)).includes("index.html");
287442
+ } catch (error53) {
287443
+ if (isExpectedFileSystemError(error53)) {
287444
+ return false;
287219
287445
  }
287446
+ throw error53;
287220
287447
  }
287221
- return false;
287222
287448
  }
287223
287449
  async function findAssetsDir(from) {
287224
287450
  if (await hasIndexHtml(from)) {
@@ -287227,8 +287453,8 @@ async function findAssetsDir(from) {
287227
287453
  const children = await fs$1.readdir(from);
287228
287454
  for (const child of children) {
287229
287455
  const path107 = path28.join(from, child);
287230
- const stats = await fs$1.stat(path107);
287231
- if (stats.isDirectory() && await hasIndexHtml(path107)) {
287456
+ const stats = await getPathStats(path107);
287457
+ if (stats?.isDirectory() && await hasIndexHtml(path107)) {
287232
287458
  return path28.relative(from, path107);
287233
287459
  }
287234
287460
  }
@@ -287415,6 +287641,8 @@ var init_details2 = __esm({
287415
287641
  init_framework_detection();
287416
287642
  CLOUDFLARE_CONFIG_FILE = "cloudflare.config.ts";
287417
287643
  __name(assertNonConfigured, "assertNonConfigured");
287644
+ __name(isExpectedFileSystemError, "isExpectedFileSystemError");
287645
+ __name(getPathStats, "getPathStats");
287418
287646
  __name(hasIndexHtml, "hasIndexHtml");
287419
287647
  __name(findAssetsDir, "findAssetsDir");
287420
287648
  __name(getDetailsForAutoConfig, "getDetailsForAutoConfig");
@@ -288391,6 +288619,20 @@ var init_open_next = __esm({
288391
288619
  });
288392
288620
 
288393
288621
  // src/deploy/index.ts
288622
+ function parseEventCode(value) {
288623
+ if (Array.isArray(value)) {
288624
+ throw new CommandLineArgsError("--event-code expects a single value.", {
288625
+ telemetryMessage: "deploy event code multiple values"
288626
+ });
288627
+ }
288628
+ const eventCode = value.trim();
288629
+ if (!eventCode) {
288630
+ throw new CommandLineArgsError("--event-code cannot be empty.", {
288631
+ telemetryMessage: "deploy event code empty"
288632
+ });
288633
+ }
288634
+ return eventCode;
288635
+ }
288394
288636
  async function runDeployCommandHandler(args, {
288395
288637
  config: config2,
288396
288638
  pagesToWorkersDelegation = false
@@ -288493,6 +288735,7 @@ var init_deploy3 = __esm({
288493
288735
  init_getScriptName();
288494
288736
  init_autoconfig2();
288495
288737
  init_open_next();
288738
+ __name(parseEventCode, "parseEventCode");
288496
288739
  deployCommand = createCommand({
288497
288740
  metadata: {
288498
288741
  description: "\u{1F199} Deploy a Worker to Cloudflare",
@@ -288504,6 +288747,13 @@ var init_deploy3 = __esm({
288504
288747
  args: {
288505
288748
  ...experimentalNewConfigArg,
288506
288749
  ...sharedDeployVersionsArgs,
288750
+ "event-code": {
288751
+ describe: "Create a temporary account for an event",
288752
+ type: "string",
288753
+ requiresArg: true,
288754
+ hidden: true,
288755
+ coerce: parseEventCode
288756
+ },
288507
288757
  triggers: {
288508
288758
  describe: "cron schedules to attach",
288509
288759
  alias: ["schedule", "schedules"],
@@ -288566,6 +288816,11 @@ var init_deploy3 = __esm({
288566
288816
  suggestSkillsAfterHandler: true
288567
288817
  },
288568
288818
  validateArgs(args) {
288819
+ if (args.eventCode && !args.temporary) {
288820
+ throw new CommandLineArgsError("--event-code requires --temporary.", {
288821
+ telemetryMessage: "deploy event code temporary required"
288822
+ });
288823
+ }
288569
288824
  validateDeployVersionsArgs(args, "deploy");
288570
288825
  validateRouteZoneArgs(args);
288571
288826
  },
@@ -299274,6 +299529,7 @@ async function runPagesToWorkersDeploy(delegation) {
299274
299529
  envFile: void 0,
299275
299530
  experimentalProvision: void 0,
299276
299531
  profile: void 0,
299532
+ eventCode: void 0,
299277
299533
  triggers: void 0,
299278
299534
  routes: void 0,
299279
299535
  zone: void 0,
@@ -299326,7 +299582,6 @@ async function runPagesToWorkersDeploy(delegation) {
299326
299582
  await run(experimentalFlags, async () => {
299327
299583
  initDeployHelpersContext({
299328
299584
  logger: logger2,
299329
- createCloudflareClient: createCloudflareClient2,
299330
299585
  fetchResult: fetchResult2,
299331
299586
  fetchListResult: fetchListResult2,
299332
299587
  fetchPagedListResult: fetchPagedListResult2,
@@ -299360,7 +299615,6 @@ var init_run_workers_deploy = __esm({
299360
299615
  init_import_meta_url();
299361
299616
  init_context();
299362
299617
  init_cfetch2();
299363
- init_internal();
299364
299618
  init_config6();
299365
299619
  init_deploy3();
299366
299620
  init_dialogs();
@@ -359196,6 +359450,21 @@ var init_trigger = __esm({
359196
359450
  });
359197
359451
  }
359198
359452
  });
359453
+ function redactEventCode(argv) {
359454
+ return argv.map((arg, index) => {
359455
+ const previousArg = argv[index - 1];
359456
+ if (previousArg === "--event-code" || previousArg === "--eventCode") {
359457
+ return "<redacted>";
359458
+ }
359459
+ if (arg.startsWith("--event-code=")) {
359460
+ return "--event-code=<redacted>";
359461
+ }
359462
+ if (arg.startsWith("--eventCode=")) {
359463
+ return "--eventCode=<redacted>";
359464
+ }
359465
+ return arg;
359466
+ });
359467
+ }
359199
359468
  function createCLIParser(argv) {
359200
359469
  const globalFlags = {
359201
359470
  v: {
@@ -359277,7 +359546,7 @@ function createCLIParser(argv) {
359277
359546
  type: "wrangler-session",
359278
359547
  version: 1,
359279
359548
  wrangler_version: version2,
359280
- command_line_args: argv,
359549
+ command_line_args: redactEventCode(argv),
359281
359550
  log_file_path: debugLogFilepath
359282
359551
  });
359283
359552
  return true;
@@ -361520,6 +361789,7 @@ var init_src7 = __esm({
361520
361789
  `Proxy environment variables detected. We'll use your proxy for fetch requests.`
361521
361790
  );
361522
361791
  }
361792
+ __name(redactEventCode, "redactEventCode");
361523
361793
  __name(createCLIParser, "createCLIParser");
361524
361794
  __name(main, "main");
361525
361795
  __name(dispatchGenericCommandErrorEvent, "dispatchGenericCommandErrorEvent");
@@ -362614,7 +362884,6 @@ var init_DevEnv = __esm({
362614
362884
  init_context();
362615
362885
  init_src();
362616
362886
  init_cfetch2();
362617
- init_internal();
362618
362887
  init_build_failures();
362619
362888
  init_dialogs();
362620
362889
  init_logger2();
@@ -362634,7 +362903,6 @@ var init_DevEnv = __esm({
362634
362903
  async startWorker(options) {
362635
362904
  initDeployHelpersContext({
362636
362905
  logger: logger2,
362637
- createCloudflareClient: createCloudflareClient2,
362638
362906
  fetchResult: fetchResult2,
362639
362907
  fetchListResult: fetchListResult2,
362640
362908
  fetchPagedListResult: fetchPagedListResult2,
@@ -363094,15 +363362,14 @@ var init_LocalRuntimeController = __esm({
363094
363362
  const nextState = {
363095
363363
  dockerPath: data.config.dev.dockerPath ?? getDockerPath(),
363096
363364
  complianceRegion: data.config.complianceRegion,
363365
+ hasContainers: Boolean(
363366
+ data.config.dev.enableContainers && data.config.containerDevPlan !== void 0
363367
+ ),
363097
363368
  containerOptions: data.config.dev.enableContainers ? data.config.containerDevPlan?.containerOptions ?? [] : []
363098
363369
  };
363099
- if (util.isDeepStrictEqual(previousState, nextState) || nextState.containerOptions.length === 0) {
363370
+ if (util.isDeepStrictEqual(previousState, nextState) || !nextState.hasContainers) {
363100
363371
  return nextState;
363101
363372
  }
363102
- assert38__default.default(
363103
- data.config.dev.containerBuildId,
363104
- "Build ID should be set when Container images require preparation"
363105
- );
363106
363373
  this.dockerPath = nextState.dockerPath;
363107
363374
  for (const { image_tag } of nextState.containerOptions) {
363108
363375
  this.containerImageTagsSeen.add(image_tag);
@@ -366576,6 +366843,13 @@ var init_compatibility_flags = __esm({
366576
366843
  }
366577
366844
  });
366578
366845
 
366846
+ // ../workers-shared/asset-worker/src/utils/base-path.ts
366847
+ var init_base_path = __esm({
366848
+ "../workers-shared/asset-worker/src/utils/base-path.ts"() {
366849
+ init_import_meta_url();
366850
+ }
366851
+ });
366852
+
366579
366853
  // ../workers-shared/asset-worker/src/constants.ts
366580
366854
  var init_constants23 = __esm({
366581
366855
  "../workers-shared/asset-worker/src/constants.ts"() {
@@ -366602,6 +366876,7 @@ var init_handler2 = __esm({
366602
366876
  init_responses2();
366603
366877
  init_tracing2();
366604
366878
  init_compatibility_flags();
366879
+ init_base_path();
366605
366880
  init_headers();
366606
366881
  init_rules_engine();
366607
366882
  }
@@ -369721,8 +369996,12 @@ init_client14();
369721
369996
  // src/cf-wrangler/build.ts
369722
369997
  init_import_meta_url();
369723
369998
  init_write_build_output();
369999
+ var PREVIEW_BUILD_ENV_VAR = "CLOUDFLARE_PREVIEW_BUILD";
369724
370000
  async function runCfWranglerBuild(args) {
369725
- await writeBuildOutput({ env: args.mode, isPreview: args.preview });
370001
+ await writeBuildOutput({
370002
+ env: args.mode,
370003
+ isPreview: process.env[PREVIEW_BUILD_ENV_VAR] === "true"
370004
+ });
369726
370005
  return 0;
369727
370006
  }
369728
370007
  __name(runCfWranglerBuild, "runCfWranglerBuild");
@@ -369811,8 +370090,7 @@ function parseBuildArgs(argv) {
369811
370090
  parsed = util.parseArgs({
369812
370091
  args: argv,
369813
370092
  options: {
369814
- mode: { type: "string" },
369815
- preview: { type: "boolean" }
370093
+ mode: { type: "string" }
369816
370094
  },
369817
370095
  strict: true,
369818
370096
  allowPositionals: false
@@ -369824,9 +370102,6 @@ function parseBuildArgs(argv) {
369824
370102
  if (parsed.values.mode !== void 0) {
369825
370103
  out.mode = parsed.values.mode;
369826
370104
  }
369827
- if (parsed.values.preview !== void 0) {
369828
- out.preview = parsed.values.preview;
369829
- }
369830
370105
  return out;
369831
370106
  }
369832
370107
  __name(parseBuildArgs, "parseBuildArgs");