@angeloashmore/prismic-cli-poc 0.0.0-canary.6fd8413 → 0.0.0-canary.e58e691

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/dist/index.mjs +170 -451
  2. package/package.json +1 -2
  3. package/src/custom-type-add-field-boolean.ts +2 -3
  4. package/src/custom-type-add-field-color.ts +2 -3
  5. package/src/custom-type-add-field-date.ts +2 -3
  6. package/src/custom-type-add-field-embed.ts +2 -3
  7. package/src/custom-type-add-field-geo-point.ts +2 -3
  8. package/src/custom-type-add-field-image.ts +2 -3
  9. package/src/custom-type-add-field-key-text.ts +2 -3
  10. package/src/custom-type-add-field-link.ts +2 -3
  11. package/src/custom-type-add-field-number.ts +2 -3
  12. package/src/custom-type-add-field-rich-text.ts +2 -3
  13. package/src/custom-type-add-field-select.ts +2 -3
  14. package/src/custom-type-add-field-timestamp.ts +2 -3
  15. package/src/custom-type-add-field-uid.ts +2 -3
  16. package/src/index.ts +0 -5
  17. package/src/page-type-add-field-boolean.ts +2 -3
  18. package/src/page-type-add-field-color.ts +2 -3
  19. package/src/page-type-add-field-date.ts +2 -3
  20. package/src/page-type-add-field-embed.ts +2 -3
  21. package/src/page-type-add-field-geo-point.ts +2 -3
  22. package/src/page-type-add-field-image.ts +2 -3
  23. package/src/page-type-add-field-key-text.ts +2 -3
  24. package/src/page-type-add-field-link.ts +2 -3
  25. package/src/page-type-add-field-number.ts +2 -3
  26. package/src/page-type-add-field-rich-text.ts +2 -3
  27. package/src/page-type-add-field-select.ts +2 -3
  28. package/src/page-type-add-field-timestamp.ts +2 -3
  29. package/src/page-type-add-field-uid.ts +2 -3
  30. package/src/preview.ts +4 -19
  31. package/src/repo.ts +0 -10
  32. package/src/slice-add-field-boolean.ts +2 -3
  33. package/src/slice-add-field-color.ts +2 -3
  34. package/src/slice-add-field-date.ts +2 -3
  35. package/src/slice-add-field-embed.ts +2 -3
  36. package/src/slice-add-field-geo-point.ts +2 -3
  37. package/src/slice-add-field-image.ts +2 -3
  38. package/src/slice-add-field-key-text.ts +2 -3
  39. package/src/slice-add-field-link.ts +2 -3
  40. package/src/slice-add-field-number.ts +2 -3
  41. package/src/slice-add-field-rich-text.ts +2 -3
  42. package/src/slice-add-field-select.ts +2 -3
  43. package/src/slice-add-field-timestamp.ts +2 -3
  44. package/src/codegen-types.ts +0 -105
  45. package/src/codegen.ts +0 -45
  46. package/src/lib/string.ts +0 -6
  47. package/src/preview-get-simulator.ts +0 -106
  48. package/src/preview-remove-simulator.ts +0 -80
  49. package/src/preview-set-simulator.ts +0 -116
  50. package/src/repo-get-access.ts +0 -89
  51. package/src/repo-set-access.ts +0 -104
package/dist/index.mjs CHANGED
@@ -1,215 +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*as c from"node:crypto";import{homedir as l}from"node:os";import{pathToFileURL as u}from"node:url";import{exec as d}from"node:child_process";import{createServer as f}from"node:http";var p=Object.defineProperty,m=Object.getOwnPropertyDescriptor,h=Object.getOwnPropertyNames,g=Object.prototype.hasOwnProperty,_=(e,t)=>()=>(e&&(t=e(e=0)),t),v=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),y=(e,t)=>{let n={};for(var r in e)p(n,r,{get:e[r],enumerable:!0});return t&&p(n,Symbol.toStringTag,{value:`Module`}),n},ee=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=h(t),a=0,o=i.length,s;a<o;a++)s=i[a],!g.call(e,s)&&s!==n&&p(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=m(t,s))||r.enumerable});return e},b=e=>g.call(e,`module.exports`)?e[`module.exports`]:ee(p({},`__esModule`,{value:!0}),e),te=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});var n=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),r=i([``,``],[``,``]);function i(e,t){return Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function a(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}e.default=function(){function e(){var t=this,n=[...arguments];return a(this,e),this.tag=function(e){var n=[...arguments].slice(1);return typeof e==`function`?t.interimTag.bind(t,e):typeof e==`string`?t.transformEndResult(e):(e=e.map(t.transformString.bind(t)),t.transformEndResult(e.reduce(t.processSubstitutions.bind(t,n))))},n.length>0&&Array.isArray(n[0])&&(n=n[0]),this.transformers=n.map(function(e){return typeof e==`function`?e():e}),this.tag}return n(e,[{key:`interimTag`,value:function(e,t){var n=[...arguments].slice(2);return this.tag(r,e.apply(void 0,[t].concat(n)))}},{key:`processSubstitutions`,value:function(e,t,n){return`${t}${this.transformSubstitution(e.shift(),t)}${n}`}},{key:`transformString`,value:function(e){return this.transformers.reduce(function(e,t){return t.onString?t.onString(e):e},e)}},{key:`transformSubstitution`,value:function(e,t){return this.transformers.reduce(function(e,n){return n.onSubstitution?n.onSubstitution(e,t):e},e)}},{key:`transformEndResult`,value:function(e){return this.transformers.reduce(function(e,t){return t.onEndResult?t.onEndResult(e):e},e)}}]),e}(),t.exports=e.default})),x=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(te());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),ne=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:``;return{onEndResult:function(t){if(e===``)return t.trim();if(e=e.toLowerCase(),e===`start`||e===`left`)return t.replace(/^\s*/,``);if(e===`end`||e===`right`)return t.replace(/\s*$/,``);throw Error(`Side not supported: `+e)}}},t.exports=e.default})),S=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(ne());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),re=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});function n(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}else return Array.from(e)}e.default=function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:`initial`;return{onEndResult:function(t){if(e===`initial`){var r=t.match(/^[^\S\n]*(?=\S)/gm),i=r&&Math.min.apply(Math,n(r.map(function(e){return e.length})));if(i){var a=RegExp(`^.{`+i+`}`,`gm`);return t.replace(a,``)}return t}if(e===`all`)return t.replace(/^[^\S\n]+/gm,``);throw Error(`Unknown type: `+e)}}},t.exports=e.default})),C=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(re());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),ie=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=function(e,t){return{onEndResult:function(n){if(e==null||t==null)throw Error(`replaceResultTransformer requires at least 2 arguments.`);return n.replace(e,t)}}},t.exports=e.default})),ae=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(ie());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),w=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=function(e,t){return{onSubstitution:function(n,r){if(e==null||t==null)throw Error(`replaceSubstitutionTransformer requires at least 2 arguments.`);return n==null?n:n.toString().replace(e,t)}}},t.exports=e.default})),oe=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(w());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),se=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=function(e,t){return{onString:function(n){if(e==null||t==null)throw Error(`replaceStringTransformer requires at least 2 arguments.`);return n.replace(e,t)}}},t.exports=e.default})),ce=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(se());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),le=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});var n={separator:``,conjunction:``,serial:!1};e.default=function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:n;return{onSubstitution:function(t,n){if(Array.isArray(t)){var r=t.length,i=e.separator,a=e.conjunction,o=e.serial,s=n.match(/(\n?[^\S\n]+)$/);if(t=s?t.join(i+s[1]):t.join(i+` `),a&&r>1){var c=t.lastIndexOf(i);t=t.slice(0,c)+(o?i:``)+` `+a+t.slice(c+1)}}return t}}},t.exports=e.default})),T=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(le());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),ue=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=function(e){return{onSubstitution:function(t,n){if(e!=null&&typeof e==`string`)typeof t==`string`&&t.includes(e)&&(t=t.split(e));else throw Error(`You need to specify a string character to split by.`);return t}}},t.exports=e.default})),de=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(ue());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),fe=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});var n=function(e){return e!=null&&!Number.isNaN(e)&&typeof e!=`boolean`};e.default=function(){return{onSubstitution:function(e){return Array.isArray(e)?e.filter(n):n(e)?e:``}}},t.exports=e.default})),pe=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(fe());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),me=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});var n=o(x()),r=o(C()),i=o(T()),a=o(S());function o(e){return e&&e.__esModule?e:{default:e}}e.default=new n.default((0,i.default)({separator:`,`}),r.default,a.default),t.exports=e.default})),he=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(me());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),ge=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});var n=o(x()),r=o(C()),i=o(T()),a=o(S());function o(e){return e&&e.__esModule?e:{default:e}}e.default=new n.default((0,i.default)({separator:`,`,conjunction:`and`}),r.default,a.default),t.exports=e.default})),_e=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(ge());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),ve=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});var n=o(x()),r=o(C()),i=o(T()),a=o(S());function o(e){return e&&e.__esModule?e:{default:e}}e.default=new n.default((0,i.default)({separator:`,`,conjunction:`or`}),r.default,a.default),t.exports=e.default})),ye=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(ve());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),be=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});var n=c(x()),r=c(C()),i=c(T()),a=c(S()),o=c(de()),s=c(pe());function c(e){return e&&e.__esModule?e:{default:e}}e.default=new n.default((0,o.default)(`
3
- `),s.default,i.default,r.default,a.default),t.exports=e.default})),xe=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(be());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),Se=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(xe());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),Ce=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(xe());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),we=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});var n=c(x()),r=c(C()),i=c(T()),a=c(S()),o=c(de()),s=c(oe());function c(e){return e&&e.__esModule?e:{default:e}}e.default=new n.default((0,o.default)(`
4
- `),i.default,r.default,a.default,(0,s.default)(/&/g,`&amp;`),(0,s.default)(/</g,`&lt;`),(0,s.default)(/>/g,`&gt;`),(0,s.default)(/"/g,`&quot;`),(0,s.default)(/'/g,`&#x27;`),(0,s.default)(/`/g,`&#x60;`)),t.exports=e.default})),Te=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(we());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),Ee=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});var n=a(x()),r=a(S()),i=a(ae());function a(e){return e&&e.__esModule?e:{default:e}}e.default=new n.default((0,i.default)(/(?:\n(?:\s*))+/g,` `),r.default),t.exports=e.default})),De=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(Ee());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),Oe=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});var n=a(x()),r=a(S()),i=a(ae());function a(e){return e&&e.__esModule?e:{default:e}}e.default=new n.default((0,i.default)(/(?:\n\s*)/g,``),r.default),t.exports=e.default})),ke=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(Oe());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),Ae=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});var n=o(x()),r=o(T()),i=o(S()),a=o(ae());function o(e){return e&&e.__esModule?e:{default:e}}e.default=new n.default((0,r.default)({separator:`,`}),(0,a.default)(/(?:\s+)/g,` `),i.default),t.exports=e.default})),je=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(Ae());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),Me=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});var n=o(x()),r=o(T()),i=o(S()),a=o(ae());function o(e){return e&&e.__esModule?e:{default:e}}e.default=new n.default((0,r.default)({separator:`,`,conjunction:`or`}),(0,a.default)(/(?:\s+)/g,` `),i.default),t.exports=e.default})),Ne=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(Me());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),Pe=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});var n=o(x()),r=o(T()),i=o(S()),a=o(ae());function o(e){return e&&e.__esModule?e:{default:e}}e.default=new n.default((0,r.default)({separator:`,`,conjunction:`and`}),(0,a.default)(/(?:\s+)/g,` `),i.default),t.exports=e.default})),Fe=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(Pe());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),Ie=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});var n=o(x()),r=o(C()),i=o(T()),a=o(S());function o(e){return e&&e.__esModule?e:{default:e}}e.default=new n.default(i.default,r.default,a.default),t.exports=e.default})),Le=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(Ie());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),Re=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});var n=o(x()),r=o(T()),i=o(S()),a=o(ae());function o(e){return e&&e.__esModule?e:{default:e}}e.default=new n.default(r.default,(0,a.default)(/(?:\s+)/g,` `),i.default),t.exports=e.default})),ze=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(Re());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),Be=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});var n=a(x()),r=a(C()),i=a(S());function a(e){return e&&e.__esModule?e:{default:e}}e.default=new n.default(r.default,i.default),t.exports=e.default})),Ve=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(Be());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),He=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});var n=a(x()),r=a(C()),i=a(S());function a(e){return e&&e.__esModule?e:{default:e}}e.default=new n.default((0,r.default)(`all`),i.default),t.exports=e.default})),Ue=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(He());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),E=v((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.stripIndents=e.stripIndent=e.oneLineInlineLists=e.inlineLists=e.oneLineCommaListsAnd=e.oneLineCommaListsOr=e.oneLineCommaLists=e.oneLineTrim=e.oneLine=e.safeHtml=e.source=e.codeBlock=e.html=e.commaListsOr=e.commaListsAnd=e.commaLists=e.removeNonPrintingValuesTransformer=e.splitStringTransformer=e.inlineArrayTransformer=e.replaceStringTransformer=e.replaceSubstitutionTransformer=e.replaceResultTransformer=e.stripIndentTransformer=e.trimResultTransformer=e.TemplateTag=void 0;var t=w(x()),n=w(S()),r=w(C()),i=w(ae()),a=w(oe()),o=w(ce()),s=w(T()),c=w(de()),l=w(pe()),u=w(he()),d=w(_e()),f=w(ye()),p=w(xe()),m=w(Se()),h=w(Ce()),g=w(Te()),_=w(De()),v=w(ke()),y=w(je()),ee=w(Ne()),b=w(Fe()),te=w(Le()),ne=w(ze()),re=w(Ve()),ie=w(Ue());function w(e){return e&&e.__esModule?e:{default:e}}e.TemplateTag=t.default,e.trimResultTransformer=n.default,e.stripIndentTransformer=r.default,e.replaceResultTransformer=i.default,e.replaceSubstitutionTransformer=a.default,e.replaceStringTransformer=o.default,e.inlineArrayTransformer=s.default,e.splitStringTransformer=c.default,e.removeNonPrintingValuesTransformer=l.default,e.commaLists=u.default,e.commaListsAnd=d.default,e.commaListsOr=f.default,e.html=p.default,e.codeBlock=m.default,e.source=h.default,e.safeHtml=g.default,e.oneLine=_.default,e.oneLineTrim=v.default,e.oneLineCommaLists=y.default,e.oneLineCommaListsOr=ee.default,e.oneLineCommaListsAnd=b.default,e.inlineLists=te.default,e.oneLineInlineLists=ne.default,e.stripIndent=re.default,e.stripIndents=ie.default}))(),We=class extends Map{constructor(e={}){if(super(),!(e.maxSize&&e.maxSize>0))throw TypeError("`maxSize` must be a number greater than 0");if(typeof e.maxAge==`number`&&e.maxAge===0)throw TypeError("`maxAge` must be a number greater than 0");this.maxSize=e.maxSize,this.maxAge=e.maxAge||1/0,this.onEviction=e.onEviction,this.cache=new Map,this.oldCache=new Map,this._size=0}_emitEvictions(e){if(typeof this.onEviction==`function`)for(let[t,n]of e)this.onEviction(t,n.value)}_deleteIfExpired(e,t){return typeof t.expiry==`number`&&t.expiry<=Date.now()?(typeof this.onEviction==`function`&&this.onEviction(e,t.value),this.delete(e)):!1}_getOrDeleteIfExpired(e,t){if(this._deleteIfExpired(e,t)===!1)return t.value}_getItemValue(e,t){return t.expiry?this._getOrDeleteIfExpired(e,t):t.value}_peek(e,t){let n=t.get(e);return this._getItemValue(e,n)}_set(e,t){this.cache.set(e,t),this._size++,this._size>=this.maxSize&&(this._size=0,this._emitEvictions(this.oldCache),this.oldCache=this.cache,this.cache=new Map)}_moveToRecent(e,t){this.oldCache.delete(e),this._set(e,t)}*_entriesAscending(){for(let e of this.oldCache){let[t,n]=e;this.cache.has(t)||this._deleteIfExpired(t,n)===!1&&(yield e)}for(let e of this.cache){let[t,n]=e;this._deleteIfExpired(t,n)===!1&&(yield e)}}get(e){if(this.cache.has(e)){let t=this.cache.get(e);return this._getItemValue(e,t)}if(this.oldCache.has(e)){let t=this.oldCache.get(e);if(this._deleteIfExpired(e,t)===!1)return this._moveToRecent(e,t),t.value}}set(e,t,{maxAge:n=this.maxAge}={}){let r=typeof n==`number`&&n!==1/0?Date.now()+n:void 0;return this.cache.has(e)?this.cache.set(e,{value:t,expiry:r}):this._set(e,{value:t,expiry:r}),this}has(e){return this.cache.has(e)?!this._deleteIfExpired(e,this.cache.get(e)):this.oldCache.has(e)?!this._deleteIfExpired(e,this.oldCache.get(e)):!1}peek(e){if(this.cache.has(e))return this._peek(e,this.cache);if(this.oldCache.has(e))return this._peek(e,this.oldCache)}delete(e){let t=this.cache.delete(e);return t&&this._size--,this.oldCache.delete(e)||t}clear(){this.cache.clear(),this.oldCache.clear(),this._size=0}resize(e){if(!(e&&e>0))throw TypeError("`maxSize` must be a number greater than 0");let t=[...this._entriesAscending()],n=t.length-e;n<0?(this.cache=new Map(t),this.oldCache=new Map,this._size=t.length):(n>0&&this._emitEvictions(t.slice(0,n)),this.oldCache=new Map(t.slice(n)),this.cache=new Map,this._size=0),this.maxSize=e}*keys(){for(let[e]of this)yield e}*values(){for(let[,e]of this)yield e}*[Symbol.iterator](){for(let e of this.cache){let[t,n]=e;this._deleteIfExpired(t,n)===!1&&(yield[t,n.value])}for(let e of this.oldCache){let[t,n]=e;this.cache.has(t)||this._deleteIfExpired(t,n)===!1&&(yield[t,n.value])}}*entriesDescending(){let e=[...this.cache];for(let t=e.length-1;t>=0;--t){let[n,r]=e[t];this._deleteIfExpired(n,r)===!1&&(yield[n,r.value])}e=[...this.oldCache];for(let t=e.length-1;t>=0;--t){let[n,r]=e[t];this.cache.has(n)||this._deleteIfExpired(n,r)===!1&&(yield[n,r.value])}}*entriesAscending(){for(let[e,t]of this._entriesAscending())yield[e,t.value]}get size(){if(!this._size)return this.oldCache.size;let e=0;for(let t of this.oldCache.keys())this.cache.has(t)||e++;return Math.min(this._size+e,this.maxSize)}entries(){return this.entriesAscending()}forEach(e,t=this){for(let[n,r]of this.entriesAscending())e.call(t,r,n,this)}get[Symbol.toStringTag](){return JSON.stringify([...this.entriesAscending()])}};function Ge(e,t){return(!e||e.endsWith(`
5
- `))&&!t?.force?e:e+`
6
- `}function D(e,t){return Ge(t)+e}function Ke(e,t){return(!e||e.endsWith(`
7
-
8
- `))&&!t?.force?e:Ge(e)+`
9
- `}function O(e,t){return Ke(t)+e}const qe=`https://prismic.io/docs/slices`,Je={UID:`https://prismic.io/docs/fields/uid`,Boolean:`https://prismic.io/docs/fields/boolean`,Color:`https://prismic.io/docs/fields/color`,Date:`https://prismic.io/docs/fields/date`,Timestamp:`https://prismic.io/docs/fields/timestamp`,Number:`https://prismic.io/docs/fields/number`,Text:`https://prismic.io/docs/fields/text`,Select:`https://prismic.io/docs/fields/select`,StructuredText:`https://prismic.io/docs/fields/rich-text`,Image:`https://prismic.io/docs/fields/image`,Link:{contentRelationship:`https://prismic.io/docs/fields/content-relationship`,link:`https://prismic.io/docs/fields/link`,linkToMedia:`https://prismic.io/docs/fields/link-to-media`},Embed:`https://prismic.io/docs/fields/embed`,GeoPoint:`https://prismic.io/docs/fields/geopoint`,Table:`https://prismic.io/docs/fields/table`,Group:`https://prismic.io/docs/fields/repeatable-group`,IntegrationFields:`https://prismic.io/docs/fields/integration`,Slices:`https://prismic.io/docs/slices`,Choice:`https://prismic.io/docs/slices`};var Ye=y({__addDisposableResource:()=>Ct,__assign:()=>Dt,__asyncDelegator:()=>ht,__asyncGenerator:()=>mt,__asyncValues:()=>gt,__await:()=>pt,__awaiter:()=>at,__classPrivateFieldGet:()=>bt,__classPrivateFieldIn:()=>St,__classPrivateFieldSet:()=>xt,__createBinding:()=>Ot,__decorate:()=>Qe,__disposeResources:()=>wt,__esDecorate:()=>et,__exportStar:()=>st,__extends:()=>Xe,__generator:()=>ot,__importDefault:()=>yt,__importStar:()=>vt,__makeTemplateObject:()=>_t,__metadata:()=>it,__param:()=>$e,__propKey:()=>nt,__read:()=>lt,__rest:()=>Ze,__rewriteRelativeImportExtension:()=>Tt,__runInitializers:()=>tt,__setFunctionName:()=>rt,__spread:()=>ut,__spreadArray:()=>ft,__spreadArrays:()=>dt,__values:()=>ct,default:()=>Mt});function Xe(e,t){if(typeof t!=`function`&&t!==null)throw TypeError(`Class extends value `+String(t)+` is not a constructor or null`);Et(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}function Ze(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n}function Qe(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}function $e(e,t){return function(n,r){t(n,r,e)}}function et(e,t,n,r,i,a){function o(e){if(e!==void 0&&typeof e!=`function`)throw TypeError(`Function expected`);return e}for(var s=r.kind,c=s===`getter`?`get`:s===`setter`?`set`:`value`,l=!t&&e?r.static?e:e.prototype:null,u=t||(l?Object.getOwnPropertyDescriptor(l,r.name):{}),d,f=!1,p=n.length-1;p>=0;p--){var m={};for(var h in r)m[h]=h===`access`?{}:r[h];for(var h in r.access)m.access[h]=r.access[h];m.addInitializer=function(e){if(f)throw TypeError(`Cannot add initializers after decoration has completed`);a.push(o(e||null))};var g=(0,n[p])(s===`accessor`?{get:u.get,set:u.set}:u[c],m);if(s===`accessor`){if(g===void 0)continue;if(typeof g!=`object`||!g)throw TypeError(`Object expected`);(d=o(g.get))&&(u.get=d),(d=o(g.set))&&(u.set=d),(d=o(g.init))&&i.unshift(d)}else (d=o(g))&&(s===`field`?i.unshift(d):u[c]=d)}l&&Object.defineProperty(l,r.name,u),f=!0}function tt(e,t,n){for(var r=arguments.length>2,i=0;i<t.length;i++)n=r?t[i].call(e,n):t[i].call(e);return r?n:void 0}function nt(e){return typeof e==`symbol`?e:`${e}`}function rt(e,t,n){return typeof t==`symbol`&&(t=t.description?`[${t.description}]`:``),Object.defineProperty(e,`name`,{configurable:!0,value:n?`${n} ${t}`:t})}function it(e,t){if(typeof Reflect==`object`&&typeof Reflect.metadata==`function`)return Reflect.metadata(e,t)}function at(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})}function ot(e,t){var n={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},r,i,a,o=Object.create((typeof Iterator==`function`?Iterator:Object).prototype);return o.next=s(0),o.throw=s(1),o.return=s(2),typeof Symbol==`function`&&(o[Symbol.iterator]=function(){return this}),o;function s(e){return function(t){return c([e,t])}}function c(s){if(r)throw TypeError(`Generator is already executing.`);for(;o&&(o=0,s[0]&&(n=0)),n;)try{if(r=1,i&&(a=s[0]&2?i.return:s[0]?i.throw||((a=i.return)&&a.call(i),0):i.next)&&!(a=a.call(i,s[1])).done)return a;switch(i=0,a&&(s=[s[0]&2,a.value]),s[0]){case 0:case 1:a=s;break;case 4:return n.label++,{value:s[1],done:!1};case 5:n.label++,i=s[1],s=[0];continue;case 7:s=n.ops.pop(),n.trys.pop();continue;default:if((a=n.trys,!(a=a.length>0&&a[a.length-1]))&&(s[0]===6||s[0]===2)){n=0;continue}if(s[0]===3&&(!a||s[1]>a[0]&&s[1]<a[3])){n.label=s[1];break}if(s[0]===6&&n.label<a[1]){n.label=a[1],a=s;break}if(a&&n.label<a[2]){n.label=a[2],n.ops.push(s);break}a[2]&&n.ops.pop(),n.trys.pop();continue}s=t.call(e,n)}catch(e){s=[6,e],i=0}finally{r=a=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}}function st(e,t){for(var n in e)n!==`default`&&!Object.prototype.hasOwnProperty.call(t,n)&&Ot(t,e,n)}function ct(e){var t=typeof Symbol==`function`&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&typeof e.length==`number`)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw TypeError(t?`Object is not iterable.`:`Symbol.iterator is not defined.`)}function lt(e,t){var n=typeof Symbol==`function`&&e[Symbol.iterator];if(!n)return e;var r=n.call(e),i,a=[],o;try{for(;(t===void 0||t-- >0)&&!(i=r.next()).done;)a.push(i.value)}catch(e){o={error:e}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(o)throw o.error}}return a}function ut(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(lt(arguments[t]));return e}function dt(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;for(var r=Array(e),i=0,t=0;t<n;t++)for(var a=arguments[t],o=0,s=a.length;o<s;o++,i++)r[i]=a[o];return r}function ft(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,a;r<i;r++)(a||!(r in t))&&(a||=Array.prototype.slice.call(t,0,r),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))}function pt(e){return this instanceof pt?(this.v=e,this):new pt(e)}function mt(e,t,n){if(!Symbol.asyncIterator)throw TypeError(`Symbol.asyncIterator is not defined.`);var r=n.apply(e,t||[]),i,a=[];return i=Object.create((typeof AsyncIterator==`function`?AsyncIterator:Object).prototype),s(`next`),s(`throw`),s(`return`,o),i[Symbol.asyncIterator]=function(){return this},i;function o(e){return function(t){return Promise.resolve(t).then(e,d)}}function s(e,t){r[e]&&(i[e]=function(t){return new Promise(function(n,r){a.push([e,t,n,r])>1||c(e,t)})},t&&(i[e]=t(i[e])))}function c(e,t){try{l(r[e](t))}catch(e){f(a[0][3],e)}}function l(e){e.value instanceof pt?Promise.resolve(e.value.v).then(u,d):f(a[0][2],e)}function u(e){c(`next`,e)}function d(e){c(`throw`,e)}function f(e,t){e(t),a.shift(),a.length&&c(a[0][0],a[0][1])}}function ht(e){var t,n;return t={},r(`next`),r(`throw`,function(e){throw e}),r(`return`),t[Symbol.iterator]=function(){return this},t;function r(r,i){t[r]=e[r]?function(t){return(n=!n)?{value:pt(e[r](t)),done:!1}:i?i(t):t}:i}}function gt(e){if(!Symbol.asyncIterator)throw TypeError(`Symbol.asyncIterator is not defined.`);var t=e[Symbol.asyncIterator],n;return t?t.call(e):(e=typeof ct==`function`?ct(e):e[Symbol.iterator](),n={},r(`next`),r(`throw`),r(`return`),n[Symbol.asyncIterator]=function(){return this},n);function r(t){n[t]=e[t]&&function(n){return new Promise(function(r,a){n=e[t](n),i(r,a,n.done,n.value)})}}function i(e,t,n,r){Promise.resolve(r).then(function(t){e({value:t,done:n})},t)}}function _t(e,t){return Object.defineProperty?Object.defineProperty(e,`raw`,{value:t}):e.raw=t,e}function vt(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var n=At(e),r=0;r<n.length;r++)n[r]!==`default`&&Ot(t,e,n[r]);return kt(t,e),t}function yt(e){return e&&e.__esModule?e:{default:e}}function bt(e,t,n,r){if(n===`a`&&!r)throw TypeError(`Private accessor was defined without a getter`);if(typeof t==`function`?e!==t||!r:!t.has(e))throw TypeError(`Cannot read private member from an object whose class did not declare it`);return n===`m`?r:n===`a`?r.call(e):r?r.value:t.get(e)}function xt(e,t,n,r,i){if(r===`m`)throw TypeError(`Private method is not writable`);if(r===`a`&&!i)throw TypeError(`Private accessor was defined without a setter`);if(typeof t==`function`?e!==t||!i:!t.has(e))throw TypeError(`Cannot write private member to an object whose class did not declare it`);return r===`a`?i.call(e,n):i?i.value=n:t.set(e,n),n}function St(e,t){if(t===null||typeof t!=`object`&&typeof t!=`function`)throw TypeError(`Cannot use 'in' operator on non-object`);return typeof e==`function`?t===e:e.has(t)}function Ct(e,t,n){if(t!=null){if(typeof t!=`object`&&typeof t!=`function`)throw TypeError(`Object expected.`);var r,i;if(n){if(!Symbol.asyncDispose)throw TypeError(`Symbol.asyncDispose is not defined.`);r=t[Symbol.asyncDispose]}if(r===void 0){if(!Symbol.dispose)throw TypeError(`Symbol.dispose is not defined.`);r=t[Symbol.dispose],n&&(i=r)}if(typeof r!=`function`)throw TypeError(`Object not disposable.`);i&&(r=function(){try{i.call(this)}catch(e){return Promise.reject(e)}}),e.stack.push({value:t,dispose:r,async:n})}else n&&e.stack.push({async:!0});return t}function wt(e){function t(t){e.error=e.hasError?new jt(t,e.error,`An error was suppressed during disposal.`):t,e.hasError=!0}var n,r=0;function i(){for(;n=e.stack.pop();)try{if(!n.async&&r===1)return r=0,e.stack.push(n),Promise.resolve().then(i);if(n.dispose){var a=n.dispose.call(n.value);if(n.async)return r|=2,Promise.resolve(a).then(i,function(e){return t(e),i()})}else r|=1}catch(e){t(e)}if(r===1)return e.hasError?Promise.reject(e.error):Promise.resolve();if(e.hasError)throw e.error}return i()}function Tt(e,t){return typeof e==`string`&&/^\.\.?\//.test(e)?e.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(e,n,r,i,a){return n?t?`.jsx`:`.js`:r&&(!i||!a)?e:r+i+`.`+a.toLowerCase()+`js`}):e}var Et,Dt,Ot,kt,At,jt,Mt,Nt=_((()=>{Et=function(e,t){return Et=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},Et(e,t)},Dt=function(){return Dt=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},Dt.apply(this,arguments)},Ot=Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]}),kt=Object.create?(function(e,t){Object.defineProperty(e,`default`,{enumerable:!0,value:t})}):function(e,t){e.default=t},At=function(e){return At=Object.getOwnPropertyNames||function(e){var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[t.length]=n);return t},At(e)},jt=typeof SuppressedError==`function`?SuppressedError:function(e,t,n){var r=Error(n);return r.name=`SuppressedError`,r.error=e,r.suppressed=t,r},Mt={__extends:Xe,__assign:Dt,__rest:Ze,__decorate:Qe,__param:$e,__esDecorate:et,__runInitializers:tt,__propKey:nt,__setFunctionName:rt,__metadata:it,__awaiter:at,__generator:ot,__createBinding:Ot,__exportStar:st,__values:ct,__read:lt,__spread:ut,__spreadArrays:dt,__spreadArray:ft,__await:pt,__asyncGenerator:mt,__asyncDelegator:ht,__asyncValues:gt,__makeTemplateObject:_t,__importStar:vt,__importDefault:yt,__classPrivateFieldGet:bt,__classPrivateFieldSet:xt,__classPrivateFieldIn:St,__addDisposableResource:Ct,__disposeResources:wt,__rewriteRelativeImportExtension:Tt}})),Pt=v((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.lowerCase=e.localeLowerCase=void 0;var t={tr:{regexp:/\u0130|\u0049|\u0049\u0307/g,map:{İ:`i`,I:`ı`,İ:`i`}},az:{regexp:/\u0130/g,map:{İ:`i`,I:`ı`,İ:`i`}},lt:{regexp:/\u0049|\u004A|\u012E|\u00CC|\u00CD|\u0128/g,map:{I:`i̇`,J:`j̇`,Į:`į̇`,Ì:`i̇̀`,Í:`i̇́`,Ĩ:`i̇̃`}}};function n(e,n){var i=t[n.toLowerCase()];return r(i?e.replace(i.regexp,function(e){return i.map[e]}):e)}e.localeLowerCase=n;function r(e){return e.toLowerCase()}e.lowerCase=r})),Ft=v((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.noCase=void 0;var t=Pt(),n=[/([a-z0-9])([A-Z])/g,/([A-Z])([A-Z][a-z])/g],r=/[^A-Z0-9]+/gi;function i(e,i){i===void 0&&(i={});for(var o=i.splitRegexp,s=o===void 0?n:o,c=i.stripRegexp,l=c===void 0?r:c,u=i.transform,d=u===void 0?t.lowerCase:u,f=i.delimiter,p=f===void 0?` `:f,m=a(a(e,s,`$1\0$2`),l,`\0`),h=0,g=m.length;m.charAt(h)===`\0`;)h++;for(;m.charAt(g-1)===`\0`;)g--;return m.slice(h,g).split(`\0`).map(d).join(p)}e.noCase=i;function a(e,t,n){return t instanceof RegExp?e.replace(t,n):t.reduce(function(e,t){return e.replace(t,n)},e)}})),It=v((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.pascalCase=e.pascalCaseTransformMerge=e.pascalCaseTransform=void 0;var t=(Nt(),b(Ye)),n=Ft();function r(e,t){var n=e.charAt(0),r=e.substr(1).toLowerCase();return t>0&&n>=`0`&&n<=`9`?`_`+n+r:``+n.toUpperCase()+r}e.pascalCaseTransform=r;function i(e){return e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()}e.pascalCaseTransformMerge=i;function a(e,i){return i===void 0&&(i={}),n.noCase(e,t.__assign({delimiter:``,transform:r},i))}e.pascalCase=a}))();const k=(...e)=>{let t=(0,It.pascalCase)(e.filter(Boolean).join(` `),{transform:It.pascalCaseTransformMerge});return/^[0-9]/.test(t)&&(t=`_${t}`),t},Lt={Boolean:`Boolean`,Color:`Color`,Date:`Date`,Embed:`Embed`,GeoPoint:`GeoPoint`,Group:`Group`,Image:`Image`,Integration:`IntegrationFields`,Link:`Link`,Number:`Number`,Select:`Select`,Slices:`Slices`,StructuredText:`StructuredText`,Table:`Table`,Text:`Text`,Timestamp:`Timestamp`,UID:`UID`,IntegrationFields:`IntegrationFields`,Range:`Range`,Separator:`Separator`,LegacySlices:`Choice`};function Rt(e){let t=``;for(let n=0;n<e.path.length;n++){n>0&&(t+=`.`);let r=e.path[n];if(r.model&&`type`in r.model&&(r.model.type===`Group`||r.model.type===`Slices`))t+=`${r.name}[]`;else{if(r.name===`items`){let i=e.path[n-1];if(i.model&&`json`in i.model||i.model&&`type`in i.model&&i.model.type===`SharedSlice`){t+=`${r.name}[]`;continue}}t+=r.name}}return t}const zt=e=>{if(`json`in e.model)return e.model.label||e.model.id;if(`type`in e.model&&e.model.type===`SharedSlice`)return e.model.name;if(`type`in e.model&&e.model.type===`Slice`)return e.model.fieldset||e.name;if(`type`in e.model){if(e.model.config&&`label`in e.model.config)return e.model.config.label||e.name;if(e.model.config&&`fieldset`in e.model)return e.model.fieldset||e.name}return`\`${e.name}\``};function Bt(e){return e.path.map(e=>e.label?e.label:e.model?zt({model:e.model,name:e.name}):e.name).join(` → `)}function Vt(e){switch(e.field.type){case`StructuredText`:return`Rich Text`;case`IntegrationFields`:{let t=e.field.config?.catalog;return`Integration Fields (Catalog: ${t?`\`${t}\``:`*unknown*`})`}case`Link`:switch(e.field.config?.select){case`document`:return`Content Relationship`;case`media`:return`Link to Media`;default:return`Link`}case`Slices`:return`Slice Zone`;default:return e.field.type}}function Ht(e){switch(e.field.type){case`Link`:{let t=Je.Link;switch(e.field.config?.select){case`document`:return t.contentRelationship;case`media`:return t.linkToMedia;default:return t.link}}default:{let t=Je[e.field.type];if(typeof t==`string`)return t}}}function Ut(e){let t=`/**`,n=zt({model:e.field,name:e.name}),r=Bt({path:e.path}),i=Vt({field:e.field});t=D(` * ${n} field in *${r}*`,t),t=D(` *`,t),t=D(` * - **Field Type**: ${i}`,t),t=D(` * - **Placeholder**: ${e.field.config&&`placeholder`in e.field.config&&e.field.config.placeholder||`*None*`}`,t);let a=e.field.config&&`default_value`in e.field.config?e.field.config.default_value:void 0;a!==void 0&&(t=D(` * - **Default Value**: ${typeof a==`boolean`?`${a}`:a}`,t)),t=D(` * - **API ID Path**: ${Rt({path:[...e.path,{name:e.name,model:e.field}]})}`,t),e.tabName&&(t=D(` * - **Tab**: ${e.tabName}`,t));let o=Ht({field:e.field});return o&&(t=D(` * - **Documentation**: ${o}`,t)),t=D(` */`,t),t}function A(e){return e.filter(Boolean).join(` | `)||`never`}function Wt(e){let t=Ut({name:e.name,field:e.field,path:e.path,tabName:e.tabName}),n=[],r=[],i=e.name.includes(`-`)||e.name.includes(`:`)||/^[0-9]/.test(e.name)?`"${e.name}"`:e.name;switch(e.field.type){case`UID`:break;case`Boolean`:t=D(`${i}: prismic.BooleanField;`,t);break;case`Color`:t=D(`${i}: prismic.ColorField;`,t);break;case`Date`:t=D(`${i}: prismic.DateField;`,t);break;case`Embed`:{let n=[];if(e.fieldConfigs.embed?.providerTypes)for(let t in e.fieldConfigs.embed?.providerTypes){let r=e.fieldConfigs.embed?.providerTypes[t];n.push(`({ provider_name: "${t}" } & ${r})`)}let r=A(n);t=n.length>0?D(`${i}: prismic.EmbedField<prismic.AnyOEmbed & prismic.OEmbedExtra & (${r})>`,t):D(`${i}: prismic.EmbedField`,t);break}case`GeoPoint`:t=D(`${i}: prismic.GeoPointField;`,t);break;case`Image`:t=e.field.config?.thumbnails&&e.field.config.thumbnails.length>0?D(`${i}: prismic.ImageField<${A(e.field.config.thumbnails.map(e=>`"${e.name}"`))}>;`,t):D(`${i}: prismic.ImageField<never>;`,t);break;case`IntegrationFields`:{let n=e.field.config?.catalog?e.fieldConfigs.integrationFields?.catalogTypes?.[e.field.config.catalog]:void 0;t=D(n?`${i}: prismic.IntegrationField<${n}>;`:`${i}: prismic.IntegrationField;`,t);break}case`Link`:{let n=e.field.config&&`variants`in e.field.config&&Array.isArray(e.field.config.variants)&&e.field.config.variants.length>0?e.field.config.variants.map(e=>`"${e.replace(/\"/g,`\\"`)}"`).join(` | `):`never`;switch(e.field.config?.select){case`document`:t=`customtypes`in e.field.config&&e.field.config.customtypes&&e.field.config.customtypes.length>0?D(`${i}: ${A(e.field.config.customtypes.map(e=>typeof e==`string`?`prismic.ContentRelationshipField<"${e}">`:`ContentRelationshipFieldWithData<${JSON.stringify([e])}>`))};`,t):D(`${i}: prismic.ContentRelationshipField;`,t);break;case`media`:t=D(`${i}: prismic.LinkToMediaField<prismic.FieldState, ${n}>;`,t);break;default:{let r=`prismic.LinkField<string, string, unknown, prismic.FieldState, ${n}>`;e.field.config?.repeat&&(r=`prismic.Repeatable<${r}>`),t=D(`${i}: ${r};`,t);break}}break}case`Number`:t=D(`${i}: prismic.NumberField;`,t);break;case`StructuredText`:t=D(`${i}: prismic.RichTextField;`,t);break;case`Select`:{let n=(e.field.config?.options)?.map(e=>`"${e}"`)||[],r=n.length?A(n):`string`;t=e.field.config?.default_value?D(`${i}: prismic.SelectField<${r}, "filled">;`,t):D(`${i}: prismic.SelectField${n.length>0?`<${r}>`:``};`,t);break}case`Table`:t=D(`${i}: prismic.TableField;`,t);break;case`Text`:t=D(`${i}: prismic.KeyTextField;`,t);break;case`Timestamp`:t=D(`${i}: prismic.TimestampField;`,t);break;case`Group`:{let a=e.path.filter(e=>e.model!==void 0&&`type`in e.model&&e.model.type===Lt.Group),o=a.length>0,s;if(e.path[0].model&&`type`in e.path[0].model&&e.path[0].model.type===`SharedSlice`){let[t,n,r]=e.path;s=k(t.name,`Slice`,n.name,r.name,...a.map(e=>e.name),e.name,`Item`)}else s=k(e.path[0].name,`Document`,`Data`,...a.map(e=>e.name),e.name,`Item`);let c=[...e.path,{name:i,model:e.field}],l=Bt({path:c}),u=Gt({fields:e.field.config?.fields||{},fieldConfigs:e.fieldConfigs,path:c});n.push(...u.auxiliaryTypes),r.push(...u.contentTypeNames),n.push({name:s,code:E.source`
10
- /**
11
- * Item in *${l}*
12
- */
13
- export interface ${s} {
14
- ${u.code}
15
- }
16
- `}),r.push(s),t=D(o?`${i}: prismic.NestedGroupField<Simplify<${s}>>;`:`${i}: prismic.GroupField<Simplify<${s}>>;`,t);break}case`Slices`:{let a=[];if(e.field.config?.choices)for(let t in e.field.config.choices){let i=e.field.config.choices[t];if(i.type===`SharedSlice`)a.push(k(t,`Slice`));else if(i.type===`Slice`){let o=k(e.path[0].name,`Document`,`Data`,e.name,t,`Slice`),s;if(i[`non-repeat`]&&Object.keys(i[`non-repeat`]).length>0){s=k(o,`Primary`);let a=[...e.path,{name:e.name,model:e.field},{name:t,model:i},{name:`primary`,label:`Primary`}],c=Bt({path:a}),l=Gt({fields:i[`non-repeat`],fieldConfigs:e.fieldConfigs,path:a});n.push(...l.auxiliaryTypes),r.push(...l.contentTypeNames);let u=E.stripIndent`
17
- /**
18
- * Primary content in *${c}*
19
- */
20
- `;u=l.code?D(E.source`
21
- export interface ${s} {
22
- ${l.code}
23
- }
24
- `,u):D(`export interface ${s} {}`,u),n.push({name:s,code:u}),r.push(s)}let c;if(i.repeat&&Object.keys(i.repeat).length>0){c=k(o,`Item`);let a=[...e.path,{name:e.name,model:e.field},{name:t,model:i},{name:`items`,label:`Items`}],s=Bt({path:a}),l=Gt({fields:i.repeat,fieldConfigs:e.fieldConfigs,path:a});n.push(...l.auxiliaryTypes),r.push(...l.contentTypeNames);let u=E.stripIndent`
25
- /**
26
- * Item content in *${s}*
27
- */
28
- `;u=l.code?D(E.source`
29
- export interface ${c} {
30
- ${l.code}
31
- }
32
- `,u):D(`export interface ${c} {}`,u),n.push({name:c,code:u}),r.push(c)}n.push({name:o,code:E.stripIndent`
33
- /**
34
- * Slice for *${Bt({path:[...e.path,{name:e.name,model:e.field}]})}*
35
- */
36
- export type ${o} = prismic.Slice<"${t}", ${s?`Simplify<${s}>`:`Record<string, never>`}, ${c?`Simplify<${c}>`:`never`}>
37
- `}),a.push(o)}}let o=k(e.path[0].name,`Document`,`Data`,e.name,`Slice`),s=A(a);n.push({name:o,code:`type ${o} = ${s}`}),r.push(o),t=D(`${i}: prismic.SliceZone<${o}>;`,t);break}default:t=D(`${i}: unknown;`,t)}return{code:t,auxiliaryTypes:n,contentTypeNames:r}}function Gt(e){let t=``,n=[],r=[];for(let i in e.fields){let a=e.fields[i],o=Wt({name:i,field:a,path:e.path,fieldConfigs:e.fieldConfigs,tabName:e.tabName});t=O(o.code,t),n.push(...o.auxiliaryTypes),r.push(...o.contentTypeNames)}return{code:t,auxiliaryTypes:n,contentTypeNames:r}}function Kt(e){let t=``,n=[],r=[],i=k(e.model.id,`Document`,`Data`),a=zt({name:e.model.id,model:e.model}),o=``;for(let t in e.model.json){let{uid:i,...a}=e.model.json[t],s=Gt({fields:a,fieldConfigs:e.fieldConfigs,path:[{name:e.model.id,model:e.model}],tabName:t});o+=s.code,n.push(...s.auxiliaryTypes),r.push(...s.contentTypeNames)}return t=o?E.source`
38
- /**
39
- * Content for ${a} documents
40
- */
41
- interface ${i} {
42
- ${o}
43
- }
44
- `:`interface ${i} {}`,{name:i,code:t,auxiliaryTypes:n,contentTypeNames:r}}function qt(e){return`uid`in Object.assign({},...Object.values(e.json))}const Jt=e=>c.createHash(`sha1`).update(JSON.stringify(e)).digest(`hex`);function Yt(e){if(e.cache){let t=Jt(e.model),n=e.cache.get(t);if(n)return n}let t=``,n=[],r=[],i=k(e.model.id,`Document`),a=e.localeIDs&&e.localeIDs.length>0?A(e.localeIDs.map(e=>`"${e}"`)):`string`,o=qt(e.model)?`PrismicDocumentWithUID`:`PrismicDocumentWithoutUID`,s=zt({name:e.model.id,model:e.model}),c=Kt({model:e.model,fieldConfigs:e.fieldConfigs});n.push(...c.auxiliaryTypes),r.push(c.name),r.push(...c.contentTypeNames),t=O(c.code,t),t=O(E.source`
45
- /**
46
- * ${s} document from Prismic
47
- *
48
- * - **API ID**: \`${e.model.id}\`
49
- * - **Repeatable**: \`${e.model.repeatable.toString()}\`
50
- * - **Documentation**: ${`https://prismic.io/docs/content-modeling`}
51
- *
52
- * @typeParam Lang - Language API ID of the document.
53
- */
54
- export type ${i}<Lang extends string = ${a}> = prismic.${o}<Simplify<${c.name}>, "${e.model.id}", Lang>;
55
- `,t);let l={name:i,code:t,auxiliaryTypes:n,contentTypeNames:r};if(e.cache){let t=Jt(e.model);e.cache.set(t,l)}return l}function Xt(e){if(e.cache){let t=Jt([e.model,e.fieldConfigs]),n=e.cache.get(t);if(n)return n}let t=``,n=[],r=[],i=k(e.model.id,`Slice`),a=zt({name:e.model.id,model:e.model}),o=[];for(let s of e.model.variations){let c=k(i,s.id),l;if(s.primary&&Object.keys(s.primary).length>0){l=k(c,`Primary`);let i=[{name:e.model.id,model:e.model},{name:s.id,label:s.name},{name:`primary`,label:`Primary`}],a=Bt({path:i}),o=Gt({fields:s.primary,fieldConfigs:e.fieldConfigs,path:i});n.push(...o.auxiliaryTypes),r.push(...o.contentTypeNames),r.push(l);let u=E.stripIndent`
56
- /**
57
- * Primary content in *${a}*
58
- */
59
- `;t=O(o.code?E.source`
60
- ${u}
61
- export interface ${l} {
62
- ${o.code}
63
- }
64
- `:E.source`
65
- ${u}
66
- export interface ${l} {}
67
- `,t)}let u;if(s.items&&Object.keys(s.items).length>0){u=k(c,`Item`);let i=[{name:e.model.id,model:e.model},{name:`items`,label:`Items`}],a=Bt({path:i}),o=Gt({fields:s.items,fieldConfigs:e.fieldConfigs,path:i});n.push(...o.auxiliaryTypes),r.push(...o.contentTypeNames),r.push(u);let l=E.stripIndent`
68
- /**
69
- * Primary content in *${a}*
70
- */
71
- `;t=O(o.code?E.source`
72
- ${l}
73
- export interface ${u} {
74
- ${o.code}
75
- }
76
- `:E.source`
77
- ${l}
78
- export interface ${u} {}
79
- `,t)}t=O(E.source`
80
- /**
81
- * ${s.name} variation for ${a} Slice
82
- *
83
- * - **API ID**: \`${s.id}\`
84
- * - **Description**: ${s.description||`*None*`}
85
- * - **Documentation**: ${qe}
86
- */
87
- export type ${c} = prismic.SharedSliceVariation<"${s.id}", ${l?`Simplify<${l}>`:`Record<string, never>`}, ${u?`Simplify<${u}>`:`never`}>;
88
- `,t),o.push(c)}let s=k(i,`Variation`),c=A(o);r.push(s),r.push(...o),t=O(E.source`
89
- /**
90
- * Slice variation for *${a}*
91
- */
92
- type ${s} = ${o.length>0?c:`never`}
93
- `,t),t=O(E.source`
94
- /**
95
- * ${a} Shared Slice
96
- *
97
- * - **API ID**: \`${e.model.id}\`
98
- * - **Description**: ${e.model.description||`*None*`}
99
- * - **Documentation**: ${qe}
100
- */
101
- export type ${i} = prismic.SharedSlice<"${e.model.id}", ${s}>;
102
- `,t);let l={name:i,variationNames:o,code:t,auxiliaryTypes:n,contentTypeNames:r};if(e.cache){let t=Jt([e.model,e.fieldConfigs]);e.cache.set(t,l)}return l}const Zt=new We({maxSize:1e3});function Qt(e={}){let t=e.fieldConfigs||{},n=e.cache??!0,r=``,i=e.typesProvider||`@prismicio/types`,a=`prismic`;r=D(`import type * as prismic from "${i}";`,r),(e.clientIntegration?.includeCreateClientInterface||e.clientIntegration?.includeContentNamespace)&&i!==`@prismicio/client`&&(a=`prismicClient`,r=D(`import type * as ${a} from "@prismicio/client";`,r)),r=O(`type Simplify<T> = { [KeyType in keyof T]: T[KeyType] };`,r),r=O(`
103
- type PickContentRelationshipFieldData<
104
- TRelationship extends prismic.CustomTypeModelFetchCustomTypeLevel1 | prismic.CustomTypeModelFetchCustomTypeLevel2 | prismic.CustomTypeModelFetchGroupLevel1 | prismic.CustomTypeModelFetchGroupLevel2,
105
- TData extends Record<string, prismic.AnyRegularField | prismic.GroupField | prismic.NestedGroupField | prismic.SliceZone>,
106
- TLang extends string
107
- > = |
108
- // Content relationship fields
109
- {
110
- [TSubRelationship in Extract<
111
- TRelationship["fields"][number], prismic.CustomTypeModelFetchContentRelationshipLevel1
112
- > as TSubRelationship["id"]]:
113
- ContentRelationshipFieldWithData<TSubRelationship["customtypes"], TLang>;
114
- } &
115
- // Group
116
- {
117
- [TGroup in Extract<
118
- TRelationship["fields"][number], prismic.CustomTypeModelFetchGroupLevel1 | prismic.CustomTypeModelFetchGroupLevel2
119
- > as TGroup["id"]]:
120
- TData[TGroup["id"]] extends prismic.GroupField<infer TGroupData>
121
- ? prismic.GroupField<PickContentRelationshipFieldData<TGroup, TGroupData, TLang>>
122
- : never
123
- } &
124
- // Other fields
125
- {
126
- [TFieldKey in Extract<TRelationship["fields"][number], string>]:
127
- TFieldKey extends keyof TData ? TData[TFieldKey] : never;
128
- };
129
-
130
- type ContentRelationshipFieldWithData<
131
- TCustomType extends readonly (prismic.CustomTypeModelFetchCustomTypeLevel1 | string)[] | readonly (prismic.CustomTypeModelFetchCustomTypeLevel2 | string)[],
132
- TLang extends string = string
133
- > = {
134
- [ID in Exclude<TCustomType[number], string>["id"]]:
135
- prismic.ContentRelationshipField<
136
- ID,
137
- TLang,
138
- PickContentRelationshipFieldData<
139
- Extract<TCustomType[number], { id: ID }>,
140
- Extract<prismic.Content.AllDocumentTypes, { type: ID }>["data"],
141
- TLang
142
- >
143
- >
144
- }[Exclude<TCustomType[number], string>["id"]];
145
- `,r);let o=[];if(e.customTypeModels){let i=[];for(let a of e.customTypeModels){let s=Yt({model:a,localeIDs:e.localeIDs,fieldConfigs:t,cache:n?Zt:void 0});for(let e of s.auxiliaryTypes)r=O(e.code,r);r=O(s.code,r),i.push(s.name),o.push(s.name),o.push(...s.contentTypeNames)}if(e.customTypeModels.length>0){let e=`AllDocumentTypes`;r=O(`export type ${e} = ${A(i)};`,r),o.push(e)}}if(e.sharedSliceModels)for(let i of e.sharedSliceModels){let e=Xt({model:i,fieldConfigs:t,cache:n?Zt:void 0});for(let t of e.auxiliaryTypes)r=O(t.code,r);r=O(e.code,r),o.push(e.name),o.push(...e.contentTypeNames)}if(e.clientIntegration?.includeCreateClientInterface||e.clientIntegration?.includeContentNamespace){let t=``;e.clientIntegration.includeCreateClientInterface&&((e.customTypeModels?.length||0)>0?(t=O(`interface CreateClient {
146
- (repositoryNameOrEndpoint: string, options?: ${a}.ClientConfig): ${a}.Client<AllDocumentTypes>;
147
- }`,t),t=O(`interface CreateWriteClient {
148
- (repositoryNameOrEndpoint: string, options: ${a}.WriteClientConfig): ${a}.WriteClient<AllDocumentTypes>;
149
- }`,t),t=O(`interface CreateMigration {
150
- (): ${a}.Migration<AllDocumentTypes>;
151
- }`,t)):(t=O(`interface CreateClient {
152
- (repositoryNameOrEndpoint: string, options?: ${a}.ClientConfig): ${a}.Client;
153
- }`,t),t=O(`interface CreateWriteClient {
154
- (repositoryNameOrEndpoint: string, options?: ${a}.WriteClientConfig): ${a}.WriteClient;
155
- }`,t),t=O(`interface CreateMigration {
156
- (): ${a}.Migration;
157
- }`,t))),e.clientIntegration.includeContentNamespace&&(t=O(E.source`
158
- namespace Content {
159
- export type {
160
- ${o.join(`,
161
- `)}
162
- }
163
- }
164
- `,t)),r=O(E.source`
165
- declare module "@prismicio/client" {
166
- ${t}
167
- }
168
- `,r)}return r}async function j(e){let t=await on();return t.hostname=`${e}.${t.hostname}`,tn(t)}async function $t(){let e=await on();return e.hostname=`api.internal.${e.hostname}`,tn(e)}async function en(){let e=await on();return e.hostname=`user-service.${e.hostname}`,tn(e)}function tn(e){let t=new URL(e);return t.pathname.endsWith(`/`)||(t.pathname+=`/`),t}const nn=new URL(`.prismic`,tn(u(l()))),rn=`https://prismic.io`;async function an(e,t){let n={token:e,host:t?.host};await s(nn,JSON.stringify(n,null,2))}async function M(){return!!await N()}async function N(){return(await sn())?.token}async function on(){try{let e=await sn();return e?.host?new URL(e.host):new URL(rn)}catch{return new URL(rn)}}async function sn(){try{let e=await r(nn,`utf-8`);return JSON.parse(e)}catch{return}}async function cn(){try{await t(nn)}catch{return!0}return await sn()?(await o(nn),!0):!1}function ln(e){return{lang:e?.lang??void 0,message:e?.message,abortEarly:e?.abortEarly??void 0,abortPipeEarly:e?.abortPipeEarly??void 0}}function un(e){return(void 0)?.get(e)}function dn(e){return(void 0)?.get(e)}function fn(e,t){return(void 0)?.get(e)?.get(t)}function pn(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 P(e,t,n,r,i){let a=i&&`input`in i?i.input:n.value,o=i?.expected??e.expects??null,s=i?.received??pn(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??fn(e.reference,c.lang)??(l?dn(c.lang):null)??r.message??un(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 F(e){return{version:1,vendor:`valibot`,validate(t){return e[`~run`]({value:t},ln())}}}function mn(e,t){return Object.hasOwn(e,t)&&t!==`__proto__`&&t!==`prototype`&&t!==`constructor`}function I(e){return e instanceof hn}var hn=class extends Error{constructor(e){super(e[0].message),this.name=`ValiError`,this.issues=e}};function gn(e){return{kind:`validation`,type:`url`,reference:gn,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)&&P(this,`URL`,e,t),e}}}function _n(e,t,n){return typeof e.fallback==`function`?e.fallback(t,n):e.fallback}function vn(e,t,n){return typeof e.default==`function`?e.default(t,n):e.default}function L(e,t){return{kind:`schema`,type:`array`,reference:L,expects:`Array`,async:!1,item:e,message:t,get"~standard"(){return F(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 P(this,`type`,e,t);return e}}}function R(e){return{kind:`schema`,type:`boolean`,reference:R,expects:`boolean`,async:!1,message:e,get"~standard"(){return F(this)},"~run"(e,t){return typeof e.value==`boolean`?e.typed=!0:P(this,`type`,e,t),e}}}function yn(e,t){return{kind:`schema`,type:`literal`,reference:yn,expects:pn(e),async:!1,literal:e,message:t,get"~standard"(){return F(this)},"~run"(e,t){return e.value===this.literal?e.typed=!0:P(this,`type`,e,t),e}}}function bn(e,t){return{kind:`schema`,type:`nullable`,reference:bn,expects:`(${e.expects} | null)`,async:!1,wrapped:e,default:t,get"~standard"(){return F(this)},"~run"(e,t){return e.value===null&&(this.default!==void 0&&(e.value=vn(this,e,t)),e.value===null)?(e.typed=!0,e):this.wrapped[`~run`](e,t)}}}function xn(e){return{kind:`schema`,type:`number`,reference:xn,expects:`number`,async:!1,message:e,get"~standard"(){return F(this)},"~run"(e,t){return typeof e.value==`number`&&!isNaN(e.value)?e.typed=!0:P(this,`type`,e,t),e}}}function z(e,t){return{kind:`schema`,type:`object`,reference:z,expects:`Object`,async:!1,entries:e,message:t,get"~standard"(){return F(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]:vn(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]=_n(i);else if(i.type!==`exact_optional`&&i.type!==`optional`&&i.type!==`nullish`&&(P(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 P(this,`type`,e,t);return e}}}function B(e,t){return{kind:`schema`,type:`optional`,reference:B,expects:`(${e.expects} | undefined)`,async:!1,wrapped:e,default:t,get"~standard"(){return F(this)},"~run"(e,t){return e.value===void 0&&(this.default!==void 0&&(e.value=vn(this,e,t)),e.value===void 0)?(e.typed=!0,e):this.wrapped[`~run`](e,t)}}}function V(e,t,n){return{kind:`schema`,type:`record`,reference:V,expects:`Object`,async:!1,key:e,value:t,message:n,get"~standard"(){return F(this)},"~run"(e,t){let n=e.value;if(n&&typeof n==`object`){for(let r in e.typed=!0,e.value={},n)if(mn(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 P(this,`type`,e,t);return e}}}function H(e){return{kind:`schema`,type:`string`,reference:H,expects:`string`,async:!1,message:e,get"~standard"(){return F(this)},"~run"(e,t){return typeof e.value==`string`?e.typed=!0:P(this,`type`,e,t),e}}}function U(){return{kind:`schema`,type:`unknown`,reference:U,expects:`unknown`,async:!1,get"~standard"(){return F(this)},"~run"(e){return e.typed=!0,e}}}function Sn(e,t,n){let r=e[`~run`]({value:t},ln(n));if(r.issues)throw new hn(r.issues);return r.value}function Cn(...e){return{...e[0],pipe:e,get"~standard"(){return F(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 W(e,t,n){let r=e[`~run`]({value:t},ln(n));return{typed:r.typed,success:!r.issues,output:r.value,issues:r.issues}}async function G(e,n={}){let{start:r=u(process.cwd()),stop:i}=n,a=tn(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 wn(e){try{return await t(e),!0}catch{return!1}}function K(e){return JSON.stringify(e,null,2)}const Tn=`prismic.config.json`,En=z({repositoryName:H(),apiEndpoint:B(Cn(H(),gn())),localSliceMachineSimulatorURL:B(Cn(H(),gn())),libraries:B(L(H())),adapter:B(H()),labs:B(z({legacySliceUpgrader:B(R())}))});async function Dn(e,t=u(process.cwd())){let n=await Mn(t);return n.ok?(await s(n.path,K(e)),{ok:!0,config:e}):n}async function q(e=u(process.cwd())){let t=await On(e);if(t.ok)return t.config.repositoryName}async function On(e=u(process.cwd())){let t=await jn(e);if(!t.ok)return t;try{let e=await r(t.path,`utf8`),n=W(En,JSON.parse(e));return n.success?{ok:!0,config:n.output}:{ok:!1,error:new kn(n.issues)}}catch{return{ok:!1,error:new kn}}}var kn=class extends Error{issues;constructor(e=[]){super(`prismic.config.json is invalid.`),this.issues=e}};async function An(e,t=u(process.cwd())){let n=await jn(t);if(!n.ok)return n;let r=await On(t);if(!r.ok)return r;let i={...r.config,...e};return await s(n.path,K(i)),{ok:!0,config:i}}async function jn(e=u(process.cwd())){let t=await G(Tn,{start:e,stop:`package.json`});return t?{ok:!0,path:t}:{ok:!1,error:new Nn}}async function Mn(e=u(process.cwd())){let t=await G(`package.json`,{start:e});return t?{ok:!0,path:new URL(Tn,t)}:{ok:!1,error:new Pn}}var Nn=class extends Error{message=`Could not find a prismic.config.json file.`},Pn=class extends Error{message=`Could not find a package.json file.`};const Fn=z({id:H(),type:yn(`SharedSlice`),name:H(),description:B(H()),variations:L(z({id:H(),name:H(),description:B(H()),docURL:B(H()),version:B(H()),imageUrl:B(H()),primary:B(V(H(),U())),items:B(V(H(),U()))}))});async function J(e){if(!await G(`package.json`))return{ok:!1,error:`Could not find project root (no package.json found)`};let t=await In(),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=W(Fn,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 In(){let e=await Rn(),t=await G(`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 wn(new URL(`src`,n)))return new URL(`src/slices/`,n);case`nuxt`:if(await wn(new URL(`app`,n)))return new URL(`app/slices/`,n);case`sveltekit`:return new URL(`src/slices/`,n)}return new URL(`slices/`,n)}const Ln=z({dependencies:B(V(H(),H()))});async function Rn(){let e=await G(`package.json`);if(e)try{let t=await r(e,`utf8`),{dependencies:n={}}=Sn(Ln,JSON.parse(t));if(`next`in n)return`next`;if(`nuxt`in n)return`nuxt`;if(`@sveltejs/kit`in n)return`sveltekit`}catch{}}function zn(e){return e.toLowerCase().replace(/(^|[-_\s]+)(.)?/g,(e,t,n)=>n?.toUpperCase()??``)}const Bn=z({id:H(),label:B(H()),repeatable:R(),status:R(),format:B(H()),json:V(H(),U())});async function Vn(){let e=await on();return e.hostname=`customtypes.${e.hostname}`,e}async function Hn(e){let t=await N();if(!t)return{ok:!1,error:`Not authenticated`};let n=await Vn(),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=W(L(Bn),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 Un(e){let t=await N();if(!t)return{ok:!1,error:`Not authenticated`};let n=await Vn(),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=W(L(Fn),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 Wn(){let e=await G(`package.json`);if(!e)return{ok:!1,error:`Could not find project root (no package.json found)`};let t=new URL(`.`,e),n=new URL(`customtypes/`,t),a;try{a=await i(n,{withFileTypes:!1})}catch{return{ok:!0,value:[]}}let o=[];for(let e of a){let t=new URL(`${e}/index.json`,n);try{let e=await r(t,`utf8`),n=W(Bn,JSON.parse(e));n.success&&o.push(n.output)}catch{}}return{ok:!0,value:o}}async function Gn(){let e;try{e=await In()}catch{return{ok:!1,error:`Could not find project root (no package.json found)`}}let t;try{t=await i(e,{withFileTypes:!1})}catch{return{ok:!0,value:[]}}let n=[];for(let i of t){let t=new URL(`${i}/model.json`,e);try{let e=await r(t,`utf8`),i=W(Fn,JSON.parse(e));i.success&&n.push(i.output)}catch{}}return{ok:!0,value:n}}async function Kn(e,t){let n=await N();if(!n)return{ok:!1,error:`Not authenticated`};let r=await Vn(),i=new URL(`customtypes/insert`,r);try{let r=await fetch(i,{method:`POST`,headers:{Authorization:`Bearer ${n}`,repository:e,"Content-Type":`application/json`},body:JSON.stringify(t)});return r.ok?{ok:!0,value:void 0}:r.status===401?{ok:!1,error:"Unauthorized. Your session may have expired. Run `prismic login` again."}:r.status===403?{ok:!1,error:`Access denied. You may not have access to repository "${e}".`}:{ok:!1,error:`API error: ${r.status} ${r.statusText}`}}catch(e){return{ok:!1,error:`Network error: ${e instanceof Error?e.message:e}`}}}async function qn(e,t){let n=await N();if(!n)return{ok:!1,error:`Not authenticated`};let r=await Vn(),i=new URL(`customtypes/update`,r);try{let r=await fetch(i,{method:`POST`,headers:{Authorization:`Bearer ${n}`,repository:e,"Content-Type":`application/json`},body:JSON.stringify(t)});return r.ok?{ok:!0,value:void 0}:r.status===401?{ok:!1,error:"Unauthorized. Your session may have expired. Run `prismic login` again."}:r.status===403?{ok:!1,error:`Access denied. You may not have access to repository "${e}".`}:{ok:!1,error:`API error: ${r.status} ${r.statusText}`}}catch(e){return{ok:!1,error:`Network error: ${e instanceof Error?e.message:e}`}}}async function Jn(e,t){let n=await N();if(!n)return{ok:!1,error:`Not authenticated`};let r=await Vn(),i=new URL(`customtypes/${encodeURIComponent(t)}`,r);try{let t=await fetch(i,{method:`DELETE`,headers:{Authorization:`Bearer ${n}`,repository:e}});return t.ok?{ok:!0,value:void 0}:t.status===401?{ok:!1,error:"Unauthorized. Your session may have expired. Run `prismic login` again."}:t.status===403?{ok:!1,error:`Access denied. You may not have access to repository "${e}".`}:{ok:!1,error:`API error: ${t.status} ${t.statusText}`}}catch(e){return{ok:!1,error:`Network error: ${e instanceof Error?e.message:e}`}}}async function Yn(e,t){let n=await N();if(!n)return{ok:!1,error:`Not authenticated`};let r=await Vn(),i=new URL(`slices/insert`,r);try{let r=await fetch(i,{method:`POST`,headers:{Authorization:`Bearer ${n}`,repository:e,"Content-Type":`application/json`},body:JSON.stringify(t)});return r.ok?{ok:!0,value:void 0}:r.status===401?{ok:!1,error:"Unauthorized. Your session may have expired. Run `prismic login` again."}:r.status===403?{ok:!1,error:`Access denied. You may not have access to repository "${e}".`}:{ok:!1,error:`API error: ${r.status} ${r.statusText}`}}catch(e){return{ok:!1,error:`Network error: ${e instanceof Error?e.message:e}`}}}async function Xn(e,t){let n=await N();if(!n)return{ok:!1,error:`Not authenticated`};let r=await Vn(),i=new URL(`slices/update`,r);try{let r=await fetch(i,{method:`POST`,headers:{Authorization:`Bearer ${n}`,repository:e,"Content-Type":`application/json`},body:JSON.stringify(t)});return r.ok?{ok:!0,value:void 0}:r.status===401?{ok:!1,error:"Unauthorized. Your session may have expired. Run `prismic login` again."}:r.status===403?{ok:!1,error:`Access denied. You may not have access to repository "${e}".`}:{ok:!1,error:`API error: ${r.status} ${r.statusText}`}}catch(e){return{ok:!1,error:`Network error: ${e instanceof Error?e.message:e}`}}}async function Zn(e,t){let n=await N();if(!n)return{ok:!1,error:`Not authenticated`};let r=await Vn(),i=new URL(`slices/${encodeURIComponent(t)}`,r);try{let t=await fetch(i,{method:`DELETE`,headers:{Authorization:`Bearer ${n}`,repository:e}});return t.ok?{ok:!0,value:void 0}:t.status===401?{ok:!1,error:"Unauthorized. Your session may have expired. Run `prismic login` again."}:t.status===403?{ok:!1,error:`Access denied. You may not have access to repository "${e}".`}:{ok:!1,error:`API error: ${t.status} ${t.statusText}`}}catch(e){return{ok:!1,error:`Network error: ${e instanceof Error?e.message:e}`}}}async function Y(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:Sn(t.schema,o)}}catch(e){if(I(e))return{ok:!1,value:o,error:e};throw e}}else if(a.status===401)return{ok:!1,value:o,error:new Z(a)};else if(a.status===403)return{ok:!1,value:o,error:new X(a)};else return{ok:!1,value:o,error:new Qn(a)}}var Qn=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}},X=class extends Qn{},Z=class extends Qn{};async function $n(){let{values:{help:t,repo:n=await q(),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.
169
-
170
- By default, this command reads the repository from prismic.config.json at the
171
- project root.
172
-
173
- USAGE
174
- prismic locale list [flags]
175
-
176
- FLAGS
177
- --json Output as JSON
178
- -r, --repo string Repository domain
179
- -h, --help Show help for command
180
-
181
- LEARN MORE
182
- 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()){nr();return}let i=await tr(n);if(!i.ok){i.error instanceof X?nr():I(i.error)?(console.error(`Failed to list locales: Invalid response: ${K(i.error.issues)}`),process.exitCode=1):(console.error(`Failed to list locales: ${K(i.value)}`),process.exitCode=1);return}let a=i.value.results;if(r)console.info(K(a));else for(let e of a){let t=e.isMaster?` (default)`:``;console.info(`${e.id} ${e.label}${t}`)}}const er=z({results:L(z({id:H(),label:H(),customName:bn(H()),isMaster:R()}))});async function tr(e){let t=new URL(`/locale/repository/locales`,await $t());return t.searchParams.set(`repository`,e),await Y(t,{schema:er})}function nr(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function rr(){let{values:{help:t,repo:n=await q(),output:r=`prismicio-types.d.ts`}}=e({args:process.argv.slice(4),options:{output:{type:`string`,short:`o`},repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!1});if(t){console.info(`Generate TypeScript types from models pushed to Prismic.
183
-
184
- By default, this command reads the repository from prismic.config.json at the
185
- project root.
186
-
187
- USAGE
188
- prismic codegen types [flags]
189
-
190
- FLAGS
191
- -o, --output string Output file path (default: "prismicio-types.d.ts")
192
- -r, --repo string Repository domain
193
- -h, --help Show help for command
194
-
195
- EXAMPLES
196
- prismic codegen types
197
- prismic codegen types --repo my-repo
198
- prismic codegen types --output custom.d.ts`);return}if(!n){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}let[i,a,o]=await Promise.all([Hn(n),Un(n),tr(n)]);if(!i.ok){console.error(`Failed to fetch custom types: ${i.error}`),process.exitCode=1;return}if(!a.ok){console.error(`Failed to fetch slices: ${a.error}`),process.exitCode=1;return}if(!o.ok){console.error(`Failed to fetch locales: ${o.error}`),process.exitCode=1;return}let c=i.value,l=a.value;await s(r,`// Code generated by prismic-ts-codegen. DO NOT EDIT.
199
-
200
- `+Qt({customTypeModels:c,sharedSliceModels:l,localeIDs:o.value.results.map(e=>e.id),typesProvider:`@prismicio/client`,clientIntegration:{includeCreateClientInterface:c.length>0||l.length>0,includeContentNamespace:!0}})),console.info(`Generated types written to ${r}`)}async function ir(){let{positionals:[t]}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`types`:await rr();break;default:t&&(console.error(`Unknown codegen subcommand: ${t}\n`),process.exitCode=1),console.info(`Generate code from Prismic models.
201
-
202
- USAGE
203
- prismic codegen <command> [flags]
204
-
205
- COMMANDS
206
- types Generate TypeScript types from models pushed to Prismic
207
-
208
- FLAGS
209
- -h, --help Show help for command
210
-
211
- LEARN MORE
212
- Use \`prismic codegen <command> --help\` for more information about a command.`)}}function Q(e){return e.replace(/([a-z])([A-Z])/g,`$1 $2`).replace(/[_-]+/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}const ar=z({id:H(),label:H(),repeatable:R(),status:R(),format:H(),json:V(H(),V(H(),U()))});async function or(){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 x}var x=class extends Error{constructor(e){super(e[0].message),this.name=`ValiError`,this.issues=e}};function ee(e){return{kind:`validation`,type:`url`,reference:ee,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 te(e,t,n){return typeof e.fallback==`function`?e.fallback(t,n):e.fallback}function ne(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=ne(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]:ne(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]=te(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=ne(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 ie(e,t,n){let r=e[`~run`]({value:t},f(n));if(r.issues)throw new x(r.issues);return r.value}function ae(...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 j(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 oe=new URL(`.prismic`,I(c(l()))),se=`https://prismic.io`;async function ce(e,t){let n={token:e,host:t?.host};await s(oe,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(oe,`utf-8`);return JSON.parse(e)}catch{return}}async function ue(){try{await t(oe)}catch{return!0}return await le()?(await o(oe),!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=E({id:k(),label:k(),repeatable:C(),status:C(),format:k(),json:O(k(),O(k(),A()))});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.
213
3
 
214
4
  USAGE
215
5
  prismic custom-type add-field boolean <type-id> <field-id> [flags]
@@ -220,7 +10,7 @@ ARGUMENTS
220
10
 
221
11
  FLAGS
222
12
  -t, --tab string Target tab (default: first existing tab, or "Main")
223
- -l, --label string Display label for the field (inferred from field-id if omitted)
13
+ -l, --label string Display label for the field
224
14
  --default Set default value to true
225
15
  --true-label string Label shown when toggle is on
226
16
  --false-label string Label shown when toggle is off
@@ -231,7 +21,7 @@ EXAMPLES
231
21
  prismic custom-type add-field boolean article published --default
232
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
233
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
234
- `),console.error(`Usage: prismic custom-type add-field boolean <type-id> <field-id>`),process.exitCode=1;return}let d=await G(`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=W(ar,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:{label:i??Q(u),...a&&{default_value:!0},...o&&{placeholder_true:o},...c&&{placeholder_false:c}}};p.json[h][u]=g;try{await s(f,K(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 sr=z({id:H(),label:H(),repeatable:R(),status:R(),format:H(),json:V(H(),V(H(),U()))});async function cr(){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 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=j(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=E({id:k(),label:k(),repeatable:C(),status:C(),format:k(),json:O(k(),O(k(),A()))});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.
235
25
 
236
26
  USAGE
237
27
  prismic custom-type add-field color <type-id> <field-id> [flags]
@@ -242,7 +32,7 @@ ARGUMENTS
242
32
 
243
33
  FLAGS
244
34
  -t, --tab string Target tab (default: first existing tab, or "Main")
245
- -l, --label string Display label for the field (inferred from field-id if omitted)
35
+ -l, --label string Display label for the field
246
36
  -p, --placeholder string Placeholder text
247
37
  -h, --help Show help for command
248
38
 
@@ -251,7 +41,7 @@ EXAMPLES
251
41
  prismic custom-type add-field color homepage accent --tab "Design"
252
42
  prismic custom-type add-field color homepage text_color --label "Text Color"`);return}if(!o){console.error(`Missing required argument: type-id
253
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
254
- `),console.error(`Usage: prismic custom-type add-field color <type-id> <field-id>`),process.exitCode=1;return}let l=await G(`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=W(sr,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:{label:i??Q(c),...a&&{placeholder:a}}};d.json[p][c]=m;try{await s(u,K(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 lr=z({id:H(),label:H(),repeatable:R(),status:R(),format:H(),json:V(H(),V(H(),U()))});async function ur(){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 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=j(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=E({id:k(),label:k(),repeatable:C(),status:C(),format:k(),json:O(k(),O(k(),A()))});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.
255
45
 
256
46
  USAGE
257
47
  prismic custom-type add-field date <type-id> <field-id> [flags]
@@ -262,7 +52,7 @@ ARGUMENTS
262
52
 
263
53
  FLAGS
264
54
  -t, --tab string Target tab (default: first existing tab, or "Main")
265
- -l, --label string Display label for the field (inferred from field-id if omitted)
55
+ -l, --label string Display label for the field
266
56
  -p, --placeholder string Placeholder text
267
57
  --default string Default date value (YYYY-MM-DD format)
268
58
  -h, --help Show help for command
@@ -272,7 +62,7 @@ EXAMPLES
272
62
  prismic custom-type add-field date event start_date --tab "Schedule"
273
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
274
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
275
- `),console.error(`Usage: prismic custom-type add-field date <type-id> <field-id>`),process.exitCode=1;return}let u=await G(`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=W(lr,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:{label:i??Q(l),...a&&{placeholder:a},...o&&{default:o}}};f.json[m][l]=h;try{await s(d,K(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 dr=z({id:H(),label:H(),repeatable:R(),status:R(),format:H(),json:V(H(),V(H(),U()))});async function fr(){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 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=j(_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=E({id:k(),label:k(),repeatable:C(),status:C(),format:k(),json:O(k(),O(k(),A()))});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.
276
66
 
277
67
  USAGE
278
68
  prismic custom-type add-field embed <type-id> <field-id> [flags]
@@ -283,7 +73,7 @@ ARGUMENTS
283
73
 
284
74
  FLAGS
285
75
  -t, --tab string Target tab (default: first existing tab, or "Main")
286
- -l, --label string Display label for the field (inferred from field-id if omitted)
76
+ -l, --label string Display label for the field
287
77
  -p, --placeholder string Placeholder text
288
78
  -h, --help Show help for command
289
79
 
@@ -292,7 +82,7 @@ EXAMPLES
292
82
  prismic custom-type add-field embed homepage youtube --tab "Media"
293
83
  prismic custom-type add-field embed homepage media --label "Media Embed"`);return}if(!o){console.error(`Missing required argument: type-id
294
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
295
- `),console.error(`Usage: prismic custom-type add-field embed <type-id> <field-id>`),process.exitCode=1;return}let l=await G(`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=W(dr,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:{label:i??Q(c),...a&&{placeholder:a}}};d.json[p][c]=m;try{await s(u,K(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 pr=z({id:H(),label:H(),repeatable:R(),status:R(),format:H(),json:V(H(),V(H(),U()))});async function mr(){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 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=j(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=E({id:k(),label:k(),repeatable:C(),status:C(),format:k(),json:O(k(),O(k(),A()))});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.
296
86
 
297
87
  USAGE
298
88
  prismic custom-type add-field geo-point <type-id> <field-id> [flags]
@@ -303,7 +93,7 @@ ARGUMENTS
303
93
 
304
94
  FLAGS
305
95
  -t, --tab string Target tab (default: first existing tab, or "Main")
306
- -l, --label string Display label for the field (inferred from field-id if omitted)
96
+ -l, --label string Display label for the field
307
97
  -h, --help Show help for command
308
98
 
309
99
  EXAMPLES
@@ -311,7 +101,7 @@ EXAMPLES
311
101
  prismic custom-type add-field geo-point store address --tab "Details"
312
102
  prismic custom-type add-field geo-point event venue --label "Event Venue"`);return}if(!a){console.error(`Missing required argument: type-id
313
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
314
- `),console.error(`Usage: prismic custom-type add-field geo-point <type-id> <field-id>`),process.exitCode=1;return}let c=await G(`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=W(pr,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:{label:i??Q(o)}};u.json[f][o]=p;try{await s(l,K(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 hr=z({id:H(),label:H(),repeatable:R(),status:R(),format:H(),json:V(H(),V(H(),U()))});async function gr(){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 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=j(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=E({id:k(),label:k(),repeatable:C(),status:C(),format:k(),json:O(k(),O(k(),A()))});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.
315
105
 
316
106
  USAGE
317
107
  prismic custom-type add-field image <type-id> <field-id> [flags]
@@ -322,7 +112,7 @@ ARGUMENTS
322
112
 
323
113
  FLAGS
324
114
  -t, --tab string Target tab (default: first existing tab, or "Main")
325
- -l, --label string Display label for the field (inferred from field-id if omitted)
115
+ -l, --label string Display label for the field
326
116
  -p, --placeholder string Placeholder text
327
117
  -h, --help Show help for command
328
118
 
@@ -331,7 +121,7 @@ EXAMPLES
331
121
  prismic custom-type add-field image article thumbnail --tab "Media"
332
122
  prismic custom-type add-field image product photo --label "Product Photo"`);return}if(!o){console.error(`Missing required argument: type-id
333
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
334
- `),console.error(`Usage: prismic custom-type add-field image <type-id> <field-id>`),process.exitCode=1;return}let l=await G(`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=W(hr,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:{label:i??Q(c),...a&&{placeholder:a}}};d.json[p][c]=m;try{await s(u,K(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 _r=z({id:H(),label:H(),repeatable:R(),status:R(),format:H(),json:V(H(),V(H(),U()))});async function vr(){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 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=j(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=E({id:k(),label:k(),repeatable:C(),status:C(),format:k(),json:O(k(),O(k(),A()))});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.
335
125
 
336
126
  USAGE
337
127
  prismic custom-type add-field key-text <type-id> <field-id> [flags]
@@ -342,7 +132,7 @@ ARGUMENTS
342
132
 
343
133
  FLAGS
344
134
  -t, --tab string Target tab (default: first existing tab, or "Main")
345
- -l, --label string Display label for the field (inferred from field-id if omitted)
135
+ -l, --label string Display label for the field
346
136
  -p, --placeholder string Placeholder text
347
137
  -h, --help Show help for command
348
138
 
@@ -351,7 +141,7 @@ EXAMPLES
351
141
  prismic custom-type add-field key-text homepage meta_title --tab "SEO"
352
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
353
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
354
- `),console.error(`Usage: prismic custom-type add-field key-text <type-id> <field-id>`),process.exitCode=1;return}let l=await G(`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=W(_r,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:{label:i??Q(c),...a&&{placeholder:a}}};d.json[p][c]=m;try{await s(u,K(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 yr=z({id:H(),label:H(),repeatable:R(),status:R(),format:H(),json:V(H(),V(H(),U()))});async function br(){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 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=j(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=E({id:k(),label:k(),repeatable:C(),status:C(),format:k(),json:O(k(),O(k(),A()))});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.
355
145
 
356
146
  USAGE
357
147
  prismic custom-type add-field link <type-id> <field-id> [flags]
@@ -362,7 +152,7 @@ ARGUMENTS
362
152
 
363
153
  FLAGS
364
154
  -t, --tab string Target tab (default: first existing tab, or "Main")
365
- -l, --label string Display label for the field (inferred from field-id if omitted)
155
+ -l, --label string Display label for the field
366
156
  -p, --placeholder string Placeholder text
367
157
  --variation string Slice variations (can be used multiple times)
368
158
  --allow-text Allow text with link
@@ -376,7 +166,7 @@ EXAMPLES
376
166
  prismic custom-type add-field link homepage cta --variation Primary --variation Secondary
377
167
  prismic custom-type add-field link homepage links --repeatable`);return}if(!d){console.error(`Missing required argument: type-id
378
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
379
- `),console.error(`Usage: prismic custom-type add-field link <type-id> <field-id>`),process.exitCode=1;return}let p=await G(`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=W(yr,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:{label:i??Q(f),...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,K(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 xr=z({id:H(),label:H(),repeatable:R(),status:R(),format:H(),json:V(H(),V(H(),U()))});async function Sr(){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 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=j(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=E({id:k(),label:k(),repeatable:C(),status:C(),format:k(),json:O(k(),O(k(),A()))});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.
380
170
 
381
171
  USAGE
382
172
  prismic custom-type add-field number <type-id> <field-id> [flags]
@@ -387,7 +177,7 @@ ARGUMENTS
387
177
 
388
178
  FLAGS
389
179
  -t, --tab string Target tab (default: first existing tab, or "Main")
390
- -l, --label string Display label for the field (inferred from field-id if omitted)
180
+ -l, --label string Display label for the field
391
181
  -p, --placeholder string Placeholder text
392
182
  --min number Minimum value
393
183
  --max number Maximum value
@@ -399,7 +189,7 @@ EXAMPLES
399
189
  prismic custom-type add-field number product quantity --min 0 --max 100
400
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
401
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
402
- `),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 G(`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=W(xr,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 ee={type:`Number`,config:{label:i??Q(d),...a&&{placeholder:a},...f!==void 0&&{min:f},...p!==void 0&&{max:p},...m!==void 0&&{step:m}}};_.json[y][d]=ee;try{await s(g,K(_))}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 Cr=z({id:H(),label:H(),repeatable:R(),status:R(),format:H(),json:V(H(),V(H(),U()))});async function wr(){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 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=j(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=E({id:k(),label:k(),repeatable:C(),status:C(),format:k(),json:O(k(),O(k(),A()))});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.
403
193
 
404
194
  USAGE
405
195
  prismic custom-type add-field rich-text <type-id> <field-id> [flags]
@@ -410,7 +200,7 @@ ARGUMENTS
410
200
 
411
201
  FLAGS
412
202
  -t, --tab string Target tab (default: first existing tab, or "Main")
413
- -l, --label string Display label for the field (inferred from field-id if omitted)
203
+ -l, --label string Display label for the field
414
204
  -p, --placeholder string Placeholder text
415
205
  --single string Allowed block types for single-line (comma-separated)
416
206
  --multi string Allowed block types for multi-line (comma-separated)
@@ -428,7 +218,7 @@ EXAMPLES
428
218
  prismic custom-type add-field rich-text page tagline --single "heading1"
429
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
430
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
431
- `),console.error(`Usage: prismic custom-type add-field rich-text <type-id> <field-id>`),process.exitCode=1;return}let f=await G(`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=W(Cr,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:{label:i??Q(d),...a&&{placeholder:a},...o&&{single:o},...c&&{multi:c},...l&&{allowTargetBlank:!0}}};m.json[g][d]=_;try{await s(p,K(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 Tr=z({id:H(),label:H(),repeatable:R(),status:R(),format:H(),json:V(H(),V(H(),U()))});async function Er(){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 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=j(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=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,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.
432
222
 
433
223
  USAGE
434
224
  prismic custom-type add-field select <type-id> <field-id> [flags]
@@ -439,7 +229,7 @@ ARGUMENTS
439
229
 
440
230
  FLAGS
441
231
  -t, --tab string Target tab (default: first existing tab, or "Main")
442
- -l, --label string Display label for the field (inferred from field-id if omitted)
232
+ -l, --label string Display label for the field
443
233
  -p, --placeholder string Placeholder text
444
234
  --option string Add an option (can be used multiple times)
445
235
  --default string Default selected value
@@ -450,7 +240,7 @@ EXAMPLES
450
240
  prismic custom-type add-field select product size --option "small" --option "medium" --option "large" --default "medium"
451
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
452
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
453
- `),console.error(`Usage: prismic custom-type add-field select <type-id> <field-id>`),process.exitCode=1;return}let d=await G(`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=W(Tr,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:{label:i??Q(u),...a&&{placeholder:a},...o&&o.length>0&&{options:o},...c&&{default_value:c}}};p.json[h][u]=g;try{await s(f,K(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 Dr=z({id:H(),label:H(),repeatable:R(),status:R(),format:H(),json:V(H(),V(H(),U()))});async function Or(){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 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=j(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=E({id:k(),label:k(),repeatable:C(),status:C(),format:k(),json:O(k(),O(k(),A()))});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.
454
244
 
455
245
  USAGE
456
246
  prismic custom-type add-field timestamp <type-id> <field-id> [flags]
@@ -461,7 +251,7 @@ ARGUMENTS
461
251
 
462
252
  FLAGS
463
253
  -t, --tab string Target tab (default: first existing tab, or "Main")
464
- -l, --label string Display label for the field (inferred from field-id if omitted)
254
+ -l, --label string Display label for the field
465
255
  -p, --placeholder string Placeholder text
466
256
  --default string Default timestamp value (ISO 8601 format)
467
257
  -h, --help Show help for command
@@ -471,7 +261,7 @@ EXAMPLES
471
261
  prismic custom-type add-field timestamp event start --tab "Schedule"
472
262
  prismic custom-type add-field timestamp article published_at --label "Published At"`);return}if(!c){console.error(`Missing required argument: type-id
473
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
474
- `),console.error(`Usage: prismic custom-type add-field timestamp <type-id> <field-id>`),process.exitCode=1;return}let u=await G(`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=W(Dr,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:{label:i??Q(l),...a&&{placeholder:a},...o&&{default:o}}};f.json[m][l]=h;try{await s(d,K(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 kr=z({id:H(),label:H(),repeatable:R(),status:R(),format:H(),json:V(H(),V(H(),U()))});async function Ar(){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 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=j(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=E({id:k(),label:k(),repeatable:C(),status:C(),format:k(),json:O(k(),O(k(),A()))});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.
475
265
 
476
266
  USAGE
477
267
  prismic custom-type add-field uid <type-id> <field-id> [flags]
@@ -482,7 +272,7 @@ ARGUMENTS
482
272
 
483
273
  FLAGS
484
274
  -t, --tab string Target tab (default: first existing tab, or "Main")
485
- -l, --label string Display label for the field (inferred from field-id if omitted)
275
+ -l, --label string Display label for the field
486
276
  -p, --placeholder string Placeholder text
487
277
  -h, --help Show help for command
488
278
 
@@ -491,7 +281,7 @@ EXAMPLES
491
281
  prismic custom-type add-field uid article slug --label "URL Slug"
492
282
  prismic custom-type add-field uid product sku --placeholder "Enter unique SKU"`);return}if(!o){console.error(`Missing required argument: type-id
493
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
494
- `),console.error(`Usage: prismic custom-type add-field uid <type-id> <field-id>`),process.exitCode=1;return}let l=await G(`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=W(kr,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:{label:i??Q(c),...a&&{placeholder:a}}};d.json[p][c]=m;try{await s(u,K(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 jr(){let{positionals:[t]}=e({args:process.argv.slice(4),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`boolean`:await or();break;case`color`:await cr();break;case`date`:await ur();break;case`embed`:await fr();break;case`geo-point`:await mr();break;case`image`:await gr();break;case`key-text`:await vr();break;case`link`:await br();break;case`number`:await Sr();break;case`rich-text`:await wr();break;case`select`:await Er();break;case`timestamp`:await Or();break;case`uid`:await Ar();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 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=j(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.
495
285
 
496
286
  USAGE
497
287
  prismic custom-type add-field <field-type> <type-id> <field-id> [flags]
@@ -521,7 +311,7 @@ EXAMPLES
521
311
  prismic custom-type add-field key-text homepage meta_title --tab "SEO"
522
312
  prismic custom-type add-field link homepage button --allow-text
523
313
  prismic custom-type add-field rich-text homepage body --multi "paragraph,heading2,strong,em"
524
- prismic custom-type add-field select homepage layout --option "full" --option "sidebar"`)}}const Mr=z({id:H(),label:H(),repeatable:R(),status:R(),format:H(),json:V(H(),V(H(),U()))});async function Nr(){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 B=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 L(`package.json`))return{ok:!1,error:`Could not find project root (no package.json found)`};let t=await H(),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=j(B,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 H(){let e=await Ve(),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 Be=E({dependencies:D(O(k(),k()))});async function Ve(){let e=await L(`package.json`);if(e)try{let t=await r(e,`utf8`),{dependencies:n={}}=ie(Be,JSON.parse(t));if(`next`in n)return`next`;if(`nuxt`in n)return`nuxt`;if(`@sveltejs/kit`in n)return`sveltekit`}catch{}}function U(e){return e.toLowerCase().replace(/(^|[-_\s]+)(.)?/g,(e,t,n)=>n?.toUpperCase()??``)}const He=E({id:k(),label:k(),repeatable:C(),status:C(),format:k(),json:O(k(),O(k(),A()))});async function Ue(){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.
525
315
 
526
316
  USAGE
527
317
  prismic custom-type connect-slice <type-id> <slice-id> [flags]
@@ -539,7 +329,7 @@ EXAMPLES
539
329
  prismic custom-type connect-slice homepage CallToAction --slice-zone slices
540
330
  prismic custom-type connect-slice article HeroSection -z body`);return}if(!i){console.error(`Missing required argument: type-id
541
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
542
- `),console.error(`Usage: prismic custom-type connect-slice <type-id> <slice-id>`),process.exitCode=1;return}let o=await J(a);if(!o.ok){console.error(o.error),process.exitCode=1;return}let c=await G(`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=W(Mr,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,K(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 Pr(){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 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=j(He,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 We(){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.
543
333
 
544
334
  USAGE
545
335
  prismic custom-type create <id> [flags]
@@ -553,7 +343,7 @@ FLAGS
553
343
  -h, --help Show help for command
554
344
 
555
345
  LEARN MORE
556
- 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??Fr(a),repeatable:!i,status:!0,format:`custom`,json:{Main:{}}},c=await G(`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,K(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 Fr(e){return e.toLowerCase().replace(/(^|[-_\s]+)(.)?/g,(e,t,n)=>n?.toUpperCase()??``)}const Ir=z({id:H(),label:H(),repeatable:R(),status:R(),format:H(),json:V(H(),V(H(),U()))});async function Lr(){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??Ge(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 Ge(e){return e.toLowerCase().replace(/(^|[-_\s]+)(.)?/g,(e,t,n)=>n?.toUpperCase()??``)}const Ke=E({id:k(),label:k(),repeatable:C(),status:C(),format:k(),json:O(k(),O(k(),A()))});async function qe(){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.
557
347
 
558
348
  USAGE
559
349
  prismic custom-type disconnect-slice <type-id> <slice-id> [flags]
@@ -571,7 +361,7 @@ EXAMPLES
571
361
  prismic custom-type disconnect-slice homepage CallToAction --slice-zone slices
572
362
  prismic custom-type disconnect-slice article HeroSection -z body`);return}if(!i){console.error(`Missing required argument: type-id
573
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
574
- `),console.error(`Usage: prismic custom-type disconnect-slice <type-id> <slice-id>`),process.exitCode=1;return}let o=await G(`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=W(Ir,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,K(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 Rr=z({id:H(),label:H(),repeatable:R(),status:R(),format:B(H()),json:V(H(),V(H(),U()))});async function zr(){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 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=j(Ke,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 Je=E({id:k(),label:k(),repeatable:C(),status:C(),format:D(k()),json:O(k(),O(k(),A()))});async function Ye(){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.
575
365
 
576
366
  USAGE
577
367
  prismic custom-type list [flags]
@@ -582,7 +372,7 @@ FLAGS
582
372
 
583
373
  EXAMPLES
584
374
  prismic custom-type list
585
- prismic custom-type list --json`);return}let a=await G(`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=W(Rr,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 Br=z({id:H(),label:H(),repeatable:R(),status:R(),format:B(H()),json:V(H(),V(H(),U()))});async function Vr(){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 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=j(Je,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 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,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.
586
376
 
587
377
  USAGE
588
378
  prismic custom-type remove <type-id> [flags]
@@ -597,7 +387,7 @@ FLAGS
597
387
  EXAMPLES
598
388
  prismic custom-type remove settings
599
389
  prismic custom-type remove settings -y`);return}if(!i){console.error(`Missing required argument: type-id
600
- `),console.error(`Usage: prismic custom-type remove <type-id>`),process.exitCode=1;return}let a=await G(`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=W(Br,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 Hr=z({id:H(),label:H(),repeatable:R(),status:R(),format:B(H()),json:V(H(),V(H(),U()))});async function Ur(){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 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=j(Xe,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 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,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.
601
391
 
602
392
  USAGE
603
393
  prismic custom-type remove-field <type-id> <field-id> [flags]
@@ -614,7 +404,7 @@ EXAMPLES
614
404
  prismic custom-type remove-field settings title
615
405
  prismic custom-type remove-field settings description --tab "Content"`);return}if(!i){console.error(`Missing required argument: type-id
616
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
617
- `),console.error(`Usage: prismic custom-type remove-field <type-id> <field-id>`),process.exitCode=1;return}let o=await G(`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=W(Hr,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,K(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 Wr=z({id:H(),label:H(),repeatable:R(),status:R(),format:B(H()),json:V(H(),V(H(),U()))});async function Gr(){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 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=j(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}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 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},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).
618
408
 
619
409
  USAGE
620
410
  prismic custom-type set-name <type-id> <new-name> [flags]
@@ -630,7 +420,7 @@ EXAMPLES
630
420
  prismic custom-type set-name settings "Site Settings"
631
421
  prismic custom-type set-name menu "Navigation Menu"`);return}if(!n){console.error(`Missing required argument: type-id
632
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
633
- `),console.error(`Usage: prismic custom-type set-name <type-id> <new-name>`),process.exitCode=1;return}let a=await G(`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=W(Wr,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,K(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 Kr=z({id:H(),label:H(),repeatable:R(),status:R(),format:B(H()),json:V(H(),V(H(),U()))});async function qr(){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 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=j(et,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 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,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.
634
424
 
635
425
  USAGE
636
426
  prismic custom-type view <type-id> [flags]
@@ -645,7 +435,7 @@ FLAGS
645
435
  EXAMPLES
646
436
  prismic custom-type view settings
647
437
  prismic custom-type view settings --json`);return}if(!i){console.error(`Missing required argument: type-id
648
- `),console.error(`Usage: prismic custom-type view <type-id>`),process.exitCode=1;return}let a=await G(`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=W(Kr,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 Jr(){let{positionals:[t]}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`create`:await Pr();break;case`list`:await zr();break;case`view`:await qr();break;case`remove`:await Vr();break;case`set-name`:await Gr();break;case`add-field`:await jr();break;case`remove-field`:await Ur();break;case`connect-slice`:await Nr();break;case`disconnect-slice`:await Lr();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 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=j(nt,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 it(){let{positionals:[t]}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`create`:await We();break;case`list`:await Ye();break;case`view`:await rt();break;case`remove`:await Ze();break;case`set-name`:await tt();break;case`add-field`:await ze();break;case`remove-field`:await $e();break;case`connect-slice`:await Ue();break;case`disconnect-slice`:await qe();break;default:t&&(console.error(`Unknown custom-type subcommand: ${t}\n`),process.exitCode=1),console.info(`Manage custom types in a Prismic repository.
649
439
 
650
440
  USAGE
651
441
  prismic custom-type <command> [flags]
@@ -665,7 +455,7 @@ FLAGS
665
455
  -h, --help Show help for command
666
456
 
667
457
  LEARN MORE
668
- Use \`prismic custom-type <command> --help\` for more information about a command.`)}}async function Yr(){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 at=`prismic.config.json`,ot=E({repositoryName:k(),apiEndpoint:D(ae(k(),ee())),localSliceMachineSimulatorURL:D(ae(k(),ee())),libraries:D(S(k())),adapter:D(k()),labs:D(E({legacySliceUpgrader:D(C())}))});async function st(e,t=c(process.cwd())){let n=await dt(t);return n.ok?(await s(n.path,z(e)),{ok:!0,config:e}):n}async function W(e=c(process.cwd())){let t=await G(e);if(t.ok)return t.config.repositoryName}async function G(e=c(process.cwd())){let t=await ut(e);if(!t.ok)return t;try{let e=await r(t.path,`utf8`),n=j(ot,JSON.parse(e));return n.success?{ok:!0,config:n.output}:{ok:!1,error:new ct(n.issues)}}catch{return{ok:!1,error:new ct}}}var ct=class extends Error{issues;constructor(e=[]){super(`prismic.config.json is invalid.`),this.issues=e}};async function lt(e,t=c(process.cwd())){let n=await ut(t);if(!n.ok)return n;let r=await G(t);if(!r.ok)return r;let i={...r.config,...e};return await s(n.path,z(i)),{ok:!0,config:i}}async function ut(e=c(process.cwd())){let t=await L(at,{start:e,stop:`package.json`});return t?{ok:!0,path:t}:{ok:!1,error:new ft}}async function dt(e=c(process.cwd())){let t=await L(`package.json`,{start:e});return t?{ok:!0,path:new URL(at,t)}:{ok:!1,error:new pt}}var ft=class extends Error{message=`Could not find a prismic.config.json file.`},pt=class extends Error{message=`Could not find a package.json file.`};async function mt(){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.
669
459
 
670
460
  Use this command to connect an existing Prismic repository to your project.
671
461
  To create a new repository, use \`prismic repo create\` instead.
@@ -678,7 +468,7 @@ FLAGS
678
468
  -h, --help Show help for command
679
469
 
680
470
  LEARN MORE
681
- 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 On()).ok){console.error(`A prismic.config.json file already exists.`),process.exitCode=1;return}let n=await Dn({repositoryName:t.repo});if(!n.ok){n.error instanceof Pn?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 Xr(){let{values:{help:t,name:n,repo:r=await q()},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 G()).ok){console.error(`A prismic.config.json file already exists.`),process.exitCode=1;return}let n=await st({repositoryName:t.repo});if(!n.ok){n.error instanceof pt?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 K(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:ie(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 J(a)};else if(a.status===403)return{ok:!1,value:o,error:new q(a)};else return{ok:!1,value:o,error:new ht(a)}}var ht=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}},q=class extends ht{},J=class extends ht{};async function gt(){let{values:{help:t,name:n,repo:r=await W()},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.
682
472
 
683
473
  By default, this command reads the repository from prismic.config.json at the
684
474
  project root.
@@ -695,7 +485,21 @@ FLAGS
695
485
  -h, --help Show help for command
696
486
 
697
487
  LEARN MORE
698
- 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()){$r();return}let a=n?await Qr(r,i,n):await Zr(r,i);if(!a.ok){if(typeof a.value==`string`&&a.value.includes(`already existing languages`))return;a.error instanceof X?$r():(console.error(`Failed to add locale: ${K(a.value)}`),process.exitCode=1);return}console.info(`Locale added: ${i}`)}async function Zr(e,t){return await Y(new URL(`/app/settings/multilanguages`,await j(e)),{method:`POST`,body:{languages:[t]}})}async function Qr(e,t,n){let[r,i]=t.split(`-`);return await Y(new URL(`/app/settings/multilanguages/custom`,await j(e)),{method:`POST`,body:{lang:{label:n,id:r||t},region:{label:n,id:i||r||t}}})}function $r(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function ei(){let{values:{repo:t=await q(),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.
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()){yt();return}let a=n?await vt(r,i,n):await _t(r,i);if(!a.ok){if(typeof a.value==`string`&&a.value.includes(`already existing languages`))return;a.error instanceof q?yt():(console.error(`Failed to add locale: ${z(a.value)}`),process.exitCode=1);return}console.info(`Locale added: ${i}`)}async function _t(e,t){return await K(new URL(`/app/settings/multilanguages`,await F(e)),{method:`POST`,body:{languages:[t]}})}async function vt(e,t,n){let[r,i]=t.split(`-`);return await K(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 yt(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function bt(){let{values:{help:t,repo:n=await W(),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
+
490
+ By default, this command reads the repository from prismic.config.json at the
491
+ project root.
492
+
493
+ USAGE
494
+ prismic locale list [flags]
495
+
496
+ FLAGS
497
+ --json Output as JSON
498
+ -r, --repo string Repository domain
499
+ -h, --help Show help for command
500
+
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()){Ct();return}let i=await St(n);if(!i.ok){i.error instanceof q?Ct():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 xt=E({results:S(E({id:k(),label:k(),customName:w(k()),isMaster:C()}))});async function St(e){let t=new URL(`/locale/repository/locales`,await de());return t.searchParams.set(`repository`,e),await K(t,{schema:xt})}function Ct(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function wt(){let{values:{repo:t=await W(),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.
699
503
 
700
504
  By default, this command reads the repository from prismic.config.json at the
701
505
  project root.
@@ -711,7 +515,7 @@ FLAGS
711
515
  -h, --help Show help for command
712
516
 
713
517
  LEARN MORE
714
- 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()){ni();return}let i=await ti(t,r);if(!i.ok){i.error instanceof X?ni():(console.error(`Failed to remove locale: ${K(i.value)}`),process.exitCode=1);return}console.info(`Removed locale: ${r}`)}async function ti(e,t){let n=new URL(`/locale/repository/locales/${t}`,await $t());return n.searchParams.set(`repository`,e),await Y(n,{method:`DELETE`})}function ni(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function ri(){let{values:{help:t,repo:n=await q()},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 M()){Et();return}let i=await Tt(t,r);if(!i.ok){i.error instanceof q?Et():(console.error(`Failed to remove locale: ${z(i.value)}`),process.exitCode=1);return}console.info(`Removed locale: ${r}`)}async function Tt(e,t){let n=new URL(`/locale/repository/locales/${t}`,await de());return n.searchParams.set(`repository`,e),await K(n,{method:`DELETE`})}function Et(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function Dt(){let{values:{help:t,repo:n=await W()},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.
715
519
 
716
520
  By default, this command reads the repository from prismic.config.json at the
717
521
  project root.
@@ -727,7 +531,7 @@ FLAGS
727
531
  -h, --help Show help for command
728
532
 
729
533
  LEARN MORE
730
- 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()){ai();return}let i=await tr(n);if(!i.ok){i.error instanceof X?ai():I(i.error)?(console.error(`Failed to set default locale: Invalid response: ${K(i.error.issues)}`),process.exitCode=1):(console.error(`Failed to set default locale: ${K(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 ii(n,o);if(!s.ok){s.error instanceof X?ai():(console.error(`Failed to set default locale: ${K(s.value)}`),process.exitCode=1);return}console.info(`Default locale set: ${r}`)}async function ii(e,t){let n=new URL(`/locale/repository/locales`,await $t());return n.searchParams.set(`repository`,e),await Y(n,{method:`POST`,body:{id:t.id,label:t.label,customName:t.customName,isMaster:!0}})}function ai(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function oi(){let{positionals:[t]}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`add`:await Xr();break;case`list`:await $n();break;case`remove`:await ei();break;case`set-default`:await ri();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 M()){kt();return}let i=await St(n);if(!i.ok){i.error instanceof q?kt():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 Ot(n,o);if(!s.ok){s.error instanceof q?kt():(console.error(`Failed to set default locale: ${z(s.value)}`),process.exitCode=1);return}console.info(`Default locale set: ${r}`)}async function Ot(e,t){let n=new URL(`/locale/repository/locales`,await de());return n.searchParams.set(`repository`,e),await K(n,{method:`POST`,body:{id:t.id,label:t.label,customName:t.customName,isMaster:!0}})}function kt(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}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`add`:await gt();break;case`list`:await bt();break;case`remove`:await wt();break;case`set-default`:await Dt();break;default:t&&(console.error(`Unknown locale subcommand: ${t}\n`),process.exitCode=1),console.info(`Manage locales in a Prismic repository.
731
535
 
732
536
  USAGE
733
537
  prismic locale <command> [flags]
@@ -742,7 +546,7 @@ FLAGS
742
546
  -h, --help Show help for command
743
547
 
744
548
  LEARN MORE
745
- Use \`prismic locale <command> --help\` for more information about a command.`)}}async function si(){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 jt(){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.
746
550
 
747
551
  USAGE
748
552
  prismic login [flags]
@@ -751,7 +555,7 @@ FLAGS
751
555
  -h, --help Show help for command
752
556
 
753
557
  LEARN MORE
754
- Use \`prismic <command> --help\` for more information about a command.`);return}return new Promise((e,t)=>{let n=f((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 an(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=ci(i);console.info(`Opening browser to complete login...`),console.info(`If the browser doesn't open, visit: ${a}`),li(a)}),n.on(`error`,e=>{clearTimeout(r),t(e)})})}function ci(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 li(e){d(`${process.platform===`darwin`?`open`:process.platform===`win32`?`start`:`xdg-open`} "${e.toString()}"`)}async function ui(){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 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=Mt(i);console.info(`Opening browser to complete login...`),console.info(`If the browser doesn't open, visit: ${a}`),Nt(a)}),n.on(`error`,e=>{clearTimeout(r),t(e)})})}function Mt(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 Nt(e){u(`${process.platform===`darwin`?`open`:process.platform===`win32`?`start`:`xdg-open`} "${e.toString()}"`)}async function Pt(){let{values:t}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}}});if(t.help){console.info(`Log out of Prismic.
755
559
 
756
560
  USAGE
757
561
  prismic logout [flags]
@@ -760,7 +564,7 @@ FLAGS
760
564
  -h, --help Show help for command
761
565
 
762
566
  LEARN MORE
763
- Use \`prismic <command> --help\` for more information about a command.`);return}await cn()?console.info(`Logged out of Prismic`):(console.error(`Logout failed. You can log out manually by deleting the file.`),process.exitCode=1)}const di=z({id:H(),label:H(),repeatable:R(),status:R(),format:H(),json:V(H(),V(H(),U()))});async function fi(){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 ue()?console.info(`Logged out of Prismic`):(console.error(`Logout failed. You can log out manually by deleting the file.`),process.exitCode=1)}const Ft=E({id:k(),label:k(),repeatable:C(),status:C(),format:k(),json:O(k(),O(k(),A()))});async function It(){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.
764
568
 
765
569
  USAGE
766
570
  prismic page-type add-field boolean <type-id> <field-id> [flags]
@@ -771,7 +575,7 @@ ARGUMENTS
771
575
 
772
576
  FLAGS
773
577
  -t, --tab string Target tab (default: first existing tab, or "Main")
774
- -l, --label string Display label for the field (inferred from field-id if omitted)
578
+ -l, --label string Display label for the field
775
579
  --default Set default value to true
776
580
  --true-label string Label shown when toggle is on
777
581
  --false-label string Label shown when toggle is off
@@ -782,7 +586,7 @@ EXAMPLES
782
586
  prismic page-type add-field boolean article published --default
783
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
784
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
785
- `),console.error(`Usage: prismic page-type add-field boolean <type-id> <field-id>`),process.exitCode=1;return}let d=await G(`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=W(di,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:{label:i??Q(u),...a&&{default_value:!0},...o&&{placeholder_true:o},...c&&{placeholder_false:c}}};p.json[h][u]=g;try{await s(f,K(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 pi=z({id:H(),label:H(),repeatable:R(),status:R(),format:H(),json:V(H(),V(H(),U()))});async function mi(){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 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=j(Ft,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 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,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.
786
590
 
787
591
  USAGE
788
592
  prismic page-type add-field color <type-id> <field-id> [flags]
@@ -793,7 +597,7 @@ ARGUMENTS
793
597
 
794
598
  FLAGS
795
599
  -t, --tab string Target tab (default: first existing tab, or "Main")
796
- -l, --label string Display label for the field (inferred from field-id if omitted)
600
+ -l, --label string Display label for the field
797
601
  -p, --placeholder string Placeholder text
798
602
  -h, --help Show help for command
799
603
 
@@ -802,7 +606,7 @@ EXAMPLES
802
606
  prismic page-type add-field color homepage accent --tab "Design"
803
607
  prismic page-type add-field color homepage text_color --label "Text Color"`);return}if(!o){console.error(`Missing required argument: type-id
804
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
805
- `),console.error(`Usage: prismic page-type add-field color <type-id> <field-id>`),process.exitCode=1;return}let l=await G(`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=W(pi,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:{label:i??Q(c),...a&&{placeholder:a}}};d.json[p][c]=m;try{await s(u,K(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 hi=z({id:H(),label:H(),repeatable:R(),status:R(),format:H(),json:V(H(),V(H(),U()))});async function gi(){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 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=j(Lt,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 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,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.
806
610
 
807
611
  USAGE
808
612
  prismic page-type add-field date <type-id> <field-id> [flags]
@@ -813,7 +617,7 @@ ARGUMENTS
813
617
 
814
618
  FLAGS
815
619
  -t, --tab string Target tab (default: first existing tab, or "Main")
816
- -l, --label string Display label for the field (inferred from field-id if omitted)
620
+ -l, --label string Display label for the field
817
621
  -p, --placeholder string Placeholder text
818
622
  --default string Default date value (YYYY-MM-DD format)
819
623
  -h, --help Show help for command
@@ -823,7 +627,7 @@ EXAMPLES
823
627
  prismic page-type add-field date event start_date --tab "Schedule"
824
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
825
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
826
- `),console.error(`Usage: prismic page-type add-field date <type-id> <field-id>`),process.exitCode=1;return}let u=await G(`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=W(hi,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:{label:i??Q(l),...a&&{placeholder:a},...o&&{default:o}}};f.json[m][l]=h;try{await s(d,K(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 _i=z({id:H(),label:H(),repeatable:R(),status:R(),format:H(),json:V(H(),V(H(),U()))});async function vi(){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 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=j(zt,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 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},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.
827
631
 
828
632
  USAGE
829
633
  prismic page-type add-field embed <type-id> <field-id> [flags]
@@ -834,7 +638,7 @@ ARGUMENTS
834
638
 
835
639
  FLAGS
836
640
  -t, --tab string Target tab (default: first existing tab, or "Main")
837
- -l, --label string Display label for the field (inferred from field-id if omitted)
641
+ -l, --label string Display label for the field
838
642
  -p, --placeholder string Placeholder text
839
643
  -h, --help Show help for command
840
644
 
@@ -843,7 +647,7 @@ EXAMPLES
843
647
  prismic page-type add-field embed homepage youtube --tab "Media"
844
648
  prismic page-type add-field embed homepage media --label "Media Embed"`);return}if(!o){console.error(`Missing required argument: type-id
845
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
846
- `),console.error(`Usage: prismic page-type add-field embed <type-id> <field-id>`),process.exitCode=1;return}let l=await G(`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=W(_i,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:{label:i??Q(c),...a&&{placeholder:a}}};d.json[p][c]=m;try{await s(u,K(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 yi=z({id:H(),label:H(),repeatable:R(),status:R(),format:H(),json:V(H(),V(H(),U()))});async function bi(){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 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=j(Vt,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 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},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.
847
651
 
848
652
  USAGE
849
653
  prismic page-type add-field geo-point <type-id> <field-id> [flags]
@@ -854,7 +658,7 @@ ARGUMENTS
854
658
 
855
659
  FLAGS
856
660
  -t, --tab string Target tab (default: first existing tab, or "Main")
857
- -l, --label string Display label for the field (inferred from field-id if omitted)
661
+ -l, --label string Display label for the field
858
662
  -h, --help Show help for command
859
663
 
860
664
  EXAMPLES
@@ -862,7 +666,7 @@ EXAMPLES
862
666
  prismic page-type add-field geo-point store address --tab "Details"
863
667
  prismic page-type add-field geo-point event venue --label "Event Venue"`);return}if(!a){console.error(`Missing required argument: type-id
864
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
865
- `),console.error(`Usage: prismic page-type add-field geo-point <type-id> <field-id>`),process.exitCode=1;return}let c=await G(`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=W(yi,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:{label:i??Q(o)}};u.json[f][o]=p;try{await s(l,K(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 xi=z({id:H(),label:H(),repeatable:R(),status:R(),format:H(),json:V(H(),V(H(),U()))});async function Si(){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 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=j(Ut,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 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,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.
866
670
 
867
671
  USAGE
868
672
  prismic page-type add-field image <type-id> <field-id> [flags]
@@ -873,7 +677,7 @@ ARGUMENTS
873
677
 
874
678
  FLAGS
875
679
  -t, --tab string Target tab (default: first existing tab, or "Main")
876
- -l, --label string Display label for the field (inferred from field-id if omitted)
680
+ -l, --label string Display label for the field
877
681
  -p, --placeholder string Placeholder text
878
682
  -h, --help Show help for command
879
683
 
@@ -882,7 +686,7 @@ EXAMPLES
882
686
  prismic page-type add-field image article thumbnail --tab "Media"
883
687
  prismic page-type add-field image product photo --label "Product Photo"`);return}if(!o){console.error(`Missing required argument: type-id
884
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
885
- `),console.error(`Usage: prismic page-type add-field image <type-id> <field-id>`),process.exitCode=1;return}let l=await G(`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=W(xi,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:{label:i??Q(c),...a&&{placeholder:a}}};d.json[p][c]=m;try{await s(u,K(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 Ci=z({id:H(),label:H(),repeatable:R(),status:R(),format:H(),json:V(H(),V(H(),U()))});async function wi(){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 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=j(Gt,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 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 a key-text (single-line text) field to an existing page type.
886
690
 
887
691
  USAGE
888
692
  prismic page-type add-field key-text <type-id> <field-id> [flags]
@@ -893,7 +697,7 @@ ARGUMENTS
893
697
 
894
698
  FLAGS
895
699
  -t, --tab string Target tab (default: first existing tab, or "Main")
896
- -l, --label string Display label for the field (inferred from field-id if omitted)
700
+ -l, --label string Display label for the field
897
701
  -p, --placeholder string Placeholder text
898
702
  -h, --help Show help for command
899
703
 
@@ -902,7 +706,7 @@ EXAMPLES
902
706
  prismic page-type add-field key-text homepage meta_title --tab "SEO"
903
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
904
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
905
- `),console.error(`Usage: prismic page-type add-field key-text <type-id> <field-id>`),process.exitCode=1;return}let l=await G(`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=W(Ci,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:{label:i??Q(c),...a&&{placeholder:a}}};d.json[p][c]=m;try{await s(u,K(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 Ti=z({id:H(),label:H(),repeatable:R(),status:R(),format:H(),json:V(H(),V(H(),U()))});async function Ei(){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 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=j(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:`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 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,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.
906
710
 
907
711
  USAGE
908
712
  prismic page-type add-field link <type-id> <field-id> [flags]
@@ -913,7 +717,7 @@ ARGUMENTS
913
717
 
914
718
  FLAGS
915
719
  -t, --tab string Target tab (default: first existing tab, or "Main")
916
- -l, --label string Display label for the field (inferred from field-id if omitted)
720
+ -l, --label string Display label for the field
917
721
  -p, --placeholder string Placeholder text
918
722
  --variation string Slice variations (can be used multiple times)
919
723
  --allow-text Allow text with link
@@ -927,7 +731,7 @@ EXAMPLES
927
731
  prismic page-type add-field link homepage cta --variation Primary --variation Secondary
928
732
  prismic page-type add-field link homepage links --repeatable`);return}if(!d){console.error(`Missing required argument: type-id
929
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
930
- `),console.error(`Usage: prismic page-type add-field link <type-id> <field-id>`),process.exitCode=1;return}let p=await G(`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=W(Ti,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:{label:i??Q(f),...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,K(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 Di=z({id:H(),label:H(),repeatable:R(),status:R(),format:H(),json:V(H(),V(H(),U()))});async function Oi(){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 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=j(Yt,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 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,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.
931
735
 
932
736
  USAGE
933
737
  prismic page-type add-field number <type-id> <field-id> [flags]
@@ -938,7 +742,7 @@ ARGUMENTS
938
742
 
939
743
  FLAGS
940
744
  -t, --tab string Target tab (default: first existing tab, or "Main")
941
- -l, --label string Display label for the field (inferred from field-id if omitted)
745
+ -l, --label string Display label for the field
942
746
  -p, --placeholder string Placeholder text
943
747
  --min number Minimum value
944
748
  --max number Maximum value
@@ -950,7 +754,7 @@ EXAMPLES
950
754
  prismic page-type add-field number product quantity --min 0 --max 100
951
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
952
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
953
- `),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 G(`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=W(Di,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 ee={type:`Number`,config:{label:i??Q(d),...a&&{placeholder:a},...f!==void 0&&{min:f},...p!==void 0&&{max:p},...m!==void 0&&{step:m}}};_.json[y][d]=ee;try{await s(g,K(_))}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 ki=z({id:H(),label:H(),repeatable:R(),status:R(),format:H(),json:V(H(),V(H(),U()))});async function Ai(){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 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=j(Zt,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 $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,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.
954
758
 
955
759
  USAGE
956
760
  prismic page-type add-field rich-text <type-id> <field-id> [flags]
@@ -961,7 +765,7 @@ ARGUMENTS
961
765
 
962
766
  FLAGS
963
767
  -t, --tab string Target tab (default: first existing tab, or "Main")
964
- -l, --label string Display label for the field (inferred from field-id if omitted)
768
+ -l, --label string Display label for the field
965
769
  -p, --placeholder string Placeholder text
966
770
  --single string Allowed block types for single-line (comma-separated)
967
771
  --multi string Allowed block types for multi-line (comma-separated)
@@ -979,7 +783,7 @@ EXAMPLES
979
783
  prismic page-type add-field rich-text page tagline --single "heading1"
980
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
981
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
982
- `),console.error(`Usage: prismic page-type add-field rich-text <type-id> <field-id>`),process.exitCode=1;return}let f=await G(`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=W(ki,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:{label:i??Q(d),...a&&{placeholder:a},...o&&{single:o},...c&&{multi:c},...l&&{allowTargetBlank:!0}}};m.json[g][d]=_;try{await s(p,K(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 ji=z({id:H(),label:H(),repeatable:R(),status:R(),format:H(),json:V(H(),V(H(),U()))});async function Mi(){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 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=j($t,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 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,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.
983
787
 
984
788
  USAGE
985
789
  prismic page-type add-field select <type-id> <field-id> [flags]
@@ -990,7 +794,7 @@ ARGUMENTS
990
794
 
991
795
  FLAGS
992
796
  -t, --tab string Target tab (default: first existing tab, or "Main")
993
- -l, --label string Display label for the field (inferred from field-id if omitted)
797
+ -l, --label string Display label for the field
994
798
  -p, --placeholder string Placeholder text
995
799
  --option string Add an option (can be used multiple times)
996
800
  --default string Default selected value
@@ -1001,7 +805,7 @@ EXAMPLES
1001
805
  prismic page-type add-field select product size --option "small" --option "medium" --option "large" --default "medium"
1002
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
1003
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
1004
- `),console.error(`Usage: prismic page-type add-field select <type-id> <field-id>`),process.exitCode=1;return}let d=await G(`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=W(ji,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:{label:i??Q(u),...a&&{placeholder:a},...o&&o.length>0&&{options:o},...c&&{default_value:c}}};p.json[h][u]=g;try{await s(f,K(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 Ni=z({id:H(),label:H(),repeatable:R(),status:R(),format:H(),json:V(H(),V(H(),U()))});async function Pi(){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 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=j(tn,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 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,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.
1005
809
 
1006
810
  USAGE
1007
811
  prismic page-type add-field timestamp <type-id> <field-id> [flags]
@@ -1012,7 +816,7 @@ ARGUMENTS
1012
816
 
1013
817
  FLAGS
1014
818
  -t, --tab string Target tab (default: first existing tab, or "Main")
1015
- -l, --label string Display label for the field (inferred from field-id if omitted)
819
+ -l, --label string Display label for the field
1016
820
  -p, --placeholder string Placeholder text
1017
821
  --default string Default timestamp value (ISO 8601 format)
1018
822
  -h, --help Show help for command
@@ -1022,7 +826,7 @@ EXAMPLES
1022
826
  prismic page-type add-field timestamp event start --tab "Schedule"
1023
827
  prismic page-type add-field timestamp article published_at --label "Published At"`);return}if(!c){console.error(`Missing required argument: type-id
1024
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
1025
- `),console.error(`Usage: prismic page-type add-field timestamp <type-id> <field-id>`),process.exitCode=1;return}let u=await G(`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=W(Ni,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:{label:i??Q(l),...a&&{placeholder:a},...o&&{default:o}}};f.json[m][l]=h;try{await s(d,K(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 Fi=z({id:H(),label:H(),repeatable:R(),status:R(),format:H(),json:V(H(),V(H(),U()))});async function Ii(){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 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=j(rn,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 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},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.
1026
830
 
1027
831
  USAGE
1028
832
  prismic page-type add-field uid <type-id> <field-id> [flags]
@@ -1033,7 +837,7 @@ ARGUMENTS
1033
837
 
1034
838
  FLAGS
1035
839
  -t, --tab string Target tab (default: first existing tab, or "Main")
1036
- -l, --label string Display label for the field (inferred from field-id if omitted)
840
+ -l, --label string Display label for the field
1037
841
  -p, --placeholder string Placeholder text
1038
842
  -h, --help Show help for command
1039
843
 
@@ -1042,7 +846,7 @@ EXAMPLES
1042
846
  prismic page-type add-field uid article slug --label "URL Slug"
1043
847
  prismic page-type add-field uid product sku --placeholder "Enter unique SKU"`);return}if(!o){console.error(`Missing required argument: type-id
1044
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
1045
- `),console.error(`Usage: prismic page-type add-field uid <type-id> <field-id>`),process.exitCode=1;return}let l=await G(`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=W(Fi,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:{label:i??Q(c),...a&&{placeholder:a}}};d.json[p][c]=m;try{await s(u,K(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 Li(){let{positionals:[t]}=e({args:process.argv.slice(4),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`boolean`:await fi();break;case`color`:await mi();break;case`date`:await gi();break;case`embed`:await vi();break;case`geo-point`:await bi();break;case`image`:await Si();break;case`key-text`:await wi();break;case`link`:await Ei();break;case`number`:await Oi();break;case`rich-text`:await Ai();break;case`select`:await Mi();break;case`timestamp`:await Pi();break;case`uid`:await Ii();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 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=j(on,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 cn(){let{positionals:[t]}=e({args:process.argv.slice(4),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`boolean`:await It();break;case`color`:await Rt();break;case`date`:await Bt();break;case`embed`:await Ht();break;case`geo-point`:await Wt();break;case`image`:await Kt();break;case`key-text`:await Jt();break;case`link`:await Xt();break;case`number`:await Qt();break;case`rich-text`:await en();break;case`select`:await nn();break;case`timestamp`:await an();break;case`uid`:await sn();break;default:t&&(console.error(`Unknown field type: ${t}\n`),process.exitCode=1),console.info(`Add a field to an existing page type.
1046
850
 
1047
851
  USAGE
1048
852
  prismic page-type add-field <field-type> <type-id> <field-id> [flags]
@@ -1072,7 +876,7 @@ EXAMPLES
1072
876
  prismic page-type add-field key-text homepage meta_title --tab "SEO"
1073
877
  prismic page-type add-field link homepage button --allow-text
1074
878
  prismic page-type add-field rich-text homepage body --multi "paragraph,heading2,strong,em"
1075
- prismic page-type add-field select homepage layout --option "full" --option "sidebar"`)}}const Ri=z({id:H(),label:H(),repeatable:R(),status:R(),format:H(),json:V(H(),V(H(),U()))});async function zi(){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 ln=E({id:k(),label:k(),repeatable:C(),status:C(),format:k(),json:O(k(),O(k(),A()))});async function un(){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.
1076
880
 
1077
881
  USAGE
1078
882
  prismic page-type connect-slice <type-id> <slice-id> [flags]
@@ -1090,7 +894,7 @@ EXAMPLES
1090
894
  prismic page-type connect-slice homepage CallToAction --slice-zone slices
1091
895
  prismic page-type connect-slice article HeroSection -z body`);return}if(!i){console.error(`Missing required argument: type-id
1092
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
1093
- `),console.error(`Usage: prismic page-type connect-slice <type-id> <slice-id>`),process.exitCode=1;return}let o=await J(a);if(!o.ok){console.error(o.error),process.exitCode=1;return}let c=await G(`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=W(Ri,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,K(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 Bi(){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 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=j(ln,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 dn(){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.
1094
898
 
1095
899
  USAGE
1096
900
  prismic page-type create <id> [flags]
@@ -1104,7 +908,7 @@ FLAGS
1104
908
  -h, --help Show help for command
1105
909
 
1106
910
  LEARN MORE
1107
- 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??Vi(a),repeatable:!i,status:!0,format:`page`,json:{Main:{},"SEO & Metadata":{}}},c=await G(`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,K(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 Vi(e){return e.toLowerCase().replace(/(^|[-_\s]+)(.)?/g,(e,t,n)=>n?.toUpperCase()??``)}const Hi=z({id:H(),label:H(),repeatable:R(),status:R(),format:H(),json:V(H(),V(H(),U()))});async function Ui(){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??fn(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 fn(e){return e.toLowerCase().replace(/(^|[-_\s]+)(.)?/g,(e,t,n)=>n?.toUpperCase()??``)}const pn=E({id:k(),label:k(),repeatable:C(),status:C(),format:k(),json:O(k(),O(k(),A()))});async function mn(){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.
1108
912
 
1109
913
  USAGE
1110
914
  prismic page-type disconnect-slice <type-id> <slice-id> [flags]
@@ -1122,7 +926,7 @@ EXAMPLES
1122
926
  prismic page-type disconnect-slice homepage CallToAction --slice-zone slices
1123
927
  prismic page-type disconnect-slice article HeroSection -z body`);return}if(!i){console.error(`Missing required argument: type-id
1124
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
1125
- `),console.error(`Usage: prismic page-type disconnect-slice <type-id> <slice-id>`),process.exitCode=1;return}let o=await G(`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=W(Hi,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,K(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 Wi=z({id:H(),label:H(),repeatable:R(),status:R(),format:B(H()),json:V(H(),V(H(),U()))});async function Gi(){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 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=j(pn,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 hn=E({id:k(),label:k(),repeatable:C(),status:C(),format:D(k()),json:O(k(),O(k(),A()))});async function gn(){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.
1126
930
 
1127
931
  USAGE
1128
932
  prismic page-type list [flags]
@@ -1133,7 +937,7 @@ FLAGS
1133
937
 
1134
938
  EXAMPLES
1135
939
  prismic page-type list
1136
- prismic page-type list --json`);return}let a=await G(`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=W(Wi,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 Ki=z({id:H(),label:H(),repeatable:R(),status:R(),format:B(H()),json:V(H(),V(H(),U()))});async function qi(){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 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=j(hn,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 _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,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.
1137
941
 
1138
942
  USAGE
1139
943
  prismic page-type remove <type-id> [flags]
@@ -1148,7 +952,7 @@ FLAGS
1148
952
  EXAMPLES
1149
953
  prismic page-type remove homepage
1150
954
  prismic page-type remove homepage -y`);return}if(!i){console.error(`Missing required argument: type-id
1151
- `),console.error(`Usage: prismic page-type remove <type-id>`),process.exitCode=1;return}let a=await G(`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=W(Ki,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 Ji=z({id:H(),label:H(),repeatable:R(),status:R(),format:B(H()),json:V(H(),V(H(),U()))});async function Yi(){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 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=j(_n,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 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,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.
1152
956
 
1153
957
  USAGE
1154
958
  prismic page-type remove-field <type-id> <field-id> [flags]
@@ -1165,7 +969,7 @@ EXAMPLES
1165
969
  prismic page-type remove-field homepage title
1166
970
  prismic page-type remove-field homepage meta_title --tab "SEO & Metadata"`);return}if(!i){console.error(`Missing required argument: type-id
1167
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
1168
- `),console.error(`Usage: prismic page-type remove-field <type-id> <field-id>`),process.exitCode=1;return}let o=await G(`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=W(Ji,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,K(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 Xi=z({id:H(),label:H(),repeatable:R(),status:R(),format:B(H()),json:V(H(),V(H(),U()))});async function Zi(){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 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=j(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}\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 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},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).
1169
973
 
1170
974
  USAGE
1171
975
  prismic page-type set-name <type-id> <new-name> [flags]
@@ -1181,7 +985,7 @@ EXAMPLES
1181
985
  prismic page-type set-name homepage "Home Page"
1182
986
  prismic page-type set-name blog_post "Blog Post"`);return}if(!n){console.error(`Missing required argument: type-id
1183
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
1184
- `),console.error(`Usage: prismic page-type set-name <type-id> <new-name>`),process.exitCode=1;return}let a=await G(`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=W(Xi,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,K(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 Qi=z({id:H(),label:H(),repeatable:R(),status:R(),format:B(H()),json:V(H(),V(H(),U()))});async function $i(){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 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=j(xn,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 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(`Set whether a page type is repeatable.
1185
989
 
1186
990
  USAGE
1187
991
  prismic page-type set-repeatable <type-id> <true|false> [flags]
@@ -1197,7 +1001,7 @@ EXAMPLES
1197
1001
  prismic page-type set-repeatable homepage true
1198
1002
  prismic page-type set-repeatable settings false`);return}if(!n){console.error(`Missing required argument: type-id
1199
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
1200
- `),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 G(`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=W(Qi,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,K(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 ea=z({id:H(),label:H(),repeatable:R(),status:R(),format:B(H()),json:V(H(),V(H(),U()))});async function ta(){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 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=j(Cn,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 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,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.
1201
1005
 
1202
1006
  USAGE
1203
1007
  prismic page-type view <type-id> [flags]
@@ -1212,7 +1016,7 @@ FLAGS
1212
1016
  EXAMPLES
1213
1017
  prismic page-type view homepage
1214
1018
  prismic page-type view homepage --json`);return}if(!i){console.error(`Missing required argument: type-id
1215
- `),console.error(`Usage: prismic page-type view <type-id>`),process.exitCode=1;return}let a=await G(`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=W(ea,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 na(){let{positionals:[t]}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`create`:await Bi();break;case`list`:await Gi();break;case`view`:await ta();break;case`remove`:await qi();break;case`set-name`:await Zi();break;case`set-repeatable`:await $i();break;case`add-field`:await Li();break;case`remove-field`:await Yi();break;case`connect-slice`:await zi();break;case`disconnect-slice`:await Ui();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 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=j(Tn,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 Dn(){let{positionals:[t]}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`create`:await dn();break;case`list`:await gn();break;case`view`:await En();break;case`remove`:await vn();break;case`set-name`:await Sn();break;case`set-repeatable`:await wn();break;case`add-field`:await cn();break;case`remove-field`:await bn();break;case`connect-slice`:await un();break;case`disconnect-slice`:await mn();break;default:t&&(console.error(`Unknown page-type subcommand: ${t}\n`),process.exitCode=1),console.info(`Manage page types in a Prismic repository.
1216
1020
 
1217
1021
  USAGE
1218
1022
  prismic page-type <command> [flags]
@@ -1233,7 +1037,7 @@ FLAGS
1233
1037
  -h, --help Show help for command
1234
1038
 
1235
1039
  LEARN MORE
1236
- Use \`prismic page-type <command> --help\` for more information about a command.`)}}async function ra(){let{values:{help:t,name:n,repo:r=await q()},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 On(){let{values:{help:t,name:n,repo:r=await W()},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.
1237
1041
 
1238
1042
  By default, this command reads the repository from prismic.config.json at the
1239
1043
  project root.
@@ -1250,21 +1054,7 @@ FLAGS
1250
1054
  -h, --help Show help for command
1251
1055
 
1252
1056
  LEARN MORE
1253
- 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()){oa();return}let a=ia(i);if(!a){console.error(`Invalid URL: ${i}`),process.exitCode=1;return}let o=await aa(r,{name:n||a.hostname,websiteURL:a.websiteURL,resolverPath:a.resolverPath});if(!o.ok){o.error instanceof X?oa():(console.error(`Failed to add preview: ${K(o.value)}`),process.exitCode=1);return}console.info(`Preview added: ${i}`)}function ia(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 aa(e,t){return await Y(new URL(`/previews/new`,await j(e)),{method:`POST`,body:{name:t.name,websiteURL:t.websiteURL,resolverPath:t.resolverPath}})}function oa(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function sa(){let{values:{help:t,repo:n=await q(),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(`Show the slice simulator URL for a Prismic repository.
1254
-
1255
- By default, this command reads the repository from prismic.config.json at the
1256
- project root.
1257
-
1258
- USAGE
1259
- prismic preview get-simulator [flags]
1260
-
1261
- FLAGS
1262
- --json Output as JSON
1263
- -r, --repo string Repository domain
1264
- -h, --help Show help for command
1265
-
1266
- LEARN MORE
1267
- 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()){ua();return}let i=await la(n);if(!i.ok){i.error instanceof X?ua():I(i.error)?(console.error(`Failed to get simulator URL: Invalid response: ${K(i.error.issues)}`),process.exitCode=1):(console.error(`Failed to get simulator URL: ${K(i.value)}`),process.exitCode=1);return}let a=i.value.simulator_url;if(!a){r?console.info(K({simulator_url:null})):console.info(`No simulator URL configured.`);return}r?console.info(K({simulator_url:a})):console.info(a)}const ca=z({simulator_url:B(H())});async function la(e){return await Y(new URL(`/core/repository`,await j(e)),{schema:ca})}function ua(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function da(){let{values:{help:t,repo:n=await q(),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 M()){jn();return}let a=kn(i);if(!a){console.error(`Invalid URL: ${i}`),process.exitCode=1;return}let o=await An(r,{name:n||a.hostname,websiteURL:a.websiteURL,resolverPath:a.resolverPath});if(!o.ok){o.error instanceof q?jn():(console.error(`Failed to add preview: ${z(o.value)}`),process.exitCode=1);return}console.info(`Preview added: ${i}`)}function kn(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 An(e,t){return await K(new URL(`/previews/new`,await F(e)),{method:`POST`,body:{name:t.name,websiteURL:t.websiteURL,resolverPath:t.resolverPath}})}function jn(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function Mn(){let{values:{help:t,repo:n=await W(),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.
1268
1058
 
1269
1059
  By default, this command reads the repository from prismic.config.json at the
1270
1060
  project root.
@@ -1278,7 +1068,7 @@ FLAGS
1278
1068
  -h, --help Show help for command
1279
1069
 
1280
1070
  LEARN MORE
1281
- 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()){ma();return}let i=await pa(n);if(!i.ok){i.error instanceof X?ma():I(i.error)?(console.error(`Failed to list previews: Invalid response: ${K(i.error.issues)}`),process.exitCode=1):(console.error(`Failed to list previews: ${K(i.value)}`),process.exitCode=1);return}let a=i.value.results;if(r)console.info(K(a));else for(let e of a)console.info(`${e.url} ${e.label}`)}const fa=z({results:L(z({id:H(),label:H(),url:H()}))});async function pa(e){return await Y(new URL(`/core/repository/preview_configs`,await j(e)),{schema:fa})}function ma(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function ha(){let{values:{help:t,repo:n=await q()},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 M()){Fn();return}let i=await Pn(n);if(!i.ok){i.error instanceof q?Fn():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 Nn=E({results:S(E({id:k(),label:k(),url:k()}))});async function Pn(e){return await K(new URL(`/core/repository/preview_configs`,await F(e)),{schema:Nn})}function Fn(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function In(){let{values:{help:t,repo:n=await W()},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.
1282
1072
 
1283
1073
  By default, this command reads the repository from prismic.config.json at the
1284
1074
  project root.
@@ -1294,20 +1084,7 @@ FLAGS
1294
1084
  -h, --help Show help for command
1295
1085
 
1296
1086
  LEARN MORE
1297
- 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()){_a();return}let i=await pa(n);if(!i.ok){i.error instanceof X?_a():(console.error(`Failed to fetch previews: ${K(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 ga(n,a.id);if(!o.ok){o.error instanceof X?_a():(console.error(`Failed to remove preview: ${K(o.value)}`),process.exitCode=1);return}console.info(`Preview removed: ${r}`)}async function ga(e,t){return await Y(new URL(`/previews/delete/${t}`,await j(e)),{method:`POST`,body:{}})}function _a(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function va(){let{values:{help:t,repo:n=await q()}}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!1});if(t){console.info(`Remove the slice simulator URL from a Prismic repository.
1298
-
1299
- By default, this command reads the repository from prismic.config.json at the
1300
- project root.
1301
-
1302
- USAGE
1303
- prismic preview remove-simulator [flags]
1304
-
1305
- FLAGS
1306
- -r, --repo string Repository domain
1307
- -h, --help Show help for command
1308
-
1309
- LEARN MORE
1310
- 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()){ba();return}let r=await ya(n);if(!r.ok){r.error instanceof X?ba():(console.error(`Failed to remove simulator URL: ${K(r.value)}`),process.exitCode=1);return}console.info(`Simulator URL removed.`)}async function ya(e){return await Y(new URL(`/core/repository`,await j(e)),{method:`PATCH`,body:{simulator_url:``}})}function ba(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function xa(){let{values:{help:t,repo:n=await q()},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 M()){Rn();return}let i=await Pn(n);if(!i.ok){i.error instanceof q?Rn():(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 Ln(n,a.id);if(!o.ok){o.error instanceof q?Rn():(console.error(`Failed to remove preview: ${z(o.value)}`),process.exitCode=1);return}console.info(`Preview removed: ${r}`)}async function Ln(e,t){return await K(new URL(`/previews/delete/${t}`,await F(e)),{method:`POST`,body:{}})}function Rn(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function zn(){let{values:{help:t,repo:n=await W()},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.
1311
1088
 
1312
1089
  By default, this command reads the repository from prismic.config.json at the
1313
1090
  project root.
@@ -1324,48 +1101,22 @@ FLAGS
1324
1101
  -h, --help Show help for command
1325
1102
 
1326
1103
  LEARN MORE
1327
- 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()){Ca();return}let a=ia(r);if(!a){console.error(`Invalid URL: ${r}`),process.exitCode=1;return}let o=await pa(n);if(!o.ok){o.error instanceof X?Ca():(console.error(`Failed to fetch previews: ${K(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 Sa(n,s.id,{name:i,websiteURL:a.websiteURL,resolverPath:a.resolverPath});if(!c.ok){c.error instanceof X?Ca():(console.error(`Failed to update preview: ${K(c.value)}`),process.exitCode=1);return}console.info(`Preview updated: ${r}`)}async function Sa(e,t,n){return await Y(new URL(`/previews/save/${t}`,await j(e)),{method:`POST`,body:{name:n.name,websiteURL:n.websiteURL,resolverPath:n.resolverPath}})}function Ca(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function wa(){let{values:{help:t,repo:n=await q()},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 slice simulator URL for a Prismic repository.
1328
-
1329
- If the URL pathname does not end with /slice-simulator, it is appended
1330
- automatically.
1331
-
1332
- By default, this command reads the repository from prismic.config.json at the
1333
- project root.
1334
-
1335
- USAGE
1336
- prismic preview set-simulator <url> [flags]
1337
-
1338
- ARGUMENTS
1339
- <url> Simulator URL (e.g. https://example.com/slice-simulator)
1340
-
1341
- FLAGS
1342
- -r, --repo string Repository domain
1343
- -h, --help Show help for command
1344
-
1345
- EXAMPLES
1346
- prismic preview set-simulator https://my-site.com
1347
- prismic preview set-simulator http://localhost:3000/slice-simulator
1348
-
1349
- LEARN MORE
1350
- 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()){Da();return}let i=Ta(r);if(!i){console.error(`Invalid URL: ${r}`),process.exitCode=1;return}let a=await Ea(n,i);if(!a.ok){a.error instanceof X?Da():(console.error(`Failed to set simulator URL: ${K(a.value)}`),process.exitCode=1);return}console.info(`Simulator URL set: ${i}`)}function Ta(e){try{let t=new URL(e);return t.pathname.endsWith(`/slice-simulator`)||(t.pathname=t.pathname.replace(/\/+$/,``)+`/slice-simulator`),t.toString()}catch{return}}async function Ea(e,t){return await Y(new URL(`/core/repository`,await j(e)),{method:`PATCH`,body:{simulator_url:t}})}function Da(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function Oa(){let{positionals:[t]}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`add`:await ra();break;case`list`:await da();break;case`remove`:await ha();break;case`set-name`:await xa();break;case`set-simulator`:await wa();break;case`get-simulator`:await sa();break;case`remove-simulator`:await va();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 M()){Vn();return}let a=kn(r);if(!a){console.error(`Invalid URL: ${r}`),process.exitCode=1;return}let o=await Pn(n);if(!o.ok){o.error instanceof q?Vn():(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 Bn(n,s.id,{name:i,websiteURL:a.websiteURL,resolverPath:a.resolverPath});if(!c.ok){c.error instanceof q?Vn():(console.error(`Failed to update preview: ${z(c.value)}`),process.exitCode=1);return}console.info(`Preview updated: ${r}`)}async function Bn(e,t,n){return await K(new URL(`/previews/save/${t}`,await F(e)),{method:`POST`,body:{name:n.name,websiteURL:n.websiteURL,resolverPath:n.resolverPath}})}function Vn(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function Hn(){let{positionals:[t]}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`add`:await On();break;case`list`:await Mn();break;case`remove`:await In();break;case`set-name`:await zn();break;default:t&&(console.error(`Unknown preview subcommand: ${t}\n`),process.exitCode=1),console.info(`Manage preview configurations in a Prismic repository.
1351
1105
 
1352
1106
  USAGE
1353
1107
  prismic preview <command> [flags]
1354
1108
 
1355
1109
  COMMANDS
1356
- add Add a preview configuration
1357
- list List preview configurations
1358
- remove Remove a preview configuration
1359
- set-name Update a preview's name
1360
- set-simulator Set the slice simulator URL
1361
- get-simulator Show the slice simulator URL
1362
- remove-simulator Remove the slice simulator URL
1110
+ add Add a preview configuration
1111
+ list List preview configurations
1112
+ remove Remove a preview configuration
1113
+ set-name Update a preview's name
1363
1114
 
1364
1115
  FLAGS
1365
1116
  -h, --help Show help for command
1366
1117
 
1367
1118
  LEARN MORE
1368
- Use \`prismic preview <command> --help\` for more information about a command.`)}}async function ka(){let{values:{help:t,repo:r=await q(),"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(`Pull custom types and slices from Prismic to local files.
1119
+ Use \`prismic preview <command> --help\` for more information about a command.`)}}const Un=E({id:k(),label:D(k()),repeatable:C(),status:C(),format:D(k()),json:O(k(),A())});async function Y(){let e=await P();return e.hostname=`customtypes.${e.hostname}`,e}async function Wn(e){let t=await N();if(!t)return{ok:!1,error:`Not authenticated`};let n=await Y(),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=j(S(Un),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 Gn(e){let t=await N();if(!t)return{ok:!1,error:`Not authenticated`};let n=await Y(),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=j(S(B),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 Kn(){let e=await L(`package.json`);if(!e)return{ok:!1,error:`Could not find project root (no package.json found)`};let t=new URL(`.`,e),n=new URL(`customtypes/`,t),a;try{a=await i(n,{withFileTypes:!1})}catch{return{ok:!0,value:[]}}let o=[];for(let e of a){let t=new URL(`${e}/index.json`,n);try{let e=await r(t,`utf8`),n=j(Un,JSON.parse(e));n.success&&o.push(n.output)}catch{}}return{ok:!0,value:o}}async function qn(){let e;try{e=await H()}catch{return{ok:!1,error:`Could not find project root (no package.json found)`}}let t;try{t=await i(e,{withFileTypes:!1})}catch{return{ok:!0,value:[]}}let n=[];for(let i of t){let t=new URL(`${i}/model.json`,e);try{let e=await r(t,`utf8`),i=j(B,JSON.parse(e));i.success&&n.push(i.output)}catch{}}return{ok:!0,value:n}}async function Jn(e,t){let n=await N();if(!n)return{ok:!1,error:`Not authenticated`};let r=await Y(),i=new URL(`customtypes/insert`,r);try{let r=await fetch(i,{method:`POST`,headers:{Authorization:`Bearer ${n}`,repository:e,"Content-Type":`application/json`},body:JSON.stringify(t)});return r.ok?{ok:!0,value:void 0}:r.status===401?{ok:!1,error:"Unauthorized. Your session may have expired. Run `prismic login` again."}:r.status===403?{ok:!1,error:`Access denied. You may not have access to repository "${e}".`}:{ok:!1,error:`API error: ${r.status} ${r.statusText}`}}catch(e){return{ok:!1,error:`Network error: ${e instanceof Error?e.message:e}`}}}async function Yn(e,t){let n=await N();if(!n)return{ok:!1,error:`Not authenticated`};let r=await Y(),i=new URL(`customtypes/update`,r);try{let r=await fetch(i,{method:`POST`,headers:{Authorization:`Bearer ${n}`,repository:e,"Content-Type":`application/json`},body:JSON.stringify(t)});return r.ok?{ok:!0,value:void 0}:r.status===401?{ok:!1,error:"Unauthorized. Your session may have expired. Run `prismic login` again."}:r.status===403?{ok:!1,error:`Access denied. You may not have access to repository "${e}".`}:{ok:!1,error:`API error: ${r.status} ${r.statusText}`}}catch(e){return{ok:!1,error:`Network error: ${e instanceof Error?e.message:e}`}}}async function Xn(e,t){let n=await N();if(!n)return{ok:!1,error:`Not authenticated`};let r=await Y(),i=new URL(`customtypes/${encodeURIComponent(t)}`,r);try{let t=await fetch(i,{method:`DELETE`,headers:{Authorization:`Bearer ${n}`,repository:e}});return t.ok?{ok:!0,value:void 0}:t.status===401?{ok:!1,error:"Unauthorized. Your session may have expired. Run `prismic login` again."}:t.status===403?{ok:!1,error:`Access denied. You may not have access to repository "${e}".`}:{ok:!1,error:`API error: ${t.status} ${t.statusText}`}}catch(e){return{ok:!1,error:`Network error: ${e instanceof Error?e.message:e}`}}}async function Zn(e,t){let n=await N();if(!n)return{ok:!1,error:`Not authenticated`};let r=await Y(),i=new URL(`slices/insert`,r);try{let r=await fetch(i,{method:`POST`,headers:{Authorization:`Bearer ${n}`,repository:e,"Content-Type":`application/json`},body:JSON.stringify(t)});return r.ok?{ok:!0,value:void 0}:r.status===401?{ok:!1,error:"Unauthorized. Your session may have expired. Run `prismic login` again."}:r.status===403?{ok:!1,error:`Access denied. You may not have access to repository "${e}".`}:{ok:!1,error:`API error: ${r.status} ${r.statusText}`}}catch(e){return{ok:!1,error:`Network error: ${e instanceof Error?e.message:e}`}}}async function Qn(e,t){let n=await N();if(!n)return{ok:!1,error:`Not authenticated`};let r=await Y(),i=new URL(`slices/update`,r);try{let r=await fetch(i,{method:`POST`,headers:{Authorization:`Bearer ${n}`,repository:e,"Content-Type":`application/json`},body:JSON.stringify(t)});return r.ok?{ok:!0,value:void 0}:r.status===401?{ok:!1,error:"Unauthorized. Your session may have expired. Run `prismic login` again."}:r.status===403?{ok:!1,error:`Access denied. You may not have access to repository "${e}".`}:{ok:!1,error:`API error: ${r.status} ${r.statusText}`}}catch(e){return{ok:!1,error:`Network error: ${e instanceof Error?e.message:e}`}}}async function $n(e,t){let n=await N();if(!n)return{ok:!1,error:`Not authenticated`};let r=await Y(),i=new URL(`slices/${encodeURIComponent(t)}`,r);try{let t=await fetch(i,{method:`DELETE`,headers:{Authorization:`Bearer ${n}`,repository:e}});return t.ok?{ok:!0,value:void 0}:t.status===401?{ok:!1,error:"Unauthorized. Your session may have expired. Run `prismic login` again."}:t.status===403?{ok:!1,error:`Access denied. You may not have access to repository "${e}".`}:{ok:!1,error:`API error: ${t.status} ${t.statusText}`}}catch(e){return{ok:!1,error:`Network error: ${e instanceof Error?e.message:e}`}}}async function er(){let{values:{help:t,repo:r=await W(),"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(`Pull custom types and slices from Prismic to local files.
1369
1120
 
1370
1121
  By default, this command reads the repository from prismic.config.json at the
1371
1122
  project root.
@@ -1385,9 +1136,9 @@ EXAMPLES
1385
1136
  prismic pull
1386
1137
  prismic pull --repo my-repo
1387
1138
  prismic pull --dry-run
1388
- prismic pull --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(`Pulling from repository: ${r}\n`);let l=!o,u=!a,[d,f]=await Promise.all([l?Hn(r):Promise.resolve({ok:!0,value:[]}),u?Un(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(K({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=Aa(await In());console.info(`Would write slices:`);for(let t of m)console.info(` ${e}${zn(t.name)}/model.json`)}console.info(`\nDry run complete: ${p.length} custom types, ${m.length} slices`)}return}let h=await G(`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(`
1389
- 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,K(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(`
1390
- Writing slices:`);let e=await In();for(let t of m){let r=new URL(`${zn(t.name)}/`,e),i=new URL(`model.json`,r);try{await n(r,{recursive:!0}),await s(i,K(t));let a=`${Aa(e)}${zn(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(K({writtenTypes:_,writtenSlices:v})):console.info(`\nPull complete: ${_.length} custom types, ${v.length} slices`)}function Aa(e){let t=process.cwd(),n=e.pathname;return n.startsWith(t)?n.slice(t.length+1):n}function ja(e,t){let n=new Map(e.map(e=>[e.id,e])),r=new Map(t.map(e=>[e.id,e])),i=[],a=[],o=[];for(let t of e){let e=r.get(t.id);e?JSON.stringify(t)!==JSON.stringify(e)&&a.push(t):i.push(t)}for(let e of t)n.has(e.id)||o.push(e.id);return{toInsert:i,toUpdate:a,toDelete:o}}async function Ma(){let{values:{help:t,repo:n=await q(),"dry-run":r,"types-only":i,"slices-only":a,delete:o,json:s}}=e({args:process.argv.slice(3),options:{repo:{type:`string`,short:`r`},"dry-run":{type:`boolean`},"types-only":{type:`boolean`},"slices-only":{type:`boolean`},delete:{type:`boolean`},json:{type:`boolean`},help:{type:`boolean`,short:`h`}},allowPositionals:!1});if(t){console.info(`Push custom types and slices to Prismic from local files.
1139
+ prismic pull --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(`Pulling from repository: ${r}\n`);let l=!o,u=!a,[d,f]=await Promise.all([l?Wn(r):Promise.resolve({ok:!0,value:[]}),u?Gn(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=tr(await H());console.info(`Would write slices:`);for(let t of m)console.info(` ${e}${U(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(`
1140
+ 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(`
1141
+ Writing slices:`);let e=await H();for(let t of m){let r=new URL(`${U(t.name)}/`,e),i=new URL(`model.json`,r);try{await n(r,{recursive:!0}),await s(i,z(t));let a=`${tr(e)}${U(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(`\nPull complete: ${_.length} custom types, ${v.length} slices`)}function tr(e){let t=process.cwd(),n=e.pathname;return n.startsWith(t)?n.slice(t.length+1):n}function nr(e,t){let n=new Map(e.map(e=>[e.id,e])),r=new Map(t.map(e=>[e.id,e])),i=[],a=[],o=[];for(let t of e){let e=r.get(t.id);e?JSON.stringify(t)!==JSON.stringify(e)&&a.push(t):i.push(t)}for(let e of t)n.has(e.id)||o.push(e.id);return{toInsert:i,toUpdate:a,toDelete:o}}async function rr(){let{values:{help:t,repo:n=await W(),"dry-run":r,"types-only":i,"slices-only":a,delete:o,json:s}}=e({args:process.argv.slice(3),options:{repo:{type:`string`,short:`r`},"dry-run":{type:`boolean`},"types-only":{type:`boolean`},"slices-only":{type:`boolean`},delete:{type:`boolean`},json:{type:`boolean`},help:{type:`boolean`,short:`h`}},allowPositionals:!1});if(t){console.info(`Push custom types and slices to Prismic from local files.
1391
1142
 
1392
1143
  By default, this command reads the repository from prismic.config.json at the
1393
1144
  project root.
@@ -1409,10 +1160,10 @@ EXAMPLES
1409
1160
  prismic push --repo my-repo
1410
1161
  prismic push --dry-run
1411
1162
  prismic push --types-only
1412
- prismic push --delete`);return}if(!n){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}s||console.info(`Pushing to repository: ${n}\n`);let c=!a,l=!i,[u,d,f,p]=await Promise.all([c?Wn():Promise.resolve({ok:!0,value:[]}),l?Gn():Promise.resolve({ok:!0,value:[]}),c?Hn(n):Promise.resolve({ok:!0,value:[]}),l?Un(n):Promise.resolve({ok:!0,value:[]})]);if(!u.ok){console.error(`Failed to read local custom types: ${u.error}`),process.exitCode=1;return}if(!d.ok){console.error(`Failed to read local slices: ${d.error}`),process.exitCode=1;return}if(!f.ok){console.error(`Failed to fetch remote custom types: ${f.error}`),process.exitCode=1;return}if(!p.ok){console.error(`Failed to fetch remote slices: ${p.error}`),process.exitCode=1;return}let m=u.value,h=d.value,g=f.value,_=p.value;s||(c&&(console.info(`Local custom types: ${m.length}`),console.info(`Remote custom types: ${g.length}`)),l&&(console.info(`Local slices: ${h.length}`),console.info(`Remote slices: ${_.length}`)));let v=c?ja([...m],[...g]):{toInsert:[],toUpdate:[],toDelete:[]},y=l?ja([...h],[..._]):{toInsert:[],toUpdate:[],toDelete:[]};o||(v.toDelete=[],y.toDelete=[]);let ee=v.toInsert.length+v.toUpdate.length+v.toDelete.length+y.toInsert.length+y.toUpdate.length+y.toDelete.length;if(ee===0){s?console.info(K({customTypes:{inserted:[],updated:[],deleted:[]},slices:{inserted:[],updated:[],deleted:[]}})):console.info(`
1413
- No changes to push.`);return}if(r){if(s)console.info(K({customTypes:{toInsert:v.toInsert.map(e=>e.id),toUpdate:v.toUpdate.map(e=>e.id),toDelete:v.toDelete},slices:{toInsert:y.toInsert.map(e=>e.id),toUpdate:y.toUpdate.map(e=>e.id),toDelete:y.toDelete}}));else{if(console.info(``),c){if(v.toInsert.length>0){console.info(`Would insert custom types:`);for(let e of v.toInsert)console.info(` + ${e.id}`)}if(v.toUpdate.length>0){console.info(`Would update custom types:`);for(let e of v.toUpdate)console.info(` ~ ${e.id}`)}if(v.toDelete.length>0){console.info(`Would delete custom types:`);for(let e of v.toDelete)console.info(` - ${e}`)}}if(l){if(y.toInsert.length>0){console.info(`Would insert slices:`);for(let e of y.toInsert)console.info(` + ${e.id}`)}if(y.toUpdate.length>0){console.info(`Would update slices:`);for(let e of y.toUpdate)console.info(` ~ ${e.id}`)}if(y.toDelete.length>0){console.info(`Would delete slices:`);for(let e of y.toDelete)console.info(` - ${e}`)}}console.info(`\nDry run complete: ${ee} changes would be made`)}return}let b={customTypes:{inserted:[],updated:[],deleted:[]},slices:{inserted:[],updated:[],deleted:[]}};if(c){!s&&(v.toInsert.length>0||v.toUpdate.length>0||v.toDelete.length>0)&&console.info(`
1414
- Pushing custom types:`);for(let e of v.toInsert){let t=await Kn(n,e);if(!t.ok){console.error(`Failed to insert custom type ${e.id}: ${t.error}`),process.exitCode=1;return}b.customTypes.inserted.push(e.id),s||console.info(` + ${e.id}`)}for(let e of v.toUpdate){let t=await qn(n,e);if(!t.ok){console.error(`Failed to update custom type ${e.id}: ${t.error}`),process.exitCode=1;return}b.customTypes.updated.push(e.id),s||console.info(` ~ ${e.id}`)}for(let e of v.toDelete){let t=await Jn(n,e);if(!t.ok){console.error(`Failed to delete custom type ${e}: ${t.error}`),process.exitCode=1;return}b.customTypes.deleted.push(e),s||console.info(` - ${e}`)}}if(l){!s&&(y.toInsert.length>0||y.toUpdate.length>0||y.toDelete.length>0)&&console.info(`
1415
- Pushing slices:`);for(let e of y.toInsert){let t=await Yn(n,e);if(!t.ok){console.error(`Failed to insert slice ${e.id}: ${t.error}`),process.exitCode=1;return}b.slices.inserted.push(e.id),s||console.info(` + ${e.id}`)}for(let e of y.toUpdate){let t=await Xn(n,e);if(!t.ok){console.error(`Failed to update slice ${e.id}: ${t.error}`),process.exitCode=1;return}b.slices.updated.push(e.id),s||console.info(` ~ ${e.id}`)}for(let e of y.toDelete){let t=await Zn(n,e);if(!t.ok){console.error(`Failed to delete slice ${e}: ${t.error}`),process.exitCode=1;return}b.slices.deleted.push(e),s||console.info(` - ${e}`)}}if(s)console.info(K(b));else{let e=b.customTypes.inserted.length+b.customTypes.updated.length+b.customTypes.deleted.length+b.slices.inserted.length+b.slices.updated.length+b.slices.deleted.length;console.info(`\nPush complete: ${e} changes`)}}const Na=/^[a-zA-Z0-9][-a-zA-Z0-9]{2,}[a-zA-Z0-9]$/;async function Pa(){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.
1163
+ prismic push --delete`);return}if(!n){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}s||console.info(`Pushing to repository: ${n}\n`);let c=!a,l=!i,[u,d,f,p]=await Promise.all([c?Kn():Promise.resolve({ok:!0,value:[]}),l?qn():Promise.resolve({ok:!0,value:[]}),c?Wn(n):Promise.resolve({ok:!0,value:[]}),l?Gn(n):Promise.resolve({ok:!0,value:[]})]);if(!u.ok){console.error(`Failed to read local custom types: ${u.error}`),process.exitCode=1;return}if(!d.ok){console.error(`Failed to read local slices: ${d.error}`),process.exitCode=1;return}if(!f.ok){console.error(`Failed to fetch remote custom types: ${f.error}`),process.exitCode=1;return}if(!p.ok){console.error(`Failed to fetch remote slices: ${p.error}`),process.exitCode=1;return}let m=u.value,h=d.value,g=f.value,_=p.value;s||(c&&(console.info(`Local custom types: ${m.length}`),console.info(`Remote custom types: ${g.length}`)),l&&(console.info(`Local slices: ${h.length}`),console.info(`Remote slices: ${_.length}`)));let v=c?nr([...m],[...g]):{toInsert:[],toUpdate:[],toDelete:[]},y=l?nr([...h],[..._]):{toInsert:[],toUpdate:[],toDelete:[]};o||(v.toDelete=[],y.toDelete=[]);let b=v.toInsert.length+v.toUpdate.length+v.toDelete.length+y.toInsert.length+y.toUpdate.length+y.toDelete.length;if(b===0){s?console.info(z({customTypes:{inserted:[],updated:[],deleted:[]},slices:{inserted:[],updated:[],deleted:[]}})):console.info(`
1164
+ No changes to push.`);return}if(r){if(s)console.info(z({customTypes:{toInsert:v.toInsert.map(e=>e.id),toUpdate:v.toUpdate.map(e=>e.id),toDelete:v.toDelete},slices:{toInsert:y.toInsert.map(e=>e.id),toUpdate:y.toUpdate.map(e=>e.id),toDelete:y.toDelete}}));else{if(console.info(``),c){if(v.toInsert.length>0){console.info(`Would insert custom types:`);for(let e of v.toInsert)console.info(` + ${e.id}`)}if(v.toUpdate.length>0){console.info(`Would update custom types:`);for(let e of v.toUpdate)console.info(` ~ ${e.id}`)}if(v.toDelete.length>0){console.info(`Would delete custom types:`);for(let e of v.toDelete)console.info(` - ${e}`)}}if(l){if(y.toInsert.length>0){console.info(`Would insert slices:`);for(let e of y.toInsert)console.info(` + ${e.id}`)}if(y.toUpdate.length>0){console.info(`Would update slices:`);for(let e of y.toUpdate)console.info(` ~ ${e.id}`)}if(y.toDelete.length>0){console.info(`Would delete slices:`);for(let e of y.toDelete)console.info(` - ${e}`)}}console.info(`\nDry run complete: ${b} changes would be made`)}return}let x={customTypes:{inserted:[],updated:[],deleted:[]},slices:{inserted:[],updated:[],deleted:[]}};if(c){!s&&(v.toInsert.length>0||v.toUpdate.length>0||v.toDelete.length>0)&&console.info(`
1165
+ Pushing custom types:`);for(let e of v.toInsert){let t=await Jn(n,e);if(!t.ok){console.error(`Failed to insert custom type ${e.id}: ${t.error}`),process.exitCode=1;return}x.customTypes.inserted.push(e.id),s||console.info(` + ${e.id}`)}for(let e of v.toUpdate){let t=await Yn(n,e);if(!t.ok){console.error(`Failed to update custom type ${e.id}: ${t.error}`),process.exitCode=1;return}x.customTypes.updated.push(e.id),s||console.info(` ~ ${e.id}`)}for(let e of v.toDelete){let t=await Xn(n,e);if(!t.ok){console.error(`Failed to delete custom type ${e}: ${t.error}`),process.exitCode=1;return}x.customTypes.deleted.push(e),s||console.info(` - ${e}`)}}if(l){!s&&(y.toInsert.length>0||y.toUpdate.length>0||y.toDelete.length>0)&&console.info(`
1166
+ Pushing slices:`);for(let e of y.toInsert){let t=await Zn(n,e);if(!t.ok){console.error(`Failed to insert slice ${e.id}: ${t.error}`),process.exitCode=1;return}x.slices.inserted.push(e.id),s||console.info(` + ${e.id}`)}for(let e of y.toUpdate){let t=await Qn(n,e);if(!t.ok){console.error(`Failed to update slice ${e.id}: ${t.error}`),process.exitCode=1;return}x.slices.updated.push(e.id),s||console.info(` ~ ${e.id}`)}for(let e of y.toDelete){let t=await $n(n,e);if(!t.ok){console.error(`Failed to delete slice ${e}: ${t.error}`),process.exitCode=1;return}x.slices.deleted.push(e),s||console.info(` - ${e}`)}}if(s)console.info(z(x));else{let e=x.customTypes.inserted.length+x.customTypes.updated.length+x.customTypes.deleted.length+x.slices.inserted.length+x.slices.updated.length+x.slices.deleted.length;console.info(`\nPush complete: ${e} changes`)}}const ir=/^[a-zA-Z0-9][-a-zA-Z0-9]{2,}[a-zA-Z0-9]$/;async function ar(){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.
1416
1167
 
1417
1168
  Creates prismic.config.json in the current directory. If a config file already
1418
1169
  exists, use --replace to update it with the new repository.
@@ -1431,20 +1182,7 @@ FLAGS
1431
1182
  -h, --help Show help for command
1432
1183
 
1433
1184
  LEARN MORE
1434
- 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(!Na.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()){Ia();return}let o=await On();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 Fa(a,n);if(!s.ok){s.error instanceof X?Ia():(console.error(`Failed to create repository: ${K(s.error)}`),process.exitCode=1);return}if(!r)if(o.ok){let e=await An({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 Dn({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 j(a)}`)}async function Fa(e,t=e){return await Y(new URL(`/app/dashboard/repositories`,await on()),{method:`POST`,body:{domain:e,name:t,framework:`next`,plan:`personal`,usageIntent:`Exploring Prismic's features for future projects.`,usageIntentIndex:0}})}function Ia(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}const La=z({repository:z({api_access:H()})});async function Ra(){let{values:{help:t,repo:n=await q()}}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Get the Content API access level of a Prismic repository.
1435
-
1436
- By default, this command reads the repository from prismic.config.json at the
1437
- project root.
1438
-
1439
- USAGE
1440
- prismic repo get-access [flags]
1441
-
1442
- FLAGS
1443
- -r, --repo string Repository domain
1444
- -h, --help Show help for command
1445
-
1446
- LEARN MORE
1447
- 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()){Ba();return}let r=await za(n);if(!r.ok){r.error instanceof X?Ba():(console.error(`Failed to get repository access: ${K(r.value)}`),process.exitCode=1);return}console.info(r.value.repository.api_access)}async function za(e){let t=await j(e);return await Y(new URL(`syncState`,t),{schema:La})}function Ba(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}const Va=z({repositories:L(z({domain:H(),name:B(H()),role:H()}))});async function Ha(){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.
1185
+ 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(!ir.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()){sr();return}let o=await G();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 or(a,n);if(!s.ok){s.error instanceof q?sr():(console.error(`Failed to create repository: ${z(s.error)}`),process.exitCode=1);return}if(!r)if(o.ok){let e=await lt({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 st({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 or(e,t=e){return await K(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 sr(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}const cr=E({repositories:S(E({domain:k(),name:D(k()),role:k()}))});async function lr(){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.
1448
1186
 
1449
1187
  USAGE
1450
1188
  prismic repo list [flags]
@@ -1454,23 +1192,7 @@ FLAGS
1454
1192
  -h, --help Show help for command
1455
1193
 
1456
1194
  LEARN MORE
1457
- Use \`prismic repo <command> --help\` for more information about a command.`);return}if(!await M()){Wa();return}let r=await Ua();if(!r.ok){r.error instanceof X?Wa():(console.error(`Failed to fetch repositories: ${K(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 j(e.domain)).toString()})));console.info(K(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 Ua(){return await Y(new URL(`profile`,await en()),{schema:Va})}function Wa(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}const Ga=[`private`,`public`,`open`];async function Ka(){let{values:{help:t,repo:n=await q()},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 Content API access level of a Prismic repository.
1458
-
1459
- By default, this command reads the repository from prismic.config.json at the
1460
- project root.
1461
-
1462
- USAGE
1463
- prismic repo set-access <level> [flags]
1464
-
1465
- ARGUMENTS
1466
- <level> The access level to set (private, public, open)
1467
-
1468
- FLAGS
1469
- -r, --repo string Repository domain
1470
- -h, --help Show help for command
1471
-
1472
- LEARN MORE
1473
- Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <level>`),process.exitCode=1;return}if(!Ga.includes(r)){console.error(`Invalid access level: ${r}. Must be one of: ${Ga.join(`, `)}`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await M()){Ja();return}let i=await qa(n,r);if(!i.ok){i.error instanceof X?Ja():(console.error(`Failed to set repository access: ${K(i.value)}`),process.exitCode=1);return}console.info(`Repository access set to: ${r}`)}async function qa(e,t){let n=await j(e);return await Y(new URL(`settings/security/apiaccess`,n),{method:`POST`,body:{api_access:t}})}function Ja(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function Ya(){let{values:{help:t,repo:n=await q()},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.
1195
+ Use \`prismic repo <command> --help\` for more information about a command.`);return}if(!await M()){dr();return}let r=await ur();if(!r.ok){r.error instanceof q?dr():(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 ur(){return await K(new URL(`profile`,await fe()),{schema:cr})}function dr(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function fr(){let{values:{help:t,repo:n=await W()},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.
1474
1196
 
1475
1197
  By default, this command reads the repository from prismic.config.json at the
1476
1198
  project root.
@@ -1486,7 +1208,7 @@ FLAGS
1486
1208
  -h, --help Show help for command
1487
1209
 
1488
1210
  LEARN MORE
1489
- 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()){Za();return}let i=await Xa(n,r);if(!i.ok){i.error instanceof X?Za():I(i.error)?(console.error(`Failed to set repository name: Invalid response: ${K(i.error.issues)}`),process.exitCode=1):(console.error(`Failed to set repository name: ${K(i.value)}`),process.exitCode=1);return}console.info(`Repository name set to: ${i.value.repository.name}`)}async function Xa(e,t){let n=await j(e),r=new URL(`app/settings/repository`,n),i=new FormData;return i.set(`displayname`,t),await Y(r,{method:`POST`,body:i,schema:z({repository:z({name:H()})})})}function Za(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}const Qa=z({repositories:L(z({domain:H(),name:B(H())}))});async function $a(){let{values:{help:t,repo:n=await q(),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.
1211
+ 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()){mr();return}let i=await pr(n,r);if(!i.ok){i.error instanceof q?mr():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 pr(e,t){let n=await F(e),r=new URL(`app/settings/repository`,n),i=new FormData;return i.set(`displayname`,t),await K(r,{method:`POST`,body:i,schema:E({repository:E({name:k()})})})}function mr(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}const hr=E({repositories:S(E({domain:k(),name:D(k())}))});async function gr(){let{values:{help:t,repo:n=await W(),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.
1490
1212
 
1491
1213
  By default, this command reads the repository from prismic.config.json at the
1492
1214
  project root.
@@ -1500,7 +1222,7 @@ FLAGS
1500
1222
  -h, --help Show help for command
1501
1223
 
1502
1224
  LEARN MORE
1503
- 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 j(n);if(r){to(i.toString()),console.info(`Opening ${i}`);return}if(!await M()){no();return}let a=await eo();if(!a.ok){a.error instanceof X?no():(console.error(`Failed to fetch repository info: ${K(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 eo(){return await Y(new URL(`profile`,await en()),{schema:Qa})}function to(e){d(`${process.platform===`darwin`?`open`:process.platform===`win32`?`start`:`xdg-open`} "${e}"`)}function no(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function ro(){let{positionals:[t]}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`create`:await Pa();break;case`list`:await Ha();break;case`view`:await $a();break;case`get-access`:await Ra();break;case`set-access`:await Ka();break;case`set-name`:await Ya();break;default:t&&(console.error(`Unknown repo subcommand: ${t}\n`),process.exitCode=1),console.info(`Manage Prismic repositories.
1225
+ 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){vr(i.toString()),console.info(`Opening ${i}`);return}if(!await M()){yr();return}let a=await _r();if(!a.ok){a.error instanceof q?yr():(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 _r(){return await K(new URL(`profile`,await fe()),{schema:hr})}function vr(e){u(`${process.platform===`darwin`?`open`:process.platform===`win32`?`start`:`xdg-open`} "${e}"`)}function yr(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function br(){let{positionals:[t]}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`create`:await ar();break;case`list`:await lr();break;case`view`:await gr();break;case`set-name`:await fr();break;default:t&&(console.error(`Unknown repo subcommand: ${t}\n`),process.exitCode=1),console.info(`Manage Prismic repositories.
1504
1226
 
1505
1227
  USAGE
1506
1228
  prismic repo <command> [flags]
@@ -1509,15 +1231,13 @@ COMMANDS
1509
1231
  create Create a new Prismic repository
1510
1232
  list List all repositories
1511
1233
  view View repository details
1512
- get-access Get Content API access level
1513
- set-access Set Content API access level
1514
1234
  set-name Set repository display name
1515
1235
 
1516
1236
  FLAGS
1517
1237
  -h, --help Show help for command
1518
1238
 
1519
1239
  LEARN MORE
1520
- Use \`prismic repo <command> --help\` for more information about a command.`)}}async function io(){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.
1240
+ Use \`prismic repo <command> --help\` for more information about a command.`)}}async function xr(){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.
1521
1241
 
1522
1242
  USAGE
1523
1243
  prismic slice add-field boolean <slice-id> <field-id> [flags]
@@ -1528,7 +1248,7 @@ ARGUMENTS
1528
1248
 
1529
1249
  FLAGS
1530
1250
  -v, --variation string Target variation (default: first variation)
1531
- -l, --label string Display label for the field (inferred from field-id if omitted)
1251
+ -l, --label string Display label for the field
1532
1252
  --default Set default value to true
1533
1253
  --true-label string Label shown when toggle is on
1534
1254
  --false-label string Label shown when toggle is off
@@ -1539,7 +1259,7 @@ EXAMPLES
1539
1259
  prismic slice add-field boolean hero show_overlay --default
1540
1260
  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
1541
1261
  `),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
1542
- `),console.error(`Usage: prismic slice add-field boolean <slice-id> <field-id>`),process.exitCode=1;return}let u=await J(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:{label:r??Q(l),...i&&{default_value:!0},...a&&{placeholder_true:a},...o&&{placeholder_false:o}}};p.primary[l]=m;try{await s(f,K(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 ao(){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.
1262
+ `),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,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 Sr(){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.
1543
1263
 
1544
1264
  USAGE
1545
1265
  prismic slice add-field color <slice-id> <field-id> [flags]
@@ -1550,7 +1270,7 @@ ARGUMENTS
1550
1270
 
1551
1271
  FLAGS
1552
1272
  -v, --variation string Target variation (default: first variation)
1553
- -l, --label string Display label for the field (inferred from field-id if omitted)
1273
+ -l, --label string Display label for the field
1554
1274
  -p, --placeholder string Placeholder text
1555
1275
  -h, --help Show help for command
1556
1276
 
@@ -1559,7 +1279,7 @@ EXAMPLES
1559
1279
  prismic slice add-field color hero accent --label "Accent Color"
1560
1280
  prismic slice add-field color banner theme_color --variation "dark"`);return}if(!a){console.error(`Missing required argument: slice-id
1561
1281
  `),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
1562
- `),console.error(`Usage: prismic slice add-field color <slice-id> <field-id>`),process.exitCode=1;return}let c=await J(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:{label:r??Q(o),...i&&{placeholder:i}}};d.primary[o]=f;try{await s(u,K(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 oo(){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.
1282
+ `),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,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 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 date picker field to an existing slice.
1563
1283
 
1564
1284
  USAGE
1565
1285
  prismic slice add-field date <slice-id> <field-id> [flags]
@@ -1570,7 +1290,7 @@ ARGUMENTS
1570
1290
 
1571
1291
  FLAGS
1572
1292
  -v, --variation string Target variation (default: first variation)
1573
- -l, --label string Display label for the field (inferred from field-id if omitted)
1293
+ -l, --label string Display label for the field
1574
1294
  -p, --placeholder string Placeholder text
1575
1295
  -h, --help Show help for command
1576
1296
 
@@ -1579,7 +1299,7 @@ EXAMPLES
1579
1299
  prismic slice add-field date event start_date --label "Start Date"
1580
1300
  prismic slice add-field date promo end_date --variation "countdown"`);return}if(!a){console.error(`Missing required argument: slice-id
1581
1301
  `),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
1582
- `),console.error(`Usage: prismic slice add-field date <slice-id> <field-id>`),process.exitCode=1;return}let c=await J(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:{label:r??Q(o),...i&&{placeholder:i}}};d.primary[o]=f;try{await s(u,K(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 so(){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.
1302
+ `),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,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 wr(){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.
1583
1303
 
1584
1304
  USAGE
1585
1305
  prismic slice add-field embed <slice-id> <field-id> [flags]
@@ -1590,7 +1310,7 @@ ARGUMENTS
1590
1310
 
1591
1311
  FLAGS
1592
1312
  -v, --variation string Target variation (default: first variation)
1593
- -l, --label string Display label for the field (inferred from field-id if omitted)
1313
+ -l, --label string Display label for the field
1594
1314
  -p, --placeholder string Placeholder text
1595
1315
  -h, --help Show help for command
1596
1316
 
@@ -1599,7 +1319,7 @@ EXAMPLES
1599
1319
  prismic slice add-field embed gallery media --label "Media Embed"
1600
1320
  prismic slice add-field embed social tweet --variation "twitter"`);return}if(!a){console.error(`Missing required argument: slice-id
1601
1321
  `),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
1602
- `),console.error(`Usage: prismic slice add-field embed <slice-id> <field-id>`),process.exitCode=1;return}let c=await J(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:{label:r??Q(o),...i&&{placeholder:i}}};d.primary[o]=f;try{await s(u,K(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 co(){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.
1322
+ `),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,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 Tr(){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.
1603
1323
 
1604
1324
  USAGE
1605
1325
  prismic slice add-field geo-point <slice-id> <field-id> [flags]
@@ -1610,7 +1330,7 @@ ARGUMENTS
1610
1330
 
1611
1331
  FLAGS
1612
1332
  -v, --variation string Target variation (default: first variation)
1613
- -l, --label string Display label for the field (inferred from field-id if omitted)
1333
+ -l, --label string Display label for the field
1614
1334
  -h, --help Show help for command
1615
1335
 
1616
1336
  EXAMPLES
@@ -1618,7 +1338,7 @@ EXAMPLES
1618
1338
  prismic slice add-field geo-point store coordinates --label "Store Location"
1619
1339
  prismic slice add-field geo-point map marker --variation "interactive"`);return}if(!i){console.error(`Missing required argument: slice-id
1620
1340
  `),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
1621
- `),console.error(`Usage: prismic slice add-field geo-point <slice-id> <field-id>`),process.exitCode=1;return}let o=await J(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:{label:r??Q(a)}};u.primary[a]=d;try{await s(l,K(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 lo(){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.
1341
+ `),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,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 Er(){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.
1622
1342
 
1623
1343
  USAGE
1624
1344
  prismic slice add-field image <slice-id> <field-id> [flags]
@@ -1629,7 +1349,7 @@ ARGUMENTS
1629
1349
 
1630
1350
  FLAGS
1631
1351
  -v, --variation string Target variation (default: first variation)
1632
- -l, --label string Display label for the field (inferred from field-id if omitted)
1352
+ -l, --label string Display label for the field
1633
1353
  -h, --help Show help for command
1634
1354
 
1635
1355
  EXAMPLES
@@ -1637,7 +1357,7 @@ EXAMPLES
1637
1357
  prismic slice add-field image hero banner --label "Hero Banner"
1638
1358
  prismic slice add-field image gallery thumbnail --variation "grid"`);return}if(!i){console.error(`Missing required argument: slice-id
1639
1359
  `),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
1640
- `),console.error(`Usage: prismic slice add-field image <slice-id> <field-id>`),process.exitCode=1;return}let o=await J(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:{label:r??Q(a)}};u.primary[a]=d;try{await s(l,K(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 uo(){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.
1360
+ `),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,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 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 a key-text (single-line text) field to an existing slice.
1641
1361
 
1642
1362
  USAGE
1643
1363
  prismic slice add-field key-text <slice-id> <field-id> [flags]
@@ -1648,7 +1368,7 @@ ARGUMENTS
1648
1368
 
1649
1369
  FLAGS
1650
1370
  -v, --variation string Target variation (default: first variation)
1651
- -l, --label string Display label for the field (inferred from field-id if omitted)
1371
+ -l, --label string Display label for the field
1652
1372
  -p, --placeholder string Placeholder text
1653
1373
  -h, --help Show help for command
1654
1374
 
@@ -1657,7 +1377,7 @@ EXAMPLES
1657
1377
  prismic slice add-field key-text hero heading --label "Heading"
1658
1378
  prismic slice add-field key-text cta button_text --placeholder "Enter button text"`);return}if(!a){console.error(`Missing required argument: slice-id
1659
1379
  `),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
1660
- `),console.error(`Usage: prismic slice add-field key-text <slice-id> <field-id>`),process.exitCode=1;return}let c=await J(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:{label:r??Q(o),...i&&{placeholder:i}}};d.primary[o]=f;try{await s(u,K(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 fo(){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.
1380
+ `),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,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 Or(){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.
1661
1381
 
1662
1382
  USAGE
1663
1383
  prismic slice add-field link <slice-id> <field-id> [flags]
@@ -1668,7 +1388,7 @@ ARGUMENTS
1668
1388
 
1669
1389
  FLAGS
1670
1390
  -v, --variation string Target variation (default: first variation)
1671
- -l, --label string Display label for the field (inferred from field-id if omitted)
1391
+ -l, --label string Display label for the field
1672
1392
  -p, --placeholder string Placeholder text
1673
1393
  --allow-text Allow text with link
1674
1394
  --allow-target-blank Allow opening link in new tab
@@ -1681,7 +1401,7 @@ EXAMPLES
1681
1401
  prismic slice add-field link navigation links --repeatable
1682
1402
  prismic slice add-field link hero cta --allow-text --allow-target-blank`);return}if(!l){console.error(`Missing required argument: slice-id
1683
1403
  `),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
1684
- `),console.error(`Usage: prismic slice add-field link <slice-id> <field-id>`),process.exitCode=1;return}let d=await J(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:{label:r??Q(u),...i&&{placeholder:i},...a&&{allowText:!0},...o&&{allowTargetBlank:!0},...c&&{repeat:!0}}};m.primary[u]=h;try{await s(p,K(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 po(){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.
1404
+ `),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,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 kr(){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.
1685
1405
 
1686
1406
  USAGE
1687
1407
  prismic slice add-field number <slice-id> <field-id> [flags]
@@ -1692,7 +1412,7 @@ ARGUMENTS
1692
1412
 
1693
1413
  FLAGS
1694
1414
  -v, --variation string Target variation (default: first variation)
1695
- -l, --label string Display label for the field (inferred from field-id if omitted)
1415
+ -l, --label string Display label for the field
1696
1416
  -p, --placeholder string Placeholder text
1697
1417
  -h, --help Show help for command
1698
1418
 
@@ -1701,7 +1421,7 @@ EXAMPLES
1701
1421
  prismic slice add-field number product quantity --label "Quantity"
1702
1422
  prismic slice add-field number stats count --variation "detailed"`);return}if(!a){console.error(`Missing required argument: slice-id
1703
1423
  `),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
1704
- `),console.error(`Usage: prismic slice add-field number <slice-id> <field-id>`),process.exitCode=1;return}let c=await J(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:{label:r??Q(o),...i&&{placeholder:i}}};d.primary[o]=f;try{await s(u,K(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 mo(){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.
1424
+ `),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,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 Ar(){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.
1705
1425
 
1706
1426
  USAGE
1707
1427
  prismic slice add-field rich-text <slice-id> <field-id> [flags]
@@ -1712,7 +1432,7 @@ ARGUMENTS
1712
1432
 
1713
1433
  FLAGS
1714
1434
  -v, --variation string Target variation (default: first variation)
1715
- -l, --label string Display label for the field (inferred from field-id if omitted)
1435
+ -l, --label string Display label for the field
1716
1436
  -p, --placeholder string Placeholder text
1717
1437
  --single string Allowed block types for single-line (comma-separated)
1718
1438
  --multi string Allowed block types for multi-line (comma-separated)
@@ -1730,7 +1450,7 @@ EXAMPLES
1730
1450
  prismic slice add-field rich-text hero tagline --single "heading1"
1731
1451
  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
1732
1452
  `),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
1733
- `),console.error(`Usage: prismic slice add-field rich-text <slice-id> <field-id>`),process.exitCode=1;return}let d=await J(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:{label:r??Q(u),...i&&{placeholder:i},...a&&{single:a},...o&&{multi:o},...c&&{allowTargetBlank:!0}}};m.primary[u]=h;try{await s(p,K(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 ho(){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.
1453
+ `),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,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 jr(){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.
1734
1454
 
1735
1455
  USAGE
1736
1456
  prismic slice add-field select <slice-id> <field-id> [flags]
@@ -1741,7 +1461,7 @@ ARGUMENTS
1741
1461
 
1742
1462
  FLAGS
1743
1463
  -v, --variation string Target variation (default: first variation)
1744
- -l, --label string Display label for the field (inferred from field-id if omitted)
1464
+ -l, --label string Display label for the field
1745
1465
  -p, --placeholder string Placeholder text
1746
1466
  --option string Add an option (can be used multiple times)
1747
1467
  --default string Default selected value
@@ -1752,7 +1472,7 @@ EXAMPLES
1752
1472
  prismic slice add-field select hero style --option "light" --option "dark" --default "light"
1753
1473
  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
1754
1474
  `),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
1755
- `),console.error(`Usage: prismic slice add-field select <slice-id> <field-id>`),process.exitCode=1;return}let u=await J(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:{label:r??Q(l),...i&&{placeholder:i},...a&&a.length>0&&{options:a},...o&&{default_value:o}}};p.primary[l]=m;try{await s(f,K(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 go(){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.
1475
+ `),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,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 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 timestamp (date and time) field to an existing slice.
1756
1476
 
1757
1477
  USAGE
1758
1478
  prismic slice add-field timestamp <slice-id> <field-id> [flags]
@@ -1763,7 +1483,7 @@ ARGUMENTS
1763
1483
 
1764
1484
  FLAGS
1765
1485
  -v, --variation string Target variation (default: first variation)
1766
- -l, --label string Display label for the field (inferred from field-id if omitted)
1486
+ -l, --label string Display label for the field
1767
1487
  -p, --placeholder string Placeholder text
1768
1488
  -h, --help Show help for command
1769
1489
 
@@ -1772,7 +1492,7 @@ EXAMPLES
1772
1492
  prismic slice add-field timestamp event start_time --label "Event Start"
1773
1493
  prismic slice add-field timestamp schedule meeting_time --variation "detailed"`);return}if(!a){console.error(`Missing required argument: slice-id
1774
1494
  `),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
1775
- `),console.error(`Usage: prismic slice add-field timestamp <slice-id> <field-id>`),process.exitCode=1;return}let c=await J(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:{label:r??Q(o),...i&&{placeholder:i}}};d.primary[o]=f;try{await s(u,K(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 _o(){let{positionals:[t]}=e({args:process.argv.slice(4),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`boolean`:await io();break;case`color`:await ao();break;case`date`:await oo();break;case`embed`:await so();break;case`geo-point`:await co();break;case`image`:await lo();break;case`key-text`:await uo();break;case`link`:await fo();break;case`number`:await po();break;case`rich-text`:await mo();break;case`select`:await ho();break;case`timestamp`:await go();break;default:t&&(console.error(`Unknown field type: ${t}\n`),process.exitCode=1),console.info(`Add a field to an existing slice.
1495
+ `),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,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 Nr(){let{positionals:[t]}=e({args:process.argv.slice(4),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`boolean`:await xr();break;case`color`:await Sr();break;case`date`:await Cr();break;case`embed`:await wr();break;case`geo-point`:await Tr();break;case`image`:await Er();break;case`key-text`:await Dr();break;case`link`:await Or();break;case`number`:await kr();break;case`rich-text`:await Ar();break;case`select`:await jr();break;case`timestamp`:await Mr();break;default:t&&(console.error(`Unknown field type: ${t}\n`),process.exitCode=1),console.info(`Add a field to an existing slice.
1776
1496
 
1777
1497
  USAGE
1778
1498
  prismic slice add-field <field-type> <slice-id> <field-id> [flags]
@@ -1801,7 +1521,7 @@ EXAMPLES
1801
1521
  prismic slice add-field key-text my_slice title --label "Title"
1802
1522
  prismic slice add-field link my_slice cta --allow-text
1803
1523
  prismic slice add-field rich-text my_slice body --multi "paragraph,heading2,strong,em"
1804
- prismic slice add-field select my_slice layout --option "full" --option "sidebar"`)}}async function vo(){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.
1524
+ prismic slice add-field select my_slice layout --option "full" --option "sidebar"`)}}async function Pr(){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.
1805
1525
 
1806
1526
  USAGE
1807
1527
  prismic slice add-variation <slice-id> <variation-id> [flags]
@@ -1820,7 +1540,7 @@ EXAMPLES
1820
1540
  prismic slice add-variation MySlice withImage --name "With Image"
1821
1541
  prismic slice add-variation MySlice withImage --copy-from default`);return}if(!i){console.error(`Missing required argument: slice-id
1822
1542
  `),console.error(`Usage: prismic slice add-variation <slice-id> <variation-id>`),process.exitCode=1;return}if(!a){console.error(`Missing required argument: variation-id
1823
- `),console.error(`Usage: prismic slice add-variation <slice-id> <variation-id>`),process.exitCode=1;return}let o=await J(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??zn(a)}}else u={id:a,name:n??zn(a),description:a,imageUrl:``,docURL:``,version:`initial`,primary:{},items:{}};let d={...c,variations:[...c.variations,u]};try{await s(l,K(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 yo(){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.
1543
+ `),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??U(a)}}else u={id:a,name:n??U(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 Fr(){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.
1824
1544
 
1825
1545
  USAGE
1826
1546
  prismic slice create <id> [flags]
@@ -1833,7 +1553,7 @@ FLAGS
1833
1553
  -h, --help Show help for command
1834
1554
 
1835
1555
  LEARN MORE
1836
- 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??Co(i),description:``,variations:[{id:`default`,name:`Default`,description:`Default`,imageUrl:``,docURL:``,version:`initial`,primary:{},items:{}}]},o=await bo(),c=new URL(Co(a.name)+`/`,o),l=new URL(`model.json`,c);try{await n(new URL(`.`,l),{recursive:!0}),await s(l,K(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 bo(){let e=await So(),t=await G(`package.json`);switch(e){case`next`:if(await wn(new URL(`src`,t)))return new URL(`src/slices/`,t);case`nuxt`:if(await wn(new URL(`app`,t)))return new URL(`app/slices/`,t);case`sveltekit`:return new URL(`src/slices/`,t)}return new URL(`slices/`,t)}const xo=z({dependencies:B(V(H(),H()))});async function So(){let e=await G(`package.json`);if(e)try{let t=await r(e,`utf8`),{dependencies:n={}}=Sn(xo,JSON.parse(t));if(`next`in n)return`next`;if(`nuxt`in n)return`nuxt`;if(`@sveltejs/kit`in n)return`sveltekit`}catch{}}function Co(e){return e.toLowerCase().replace(/(^|[-_\s]+)(.)?/g,(e,t,n)=>n?.toUpperCase()??``)}async function wo(){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.
1556
+ 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??zr(i),description:``,variations:[{id:`default`,name:`Default`,description:`Default`,imageUrl:``,docURL:``,version:`initial`,primary:{},items:{}}]},o=await Ir(),c=new URL(zr(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 Ir(){let e=await Rr(),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 Lr=E({dependencies:D(O(k(),k()))});async function Rr(){let e=await L(`package.json`);if(e)try{let t=await r(e,`utf8`),{dependencies:n={}}=ie(Lr,JSON.parse(t));if(`next`in n)return`next`;if(`nuxt`in n)return`nuxt`;if(`@sveltejs/kit`in n)return`sveltekit`}catch{}}function zr(e){return e.toLowerCase().replace(/(^|[-_\s]+)(.)?/g,(e,t,n)=>n?.toUpperCase()??``)}async function Br(){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.
1837
1557
 
1838
1558
  USAGE
1839
1559
  prismic slice list [flags]
@@ -1844,7 +1564,7 @@ FLAGS
1844
1564
 
1845
1565
  EXAMPLES
1846
1566
  prismic slice list
1847
- prismic slice list --json`);return}let a=await In(),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=W(Fn,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 To(){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.
1567
+ prismic slice list --json`);return}let a=await H(),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=j(B,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 Vr(){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.
1848
1568
 
1849
1569
  USAGE
1850
1570
  prismic slice list-variations <slice-id> [flags]
@@ -1859,7 +1579,7 @@ FLAGS
1859
1579
  EXAMPLES
1860
1580
  prismic slice list-variations MySlice
1861
1581
  prismic slice list-variations MySlice --json`);return}if(!r){console.error(`Missing required argument: slice-id
1862
- `),console.error(`Usage: prismic slice list-variations <slice-id>`),process.exitCode=1;return}let i=await J(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 Eo(){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.
1582
+ `),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 Hr(){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.
1863
1583
 
1864
1584
  USAGE
1865
1585
  prismic slice remove <slice-id> [flags]
@@ -1874,7 +1594,7 @@ FLAGS
1874
1594
  EXAMPLES
1875
1595
  prismic slice remove MySlice
1876
1596
  prismic slice remove MySlice -y`);return}if(!r){console.error(`Missing required argument: slice-id
1877
- `),console.error(`Usage: prismic slice remove <slice-id>`),process.exitCode=1;return}let i=await J(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 Do(){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.
1597
+ `),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 Ur(){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.
1878
1598
 
1879
1599
  USAGE
1880
1600
  prismic slice remove-field <slice-id> <field-id> [flags]
@@ -1893,7 +1613,7 @@ EXAMPLES
1893
1613
  prismic slice remove-field MySlice title --variation withImage
1894
1614
  prismic slice remove-field MySlice item_title --zone items`);return}if(!i){console.error(`Missing required argument: slice-id
1895
1615
  `),console.error(`Usage: prismic slice remove-field <slice-id> <field-id>`),process.exitCode=1;return}if(!a){console.error(`Missing required argument: field-id
1896
- `),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 J(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,K(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 Oo(){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.
1616
+ `),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,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 Wr(){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.
1897
1617
 
1898
1618
  USAGE
1899
1619
  prismic slice remove-variation <slice-id> <variation-id> [flags]
@@ -1908,7 +1628,7 @@ FLAGS
1908
1628
  EXAMPLES
1909
1629
  prismic slice remove-variation MySlice withImage`);return}if(!n){console.error(`Missing required argument: slice-id
1910
1630
  `),console.error(`Usage: prismic slice remove-variation <slice-id> <variation-id>`),process.exitCode=1;return}if(!r){console.error(`Missing required argument: variation-id
1911
- `),console.error(`Usage: prismic slice remove-variation <slice-id> <variation-id>`),process.exitCode=1;return}let i=await J(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,K(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 ko(){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).
1631
+ `),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,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 Gr(){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).
1912
1632
 
1913
1633
  USAGE
1914
1634
  prismic slice rename <slice-id> <new-name> [flags]
@@ -1925,7 +1645,7 @@ EXAMPLES
1925
1645
  prismic slice rename MySlice "My New Name"
1926
1646
  prismic slice rename MySlice "My New Name" --id NewSliceId`);return}if(!r){console.error(`Missing required argument: slice-id
1927
1647
  `),console.error(`Usage: prismic slice rename <slice-id> <new-name>`),process.exitCode=1;return}if(!i){console.error(`Missing required argument: new-name
1928
- `),console.error(`Usage: prismic slice rename <slice-id> <new-name>`),process.exitCode=1;return}let o=await J(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,K(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 In(),t=new URL(`.`,l),o=new URL(zn(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 Ao(){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.
1648
+ `),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,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 H(),t=new URL(`.`,l),o=new URL(U(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 Kr(){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.
1929
1649
 
1930
1650
  USAGE
1931
1651
  prismic slice view <slice-id> [flags]
@@ -1940,8 +1660,8 @@ FLAGS
1940
1660
  EXAMPLES
1941
1661
  prismic slice view MySlice
1942
1662
  prismic slice view MySlice --json`);return}if(!r){console.error(`Missing required argument: slice-id
1943
- `),console.error(`Usage: prismic slice view <slice-id>`),process.exitCode=1;return}let i=await J(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(`
1944
- 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 jo(){let{positionals:[t]}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`create`:await yo();break;case`list`:await wo();break;case`view`:await Ao();break;case`rename`:await ko();break;case`remove`:await Eo();break;case`add-field`:await _o();break;case`remove-field`:await Do();break;case`add-variation`:await vo();break;case`remove-variation`:await Oo();break;case`list-variations`:await To();break;default:t&&(console.error(`Unknown slice subcommand: ${t}\n`),process.exitCode=1),console.info(`Manage slices in a Prismic project.
1663
+ `),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(`
1664
+ 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 qr(){let{positionals:[t]}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`create`:await Fr();break;case`list`:await Br();break;case`view`:await Kr();break;case`rename`:await Gr();break;case`remove`:await Hr();break;case`add-field`:await Nr();break;case`remove-field`:await Ur();break;case`add-variation`:await Pr();break;case`remove-variation`:await Wr();break;case`list-variations`:await Vr();break;default:t&&(console.error(`Unknown slice subcommand: ${t}\n`),process.exitCode=1),console.info(`Manage slices in a Prismic project.
1945
1665
 
1946
1666
  USAGE
1947
1667
  prismic slice <command> [flags]
@@ -1962,7 +1682,7 @@ FLAGS
1962
1682
  -h, --help Show help for command
1963
1683
 
1964
1684
  LEARN MORE
1965
- Use \`prismic slice <command> --help\` for more information about a command.`)}}async function Mo(){let{values:{help:t,repo:n=await q(),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.
1685
+ Use \`prismic slice <command> --help\` for more information about a command.`)}}async function Jr(){let{values:{help:t,repo:n=await W(),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.
1966
1686
 
1967
1687
  By default, this command reads the repository from prismic.config.json at the
1968
1688
  project root.
@@ -1976,7 +1696,7 @@ FLAGS
1976
1696
  -h, --help Show help for command
1977
1697
 
1978
1698
  LEARN MORE
1979
- 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()){Uo();return}let[i,a]=await Promise.all([zo(n),Bo(n)]);if(!i.ok){i.error instanceof X||i.error instanceof Z?Uo():I(i.error)?(console.error(`Failed to list access tokens: Invalid response: ${K(i.error.issues)}`),process.exitCode=1):(console.error(`Failed to list access tokens: ${K(i.value)}`),process.exitCode=1);return}if(!a.ok){a.error instanceof X||a.error instanceof Z?Uo():I(a.error)?(console.error(`Failed to list write tokens: Invalid response: ${K(a.error.issues)}`),process.exitCode=1):(console.error(`Failed to list write tokens: ${K(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(K({accessTokens:o,writeTokens:s}));else{if(o.length>0){console.info(`ACCESS TOKENS`);for(let e of o){let t=Vo(e.token),n=Ho(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=Vo(e.token),n=Ho(e.timestamp);console.info(` ${e.app_name} ${t} ${n}`)}}else console.info(`WRITE TOKENS (none)`)}}const No=z({$date:xn()}),Po=z({id:H(),origin:H(),domain:H(),app:H(),scope:H(),expired_at:No,created_at:No,owner:bn(H()),token:H()}),Fo=z({id:H(),secret:H(),name:H(),owner:H(),created_at:No,authorized_domains:L(H()),wroom_auths:L(Po)}),Io=z({app_name:H(),token:H(),timestamp:xn()}),Lo=z({max_tokens:xn(),tokens:L(Io)}),Ro=L(Fo);async function zo(e){return await Y(new URL(`settings/security/contentapi`,await j(e)),{schema:Ro})}async function Bo(e){return await Y(new URL(`settings/security/customtypesapi`,await j(e)),{schema:Lo})}function Vo(e){return e.length<=12?e:`${e.slice(0,8)}...${e.slice(-4)}`}function Ho(e){let t=typeof e==`number`?e*1e3:e.$date;return new Date(t).toISOString().split(`T`)[0]}function Uo(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function Wo(){let{values:{help:t,repo:n=await q(),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.
1699
+ 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()){ai();return}let[i,a]=await Promise.all([ti(n),ni(n)]);if(!i.ok){i.error instanceof q||i.error instanceof J?ai():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 q||a.error instanceof J?ai():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=ri(e.token),n=ii(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=ri(e.token),n=ii(e.timestamp);console.info(` ${e.app_name} ${t} ${n}`)}}else console.info(`WRITE TOKENS (none)`)}}const Yr=E({$date:T()}),Xr=E({id:k(),origin:k(),domain:k(),app:k(),scope:k(),expired_at:Yr,created_at:Yr,owner:w(k()),token:k()}),Zr=E({id:k(),secret:k(),name:k(),owner:k(),created_at:Yr,authorized_domains:S(k()),wroom_auths:S(Xr)}),Qr=E({app_name:k(),token:k(),timestamp:T()}),$r=E({max_tokens:T(),tokens:S(Qr)}),ei=S(Zr);async function ti(e){return await K(new URL(`settings/security/contentapi`,await F(e)),{schema:ei})}async function ni(e){return await K(new URL(`settings/security/customtypesapi`,await F(e)),{schema:$r})}function ri(e){return e.length<=12?e:`${e.slice(0,8)}...${e.slice(-4)}`}function ii(e){let t=typeof e==`number`?e*1e3:e.$date;return new Date(t).toISOString().split(`T`)[0]}function ai(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function oi(){let{values:{help:t,repo:n=await W(),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.
1980
1700
 
1981
1701
  By default, this command reads the repository from prismic.config.json at the
1982
1702
  project root.
@@ -1993,7 +1713,7 @@ FLAGS
1993
1713
  -h, --help Show help for command
1994
1714
 
1995
1715
  LEARN MORE
1996
- 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()){qo();return}if(i){let e=await Go(n,a);if(!e.ok){e.error instanceof X||e.error instanceof Z?qo():I(e.error)?(console.error(`Failed to create write token: Invalid response: ${K(e.error.issues)}`),process.exitCode=1):(console.error(`Failed to create write token: ${K(e.value)}`),process.exitCode=1);return}r?console.info(K(e.value)):console.info(`Token created: ${e.value.token}`)}else{let e=await Ko(n,a,o?`master+releases`:`master`);if(!e.ok){e.error instanceof X||e.error instanceof Z?qo():I(e.error)?(console.error(`Failed to create access token: Invalid response: ${K(e.error.issues)}`),process.exitCode=1):(console.error(`Failed to create access token: ${K(e.value)}`),process.exitCode=1);return}r?console.info(K(e.value)):console.info(`Token created: ${e.value.token}`)}}async function Go(e,t){return await Y(new URL(`settings/security/token`,await j(e)),{method:`POST`,body:{app_name:t},schema:Io})}async function Ko(e,t,n){let r=await zo(e);if(!r.ok)return r;let i=r.value.find(e=>e.name===t);if(!i){let n=await Y(new URL(`settings/security/oauthapp`,await j(e)),{method:`POST`,body:{app_name:t},schema:Fo});if(!n.ok)return n;i=n.value}return await Y(new URL(`settings/security/authorizations`,await j(e)),{method:`POST`,body:{app:i.id,scope:n},schema:Po})}function qo(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function Jo(){let{values:{help:t,repo:n=await q()},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.
1716
+ 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()){li();return}if(i){let e=await si(n,a);if(!e.ok){e.error instanceof q||e.error instanceof J?li():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 ci(n,a,o?`master+releases`:`master`);if(!e.ok){e.error instanceof q||e.error instanceof J?li():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 si(e,t){return await K(new URL(`settings/security/token`,await F(e)),{method:`POST`,body:{app_name:t},schema:Qr})}async function ci(e,t,n){let r=await ti(e);if(!r.ok)return r;let i=r.value.find(e=>e.name===t);if(!i){let n=await K(new URL(`settings/security/oauthapp`,await F(e)),{method:`POST`,body:{app_name:t},schema:Zr});if(!n.ok)return n;i=n.value}return await K(new URL(`settings/security/authorizations`,await F(e)),{method:`POST`,body:{app:i.id,scope:n},schema:Xr})}function li(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function ui(){let{values:{help:t,repo:n=await W()},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.
1997
1717
 
1998
1718
  By default, this command reads the repository from prismic.config.json at the
1999
1719
  project root.
@@ -2009,7 +1729,7 @@ FLAGS
2009
1729
  -h, --help Show help for command
2010
1730
 
2011
1731
  LEARN MORE
2012
- 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()){Yo();return}let[i,a]=await Promise.all([zo(n),Bo(n)]);if(!i.ok){i.error instanceof X||i.error instanceof Z?Yo():I(i.error)?(console.error(`Failed to list access tokens: Invalid response: ${K(i.error.issues)}`),process.exitCode=1):(console.error(`Failed to list access tokens: ${K(i.value)}`),process.exitCode=1);return}if(!a.ok){a.error instanceof X||a.error instanceof Z?Yo():I(a.error)?(console.error(`Failed to list write tokens: Invalid response: ${K(a.error.issues)}`),process.exitCode=1):(console.error(`Failed to list write tokens: ${K(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 Y(new URL(`settings/security/authorizations/${o.id}`,await j(n)),{method:`DELETE`});if(!e.ok){e.error instanceof X||e.error instanceof Z?Yo():(console.error(`Failed to delete token: ${K(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 Y(new URL(`settings/security/token/${s.token}`,await j(n)),{method:`DELETE`});if(!e.ok){e.error instanceof X||e.error instanceof Z?Yo():(console.error(`Failed to delete token: ${K(e.value)}`),process.exitCode=1);return}console.info(`Token deleted`);return}console.error(`Token not found: ${r}`),process.exitCode=1}function Yo(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function Xo(){let{values:{help:t,repo:n=await q()},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.
1732
+ 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()){X();return}let[i,a]=await Promise.all([ti(n),ni(n)]);if(!i.ok){i.error instanceof q||i.error instanceof J?X():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 q||a.error instanceof J?X():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 K(new URL(`settings/security/authorizations/${o.id}`,await F(n)),{method:`DELETE`});if(!e.ok){e.error instanceof q||e.error instanceof J?X():(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 K(new URL(`settings/security/token/${s.token}`,await F(n)),{method:`DELETE`});if(!e.ok){e.error instanceof q||e.error instanceof J?X():(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 X(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function di(){let{values:{help:t,repo:n=await W()},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.
2013
1733
 
2014
1734
  Note: Only access tokens can be renamed. Write tokens cannot be renamed without
2015
1735
  changing the token value.
@@ -2029,7 +1749,7 @@ FLAGS
2029
1749
  -h, --help Show help for command
2030
1750
 
2031
1751
  LEARN MORE
2032
- 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()){Zo();return}let[a,o]=await Promise.all([zo(n),Bo(n)]);if(!a.ok){a.error instanceof X||a.error instanceof Z?Zo():I(a.error)?(console.error(`Failed to list access tokens: Invalid response: ${K(a.error.issues)}`),process.exitCode=1):(console.error(`Failed to list access tokens: ${K(a.value)}`),process.exitCode=1);return}if(!o.ok){o.error instanceof X||o.error instanceof Z?Zo():I(o.error)?(console.error(`Failed to list write tokens: Invalid response: ${K(o.error.issues)}`),process.exitCode=1):(console.error(`Failed to list write tokens: ${K(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 Y(new URL(`settings/security/oauthapp/${s.id}`,await j(n)),{method:`POST`,body:{name:i},schema:Fo});if(!e.ok){e.error instanceof X||e.error instanceof Z?Zo():I(e.error)?(console.error(`Failed to rename token: Invalid response: ${K(e.error.issues)}`),process.exitCode=1):(console.error(`Failed to rename token: ${K(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 Zo(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function Qo(){let{positionals:[t]}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`list`:await Mo();break;case`create`:await Wo();break;case`set-name`:await Xo();break;case`delete`:await Jo();break;default:t&&(console.error(`Unknown token subcommand: ${t}\n`),process.exitCode=1),console.info(`Manage API tokens for a Prismic repository.
1752
+ 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()){fi();return}let[a,o]=await Promise.all([ti(n),ni(n)]);if(!a.ok){a.error instanceof q||a.error instanceof J?fi():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 q||o.error instanceof J?fi():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 K(new URL(`settings/security/oauthapp/${s.id}`,await F(n)),{method:`POST`,body:{name:i},schema:Zr});if(!e.ok){e.error instanceof q||e.error instanceof J?fi():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 fi(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function pi(){let{positionals:[t]}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`list`:await Jr();break;case`create`:await oi();break;case`set-name`:await di();break;case`delete`:await ui();break;default:t&&(console.error(`Unknown token subcommand: ${t}\n`),process.exitCode=1),console.info(`Manage API tokens for a Prismic repository.
2033
1753
 
2034
1754
  USAGE
2035
1755
  prismic token <command> [flags]
@@ -2044,7 +1764,7 @@ FLAGS
2044
1764
  -h, --help Show help for command
2045
1765
 
2046
1766
  LEARN MORE
2047
- Use \`prismic token <command> --help\` for more information about a command.`)}}const $o={documentsPublished:`document.published`,documentsUnpublished:`document.unpublished`,releasesCreated:`release.created`,releasesUpdated:`release.updated`,tagsCreated:`tag.created`,tagsDeleted:`tag.deleted`};async function es(){let{values:{help:t,repo:n=await q()},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.
1767
+ 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 mi(){let{values:{help:t,repo:n=await W()},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.
2048
1768
 
2049
1769
  By default, this command reads the repository from prismic.config.json at the
2050
1770
  project root.
@@ -2060,7 +1780,7 @@ FLAGS
2060
1780
  -h, --help Show help for command
2061
1781
 
2062
1782
  LEARN MORE
2063
- 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()){ts();return}let i=await $(n);if(!i.ok){i.error instanceof X?ts():(console.error(`Failed to view webhook: ${K(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($o))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 ts(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}const ns=z({config:z({_id:H(),url:H(),active:R(),name:bn(H()),secret:bn(H()),headers:V(H(),H()),documentsPublished:R(),documentsUnpublished:R(),releasesCreated:R(),releasesUpdated:R(),tagsCreated:R(),tagsDeleted:R()})});async function $(e){return await Y(new URL(`/app/settings/webhooks`,await j(e)),{schema:L(ns)})}async function rs(){let{values:{help:t,repo:n=await q()},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.
1783
+ 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()){hi();return}let i=await Q(n);if(!i.ok){i.error instanceof q?hi():(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 hi(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}const gi=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 Q(e){return await K(new URL(`/app/settings/webhooks`,await F(e)),{schema:S(gi)})}async function _i(){let{values:{help:t,repo:n=await W()},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.
2064
1784
 
2065
1785
  By default, this command reads the repository from prismic.config.json at the
2066
1786
  project root.
@@ -2076,7 +1796,7 @@ FLAGS
2076
1796
  -h, --help Show help for command
2077
1797
 
2078
1798
  LEARN MORE
2079
- 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()){as();return}let i=await $(n);if(!i.ok){i.error instanceof X?as():(console.error(`Failed to enable webhook: ${K(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 is(n,a.config._id,o);if(!s.ok){s.error instanceof X?as():(console.error(`Failed to enable webhook: ${K(s.value)}`),process.exitCode=1);return}console.info(`Webhook enabled: ${r}`)}async function is(e,t,n){let r=new URL(`/app/settings/webhooks/${t}`,await j(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 Y(r,{method:`POST`,body:i})}function as(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function os(){let{values:{help:t,repo:n=await q()},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.
1799
+ 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()){vi();return}let i=await Q(n);if(!i.ok){i.error instanceof q?vi():(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 q?vi():(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 K(r,{method:`POST`,body:i})}function vi(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function yi(){let{values:{help:t,repo:n=await W()},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.
2080
1800
 
2081
1801
  By default, this command reads the repository from prismic.config.json at the
2082
1802
  project root.
@@ -2094,7 +1814,7 @@ FLAGS
2094
1814
  -h, --help Show help for command
2095
1815
 
2096
1816
  LEARN MORE
2097
- 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()){ss();return}let o=await $(n);if(!o.ok){o.error instanceof X?ss():(console.error(`Failed to add header: ${K(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 is(n,s.config._id,c);if(!l.ok){l.error instanceof X?ss():(console.error(`Failed to add header: ${K(l.value)}`),process.exitCode=1);return}console.info(`Header added: ${i}`)}function ss(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}const cs=Object.values($o);async function ls(){let{values:{help:t,repo:n=await q(),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.
1817
+ 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()){bi();return}let o=await Q(n);if(!o.ok){o.error instanceof q?bi():(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 q?bi():(console.error(`Failed to add header: ${z(l.value)}`),process.exitCode=1);return}console.info(`Header added: ${i}`)}function bi(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}const xi=Object.values(Z);async function Si(){let{values:{help:t,repo:n=await W(),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.
2098
1818
 
2099
1819
  By default, this command reads the repository from prismic.config.json at the
2100
1820
  project root.
@@ -2123,7 +1843,7 @@ TRIGGERS
2123
1843
  If no triggers specified, all are enabled.
2124
1844
 
2125
1845
  LEARN MORE
2126
- 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(!cs.includes(e)){console.error(`Invalid trigger: ${e}`),console.error(`Valid triggers: ${cs.join(`, `)}`),process.exitCode=1;return}if(!await M()){ds();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($o).find(([,t])=>e===t)??[];t&&(c[t]=!0)}let l=await us(n,{url:o,name:r??null,secret:i??null,...c});if(!l.ok){l.error instanceof X?ds():(console.error(`Failed to create webhook: ${K(l.value)}`),process.exitCode=1);return}console.info(`Webhook created: ${o}`)}async function us(e,t){let n=new URL(`/app/settings/webhooks/create`,await j(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 Y(n,{method:`POST`,body:r})}function ds(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function fs(){let{values:{help:t,repo:n=await q()},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.
1846
+ 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(!xi.includes(e)){console.error(`Invalid trigger: ${e}`),console.error(`Valid triggers: ${xi.join(`, `)}`),process.exitCode=1;return}if(!await M()){wi();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 Ci(n,{url:o,name:r??null,secret:i??null,...c});if(!l.ok){l.error instanceof q?wi():(console.error(`Failed to create webhook: ${z(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 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 K(n,{method:`POST`,body:r})}function wi(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function Ti(){let{values:{help:t,repo:n=await W()},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.
2127
1847
 
2128
1848
  By default, this command reads the repository from prismic.config.json at the
2129
1849
  project root.
@@ -2139,7 +1859,7 @@ FLAGS
2139
1859
  -h, --help Show help for command
2140
1860
 
2141
1861
  LEARN MORE
2142
- 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()){ps();return}let i=await $(n);if(!i.ok){i.error instanceof X?ps():(console.error(`Failed to disable webhook: ${K(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 is(n,a.config._id,o);if(!s.ok){s.error instanceof X?ps():(console.error(`Failed to disable webhook: ${K(s.value)}`),process.exitCode=1);return}console.info(`Webhook disabled: ${r}`)}function ps(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function ms(){let{values:{help:t,repo:n=await q(),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.
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(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await M()){Ei();return}let i=await Q(n);if(!i.ok){i.error instanceof q?Ei():(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 q?Ei():(console.error(`Failed to disable webhook: ${z(s.value)}`),process.exitCode=1);return}console.info(`Webhook disabled: ${r}`)}function Ei(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function Di(){let{values:{help:t,repo:n=await W(),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.
2143
1863
 
2144
1864
  By default, this command reads the repository from prismic.config.json at the
2145
1865
  project root.
@@ -2153,7 +1873,7 @@ FLAGS
2153
1873
  -h, --help Show help for command
2154
1874
 
2155
1875
  LEARN MORE
2156
- 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()){hs();return}let i=await $(n);if(!i.ok){i.error instanceof X?hs():I(i.error)?(console.error(`Failed to list webhooks: Invalid response: ${K(i.error.issues)}`),process.exitCode=1):(console.error(`Failed to list webhooks: ${K(i.value)}`),process.exitCode=1);return}let a=i.value;if(r)console.info(K(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 hs(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function gs(){let{values:{help:t,repo:n=await q()},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.
1876
+ 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()){Oi();return}let i=await Q(n);if(!i.ok){i.error instanceof q?Oi():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 Oi(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function ki(){let{values:{help:t,repo:n=await W()},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.
2157
1877
 
2158
1878
  By default, this command reads the repository from prismic.config.json at the
2159
1879
  project root.
@@ -2169,7 +1889,7 @@ FLAGS
2169
1889
  -h, --help Show help for command
2170
1890
 
2171
1891
  LEARN MORE
2172
- 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()){vs();return}let i=await $(n);if(!i.ok){i.error instanceof X?vs():(console.error(`Failed to remove webhook: ${K(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 _s(n,a.config._id);if(!o.ok){o.error instanceof X?vs():(console.error(`Failed to remove webhook: ${K(o.value)}`),process.exitCode=1);return}console.info(`Webhook removed: ${r}`)}async function _s(e,t){return await Y(new URL(`/app/settings/webhooks/${t}/delete`,await j(e)),{method:`POST`})}function vs(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function ys(){let{values:{help:t,repo:n=await q()},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.
1892
+ 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 q?ji():(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 Ai(n,a.config._id);if(!o.ok){o.error instanceof q?ji():(console.error(`Failed to remove webhook: ${z(o.value)}`),process.exitCode=1);return}console.info(`Webhook removed: ${r}`)}async function Ai(e,t){return await K(new URL(`/app/settings/webhooks/${t}/delete`,await F(e)),{method:`POST`})}function ji(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function Mi(){let{values:{help:t,repo:n=await W()},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.
2173
1893
 
2174
1894
  By default, this command reads the repository from prismic.config.json at the
2175
1895
  project root.
@@ -2186,7 +1906,7 @@ FLAGS
2186
1906
  -h, --help Show help for command
2187
1907
 
2188
1908
  LEARN MORE
2189
- 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()){bs();return}let a=await $(n);if(!a.ok){a.error instanceof X?bs():(console.error(`Failed to remove header: ${K(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 is(n,o.config._id,s);if(!c.ok){c.error instanceof X?bs():(console.error(`Failed to remove header: ${K(c.value)}`),process.exitCode=1);return}console.info(`Header removed: ${i}`)}function bs(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}const xs=Object.values($o);async function Ss(){let{values:{help:t,repo:n=await q(),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.
1909
+ 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()){Ni();return}let a=await Q(n);if(!a.ok){a.error instanceof q?Ni():(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 q?Ni():(console.error(`Failed to remove header: ${z(c.value)}`),process.exitCode=1);return}console.info(`Header removed: ${i}`)}function Ni(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}const Pi=Object.values(Z);async function Fi(){let{values:{help:t,repo:n=await W(),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.
2190
1910
 
2191
1911
  By default, this command reads the repository from prismic.config.json at the
2192
1912
  project root.
@@ -2211,7 +1931,7 @@ TRIGGERS
2211
1931
  tag.deleted When a tag is deleted
2212
1932
 
2213
1933
  LEARN MORE
2214
- 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(!xs.includes(e)){console.error(`Invalid trigger: ${e}`),console.error(`Valid triggers: ${xs.join(`, `)}`),process.exitCode=1;return}if(!await M()){Cs();return}let a=await $(n);if(!a.ok){a.error instanceof X?Cs():(console.error(`Failed to update webhook triggers: ${K(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($o).find(([,t])=>e===t)??[];t&&(c[t]=!0)}let l=await is(n,o.config._id,{...o.config,...c});if(!l.ok){l.error instanceof X?Cs():(console.error(`Failed to update webhook triggers: ${K(l.value)}`),process.exitCode=1);return}console.info(`Webhook triggers updated: ${r.join(`, `)}`)}function Cs(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function ws(){let{values:{help:t,repo:n=await q()},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.
1934
+ 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(!Pi.includes(e)){console.error(`Invalid trigger: ${e}`),console.error(`Valid triggers: ${Pi.join(`, `)}`),process.exitCode=1;return}if(!await M()){Ii();return}let a=await Q(n);if(!a.ok){a.error instanceof q?Ii():(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 q?Ii():(console.error(`Failed to update webhook triggers: ${z(l.value)}`),process.exitCode=1);return}console.info(`Webhook triggers updated: ${r.join(`, `)}`)}function Ii(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function Li(){let{values:{help:t,repo:n=await W()},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.
2215
1935
 
2216
1936
  By default, this command reads the repository from prismic.config.json at the
2217
1937
  project root.
@@ -2227,7 +1947,7 @@ FLAGS
2227
1947
  -h, --help Show help for command
2228
1948
 
2229
1949
  LEARN MORE
2230
- 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()){Ts();return}let i=await $(n);if(!i.ok){i.error instanceof X?Ts():(console.error(`Failed to get webhook status: ${K(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 Ts(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function Es(){let{values:{help:t,repo:n=await q()},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.
1950
+ 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()){Ri();return}let i=await Q(n);if(!i.ok){i.error instanceof q?Ri():(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 Ri(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function zi(){let{values:{help:t,repo:n=await W()},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.
2231
1951
 
2232
1952
  By default, this command reads the repository from prismic.config.json at the
2233
1953
  project root.
@@ -2243,7 +1963,7 @@ FLAGS
2243
1963
  -h, --help Show help for command
2244
1964
 
2245
1965
  LEARN MORE
2246
- 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()){Os();return}let i=await $(n);if(!i.ok){i.error instanceof X?Os():(console.error(`Failed to test webhook: ${K(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 Ds(n,a.config._id);if(!o.ok){o.error instanceof X?Os():(console.error(`Failed to test webhook: ${K(o.value)}`),process.exitCode=1);return}console.info(`Test webhook triggered: ${r}`)}async function Ds(e,t){return await Y(new URL(`/app/settings/webhooks/${t}/trigger`,await j(e)),{method:`POST`})}function Os(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function ks(){let{positionals:[t]}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`list`:await ms();break;case`create`:await ls();break;case`view`:await es();break;case`remove`:await gs();break;case`test`:await Es();break;case`enable`:await rs();break;case`disable`:await fs();break;case`status`:await ws();break;case`add-header`:await os();break;case`remove-header`:await ys();break;case`set-triggers`:await Ss();break;default:t&&(console.error(`Unknown webhook subcommand: ${t}\n`),process.exitCode=1),console.info(`Manage webhooks in a Prismic repository.
1966
+ 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()){Vi();return}let i=await Q(n);if(!i.ok){i.error instanceof q?Vi():(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 Bi(n,a.config._id);if(!o.ok){o.error instanceof q?Vi():(console.error(`Failed to test webhook: ${z(o.value)}`),process.exitCode=1);return}console.info(`Test webhook triggered: ${r}`)}async function Bi(e,t){return await K(new URL(`/app/settings/webhooks/${t}/trigger`,await F(e)),{method:`POST`})}function Vi(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function Hi(){let{positionals:[t]}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`list`:await Di();break;case`create`:await Si();break;case`view`:await mi();break;case`remove`:await ki();break;case`test`:await zi();break;case`enable`:await _i();break;case`disable`:await Ti();break;case`status`:await Li();break;case`add-header`:await yi();break;case`remove-header`:await Mi();break;case`set-triggers`:await Fi();break;default:t&&(console.error(`Unknown webhook subcommand: ${t}\n`),process.exitCode=1),console.info(`Manage webhooks in a Prismic repository.
2247
1967
 
2248
1968
  USAGE
2249
1969
  prismic webhook <command> [flags]
@@ -2265,7 +1985,7 @@ FLAGS
2265
1985
  -h, --help Show help for command
2266
1986
 
2267
1987
  LEARN MORE
2268
- Use \`prismic webhook <command> --help\` for more information about a command.`)}}async function As(){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.
1988
+ Use \`prismic webhook <command> --help\` for more information about a command.`)}}async function Ui(){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.
2269
1989
 
2270
1990
  USAGE
2271
1991
  prismic whoami [flags]
@@ -2274,7 +1994,7 @@ FLAGS
2274
1994
  -h, --help Show help for command
2275
1995
 
2276
1996
  LEARN MORE
2277
- Use \`prismic <command> --help\` for more information about a command.`);return}if(!await M()){Ms();return}let n=await js();if(!n.ok){n.error instanceof X?Ms():console.error(`Failed to fetch user profile.`),process.exitCode=1;return}console.info(n.value.email)}async function js(){return await Y(new URL(`profile`,await en()),{schema:z({email:H()})})}function Ms(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}const{positionals:Ns}=e({options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(Ns[0]){case`init`:await Yr();break;case`login`:await si();break;case`logout`:await ui();break;case`whoami`:await As();break;case`repo`:await ro();break;case`locale`:await oi();break;case`page-type`:await na();break;case`custom-type`:await Jr();break;case`slice`:await jo();break;case`pull`:await ka();break;case`push`:await Ma();break;case`codegen`:await ir();break;case`preview`:await Oa();break;case`token`:await Qo();break;case`webhook`:await ks();break;default:Ns[0]&&(console.error(`Unknown command: ${Ns[0]}`),process.exitCode=1),console.info(`Prismic CLI for managing repositories and configurations.
1997
+ Use \`prismic <command> --help\` for more information about a command.`);return}if(!await M()){Gi();return}let n=await Wi();if(!n.ok){n.error instanceof q?Gi():console.error(`Failed to fetch user profile.`),process.exitCode=1;return}console.info(n.value.email)}async function Wi(){return await K(new URL(`profile`,await fe()),{schema:E({email:k()})})}function Gi(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}const{positionals:Ki}=e({options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(Ki[0]){case`init`:await mt();break;case`login`:await jt();break;case`logout`:await Pt();break;case`whoami`:await Ui();break;case`repo`:await br();break;case`locale`:await At();break;case`page-type`:await Dn();break;case`custom-type`:await it();break;case`slice`:await qr();break;case`pull`:await er();break;case`push`:await rr();break;case`preview`:await Hn();break;case`token`:await pi();break;case`webhook`:await Hi();break;default:Ki[0]&&(console.error(`Unknown command: ${Ki[0]}`),process.exitCode=1),console.info(`Prismic CLI for managing repositories and configurations.
2278
1998
 
2279
1999
  USAGE
2280
2000
  prismic <command> [flags]
@@ -2291,7 +2011,6 @@ COMMANDS
2291
2011
  slice Manage slices in a project
2292
2012
  pull Pull types and slices from Prismic
2293
2013
  push Push types and slices to Prismic
2294
- codegen Generate code from Prismic models
2295
2014
  preview Manage preview configurations
2296
2015
  token Manage API tokens in a repository
2297
2016
  webhook Manage webhooks in a repository