prismic 1.28.0 → 1.29.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-DPO7tnYd.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 x,J as ee,Jt as S,K as te,Kt as C,L as w,Lt as ne,M as T,Mt as re,N as ie,Nt as ae,O as oe,Ot as se,P as ce,Pt as le,Q as ue,R as de,Rt as fe,S as E,St as pe,T as me,Tt as he,U as ge,Ut as _e,V as ve,Vt as ye,W as D,Wt as be,X as xe,Xt as O,Y as Se,Yt as Ce,Z as we,Zt as Te,_t as Ee,a as De,an as Oe,at as k,b as ke,bt as Ae,c as A,cn as je,ct as Me,dt as Ne,en as Pe,et as Fe,f as Ie,fn as j,ft as Le,g as Re,gn as ze,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 M,ln as Ze,lt as Qe,m as $e,mn as N,mt as et,n as tt,nn as nt,nt as rt,o as it,on as at,ot,p as st,pn as ct,pt as lt,q as P,qt as F,r as I,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 L,xt as St,y as Ct,yt as wt,z as Tt,zt as Et}from"./adapters-_6OwtgCL.mjs";import{C as Dt,D as Ot,E as kt,H as At,K as jt,M as R,N as z,O as B,R as Mt,S as Nt,T as Pt,X as V,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 H,o as Wt,p as U,q as W,t as Gt,u as Kt,v as qt,w as G,x as Jt}from"./packageJson-Du_fIYqH.mjs";import{t as Yt}from"./update-notifier-CaPWDsNo.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=W({error:At(`invalid_auth_context`)});function sn(e){return e instanceof B&&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 ft)return e.reason===`misconfigured`?`Login isn't set up correctly for ${await D()} (${e.detail}). Report this: https://github.com/prismicio/cli/issues`:cn[e.reason];if(e instanceof B||e instanceof G)return await g().catch(()=>void 0)?j.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 B?"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 Te`
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`
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 Te(e.message)}const un=j.PRISMIC_SYNC_POLL_MS??5e3;var dn=F({name:`prismic dev`,description:`
8
+ `}if(e instanceof Error)return le(e.message)}const un=I.PRISMIC_SYNC_POLL_MS??5e3;var dn=S({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-DPO7tnYd.mjs";import{$ as n,$t as r,A as i,At as
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})=>{O(e,[`continue`,`new`]);let t=await M(),{repo:n=await t.getEnvironment()??await E(),continue:r,new:i,"no-browser":a}=e,o=await D(),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:g,host:o}));let u={repo:n,getToken:g,host:o,onUnauthorized:P,releaseId:l.releaseId},d=(e=!0)=>xn(t,u,l,s,{push:e,onPull:e=>q(`↓ Pulled ${En(e)}`),onPush:e=>q(`↑ Pushed ${En(e)}`),onDelete:e=>q(`− 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.`):(Pe(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&&q(`! ${e}`,console.error),h=e};await Sn(d,e,p.signal,{onSync:()=>{h=void 0},onRecover:()=>q(`Back in sync.`),onUnreachable:()=>g(`Cannot reach Prismic. Retrying...`),onError:async e=>g(await ln(On(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 L())).digest(`hex`);return new URL(`dev/${e}.json`,Ze)}async function pn(e){return It(e,{schema:jn}).catch(()=>void 0)}async function mn(e,t){await Nt(e,U(t))}async function hn({repo:e,getToken:t,host:n}){return{repo:e,releaseId:(await _t({label:`prismic dev`,hidden:!0},{repo:e,getToken:t,host:n,onUnauthorized:P}).catch(e=>{throw On(e)})).id,pid:process.pid,synced:{}}}async function gn({releaseId:e,...t},n){await Ee(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&&Dn(o.pid))throw new C(`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 C("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:g,host:r,onUnauthorized:P,releaseId:o.releaseId},o.synced))throw new C("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 Ee(o.releaseId,{repo:o.repo,getToken:g,host:r,onUnauthorized:P}).catch(()=>{})}}async function vn(e,t,n){let r=await w(t).catch(e=>{if(!(e instanceof kt))throw On(e)}),i=K(await e.getModels());if(!r)return!1;let a=K(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 w(t);return await ve(m(i,a),t),n.synced=K(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(),w(t)]),d=K(l),f=K(u),p=wn(d,f,n.synced),h=l;if(p.pull.length>0){await e.writeModels(m(Tn(u,p.pull),Tn(l,p.pull))),await e.generateTypes(),h=await e.getModels();let t=K(h);for(let e of p.pull)e in t?n.synced[e]=t[e]:delete n.synced[e];await mn(r,n)}let g=p.pull.filter(e=>e in f);g.length>0&&o(g);let _=a?p.push:[];await ve(m(Tn(l,_),Tn(u,_)),t);let v=_.filter(e=>e in d);v.length>0&&s(v);let y=[...p.pull.filter(e=>!(e in f)),..._.filter(e=>!(e in d))];return y.length>0&&c(y),n.synced=K(h),await mn(r,n),h}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 B||e instanceof G||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 B?new C("Your login expired. Run `prismic login`, then `prismic dev --continue` to continue the session."):e instanceof kt?new C("The session ended. Run `prismic dev` to start a new one."):(e instanceof G||await t(),On(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 K(e){let t=e=>nn(`sha256`).update(JSON.stringify(e)).digest(`hex`);return Object.fromEntries([...e.customTypes.map(e=>[`type:${e.id}`,t(ie(e))]),...e.slices.map(e=>[`slice:${e.id}`,t(ce(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 q(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})=>{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(`
21
21
  `,`
22
- `)}`)}function Dn(e){try{return process.kill(e,0),!0}catch(e){return e.code===`EPERM`}}function On(e){if(!(e instanceof Ot))return e;switch(Vt(W({error:V()}),e.body).data?.error){case`missing_right`:return new C(`To edit models in the Type Builder, you need an Administrator, Owner, or Super User role on this repository.`);case`LEGACY_REPOSITORY`:return new C(`Local mode does not support this repository yet.`)}let t=Vt(An,e.body).data?.details;return t?new C([...t.customTypes,...t.slices].map(({id:e,error:t})=>`Could not push ${e}: ${t}`).join(`
23
- `)):e}const kn=Mt(W({id:V(),error:V()})),An=W({details:W({customTypes:kn,slices:kn})}),jn=W({repo:V(),releaseId:V(),pid:jt(),synced:Ft(V(),V())});var Mn=F({name:`prismic docs list`,description:`
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:`
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:i}=t;if(n){let e=await xt(n,{host:j.PRISMIC_DOCS_HOST});if(i){console.info(U(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(r(t,{headers:[`PATH`,`EXCERPT`]}))}else{let e=await pe({host:j.PRISMIC_DOCS_HOST});if(e.sort((e,t)=>e.path.localeCompare(t.path)),i){console.info(U(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(r(t,{headers:[`PATH`,`TITLE`,`DESCRIPTION`]}))}});const Nn=/[\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,Pn=Object.hasOwnProperty;var Fn=class{constructor(){this.occurrences,this.reset()}slug(e,t){let n=this,r=In(e,t===!0),i=r;for(;Pn.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 In(e,t){return typeof e==`string`?(t||(e=e.toLowerCase()),e.replace(Nn,``).replace(/ /g,`-`)):``}var Ln=F({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 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:`
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 l(a,{host:j.PRISMIC_DOCS_HOST,headers:xe()});if(o){let e=Rn(s,o);if(!e)throw new C(`Anchor not found: #${o}`);s=e}console.info(r?U({path:a,anchor:o,content:s}):s)});function Rn(e,t){let n=e.split(`
32
- `),r=new Fn,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 zn=S({name:`prismic docs`,description:`Browse Prismic documentation.`,commands:{list:{handler:Mn,description:`List available documentation pages`},view:{handler:Ln,description:`View a documentation page`}}}),Bn=F({name:`prismic env active`,description:`Print the active environment.`},async()=>{let e=await E(),t=await(await M()).getEnvironment();console.info(t??e)});async function Vn(e){let{results:t}=await p(e),n=await _(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 Hn=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(Te`
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`
35
35
  Environment "${e}" not found on repository "${n}".
36
36
 
37
37
  Available environments:
38
38
  ${r}
39
- `)}}},Un=F({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 E(),{json:n,repo:i=t}=e,a=await D(),o=await Vn({repo:i,getToken:g,host:a,onUnauthorized:P}),s;if(i===t&&(s=await(await M()).getEnvironment()??t),n){let e=o.map(e=>({domain:e.domain,kind:e.kind,active:e.domain===s}));console.info(U(e));return}let c=o.map(e=>[e.domain,e.kind,e.domain===s?`*`:``]);console.info(r(c,{headers:[`DOMAIN`,`KIND`,`ACTIVE`]}))}),Wn=F({name:`prismic env set`,description:`Set the active environment.`,positionals:{environment:{description:`Environment domain`,required:!0}}},async({positionals:e})=>{let[t]=e,n=await E(),r=await D(),i=await Vn({repo:n,getToken:g,host:r,onUnauthorized:P});if(!i.some(e=>e.domain===t))throw new Hn(t,i,n);let a=await M();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}`)}),Gn=F({name:`prismic env unset`,description:`Reset the active environment to the production environment.`},async()=>{let e=await E();await(await M()).unsetEnvironment(),console.info(`Reset to the production environment "${e}".`)}),Kn=S({name:`prismic env`,description:`
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:`
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:Wn,description:`Set the active environment`},unset:{handler:Gn,description:`Reset to the production environment`},active:{handler:Bn,description:`Print the active environment`},list:{handler:Un,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`},tab:{type:`string`,description:`Content type tab name (default: "Main")`,dependsOn:`to-type`}},qn={"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`}};async function Jn(e,t,n){let{variation:r=`default`}=n,{key:i,value:a}=Ce(n,[`from-slice`,`from-type`]),s=await M(),c,l,d;if(i===`from-slice`){let{model:n}=await s.getSlice(a);c=o(e,n,r),l=o(t,n,r),d=async()=>{await s.updateSlice(n),await s.generateTypes()}}else{let{model:n}=await s.getCustomType(a);c=Tt(e,n),l=Tt(t,n),d=async()=>{await s.updateCustomType(n),await s.generateTypes()}}if(!(c.fieldId in c.fields))throw new u(e);if(!(l.fieldId in l.fields))throw new u(t);return{source:c,anchor:l,save:d}}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 Zn(e,a,r):await Qn(e,a,n);if(o.fieldId in o.fields)throw new f(e);return o}async function Yn(e,t){let{variation:n=`default`}=t,{key:r,value:i}=Ce(t,[`from-slice`,`from-type`]),a=r===`from-slice`?await Zn(e,i,n):await Qn(e,i),o=a.fields[a.fieldId];if(!o)throw new u(e);return{...a,field:o}}async function Xn(e,t){let n=await(await M()).getCustomTypes();return de(e,t,n.map(({model:e})=>e))}async function Zn(e,t,n){let r=await M(),{model:i}=await r.getSlice(t);return{...o(e,i,n),save:async()=>{await r.updateSlice(i),await r.generateTypes()}}}async function Qn(e,t,n){let r=await M(),{model:i}=await r.getCustomType(t);return{...Tt(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 C(`--${t} must be a valid number, got "${e}"`);return n}function $n(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 r(n)}const er={name:`prismic field add boolean`,description:`
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:`
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 tr=F(er,async({positionals:e,values:t})=>{let[n]=e;O(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 nr={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 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:`
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 rr=F(nr,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 ir={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 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:`
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 ar=F(ir,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 C(`--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 Xn(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 or={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 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:`
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 sr=F(or,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 cr={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 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:`
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 lr=F(cr,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 ur={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 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:`
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 dr=F(ur,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 fr={name:`prismic field add group`,description:`
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:`
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 pr=F(fr,async({positionals:e,values:t})=>{let[n]=e,{label:r}=t,{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 mr={name:`prismic field add image`,description:`
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:`
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 hr=F(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:`Image`,config:{label:r??N(o),placeholder:i}};T(a,o,c),await s(),console.info(`Field added: ${n}`)});const gr={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 _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:`
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 _r=F(gr,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 vr={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 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:`
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 yr=F(vr,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 C(`--allow accepts a single link type. Prismic links allow either one type or all types.`);if(a&&!r.includes(a))throw new C(`--allow must be one of: ${r.join(`, `)}`);let d=a;if(u&&(d===`media`||d===`web`))throw new C(`--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 br={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 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:`
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 xr=F(br,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 Sr={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 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:`
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 Cr=F(Sr,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 wr={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 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:`
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 Tr=F(wr,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 Er={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 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:`
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 Dr=F(Er,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 Or={name:`prismic field add text`,description:`
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:`
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 kr=F(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:`Text`,config:{label:r??N(o),placeholder:i}};T(a,o,c),await s(),console.info(`Field added: ${n}`)});const Ar={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 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:`
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 jr=F(Ar,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 Mr={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 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:`
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 Nr=F(Mr,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`)}),Pr=S({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 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:`
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:tr,description:`Add a boolean field`},color:{handler:rr,description:`Add a color field`},"content-relationship":{handler:ar,description:`Add a content relationship field for fetching data from related documents (not for navigation -- use link)`},date:{handler:sr,description:`Add a date field`},embed:{handler:lr,description:`Add an embed field`},geopoint:{handler:dr,description:`Add a geopoint field`},group:{handler:pr,description:`Add a group field`},image:{handler:hr,description:`Add an image field`},integration:{handler:_r,description:`Add an integration field`},link:{handler:yr,description:`Add a link field for URLs, documents, or media (navigational)`},number:{handler:xr,description:`Add a number field`},"rich-text":{handler:Cr,description:`Add a rich text field`},select:{handler:Tr,description:`Add a select field`},table:{handler:Dr,description:`Add a table field`},text:{handler:kr,description:`Add a text field for short plain strings (not for titles or headings -- use rich-text --allow heading1 --single)`},timestamp:{handler:jr,description:`Add a timestamp field`},uid:{handler:Nr,description:`Add a UID field`}}});const Fr={name:`prismic field edit`,description:`Edit an existing field in a slice or custom type.`,sections:{"FIELD TYPE OPTIONS":`
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":`
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:{...qn,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 Ir=F(Fr,async({positionals:e,values:t})=>{let[n]=e,{field:r,save:i}=await Yn(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`:O(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 C(`--allow accepts a single link type. Prismic links allow either one type or all types.`);else throw new C(`--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 C(`--field requires the field to be restricted to a custom type. Use --custom-type to specify one.`);if(e.length>1)throw new C(`--field requires the field to be restricted to a single custom type.`);let[n]=e,i=typeof n==`string`?n:n.id,a=await Xn(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 C(`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}`)}),Lr=F({name:`prismic field remove`,description:`Remove a field from a slice or custom type.`,positionals:{id:{description:`Field ID`,required:!0}},options:qn},async({positionals:e,values:t})=>{let[n]=e,{fields:r,fieldId:i,save:a}=await Yn(n,t);delete r[i],await a(),console.info(`Field removed: ${n}`)});const Rr={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`},...qn}};var zr=F(Rr,async({positionals:e,values:t})=>{let[n]=e,{key:r,value:i}=Ce(t,[`before`,`after`]);if(n===i)throw new C(`Cannot reorder "${n}" relative to itself.`);if(n.split(`.`).slice(0,-1).join(`.`)!==i.split(`.`).slice(0,-1).join(`.`))throw new C(`Cannot reorder "${n}" relative to "${i}": fields must be in the same container.`);let{source:a,anchor:o,save:s}=await Jn(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 Br={name:`prismic field view`,description:`View details of a field in a slice or custom type.`,positionals:{id:{description:`Field ID`,required:!0}},options:{...qn,json:{type:`boolean`,description:`Output as JSON`}}};var Vr=F(Br,async({positionals:e,values:t})=>{let[n]=e,{field:r,fieldId:i}=await Yn(n,t);if(t.json)console.info(U({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}`)}}}),Hr=S({name:`prismic field`,description:`
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:`
197
197
  Manage fields in slices and content types.
198
198
 
199
199
  Run \`prismic docs view fields\` for details.
200
- `,commands:{add:{handler:Pr,description:`Add a field`},edit:{handler:Ir,description:`Edit a field`},remove:{handler:Lr,description:`Remove a field`},reorder:{handler:zr,description:`Reorder a field`},view:{handler:Vr,description:`View details of a field`}}}),Ur=F({name:`prismic gen page`,description:`
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:`
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 M(),{model:r}=await n.getCustomType(t);if(r.format!==`page`)throw new C(`"${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 ${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 s=await L();for(let e of o){let t=z(s,e.path);console.info(`${t} already exists. Generated code:\n\n${e.contents}`),console.info(`Merge this into ${t}.\n`)}}),Wr=F({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 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:`
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 M(),n=await H();await t.setupProject();for(let{name:e,from:t,to:r}of Wt(n,await H()))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}`)}),Gr=F({name:`prismic gen slice-index`,description:`Generate the slice index file of each slice library.`},async()=>{let e=await M(),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.`)}),Kr=F({name:`prismic gen types`,description:`Generate TypeScript types for slices and content types.`},async()=>{let e=await(await M()).generateTypes(),t=await L(),n=z(t,e);console.info(`Generated types at ${n}`)}),qr=S({name:`prismic gen`,description:`Generate files from local Prismic models.`,commands:{page:{handler:Ur,description:`Generate the page files for a page type`},setup:{handler:Wr,description:`Generate framework-specific Prismic setup`},"slice-index":{handler:Gr,description:`Generate the slice index file of each slice library`},types:{handler:Kr,description:`Generate TypeScript types from local models`}}});async function Z(e,t){let{completedSteps:n}=await Xe(t),r=e.filter(e=>!n.includes(e));for(let e of r)await ye(e,t)}let Q;const $={tags:{},contexts:{}};function Jr(e){Q=e,$.contexts.Process={command:process.argv.join(` `),cwd:process.cwd()}}function Yr(e,t){$.tags[e]=t}function Xr(e,t){$.contexts[e]=t}function Zr(e){$.user=e}async function Qr(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||$r(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:ti(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(ei(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 $r(e){let t=e.match(/-(.+?)\./);return t?t[1]:`production`}function ei(e){return`${e.protocol}//${e.host}/api${e.pathname}/envelope/`}function ti(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 ni={name:`prismic repo create`,description:`
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:`
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: ${I.join(`, `)} (default: detected from the project)`}}};var ri=F(ni,async({values:e})=>{let t=await M().catch(()=>void 0),{name:n,lang:r,framework:i=t?.id}=e;if(!i)throw new C(`
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(`
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 <${I.join(`|`)}> to create the repository now.
225
+ - Pass --framework <${lt.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(!I.includes(i))throw new C(`Unsupported framework "${i}". Use one of: ${I.join(`, `)}.`);let a=await D(),o=await ii({name:n,lang:r,framework:i,host:a});console.info(`Repository created: ${o}`),console.info(`URL: https://${o}.${a}/`)});async function ii(e){let{name:t,lang:n=`en-us`,framework:r,host:i}=e,a=await ai(i);if(!a)throw new C(`Failed to create a repository. Please try again.`);let o=mt();return await Ne({domain:a,name:t??a,framework:r,agent:o,getToken:g,host:i,onUnauthorized:P}),await be({id:n,isMaster:!0},{repo:a,getToken:g,host:i,onUnauthorized:P}),await Z([`createPrismicProject`],{repo:a,getToken:g,host:i,onUnauthorized:P}).catch(()=>{}),a}async function ai(e){let t;for(let n=0;n<5;n++){let n=crypto.randomUUID().replace(/-/g,``).slice(0,8);if(await pt({domain:n,getToken:g,host:e,onUnauthorized:P})){t=n;break}}return t}var oi=F({name:`prismic init`,description:`
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:`
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
@@ -232,73 +232,78 @@ Ending the session...`),await f()&&console.info(`Session ended.`)});async functi
232
232
 
233
233
  Use --repo to connect to an existing repository instead. If a
234
234
  slicemachine.config.json exists, its repository and settings will be
235
- migrated.
235
+ migrated. Otherwise, init creates a new repository, even if the project
236
+ used another one before. If a prismic.config.json exists, init requires
237
+ --repo.
236
238
 
237
239
  Run \`prismic docs view cli#set-up-a-type-builder-project\` for details.
238
- `,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})=>{O(e,[`repo`,`repo-name`]);let{repo:t,lang:n,"no-browser":r,"no-setup":i}=e,a;try{a=await c()}catch(e){if(!(e instanceof $e))throw e}if(a&&!t)throw new C(`
240
+ `,agents:`
241
+ Do not ask the user whether to create a new repository or connect an
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(`
239
244
  This project is already set up for Prismic (repository: ${a.repositoryName}).
240
245
 
241
246
  Do one of the following:
242
247
  - Run \`prismic gen setup\` to add missing framework files and install dependencies.
243
248
  - Run \`prismic init --repo <domain>\` to connect the project to a different repository.
244
- `);let o=a!==void 0&&t!==void 0,s;if(!a)try{s=await bt()}catch(e){e instanceof Ie&&console.warn(`Could not read slicemachine.config.json, ignoring.`)}let l=await D();try{await le({getToken:g,host:l})}catch(e){if(e instanceof B||e instanceof G){if(j.PRISMIC_TOKEN)throw e;await ee({browser:!r})}else throw e}let u=(t??s?.repositoryName)?.toLowerCase(),d;u&&(d=await Je({repo:u,getToken:g,host:l}).catch(e=>{throw e instanceof G?new C(`Repository "${u}" not found in your account. Check the name or request access to the repository.`):e}));let f;try{f=await M()}catch(e){throw e instanceof De||e instanceof Gt?new C(`
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(`
245
250
  No supported framework found. \`prismic init\` needs a Next.js, Nuxt, or SvelteKit project.
246
251
 
247
252
  Do one of the following:
248
253
  - Run this command inside an existing Next.js, Nuxt, or SvelteKit project.
249
254
  - Create the project first, then run \`prismic init\` again.
250
- - To create the repository now, run \`prismic repo create --framework <${I.join(`|`)}>\`.
255
+ - To create the repository now, run \`prismic repo create --framework <${lt.join(`|`)}>\`.
251
256
  Connect the project later with \`prismic init --repo <domain>\`.
252
- `):e}let p=j.PRISMIC_TYPE_BUILDER_ENABLED??d?.quotas?.sliceMachineEnabled;if(u&&d&&(!p||d.framework!==f.id))try{await St(f.id,{repo:u,getToken:g,host:l}),p||console.info(`Turned on the Type Builder for repository "${u}".`)}catch(e){if(!(e instanceof G))throw e;if(!p)throw new C(`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 ii({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 me({repositoryName:u,documentAPIEndpoint:e}):await vt({repositoryName:u,documentAPIEndpoint:e,libraries:s?.libraries,routes:[]})}catch(e){throw e instanceof Ve?new C(`Could not find a package.json file. Run this command from a project directory.`):new C(`Failed to create prismic.config.json.`)}if(s){try{await Ct()}catch{}let{dependencies:e,devDependencies:t,peerDependencies:n}=await H(),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 h=await H();await f.initProject({setup:!i&&!a});for(let{name:e,from:t,to:n}of Wt(h,await H()))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([w({repo:u,getToken:g,host:l}),f.getModels()]),y=m(_,v);if(o&&d?.starter){if(_.customTypes.length===0&&_.slices.length===0)throw new C(`Repository "${u}" has no starter models. Use a repository created from the starter in the Prismic dashboard.`);await li(d.starter)}let x=o&&[y.customTypes,y.slices].some(e=>e.update.length>0||e.delete.length>0);if(!x)for(let e of await f.writeModels(y))console.info(e);await f.generateTypes(),await Z([`connectPrismic`],{repo:u,getToken:g,host:l}).catch(()=>{}),b(_.customTypes).length>0&&console.info("\nRun `prismic slice list --legacy` to find legacy slices to upgrade."),x&&console.warn(Te`
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`
253
258
  Local and remote models differ, so no model files were changed. The project is connected.
254
259
 
255
260
  Choose the source of truth:
256
261
  prismic pull --force Adopt remote models
257
262
  prismic push --force Keep local models
258
- `),o&&d?.starter?(await ci(f,d.starter,{repo:u,getToken:g,host:l}),x||(console.info(`
263
+ `),o&&d?.starter?(await ui(f,d.starter,{repo:u,getToken:C,host:l}),x||(console.info(`
259
264
  ---`),console.info(`
260
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(`
261
266
  Start building 🚀`))):(console.info(`
262
- ---`),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 si(e){let t=await H(),n=e.id.split(`/`).at(-1);return!!(n&&t.name===n)}async function ci(e,t,n){try{let{results:t}=await a(n);await Promise.all(t.filter(e=>e.label===`Starter Preview`).map(e=>Be(e.id,n))),t.some(t=>t.url===e.localPreviewUrl)||await ot(e.localPreviewConfig,n)}catch(t){await Qr(t),console.error(`Could not configure the local preview. Run \`prismic preview add ${e.localPreviewUrl} --name ${e.localPreviewConfig.name}\` manually. Continuing.`)}try{await s(e.localSimulatorUrl,n)}catch(t){await Qr(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 si(t)&&await Rt(n.repo)}async function li(e){if(!await si(e))return;let t=await L();await Promise.all([$t(new URL(`.deployment`,t),{recursive:!0,force:!0}),$t(new URL(`documents`,t),{recursive:!0,force:!0})])}var ui=F({name:`prismic locale add`,description:`
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:`
263
268
  Add a locale to a Prismic repository.
264
269
 
265
270
  By default, this command reads the repository from prismic.config.json at the
266
271
  project root.
267
- `,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 A(),master:a=!1,name:o}=t,s=await D();await be({id:n,isMaster:a,customName:o},{repo:i,getToken:g,host:s,onUnauthorized:P}),console.info(`Locale added: ${n}`)}),di=F({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 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:`
268
273
  List all locales in a Prismic repository.
269
274
 
270
275
  By default, this command reads the repository from prismic.config.json at the
271
276
  project root.
272
- `,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 A(),json:i}=e,a=await D(),{results:o}=await d({repo:n,getToken:g,host:a,onUnauthorized:P});if(i){console.info(U(o));return}if(o.length===0){console.info(`No locales found.`);return}let s=o.map(e=>{let t=e.isMaster?` (master)`:``;return[e.id,`${e.label}${t}`]});console.info(r(s,{headers:[`ID`,`LABEL`]}))}),fi=F({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 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:`
273
278
  Remove a locale from a Prismic repository.
274
279
 
275
280
  By default, this command reads the repository from prismic.config.json at the
276
281
  project root.
277
- `,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 A()}=t,a=await D();await et(n,{repo:i,getToken:g,host:a,onUnauthorized:P}),console.info(`Locale removed: ${n}`)}),pi=F({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 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:`
278
283
  Set the master locale for a Prismic repository.
279
284
 
280
285
  By default, this command reads the repository from prismic.config.json at the
281
286
  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 A()}=t,a=await D(),{results:o}=await d({repo:i,getToken:g,host:a,onUnauthorized:P}),s=o.find(e=>e.id===n);if(!s)throw new C(`Locale "${n}" not found. Available locales: ${o.map(e=>e.id).join(`, `)}`);if(s.isMaster)throw new C(`Locale "${n}" is already the master.`);await be({id:s.id,isMaster:!0,customName:s.customName??void 0},{repo:i,getToken:g,host:a,onUnauthorized:P}),console.info(`Master locale set: ${n}`)}),mi=S({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 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:`
283
288
  Manage locales in a Prismic repository.
284
289
 
285
290
  Run \`prismic docs view locales\` for details.
286
- `,commands:{add:{handler:ui,description:`Add a locale`},list:{handler:di,description:`List locales`},remove:{handler:fi,description:`Remove a locale`},"set-master":{handler:pi,description:`Set the master locale`}}}),hi=F({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 te({browser:!e[`no-browser`]})}),gi=F({name:`prismic logout`,description:`Log out of Prismic.`},async()=>{let e=!1;await at(async t=>{try{let t=(await Ge()).login?.session;t?.refreshToken&&(await je(t.refreshToken,t),e=!0)}catch(e){if(!(e instanceof nt||e instanceof ft))throw e;console.warn(`Couldn't revoke your session because ${_i(e)}. It stays valid until it expires.`)}await ut(t),await Se()}),Fe({revoked:e}),j.PRISMIC_TOKEN&&console.warn(`PRISMIC_TOKEN is still set, so commands still use it.`),console.info(`Logged out of Prismic`)});function _i(e){return e instanceof nt?`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 vi=F({name:`prismic preview add`,description:`
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:`
287
292
  Add a preview configuration to a Prismic repository.
288
293
 
289
294
  By default, this command reads the repository from prismic.config.json at the
290
295
  project root.
291
- `,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 A(),name:a}=t,o;try{o=new URL(n)}catch{throw new C(`Invalid URL: ${n}`)}let s=a||o.hostname,c=`${o.protocol}//${o.host}`,l=o.pathname===`/`?void 0:o.pathname,u=await D();await ot({name:s,websiteURL:c,resolverPath:l},{repo:i,getToken:g,host:u,onUnauthorized:P}),console.info(`Preview added: ${n}`),console.info("Run `prismic preview set-simulator <url>` to set the slice simulator URL.");try{let e=await(await M()).getSetupInstructions();e&&console.info(`\n${e}`)}catch(e){if(!(e instanceof De||e instanceof Gt))throw e}}),yi=F({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 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:`
292
297
  List all preview configurations in a Prismic repository.
293
298
 
294
299
  By default, this command reads the repository from prismic.config.json at the
295
300
  project root.
296
- `,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 A(),json:i}=e,o=await D(),[{results:s},{simulator_url:c}]=await Promise.all([a({repo:n,getToken:g,host:o,onUnauthorized:P}),ae({repo:n,getToken:g,host:o,onUnauthorized:P})]);if(i)console.info(U({previews:s,simulatorUrl:c??null}));else if(s.length===0&&!c)console.info(`No preview configurations found.`);else{if(s.length>0){let e=s.map(e=>[e.url,e.label]);console.info(r(e,{headers:[`URL`,`NAME`]}))}c&&(s.length>0&&console.info(``),console.info(`Simulator: ${c}`))}}),bi=F({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 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:`
297
302
  Remove a preview configuration from a Prismic repository.
298
303
 
299
304
  By default, this command reads the repository from prismic.config.json at the
300
305
  project root.
301
- `,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 A()}=t,o=await D(),{results:s}=await a({repo:i,getToken:g,host:o,onUnauthorized:P}),c=s.find(e=>e.url===n);if(!c)throw new C(`Preview not found: ${n}`);await Be(c.id,{repo:i,getToken:g,host:o,onUnauthorized:P}),console.info(`Preview removed: ${n}`)}),xi=F({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 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:`
302
307
  Set the slice simulator URL for a Prismic repository.
303
308
 
304
309
  If the URL pathname does not end with /slice-simulator, it is appended
@@ -306,7 +311,7 @@ Start building 🚀`))):(console.info(`
306
311
 
307
312
  By default, this command reads the repository from prismic.config.json at the
308
313
  project root.
309
- `,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 A()}=t,a;try{a=new URL(n)}catch{throw new C(`Invalid URL: ${n}`)}a.pathname.endsWith(`/slice-simulator`)||(a.pathname=a.pathname.replace(/\/+$/,``)+`/slice-simulator`);let o=a.toString(),c=await D();await s(o,{repo:i,getToken:g,host:c,onUnauthorized:P}),console.info(`Simulator URL set: ${o}`)}),Si=S({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 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:`
310
315
  Manage previews in a Prismic repository.
311
316
 
312
317
  Run \`prismic docs view previews\` for details.
@@ -314,15 +319,15 @@ Start building 🚀`))):(console.info(`
314
319
  Set up previews after a deploy, using both settings:
315
320
  prismic preview add https://example.com/api/preview
316
321
  prismic preview set-simulator https://example.com
317
- `},commands:{add:{handler:vi,description:`Add a preview URL`},list:{handler:yi,description:`List preview URLs and the simulator URL`},remove:{handler:bi,description:`Remove a preview URL`},"set-simulator":{handler:xi,description:`Set the slice simulator URL`}}});async function Ci(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 wi(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(`
318
- `)){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 Ti=F({name:`prismic pull`,description:`
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:`
319
324
  Pull content types and slices from Prismic to local files.
320
325
 
321
326
  Remote models are the source of truth. Local files are created, updated,
322
327
  or deleted to match.
323
328
 
324
329
  Run \`prismic docs view cli#pull-models-from-prismic\` for details.
325
- `,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 M(),{force:n=!1,env:r,repo:i=r??await t.getEnvironment()??await E()}=e,a=await D(),o=await L();console.info(`Pulling from repository: ${i}`);let[s,c,l]=await Promise.all([Ci(o),t.getCustomTypeLibraries(),t.getSliceLibraries()]);if(!n&&s){let e=(await wi(s)).filter(e=>e.pathname.endsWith(`/model.json`)&&l.some(t=>R(t,e))||e.pathname.endsWith(`/index.json`)&&c.some(t=>R(t,e))).map(e=>z(o,e));if(e.length>0)throw new C(`
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(`
326
331
  Local model files have uncommitted changes. Prismic keeps model history in
327
332
  git. Commit model changes before you pull them, so this pull can't discard
328
333
  your edits:
@@ -334,7 +339,7 @@ Start building 🚀`))):(console.info(`
334
339
  Other options:
335
340
  prismic push --force Keep local edits, overwrite remote
336
341
  prismic pull --force Discard local edits, adopt remote
337
- `)}let[u,d,f]=await Promise.all([t.getCustomTypes(),t.getSlices(),w({repo:i,getToken:g,host:a,onUnauthorized:P})]),p=m(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=>z(o,e.modelPath));if(n.length>0)throw new C(`
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(`
338
343
  Pull would modify or delete local model files:
339
344
  ${n.join(`
340
345
  `)}
@@ -342,7 +347,7 @@ Start building 🚀`))):(console.info(`
342
347
  This project isn't in a git repo, so changes can't be tracked. Choose one:
343
348
  prismic pull --force Discard local files, adopt remote
344
349
  prismic push --force Keep local files, overwrite remote
345
- `)}let h=await t.writeModels(p);await t.generateTypes(),await Z([`connectPrismic`],{repo:await E(),getToken:g,host:a,onUnauthorized:P}).catch(()=>{});let _=p.customTypes.insert.length+p.customTypes.update.length,v=p.slices.insert.length+p.slices.update.length,y=p.customTypes.delete.length+p.slices.delete.length;for(let e of h)console.info(e);_===0&&v===0&&y===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`))}),Ei=F({name:`prismic push`,description:`
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:`
346
351
  Push local content types and slices to Prismic.
347
352
 
348
353
  Local models are the source of truth. Remote models are created,
@@ -353,7 +358,7 @@ Start building 🚀`))):(console.info(`
353
358
  Deleting a remote model needs --force.
354
359
 
355
360
  Run \`prismic docs view cli#push-models-to-prismic\` for details.
356
- `,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 M(),{force:n=!1,env:r,repo:i=r??await t.getEnvironment()??await E()}=e,a=await D(),o=await L();console.info(`Pushing to repository: ${i}`);let[s,c,l]=await Promise.all([Ci(o),t.getCustomTypeLibraries(),t.getSliceLibraries()]);if(!n&&s){let e=(await wi(s)).filter(e=>e.pathname.endsWith(`/model.json`)&&l.some(t=>R(t,e))||e.pathname.endsWith(`/index.json`)&&c.some(t=>R(t,e))).map(e=>z(o,e));if(e.length>0)throw new C(`
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(`
357
362
  Local model files have uncommitted changes. Prismic keeps model history in
358
363
  git. Commit model changes before you push them:
359
364
 
@@ -362,50 +367,50 @@ Start building 🚀`))):(console.info(`
362
367
  prismic push
363
368
 
364
369
  Or skip the check with \`prismic push --force\`.
365
- `)}let[u,d]=await Promise.all([t.getModels(),w({repo:i,getToken:g,host:a,onUnauthorized:P})]),f=m(u,d);if(!n){let e=Ht(c[0]),t=Ht(l[0]),n=[...f.customTypes.delete.map(t=>z(o,new URL(`${t.id}/index.json`,e))),...f.slices.delete.map(e=>z(o,new URL(`${He(e.name)}/model.json`,t)))];if(n.length>0)throw new C(`
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(`
366
371
  Push would delete remote models. Re-run with --force to proceed.
367
372
 
368
373
  Models that would be deleted:
369
374
  ${n.join(`
370
375
  `)}
371
- `)}try{await ve(f,{repo:i,getToken:g,host:a,onUnauthorized:P})}catch(e){throw await Oi(e,f.customTypes.delete,{repo:i,getToken:g,host:a,onUnauthorized:P})}for(let{id:e}of f.slices.delete)await yt(e,{repo:i,getToken:g,host:a,onUnauthorized:P}).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 E(),getToken:g,host:a,onUnauthorized:P}).catch(()=>{});let h=f.customTypes.insert.length+f.customTypes.update.length,_=f.slices.insert.length+f.slices.update.length,v=f.customTypes.delete.length+f.slices.delete.length;h===0&&_===0&&v===0?console.info(`Already up to date.`):(console.info(`Pushed ${h} type(s), ${_} slice(s).`),v>0&&console.info(`Deleted ${v} model(s).`))});const Di=W({hasExistingDocuments:At(!0)});async function Oi(e,t,n){if(!(e instanceof G)||!Vt(Di,e.body).success)return e;let{repo:r,host:i}=n;for(let{id:e}of t){let t=ki({repo:r,host:i,customTypeId:e}),a;try{a=(await he(e,n)).total}catch{return new C(`Could not check whether type "${e}" has associated pages.
372
- Please try again, or manually delete any associated pages at: `+t)}if(a!==0)return new C(`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 ki(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 Ai=F({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 D(),{repositories:i}=await h({getToken:g,host:n,onUnauthorized:P});if(t){console.info(U(i.map(e=>({domain:e.domain,name:e.name??null,role:e.role??null,url:`https://${e.domain}.${n}/`}))));return}if(i.length===0){console.info(`No repositories found.`);return}let a=i.map(e=>{let t=e.name||`(no name)`;return[e.domain,t,ji(e.role)]});console.info(r(a,{headers:[`DOMAIN`,`NAME`,`ROLE`]}))});function ji(e){return typeof e==`string`?e:e?Object.entries(e).map(([e,t])=>`${t} (${e})`).join(`, `):``}const Mi=[`private`,`public`,`open`],Ni={name:`prismic repo set-api-access`,description:`
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:`
373
378
  Set the Content API access level of a Prismic repository.
374
379
 
375
380
  By default, this command reads the repository from prismic.config.json at the
376
381
  project root.
377
382
 
378
383
  Run \`prismic docs view repository-settings#configuration\` for details.
379
- `,positionals:{level:{description:`Access level (${Mi.join(`, `)})`,required:!0}},options:{repo:{type:`string`,short:`r`,description:`Repository domain`}}};var Pi=F(Ni,async({positionals:e,values:t})=>{let[n]=e,{repo:r=await E()}=t;if(!Mi.includes(n))throw new C(`Invalid access level: ${n}. Must be one of: ${Mi.join(`, `)}`);let i=await D();await fe(n,{repo:r,getToken:g,host:i,onUnauthorized:P}),console.info(`Repository access set to: ${n}`)}),Fi=F({name:`prismic repo set-name`,description:`
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:`
380
385
  Set the display name of a Prismic repository.
381
386
 
382
387
  By default, this command reads the repository from prismic.config.json at the
383
388
  project root.
384
- `,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 E()}=t,i=await D(),{repository:a}=await Et(n,{repo:r,getToken:g,host:i,onUnauthorized:P});console.info(`Repository name set to: ${a.name}`)}),Ii=F({name:`prismic repo view`,description:`
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:`
385
390
  View details of a Prismic repository.
386
391
 
387
392
  By default, this command reads the repository from prismic.config.json at the
388
393
  project root.
389
- `,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 E(),web:n,json:r}=e,i=await D(),a=`https://${t}.${i}/`;if(n){Pe(new URL(a)),console.info(`Opening ${a}`);return}let[o,s]=await Promise.all([Je({repo:t,getToken:g,host:i,onUnauthorized:P}),re({repo:t,getToken:g,host:i,onUnauthorized:P}).catch(e=>{if(!sn(e))throw e})]);if(r){console.info(U({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)`}`)}),Li=S({name:`prismic repo`,description:`
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:`
390
395
  Manage Prismic repositories.
391
396
 
392
397
  Run \`prismic docs view repository-settings\` for details.
393
- `,commands:{create:{handler:ri,description:`Create a new repository`},list:{handler:Ai,description:`List repositories`},view:{handler:Ii,description:`View repository details`},"set-name":{handler:Fi,description:`Set repository display name`},"set-api-access":{handler:Pi,description:`Set Content API access level`}}}),Ri=F({name:`prismic slice add-variation`,description:`
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:`
394
399
  Add a variation to a slice.
395
400
 
396
401
  Run \`prismic docs view slices#slice-variations\` for details.
397
- `,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=ct(n),screenshot:a}=t,o=await M(),{model:s}=await o.getSlice(r);if(s.variations.some(e=>e.id===i))throw new C(`Variation "${i}" already exists in slice "${r}".`);let c=``;if(a){let e=await E(),t=await D(),n=/^https?:\/\//i.test(a)?new URL(a):tn(a),r=await qt(n);c=(await _e(r,{sliceId:s.id,variationId:i,repo:e,getToken:g,host:t,onUnauthorized:P})).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}"`)}),zi=F({name:`prismic slice connect`,description:`Connect a slice to a type's slice zone.`,sections:{EXAMPLES:`
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:`
398
403
  Connect a slice to a type's default slice zone:
399
404
  prismic slice connect hero --to blog_post
400
405
 
401
406
  Connect to a named slice zone:
402
407
  prismic slice connect hero --to blog_post --slice-zone page_slices
403
- `},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 M(),{model:o}=await a.getSlice(n),{model:s}=await a.getCustomType(r),c=Object.assign({},...Object.values(s.json))[i];if(!c||c.type!==`Slices`)throw new C(`Slice zone "${i}" not found in "${r}".`);if(c.config??={},c.config.choices??={},o.id in c.config.choices)throw new C(`Slice "${o.id}" is already connected to "${r}" in slice zone "${i}".`);c.config.choices[o.id]={type:`SharedSlice`},await a.updateCustomType(s),await a.generateTypes(),console.info(`Connected slice "${n}" to "${r}"`)}),Bi=F({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=ze(n)}=t,i={id:r,name:n,type:`SharedSlice`,variations:[{id:`default`,name:`Default`,description:`Default`,docURL:``,imageUrl:``,version:``,primary:{}}]},a=await M();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.`)}),Vi=F({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 M(),{model:o}=await a.getSlice(n),{model:s}=await a.getCustomType(r),c=Object.assign({},...Object.values(s.json))[i];if(!c||c.type!==`Slices`)throw new C(`Slice zone "${i}" not found in "${r}".`);if(!c.config?.choices||!(o.id in c.config.choices))throw new C(`Slice "${o.id}" is not connected to "${r}" in slice zone "${i}".`);delete c.config.choices[o.id],await a.updateCustomType(s),await a.generateTypes(),console.info(`Disconnected slice "${n}" from "${r}"`)}),Hi=F({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 M(),{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})`)}),Ui=F({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 M(),{model:o}=await a.getSlice(r),s=o.variations.find(e=>e.id===n);if(!s)throw new C(`Variation "${n}" not found in slice "${r}".`);if(`name`in t&&(s.name=t.name),i){let e=await E(),t=await D(),n=/^https?:\/\//i.test(i)?new URL(i):tn(i),r=await qt(n);s.imageUrl=(await _e(r,{sliceId:o.id,variationId:s.id,repo:e,getToken:g,host:t,onUnauthorized:P})).toString()}await a.updateSlice(o),await a.generateTypes(),console.info(`Variation updated: "${n}" in slice "${r}"`)}),Wi=F({name:`prismic slice list`,description:`
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:`
404
409
  List all slices.
405
410
 
406
411
  Legacy slices from the Legacy Builder are marked with * and show the type
407
412
  that defines them.
408
- `,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,i=await M(),a=t?[]:(await i.getSlices()).map(e=>e.model),o=(await i.getCustomTypes()).map(e=>e.model),s=b(o);if(n&&t){let e=s.map(e=>({id:e.id,definedIn:e.customTypeId,sliceZone:e.sliceZoneId}));console.info(U(e));return}if(n){console.info(U(a));return}if(a.length===0&&s.length===0){console.info(t?`No legacy slices found.`:`No slices found.`);return}let c=[...a.map(e=>[e.name,e.id,``]),...s.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(r(c,{headers:[`NAME`,`ID`,`DEFINED IN`]})),s.length>0&&console.info("\n* Legacy slice. Run `prismic slice upgrade-legacy --help` to upgrade it.")}),Gi=F({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 M();await n.deleteSlice(t),await n.generateTypes(),console.info(`Slice removed: ${t}`)}),Ki=F({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 M(),{model:a}=await i.getSlice(r),o=a.variations.find(e=>e.id===n);if(!o)throw new C(`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}"`)}),qi=F({name:`prismic slice upgrade-legacy`,description:`
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:`
409
414
  Upgrade a legacy slice from the Legacy Builder.
410
415
 
411
416
  The CLI and the Type Builder cannot edit legacy slices. Run
@@ -432,47 +437,47 @@ Please try again, or manually delete any associated pages at: `+t)}if(a!==0)retu
432
437
 
433
438
  Merge a legacy slice into an existing variation with the same fields:
434
439
  prismic slice upgrade-legacy hero --from landing_page --to hero --variation default
435
- `},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 M(),c=(await s.getCustomTypes()).map(e=>e.model),l=(await s.getSlices()).map(e=>e.model),u=b(c),d=c.find(e=>e.id===r);if(!d)throw new C(`Type "${r}" not found.`);let f=u.find(e=>e.customTypeId===r&&e.sliceZoneId===i&&e.id===n);if(!f)throw new C(`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??ze(n),h=f.sliceZone.config?.choices?.[m];if(m!==n&&h&&h.type!==`SharedSlice`)throw new C(`The "${i}" slice zone of "${r}" also has legacy slice "${m}". Upgrade it first.`);let g=l.find(e=>e.id===m),_=ct(o??(g?n:`default`)),v=Xi(f,_),y;if(g){if(!a)throw new C(Ji(g,f,v));let e=g.variations.find(e=>e.id===_);if(e&&!Zi(e,v))throw new C(`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:He(a??t??m),legacyPaths:{[p]:_},variations:[v]},y=`Upgraded legacy slice "${n}" to slice "${m}"`,await s.createSlice(g)}Qi(f,g.id),await s.updateCustomType(d),await s.generateTypes();let{directory:x}=await s.getSlice(g.id),ee=z(await L(),x),S=u.length-1;console.info(y),console.info(`After \`prismic push\`: ${Yi(f,m,_)}`),console.info(`Update the component in ${ee}, 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 Ji(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=>Zi(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(`
436
- `)}function Yi(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 Xi(e,t){let{model:n}=e,r=t==="default"?`Default`:He(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 Zi(e,t){return Xt(e.primary??{},t.primary??{})&&Xt(e.items??{},t.items??{})}function Qi({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 $i=F({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 M()).getSlice(n);if(r)console.info(U(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($n(e.primary??{}))}}),ea=S({name:`prismic slice`,description:`
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:`
437
442
  Manage slices.
438
443
 
439
444
  Run \`prismic docs view slices\` for details.
440
- `,commands:{create:{handler:Bi,description:`Create a new slice`},edit:{handler:Hi,description:`Edit a slice`},remove:{handler:Gi,description:`Remove a slice`},list:{handler:Wi,description:`List slices`},view:{handler:$i,description:`View a slice`},connect:{handler:zi,description:`Connect a slice to a type's slice zone`},disconnect:{handler:Vi,description:`Disconnect a slice from a type's slice zone`},"upgrade-legacy":{handler:qi,description:`Upgrade a legacy slice`},"add-variation":{handler:Ri,description:`Add a variation to a slice`},"edit-variation":{handler:Ui,description:`Edit a variation of a slice`},"remove-variation":{handler:Ki,description:`Remove a variation from a slice`}}}),ta=F({name:`prismic status`,description:`
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:`
441
446
  Show local vs remote model differences.
442
447
 
443
448
  Reports what would be pushed to or pulled from Prismic, plus any local
444
449
  model files with uncommitted git changes that must be committed before
445
450
  pull and push.
446
- `,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 M(),n=await E(),r=await t.getEnvironment(),{env:i,repo:a=i??r??n}=e,o=await D(),s=await g(),c=await L(),[l,u,d,f]=await Promise.all([Ci(c),t.getCustomTypeLibraries(),t.getSliceLibraries(),t.getModels()]),p,h;if(s){let[e,t]=await Promise.all([_(s,{host:o}),w({repo:a,getToken:g,host:o})]);p=e.type===`USER`?e.email:`${e.appName} (Write API token for ${e.domain})`,h=m(f,t)}let y=[];l&&(y=(await wi(l)).filter(e=>e.pathname.endsWith(`/model.json`)&&d.some(t=>R(t,e))||e.pathname.endsWith(`/index.json`)&&u.some(t=>R(t,e))).map(e=>z(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 x=b(f.customTypes).length;x>0&&console.info(`\n${x} legacy ${x===1?`slice needs`:`slices need`} upgrading. Run \`prismic slice list --legacy\`.`);let ee=h!==void 0&&!v(h.customTypes)&&!v(h.slices);if(ee&&y.length===0){console.info(``),console.info(`Already up to date.`);return}if(h){let e=[],t=[...h.customTypes.insert.map(e=>` ${e.id} (custom type)`),...h.slices.insert.map(e=>` ${e.id} (slice)`)];t.length>0&&e.push([`Local-only:`,...t]);let n=[...h.customTypes.delete.map(e=>` ${e.id} (custom type)`),...h.slices.delete.map(e=>` ${e.id} (slice)`)];n.length>0&&e.push([`Remote-only:`,...n]);let r=[...h.customTypes.update.map(e=>` ${e.id} (custom type)`),...h.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 S=[];if(y.length>0&&(console.info(``),console.info(`Prismic keeps model history in git. Commit model changes before you push or pull them.`),S.push(`git add ${y.join(` `)}`),S.push(`git commit -m "Update Prismic models"`)),h&&!ee){let e=h.customTypes.insert.length+h.slices.insert.length,t=h.customTypes.update.length+h.slices.update.length,n=h.customTypes.delete.length+h.slices.delete.length;S.push(`prismic push # creates ${e}, updates ${t}, deletes ${n}`),S.push(`prismic pull # creates ${n}, updates ${t}, deletes ${e}`)}if(S.length>0){console.info(``),console.info(`Next:`);for(let e of S)console.info(` ${e}`)}});const na=j.PRISMIC_SYNC_POLL_MS??5e3;var ra=F({name:`prismic sync`,description:`
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:`
447
452
  Watch Prismic and continuously pull changes to local files.
448
453
 
449
454
  For one-time pulls, use \`prismic pull\`.
450
- `,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 M(),{env:n,repo:r=n??await t.getEnvironment()??await E()}=e,i=await D();rt(`sync`,{watch:!0}),process.on(`SIGINT`,()=>{console.info(`
451
- Watch stopped. Goodbye!`),ht(),process.exit(0)}),console.info(`Watching repository: ${r} (polling every ${na/1e3}s, Ctrl+C to stop)`);let a,o=0;for(;;){try{let e=await w({repo:r,getToken:g,host:i,onUnauthorized:P}),n=a&&m(e,a);if(!n||v(n.customTypes)||v(n.slices)){let r=!n,o=m(e,await t.getModels(),{treatNonCanonicalAsChanged:!0});for(let e of await t.writeModels(o))console.info(e);let s=[...v(o.slices)?[`slices`]:[],...v(o.customTypes)?[`custom types`]:[]];if((r||s.length>0)&&await t.generateTypes(),a=e,r)await Z([`connectPrismic`],{repo:await E(),getToken:g,host:i,onUnauthorized:P}).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 C(`Too many consecutive errors (5), stopping watch.`)}await an(na)}});const ia=`0123456789abcdefghjkmnpqrstvwxyz`,aa=RegExp(`^pt_[${ia}]{16}$`);function oa(){let e=`pt_`;for(let t of rn(16))e+=ia[t&31];return e}function sa(e){return aa.test(e)}var ca=F({name:`prismic task-id`,description:`
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:`
452
457
  Print a task ID for --task-id.
453
458
 
454
459
  One ID covers one user request: pass it on every command for that request,
455
460
  and run this again when the user asks for something else.
456
- `},async()=>{console.info(oa())});const la=`Prismic CLI`;var ua=F({name:`prismic token create`,description:`
461
+ `},async()=>{console.info(ca())});const da=`Prismic CLI`;var fa=S({name:`prismic token create`,description:`
457
462
  Create a new API token for a Prismic repository.
458
463
 
459
464
  By default, this command reads the repository from prismic.config.json at the
460
465
  project root.
461
- `,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: "${la}")`},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 A(),write:r,"allow-releases":i,name:a=la,json:o}=e;if(r&&i)throw new C(`--allow-releases is only valid for access tokens (not with --write)`);let s=await D(),c,l;if(r)c=(await lt(a,{repo:n,getToken:g,host:s,onUnauthorized:P})).token;else{l=i?`master+releases`:`master`;let e=(await se({repo:n,getToken:g,host:s,onUnauthorized:P})).find(e=>e.name===a);e||=await Me(a,{repo:n,getToken:g,host:s,onUnauthorized:P}),c=(await Qe(e.id,l,{repo:n,getToken:g,host:s,onUnauthorized:P})).token}console.info(o?U({token:c,type:r?`write`:`access`,name:a,repository:n,...l?{scope:l}:{}}):`Token created: ${c}`)}),da=F({name:`prismic token delete`,description:`
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:`
462
467
  Delete a token from a Prismic repository.
463
468
 
464
469
  By default, this command reads the repository from prismic.config.json at the
465
470
  project root.
466
- `,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 A()}=t,a=await D(),[o,s]=await Promise.all([se({repo:i,getToken:g,host:a,onUnauthorized:P}),ne({repo:i,getToken:g,host:a,onUnauthorized:P})]),c=o.flatMap(e=>e.wroom_auths).find(e=>e.token===n);if(c){await Ue(c.id,{repo:i,getToken:g,host:a,onUnauthorized:P}),console.info(`Token deleted`);return}let l=s.tokens.find(e=>e.token===n);if(l)await Ae(l.token,{repo:i,getToken:g,host:a,onUnauthorized:P}),console.info(`Token deleted`);else throw new C(`Token not found: ${n}`)}),fa=F({name:`prismic token list`,description:`
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:`
467
472
  List all API tokens for a Prismic repository.
468
473
 
469
474
  By default, this command reads the repository from prismic.config.json at the
470
475
  project root.
471
- `,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 A(),json:i}=e,a=await D(),[o,s]=await Promise.all([se({repo:n,getToken:g,host:a,onUnauthorized:P}),ne({repo:n,getToken:g,host:a,onUnauthorized:P})]),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(i)console.info(U({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(r(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(r(e))}else console.info(`WRITE TOKENS (none)`)}}),pa=S({name:`prismic token`,description:`
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:`
472
477
  Manage API tokens for a Prismic repository.
473
478
 
474
479
  Run \`prismic docs view repository-settings#configuration\` for details.
475
- `,commands:{list:{handler:fa,description:`List all tokens`},create:{handler:ua,description:`Create a new token`},delete:{handler:da,description:`Delete a token`}}}),ma=F({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 M(),{model:o}=await a.getCustomType(r);if(n in o.json)throw new C(`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}"`)}),ha=F({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:`
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:`
476
481
  custom A non-page type (e.g. settings, navigation, author, blog
477
482
  category). This is the default.
478
483
  page A page type with a URL (e.g. homepage, blog post, landing
@@ -487,11 +492,11 @@ Watch stopped. Goodbye!`),ht(),process.exit(0)}),console.info(`Watching reposito
487
492
 
488
493
  Create with a custom ID:
489
494
  prismic type create "Landing Page" --format page --id landing
490
- `}},async({positionals:e,values:t})=>{let[n]=e,{format:r=`custom`,single:i=!1,id:a=ze(n)}=t;if(r!==`custom`&&r!==`page`)throw new C(`Invalid format: "${r}". Use "custom" or "page".`);let o=await M();if((await o.getCustomTypes()).some(({model:e})=>e.id===a))throw new C(`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.`)}),ga=F({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 C(`Invalid format: "${t.format}". Use "custom" or "page".`);let r=await M(),{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})`)}),_a=F({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 M(),{model:a}=await i.getCustomType(r);if(!(n in a.json))throw new C(`Tab "${n}" not found in "${r}".`);if(`with-slice-zone`in t&&`without-slice-zone`in t)throw new C(`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 C(`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 C(`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 C(`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 C(`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}"`)}),va=F({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 M()).getCustomTypes();if(t){console.info(U(n.map(e=>e.model)));return}if(n.length===0){console.info(`No types found.`);return}let i=n.map(({model:e})=>[e.label||`(no name)`,e.id,e.format??``]);console.info(r(i,{headers:[`NAME`,`ID`,`FORMAT`]}))}),ya=F({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 M();await n.deleteCustomType(t),await n.generateTypes(),console.info(`Type removed: ${t}`)}),ba=F({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 M(),{model:a}=await i.getCustomType(r);if(!(n in a.json))throw new C(`Tab "${n}" not found in "${r}".`);if(Object.keys(a.json).length<=1)throw new C(`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}"`)}),xa=F({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 M()).getCustomType(n);if(r){console.info(U(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($n(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)`}`)}}b([i]).length>0&&console.info("\n* Legacy slice. Run `prismic slice upgrade-legacy --help` to upgrade it.")}),Sa=S({name:`prismic type`,description:`
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:`
491
496
  Manage content types.
492
497
 
493
498
  Run \`prismic docs view content-modeling\` for details.
494
- `,commands:{create:{handler:ha,description:`Create a new content type`},edit:{handler:ga,description:`Edit a content type`},remove:{handler:ya,description:`Remove a content type`},list:{handler:va,description:`List content types`},view:{handler:xa,description:`View a content type`},"add-tab":{handler:ma,description:`Add a tab to a content type`},"edit-tab":{handler:_a,description:`Edit a tab of a content type`},"remove-tab":{handler:ba,description:`Remove a tab from a content type`}}}),Ca=F({name:`prismic webhook create`,description:`
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:`
495
500
  Create a new webhook in a Prismic repository.
496
501
 
497
502
  By default, this command reads the repository from prismic.config.json at the
@@ -514,27 +519,27 @@ Watch stopped. Goodbye!`),ht(),process.exit(0)}),console.info(`Watching reposito
514
519
 
515
520
  Create a named webhook with a secret:
516
521
  prismic webhook create https://example.com/webhook --name "Deploy" --secret my-secret
517
- `}},async({positionals:e,values:t})=>{let[n]=e,{env:r,repo:i=r??await A(),name:a,secret:o,trigger:s=[]}=t;for(let e of s)if(!k.includes(e))throw new C(`Invalid trigger: ${e}\nValid triggers: ${k.join(`, `)}`);let c=await D(),l=!(s.length>0);await Le({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:g,host:c,onUnauthorized:P}),console.info(`Webhook created: ${n}`),console.info(`Run \`prismic webhook set-triggers ${n}\` to configure triggers.`)}),wa=F({name:`prismic webhook disable`,description:`
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:`
518
523
  Disable a webhook in a Prismic repository.
519
524
 
520
525
  By default, this command reads the repository from prismic.config.json at the
521
526
  project root.
522
- `,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 A()}=t,a=await D(),o=(await x({repo:i,getToken:g,host:a,onUnauthorized:P})).find(e=>e.config.url===n);if(!o)throw new C(`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 y(s,c,{repo:i,getToken:g,host:a,onUnauthorized:P}),console.info(`Webhook disabled: ${n}`)}),Ta=F({name:`prismic webhook enable`,description:`
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:`
523
528
  Enable a webhook in a Prismic repository.
524
529
 
525
530
  By default, this command reads the repository from prismic.config.json at the
526
531
  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 A()}=t,a=await D(),o=(await x({repo:i,getToken:g,host:a,onUnauthorized:P})).find(e=>e.config.url===n);if(!o)throw new C(`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 y(s,c,{repo:i,getToken:g,host:a,onUnauthorized:P}),console.info(`Webhook enabled: ${n}`)}),Ea=F({name:`prismic webhook list`,description:`
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:`
528
533
  List all webhooks in a Prismic repository.
529
534
 
530
535
  By default, this command reads the repository from prismic.config.json at the
531
536
  project root.
532
- `,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 A(),json:i}=e,a=await D(),o=await x({repo:n,getToken:g,host:a,onUnauthorized:P});if(i){console.info(U(o.map(e=>e.config)));return}if(o.length===0){console.info(`No webhooks configured.`);return}let s=o.map(e=>{let t=e.config.active?`enabled`:`disabled`,n=e.config.name?` (${e.config.name})`:``;return[`${e.config.url}${n}`,`[${t}]`]});console.info(r(s,{headers:[`URL`,`STATUS`]}))}),Da=F({name:`prismic webhook remove`,description:`
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:`
533
538
  Delete a webhook from a Prismic repository.
534
539
 
535
540
  By default, this command reads the repository from prismic.config.json at the
536
541
  project root.
537
- `,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 A()}=t,a=await D(),o=(await x({repo:i,getToken:g,host:a,onUnauthorized:P})).find(e=>e.config.url===n);if(!o)throw new C(`Webhook not found: ${n}`);let s=o.config._id;await wt(s,{repo:i,getToken:g,host:a,onUnauthorized:P}),console.info(`Webhook removed: ${n}`)}),Oa=F({name:`prismic webhook set-triggers`,description:`
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:`
538
543
  Update which events trigger a webhook.
539
544
 
540
545
  By default, this command reads the repository from prismic.config.json at the
@@ -546,16 +551,16 @@ Watch stopped. Goodbye!`),ht(),process.exit(0)}),console.info(`Watching reposito
546
551
  releasesUpdated When a release is edited or deleted
547
552
  tagsCreated When a tag is created
548
553
  tagsDeleted When a tag is deleted
549
- `}},async({positionals:e,values:t})=>{let[n]=e,{env:r,repo:i=r??await A(),trigger:a=[]}=t;for(let e of a)if(!k.includes(e))throw new C(`Invalid trigger: ${e}\nValid triggers: ${k.join(`, `)}`);let o=await D(),s=(await x({repo:i,getToken:g,host:o,onUnauthorized:P})).find(e=>e.config.url===n);if(!s)throw new C(`Webhook not found: ${n}`);let c=s.config._id;await y(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:g,host:o,onUnauthorized:P}),console.info(`Webhook triggers updated: ${a.join(`, `)}`)}),ka=F({name:`prismic webhook view`,description:`
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:`
550
555
  View details of a webhook in a Prismic repository.
551
556
 
552
557
  By default, this command reads the repository from prismic.config.json at the
553
558
  project root.
554
- `,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 A()}=t,a=await D(),o=(await x({repo:i,getToken:g,host:a,onUnauthorized:P})).find(e=>e.config.url===n);if(!o)throw new C(`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 k)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)`)}),Aa=S({name:`prismic webhook`,description:`
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:`
555
560
  Manage webhooks in a Prismic repository.
556
561
 
557
562
  Run \`prismic docs view webhooks\` for details.
558
- `,commands:{list:{handler:Ea,description:`List all webhooks`},create:{handler:Ca,description:`Create a new webhook`},view:{handler:ka,description:`View webhook details`},remove:{handler:Da,description:`Delete a webhook`},enable:{handler:Ta,description:`Enable a webhook`},disable:{handler:wa,description:`Disable a webhook`},"set-triggers":{handler:Oa,description:`Update webhook triggers`}}}),ja=F({name:`prismic whoami`,description:`Show the currently logged in user.`},async()=>{let e=await D(),t=await _(await g(),{host:e});t.type===`Machine2Machine`?console.info(`${t.appName} (Write API token for ${t.domain})`):console.info(t.email)}),Ma=S({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:`
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:`
559
564
  Pages are page types, built from slices and fields. Content that is
560
565
  not a page is a custom type, such as an author or a navigation menu.
561
566
  A page references a custom type with a content relationship field,
@@ -576,4 +581,4 @@ Watch stopped. Goodbye!`),ht(),process.exit(0)}),console.info(`Watching reposito
576
581
  A repository can hold multiple preview URLs but only one simulator URL,
577
582
  which the Page Builder loads live slice previews from.
578
583
  Run \`prismic docs view previews\` for details.
579
- `},commands:{init:{handler:oi,description:`Initialize a Prismic project`},docs:{handler:zn,description:`Browse Prismic documentation`},gen:{handler:qr,description:`Generate files from local models`},pull:{handler:Ti,description:`Pull types and slices from Prismic`},push:{handler:Ei,description:`Push types and slices to Prismic`},sync:{handler:ra,description:`Sync types and slices from Prismic`},dev:{handler:dn,description:`Edit local models visually in the Type Builder`,hidden:!0},status:{handler:ta,description:`Show local vs remote model differences`},env:{handler:Kn,description:`Manage the active environment`},locale:{handler:mi,description:`Manage locales`},repo:{handler:Li,description:`Manage repositories`},type:{handler:Sa,description:`Manage content types`},field:{handler:Hr,description:`Manage fields`},slice:{handler:ea,description:`Manage slices`},preview:{handler:Si,description:`Manage preview and simulator URLs`},token:{handler:pa,description:`Manage API tokens`},webhook:{handler:Aa,description:`Manage webhooks`},login:{handler:hi,description:`Log in to Prismic`},logout:{handler:gi,description:`Log out of Prismic`},whoami:{handler:ja,description:`Show the currently logged in user`},"task-id":{handler:ca,description:`Print a task ID for --task-id`,hidden:mt()===void 0}}});const Na=[C,f,u,qe,oe,i,Ye,Ke,De,We,it,tt,Hn,st,$e,Ie,Gt,Ve,Pt,kt,B,G,Dt,Ut,ft,nt],Pa=[Dt,Ut];await Fa();async function Fa(){await Yt({npmPackageName:t,statePath:gt}),ge().catch(()=>{});let{positionals:[r=``],values:{version:i,help:a,repo:o=await E().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,m=!a&&r!==``&&r!==`task-id`&&mt()!==void 0?La(p,f):void 0;if(m){let e=p&&sa(p)?p:oa();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;return}if(!a){let e=await D(),t=j.PRISMIC_TOKEN?{}:await Oe(),r=!!(j.PRISMIC_TOKEN||t.expiresAt),i=j.PRISMIC_TELEMETRY_ENABLED??await n(),a=j.PRISMIC_SENTRY_ENABLED??(i&&j.PROD);if(a&&await Ia({host:e,repo:d,userIntent:f,taskId:p}),i&&await ue({host:e,loggedIn:r,repo:d,userIntent:f,taskId:p,store:t.store,storeReason:t.storeReason}),r&&(a||i)){let t=we();t?Zr({id:t}):le({getToken:g,host:e}).then(e=>{dt(e),Zr({id:e.shortId})}).catch(()=>{})}}let h=!a&&r&&r!==`sync`;try{h&&rt(r),await Ma(),h&&ht()}catch(e){process.exitCode=1;let t=await ln(e).catch(()=>void 0);if(h&&ht({error:t??e}),Na.some(t=>e instanceof t))console.error(t),Ra(e)&&await Qr(e);else throw console.error(`The CLI reached a bug. Report this if it keeps happening: https://github.com/prismicio/cli/issues`),await Qr(e),e}}async function Ia(n){let{host:r,repo:i,userIntent:a,taskId:o}=n;Jr({dsn:j.PRISMIC_SENTRY_DSN,appName:t,appVersion:e,environment:j.PRISMIC_SENTRY_ENVIRONMENT}),Yr(`host`,r),i&&(Yr(`repository`,i),Xr(`Repository Data`,{name:i})),o&&Yr(`taskId`,o),a&&Xr(`Agent Task`,{userIntent:a,taskId:o});try{Yr(`framework`,(await M()).id)}catch{}}function La(e,t){if(!e)return`missing --task-id`;if(!sa(e))return"--task-id must come from `prismic task-id`";if(!t)return`missing --user-intent`}function Ra(e){return e instanceof ft?e.reason===`misconfigured`:Pa.some(t=>e instanceof t)}export{};
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{};