nemar-cli 0.8.76-PR946.d72c54c → 0.8.76-PR947.fa8af3e

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
@@ -102,7 +102,7 @@ ${H.dim(`eta: ${D.eta}`)}`:"";process.stderr.write(`${F}
102
102
  ${$} ${D.message}
103
103
  ${Q}${J}
104
104
  ${F}
105
- `)}var Bp=!1;var qz=I(()=>{FD()});var Wp;var Gp=I(()=>{Wp={name:"nemar-cli",version:"0.8.76-PR946.d72c54c",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",ajv:"^8.20.0","ajv-formats":"^3.0.1",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 A3;var tY=I(()=>{Gp();A3=Wp.version});function z0(D){if(D instanceof Error)return D.message;return String(D)}var _,N3;var L1=I(()=>{_=class _ extends Error{statusCode;details;step;constructor(D,F,$,Q){super(F);this.statusCode=D;this.details=$;this.step=Q;this.name="ApiError"}};N3=class N3 extends _{mode;eta;constructor(D,F,$,Q){super(503,F,Q);this.mode=D;this.eta=$;this.name="MaintenanceError"}}});function Hp(){if(process.env.TEST_API_URL)return process.env.TEST_API_URL;if(zz)return Kz;return KD().apiUrl||Kz}async function x(D,F={},$=!1,Q){let J=`${Hp()}${D}`,Y={"Content-Type":"application/json","X-CLI-Version":A3,...F.headers};if($){let G=KD();if(!G.apiKey&&$===!0)throw new _(401,"Not authenticated. Run 'nemar auth login' first.");if(G.apiKey)Y.Authorization=`Bearer ${G.apiKey}`}let X;try{X=await fetch(J,{...F,headers:Y})}catch(G){throw new _(0,`Network error: Could not connect to ${Hp()}`,{originalError:G instanceof Error?G.message:String(G)})}let B;try{B=await X.json()}catch{throw new _(X.status,`Invalid response from server (status ${X.status})`)}if(!X.ok){if(X.status===503&&(B.mode==="read-only"||B.mode==="full")){let G=typeof B.message==="string"?B.message:"NEMAR is in maintenance mode. Please retry shortly.",W=typeof B.eta==="string"?B.eta:null,q=new N3(B.mode,G,W,B.details);throw rY(q),q}throw new _(X.status,B.error||B.message||"Request failed",B.details,typeof B.step==="string"?B.step:void 0)}if(Q){let G=Q.safeParse(B);if(!G.success)throw new _(X.status,`Response for ${D} did not match the expected NEMAR contract`,{issues:G.error.issues});return G.data}return B}var Kz="https://api.nemar.org",zz;var j4=I(()=>{O4();qz();tY();L1();zz=Kz.includes("workers.dev")});async function qp(D,F){let $=new URLSearchParams;if(D)$.set("status",D);if(F)$.set("role",F);let Q=$.toString()?`?${$.toString()}`:"";return x(`/admin/users${Q}`,{},!0)}async function Kp(D){return x(`/admin/approve/${D}`,{method:"POST"},!0)}async function zp(D){return x(`/admin/revoke/${D}`,{method:"POST"},!0)}async function Zp(D,F){return x(`/admin/users/${D}/role`,{method:"POST",body:JSON.stringify({role:F})},!0)}async function Zz(D,F){return x(`/admin/datasets/${D}/visibility`,{method:"PATCH",body:JSON.stringify({visibility:F})},!0)}async function Vp(D){return x(`/datasets/${D}/publish`,{method:"POST"},!0)}async function Ep(D){return x(`/admin/datasets/${D}/ci`,{},!0)}async function R3(D){return x(`/admin/datasets/${D}/ci`,{method:"POST"},!0)}async function Vz(D){return x(`/admin/datasets/${D}/ci/validate`,{method:"POST"},!0)}async function Ez(D){return x(`/admin/datasets/${D}/ci/sync`,{method:"POST"},!0)}async function Up(D,F){return x(`/admin/datasets/${D}/doi/concept`,{method:"POST",body:JSON.stringify(F)},!0)}async function t7(D){return x(`/admin/datasets/${D}/doi`,{},!0)}async function Uz(D,F){return x(`/admin/datasets/${D}/doi/update`,{method:"POST",body:JSON.stringify(F)},!0)}async function Lp(D){return x(`/admin/datasets/${D}/reset`,{method:"POST"},!0)}async function Mp(D,F=!1){return x(`/admin/datasets/${D}`,{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({force:F})},!0)}async function Ap(D){return x("/admin/datasets/bulk-delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({dataset_ids:D})},!0)}async function Np(D){return x("/admin/datasets/import",{method:"POST",body:JSON.stringify(D)},!0)}async function Rp(D){let F=D?`?status=${encodeURIComponent(D)}`:"";return x(`/admin/imports${F}`,{},!0)}async function Cp(D){return x(`/admin/imports/${D}/rollback`,{method:"POST"},!0)}async function Op(D){return x(`/admin/imports/${D}/retry`,{method:"POST"},!0)}async function eY(D,F){return x(`/admin/datasets/${D}/reindex`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(F??{})},!0)}async function jp(D,F){return x("/admin/datasets/reindex/bulk",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filter:D,...F??{}})},!0)}async function Tp(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 wp(){return x("/admin/datasets/hed-sweep?reset=1",{method:"POST",headers:{"Content-Type":"application/json"}},!0)}async function Ip(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 O5(D,F){return x(`/admin/datasets/${D}/enforce`,{method:"POST",body:JSON.stringify({dry_run:F})},!0)}async function Pp(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 Sp(D,F=!1){return x(`/admin/datasets/${D}/revalidate${F?"?force=true":""}`,{method:"POST"},!0)}async function kp(D){let F=D?`?user=${encodeURIComponent(D)}`:"";return x(`/admin/email-preferences${F}`,{},!0)}async function vp(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 Lz(D){return x("/admin/notify",{method:"POST",body:JSON.stringify(D)},!0)}async function yp(){return x("/admin/summary/coverage",{},!0)}async function xp(D,F,$){return x("/admin/manifest/dispatch",{method:"POST",body:JSON.stringify({dataset_id:D,version:F,skip_canary:$?.skipCanary??!1})},!0)}var e7=I(()=>{j4()});async function o8(D,F){return x(`/datasets/${D}/upload-credentials`,{method:"POST",body:JSON.stringify({duration_seconds:F})},!0)}async function Mz(D,F){return x(`/datasets/${D}/download-credentials`,{method:"POST",body:JSON.stringify({duration_seconds:F})},!0)}async function _p(D){return x(`/admin/datasets/${D}/files`,{},!0)}async function fp(D){let F,$=0,Q=[],J=!0;while(J){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)Q.push(...Y.failed);if(J=Y.hasMore,F=Y.continuation_token,J&&!F)throw new _(500,"S3 lock paginated response missing continuation_token; aborting to avoid infinite loop")}return{locked:$,failed:Q}}var j5=I(()=>{j4();L1()});async function FX(D){return x(`/datasets/${D}/ci/status`,{},!0)}async function bp(D){return x(`/datasets/${D}/manifest`,{},!0)}async function $X(D,F){return x(`/datasets/${D}/manifest/${F}`,{},!0)}function gp(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 T5(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()}`:"",Q=await x(`/datasets${$}`,{},D.mine?!0:"optional");return Q.datasets=Q.datasets.map(gp),Q}async function hp(D){return x(`/datasets/resolve/${D}`,{},"optional")}async function up(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 bD(D){let F=await x(`/datasets/${D}`,{},"optional");return gp(F.dataset)}async function mp(D){return x(`/datasets/${D}/versions`,{},!0)}async function QX(D){return x("/datasets",{method:"POST",body:JSON.stringify(D)},!0)}async function JX(D){return x(`/datasets/${D}/finalize`,{method:"POST"},!0)}async function Az(D){return x(`/datasets/${D}/request-access`,{method:"POST"},!0)}async function lp(D,F){let $=F?`?status=${F}`:"";return x(`/datasets/${D}/access-requests${$}`,{},!0)}async function pp(D,F){return x(`/datasets/${D}/access-requests/${F}/approve`,{method:"POST"},!0)}async function dp(D,F){return x(`/datasets/${D}/access-requests/${F}/deny`,{method:"POST"},!0)}async function cp(D,F){return x(`/datasets/${D}/invite`,{method:"POST",body:JSON.stringify({username:F})},!0)}async function np(D){return x(`/datasets/${D}/collaborators`,{},!0)}async function ip(D,F){return x(`/admin/datasets/${D}/enrichment`,{method:"POST",body:JSON.stringify(F)},!0)}var DX;var C3=I(()=>{j4();DX=/^\d{4}-\d{4}-\d{4}-\d{3}[\dX]$/});var w5;var tp=I(()=>{w5=["ci_check","enrichment_check","s3_public_read","repo_public","tag_protect","doi_create","update_metadata","update_readme","create_tag","create_release","upload_to_zenodo","publish_doi","version_doi","s3_lock","sync_nemar","notify_user"]});async function YX(D){return x(`/datasets/${D}/publish/request`,{method:"POST"},!0)}async function Dd(D){return x(`/datasets/${D}/publish/status`,{},!0)}async function Fd(D){return x(`/datasets/${D}/publish/resend`,{method:"POST"},!0)}async function $d(D){let F=D?`?status=${D}`:"";return x(`/admin/publish/requests${F}`,{},!0)}async function Qd(D,F){return x(`/admin/publish/${D}/deny`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({reason:F})},!0)}function BP0(D,F=[]){if(D){let $=w5.indexOf(D);if($>=0)return $+1}return Math.min(F.length+1,w5.length)}function GP0(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 XX(D,F=!1,$=!1,Q=!1,J,Y){let G,W,q=0,K=!1,Z,z=F,E=[],U;function M(A,R,O,T){if(!Y)return;Y({step:A,stepIndex:BP0(A,R),stepTotal:w5.length,s3LockLocked:O,s3LockTotal:T,s3LockResumed:A==="s3_lock"&&K?!0:void 0})}for(let A=1;A<=5;A++)try{let R,O=!0;do{if(R=await x(`/admin/publish/${D}/approve`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({resume:O?z:!0,sandbox:$,s3_lock_continuation_token:G,s3_lock_total:W,skip_ci_check:Q})},!0),O=!1,R.step_results)E.push(...R.step_results);if(R.s3_lock_total!==void 0)W=R.s3_lock_total;if(R.s3_lock_batch_count!==void 0)q+=R.s3_lock_batch_count;let T=R.step??R.step_results?.[R.step_results.length-1]?.step;if(T&&(T!==Z||T==="s3_lock"))M(T,R.steps_completed??[],T==="s3_lock"?q:void 0,T==="s3_lock"?W:void 0),Z=T;if(R.hasMore&&R.s3_lock_continuation_token!==void 0)G=R.s3_lock_continuation_token;else break}while(R.hasMore);if(E.length>0)R.step_results=ep(E);return R}catch(R){if(U=R,A===5||!GP0(R)){if(R instanceof _&&E.length>0)R.stepResults=ep(E);throw R}let T=R;if(J?.({attempt:A,maxAttempts:5,delayMs:1e4,step:T.step,error:T.message}),await new Promise((N)=>setTimeout(N,1e4)),z=!0,G!==void 0)K=!0}throw U}function ep(D){let F=new Map;for(let $ of D)F.set($.step,$);return Array.from(F.values())}var BX=I(()=>{tp();j4();L1()});function Xd(D){Rz=D}function Cz(){return Rz}function D$(D){if(Rz)process.stderr.write(`${D}
105
+ `)}var Bp=!1;var qz=I(()=>{FD()});var Wp;var Gp=I(()=>{Wp={name:"nemar-cli",version:"0.8.76-PR947.fa8af3e",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",ajv:"^8.20.0","ajv-formats":"^3.0.1",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 A3;var tY=I(()=>{Gp();A3=Wp.version});function z0(D){if(D instanceof Error)return D.message;return String(D)}var _,N3;var L1=I(()=>{_=class _ extends Error{statusCode;details;step;constructor(D,F,$,Q){super(F);this.statusCode=D;this.details=$;this.step=Q;this.name="ApiError"}};N3=class N3 extends _{mode;eta;constructor(D,F,$,Q){super(503,F,Q);this.mode=D;this.eta=$;this.name="MaintenanceError"}}});function Hp(){if(process.env.TEST_API_URL)return process.env.TEST_API_URL;if(zz)return Kz;return KD().apiUrl||Kz}async function x(D,F={},$=!1,Q){let J=`${Hp()}${D}`,Y={"Content-Type":"application/json","X-CLI-Version":A3,...F.headers};if($){let G=KD();if(!G.apiKey&&$===!0)throw new _(401,"Not authenticated. Run 'nemar auth login' first.");if(G.apiKey)Y.Authorization=`Bearer ${G.apiKey}`}let X;try{X=await fetch(J,{...F,headers:Y})}catch(G){throw new _(0,`Network error: Could not connect to ${Hp()}`,{originalError:G instanceof Error?G.message:String(G)})}let B;try{B=await X.json()}catch{throw new _(X.status,`Invalid response from server (status ${X.status})`)}if(!X.ok){if(X.status===503&&(B.mode==="read-only"||B.mode==="full")){let G=typeof B.message==="string"?B.message:"NEMAR is in maintenance mode. Please retry shortly.",W=typeof B.eta==="string"?B.eta:null,q=new N3(B.mode,G,W,B.details);throw rY(q),q}throw new _(X.status,B.error||B.message||"Request failed",B.details,typeof B.step==="string"?B.step:void 0)}if(Q){let G=Q.safeParse(B);if(!G.success)throw new _(X.status,`Response for ${D} did not match the expected NEMAR contract`,{issues:G.error.issues});return G.data}return B}var Kz="https://api.nemar.org",zz;var j4=I(()=>{O4();qz();tY();L1();zz=Kz.includes("workers.dev")});async function qp(D,F){let $=new URLSearchParams;if(D)$.set("status",D);if(F)$.set("role",F);let Q=$.toString()?`?${$.toString()}`:"";return x(`/admin/users${Q}`,{},!0)}async function Kp(D){return x(`/admin/approve/${D}`,{method:"POST"},!0)}async function zp(D){return x(`/admin/revoke/${D}`,{method:"POST"},!0)}async function Zp(D,F){return x(`/admin/users/${D}/role`,{method:"POST",body:JSON.stringify({role:F})},!0)}async function Zz(D,F){return x(`/admin/datasets/${D}/visibility`,{method:"PATCH",body:JSON.stringify({visibility:F})},!0)}async function Vp(D){return x(`/datasets/${D}/publish`,{method:"POST"},!0)}async function Ep(D){return x(`/admin/datasets/${D}/ci`,{},!0)}async function R3(D){return x(`/admin/datasets/${D}/ci`,{method:"POST"},!0)}async function Vz(D){return x(`/admin/datasets/${D}/ci/validate`,{method:"POST"},!0)}async function Ez(D){return x(`/admin/datasets/${D}/ci/sync`,{method:"POST"},!0)}async function Up(D,F){return x(`/admin/datasets/${D}/doi/concept`,{method:"POST",body:JSON.stringify(F)},!0)}async function t7(D){return x(`/admin/datasets/${D}/doi`,{},!0)}async function Uz(D,F){return x(`/admin/datasets/${D}/doi/update`,{method:"POST",body:JSON.stringify(F)},!0)}async function Lp(D){return x(`/admin/datasets/${D}/reset`,{method:"POST"},!0)}async function Mp(D,F=!1){return x(`/admin/datasets/${D}`,{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({force:F})},!0)}async function Ap(D){return x("/admin/datasets/bulk-delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({dataset_ids:D})},!0)}async function Np(D){return x("/admin/datasets/import",{method:"POST",body:JSON.stringify(D)},!0)}async function Rp(D){let F=D?`?status=${encodeURIComponent(D)}`:"";return x(`/admin/imports${F}`,{},!0)}async function Cp(D){return x(`/admin/imports/${D}/rollback`,{method:"POST"},!0)}async function Op(D){return x(`/admin/imports/${D}/retry`,{method:"POST"},!0)}async function eY(D,F){return x(`/admin/datasets/${D}/reindex`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(F??{})},!0)}async function jp(D,F){return x("/admin/datasets/reindex/bulk",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filter:D,...F??{}})},!0)}async function Tp(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 wp(){return x("/admin/datasets/hed-sweep?reset=1",{method:"POST",headers:{"Content-Type":"application/json"}},!0)}async function Ip(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 O5(D,F){return x(`/admin/datasets/${D}/enforce`,{method:"POST",body:JSON.stringify({dry_run:F})},!0)}async function Pp(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 Sp(D,F=!1){return x(`/admin/datasets/${D}/revalidate${F?"?force=true":""}`,{method:"POST"},!0)}async function kp(D){let F=D?`?user=${encodeURIComponent(D)}`:"";return x(`/admin/email-preferences${F}`,{},!0)}async function vp(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 Lz(D){return x("/admin/notify",{method:"POST",body:JSON.stringify(D)},!0)}async function yp(){return x("/admin/summary/coverage",{},!0)}async function xp(D,F,$){return x("/admin/manifest/dispatch",{method:"POST",body:JSON.stringify({dataset_id:D,version:F,skip_canary:$?.skipCanary??!1})},!0)}var e7=I(()=>{j4()});async function o8(D,F){return x(`/datasets/${D}/upload-credentials`,{method:"POST",body:JSON.stringify({duration_seconds:F})},!0)}async function Mz(D,F){return x(`/datasets/${D}/download-credentials`,{method:"POST",body:JSON.stringify({duration_seconds:F})},!0)}async function _p(D){return x(`/admin/datasets/${D}/files`,{},!0)}async function fp(D){let F,$=0,Q=[],J=!0;while(J){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)Q.push(...Y.failed);if(J=Y.hasMore,F=Y.continuation_token,J&&!F)throw new _(500,"S3 lock paginated response missing continuation_token; aborting to avoid infinite loop")}return{locked:$,failed:Q}}var j5=I(()=>{j4();L1()});async function FX(D){return x(`/datasets/${D}/ci/status`,{},!0)}async function bp(D){return x(`/datasets/${D}/manifest`,{},!0)}async function $X(D,F){return x(`/datasets/${D}/manifest/${F}`,{},!0)}function gp(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 T5(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()}`:"",Q=await x(`/datasets${$}`,{},D.mine?!0:"optional");return Q.datasets=Q.datasets.map(gp),Q}async function hp(D){return x(`/datasets/resolve/${D}`,{},"optional")}async function up(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 bD(D){let F=await x(`/datasets/${D}`,{},"optional");return gp(F.dataset)}async function mp(D){return x(`/datasets/${D}/versions`,{},!0)}async function QX(D){return x("/datasets",{method:"POST",body:JSON.stringify(D)},!0)}async function JX(D){return x(`/datasets/${D}/finalize`,{method:"POST"},!0)}async function Az(D){return x(`/datasets/${D}/request-access`,{method:"POST"},!0)}async function lp(D,F){let $=F?`?status=${F}`:"";return x(`/datasets/${D}/access-requests${$}`,{},!0)}async function pp(D,F){return x(`/datasets/${D}/access-requests/${F}/approve`,{method:"POST"},!0)}async function dp(D,F){return x(`/datasets/${D}/access-requests/${F}/deny`,{method:"POST"},!0)}async function cp(D,F){return x(`/datasets/${D}/invite`,{method:"POST",body:JSON.stringify({username:F})},!0)}async function np(D){return x(`/datasets/${D}/collaborators`,{},!0)}async function ip(D,F){return x(`/admin/datasets/${D}/enrichment`,{method:"POST",body:JSON.stringify(F)},!0)}var DX;var C3=I(()=>{j4();DX=/^\d{4}-\d{4}-\d{4}-\d{3}[\dX]$/});var w5;var tp=I(()=>{w5=["ci_check","enrichment_check","s3_public_read","repo_public","tag_protect","doi_create","update_metadata","update_readme","create_tag","create_release","upload_to_zenodo","publish_doi","version_doi","s3_lock","sync_nemar","notify_user"]});async function YX(D){return x(`/datasets/${D}/publish/request`,{method:"POST"},!0)}async function Dd(D){return x(`/datasets/${D}/publish/status`,{},!0)}async function Fd(D){return x(`/datasets/${D}/publish/resend`,{method:"POST"},!0)}async function $d(D){let F=D?`?status=${D}`:"";return x(`/admin/publish/requests${F}`,{},!0)}async function Qd(D,F){return x(`/admin/publish/${D}/deny`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({reason:F})},!0)}function BP0(D,F=[]){if(D){let $=w5.indexOf(D);if($>=0)return $+1}return Math.min(F.length+1,w5.length)}function GP0(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 XX(D,F=!1,$=!1,Q=!1,J,Y){let G,W,q=0,K=!1,Z,z=F,E=[],U;function M(A,R,O,T){if(!Y)return;Y({step:A,stepIndex:BP0(A,R),stepTotal:w5.length,s3LockLocked:O,s3LockTotal:T,s3LockResumed:A==="s3_lock"&&K?!0:void 0})}for(let A=1;A<=5;A++)try{let R,O=!0;do{if(R=await x(`/admin/publish/${D}/approve`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({resume:O?z:!0,sandbox:$,s3_lock_continuation_token:G,s3_lock_total:W,skip_ci_check:Q})},!0),O=!1,R.step_results)E.push(...R.step_results);if(R.s3_lock_total!==void 0)W=R.s3_lock_total;if(R.s3_lock_batch_count!==void 0)q+=R.s3_lock_batch_count;let T=R.step??R.step_results?.[R.step_results.length-1]?.step;if(T&&(T!==Z||T==="s3_lock"))M(T,R.steps_completed??[],T==="s3_lock"?q:void 0,T==="s3_lock"?W:void 0),Z=T;if(R.hasMore&&R.s3_lock_continuation_token!==void 0)G=R.s3_lock_continuation_token;else break}while(R.hasMore);if(E.length>0)R.step_results=ep(E);return R}catch(R){if(U=R,A===5||!GP0(R)){if(R instanceof _&&E.length>0)R.stepResults=ep(E);throw R}let T=R;if(J?.({attempt:A,maxAttempts:5,delayMs:1e4,step:T.step,error:T.message}),await new Promise((N)=>setTimeout(N,1e4)),z=!0,G!==void 0)K=!0}throw U}function ep(D){let F=new Map;for(let $ of D)F.set($.step,$);return Array.from(F.values())}var BX=I(()=>{tp();j4();L1()});function Xd(D){Rz=D}function Cz(){return Rz}function D$(D){if(Rz)process.stderr.write(`${D}
106
106
  `)}var Rz=!1;var Bd={};k4(Bd,{runCommand:()=>w});var{spawn:WP0}=globalThis.Bun;async function w(D,F={}){let $={...process.env,GIT_TERMINAL_PROMPT:"0",...F.env};for(let W of F.unsetEnv??[])delete $[W];let Q=WP0({cmd:D,cwd:F.cwd,stdout:"pipe",stderr:"pipe",env:$}),J=!1,Y;if(F.timeout)Y=setTimeout(()=>{J=!0,Q.kill()},F.timeout);if(Cz()){let W=F.cwd?` (cwd=${F.cwd})`:"";D$(H.dim(`$ ${D.join(" ")}${W}`))}let X=await new Response(Q.stdout).text(),B=await new Response(Q.stderr).text(),G=await Q.exited;if(Y)clearTimeout(Y);if(Cz()){if(X.trim())D$(H.dim(X.trimEnd()));if(B.trim())D$(H.yellow(B.trimEnd()));D$(H.dim(`(exit ${G})`))}if(J)return{stdout:X,stderr:B||`Command timed out after ${Math.round(F.timeout/1000)}s`,exitCode:G??1};return{stdout:X,stderr:B,exitCode:G}}var M1=I(()=>{FD()});async function HP0(){try{let{exitCode:D,stderr:F}=await w(["ssh","-T","-o","BatchMode=yes","-o","ConnectTimeout=5","git@github.com"]),$=F.includes("successfully authenticated");if(!$)console.warn("SSH test to github.com failed:",{exitCode:D,stderr:F.trim().slice(0,500)});return{works:$,error:$?void 0:F.trim().slice(0,500)}}catch(D){let F=D instanceof Error?D.message:String(D);return console.warn("SSH test exception:",F),{works:!1,error:F}}}async function F$(){try{let{stdout:D,exitCode:F,stderr:$}=await w(["gh","auth","token"]);if(F!==0)return console.warn("gh CLI returned non-zero exit code:",F),console.warn("stderr:",$),{token:null,error:`gh auth token failed: ${$.trim()||"unknown error"}`};if(!D.trim())return console.warn("gh auth token returned empty output"),{token:null,error:"gh CLI returned empty token"};return{token:D.trim()}}catch(D){let F=D instanceof Error?D.message:String(D);if(console.error("Failed to get GitHub token from gh CLI:",F),F.includes("ENOENT")||F.includes("not found"))return{token:null,error:"gh CLI not installed (command not found)"};return{token:null,error:`gh CLI error: ${F}`}}}async function GX(D){try{let{stdout:F,exitCode:$,stderr:Q}=await w(["gh","api","user","--jq",".login"]);if($!==0){if(Q.includes("not logged in")||Q.includes("auth login"))return{authenticated:!1,error:"gh CLI not authenticated. Run 'gh auth login' to authenticate."};return{authenticated:!1,error:`gh CLI error: ${Q.trim()||"unknown error"}`}}let J=F.trim();if(!J)return{authenticated:!1,error:"gh CLI returned empty username"};if(D){let Y=J.toLowerCase()===D.toLowerCase();return{authenticated:!0,username:J,matches:Y,error:Y?void 0:`gh CLI authenticated as '${J}', expected '${D}'`}}return{authenticated:!0,username:J}}catch(F){let $=F instanceof Error?F.message:String(F);if($.includes("ENOENT")||$.includes("not found"))return{authenticated:!1,error:"gh CLI not installed. Install from https://cli.github.com/"};return{authenticated:!1,error:`Failed to verify gh CLI: ${$}`}}}async function WX(D){if(!/^[a-zA-Z0-9_.-]+\/[a-zA-Z0-9_.-]+$/.test(D))return{accepted:!1,error:`Invalid repository format: ${D}`};let{stdout:F,exitCode:$,stderr:Q}=await w(["gh","api","/user/repository_invitations"]);if($!==0){if(Q.includes("not logged in")||Q.includes("auth login"))return{accepted:!1,error:"gh CLI not authenticated. Run 'gh auth login' to authenticate."};if(Q.includes("API rate limit")||Q.includes("403"))return{accepted:!1,error:"GitHub API rate limit exceeded. Please try again in a few minutes."};if(Q.includes("ENOENT")||Q.includes("not found"))return{accepted:!1,error:"gh CLI not installed. Install from https://cli.github.com/"};return{accepted:!1,error:`Failed to list invitations: ${Q.trim()||"unknown error"}`}}let J=null;try{J=JSON.parse(F||"[]").find((W)=>W.repository.full_name===D)?.id??null}catch(B){let G=B instanceof Error?B.message:String(B);return console.error("Failed to parse GitHub invitations response:",G),console.error(" Raw response (first 500 chars):",(F||"").slice(0,500)),{accepted:!1,error:`Failed to parse GitHub API response: ${G}`}}if(!J){let{exitCode:B}=await w(["gh","api",`/repos/${D}`,"--silent"]);if(B===0)return{accepted:!0,alreadyCollaborator:!0};return{accepted:!1,error:`No pending invitation found for ${D}. You may need to accept it manually via GitHub.`}}let{exitCode:Y,stderr:X}=await w(["gh","api","--method","PATCH",`/user/repository_invitations/${J}`]);if(Y!==0)return{accepted:!1,error:`Failed to accept invitation: ${X.trim()||"unknown error"}`};return{accepted:!0}}async function T4(D,F,$="origin"){let Q=F;if(process.env.GH_TOKEN&&F.startsWith("git@github.com:")){let J=process.env.GH_TOKEN.trim();if(!J||/\s/.test(J))return{success:!1,error:"GH_TOKEN environment variable is set but appears malformed (empty or contains whitespace)"};Q=`https://github.com/${F.replace("git@github.com:","")}`,await w(["git","config","credential.https://github.com.helper",`!printf 'username=x-access-token\\npassword=${J}'`],{cwd:D})}else if(F.startsWith("git@github.com:")){let J=F.replace("git@github.com:",""),Y=await F$();if(Y.token)Q=`https://github.com/${J}`,await w(["git","config","credential.https://github.com.helper",`!printf 'username=x-access-token\\npassword=${Y.token}'`],{cwd:D});else{let X=await HP0();if(X.works)Q=F;else return{success:!1,error:`GitHub authentication not configured.
107
107
 
108
108
  gh CLI failed: ${Y.error||"could not get token"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nemar-cli",
3
- "version": "0.8.76-PR946.d72c54c",
3
+ "version": "0.8.76-PR947.fa8af3e",
4
4
  "description": "CLI for NEMAR (Neuroelectromagnetic Data Archive and Tools Resource) dataset management",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",