onveloz 0.0.0-beta.44 → 0.0.0-beta.45

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.
@@ -201,7 +201,7 @@ function getGitBranch() {
201
201
 
202
202
  //#endregion
203
203
  //#region src/lib/client.ts
204
- const CLI_VERSION = "0.0.0-beta.44";
204
+ const CLI_VERSION = "0.0.0-beta.45";
205
205
  const USER_AGENT = `veloz-cli/${CLI_VERSION}`;
206
206
  /**
207
207
  * Client source — "cli" by default; the init wizard sets this to "cli-wizard"
@@ -839,7 +839,7 @@ async function streamDeploymentLogs(deploymentId, serviceId, serviceName, option
839
839
  isVerbose,
840
840
  useTui: options.useTui
841
841
  })) {
842
- const { renderDeployTUI } = await import("./deploy-tui-DkKLXRMw.mjs");
842
+ const { renderDeployTUI } = await import("./deploy-tui-BDhyXrb0.mjs");
843
843
  return renderDeployTUI(deploymentId, serviceId, serviceName);
844
844
  }
845
845
  const allLogLines = [];
@@ -1,4 +1,4 @@
1
- import { f as statusLabels, h as getClient, i as parseBuildLine, n as fetchDeployUrls, r as isHiddenMessage, s as getFailureHints, t as cleanDisplayLine, u as TERMINAL_STATUSES } from "./deploy-stream-CAxevtis.mjs";
1
+ import { f as statusLabels, h as getClient, i as parseBuildLine, n as fetchDeployUrls, r as isHiddenMessage, s as getFailureHints, t as cleanDisplayLine, u as TERMINAL_STATUSES } from "./deploy-stream-BPe1wrzQ.mjs";
2
2
  import { k as success, w as info } from "./config-CPTQd4xp.mjs";
3
3
  import "./veloz-config-DDaH3Lkl.mjs";
4
4
  import chalk from "chalk";
@@ -1,5 +1,5 @@
1
1
  import "./Effect-bx4z8tIJ.mjs";
2
- import { n as runEdgeDev, r as startEdgeDev, t as EdgeDevError } from "./edge-dev-BGc_8yAn.mjs";
2
+ import { n as runEdgeDev, r as startEdgeDev, t as EdgeDevError } from "./edge-dev-HISJWa4t.mjs";
3
3
  import "./veloz-config-DDaH3Lkl.mjs";
4
4
 
5
5
  export { runEdgeDev };
@@ -10912,6 +10912,23 @@ const StoredRecord = Struct({
10912
10912
  expectedMapDigest: NullOr(String$1)
10913
10913
  });
10914
10914
 
10915
+ //#endregion
10916
+ //#region ../../packages/route-authority-contract/src/authority-mirror.ts
10917
+ const HostRetirementMirror = Struct({
10918
+ version: Literal(1),
10919
+ hostname: NonEmptyString,
10920
+ retired: Boolean
10921
+ });
10922
+ const WorkerRunStateMirror = Struct({
10923
+ version: Literal(1),
10924
+ serviceId: NonEmptyString,
10925
+ runState: Literals([
10926
+ "RUNNING",
10927
+ "PAUSED",
10928
+ "RETIRED"
10929
+ ])
10930
+ });
10931
+
10915
10932
  //#endregion
10916
10933
  //#region ../../packages/route-authority-contract/src/worker-redeploy.ts
10917
10934
  const MINIMUM_DRAIN_MS = 5 * 6e4;
@@ -12108,7 +12125,7 @@ function createCloudflareWorkersPlan(input) {
12108
12125
  workersLogsHeadSamplingRate,
12109
12126
  placementRegion,
12110
12127
  ...details.adapter === "opennext" ? {
12111
- openNextVersion: input.openNextVersion ?? "1.20.2",
12128
+ openNextVersion: input.openNextVersion ?? "1.20.3",
12112
12129
  ...openNextRouteModulesPerShard === void 0 ? {} : { openNextRouteModulesPerShard }
12113
12130
  } : {},
12114
12131
  ...details.generatedEntrypoint ? { generatedEntrypoint: details.generatedEntrypoint } : {},
@@ -1,5 +1,5 @@
1
1
  import { B as void_, E as raceFirst, F as sync, O as runPromise, a as callback, b as match, i as andThen, j as scoped, x as never } from "./Effect-bx4z8tIJ.mjs";
2
- import { r as startEdgeDev } from "./edge-dev-BGc_8yAn.mjs";
2
+ import { r as startEdgeDev } from "./edge-dev-HISJWa4t.mjs";
3
3
  import "./veloz-config-DDaH3Lkl.mjs";
4
4
  import { parentPort, workerData } from "node:worker_threads";
5
5
 
package/dist/index.mjs CHANGED
@@ -1,21 +1,21 @@
1
1
  #!/usr/bin/env node
2
2
  import { B as void_, C as orDie, Ct as isNone, D as result, F as sync, I as tryPromise, L as try_, O as runPromise, Ot as none, R as uninterruptible, S as onError, St as getOrUndefined, T as provide, U as succeed, V as TaggedError, b as match, f as fn, ft as Service, j as scoped, k as runSync, kt as some, m as gen, n as acquireUseRelease, r as all, s as die, t as acquireRelease, u as flatMap, wt as isSome, z as uninterruptibleMask } from "./Effect-bx4z8tIJ.mjs";
3
- import { A as requireProjectId, C as getGitRemote, D as loadRawConfig, E as loadConfig$1, M as saveConfig$1, N as setActiveEnv, O as patchConfig, P as createClient, S as getGitBranch, T as isInheritedConfig, _ as setClientSource, a as streamDeploymentLogs, b as getConfigFileName, c as checkAiSetup, d as getStatusIcon, f as statusLabels, g as getClientForOrg, h as getClient, i as parseBuildLine, j as requireProjectName, k as requireConfig, l as printAiSetupHint, m as getAuthHeaders, n as fetchDeployUrls, o as createDeployOutput, p as buildVelozHeaders, r as isHiddenMessage, t as cleanDisplayLine, u as TERMINAL_STATUSES, v as findProjectRoot, w as isGitRepo, x as getConfigPath, y as getActiveEnv } from "./deploy-stream-CAxevtis.mjs";
3
+ import { A as requireProjectId, C as getGitRemote, D as loadRawConfig, E as loadConfig$1, M as saveConfig$1, N as setActiveEnv, O as patchConfig, P as createClient, S as getGitBranch, T as isInheritedConfig, _ as setClientSource, a as streamDeploymentLogs, b as getConfigFileName, c as checkAiSetup, d as getStatusIcon, f as statusLabels, g as getClientForOrg, h as getClient, i as parseBuildLine, j as requireProjectName, k as requireConfig, l as printAiSetupHint, m as getAuthHeaders, n as fetchDeployUrls, o as createDeployOutput, p as buildVelozHeaders, r as isHiddenMessage, t as cleanDisplayLine, u as TERMINAL_STATUSES, v as findProjectRoot, w as isGitRepo, x as getConfigPath, y as getActiveEnv } from "./deploy-stream-BPe1wrzQ.mjs";
4
4
  import { A as warn, D as log, E as isMcpMode, S as withSpinner, T as isAiAgent, _ as promptConfirm, a as setSessionOrganizationId, b as requireMcpConfirmation, c as buildVerificationUrl, d as registerLogin, f as hasValidNonInteractiveConfirmation, g as prompt, h as openBrowser, i as saveConfig, k as success, m as isRateLimitError, n as loadConfig, o as DEVICE_AUTH_CLIENT_ID, p as isInteractive, r as requireAuth, s as buildDeviceAuthClient, t as isAuthenticated, u as pollForToken, v as promptMultiSelect, w as info, x as spinner, y as promptSelect } from "./config-CPTQd4xp.mjs";
5
5
  import { A as nodeVersionSchema, C as getDatabaseSizes, D as poolerPoolModeSchema, E as databaseTierSchema, F as nativeWorkerSchedulesSchema, I as databaseNameSchema, L as databaseStorageSchema, M as nativeWorkerAssetsDirectorySchema, N as nativeWorkerCompatibilityDateSchema, O as aptPackageNameSchema, P as nativeWorkerEntrypointSchema, S as getDatabaseSizeRank, T as resolveServiceSizeFromResources, _ as DATABASE_SIZE_KEYS, b as SERVICE_SIZES, f as validateVelozConfig, g as DATABASE_SIZES, h as DATABASE_ENGINE_DEFAULTS, i as VolumeConfigSchema, k as nixpkgsArchiveSchema, l as resolveMetricsScrape, m as DATABASE_ENGINES, n as ServiceConfigSchema, o as mergeServiceWithDefaults, p as BUILD_TIMEOUT_MS, r as ServiceSizeSchema, t as PackageManagerSchema, u as resolveTracesExport, v as PG_CONFIGURABLE_PARAMS, w as resolveDatabaseSize, x as SERVICE_TYPES, y as PG_DENIED_PARAMS } from "./veloz-config-DDaH3Lkl.mjs";
6
6
  import { Cli, middleware, z } from "incur";
7
7
  import { ORPCError } from "@orpc/client";
8
8
  import { createHash, randomBytes } from "node:crypto";
9
9
  import * as fs from "node:fs";
10
- import { appendFileSync, constants, createWriteStream, existsSync, mkdirSync, readFileSync, readdirSync, realpathSync, statSync, unlinkSync, writeFileSync } from "node:fs";
10
+ import { appendFileSync, constants, createReadStream, createWriteStream, existsSync, mkdirSync, readFileSync, readdirSync, realpathSync, statSync, unlinkSync, writeFileSync } from "node:fs";
11
11
  import { homedir, tmpdir } from "node:os";
12
12
  import * as path from "node:path";
13
- import { basename, dirname, isAbsolute, join, posix, relative, resolve, win32 } from "node:path";
13
+ import { basename, dirname, isAbsolute, join, posix, relative, resolve, sep, win32 } from "node:path";
14
14
  import chalk from "chalk";
15
15
  import * as readline from "node:readline";
16
16
  import { exec, execSync, spawn } from "node:child_process";
17
17
  import { z as z$1 } from "zod";
18
- import { chmod, copyFile, lstat, mkdir, mkdtemp, open, readFile, readdir, realpath, rm, writeFile } from "node:fs/promises";
18
+ import { chmod, copyFile, lstat, mkdir, mkdtemp, open, readFile, readdir, realpath, rm, stat, writeFile } from "node:fs/promises";
19
19
  import { Transform } from "node:stream";
20
20
  import { pipeline } from "node:stream/promises";
21
21
  import ignore from "ignore";
@@ -1465,7 +1465,7 @@ edgeGroup.command("dev", {
1465
1465
  testQueue: z.string().optional().describe("Arquivo JSON com um lote de mensagens de fila para simular uma vez ao iniciar")
1466
1466
  }),
1467
1467
  async run(c) {
1468
- const { runEdgeDev } = await import("./edge-dev-C8CkpAwN.mjs");
1468
+ const { runEdgeDev } = await import("./edge-dev-CAn42jDX.mjs");
1469
1469
  const result$1 = await runPromise(runEdgeDev(c.options, (event) => {
1470
1470
  if (event.type === "ready") process.stderr.write(`Veloz Edge disponível em ${event.url}\n`);
1471
1471
  else if (event.type === "reloaded") process.stderr.write("Veloz Edge atualizado.\n");
@@ -7280,6 +7280,69 @@ buildsGroup.command("logs", {
7280
7280
  };
7281
7281
  }
7282
7282
  });
7283
+ buildsGroup.command("bundle", {
7284
+ description: "Baixar o bundle de Worker que um deploy publicou, byte a byte",
7285
+ mcp: false,
7286
+ middleware: [requireAuth$1],
7287
+ args: z.object({ id: z.string().describe("ID do build") }),
7288
+ options: z.object({ out: z.string().optional().describe("Diretório de saída (padrão: ./veloz-bundle-<id>)") }),
7289
+ output: z.object({
7290
+ directory: z.string(),
7291
+ scripts: z.array(z.object({
7292
+ role: z.string(),
7293
+ scriptName: z.string(),
7294
+ modules: z.number()
7295
+ }))
7296
+ }),
7297
+ async run(c) {
7298
+ const client = await getClient();
7299
+ const deploymentId = c.args.id;
7300
+ const directory = resolve(process.cwd(), c.options.out ?? `veloz-bundle-${deploymentId}`);
7301
+ const scripts = await withSpinner({
7302
+ text: "Carregando scripts do deploy...",
7303
+ fn: () => withRetry(() => client.deployments.workerScripts({ deploymentId }))
7304
+ });
7305
+ const written = [];
7306
+ for (const script of scripts) {
7307
+ const bundle = await withSpinner({
7308
+ text: `Baixando ${script.role} (${script.scriptName})...`,
7309
+ fn: () => withRetry(() => client.deployments.workerScript({
7310
+ deploymentId,
7311
+ scriptName: script.scriptName
7312
+ }))
7313
+ });
7314
+ const scriptDirectory = join(directory, script.role);
7315
+ for (const module of bundle.modules) {
7316
+ const target = resolve(scriptDirectory, module.name);
7317
+ if (!target.startsWith(scriptDirectory + sep)) return c.error({
7318
+ code: "UNSAFE_MODULE_PATH",
7319
+ message: `O bundle tem um caminho de módulo inválido: ${module.name}`
7320
+ });
7321
+ mkdirSync(dirname(target), { recursive: true });
7322
+ writeFileSync(target, new Uint8Array(await module.content.arrayBuffer()));
7323
+ }
7324
+ writeFileSync(join(directory, `${script.role}.json`), JSON.stringify({
7325
+ scriptName: script.scriptName,
7326
+ mainModule: bundle.mainModule,
7327
+ compatibilityDate: bundle.compatibilityDate,
7328
+ compatibilityFlags: bundle.compatibilityFlags,
7329
+ bindings: bundle.bindings
7330
+ }, null, 2) + "\n", "utf-8");
7331
+ written.push({
7332
+ role: script.role,
7333
+ scriptName: script.scriptName,
7334
+ modules: bundle.modules.length
7335
+ });
7336
+ }
7337
+ success(`Bundle salvo em ${chalk.bold(directory)}`);
7338
+ for (const script of written) console.log(` ${chalk.bold(script.role.padEnd(6))} ${script.modules} módulo(s) ${chalk.dim(script.scriptName)}`);
7339
+ console.log(chalk.dim(" Cada <papel>.json traz o módulo principal, a data de compatibilidade e os nomes dos bindings (sem valores)."));
7340
+ return {
7341
+ directory,
7342
+ scripts: written
7343
+ };
7344
+ }
7345
+ });
7283
7346
 
7284
7347
  //#endregion
7285
7348
  //#region src/commands/support.ts
@@ -8986,32 +9049,69 @@ const createTarball = (directory, extraFiles) => runPromise(gen(function* () {
8986
9049
  tempDir: archive.tempDir
8987
9050
  };
8988
9051
  }));
9052
+ const MAX_STALLED_ROUNDS = 5;
9053
+ function sha256File(path$1) {
9054
+ return new Promise((resolve$1, reject) => {
9055
+ const hash = createHash("sha256");
9056
+ createReadStream(path$1).on("error", reject).on("data", (chunk) => hash.update(chunk)).on("end", () => resolve$1(hash.digest("hex")));
9057
+ });
9058
+ }
9059
+ /**
9060
+ * Sends the tarball as a multipart upload. The server lists what it already
9061
+ * holds on every round, so a part lost to a dropped connection is simply sent
9062
+ * again, and a rerun of the same deploy resumes where the last one stopped
9063
+ * instead of starting over (#2221).
9064
+ */
9065
+ async function sendSource(client, deploymentId, tarPath) {
9066
+ const { size: byteLength } = await stat(tarPath);
9067
+ const sha256 = await sha256File(tarPath);
9068
+ const file = await open(tarPath, "r");
9069
+ try {
9070
+ let receivedBytes = -1;
9071
+ let stalledRounds = 0;
9072
+ let lastFailure = "";
9073
+ for (;;) {
9074
+ const plan = await client.deployments.prepareSourceUpload({
9075
+ deploymentId,
9076
+ byteLength,
9077
+ sha256
9078
+ });
9079
+ if (plan.parts.length === 0) break;
9080
+ stalledRounds = plan.receivedBytes > receivedBytes ? 0 : stalledRounds + 1;
9081
+ receivedBytes = plan.receivedBytes;
9082
+ if (stalledRounds >= MAX_STALLED_ROUNDS) throw new Error(`Upload falhou: ${lastFailure}`);
9083
+ if (stalledRounds > 0) await new Promise((resolve$1) => {
9084
+ setTimeout(resolve$1, stalledRounds * 1e3);
9085
+ });
9086
+ await Promise.all(plan.parts.map(async ({ partNumber, url }) => {
9087
+ const offset = (partNumber - 1) * plan.partSize;
9088
+ const body = Buffer.alloc(Math.min(plan.partSize, byteLength - offset));
9089
+ await file.read(body, 0, body.length, offset);
9090
+ const response = await fetch(url, {
9091
+ method: "PUT",
9092
+ body
9093
+ }).catch((error) => {
9094
+ lastFailure = error instanceof Error ? error.message : String(error);
9095
+ return null;
9096
+ });
9097
+ if (response && !response.ok) lastFailure = String(response.status);
9098
+ }));
9099
+ }
9100
+ } finally {
9101
+ await file.close();
9102
+ }
9103
+ await client.deployments.completeSourceUpload({ deploymentId });
9104
+ }
8989
9105
  /** Upload a pre-built tarball for a deployment. */
8990
9106
  async function uploadTarball(deploymentId, tarPath) {
8991
9107
  const client = await getClient();
8992
- const { uploadUrl } = await client.deployments.getUploadUrl({ deploymentId });
8993
- const fileBuffer = readFileSync(tarPath);
8994
- const putResponse = await fetch(uploadUrl, {
8995
- method: "PUT",
8996
- headers: { "Content-Type": "application/gzip" },
8997
- body: fileBuffer
8998
- });
8999
- if (!putResponse.ok) throw new Error(`Upload falhou: ${putResponse.status}`);
9108
+ await sendSource(client, deploymentId, tarPath);
9000
9109
  await client.deployments.startBuild({ deploymentId });
9001
9110
  }
9002
9111
  async function uploadSource(deploymentId, directory, extraFiles) {
9003
9112
  const { path: tarPath, tempDir } = await createTarball(directory, extraFiles);
9004
9113
  try {
9005
- const client = await getClient();
9006
- const { uploadUrl } = await client.deployments.getUploadUrl({ deploymentId });
9007
- const fileBuffer = readFileSync(tarPath);
9008
- const putResponse = await fetch(uploadUrl, {
9009
- method: "PUT",
9010
- headers: { "Content-Type": "application/gzip" },
9011
- body: fileBuffer
9012
- });
9013
- if (!putResponse.ok) throw new Error(`Upload falhou: ${putResponse.status}`);
9014
- await client.deployments.startBuild({ deploymentId });
9114
+ await uploadTarball(deploymentId, tarPath);
9015
9115
  } finally {
9016
9116
  await rm(tempDir, {
9017
9117
  recursive: true,
@@ -9059,7 +9159,7 @@ const LOGO_LINES$1 = [
9059
9159
  ];
9060
9160
  const BRAND_COLOR$1 = "#FF4D00";
9061
9161
  function getVersion() {
9062
- return "0.0.0-beta.44";
9162
+ return "0.0.0-beta.45";
9063
9163
  }
9064
9164
  function printBanner(subtitle) {
9065
9165
  const version$1 = getVersion();
@@ -9848,7 +9948,7 @@ async function fetchLatestVersion() {
9848
9948
  }
9849
9949
  }
9850
9950
  function getCurrentVersion() {
9851
- return "0.0.0-beta.44";
9951
+ return "0.0.0-beta.45";
9852
9952
  }
9853
9953
  /**
9854
9954
  * Install a specific CLI version. Returns true on success.
@@ -15069,7 +15169,7 @@ function PickerMenu({ items, onSelect, onCancel }) {
15069
15169
 
15070
15170
  //#endregion
15071
15171
  //#region src/wizard/ui/primitives/ScreenLayout.tsx
15072
- const version = "0.0.0-beta.44";
15172
+ const version = "0.0.0-beta.45";
15073
15173
  const LOGO_LINES = [
15074
15174
  "██╗ ██╗███████╗██╗ ██████╗ ███████╗",
15075
15175
  "██║ ██║██╔════╝██║ ██╔═══██╗╚══███╔╝",
@@ -19736,7 +19836,7 @@ async function runOrgCreationFlow(store, apiUrl) {
19736
19836
  //#region src/index.ts
19737
19837
  if (process.argv.includes("--mcp")) process.env.VELOZ_MCP = "true";
19738
19838
  const cli = Cli.create("veloz", {
19739
- version: "0.0.0-beta.44",
19839
+ version: "0.0.0-beta.45",
19740
19840
  description: "CLI da plataforma Veloz — deploy rápido para o Brasil",
19741
19841
  env: z.object({ VELOZ_ENV: z.string().optional().describe("Ambiente alvo (ex: preview, staging)") }),
19742
19842
  globals: z.object({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "onveloz",
3
- "version": "0.0.0-beta.44",
3
+ "version": "0.0.0-beta.45",
4
4
  "description": "CLI da plataforma Veloz — deploy rápido para o Brasil",
5
5
  "keywords": [
6
6
  "brasil",