@npayload/sdk 5.0.4 → 5.1.0

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 (53) hide show
  1. package/README.md +4 -0
  2. package/dist/chunk-2G46BKEC.mjs +1 -0
  3. package/dist/{chunk-KUJJYP3K.mjs → chunk-2WG7FETK.mjs} +1 -1
  4. package/dist/chunk-5R5L7GTT.mjs +17 -0
  5. package/dist/{chunk-2N25V56J.mjs → chunk-6R2QLUWE.mjs} +2 -2
  6. package/dist/chunk-7IFTQ52O.mjs +1 -0
  7. package/dist/chunk-7QTR5IWG.mjs +1 -0
  8. package/dist/chunk-AECDYMA2.mjs +1 -0
  9. package/dist/{chunk-455C67EN.mjs → chunk-AGDMCMF3.mjs} +1 -1
  10. package/dist/chunk-C5EDDEPR.mjs +1 -0
  11. package/dist/{chunk-2PCG57PX.mjs → chunk-CDA75PLA.mjs} +1 -1
  12. package/dist/{chunk-6ZOPXG44.mjs → chunk-CFM43QNN.mjs} +4 -4
  13. package/dist/{chunk-6RMN6EHY.mjs → chunk-GG7UQYUV.mjs} +1 -1
  14. package/dist/{chunk-FAO3QJC5.mjs → chunk-HX6PH7C3.mjs} +1 -1
  15. package/dist/{chunk-RIBBVOCC.mjs → chunk-IH2OLS7G.mjs} +1 -1
  16. package/dist/{chunk-FNAZW7X3.mjs → chunk-K3YY77PG.mjs} +1 -1
  17. package/dist/chunk-KQCX2PCW.mjs +1 -0
  18. package/dist/chunk-LCUELOEE.mjs +2 -0
  19. package/dist/{chunk-2XQXDEXA.mjs → chunk-M7WGBUJ2.mjs} +1 -1
  20. package/dist/{chunk-UMQ2SWSM.mjs → chunk-N6NIJISZ.mjs} +1 -1
  21. package/dist/chunk-ONTNXGOM.mjs +1 -0
  22. package/dist/{chunk-HTQLUO4J.mjs → chunk-ORT5FUFW.mjs} +1 -1
  23. package/dist/chunk-R6DPWMZM.mjs +1 -0
  24. package/dist/{chunk-MPYL6HQR.mjs → chunk-STS7CL74.mjs} +1 -1
  25. package/dist/{chunk-A7HA64P6.mjs → chunk-TUWFD3AZ.mjs} +1 -1
  26. package/dist/chunk-UDLS46F5.mjs +1 -0
  27. package/dist/chunk-VZT7RCAC.mjs +4 -0
  28. package/dist/{chunk-76OM2ZBO.mjs → chunk-WOMYXKGW.mjs} +3 -3
  29. package/dist/{chunk-6NCRQ746.mjs → chunk-X3CZMXOZ.mjs} +1 -1
  30. package/dist/{chunk-BMMAZIUY.mjs → chunk-YFFHEYYK.mjs} +1 -1
  31. package/dist/chunk-YHUBO6K4.mjs +1 -0
  32. package/dist/{chunk-4HVQZC7R.mjs → chunk-YLV3KSNV.mjs} +1 -1
  33. package/dist/{chunk-2OCUKD3K.mjs → chunk-ZDOLKWQD.mjs} +1 -1
  34. package/dist/cli/index.js +254 -277
  35. package/dist/cli/index.mjs +183 -206
  36. package/dist/index.d.mts +4795 -1890
  37. package/dist/index.d.ts +4795 -1890
  38. package/dist/index.js +2 -2
  39. package/dist/index.mjs +2 -2
  40. package/package.json +1 -1
  41. package/dist/chunk-22PYMXSS.mjs +0 -1
  42. package/dist/chunk-52ZB3ZAG.mjs +0 -1
  43. package/dist/chunk-5YK2JKKH.mjs +0 -17
  44. package/dist/chunk-APBVAT7F.mjs +0 -1
  45. package/dist/chunk-EL7XOWA4.mjs +0 -1
  46. package/dist/chunk-GKDZ7663.mjs +0 -1
  47. package/dist/chunk-II74EBLQ.mjs +0 -1
  48. package/dist/chunk-JBAV2AQK.mjs +0 -1
  49. package/dist/chunk-LT2DQLXJ.mjs +0 -1
  50. package/dist/chunk-QUJ2IZXU.mjs +0 -1
  51. package/dist/chunk-WE3NRBO6.mjs +0 -1
  52. package/dist/chunk-YHY7Y4HD.mjs +0 -4
  53. package/dist/chunk-YQVQTVHK.mjs +0 -2
package/README.md CHANGED
@@ -58,6 +58,10 @@ develop, name its API, its sign-in host and its live connection together:
58
58
  `NPAYLOAD_API_URL`, `NPAYLOAD_AUTH_URL` and `NPAYLOAD_EDGE_URL`. The CLI reads
59
59
  your project's `.env` to see which deployment you are on, but dials only what
60
60
  the shell exports, so export them.
61
+ On npayload's production estate, with no auth host named, every `np`
62
+ command gets its token from the production API's own token door,
63
+ `https://api.npayload.com/oauth/token`; with another API and no auth
64
+ host named, from that API.
61
65
  - For a new project, `npx @npayload/sdk init --edge-url <url>` writes that live
62
66
  connection into its `.env`; a `.env` that already holds your credentials is
63
67
  kept as it is.
@@ -0,0 +1 @@
1
+ import{d as a,e as b,f as c,g as d}from"./chunk-6R2QLUWE.mjs";import"./chunk-MDW42OG6.mjs";import"./chunk-GG7UQYUV.mjs";import"./chunk-IH2OLS7G.mjs";import"./chunk-WOMYXKGW.mjs";import"./chunk-ZDOLKWQD.mjs";import"./chunk-CFM43QNN.mjs";import"./chunk-TQFAYJEP.mjs";import"./chunk-4NWQCPI4.mjs";import"./chunk-HX6PH7C3.mjs";import"./chunk-AGDMCMF3.mjs";import"./chunk-CJDCY2NH.mjs";import"./chunk-M7WGBUJ2.mjs";import"./chunk-XLK55DEY.mjs";import"./chunk-N6NIJISZ.mjs";import"./chunk-LCUELOEE.mjs";import"./chunk-OA73YMB6.mjs";import"./chunk-YFFHEYYK.mjs";import"./chunk-AECDYMA2.mjs";import"./chunk-VZT7RCAC.mjs";import"./chunk-GGXNXM73.mjs";import"./chunk-LJNU5QHZ.mjs";export{c as pullScopesIntoManifest,d as registerScopes,b as runScopesDiff,a as runScopesFix};
@@ -1,4 +1,4 @@
1
- import{a as i}from"./chunk-FAO3QJC5.mjs";import{a as n}from"./chunk-LJNU5QHZ.mjs";import{createHash as f}from"crypto";import{readFileSync as a,writeFileSync as c,existsSync as p}from"fs";function o(t){return f("sha256").update(t.join(`
1
+ import{a as i}from"./chunk-HX6PH7C3.mjs";import{a as n}from"./chunk-LJNU5QHZ.mjs";import{createHash as f}from"crypto";import{readFileSync as a,writeFileSync as c,existsSync as p}from"fs";function o(t){return f("sha256").update(t.join(`
2
2
  `)).digest("hex")}n(o,"permissionsContentHash");function d(t){let s=o(t),e=t.map(r=>` "${r}",`).join(`
3
3
  `);return`/**
4
4
  * GENERATED by \`npayload push\` (or \`npayload deploy\`) \u2014 DO NOT EDIT BY HAND.
@@ -0,0 +1,17 @@
1
+ import{Z as B}from"./chunk-CFM43QNN.mjs";import{b as W}from"./chunk-TQFAYJEP.mjs";import{f as F,i as H}from"./chunk-N6NIJISZ.mjs";import{a as R,e as N,f as q}from"./chunk-LCUELOEE.mjs";import{b as z,c as K}from"./chunk-OA73YMB6.mjs";import{b as j,f as Y}from"./chunk-AECDYMA2.mjs";import{ca as O}from"./chunk-VZT7RCAC.mjs";import{a as o}from"./chunk-LJNU5QHZ.mjs";import{existsSync as Z,readFileSync as le}from"fs";import{join as X}from"path";import i from"chalk";import d from"chalk";import se from"ora";var k=class{static{o(this,"Spinner")}instance;constructor(t){this.instance=se({text:t,isSilent:!process.stderr.isTTY})}start(t){return t&&(this.instance.text=t),this.instance.start(),this}succeed(t){this.instance.succeed(t)}fail(t){this.instance.fail(t)}warn(t){this.instance.warn(t)}info(t){this.instance.info(t)}stop(){this.instance.stop()}set text(t){this.instance.text=t}};function be(e){return new k(e).start()}o(be,"spin");var ie=new Set(["human","table","json","yaml","ndjson"]);function V(e){if(e===void 0)return"human";let t=e.toLowerCase();if(!ie.has(t))throw new Error(`Unknown --output "${e}". Use one of: human, table, json, yaml, ndjson.`);return t}o(V,"resolveOutputFormat");function f(e){return e===null||typeof e=="string"||typeof e=="number"||typeof e=="boolean"}o(f,"isScalar");function E(e){return e===null?"":String(e)}o(E,"scalarToString");function C(e){if(e==null)return"null";if(typeof e=="number"||typeof e=="boolean")return String(e);let t=String(e);return t===""||/[:#\-?,[\]{}&*!|>'"%@`]/.test(t)||/^\s|\s$/.test(t)||/^(true|false|null|~|\d)/i.test(t)?`"${t.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`:t}o(C,"yamlScalar");function P(e,t=0){let n=" ".repeat(t);if(f(e)||e===void 0)return`${n}${C(e)}`;if(Array.isArray(e))return e.length===0?`${n}[]`:e.map(a=>{if(f(a)||a===void 0)return`${n}- ${C(a)}`;let p=P(a,t+1).replace(/^ {2}/,"");return`${n}- ${p.replace(/^\s+/,"")}
2
+ ${P(a,t+1).split(`
3
+ `).slice(1).join(`
4
+ `)}`.trimEnd()}).join(`
5
+ `);let r=Object.entries(e);return r.length===0?`${n}{}`:r.map(([a,p])=>f(p)||p===void 0?`${n}${a}: ${C(p)}`:Array.isArray(p)&&p.length===0?`${n}${a}: []`:!Array.isArray(p)&&Object.keys(p).length===0?`${n}${a}: {}`:`${n}${a}:
6
+ ${P(p,t+1)}`).join(`
7
+ `)}o(P,"toYaml");function pe(e){if(e.length===0)return"(no rows)";let t=[];for(let s of e)for(let u of Object.keys(s))t.includes(u)||t.push(u);let n=o(s=>s==null?"":f(s)?E(s):JSON.stringify(s),"cell"),r=t.map(s=>Math.max(s.length,...e.map(u=>n(u[s]).length))),a=o(s=>s.map((u,b)=>u.padEnd(r[b])).join(" ").trimEnd(),"fmtRow"),p=a(t),c=r.map(s=>"-".repeat(s)).join(" "),h=e.map(s=>a(t.map(u=>n(s[u]))));return[p,c,...h].join(`
8
+ `)}o(pe,"toTable");function J(e,t){switch(t){case"json":return JSON.stringify(e,null,2);case"ndjson":return(Array.isArray(e)?e:[e]).map(n=>JSON.stringify(n)).join(`
9
+ `);case"yaml":return P(e);case"table":{let n=Array.isArray(e)?e:[e];return n.every(a=>a!==null&&typeof a=="object"&&!Array.isArray(a))?pe(n):P(e)}case"human":default:return T(e)}}o(J,"renderResult");function T(e,t=0){let n=" ".repeat(t);if(f(e)||e===void 0)return`${n}${e===void 0?"":E(e)}`;if(Array.isArray(e))return e.length===0?`${n}${d.dim("(none)")}`:e.map((p,c)=>`${n}${d.dim(`[${c}]`)}
10
+ ${T(p,t+1)}`).join(`
11
+ `);let r=Object.entries(e);if(r.length===0)return`${n}${d.dim("(empty)")}`;let a=Math.max(...r.map(([p])=>p.length));return r.map(([p,c])=>{let h=d.cyan(p.padEnd(a));return f(c)||c===void 0?`${n}${h} ${c===void 0?"":E(c)}`:`${n}${h}
12
+ ${T(c,t+1)}`}).join(`
13
+ `)}o(T,"renderHuman");var G=class{constructor(t){this.format=t;this.tty=t==="human"&&!!process.stderr.isTTY}static{o(this,"StepLog")}tty;spinner=null;lines=[];start(t){this.tty&&(this.spinner=new k(`\u25C9 ${t}`).start())}finish(t){if(this.lines.push(t),!this.tty)return;let n=t.message?d.dim(` (${t.message})`):"",r=`${t.label}${n}`;this.spinner?(t.status==="succeeded"?this.spinner.succeed(`\u2713 ${r}`):t.status==="failed"?this.spinner.fail(`\u2716 ${r}`):t.status==="skipped"?this.spinner.warn(`\u293F ${r}`):this.spinner.info(r),this.spinner=null):process.stderr.write(`${ce(t.status)} ${r}
14
+ `)}all(){return this.lines}hasFailure(){return this.lines.some(t=>t.status==="failed")}};function ce(e){switch(e){case"succeeded":return d.green("\u2713");case"failed":return d.red("\u2716");case"skipped":return d.yellow("\u293F");default:return d.cyan("\u25C9")}}o(ce,"glyph");var Le="__set_by_npayload_login__",we="__set_by_npayload_login__",xe="__set_by_npayload_login__";function D(e){if(e==null)return!0;let t=e.trim();return t.length===0?!0:t.startsWith("__set_by_npayload_login__")}o(D,"isPlaceholderCredential");var Q="4733cbf89a6b8a9c96c26de1b5df06bba969130890e64b8d404f8fe4ce6bca25",je={$schema:"http://json-schema.org/draft-07/schema#",title:"EventsConfig",type:"object",additionalProperties:!1,properties:{channels:{type:"object",maxProperties:500,propertyNames:{pattern:"^[a-z0-9][a-z0-9._-]{0,126}$"},additionalProperties:{type:"object",additionalProperties:!1,properties:{name:{type:"string",maxLength:4096},idempotencyKey:{type:"string",maxLength:4096},description:{type:"string",maxLength:4096},type:{type:"string",enum:["topic","queue","stream"]},schema:{type:"object",properties:{type:{type:"string",enum:["json","avro","protobuf"]},definition:{type:"string",maxLength:4096},strict:{type:"boolean"}},required:["type"],additionalProperties:!1},settings:{type:"object",properties:{retentionMs:{type:"number"},maxMessageSize:{type:"number"},maxSubscriptions:{type:"number"},idempotencyWindowMs:{type:"number"}},additionalProperties:!1},metadata:{type:"object",additionalProperties:{oneOf:[{type:"string",maxLength:4096},{type:"number"},{type:"boolean"},{type:"null"}]},propertyNames:{maxLength:256,not:{enum:["__proto__","constructor","prototype"]}}},retentionMode:{type:"string",enum:["standard","compacted","compacted_with_log"]},compactionConfig:{type:"object",properties:{minAge:{type:"number"},deletePolicy:{type:"string",enum:["compact","delete","compact_and_delete"]}},additionalProperties:!1},nppMinQos:{type:"number"},rateLimit:{type:"object",properties:{ratePerSec:{type:"number"},burst:{type:"number"}},required:["ratePerSec","burst"],additionalProperties:!1},complianceClass:{type:"string",enum:["NONE","SOC2","GDPR","HIPAA","PCI","FEDRAMP_MOD","FEDRAMP_HIGH","IL5","ITAR"]},privacy:{type:"object",properties:{mode:{type:"string",enum:["standard","e2e","hybrid"]},encryptionProvider:{type:"string",enum:["none","publisher","platform"]}},required:["mode","encryptionProvider"],additionalProperties:!1},privacyMode:{type:"string",enum:["standard","hybrid","e2e"]},pii:{type:"string",enum:["strip","allow","block"]}},required:["name"]}},consumerGroups:{type:"object",maxProperties:500,propertyNames:{pattern:"^[a-z0-9][a-z0-9._-]{0,126}$"},additionalProperties:{type:"object",additionalProperties:!1,properties:{channelGid:{type:"string",maxLength:4096},strategy:{type:"string",enum:["competing","sticky","broadcast"]},maxConcurrency:{type:"number"}},required:["strategy"]}},eventTypes:{type:"object",maxProperties:500,propertyNames:{pattern:"^[a-z0-9][a-z0-9._-]{0,126}$"},additionalProperties:{type:"object",additionalProperties:!1,properties:{displayName:{type:"string",maxLength:4096},description:{type:"string",maxLength:4096},domain:{type:"string",maxLength:4096},entity:{type:"string",maxLength:4096},action:{type:"string",maxLength:4096},ownership:{type:"object",properties:{team:{type:"string",maxLength:4096},contact:{type:"string",maxLength:4096},slackChannel:{type:"string",maxLength:4096}},required:["team","contact"],additionalProperties:!1},channels:{type:"array",items:{type:"string",maxLength:4096}},tags:{type:"array",items:{type:"string",maxLength:4096}},schema:{type:"object",properties:{format:{type:"string",enum:["json_schema","avro","protobuf"]},definition:{type:"string",maxLength:4096}},required:["format","definition"],additionalProperties:!1}},required:["displayName","description","ownership"]}},exchanges:{type:"object",maxProperties:500,propertyNames:{pattern:"^[a-z0-9][a-z0-9._-]{0,126}$"},additionalProperties:{type:"object",additionalProperties:!1,properties:{type:{type:"string",enum:["direct","fanout","topic","headers"]},config:{type:"object",properties:{headersMatchMode:{}},additionalProperties:!1}}}},subscriptions:{type:"object",maxProperties:500,propertyNames:{pattern:"^[a-z0-9][a-z0-9._-]{0,126}$"},additionalProperties:{type:"object",additionalProperties:!1,properties:{channelGid:{type:"string",maxLength:4096},subscribesTo:{type:"string",enum:["messages","failures"]},idempotencyKey:{type:"string",maxLength:4096},consumerAppId:{type:"string",maxLength:4096},description:{type:"string",maxLength:4096},type:{type:"string",enum:["webhook","queue","adapter"]},filter:{type:"object",properties:{where:{type:"object",additionalProperties:{oneOf:[{type:"string",maxLength:4096},{type:"number"},{type:"boolean"}]},propertyNames:{maxLength:256,not:{enum:["__proto__","constructor","prototype"]}}},routingKey:{type:"string",maxLength:4096},subject:{type:"string",maxLength:4096}},additionalProperties:!1},subjectFilter:{type:"string",maxLength:4096},endpoint:{type:"object",properties:{url:{type:"string",format:"npayload-safe-url",maxLength:4096},method:{type:"string",enum:["POST","PUT"]},headers:{type:"object",additionalProperties:{type:"string",pattern:"^[^\\r\\n]*$",maxLength:4096},propertyNames:{pattern:"^[A-Za-z0-9!#$%&'*+.^_`|~-]{1,128}$"}},queueName:{type:"string",maxLength:4096}},additionalProperties:!1},delivery:{type:"object",properties:{timeoutMs:{type:"number"},retryPolicy:{type:"object",properties:{maxAttempts:{type:"number"},backoffStrategy:{type:"string",enum:["exponential","linear","constant"]},initialDelayMs:{type:"number"},maxDelayMs:{type:"number"},backoffMultiplier:{type:"number"}},additionalProperties:!1},batchSize:{type:"number"},batchWindowMs:{type:"number"}},additionalProperties:!1},dlq:{type:"object",properties:{enabled:{type:"boolean"},maxAge:{type:"number"}},required:["enabled"],additionalProperties:!1},deliveryConfig:{type:"object",properties:{maxPerMinute:{type:"number"}},additionalProperties:!1},metadata:{type:"object",additionalProperties:{oneOf:[{type:"string",maxLength:4096},{type:"number"},{type:"boolean"},{type:"null"}]},propertyNames:{maxLength:256,not:{enum:["__proto__","constructor","prototype"]}}},transformPipeId:{type:"string",maxLength:4096},transformTimeout:{type:"number"},transformOnFailure:{type:"string",enum:["deliver_raw","drop_to_dlq"]}},required:["endpoint"]}}}};async function ee(e,t){try{let n=new URL("/health",e);return await j(N())(n,{signal:AbortSignal.timeout(2500)}),"reachable"}catch(n){return n instanceof O?(t.push(n),"refused"):"unreachable"}}o(ee,"reachable");async function ue(e,t){let n;try{n=await j(N())(e,{method:"POST",headers:{"content-type":"application/x-www-form-urlencoded"},body:"grant_type=client_credentials",signal:AbortSignal.timeout(2500)})}catch(c){return c instanceof O?(t.push(c),{probe:"refused"}):{probe:"unreachable"}}let r;try{r=await n.json()}catch{r=void 0}let a=typeof r=="object"&&r!==null?r.error:void 0;return{probe:(n.status===400||n.status===401)&&typeof a=="string"&&a.length>0?"reachable":"not-a-token-endpoint",status:n.status}}o(ue,"tokenEndpointProbe");function de(){let e=process.env.npm_config_user_agent??"";return e.startsWith("bun")?"bun":e.startsWith("pnpm")?"pnpm":e.startsWith("yarn")?"yarn":e.startsWith("npm")?"npm":process.env.BUN_INSTALL?"bun":"unknown"}o(de,"detectPackageManager");function me(){switch(process.platform){case"darwin":return"macOS Keychain";case"win32":return"Windows Credential Manager";case"linux":return"Linux Secret Service (libsecret)";default:return`${process.platform} (unsupported)`}}o(me,"keychainBackend");async function he(){let e=await z(),t=!1;if(e)try{let m=await K();t=!!(m?.clientId&&m?.hmacSecret)}catch{t=!1}let n=!!process.env.NPAYLOAD_TOKEN,r=!!(process.env.NPAYLOAD_CLIENT_ID&&(process.env.NPAYLOAD_CLIENT_SECRET||process.env.NPAYLOAD_HMAC_SECRET)),a=W(),p=!!(a?.clientId&&a?.hmacSecret&&!D(a.clientId)&&!D(a.hmacSecret)),c=t||n||r||p,h=[];(process.env.NPAYLOAD_CLIENT_SECRET||process.env.NPAYLOAD_HMAC_SECRET)&&h.push("A client secret is set in the environment. Prefer a short-lived NPAYLOAD_TOKEN, source it from a secret manager, and never commit it to a .env file.");let s=[];c||(e||s.push(process.platform==="linux"?"No OS keychain: install and start a Secret Service (e.g. `gnome-keyring` or KWallet).":"OS keychain is not reachable on this host."),s.push("In a project: run `npx @npayload/sdk init` (provisions machine credentials into .npayload.json).","Interactive: run `npayload login` (stores the session in the OS keychain).","Headless / CI: export NPAYLOAD_CLIENT_ID + NPAYLOAD_CLIENT_SECRET (or NPAYLOAD_TOKEN)."));let u=!1,b=R(process.env.NPAYLOAD_API_URL,"apiUrl")??"https://api.npayload.com",y=R(process.env.NPAYLOAD_AUTH_URL,"authUrl")??null,_=[],x=await ee(b,_),$=y?await ee(y,_):null,A=Y({authUrl:q().authUrl}),g=await ue(A,_),te=x==="reachable",ne=$===null?null:$==="reachable",re=g.probe==="reachable";for(let m of _)s.push(F(`Not probed: ${m.message}`,m));x==="unreachable"&&s.push(`API endpoint ${b} is unreachable \u2014 check your network / status page.`),y&&$==="unreachable"&&s.push(`Auth endpoint ${y} is unreachable \u2014 token minting will fail until it is back.`);let I=y?"Check the auth host NPAYLOAD_AUTH_URL names, or unset it so the CLI gets its token from the API it calls.":"Check your network and npayload's status page.";g.probe==="unreachable"?s.push(`Token endpoint ${A} is unreachable, so no command can get its access token. ${I}`):g.probe==="not-a-token-endpoint"&&s.push(`Token endpoint ${A} answered HTTP ${g.status} but is not a token endpoint, so no command can get its access token. ${I}`);let L="n/a",M=X(process.cwd(),"npayload","_generated","contract.lock");if(Z(M)){try{L=JSON.parse(le(M,"utf8")).hash===Q?"ok":"stale"}catch{L="stale"}L==="stale"&&s.push("npayload/_generated/contract.lock disagrees with the installed npayload contract \u2014 this project was authored against a different version; re-run `npayload validate` after upgrading (or reinstall the pinned version).")}let S="n/a";try{let m=B(),U=X(m,"..","permissions.generated.ts"),{projectAllPermissions:ae}=await import("./chunk-7IFTQ52O.mjs"),{checkScopesDrift:oe}=await import("./chunk-TUWFD3AZ.mjs"),w=oe(await ae(),U);S=w.ok?"ok":Z(U)?"stale":"missing",!w.ok&&w.reason&&s.push(w.reason)}catch{S="n/a"}return{os:process.platform,arch:process.arch,node:process.version,packageManager:de(),keychain:{reachable:e,backend:me()},credentials:{envToken:n,envClient:r,project:p,keychain:t},authReady:c,stack:{apiUrl:b,apiReachable:te,apiProbe:x,authUrl:y,authReachable:ne,authProbe:$,mintUrl:A,mintReachable:re,mintProbe:g.probe,contractLock:L,permissions:S},warnings:h,remediation:s}}o(he,"buildReport");function v(e){return e==="reachable"?i.green("reachable"):e==="not-a-token-endpoint"?i.red("answered, but is not a token endpoint"):e==="refused"?i.yellow("refused by this run's estate (TRANSPORT_UNAVAILABLE)"):i.red("unreachable")}o(v,"probeWords");function l(e){return e?i.green("\u2713"):i.dim("\u25CB")}o(l,"mark");function ye(e){let t=["",i.bold(" npayload doctor"),""];t.push(` ${i.dim("platform")} ${e.os} ${e.arch} \xB7 node ${e.node} \xB7 pm ${e.packageManager}`),t.push(` ${l(e.keychain.reachable)} ${i.dim("keychain")} ${e.keychain.backend} \u2014 ${e.keychain.reachable?i.green("reachable"):i.yellow("not reachable")}`),t.push(""),t.push(` ${i.bold("credentials")}`),t.push(` ${l(e.credentials.project)} project credentials (.npayload.json)`),t.push(` ${l(e.credentials.keychain)} login session in OS keychain`),t.push(` ${l(e.credentials.envClient)} NPAYLOAD_CLIENT_ID + NPAYLOAD_CLIENT_SECRET (env)`),t.push(` ${l(e.credentials.envToken)} NPAYLOAD_TOKEN (env, short-lived)`),t.push(""),t.push(` ${i.bold("stack")}`),t.push(` ${l(e.stack.apiReachable)} API ${i.dim(e.stack.apiUrl)} \u2014 ${v(e.stack.apiProbe)}`),e.stack.authUrl&&e.stack.authProbe!==null&&t.push(` ${l(e.stack.authReachable===!0)} auth ${i.dim(e.stack.authUrl)} \u2014 ${v(e.stack.authProbe)}`),t.push(` ${l(e.stack.mintReachable)} token endpoint ${i.dim(e.stack.mintUrl)} \u2014 ${v(e.stack.mintProbe)}`),e.stack.contractLock!=="n/a"&&t.push(` ${l(e.stack.contractLock==="ok")} contract.lock \u2014 ${e.stack.contractLock}`),e.stack.permissions!=="n/a"&&t.push(` ${l(e.stack.permissions==="ok")} permissions.generated.ts \u2014 ${e.stack.permissions}`),t.push("");let n=!e.stack.apiReachable||e.stack.authReachable===!1,r=e.stack.apiProbe==="refused"||e.stack.authProbe==="refused"||e.stack.mintProbe==="refused";e.authReady?r?t.push(` ${i.yellow("! credentials present, but this run's estate refused a probe \u2014 see next")}`):n?t.push(` ${i.yellow("! credentials present, but the stack is unreachable \u2014 see next")}`):e.stack.mintReachable?t.push(` ${i.green("\u2713 ready \u2014 credentials present and the stack is reachable")}`):t.push(` ${i.yellow("! credentials present, but no access token can be minted. See next.")}`):t.push(` ${i.red("\u2716 no credential source available")}`);for(let a of e.warnings)t.push(i.yellow(` ! ${a}`));if(e.remediation.length){t.push(""),t.push(` ${i.bold("next")}`);for(let a of e.remediation)t.push(i.dim(` \u2022 ${a}`))}return t.push(""),t.join(`
15
+ `)}o(ye,"renderHuman");function Be(e){e.command("doctor").description("diagnose OS / package manager / keychain reachability, which credential source is available, and the API and token endpoints").option("--output <fmt>","human | table | json | yaml | ndjson").action(async t=>{try{let n=V(t.output),r=await he();n==="human"?process.stdout.write(ye(r)+`
16
+ `):process.stdout.write(`${J(r,n)}
17
+ `);let a=r.stack.authReachable===!1;(!r.authReady||!r.stack.apiReachable||a||!r.stack.mintReachable)&&(process.exitCode=1)}catch(n){H(n)}})}o(Be,"registerDoctor");export{k as a,be as b,Le as c,we as d,xe as e,D as f,V as g,J as h,G as i,Q as j,je as k,he as l,Be as m};
@@ -1,4 +1,4 @@
1
- import{b as P,c as R}from"./chunk-MDW42OG6.mjs";import{a as b}from"./chunk-6RMN6EHY.mjs";import{a as y,b as G}from"./chunk-RIBBVOCC.mjs";import{g as x,k as g,l as h,o as m,p as w}from"./chunk-6ZOPXG44.mjs";import{f as S}from"./chunk-UMQ2SWSM.mjs";import{a as c}from"./chunk-LJNU5QHZ.mjs";import{readFileSync as _,writeFileSync as D}from"fs";import a from"chalk";import{existsSync as u,readFileSync as $,watch as j}from"fs";import{resolve as C,join as d}from"path";function L(o){if(o){let e=C(process.cwd(),o);return u(e)?[e]:[]}let t=[];for(let e of["events","primus","pipes"])for(let n of[d("npayload",`${e}.config.ts`),`${e}.config.ts`]){let r=d(process.cwd(),n);u(r)&&t.push(r)}return t}c(L,"findAllConfigs");function I(o,t){if(u(o))try{for(let e of $(o,"utf8").split(`
1
+ import{b as P,c as R}from"./chunk-MDW42OG6.mjs";import{a as b}from"./chunk-GG7UQYUV.mjs";import{a as y,b as G}from"./chunk-IH2OLS7G.mjs";import{g as x,k as g,l as h,o as m,p as w}from"./chunk-CFM43QNN.mjs";import{f as S}from"./chunk-N6NIJISZ.mjs";import{a as c}from"./chunk-LJNU5QHZ.mjs";import{readFileSync as _,writeFileSync as D}from"fs";import a from"chalk";import{existsSync as u,readFileSync as $,watch as j}from"fs";import{resolve as C,join as d}from"path";function L(o){if(o){let e=C(process.cwd(),o);return u(e)?[e]:[]}let t=[];for(let e of["events","primus","pipes"])for(let n of[d("npayload",`${e}.config.ts`),`${e}.config.ts`]){let r=d(process.cwd(),n);u(r)&&t.push(r)}return t}c(L,"findAllConfigs");function I(o,t){if(u(o))try{for(let e of $(o,"utf8").split(`
2
2
  `)){let n=e.trim();if(!n||n.startsWith("#"))continue;let r=n.indexOf("=");if(!(r===-1||n.slice(0,r).trim()!==t))return n.slice(r+1).trim().replace(/^["']|["']$/g,"")}}catch{}}c(I,"readEnvVar");function v(o){if(o)return o;let t=process.env.NPAYLOAD_APP_ID?.trim();if(t)return t;for(let e of[d(process.cwd(),".env"),d(process.cwd(),"npayload",".env")]){let n=I(e,"NPAYLOAD_APP_ID");if(n)return n}for(let e=process.cwd(),n=0;n<5;n++){let r=d(e,".npayload.json");if(u(r))try{let i=JSON.parse($(r,"utf8"));if(typeof i.appId=="string"&&i.appId.trim())return i.appId.trim()}catch{}let s=d(e,"..");if(s===e)break;e=s}}c(v,"resolveAppGid");function M(o,t,e=300,n){let r=null,s=c(()=>{r&&clearTimeout(r),r=setTimeout(()=>void t("change"),e)},"bump"),i=o.map(p=>j(p,s)),f=new Promise(p=>{process.on("SIGINT",()=>p())});return n===void 0?f:Promise.race([f,n.ended]).catch(p=>{r&&clearTimeout(r);for(let l of i)l.close();throw p})}c(M,"watchConfigs");function k(o,t){return{...o!==void 0?{cwd:o}:{},components:t}}c(k,"floorOptions");function A(o,t){let e=x(o);e.length!==0&&t?.(a.dim(` (declared component(s) not embeddable \u2014 they contribute no scope: ${e.join(", ")})
3
3
  `))}c(A,"reportInertComponents");async function F(o={}){let t=m(o.cwd),e=t?.path??w(o.cwd);if(!t||!e)throw new Error("no npayload.toml found \u2014 `np scopes fix` needs a manifest with an [access_scopes] block.");h(t.accessScopes);let n=o.floor??await y(k(o.cwd,t.embedComponents));A(t.embedComponents,o.log);let r=G(t.accessScopes,n),s=r.filter(l=>g(l)),i=r.filter(l=>!g(l));if(i.length>0&&o.log?.(a.dim(` (skipped ${i.length} non-catalog projection scope(s) \u2014 not declarable in [access_scopes]: ${i.join(", ")})
4
4
  `)),s.length===0)return o.log?.(a.dim(` [access_scopes] already covers the projected floor \u2014 nothing to add.
@@ -15,6 +15,6 @@ import{b as P,c as R}from"./chunk-MDW42OG6.mjs";import{a as b}from"./chunk-6RMN6
15
15
  `));break;case"sync":i(a.green(`\u2713 [access_scopes] covers the floor and matches the remote grant (${s.grant.length} scope(s)).
16
16
  `));break;case"accept-remote":i(a.green(`\u2713 resolvable via --accept-remote.
17
17
  `));break}return s}c(T,"runScopesDiff");async function Z(o){let t=m(o.cwd),e=t?.path??w(o.cwd);if(!t||!e)return null;let n=o.appGid??v();if(!n)return null;let r=await o.readRemoteGrant(n);if(!r)return null;let s=[...new Set(r.scopes)].sort(),i=P(_(e,"utf8"),s);return D(e,i,"utf8"),o.log?.(a.green(`\u2713 pulled ${s.length} scope(s) from the remote grant into [access_scopes].
18
- `)),{written:s,path:e}}c(Z,"pullScopesIntoManifest");async function E(o){let{restoreSession:t}=await import("./chunk-QUJ2IZXU.mjs"),e=await t();return e?e.getOacGrant(o):null}c(E,"sessionGrantReader");function ee(o){let t=o.command("scopes").description("Scopes-as-code: inspect and reconcile the manifest's [access_scopes] against the floor + the remote grant");t.command("diff").description("Show the floor gap + manifest\u21C4remote drift for [access_scopes]. Exit 0 in sync, 2 with a gap/conflict, 1 on error.").action(async()=>{try{let e=await T({readRemoteGrant:E});process.exit(e.kind==="sync"||e.kind==="accept-remote"?0:2)}catch(e){process.stderr.write(a.red(`${S(`scopes diff failed: ${e instanceof Error?e.message:String(e)}`,e)}
18
+ `)),{written:s,path:e}}c(Z,"pullScopesIntoManifest");async function E(o){let{restoreSession:t}=await import("./chunk-7QTR5IWG.mjs"),e=await t();return e?e.getOacGrant(o):null}c(E,"sessionGrantReader");function ee(o){let t=o.command("scopes").description("Scopes-as-code: inspect and reconcile the manifest's [access_scopes] against the floor + the remote grant");t.command("diff").description("Show the floor gap + manifest\u21C4remote drift for [access_scopes]. Exit 0 in sync, 2 with a gap/conflict, 1 on error.").action(async()=>{try{let e=await T({readRemoteGrant:E});process.exit(e.kind==="sync"||e.kind==="accept-remote"?0:2)}catch(e){process.stderr.write(a.red(`${S(`scopes diff failed: ${e instanceof Error?e.message:String(e)}`,e)}
19
19
  `)),process.exit(1)}}),t.command("fix").description("Append exactly the projected-floor gap to the manifest's [access_scopes] (idempotent)").action(async()=>{try{await F({log:c(e=>process.stdout.write(e),"log")}),process.exit(0)}catch(e){process.stderr.write(a.red(`scopes fix failed: ${e instanceof Error?e.message:String(e)}
20
20
  `)),process.exit(1)}})}c(ee,"registerScopes");export{L as a,v as b,M as c,F as d,T as e,Z as f,ee as g};
@@ -0,0 +1 @@
1
+ import{a}from"./chunk-ZDOLKWQD.mjs";import"./chunk-CFM43QNN.mjs";import"./chunk-TQFAYJEP.mjs";import"./chunk-4NWQCPI4.mjs";import"./chunk-HX6PH7C3.mjs";import"./chunk-AGDMCMF3.mjs";import"./chunk-CJDCY2NH.mjs";import"./chunk-M7WGBUJ2.mjs";import"./chunk-XLK55DEY.mjs";import"./chunk-N6NIJISZ.mjs";import"./chunk-LCUELOEE.mjs";import"./chunk-OA73YMB6.mjs";import"./chunk-YFFHEYYK.mjs";import"./chunk-AECDYMA2.mjs";import"./chunk-VZT7RCAC.mjs";import"./chunk-GGXNXM73.mjs";import"./chunk-LJNU5QHZ.mjs";export{a as projectAllPermissions};
@@ -0,0 +1 @@
1
+ import{i as a,j as b,k as c,l as d,m as e}from"./chunk-K3YY77PG.mjs";import"./chunk-LCUELOEE.mjs";import"./chunk-OA73YMB6.mjs";import"./chunk-ONTNXGOM.mjs";import"./chunk-YFFHEYYK.mjs";import"./chunk-AECDYMA2.mjs";import"./chunk-VZT7RCAC.mjs";import"./chunk-GGXNXM73.mjs";import"./chunk-LJNU5QHZ.mjs";export{a as CliSession,e as appCreateRefusalMessage,d as deviceLogin,b as restoreSession,c as verificationPage};
@@ -0,0 +1 @@
1
+ import{S as h,V as g,W as m,Y as U,Z as k,_ as b,aa as E,ca as u,ka as T,w as R}from"./chunk-VZT7RCAC.mjs";import{a as r}from"./chunk-LJNU5QHZ.mjs";var A=class e{constructor(n,t){this.estate=n;this.cureFor=t}static{r(this,"DialGuard")}get production(){return this.estate.other===void 0}refusal(n){let t=U(this.estate,n);return t===void 0?void 0:`${t}. ${this.cureFor(g(n))}`}noEdge(){let n=b(this.estate);return n===void 0?void 0:`${n}. ${this.cureFor("edge")}`}checkPages(...n){for(let t of n){let a=k(this.estate,t);if(a!==void 0)throw new u(y(`${a}. ${this.cureFor(g(t))}`))}}check(...n){for(let t of n){let a=this.refusal(t);if(a!==void 0)throw new u(y(a))}}with(n){return new e(m([...this.estate.named.map(t=>[t.source,t.url]),...n]),this.cureFor)}};function C(e,n){return E(t=>e.refusal(t),t=>new u(y(t)),n)}r(C,"guardedFetch");var D=Symbol("npayload.dial.refusal");function K(e){let n=new Error(e.message);return n.name="AbortError",n[D]=e,n}r(K,"carried");function $(e){return e instanceof Error?e[D]:void 0}r($,"refusalCarriedBy");function y(e){return e.charAt(0).toUpperCase()+e.slice(1)}r(y,"capitalised");var f=new WeakMap;function j(e){return f.get(e)?.guard}r(j,"guardOf");function H(e){return f.get(e)?.tokenUrl}r(H,"tokenUrlOf");function L(e){return f.get(e)?.apiUrl}r(L,"apiUrlOf");function v(e){return`${(e.authUrl??e.baseUrl??h).replace(/\/+$/,"")}/oauth/token`}r(v,"tokenEndpointOf");function F(e,n){let t=n.path;for(let[a,d]of Object.entries(n.pathParams??{}))t=t.replace(`{${a}}`,encodeURIComponent(d));return e.replace(/\/+$/,"")+t}r(F,"requestUrl");function S(e,n){let t=C(n),a,d={fetch:r(async o=>{try{return await t(o.url,{method:o.method,headers:o.headers,body:o.body??null,...o.signal!==void 0?{signal:o.signal}:{},...a!==void 0?{dispatcher:a}:{}})}catch(i){throw i instanceof u?K(i):I(i)}},"fetch")},s=new R({config:{...e,httpClient:d}});a=s.dispatcher;let p=v(e),w=e.baseUrl??h;f.set(s,{guard:n,tokenUrl:p,apiUrl:w});let c=s.auth;if(c!==void 0&&typeof c.getAccessToken=="function"){let o=c;typeof o.fetchImpl=="function"&&(o.fetchImpl=C(n,o.fetchImpl));let i=c.getAccessToken.bind(c);c.getAccessToken=async l=>(n.check(p),i(l))}if(typeof s.send=="function"){let o=s.send.bind(s);s.send=(async i=>{n.check(p,F(w,i));try{return await o(i)}catch(l){throw $(l)??l}})}return s}r(S,"dialKernel");function I(e){if(!(e instanceof TypeError))return e;let n=e.cause,t=n instanceof Error?n.message:typeof n=="string"?n:void 0;return t===void 0||t===""||e.message.includes(t)?e:new TypeError(`${e.message}: ${t}`,{cause:n})}r(I,"withDialReason");function _(e){if(e instanceof u)throw e}r(_,"rethrowRefusal");function N(e,n){T(e,t=>n.refusal(t))}r(N,"guardTransport");export{A as a,C as b,j as c,H as d,L as e,v as f,S as g,_ as h,N as i};