prismic 1.29.0 → 1.30.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.
package/dist/index.mjs CHANGED
@@ -1,11 +1,11 @@
1
1
  #!/usr/bin/env node
2
- import{n as e,t}from"./package-CR69YEZ6.mjs";import{$ as n,A as r,At as i,B as a,Bt as o,C as s,Ct as c,D as l,Dt as u,E as d,Et as f,F as p,Ft as m,G as h,Gt as g,H as _,Ht as v,I as y,It as b,J as x,Jt as S,K as C,Kt as ee,L as w,Lt as T,M as te,Mt as ne,N as E,Nt as re,O as ie,Ot as ae,P as oe,Pt as se,Q as ce,Qt as le,R as D,Rt as ue,S as O,St as de,T as fe,Tt as pe,U as k,Ut as me,V as he,Vt as ge,W as _e,Wt as ve,X as ye,Xt as be,Y as xe,Yt as A,Z as Se,Zt as Ce,_n as we,_t as Te,a as Ee,an as De,at as Oe,b as ke,bt as Ae,c as j,cn as je,ct as Me,dn as Ne,dt as Pe,en as M,et as Fe,f as Ie,ft as Le,g as Re,gn as ze,gt as Be,h as Ve,hn as N,ht as He,i as Ue,in as We,it as Ge,j as Ke,jt as qe,k as Je,kt as Ye,l as P,ln as Xe,lt as Ze,m as Qe,mn as $e,mt as et,n as tt,nn as nt,nt as rt,o as it,on as at,ot as F,p as ot,pn as I,pt as st,q as ct,qt as L,r as lt,rn as ut,rt as dt,sn as ft,st as pt,tn as mt,tt as ht,un as gt,ut as _t,v as vt,vt as yt,w as bt,wt as xt,x as R,xt as St,y as Ct,yt as wt,z as Tt,zt as Et}from"./adapters-C-tqRizJ.mjs";import{C as Dt,D as Ot,E as kt,H as At,K as jt,M as z,N as B,O as V,R as Mt,S as Nt,T as Pt,X as H,Y as Ft,_ as It,c as Lt,d as Rt,f as zt,i as Bt,it as Vt,j as Ht,k as Ut,l as U,o as Wt,p as W,q as G,t as Gt,u as Kt,v as qt,w as K,x as Jt}from"./packageJson-Du_fIYqH.mjs";import{t as Yt}from"./update-notifier-BGQNWIvh.mjs";import{isDeepStrictEqual as Xt,parseArgs as Zt}from"node:util";import{realpath as Qt,rm as $t}from"node:fs/promises";import{fileURLToPath as en,pathToFileURL as tn}from"node:url";import{createHash as nn,randomBytes as rn}from"node:crypto";import{setTimeout as an}from"node:timers/promises";const on=G({error:At(`invalid_auth_context`)});function sn(e){return e instanceof V&&Vt(on,e.body).success}const cn={expired:`The login code expired. Run the command again.`,declined:`The login was declined in the browser.`,"email-unverified":`Prismic sent you an email to verify your address. Verify it, then run the command again.`,"invalid-grant":`The login code was already used or isn't valid. Run the command again.`,unavailable:`Can't reach the Prismic login service. Check your connection, then run the command again.`};async function ln(e){if(e instanceof je)return e.reason===`misconfigured`?`Login isn't set up correctly for ${await h()} (${e.detail}). Report this: https://github.com/prismicio/cli/issues`:cn[e.reason];if(e instanceof V||e instanceof K)return await C().catch(()=>void 0)?I.PRISMIC_TOKEN?sn(e)?"This token cannot run administrative commands. Unset PRISMIC_TOKEN and run `prismic login`.":`PRISMIC_TOKEN is invalid or expired, or doesn't have access to this repository. Unset it to log in with a browser, or replace it with a valid token.`:e instanceof V?"Your session is invalid or expired. Run `prismic login` to sign in again.":`You do not have access to this repository. Check the repository name or log in with an account that has access.`:"Not logged in. Run `prismic login` first.";if(e instanceof Pt)return`Can't reach Prismic. Check your connection, then run the command again.`;if(e instanceof Dt||e instanceof Ut){let t=new URL(e.response.url);t.search=``;let n=e.message?`${e.message}\n\n`:``;return le`
2
+ import{n as e,t}from"./package-DZJSt_MI.mjs";import{$ as n,$t as r,A as i,At as a,B as o,Bt as s,C as c,Ct as l,D as u,Dt as d,E as f,Et as p,F as m,Ft as h,G as g,Gt as _,H as v,Ht as y,I as b,It as ee,J as x,Jt as S,K as C,Kt as w,L as te,Lt as ne,M as re,Mt as ie,N as T,Nt as ae,O as oe,Ot as se,P as ce,Pt as le,Q as ue,Qt as de,R as E,Rt as D,S as O,St as fe,T as pe,Tt as me,U as k,Ut as he,V as ge,Vt as _e,W as ve,Wt as ye,X as be,Xt as A,Y as xe,Yt as j,Z as Se,Zt as Ce,_n as we,_t as Te,a as Ee,an as De,at as Oe,b as ke,bt as Ae,c as M,cn as je,ct as Me,dn as Ne,dt as Pe,et as Fe,f as Ie,fn as Le,ft as Re,g as ze,gn as N,gt as Be,h as Ve,hn as He,ht as Ue,i as We,in as Ge,it as Ke,j as qe,jt as Je,k as Ye,kt as Xe,l as P,ln as Ze,lt as Qe,m as $e,mn as F,mt as et,n as tt,nn as nt,nt as rt,o as it,on as at,ot,p as st,pt as ct,q as lt,qt as ut,r as I,rn as dt,rt as ft,sn as pt,st as mt,tn as L,tt as ht,un as gt,ut as _t,v as vt,vn as yt,vt as bt,w as xt,wt as St,x as R,xt as Ct,y as wt,yt as Tt,z as Et,zt as Dt}from"./adapters-DWhQeyDo.mjs";import{C as Ot,D as kt,E as At,J as z,M as B,N as jt,O as V,P as H,S as Mt,T as Nt,U as Pt,X as Ft,Z as U,_ as It,at as Lt,c as Rt,d as zt,f as Bt,i as Vt,j as Ht,k as Ut,l as W,o as Wt,p as G,q as Gt,t as Kt,u as qt,v as Jt,w as K,x as Yt,z as Xt}from"./packageJson-BEVwXn1i.mjs";import{t as Zt}from"./update-notifier-B86qEI1j.mjs";import{isDeepStrictEqual as Qt,parseArgs as $t}from"node:util";import{realpath as en,rm as tn}from"node:fs/promises";import{fileURLToPath as nn,pathToFileURL as rn}from"node:url";import{createHash as an,randomBytes as on}from"node:crypto";import{setTimeout as sn}from"node:timers/promises";const cn=z({error:Pt(`invalid_auth_context`)});function ln(e){return e instanceof V&&Lt(cn,e.body).success}const un={expired:`The login code expired. Run the command again.`,declined:`The login was declined in the browser.`,"email-unverified":`Prismic sent you an email to verify your address. Verify it, then run the command again.`,"invalid-grant":`The login code was already used or isn't valid. Run the command again.`,unavailable:`Can't reach the Prismic login service. Check your connection, then run the command again.`};async function dn(e){if(e instanceof Ze)return e.reason===`misconfigured`?`Login isn't set up correctly for ${await g()} (${e.detail}). Report this: https://github.com/prismicio/cli/issues`:un[e.reason];if(e instanceof V||e instanceof K)return await C().catch(()=>void 0)?F.PRISMIC_TOKEN?ln(e)?"This token cannot run administrative commands. Unset PRISMIC_TOKEN and run `prismic login`.":`PRISMIC_TOKEN is invalid or expired, or doesn't have access to this repository. Unset it to log in with a browser, or replace it with a valid token.`:e instanceof V?"Your session is invalid or expired. Run `prismic login` to sign in again.":`You do not have access to this repository. Check the repository name or log in with an account that has access.`:"Not logged in. Run `prismic login` first.";if(e instanceof Nt)return`Can't reach Prismic. Check your connection, then run the command again.`;if(e instanceof Ot||e instanceof Ut){let t=new URL(e.response.url);t.search=``;let n=e.message?`${e.message}\n\n`:``;return r`
3
3
  ${n}Prismic responded with an unexpected error. Try again, and report it if it keeps happening.
4
4
 
5
5
  Status: ${e.status} ${e.statusText}
6
6
  URL: ${t}
7
7
  Report: https://github.com/prismicio/cli/issues
8
- `}if(e instanceof Error)return le(e.message)}const un=I.PRISMIC_SYNC_POLL_MS??5e3;var dn=S({name:`prismic dev`,description:`
8
+ `}if(e instanceof Error)return r(e.message)}const fn=F.PRISMIC_SYNC_POLL_MS??5e3;var pn=j({name:`prismic dev`,description:`
9
9
  Edit local content types and slices visually in the Type Builder.
10
10
 
11
11
  Type Builder changes are saved to local files, and local file changes
@@ -15,40 +15,40 @@ import{n as e,t}from"./package-CR69YEZ6.mjs";import{$ as n,A as r,At as i,B as a
15
15
  background and give the user the URL from its "Type Builder:" line.
16
16
 
17
17
  @experimental - This command may change or be removed in any release and does not follow semver.
18
- `,options:{repo:{type:`string`,short:`r`,description:`Repository or environment domain`},continue:{type:`boolean`,description:`Continue the previous session`},new:{type:`boolean`,description:`Start a new session, even if the previous one has unpulled changes`},"no-browser":{type:`boolean`,description:`Skip opening the Type Builder in the browser`}}},async({values:e})=>{Ce(e,[`continue`,`new`]);let t=await P(),{repo:n=await t.getEnvironment()??await O(),continue:r,new:i,"no-browser":a}=e,o=await h(),s=await fn(),c=await _n(t,s,{host:o,continueSession:r,newSession:i}),l;c?(l={...c,pid:process.pid},console.info(`Continuing your session for ${n}...`)):(console.info(`Preparing your session for ${n}...`),l=await hn({repo:n,getToken:C,host:o}));let u={repo:n,getToken:C,host:o,onUnauthorized:x,releaseId:l.releaseId},d=(e=!0)=>xn(t,u,l,s,{push:e,onPull:e=>Dn(`↓ Pulled ${En(e)}`),onPush:e=>Dn(`↑ Pushed ${En(e)}`),onDelete:e=>Dn(`− Deleted ${En(e)}`)}),f=async()=>{try{return await d(!1),await gn(u,s),!0}catch(e){return console.error(`Could not end the session: ${await ln(e)}\nRun \`prismic dev --continue\` to continue it.`),!1}},p=yn();try{let e=Jt([...await t.getCustomTypeLibraries(),...await t.getSliceLibraries()],p.signal),i=r?await d():await bn(t,u,l,s),c=i.customTypes.length,f=i.slices.length;console.info(`Ready. Loaded ${c} ${c===1?`type`:`types`} and ${f} ${f===1?`slice`:`slices`} from your project.\n`);let m=new URL(`builder/types`,`https://${n}.${o}/`);m.searchParams.set(`r`,u.releaseId),console.info(`Type Builder: ${m}`),a?console.info(`Open the URL above to start editing. Changes sync both ways while this runs.`):(mt(m),console.info(`Opened in your browser. Changes sync both ways while this runs.`)),console.info(`Press Ctrl+C to end the session.
19
- `);let h,g=e=>{e!==h&&Dn(`! ${e}`,console.error),h=e};await Sn(d,e,p.signal,{onSync:()=>{h=void 0},onRecover:()=>Dn(`Back in sync.`),onUnreachable:()=>g(`Cannot reach Prismic. Retrying...`),onError:async e=>g(await ln(kn(e))??`Unknown error`)})}catch(e){throw p.abort(),await Cn(e,f)}console.info(`
20
- Ending the session...`),await f()&&console.info(`Session ended.`)});async function fn(){let e=nn(`sha256`).update(en(await R())).digest(`hex`);return new URL(`dev/${e}.json`,gt)}async function pn(e){return It(e,{schema:Mn}).catch(()=>void 0)}async function mn(e,t){await Nt(e,W(t))}async function hn({repo:e,getToken:t,host:n}){return{repo:e,releaseId:(await Pe({label:`prismic dev`,hidden:!0},{repo:e,getToken:t,host:n,onUnauthorized:x}).catch(e=>{throw kn(e)})).id,pid:process.pid,synced:{}}}async function gn({releaseId:e,...t},n){await yt(e,t),await $t(n,{force:!0})}async function _n(e,t,n){let{host:r,continueSession:i,newSession:a}=n,o=await pn(t);if(o&&On(o.pid))throw new L(`A session is already running for this project. Press Ctrl+C in its terminal to end it, or run \`kill ${o.pid}\`.`);if(i){if(!o)throw new L("There is no session to continue. Run `prismic dev` to start a new one.");return o}if(o){if(!a&&await vn(e,{repo:o.repo,getToken:C,host:r,onUnauthorized:x,releaseId:o.releaseId},o.synced))throw new L("Your last session has Type Builder changes that were not pulled.\nRun `prismic dev --continue` to continue the session, or `prismic dev --new` to start a new one without them.");await yt(o.releaseId,{repo:o.repo,getToken:C,host:r,onUnauthorized:x}).catch(()=>{})}}async function vn(e,t,n){let r=await D(t).catch(e=>{if(!(e instanceof kt))throw kn(e)}),i=q(await e.getModels());if(!r)return!1;let a=q(r);return Object.keys({...a,...n}).some(e=>a[e]!==n[e]&&a[e]!==i[e])}function yn(){let e=new AbortController;for(let t of[`SIGINT`,`SIGTERM`,`SIGHUP`,`SIGBREAK`])process.on(t,()=>{process.stdout.on(`error`,()=>{}),process.stderr.on(`error`,()=>{}),e.abort()});return e}async function bn(e,t,n,r){let i=await e.getModels(),a=await D(t);return await _(y(i,a),t),n.synced=q(i),await mn(r,n),i}async function xn(e,t,n,r,i){let{push:a,onPull:o,onPush:s,onDelete:c}=i,[l,u]=await Promise.all([e.getModels(),D(t)]),d=q(l),f=q(u),p=wn(d,f,n.synced),m=l;if(p.pull.length>0){await e.writeModels(y(Tn(u,p.pull),Tn(l,p.pull))),await e.generateTypes(),m=await e.getModels();let t=q(m);for(let e of p.pull)e in t?n.synced[e]=t[e]:delete n.synced[e];await mn(r,n)}let h=p.pull.filter(e=>e in f);h.length>0&&o(h);let g=a?p.push:[];await _(y(Tn(l,g),Tn(u,g)),t);let v=g.filter(e=>e in d);v.length>0&&s(v);let b=[...p.pull.filter(e=>!(e in f)),...g.filter(e=>!(e in d))];return b.length>0&&c(b),n.synced=q(m),await mn(r,n),m}async function Sn(e,t,n,r){let{onSync:i,onRecover:a,onUnreachable:o,onError:s}=r,c=0;for(;;){if(await t(un),n.aborted)return;try{await e(),c>=6&&a(),c=0,i()}catch(e){if(e instanceof V||e instanceof K||e instanceof kt)throw e;let t=e instanceof Ot?e.status>=500||e.status===429:e instanceof Pt;if(t&&++c<6)continue;t?o():await s(e)}}}async function Cn(e,t){return e instanceof V?new L("Your login expired. Run `prismic login`, then `prismic dev --continue` to continue the session."):e instanceof kt?new L("The session ended. Run `prismic dev` to start a new one."):(e instanceof K||await t(),kn(e))}function wn(e,t,n){let r=[],i=[];for(let a of/* @__PURE__ */ new Set([...Object.keys(e),...Object.keys(t),...Object.keys(n)])){if(e[a]===t[a])continue;let o=e[a]!==n[a],s=t[a]!==n[a];!o||s&&!(a in e)?r.push(a):i.push(a)}return{pull:r,push:i}}function q(e){let t=e=>nn(`sha256`).update(JSON.stringify(e)).digest(`hex`);return Object.fromEntries([...e.customTypes.map(e=>[`type:${e.id}`,t(oe(e))]),...e.slices.map(e=>[`slice:${e.id}`,t(p(e))])])}function Tn(e,t){return{customTypes:e.customTypes.filter(e=>t.includes(`type:${e.id}`)),slices:e.slices.filter(e=>t.includes(`slice:${e.id}`))}}function En(e){return e.map(e=>e.slice(e.indexOf(`:`)+1)).join(`, `)}function Dn(e,t=console.info){t(`${(/* @__PURE__ */ new Date()).toTimeString().slice(0,8)} ${e.replaceAll(`
18
+ `,options:{repo:{type:`string`,short:`r`,description:`Repository or environment domain`},continue:{type:`boolean`,description:`Continue the previous session`},new:{type:`boolean`,description:`Start a new session, even if the previous one has unpulled changes`},"no-browser":{type:`boolean`,description:`Skip opening the Type Builder in the browser`}}},async({values:e})=>{de(e,[`continue`,`new`]);let t=await P(),{repo:n=await t.getEnvironment()??await O(),continue:r,new:i,"no-browser":a}=e,o=await g(),s=await mn(),c=await yn(t,s,{host:o,continueSession:r,newSession:i}),l;c?(l={...c,pid:process.pid},console.info(`Continuing your session for ${n}...`)):(console.info(`Preparing your session for ${n}...`),l=await _n({repo:n,getToken:C,host:o}));let u={repo:n,getToken:C,host:o,onUnauthorized:x,releaseId:l.releaseId},d=(e=!0)=>Cn(t,u,l,s,{push:e,onPull:e=>kn(`↓ Pulled ${On(e)}`),onPush:e=>kn(`↑ Pushed ${On(e)}`),onDelete:e=>kn(`− Deleted ${On(e)}`)}),f=async()=>{try{return await d(!1),await vn(u,s),!0}catch(e){return console.error(`Could not end the session: ${await dn(e)}\nRun \`prismic dev --continue\` to continue it.`),!1}},p=xn();try{let e=Yt([...await t.getCustomTypeLibraries(),...await t.getSliceLibraries()],p.signal),i=r?await d():await Sn(t,u,l,s),c=i.customTypes.length,f=i.slices.length;console.info(`Ready. Loaded ${c} ${c===1?`type`:`types`} and ${f} ${f===1?`slice`:`slices`} from your project.\n`);let m=new URL(`builder/types`,`https://${n}.${o}/`);m.searchParams.set(`r`,u.releaseId),console.info(`Type Builder: ${m}`),a?console.info(`Open the URL above to start editing. Changes sync both ways while this runs.`):(nt(m),console.info(`Opened in your browser. Changes sync both ways while this runs.`)),console.info(`Press Ctrl+C to end the session.
19
+ `);let h,g=e=>{e!==h&&kn(`! ${e}`,console.error),h=e};await wn(d,e,p.signal,{onSync:()=>{h=void 0},onRecover:()=>kn(`Back in sync.`),onUnreachable:()=>g(`Cannot reach Prismic. Retrying...`),onError:async e=>g(await dn(jn(e))??`Unknown error`)})}catch(e){throw p.abort(),await Tn(e,f)}console.info(`
20
+ Ending the session...`),await f()&&console.info(`Session ended.`)});async function mn(){let e=an(`sha256`).update(nn(await R())).digest(`hex`);return new URL(`dev/${e}.json`,Ne)}async function hn(e){return It(e,{schema:Pn}).catch(()=>void 0)}async function gn(e,t){await Mt(e,G(t))}async function _n({repo:e,getToken:t,host:n}){return{repo:e,releaseId:(await Re({label:`prismic dev`,hidden:!0},{repo:e,getToken:t,host:n,onUnauthorized:x}).catch(e=>{throw jn(e)})).id,pid:process.pid,synced:{}}}async function vn({releaseId:e,...t},n){await Tt(e,t),await tn(n,{force:!0})}async function yn(e,t,n){let{host:r,continueSession:i,newSession:a}=n,o=await hn(t);if(o&&An(o.pid))throw new S(`A session is already running for this project. Press Ctrl+C in its terminal to end it, or run \`kill ${o.pid}\`.`);if(i){if(!o)throw new S("There is no session to continue. Run `prismic dev` to start a new one.");return o}if(o){if(!a&&await bn(e,{repo:o.repo,getToken:C,host:r,onUnauthorized:x,releaseId:o.releaseId},o.synced))throw new S("Your last session has Type Builder changes that were not pulled.\nRun `prismic dev --continue` to continue the session, or `prismic dev --new` to start a new one without them.");await Tt(o.releaseId,{repo:o.repo,getToken:C,host:r,onUnauthorized:x}).catch(()=>{})}}async function bn(e,t,n){let r=await E(t).catch(e=>{if(!(e instanceof At))throw jn(e)}),i=q(await e.getModels());if(!r)return!1;let a=q(r);return Object.keys({...a,...n}).some(e=>a[e]!==n[e]&&a[e]!==i[e])}function xn(){let e=new AbortController;for(let t of[`SIGINT`,`SIGTERM`,`SIGHUP`,`SIGBREAK`])process.on(t,()=>{process.stdout.on(`error`,()=>{}),process.stderr.on(`error`,()=>{}),e.abort()});return e}async function Sn(e,t,n,r){let i=await e.getModels(),a=await E(t);return await v(b(i,a),t),n.synced=q(i),await gn(r,n),i}async function Cn(e,t,n,r,i){let{push:a,onPull:o,onPush:s,onDelete:c}=i,[l,u]=await Promise.all([e.getModels(),E(t)]),d=q(l),f=q(u),p=En(d,f,n.synced),m=l;if(p.pull.length>0){await e.writeModels(b(Dn(u,p.pull),Dn(l,p.pull))),await e.generateTypes(),m=await e.getModels();let t=q(m);for(let e of p.pull)e in t?n.synced[e]=t[e]:delete n.synced[e];await gn(r,n)}let h=p.pull.filter(e=>e in f);h.length>0&&o(h);let g=a?p.push:[];await v(b(Dn(l,g),Dn(u,g)),t);let _=g.filter(e=>e in d);_.length>0&&s(_);let y=[...p.pull.filter(e=>!(e in f)),...g.filter(e=>!(e in d))];return y.length>0&&c(y),n.synced=q(m),await gn(r,n),m}async function wn(e,t,n,r){let{onSync:i,onRecover:a,onUnreachable:o,onError:s}=r,c=0;for(;;){if(await t(fn),n.aborted)return;try{await e(),c>=6&&a(),c=0,i()}catch(e){if(e instanceof V||e instanceof K||e instanceof At)throw e;let t=e instanceof kt?e.status>=500||e.status===429:e instanceof Nt;if(t&&++c<6)continue;t?o():await s(e)}}}async function Tn(e,t){return e instanceof V?new S("Your login expired. Run `prismic login`, then `prismic dev --continue` to continue the session."):e instanceof At?new S("The session ended. Run `prismic dev` to start a new one."):(e instanceof K||await t(),jn(e))}function En(e,t,n){let r=[],i=[];for(let a of/* @__PURE__ */ new Set([...Object.keys(e),...Object.keys(t),...Object.keys(n)])){if(e[a]===t[a])continue;let o=e[a]!==n[a],s=t[a]!==n[a];!o||s&&!(a in e)?r.push(a):i.push(a)}return{pull:r,push:i}}function q(e){let t=e=>an(`sha256`).update(JSON.stringify(e)).digest(`hex`);return Object.fromEntries([...e.customTypes.map(e=>[`type:${e.id}`,t(ce(e))]),...e.slices.map(e=>[`slice:${e.id}`,t(m(e))])])}function Dn(e,t){return{customTypes:e.customTypes.filter(e=>t.includes(`type:${e.id}`)),slices:e.slices.filter(e=>t.includes(`slice:${e.id}`))}}function On(e){return e.map(e=>e.slice(e.indexOf(`:`)+1)).join(`, `)}function kn(e,t=console.info){t(`${(/* @__PURE__ */ new Date()).toTimeString().slice(0,8)} ${e.replaceAll(`
21
21
  `,`
22
- `)}`)}function On(e){try{return process.kill(e,0),!0}catch(e){return e.code===`EPERM`}}function kn(e){if(!(e instanceof Ot))return e;switch(Vt(G({error:H()}),e.body).data?.error){case`missing_right`:return new L(`To edit models in the Type Builder, you need an Administrator, Owner, or Super User role on this repository.`);case`LEGACY_REPOSITORY`:return new L(`Local mode does not support this repository yet.`)}let t=Vt(jn,e.body).data?.details;return t?new L([...t.customTypes,...t.slices].map(({id:e,error:t})=>`Could not push ${e}: ${t}`).join(`
23
- `)):e}const An=Mt(G({id:H(),error:H()})),jn=G({details:G({customTypes:An,slices:An})}),Mn=G({repo:H(),releaseId:H(),pid:jt(),synced:Ft(H(),H())});var Nn=S({name:`prismic docs list`,description:`
22
+ `)}`)}function An(e){try{return process.kill(e,0),!0}catch(e){return e.code===`EPERM`}}function jn(e){if(!(e instanceof kt))return e;switch(Lt(z({error:U()}),e.body).data?.error){case`missing_right`:return new S(`To edit models in the Type Builder, you need an Administrator, Owner, or Super User role on this repository.`);case`LEGACY_REPOSITORY`:return new S(`Local mode does not support this repository yet.`)}let t=Lt(Nn,e.body).data?.details;return t?new S([...t.customTypes,...t.slices].map(({id:e,error:t})=>`Could not push ${e}: ${t}`).join(`
23
+ `)):e}const Mn=Xt(z({id:U(),error:U()})),Nn=z({details:z({customTypes:Mn,slices:Mn})}),Pn=z({repo:U(),releaseId:U(),pid:Gt(),synced:Ft(U(),U())});var Fn=j({name:`prismic docs list`,description:`
24
24
  List available documentation pages.
25
25
 
26
26
  With a path argument, list the anchors within that page.
27
- `,positionals:{path:{description:`Documentation path to list anchors for`,required:!1}},options:{json:{type:`boolean`,description:`Output as JSON`}}},async({positionals:e,values:t})=>{let[n]=e,{json:r}=t;if(n){let e=await pe(n,{host:I.PRISMIC_DOCS_HOST});if(r){console.info(W(e));return}if(e.anchors.length===0){console.info(`(no anchors)`);return}let t=e.anchors.map(e=>[`${n}#${e.slug}`,e.excerpt]);console.info(M(t,{headers:[`PATH`,`EXCERPT`]}))}else{let e=await c({host:I.PRISMIC_DOCS_HOST});if(e.sort((e,t)=>e.path.localeCompare(t.path)),r){console.info(W(e));return}if(e.length===0){console.info(`No documentation pages found.`);return}let t=e.map(e=>[e.path,e.title,e.description??``]);console.info(M(t,{headers:[`PATH`,`TITLE`,`DESCRIPTION`]}))}});const Pn=/[\0-\x1F!-,\.\/:-@\[-\^`\{-\xA9\xAB-\xB4\xB6-\xB9\xBB-\xBF\xD7\xF7\u02C2-\u02C5\u02D2-\u02DF\u02E5-\u02EB\u02ED\u02EF-\u02FF\u0375\u0378\u0379\u037E\u0380-\u0385\u0387\u038B\u038D\u03A2\u03F6\u0482\u0530\u0557\u0558\u055A-\u055F\u0589-\u0590\u05BE\u05C0\u05C3\u05C6\u05C8-\u05CF\u05EB-\u05EE\u05F3-\u060F\u061B-\u061F\u066A-\u066D\u06D4\u06DD\u06DE\u06E9\u06FD\u06FE\u0700-\u070F\u074B\u074C\u07B2-\u07BF\u07F6-\u07F9\u07FB\u07FC\u07FE\u07FF\u082E-\u083F\u085C-\u085F\u086B-\u089F\u08B5\u08C8-\u08D2\u08E2\u0964\u0965\u0970\u0984\u098D\u098E\u0991\u0992\u09A9\u09B1\u09B3-\u09B5\u09BA\u09BB\u09C5\u09C6\u09C9\u09CA\u09CF-\u09D6\u09D8-\u09DB\u09DE\u09E4\u09E5\u09F2-\u09FB\u09FD\u09FF\u0A00\u0A04\u0A0B-\u0A0E\u0A11\u0A12\u0A29\u0A31\u0A34\u0A37\u0A3A\u0A3B\u0A3D\u0A43-\u0A46\u0A49\u0A4A\u0A4E-\u0A50\u0A52-\u0A58\u0A5D\u0A5F-\u0A65\u0A76-\u0A80\u0A84\u0A8E\u0A92\u0AA9\u0AB1\u0AB4\u0ABA\u0ABB\u0AC6\u0ACA\u0ACE\u0ACF\u0AD1-\u0ADF\u0AE4\u0AE5\u0AF0-\u0AF8\u0B00\u0B04\u0B0D\u0B0E\u0B11\u0B12\u0B29\u0B31\u0B34\u0B3A\u0B3B\u0B45\u0B46\u0B49\u0B4A\u0B4E-\u0B54\u0B58-\u0B5B\u0B5E\u0B64\u0B65\u0B70\u0B72-\u0B81\u0B84\u0B8B-\u0B8D\u0B91\u0B96-\u0B98\u0B9B\u0B9D\u0BA0-\u0BA2\u0BA5-\u0BA7\u0BAB-\u0BAD\u0BBA-\u0BBD\u0BC3-\u0BC5\u0BC9\u0BCE\u0BCF\u0BD1-\u0BD6\u0BD8-\u0BE5\u0BF0-\u0BFF\u0C0D\u0C11\u0C29\u0C3A-\u0C3C\u0C45\u0C49\u0C4E-\u0C54\u0C57\u0C5B-\u0C5F\u0C64\u0C65\u0C70-\u0C7F\u0C84\u0C8D\u0C91\u0CA9\u0CB4\u0CBA\u0CBB\u0CC5\u0CC9\u0CCE-\u0CD4\u0CD7-\u0CDD\u0CDF\u0CE4\u0CE5\u0CF0\u0CF3-\u0CFF\u0D0D\u0D11\u0D45\u0D49\u0D4F-\u0D53\u0D58-\u0D5E\u0D64\u0D65\u0D70-\u0D79\u0D80\u0D84\u0D97-\u0D99\u0DB2\u0DBC\u0DBE\u0DBF\u0DC7-\u0DC9\u0DCB-\u0DCE\u0DD5\u0DD7\u0DE0-\u0DE5\u0DF0\u0DF1\u0DF4-\u0E00\u0E3B-\u0E3F\u0E4F\u0E5A-\u0E80\u0E83\u0E85\u0E8B\u0EA4\u0EA6\u0EBE\u0EBF\u0EC5\u0EC7\u0ECE\u0ECF\u0EDA\u0EDB\u0EE0-\u0EFF\u0F01-\u0F17\u0F1A-\u0F1F\u0F2A-\u0F34\u0F36\u0F38\u0F3A-\u0F3D\u0F48\u0F6D-\u0F70\u0F85\u0F98\u0FBD-\u0FC5\u0FC7-\u0FFF\u104A-\u104F\u109E\u109F\u10C6\u10C8-\u10CC\u10CE\u10CF\u10FB\u1249\u124E\u124F\u1257\u1259\u125E\u125F\u1289\u128E\u128F\u12B1\u12B6\u12B7\u12BF\u12C1\u12C6\u12C7\u12D7\u1311\u1316\u1317\u135B\u135C\u1360-\u137F\u1390-\u139F\u13F6\u13F7\u13FE-\u1400\u166D\u166E\u1680\u169B-\u169F\u16EB-\u16ED\u16F9-\u16FF\u170D\u1715-\u171F\u1735-\u173F\u1754-\u175F\u176D\u1771\u1774-\u177F\u17D4-\u17D6\u17D8-\u17DB\u17DE\u17DF\u17EA-\u180A\u180E\u180F\u181A-\u181F\u1879-\u187F\u18AB-\u18AF\u18F6-\u18FF\u191F\u192C-\u192F\u193C-\u1945\u196E\u196F\u1975-\u197F\u19AC-\u19AF\u19CA-\u19CF\u19DA-\u19FF\u1A1C-\u1A1F\u1A5F\u1A7D\u1A7E\u1A8A-\u1A8F\u1A9A-\u1AA6\u1AA8-\u1AAF\u1AC1-\u1AFF\u1B4C-\u1B4F\u1B5A-\u1B6A\u1B74-\u1B7F\u1BF4-\u1BFF\u1C38-\u1C3F\u1C4A-\u1C4C\u1C7E\u1C7F\u1C89-\u1C8F\u1CBB\u1CBC\u1CC0-\u1CCF\u1CD3\u1CFB-\u1CFF\u1DFA\u1F16\u1F17\u1F1E\u1F1F\u1F46\u1F47\u1F4E\u1F4F\u1F58\u1F5A\u1F5C\u1F5E\u1F7E\u1F7F\u1FB5\u1FBD\u1FBF-\u1FC1\u1FC5\u1FCD-\u1FCF\u1FD4\u1FD5\u1FDC-\u1FDF\u1FED-\u1FF1\u1FF5\u1FFD-\u203E\u2041-\u2053\u2055-\u2070\u2072-\u207E\u2080-\u208F\u209D-\u20CF\u20F1-\u2101\u2103-\u2106\u2108\u2109\u2114\u2116-\u2118\u211E-\u2123\u2125\u2127\u2129\u212E\u213A\u213B\u2140-\u2144\u214A-\u214D\u214F-\u215F\u2189-\u24B5\u24EA-\u2BFF\u2C2F\u2C5F\u2CE5-\u2CEA\u2CF4-\u2CFF\u2D26\u2D28-\u2D2C\u2D2E\u2D2F\u2D68-\u2D6E\u2D70-\u2D7E\u2D97-\u2D9F\u2DA7\u2DAF\u2DB7\u2DBF\u2DC7\u2DCF\u2DD7\u2DDF\u2E00-\u2E2E\u2E30-\u3004\u3008-\u3020\u3030\u3036\u3037\u303D-\u3040\u3097\u3098\u309B\u309C\u30A0\u30FB\u3100-\u3104\u3130\u318F-\u319F\u31C0-\u31EF\u3200-\u33FF\u4DC0-\u4DFF\u9FFD-\u9FFF\uA48D-\uA4CF\uA4FE\uA4FF\uA60D-\uA60F\uA62C-\uA63F\uA673\uA67E\uA6F2-\uA716\uA720\uA721\uA789\uA78A\uA7C0\uA7C1\uA7CB-\uA7F4\uA828-\uA82B\uA82D-\uA83F\uA874-\uA87F\uA8C6-\uA8CF\uA8DA-\uA8DF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA954-\uA95F\uA97D-\uA97F\uA9C1-\uA9CE\uA9DA-\uA9DF\uA9FF\uAA37-\uAA3F\uAA4E\uAA4F\uAA5A-\uAA5F\uAA77-\uAA79\uAAC3-\uAADA\uAADE\uAADF\uAAF0\uAAF1\uAAF7-\uAB00\uAB07\uAB08\uAB0F\uAB10\uAB17-\uAB1F\uAB27\uAB2F\uAB5B\uAB6A-\uAB6F\uABEB\uABEE\uABEF\uABFA-\uABFF\uD7A4-\uD7AF\uD7C7-\uD7CA\uD7FC-\uD7FF\uE000-\uF8FF\uFA6E\uFA6F\uFADA-\uFAFF\uFB07-\uFB12\uFB18-\uFB1C\uFB29\uFB37\uFB3D\uFB3F\uFB42\uFB45\uFBB2-\uFBD2\uFD3E-\uFD4F\uFD90\uFD91\uFDC8-\uFDEF\uFDFC-\uFDFF\uFE10-\uFE1F\uFE30-\uFE32\uFE35-\uFE4C\uFE50-\uFE6F\uFE75\uFEFD-\uFF0F\uFF1A-\uFF20\uFF3B-\uFF3E\uFF40\uFF5B-\uFF65\uFFBF-\uFFC1\uFFC8\uFFC9\uFFD0\uFFD1\uFFD8\uFFD9\uFFDD-\uFFFF]|\uD800[\uDC0C\uDC27\uDC3B\uDC3E\uDC4E\uDC4F\uDC5E-\uDC7F\uDCFB-\uDD3F\uDD75-\uDDFC\uDDFE-\uDE7F\uDE9D-\uDE9F\uDED1-\uDEDF\uDEE1-\uDEFF\uDF20-\uDF2C\uDF4B-\uDF4F\uDF7B-\uDF7F\uDF9E\uDF9F\uDFC4-\uDFC7\uDFD0\uDFD6-\uDFFF]|\uD801[\uDC9E\uDC9F\uDCAA-\uDCAF\uDCD4-\uDCD7\uDCFC-\uDCFF\uDD28-\uDD2F\uDD64-\uDDFF\uDF37-\uDF3F\uDF56-\uDF5F\uDF68-\uDFFF]|\uD802[\uDC06\uDC07\uDC09\uDC36\uDC39-\uDC3B\uDC3D\uDC3E\uDC56-\uDC5F\uDC77-\uDC7F\uDC9F-\uDCDF\uDCF3\uDCF6-\uDCFF\uDD16-\uDD1F\uDD3A-\uDD7F\uDDB8-\uDDBD\uDDC0-\uDDFF\uDE04\uDE07-\uDE0B\uDE14\uDE18\uDE36\uDE37\uDE3B-\uDE3E\uDE40-\uDE5F\uDE7D-\uDE7F\uDE9D-\uDEBF\uDEC8\uDEE7-\uDEFF\uDF36-\uDF3F\uDF56-\uDF5F\uDF73-\uDF7F\uDF92-\uDFFF]|\uD803[\uDC49-\uDC7F\uDCB3-\uDCBF\uDCF3-\uDCFF\uDD28-\uDD2F\uDD3A-\uDE7F\uDEAA\uDEAD-\uDEAF\uDEB2-\uDEFF\uDF1D-\uDF26\uDF28-\uDF2F\uDF51-\uDFAF\uDFC5-\uDFDF\uDFF7-\uDFFF]|\uD804[\uDC47-\uDC65\uDC70-\uDC7E\uDCBB-\uDCCF\uDCE9-\uDCEF\uDCFA-\uDCFF\uDD35\uDD40-\uDD43\uDD48-\uDD4F\uDD74\uDD75\uDD77-\uDD7F\uDDC5-\uDDC8\uDDCD\uDDDB\uDDDD-\uDDFF\uDE12\uDE38-\uDE3D\uDE3F-\uDE7F\uDE87\uDE89\uDE8E\uDE9E\uDEA9-\uDEAF\uDEEB-\uDEEF\uDEFA-\uDEFF\uDF04\uDF0D\uDF0E\uDF11\uDF12\uDF29\uDF31\uDF34\uDF3A\uDF45\uDF46\uDF49\uDF4A\uDF4E\uDF4F\uDF51-\uDF56\uDF58-\uDF5C\uDF64\uDF65\uDF6D-\uDF6F\uDF75-\uDFFF]|\uD805[\uDC4B-\uDC4F\uDC5A-\uDC5D\uDC62-\uDC7F\uDCC6\uDCC8-\uDCCF\uDCDA-\uDD7F\uDDB6\uDDB7\uDDC1-\uDDD7\uDDDE-\uDDFF\uDE41-\uDE43\uDE45-\uDE4F\uDE5A-\uDE7F\uDEB9-\uDEBF\uDECA-\uDEFF\uDF1B\uDF1C\uDF2C-\uDF2F\uDF3A-\uDFFF]|\uD806[\uDC3B-\uDC9F\uDCEA-\uDCFE\uDD07\uDD08\uDD0A\uDD0B\uDD14\uDD17\uDD36\uDD39\uDD3A\uDD44-\uDD4F\uDD5A-\uDD9F\uDDA8\uDDA9\uDDD8\uDDD9\uDDE2\uDDE5-\uDDFF\uDE3F-\uDE46\uDE48-\uDE4F\uDE9A-\uDE9C\uDE9E-\uDEBF\uDEF9-\uDFFF]|\uD807[\uDC09\uDC37\uDC41-\uDC4F\uDC5A-\uDC71\uDC90\uDC91\uDCA8\uDCB7-\uDCFF\uDD07\uDD0A\uDD37-\uDD39\uDD3B\uDD3E\uDD48-\uDD4F\uDD5A-\uDD5F\uDD66\uDD69\uDD8F\uDD92\uDD99-\uDD9F\uDDAA-\uDEDF\uDEF7-\uDFAF\uDFB1-\uDFFF]|\uD808[\uDF9A-\uDFFF]|\uD809[\uDC6F-\uDC7F\uDD44-\uDFFF]|[\uD80A\uD80B\uD80E-\uD810\uD812-\uD819\uD824-\uD82B\uD82D\uD82E\uD830-\uD833\uD837\uD839\uD83D\uD83F\uD87B-\uD87D\uD87F\uD885-\uDB3F\uDB41-\uDBFF][\uDC00-\uDFFF]|\uD80D[\uDC2F-\uDFFF]|\uD811[\uDE47-\uDFFF]|\uD81A[\uDE39-\uDE3F\uDE5F\uDE6A-\uDECF\uDEEE\uDEEF\uDEF5-\uDEFF\uDF37-\uDF3F\uDF44-\uDF4F\uDF5A-\uDF62\uDF78-\uDF7C\uDF90-\uDFFF]|\uD81B[\uDC00-\uDE3F\uDE80-\uDEFF\uDF4B-\uDF4E\uDF88-\uDF8E\uDFA0-\uDFDF\uDFE2\uDFE5-\uDFEF\uDFF2-\uDFFF]|\uD821[\uDFF8-\uDFFF]|\uD823[\uDCD6-\uDCFF\uDD09-\uDFFF]|\uD82C[\uDD1F-\uDD4F\uDD53-\uDD63\uDD68-\uDD6F\uDEFC-\uDFFF]|\uD82F[\uDC6B-\uDC6F\uDC7D-\uDC7F\uDC89-\uDC8F\uDC9A-\uDC9C\uDC9F-\uDFFF]|\uD834[\uDC00-\uDD64\uDD6A-\uDD6C\uDD73-\uDD7A\uDD83\uDD84\uDD8C-\uDDA9\uDDAE-\uDE41\uDE45-\uDFFF]|\uD835[\uDC55\uDC9D\uDCA0\uDCA1\uDCA3\uDCA4\uDCA7\uDCA8\uDCAD\uDCBA\uDCBC\uDCC4\uDD06\uDD0B\uDD0C\uDD15\uDD1D\uDD3A\uDD3F\uDD45\uDD47-\uDD49\uDD51\uDEA6\uDEA7\uDEC1\uDEDB\uDEFB\uDF15\uDF35\uDF4F\uDF6F\uDF89\uDFA9\uDFC3\uDFCC\uDFCD]|\uD836[\uDC00-\uDDFF\uDE37-\uDE3A\uDE6D-\uDE74\uDE76-\uDE83\uDE85-\uDE9A\uDEA0\uDEB0-\uDFFF]|\uD838[\uDC07\uDC19\uDC1A\uDC22\uDC25\uDC2B-\uDCFF\uDD2D-\uDD2F\uDD3E\uDD3F\uDD4A-\uDD4D\uDD4F-\uDEBF\uDEFA-\uDFFF]|\uD83A[\uDCC5-\uDCCF\uDCD7-\uDCFF\uDD4C-\uDD4F\uDD5A-\uDFFF]|\uD83B[\uDC00-\uDDFF\uDE04\uDE20\uDE23\uDE25\uDE26\uDE28\uDE33\uDE38\uDE3A\uDE3C-\uDE41\uDE43-\uDE46\uDE48\uDE4A\uDE4C\uDE50\uDE53\uDE55\uDE56\uDE58\uDE5A\uDE5C\uDE5E\uDE60\uDE63\uDE65\uDE66\uDE6B\uDE73\uDE78\uDE7D\uDE7F\uDE8A\uDE9C-\uDEA0\uDEA4\uDEAA\uDEBC-\uDFFF]|\uD83C[\uDC00-\uDD2F\uDD4A-\uDD4F\uDD6A-\uDD6F\uDD8A-\uDFFF]|\uD83E[\uDC00-\uDFEF\uDFFA-\uDFFF]|\uD869[\uDEDE-\uDEFF]|\uD86D[\uDF35-\uDF3F]|\uD86E[\uDC1E\uDC1F]|\uD873[\uDEA2-\uDEAF]|\uD87A[\uDFE1-\uDFFF]|\uD87E[\uDE1E-\uDFFF]|\uD884[\uDF4B-\uDFFF]|\uDB40[\uDC00-\uDCFF\uDDF0-\uDFFF]/g,Fn=Object.hasOwnProperty;var In=class{constructor(){this.occurrences,this.reset()}slug(e,t){let n=this,r=Ln(e,t===!0),i=r;for(;Fn.call(n.occurrences,r);)n.occurrences[i]++,r=i+`-`+n.occurrences[i];return n.occurrences[r]=0,r}reset(){this.occurrences=Object.create(null)}};function Ln(e,t){return typeof e==`string`?(t||(e=e.toLowerCase()),e.replace(Pn,``).replace(/ /g,`-`)):``}var Rn=S({name:`prismic docs view`,description:`
27
+ `,positionals:{path:{description:`Documentation path to list anchors for`,required:!1}},options:{json:{type:`boolean`,description:`Output as JSON`}}},async({positionals:e,values:t})=>{let[n]=e,{json:r}=t;if(n){let e=await p(n,{host:F.PRISMIC_DOCS_HOST});if(r){console.info(G(e));return}if(e.anchors.length===0){console.info(`(no anchors)`);return}let t=e.anchors.map(e=>[`${n}#${e.slug}`,e.excerpt]);console.info(L(t,{headers:[`PATH`,`EXCERPT`]}))}else{let e=await St({host:F.PRISMIC_DOCS_HOST});if(e.sort((e,t)=>e.path.localeCompare(t.path)),r){console.info(G(e));return}if(e.length===0){console.info(`No documentation pages found.`);return}let t=e.map(e=>[e.path,e.title,e.description??``]);console.info(L(t,{headers:[`PATH`,`TITLE`,`DESCRIPTION`]}))}});const In=/[\0-\x1F!-,\.\/:-@\[-\^`\{-\xA9\xAB-\xB4\xB6-\xB9\xBB-\xBF\xD7\xF7\u02C2-\u02C5\u02D2-\u02DF\u02E5-\u02EB\u02ED\u02EF-\u02FF\u0375\u0378\u0379\u037E\u0380-\u0385\u0387\u038B\u038D\u03A2\u03F6\u0482\u0530\u0557\u0558\u055A-\u055F\u0589-\u0590\u05BE\u05C0\u05C3\u05C6\u05C8-\u05CF\u05EB-\u05EE\u05F3-\u060F\u061B-\u061F\u066A-\u066D\u06D4\u06DD\u06DE\u06E9\u06FD\u06FE\u0700-\u070F\u074B\u074C\u07B2-\u07BF\u07F6-\u07F9\u07FB\u07FC\u07FE\u07FF\u082E-\u083F\u085C-\u085F\u086B-\u089F\u08B5\u08C8-\u08D2\u08E2\u0964\u0965\u0970\u0984\u098D\u098E\u0991\u0992\u09A9\u09B1\u09B3-\u09B5\u09BA\u09BB\u09C5\u09C6\u09C9\u09CA\u09CF-\u09D6\u09D8-\u09DB\u09DE\u09E4\u09E5\u09F2-\u09FB\u09FD\u09FF\u0A00\u0A04\u0A0B-\u0A0E\u0A11\u0A12\u0A29\u0A31\u0A34\u0A37\u0A3A\u0A3B\u0A3D\u0A43-\u0A46\u0A49\u0A4A\u0A4E-\u0A50\u0A52-\u0A58\u0A5D\u0A5F-\u0A65\u0A76-\u0A80\u0A84\u0A8E\u0A92\u0AA9\u0AB1\u0AB4\u0ABA\u0ABB\u0AC6\u0ACA\u0ACE\u0ACF\u0AD1-\u0ADF\u0AE4\u0AE5\u0AF0-\u0AF8\u0B00\u0B04\u0B0D\u0B0E\u0B11\u0B12\u0B29\u0B31\u0B34\u0B3A\u0B3B\u0B45\u0B46\u0B49\u0B4A\u0B4E-\u0B54\u0B58-\u0B5B\u0B5E\u0B64\u0B65\u0B70\u0B72-\u0B81\u0B84\u0B8B-\u0B8D\u0B91\u0B96-\u0B98\u0B9B\u0B9D\u0BA0-\u0BA2\u0BA5-\u0BA7\u0BAB-\u0BAD\u0BBA-\u0BBD\u0BC3-\u0BC5\u0BC9\u0BCE\u0BCF\u0BD1-\u0BD6\u0BD8-\u0BE5\u0BF0-\u0BFF\u0C0D\u0C11\u0C29\u0C3A-\u0C3C\u0C45\u0C49\u0C4E-\u0C54\u0C57\u0C5B-\u0C5F\u0C64\u0C65\u0C70-\u0C7F\u0C84\u0C8D\u0C91\u0CA9\u0CB4\u0CBA\u0CBB\u0CC5\u0CC9\u0CCE-\u0CD4\u0CD7-\u0CDD\u0CDF\u0CE4\u0CE5\u0CF0\u0CF3-\u0CFF\u0D0D\u0D11\u0D45\u0D49\u0D4F-\u0D53\u0D58-\u0D5E\u0D64\u0D65\u0D70-\u0D79\u0D80\u0D84\u0D97-\u0D99\u0DB2\u0DBC\u0DBE\u0DBF\u0DC7-\u0DC9\u0DCB-\u0DCE\u0DD5\u0DD7\u0DE0-\u0DE5\u0DF0\u0DF1\u0DF4-\u0E00\u0E3B-\u0E3F\u0E4F\u0E5A-\u0E80\u0E83\u0E85\u0E8B\u0EA4\u0EA6\u0EBE\u0EBF\u0EC5\u0EC7\u0ECE\u0ECF\u0EDA\u0EDB\u0EE0-\u0EFF\u0F01-\u0F17\u0F1A-\u0F1F\u0F2A-\u0F34\u0F36\u0F38\u0F3A-\u0F3D\u0F48\u0F6D-\u0F70\u0F85\u0F98\u0FBD-\u0FC5\u0FC7-\u0FFF\u104A-\u104F\u109E\u109F\u10C6\u10C8-\u10CC\u10CE\u10CF\u10FB\u1249\u124E\u124F\u1257\u1259\u125E\u125F\u1289\u128E\u128F\u12B1\u12B6\u12B7\u12BF\u12C1\u12C6\u12C7\u12D7\u1311\u1316\u1317\u135B\u135C\u1360-\u137F\u1390-\u139F\u13F6\u13F7\u13FE-\u1400\u166D\u166E\u1680\u169B-\u169F\u16EB-\u16ED\u16F9-\u16FF\u170D\u1715-\u171F\u1735-\u173F\u1754-\u175F\u176D\u1771\u1774-\u177F\u17D4-\u17D6\u17D8-\u17DB\u17DE\u17DF\u17EA-\u180A\u180E\u180F\u181A-\u181F\u1879-\u187F\u18AB-\u18AF\u18F6-\u18FF\u191F\u192C-\u192F\u193C-\u1945\u196E\u196F\u1975-\u197F\u19AC-\u19AF\u19CA-\u19CF\u19DA-\u19FF\u1A1C-\u1A1F\u1A5F\u1A7D\u1A7E\u1A8A-\u1A8F\u1A9A-\u1AA6\u1AA8-\u1AAF\u1AC1-\u1AFF\u1B4C-\u1B4F\u1B5A-\u1B6A\u1B74-\u1B7F\u1BF4-\u1BFF\u1C38-\u1C3F\u1C4A-\u1C4C\u1C7E\u1C7F\u1C89-\u1C8F\u1CBB\u1CBC\u1CC0-\u1CCF\u1CD3\u1CFB-\u1CFF\u1DFA\u1F16\u1F17\u1F1E\u1F1F\u1F46\u1F47\u1F4E\u1F4F\u1F58\u1F5A\u1F5C\u1F5E\u1F7E\u1F7F\u1FB5\u1FBD\u1FBF-\u1FC1\u1FC5\u1FCD-\u1FCF\u1FD4\u1FD5\u1FDC-\u1FDF\u1FED-\u1FF1\u1FF5\u1FFD-\u203E\u2041-\u2053\u2055-\u2070\u2072-\u207E\u2080-\u208F\u209D-\u20CF\u20F1-\u2101\u2103-\u2106\u2108\u2109\u2114\u2116-\u2118\u211E-\u2123\u2125\u2127\u2129\u212E\u213A\u213B\u2140-\u2144\u214A-\u214D\u214F-\u215F\u2189-\u24B5\u24EA-\u2BFF\u2C2F\u2C5F\u2CE5-\u2CEA\u2CF4-\u2CFF\u2D26\u2D28-\u2D2C\u2D2E\u2D2F\u2D68-\u2D6E\u2D70-\u2D7E\u2D97-\u2D9F\u2DA7\u2DAF\u2DB7\u2DBF\u2DC7\u2DCF\u2DD7\u2DDF\u2E00-\u2E2E\u2E30-\u3004\u3008-\u3020\u3030\u3036\u3037\u303D-\u3040\u3097\u3098\u309B\u309C\u30A0\u30FB\u3100-\u3104\u3130\u318F-\u319F\u31C0-\u31EF\u3200-\u33FF\u4DC0-\u4DFF\u9FFD-\u9FFF\uA48D-\uA4CF\uA4FE\uA4FF\uA60D-\uA60F\uA62C-\uA63F\uA673\uA67E\uA6F2-\uA716\uA720\uA721\uA789\uA78A\uA7C0\uA7C1\uA7CB-\uA7F4\uA828-\uA82B\uA82D-\uA83F\uA874-\uA87F\uA8C6-\uA8CF\uA8DA-\uA8DF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA954-\uA95F\uA97D-\uA97F\uA9C1-\uA9CE\uA9DA-\uA9DF\uA9FF\uAA37-\uAA3F\uAA4E\uAA4F\uAA5A-\uAA5F\uAA77-\uAA79\uAAC3-\uAADA\uAADE\uAADF\uAAF0\uAAF1\uAAF7-\uAB00\uAB07\uAB08\uAB0F\uAB10\uAB17-\uAB1F\uAB27\uAB2F\uAB5B\uAB6A-\uAB6F\uABEB\uABEE\uABEF\uABFA-\uABFF\uD7A4-\uD7AF\uD7C7-\uD7CA\uD7FC-\uD7FF\uE000-\uF8FF\uFA6E\uFA6F\uFADA-\uFAFF\uFB07-\uFB12\uFB18-\uFB1C\uFB29\uFB37\uFB3D\uFB3F\uFB42\uFB45\uFBB2-\uFBD2\uFD3E-\uFD4F\uFD90\uFD91\uFDC8-\uFDEF\uFDFC-\uFDFF\uFE10-\uFE1F\uFE30-\uFE32\uFE35-\uFE4C\uFE50-\uFE6F\uFE75\uFEFD-\uFF0F\uFF1A-\uFF20\uFF3B-\uFF3E\uFF40\uFF5B-\uFF65\uFFBF-\uFFC1\uFFC8\uFFC9\uFFD0\uFFD1\uFFD8\uFFD9\uFFDD-\uFFFF]|\uD800[\uDC0C\uDC27\uDC3B\uDC3E\uDC4E\uDC4F\uDC5E-\uDC7F\uDCFB-\uDD3F\uDD75-\uDDFC\uDDFE-\uDE7F\uDE9D-\uDE9F\uDED1-\uDEDF\uDEE1-\uDEFF\uDF20-\uDF2C\uDF4B-\uDF4F\uDF7B-\uDF7F\uDF9E\uDF9F\uDFC4-\uDFC7\uDFD0\uDFD6-\uDFFF]|\uD801[\uDC9E\uDC9F\uDCAA-\uDCAF\uDCD4-\uDCD7\uDCFC-\uDCFF\uDD28-\uDD2F\uDD64-\uDDFF\uDF37-\uDF3F\uDF56-\uDF5F\uDF68-\uDFFF]|\uD802[\uDC06\uDC07\uDC09\uDC36\uDC39-\uDC3B\uDC3D\uDC3E\uDC56-\uDC5F\uDC77-\uDC7F\uDC9F-\uDCDF\uDCF3\uDCF6-\uDCFF\uDD16-\uDD1F\uDD3A-\uDD7F\uDDB8-\uDDBD\uDDC0-\uDDFF\uDE04\uDE07-\uDE0B\uDE14\uDE18\uDE36\uDE37\uDE3B-\uDE3E\uDE40-\uDE5F\uDE7D-\uDE7F\uDE9D-\uDEBF\uDEC8\uDEE7-\uDEFF\uDF36-\uDF3F\uDF56-\uDF5F\uDF73-\uDF7F\uDF92-\uDFFF]|\uD803[\uDC49-\uDC7F\uDCB3-\uDCBF\uDCF3-\uDCFF\uDD28-\uDD2F\uDD3A-\uDE7F\uDEAA\uDEAD-\uDEAF\uDEB2-\uDEFF\uDF1D-\uDF26\uDF28-\uDF2F\uDF51-\uDFAF\uDFC5-\uDFDF\uDFF7-\uDFFF]|\uD804[\uDC47-\uDC65\uDC70-\uDC7E\uDCBB-\uDCCF\uDCE9-\uDCEF\uDCFA-\uDCFF\uDD35\uDD40-\uDD43\uDD48-\uDD4F\uDD74\uDD75\uDD77-\uDD7F\uDDC5-\uDDC8\uDDCD\uDDDB\uDDDD-\uDDFF\uDE12\uDE38-\uDE3D\uDE3F-\uDE7F\uDE87\uDE89\uDE8E\uDE9E\uDEA9-\uDEAF\uDEEB-\uDEEF\uDEFA-\uDEFF\uDF04\uDF0D\uDF0E\uDF11\uDF12\uDF29\uDF31\uDF34\uDF3A\uDF45\uDF46\uDF49\uDF4A\uDF4E\uDF4F\uDF51-\uDF56\uDF58-\uDF5C\uDF64\uDF65\uDF6D-\uDF6F\uDF75-\uDFFF]|\uD805[\uDC4B-\uDC4F\uDC5A-\uDC5D\uDC62-\uDC7F\uDCC6\uDCC8-\uDCCF\uDCDA-\uDD7F\uDDB6\uDDB7\uDDC1-\uDDD7\uDDDE-\uDDFF\uDE41-\uDE43\uDE45-\uDE4F\uDE5A-\uDE7F\uDEB9-\uDEBF\uDECA-\uDEFF\uDF1B\uDF1C\uDF2C-\uDF2F\uDF3A-\uDFFF]|\uD806[\uDC3B-\uDC9F\uDCEA-\uDCFE\uDD07\uDD08\uDD0A\uDD0B\uDD14\uDD17\uDD36\uDD39\uDD3A\uDD44-\uDD4F\uDD5A-\uDD9F\uDDA8\uDDA9\uDDD8\uDDD9\uDDE2\uDDE5-\uDDFF\uDE3F-\uDE46\uDE48-\uDE4F\uDE9A-\uDE9C\uDE9E-\uDEBF\uDEF9-\uDFFF]|\uD807[\uDC09\uDC37\uDC41-\uDC4F\uDC5A-\uDC71\uDC90\uDC91\uDCA8\uDCB7-\uDCFF\uDD07\uDD0A\uDD37-\uDD39\uDD3B\uDD3E\uDD48-\uDD4F\uDD5A-\uDD5F\uDD66\uDD69\uDD8F\uDD92\uDD99-\uDD9F\uDDAA-\uDEDF\uDEF7-\uDFAF\uDFB1-\uDFFF]|\uD808[\uDF9A-\uDFFF]|\uD809[\uDC6F-\uDC7F\uDD44-\uDFFF]|[\uD80A\uD80B\uD80E-\uD810\uD812-\uD819\uD824-\uD82B\uD82D\uD82E\uD830-\uD833\uD837\uD839\uD83D\uD83F\uD87B-\uD87D\uD87F\uD885-\uDB3F\uDB41-\uDBFF][\uDC00-\uDFFF]|\uD80D[\uDC2F-\uDFFF]|\uD811[\uDE47-\uDFFF]|\uD81A[\uDE39-\uDE3F\uDE5F\uDE6A-\uDECF\uDEEE\uDEEF\uDEF5-\uDEFF\uDF37-\uDF3F\uDF44-\uDF4F\uDF5A-\uDF62\uDF78-\uDF7C\uDF90-\uDFFF]|\uD81B[\uDC00-\uDE3F\uDE80-\uDEFF\uDF4B-\uDF4E\uDF88-\uDF8E\uDFA0-\uDFDF\uDFE2\uDFE5-\uDFEF\uDFF2-\uDFFF]|\uD821[\uDFF8-\uDFFF]|\uD823[\uDCD6-\uDCFF\uDD09-\uDFFF]|\uD82C[\uDD1F-\uDD4F\uDD53-\uDD63\uDD68-\uDD6F\uDEFC-\uDFFF]|\uD82F[\uDC6B-\uDC6F\uDC7D-\uDC7F\uDC89-\uDC8F\uDC9A-\uDC9C\uDC9F-\uDFFF]|\uD834[\uDC00-\uDD64\uDD6A-\uDD6C\uDD73-\uDD7A\uDD83\uDD84\uDD8C-\uDDA9\uDDAE-\uDE41\uDE45-\uDFFF]|\uD835[\uDC55\uDC9D\uDCA0\uDCA1\uDCA3\uDCA4\uDCA7\uDCA8\uDCAD\uDCBA\uDCBC\uDCC4\uDD06\uDD0B\uDD0C\uDD15\uDD1D\uDD3A\uDD3F\uDD45\uDD47-\uDD49\uDD51\uDEA6\uDEA7\uDEC1\uDEDB\uDEFB\uDF15\uDF35\uDF4F\uDF6F\uDF89\uDFA9\uDFC3\uDFCC\uDFCD]|\uD836[\uDC00-\uDDFF\uDE37-\uDE3A\uDE6D-\uDE74\uDE76-\uDE83\uDE85-\uDE9A\uDEA0\uDEB0-\uDFFF]|\uD838[\uDC07\uDC19\uDC1A\uDC22\uDC25\uDC2B-\uDCFF\uDD2D-\uDD2F\uDD3E\uDD3F\uDD4A-\uDD4D\uDD4F-\uDEBF\uDEFA-\uDFFF]|\uD83A[\uDCC5-\uDCCF\uDCD7-\uDCFF\uDD4C-\uDD4F\uDD5A-\uDFFF]|\uD83B[\uDC00-\uDDFF\uDE04\uDE20\uDE23\uDE25\uDE26\uDE28\uDE33\uDE38\uDE3A\uDE3C-\uDE41\uDE43-\uDE46\uDE48\uDE4A\uDE4C\uDE50\uDE53\uDE55\uDE56\uDE58\uDE5A\uDE5C\uDE5E\uDE60\uDE63\uDE65\uDE66\uDE6B\uDE73\uDE78\uDE7D\uDE7F\uDE8A\uDE9C-\uDEA0\uDEA4\uDEAA\uDEBC-\uDFFF]|\uD83C[\uDC00-\uDD2F\uDD4A-\uDD4F\uDD6A-\uDD6F\uDD8A-\uDFFF]|\uD83E[\uDC00-\uDFEF\uDFFA-\uDFFF]|\uD869[\uDEDE-\uDEFF]|\uD86D[\uDF35-\uDF3F]|\uD86E[\uDC1E\uDC1F]|\uD873[\uDEA2-\uDEAF]|\uD87A[\uDFE1-\uDFFF]|\uD87E[\uDE1E-\uDFFF]|\uD884[\uDF4B-\uDFFF]|\uDB40[\uDC00-\uDCFF\uDDF0-\uDFFF]/g,Ln=Object.hasOwnProperty;var Rn=class{constructor(){this.occurrences,this.reset()}slug(e,t){let n=this,r=zn(e,t===!0),i=r;for(;Ln.call(n.occurrences,r);)n.occurrences[i]++,r=i+`-`+n.occurrences[i];return n.occurrences[r]=0,r}reset(){this.occurrences=Object.create(null)}};function zn(e,t){return typeof e==`string`?(t||(e=e.toLowerCase()),e.replace(In,``).replace(/ /g,`-`)):``}var Bn=j({name:`prismic docs view`,description:`
28
28
  View a documentation page as Markdown.
29
29
 
30
30
  Append #anchor to the path to view only the section under that heading.
31
- `,positionals:{path:{description:`Documentation path, optionally with #anchor (e.g., setup#install)`,required:!0}},options:{json:{type:`boolean`,description:`Output as JSON`}}},async({positionals:e,values:t})=>{let[n]=e,{json:r}=t,i=n.indexOf(`#`),a=i>=0?n.slice(0,i):n,o=i>=0?n.slice(i+1):void 0,s=await xt(a,{host:I.PRISMIC_DOCS_HOST,headers:Se()});if(o){let e=zn(s,o);if(!e)throw new L(`Anchor not found: #${o}`);s=e}console.info(r?W({path:a,anchor:o,content:s}):s)});function zn(e,t){let n=e.split(`
32
- `),r=new In,i,a,o,s;for(let e=0;e<n.length;e++){let c=n[e],l=c.match(/^(?<fence>`{3,}|~{3,})/)?.groups?.fence;if(i){l?.startsWith(i)&&(i=void 0);continue}if(l){i=l;continue}let u=c.match(/^(?<level>#{1,6})\s+(?<text>.*)/);if(u?.groups?.level&&u?.groups?.text){if(a!==void 0&&s!==void 0&&u.groups.level.length<=s){o=e;break}r.slug(u.groups.text)===t&&(a=e,s=u.groups.level.length)}}if(a!==void 0)return n.slice(a,o).join(`
33
- `).trim()}var Bn=A({name:`prismic docs`,description:`Browse Prismic documentation.`,commands:{list:{handler:Nn,description:`List available documentation pages`},view:{handler:Rn,description:`View a documentation page`}}}),Vn=S({name:`prismic env active`,description:`Print the active environment.`},async()=>{let e=await O(),t=await(await P()).getEnvironment();console.info(t??e)});async function Hn(e){let{results:t}=await u(e),n=await ee(await e.getToken(),e);return n.type===`Machine2Machine`?t.filter(e=>e.domain===n.domain):t.filter(e=>(e.kind===`prod`||e.kind===`stage`)&&e.users.some(e=>e.id===n.shortId))}var Un=class extends Error{name=`InvalidEnvironmentError`;constructor(e,t,n){if(t.length===1&&n===t[0].domain)super(`No environments available on repository "${n}".`);else{let r=t.map(e=>e.domain).join(`
34
- `);super(le`
31
+ `,positionals:{path:{description:`Documentation path, optionally with #anchor (e.g., setup#install)`,required:!0}},options:{json:{type:`boolean`,description:`Output as JSON`}}},async({positionals:e,values:t})=>{let[n]=e,{json:r}=t,i=n.indexOf(`#`),a=i>=0?n.slice(0,i):n,o=i>=0?n.slice(i+1):void 0,s=await me(a,{host:F.PRISMIC_DOCS_HOST,headers:Se()});if(o){let e=Vn(s,o);if(!e)throw new S(`Anchor not found: #${o}`);s=e}console.info(r?G({path:a,anchor:o,content:s}):s)});function Vn(e,t){let n=e.split(`
32
+ `),r=new Rn,i,a,o,s;for(let e=0;e<n.length;e++){let c=n[e],l=c.match(/^(?<fence>`{3,}|~{3,})/)?.groups?.fence;if(i){l?.startsWith(i)&&(i=void 0);continue}if(l){i=l;continue}let u=c.match(/^(?<level>#{1,6})\s+(?<text>.*)/);if(u?.groups?.level&&u?.groups?.text){if(a!==void 0&&s!==void 0&&u.groups.level.length<=s){o=e;break}r.slug(u.groups.text)===t&&(a=e,s=u.groups.level.length)}}if(a!==void 0)return n.slice(a,o).join(`
33
+ `).trim()}var Hn=A({name:`prismic docs`,description:`Browse Prismic documentation.`,commands:{list:{handler:Fn,description:`List available documentation pages`},view:{handler:Bn,description:`View a documentation page`}}}),Un=j({name:`prismic env active`,description:`Print the active environment.`},async()=>{let e=await O(),t=await(await P()).getEnvironment();console.info(t??e)});async function Wn(e){let{results:t}=await se(e),n=await ut(await e.getToken(),e);return n.type===`Machine2Machine`?t.filter(e=>e.domain===n.domain):t.filter(e=>(e.kind===`prod`||e.kind===`stage`)&&e.users.some(e=>e.id===n.shortId))}var Gn=class extends Error{name=`InvalidEnvironmentError`;constructor(e,t,n){if(t.length===1&&n===t[0].domain)super(`No environments available on repository "${n}".`);else{let i=t.map(e=>e.domain).join(`
34
+ `);super(r`
35
35
  Environment "${e}" not found on repository "${n}".
36
36
 
37
37
  Available environments:
38
- ${r}
39
- `)}}},Wn=S({name:`prismic env list`,description:`List the environments available for the project.`,options:{json:{type:`boolean`,description:`Output as JSON`},repo:{type:`string`,short:`r`,description:`Repository domain`}}},async({values:e})=>{let t=await O(),{json:n,repo:r=t}=e,i=await h(),a=await Hn({repo:r,getToken:C,host:i,onUnauthorized:x}),o;if(r===t&&(o=await(await P()).getEnvironment()??t),n){let e=a.map(e=>({domain:e.domain,kind:e.kind,active:e.domain===o}));console.info(W(e));return}let s=a.map(e=>[e.domain,e.kind,e.domain===o?`*`:``]);console.info(M(s,{headers:[`DOMAIN`,`KIND`,`ACTIVE`]}))}),Gn=S({name:`prismic env set`,description:`Set the active environment.`,positionals:{environment:{description:`Environment domain`,required:!0}}},async({positionals:e})=>{let[t]=e,n=await O(),r=await h(),i=await Hn({repo:n,getToken:C,host:r,onUnauthorized:x});if(!i.some(e=>e.domain===t))throw new Un(t,i,n);let a=await P();t===n?(await a.unsetEnvironment(),console.info(`Reset to the production environment "${n}".`)):(await a.setEnvironment(t),console.info(`Set the active environment to "${t}".`));let o=await a.getSetupInstructions();o&&console.info(`\n${o}`)}),Kn=S({name:`prismic env unset`,description:`Reset the active environment to the production environment.`},async()=>{let e=await O();await(await P()).unsetEnvironment(),console.info(`Reset to the production environment "${e}".`)}),qn=A({name:`prismic env`,description:`
38
+ ${i}
39
+ `)}}},Kn=j({name:`prismic env list`,description:`List the environments available for the project.`,options:{json:{type:`boolean`,description:`Output as JSON`},repo:{type:`string`,short:`r`,description:`Repository domain`}}},async({values:e})=>{let t=await O(),{json:n,repo:r=t}=e,i=await g(),a=await Wn({repo:r,getToken:C,host:i,onUnauthorized:x}),o;if(r===t&&(o=await(await P()).getEnvironment()??t),n){let e=a.map(e=>({domain:e.domain,kind:e.kind,active:e.domain===o}));console.info(G(e));return}let s=a.map(e=>[e.domain,e.kind,e.domain===o?`*`:``]);console.info(L(s,{headers:[`DOMAIN`,`KIND`,`ACTIVE`]}))}),qn=j({name:`prismic env set`,description:`Set the active environment.`,positionals:{environment:{description:`Environment domain`,required:!0}}},async({positionals:e})=>{let[t]=e,n=await O(),r=await g(),i=await Wn({repo:n,getToken:C,host:r,onUnauthorized:x});if(!i.some(e=>e.domain===t))throw new Gn(t,i,n);let a=await P();t===n?(await a.unsetEnvironment(),console.info(`Reset to the production environment "${n}".`)):(await a.setEnvironment(t),console.info(`Set the active environment to "${t}".`));let o=await a.getSetupInstructions();o&&console.info(`\n${o}`)}),Jn=j({name:`prismic env unset`,description:`Reset the active environment to the production environment.`},async()=>{let e=await O();await(await P()).unsetEnvironment(),console.info(`Reset to the production environment "${e}".`)}),Yn=A({name:`prismic env`,description:`
40
40
  Manage the active environment for a Prismic project.
41
41
 
42
42
  Run \`prismic docs view environments\` for details.
43
- `,commands:{set:{handler:Gn,description:`Set the active environment`},unset:{handler:Kn,description:`Reset to the production environment`},active:{handler:Vn,description:`Print the active environment`},list:{handler:Wn,description:`List environments`}}});const J={"to-slice":{type:`string`,description:`ID of the target slice`},"to-type":{type:`string`,description:`ID of the target content type`},variation:{type:`string`,description:`Slice variation ID (default: "default")`,dependsOn:`to-slice`},"legacy-items-zone":{type:`boolean`,description:`Edit the legacy repeatable zone of a slice upgraded from the Legacy Builder. New slices use a repeatable group instead.`,dependsOn:`to-slice`},tab:{type:`string`,description:`Content type tab name (default: "Main")`,dependsOn:`to-type`}},Jn={"from-slice":{type:`string`,description:`ID of the source slice`},"from-type":{type:`string`,description:`ID of the source content type`},variation:{type:`string`,description:`Slice variation ID (default: "default")`,dependsOn:`from-slice`},"legacy-items-zone":{type:`boolean`,description:`Edit the legacy repeatable zone of a slice upgraded from the Legacy Builder. New slices use a repeatable group instead.`,dependsOn:`from-slice`}};async function Yn(e,t,n){let{variation:r=`default`,"legacy-items-zone":i}=n,{key:o,value:s}=be(n,[`from-slice`,`from-type`]),c=await P(),u,d,f;if(o===`from-slice`){let{model:n}=await c.getSlice(s);u=$n(e,n,r,i),d=$n(t,n,r,i),f=async()=>{await c.updateSlice(n),await c.generateTypes()}}else{let{model:n}=await c.getCustomType(s);u=a(e,n),d=a(t,n),f=async()=>{await c.updateCustomType(n),await c.generateTypes()}}if(!(u.fieldId in u.fields))throw new l(e);if(!(d.fieldId in d.fields))throw new l(t);return{source:u,anchor:d,save:f}}async function Y(e,t){let{tab:n=`Main`,variation:r=`default`}=t,{key:i,value:a}=be(t,[`to-slice`,`to-type`]),o=i===`to-slice`?await Qn(e,a,r,t[`legacy-items-zone`]):await er(e,a,n);if(o.fieldId in o.fields)throw new d(e);return o}async function Xn(e,t){let{variation:n=`default`}=t,{key:r,value:i}=be(t,[`from-slice`,`from-type`]),a=r===`from-slice`?await Qn(e,i,n,t[`legacy-items-zone`]):await er(e,i),o=a.fields[a.fieldId];if(!o)throw new l(e);return{...a,field:o}}async function Zn(e,t){let n=await(await P()).getCustomTypes();return Tt(e,t,n.map(({model:e})=>e))}async function Qn(e,t,n,r){let i=await P(),{model:a}=await i.getSlice(t);return{...$n(e,a,n,r),save:async()=>{await i.updateSlice(a),await i.generateTypes()}}}function $n(e,t,n,r){try{return he(e,t,n,r)}catch(e){if(!(e instanceof Je))throw e;let r=`--to-slice ${t.id}`;throw n!=="default"&&(r+=` --variation ${n}`),new L(`${e.message}\nHint: prismic field add group items ${r}\nThen add fields to the group: prismic field add text items.<field_id> ${r}`)}}async function er(e,t,n){let r=await P(),{model:i}=await r.getCustomType(t);return{...a(e,i,n),save:async()=>{await r.updateCustomType(i),await r.generateTypes()}}}function X(e,t){if(e===void 0)return;let n=Number(e);if(Number.isNaN(n))throw new L(`--${t} must be a valid number, got "${e}"`);return n}function tr(e){let t=Object.entries(e);if(t.length===0)return` (no fields)`;let n=t.map(([e,t])=>{let n=t.config,r=n?.label||``,i=n?.placeholder?`"${n.placeholder}"`:``;return[` ${e}`,t.type,r,i]});return M(n)}const nr={name:`prismic field add boolean`,description:`
43
+ `,commands:{set:{handler:qn,description:`Set the active environment`},unset:{handler:Jn,description:`Reset to the production environment`},active:{handler:Un,description:`Print the active environment`},list:{handler:Kn,description:`List environments`}}});const J={"to-slice":{type:`string`,description:`ID of the target slice`},"to-type":{type:`string`,description:`ID of the target content type`},variation:{type:`string`,description:`Slice variation ID (default: "default")`,dependsOn:`to-slice`},"legacy-items-zone":{type:`boolean`,description:`Edit the legacy repeatable zone of a slice upgraded from the Legacy Builder. New slices use a repeatable group instead.`,dependsOn:`to-slice`},tab:{type:`string`,description:`Content type tab name (default: "Main")`,dependsOn:`to-type`}},Xn={"from-slice":{type:`string`,description:`ID of the source slice`},"from-type":{type:`string`,description:`ID of the source content type`},variation:{type:`string`,description:`Slice variation ID (default: "default")`,dependsOn:`from-slice`},"legacy-items-zone":{type:`boolean`,description:`Edit the legacy repeatable zone of a slice upgraded from the Legacy Builder. New slices use a repeatable group instead.`,dependsOn:`from-slice`}};async function Zn(e,t,n){let{variation:r=`default`,"legacy-items-zone":i}=n,{key:a,value:s}=Ce(n,[`from-slice`,`from-type`]),c=await P(),l,d,f;if(a===`from-slice`){let{model:n}=await c.getSlice(s);l=tr(e,n,r,i),d=tr(t,n,r,i),f=async()=>{await c.updateSlice(n),await c.generateTypes()}}else{let{model:n}=await c.getCustomType(s);l=o(e,n),d=o(t,n),f=async()=>{await c.updateCustomType(n),await c.generateTypes()}}if(!(l.fieldId in l.fields))throw new u(e);if(!(d.fieldId in d.fields))throw new u(t);return{source:l,anchor:d,save:f}}async function Y(e,t){let{tab:n=`Main`,variation:r=`default`}=t,{key:i,value:a}=Ce(t,[`to-slice`,`to-type`]),o=i===`to-slice`?await er(e,a,r,t[`legacy-items-zone`]):await nr(e,a,n);if(o.fieldId in o.fields)throw new f(e);return o}async function Qn(e,t){let{variation:n=`default`}=t,{key:r,value:i}=Ce(t,[`from-slice`,`from-type`]),a=r===`from-slice`?await er(e,i,n,t[`legacy-items-zone`]):await nr(e,i),o=a.fields[a.fieldId];if(!o)throw new u(e);return{...a,field:o}}async function $n(e,t){let n=await(await P()).getCustomTypes();return Et(e,t,n.map(({model:e})=>e))}async function er(e,t,n,r){let i=await P(),{model:a}=await i.getSlice(t);return{...tr(e,a,n,r),save:async()=>{await i.updateSlice(a),await i.generateTypes()}}}function tr(e,t,n,r){try{return ge(e,t,n,r)}catch(e){if(!(e instanceof Ye))throw e;let r=`--to-slice ${t.id}`;throw n!=="default"&&(r+=` --variation ${n}`),new S(`${e.message}\nHint: prismic field add group items ${r}\nThen add fields to the group: prismic field add text items.<field_id> ${r}`)}}async function nr(e,t,n){let r=await P(),{model:i}=await r.getCustomType(t);return{...o(e,i,n),save:async()=>{await r.updateCustomType(i),await r.generateTypes()}}}function X(e,t){if(e===void 0)return;let n=Number(e);if(Number.isNaN(n))throw new S(`--${t} must be a valid number, got "${e}"`);return n}function rr(e){let t=Object.entries(e);if(t.length===0)return` (no fields)`;let n=t.map(([e,t])=>{let n=t.config,r=n?.label||``,i=n?.placeholder?`"${n.placeholder}"`:``;return[` ${e}`,t.type,r,i]});return L(n)}const ir={name:`prismic field add boolean`,description:`
44
44
  Add a boolean field to a slice or custom type.
45
45
 
46
46
  Run \`prismic docs view fields/boolean\` for details.
47
- `,positionals:{id:{description:`Field ID`,required:!0}},options:{...J,label:{type:`string`,description:`Field label`},"default-true":{type:`boolean`,description:`Default the field to true`},"default-false":{type:`boolean`,description:`Default the field to false`},"true-label":{type:`string`,description:`Label for true value`},"false-label":{type:`string`,description:`Label for false value`}}};var rr=S(nr,async({positionals:e,values:t})=>{let[n]=e;Ce(t,[`default-true`,`default-false`]);let{label:r,"true-label":i,"false-label":a}=t,{fields:o,fieldId:s,save:c}=await Y(n,t),l={type:`Boolean`,config:{label:r??N(s),default_value:!t[`default-false`]&&t[`default-true`],placeholder_true:i,placeholder_false:a}};E(o,s,l),await c(),console.info(`Field added: ${n}`)});const ir={name:`prismic field add color`,description:`
47
+ `,positionals:{id:{description:`Field ID`,required:!0}},options:{...J,label:{type:`string`,description:`Field label`},"default-true":{type:`boolean`,description:`Default the field to true`},"default-false":{type:`boolean`,description:`Default the field to false`},"true-label":{type:`string`,description:`Label for true value`},"false-label":{type:`string`,description:`Label for false value`}}};var ar=j(ir,async({positionals:e,values:t})=>{let[n]=e;de(t,[`default-true`,`default-false`]);let{label:r,"true-label":i,"false-label":a}=t,{fields:o,fieldId:s,save:c}=await Y(n,t),l={type:`Boolean`,config:{label:r??N(s),default_value:!t[`default-false`]&&t[`default-true`],placeholder_true:i,placeholder_false:a}};T(o,s,l),await c(),console.info(`Field added: ${n}`)});const or={name:`prismic field add color`,description:`
48
48
  Add a color field to a slice or custom type.
49
49
 
50
50
  Run \`prismic docs view fields/color\` for details.
51
- `,positionals:{id:{description:`Field ID`,required:!0}},options:{...J,label:{type:`string`,description:`Field label`},placeholder:{type:`string`,description:`Placeholder text`}}};var ar=S(ir,async({positionals:e,values:t})=>{let[n]=e,{label:r,placeholder:i}=t,{fields:a,fieldId:o,save:s}=await Y(n,t),c={type:`Color`,config:{label:r??N(o),placeholder:i}};E(a,o,c),await s(),console.info(`Field added: ${n}`)});const or={name:`prismic field add content-relationship`,description:`
51
+ `,positionals:{id:{description:`Field ID`,required:!0}},options:{...J,label:{type:`string`,description:`Field label`},placeholder:{type:`string`,description:`Placeholder text`}}};var sr=j(or,async({positionals:e,values:t})=>{let[n]=e,{label:r,placeholder:i}=t,{fields:a,fieldId:o,save:s}=await Y(n,t),c={type:`Color`,config:{label:r??N(o),placeholder:i}};T(a,o,c),await s(),console.info(`Field added: ${n}`)});const cr={name:`prismic field add content-relationship`,description:`
52
52
  Add a content relationship field to a slice or custom type.
53
53
 
54
54
  Content relationships fetch and display data from related documents
@@ -79,31 +79,31 @@ Ending the session...`),await f()&&console.info(`Session ended.`)});async functi
79
79
 
80
80
  Fetch fields from the related document:
81
81
  prismic field add content-relationship author --to-type blog_post --custom-type author --field name --field bio
82
- `},positionals:{id:{description:`Field ID`,required:!0}},options:{...J,label:{type:`string`,description:`Field label`},tag:{type:`string`,multiple:!0,description:`Restrict to documents with this tag (can be repeated)`},"custom-type":{type:`string`,multiple:!0,description:`Restrict to documents of this type (can be repeated)`},field:{type:`string`,multiple:!0,description:`Fetch this field from the related document (can be repeated, requires one --custom-type)`}}};var sr=S(or,async({positionals:e,values:t})=>{let[n]=e,{label:r,tag:i,"custom-type":a,field:o}=t;if(o&&(!a||a.length!==1))throw new L(`--field requires exactly one --custom-type.`);let{fields:s,fieldId:c,save:l}=await Y(n,t),u=a;if(o&&a){let e=await Zn(o,a[0]);u=[{id:a[0],fields:e}]}let d={type:`Link`,config:{label:r??N(c),select:`document`,tags:i,customtypes:u}};E(s,c,d),await l(),console.info(`Field added: ${n}`)});const cr={name:`prismic field add date`,description:`
82
+ `},positionals:{id:{description:`Field ID`,required:!0}},options:{...J,label:{type:`string`,description:`Field label`},tag:{type:`string`,multiple:!0,description:`Restrict to documents with this tag (can be repeated)`},"custom-type":{type:`string`,multiple:!0,description:`Restrict to documents of this type (can be repeated)`},field:{type:`string`,multiple:!0,description:`Fetch this field from the related document (can be repeated, requires one --custom-type)`}}};var lr=j(cr,async({positionals:e,values:t})=>{let[n]=e,{label:r,tag:i,"custom-type":a,field:o}=t;if(o&&(!a||a.length!==1))throw new S(`--field requires exactly one --custom-type.`);let{fields:s,fieldId:c,save:l}=await Y(n,t),u=a;if(o&&a){let e=await $n(o,a[0]);u=[{id:a[0],fields:e}]}let d={type:`Link`,config:{label:r??N(c),select:`document`,tags:i,customtypes:u}};T(s,c,d),await l(),console.info(`Field added: ${n}`)});const ur={name:`prismic field add date`,description:`
83
83
  Add a date field to a slice or custom type.
84
84
 
85
85
  Run \`prismic docs view fields/date\` for details.
86
- `,positionals:{id:{description:`Field ID`,required:!0}},options:{...J,label:{type:`string`,description:`Field label`},placeholder:{type:`string`,description:`Placeholder text`},default:{type:`string`,description:`Default value`}}};var lr=S(cr,async({positionals:e,values:t})=>{let[n]=e,{label:r,placeholder:i,default:a}=t,{fields:o,fieldId:s,save:c}=await Y(n,t),l={type:`Date`,config:{label:r??N(s),placeholder:i,default:a}};E(o,s,l),await c(),console.info(`Field added: ${n}`)});const ur={name:`prismic field add embed`,description:`
86
+ `,positionals:{id:{description:`Field ID`,required:!0}},options:{...J,label:{type:`string`,description:`Field label`},placeholder:{type:`string`,description:`Placeholder text`},default:{type:`string`,description:`Default value`}}};var dr=j(ur,async({positionals:e,values:t})=>{let[n]=e,{label:r,placeholder:i,default:a}=t,{fields:o,fieldId:s,save:c}=await Y(n,t),l={type:`Date`,config:{label:r??N(s),placeholder:i,default:a}};T(o,s,l),await c(),console.info(`Field added: ${n}`)});const fr={name:`prismic field add embed`,description:`
87
87
  Add an embed field to a slice or custom type.
88
88
 
89
89
  Run \`prismic docs view fields/embed\` for details.
90
- `,positionals:{id:{description:`Field ID`,required:!0}},options:{...J,label:{type:`string`,description:`Field label`},placeholder:{type:`string`,description:`Placeholder text`}}};var dr=S(ur,async({positionals:e,values:t})=>{let[n]=e,{label:r,placeholder:i}=t,{fields:a,fieldId:o,save:s}=await Y(n,t),c={type:`Embed`,config:{label:r??N(o),placeholder:i}};E(a,o,c),await s(),console.info(`Field added: ${n}`)});const fr={name:`prismic field add geopoint`,description:`
90
+ `,positionals:{id:{description:`Field ID`,required:!0}},options:{...J,label:{type:`string`,description:`Field label`},placeholder:{type:`string`,description:`Placeholder text`}}};var pr=j(fr,async({positionals:e,values:t})=>{let[n]=e,{label:r,placeholder:i}=t,{fields:a,fieldId:o,save:s}=await Y(n,t),c={type:`Embed`,config:{label:r??N(o),placeholder:i}};T(a,o,c),await s(),console.info(`Field added: ${n}`)});const mr={name:`prismic field add geopoint`,description:`
91
91
  Add a geopoint field to a slice or custom type.
92
92
 
93
93
  Run \`prismic docs view fields/geopoint\` for details.
94
- `,positionals:{id:{description:`Field ID`,required:!0}},options:{...J,label:{type:`string`,description:`Field label`}}};var pr=S(fr,async({positionals:e,values:t})=>{let[n]=e,{label:r}=t,{fields:i,fieldId:a,save:o}=await Y(n,t),s={type:`GeoPoint`,config:{label:r??N(a)}};E(i,a,s),await o(),console.info(`Field added: ${n}`)});const mr={name:`prismic field add group`,description:`
94
+ `,positionals:{id:{description:`Field ID`,required:!0}},options:{...J,label:{type:`string`,description:`Field label`}}};var hr=j(mr,async({positionals:e,values:t})=>{let[n]=e,{label:r}=t,{fields:i,fieldId:a,save:o}=await Y(n,t),s={type:`GeoPoint`,config:{label:r??N(a)}};T(i,a,s),await o(),console.info(`Field added: ${n}`)});const gr={name:`prismic field add group`,description:`
95
95
  Add a group field to a slice or custom type.
96
96
 
97
97
  Run \`prismic docs view fields/repeatable-group\` for details.
98
- `,positionals:{id:{description:`Field ID`,required:!0}},options:{...J,label:{type:`string`,description:`Field label`}}};var hr=S(mr,async({positionals:e,values:t})=>{let[n]=e,{label:r}=t;if(t[`legacy-items-zone`])throw new L(`Group fields cannot be added to the legacy items zone.`);let{fields:i,fieldId:a,save:o}=await Y(n,t),s={type:`Group`,config:{label:r??N(a)}};E(i,a,s),await o(),console.info(`Field added: ${n}`)});const gr={name:`prismic field add image`,description:`
98
+ `,positionals:{id:{description:`Field ID`,required:!0}},options:{...J,label:{type:`string`,description:`Field label`}}};var _r=j(gr,async({positionals:e,values:t})=>{let[n]=e,{label:r}=t;if(t[`legacy-items-zone`])throw new S(`Group fields cannot be added to the legacy items zone.`);let{fields:i,fieldId:a,save:o}=await Y(n,t),s={type:`Group`,config:{label:r??N(a)}};T(i,a,s),await o(),console.info(`Field added: ${n}`)});const vr={name:`prismic field add image`,description:`
99
99
  Add an image field to a slice or custom type.
100
100
 
101
101
  Run \`prismic docs view fields/image\` for details.
102
- `,positionals:{id:{description:`Field ID`,required:!0}},options:{...J,label:{type:`string`,description:`Field label`},placeholder:{type:`string`,description:`Placeholder text`}}};var _r=S(gr,async({positionals:e,values:t})=>{let[n]=e,{label:r,placeholder:i}=t,{fields:a,fieldId:o,save:s}=await Y(n,t),c={type:`Image`,config:{label:r??N(o),placeholder:i}};E(a,o,c),await s(),console.info(`Field added: ${n}`)});const vr={name:`prismic field add integration`,description:`
102
+ `,positionals:{id:{description:`Field ID`,required:!0}},options:{...J,label:{type:`string`,description:`Field label`},placeholder:{type:`string`,description:`Placeholder text`}}};var yr=j(vr,async({positionals:e,values:t})=>{let[n]=e,{label:r,placeholder:i}=t,{fields:a,fieldId:o,save:s}=await Y(n,t),c={type:`Image`,config:{label:r??N(o),placeholder:i}};T(a,o,c),await s(),console.info(`Field added: ${n}`)});const br={name:`prismic field add integration`,description:`
103
103
  Add an integration field to a slice or custom type.
104
104
 
105
105
  Run \`prismic docs view fields/integration\` for details.
106
- `,positionals:{id:{description:`Field ID`,required:!0}},options:{...J,label:{type:`string`,description:`Field label`},placeholder:{type:`string`,description:`Placeholder text`},catalog:{type:`string`,description:`Integration catalog ID`}}};var yr=S(vr,async({positionals:e,values:t})=>{let[n]=e,{label:r,placeholder:i,catalog:a}=t,{fields:o,fieldId:s,save:c}=await Y(n,t),l={type:`IntegrationFields`,config:{label:r??N(s),placeholder:i,catalog:a}};E(o,s,l),await c(),console.info(`Field added: ${n}`)});const br={name:`prismic field add link`,description:`
106
+ `,positionals:{id:{description:`Field ID`,required:!0}},options:{...J,label:{type:`string`,description:`Field label`},placeholder:{type:`string`,description:`Placeholder text`},catalog:{type:`string`,description:`Integration catalog ID`}}};var xr=j(br,async({positionals:e,values:t})=>{let[n]=e,{label:r,placeholder:i,catalog:a}=t,{fields:o,fieldId:s,save:c}=await Y(n,t),l={type:`IntegrationFields`,config:{label:r??N(s),placeholder:i,catalog:a}};T(o,s,l),await c(),console.info(`Field added: ${n}`)});const Sr={name:`prismic field add link`,description:`
107
107
  Add a link field to a slice or custom type. Use for navigational links to URLs, documents, or media. For data-level relations between documents, use content-relationship instead.
108
108
 
109
109
  Run \`prismic docs view fields/link\` for details.
@@ -119,11 +119,11 @@ Ending the session...`),await f()&&console.info(`Session ended.`)});async functi
119
119
 
120
120
  Allow any link type, but restrict document links to a type:
121
121
  prismic field add link cta --to-type landing_page --custom-type page
122
- `},positionals:{id:{description:`Field ID`,required:!0}},options:{...J,label:{type:`string`,description:`Field label`},allow:{type:`string`,description:`Restrict to a link type: document, media, or web`},"allow-target-blank":{type:`boolean`,description:`Allow opening in new tab`},"allow-text":{type:`boolean`,description:`Allow custom link text`},repeatable:{type:`boolean`,description:`Allow multiple links`},variant:{type:`string`,multiple:!0,description:`Allowed variant (can be repeated)`},"custom-type":{type:`string`,multiple:!0,description:`Restrict document links to this custom type (can be repeated)`}}};var xr=S(br,async({positionals:e,values:t})=>{let[n]=e,r=[`document`,`media`,`web`],{label:i,allow:a,"allow-target-blank":o,"allow-text":s,repeatable:c,variant:l,"custom-type":u}=t;if(a?.includes(`,`))throw new L(`--allow accepts a single link type. Prismic links allow either one type or all types.`);if(a&&!r.includes(a))throw new L(`--allow must be one of: ${r.join(`, `)}`);let d=a;if(u&&(d===`media`||d===`web`))throw new L(`--custom-type cannot be used with --allow ${d}`);let{fields:f,fieldId:p,save:m}=await Y(n,t),h={type:`Link`,config:{label:i??N(p),select:d,allowTargetBlank:o,allowText:s,repeat:c,variants:l,customtypes:u}};E(f,p,h),await m(),console.info(`Field added: ${n}`)});const Sr={name:`prismic field add number`,description:`
122
+ `},positionals:{id:{description:`Field ID`,required:!0}},options:{...J,label:{type:`string`,description:`Field label`},allow:{type:`string`,description:`Restrict to a link type: document, media, or web`},"allow-target-blank":{type:`boolean`,description:`Allow opening in new tab`},"allow-text":{type:`boolean`,description:`Allow custom link text`},repeatable:{type:`boolean`,description:`Allow multiple links`},variant:{type:`string`,multiple:!0,description:`Allowed variant (can be repeated)`},"custom-type":{type:`string`,multiple:!0,description:`Restrict document links to this custom type (can be repeated)`}}};var Cr=j(Sr,async({positionals:e,values:t})=>{let[n]=e,r=[`document`,`media`,`web`],{label:i,allow:a,"allow-target-blank":o,"allow-text":s,repeatable:c,variant:l,"custom-type":u}=t;if(a?.includes(`,`))throw new S(`--allow accepts a single link type. Prismic links allow either one type or all types.`);if(a&&!r.includes(a))throw new S(`--allow must be one of: ${r.join(`, `)}`);let d=a;if(u&&(d===`media`||d===`web`))throw new S(`--custom-type cannot be used with --allow ${d}`);let{fields:f,fieldId:p,save:m}=await Y(n,t),h={type:`Link`,config:{label:i??N(p),select:d,allowTargetBlank:o,allowText:s,repeat:c,variants:l,customtypes:u}};T(f,p,h),await m(),console.info(`Field added: ${n}`)});const wr={name:`prismic field add number`,description:`
123
123
  Add a number field to a slice or custom type.
124
124
 
125
125
  Run \`prismic docs view fields/number\` for details.
126
- `,positionals:{id:{description:`Field ID`,required:!0}},options:{...J,label:{type:`string`,description:`Field label`},placeholder:{type:`string`,description:`Placeholder text`},min:{type:`string`,description:`Minimum value`},max:{type:`string`,description:`Maximum value`},step:{type:`string`,description:`Step increment`}}};var Cr=S(Sr,async({positionals:e,values:t})=>{let[n]=e,{label:r,placeholder:i}=t,a=X(t.min,`min`),o=X(t.max,`max`),s=X(t.step,`step`),{fields:c,fieldId:l,save:u}=await Y(n,t),d={type:`Number`,config:{label:r??N(l),placeholder:i,min:a,max:o,step:s}};E(c,l,d),await u(),console.info(`Field added: ${n}`)});const wr={name:`prismic field add rich-text`,description:`
126
+ `,positionals:{id:{description:`Field ID`,required:!0}},options:{...J,label:{type:`string`,description:`Field label`},placeholder:{type:`string`,description:`Placeholder text`},min:{type:`string`,description:`Minimum value`},max:{type:`string`,description:`Maximum value`},step:{type:`string`,description:`Step increment`}}};var Tr=j(wr,async({positionals:e,values:t})=>{let[n]=e,{label:r,placeholder:i}=t,a=X(t.min,`min`),o=X(t.max,`max`),s=X(t.step,`step`),{fields:c,fieldId:l,save:u}=await Y(n,t),d={type:`Number`,config:{label:r??N(l),placeholder:i,min:a,max:o,step:s}};T(c,l,d),await u(),console.info(`Field added: ${n}`)});const Er={name:`prismic field add rich-text`,description:`
127
127
  Add a rich text field to a slice or custom type.
128
128
 
129
129
  Run \`prismic docs view fields/rich-text\` for details.
@@ -137,7 +137,7 @@ Ending the session...`),await f()&&console.info(`Session ended.`)});async functi
137
137
 
138
138
  Add a body field with only headings and paragraphs:
139
139
  prismic field add rich-text body --to-type blog_post --allow heading1,heading2,paragraph,strong,em,hyperlink
140
- `},positionals:{id:{description:`Field ID`,required:!0}},options:{...J,label:{type:`string`,description:`Field label`},placeholder:{type:`string`,description:`Placeholder text`},allow:{type:`string`,description:`Comma-separated allowed block types (e.g. heading1,heading2,paragraph)`},single:{type:`boolean`,description:`Restrict to a single block`},labels:{type:`string`,description:`Comma-separated custom labels for styling text spans (e.g. highlight,quote)`},"allow-target-blank":{type:`boolean`,description:`Allow opening links in new tab`}}};var Tr=S(wr,async({positionals:e,values:t})=>{let[n]=e,{label:r,placeholder:i,allow:a=`paragraph,preformatted,heading1,heading2,heading3,heading4,heading5,heading6,strong,em,hyperlink,image,embed,list-item,o-list-item,rtl`,single:o,labels:s,"allow-target-blank":c}=t,{fields:l,fieldId:u,save:d}=await Y(n,t),f={type:`StructuredText`,config:{label:r??N(u),placeholder:i,...o?{single:a}:{multi:a},labels:s?.split(`,`).map(e=>e.trim()).filter(Boolean),allowTargetBlank:c}};E(l,u,f),await d(),console.info(`Field added: ${n}`)});const Er={name:`prismic field add select`,description:`
140
+ `},positionals:{id:{description:`Field ID`,required:!0}},options:{...J,label:{type:`string`,description:`Field label`},placeholder:{type:`string`,description:`Placeholder text`},allow:{type:`string`,description:`Comma-separated allowed block types (e.g. heading1,heading2,paragraph)`},single:{type:`boolean`,description:`Restrict to a single block`},labels:{type:`string`,description:`Comma-separated custom labels for styling text spans (e.g. highlight,quote)`},"allow-target-blank":{type:`boolean`,description:`Allow opening links in new tab`}}};var Dr=j(Er,async({positionals:e,values:t})=>{let[n]=e,{label:r,placeholder:i,allow:a=`paragraph,preformatted,heading1,heading2,heading3,heading4,heading5,heading6,strong,em,hyperlink,image,embed,list-item,o-list-item,rtl`,single:o,labels:s,"allow-target-blank":c}=t,{fields:l,fieldId:u,save:d}=await Y(n,t),f={type:`StructuredText`,config:{label:r??N(u),placeholder:i,...o?{single:a}:{multi:a},labels:s?.split(`,`).map(e=>e.trim()).filter(Boolean),allowTargetBlank:c}};T(l,u,f),await d(),console.info(`Field added: ${n}`)});const Or={name:`prismic field add select`,description:`
141
141
  Add a select field to a slice or custom type.
142
142
 
143
143
  Run \`prismic docs view fields/select\` for details.
@@ -147,11 +147,11 @@ Ending the session...`),await f()&&console.info(`Session ended.`)});async functi
147
147
 
148
148
  With a default value:
149
149
  prismic field add select layout --to-type landing_page --option full --option centered --option sidebar --default-value full
150
- `},positionals:{id:{description:`Field ID`,required:!0}},options:{...J,label:{type:`string`,description:`Field label`},placeholder:{type:`string`,description:`Placeholder text`},"default-value":{type:`string`,description:`Default selected value`},option:{type:`string`,multiple:!0,description:`Select option value (can be repeated)`}}};var Dr=S(Er,async({positionals:e,values:t})=>{let[n]=e,{label:r,placeholder:i,"default-value":a,option:o}=t,{fields:s,fieldId:c,save:l}=await Y(n,t),u={type:`Select`,config:{label:r??N(c),placeholder:i,default_value:a,options:o}};E(s,c,u),await l(),console.info(`Field added: ${n}`)});const Or={name:`prismic field add table`,description:`
150
+ `},positionals:{id:{description:`Field ID`,required:!0}},options:{...J,label:{type:`string`,description:`Field label`},placeholder:{type:`string`,description:`Placeholder text`},"default-value":{type:`string`,description:`Default selected value`},option:{type:`string`,multiple:!0,description:`Select option value (can be repeated)`}}};var kr=j(Or,async({positionals:e,values:t})=>{let[n]=e,{label:r,placeholder:i,"default-value":a,option:o}=t,{fields:s,fieldId:c,save:l}=await Y(n,t),u={type:`Select`,config:{label:r??N(c),placeholder:i,default_value:a,options:o}};T(s,c,u),await l(),console.info(`Field added: ${n}`)});const Ar={name:`prismic field add table`,description:`
151
151
  Add a table field to a slice or custom type.
152
152
 
153
153
  Run \`prismic docs view fields/table\` for details.
154
- `,positionals:{id:{description:`Field ID`,required:!0}},options:{...J,label:{type:`string`,description:`Field label`}}};var kr=S(Or,async({positionals:e,values:t})=>{let[n]=e,{label:r}=t,{fields:i,fieldId:a,save:o}=await Y(n,t),s={type:`Table`,config:{label:r??N(a)}};E(i,a,s),await o(),console.info(`Field added: ${n}`)});const Ar={name:`prismic field add text`,description:`
154
+ `,positionals:{id:{description:`Field ID`,required:!0}},options:{...J,label:{type:`string`,description:`Field label`}}};var jr=j(Ar,async({positionals:e,values:t})=>{let[n]=e,{label:r}=t,{fields:i,fieldId:a,save:o}=await Y(n,t),s={type:`Table`,config:{label:r??N(a)}};T(i,a,s),await o(),console.info(`Field added: ${n}`)});const Mr={name:`prismic field add text`,description:`
155
155
  Add a text field to a slice or custom type.
156
156
 
157
157
  A text field holds a short plain string with no formatting.
@@ -162,15 +162,15 @@ Ending the session...`),await f()&&console.info(`Session ended.`)});async functi
162
162
  prismic field add rich-text title --to-type blog_post --allow heading1 --single
163
163
 
164
164
  Run \`prismic docs view fields/text\` for details.
165
- `,positionals:{id:{description:`Field ID`,required:!0}},options:{...J,label:{type:`string`,description:`Field label`},placeholder:{type:`string`,description:`Placeholder text`}}};var jr=S(Ar,async({positionals:e,values:t})=>{let[n]=e,{label:r,placeholder:i}=t,{fields:a,fieldId:o,save:s}=await Y(n,t),c={type:`Text`,config:{label:r??N(o),placeholder:i}};E(a,o,c),await s(),console.info(`Field added: ${n}`)});const Mr={name:`prismic field add timestamp`,description:`
165
+ `,positionals:{id:{description:`Field ID`,required:!0}},options:{...J,label:{type:`string`,description:`Field label`},placeholder:{type:`string`,description:`Placeholder text`}}};var Nr=j(Mr,async({positionals:e,values:t})=>{let[n]=e,{label:r,placeholder:i}=t,{fields:a,fieldId:o,save:s}=await Y(n,t),c={type:`Text`,config:{label:r??N(o),placeholder:i}};T(a,o,c),await s(),console.info(`Field added: ${n}`)});const Pr={name:`prismic field add timestamp`,description:`
166
166
  Add a timestamp field to a slice or custom type.
167
167
 
168
168
  Run \`prismic docs view fields/timestamp\` for details.
169
- `,positionals:{id:{description:`Field ID`,required:!0}},options:{...J,label:{type:`string`,description:`Field label`},placeholder:{type:`string`,description:`Placeholder text`},default:{type:`string`,description:`Default value`}}};var Nr=S(Mr,async({positionals:e,values:t})=>{let[n]=e,{label:r,placeholder:i,default:a}=t,{fields:o,fieldId:s,save:c}=await Y(n,t),l={type:`Timestamp`,config:{label:r??N(s),placeholder:i,default:a}};E(o,s,l),await c(),console.info(`Field added: ${n}`)});const Pr={name:`prismic field add uid`,description:`
169
+ `,positionals:{id:{description:`Field ID`,required:!0}},options:{...J,label:{type:`string`,description:`Field label`},placeholder:{type:`string`,description:`Placeholder text`},default:{type:`string`,description:`Default value`}}};var Fr=j(Pr,async({positionals:e,values:t})=>{let[n]=e,{label:r,placeholder:i,default:a}=t,{fields:o,fieldId:s,save:c}=await Y(n,t),l={type:`Timestamp`,config:{label:r??N(s),placeholder:i,default:a}};T(o,s,l),await c(),console.info(`Field added: ${n}`)});const Ir={name:`prismic field add uid`,description:`
170
170
  Add a UID field to a content type.
171
171
 
172
172
  Run \`prismic docs view fields/uid\` for details.
173
- `,options:{"to-type":J[`to-type`],tab:J.tab,label:{type:`string`,description:`Field label`},placeholder:{type:`string`,description:`Placeholder text`}}};var Fr=S(Pr,async({values:e})=>{let{label:t=`UID`,placeholder:n}=e,{fields:r,fieldId:i,save:a}=await Y(`uid`,e);E(r,i,{type:`UID`,config:{label:t,placeholder:n}}),await a(),console.info(`Field added: uid`)}),Ir=A({name:`prismic field add`,description:`
173
+ `,options:{"to-type":J[`to-type`],tab:J.tab,label:{type:`string`,description:`Field label`},placeholder:{type:`string`,description:`Placeholder text`}}};var Lr=j(Ir,async({values:e})=>{let{label:t=`UID`,placeholder:n}=e,{fields:r,fieldId:i,save:a}=await Y(`uid`,e);T(r,i,{type:`UID`,config:{label:t,placeholder:n}}),await a(),console.info(`Field added: uid`)}),Rr=A({name:`prismic field add`,description:`
174
174
  Add a field to a slice or custom type.
175
175
 
176
176
  Run \`prismic docs view fields\` for details.
@@ -180,7 +180,7 @@ Ending the session...`),await f()&&console.info(`Session ended.`)});async functi
180
180
  prismic field add text my_group.description --to-type blog_post
181
181
 
182
182
  The group must already exist. Only one level of nesting is supported.
183
- `},commands:{boolean:{handler:rr,description:`Add a boolean field`},color:{handler:ar,description:`Add a color field`},"content-relationship":{handler:sr,description:`Add a content relationship field for fetching data from related documents (not for navigation -- use link)`},date:{handler:lr,description:`Add a date field`},embed:{handler:dr,description:`Add an embed field`},geopoint:{handler:pr,description:`Add a geopoint field`},group:{handler:hr,description:`Add a group field`},image:{handler:_r,description:`Add an image field`},integration:{handler:yr,description:`Add an integration field`},link:{handler:xr,description:`Add a link field for URLs, documents, or media (navigational)`},number:{handler:Cr,description:`Add a number field`},"rich-text":{handler:Tr,description:`Add a rich text field`},select:{handler:Dr,description:`Add a select field`},table:{handler:kr,description:`Add a table field`},text:{handler:jr,description:`Add a text field for short plain strings (not for titles or headings -- use rich-text --allow heading1 --single)`},timestamp:{handler:Nr,description:`Add a timestamp field`},uid:{handler:Fr,description:`Add a UID field`}}});const Lr={name:`prismic field edit`,description:`Edit an existing field in a slice or custom type.`,sections:{"FIELD TYPE OPTIONS":`
183
+ `},commands:{boolean:{handler:ar,description:`Add a boolean field`},color:{handler:sr,description:`Add a color field`},"content-relationship":{handler:lr,description:`Add a content relationship field for fetching data from related documents (not for navigation -- use link)`},date:{handler:dr,description:`Add a date field`},embed:{handler:pr,description:`Add an embed field`},geopoint:{handler:hr,description:`Add a geopoint field`},group:{handler:_r,description:`Add a group field`},image:{handler:yr,description:`Add an image field`},integration:{handler:xr,description:`Add an integration field`},link:{handler:Cr,description:`Add a link field for URLs, documents, or media (navigational)`},number:{handler:Tr,description:`Add a number field`},"rich-text":{handler:Dr,description:`Add a rich text field`},select:{handler:kr,description:`Add a select field`},table:{handler:jr,description:`Add a table field`},text:{handler:Nr,description:`Add a text field for short plain strings (not for titles or headings -- use rich-text --allow heading1 --single)`},timestamp:{handler:Fr,description:`Add a timestamp field`},uid:{handler:Lr,description:`Add a UID field`}}});const zr={name:`prismic field edit`,description:`Edit an existing field in a slice or custom type.`,sections:{"FIELD TYPE OPTIONS":`
184
184
  Options vary by field type. Only options matching the field's
185
185
  type will be applied. See \`prismic field add <type> --help\`
186
186
  for type-specific option details.
@@ -193,38 +193,38 @@ Ending the session...`),await f()&&console.info(`Session ended.`)});async functi
193
193
 
194
194
  Restrict a rich text field to a single block:
195
195
  prismic field edit subtitle --from-type blog_post --single
196
- `},positionals:{id:{description:`Field ID`,required:!0}},options:{...Jn,label:{type:`string`,description:`Field label`},placeholder:{type:`string`,description:`Placeholder text`},"default-true":{type:`boolean`,description:`Default the field to true (boolean)`},"default-false":{type:`boolean`,description:`Default the field to false (boolean)`},"true-label":{type:`string`,description:`Label for true value (boolean)`},"false-label":{type:`string`,description:`Label for false value (boolean)`},default:{type:`string`,description:`Default value (date/timestamp)`},min:{type:`string`,description:`Minimum value (number)`},max:{type:`string`,description:`Maximum value (number)`},step:{type:`string`,description:`Step increment (number)`},"default-value":{type:`string`,description:`Default selected value (select)`},option:{type:`string`,multiple:!0,description:`Select option value (can be repeated)`},"allow-target-blank":{type:`boolean`,description:`Allow opening in new tab (link/rich-text)`},"allow-text":{type:`boolean`,description:`Allow custom link text (link)`},repeatable:{type:`boolean`,description:`Allow multiple links (link)`},variant:{type:`string`,multiple:!0,description:`Allowed variant (link/link-to-media, can be repeated)`},tag:{type:`string`,multiple:!0,description:`Allowed tag (content-relationship, can be repeated)`},"custom-type":{type:`string`,multiple:!0,description:`Allowed custom type (content-relationship, can be repeated)`},field:{type:`string`,multiple:!0,description:`Fetch this field from the related document (content-relationship, can be repeated)`},allow:{type:`string`,description:`Comma-separated allowed block types (rich-text), or allowed link type: document, media, web, any (link)`},single:{type:`boolean`,description:`Restrict to a single block (rich-text)`},labels:{type:`string`,description:`Comma-separated custom labels for styling text spans; "" clears (rich-text)`},catalog:{type:`string`,description:`Integration catalog ID (integration)`}}};var Rr=S(Lr,async({positionals:e,values:t})=>{let[n]=e,{field:r,save:i}=await Xn(n,t);switch(r.config??={},`label`in t&&(r.config.label=t.label),`placeholder`in t&&(r.config.placeholder=t.placeholder),r.type){case`Boolean`:Ce(t,[`default-true`,`default-false`]),`default-true`in t&&(r.config.default_value=!0),`default-false`in t&&(r.config.default_value=!1),`true-label`in t&&(r.config.placeholder_true=t[`true-label`]),`false-label`in t&&(r.config.placeholder_false=t[`false-label`]);break;case`Number`:`min`in t&&(r.config.min=X(t.min,`min`)),`max`in t&&(r.config.max=X(t.max,`max`)),`step`in t&&(r.config.step=X(t.step,`step`));break;case`Select`:`default-value`in t&&(r.config.default_value=t[`default-value`]),`option`in t&&(r.config.options=t.option);break;case`Date`:case`Timestamp`:`default`in t&&(r.config.default=t.default);break;case`IntegrationFields`:`catalog`in t&&(r.config.catalog=t.catalog);break;case`StructuredText`:if(`allow-target-blank`in t&&(r.config.allowTargetBlank=t[`allow-target-blank`]),`labels`in t&&(t.labels?r.config.labels=t.labels.split(`,`):delete r.config.labels),`single`in t){let e=`allow`in t?t.allow:r.config.multi??r.config.single;delete r.config.multi,r.config.single=e}else`allow`in t&&(`single`in r.config?r.config.single=t.allow:r.config.multi=t.allow);break;case`Link`:if(`allow-target-blank`in t&&(r.config.allowTargetBlank=t[`allow-target-blank`]),`allow-text`in t&&(r.config.allowText=t[`allow-text`]),`repeatable`in t&&(r.config.repeat=t.repeatable),`variant`in t&&(r.config.variants=t.variant),`tag`in t&&(r.config.tags=t.tag),`allow`in t){let e=t.allow;if(e===`any`)delete r.config.select;else if(e===`document`||e===`media`||e===`web`)r.config.select=e;else if(e?.includes(`,`))throw new L(`--allow accepts a single link type. Prismic links allow either one type or all types.`);else throw new L(`--allow for link fields must be one of: document, media, web, any`)}if(`field`in t){let e=`custom-type`in t?t[`custom-type`]:r.config.customtypes;if(!e||e.length===0)throw new L(`--field requires the field to be restricted to a custom type. Use --custom-type to specify one.`);if(e.length>1)throw new L(`--field requires the field to be restricted to a single custom type.`);let[n]=e,i=typeof n==`string`?n:n.id,a=await Zn(t.field,i);r.config.customtypes=[{id:i,fields:a}]}else if(`custom-type`in t){let e=t[`custom-type`].filter(Boolean);e.length===0?delete r.config.customtypes:r.config.customtypes=e}if((r.config.select===`media`||r.config.select===`web`)&&r.config.customtypes&&r.config.customtypes.length>0)throw new L(`Custom type restrictions require document links, but this field is restricted to ${r.config.select} links. Change --allow or clear the restriction with --custom-type "".`)}await i(),console.info(`Field updated: ${n}`)}),zr=S({name:`prismic field remove`,description:`Remove a field from a slice or custom type.`,positionals:{id:{description:`Field ID`,required:!0}},options:Jn},async({positionals:e,values:t})=>{let[n]=e,{fields:r,fieldId:i,save:a}=await Xn(n,t);delete r[i],await a(),console.info(`Field removed: ${n}`)});const Br={name:`prismic field reorder`,description:`Reorder a field in a slice or custom type.`,positionals:{id:{description:`Field ID to move`,required:!0}},options:{before:{type:`string`,description:`Place field before this field ID`},after:{type:`string`,description:`Place field after this field ID`},...Jn}};var Vr=S(Br,async({positionals:e,values:t})=>{let[n]=e,{key:r,value:i}=be(t,[`before`,`after`]);if(n===i)throw new L(`Cannot reorder "${n}" relative to itself.`);if(n.split(`.`).slice(0,-1).join(`.`)!==i.split(`.`).slice(0,-1).join(`.`))throw new L(`Cannot reorder "${n}" relative to "${i}": fields must be in the same container.`);let{source:a,anchor:o,save:s}=await Yn(n,i,t);if(a.fields!==o.fields&&a.fieldId in o.fields)throw new d(a.fieldId);let c=a.fields[a.fieldId];delete a.fields[a.fieldId];let l=Object.entries(o.fields);for(let[e]of l)delete o.fields[e];for(let[e,t]of l)r===`before`&&e===o.fieldId&&(o.fields[a.fieldId]=c),o.fields[e]=t,r===`after`&&e===o.fieldId&&(o.fields[a.fieldId]=c);await s(),console.info(`Field reordered: ${n}`)});const Hr={name:`prismic field view`,description:`View details of a field in a slice or custom type.`,positionals:{id:{description:`Field ID`,required:!0}},options:{...Jn,json:{type:`boolean`,description:`Output as JSON`}}};var Ur=S(Hr,async({positionals:e,values:t})=>{let[n]=e,{field:r,fieldId:i}=await Xn(n,t);if(t.json)console.info(W({id:i,...r}));else if(console.info(`Type: ${r.type}`),r.config){for(let[e,t]of Object.entries(r.config))if(t!==void 0){if(e===`fields`&&typeof t==`object`&&t){let e=Object.keys(t).join(`, `)||`(none)`;console.info(`Fields: ${e}`)}else console.info(Array.isArray(t)?`${N(e)}: ${t.join(`, `)}`:`${N(e)}: ${t}`)}}}),Wr=A({name:`prismic field`,description:`
196
+ `},positionals:{id:{description:`Field ID`,required:!0}},options:{...Xn,label:{type:`string`,description:`Field label`},placeholder:{type:`string`,description:`Placeholder text`},"default-true":{type:`boolean`,description:`Default the field to true (boolean)`},"default-false":{type:`boolean`,description:`Default the field to false (boolean)`},"true-label":{type:`string`,description:`Label for true value (boolean)`},"false-label":{type:`string`,description:`Label for false value (boolean)`},default:{type:`string`,description:`Default value (date/timestamp)`},min:{type:`string`,description:`Minimum value (number)`},max:{type:`string`,description:`Maximum value (number)`},step:{type:`string`,description:`Step increment (number)`},"default-value":{type:`string`,description:`Default selected value (select)`},option:{type:`string`,multiple:!0,description:`Select option value (can be repeated)`},"allow-target-blank":{type:`boolean`,description:`Allow opening in new tab (link/rich-text)`},"allow-text":{type:`boolean`,description:`Allow custom link text (link)`},repeatable:{type:`boolean`,description:`Allow multiple links (link)`},variant:{type:`string`,multiple:!0,description:`Allowed variant (link/link-to-media, can be repeated)`},tag:{type:`string`,multiple:!0,description:`Allowed tag (content-relationship, can be repeated)`},"custom-type":{type:`string`,multiple:!0,description:`Allowed custom type (content-relationship, can be repeated)`},field:{type:`string`,multiple:!0,description:`Fetch this field from the related document (content-relationship, can be repeated)`},allow:{type:`string`,description:`Comma-separated allowed block types (rich-text), or allowed link type: document, media, web, any (link)`},single:{type:`boolean`,description:`Restrict to a single block (rich-text)`},labels:{type:`string`,description:`Comma-separated custom labels for styling text spans; "" clears (rich-text)`},catalog:{type:`string`,description:`Integration catalog ID (integration)`}}};var Br=j(zr,async({positionals:e,values:t})=>{let[n]=e,{field:r,save:i}=await Qn(n,t);switch(r.config??={},`label`in t&&(r.config.label=t.label),`placeholder`in t&&(r.config.placeholder=t.placeholder),r.type){case`Boolean`:de(t,[`default-true`,`default-false`]),`default-true`in t&&(r.config.default_value=!0),`default-false`in t&&(r.config.default_value=!1),`true-label`in t&&(r.config.placeholder_true=t[`true-label`]),`false-label`in t&&(r.config.placeholder_false=t[`false-label`]);break;case`Number`:`min`in t&&(r.config.min=X(t.min,`min`)),`max`in t&&(r.config.max=X(t.max,`max`)),`step`in t&&(r.config.step=X(t.step,`step`));break;case`Select`:`default-value`in t&&(r.config.default_value=t[`default-value`]),`option`in t&&(r.config.options=t.option);break;case`Date`:case`Timestamp`:`default`in t&&(r.config.default=t.default);break;case`IntegrationFields`:`catalog`in t&&(r.config.catalog=t.catalog);break;case`StructuredText`:if(`allow-target-blank`in t&&(r.config.allowTargetBlank=t[`allow-target-blank`]),`labels`in t&&(t.labels?r.config.labels=t.labels.split(`,`):delete r.config.labels),`single`in t){let e=`allow`in t?t.allow:r.config.multi??r.config.single;delete r.config.multi,r.config.single=e}else`allow`in t&&(`single`in r.config?r.config.single=t.allow:r.config.multi=t.allow);break;case`Link`:if(`allow-target-blank`in t&&(r.config.allowTargetBlank=t[`allow-target-blank`]),`allow-text`in t&&(r.config.allowText=t[`allow-text`]),`repeatable`in t&&(r.config.repeat=t.repeatable),`variant`in t&&(r.config.variants=t.variant),`tag`in t&&(r.config.tags=t.tag),`allow`in t){let e=t.allow;if(e===`any`)delete r.config.select;else if(e===`document`||e===`media`||e===`web`)r.config.select=e;else if(e?.includes(`,`))throw new S(`--allow accepts a single link type. Prismic links allow either one type or all types.`);else throw new S(`--allow for link fields must be one of: document, media, web, any`)}if(`field`in t){let e=`custom-type`in t?t[`custom-type`]:r.config.customtypes;if(!e||e.length===0)throw new S(`--field requires the field to be restricted to a custom type. Use --custom-type to specify one.`);if(e.length>1)throw new S(`--field requires the field to be restricted to a single custom type.`);let[n]=e,i=typeof n==`string`?n:n.id,a=await $n(t.field,i);r.config.customtypes=[{id:i,fields:a}]}else if(`custom-type`in t){let e=t[`custom-type`].filter(Boolean);e.length===0?delete r.config.customtypes:r.config.customtypes=e}if((r.config.select===`media`||r.config.select===`web`)&&r.config.customtypes&&r.config.customtypes.length>0)throw new S(`Custom type restrictions require document links, but this field is restricted to ${r.config.select} links. Change --allow or clear the restriction with --custom-type "".`)}await i(),console.info(`Field updated: ${n}`)}),Vr=j({name:`prismic field remove`,description:`Remove a field from a slice or custom type.`,positionals:{id:{description:`Field ID`,required:!0}},options:Xn},async({positionals:e,values:t})=>{let[n]=e,{fields:r,fieldId:i,save:a}=await Qn(n,t);delete r[i],await a(),console.info(`Field removed: ${n}`)});const Hr={name:`prismic field reorder`,description:`Reorder a field in a slice or custom type.`,positionals:{id:{description:`Field ID to move`,required:!0}},options:{before:{type:`string`,description:`Place field before this field ID`},after:{type:`string`,description:`Place field after this field ID`},...Xn}};var Ur=j(Hr,async({positionals:e,values:t})=>{let[n]=e,{key:r,value:i}=Ce(t,[`before`,`after`]);if(n===i)throw new S(`Cannot reorder "${n}" relative to itself.`);if(n.split(`.`).slice(0,-1).join(`.`)!==i.split(`.`).slice(0,-1).join(`.`))throw new S(`Cannot reorder "${n}" relative to "${i}": fields must be in the same container.`);let{source:a,anchor:o,save:s}=await Zn(n,i,t);if(a.fields!==o.fields&&a.fieldId in o.fields)throw new f(a.fieldId);let c=a.fields[a.fieldId];delete a.fields[a.fieldId];let l=Object.entries(o.fields);for(let[e]of l)delete o.fields[e];for(let[e,t]of l)r===`before`&&e===o.fieldId&&(o.fields[a.fieldId]=c),o.fields[e]=t,r===`after`&&e===o.fieldId&&(o.fields[a.fieldId]=c);await s(),console.info(`Field reordered: ${n}`)});const Wr={name:`prismic field view`,description:`View details of a field in a slice or custom type.`,positionals:{id:{description:`Field ID`,required:!0}},options:{...Xn,json:{type:`boolean`,description:`Output as JSON`}}};var Gr=j(Wr,async({positionals:e,values:t})=>{let[n]=e,{field:r,fieldId:i}=await Qn(n,t);if(t.json)console.info(G({id:i,...r}));else if(console.info(`Type: ${r.type}`),r.config){for(let[e,t]of Object.entries(r.config))if(t!==void 0){if(e===`fields`&&typeof t==`object`&&t){let e=Object.keys(t).join(`, `)||`(none)`;console.info(`Fields: ${e}`)}else console.info(Array.isArray(t)?`${N(e)}: ${t.join(`, `)}`:`${N(e)}: ${t}`)}}}),Kr=A({name:`prismic field`,description:`
197
197
  Manage fields in slices and content types.
198
198
 
199
199
  Run \`prismic docs view fields\` for details.
200
- `,commands:{add:{handler:Ir,description:`Add a field`},edit:{handler:Rr,description:`Edit a field`},remove:{handler:zr,description:`Remove a field`},reorder:{handler:Vr,description:`Reorder a field`},view:{handler:Ur,description:`View details of a field`}}}),Gr=S({name:`prismic gen page`,description:`
200
+ `,commands:{add:{handler:Rr,description:`Add a field`},edit:{handler:Br,description:`Edit a field`},remove:{handler:Vr,description:`Remove a field`},reorder:{handler:Ur,description:`Reorder a field`},view:{handler:Gr,description:`View details of a field`}}}),qr=j({name:`prismic gen page`,description:`
201
201
  Generate the page files for a page type.
202
202
 
203
203
  Uses the type's route in prismic.config.json. Existing files are not
204
204
  changed: their generated code is printed instead.
205
- `,positionals:{"type-id":{description:`ID of the page type`,required:!0}}},async({positionals:e})=>{let[t]=e,n=await P(),{model:r}=await n.getCustomType(t);if(r.format!==`page`)throw new L(`"${t}" is not a page type.`);let{routes:i=[]}=await s(),a=!ke(i,t)&&i.find(e=>e.type===t&&!e.uid);a&&console.info(`The route ${a.path} has optional or repeated params, so the page uses the default path ${Re(r)}. Move it to match the route.\n`);let o=await n.writePageFiles(r);if(o.length===0){console.info(`Generated the page for "${t}".`);return}let c=await R();for(let e of o){let t=B(c,e.path);console.info(`${t} already exists. Generated code:\n\n${e.contents}`),console.info(`Merge this into ${t}.\n`)}}),Kr=S({name:`prismic gen setup`,description:`
205
+ `,positionals:{"type-id":{description:`ID of the page type`,required:!0}}},async({positionals:e})=>{let[t]=e,n=await P(),{model:r}=await n.getCustomType(t);if(r.format!==`page`)throw new S(`"${t}" is not a page type.`);let{routes:i=[]}=await c(),a=!ke(i,t)&&i.find(e=>e.type===t&&!e.uid);a&&console.info(`The route ${a.path} has optional or repeated params, so the page uses the default path ${ze(r)}. Move it to match the route.\n`);let o=await n.writePageFiles(r);if(o.length===0){console.info(`Generated the page for "${t}".`);return}let s=await R();for(let e of o){let t=H(s,e.path);console.info(`${t} already exists. Generated code:\n\n${e.contents}`),console.info(`Merge this into ${t}.\n`)}}),Jr=j({name:`prismic gen setup`,description:`
206
206
  Generate framework-specific setup files for a Prismic project.
207
207
 
208
208
  Installs dependencies, creates the Prismic client file, slice simulator
209
209
  page, preview routes, and other files required by the detected framework.
210
210
  Skips files that already exist.
211
- `,options:{"no-install":{type:`boolean`,description:`Skip installing dependencies`}}},async({values:e})=>{let t=await P(),n=await U();await t.setupProject();for(let{name:e,from:t,to:r}of Wt(n,await U()))console.info(`Updated ${e} from ${t} to ${r}. Check your code for breaking changes in the new version.`);if(!e[`no-install`])try{console.info(`Installing dependencies...`),await Lt()}catch{console.warn(`Could not install dependencies. Run \`${await Bt()}\` to finish.\nThe rest of the setup is done.`)}console.info(`Generated setup files.`);let r=await t.getSetupInstructions();r&&console.info(`\n${r}`)}),qr=S({name:`prismic gen slice-index`,description:`Generate the slice index file of each slice library.`},async()=>{let e=await P(),t=await e.getSliceLibraries();for(let n of t)await e.createSliceIndexFile(n);console.info(t.length===1?`Generated the slice index file.`:`Generated ${t.length} slice index files.`)}),Jr=S({name:`prismic gen types`,description:`Generate TypeScript types for slices and content types.`},async()=>{let e=await(await P()).generateTypes(),t=await R(),n=B(t,e);console.info(`Generated types at ${n}`)}),Yr=A({name:`prismic gen`,description:`Generate files from local Prismic models.`,commands:{page:{handler:Gr,description:`Generate the page files for a page type`},setup:{handler:Kr,description:`Generate framework-specific Prismic setup`},"slice-index":{handler:qr,description:`Generate the slice index file of each slice library`},types:{handler:Jr,description:`Generate TypeScript types from local models`}}});async function Z(e,t){let{completedSteps:n}=await i(t),r=e.filter(e=>!n.includes(e));for(let e of r)await v(e,t)}let Q;const $={tags:{},contexts:{}};function Xr(e){Q=e,$.contexts.Process={command:process.argv.join(` `),cwd:process.cwd()}}function Zr(e,t){$.tags[e]=t}function Qr(e,t){$.contexts[e]=t}function $r(e){$.user=e}async function ei(e){if(Q)try{let t=new URL(Q.dsn),n=e instanceof Error?e:Error(String(e)),r=crypto.randomUUID().replace(/-/g,``),i={event_id:r,timestamp:Date.now()/1e3,platform:`node`,level:`error`,release:Q.appVersion,environment:Q.environment||ti(Q.appVersion),tags:$.tags,user:$.user,contexts:{...$.contexts,runtime:{name:`node`,version:process.versions.node}},exception:{values:[{type:n.name,value:n.message.slice(0,2500),stacktrace:ri(n)}]},extra:{cause:n.cause,fullCommand:process.argv.join(` `)}},a=[JSON.stringify({event_id:r,sent_at:(/* @__PURE__ */ new Date()).toISOString()}),JSON.stringify({type:`event`}),JSON.stringify(i)].join(`
212
- `);await fetch(ni(t),{method:`POST`,headers:{"Content-Type":`application/x-sentry-envelope`,"X-Sentry-Auth":`Sentry sentry_version=7, sentry_client=${Q.appName}/${Q.appVersion}, sentry_key=${t.username}`},body:a,signal:AbortSignal.timeout(2e3)})}catch{}}function ti(e){let t=e.match(/-(.+?)\./);return t?t[1]:`production`}function ni(e){return`${e.protocol}//${e.host}/api${e.pathname}/envelope/`}function ri(e){let t=[];for(let n of(e.stack??``).split(`
213
- `).slice(1)){let e=n.match(/^\s*at (?:(.+?) \()?(.+?):(\d+):(\d+)\)?$/);e&&t.push({function:e[1]||`?`,filename:e[2],lineno:Number(e[3]),colno:Number(e[4]),in_app:!0})}return t.length>0?{frames:t.reverse()}:void 0}const ii={name:`prismic repo create`,description:`
211
+ `,options:{"no-install":{type:`boolean`,description:`Skip installing dependencies`}}},async({values:e})=>{let t=await P(),n=await W();await t.setupProject();for(let{name:e,from:t,to:r}of Wt(n,await W()))console.info(`Updated ${e} from ${t} to ${r}. Check your code for breaking changes in the new version.`);if(!e[`no-install`])try{console.info(`Installing dependencies...`),await Rt()}catch{console.warn(`Could not install dependencies. Run \`${await Vt()}\` to finish.\nThe rest of the setup is done.`)}console.info(`Generated setup files.`);let r=await t.getSetupInstructions();r&&console.info(`\n${r}`)}),Yr=j({name:`prismic gen slice-index`,description:`Generate the slice index file of each slice library.`},async()=>{let e=await P(),t=await e.getSliceLibraries();for(let n of t)await e.createSliceIndexFile(n);console.info(t.length===1?`Generated the slice index file.`:`Generated ${t.length} slice index files.`)}),Xr=j({name:`prismic gen types`,description:`Generate TypeScript types for slices and content types.`},async()=>{let e=await(await P()).generateTypes(),t=await R(),n=H(t,e);console.info(`Generated types at ${n}`)}),Zr=A({name:`prismic gen`,description:`Generate files from local Prismic models.`,commands:{page:{handler:qr,description:`Generate the page files for a page type`},setup:{handler:Jr,description:`Generate framework-specific Prismic setup`},"slice-index":{handler:Yr,description:`Generate the slice index file of each slice library`},types:{handler:Xr,description:`Generate TypeScript types from local models`}}});async function Z(e,t){let{completedSteps:n}=await Je(t),r=e.filter(e=>!n.includes(e));for(let e of r)await he(e,t)}let Q;const $={tags:{},contexts:{}};function Qr(e){Q=e,$.contexts.Process={command:process.argv.join(` `),cwd:process.cwd()}}function $r(e,t){$.tags[e]=t}function ei(e,t){$.contexts[e]=t}function ti(e){$.user=e}async function ni(e){if(Q)try{let t=new URL(Q.dsn),n=e instanceof Error?e:Error(String(e)),r=crypto.randomUUID().replace(/-/g,``),i={event_id:r,timestamp:Date.now()/1e3,platform:`node`,level:`error`,release:Q.appVersion,environment:Q.environment||ri(Q.appVersion),tags:$.tags,user:$.user,contexts:{...$.contexts,runtime:{name:`node`,version:process.versions.node}},exception:{values:[{type:n.name,value:n.message.slice(0,2500),stacktrace:ai(n)}]},extra:{cause:n.cause,fullCommand:process.argv.join(` `)}},a=[JSON.stringify({event_id:r,sent_at:(/* @__PURE__ */ new Date()).toISOString()}),JSON.stringify({type:`event`}),JSON.stringify(i)].join(`
212
+ `);await fetch(ii(t),{method:`POST`,headers:{"Content-Type":`application/x-sentry-envelope`,"X-Sentry-Auth":`Sentry sentry_version=7, sentry_client=${Q.appName}/${Q.appVersion}, sentry_key=${t.username}`},body:a,signal:AbortSignal.timeout(2e3)})}catch{}}function ri(e){let t=e.match(/-(.+?)\./);return t?t[1]:`production`}function ii(e){return`${e.protocol}//${e.host}/api${e.pathname}/envelope/`}function ai(e){let t=[];for(let n of(e.stack??``).split(`
213
+ `).slice(1)){let e=n.match(/^\s*at (?:(.+?) \()?(.+?):(\d+):(\d+)\)?$/);e&&t.push({function:e[1]||`?`,filename:e[2],lineno:Number(e[3]),colno:Number(e[4]),in_app:!0})}return t.length>0?{frames:t.reverse()}:void 0}const oi={name:`prismic repo create`,description:`
214
214
  Create a new Prismic repository.
215
215
 
216
216
  The CLI generates a random domain, shown in the output. The domain cannot
217
217
  be chosen or changed. --name sets only the display name, which
218
218
  \`prismic repo set-name\` can change later.
219
- `,options:{name:{type:`string`,short:`n`,description:`Display name for the repository`},lang:{type:`string`,short:`l`,description:`Master locale for the new repository (default: en-us)`},framework:{type:`string`,short:`f`,description:`Framework the repository is for: ${lt.join(`, `)} (default: detected from the project)`}}};var ai=S(ii,async({values:e})=>{let t=await P().catch(()=>void 0),{name:n,lang:r,framework:i=t?.id}=e;if(!i)throw new L(`
219
+ `,options:{name:{type:`string`,short:`n`,description:`Display name for the repository`},lang:{type:`string`,short:`l`,description:`Master locale for the new repository (default: en-us)`},framework:{type:`string`,short:`f`,description:`Framework the repository is for: ${I.join(`, `)} (default: detected from the project)`}}};var si=j(oi,async({values:e})=>{let t=await P().catch(()=>void 0),{name:n,lang:r,framework:i=t?.id}=e;if(!i)throw new S(`
220
220
  No supported framework found. The CLI needs a Next.js, Nuxt, or SvelteKit project to work with a repository.
221
221
 
222
222
  Do one of the following:
223
223
  - Run this command inside an existing Next.js, Nuxt, or SvelteKit project.
224
224
  - Create the project first, then run \`prismic init\` to create and connect a repository.
225
- - Pass --framework <${lt.join(`|`)}> to create the repository now.
225
+ - Pass --framework <${I.join(`|`)}> to create the repository now.
226
226
  You still need a compatible project to use it. Connect one later with \`prismic init --repo <domain>\`.
227
- `);if(!lt.includes(i))throw new L(`Unsupported framework "${i}". Use one of: ${lt.join(`, `)}.`);let a=await h(),o=await oi({name:n,lang:r,framework:i,host:a});console.info(`Repository created: ${o}`),console.info(`URL: https://${o}.${a}/`)});async function oi(e){let{name:t,lang:n=`en-us`,framework:r,host:i}=e,a=await si(i);if(!a)throw new L(`Failed to create a repository. Please try again.`);let o=nt();return await Le({domain:a,name:t??a,framework:r,agent:o,getToken:C,host:i,onUnauthorized:x}),await g({id:n,isMaster:!0},{repo:a,getToken:C,host:i,onUnauthorized:x}),await Z([`createPrismicProject`],{repo:a,getToken:C,host:i,onUnauthorized:x}).catch(()=>{}),a}async function si(e){let t;for(let n=0;n<5;n++){let n=crypto.randomUUID().replace(/-/g,``).slice(0,8);if(await Me({domain:n,getToken:C,host:e,onUnauthorized:x})){t=n;break}}return t}var ci=S({name:`prismic init`,description:`
227
+ `);if(!I.includes(i))throw new S(`Unsupported framework "${i}". Use one of: ${I.join(`, `)}.`);let a=await g(),o=await ci({name:n,lang:r,framework:i,host:a});console.info(`Repository created: ${o}`),console.info(`URL: https://${o}.${a}/`)});async function ci(e){let{name:t,lang:n=`en-us`,framework:r,host:i}=e,a=await li(i);if(!a)throw new S(`Failed to create a repository. Please try again.`);let o=dt();return await ct({domain:a,name:t??a,framework:r,agent:o,getToken:C,host:i,onUnauthorized:x}),await w({id:n,isMaster:!0},{repo:a,getToken:C,host:i,onUnauthorized:x}),await Z([`createPrismicProject`],{repo:a,getToken:C,host:i,onUnauthorized:x}).catch(()=>{}),a}async function li(e){let t;for(let n=0;n<5;n++){let n=crypto.randomUUID().replace(/-/g,``).slice(0,8);if(await Qe({domain:n,getToken:C,host:e,onUnauthorized:x})){t=n;break}}return t}var ui=j({name:`prismic init`,description:`
228
228
  Initialize a new Prismic project by creating a repository and
229
229
  prismic.config.json file. Detects the project framework, installs
230
230
  dependencies, and pulls models from Prismic. The CLI generates a random
@@ -240,70 +240,70 @@ Ending the session...`),await f()&&console.info(`Session ended.`)});async functi
240
240
  `,agents:`
241
241
  Do not ask the user whether to create a new repository or connect an
242
242
  existing one. Use --repo only for a repository the user names, and run init.
243
- `,options:{repo:{type:`string`,short:`r`,description:`Domain of an existing repository to connect to`},"repo-name":{type:`string`,description:`Display name for the new repository (its domain is generated)`},lang:{type:`string`,short:`l`,description:`Master locale for a new repository (default: en-us)`},"no-browser":{type:`boolean`,description:`Skip opening the browser automatically during login`},"no-setup":{type:`boolean`,description:`Skip framework scaffolding (dependencies and framework files)`}}},async({values:e})=>{Ce(e,[`repo`,`repo-name`]);let{repo:t,lang:n,"no-browser":r,"no-setup":i}=e,a;try{a=await s()}catch(e){if(!(e instanceof Qe))throw e}if(a&&!t)throw new L(`
244
- This project is already set up for Prismic (repository: ${a.repositoryName}).
243
+ `,options:{repo:{type:`string`,short:`r`,description:`Domain of an existing repository to connect to`},"repo-name":{type:`string`,description:`Display name for the new repository (its domain is generated)`},lang:{type:`string`,short:`l`,description:`Master locale for a new repository (default: en-us)`},"no-browser":{type:`boolean`,description:`Skip opening the browser automatically during login`},"no-setup":{type:`boolean`,description:`Skip framework scaffolding (dependencies and framework files)`}}},async({values:e})=>{de(e,[`repo`,`repo-name`]);let{repo:t,lang:n,"no-browser":i,"no-setup":a}=e,o;try{o=await c()}catch(e){if(!(e instanceof $e))throw e}if(o&&!t)throw new S(`
244
+ This project is already set up for Prismic (repository: ${o.repositoryName}).
245
245
 
246
246
  Do one of the following:
247
247
  - Run \`prismic gen setup\` to add missing framework files and install dependencies.
248
248
  - Run \`prismic init --repo <domain>\` to connect the project to a different repository.
249
- `);let o=a!==void 0&&t!==void 0,c;if(!a)try{c=await bt()}catch(e){e instanceof Ie&&console.warn(`Could not read slicemachine.config.json, ignoring.`)}let l=await h();try{await m({getToken:C,host:l})}catch(e){if(e instanceof V||e instanceof K){if(I.PRISMIC_TOKEN)throw e;await xe({browser:!r})}else throw e}let u=(t??c?.repositoryName)?.toLowerCase(),d;u&&(d=await ne({repo:u,getToken:C,host:l}).catch(e=>{throw e instanceof K?new L(`Repository "${u}" not found in your account. Check the name or request access to the repository.`):e}));let f;try{f=await P()}catch(e){throw e instanceof Ee||e instanceof Gt?new L(`
249
+ `);let s=o!==void 0&&t!==void 0,u;if(!o)try{u=await xt()}catch(e){e instanceof Ie&&console.warn(`Could not read slicemachine.config.json, ignoring.`)}let d=await g();try{await ee({getToken:C,host:d})}catch(e){if(e instanceof V||e instanceof K){if(F.PRISMIC_TOKEN)throw e;await xe({browser:!i})}else throw e}let f=(t??u?.repositoryName)?.toLowerCase(),p;f&&(p=await ae({repo:f,getToken:C,host:d}).catch(e=>{throw e instanceof K?new S(`Repository "${f}" not found in your account. Check the name or request access to the repository.`):e}));let m;try{m=await P()}catch(e){throw e instanceof Ee||e instanceof Kt?new S(`
250
250
  No supported framework found. \`prismic init\` needs a Next.js, Nuxt, or SvelteKit project.
251
251
 
252
252
  Do one of the following:
253
253
  - Run this command inside an existing Next.js, Nuxt, or SvelteKit project.
254
254
  - Create the project first, then run \`prismic init\` again.
255
- - To create the repository now, run \`prismic repo create --framework <${lt.join(`|`)}>\`.
255
+ - To create the repository now, run \`prismic repo create --framework <${I.join(`|`)}>\`.
256
256
  Connect the project later with \`prismic init --repo <domain>\`.
257
- `):e}let p=I.PRISMIC_TYPE_BUILDER_ENABLED??d?.quotas?.sliceMachineEnabled;if(u&&d&&(!p||d.framework!==f.id))try{await de(f.id,{repo:u,getToken:C,host:l}),p||console.info(`Turned on the Type Builder for repository "${u}".`)}catch(e){if(!(e instanceof K))throw e;if(!p)throw new L(`Repository "${u}" uses the Legacy Builder. Only a repository administrator can turn on the Type Builder. Ask an administrator to run \`prismic init\`.`);console.warn(`Could not set the repository's framework to ${f.id}. Ask a repository administrator to run \`prismic init\`.`)}u||(u=await oi({name:e[`repo-name`],lang:n,framework:f.id,host:l}),console.info(`Created repository: ${u}`));try{let e=l===`prismic.io`?void 0:`https://${u}.cdn.${l}/api/v2/`;a?await fe({repositoryName:u,documentAPIEndpoint:e}):await vt({repositoryName:u,documentAPIEndpoint:e,libraries:c?.libraries,routes:[]})}catch(e){throw e instanceof Ve?new L(`Could not find a package.json file. Run this command from a project directory.`):new L(`Failed to create prismic.config.json.`)}if(c){try{await Ct()}catch{}let{dependencies:e,devDependencies:t,peerDependencies:n}=await U(),r=Object.keys({...e,...t,...n}).filter(e=>e===`slice-machine-ui`||e.startsWith(`@slicemachine/adapter-`));r.length>0&&await Kt(r),console.info(`Migrated slicemachine.config.json to prismic.config.json`)}let g=await U();await f.initProject({setup:!i&&!a});for(let{name:e,from:t,to:n}of Wt(g,await U()))console.info(`Updated ${e} from ${t} to ${n}. Check your code for breaking changes in the new version.`);if(!i)try{console.info(`Installing dependencies...`),await Lt()}catch{console.warn(`Could not install dependencies. Run \`${await Bt()}\` to finish.\nThe rest of the setup is done, so you don't need to run \`prismic init\` again.`)}let[_,v]=await Promise.all([D({repo:u,getToken:C,host:l}),f.getModels()]),b=y(_,v);if(o&&d?.starter){if(_.customTypes.length===0&&_.slices.length===0)throw new L(`Repository "${u}" has no starter models. Use a repository created from the starter in the Prismic dashboard.`);await di(d.starter)}let x=o&&[b.customTypes,b.slices].some(e=>e.update.length>0||e.delete.length>0);if(!x)for(let e of await f.writeModels(b))console.info(e);await f.generateTypes(),await Z([`connectPrismic`],{repo:u,getToken:C,host:l}).catch(()=>{}),w(_.customTypes).length>0&&console.info("\nRun `prismic slice list --legacy` to find legacy slices to upgrade."),x&&console.warn(le`
257
+ `):e}let h=F.PRISMIC_TYPE_BUILDER_ENABLED??p?.quotas?.sliceMachineEnabled;if(f&&p&&(!h||p.framework!==m.id))try{await l(m.id,{repo:f,getToken:C,host:d}),h||console.info(`Turned on the Type Builder for repository "${f}".`)}catch(e){if(!(e instanceof K))throw e;if(!h)throw new S(`Repository "${f}" uses the Legacy Builder. Only a repository administrator can turn on the Type Builder. Ask an administrator to run \`prismic init\`.`);console.warn(`Could not set the repository's framework to ${m.id}. Ask a repository administrator to run \`prismic init\`.`)}f||(f=await ci({name:e[`repo-name`],lang:n,framework:m.id,host:d}),console.info(`Created repository: ${f}`));try{let e=d===`prismic.io`?void 0:`https://${f}.cdn.${d}/api/v2/`;o?await pe({repositoryName:f,documentAPIEndpoint:e}):await vt({repositoryName:f,documentAPIEndpoint:e,libraries:u?.libraries,routes:[]})}catch(e){throw e instanceof Ve?new S(`Could not find a package.json file. Run this command from a project directory.`):new S(`Failed to create prismic.config.json.`)}if(u){try{await wt()}catch{}let{dependencies:e,devDependencies:t,peerDependencies:n}=await W(),r=Object.keys({...e,...t,...n}).filter(e=>e===`slice-machine-ui`||e.startsWith(`@slicemachine/adapter-`));r.length>0&&await qt(r),console.info(`Migrated slicemachine.config.json to prismic.config.json`)}let _=await W();await m.initProject({setup:!a&&!o});for(let{name:e,from:t,to:n}of Wt(_,await W()))console.info(`Updated ${e} from ${t} to ${n}. Check your code for breaking changes in the new version.`);if(!a)try{console.info(`Installing dependencies...`),await Rt()}catch{console.warn(`Could not install dependencies. Run \`${await Vt()}\` to finish.\nThe rest of the setup is done, so you don't need to run \`prismic init\` again.`)}let[v,y]=await Promise.all([E({repo:f,getToken:C,host:d}),m.getModels()]),x=b(v,y);if(s&&p?.starter){if(v.customTypes.length===0&&v.slices.length===0)throw new S(`Repository "${f}" has no starter models. Use a repository created from the starter in the Prismic dashboard.`);await pi(p.starter)}let w=s&&[x.customTypes,x.slices].some(e=>e.update.length>0||e.delete.length>0);if(!w)for(let e of await m.writeModels(x))console.info(e);await m.generateTypes(),await Z([`connectPrismic`],{repo:f,getToken:C,host:d}).catch(()=>{}),te(v.customTypes).length>0&&console.info("\nRun `prismic slice list --legacy` to find legacy slices to upgrade."),w&&console.warn(r`
258
258
  Local and remote models differ, so no model files were changed. The project is connected.
259
259
 
260
260
  Choose the source of truth:
261
261
  prismic pull --force Adopt remote models
262
262
  prismic push --force Keep local models
263
- `),o&&d?.starter?(await ui(f,d.starter,{repo:u,getToken:C,host:l}),x||(console.info(`
263
+ `),s&&p?.starter?(await fi(m,p.starter,{repo:f,getToken:C,host:d}),w||(console.info(`
264
264
  ---`),console.info(`
265
- Your project is ready! Here's what you can do next:`),console.info("- Run `npm run dev` to start the development server"),console.info(`- Open https://${u}.${l}/builder to preview pages live`),console.info(`
265
+ Your project is ready! Here's what you can do next:`),console.info("- Run `npm run dev` to start the development server"),console.info(`- Open https://${f}.${d}/builder to preview pages live`),console.info(`
266
266
  Start building 🚀`))):(console.info(`
267
- ---`),console.info(`\nInitialized Prismic for repository "${u}".`),console.info("Run `prismic type create <name>` to create a content type."),console.info("Run `prismic pull` to pull models from Prismic."));let S=await f.getSetupInstructions();S&&console.info(`\n${S}`)});async function li(e){let t=await U(),n=e.id.split(`/`).at(-1);return!!(n&&t.name===n)}async function ui(e,t,n){try{let{results:t}=await qe(n);await Promise.all(t.filter(e=>e.label===`Starter Preview`).map(e=>Te(e.id,n))),t.some(t=>t.url===e.localPreviewUrl)||await pt(e.localPreviewConfig,n)}catch(t){await ei(t),console.error(`Could not configure the local preview. Run \`prismic preview add ${e.localPreviewUrl} --name ${e.localPreviewConfig.name}\` manually. Continuing.`)}try{await ge(e.localSimulatorUrl,n)}catch(t){await ei(t),console.error(`Could not configure the local slice simulator. Run \`prismic preview set-simulator ${e.localSimulatorUrl}\` manually. Continuing.`)}await Z([`instantStart_continueBuildingLocally`],n).catch(()=>{}),await li(t)&&await Rt(n.repo)}async function di(e){if(!await li(e))return;let t=await R();await Promise.all([$t(new URL(`.deployment`,t),{recursive:!0,force:!0}),$t(new URL(`documents`,t),{recursive:!0,force:!0})])}var fi=S({name:`prismic locale add`,description:`
267
+ ---`),console.info(`\nInitialized Prismic for repository "${f}".`),console.info("Run `prismic type create <name>` to create a content type."),console.info("Run `prismic pull` to pull models from Prismic."));let ne=await m.getSetupInstructions();ne&&console.info(`\n${ne}`)});async function di(e){let t=await W(),n=e.id.split(`/`).at(-1);return!!(n&&t.name===n)}async function fi(e,t,n){try{let{results:t}=await ie(n);await Promise.all(t.filter(e=>e.label===`Starter Preview`).map(e=>bt(e.id,n))),t.some(t=>t.url===e.localPreviewUrl)||await Me(e.localPreviewConfig,n)}catch(t){await ni(t),console.error(`Could not configure the local preview. Run \`prismic preview add ${e.localPreviewUrl} --name ${e.localPreviewConfig.name}\` manually. Continuing.`)}try{await y(e.localSimulatorUrl,n)}catch(t){await ni(t),console.error(`Could not configure the local slice simulator. Run \`prismic preview set-simulator ${e.localSimulatorUrl}\` manually. Continuing.`)}await Z([`instantStart_continueBuildingLocally`],n).catch(()=>{}),await di(t)&&await zt(n.repo)}async function pi(e){if(!await di(e))return;let t=await R();await Promise.all([tn(new URL(`.deployment`,t),{recursive:!0,force:!0}),tn(new URL(`documents`,t),{recursive:!0,force:!0})])}var mi=j({name:`prismic locale add`,description:`
268
268
  Add a locale to a Prismic repository.
269
269
 
270
270
  By default, this command reads the repository from prismic.config.json at the
271
271
  project root.
272
- `,positionals:{code:{description:`Locale code (e.g. fr-fr, es-es)`,required:!0}},options:{master:{type:`boolean`,description:`Set as the master locale`},name:{type:`string`,short:`n`,description:`Custom display name (for custom locales)`},repo:{type:`string`,short:`r`,description:`Repository or environment domain`},env:{type:`string`,short:`e`,description:`Alias for --repo`,deprecated:"Use `prismic env` or --repo instead."}}},async({positionals:e,values:t})=>{let[n]=e,{env:r,repo:i=r??await j(),master:a=!1,name:o}=t,s=await h();await g({id:n,isMaster:a,customName:o},{repo:i,getToken:C,host:s,onUnauthorized:x}),console.info(`Locale added: ${n}`)}),pi=S({name:`prismic locale list`,description:`
272
+ `,positionals:{code:{description:`Locale code (e.g. fr-fr, es-es)`,required:!0}},options:{master:{type:`boolean`,description:`Set as the master locale`},name:{type:`string`,short:`n`,description:`Custom display name (for custom locales)`},repo:{type:`string`,short:`r`,description:`Repository or environment domain`},env:{type:`string`,short:`e`,description:`Alias for --repo`,deprecated:"Use `prismic env` or --repo instead."}}},async({positionals:e,values:t})=>{let[n]=e,{env:r,repo:i=r??await M(),master:a=!1,name:o}=t,s=await g();await w({id:n,isMaster:a,customName:o},{repo:i,getToken:C,host:s,onUnauthorized:x}),console.info(`Locale added: ${n}`)}),hi=j({name:`prismic locale list`,description:`
273
273
  List all locales in a Prismic repository.
274
274
 
275
275
  By default, this command reads the repository from prismic.config.json at the
276
276
  project root.
277
- `,options:{json:{type:`boolean`,description:`Output as JSON`},repo:{type:`string`,short:`r`,description:`Repository or environment domain`},env:{type:`string`,short:`e`,description:`Alias for --repo`,deprecated:"Use `prismic env` or --repo instead."}}},async({values:e})=>{let{env:t,repo:n=t??await j(),json:r}=e,i=await h(),{results:a}=await ae({repo:n,getToken:C,host:i,onUnauthorized:x});if(r){console.info(W(a));return}if(a.length===0){console.info(`No locales found.`);return}let o=a.map(e=>{let t=e.isMaster?` (master)`:``;return[e.id,`${e.label}${t}`]});console.info(M(o,{headers:[`ID`,`LABEL`]}))}),mi=S({name:`prismic locale remove`,description:`
277
+ `,options:{json:{type:`boolean`,description:`Output as JSON`},repo:{type:`string`,short:`r`,description:`Repository or environment domain`},env:{type:`string`,short:`e`,description:`Alias for --repo`,deprecated:"Use `prismic env` or --repo instead."}}},async({values:e})=>{let{env:t,repo:n=t??await M(),json:r}=e,i=await g(),{results:a}=await Xe({repo:n,getToken:C,host:i,onUnauthorized:x});if(r){console.info(G(a));return}if(a.length===0){console.info(`No locales found.`);return}let o=a.map(e=>{let t=e.isMaster?` (master)`:``;return[e.id,`${e.label}${t}`]});console.info(L(o,{headers:[`ID`,`LABEL`]}))}),gi=j({name:`prismic locale remove`,description:`
278
278
  Remove a locale from a Prismic repository.
279
279
 
280
280
  By default, this command reads the repository from prismic.config.json at the
281
281
  project root.
282
- `,positionals:{code:{description:`Locale code (e.g. en-us, fr-fr)`,required:!0}},options:{repo:{type:`string`,short:`r`,description:`Repository or environment domain`},env:{type:`string`,short:`e`,description:`Alias for --repo`,deprecated:"Use `prismic env` or --repo instead."}}},async({positionals:e,values:t})=>{let[n]=e,{env:r,repo:i=r??await j()}=t,a=await h();await He(n,{repo:i,getToken:C,host:a,onUnauthorized:x}),console.info(`Locale removed: ${n}`)}),hi=S({name:`prismic locale set-master`,description:`
282
+ `,positionals:{code:{description:`Locale code (e.g. en-us, fr-fr)`,required:!0}},options:{repo:{type:`string`,short:`r`,description:`Repository or environment domain`},env:{type:`string`,short:`e`,description:`Alias for --repo`,deprecated:"Use `prismic env` or --repo instead."}}},async({positionals:e,values:t})=>{let[n]=e,{env:r,repo:i=r??await M()}=t,a=await g();await Be(n,{repo:i,getToken:C,host:a,onUnauthorized:x}),console.info(`Locale removed: ${n}`)}),_i=j({name:`prismic locale set-master`,description:`
283
283
  Set the master locale for a Prismic repository.
284
284
 
285
285
  By default, this command reads the repository from prismic.config.json at the
286
286
  project root.
287
- `,positionals:{code:{description:`Locale code (e.g. en-us, fr-fr)`,required:!0}},options:{repo:{type:`string`,short:`r`,description:`Repository or environment domain`},env:{type:`string`,short:`e`,description:`Alias for --repo`,deprecated:"Use `prismic env` or --repo instead."}}},async({positionals:e,values:t})=>{let[n]=e,{env:r,repo:i=r??await j()}=t,a=await h(),{results:o}=await ae({repo:i,getToken:C,host:a,onUnauthorized:x}),s=o.find(e=>e.id===n);if(!s)throw new L(`Locale "${n}" not found. Available locales: ${o.map(e=>e.id).join(`, `)}`);if(s.isMaster)throw new L(`Locale "${n}" is already the master.`);await g({id:s.id,isMaster:!0,customName:s.customName??void 0},{repo:i,getToken:C,host:a,onUnauthorized:x}),console.info(`Master locale set: ${n}`)}),gi=A({name:`prismic locale`,description:`
287
+ `,positionals:{code:{description:`Locale code (e.g. en-us, fr-fr)`,required:!0}},options:{repo:{type:`string`,short:`r`,description:`Repository or environment domain`},env:{type:`string`,short:`e`,description:`Alias for --repo`,deprecated:"Use `prismic env` or --repo instead."}}},async({positionals:e,values:t})=>{let[n]=e,{env:r,repo:i=r??await M()}=t,a=await g(),{results:o}=await Xe({repo:i,getToken:C,host:a,onUnauthorized:x}),s=o.find(e=>e.id===n);if(!s)throw new S(`Locale "${n}" not found. Available locales: ${o.map(e=>e.id).join(`, `)}`);if(s.isMaster)throw new S(`Locale "${n}" is already the master.`);await w({id:s.id,isMaster:!0,customName:s.customName??void 0},{repo:i,getToken:C,host:a,onUnauthorized:x}),console.info(`Master locale set: ${n}`)}),vi=A({name:`prismic locale`,description:`
288
288
  Manage locales in a Prismic repository.
289
289
 
290
290
  Run \`prismic docs view locales\` for details.
291
- `,commands:{add:{handler:fi,description:`Add a locale`},list:{handler:pi,description:`List locales`},remove:{handler:mi,description:`Remove a locale`},"set-master":{handler:hi,description:`Set the master locale`}}}),_i=S({name:`prismic login`,description:`Log in to Prismic. Prints a URL and a code to approve in a browser.`,options:{"no-browser":{type:`boolean`,description:`Skip opening the browser automatically`}}},async({values:e})=>{await ct({browser:!e[`no-browser`]})}),vi=S({name:`prismic logout`,description:`Log out of Prismic.`},async()=>{let e=!1;await ft(async t=>{try{let t=(await De()).login?.session;t?.refreshToken&&(await Xe(t.refreshToken,t),e=!0)}catch(e){if(!(e instanceof ut||e instanceof je))throw e;console.warn(`Couldn't revoke your session because ${yi(e)}. It stays valid until it expires.`)}await We(t),await ye()}),ht({revoked:e}),I.PRISMIC_TOKEN&&console.warn(`PRISMIC_TOKEN is still set, so commands still use it.`),console.info(`Logged out of Prismic`)});function yi(e){return e instanceof ut?`the saved login can't be read`:e.reason===`unavailable`?`the Prismic login service can't be reached`:`the Prismic login service answered ${e.detail}`}var bi=S({name:`prismic preview add`,description:`
291
+ `,commands:{add:{handler:mi,description:`Add a locale`},list:{handler:hi,description:`List locales`},remove:{handler:gi,description:`Remove a locale`},"set-master":{handler:_i,description:`Set the master locale`}}}),yi=j({name:`prismic login`,description:`Log in to Prismic. Prints a URL and a code to approve in a browser.`,options:{"no-browser":{type:`boolean`,description:`Skip opening the browser automatically`}}},async({values:e})=>{await lt({browser:!e[`no-browser`]})}),bi=j({name:`prismic logout`,description:`Log out of Prismic.`},async()=>{let e=!1;await je(async t=>{try{let t=(await at()).login?.session;t?.refreshToken&&(await gt(t.refreshToken,t),e=!0)}catch(e){if(!(e instanceof Ge||e instanceof Ze))throw e;console.warn(`Couldn't revoke your session because ${xi(e)}. It stays valid until it expires.`)}await De(t),await be()}),ht({revoked:e}),F.PRISMIC_TOKEN&&console.warn(`PRISMIC_TOKEN is still set, so commands still use it.`),console.info(`Logged out of Prismic`)});function xi(e){return e instanceof Ge?`the saved login can't be read`:e.reason===`unavailable`?`the Prismic login service can't be reached`:`the Prismic login service answered ${e.detail}`}var Si=j({name:`prismic preview add`,description:`
292
292
  Add a preview configuration to a Prismic repository.
293
293
 
294
294
  By default, this command reads the repository from prismic.config.json at the
295
295
  project root.
296
- `,positionals:{url:{description:`Preview URL (e.g. https://example.com/api/preview)`,required:!0}},options:{name:{type:`string`,short:`n`,description:`Display name (defaults to hostname)`},repo:{type:`string`,short:`r`,description:`Repository or environment domain`},env:{type:`string`,short:`e`,description:`Alias for --repo`,deprecated:"Use `prismic env` or --repo instead."}}},async({positionals:e,values:t})=>{let[n]=e,{env:r,repo:i=r??await j(),name:a}=t,o;try{o=new URL(n)}catch{throw new L(`Invalid URL: ${n}`)}let s=a||o.hostname,c=`${o.protocol}//${o.host}`,l=o.pathname===`/`?void 0:o.pathname,u=await h();await pt({name:s,websiteURL:c,resolverPath:l},{repo:i,getToken:C,host:u,onUnauthorized:x}),console.info(`Preview added: ${n}`),console.info("Run `prismic preview set-simulator <url>` to set the slice simulator URL.");try{let e=await(await P()).getSetupInstructions();e&&console.info(`\n${e}`)}catch(e){if(!(e instanceof Ee||e instanceof Gt))throw e}}),xi=S({name:`prismic preview list`,description:`
296
+ `,positionals:{url:{description:`Preview URL (e.g. https://example.com/api/preview)`,required:!0}},options:{name:{type:`string`,short:`n`,description:`Display name (defaults to hostname)`},repo:{type:`string`,short:`r`,description:`Repository or environment domain`},env:{type:`string`,short:`e`,description:`Alias for --repo`,deprecated:"Use `prismic env` or --repo instead."}}},async({positionals:e,values:t})=>{let[n]=e,{env:r,repo:i=r??await M(),name:a}=t,o;try{o=new URL(n)}catch{throw new S(`Invalid URL: ${n}`)}let s=a||o.hostname,c=`${o.protocol}//${o.host}`,l=o.pathname===`/`?void 0:o.pathname,u=await g();await Me({name:s,websiteURL:c,resolverPath:l},{repo:i,getToken:C,host:u,onUnauthorized:x}),console.info(`Preview added: ${n}`),console.info("Run `prismic preview set-simulator <url>` to set the slice simulator URL.");try{let e=await(await P()).getSetupInstructions();e&&console.info(`\n${e}`)}catch(e){if(!(e instanceof Ee||e instanceof Kt))throw e}}),Ci=j({name:`prismic preview list`,description:`
297
297
  List all preview configurations in a Prismic repository.
298
298
 
299
299
  By default, this command reads the repository from prismic.config.json at the
300
300
  project root.
301
- `,options:{json:{type:`boolean`,description:`Output as JSON`},repo:{type:`string`,short:`r`,description:`Repository or environment domain`},env:{type:`string`,short:`e`,description:`Alias for --repo`,deprecated:"Use `prismic env` or --repo instead."}}},async({values:e})=>{let{env:t,repo:n=t??await j(),json:r}=e,i=await h(),[{results:a},{simulator_url:o}]=await Promise.all([qe({repo:n,getToken:C,host:i,onUnauthorized:x}),se({repo:n,getToken:C,host:i,onUnauthorized:x})]);if(r)console.info(W({previews:a,simulatorUrl:o??null}));else if(a.length===0&&!o)console.info(`No preview configurations found.`);else{if(a.length>0){let e=a.map(e=>[e.url,e.label]);console.info(M(e,{headers:[`URL`,`NAME`]}))}o&&(a.length>0&&console.info(``),console.info(`Simulator: ${o}`))}}),Si=S({name:`prismic preview remove`,description:`
301
+ `,options:{json:{type:`boolean`,description:`Output as JSON`},repo:{type:`string`,short:`r`,description:`Repository or environment domain`},env:{type:`string`,short:`e`,description:`Alias for --repo`,deprecated:"Use `prismic env` or --repo instead."}}},async({values:e})=>{let{env:t,repo:n=t??await M(),json:r}=e,i=await g(),[{results:a},{simulator_url:o}]=await Promise.all([ie({repo:n,getToken:C,host:i,onUnauthorized:x}),h({repo:n,getToken:C,host:i,onUnauthorized:x})]);if(r)console.info(G({previews:a,simulatorUrl:o??null}));else if(a.length===0&&!o)console.info(`No preview configurations found.`);else{if(a.length>0){let e=a.map(e=>[e.url,e.label]);console.info(L(e,{headers:[`URL`,`NAME`]}))}o&&(a.length>0&&console.info(``),console.info(`Simulator: ${o}`))}}),wi=j({name:`prismic preview remove`,description:`
302
302
  Remove a preview configuration from a Prismic repository.
303
303
 
304
304
  By default, this command reads the repository from prismic.config.json at the
305
305
  project root.
306
- `,positionals:{url:{description:`Preview URL to remove`,required:!0}},options:{repo:{type:`string`,short:`r`,description:`Repository or environment domain`},env:{type:`string`,short:`e`,description:`Alias for --repo`,deprecated:"Use `prismic env` or --repo instead."}}},async({positionals:e,values:t})=>{let[n]=e,{env:r,repo:i=r??await j()}=t,a=await h(),{results:o}=await qe({repo:i,getToken:C,host:a,onUnauthorized:x}),s=o.find(e=>e.url===n);if(!s)throw new L(`Preview not found: ${n}`);await Te(s.id,{repo:i,getToken:C,host:a,onUnauthorized:x}),console.info(`Preview removed: ${n}`)}),Ci=S({name:`prismic preview set-simulator`,description:`
306
+ `,positionals:{url:{description:`Preview URL to remove`,required:!0}},options:{repo:{type:`string`,short:`r`,description:`Repository or environment domain`},env:{type:`string`,short:`e`,description:`Alias for --repo`,deprecated:"Use `prismic env` or --repo instead."}}},async({positionals:e,values:t})=>{let[n]=e,{env:r,repo:i=r??await M()}=t,a=await g(),{results:o}=await ie({repo:i,getToken:C,host:a,onUnauthorized:x}),s=o.find(e=>e.url===n);if(!s)throw new S(`Preview not found: ${n}`);await bt(s.id,{repo:i,getToken:C,host:a,onUnauthorized:x}),console.info(`Preview removed: ${n}`)}),Ti=j({name:`prismic preview set-simulator`,description:`
307
307
  Set the slice simulator URL for a Prismic repository.
308
308
 
309
309
  If the URL pathname does not end with /slice-simulator, it is appended
@@ -311,7 +311,7 @@ Start building 🚀`))):(console.info(`
311
311
 
312
312
  By default, this command reads the repository from prismic.config.json at the
313
313
  project root.
314
- `,positionals:{url:{description:`Simulator URL (e.g. https://example.com/slice-simulator)`,required:!0}},options:{repo:{type:`string`,short:`r`,description:`Repository or environment domain`},env:{type:`string`,short:`e`,description:`Alias for --repo`,deprecated:"Use `prismic env` or --repo instead."}}},async({positionals:e,values:t})=>{let[n]=e,{env:r,repo:i=r??await j()}=t,a;try{a=new URL(n)}catch{throw new L(`Invalid URL: ${n}`)}a.pathname.endsWith(`/slice-simulator`)||(a.pathname=a.pathname.replace(/\/+$/,``)+`/slice-simulator`);let o=a.toString(),s=await h();await ge(o,{repo:i,getToken:C,host:s,onUnauthorized:x}),console.info(`Simulator URL set: ${o}`)}),wi=A({name:`prismic preview`,description:`
314
+ `,positionals:{url:{description:`Simulator URL (e.g. https://example.com/slice-simulator)`,required:!0}},options:{repo:{type:`string`,short:`r`,description:`Repository or environment domain`},env:{type:`string`,short:`e`,description:`Alias for --repo`,deprecated:"Use `prismic env` or --repo instead."}}},async({positionals:e,values:t})=>{let[n]=e,{env:r,repo:i=r??await M()}=t,a;try{a=new URL(n)}catch{throw new S(`Invalid URL: ${n}`)}a.pathname.endsWith(`/slice-simulator`)||(a.pathname=a.pathname.replace(/\/+$/,``)+`/slice-simulator`);let o=a.toString(),s=await g();await y(o,{repo:i,getToken:C,host:s,onUnauthorized:x}),console.info(`Simulator URL set: ${o}`)}),Ei=A({name:`prismic preview`,description:`
315
315
  Manage previews in a Prismic repository.
316
316
 
317
317
  Run \`prismic docs view previews\` for details.
@@ -319,15 +319,18 @@ Start building 🚀`))):(console.info(`
319
319
  Set up previews after a deploy, using both settings:
320
320
  prismic preview add https://example.com/api/preview
321
321
  prismic preview set-simulator https://example.com
322
- `},commands:{add:{handler:bi,description:`Add a preview URL`},list:{handler:xi,description:`List preview URLs and the simulator URL`},remove:{handler:Si,description:`Remove a preview URL`},"set-simulator":{handler:Ci,description:`Set the slice simulator URL`}}});async function Ti(e){try{let{stdout:t}=await zt(`git`,[`rev-parse`,`--show-toplevel`],{nodeOptions:{cwd:en(e)},throwOnError:!0}),n=t.trim();return n?Ht(tn(await Qt(n))):void 0}catch{return}}async function Ei(e){try{let{stdout:t}=await zt(`git`,[`status`,`--porcelain`,`--untracked-files=all`],{nodeOptions:{cwd:en(e)},throwOnError:!0}),n=[];for(let r of t.split(`
323
- `)){if(r.length<4)continue;let t=r.slice(3),i=t.indexOf(` -> `);i!==-1&&(t=t.slice(i+4)),n.push(new URL(t,e))}return n}catch{return[]}}var Di=S({name:`prismic pull`,description:`
322
+ `},commands:{add:{handler:Si,description:`Add a preview URL`},list:{handler:Ci,description:`List preview URLs and the simulator URL`},remove:{handler:wi,description:`Remove a preview URL`},"set-simulator":{handler:Ti,description:`Set the slice simulator URL`}}});async function Di(e){try{let{stdout:t}=await Bt(`git`,[`rev-parse`,`--show-toplevel`],{nodeOptions:{cwd:nn(e)},throwOnError:!0}),n=t.trim();return n?Ht(rn(await en(n))):void 0}catch{return}}async function Oi(e){try{let{stdout:t}=await Bt(`git`,[`status`,`--porcelain`,`--untracked-files=all`],{nodeOptions:{cwd:nn(e)},throwOnError:!0}),n=[];for(let r of t.split(`
323
+ `)){if(r.length<4)continue;let t=r.slice(3),i=t.indexOf(` -> `);i!==-1&&(t=t.slice(i+4)),n.push(new URL(t,e))}return n}catch{return[]}}var ki=j({name:`prismic pull`,description:`
324
324
  Pull content types and slices from Prismic to local files.
325
325
 
326
326
  Remote models are the source of truth. Local files are created, updated,
327
327
  or deleted to match.
328
328
 
329
329
  Run \`prismic docs view cli#pull-models-from-prismic\` for details.
330
- `,options:{force:{type:`boolean`,short:`f`,description:`Skip the git history check and overwrite local changes`},repo:{type:`string`,short:`r`,description:`Repository or environment domain`},env:{type:`string`,short:`e`,description:`Alias for --repo`,deprecated:"Use `prismic env` or --repo instead."}}},async({values:e})=>{let t=await P(),{force:n=!1,env:r,repo:i=r??await t.getEnvironment()??await O()}=e,a=await h(),o=await R();console.info(`Pulling from repository: ${i}`);let[s,c,l]=await Promise.all([Ti(o),t.getCustomTypeLibraries(),t.getSliceLibraries()]);if(!n&&s){let e=(await Ei(s)).filter(e=>e.pathname.endsWith(`/model.json`)&&l.some(t=>z(t,e))||e.pathname.endsWith(`/index.json`)&&c.some(t=>z(t,e))).map(e=>B(o,e));if(e.length>0)throw new L(`
330
+ `,agents:`
331
+ Use --force only when the user asks for it. It discards uncommitted
332
+ local model changes.
333
+ `,options:{force:{type:`boolean`,short:`f`,description:`Skip the git history check and overwrite local changes`},repo:{type:`string`,short:`r`,description:`Repository or environment domain`},env:{type:`string`,short:`e`,description:`Alias for --repo`,deprecated:"Use `prismic env` or --repo instead."}}},async({values:e})=>{let t=await P(),{force:n=!1,env:r,repo:i=r??await t.getEnvironment()??await O()}=e,a=await g(),o=await R();console.info(`Pulling from repository: ${i}`);let[s,c,l]=await Promise.all([Di(o),t.getCustomTypeLibraries(),t.getSliceLibraries()]);if(!n&&s){let e=(await Oi(s)).filter(e=>e.pathname.endsWith(`/model.json`)&&l.some(t=>B(t,e))||e.pathname.endsWith(`/index.json`)&&c.some(t=>B(t,e))).map(e=>H(o,e));if(e.length>0)throw new S(`
331
334
  Local model files have uncommitted changes. Prismic keeps model history in
332
335
  git. Commit model changes before you pull them, so this pull can't discard
333
336
  your edits:
@@ -339,7 +342,7 @@ Start building 🚀`))):(console.info(`
339
342
  Other options:
340
343
  prismic push --force Keep local edits, overwrite remote
341
344
  prismic pull --force Discard local edits, adopt remote
342
- `)}let[u,d,f]=await Promise.all([t.getCustomTypes(),t.getSlices(),D({repo:i,getToken:C,host:a,onUnauthorized:x})]),p=y(f,{customTypes:u.map(e=>e.model),slices:d.map(e=>e.model)},{treatNonCanonicalAsChanged:!0});if(!n&&!s){let e=new Set([...p.customTypes.update,...p.customTypes.delete].map(e=>e.id)),t=new Set([...p.slices.update,...p.slices.delete].map(e=>e.id)),n=[...u.filter(t=>e.has(t.model.id)),...d.filter(e=>t.has(e.model.id))].map(e=>B(o,e.modelPath));if(n.length>0)throw new L(`
345
+ `)}let[u,d,f]=await Promise.all([t.getCustomTypes(),t.getSlices(),E({repo:i,getToken:C,host:a,onUnauthorized:x})]),p=b(f,{customTypes:u.map(e=>e.model),slices:d.map(e=>e.model)},{treatNonCanonicalAsChanged:!0});if(!n&&!s){let e=new Set([...p.customTypes.update,...p.customTypes.delete].map(e=>e.id)),t=new Set([...p.slices.update,...p.slices.delete].map(e=>e.id)),n=[...u.filter(t=>e.has(t.model.id)),...d.filter(e=>t.has(e.model.id))].map(e=>H(o,e.modelPath));if(n.length>0)throw new S(`
343
346
  Pull would modify or delete local model files:
344
347
  ${n.join(`
345
348
  `)}
@@ -347,7 +350,7 @@ Start building 🚀`))):(console.info(`
347
350
  This project isn't in a git repo, so changes can't be tracked. Choose one:
348
351
  prismic pull --force Discard local files, adopt remote
349
352
  prismic push --force Keep local files, overwrite remote
350
- `)}let m=await t.writeModels(p);await t.generateTypes(),await Z([`connectPrismic`],{repo:await O(),getToken:C,host:a,onUnauthorized:x}).catch(()=>{});let g=p.customTypes.insert.length+p.customTypes.update.length,_=p.slices.insert.length+p.slices.update.length,v=p.customTypes.delete.length+p.slices.delete.length;for(let e of m)console.info(e);g===0&&_===0&&v===0?console.info(`Already up to date.`):(console.info(`Inserted ${p.customTypes.insert.length}, updated ${p.customTypes.update.length}, deleted ${p.customTypes.delete.length} types`),console.info(`Inserted ${p.slices.insert.length}, updated ${p.slices.update.length}, deleted ${p.slices.delete.length} slices`))}),Oi=S({name:`prismic push`,description:`
353
+ `)}let m=await t.writeModels(p);await t.generateTypes(),await Z([`connectPrismic`],{repo:await O(),getToken:C,host:a,onUnauthorized:x}).catch(()=>{});let h=p.customTypes.insert.length+p.customTypes.update.length,_=p.slices.insert.length+p.slices.update.length,v=p.customTypes.delete.length+p.slices.delete.length;for(let e of m)console.info(e);h===0&&_===0&&v===0?console.info(`Already up to date.`):(console.info(`Inserted ${p.customTypes.insert.length}, updated ${p.customTypes.update.length}, deleted ${p.customTypes.delete.length} types`),console.info(`Inserted ${p.slices.insert.length}, updated ${p.slices.update.length}, deleted ${p.slices.delete.length} slices`))}),Ai=j({name:`prismic push`,description:`
351
354
  Push local content types and slices to Prismic.
352
355
 
353
356
  Local models are the source of truth. Remote models are created,
@@ -358,7 +361,10 @@ Start building 🚀`))):(console.info(`
358
361
  Deleting a remote model needs --force.
359
362
 
360
363
  Run \`prismic docs view cli#push-models-to-prismic\` for details.
361
- `,options:{force:{type:`boolean`,short:`f`,description:`Skip the git history and deletion checks`},repo:{type:`string`,short:`r`,description:`Repository or environment domain`},env:{type:`string`,short:`e`,description:`Alias for --repo`,deprecated:"Use `prismic env` or --repo instead."}}},async({values:e})=>{let t=await P(),{force:n=!1,env:r,repo:i=r??await t.getEnvironment()??await O()}=e,a=await h(),o=await R();console.info(`Pushing to repository: ${i}`);let[s,c,l]=await Promise.all([Ti(o),t.getCustomTypeLibraries(),t.getSliceLibraries()]);if(!n&&s){let e=(await Ei(s)).filter(e=>e.pathname.endsWith(`/model.json`)&&l.some(t=>z(t,e))||e.pathname.endsWith(`/index.json`)&&c.some(t=>z(t,e))).map(e=>B(o,e));if(e.length>0)throw new L(`
364
+ `,agents:`
365
+ Use --force only when the user asks for it. It lets push delete remote
366
+ models and skips the git check.
367
+ `,options:{force:{type:`boolean`,short:`f`,description:`Skip the git history and deletion checks`},repo:{type:`string`,short:`r`,description:`Repository or environment domain`},env:{type:`string`,short:`e`,description:`Alias for --repo`,deprecated:"Use `prismic env` or --repo instead."}}},async({values:e})=>{let t=await P(),{force:n=!1,env:r,repo:i=r??await t.getEnvironment()??await O()}=e,a=await g(),o=await R();console.info(`Pushing to repository: ${i}`);let[s,c,l]=await Promise.all([Di(o),t.getCustomTypeLibraries(),t.getSliceLibraries()]);if(!n&&s){let e=(await Oi(s)).filter(e=>e.pathname.endsWith(`/model.json`)&&l.some(t=>B(t,e))||e.pathname.endsWith(`/index.json`)&&c.some(t=>B(t,e))).map(e=>H(o,e));if(e.length>0)throw new S(`
362
368
  Local model files have uncommitted changes. Prismic keeps model history in
363
369
  git. Commit model changes before you push them:
364
370
 
@@ -367,50 +373,50 @@ Start building 🚀`))):(console.info(`
367
373
  prismic push
368
374
 
369
375
  Or skip the check with \`prismic push --force\`.
370
- `)}let[u,d]=await Promise.all([t.getModels(),D({repo:i,getToken:C,host:a,onUnauthorized:x})]),f=y(u,d);if(!n){let e=Ht(c[0]),t=Ht(l[0]),n=[...f.customTypes.delete.map(t=>B(o,new URL(`${t.id}/index.json`,e))),...f.slices.delete.map(e=>B(o,new URL(`${ze(e.name)}/model.json`,t)))];if(n.length>0)throw new L(`
376
+ `)}let[u,d]=await Promise.all([t.getModels(),E({repo:i,getToken:C,host:a,onUnauthorized:x})]),f=b(u,d);if(!n){let e=Ht(c[0]),t=Ht(l[0]),n=[...f.customTypes.delete.map(t=>H(o,new URL(`${t.id}/index.json`,e))),...f.slices.delete.map(e=>H(o,new URL(`${we(e.name)}/model.json`,t)))];if(n.length>0)throw new S(`
371
377
  Push would delete remote models. Re-run with --force to proceed.
372
378
 
373
379
  Models that would be deleted:
374
380
  ${n.join(`
375
381
  `)}
376
- `)}try{await _(f,{repo:i,getToken:C,host:a,onUnauthorized:x})}catch(e){throw await Ai(e,f.customTypes.delete,{repo:i,getToken:C,host:a,onUnauthorized:x})}for(let{id:e}of f.slices.delete)await wt(e,{repo:i,getToken:C,host:a,onUnauthorized:x}).catch(t=>{let n=t instanceof Error?t.message:String(t);console.warn(`Failed to delete screenshots for slice "${e}"${n?`: ${n}`:`.`}`)});let p=[];f.slices.insert.length>0&&p.push(`createSlice`),f.customTypes.insert.some(e=>e.format===`page`)&&p.push(`createPageType`),p.length>0&&await Z(p,{repo:await O(),getToken:C,host:a,onUnauthorized:x}).catch(()=>{});let m=f.customTypes.insert.length+f.customTypes.update.length,g=f.slices.insert.length+f.slices.update.length,v=f.customTypes.delete.length+f.slices.delete.length;m===0&&g===0&&v===0?console.info(`Already up to date.`):(console.info(`Pushed ${m} type(s), ${g} slice(s).`),v>0&&console.info(`Deleted ${v} model(s).`))});const ki=G({hasExistingDocuments:At(!0)});async function Ai(e,t,n){if(!(e instanceof K)||!Vt(ki,e.body).success)return e;let{repo:r,host:i}=n;for(let{id:e}of t){let t=ji({repo:r,host:i,customTypeId:e}),a;try{a=(await f(e,n)).total}catch{return new L(`Could not check whether type "${e}" has associated pages.
377
- Please try again, or manually delete any associated pages at: `+t)}if(a!==0)return new L(`Could not delete type "${e}" because it has ${a} associated ${a===1?`page`:`pages`}. \nDelete any associated pages manually before pushing at: `+t)}return e}function ji(e){let{repo:t,host:n,customTypeId:r}=e,i=new URL(`builder/working`,`https://${t}.${n}/`);return i.searchParams.set(`customTypes`,r),i.href}var Mi=S({name:`prismic repo list`,description:`List all Prismic repositories associated with your account.`,options:{json:{type:`boolean`,description:`Output as JSON`}}},async({values:e})=>{let{json:t}=e,n=await h(),{repositories:r}=await b({getToken:C,host:n,onUnauthorized:x});if(t){console.info(W(r.map(e=>({domain:e.domain,name:e.name??null,role:e.role??null,url:`https://${e.domain}.${n}/`}))));return}if(r.length===0){console.info(`No repositories found.`);return}let i=r.map(e=>{let t=e.name||`(no name)`;return[e.domain,t,Ni(e.role)]});console.info(M(i,{headers:[`DOMAIN`,`NAME`,`ROLE`]}))});function Ni(e){return typeof e==`string`?e:e?Object.entries(e).map(([e,t])=>`${t} (${e})`).join(`, `):``}const Pi=[`private`,`public`,`open`],Fi={name:`prismic repo set-api-access`,description:`
382
+ `)}try{await v(f,{repo:i,getToken:C,host:a,onUnauthorized:x})}catch(e){throw await Mi(e,f.customTypes.delete,{repo:i,getToken:C,host:a,onUnauthorized:x})}for(let{id:e}of f.slices.delete)await Ae(e,{repo:i,getToken:C,host:a,onUnauthorized:x}).catch(t=>{let n=t instanceof Error?t.message:String(t);console.warn(`Failed to delete screenshots for slice "${e}"${n?`: ${n}`:`.`}`)});let p=[];f.slices.insert.length>0&&p.push(`createSlice`),f.customTypes.insert.some(e=>e.format===`page`)&&p.push(`createPageType`),p.length>0&&await Z(p,{repo:await O(),getToken:C,host:a,onUnauthorized:x}).catch(()=>{});let m=f.customTypes.insert.length+f.customTypes.update.length,h=f.slices.insert.length+f.slices.update.length,_=f.customTypes.delete.length+f.slices.delete.length;m===0&&h===0&&_===0?console.info(`Already up to date.`):(console.info(`Pushed ${m} type(s), ${h} slice(s).`),_>0&&console.info(`Deleted ${_} model(s).`))});const ji=z({hasExistingDocuments:Pt(!0)});async function Mi(e,t,n){if(!(e instanceof K)||!Lt(ji,e.body).success)return e;let{repo:r,host:i}=n;for(let{id:e}of t){let t=Ni({repo:r,host:i,customTypeId:e}),a;try{a=(await d(e,n)).total}catch{return new S(`Could not check whether type "${e}" has associated pages.
383
+ Please try again, or manually delete any associated pages at: `+t)}if(a!==0)return new S(`Could not delete type "${e}" because it has ${a} associated ${a===1?`page`:`pages`}. \nDelete any associated pages manually before pushing at: `+t)}return e}function Ni(e){let{repo:t,host:n,customTypeId:r}=e,i=new URL(`builder/working`,`https://${t}.${n}/`);return i.searchParams.set(`customTypes`,r),i.href}var Pi=j({name:`prismic repo list`,description:`List all Prismic repositories associated with your account.`,options:{json:{type:`boolean`,description:`Output as JSON`}}},async({values:e})=>{let{json:t}=e,n=await g(),{repositories:r}=await ne({getToken:C,host:n,onUnauthorized:x});if(t){console.info(G(r.map(e=>({domain:e.domain,name:e.name??null,role:e.role??null,url:`https://${e.domain}.${n}/`}))));return}if(r.length===0){console.info(`No repositories found.`);return}let i=r.map(e=>{let t=e.name||`(no name)`;return[e.domain,t,Fi(e.role)]});console.info(L(i,{headers:[`DOMAIN`,`NAME`,`ROLE`]}))});function Fi(e){return typeof e==`string`?e:e?Object.entries(e).map(([e,t])=>`${t} (${e})`).join(`, `):``}const Ii=[`private`,`public`,`open`],Li={name:`prismic repo set-api-access`,description:`
378
384
  Set the Content API access level of a Prismic repository.
379
385
 
380
386
  By default, this command reads the repository from prismic.config.json at the
381
387
  project root.
382
388
 
383
389
  Run \`prismic docs view repository-settings#configuration\` for details.
384
- `,positionals:{level:{description:`Access level (${Pi.join(`, `)})`,required:!0}},options:{repo:{type:`string`,short:`r`,description:`Repository domain`}}};var Ii=S(Fi,async({positionals:e,values:t})=>{let[n]=e,{repo:r=await O()}=t;if(!Pi.includes(n))throw new L(`Invalid access level: ${n}. Must be one of: ${Pi.join(`, `)}`);let i=await h();await Et(n,{repo:r,getToken:C,host:i,onUnauthorized:x}),console.info(`Repository access set to: ${n}`)}),Li=S({name:`prismic repo set-name`,description:`
390
+ `,positionals:{level:{description:`Access level (${Ii.join(`, `)})`,required:!0}},options:{repo:{type:`string`,short:`r`,description:`Repository domain`}}};var Ri=j(Li,async({positionals:e,values:t})=>{let[n]=e,{repo:r=await O()}=t;if(!Ii.includes(n))throw new S(`Invalid access level: ${n}. Must be one of: ${Ii.join(`, `)}`);let i=await g();await s(n,{repo:r,getToken:C,host:i,onUnauthorized:x}),console.info(`Repository access set to: ${n}`)}),zi=j({name:`prismic repo set-name`,description:`
385
391
  Set the display name of a Prismic repository.
386
392
 
387
393
  By default, this command reads the repository from prismic.config.json at the
388
394
  project root.
389
- `,positionals:{name:{description:`Display name for the repository`,required:!0}},options:{repo:{type:`string`,short:`r`,description:`Repository domain`}}},async({positionals:e,values:t})=>{let[n]=e,{repo:r=await O()}=t,i=await h(),{repository:a}=await o(n,{repo:r,getToken:C,host:i,onUnauthorized:x});console.info(`Repository name set to: ${a.name}`)}),Ri=S({name:`prismic repo view`,description:`
395
+ `,positionals:{name:{description:`Display name for the repository`,required:!0}},options:{repo:{type:`string`,short:`r`,description:`Repository domain`}}},async({positionals:e,values:t})=>{let[n]=e,{repo:r=await O()}=t,i=await g(),{repository:a}=await _e(n,{repo:r,getToken:C,host:i,onUnauthorized:x});console.info(`Repository name set to: ${a.name}`)}),Bi=j({name:`prismic repo view`,description:`
390
396
  View details of a Prismic repository.
391
397
 
392
398
  By default, this command reads the repository from prismic.config.json at the
393
399
  project root.
394
- `,options:{web:{type:`boolean`,short:`w`,description:`Open repository in browser`},json:{type:`boolean`,description:`Output as JSON`},repo:{type:`string`,short:`r`,description:`Repository domain`}}},async({values:e})=>{let{repo:t=await O(),web:n,json:r}=e,i=await h(),a=`https://${t}.${i}/`;if(n){mt(new URL(a)),console.info(`Opening ${a}`);return}let[o,s]=await Promise.all([ne({repo:t,getToken:C,host:i,onUnauthorized:x}),re({repo:t,getToken:C,host:i,onUnauthorized:x}).catch(e=>{if(!sn(e))throw e})]);if(r){console.info(W({domain:t,name:o.name??null,url:a,apiAccess:s?.repository.api_access??null}));return}let c=o.name||`(no name)`;console.info(`Name: ${c}`),console.info(`URL: ${a}`),console.info(`Content API: ${s?.repository.api_access??`(unavailable)`}`)}),zi=A({name:`prismic repo`,description:`
400
+ `,options:{web:{type:`boolean`,short:`w`,description:`Open repository in browser`},json:{type:`boolean`,description:`Output as JSON`},repo:{type:`string`,short:`r`,description:`Repository domain`}}},async({values:e})=>{let{repo:t=await O(),web:n,json:r}=e,i=await g(),a=`https://${t}.${i}/`;if(n){nt(new URL(a)),console.info(`Opening ${a}`);return}let[o,s]=await Promise.all([ae({repo:t,getToken:C,host:i,onUnauthorized:x}),le({repo:t,getToken:C,host:i,onUnauthorized:x}).catch(e=>{if(!ln(e))throw e})]);if(r){console.info(G({domain:t,name:o.name??null,url:a,apiAccess:s?.repository.api_access??null}));return}let c=o.name||`(no name)`;console.info(`Name: ${c}`),console.info(`URL: ${a}`),console.info(`Content API: ${s?.repository.api_access??`(unavailable)`}`)}),Vi=A({name:`prismic repo`,description:`
395
401
  Manage Prismic repositories.
396
402
 
397
403
  Run \`prismic docs view repository-settings\` for details.
398
- `,commands:{create:{handler:ai,description:`Create a new repository`},list:{handler:Mi,description:`List repositories`},view:{handler:Ri,description:`View repository details`},"set-name":{handler:Li,description:`Set repository display name`},"set-api-access":{handler:Ii,description:`Set Content API access level`}}}),Bi=S({name:`prismic slice add-variation`,description:`
404
+ `,commands:{create:{handler:si,description:`Create a new repository`},list:{handler:Pi,description:`List repositories`},view:{handler:Bi,description:`View repository details`},"set-name":{handler:zi,description:`Set repository display name`},"set-api-access":{handler:Ri,description:`Set Content API access level`}}}),Hi=j({name:`prismic slice add-variation`,description:`
399
405
  Add a variation to a slice.
400
406
 
401
407
  Run \`prismic docs view slices#slice-variations\` for details.
402
- `,positionals:{name:{description:`Name of the variation`,required:!0}},options:{to:{type:`string`,required:!0,description:`ID of the slice`},id:{type:`string`,description:`Custom ID for the variation`},screenshot:{type:`string`,short:`s`,description:`Screenshot image file path or URL`}}},async({positionals:e,values:t})=>{let[n]=e,{to:r,id:i=$e(n),screenshot:a}=t,o=await P(),{model:s}=await o.getSlice(r);if(s.variations.some(e=>e.id===i))throw new L(`Variation "${i}" already exists in slice "${r}".`);let c=``;if(a){let e=await O(),t=await h(),n=/^https?:\/\//i.test(a)?new URL(a):tn(a),r=await qt(n);c=(await ve(r,{sliceId:s.id,variationId:i,repo:e,getToken:C,host:t,onUnauthorized:x})).toString()}s.variations.push({id:i,name:n,description:n,docURL:``,imageUrl:c,version:``,primary:{}}),await o.updateSlice(s),await o.generateTypes(),console.info(`Added variation "${n}" (id: "${i}") to slice "${r}"`)}),Vi=S({name:`prismic slice connect`,description:`Connect a slice to a type's slice zone.`,sections:{EXAMPLES:`
408
+ `,positionals:{name:{description:`Name of the variation`,required:!0}},options:{to:{type:`string`,required:!0,description:`ID of the slice`},id:{type:`string`,description:`Custom ID for the variation`},screenshot:{type:`string`,short:`s`,description:`Screenshot image file path or URL`}}},async({positionals:e,values:t})=>{let[n]=e,{to:r,id:i=He(n),screenshot:a}=t,o=await P(),{model:s}=await o.getSlice(r);if(s.variations.some(e=>e.id===i))throw new S(`Variation "${i}" already exists in slice "${r}".`);let c=``;if(a){let e=await O(),t=await g(),n=/^https?:\/\//i.test(a)?new URL(a):rn(a),r=await Jt(n);c=(await _(r,{sliceId:s.id,variationId:i,repo:e,getToken:C,host:t,onUnauthorized:x})).toString()}s.variations.push({id:i,name:n,description:n,docURL:``,imageUrl:c,version:``,primary:{}}),await o.updateSlice(s),await o.generateTypes(),console.info(`Added variation "${n}" (id: "${i}") to slice "${r}"`)}),Ui=j({name:`prismic slice connect`,description:`Connect a slice to a type's slice zone.`,sections:{EXAMPLES:`
403
409
  Connect a slice to a type's default slice zone:
404
410
  prismic slice connect hero --to blog_post
405
411
 
406
412
  Connect to a named slice zone:
407
413
  prismic slice connect hero --to blog_post --slice-zone page_slices
408
- `},positionals:{id:{description:`ID of the slice`,required:!0}},options:{to:{type:`string`,required:!0,description:`ID of the content type`},"slice-zone":{type:`string`,description:`Slice zone field ID (default: "slices")`}}},async({positionals:e,values:t})=>{let[n]=e,{to:r,"slice-zone":i=`slices`}=t,a=await P(),{model:o}=await a.getSlice(n),{model:s}=await a.getCustomType(r),c=Object.assign({},...Object.values(s.json)),l=c[i];if(!l||l.type!==`Slices`){let e=Object.keys(c).filter(e=>c[e].type===`Slices`);if(e.length===0){let[e=`Main`]=Object.keys(s.json);throw new L(`"${r}" has no slice zone. Add one with \`prismic type edit-tab "${e}" --from-type ${r} --with-slice-zone\`, then run this command again.`)}throw new L(`Slice zone "${i}" not found in "${r}". Use --slice-zone with one of: ${e.join(`, `)}.`)}if(l.config??={},l.config.choices??={},o.id in l.config.choices)throw new L(`Slice "${o.id}" is already connected to "${r}" in slice zone "${i}".`);l.config.choices[o.id]={type:`SharedSlice`},await a.updateCustomType(s),await a.generateTypes(),console.info(`Connected slice "${n}" to "${r}"`)}),Hi=S({name:`prismic slice create`,description:`Create a new slice.`,positionals:{name:{description:`Name of the slice`,required:!0}},options:{id:{type:`string`,description:`Custom ID for the slice`}}},async({positionals:e,values:t})=>{let[n]=e,{id:r=we(n)}=t,i={id:r,name:n,type:`SharedSlice`,variations:[{id:`default`,name:`Default`,description:`Default`,docURL:``,imageUrl:``,version:``,primary:{}}]},a=await P();await a.createSlice(i),await a.generateTypes(),console.info(`Created slice "${n}" (id: "${r}")`),console.info(`Run \`prismic field add <type> --to-slice ${r}\` to add fields.`),console.info(`Run \`prismic slice connect ${r} --to <type>\` to connect the slice to a type.`)}),Ui=S({name:`prismic slice disconnect`,description:`Disconnect a slice from a type's slice zone.`,positionals:{id:{description:`ID of the slice`,required:!0}},options:{from:{type:`string`,required:!0,description:`ID of the content type`},"slice-zone":{type:`string`,description:`Slice zone field ID (default: "slices")`}}},async({positionals:e,values:t})=>{let[n]=e,{from:r,"slice-zone":i=`slices`}=t,a=await P(),{model:o}=await a.getSlice(n),{model:s}=await a.getCustomType(r),c=Object.assign({},...Object.values(s.json)),l=c[i];if(!l||l.type!==`Slices`){let e=Object.keys(c).filter(e=>c[e].type===`Slices`);throw e.length===0?new L(`"${r}" has no slice zone, so no slice is connected to it.`):new L(`Slice zone "${i}" not found in "${r}". Use --slice-zone with one of: ${e.join(`, `)}.`)}if(!l.config?.choices||!(o.id in l.config.choices))throw new L(`Slice "${o.id}" is not connected to "${r}" in slice zone "${i}".`);delete l.config.choices[o.id],await a.updateCustomType(s),await a.generateTypes(),console.info(`Disconnected slice "${n}" from "${r}"`)}),Wi=S({name:`prismic slice edit`,description:`Edit a slice.`,positionals:{id:{description:`ID of the slice`,required:!0}},options:{name:{type:`string`,short:`n`,description:`New name for the slice`}}},async({positionals:e,values:t})=>{let[n]=e,r=await P(),{model:i}=await r.getSlice(n);`name`in t&&(i.name=t.name),await r.updateSlice(i),await r.generateTypes(),console.info(`Slice updated: "${i.name}" (id: ${i.id})`)}),Gi=S({name:`prismic slice edit-variation`,description:`Edit a variation of a slice.`,positionals:{id:{description:`ID of the variation`,required:!0}},options:{"from-slice":{type:`string`,required:!0,description:`ID of the slice`},name:{type:`string`,short:`n`,description:`New name for the variation`},screenshot:{type:`string`,short:`s`,description:`Screenshot image file path or URL`}}},async({positionals:e,values:t})=>{let[n]=e,{"from-slice":r,screenshot:i}=t,a=await P(),{model:o}=await a.getSlice(r),s=o.variations.find(e=>e.id===n);if(!s)throw new L(`Variation "${n}" not found in slice "${r}".`);if(`name`in t&&(s.name=t.name),i){let e=await O(),t=await h(),n=/^https?:\/\//i.test(i)?new URL(i):tn(i),r=await qt(n);s.imageUrl=(await ve(r,{sliceId:o.id,variationId:s.id,repo:e,getToken:C,host:t,onUnauthorized:x})).toString()}await a.updateSlice(o),await a.generateTypes(),console.info(`Variation updated: "${n}" in slice "${r}"`)}),Ki=S({name:`prismic slice list`,description:`
414
+ `},positionals:{id:{description:`ID of the slice`,required:!0}},options:{to:{type:`string`,required:!0,description:`ID of the content type`},"slice-zone":{type:`string`,description:`Slice zone field ID (default: "slices")`}}},async({positionals:e,values:t})=>{let[n]=e,{to:r,"slice-zone":i=`slices`}=t,a=await P(),{model:o}=await a.getSlice(n),{model:s}=await a.getCustomType(r),c=Object.assign({},...Object.values(s.json)),l=c[i];if(!l||l.type!==`Slices`){let e=Object.keys(c).filter(e=>c[e].type===`Slices`);if(e.length===0){let[e=`Main`]=Object.keys(s.json);throw new S(`"${r}" has no slice zone. Add one with \`prismic type edit-tab "${e}" --from-type ${r} --with-slice-zone\`, then run this command again.`)}throw new S(`Slice zone "${i}" not found in "${r}". Use --slice-zone with one of: ${e.join(`, `)}.`)}if(l.config??={},l.config.choices??={},o.id in l.config.choices)throw new S(`Slice "${o.id}" is already connected to "${r}" in slice zone "${i}".`);l.config.choices[o.id]={type:`SharedSlice`},await a.updateCustomType(s),await a.generateTypes(),console.info(`Connected slice "${n}" to "${r}"`)}),Wi=j({name:`prismic slice create`,description:`Create a new slice.`,positionals:{name:{description:`Name of the slice`,required:!0}},options:{id:{type:`string`,description:`Custom ID for the slice`}}},async({positionals:e,values:t})=>{let[n]=e,{id:r=yt(n)}=t,i={id:r,name:n,type:`SharedSlice`,variations:[{id:`default`,name:`Default`,description:`Default`,docURL:``,imageUrl:``,version:``,primary:{}}]},a=await P();await a.createSlice(i),await a.generateTypes(),console.info(`Created slice "${n}" (id: "${r}")`),console.info(`Run \`prismic field add <type> --to-slice ${r}\` to add fields.`),console.info(`Run \`prismic slice connect ${r} --to <type>\` to connect the slice to a type.`)}),Gi=j({name:`prismic slice disconnect`,description:`Disconnect a slice from a type's slice zone.`,positionals:{id:{description:`ID of the slice`,required:!0}},options:{from:{type:`string`,required:!0,description:`ID of the content type`},"slice-zone":{type:`string`,description:`Slice zone field ID (default: "slices")`}}},async({positionals:e,values:t})=>{let[n]=e,{from:r,"slice-zone":i=`slices`}=t,a=await P(),{model:o}=await a.getSlice(n),{model:s}=await a.getCustomType(r),c=Object.assign({},...Object.values(s.json)),l=c[i];if(!l||l.type!==`Slices`){let e=Object.keys(c).filter(e=>c[e].type===`Slices`);throw e.length===0?new S(`"${r}" has no slice zone, so no slice is connected to it.`):new S(`Slice zone "${i}" not found in "${r}". Use --slice-zone with one of: ${e.join(`, `)}.`)}if(!l.config?.choices||!(o.id in l.config.choices))throw new S(`Slice "${o.id}" is not connected to "${r}" in slice zone "${i}".`);delete l.config.choices[o.id],await a.updateCustomType(s),await a.generateTypes(),console.info(`Disconnected slice "${n}" from "${r}"`)}),Ki=j({name:`prismic slice edit`,description:`Edit a slice.`,positionals:{id:{description:`ID of the slice`,required:!0}},options:{name:{type:`string`,short:`n`,description:`New name for the slice`}}},async({positionals:e,values:t})=>{let[n]=e,r=await P(),{model:i}=await r.getSlice(n);`name`in t&&(i.name=t.name),await r.updateSlice(i),await r.generateTypes(),console.info(`Slice updated: "${i.name}" (id: ${i.id})`)}),qi=j({name:`prismic slice edit-variation`,description:`Edit a variation of a slice.`,positionals:{id:{description:`ID of the variation`,required:!0}},options:{"from-slice":{type:`string`,required:!0,description:`ID of the slice`},name:{type:`string`,short:`n`,description:`New name for the variation`},screenshot:{type:`string`,short:`s`,description:`Screenshot image file path or URL`}}},async({positionals:e,values:t})=>{let[n]=e,{"from-slice":r,screenshot:i}=t,a=await P(),{model:o}=await a.getSlice(r),s=o.variations.find(e=>e.id===n);if(!s)throw new S(`Variation "${n}" not found in slice "${r}".`);if(`name`in t&&(s.name=t.name),i){let e=await O(),t=await g(),n=/^https?:\/\//i.test(i)?new URL(i):rn(i),r=await Jt(n);s.imageUrl=(await _(r,{sliceId:o.id,variationId:s.id,repo:e,getToken:C,host:t,onUnauthorized:x})).toString()}await a.updateSlice(o),await a.generateTypes(),console.info(`Variation updated: "${n}" in slice "${r}"`)}),Ji=j({name:`prismic slice list`,description:`
409
415
  List all slices.
410
416
 
411
417
  Legacy slices from the Legacy Builder are marked with * and show the type
412
418
  that defines them.
413
- `,options:{legacy:{type:`boolean`,description:`List only legacy slices`},json:{type:`boolean`,description:`Output as JSON`}}},async({values:e})=>{let{legacy:t,json:n}=e,r=await P(),i=t?[]:(await r.getSlices()).map(e=>e.model),a=(await r.getCustomTypes()).map(e=>e.model),o=w(a);if(n&&t){let e=o.map(e=>({id:e.id,definedIn:e.customTypeId,sliceZone:e.sliceZoneId}));console.info(W(e));return}if(n){console.info(W(i));return}if(i.length===0&&o.length===0){console.info(t?`No legacy slices found.`:`No slices found.`);return}let s=[...i.map(e=>[e.name,e.id,``]),...o.map(({id:e,model:t,customTypeId:n,sliceZoneId:r})=>[`${(`fieldset`in t?t.fieldset:t.config?.label)||e} *`,e,r===`body`?n:`${n} (${r} slice zone)`])];console.info(M(s,{headers:[`NAME`,`ID`,`DEFINED IN`]})),o.length>0&&console.info("\n* Legacy slice. Run `prismic slice upgrade-legacy --help` to upgrade it.")}),qi=S({name:`prismic slice remove`,description:`Remove a slice.`,positionals:{id:{description:`ID of the slice`,required:!0}}},async({positionals:e})=>{let[t]=e,n=await P();await n.deleteSlice(t),await n.generateTypes(),console.info(`Slice removed: ${t}`)}),Ji=S({name:`prismic slice remove-variation`,description:`Remove a variation from a slice.`,positionals:{id:{description:`ID of the variation`,required:!0}},options:{from:{type:`string`,required:!0,description:`ID of the slice`}}},async({positionals:e,values:t})=>{let[n]=e,{from:r}=t,i=await P(),{model:a}=await i.getSlice(r),o=a.variations.find(e=>e.id===n);if(!o)throw new L(`Variation "${n}" not found in slice "${r}".`);a.variations=a.variations.filter(e=>e.id!==o.id),await i.updateSlice(a),await i.generateTypes(),console.info(`Removed variation "${n}" from slice "${r}"`)}),Yi=S({name:`prismic slice upgrade-legacy`,description:`
419
+ `,options:{legacy:{type:`boolean`,description:`List only legacy slices`},json:{type:`boolean`,description:`Output as JSON`}}},async({values:e})=>{let{legacy:t,json:n}=e,r=await P(),i=t?[]:(await r.getSlices()).map(e=>e.model),a=(await r.getCustomTypes()).map(e=>e.model),o=te(a);if(n&&t){let e=o.map(e=>({id:e.id,definedIn:e.customTypeId,sliceZone:e.sliceZoneId}));console.info(G(e));return}if(n){console.info(G(i));return}if(i.length===0&&o.length===0){console.info(t?`No legacy slices found.`:`No slices found.`);return}let s=[...i.map(e=>[e.name,e.id,``]),...o.map(({id:e,model:t,customTypeId:n,sliceZoneId:r})=>[`${(`fieldset`in t?t.fieldset:t.config?.label)||e} *`,e,r===`body`?n:`${n} (${r} slice zone)`])];console.info(L(s,{headers:[`NAME`,`ID`,`DEFINED IN`]})),o.length>0&&console.info("\n* Legacy slice. Run `prismic slice upgrade-legacy --help` to upgrade it.")}),Yi=j({name:`prismic slice remove`,description:`Remove a slice.`,positionals:{id:{description:`ID of the slice`,required:!0}}},async({positionals:e})=>{let[t]=e,n=await P();await n.deleteSlice(t),await n.generateTypes(),console.info(`Slice removed: ${t}`)}),Xi=j({name:`prismic slice remove-variation`,description:`Remove a variation from a slice.`,positionals:{id:{description:`ID of the variation`,required:!0}},options:{from:{type:`string`,required:!0,description:`ID of the slice`}}},async({positionals:e,values:t})=>{let[n]=e,{from:r}=t,i=await P(),{model:a}=await i.getSlice(r),o=a.variations.find(e=>e.id===n);if(!o)throw new S(`Variation "${n}" not found in slice "${r}".`);a.variations=a.variations.filter(e=>e.id!==o.id),await i.updateSlice(a),await i.generateTypes(),console.info(`Removed variation "${n}" from slice "${r}"`)}),Zi=j({name:`prismic slice upgrade-legacy`,description:`
414
420
  Upgrade a legacy slice from the Legacy Builder.
415
421
 
416
422
  The CLI and the Type Builder cannot edit legacy slices. Run
@@ -437,47 +443,47 @@ Please try again, or manually delete any associated pages at: `+t)}if(a!==0)retu
437
443
 
438
444
  Merge a legacy slice into an existing variation with the same fields:
439
445
  prismic slice upgrade-legacy hero --from landing_page --to hero --variation default
440
- `},positionals:{id:{description:`ID of the legacy slice`,required:!0}},options:{from:{type:`string`,required:!0,description:`ID of the type that contains the legacy slice`},"slice-zone":{type:`string`,description:`Slice zone field ID (default: "body")`},to:{type:`string`,description:`ID of the slice to upgrade to, created if missing (default: the legacy slice ID)`},variation:{type:`string`,description:`Variation to create, or to merge into if it has the same fields (default: "default" for a new slice, the legacy slice ID otherwise)`}}},async({positionals:e,values:t})=>{let[n]=e,{from:r,"slice-zone":i=`body`,to:a,variation:o}=t,s=await P(),c=(await s.getCustomTypes()).map(e=>e.model),l=(await s.getSlices()).map(e=>e.model),u=w(c),d=c.find(e=>e.id===r);if(!d)throw new L(`Type "${r}" not found.`);let f=u.find(e=>e.customTypeId===r&&e.sliceZoneId===i&&e.id===n);if(!f)throw new L(`Legacy slice "${n}" not found in the "${i}" slice zone of "${r}". Use --slice-zone to choose the slice zone.`);let p=`${r}::${i}::${n}`,m=a??we(n),h=f.sliceZone.config?.choices?.[m];if(m!==n&&h&&h.type!==`SharedSlice`)throw new L(`The "${i}" slice zone of "${r}" also has legacy slice "${m}". Upgrade it first.`);let g=l.find(e=>e.id===m),_=$e(o??(g?n:`default`)),v=Qi(f,_),y;if(g){if(!a)throw new L(Xi(g,f,v));let e=g.variations.find(e=>e.id===_);if(e&&!$i(e,v))throw new L(`Variation "${_}" of slice "${m}" has different fields than legacy slice "${n}". Use another ID with --variation.`);e?y=`Merged legacy slice "${n}" into variation "${_}" of slice "${m}"`:(g.variations.push(v),y=`Added legacy slice "${n}" to slice "${m}" as variation "${_}"`),g.legacyPaths={...g.legacyPaths,[p]:_},await s.updateSlice(g)}else{let{model:e}=f,t=`fieldset`in e?e.fieldset:void 0;g={id:m,type:`SharedSlice`,name:ze(a??t??m),legacyPaths:{[p]:_},variations:[v]},y=`Upgraded legacy slice "${n}" to slice "${m}"`,await s.createSlice(g)}ea(f,g.id),await s.updateCustomType(d),await s.generateTypes();let{directory:b}=await s.getSlice(g.id),x=B(await R(),b),S=u.length-1;console.info(y),console.info(`After \`prismic push\`: ${Zi(f,m,_)}`),console.info(`Update the component in ${x}, then deploy it with \`prismic push\`. Documents use the new shape after the next publish.`),S>0&&console.info(`\n${S} legacy ${S===1?`slice remains`:`slices remain`}. Run \`prismic slice list --legacy\` to list them.`)});function Xi(e,t,n){let{id:r,customTypeId:i,sliceZoneId:a}=t,o=`prismic slice upgrade-legacy ${r} --from ${i}${a===`body`?``:` --slice-zone ${a}`}`,s=e.variations.find(e=>$i(e,n));return[`Slice "${e.id}" already exists. How do you want to upgrade legacy slice "${r}" of "${i}"? This changes how editors pick slices, so the project's owner should choose:`,` Add it to slice "${e.id}" as a new variation: ${o} --to ${e.id}`,...s?[` Merge it into variation "${s.id}", which has the same fields: ${o} --to ${e.id} --variation ${s.id}`]:[],` Upgrade it to a separate slice: ${o} --to <new-slice-id>`].join(`
441
- `)}function Zi(e,t,n){let{model:r,id:i}=e,a=[];return(t!==i||n!=="default")&&a.push(`\`slice_type\` becomes "${t}" and \`variation\` becomes "${n}".`),r.type===`Group`?a.push("`slice.value` moves to `slice.items`."):r.type!==`Slice`&&a.push(`\`slice.value\` moves to \`slice.primary.${i}\`.`),a.join(` `)||"`slice.primary` and `slice.items` keep their shape."}function Qi(e,t){let{model:n}=e,r=t==="default"?`Default`:ze(t),i={id:t,name:r,description:r,docURL:``,imageUrl:``,version:`initial`,primary:{},items:{}};switch(n.type){case`Slice`:i.primary=n[`non-repeat`]??{},i.items=n.repeat??{};break;case`Group`:i.items=n.config?.fields??{};break;default:i.primary={[e.id]:n}}return i}function $i(e,t){return Xt(e.primary??{},t.primary??{})&&Xt(e.items??{},t.items??{})}function ea({id:e,sliceZone:t},n){t.config.choices=Object.fromEntries(Object.entries(t.config.choices).filter(([t])=>t===e||t!==n).map(([t,r])=>t===e?[n,{type:`SharedSlice`}]:[t,r]))}var ta=S({name:`prismic slice view`,description:`View details of a slice.`,positionals:{id:{description:`ID of the slice`,required:!0}},options:{json:{type:`boolean`,description:`Output as JSON`}}},async({positionals:e,values:t})=>{let[n]=e,{json:r}=t,{model:i}=await(await P()).getSlice(n);if(r)console.info(W(i));else{console.info(`ID: ${i.id}`),console.info(`Name: ${i.name}`);for(let e of i.variations??[])console.info(``),console.info(`${e.id}:`),console.info(tr(e.primary??{})),e.items&&Object.keys(e.items).length>0&&(console.info(``),console.info(`${e.id} (legacy items zone):`),console.info(tr(e.items)))}}),na=A({name:`prismic slice`,description:`
446
+ `},positionals:{id:{description:`ID of the legacy slice`,required:!0}},options:{from:{type:`string`,required:!0,description:`ID of the type that contains the legacy slice`},"slice-zone":{type:`string`,description:`Slice zone field ID (default: "body")`},to:{type:`string`,description:`ID of the slice to upgrade to, created if missing (default: the legacy slice ID)`},variation:{type:`string`,description:`Variation to create, or to merge into if it has the same fields (default: "default" for a new slice, the legacy slice ID otherwise)`}}},async({positionals:e,values:t})=>{let[n]=e,{from:r,"slice-zone":i=`body`,to:a,variation:o}=t,s=await P(),c=(await s.getCustomTypes()).map(e=>e.model),l=(await s.getSlices()).map(e=>e.model),u=te(c),d=c.find(e=>e.id===r);if(!d)throw new S(`Type "${r}" not found.`);let f=u.find(e=>e.customTypeId===r&&e.sliceZoneId===i&&e.id===n);if(!f)throw new S(`Legacy slice "${n}" not found in the "${i}" slice zone of "${r}". Use --slice-zone to choose the slice zone.`);let p=`${r}::${i}::${n}`,m=a??yt(n),h=f.sliceZone.config?.choices?.[m];if(m!==n&&h&&h.type!==`SharedSlice`)throw new S(`The "${i}" slice zone of "${r}" also has legacy slice "${m}". Upgrade it first.`);let g=l.find(e=>e.id===m),_=He(o??(g?n:`default`)),v=ea(f,_),y;if(g){if(!a)throw new S(Qi(g,f,v));let e=g.variations.find(e=>e.id===_);if(e&&!ta(e,v))throw new S(`Variation "${_}" of slice "${m}" has different fields than legacy slice "${n}". Use another ID with --variation.`);e?y=`Merged legacy slice "${n}" into variation "${_}" of slice "${m}"`:(g.variations.push(v),y=`Added legacy slice "${n}" to slice "${m}" as variation "${_}"`),g.legacyPaths={...g.legacyPaths,[p]:_},await s.updateSlice(g)}else{let{model:e}=f,t=`fieldset`in e?e.fieldset:void 0;g={id:m,type:`SharedSlice`,name:we(a??t??m),legacyPaths:{[p]:_},variations:[v]},y=`Upgraded legacy slice "${n}" to slice "${m}"`,await s.createSlice(g)}na(f,g.id),await s.updateCustomType(d),await s.generateTypes();let{directory:b}=await s.getSlice(g.id),ee=H(await R(),b),x=u.length-1;console.info(y),console.info(`After \`prismic push\`: ${$i(f,m,_)}`),console.info(`Update the component in ${ee}, then deploy it with \`prismic push\`. Documents use the new shape after the next publish.`),x>0&&console.info(`\n${x} legacy ${x===1?`slice remains`:`slices remain`}. Run \`prismic slice list --legacy\` to list them.`)});function Qi(e,t,n){let{id:r,customTypeId:i,sliceZoneId:a}=t,o=`prismic slice upgrade-legacy ${r} --from ${i}${a===`body`?``:` --slice-zone ${a}`}`,s=e.variations.find(e=>ta(e,n));return[`Slice "${e.id}" already exists. How do you want to upgrade legacy slice "${r}" of "${i}"? This changes how editors pick slices, so the project's owner should choose:`,` Add it to slice "${e.id}" as a new variation: ${o} --to ${e.id}`,...s?[` Merge it into variation "${s.id}", which has the same fields: ${o} --to ${e.id} --variation ${s.id}`]:[],` Upgrade it to a separate slice: ${o} --to <new-slice-id>`].join(`
447
+ `)}function $i(e,t,n){let{model:r,id:i}=e,a=[];return(t!==i||n!=="default")&&a.push(`\`slice_type\` becomes "${t}" and \`variation\` becomes "${n}".`),r.type===`Group`?a.push("`slice.value` moves to `slice.items`."):r.type!==`Slice`&&a.push(`\`slice.value\` moves to \`slice.primary.${i}\`.`),a.join(` `)||"`slice.primary` and `slice.items` keep their shape."}function ea(e,t){let{model:n}=e,r=t==="default"?`Default`:we(t),i={id:t,name:r,description:r,docURL:``,imageUrl:``,version:`initial`,primary:{},items:{}};switch(n.type){case`Slice`:i.primary=n[`non-repeat`]??{},i.items=n.repeat??{};break;case`Group`:i.items=n.config?.fields??{};break;default:i.primary={[e.id]:n}}return i}function ta(e,t){return Qt(e.primary??{},t.primary??{})&&Qt(e.items??{},t.items??{})}function na({id:e,sliceZone:t},n){t.config.choices=Object.fromEntries(Object.entries(t.config.choices).filter(([t])=>t===e||t!==n).map(([t,r])=>t===e?[n,{type:`SharedSlice`}]:[t,r]))}var ra=j({name:`prismic slice view`,description:`View details of a slice.`,positionals:{id:{description:`ID of the slice`,required:!0}},options:{json:{type:`boolean`,description:`Output as JSON`}}},async({positionals:e,values:t})=>{let[n]=e,{json:r}=t,{model:i}=await(await P()).getSlice(n);if(r)console.info(G(i));else{console.info(`ID: ${i.id}`),console.info(`Name: ${i.name}`);for(let e of i.variations??[])console.info(``),console.info(`${e.id}:`),console.info(rr(e.primary??{})),e.items&&Object.keys(e.items).length>0&&(console.info(``),console.info(`${e.id} (legacy items zone):`),console.info(rr(e.items)))}}),ia=A({name:`prismic slice`,description:`
442
448
  Manage slices.
443
449
 
444
450
  Run \`prismic docs view slices\` for details.
445
- `,commands:{create:{handler:Hi,description:`Create a new slice`},edit:{handler:Wi,description:`Edit a slice`},remove:{handler:qi,description:`Remove a slice`},list:{handler:Ki,description:`List slices`},view:{handler:ta,description:`View a slice`},connect:{handler:Vi,description:`Connect a slice to a type's slice zone`},disconnect:{handler:Ui,description:`Disconnect a slice from a type's slice zone`},"upgrade-legacy":{handler:Yi,description:`Upgrade a legacy slice`},"add-variation":{handler:Bi,description:`Add a variation to a slice`},"edit-variation":{handler:Gi,description:`Edit a variation of a slice`},"remove-variation":{handler:Ji,description:`Remove a variation from a slice`}}}),ra=S({name:`prismic status`,description:`
451
+ `,commands:{create:{handler:Wi,description:`Create a new slice`},edit:{handler:Ki,description:`Edit a slice`},remove:{handler:Yi,description:`Remove a slice`},list:{handler:Ji,description:`List slices`},view:{handler:ra,description:`View a slice`},connect:{handler:Ui,description:`Connect a slice to a type's slice zone`},disconnect:{handler:Gi,description:`Disconnect a slice from a type's slice zone`},"upgrade-legacy":{handler:Zi,description:`Upgrade a legacy slice`},"add-variation":{handler:Hi,description:`Add a variation to a slice`},"edit-variation":{handler:qi,description:`Edit a variation of a slice`},"remove-variation":{handler:Xi,description:`Remove a variation from a slice`}}}),aa=j({name:`prismic status`,description:`
446
452
  Show local vs remote model differences.
447
453
 
448
454
  Reports what would be pushed to or pulled from Prismic, plus any local
449
455
  model files with uncommitted git changes that must be committed before
450
456
  pull and push.
451
- `,options:{repo:{type:`string`,short:`r`,description:`Repository or environment domain`},env:{type:`string`,short:`e`,description:`Alias for --repo`,deprecated:"Use `prismic env` or --repo instead."}}},async({values:e})=>{let t=await P(),n=await O(),r=await t.getEnvironment(),{env:i,repo:a=i??r??n}=e,o=await h(),s=await C(),c=await R(),[l,u,d,f]=await Promise.all([Ti(c),t.getCustomTypeLibraries(),t.getSliceLibraries(),t.getModels()]),p,m;if(s){let[e,t]=await Promise.all([ee(s,{host:o}),D({repo:a,getToken:C,host:o})]);p=e.type===`USER`?e.email:`${e.appName} (Write API token for ${e.domain})`,m=y(f,t)}let g=[];l&&(g=(await Ei(l)).filter(e=>e.pathname.endsWith(`/model.json`)&&d.some(t=>z(t,e))||e.pathname.endsWith(`/index.json`)&&u.some(t=>z(t,e))).map(e=>B(c,e))),console.info(`Repository: ${n}`),a!==n&&console.info(`Environment: ${a}`),console.info(p?`Authenticated as: ${p}`:"Not logged in — log in with `prismic login` to compare with remote.");let _=w(f.customTypes).length;_>0&&console.info(`\n${_} legacy ${_===1?`slice needs`:`slices need`} upgrading. Run \`prismic slice list --legacy\`.`);let v=m!==void 0&&!k(m.customTypes)&&!k(m.slices);if(v&&g.length===0){console.info(``),console.info(`Already up to date.`);return}if(m){let e=[],t=[...m.customTypes.insert.map(e=>` ${e.id} (custom type)`),...m.slices.insert.map(e=>` ${e.id} (slice)`)];t.length>0&&e.push([`Local-only:`,...t]);let n=[...m.customTypes.delete.map(e=>` ${e.id} (custom type)`),...m.slices.delete.map(e=>` ${e.id} (slice)`)];n.length>0&&e.push([`Remote-only:`,...n]);let r=[...m.customTypes.update.map(e=>` ${e.id} (custom type)`),...m.slices.update.map(e=>` ${e.id} (slice)`)];r.length>0&&e.push([`Differ:`,...r]);for(let t of e){console.info(``);for(let e of t)console.info(e)}}let b=[];if(g.length>0&&(console.info(``),console.info(`Prismic keeps model history in git. Commit model changes before you push or pull them.`),b.push(`git add ${g.join(` `)}`),b.push(`git commit -m "Update Prismic models"`)),m&&!v){let e=m.customTypes.insert.length+m.slices.insert.length,t=m.customTypes.update.length+m.slices.update.length,n=m.customTypes.delete.length+m.slices.delete.length;b.push(`prismic push # creates ${e}, updates ${t}, deletes ${n}`),b.push(`prismic pull # creates ${n}, updates ${t}, deletes ${e}`)}if(b.length>0){console.info(``),console.info(`Next:`);for(let e of b)console.info(` ${e}`)}});const ia=I.PRISMIC_SYNC_POLL_MS??5e3;var aa=S({name:`prismic sync`,description:`
457
+ `,options:{repo:{type:`string`,short:`r`,description:`Repository or environment domain`},env:{type:`string`,short:`e`,description:`Alias for --repo`,deprecated:"Use `prismic env` or --repo instead."}}},async({values:e})=>{let t=await P(),n=await O(),r=await t.getEnvironment(),{env:i,repo:a=i??r??n}=e,o=await g(),s=await C(),c=await R(),[l,u,d,f]=await Promise.all([Di(c),t.getCustomTypeLibraries(),t.getSliceLibraries(),t.getModels()]),p,m;if(s){let[e,t]=await Promise.all([ut(s,{host:o}),E({repo:a,getToken:C,host:o})]);p=e.type===`USER`?e.email:`${e.appName} (Write API token for ${e.domain})`,m=b(f,t)}let h=[];l&&(h=(await Oi(l)).filter(e=>e.pathname.endsWith(`/model.json`)&&d.some(t=>B(t,e))||e.pathname.endsWith(`/index.json`)&&u.some(t=>B(t,e))).map(e=>H(c,e))),console.info(`Repository: ${n}`),a!==n&&console.info(`Environment: ${a}`),console.info(p?`Authenticated as: ${p}`:"Not logged in — log in with `prismic login` to compare with remote.");let _=te(f.customTypes).length;_>0&&console.info(`\n${_} legacy ${_===1?`slice needs`:`slices need`} upgrading. Run \`prismic slice list --legacy\`.`);let v=m!==void 0&&!k(m.customTypes)&&!k(m.slices);if(v&&h.length===0){console.info(``),console.info(`Already up to date.`);return}if(m){let e=[],t=[...m.customTypes.insert.map(e=>` ${e.id} (custom type)`),...m.slices.insert.map(e=>` ${e.id} (slice)`)];t.length>0&&e.push([`Local-only:`,...t]);let n=[...m.customTypes.delete.map(e=>` ${e.id} (custom type)`),...m.slices.delete.map(e=>` ${e.id} (slice)`)];n.length>0&&e.push([`Remote-only:`,...n]);let r=[...m.customTypes.update.map(e=>` ${e.id} (custom type)`),...m.slices.update.map(e=>` ${e.id} (slice)`)];r.length>0&&e.push([`Differ:`,...r]);for(let t of e){console.info(``);for(let e of t)console.info(e)}}let y=[];if(h.length>0&&(console.info(``),console.info(`Prismic keeps model history in git. Commit model changes before you push or pull them.`),y.push(`git add ${h.join(` `)}`),y.push(`git commit -m "Update Prismic models"`)),m&&!v){let e=m.customTypes.insert.length+m.slices.insert.length,t=m.customTypes.update.length+m.slices.update.length,n=m.customTypes.delete.length+m.slices.delete.length;y.push(`prismic push # creates ${e}, updates ${t}, deletes ${n}`),y.push(`prismic pull # creates ${n}, updates ${t}, deletes ${e}`)}if(y.length>0){console.info(``),console.info(`Next:`);for(let e of y)console.info(` ${e}`)}});const oa=F.PRISMIC_SYNC_POLL_MS??5e3;var sa=j({name:`prismic sync`,description:`
452
458
  Watch Prismic and continuously pull changes to local files.
453
459
 
454
460
  For one-time pulls, use \`prismic pull\`.
455
- `,options:{watch:{type:`boolean`,short:`w`,description:`Watch for changes and sync continuously`,required:!0},repo:{type:`string`,short:`r`,description:`Repository or environment domain`},env:{type:`string`,short:`e`,description:`Alias for --repo`,deprecated:"Use `prismic env` or --repo instead."}}},async({values:e})=>{let t=await P(),{env:n,repo:r=n??await t.getEnvironment()??await O()}=e,i=await h();dt(`sync`,{watch:!0}),process.on(`SIGINT`,()=>{console.info(`
456
- Watch stopped. Goodbye!`),rt(),process.exit(0)}),console.info(`Watching repository: ${r} (polling every ${ia/1e3}s, Ctrl+C to stop)`);let a,o=0;for(;;){try{let e=await D({repo:r,getToken:C,host:i,onUnauthorized:x}),n=a&&y(e,a);if(!n||k(n.customTypes)||k(n.slices)){let r=!n,o=y(e,await t.getModels(),{treatNonCanonicalAsChanged:!0});for(let e of await t.writeModels(o))console.info(e);let s=[...k(o.slices)?[`slices`]:[],...k(o.customTypes)?[`custom types`]:[]];if((r||s.length>0)&&await t.generateTypes(),a=e,r)await Z([`connectPrismic`],{repo:await O(),getToken:C,host:i,onUnauthorized:x}).catch(()=>{}),console.info(`Initial sync complete.`);else if(s.length>0){let e=(/* @__PURE__ */ new Date()).toLocaleTimeString();console.info(`[${e}] Changes detected in ${s.join(` and `)}`)}}o=0}catch(e){o++;let t=await ln(e)??`Unknown error`;if(console.error(`Error checking for changes: ${t}`),o>=5)throw new L(`Too many consecutive errors (5), stopping watch.`)}await an(ia)}});const oa=`0123456789abcdefghjkmnpqrstvwxyz`,sa=RegExp(`^pt_[${oa}]{16}$`);function ca(){let e=`pt_`;for(let t of rn(16))e+=oa[t&31];return e}function la(e){return sa.test(e)}var ua=S({name:`prismic task-id`,description:`
461
+ `,options:{watch:{type:`boolean`,short:`w`,description:`Watch for changes and sync continuously`,required:!0},repo:{type:`string`,short:`r`,description:`Repository or environment domain`},env:{type:`string`,short:`e`,description:`Alias for --repo`,deprecated:"Use `prismic env` or --repo instead."}}},async({values:e})=>{let t=await P(),{env:n,repo:r=n??await t.getEnvironment()??await O()}=e,i=await g();ft(`sync`,{watch:!0}),process.on(`SIGINT`,()=>{console.info(`
462
+ Watch stopped. Goodbye!`),rt(),process.exit(0)}),console.info(`Watching repository: ${r} (polling every ${oa/1e3}s, Ctrl+C to stop)`);let a,o=0;for(;;){try{let e=await E({repo:r,getToken:C,host:i,onUnauthorized:x}),n=a&&b(e,a);if(!n||k(n.customTypes)||k(n.slices)){let r=!n,o=b(e,await t.getModels(),{treatNonCanonicalAsChanged:!0});for(let e of await t.writeModels(o))console.info(e);let s=[...k(o.slices)?[`slices`]:[],...k(o.customTypes)?[`custom types`]:[]];if((r||s.length>0)&&await t.generateTypes(),a=e,r)await Z([`connectPrismic`],{repo:await O(),getToken:C,host:i,onUnauthorized:x}).catch(()=>{}),console.info(`Initial sync complete.`);else if(s.length>0){let e=(/* @__PURE__ */ new Date()).toLocaleTimeString();console.info(`[${e}] Changes detected in ${s.join(` and `)}`)}}o=0}catch(e){o++;let t=await dn(e)??`Unknown error`;if(console.error(`Error checking for changes: ${t}`),o>=5)throw new S(`Too many consecutive errors (5), stopping watch.`)}await sn(oa)}});const ca=`0123456789abcdefghjkmnpqrstvwxyz`,la=RegExp(`^pt_[${ca}]{16}$`);function ua(){let e=`pt_`;for(let t of on(16))e+=ca[t&31];return e}function da(e){return la.test(e)}var fa=j({name:`prismic task-id`,description:`
457
463
  Print a task ID for --task-id.
458
464
 
459
465
  One ID covers one user request: pass it on every command for that request,
460
466
  and run this again when the user asks for something else.
461
- `},async()=>{console.info(ca())});const da=`Prismic CLI`;var fa=S({name:`prismic token create`,description:`
467
+ `},async()=>{console.info(ua())});const pa=`Prismic CLI`;var ma=j({name:`prismic token create`,description:`
462
468
  Create a new API token for a Prismic repository.
463
469
 
464
470
  By default, this command reads the repository from prismic.config.json at the
465
471
  project root.
466
- `,options:{write:{type:`boolean`,description:`Create a write token`},"allow-releases":{type:`boolean`,description:`Allow access to releases (read tokens only)`},name:{type:`string`,short:`n`,description:`Name to identify the token (default: "${da}")`},json:{type:`boolean`,description:`Output as JSON`},repo:{type:`string`,short:`r`,description:`Repository or environment domain`},env:{type:`string`,short:`e`,description:`Alias for --repo`,deprecated:"Use `prismic env` or --repo instead."}}},async({values:e})=>{let{env:t,repo:n=t??await j(),write:r,"allow-releases":i,name:a=da,json:o}=e;if(r&&i)throw new L(`--allow-releases is only valid for access tokens (not with --write)`);let s=await h(),c,l;if(r)c=(await et(a,{repo:n,getToken:C,host:s,onUnauthorized:x})).token;else{l=i?`master+releases`:`master`;let e=(await Ye({repo:n,getToken:C,host:s,onUnauthorized:x})).find(e=>e.name===a);e||=await Ze(a,{repo:n,getToken:C,host:s,onUnauthorized:x}),c=(await _t(e.id,l,{repo:n,getToken:C,host:s,onUnauthorized:x})).token}console.info(o?W({token:c,type:r?`write`:`access`,name:a,repository:n,...l?{scope:l}:{}}):`Token created: ${c}`)}),pa=S({name:`prismic token delete`,description:`
472
+ `,options:{write:{type:`boolean`,description:`Create a write token`},"allow-releases":{type:`boolean`,description:`Allow access to releases (read tokens only)`},name:{type:`string`,short:`n`,description:`Name to identify the token (default: "${pa}")`},json:{type:`boolean`,description:`Output as JSON`},repo:{type:`string`,short:`r`,description:`Repository or environment domain`},env:{type:`string`,short:`e`,description:`Alias for --repo`,deprecated:"Use `prismic env` or --repo instead."}}},async({values:e})=>{let{env:t,repo:n=t??await M(),write:r,"allow-releases":i,name:o=pa,json:s}=e;if(r&&i)throw new S(`--allow-releases is only valid for access tokens (not with --write)`);let c=await g(),l,u;if(r)l=(await Ue(o,{repo:n,getToken:C,host:c,onUnauthorized:x})).token;else{u=i?`master+releases`:`master`;let e=(await a({repo:n,getToken:C,host:c,onUnauthorized:x})).find(e=>e.name===o);e||=await _t(o,{repo:n,getToken:C,host:c,onUnauthorized:x}),l=(await Pe(e.id,u,{repo:n,getToken:C,host:c,onUnauthorized:x})).token}console.info(s?G({token:l,type:r?`write`:`access`,name:o,repository:n,...u?{scope:u}:{}}):`Token created: ${l}`)}),ha=j({name:`prismic token delete`,description:`
467
473
  Delete a token from a Prismic repository.
468
474
 
469
475
  By default, this command reads the repository from prismic.config.json at the
470
476
  project root.
471
- `,positionals:{token:{description:`Token value`,required:!0}},options:{repo:{type:`string`,short:`r`,description:`Repository or environment domain`},env:{type:`string`,short:`e`,description:`Alias for --repo`,deprecated:"Use `prismic env` or --repo instead."}}},async({positionals:e,values:t})=>{let[n]=e,{env:r,repo:i=r??await j()}=t,a=await h(),[o,s]=await Promise.all([Ye({repo:i,getToken:C,host:a,onUnauthorized:x}),ue({repo:i,getToken:C,host:a,onUnauthorized:x})]),c=o.flatMap(e=>e.wroom_auths).find(e=>e.token===n);if(c){await Be(c.id,{repo:i,getToken:C,host:a,onUnauthorized:x}),console.info(`Token deleted`);return}let l=s.tokens.find(e=>e.token===n);if(l)await St(l.token,{repo:i,getToken:C,host:a,onUnauthorized:x}),console.info(`Token deleted`);else throw new L(`Token not found: ${n}`)}),ma=S({name:`prismic token list`,description:`
477
+ `,positionals:{token:{description:`Token value`,required:!0}},options:{repo:{type:`string`,short:`r`,description:`Repository or environment domain`},env:{type:`string`,short:`e`,description:`Alias for --repo`,deprecated:"Use `prismic env` or --repo instead."}}},async({positionals:e,values:t})=>{let[n]=e,{env:r,repo:i=r??await M()}=t,o=await g(),[s,c]=await Promise.all([a({repo:i,getToken:C,host:o,onUnauthorized:x}),Dt({repo:i,getToken:C,host:o,onUnauthorized:x})]),l=s.flatMap(e=>e.wroom_auths).find(e=>e.token===n);if(l){await Te(l.id,{repo:i,getToken:C,host:o,onUnauthorized:x}),console.info(`Token deleted`);return}let u=c.tokens.find(e=>e.token===n);if(u)await fe(u.token,{repo:i,getToken:C,host:o,onUnauthorized:x}),console.info(`Token deleted`);else throw new S(`Token not found: ${n}`)}),ga=j({name:`prismic token list`,description:`
472
478
  List all API tokens for a Prismic repository.
473
479
 
474
480
  By default, this command reads the repository from prismic.config.json at the
475
481
  project root.
476
- `,options:{json:{type:`boolean`,description:`Output as JSON`},repo:{type:`string`,short:`r`,description:`Repository or environment domain`},env:{type:`string`,short:`e`,description:`Alias for --repo`,deprecated:"Use `prismic env` or --repo instead."}}},async({values:e})=>{let{env:t,repo:n=t??await j(),json:r}=e,i=await h(),[a,o]=await Promise.all([Ye({repo:n,getToken:C,host:i,onUnauthorized:x}),ue({repo:n,getToken:C,host:i,onUnauthorized:x})]),s=a.flatMap(e=>e.wroom_auths.map(t=>({name:e.name,scope:t.scope,token:t.token,createdAt:new Date(t.created_at.$date).toISOString().split(`T`)[0]}))),c=o.tokens;if(r)console.info(W({accessTokens:s,writeTokens:c}));else{if(s.length>0){console.info(`ACCESS TOKENS`);let e=s.map(e=>[` ${e.name}`,e.scope,e.token,e.createdAt]);console.info(M(e))}else console.info(`ACCESS TOKENS (none)`);if(console.info(``),c.length>0){console.info(`WRITE TOKENS`);let e=c.map(e=>{let t=(/* @__PURE__ */ new Date(e.timestamp*1e3)).toISOString().split(`T`)[0];return[` ${e.app_name}`,e.token,t]});console.info(M(e))}else console.info(`WRITE TOKENS (none)`)}}),ha=A({name:`prismic token`,description:`
482
+ `,options:{json:{type:`boolean`,description:`Output as JSON`},repo:{type:`string`,short:`r`,description:`Repository or environment domain`},env:{type:`string`,short:`e`,description:`Alias for --repo`,deprecated:"Use `prismic env` or --repo instead."}}},async({values:e})=>{let{env:t,repo:n=t??await M(),json:r}=e,i=await g(),[o,s]=await Promise.all([a({repo:n,getToken:C,host:i,onUnauthorized:x}),Dt({repo:n,getToken:C,host:i,onUnauthorized:x})]),c=o.flatMap(e=>e.wroom_auths.map(t=>({name:e.name,scope:t.scope,token:t.token,createdAt:new Date(t.created_at.$date).toISOString().split(`T`)[0]}))),l=s.tokens;if(r)console.info(G({accessTokens:c,writeTokens:l}));else{if(c.length>0){console.info(`ACCESS TOKENS`);let e=c.map(e=>[` ${e.name}`,e.scope,e.token,e.createdAt]);console.info(L(e))}else console.info(`ACCESS TOKENS (none)`);if(console.info(``),l.length>0){console.info(`WRITE TOKENS`);let e=l.map(e=>{let t=(/* @__PURE__ */ new Date(e.timestamp*1e3)).toISOString().split(`T`)[0];return[` ${e.app_name}`,e.token,t]});console.info(L(e))}else console.info(`WRITE TOKENS (none)`)}}),_a=A({name:`prismic token`,description:`
477
483
  Manage API tokens for a Prismic repository.
478
484
 
479
485
  Run \`prismic docs view repository-settings#configuration\` for details.
480
- `,commands:{list:{handler:ma,description:`List all tokens`},create:{handler:fa,description:`Create a new token`},delete:{handler:pa,description:`Delete a token`}}}),ga=S({name:`prismic type add-tab`,description:`Add a tab to a content type.`,positionals:{name:{description:`Name of the tab`,required:!0}},options:{to:{type:`string`,required:!0,description:`ID of the content type`},"with-slice-zone":{type:`boolean`,description:`Add a slice zone to the tab`}}},async({positionals:e,values:t})=>{let[n]=e,{to:r,"with-slice-zone":i}=t,a=await P(),{model:o}=await a.getCustomType(r);if(n in o.json)throw new L(`Tab "${n}" already exists in "${r}".`);o.json[n]=i?{slices:{type:`Slices`,fieldset:`Slice Zone`,config:{choices:{}}}}:{},await a.updateCustomType(o),await a.generateTypes(),console.info(`Added tab "${n}" to "${r}"`)}),_a=S({name:`prismic type create`,description:`Create a new content type.`,positionals:{name:{description:`Name of the content type`,required:!0}},options:{format:{type:`string`,short:`f`,description:`Type format: "custom" (default) or "page"`},single:{type:`boolean`,short:`s`,description:`Allow only one document of this type`},id:{type:`string`,description:`Custom ID for the content type`}},sections:{FORMATS:`
486
+ `,commands:{list:{handler:ga,description:`List all tokens`},create:{handler:ma,description:`Create a new token`},delete:{handler:ha,description:`Delete a token`}}}),va=j({name:`prismic type add-tab`,description:`Add a tab to a content type.`,positionals:{name:{description:`Name of the tab`,required:!0}},options:{to:{type:`string`,required:!0,description:`ID of the content type`},"with-slice-zone":{type:`boolean`,description:`Add a slice zone to the tab`}}},async({positionals:e,values:t})=>{let[n]=e,{to:r,"with-slice-zone":i}=t,a=await P(),{model:o}=await a.getCustomType(r);if(n in o.json)throw new S(`Tab "${n}" already exists in "${r}".`);o.json[n]=i?{slices:{type:`Slices`,fieldset:`Slice Zone`,config:{choices:{}}}}:{},await a.updateCustomType(o),await a.generateTypes(),console.info(`Added tab "${n}" to "${r}"`)}),ya=j({name:`prismic type create`,description:`Create a new content type.`,positionals:{name:{description:`Name of the content type`,required:!0}},options:{format:{type:`string`,short:`f`,description:`Type format: "custom" (default) or "page"`},single:{type:`boolean`,short:`s`,description:`Allow only one document of this type`},id:{type:`string`,description:`Custom ID for the content type`}},sections:{FORMATS:`
481
487
  custom A non-page type (e.g. settings, navigation, author, blog
482
488
  category). This is the default.
483
489
  page A page type with a URL (e.g. homepage, blog post, landing
@@ -492,11 +498,11 @@ Watch stopped. Goodbye!`),rt(),process.exit(0)}),console.info(`Watching reposito
492
498
 
493
499
  Create with a custom ID:
494
500
  prismic type create "Landing Page" --format page --id landing
495
- `}},async({positionals:e,values:t})=>{let[n]=e,{format:r=`custom`,single:i=!1,id:a=we(n)}=t;if(r!==`custom`&&r!==`page`)throw new L(`Invalid format: "${r}". Use "custom" or "page".`);let o=await P();if((await o.getCustomTypes()).some(({model:e})=>e.id===a))throw new L(`Type "${a}" already exists. Run \`prismic type edit ${a}\` to change it.`);let s=r===`page`?{Main:{slices:{type:`Slices`,fieldset:`Slice Zone`,config:{choices:{}}}},"SEO & Metadata":{meta_title:{type:`Text`,config:{label:`Meta Title`,placeholder:`A title of the page used for social media and search engines`}},meta_description:{type:`Text`,config:{label:`Meta Description`,placeholder:`A brief summary of the page`}},meta_image:{type:`Image`,config:{label:`Meta Image`,constraint:{width:2400,height:1260},thumbnails:[]}}}}:{Main:{}};i||(s.Main={uid:{type:`UID`,config:{label:`UID`}},...s.Main});let c={id:a,label:n,repeatable:!i,status:!0,format:r,json:s},l=await o.createCustomType(c);await o.generateTypes(),console.info(`Created type "${n}" (id: "${a}", format: "${r}")`);for(let e of l)console.info(e);console.info(`Run \`prismic field add <type> --to-type ${a}\` to add fields.`),console.info(`Run \`prismic type view ${a}\` to view the type.`)}),va=S({name:`prismic type edit`,description:`Edit a content type.`,positionals:{id:{description:`ID of the content type`,required:!0}},options:{name:{type:`string`,short:`n`,description:`New name for the type`},format:{type:`string`,short:`f`,description:`Type format: "custom" or "page"`}}},async({positionals:e,values:t})=>{let[n]=e;if(`format`in t&&t.format!==`custom`&&t.format!==`page`)throw new L(`Invalid format: "${t.format}". Use "custom" or "page".`);let r=await P(),{model:i}=await r.getCustomType(n);`name`in t&&(i.label=t.name),`format`in t&&(i.format=t.format),await r.updateCustomType(i),await r.generateTypes(),console.info(`Type updated: "${i.label}" (id: ${i.id})`)}),ya=S({name:`prismic type edit-tab`,description:`Edit a tab of a content type.`,positionals:{name:{description:`Current name of the tab`,required:!0}},options:{"from-type":{type:`string`,required:!0,description:`ID of the content type`},name:{type:`string`,short:`n`,description:`New name for the tab`},"with-slice-zone":{type:`boolean`,description:`Add a slice zone to the tab`},"without-slice-zone":{type:`boolean`,description:`Remove the slice zone from the tab`}}},async({positionals:e,values:t})=>{let[n]=e,{"from-type":r}=t,i=await P(),{model:a}=await i.getCustomType(r);if(!(n in a.json))throw new L(`Tab "${n}" not found in "${r}".`);if(`with-slice-zone`in t&&`without-slice-zone`in t)throw new L(`Cannot use --with-slice-zone and --without-slice-zone together.`);if(`with-slice-zone`in t){let e=a.json[n];if(Object.values(e).some(e=>e.type===`Slices`))throw new L(`Tab "${n}" already has a slice zone.`);e.slices={type:`Slices`,fieldset:`Slice Zone`,config:{choices:{}}}}if(`without-slice-zone`in t){let e=a.json[n],t=Object.entries(e).find(([,e])=>e.type===`Slices`);if(!t)throw new L(`Tab "${n}" does not have a slice zone.`);let[r,i]=t,o=i.type===`Slices`?i.config?.choices??{}:{};if(Object.keys(o).length>0)throw new L(`Cannot remove slice zone from "${n}": disconnect all slices first.`);delete e[r]}if(`name`in t){if(t.name in a.json)throw new L(`Tab "${t.name}" already exists in "${r}".`);let e={};for(let[r,i]of Object.entries(a.json))e[r===n?t.name:r]=i;a.json=e}await i.updateCustomType(a),await i.generateTypes(),console.info(`Tab updated: "${n}" in "${r}"`)}),ba=S({name:`prismic type list`,description:`List all content types.`,options:{json:{type:`boolean`,description:`Output as JSON`}}},async({values:e})=>{let{json:t}=e,n=await(await P()).getCustomTypes();if(t){console.info(W(n.map(e=>e.model)));return}if(n.length===0){console.info(`No types found.`);return}let r=n.map(({model:e})=>[e.label||`(no name)`,e.id,e.format??``]);console.info(M(r,{headers:[`NAME`,`ID`,`FORMAT`]}))}),xa=S({name:`prismic type remove`,description:`Remove a content type.`,positionals:{id:{description:`ID of the content type`,required:!0}}},async({positionals:e})=>{let[t]=e,n=await P();await n.deleteCustomType(t),await n.generateTypes(),console.info(`Type removed: ${t}`)}),Sa=S({name:`prismic type remove-tab`,description:`Remove a tab from a content type.`,positionals:{name:{description:`Name of the tab`,required:!0}},options:{from:{type:`string`,required:!0,description:`ID of the content type`}}},async({positionals:e,values:t})=>{let[n]=e,{from:r}=t,i=await P(),{model:a}=await i.getCustomType(r);if(!(n in a.json))throw new L(`Tab "${n}" not found in "${r}".`);if(Object.keys(a.json).length<=1)throw new L(`Cannot remove the last tab from "${r}".`);delete a.json[n],await i.updateCustomType(a),await i.generateTypes(),console.info(`Removed tab "${n}" from "${r}"`)}),Ca=S({name:`prismic type view`,description:`View details of a content type.`,positionals:{id:{description:`ID of the content type`,required:!0}},options:{json:{type:`boolean`,description:`Output as JSON`}}},async({positionals:e,values:t})=>{let[n]=e,{json:r}=t,{model:i}=await(await P()).getCustomType(n);if(r){console.info(W(i));return}let a=(await s()).routes?.find(e=>e.type===i.id);console.info(`ID: ${i.id}`),console.info(`Name: ${i.label||`(no name)`}`),console.info(`Format: ${i.format??`custom`}`),console.info(`Repeatable: ${i.repeatable}`),console.info(`Route: ${a?.path??`none`}`);for(let[e,t]of Object.entries(i.json)){console.info(``),console.info(`${e}:`),console.info(tr(t));for(let[e,n]of Object.entries(t)){if(n.type!==`Slices`)continue;let t=Object.entries(n.config?.choices??{}).map(([e,t])=>t.type===`SharedSlice`?e:`${e} *`);console.info(`\n ${e} slices: ${t.join(`, `)||`(none)`}`)}}w([i]).length>0&&console.info("\n* Legacy slice. Run `prismic slice upgrade-legacy --help` to upgrade it.")}),wa=A({name:`prismic type`,description:`
501
+ `}},async({positionals:e,values:t})=>{let[n]=e,{format:r=`custom`,single:i=!1,id:a=yt(n)}=t;if(r!==`custom`&&r!==`page`)throw new S(`Invalid format: "${r}". Use "custom" or "page".`);let o=await P();if((await o.getCustomTypes()).some(({model:e})=>e.id===a))throw new S(`Type "${a}" already exists. Run \`prismic type edit ${a}\` to change it.`);let s=r===`page`?{Main:{slices:{type:`Slices`,fieldset:`Slice Zone`,config:{choices:{}}}},"SEO & Metadata":{meta_title:{type:`Text`,config:{label:`Meta Title`,placeholder:`A title of the page used for social media and search engines`}},meta_description:{type:`Text`,config:{label:`Meta Description`,placeholder:`A brief summary of the page`}},meta_image:{type:`Image`,config:{label:`Meta Image`,constraint:{width:2400,height:1260},thumbnails:[]}}}}:{Main:{}};i||(s.Main={uid:{type:`UID`,config:{label:`UID`}},...s.Main});let c={id:a,label:n,repeatable:!i,status:!0,format:r,json:s},l=await o.createCustomType(c);await o.generateTypes(),console.info(`Created type "${n}" (id: "${a}", format: "${r}")`);for(let e of l)console.info(e);console.info(`Run \`prismic field add <type> --to-type ${a}\` to add fields.`),console.info(`Run \`prismic type view ${a}\` to view the type.`)}),ba=j({name:`prismic type edit`,description:`Edit a content type.`,positionals:{id:{description:`ID of the content type`,required:!0}},options:{name:{type:`string`,short:`n`,description:`New name for the type`},format:{type:`string`,short:`f`,description:`Type format: "custom" or "page"`}}},async({positionals:e,values:t})=>{let[n]=e;if(`format`in t&&t.format!==`custom`&&t.format!==`page`)throw new S(`Invalid format: "${t.format}". Use "custom" or "page".`);let r=await P(),{model:i}=await r.getCustomType(n);`name`in t&&(i.label=t.name),`format`in t&&(i.format=t.format),await r.updateCustomType(i),await r.generateTypes(),console.info(`Type updated: "${i.label}" (id: ${i.id})`)}),xa=j({name:`prismic type edit-tab`,description:`Edit a tab of a content type.`,positionals:{name:{description:`Current name of the tab`,required:!0}},options:{"from-type":{type:`string`,required:!0,description:`ID of the content type`},name:{type:`string`,short:`n`,description:`New name for the tab`},"with-slice-zone":{type:`boolean`,description:`Add a slice zone to the tab`},"without-slice-zone":{type:`boolean`,description:`Remove the slice zone from the tab`}}},async({positionals:e,values:t})=>{let[n]=e,{"from-type":r}=t,i=await P(),{model:a}=await i.getCustomType(r);if(!(n in a.json))throw new S(`Tab "${n}" not found in "${r}".`);if(`with-slice-zone`in t&&`without-slice-zone`in t)throw new S(`Cannot use --with-slice-zone and --without-slice-zone together.`);if(`with-slice-zone`in t){let e=a.json[n];if(Object.values(e).some(e=>e.type===`Slices`))throw new S(`Tab "${n}" already has a slice zone.`);e.slices={type:`Slices`,fieldset:`Slice Zone`,config:{choices:{}}}}if(`without-slice-zone`in t){let e=a.json[n],t=Object.entries(e).find(([,e])=>e.type===`Slices`);if(!t)throw new S(`Tab "${n}" does not have a slice zone.`);let[r,i]=t,o=i.type===`Slices`?i.config?.choices??{}:{};if(Object.keys(o).length>0)throw new S(`Cannot remove slice zone from "${n}": disconnect all slices first.`);delete e[r]}if(`name`in t){if(t.name in a.json)throw new S(`Tab "${t.name}" already exists in "${r}".`);let e={};for(let[r,i]of Object.entries(a.json))e[r===n?t.name:r]=i;a.json=e}await i.updateCustomType(a),await i.generateTypes(),console.info(`Tab updated: "${n}" in "${r}"`)}),Sa=j({name:`prismic type list`,description:`List all content types.`,options:{json:{type:`boolean`,description:`Output as JSON`}}},async({values:e})=>{let{json:t}=e,n=await(await P()).getCustomTypes();if(t){console.info(G(n.map(e=>e.model)));return}if(n.length===0){console.info(`No types found.`);return}let r=n.map(({model:e})=>[e.label||`(no name)`,e.id,e.format??``]);console.info(L(r,{headers:[`NAME`,`ID`,`FORMAT`]}))}),Ca=j({name:`prismic type remove`,description:`Remove a content type.`,positionals:{id:{description:`ID of the content type`,required:!0}}},async({positionals:e})=>{let[t]=e,n=await P();await n.deleteCustomType(t),await n.generateTypes(),console.info(`Type removed: ${t}`)}),wa=j({name:`prismic type remove-tab`,description:`Remove a tab from a content type.`,positionals:{name:{description:`Name of the tab`,required:!0}},options:{from:{type:`string`,required:!0,description:`ID of the content type`}}},async({positionals:e,values:t})=>{let[n]=e,{from:r}=t,i=await P(),{model:a}=await i.getCustomType(r);if(!(n in a.json))throw new S(`Tab "${n}" not found in "${r}".`);if(Object.keys(a.json).length<=1)throw new S(`Cannot remove the last tab from "${r}".`);delete a.json[n],await i.updateCustomType(a),await i.generateTypes(),console.info(`Removed tab "${n}" from "${r}"`)}),Ta=j({name:`prismic type view`,description:`View details of a content type.`,positionals:{id:{description:`ID of the content type`,required:!0}},options:{json:{type:`boolean`,description:`Output as JSON`}}},async({positionals:e,values:t})=>{let[n]=e,{json:r}=t,{model:i}=await(await P()).getCustomType(n);if(r){console.info(G(i));return}let a=(await c()).routes?.find(e=>e.type===i.id);console.info(`ID: ${i.id}`),console.info(`Name: ${i.label||`(no name)`}`),console.info(`Format: ${i.format??`custom`}`),console.info(`Repeatable: ${i.repeatable}`),console.info(`Route: ${a?.path??`none`}`);for(let[e,t]of Object.entries(i.json)){console.info(``),console.info(`${e}:`),console.info(rr(t));for(let[e,n]of Object.entries(t)){if(n.type!==`Slices`)continue;let t=Object.entries(n.config?.choices??{}).map(([e,t])=>t.type===`SharedSlice`?e:`${e} *`);console.info(`\n ${e} slices: ${t.join(`, `)||`(none)`}`)}}te([i]).length>0&&console.info("\n* Legacy slice. Run `prismic slice upgrade-legacy --help` to upgrade it.")}),Ea=A({name:`prismic type`,description:`
496
502
  Manage content types.
497
503
 
498
504
  Run \`prismic docs view content-modeling\` for details.
499
- `,commands:{create:{handler:_a,description:`Create a new content type`},edit:{handler:va,description:`Edit a content type`},remove:{handler:xa,description:`Remove a content type`},list:{handler:ba,description:`List content types`},view:{handler:Ca,description:`View a content type`},"add-tab":{handler:ga,description:`Add a tab to a content type`},"edit-tab":{handler:ya,description:`Edit a tab of a content type`},"remove-tab":{handler:Sa,description:`Remove a tab from a content type`}}}),Ta=S({name:`prismic webhook create`,description:`
505
+ `,commands:{create:{handler:ya,description:`Create a new content type`},edit:{handler:ba,description:`Edit a content type`},remove:{handler:Ca,description:`Remove a content type`},list:{handler:Sa,description:`List content types`},view:{handler:Ta,description:`View a content type`},"add-tab":{handler:va,description:`Add a tab to a content type`},"edit-tab":{handler:xa,description:`Edit a tab of a content type`},"remove-tab":{handler:wa,description:`Remove a tab from a content type`}}}),Da=j({name:`prismic webhook create`,description:`
500
506
  Create a new webhook in a Prismic repository.
501
507
 
502
508
  By default, this command reads the repository from prismic.config.json at the
@@ -519,27 +525,27 @@ Watch stopped. Goodbye!`),rt(),process.exit(0)}),console.info(`Watching reposito
519
525
 
520
526
  Create a named webhook with a secret:
521
527
  prismic webhook create https://example.com/webhook --name "Deploy" --secret my-secret
522
- `}},async({positionals:e,values:t})=>{let[n]=e,{env:r,repo:i=r??await j(),name:a,secret:o,trigger:s=[]}=t;for(let e of s)if(!F.includes(e))throw new L(`Invalid trigger: ${e}\nValid triggers: ${F.join(`, `)}`);let c=await h(),l=!(s.length>0);await st({url:n,name:a??null,secret:o??null,documentsPublished:s.includes(`documentsPublished`)||l,documentsUnpublished:s.includes(`documentsUnpublished`)||l,releasesCreated:s.includes(`releasesCreated`)||l,releasesUpdated:s.includes(`releasesUpdated`)||l,tagsCreated:s.includes(`tagsCreated`)||l,tagsDeleted:s.includes(`tagsDeleted`)||l},{repo:i,getToken:C,host:c,onUnauthorized:x}),console.info(`Webhook created: ${n}`),console.info(`Run \`prismic webhook set-triggers ${n}\` to configure triggers.`)}),Ea=S({name:`prismic webhook disable`,description:`
528
+ `}},async({positionals:e,values:t})=>{let[n]=e,{env:r,repo:i=r??await M(),name:a,secret:o,trigger:s=[]}=t;for(let e of s)if(!mt.includes(e))throw new S(`Invalid trigger: ${e}\nValid triggers: ${mt.join(`, `)}`);let c=await g(),l=!(s.length>0);await et({url:n,name:a??null,secret:o??null,documentsPublished:s.includes(`documentsPublished`)||l,documentsUnpublished:s.includes(`documentsUnpublished`)||l,releasesCreated:s.includes(`releasesCreated`)||l,releasesUpdated:s.includes(`releasesUpdated`)||l,tagsCreated:s.includes(`tagsCreated`)||l,tagsDeleted:s.includes(`tagsDeleted`)||l},{repo:i,getToken:C,host:c,onUnauthorized:x}),console.info(`Webhook created: ${n}`),console.info(`Run \`prismic webhook set-triggers ${n}\` to configure triggers.`)}),Oa=j({name:`prismic webhook disable`,description:`
523
529
  Disable a webhook in a Prismic repository.
524
530
 
525
531
  By default, this command reads the repository from prismic.config.json at the
526
532
  project root.
527
- `,positionals:{url:{description:`Webhook URL`,required:!0}},options:{repo:{type:`string`,short:`r`,description:`Repository or environment domain`},env:{type:`string`,short:`e`,description:`Alias for --repo`,deprecated:"Use `prismic env` or --repo instead."}}},async({positionals:e,values:t})=>{let[n]=e,{env:r,repo:i=r??await j()}=t,a=await h(),o=(await T({repo:i,getToken:C,host:a,onUnauthorized:x})).find(e=>e.config.url===n);if(!o)throw new L(`Webhook not found: ${n}`);if(!o.config.active){console.info(`Webhook already disabled: ${n}`);return}let s=o.config._id,c=structuredClone(o.config);c.active=!1,await me(s,c,{repo:i,getToken:C,host:a,onUnauthorized:x}),console.info(`Webhook disabled: ${n}`)}),Da=S({name:`prismic webhook enable`,description:`
533
+ `,positionals:{url:{description:`Webhook URL`,required:!0}},options:{repo:{type:`string`,short:`r`,description:`Repository or environment domain`},env:{type:`string`,short:`e`,description:`Alias for --repo`,deprecated:"Use `prismic env` or --repo instead."}}},async({positionals:e,values:t})=>{let[n]=e,{env:r,repo:i=r??await M()}=t,a=await g(),o=(await D({repo:i,getToken:C,host:a,onUnauthorized:x})).find(e=>e.config.url===n);if(!o)throw new S(`Webhook not found: ${n}`);if(!o.config.active){console.info(`Webhook already disabled: ${n}`);return}let s=o.config._id,c=structuredClone(o.config);c.active=!1,await ye(s,c,{repo:i,getToken:C,host:a,onUnauthorized:x}),console.info(`Webhook disabled: ${n}`)}),ka=j({name:`prismic webhook enable`,description:`
528
534
  Enable a webhook in a Prismic repository.
529
535
 
530
536
  By default, this command reads the repository from prismic.config.json at the
531
537
  project root.
532
- `,positionals:{url:{description:`Webhook URL`,required:!0}},options:{repo:{type:`string`,short:`r`,description:`Repository or environment domain`},env:{type:`string`,short:`e`,description:`Alias for --repo`,deprecated:"Use `prismic env` or --repo instead."}}},async({positionals:e,values:t})=>{let[n]=e,{env:r,repo:i=r??await j()}=t,a=await h(),o=(await T({repo:i,getToken:C,host:a,onUnauthorized:x})).find(e=>e.config.url===n);if(!o)throw new L(`Webhook not found: ${n}`);if(o.config.active){console.info(`Webhook already enabled: ${n}`);return}let s=o.config._id,c=structuredClone(o.config);c.active=!0,await me(s,c,{repo:i,getToken:C,host:a,onUnauthorized:x}),console.info(`Webhook enabled: ${n}`)}),Oa=S({name:`prismic webhook list`,description:`
538
+ `,positionals:{url:{description:`Webhook URL`,required:!0}},options:{repo:{type:`string`,short:`r`,description:`Repository or environment domain`},env:{type:`string`,short:`e`,description:`Alias for --repo`,deprecated:"Use `prismic env` or --repo instead."}}},async({positionals:e,values:t})=>{let[n]=e,{env:r,repo:i=r??await M()}=t,a=await g(),o=(await D({repo:i,getToken:C,host:a,onUnauthorized:x})).find(e=>e.config.url===n);if(!o)throw new S(`Webhook not found: ${n}`);if(o.config.active){console.info(`Webhook already enabled: ${n}`);return}let s=o.config._id,c=structuredClone(o.config);c.active=!0,await ye(s,c,{repo:i,getToken:C,host:a,onUnauthorized:x}),console.info(`Webhook enabled: ${n}`)}),Aa=j({name:`prismic webhook list`,description:`
533
539
  List all webhooks in a Prismic repository.
534
540
 
535
541
  By default, this command reads the repository from prismic.config.json at the
536
542
  project root.
537
- `,options:{json:{type:`boolean`,description:`Output as JSON`},repo:{type:`string`,short:`r`,description:`Repository or environment domain`},env:{type:`string`,short:`e`,description:`Alias for --repo`,deprecated:"Use `prismic env` or --repo instead."}}},async({values:e})=>{let{env:t,repo:n=t??await j(),json:r}=e,i=await h(),a=await T({repo:n,getToken:C,host:i,onUnauthorized:x});if(r){console.info(W(a.map(e=>e.config)));return}if(a.length===0){console.info(`No webhooks configured.`);return}let o=a.map(e=>{let t=e.config.active?`enabled`:`disabled`,n=e.config.name?` (${e.config.name})`:``;return[`${e.config.url}${n}`,`[${t}]`]});console.info(M(o,{headers:[`URL`,`STATUS`]}))}),ka=S({name:`prismic webhook remove`,description:`
543
+ `,options:{json:{type:`boolean`,description:`Output as JSON`},repo:{type:`string`,short:`r`,description:`Repository or environment domain`},env:{type:`string`,short:`e`,description:`Alias for --repo`,deprecated:"Use `prismic env` or --repo instead."}}},async({values:e})=>{let{env:t,repo:n=t??await M(),json:r}=e,i=await g(),a=await D({repo:n,getToken:C,host:i,onUnauthorized:x});if(r){console.info(G(a.map(e=>e.config)));return}if(a.length===0){console.info(`No webhooks configured.`);return}let o=a.map(e=>{let t=e.config.active?`enabled`:`disabled`,n=e.config.name?` (${e.config.name})`:``;return[`${e.config.url}${n}`,`[${t}]`]});console.info(L(o,{headers:[`URL`,`STATUS`]}))}),ja=j({name:`prismic webhook remove`,description:`
538
544
  Delete a webhook from a Prismic repository.
539
545
 
540
546
  By default, this command reads the repository from prismic.config.json at the
541
547
  project root.
542
- `,positionals:{url:{description:`Webhook URL`,required:!0}},options:{repo:{type:`string`,short:`r`,description:`Repository or environment domain`},env:{type:`string`,short:`e`,description:`Alias for --repo`,deprecated:"Use `prismic env` or --repo instead."}}},async({positionals:e,values:t})=>{let[n]=e,{env:r,repo:i=r??await j()}=t,a=await h(),o=(await T({repo:i,getToken:C,host:a,onUnauthorized:x})).find(e=>e.config.url===n);if(!o)throw new L(`Webhook not found: ${n}`);let s=o.config._id;await Ae(s,{repo:i,getToken:C,host:a,onUnauthorized:x}),console.info(`Webhook removed: ${n}`)}),Aa=S({name:`prismic webhook set-triggers`,description:`
548
+ `,positionals:{url:{description:`Webhook URL`,required:!0}},options:{repo:{type:`string`,short:`r`,description:`Repository or environment domain`},env:{type:`string`,short:`e`,description:`Alias for --repo`,deprecated:"Use `prismic env` or --repo instead."}}},async({positionals:e,values:t})=>{let[n]=e,{env:r,repo:i=r??await M()}=t,a=await g(),o=(await D({repo:i,getToken:C,host:a,onUnauthorized:x})).find(e=>e.config.url===n);if(!o)throw new S(`Webhook not found: ${n}`);let s=o.config._id;await Ct(s,{repo:i,getToken:C,host:a,onUnauthorized:x}),console.info(`Webhook removed: ${n}`)}),Ma=j({name:`prismic webhook set-triggers`,description:`
543
549
  Update which events trigger a webhook.
544
550
 
545
551
  By default, this command reads the repository from prismic.config.json at the
@@ -551,16 +557,16 @@ Watch stopped. Goodbye!`),rt(),process.exit(0)}),console.info(`Watching reposito
551
557
  releasesUpdated When a release is edited or deleted
552
558
  tagsCreated When a tag is created
553
559
  tagsDeleted When a tag is deleted
554
- `}},async({positionals:e,values:t})=>{let[n]=e,{env:r,repo:i=r??await j(),trigger:a=[]}=t;for(let e of a)if(!F.includes(e))throw new L(`Invalid trigger: ${e}\nValid triggers: ${F.join(`, `)}`);let o=await h(),s=(await T({repo:i,getToken:C,host:o,onUnauthorized:x})).find(e=>e.config.url===n);if(!s)throw new L(`Webhook not found: ${n}`);let c=s.config._id;await me(c,{...s.config,documentsPublished:a.includes(`documentsPublished`),documentsUnpublished:a.includes(`documentsUnpublished`),releasesCreated:a.includes(`releasesCreated`),releasesUpdated:a.includes(`releasesUpdated`),tagsCreated:a.includes(`tagsCreated`),tagsDeleted:a.includes(`tagsDeleted`)},{repo:i,getToken:C,host:o,onUnauthorized:x}),console.info(`Webhook triggers updated: ${a.join(`, `)}`)}),ja=S({name:`prismic webhook view`,description:`
560
+ `}},async({positionals:e,values:t})=>{let[n]=e,{env:r,repo:i=r??await M(),trigger:a=[]}=t;for(let e of a)if(!mt.includes(e))throw new S(`Invalid trigger: ${e}\nValid triggers: ${mt.join(`, `)}`);let o=await g(),s=(await D({repo:i,getToken:C,host:o,onUnauthorized:x})).find(e=>e.config.url===n);if(!s)throw new S(`Webhook not found: ${n}`);let c=s.config._id;await ye(c,{...s.config,documentsPublished:a.includes(`documentsPublished`),documentsUnpublished:a.includes(`documentsUnpublished`),releasesCreated:a.includes(`releasesCreated`),releasesUpdated:a.includes(`releasesUpdated`),tagsCreated:a.includes(`tagsCreated`),tagsDeleted:a.includes(`tagsDeleted`)},{repo:i,getToken:C,host:o,onUnauthorized:x}),console.info(`Webhook triggers updated: ${a.join(`, `)}`)}),Na=j({name:`prismic webhook view`,description:`
555
561
  View details of a webhook in a Prismic repository.
556
562
 
557
563
  By default, this command reads the repository from prismic.config.json at the
558
564
  project root.
559
- `,positionals:{url:{description:`Webhook URL`,required:!0}},options:{repo:{type:`string`,short:`r`,description:`Repository or environment domain`},env:{type:`string`,short:`e`,description:`Alias for --repo`,deprecated:"Use `prismic env` or --repo instead."}}},async({positionals:e,values:t})=>{let[n]=e,{env:r,repo:i=r??await j()}=t,a=await h(),o=(await T({repo:i,getToken:C,host:a,onUnauthorized:x})).find(e=>e.config.url===n);if(!o)throw new L(`Webhook not found: ${n}`);let{config:s}=o;console.info(`URL: ${s.url}`),console.info(`Name: ${s.name||`(none)`}`),console.info(`Status: ${s.active?`enabled`:`disabled`}`),console.info(`Secret: ${s.secret?`(set)`:`(none)`}`);let c=[];for(let e of F)s[e]&&c.push(e);if(console.info(`Triggers: ${c.length>0?c.join(`, `):`(none)`}`),Object.keys(s.headers).length>0){console.info(`Headers:`);for(let[e,t]of Object.entries(s.headers))console.info(` ${e}: ${t}`)}else console.info(`Headers: (none)`)}),Ma=A({name:`prismic webhook`,description:`
565
+ `,positionals:{url:{description:`Webhook URL`,required:!0}},options:{repo:{type:`string`,short:`r`,description:`Repository or environment domain`},env:{type:`string`,short:`e`,description:`Alias for --repo`,deprecated:"Use `prismic env` or --repo instead."}}},async({positionals:e,values:t})=>{let[n]=e,{env:r,repo:i=r??await M()}=t,a=await g(),o=(await D({repo:i,getToken:C,host:a,onUnauthorized:x})).find(e=>e.config.url===n);if(!o)throw new S(`Webhook not found: ${n}`);let{config:s}=o;console.info(`URL: ${s.url}`),console.info(`Name: ${s.name||`(none)`}`),console.info(`Status: ${s.active?`enabled`:`disabled`}`),console.info(`Secret: ${s.secret?`(set)`:`(none)`}`);let c=[];for(let e of mt)s[e]&&c.push(e);if(console.info(`Triggers: ${c.length>0?c.join(`, `):`(none)`}`),Object.keys(s.headers).length>0){console.info(`Headers:`);for(let[e,t]of Object.entries(s.headers))console.info(` ${e}: ${t}`)}else console.info(`Headers: (none)`)}),Pa=A({name:`prismic webhook`,description:`
560
566
  Manage webhooks in a Prismic repository.
561
567
 
562
568
  Run \`prismic docs view webhooks\` for details.
563
- `,commands:{list:{handler:Oa,description:`List all webhooks`},create:{handler:Ta,description:`Create a new webhook`},view:{handler:ja,description:`View webhook details`},remove:{handler:ka,description:`Delete a webhook`},enable:{handler:Da,description:`Enable a webhook`},disable:{handler:Ea,description:`Disable a webhook`},"set-triggers":{handler:Aa,description:`Update webhook triggers`}}}),Na=S({name:`prismic whoami`,description:`Show the currently logged in user.`},async()=>{let e=await h(),t=await ee(await C(),{host:e});t.type===`Machine2Machine`?console.info(`${t.appName} (Write API token for ${t.domain})`):console.info(t.email)}),Pa=A({name:`prismic`,description:`Prismic CLI for managing repositories and configurations.`,sections:{DOCUMENTATION:"\n Run `prismic docs list` to browse available documentation topics.\n Run `prismic docs view <path>` to read a topic.\n ",MODELING:`
569
+ `,commands:{list:{handler:Aa,description:`List all webhooks`},create:{handler:Da,description:`Create a new webhook`},view:{handler:Na,description:`View webhook details`},remove:{handler:ja,description:`Delete a webhook`},enable:{handler:ka,description:`Enable a webhook`},disable:{handler:Oa,description:`Disable a webhook`},"set-triggers":{handler:Ma,description:`Update webhook triggers`}}}),Fa=j({name:`prismic whoami`,description:`Show the currently logged in user.`},async()=>{let e=await g(),t=await ut(await C(),{host:e});t.type===`Machine2Machine`?console.info(`${t.appName} (Write API token for ${t.domain})`):console.info(t.email)}),Ia=A({name:`prismic`,description:`Prismic CLI for managing repositories and configurations.`,sections:{DOCUMENTATION:"\n Run `prismic docs list` to browse available documentation topics.\n Run `prismic docs view <path>` to read a topic.\n ",MODELING:`
564
570
  Pages are page types, built from slices and fields. Content that is
565
571
  not a page is a custom type, such as an author or a navigation menu.
566
572
  A page references a custom type with a content relationship field,
@@ -581,4 +587,4 @@ Watch stopped. Goodbye!`),rt(),process.exit(0)}),console.info(`Watching reposito
581
587
  A repository can hold multiple preview URLs but only one simulator URL,
582
588
  which the Page Builder loads live slice previews from.
583
589
  Run \`prismic docs view previews\` for details.
584
- `},commands:{init:{handler:ci,description:`Initialize a Prismic project`},docs:{handler:Bn,description:`Browse Prismic documentation`},gen:{handler:Yr,description:`Generate files from local models`},pull:{handler:Di,description:`Pull types and slices from Prismic`},push:{handler:Oi,description:`Push types and slices to Prismic`},sync:{handler:aa,description:`Sync types and slices from Prismic`},dev:{handler:dn,description:`Edit local models visually in the Type Builder`,hidden:!0},status:{handler:ra,description:`Show local vs remote model differences`},env:{handler:qn,description:`Manage the active environment`},locale:{handler:gi,description:`Manage locales`},repo:{handler:zi,description:`Manage repositories`},type:{handler:wa,description:`Manage content types`},field:{handler:Wr,description:`Manage fields`},slice:{handler:na,description:`Manage slices`},preview:{handler:wi,description:`Manage preview and simulator URLs`},token:{handler:ha,description:`Manage API tokens`},webhook:{handler:Ma,description:`Manage webhooks`},login:{handler:_i,description:`Log in to Prismic`},logout:{handler:vi,description:`Log out of Prismic`},whoami:{handler:Na,description:`Show the currently logged in user`},"task-id":{handler:ua,description:`Print a task ID for --task-id`,hidden:nt()===void 0}}});const Fa=[L,d,l,te,ie,Ke,r,Je,Oe,Ee,Ue,it,tt,Un,ot,Qe,Ie,Gt,Ve,Pt,kt,V,K,Dt,Ut,je,ut],Ia=[Dt,Ut];await La();async function La(){await Yt({npmPackageName:t,statePath:Ne}),_e().catch(()=>{});let{positionals:[r=``],values:{version:i,help:a,repo:o=await O().catch(()=>void 0),"analytics-intent":s,"analytics-task-id":c,"user-intent":l=s,"task-id":u=c}}=Zt({options:{version:{type:`boolean`,short:`v`},help:{type:`boolean`,short:`h`},repo:{type:`string`,short:`r`},"user-intent":{type:`string`},"task-id":{type:`string`},"analytics-intent":{type:`string`},"analytics-task-id":{type:`string`}},allowPositionals:!0,strict:!1});if(i){console.info(e);return}let d=typeof o==`string`?o:void 0,f=typeof l==`string`?l:void 0,p=typeof u==`string`?u:void 0,g=!a&&r!==``&&r!==`task-id`&&nt()!==void 0?za(p,f):void 0;if(g){let e=p&&la(p)?p:ca();console.error(`error: ${g}\nrerun with --task-id ${e} --user-intent "<what the user asked for>", and pass both on every command until the user asks for something else`),process.exitCode=1;return}if(!a){let e=await h(),t=I.PRISMIC_TOKEN?{}:await at(),r=!!(I.PRISMIC_TOKEN||t.expiresAt),i=I.PRISMIC_TELEMETRY_ENABLED??await Fe(),a=I.PRISMIC_SENTRY_ENABLED??(i&&I.PROD);if(a&&await Ra({host:e,repo:d,userIntent:f,taskId:p}),i&&await n({host:e,loggedIn:r,repo:d,userIntent:f,taskId:p,store:t.store,storeReason:t.storeReason}),r&&(a||i)){let t=ce();t?$r({id:t}):m({getToken:C,host:e}).then(e=>{Ge(e),$r({id:e.shortId})}).catch(()=>{})}}let _=!a&&r&&r!==`sync`;try{_&&dt(r),await Pa(),_&&rt()}catch(e){process.exitCode=1;let t=await ln(e).catch(()=>void 0);if(_&&rt({error:t??e}),Fa.some(t=>e instanceof t))console.error(t),Ba(e)&&await ei(e);else throw console.error(`The CLI reached a bug. Report this if it keeps happening: https://github.com/prismicio/cli/issues`),await ei(e),e}}async function Ra(n){let{host:r,repo:i,userIntent:a,taskId:o}=n;Xr({dsn:I.PRISMIC_SENTRY_DSN,appName:t,appVersion:e,environment:I.PRISMIC_SENTRY_ENVIRONMENT}),Zr(`host`,r),i&&(Zr(`repository`,i),Qr(`Repository Data`,{name:i})),o&&Zr(`taskId`,o),a&&Qr(`Agent Task`,{userIntent:a,taskId:o});try{Zr(`framework`,(await P()).id)}catch{}}function za(e,t){if(!e)return`missing --task-id`;if(!la(e))return"--task-id must come from `prismic task-id`";if(!t)return`missing --user-intent`}function Ba(e){return e instanceof je?e.reason===`misconfigured`:Ia.some(t=>e instanceof t)}export{};
590
+ `},commands:{init:{handler:ui,description:`Initialize a Prismic project`},docs:{handler:Hn,description:`Browse Prismic documentation`},gen:{handler:Zr,description:`Generate files from local models`},pull:{handler:ki,description:`Pull types and slices from Prismic`},push:{handler:Ai,description:`Push types and slices to Prismic`},sync:{handler:sa,description:`Sync types and slices from Prismic`},dev:{handler:pn,description:`Edit local models visually in the Type Builder`,hidden:!0},status:{handler:aa,description:`Show local vs remote model differences`},env:{handler:Yn,description:`Manage the active environment`},locale:{handler:vi,description:`Manage locales`},repo:{handler:Vi,description:`Manage repositories`},type:{handler:Ea,description:`Manage content types`},field:{handler:Kr,description:`Manage fields`},slice:{handler:ia,description:`Manage slices`},preview:{handler:Ei,description:`Manage preview and simulator URLs`},token:{handler:_a,description:`Manage API tokens`},webhook:{handler:Pa,description:`Manage webhooks`},login:{handler:yi,description:`Log in to Prismic`},logout:{handler:bi,description:`Log out of Prismic`},whoami:{handler:Fa,description:`Show the currently logged in user`},"task-id":{handler:fa,description:`Print a task ID for --task-id`,hidden:dt()===void 0}}});const La=[S,f,u,re,oe,qe,i,Ye,ot,Oe,Ee,We,it,tt,Gn,st,$e,Ie,Kt,Ve,Nt,At,V,K,Ot,Ut,Ze,Ge],Ra=[Ot,Ut];await za();async function za(){await Zt({npmPackageName:t,statePath:Le}),ve().catch(()=>{});let{positionals:[r=``],values:{version:i,help:a,repo:o=await O().catch(()=>void 0),"analytics-intent":s,"analytics-task-id":c,"user-intent":l=s,"task-id":u=c}}=$t({options:{version:{type:`boolean`,short:`v`},help:{type:`boolean`,short:`h`},repo:{type:`string`,short:`r`},"user-intent":{type:`string`},"task-id":{type:`string`},"analytics-intent":{type:`string`},"analytics-task-id":{type:`string`}},allowPositionals:!0,strict:!1});if(i){console.info(e);return}let d=typeof o==`string`&&jt(o)?o:void 0,f=typeof l==`string`?l:void 0,p=typeof u==`string`?u:void 0,m=!a&&r!==``&&r!==`task-id`&&dt()!==void 0?Va(p,f):void 0;if(!a){let e=await g(),t=F.PRISMIC_TOKEN?{}:await pt(),r=!!(F.PRISMIC_TOKEN||t.expiresAt),i=F.PRISMIC_TELEMETRY_ENABLED??await Fe(),a=F.PRISMIC_SENTRY_ENABLED??(i&&F.PROD);if(a&&await Ba({host:e,repo:d,userIntent:f,taskId:p}),i&&await n({host:e,loggedIn:r,repo:d,userIntent:f,taskId:p,store:t.store,storeReason:t.storeReason}),r&&(a||i)){let t=ue();t?ti({id:t}):ee({getToken:C,host:e}).then(e=>{Ke(e),ti({id:e.shortId})}).catch(()=>{})}}let h=!a&&r&&r!==`sync`;if(m){let e=p&&da(p)?p:ua();console.error(`error: ${m}\nrerun with --task-id ${e} --user-intent "<what the user asked for>", and pass both on every command until the user asks for something else`),process.exitCode=1,ft(r),rt({error:m})}else try{h&&ft(r),await Ia(),h&&rt()}catch(e){process.exitCode=1;let t=await dn(e).catch(()=>void 0);if(h&&rt({error:t??e}),La.some(t=>e instanceof t))console.error(t),Ha(e)&&await ni(e);else throw console.error(`The CLI reached a bug. Report this if it keeps happening: https://github.com/prismicio/cli/issues`),await ni(e),e}}async function Ba(n){let{host:r,repo:i,userIntent:a,taskId:o}=n;Qr({dsn:F.PRISMIC_SENTRY_DSN,appName:t,appVersion:e,environment:F.PRISMIC_SENTRY_ENVIRONMENT}),$r(`host`,r),i&&($r(`repository`,i),ei(`Repository Data`,{name:i})),o&&$r(`taskId`,o),a&&ei(`Agent Task`,{userIntent:a,taskId:o});try{$r(`framework`,(await P()).id)}catch{}}function Va(e,t){if(!e)return`missing --task-id`;if(!da(e))return"--task-id must come from `prismic task-id`";if(!t)return`missing --user-intent`}function Ha(e){return e instanceof Ze?e.reason===`misconfigured`:Ra.some(t=>e instanceof t)}export{};