nemar-cli 0.8.76-PR931.a9df607 → 0.8.76-PR934.63eaa7d
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/index.js +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -95,7 +95,7 @@ ${W.dim(`eta: ${D.eta}`)}`:"";process.stderr.write(`${F}
|
|
|
95
95
|
${$} ${D.message}
|
|
96
96
|
${J}${Q}
|
|
97
97
|
${F}
|
|
98
|
-
`)}var yf=!1;var gW=j(()=>{c0()});var _f;var xf=j(()=>{_f={name:"nemar-cli",version:"0.8.76-PR931.a9df607",description:"CLI for NEMAR (Neuroelectromagnetic Data Archive and Tools Resource) dataset management",type:"module",main:"dist/index.js",bin:{nemar:"dist/index.js"},scripts:{dev:"bun run src/index.ts",build:"bun build src/index.ts --outdir dist --target bun --minify && sed '1s|#!/usr/bin/env node|#!/usr/bin/env bun|' dist/index.js > dist/index.js.tmp && mv dist/index.js.tmp dist/index.js",test:"bun test",lint:"biome check src/","lint:fix":"biome check --fix src/",format:"biome format --write src/",typecheck:"tsc --noEmit",prepublishOnly:"bun run build",prepare:"husky",postinstall:"bun scripts/postinstall-check.mjs",deploy:"wrangler deploy",preview:"wrangler dev"},keywords:["nemar","bids","neuroimaging","eeg","emg","datalad","cli"],author:"NEMAR Team",license:"CC-BY-NC-ND-4.0",repository:{type:"git",url:"git+https://github.com/nemarOrg/nemar-cli.git"},bugs:{url:"https://github.com/nemarOrg/nemar-cli/issues"},homepage:"https://docs.nemar.org",engines:{bun:">=1.0.0"},files:["dist","scripts/postinstall-check.mjs","README.md","LICENSE"],dependencies:{chalk:"^5.3.0",commander:"^12.1.0",conf:"^13.0.1","fuse.js":"^7.1.0",inquirer:"^9.2.15",ora:"^8.0.1",zod:"^3.23.8"},"lint-staged":{"src/**/*.{ts,tsx}":["biome check --fix"],"backend/src/**/*.{ts,tsx}":["biome check --fix"]},devDependencies:{"@biomejs/biome":"1.9.4","@types/bcryptjs":"^3.0.0","@types/bun":"latest","@types/inquirer":"^9.0.7",bcryptjs:"^3.0.3",husky:"^9.1.7","lint-staged":"^16.3.2",typescript:"^5.5.4",wrangler:"^4.70.0",yaml:"^2.8.4"}}});var x4;var QQ=j(()=>{xf();x4=_f.version});function X0(D){if(D instanceof Error)return D.message;return String(D)}var _,_4;var F1=j(()=>{_=class _ extends Error{statusCode;details;step;constructor(D,F,$,J){super(F);this.statusCode=D;this.details=$;this.step=J;this.name="ApiError"}};_4=class _4 extends _{mode;eta;constructor(D,F,$,J){super(503,F,J);this.mode=D;this.eta=$;this.name="MaintenanceError"}}});function ff(){if(process.env.TEST_API_URL)return process.env.TEST_API_URL;if(hW)return bW;return FD().apiUrl||bW}async function v(D,F={},$=!1){let J=`${ff()}${D}`,Q={"Content-Type":"application/json","X-CLI-Version":x4,...F.headers};if($){let X=FD();if(!X.apiKey&&$===!0)throw new _(401,"Not authenticated. Run 'nemar auth login' first.");if(X.apiKey)Q.Authorization=`Bearer ${X.apiKey}`}let Y;try{Y=await fetch(J,{...F,headers:Q})}catch(X){throw new _(0,`Network error: Could not connect to ${ff()}`,{originalError:X instanceof Error?X.message:String(X)})}let B;try{B=await Y.json()}catch{throw new _(Y.status,`Invalid response from server (status ${Y.status})`)}if(!Y.ok){if(Y.status===503&&(B.mode==="read-only"||B.mode==="full")){let X=typeof B.message==="string"?B.message:"NEMAR is in maintenance mode. Please retry shortly.",G=typeof B.eta==="string"?B.eta:null,H=new _4(B.mode,X,G,B.details);throw JQ(H),H}throw new _(Y.status,B.error||B.message||"Request failed",B.details,typeof B.step==="string"?B.step:void 0)}return B}var bW="https://api.nemar.org",hW;var c6=j(()=>{d6();gW();QQ();F1();hW=bW.includes("workers.dev")});async function gf(D,F){let $=new URLSearchParams;if(D)$.set("status",D);if(F)$.set("role",F);let J=$.toString()?`?${$.toString()}`:"";return v(`/admin/users${J}`,{},!0)}async function bf(D){return v(`/admin/approve/${D}`,{method:"POST"},!0)}async function hf(D){return v(`/admin/revoke/${D}`,{method:"POST"},!0)}async function uf(D,F){return v(`/admin/users/${D}/role`,{method:"POST",body:JSON.stringify({role:F})},!0)}async function uW(D,F){return v(`/admin/datasets/${D}/visibility`,{method:"PATCH",body:JSON.stringify({visibility:F})},!0)}async function mf(D){return v(`/datasets/${D}/publish`,{method:"POST"},!0)}async function lf(D){return v(`/admin/datasets/${D}/ci`,{},!0)}async function f4(D){return v(`/admin/datasets/${D}/ci`,{method:"POST"},!0)}async function mW(D){return v(`/admin/datasets/${D}/ci/validate`,{method:"POST"},!0)}async function lW(D){return v(`/admin/datasets/${D}/ci/sync`,{method:"POST"},!0)}async function pf(D,F){return v(`/admin/datasets/${D}/doi/concept`,{method:"POST",body:JSON.stringify(F)},!0)}async function f9(D){return v(`/admin/datasets/${D}/doi`,{},!0)}async function pW(D,F){return v(`/admin/datasets/${D}/doi/update`,{method:"POST",body:JSON.stringify(F)},!0)}async function df(D){return v(`/admin/datasets/${D}/reset`,{method:"POST"},!0)}async function cf(D,F=!1){return v(`/admin/datasets/${D}`,{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({force:F})},!0)}async function nf(D){return v("/admin/datasets/bulk-delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({dataset_ids:D})},!0)}async function af(D){return v("/admin/datasets/import",{method:"POST",body:JSON.stringify(D)},!0)}async function of(D){let F=D?`?status=${encodeURIComponent(D)}`:"";return v(`/admin/imports${F}`,{},!0)}async function sf(D){return v(`/admin/imports/${D}/rollback`,{method:"POST"},!0)}async function rf(D){return v(`/admin/imports/${D}/retry`,{method:"POST"},!0)}async function YQ(D,F){return v(`/admin/datasets/${D}/reindex`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(F??{})},!0)}async function tf(D,F){return v("/admin/datasets/reindex/bulk",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filter:D,...F??{}})},!0)}async function ef(D){let F=D?.limit??15;return v(`/admin/datasets/hed-sweep?limit=${encodeURIComponent(String(F))}`,{method:"POST",headers:{"Content-Type":"application/json"}},!0)}async function Dg(){return v("/admin/datasets/hed-sweep?reset=1",{method:"POST",headers:{"Content-Type":"application/json"}},!0)}async function Fg(D){let F=new URLSearchParams;if(D?.prefix)F.set("prefix",D.prefix);if(D?.visibility)F.set("visibility",D.visibility);if(D?.limit)F.set("limit",String(D.limit));let $=F.toString()?`?${F.toString()}`:"";return v(`/admin/fleet/drift${$}`,{},!0)}async function kF(D,F){return v(`/admin/datasets/${D}/enforce`,{method:"POST",body:JSON.stringify({dry_run:F})},!0)}async function $g(D){return v("/admin/datasets/enforce/bulk",{method:"POST",body:JSON.stringify({prefix:D.prefix,visibility:D.visibility,limit:D.limit,dry_run:D.dryRun})},!0)}async function Jg(D,F=!1){return v(`/admin/datasets/${D}/revalidate${F?"?force=true":""}`,{method:"POST"},!0)}async function Qg(D){let F=D?`?user=${encodeURIComponent(D)}`:"";return v(`/admin/email-preferences${F}`,{},!0)}async function Yg(D,F){let $=F?`?user=${encodeURIComponent(F)}`:"";return v(`/admin/email-preferences${$}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(D)},!0)}async function dW(D){return v("/admin/notify",{method:"POST",body:JSON.stringify(D)},!0)}async function Bg(){return v("/admin/summary/coverage",{},!0)}async function Xg(D,F,$){return v("/admin/manifest/dispatch",{method:"POST",body:JSON.stringify({dataset_id:D,version:F,skip_canary:$?.skipCanary??!1})},!0)}var g9=j(()=>{c6()});async function O8(D,F){return v(`/datasets/${D}/upload-credentials`,{method:"POST",body:JSON.stringify({duration_seconds:F})},!0)}async function cW(D,F){return v(`/datasets/${D}/download-credentials`,{method:"POST",body:JSON.stringify({duration_seconds:F})},!0)}async function Gg(D){return v(`/admin/datasets/${D}/files`,{},!0)}async function Wg(D){let F,$=0,J=[],Q=!0;while(Q){let Y=await v(`/admin/datasets/${D}/s3-lock`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({continuation_token:F})},!0);if($+=Y.locked,Y.failed?.length)J.push(...Y.failed);if(Q=Y.hasMore,F=Y.continuation_token,Q&&!F)throw new _(500,"S3 lock paginated response missing continuation_token; aborting to avoid infinite loop")}return{locked:$,failed:J}}var vF=j(()=>{c6();F1()});async function XQ(D){return v(`/datasets/${D}/ci/status`,{},!0)}async function Hg(D){return v(`/datasets/${D}/manifest`,{},!0)}async function GQ(D,F){return v(`/datasets/${D}/manifest/${F}`,{},!0)}function Kg(D){let F=D;if(!F.status)F.status="active";else if(!["active","archived","deleted"].includes(F.status))throw Error(`Invalid dataset status: ${F.status}`);if(!F.visibility)F.visibility="private";else if(!["public","private"].includes(F.visibility))throw Error(`Invalid dataset visibility: ${F.visibility}`);return F}async function yF(D={}){let F=new URLSearchParams;if(D.mine)F.set("mine","true");if(D.search)F.set("search",D.search);if(D.modality)F.set("modality",D.modality);if(D.author)F.set("author",D.author);if(D.task)F.set("task",D.task);if(D.license)F.set("license",D.license);if(D.hasDoi)F.set("has_doi","true");if(D.hasHed)F.set("has_hed","1");if(D.recent)F.set("recent",String(D.recent));if(D.sort)F.set("sort",D.sort);if(D.limit!=null)F.set("limit",String(D.limit));if(D.offset!=null)F.set("offset",String(D.offset));if(D.owner)F.set("owner",D.owner);let $=F.toString()?`?${F.toString()}`:"",J=await v(`/datasets${$}`,{},D.mine?!0:"optional");return J.datasets=J.datasets.map(Kg),J}async function qg(D){return v(`/datasets/resolve/${D}`,{},"optional")}async function zg(D,F={}){let $=new URLSearchParams({q:D});if(F.modality)$.set("modality",F.modality);if(F.limit)$.set("limit",String(F.limit));if(F.hasHed)$.set("has_hed","1");return v(`/datasets/search?${$.toString()}`,{},"optional")}async function OD(D){let F=await v(`/datasets/${D}`,{},"optional");return Kg(F.dataset)}async function Eg(D){return v(`/datasets/${D}/versions`,{},!0)}async function WQ(D){return v("/datasets",{method:"POST",body:JSON.stringify(D)},!0)}async function HQ(D){return v(`/datasets/${D}/finalize`,{method:"POST"},!0)}async function nW(D){return v(`/datasets/${D}/request-access`,{method:"POST"},!0)}async function Vg(D,F){let $=F?`?status=${F}`:"";return v(`/datasets/${D}/access-requests${$}`,{},!0)}async function Zg(D,F){return v(`/datasets/${D}/access-requests/${F}/approve`,{method:"POST"},!0)}async function Ug(D,F){return v(`/datasets/${D}/access-requests/${F}/deny`,{method:"POST"},!0)}async function Lg(D,F){return v(`/datasets/${D}/invite`,{method:"POST",body:JSON.stringify({username:F})},!0)}async function Mg(D){return v(`/datasets/${D}/collaborators`,{},!0)}async function Ag(D,F){return v(`/admin/datasets/${D}/enrichment`,{method:"POST",body:JSON.stringify(F)},!0)}var BQ;var g4=j(()=>{c6();BQ=/^\d{4}-\d{4}-\d{4}-\d{3}[\dX]$/});var xF;var Tg=j(()=>{xF=["ci_check","enrichment_check","s3_public_read","repo_public","tag_protect","doi_create","update_metadata","update_readme","create_tag","create_release","upload_to_zenodo","publish_doi","version_doi","s3_lock","sync_nemar","notify_user"]});async function KQ(D){return v(`/datasets/${D}/publish/request`,{method:"POST"},!0)}async function jg(D){return v(`/datasets/${D}/publish/status`,{},!0)}async function Pg(D){return v(`/datasets/${D}/publish/resend`,{method:"POST"},!0)}async function Ig(D){let F=D?`?status=${D}`:"";return v(`/admin/publish/requests${F}`,{},!0)}async function Sg(D,F){return v(`/admin/publish/${D}/deny`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({reason:F})},!0)}function fV0(D,F=[]){if(D){let $=xF.indexOf(D);if($>=0)return $+1}return Math.min(F.length+1,xF.length)}function gV0(D){if(!(D instanceof _))return!1;if(D.statusCode===0)return!0;if(D.statusCode===429)return!0;if(D.statusCode>=500&&D.statusCode<600)return!0;if(D.statusCode===403&&/repository has been locked/i.test(D.message))return!0;return!1}async function qQ(D,F=!1,$=!1,J=!1,Q,Y){let G,H,K=0,q=!1,E,z=F,Z=[],U;function A(M,R,w,S){if(!Y)return;Y({step:M,stepIndex:fV0(M,R),stepTotal:xF.length,s3LockLocked:w,s3LockTotal:S,s3LockResumed:M==="s3_lock"&&q?!0:void 0})}for(let M=1;M<=5;M++)try{let R,w=!0;do{if(R=await v(`/admin/publish/${D}/approve`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({resume:w?z:!0,sandbox:$,s3_lock_continuation_token:G,s3_lock_total:H,skip_ci_check:J})},!0),w=!1,R.step_results)Z.push(...R.step_results);if(R.s3_lock_total!==void 0)H=R.s3_lock_total;if(R.s3_lock_batch_count!==void 0)K+=R.s3_lock_batch_count;let S=R.step??R.step_results?.[R.step_results.length-1]?.step;if(S&&(S!==E||S==="s3_lock"))A(S,R.steps_completed??[],S==="s3_lock"?K:void 0,S==="s3_lock"?H:void 0),E=S;if(R.hasMore&&R.s3_lock_continuation_token!==void 0)G=R.s3_lock_continuation_token;else break}while(R.hasMore);if(Z.length>0)R.step_results=wg(Z);return R}catch(R){if(U=R,M===5||!gV0(R)){if(R instanceof _&&Z.length>0)R.stepResults=wg(Z);throw R}let S=R;if(Q?.({attempt:M,maxAttempts:5,delayMs:1e4,step:S.step,error:S.message}),await new Promise((N)=>setTimeout(N,1e4)),z=!0,G!==void 0)q=!0}throw U}function wg(D){let F=new Map;for(let $ of D)F.set($.step,$);return Array.from(F.values())}var zQ=j(()=>{Tg();c6();F1()});function yg(D){aW=D}function oW(){return aW}function b9(D){if(aW)process.stderr.write(`${D}
|
|
98
|
+
`)}var yf=!1;var gW=j(()=>{c0()});var _f;var xf=j(()=>{_f={name:"nemar-cli",version:"0.8.76-PR934.63eaa7d",description:"CLI for NEMAR (Neuroelectromagnetic Data Archive and Tools Resource) dataset management",type:"module",main:"dist/index.js",bin:{nemar:"dist/index.js"},scripts:{dev:"bun run src/index.ts",build:"bun build src/index.ts --outdir dist --target bun --minify && sed '1s|#!/usr/bin/env node|#!/usr/bin/env bun|' dist/index.js > dist/index.js.tmp && mv dist/index.js.tmp dist/index.js",test:"bun test",lint:"biome check src/","lint:fix":"biome check --fix src/",format:"biome format --write src/",typecheck:"tsc --noEmit",prepublishOnly:"bun run build",prepare:"husky",postinstall:"bun scripts/postinstall-check.mjs",deploy:"wrangler deploy",preview:"wrangler dev"},keywords:["nemar","bids","neuroimaging","eeg","emg","datalad","cli"],author:"NEMAR Team",license:"CC-BY-NC-ND-4.0",repository:{type:"git",url:"git+https://github.com/nemarOrg/nemar-cli.git"},bugs:{url:"https://github.com/nemarOrg/nemar-cli/issues"},homepage:"https://docs.nemar.org",engines:{bun:">=1.0.0"},files:["dist","scripts/postinstall-check.mjs","README.md","LICENSE"],dependencies:{chalk:"^5.3.0",commander:"^12.1.0",conf:"^13.0.1","fuse.js":"^7.1.0",inquirer:"^9.2.15",ora:"^8.0.1",zod:"^3.23.8"},"lint-staged":{"src/**/*.{ts,tsx}":["biome check --fix"],"backend/src/**/*.{ts,tsx}":["biome check --fix"]},devDependencies:{"@biomejs/biome":"1.9.4","@types/bcryptjs":"^3.0.0","@types/bun":"latest","@types/inquirer":"^9.0.7",bcryptjs:"^3.0.3",husky:"^9.1.7","lint-staged":"^16.3.2",typescript:"^5.5.4",wrangler:"^4.70.0",yaml:"^2.8.4"}}});var x4;var QQ=j(()=>{xf();x4=_f.version});function X0(D){if(D instanceof Error)return D.message;return String(D)}var _,_4;var F1=j(()=>{_=class _ extends Error{statusCode;details;step;constructor(D,F,$,J){super(F);this.statusCode=D;this.details=$;this.step=J;this.name="ApiError"}};_4=class _4 extends _{mode;eta;constructor(D,F,$,J){super(503,F,J);this.mode=D;this.eta=$;this.name="MaintenanceError"}}});function ff(){if(process.env.TEST_API_URL)return process.env.TEST_API_URL;if(hW)return bW;return FD().apiUrl||bW}async function v(D,F={},$=!1){let J=`${ff()}${D}`,Q={"Content-Type":"application/json","X-CLI-Version":x4,...F.headers};if($){let X=FD();if(!X.apiKey&&$===!0)throw new _(401,"Not authenticated. Run 'nemar auth login' first.");if(X.apiKey)Q.Authorization=`Bearer ${X.apiKey}`}let Y;try{Y=await fetch(J,{...F,headers:Q})}catch(X){throw new _(0,`Network error: Could not connect to ${ff()}`,{originalError:X instanceof Error?X.message:String(X)})}let B;try{B=await Y.json()}catch{throw new _(Y.status,`Invalid response from server (status ${Y.status})`)}if(!Y.ok){if(Y.status===503&&(B.mode==="read-only"||B.mode==="full")){let X=typeof B.message==="string"?B.message:"NEMAR is in maintenance mode. Please retry shortly.",G=typeof B.eta==="string"?B.eta:null,H=new _4(B.mode,X,G,B.details);throw JQ(H),H}throw new _(Y.status,B.error||B.message||"Request failed",B.details,typeof B.step==="string"?B.step:void 0)}return B}var bW="https://api.nemar.org",hW;var c6=j(()=>{d6();gW();QQ();F1();hW=bW.includes("workers.dev")});async function gf(D,F){let $=new URLSearchParams;if(D)$.set("status",D);if(F)$.set("role",F);let J=$.toString()?`?${$.toString()}`:"";return v(`/admin/users${J}`,{},!0)}async function bf(D){return v(`/admin/approve/${D}`,{method:"POST"},!0)}async function hf(D){return v(`/admin/revoke/${D}`,{method:"POST"},!0)}async function uf(D,F){return v(`/admin/users/${D}/role`,{method:"POST",body:JSON.stringify({role:F})},!0)}async function uW(D,F){return v(`/admin/datasets/${D}/visibility`,{method:"PATCH",body:JSON.stringify({visibility:F})},!0)}async function mf(D){return v(`/datasets/${D}/publish`,{method:"POST"},!0)}async function lf(D){return v(`/admin/datasets/${D}/ci`,{},!0)}async function f4(D){return v(`/admin/datasets/${D}/ci`,{method:"POST"},!0)}async function mW(D){return v(`/admin/datasets/${D}/ci/validate`,{method:"POST"},!0)}async function lW(D){return v(`/admin/datasets/${D}/ci/sync`,{method:"POST"},!0)}async function pf(D,F){return v(`/admin/datasets/${D}/doi/concept`,{method:"POST",body:JSON.stringify(F)},!0)}async function f9(D){return v(`/admin/datasets/${D}/doi`,{},!0)}async function pW(D,F){return v(`/admin/datasets/${D}/doi/update`,{method:"POST",body:JSON.stringify(F)},!0)}async function df(D){return v(`/admin/datasets/${D}/reset`,{method:"POST"},!0)}async function cf(D,F=!1){return v(`/admin/datasets/${D}`,{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({force:F})},!0)}async function nf(D){return v("/admin/datasets/bulk-delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({dataset_ids:D})},!0)}async function af(D){return v("/admin/datasets/import",{method:"POST",body:JSON.stringify(D)},!0)}async function of(D){let F=D?`?status=${encodeURIComponent(D)}`:"";return v(`/admin/imports${F}`,{},!0)}async function sf(D){return v(`/admin/imports/${D}/rollback`,{method:"POST"},!0)}async function rf(D){return v(`/admin/imports/${D}/retry`,{method:"POST"},!0)}async function YQ(D,F){return v(`/admin/datasets/${D}/reindex`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(F??{})},!0)}async function tf(D,F){return v("/admin/datasets/reindex/bulk",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filter:D,...F??{}})},!0)}async function ef(D){let F=D?.limit??15;return v(`/admin/datasets/hed-sweep?limit=${encodeURIComponent(String(F))}`,{method:"POST",headers:{"Content-Type":"application/json"}},!0)}async function Dg(){return v("/admin/datasets/hed-sweep?reset=1",{method:"POST",headers:{"Content-Type":"application/json"}},!0)}async function Fg(D){let F=new URLSearchParams;if(D?.prefix)F.set("prefix",D.prefix);if(D?.visibility)F.set("visibility",D.visibility);if(D?.limit)F.set("limit",String(D.limit));let $=F.toString()?`?${F.toString()}`:"";return v(`/admin/fleet/drift${$}`,{},!0)}async function kF(D,F){return v(`/admin/datasets/${D}/enforce`,{method:"POST",body:JSON.stringify({dry_run:F})},!0)}async function $g(D){return v("/admin/datasets/enforce/bulk",{method:"POST",body:JSON.stringify({prefix:D.prefix,visibility:D.visibility,limit:D.limit,dry_run:D.dryRun})},!0)}async function Jg(D,F=!1){return v(`/admin/datasets/${D}/revalidate${F?"?force=true":""}`,{method:"POST"},!0)}async function Qg(D){let F=D?`?user=${encodeURIComponent(D)}`:"";return v(`/admin/email-preferences${F}`,{},!0)}async function Yg(D,F){let $=F?`?user=${encodeURIComponent(F)}`:"";return v(`/admin/email-preferences${$}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(D)},!0)}async function dW(D){return v("/admin/notify",{method:"POST",body:JSON.stringify(D)},!0)}async function Bg(){return v("/admin/summary/coverage",{},!0)}async function Xg(D,F,$){return v("/admin/manifest/dispatch",{method:"POST",body:JSON.stringify({dataset_id:D,version:F,skip_canary:$?.skipCanary??!1})},!0)}var g9=j(()=>{c6()});async function O8(D,F){return v(`/datasets/${D}/upload-credentials`,{method:"POST",body:JSON.stringify({duration_seconds:F})},!0)}async function cW(D,F){return v(`/datasets/${D}/download-credentials`,{method:"POST",body:JSON.stringify({duration_seconds:F})},!0)}async function Gg(D){return v(`/admin/datasets/${D}/files`,{},!0)}async function Wg(D){let F,$=0,J=[],Q=!0;while(Q){let Y=await v(`/admin/datasets/${D}/s3-lock`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({continuation_token:F})},!0);if($+=Y.locked,Y.failed?.length)J.push(...Y.failed);if(Q=Y.hasMore,F=Y.continuation_token,Q&&!F)throw new _(500,"S3 lock paginated response missing continuation_token; aborting to avoid infinite loop")}return{locked:$,failed:J}}var vF=j(()=>{c6();F1()});async function XQ(D){return v(`/datasets/${D}/ci/status`,{},!0)}async function Hg(D){return v(`/datasets/${D}/manifest`,{},!0)}async function GQ(D,F){return v(`/datasets/${D}/manifest/${F}`,{},!0)}function Kg(D){let F=D;if(!F.status)F.status="active";else if(!["active","archived","deleted"].includes(F.status))throw Error(`Invalid dataset status: ${F.status}`);if(!F.visibility)F.visibility="private";else if(!["public","private"].includes(F.visibility))throw Error(`Invalid dataset visibility: ${F.visibility}`);return F}async function yF(D={}){let F=new URLSearchParams;if(D.mine)F.set("mine","true");if(D.search)F.set("search",D.search);if(D.modality)F.set("modality",D.modality);if(D.author)F.set("author",D.author);if(D.task)F.set("task",D.task);if(D.license)F.set("license",D.license);if(D.hasDoi)F.set("has_doi","true");if(D.hasHed)F.set("has_hed","1");if(D.recent)F.set("recent",String(D.recent));if(D.sort)F.set("sort",D.sort);if(D.limit!=null)F.set("limit",String(D.limit));if(D.offset!=null)F.set("offset",String(D.offset));if(D.owner)F.set("owner",D.owner);let $=F.toString()?`?${F.toString()}`:"",J=await v(`/datasets${$}`,{},D.mine?!0:"optional");return J.datasets=J.datasets.map(Kg),J}async function qg(D){return v(`/datasets/resolve/${D}`,{},"optional")}async function zg(D,F={}){let $=new URLSearchParams({q:D});if(F.modality)$.set("modality",F.modality);if(F.limit)$.set("limit",String(F.limit));if(F.hasHed)$.set("has_hed","1");return v(`/datasets/search?${$.toString()}`,{},"optional")}async function OD(D){let F=await v(`/datasets/${D}`,{},"optional");return Kg(F.dataset)}async function Eg(D){return v(`/datasets/${D}/versions`,{},!0)}async function WQ(D){return v("/datasets",{method:"POST",body:JSON.stringify(D)},!0)}async function HQ(D){return v(`/datasets/${D}/finalize`,{method:"POST"},!0)}async function nW(D){return v(`/datasets/${D}/request-access`,{method:"POST"},!0)}async function Vg(D,F){let $=F?`?status=${F}`:"";return v(`/datasets/${D}/access-requests${$}`,{},!0)}async function Zg(D,F){return v(`/datasets/${D}/access-requests/${F}/approve`,{method:"POST"},!0)}async function Ug(D,F){return v(`/datasets/${D}/access-requests/${F}/deny`,{method:"POST"},!0)}async function Lg(D,F){return v(`/datasets/${D}/invite`,{method:"POST",body:JSON.stringify({username:F})},!0)}async function Mg(D){return v(`/datasets/${D}/collaborators`,{},!0)}async function Ag(D,F){return v(`/admin/datasets/${D}/enrichment`,{method:"POST",body:JSON.stringify(F)},!0)}var BQ;var g4=j(()=>{c6();BQ=/^\d{4}-\d{4}-\d{4}-\d{3}[\dX]$/});var xF;var Tg=j(()=>{xF=["ci_check","enrichment_check","s3_public_read","repo_public","tag_protect","doi_create","update_metadata","update_readme","create_tag","create_release","upload_to_zenodo","publish_doi","version_doi","s3_lock","sync_nemar","notify_user"]});async function KQ(D){return v(`/datasets/${D}/publish/request`,{method:"POST"},!0)}async function jg(D){return v(`/datasets/${D}/publish/status`,{},!0)}async function Pg(D){return v(`/datasets/${D}/publish/resend`,{method:"POST"},!0)}async function Ig(D){let F=D?`?status=${D}`:"";return v(`/admin/publish/requests${F}`,{},!0)}async function Sg(D,F){return v(`/admin/publish/${D}/deny`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({reason:F})},!0)}function fV0(D,F=[]){if(D){let $=xF.indexOf(D);if($>=0)return $+1}return Math.min(F.length+1,xF.length)}function gV0(D){if(!(D instanceof _))return!1;if(D.statusCode===0)return!0;if(D.statusCode===429)return!0;if(D.statusCode>=500&&D.statusCode<600)return!0;if(D.statusCode===403&&/repository has been locked/i.test(D.message))return!0;return!1}async function qQ(D,F=!1,$=!1,J=!1,Q,Y){let G,H,K=0,q=!1,E,z=F,Z=[],U;function A(M,R,w,S){if(!Y)return;Y({step:M,stepIndex:fV0(M,R),stepTotal:xF.length,s3LockLocked:w,s3LockTotal:S,s3LockResumed:M==="s3_lock"&&q?!0:void 0})}for(let M=1;M<=5;M++)try{let R,w=!0;do{if(R=await v(`/admin/publish/${D}/approve`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({resume:w?z:!0,sandbox:$,s3_lock_continuation_token:G,s3_lock_total:H,skip_ci_check:J})},!0),w=!1,R.step_results)Z.push(...R.step_results);if(R.s3_lock_total!==void 0)H=R.s3_lock_total;if(R.s3_lock_batch_count!==void 0)K+=R.s3_lock_batch_count;let S=R.step??R.step_results?.[R.step_results.length-1]?.step;if(S&&(S!==E||S==="s3_lock"))A(S,R.steps_completed??[],S==="s3_lock"?K:void 0,S==="s3_lock"?H:void 0),E=S;if(R.hasMore&&R.s3_lock_continuation_token!==void 0)G=R.s3_lock_continuation_token;else break}while(R.hasMore);if(Z.length>0)R.step_results=wg(Z);return R}catch(R){if(U=R,M===5||!gV0(R)){if(R instanceof _&&Z.length>0)R.stepResults=wg(Z);throw R}let S=R;if(Q?.({attempt:M,maxAttempts:5,delayMs:1e4,step:S.step,error:S.message}),await new Promise((N)=>setTimeout(N,1e4)),z=!0,G!==void 0)q=!0}throw U}function wg(D){let F=new Map;for(let $ of D)F.set($.step,$);return Array.from(F.values())}var zQ=j(()=>{Tg();c6();F1()});function yg(D){aW=D}function oW(){return aW}function b9(D){if(aW)process.stderr.write(`${D}
|
|
99
99
|
`)}var aW=!1;var xg={};r6(xg,{runCommand:()=>T});var{spawn:bV0}=globalThis.Bun;async function T(D,F={}){let $={...process.env,GIT_TERMINAL_PROMPT:"0",...F.env};for(let H of F.unsetEnv??[])delete $[H];let J=bV0({cmd:D,cwd:F.cwd,stdout:"pipe",stderr:"pipe",env:$}),Q=!1,Y;if(F.timeout)Y=setTimeout(()=>{Q=!0,J.kill()},F.timeout);if(oW()){let H=F.cwd?` (cwd=${F.cwd})`:"";b9(W.dim(`$ ${D.join(" ")}${H}`))}let B=await new Response(J.stdout).text(),X=await new Response(J.stderr).text(),G=await J.exited;if(Y)clearTimeout(Y);if(oW()){if(B.trim())b9(W.dim(B.trimEnd()));if(X.trim())b9(W.yellow(X.trimEnd()));b9(W.dim(`(exit ${G})`))}if(Q)return{stdout:B,stderr:X||`Command timed out after ${Math.round(F.timeout/1000)}s`,exitCode:G??1};return{stdout:B,stderr:X,exitCode:G}}var $1=j(()=>{c0()});async function hV0(){try{let{exitCode:D,stderr:F}=await T(["ssh","-T","-o","BatchMode=yes","-o","ConnectTimeout=5","git@github.com"]),$=F.includes("successfully authenticated");if(!$)console.warn("SSH test to github.com failed:",{exitCode:D,stderr:F.trim().slice(0,500)});return{works:$,error:$?void 0:F.trim().slice(0,500)}}catch(D){let F=D instanceof Error?D.message:String(D);return console.warn("SSH test exception:",F),{works:!1,error:F}}}async function h9(){try{let{stdout:D,exitCode:F,stderr:$}=await T(["gh","auth","token"]);if(F!==0)return console.warn("gh CLI returned non-zero exit code:",F),console.warn("stderr:",$),{token:null,error:`gh auth token failed: ${$.trim()||"unknown error"}`};if(!D.trim())return console.warn("gh auth token returned empty output"),{token:null,error:"gh CLI returned empty token"};return{token:D.trim()}}catch(D){let F=D instanceof Error?D.message:String(D);if(console.error("Failed to get GitHub token from gh CLI:",F),F.includes("ENOENT")||F.includes("not found"))return{token:null,error:"gh CLI not installed (command not found)"};return{token:null,error:`gh CLI error: ${F}`}}}async function EQ(D){try{let{stdout:F,exitCode:$,stderr:J}=await T(["gh","api","user","--jq",".login"]);if($!==0){if(J.includes("not logged in")||J.includes("auth login"))return{authenticated:!1,error:"gh CLI not authenticated. Run 'gh auth login' to authenticate."};return{authenticated:!1,error:`gh CLI error: ${J.trim()||"unknown error"}`}}let Q=F.trim();if(!Q)return{authenticated:!1,error:"gh CLI returned empty username"};if(D){let Y=Q.toLowerCase()===D.toLowerCase();return{authenticated:!0,username:Q,matches:Y,error:Y?void 0:`gh CLI authenticated as '${Q}', expected '${D}'`}}return{authenticated:!0,username:Q}}catch(F){let $=F instanceof Error?F.message:String(F);if($.includes("ENOENT")||$.includes("not found"))return{authenticated:!1,error:"gh CLI not installed. Install from https://cli.github.com/"};return{authenticated:!1,error:`Failed to verify gh CLI: ${$}`}}}async function VQ(D){if(!/^[a-zA-Z0-9_.-]+\/[a-zA-Z0-9_.-]+$/.test(D))return{accepted:!1,error:`Invalid repository format: ${D}`};let{stdout:F,exitCode:$,stderr:J}=await T(["gh","api","/user/repository_invitations"]);if($!==0){if(J.includes("not logged in")||J.includes("auth login"))return{accepted:!1,error:"gh CLI not authenticated. Run 'gh auth login' to authenticate."};if(J.includes("API rate limit")||J.includes("403"))return{accepted:!1,error:"GitHub API rate limit exceeded. Please try again in a few minutes."};if(J.includes("ENOENT")||J.includes("not found"))return{accepted:!1,error:"gh CLI not installed. Install from https://cli.github.com/"};return{accepted:!1,error:`Failed to list invitations: ${J.trim()||"unknown error"}`}}let Q=null;try{Q=JSON.parse(F||"[]").find((H)=>H.repository.full_name===D)?.id??null}catch(X){let G=X instanceof Error?X.message:String(X);return console.error("Failed to parse GitHub invitations response:",G),console.error(" Raw response (first 500 chars):",(F||"").slice(0,500)),{accepted:!1,error:`Failed to parse GitHub API response: ${G}`}}if(!Q){let{exitCode:X}=await T(["gh","api",`/repos/${D}`,"--silent"]);if(X===0)return{accepted:!0,alreadyCollaborator:!0};return{accepted:!1,error:`No pending invitation found for ${D}. You may need to accept it manually via GitHub.`}}let{exitCode:Y,stderr:B}=await T(["gh","api","--method","PATCH",`/user/repository_invitations/${Q}`]);if(Y!==0)return{accepted:!1,error:`Failed to accept invitation: ${B.trim()||"unknown error"}`};return{accepted:!0}}async function n6(D,F,$="origin"){let J=F;if(process.env.GH_TOKEN&&F.startsWith("git@github.com:")){let Q=process.env.GH_TOKEN.trim();if(!Q||/\s/.test(Q))return{success:!1,error:"GH_TOKEN environment variable is set but appears malformed (empty or contains whitespace)"};J=`https://github.com/${F.replace("git@github.com:","")}`,await T(["git","config","credential.https://github.com.helper",`!printf 'username=x-access-token\\npassword=${Q}'`],{cwd:D})}else if(F.startsWith("git@github.com:")){let Q=F.replace("git@github.com:",""),Y=await h9();if(Y.token)J=`https://github.com/${Q}`,await T(["git","config","credential.https://github.com.helper",`!printf 'username=x-access-token\\npassword=${Y.token}'`],{cwd:D});else{let B=await hV0();if(B.works)J=F;else return{success:!1,error:`GitHub authentication not configured.
|
|
100
100
|
|
|
101
101
|
gh CLI failed: ${Y.error||"could not get token"}
|
package/package.json
CHANGED