nemar-cli 0.8.73-PR876.449f6ec → 0.8.73-PR877.fbd19b5

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 +5 -5
  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 df=!1;var vW=S(()=>{ND()});var nf;var cf=S(()=>{nf={name:"nemar-cli",version:"0.8.73-PR876.449f6ec",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 _4;var DQ=S(()=>{cf();_4=nf.version});function L0(D){if(D instanceof Error)return D.message;return String(D)}function af(){if(process.env.TEST_API_URL)return process.env.TEST_API_URL;if(xW)return yW;return $D().apiUrl||yW}async function x(D,F={},$=!1){let J=`${af()}${D}`,Q={"Content-Type":"application/json","X-CLI-Version":_4,...F.headers};if($){let X=$D();if(!X.apiKey&&$===!0)throw new f(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 f(0,`Network error: Could not connect to ${af()}`,{originalError:X instanceof Error?X.message:String(X)})}let B;try{B=await Y.json()}catch{throw new f(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 TF(B.mode,X,G,B.details);throw eJ(H),H}throw new f(Y.status,B.error||B.message||"Request failed",B.details,typeof B.step==="string"?B.step:void 0)}return B}async function sf(D){return x(`/auth/check-username?username=${encodeURIComponent(D)}`)}async function rf(D){return x(`/auth/check-github?username=${encodeURIComponent(D)}`)}async function tf(D){return x("/auth/signup",{method:"POST",body:JSON.stringify(D)})}async function _W(D){return x("/auth/login",{method:"POST",body:JSON.stringify({api_key:D})})}async function ef(D){return x("/auth/resend-verification",{method:"POST",body:JSON.stringify({email:D})})}async function Dg(D,F){return x("/auth/retrieve-key",{method:"POST",body:JSON.stringify({email:D,password:F})})}async function Fg(D){return x("/auth/request-key-regeneration",{method:"POST",body:JSON.stringify({email:D})})}async function $Q(){return x("/users/me",{},!0)}async function $g(D,F){let $=new URLSearchParams;if(D)$.set("status",D);if(F)$.set("role",F);let J=$.toString()?`?${$.toString()}`:"";return x(`/admin/users${J}`,{},!0)}async function Jg(D){return x(`/admin/approve/${D}`,{method:"POST"},!0)}async function Qg(D){return x(`/admin/revoke/${D}`,{method:"POST"},!0)}async function Yg(D,F){return x(`/admin/users/${D}/role`,{method:"POST",body:JSON.stringify({role:F})},!0)}async function fW(D,F){return x(`/admin/datasets/${D}/visibility`,{method:"PATCH",body:JSON.stringify({visibility:F})},!0)}async function Bg(D){return x(`/datasets/${D}/publish`,{method:"POST"},!0)}async function Xg(D){return x(`/admin/datasets/${D}/ci`,{},!0)}async function f4(D){return x(`/admin/datasets/${D}/ci`,{method:"POST"},!0)}async function gW(D){return x(`/admin/datasets/${D}/ci/validate`,{method:"POST"},!0)}async function hW(D){return x(`/admin/datasets/${D}/ci/sync`,{method:"POST"},!0)}async function JQ(D){return x(`/datasets/${D}/ci/status`,{},!0)}async function Gg(D){return x(`/datasets/${D}/manifest`,{},!0)}async function QQ(D,F){return x(`/datasets/${D}/manifest/${F}`,{},!0)}function Wg(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 PF(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 x(`/datasets${$}`,{},D.mine?!0:"optional");return J.datasets=J.datasets.map(Wg),J}async function Hg(D){return x(`/datasets/resolve/${D}`,{},"optional")}async function qg(D,F={}){let $=new URLSearchParams({q:D});if(F.modality)$.set("modality",F.modality);if(F.limit)$.set("limit",String(F.limit));return x(`/datasets/search?${$.toString()}`,{},"optional")}async function gD(D){let F=await x(`/datasets/${D}`,{},"optional");return Wg(F.dataset)}async function Kg(D){return x(`/datasets/${D}/versions`,{},!0)}async function YQ(D){return x("/datasets",{method:"POST",body:JSON.stringify(D)},!0)}async function BQ(D){return x(`/datasets/${D}/finalize`,{method:"POST"},!0)}async function c8(D,F){return x(`/datasets/${D}/upload-credentials`,{method:"POST",body:JSON.stringify({duration_seconds:F})},!0)}async function bW(D,F){return x(`/datasets/${D}/download-credentials`,{method:"POST",body:JSON.stringify({duration_seconds:F})},!0)}async function zg(D,F){return x(`/admin/datasets/${D}/doi/concept`,{method:"POST",body:JSON.stringify(F)},!0)}async function y9(D){return x(`/admin/datasets/${D}/doi`,{},!0)}async function uW(D,F){return x(`/admin/datasets/${D}/doi/update`,{method:"POST",body:JSON.stringify(F)},!0)}async function mW(D){return x(`/datasets/${D}/request-access`,{method:"POST"},!0)}async function Eg(D,F){let $=F?`?status=${F}`:"";return x(`/datasets/${D}/access-requests${$}`,{},!0)}async function Vg(D,F){return x(`/datasets/${D}/access-requests/${F}/approve`,{method:"POST"},!0)}async function Zg(D,F){return x(`/datasets/${D}/access-requests/${F}/deny`,{method:"POST"},!0)}async function Ug(D,F){return x(`/datasets/${D}/invite`,{method:"POST",body:JSON.stringify({username:F})},!0)}async function Lg(D){return x(`/datasets/${D}/collaborators`,{},!0)}async function Ag(D){return x("/sandbox/complete",{method:"POST",body:JSON.stringify({dataset_id:D})},!0)}async function Mg(){return x("/sandbox/reset",{method:"POST"},!0)}async function Ng(){return x("/sandbox/status",{},!0)}async function XQ(D){return x(`/datasets/${D}/publish/request`,{method:"POST"},!0)}async function Rg(D){return x(`/datasets/${D}/publish/status`,{},!0)}async function Cg(D){return x(`/datasets/${D}/publish/resend`,{method:"POST"},!0)}async function Og(D){let F=D?`?status=${D}`:"";return x(`/admin/publish/requests${F}`,{},!0)}async function jg(D,F){return x(`/admin/publish/${D}/deny`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({reason:F})},!0)}function WV0(D,F=[]){if(D){let $=v9.indexOf(D);if($>=0)return $+1}return Math.min(F.length+1,v9.length)}function HV0(D){if(!(D instanceof f))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 GQ(D,F=!1,$=!1,J=!1,Q,Y){let G,H,q=0,K=!1,V,z=F,Z=[],U;function M(A,C,j,I){if(!Y)return;Y({step:A,stepIndex:WV0(A,C),stepTotal:v9.length,s3LockLocked:j,s3LockTotal:I,s3LockResumed:A==="s3_lock"&&K?!0:void 0})}for(let A=1;A<=5;A++)try{let C,j=!0;do{if(C=await x(`/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,C.step_results)Z.push(...C.step_results);if(C.s3_lock_total!==void 0)H=C.s3_lock_total;if(C.s3_lock_batch_count!==void 0)q+=C.s3_lock_batch_count;let I=C.step??C.step_results?.[C.step_results.length-1]?.step;if(I&&(I!==V||I==="s3_lock"))M(I,C.steps_completed??[],I==="s3_lock"?q:void 0,I==="s3_lock"?H:void 0),V=I;if(C.hasMore&&C.s3_lock_continuation_token!==void 0)G=C.s3_lock_continuation_token;else break}while(C.hasMore);if(Z.length>0)C.step_results=of(Z);return C}catch(C){if(U=C,A===5||!HV0(C)){if(C instanceof f&&Z.length>0)C.stepResults=of(Z);throw C}let I=C;if(Q?.({attempt:A,maxAttempts:5,delayMs:1e4,step:I.step,error:I.message}),await new Promise((R)=>setTimeout(R,1e4)),z=!0,G!==void 0)K=!0}throw U}function of(D){let F=new Map;for(let $ of D)F.set($.step,$);return Array.from(F.values())}async function wg(D,F){return x(`/admin/datasets/${D}/enrichment`,{method:"POST",body:JSON.stringify(F)},!0)}async function Tg(D){return x(`/admin/datasets/${D}/files`,{},!0)}async function Pg(D){let F,$=0,J=[],Q=!0;while(Q){let Y=await x(`/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 f(500,"S3 lock paginated response missing continuation_token; aborting to avoid infinite loop")}return{locked:$,failed:J}}async function Ig(D){return x(`/admin/datasets/${D}/reset`,{method:"POST"},!0)}async function Sg(D,F=!1){return x(`/admin/datasets/${D}`,{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({force:F})},!0)}async function kg(D){return x("/admin/datasets/bulk-delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({dataset_ids:D})},!0)}async function vg(D){return x("/admin/datasets/import",{method:"POST",body:JSON.stringify(D)},!0)}async function yg(D){let F=D?`?status=${encodeURIComponent(D)}`:"";return x(`/admin/imports${F}`,{},!0)}async function xg(D){return x(`/admin/imports/${D}/rollback`,{method:"POST"},!0)}async function _g(D){return x(`/admin/imports/${D}/retry`,{method:"POST"},!0)}async function WQ(D,F){return x(`/admin/datasets/${D}/reindex`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(F??{})},!0)}async function fg(D,F){return x("/admin/datasets/reindex/bulk",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filter:D,...F??{}})},!0)}async function gg(D){let F=D?.limit??15;return x(`/admin/datasets/hed-sweep?limit=${encodeURIComponent(String(F))}`,{method:"POST",headers:{"Content-Type":"application/json"}},!0)}async function hg(){return x("/admin/datasets/hed-sweep?reset=1",{method:"POST",headers:{"Content-Type":"application/json"}},!0)}async function bg(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 x(`/admin/fleet/drift${$}`,{},!0)}async function IF(D,F){return x(`/admin/datasets/${D}/enforce`,{method:"POST",body:JSON.stringify({dry_run:F})},!0)}async function ug(D){return x("/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 mg(D,F=!1){return x(`/admin/datasets/${D}/revalidate${F?"?force=true":""}`,{method:"POST"},!0)}async function lg(D){let F=D?`?user=${encodeURIComponent(D)}`:"";return x(`/admin/email-preferences${F}`,{},!0)}async function pg(D,F){let $=F?`?user=${encodeURIComponent(F)}`:"";return x(`/admin/email-preferences${$}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(D)},!0)}async function dg(){return x("/notices",{},"optional")}async function cg(){return x("/admin/notices",{},!0)}async function ng(D){return x("/admin/notices",{method:"POST",body:JSON.stringify(D)},!0)}async function ig(D){return x(`/admin/notices/${D}`,{method:"DELETE"},!0)}async function lW(D){return x("/admin/notify",{method:"POST",body:JSON.stringify(D)},!0)}async function ag(){return x("/admin/summary/coverage",{},!0)}async function og(D,F,$){return x("/admin/manifest/dispatch",{method:"POST",body:JSON.stringify({dataset_id:D,version:F,skip_canary:$?.skipCanary??!1})},!0)}var yW="https://api.nemar.org",FQ,f,TF,xW,v9;var n8=S(()=>{x4();vW();DQ();FQ=/^\d{4}-\d{4}-\d{4}-\d{3}[\dX]$/;f=class f extends Error{statusCode;details;step;constructor(D,F,$,J){super(F);this.statusCode=D;this.details=$;this.step=J;this.name="ApiError"}};TF=class TF extends f{mode;eta;constructor(D,F,$,J){super(503,F,J);this.mode=D;this.eta=$;this.name="MaintenanceError"}};xW=yW.includes("workers.dev");v9=["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 tg(D){dW=D}function cW(){return dW}function x9(D){if(dW)process.stderr.write(`${D}
98
+ `)}var df=!1;var vW=S(()=>{ND()});var nf;var cf=S(()=>{nf={name:"nemar-cli",version:"0.8.73-PR877.fbd19b5",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 _4;var DQ=S(()=>{cf();_4=nf.version});function L0(D){if(D instanceof Error)return D.message;return String(D)}function af(){if(process.env.TEST_API_URL)return process.env.TEST_API_URL;if(xW)return yW;return $D().apiUrl||yW}async function x(D,F={},$=!1){let J=`${af()}${D}`,Q={"Content-Type":"application/json","X-CLI-Version":_4,...F.headers};if($){let X=$D();if(!X.apiKey&&$===!0)throw new f(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 f(0,`Network error: Could not connect to ${af()}`,{originalError:X instanceof Error?X.message:String(X)})}let B;try{B=await Y.json()}catch{throw new f(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 TF(B.mode,X,G,B.details);throw eJ(H),H}throw new f(Y.status,B.error||B.message||"Request failed",B.details,typeof B.step==="string"?B.step:void 0)}return B}async function sf(D){return x(`/auth/check-username?username=${encodeURIComponent(D)}`)}async function rf(D){return x(`/auth/check-github?username=${encodeURIComponent(D)}`)}async function tf(D){return x("/auth/signup",{method:"POST",body:JSON.stringify(D)})}async function _W(D){return x("/auth/login",{method:"POST",body:JSON.stringify({api_key:D})})}async function ef(D){return x("/auth/resend-verification",{method:"POST",body:JSON.stringify({email:D})})}async function Dg(D,F){return x("/auth/retrieve-key",{method:"POST",body:JSON.stringify({email:D,password:F})})}async function Fg(D){return x("/auth/request-key-regeneration",{method:"POST",body:JSON.stringify({email:D})})}async function $Q(){return x("/users/me",{},!0)}async function $g(D,F){let $=new URLSearchParams;if(D)$.set("status",D);if(F)$.set("role",F);let J=$.toString()?`?${$.toString()}`:"";return x(`/admin/users${J}`,{},!0)}async function Jg(D){return x(`/admin/approve/${D}`,{method:"POST"},!0)}async function Qg(D){return x(`/admin/revoke/${D}`,{method:"POST"},!0)}async function Yg(D,F){return x(`/admin/users/${D}/role`,{method:"POST",body:JSON.stringify({role:F})},!0)}async function fW(D,F){return x(`/admin/datasets/${D}/visibility`,{method:"PATCH",body:JSON.stringify({visibility:F})},!0)}async function Bg(D){return x(`/datasets/${D}/publish`,{method:"POST"},!0)}async function Xg(D){return x(`/admin/datasets/${D}/ci`,{},!0)}async function f4(D){return x(`/admin/datasets/${D}/ci`,{method:"POST"},!0)}async function gW(D){return x(`/admin/datasets/${D}/ci/validate`,{method:"POST"},!0)}async function hW(D){return x(`/admin/datasets/${D}/ci/sync`,{method:"POST"},!0)}async function JQ(D){return x(`/datasets/${D}/ci/status`,{},!0)}async function Gg(D){return x(`/datasets/${D}/manifest`,{},!0)}async function QQ(D,F){return x(`/datasets/${D}/manifest/${F}`,{},!0)}function Wg(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 PF(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 x(`/datasets${$}`,{},D.mine?!0:"optional");return J.datasets=J.datasets.map(Wg),J}async function Hg(D){return x(`/datasets/resolve/${D}`,{},"optional")}async function qg(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 x(`/datasets/search?${$.toString()}`,{},"optional")}async function gD(D){let F=await x(`/datasets/${D}`,{},"optional");return Wg(F.dataset)}async function Kg(D){return x(`/datasets/${D}/versions`,{},!0)}async function YQ(D){return x("/datasets",{method:"POST",body:JSON.stringify(D)},!0)}async function BQ(D){return x(`/datasets/${D}/finalize`,{method:"POST"},!0)}async function c8(D,F){return x(`/datasets/${D}/upload-credentials`,{method:"POST",body:JSON.stringify({duration_seconds:F})},!0)}async function bW(D,F){return x(`/datasets/${D}/download-credentials`,{method:"POST",body:JSON.stringify({duration_seconds:F})},!0)}async function zg(D,F){return x(`/admin/datasets/${D}/doi/concept`,{method:"POST",body:JSON.stringify(F)},!0)}async function y9(D){return x(`/admin/datasets/${D}/doi`,{},!0)}async function uW(D,F){return x(`/admin/datasets/${D}/doi/update`,{method:"POST",body:JSON.stringify(F)},!0)}async function mW(D){return x(`/datasets/${D}/request-access`,{method:"POST"},!0)}async function Eg(D,F){let $=F?`?status=${F}`:"";return x(`/datasets/${D}/access-requests${$}`,{},!0)}async function Vg(D,F){return x(`/datasets/${D}/access-requests/${F}/approve`,{method:"POST"},!0)}async function Zg(D,F){return x(`/datasets/${D}/access-requests/${F}/deny`,{method:"POST"},!0)}async function Ug(D,F){return x(`/datasets/${D}/invite`,{method:"POST",body:JSON.stringify({username:F})},!0)}async function Lg(D){return x(`/datasets/${D}/collaborators`,{},!0)}async function Ag(D){return x("/sandbox/complete",{method:"POST",body:JSON.stringify({dataset_id:D})},!0)}async function Mg(){return x("/sandbox/reset",{method:"POST"},!0)}async function Ng(){return x("/sandbox/status",{},!0)}async function XQ(D){return x(`/datasets/${D}/publish/request`,{method:"POST"},!0)}async function Rg(D){return x(`/datasets/${D}/publish/status`,{},!0)}async function Cg(D){return x(`/datasets/${D}/publish/resend`,{method:"POST"},!0)}async function Og(D){let F=D?`?status=${D}`:"";return x(`/admin/publish/requests${F}`,{},!0)}async function jg(D,F){return x(`/admin/publish/${D}/deny`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({reason:F})},!0)}function WV0(D,F=[]){if(D){let $=v9.indexOf(D);if($>=0)return $+1}return Math.min(F.length+1,v9.length)}function HV0(D){if(!(D instanceof f))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 GQ(D,F=!1,$=!1,J=!1,Q,Y){let G,H,q=0,K=!1,V,z=F,Z=[],U;function M(A,C,j,I){if(!Y)return;Y({step:A,stepIndex:WV0(A,C),stepTotal:v9.length,s3LockLocked:j,s3LockTotal:I,s3LockResumed:A==="s3_lock"&&K?!0:void 0})}for(let A=1;A<=5;A++)try{let C,j=!0;do{if(C=await x(`/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,C.step_results)Z.push(...C.step_results);if(C.s3_lock_total!==void 0)H=C.s3_lock_total;if(C.s3_lock_batch_count!==void 0)q+=C.s3_lock_batch_count;let I=C.step??C.step_results?.[C.step_results.length-1]?.step;if(I&&(I!==V||I==="s3_lock"))M(I,C.steps_completed??[],I==="s3_lock"?q:void 0,I==="s3_lock"?H:void 0),V=I;if(C.hasMore&&C.s3_lock_continuation_token!==void 0)G=C.s3_lock_continuation_token;else break}while(C.hasMore);if(Z.length>0)C.step_results=of(Z);return C}catch(C){if(U=C,A===5||!HV0(C)){if(C instanceof f&&Z.length>0)C.stepResults=of(Z);throw C}let I=C;if(Q?.({attempt:A,maxAttempts:5,delayMs:1e4,step:I.step,error:I.message}),await new Promise((R)=>setTimeout(R,1e4)),z=!0,G!==void 0)K=!0}throw U}function of(D){let F=new Map;for(let $ of D)F.set($.step,$);return Array.from(F.values())}async function wg(D,F){return x(`/admin/datasets/${D}/enrichment`,{method:"POST",body:JSON.stringify(F)},!0)}async function Tg(D){return x(`/admin/datasets/${D}/files`,{},!0)}async function Pg(D){let F,$=0,J=[],Q=!0;while(Q){let Y=await x(`/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 f(500,"S3 lock paginated response missing continuation_token; aborting to avoid infinite loop")}return{locked:$,failed:J}}async function Ig(D){return x(`/admin/datasets/${D}/reset`,{method:"POST"},!0)}async function Sg(D,F=!1){return x(`/admin/datasets/${D}`,{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({force:F})},!0)}async function kg(D){return x("/admin/datasets/bulk-delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({dataset_ids:D})},!0)}async function vg(D){return x("/admin/datasets/import",{method:"POST",body:JSON.stringify(D)},!0)}async function yg(D){let F=D?`?status=${encodeURIComponent(D)}`:"";return x(`/admin/imports${F}`,{},!0)}async function xg(D){return x(`/admin/imports/${D}/rollback`,{method:"POST"},!0)}async function _g(D){return x(`/admin/imports/${D}/retry`,{method:"POST"},!0)}async function WQ(D,F){return x(`/admin/datasets/${D}/reindex`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(F??{})},!0)}async function fg(D,F){return x("/admin/datasets/reindex/bulk",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filter:D,...F??{}})},!0)}async function gg(D){let F=D?.limit??15;return x(`/admin/datasets/hed-sweep?limit=${encodeURIComponent(String(F))}`,{method:"POST",headers:{"Content-Type":"application/json"}},!0)}async function hg(){return x("/admin/datasets/hed-sweep?reset=1",{method:"POST",headers:{"Content-Type":"application/json"}},!0)}async function bg(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 x(`/admin/fleet/drift${$}`,{},!0)}async function IF(D,F){return x(`/admin/datasets/${D}/enforce`,{method:"POST",body:JSON.stringify({dry_run:F})},!0)}async function ug(D){return x("/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 mg(D,F=!1){return x(`/admin/datasets/${D}/revalidate${F?"?force=true":""}`,{method:"POST"},!0)}async function lg(D){let F=D?`?user=${encodeURIComponent(D)}`:"";return x(`/admin/email-preferences${F}`,{},!0)}async function pg(D,F){let $=F?`?user=${encodeURIComponent(F)}`:"";return x(`/admin/email-preferences${$}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(D)},!0)}async function dg(){return x("/notices",{},"optional")}async function cg(){return x("/admin/notices",{},!0)}async function ng(D){return x("/admin/notices",{method:"POST",body:JSON.stringify(D)},!0)}async function ig(D){return x(`/admin/notices/${D}`,{method:"DELETE"},!0)}async function lW(D){return x("/admin/notify",{method:"POST",body:JSON.stringify(D)},!0)}async function ag(){return x("/admin/summary/coverage",{},!0)}async function og(D,F,$){return x("/admin/manifest/dispatch",{method:"POST",body:JSON.stringify({dataset_id:D,version:F,skip_canary:$?.skipCanary??!1})},!0)}var yW="https://api.nemar.org",FQ,f,TF,xW,v9;var n8=S(()=>{x4();vW();DQ();FQ=/^\d{4}-\d{4}-\d{4}-\d{3}[\dX]$/;f=class f extends Error{statusCode;details;step;constructor(D,F,$,J){super(F);this.statusCode=D;this.details=$;this.step=J;this.name="ApiError"}};TF=class TF extends f{mode;eta;constructor(D,F,$,J){super(503,F,J);this.mode=D;this.eta=$;this.name="MaintenanceError"}};xW=yW.includes("workers.dev");v9=["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 tg(D){dW=D}function cW(){return dW}function x9(D){if(dW)process.stderr.write(`${D}
99
99
  `)}var dW=!1;function YD(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 eg(D){return`${YD(D)}/s`}function qV0(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 KV0(D,F=20){let $=Math.round(D/100*F),J=F-$;return`[${"=".repeat($)}${" ".repeat(J)}]`}class HQ{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=`${KV0($)} ${$}% ${Q}`;else Y=Q;if(F>0){let B=this.bytesTotal>0?`${YD(F)}/${YD(this.bytesTotal)}`:YD(F);Y+=` | ${B}`}if(D>0)Y+=` | ${eg(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 ${qV0(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?`${eg(this.totalBytesTransferred/F)}`:"",J=[`${D} file${D!==1?"s":""} downloaded`,this.totalBytesTransferred>0?YD(this.totalBytesTransferred):"",$].filter(Boolean).join(" | ");process.stderr.write(`${W.green(J)}
100
100
  `)}}}var nW=S(()=>{ND()});var Eh={};r6(Eh,{verifyGitHubAuth:()=>f9,toS3Credentials:()=>PD,switchBranch:()=>RV0,setKeyPresent:()=>zh,selectAnnexS3Remote:()=>JH,saveDataset:()=>a8,runCommand:()=>T,resolveUpstreamRef:()=>qH,resolveGitHubCloneAuth:()=>qh,readRemoteHeadDatasetVersion:()=>HH,readLocalDatasetVersion:()=>WH,pushToGitHub:()=>C1,pushBranch:()=>kF,markInheritedOpenNeuroRemotesIgnored:()=>$H,listDatasetVersions:()=>YH,isWorkingTreeDirty:()=>KH,isNonFastForwardPush:()=>Wh,isGitAnnexDataset:()=>R1,isDataladDataset:()=>TV0,initOrEnableSpecialRemote:()=>Gh,initDataset:()=>n6,githubTokenCredentialHelper:()=>Hh,gitMergeFastForward:()=>EH,gitFetchOrigin:()=>zH,gitAnnexAdd:()=>i6,getVersionCommit:()=>BH,getRemoteUuid:()=>UQ,getLocalDatasetInfo:()=>QH,getKeyHashDirs:()=>jV0,getKeyHashDir:()=>Kh,getDatasetStats:()=>AV0,getDatasetIdFromRemote:()=>s8,getDatasetData:()=>VQ,getCurrentBranch:()=>o8,getAnnexWhereisAll:()=>ZQ,getAnnexS3Remotes:()=>h9,formatBytes:()=>YD,extractWhereisKeyUrl:()=>aW,ensureLocalMainBranch:()=>b9,ensureGitAnnexInitialized:()=>eW,enableS3Remote:()=>h4,dropUnusedAnnexObjects:()=>VH,dropFiles:()=>FH,detectImportMarker:()=>EQ,createRevertBranch:()=>XH,createDataladDataset:()=>wV0,countPendingDownload:()=>zQ,copyToAnnexRemote:()=>C8,configureS3Remote:()=>o1,configureLargefiles:()=>g4,configureGitHubRemote:()=>i8,commitRevert:()=>GH,collectFileManifest:()=>ZH,cloneDataset:()=>Q1,clearAnnexCredentials:()=>ID,checkPrerequisites:()=>_9,checkGitHubSSH:()=>Qh,checkGitAnnexInstalled:()=>tW,checkDownloadPrerequisites:()=>SF,checkAWSCredentials:()=>ZV0,batchSetKeysPresent:()=>UH,awsCredentialEnv:()=>KQ,annexRemoteExists:()=>Xh,acceptGitHubInvitation:()=>g9,NEMAR_S3_REMOTE_NAME:()=>qQ,ANNEX_REMOTE_EXISTS_RE:()=>Bh});import{existsSync as oW,readFileSync as zV0,statSync as EV0}from"fs";import{join as sW}from"path";var{spawn:rW}=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=rW({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(cW()){let H=F.cwd?` (cwd=${F.cwd})`:"";x9(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(cW()){if(B.trim())x9(W.dim(B.trimEnd()));if(X.trim())x9(W.yellow(X.trimEnd()));x9(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}}function Dh(D){return D.split(".").map((F)=>{let $=Number.parseInt(F.replace(/[^0-9]/g,""),10);return Number.isNaN($)?0:$})}function VV0(D,F){let $=Dh(D),J=Dh(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 tW(){try{let{stdout:F,exitCode:$,stderr:J}=await T(["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?VV0(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 Qh(){if(process.env.GH_TOKEN)return{accessible:!0,username:"token-auth",useHttps:!0};try{let{stdout:D,stderr:F}=await T(["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 ZV0(){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 T(["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 Yh(){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 _9(){let[D,F]=await Promise.all([tW(),Qh()]),$=[];if(!D.installed)$.push(`git-annex is not installed. Install: ${Yh()}`);else if(D.compatible===!1)$.push(`git-annex version ${D.version} is too old. Required: >= ${D.minVersion}`);if(!F.accessible){if(!(await DH()).token)$.push("GitHub authentication not configured. Run 'gh auth login' to authenticate.")}return{gitAnnex:D,githubSSH:F,allPassed:$.length===0,errors:$}}async function R1(D){if(!oW(sW(D,".git")))return!1;try{let{exitCode:F}=await T(["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 n6(D,F={}){if(!F.force&&await R1(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 T(["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 T(["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 T(["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 T(["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 eW(D){try{let{exitCode:F,stderr:$}=await T(["git","annex","info"],{cwd:D});if(F===0)return{success:!0};if($.includes("First run: git-annex init")){let{stderr:J,exitCode:Q}=await T(["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 g4(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 T(["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 i6(D,F="."){try{let{stderr:$,exitCode:J}=await T(["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 PD(D){return{accessKeyId:D.access_key_id,secretAccessKey:D.secret_access_key,sessionToken:D.session_token}}function iW(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(`
@@ -620,7 +620,7 @@ Description:
620
620
 
621
621
  Examples:
622
622
  $ nemar dataset status nm000104
623
- $ nemar dataset status nm000104 --json | jq '.concept_doi'`).action(async(D,F)=>{let $=O(`Fetching dataset info for ${D}...`).start(),J;try{J=await gD(D),$.stop()}catch(Q){if($.fail("Dataset not found"),Q instanceof f)console.log(W.red(` ${Q.message}`));else console.log(W.red(` ${Q.message}`));process.exit(1)}if(F.json){console.log(JSON.stringify(J,null,2));return}if(console.log(),console.log(W.bold(`Dataset: ${J.dataset_id}`)),console.log(),console.log(` Name: ${J.name}`),console.log(` Owner: ${J.owner_username}`),console.log(` Status: ${AU0(J.status)}`),console.log(` Created: ${new Date(J.created_at).toLocaleDateString()}`),J.description)console.log(` Description: ${J.description}`);if(J.github_repo)console.log(` GitHub: https://github.com/${J.github_repo}`);if(J.concept_doi)console.log(` DOI: https://doi.org/${J.concept_doi}`);console.log(),console.log(W.dim("To download this dataset:")),console.log(W.dim(` nemar dataset download ${D}`))});async function LU0(D){if(!vb(D))return D;let F=null;try{F=await Hg(D)}catch(J){return console.log(W.dim(`Could not check NEMAR availability: ${J.message}`)),null}if(!F?.found||!F.dataset_id)return null;console.log(),console.log(W.green(`This dataset is available on NEMAR as ${W.bold(F.dataset_id)}`)),console.log(W.dim("NEMAR provides git-annex version tracking and selective file download."));let{useNemarBackend:$}=await D0.prompt([{type:"confirm",name:"useNemarBackend",message:`Download from NEMAR (${F.dataset_id}) instead of OpenNeuro?`,default:!0}]);return $?F.dataset_id:null}function AU0(D){switch(D.toLowerCase()){case"published":return W.green(D);case"active":return W.blue(D);case"archived":return W.dim(D);case"pending":return W.yellow(D);default:return D}}function MU0(D,F){let{offset:$,totalCount:J}=F,Q=$+1,Y=$+D.length,B=J>D.length?`${Q}-${Y} of ${J}`:`${J}`;console.log(),console.log(W.bold(`Datasets (${B}):`)),console.log();let X=(Z)=>Z.dataset_id||Z.id||"",G=Math.max(10,...D.map((Z)=>X(Z).length)),H=Math.min(30,Math.max(10,...D.map((Z)=>Z.name.length))),q=10,K=8,V=Math.max(8,...D.map((Z)=>(Z.owner_username||"-").length)),z=["ID".padEnd(G),"Name".padEnd(H),"Modality".padEnd(q),"Subj".padEnd(K),"Owner".padEnd(V),"Status"].join(" ");console.log(W.dim(z)),console.log(W.dim("-".repeat(z.length)));for(let Z of D){let U=X(Z),M=Z.name.length>H?`${Z.name.substring(0,H-3)}...`:Z.name,A=(Z.modalities||"").substring(0,q),C=Z.participants?String(Z.participants):"-",j=Z.owner_username||"-",I=Z.visibility==="public"?W.green("pub"):W.yellow("prv"),R;if(Z.source_type==="catalog")R=W.dim(U.padEnd(G));else R=W.cyan(U.padEnd(G));let w=Z.source_type==="catalog"?W.dim(M):M,v=[R,w.padEnd(H+(Z.source_type==="catalog"?W.dim("").length:0)),A.padEnd(q),C.padEnd(K),j.padEnd(V),I].join(" ");console.log(v)}if(console.log(),J>Y){let Z=Math.floor($/F.limit)+1,U=Math.ceil(J/F.limit);console.log(W.dim(`Page ${Z}/${U}. Next: nemar dataset list --page ${Z+1}`))}console.log(W.dim(` * = not synced to nemar.org ${W.dim("dim")} = catalog-only (not on GitHub)`)),console.log(W.dim("For details: nemar dataset status <dataset-id>")),console.log(W.dim("Search: nemar dataset search <query>"))}t0.command("list").description("List datasets on NEMAR (full catalog)").option("--mine","List only your datasets (both private and public)").option("--owner <username>","List datasets owned by a specific user").option("--search <query>","Search by name, description, authors, or tasks").option("--modality <type>","Filter by modality (eeg, emg, meg, etc.)").option("--author <name>","Filter by author name").option("--task <name>","Filter by task name").option("--license <tiers>","Filter by license tier(s), comma-separated: public, attribution, sharealike, noncommercial, noderiv, unknown").option("--doi","Show only datasets with DOIs").option("--recent [days]","Show recently published datasets").option("--sort <order>","Sort: newest, oldest, name, participants, size","newest").option("--json","Output as JSON for scripting").option("-n, --limit <n>","Results per page (default: 20, max: 200)","20").option("--page <n>","Page number (starts at 1)").option("--offset <n>","Skip this many results (alternative to --page)").option("--all","Show all results (up to 200)").addHelpText("after",`
623
+ $ nemar dataset status nm000104 --json | jq '.concept_doi'`).action(async(D,F)=>{let $=O(`Fetching dataset info for ${D}...`).start(),J;try{J=await gD(D),$.stop()}catch(Q){if($.fail("Dataset not found"),Q instanceof f)console.log(W.red(` ${Q.message}`));else console.log(W.red(` ${Q.message}`));process.exit(1)}if(F.json){console.log(JSON.stringify(J,null,2));return}if(console.log(),console.log(W.bold(`Dataset: ${J.dataset_id}`)),console.log(),console.log(` Name: ${J.name}`),console.log(` Owner: ${J.owner_username}`),console.log(` Status: ${AU0(J.status)}`),console.log(` Created: ${new Date(J.created_at).toLocaleDateString()}`),J.description)console.log(` Description: ${J.description}`);if(J.github_repo)console.log(` GitHub: https://github.com/${J.github_repo}`);if(J.concept_doi)console.log(` DOI: https://doi.org/${J.concept_doi}`);console.log(),console.log(W.dim("To download this dataset:")),console.log(W.dim(` nemar dataset download ${D}`))});async function LU0(D){if(!vb(D))return D;let F=null;try{F=await Hg(D)}catch(J){return console.log(W.dim(`Could not check NEMAR availability: ${J.message}`)),null}if(!F?.found||!F.dataset_id)return null;console.log(),console.log(W.green(`This dataset is available on NEMAR as ${W.bold(F.dataset_id)}`)),console.log(W.dim("NEMAR provides git-annex version tracking and selective file download."));let{useNemarBackend:$}=await D0.prompt([{type:"confirm",name:"useNemarBackend",message:`Download from NEMAR (${F.dataset_id}) instead of OpenNeuro?`,default:!0}]);return $?F.dataset_id:null}function AU0(D){switch(D.toLowerCase()){case"published":return W.green(D);case"active":return W.blue(D);case"archived":return W.dim(D);case"pending":return W.yellow(D);default:return D}}function MU0(D,F){let{offset:$,totalCount:J}=F,Q=$+1,Y=$+D.length,B=J>D.length?`${Q}-${Y} of ${J}`:`${J}`;console.log(),console.log(W.bold(`Datasets (${B}):`)),console.log();let X=(Z)=>Z.dataset_id||Z.id||"",G=Math.max(10,...D.map((Z)=>X(Z).length)),H=Math.min(30,Math.max(10,...D.map((Z)=>Z.name.length))),q=10,K=8,V=Math.max(8,...D.map((Z)=>(Z.owner_username||"-").length)),z=["ID".padEnd(G),"Name".padEnd(H),"Modality".padEnd(q),"Subj".padEnd(K),"HED".padEnd(3),"Owner".padEnd(V),"Status"].join(" ");console.log(W.dim(z)),console.log(W.dim("-".repeat(z.length)));for(let Z of D){let U=X(Z),M=Z.name.length>H?`${Z.name.substring(0,H-3)}...`:Z.name,A=(Z.modalities||"").substring(0,q),C=Z.participants?String(Z.participants):"-",j=Z.owner_username||"-",I=Z.visibility==="public"?W.green("pub"):W.yellow("prv"),R;if(Z.source_type==="catalog")R=W.dim(U.padEnd(G));else R=W.cyan(U.padEnd(G));let w=Z.source_type==="catalog"?W.dim(M):M,v=[R,w.padEnd(H+(Z.source_type==="catalog"?W.dim("").length:0)),A.padEnd(q),C.padEnd(K),Z.has_hed===1?W.magenta("HED".padEnd(3)):W.dim("-".padEnd(3)),j.padEnd(V),I].join(" ");console.log(v)}if(console.log(),J>Y){let Z=Math.floor($/F.limit)+1,U=Math.ceil(J/F.limit);console.log(W.dim(`Page ${Z}/${U}. Next: nemar dataset list --page ${Z+1}`))}console.log(W.dim(` * = not synced to nemar.org ${W.dim("dim")} = catalog-only (not on GitHub)`)),console.log(W.dim("For details: nemar dataset status <dataset-id>")),console.log(W.dim("Search: nemar dataset search <query>"))}t0.command("list").description("List datasets on NEMAR (full catalog)").option("--mine","List only your datasets (both private and public)").option("--owner <username>","List datasets owned by a specific user").option("--search <query>","Search by name, description, authors, or tasks").option("--modality <type>","Filter by modality (eeg, emg, meg, etc.)").option("--author <name>","Filter by author name").option("--task <name>","Filter by task name").option("--license <tiers>","Filter by license tier(s), comma-separated: public, attribution, sharealike, noncommercial, noderiv, unknown").option("--doi","Show only datasets with DOIs").option("--hed","Show only datasets with HED annotations").option("--recent [days]","Show recently published datasets").option("--sort <order>","Sort: newest, oldest, name, participants, size","newest").option("--json","Output as JSON for scripting").option("-n, --limit <n>","Results per page (default: 20, max: 200)","20").option("--page <n>","Page number (starts at 1)").option("--offset <n>","Skip this many results (alternative to --page)").option("--all","Show all results (up to 200)").addHelpText("after",`
624
624
  Description:
625
625
  Lists the full NEMAR catalog, including legacy datasets from nemar.org
626
626
  and datasets managed via nemar-cli. Shows 20 results per page by default.
@@ -651,8 +651,8 @@ Examples:
651
651
  $ nemar dataset list --license public,attribution # Permissive licenses
652
652
  $ nemar dataset list --search "motor" # Search by keyword
653
653
  $ nemar dataset list --doi --sort size # Published, by size
654
- $ nemar dataset search "resting state EEG" # Semantic search`).action(async(D)=>{if(D.mine&&D.owner)console.log(W.red("Error: --mine and --owner cannot be used together")),console.log("Use --mine for your datasets, or --owner <username> for another user's."),process.exit(1);if(D.mine&&!H0())console.log(W.red("Error: Not authenticated")),console.log("Run 'nemar auth login' to see your datasets"),process.exit(1);if(D.license){let X=["public","attribution","sharealike","noncommercial","noderiv","unknown"],G=D.license.split(",").map((H)=>H.trim().toLowerCase()).filter((H)=>H&&!X.includes(H));if(G.length>0)console.log(W.red(`Error: invalid license tier(s): ${G.join(", ")}`)),console.log(`Valid tiers: ${X.join(", ")}`),process.exit(1)}let F=D.all?200:Math.min(Number.parseInt(D.limit,10)||20,200),$=0;if(D.page)$=(Math.max(Number.parseInt(D.page,10)||1,1)-1)*F;else if(D.offset)$=Math.max(Number.parseInt(D.offset,10)||0,0);let J=O("Fetching datasets...").start(),Q;try{Q=await PF({mine:!!D.mine,search:D.search,modality:D.modality,author:D.author,task:D.task,license:D.license,hasDoi:!!D.doi,recent:D.recent?Number.parseInt(D.recent,10)||30:void 0,sort:D.sort,limit:F,offset:$,owner:D.owner}),J.stop()}catch(X){if(J.fail("Failed to fetch datasets"),X instanceof f)console.log(W.red(` ${X.message}`));else console.log(W.red(` ${X.message}`));process.exit(1)}let Y=Q.datasets,B=Q.total_count??Q.count;if(D.json){console.log(JSON.stringify({datasets:Y,total_count:B,limit:F,offset:$,fallback:Q.fallback,warning:Q.warning},null,2));return}if(Q.warning)console.log(W.yellow(`
655
- \u26A0 ${Q.warning}`));if(Y.length===0){if(console.log(),D.mine)console.log(W.yellow("You don't have any datasets yet.")),console.log(W.dim("Create one with: nemar dataset upload <path>"));else if(D.owner)console.log(W.yellow(`No datasets found for user '${D.owner}'.`));else if(D.search||D.modality||D.author)console.log(W.yellow("No datasets match your filters.")),console.log(W.dim("Try broader search terms or remove filters."));else console.log(W.yellow("No datasets found."));return}MU0(Y,{limit:F,offset:$,totalCount:B})});t0.command("search <query>").description("Search datasets using semantic matching").option("--modality <type>","Filter by modality (eeg, emg, meg, etc.)").option("--json","Output as JSON for scripting").option("--limit <n>","Limit results (default: 20)","20").addHelpText("after",`
654
+ $ nemar dataset search "resting state EEG" # Semantic search`).action(async(D)=>{if(D.mine&&D.owner)console.log(W.red("Error: --mine and --owner cannot be used together")),console.log("Use --mine for your datasets, or --owner <username> for another user's."),process.exit(1);if(D.mine&&!H0())console.log(W.red("Error: Not authenticated")),console.log("Run 'nemar auth login' to see your datasets"),process.exit(1);if(D.license){let X=["public","attribution","sharealike","noncommercial","noderiv","unknown"],G=D.license.split(",").map((H)=>H.trim().toLowerCase()).filter((H)=>H&&!X.includes(H));if(G.length>0)console.log(W.red(`Error: invalid license tier(s): ${G.join(", ")}`)),console.log(`Valid tiers: ${X.join(", ")}`),process.exit(1)}let F=D.all?200:Math.min(Number.parseInt(D.limit,10)||20,200),$=0;if(D.page)$=(Math.max(Number.parseInt(D.page,10)||1,1)-1)*F;else if(D.offset)$=Math.max(Number.parseInt(D.offset,10)||0,0);let J=O("Fetching datasets...").start(),Q;try{Q=await PF({mine:!!D.mine,search:D.search,modality:D.modality,author:D.author,task:D.task,license:D.license,hasDoi:!!D.doi,hasHed:!!D.hed,recent:D.recent?Number.parseInt(D.recent,10)||30:void 0,sort:D.sort,limit:F,offset:$,owner:D.owner}),J.stop()}catch(X){if(J.fail("Failed to fetch datasets"),X instanceof f)console.log(W.red(` ${X.message}`));else console.log(W.red(` ${X.message}`));process.exit(1)}let Y=Q.datasets,B=Q.total_count??Q.count;if(D.json){console.log(JSON.stringify({datasets:Y,total_count:B,limit:F,offset:$,fallback:Q.fallback,warning:Q.warning},null,2));return}if(Q.warning)console.log(W.yellow(`
655
+ \u26A0 ${Q.warning}`));if(Y.length===0){if(console.log(),D.mine)console.log(W.yellow("You don't have any datasets yet.")),console.log(W.dim("Create one with: nemar dataset upload <path>"));else if(D.owner)console.log(W.yellow(`No datasets found for user '${D.owner}'.`));else if(D.search||D.modality||D.author||D.hed||D.license||D.task)console.log(W.yellow("No datasets match your filters.")),console.log(W.dim("Try broader search terms or remove filters."));else console.log(W.yellow("No datasets found."));return}MU0(Y,{limit:F,offset:$,totalCount:B})});t0.command("search <query>").description("Search datasets using semantic matching").option("--modality <type>","Filter by modality (eeg, emg, meg, etc.)").option("--hed","Show only datasets with HED annotations").option("--json","Output as JSON for scripting").option("--limit <n>","Limit results (default: 20)","20").addHelpText("after",`
656
656
  Description:
657
657
  Performs semantic search across the NEMAR dataset catalog. Unlike
658
658
  --search on the list command (which uses exact text matching), this
@@ -664,7 +664,7 @@ Description:
664
664
  Examples:
665
665
  $ nemar dataset search "motor imagery EEG"
666
666
  $ nemar dataset search "resting state" --modality eeg
667
- $ nemar dataset search "sleep spindles" --json`).action(async(D,F)=>{let $=O("Searching datasets...").start();try{let J=await qg(D,{modality:F.modality,limit:Number.parseInt(F.limit,10)});if($.stop(),F.json){console.log(JSON.stringify(J,null,2));return}if(J.results.length===0){console.log(),console.log(W.yellow("No datasets match your search.")),console.log(W.dim("Try different search terms or use 'nemar dataset list' for browsing."));return}console.log(),console.log(W.bold(`Search results for "${D}" (${J.results.length} found, ${J.method}):`)),console.log();let Q=Math.max(10,...J.results.map((H)=>H.id.length)),Y=Math.min(35,Math.max(10,...J.results.map((H)=>H.name.length))),B=10,X=6,G=["Score".padEnd(5),"ID".padEnd(Q),"Name".padEnd(Y),"Modality".padEnd(B),"Subj".padEnd(X)].join(" ");console.log(W.dim(G)),console.log(W.dim("-".repeat(G.length)));for(let H of J.results){let q=H.name.length>Y?`${H.name.substring(0,Y-3)}...`:H.name,V=[(H.score>=0.8?W.green:H.score>=0.5?W.yellow:W.dim)(String(H.score).padEnd(5)),W.cyan(H.id.padEnd(Q)),q.padEnd(Y),(H.modalities||"-").substring(0,B).padEnd(B),(H.participants?String(H.participants):"-").padEnd(X)].join(" ");console.log(V)}console.log(),console.log(W.dim("For details: nemar dataset status <dataset-id>"))}catch(J){if($.fail("Search failed"),J instanceof f)console.log(W.red(` ${J.message}`));else console.log(W.red(` ${J.message}`));process.exit(1)}});t0.command("release").description("Create a version bump PR for a dataset").argument("<dataset-id>","Dataset ID (e.g., nm000104)").option("--type <type>","Bump type: patch, minor, or major").option("--version <version>","Explicit version (e.g., 2.0.0)").option("--dir <path>","Use existing local clone instead of cloning").option("--monitor","Watch CI checks and offer to merge").option(j0,w0).addHelpText("after",`
667
+ $ nemar dataset search "sleep spindles" --json`).action(async(D,F)=>{let $=O("Searching datasets...").start();try{let J=await qg(D,{modality:F.modality,hasHed:!!F.hed,limit:Number.parseInt(F.limit,10)});if($.stop(),F.json){console.log(JSON.stringify(J,null,2));return}if(J.results.length===0){console.log(),console.log(W.yellow("No datasets match your search.")),console.log(W.dim("Try different search terms or use 'nemar dataset list' for browsing."));return}console.log(),console.log(W.bold(`Search results for "${D}" (${J.results.length} found, ${J.method}):`)),console.log();let Q=Math.max(10,...J.results.map((H)=>H.id.length)),Y=Math.min(35,Math.max(10,...J.results.map((H)=>H.name.length))),B=10,X=6,G=["Score".padEnd(5),"ID".padEnd(Q),"Name".padEnd(Y),"Modality".padEnd(B),"Subj".padEnd(X),"HED".padEnd(3)].join(" ");console.log(W.dim(G)),console.log(W.dim("-".repeat(G.length)));for(let H of J.results){let q=H.name.length>Y?`${H.name.substring(0,Y-3)}...`:H.name,V=[(H.score>=0.8?W.green:H.score>=0.5?W.yellow:W.dim)(String(H.score).padEnd(5)),W.cyan(H.id.padEnd(Q)),q.padEnd(Y),(H.modalities||"-").substring(0,B).padEnd(B),(H.participants?String(H.participants):"-").padEnd(X),H.has_hed===1?W.magenta("HED"):W.dim("-")].join(" ");console.log(V)}console.log(),console.log(W.dim("For details: nemar dataset status <dataset-id>"))}catch(J){if($.fail("Search failed"),J instanceof f)console.log(W.red(` ${J.message}`));else console.log(W.red(` ${J.message}`));process.exit(1)}});t0.command("release").description("Create a version bump PR for a dataset").argument("<dataset-id>","Dataset ID (e.g., nm000104)").option("--type <type>","Bump type: patch, minor, or major").option("--version <version>","Explicit version (e.g., 2.0.0)").option("--dir <path>","Use existing local clone instead of cloning").option("--monitor","Watch CI checks and offer to merge").option(j0,w0).addHelpText("after",`
668
668
  Description:
669
669
  Create a pull request that bumps the dataset version in
670
670
  dataset_description.json. The PR triggers CI checks (BIDS validation,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nemar-cli",
3
- "version": "0.8.73-PR876.449f6ec",
3
+ "version": "0.8.73-PR877.fbd19b5",
4
4
  "description": "CLI for NEMAR (Neuroelectromagnetic Data Archive and Tools Resource) dataset management",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",