trajectories-sh 1.18.5 → 1.18.7
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
|
@@ -98,7 +98,7 @@ async function uploadTrajectoryAction(pathArg, opts) {
|
|
|
98
98
|
);
|
|
99
99
|
}
|
|
100
100
|
if (isZip) {
|
|
101
|
-
const { uploadZip } = await import("./upload-
|
|
101
|
+
const { uploadZip } = await import("./upload-UIHU3KYE.js");
|
|
102
102
|
const slug2 = opts.slug ?? pathArg.replace(/\.zip$/i, "").replace(/\/+$/, "").split("/").pop();
|
|
103
103
|
console.log(chalk.bold(`
|
|
104
104
|
Uploading ZIP ${pathArg} \u2192 ${chalk.cyan(slug2)}
|
|
@@ -127,7 +127,7 @@ async function uploadTrajectoryAction(pathArg, opts) {
|
|
|
127
127
|
Uploading trajectory ${pathArg} \u2192 ${chalk.cyan(slug)}
|
|
128
128
|
`));
|
|
129
129
|
try {
|
|
130
|
-
const { uploadJob } = await import("./upload-
|
|
130
|
+
const { uploadJob } = await import("./upload-UIHU3KYE.js");
|
|
131
131
|
const result = await uploadJob(pathArg, {
|
|
132
132
|
slug,
|
|
133
133
|
name: opts.name
|
|
@@ -60,32 +60,56 @@ async function uploadZip(zipPath, opts) {
|
|
|
60
60
|
const auth = await getAuthHeader();
|
|
61
61
|
if (!auth) throw new Error("Not authenticated. Run: trajectories auth login");
|
|
62
62
|
const apiUrl = getApiUrl();
|
|
63
|
-
console.log(" Requesting upload
|
|
64
|
-
const
|
|
63
|
+
console.log(" Requesting upload info...");
|
|
64
|
+
const infoResp = await fetch(`${apiUrl}/api/cli/push-zip/upload-url`, {
|
|
65
65
|
method: "POST",
|
|
66
66
|
headers: { Authorization: auth, "Content-Type": "application/json" },
|
|
67
67
|
body: "{}",
|
|
68
68
|
signal: AbortSignal.timeout(3e4)
|
|
69
69
|
});
|
|
70
|
-
if (!
|
|
71
|
-
throw new Error(`Failed to get upload
|
|
70
|
+
if (!infoResp.ok) {
|
|
71
|
+
throw new Error(`Failed to get upload info: ${await infoResp.text()}`);
|
|
72
72
|
}
|
|
73
|
-
const
|
|
74
|
-
|
|
73
|
+
const uploadInfo = await infoResp.json();
|
|
74
|
+
const task_id = uploadInfo.task_id;
|
|
75
|
+
console.log(" Uploading ZIP via resumable upload...");
|
|
75
76
|
const zipData = readFileSync2(zipPath);
|
|
76
|
-
const
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
77
|
+
const tus = await import("tus-js-client");
|
|
78
|
+
const projectRef = uploadInfo.supabase_url.replace("https://", "").replace(".supabase.co", "");
|
|
79
|
+
await new Promise((resolve, reject) => {
|
|
80
|
+
const upload = new tus.Upload(new Blob([zipData]), {
|
|
81
|
+
endpoint: `${uploadInfo.supabase_url}/storage/v1/upload/resumable`,
|
|
82
|
+
retryDelays: [0, 3e3, 5e3, 1e4],
|
|
83
|
+
headers: {
|
|
84
|
+
authorization: `Bearer ${uploadInfo.service_key}`,
|
|
85
|
+
"x-upsert": "true"
|
|
86
|
+
},
|
|
87
|
+
uploadDataDuringCreation: true,
|
|
88
|
+
removeFingerprintOnSuccess: true,
|
|
89
|
+
metadata: {
|
|
90
|
+
bucketName: uploadInfo.bucket,
|
|
91
|
+
objectName: uploadInfo.storage_path,
|
|
92
|
+
contentType: "application/zip"
|
|
93
|
+
},
|
|
94
|
+
chunkSize: 6 * 1024 * 1024,
|
|
95
|
+
onError(error) {
|
|
96
|
+
reject(new Error(`TUS upload failed: ${error.message}`));
|
|
97
|
+
},
|
|
98
|
+
onProgress(bytesUploaded, bytesTotal) {
|
|
99
|
+
const pct = (bytesUploaded / bytesTotal * 100).toFixed(1);
|
|
100
|
+
const uploadedMB = (bytesUploaded / (1024 * 1024)).toFixed(1);
|
|
101
|
+
const totalMB = (bytesTotal / (1024 * 1024)).toFixed(1);
|
|
102
|
+
process.stdout.write(` \u2191 ${pct}% ${uploadedMB}/${totalMB} MB\r`);
|
|
103
|
+
},
|
|
104
|
+
onSuccess() {
|
|
105
|
+
console.log(` \u2191 100% \u2014 ZIP uploaded to storage.`);
|
|
106
|
+
resolve();
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
upload.start();
|
|
81
110
|
});
|
|
82
|
-
if (!putResp.ok) {
|
|
83
|
-
const body = await putResp.text().catch(() => "");
|
|
84
|
-
throw new Error(`ZIP upload to storage failed (${putResp.status}): ${body.slice(0, 200)}`);
|
|
85
|
-
}
|
|
86
|
-
console.log(" ZIP uploaded to storage.");
|
|
87
111
|
console.log(" Enqueuing for server-side extraction...");
|
|
88
|
-
const enqueueResp = await fetch(`${apiUrl}/api/cli/push
|
|
112
|
+
const enqueueResp = await fetch(`${apiUrl}/api/cli/push-zip/enqueue`, {
|
|
89
113
|
method: "POST",
|
|
90
114
|
headers: { Authorization: auth, "Content-Type": "application/json" },
|
|
91
115
|
body: JSON.stringify({
|
|
@@ -104,7 +128,7 @@ async function uploadZip(zipPath, opts) {
|
|
|
104
128
|
let lastStatus = "";
|
|
105
129
|
while (true) {
|
|
106
130
|
await new Promise((r) => setTimeout(r, 5e3));
|
|
107
|
-
const statusResp = await fetch(`${apiUrl}/api/cli/push
|
|
131
|
+
const statusResp = await fetch(`${apiUrl}/api/cli/push-zip/${task_id}/status`, {
|
|
108
132
|
headers: { Authorization: auth },
|
|
109
133
|
signal: AbortSignal.timeout(3e4)
|
|
110
134
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "trajectories-sh",
|
|
3
|
-
"version": "1.18.
|
|
3
|
+
"version": "1.18.7",
|
|
4
4
|
"description": "CLI for uploading trajectory jobs to trajectories.sh",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -28,10 +28,11 @@
|
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"chalk": "^5.0.0",
|
|
30
30
|
"commander": "^13.0.0",
|
|
31
|
-
"sharp": "^0.34.5",
|
|
32
31
|
"open": "^10.0.0",
|
|
33
32
|
"ora": "^8.0.0",
|
|
34
|
-
"
|
|
33
|
+
"sharp": "^0.34.5",
|
|
34
|
+
"tar": "^7.0.0",
|
|
35
|
+
"tus-js-client": "^4.3.1"
|
|
35
36
|
},
|
|
36
37
|
"devDependencies": {
|
|
37
38
|
"@types/node": "^22.0.0",
|