@angeloashmore/prismic-cli-poc 0.0.0-canary.2ff9563 → 0.0.0-canary.d96e685

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,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import{parseArgs as e}from"node:util";import{access as t,mkdir as n,readFile as r,readdir as i,rename as a,rm as o,writeFile as s}from"node:fs/promises";import{pathToFileURL as c}from"node:url";import{homedir as l}from"node:os";import{exec as u}from"node:child_process";import{createServer as d}from"node:http";function f(e){return{lang:e?.lang??void 0,message:e?.message,abortEarly:e?.abortEarly??void 0,abortPipeEarly:e?.abortPipeEarly??void 0}}function p(e){return(void 0)?.get(e)}function m(e){return(void 0)?.get(e)}function h(e,t){return(void 0)?.get(e)?.get(t)}function g(e){let t=typeof e;return t===`string`?`"${e}"`:t===`number`||t===`bigint`||t===`boolean`?`${e}`:t===`object`||t===`function`?(e&&Object.getPrototypeOf(e)?.constructor?.name)??`null`:t}function _(e,t,n,r,i){let a=i&&`input`in i?i.input:n.value,o=i?.expected??e.expects??null,s=i?.received??g(a),c={kind:e.kind,type:e.type,input:a,expected:o,received:s,message:`Invalid ${t}: ${o?`Expected ${o} but r`:`R`}eceived ${s}`,requirement:e.requirement,path:i?.path,issues:i?.issues,lang:r.lang,abortEarly:r.abortEarly,abortPipeEarly:r.abortPipeEarly},l=e.kind===`schema`,u=i?.message??e.message??h(e.reference,c.lang)??(l?m(c.lang):null)??r.message??p(c.lang);u!==void 0&&(c.message=typeof u==`function`?u(c):u),l&&(n.typed=!1),n.issues?n.issues.push(c):n.issues=[c]}function v(e){return{version:1,vendor:`valibot`,validate(t){return e[`~run`]({value:t},f())}}}function y(e,t){return Object.hasOwn(e,t)&&t!==`__proto__`&&t!==`prototype`&&t!==`constructor`}function b(e){return e instanceof ee}var ee=class extends Error{constructor(e){super(e[0].message),this.name=`ValiError`,this.issues=e}};function te(e){return{kind:`validation`,type:`url`,reference:te,async:!1,expects:null,requirement(e){try{return new URL(e),!0}catch{return!1}},message:e,"~run"(e,t){return e.typed&&!this.requirement(e.value)&&_(this,`URL`,e,t),e}}}function ne(e,t,n){return typeof e.fallback==`function`?e.fallback(t,n):e.fallback}function re(e,t,n){return typeof e.default==`function`?e.default(t,n):e.default}function x(e,t){return{kind:`schema`,type:`array`,reference:x,expects:`Array`,async:!1,item:e,message:t,get"~standard"(){return v(this)},"~run"(e,t){let n=e.value;if(Array.isArray(n)){e.typed=!0,e.value=[];for(let r=0;r<n.length;r++){let i=n[r],a=this.item[`~run`]({value:i},t);if(a.issues){let o={type:`array`,origin:`value`,input:n,key:r,value:i};for(let t of a.issues)t.path?t.path.unshift(o):t.path=[o],e.issues?.push(t);if(e.issues||=a.issues,t.abortEarly){e.typed=!1;break}}a.typed||(e.typed=!1),e.value.push(a.value)}}else _(this,`type`,e,t);return e}}}function S(e){return{kind:`schema`,type:`boolean`,reference:S,expects:`boolean`,async:!1,message:e,get"~standard"(){return v(this)},"~run"(e,t){return typeof e.value==`boolean`?e.typed=!0:_(this,`type`,e,t),e}}}function ie(e,t){return{kind:`schema`,type:`literal`,reference:ie,expects:g(e),async:!1,literal:e,message:t,get"~standard"(){return v(this)},"~run"(e,t){return e.value===this.literal?e.typed=!0:_(this,`type`,e,t),e}}}function C(e,t){return{kind:`schema`,type:`nullable`,reference:C,expects:`(${e.expects} | null)`,async:!1,wrapped:e,default:t,get"~standard"(){return v(this)},"~run"(e,t){return e.value===null&&(this.default!==void 0&&(e.value=re(this,e,t)),e.value===null)?(e.typed=!0,e):this.wrapped[`~run`](e,t)}}}function w(e){return{kind:`schema`,type:`number`,reference:w,expects:`number`,async:!1,message:e,get"~standard"(){return v(this)},"~run"(e,t){return typeof e.value==`number`&&!isNaN(e.value)?e.typed=!0:_(this,`type`,e,t),e}}}function T(e,t){return{kind:`schema`,type:`object`,reference:T,expects:`Object`,async:!1,entries:e,message:t,get"~standard"(){return v(this)},"~run"(e,t){let n=e.value;if(n&&typeof n==`object`)for(let r in e.typed=!0,e.value={},this.entries){let i=this.entries[r];if(r in n||(i.type===`exact_optional`||i.type===`optional`||i.type===`nullish`)&&i.default!==void 0){let a=r in n?n[r]:re(i),o=i[`~run`]({value:a},t);if(o.issues){let i={type:`object`,origin:`value`,input:n,key:r,value:a};for(let t of o.issues)t.path?t.path.unshift(i):t.path=[i],e.issues?.push(t);if(e.issues||=o.issues,t.abortEarly){e.typed=!1;break}}o.typed||(e.typed=!1),e.value[r]=o.value}else if(i.fallback!==void 0)e.value[r]=ne(i);else if(i.type!==`exact_optional`&&i.type!==`optional`&&i.type!==`nullish`&&(_(this,`key`,e,t,{input:void 0,expected:`"${r}"`,path:[{type:`object`,origin:`key`,input:n,key:r,value:n[r]}]}),t.abortEarly))break}else _(this,`type`,e,t);return e}}}function E(e,t){return{kind:`schema`,type:`optional`,reference:E,expects:`(${e.expects} | undefined)`,async:!1,wrapped:e,default:t,get"~standard"(){return v(this)},"~run"(e,t){return e.value===void 0&&(this.default!==void 0&&(e.value=re(this,e,t)),e.value===void 0)?(e.typed=!0,e):this.wrapped[`~run`](e,t)}}}function D(e,t,n){return{kind:`schema`,type:`record`,reference:D,expects:`Object`,async:!1,key:e,value:t,message:n,get"~standard"(){return v(this)},"~run"(e,t){let n=e.value;if(n&&typeof n==`object`){for(let r in e.typed=!0,e.value={},n)if(y(n,r)){let i=n[r],a=this.key[`~run`]({value:r},t);if(a.issues){let o={type:`object`,origin:`key`,input:n,key:r,value:i};for(let t of a.issues)t.path=[o],e.issues?.push(t);if(e.issues||=a.issues,t.abortEarly){e.typed=!1;break}}let o=this.value[`~run`]({value:i},t);if(o.issues){let a={type:`object`,origin:`value`,input:n,key:r,value:i};for(let t of o.issues)t.path?t.path.unshift(a):t.path=[a],e.issues?.push(t);if(e.issues||=o.issues,t.abortEarly){e.typed=!1;break}}(!a.typed||!o.typed)&&(e.typed=!1),a.typed&&(e.value[a.value]=o.value)}}else _(this,`type`,e,t);return e}}}function O(e){return{kind:`schema`,type:`string`,reference:O,expects:`string`,async:!1,message:e,get"~standard"(){return v(this)},"~run"(e,t){return typeof e.value==`string`?e.typed=!0:_(this,`type`,e,t),e}}}function k(){return{kind:`schema`,type:`unknown`,reference:k,expects:`unknown`,async:!1,get"~standard"(){return v(this)},"~run"(e){return e.typed=!0,e}}}function ae(e,t,n){let r=e[`~run`]({value:t},f(n));if(r.issues)throw new ee(r.issues);return r.value}function oe(...e){return{...e[0],pipe:e,get"~standard"(){return v(this)},"~run"(t,n){for(let r of e)if(r.kind!==`metadata`){if(t.issues&&(r.kind===`schema`||r.kind===`transformation`)){t.typed=!1;break}(!t.issues||!n.abortEarly&&!n.abortPipeEarly)&&(t=r[`~run`](t,n))}return t}}}function A(e,t,n){let r=e[`~run`]({value:t},f(n));return{typed:r.typed,success:!r.issues,output:r.value,issues:r.issues}}const j=new URL(`.prismic`,I(c(l()))),se=`https://prismic.io`;async function ce(e,t){let n={token:e,host:t?.host};await s(j,JSON.stringify(n,null,2))}async function M(){return!!await N()}async function N(){return(await le())?.token}async function P(){try{let e=await le();return e?.host?new URL(e.host):new URL(se)}catch{return new URL(se)}}async function le(){try{let e=await r(j,`utf-8`);return JSON.parse(e)}catch{return}}async function ue(){try{await t(j)}catch{return!0}return await le()?(await o(j),!0):!1}async function F(e){let t=await P();return t.hostname=`${e}.${t.hostname}`,I(t)}async function de(){let e=await P();return e.hostname=`api.internal.${e.hostname}`,I(e)}async function fe(){let e=await P();return e.hostname=`user-service.${e.hostname}`,I(e)}function I(e){let t=new URL(e);return t.pathname.endsWith(`/`)||(t.pathname+=`/`),t}async function L(e,n={}){let{start:r=c(process.cwd()),stop:i}=n,a=I(r);for(;;){let n=new URL(e,a);try{return await t(n),n}catch{}if(typeof i==`string`){let e=new URL(i,a);try{await t(e);return}catch{}}else if(i instanceof URL&&i.href===a.href)return;let r=new URL(`..`,a);if(r.href===a.href)return;a=r}}async function R(e){try{return await t(e),!0}catch{return!1}}function z(e){return JSON.stringify(e,null,2)}const pe=T({id:O(),label:O(),repeatable:S(),status:S(),format:O(),json:D(O(),D(O(),k()))});async function me(){let{values:{help:t,tab:n,label:i,default:a,"true-label":o,"false-label":c},positionals:[l,u]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},default:{type:`boolean`},"true-label":{type:`string`},"false-label":{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a boolean (toggle) field to an existing custom type.
2
+ import{parseArgs as e}from"node:util";import{access as t,mkdir as n,readFile as r,readdir as i,rename as a,rm as o,writeFile as s}from"node:fs/promises";import{pathToFileURL as c}from"node:url";import{homedir as l}from"node:os";import{exec as u}from"node:child_process";import{createServer as d}from"node:http";function f(e){return{lang:e?.lang??void 0,message:e?.message,abortEarly:e?.abortEarly??void 0,abortPipeEarly:e?.abortPipeEarly??void 0}}function p(e){return(void 0)?.get(e)}function m(e){return(void 0)?.get(e)}function h(e,t){return(void 0)?.get(e)?.get(t)}function g(e){let t=typeof e;return t===`string`?`"${e}"`:t===`number`||t===`bigint`||t===`boolean`?`${e}`:t===`object`||t===`function`?(e&&Object.getPrototypeOf(e)?.constructor?.name)??`null`:t}function _(e,t,n,r,i){let a=i&&`input`in i?i.input:n.value,o=i?.expected??e.expects??null,s=i?.received??g(a),c={kind:e.kind,type:e.type,input:a,expected:o,received:s,message:`Invalid ${t}: ${o?`Expected ${o} but r`:`R`}eceived ${s}`,requirement:e.requirement,path:i?.path,issues:i?.issues,lang:r.lang,abortEarly:r.abortEarly,abortPipeEarly:r.abortPipeEarly},l=e.kind===`schema`,u=i?.message??e.message??h(e.reference,c.lang)??(l?m(c.lang):null)??r.message??p(c.lang);u!==void 0&&(c.message=typeof u==`function`?u(c):u),l&&(n.typed=!1),n.issues?n.issues.push(c):n.issues=[c]}function v(e){return{version:1,vendor:`valibot`,validate(t){return e[`~run`]({value:t},f())}}}function y(e,t){return Object.hasOwn(e,t)&&t!==`__proto__`&&t!==`prototype`&&t!==`constructor`}function b(e){return e instanceof ee}var ee=class extends Error{constructor(e){super(e[0].message),this.name=`ValiError`,this.issues=e}};function te(e){return{kind:`validation`,type:`url`,reference:te,async:!1,expects:null,requirement(e){try{return new URL(e),!0}catch{return!1}},message:e,"~run"(e,t){return e.typed&&!this.requirement(e.value)&&_(this,`URL`,e,t),e}}}function ne(e,t,n){return typeof e.fallback==`function`?e.fallback(t,n):e.fallback}function x(e,t,n){return typeof e.default==`function`?e.default(t,n):e.default}function S(e,t){return{kind:`schema`,type:`array`,reference:S,expects:`Array`,async:!1,item:e,message:t,get"~standard"(){return v(this)},"~run"(e,t){let n=e.value;if(Array.isArray(n)){e.typed=!0,e.value=[];for(let r=0;r<n.length;r++){let i=n[r],a=this.item[`~run`]({value:i},t);if(a.issues){let o={type:`array`,origin:`value`,input:n,key:r,value:i};for(let t of a.issues)t.path?t.path.unshift(o):t.path=[o],e.issues?.push(t);if(e.issues||=a.issues,t.abortEarly){e.typed=!1;break}}a.typed||(e.typed=!1),e.value.push(a.value)}}else _(this,`type`,e,t);return e}}}function C(e){return{kind:`schema`,type:`boolean`,reference:C,expects:`boolean`,async:!1,message:e,get"~standard"(){return v(this)},"~run"(e,t){return typeof e.value==`boolean`?e.typed=!0:_(this,`type`,e,t),e}}}function re(e,t){return{kind:`schema`,type:`literal`,reference:re,expects:g(e),async:!1,literal:e,message:t,get"~standard"(){return v(this)},"~run"(e,t){return e.value===this.literal?e.typed=!0:_(this,`type`,e,t),e}}}function w(e,t){return{kind:`schema`,type:`nullable`,reference:w,expects:`(${e.expects} | null)`,async:!1,wrapped:e,default:t,get"~standard"(){return v(this)},"~run"(e,t){return e.value===null&&(this.default!==void 0&&(e.value=x(this,e,t)),e.value===null)?(e.typed=!0,e):this.wrapped[`~run`](e,t)}}}function T(e){return{kind:`schema`,type:`number`,reference:T,expects:`number`,async:!1,message:e,get"~standard"(){return v(this)},"~run"(e,t){return typeof e.value==`number`&&!isNaN(e.value)?e.typed=!0:_(this,`type`,e,t),e}}}function E(e,t){return{kind:`schema`,type:`object`,reference:E,expects:`Object`,async:!1,entries:e,message:t,get"~standard"(){return v(this)},"~run"(e,t){let n=e.value;if(n&&typeof n==`object`)for(let r in e.typed=!0,e.value={},this.entries){let i=this.entries[r];if(r in n||(i.type===`exact_optional`||i.type===`optional`||i.type===`nullish`)&&i.default!==void 0){let a=r in n?n[r]:x(i),o=i[`~run`]({value:a},t);if(o.issues){let i={type:`object`,origin:`value`,input:n,key:r,value:a};for(let t of o.issues)t.path?t.path.unshift(i):t.path=[i],e.issues?.push(t);if(e.issues||=o.issues,t.abortEarly){e.typed=!1;break}}o.typed||(e.typed=!1),e.value[r]=o.value}else if(i.fallback!==void 0)e.value[r]=ne(i);else if(i.type!==`exact_optional`&&i.type!==`optional`&&i.type!==`nullish`&&(_(this,`key`,e,t,{input:void 0,expected:`"${r}"`,path:[{type:`object`,origin:`key`,input:n,key:r,value:n[r]}]}),t.abortEarly))break}else _(this,`type`,e,t);return e}}}function D(e,t){return{kind:`schema`,type:`optional`,reference:D,expects:`(${e.expects} | undefined)`,async:!1,wrapped:e,default:t,get"~standard"(){return v(this)},"~run"(e,t){return e.value===void 0&&(this.default!==void 0&&(e.value=x(this,e,t)),e.value===void 0)?(e.typed=!0,e):this.wrapped[`~run`](e,t)}}}function O(e,t,n){return{kind:`schema`,type:`record`,reference:O,expects:`Object`,async:!1,key:e,value:t,message:n,get"~standard"(){return v(this)},"~run"(e,t){let n=e.value;if(n&&typeof n==`object`){for(let r in e.typed=!0,e.value={},n)if(y(n,r)){let i=n[r],a=this.key[`~run`]({value:r},t);if(a.issues){let o={type:`object`,origin:`key`,input:n,key:r,value:i};for(let t of a.issues)t.path=[o],e.issues?.push(t);if(e.issues||=a.issues,t.abortEarly){e.typed=!1;break}}let o=this.value[`~run`]({value:i},t);if(o.issues){let a={type:`object`,origin:`value`,input:n,key:r,value:i};for(let t of o.issues)t.path?t.path.unshift(a):t.path=[a],e.issues?.push(t);if(e.issues||=o.issues,t.abortEarly){e.typed=!1;break}}(!a.typed||!o.typed)&&(e.typed=!1),a.typed&&(e.value[a.value]=o.value)}}else _(this,`type`,e,t);return e}}}function k(e){return{kind:`schema`,type:`string`,reference:k,expects:`string`,async:!1,message:e,get"~standard"(){return v(this)},"~run"(e,t){return typeof e.value==`string`?e.typed=!0:_(this,`type`,e,t),e}}}function A(){return{kind:`schema`,type:`unknown`,reference:A,expects:`unknown`,async:!1,get"~standard"(){return v(this)},"~run"(e){return e.typed=!0,e}}}function j(e,t,n){let r=e[`~run`]({value:t},f(n));if(r.issues)throw new ee(r.issues);return r.value}function ie(...e){return{...e[0],pipe:e,get"~standard"(){return v(this)},"~run"(t,n){for(let r of e)if(r.kind!==`metadata`){if(t.issues&&(r.kind===`schema`||r.kind===`transformation`)){t.typed=!1;break}(!t.issues||!n.abortEarly&&!n.abortPipeEarly)&&(t=r[`~run`](t,n))}return t}}}function M(e,t,n){let r=e[`~run`]({value:t},f(n));return{typed:r.typed,success:!r.issues,output:r.value,issues:r.issues}}const N=new URL(`.prismic`,L(c(l()))),ae=`https://prismic.io`;async function oe(e,t){let n={token:e,host:t?.host};await s(N,JSON.stringify(n,null,2))}async function P(){return!!await se()}async function se(){return(await ce())?.token}async function F(){try{let e=await ce();return e?.host?new URL(e.host):new URL(ae)}catch{return new URL(ae)}}async function ce(){try{let e=await r(N,`utf-8`);return JSON.parse(e)}catch{return}}async function le(){try{await t(N)}catch{return!0}return await ce()?(await o(N),!0):!1}async function I(e){let t=await F();return t.hostname=`${e}.${t.hostname}`,L(t)}async function ue(){let e=await F();return e.hostname=`api.internal.${e.hostname}`,L(e)}async function de(){let e=await F();return e.hostname=`user-service.${e.hostname}`,L(e)}function L(e){let t=new URL(e);return t.pathname.endsWith(`/`)||(t.pathname+=`/`),t}async function R(e,n={}){let{start:r=c(process.cwd()),stop:i}=n,a=L(r);for(;;){let n=new URL(e,a);try{return await t(n),n}catch{}if(typeof i==`string`){let e=new URL(i,a);try{await t(e);return}catch{}}else if(i instanceof URL&&i.href===a.href)return;let r=new URL(`..`,a);if(r.href===a.href)return;a=r}}async function z(e){try{return await t(e),!0}catch{return!1}}function B(e){return JSON.stringify(e,null,2)}const fe=E({id:k(),label:k(),repeatable:C(),status:C(),format:k(),json:O(k(),O(k(),A()))});async function pe(){let{values:{help:t,tab:n,label:i,default:a,"true-label":o,"false-label":c},positionals:[l,u]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},default:{type:`boolean`},"true-label":{type:`string`},"false-label":{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a boolean (toggle) field to an existing custom type.
3
3
 
4
4
  USAGE
5
5
  prismic custom-type add-field boolean <type-id> <field-id> [flags]
@@ -21,7 +21,7 @@ EXAMPLES
21
21
  prismic custom-type add-field boolean article published --default
22
22
  prismic custom-type add-field boolean product available --true-label "In Stock" --false-label "Out of Stock"`);return}if(!l){console.error(`Missing required argument: type-id
23
23
  `),console.error(`Usage: prismic custom-type add-field boolean <type-id> <field-id>`),process.exitCode=1;return}if(!u){console.error(`Missing required argument: field-id
24
- `),console.error(`Usage: prismic custom-type add-field boolean <type-id> <field-id>`),process.exitCode=1;return}let d=await L(`package.json`);if(!d){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let f=new URL(`customtypes/${l}/index.json`,d),p;try{let e=await r(f,`utf8`),t=A(pe,JSON.parse(e));if(!t.success){console.error(`Invalid custom type model: ${f.href}`),process.exitCode=1;return}p=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Custom type not found: ${l}\n`),console.error(`Create it first with: prismic custom-type create ${l}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read custom type: ${e.message}`):console.error(`Failed to read custom type`),process.exitCode=1;return}let m=Object.keys(p.json),h=n??m[0]??`Main`;p.json[h]||(p.json[h]={});for(let[e,t]of Object.entries(p.json))if(t[u]){console.error(`Field "${u}" already exists in tab "${e}"`),process.exitCode=1;return}let g={type:`Boolean`,config:{...i&&{label:i},...a&&{default_value:!0},...o&&{placeholder_true:o},...c&&{placeholder_false:c}}};p.json[h][u]=g;try{await s(f,z(p))}catch(e){e instanceof Error?console.error(`Failed to update custom type: ${e.message}`):console.error(`Failed to update custom type`),process.exitCode=1;return}console.info(`Added field "${u}" (Boolean) to "${h}" tab in ${l}`)}const he=T({id:O(),label:O(),repeatable:S(),status:S(),format:O(),json:D(O(),D(O(),k()))});async function ge(){let{values:{help:t,tab:n,label:i,placeholder:a},positionals:[o,c]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a color picker field to an existing custom type.
24
+ `),console.error(`Usage: prismic custom-type add-field boolean <type-id> <field-id>`),process.exitCode=1;return}let d=await R(`package.json`);if(!d){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let f=new URL(`customtypes/${l}/index.json`,d),p;try{let e=await r(f,`utf8`),t=M(fe,JSON.parse(e));if(!t.success){console.error(`Invalid custom type model: ${f.href}`),process.exitCode=1;return}p=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Custom type not found: ${l}\n`),console.error(`Create it first with: prismic custom-type create ${l}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read custom type: ${e.message}`):console.error(`Failed to read custom type`),process.exitCode=1;return}let m=Object.keys(p.json),h=n??m[0]??`Main`;p.json[h]||(p.json[h]={});for(let[e,t]of Object.entries(p.json))if(t[u]){console.error(`Field "${u}" already exists in tab "${e}"`),process.exitCode=1;return}let g={type:`Boolean`,config:{...i&&{label:i},...a&&{default_value:!0},...o&&{placeholder_true:o},...c&&{placeholder_false:c}}};p.json[h][u]=g;try{await s(f,B(p))}catch(e){e instanceof Error?console.error(`Failed to update custom type: ${e.message}`):console.error(`Failed to update custom type`),process.exitCode=1;return}console.info(`Added field "${u}" (Boolean) to "${h}" tab in ${l}`)}const me=E({id:k(),label:k(),repeatable:C(),status:C(),format:k(),json:O(k(),O(k(),A()))});async function he(){let{values:{help:t,tab:n,label:i,placeholder:a},positionals:[o,c]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a color picker field to an existing custom type.
25
25
 
26
26
  USAGE
27
27
  prismic custom-type add-field color <type-id> <field-id> [flags]
@@ -41,7 +41,7 @@ EXAMPLES
41
41
  prismic custom-type add-field color homepage accent --tab "Design"
42
42
  prismic custom-type add-field color homepage text_color --label "Text Color"`);return}if(!o){console.error(`Missing required argument: type-id
43
43
  `),console.error(`Usage: prismic custom-type add-field color <type-id> <field-id>`),process.exitCode=1;return}if(!c){console.error(`Missing required argument: field-id
44
- `),console.error(`Usage: prismic custom-type add-field color <type-id> <field-id>`),process.exitCode=1;return}let l=await L(`package.json`);if(!l){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let u=new URL(`customtypes/${o}/index.json`,l),d;try{let e=await r(u,`utf8`),t=A(he,JSON.parse(e));if(!t.success){console.error(`Invalid custom type model: ${u.href}`),process.exitCode=1;return}d=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Custom type not found: ${o}\n`),console.error(`Create it first with: prismic custom-type create ${o}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read custom type: ${e.message}`):console.error(`Failed to read custom type`),process.exitCode=1;return}let f=Object.keys(d.json),p=n??f[0]??`Main`;d.json[p]||(d.json[p]={});for(let[e,t]of Object.entries(d.json))if(t[c]){console.error(`Field "${c}" already exists in tab "${e}"`),process.exitCode=1;return}let m={type:`Color`,config:{...i&&{label:i},...a&&{placeholder:a}}};d.json[p][c]=m;try{await s(u,z(d))}catch(e){e instanceof Error?console.error(`Failed to update custom type: ${e.message}`):console.error(`Failed to update custom type`),process.exitCode=1;return}console.info(`Added field "${c}" (Color) to "${p}" tab in ${o}`)}const _e=T({id:O(),label:O(),repeatable:S(),status:S(),format:O(),json:D(O(),D(O(),k()))});async function ve(){let{values:{help:t,tab:n,label:i,placeholder:a,default:o},positionals:[c,l]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},default:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a date field to an existing custom type.
44
+ `),console.error(`Usage: prismic custom-type add-field color <type-id> <field-id>`),process.exitCode=1;return}let l=await R(`package.json`);if(!l){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let u=new URL(`customtypes/${o}/index.json`,l),d;try{let e=await r(u,`utf8`),t=M(me,JSON.parse(e));if(!t.success){console.error(`Invalid custom type model: ${u.href}`),process.exitCode=1;return}d=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Custom type not found: ${o}\n`),console.error(`Create it first with: prismic custom-type create ${o}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read custom type: ${e.message}`):console.error(`Failed to read custom type`),process.exitCode=1;return}let f=Object.keys(d.json),p=n??f[0]??`Main`;d.json[p]||(d.json[p]={});for(let[e,t]of Object.entries(d.json))if(t[c]){console.error(`Field "${c}" already exists in tab "${e}"`),process.exitCode=1;return}let m={type:`Color`,config:{...i&&{label:i},...a&&{placeholder:a}}};d.json[p][c]=m;try{await s(u,B(d))}catch(e){e instanceof Error?console.error(`Failed to update custom type: ${e.message}`):console.error(`Failed to update custom type`),process.exitCode=1;return}console.info(`Added field "${c}" (Color) to "${p}" tab in ${o}`)}const ge=E({id:k(),label:k(),repeatable:C(),status:C(),format:k(),json:O(k(),O(k(),A()))});async function _e(){let{values:{help:t,tab:n,label:i,placeholder:a,default:o},positionals:[c,l]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},default:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a date field to an existing custom type.
45
45
 
46
46
  USAGE
47
47
  prismic custom-type add-field date <type-id> <field-id> [flags]
@@ -62,7 +62,7 @@ EXAMPLES
62
62
  prismic custom-type add-field date event start_date --tab "Schedule"
63
63
  prismic custom-type add-field date article date --label "Publication Date" --default "2024-01-01"`);return}if(!c){console.error(`Missing required argument: type-id
64
64
  `),console.error(`Usage: prismic custom-type add-field date <type-id> <field-id>`),process.exitCode=1;return}if(!l){console.error(`Missing required argument: field-id
65
- `),console.error(`Usage: prismic custom-type add-field date <type-id> <field-id>`),process.exitCode=1;return}let u=await L(`package.json`);if(!u){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let d=new URL(`customtypes/${c}/index.json`,u),f;try{let e=await r(d,`utf8`),t=A(_e,JSON.parse(e));if(!t.success){console.error(`Invalid custom type model: ${d.href}`),process.exitCode=1;return}f=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Custom type not found: ${c}\n`),console.error(`Create it first with: prismic custom-type create ${c}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read custom type: ${e.message}`):console.error(`Failed to read custom type`),process.exitCode=1;return}let p=Object.keys(f.json),m=n??p[0]??`Main`;f.json[m]||(f.json[m]={});for(let[e,t]of Object.entries(f.json))if(t[l]){console.error(`Field "${l}" already exists in tab "${e}"`),process.exitCode=1;return}let h={type:`Date`,config:{...i&&{label:i},...a&&{placeholder:a},...o&&{default:o}}};f.json[m][l]=h;try{await s(d,z(f))}catch(e){e instanceof Error?console.error(`Failed to update custom type: ${e.message}`):console.error(`Failed to update custom type`),process.exitCode=1;return}console.info(`Added field "${l}" (Date) to "${m}" tab in ${c}`)}const ye=T({id:O(),label:O(),repeatable:S(),status:S(),format:O(),json:D(O(),D(O(),k()))});async function be(){let{values:{help:t,tab:n,label:i,placeholder:a},positionals:[o,c]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add an embed field to an existing custom type.
65
+ `),console.error(`Usage: prismic custom-type add-field date <type-id> <field-id>`),process.exitCode=1;return}let u=await R(`package.json`);if(!u){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let d=new URL(`customtypes/${c}/index.json`,u),f;try{let e=await r(d,`utf8`),t=M(ge,JSON.parse(e));if(!t.success){console.error(`Invalid custom type model: ${d.href}`),process.exitCode=1;return}f=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Custom type not found: ${c}\n`),console.error(`Create it first with: prismic custom-type create ${c}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read custom type: ${e.message}`):console.error(`Failed to read custom type`),process.exitCode=1;return}let p=Object.keys(f.json),m=n??p[0]??`Main`;f.json[m]||(f.json[m]={});for(let[e,t]of Object.entries(f.json))if(t[l]){console.error(`Field "${l}" already exists in tab "${e}"`),process.exitCode=1;return}let h={type:`Date`,config:{...i&&{label:i},...a&&{placeholder:a},...o&&{default:o}}};f.json[m][l]=h;try{await s(d,B(f))}catch(e){e instanceof Error?console.error(`Failed to update custom type: ${e.message}`):console.error(`Failed to update custom type`),process.exitCode=1;return}console.info(`Added field "${l}" (Date) to "${m}" tab in ${c}`)}const ve=E({id:k(),label:k(),repeatable:C(),status:C(),format:k(),json:O(k(),O(k(),A()))});async function ye(){let{values:{help:t,tab:n,label:i,placeholder:a},positionals:[o,c]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add an embed field to an existing custom type.
66
66
 
67
67
  USAGE
68
68
  prismic custom-type add-field embed <type-id> <field-id> [flags]
@@ -82,7 +82,7 @@ EXAMPLES
82
82
  prismic custom-type add-field embed homepage youtube --tab "Media"
83
83
  prismic custom-type add-field embed homepage media --label "Media Embed"`);return}if(!o){console.error(`Missing required argument: type-id
84
84
  `),console.error(`Usage: prismic custom-type add-field embed <type-id> <field-id>`),process.exitCode=1;return}if(!c){console.error(`Missing required argument: field-id
85
- `),console.error(`Usage: prismic custom-type add-field embed <type-id> <field-id>`),process.exitCode=1;return}let l=await L(`package.json`);if(!l){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let u=new URL(`customtypes/${o}/index.json`,l),d;try{let e=await r(u,`utf8`),t=A(ye,JSON.parse(e));if(!t.success){console.error(`Invalid custom type model: ${u.href}`),process.exitCode=1;return}d=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Custom type not found: ${o}\n`),console.error(`Create it first with: prismic custom-type create ${o}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read custom type: ${e.message}`):console.error(`Failed to read custom type`),process.exitCode=1;return}let f=Object.keys(d.json),p=n??f[0]??`Main`;d.json[p]||(d.json[p]={});for(let[e,t]of Object.entries(d.json))if(t[c]){console.error(`Field "${c}" already exists in tab "${e}"`),process.exitCode=1;return}let m={type:`Embed`,config:{...i&&{label:i},...a&&{placeholder:a}}};d.json[p][c]=m;try{await s(u,z(d))}catch(e){e instanceof Error?console.error(`Failed to update custom type: ${e.message}`):console.error(`Failed to update custom type`),process.exitCode=1;return}console.info(`Added field "${c}" (Embed) to "${p}" tab in ${o}`)}const xe=T({id:O(),label:O(),repeatable:S(),status:S(),format:O(),json:D(O(),D(O(),k()))});async function Se(){let{values:{help:t,tab:n,label:i},positionals:[a,o]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a geo-point (location) field to an existing custom type.
85
+ `),console.error(`Usage: prismic custom-type add-field embed <type-id> <field-id>`),process.exitCode=1;return}let l=await R(`package.json`);if(!l){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let u=new URL(`customtypes/${o}/index.json`,l),d;try{let e=await r(u,`utf8`),t=M(ve,JSON.parse(e));if(!t.success){console.error(`Invalid custom type model: ${u.href}`),process.exitCode=1;return}d=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Custom type not found: ${o}\n`),console.error(`Create it first with: prismic custom-type create ${o}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read custom type: ${e.message}`):console.error(`Failed to read custom type`),process.exitCode=1;return}let f=Object.keys(d.json),p=n??f[0]??`Main`;d.json[p]||(d.json[p]={});for(let[e,t]of Object.entries(d.json))if(t[c]){console.error(`Field "${c}" already exists in tab "${e}"`),process.exitCode=1;return}let m={type:`Embed`,config:{...i&&{label:i},...a&&{placeholder:a}}};d.json[p][c]=m;try{await s(u,B(d))}catch(e){e instanceof Error?console.error(`Failed to update custom type: ${e.message}`):console.error(`Failed to update custom type`),process.exitCode=1;return}console.info(`Added field "${c}" (Embed) to "${p}" tab in ${o}`)}const be=E({id:k(),label:k(),repeatable:C(),status:C(),format:k(),json:O(k(),O(k(),A()))});async function xe(){let{values:{help:t,tab:n,label:i},positionals:[a,o]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a geo-point (location) field to an existing custom type.
86
86
 
87
87
  USAGE
88
88
  prismic custom-type add-field geo-point <type-id> <field-id> [flags]
@@ -101,7 +101,7 @@ EXAMPLES
101
101
  prismic custom-type add-field geo-point store address --tab "Details"
102
102
  prismic custom-type add-field geo-point event venue --label "Event Venue"`);return}if(!a){console.error(`Missing required argument: type-id
103
103
  `),console.error(`Usage: prismic custom-type add-field geo-point <type-id> <field-id>`),process.exitCode=1;return}if(!o){console.error(`Missing required argument: field-id
104
- `),console.error(`Usage: prismic custom-type add-field geo-point <type-id> <field-id>`),process.exitCode=1;return}let c=await L(`package.json`);if(!c){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let l=new URL(`customtypes/${a}/index.json`,c),u;try{let e=await r(l,`utf8`),t=A(xe,JSON.parse(e));if(!t.success){console.error(`Invalid custom type model: ${l.href}`),process.exitCode=1;return}u=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Custom type not found: ${a}\n`),console.error(`Create it first with: prismic custom-type create ${a}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read custom type: ${e.message}`):console.error(`Failed to read custom type`),process.exitCode=1;return}let d=Object.keys(u.json),f=n??d[0]??`Main`;u.json[f]||(u.json[f]={});for(let[e,t]of Object.entries(u.json))if(t[o]){console.error(`Field "${o}" already exists in tab "${e}"`),process.exitCode=1;return}let p={type:`GeoPoint`,config:{...i&&{label:i}}};u.json[f][o]=p;try{await s(l,z(u))}catch(e){e instanceof Error?console.error(`Failed to update custom type: ${e.message}`):console.error(`Failed to update custom type`),process.exitCode=1;return}console.info(`Added field "${o}" (GeoPoint) to "${f}" tab in ${a}`)}const Ce=T({id:O(),label:O(),repeatable:S(),status:S(),format:O(),json:D(O(),D(O(),k()))});async function we(){let{values:{help:t,tab:n,label:i,placeholder:a},positionals:[o,c]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add an image field to an existing custom type.
104
+ `),console.error(`Usage: prismic custom-type add-field geo-point <type-id> <field-id>`),process.exitCode=1;return}let c=await R(`package.json`);if(!c){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let l=new URL(`customtypes/${a}/index.json`,c),u;try{let e=await r(l,`utf8`),t=M(be,JSON.parse(e));if(!t.success){console.error(`Invalid custom type model: ${l.href}`),process.exitCode=1;return}u=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Custom type not found: ${a}\n`),console.error(`Create it first with: prismic custom-type create ${a}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read custom type: ${e.message}`):console.error(`Failed to read custom type`),process.exitCode=1;return}let d=Object.keys(u.json),f=n??d[0]??`Main`;u.json[f]||(u.json[f]={});for(let[e,t]of Object.entries(u.json))if(t[o]){console.error(`Field "${o}" already exists in tab "${e}"`),process.exitCode=1;return}let p={type:`GeoPoint`,config:{...i&&{label:i}}};u.json[f][o]=p;try{await s(l,B(u))}catch(e){e instanceof Error?console.error(`Failed to update custom type: ${e.message}`):console.error(`Failed to update custom type`),process.exitCode=1;return}console.info(`Added field "${o}" (GeoPoint) to "${f}" tab in ${a}`)}const Se=E({id:k(),label:k(),repeatable:C(),status:C(),format:k(),json:O(k(),O(k(),A()))});async function Ce(){let{values:{help:t,tab:n,label:i,placeholder:a},positionals:[o,c]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add an image field to an existing custom type.
105
105
 
106
106
  USAGE
107
107
  prismic custom-type add-field image <type-id> <field-id> [flags]
@@ -121,7 +121,7 @@ EXAMPLES
121
121
  prismic custom-type add-field image article thumbnail --tab "Media"
122
122
  prismic custom-type add-field image product photo --label "Product Photo"`);return}if(!o){console.error(`Missing required argument: type-id
123
123
  `),console.error(`Usage: prismic custom-type add-field image <type-id> <field-id>`),process.exitCode=1;return}if(!c){console.error(`Missing required argument: field-id
124
- `),console.error(`Usage: prismic custom-type add-field image <type-id> <field-id>`),process.exitCode=1;return}let l=await L(`package.json`);if(!l){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let u=new URL(`customtypes/${o}/index.json`,l),d;try{let e=await r(u,`utf8`),t=A(Ce,JSON.parse(e));if(!t.success){console.error(`Invalid custom type model: ${u.href}`),process.exitCode=1;return}d=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Custom type not found: ${o}\n`),console.error(`Create it first with: prismic custom-type create ${o}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read custom type: ${e.message}`):console.error(`Failed to read custom type`),process.exitCode=1;return}let f=Object.keys(d.json),p=n??f[0]??`Main`;d.json[p]||(d.json[p]={});for(let[e,t]of Object.entries(d.json))if(t[c]){console.error(`Field "${c}" already exists in tab "${e}"`),process.exitCode=1;return}let m={type:`Image`,config:{...i&&{label:i},...a&&{placeholder:a}}};d.json[p][c]=m;try{await s(u,z(d))}catch(e){e instanceof Error?console.error(`Failed to update custom type: ${e.message}`):console.error(`Failed to update custom type`),process.exitCode=1;return}console.info(`Added field "${c}" (Image) to "${p}" tab in ${o}`)}const Te=T({id:O(),label:O(),repeatable:S(),status:S(),format:O(),json:D(O(),D(O(),k()))});async function Ee(){let{values:{help:t,tab:n,label:i,placeholder:a},positionals:[o,c]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a key-text (single-line text) field to an existing custom type.
124
+ `),console.error(`Usage: prismic custom-type add-field image <type-id> <field-id>`),process.exitCode=1;return}let l=await R(`package.json`);if(!l){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let u=new URL(`customtypes/${o}/index.json`,l),d;try{let e=await r(u,`utf8`),t=M(Se,JSON.parse(e));if(!t.success){console.error(`Invalid custom type model: ${u.href}`),process.exitCode=1;return}d=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Custom type not found: ${o}\n`),console.error(`Create it first with: prismic custom-type create ${o}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read custom type: ${e.message}`):console.error(`Failed to read custom type`),process.exitCode=1;return}let f=Object.keys(d.json),p=n??f[0]??`Main`;d.json[p]||(d.json[p]={});for(let[e,t]of Object.entries(d.json))if(t[c]){console.error(`Field "${c}" already exists in tab "${e}"`),process.exitCode=1;return}let m={type:`Image`,config:{...i&&{label:i},...a&&{placeholder:a}}};d.json[p][c]=m;try{await s(u,B(d))}catch(e){e instanceof Error?console.error(`Failed to update custom type: ${e.message}`):console.error(`Failed to update custom type`),process.exitCode=1;return}console.info(`Added field "${c}" (Image) to "${p}" tab in ${o}`)}const we=E({id:k(),label:k(),repeatable:C(),status:C(),format:k(),json:O(k(),O(k(),A()))});async function Te(){let{values:{help:t,tab:n,label:i,placeholder:a},positionals:[o,c]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a key-text (single-line text) field to an existing custom type.
125
125
 
126
126
  USAGE
127
127
  prismic custom-type add-field key-text <type-id> <field-id> [flags]
@@ -141,7 +141,7 @@ EXAMPLES
141
141
  prismic custom-type add-field key-text homepage meta_title --tab "SEO"
142
142
  prismic custom-type add-field key-text homepage subtitle --label "Subtitle" --placeholder "Enter subtitle"`);return}if(!o){console.error(`Missing required argument: type-id
143
143
  `),console.error(`Usage: prismic custom-type add-field key-text <type-id> <field-id>`),process.exitCode=1;return}if(!c){console.error(`Missing required argument: field-id
144
- `),console.error(`Usage: prismic custom-type add-field key-text <type-id> <field-id>`),process.exitCode=1;return}let l=await L(`package.json`);if(!l){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let u=new URL(`customtypes/${o}/index.json`,l),d;try{let e=await r(u,`utf8`),t=A(Te,JSON.parse(e));if(!t.success){console.error(`Invalid custom type model: ${u.href}`),process.exitCode=1;return}d=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Custom type not found: ${o}\n`),console.error(`Create it first with: prismic custom-type create ${o}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read custom type: ${e.message}`):console.error(`Failed to read custom type`),process.exitCode=1;return}let f=Object.keys(d.json),p=n??f[0]??`Main`;d.json[p]||(d.json[p]={});for(let[e,t]of Object.entries(d.json))if(t[c]){console.error(`Field "${c}" already exists in tab "${e}"`),process.exitCode=1;return}let m={type:`Text`,config:{...i&&{label:i},...a&&{placeholder:a}}};d.json[p][c]=m;try{await s(u,z(d))}catch(e){e instanceof Error?console.error(`Failed to update custom type: ${e.message}`):console.error(`Failed to update custom type`),process.exitCode=1;return}console.info(`Added field "${c}" (Text) to "${p}" tab in ${o}`)}const De=T({id:O(),label:O(),repeatable:S(),status:S(),format:O(),json:D(O(),D(O(),k()))});async function Oe(){let{values:{help:t,tab:n,label:i,placeholder:a,variation:o,"allow-text":c,"allow-target-blank":l,repeatable:u},positionals:[d,f]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},variation:{type:`string`,multiple:!0},"allow-text":{type:`boolean`},"allow-target-blank":{type:`boolean`},repeatable:{type:`boolean`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a link field to an existing custom type.
144
+ `),console.error(`Usage: prismic custom-type add-field key-text <type-id> <field-id>`),process.exitCode=1;return}let l=await R(`package.json`);if(!l){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let u=new URL(`customtypes/${o}/index.json`,l),d;try{let e=await r(u,`utf8`),t=M(we,JSON.parse(e));if(!t.success){console.error(`Invalid custom type model: ${u.href}`),process.exitCode=1;return}d=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Custom type not found: ${o}\n`),console.error(`Create it first with: prismic custom-type create ${o}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read custom type: ${e.message}`):console.error(`Failed to read custom type`),process.exitCode=1;return}let f=Object.keys(d.json),p=n??f[0]??`Main`;d.json[p]||(d.json[p]={});for(let[e,t]of Object.entries(d.json))if(t[c]){console.error(`Field "${c}" already exists in tab "${e}"`),process.exitCode=1;return}let m={type:`Text`,config:{...i&&{label:i},...a&&{placeholder:a}}};d.json[p][c]=m;try{await s(u,B(d))}catch(e){e instanceof Error?console.error(`Failed to update custom type: ${e.message}`):console.error(`Failed to update custom type`),process.exitCode=1;return}console.info(`Added field "${c}" (Text) to "${p}" tab in ${o}`)}const Ee=E({id:k(),label:k(),repeatable:C(),status:C(),format:k(),json:O(k(),O(k(),A()))});async function De(){let{values:{help:t,tab:n,label:i,placeholder:a,variation:o,"allow-text":c,"allow-target-blank":l,repeatable:u},positionals:[d,f]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},variation:{type:`string`,multiple:!0},"allow-text":{type:`boolean`},"allow-target-blank":{type:`boolean`},repeatable:{type:`boolean`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a link field to an existing custom type.
145
145
 
146
146
  USAGE
147
147
  prismic custom-type add-field link <type-id> <field-id> [flags]
@@ -166,7 +166,7 @@ EXAMPLES
166
166
  prismic custom-type add-field link homepage cta --variation Primary --variation Secondary
167
167
  prismic custom-type add-field link homepage links --repeatable`);return}if(!d){console.error(`Missing required argument: type-id
168
168
  `),console.error(`Usage: prismic custom-type add-field link <type-id> <field-id>`),process.exitCode=1;return}if(!f){console.error(`Missing required argument: field-id
169
- `),console.error(`Usage: prismic custom-type add-field link <type-id> <field-id>`),process.exitCode=1;return}let p=await L(`package.json`);if(!p){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let m=new URL(`customtypes/${d}/index.json`,p),h;try{let e=await r(m,`utf8`),t=A(De,JSON.parse(e));if(!t.success){console.error(`Invalid custom type model: ${m.href}`),process.exitCode=1;return}h=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Custom type not found: ${d}\n`),console.error(`Create it first with: prismic custom-type create ${d}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read custom type: ${e.message}`):console.error(`Failed to read custom type`),process.exitCode=1;return}let g=Object.keys(h.json),_=n??g[0]??`Main`;h.json[_]||(h.json[_]={});for(let[e,t]of Object.entries(h.json))if(t[f]){console.error(`Field "${f}" already exists in tab "${e}"`),process.exitCode=1;return}let v={type:`Link`,config:{...i&&{label:i},...a&&{placeholder:a},...o&&o.length>0&&{variants:o},...c&&{allowText:!0},...l&&{allowTargetBlank:!0},...u&&{repeat:!0}}};h.json[_][f]=v;try{await s(m,z(h))}catch(e){e instanceof Error?console.error(`Failed to update custom type: ${e.message}`):console.error(`Failed to update custom type`),process.exitCode=1;return}console.info(`Added field "${f}" (Link) to "${_}" tab in ${d}`)}const ke=T({id:O(),label:O(),repeatable:S(),status:S(),format:O(),json:D(O(),D(O(),k()))});async function Ae(){let{values:{help:t,tab:n,label:i,placeholder:a,min:o,max:c,step:l},positionals:[u,d]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},min:{type:`string`},max:{type:`string`},step:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a number field to an existing custom type.
169
+ `),console.error(`Usage: prismic custom-type add-field link <type-id> <field-id>`),process.exitCode=1;return}let p=await R(`package.json`);if(!p){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let m=new URL(`customtypes/${d}/index.json`,p),h;try{let e=await r(m,`utf8`),t=M(Ee,JSON.parse(e));if(!t.success){console.error(`Invalid custom type model: ${m.href}`),process.exitCode=1;return}h=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Custom type not found: ${d}\n`),console.error(`Create it first with: prismic custom-type create ${d}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read custom type: ${e.message}`):console.error(`Failed to read custom type`),process.exitCode=1;return}let g=Object.keys(h.json),_=n??g[0]??`Main`;h.json[_]||(h.json[_]={});for(let[e,t]of Object.entries(h.json))if(t[f]){console.error(`Field "${f}" already exists in tab "${e}"`),process.exitCode=1;return}let v={type:`Link`,config:{...i&&{label:i},...a&&{placeholder:a},...o&&o.length>0&&{variants:o},...c&&{allowText:!0},...l&&{allowTargetBlank:!0},...u&&{repeat:!0}}};h.json[_][f]=v;try{await s(m,B(h))}catch(e){e instanceof Error?console.error(`Failed to update custom type: ${e.message}`):console.error(`Failed to update custom type`),process.exitCode=1;return}console.info(`Added field "${f}" (Link) to "${_}" tab in ${d}`)}const Oe=E({id:k(),label:k(),repeatable:C(),status:C(),format:k(),json:O(k(),O(k(),A()))});async function ke(){let{values:{help:t,tab:n,label:i,placeholder:a,min:o,max:c,step:l},positionals:[u,d]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},min:{type:`string`},max:{type:`string`},step:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a number field to an existing custom type.
170
170
 
171
171
  USAGE
172
172
  prismic custom-type add-field number <type-id> <field-id> [flags]
@@ -189,7 +189,7 @@ EXAMPLES
189
189
  prismic custom-type add-field number product quantity --min 0 --max 100
190
190
  prismic custom-type add-field number settings rating --min 1 --max 5 --step 1`);return}if(!u){console.error(`Missing required argument: type-id
191
191
  `),console.error(`Usage: prismic custom-type add-field number <type-id> <field-id>`),process.exitCode=1;return}if(!d){console.error(`Missing required argument: field-id
192
- `),console.error(`Usage: prismic custom-type add-field number <type-id> <field-id>`),process.exitCode=1;return}let f=o===void 0?void 0:Number(o),p=c===void 0?void 0:Number(c),m=l===void 0?void 0:Number(l);if(o!==void 0&&Number.isNaN(f)){console.error(`Invalid --min value: must be a number`),process.exitCode=1;return}if(c!==void 0&&Number.isNaN(p)){console.error(`Invalid --max value: must be a number`),process.exitCode=1;return}if(l!==void 0&&Number.isNaN(m)){console.error(`Invalid --step value: must be a number`),process.exitCode=1;return}let h=await L(`package.json`);if(!h){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let g=new URL(`customtypes/${u}/index.json`,h),_;try{let e=await r(g,`utf8`),t=A(ke,JSON.parse(e));if(!t.success){console.error(`Invalid custom type model: ${g.href}`),process.exitCode=1;return}_=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Custom type not found: ${u}\n`),console.error(`Create it first with: prismic custom-type create ${u}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read custom type: ${e.message}`):console.error(`Failed to read custom type`),process.exitCode=1;return}let v=Object.keys(_.json),y=n??v[0]??`Main`;_.json[y]||(_.json[y]={});for(let[e,t]of Object.entries(_.json))if(t[d]){console.error(`Field "${d}" already exists in tab "${e}"`),process.exitCode=1;return}let b={type:`Number`,config:{...i&&{label:i},...a&&{placeholder:a},...f!==void 0&&{min:f},...p!==void 0&&{max:p},...m!==void 0&&{step:m}}};_.json[y][d]=b;try{await s(g,z(_))}catch(e){e instanceof Error?console.error(`Failed to update custom type: ${e.message}`):console.error(`Failed to update custom type`),process.exitCode=1;return}console.info(`Added field "${d}" (Number) to "${y}" tab in ${u}`)}const je=T({id:O(),label:O(),repeatable:S(),status:S(),format:O(),json:D(O(),D(O(),k()))});async function Me(){let{values:{help:t,tab:n,label:i,placeholder:a,single:o,multi:c,"allow-target-blank":l},positionals:[u,d]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},single:{type:`string`},multi:{type:`string`},"allow-target-blank":{type:`boolean`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a rich text field to an existing custom type.
192
+ `),console.error(`Usage: prismic custom-type add-field number <type-id> <field-id>`),process.exitCode=1;return}let f=o===void 0?void 0:Number(o),p=c===void 0?void 0:Number(c),m=l===void 0?void 0:Number(l);if(o!==void 0&&Number.isNaN(f)){console.error(`Invalid --min value: must be a number`),process.exitCode=1;return}if(c!==void 0&&Number.isNaN(p)){console.error(`Invalid --max value: must be a number`),process.exitCode=1;return}if(l!==void 0&&Number.isNaN(m)){console.error(`Invalid --step value: must be a number`),process.exitCode=1;return}let h=await R(`package.json`);if(!h){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let g=new URL(`customtypes/${u}/index.json`,h),_;try{let e=await r(g,`utf8`),t=M(Oe,JSON.parse(e));if(!t.success){console.error(`Invalid custom type model: ${g.href}`),process.exitCode=1;return}_=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Custom type not found: ${u}\n`),console.error(`Create it first with: prismic custom-type create ${u}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read custom type: ${e.message}`):console.error(`Failed to read custom type`),process.exitCode=1;return}let v=Object.keys(_.json),y=n??v[0]??`Main`;_.json[y]||(_.json[y]={});for(let[e,t]of Object.entries(_.json))if(t[d]){console.error(`Field "${d}" already exists in tab "${e}"`),process.exitCode=1;return}let b={type:`Number`,config:{...i&&{label:i},...a&&{placeholder:a},...f!==void 0&&{min:f},...p!==void 0&&{max:p},...m!==void 0&&{step:m}}};_.json[y][d]=b;try{await s(g,B(_))}catch(e){e instanceof Error?console.error(`Failed to update custom type: ${e.message}`):console.error(`Failed to update custom type`),process.exitCode=1;return}console.info(`Added field "${d}" (Number) to "${y}" tab in ${u}`)}const Ae=E({id:k(),label:k(),repeatable:C(),status:C(),format:k(),json:O(k(),O(k(),A()))});async function je(){let{values:{help:t,tab:n,label:i,placeholder:a,single:o,multi:c,"allow-target-blank":l},positionals:[u,d]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},single:{type:`string`},multi:{type:`string`},"allow-target-blank":{type:`boolean`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a rich text field to an existing custom type.
193
193
 
194
194
  USAGE
195
195
  prismic custom-type add-field rich-text <type-id> <field-id> [flags]
@@ -218,7 +218,7 @@ EXAMPLES
218
218
  prismic custom-type add-field rich-text page tagline --single "heading1"
219
219
  prismic custom-type add-field rich-text blog post --multi "paragraph,strong,em,hyperlink" --allow-target-blank`);return}if(!u){console.error(`Missing required argument: type-id
220
220
  `),console.error(`Usage: prismic custom-type add-field rich-text <type-id> <field-id>`),process.exitCode=1;return}if(!d){console.error(`Missing required argument: field-id
221
- `),console.error(`Usage: prismic custom-type add-field rich-text <type-id> <field-id>`),process.exitCode=1;return}let f=await L(`package.json`);if(!f){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let p=new URL(`customtypes/${u}/index.json`,f),m;try{let e=await r(p,`utf8`),t=A(je,JSON.parse(e));if(!t.success){console.error(`Invalid custom type model: ${p.href}`),process.exitCode=1;return}m=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Custom type not found: ${u}\n`),console.error(`Create it first with: prismic custom-type create ${u}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read custom type: ${e.message}`):console.error(`Failed to read custom type`),process.exitCode=1;return}let h=Object.keys(m.json),g=n??h[0]??`Main`;m.json[g]||(m.json[g]={});for(let[e,t]of Object.entries(m.json))if(t[d]){console.error(`Field "${d}" already exists in tab "${e}"`),process.exitCode=1;return}let _={type:`StructuredText`,config:{...i&&{label:i},...a&&{placeholder:a},...o&&{single:o},...c&&{multi:c},...l&&{allowTargetBlank:!0}}};m.json[g][d]=_;try{await s(p,z(m))}catch(e){e instanceof Error?console.error(`Failed to update custom type: ${e.message}`):console.error(`Failed to update custom type`),process.exitCode=1;return}console.info(`Added field "${d}" (StructuredText) to "${g}" tab in ${u}`)}const Ne=T({id:O(),label:O(),repeatable:S(),status:S(),format:O(),json:D(O(),D(O(),k()))});async function Pe(){let{values:{help:t,tab:n,label:i,placeholder:a,option:o,default:c},positionals:[l,u]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},option:{type:`string`,multiple:!0},default:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a select (dropdown) field to an existing custom type.
221
+ `),console.error(`Usage: prismic custom-type add-field rich-text <type-id> <field-id>`),process.exitCode=1;return}let f=await R(`package.json`);if(!f){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let p=new URL(`customtypes/${u}/index.json`,f),m;try{let e=await r(p,`utf8`),t=M(Ae,JSON.parse(e));if(!t.success){console.error(`Invalid custom type model: ${p.href}`),process.exitCode=1;return}m=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Custom type not found: ${u}\n`),console.error(`Create it first with: prismic custom-type create ${u}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read custom type: ${e.message}`):console.error(`Failed to read custom type`),process.exitCode=1;return}let h=Object.keys(m.json),g=n??h[0]??`Main`;m.json[g]||(m.json[g]={});for(let[e,t]of Object.entries(m.json))if(t[d]){console.error(`Field "${d}" already exists in tab "${e}"`),process.exitCode=1;return}let _={type:`StructuredText`,config:{...i&&{label:i},...a&&{placeholder:a},...o&&{single:o},...c&&{multi:c},...l&&{allowTargetBlank:!0}}};m.json[g][d]=_;try{await s(p,B(m))}catch(e){e instanceof Error?console.error(`Failed to update custom type: ${e.message}`):console.error(`Failed to update custom type`),process.exitCode=1;return}console.info(`Added field "${d}" (StructuredText) to "${g}" tab in ${u}`)}const Me=E({id:k(),label:k(),repeatable:C(),status:C(),format:k(),json:O(k(),O(k(),A()))});async function Ne(){let{values:{help:t,tab:n,label:i,placeholder:a,option:o,default:c},positionals:[l,u]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},option:{type:`string`,multiple:!0},default:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a select (dropdown) field to an existing custom type.
222
222
 
223
223
  USAGE
224
224
  prismic custom-type add-field select <type-id> <field-id> [flags]
@@ -240,7 +240,7 @@ EXAMPLES
240
240
  prismic custom-type add-field select product size --option "small" --option "medium" --option "large" --default "medium"
241
241
  prismic custom-type add-field select article status --option "draft" --option "published" --label "Status"`);return}if(!l){console.error(`Missing required argument: type-id
242
242
  `),console.error(`Usage: prismic custom-type add-field select <type-id> <field-id>`),process.exitCode=1;return}if(!u){console.error(`Missing required argument: field-id
243
- `),console.error(`Usage: prismic custom-type add-field select <type-id> <field-id>`),process.exitCode=1;return}let d=await L(`package.json`);if(!d){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let f=new URL(`customtypes/${l}/index.json`,d),p;try{let e=await r(f,`utf8`),t=A(Ne,JSON.parse(e));if(!t.success){console.error(`Invalid custom type model: ${f.href}`),process.exitCode=1;return}p=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Custom type not found: ${l}\n`),console.error(`Create it first with: prismic custom-type create ${l}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read custom type: ${e.message}`):console.error(`Failed to read custom type`),process.exitCode=1;return}let m=Object.keys(p.json),h=n??m[0]??`Main`;p.json[h]||(p.json[h]={});for(let[e,t]of Object.entries(p.json))if(t[u]){console.error(`Field "${u}" already exists in tab "${e}"`),process.exitCode=1;return}let g={type:`Select`,config:{...i&&{label:i},...a&&{placeholder:a},...o&&o.length>0&&{options:o},...c&&{default_value:c}}};p.json[h][u]=g;try{await s(f,z(p))}catch(e){e instanceof Error?console.error(`Failed to update custom type: ${e.message}`):console.error(`Failed to update custom type`),process.exitCode=1;return}console.info(`Added field "${u}" (Select) to "${h}" tab in ${l}`)}const Fe=T({id:O(),label:O(),repeatable:S(),status:S(),format:O(),json:D(O(),D(O(),k()))});async function Ie(){let{values:{help:t,tab:n,label:i,placeholder:a,default:o},positionals:[c,l]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},default:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a timestamp (date and time) field to an existing custom type.
243
+ `),console.error(`Usage: prismic custom-type add-field select <type-id> <field-id>`),process.exitCode=1;return}let d=await R(`package.json`);if(!d){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let f=new URL(`customtypes/${l}/index.json`,d),p;try{let e=await r(f,`utf8`),t=M(Me,JSON.parse(e));if(!t.success){console.error(`Invalid custom type model: ${f.href}`),process.exitCode=1;return}p=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Custom type not found: ${l}\n`),console.error(`Create it first with: prismic custom-type create ${l}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read custom type: ${e.message}`):console.error(`Failed to read custom type`),process.exitCode=1;return}let m=Object.keys(p.json),h=n??m[0]??`Main`;p.json[h]||(p.json[h]={});for(let[e,t]of Object.entries(p.json))if(t[u]){console.error(`Field "${u}" already exists in tab "${e}"`),process.exitCode=1;return}let g={type:`Select`,config:{...i&&{label:i},...a&&{placeholder:a},...o&&o.length>0&&{options:o},...c&&{default_value:c}}};p.json[h][u]=g;try{await s(f,B(p))}catch(e){e instanceof Error?console.error(`Failed to update custom type: ${e.message}`):console.error(`Failed to update custom type`),process.exitCode=1;return}console.info(`Added field "${u}" (Select) to "${h}" tab in ${l}`)}const Pe=E({id:k(),label:k(),repeatable:C(),status:C(),format:k(),json:O(k(),O(k(),A()))});async function Fe(){let{values:{help:t,tab:n,label:i,placeholder:a,default:o},positionals:[c,l]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},default:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a timestamp (date and time) field to an existing custom type.
244
244
 
245
245
  USAGE
246
246
  prismic custom-type add-field timestamp <type-id> <field-id> [flags]
@@ -261,7 +261,7 @@ EXAMPLES
261
261
  prismic custom-type add-field timestamp event start --tab "Schedule"
262
262
  prismic custom-type add-field timestamp article published_at --label "Published At"`);return}if(!c){console.error(`Missing required argument: type-id
263
263
  `),console.error(`Usage: prismic custom-type add-field timestamp <type-id> <field-id>`),process.exitCode=1;return}if(!l){console.error(`Missing required argument: field-id
264
- `),console.error(`Usage: prismic custom-type add-field timestamp <type-id> <field-id>`),process.exitCode=1;return}let u=await L(`package.json`);if(!u){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let d=new URL(`customtypes/${c}/index.json`,u),f;try{let e=await r(d,`utf8`),t=A(Fe,JSON.parse(e));if(!t.success){console.error(`Invalid custom type model: ${d.href}`),process.exitCode=1;return}f=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Custom type not found: ${c}\n`),console.error(`Create it first with: prismic custom-type create ${c}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read custom type: ${e.message}`):console.error(`Failed to read custom type`),process.exitCode=1;return}let p=Object.keys(f.json),m=n??p[0]??`Main`;f.json[m]||(f.json[m]={});for(let[e,t]of Object.entries(f.json))if(t[l]){console.error(`Field "${l}" already exists in tab "${e}"`),process.exitCode=1;return}let h={type:`Timestamp`,config:{...i&&{label:i},...a&&{placeholder:a},...o&&{default:o}}};f.json[m][l]=h;try{await s(d,z(f))}catch(e){e instanceof Error?console.error(`Failed to update custom type: ${e.message}`):console.error(`Failed to update custom type`),process.exitCode=1;return}console.info(`Added field "${l}" (Timestamp) to "${m}" tab in ${c}`)}const Le=T({id:O(),label:O(),repeatable:S(),status:S(),format:O(),json:D(O(),D(O(),k()))});async function Re(){let{values:{help:t,tab:n,label:i,placeholder:a},positionals:[o,c]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a UID (unique identifier) field to an existing custom type.
264
+ `),console.error(`Usage: prismic custom-type add-field timestamp <type-id> <field-id>`),process.exitCode=1;return}let u=await R(`package.json`);if(!u){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let d=new URL(`customtypes/${c}/index.json`,u),f;try{let e=await r(d,`utf8`),t=M(Pe,JSON.parse(e));if(!t.success){console.error(`Invalid custom type model: ${d.href}`),process.exitCode=1;return}f=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Custom type not found: ${c}\n`),console.error(`Create it first with: prismic custom-type create ${c}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read custom type: ${e.message}`):console.error(`Failed to read custom type`),process.exitCode=1;return}let p=Object.keys(f.json),m=n??p[0]??`Main`;f.json[m]||(f.json[m]={});for(let[e,t]of Object.entries(f.json))if(t[l]){console.error(`Field "${l}" already exists in tab "${e}"`),process.exitCode=1;return}let h={type:`Timestamp`,config:{...i&&{label:i},...a&&{placeholder:a},...o&&{default:o}}};f.json[m][l]=h;try{await s(d,B(f))}catch(e){e instanceof Error?console.error(`Failed to update custom type: ${e.message}`):console.error(`Failed to update custom type`),process.exitCode=1;return}console.info(`Added field "${l}" (Timestamp) to "${m}" tab in ${c}`)}const Ie=E({id:k(),label:k(),repeatable:C(),status:C(),format:k(),json:O(k(),O(k(),A()))});async function Le(){let{values:{help:t,tab:n,label:i,placeholder:a},positionals:[o,c]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a UID (unique identifier) field to an existing custom type.
265
265
 
266
266
  USAGE
267
267
  prismic custom-type add-field uid <type-id> <field-id> [flags]
@@ -281,7 +281,7 @@ EXAMPLES
281
281
  prismic custom-type add-field uid article slug --label "URL Slug"
282
282
  prismic custom-type add-field uid product sku --placeholder "Enter unique SKU"`);return}if(!o){console.error(`Missing required argument: type-id
283
283
  `),console.error(`Usage: prismic custom-type add-field uid <type-id> <field-id>`),process.exitCode=1;return}if(!c){console.error(`Missing required argument: field-id
284
- `),console.error(`Usage: prismic custom-type add-field uid <type-id> <field-id>`),process.exitCode=1;return}let l=await L(`package.json`);if(!l){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let u=new URL(`customtypes/${o}/index.json`,l),d;try{let e=await r(u,`utf8`),t=A(Le,JSON.parse(e));if(!t.success){console.error(`Invalid custom type model: ${u.href}`),process.exitCode=1;return}d=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Custom type not found: ${o}\n`),console.error(`Create it first with: prismic custom-type create ${o}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read custom type: ${e.message}`):console.error(`Failed to read custom type`),process.exitCode=1;return}let f=Object.keys(d.json),p=n??f[0]??`Main`;d.json[p]||(d.json[p]={});for(let[e,t]of Object.entries(d.json))if(t[c]){console.error(`Field "${c}" already exists in tab "${e}"`),process.exitCode=1;return}let m={type:`UID`,config:{...i&&{label:i},...a&&{placeholder:a}}};d.json[p][c]=m;try{await s(u,z(d))}catch(e){e instanceof Error?console.error(`Failed to update custom type: ${e.message}`):console.error(`Failed to update custom type`),process.exitCode=1;return}console.info(`Added field "${c}" (UID) to "${p}" tab in ${o}`)}async function ze(){let{positionals:[t]}=e({args:process.argv.slice(4),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`boolean`:await me();break;case`color`:await ge();break;case`date`:await ve();break;case`embed`:await be();break;case`geo-point`:await Se();break;case`image`:await we();break;case`key-text`:await Ee();break;case`link`:await Oe();break;case`number`:await Ae();break;case`rich-text`:await Me();break;case`select`:await Pe();break;case`timestamp`:await Ie();break;case`uid`:await Re();break;default:t&&(console.error(`Unknown field type: ${t}\n`),process.exitCode=1),console.info(`Add a field to an existing custom type.
284
+ `),console.error(`Usage: prismic custom-type add-field uid <type-id> <field-id>`),process.exitCode=1;return}let l=await R(`package.json`);if(!l){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let u=new URL(`customtypes/${o}/index.json`,l),d;try{let e=await r(u,`utf8`),t=M(Ie,JSON.parse(e));if(!t.success){console.error(`Invalid custom type model: ${u.href}`),process.exitCode=1;return}d=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Custom type not found: ${o}\n`),console.error(`Create it first with: prismic custom-type create ${o}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read custom type: ${e.message}`):console.error(`Failed to read custom type`),process.exitCode=1;return}let f=Object.keys(d.json),p=n??f[0]??`Main`;d.json[p]||(d.json[p]={});for(let[e,t]of Object.entries(d.json))if(t[c]){console.error(`Field "${c}" already exists in tab "${e}"`),process.exitCode=1;return}let m={type:`UID`,config:{...i&&{label:i},...a&&{placeholder:a}}};d.json[p][c]=m;try{await s(u,B(d))}catch(e){e instanceof Error?console.error(`Failed to update custom type: ${e.message}`):console.error(`Failed to update custom type`),process.exitCode=1;return}console.info(`Added field "${c}" (UID) to "${p}" tab in ${o}`)}async function Re(){let{positionals:[t]}=e({args:process.argv.slice(4),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`boolean`:await pe();break;case`color`:await he();break;case`date`:await _e();break;case`embed`:await ye();break;case`geo-point`:await xe();break;case`image`:await Ce();break;case`key-text`:await Te();break;case`link`:await De();break;case`number`:await ke();break;case`rich-text`:await je();break;case`select`:await Ne();break;case`timestamp`:await Fe();break;case`uid`:await Le();break;default:t&&(console.error(`Unknown field type: ${t}\n`),process.exitCode=1),console.info(`Add a field to an existing custom type.
285
285
 
286
286
  USAGE
287
287
  prismic custom-type add-field <field-type> <type-id> <field-id> [flags]
@@ -311,7 +311,7 @@ EXAMPLES
311
311
  prismic custom-type add-field key-text homepage meta_title --tab "SEO"
312
312
  prismic custom-type add-field link homepage button --allow-text
313
313
  prismic custom-type add-field rich-text homepage body --multi "paragraph,heading2,strong,em"
314
- prismic custom-type add-field select homepage layout --option "full" --option "sidebar"`)}}const Be=T({id:O(),type:ie(`SharedSlice`),name:O(),description:E(O()),variations:x(T({id:O(),name:O(),description:E(O()),docURL:E(O()),version:E(O()),imageUrl:E(O()),primary:E(D(O(),k())),items:E(D(O(),k()))}))});async function B(e){if(!await L(`package.json`))return{ok:!1,error:`Could not find project root (no package.json found)`};let t=await V(),n;try{n=await i(t,{withFileTypes:!1})}catch{return{ok:!1,error:`No slices directory found at ${t.href}`}}for(let i of n){let n=new URL(`${i}/model.json`,t);try{let t=await r(n,`utf8`),i=JSON.parse(t);if(i.id===e){let e=A(Be,i);return e.success?{ok:!0,model:e.output,modelPath:n}:{ok:!1,error:`Invalid slice model at ${n.href}`}}}catch{}}return{ok:!1,error:`Slice not found: ${e}\n\nCreate it first with: prismic slice create ${e}`}}async function V(){let e=await He(),t=await L(`package.json`);if(!t)throw Error(`Could not find project root (no package.json found)`);let n=new URL(`.`,t);switch(e){case`next`:if(await R(new URL(`src`,n)))return new URL(`src/slices/`,n);case`nuxt`:if(await R(new URL(`app`,n)))return new URL(`app/slices/`,n);case`sveltekit`:return new URL(`src/slices/`,n)}return new URL(`slices/`,n)}const Ve=T({dependencies:E(D(O(),O()))});async function He(){let e=await L(`package.json`);if(e)try{let t=await r(e,`utf8`),{dependencies:n={}}=ae(Ve,JSON.parse(t));if(`next`in n)return`next`;if(`nuxt`in n)return`nuxt`;if(`@sveltejs/kit`in n)return`sveltekit`}catch{}}function H(e){return e.toLowerCase().replace(/(^|[-_\s]+)(.)?/g,(e,t,n)=>n?.toUpperCase()??``)}const Ue=T({id:O(),label:O(),repeatable:S(),status:S(),format:O(),json:D(O(),D(O(),k()))});async function We(){let{values:{help:t,"slice-zone":n},positionals:[i,a]}=e({args:process.argv.slice(4),options:{"slice-zone":{type:`string`,short:`z`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Connect a shared slice to a custom type's slice zone.
314
+ prismic custom-type add-field select homepage layout --option "full" --option "sidebar"`)}}const ze=E({id:k(),type:re(`SharedSlice`),name:k(),description:D(k()),variations:S(E({id:k(),name:k(),description:D(k()),docURL:D(k()),version:D(k()),imageUrl:D(k()),primary:D(O(k(),A())),items:D(O(k(),A()))}))});async function V(e){if(!await R(`package.json`))return{ok:!1,error:`Could not find project root (no package.json found)`};let t=await Be(),n;try{n=await i(t,{withFileTypes:!1})}catch{return{ok:!1,error:`No slices directory found at ${t.href}`}}for(let i of n){let n=new URL(`${i}/model.json`,t);try{let t=await r(n,`utf8`),i=JSON.parse(t);if(i.id===e){let e=M(ze,i);return e.success?{ok:!0,model:e.output,modelPath:n}:{ok:!1,error:`Invalid slice model at ${n.href}`}}}catch{}}return{ok:!1,error:`Slice not found: ${e}\n\nCreate it first with: prismic slice create ${e}`}}async function Be(){let e=await He(),t=await R(`package.json`);if(!t)throw Error(`Could not find project root (no package.json found)`);let n=new URL(`.`,t);switch(e){case`next`:if(await z(new URL(`src`,n)))return new URL(`src/slices/`,n);case`nuxt`:if(await z(new URL(`app`,n)))return new URL(`app/slices/`,n);case`sveltekit`:return new URL(`src/slices/`,n)}return new URL(`slices/`,n)}const Ve=E({dependencies:D(O(k(),k()))});async function He(){let e=await R(`package.json`);if(e)try{let t=await r(e,`utf8`),{dependencies:n={}}=j(Ve,JSON.parse(t));if(`next`in n)return`next`;if(`nuxt`in n)return`nuxt`;if(`@sveltejs/kit`in n)return`sveltekit`}catch{}}function Ue(e){return e.toLowerCase().replace(/(^|[-_\s]+)(.)?/g,(e,t,n)=>n?.toUpperCase()??``)}const We=E({id:k(),label:k(),repeatable:C(),status:C(),format:k(),json:O(k(),O(k(),A()))});async function Ge(){let{values:{help:t,"slice-zone":n},positionals:[i,a]}=e({args:process.argv.slice(4),options:{"slice-zone":{type:`string`,short:`z`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Connect a shared slice to a custom type's slice zone.
315
315
 
316
316
  USAGE
317
317
  prismic custom-type connect-slice <type-id> <slice-id> [flags]
@@ -329,7 +329,7 @@ EXAMPLES
329
329
  prismic custom-type connect-slice homepage CallToAction --slice-zone slices
330
330
  prismic custom-type connect-slice article HeroSection -z body`);return}if(!i){console.error(`Missing required argument: type-id
331
331
  `),console.error(`Usage: prismic custom-type connect-slice <type-id> <slice-id>`),process.exitCode=1;return}if(!a){console.error(`Missing required argument: slice-id
332
- `),console.error(`Usage: prismic custom-type connect-slice <type-id> <slice-id>`),process.exitCode=1;return}let o=await B(a);if(!o.ok){console.error(o.error),process.exitCode=1;return}let c=await L(`package.json`);if(!c){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let l=new URL(`customtypes/${i}/index.json`,c),u;try{let e=await r(l,`utf8`),t=A(Ue,JSON.parse(e));if(!t.success){console.error(`Invalid custom type model: ${l.href}`),process.exitCode=1;return}u=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Custom type not found: ${i}\n`),console.error(`Create it first with: prismic custom-type create ${i}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read custom type: ${e.message}`):console.error(`Failed to read custom type`),process.exitCode=1;return}let d=n??`slices`,f,p;for(let[,e]of Object.entries(u.json)){for(let[t,n]of Object.entries(e))if(n.type===`Slices`&&t===d){f=n,p=t;break}if(f)break}if(!f){if(n){console.error(`Slice zone "${n}" not found in custom type "${i}"`),process.exitCode=1;return}let e=Object.keys(u.json)[0]??`Main`;u.json[e]||(u.json[e]={});let t={type:`Slices`,fieldset:`Slice Zone`,config:{choices:{}}};u.json[e][d]=t,f=t,p=d}if(f.config||={choices:{}},f.config.choices||(f.config.choices={}),a in f.config.choices){console.info(`Slice "${a}" is already connected to slice zone "${p}" in ${i}`);return}let m={type:`SharedSlice`};f.config.choices[a]=m;try{await s(l,z(u))}catch(e){e instanceof Error?console.error(`Failed to update custom type: ${e.message}`):console.error(`Failed to update custom type`),process.exitCode=1;return}console.info(`Connected slice "${a}" to slice zone "${p}" in ${i}`)}async function Ge(){let{values:{help:t,name:r,single:i},positionals:[a]}=e({args:process.argv.slice(4),options:{name:{type:`string`,short:`n`},single:{type:`boolean`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Create a new custom type in a Prismic repository.
332
+ `),console.error(`Usage: prismic custom-type connect-slice <type-id> <slice-id>`),process.exitCode=1;return}let o=await V(a);if(!o.ok){console.error(o.error),process.exitCode=1;return}let c=await R(`package.json`);if(!c){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let l=new URL(`customtypes/${i}/index.json`,c),u;try{let e=await r(l,`utf8`),t=M(We,JSON.parse(e));if(!t.success){console.error(`Invalid custom type model: ${l.href}`),process.exitCode=1;return}u=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Custom type not found: ${i}\n`),console.error(`Create it first with: prismic custom-type create ${i}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read custom type: ${e.message}`):console.error(`Failed to read custom type`),process.exitCode=1;return}let d=n??`slices`,f,p;for(let[,e]of Object.entries(u.json)){for(let[t,n]of Object.entries(e))if(n.type===`Slices`&&t===d){f=n,p=t;break}if(f)break}if(!f){if(n){console.error(`Slice zone "${n}" not found in custom type "${i}"`),process.exitCode=1;return}let e=Object.keys(u.json)[0]??`Main`;u.json[e]||(u.json[e]={});let t={type:`Slices`,fieldset:`Slice Zone`,config:{choices:{}}};u.json[e][d]=t,f=t,p=d}if(f.config||={choices:{}},f.config.choices||(f.config.choices={}),a in f.config.choices){console.info(`Slice "${a}" is already connected to slice zone "${p}" in ${i}`);return}let m={type:`SharedSlice`};f.config.choices[a]=m;try{await s(l,B(u))}catch(e){e instanceof Error?console.error(`Failed to update custom type: ${e.message}`):console.error(`Failed to update custom type`),process.exitCode=1;return}console.info(`Connected slice "${a}" to slice zone "${p}" in ${i}`)}async function Ke(){let{values:{help:t,name:r,single:i},positionals:[a]}=e({args:process.argv.slice(4),options:{name:{type:`string`,short:`n`},single:{type:`boolean`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Create a new custom type in a Prismic repository.
333
333
 
334
334
  USAGE
335
335
  prismic custom-type create <id> [flags]
@@ -343,7 +343,7 @@ FLAGS
343
343
  -h, --help Show help for command
344
344
 
345
345
  LEARN MORE
346
- Use \`prismic custom-type <command> --help\` for more information about a command.`);return}if(!a){console.error(`Missing required argument: id`),process.exitCode=1;return}let o={id:a,label:r??Ke(a),repeatable:!i,status:!0,format:`custom`,json:{Main:{}}},c=await L(`package.json`);if(!c){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let l=new URL(`customtypes/`,c),u=new URL(a+`/`,l),d=new URL(`index.json`,u);try{await n(new URL(`.`,d),{recursive:!0}),await s(d,z(o))}catch(e){e instanceof Error?console.error(`Failed to create custom type: ${e.message}`):console.error(`Failed to create custom type`),process.exitCode=1;return}console.info(`Created custom type at ${d.href}`)}function Ke(e){return e.toLowerCase().replace(/(^|[-_\s]+)(.)?/g,(e,t,n)=>n?.toUpperCase()??``)}const qe=T({id:O(),label:O(),repeatable:S(),status:S(),format:O(),json:D(O(),D(O(),k()))});async function Je(){let{values:{help:t,"slice-zone":n},positionals:[i,a]}=e({args:process.argv.slice(4),options:{"slice-zone":{type:`string`,short:`z`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Disconnect a shared slice from a custom type's slice zone.
346
+ Use \`prismic custom-type <command> --help\` for more information about a command.`);return}if(!a){console.error(`Missing required argument: id`),process.exitCode=1;return}let o={id:a,label:r??qe(a),repeatable:!i,status:!0,format:`custom`,json:{Main:{}}},c=await R(`package.json`);if(!c){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let l=new URL(`customtypes/`,c),u=new URL(a+`/`,l),d=new URL(`index.json`,u);try{await n(new URL(`.`,d),{recursive:!0}),await s(d,B(o))}catch(e){e instanceof Error?console.error(`Failed to create custom type: ${e.message}`):console.error(`Failed to create custom type`),process.exitCode=1;return}console.info(`Created custom type at ${d.href}`)}function qe(e){return e.toLowerCase().replace(/(^|[-_\s]+)(.)?/g,(e,t,n)=>n?.toUpperCase()??``)}const Je=E({id:k(),label:k(),repeatable:C(),status:C(),format:k(),json:O(k(),O(k(),A()))});async function Ye(){let{values:{help:t,"slice-zone":n},positionals:[i,a]}=e({args:process.argv.slice(4),options:{"slice-zone":{type:`string`,short:`z`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Disconnect a shared slice from a custom type's slice zone.
347
347
 
348
348
  USAGE
349
349
  prismic custom-type disconnect-slice <type-id> <slice-id> [flags]
@@ -361,7 +361,7 @@ EXAMPLES
361
361
  prismic custom-type disconnect-slice homepage CallToAction --slice-zone slices
362
362
  prismic custom-type disconnect-slice article HeroSection -z body`);return}if(!i){console.error(`Missing required argument: type-id
363
363
  `),console.error(`Usage: prismic custom-type disconnect-slice <type-id> <slice-id>`),process.exitCode=1;return}if(!a){console.error(`Missing required argument: slice-id
364
- `),console.error(`Usage: prismic custom-type disconnect-slice <type-id> <slice-id>`),process.exitCode=1;return}let o=await L(`package.json`);if(!o){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let c=new URL(`customtypes/${i}/index.json`,o),l;try{let e=await r(c,`utf8`),t=A(qe,JSON.parse(e));if(!t.success){console.error(`Invalid custom type model: ${c.href}`),process.exitCode=1;return}l=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Custom type not found: ${i}\n`),console.error(`Create it first with: prismic custom-type create ${i}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read custom type: ${e.message}`):console.error(`Failed to read custom type`),process.exitCode=1;return}let u=n??`slices`,d,f;for(let[,e]of Object.entries(l.json)){for(let[t,n]of Object.entries(e))if(n.type===`Slices`&&t===u){d=n,f=t;break}if(d)break}if(!d){console.error(`Slice zone "${u}" not found in custom type "${i}"`),process.exitCode=1;return}if(!d.config?.choices||!(a in d.config.choices)){console.error(`Slice "${a}" is not connected to slice zone "${f}" in ${i}`),process.exitCode=1;return}delete d.config.choices[a];try{await s(c,z(l))}catch(e){e instanceof Error?console.error(`Failed to update custom type: ${e.message}`):console.error(`Failed to update custom type`),process.exitCode=1;return}console.info(`Disconnected slice "${a}" from slice zone "${f}" in ${i}`)}const Ye=T({id:O(),label:O(),repeatable:S(),status:S(),format:E(O()),json:D(O(),D(O(),k()))});async function Xe(){let{values:{help:t,json:n}}=e({args:process.argv.slice(4),options:{json:{type:`boolean`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`List all custom types in a Prismic project.
364
+ `),console.error(`Usage: prismic custom-type disconnect-slice <type-id> <slice-id>`),process.exitCode=1;return}let o=await R(`package.json`);if(!o){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let c=new URL(`customtypes/${i}/index.json`,o),l;try{let e=await r(c,`utf8`),t=M(Je,JSON.parse(e));if(!t.success){console.error(`Invalid custom type model: ${c.href}`),process.exitCode=1;return}l=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Custom type not found: ${i}\n`),console.error(`Create it first with: prismic custom-type create ${i}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read custom type: ${e.message}`):console.error(`Failed to read custom type`),process.exitCode=1;return}let u=n??`slices`,d,f;for(let[,e]of Object.entries(l.json)){for(let[t,n]of Object.entries(e))if(n.type===`Slices`&&t===u){d=n,f=t;break}if(d)break}if(!d){console.error(`Slice zone "${u}" not found in custom type "${i}"`),process.exitCode=1;return}if(!d.config?.choices||!(a in d.config.choices)){console.error(`Slice "${a}" is not connected to slice zone "${f}" in ${i}`),process.exitCode=1;return}delete d.config.choices[a];try{await s(c,B(l))}catch(e){e instanceof Error?console.error(`Failed to update custom type: ${e.message}`):console.error(`Failed to update custom type`),process.exitCode=1;return}console.info(`Disconnected slice "${a}" from slice zone "${f}" in ${i}`)}const Xe=E({id:k(),label:k(),repeatable:C(),status:C(),format:D(k()),json:O(k(),O(k(),A()))});async function Ze(){let{values:{help:t,json:n}}=e({args:process.argv.slice(4),options:{json:{type:`boolean`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`List all custom types in a Prismic project.
365
365
 
366
366
  USAGE
367
367
  prismic custom-type list [flags]
@@ -372,7 +372,7 @@ FLAGS
372
372
 
373
373
  EXAMPLES
374
374
  prismic custom-type list
375
- prismic custom-type list --json`);return}let a=await L(`package.json`);if(!a){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let o=new URL(`customtypes/`,a),s;try{s=await i(o,{withFileTypes:!1})}catch{n?console.info(JSON.stringify([])):console.info(`No custom types found.`);return}let c=[];for(let e of s){let t=new URL(`${e}/index.json`,o);try{let e=await r(t,`utf8`),n=A(Ye,JSON.parse(e));n.success&&n.output.format!==`page`&&c.push({id:n.output.id,label:n.output.label,repeatable:n.output.repeatable})}catch{}}if(c.length===0){n?console.info(JSON.stringify([])):console.info(`No custom types found.`);return}if(n)console.info(JSON.stringify(c,null,2));else{console.info(`ID LABEL TYPE`);for(let e of c){let t=e.repeatable?`repeatable`:`singleton`;console.info(`${e.id}\t${e.label}\t${t}`)}}}const Ze=T({id:O(),label:O(),repeatable:S(),status:S(),format:E(O()),json:D(O(),D(O(),k()))});async function Qe(){let{values:{help:t,y:n},positionals:[i]}=e({args:process.argv.slice(4),options:{y:{type:`boolean`,short:`y`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Remove a custom type from the project.
375
+ prismic custom-type list --json`);return}let a=await R(`package.json`);if(!a){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let o=new URL(`customtypes/`,a),s;try{s=await i(o,{withFileTypes:!1})}catch{n?console.info(JSON.stringify([])):console.info(`No custom types found.`);return}let c=[];for(let e of s){let t=new URL(`${e}/index.json`,o);try{let e=await r(t,`utf8`),n=M(Xe,JSON.parse(e));n.success&&n.output.format!==`page`&&c.push({id:n.output.id,label:n.output.label,repeatable:n.output.repeatable})}catch{}}if(c.length===0){n?console.info(JSON.stringify([])):console.info(`No custom types found.`);return}if(n)console.info(JSON.stringify(c,null,2));else{console.info(`ID LABEL TYPE`);for(let e of c){let t=e.repeatable?`repeatable`:`singleton`;console.info(`${e.id}\t${e.label}\t${t}`)}}}const Qe=E({id:k(),label:k(),repeatable:C(),status:C(),format:D(k()),json:O(k(),O(k(),A()))});async function $e(){let{values:{help:t,y:n},positionals:[i]}=e({args:process.argv.slice(4),options:{y:{type:`boolean`,short:`y`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Remove a custom type from the project.
376
376
 
377
377
  USAGE
378
378
  prismic custom-type remove <type-id> [flags]
@@ -387,7 +387,7 @@ FLAGS
387
387
  EXAMPLES
388
388
  prismic custom-type remove settings
389
389
  prismic custom-type remove settings -y`);return}if(!i){console.error(`Missing required argument: type-id
390
- `),console.error(`Usage: prismic custom-type remove <type-id>`),process.exitCode=1;return}let a=await L(`package.json`);if(!a){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let s=new URL(`customtypes/${i}/`,a),c=new URL(`index.json`,s),l;try{let e=await r(c,`utf8`),t=A(Ze,JSON.parse(e));if(!t.success){console.error(`Invalid custom type model: ${c.href}`),process.exitCode=1;return}l=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Custom type not found: ${i}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read custom type: ${e.message}`):console.error(`Failed to read custom type`),process.exitCode=1;return}if(l.format===`page`){console.error(`"${i}" is not a custom type (format: page)`),process.exitCode=1;return}if(!n){console.error(`Refusing to remove custom type "${i}" (this will delete the entire directory).`),console.error(`Re-run with -y to confirm.`),process.exitCode=1;return}try{await o(s,{recursive:!0})}catch(e){e instanceof Error?console.error(`Failed to remove custom type: ${e.message}`):console.error(`Failed to remove custom type`),process.exitCode=1;return}console.info(`Removed custom type "${i}"`)}const $e=T({id:O(),label:O(),repeatable:S(),status:S(),format:E(O()),json:D(O(),D(O(),k()))});async function et(){let{values:{help:t,tab:n},positionals:[i,a]}=e({args:process.argv.slice(4),options:{tab:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Remove a field from a custom type.
390
+ `),console.error(`Usage: prismic custom-type remove <type-id>`),process.exitCode=1;return}let a=await R(`package.json`);if(!a){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let s=new URL(`customtypes/${i}/`,a),c=new URL(`index.json`,s),l;try{let e=await r(c,`utf8`),t=M(Qe,JSON.parse(e));if(!t.success){console.error(`Invalid custom type model: ${c.href}`),process.exitCode=1;return}l=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Custom type not found: ${i}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read custom type: ${e.message}`):console.error(`Failed to read custom type`),process.exitCode=1;return}if(l.format===`page`){console.error(`"${i}" is not a custom type (format: page)`),process.exitCode=1;return}if(!n){console.error(`Refusing to remove custom type "${i}" (this will delete the entire directory).`),console.error(`Re-run with -y to confirm.`),process.exitCode=1;return}try{await o(s,{recursive:!0})}catch(e){e instanceof Error?console.error(`Failed to remove custom type: ${e.message}`):console.error(`Failed to remove custom type`),process.exitCode=1;return}console.info(`Removed custom type "${i}"`)}const et=E({id:k(),label:k(),repeatable:C(),status:C(),format:D(k()),json:O(k(),O(k(),A()))});async function tt(){let{values:{help:t,tab:n},positionals:[i,a]}=e({args:process.argv.slice(4),options:{tab:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Remove a field from a custom type.
391
391
 
392
392
  USAGE
393
393
  prismic custom-type remove-field <type-id> <field-id> [flags]
@@ -404,7 +404,7 @@ EXAMPLES
404
404
  prismic custom-type remove-field settings title
405
405
  prismic custom-type remove-field settings description --tab "Content"`);return}if(!i){console.error(`Missing required argument: type-id
406
406
  `),console.error(`Usage: prismic custom-type remove-field <type-id> <field-id>`),process.exitCode=1;return}if(!a){console.error(`Missing required argument: field-id
407
- `),console.error(`Usage: prismic custom-type remove-field <type-id> <field-id>`),process.exitCode=1;return}let o=await L(`package.json`);if(!o){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let c=new URL(`customtypes/${i}/index.json`,o),l;try{let e=await r(c,`utf8`),t=A($e,JSON.parse(e));if(!t.success){console.error(`Invalid custom type model: ${c.href}`),process.exitCode=1;return}l=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Custom type not found: ${i}\n`),console.error(`Create it first with: prismic custom-type create ${i}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read custom type: ${e.message}`):console.error(`Failed to read custom type`),process.exitCode=1;return}if(l.format===`page`){console.error(`"${i}" is not a custom type (format: page)`),process.exitCode=1;return}let u;if(n){if(!l.json[n]){console.error(`Tab "${n}" not found in custom type "${i}"`),console.error(`Available tabs: ${Object.keys(l.json).join(`, `)}`),process.exitCode=1;return}if(!(a in l.json[n])){console.error(`Field "${a}" not found in tab "${n}"`),process.exitCode=1;return}delete l.json[n][a],u=n}else{for(let[e,t]of Object.entries(l.json))if(a in t){delete t[a],u=e;break}if(!u){console.error(`Field "${a}" not found in any tab of custom type "${i}"`),process.exitCode=1;return}}try{await s(c,z(l))}catch(e){e instanceof Error?console.error(`Failed to update custom type: ${e.message}`):console.error(`Failed to update custom type`),process.exitCode=1;return}console.info(`Removed field "${a}" from tab "${u}" in custom type "${i}"`)}const tt=T({id:O(),label:O(),repeatable:S(),status:S(),format:E(O()),json:D(O(),D(O(),k()))});async function nt(){let{values:{help:t},positionals:[n,i]}=e({args:process.argv.slice(4),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Change a custom type's display name (label).
407
+ `),console.error(`Usage: prismic custom-type remove-field <type-id> <field-id>`),process.exitCode=1;return}let o=await R(`package.json`);if(!o){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let c=new URL(`customtypes/${i}/index.json`,o),l;try{let e=await r(c,`utf8`),t=M(et,JSON.parse(e));if(!t.success){console.error(`Invalid custom type model: ${c.href}`),process.exitCode=1;return}l=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Custom type not found: ${i}\n`),console.error(`Create it first with: prismic custom-type create ${i}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read custom type: ${e.message}`):console.error(`Failed to read custom type`),process.exitCode=1;return}if(l.format===`page`){console.error(`"${i}" is not a custom type (format: page)`),process.exitCode=1;return}let u;if(n){if(!l.json[n]){console.error(`Tab "${n}" not found in custom type "${i}"`),console.error(`Available tabs: ${Object.keys(l.json).join(`, `)}`),process.exitCode=1;return}if(!(a in l.json[n])){console.error(`Field "${a}" not found in tab "${n}"`),process.exitCode=1;return}delete l.json[n][a],u=n}else{for(let[e,t]of Object.entries(l.json))if(a in t){delete t[a],u=e;break}if(!u){console.error(`Field "${a}" not found in any tab of custom type "${i}"`),process.exitCode=1;return}}try{await s(c,B(l))}catch(e){e instanceof Error?console.error(`Failed to update custom type: ${e.message}`):console.error(`Failed to update custom type`),process.exitCode=1;return}console.info(`Removed field "${a}" from tab "${u}" in custom type "${i}"`)}const nt=E({id:k(),label:k(),repeatable:C(),status:C(),format:D(k()),json:O(k(),O(k(),A()))});async function rt(){let{values:{help:t},positionals:[n,i]}=e({args:process.argv.slice(4),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Change a custom type's display name (label).
408
408
 
409
409
  USAGE
410
410
  prismic custom-type set-name <type-id> <new-name> [flags]
@@ -420,7 +420,7 @@ EXAMPLES
420
420
  prismic custom-type set-name settings "Site Settings"
421
421
  prismic custom-type set-name menu "Navigation Menu"`);return}if(!n){console.error(`Missing required argument: type-id
422
422
  `),console.error(`Usage: prismic custom-type set-name <type-id> <new-name>`),process.exitCode=1;return}if(!i){console.error(`Missing required argument: new-name
423
- `),console.error(`Usage: prismic custom-type set-name <type-id> <new-name>`),process.exitCode=1;return}let a=await L(`package.json`);if(!a){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let o=new URL(`customtypes/${n}/index.json`,a),c;try{let e=await r(o,`utf8`),t=A(tt,JSON.parse(e));if(!t.success){console.error(`Invalid custom type model: ${o.href}`),process.exitCode=1;return}c=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Custom type not found: ${n}\n`),console.error(`Create it first with: prismic custom-type create ${n}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read custom type: ${e.message}`):console.error(`Failed to read custom type`),process.exitCode=1;return}if(c.format===`page`){console.error(`"${n}" is not a custom type (format: page)`),process.exitCode=1;return}c.label=i;try{await s(o,z(c))}catch(e){e instanceof Error?console.error(`Failed to update custom type: ${e.message}`):console.error(`Failed to update custom type`),process.exitCode=1;return}console.info(`Renamed custom type "${n}" to "${i}"`)}const rt=T({id:O(),label:O(),repeatable:S(),status:S(),format:E(O()),json:D(O(),D(O(),k()))});async function it(){let{values:{help:t,json:n},positionals:[i]}=e({args:process.argv.slice(4),options:{json:{type:`boolean`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`View details of a specific custom type.
423
+ `),console.error(`Usage: prismic custom-type set-name <type-id> <new-name>`),process.exitCode=1;return}let a=await R(`package.json`);if(!a){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let o=new URL(`customtypes/${n}/index.json`,a),c;try{let e=await r(o,`utf8`),t=M(nt,JSON.parse(e));if(!t.success){console.error(`Invalid custom type model: ${o.href}`),process.exitCode=1;return}c=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Custom type not found: ${n}\n`),console.error(`Create it first with: prismic custom-type create ${n}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read custom type: ${e.message}`):console.error(`Failed to read custom type`),process.exitCode=1;return}if(c.format===`page`){console.error(`"${n}" is not a custom type (format: page)`),process.exitCode=1;return}c.label=i;try{await s(o,B(c))}catch(e){e instanceof Error?console.error(`Failed to update custom type: ${e.message}`):console.error(`Failed to update custom type`),process.exitCode=1;return}console.info(`Renamed custom type "${n}" to "${i}"`)}const it=E({id:k(),label:k(),repeatable:C(),status:C(),format:D(k()),json:O(k(),O(k(),A()))});async function at(){let{values:{help:t,json:n},positionals:[i]}=e({args:process.argv.slice(4),options:{json:{type:`boolean`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`View details of a specific custom type.
424
424
 
425
425
  USAGE
426
426
  prismic custom-type view <type-id> [flags]
@@ -435,7 +435,7 @@ FLAGS
435
435
  EXAMPLES
436
436
  prismic custom-type view settings
437
437
  prismic custom-type view settings --json`);return}if(!i){console.error(`Missing required argument: type-id
438
- `),console.error(`Usage: prismic custom-type view <type-id>`),process.exitCode=1;return}let a=await L(`package.json`);if(!a){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let o=new URL(`customtypes/${i}/index.json`,a),s;try{let e=await r(o,`utf8`),t=A(rt,JSON.parse(e));if(!t.success){console.error(`Invalid custom type model: ${o.href}`),process.exitCode=1;return}s=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Custom type not found: ${i}\n`),console.error(`Create it first with: prismic custom-type create ${i}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read custom type: ${e.message}`):console.error(`Failed to read custom type`),process.exitCode=1;return}if(s.format===`page`){console.error(`"${i}" is not a custom type (format: page)`),process.exitCode=1;return}if(n){console.info(JSON.stringify(s,null,2));return}console.info(`ID: ${s.id}`),console.info(`Label: ${s.label}`),console.info(`Repeatable: ${s.repeatable}`);let c=Object.entries(s.json);console.info(`\nTabs (${c.length}):`);for(let[e,t]of c){let n=Object.keys(t).length;console.info(` - ${e}: ${n} fields`)}}async function at(){let{positionals:[t]}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`create`:await Ge();break;case`list`:await Xe();break;case`view`:await it();break;case`remove`:await Qe();break;case`set-name`:await nt();break;case`add-field`:await ze();break;case`remove-field`:await et();break;case`connect-slice`:await We();break;case`disconnect-slice`:await Je();break;default:t&&(console.error(`Unknown custom-type subcommand: ${t}\n`),process.exitCode=1),console.info(`Manage custom types in a Prismic repository.
438
+ `),console.error(`Usage: prismic custom-type view <type-id>`),process.exitCode=1;return}let a=await R(`package.json`);if(!a){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let o=new URL(`customtypes/${i}/index.json`,a),s;try{let e=await r(o,`utf8`),t=M(it,JSON.parse(e));if(!t.success){console.error(`Invalid custom type model: ${o.href}`),process.exitCode=1;return}s=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Custom type not found: ${i}\n`),console.error(`Create it first with: prismic custom-type create ${i}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read custom type: ${e.message}`):console.error(`Failed to read custom type`),process.exitCode=1;return}if(s.format===`page`){console.error(`"${i}" is not a custom type (format: page)`),process.exitCode=1;return}if(n){console.info(JSON.stringify(s,null,2));return}console.info(`ID: ${s.id}`),console.info(`Label: ${s.label}`),console.info(`Repeatable: ${s.repeatable}`);let c=Object.entries(s.json);console.info(`\nTabs (${c.length}):`);for(let[e,t]of c){let n=Object.keys(t).length;console.info(` - ${e}: ${n} fields`)}}async function ot(){let{positionals:[t]}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`create`:await Ke();break;case`list`:await Ze();break;case`view`:await at();break;case`remove`:await $e();break;case`set-name`:await rt();break;case`add-field`:await Re();break;case`remove-field`:await tt();break;case`connect-slice`:await Ge();break;case`disconnect-slice`:await Ye();break;default:t&&(console.error(`Unknown custom-type subcommand: ${t}\n`),process.exitCode=1),console.info(`Manage custom types in a Prismic repository.
439
439
 
440
440
  USAGE
441
441
  prismic custom-type <command> [flags]
@@ -455,7 +455,7 @@ FLAGS
455
455
  -h, --help Show help for command
456
456
 
457
457
  LEARN MORE
458
- Use \`prismic custom-type <command> --help\` for more information about a command.`)}}const ot=`prismic.config.json`,st=T({repositoryName:O(),apiEndpoint:E(oe(O(),te())),localSliceMachineSimulatorURL:E(oe(O(),te())),libraries:E(x(O())),adapter:E(O()),labs:E(T({legacySliceUpgrader:E(S())}))});async function ct(e,t=c(process.cwd())){let n=await ft(t);return n.ok?(await s(n.path,z(e)),{ok:!0,config:e}):n}async function U(e=c(process.cwd())){let t=await W(e);if(t.ok)return t.config.repositoryName}async function W(e=c(process.cwd())){let t=await dt(e);if(!t.ok)return t;try{let e=await r(t.path,`utf8`),n=A(st,JSON.parse(e));return n.success?{ok:!0,config:n.output}:{ok:!1,error:new lt(n.issues)}}catch{return{ok:!1,error:new lt}}}var lt=class extends Error{issues;constructor(e=[]){super(`prismic.config.json is invalid.`),this.issues=e}};async function ut(e,t=c(process.cwd())){let n=await dt(t);if(!n.ok)return n;let r=await W(t);if(!r.ok)return r;let i={...r.config,...e};return await s(n.path,z(i)),{ok:!0,config:i}}async function dt(e=c(process.cwd())){let t=await L(ot,{start:e,stop:`package.json`});return t?{ok:!0,path:t}:{ok:!1,error:new pt}}async function ft(e=c(process.cwd())){let t=await L(`package.json`,{start:e});return t?{ok:!0,path:new URL(ot,t)}:{ok:!1,error:new mt}}var pt=class extends Error{message=`Could not find a prismic.config.json file.`},mt=class extends Error{message=`Could not find a package.json file.`};async function ht(){let{values:t}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`},repo:{type:`string`,short:`r`}}});if(t.help){console.info(`Initialize a Prismic project by creating a prismic.config.json file.
458
+ Use \`prismic custom-type <command> --help\` for more information about a command.`)}}const st=`prismic.config.json`,ct=E({repositoryName:k(),apiEndpoint:D(ie(k(),te())),localSliceMachineSimulatorURL:D(ie(k(),te())),libraries:D(S(k())),adapter:D(k()),labs:D(E({legacySliceUpgrader:D(C())}))});async function lt(e,t=c(process.cwd())){let n=await pt(t);return n.ok?(await s(n.path,B(e)),{ok:!0,config:e}):n}async function H(e=c(process.cwd())){let t=await U(e);if(t.ok)return t.config.repositoryName}async function U(e=c(process.cwd())){let t=await ft(e);if(!t.ok)return t;try{let e=await r(t.path,`utf8`),n=M(ct,JSON.parse(e));return n.success?{ok:!0,config:n.output}:{ok:!1,error:new ut(n.issues)}}catch{return{ok:!1,error:new ut}}}var ut=class extends Error{issues;constructor(e=[]){super(`prismic.config.json is invalid.`),this.issues=e}};async function dt(e,t=c(process.cwd())){let n=await ft(t);if(!n.ok)return n;let r=await U(t);if(!r.ok)return r;let i={...r.config,...e};return await s(n.path,B(i)),{ok:!0,config:i}}async function ft(e=c(process.cwd())){let t=await R(st,{start:e,stop:`package.json`});return t?{ok:!0,path:t}:{ok:!1,error:new mt}}async function pt(e=c(process.cwd())){let t=await R(`package.json`,{start:e});return t?{ok:!0,path:new URL(st,t)}:{ok:!1,error:new ht}}var mt=class extends Error{message=`Could not find a prismic.config.json file.`},ht=class extends Error{message=`Could not find a package.json file.`};async function gt(){let{values:t}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`},repo:{type:`string`,short:`r`}}});if(t.help){console.info(`Initialize a Prismic project by creating a prismic.config.json file.
459
459
 
460
460
  Use this command to connect an existing Prismic repository to your project.
461
461
  To create a new repository, use \`prismic repo create\` instead.
@@ -468,7 +468,7 @@ FLAGS
468
468
  -h, --help Show help for command
469
469
 
470
470
  LEARN MORE
471
- Use \`prismic <command> --help\` for more information about a command.`);return}if(!t.repo){console.error(`Missing required flag: --repo`),process.exitCode=1;return}if((await W()).ok){console.error(`A prismic.config.json file already exists.`),process.exitCode=1;return}let n=await ct({repositoryName:t.repo});if(!n.ok){n.error instanceof mt?console.error(`Could not find a package.json file. Run this command from a project directory.`):console.error(`Failed to create config file.`),process.exitCode=1;return}console.info(`Created prismic.config.json for repository "${t.repo}"`)}async function G(e,t={}){let{credentials:n=`include`}=t,r=new Headers(t.headers);if(r.set(`Accept`,`application/json`),n===`include`){let e=await N();e&&r.set(`Cookie`,`SESSION=fake_session; prismic-auth=${e}`)}!r.has(`Content-Type`)&&t.body&&r.set(`Content-Type`,`application/json`),t.body instanceof FormData&&r.delete(`Content-Type`);let i=r.get(`Content-Type`)===`application/json`?JSON.stringify(t.body):t.body,a=await fetch(e,{...t,body:i,headers:r}),o=await a.clone().json().catch(()=>a.clone().text());if(a.ok){if(!t?.schema)return{ok:!0,value:o};try{return{ok:!0,value:ae(t.schema,o)}}catch(e){if(b(e))return{ok:!1,value:o,error:e};throw e}}else if(a.status===401)return{ok:!1,value:o,error:new q(a)};else if(a.status===403)return{ok:!1,value:o,error:new K(a)};else return{ok:!1,value:o,error:new gt(a)}}var gt=class extends Error{name=`RequestError`;response;constructor(e){super(`fetch failed: ${e.url}`),this.response=e}async text(){return this.response.clone().text()}async json(){return this.response.clone().json()}get status(){return this.response.status}get statusText(){return this.response.statusText}},K=class extends gt{},q=class extends gt{};async function _t(){let{values:{help:t,name:n,repo:r=await U()},positionals:[i]}=e({args:process.argv.slice(4),options:{name:{type:`string`,short:`n`},repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a new locale to a Prismic repository.
471
+ Use \`prismic <command> --help\` for more information about a command.`);return}if(!t.repo){console.error(`Missing required flag: --repo`),process.exitCode=1;return}if((await U()).ok){console.error(`A prismic.config.json file already exists.`),process.exitCode=1;return}let n=await lt({repositoryName:t.repo});if(!n.ok){n.error instanceof ht?console.error(`Could not find a package.json file. Run this command from a project directory.`):console.error(`Failed to create config file.`),process.exitCode=1;return}console.info(`Created prismic.config.json for repository "${t.repo}"`)}async function W(e,t={}){let{credentials:n=`include`}=t,r=new Headers(t.headers);if(r.set(`Accept`,`application/json`),n===`include`){let e=await se();e&&r.set(`Cookie`,`SESSION=fake_session; prismic-auth=${e}`)}!r.has(`Content-Type`)&&t.body&&r.set(`Content-Type`,`application/json`),t.body instanceof FormData&&r.delete(`Content-Type`);let i=r.get(`Content-Type`)===`application/json`?JSON.stringify(t.body):t.body,a=await fetch(e,{...t,body:i,headers:r}),o=await a.clone().json().catch(()=>a.clone().text());if(a.ok){if(!t?.schema)return{ok:!0,value:o};try{return{ok:!0,value:j(t.schema,o)}}catch(e){if(b(e))return{ok:!1,value:o,error:e};throw e}}else if(a.status===401)return{ok:!1,value:o,error:new K(a)};else if(a.status===403)return{ok:!1,value:o,error:new G(a)};else return{ok:!1,value:o,error:new _t(a)}}var _t=class extends Error{name=`RequestError`;response;constructor(e){super(`fetch failed: ${e.url}`),this.response=e}async text(){return this.response.clone().text()}async json(){return this.response.clone().json()}get status(){return this.response.status}get statusText(){return this.response.statusText}},G=class extends _t{},K=class extends _t{};async function vt(){let{values:{help:t,name:n,repo:r=await H()},positionals:[i]}=e({args:process.argv.slice(4),options:{name:{type:`string`,short:`n`},repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a new locale to a Prismic repository.
472
472
 
473
473
  By default, this command reads the repository from prismic.config.json at the
474
474
  project root.
@@ -485,7 +485,7 @@ FLAGS
485
485
  -h, --help Show help for command
486
486
 
487
487
  LEARN MORE
488
- Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!i){console.error(`Missing required argument: <code>`),process.exitCode=1;return}if(!r){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await M()){bt();return}let a=n?await yt(r,i,n):await vt(r,i);if(!a.ok){if(typeof a.value==`string`&&a.value.includes(`already existing languages`))return;a.error instanceof K?bt():(console.error(`Failed to add locale: ${z(a.value)}`),process.exitCode=1);return}console.info(`Locale added: ${i}`)}async function vt(e,t){return await G(new URL(`/app/settings/multilanguages`,await F(e)),{method:`POST`,body:{languages:[t]}})}async function yt(e,t,n){let[r,i]=t.split(`-`);return await G(new URL(`/app/settings/multilanguages/custom`,await F(e)),{method:`POST`,body:{lang:{label:n,id:r||t},region:{label:n,id:i||r||t}}})}function bt(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function xt(){let{values:{help:t,repo:n=await U(),json:r}}=e({args:process.argv.slice(4),options:{json:{type:`boolean`},repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!1});if(t){console.info(`List all locales in a Prismic repository.
488
+ Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!i){console.error(`Missing required argument: <code>`),process.exitCode=1;return}if(!r){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await P()){xt();return}let a=n?await bt(r,i,n):await yt(r,i);if(!a.ok){if(typeof a.value==`string`&&a.value.includes(`already existing languages`))return;a.error instanceof G?xt():(console.error(`Failed to add locale: ${B(a.value)}`),process.exitCode=1);return}console.info(`Locale added: ${i}`)}async function yt(e,t){return await W(new URL(`/app/settings/multilanguages`,await I(e)),{method:`POST`,body:{languages:[t]}})}async function bt(e,t,n){let[r,i]=t.split(`-`);return await W(new URL(`/app/settings/multilanguages/custom`,await I(e)),{method:`POST`,body:{lang:{label:n,id:r||t},region:{label:n,id:i||r||t}}})}function xt(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function St(){let{values:{help:t,repo:n=await H(),json:r}}=e({args:process.argv.slice(4),options:{json:{type:`boolean`},repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!1});if(t){console.info(`List all locales in a Prismic repository.
489
489
 
490
490
  By default, this command reads the repository from prismic.config.json at the
491
491
  project root.
@@ -499,7 +499,7 @@ FLAGS
499
499
  -h, --help Show help for command
500
500
 
501
501
  LEARN MORE
502
- Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await M()){wt();return}let i=await Ct(n);if(!i.ok){i.error instanceof K?wt():b(i.error)?(console.error(`Failed to list locales: Invalid response: ${z(i.error.issues)}`),process.exitCode=1):(console.error(`Failed to list locales: ${z(i.value)}`),process.exitCode=1);return}let a=i.value.results;if(r)console.info(z(a));else for(let e of a){let t=e.isMaster?` (default)`:``;console.info(`${e.id} ${e.label}${t}`)}}const St=T({results:x(T({id:O(),label:O(),customName:C(O()),isMaster:S()}))});async function Ct(e){let t=new URL(`/locale/repository/locales`,await de());return t.searchParams.set(`repository`,e),await G(t,{schema:St})}function wt(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function Tt(){let{values:{repo:t=await U(),help:n},positionals:[r]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(n){console.info(`Remove a locale from a Prismic repository.
502
+ Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await P()){Tt();return}let i=await wt(n);if(!i.ok){i.error instanceof G?Tt():b(i.error)?(console.error(`Failed to list locales: Invalid response: ${B(i.error.issues)}`),process.exitCode=1):(console.error(`Failed to list locales: ${B(i.value)}`),process.exitCode=1);return}let a=i.value.results;if(r)console.info(B(a));else for(let e of a){let t=e.isMaster?` (default)`:``;console.info(`${e.id} ${e.label}${t}`)}}const Ct=E({results:S(E({id:k(),label:k(),customName:w(k()),isMaster:C()}))});async function wt(e){let t=new URL(`/locale/repository/locales`,await ue());return t.searchParams.set(`repository`,e),await W(t,{schema:Ct})}function Tt(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function Et(){let{values:{repo:t=await H(),help:n},positionals:[r]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(n){console.info(`Remove a locale from a Prismic repository.
503
503
 
504
504
  By default, this command reads the repository from prismic.config.json at the
505
505
  project root.
@@ -515,7 +515,7 @@ FLAGS
515
515
  -h, --help Show help for command
516
516
 
517
517
  LEARN MORE
518
- Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <code>`),process.exitCode=1;return}if(!t){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await M()){Dt();return}let i=await Et(t,r);if(!i.ok){i.error instanceof K?Dt():(console.error(`Failed to remove locale: ${z(i.value)}`),process.exitCode=1);return}console.info(`Removed locale: ${r}`)}async function Et(e,t){let n=new URL(`/locale/repository/locales/${t}`,await de());return n.searchParams.set(`repository`,e),await G(n,{method:`DELETE`})}function Dt(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function Ot(){let{values:{help:t,repo:n=await U()},positionals:[r]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Set the default locale for a Prismic repository.
518
+ Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <code>`),process.exitCode=1;return}if(!t){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await P()){Ot();return}let i=await Dt(t,r);if(!i.ok){i.error instanceof G?Ot():(console.error(`Failed to remove locale: ${B(i.value)}`),process.exitCode=1);return}console.info(`Removed locale: ${r}`)}async function Dt(e,t){let n=new URL(`/locale/repository/locales/${t}`,await ue());return n.searchParams.set(`repository`,e),await W(n,{method:`DELETE`})}function Ot(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function kt(){let{values:{help:t,repo:n=await H()},positionals:[r]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Set the default locale for a Prismic repository.
519
519
 
520
520
  By default, this command reads the repository from prismic.config.json at the
521
521
  project root.
@@ -531,7 +531,7 @@ FLAGS
531
531
  -h, --help Show help for command
532
532
 
533
533
  LEARN MORE
534
- Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <code>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await M()){At();return}let i=await Ct(n);if(!i.ok){i.error instanceof K?At():b(i.error)?(console.error(`Failed to set default locale: Invalid response: ${z(i.error.issues)}`),process.exitCode=1):(console.error(`Failed to set default locale: ${z(i.value)}`),process.exitCode=1);return}let a=i.value.results,o=a.find(e=>e.id===r);if(!o){console.error(`Locale "${r}" not found in repository. Available locales: ${a.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}if(o.isMaster){console.error(`Locale "${r}" is already the default.`),process.exitCode=1;return}let s=await kt(n,o);if(!s.ok){s.error instanceof K?At():(console.error(`Failed to set default locale: ${z(s.value)}`),process.exitCode=1);return}console.info(`Default locale set: ${r}`)}async function kt(e,t){let n=new URL(`/locale/repository/locales`,await de());return n.searchParams.set(`repository`,e),await G(n,{method:`POST`,body:{id:t.id,label:t.label,customName:t.customName,isMaster:!0}})}function At(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function jt(){let{positionals:[t]}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`add`:await _t();break;case`list`:await xt();break;case`remove`:await Tt();break;case`set-default`:await Ot();break;default:t&&(console.error(`Unknown locale subcommand: ${t}\n`),process.exitCode=1),console.info(`Manage locales in a Prismic repository.
534
+ Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <code>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await P()){jt();return}let i=await wt(n);if(!i.ok){i.error instanceof G?jt():b(i.error)?(console.error(`Failed to set default locale: Invalid response: ${B(i.error.issues)}`),process.exitCode=1):(console.error(`Failed to set default locale: ${B(i.value)}`),process.exitCode=1);return}let a=i.value.results,o=a.find(e=>e.id===r);if(!o){console.error(`Locale "${r}" not found in repository. Available locales: ${a.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}if(o.isMaster){console.error(`Locale "${r}" is already the default.`),process.exitCode=1;return}let s=await At(n,o);if(!s.ok){s.error instanceof G?jt():(console.error(`Failed to set default locale: ${B(s.value)}`),process.exitCode=1);return}console.info(`Default locale set: ${r}`)}async function At(e,t){let n=new URL(`/locale/repository/locales`,await ue());return n.searchParams.set(`repository`,e),await W(n,{method:`POST`,body:{id:t.id,label:t.label,customName:t.customName,isMaster:!0}})}function jt(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function Mt(){let{positionals:[t]}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`add`:await vt();break;case`list`:await St();break;case`remove`:await Et();break;case`set-default`:await kt();break;default:t&&(console.error(`Unknown locale subcommand: ${t}\n`),process.exitCode=1),console.info(`Manage locales in a Prismic repository.
535
535
 
536
536
  USAGE
537
537
  prismic locale <command> [flags]
@@ -546,7 +546,7 @@ FLAGS
546
546
  -h, --help Show help for command
547
547
 
548
548
  LEARN MORE
549
- Use \`prismic locale <command> --help\` for more information about a command.`)}}async function Mt(){let{values:t}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}}});if(t.help){console.info(`Log in to Prismic via browser.
549
+ Use \`prismic locale <command> --help\` for more information about a command.`)}}async function Nt(){let{values:t}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}}});if(t.help){console.info(`Log in to Prismic via browser.
550
550
 
551
551
  USAGE
552
552
  prismic login [flags]
@@ -555,7 +555,7 @@ FLAGS
555
555
  -h, --help Show help for command
556
556
 
557
557
  LEARN MORE
558
- Use \`prismic <command> --help\` for more information about a command.`);return}return new Promise((e,t)=>{let n=d((t,i)=>{if(t.method===`OPTIONS`){i.writeHead(204,{"Access-Control-Allow-Origin":`*`,"Access-Control-Allow-Methods":`POST, OPTIONS`,"Access-Control-Allow-Headers":`Content-Type`}),i.end();return}if(t.method===`POST`){let a=``;t.on(`data`,e=>{a+=e.toString()}),t.on(`end`,async()=>{try{let{cookies:t,email:o}=JSON.parse(a),s=t.find(e=>e.startsWith(`prismic-auth=`))?.split(`;`)[0]?.replace(/^prismic-auth=/,``);if(!s){i.writeHead(400,{"Access-Control-Allow-Origin":`*`,"Content-Type":`application/json`}),i.end(JSON.stringify({error:`Invalid request`}));return}await ce(s),console.info(`Logged in to Prismic as ${o}`),i.writeHead(200,{"Access-Control-Allow-Origin":`*`,"Content-Type":`application/json`}),i.end(JSON.stringify({success:!0})),clearTimeout(r),n.close(),e()}catch{i.writeHead(400,{"Access-Control-Allow-Origin":`*`,"Content-Type":`application/json`}),i.end(JSON.stringify({error:`Invalid request`}))}});return}i.writeHead(404),i.end()}),r=setTimeout(()=>{n.close(),t(Error(`Login timed out. Please try again.`))},18e4);n.listen(0,`127.0.0.1`,()=>{let e=n.address();if(!e||typeof e==`string`){clearTimeout(r),n.close(),t(Error(`Failed to start login server`));return}let i=e.port,a=Nt(i);console.info(`Opening browser to complete login...`),console.info(`If the browser doesn't open, visit: ${a}`),Pt(a)}),n.on(`error`,e=>{clearTimeout(r),t(e)})})}function Nt(e){let t=new URL(`https://prismic.io/dashboard/cli/login`);return t.searchParams.set(`source`,`slice-machine`),t.searchParams.set(`port`,e.toString()),t}function Pt(e){u(`${process.platform===`darwin`?`open`:process.platform===`win32`?`start`:`xdg-open`} "${e.toString()}"`)}async function Ft(){let{values:t}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}}});if(t.help){console.info(`Log out of Prismic.
558
+ Use \`prismic <command> --help\` for more information about a command.`);return}return new Promise((e,t)=>{let n=d((t,i)=>{if(t.method===`OPTIONS`){i.writeHead(204,{"Access-Control-Allow-Origin":`*`,"Access-Control-Allow-Methods":`POST, OPTIONS`,"Access-Control-Allow-Headers":`Content-Type`}),i.end();return}if(t.method===`POST`){let a=``;t.on(`data`,e=>{a+=e.toString()}),t.on(`end`,async()=>{try{let{cookies:t,email:o}=JSON.parse(a),s=t.find(e=>e.startsWith(`prismic-auth=`))?.split(`;`)[0]?.replace(/^prismic-auth=/,``);if(!s){i.writeHead(400,{"Access-Control-Allow-Origin":`*`,"Content-Type":`application/json`}),i.end(JSON.stringify({error:`Invalid request`}));return}await oe(s),console.info(`Logged in to Prismic as ${o}`),i.writeHead(200,{"Access-Control-Allow-Origin":`*`,"Content-Type":`application/json`}),i.end(JSON.stringify({success:!0})),clearTimeout(r),n.close(),e()}catch{i.writeHead(400,{"Access-Control-Allow-Origin":`*`,"Content-Type":`application/json`}),i.end(JSON.stringify({error:`Invalid request`}))}});return}i.writeHead(404),i.end()}),r=setTimeout(()=>{n.close(),t(Error(`Login timed out. Please try again.`))},18e4);n.listen(0,`127.0.0.1`,()=>{let e=n.address();if(!e||typeof e==`string`){clearTimeout(r),n.close(),t(Error(`Failed to start login server`));return}let i=e.port,a=Pt(i);console.info(`Opening browser to complete login...`),console.info(`If the browser doesn't open, visit: ${a}`),Ft(a)}),n.on(`error`,e=>{clearTimeout(r),t(e)})})}function Pt(e){let t=new URL(`https://prismic.io/dashboard/cli/login`);return t.searchParams.set(`source`,`slice-machine`),t.searchParams.set(`port`,e.toString()),t}function Ft(e){u(`${process.platform===`darwin`?`open`:process.platform===`win32`?`start`:`xdg-open`} "${e.toString()}"`)}async function It(){let{values:t}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}}});if(t.help){console.info(`Log out of Prismic.
559
559
 
560
560
  USAGE
561
561
  prismic logout [flags]
@@ -564,7 +564,7 @@ FLAGS
564
564
  -h, --help Show help for command
565
565
 
566
566
  LEARN MORE
567
- Use \`prismic <command> --help\` for more information about a command.`);return}await ue()?console.info(`Logged out of Prismic`):(console.error(`Logout failed. You can log out manually by deleting the file.`),process.exitCode=1)}const It=T({id:O(),label:O(),repeatable:S(),status:S(),format:O(),json:D(O(),D(O(),k()))});async function Lt(){let{values:{help:t,tab:n,label:i,default:a,"true-label":o,"false-label":c},positionals:[l,u]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},default:{type:`boolean`},"true-label":{type:`string`},"false-label":{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a boolean (toggle) field to an existing page type.
567
+ Use \`prismic <command> --help\` for more information about a command.`);return}await le()?console.info(`Logged out of Prismic`):(console.error(`Logout failed. You can log out manually by deleting the file.`),process.exitCode=1)}const Lt=E({id:k(),label:k(),repeatable:C(),status:C(),format:k(),json:O(k(),O(k(),A()))});async function Rt(){let{values:{help:t,tab:n,label:i,default:a,"true-label":o,"false-label":c},positionals:[l,u]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},default:{type:`boolean`},"true-label":{type:`string`},"false-label":{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a boolean (toggle) field to an existing page type.
568
568
 
569
569
  USAGE
570
570
  prismic page-type add-field boolean <type-id> <field-id> [flags]
@@ -586,7 +586,7 @@ EXAMPLES
586
586
  prismic page-type add-field boolean article published --default
587
587
  prismic page-type add-field boolean product available --true-label "In Stock" --false-label "Out of Stock"`);return}if(!l){console.error(`Missing required argument: type-id
588
588
  `),console.error(`Usage: prismic page-type add-field boolean <type-id> <field-id>`),process.exitCode=1;return}if(!u){console.error(`Missing required argument: field-id
589
- `),console.error(`Usage: prismic page-type add-field boolean <type-id> <field-id>`),process.exitCode=1;return}let d=await L(`package.json`);if(!d){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let f=new URL(`customtypes/${l}/index.json`,d),p;try{let e=await r(f,`utf8`),t=A(It,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${f.href}`),process.exitCode=1;return}p=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${l}\n`),console.error(`Create it first with: prismic page-type create ${l}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}let m=Object.keys(p.json),h=n??m[0]??`Main`;p.json[h]||(p.json[h]={});for(let[e,t]of Object.entries(p.json))if(t[u]){console.error(`Field "${u}" already exists in tab "${e}"`),process.exitCode=1;return}let g={type:`Boolean`,config:{...i&&{label:i},...a&&{default_value:!0},...o&&{placeholder_true:o},...c&&{placeholder_false:c}}};p.json[h][u]=g;try{await s(f,z(p))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}console.info(`Added field "${u}" (Boolean) to "${h}" tab in ${l}`)}const Rt=T({id:O(),label:O(),repeatable:S(),status:S(),format:O(),json:D(O(),D(O(),k()))});async function zt(){let{values:{help:t,tab:n,label:i,placeholder:a},positionals:[o,c]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a color picker field to an existing page type.
589
+ `),console.error(`Usage: prismic page-type add-field boolean <type-id> <field-id>`),process.exitCode=1;return}let d=await R(`package.json`);if(!d){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let f=new URL(`customtypes/${l}/index.json`,d),p;try{let e=await r(f,`utf8`),t=M(Lt,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${f.href}`),process.exitCode=1;return}p=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${l}\n`),console.error(`Create it first with: prismic page-type create ${l}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}let m=Object.keys(p.json),h=n??m[0]??`Main`;p.json[h]||(p.json[h]={});for(let[e,t]of Object.entries(p.json))if(t[u]){console.error(`Field "${u}" already exists in tab "${e}"`),process.exitCode=1;return}let g={type:`Boolean`,config:{...i&&{label:i},...a&&{default_value:!0},...o&&{placeholder_true:o},...c&&{placeholder_false:c}}};p.json[h][u]=g;try{await s(f,B(p))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}console.info(`Added field "${u}" (Boolean) to "${h}" tab in ${l}`)}const zt=E({id:k(),label:k(),repeatable:C(),status:C(),format:k(),json:O(k(),O(k(),A()))});async function Bt(){let{values:{help:t,tab:n,label:i,placeholder:a},positionals:[o,c]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a color picker field to an existing page type.
590
590
 
591
591
  USAGE
592
592
  prismic page-type add-field color <type-id> <field-id> [flags]
@@ -606,7 +606,7 @@ EXAMPLES
606
606
  prismic page-type add-field color homepage accent --tab "Design"
607
607
  prismic page-type add-field color homepage text_color --label "Text Color"`);return}if(!o){console.error(`Missing required argument: type-id
608
608
  `),console.error(`Usage: prismic page-type add-field color <type-id> <field-id>`),process.exitCode=1;return}if(!c){console.error(`Missing required argument: field-id
609
- `),console.error(`Usage: prismic page-type add-field color <type-id> <field-id>`),process.exitCode=1;return}let l=await L(`package.json`);if(!l){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let u=new URL(`customtypes/${o}/index.json`,l),d;try{let e=await r(u,`utf8`),t=A(Rt,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${u.href}`),process.exitCode=1;return}d=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${o}\n`),console.error(`Create it first with: prismic page-type create ${o}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}let f=Object.keys(d.json),p=n??f[0]??`Main`;d.json[p]||(d.json[p]={});for(let[e,t]of Object.entries(d.json))if(t[c]){console.error(`Field "${c}" already exists in tab "${e}"`),process.exitCode=1;return}let m={type:`Color`,config:{...i&&{label:i},...a&&{placeholder:a}}};d.json[p][c]=m;try{await s(u,z(d))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}console.info(`Added field "${c}" (Color) to "${p}" tab in ${o}`)}const Bt=T({id:O(),label:O(),repeatable:S(),status:S(),format:O(),json:D(O(),D(O(),k()))});async function Vt(){let{values:{help:t,tab:n,label:i,placeholder:a,default:o},positionals:[c,l]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},default:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a date field to an existing page type.
609
+ `),console.error(`Usage: prismic page-type add-field color <type-id> <field-id>`),process.exitCode=1;return}let l=await R(`package.json`);if(!l){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let u=new URL(`customtypes/${o}/index.json`,l),d;try{let e=await r(u,`utf8`),t=M(zt,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${u.href}`),process.exitCode=1;return}d=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${o}\n`),console.error(`Create it first with: prismic page-type create ${o}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}let f=Object.keys(d.json),p=n??f[0]??`Main`;d.json[p]||(d.json[p]={});for(let[e,t]of Object.entries(d.json))if(t[c]){console.error(`Field "${c}" already exists in tab "${e}"`),process.exitCode=1;return}let m={type:`Color`,config:{...i&&{label:i},...a&&{placeholder:a}}};d.json[p][c]=m;try{await s(u,B(d))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}console.info(`Added field "${c}" (Color) to "${p}" tab in ${o}`)}const Vt=E({id:k(),label:k(),repeatable:C(),status:C(),format:k(),json:O(k(),O(k(),A()))});async function Ht(){let{values:{help:t,tab:n,label:i,placeholder:a,default:o},positionals:[c,l]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},default:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a date field to an existing page type.
610
610
 
611
611
  USAGE
612
612
  prismic page-type add-field date <type-id> <field-id> [flags]
@@ -627,7 +627,7 @@ EXAMPLES
627
627
  prismic page-type add-field date event start_date --tab "Schedule"
628
628
  prismic page-type add-field date article date --label "Publication Date" --default "2024-01-01"`);return}if(!c){console.error(`Missing required argument: type-id
629
629
  `),console.error(`Usage: prismic page-type add-field date <type-id> <field-id>`),process.exitCode=1;return}if(!l){console.error(`Missing required argument: field-id
630
- `),console.error(`Usage: prismic page-type add-field date <type-id> <field-id>`),process.exitCode=1;return}let u=await L(`package.json`);if(!u){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let d=new URL(`customtypes/${c}/index.json`,u),f;try{let e=await r(d,`utf8`),t=A(Bt,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${d.href}`),process.exitCode=1;return}f=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${c}\n`),console.error(`Create it first with: prismic page-type create ${c}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}let p=Object.keys(f.json),m=n??p[0]??`Main`;f.json[m]||(f.json[m]={});for(let[e,t]of Object.entries(f.json))if(t[l]){console.error(`Field "${l}" already exists in tab "${e}"`),process.exitCode=1;return}let h={type:`Date`,config:{...i&&{label:i},...a&&{placeholder:a},...o&&{default:o}}};f.json[m][l]=h;try{await s(d,z(f))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}console.info(`Added field "${l}" (Date) to "${m}" tab in ${c}`)}const Ht=T({id:O(),label:O(),repeatable:S(),status:S(),format:O(),json:D(O(),D(O(),k()))});async function Ut(){let{values:{help:t,tab:n,label:i,placeholder:a},positionals:[o,c]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add an embed field to an existing page type.
630
+ `),console.error(`Usage: prismic page-type add-field date <type-id> <field-id>`),process.exitCode=1;return}let u=await R(`package.json`);if(!u){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let d=new URL(`customtypes/${c}/index.json`,u),f;try{let e=await r(d,`utf8`),t=M(Vt,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${d.href}`),process.exitCode=1;return}f=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${c}\n`),console.error(`Create it first with: prismic page-type create ${c}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}let p=Object.keys(f.json),m=n??p[0]??`Main`;f.json[m]||(f.json[m]={});for(let[e,t]of Object.entries(f.json))if(t[l]){console.error(`Field "${l}" already exists in tab "${e}"`),process.exitCode=1;return}let h={type:`Date`,config:{...i&&{label:i},...a&&{placeholder:a},...o&&{default:o}}};f.json[m][l]=h;try{await s(d,B(f))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}console.info(`Added field "${l}" (Date) to "${m}" tab in ${c}`)}const Ut=E({id:k(),label:k(),repeatable:C(),status:C(),format:k(),json:O(k(),O(k(),A()))});async function Wt(){let{values:{help:t,tab:n,label:i,placeholder:a},positionals:[o,c]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add an embed field to an existing page type.
631
631
 
632
632
  USAGE
633
633
  prismic page-type add-field embed <type-id> <field-id> [flags]
@@ -647,7 +647,7 @@ EXAMPLES
647
647
  prismic page-type add-field embed homepage youtube --tab "Media"
648
648
  prismic page-type add-field embed homepage media --label "Media Embed"`);return}if(!o){console.error(`Missing required argument: type-id
649
649
  `),console.error(`Usage: prismic page-type add-field embed <type-id> <field-id>`),process.exitCode=1;return}if(!c){console.error(`Missing required argument: field-id
650
- `),console.error(`Usage: prismic page-type add-field embed <type-id> <field-id>`),process.exitCode=1;return}let l=await L(`package.json`);if(!l){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let u=new URL(`customtypes/${o}/index.json`,l),d;try{let e=await r(u,`utf8`),t=A(Ht,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${u.href}`),process.exitCode=1;return}d=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${o}\n`),console.error(`Create it first with: prismic page-type create ${o}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}let f=Object.keys(d.json),p=n??f[0]??`Main`;d.json[p]||(d.json[p]={});for(let[e,t]of Object.entries(d.json))if(t[c]){console.error(`Field "${c}" already exists in tab "${e}"`),process.exitCode=1;return}let m={type:`Embed`,config:{...i&&{label:i},...a&&{placeholder:a}}};d.json[p][c]=m;try{await s(u,z(d))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}console.info(`Added field "${c}" (Embed) to "${p}" tab in ${o}`)}const Wt=T({id:O(),label:O(),repeatable:S(),status:S(),format:O(),json:D(O(),D(O(),k()))});async function Gt(){let{values:{help:t,tab:n,label:i},positionals:[a,o]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a geo-point (location) field to an existing page type.
650
+ `),console.error(`Usage: prismic page-type add-field embed <type-id> <field-id>`),process.exitCode=1;return}let l=await R(`package.json`);if(!l){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let u=new URL(`customtypes/${o}/index.json`,l),d;try{let e=await r(u,`utf8`),t=M(Ut,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${u.href}`),process.exitCode=1;return}d=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${o}\n`),console.error(`Create it first with: prismic page-type create ${o}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}let f=Object.keys(d.json),p=n??f[0]??`Main`;d.json[p]||(d.json[p]={});for(let[e,t]of Object.entries(d.json))if(t[c]){console.error(`Field "${c}" already exists in tab "${e}"`),process.exitCode=1;return}let m={type:`Embed`,config:{...i&&{label:i},...a&&{placeholder:a}}};d.json[p][c]=m;try{await s(u,B(d))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}console.info(`Added field "${c}" (Embed) to "${p}" tab in ${o}`)}const Gt=E({id:k(),label:k(),repeatable:C(),status:C(),format:k(),json:O(k(),O(k(),A()))});async function Kt(){let{values:{help:t,tab:n,label:i},positionals:[a,o]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a geo-point (location) field to an existing page type.
651
651
 
652
652
  USAGE
653
653
  prismic page-type add-field geo-point <type-id> <field-id> [flags]
@@ -666,7 +666,7 @@ EXAMPLES
666
666
  prismic page-type add-field geo-point store address --tab "Details"
667
667
  prismic page-type add-field geo-point event venue --label "Event Venue"`);return}if(!a){console.error(`Missing required argument: type-id
668
668
  `),console.error(`Usage: prismic page-type add-field geo-point <type-id> <field-id>`),process.exitCode=1;return}if(!o){console.error(`Missing required argument: field-id
669
- `),console.error(`Usage: prismic page-type add-field geo-point <type-id> <field-id>`),process.exitCode=1;return}let c=await L(`package.json`);if(!c){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let l=new URL(`customtypes/${a}/index.json`,c),u;try{let e=await r(l,`utf8`),t=A(Wt,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${l.href}`),process.exitCode=1;return}u=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${a}\n`),console.error(`Create it first with: prismic page-type create ${a}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}let d=Object.keys(u.json),f=n??d[0]??`Main`;u.json[f]||(u.json[f]={});for(let[e,t]of Object.entries(u.json))if(t[o]){console.error(`Field "${o}" already exists in tab "${e}"`),process.exitCode=1;return}let p={type:`GeoPoint`,config:{...i&&{label:i}}};u.json[f][o]=p;try{await s(l,z(u))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}console.info(`Added field "${o}" (GeoPoint) to "${f}" tab in ${a}`)}const Kt=T({id:O(),label:O(),repeatable:S(),status:S(),format:O(),json:D(O(),D(O(),k()))});async function qt(){let{values:{help:t,tab:n,label:i,placeholder:a},positionals:[o,c]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add an image field to an existing page type.
669
+ `),console.error(`Usage: prismic page-type add-field geo-point <type-id> <field-id>`),process.exitCode=1;return}let c=await R(`package.json`);if(!c){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let l=new URL(`customtypes/${a}/index.json`,c),u;try{let e=await r(l,`utf8`),t=M(Gt,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${l.href}`),process.exitCode=1;return}u=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${a}\n`),console.error(`Create it first with: prismic page-type create ${a}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}let d=Object.keys(u.json),f=n??d[0]??`Main`;u.json[f]||(u.json[f]={});for(let[e,t]of Object.entries(u.json))if(t[o]){console.error(`Field "${o}" already exists in tab "${e}"`),process.exitCode=1;return}let p={type:`GeoPoint`,config:{...i&&{label:i}}};u.json[f][o]=p;try{await s(l,B(u))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}console.info(`Added field "${o}" (GeoPoint) to "${f}" tab in ${a}`)}const qt=E({id:k(),label:k(),repeatable:C(),status:C(),format:k(),json:O(k(),O(k(),A()))});async function Jt(){let{values:{help:t,tab:n,label:i,placeholder:a},positionals:[o,c]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add an image field to an existing page type.
670
670
 
671
671
  USAGE
672
672
  prismic page-type add-field image <type-id> <field-id> [flags]
@@ -686,7 +686,7 @@ EXAMPLES
686
686
  prismic page-type add-field image article thumbnail --tab "Media"
687
687
  prismic page-type add-field image product photo --label "Product Photo"`);return}if(!o){console.error(`Missing required argument: type-id
688
688
  `),console.error(`Usage: prismic page-type add-field image <type-id> <field-id>`),process.exitCode=1;return}if(!c){console.error(`Missing required argument: field-id
689
- `),console.error(`Usage: prismic page-type add-field image <type-id> <field-id>`),process.exitCode=1;return}let l=await L(`package.json`);if(!l){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let u=new URL(`customtypes/${o}/index.json`,l),d;try{let e=await r(u,`utf8`),t=A(Kt,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${u.href}`),process.exitCode=1;return}d=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${o}\n`),console.error(`Create it first with: prismic page-type create ${o}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}let f=Object.keys(d.json),p=n??f[0]??`Main`;d.json[p]||(d.json[p]={});for(let[e,t]of Object.entries(d.json))if(t[c]){console.error(`Field "${c}" already exists in tab "${e}"`),process.exitCode=1;return}let m={type:`Image`,config:{...i&&{label:i},...a&&{placeholder:a}}};d.json[p][c]=m;try{await s(u,z(d))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}console.info(`Added field "${c}" (Image) to "${p}" tab in ${o}`)}const Jt=T({id:O(),label:O(),repeatable:S(),status:S(),format:O(),json:D(O(),D(O(),k()))});async function Yt(){let{values:{help:t,tab:n,label:i,placeholder:a},positionals:[o,c]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a key-text (single-line text) field to an existing page type.
689
+ `),console.error(`Usage: prismic page-type add-field image <type-id> <field-id>`),process.exitCode=1;return}let l=await R(`package.json`);if(!l){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let u=new URL(`customtypes/${o}/index.json`,l),d;try{let e=await r(u,`utf8`),t=M(qt,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${u.href}`),process.exitCode=1;return}d=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${o}\n`),console.error(`Create it first with: prismic page-type create ${o}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}let f=Object.keys(d.json),p=n??f[0]??`Main`;d.json[p]||(d.json[p]={});for(let[e,t]of Object.entries(d.json))if(t[c]){console.error(`Field "${c}" already exists in tab "${e}"`),process.exitCode=1;return}let m={type:`Image`,config:{...i&&{label:i},...a&&{placeholder:a}}};d.json[p][c]=m;try{await s(u,B(d))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}console.info(`Added field "${c}" (Image) to "${p}" tab in ${o}`)}const Yt=E({id:k(),label:k(),repeatable:C(),status:C(),format:k(),json:O(k(),O(k(),A()))});async function Xt(){let{values:{help:t,tab:n,label:i,placeholder:a},positionals:[o,c]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a key-text (single-line text) field to an existing page type.
690
690
 
691
691
  USAGE
692
692
  prismic page-type add-field key-text <type-id> <field-id> [flags]
@@ -706,7 +706,7 @@ EXAMPLES
706
706
  prismic page-type add-field key-text homepage meta_title --tab "SEO"
707
707
  prismic page-type add-field key-text homepage subtitle --label "Subtitle" --placeholder "Enter subtitle"`);return}if(!o){console.error(`Missing required argument: type-id
708
708
  `),console.error(`Usage: prismic page-type add-field key-text <type-id> <field-id>`),process.exitCode=1;return}if(!c){console.error(`Missing required argument: field-id
709
- `),console.error(`Usage: prismic page-type add-field key-text <type-id> <field-id>`),process.exitCode=1;return}let l=await L(`package.json`);if(!l){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let u=new URL(`customtypes/${o}/index.json`,l),d;try{let e=await r(u,`utf8`),t=A(Jt,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${u.href}`),process.exitCode=1;return}d=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${o}\n`),console.error(`Create it first with: prismic page-type create ${o}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}let f=Object.keys(d.json),p=n??f[0]??`Main`;d.json[p]||(d.json[p]={});for(let[e,t]of Object.entries(d.json))if(t[c]){console.error(`Field "${c}" already exists in tab "${e}"`),process.exitCode=1;return}let m={type:`Text`,config:{...i&&{label:i},...a&&{placeholder:a}}};d.json[p][c]=m;try{await s(u,z(d))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}console.info(`Added field "${c}" (Text) to "${p}" tab in ${o}`)}const Xt=T({id:O(),label:O(),repeatable:S(),status:S(),format:O(),json:D(O(),D(O(),k()))});async function Zt(){let{values:{help:t,tab:n,label:i,placeholder:a,variation:o,"allow-text":c,"allow-target-blank":l,repeatable:u},positionals:[d,f]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},variation:{type:`string`,multiple:!0},"allow-text":{type:`boolean`},"allow-target-blank":{type:`boolean`},repeatable:{type:`boolean`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a link field to an existing page type.
709
+ `),console.error(`Usage: prismic page-type add-field key-text <type-id> <field-id>`),process.exitCode=1;return}let l=await R(`package.json`);if(!l){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let u=new URL(`customtypes/${o}/index.json`,l),d;try{let e=await r(u,`utf8`),t=M(Yt,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${u.href}`),process.exitCode=1;return}d=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${o}\n`),console.error(`Create it first with: prismic page-type create ${o}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}let f=Object.keys(d.json),p=n??f[0]??`Main`;d.json[p]||(d.json[p]={});for(let[e,t]of Object.entries(d.json))if(t[c]){console.error(`Field "${c}" already exists in tab "${e}"`),process.exitCode=1;return}let m={type:`Text`,config:{...i&&{label:i},...a&&{placeholder:a}}};d.json[p][c]=m;try{await s(u,B(d))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}console.info(`Added field "${c}" (Text) to "${p}" tab in ${o}`)}const Zt=E({id:k(),label:k(),repeatable:C(),status:C(),format:k(),json:O(k(),O(k(),A()))});async function Qt(){let{values:{help:t,tab:n,label:i,placeholder:a,variation:o,"allow-text":c,"allow-target-blank":l,repeatable:u},positionals:[d,f]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},variation:{type:`string`,multiple:!0},"allow-text":{type:`boolean`},"allow-target-blank":{type:`boolean`},repeatable:{type:`boolean`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a link field to an existing page type.
710
710
 
711
711
  USAGE
712
712
  prismic page-type add-field link <type-id> <field-id> [flags]
@@ -731,7 +731,7 @@ EXAMPLES
731
731
  prismic page-type add-field link homepage cta --variation Primary --variation Secondary
732
732
  prismic page-type add-field link homepage links --repeatable`);return}if(!d){console.error(`Missing required argument: type-id
733
733
  `),console.error(`Usage: prismic page-type add-field link <type-id> <field-id>`),process.exitCode=1;return}if(!f){console.error(`Missing required argument: field-id
734
- `),console.error(`Usage: prismic page-type add-field link <type-id> <field-id>`),process.exitCode=1;return}let p=await L(`package.json`);if(!p){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let m=new URL(`customtypes/${d}/index.json`,p),h;try{let e=await r(m,`utf8`),t=A(Xt,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${m.href}`),process.exitCode=1;return}h=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${d}\n`),console.error(`Create it first with: prismic page-type create ${d}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}let g=Object.keys(h.json),_=n??g[0]??`Main`;h.json[_]||(h.json[_]={});for(let[e,t]of Object.entries(h.json))if(t[f]){console.error(`Field "${f}" already exists in tab "${e}"`),process.exitCode=1;return}let v={type:`Link`,config:{...i&&{label:i},...a&&{placeholder:a},...o&&o.length>0&&{variants:o},...c&&{allowText:!0},...l&&{allowTargetBlank:!0},...u&&{repeat:!0}}};h.json[_][f]=v;try{await s(m,z(h))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}console.info(`Added field "${f}" (Link) to "${_}" tab in ${d}`)}const Qt=T({id:O(),label:O(),repeatable:S(),status:S(),format:O(),json:D(O(),D(O(),k()))});async function $t(){let{values:{help:t,tab:n,label:i,placeholder:a,min:o,max:c,step:l},positionals:[u,d]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},min:{type:`string`},max:{type:`string`},step:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a number field to an existing page type.
734
+ `),console.error(`Usage: prismic page-type add-field link <type-id> <field-id>`),process.exitCode=1;return}let p=await R(`package.json`);if(!p){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let m=new URL(`customtypes/${d}/index.json`,p),h;try{let e=await r(m,`utf8`),t=M(Zt,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${m.href}`),process.exitCode=1;return}h=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${d}\n`),console.error(`Create it first with: prismic page-type create ${d}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}let g=Object.keys(h.json),_=n??g[0]??`Main`;h.json[_]||(h.json[_]={});for(let[e,t]of Object.entries(h.json))if(t[f]){console.error(`Field "${f}" already exists in tab "${e}"`),process.exitCode=1;return}let v={type:`Link`,config:{...i&&{label:i},...a&&{placeholder:a},...o&&o.length>0&&{variants:o},...c&&{allowText:!0},...l&&{allowTargetBlank:!0},...u&&{repeat:!0}}};h.json[_][f]=v;try{await s(m,B(h))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}console.info(`Added field "${f}" (Link) to "${_}" tab in ${d}`)}const $t=E({id:k(),label:k(),repeatable:C(),status:C(),format:k(),json:O(k(),O(k(),A()))});async function en(){let{values:{help:t,tab:n,label:i,placeholder:a,min:o,max:c,step:l},positionals:[u,d]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},min:{type:`string`},max:{type:`string`},step:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a number field to an existing page type.
735
735
 
736
736
  USAGE
737
737
  prismic page-type add-field number <type-id> <field-id> [flags]
@@ -754,7 +754,7 @@ EXAMPLES
754
754
  prismic page-type add-field number product quantity --min 0 --max 100
755
755
  prismic page-type add-field number settings rating --min 1 --max 5 --step 1`);return}if(!u){console.error(`Missing required argument: type-id
756
756
  `),console.error(`Usage: prismic page-type add-field number <type-id> <field-id>`),process.exitCode=1;return}if(!d){console.error(`Missing required argument: field-id
757
- `),console.error(`Usage: prismic page-type add-field number <type-id> <field-id>`),process.exitCode=1;return}let f=o===void 0?void 0:Number(o),p=c===void 0?void 0:Number(c),m=l===void 0?void 0:Number(l);if(o!==void 0&&Number.isNaN(f)){console.error(`Invalid --min value: must be a number`),process.exitCode=1;return}if(c!==void 0&&Number.isNaN(p)){console.error(`Invalid --max value: must be a number`),process.exitCode=1;return}if(l!==void 0&&Number.isNaN(m)){console.error(`Invalid --step value: must be a number`),process.exitCode=1;return}let h=await L(`package.json`);if(!h){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let g=new URL(`customtypes/${u}/index.json`,h),_;try{let e=await r(g,`utf8`),t=A(Qt,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${g.href}`),process.exitCode=1;return}_=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${u}\n`),console.error(`Create it first with: prismic page-type create ${u}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}let v=Object.keys(_.json),y=n??v[0]??`Main`;_.json[y]||(_.json[y]={});for(let[e,t]of Object.entries(_.json))if(t[d]){console.error(`Field "${d}" already exists in tab "${e}"`),process.exitCode=1;return}let b={type:`Number`,config:{...i&&{label:i},...a&&{placeholder:a},...f!==void 0&&{min:f},...p!==void 0&&{max:p},...m!==void 0&&{step:m}}};_.json[y][d]=b;try{await s(g,z(_))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}console.info(`Added field "${d}" (Number) to "${y}" tab in ${u}`)}const en=T({id:O(),label:O(),repeatable:S(),status:S(),format:O(),json:D(O(),D(O(),k()))});async function tn(){let{values:{help:t,tab:n,label:i,placeholder:a,single:o,multi:c,"allow-target-blank":l},positionals:[u,d]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},single:{type:`string`},multi:{type:`string`},"allow-target-blank":{type:`boolean`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a rich text field to an existing page type.
757
+ `),console.error(`Usage: prismic page-type add-field number <type-id> <field-id>`),process.exitCode=1;return}let f=o===void 0?void 0:Number(o),p=c===void 0?void 0:Number(c),m=l===void 0?void 0:Number(l);if(o!==void 0&&Number.isNaN(f)){console.error(`Invalid --min value: must be a number`),process.exitCode=1;return}if(c!==void 0&&Number.isNaN(p)){console.error(`Invalid --max value: must be a number`),process.exitCode=1;return}if(l!==void 0&&Number.isNaN(m)){console.error(`Invalid --step value: must be a number`),process.exitCode=1;return}let h=await R(`package.json`);if(!h){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let g=new URL(`customtypes/${u}/index.json`,h),_;try{let e=await r(g,`utf8`),t=M($t,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${g.href}`),process.exitCode=1;return}_=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${u}\n`),console.error(`Create it first with: prismic page-type create ${u}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}let v=Object.keys(_.json),y=n??v[0]??`Main`;_.json[y]||(_.json[y]={});for(let[e,t]of Object.entries(_.json))if(t[d]){console.error(`Field "${d}" already exists in tab "${e}"`),process.exitCode=1;return}let b={type:`Number`,config:{...i&&{label:i},...a&&{placeholder:a},...f!==void 0&&{min:f},...p!==void 0&&{max:p},...m!==void 0&&{step:m}}};_.json[y][d]=b;try{await s(g,B(_))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}console.info(`Added field "${d}" (Number) to "${y}" tab in ${u}`)}const tn=E({id:k(),label:k(),repeatable:C(),status:C(),format:k(),json:O(k(),O(k(),A()))});async function nn(){let{values:{help:t,tab:n,label:i,placeholder:a,single:o,multi:c,"allow-target-blank":l},positionals:[u,d]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},single:{type:`string`},multi:{type:`string`},"allow-target-blank":{type:`boolean`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a rich text field to an existing page type.
758
758
 
759
759
  USAGE
760
760
  prismic page-type add-field rich-text <type-id> <field-id> [flags]
@@ -783,7 +783,7 @@ EXAMPLES
783
783
  prismic page-type add-field rich-text page tagline --single "heading1"
784
784
  prismic page-type add-field rich-text blog post --multi "paragraph,strong,em,hyperlink" --allow-target-blank`);return}if(!u){console.error(`Missing required argument: type-id
785
785
  `),console.error(`Usage: prismic page-type add-field rich-text <type-id> <field-id>`),process.exitCode=1;return}if(!d){console.error(`Missing required argument: field-id
786
- `),console.error(`Usage: prismic page-type add-field rich-text <type-id> <field-id>`),process.exitCode=1;return}let f=await L(`package.json`);if(!f){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let p=new URL(`customtypes/${u}/index.json`,f),m;try{let e=await r(p,`utf8`),t=A(en,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${p.href}`),process.exitCode=1;return}m=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${u}\n`),console.error(`Create it first with: prismic page-type create ${u}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}let h=Object.keys(m.json),g=n??h[0]??`Main`;m.json[g]||(m.json[g]={});for(let[e,t]of Object.entries(m.json))if(t[d]){console.error(`Field "${d}" already exists in tab "${e}"`),process.exitCode=1;return}let _={type:`StructuredText`,config:{...i&&{label:i},...a&&{placeholder:a},...o&&{single:o},...c&&{multi:c},...l&&{allowTargetBlank:!0}}};m.json[g][d]=_;try{await s(p,z(m))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}console.info(`Added field "${d}" (StructuredText) to "${g}" tab in ${u}`)}const nn=T({id:O(),label:O(),repeatable:S(),status:S(),format:O(),json:D(O(),D(O(),k()))});async function rn(){let{values:{help:t,tab:n,label:i,placeholder:a,option:o,default:c},positionals:[l,u]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},option:{type:`string`,multiple:!0},default:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a select (dropdown) field to an existing page type.
786
+ `),console.error(`Usage: prismic page-type add-field rich-text <type-id> <field-id>`),process.exitCode=1;return}let f=await R(`package.json`);if(!f){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let p=new URL(`customtypes/${u}/index.json`,f),m;try{let e=await r(p,`utf8`),t=M(tn,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${p.href}`),process.exitCode=1;return}m=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${u}\n`),console.error(`Create it first with: prismic page-type create ${u}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}let h=Object.keys(m.json),g=n??h[0]??`Main`;m.json[g]||(m.json[g]={});for(let[e,t]of Object.entries(m.json))if(t[d]){console.error(`Field "${d}" already exists in tab "${e}"`),process.exitCode=1;return}let _={type:`StructuredText`,config:{...i&&{label:i},...a&&{placeholder:a},...o&&{single:o},...c&&{multi:c},...l&&{allowTargetBlank:!0}}};m.json[g][d]=_;try{await s(p,B(m))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}console.info(`Added field "${d}" (StructuredText) to "${g}" tab in ${u}`)}const rn=E({id:k(),label:k(),repeatable:C(),status:C(),format:k(),json:O(k(),O(k(),A()))});async function an(){let{values:{help:t,tab:n,label:i,placeholder:a,option:o,default:c},positionals:[l,u]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},option:{type:`string`,multiple:!0},default:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a select (dropdown) field to an existing page type.
787
787
 
788
788
  USAGE
789
789
  prismic page-type add-field select <type-id> <field-id> [flags]
@@ -805,7 +805,7 @@ EXAMPLES
805
805
  prismic page-type add-field select product size --option "small" --option "medium" --option "large" --default "medium"
806
806
  prismic page-type add-field select article status --option "draft" --option "published" --label "Status"`);return}if(!l){console.error(`Missing required argument: type-id
807
807
  `),console.error(`Usage: prismic page-type add-field select <type-id> <field-id>`),process.exitCode=1;return}if(!u){console.error(`Missing required argument: field-id
808
- `),console.error(`Usage: prismic page-type add-field select <type-id> <field-id>`),process.exitCode=1;return}let d=await L(`package.json`);if(!d){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let f=new URL(`customtypes/${l}/index.json`,d),p;try{let e=await r(f,`utf8`),t=A(nn,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${f.href}`),process.exitCode=1;return}p=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${l}\n`),console.error(`Create it first with: prismic page-type create ${l}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}let m=Object.keys(p.json),h=n??m[0]??`Main`;p.json[h]||(p.json[h]={});for(let[e,t]of Object.entries(p.json))if(t[u]){console.error(`Field "${u}" already exists in tab "${e}"`),process.exitCode=1;return}let g={type:`Select`,config:{...i&&{label:i},...a&&{placeholder:a},...o&&o.length>0&&{options:o},...c&&{default_value:c}}};p.json[h][u]=g;try{await s(f,z(p))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}console.info(`Added field "${u}" (Select) to "${h}" tab in ${l}`)}const an=T({id:O(),label:O(),repeatable:S(),status:S(),format:O(),json:D(O(),D(O(),k()))});async function on(){let{values:{help:t,tab:n,label:i,placeholder:a,default:o},positionals:[c,l]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},default:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a timestamp (date and time) field to an existing page type.
808
+ `),console.error(`Usage: prismic page-type add-field select <type-id> <field-id>`),process.exitCode=1;return}let d=await R(`package.json`);if(!d){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let f=new URL(`customtypes/${l}/index.json`,d),p;try{let e=await r(f,`utf8`),t=M(rn,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${f.href}`),process.exitCode=1;return}p=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${l}\n`),console.error(`Create it first with: prismic page-type create ${l}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}let m=Object.keys(p.json),h=n??m[0]??`Main`;p.json[h]||(p.json[h]={});for(let[e,t]of Object.entries(p.json))if(t[u]){console.error(`Field "${u}" already exists in tab "${e}"`),process.exitCode=1;return}let g={type:`Select`,config:{...i&&{label:i},...a&&{placeholder:a},...o&&o.length>0&&{options:o},...c&&{default_value:c}}};p.json[h][u]=g;try{await s(f,B(p))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}console.info(`Added field "${u}" (Select) to "${h}" tab in ${l}`)}const on=E({id:k(),label:k(),repeatable:C(),status:C(),format:k(),json:O(k(),O(k(),A()))});async function sn(){let{values:{help:t,tab:n,label:i,placeholder:a,default:o},positionals:[c,l]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},default:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a timestamp (date and time) field to an existing page type.
809
809
 
810
810
  USAGE
811
811
  prismic page-type add-field timestamp <type-id> <field-id> [flags]
@@ -826,7 +826,7 @@ EXAMPLES
826
826
  prismic page-type add-field timestamp event start --tab "Schedule"
827
827
  prismic page-type add-field timestamp article published_at --label "Published At"`);return}if(!c){console.error(`Missing required argument: type-id
828
828
  `),console.error(`Usage: prismic page-type add-field timestamp <type-id> <field-id>`),process.exitCode=1;return}if(!l){console.error(`Missing required argument: field-id
829
- `),console.error(`Usage: prismic page-type add-field timestamp <type-id> <field-id>`),process.exitCode=1;return}let u=await L(`package.json`);if(!u){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let d=new URL(`customtypes/${c}/index.json`,u),f;try{let e=await r(d,`utf8`),t=A(an,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${d.href}`),process.exitCode=1;return}f=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${c}\n`),console.error(`Create it first with: prismic page-type create ${c}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}let p=Object.keys(f.json),m=n??p[0]??`Main`;f.json[m]||(f.json[m]={});for(let[e,t]of Object.entries(f.json))if(t[l]){console.error(`Field "${l}" already exists in tab "${e}"`),process.exitCode=1;return}let h={type:`Timestamp`,config:{...i&&{label:i},...a&&{placeholder:a},...o&&{default:o}}};f.json[m][l]=h;try{await s(d,z(f))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}console.info(`Added field "${l}" (Timestamp) to "${m}" tab in ${c}`)}const sn=T({id:O(),label:O(),repeatable:S(),status:S(),format:O(),json:D(O(),D(O(),k()))});async function cn(){let{values:{help:t,tab:n,label:i,placeholder:a},positionals:[o,c]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a UID (unique identifier) field to an existing page type.
829
+ `),console.error(`Usage: prismic page-type add-field timestamp <type-id> <field-id>`),process.exitCode=1;return}let u=await R(`package.json`);if(!u){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let d=new URL(`customtypes/${c}/index.json`,u),f;try{let e=await r(d,`utf8`),t=M(on,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${d.href}`),process.exitCode=1;return}f=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${c}\n`),console.error(`Create it first with: prismic page-type create ${c}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}let p=Object.keys(f.json),m=n??p[0]??`Main`;f.json[m]||(f.json[m]={});for(let[e,t]of Object.entries(f.json))if(t[l]){console.error(`Field "${l}" already exists in tab "${e}"`),process.exitCode=1;return}let h={type:`Timestamp`,config:{...i&&{label:i},...a&&{placeholder:a},...o&&{default:o}}};f.json[m][l]=h;try{await s(d,B(f))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}console.info(`Added field "${l}" (Timestamp) to "${m}" tab in ${c}`)}const cn=E({id:k(),label:k(),repeatable:C(),status:C(),format:k(),json:O(k(),O(k(),A()))});async function ln(){let{values:{help:t,tab:n,label:i,placeholder:a},positionals:[o,c]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a UID (unique identifier) field to an existing page type.
830
830
 
831
831
  USAGE
832
832
  prismic page-type add-field uid <type-id> <field-id> [flags]
@@ -846,7 +846,7 @@ EXAMPLES
846
846
  prismic page-type add-field uid article slug --label "URL Slug"
847
847
  prismic page-type add-field uid product sku --placeholder "Enter unique SKU"`);return}if(!o){console.error(`Missing required argument: type-id
848
848
  `),console.error(`Usage: prismic page-type add-field uid <type-id> <field-id>`),process.exitCode=1;return}if(!c){console.error(`Missing required argument: field-id
849
- `),console.error(`Usage: prismic page-type add-field uid <type-id> <field-id>`),process.exitCode=1;return}let l=await L(`package.json`);if(!l){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let u=new URL(`customtypes/${o}/index.json`,l),d;try{let e=await r(u,`utf8`),t=A(sn,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${u.href}`),process.exitCode=1;return}d=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${o}\n`),console.error(`Create it first with: prismic page-type create ${o}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}let f=Object.keys(d.json),p=n??f[0]??`Main`;d.json[p]||(d.json[p]={});for(let[e,t]of Object.entries(d.json))if(t[c]){console.error(`Field "${c}" already exists in tab "${e}"`),process.exitCode=1;return}let m={type:`UID`,config:{...i&&{label:i},...a&&{placeholder:a}}};d.json[p][c]=m;try{await s(u,z(d))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}console.info(`Added field "${c}" (UID) to "${p}" tab in ${o}`)}async function ln(){let{positionals:[t]}=e({args:process.argv.slice(4),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`boolean`:await Lt();break;case`color`:await zt();break;case`date`:await Vt();break;case`embed`:await Ut();break;case`geo-point`:await Gt();break;case`image`:await qt();break;case`key-text`:await Yt();break;case`link`:await Zt();break;case`number`:await $t();break;case`rich-text`:await tn();break;case`select`:await rn();break;case`timestamp`:await on();break;case`uid`:await cn();break;default:t&&(console.error(`Unknown field type: ${t}\n`),process.exitCode=1),console.info(`Add a field to an existing page type.
849
+ `),console.error(`Usage: prismic page-type add-field uid <type-id> <field-id>`),process.exitCode=1;return}let l=await R(`package.json`);if(!l){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let u=new URL(`customtypes/${o}/index.json`,l),d;try{let e=await r(u,`utf8`),t=M(cn,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${u.href}`),process.exitCode=1;return}d=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${o}\n`),console.error(`Create it first with: prismic page-type create ${o}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}let f=Object.keys(d.json),p=n??f[0]??`Main`;d.json[p]||(d.json[p]={});for(let[e,t]of Object.entries(d.json))if(t[c]){console.error(`Field "${c}" already exists in tab "${e}"`),process.exitCode=1;return}let m={type:`UID`,config:{...i&&{label:i},...a&&{placeholder:a}}};d.json[p][c]=m;try{await s(u,B(d))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}console.info(`Added field "${c}" (UID) to "${p}" tab in ${o}`)}async function un(){let{positionals:[t]}=e({args:process.argv.slice(4),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`boolean`:await Rt();break;case`color`:await Bt();break;case`date`:await Ht();break;case`embed`:await Wt();break;case`geo-point`:await Kt();break;case`image`:await Jt();break;case`key-text`:await Xt();break;case`link`:await Qt();break;case`number`:await en();break;case`rich-text`:await nn();break;case`select`:await an();break;case`timestamp`:await sn();break;case`uid`:await ln();break;default:t&&(console.error(`Unknown field type: ${t}\n`),process.exitCode=1),console.info(`Add a field to an existing page type.
850
850
 
851
851
  USAGE
852
852
  prismic page-type add-field <field-type> <type-id> <field-id> [flags]
@@ -876,7 +876,7 @@ EXAMPLES
876
876
  prismic page-type add-field key-text homepage meta_title --tab "SEO"
877
877
  prismic page-type add-field link homepage button --allow-text
878
878
  prismic page-type add-field rich-text homepage body --multi "paragraph,heading2,strong,em"
879
- prismic page-type add-field select homepage layout --option "full" --option "sidebar"`)}}const un=T({id:O(),label:O(),repeatable:S(),status:S(),format:O(),json:D(O(),D(O(),k()))});async function dn(){let{values:{help:t,"slice-zone":n},positionals:[i,a]}=e({args:process.argv.slice(4),options:{"slice-zone":{type:`string`,short:`z`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Connect a shared slice to a page type's slice zone.
879
+ prismic page-type add-field select homepage layout --option "full" --option "sidebar"`)}}const dn=E({id:k(),label:k(),repeatable:C(),status:C(),format:k(),json:O(k(),O(k(),A()))});async function fn(){let{values:{help:t,"slice-zone":n},positionals:[i,a]}=e({args:process.argv.slice(4),options:{"slice-zone":{type:`string`,short:`z`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Connect a shared slice to a page type's slice zone.
880
880
 
881
881
  USAGE
882
882
  prismic page-type connect-slice <type-id> <slice-id> [flags]
@@ -894,7 +894,7 @@ EXAMPLES
894
894
  prismic page-type connect-slice homepage CallToAction --slice-zone slices
895
895
  prismic page-type connect-slice article HeroSection -z body`);return}if(!i){console.error(`Missing required argument: type-id
896
896
  `),console.error(`Usage: prismic page-type connect-slice <type-id> <slice-id>`),process.exitCode=1;return}if(!a){console.error(`Missing required argument: slice-id
897
- `),console.error(`Usage: prismic page-type connect-slice <type-id> <slice-id>`),process.exitCode=1;return}let o=await B(a);if(!o.ok){console.error(o.error),process.exitCode=1;return}let c=await L(`package.json`);if(!c){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let l=new URL(`customtypes/${i}/index.json`,c),u;try{let e=await r(l,`utf8`),t=A(un,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${l.href}`),process.exitCode=1;return}u=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${i}\n`),console.error(`Create it first with: prismic page-type create ${i}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}let d=n??`slices`,f,p;for(let[,e]of Object.entries(u.json)){for(let[t,n]of Object.entries(e))if(n.type===`Slices`&&t===d){f=n,p=t;break}if(f)break}if(!f){if(n){console.error(`Slice zone "${n}" not found in page type "${i}"`),process.exitCode=1;return}let e=Object.keys(u.json)[0]??`Main`;u.json[e]||(u.json[e]={});let t={type:`Slices`,fieldset:`Slice Zone`,config:{choices:{}}};u.json[e][d]=t,f=t,p=d}if(f.config||={choices:{}},f.config.choices||(f.config.choices={}),a in f.config.choices){console.info(`Slice "${a}" is already connected to slice zone "${p}" in ${i}`);return}let m={type:`SharedSlice`};f.config.choices[a]=m;try{await s(l,z(u))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}console.info(`Connected slice "${a}" to slice zone "${p}" in ${i}`)}async function fn(){let{values:{help:t,name:r,single:i},positionals:[a]}=e({args:process.argv.slice(4),options:{name:{type:`string`,short:`n`},single:{type:`boolean`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Create a new page type in a Prismic repository.
897
+ `),console.error(`Usage: prismic page-type connect-slice <type-id> <slice-id>`),process.exitCode=1;return}let o=await V(a);if(!o.ok){console.error(o.error),process.exitCode=1;return}let c=await R(`package.json`);if(!c){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let l=new URL(`customtypes/${i}/index.json`,c),u;try{let e=await r(l,`utf8`),t=M(dn,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${l.href}`),process.exitCode=1;return}u=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${i}\n`),console.error(`Create it first with: prismic page-type create ${i}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}let d=n??`slices`,f,p;for(let[,e]of Object.entries(u.json)){for(let[t,n]of Object.entries(e))if(n.type===`Slices`&&t===d){f=n,p=t;break}if(f)break}if(!f){if(n){console.error(`Slice zone "${n}" not found in page type "${i}"`),process.exitCode=1;return}let e=Object.keys(u.json)[0]??`Main`;u.json[e]||(u.json[e]={});let t={type:`Slices`,fieldset:`Slice Zone`,config:{choices:{}}};u.json[e][d]=t,f=t,p=d}if(f.config||={choices:{}},f.config.choices||(f.config.choices={}),a in f.config.choices){console.info(`Slice "${a}" is already connected to slice zone "${p}" in ${i}`);return}let m={type:`SharedSlice`};f.config.choices[a]=m;try{await s(l,B(u))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}console.info(`Connected slice "${a}" to slice zone "${p}" in ${i}`)}async function pn(){let{values:{help:t,name:r,single:i},positionals:[a]}=e({args:process.argv.slice(4),options:{name:{type:`string`,short:`n`},single:{type:`boolean`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Create a new page type in a Prismic repository.
898
898
 
899
899
  USAGE
900
900
  prismic page-type create <id> [flags]
@@ -908,7 +908,7 @@ FLAGS
908
908
  -h, --help Show help for command
909
909
 
910
910
  LEARN MORE
911
- Use \`prismic page-type <command> --help\` for more information about a command.`);return}if(!a){console.error(`Missing required argument: id`),process.exitCode=1;return}let o={id:a,label:r??pn(a),repeatable:!i,status:!0,format:`page`,json:{Main:{},"SEO & Metadata":{}}},c=await L(`package.json`);if(!c){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let l=new URL(`customtypes/`,c),u=new URL(a+`/`,l),d=new URL(`index.json`,u);try{await n(new URL(`.`,d),{recursive:!0}),await s(d,z(o))}catch(e){e instanceof Error?console.error(`Failed to create page type: ${e.message}`):console.error(`Failed to create page type`),process.exitCode=1;return}console.info(`Created page type at ${d.href}`)}function pn(e){return e.toLowerCase().replace(/(^|[-_\s]+)(.)?/g,(e,t,n)=>n?.toUpperCase()??``)}const mn=T({id:O(),label:O(),repeatable:S(),status:S(),format:O(),json:D(O(),D(O(),k()))});async function hn(){let{values:{help:t,"slice-zone":n},positionals:[i,a]}=e({args:process.argv.slice(4),options:{"slice-zone":{type:`string`,short:`z`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Disconnect a shared slice from a page type's slice zone.
911
+ Use \`prismic page-type <command> --help\` for more information about a command.`);return}if(!a){console.error(`Missing required argument: id`),process.exitCode=1;return}let o={id:a,label:r??mn(a),repeatable:!i,status:!0,format:`page`,json:{Main:{},"SEO & Metadata":{}}},c=await R(`package.json`);if(!c){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let l=new URL(`customtypes/`,c),u=new URL(a+`/`,l),d=new URL(`index.json`,u);try{await n(new URL(`.`,d),{recursive:!0}),await s(d,B(o))}catch(e){e instanceof Error?console.error(`Failed to create page type: ${e.message}`):console.error(`Failed to create page type`),process.exitCode=1;return}console.info(`Created page type at ${d.href}`)}function mn(e){return e.toLowerCase().replace(/(^|[-_\s]+)(.)?/g,(e,t,n)=>n?.toUpperCase()??``)}const hn=E({id:k(),label:k(),repeatable:C(),status:C(),format:k(),json:O(k(),O(k(),A()))});async function gn(){let{values:{help:t,"slice-zone":n},positionals:[i,a]}=e({args:process.argv.slice(4),options:{"slice-zone":{type:`string`,short:`z`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Disconnect a shared slice from a page type's slice zone.
912
912
 
913
913
  USAGE
914
914
  prismic page-type disconnect-slice <type-id> <slice-id> [flags]
@@ -926,7 +926,7 @@ EXAMPLES
926
926
  prismic page-type disconnect-slice homepage CallToAction --slice-zone slices
927
927
  prismic page-type disconnect-slice article HeroSection -z body`);return}if(!i){console.error(`Missing required argument: type-id
928
928
  `),console.error(`Usage: prismic page-type disconnect-slice <type-id> <slice-id>`),process.exitCode=1;return}if(!a){console.error(`Missing required argument: slice-id
929
- `),console.error(`Usage: prismic page-type disconnect-slice <type-id> <slice-id>`),process.exitCode=1;return}let o=await L(`package.json`);if(!o){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let c=new URL(`customtypes/${i}/index.json`,o),l;try{let e=await r(c,`utf8`),t=A(mn,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${c.href}`),process.exitCode=1;return}l=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${i}\n`),console.error(`Create it first with: prismic page-type create ${i}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}let u=n??`slices`,d,f;for(let[,e]of Object.entries(l.json)){for(let[t,n]of Object.entries(e))if(n.type===`Slices`&&t===u){d=n,f=t;break}if(d)break}if(!d){console.error(`Slice zone "${u}" not found in page type "${i}"`),process.exitCode=1;return}if(!d.config?.choices||!(a in d.config.choices)){console.error(`Slice "${a}" is not connected to slice zone "${f}" in ${i}`),process.exitCode=1;return}delete d.config.choices[a];try{await s(c,z(l))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}console.info(`Disconnected slice "${a}" from slice zone "${f}" in ${i}`)}const gn=T({id:O(),label:O(),repeatable:S(),status:S(),format:E(O()),json:D(O(),D(O(),k()))});async function _n(){let{values:{help:t,json:n}}=e({args:process.argv.slice(4),options:{json:{type:`boolean`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`List all page types in a Prismic project.
929
+ `),console.error(`Usage: prismic page-type disconnect-slice <type-id> <slice-id>`),process.exitCode=1;return}let o=await R(`package.json`);if(!o){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let c=new URL(`customtypes/${i}/index.json`,o),l;try{let e=await r(c,`utf8`),t=M(hn,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${c.href}`),process.exitCode=1;return}l=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${i}\n`),console.error(`Create it first with: prismic page-type create ${i}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}let u=n??`slices`,d,f;for(let[,e]of Object.entries(l.json)){for(let[t,n]of Object.entries(e))if(n.type===`Slices`&&t===u){d=n,f=t;break}if(d)break}if(!d){console.error(`Slice zone "${u}" not found in page type "${i}"`),process.exitCode=1;return}if(!d.config?.choices||!(a in d.config.choices)){console.error(`Slice "${a}" is not connected to slice zone "${f}" in ${i}`),process.exitCode=1;return}delete d.config.choices[a];try{await s(c,B(l))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}console.info(`Disconnected slice "${a}" from slice zone "${f}" in ${i}`)}const _n=E({id:k(),label:k(),repeatable:C(),status:C(),format:D(k()),json:O(k(),O(k(),A()))});async function vn(){let{values:{help:t,json:n}}=e({args:process.argv.slice(4),options:{json:{type:`boolean`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`List all page types in a Prismic project.
930
930
 
931
931
  USAGE
932
932
  prismic page-type list [flags]
@@ -937,7 +937,7 @@ FLAGS
937
937
 
938
938
  EXAMPLES
939
939
  prismic page-type list
940
- prismic page-type list --json`);return}let a=await L(`package.json`);if(!a){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let o=new URL(`customtypes/`,a),s;try{s=await i(o,{withFileTypes:!1})}catch{n?console.info(JSON.stringify([])):console.info(`No page types found.`);return}let c=[];for(let e of s){let t=new URL(`${e}/index.json`,o);try{let e=await r(t,`utf8`),n=A(gn,JSON.parse(e));n.success&&n.output.format===`page`&&c.push({id:n.output.id,label:n.output.label,repeatable:n.output.repeatable})}catch{}}if(c.length===0){n?console.info(JSON.stringify([])):console.info(`No page types found.`);return}if(n)console.info(JSON.stringify(c,null,2));else{console.info(`ID LABEL TYPE`);for(let e of c){let t=e.repeatable?`repeatable`:`singleton`;console.info(`${e.id}\t${e.label}\t${t}`)}}}const vn=T({id:O(),label:O(),repeatable:S(),status:S(),format:E(O()),json:D(O(),D(O(),k()))});async function yn(){let{values:{help:t,y:n},positionals:[i]}=e({args:process.argv.slice(4),options:{y:{type:`boolean`,short:`y`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Remove a page type from the project.
940
+ prismic page-type list --json`);return}let a=await R(`package.json`);if(!a){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let o=new URL(`customtypes/`,a),s;try{s=await i(o,{withFileTypes:!1})}catch{n?console.info(JSON.stringify([])):console.info(`No page types found.`);return}let c=[];for(let e of s){let t=new URL(`${e}/index.json`,o);try{let e=await r(t,`utf8`),n=M(_n,JSON.parse(e));n.success&&n.output.format===`page`&&c.push({id:n.output.id,label:n.output.label,repeatable:n.output.repeatable})}catch{}}if(c.length===0){n?console.info(JSON.stringify([])):console.info(`No page types found.`);return}if(n)console.info(JSON.stringify(c,null,2));else{console.info(`ID LABEL TYPE`);for(let e of c){let t=e.repeatable?`repeatable`:`singleton`;console.info(`${e.id}\t${e.label}\t${t}`)}}}const yn=E({id:k(),label:k(),repeatable:C(),status:C(),format:D(k()),json:O(k(),O(k(),A()))});async function bn(){let{values:{help:t,y:n},positionals:[i]}=e({args:process.argv.slice(4),options:{y:{type:`boolean`,short:`y`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Remove a page type from the project.
941
941
 
942
942
  USAGE
943
943
  prismic page-type remove <type-id> [flags]
@@ -952,7 +952,7 @@ FLAGS
952
952
  EXAMPLES
953
953
  prismic page-type remove homepage
954
954
  prismic page-type remove homepage -y`);return}if(!i){console.error(`Missing required argument: type-id
955
- `),console.error(`Usage: prismic page-type remove <type-id>`),process.exitCode=1;return}let a=await L(`package.json`);if(!a){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let s=new URL(`customtypes/${i}/`,a),c=new URL(`index.json`,s),l;try{let e=await r(c,`utf8`),t=A(vn,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${c.href}`),process.exitCode=1;return}l=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${i}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}if(l.format!==`page`){console.error(`"${i}" is not a page type (format: ${l.format??`custom`})`),process.exitCode=1;return}if(!n){console.error(`Refusing to remove page type "${i}" (this will delete the entire directory).`),console.error(`Re-run with -y to confirm.`),process.exitCode=1;return}try{await o(s,{recursive:!0})}catch(e){e instanceof Error?console.error(`Failed to remove page type: ${e.message}`):console.error(`Failed to remove page type`),process.exitCode=1;return}console.info(`Removed page type "${i}"`)}const bn=T({id:O(),label:O(),repeatable:S(),status:S(),format:E(O()),json:D(O(),D(O(),k()))});async function xn(){let{values:{help:t,tab:n},positionals:[i,a]}=e({args:process.argv.slice(4),options:{tab:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Remove a field from a page type.
955
+ `),console.error(`Usage: prismic page-type remove <type-id>`),process.exitCode=1;return}let a=await R(`package.json`);if(!a){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let s=new URL(`customtypes/${i}/`,a),c=new URL(`index.json`,s),l;try{let e=await r(c,`utf8`),t=M(yn,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${c.href}`),process.exitCode=1;return}l=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${i}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}if(l.format!==`page`){console.error(`"${i}" is not a page type (format: ${l.format??`custom`})`),process.exitCode=1;return}if(!n){console.error(`Refusing to remove page type "${i}" (this will delete the entire directory).`),console.error(`Re-run with -y to confirm.`),process.exitCode=1;return}try{await o(s,{recursive:!0})}catch(e){e instanceof Error?console.error(`Failed to remove page type: ${e.message}`):console.error(`Failed to remove page type`),process.exitCode=1;return}console.info(`Removed page type "${i}"`)}const xn=E({id:k(),label:k(),repeatable:C(),status:C(),format:D(k()),json:O(k(),O(k(),A()))});async function Sn(){let{values:{help:t,tab:n},positionals:[i,a]}=e({args:process.argv.slice(4),options:{tab:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Remove a field from a page type.
956
956
 
957
957
  USAGE
958
958
  prismic page-type remove-field <type-id> <field-id> [flags]
@@ -969,7 +969,7 @@ EXAMPLES
969
969
  prismic page-type remove-field homepage title
970
970
  prismic page-type remove-field homepage meta_title --tab "SEO & Metadata"`);return}if(!i){console.error(`Missing required argument: type-id
971
971
  `),console.error(`Usage: prismic page-type remove-field <type-id> <field-id>`),process.exitCode=1;return}if(!a){console.error(`Missing required argument: field-id
972
- `),console.error(`Usage: prismic page-type remove-field <type-id> <field-id>`),process.exitCode=1;return}let o=await L(`package.json`);if(!o){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let c=new URL(`customtypes/${i}/index.json`,o),l;try{let e=await r(c,`utf8`),t=A(bn,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${c.href}`),process.exitCode=1;return}l=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${i}\n`),console.error(`Create it first with: prismic page-type create ${i}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}if(l.format!==`page`){console.error(`"${i}" is not a page type (format: ${l.format??`custom`})`),process.exitCode=1;return}let u;if(n){if(!l.json[n]){console.error(`Tab "${n}" not found in page type "${i}"`),console.error(`Available tabs: ${Object.keys(l.json).join(`, `)}`),process.exitCode=1;return}if(!(a in l.json[n])){console.error(`Field "${a}" not found in tab "${n}"`),process.exitCode=1;return}delete l.json[n][a],u=n}else{for(let[e,t]of Object.entries(l.json))if(a in t){delete t[a],u=e;break}if(!u){console.error(`Field "${a}" not found in any tab of page type "${i}"`),process.exitCode=1;return}}try{await s(c,z(l))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}console.info(`Removed field "${a}" from tab "${u}" in page type "${i}"`)}const Sn=T({id:O(),label:O(),repeatable:S(),status:S(),format:E(O()),json:D(O(),D(O(),k()))});async function Cn(){let{values:{help:t},positionals:[n,i]}=e({args:process.argv.slice(4),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Change a page type's display name (label).
972
+ `),console.error(`Usage: prismic page-type remove-field <type-id> <field-id>`),process.exitCode=1;return}let o=await R(`package.json`);if(!o){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let c=new URL(`customtypes/${i}/index.json`,o),l;try{let e=await r(c,`utf8`),t=M(xn,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${c.href}`),process.exitCode=1;return}l=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${i}\n`),console.error(`Create it first with: prismic page-type create ${i}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}if(l.format!==`page`){console.error(`"${i}" is not a page type (format: ${l.format??`custom`})`),process.exitCode=1;return}let u;if(n){if(!l.json[n]){console.error(`Tab "${n}" not found in page type "${i}"`),console.error(`Available tabs: ${Object.keys(l.json).join(`, `)}`),process.exitCode=1;return}if(!(a in l.json[n])){console.error(`Field "${a}" not found in tab "${n}"`),process.exitCode=1;return}delete l.json[n][a],u=n}else{for(let[e,t]of Object.entries(l.json))if(a in t){delete t[a],u=e;break}if(!u){console.error(`Field "${a}" not found in any tab of page type "${i}"`),process.exitCode=1;return}}try{await s(c,B(l))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}console.info(`Removed field "${a}" from tab "${u}" in page type "${i}"`)}const Cn=E({id:k(),label:k(),repeatable:C(),status:C(),format:D(k()),json:O(k(),O(k(),A()))});async function wn(){let{values:{help:t},positionals:[n,i]}=e({args:process.argv.slice(4),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Change a page type's display name (label).
973
973
 
974
974
  USAGE
975
975
  prismic page-type set-name <type-id> <new-name> [flags]
@@ -985,7 +985,7 @@ EXAMPLES
985
985
  prismic page-type set-name homepage "Home Page"
986
986
  prismic page-type set-name blog_post "Blog Post"`);return}if(!n){console.error(`Missing required argument: type-id
987
987
  `),console.error(`Usage: prismic page-type set-name <type-id> <new-name>`),process.exitCode=1;return}if(!i){console.error(`Missing required argument: new-name
988
- `),console.error(`Usage: prismic page-type set-name <type-id> <new-name>`),process.exitCode=1;return}let a=await L(`package.json`);if(!a){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let o=new URL(`customtypes/${n}/index.json`,a),c;try{let e=await r(o,`utf8`),t=A(Sn,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${o.href}`),process.exitCode=1;return}c=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${n}\n`),console.error(`Create it first with: prismic page-type create ${n}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}if(c.format!==`page`){console.error(`"${n}" is not a page type (format: ${c.format??`custom`})`),process.exitCode=1;return}c.label=i;try{await s(o,z(c))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}console.info(`Renamed page type "${n}" to "${i}"`)}const wn=T({id:O(),label:O(),repeatable:S(),status:S(),format:E(O()),json:D(O(),D(O(),k()))});async function Tn(){let{values:{help:t},positionals:[n,i]}=e({args:process.argv.slice(4),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Set whether a page type is repeatable.
988
+ `),console.error(`Usage: prismic page-type set-name <type-id> <new-name>`),process.exitCode=1;return}let a=await R(`package.json`);if(!a){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let o=new URL(`customtypes/${n}/index.json`,a),c;try{let e=await r(o,`utf8`),t=M(Cn,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${o.href}`),process.exitCode=1;return}c=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${n}\n`),console.error(`Create it first with: prismic page-type create ${n}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}if(c.format!==`page`){console.error(`"${n}" is not a page type (format: ${c.format??`custom`})`),process.exitCode=1;return}c.label=i;try{await s(o,B(c))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}console.info(`Renamed page type "${n}" to "${i}"`)}const Tn=E({id:k(),label:k(),repeatable:C(),status:C(),format:D(k()),json:O(k(),O(k(),A()))});async function En(){let{values:{help:t},positionals:[n,i]}=e({args:process.argv.slice(4),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Set whether a page type is repeatable.
989
989
 
990
990
  USAGE
991
991
  prismic page-type set-repeatable <type-id> <true|false> [flags]
@@ -1001,7 +1001,7 @@ EXAMPLES
1001
1001
  prismic page-type set-repeatable homepage true
1002
1002
  prismic page-type set-repeatable settings false`);return}if(!n){console.error(`Missing required argument: type-id
1003
1003
  `),console.error(`Usage: prismic page-type set-repeatable <type-id> <true|false>`),process.exitCode=1;return}if(!i){console.error(`Missing required argument: true|false
1004
- `),console.error(`Usage: prismic page-type set-repeatable <type-id> <true|false>`),process.exitCode=1;return}if(i!==`true`&&i!==`false`){console.error(`Invalid value: "${i}". Must be "true" or "false".`),process.exitCode=1;return}let a=i===`true`,o=await L(`package.json`);if(!o){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let c=new URL(`customtypes/${n}/index.json`,o),l;try{let e=await r(c,`utf8`),t=A(wn,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${c.href}`),process.exitCode=1;return}l=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${n}\n`),console.error(`Create it first with: prismic page-type create ${n}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}if(l.format!==`page`){console.error(`"${n}" is not a page type (format: ${l.format??`custom`})`),process.exitCode=1;return}l.repeatable=a;try{await s(c,z(l))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}let u=a?`repeatable`:`singleton`;console.info(`Set page type "${n}" to ${u}`)}const En=T({id:O(),label:O(),repeatable:S(),status:S(),format:E(O()),json:D(O(),D(O(),k()))});async function Dn(){let{values:{help:t,json:n},positionals:[i]}=e({args:process.argv.slice(4),options:{json:{type:`boolean`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`View details of a specific page type.
1004
+ `),console.error(`Usage: prismic page-type set-repeatable <type-id> <true|false>`),process.exitCode=1;return}if(i!==`true`&&i!==`false`){console.error(`Invalid value: "${i}". Must be "true" or "false".`),process.exitCode=1;return}let a=i===`true`,o=await R(`package.json`);if(!o){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let c=new URL(`customtypes/${n}/index.json`,o),l;try{let e=await r(c,`utf8`),t=M(Tn,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${c.href}`),process.exitCode=1;return}l=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${n}\n`),console.error(`Create it first with: prismic page-type create ${n}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}if(l.format!==`page`){console.error(`"${n}" is not a page type (format: ${l.format??`custom`})`),process.exitCode=1;return}l.repeatable=a;try{await s(c,B(l))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}let u=a?`repeatable`:`singleton`;console.info(`Set page type "${n}" to ${u}`)}const Dn=E({id:k(),label:k(),repeatable:C(),status:C(),format:D(k()),json:O(k(),O(k(),A()))});async function On(){let{values:{help:t,json:n},positionals:[i]}=e({args:process.argv.slice(4),options:{json:{type:`boolean`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`View details of a specific page type.
1005
1005
 
1006
1006
  USAGE
1007
1007
  prismic page-type view <type-id> [flags]
@@ -1016,7 +1016,7 @@ FLAGS
1016
1016
  EXAMPLES
1017
1017
  prismic page-type view homepage
1018
1018
  prismic page-type view homepage --json`);return}if(!i){console.error(`Missing required argument: type-id
1019
- `),console.error(`Usage: prismic page-type view <type-id>`),process.exitCode=1;return}let a=await L(`package.json`);if(!a){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let o=new URL(`customtypes/${i}/index.json`,a),s;try{let e=await r(o,`utf8`),t=A(En,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${o.href}`),process.exitCode=1;return}s=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${i}\n`),console.error(`Create it first with: prismic page-type create ${i}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}if(s.format!==`page`){console.error(`"${i}" is not a page type (format: ${s.format??`custom`})`),process.exitCode=1;return}if(n){console.info(JSON.stringify(s,null,2));return}console.info(`ID: ${s.id}`),console.info(`Label: ${s.label}`),console.info(`Repeatable: ${s.repeatable}`);let c=Object.entries(s.json);console.info(`\nTabs (${c.length}):`);for(let[e,t]of c){let n=Object.keys(t).length;console.info(` - ${e}: ${n} fields`)}}async function On(){let{positionals:[t]}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`create`:await fn();break;case`list`:await _n();break;case`view`:await Dn();break;case`remove`:await yn();break;case`set-name`:await Cn();break;case`set-repeatable`:await Tn();break;case`add-field`:await ln();break;case`remove-field`:await xn();break;case`connect-slice`:await dn();break;case`disconnect-slice`:await hn();break;default:t&&(console.error(`Unknown page-type subcommand: ${t}\n`),process.exitCode=1),console.info(`Manage page types in a Prismic repository.
1019
+ `),console.error(`Usage: prismic page-type view <type-id>`),process.exitCode=1;return}let a=await R(`package.json`);if(!a){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let o=new URL(`customtypes/${i}/index.json`,a),s;try{let e=await r(o,`utf8`),t=M(Dn,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${o.href}`),process.exitCode=1;return}s=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${i}\n`),console.error(`Create it first with: prismic page-type create ${i}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}if(s.format!==`page`){console.error(`"${i}" is not a page type (format: ${s.format??`custom`})`),process.exitCode=1;return}if(n){console.info(JSON.stringify(s,null,2));return}console.info(`ID: ${s.id}`),console.info(`Label: ${s.label}`),console.info(`Repeatable: ${s.repeatable}`);let c=Object.entries(s.json);console.info(`\nTabs (${c.length}):`);for(let[e,t]of c){let n=Object.keys(t).length;console.info(` - ${e}: ${n} fields`)}}async function kn(){let{positionals:[t]}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`create`:await pn();break;case`list`:await vn();break;case`view`:await On();break;case`remove`:await bn();break;case`set-name`:await wn();break;case`set-repeatable`:await En();break;case`add-field`:await un();break;case`remove-field`:await Sn();break;case`connect-slice`:await fn();break;case`disconnect-slice`:await gn();break;default:t&&(console.error(`Unknown page-type subcommand: ${t}\n`),process.exitCode=1),console.info(`Manage page types in a Prismic repository.
1020
1020
 
1021
1021
  USAGE
1022
1022
  prismic page-type <command> [flags]
@@ -1037,7 +1037,7 @@ FLAGS
1037
1037
  -h, --help Show help for command
1038
1038
 
1039
1039
  LEARN MORE
1040
- Use \`prismic page-type <command> --help\` for more information about a command.`)}}async function kn(){let{values:{help:t,name:n,repo:r=await U()},positionals:[i]}=e({args:process.argv.slice(4),options:{name:{type:`string`,short:`n`},repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a preview configuration to a Prismic repository.
1040
+ Use \`prismic page-type <command> --help\` for more information about a command.`)}}async function An(){let{values:{help:t,name:n,repo:r=await H()},positionals:[i]}=e({args:process.argv.slice(4),options:{name:{type:`string`,short:`n`},repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a preview configuration to a Prismic repository.
1041
1041
 
1042
1042
  By default, this command reads the repository from prismic.config.json at the
1043
1043
  project root.
@@ -1054,7 +1054,7 @@ FLAGS
1054
1054
  -h, --help Show help for command
1055
1055
 
1056
1056
  LEARN MORE
1057
- Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!i){console.error(`Missing required argument: <url>`),process.exitCode=1;return}if(!r){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await M()){Mn();return}let a=An(i);if(!a){console.error(`Invalid URL: ${i}`),process.exitCode=1;return}let o=await jn(r,{name:n||a.hostname,websiteURL:a.websiteURL,resolverPath:a.resolverPath});if(!o.ok){o.error instanceof K?Mn():(console.error(`Failed to add preview: ${z(o.value)}`),process.exitCode=1);return}console.info(`Preview added: ${i}`)}function An(e){try{let t=new URL(e);return{websiteURL:`${t.protocol}//${t.host}`,resolverPath:t.pathname===`/`?void 0:t.pathname,hostname:t.hostname}}catch{return}}async function jn(e,t){return await G(new URL(`/previews/new`,await F(e)),{method:`POST`,body:{name:t.name,websiteURL:t.websiteURL,resolverPath:t.resolverPath}})}function Mn(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function Nn(){let{values:{help:t,repo:n=await U(),json:r}}=e({args:process.argv.slice(4),options:{json:{type:`boolean`},repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!1});if(t){console.info(`List all preview configurations in a Prismic repository.
1057
+ Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!i){console.error(`Missing required argument: <url>`),process.exitCode=1;return}if(!r){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await P()){Nn();return}let a=jn(i);if(!a){console.error(`Invalid URL: ${i}`),process.exitCode=1;return}let o=await Mn(r,{name:n||a.hostname,websiteURL:a.websiteURL,resolverPath:a.resolverPath});if(!o.ok){o.error instanceof G?Nn():(console.error(`Failed to add preview: ${B(o.value)}`),process.exitCode=1);return}console.info(`Preview added: ${i}`)}function jn(e){try{let t=new URL(e);return{websiteURL:`${t.protocol}//${t.host}`,resolverPath:t.pathname===`/`?void 0:t.pathname,hostname:t.hostname}}catch{return}}async function Mn(e,t){return await W(new URL(`/previews/new`,await I(e)),{method:`POST`,body:{name:t.name,websiteURL:t.websiteURL,resolverPath:t.resolverPath}})}function Nn(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function Pn(){let{values:{help:t,repo:n=await H(),json:r}}=e({args:process.argv.slice(4),options:{json:{type:`boolean`},repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!1});if(t){console.info(`List all preview configurations in a Prismic repository.
1058
1058
 
1059
1059
  By default, this command reads the repository from prismic.config.json at the
1060
1060
  project root.
@@ -1068,7 +1068,7 @@ FLAGS
1068
1068
  -h, --help Show help for command
1069
1069
 
1070
1070
  LEARN MORE
1071
- Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await M()){In();return}let i=await Fn(n);if(!i.ok){i.error instanceof K?In():b(i.error)?(console.error(`Failed to list previews: Invalid response: ${z(i.error.issues)}`),process.exitCode=1):(console.error(`Failed to list previews: ${z(i.value)}`),process.exitCode=1);return}let a=i.value.results;if(r)console.info(z(a));else for(let e of a)console.info(`${e.url} ${e.label}`)}const Pn=T({results:x(T({id:O(),label:O(),url:O()}))});async function Fn(e){return await G(new URL(`/core/repository/preview_configs`,await F(e)),{schema:Pn})}function In(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function Ln(){let{values:{help:t,repo:n=await U()},positionals:[r]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Remove a preview configuration from a Prismic repository.
1071
+ Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await P()){Ln();return}let i=await In(n);if(!i.ok){i.error instanceof G?Ln():b(i.error)?(console.error(`Failed to list previews: Invalid response: ${B(i.error.issues)}`),process.exitCode=1):(console.error(`Failed to list previews: ${B(i.value)}`),process.exitCode=1);return}let a=i.value.results;if(r)console.info(B(a));else for(let e of a)console.info(`${e.url} ${e.label}`)}const Fn=E({results:S(E({id:k(),label:k(),url:k()}))});async function In(e){return await W(new URL(`/core/repository/preview_configs`,await I(e)),{schema:Fn})}function Ln(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function Rn(){let{values:{help:t,repo:n=await H()},positionals:[r]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Remove a preview configuration from a Prismic repository.
1072
1072
 
1073
1073
  By default, this command reads the repository from prismic.config.json at the
1074
1074
  project root.
@@ -1084,7 +1084,7 @@ FLAGS
1084
1084
  -h, --help Show help for command
1085
1085
 
1086
1086
  LEARN MORE
1087
- Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <url>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await M()){zn();return}let i=await Fn(n);if(!i.ok){i.error instanceof K?zn():(console.error(`Failed to fetch previews: ${z(i.value)}`),process.exitCode=1);return}let a=i.value.results.find(e=>e.url===r);if(!a){console.error(`Preview not found: ${r}`),process.exitCode=1;return}let o=await Rn(n,a.id);if(!o.ok){o.error instanceof K?zn():(console.error(`Failed to remove preview: ${z(o.value)}`),process.exitCode=1);return}console.info(`Preview removed: ${r}`)}async function Rn(e,t){return await G(new URL(`/previews/delete/${t}`,await F(e)),{method:`POST`,body:{}})}function zn(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function Bn(){let{values:{help:t,repo:n=await U()},positionals:[r,i]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Update the name of a preview configuration.
1087
+ Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <url>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await P()){Bn();return}let i=await In(n);if(!i.ok){i.error instanceof G?Bn():(console.error(`Failed to fetch previews: ${B(i.value)}`),process.exitCode=1);return}let a=i.value.results.find(e=>e.url===r);if(!a){console.error(`Preview not found: ${r}`),process.exitCode=1;return}let o=await zn(n,a.id);if(!o.ok){o.error instanceof G?Bn():(console.error(`Failed to remove preview: ${B(o.value)}`),process.exitCode=1);return}console.info(`Preview removed: ${r}`)}async function zn(e,t){return await W(new URL(`/previews/delete/${t}`,await I(e)),{method:`POST`,body:{}})}function Bn(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function Vn(){let{values:{help:t,repo:n=await H()},positionals:[r,i]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Update the name of a preview configuration.
1088
1088
 
1089
1089
  By default, this command reads the repository from prismic.config.json at the
1090
1090
  project root.
@@ -1101,7 +1101,7 @@ FLAGS
1101
1101
  -h, --help Show help for command
1102
1102
 
1103
1103
  LEARN MORE
1104
- Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <url>`),process.exitCode=1;return}if(!i){console.error(`Missing required argument: <name>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await M()){Hn();return}let a=An(r);if(!a){console.error(`Invalid URL: ${r}`),process.exitCode=1;return}let o=await Fn(n);if(!o.ok){o.error instanceof K?Hn():(console.error(`Failed to fetch previews: ${z(o.value)}`),process.exitCode=1);return}let s=o.value.results.find(e=>e.url===r);if(!s){console.error(`Preview not found: ${r}`),process.exitCode=1;return}let c=await Vn(n,s.id,{name:i,websiteURL:a.websiteURL,resolverPath:a.resolverPath});if(!c.ok){c.error instanceof K?Hn():(console.error(`Failed to update preview: ${z(c.value)}`),process.exitCode=1);return}console.info(`Preview updated: ${r}`)}async function Vn(e,t,n){return await G(new URL(`/previews/save/${t}`,await F(e)),{method:`POST`,body:{name:n.name,websiteURL:n.websiteURL,resolverPath:n.resolverPath}})}function Hn(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function Un(){let{positionals:[t]}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`add`:await kn();break;case`list`:await Nn();break;case`remove`:await Ln();break;case`set-name`:await Bn();break;default:t&&(console.error(`Unknown preview subcommand: ${t}\n`),process.exitCode=1),console.info(`Manage preview configurations in a Prismic repository.
1104
+ Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <url>`),process.exitCode=1;return}if(!i){console.error(`Missing required argument: <name>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await P()){Un();return}let a=jn(r);if(!a){console.error(`Invalid URL: ${r}`),process.exitCode=1;return}let o=await In(n);if(!o.ok){o.error instanceof G?Un():(console.error(`Failed to fetch previews: ${B(o.value)}`),process.exitCode=1);return}let s=o.value.results.find(e=>e.url===r);if(!s){console.error(`Preview not found: ${r}`),process.exitCode=1;return}let c=await Hn(n,s.id,{name:i,websiteURL:a.websiteURL,resolverPath:a.resolverPath});if(!c.ok){c.error instanceof G?Un():(console.error(`Failed to update preview: ${B(c.value)}`),process.exitCode=1);return}console.info(`Preview updated: ${r}`)}async function Hn(e,t,n){return await W(new URL(`/previews/save/${t}`,await I(e)),{method:`POST`,body:{name:n.name,websiteURL:n.websiteURL,resolverPath:n.resolverPath}})}function Un(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function Wn(){let{positionals:[t]}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`add`:await An();break;case`list`:await Pn();break;case`remove`:await Rn();break;case`set-name`:await Vn();break;default:t&&(console.error(`Unknown preview subcommand: ${t}\n`),process.exitCode=1),console.info(`Manage preview configurations in a Prismic repository.
1105
1105
 
1106
1106
  USAGE
1107
1107
  prismic preview <command> [flags]
@@ -1116,7 +1116,7 @@ FLAGS
1116
1116
  -h, --help Show help for command
1117
1117
 
1118
1118
  LEARN MORE
1119
- Use \`prismic preview <command> --help\` for more information about a command.`)}}const Wn=/^[a-zA-Z0-9][-a-zA-Z0-9]{2,}[a-zA-Z0-9]$/;async function Gn(){let{values:{help:t,name:n,"no-config":r,replace:i},positionals:[a]}=e({args:process.argv.slice(4),options:{help:{type:`boolean`,short:`h`},name:{type:`string`,short:`n`},"no-config":{type:`boolean`},replace:{type:`boolean`}},allowPositionals:!0});if(t){console.info(`Create a new Prismic repository.
1119
+ Use \`prismic preview <command> --help\` for more information about a command.`)}}const Gn=/^[a-zA-Z0-9][-a-zA-Z0-9]{2,}[a-zA-Z0-9]$/;async function Kn(){let{values:{help:t,name:n,"no-config":r,replace:i},positionals:[a]}=e({args:process.argv.slice(4),options:{help:{type:`boolean`,short:`h`},name:{type:`string`,short:`n`},"no-config":{type:`boolean`},replace:{type:`boolean`}},allowPositionals:!0});if(t){console.info(`Create a new Prismic repository.
1120
1120
 
1121
1121
  Creates prismic.config.json in the current directory. If a config file already
1122
1122
  exists, use --replace to update it with the new repository.
@@ -1135,7 +1135,7 @@ FLAGS
1135
1135
  -h, --help Show help for command
1136
1136
 
1137
1137
  LEARN MORE
1138
- Use \`prismic repo <command> --help\` for more information about a command.`);return}if(!a){console.error(`Missing required argument: domain`),process.exitCode=1;return}if(!Wn.test(a)){console.error(`Invalid domain format.`),console.error(`Must be at least 4 characters, start and end with alphanumeric, and contain only alphanumerics and hyphens.`),process.exitCode=1;return}if(!await M()){qn();return}let o=await W();if(!r&&o.ok&&!i){console.error(`This project already has a repository: ${o.config.repositoryName}`),console.error(`Use --replace to replace it, or --no-config to skip config creation.`),process.exitCode=1;return}let s=await Kn(a,n);if(!s.ok){s.error instanceof K?qn():(console.error(`Failed to create repository: ${z(s.error)}`),process.exitCode=1);return}if(!r)if(o.ok){let e=await ut({repositoryName:a});e.ok?console.info(`Updated prismic.config.json`):console.warn(`Could not update prismic.config.json: `+e.error.message)}else{let e=await ct({repositoryName:a});e.ok?console.info(`Created prismic.config.json`):console.warn(`Could not create prismic.config.json: `+e.error.message)}console.info(`Repository created: ${a}`),console.info(`URL: ${await F(a)}`)}async function Kn(e,t=e){return await G(new URL(`/app/dashboard/repositories`,await P()),{method:`POST`,body:{domain:e,name:t,framework:`next`,plan:`personal`,usageIntent:`Exploring Prismic's features for future projects.`,usageIntentIndex:0}})}function qn(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}const Jn=T({repositories:x(T({domain:O(),name:E(O()),role:O()}))});async function Yn(){let{values:{help:t,json:n}}=e({args:process.argv.slice(4),options:{help:{type:`boolean`,short:`h`},json:{type:`boolean`}}});if(t){console.info(`List all Prismic repositories.
1138
+ Use \`prismic repo <command> --help\` for more information about a command.`);return}if(!a){console.error(`Missing required argument: domain`),process.exitCode=1;return}if(!Gn.test(a)){console.error(`Invalid domain format.`),console.error(`Must be at least 4 characters, start and end with alphanumeric, and contain only alphanumerics and hyphens.`),process.exitCode=1;return}if(!await P()){Jn();return}let o=await U();if(!r&&o.ok&&!i){console.error(`This project already has a repository: ${o.config.repositoryName}`),console.error(`Use --replace to replace it, or --no-config to skip config creation.`),process.exitCode=1;return}let s=await qn(a,n);if(!s.ok){s.error instanceof G?Jn():(console.error(`Failed to create repository: ${B(s.error)}`),process.exitCode=1);return}if(!r)if(o.ok){let e=await dt({repositoryName:a});e.ok?console.info(`Updated prismic.config.json`):console.warn(`Could not update prismic.config.json: `+e.error.message)}else{let e=await lt({repositoryName:a});e.ok?console.info(`Created prismic.config.json`):console.warn(`Could not create prismic.config.json: `+e.error.message)}console.info(`Repository created: ${a}`),console.info(`URL: ${await I(a)}`)}async function qn(e,t=e){return await W(new URL(`/app/dashboard/repositories`,await F()),{method:`POST`,body:{domain:e,name:t,framework:`next`,plan:`personal`,usageIntent:`Exploring Prismic's features for future projects.`,usageIntentIndex:0}})}function Jn(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}const Yn=E({repositories:S(E({domain:k(),name:D(k()),role:k()}))});async function Xn(){let{values:{help:t,json:n}}=e({args:process.argv.slice(4),options:{help:{type:`boolean`,short:`h`},json:{type:`boolean`}}});if(t){console.info(`List all Prismic repositories.
1139
1139
 
1140
1140
  USAGE
1141
1141
  prismic repo list [flags]
@@ -1145,7 +1145,7 @@ FLAGS
1145
1145
  -h, --help Show help for command
1146
1146
 
1147
1147
  LEARN MORE
1148
- Use \`prismic repo <command> --help\` for more information about a command.`);return}if(!await M()){Zn();return}let r=await Xn();if(!r.ok){r.error instanceof K?Zn():(console.error(`Failed to fetch repositories: ${z(r.value)}`),process.exitCode=1);return}let i=r.value.repositories;if(n){let e=await Promise.all(i.map(async e=>({domain:e.domain,name:e.name||null,role:e.role,url:(await F(e.domain)).toString()})));console.info(z(e));return}if(i.length===0){console.info(`No repositories found.`);return}for(let e of i){let t=e.name||`(no name)`;console.info(`${e.domain} ${t} ${e.role}`)}}async function Xn(){return await G(new URL(`profile`,await fe()),{schema:Jn})}function Zn(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function Qn(){let{values:{help:t,repo:n=await U()},positionals:[r]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Set the display name of a Prismic repository.
1148
+ Use \`prismic repo <command> --help\` for more information about a command.`);return}if(!await P()){Qn();return}let r=await Zn();if(!r.ok){r.error instanceof G?Qn():(console.error(`Failed to fetch repositories: ${B(r.value)}`),process.exitCode=1);return}let i=r.value.repositories;if(n){let e=await Promise.all(i.map(async e=>({domain:e.domain,name:e.name||null,role:e.role,url:(await I(e.domain)).toString()})));console.info(B(e));return}if(i.length===0){console.info(`No repositories found.`);return}for(let e of i){let t=e.name||`(no name)`;console.info(`${e.domain} ${t} ${e.role}`)}}async function Zn(){return await W(new URL(`profile`,await de()),{schema:Yn})}function Qn(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function $n(){let{values:{help:t,repo:n=await H()},positionals:[r]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Set the display name of a Prismic repository.
1149
1149
 
1150
1150
  By default, this command reads the repository from prismic.config.json at the
1151
1151
  project root.
@@ -1161,7 +1161,7 @@ FLAGS
1161
1161
  -h, --help Show help for command
1162
1162
 
1163
1163
  LEARN MORE
1164
- Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <name>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await M()){er();return}let i=await $n(n,r);if(!i.ok){i.error instanceof K?er():b(i.error)?(console.error(`Failed to set repository name: Invalid response: ${z(i.error.issues)}`),process.exitCode=1):(console.error(`Failed to set repository name: ${z(i.value)}`),process.exitCode=1);return}console.info(`Repository name set to: ${i.value.repository.name}`)}async function $n(e,t){let n=await F(e),r=new URL(`app/settings/repository`,n),i=new FormData;return i.set(`displayname`,t),await G(r,{method:`POST`,body:i,schema:T({repository:T({name:O()})})})}function er(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}const tr=T({repositories:x(T({domain:O(),name:E(O())}))});async function nr(){let{values:{help:t,repo:n=await U(),web:r}}=e({args:process.argv.slice(4),options:{web:{type:`boolean`,short:`w`},repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}}});if(t){console.info(`View a Prismic repository.
1164
+ Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <name>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await P()){tr();return}let i=await er(n,r);if(!i.ok){i.error instanceof G?tr():b(i.error)?(console.error(`Failed to set repository name: Invalid response: ${B(i.error.issues)}`),process.exitCode=1):(console.error(`Failed to set repository name: ${B(i.value)}`),process.exitCode=1);return}console.info(`Repository name set to: ${i.value.repository.name}`)}async function er(e,t){let n=await I(e),r=new URL(`app/settings/repository`,n),i=new FormData;return i.set(`displayname`,t),await W(r,{method:`POST`,body:i,schema:E({repository:E({name:k()})})})}function tr(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}const nr=E({repositories:S(E({domain:k(),name:D(k())}))});async function rr(){let{values:{help:t,repo:n=await H(),web:r}}=e({args:process.argv.slice(4),options:{web:{type:`boolean`,short:`w`},repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}}});if(t){console.info(`View a Prismic repository.
1165
1165
 
1166
1166
  By default, this command reads the repository from prismic.config.json at the
1167
1167
  project root.
@@ -1175,7 +1175,7 @@ FLAGS
1175
1175
  -h, --help Show help for command
1176
1176
 
1177
1177
  LEARN MORE
1178
- Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}let i=await F(n);if(r){ir(i.toString()),console.info(`Opening ${i}`);return}if(!await M()){ar();return}let a=await rr();if(!a.ok){a.error instanceof K?ar():(console.error(`Failed to fetch repository info: ${z(a.value)}`),process.exitCode=1);return}let o=a.value.repositories.find(e=>e.domain===n);if(!o){console.error(`Repository not found: ${n}`),process.exitCode=1;return}let s=o.name||`(no name)`;console.info(`Name: ${s}`),console.info(`URL: ${i}`)}async function rr(){return await G(new URL(`profile`,await fe()),{schema:tr})}function ir(e){u(`${process.platform===`darwin`?`open`:process.platform===`win32`?`start`:`xdg-open`} "${e}"`)}function ar(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function or(){let{positionals:[t]}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`create`:await Gn();break;case`list`:await Yn();break;case`view`:await nr();break;case`set-name`:await Qn();break;default:t&&(console.error(`Unknown repo subcommand: ${t}\n`),process.exitCode=1),console.info(`Manage Prismic repositories.
1178
+ Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}let i=await I(n);if(r){ar(i.toString()),console.info(`Opening ${i}`);return}if(!await P()){or();return}let a=await ir();if(!a.ok){a.error instanceof G?or():(console.error(`Failed to fetch repository info: ${B(a.value)}`),process.exitCode=1);return}let o=a.value.repositories.find(e=>e.domain===n);if(!o){console.error(`Repository not found: ${n}`),process.exitCode=1;return}let s=o.name||`(no name)`;console.info(`Name: ${s}`),console.info(`URL: ${i}`)}async function ir(){return await W(new URL(`profile`,await de()),{schema:nr})}function ar(e){u(`${process.platform===`darwin`?`open`:process.platform===`win32`?`start`:`xdg-open`} "${e}"`)}function or(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function sr(){let{positionals:[t]}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`create`:await Kn();break;case`list`:await Xn();break;case`view`:await rr();break;case`set-name`:await $n();break;default:t&&(console.error(`Unknown repo subcommand: ${t}\n`),process.exitCode=1),console.info(`Manage Prismic repositories.
1179
1179
 
1180
1180
  USAGE
1181
1181
  prismic repo <command> [flags]
@@ -1190,7 +1190,7 @@ FLAGS
1190
1190
  -h, --help Show help for command
1191
1191
 
1192
1192
  LEARN MORE
1193
- Use \`prismic repo <command> --help\` for more information about a command.`)}}async function sr(){let{values:{help:t,variation:n,label:r,default:i,"true-label":a,"false-label":o},positionals:[c,l]}=e({args:process.argv.slice(5),options:{variation:{type:`string`,short:`v`},label:{type:`string`,short:`l`},default:{type:`boolean`},"true-label":{type:`string`},"false-label":{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a boolean (toggle) field to an existing slice.
1193
+ Use \`prismic repo <command> --help\` for more information about a command.`)}}async function cr(){let{values:{help:t,variation:n,label:r,default:i,"true-label":a,"false-label":o},positionals:[c,l]}=e({args:process.argv.slice(5),options:{variation:{type:`string`,short:`v`},label:{type:`string`,short:`l`},default:{type:`boolean`},"true-label":{type:`string`},"false-label":{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a boolean (toggle) field to an existing slice.
1194
1194
 
1195
1195
  USAGE
1196
1196
  prismic slice add-field boolean <slice-id> <field-id> [flags]
@@ -1212,7 +1212,7 @@ EXAMPLES
1212
1212
  prismic slice add-field boolean hero show_overlay --default
1213
1213
  prismic slice add-field boolean product available --true-label "In Stock" --false-label "Out of Stock"`);return}if(!c){console.error(`Missing required argument: slice-id
1214
1214
  `),console.error(`Usage: prismic slice add-field boolean <slice-id> <field-id>`),process.exitCode=1;return}if(!l){console.error(`Missing required argument: field-id
1215
- `),console.error(`Usage: prismic slice add-field boolean <slice-id> <field-id>`),process.exitCode=1;return}let u=await B(c);if(!u.ok){console.error(u.error),process.exitCode=1;return}let{model:d,modelPath:f}=u;if(d.variations.length===0){console.error(`Slice "${c}" has no variations.\n`),console.error(`Add a variation first before adding fields.`),process.exitCode=1;return}let p=n?d.variations.find(e=>e.id===n):d.variations[0];if(!p){console.error(`Variation "${n}" not found in slice "${c}"\n`),console.error(`Available variations: ${d.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}p.primary||={};for(let e of d.variations)if(e.primary?.[l]){console.error(`Field "${l}" already exists in variation "${e.id}"`),process.exitCode=1;return}let m={type:`Boolean`,config:{...r&&{label:r},...i&&{default_value:!0},...a&&{placeholder_true:a},...o&&{placeholder_false:o}}};p.primary[l]=m;try{await s(f,z(d))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}console.info(`Added field "${l}" (Boolean) to "${p.id}" variation in ${c}`)}async function cr(){let{values:{help:t,variation:n,label:r,placeholder:i},positionals:[a,o]}=e({args:process.argv.slice(5),options:{variation:{type:`string`,short:`v`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a color picker field to an existing slice.
1215
+ `),console.error(`Usage: prismic slice add-field boolean <slice-id> <field-id>`),process.exitCode=1;return}let u=await V(c);if(!u.ok){console.error(u.error),process.exitCode=1;return}let{model:d,modelPath:f}=u;if(d.variations.length===0){console.error(`Slice "${c}" has no variations.\n`),console.error(`Add a variation first before adding fields.`),process.exitCode=1;return}let p=n?d.variations.find(e=>e.id===n):d.variations[0];if(!p){console.error(`Variation "${n}" not found in slice "${c}"\n`),console.error(`Available variations: ${d.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}p.primary||={};for(let e of d.variations)if(e.primary?.[l]){console.error(`Field "${l}" already exists in variation "${e.id}"`),process.exitCode=1;return}let m={type:`Boolean`,config:{...r&&{label:r},...i&&{default_value:!0},...a&&{placeholder_true:a},...o&&{placeholder_false:o}}};p.primary[l]=m;try{await s(f,B(d))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}console.info(`Added field "${l}" (Boolean) to "${p.id}" variation in ${c}`)}async function lr(){let{values:{help:t,variation:n,label:r,placeholder:i},positionals:[a,o]}=e({args:process.argv.slice(5),options:{variation:{type:`string`,short:`v`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a color picker field to an existing slice.
1216
1216
 
1217
1217
  USAGE
1218
1218
  prismic slice add-field color <slice-id> <field-id> [flags]
@@ -1232,7 +1232,7 @@ EXAMPLES
1232
1232
  prismic slice add-field color hero accent --label "Accent Color"
1233
1233
  prismic slice add-field color banner theme_color --variation "dark"`);return}if(!a){console.error(`Missing required argument: slice-id
1234
1234
  `),console.error(`Usage: prismic slice add-field color <slice-id> <field-id>`),process.exitCode=1;return}if(!o){console.error(`Missing required argument: field-id
1235
- `),console.error(`Usage: prismic slice add-field color <slice-id> <field-id>`),process.exitCode=1;return}let c=await B(a);if(!c.ok){console.error(c.error),process.exitCode=1;return}let{model:l,modelPath:u}=c;if(l.variations.length===0){console.error(`Slice "${a}" has no variations.\n`),console.error(`Add a variation first before adding fields.`),process.exitCode=1;return}let d=n?l.variations.find(e=>e.id===n):l.variations[0];if(!d){console.error(`Variation "${n}" not found in slice "${a}"\n`),console.error(`Available variations: ${l.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}d.primary||={};for(let e of l.variations)if(e.primary?.[o]){console.error(`Field "${o}" already exists in variation "${e.id}"`),process.exitCode=1;return}let f={type:`Color`,config:{...r&&{label:r},...i&&{placeholder:i}}};d.primary[o]=f;try{await s(u,z(l))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}console.info(`Added field "${o}" (Color) to "${d.id}" variation in ${a}`)}async function lr(){let{values:{help:t,variation:n,label:r,placeholder:i},positionals:[a,o]}=e({args:process.argv.slice(5),options:{variation:{type:`string`,short:`v`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a date picker field to an existing slice.
1235
+ `),console.error(`Usage: prismic slice add-field color <slice-id> <field-id>`),process.exitCode=1;return}let c=await V(a);if(!c.ok){console.error(c.error),process.exitCode=1;return}let{model:l,modelPath:u}=c;if(l.variations.length===0){console.error(`Slice "${a}" has no variations.\n`),console.error(`Add a variation first before adding fields.`),process.exitCode=1;return}let d=n?l.variations.find(e=>e.id===n):l.variations[0];if(!d){console.error(`Variation "${n}" not found in slice "${a}"\n`),console.error(`Available variations: ${l.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}d.primary||={};for(let e of l.variations)if(e.primary?.[o]){console.error(`Field "${o}" already exists in variation "${e.id}"`),process.exitCode=1;return}let f={type:`Color`,config:{...r&&{label:r},...i&&{placeholder:i}}};d.primary[o]=f;try{await s(u,B(l))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}console.info(`Added field "${o}" (Color) to "${d.id}" variation in ${a}`)}async function ur(){let{values:{help:t,variation:n,label:r,placeholder:i},positionals:[a,o]}=e({args:process.argv.slice(5),options:{variation:{type:`string`,short:`v`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a date picker field to an existing slice.
1236
1236
 
1237
1237
  USAGE
1238
1238
  prismic slice add-field date <slice-id> <field-id> [flags]
@@ -1252,7 +1252,7 @@ EXAMPLES
1252
1252
  prismic slice add-field date event start_date --label "Start Date"
1253
1253
  prismic slice add-field date promo end_date --variation "countdown"`);return}if(!a){console.error(`Missing required argument: slice-id
1254
1254
  `),console.error(`Usage: prismic slice add-field date <slice-id> <field-id>`),process.exitCode=1;return}if(!o){console.error(`Missing required argument: field-id
1255
- `),console.error(`Usage: prismic slice add-field date <slice-id> <field-id>`),process.exitCode=1;return}let c=await B(a);if(!c.ok){console.error(c.error),process.exitCode=1;return}let{model:l,modelPath:u}=c;if(l.variations.length===0){console.error(`Slice "${a}" has no variations.\n`),console.error(`Add a variation first before adding fields.`),process.exitCode=1;return}let d=n?l.variations.find(e=>e.id===n):l.variations[0];if(!d){console.error(`Variation "${n}" not found in slice "${a}"\n`),console.error(`Available variations: ${l.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}d.primary||={};for(let e of l.variations)if(e.primary?.[o]){console.error(`Field "${o}" already exists in variation "${e.id}"`),process.exitCode=1;return}let f={type:`Date`,config:{...r&&{label:r},...i&&{placeholder:i}}};d.primary[o]=f;try{await s(u,z(l))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}console.info(`Added field "${o}" (Date) to "${d.id}" variation in ${a}`)}async function ur(){let{values:{help:t,variation:n,label:r,placeholder:i},positionals:[a,o]}=e({args:process.argv.slice(5),options:{variation:{type:`string`,short:`v`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add an embed (oEmbed) field to an existing slice.
1255
+ `),console.error(`Usage: prismic slice add-field date <slice-id> <field-id>`),process.exitCode=1;return}let c=await V(a);if(!c.ok){console.error(c.error),process.exitCode=1;return}let{model:l,modelPath:u}=c;if(l.variations.length===0){console.error(`Slice "${a}" has no variations.\n`),console.error(`Add a variation first before adding fields.`),process.exitCode=1;return}let d=n?l.variations.find(e=>e.id===n):l.variations[0];if(!d){console.error(`Variation "${n}" not found in slice "${a}"\n`),console.error(`Available variations: ${l.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}d.primary||={};for(let e of l.variations)if(e.primary?.[o]){console.error(`Field "${o}" already exists in variation "${e.id}"`),process.exitCode=1;return}let f={type:`Date`,config:{...r&&{label:r},...i&&{placeholder:i}}};d.primary[o]=f;try{await s(u,B(l))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}console.info(`Added field "${o}" (Date) to "${d.id}" variation in ${a}`)}async function dr(){let{values:{help:t,variation:n,label:r,placeholder:i},positionals:[a,o]}=e({args:process.argv.slice(5),options:{variation:{type:`string`,short:`v`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add an embed (oEmbed) field to an existing slice.
1256
1256
 
1257
1257
  USAGE
1258
1258
  prismic slice add-field embed <slice-id> <field-id> [flags]
@@ -1272,7 +1272,7 @@ EXAMPLES
1272
1272
  prismic slice add-field embed gallery media --label "Media Embed"
1273
1273
  prismic slice add-field embed social tweet --variation "twitter"`);return}if(!a){console.error(`Missing required argument: slice-id
1274
1274
  `),console.error(`Usage: prismic slice add-field embed <slice-id> <field-id>`),process.exitCode=1;return}if(!o){console.error(`Missing required argument: field-id
1275
- `),console.error(`Usage: prismic slice add-field embed <slice-id> <field-id>`),process.exitCode=1;return}let c=await B(a);if(!c.ok){console.error(c.error),process.exitCode=1;return}let{model:l,modelPath:u}=c;if(l.variations.length===0){console.error(`Slice "${a}" has no variations.\n`),console.error(`Add a variation first before adding fields.`),process.exitCode=1;return}let d=n?l.variations.find(e=>e.id===n):l.variations[0];if(!d){console.error(`Variation "${n}" not found in slice "${a}"\n`),console.error(`Available variations: ${l.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}d.primary||={};for(let e of l.variations)if(e.primary?.[o]){console.error(`Field "${o}" already exists in variation "${e.id}"`),process.exitCode=1;return}let f={type:`Embed`,config:{...r&&{label:r},...i&&{placeholder:i}}};d.primary[o]=f;try{await s(u,z(l))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}console.info(`Added field "${o}" (Embed) to "${d.id}" variation in ${a}`)}async function dr(){let{values:{help:t,variation:n,label:r},positionals:[i,a]}=e({args:process.argv.slice(5),options:{variation:{type:`string`,short:`v`},label:{type:`string`,short:`l`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a geographic coordinates field to an existing slice.
1275
+ `),console.error(`Usage: prismic slice add-field embed <slice-id> <field-id>`),process.exitCode=1;return}let c=await V(a);if(!c.ok){console.error(c.error),process.exitCode=1;return}let{model:l,modelPath:u}=c;if(l.variations.length===0){console.error(`Slice "${a}" has no variations.\n`),console.error(`Add a variation first before adding fields.`),process.exitCode=1;return}let d=n?l.variations.find(e=>e.id===n):l.variations[0];if(!d){console.error(`Variation "${n}" not found in slice "${a}"\n`),console.error(`Available variations: ${l.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}d.primary||={};for(let e of l.variations)if(e.primary?.[o]){console.error(`Field "${o}" already exists in variation "${e.id}"`),process.exitCode=1;return}let f={type:`Embed`,config:{...r&&{label:r},...i&&{placeholder:i}}};d.primary[o]=f;try{await s(u,B(l))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}console.info(`Added field "${o}" (Embed) to "${d.id}" variation in ${a}`)}async function fr(){let{values:{help:t,variation:n,label:r},positionals:[i,a]}=e({args:process.argv.slice(5),options:{variation:{type:`string`,short:`v`},label:{type:`string`,short:`l`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a geographic coordinates field to an existing slice.
1276
1276
 
1277
1277
  USAGE
1278
1278
  prismic slice add-field geo-point <slice-id> <field-id> [flags]
@@ -1291,7 +1291,7 @@ EXAMPLES
1291
1291
  prismic slice add-field geo-point store coordinates --label "Store Location"
1292
1292
  prismic slice add-field geo-point map marker --variation "interactive"`);return}if(!i){console.error(`Missing required argument: slice-id
1293
1293
  `),console.error(`Usage: prismic slice add-field geo-point <slice-id> <field-id>`),process.exitCode=1;return}if(!a){console.error(`Missing required argument: field-id
1294
- `),console.error(`Usage: prismic slice add-field geo-point <slice-id> <field-id>`),process.exitCode=1;return}let o=await B(i);if(!o.ok){console.error(o.error),process.exitCode=1;return}let{model:c,modelPath:l}=o;if(c.variations.length===0){console.error(`Slice "${i}" has no variations.\n`),console.error(`Add a variation first before adding fields.`),process.exitCode=1;return}let u=n?c.variations.find(e=>e.id===n):c.variations[0];if(!u){console.error(`Variation "${n}" not found in slice "${i}"\n`),console.error(`Available variations: ${c.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}u.primary||={};for(let e of c.variations)if(e.primary?.[a]){console.error(`Field "${a}" already exists in variation "${e.id}"`),process.exitCode=1;return}let d={type:`GeoPoint`,config:{...r&&{label:r}}};u.primary[a]=d;try{await s(l,z(c))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}console.info(`Added field "${a}" (GeoPoint) to "${u.id}" variation in ${i}`)}async function fr(){let{values:{help:t,variation:n,label:r},positionals:[i,a]}=e({args:process.argv.slice(5),options:{variation:{type:`string`,short:`v`},label:{type:`string`,short:`l`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add an image field to an existing slice.
1294
+ `),console.error(`Usage: prismic slice add-field geo-point <slice-id> <field-id>`),process.exitCode=1;return}let o=await V(i);if(!o.ok){console.error(o.error),process.exitCode=1;return}let{model:c,modelPath:l}=o;if(c.variations.length===0){console.error(`Slice "${i}" has no variations.\n`),console.error(`Add a variation first before adding fields.`),process.exitCode=1;return}let u=n?c.variations.find(e=>e.id===n):c.variations[0];if(!u){console.error(`Variation "${n}" not found in slice "${i}"\n`),console.error(`Available variations: ${c.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}u.primary||={};for(let e of c.variations)if(e.primary?.[a]){console.error(`Field "${a}" already exists in variation "${e.id}"`),process.exitCode=1;return}let d={type:`GeoPoint`,config:{...r&&{label:r}}};u.primary[a]=d;try{await s(l,B(c))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}console.info(`Added field "${a}" (GeoPoint) to "${u.id}" variation in ${i}`)}async function pr(){let{values:{help:t,variation:n,label:r},positionals:[i,a]}=e({args:process.argv.slice(5),options:{variation:{type:`string`,short:`v`},label:{type:`string`,short:`l`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add an image field to an existing slice.
1295
1295
 
1296
1296
  USAGE
1297
1297
  prismic slice add-field image <slice-id> <field-id> [flags]
@@ -1310,7 +1310,7 @@ EXAMPLES
1310
1310
  prismic slice add-field image hero banner --label "Hero Banner"
1311
1311
  prismic slice add-field image gallery thumbnail --variation "grid"`);return}if(!i){console.error(`Missing required argument: slice-id
1312
1312
  `),console.error(`Usage: prismic slice add-field image <slice-id> <field-id>`),process.exitCode=1;return}if(!a){console.error(`Missing required argument: field-id
1313
- `),console.error(`Usage: prismic slice add-field image <slice-id> <field-id>`),process.exitCode=1;return}let o=await B(i);if(!o.ok){console.error(o.error),process.exitCode=1;return}let{model:c,modelPath:l}=o;if(c.variations.length===0){console.error(`Slice "${i}" has no variations.\n`),console.error(`Add a variation first before adding fields.`),process.exitCode=1;return}let u=n?c.variations.find(e=>e.id===n):c.variations[0];if(!u){console.error(`Variation "${n}" not found in slice "${i}"\n`),console.error(`Available variations: ${c.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}u.primary||={};for(let e of c.variations)if(e.primary?.[a]){console.error(`Field "${a}" already exists in variation "${e.id}"`),process.exitCode=1;return}let d={type:`Image`,config:{...r&&{label:r}}};u.primary[a]=d;try{await s(l,z(c))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}console.info(`Added field "${a}" (Image) to "${u.id}" variation in ${i}`)}async function pr(){let{values:{help:t,variation:n,label:r,placeholder:i},positionals:[a,o]}=e({args:process.argv.slice(5),options:{variation:{type:`string`,short:`v`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a key-text (single-line text) field to an existing slice.
1313
+ `),console.error(`Usage: prismic slice add-field image <slice-id> <field-id>`),process.exitCode=1;return}let o=await V(i);if(!o.ok){console.error(o.error),process.exitCode=1;return}let{model:c,modelPath:l}=o;if(c.variations.length===0){console.error(`Slice "${i}" has no variations.\n`),console.error(`Add a variation first before adding fields.`),process.exitCode=1;return}let u=n?c.variations.find(e=>e.id===n):c.variations[0];if(!u){console.error(`Variation "${n}" not found in slice "${i}"\n`),console.error(`Available variations: ${c.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}u.primary||={};for(let e of c.variations)if(e.primary?.[a]){console.error(`Field "${a}" already exists in variation "${e.id}"`),process.exitCode=1;return}let d={type:`Image`,config:{...r&&{label:r}}};u.primary[a]=d;try{await s(l,B(c))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}console.info(`Added field "${a}" (Image) to "${u.id}" variation in ${i}`)}async function mr(){let{values:{help:t,variation:n,label:r,placeholder:i},positionals:[a,o]}=e({args:process.argv.slice(5),options:{variation:{type:`string`,short:`v`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a key-text (single-line text) field to an existing slice.
1314
1314
 
1315
1315
  USAGE
1316
1316
  prismic slice add-field key-text <slice-id> <field-id> [flags]
@@ -1330,7 +1330,7 @@ EXAMPLES
1330
1330
  prismic slice add-field key-text hero heading --label "Heading"
1331
1331
  prismic slice add-field key-text cta button_text --placeholder "Enter button text"`);return}if(!a){console.error(`Missing required argument: slice-id
1332
1332
  `),console.error(`Usage: prismic slice add-field key-text <slice-id> <field-id>`),process.exitCode=1;return}if(!o){console.error(`Missing required argument: field-id
1333
- `),console.error(`Usage: prismic slice add-field key-text <slice-id> <field-id>`),process.exitCode=1;return}let c=await B(a);if(!c.ok){console.error(c.error),process.exitCode=1;return}let{model:l,modelPath:u}=c;if(l.variations.length===0){console.error(`Slice "${a}" has no variations.\n`),console.error(`Add a variation first before adding fields.`),process.exitCode=1;return}let d=n?l.variations.find(e=>e.id===n):l.variations[0];if(!d){console.error(`Variation "${n}" not found in slice "${a}"\n`),console.error(`Available variations: ${l.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}d.primary||={};for(let e of l.variations)if(e.primary?.[o]){console.error(`Field "${o}" already exists in variation "${e.id}"`),process.exitCode=1;return}let f={type:`Text`,config:{...r&&{label:r},...i&&{placeholder:i}}};d.primary[o]=f;try{await s(u,z(l))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}console.info(`Added field "${o}" (Text) to "${d.id}" variation in ${a}`)}async function mr(){let{values:{help:t,variation:n,label:r,placeholder:i,"allow-text":a,"allow-target-blank":o,repeatable:c},positionals:[l,u]}=e({args:process.argv.slice(5),options:{variation:{type:`string`,short:`v`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},"allow-text":{type:`boolean`},"allow-target-blank":{type:`boolean`},repeatable:{type:`boolean`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a link field to an existing slice.
1333
+ `),console.error(`Usage: prismic slice add-field key-text <slice-id> <field-id>`),process.exitCode=1;return}let c=await V(a);if(!c.ok){console.error(c.error),process.exitCode=1;return}let{model:l,modelPath:u}=c;if(l.variations.length===0){console.error(`Slice "${a}" has no variations.\n`),console.error(`Add a variation first before adding fields.`),process.exitCode=1;return}let d=n?l.variations.find(e=>e.id===n):l.variations[0];if(!d){console.error(`Variation "${n}" not found in slice "${a}"\n`),console.error(`Available variations: ${l.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}d.primary||={};for(let e of l.variations)if(e.primary?.[o]){console.error(`Field "${o}" already exists in variation "${e.id}"`),process.exitCode=1;return}let f={type:`Text`,config:{...r&&{label:r},...i&&{placeholder:i}}};d.primary[o]=f;try{await s(u,B(l))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}console.info(`Added field "${o}" (Text) to "${d.id}" variation in ${a}`)}async function hr(){let{values:{help:t,variation:n,label:r,placeholder:i,"allow-text":a,"allow-target-blank":o,repeatable:c},positionals:[l,u]}=e({args:process.argv.slice(5),options:{variation:{type:`string`,short:`v`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},"allow-text":{type:`boolean`},"allow-target-blank":{type:`boolean`},repeatable:{type:`boolean`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a link field to an existing slice.
1334
1334
 
1335
1335
  USAGE
1336
1336
  prismic slice add-field link <slice-id> <field-id> [flags]
@@ -1354,7 +1354,7 @@ EXAMPLES
1354
1354
  prismic slice add-field link navigation links --repeatable
1355
1355
  prismic slice add-field link hero cta --allow-text --allow-target-blank`);return}if(!l){console.error(`Missing required argument: slice-id
1356
1356
  `),console.error(`Usage: prismic slice add-field link <slice-id> <field-id>`),process.exitCode=1;return}if(!u){console.error(`Missing required argument: field-id
1357
- `),console.error(`Usage: prismic slice add-field link <slice-id> <field-id>`),process.exitCode=1;return}let d=await B(l);if(!d.ok){console.error(d.error),process.exitCode=1;return}let{model:f,modelPath:p}=d;if(f.variations.length===0){console.error(`Slice "${l}" has no variations.\n`),console.error(`Add a variation first before adding fields.`),process.exitCode=1;return}let m=n?f.variations.find(e=>e.id===n):f.variations[0];if(!m){console.error(`Variation "${n}" not found in slice "${l}"\n`),console.error(`Available variations: ${f.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}m.primary||={};for(let e of f.variations)if(e.primary?.[u]){console.error(`Field "${u}" already exists in variation "${e.id}"`),process.exitCode=1;return}let h={type:`Link`,config:{...r&&{label:r},...i&&{placeholder:i},...a&&{allowText:!0},...o&&{allowTargetBlank:!0},...c&&{repeat:!0}}};m.primary[u]=h;try{await s(p,z(f))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}console.info(`Added field "${u}" (Link) to "${m.id}" variation in ${l}`)}async function hr(){let{values:{help:t,variation:n,label:r,placeholder:i},positionals:[a,o]}=e({args:process.argv.slice(5),options:{variation:{type:`string`,short:`v`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a number field to an existing slice.
1357
+ `),console.error(`Usage: prismic slice add-field link <slice-id> <field-id>`),process.exitCode=1;return}let d=await V(l);if(!d.ok){console.error(d.error),process.exitCode=1;return}let{model:f,modelPath:p}=d;if(f.variations.length===0){console.error(`Slice "${l}" has no variations.\n`),console.error(`Add a variation first before adding fields.`),process.exitCode=1;return}let m=n?f.variations.find(e=>e.id===n):f.variations[0];if(!m){console.error(`Variation "${n}" not found in slice "${l}"\n`),console.error(`Available variations: ${f.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}m.primary||={};for(let e of f.variations)if(e.primary?.[u]){console.error(`Field "${u}" already exists in variation "${e.id}"`),process.exitCode=1;return}let h={type:`Link`,config:{...r&&{label:r},...i&&{placeholder:i},...a&&{allowText:!0},...o&&{allowTargetBlank:!0},...c&&{repeat:!0}}};m.primary[u]=h;try{await s(p,B(f))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}console.info(`Added field "${u}" (Link) to "${m.id}" variation in ${l}`)}async function gr(){let{values:{help:t,variation:n,label:r,placeholder:i},positionals:[a,o]}=e({args:process.argv.slice(5),options:{variation:{type:`string`,short:`v`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a number field to an existing slice.
1358
1358
 
1359
1359
  USAGE
1360
1360
  prismic slice add-field number <slice-id> <field-id> [flags]
@@ -1374,7 +1374,7 @@ EXAMPLES
1374
1374
  prismic slice add-field number product quantity --label "Quantity"
1375
1375
  prismic slice add-field number stats count --variation "detailed"`);return}if(!a){console.error(`Missing required argument: slice-id
1376
1376
  `),console.error(`Usage: prismic slice add-field number <slice-id> <field-id>`),process.exitCode=1;return}if(!o){console.error(`Missing required argument: field-id
1377
- `),console.error(`Usage: prismic slice add-field number <slice-id> <field-id>`),process.exitCode=1;return}let c=await B(a);if(!c.ok){console.error(c.error),process.exitCode=1;return}let{model:l,modelPath:u}=c;if(l.variations.length===0){console.error(`Slice "${a}" has no variations.\n`),console.error(`Add a variation first before adding fields.`),process.exitCode=1;return}let d=n?l.variations.find(e=>e.id===n):l.variations[0];if(!d){console.error(`Variation "${n}" not found in slice "${a}"\n`),console.error(`Available variations: ${l.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}d.primary||={};for(let e of l.variations)if(e.primary?.[o]){console.error(`Field "${o}" already exists in variation "${e.id}"`),process.exitCode=1;return}let f={type:`Number`,config:{...r&&{label:r},...i&&{placeholder:i}}};d.primary[o]=f;try{await s(u,z(l))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}console.info(`Added field "${o}" (Number) to "${d.id}" variation in ${a}`)}async function gr(){let{values:{help:t,variation:n,label:r,placeholder:i,single:a,multi:o,"allow-target-blank":c},positionals:[l,u]}=e({args:process.argv.slice(5),options:{variation:{type:`string`,short:`v`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},single:{type:`string`},multi:{type:`string`},"allow-target-blank":{type:`boolean`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a rich text field to an existing slice.
1377
+ `),console.error(`Usage: prismic slice add-field number <slice-id> <field-id>`),process.exitCode=1;return}let c=await V(a);if(!c.ok){console.error(c.error),process.exitCode=1;return}let{model:l,modelPath:u}=c;if(l.variations.length===0){console.error(`Slice "${a}" has no variations.\n`),console.error(`Add a variation first before adding fields.`),process.exitCode=1;return}let d=n?l.variations.find(e=>e.id===n):l.variations[0];if(!d){console.error(`Variation "${n}" not found in slice "${a}"\n`),console.error(`Available variations: ${l.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}d.primary||={};for(let e of l.variations)if(e.primary?.[o]){console.error(`Field "${o}" already exists in variation "${e.id}"`),process.exitCode=1;return}let f={type:`Number`,config:{...r&&{label:r},...i&&{placeholder:i}}};d.primary[o]=f;try{await s(u,B(l))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}console.info(`Added field "${o}" (Number) to "${d.id}" variation in ${a}`)}async function _r(){let{values:{help:t,variation:n,label:r,placeholder:i,single:a,multi:o,"allow-target-blank":c},positionals:[l,u]}=e({args:process.argv.slice(5),options:{variation:{type:`string`,short:`v`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},single:{type:`string`},multi:{type:`string`},"allow-target-blank":{type:`boolean`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a rich text field to an existing slice.
1378
1378
 
1379
1379
  USAGE
1380
1380
  prismic slice add-field rich-text <slice-id> <field-id> [flags]
@@ -1403,7 +1403,7 @@ EXAMPLES
1403
1403
  prismic slice add-field rich-text hero tagline --single "heading1"
1404
1404
  prismic slice add-field rich-text blog post --multi "paragraph,strong,em,hyperlink" --allow-target-blank`);return}if(!l){console.error(`Missing required argument: slice-id
1405
1405
  `),console.error(`Usage: prismic slice add-field rich-text <slice-id> <field-id>`),process.exitCode=1;return}if(!u){console.error(`Missing required argument: field-id
1406
- `),console.error(`Usage: prismic slice add-field rich-text <slice-id> <field-id>`),process.exitCode=1;return}let d=await B(l);if(!d.ok){console.error(d.error),process.exitCode=1;return}let{model:f,modelPath:p}=d;if(f.variations.length===0){console.error(`Slice "${l}" has no variations.\n`),console.error(`Add a variation first before adding fields.`),process.exitCode=1;return}let m=n?f.variations.find(e=>e.id===n):f.variations[0];if(!m){console.error(`Variation "${n}" not found in slice "${l}"\n`),console.error(`Available variations: ${f.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}m.primary||={};for(let e of f.variations)if(e.primary?.[u]){console.error(`Field "${u}" already exists in variation "${e.id}"`),process.exitCode=1;return}let h={type:`StructuredText`,config:{...r&&{label:r},...i&&{placeholder:i},...a&&{single:a},...o&&{multi:o},...c&&{allowTargetBlank:!0}}};m.primary[u]=h;try{await s(p,z(f))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}console.info(`Added field "${u}" (StructuredText) to "${m.id}" variation in ${l}`)}async function _r(){let{values:{help:t,variation:n,label:r,placeholder:i,option:a,default:o},positionals:[c,l]}=e({args:process.argv.slice(5),options:{variation:{type:`string`,short:`v`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},option:{type:`string`,multiple:!0},default:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a select (dropdown) field to an existing slice.
1406
+ `),console.error(`Usage: prismic slice add-field rich-text <slice-id> <field-id>`),process.exitCode=1;return}let d=await V(l);if(!d.ok){console.error(d.error),process.exitCode=1;return}let{model:f,modelPath:p}=d;if(f.variations.length===0){console.error(`Slice "${l}" has no variations.\n`),console.error(`Add a variation first before adding fields.`),process.exitCode=1;return}let m=n?f.variations.find(e=>e.id===n):f.variations[0];if(!m){console.error(`Variation "${n}" not found in slice "${l}"\n`),console.error(`Available variations: ${f.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}m.primary||={};for(let e of f.variations)if(e.primary?.[u]){console.error(`Field "${u}" already exists in variation "${e.id}"`),process.exitCode=1;return}let h={type:`StructuredText`,config:{...r&&{label:r},...i&&{placeholder:i},...a&&{single:a},...o&&{multi:o},...c&&{allowTargetBlank:!0}}};m.primary[u]=h;try{await s(p,B(f))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}console.info(`Added field "${u}" (StructuredText) to "${m.id}" variation in ${l}`)}async function vr(){let{values:{help:t,variation:n,label:r,placeholder:i,option:a,default:o},positionals:[c,l]}=e({args:process.argv.slice(5),options:{variation:{type:`string`,short:`v`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},option:{type:`string`,multiple:!0},default:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a select (dropdown) field to an existing slice.
1407
1407
 
1408
1408
  USAGE
1409
1409
  prismic slice add-field select <slice-id> <field-id> [flags]
@@ -1425,7 +1425,7 @@ EXAMPLES
1425
1425
  prismic slice add-field select hero style --option "light" --option "dark" --default "light"
1426
1426
  prismic slice add-field select product size --option "small" --option "medium" --option "large" --label "Size"`);return}if(!c){console.error(`Missing required argument: slice-id
1427
1427
  `),console.error(`Usage: prismic slice add-field select <slice-id> <field-id>`),process.exitCode=1;return}if(!l){console.error(`Missing required argument: field-id
1428
- `),console.error(`Usage: prismic slice add-field select <slice-id> <field-id>`),process.exitCode=1;return}let u=await B(c);if(!u.ok){console.error(u.error),process.exitCode=1;return}let{model:d,modelPath:f}=u;if(d.variations.length===0){console.error(`Slice "${c}" has no variations.\n`),console.error(`Add a variation first before adding fields.`),process.exitCode=1;return}let p=n?d.variations.find(e=>e.id===n):d.variations[0];if(!p){console.error(`Variation "${n}" not found in slice "${c}"\n`),console.error(`Available variations: ${d.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}p.primary||={};for(let e of d.variations)if(e.primary?.[l]){console.error(`Field "${l}" already exists in variation "${e.id}"`),process.exitCode=1;return}let m={type:`Select`,config:{...r&&{label:r},...i&&{placeholder:i},...a&&a.length>0&&{options:a},...o&&{default_value:o}}};p.primary[l]=m;try{await s(f,z(d))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}console.info(`Added field "${l}" (Select) to "${p.id}" variation in ${c}`)}async function vr(){let{values:{help:t,variation:n,label:r,placeholder:i},positionals:[a,o]}=e({args:process.argv.slice(5),options:{variation:{type:`string`,short:`v`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a timestamp (date and time) field to an existing slice.
1428
+ `),console.error(`Usage: prismic slice add-field select <slice-id> <field-id>`),process.exitCode=1;return}let u=await V(c);if(!u.ok){console.error(u.error),process.exitCode=1;return}let{model:d,modelPath:f}=u;if(d.variations.length===0){console.error(`Slice "${c}" has no variations.\n`),console.error(`Add a variation first before adding fields.`),process.exitCode=1;return}let p=n?d.variations.find(e=>e.id===n):d.variations[0];if(!p){console.error(`Variation "${n}" not found in slice "${c}"\n`),console.error(`Available variations: ${d.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}p.primary||={};for(let e of d.variations)if(e.primary?.[l]){console.error(`Field "${l}" already exists in variation "${e.id}"`),process.exitCode=1;return}let m={type:`Select`,config:{...r&&{label:r},...i&&{placeholder:i},...a&&a.length>0&&{options:a},...o&&{default_value:o}}};p.primary[l]=m;try{await s(f,B(d))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}console.info(`Added field "${l}" (Select) to "${p.id}" variation in ${c}`)}async function yr(){let{values:{help:t,variation:n,label:r,placeholder:i},positionals:[a,o]}=e({args:process.argv.slice(5),options:{variation:{type:`string`,short:`v`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a timestamp (date and time) field to an existing slice.
1429
1429
 
1430
1430
  USAGE
1431
1431
  prismic slice add-field timestamp <slice-id> <field-id> [flags]
@@ -1445,7 +1445,7 @@ EXAMPLES
1445
1445
  prismic slice add-field timestamp event start_time --label "Event Start"
1446
1446
  prismic slice add-field timestamp schedule meeting_time --variation "detailed"`);return}if(!a){console.error(`Missing required argument: slice-id
1447
1447
  `),console.error(`Usage: prismic slice add-field timestamp <slice-id> <field-id>`),process.exitCode=1;return}if(!o){console.error(`Missing required argument: field-id
1448
- `),console.error(`Usage: prismic slice add-field timestamp <slice-id> <field-id>`),process.exitCode=1;return}let c=await B(a);if(!c.ok){console.error(c.error),process.exitCode=1;return}let{model:l,modelPath:u}=c;if(l.variations.length===0){console.error(`Slice "${a}" has no variations.\n`),console.error(`Add a variation first before adding fields.`),process.exitCode=1;return}let d=n?l.variations.find(e=>e.id===n):l.variations[0];if(!d){console.error(`Variation "${n}" not found in slice "${a}"\n`),console.error(`Available variations: ${l.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}d.primary||={};for(let e of l.variations)if(e.primary?.[o]){console.error(`Field "${o}" already exists in variation "${e.id}"`),process.exitCode=1;return}let f={type:`Timestamp`,config:{...r&&{label:r},...i&&{placeholder:i}}};d.primary[o]=f;try{await s(u,z(l))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}console.info(`Added field "${o}" (Timestamp) to "${d.id}" variation in ${a}`)}async function yr(){let{positionals:[t]}=e({args:process.argv.slice(4),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`boolean`:await sr();break;case`color`:await cr();break;case`date`:await lr();break;case`embed`:await ur();break;case`geo-point`:await dr();break;case`image`:await fr();break;case`key-text`:await pr();break;case`link`:await mr();break;case`number`:await hr();break;case`rich-text`:await gr();break;case`select`:await _r();break;case`timestamp`:await vr();break;default:t&&(console.error(`Unknown field type: ${t}\n`),process.exitCode=1),console.info(`Add a field to an existing slice.
1448
+ `),console.error(`Usage: prismic slice add-field timestamp <slice-id> <field-id>`),process.exitCode=1;return}let c=await V(a);if(!c.ok){console.error(c.error),process.exitCode=1;return}let{model:l,modelPath:u}=c;if(l.variations.length===0){console.error(`Slice "${a}" has no variations.\n`),console.error(`Add a variation first before adding fields.`),process.exitCode=1;return}let d=n?l.variations.find(e=>e.id===n):l.variations[0];if(!d){console.error(`Variation "${n}" not found in slice "${a}"\n`),console.error(`Available variations: ${l.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}d.primary||={};for(let e of l.variations)if(e.primary?.[o]){console.error(`Field "${o}" already exists in variation "${e.id}"`),process.exitCode=1;return}let f={type:`Timestamp`,config:{...r&&{label:r},...i&&{placeholder:i}}};d.primary[o]=f;try{await s(u,B(l))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}console.info(`Added field "${o}" (Timestamp) to "${d.id}" variation in ${a}`)}async function br(){let{positionals:[t]}=e({args:process.argv.slice(4),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`boolean`:await cr();break;case`color`:await lr();break;case`date`:await ur();break;case`embed`:await dr();break;case`geo-point`:await fr();break;case`image`:await pr();break;case`key-text`:await mr();break;case`link`:await hr();break;case`number`:await gr();break;case`rich-text`:await _r();break;case`select`:await vr();break;case`timestamp`:await yr();break;default:t&&(console.error(`Unknown field type: ${t}\n`),process.exitCode=1),console.info(`Add a field to an existing slice.
1449
1449
 
1450
1450
  USAGE
1451
1451
  prismic slice add-field <field-type> <slice-id> <field-id> [flags]
@@ -1474,7 +1474,7 @@ EXAMPLES
1474
1474
  prismic slice add-field key-text my_slice title --label "Title"
1475
1475
  prismic slice add-field link my_slice cta --allow-text
1476
1476
  prismic slice add-field rich-text my_slice body --multi "paragraph,heading2,strong,em"
1477
- prismic slice add-field select my_slice layout --option "full" --option "sidebar"`)}}async function br(){let{values:{help:t,name:n,"copy-from":r},positionals:[i,a]}=e({args:process.argv.slice(4),options:{name:{type:`string`},"copy-from":{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a new variation to a slice.
1477
+ prismic slice add-field select my_slice layout --option "full" --option "sidebar"`)}}async function xr(){let{values:{help:t,name:n,"copy-from":r},positionals:[i,a]}=e({args:process.argv.slice(4),options:{name:{type:`string`},"copy-from":{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a new variation to a slice.
1478
1478
 
1479
1479
  USAGE
1480
1480
  prismic slice add-variation <slice-id> <variation-id> [flags]
@@ -1493,7 +1493,7 @@ EXAMPLES
1493
1493
  prismic slice add-variation MySlice withImage --name "With Image"
1494
1494
  prismic slice add-variation MySlice withImage --copy-from default`);return}if(!i){console.error(`Missing required argument: slice-id
1495
1495
  `),console.error(`Usage: prismic slice add-variation <slice-id> <variation-id>`),process.exitCode=1;return}if(!a){console.error(`Missing required argument: variation-id
1496
- `),console.error(`Usage: prismic slice add-variation <slice-id> <variation-id>`),process.exitCode=1;return}let o=await B(i);if(!o.ok){console.error(o.error),process.exitCode=1;return}let{model:c,modelPath:l}=o;if(c.variations.some(e=>e.id===a)){console.error(`Variation "${a}" already exists in slice "${i}"`),process.exitCode=1;return}let u;if(r){let e=c.variations.find(e=>e.id===r);if(!e){console.error(`Source variation not found: ${r}`),console.error(`Available variations: ${c.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}u={...structuredClone(e),id:a,name:n??H(a)}}else u={id:a,name:n??H(a),description:a,imageUrl:``,docURL:``,version:`initial`,primary:{},items:{}};let d={...c,variations:[...c.variations,u]};try{await s(l,z(d))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}console.info(`Added variation "${a}" to slice "${i}"`)}async function xr(){let{values:{help:t,name:r},positionals:[i]}=e({args:process.argv.slice(4),options:{name:{type:`string`,short:`n`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Create a new slice in a Prismic project.
1496
+ `),console.error(`Usage: prismic slice add-variation <slice-id> <variation-id>`),process.exitCode=1;return}let o=await V(i);if(!o.ok){console.error(o.error),process.exitCode=1;return}let{model:c,modelPath:l}=o;if(c.variations.some(e=>e.id===a)){console.error(`Variation "${a}" already exists in slice "${i}"`),process.exitCode=1;return}let u;if(r){let e=c.variations.find(e=>e.id===r);if(!e){console.error(`Source variation not found: ${r}`),console.error(`Available variations: ${c.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}u={...structuredClone(e),id:a,name:n??Ue(a)}}else u={id:a,name:n??Ue(a),description:a,imageUrl:``,docURL:``,version:`initial`,primary:{},items:{}};let d={...c,variations:[...c.variations,u]};try{await s(l,B(d))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}console.info(`Added variation "${a}" to slice "${i}"`)}async function Sr(){let{values:{help:t,name:r},positionals:[i]}=e({args:process.argv.slice(4),options:{name:{type:`string`,short:`n`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Create a new slice in a Prismic project.
1497
1497
 
1498
1498
  USAGE
1499
1499
  prismic slice create <id> [flags]
@@ -1506,7 +1506,7 @@ FLAGS
1506
1506
  -h, --help Show help for command
1507
1507
 
1508
1508
  LEARN MORE
1509
- Use \`prismic slice <command> --help\` for more information about a command.`);return}if(!i){console.error(`Missing required argument: id`),process.exitCode=1;return}let a={id:i,type:`SharedSlice`,name:r??Tr(i),description:``,variations:[{id:`default`,name:`Default`,description:`Default`,imageUrl:``,docURL:``,version:`initial`,primary:{},items:{}}]},o=await Sr(),c=new URL(Tr(a.name)+`/`,o),l=new URL(`model.json`,c);try{await n(new URL(`.`,l),{recursive:!0}),await s(l,z(a))}catch(e){e instanceof Error?console.error(`Failed to create slice: ${e.message}`):console.error(`Failed to create slice`),process.exitCode=1;return}console.info(`Created slice at ${l.href}`)}async function Sr(){let e=await wr(),t=await L(`package.json`);switch(e){case`next`:if(await R(new URL(`src`,t)))return new URL(`src/slices/`,t);case`nuxt`:if(await R(new URL(`app`,t)))return new URL(`app/slices/`,t);case`sveltekit`:return new URL(`src/slices/`,t)}return new URL(`slices/`,t)}const Cr=T({dependencies:E(D(O(),O()))});async function wr(){let e=await L(`package.json`);if(e)try{let t=await r(e,`utf8`),{dependencies:n={}}=ae(Cr,JSON.parse(t));if(`next`in n)return`next`;if(`nuxt`in n)return`nuxt`;if(`@sveltejs/kit`in n)return`sveltekit`}catch{}}function Tr(e){return e.toLowerCase().replace(/(^|[-_\s]+)(.)?/g,(e,t,n)=>n?.toUpperCase()??``)}async function Er(){let{values:{help:t,json:n}}=e({args:process.argv.slice(4),options:{json:{type:`boolean`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`List all slices in a Prismic project.
1509
+ Use \`prismic slice <command> --help\` for more information about a command.`);return}if(!i){console.error(`Missing required argument: id`),process.exitCode=1;return}let a={id:i,type:`SharedSlice`,name:r??Er(i),description:``,variations:[{id:`default`,name:`Default`,description:`Default`,imageUrl:``,docURL:``,version:`initial`,primary:{},items:{}}]},o=await Cr(),c=new URL(Er(a.name)+`/`,o),l=new URL(`model.json`,c);try{await n(new URL(`.`,l),{recursive:!0}),await s(l,B(a))}catch(e){e instanceof Error?console.error(`Failed to create slice: ${e.message}`):console.error(`Failed to create slice`),process.exitCode=1;return}console.info(`Created slice at ${l.href}`)}async function Cr(){let e=await Tr(),t=await R(`package.json`);switch(e){case`next`:if(await z(new URL(`src`,t)))return new URL(`src/slices/`,t);case`nuxt`:if(await z(new URL(`app`,t)))return new URL(`app/slices/`,t);case`sveltekit`:return new URL(`src/slices/`,t)}return new URL(`slices/`,t)}const wr=E({dependencies:D(O(k(),k()))});async function Tr(){let e=await R(`package.json`);if(e)try{let t=await r(e,`utf8`),{dependencies:n={}}=j(wr,JSON.parse(t));if(`next`in n)return`next`;if(`nuxt`in n)return`nuxt`;if(`@sveltejs/kit`in n)return`sveltekit`}catch{}}function Er(e){return e.toLowerCase().replace(/(^|[-_\s]+)(.)?/g,(e,t,n)=>n?.toUpperCase()??``)}async function Dr(){let{values:{help:t,json:n}}=e({args:process.argv.slice(4),options:{json:{type:`boolean`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`List all slices in a Prismic project.
1510
1510
 
1511
1511
  USAGE
1512
1512
  prismic slice list [flags]
@@ -1517,7 +1517,7 @@ FLAGS
1517
1517
 
1518
1518
  EXAMPLES
1519
1519
  prismic slice list
1520
- prismic slice list --json`);return}let a=await V(),o;try{o=await i(a,{withFileTypes:!1})}catch{n?console.info(JSON.stringify([])):console.info(`No slices found.`);return}let s=[];for(let e of o){let t=new URL(`${e}/model.json`,a);try{let e=await r(t,`utf8`),n=A(Be,JSON.parse(e));n.success&&s.push({id:n.output.id,name:n.output.name})}catch{}}if(s.length===0){n?console.info(JSON.stringify([])):console.info(`No slices found.`);return}if(n)console.info(JSON.stringify(s,null,2));else{console.info(`ID NAME`);for(let e of s)console.info(`${e.id}\t${e.name}`)}}async function Dr(){let{values:{help:t,json:n},positionals:[r]}=e({args:process.argv.slice(4),options:{json:{type:`boolean`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`List all variations for a slice.
1520
+ prismic slice list --json`);return}let a=await Be(),o;try{o=await i(a,{withFileTypes:!1})}catch{n?console.info(JSON.stringify([])):console.info(`No slices found.`);return}let s=[];for(let e of o){let t=new URL(`${e}/model.json`,a);try{let e=await r(t,`utf8`),n=M(ze,JSON.parse(e));n.success&&s.push({id:n.output.id,name:n.output.name})}catch{}}if(s.length===0){n?console.info(JSON.stringify([])):console.info(`No slices found.`);return}if(n)console.info(JSON.stringify(s,null,2));else{console.info(`ID NAME`);for(let e of s)console.info(`${e.id}\t${e.name}`)}}async function Or(){let{values:{help:t,json:n},positionals:[r]}=e({args:process.argv.slice(4),options:{json:{type:`boolean`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`List all variations for a slice.
1521
1521
 
1522
1522
  USAGE
1523
1523
  prismic slice list-variations <slice-id> [flags]
@@ -1532,7 +1532,7 @@ FLAGS
1532
1532
  EXAMPLES
1533
1533
  prismic slice list-variations MySlice
1534
1534
  prismic slice list-variations MySlice --json`);return}if(!r){console.error(`Missing required argument: slice-id
1535
- `),console.error(`Usage: prismic slice list-variations <slice-id>`),process.exitCode=1;return}let i=await B(r);if(!i.ok){console.error(i.error),process.exitCode=1;return}let{model:a}=i,o=a.variations.map(e=>({id:e.id,name:e.name}));if(n){console.info(JSON.stringify(o,null,2));return}console.info(`ID NAME`);for(let e of o)console.info(`${e.id}\t${e.name}`)}async function Or(){let{values:{help:t,y:n},positionals:[r]}=e({args:process.argv.slice(4),options:{y:{type:`boolean`,short:`y`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Remove a slice from the project.
1535
+ `),console.error(`Usage: prismic slice list-variations <slice-id>`),process.exitCode=1;return}let i=await V(r);if(!i.ok){console.error(i.error),process.exitCode=1;return}let{model:a}=i,o=a.variations.map(e=>({id:e.id,name:e.name}));if(n){console.info(JSON.stringify(o,null,2));return}console.info(`ID NAME`);for(let e of o)console.info(`${e.id}\t${e.name}`)}async function kr(){let{values:{help:t,y:n},positionals:[r]}=e({args:process.argv.slice(4),options:{y:{type:`boolean`,short:`y`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Remove a slice from the project.
1536
1536
 
1537
1537
  USAGE
1538
1538
  prismic slice remove <slice-id> [flags]
@@ -1547,7 +1547,7 @@ FLAGS
1547
1547
  EXAMPLES
1548
1548
  prismic slice remove MySlice
1549
1549
  prismic slice remove MySlice -y`);return}if(!r){console.error(`Missing required argument: slice-id
1550
- `),console.error(`Usage: prismic slice remove <slice-id>`),process.exitCode=1;return}let i=await B(r);if(!i.ok){console.error(i.error),process.exitCode=1;return}let{modelPath:a}=i,s=new URL(`.`,a);if(!n){console.error(`Refusing to remove slice "${r}" (this will delete the entire directory).`),console.error(`Re-run with -y to confirm.`),process.exitCode=1;return}try{await o(s,{recursive:!0})}catch(e){e instanceof Error?console.error(`Failed to remove slice: ${e.message}`):console.error(`Failed to remove slice`),process.exitCode=1;return}console.info(`Removed slice "${r}"`)}async function kr(){let{values:{help:t,variation:n,zone:r},positionals:[i,a]}=e({args:process.argv.slice(4),options:{variation:{type:`string`,default:`default`},zone:{type:`string`,default:`primary`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Remove a field from a slice variation.
1550
+ `),console.error(`Usage: prismic slice remove <slice-id>`),process.exitCode=1;return}let i=await V(r);if(!i.ok){console.error(i.error),process.exitCode=1;return}let{modelPath:a}=i,s=new URL(`.`,a);if(!n){console.error(`Refusing to remove slice "${r}" (this will delete the entire directory).`),console.error(`Re-run with -y to confirm.`),process.exitCode=1;return}try{await o(s,{recursive:!0})}catch(e){e instanceof Error?console.error(`Failed to remove slice: ${e.message}`):console.error(`Failed to remove slice`),process.exitCode=1;return}console.info(`Removed slice "${r}"`)}async function Ar(){let{values:{help:t,variation:n,zone:r},positionals:[i,a]}=e({args:process.argv.slice(4),options:{variation:{type:`string`,default:`default`},zone:{type:`string`,default:`primary`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Remove a field from a slice variation.
1551
1551
 
1552
1552
  USAGE
1553
1553
  prismic slice remove-field <slice-id> <field-id> [flags]
@@ -1566,7 +1566,7 @@ EXAMPLES
1566
1566
  prismic slice remove-field MySlice title --variation withImage
1567
1567
  prismic slice remove-field MySlice item_title --zone items`);return}if(!i){console.error(`Missing required argument: slice-id
1568
1568
  `),console.error(`Usage: prismic slice remove-field <slice-id> <field-id>`),process.exitCode=1;return}if(!a){console.error(`Missing required argument: field-id
1569
- `),console.error(`Usage: prismic slice remove-field <slice-id> <field-id>`),process.exitCode=1;return}if(r!==`primary`&&r!==`items`){console.error(`Invalid zone: ${r}. Must be "primary" or "items".`),process.exitCode=1;return}let o=await B(i);if(!o.ok){console.error(o.error),process.exitCode=1;return}let{model:c,modelPath:l}=o,u=c.variations.find(e=>e.id===n);if(!u){console.error(`Variation not found: ${n}`),console.error(`Available variations: ${c.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}let d=r===`primary`?u.primary:u.items;if(!d||!(a in d)){console.error(`Field "${a}" not found in ${r} zone of variation "${n}"`),process.exitCode=1;return}delete d[a];try{await s(l,z(c))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}console.info(`Removed field "${a}" from ${r} zone in variation "${n}" of slice "${i}"`)}async function Ar(){let{values:{help:t},positionals:[n,r]}=e({args:process.argv.slice(4),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Remove a variation from a slice.
1569
+ `),console.error(`Usage: prismic slice remove-field <slice-id> <field-id>`),process.exitCode=1;return}if(r!==`primary`&&r!==`items`){console.error(`Invalid zone: ${r}. Must be "primary" or "items".`),process.exitCode=1;return}let o=await V(i);if(!o.ok){console.error(o.error),process.exitCode=1;return}let{model:c,modelPath:l}=o,u=c.variations.find(e=>e.id===n);if(!u){console.error(`Variation not found: ${n}`),console.error(`Available variations: ${c.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}let d=r===`primary`?u.primary:u.items;if(!d||!(a in d)){console.error(`Field "${a}" not found in ${r} zone of variation "${n}"`),process.exitCode=1;return}delete d[a];try{await s(l,B(c))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}console.info(`Removed field "${a}" from ${r} zone in variation "${n}" of slice "${i}"`)}async function jr(){let{values:{help:t},positionals:[n,r]}=e({args:process.argv.slice(4),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Remove a variation from a slice.
1570
1570
 
1571
1571
  USAGE
1572
1572
  prismic slice remove-variation <slice-id> <variation-id> [flags]
@@ -1581,7 +1581,7 @@ FLAGS
1581
1581
  EXAMPLES
1582
1582
  prismic slice remove-variation MySlice withImage`);return}if(!n){console.error(`Missing required argument: slice-id
1583
1583
  `),console.error(`Usage: prismic slice remove-variation <slice-id> <variation-id>`),process.exitCode=1;return}if(!r){console.error(`Missing required argument: variation-id
1584
- `),console.error(`Usage: prismic slice remove-variation <slice-id> <variation-id>`),process.exitCode=1;return}let i=await B(n);if(!i.ok){console.error(i.error),process.exitCode=1;return}let{model:a,modelPath:o}=i;if(!a.variations.some(e=>e.id===r)){console.error(`Variation not found: ${r}`),console.error(`Available variations: ${a.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}if(a.variations.length===1){console.error(`Cannot remove the last variation from a slice.`),process.exitCode=1;return}let c={...a,variations:a.variations.filter(e=>e.id!==r)};try{await s(o,z(c))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}console.info(`Removed variation "${r}" from slice "${n}"`)}async function jr(){let{values:{help:t,id:n},positionals:[r,i]}=e({args:process.argv.slice(4),options:{id:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Rename a slice (updates name field, optionally id and directory).
1584
+ `),console.error(`Usage: prismic slice remove-variation <slice-id> <variation-id>`),process.exitCode=1;return}let i=await V(n);if(!i.ok){console.error(i.error),process.exitCode=1;return}let{model:a,modelPath:o}=i;if(!a.variations.some(e=>e.id===r)){console.error(`Variation not found: ${r}`),console.error(`Available variations: ${a.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}if(a.variations.length===1){console.error(`Cannot remove the last variation from a slice.`),process.exitCode=1;return}let c={...a,variations:a.variations.filter(e=>e.id!==r)};try{await s(o,B(c))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}console.info(`Removed variation "${r}" from slice "${n}"`)}async function Mr(){let{values:{help:t,id:n},positionals:[r,i]}=e({args:process.argv.slice(4),options:{id:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Rename a slice (updates name field, optionally id and directory).
1585
1585
 
1586
1586
  USAGE
1587
1587
  prismic slice rename <slice-id> <new-name> [flags]
@@ -1598,7 +1598,7 @@ EXAMPLES
1598
1598
  prismic slice rename MySlice "My New Name"
1599
1599
  prismic slice rename MySlice "My New Name" --id NewSliceId`);return}if(!r){console.error(`Missing required argument: slice-id
1600
1600
  `),console.error(`Usage: prismic slice rename <slice-id> <new-name>`),process.exitCode=1;return}if(!i){console.error(`Missing required argument: new-name
1601
- `),console.error(`Usage: prismic slice rename <slice-id> <new-name>`),process.exitCode=1;return}let o=await B(r);if(!o.ok){console.error(o.error),process.exitCode=1;return}let{model:c,modelPath:l}=o;c.name=i,n&&(c.id=n);try{await s(l,z(c))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}if(n){let e=await V(),t=new URL(`.`,l),o=new URL(H(i)+`/`,e);if(t.href!==o.href)try{await a(t,o),console.info(`Renamed slice "${r}" to "${n}" (${i})`),console.info(`Moved directory to ${o.href}`)}catch(e){e instanceof Error?console.error(`Failed to rename directory: ${e.message}`):console.error(`Failed to rename directory`),process.exitCode=1;return}else console.info(`Renamed slice "${r}" to "${n}" (${i})`)}else console.info(`Renamed slice "${r}" to "${i}"`)}async function Mr(){let{values:{help:t,json:n},positionals:[r]}=e({args:process.argv.slice(4),options:{json:{type:`boolean`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`View details of a specific slice.
1601
+ `),console.error(`Usage: prismic slice rename <slice-id> <new-name>`),process.exitCode=1;return}let o=await V(r);if(!o.ok){console.error(o.error),process.exitCode=1;return}let{model:c,modelPath:l}=o;c.name=i,n&&(c.id=n);try{await s(l,B(c))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}if(n){let e=await Be(),t=new URL(`.`,l),o=new URL(Ue(i)+`/`,e);if(t.href!==o.href)try{await a(t,o),console.info(`Renamed slice "${r}" to "${n}" (${i})`),console.info(`Moved directory to ${o.href}`)}catch(e){e instanceof Error?console.error(`Failed to rename directory: ${e.message}`):console.error(`Failed to rename directory`),process.exitCode=1;return}else console.info(`Renamed slice "${r}" to "${n}" (${i})`)}else console.info(`Renamed slice "${r}" to "${i}"`)}async function Nr(){let{values:{help:t,json:n},positionals:[r]}=e({args:process.argv.slice(4),options:{json:{type:`boolean`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`View details of a specific slice.
1602
1602
 
1603
1603
  USAGE
1604
1604
  prismic slice view <slice-id> [flags]
@@ -1613,8 +1613,8 @@ FLAGS
1613
1613
  EXAMPLES
1614
1614
  prismic slice view MySlice
1615
1615
  prismic slice view MySlice --json`);return}if(!r){console.error(`Missing required argument: slice-id
1616
- `),console.error(`Usage: prismic slice view <slice-id>`),process.exitCode=1;return}let i=await B(r);if(!i.ok){console.error(i.error),process.exitCode=1;return}let{model:a}=i;if(n){console.info(JSON.stringify(a,null,2));return}console.info(`ID: ${a.id}`),console.info(`Name: ${a.name}`),a.description&&console.info(`Description: ${a.description}`),console.info(`Variations: ${a.variations.length}`),console.info(`
1617
- Variations:`);for(let e of a.variations){let t=Object.keys(e.primary??{}).length,n=Object.keys(e.items??{}).length;console.info(` - ${e.id} (${e.name}): ${t} primary fields, ${n} items fields`)}}async function Nr(){let{positionals:[t]}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`create`:await xr();break;case`list`:await Er();break;case`view`:await Mr();break;case`rename`:await jr();break;case`remove`:await Or();break;case`add-field`:await yr();break;case`remove-field`:await kr();break;case`add-variation`:await br();break;case`remove-variation`:await Ar();break;case`list-variations`:await Dr();break;default:t&&(console.error(`Unknown slice subcommand: ${t}\n`),process.exitCode=1),console.info(`Manage slices in a Prismic project.
1616
+ `),console.error(`Usage: prismic slice view <slice-id>`),process.exitCode=1;return}let i=await V(r);if(!i.ok){console.error(i.error),process.exitCode=1;return}let{model:a}=i;if(n){console.info(JSON.stringify(a,null,2));return}console.info(`ID: ${a.id}`),console.info(`Name: ${a.name}`),a.description&&console.info(`Description: ${a.description}`),console.info(`Variations: ${a.variations.length}`),console.info(`
1617
+ Variations:`);for(let e of a.variations){let t=Object.keys(e.primary??{}).length,n=Object.keys(e.items??{}).length;console.info(` - ${e.id} (${e.name}): ${t} primary fields, ${n} items fields`)}}async function Pr(){let{positionals:[t]}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`create`:await Sr();break;case`list`:await Dr();break;case`view`:await Nr();break;case`rename`:await Mr();break;case`remove`:await kr();break;case`add-field`:await br();break;case`remove-field`:await Ar();break;case`add-variation`:await xr();break;case`remove-variation`:await jr();break;case`list-variations`:await Or();break;default:t&&(console.error(`Unknown slice subcommand: ${t}\n`),process.exitCode=1),console.info(`Manage slices in a Prismic project.
1618
1618
 
1619
1619
  USAGE
1620
1620
  prismic slice <command> [flags]
@@ -1635,29 +1635,7 @@ FLAGS
1635
1635
  -h, --help Show help for command
1636
1636
 
1637
1637
  LEARN MORE
1638
- Use \`prismic slice <command> --help\` for more information about a command.`)}}const Pr=T({id:O(),label:E(O()),repeatable:S(),status:S(),format:E(O()),json:D(O(),k())});async function Fr(){let{values:{help:t,repo:r=await U(),"dry-run":i,"types-only":a,"slices-only":o,json:c}}=e({args:process.argv.slice(3),options:{repo:{type:`string`,short:`r`},"dry-run":{type:`boolean`},"types-only":{type:`boolean`},"slices-only":{type:`boolean`},json:{type:`boolean`},help:{type:`boolean`,short:`h`}},allowPositionals:!1});if(t){console.info(`Sync custom types and slices from Prismic to local files.
1639
-
1640
- By default, this command reads the repository from prismic.config.json at the
1641
- project root.
1642
-
1643
- USAGE
1644
- prismic sync [flags]
1645
-
1646
- FLAGS
1647
- -r, --repo string Repository domain
1648
- --dry-run Show what would be synced without writing files
1649
- --types-only Only sync custom types
1650
- --slices-only Only sync slices
1651
- --json Output as JSON
1652
- -h, --help Show help for command
1653
-
1654
- EXAMPLES
1655
- prismic sync
1656
- prismic sync --repo my-repo
1657
- prismic sync --dry-run
1658
- prismic sync --types-only`);return}if(!r){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await M()){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1;return}c||console.info(`Syncing from repository: ${r}\n`);let l=!o,u=!a,[d,f]=await Promise.all([l?Lr(r):Promise.resolve({ok:!0,value:[]}),u?Rr(r):Promise.resolve({ok:!0,value:[]})]);if(!d.ok){console.error(`Failed to fetch custom types: ${d.error}`),process.exitCode=1;return}if(!f.ok){console.error(`Failed to fetch slices: ${f.error}`),process.exitCode=1;return}let p=d.value,m=f.value;if(c||(l&&console.info(`Fetching custom types... ${p.length} types`),u&&console.info(`Fetching slices... ${m.length} slices`)),i){if(c)console.info(z({customTypes:p,slices:m}));else{if(console.info(``),l&&p.length>0){console.info(`Would write custom types:`);for(let e of p)console.info(` customtypes/${e.id}/index.json`)}if(u&&m.length>0){let e=zr(await V());console.info(`Would write slices:`);for(let t of m)console.info(` ${e}${H(t.name)}/model.json`)}console.info(`\nDry run complete: ${p.length} custom types, ${m.length} slices`)}return}let h=await L(`package.json`);if(!h){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let g=new URL(`.`,h),_=[],v=[];if(l&&p.length>0){c||console.info(`
1659
- Writing custom types:`);let e=new URL(`customtypes/`,g);for(let t of p){let r=new URL(`${t.id}/`,e),i=new URL(`index.json`,r);try{await n(r,{recursive:!0}),await s(i,z(t));let e=`customtypes/${t.id}/index.json`;_.push(e),c||console.info(` ${e}`)}catch(e){console.error(`Failed to write custom type ${t.id}: ${e instanceof Error?e.message:e}`),process.exitCode=1;return}}}if(u&&m.length>0){c||console.info(`
1660
- Writing slices:`);let e=await V();for(let t of m){let r=new URL(`${H(t.name)}/`,e),i=new URL(`model.json`,r);try{await n(r,{recursive:!0}),await s(i,z(t));let a=`${zr(e)}${H(t.name)}/model.json`;v.push(a),c||console.info(` ${a}`)}catch(e){console.error(`Failed to write slice ${t.name}: ${e instanceof Error?e.message:e}`),process.exitCode=1;return}}}c?console.info(z({writtenTypes:_,writtenSlices:v})):console.info(`\nSync complete: ${_.length} custom types, ${v.length} slices`)}async function Ir(){let e=await P();return e.hostname=`customtypes.${e.hostname}`,e}async function Lr(e){let t=await N();if(!t)return{ok:!1,error:`Not authenticated`};let n=await Ir(),r=new URL(`customtypes`,n);try{let n=await fetch(r,{headers:{Authorization:`Bearer ${t}`,repository:e}});if(!n.ok)return n.status===401?{ok:!1,error:"Unauthorized. Your session may have expired. Run `prismic login` again."}:n.status===403?{ok:!1,error:`Access denied. You may not have access to repository "${e}".`}:{ok:!1,error:`API error: ${n.status} ${n.statusText}`};let i=await n.json(),a=A(x(Pr),i);return a.success?{ok:!0,value:a.output}:{ok:!1,error:`Invalid response from Custom Types API`}}catch(e){return{ok:!1,error:`Network error: ${e instanceof Error?e.message:e}`}}}async function Rr(e){let t=await N();if(!t)return{ok:!1,error:`Not authenticated`};let n=await Ir(),r=new URL(`slices`,n);try{let n=await fetch(r,{headers:{Authorization:`Bearer ${t}`,repository:e}});if(!n.ok)return n.status===401?{ok:!1,error:"Unauthorized. Your session may have expired. Run `prismic login` again."}:n.status===403?{ok:!1,error:`Access denied. You may not have access to repository "${e}".`}:{ok:!1,error:`API error: ${n.status} ${n.statusText}`};let i=await n.json(),a=A(x(Be),i);return a.success?{ok:!0,value:a.output}:{ok:!1,error:`Invalid response from Custom Types API`}}catch(e){return{ok:!1,error:`Network error: ${e instanceof Error?e.message:e}`}}}function zr(e){let t=process.cwd(),n=e.pathname;return n.startsWith(t)?n.slice(t.length+1):n}async function Br(){let{values:{help:t,repo:n=await U(),json:r}}=e({args:process.argv.slice(4),options:{json:{type:`boolean`},repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!1});if(t){console.info(`List all API tokens for a Prismic repository.
1638
+ Use \`prismic slice <command> --help\` for more information about a command.`)}}async function Fr(){let{values:{help:t,repo:n=await H(),json:r}}=e({args:process.argv.slice(4),options:{json:{type:`boolean`},repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!1});if(t){console.info(`List all API tokens for a Prismic repository.
1661
1639
 
1662
1640
  By default, this command reads the repository from prismic.config.json at the
1663
1641
  project root.
@@ -1671,7 +1649,7 @@ FLAGS
1671
1649
  -h, --help Show help for command
1672
1650
 
1673
1651
  LEARN MORE
1674
- Use \`prismic token <command> --help\` for more information about a command.`);return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await M()){Xr();return}let[i,a]=await Promise.all([J(n),qr(n)]);if(!i.ok){i.error instanceof K||i.error instanceof q?Xr():b(i.error)?(console.error(`Failed to list access tokens: Invalid response: ${z(i.error.issues)}`),process.exitCode=1):(console.error(`Failed to list access tokens: ${z(i.value)}`),process.exitCode=1);return}if(!a.ok){a.error instanceof K||a.error instanceof q?Xr():b(a.error)?(console.error(`Failed to list write tokens: Invalid response: ${z(a.error.issues)}`),process.exitCode=1):(console.error(`Failed to list write tokens: ${z(a.value)}`),process.exitCode=1);return}let o=i.value.flatMap(e=>e.wroom_auths.map(t=>({name:e.name,appId:e.id,authId:t.id,scope:t.scope,token:t.token,createdAt:t.created_at.$date}))),s=a.value.tokens;if(r)console.info(z({accessTokens:o,writeTokens:s}));else{if(o.length>0){console.info(`ACCESS TOKENS`);for(let e of o){let t=Jr(e.token),n=Yr(e.createdAt);console.info(` ${e.name} ${e.scope} ${t} ${n}`)}}else console.info(`ACCESS TOKENS (none)`);if(console.info(``),s.length>0){console.info(`WRITE TOKENS`);for(let e of s){let t=Jr(e.token),n=Yr(e.timestamp);console.info(` ${e.app_name} ${t} ${n}`)}}else console.info(`WRITE TOKENS (none)`)}}const Vr=T({$date:w()}),Hr=T({id:O(),origin:O(),domain:O(),app:O(),scope:O(),expired_at:Vr,created_at:Vr,owner:C(O()),token:O()}),Ur=T({id:O(),secret:O(),name:O(),owner:O(),created_at:Vr,authorized_domains:x(O()),wroom_auths:x(Hr)}),Wr=T({app_name:O(),token:O(),timestamp:w()}),Gr=T({max_tokens:w(),tokens:x(Wr)}),Kr=x(Ur);async function J(e){return await G(new URL(`settings/security/contentapi`,await F(e)),{schema:Kr})}async function qr(e){return await G(new URL(`settings/security/customtypesapi`,await F(e)),{schema:Gr})}function Jr(e){return e.length<=12?e:`${e.slice(0,8)}...${e.slice(-4)}`}function Yr(e){let t=typeof e==`number`?e*1e3:e.$date;return new Date(t).toISOString().split(`T`)[0]}function Xr(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function Zr(){let{values:{help:t,repo:n=await U(),json:r,write:i,name:a=`Prismic CLI`,"allow-releases":o}}=e({args:process.argv.slice(4),options:{json:{type:`boolean`},repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`},write:{type:`boolean`,short:`w`},name:{type:`string`,short:`n`},"allow-releases":{type:`boolean`}},allowPositionals:!1});if(t){console.info(`Create a new API token for a Prismic repository.
1652
+ Use \`prismic token <command> --help\` for more information about a command.`);return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await P()){Gr();return}let[i,a]=await Promise.all([q(n),Hr(n)]);if(!i.ok){i.error instanceof G||i.error instanceof K?Gr():b(i.error)?(console.error(`Failed to list access tokens: Invalid response: ${B(i.error.issues)}`),process.exitCode=1):(console.error(`Failed to list access tokens: ${B(i.value)}`),process.exitCode=1);return}if(!a.ok){a.error instanceof G||a.error instanceof K?Gr():b(a.error)?(console.error(`Failed to list write tokens: Invalid response: ${B(a.error.issues)}`),process.exitCode=1):(console.error(`Failed to list write tokens: ${B(a.value)}`),process.exitCode=1);return}let o=i.value.flatMap(e=>e.wroom_auths.map(t=>({name:e.name,appId:e.id,authId:t.id,scope:t.scope,token:t.token,createdAt:t.created_at.$date}))),s=a.value.tokens;if(r)console.info(B({accessTokens:o,writeTokens:s}));else{if(o.length>0){console.info(`ACCESS TOKENS`);for(let e of o){let t=Ur(e.token),n=Wr(e.createdAt);console.info(` ${e.name} ${e.scope} ${t} ${n}`)}}else console.info(`ACCESS TOKENS (none)`);if(console.info(``),s.length>0){console.info(`WRITE TOKENS`);for(let e of s){let t=Ur(e.token),n=Wr(e.timestamp);console.info(` ${e.app_name} ${t} ${n}`)}}else console.info(`WRITE TOKENS (none)`)}}const Ir=E({$date:T()}),Lr=E({id:k(),origin:k(),domain:k(),app:k(),scope:k(),expired_at:Ir,created_at:Ir,owner:w(k()),token:k()}),Rr=E({id:k(),secret:k(),name:k(),owner:k(),created_at:Ir,authorized_domains:S(k()),wroom_auths:S(Lr)}),zr=E({app_name:k(),token:k(),timestamp:T()}),Br=E({max_tokens:T(),tokens:S(zr)}),Vr=S(Rr);async function q(e){return await W(new URL(`settings/security/contentapi`,await I(e)),{schema:Vr})}async function Hr(e){return await W(new URL(`settings/security/customtypesapi`,await I(e)),{schema:Br})}function Ur(e){return e.length<=12?e:`${e.slice(0,8)}...${e.slice(-4)}`}function Wr(e){let t=typeof e==`number`?e*1e3:e.$date;return new Date(t).toISOString().split(`T`)[0]}function Gr(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function Kr(){let{values:{help:t,repo:n=await H(),json:r,write:i,name:a=`Prismic CLI`,"allow-releases":o}}=e({args:process.argv.slice(4),options:{json:{type:`boolean`},repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`},write:{type:`boolean`,short:`w`},name:{type:`string`,short:`n`},"allow-releases":{type:`boolean`}},allowPositionals:!1});if(t){console.info(`Create a new API token for a Prismic repository.
1675
1653
 
1676
1654
  By default, this command reads the repository from prismic.config.json at the
1677
1655
  project root.
@@ -1688,7 +1666,7 @@ FLAGS
1688
1666
  -h, --help Show help for command
1689
1667
 
1690
1668
  LEARN MORE
1691
- Use \`prismic token <command> --help\` for more information about a command.`);return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(i&&o){console.error(`--allow-releases is only valid for access tokens (not with --write)`),process.exitCode=1;return}if(!await M()){ei();return}if(i){let e=await Qr(n,a);if(!e.ok){e.error instanceof K||e.error instanceof q?ei():b(e.error)?(console.error(`Failed to create write token: Invalid response: ${z(e.error.issues)}`),process.exitCode=1):(console.error(`Failed to create write token: ${z(e.value)}`),process.exitCode=1);return}r?console.info(z(e.value)):console.info(`Token created: ${e.value.token}`)}else{let e=await $r(n,a,o?`master+releases`:`master`);if(!e.ok){e.error instanceof K||e.error instanceof q?ei():b(e.error)?(console.error(`Failed to create access token: Invalid response: ${z(e.error.issues)}`),process.exitCode=1):(console.error(`Failed to create access token: ${z(e.value)}`),process.exitCode=1);return}r?console.info(z(e.value)):console.info(`Token created: ${e.value.token}`)}}async function Qr(e,t){return await G(new URL(`settings/security/token`,await F(e)),{method:`POST`,body:{app_name:t},schema:Wr})}async function $r(e,t,n){let r=await J(e);if(!r.ok)return r;let i=r.value.find(e=>e.name===t);if(!i){let n=await G(new URL(`settings/security/oauthapp`,await F(e)),{method:`POST`,body:{app_name:t},schema:Ur});if(!n.ok)return n;i=n.value}return await G(new URL(`settings/security/authorizations`,await F(e)),{method:`POST`,body:{app:i.id,scope:n},schema:Hr})}function ei(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function ti(){let{values:{help:t,repo:n=await U()},positionals:[r]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Delete a token from a Prismic repository.
1669
+ Use \`prismic token <command> --help\` for more information about a command.`);return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(i&&o){console.error(`--allow-releases is only valid for access tokens (not with --write)`),process.exitCode=1;return}if(!await P()){Yr();return}if(i){let e=await qr(n,a);if(!e.ok){e.error instanceof G||e.error instanceof K?Yr():b(e.error)?(console.error(`Failed to create write token: Invalid response: ${B(e.error.issues)}`),process.exitCode=1):(console.error(`Failed to create write token: ${B(e.value)}`),process.exitCode=1);return}r?console.info(B(e.value)):console.info(`Token created: ${e.value.token}`)}else{let e=await Jr(n,a,o?`master+releases`:`master`);if(!e.ok){e.error instanceof G||e.error instanceof K?Yr():b(e.error)?(console.error(`Failed to create access token: Invalid response: ${B(e.error.issues)}`),process.exitCode=1):(console.error(`Failed to create access token: ${B(e.value)}`),process.exitCode=1);return}r?console.info(B(e.value)):console.info(`Token created: ${e.value.token}`)}}async function qr(e,t){return await W(new URL(`settings/security/token`,await I(e)),{method:`POST`,body:{app_name:t},schema:zr})}async function Jr(e,t,n){let r=await q(e);if(!r.ok)return r;let i=r.value.find(e=>e.name===t);if(!i){let n=await W(new URL(`settings/security/oauthapp`,await I(e)),{method:`POST`,body:{app_name:t},schema:Rr});if(!n.ok)return n;i=n.value}return await W(new URL(`settings/security/authorizations`,await I(e)),{method:`POST`,body:{app:i.id,scope:n},schema:Lr})}function Yr(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function Xr(){let{values:{help:t,repo:n=await H()},positionals:[r]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Delete a token from a Prismic repository.
1692
1670
 
1693
1671
  By default, this command reads the repository from prismic.config.json at the
1694
1672
  project root.
@@ -1704,7 +1682,7 @@ FLAGS
1704
1682
  -h, --help Show help for command
1705
1683
 
1706
1684
  LEARN MORE
1707
- Use \`prismic token <command> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: token`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await M()){Y();return}let[i,a]=await Promise.all([J(n),qr(n)]);if(!i.ok){i.error instanceof K||i.error instanceof q?Y():b(i.error)?(console.error(`Failed to list access tokens: Invalid response: ${z(i.error.issues)}`),process.exitCode=1):(console.error(`Failed to list access tokens: ${z(i.value)}`),process.exitCode=1);return}if(!a.ok){a.error instanceof K||a.error instanceof q?Y():b(a.error)?(console.error(`Failed to list write tokens: Invalid response: ${z(a.error.issues)}`),process.exitCode=1):(console.error(`Failed to list write tokens: ${z(a.value)}`),process.exitCode=1);return}let o;for(let e of i.value){for(let t of e.wroom_auths)if(t.token===r||t.token.startsWith(r)||t.token.endsWith(r)){o=t;break}if(o)break}if(o){let e=await G(new URL(`settings/security/authorizations/${o.id}`,await F(n)),{method:`DELETE`});if(!e.ok){e.error instanceof K||e.error instanceof q?Y():(console.error(`Failed to delete token: ${z(e.value)}`),process.exitCode=1);return}console.info(`Token deleted`);return}let s=a.value.tokens.find(e=>e.token===r||e.token.startsWith(r)||e.token.endsWith(r));if(s){let e=await G(new URL(`settings/security/token/${s.token}`,await F(n)),{method:`DELETE`});if(!e.ok){e.error instanceof K||e.error instanceof q?Y():(console.error(`Failed to delete token: ${z(e.value)}`),process.exitCode=1);return}console.info(`Token deleted`);return}console.error(`Token not found: ${r}`),process.exitCode=1}function Y(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function ni(){let{values:{help:t,repo:n=await U()},positionals:[r,i]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Set the name of a token in a Prismic repository.
1685
+ Use \`prismic token <command> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: token`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await P()){J();return}let[i,a]=await Promise.all([q(n),Hr(n)]);if(!i.ok){i.error instanceof G||i.error instanceof K?J():b(i.error)?(console.error(`Failed to list access tokens: Invalid response: ${B(i.error.issues)}`),process.exitCode=1):(console.error(`Failed to list access tokens: ${B(i.value)}`),process.exitCode=1);return}if(!a.ok){a.error instanceof G||a.error instanceof K?J():b(a.error)?(console.error(`Failed to list write tokens: Invalid response: ${B(a.error.issues)}`),process.exitCode=1):(console.error(`Failed to list write tokens: ${B(a.value)}`),process.exitCode=1);return}let o;for(let e of i.value){for(let t of e.wroom_auths)if(t.token===r||t.token.startsWith(r)||t.token.endsWith(r)){o=t;break}if(o)break}if(o){let e=await W(new URL(`settings/security/authorizations/${o.id}`,await I(n)),{method:`DELETE`});if(!e.ok){e.error instanceof G||e.error instanceof K?J():(console.error(`Failed to delete token: ${B(e.value)}`),process.exitCode=1);return}console.info(`Token deleted`);return}let s=a.value.tokens.find(e=>e.token===r||e.token.startsWith(r)||e.token.endsWith(r));if(s){let e=await W(new URL(`settings/security/token/${s.token}`,await I(n)),{method:`DELETE`});if(!e.ok){e.error instanceof G||e.error instanceof K?J():(console.error(`Failed to delete token: ${B(e.value)}`),process.exitCode=1);return}console.info(`Token deleted`);return}console.error(`Token not found: ${r}`),process.exitCode=1}function J(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function Zr(){let{values:{help:t,repo:n=await H()},positionals:[r,i]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Set the name of a token in a Prismic repository.
1708
1686
 
1709
1687
  Note: Only access tokens can be renamed. Write tokens cannot be renamed without
1710
1688
  changing the token value.
@@ -1724,7 +1702,7 @@ FLAGS
1724
1702
  -h, --help Show help for command
1725
1703
 
1726
1704
  LEARN MORE
1727
- Use \`prismic token <command> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: token`),process.exitCode=1;return}if(!i){console.error(`Missing required argument: name`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await M()){X();return}let[a,o]=await Promise.all([J(n),qr(n)]);if(!a.ok){a.error instanceof K||a.error instanceof q?X():b(a.error)?(console.error(`Failed to list access tokens: Invalid response: ${z(a.error.issues)}`),process.exitCode=1):(console.error(`Failed to list access tokens: ${z(a.value)}`),process.exitCode=1);return}if(!o.ok){o.error instanceof K||o.error instanceof q?X():b(o.error)?(console.error(`Failed to list write tokens: Invalid response: ${z(o.error.issues)}`),process.exitCode=1):(console.error(`Failed to list write tokens: ${z(o.value)}`),process.exitCode=1);return}let s;for(let e of a.value){for(let t of e.wroom_auths)if(t.token===r||t.token.startsWith(r)||t.token.endsWith(r)){s=e;break}if(s)break}if(s){let e=await G(new URL(`settings/security/oauthapp/${s.id}`,await F(n)),{method:`POST`,body:{name:i},schema:Ur});if(!e.ok){e.error instanceof K||e.error instanceof q?X():b(e.error)?(console.error(`Failed to rename token: Invalid response: ${z(e.error.issues)}`),process.exitCode=1):(console.error(`Failed to rename token: ${z(e.value)}`),process.exitCode=1);return}console.info(`Token renamed to: ${i}`);return}if(o.value.tokens.find(e=>e.token===r||e.token.startsWith(r)||e.token.endsWith(r))){console.error(`Write tokens cannot be renamed. Delete and create a new token with the desired name.`),process.exitCode=1;return}console.error(`Token not found: ${r}`),process.exitCode=1}function X(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function ri(){let{positionals:[t]}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`list`:await Br();break;case`create`:await Zr();break;case`set-name`:await ni();break;case`delete`:await ti();break;default:t&&(console.error(`Unknown token subcommand: ${t}\n`),process.exitCode=1),console.info(`Manage API tokens for a Prismic repository.
1705
+ Use \`prismic token <command> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: token`),process.exitCode=1;return}if(!i){console.error(`Missing required argument: name`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await P()){Y();return}let[a,o]=await Promise.all([q(n),Hr(n)]);if(!a.ok){a.error instanceof G||a.error instanceof K?Y():b(a.error)?(console.error(`Failed to list access tokens: Invalid response: ${B(a.error.issues)}`),process.exitCode=1):(console.error(`Failed to list access tokens: ${B(a.value)}`),process.exitCode=1);return}if(!o.ok){o.error instanceof G||o.error instanceof K?Y():b(o.error)?(console.error(`Failed to list write tokens: Invalid response: ${B(o.error.issues)}`),process.exitCode=1):(console.error(`Failed to list write tokens: ${B(o.value)}`),process.exitCode=1);return}let s;for(let e of a.value){for(let t of e.wroom_auths)if(t.token===r||t.token.startsWith(r)||t.token.endsWith(r)){s=e;break}if(s)break}if(s){let e=await W(new URL(`settings/security/oauthapp/${s.id}`,await I(n)),{method:`POST`,body:{name:i},schema:Rr});if(!e.ok){e.error instanceof G||e.error instanceof K?Y():b(e.error)?(console.error(`Failed to rename token: Invalid response: ${B(e.error.issues)}`),process.exitCode=1):(console.error(`Failed to rename token: ${B(e.value)}`),process.exitCode=1);return}console.info(`Token renamed to: ${i}`);return}if(o.value.tokens.find(e=>e.token===r||e.token.startsWith(r)||e.token.endsWith(r))){console.error(`Write tokens cannot be renamed. Delete and create a new token with the desired name.`),process.exitCode=1;return}console.error(`Token not found: ${r}`),process.exitCode=1}function Y(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function Qr(){let{positionals:[t]}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`list`:await Fr();break;case`create`:await Kr();break;case`set-name`:await Zr();break;case`delete`:await Xr();break;default:t&&(console.error(`Unknown token subcommand: ${t}\n`),process.exitCode=1),console.info(`Manage API tokens for a Prismic repository.
1728
1706
 
1729
1707
  USAGE
1730
1708
  prismic token <command> [flags]
@@ -1739,7 +1717,7 @@ FLAGS
1739
1717
  -h, --help Show help for command
1740
1718
 
1741
1719
  LEARN MORE
1742
- Use \`prismic token <command> --help\` for more information about a command.`)}}const Z={documentsPublished:`document.published`,documentsUnpublished:`document.unpublished`,releasesCreated:`release.created`,releasesUpdated:`release.updated`,tagsCreated:`tag.created`,tagsDeleted:`tag.deleted`};async function ii(){let{values:{help:t,repo:n=await U()},positionals:[r]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`View details of a webhook in a Prismic repository.
1720
+ Use \`prismic token <command> --help\` for more information about a command.`)}}const X={documentsPublished:`document.published`,documentsUnpublished:`document.unpublished`,releasesCreated:`release.created`,releasesUpdated:`release.updated`,tagsCreated:`tag.created`,tagsDeleted:`tag.deleted`};async function $r(){let{values:{help:t,repo:n=await H()},positionals:[r]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`View details of a webhook in a Prismic repository.
1743
1721
 
1744
1722
  By default, this command reads the repository from prismic.config.json at the
1745
1723
  project root.
@@ -1755,7 +1733,7 @@ FLAGS
1755
1733
  -h, --help Show help for command
1756
1734
 
1757
1735
  LEARN MORE
1758
- Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <url>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await M()){ai();return}let i=await Q(n);if(!i.ok){i.error instanceof K?ai():(console.error(`Failed to view webhook: ${z(i.value)}`),process.exitCode=1);return}let a=i.value.find(e=>e.config.url===r);if(!a){console.error(`Webhook not found: ${r}`),process.exitCode=1;return}let{config:o}=a;console.info(`URL: ${o.url}`),console.info(`Name: ${o.name||`(none)`}`),console.info(`Status: ${o.active?`enabled`:`disabled`}`),console.info(`Secret: ${o.secret?`(set)`:`(none)`}`);let s=[];for(let[e,t]of Object.entries(Z))o[e]&&s.push(t);if(console.info(`Triggers: ${s.length>0?s.join(`, `):`(none)`}`),Object.keys(o.headers).length>0){console.info(`Headers:`);for(let[e,t]of Object.entries(o.headers))console.info(` ${e}: ${t}`)}else console.info(`Headers: (none)`)}function ai(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}const oi=T({config:T({_id:O(),url:O(),active:S(),name:C(O()),secret:C(O()),headers:D(O(),O()),documentsPublished:S(),documentsUnpublished:S(),releasesCreated:S(),releasesUpdated:S(),tagsCreated:S(),tagsDeleted:S()})});async function Q(e){return await G(new URL(`/app/settings/webhooks`,await F(e)),{schema:x(oi)})}async function si(){let{values:{help:t,repo:n=await U()},positionals:[r]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Enable a webhook in a Prismic repository.
1736
+ Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <url>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await P()){ei();return}let i=await Z(n);if(!i.ok){i.error instanceof G?ei():(console.error(`Failed to view webhook: ${B(i.value)}`),process.exitCode=1);return}let a=i.value.find(e=>e.config.url===r);if(!a){console.error(`Webhook not found: ${r}`),process.exitCode=1;return}let{config:o}=a;console.info(`URL: ${o.url}`),console.info(`Name: ${o.name||`(none)`}`),console.info(`Status: ${o.active?`enabled`:`disabled`}`),console.info(`Secret: ${o.secret?`(set)`:`(none)`}`);let s=[];for(let[e,t]of Object.entries(X))o[e]&&s.push(t);if(console.info(`Triggers: ${s.length>0?s.join(`, `):`(none)`}`),Object.keys(o.headers).length>0){console.info(`Headers:`);for(let[e,t]of Object.entries(o.headers))console.info(` ${e}: ${t}`)}else console.info(`Headers: (none)`)}function ei(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}const ti=E({config:E({_id:k(),url:k(),active:C(),name:w(k()),secret:w(k()),headers:O(k(),k()),documentsPublished:C(),documentsUnpublished:C(),releasesCreated:C(),releasesUpdated:C(),tagsCreated:C(),tagsDeleted:C()})});async function Z(e){return await W(new URL(`/app/settings/webhooks`,await I(e)),{schema:S(ti)})}async function ni(){let{values:{help:t,repo:n=await H()},positionals:[r]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Enable a webhook in a Prismic repository.
1759
1737
 
1760
1738
  By default, this command reads the repository from prismic.config.json at the
1761
1739
  project root.
@@ -1771,7 +1749,7 @@ FLAGS
1771
1749
  -h, --help Show help for command
1772
1750
 
1773
1751
  LEARN MORE
1774
- Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <url>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await M()){ci();return}let i=await Q(n);if(!i.ok){i.error instanceof K?ci():(console.error(`Failed to enable webhook: ${z(i.value)}`),process.exitCode=1);return}let a=i.value.find(e=>e.config.url===r);if(!a){console.error(`Webhook not found: ${r}`),process.exitCode=1;return}if(a.config.active){console.info(`Webhook already enabled: ${r}`);return}let o=structuredClone(a.config);o.active=!0;let s=await $(n,a.config._id,o);if(!s.ok){s.error instanceof K?ci():(console.error(`Failed to enable webhook: ${z(s.value)}`),process.exitCode=1);return}console.info(`Webhook enabled: ${r}`)}async function $(e,t,n){let r=new URL(`/app/settings/webhooks/${t}`,await F(e)),i=new FormData;return i.set(`url`,n.url),i.set(`name`,n.name??``),i.set(`secret`,n.secret??``),i.set(`headers`,JSON.stringify(n.headers??{})),i.set(`active`,n.active?`on`:`off`),i.set(`documentsPublished`,n.documentsUnpublished.toString()),i.set(`documentsUnpublished`,n.documentsUnpublished.toString()),i.set(`releasesCreated`,n.documentsUnpublished.toString()),i.set(`releasesUpdated`,n.documentsUnpublished.toString()),i.set(`tagsCreated`,n.documentsUnpublished.toString()),i.set(`documentsPublished`,n.documentsUnpublished.toString()),await G(r,{method:`POST`,body:i})}function ci(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function li(){let{values:{help:t,repo:n=await U()},positionals:[r,i,a]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a custom HTTP header to a webhook.
1752
+ Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <url>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await P()){ri();return}let i=await Z(n);if(!i.ok){i.error instanceof G?ri():(console.error(`Failed to enable webhook: ${B(i.value)}`),process.exitCode=1);return}let a=i.value.find(e=>e.config.url===r);if(!a){console.error(`Webhook not found: ${r}`),process.exitCode=1;return}if(a.config.active){console.info(`Webhook already enabled: ${r}`);return}let o=structuredClone(a.config);o.active=!0;let s=await Q(n,a.config._id,o);if(!s.ok){s.error instanceof G?ri():(console.error(`Failed to enable webhook: ${B(s.value)}`),process.exitCode=1);return}console.info(`Webhook enabled: ${r}`)}async function Q(e,t,n){let r=new URL(`/app/settings/webhooks/${t}`,await I(e)),i=new FormData;return i.set(`url`,n.url),i.set(`name`,n.name??``),i.set(`secret`,n.secret??``),i.set(`headers`,JSON.stringify(n.headers??{})),i.set(`active`,n.active?`on`:`off`),i.set(`documentsPublished`,n.documentsUnpublished.toString()),i.set(`documentsUnpublished`,n.documentsUnpublished.toString()),i.set(`releasesCreated`,n.documentsUnpublished.toString()),i.set(`releasesUpdated`,n.documentsUnpublished.toString()),i.set(`tagsCreated`,n.documentsUnpublished.toString()),i.set(`documentsPublished`,n.documentsUnpublished.toString()),await W(r,{method:`POST`,body:i})}function ri(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function ii(){let{values:{help:t,repo:n=await H()},positionals:[r,i,a]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a custom HTTP header to a webhook.
1775
1753
 
1776
1754
  By default, this command reads the repository from prismic.config.json at the
1777
1755
  project root.
@@ -1789,7 +1767,7 @@ FLAGS
1789
1767
  -h, --help Show help for command
1790
1768
 
1791
1769
  LEARN MORE
1792
- Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <url>`),process.exitCode=1;return}if(!i){console.error(`Missing required argument: <key>`),process.exitCode=1;return}if(!a){console.error(`Missing required argument: <value>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await M()){ui();return}let o=await Q(n);if(!o.ok){o.error instanceof K?ui():(console.error(`Failed to add header: ${z(o.value)}`),process.exitCode=1);return}let s=o.value.find(e=>e.config.url===r);if(!s){console.error(`Webhook not found: ${r}`),process.exitCode=1;return}let c=structuredClone(s.config);c.headers[i]=a;let l=await $(n,s.config._id,c);if(!l.ok){l.error instanceof K?ui():(console.error(`Failed to add header: ${z(l.value)}`),process.exitCode=1);return}console.info(`Header added: ${i}`)}function ui(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}const di=Object.values(Z);async function fi(){let{values:{help:t,repo:n=await U(),name:r,secret:i,trigger:a=[]},positionals:[o]}=e({args:process.argv.slice(4),options:{name:{type:`string`,short:`n`},secret:{type:`string`,short:`s`},trigger:{type:`string`,multiple:!0,short:`t`},repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Create a new webhook in a Prismic repository.
1770
+ Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <url>`),process.exitCode=1;return}if(!i){console.error(`Missing required argument: <key>`),process.exitCode=1;return}if(!a){console.error(`Missing required argument: <value>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await P()){ai();return}let o=await Z(n);if(!o.ok){o.error instanceof G?ai():(console.error(`Failed to add header: ${B(o.value)}`),process.exitCode=1);return}let s=o.value.find(e=>e.config.url===r);if(!s){console.error(`Webhook not found: ${r}`),process.exitCode=1;return}let c=structuredClone(s.config);c.headers[i]=a;let l=await Q(n,s.config._id,c);if(!l.ok){l.error instanceof G?ai():(console.error(`Failed to add header: ${B(l.value)}`),process.exitCode=1);return}console.info(`Header added: ${i}`)}function ai(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}const oi=Object.values(X);async function si(){let{values:{help:t,repo:n=await H(),name:r,secret:i,trigger:a=[]},positionals:[o]}=e({args:process.argv.slice(4),options:{name:{type:`string`,short:`n`},secret:{type:`string`,short:`s`},trigger:{type:`string`,multiple:!0,short:`t`},repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Create a new webhook in a Prismic repository.
1793
1771
 
1794
1772
  By default, this command reads the repository from prismic.config.json at the
1795
1773
  project root.
@@ -1818,7 +1796,7 @@ TRIGGERS
1818
1796
  If no triggers specified, all are enabled.
1819
1797
 
1820
1798
  LEARN MORE
1821
- Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!o){console.error(`Missing required argument: <url>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}for(let e of a)if(!di.includes(e)){console.error(`Invalid trigger: ${e}`),console.error(`Valid triggers: ${di.join(`, `)}`),process.exitCode=1;return}if(!await M()){mi();return}let s=!(a.length>0),c={documentsPublished:s,documentsUnpublished:s,releasesCreated:s,releasesUpdated:s,tagsCreated:s,tagsDeleted:s};for(let e of a){let[t]=Object.entries(Z).find(([,t])=>e===t)??[];t&&(c[t]=!0)}let l=await pi(n,{url:o,name:r??null,secret:i??null,...c});if(!l.ok){l.error instanceof K?mi():(console.error(`Failed to create webhook: ${z(l.value)}`),process.exitCode=1);return}console.info(`Webhook created: ${o}`)}async function pi(e,t){let n=new URL(`/app/settings/webhooks/create`,await F(e)),r=new FormData;return r.set(`url`,t.url),r.set(`name`,t.name??``),r.set(`secret`,t.secret??``),r.set(`headers`,JSON.stringify({})),r.set(`active`,`on`),r.set(`documentsPublished`,t.documentsUnpublished.toString()),r.set(`documentsUnpublished`,t.documentsUnpublished.toString()),r.set(`releasesCreated`,t.documentsUnpublished.toString()),r.set(`releasesUpdated`,t.documentsUnpublished.toString()),r.set(`tagsCreated`,t.documentsUnpublished.toString()),r.set(`documentsPublished`,t.documentsUnpublished.toString()),await G(n,{method:`POST`,body:r})}function mi(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function hi(){let{values:{help:t,repo:n=await U()},positionals:[r]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Disable a webhook in a Prismic repository.
1799
+ Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!o){console.error(`Missing required argument: <url>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}for(let e of a)if(!oi.includes(e)){console.error(`Invalid trigger: ${e}`),console.error(`Valid triggers: ${oi.join(`, `)}`),process.exitCode=1;return}if(!await P()){li();return}let s=!(a.length>0),c={documentsPublished:s,documentsUnpublished:s,releasesCreated:s,releasesUpdated:s,tagsCreated:s,tagsDeleted:s};for(let e of a){let[t]=Object.entries(X).find(([,t])=>e===t)??[];t&&(c[t]=!0)}let l=await ci(n,{url:o,name:r??null,secret:i??null,...c});if(!l.ok){l.error instanceof G?li():(console.error(`Failed to create webhook: ${B(l.value)}`),process.exitCode=1);return}console.info(`Webhook created: ${o}`)}async function ci(e,t){let n=new URL(`/app/settings/webhooks/create`,await I(e)),r=new FormData;return r.set(`url`,t.url),r.set(`name`,t.name??``),r.set(`secret`,t.secret??``),r.set(`headers`,JSON.stringify({})),r.set(`active`,`on`),r.set(`documentsPublished`,t.documentsUnpublished.toString()),r.set(`documentsUnpublished`,t.documentsUnpublished.toString()),r.set(`releasesCreated`,t.documentsUnpublished.toString()),r.set(`releasesUpdated`,t.documentsUnpublished.toString()),r.set(`tagsCreated`,t.documentsUnpublished.toString()),r.set(`documentsPublished`,t.documentsUnpublished.toString()),await W(n,{method:`POST`,body:r})}function li(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function ui(){let{values:{help:t,repo:n=await H()},positionals:[r]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Disable a webhook in a Prismic repository.
1822
1800
 
1823
1801
  By default, this command reads the repository from prismic.config.json at the
1824
1802
  project root.
@@ -1834,7 +1812,7 @@ FLAGS
1834
1812
  -h, --help Show help for command
1835
1813
 
1836
1814
  LEARN MORE
1837
- Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <url>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await M()){gi();return}let i=await Q(n);if(!i.ok){i.error instanceof K?gi():(console.error(`Failed to disable webhook: ${z(i.value)}`),process.exitCode=1);return}let a=i.value.find(e=>e.config.url===r);if(!a){console.error(`Webhook not found: ${r}`),process.exitCode=1;return}if(!a.config.active){console.info(`Webhook already disabled: ${r}`);return}let o=structuredClone(a.config);o.active=!1;let s=await $(n,a.config._id,o);if(!s.ok){s.error instanceof K?gi():(console.error(`Failed to disable webhook: ${z(s.value)}`),process.exitCode=1);return}console.info(`Webhook disabled: ${r}`)}function gi(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function _i(){let{values:{help:t,repo:n=await U(),json:r}}=e({args:process.argv.slice(4),options:{json:{type:`boolean`},repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!1});if(t){console.info(`List all webhooks in a Prismic repository.
1815
+ Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <url>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await P()){di();return}let i=await Z(n);if(!i.ok){i.error instanceof G?di():(console.error(`Failed to disable webhook: ${B(i.value)}`),process.exitCode=1);return}let a=i.value.find(e=>e.config.url===r);if(!a){console.error(`Webhook not found: ${r}`),process.exitCode=1;return}if(!a.config.active){console.info(`Webhook already disabled: ${r}`);return}let o=structuredClone(a.config);o.active=!1;let s=await Q(n,a.config._id,o);if(!s.ok){s.error instanceof G?di():(console.error(`Failed to disable webhook: ${B(s.value)}`),process.exitCode=1);return}console.info(`Webhook disabled: ${r}`)}function di(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function fi(){let{values:{help:t,repo:n=await H(),json:r}}=e({args:process.argv.slice(4),options:{json:{type:`boolean`},repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!1});if(t){console.info(`List all webhooks in a Prismic repository.
1838
1816
 
1839
1817
  By default, this command reads the repository from prismic.config.json at the
1840
1818
  project root.
@@ -1848,7 +1826,7 @@ FLAGS
1848
1826
  -h, --help Show help for command
1849
1827
 
1850
1828
  LEARN MORE
1851
- Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await M()){vi();return}let i=await Q(n);if(!i.ok){i.error instanceof K?vi():b(i.error)?(console.error(`Failed to list webhooks: Invalid response: ${z(i.error.issues)}`),process.exitCode=1):(console.error(`Failed to list webhooks: ${z(i.value)}`),process.exitCode=1);return}let a=i.value;if(r)console.info(z(a.map(e=>e.config)));else{if(a.length===0){console.info(`No webhooks configured.`);return}for(let e of a){let t=e.config.active?`enabled`:`disabled`,n=e.config.name?` (${e.config.name})`:``;console.info(`${e.config.url}${n} [${t}]`)}}}function vi(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function yi(){let{values:{help:t,repo:n=await U()},positionals:[r]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Delete a webhook from a Prismic repository.
1829
+ Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await P()){pi();return}let i=await Z(n);if(!i.ok){i.error instanceof G?pi():b(i.error)?(console.error(`Failed to list webhooks: Invalid response: ${B(i.error.issues)}`),process.exitCode=1):(console.error(`Failed to list webhooks: ${B(i.value)}`),process.exitCode=1);return}let a=i.value;if(r)console.info(B(a.map(e=>e.config)));else{if(a.length===0){console.info(`No webhooks configured.`);return}for(let e of a){let t=e.config.active?`enabled`:`disabled`,n=e.config.name?` (${e.config.name})`:``;console.info(`${e.config.url}${n} [${t}]`)}}}function pi(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function mi(){let{values:{help:t,repo:n=await H()},positionals:[r]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Delete a webhook from a Prismic repository.
1852
1830
 
1853
1831
  By default, this command reads the repository from prismic.config.json at the
1854
1832
  project root.
@@ -1864,7 +1842,7 @@ FLAGS
1864
1842
  -h, --help Show help for command
1865
1843
 
1866
1844
  LEARN MORE
1867
- Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <url>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await M()){xi();return}let i=await Q(n);if(!i.ok){i.error instanceof K?xi():(console.error(`Failed to remove webhook: ${z(i.value)}`),process.exitCode=1);return}let a=i.value.find(e=>e.config.url===r);if(!a){console.error(`Webhook not found: ${r}`),process.exitCode=1;return}let o=await bi(n,a.config._id);if(!o.ok){o.error instanceof K?xi():(console.error(`Failed to remove webhook: ${z(o.value)}`),process.exitCode=1);return}console.info(`Webhook removed: ${r}`)}async function bi(e,t){return await G(new URL(`/app/settings/webhooks/${t}/delete`,await F(e)),{method:`POST`})}function xi(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function Si(){let{values:{help:t,repo:n=await U()},positionals:[r,i]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Remove a custom HTTP header from a webhook.
1845
+ Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <url>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await P()){gi();return}let i=await Z(n);if(!i.ok){i.error instanceof G?gi():(console.error(`Failed to remove webhook: ${B(i.value)}`),process.exitCode=1);return}let a=i.value.find(e=>e.config.url===r);if(!a){console.error(`Webhook not found: ${r}`),process.exitCode=1;return}let o=await hi(n,a.config._id);if(!o.ok){o.error instanceof G?gi():(console.error(`Failed to remove webhook: ${B(o.value)}`),process.exitCode=1);return}console.info(`Webhook removed: ${r}`)}async function hi(e,t){return await W(new URL(`/app/settings/webhooks/${t}/delete`,await I(e)),{method:`POST`})}function gi(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function _i(){let{values:{help:t,repo:n=await H()},positionals:[r,i]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Remove a custom HTTP header from a webhook.
1868
1846
 
1869
1847
  By default, this command reads the repository from prismic.config.json at the
1870
1848
  project root.
@@ -1881,7 +1859,7 @@ FLAGS
1881
1859
  -h, --help Show help for command
1882
1860
 
1883
1861
  LEARN MORE
1884
- Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <url>`),process.exitCode=1;return}if(!i){console.error(`Missing required argument: <key>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await M()){Ci();return}let a=await Q(n);if(!a.ok){a.error instanceof K?Ci():(console.error(`Failed to remove header: ${z(a.value)}`),process.exitCode=1);return}let o=a.value.find(e=>e.config.url===r);if(!o){console.error(`Webhook not found: ${r}`),process.exitCode=1;return}if(!(i in o.config.headers)){console.error(`Header not found: ${i}`),process.exitCode=1;return}let s=structuredClone(o.config);delete s.headers[i];let c=await $(n,o.config._id,s);if(!c.ok){c.error instanceof K?Ci():(console.error(`Failed to remove header: ${z(c.value)}`),process.exitCode=1);return}console.info(`Header removed: ${i}`)}function Ci(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}const wi=Object.values(Z);async function Ti(){let{values:{help:t,repo:n=await U(),trigger:r},positionals:[i]}=e({args:process.argv.slice(4),options:{trigger:{type:`string`,multiple:!0,short:`t`},repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Update which events trigger a webhook.
1862
+ Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <url>`),process.exitCode=1;return}if(!i){console.error(`Missing required argument: <key>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await P()){vi();return}let a=await Z(n);if(!a.ok){a.error instanceof G?vi():(console.error(`Failed to remove header: ${B(a.value)}`),process.exitCode=1);return}let o=a.value.find(e=>e.config.url===r);if(!o){console.error(`Webhook not found: ${r}`),process.exitCode=1;return}if(!(i in o.config.headers)){console.error(`Header not found: ${i}`),process.exitCode=1;return}let s=structuredClone(o.config);delete s.headers[i];let c=await Q(n,o.config._id,s);if(!c.ok){c.error instanceof G?vi():(console.error(`Failed to remove header: ${B(c.value)}`),process.exitCode=1);return}console.info(`Header removed: ${i}`)}function vi(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}const yi=Object.values(X);async function bi(){let{values:{help:t,repo:n=await H(),trigger:r},positionals:[i]}=e({args:process.argv.slice(4),options:{trigger:{type:`string`,multiple:!0,short:`t`},repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Update which events trigger a webhook.
1885
1863
 
1886
1864
  By default, this command reads the repository from prismic.config.json at the
1887
1865
  project root.
@@ -1906,7 +1884,7 @@ TRIGGERS
1906
1884
  tag.deleted When a tag is deleted
1907
1885
 
1908
1886
  LEARN MORE
1909
- Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!i){console.error(`Missing required argument: <url>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!r||r.length===0){console.error(`Missing required option: --trigger`),process.exitCode=1;return}for(let e of r)if(!wi.includes(e)){console.error(`Invalid trigger: ${e}`),console.error(`Valid triggers: ${wi.join(`, `)}`),process.exitCode=1;return}if(!await M()){Ei();return}let a=await Q(n);if(!a.ok){a.error instanceof K?Ei():(console.error(`Failed to update webhook triggers: ${z(a.value)}`),process.exitCode=1);return}let o=a.value.find(e=>e.config.url===i);if(!o){console.error(`Webhook not found: ${i}`),process.exitCode=1;return}let s=!(r.length>0),c={documentsPublished:s,documentsUnpublished:s,releasesCreated:s,releasesUpdated:s,tagsCreated:s,tagsDeleted:s};for(let e of r){let[t]=Object.entries(Z).find(([,t])=>e===t)??[];t&&(c[t]=!0)}let l=await $(n,o.config._id,{...o.config,...c});if(!l.ok){l.error instanceof K?Ei():(console.error(`Failed to update webhook triggers: ${z(l.value)}`),process.exitCode=1);return}console.info(`Webhook triggers updated: ${r.join(`, `)}`)}function Ei(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function Di(){let{values:{help:t,repo:n=await U()},positionals:[r]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Show the enabled/disabled status of a webhook.
1887
+ Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!i){console.error(`Missing required argument: <url>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!r||r.length===0){console.error(`Missing required option: --trigger`),process.exitCode=1;return}for(let e of r)if(!yi.includes(e)){console.error(`Invalid trigger: ${e}`),console.error(`Valid triggers: ${yi.join(`, `)}`),process.exitCode=1;return}if(!await P()){xi();return}let a=await Z(n);if(!a.ok){a.error instanceof G?xi():(console.error(`Failed to update webhook triggers: ${B(a.value)}`),process.exitCode=1);return}let o=a.value.find(e=>e.config.url===i);if(!o){console.error(`Webhook not found: ${i}`),process.exitCode=1;return}let s=!(r.length>0),c={documentsPublished:s,documentsUnpublished:s,releasesCreated:s,releasesUpdated:s,tagsCreated:s,tagsDeleted:s};for(let e of r){let[t]=Object.entries(X).find(([,t])=>e===t)??[];t&&(c[t]=!0)}let l=await Q(n,o.config._id,{...o.config,...c});if(!l.ok){l.error instanceof G?xi():(console.error(`Failed to update webhook triggers: ${B(l.value)}`),process.exitCode=1);return}console.info(`Webhook triggers updated: ${r.join(`, `)}`)}function xi(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function Si(){let{values:{help:t,repo:n=await H()},positionals:[r]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Show the enabled/disabled status of a webhook.
1910
1888
 
1911
1889
  By default, this command reads the repository from prismic.config.json at the
1912
1890
  project root.
@@ -1922,7 +1900,7 @@ FLAGS
1922
1900
  -h, --help Show help for command
1923
1901
 
1924
1902
  LEARN MORE
1925
- Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <url>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await M()){Oi();return}let i=await Q(n);if(!i.ok){i.error instanceof K?Oi():(console.error(`Failed to get webhook status: ${z(i.value)}`),process.exitCode=1);return}let a=i.value.find(e=>e.config.url===r);if(!a){console.error(`Webhook not found: ${r}`),process.exitCode=1;return}let o=a.config.active?`enabled`:`disabled`;console.info(o)}function Oi(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function ki(){let{values:{help:t,repo:n=await U()},positionals:[r]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Trigger a test webhook in a Prismic repository.
1903
+ Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <url>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await P()){Ci();return}let i=await Z(n);if(!i.ok){i.error instanceof G?Ci():(console.error(`Failed to get webhook status: ${B(i.value)}`),process.exitCode=1);return}let a=i.value.find(e=>e.config.url===r);if(!a){console.error(`Webhook not found: ${r}`),process.exitCode=1;return}let o=a.config.active?`enabled`:`disabled`;console.info(o)}function Ci(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function wi(){let{values:{help:t,repo:n=await H()},positionals:[r]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Trigger a test webhook in a Prismic repository.
1926
1904
 
1927
1905
  By default, this command reads the repository from prismic.config.json at the
1928
1906
  project root.
@@ -1938,7 +1916,7 @@ FLAGS
1938
1916
  -h, --help Show help for command
1939
1917
 
1940
1918
  LEARN MORE
1941
- Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <url>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await M()){ji();return}let i=await Q(n);if(!i.ok){i.error instanceof K?ji():(console.error(`Failed to test webhook: ${z(i.value)}`),process.exitCode=1);return}let a=i.value.find(e=>e.config.url===r);if(!a){console.error(`Webhook not found: ${r}`),process.exitCode=1;return}let o=await Ai(n,a.config._id);if(!o.ok){o.error instanceof K?ji():(console.error(`Failed to test webhook: ${z(o.value)}`),process.exitCode=1);return}console.info(`Test webhook triggered: ${r}`)}async function Ai(e,t){return await G(new URL(`/app/settings/webhooks/${t}/trigger`,await F(e)),{method:`POST`})}function ji(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function Mi(){let{positionals:[t]}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`list`:await _i();break;case`create`:await fi();break;case`view`:await ii();break;case`remove`:await yi();break;case`test`:await ki();break;case`enable`:await si();break;case`disable`:await hi();break;case`status`:await Di();break;case`add-header`:await li();break;case`remove-header`:await Si();break;case`set-triggers`:await Ti();break;default:t&&(console.error(`Unknown webhook subcommand: ${t}\n`),process.exitCode=1),console.info(`Manage webhooks in a Prismic repository.
1919
+ Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <url>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await P()){Ei();return}let i=await Z(n);if(!i.ok){i.error instanceof G?Ei():(console.error(`Failed to test webhook: ${B(i.value)}`),process.exitCode=1);return}let a=i.value.find(e=>e.config.url===r);if(!a){console.error(`Webhook not found: ${r}`),process.exitCode=1;return}let o=await Ti(n,a.config._id);if(!o.ok){o.error instanceof G?Ei():(console.error(`Failed to test webhook: ${B(o.value)}`),process.exitCode=1);return}console.info(`Test webhook triggered: ${r}`)}async function Ti(e,t){return await W(new URL(`/app/settings/webhooks/${t}/trigger`,await I(e)),{method:`POST`})}function Ei(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function Di(){let{positionals:[t]}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`list`:await fi();break;case`create`:await si();break;case`view`:await $r();break;case`remove`:await mi();break;case`test`:await wi();break;case`enable`:await ni();break;case`disable`:await ui();break;case`status`:await Si();break;case`add-header`:await ii();break;case`remove-header`:await _i();break;case`set-triggers`:await bi();break;default:t&&(console.error(`Unknown webhook subcommand: ${t}\n`),process.exitCode=1),console.info(`Manage webhooks in a Prismic repository.
1942
1920
 
1943
1921
  USAGE
1944
1922
  prismic webhook <command> [flags]
@@ -1960,7 +1938,7 @@ FLAGS
1960
1938
  -h, --help Show help for command
1961
1939
 
1962
1940
  LEARN MORE
1963
- Use \`prismic webhook <command> --help\` for more information about a command.`)}}async function Ni(){let{values:{help:t}}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}}});if(t){console.info(`Show the currently logged in user.
1941
+ Use \`prismic webhook <command> --help\` for more information about a command.`)}}async function Oi(){let{values:{help:t}}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}}});if(t){console.info(`Show the currently logged in user.
1964
1942
 
1965
1943
  USAGE
1966
1944
  prismic whoami [flags]
@@ -1969,7 +1947,7 @@ FLAGS
1969
1947
  -h, --help Show help for command
1970
1948
 
1971
1949
  LEARN MORE
1972
- Use \`prismic <command> --help\` for more information about a command.`);return}if(!await M()){Fi();return}let n=await Pi();if(!n.ok){n.error instanceof K?Fi():console.error(`Failed to fetch user profile.`),process.exitCode=1;return}console.info(n.value.email)}async function Pi(){return await G(new URL(`profile`,await fe()),{schema:T({email:O()})})}function Fi(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}const{positionals:Ii}=e({options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(Ii[0]){case`init`:await ht();break;case`login`:await Mt();break;case`logout`:await Ft();break;case`whoami`:await Ni();break;case`repo`:await or();break;case`locale`:await jt();break;case`page-type`:await On();break;case`custom-type`:await at();break;case`slice`:await Nr();break;case`sync`:await Fr();break;case`preview`:await Un();break;case`token`:await ri();break;case`webhook`:await Mi();break;default:Ii[0]&&(console.error(`Unknown command: ${Ii[0]}`),process.exitCode=1),console.info(`Prismic CLI for managing repositories and configurations.
1950
+ Use \`prismic <command> --help\` for more information about a command.`);return}if(!await P()){Ai();return}let n=await ki();if(!n.ok){n.error instanceof G?Ai():console.error(`Failed to fetch user profile.`),process.exitCode=1;return}console.info(n.value.email)}async function ki(){return await W(new URL(`profile`,await de()),{schema:E({email:k()})})}function Ai(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}const{positionals:$}=e({options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch($[0]){case`init`:await gt();break;case`login`:await Nt();break;case`logout`:await It();break;case`whoami`:await Oi();break;case`repo`:await sr();break;case`locale`:await Mt();break;case`page-type`:await kn();break;case`custom-type`:await ot();break;case`slice`:await Pr();break;case`preview`:await Wn();break;case`token`:await Qr();break;case`webhook`:await Di();break;default:$[0]&&(console.error(`Unknown command: ${$[0]}`),process.exitCode=1),console.info(`Prismic CLI for managing repositories and configurations.
1973
1951
 
1974
1952
  USAGE
1975
1953
  prismic <command> [flags]
@@ -1984,7 +1962,6 @@ COMMANDS
1984
1962
  page-type Manage page types in a repository
1985
1963
  custom-type Manage custom types in a repository
1986
1964
  slice Manage slices in a project
1987
- sync Sync types and slices from Prismic
1988
1965
  preview Manage preview configurations
1989
1966
  token Manage API tokens in a repository
1990
1967
  webhook Manage webhooks in a repository