nemar-cli 0.9.5-dev.1844 → 0.9.5-dev.1852
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -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 vp=!1;var Sz=S(()=>{e0()});var xp;var yp=S(()=>{xp={name:"nemar-cli",version:"0.9.5-dev.1844",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 T3;var ZX=S(()=>{yp();T3=xp.version});function d(D){if(D instanceof Error)return D.message;return String(D)}var g,w3;var Z1=S(()=>{g=class g extends Error{statusCode;details;step;constructor(D,F,$,Q){super(F);this.statusCode=D;this.details=$;this.step=Q;this.name="ApiError"}};w3=class w3 extends g{mode;eta;constructor(D,F,$,Q){super(503,F,Q);this.mode=D;this.eta=$;this.name="MaintenanceError"}}});function _p(){if(process.env.TEST_API_URL)return process.env.TEST_API_URL;if(vz)return kz;return ZD().apiUrl||kz}async function y(D,F={},$=!1,Q){let J=`${_p()}${D}`,Y={"Content-Type":"application/json","X-CLI-Version":T3,...F.headers};if($){let B=ZD();if(!B.apiKey&&$===!0)throw new g(401,"Not authenticated. Run 'nemar auth login' first.");if(B.apiKey)Y.Authorization=`Bearer ${B.apiKey}`}let X;try{X=await fetch(J,{...F,headers:Y})}catch(B){throw new g(0,`Network error: Could not connect to ${_p()}`,{originalError:B instanceof Error?B.message:String(B)})}let G;try{G=await X.json()}catch{throw new g(X.status,`Invalid response from server (status ${X.status})`)}if(!X.ok){if(X.status===503&&(G.mode==="read-only"||G.mode==="full")){let B=typeof G.message==="string"?G.message:"NEMAR is in maintenance mode. Please retry shortly.",W=typeof G.eta==="string"?G.eta:null,q=new w3(G.mode,B,W,G.details);throw zX(q),q}throw new g(X.status,G.error||G.message||"Request failed",G.details,typeof G.step==="string"?G.step:void 0)}if(Q){let B=Q.safeParse(G);if(!B.success)throw new g(X.status,`Response for ${D} did not match the expected NEMAR contract`,{issues:B.error.issues});return B.data}return G}var kz="https://nemar-api-dev.sccn-org.workers.dev",vz;var S4=S(()=>{I4();Sz();ZX();Z1();vz=kz.includes("workers.dev")});async function fp(D,F){let $=new URLSearchParams;if(D)$.set("status",D);if(F)$.set("role",F);let Q=$.toString()?`?${$.toString()}`:"";return y(`/admin/users${Q}`,{},!0)}async function bp(D){return y(`/admin/approve/${D}`,{method:"POST"},!0)}async function gp(D){return y(`/admin/revoke/${D}`,{method:"POST"},!0)}async function hp(D,F){return y(`/admin/users/${D}/role`,{method:"POST",body:JSON.stringify({role:F})},!0)}async function yz(D,F){return y(`/admin/datasets/${D}/visibility`,{method:"PATCH",body:JSON.stringify({visibility:F})},!0)}async function up(D){return y(`/datasets/${D}/publish`,{method:"POST"},!0)}async function mp(D){return y(`/admin/datasets/${D}/ci`,{},!0)}async function T6(D){return y(`/admin/datasets/${D}/ci`,{method:"POST"},!0)}async function xz(D){return y(`/admin/datasets/${D}/ci/validate`,{method:"POST"},!0)}async function _z(D){return y(`/admin/datasets/${D}/ci/sync`,{method:"POST"},!0)}async function lp(D,F){return y(`/admin/datasets/${D}/doi/concept`,{method:"POST",body:JSON.stringify(F)},!0)}async function B$(D){return y(`/admin/datasets/${D}/doi`,{},!0)}async function fz(D,F){return y(`/admin/datasets/${D}/doi/update`,{method:"POST",body:JSON.stringify(F)},!0)}async function pp(D,F){return y(`/admin/datasets/${D}/withdraw`,{method:"POST",body:JSON.stringify({reason:F.reason,dry_run:F.dryRun})},!0)}async function dp(D,F){return y(`/admin/datasets/${D}/restore`,{method:"POST",body:JSON.stringify({dry_run:F.dryRun})},!0)}async function cp(D){return y(`/admin/datasets/${D}/reset`,{method:"POST"},!0)}async function np(D,F=!1){return y(`/admin/datasets/${D}`,{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({force:F})},!0)}async function ip(D){return y("/admin/datasets/bulk-delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({dataset_ids:D})},!0)}async function ap(D){return y("/admin/datasets/import",{method:"POST",body:JSON.stringify(D)},!0)}async function op(D){return y("/admin/datasets/exemplar",{method:"POST",body:JSON.stringify(D)},!0)}async function sp(D){return y(`/admin/datasets/${D}/exemplar/remint-dois`,{method:"POST"},!0)}async function bz(D,F){let $=new URLSearchParams;if(D)$.set("status",D);if(F!==void 0)$.set("blocklisted",F?"1":"0");let Q=$.toString();return y(`/admin/imports${Q?`?${Q}`:""}`,{},!0)}async function rp(D){return y(`/admin/imports/${D}/rollback`,{method:"POST"},!0)}async function tp(D){return y(`/admin/imports/${D}/retry`,{method:"POST"},!0)}async function gz(D){return y(`/admin/imports/${D}/verify`,{method:"POST"},!0)}async function ep(D){return y("/admin/imports/dispatch-cooldown",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({dataset_ids:D})},!0)}async function w5(D,F){return y(`/admin/datasets/${D}/reindex`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(F??{})},!0)}async function Dd(D,F){return y("/admin/datasets/reindex/bulk",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filter:D,...F??{}})},!0)}async function Fd(D){let F=D?.limit??15;return y(`/admin/datasets/hed-sweep?limit=${encodeURIComponent(String(F))}`,{method:"POST",headers:{"Content-Type":"application/json"}},!0)}async function $d(){return y("/admin/datasets/hed-sweep?reset=1",{method:"POST",headers:{"Content-Type":"application/json"}},!0)}async function Qd(D){let F=D?.limit??15,$=new URLSearchParams({limit:String(F)});if(D?.olderThan!=null)$.set("older-than",String(D.olderThan));if(D?.before!=null)$.set("before",D.before);return y(`/admin/datasets/data-integrity-sweep?${$.toString()}`,{method:"POST",headers:{"Content-Type":"application/json"}},!0)}async function Jd(){return y("/admin/datasets/data-integrity-sweep?reset=1",{method:"POST",headers:{"Content-Type":"application/json"}},!0)}async function Yd(D,F){let $=F?.write?"":"?dry_run=1";return y(`/admin/datasets/${D}/availability-report${$}`,{method:"POST",headers:{"Content-Type":"application/json"}},!0)}async function Xd(D){let F=D?.limit??10,$=new URLSearchParams({limit:String(F)});if(D?.missingOnly)$.set("missing-only","1");return y(`/admin/datasets/availability-report-sweep?${$.toString()}`,{method:"POST",headers:{"Content-Type":"application/json"}},!0)}async function Gd(){return y("/admin/datasets/availability-report-sweep?reset=1",{method:"POST",headers:{"Content-Type":"application/json"}},!0)}async function Bd(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 P5(D,F){return y(`/admin/datasets/${D}/enforce`,{method:"POST",body:JSON.stringify({dry_run:F})},!0)}async function Wd(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 Hd(D,F=!1){return y(`/admin/datasets/${D}/revalidate${F?"?force=true":""}`,{method:"POST"},!0)}async function qd(D){let F=D?`?user=${encodeURIComponent(D)}`:"";return y(`/admin/email-preferences${F}`,{},!0)}async function Kd(D,F){let $=F?`?user=${encodeURIComponent(F)}`:"";return y(`/admin/email-preferences${$}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(D)},!0)}async function hz(D){return y("/admin/notify",{method:"POST",body:JSON.stringify(D)},!0)}async function zd(){return y("/admin/summary/coverage",{},!0)}async function Zd(D,F,$){return y("/admin/manifest/dispatch",{method:"POST",body:JSON.stringify({dataset_id:D,version:F,skip_canary:$?.skipCanary??!1})},!0)}var I5=S(()=>{S4()});async function s8(D,F){return y(`/datasets/${D}/upload-credentials`,{method:"POST",body:JSON.stringify({duration_seconds:F})},!0)}async function uz(D,F){return y(`/datasets/${D}/download-credentials`,{method:"POST",body:JSON.stringify({duration_seconds:F})},!0)}async function Vd(D){return y(`/admin/datasets/${D}/files`,{},!0)}async function Ed(D){let F,$=0,Q=[],J=!0;while(J){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)Q.push(...Y.failed);if(J=Y.hasMore,F=Y.continuation_token,J&&!F)throw new g(500,"S3 lock paginated response missing continuation_token; aborting to avoid infinite loop")}return{locked:$,failed:Q}}var S5=S(()=>{S4();Z1()});async function EX(D){return y(`/datasets/${D}/ci/status`,{},!0)}async function Ud(D){return y(`/datasets/${D}/manifest`,{},!0)}async function UX(D,F){return y(`/datasets/${D}/manifest/${F}`,{},!0)}function Ld(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 k5(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.dataComplete)F.set("data_complete","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 y(`/datasets${$}`,{},D.mine?!0:"optional");return Q.datasets=Q.datasets.map(Ld),Q}async function Md(D){return y(`/datasets/resolve/${D}`,{},"optional")}async function Ad(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 y(`/datasets/search?${$.toString()}`,{},"optional")}async function VD(D){let F=await y(`/datasets/${D}`,{},"optional");return Ld(F.dataset)}async function Nd(D){return y(`/datasets/${D}/versions`,{},!0)}async function LX(D){return y("/datasets",{method:"POST",body:JSON.stringify(D)},!0)}async function MX(D){return y(`/datasets/${D}/finalize`,{method:"POST"},!0)}async function mz(D){return y(`/datasets/${D}/request-access`,{method:"POST"},!0)}async function Cd(D,F){let $=F?`?status=${F}`:"";return y(`/datasets/${D}/access-requests${$}`,{},!0)}async function Od(D,F){return y(`/datasets/${D}/access-requests/${F}/approve`,{method:"POST"},!0)}async function jd(D,F){return y(`/datasets/${D}/access-requests/${F}/deny`,{method:"POST"},!0)}async function Rd(D,F){return y(`/datasets/${D}/invite`,{method:"POST",body:JSON.stringify({username:F})},!0)}async function Td(D){return y(`/datasets/${D}/collaborators`,{},!0)}async function wd(D,F){return y(`/admin/datasets/${D}/enrichment`,{method:"POST",body:JSON.stringify(F)},!0)}var VX;var P3=S(()=>{S4();VX=/^\d{4}-\d{4}-\d{4}-\d{3}[\dX]$/});var v5;var vd=S(()=>{v5=["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 y5(D){return y(`/datasets/${D}/publish/request`,{method:"POST"},!0)}async function xd(D){return y(`/datasets/${D}/publish/status`,{},!0)}async function _d(D){return y(`/datasets/${D}/publish/resend`,{method:"POST"},!0)}async function fd(D){let F=D?`?status=${D}`:"";return y(`/admin/publish/requests${F}`,{},!0)}async function bd(D,F){return y(`/admin/publish/${D}/deny`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({reason:F})},!0)}function ZS0(D,F=[]){if(D){let $=v5.indexOf(D);if($>=0)return $+1}return Math.min(F.length+1,v5.length)}function VS0(D){if(!(D instanceof g))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 x5(D,F=!1,$=!1,Q=!1,J,Y){let B,W,q=0,K=!1,Z,z=F,E=[],U;function L(A,N,j,R){if(!Y)return;Y({step:A,stepIndex:ZS0(A,N),stepTotal:v5.length,s3LockLocked:j,s3LockTotal:R,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:B,s3_lock_total:W,skip_ci_check:Q})},!0),j=!1,N.step_results)E.push(...N.step_results);if(N.s3_lock_total!==void 0)W=N.s3_lock_total;if(N.s3_lock_batch_count!==void 0)q+=N.s3_lock_batch_count;let R=N.step??N.step_results?.[N.step_results.length-1]?.step;if(R&&(R!==Z||R==="s3_lock"))L(R,N.steps_completed??[],R==="s3_lock"?q:void 0,R==="s3_lock"?W:void 0),Z=R;if(N.hasMore&&N.s3_lock_continuation_token!==void 0)B=N.s3_lock_continuation_token;else break}while(N.hasMore);if(E.length>0)N.step_results=yd(E);return N}catch(N){if(U=N,A===5||!VS0(N)){if(N instanceof g&&E.length>0)N.stepResults=yd(E);throw N}let R=N;if(J?.({attempt:A,maxAttempts:5,delayMs:1e4,step:R.step,error:R.message}),await new Promise((C)=>setTimeout(C,1e4)),z=!0,B!==void 0)K=!0}throw U}function yd(D){let F=new Map;for(let $ of D)F.set($.step,$);return Array.from(F.values())}var W$=S(()=>{vd();S4();Z1()});function ud(D){pz=D}function dz(){return pz}function H$(D){if(pz)process.stderr.write(`${D}
|
|
105
|
+
`)}var vp=!1;var Sz=S(()=>{e0()});var xp;var yp=S(()=>{xp={name:"nemar-cli",version:"0.9.5-dev.1852",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 T3;var ZX=S(()=>{yp();T3=xp.version});function d(D){if(D instanceof Error)return D.message;return String(D)}var g,w3;var Z1=S(()=>{g=class g extends Error{statusCode;details;step;constructor(D,F,$,Q){super(F);this.statusCode=D;this.details=$;this.step=Q;this.name="ApiError"}};w3=class w3 extends g{mode;eta;constructor(D,F,$,Q){super(503,F,Q);this.mode=D;this.eta=$;this.name="MaintenanceError"}}});function _p(){if(process.env.TEST_API_URL)return process.env.TEST_API_URL;if(vz)return kz;return ZD().apiUrl||kz}async function y(D,F={},$=!1,Q){let J=`${_p()}${D}`,Y={"Content-Type":"application/json","X-CLI-Version":T3,...F.headers};if($){let B=ZD();if(!B.apiKey&&$===!0)throw new g(401,"Not authenticated. Run 'nemar auth login' first.");if(B.apiKey)Y.Authorization=`Bearer ${B.apiKey}`}let X;try{X=await fetch(J,{...F,headers:Y})}catch(B){throw new g(0,`Network error: Could not connect to ${_p()}`,{originalError:B instanceof Error?B.message:String(B)})}let G;try{G=await X.json()}catch{throw new g(X.status,`Invalid response from server (status ${X.status})`)}if(!X.ok){if(X.status===503&&(G.mode==="read-only"||G.mode==="full")){let B=typeof G.message==="string"?G.message:"NEMAR is in maintenance mode. Please retry shortly.",W=typeof G.eta==="string"?G.eta:null,q=new w3(G.mode,B,W,G.details);throw zX(q),q}throw new g(X.status,G.error||G.message||"Request failed",G.details,typeof G.step==="string"?G.step:void 0)}if(Q){let B=Q.safeParse(G);if(!B.success)throw new g(X.status,`Response for ${D} did not match the expected NEMAR contract`,{issues:B.error.issues});return B.data}return G}var kz="https://nemar-api-dev.sccn-org.workers.dev",vz;var S4=S(()=>{I4();Sz();ZX();Z1();vz=kz.includes("workers.dev")});async function fp(D,F){let $=new URLSearchParams;if(D)$.set("status",D);if(F)$.set("role",F);let Q=$.toString()?`?${$.toString()}`:"";return y(`/admin/users${Q}`,{},!0)}async function bp(D){return y(`/admin/approve/${D}`,{method:"POST"},!0)}async function gp(D){return y(`/admin/revoke/${D}`,{method:"POST"},!0)}async function hp(D,F){return y(`/admin/users/${D}/role`,{method:"POST",body:JSON.stringify({role:F})},!0)}async function yz(D,F){return y(`/admin/datasets/${D}/visibility`,{method:"PATCH",body:JSON.stringify({visibility:F})},!0)}async function up(D){return y(`/datasets/${D}/publish`,{method:"POST"},!0)}async function mp(D){return y(`/admin/datasets/${D}/ci`,{},!0)}async function T6(D){return y(`/admin/datasets/${D}/ci`,{method:"POST"},!0)}async function xz(D){return y(`/admin/datasets/${D}/ci/validate`,{method:"POST"},!0)}async function _z(D){return y(`/admin/datasets/${D}/ci/sync`,{method:"POST"},!0)}async function lp(D,F){return y(`/admin/datasets/${D}/doi/concept`,{method:"POST",body:JSON.stringify(F)},!0)}async function B$(D){return y(`/admin/datasets/${D}/doi`,{},!0)}async function fz(D,F){return y(`/admin/datasets/${D}/doi/update`,{method:"POST",body:JSON.stringify(F)},!0)}async function pp(D,F){return y(`/admin/datasets/${D}/withdraw`,{method:"POST",body:JSON.stringify({reason:F.reason,dry_run:F.dryRun})},!0)}async function dp(D,F){return y(`/admin/datasets/${D}/restore`,{method:"POST",body:JSON.stringify({dry_run:F.dryRun})},!0)}async function cp(D){return y(`/admin/datasets/${D}/reset`,{method:"POST"},!0)}async function np(D,F=!1){return y(`/admin/datasets/${D}`,{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({force:F})},!0)}async function ip(D){return y("/admin/datasets/bulk-delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({dataset_ids:D})},!0)}async function ap(D){return y("/admin/datasets/import",{method:"POST",body:JSON.stringify(D)},!0)}async function op(D){return y("/admin/datasets/exemplar",{method:"POST",body:JSON.stringify(D)},!0)}async function sp(D){return y(`/admin/datasets/${D}/exemplar/remint-dois`,{method:"POST"},!0)}async function bz(D,F){let $=new URLSearchParams;if(D)$.set("status",D);if(F!==void 0)$.set("blocklisted",F?"1":"0");let Q=$.toString();return y(`/admin/imports${Q?`?${Q}`:""}`,{},!0)}async function rp(D){return y(`/admin/imports/${D}/rollback`,{method:"POST"},!0)}async function tp(D){return y(`/admin/imports/${D}/retry`,{method:"POST"},!0)}async function gz(D){return y(`/admin/imports/${D}/verify`,{method:"POST"},!0)}async function ep(D){return y("/admin/imports/dispatch-cooldown",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({dataset_ids:D})},!0)}async function w5(D,F){return y(`/admin/datasets/${D}/reindex`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(F??{})},!0)}async function Dd(D,F){return y("/admin/datasets/reindex/bulk",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filter:D,...F??{}})},!0)}async function Fd(D){let F=D?.limit??15;return y(`/admin/datasets/hed-sweep?limit=${encodeURIComponent(String(F))}`,{method:"POST",headers:{"Content-Type":"application/json"}},!0)}async function $d(){return y("/admin/datasets/hed-sweep?reset=1",{method:"POST",headers:{"Content-Type":"application/json"}},!0)}async function Qd(D){let F=D?.limit??15,$=new URLSearchParams({limit:String(F)});if(D?.olderThan!=null)$.set("older-than",String(D.olderThan));if(D?.before!=null)$.set("before",D.before);return y(`/admin/datasets/data-integrity-sweep?${$.toString()}`,{method:"POST",headers:{"Content-Type":"application/json"}},!0)}async function Jd(){return y("/admin/datasets/data-integrity-sweep?reset=1",{method:"POST",headers:{"Content-Type":"application/json"}},!0)}async function Yd(D,F){let $=F?.write?"":"?dry_run=1";return y(`/admin/datasets/${D}/availability-report${$}`,{method:"POST",headers:{"Content-Type":"application/json"}},!0)}async function Xd(D){let F=D?.limit??10,$=new URLSearchParams({limit:String(F)});if(D?.missingOnly)$.set("missing-only","1");return y(`/admin/datasets/availability-report-sweep?${$.toString()}`,{method:"POST",headers:{"Content-Type":"application/json"}},!0)}async function Gd(){return y("/admin/datasets/availability-report-sweep?reset=1",{method:"POST",headers:{"Content-Type":"application/json"}},!0)}async function Bd(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 P5(D,F){return y(`/admin/datasets/${D}/enforce`,{method:"POST",body:JSON.stringify({dry_run:F})},!0)}async function Wd(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 Hd(D,F=!1){return y(`/admin/datasets/${D}/revalidate${F?"?force=true":""}`,{method:"POST"},!0)}async function qd(D){let F=D?`?user=${encodeURIComponent(D)}`:"";return y(`/admin/email-preferences${F}`,{},!0)}async function Kd(D,F){let $=F?`?user=${encodeURIComponent(F)}`:"";return y(`/admin/email-preferences${$}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(D)},!0)}async function hz(D){return y("/admin/notify",{method:"POST",body:JSON.stringify(D)},!0)}async function zd(){return y("/admin/summary/coverage",{},!0)}async function Zd(D,F,$){return y("/admin/manifest/dispatch",{method:"POST",body:JSON.stringify({dataset_id:D,version:F,skip_canary:$?.skipCanary??!1})},!0)}var I5=S(()=>{S4()});async function s8(D,F){return y(`/datasets/${D}/upload-credentials`,{method:"POST",body:JSON.stringify({duration_seconds:F})},!0)}async function uz(D,F){return y(`/datasets/${D}/download-credentials`,{method:"POST",body:JSON.stringify({duration_seconds:F})},!0)}async function Vd(D){return y(`/admin/datasets/${D}/files`,{},!0)}async function Ed(D){let F,$=0,Q=[],J=!0;while(J){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)Q.push(...Y.failed);if(J=Y.hasMore,F=Y.continuation_token,J&&!F)throw new g(500,"S3 lock paginated response missing continuation_token; aborting to avoid infinite loop")}return{locked:$,failed:Q}}var S5=S(()=>{S4();Z1()});async function EX(D){return y(`/datasets/${D}/ci/status`,{},!0)}async function Ud(D){return y(`/datasets/${D}/manifest`,{},!0)}async function UX(D,F){return y(`/datasets/${D}/manifest/${F}`,{},!0)}function Ld(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 k5(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.dataComplete)F.set("data_complete","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 y(`/datasets${$}`,{},D.mine?!0:"optional");return Q.datasets=Q.datasets.map(Ld),Q}async function Md(D){return y(`/datasets/resolve/${D}`,{},"optional")}async function Ad(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 y(`/datasets/search?${$.toString()}`,{},"optional")}async function VD(D){let F=await y(`/datasets/${D}`,{},"optional");return Ld(F.dataset)}async function Nd(D){return y(`/datasets/${D}/versions`,{},!0)}async function LX(D){return y("/datasets",{method:"POST",body:JSON.stringify(D)},!0)}async function MX(D){return y(`/datasets/${D}/finalize`,{method:"POST"},!0)}async function mz(D){return y(`/datasets/${D}/request-access`,{method:"POST"},!0)}async function Cd(D,F){let $=F?`?status=${F}`:"";return y(`/datasets/${D}/access-requests${$}`,{},!0)}async function Od(D,F){return y(`/datasets/${D}/access-requests/${F}/approve`,{method:"POST"},!0)}async function jd(D,F){return y(`/datasets/${D}/access-requests/${F}/deny`,{method:"POST"},!0)}async function Rd(D,F){return y(`/datasets/${D}/invite`,{method:"POST",body:JSON.stringify({username:F})},!0)}async function Td(D){return y(`/datasets/${D}/collaborators`,{},!0)}async function wd(D,F){return y(`/admin/datasets/${D}/enrichment`,{method:"POST",body:JSON.stringify(F)},!0)}var VX;var P3=S(()=>{S4();VX=/^\d{4}-\d{4}-\d{4}-\d{3}[\dX]$/});var v5;var vd=S(()=>{v5=["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 y5(D){return y(`/datasets/${D}/publish/request`,{method:"POST"},!0)}async function xd(D){return y(`/datasets/${D}/publish/status`,{},!0)}async function _d(D){return y(`/datasets/${D}/publish/resend`,{method:"POST"},!0)}async function fd(D){let F=D?`?status=${D}`:"";return y(`/admin/publish/requests${F}`,{},!0)}async function bd(D,F){return y(`/admin/publish/${D}/deny`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({reason:F})},!0)}function ZS0(D,F=[]){if(D){let $=v5.indexOf(D);if($>=0)return $+1}return Math.min(F.length+1,v5.length)}function VS0(D){if(!(D instanceof g))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 x5(D,F=!1,$=!1,Q=!1,J,Y){let B,W,q=0,K=!1,Z,z=F,E=[],U;function L(A,N,j,R){if(!Y)return;Y({step:A,stepIndex:ZS0(A,N),stepTotal:v5.length,s3LockLocked:j,s3LockTotal:R,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:B,s3_lock_total:W,skip_ci_check:Q})},!0),j=!1,N.step_results)E.push(...N.step_results);if(N.s3_lock_total!==void 0)W=N.s3_lock_total;if(N.s3_lock_batch_count!==void 0)q+=N.s3_lock_batch_count;let R=N.step??N.step_results?.[N.step_results.length-1]?.step;if(R&&(R!==Z||R==="s3_lock"))L(R,N.steps_completed??[],R==="s3_lock"?q:void 0,R==="s3_lock"?W:void 0),Z=R;if(N.hasMore&&N.s3_lock_continuation_token!==void 0)B=N.s3_lock_continuation_token;else break}while(N.hasMore);if(E.length>0)N.step_results=yd(E);return N}catch(N){if(U=N,A===5||!VS0(N)){if(N instanceof g&&E.length>0)N.stepResults=yd(E);throw N}let R=N;if(J?.({attempt:A,maxAttempts:5,delayMs:1e4,step:R.step,error:R.message}),await new Promise((C)=>setTimeout(C,1e4)),z=!0,B!==void 0)K=!0}throw U}function yd(D){let F=new Map;for(let $ of D)F.set($.step,$);return Array.from(F.values())}var W$=S(()=>{vd();S4();Z1()});function ud(D){pz=D}function dz(){return pz}function H$(D){if(pz)process.stderr.write(`${D}
|
|
106
106
|
`)}var pz=!1;var md={};v6(md,{runCommand:()=>T});var{spawn:ES0}=globalThis.Bun;async function T(D,F={}){let $={...process.env,GIT_TERMINAL_PROMPT:"0",...F.env};for(let W of F.unsetEnv??[])delete $[W];let Q=ES0({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(dz()){let W=F.cwd?` (cwd=${F.cwd})`:"";H$(H.dim(`$ ${D.join(" ")}${W}`))}let X=await new Response(Q.stdout).text(),G=await new Response(Q.stderr).text(),B=await Q.exited;if(Y)clearTimeout(Y);if(dz()){if(X.trim())H$(H.dim(X.trimEnd()));if(G.trim())H$(H.yellow(G.trimEnd()));H$(H.dim(`(exit ${B})`))}if(J)return{stdout:X,stderr:G||`Command timed out after ${Math.round(F.timeout/1000)}s`,exitCode:B??1};return{stdout:X,stderr:G,exitCode:B}}var V1=S(()=>{e0()});async function US0(){try{let{exitCode:D,stderr:F}=await T(["ssh","-T","-o","BatchMode=yes","-o","ConnectTimeout=5","git@github.com"]),$=F.includes("successfully authenticated");if(!$)console.warn("SSH test to github.com failed:",{exitCode:D,stderr:F.trim().slice(0,500)});return{works:$,error:$?void 0:F.trim().slice(0,500)}}catch(D){let F=D instanceof Error?D.message:String(D);return console.warn("SSH test exception:",F),{works:!1,error:F}}}async function q$(){try{let{stdout:D,exitCode:F,stderr:$}=await T(["gh","auth","token"]);if(F!==0)return console.warn("gh CLI returned non-zero exit code:",F),console.warn("stderr:",$),{token:null,error:`gh auth token failed: ${$.trim()||"unknown error"}`};if(!D.trim())return console.warn("gh auth token returned empty output"),{token:null,error:"gh CLI returned empty token"};return{token:D.trim()}}catch(D){let F=D instanceof Error?D.message:String(D);if(console.error("Failed to get GitHub token from gh CLI:",F),F.includes("ENOENT")||F.includes("not found"))return{token:null,error:"gh CLI not installed (command not found)"};return{token:null,error:`gh CLI error: ${F}`}}}async function AX(D){try{let{stdout:F,exitCode:$,stderr:Q}=await T(["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 NX(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 T(["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(G){let B=G instanceof Error?G.message:String(G);return console.error("Failed to parse GitHub invitations response:",B),console.error(" Raw response (first 500 chars):",(F||"").slice(0,500)),{accepted:!1,error:`Failed to parse GitHub API response: ${B}`}}if(!J){let{exitCode:G}=await T(["gh","api",`/repos/${D}`,"--silent"]);if(G===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 T(["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 r8(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 T(["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 q$();if(Y.token)Q=`https://github.com/${J}`,await T(["git","config","credential.https://github.com.helper",`!printf 'username=x-access-token\\npassword=${Y.token}'`],{cwd:D});else{let X=await US0();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