trajectories-sh 1.5.0 → 1.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -81,7 +81,7 @@ program.command("upload <directory>").description("Upload a trajectory job direc
81
81
  Pushing ${directory} \u2192 ${chalk.cyan(slug)}
82
82
  `));
83
83
  try {
84
- const { uploadJob } = await import("./upload-VENSGUFO.js");
84
+ const { uploadJob } = await import("./upload-3VEY2SEN.js");
85
85
  const result = await uploadJob(directory, {
86
86
  slug,
87
87
  name: opts.name,
@@ -145,7 +145,37 @@ async function uploadJob(dir, opts) {
145
145
  const files = collectFiles(convertedDir);
146
146
  const totalSize = files.reduce((s, f) => s + f.size, 0);
147
147
  console.log(` ${files.length} files, ${(totalSize / 1024 / 1024).toFixed(1)} MB`);
148
- const initResp = await apiPost("/api/cli/push/init", { slug, name, visibility });
148
+ try {
149
+ const auth = await getAuthHeader();
150
+ const usageResp = await fetch(`${getApiUrl()}/api/cli/usage`, {
151
+ headers: auth ? { Authorization: auth } : {},
152
+ signal: AbortSignal.timeout(1e4)
153
+ });
154
+ if (usageResp.status === 200) {
155
+ const usage = await usageResp.json();
156
+ if (usage.plan !== "enterprise") {
157
+ if (usage.trajectory_count >= usage.trajectory_limit) {
158
+ const plan = usage.plan === "free" ? "Team" : "Enterprise";
159
+ throw new Error(
160
+ `Trajectory limit reached (${usage.trajectory_count.toLocaleString()}/${usage.trajectory_limit.toLocaleString()}). Upgrade to ${plan} for more: https://trajectories.sh/pricing`
161
+ );
162
+ }
163
+ const projectedStorage = usage.storage_bytes_used + totalSize;
164
+ if (projectedStorage > usage.storage_limit_bytes) {
165
+ const usedGB = (usage.storage_bytes_used / 1024 ** 3).toFixed(1);
166
+ const uploadGB = (totalSize / 1024 ** 3).toFixed(1);
167
+ const limitGB = (usage.storage_limit_bytes / 1024 ** 3).toFixed(0);
168
+ const plan = usage.plan === "free" ? "Team" : "Enterprise";
169
+ throw new Error(
170
+ `Storage limit would be exceeded (${usedGB} GB used + ${uploadGB} GB upload > ${limitGB} GB limit). Upgrade to ${plan} for more: https://trajectories.sh/pricing`
171
+ );
172
+ }
173
+ }
174
+ }
175
+ } catch (e) {
176
+ if (e.message?.includes("limit")) throw e;
177
+ }
178
+ const initResp = await apiPost("/api/cli/push/init", { slug, name, visibility, estimated_bytes: totalSize });
149
179
  if (!initResp.ok) {
150
180
  throw new Error(`Init failed: ${await initResp.text()}`);
151
181
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "trajectories-sh",
3
- "version": "1.5.0",
3
+ "version": "1.5.1",
4
4
  "description": "CLI for uploading trajectory jobs to trajectories.sh",
5
5
  "type": "module",
6
6
  "bin": {