nemar-cli 0.8.53-dev.1381 → 0.8.53-dev.1394

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.
Files changed (2) hide show
  1. package/dist/index.js +1 -1
  2. 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 kf=!1;var vW=P(()=>{jD()});var yf;var vf=P(()=>{yf={name:"nemar-cli",version:"0.8.53-dev.1381",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 g4;var FQ=P(()=>{vf();g4=yf.version});function C0(D){if(D instanceof Error)return D.message;return String(D)}function xf(){if(process.env.TEST_API_URL)return process.env.TEST_API_URL;if(xW)return yW;return BD().apiUrl||yW}async function y(D,F={},$=!1){let J=`${xf()}${D}`,Q={"Content-Type":"application/json","X-CLI-Version":g4,...F.headers};if($){let X=BD();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 ${xf()}`,{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 JQ(B.mode,X,G,B.details);throw DQ(H),H}throw new _(Y.status,B.error||B.message||"Request failed",B.details,typeof B.step==="string"?B.step:void 0)}return B}async function ff(D){return y(`/auth/check-username?username=${encodeURIComponent(D)}`)}async function gf(D){return y(`/auth/check-github?username=${encodeURIComponent(D)}`)}async function hf(D){return y("/auth/signup",{method:"POST",body:JSON.stringify(D)})}async function bf(D){return y("/auth/login",{method:"POST",body:JSON.stringify({api_key:D})})}async function uf(D){return y("/auth/resend-verification",{method:"POST",body:JSON.stringify({email:D})})}async function mf(D,F){return y("/auth/retrieve-key",{method:"POST",body:JSON.stringify({email:D,password:F})})}async function lf(D){return y("/auth/request-key-regeneration",{method:"POST",body:JSON.stringify({email:D})})}async function QQ(){return y("/users/me",{},!0)}async function pf(D,F){let $=new URLSearchParams;if(D)$.set("status",D);if(F)$.set("role",F);let J=$.toString()?`?${$.toString()}`:"";return y(`/admin/users${J}`,{},!0)}async function df(D){return y(`/admin/approve/${D}`,{method:"POST"},!0)}async function cf(D){return y(`/admin/revoke/${D}`,{method:"POST"},!0)}async function nf(D,F){return y(`/admin/users/${D}/role`,{method:"POST",body:JSON.stringify({role:F})},!0)}async function _W(D,F){return y(`/admin/datasets/${D}/visibility`,{method:"PATCH",body:JSON.stringify({visibility:F})},!0)}async function af(D){return y(`/datasets/${D}/publish`,{method:"POST"},!0)}async function of(D){return y(`/admin/datasets/${D}/ci`,{},!0)}async function h4(D){return y(`/admin/datasets/${D}/ci`,{method:"POST"},!0)}async function fW(D){return y(`/admin/datasets/${D}/ci/validate`,{method:"POST"},!0)}async function gW(D){return y(`/admin/datasets/${D}/ci/sync`,{method:"POST"},!0)}async function YQ(D){return y(`/datasets/${D}/ci/status`,{},!0)}async function sf(D){return y(`/datasets/${D}/manifest`,{},!0)}async function BQ(D,F){return y(`/datasets/${D}/manifest/${F}`,{},!0)}function rf(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 kF(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.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 y(`/datasets${$}`,{},D.mine?!0:"optional");return J.datasets=J.datasets.map(rf),J}async function tf(D){return y(`/datasets/resolve/${D}`,{},"optional")}async function ef(D,F={}){let $=new URLSearchParams({q:D});if(F.modality)$.set("modality",F.modality);if(F.limit)$.set("limit",String(F.limit));return y(`/datasets/search?${$.toString()}`,{},"optional")}async function uD(D){let F=await y(`/datasets/${D}`,{},"optional");return rf(F.dataset)}async function Dg(D){return y(`/datasets/${D}/versions`,{},!0)}async function XQ(D){return y("/datasets",{method:"POST",body:JSON.stringify(D)},!0)}async function GQ(D){return y(`/datasets/${D}/finalize`,{method:"POST"},!0)}async function o8(D,F){return y(`/datasets/${D}/upload-credentials`,{method:"POST",body:JSON.stringify({duration_seconds:F})},!0)}async function WQ(D,F){return y(`/datasets/${D}/download-credentials`,{method:"POST",body:JSON.stringify({duration_seconds:F})},!0)}async function Fg(D,F){return y(`/admin/datasets/${D}/doi/concept`,{method:"POST",body:JSON.stringify(F)},!0)}async function _9(D){return y(`/admin/datasets/${D}/doi`,{},!0)}async function hW(D,F){return y(`/admin/datasets/${D}/doi/update`,{method:"POST",body:JSON.stringify(F)},!0)}async function bW(D){return y(`/datasets/${D}/request-access`,{method:"POST"},!0)}async function $g(D,F){let $=F?`?status=${F}`:"";return y(`/datasets/${D}/access-requests${$}`,{},!0)}async function Jg(D,F){return y(`/datasets/${D}/access-requests/${F}/approve`,{method:"POST"},!0)}async function Qg(D,F){return y(`/datasets/${D}/access-requests/${F}/deny`,{method:"POST"},!0)}async function Yg(D,F){return y(`/datasets/${D}/invite`,{method:"POST",body:JSON.stringify({username:F})},!0)}async function Bg(D){return y(`/datasets/${D}/collaborators`,{},!0)}async function Xg(D){return y("/sandbox/complete",{method:"POST",body:JSON.stringify({dataset_id:D})},!0)}async function Gg(){return y("/sandbox/reset",{method:"POST"},!0)}async function Wg(){return y("/sandbox/status",{},!0)}async function HQ(D){return y(`/datasets/${D}/publish/request`,{method:"POST"},!0)}async function Hg(D){return y(`/datasets/${D}/publish/status`,{},!0)}async function qg(D){return y(`/datasets/${D}/publish/resend`,{method:"POST"},!0)}async function Kg(D){let F=D?`?status=${D}`:"";return y(`/admin/publish/requests${F}`,{},!0)}async function zg(D,F){return y(`/admin/publish/${D}/deny`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({reason:F})},!0)}function _E0(D,F=[]){if(D){let $=x9.indexOf(D);if($>=0)return $+1}return Math.min(F.length+1,x9.length)}function fE0(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,q=0,K=!1,V,z=F,Z=[],L;function M(A,N,j,S){if(!Y)return;Y({step:A,stepIndex:_E0(A,N),stepTotal:x9.length,s3LockLocked:j,s3LockTotal:S,s3LockResumed:A==="s3_lock"&&K?!0:void 0})}for(let A=1;A<=5;A++)try{let N,j=!0;do{if(N=await y(`/admin/publish/${D}/approve`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({resume:j?z:!0,sandbox:$,s3_lock_continuation_token:G,s3_lock_total:H,skip_ci_check:J})},!0),j=!1,N.step_results)Z.push(...N.step_results);if(N.s3_lock_total!==void 0)H=N.s3_lock_total;if(N.s3_lock_batch_count!==void 0)q+=N.s3_lock_batch_count;let S=N.step??N.step_results?.[N.step_results.length-1]?.step;if(S&&(S!==V||S==="s3_lock"))M(S,N.steps_completed??[],S==="s3_lock"?q:void 0,S==="s3_lock"?H:void 0),V=S;if(N.hasMore&&N.s3_lock_continuation_token!==void 0)G=N.s3_lock_continuation_token;else break}while(N.hasMore);if(Z.length>0)N.step_results=_f(Z);return N}catch(N){if(L=N,A===5||!fE0(N)){if(N instanceof _&&Z.length>0)N.stepResults=_f(Z);throw N}let S=N;if(Q?.({attempt:A,maxAttempts:5,delayMs:1e4,step:S.step,error:S.message}),await new Promise((O)=>setTimeout(O,1e4)),z=!0,G!==void 0)K=!0}throw L}function _f(D){let F=new Map;for(let $ of D)F.set($.step,$);return Array.from(F.values())}async function Eg(D,F){return y(`/admin/datasets/${D}/enrichment`,{method:"POST",body:JSON.stringify(F)},!0)}async function Vg(D){return y(`/admin/datasets/${D}/files`,{},!0)}async function Zg(D){let F,$=0,J=[],Q=!0;while(Q){let Y=await y(`/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}}async function Ug(D){return y(`/admin/datasets/${D}/reset`,{method:"POST"},!0)}async function Lg(D,F=!1){return y(`/admin/datasets/${D}`,{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({force:F})},!0)}async function Ag(D){return y("/admin/datasets/bulk-delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({dataset_ids:D})},!0)}async function Mg(D){return y("/admin/datasets/import",{method:"POST",body:JSON.stringify(D)},!0)}async function Ng(D){return y(`/admin/datasets/${D}/sync`,{method:"POST"},!0)}async function Rg(){return y("/admin/sync/status",{},!0)}async function KQ(D,F){return y(`/admin/datasets/${D}/reindex`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(F??{})},!0)}async function Cg(D,F){return y("/admin/datasets/reindex/bulk",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filter:D,...F??{}})},!0)}async function Og(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 y(`/admin/fleet/drift${$}`,{},!0)}async function vF(D,F){return y(`/admin/datasets/${D}/enforce`,{method:"POST",body:JSON.stringify({dry_run:F})},!0)}async function jg(D){return y("/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 wg(D,F=!1){return y(`/admin/datasets/${D}/revalidate${F?"?force=true":""}`,{method:"POST"},!0)}async function Tg(){return y("/admin/email-preferences",{},!0)}async function Pg(D){return y("/admin/email-preferences",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(D)},!0)}async function Ig(){return y("/notices",{},"optional")}async function Sg(){return y("/admin/notices",{},!0)}async function kg(D){return y("/admin/notices",{method:"POST",body:JSON.stringify(D)},!0)}async function vg(D){return y(`/admin/notices/${D}`,{method:"DELETE"},!0)}async function uW(D){return y("/admin/notify",{method:"POST",body:JSON.stringify(D)},!0)}async function yg(){return y("/admin/summary/coverage",{},!0)}async function xg(D,F,$){return y("/admin/manifest/dispatch",{method:"POST",body:JSON.stringify({dataset_id:D,version:F,skip_canary:$?.skipCanary??!1})},!0)}var yW="https://nemar-api-dev.sccn-org.workers.dev",$Q,_,JQ,xW,x9;var s8=P(()=>{f4();vW();FQ();$Q=/^\d{4}-\d{4}-\d{4}-\d{3}[\dX]$/;_=class _ extends Error{statusCode;details;step;constructor(D,F,$,J){super(F);this.statusCode=D;this.details=$;this.step=J;this.name="ApiError"}};JQ=class JQ extends _{mode;eta;constructor(D,F,$,J){super(503,F,J);this.mode=D;this.eta=$;this.name="MaintenanceError"}};xW=yW.includes("workers.dev");x9=["ci_check","enrichment_check","repo_public","s3_public_read","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"]});function gg(D){lW=D}function pW(){return lW}function f9(D){if(lW)process.stderr.write(`${D}
98
+ `)}var kf=!1;var vW=P(()=>{jD()});var yf;var vf=P(()=>{yf={name:"nemar-cli",version:"0.8.53-dev.1394",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 g4;var FQ=P(()=>{vf();g4=yf.version});function C0(D){if(D instanceof Error)return D.message;return String(D)}function xf(){if(process.env.TEST_API_URL)return process.env.TEST_API_URL;if(xW)return yW;return BD().apiUrl||yW}async function y(D,F={},$=!1){let J=`${xf()}${D}`,Q={"Content-Type":"application/json","X-CLI-Version":g4,...F.headers};if($){let X=BD();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 ${xf()}`,{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 JQ(B.mode,X,G,B.details);throw DQ(H),H}throw new _(Y.status,B.error||B.message||"Request failed",B.details,typeof B.step==="string"?B.step:void 0)}return B}async function ff(D){return y(`/auth/check-username?username=${encodeURIComponent(D)}`)}async function gf(D){return y(`/auth/check-github?username=${encodeURIComponent(D)}`)}async function hf(D){return y("/auth/signup",{method:"POST",body:JSON.stringify(D)})}async function bf(D){return y("/auth/login",{method:"POST",body:JSON.stringify({api_key:D})})}async function uf(D){return y("/auth/resend-verification",{method:"POST",body:JSON.stringify({email:D})})}async function mf(D,F){return y("/auth/retrieve-key",{method:"POST",body:JSON.stringify({email:D,password:F})})}async function lf(D){return y("/auth/request-key-regeneration",{method:"POST",body:JSON.stringify({email:D})})}async function QQ(){return y("/users/me",{},!0)}async function pf(D,F){let $=new URLSearchParams;if(D)$.set("status",D);if(F)$.set("role",F);let J=$.toString()?`?${$.toString()}`:"";return y(`/admin/users${J}`,{},!0)}async function df(D){return y(`/admin/approve/${D}`,{method:"POST"},!0)}async function cf(D){return y(`/admin/revoke/${D}`,{method:"POST"},!0)}async function nf(D,F){return y(`/admin/users/${D}/role`,{method:"POST",body:JSON.stringify({role:F})},!0)}async function _W(D,F){return y(`/admin/datasets/${D}/visibility`,{method:"PATCH",body:JSON.stringify({visibility:F})},!0)}async function af(D){return y(`/datasets/${D}/publish`,{method:"POST"},!0)}async function of(D){return y(`/admin/datasets/${D}/ci`,{},!0)}async function h4(D){return y(`/admin/datasets/${D}/ci`,{method:"POST"},!0)}async function fW(D){return y(`/admin/datasets/${D}/ci/validate`,{method:"POST"},!0)}async function gW(D){return y(`/admin/datasets/${D}/ci/sync`,{method:"POST"},!0)}async function YQ(D){return y(`/datasets/${D}/ci/status`,{},!0)}async function sf(D){return y(`/datasets/${D}/manifest`,{},!0)}async function BQ(D,F){return y(`/datasets/${D}/manifest/${F}`,{},!0)}function rf(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 kF(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.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 y(`/datasets${$}`,{},D.mine?!0:"optional");return J.datasets=J.datasets.map(rf),J}async function tf(D){return y(`/datasets/resolve/${D}`,{},"optional")}async function ef(D,F={}){let $=new URLSearchParams({q:D});if(F.modality)$.set("modality",F.modality);if(F.limit)$.set("limit",String(F.limit));return y(`/datasets/search?${$.toString()}`,{},"optional")}async function uD(D){let F=await y(`/datasets/${D}`,{},"optional");return rf(F.dataset)}async function Dg(D){return y(`/datasets/${D}/versions`,{},!0)}async function XQ(D){return y("/datasets",{method:"POST",body:JSON.stringify(D)},!0)}async function GQ(D){return y(`/datasets/${D}/finalize`,{method:"POST"},!0)}async function o8(D,F){return y(`/datasets/${D}/upload-credentials`,{method:"POST",body:JSON.stringify({duration_seconds:F})},!0)}async function WQ(D,F){return y(`/datasets/${D}/download-credentials`,{method:"POST",body:JSON.stringify({duration_seconds:F})},!0)}async function Fg(D,F){return y(`/admin/datasets/${D}/doi/concept`,{method:"POST",body:JSON.stringify(F)},!0)}async function _9(D){return y(`/admin/datasets/${D}/doi`,{},!0)}async function hW(D,F){return y(`/admin/datasets/${D}/doi/update`,{method:"POST",body:JSON.stringify(F)},!0)}async function bW(D){return y(`/datasets/${D}/request-access`,{method:"POST"},!0)}async function $g(D,F){let $=F?`?status=${F}`:"";return y(`/datasets/${D}/access-requests${$}`,{},!0)}async function Jg(D,F){return y(`/datasets/${D}/access-requests/${F}/approve`,{method:"POST"},!0)}async function Qg(D,F){return y(`/datasets/${D}/access-requests/${F}/deny`,{method:"POST"},!0)}async function Yg(D,F){return y(`/datasets/${D}/invite`,{method:"POST",body:JSON.stringify({username:F})},!0)}async function Bg(D){return y(`/datasets/${D}/collaborators`,{},!0)}async function Xg(D){return y("/sandbox/complete",{method:"POST",body:JSON.stringify({dataset_id:D})},!0)}async function Gg(){return y("/sandbox/reset",{method:"POST"},!0)}async function Wg(){return y("/sandbox/status",{},!0)}async function HQ(D){return y(`/datasets/${D}/publish/request`,{method:"POST"},!0)}async function Hg(D){return y(`/datasets/${D}/publish/status`,{},!0)}async function qg(D){return y(`/datasets/${D}/publish/resend`,{method:"POST"},!0)}async function Kg(D){let F=D?`?status=${D}`:"";return y(`/admin/publish/requests${F}`,{},!0)}async function zg(D,F){return y(`/admin/publish/${D}/deny`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({reason:F})},!0)}function _E0(D,F=[]){if(D){let $=x9.indexOf(D);if($>=0)return $+1}return Math.min(F.length+1,x9.length)}function fE0(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,q=0,K=!1,V,z=F,Z=[],L;function M(A,N,j,S){if(!Y)return;Y({step:A,stepIndex:_E0(A,N),stepTotal:x9.length,s3LockLocked:j,s3LockTotal:S,s3LockResumed:A==="s3_lock"&&K?!0:void 0})}for(let A=1;A<=5;A++)try{let N,j=!0;do{if(N=await y(`/admin/publish/${D}/approve`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({resume:j?z:!0,sandbox:$,s3_lock_continuation_token:G,s3_lock_total:H,skip_ci_check:J})},!0),j=!1,N.step_results)Z.push(...N.step_results);if(N.s3_lock_total!==void 0)H=N.s3_lock_total;if(N.s3_lock_batch_count!==void 0)q+=N.s3_lock_batch_count;let S=N.step??N.step_results?.[N.step_results.length-1]?.step;if(S&&(S!==V||S==="s3_lock"))M(S,N.steps_completed??[],S==="s3_lock"?q:void 0,S==="s3_lock"?H:void 0),V=S;if(N.hasMore&&N.s3_lock_continuation_token!==void 0)G=N.s3_lock_continuation_token;else break}while(N.hasMore);if(Z.length>0)N.step_results=_f(Z);return N}catch(N){if(L=N,A===5||!fE0(N)){if(N instanceof _&&Z.length>0)N.stepResults=_f(Z);throw N}let S=N;if(Q?.({attempt:A,maxAttempts:5,delayMs:1e4,step:S.step,error:S.message}),await new Promise((O)=>setTimeout(O,1e4)),z=!0,G!==void 0)K=!0}throw L}function _f(D){let F=new Map;for(let $ of D)F.set($.step,$);return Array.from(F.values())}async function Eg(D,F){return y(`/admin/datasets/${D}/enrichment`,{method:"POST",body:JSON.stringify(F)},!0)}async function Vg(D){return y(`/admin/datasets/${D}/files`,{},!0)}async function Zg(D){let F,$=0,J=[],Q=!0;while(Q){let Y=await y(`/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}}async function Ug(D){return y(`/admin/datasets/${D}/reset`,{method:"POST"},!0)}async function Lg(D,F=!1){return y(`/admin/datasets/${D}`,{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({force:F})},!0)}async function Ag(D){return y("/admin/datasets/bulk-delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({dataset_ids:D})},!0)}async function Mg(D){return y("/admin/datasets/import",{method:"POST",body:JSON.stringify(D)},!0)}async function Ng(D){return y(`/admin/datasets/${D}/sync`,{method:"POST"},!0)}async function Rg(){return y("/admin/sync/status",{},!0)}async function KQ(D,F){return y(`/admin/datasets/${D}/reindex`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(F??{})},!0)}async function Cg(D,F){return y("/admin/datasets/reindex/bulk",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filter:D,...F??{}})},!0)}async function Og(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 y(`/admin/fleet/drift${$}`,{},!0)}async function vF(D,F){return y(`/admin/datasets/${D}/enforce`,{method:"POST",body:JSON.stringify({dry_run:F})},!0)}async function jg(D){return y("/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 wg(D,F=!1){return y(`/admin/datasets/${D}/revalidate${F?"?force=true":""}`,{method:"POST"},!0)}async function Tg(){return y("/admin/email-preferences",{},!0)}async function Pg(D){return y("/admin/email-preferences",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(D)},!0)}async function Ig(){return y("/notices",{},"optional")}async function Sg(){return y("/admin/notices",{},!0)}async function kg(D){return y("/admin/notices",{method:"POST",body:JSON.stringify(D)},!0)}async function vg(D){return y(`/admin/notices/${D}`,{method:"DELETE"},!0)}async function uW(D){return y("/admin/notify",{method:"POST",body:JSON.stringify(D)},!0)}async function yg(){return y("/admin/summary/coverage",{},!0)}async function xg(D,F,$){return y("/admin/manifest/dispatch",{method:"POST",body:JSON.stringify({dataset_id:D,version:F,skip_canary:$?.skipCanary??!1})},!0)}var yW="https://nemar-api-dev.sccn-org.workers.dev",$Q,_,JQ,xW,x9;var s8=P(()=>{f4();vW();FQ();$Q=/^\d{4}-\d{4}-\d{4}-\d{3}[\dX]$/;_=class _ extends Error{statusCode;details;step;constructor(D,F,$,J){super(F);this.statusCode=D;this.details=$;this.step=J;this.name="ApiError"}};JQ=class JQ extends _{mode;eta;constructor(D,F,$,J){super(503,F,J);this.mode=D;this.eta=$;this.name="MaintenanceError"}};xW=yW.includes("workers.dev");x9=["ci_check","enrichment_check","repo_public","s3_public_read","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"]});function gg(D){lW=D}function pW(){return lW}function f9(D){if(lW)process.stderr.write(`${D}
99
99
  `)}var lW=!1;function GD(D){if(D===0)return"0 B";let F=["B","KB","MB","GB","TB"],$=Math.min(Math.floor(Math.log(D)/Math.log(1024)),F.length-1);return`${(D/1024**$).toFixed($===0?0:1)} ${F[$]}`}function hg(D){return`${GD(D)}/s`}function gE0(D){if(D<60)return`${Math.round(D)}s`;if(D<3600)return`${Math.floor(D/60)}m ${Math.round(D%60)}s`;return`${Math.floor(D/3600)}h ${Math.floor(D%3600/60)}m`}function hE0(D,F=20){let $=Math.round(D/100*F),J=F-$;return`[${"=".repeat($)}${" ".repeat(J)}]`}class zQ{filesCompleted=0;filesTotal;bytesTotal=0;inFlight=new Map;currentFile="";startTime;lastUpdateTime;lastBytesTransferred=0;totalBytesTransferred=0;speedSamples=[];lastRenderedLine="";constructor(D=0,F=0){this.filesTotal=D,this.bytesTotal=F,this.startTime=Date.now(),this.lastUpdateTime=this.startTime}inFlightBytes(){let D=0;for(let F of this.inFlight.values())D+=F.transferred;return D}processLine(D){let F=D.file??D.action?.file;if(D.ok===!0||D.success===!0){this.filesCompleted++;let $=F??this.currentFile,J=$?this.inFlight.get($):void 0,Q=J?J.total||J.transferred:0;if(this.totalBytesTransferred+=Q,$)this.inFlight.delete($);this.render();return}if(D["byte-progress"]!==void 0){let $=F??this.currentFile;if(!$)return;this.currentFile=$;let J=this.inFlight.get($)??{transferred:0,total:0};if(J.transferred=D["byte-progress"]??J.transferred,D["total-size"]!==void 0)J.total=D["total-size"];this.inFlight.set($,J);let Q=Date.now(),Y=(Q-this.lastUpdateTime)/1000;if(Y>0.5){let B=this.totalBytesTransferred+this.inFlightBytes(),G=(B-this.lastBytesTransferred)/Y;if(G>0){if(this.speedSamples.push(G),this.speedSamples.length>5)this.speedSamples.shift()}this.lastBytesTransferred=B,this.lastUpdateTime=Q}this.render()}}incrementFilesCompleted(){this.filesCompleted++}setFilesTotal(D){this.filesTotal=D}setBytesTotal(D){this.bytesTotal=D}getPercent(){let D=this.totalBytesTransferred+this.inFlightBytes();if(this.bytesTotal>0)return Math.min(100,Math.round(D/this.bytesTotal*100));if(this.filesTotal>0)return Math.min(100,Math.round(this.filesCompleted/this.filesTotal*100));return null}getProgress(){return{filesCompleted:this.filesCompleted,filesTotal:this.filesTotal,bytesTransferred:this.totalBytesTransferred+this.inFlightBytes(),bytesTotal:this.bytesTotal,currentFile:this.currentFile||void 0}}render(){let D=this.speedSamples.length>0?this.speedSamples.reduce((B,X)=>B+X,0)/this.speedSamples.length:0,F=this.totalBytesTransferred+this.inFlightBytes(),$=0,J=!1;if(this.bytesTotal>0)$=Math.min(100,Math.round(F/this.bytesTotal*100)),J=!0;else if(this.filesTotal>0)$=Math.min(100,Math.round(this.filesCompleted/this.filesTotal*100)),J=!0;let Q=this.filesTotal>0?`${this.filesCompleted}/${this.filesTotal} files`:`${this.filesCompleted} files`,Y;if(J)Y=`${hE0($)} ${$}% ${Q}`;else Y=Q;if(F>0){let B=this.bytesTotal>0?`${GD(F)}/${GD(this.bytesTotal)}`:GD(F);Y+=` | ${B}`}if(D>0)Y+=` | ${hg(D)}`;if(D>0){let B=0;if(this.bytesTotal>0)B=Math.max(0,this.bytesTotal-F);else for(let X of this.inFlight.values())if(X.total>X.transferred)B+=X.total-X.transferred;if(B>0){let X=B/D;if(X>0)Y+=` | ETA ${gE0(X)}`}}if(Y!==this.lastRenderedLine)process.stderr.write(`\r${W.cyan(Y)}${" ".repeat(10)}`),this.lastRenderedLine=Y}finish(D){let F=(Date.now()-this.startTime)/1000;if(process.stderr.write(`\r${" ".repeat(this.lastRenderedLine.length+15)}\r`),D>0){let $=F>0?`${hg(this.totalBytesTransferred/F)}`:"",J=[`${D} file${D!==1?"s":""} downloaded`,this.totalBytesTransferred>0?GD(this.totalBytesTransferred):"",$].filter(Boolean).join(" | ");process.stderr.write(`${W.green(J)}
100
100
  `)}}}var dW=P(()=>{jD()});var rg={};a4(rg,{verifyGitHubAuth:()=>h9,toS3Credentials:()=>CD,switchBranch:()=>aE0,setKeyPresent:()=>sg,selectAnnexS3Remote:()=>tW,saveDataset:()=>t8,runCommand:()=>I,resolveUpstreamRef:()=>BH,readRemoteHeadDatasetVersion:()=>YH,readLocalDatasetVersion:()=>QH,pushToGitHub:()=>r1,pushBranch:()=>xF,markInheritedOpenNeuroRemotesIgnored:()=>rW,listDatasetVersions:()=>DH,isWorkingTreeDirty:()=>XH,isGitAnnexDataset:()=>j1,isDataladDataset:()=>eE0,initOrEnableSpecialRemote:()=>ig,initDataset:()=>o6,gitMergeFastForward:()=>WH,gitFetchOrigin:()=>GH,gitAnnexAdd:()=>s6,getVersionCommit:()=>FH,getRemoteUuid:()=>zH,getLocalDatasetInfo:()=>eW,getKeyHashDirs:()=>rE0,getKeyHashDir:()=>og,getDatasetStats:()=>cE0,getDatasetIdFromRemote:()=>D6,getDatasetData:()=>UQ,getCurrentBranch:()=>e8,getAnnexWhereisAll:()=>KH,getAnnexS3Remotes:()=>u9,formatBytes:()=>GD,ensureLocalMainBranch:()=>m9,ensureGitAnnexInitialized:()=>oW,enableS3Remote:()=>u4,dropUnusedAnnexObjects:()=>HH,dropFiles:()=>sW,detectImportMarker:()=>ZQ,createRevertBranch:()=>$H,createDataladDataset:()=>tE0,countPendingDownload:()=>VQ,copyToAnnexRemote:()=>T8,configureS3Remote:()=>w8,configureLargefiles:()=>b4,configureGitHubRemote:()=>r8,commitRevert:()=>JH,collectFileManifest:()=>qH,cloneDataset:()=>t1,clearAnnexCredentials:()=>vD,checkPrerequisites:()=>g9,checkGitHubSSH:()=>pg,checkGitAnnexInstalled:()=>aW,checkDownloadPrerequisites:()=>yF,checkAWSCredentials:()=>lE0,batchSetKeysPresent:()=>EH,annexRemoteExists:()=>ng,acceptGitHubInvitation:()=>b9,NEMAR_S3_REMOTE_NAME:()=>EQ,ANNEX_REMOTE_EXISTS_RE:()=>cg});import{existsSync as nW,readFileSync as bE0,statSync as uE0}from"fs";import{join as iW}from"path";var{spawn:lg}=globalThis.Bun;async function I(D,F={}){let $=lg({cmd:D,cwd:F.cwd,stdout:"pipe",stderr:"pipe",env:{...process.env,GIT_TERMINAL_PROMPT:"0",...F.env}}),J=!1,Q;if(F.timeout)Q=setTimeout(()=>{J=!0,$.kill()},F.timeout);if(pW()){let G=F.cwd?` (cwd=${F.cwd})`:"";f9(W.dim(`$ ${D.join(" ")}${G}`))}let Y=await new Response($.stdout).text(),B=await new Response($.stderr).text(),X=await $.exited;if(Q)clearTimeout(Q);if(pW()){if(Y.trim())f9(W.dim(Y.trimEnd()));if(B.trim())f9(W.yellow(B.trimEnd()));f9(W.dim(`(exit ${X})`))}if(J)return{stdout:Y,stderr:B||`Command timed out after ${Math.round(F.timeout/1000)}s`,exitCode:X??1};return{stdout:Y,stderr:B,exitCode:X}}function bg(D){return D.split(".").map((F)=>{let $=Number.parseInt(F.replace(/[^0-9]/g,""),10);return Number.isNaN($)?0:$})}function mE0(D,F){let $=bg(D),J=bg(F);for(let Q=0;Q<Math.max($.length,J.length);Q++){let Y=$[Q]||0,B=J[Q]||0;if(Y>B)return!0;if(Y<B)return!1}return!0}async function aW(){try{let{stdout:F,exitCode:$,stderr:J}=await I(["git-annex","version"]);if($!==0)return console.warn("git-annex version returned non-zero exit code:",$),console.warn("stderr:",J),{installed:!1,minVersion:"10.0",error:`Version check failed: ${J.trim()}`};let Q=F.match(/version:\s*(\d+\.\d+)/),Y=Q?Q[1]:void 0;if(!Y)console.warn("Could not parse git-annex version from output:",F);return{installed:!0,version:Y,minVersion:"10.0",compatible:Y?mE0(Y,"10.0"):void 0}}catch(F){let $=F instanceof Error?F.message:String(F);if($.includes("ENOENT")||$.includes("not found"))return console.info("git-annex not found in PATH"),{installed:!1,minVersion:"10.0"};return console.error("Error checking git-annex installation:",$),{installed:!1,minVersion:"10.0",error:$}}}async function pg(){if(process.env.GH_TOKEN)return{accessible:!0,username:"token-auth",useHttps:!0};try{let{stdout:D,stderr:F}=await I(["ssh","-T","-o","BatchMode=yes","-o","StrictHostKeyChecking=accept-new","-o","ConnectTimeout=10","git@github.com"]),$=D+F,J=$.match(/Hi ([^!]+)!/);if(J)return{accessible:!0,username:J[1]};if($.includes("Permission denied"))return{accessible:!1};return{accessible:$.includes("successfully authenticated")}}catch(D){let F=D instanceof Error?D.message:String(D);if(F.includes("ENOENT")||F.includes("not found"))console.info("SSH command not found");else console.error("Error checking GitHub SSH access:",F);return{accessible:!1}}}async function lE0(){if(process.env.AWS_ACCESS_KEY_ID&&process.env.AWS_SECRET_ACCESS_KEY)return{configured:!0,source:"environment"};try{let{stdout:D,exitCode:F}=await I(["aws","configure","get","aws_access_key_id"]);if(F===0&&D.trim())return{configured:!0,source:"aws-cli"}}catch(D){let F=D instanceof Error?D.message:String(D);if(F.includes("ENOENT")||F.includes("not found"))console.info("AWS CLI not found in PATH");else console.error("Error checking AWS credentials:",F)}return{configured:!1}}function dg(){let D=process.platform;if(D==="darwin")return"brew install git-annex";if(D==="linux")return"apt install git-annex (Debian/Ubuntu)";return"See https://git-annex.branchable.com/install/"}async function g9(){let[D,F]=await Promise.all([aW(),pg()]),$=[];if(!D.installed)$.push(`git-annex is not installed. Install: ${dg()}`);else if(D.compatible===!1)$.push(`git-annex version ${D.version} is too old. Required: >= ${D.minVersion}`);if(!F.accessible){if(!(await ag()).token)$.push("GitHub authentication not configured. Run 'gh auth login' to authenticate.")}return{gitAnnex:D,githubSSH:F,allPassed:$.length===0,errors:$}}async function j1(D){if(!nW(iW(D,".git")))return!1;try{let{exitCode:F}=await I(["git","annex","info"],{cwd:D});return F===0}catch(F){let $=F instanceof Error?F.message:String(F);if(!$.includes("ENOENT")&&!$.includes("not found"))console.error(`Error checking if ${D} is a git-annex dataset:`,$);return!1}}async function o6(D,F={}){if(!F.force&&await j1(D))return{success:!0};try{let $={};if(F.author)$.GIT_AUTHOR_NAME=F.author.name,$.GIT_AUTHOR_EMAIL=F.author.email,$.GIT_COMMITTER_NAME=F.author.name,$.GIT_COMMITTER_EMAIL=F.author.email;let{stderr:J,exitCode:Q}=await I(["git","init","-b","main",D],{...Object.keys($).length>0?{env:$}:{}});if(Q!==0)return{success:!1,error:J.trim()||"Failed to initialize git repository"};let Y=Object.keys($).length>0?{env:$}:{},{stderr:B,exitCode:X}=await I(["git","annex","init"],{cwd:D,...Y});if(X!==0)return{success:!1,error:B.trim()||"Failed to initialize git-annex"};let{stderr:G,exitCode:H}=await I(["git","commit","--allow-empty","-m","Initialize dataset"],{cwd:D,...Y});if(H!==0)return{success:!1,error:G.trim()||"Failed to create initial commit"};let{stderr:q,exitCode:K}=await I(["git","annex","adjust","--unlock"],{cwd:D,...Y});if(K!==0)return{success:!1,error:q.trim()||"Failed to switch to unlocked mode"};return{success:!0}}catch($){return{success:!1,error:$.message}}}async function oW(D){try{let{exitCode:F,stderr:$}=await I(["git","annex","info"],{cwd:D});if(F===0)return{success:!0};if($.includes("First run: git-annex init")){let{stderr:J,exitCode:Q}=await I(["git","annex","init"],{cwd:D});if(Q!==0)return{success:!1,error:J.trim()||"Failed to initialize git-annex"};return{success:!0}}return{success:!1,error:$.trim()||"Failed to check git-annex status"}}catch(F){return{success:!1,error:F.message}}}async function b4(D,F){let $=["*.edf","*.bdf","*.set","*.fif","*.vhdr","*.eeg","*.cnt","*.fdt"],J=["*.tsv","*.json","*.md","*.txt","*.yml","*.yaml","README*","LICENSE*","CHANGES*",".bidsignore",".gitignore"],Q=$.map((G)=>`include=${G}`).join(" or "),Y=J.map((G)=>`exclude=${G}`).join(" and "),B=`(${Q} or largerthan=100kb) and ${Y}`,X=F||B;try{let{stderr:G,exitCode:H}=await I(["git","annex","config","--set","annex.largefiles",X],{cwd:D});if(H!==0)return{success:!1,error:G.trim()||"Failed to configure largefiles"};return{success:!0}}catch(G){return{success:!1,error:G.message}}}async function s6(D,F="."){try{let{stderr:$,exitCode:J}=await I(["git","annex","add",F],{cwd:D});if(J!==0)return{success:!1,error:$.trim()||"Failed to add files to git-annex"};return{success:!0}}catch($){return{success:!1,error:$.message}}}function CD(D){return{accessKeyId:D.access_key_id,secretAccessKey:D.secret_access_key,sessionToken:D.session_token}}function cW(D){let F=[/^\(merging .* into .*\.\.\.\)$/,/^\(recording state in git\.\.\.\)$/,/^\(scanning for /,/^\(checking /];return D.split(`
101
101
  `).filter(($)=>{let J=$.trim();if(!J)return!1;if(J.includes("setting annex-ignore"))return!1;if(F.some((Q)=>Q.test(J)))return!1;return!0}).join(`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nemar-cli",
3
- "version": "0.8.53-dev.1381",
3
+ "version": "0.8.53-dev.1394",
4
4
  "description": "CLI for NEMAR (Neuroelectromagnetic Data Archive and Tools Resource) dataset management",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",