@angeloashmore/prismic-cli-poc 0.0.0-canary.6fd8413 → 0.0.0-canary.aa21905
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.mjs +460 -282
- package/package.json +1 -1
- package/src/codegen-types.ts +16 -39
- package/src/custom-type-add-field-boolean.ts +64 -14
- package/src/custom-type-add-field-color.ts +61 -15
- package/src/custom-type-add-field-date.ts +61 -15
- package/src/custom-type-add-field-embed.ts +61 -15
- package/src/custom-type-add-field-geo-point.ts +61 -15
- package/src/custom-type-add-field-group.ts +179 -0
- package/src/custom-type-add-field-image.ts +61 -15
- package/src/custom-type-add-field-key-text.ts +61 -15
- package/src/custom-type-add-field-link.ts +61 -14
- package/src/custom-type-add-field-number.ts +61 -15
- package/src/custom-type-add-field-rich-text.ts +61 -14
- package/src/custom-type-add-field-select.ts +61 -15
- package/src/custom-type-add-field-timestamp.ts +61 -15
- package/src/custom-type-add-field-uid.ts +33 -4
- package/src/custom-type-add-field.ts +5 -0
- package/src/custom-type-connect-slice.ts +18 -25
- package/src/custom-type-create.ts +22 -2
- package/src/custom-type-disconnect-slice.ts +18 -26
- package/src/custom-type-remove-field.ts +11 -1
- package/src/custom-type-remove.ts +14 -2
- package/src/custom-type-set-name.ts +11 -1
- package/src/docs.ts +149 -0
- package/src/index.ts +76 -54
- package/src/init.ts +3 -1
- package/src/lib/auth.ts +24 -1
- package/src/lib/custom-types-api.ts +74 -20
- package/src/lib/field-path.ts +81 -0
- package/src/lib/framework.ts +143 -0
- package/src/lib/slice.ts +5 -2
- package/src/login.ts +18 -9
- package/src/page-type-add-field-boolean.ts +80 -14
- package/src/page-type-add-field-color.ts +80 -15
- package/src/page-type-add-field-date.ts +80 -15
- package/src/page-type-add-field-embed.ts +80 -15
- package/src/page-type-add-field-geo-point.ts +80 -15
- package/src/page-type-add-field-group.ts +198 -0
- package/src/page-type-add-field-image.ts +80 -15
- package/src/page-type-add-field-key-text.ts +80 -15
- package/src/page-type-add-field-link.ts +80 -14
- package/src/page-type-add-field-number.ts +80 -15
- package/src/page-type-add-field-rich-text.ts +80 -14
- package/src/page-type-add-field-select.ts +80 -15
- package/src/page-type-add-field-timestamp.ts +80 -15
- package/src/page-type-add-field-uid.ts +52 -4
- package/src/page-type-add-field.ts +5 -0
- package/src/page-type-connect-slice.ts +18 -25
- package/src/page-type-create.ts +71 -3
- package/src/page-type-disconnect-slice.ts +18 -26
- package/src/page-type-remove-field.ts +11 -1
- package/src/page-type-remove.ts +14 -2
- package/src/page-type-set-name.ts +11 -1
- package/src/page-type-set-repeatable.ts +11 -1
- package/src/preview-get-simulator.ts +1 -3
- package/src/pull.ts +36 -6
- package/src/push.ts +35 -11
- package/src/repo-create.ts +59 -0
- package/src/repo-get-access.ts +1 -4
- package/src/repo-set-access.ts +2 -6
- package/src/slice-add-field-boolean.ts +104 -15
- package/src/slice-add-field-color.ts +104 -16
- package/src/slice-add-field-date.ts +104 -16
- package/src/slice-add-field-embed.ts +104 -16
- package/src/slice-add-field-geo-point.ts +104 -16
- package/src/slice-add-field-group.ts +191 -0
- package/src/slice-add-field-image.ts +104 -16
- package/src/slice-add-field-key-text.ts +104 -16
- package/src/slice-add-field-link.ts +104 -15
- package/src/slice-add-field-number.ts +104 -16
- package/src/slice-add-field-rich-text.ts +104 -15
- package/src/slice-add-field-select.ts +104 -16
- package/src/slice-add-field-timestamp.ts +104 -16
- package/src/slice-add-field.ts +5 -0
- package/src/slice-add-variation.ts +15 -13
- package/src/slice-create.ts +78 -4
- package/src/slice-remove-field.ts +14 -9
- package/src/slice-remove-variation.ts +14 -10
- package/src/slice-remove.ts +11 -1
- package/src/slice-rename.ts +11 -1
- package/src/slice-set-screenshot.ts +235 -0
- package/src/slice-view.ts +3 -0
- package/src/slice.ts +5 -0
- package/src/status.ts +873 -0
- package/src/token-create.ts +23 -5
- package/src/token-delete.ts +29 -8
- package/src/token-list.ts +14 -3
- package/src/token-set-name.ts +38 -10
package/dist/index.mjs
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
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{
|
|
3
|
-
`),s.default,i.default,r.default,a.default),t.exports=e.default})),
|
|
4
|
-
`),i.default,r.default,a.default,(0,s.default)(/&/g,`&`),(0,s.default)(/</g,`<`),(0,s.default)(/>/g,`>`),(0,s.default)(/"/g,`"`),(0,s.default)(/'/g,`'`),(0,s.default)(/`/g,```)),t.exports=e.default})),
|
|
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{createHash as l}from"node:crypto";import{homedir as u}from"node:os";import{pathToFileURL as d}from"node:url";import{exec as f}from"node:child_process";import{createServer as p}from"node:http";import{extname as m}from"node:path";var h=Object.defineProperty,g=Object.getOwnPropertyDescriptor,_=Object.getOwnPropertyNames,v=Object.prototype.hasOwnProperty,y=(e,t)=>()=>(e&&(t=e(e=0)),t),b=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),x=(e,t)=>{let n={};for(var r in e)h(n,r,{get:e[r],enumerable:!0});return t&&h(n,Symbol.toStringTag,{value:`Module`}),n},S=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=_(t),a=0,o=i.length,s;a<o;a++)s=i[a],!v.call(e,s)&&s!==n&&h(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=g(t,s))||r.enumerable});return e},ee=e=>v.call(e,`module.exports`)?e[`module.exports`]:S(h({},`__esModule`,{value:!0}),e),te=`0.0.0-canary.aa21905`,ne=b(((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})),C=b(((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})),w=b(((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})),T=b(((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})),re=b(((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})),ie=b(((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})),ae=b(((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})),oe=b(((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})),se=b(((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})),ce=b(((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=b(((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})),ue=b(((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})),de=b(((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})),fe=b(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(de());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),pe=b(((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})),me=b(((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})),he=b(((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})),ge=b(((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=b(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});var n=o(C()),r=o(ie()),i=o(fe()),a=o(T());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})),ve=b(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(_e());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),ye=b(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});var n=o(C()),r=o(ie()),i=o(fe()),a=o(T());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})),be=b(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(ye());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),xe=b(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});var n=o(C()),r=o(ie()),i=o(fe()),a=o(T());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})),Se=b(((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=b(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});var n=c(C()),r=c(ie()),i=c(fe()),a=c(T()),o=c(me()),s=c(ge());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})),we=b(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(Ce());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),Te=b(((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=b(((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})),De=b(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});var n=c(C()),r=c(ie()),i=c(fe()),a=c(T()),o=c(me()),s=c(ce());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,`&`),(0,s.default)(/</g,`<`),(0,s.default)(/>/g,`>`),(0,s.default)(/"/g,`"`),(0,s.default)(/'/g,`'`),(0,s.default)(/`/g,```)),t.exports=e.default})),Oe=b(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(De());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),ke=b(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});var n=a(C()),r=a(T()),i=a(oe());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})),Ae=b(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(ke());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),je=b(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});var n=a(C()),r=a(T()),i=a(oe());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})),Me=b(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(je());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),Ne=b(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});var n=o(C()),r=o(fe()),i=o(T()),a=o(oe());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})),Pe=b(((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})),Fe=b(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});var n=o(C()),r=o(fe()),i=o(T()),a=o(oe());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})),Ie=b(((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})),Le=b(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});var n=o(C()),r=o(fe()),i=o(T()),a=o(oe());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})),Re=b(((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})),ze=b(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});var n=o(C()),r=o(ie()),i=o(fe()),a=o(T());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})),Be=b(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(ze());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),Ve=b(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});var n=o(C()),r=o(fe()),i=o(T()),a=o(oe());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})),He=b(((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})),Ue=b(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});var n=a(C()),r=a(ie()),i=a(T());function a(e){return e&&e.__esModule?e:{default:e}}e.default=new n.default(r.default,i.default),t.exports=e.default})),We=b(((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})),Ge=b(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});var n=a(C()),r=a(ie()),i=a(T());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})),Ke=b(((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})),E=b((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(C()),n=w(T()),r=w(ie()),i=w(oe()),a=w(ce()),o=w(ue()),s=w(fe()),c=w(me()),l=w(ge()),u=w(ve()),d=w(be()),f=w(Se()),p=w(we()),m=w(Te()),h=w(Ee()),g=w(Oe()),_=w(Ae()),v=w(Me()),y=w(Pe()),b=w(Ie()),x=w(Re()),S=w(Be()),ee=w(He()),te=w(We()),ne=w(Ke());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=b.default,e.oneLineCommaListsAnd=x.default,e.inlineLists=S.default,e.oneLineInlineLists=ee.default,e.stripIndent=te.default,e.stripIndents=ne.default}))(),qe=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 Je(e,t){return(!e||e.endsWith(`
|
|
5
5
|
`))&&!t?.force?e:e+`
|
|
6
|
-
`}function D(e,t){return
|
|
6
|
+
`}function D(e,t){return Je(t)+e}function Ye(e,t){return(!e||e.endsWith(`
|
|
7
7
|
|
|
8
|
-
`))&&!t?.force?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`
|
|
8
|
+
`))&&!t?.force?e:Je(e)+`
|
|
9
|
+
`}function O(e,t){return Ye(t)+e}const Xe=`https://prismic.io/docs/slices`,Ze={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 Qe=x({__addDisposableResource:()=>Et,__assign:()=>At,__asyncDelegator:()=>vt,__asyncGenerator:()=>_t,__asyncValues:()=>yt,__await:()=>gt,__awaiter:()=>ct,__classPrivateFieldGet:()=>Ct,__classPrivateFieldIn:()=>Tt,__classPrivateFieldSet:()=>wt,__createBinding:()=>jt,__decorate:()=>tt,__disposeResources:()=>Dt,__esDecorate:()=>rt,__exportStar:()=>ut,__extends:()=>$e,__generator:()=>lt,__importDefault:()=>St,__importStar:()=>xt,__makeTemplateObject:()=>bt,__metadata:()=>st,__param:()=>nt,__propKey:()=>at,__read:()=>ft,__rest:()=>et,__rewriteRelativeImportExtension:()=>Ot,__runInitializers:()=>it,__setFunctionName:()=>ot,__spread:()=>pt,__spreadArray:()=>ht,__spreadArrays:()=>mt,__values:()=>dt,default:()=>Ft});function $e(e,t){if(typeof t!=`function`&&t!==null)throw TypeError(`Class extends value `+String(t)+` is not a constructor or null`);kt(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}function et(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 tt(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 nt(e,t){return function(n,r){t(n,r,e)}}function rt(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 it(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 at(e){return typeof e==`symbol`?e:`${e}`}function ot(e,t,n){return typeof t==`symbol`&&(t=t.description?`[${t.description}]`:``),Object.defineProperty(e,`name`,{configurable:!0,value:n?`${n} ${t}`:t})}function st(e,t){if(typeof Reflect==`object`&&typeof Reflect.metadata==`function`)return Reflect.metadata(e,t)}function ct(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 lt(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 ut(e,t){for(var n in e)n!==`default`&&!Object.prototype.hasOwnProperty.call(t,n)&&jt(t,e,n)}function dt(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 ft(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 pt(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(ft(arguments[t]));return e}function mt(){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 ht(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 gt(e){return this instanceof gt?(this.v=e,this):new gt(e)}function _t(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 gt?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 vt(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:gt(e[r](t)),done:!1}:i?i(t):t}:i}}function yt(e){if(!Symbol.asyncIterator)throw TypeError(`Symbol.asyncIterator is not defined.`);var t=e[Symbol.asyncIterator],n;return t?t.call(e):(e=typeof dt==`function`?dt(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 bt(e,t){return Object.defineProperty?Object.defineProperty(e,`raw`,{value:t}):e.raw=t,e}function xt(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var n=Nt(e),r=0;r<n.length;r++)n[r]!==`default`&&jt(t,e,n[r]);return Mt(t,e),t}function St(e){return e&&e.__esModule?e:{default:e}}function Ct(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 wt(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 Tt(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 Et(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 Dt(e){function t(t){e.error=e.hasError?new Pt(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 Ot(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 kt,At,jt,Mt,Nt,Pt,Ft,It=y((()=>{kt=function(e,t){return kt=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])},kt(e,t)},At=function(){return At=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},At.apply(this,arguments)},jt=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]}),Mt=Object.create?(function(e,t){Object.defineProperty(e,`default`,{enumerable:!0,value:t})}):function(e,t){e.default=t},Nt=function(e){return Nt=Object.getOwnPropertyNames||function(e){var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[t.length]=n);return t},Nt(e)},Pt=typeof SuppressedError==`function`?SuppressedError:function(e,t,n){var r=Error(n);return r.name=`SuppressedError`,r.error=e,r.suppressed=t,r},Ft={__extends:$e,__assign:At,__rest:et,__decorate:tt,__param:nt,__esDecorate:rt,__runInitializers:it,__propKey:at,__setFunctionName:ot,__metadata:st,__awaiter:ct,__generator:lt,__createBinding:jt,__exportStar:ut,__values:dt,__read:ft,__spread:pt,__spreadArrays:mt,__spreadArray:ht,__await:gt,__asyncGenerator:_t,__asyncDelegator:vt,__asyncValues:yt,__makeTemplateObject:bt,__importStar:xt,__importDefault:St,__classPrivateFieldGet:Ct,__classPrivateFieldSet:wt,__classPrivateFieldIn:Tt,__addDisposableResource:Et,__disposeResources:Dt,__rewriteRelativeImportExtension:Ot}})),Lt=b((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})),Rt=b((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.noCase=void 0;var t=Lt(),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)}})),zt=b((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.pascalCase=e.pascalCaseTransformMerge=e.pascalCaseTransform=void 0;var t=(It(),ee(Qe)),n=Rt();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,zt.pascalCase)(e.filter(Boolean).join(` `),{transform:zt.pascalCaseTransformMerge});return/^[0-9]/.test(t)&&(t=`_${t}`),t},Bt={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 Vt(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 Ht=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 Ut(e){return e.path.map(e=>e.label?e.label:e.model?Ht({model:e.model,name:e.name}):e.name).join(` → `)}function Wt(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 Gt(e){switch(e.field.type){case`Link`:{let t=Ze.Link;switch(e.field.config?.select){case`document`:return t.contentRelationship;case`media`:return t.linkToMedia;default:return t.link}}default:{let t=Ze[e.field.type];if(typeof t==`string`)return t}}}function Kt(e){let t=`/**`,n=Ht({model:e.field,name:e.name}),r=Ut({path:e.path}),i=Wt({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**: ${Vt({path:[...e.path,{name:e.name,model:e.field}]})}`,t),e.tabName&&(t=D(` * - **Tab**: ${e.tabName}`,t));let o=Gt({field:e.field});return o&&(t=D(` * - **Documentation**: ${o}`,t)),t=D(` */`,t),t}function qt(e){return e.filter(Boolean).join(` | `)||`never`}function Jt(e){let t=Kt({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=qt(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<${qt(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}: ${qt(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?qt(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===Bt.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=Ut({path:c}),u=Yt({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
10
|
/**
|
|
11
11
|
* Item in *${l}*
|
|
12
12
|
*/
|
|
13
13
|
export interface ${s} {
|
|
14
14
|
${u.code}
|
|
15
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=
|
|
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=Ut({path:a}),l=Yt({fields:i[`non-repeat`],fieldConfigs:e.fieldConfigs,path:a});n.push(...l.auxiliaryTypes),r.push(...l.contentTypeNames);let u=E.stripIndent`
|
|
17
17
|
/**
|
|
18
18
|
* Primary content in *${c}*
|
|
19
19
|
*/
|
|
@@ -21,7 +21,7 @@ import{parseArgs as e}from"node:util";import{access as t,mkdir as n,readFile as
|
|
|
21
21
|
export interface ${s} {
|
|
22
22
|
${l.code}
|
|
23
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=
|
|
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=Ut({path:a}),l=Yt({fields:i.repeat,fieldConfigs:e.fieldConfigs,path:a});n.push(...l.auxiliaryTypes),r.push(...l.contentTypeNames);let u=E.stripIndent`
|
|
25
25
|
/**
|
|
26
26
|
* Item content in *${s}*
|
|
27
27
|
*/
|
|
@@ -31,17 +31,17 @@ import{parseArgs as e}from"node:util";import{access as t,mkdir as n,readFile as
|
|
|
31
31
|
}
|
|
32
32
|
`,u):D(`export interface ${c} {}`,u),n.push({name:c,code:u}),r.push(c)}n.push({name:o,code:E.stripIndent`
|
|
33
33
|
/**
|
|
34
|
-
* Slice for *${
|
|
34
|
+
* Slice for *${Ut({path:[...e.path,{name:e.name,model:e.field}]})}*
|
|
35
35
|
*/
|
|
36
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=
|
|
37
|
+
`}),a.push(o)}}let o=k(e.path[0].name,`Document`,`Data`,e.name,`Slice`),s=qt(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 Yt(e){let t=``,n=[],r=[];for(let i in e.fields){let a=e.fields[i],o=Jt({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 Xt(e){let t=``,n=[],r=[],i=k(e.model.id,`Document`,`Data`),a=Ht({name:e.model.id,model:e.model}),o=``;for(let t in e.model.json){let{uid:i,...a}=e.model.json[t],s=Yt({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
38
|
/**
|
|
39
39
|
* Content for ${a} documents
|
|
40
40
|
*/
|
|
41
41
|
interface ${i} {
|
|
42
42
|
${o}
|
|
43
43
|
}
|
|
44
|
-
`:`interface ${i} {}`,{name:i,code:t,auxiliaryTypes:n,contentTypeNames:r}}function
|
|
44
|
+
`:`interface ${i} {}`,{name:i,code:t,auxiliaryTypes:n,contentTypeNames:r}}function Zt(e){return`uid`in Object.assign({},...Object.values(e.json))}const Qt=e=>c.createHash(`sha1`).update(JSON.stringify(e)).digest(`hex`);function $t(e){if(e.cache){let t=Qt(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?qt(e.localeIDs.map(e=>`"${e}"`)):`string`,o=Zt(e.model)?`PrismicDocumentWithUID`:`PrismicDocumentWithoutUID`,s=Ht({name:e.model.id,model:e.model}),c=Xt({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
45
|
/**
|
|
46
46
|
* ${s} document from Prismic
|
|
47
47
|
*
|
|
@@ -52,7 +52,7 @@ import{parseArgs as e}from"node:util";import{access as t,mkdir as n,readFile as
|
|
|
52
52
|
* @typeParam Lang - Language API ID of the document.
|
|
53
53
|
*/
|
|
54
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=
|
|
55
|
+
`,t);let l={name:i,code:t,auxiliaryTypes:n,contentTypeNames:r};if(e.cache){let t=Qt(e.model);e.cache.set(t,l)}return l}function en(e){if(e.cache){let t=Qt([e.model,e.fieldConfigs]),n=e.cache.get(t);if(n)return n}let t=``,n=[],r=[],i=k(e.model.id,`Slice`),a=Ht({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=Ut({path:i}),o=Yt({fields:s.primary,fieldConfigs:e.fieldConfigs,path:i});n.push(...o.auxiliaryTypes),r.push(...o.contentTypeNames),r.push(l);let u=E.stripIndent`
|
|
56
56
|
/**
|
|
57
57
|
* Primary content in *${a}*
|
|
58
58
|
*/
|
|
@@ -64,7 +64,7 @@ import{parseArgs as e}from"node:util";import{access as t,mkdir as n,readFile as
|
|
|
64
64
|
`:E.source`
|
|
65
65
|
${u}
|
|
66
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=
|
|
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=Ut({path:i}),o=Yt({fields:s.items,fieldConfigs:e.fieldConfigs,path:i});n.push(...o.auxiliaryTypes),r.push(...o.contentTypeNames),r.push(u);let l=E.stripIndent`
|
|
68
68
|
/**
|
|
69
69
|
* Primary content in *${a}*
|
|
70
70
|
*/
|
|
@@ -82,10 +82,10 @@ import{parseArgs as e}from"node:util";import{access as t,mkdir as n,readFile as
|
|
|
82
82
|
*
|
|
83
83
|
* - **API ID**: \`${s.id}\`
|
|
84
84
|
* - **Description**: ${s.description||`*None*`}
|
|
85
|
-
* - **Documentation**: ${
|
|
85
|
+
* - **Documentation**: ${Xe}
|
|
86
86
|
*/
|
|
87
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=
|
|
88
|
+
`,t),o.push(c)}let s=k(i,`Variation`),c=qt(o);r.push(s),r.push(...o),t=O(E.source`
|
|
89
89
|
/**
|
|
90
90
|
* Slice variation for *${a}*
|
|
91
91
|
*/
|
|
@@ -96,10 +96,10 @@ import{parseArgs as e}from"node:util";import{access as t,mkdir as n,readFile as
|
|
|
96
96
|
*
|
|
97
97
|
* - **API ID**: \`${e.model.id}\`
|
|
98
98
|
* - **Description**: ${e.model.description||`*None*`}
|
|
99
|
-
* - **Documentation**: ${
|
|
99
|
+
* - **Documentation**: ${Xe}
|
|
100
100
|
*/
|
|
101
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=
|
|
102
|
+
`,t);let l={name:i,variationNames:o,code:t,auxiliaryTypes:n,contentTypeNames:r};if(e.cache){let t=Qt([e.model,e.fieldConfigs]);e.cache.set(t,l)}return l}const tn=new qe({maxSize:1e3});function nn(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
103
|
type PickContentRelationshipFieldData<
|
|
104
104
|
TRelationship extends prismic.CustomTypeModelFetchCustomTypeLevel1 | prismic.CustomTypeModelFetchCustomTypeLevel2 | prismic.CustomTypeModelFetchGroupLevel1 | prismic.CustomTypeModelFetchGroupLevel2,
|
|
105
105
|
TData extends Record<string, prismic.AnyRegularField | prismic.GroupField | prismic.NestedGroupField | prismic.SliceZone>,
|
|
@@ -142,7 +142,7 @@ type ContentRelationshipFieldWithData<
|
|
|
142
142
|
>
|
|
143
143
|
>
|
|
144
144
|
}[Exclude<TCustomType[number], string>["id"]];
|
|
145
|
-
`,r);let o=[];if(e.customTypeModels){let i=[];for(let a of e.customTypeModels){let s
|
|
145
|
+
`,r);let o=[];if(e.customTypeModels){let i=[];for(let a of e.customTypeModels){let s=$t({model:a,localeIDs:e.localeIDs,fieldConfigs:t,cache:n?tn: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} = ${qt(i)};`,r),o.push(e)}}if(e.sharedSliceModels)for(let i of e.sharedSliceModels){let e=en({model:i,fieldConfigs:t,cache:n?tn: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
146
|
(repositoryNameOrEndpoint: string, options?: ${a}.ClientConfig): ${a}.Client<AllDocumentTypes>;
|
|
147
147
|
}`,t),t=O(`interface CreateWriteClient {
|
|
148
148
|
(repositoryNameOrEndpoint: string, options: ${a}.WriteClientConfig): ${a}.WriteClient<AllDocumentTypes>;
|
|
@@ -165,39 +165,20 @@ type ContentRelationshipFieldWithData<
|
|
|
165
165
|
declare module "@prismicio/client" {
|
|
166
166
|
${t}
|
|
167
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.
|
|
168
|
+
`,r)}return r}function rn(e){return{lang:e?.lang??void 0,message:e?.message,abortEarly:e?.abortEarly??void 0,abortPipeEarly:e?.abortPipeEarly??void 0}}function an(e){return(void 0)?.get(e)}function on(e){return(void 0)?.get(e)}function sn(e,t){return(void 0)?.get(e)?.get(t)}function cn(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 ln(e,t,n,r,i){let a=i&&`input`in i?i.input:n.value,o=i?.expected??e.expects??null,s=i?.received??cn(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??sn(e.reference,c.lang)??(l?on(c.lang):null)??r.message??an(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 un(e){return{version:1,vendor:`valibot`,validate(t){return e[`~run`]({value:t},rn())}}}function dn(e,t){return Object.hasOwn(e,t)&&t!==`__proto__`&&t!==`prototype`&&t!==`constructor`}function A(e){return e instanceof fn}var fn=class extends Error{constructor(e){super(e[0].message),this.name=`ValiError`,this.issues=e}};function pn(e){return{kind:`validation`,type:`url`,reference:pn,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)&&ln(this,`URL`,e,t),e}}}function mn(e,t,n){return typeof e.fallback==`function`?e.fallback(t,n):e.fallback}function hn(e,t,n){return typeof e.default==`function`?e.default(t,n):e.default}function j(e,t){return{kind:`schema`,type:`array`,reference:j,expects:`Array`,async:!1,item:e,message:t,get"~standard"(){return un(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 ln(this,`type`,e,t);return e}}}function M(e){return{kind:`schema`,type:`boolean`,reference:M,expects:`boolean`,async:!1,message:e,get"~standard"(){return un(this)},"~run"(e,t){return typeof e.value==`boolean`?e.typed=!0:ln(this,`type`,e,t),e}}}function gn(e,t){return{kind:`schema`,type:`literal`,reference:gn,expects:cn(e),async:!1,literal:e,message:t,get"~standard"(){return un(this)},"~run"(e,t){return e.value===this.literal?e.typed=!0:ln(this,`type`,e,t),e}}}function _n(e,t){return{kind:`schema`,type:`nullable`,reference:_n,expects:`(${e.expects} | null)`,async:!1,wrapped:e,default:t,get"~standard"(){return un(this)},"~run"(e,t){return e.value===null&&(this.default!==void 0&&(e.value=hn(this,e,t)),e.value===null)?(e.typed=!0,e):this.wrapped[`~run`](e,t)}}}function vn(e){return{kind:`schema`,type:`number`,reference:vn,expects:`number`,async:!1,message:e,get"~standard"(){return un(this)},"~run"(e,t){return typeof e.value==`number`&&!isNaN(e.value)?e.typed=!0:ln(this,`type`,e,t),e}}}function N(e,t){return{kind:`schema`,type:`object`,reference:N,expects:`Object`,async:!1,entries:e,message:t,get"~standard"(){return un(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]:hn(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]=mn(i);else if(i.type!==`exact_optional`&&i.type!==`optional`&&i.type!==`nullish`&&(ln(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 ln(this,`type`,e,t);return e}}}function P(e,t){return{kind:`schema`,type:`optional`,reference:P,expects:`(${e.expects} | undefined)`,async:!1,wrapped:e,default:t,get"~standard"(){return un(this)},"~run"(e,t){return e.value===void 0&&(this.default!==void 0&&(e.value=hn(this,e,t)),e.value===void 0)?(e.typed=!0,e):this.wrapped[`~run`](e,t)}}}function F(e,t,n){return{kind:`schema`,type:`record`,reference:F,expects:`Object`,async:!1,key:e,value:t,message:n,get"~standard"(){return un(this)},"~run"(e,t){let n=e.value;if(n&&typeof n==`object`){for(let r in e.typed=!0,e.value={},n)if(dn(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 ln(this,`type`,e,t);return e}}}function I(e){return{kind:`schema`,type:`string`,reference:I,expects:`string`,async:!1,message:e,get"~standard"(){return un(this)},"~run"(e,t){return typeof e.value==`string`?e.typed=!0:ln(this,`type`,e,t),e}}}function L(){return{kind:`schema`,type:`unknown`,reference:L,expects:`unknown`,async:!1,get"~standard"(){return un(this)},"~run"(e){return e.typed=!0,e}}}function yn(e,t,n){let r=e[`~run`]({value:t},rn(n));if(r.issues)throw new fn(r.issues);return r.value}function bn(...e){return{...e[0],pipe:e,get"~standard"(){return un(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 R(e,t,n){let r=e[`~run`]({value:t},rn(n));return{typed:r.typed,success:!r.issues,output:r.value,issues:r.issues}}async function z(e){let t=await On();return t.hostname=`${e}.${t.hostname}`,Cn(t)}async function xn(){let e=await On();return e.hostname=`api.internal.${e.hostname}`,Cn(e)}async function Sn(){let e=await On();return e.hostname=`user-service.${e.hostname}`,Cn(e)}function Cn(e){let t=new URL(e);return t.pathname.endsWith(`/`)||(t.pathname+=`/`),t}const wn=new URL(`.prismic`,Cn(d(u()))),Tn=`https://prismic.io`;async function En(e,t){let n={token:e,host:t?.host};await s(wn,JSON.stringify(n,null,2))}async function B(){let e=await Dn();if(!e)return!1;try{let t=await On();t.hostname=`user-service.${t.hostname}`;let n=new URL(`profile`,t);return(await fetch(n,{headers:{Accept:`application/json`,Cookie:`SESSION=fake_session; prismic-auth=${e}`}})).ok?!0:(await An(),!1)}catch{return!1}}async function Dn(){return(await kn())?.token}async function On(){try{let e=await kn();return e?.host?new URL(e.host):new URL(Tn)}catch{return new URL(Tn)}}async function kn(){try{let e=await r(wn,`utf-8`);return JSON.parse(e)}catch{return}}async function An(){try{await t(wn)}catch{return!0}return await kn()?(await o(wn),!0):!1}async function V(e,n={}){let{start:r=d(process.cwd()),stop:i}=n,a=Cn(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 jn(e){try{return await t(e),!0}catch{return!1}}const Mn=N({id:I(),type:gn(`SharedSlice`),name:I(),description:P(I()),variations:j(N({id:I(),name:I(),description:P(I()),docURL:P(I()),version:P(I()),imageUrl:P(I()),primary:P(F(I(),L())),items:P(F(I(),L()))}))});async function H(e){if(!await V(`package.json`))return{ok:!1,error:`Could not find project root (no package.json found)`};let t=await Nn(),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=R(Mn,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 Nn(){let e=await Fn(),t=await V(`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 jn(new URL(`src`,n)))return new URL(`src/slices/`,n);case`nuxt`:if(await jn(new URL(`app`,n)))return new URL(`app/slices/`,n);case`sveltekit`:return new URL(`src/slices/`,n)}return new URL(`slices/`,n)}const Pn=N({dependencies:P(F(I(),I()))});async function Fn(){let e=await V(`package.json`);if(e)try{let t=await r(e,`utf8`),{dependencies:n={}}=yn(Pn,JSON.parse(t));if(`next`in n)return`next`;if(`nuxt`in n)return`nuxt`;if(`@sveltejs/kit`in n)return`sveltekit`}catch{}}function In(e){return e.toLowerCase().replace(/(^|[-_\s]+)(.)?/g,(e,t,n)=>n?.toUpperCase()??``)}const Ln=N({id:I(),label:P(I()),repeatable:M(),status:M(),format:P(I()),json:F(I(),L())});async function Rn(){let e=await On();return e.hostname=`customtypes.${e.hostname}`,e}async function zn(e){let t=await Dn();if(!t)return{ok:!1,error:`Not authenticated`};let n=await Rn(),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=R(j(Ln),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 Bn(e){let t=await Dn();if(!t)return{ok:!1,error:`Not authenticated`};let n=await Rn(),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=R(j(Mn),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 Vn(){let e=await V(`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=R(Ln,JSON.parse(e));n.success&&o.push(n.output)}catch{}}return{ok:!0,value:o}}async function Hn(){let e;try{e=await Nn()}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=R(Mn,JSON.parse(e));i.success&&n.push(i.output)}catch{}}return{ok:!0,value:n}}async function Un(e,t){let n=await Dn();if(!n)return{ok:!1,error:`Not authenticated`};let r=await Rn(),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 Wn(e,t){let n=await Dn();if(!n)return{ok:!1,error:`Not authenticated`};let r=await Rn(),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 Gn(e,t){let n=await Dn();if(!n)return{ok:!1,error:`Not authenticated`};let r=await Rn(),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 Kn(e,t){let n=await Dn();if(!n)return{ok:!1,error:`Not authenticated`};let r=await Rn(),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 Dn();if(!n)return{ok:!1,error:`Not authenticated`};let r=await Rn(),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 Jn(e,t){let n=await Dn();if(!n)return{ok:!1,error:`Not authenticated`};let r=await Rn(),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 Yn(){let{values:{help:t,output:n}}=e({args:process.argv.slice(4),options:{output:{type:`string`,short:`o`},help:{type:`boolean`,short:`h`}},allowPositionals:!1});if(t){console.info(`Generate TypeScript types from local custom type and slice models.
|
|
186
169
|
|
|
187
170
|
USAGE
|
|
188
171
|
prismic codegen types [flags]
|
|
189
172
|
|
|
190
173
|
FLAGS
|
|
191
174
|
-o, --output string Output file path (default: "prismicio-types.d.ts")
|
|
192
|
-
-r, --repo string Repository domain
|
|
193
175
|
-h, --help Show help for command
|
|
194
176
|
|
|
195
177
|
EXAMPLES
|
|
196
178
|
prismic codegen types
|
|
197
|
-
prismic codegen types --
|
|
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.
|
|
179
|
+
prismic codegen types --output custom.d.ts`);return}try{await U({output:n}),console.info(`Generated types written to ${n??`prismicio-types.d.ts`}`)}catch(e){console.error(e instanceof Error?e.message:String(e)),process.exitCode=1}}async function U(e){let t=e?.output??`prismicio-types.d.ts`,[n,r]=await Promise.all([Vn(),Hn()]);if(!n.ok)throw Error(`failed to read local custom types: ${n.error}`);if(!r.ok)throw Error(`failed to read local slices: ${r.error}`);let i=n.value,a=r.value;await s(t,`// Code generated by prismic-ts-codegen. DO NOT EDIT.
|
|
199
180
|
|
|
200
|
-
`+
|
|
181
|
+
`+nn({customTypeModels:i,sharedSliceModels:a,typesProvider:`@prismicio/client`,clientIntegration:{includeCreateClientInterface:i.length>0||a.length>0,includeContentNamespace:!0}}))}async function Xn(){let{positionals:[t]}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`types`:await Yn();break;default:t&&(console.error(`Unknown codegen subcommand: ${t}\n`),process.exitCode=1),console.info(`Generate code from Prismic models.
|
|
201
182
|
|
|
202
183
|
USAGE
|
|
203
184
|
prismic codegen <command> [flags]
|
|
@@ -209,7 +190,7 @@ FLAGS
|
|
|
209
190
|
-h, --help Show help for command
|
|
210
191
|
|
|
211
192
|
LEARN MORE
|
|
212
|
-
Use \`prismic codegen <command> --help\` for more information about a command.`)}}function
|
|
193
|
+
Use \`prismic codegen <command> --help\` for more information about a command.`)}}function W(e){let t=e.split(`.`);return t.length===1?{type:`top-level`,fieldId:e}:t.length===2?{type:`nested`,groupId:t[0],nestedFieldId:t[1]}:{type:`nested`,groupId:t[0],nestedFieldId:t.slice(1).join(`.`)}}function G(e){return typeof e==`object`&&!!e&&`type`in e&&e.type===`Group`&&`config`in e&&typeof e.config==`object`&&e.config!==null&&`fields`in e.config}function K(e,t,n){let r=e[t];return r?G(r)?{ok:!0,group:r}:{ok:!1,error:`Field "${t}" is not a group`}:{ok:!1,error:`Group "${t}" not found in tab "${n}"`}}function Zn(e,t,n){let r=e[t];return r?G(r)?{ok:!0,group:r}:{ok:!1,error:`Field "${t}" is not a group`}:{ok:!1,error:`Group "${t}" not found in variation "${n}"`}}function q(e){return e.type===`nested`&&e.nestedFieldId.includes(`.`)?{ok:!1,error:`Nested groups not supported. Use: group.field`}:{ok:!0}}function J(e){return JSON.stringify(e,null,2)}function Y(e){return e.replace(/([a-z])([A-Z])/g,`$1 $2`).replace(/[_-]+/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}const Qn=N({id:I(),label:I(),repeatable:M(),status:M(),format:I(),json:F(I(),F(I(),L()))});async function $n(){let{values:{help:t,tab:n,label:i,default:a,"true-label":o,"false-label":c,types:l},positionals:[u,d]}=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`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a boolean (toggle) field to an existing custom type.
|
|
213
194
|
|
|
214
195
|
USAGE
|
|
215
196
|
prismic custom-type add-field boolean <type-id> <field-id> [flags]
|
|
@@ -224,14 +205,15 @@ FLAGS
|
|
|
224
205
|
--default Set default value to true
|
|
225
206
|
--true-label string Label shown when toggle is on
|
|
226
207
|
--false-label string Label shown when toggle is off
|
|
208
|
+
--types string Output file for generated types (default: "prismicio-types.d.ts")
|
|
227
209
|
-h, --help Show help for command
|
|
228
210
|
|
|
229
211
|
EXAMPLES
|
|
230
212
|
prismic custom-type add-field boolean homepage featured
|
|
231
213
|
prismic custom-type add-field boolean article published --default
|
|
232
|
-
prismic custom-type add-field boolean product available --true-label "In Stock" --false-label "Out of Stock"`);return}if(!
|
|
233
|
-
`),console.error(`Usage: prismic custom-type add-field boolean <type-id> <field-id>`),process.exitCode=1;return}if(!
|
|
234
|
-
`),console.error(`Usage: prismic custom-type add-field boolean <type-id> <field-id>`),process.exitCode=1;return}let d=await
|
|
214
|
+
prismic custom-type add-field boolean product available --true-label "In Stock" --false-label "Out of Stock"`);return}if(!u){console.error(`Missing required argument: type-id
|
|
215
|
+
`),console.error(`Usage: prismic custom-type add-field boolean <type-id> <field-id>`),process.exitCode=1;return}if(!d){console.error(`Missing required argument: field-id
|
|
216
|
+
`),console.error(`Usage: prismic custom-type add-field boolean <type-id> <field-id>`),process.exitCode=1;return}let f=W(d),p=q(f);if(!p.ok){console.error(p.error),process.exitCode=1;return}let m=await V(`package.json`);if(!m){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let h=new URL(`customtypes/${u}/index.json`,m),g;try{let e=await r(h,`utf8`),t=R(Qn,JSON.parse(e));if(!t.success){console.error(`Invalid custom type model: ${h.href}`),process.exitCode=1;return}g=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 _=Object.keys(g.json),v=n??_[0]??`Main`;g.json[v]||(g.json[v]={});let y={type:`Boolean`,config:{label:i??Y(f.type===`nested`?f.nestedFieldId:d),...a&&{default_value:!0},...o&&{placeholder_true:o},...c&&{placeholder_false:c}}};if(f.type===`nested`){let e=K(g.json[v],f.groupId,v);if(!e.ok){console.error(e.error),process.exitCode=1;return}if(e.group.config.fields[f.nestedFieldId]){console.error(`Field "${f.nestedFieldId}" already exists in group "${f.groupId}"`),process.exitCode=1;return}e.group.config.fields[f.nestedFieldId]=y}else{for(let[e,t]of Object.entries(g.json)){if(t[d]){console.error(`Field "${d}" already exists in tab "${e}"`),process.exitCode=1;return}for(let[n,r]of Object.entries(t))if(G(r)&&r.config.fields[d]){console.error(`Field "${d}" already exists in group "${n}" in tab "${e}"`),process.exitCode=1;return}}g.json[v][d]=y}try{await s(h,J(g))}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}f.type===`nested`?console.info(`Added field "${f.nestedFieldId}" (Boolean) to group "${f.groupId}" in ${u}`):console.info(`Added field "${d}" (Boolean) to "${v}" tab in ${u}`);try{await U({output:l}),console.info(`Updated types in ${l??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic custom-type add-field`"),console.info(" Run `prismic status` when done to find next steps")}const er=N({id:I(),label:I(),repeatable:M(),status:M(),format:I(),json:F(I(),F(I(),L()))});async function tr(){let{values:{help:t,tab:n,label:i,placeholder:a,types: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`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a color picker field to an existing custom type.
|
|
235
217
|
|
|
236
218
|
USAGE
|
|
237
219
|
prismic custom-type add-field color <type-id> <field-id> [flags]
|
|
@@ -244,14 +226,15 @@ FLAGS
|
|
|
244
226
|
-t, --tab string Target tab (default: first existing tab, or "Main")
|
|
245
227
|
-l, --label string Display label for the field (inferred from field-id if omitted)
|
|
246
228
|
-p, --placeholder string Placeholder text
|
|
229
|
+
--types string Output file for generated types (default: "prismicio-types.d.ts")
|
|
247
230
|
-h, --help Show help for command
|
|
248
231
|
|
|
249
232
|
EXAMPLES
|
|
250
233
|
prismic custom-type add-field color homepage bg_color
|
|
251
234
|
prismic custom-type add-field color homepage accent --tab "Design"
|
|
252
|
-
prismic custom-type add-field color homepage text_color --label "Text Color"`);return}if(!
|
|
253
|
-
`),console.error(`Usage: prismic custom-type add-field color <type-id> <field-id>`),process.exitCode=1;return}if(!
|
|
254
|
-
`),console.error(`Usage: prismic custom-type add-field color <type-id> <field-id>`),process.exitCode=1;return}let l=await
|
|
235
|
+
prismic custom-type add-field color homepage text_color --label "Text Color"`);return}if(!c){console.error(`Missing required argument: type-id
|
|
236
|
+
`),console.error(`Usage: prismic custom-type add-field color <type-id> <field-id>`),process.exitCode=1;return}if(!l){console.error(`Missing required argument: field-id
|
|
237
|
+
`),console.error(`Usage: prismic custom-type add-field color <type-id> <field-id>`),process.exitCode=1;return}let u=W(l),d=q(u);if(!d.ok){console.error(d.error),process.exitCode=1;return}let f=await V(`package.json`);if(!f){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let p=new URL(`customtypes/${c}/index.json`,f),m;try{let e=await r(p,`utf8`),t=R(er,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: ${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 h=Object.keys(m.json),g=n??h[0]??`Main`;m.json[g]||(m.json[g]={});let _={type:`Color`,config:{label:i??Y(u.type===`nested`?u.nestedFieldId:l),...a&&{placeholder:a}}};if(u.type===`nested`){let e=K(m.json[g],u.groupId,g);if(!e.ok){console.error(e.error),process.exitCode=1;return}if(e.group.config.fields[u.nestedFieldId]){console.error(`Field "${u.nestedFieldId}" already exists in group "${u.groupId}"`),process.exitCode=1;return}e.group.config.fields[u.nestedFieldId]=_}else{for(let[e,t]of Object.entries(m.json)){if(t[l]){console.error(`Field "${l}" already exists in tab "${e}"`),process.exitCode=1;return}for(let[n,r]of Object.entries(t))if(G(r)&&r.config.fields[l]){console.error(`Field "${l}" already exists in group "${n}" in tab "${e}"`),process.exitCode=1;return}}m.json[g][l]=_}try{await s(p,J(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}u.type===`nested`?console.info(`Added field "${u.nestedFieldId}" (Color) to group "${u.groupId}" in ${c}`):console.info(`Added field "${l}" (Color) to "${g}" tab in ${c}`);try{await U({output:o}),console.info(`Updated types in ${o??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic custom-type add-field`"),console.info(" Run `prismic status` when done to find next steps")}const nr=N({id:I(),label:I(),repeatable:M(),status:M(),format:I(),json:F(I(),F(I(),L()))});async function rr(){let{values:{help:t,tab:n,label:i,placeholder:a,default:o,types: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`},default:{type:`string`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a date field to an existing custom type.
|
|
255
238
|
|
|
256
239
|
USAGE
|
|
257
240
|
prismic custom-type add-field date <type-id> <field-id> [flags]
|
|
@@ -265,14 +248,15 @@ FLAGS
|
|
|
265
248
|
-l, --label string Display label for the field (inferred from field-id if omitted)
|
|
266
249
|
-p, --placeholder string Placeholder text
|
|
267
250
|
--default string Default date value (YYYY-MM-DD format)
|
|
251
|
+
--types string Output file for generated types (default: "prismicio-types.d.ts")
|
|
268
252
|
-h, --help Show help for command
|
|
269
253
|
|
|
270
254
|
EXAMPLES
|
|
271
255
|
prismic custom-type add-field date homepage publish_date
|
|
272
256
|
prismic custom-type add-field date event start_date --tab "Schedule"
|
|
273
|
-
prismic custom-type add-field date article date --label "Publication Date" --default "2024-01-01"`);return}if(!
|
|
274
|
-
`),console.error(`Usage: prismic custom-type add-field date <type-id> <field-id>`),process.exitCode=1;return}if(!
|
|
275
|
-
`),console.error(`Usage: prismic custom-type add-field date <type-id> <field-id>`),process.exitCode=1;return}let u=await
|
|
257
|
+
prismic custom-type add-field date article date --label "Publication Date" --default "2024-01-01"`);return}if(!l){console.error(`Missing required argument: type-id
|
|
258
|
+
`),console.error(`Usage: prismic custom-type add-field date <type-id> <field-id>`),process.exitCode=1;return}if(!u){console.error(`Missing required argument: field-id
|
|
259
|
+
`),console.error(`Usage: prismic custom-type add-field date <type-id> <field-id>`),process.exitCode=1;return}let d=W(u),f=q(d);if(!f.ok){console.error(f.error),process.exitCode=1;return}let p=await V(`package.json`);if(!p){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let m=new URL(`customtypes/${l}/index.json`,p),h;try{let e=await r(m,`utf8`),t=R(nr,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: ${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 g=Object.keys(h.json),_=n??g[0]??`Main`;h.json[_]||(h.json[_]={});let v={type:`Date`,config:{label:i??Y(d.type===`nested`?d.nestedFieldId:u),...a&&{placeholder:a},...o&&{default:o}}};if(d.type===`nested`){let e=K(h.json[_],d.groupId,_);if(!e.ok){console.error(e.error),process.exitCode=1;return}if(e.group.config.fields[d.nestedFieldId]){console.error(`Field "${d.nestedFieldId}" already exists in group "${d.groupId}"`),process.exitCode=1;return}e.group.config.fields[d.nestedFieldId]=v}else{for(let[e,t]of Object.entries(h.json)){if(t[u]){console.error(`Field "${u}" already exists in tab "${e}"`),process.exitCode=1;return}for(let[n,r]of Object.entries(t))if(G(r)&&r.config.fields[u]){console.error(`Field "${u}" already exists in group "${n}" in tab "${e}"`),process.exitCode=1;return}}h.json[_][u]=v}try{await s(m,J(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}d.type===`nested`?console.info(`Added field "${d.nestedFieldId}" (Date) to group "${d.groupId}" in ${l}`):console.info(`Added field "${u}" (Date) to "${_}" tab in ${l}`);try{await U({output:c}),console.info(`Updated types in ${c??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic custom-type add-field`"),console.info(" Run `prismic status` when done to find next steps")}const ir=N({id:I(),label:I(),repeatable:M(),status:M(),format:I(),json:F(I(),F(I(),L()))});async function ar(){let{values:{help:t,tab:n,label:i,placeholder:a,types: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`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add an embed field to an existing custom type.
|
|
276
260
|
|
|
277
261
|
USAGE
|
|
278
262
|
prismic custom-type add-field embed <type-id> <field-id> [flags]
|
|
@@ -285,14 +269,15 @@ FLAGS
|
|
|
285
269
|
-t, --tab string Target tab (default: first existing tab, or "Main")
|
|
286
270
|
-l, --label string Display label for the field (inferred from field-id if omitted)
|
|
287
271
|
-p, --placeholder string Placeholder text
|
|
272
|
+
--types string Output file for generated types (default: "prismicio-types.d.ts")
|
|
288
273
|
-h, --help Show help for command
|
|
289
274
|
|
|
290
275
|
EXAMPLES
|
|
291
276
|
prismic custom-type add-field embed homepage video
|
|
292
277
|
prismic custom-type add-field embed homepage youtube --tab "Media"
|
|
293
|
-
prismic custom-type add-field embed homepage media --label "Media Embed"`);return}if(!
|
|
294
|
-
`),console.error(`Usage: prismic custom-type add-field embed <type-id> <field-id>`),process.exitCode=1;return}if(!
|
|
295
|
-
`),console.error(`Usage: prismic custom-type add-field embed <type-id> <field-id>`),process.exitCode=1;return}let l=await
|
|
278
|
+
prismic custom-type add-field embed homepage media --label "Media Embed"`);return}if(!c){console.error(`Missing required argument: type-id
|
|
279
|
+
`),console.error(`Usage: prismic custom-type add-field embed <type-id> <field-id>`),process.exitCode=1;return}if(!l){console.error(`Missing required argument: field-id
|
|
280
|
+
`),console.error(`Usage: prismic custom-type add-field embed <type-id> <field-id>`),process.exitCode=1;return}let u=W(l),d=q(u);if(!d.ok){console.error(d.error),process.exitCode=1;return}let f=await V(`package.json`);if(!f){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let p=new URL(`customtypes/${c}/index.json`,f),m;try{let e=await r(p,`utf8`),t=R(ir,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: ${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 h=Object.keys(m.json),g=n??h[0]??`Main`;m.json[g]||(m.json[g]={});let _={type:`Embed`,config:{label:i??Y(u.type===`nested`?u.nestedFieldId:l),...a&&{placeholder:a}}};if(u.type===`nested`){let e=K(m.json[g],u.groupId,g);if(!e.ok){console.error(e.error),process.exitCode=1;return}if(e.group.config.fields[u.nestedFieldId]){console.error(`Field "${u.nestedFieldId}" already exists in group "${u.groupId}"`),process.exitCode=1;return}e.group.config.fields[u.nestedFieldId]=_}else{for(let[e,t]of Object.entries(m.json)){if(t[l]){console.error(`Field "${l}" already exists in tab "${e}"`),process.exitCode=1;return}for(let[n,r]of Object.entries(t))if(G(r)&&r.config.fields[l]){console.error(`Field "${l}" already exists in group "${n}" in tab "${e}"`),process.exitCode=1;return}}m.json[g][l]=_}try{await s(p,J(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}u.type===`nested`?console.info(`Added field "${u.nestedFieldId}" (Embed) to group "${u.groupId}" in ${c}`):console.info(`Added field "${l}" (Embed) to "${g}" tab in ${c}`);try{await U({output:o}),console.info(`Updated types in ${o??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic custom-type add-field`"),console.info(" Run `prismic status` when done to find next steps")}const or=N({id:I(),label:I(),repeatable:M(),status:M(),format:I(),json:F(I(),F(I(),L()))});async function sr(){let{values:{help:t,tab:n,label:i,types:a},positionals:[o,c]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a geo-point (location) field to an existing custom type.
|
|
296
281
|
|
|
297
282
|
USAGE
|
|
298
283
|
prismic custom-type add-field geo-point <type-id> <field-id> [flags]
|
|
@@ -304,14 +289,36 @@ ARGUMENTS
|
|
|
304
289
|
FLAGS
|
|
305
290
|
-t, --tab string Target tab (default: first existing tab, or "Main")
|
|
306
291
|
-l, --label string Display label for the field (inferred from field-id if omitted)
|
|
292
|
+
--types string Output file for generated types (default: "prismicio-types.d.ts")
|
|
307
293
|
-h, --help Show help for command
|
|
308
294
|
|
|
309
295
|
EXAMPLES
|
|
310
296
|
prismic custom-type add-field geo-point homepage location
|
|
311
297
|
prismic custom-type add-field geo-point store address --tab "Details"
|
|
312
|
-
prismic custom-type add-field geo-point event venue --label "Event Venue"`);return}if(!
|
|
313
|
-
`),console.error(`Usage: prismic custom-type add-field geo-point <type-id> <field-id>`),process.exitCode=1;return}if(!
|
|
314
|
-
`),console.error(`Usage: prismic custom-type add-field geo-point <type-id> <field-id>`),process.exitCode=1;return}let c=await
|
|
298
|
+
prismic custom-type add-field geo-point event venue --label "Event Venue"`);return}if(!o){console.error(`Missing required argument: type-id
|
|
299
|
+
`),console.error(`Usage: prismic custom-type add-field geo-point <type-id> <field-id>`),process.exitCode=1;return}if(!c){console.error(`Missing required argument: field-id
|
|
300
|
+
`),console.error(`Usage: prismic custom-type add-field geo-point <type-id> <field-id>`),process.exitCode=1;return}let l=W(c),u=q(l);if(!u.ok){console.error(u.error),process.exitCode=1;return}let d=await V(`package.json`);if(!d){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let f=new URL(`customtypes/${o}/index.json`,d),p;try{let e=await r(f,`utf8`),t=R(or,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: ${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 m=Object.keys(p.json),h=n??m[0]??`Main`;p.json[h]||(p.json[h]={});let g={type:`GeoPoint`,config:{label:i??Y(l.type===`nested`?l.nestedFieldId:c)}};if(l.type===`nested`){let e=K(p.json[h],l.groupId,h);if(!e.ok){console.error(e.error),process.exitCode=1;return}if(e.group.config.fields[l.nestedFieldId]){console.error(`Field "${l.nestedFieldId}" already exists in group "${l.groupId}"`),process.exitCode=1;return}e.group.config.fields[l.nestedFieldId]=g}else{for(let[e,t]of Object.entries(p.json)){if(t[c]){console.error(`Field "${c}" already exists in tab "${e}"`),process.exitCode=1;return}for(let[n,r]of Object.entries(t))if(G(r)&&r.config.fields[c]){console.error(`Field "${c}" already exists in group "${n}" in tab "${e}"`),process.exitCode=1;return}}p.json[h][c]=g}try{await s(f,J(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}l.type===`nested`?console.info(`Added field "${l.nestedFieldId}" (GeoPoint) to group "${l.groupId}" in ${o}`):console.info(`Added field "${c}" (GeoPoint) to "${h}" tab in ${o}`);try{await U({output:a}),console.info(`Updated types in ${a??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic custom-type add-field`"),console.info(" Run `prismic status` when done to find next steps")}const cr=N({id:I(),label:I(),repeatable:M(),status:M(),format:I(),json:F(I(),F(I(),L()))});async function lr(){let{values:{help:t,tab:n,label:i,"non-repeatable":a,types:o},positionals:[c,l]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},"non-repeatable":{type:`boolean`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a group field to an existing custom type.
|
|
301
|
+
|
|
302
|
+
USAGE
|
|
303
|
+
prismic custom-type add-field group <type-id> <field-id> [flags]
|
|
304
|
+
|
|
305
|
+
ARGUMENTS
|
|
306
|
+
type-id Custom type identifier (required)
|
|
307
|
+
field-id Field identifier (required)
|
|
308
|
+
|
|
309
|
+
FLAGS
|
|
310
|
+
-t, --tab string Target tab (default: first existing tab, or "Main")
|
|
311
|
+
-l, --label string Display label for the field (inferred from field-id if omitted)
|
|
312
|
+
--non-repeatable Make this a non-repeating group (default: repeatable)
|
|
313
|
+
--types string Output file for generated types (default: "prismicio-types.d.ts")
|
|
314
|
+
-h, --help Show help for command
|
|
315
|
+
|
|
316
|
+
EXAMPLES
|
|
317
|
+
prismic custom-type add-field group homepage buttons
|
|
318
|
+
prismic custom-type add-field group article authors --non-repeatable
|
|
319
|
+
prismic custom-type add-field group product variants --tab "Content"`);return}if(!c){console.error(`Missing required argument: type-id
|
|
320
|
+
`),console.error(`Usage: prismic custom-type add-field group <type-id> <field-id>`),process.exitCode=1;return}if(!l){console.error(`Missing required argument: field-id
|
|
321
|
+
`),console.error(`Usage: prismic custom-type add-field group <type-id> <field-id>`),process.exitCode=1;return}if(l.includes(`.`)){console.error(`Groups cannot be nested inside other groups`),process.exitCode=1;return}let u=await V(`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=R(cr,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:`Group`,config:{label:i??Y(l),repeat:!a,fields:{}}};f.json[m][l]=h;try{await s(d,J(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}" (Group) to "${m}" tab in ${c}`);try{await U({output:o}),console.info(`Updated types in ${o??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info(`Next: Add fields to the group with \`prismic custom-type add-field <type> ${c} ${l}.<field-id>\``),console.info(" Run `prismic status` when done to find next steps")}const ur=N({id:I(),label:I(),repeatable:M(),status:M(),format:I(),json:F(I(),F(I(),L()))});async function dr(){let{values:{help:t,tab:n,label:i,placeholder:a,types: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`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add an image field to an existing custom type.
|
|
315
322
|
|
|
316
323
|
USAGE
|
|
317
324
|
prismic custom-type add-field image <type-id> <field-id> [flags]
|
|
@@ -324,14 +331,15 @@ FLAGS
|
|
|
324
331
|
-t, --tab string Target tab (default: first existing tab, or "Main")
|
|
325
332
|
-l, --label string Display label for the field (inferred from field-id if omitted)
|
|
326
333
|
-p, --placeholder string Placeholder text
|
|
334
|
+
--types string Output file for generated types (default: "prismicio-types.d.ts")
|
|
327
335
|
-h, --help Show help for command
|
|
328
336
|
|
|
329
337
|
EXAMPLES
|
|
330
338
|
prismic custom-type add-field image homepage hero
|
|
331
339
|
prismic custom-type add-field image article thumbnail --tab "Media"
|
|
332
|
-
prismic custom-type add-field image product photo --label "Product Photo"`);return}if(!
|
|
333
|
-
`),console.error(`Usage: prismic custom-type add-field image <type-id> <field-id>`),process.exitCode=1;return}if(!
|
|
334
|
-
`),console.error(`Usage: prismic custom-type add-field image <type-id> <field-id>`),process.exitCode=1;return}let l=await
|
|
340
|
+
prismic custom-type add-field image product photo --label "Product Photo"`);return}if(!c){console.error(`Missing required argument: type-id
|
|
341
|
+
`),console.error(`Usage: prismic custom-type add-field image <type-id> <field-id>`),process.exitCode=1;return}if(!l){console.error(`Missing required argument: field-id
|
|
342
|
+
`),console.error(`Usage: prismic custom-type add-field image <type-id> <field-id>`),process.exitCode=1;return}let u=W(l),d=q(u);if(!d.ok){console.error(d.error),process.exitCode=1;return}let f=await V(`package.json`);if(!f){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let p=new URL(`customtypes/${c}/index.json`,f),m;try{let e=await r(p,`utf8`),t=R(ur,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: ${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 h=Object.keys(m.json),g=n??h[0]??`Main`;m.json[g]||(m.json[g]={});let _={type:`Image`,config:{label:i??Y(u.type===`nested`?u.nestedFieldId:l),...a&&{placeholder:a}}};if(u.type===`nested`){let e=K(m.json[g],u.groupId,g);if(!e.ok){console.error(e.error),process.exitCode=1;return}if(e.group.config.fields[u.nestedFieldId]){console.error(`Field "${u.nestedFieldId}" already exists in group "${u.groupId}"`),process.exitCode=1;return}e.group.config.fields[u.nestedFieldId]=_}else{for(let[e,t]of Object.entries(m.json)){if(t[l]){console.error(`Field "${l}" already exists in tab "${e}"`),process.exitCode=1;return}for(let[n,r]of Object.entries(t))if(G(r)&&r.config.fields[l]){console.error(`Field "${l}" already exists in group "${n}" in tab "${e}"`),process.exitCode=1;return}}m.json[g][l]=_}try{await s(p,J(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}u.type===`nested`?console.info(`Added field "${u.nestedFieldId}" (Image) to group "${u.groupId}" in ${c}`):console.info(`Added field "${l}" (Image) to "${g}" tab in ${c}`);try{await U({output:o}),console.info(`Updated types in ${o??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic custom-type add-field`"),console.info(" Run `prismic status` when done to find next steps")}const fr=N({id:I(),label:I(),repeatable:M(),status:M(),format:I(),json:F(I(),F(I(),L()))});async function pr(){let{values:{help:t,tab:n,label:i,placeholder:a,types: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`},types:{type:`string`},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
343
|
|
|
336
344
|
USAGE
|
|
337
345
|
prismic custom-type add-field key-text <type-id> <field-id> [flags]
|
|
@@ -344,14 +352,15 @@ FLAGS
|
|
|
344
352
|
-t, --tab string Target tab (default: first existing tab, or "Main")
|
|
345
353
|
-l, --label string Display label for the field (inferred from field-id if omitted)
|
|
346
354
|
-p, --placeholder string Placeholder text
|
|
355
|
+
--types string Output file for generated types (default: "prismicio-types.d.ts")
|
|
347
356
|
-h, --help Show help for command
|
|
348
357
|
|
|
349
358
|
EXAMPLES
|
|
350
359
|
prismic custom-type add-field key-text homepage title
|
|
351
360
|
prismic custom-type add-field key-text homepage meta_title --tab "SEO"
|
|
352
|
-
prismic custom-type add-field key-text homepage subtitle --label "Subtitle" --placeholder "Enter subtitle"`);return}if(!
|
|
353
|
-
`),console.error(`Usage: prismic custom-type add-field key-text <type-id> <field-id>`),process.exitCode=1;return}if(!
|
|
354
|
-
`),console.error(`Usage: prismic custom-type add-field key-text <type-id> <field-id>`),process.exitCode=1;return}let l=await
|
|
361
|
+
prismic custom-type add-field key-text homepage subtitle --label "Subtitle" --placeholder "Enter subtitle"`);return}if(!c){console.error(`Missing required argument: type-id
|
|
362
|
+
`),console.error(`Usage: prismic custom-type add-field key-text <type-id> <field-id>`),process.exitCode=1;return}if(!l){console.error(`Missing required argument: field-id
|
|
363
|
+
`),console.error(`Usage: prismic custom-type add-field key-text <type-id> <field-id>`),process.exitCode=1;return}let u=W(l),d=q(u);if(!d.ok){console.error(d.error),process.exitCode=1;return}let f=await V(`package.json`);if(!f){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let p=new URL(`customtypes/${c}/index.json`,f),m;try{let e=await r(p,`utf8`),t=R(fr,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: ${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 h=Object.keys(m.json),g=n??h[0]??`Main`;m.json[g]||(m.json[g]={});let _={type:`Text`,config:{label:i??Y(u.type===`nested`?u.nestedFieldId:l),...a&&{placeholder:a}}};if(u.type===`nested`){let e=K(m.json[g],u.groupId,g);if(!e.ok){console.error(e.error),process.exitCode=1;return}if(e.group.config.fields[u.nestedFieldId]){console.error(`Field "${u.nestedFieldId}" already exists in group "${u.groupId}"`),process.exitCode=1;return}e.group.config.fields[u.nestedFieldId]=_}else{for(let[e,t]of Object.entries(m.json)){if(t[l]){console.error(`Field "${l}" already exists in tab "${e}"`),process.exitCode=1;return}for(let[n,r]of Object.entries(t))if(G(r)&&r.config.fields[l]){console.error(`Field "${l}" already exists in group "${n}" in tab "${e}"`),process.exitCode=1;return}}m.json[g][l]=_}try{await s(p,J(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}u.type===`nested`?console.info(`Added field "${u.nestedFieldId}" (Text) to group "${u.groupId}" in ${c}`):console.info(`Added field "${l}" (Text) to "${g}" tab in ${c}`);try{await U({output:o}),console.info(`Updated types in ${o??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic custom-type add-field`"),console.info(" Run `prismic status` when done to find next steps")}const mr=N({id:I(),label:I(),repeatable:M(),status:M(),format:I(),json:F(I(),F(I(),L()))});async function hr(){let{values:{help:t,tab:n,label:i,placeholder:a,variation:o,"allow-text":c,"allow-target-blank":l,repeatable:u,types:d},positionals:[f,p]}=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`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a link field to an existing custom type.
|
|
355
364
|
|
|
356
365
|
USAGE
|
|
357
366
|
prismic custom-type add-field link <type-id> <field-id> [flags]
|
|
@@ -368,15 +377,16 @@ FLAGS
|
|
|
368
377
|
--allow-text Allow text with link
|
|
369
378
|
--allow-target-blank Allow opening link in new tab
|
|
370
379
|
--repeatable Allow multiple links
|
|
380
|
+
--types string Output file for generated types (default: "prismicio-types.d.ts")
|
|
371
381
|
-h, --help Show help for command
|
|
372
382
|
|
|
373
383
|
EXAMPLES
|
|
374
384
|
prismic custom-type add-field link homepage button
|
|
375
385
|
prismic custom-type add-field link homepage cta --allow-text
|
|
376
386
|
prismic custom-type add-field link homepage cta --variation Primary --variation Secondary
|
|
377
|
-
prismic custom-type add-field link homepage links --repeatable`);return}if(!
|
|
378
|
-
`),console.error(`Usage: prismic custom-type add-field link <type-id> <field-id>`),process.exitCode=1;return}if(!
|
|
379
|
-
`),console.error(`Usage: prismic custom-type add-field link <type-id> <field-id>`),process.exitCode=1;return}let p=await
|
|
387
|
+
prismic custom-type add-field link homepage links --repeatable`);return}if(!f){console.error(`Missing required argument: type-id
|
|
388
|
+
`),console.error(`Usage: prismic custom-type add-field link <type-id> <field-id>`),process.exitCode=1;return}if(!p){console.error(`Missing required argument: field-id
|
|
389
|
+
`),console.error(`Usage: prismic custom-type add-field link <type-id> <field-id>`),process.exitCode=1;return}let m=W(p),h=q(m);if(!h.ok){console.error(h.error),process.exitCode=1;return}let g=await V(`package.json`);if(!g){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let _=new URL(`customtypes/${f}/index.json`,g),v;try{let e=await r(_,`utf8`),t=R(mr,JSON.parse(e));if(!t.success){console.error(`Invalid custom type model: ${_.href}`),process.exitCode=1;return}v=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Custom type not found: ${f}\n`),console.error(`Create it first with: prismic custom-type create ${f}`),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 y=Object.keys(v.json),b=n??y[0]??`Main`;v.json[b]||(v.json[b]={});let x={type:`Link`,config:{label:i??Y(m.type===`nested`?m.nestedFieldId:p),...a&&{placeholder:a},...o&&o.length>0&&{variants:o},...c&&{allowText:!0},...l&&{allowTargetBlank:!0},...u&&{repeat:!0}}};if(m.type===`nested`){let e=K(v.json[b],m.groupId,b);if(!e.ok){console.error(e.error),process.exitCode=1;return}if(e.group.config.fields[m.nestedFieldId]){console.error(`Field "${m.nestedFieldId}" already exists in group "${m.groupId}"`),process.exitCode=1;return}e.group.config.fields[m.nestedFieldId]=x}else{for(let[e,t]of Object.entries(v.json)){if(t[p]){console.error(`Field "${p}" already exists in tab "${e}"`),process.exitCode=1;return}for(let[n,r]of Object.entries(t))if(G(r)&&r.config.fields[p]){console.error(`Field "${p}" already exists in group "${n}" in tab "${e}"`),process.exitCode=1;return}}v.json[b][p]=x}try{await s(_,J(v))}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}m.type===`nested`?console.info(`Added field "${m.nestedFieldId}" (Link) to group "${m.groupId}" in ${f}`):console.info(`Added field "${p}" (Link) to "${b}" tab in ${f}`);try{await U({output:d}),console.info(`Updated types in ${d??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic custom-type add-field`"),console.info(" Run `prismic status` when done to find next steps")}const gr=N({id:I(),label:I(),repeatable:M(),status:M(),format:I(),json:F(I(),F(I(),L()))});async function _r(){let{values:{help:t,tab:n,label:i,placeholder:a,min:o,max:c,step:l,types: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`},min:{type:`string`},max:{type:`string`},step:{type:`string`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a number field to an existing custom type.
|
|
380
390
|
|
|
381
391
|
USAGE
|
|
382
392
|
prismic custom-type add-field number <type-id> <field-id> [flags]
|
|
@@ -392,14 +402,15 @@ FLAGS
|
|
|
392
402
|
--min number Minimum value
|
|
393
403
|
--max number Maximum value
|
|
394
404
|
--step number Step increment
|
|
405
|
+
--types string Output file for generated types (default: "prismicio-types.d.ts")
|
|
395
406
|
-h, --help Show help for command
|
|
396
407
|
|
|
397
408
|
EXAMPLES
|
|
398
409
|
prismic custom-type add-field number homepage price
|
|
399
410
|
prismic custom-type add-field number product quantity --min 0 --max 100
|
|
400
|
-
prismic custom-type add-field number settings rating --min 1 --max 5 --step 1`);return}if(!
|
|
401
|
-
`),console.error(`Usage: prismic custom-type add-field number <type-id> <field-id>`),process.exitCode=1;return}if(!
|
|
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),
|
|
411
|
+
prismic custom-type add-field number settings rating --min 1 --max 5 --step 1`);return}if(!d){console.error(`Missing required argument: type-id
|
|
412
|
+
`),console.error(`Usage: prismic custom-type add-field number <type-id> <field-id>`),process.exitCode=1;return}if(!f){console.error(`Missing required argument: field-id
|
|
413
|
+
`),console.error(`Usage: prismic custom-type add-field number <type-id> <field-id>`),process.exitCode=1;return}let p=W(f),m=q(p);if(!m.ok){console.error(m.error),process.exitCode=1;return}let h=o===void 0?void 0:Number(o),g=c===void 0?void 0:Number(c),_=l===void 0?void 0:Number(l);if(o!==void 0&&Number.isNaN(h)){console.error(`Invalid --min value: must be a number`),process.exitCode=1;return}if(c!==void 0&&Number.isNaN(g)){console.error(`Invalid --max value: must be a number`),process.exitCode=1;return}if(l!==void 0&&Number.isNaN(_)){console.error(`Invalid --step value: must be a number`),process.exitCode=1;return}let v=await V(`package.json`);if(!v){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let y=new URL(`customtypes/${d}/index.json`,v),b;try{let e=await r(y,`utf8`),t=R(gr,JSON.parse(e));if(!t.success){console.error(`Invalid custom type model: ${y.href}`),process.exitCode=1;return}b=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 x=Object.keys(b.json),S=n??x[0]??`Main`;b.json[S]||(b.json[S]={});let ee={type:`Number`,config:{label:i??Y(p.type===`nested`?p.nestedFieldId:f),...a&&{placeholder:a},...h!==void 0&&{min:h},...g!==void 0&&{max:g},..._!==void 0&&{step:_}}};if(p.type===`nested`){let e=K(b.json[S],p.groupId,S);if(!e.ok){console.error(e.error),process.exitCode=1;return}if(e.group.config.fields[p.nestedFieldId]){console.error(`Field "${p.nestedFieldId}" already exists in group "${p.groupId}"`),process.exitCode=1;return}e.group.config.fields[p.nestedFieldId]=ee}else{for(let[e,t]of Object.entries(b.json)){if(t[f]){console.error(`Field "${f}" already exists in tab "${e}"`),process.exitCode=1;return}for(let[n,r]of Object.entries(t))if(G(r)&&r.config.fields[f]){console.error(`Field "${f}" already exists in group "${n}" in tab "${e}"`),process.exitCode=1;return}}b.json[S][f]=ee}try{await s(y,J(b))}catch(e){e instanceof Error?console.error(`Failed to update custom type: ${e.message}`):console.error(`Failed to update custom type`),process.exitCode=1;return}p.type===`nested`?console.info(`Added field "${p.nestedFieldId}" (Number) to group "${p.groupId}" in ${d}`):console.info(`Added field "${f}" (Number) to "${S}" tab in ${d}`);try{await U({output:u}),console.info(`Updated types in ${u??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic custom-type add-field`"),console.info(" Run `prismic status` when done to find next steps")}const vr=N({id:I(),label:I(),repeatable:M(),status:M(),format:I(),json:F(I(),F(I(),L()))});async function yr(){let{values:{help:t,tab:n,label:i,placeholder:a,single:o,multi:c,"allow-target-blank":l,types: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`},single:{type:`string`},multi:{type:`string`},"allow-target-blank":{type:`boolean`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a rich text field to an existing custom type.
|
|
403
414
|
|
|
404
415
|
USAGE
|
|
405
416
|
prismic custom-type add-field rich-text <type-id> <field-id> [flags]
|
|
@@ -415,6 +426,7 @@ FLAGS
|
|
|
415
426
|
--single string Allowed block types for single-line (comma-separated)
|
|
416
427
|
--multi string Allowed block types for multi-line (comma-separated)
|
|
417
428
|
--allow-target-blank Allow opening links in new tab
|
|
429
|
+
--types string Output file for generated types (default: "prismicio-types.d.ts")
|
|
418
430
|
-h, --help Show help for command
|
|
419
431
|
|
|
420
432
|
BLOCK TYPES
|
|
@@ -426,9 +438,9 @@ EXAMPLES
|
|
|
426
438
|
prismic custom-type add-field rich-text homepage body
|
|
427
439
|
prismic custom-type add-field rich-text article content --multi "paragraph,heading2,heading3,strong,em,hyperlink"
|
|
428
440
|
prismic custom-type add-field rich-text page tagline --single "heading1"
|
|
429
|
-
prismic custom-type add-field rich-text blog post --multi "paragraph,strong,em,hyperlink" --allow-target-blank`);return}if(!
|
|
430
|
-
`),console.error(`Usage: prismic custom-type add-field rich-text <type-id> <field-id>`),process.exitCode=1;return}if(!
|
|
431
|
-
`),console.error(`Usage: prismic custom-type add-field rich-text <type-id> <field-id>`),process.exitCode=1;return}let f=await
|
|
441
|
+
prismic custom-type add-field rich-text blog post --multi "paragraph,strong,em,hyperlink" --allow-target-blank`);return}if(!d){console.error(`Missing required argument: type-id
|
|
442
|
+
`),console.error(`Usage: prismic custom-type add-field rich-text <type-id> <field-id>`),process.exitCode=1;return}if(!f){console.error(`Missing required argument: field-id
|
|
443
|
+
`),console.error(`Usage: prismic custom-type add-field rich-text <type-id> <field-id>`),process.exitCode=1;return}let p=W(f),m=q(p);if(!m.ok){console.error(m.error),process.exitCode=1;return}let h=await V(`package.json`);if(!h){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let g=new URL(`customtypes/${d}/index.json`,h),_;try{let e=await r(g,`utf8`),t=R(vr,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: ${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 v=Object.keys(_.json),y=n??v[0]??`Main`;_.json[y]||(_.json[y]={});let b={type:`StructuredText`,config:{label:i??Y(p.type===`nested`?p.nestedFieldId:f),...a&&{placeholder:a},...o&&{single:o},...c&&{multi:c},...l&&{allowTargetBlank:!0}}};if(p.type===`nested`){let e=K(_.json[y],p.groupId,y);if(!e.ok){console.error(e.error),process.exitCode=1;return}if(e.group.config.fields[p.nestedFieldId]){console.error(`Field "${p.nestedFieldId}" already exists in group "${p.groupId}"`),process.exitCode=1;return}e.group.config.fields[p.nestedFieldId]=b}else{for(let[e,t]of Object.entries(_.json)){if(t[f]){console.error(`Field "${f}" already exists in tab "${e}"`),process.exitCode=1;return}for(let[n,r]of Object.entries(t))if(G(r)&&r.config.fields[f]){console.error(`Field "${f}" already exists in group "${n}" in tab "${e}"`),process.exitCode=1;return}}_.json[y][f]=b}try{await s(g,J(_))}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}p.type===`nested`?console.info(`Added field "${p.nestedFieldId}" (StructuredText) to group "${p.groupId}" in ${d}`):console.info(`Added field "${f}" (StructuredText) to "${y}" tab in ${d}`);try{await U({output:u}),console.info(`Updated types in ${u??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic custom-type add-field`"),console.info(" Run `prismic status` when done to find next steps")}const br=N({id:I(),label:I(),repeatable:M(),status:M(),format:I(),json:F(I(),F(I(),L()))});async function xr(){let{values:{help:t,tab:n,label:i,placeholder:a,option:o,default:c,types: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`},option:{type:`string`,multiple:!0},default:{type:`string`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a select (dropdown) field to an existing custom type.
|
|
432
444
|
|
|
433
445
|
USAGE
|
|
434
446
|
prismic custom-type add-field select <type-id> <field-id> [flags]
|
|
@@ -443,14 +455,15 @@ FLAGS
|
|
|
443
455
|
-p, --placeholder string Placeholder text
|
|
444
456
|
--option string Add an option (can be used multiple times)
|
|
445
457
|
--default string Default selected value
|
|
458
|
+
--types string Output file for generated types (default: "prismicio-types.d.ts")
|
|
446
459
|
-h, --help Show help for command
|
|
447
460
|
|
|
448
461
|
EXAMPLES
|
|
449
462
|
prismic custom-type add-field select homepage layout --option "full" --option "sidebar"
|
|
450
463
|
prismic custom-type add-field select product size --option "small" --option "medium" --option "large" --default "medium"
|
|
451
|
-
prismic custom-type add-field select article status --option "draft" --option "published" --label "Status"`);return}if(!
|
|
452
|
-
`),console.error(`Usage: prismic custom-type add-field select <type-id> <field-id>`),process.exitCode=1;return}if(!
|
|
453
|
-
`),console.error(`Usage: prismic custom-type add-field select <type-id> <field-id>`),process.exitCode=1;return}let d=await
|
|
464
|
+
prismic custom-type add-field select article status --option "draft" --option "published" --label "Status"`);return}if(!u){console.error(`Missing required argument: type-id
|
|
465
|
+
`),console.error(`Usage: prismic custom-type add-field select <type-id> <field-id>`),process.exitCode=1;return}if(!d){console.error(`Missing required argument: field-id
|
|
466
|
+
`),console.error(`Usage: prismic custom-type add-field select <type-id> <field-id>`),process.exitCode=1;return}let f=W(d),p=q(f);if(!p.ok){console.error(p.error),process.exitCode=1;return}let m=await V(`package.json`);if(!m){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let h=new URL(`customtypes/${u}/index.json`,m),g;try{let e=await r(h,`utf8`),t=R(br,JSON.parse(e));if(!t.success){console.error(`Invalid custom type model: ${h.href}`),process.exitCode=1;return}g=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 _=Object.keys(g.json),v=n??_[0]??`Main`;g.json[v]||(g.json[v]={});let y={type:`Select`,config:{label:i??Y(f.type===`nested`?f.nestedFieldId:d),...a&&{placeholder:a},...o&&o.length>0&&{options:o},...c&&{default_value:c}}};if(f.type===`nested`){let e=K(g.json[v],f.groupId,v);if(!e.ok){console.error(e.error),process.exitCode=1;return}if(e.group.config.fields[f.nestedFieldId]){console.error(`Field "${f.nestedFieldId}" already exists in group "${f.groupId}"`),process.exitCode=1;return}e.group.config.fields[f.nestedFieldId]=y}else{for(let[e,t]of Object.entries(g.json)){if(t[d]){console.error(`Field "${d}" already exists in tab "${e}"`),process.exitCode=1;return}for(let[n,r]of Object.entries(t))if(G(r)&&r.config.fields[d]){console.error(`Field "${d}" already exists in group "${n}" in tab "${e}"`),process.exitCode=1;return}}g.json[v][d]=y}try{await s(h,J(g))}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}f.type===`nested`?console.info(`Added field "${f.nestedFieldId}" (Select) to group "${f.groupId}" in ${u}`):console.info(`Added field "${d}" (Select) to "${v}" tab in ${u}`);try{await U({output:l}),console.info(`Updated types in ${l??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic custom-type add-field`"),console.info(" Run `prismic status` when done to find next steps")}const Sr=N({id:I(),label:I(),repeatable:M(),status:M(),format:I(),json:F(I(),F(I(),L()))});async function Cr(){let{values:{help:t,tab:n,label:i,placeholder:a,default:o,types: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`},default:{type:`string`},types:{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
467
|
|
|
455
468
|
USAGE
|
|
456
469
|
prismic custom-type add-field timestamp <type-id> <field-id> [flags]
|
|
@@ -464,14 +477,15 @@ FLAGS
|
|
|
464
477
|
-l, --label string Display label for the field (inferred from field-id if omitted)
|
|
465
478
|
-p, --placeholder string Placeholder text
|
|
466
479
|
--default string Default timestamp value (ISO 8601 format)
|
|
480
|
+
--types string Output file for generated types (default: "prismicio-types.d.ts")
|
|
467
481
|
-h, --help Show help for command
|
|
468
482
|
|
|
469
483
|
EXAMPLES
|
|
470
484
|
prismic custom-type add-field timestamp homepage event_time
|
|
471
485
|
prismic custom-type add-field timestamp event start --tab "Schedule"
|
|
472
|
-
prismic custom-type add-field timestamp article published_at --label "Published At"`);return}if(!
|
|
473
|
-
`),console.error(`Usage: prismic custom-type add-field timestamp <type-id> <field-id>`),process.exitCode=1;return}if(!
|
|
474
|
-
`),console.error(`Usage: prismic custom-type add-field timestamp <type-id> <field-id>`),process.exitCode=1;return}let u=await
|
|
486
|
+
prismic custom-type add-field timestamp article published_at --label "Published At"`);return}if(!l){console.error(`Missing required argument: type-id
|
|
487
|
+
`),console.error(`Usage: prismic custom-type add-field timestamp <type-id> <field-id>`),process.exitCode=1;return}if(!u){console.error(`Missing required argument: field-id
|
|
488
|
+
`),console.error(`Usage: prismic custom-type add-field timestamp <type-id> <field-id>`),process.exitCode=1;return}let d=W(u),f=q(d);if(!f.ok){console.error(f.error),process.exitCode=1;return}let p=await V(`package.json`);if(!p){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let m=new URL(`customtypes/${l}/index.json`,p),h;try{let e=await r(m,`utf8`),t=R(Sr,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: ${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 g=Object.keys(h.json),_=n??g[0]??`Main`;h.json[_]||(h.json[_]={});let v={type:`Timestamp`,config:{label:i??Y(d.type===`nested`?d.nestedFieldId:u),...a&&{placeholder:a},...o&&{default:o}}};if(d.type===`nested`){let e=K(h.json[_],d.groupId,_);if(!e.ok){console.error(e.error),process.exitCode=1;return}if(e.group.config.fields[d.nestedFieldId]){console.error(`Field "${d.nestedFieldId}" already exists in group "${d.groupId}"`),process.exitCode=1;return}e.group.config.fields[d.nestedFieldId]=v}else{for(let[e,t]of Object.entries(h.json)){if(t[u]){console.error(`Field "${u}" already exists in tab "${e}"`),process.exitCode=1;return}for(let[n,r]of Object.entries(t))if(G(r)&&r.config.fields[u]){console.error(`Field "${u}" already exists in group "${n}" in tab "${e}"`),process.exitCode=1;return}}h.json[_][u]=v}try{await s(m,J(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}d.type===`nested`?console.info(`Added field "${d.nestedFieldId}" (Timestamp) to group "${d.groupId}" in ${l}`):console.info(`Added field "${u}" (Timestamp) to "${_}" tab in ${l}`);try{await U({output:c}),console.info(`Updated types in ${c??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic custom-type add-field`"),console.info(" Run `prismic status` when done to find next steps")}const wr=N({id:I(),label:I(),repeatable:M(),status:M(),format:I(),json:F(I(),F(I(),L()))});async function Tr(){let{values:{help:t,tab:n,label:i,placeholder:a,types: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`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a UID (unique identifier) field to an existing custom type.
|
|
475
489
|
|
|
476
490
|
USAGE
|
|
477
491
|
prismic custom-type add-field uid <type-id> <field-id> [flags]
|
|
@@ -484,14 +498,15 @@ FLAGS
|
|
|
484
498
|
-t, --tab string Target tab (default: first existing tab, or "Main")
|
|
485
499
|
-l, --label string Display label for the field (inferred from field-id if omitted)
|
|
486
500
|
-p, --placeholder string Placeholder text
|
|
501
|
+
--types string Output file for generated types (default: "prismicio-types.d.ts")
|
|
487
502
|
-h, --help Show help for command
|
|
488
503
|
|
|
489
504
|
EXAMPLES
|
|
490
505
|
prismic custom-type add-field uid page uid
|
|
491
506
|
prismic custom-type add-field uid article slug --label "URL Slug"
|
|
492
|
-
prismic custom-type add-field uid product sku --placeholder "Enter unique SKU"`);return}if(!
|
|
493
|
-
`),console.error(`Usage: prismic custom-type add-field uid <type-id> <field-id>`),process.exitCode=1;return}if(!
|
|
494
|
-
`),console.error(`Usage: prismic custom-type add-field uid <type-id> <field-id>`),process.exitCode=1;return}let l=await
|
|
507
|
+
prismic custom-type add-field uid product sku --placeholder "Enter unique SKU"`);return}if(!c){console.error(`Missing required argument: type-id
|
|
508
|
+
`),console.error(`Usage: prismic custom-type add-field uid <type-id> <field-id>`),process.exitCode=1;return}if(!l){console.error(`Missing required argument: field-id
|
|
509
|
+
`),console.error(`Usage: prismic custom-type add-field uid <type-id> <field-id>`),process.exitCode=1;return}let u=W(l),d=q(u);if(!d.ok){console.error(d.error),process.exitCode=1;return}if(u.type===`nested`){console.error(`UID fields cannot be nested inside groups`),process.exitCode=1;return}let f=await V(`package.json`);if(!f){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let p=new URL(`customtypes/${c}/index.json`,f),m;try{let e=await r(p,`utf8`),t=R(wr,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: ${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 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[l]){console.error(`Field "${l}" already exists in tab "${e}"`),process.exitCode=1;return}let _={type:`UID`,config:{label:i??Y(l),...a&&{placeholder:a}}};m.json[g][l]=_;try{await s(p,J(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 "${l}" (UID) to "${g}" tab in ${c}`);try{await U({output:o}),console.info(`Updated types in ${o??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic custom-type add-field`"),console.info(" Run `prismic status` when done to find next steps")}async function Er(){let{positionals:[t]}=e({args:process.argv.slice(4),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`boolean`:await $n();break;case`color`:await tr();break;case`date`:await rr();break;case`embed`:await ar();break;case`geo-point`:await sr();break;case`group`:await lr();break;case`image`:await dr();break;case`key-text`:await pr();break;case`link`:await hr();break;case`number`:await _r();break;case`rich-text`:await yr();break;case`select`:await xr();break;case`timestamp`:await Cr();break;case`uid`:await Tr();break;default:t&&(console.error(`Unknown field type: ${t}\n`),process.exitCode=1),console.info(`Add a field to an existing custom type.
|
|
495
510
|
|
|
496
511
|
USAGE
|
|
497
512
|
prismic custom-type add-field <field-type> <type-id> <field-id> [flags]
|
|
@@ -502,6 +517,7 @@ FIELD TYPES
|
|
|
502
517
|
date Date picker
|
|
503
518
|
embed Embed (oEmbed)
|
|
504
519
|
geo-point Geographic coordinates
|
|
520
|
+
group Repeatable group of fields
|
|
505
521
|
image Image
|
|
506
522
|
key-text Single-line text
|
|
507
523
|
link Any link type
|
|
@@ -521,7 +537,7 @@ EXAMPLES
|
|
|
521
537
|
prismic custom-type add-field key-text homepage meta_title --tab "SEO"
|
|
522
538
|
prismic custom-type add-field link homepage button --allow-text
|
|
523
539
|
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
|
|
540
|
+
prismic custom-type add-field select homepage layout --option "full" --option "sidebar"`)}}const Dr=N({id:I(),label:I(),repeatable:M(),status:M(),format:I(),json:F(I(),F(I(),L()))});async function Or(){let{values:{help:t,"slice-zone":n,types:i},positionals:[a,o]}=e({args:process.argv.slice(4),options:{"slice-zone":{type:`string`,short:`z`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Connect a shared slice to a custom type's slice zone.
|
|
525
541
|
|
|
526
542
|
USAGE
|
|
527
543
|
prismic custom-type connect-slice <type-id> <slice-id> [flags]
|
|
@@ -532,14 +548,15 @@ ARGUMENTS
|
|
|
532
548
|
|
|
533
549
|
FLAGS
|
|
534
550
|
-z, --slice-zone string Target slice zone field ID (default: "slices")
|
|
551
|
+
--types string Output file for generated types (default: "prismicio-types.d.ts")
|
|
535
552
|
-h, --help Show help for command
|
|
536
553
|
|
|
537
554
|
EXAMPLES
|
|
538
555
|
prismic custom-type connect-slice homepage CallToAction
|
|
539
556
|
prismic custom-type connect-slice homepage CallToAction --slice-zone slices
|
|
540
|
-
prismic custom-type connect-slice article HeroSection -z body`);return}if(!
|
|
541
|
-
`),console.error(`Usage: prismic custom-type connect-slice <type-id> <slice-id>`),process.exitCode=1;return}if(!
|
|
542
|
-
`),console.error(`Usage: prismic custom-type connect-slice <type-id> <slice-id>`),process.exitCode=1;return}let
|
|
557
|
+
prismic custom-type connect-slice article HeroSection -z body`);return}if(!a){console.error(`Missing required argument: type-id
|
|
558
|
+
`),console.error(`Usage: prismic custom-type connect-slice <type-id> <slice-id>`),process.exitCode=1;return}if(!o){console.error(`Missing required argument: slice-id
|
|
559
|
+
`),console.error(`Usage: prismic custom-type connect-slice <type-id> <slice-id>`),process.exitCode=1;return}let c=await H(o);if(!c.ok){console.error(c.error),process.exitCode=1;return}let l=await V(`package.json`);if(!l){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let u=new URL(`customtypes/${a}/index.json`,l),d;try{let e=await r(u,`utf8`),t=R(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: ${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 f=n??`slices`,p,m;for(let[,e]of Object.entries(d.json)){for(let[t,n]of Object.entries(e))if(n.type===`Slices`&&t===f){p=n,m=t;break}if(p)break}if(!p){if(n){console.error(`Slice zone "${n}" not found in custom type "${a}"`),process.exitCode=1;return}let e=Object.keys(d.json)[0]??`Main`;d.json[e]||(d.json[e]={});let t={type:`Slices`,fieldset:`Slice Zone`,config:{choices:{}}};d.json[e][f]=t,p=t,m=f}if(p.config||={choices:{}},p.config.choices||(p.config.choices={}),o in p.config.choices){console.info(`Slice "${o}" is already connected to slice zone "${m}" in ${a}`);return}let h={type:`SharedSlice`};p.config.choices[o]=h;try{await s(u,J(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(`Connected slice "${o}" to slice zone "${m}" in ${a}`);try{await U({output:i}),console.info(`Updated types in ${i??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}}async function kr(){let{values:{help:t,name:r,single:i,types:a},positionals:[o]}=e({args:process.argv.slice(4),options:{name:{type:`string`,short:`n`},single:{type:`boolean`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Create a new custom type in a Prismic repository.
|
|
543
560
|
|
|
544
561
|
USAGE
|
|
545
562
|
prismic custom-type create <id> [flags]
|
|
@@ -550,10 +567,11 @@ ARGUMENTS
|
|
|
550
567
|
FLAGS
|
|
551
568
|
-n, --name string Display name for the custom type
|
|
552
569
|
--single Create as a singleton (non-repeatable) type
|
|
570
|
+
--types string Output file for generated types (default: "prismicio-types.d.ts")
|
|
553
571
|
-h, --help Show help for command
|
|
554
572
|
|
|
555
573
|
LEARN MORE
|
|
556
|
-
Use \`prismic custom-type <command> --help\` for more information about a command.`);return}if(!
|
|
574
|
+
Use \`prismic custom-type <command> --help\` for more information about a command.`);return}if(!o){console.error(`Missing required argument: id`),process.exitCode=1;return}let c={id:o,label:r??Ar(o),repeatable:!i,status:!0,format:`custom`,json:{Main:i?{}:{uid:{type:`UID`,config:{label:`UID`,placeholder:``}}}}},l=await V(`package.json`);if(!l){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let u=new URL(`customtypes/`,l),d=new URL(o+`/`,u),f=new URL(`index.json`,d);try{await n(new URL(`.`,f),{recursive:!0}),await s(f,J(c))}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 ${f.href}`);try{await U({output:a}),console.info(`Updated types in ${a??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add fields with `prismic custom-type add-field`")}function Ar(e){return e.toLowerCase().replace(/(^|[-_\s]+)(.)?/g,(e,t,n)=>n?.toUpperCase()??``)}const jr=N({id:I(),label:I(),repeatable:M(),status:M(),format:I(),json:F(I(),F(I(),L()))});async function Mr(){let{values:{help:t,"slice-zone":n,types:i},positionals:[a,o]}=e({args:process.argv.slice(4),options:{"slice-zone":{type:`string`,short:`z`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Disconnect a shared slice from a custom type's slice zone.
|
|
557
575
|
|
|
558
576
|
USAGE
|
|
559
577
|
prismic custom-type disconnect-slice <type-id> <slice-id> [flags]
|
|
@@ -564,14 +582,15 @@ ARGUMENTS
|
|
|
564
582
|
|
|
565
583
|
FLAGS
|
|
566
584
|
-z, --slice-zone string Target slice zone field ID (default: "slices")
|
|
585
|
+
--types string Output file for generated types (default: "prismicio-types.d.ts")
|
|
567
586
|
-h, --help Show help for command
|
|
568
587
|
|
|
569
588
|
EXAMPLES
|
|
570
589
|
prismic custom-type disconnect-slice homepage CallToAction
|
|
571
590
|
prismic custom-type disconnect-slice homepage CallToAction --slice-zone slices
|
|
572
|
-
prismic custom-type disconnect-slice article HeroSection -z body`);return}if(!
|
|
573
|
-
`),console.error(`Usage: prismic custom-type disconnect-slice <type-id> <slice-id>`),process.exitCode=1;return}if(!
|
|
574
|
-
`),console.error(`Usage: prismic custom-type disconnect-slice <type-id> <slice-id>`),process.exitCode=1;return}let
|
|
591
|
+
prismic custom-type disconnect-slice article HeroSection -z body`);return}if(!a){console.error(`Missing required argument: type-id
|
|
592
|
+
`),console.error(`Usage: prismic custom-type disconnect-slice <type-id> <slice-id>`),process.exitCode=1;return}if(!o){console.error(`Missing required argument: slice-id
|
|
593
|
+
`),console.error(`Usage: prismic custom-type disconnect-slice <type-id> <slice-id>`),process.exitCode=1;return}let c=await V(`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=R(jr,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=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){console.error(`Slice zone "${d}" not found in custom type "${a}"`),process.exitCode=1;return}if(!f.config?.choices||!(o in f.config.choices)){console.error(`Slice "${o}" is not connected to slice zone "${p}" in ${a}`),process.exitCode=1;return}delete f.config.choices[o];try{await s(l,J(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(`Disconnected slice "${o}" from slice zone "${p}" in ${a}`);try{await U({output:i}),console.info(`Updated types in ${i??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}}const Nr=N({id:I(),label:I(),repeatable:M(),status:M(),format:P(I()),json:F(I(),F(I(),L()))});async function Pr(){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
594
|
|
|
576
595
|
USAGE
|
|
577
596
|
prismic custom-type list [flags]
|
|
@@ -582,7 +601,7 @@ FLAGS
|
|
|
582
601
|
|
|
583
602
|
EXAMPLES
|
|
584
603
|
prismic custom-type list
|
|
585
|
-
prismic custom-type list --json`);return}let a=await
|
|
604
|
+
prismic custom-type list --json`);return}let a=await V(`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=R(Nr,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 Fr=N({id:I(),label:I(),repeatable:M(),status:M(),format:P(I()),json:F(I(),F(I(),L()))});async function Ir(){let{values:{help:t,y:n,types:i},positionals:[a]}=e({args:process.argv.slice(4),options:{y:{type:`boolean`,short:`y`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Remove a custom type from the project.
|
|
586
605
|
|
|
587
606
|
USAGE
|
|
588
607
|
prismic custom-type remove <type-id> [flags]
|
|
@@ -592,12 +611,13 @@ ARGUMENTS
|
|
|
592
611
|
|
|
593
612
|
FLAGS
|
|
594
613
|
-y Confirm removal
|
|
614
|
+
--types string Output file for generated types (default: "prismicio-types.d.ts")
|
|
595
615
|
-h, --help Show help for command
|
|
596
616
|
|
|
597
617
|
EXAMPLES
|
|
598
618
|
prismic custom-type remove settings
|
|
599
|
-
prismic custom-type remove settings -y`);return}if(!
|
|
600
|
-
`),console.error(`Usage: prismic custom-type remove <type-id>`),process.exitCode=1;return}let
|
|
619
|
+
prismic custom-type remove settings -y`);return}if(!a){console.error(`Missing required argument: type-id
|
|
620
|
+
`),console.error(`Usage: prismic custom-type remove <type-id>`),process.exitCode=1;return}let s=await V(`package.json`);if(!s){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let c=new URL(`customtypes/${a}/`,s),l=new URL(`index.json`,c),u;try{let e=await r(l,`utf8`),t=R(Fr,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}`),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(u.format===`page`){console.error(`"${a}" is not a custom type (format: page)`),process.exitCode=1;return}if(!n){console.error(`Refusing to remove custom type "${a}" (this will delete the entire directory).`),console.error(`Re-run with -y to confirm.`),process.exitCode=1;return}try{await o(c,{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 "${a}"`);try{await U({output:i}),console.info(`Updated types in ${i??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}}const Lr=N({id:I(),label:I(),repeatable:M(),status:M(),format:P(I()),json:F(I(),F(I(),L()))});async function Rr(){let{values:{help:t,tab:n,types:i},positionals:[a,o]}=e({args:process.argv.slice(4),options:{tab:{type:`string`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Remove a field from a custom type.
|
|
601
621
|
|
|
602
622
|
USAGE
|
|
603
623
|
prismic custom-type remove-field <type-id> <field-id> [flags]
|
|
@@ -608,13 +628,14 @@ ARGUMENTS
|
|
|
608
628
|
|
|
609
629
|
FLAGS
|
|
610
630
|
--tab string Specific tab (searches all tabs if not specified)
|
|
631
|
+
--types string Output file for generated types (default: "prismicio-types.d.ts")
|
|
611
632
|
-h, --help Show help for command
|
|
612
633
|
|
|
613
634
|
EXAMPLES
|
|
614
635
|
prismic custom-type remove-field settings title
|
|
615
|
-
prismic custom-type remove-field settings description --tab "Content"`);return}if(!
|
|
616
|
-
`),console.error(`Usage: prismic custom-type remove-field <type-id> <field-id>`),process.exitCode=1;return}if(!
|
|
617
|
-
`),console.error(`Usage: prismic custom-type remove-field <type-id> <field-id>`),process.exitCode=1;return}let
|
|
636
|
+
prismic custom-type remove-field settings description --tab "Content"`);return}if(!a){console.error(`Missing required argument: type-id
|
|
637
|
+
`),console.error(`Usage: prismic custom-type remove-field <type-id> <field-id>`),process.exitCode=1;return}if(!o){console.error(`Missing required argument: field-id
|
|
638
|
+
`),console.error(`Usage: prismic custom-type remove-field <type-id> <field-id>`),process.exitCode=1;return}let c=await V(`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=R(Lr,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}if(u.format===`page`){console.error(`"${a}" is not a custom type (format: page)`),process.exitCode=1;return}let d;if(n){if(!u.json[n]){console.error(`Tab "${n}" not found in custom type "${a}"`),console.error(`Available tabs: ${Object.keys(u.json).join(`, `)}`),process.exitCode=1;return}if(!(o in u.json[n])){console.error(`Field "${o}" not found in tab "${n}"`),process.exitCode=1;return}delete u.json[n][o],d=n}else{for(let[e,t]of Object.entries(u.json))if(o in t){delete t[o],d=e;break}if(!d){console.error(`Field "${o}" not found in any tab of custom type "${a}"`),process.exitCode=1;return}}try{await s(l,J(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(`Removed field "${o}" from tab "${d}" in custom type "${a}"`);try{await U({output:i}),console.info(`Updated types in ${i??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}}const zr=N({id:I(),label:I(),repeatable:M(),status:M(),format:P(I()),json:F(I(),F(I(),L()))});async function Br(){let{values:{help:t,types:n},positionals:[i,a]}=e({args:process.argv.slice(4),options:{types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Change a custom type's display name (label).
|
|
618
639
|
|
|
619
640
|
USAGE
|
|
620
641
|
prismic custom-type set-name <type-id> <new-name> [flags]
|
|
@@ -624,13 +645,14 @@ ARGUMENTS
|
|
|
624
645
|
new-name New display name (required)
|
|
625
646
|
|
|
626
647
|
FLAGS
|
|
648
|
+
--types string Output file for generated types (default: "prismicio-types.d.ts")
|
|
627
649
|
-h, --help Show help for command
|
|
628
650
|
|
|
629
651
|
EXAMPLES
|
|
630
652
|
prismic custom-type set-name settings "Site Settings"
|
|
631
|
-
prismic custom-type set-name menu "Navigation Menu"`);return}if(!
|
|
632
|
-
`),console.error(`Usage: prismic custom-type set-name <type-id> <new-name>`),process.exitCode=1;return}if(!
|
|
633
|
-
`),console.error(`Usage: prismic custom-type set-name <type-id> <new-name>`),process.exitCode=1;return}let
|
|
653
|
+
prismic custom-type set-name menu "Navigation Menu"`);return}if(!i){console.error(`Missing required argument: type-id
|
|
654
|
+
`),console.error(`Usage: prismic custom-type set-name <type-id> <new-name>`),process.exitCode=1;return}if(!a){console.error(`Missing required argument: new-name
|
|
655
|
+
`),console.error(`Usage: prismic custom-type set-name <type-id> <new-name>`),process.exitCode=1;return}let o=await V(`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=R(zr,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}l.label=a;try{await s(c,J(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(`Renamed custom type "${i}" to "${a}"`);try{await U({output:n}),console.info(`Updated types in ${n??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}}const Vr=N({id:I(),label:I(),repeatable:M(),status:M(),format:P(I()),json:F(I(),F(I(),L()))});async function Hr(){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
656
|
|
|
635
657
|
USAGE
|
|
636
658
|
prismic custom-type view <type-id> [flags]
|
|
@@ -645,7 +667,7 @@ FLAGS
|
|
|
645
667
|
EXAMPLES
|
|
646
668
|
prismic custom-type view settings
|
|
647
669
|
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
|
|
670
|
+
`),console.error(`Usage: prismic custom-type view <type-id>`),process.exitCode=1;return}let a=await V(`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=R(Vr,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 Ur(){let{positionals:[t]}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`create`:await kr();break;case`list`:await Pr();break;case`view`:await Hr();break;case`remove`:await Ir();break;case`set-name`:await Br();break;case`add-field`:await Er();break;case`remove-field`:await Rr();break;case`connect-slice`:await Or();break;case`disconnect-slice`:await Mr();break;default:t&&(console.error(`Unknown custom-type subcommand: ${t}\n`),process.exitCode=1),console.info(`Manage custom types in a Prismic repository.
|
|
649
671
|
|
|
650
672
|
USAGE
|
|
651
673
|
prismic custom-type <command> [flags]
|
|
@@ -665,7 +687,25 @@ FLAGS
|
|
|
665
687
|
-h, --help Show help for command
|
|
666
688
|
|
|
667
689
|
LEARN MORE
|
|
668
|
-
Use \`prismic custom-type <command> --help\` for more information about a command.`)}}
|
|
690
|
+
Use \`prismic custom-type <command> --help\` for more information about a command.`)}}const Wr=`Fetch and display documentation from Prismic's docs site.
|
|
691
|
+
|
|
692
|
+
USAGE
|
|
693
|
+
prismic docs <path> [flags]
|
|
694
|
+
|
|
695
|
+
ARGUMENTS
|
|
696
|
+
path Documentation path with optional anchor (e.g., "nextjs" or "nextjs#set-up-a-prismic-client")
|
|
697
|
+
|
|
698
|
+
FLAGS
|
|
699
|
+
-h, --help Show help for command
|
|
700
|
+
|
|
701
|
+
EXAMPLES
|
|
702
|
+
prismic docs nextjs
|
|
703
|
+
prismic docs nextjs#set-up-a-prismic-client
|
|
704
|
+
|
|
705
|
+
LEARN MORE
|
|
706
|
+
Visit https://prismic.io/docs for the full documentation.`;function Gr(e){let t=e.indexOf(`#`);return t===-1?{path:e}:{path:e.slice(0,t),anchor:e.slice(t+1)}}async function Kr(e){try{let t=await fetch(e);return t.status===404?{ok:!1,error:`Documentation not found: ${e}`}:t.ok?{ok:!0,content:await t.text()}:{ok:!1,error:`Failed to fetch documentation: ${t.status}`}}catch(e){return{ok:!1,error:`Network error: ${e instanceof Error?e.message:String(e)}`}}}function qr(e){let t=e.split(`-`).map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)).join(`[\\s-]+`);return RegExp(`^(#{1,6})\\s+${t}\\s*$`,`im`)}function Jr(e,t){let n=e.split(`
|
|
707
|
+
`),r=qr(t),i=-1,a=0;for(let e=0;e<n.length;e++){let t=n[e].match(r);if(t){i=e,a=t[1].length;break}}if(i===-1)return{ok:!1,error:`Anchor not found: #${t}`};let o=n.length;for(let e=i+1;e<n.length;e++){let t=n[e].match(/^(#{1,6})\s/);if(t&&t[1].length<=a){o=e;break}}return{ok:!0,content:n.slice(i,o).join(`
|
|
708
|
+
`).trim()}}async function Yr(){let{positionals:[t],values:{help:n}}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(n){console.info(Wr);return}if(!t){console.info(Wr);return}let{path:r,anchor:i}=Gr(t),a=await Kr(`https://prismic.io/docs/${r}.md`);if(!a.ok){console.error(a.error),process.exitCode=1;return}let o=a.content;if(i){let e=Jr(o,i);if(!e.ok){console.error(e.error),process.exitCode=1;return}o=e.content}console.info(o)}const Xr=`prismic.config.json`,Zr=N({repositoryName:I(),apiEndpoint:P(bn(I(),pn())),localSliceMachineSimulatorURL:P(bn(I(),pn())),libraries:P(j(I())),adapter:P(I()),labs:P(N({legacySliceUpgrader:P(M())}))});async function Qr(e,t=d(process.cwd())){let n=await ri(t);return n.ok?(await s(n.path,J(e)),{ok:!0,config:e}):n}async function X(e=d(process.cwd())){let t=await $r(e);if(t.ok)return t.config.repositoryName}async function $r(e=d(process.cwd())){let t=await ni(e);if(!t.ok)return t;try{let e=await r(t.path,`utf8`),n=R(Zr,JSON.parse(e));return n.success?{ok:!0,config:n.output}:{ok:!1,error:new ei(n.issues)}}catch{return{ok:!1,error:new ei}}}var ei=class extends Error{issues;constructor(e=[]){super(`prismic.config.json is invalid.`),this.issues=e}};async function ti(e,t=d(process.cwd())){let n=await ni(t);if(!n.ok)return n;let r=await $r(t);if(!r.ok)return r;let i={...r.config,...e};return await s(n.path,J(i)),{ok:!0,config:i}}async function ni(e=d(process.cwd())){let t=await V(Xr,{start:e,stop:`package.json`});return t?{ok:!0,path:t}:{ok:!1,error:new ii}}async function ri(e=d(process.cwd())){let t=await V(`package.json`,{start:e});return t?{ok:!0,path:new URL(Xr,t)}:{ok:!1,error:new ai}}var ii=class extends Error{message=`Could not find a prismic.config.json file.`},ai=class extends Error{message=`Could not find a package.json file.`};async function oi(){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
709
|
|
|
670
710
|
Use this command to connect an existing Prismic repository to your project.
|
|
671
711
|
To create a new repository, use \`prismic repo create\` instead.
|
|
@@ -678,7 +718,7 @@ FLAGS
|
|
|
678
718
|
-h, --help Show help for command
|
|
679
719
|
|
|
680
720
|
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
|
|
721
|
+
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 $r()).ok){console.error(`A prismic.config.json file already exists.`),process.exitCode=1;return}let n=await Qr({repositoryName:t.repo});if(!n.ok){n.error instanceof ai?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 Z(e,t={}){let{credentials:n=`include`}=t,r=new Headers(t.headers);if(r.set(`Accept`,`application/json`),n===`include`){let e=await Dn();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:yn(t.schema,o)}}catch(e){if(A(e))return{ok:!1,value:o,error:e};throw e}}else if(a.status===401)return{ok:!1,value:o,error:new ci(a)};else if(a.status===403)return{ok:!1,value:o,error:new Q(a)};else return{ok:!1,value:o,error:new si(a)}}var si=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 si{},ci=class extends si{};async function li(){let{values:{help:t,name:n,repo:r=await X()},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
722
|
|
|
683
723
|
By default, this command reads the repository from prismic.config.json at the
|
|
684
724
|
project root.
|
|
@@ -695,7 +735,21 @@ FLAGS
|
|
|
695
735
|
-h, --help Show help for command
|
|
696
736
|
|
|
697
737
|
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
|
|
738
|
+
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 B()){fi();return}let a=n?await di(r,i,n):await ui(r,i);if(!a.ok){if(typeof a.value==`string`&&a.value.includes(`already existing languages`))return;a.error instanceof Q?fi():(console.error(`Failed to add locale: ${J(a.value)}`),process.exitCode=1);return}console.info(`Locale added: ${i}`)}async function ui(e,t){return await Z(new URL(`/app/settings/multilanguages`,await z(e)),{method:`POST`,body:{languages:[t]}})}async function di(e,t,n){let[r,i]=t.split(`-`);return await Z(new URL(`/app/settings/multilanguages/custom`,await z(e)),{method:`POST`,body:{lang:{label:n,id:r||t},region:{label:n,id:i||r||t}}})}function fi(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function pi(){let{values:{help:t,repo:n=await X(),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.
|
|
739
|
+
|
|
740
|
+
By default, this command reads the repository from prismic.config.json at the
|
|
741
|
+
project root.
|
|
742
|
+
|
|
743
|
+
USAGE
|
|
744
|
+
prismic locale list [flags]
|
|
745
|
+
|
|
746
|
+
FLAGS
|
|
747
|
+
--json Output as JSON
|
|
748
|
+
-r, --repo string Repository domain
|
|
749
|
+
-h, --help Show help for command
|
|
750
|
+
|
|
751
|
+
LEARN MORE
|
|
752
|
+
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 B()){gi();return}let i=await hi(n);if(!i.ok){i.error instanceof Q?gi():A(i.error)?(console.error(`Failed to list locales: Invalid response: ${J(i.error.issues)}`),process.exitCode=1):(console.error(`Failed to list locales: ${J(i.value)}`),process.exitCode=1);return}let a=i.value.results;if(r)console.info(J(a));else for(let e of a){let t=e.isMaster?` (default)`:``;console.info(`${e.id} ${e.label}${t}`)}}const mi=N({results:j(N({id:I(),label:I(),customName:_n(I()),isMaster:M()}))});async function hi(e){let t=new URL(`/locale/repository/locales`,await xn());return t.searchParams.set(`repository`,e),await Z(t,{schema:mi})}function gi(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function _i(){let{values:{repo:t=await X(),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
753
|
|
|
700
754
|
By default, this command reads the repository from prismic.config.json at the
|
|
701
755
|
project root.
|
|
@@ -711,7 +765,7 @@ FLAGS
|
|
|
711
765
|
-h, --help Show help for command
|
|
712
766
|
|
|
713
767
|
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
|
|
768
|
+
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 B()){yi();return}let i=await vi(t,r);if(!i.ok){i.error instanceof Q?yi():(console.error(`Failed to remove locale: ${J(i.value)}`),process.exitCode=1);return}console.info(`Removed locale: ${r}`)}async function vi(e,t){let n=new URL(`/locale/repository/locales/${t}`,await xn());return n.searchParams.set(`repository`,e),await Z(n,{method:`DELETE`})}function yi(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function bi(){let{values:{help:t,repo:n=await X()},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
769
|
|
|
716
770
|
By default, this command reads the repository from prismic.config.json at the
|
|
717
771
|
project root.
|
|
@@ -727,7 +781,7 @@ FLAGS
|
|
|
727
781
|
-h, --help Show help for command
|
|
728
782
|
|
|
729
783
|
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
|
|
784
|
+
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 B()){Si();return}let i=await hi(n);if(!i.ok){i.error instanceof Q?Si():A(i.error)?(console.error(`Failed to set default locale: Invalid response: ${J(i.error.issues)}`),process.exitCode=1):(console.error(`Failed to set default locale: ${J(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 xi(n,o);if(!s.ok){s.error instanceof Q?Si():(console.error(`Failed to set default locale: ${J(s.value)}`),process.exitCode=1);return}console.info(`Default locale set: ${r}`)}async function xi(e,t){let n=new URL(`/locale/repository/locales`,await xn());return n.searchParams.set(`repository`,e),await Z(n,{method:`POST`,body:{id:t.id,label:t.label,customName:t.customName,isMaster:!0}})}function Si(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function Ci(){let{positionals:[t]}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`add`:await li();break;case`list`:await pi();break;case`remove`:await _i();break;case`set-default`:await bi();break;default:t&&(console.error(`Unknown locale subcommand: ${t}\n`),process.exitCode=1),console.info(`Manage locales in a Prismic repository.
|
|
731
785
|
|
|
732
786
|
USAGE
|
|
733
787
|
prismic locale <command> [flags]
|
|
@@ -742,7 +796,7 @@ FLAGS
|
|
|
742
796
|
-h, --help Show help for command
|
|
743
797
|
|
|
744
798
|
LEARN MORE
|
|
745
|
-
Use \`prismic locale <command> --help\` for more information about a command.`)}}async function
|
|
799
|
+
Use \`prismic locale <command> --help\` for more information about a command.`)}}const wi=`https://prismic.io`;async function Ti(){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
800
|
|
|
747
801
|
USAGE
|
|
748
802
|
prismic login [flags]
|
|
@@ -751,7 +805,7 @@ FLAGS
|
|
|
751
805
|
-h, --help Show help for command
|
|
752
806
|
|
|
753
807
|
LEARN MORE
|
|
754
|
-
Use \`prismic <command> --help\` for more information about a command.`);return}return new Promise((e,t)=>{let n=
|
|
808
|
+
Use \`prismic <command> --help\` for more information about a command.`);return}return new Promise((e,t)=>{let n=p((t,i)=>{if(t.method===`OPTIONS`){i.writeHead(204,{"Access-Control-Allow-Origin":wi,"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":wi,"Content-Type":`application/json`}),i.end(JSON.stringify({error:`Invalid request`}));return}await En(s),console.info(`Logged in to Prismic as ${o}`),i.writeHead(200,{"Access-Control-Allow-Origin":wi,"Content-Type":`application/json`}),i.end(JSON.stringify({success:!0})),clearTimeout(r),n.close(),e()}catch{i.writeHead(400,{"Access-Control-Allow-Origin":wi,"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),i=()=>{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=Ei(i);console.info(`Opening browser to complete login...`),console.info(`If the browser doesn't open, visit: ${a}`),Di(a)};n.on(`error`,e=>{e.code===`EADDRINUSE`&&n.listening===!1?n.listen(0,`0.0.0.0`,i):(clearTimeout(r),t(e))}),n.listen(5555,`0.0.0.0`,i)})}function Ei(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 Di(e){f(`${process.platform===`darwin`?`open`:process.platform===`win32`?`start`:`xdg-open`} "${e.toString()}"`)}async function Oi(){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
809
|
|
|
756
810
|
USAGE
|
|
757
811
|
prismic logout [flags]
|
|
@@ -760,7 +814,7 @@ FLAGS
|
|
|
760
814
|
-h, --help Show help for command
|
|
761
815
|
|
|
762
816
|
LEARN MORE
|
|
763
|
-
Use \`prismic <command> --help\` for more information about a command.`);return}await
|
|
817
|
+
Use \`prismic <command> --help\` for more information about a command.`);return}await An()?console.info(`Logged out of Prismic`):(console.error(`Logout failed. You can log out manually by deleting the file.`),process.exitCode=1)}const ki=N({dependencies:P(F(I(),I())),devDependencies:P(F(I(),I()))});async function $(){let e=await V(`package.json`);if(!e)return;let t=new URL(`.`,e),n;try{let t=await r(e,`utf8`),{dependencies:i={},devDependencies:a={}}=yn(ki,JSON.parse(t)),o={...i,...a};`next`in o?n=`next`:`nuxt`in o?n=`nuxt`:`@sveltejs/kit`in o&&(n=`sveltekit`)}catch{}let i=!1;return n===`next`||n===`sveltekit`?i=await jn(new URL(`src/`,t)):n===`nuxt`&&(i=await jn(new URL(`app/`,t))),{framework:n,hasSrcDir:i,projectRoot:t}}function Ai(e){switch(e){case`next`:return[`@prismicio/client`,`@prismicio/react`,`@prismicio/next`];case`nuxt`:return[`@nuxtjs/prismic`];case`sveltekit`:return[`@prismicio/client`,`@prismicio/svelte`];default:return[`@prismicio/client`]}}function ji(e){switch(e.framework){case`next`:return e.hasSrcDir?`src/prismicio.ts`:`prismicio.ts`;case`nuxt`:return null;case`sveltekit`:return`src/lib/prismicio.ts`;default:return`prismicio.ts`}}function Mi(e){switch(e.framework){case`next`:return e.hasSrcDir?`src/slices/`:`slices/`;case`nuxt`:return e.hasSrcDir?`app/slices/`:`slices/`;case`sveltekit`:return`src/lib/slices/`;default:return`slices/`}}function Ni(e){switch(e){case`next`:return[`.tsx`,`.ts`,`.jsx`,`.js`];case`nuxt`:return[`.vue`];case`sveltekit`:return[`.svelte`];default:return[`.tsx`,`.ts`,`.jsx`,`.js`]}}function Pi(e,t){switch(e.framework){case`next`:{let n=e.hasSrcDir?`src/app`:`app`;return t===`/slice-simulator`?{path:`${n}/slice-simulator/page`,extensions:[`.tsx`,`.ts`,`.jsx`,`.js`]}:t===`/api/preview`?{path:`${n}/api/preview/route`,extensions:[`.ts`,`.js`]}:t===`/api/exit-preview`?{path:`${n}/api/exit-preview/route`,extensions:[`.ts`,`.js`]}:t===`/api/revalidate`?{path:`${n}/api/revalidate/route`,extensions:[`.ts`,`.js`]}:null}case`nuxt`:return t===`/slice-simulator`?{path:`pages/slice-simulator`,extensions:[`.vue`]}:null;case`sveltekit`:return t===`/slice-simulator`?{path:`src/routes/slice-simulator/+page`,extensions:[`.svelte`]}:t===`/api/preview`?{path:`src/routes/api/preview/+server`,extensions:[`.ts`,`.js`]}:null;default:return null}}const Fi=N({id:I(),label:I(),repeatable:M(),status:M(),format:I(),json:F(I(),F(I(),L()))});function Ii(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}async function Li(){let{values:{help:t,tab:n,label:i,default:a,"true-label":o,"false-label":c,types:l},positionals:[u,d]}=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`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a boolean (toggle) field to an existing page type.
|
|
764
818
|
|
|
765
819
|
USAGE
|
|
766
820
|
prismic page-type add-field boolean <type-id> <field-id> [flags]
|
|
@@ -775,14 +829,15 @@ FLAGS
|
|
|
775
829
|
--default Set default value to true
|
|
776
830
|
--true-label string Label shown when toggle is on
|
|
777
831
|
--false-label string Label shown when toggle is off
|
|
832
|
+
--types string Output file for generated types (default: "prismicio-types.d.ts")
|
|
778
833
|
-h, --help Show help for command
|
|
779
834
|
|
|
780
835
|
EXAMPLES
|
|
781
836
|
prismic page-type add-field boolean homepage featured
|
|
782
837
|
prismic page-type add-field boolean article published --default
|
|
783
|
-
prismic page-type add-field boolean product available --true-label "In Stock" --false-label "Out of Stock"`);return}if(!
|
|
784
|
-
`),console.error(`Usage: prismic page-type add-field boolean <type-id> <field-id>`),process.exitCode=1;return}if(!
|
|
785
|
-
`),console.error(`Usage: prismic page-type add-field boolean <type-id> <field-id>`),process.exitCode=1;return}let d=await
|
|
838
|
+
prismic page-type add-field boolean product available --true-label "In Stock" --false-label "Out of Stock"`);return}if(!u){console.error(`Missing required argument: type-id
|
|
839
|
+
`),console.error(`Usage: prismic page-type add-field boolean <type-id> <field-id>`),process.exitCode=1;return}if(!d){console.error(`Missing required argument: field-id
|
|
840
|
+
`),console.error(`Usage: prismic page-type add-field boolean <type-id> <field-id>`),process.exitCode=1;return}let f=W(d),p=q(f);if(!p.ok){console.error(p.error),process.exitCode=1;return}let m=await V(`package.json`);if(!m){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let h=new URL(`customtypes/${u}/index.json`,m),g;try{let e=await r(h,`utf8`),t=R(Fi,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${h.href}`),process.exitCode=1;return}g=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 _=Object.keys(g.json),v=n??_[0]??`Main`;g.json[v]||(g.json[v]={});let y={type:`Boolean`,config:{label:i??Y(f.type===`nested`?f.nestedFieldId:d),...a&&{default_value:!0},...o&&{placeholder_true:o},...c&&{placeholder_false:c}}};if(f.type===`nested`){let e=K(g.json[v],f.groupId,v);if(!e.ok){console.error(e.error),process.exitCode=1;return}if(e.group.config.fields[f.nestedFieldId]){console.error(`Field "${f.nestedFieldId}" already exists in group "${f.groupId}"`),process.exitCode=1;return}e.group.config.fields[f.nestedFieldId]=y}else{for(let[e,t]of Object.entries(g.json)){if(t[d]){console.error(`Field "${d}" already exists in tab "${e}"`),process.exitCode=1;return}for(let[n,r]of Object.entries(t))if(G(r)&&r.config.fields[d]){console.error(`Field "${d}" already exists in group "${n}" in tab "${e}"`),process.exitCode=1;return}}g.json[v][d]=y}try{await s(h,J(g))}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}f.type===`nested`?console.info(`Added field "${f.nestedFieldId}" (Boolean) to group "${f.groupId}" in ${u}`):console.info(`Added field "${d}" (Boolean) to "${v}" tab in ${u}`);try{await U({output:l}),console.info(`Updated types in ${l??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic page-type add-field`");let b=await $();if(b?.framework){let e=Ii(b.framework);console.info(` Run \`prismic docs ${e}#write-page-components\` to learn how to implement a page file`)}}const Ri=N({id:I(),label:I(),repeatable:M(),status:M(),format:I(),json:F(I(),F(I(),L()))});function zi(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}async function Bi(){let{values:{help:t,tab:n,label:i,placeholder:a,types: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`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a color picker field to an existing page type.
|
|
786
841
|
|
|
787
842
|
USAGE
|
|
788
843
|
prismic page-type add-field color <type-id> <field-id> [flags]
|
|
@@ -795,14 +850,15 @@ FLAGS
|
|
|
795
850
|
-t, --tab string Target tab (default: first existing tab, or "Main")
|
|
796
851
|
-l, --label string Display label for the field (inferred from field-id if omitted)
|
|
797
852
|
-p, --placeholder string Placeholder text
|
|
853
|
+
--types string Output file for generated types (default: "prismicio-types.d.ts")
|
|
798
854
|
-h, --help Show help for command
|
|
799
855
|
|
|
800
856
|
EXAMPLES
|
|
801
857
|
prismic page-type add-field color homepage bg_color
|
|
802
858
|
prismic page-type add-field color homepage accent --tab "Design"
|
|
803
|
-
prismic page-type add-field color homepage text_color --label "Text Color"`);return}if(!
|
|
804
|
-
`),console.error(`Usage: prismic page-type add-field color <type-id> <field-id>`),process.exitCode=1;return}if(!
|
|
805
|
-
`),console.error(`Usage: prismic page-type add-field color <type-id> <field-id>`),process.exitCode=1;return}let l=await
|
|
859
|
+
prismic page-type add-field color homepage text_color --label "Text Color"`);return}if(!c){console.error(`Missing required argument: type-id
|
|
860
|
+
`),console.error(`Usage: prismic page-type add-field color <type-id> <field-id>`),process.exitCode=1;return}if(!l){console.error(`Missing required argument: field-id
|
|
861
|
+
`),console.error(`Usage: prismic page-type add-field color <type-id> <field-id>`),process.exitCode=1;return}let u=W(l),d=q(u);if(!d.ok){console.error(d.error),process.exitCode=1;return}let f=await V(`package.json`);if(!f){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let p=new URL(`customtypes/${c}/index.json`,f),m;try{let e=await r(p,`utf8`),t=R(Ri,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: ${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 h=Object.keys(m.json),g=n??h[0]??`Main`;m.json[g]||(m.json[g]={});let _={type:`Color`,config:{label:i??Y(u.type===`nested`?u.nestedFieldId:l),...a&&{placeholder:a}}};if(u.type===`nested`){let e=K(m.json[g],u.groupId,g);if(!e.ok){console.error(e.error),process.exitCode=1;return}if(e.group.config.fields[u.nestedFieldId]){console.error(`Field "${u.nestedFieldId}" already exists in group "${u.groupId}"`),process.exitCode=1;return}e.group.config.fields[u.nestedFieldId]=_}else{for(let[e,t]of Object.entries(m.json)){if(t[l]){console.error(`Field "${l}" already exists in tab "${e}"`),process.exitCode=1;return}for(let[n,r]of Object.entries(t))if(G(r)&&r.config.fields[l]){console.error(`Field "${l}" already exists in group "${n}" in tab "${e}"`),process.exitCode=1;return}}m.json[g][l]=_}try{await s(p,J(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}u.type===`nested`?console.info(`Added field "${u.nestedFieldId}" (Color) to group "${u.groupId}" in ${c}`):console.info(`Added field "${l}" (Color) to "${g}" tab in ${c}`);try{await U({output:o}),console.info(`Updated types in ${o??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic page-type add-field`");let v=await $();if(v?.framework){let e=zi(v.framework);console.info(` Run \`prismic docs ${e}#write-page-components\` to learn how to implement a page file`)}}const Vi=N({id:I(),label:I(),repeatable:M(),status:M(),format:I(),json:F(I(),F(I(),L()))});function Hi(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}async function Ui(){let{values:{help:t,tab:n,label:i,placeholder:a,default:o,types: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`},default:{type:`string`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a date field to an existing page type.
|
|
806
862
|
|
|
807
863
|
USAGE
|
|
808
864
|
prismic page-type add-field date <type-id> <field-id> [flags]
|
|
@@ -816,14 +872,15 @@ FLAGS
|
|
|
816
872
|
-l, --label string Display label for the field (inferred from field-id if omitted)
|
|
817
873
|
-p, --placeholder string Placeholder text
|
|
818
874
|
--default string Default date value (YYYY-MM-DD format)
|
|
875
|
+
--types string Output file for generated types (default: "prismicio-types.d.ts")
|
|
819
876
|
-h, --help Show help for command
|
|
820
877
|
|
|
821
878
|
EXAMPLES
|
|
822
879
|
prismic page-type add-field date homepage publish_date
|
|
823
880
|
prismic page-type add-field date event start_date --tab "Schedule"
|
|
824
|
-
prismic page-type add-field date article date --label "Publication Date" --default "2024-01-01"`);return}if(!
|
|
825
|
-
`),console.error(`Usage: prismic page-type add-field date <type-id> <field-id>`),process.exitCode=1;return}if(!
|
|
826
|
-
`),console.error(`Usage: prismic page-type add-field date <type-id> <field-id>`),process.exitCode=1;return}let u=await
|
|
881
|
+
prismic page-type add-field date article date --label "Publication Date" --default "2024-01-01"`);return}if(!l){console.error(`Missing required argument: type-id
|
|
882
|
+
`),console.error(`Usage: prismic page-type add-field date <type-id> <field-id>`),process.exitCode=1;return}if(!u){console.error(`Missing required argument: field-id
|
|
883
|
+
`),console.error(`Usage: prismic page-type add-field date <type-id> <field-id>`),process.exitCode=1;return}let d=W(u),f=q(d);if(!f.ok){console.error(f.error),process.exitCode=1;return}let p=await V(`package.json`);if(!p){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let m=new URL(`customtypes/${l}/index.json`,p),h;try{let e=await r(m,`utf8`),t=R(Vi,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: ${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 g=Object.keys(h.json),_=n??g[0]??`Main`;h.json[_]||(h.json[_]={});let v={type:`Date`,config:{label:i??Y(d.type===`nested`?d.nestedFieldId:u),...a&&{placeholder:a},...o&&{default:o}}};if(d.type===`nested`){let e=K(h.json[_],d.groupId,_);if(!e.ok){console.error(e.error),process.exitCode=1;return}if(e.group.config.fields[d.nestedFieldId]){console.error(`Field "${d.nestedFieldId}" already exists in group "${d.groupId}"`),process.exitCode=1;return}e.group.config.fields[d.nestedFieldId]=v}else{for(let[e,t]of Object.entries(h.json)){if(t[u]){console.error(`Field "${u}" already exists in tab "${e}"`),process.exitCode=1;return}for(let[n,r]of Object.entries(t))if(G(r)&&r.config.fields[u]){console.error(`Field "${u}" already exists in group "${n}" in tab "${e}"`),process.exitCode=1;return}}h.json[_][u]=v}try{await s(m,J(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}d.type===`nested`?console.info(`Added field "${d.nestedFieldId}" (Date) to group "${d.groupId}" in ${l}`):console.info(`Added field "${u}" (Date) to "${_}" tab in ${l}`);try{await U({output:c}),console.info(`Updated types in ${c??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic page-type add-field`");let y=await $();if(y?.framework){let e=Hi(y.framework);console.info(` Run \`prismic docs ${e}#write-page-components\` to learn how to implement a page file`)}}const Wi=N({id:I(),label:I(),repeatable:M(),status:M(),format:I(),json:F(I(),F(I(),L()))});function Gi(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}async function Ki(){let{values:{help:t,tab:n,label:i,placeholder:a,types: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`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add an embed field to an existing page type.
|
|
827
884
|
|
|
828
885
|
USAGE
|
|
829
886
|
prismic page-type add-field embed <type-id> <field-id> [flags]
|
|
@@ -836,14 +893,15 @@ FLAGS
|
|
|
836
893
|
-t, --tab string Target tab (default: first existing tab, or "Main")
|
|
837
894
|
-l, --label string Display label for the field (inferred from field-id if omitted)
|
|
838
895
|
-p, --placeholder string Placeholder text
|
|
896
|
+
--types string Output file for generated types (default: "prismicio-types.d.ts")
|
|
839
897
|
-h, --help Show help for command
|
|
840
898
|
|
|
841
899
|
EXAMPLES
|
|
842
900
|
prismic page-type add-field embed homepage video
|
|
843
901
|
prismic page-type add-field embed homepage youtube --tab "Media"
|
|
844
|
-
prismic page-type add-field embed homepage media --label "Media Embed"`);return}if(!
|
|
845
|
-
`),console.error(`Usage: prismic page-type add-field embed <type-id> <field-id>`),process.exitCode=1;return}if(!
|
|
846
|
-
`),console.error(`Usage: prismic page-type add-field embed <type-id> <field-id>`),process.exitCode=1;return}let l=await
|
|
902
|
+
prismic page-type add-field embed homepage media --label "Media Embed"`);return}if(!c){console.error(`Missing required argument: type-id
|
|
903
|
+
`),console.error(`Usage: prismic page-type add-field embed <type-id> <field-id>`),process.exitCode=1;return}if(!l){console.error(`Missing required argument: field-id
|
|
904
|
+
`),console.error(`Usage: prismic page-type add-field embed <type-id> <field-id>`),process.exitCode=1;return}let u=W(l),d=q(u);if(!d.ok){console.error(d.error),process.exitCode=1;return}let f=await V(`package.json`);if(!f){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let p=new URL(`customtypes/${c}/index.json`,f),m;try{let e=await r(p,`utf8`),t=R(Wi,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: ${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 h=Object.keys(m.json),g=n??h[0]??`Main`;m.json[g]||(m.json[g]={});let _={type:`Embed`,config:{label:i??Y(u.type===`nested`?u.nestedFieldId:l),...a&&{placeholder:a}}};if(u.type===`nested`){let e=K(m.json[g],u.groupId,g);if(!e.ok){console.error(e.error),process.exitCode=1;return}if(e.group.config.fields[u.nestedFieldId]){console.error(`Field "${u.nestedFieldId}" already exists in group "${u.groupId}"`),process.exitCode=1;return}e.group.config.fields[u.nestedFieldId]=_}else{for(let[e,t]of Object.entries(m.json)){if(t[l]){console.error(`Field "${l}" already exists in tab "${e}"`),process.exitCode=1;return}for(let[n,r]of Object.entries(t))if(G(r)&&r.config.fields[l]){console.error(`Field "${l}" already exists in group "${n}" in tab "${e}"`),process.exitCode=1;return}}m.json[g][l]=_}try{await s(p,J(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}u.type===`nested`?console.info(`Added field "${u.nestedFieldId}" (Embed) to group "${u.groupId}" in ${c}`):console.info(`Added field "${l}" (Embed) to "${g}" tab in ${c}`);try{await U({output:o}),console.info(`Updated types in ${o??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic page-type add-field`");let v=await $();if(v?.framework){let e=Gi(v.framework);console.info(` Run \`prismic docs ${e}#write-page-components\` to learn how to implement a page file`)}}const qi=N({id:I(),label:I(),repeatable:M(),status:M(),format:I(),json:F(I(),F(I(),L()))});function Ji(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}async function Yi(){let{values:{help:t,tab:n,label:i,types:a},positionals:[o,c]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a geo-point (location) field to an existing page type.
|
|
847
905
|
|
|
848
906
|
USAGE
|
|
849
907
|
prismic page-type add-field geo-point <type-id> <field-id> [flags]
|
|
@@ -855,14 +913,36 @@ ARGUMENTS
|
|
|
855
913
|
FLAGS
|
|
856
914
|
-t, --tab string Target tab (default: first existing tab, or "Main")
|
|
857
915
|
-l, --label string Display label for the field (inferred from field-id if omitted)
|
|
916
|
+
--types string Output file for generated types (default: "prismicio-types.d.ts")
|
|
858
917
|
-h, --help Show help for command
|
|
859
918
|
|
|
860
919
|
EXAMPLES
|
|
861
920
|
prismic page-type add-field geo-point homepage location
|
|
862
921
|
prismic page-type add-field geo-point store address --tab "Details"
|
|
863
|
-
prismic page-type add-field geo-point event venue --label "Event Venue"`);return}if(!
|
|
864
|
-
`),console.error(`Usage: prismic page-type add-field geo-point <type-id> <field-id>`),process.exitCode=1;return}if(!
|
|
865
|
-
`),console.error(`Usage: prismic page-type add-field geo-point <type-id> <field-id>`),process.exitCode=1;return}let c=await
|
|
922
|
+
prismic page-type add-field geo-point event venue --label "Event Venue"`);return}if(!o){console.error(`Missing required argument: type-id
|
|
923
|
+
`),console.error(`Usage: prismic page-type add-field geo-point <type-id> <field-id>`),process.exitCode=1;return}if(!c){console.error(`Missing required argument: field-id
|
|
924
|
+
`),console.error(`Usage: prismic page-type add-field geo-point <type-id> <field-id>`),process.exitCode=1;return}let l=W(c),u=q(l);if(!u.ok){console.error(u.error),process.exitCode=1;return}let d=await V(`package.json`);if(!d){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let f=new URL(`customtypes/${o}/index.json`,d),p;try{let e=await r(f,`utf8`),t=R(qi,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: ${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 m=Object.keys(p.json),h=n??m[0]??`Main`;p.json[h]||(p.json[h]={});let g={type:`GeoPoint`,config:{label:i??Y(l.type===`nested`?l.nestedFieldId:c)}};if(l.type===`nested`){let e=K(p.json[h],l.groupId,h);if(!e.ok){console.error(e.error),process.exitCode=1;return}if(e.group.config.fields[l.nestedFieldId]){console.error(`Field "${l.nestedFieldId}" already exists in group "${l.groupId}"`),process.exitCode=1;return}e.group.config.fields[l.nestedFieldId]=g}else{for(let[e,t]of Object.entries(p.json)){if(t[c]){console.error(`Field "${c}" already exists in tab "${e}"`),process.exitCode=1;return}for(let[n,r]of Object.entries(t))if(G(r)&&r.config.fields[c]){console.error(`Field "${c}" already exists in group "${n}" in tab "${e}"`),process.exitCode=1;return}}p.json[h][c]=g}try{await s(f,J(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}l.type===`nested`?console.info(`Added field "${l.nestedFieldId}" (GeoPoint) to group "${l.groupId}" in ${o}`):console.info(`Added field "${c}" (GeoPoint) to "${h}" tab in ${o}`);try{await U({output:a}),console.info(`Updated types in ${a??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic page-type add-field`");let _=await $();if(_?.framework){let e=Ji(_.framework);console.info(` Run \`prismic docs ${e}#write-page-components\` to learn how to implement a page file`)}}const Xi=N({id:I(),label:I(),repeatable:M(),status:M(),format:I(),json:F(I(),F(I(),L()))});function Zi(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}async function Qi(){let{values:{help:t,tab:n,label:i,"non-repeatable":a,types:o},positionals:[c,l]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},"non-repeatable":{type:`boolean`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a group field to an existing page type.
|
|
925
|
+
|
|
926
|
+
USAGE
|
|
927
|
+
prismic page-type add-field group <type-id> <field-id> [flags]
|
|
928
|
+
|
|
929
|
+
ARGUMENTS
|
|
930
|
+
type-id Page type identifier (required)
|
|
931
|
+
field-id Field identifier (required)
|
|
932
|
+
|
|
933
|
+
FLAGS
|
|
934
|
+
-t, --tab string Target tab (default: first existing tab, or "Main")
|
|
935
|
+
-l, --label string Display label for the field (inferred from field-id if omitted)
|
|
936
|
+
--non-repeatable Make this a non-repeating group (default: repeatable)
|
|
937
|
+
--types string Output file for generated types (default: "prismicio-types.d.ts")
|
|
938
|
+
-h, --help Show help for command
|
|
939
|
+
|
|
940
|
+
EXAMPLES
|
|
941
|
+
prismic page-type add-field group homepage buttons
|
|
942
|
+
prismic page-type add-field group article authors --non-repeatable
|
|
943
|
+
prismic page-type add-field group product variants --tab "Content"`);return}if(!c){console.error(`Missing required argument: type-id
|
|
944
|
+
`),console.error(`Usage: prismic page-type add-field group <type-id> <field-id>`),process.exitCode=1;return}if(!l){console.error(`Missing required argument: field-id
|
|
945
|
+
`),console.error(`Usage: prismic page-type add-field group <type-id> <field-id>`),process.exitCode=1;return}if(l.includes(`.`)){console.error(`Groups cannot be nested inside other groups`),process.exitCode=1;return}let u=await V(`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=R(Xi,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:`Group`,config:{label:i??Y(l),repeat:!a,fields:{}}};f.json[m][l]=h;try{await s(d,J(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}" (Group) to "${m}" tab in ${c}`);try{await U({output:o}),console.info(`Updated types in ${o??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info(`Next: Add fields to the group with \`prismic page-type add-field <type> ${c} ${l}.<field-id>\``);let g=await $();if(g?.framework){let e=Zi(g.framework);console.info(` Run \`prismic docs ${e}#write-page-components\` to learn how to implement a page file`)}}const $i=N({id:I(),label:I(),repeatable:M(),status:M(),format:I(),json:F(I(),F(I(),L()))});function ea(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}async function ta(){let{values:{help:t,tab:n,label:i,placeholder:a,types: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`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add an image field to an existing page type.
|
|
866
946
|
|
|
867
947
|
USAGE
|
|
868
948
|
prismic page-type add-field image <type-id> <field-id> [flags]
|
|
@@ -875,14 +955,15 @@ FLAGS
|
|
|
875
955
|
-t, --tab string Target tab (default: first existing tab, or "Main")
|
|
876
956
|
-l, --label string Display label for the field (inferred from field-id if omitted)
|
|
877
957
|
-p, --placeholder string Placeholder text
|
|
958
|
+
--types string Output file for generated types (default: "prismicio-types.d.ts")
|
|
878
959
|
-h, --help Show help for command
|
|
879
960
|
|
|
880
961
|
EXAMPLES
|
|
881
962
|
prismic page-type add-field image homepage hero
|
|
882
963
|
prismic page-type add-field image article thumbnail --tab "Media"
|
|
883
|
-
prismic page-type add-field image product photo --label "Product Photo"`);return}if(!
|
|
884
|
-
`),console.error(`Usage: prismic page-type add-field image <type-id> <field-id>`),process.exitCode=1;return}if(!
|
|
885
|
-
`),console.error(`Usage: prismic page-type add-field image <type-id> <field-id>`),process.exitCode=1;return}let l=await
|
|
964
|
+
prismic page-type add-field image product photo --label "Product Photo"`);return}if(!c){console.error(`Missing required argument: type-id
|
|
965
|
+
`),console.error(`Usage: prismic page-type add-field image <type-id> <field-id>`),process.exitCode=1;return}if(!l){console.error(`Missing required argument: field-id
|
|
966
|
+
`),console.error(`Usage: prismic page-type add-field image <type-id> <field-id>`),process.exitCode=1;return}let u=W(l),d=q(u);if(!d.ok){console.error(d.error),process.exitCode=1;return}let f=await V(`package.json`);if(!f){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let p=new URL(`customtypes/${c}/index.json`,f),m;try{let e=await r(p,`utf8`),t=R($i,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: ${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 h=Object.keys(m.json),g=n??h[0]??`Main`;m.json[g]||(m.json[g]={});let _={type:`Image`,config:{label:i??Y(u.type===`nested`?u.nestedFieldId:l),...a&&{placeholder:a}}};if(u.type===`nested`){let e=K(m.json[g],u.groupId,g);if(!e.ok){console.error(e.error),process.exitCode=1;return}if(e.group.config.fields[u.nestedFieldId]){console.error(`Field "${u.nestedFieldId}" already exists in group "${u.groupId}"`),process.exitCode=1;return}e.group.config.fields[u.nestedFieldId]=_}else{for(let[e,t]of Object.entries(m.json)){if(t[l]){console.error(`Field "${l}" already exists in tab "${e}"`),process.exitCode=1;return}for(let[n,r]of Object.entries(t))if(G(r)&&r.config.fields[l]){console.error(`Field "${l}" already exists in group "${n}" in tab "${e}"`),process.exitCode=1;return}}m.json[g][l]=_}try{await s(p,J(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}u.type===`nested`?console.info(`Added field "${u.nestedFieldId}" (Image) to group "${u.groupId}" in ${c}`):console.info(`Added field "${l}" (Image) to "${g}" tab in ${c}`);try{await U({output:o}),console.info(`Updated types in ${o??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic page-type add-field`");let v=await $();if(v?.framework){let e=ea(v.framework);console.info(` Run \`prismic docs ${e}#write-page-components\` to learn how to implement a page file`)}}const na=N({id:I(),label:I(),repeatable:M(),status:M(),format:I(),json:F(I(),F(I(),L()))});function ra(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}async function ia(){let{values:{help:t,tab:n,label:i,placeholder:a,types: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`},types:{type:`string`},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
967
|
|
|
887
968
|
USAGE
|
|
888
969
|
prismic page-type add-field key-text <type-id> <field-id> [flags]
|
|
@@ -895,14 +976,15 @@ FLAGS
|
|
|
895
976
|
-t, --tab string Target tab (default: first existing tab, or "Main")
|
|
896
977
|
-l, --label string Display label for the field (inferred from field-id if omitted)
|
|
897
978
|
-p, --placeholder string Placeholder text
|
|
979
|
+
--types string Output file for generated types (default: "prismicio-types.d.ts")
|
|
898
980
|
-h, --help Show help for command
|
|
899
981
|
|
|
900
982
|
EXAMPLES
|
|
901
983
|
prismic page-type add-field key-text homepage title
|
|
902
984
|
prismic page-type add-field key-text homepage meta_title --tab "SEO"
|
|
903
|
-
prismic page-type add-field key-text homepage subtitle --label "Subtitle" --placeholder "Enter subtitle"`);return}if(!
|
|
904
|
-
`),console.error(`Usage: prismic page-type add-field key-text <type-id> <field-id>`),process.exitCode=1;return}if(!
|
|
905
|
-
`),console.error(`Usage: prismic page-type add-field key-text <type-id> <field-id>`),process.exitCode=1;return}let l=await
|
|
985
|
+
prismic page-type add-field key-text homepage subtitle --label "Subtitle" --placeholder "Enter subtitle"`);return}if(!c){console.error(`Missing required argument: type-id
|
|
986
|
+
`),console.error(`Usage: prismic page-type add-field key-text <type-id> <field-id>`),process.exitCode=1;return}if(!l){console.error(`Missing required argument: field-id
|
|
987
|
+
`),console.error(`Usage: prismic page-type add-field key-text <type-id> <field-id>`),process.exitCode=1;return}let u=W(l),d=q(u);if(!d.ok){console.error(d.error),process.exitCode=1;return}let f=await V(`package.json`);if(!f){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let p=new URL(`customtypes/${c}/index.json`,f),m;try{let e=await r(p,`utf8`),t=R(na,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: ${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 h=Object.keys(m.json),g=n??h[0]??`Main`;m.json[g]||(m.json[g]={});let _={type:`Text`,config:{label:i??Y(u.type===`nested`?u.nestedFieldId:l),...a&&{placeholder:a}}};if(u.type===`nested`){let e=K(m.json[g],u.groupId,g);if(!e.ok){console.error(e.error),process.exitCode=1;return}if(e.group.config.fields[u.nestedFieldId]){console.error(`Field "${u.nestedFieldId}" already exists in group "${u.groupId}"`),process.exitCode=1;return}e.group.config.fields[u.nestedFieldId]=_}else{for(let[e,t]of Object.entries(m.json)){if(t[l]){console.error(`Field "${l}" already exists in tab "${e}"`),process.exitCode=1;return}for(let[n,r]of Object.entries(t))if(G(r)&&r.config.fields[l]){console.error(`Field "${l}" already exists in group "${n}" in tab "${e}"`),process.exitCode=1;return}}m.json[g][l]=_}try{await s(p,J(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}u.type===`nested`?console.info(`Added field "${u.nestedFieldId}" (Text) to group "${u.groupId}" in ${c}`):console.info(`Added field "${l}" (Text) to "${g}" tab in ${c}`);try{await U({output:o}),console.info(`Updated types in ${o??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic page-type add-field`");let v=await $();if(v?.framework){let e=ra(v.framework);console.info(` Run \`prismic docs ${e}#write-page-components\` to learn how to implement a page file`)}}const aa=N({id:I(),label:I(),repeatable:M(),status:M(),format:I(),json:F(I(),F(I(),L()))});function oa(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}async function sa(){let{values:{help:t,tab:n,label:i,placeholder:a,variation:o,"allow-text":c,"allow-target-blank":l,repeatable:u,types:d},positionals:[f,p]}=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`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a link field to an existing page type.
|
|
906
988
|
|
|
907
989
|
USAGE
|
|
908
990
|
prismic page-type add-field link <type-id> <field-id> [flags]
|
|
@@ -919,15 +1001,16 @@ FLAGS
|
|
|
919
1001
|
--allow-text Allow text with link
|
|
920
1002
|
--allow-target-blank Allow opening link in new tab
|
|
921
1003
|
--repeatable Allow multiple links
|
|
1004
|
+
--types string Output file for generated types (default: "prismicio-types.d.ts")
|
|
922
1005
|
-h, --help Show help for command
|
|
923
1006
|
|
|
924
1007
|
EXAMPLES
|
|
925
1008
|
prismic page-type add-field link homepage button
|
|
926
1009
|
prismic page-type add-field link homepage cta --allow-text
|
|
927
1010
|
prismic page-type add-field link homepage cta --variation Primary --variation Secondary
|
|
928
|
-
prismic page-type add-field link homepage links --repeatable`);return}if(!
|
|
929
|
-
`),console.error(`Usage: prismic page-type add-field link <type-id> <field-id>`),process.exitCode=1;return}if(!
|
|
930
|
-
`),console.error(`Usage: prismic page-type add-field link <type-id> <field-id>`),process.exitCode=1;return}let p=await
|
|
1011
|
+
prismic page-type add-field link homepage links --repeatable`);return}if(!f){console.error(`Missing required argument: type-id
|
|
1012
|
+
`),console.error(`Usage: prismic page-type add-field link <type-id> <field-id>`),process.exitCode=1;return}if(!p){console.error(`Missing required argument: field-id
|
|
1013
|
+
`),console.error(`Usage: prismic page-type add-field link <type-id> <field-id>`),process.exitCode=1;return}let m=W(p),h=q(m);if(!h.ok){console.error(h.error),process.exitCode=1;return}let g=await V(`package.json`);if(!g){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let _=new URL(`customtypes/${f}/index.json`,g),v;try{let e=await r(_,`utf8`),t=R(aa,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${_.href}`),process.exitCode=1;return}v=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${f}\n`),console.error(`Create it first with: prismic page-type create ${f}`),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 y=Object.keys(v.json),b=n??y[0]??`Main`;v.json[b]||(v.json[b]={});let x={type:`Link`,config:{label:i??Y(m.type===`nested`?m.nestedFieldId:p),...a&&{placeholder:a},...o&&o.length>0&&{variants:o},...c&&{allowText:!0},...l&&{allowTargetBlank:!0},...u&&{repeat:!0}}};if(m.type===`nested`){let e=K(v.json[b],m.groupId,b);if(!e.ok){console.error(e.error),process.exitCode=1;return}if(e.group.config.fields[m.nestedFieldId]){console.error(`Field "${m.nestedFieldId}" already exists in group "${m.groupId}"`),process.exitCode=1;return}e.group.config.fields[m.nestedFieldId]=x}else{for(let[e,t]of Object.entries(v.json)){if(t[p]){console.error(`Field "${p}" already exists in tab "${e}"`),process.exitCode=1;return}for(let[n,r]of Object.entries(t))if(G(r)&&r.config.fields[p]){console.error(`Field "${p}" already exists in group "${n}" in tab "${e}"`),process.exitCode=1;return}}v.json[b][p]=x}try{await s(_,J(v))}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}m.type===`nested`?console.info(`Added field "${m.nestedFieldId}" (Link) to group "${m.groupId}" in ${f}`):console.info(`Added field "${p}" (Link) to "${b}" tab in ${f}`);try{await U({output:d}),console.info(`Updated types in ${d??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic page-type add-field`");let S=await $();if(S?.framework){let e=oa(S.framework);console.info(` Run \`prismic docs ${e}#write-page-components\` to learn how to implement a page file`)}}const ca=N({id:I(),label:I(),repeatable:M(),status:M(),format:I(),json:F(I(),F(I(),L()))});function la(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}async function ua(){let{values:{help:t,tab:n,label:i,placeholder:a,min:o,max:c,step:l,types: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`},min:{type:`string`},max:{type:`string`},step:{type:`string`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a number field to an existing page type.
|
|
931
1014
|
|
|
932
1015
|
USAGE
|
|
933
1016
|
prismic page-type add-field number <type-id> <field-id> [flags]
|
|
@@ -943,14 +1026,15 @@ FLAGS
|
|
|
943
1026
|
--min number Minimum value
|
|
944
1027
|
--max number Maximum value
|
|
945
1028
|
--step number Step increment
|
|
1029
|
+
--types string Output file for generated types (default: "prismicio-types.d.ts")
|
|
946
1030
|
-h, --help Show help for command
|
|
947
1031
|
|
|
948
1032
|
EXAMPLES
|
|
949
1033
|
prismic page-type add-field number homepage price
|
|
950
1034
|
prismic page-type add-field number product quantity --min 0 --max 100
|
|
951
|
-
prismic page-type add-field number settings rating --min 1 --max 5 --step 1`);return}if(!
|
|
952
|
-
`),console.error(`Usage: prismic page-type add-field number <type-id> <field-id>`),process.exitCode=1;return}if(!
|
|
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),
|
|
1035
|
+
prismic page-type add-field number settings rating --min 1 --max 5 --step 1`);return}if(!d){console.error(`Missing required argument: type-id
|
|
1036
|
+
`),console.error(`Usage: prismic page-type add-field number <type-id> <field-id>`),process.exitCode=1;return}if(!f){console.error(`Missing required argument: field-id
|
|
1037
|
+
`),console.error(`Usage: prismic page-type add-field number <type-id> <field-id>`),process.exitCode=1;return}let p=W(f),m=q(p);if(!m.ok){console.error(m.error),process.exitCode=1;return}let h=o===void 0?void 0:Number(o),g=c===void 0?void 0:Number(c),_=l===void 0?void 0:Number(l);if(o!==void 0&&Number.isNaN(h)){console.error(`Invalid --min value: must be a number`),process.exitCode=1;return}if(c!==void 0&&Number.isNaN(g)){console.error(`Invalid --max value: must be a number`),process.exitCode=1;return}if(l!==void 0&&Number.isNaN(_)){console.error(`Invalid --step value: must be a number`),process.exitCode=1;return}let v=await V(`package.json`);if(!v){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let y=new URL(`customtypes/${d}/index.json`,v),b;try{let e=await r(y,`utf8`),t=R(ca,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${y.href}`),process.exitCode=1;return}b=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 x=Object.keys(b.json),S=n??x[0]??`Main`;b.json[S]||(b.json[S]={});let ee={type:`Number`,config:{label:i??Y(p.type===`nested`?p.nestedFieldId:f),...a&&{placeholder:a},...h!==void 0&&{min:h},...g!==void 0&&{max:g},..._!==void 0&&{step:_}}};if(p.type===`nested`){let e=K(b.json[S],p.groupId,S);if(!e.ok){console.error(e.error),process.exitCode=1;return}if(e.group.config.fields[p.nestedFieldId]){console.error(`Field "${p.nestedFieldId}" already exists in group "${p.groupId}"`),process.exitCode=1;return}e.group.config.fields[p.nestedFieldId]=ee}else{for(let[e,t]of Object.entries(b.json)){if(t[f]){console.error(`Field "${f}" already exists in tab "${e}"`),process.exitCode=1;return}for(let[n,r]of Object.entries(t))if(G(r)&&r.config.fields[f]){console.error(`Field "${f}" already exists in group "${n}" in tab "${e}"`),process.exitCode=1;return}}b.json[S][f]=ee}try{await s(y,J(b))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}p.type===`nested`?console.info(`Added field "${p.nestedFieldId}" (Number) to group "${p.groupId}" in ${d}`):console.info(`Added field "${f}" (Number) to "${S}" tab in ${d}`);try{await U({output:u}),console.info(`Updated types in ${u??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic page-type add-field`");let te=await $();if(te?.framework){let e=la(te.framework);console.info(` Run \`prismic docs ${e}#write-page-components\` to learn how to implement a page file`)}}const da=N({id:I(),label:I(),repeatable:M(),status:M(),format:I(),json:F(I(),F(I(),L()))});function fa(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}async function pa(){let{values:{help:t,tab:n,label:i,placeholder:a,single:o,multi:c,"allow-target-blank":l,types: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`},single:{type:`string`},multi:{type:`string`},"allow-target-blank":{type:`boolean`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a rich text field to an existing page type.
|
|
954
1038
|
|
|
955
1039
|
USAGE
|
|
956
1040
|
prismic page-type add-field rich-text <type-id> <field-id> [flags]
|
|
@@ -966,6 +1050,7 @@ FLAGS
|
|
|
966
1050
|
--single string Allowed block types for single-line (comma-separated)
|
|
967
1051
|
--multi string Allowed block types for multi-line (comma-separated)
|
|
968
1052
|
--allow-target-blank Allow opening links in new tab
|
|
1053
|
+
--types string Output file for generated types (default: "prismicio-types.d.ts")
|
|
969
1054
|
-h, --help Show help for command
|
|
970
1055
|
|
|
971
1056
|
BLOCK TYPES
|
|
@@ -977,9 +1062,9 @@ EXAMPLES
|
|
|
977
1062
|
prismic page-type add-field rich-text homepage body
|
|
978
1063
|
prismic page-type add-field rich-text article content --multi "paragraph,heading2,heading3,strong,em,hyperlink"
|
|
979
1064
|
prismic page-type add-field rich-text page tagline --single "heading1"
|
|
980
|
-
prismic page-type add-field rich-text blog post --multi "paragraph,strong,em,hyperlink" --allow-target-blank`);return}if(!
|
|
981
|
-
`),console.error(`Usage: prismic page-type add-field rich-text <type-id> <field-id>`),process.exitCode=1;return}if(!
|
|
982
|
-
`),console.error(`Usage: prismic page-type add-field rich-text <type-id> <field-id>`),process.exitCode=1;return}let f=await
|
|
1065
|
+
prismic page-type add-field rich-text blog post --multi "paragraph,strong,em,hyperlink" --allow-target-blank`);return}if(!d){console.error(`Missing required argument: type-id
|
|
1066
|
+
`),console.error(`Usage: prismic page-type add-field rich-text <type-id> <field-id>`),process.exitCode=1;return}if(!f){console.error(`Missing required argument: field-id
|
|
1067
|
+
`),console.error(`Usage: prismic page-type add-field rich-text <type-id> <field-id>`),process.exitCode=1;return}let p=W(f),m=q(p);if(!m.ok){console.error(m.error),process.exitCode=1;return}let h=await V(`package.json`);if(!h){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let g=new URL(`customtypes/${d}/index.json`,h),_;try{let e=await r(g,`utf8`),t=R(da,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: ${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 v=Object.keys(_.json),y=n??v[0]??`Main`;_.json[y]||(_.json[y]={});let b={type:`StructuredText`,config:{label:i??Y(p.type===`nested`?p.nestedFieldId:f),...a&&{placeholder:a},...o&&{single:o},...c&&{multi:c},...l&&{allowTargetBlank:!0}}};if(p.type===`nested`){let e=K(_.json[y],p.groupId,y);if(!e.ok){console.error(e.error),process.exitCode=1;return}if(e.group.config.fields[p.nestedFieldId]){console.error(`Field "${p.nestedFieldId}" already exists in group "${p.groupId}"`),process.exitCode=1;return}e.group.config.fields[p.nestedFieldId]=b}else{for(let[e,t]of Object.entries(_.json)){if(t[f]){console.error(`Field "${f}" already exists in tab "${e}"`),process.exitCode=1;return}for(let[n,r]of Object.entries(t))if(G(r)&&r.config.fields[f]){console.error(`Field "${f}" already exists in group "${n}" in tab "${e}"`),process.exitCode=1;return}}_.json[y][f]=b}try{await s(g,J(_))}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}p.type===`nested`?console.info(`Added field "${p.nestedFieldId}" (StructuredText) to group "${p.groupId}" in ${d}`):console.info(`Added field "${f}" (StructuredText) to "${y}" tab in ${d}`);try{await U({output:u}),console.info(`Updated types in ${u??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic page-type add-field`");let x=await $();if(x?.framework){let e=fa(x.framework);console.info(` Run \`prismic docs ${e}#write-page-components\` to learn how to implement a page file`)}}const ma=N({id:I(),label:I(),repeatable:M(),status:M(),format:I(),json:F(I(),F(I(),L()))});function ha(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}async function ga(){let{values:{help:t,tab:n,label:i,placeholder:a,option:o,default:c,types: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`},option:{type:`string`,multiple:!0},default:{type:`string`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a select (dropdown) field to an existing page type.
|
|
983
1068
|
|
|
984
1069
|
USAGE
|
|
985
1070
|
prismic page-type add-field select <type-id> <field-id> [flags]
|
|
@@ -994,14 +1079,15 @@ FLAGS
|
|
|
994
1079
|
-p, --placeholder string Placeholder text
|
|
995
1080
|
--option string Add an option (can be used multiple times)
|
|
996
1081
|
--default string Default selected value
|
|
1082
|
+
--types string Output file for generated types (default: "prismicio-types.d.ts")
|
|
997
1083
|
-h, --help Show help for command
|
|
998
1084
|
|
|
999
1085
|
EXAMPLES
|
|
1000
1086
|
prismic page-type add-field select homepage layout --option "full" --option "sidebar"
|
|
1001
1087
|
prismic page-type add-field select product size --option "small" --option "medium" --option "large" --default "medium"
|
|
1002
|
-
prismic page-type add-field select article status --option "draft" --option "published" --label "Status"`);return}if(!
|
|
1003
|
-
`),console.error(`Usage: prismic page-type add-field select <type-id> <field-id>`),process.exitCode=1;return}if(!
|
|
1004
|
-
`),console.error(`Usage: prismic page-type add-field select <type-id> <field-id>`),process.exitCode=1;return}let d=await
|
|
1088
|
+
prismic page-type add-field select article status --option "draft" --option "published" --label "Status"`);return}if(!u){console.error(`Missing required argument: type-id
|
|
1089
|
+
`),console.error(`Usage: prismic page-type add-field select <type-id> <field-id>`),process.exitCode=1;return}if(!d){console.error(`Missing required argument: field-id
|
|
1090
|
+
`),console.error(`Usage: prismic page-type add-field select <type-id> <field-id>`),process.exitCode=1;return}let f=W(d),p=q(f);if(!p.ok){console.error(p.error),process.exitCode=1;return}let m=await V(`package.json`);if(!m){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let h=new URL(`customtypes/${u}/index.json`,m),g;try{let e=await r(h,`utf8`),t=R(ma,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${h.href}`),process.exitCode=1;return}g=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 _=Object.keys(g.json),v=n??_[0]??`Main`;g.json[v]||(g.json[v]={});let y={type:`Select`,config:{label:i??Y(f.type===`nested`?f.nestedFieldId:d),...a&&{placeholder:a},...o&&o.length>0&&{options:o},...c&&{default_value:c}}};if(f.type===`nested`){let e=K(g.json[v],f.groupId,v);if(!e.ok){console.error(e.error),process.exitCode=1;return}if(e.group.config.fields[f.nestedFieldId]){console.error(`Field "${f.nestedFieldId}" already exists in group "${f.groupId}"`),process.exitCode=1;return}e.group.config.fields[f.nestedFieldId]=y}else{for(let[e,t]of Object.entries(g.json)){if(t[d]){console.error(`Field "${d}" already exists in tab "${e}"`),process.exitCode=1;return}for(let[n,r]of Object.entries(t))if(G(r)&&r.config.fields[d]){console.error(`Field "${d}" already exists in group "${n}" in tab "${e}"`),process.exitCode=1;return}}g.json[v][d]=y}try{await s(h,J(g))}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}f.type===`nested`?console.info(`Added field "${f.nestedFieldId}" (Select) to group "${f.groupId}" in ${u}`):console.info(`Added field "${d}" (Select) to "${v}" tab in ${u}`);try{await U({output:l}),console.info(`Updated types in ${l??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic page-type add-field`");let b=await $();if(b?.framework){let e=ha(b.framework);console.info(` Run \`prismic docs ${e}#write-page-components\` to learn how to implement a page file`)}}const _a=N({id:I(),label:I(),repeatable:M(),status:M(),format:I(),json:F(I(),F(I(),L()))});function va(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}async function ya(){let{values:{help:t,tab:n,label:i,placeholder:a,default:o,types: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`},default:{type:`string`},types:{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
1091
|
|
|
1006
1092
|
USAGE
|
|
1007
1093
|
prismic page-type add-field timestamp <type-id> <field-id> [flags]
|
|
@@ -1015,14 +1101,15 @@ FLAGS
|
|
|
1015
1101
|
-l, --label string Display label for the field (inferred from field-id if omitted)
|
|
1016
1102
|
-p, --placeholder string Placeholder text
|
|
1017
1103
|
--default string Default timestamp value (ISO 8601 format)
|
|
1104
|
+
--types string Output file for generated types (default: "prismicio-types.d.ts")
|
|
1018
1105
|
-h, --help Show help for command
|
|
1019
1106
|
|
|
1020
1107
|
EXAMPLES
|
|
1021
1108
|
prismic page-type add-field timestamp homepage event_time
|
|
1022
1109
|
prismic page-type add-field timestamp event start --tab "Schedule"
|
|
1023
|
-
prismic page-type add-field timestamp article published_at --label "Published At"`);return}if(!
|
|
1024
|
-
`),console.error(`Usage: prismic page-type add-field timestamp <type-id> <field-id>`),process.exitCode=1;return}if(!
|
|
1025
|
-
`),console.error(`Usage: prismic page-type add-field timestamp <type-id> <field-id>`),process.exitCode=1;return}let u=await
|
|
1110
|
+
prismic page-type add-field timestamp article published_at --label "Published At"`);return}if(!l){console.error(`Missing required argument: type-id
|
|
1111
|
+
`),console.error(`Usage: prismic page-type add-field timestamp <type-id> <field-id>`),process.exitCode=1;return}if(!u){console.error(`Missing required argument: field-id
|
|
1112
|
+
`),console.error(`Usage: prismic page-type add-field timestamp <type-id> <field-id>`),process.exitCode=1;return}let d=W(u),f=q(d);if(!f.ok){console.error(f.error),process.exitCode=1;return}let p=await V(`package.json`);if(!p){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let m=new URL(`customtypes/${l}/index.json`,p),h;try{let e=await r(m,`utf8`),t=R(_a,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: ${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 g=Object.keys(h.json),_=n??g[0]??`Main`;h.json[_]||(h.json[_]={});let v={type:`Timestamp`,config:{label:i??Y(d.type===`nested`?d.nestedFieldId:u),...a&&{placeholder:a},...o&&{default:o}}};if(d.type===`nested`){let e=K(h.json[_],d.groupId,_);if(!e.ok){console.error(e.error),process.exitCode=1;return}if(e.group.config.fields[d.nestedFieldId]){console.error(`Field "${d.nestedFieldId}" already exists in group "${d.groupId}"`),process.exitCode=1;return}e.group.config.fields[d.nestedFieldId]=v}else{for(let[e,t]of Object.entries(h.json)){if(t[u]){console.error(`Field "${u}" already exists in tab "${e}"`),process.exitCode=1;return}for(let[n,r]of Object.entries(t))if(G(r)&&r.config.fields[u]){console.error(`Field "${u}" already exists in group "${n}" in tab "${e}"`),process.exitCode=1;return}}h.json[_][u]=v}try{await s(m,J(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}d.type===`nested`?console.info(`Added field "${d.nestedFieldId}" (Timestamp) to group "${d.groupId}" in ${l}`):console.info(`Added field "${u}" (Timestamp) to "${_}" tab in ${l}`);try{await U({output:c}),console.info(`Updated types in ${c??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic page-type add-field`");let y=await $();if(y?.framework){let e=va(y.framework);console.info(` Run \`prismic docs ${e}#write-page-components\` to learn how to implement a page file`)}}const ba=N({id:I(),label:I(),repeatable:M(),status:M(),format:I(),json:F(I(),F(I(),L()))});function xa(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}async function Sa(){let{values:{help:t,tab:n,label:i,placeholder:a,types: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`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a UID (unique identifier) field to an existing page type.
|
|
1026
1113
|
|
|
1027
1114
|
USAGE
|
|
1028
1115
|
prismic page-type add-field uid <type-id> <field-id> [flags]
|
|
@@ -1035,14 +1122,15 @@ FLAGS
|
|
|
1035
1122
|
-t, --tab string Target tab (default: first existing tab, or "Main")
|
|
1036
1123
|
-l, --label string Display label for the field (inferred from field-id if omitted)
|
|
1037
1124
|
-p, --placeholder string Placeholder text
|
|
1125
|
+
--types string Output file for generated types (default: "prismicio-types.d.ts")
|
|
1038
1126
|
-h, --help Show help for command
|
|
1039
1127
|
|
|
1040
1128
|
EXAMPLES
|
|
1041
1129
|
prismic page-type add-field uid page uid
|
|
1042
1130
|
prismic page-type add-field uid article slug --label "URL Slug"
|
|
1043
|
-
prismic page-type add-field uid product sku --placeholder "Enter unique SKU"`);return}if(!
|
|
1044
|
-
`),console.error(`Usage: prismic page-type add-field uid <type-id> <field-id>`),process.exitCode=1;return}if(!
|
|
1045
|
-
`),console.error(`Usage: prismic page-type add-field uid <type-id> <field-id>`),process.exitCode=1;return}let l=await
|
|
1131
|
+
prismic page-type add-field uid product sku --placeholder "Enter unique SKU"`);return}if(!c){console.error(`Missing required argument: type-id
|
|
1132
|
+
`),console.error(`Usage: prismic page-type add-field uid <type-id> <field-id>`),process.exitCode=1;return}if(!l){console.error(`Missing required argument: field-id
|
|
1133
|
+
`),console.error(`Usage: prismic page-type add-field uid <type-id> <field-id>`),process.exitCode=1;return}let u=W(l),d=q(u);if(!d.ok){console.error(d.error),process.exitCode=1;return}if(u.type===`nested`){console.error(`UID fields cannot be nested inside groups`),process.exitCode=1;return}let f=await V(`package.json`);if(!f){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let p=new URL(`customtypes/${c}/index.json`,f),m;try{let e=await r(p,`utf8`),t=R(ba,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: ${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 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[l]){console.error(`Field "${l}" already exists in tab "${e}"`),process.exitCode=1;return}let _={type:`UID`,config:{label:i??Y(l),...a&&{placeholder:a}}};m.json[g][l]=_;try{await s(p,J(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 "${l}" (UID) to "${g}" tab in ${c}`);try{await U({output:o}),console.info(`Updated types in ${o??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic page-type add-field`");let v=await $();if(v?.framework){let e=xa(v.framework);console.info(` Run \`prismic docs ${e}#write-page-components\` to learn how to implement a page file`)}}async function Ca(){let{positionals:[t]}=e({args:process.argv.slice(4),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`boolean`:await Li();break;case`color`:await Bi();break;case`date`:await Ui();break;case`embed`:await Ki();break;case`geo-point`:await Yi();break;case`group`:await Qi();break;case`image`:await ta();break;case`key-text`:await ia();break;case`link`:await sa();break;case`number`:await ua();break;case`rich-text`:await pa();break;case`select`:await ga();break;case`timestamp`:await ya();break;case`uid`:await Sa();break;default:t&&(console.error(`Unknown field type: ${t}\n`),process.exitCode=1),console.info(`Add a field to an existing page type.
|
|
1046
1134
|
|
|
1047
1135
|
USAGE
|
|
1048
1136
|
prismic page-type add-field <field-type> <type-id> <field-id> [flags]
|
|
@@ -1053,6 +1141,7 @@ FIELD TYPES
|
|
|
1053
1141
|
date Date picker
|
|
1054
1142
|
embed Embed (oEmbed)
|
|
1055
1143
|
geo-point Geographic coordinates
|
|
1144
|
+
group Repeatable group of fields
|
|
1056
1145
|
image Image
|
|
1057
1146
|
key-text Single-line text
|
|
1058
1147
|
link Any link type
|
|
@@ -1072,7 +1161,7 @@ EXAMPLES
|
|
|
1072
1161
|
prismic page-type add-field key-text homepage meta_title --tab "SEO"
|
|
1073
1162
|
prismic page-type add-field link homepage button --allow-text
|
|
1074
1163
|
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
|
|
1164
|
+
prismic page-type add-field select homepage layout --option "full" --option "sidebar"`)}}const wa=N({id:I(),label:I(),repeatable:M(),status:M(),format:I(),json:F(I(),F(I(),L()))});async function Ta(){let{values:{help:t,"slice-zone":n,types:i},positionals:[a,o]}=e({args:process.argv.slice(4),options:{"slice-zone":{type:`string`,short:`z`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Connect a shared slice to a page type's slice zone.
|
|
1076
1165
|
|
|
1077
1166
|
USAGE
|
|
1078
1167
|
prismic page-type connect-slice <type-id> <slice-id> [flags]
|
|
@@ -1083,14 +1172,15 @@ ARGUMENTS
|
|
|
1083
1172
|
|
|
1084
1173
|
FLAGS
|
|
1085
1174
|
-z, --slice-zone string Target slice zone field ID (default: "slices")
|
|
1175
|
+
--types string Output file for generated types (default: "prismicio-types.d.ts")
|
|
1086
1176
|
-h, --help Show help for command
|
|
1087
1177
|
|
|
1088
1178
|
EXAMPLES
|
|
1089
1179
|
prismic page-type connect-slice homepage CallToAction
|
|
1090
1180
|
prismic page-type connect-slice homepage CallToAction --slice-zone slices
|
|
1091
|
-
prismic page-type connect-slice article HeroSection -z body`);return}if(!
|
|
1092
|
-
`),console.error(`Usage: prismic page-type connect-slice <type-id> <slice-id>`),process.exitCode=1;return}if(!
|
|
1093
|
-
`),console.error(`Usage: prismic page-type connect-slice <type-id> <slice-id>`),process.exitCode=1;return}let
|
|
1181
|
+
prismic page-type connect-slice article HeroSection -z body`);return}if(!a){console.error(`Missing required argument: type-id
|
|
1182
|
+
`),console.error(`Usage: prismic page-type connect-slice <type-id> <slice-id>`),process.exitCode=1;return}if(!o){console.error(`Missing required argument: slice-id
|
|
1183
|
+
`),console.error(`Usage: prismic page-type connect-slice <type-id> <slice-id>`),process.exitCode=1;return}let c=await H(o);if(!c.ok){console.error(c.error),process.exitCode=1;return}let l=await V(`package.json`);if(!l){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let u=new URL(`customtypes/${a}/index.json`,l),d;try{let e=await r(u,`utf8`),t=R(wa,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: ${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 f=n??`slices`,p,m;for(let[,e]of Object.entries(d.json)){for(let[t,n]of Object.entries(e))if(n.type===`Slices`&&t===f){p=n,m=t;break}if(p)break}if(!p){if(n){console.error(`Slice zone "${n}" not found in page type "${a}"`),process.exitCode=1;return}let e=Object.keys(d.json)[0]??`Main`;d.json[e]||(d.json[e]={});let t={type:`Slices`,fieldset:`Slice Zone`,config:{choices:{}}};d.json[e][f]=t,p=t,m=f}if(p.config||={choices:{}},p.config.choices||(p.config.choices={}),o in p.config.choices){console.info(`Slice "${o}" is already connected to slice zone "${m}" in ${a}`);return}let h={type:`SharedSlice`};p.config.choices[o]=h;try{await s(u,J(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(`Connected slice "${o}" to slice zone "${m}" in ${a}`);try{await U({output:i}),console.info(`Updated types in ${i??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}}function Ea(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}function Da(e){return`#write-page-components`}async function Oa(){let{values:{help:t,name:r,single:i,types:a},positionals:[o]}=e({args:process.argv.slice(4),options:{name:{type:`string`,short:`n`},single:{type:`boolean`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Create a new page type in a Prismic repository.
|
|
1094
1184
|
|
|
1095
1185
|
USAGE
|
|
1096
1186
|
prismic page-type create <id> [flags]
|
|
@@ -1101,10 +1191,11 @@ ARGUMENTS
|
|
|
1101
1191
|
FLAGS
|
|
1102
1192
|
-n, --name string Display name for the page type
|
|
1103
1193
|
--single Create as a singleton (non-repeatable) type
|
|
1194
|
+
--types string Output file for generated types (default: "prismicio-types.d.ts")
|
|
1104
1195
|
-h, --help Show help for command
|
|
1105
1196
|
|
|
1106
1197
|
LEARN MORE
|
|
1107
|
-
Use \`prismic page-type <command> --help\` for more information about a command.`);return}if(!
|
|
1198
|
+
Use \`prismic page-type <command> --help\` for more information about a command.`);return}if(!o){console.error(`Missing required argument: id`),process.exitCode=1;return}let c={id:o,label:r??ka(o),repeatable:!i,status:!0,format:`page`,json:{Main:i?{}:{uid:{type:`UID`,config:{label:`UID`,placeholder:``}}},"SEO & Metadata":{meta_title:{type:`Text`,config:{label:`Meta Title`,placeholder:`A title of the page used for social media and search engines`}},meta_description:{type:`Text`,config:{label:`Meta Description`,placeholder:`A brief summary of the page`}},meta_image:{type:`Image`,config:{label:`Meta Image`,constraint:{width:2400,height:1260},thumbnails:[]}}}}},l=await V(`package.json`);if(!l){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let u=new URL(`customtypes/`,l),d=new URL(o+`/`,u),f=new URL(`index.json`,d);try{await n(new URL(`.`,f),{recursive:!0}),await s(f,J(c))}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 ${f.href}`);try{await U({output:a}),console.info(`Updated types in ${a??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add fields with `prismic page-type add-field`");let p=await $();if(p?.framework){let e=Ea(p.framework),t=Da(p.framework);console.info(` Run \`prismic docs ${e}${t}\` to learn how to implement a page file`)}}function ka(e){return e.toLowerCase().replace(/(^|[-_\s]+)(.)?/g,(e,t,n)=>n?.toUpperCase()??``)}const Aa=N({id:I(),label:I(),repeatable:M(),status:M(),format:I(),json:F(I(),F(I(),L()))});async function ja(){let{values:{help:t,"slice-zone":n,types:i},positionals:[a,o]}=e({args:process.argv.slice(4),options:{"slice-zone":{type:`string`,short:`z`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Disconnect a shared slice from a page type's slice zone.
|
|
1108
1199
|
|
|
1109
1200
|
USAGE
|
|
1110
1201
|
prismic page-type disconnect-slice <type-id> <slice-id> [flags]
|
|
@@ -1115,14 +1206,15 @@ ARGUMENTS
|
|
|
1115
1206
|
|
|
1116
1207
|
FLAGS
|
|
1117
1208
|
-z, --slice-zone string Target slice zone field ID (default: "slices")
|
|
1209
|
+
--types string Output file for generated types (default: "prismicio-types.d.ts")
|
|
1118
1210
|
-h, --help Show help for command
|
|
1119
1211
|
|
|
1120
1212
|
EXAMPLES
|
|
1121
1213
|
prismic page-type disconnect-slice homepage CallToAction
|
|
1122
1214
|
prismic page-type disconnect-slice homepage CallToAction --slice-zone slices
|
|
1123
|
-
prismic page-type disconnect-slice article HeroSection -z body`);return}if(!
|
|
1124
|
-
`),console.error(`Usage: prismic page-type disconnect-slice <type-id> <slice-id>`),process.exitCode=1;return}if(!
|
|
1125
|
-
`),console.error(`Usage: prismic page-type disconnect-slice <type-id> <slice-id>`),process.exitCode=1;return}let
|
|
1215
|
+
prismic page-type disconnect-slice article HeroSection -z body`);return}if(!a){console.error(`Missing required argument: type-id
|
|
1216
|
+
`),console.error(`Usage: prismic page-type disconnect-slice <type-id> <slice-id>`),process.exitCode=1;return}if(!o){console.error(`Missing required argument: slice-id
|
|
1217
|
+
`),console.error(`Usage: prismic page-type disconnect-slice <type-id> <slice-id>`),process.exitCode=1;return}let c=await V(`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=R(Aa,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=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){console.error(`Slice zone "${d}" not found in page type "${a}"`),process.exitCode=1;return}if(!f.config?.choices||!(o in f.config.choices)){console.error(`Slice "${o}" is not connected to slice zone "${p}" in ${a}`),process.exitCode=1;return}delete f.config.choices[o];try{await s(l,J(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(`Disconnected slice "${o}" from slice zone "${p}" in ${a}`);try{await U({output:i}),console.info(`Updated types in ${i??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}}const Ma=N({id:I(),label:I(),repeatable:M(),status:M(),format:P(I()),json:F(I(),F(I(),L()))});async function Na(){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
1218
|
|
|
1127
1219
|
USAGE
|
|
1128
1220
|
prismic page-type list [flags]
|
|
@@ -1133,7 +1225,7 @@ FLAGS
|
|
|
1133
1225
|
|
|
1134
1226
|
EXAMPLES
|
|
1135
1227
|
prismic page-type list
|
|
1136
|
-
prismic page-type list --json`);return}let a=await
|
|
1228
|
+
prismic page-type list --json`);return}let a=await V(`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=R(Ma,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 Pa=N({id:I(),label:I(),repeatable:M(),status:M(),format:P(I()),json:F(I(),F(I(),L()))});async function Fa(){let{values:{help:t,y:n,types:i},positionals:[a]}=e({args:process.argv.slice(4),options:{y:{type:`boolean`,short:`y`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Remove a page type from the project.
|
|
1137
1229
|
|
|
1138
1230
|
USAGE
|
|
1139
1231
|
prismic page-type remove <type-id> [flags]
|
|
@@ -1143,12 +1235,13 @@ ARGUMENTS
|
|
|
1143
1235
|
|
|
1144
1236
|
FLAGS
|
|
1145
1237
|
-y Confirm removal
|
|
1238
|
+
--types string Output file for generated types (default: "prismicio-types.d.ts")
|
|
1146
1239
|
-h, --help Show help for command
|
|
1147
1240
|
|
|
1148
1241
|
EXAMPLES
|
|
1149
1242
|
prismic page-type remove homepage
|
|
1150
|
-
prismic page-type remove homepage -y`);return}if(!
|
|
1151
|
-
`),console.error(`Usage: prismic page-type remove <type-id>`),process.exitCode=1;return}let
|
|
1243
|
+
prismic page-type remove homepage -y`);return}if(!a){console.error(`Missing required argument: type-id
|
|
1244
|
+
`),console.error(`Usage: prismic page-type remove <type-id>`),process.exitCode=1;return}let s=await V(`package.json`);if(!s){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let c=new URL(`customtypes/${a}/`,s),l=new URL(`index.json`,c),u;try{let e=await r(l,`utf8`),t=R(Pa,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}`),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(u.format!==`page`){console.error(`"${a}" is not a page type (format: ${u.format??`custom`})`),process.exitCode=1;return}if(!n){console.error(`Refusing to remove page type "${a}" (this will delete the entire directory).`),console.error(`Re-run with -y to confirm.`),process.exitCode=1;return}try{await o(c,{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 "${a}"`);try{await U({output:i}),console.info(`Updated types in ${i??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}}const Ia=N({id:I(),label:I(),repeatable:M(),status:M(),format:P(I()),json:F(I(),F(I(),L()))});async function La(){let{values:{help:t,tab:n,types:i},positionals:[a,o]}=e({args:process.argv.slice(4),options:{tab:{type:`string`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Remove a field from a page type.
|
|
1152
1245
|
|
|
1153
1246
|
USAGE
|
|
1154
1247
|
prismic page-type remove-field <type-id> <field-id> [flags]
|
|
@@ -1159,13 +1252,14 @@ ARGUMENTS
|
|
|
1159
1252
|
|
|
1160
1253
|
FLAGS
|
|
1161
1254
|
--tab string Specific tab (searches all tabs if not specified)
|
|
1255
|
+
--types string Output file for generated types (default: "prismicio-types.d.ts")
|
|
1162
1256
|
-h, --help Show help for command
|
|
1163
1257
|
|
|
1164
1258
|
EXAMPLES
|
|
1165
1259
|
prismic page-type remove-field homepage title
|
|
1166
|
-
prismic page-type remove-field homepage meta_title --tab "SEO & Metadata"`);return}if(!
|
|
1167
|
-
`),console.error(`Usage: prismic page-type remove-field <type-id> <field-id>`),process.exitCode=1;return}if(!
|
|
1168
|
-
`),console.error(`Usage: prismic page-type remove-field <type-id> <field-id>`),process.exitCode=1;return}let
|
|
1260
|
+
prismic page-type remove-field homepage meta_title --tab "SEO & Metadata"`);return}if(!a){console.error(`Missing required argument: type-id
|
|
1261
|
+
`),console.error(`Usage: prismic page-type remove-field <type-id> <field-id>`),process.exitCode=1;return}if(!o){console.error(`Missing required argument: field-id
|
|
1262
|
+
`),console.error(`Usage: prismic page-type remove-field <type-id> <field-id>`),process.exitCode=1;return}let c=await V(`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=R(Ia,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}if(u.format!==`page`){console.error(`"${a}" is not a page type (format: ${u.format??`custom`})`),process.exitCode=1;return}let d;if(n){if(!u.json[n]){console.error(`Tab "${n}" not found in page type "${a}"`),console.error(`Available tabs: ${Object.keys(u.json).join(`, `)}`),process.exitCode=1;return}if(!(o in u.json[n])){console.error(`Field "${o}" not found in tab "${n}"`),process.exitCode=1;return}delete u.json[n][o],d=n}else{for(let[e,t]of Object.entries(u.json))if(o in t){delete t[o],d=e;break}if(!d){console.error(`Field "${o}" not found in any tab of page type "${a}"`),process.exitCode=1;return}}try{await s(l,J(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(`Removed field "${o}" from tab "${d}" in page type "${a}"`);try{await U({output:i}),console.info(`Updated types in ${i??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}}const Ra=N({id:I(),label:I(),repeatable:M(),status:M(),format:P(I()),json:F(I(),F(I(),L()))});async function za(){let{values:{help:t,types:n},positionals:[i,a]}=e({args:process.argv.slice(4),options:{types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Change a page type's display name (label).
|
|
1169
1263
|
|
|
1170
1264
|
USAGE
|
|
1171
1265
|
prismic page-type set-name <type-id> <new-name> [flags]
|
|
@@ -1175,13 +1269,14 @@ ARGUMENTS
|
|
|
1175
1269
|
new-name New display name (required)
|
|
1176
1270
|
|
|
1177
1271
|
FLAGS
|
|
1272
|
+
--types string Output file for generated types (default: "prismicio-types.d.ts")
|
|
1178
1273
|
-h, --help Show help for command
|
|
1179
1274
|
|
|
1180
1275
|
EXAMPLES
|
|
1181
1276
|
prismic page-type set-name homepage "Home Page"
|
|
1182
|
-
prismic page-type set-name blog_post "Blog Post"`);return}if(!
|
|
1183
|
-
`),console.error(`Usage: prismic page-type set-name <type-id> <new-name>`),process.exitCode=1;return}if(!
|
|
1184
|
-
`),console.error(`Usage: prismic page-type set-name <type-id> <new-name>`),process.exitCode=1;return}let
|
|
1277
|
+
prismic page-type set-name blog_post "Blog Post"`);return}if(!i){console.error(`Missing required argument: type-id
|
|
1278
|
+
`),console.error(`Usage: prismic page-type set-name <type-id> <new-name>`),process.exitCode=1;return}if(!a){console.error(`Missing required argument: new-name
|
|
1279
|
+
`),console.error(`Usage: prismic page-type set-name <type-id> <new-name>`),process.exitCode=1;return}let o=await V(`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=R(Ra,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}l.label=a;try{await s(c,J(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(`Renamed page type "${i}" to "${a}"`);try{await U({output:n}),console.info(`Updated types in ${n??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}}const Ba=N({id:I(),label:I(),repeatable:M(),status:M(),format:P(I()),json:F(I(),F(I(),L()))});async function Va(){let{values:{help:t,types:n},positionals:[i,a]}=e({args:process.argv.slice(4),options:{types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Set whether a page type is repeatable.
|
|
1185
1280
|
|
|
1186
1281
|
USAGE
|
|
1187
1282
|
prismic page-type set-repeatable <type-id> <true|false> [flags]
|
|
@@ -1191,13 +1286,14 @@ ARGUMENTS
|
|
|
1191
1286
|
true|false Repeatable value (required)
|
|
1192
1287
|
|
|
1193
1288
|
FLAGS
|
|
1289
|
+
--types string Output file for generated types (default: "prismicio-types.d.ts")
|
|
1194
1290
|
-h, --help Show help for command
|
|
1195
1291
|
|
|
1196
1292
|
EXAMPLES
|
|
1197
1293
|
prismic page-type set-repeatable homepage true
|
|
1198
|
-
prismic page-type set-repeatable settings false`);return}if(!
|
|
1199
|
-
`),console.error(`Usage: prismic page-type set-repeatable <type-id> <true|false>`),process.exitCode=1;return}if(!
|
|
1200
|
-
`),console.error(`Usage: prismic page-type set-repeatable <type-id> <true|false>`),process.exitCode=1;return}if(
|
|
1294
|
+
prismic page-type set-repeatable settings false`);return}if(!i){console.error(`Missing required argument: type-id
|
|
1295
|
+
`),console.error(`Usage: prismic page-type set-repeatable <type-id> <true|false>`),process.exitCode=1;return}if(!a){console.error(`Missing required argument: true|false
|
|
1296
|
+
`),console.error(`Usage: prismic page-type set-repeatable <type-id> <true|false>`),process.exitCode=1;return}if(a!==`true`&&a!==`false`){console.error(`Invalid value: "${a}". Must be "true" or "false".`),process.exitCode=1;return}let o=a===`true`,c=await V(`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=R(Ba,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}if(u.format!==`page`){console.error(`"${i}" is not a page type (format: ${u.format??`custom`})`),process.exitCode=1;return}u.repeatable=o;try{await s(l,J(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}let d=o?`repeatable`:`singleton`;console.info(`Set page type "${i}" to ${d}`);try{await U({output:n}),console.info(`Updated types in ${n??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}}const Ha=N({id:I(),label:I(),repeatable:M(),status:M(),format:P(I()),json:F(I(),F(I(),L()))});async function Ua(){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
1297
|
|
|
1202
1298
|
USAGE
|
|
1203
1299
|
prismic page-type view <type-id> [flags]
|
|
@@ -1212,7 +1308,7 @@ FLAGS
|
|
|
1212
1308
|
EXAMPLES
|
|
1213
1309
|
prismic page-type view homepage
|
|
1214
1310
|
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
|
|
1311
|
+
`),console.error(`Usage: prismic page-type view <type-id>`),process.exitCode=1;return}let a=await V(`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=R(Ha,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 Wa(){let{positionals:[t]}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`create`:await Oa();break;case`list`:await Na();break;case`view`:await Ua();break;case`remove`:await Fa();break;case`set-name`:await za();break;case`set-repeatable`:await Va();break;case`add-field`:await Ca();break;case`remove-field`:await La();break;case`connect-slice`:await Ta();break;case`disconnect-slice`:await ja();break;default:t&&(console.error(`Unknown page-type subcommand: ${t}\n`),process.exitCode=1),console.info(`Manage page types in a Prismic repository.
|
|
1216
1312
|
|
|
1217
1313
|
USAGE
|
|
1218
1314
|
prismic page-type <command> [flags]
|
|
@@ -1233,7 +1329,7 @@ FLAGS
|
|
|
1233
1329
|
-h, --help Show help for command
|
|
1234
1330
|
|
|
1235
1331
|
LEARN MORE
|
|
1236
|
-
Use \`prismic page-type <command> --help\` for more information about a command.`)}}async function
|
|
1332
|
+
Use \`prismic page-type <command> --help\` for more information about a command.`)}}async function Ga(){let{values:{help:t,name:n,repo:r=await X()},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
1333
|
|
|
1238
1334
|
By default, this command reads the repository from prismic.config.json at the
|
|
1239
1335
|
project root.
|
|
@@ -1250,7 +1346,7 @@ FLAGS
|
|
|
1250
1346
|
-h, --help Show help for command
|
|
1251
1347
|
|
|
1252
1348
|
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
|
|
1349
|
+
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 B()){Ja();return}let a=Ka(i);if(!a){console.error(`Invalid URL: ${i}`),process.exitCode=1;return}let o=await qa(r,{name:n||a.hostname,websiteURL:a.websiteURL,resolverPath:a.resolverPath});if(!o.ok){o.error instanceof Q?Ja():(console.error(`Failed to add preview: ${J(o.value)}`),process.exitCode=1);return}console.info(`Preview added: ${i}`)}function Ka(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 qa(e,t){return await Z(new URL(`/previews/new`,await z(e)),{method:`POST`,body:{name:t.name,websiteURL:t.websiteURL,resolverPath:t.resolverPath}})}function Ja(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function Ya(){let{values:{help:t,repo:n=await X(),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
1350
|
|
|
1255
1351
|
By default, this command reads the repository from prismic.config.json at the
|
|
1256
1352
|
project root.
|
|
@@ -1264,7 +1360,7 @@ FLAGS
|
|
|
1264
1360
|
-h, --help Show help for command
|
|
1265
1361
|
|
|
1266
1362
|
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
|
|
1363
|
+
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 B()){Qa();return}let i=await Za(n);if(!i.ok){i.error instanceof Q?Qa():A(i.error)?(console.error(`Failed to get simulator URL: Invalid response: ${J(i.error.issues)}`),process.exitCode=1):(console.error(`Failed to get simulator URL: ${J(i.value)}`),process.exitCode=1);return}let a=i.value.simulator_url;if(!a){r?console.info(J({simulator_url:null})):console.info(`No simulator URL configured.`);return}r?console.info(J({simulator_url:a})):console.info(a)}const Xa=N({simulator_url:P(I())});async function Za(e){return await Z(new URL(`/core/repository`,await z(e)),{schema:Xa})}function Qa(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function $a(){let{values:{help:t,repo:n=await X(),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
1364
|
|
|
1269
1365
|
By default, this command reads the repository from prismic.config.json at the
|
|
1270
1366
|
project root.
|
|
@@ -1278,7 +1374,7 @@ FLAGS
|
|
|
1278
1374
|
-h, --help Show help for command
|
|
1279
1375
|
|
|
1280
1376
|
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
|
|
1377
|
+
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 B()){no();return}let i=await to(n);if(!i.ok){i.error instanceof Q?no():A(i.error)?(console.error(`Failed to list previews: Invalid response: ${J(i.error.issues)}`),process.exitCode=1):(console.error(`Failed to list previews: ${J(i.value)}`),process.exitCode=1);return}let a=i.value.results;if(r)console.info(J(a));else for(let e of a)console.info(`${e.url} ${e.label}`)}const eo=N({results:j(N({id:I(),label:I(),url:I()}))});async function to(e){return await Z(new URL(`/core/repository/preview_configs`,await z(e)),{schema:eo})}function no(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function ro(){let{values:{help:t,repo:n=await X()},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
1378
|
|
|
1283
1379
|
By default, this command reads the repository from prismic.config.json at the
|
|
1284
1380
|
project root.
|
|
@@ -1294,7 +1390,7 @@ FLAGS
|
|
|
1294
1390
|
-h, --help Show help for command
|
|
1295
1391
|
|
|
1296
1392
|
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
|
|
1393
|
+
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 B()){ao();return}let i=await to(n);if(!i.ok){i.error instanceof Q?ao():(console.error(`Failed to fetch previews: ${J(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 io(n,a.id);if(!o.ok){o.error instanceof Q?ao():(console.error(`Failed to remove preview: ${J(o.value)}`),process.exitCode=1);return}console.info(`Preview removed: ${r}`)}async function io(e,t){return await Z(new URL(`/previews/delete/${t}`,await z(e)),{method:`POST`,body:{}})}function ao(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function oo(){let{values:{help:t,repo:n=await X()}}=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
1394
|
|
|
1299
1395
|
By default, this command reads the repository from prismic.config.json at the
|
|
1300
1396
|
project root.
|
|
@@ -1307,7 +1403,7 @@ FLAGS
|
|
|
1307
1403
|
-h, --help Show help for command
|
|
1308
1404
|
|
|
1309
1405
|
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
|
|
1406
|
+
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 B()){co();return}let r=await so(n);if(!r.ok){r.error instanceof Q?co():(console.error(`Failed to remove simulator URL: ${J(r.value)}`),process.exitCode=1);return}console.info(`Simulator URL removed.`)}async function so(e){return await Z(new URL(`/core/repository`,await z(e)),{method:`PATCH`,body:{simulator_url:``}})}function co(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function lo(){let{values:{help:t,repo:n=await X()},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
1407
|
|
|
1312
1408
|
By default, this command reads the repository from prismic.config.json at the
|
|
1313
1409
|
project root.
|
|
@@ -1324,7 +1420,7 @@ FLAGS
|
|
|
1324
1420
|
-h, --help Show help for command
|
|
1325
1421
|
|
|
1326
1422
|
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
|
|
1423
|
+
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 B()){fo();return}let a=Ka(r);if(!a){console.error(`Invalid URL: ${r}`),process.exitCode=1;return}let o=await to(n);if(!o.ok){o.error instanceof Q?fo():(console.error(`Failed to fetch previews: ${J(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 uo(n,s.id,{name:i,websiteURL:a.websiteURL,resolverPath:a.resolverPath});if(!c.ok){c.error instanceof Q?fo():(console.error(`Failed to update preview: ${J(c.value)}`),process.exitCode=1);return}console.info(`Preview updated: ${r}`)}async function uo(e,t,n){return await Z(new URL(`/previews/save/${t}`,await z(e)),{method:`POST`,body:{name:n.name,websiteURL:n.websiteURL,resolverPath:n.resolverPath}})}function fo(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function po(){let{values:{help:t,repo:n=await X()},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
1424
|
|
|
1329
1425
|
If the URL pathname does not end with /slice-simulator, it is appended
|
|
1330
1426
|
automatically.
|
|
@@ -1347,7 +1443,7 @@ EXAMPLES
|
|
|
1347
1443
|
prismic preview set-simulator http://localhost:3000/slice-simulator
|
|
1348
1444
|
|
|
1349
1445
|
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
|
|
1446
|
+
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 B()){go();return}let i=mo(r);if(!i){console.error(`Invalid URL: ${r}`),process.exitCode=1;return}let a=await ho(n,i);if(!a.ok){a.error instanceof Q?go():(console.error(`Failed to set simulator URL: ${J(a.value)}`),process.exitCode=1);return}console.info(`Simulator URL set: ${i}`)}function mo(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 ho(e,t){return await Z(new URL(`/core/repository`,await z(e)),{method:`PATCH`,body:{simulator_url:t}})}function go(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function _o(){let{positionals:[t]}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`add`:await Ga();break;case`list`:await $a();break;case`remove`:await ro();break;case`set-name`:await lo();break;case`set-simulator`:await po();break;case`get-simulator`:await Ya();break;case`remove-simulator`:await oo();break;default:t&&(console.error(`Unknown preview subcommand: ${t}\n`),process.exitCode=1),console.info(`Manage preview configurations in a Prismic repository.
|
|
1351
1447
|
|
|
1352
1448
|
USAGE
|
|
1353
1449
|
prismic preview <command> [flags]
|
|
@@ -1365,7 +1461,7 @@ FLAGS
|
|
|
1365
1461
|
-h, --help Show help for command
|
|
1366
1462
|
|
|
1367
1463
|
LEARN MORE
|
|
1368
|
-
Use \`prismic preview <command> --help\` for more information about a command.`)}}async function
|
|
1464
|
+
Use \`prismic preview <command> --help\` for more information about a command.`)}}async function vo(){let{values:{help:t,repo:r=await X(),"dry-run":i,"types-only":a,"slices-only":o,json:c,types:l}}=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`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!1});if(t){console.info(`Pull custom types and slices from Prismic to local files.
|
|
1369
1465
|
|
|
1370
1466
|
By default, this command reads the repository from prismic.config.json at the
|
|
1371
1467
|
project root.
|
|
@@ -1379,15 +1475,16 @@ FLAGS
|
|
|
1379
1475
|
--types-only Only pull custom types
|
|
1380
1476
|
--slices-only Only pull slices
|
|
1381
1477
|
--json Output as JSON
|
|
1478
|
+
--types string Output file for generated types (default: "prismicio-types.d.ts")
|
|
1382
1479
|
-h, --help Show help for command
|
|
1383
1480
|
|
|
1384
1481
|
EXAMPLES
|
|
1385
1482
|
prismic pull
|
|
1386
1483
|
prismic pull --repo my-repo
|
|
1387
1484
|
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
|
|
1389
|
-
Writing custom types:`);let e=new URL(`customtypes/`,
|
|
1390
|
-
Writing slices:`);let e=await
|
|
1485
|
+
prismic pull --types-only`);return}if(!r){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await B()){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1;return}c||console.info(`Pulling from repository: ${r}\n`);let u=!o,d=!a,[f,p]=await Promise.all([u?zn(r):Promise.resolve({ok:!0,value:[]}),d?Bn(r):Promise.resolve({ok:!0,value:[]})]);if(!f.ok){console.error(`Failed to fetch custom types: ${f.error}`),process.exitCode=1;return}if(!p.ok){console.error(`Failed to fetch slices: ${p.error}`),process.exitCode=1;return}let m=f.value,h=p.value;if(c||(u&&console.info(`Fetching custom types... ${m.length} types`),d&&console.info(`Fetching slices... ${h.length} slices`)),i){if(c)console.info(J({customTypes:m,slices:h}));else{if(console.info(``),u&&m.length>0){console.info(`Would write custom types:`);for(let e of m)console.info(` customtypes/${e.id}/index.json`)}if(d&&h.length>0){let e=yo(await Nn());console.info(`Would write slices:`);for(let t of h)console.info(` ${e}${In(t.name)}/model.json`)}console.info(`\nDry run complete: ${m.length} custom types, ${h.length} slices`)}return}let g=await V(`package.json`);if(!g){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let _=new URL(`.`,g),v=[],y=[];if(u&&m.length>0){c||console.info(`
|
|
1486
|
+
Writing custom types:`);let e=new URL(`customtypes/`,_);for(let t of m){let r=new URL(`${t.id}/`,e),i=new URL(`index.json`,r);try{await n(r,{recursive:!0}),await s(i,J(t));let e=`customtypes/${t.id}/index.json`;v.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(d&&h.length>0){c||console.info(`
|
|
1487
|
+
Writing slices:`);let e=await Nn();for(let t of h){let r=new URL(`${In(t.name)}/`,e),i=new URL(`model.json`,r);try{await n(r,{recursive:!0}),await s(i,J(t));let a=`${yo(e)}${In(t.name)}/model.json`;y.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}}}if(c?console.info(J({writtenTypes:v,writtenSlices:y})):console.info(`\nPull complete: ${v.length} custom types, ${y.length} slices`),!c)try{await U({output:l}),console.info(`Updated types in ${l??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}}function yo(e){let t=process.cwd(),n=e.pathname;return n.startsWith(t)?n.slice(t.length+1):n}function bo(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 xo(){let{values:{help:t,repo:n=await X(),"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
1488
|
|
|
1392
1489
|
By default, this command reads the repository from prismic.config.json at the
|
|
1393
1490
|
project root.
|
|
@@ -1409,10 +1506,10 @@ EXAMPLES
|
|
|
1409
1506
|
prismic push --repo my-repo
|
|
1410
1507
|
prismic push --dry-run
|
|
1411
1508
|
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
|
|
1413
|
-
No changes to push.`);return}if(r){if(s)console.info(
|
|
1414
|
-
Pushing custom types:`);for(let e of v.toInsert){let t=await
|
|
1415
|
-
Pushing slices:`);for(let e of y.toInsert){let t=await
|
|
1509
|
+
prismic push --delete`);return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await B()){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?Vn():Promise.resolve({ok:!0,value:[]}),l?Hn():Promise.resolve({ok:!0,value:[]}),c?zn(n):Promise.resolve({ok:!0,value:[]}),l?Bn(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?bo([...m],[...g]):{toInsert:[],toUpdate:[],toDelete:[]},y=l?bo([...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(J({customTypes:{inserted:[],updated:[],deleted:[]},slices:{inserted:[],updated:[],deleted:[]}})):console.info(`
|
|
1510
|
+
No changes to push.`);return}if(r){if(s)console.info(J({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(`
|
|
1511
|
+
Pushing custom types:`);for(let e of v.toInsert){let t=await Un(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 Wn(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 Gn(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(`
|
|
1512
|
+
Pushing slices:`);for(let e of y.toInsert){let t=await Kn(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 Jn(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(J(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 So=/^[a-zA-Z0-9][-a-zA-Z0-9]{2,}[a-zA-Z0-9]$/;function Co(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}function wo(e){switch(e){case`nuxt`:return`#configure-the-modules-prismic-client`;default:return`#set-up-a-prismic-client`}}async function To(){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
1513
|
|
|
1417
1514
|
Creates prismic.config.json in the current directory. If a config file already
|
|
1418
1515
|
exists, use --replace to update it with the new repository.
|
|
@@ -1431,7 +1528,7 @@ FLAGS
|
|
|
1431
1528
|
-h, --help Show help for command
|
|
1432
1529
|
|
|
1433
1530
|
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(!
|
|
1531
|
+
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(!So.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 B()){Oo();return}let o=await $r();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 Eo(a);if(!s.ok){s.error instanceof Q?Oo():(console.error(`Failed to check domain availability: ${J(s.error)}`),process.exitCode=1);return}if(!s.value){console.error(`Repository name "${a}" is already taken.`),process.exitCode=1;return}let c=await Do(a,n);if(!c.ok){c.error instanceof Q?Oo():(console.error(`Failed to create repository: ${J(c.error)}`),process.exitCode=1);return}if(!r)if(o.ok){let e=await ti({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 Qr({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 z(a)}`);let l=await $();if(l?.framework){let e=Co(l.framework),t=wo(l.framework),n=ji(l),r=n?`creating ${n}`:`configuring Prismic`;console.info(),console.info(`Next: Run \`prismic docs ${e}${t}\` for instructions on ${r}`)}}async function Eo(e){let t=await Z(new URL(`/app/dashboard/repositories/${e}/exists`,await On()));return t.ok?{ok:!0,value:t.value===`true`}:t}async function Do(e,t=e){return await Z(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 Oo(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}const ko=N({repository:N({api_access:I()})});async function Ao(){let{values:{help:t,repo:n=await X()}}=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
1532
|
|
|
1436
1533
|
By default, this command reads the repository from prismic.config.json at the
|
|
1437
1534
|
project root.
|
|
@@ -1444,7 +1541,7 @@ FLAGS
|
|
|
1444
1541
|
-h, --help Show help for command
|
|
1445
1542
|
|
|
1446
1543
|
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
|
|
1544
|
+
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 B()){Mo();return}let r=await jo(n);if(!r.ok){r.error instanceof Q?Mo():(console.error(`Failed to get repository access: ${J(r.value)}`),process.exitCode=1);return}console.info(r.value.repository.api_access)}async function jo(e){let t=await z(e);return await Z(new URL(`syncState`,t),{schema:ko})}function Mo(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}const No=N({repositories:j(N({domain:I(),name:P(I()),role:I()}))});async function Po(){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
1545
|
|
|
1449
1546
|
USAGE
|
|
1450
1547
|
prismic repo list [flags]
|
|
@@ -1454,7 +1551,7 @@ FLAGS
|
|
|
1454
1551
|
-h, --help Show help for command
|
|
1455
1552
|
|
|
1456
1553
|
LEARN MORE
|
|
1457
|
-
Use \`prismic repo <command> --help\` for more information about a command.`);return}if(!await
|
|
1554
|
+
Use \`prismic repo <command> --help\` for more information about a command.`);return}if(!await B()){Io();return}let r=await Fo();if(!r.ok){r.error instanceof Q?Io():(console.error(`Failed to fetch repositories: ${J(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 z(e.domain)).toString()})));console.info(J(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 Fo(){return await Z(new URL(`profile`,await Sn()),{schema:No})}function Io(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}const Lo=[`private`,`public`,`open`];async function Ro(){let{values:{help:t,repo:n=await X()},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
1555
|
|
|
1459
1556
|
By default, this command reads the repository from prismic.config.json at the
|
|
1460
1557
|
project root.
|
|
@@ -1470,7 +1567,7 @@ FLAGS
|
|
|
1470
1567
|
-h, --help Show help for command
|
|
1471
1568
|
|
|
1472
1569
|
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(!
|
|
1570
|
+
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(!Lo.includes(r)){console.error(`Invalid access level: ${r}. Must be one of: ${Lo.join(`, `)}`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await B()){Bo();return}let i=await zo(n,r);if(!i.ok){i.error instanceof Q?Bo():(console.error(`Failed to set repository access: ${J(i.value)}`),process.exitCode=1);return}console.info(`Repository access set to: ${r}`)}async function zo(e,t){let n=await z(e);return await Z(new URL(`settings/security/apiaccess`,n),{method:`POST`,body:{api_access:t}})}function Bo(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function Vo(){let{values:{help:t,repo:n=await X()},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
1571
|
|
|
1475
1572
|
By default, this command reads the repository from prismic.config.json at the
|
|
1476
1573
|
project root.
|
|
@@ -1486,7 +1583,7 @@ FLAGS
|
|
|
1486
1583
|
-h, --help Show help for command
|
|
1487
1584
|
|
|
1488
1585
|
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
|
|
1586
|
+
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 B()){Uo();return}let i=await Ho(n,r);if(!i.ok){i.error instanceof Q?Uo():A(i.error)?(console.error(`Failed to set repository name: Invalid response: ${J(i.error.issues)}`),process.exitCode=1):(console.error(`Failed to set repository name: ${J(i.value)}`),process.exitCode=1);return}console.info(`Repository name set to: ${i.value.repository.name}`)}async function Ho(e,t){let n=await z(e),r=new URL(`app/settings/repository`,n),i=new FormData;return i.set(`displayname`,t),await Z(r,{method:`POST`,body:i,schema:N({repository:N({name:I()})})})}function Uo(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}const Wo=N({repositories:j(N({domain:I(),name:P(I())}))});async function Go(){let{values:{help:t,repo:n=await X(),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
1587
|
|
|
1491
1588
|
By default, this command reads the repository from prismic.config.json at the
|
|
1492
1589
|
project root.
|
|
@@ -1500,7 +1597,7 @@ FLAGS
|
|
|
1500
1597
|
-h, --help Show help for command
|
|
1501
1598
|
|
|
1502
1599
|
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
|
|
1600
|
+
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 z(n);if(r){qo(i.toString()),console.info(`Opening ${i}`);return}if(!await B()){Jo();return}let a=await Ko();if(!a.ok){a.error instanceof Q?Jo():(console.error(`Failed to fetch repository info: ${J(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 Ko(){return await Z(new URL(`profile`,await Sn()),{schema:Wo})}function qo(e){f(`${process.platform===`darwin`?`open`:process.platform===`win32`?`start`:`xdg-open`} "${e}"`)}function Jo(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function Yo(){let{positionals:[t]}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`create`:await To();break;case`list`:await Po();break;case`view`:await Go();break;case`get-access`:await Ao();break;case`set-access`:await Ro();break;case`set-name`:await Vo();break;default:t&&(console.error(`Unknown repo subcommand: ${t}\n`),process.exitCode=1),console.info(`Manage Prismic repositories.
|
|
1504
1601
|
|
|
1505
1602
|
USAGE
|
|
1506
1603
|
prismic repo <command> [flags]
|
|
@@ -1517,7 +1614,7 @@ FLAGS
|
|
|
1517
1614
|
-h, --help Show help for command
|
|
1518
1615
|
|
|
1519
1616
|
LEARN MORE
|
|
1520
|
-
Use \`prismic repo <command> --help\` for more information about a command.`)}}async function
|
|
1617
|
+
Use \`prismic repo <command> --help\` for more information about a command.`)}}function Xo(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}function Zo(e){switch(e){case`nuxt`:return`#write-vue-components`;case`sveltekit`:return`#write-svelte-components`;default:return`#write-react-components`}}async function Qo(){let{values:{help:t,variation:n,label:r,default:i,"true-label":a,"false-label":o,types:c},positionals:[l,u]}=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`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a boolean (toggle) field to an existing slice.
|
|
1521
1618
|
|
|
1522
1619
|
USAGE
|
|
1523
1620
|
prismic slice add-field boolean <slice-id> <field-id> [flags]
|
|
@@ -1532,14 +1629,15 @@ FLAGS
|
|
|
1532
1629
|
--default Set default value to true
|
|
1533
1630
|
--true-label string Label shown when toggle is on
|
|
1534
1631
|
--false-label string Label shown when toggle is off
|
|
1632
|
+
--types string Output file for generated types (default: "prismicio-types.d.ts")
|
|
1535
1633
|
-h, --help Show help for command
|
|
1536
1634
|
|
|
1537
1635
|
EXAMPLES
|
|
1538
1636
|
prismic slice add-field boolean my_slice featured
|
|
1539
1637
|
prismic slice add-field boolean hero show_overlay --default
|
|
1540
|
-
prismic slice add-field boolean product available --true-label "In Stock" --false-label "Out of Stock"`);return}if(!
|
|
1541
|
-
`),console.error(`Usage: prismic slice add-field boolean <slice-id> <field-id>`),process.exitCode=1;return}if(!
|
|
1542
|
-
`),console.error(`Usage: prismic slice add-field boolean <slice-id> <field-id>`),process.exitCode=1;return}let u=await
|
|
1638
|
+
prismic slice add-field boolean product available --true-label "In Stock" --false-label "Out of Stock"`);return}if(!l){console.error(`Missing required argument: slice-id
|
|
1639
|
+
`),console.error(`Usage: prismic slice add-field boolean <slice-id> <field-id>`),process.exitCode=1;return}if(!u){console.error(`Missing required argument: field-id
|
|
1640
|
+
`),console.error(`Usage: prismic slice add-field boolean <slice-id> <field-id>`),process.exitCode=1;return}let d=W(u),f=q(d);if(!f.ok){console.error(f.error),process.exitCode=1;return}let p=await H(l);if(!p.ok){console.error(p.error),process.exitCode=1;return}let{model:m,modelPath:h}=p;if(m.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 g=n?m.variations.find(e=>e.id===n):m.variations[0];if(!g){console.error(`Variation "${n}" not found in slice "${l}"\n`),console.error(`Available variations: ${m.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}g.primary||={};let _={type:`Boolean`,config:{label:r??Y(d.type===`nested`?d.nestedFieldId:u),...i&&{default_value:!0},...a&&{placeholder_true:a},...o&&{placeholder_false:o}}};if(d.type===`nested`){let e=Zn(g.primary,d.groupId,g.id);if(!e.ok){console.error(e.error),process.exitCode=1;return}if(e.group.config.fields[d.nestedFieldId]){console.error(`Field "${d.nestedFieldId}" already exists in group "${d.groupId}"`),process.exitCode=1;return}e.group.config.fields[d.nestedFieldId]=_}else{for(let e of m.variations){if(e.primary?.[u]){console.error(`Field "${u}" already exists in variation "${e.id}"`),process.exitCode=1;return}for(let[t,n]of Object.entries(e.primary??{}))if(G(n)&&n.config.fields[u]){console.error(`Field "${u}" already exists in group "${t}" in variation "${e.id}"`),process.exitCode=1;return}}g.primary[u]=_}try{await s(h,J(m))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}d.type===`nested`?console.info(`Added field "${d.nestedFieldId}" (Boolean) to group "${d.groupId}" in ${l}`):console.info(`Added field "${u}" (Boolean) to "${g.id}" variation in ${l}`);try{await U({output:c}),console.info(`Updated types in ${c??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic slice add-field`");let v=await $();if(v?.framework){let e=Xo(v.framework),t=Zo(v.framework);console.info(` Run \`prismic docs ${e}${t}\` to learn how to implement the slice's component`)}}function $o(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}function es(e){switch(e){case`nuxt`:return`#write-vue-components`;case`sveltekit`:return`#write-svelte-components`;default:return`#write-react-components`}}async function ts(){let{values:{help:t,variation:n,label:r,placeholder:i,types:a},positionals:[o,c]}=e({args:process.argv.slice(5),options:{variation:{type:`string`,short:`v`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a color picker field to an existing slice.
|
|
1543
1641
|
|
|
1544
1642
|
USAGE
|
|
1545
1643
|
prismic slice add-field color <slice-id> <field-id> [flags]
|
|
@@ -1552,14 +1650,15 @@ FLAGS
|
|
|
1552
1650
|
-v, --variation string Target variation (default: first variation)
|
|
1553
1651
|
-l, --label string Display label for the field (inferred from field-id if omitted)
|
|
1554
1652
|
-p, --placeholder string Placeholder text
|
|
1653
|
+
--types string Output file for generated types (default: "prismicio-types.d.ts")
|
|
1555
1654
|
-h, --help Show help for command
|
|
1556
1655
|
|
|
1557
1656
|
EXAMPLES
|
|
1558
1657
|
prismic slice add-field color my_slice background_color
|
|
1559
1658
|
prismic slice add-field color hero accent --label "Accent Color"
|
|
1560
|
-
prismic slice add-field color banner theme_color --variation "dark"`);return}if(!
|
|
1561
|
-
`),console.error(`Usage: prismic slice add-field color <slice-id> <field-id>`),process.exitCode=1;return}if(!
|
|
1562
|
-
`),console.error(`Usage: prismic slice add-field color <slice-id> <field-id>`),process.exitCode=1;return}let c=await
|
|
1659
|
+
prismic slice add-field color banner theme_color --variation "dark"`);return}if(!o){console.error(`Missing required argument: slice-id
|
|
1660
|
+
`),console.error(`Usage: prismic slice add-field color <slice-id> <field-id>`),process.exitCode=1;return}if(!c){console.error(`Missing required argument: field-id
|
|
1661
|
+
`),console.error(`Usage: prismic slice add-field color <slice-id> <field-id>`),process.exitCode=1;return}let l=W(c),u=q(l);if(!u.ok){console.error(u.error),process.exitCode=1;return}let d=await H(o);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 "${o}" 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 "${o}"\n`),console.error(`Available variations: ${f.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}m.primary||={};let h={type:`Color`,config:{label:r??Y(l.type===`nested`?l.nestedFieldId:c),...i&&{placeholder:i}}};if(l.type===`nested`){let e=Zn(m.primary,l.groupId,m.id);if(!e.ok){console.error(e.error),process.exitCode=1;return}if(e.group.config.fields[l.nestedFieldId]){console.error(`Field "${l.nestedFieldId}" already exists in group "${l.groupId}"`),process.exitCode=1;return}e.group.config.fields[l.nestedFieldId]=h}else{for(let e of f.variations){if(e.primary?.[c]){console.error(`Field "${c}" already exists in variation "${e.id}"`),process.exitCode=1;return}for(let[t,n]of Object.entries(e.primary??{}))if(G(n)&&n.config.fields[c]){console.error(`Field "${c}" already exists in group "${t}" in variation "${e.id}"`),process.exitCode=1;return}}m.primary[c]=h}try{await s(p,J(f))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}l.type===`nested`?console.info(`Added field "${l.nestedFieldId}" (Color) to group "${l.groupId}" in ${o}`):console.info(`Added field "${c}" (Color) to "${m.id}" variation in ${o}`);try{await U({output:a}),console.info(`Updated types in ${a??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic slice add-field`");let g=await $();if(g?.framework){let e=$o(g.framework),t=es(g.framework);console.info(` Run \`prismic docs ${e}${t}\` to learn how to implement the slice's component`)}}function ns(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}function rs(e){switch(e){case`nuxt`:return`#write-vue-components`;case`sveltekit`:return`#write-svelte-components`;default:return`#write-react-components`}}async function is(){let{values:{help:t,variation:n,label:r,placeholder:i,types:a},positionals:[o,c]}=e({args:process.argv.slice(5),options:{variation:{type:`string`,short:`v`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a date picker field to an existing slice.
|
|
1563
1662
|
|
|
1564
1663
|
USAGE
|
|
1565
1664
|
prismic slice add-field date <slice-id> <field-id> [flags]
|
|
@@ -1572,14 +1671,15 @@ FLAGS
|
|
|
1572
1671
|
-v, --variation string Target variation (default: first variation)
|
|
1573
1672
|
-l, --label string Display label for the field (inferred from field-id if omitted)
|
|
1574
1673
|
-p, --placeholder string Placeholder text
|
|
1674
|
+
--types string Output file for generated types (default: "prismicio-types.d.ts")
|
|
1575
1675
|
-h, --help Show help for command
|
|
1576
1676
|
|
|
1577
1677
|
EXAMPLES
|
|
1578
1678
|
prismic slice add-field date my_slice publish_date
|
|
1579
1679
|
prismic slice add-field date event start_date --label "Start Date"
|
|
1580
|
-
prismic slice add-field date promo end_date --variation "countdown"`);return}if(!
|
|
1581
|
-
`),console.error(`Usage: prismic slice add-field date <slice-id> <field-id>`),process.exitCode=1;return}if(!
|
|
1582
|
-
`),console.error(`Usage: prismic slice add-field date <slice-id> <field-id>`),process.exitCode=1;return}let c=await
|
|
1680
|
+
prismic slice add-field date promo end_date --variation "countdown"`);return}if(!o){console.error(`Missing required argument: slice-id
|
|
1681
|
+
`),console.error(`Usage: prismic slice add-field date <slice-id> <field-id>`),process.exitCode=1;return}if(!c){console.error(`Missing required argument: field-id
|
|
1682
|
+
`),console.error(`Usage: prismic slice add-field date <slice-id> <field-id>`),process.exitCode=1;return}let l=W(c),u=q(l);if(!u.ok){console.error(u.error),process.exitCode=1;return}let d=await H(o);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 "${o}" 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 "${o}"\n`),console.error(`Available variations: ${f.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}m.primary||={};let h={type:`Date`,config:{label:r??Y(l.type===`nested`?l.nestedFieldId:c),...i&&{placeholder:i}}};if(l.type===`nested`){let e=Zn(m.primary,l.groupId,m.id);if(!e.ok){console.error(e.error),process.exitCode=1;return}if(e.group.config.fields[l.nestedFieldId]){console.error(`Field "${l.nestedFieldId}" already exists in group "${l.groupId}"`),process.exitCode=1;return}e.group.config.fields[l.nestedFieldId]=h}else{for(let e of f.variations){if(e.primary?.[c]){console.error(`Field "${c}" already exists in variation "${e.id}"`),process.exitCode=1;return}for(let[t,n]of Object.entries(e.primary??{}))if(G(n)&&n.config.fields[c]){console.error(`Field "${c}" already exists in group "${t}" in variation "${e.id}"`),process.exitCode=1;return}}m.primary[c]=h}try{await s(p,J(f))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}l.type===`nested`?console.info(`Added field "${l.nestedFieldId}" (Date) to group "${l.groupId}" in ${o}`):console.info(`Added field "${c}" (Date) to "${m.id}" variation in ${o}`);try{await U({output:a}),console.info(`Updated types in ${a??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic slice add-field`");let g=await $();if(g?.framework){let e=ns(g.framework),t=rs(g.framework);console.info(` Run \`prismic docs ${e}${t}\` to learn how to implement the slice's component`)}}function as(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}function os(e){switch(e){case`nuxt`:return`#write-vue-components`;case`sveltekit`:return`#write-svelte-components`;default:return`#write-react-components`}}async function ss(){let{values:{help:t,variation:n,label:r,placeholder:i,types:a},positionals:[o,c]}=e({args:process.argv.slice(5),options:{variation:{type:`string`,short:`v`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add an embed (oEmbed) field to an existing slice.
|
|
1583
1683
|
|
|
1584
1684
|
USAGE
|
|
1585
1685
|
prismic slice add-field embed <slice-id> <field-id> [flags]
|
|
@@ -1592,14 +1692,15 @@ FLAGS
|
|
|
1592
1692
|
-v, --variation string Target variation (default: first variation)
|
|
1593
1693
|
-l, --label string Display label for the field (inferred from field-id if omitted)
|
|
1594
1694
|
-p, --placeholder string Placeholder text
|
|
1695
|
+
--types string Output file for generated types (default: "prismicio-types.d.ts")
|
|
1595
1696
|
-h, --help Show help for command
|
|
1596
1697
|
|
|
1597
1698
|
EXAMPLES
|
|
1598
1699
|
prismic slice add-field embed my_slice video
|
|
1599
1700
|
prismic slice add-field embed gallery media --label "Media Embed"
|
|
1600
|
-
prismic slice add-field embed social tweet --variation "twitter"`);return}if(!
|
|
1601
|
-
`),console.error(`Usage: prismic slice add-field embed <slice-id> <field-id>`),process.exitCode=1;return}if(!
|
|
1602
|
-
`),console.error(`Usage: prismic slice add-field embed <slice-id> <field-id>`),process.exitCode=1;return}let c=await
|
|
1701
|
+
prismic slice add-field embed social tweet --variation "twitter"`);return}if(!o){console.error(`Missing required argument: slice-id
|
|
1702
|
+
`),console.error(`Usage: prismic slice add-field embed <slice-id> <field-id>`),process.exitCode=1;return}if(!c){console.error(`Missing required argument: field-id
|
|
1703
|
+
`),console.error(`Usage: prismic slice add-field embed <slice-id> <field-id>`),process.exitCode=1;return}let l=W(c),u=q(l);if(!u.ok){console.error(u.error),process.exitCode=1;return}let d=await H(o);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 "${o}" 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 "${o}"\n`),console.error(`Available variations: ${f.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}m.primary||={};let h={type:`Embed`,config:{label:r??Y(l.type===`nested`?l.nestedFieldId:c),...i&&{placeholder:i}}};if(l.type===`nested`){let e=Zn(m.primary,l.groupId,m.id);if(!e.ok){console.error(e.error),process.exitCode=1;return}if(e.group.config.fields[l.nestedFieldId]){console.error(`Field "${l.nestedFieldId}" already exists in group "${l.groupId}"`),process.exitCode=1;return}e.group.config.fields[l.nestedFieldId]=h}else{for(let e of f.variations){if(e.primary?.[c]){console.error(`Field "${c}" already exists in variation "${e.id}"`),process.exitCode=1;return}for(let[t,n]of Object.entries(e.primary??{}))if(G(n)&&n.config.fields[c]){console.error(`Field "${c}" already exists in group "${t}" in variation "${e.id}"`),process.exitCode=1;return}}m.primary[c]=h}try{await s(p,J(f))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}l.type===`nested`?console.info(`Added field "${l.nestedFieldId}" (Embed) to group "${l.groupId}" in ${o}`):console.info(`Added field "${c}" (Embed) to "${m.id}" variation in ${o}`);try{await U({output:a}),console.info(`Updated types in ${a??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic slice add-field`");let g=await $();if(g?.framework){let e=as(g.framework),t=os(g.framework);console.info(` Run \`prismic docs ${e}${t}\` to learn how to implement the slice's component`)}}function cs(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}function ls(e){switch(e){case`nuxt`:return`#write-vue-components`;case`sveltekit`:return`#write-svelte-components`;default:return`#write-react-components`}}async function us(){let{values:{help:t,variation:n,label:r,types:i},positionals:[a,o]}=e({args:process.argv.slice(5),options:{variation:{type:`string`,short:`v`},label:{type:`string`,short:`l`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a geographic coordinates field to an existing slice.
|
|
1603
1704
|
|
|
1604
1705
|
USAGE
|
|
1605
1706
|
prismic slice add-field geo-point <slice-id> <field-id> [flags]
|
|
@@ -1611,14 +1712,36 @@ ARGUMENTS
|
|
|
1611
1712
|
FLAGS
|
|
1612
1713
|
-v, --variation string Target variation (default: first variation)
|
|
1613
1714
|
-l, --label string Display label for the field (inferred from field-id if omitted)
|
|
1715
|
+
--types string Output file for generated types (default: "prismicio-types.d.ts")
|
|
1614
1716
|
-h, --help Show help for command
|
|
1615
1717
|
|
|
1616
1718
|
EXAMPLES
|
|
1617
1719
|
prismic slice add-field geo-point my_slice location
|
|
1618
1720
|
prismic slice add-field geo-point store coordinates --label "Store Location"
|
|
1619
|
-
prismic slice add-field geo-point map marker --variation "interactive"`);return}if(!
|
|
1620
|
-
`),console.error(`Usage: prismic slice add-field geo-point <slice-id> <field-id>`),process.exitCode=1;return}if(!
|
|
1621
|
-
`),console.error(`Usage: prismic slice add-field geo-point <slice-id> <field-id>`),process.exitCode=1;return}let o=await
|
|
1721
|
+
prismic slice add-field geo-point map marker --variation "interactive"`);return}if(!a){console.error(`Missing required argument: slice-id
|
|
1722
|
+
`),console.error(`Usage: prismic slice add-field geo-point <slice-id> <field-id>`),process.exitCode=1;return}if(!o){console.error(`Missing required argument: field-id
|
|
1723
|
+
`),console.error(`Usage: prismic slice add-field geo-point <slice-id> <field-id>`),process.exitCode=1;return}let c=W(o),l=q(c);if(!l.ok){console.error(l.error),process.exitCode=1;return}let u=await H(a);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 "${a}" 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 "${a}"\n`),console.error(`Available variations: ${d.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}p.primary||={};let m={type:`GeoPoint`,config:{label:r??Y(c.type===`nested`?c.nestedFieldId:o)}};if(c.type===`nested`){let e=Zn(p.primary,c.groupId,p.id);if(!e.ok){console.error(e.error),process.exitCode=1;return}if(e.group.config.fields[c.nestedFieldId]){console.error(`Field "${c.nestedFieldId}" already exists in group "${c.groupId}"`),process.exitCode=1;return}e.group.config.fields[c.nestedFieldId]=m}else{for(let e of d.variations){if(e.primary?.[o]){console.error(`Field "${o}" already exists in variation "${e.id}"`),process.exitCode=1;return}for(let[t,n]of Object.entries(e.primary??{}))if(G(n)&&n.config.fields[o]){console.error(`Field "${o}" already exists in group "${t}" in variation "${e.id}"`),process.exitCode=1;return}}p.primary[o]=m}try{await s(f,J(d))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}c.type===`nested`?console.info(`Added field "${c.nestedFieldId}" (GeoPoint) to group "${c.groupId}" in ${a}`):console.info(`Added field "${o}" (GeoPoint) to "${p.id}" variation in ${a}`);try{await U({output:i}),console.info(`Updated types in ${i??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic slice add-field`");let h=await $();if(h?.framework){let e=cs(h.framework),t=ls(h.framework);console.info(` Run \`prismic docs ${e}${t}\` to learn how to implement the slice's component`)}}function ds(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}function fs(e){switch(e){case`nuxt`:return`#write-vue-components`;case`sveltekit`:return`#write-svelte-components`;default:return`#write-react-components`}}async function ps(){let{values:{help:t,variation:n,label:r,"non-repeatable":i,types:a},positionals:[o,c]}=e({args:process.argv.slice(5),options:{variation:{type:`string`,short:`v`},label:{type:`string`,short:`l`},"non-repeatable":{type:`boolean`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a group field to an existing slice.
|
|
1724
|
+
|
|
1725
|
+
USAGE
|
|
1726
|
+
prismic slice add-field group <slice-id> <field-id> [flags]
|
|
1727
|
+
|
|
1728
|
+
ARGUMENTS
|
|
1729
|
+
slice-id Slice identifier (required)
|
|
1730
|
+
field-id Field identifier (required)
|
|
1731
|
+
|
|
1732
|
+
FLAGS
|
|
1733
|
+
-v, --variation string Target variation (default: first variation)
|
|
1734
|
+
-l, --label string Display label for the field (inferred from field-id if omitted)
|
|
1735
|
+
--non-repeatable Make this a non-repeating group (default: repeatable)
|
|
1736
|
+
--types string Output file for generated types (default: "prismicio-types.d.ts")
|
|
1737
|
+
-h, --help Show help for command
|
|
1738
|
+
|
|
1739
|
+
EXAMPLES
|
|
1740
|
+
prismic slice add-field group my_slice buttons
|
|
1741
|
+
prismic slice add-field group hero ctas --non-repeatable
|
|
1742
|
+
prismic slice add-field group product variants --variation "withImage"`);return}if(!o){console.error(`Missing required argument: slice-id
|
|
1743
|
+
`),console.error(`Usage: prismic slice add-field group <slice-id> <field-id>`),process.exitCode=1;return}if(!c){console.error(`Missing required argument: field-id
|
|
1744
|
+
`),console.error(`Usage: prismic slice add-field group <slice-id> <field-id>`),process.exitCode=1;return}if(c.includes(`.`)){console.error(`Groups cannot be nested inside other groups`),process.exitCode=1;return}let l=await H(o);if(!l.ok){console.error(l.error),process.exitCode=1;return}let{model:u,modelPath:d}=l;if(u.variations.length===0){console.error(`Slice "${o}" has no variations.\n`),console.error(`Add a variation first before adding fields.`),process.exitCode=1;return}let f=n?u.variations.find(e=>e.id===n):u.variations[0];if(!f){console.error(`Variation "${n}" not found in slice "${o}"\n`),console.error(`Available variations: ${u.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}f.primary||={};for(let e of u.variations)if(e.primary?.[c]){console.error(`Field "${c}" already exists in variation "${e.id}"`),process.exitCode=1;return}let p={type:`Group`,config:{label:r??Y(c),repeat:!i,fields:{}}};f.primary[c]=p;try{await s(d,J(u))}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 "${c}" (Group) to "${f.id}" variation in ${o}`);try{await U({output:a}),console.info(`Updated types in ${a??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info(`Next: Add fields to the group with \`prismic slice add-field <type> ${o} ${c}.<field-id>\``);let m=await $();if(m?.framework){let e=ds(m.framework),t=fs(m.framework);console.info(` Run \`prismic docs ${e}${t}\` to learn how to implement the slice's component`)}}function ms(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}function hs(e){switch(e){case`nuxt`:return`#write-vue-components`;case`sveltekit`:return`#write-svelte-components`;default:return`#write-react-components`}}async function gs(){let{values:{help:t,variation:n,label:r,types:i},positionals:[a,o]}=e({args:process.argv.slice(5),options:{variation:{type:`string`,short:`v`},label:{type:`string`,short:`l`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add an image field to an existing slice.
|
|
1622
1745
|
|
|
1623
1746
|
USAGE
|
|
1624
1747
|
prismic slice add-field image <slice-id> <field-id> [flags]
|
|
@@ -1630,14 +1753,15 @@ ARGUMENTS
|
|
|
1630
1753
|
FLAGS
|
|
1631
1754
|
-v, --variation string Target variation (default: first variation)
|
|
1632
1755
|
-l, --label string Display label for the field (inferred from field-id if omitted)
|
|
1756
|
+
--types string Output file for generated types (default: "prismicio-types.d.ts")
|
|
1633
1757
|
-h, --help Show help for command
|
|
1634
1758
|
|
|
1635
1759
|
EXAMPLES
|
|
1636
1760
|
prismic slice add-field image my_slice background
|
|
1637
1761
|
prismic slice add-field image hero banner --label "Hero Banner"
|
|
1638
|
-
prismic slice add-field image gallery thumbnail --variation "grid"`);return}if(!
|
|
1639
|
-
`),console.error(`Usage: prismic slice add-field image <slice-id> <field-id>`),process.exitCode=1;return}if(!
|
|
1640
|
-
`),console.error(`Usage: prismic slice add-field image <slice-id> <field-id>`),process.exitCode=1;return}let o=await
|
|
1762
|
+
prismic slice add-field image gallery thumbnail --variation "grid"`);return}if(!a){console.error(`Missing required argument: slice-id
|
|
1763
|
+
`),console.error(`Usage: prismic slice add-field image <slice-id> <field-id>`),process.exitCode=1;return}if(!o){console.error(`Missing required argument: field-id
|
|
1764
|
+
`),console.error(`Usage: prismic slice add-field image <slice-id> <field-id>`),process.exitCode=1;return}let c=W(o),l=q(c);if(!l.ok){console.error(l.error),process.exitCode=1;return}let u=await H(a);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 "${a}" 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 "${a}"\n`),console.error(`Available variations: ${d.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}p.primary||={};let m={type:`Image`,config:{label:r??Y(c.type===`nested`?c.nestedFieldId:o)}};if(c.type===`nested`){let e=Zn(p.primary,c.groupId,p.id);if(!e.ok){console.error(e.error),process.exitCode=1;return}if(e.group.config.fields[c.nestedFieldId]){console.error(`Field "${c.nestedFieldId}" already exists in group "${c.groupId}"`),process.exitCode=1;return}e.group.config.fields[c.nestedFieldId]=m}else{for(let e of d.variations){if(e.primary?.[o]){console.error(`Field "${o}" already exists in variation "${e.id}"`),process.exitCode=1;return}for(let[t,n]of Object.entries(e.primary??{}))if(G(n)&&n.config.fields[o]){console.error(`Field "${o}" already exists in group "${t}" in variation "${e.id}"`),process.exitCode=1;return}}p.primary[o]=m}try{await s(f,J(d))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}c.type===`nested`?console.info(`Added field "${c.nestedFieldId}" (Image) to group "${c.groupId}" in ${a}`):console.info(`Added field "${o}" (Image) to "${p.id}" variation in ${a}`);try{await U({output:i}),console.info(`Updated types in ${i??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic slice add-field`");let h=await $();if(h?.framework){let e=ms(h.framework),t=hs(h.framework);console.info(` Run \`prismic docs ${e}${t}\` to learn how to implement the slice's component`)}}function _s(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}function vs(e){switch(e){case`nuxt`:return`#write-vue-components`;case`sveltekit`:return`#write-svelte-components`;default:return`#write-react-components`}}async function ys(){let{values:{help:t,variation:n,label:r,placeholder:i,types:a},positionals:[o,c]}=e({args:process.argv.slice(5),options:{variation:{type:`string`,short:`v`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a key-text (single-line text) field to an existing slice.
|
|
1641
1765
|
|
|
1642
1766
|
USAGE
|
|
1643
1767
|
prismic slice add-field key-text <slice-id> <field-id> [flags]
|
|
@@ -1650,14 +1774,15 @@ FLAGS
|
|
|
1650
1774
|
-v, --variation string Target variation (default: first variation)
|
|
1651
1775
|
-l, --label string Display label for the field (inferred from field-id if omitted)
|
|
1652
1776
|
-p, --placeholder string Placeholder text
|
|
1777
|
+
--types string Output file for generated types (default: "prismicio-types.d.ts")
|
|
1653
1778
|
-h, --help Show help for command
|
|
1654
1779
|
|
|
1655
1780
|
EXAMPLES
|
|
1656
1781
|
prismic slice add-field key-text my_slice title
|
|
1657
1782
|
prismic slice add-field key-text hero heading --label "Heading"
|
|
1658
|
-
prismic slice add-field key-text cta button_text --placeholder "Enter button text"`);return}if(!
|
|
1659
|
-
`),console.error(`Usage: prismic slice add-field key-text <slice-id> <field-id>`),process.exitCode=1;return}if(!
|
|
1660
|
-
`),console.error(`Usage: prismic slice add-field key-text <slice-id> <field-id>`),process.exitCode=1;return}let c=await
|
|
1783
|
+
prismic slice add-field key-text cta button_text --placeholder "Enter button text"`);return}if(!o){console.error(`Missing required argument: slice-id
|
|
1784
|
+
`),console.error(`Usage: prismic slice add-field key-text <slice-id> <field-id>`),process.exitCode=1;return}if(!c){console.error(`Missing required argument: field-id
|
|
1785
|
+
`),console.error(`Usage: prismic slice add-field key-text <slice-id> <field-id>`),process.exitCode=1;return}let l=W(c),u=q(l);if(!u.ok){console.error(u.error),process.exitCode=1;return}let d=await H(o);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 "${o}" 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 "${o}"\n`),console.error(`Available variations: ${f.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}m.primary||={};let h={type:`Text`,config:{label:r??Y(l.type===`nested`?l.nestedFieldId:c),...i&&{placeholder:i}}};if(l.type===`nested`){let e=Zn(m.primary,l.groupId,m.id);if(!e.ok){console.error(e.error),process.exitCode=1;return}if(e.group.config.fields[l.nestedFieldId]){console.error(`Field "${l.nestedFieldId}" already exists in group "${l.groupId}"`),process.exitCode=1;return}e.group.config.fields[l.nestedFieldId]=h}else{for(let e of f.variations){if(e.primary?.[c]){console.error(`Field "${c}" already exists in variation "${e.id}"`),process.exitCode=1;return}for(let[t,n]of Object.entries(e.primary??{}))if(G(n)&&n.config.fields[c]){console.error(`Field "${c}" already exists in group "${t}" in variation "${e.id}"`),process.exitCode=1;return}}m.primary[c]=h}try{await s(p,J(f))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}l.type===`nested`?console.info(`Added field "${l.nestedFieldId}" (Text) to group "${l.groupId}" in ${o}`):console.info(`Added field "${c}" (Text) to "${m.id}" variation in ${o}`);try{await U({output:a}),console.info(`Updated types in ${a??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic slice add-field`");let g=await $();if(g?.framework){let e=_s(g.framework),t=vs(g.framework);console.info(` Run \`prismic docs ${e}${t}\` to learn how to implement the slice's component`)}}function bs(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}function xs(e){switch(e){case`nuxt`:return`#write-vue-components`;case`sveltekit`:return`#write-svelte-components`;default:return`#write-react-components`}}async function Ss(){let{values:{help:t,variation:n,label:r,placeholder:i,"allow-text":a,"allow-target-blank":o,repeatable:c,types:l},positionals:[u,d]}=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`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a link field to an existing slice.
|
|
1661
1786
|
|
|
1662
1787
|
USAGE
|
|
1663
1788
|
prismic slice add-field link <slice-id> <field-id> [flags]
|
|
@@ -1673,15 +1798,16 @@ FLAGS
|
|
|
1673
1798
|
--allow-text Allow text with link
|
|
1674
1799
|
--allow-target-blank Allow opening link in new tab
|
|
1675
1800
|
--repeatable Allow multiple links
|
|
1801
|
+
--types string Output file for generated types (default: "prismicio-types.d.ts")
|
|
1676
1802
|
-h, --help Show help for command
|
|
1677
1803
|
|
|
1678
1804
|
EXAMPLES
|
|
1679
1805
|
prismic slice add-field link my_slice button
|
|
1680
1806
|
prismic slice add-field link cta primary_link --allow-text
|
|
1681
1807
|
prismic slice add-field link navigation links --repeatable
|
|
1682
|
-
prismic slice add-field link hero cta --allow-text --allow-target-blank`);return}if(!
|
|
1683
|
-
`),console.error(`Usage: prismic slice add-field link <slice-id> <field-id>`),process.exitCode=1;return}if(!
|
|
1684
|
-
`),console.error(`Usage: prismic slice add-field link <slice-id> <field-id>`),process.exitCode=1;return}let d=await
|
|
1808
|
+
prismic slice add-field link hero cta --allow-text --allow-target-blank`);return}if(!u){console.error(`Missing required argument: slice-id
|
|
1809
|
+
`),console.error(`Usage: prismic slice add-field link <slice-id> <field-id>`),process.exitCode=1;return}if(!d){console.error(`Missing required argument: field-id
|
|
1810
|
+
`),console.error(`Usage: prismic slice add-field link <slice-id> <field-id>`),process.exitCode=1;return}let f=W(d),p=q(f);if(!p.ok){console.error(p.error),process.exitCode=1;return}let m=await H(u);if(!m.ok){console.error(m.error),process.exitCode=1;return}let{model:h,modelPath:g}=m;if(h.variations.length===0){console.error(`Slice "${u}" has no variations.\n`),console.error(`Add a variation first before adding fields.`),process.exitCode=1;return}let _=n?h.variations.find(e=>e.id===n):h.variations[0];if(!_){console.error(`Variation "${n}" not found in slice "${u}"\n`),console.error(`Available variations: ${h.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}_.primary||={};let v={type:`Link`,config:{label:r??Y(f.type===`nested`?f.nestedFieldId:d),...i&&{placeholder:i},...a&&{allowText:!0},...o&&{allowTargetBlank:!0},...c&&{repeat:!0}}};if(f.type===`nested`){let e=Zn(_.primary,f.groupId,_.id);if(!e.ok){console.error(e.error),process.exitCode=1;return}if(e.group.config.fields[f.nestedFieldId]){console.error(`Field "${f.nestedFieldId}" already exists in group "${f.groupId}"`),process.exitCode=1;return}e.group.config.fields[f.nestedFieldId]=v}else{for(let e of h.variations){if(e.primary?.[d]){console.error(`Field "${d}" already exists in variation "${e.id}"`),process.exitCode=1;return}for(let[t,n]of Object.entries(e.primary??{}))if(G(n)&&n.config.fields[d]){console.error(`Field "${d}" already exists in group "${t}" in variation "${e.id}"`),process.exitCode=1;return}}_.primary[d]=v}try{await s(g,J(h))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}f.type===`nested`?console.info(`Added field "${f.nestedFieldId}" (Link) to group "${f.groupId}" in ${u}`):console.info(`Added field "${d}" (Link) to "${_.id}" variation in ${u}`);try{await U({output:l}),console.info(`Updated types in ${l??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic slice add-field`");let y=await $();if(y?.framework){let e=bs(y.framework),t=xs(y.framework);console.info(` Run \`prismic docs ${e}${t}\` to learn how to implement the slice's component`)}}function Cs(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}function ws(e){switch(e){case`nuxt`:return`#write-vue-components`;case`sveltekit`:return`#write-svelte-components`;default:return`#write-react-components`}}async function Ts(){let{values:{help:t,variation:n,label:r,placeholder:i,types:a},positionals:[o,c]}=e({args:process.argv.slice(5),options:{variation:{type:`string`,short:`v`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a number field to an existing slice.
|
|
1685
1811
|
|
|
1686
1812
|
USAGE
|
|
1687
1813
|
prismic slice add-field number <slice-id> <field-id> [flags]
|
|
@@ -1694,14 +1820,15 @@ FLAGS
|
|
|
1694
1820
|
-v, --variation string Target variation (default: first variation)
|
|
1695
1821
|
-l, --label string Display label for the field (inferred from field-id if omitted)
|
|
1696
1822
|
-p, --placeholder string Placeholder text
|
|
1823
|
+
--types string Output file for generated types (default: "prismicio-types.d.ts")
|
|
1697
1824
|
-h, --help Show help for command
|
|
1698
1825
|
|
|
1699
1826
|
EXAMPLES
|
|
1700
1827
|
prismic slice add-field number my_slice price
|
|
1701
1828
|
prismic slice add-field number product quantity --label "Quantity"
|
|
1702
|
-
prismic slice add-field number stats count --variation "detailed"`);return}if(!
|
|
1703
|
-
`),console.error(`Usage: prismic slice add-field number <slice-id> <field-id>`),process.exitCode=1;return}if(!
|
|
1704
|
-
`),console.error(`Usage: prismic slice add-field number <slice-id> <field-id>`),process.exitCode=1;return}let c=await
|
|
1829
|
+
prismic slice add-field number stats count --variation "detailed"`);return}if(!o){console.error(`Missing required argument: slice-id
|
|
1830
|
+
`),console.error(`Usage: prismic slice add-field number <slice-id> <field-id>`),process.exitCode=1;return}if(!c){console.error(`Missing required argument: field-id
|
|
1831
|
+
`),console.error(`Usage: prismic slice add-field number <slice-id> <field-id>`),process.exitCode=1;return}let l=W(c),u=q(l);if(!u.ok){console.error(u.error),process.exitCode=1;return}let d=await H(o);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 "${o}" 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 "${o}"\n`),console.error(`Available variations: ${f.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}m.primary||={};let h={type:`Number`,config:{label:r??Y(l.type===`nested`?l.nestedFieldId:c),...i&&{placeholder:i}}};if(l.type===`nested`){let e=Zn(m.primary,l.groupId,m.id);if(!e.ok){console.error(e.error),process.exitCode=1;return}if(e.group.config.fields[l.nestedFieldId]){console.error(`Field "${l.nestedFieldId}" already exists in group "${l.groupId}"`),process.exitCode=1;return}e.group.config.fields[l.nestedFieldId]=h}else{for(let e of f.variations){if(e.primary?.[c]){console.error(`Field "${c}" already exists in variation "${e.id}"`),process.exitCode=1;return}for(let[t,n]of Object.entries(e.primary??{}))if(G(n)&&n.config.fields[c]){console.error(`Field "${c}" already exists in group "${t}" in variation "${e.id}"`),process.exitCode=1;return}}m.primary[c]=h}try{await s(p,J(f))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}l.type===`nested`?console.info(`Added field "${l.nestedFieldId}" (Number) to group "${l.groupId}" in ${o}`):console.info(`Added field "${c}" (Number) to "${m.id}" variation in ${o}`);try{await U({output:a}),console.info(`Updated types in ${a??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic slice add-field`");let g=await $();if(g?.framework){let e=Cs(g.framework),t=ws(g.framework);console.info(` Run \`prismic docs ${e}${t}\` to learn how to implement the slice's component`)}}function Es(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}function Ds(e){switch(e){case`nuxt`:return`#write-vue-components`;case`sveltekit`:return`#write-svelte-components`;default:return`#write-react-components`}}async function Os(){let{values:{help:t,variation:n,label:r,placeholder:i,single:a,multi:o,"allow-target-blank":c,types:l},positionals:[u,d]}=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`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a rich text field to an existing slice.
|
|
1705
1832
|
|
|
1706
1833
|
USAGE
|
|
1707
1834
|
prismic slice add-field rich-text <slice-id> <field-id> [flags]
|
|
@@ -1717,6 +1844,7 @@ FLAGS
|
|
|
1717
1844
|
--single string Allowed block types for single-line (comma-separated)
|
|
1718
1845
|
--multi string Allowed block types for multi-line (comma-separated)
|
|
1719
1846
|
--allow-target-blank Allow opening links in new tab
|
|
1847
|
+
--types string Output file for generated types (default: "prismicio-types.d.ts")
|
|
1720
1848
|
-h, --help Show help for command
|
|
1721
1849
|
|
|
1722
1850
|
BLOCK TYPES
|
|
@@ -1728,9 +1856,9 @@ EXAMPLES
|
|
|
1728
1856
|
prismic slice add-field rich-text my_slice body
|
|
1729
1857
|
prismic slice add-field rich-text article content --multi "paragraph,heading2,heading3,strong,em,hyperlink"
|
|
1730
1858
|
prismic slice add-field rich-text hero tagline --single "heading1"
|
|
1731
|
-
prismic slice add-field rich-text blog post --multi "paragraph,strong,em,hyperlink" --allow-target-blank`);return}if(!
|
|
1732
|
-
`),console.error(`Usage: prismic slice add-field rich-text <slice-id> <field-id>`),process.exitCode=1;return}if(!
|
|
1733
|
-
`),console.error(`Usage: prismic slice add-field rich-text <slice-id> <field-id>`),process.exitCode=1;return}let d=await
|
|
1859
|
+
prismic slice add-field rich-text blog post --multi "paragraph,strong,em,hyperlink" --allow-target-blank`);return}if(!u){console.error(`Missing required argument: slice-id
|
|
1860
|
+
`),console.error(`Usage: prismic slice add-field rich-text <slice-id> <field-id>`),process.exitCode=1;return}if(!d){console.error(`Missing required argument: field-id
|
|
1861
|
+
`),console.error(`Usage: prismic slice add-field rich-text <slice-id> <field-id>`),process.exitCode=1;return}let f=W(d),p=q(f);if(!p.ok){console.error(p.error),process.exitCode=1;return}let m=await H(u);if(!m.ok){console.error(m.error),process.exitCode=1;return}let{model:h,modelPath:g}=m;if(h.variations.length===0){console.error(`Slice "${u}" has no variations.\n`),console.error(`Add a variation first before adding fields.`),process.exitCode=1;return}let _=n?h.variations.find(e=>e.id===n):h.variations[0];if(!_){console.error(`Variation "${n}" not found in slice "${u}"\n`),console.error(`Available variations: ${h.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}_.primary||={};let v={type:`StructuredText`,config:{label:r??Y(f.type===`nested`?f.nestedFieldId:d),...i&&{placeholder:i},...a&&{single:a},...o&&{multi:o},...c&&{allowTargetBlank:!0}}};if(f.type===`nested`){let e=Zn(_.primary,f.groupId,_.id);if(!e.ok){console.error(e.error),process.exitCode=1;return}if(e.group.config.fields[f.nestedFieldId]){console.error(`Field "${f.nestedFieldId}" already exists in group "${f.groupId}"`),process.exitCode=1;return}e.group.config.fields[f.nestedFieldId]=v}else{for(let e of h.variations){if(e.primary?.[d]){console.error(`Field "${d}" already exists in variation "${e.id}"`),process.exitCode=1;return}for(let[t,n]of Object.entries(e.primary??{}))if(G(n)&&n.config.fields[d]){console.error(`Field "${d}" already exists in group "${t}" in variation "${e.id}"`),process.exitCode=1;return}}_.primary[d]=v}try{await s(g,J(h))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}f.type===`nested`?console.info(`Added field "${f.nestedFieldId}" (StructuredText) to group "${f.groupId}" in ${u}`):console.info(`Added field "${d}" (StructuredText) to "${_.id}" variation in ${u}`);try{await U({output:l}),console.info(`Updated types in ${l??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic slice add-field`");let y=await $();if(y?.framework){let e=Es(y.framework),t=Ds(y.framework);console.info(` Run \`prismic docs ${e}${t}\` to learn how to implement the slice's component`)}}function ks(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}function As(e){switch(e){case`nuxt`:return`#write-vue-components`;case`sveltekit`:return`#write-svelte-components`;default:return`#write-react-components`}}async function js(){let{values:{help:t,variation:n,label:r,placeholder:i,option:a,default:o,types: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`},option:{type:`string`,multiple:!0},default:{type:`string`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a select (dropdown) field to an existing slice.
|
|
1734
1862
|
|
|
1735
1863
|
USAGE
|
|
1736
1864
|
prismic slice add-field select <slice-id> <field-id> [flags]
|
|
@@ -1745,14 +1873,15 @@ FLAGS
|
|
|
1745
1873
|
-p, --placeholder string Placeholder text
|
|
1746
1874
|
--option string Add an option (can be used multiple times)
|
|
1747
1875
|
--default string Default selected value
|
|
1876
|
+
--types string Output file for generated types (default: "prismicio-types.d.ts")
|
|
1748
1877
|
-h, --help Show help for command
|
|
1749
1878
|
|
|
1750
1879
|
EXAMPLES
|
|
1751
1880
|
prismic slice add-field select my_slice layout --option "full" --option "sidebar"
|
|
1752
1881
|
prismic slice add-field select hero style --option "light" --option "dark" --default "light"
|
|
1753
|
-
prismic slice add-field select product size --option "small" --option "medium" --option "large" --label "Size"`);return}if(!
|
|
1754
|
-
`),console.error(`Usage: prismic slice add-field select <slice-id> <field-id>`),process.exitCode=1;return}if(!
|
|
1755
|
-
`),console.error(`Usage: prismic slice add-field select <slice-id> <field-id>`),process.exitCode=1;return}let u=await
|
|
1882
|
+
prismic slice add-field select product size --option "small" --option "medium" --option "large" --label "Size"`);return}if(!l){console.error(`Missing required argument: slice-id
|
|
1883
|
+
`),console.error(`Usage: prismic slice add-field select <slice-id> <field-id>`),process.exitCode=1;return}if(!u){console.error(`Missing required argument: field-id
|
|
1884
|
+
`),console.error(`Usage: prismic slice add-field select <slice-id> <field-id>`),process.exitCode=1;return}let d=W(u),f=q(d);if(!f.ok){console.error(f.error),process.exitCode=1;return}let p=await H(l);if(!p.ok){console.error(p.error),process.exitCode=1;return}let{model:m,modelPath:h}=p;if(m.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 g=n?m.variations.find(e=>e.id===n):m.variations[0];if(!g){console.error(`Variation "${n}" not found in slice "${l}"\n`),console.error(`Available variations: ${m.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}g.primary||={};let _={type:`Select`,config:{label:r??Y(d.type===`nested`?d.nestedFieldId:u),...i&&{placeholder:i},...a&&a.length>0&&{options:a},...o&&{default_value:o}}};if(d.type===`nested`){let e=Zn(g.primary,d.groupId,g.id);if(!e.ok){console.error(e.error),process.exitCode=1;return}if(e.group.config.fields[d.nestedFieldId]){console.error(`Field "${d.nestedFieldId}" already exists in group "${d.groupId}"`),process.exitCode=1;return}e.group.config.fields[d.nestedFieldId]=_}else{for(let e of m.variations){if(e.primary?.[u]){console.error(`Field "${u}" already exists in variation "${e.id}"`),process.exitCode=1;return}for(let[t,n]of Object.entries(e.primary??{}))if(G(n)&&n.config.fields[u]){console.error(`Field "${u}" already exists in group "${t}" in variation "${e.id}"`),process.exitCode=1;return}}g.primary[u]=_}try{await s(h,J(m))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}d.type===`nested`?console.info(`Added field "${d.nestedFieldId}" (Select) to group "${d.groupId}" in ${l}`):console.info(`Added field "${u}" (Select) to "${g.id}" variation in ${l}`);try{await U({output:c}),console.info(`Updated types in ${c??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic slice add-field`");let v=await $();if(v?.framework){let e=ks(v.framework),t=As(v.framework);console.info(` Run \`prismic docs ${e}${t}\` to learn how to implement the slice's component`)}}function Ms(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}function Ns(e){switch(e){case`nuxt`:return`#write-vue-components`;case`sveltekit`:return`#write-svelte-components`;default:return`#write-react-components`}}async function Ps(){let{values:{help:t,variation:n,label:r,placeholder:i,types:a},positionals:[o,c]}=e({args:process.argv.slice(5),options:{variation:{type:`string`,short:`v`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a timestamp (date and time) field to an existing slice.
|
|
1756
1885
|
|
|
1757
1886
|
USAGE
|
|
1758
1887
|
prismic slice add-field timestamp <slice-id> <field-id> [flags]
|
|
@@ -1765,14 +1894,15 @@ FLAGS
|
|
|
1765
1894
|
-v, --variation string Target variation (default: first variation)
|
|
1766
1895
|
-l, --label string Display label for the field (inferred from field-id if omitted)
|
|
1767
1896
|
-p, --placeholder string Placeholder text
|
|
1897
|
+
--types string Output file for generated types (default: "prismicio-types.d.ts")
|
|
1768
1898
|
-h, --help Show help for command
|
|
1769
1899
|
|
|
1770
1900
|
EXAMPLES
|
|
1771
1901
|
prismic slice add-field timestamp my_slice created_at
|
|
1772
1902
|
prismic slice add-field timestamp event start_time --label "Event Start"
|
|
1773
|
-
prismic slice add-field timestamp schedule meeting_time --variation "detailed"`);return}if(!
|
|
1774
|
-
`),console.error(`Usage: prismic slice add-field timestamp <slice-id> <field-id>`),process.exitCode=1;return}if(!
|
|
1775
|
-
`),console.error(`Usage: prismic slice add-field timestamp <slice-id> <field-id>`),process.exitCode=1;return}let c=await
|
|
1903
|
+
prismic slice add-field timestamp schedule meeting_time --variation "detailed"`);return}if(!o){console.error(`Missing required argument: slice-id
|
|
1904
|
+
`),console.error(`Usage: prismic slice add-field timestamp <slice-id> <field-id>`),process.exitCode=1;return}if(!c){console.error(`Missing required argument: field-id
|
|
1905
|
+
`),console.error(`Usage: prismic slice add-field timestamp <slice-id> <field-id>`),process.exitCode=1;return}let l=W(c),u=q(l);if(!u.ok){console.error(u.error),process.exitCode=1;return}let d=await H(o);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 "${o}" 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 "${o}"\n`),console.error(`Available variations: ${f.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}m.primary||={};let h={type:`Timestamp`,config:{label:r??Y(l.type===`nested`?l.nestedFieldId:c),...i&&{placeholder:i}}};if(l.type===`nested`){let e=Zn(m.primary,l.groupId,m.id);if(!e.ok){console.error(e.error),process.exitCode=1;return}if(e.group.config.fields[l.nestedFieldId]){console.error(`Field "${l.nestedFieldId}" already exists in group "${l.groupId}"`),process.exitCode=1;return}e.group.config.fields[l.nestedFieldId]=h}else{for(let e of f.variations){if(e.primary?.[c]){console.error(`Field "${c}" already exists in variation "${e.id}"`),process.exitCode=1;return}for(let[t,n]of Object.entries(e.primary??{}))if(G(n)&&n.config.fields[c]){console.error(`Field "${c}" already exists in group "${t}" in variation "${e.id}"`),process.exitCode=1;return}}m.primary[c]=h}try{await s(p,J(f))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}l.type===`nested`?console.info(`Added field "${l.nestedFieldId}" (Timestamp) to group "${l.groupId}" in ${o}`):console.info(`Added field "${c}" (Timestamp) to "${m.id}" variation in ${o}`);try{await U({output:a}),console.info(`Updated types in ${a??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic slice add-field`");let g=await $();if(g?.framework){let e=Ms(g.framework),t=Ns(g.framework);console.info(` Run \`prismic docs ${e}${t}\` to learn how to implement the slice's component`)}}async function Fs(){let{positionals:[t]}=e({args:process.argv.slice(4),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`boolean`:await Qo();break;case`color`:await ts();break;case`date`:await is();break;case`embed`:await ss();break;case`geo-point`:await us();break;case`group`:await ps();break;case`image`:await gs();break;case`key-text`:await ys();break;case`link`:await Ss();break;case`number`:await Ts();break;case`rich-text`:await Os();break;case`select`:await js();break;case`timestamp`:await Ps();break;default:t&&(console.error(`Unknown field type: ${t}\n`),process.exitCode=1),console.info(`Add a field to an existing slice.
|
|
1776
1906
|
|
|
1777
1907
|
USAGE
|
|
1778
1908
|
prismic slice add-field <field-type> <slice-id> <field-id> [flags]
|
|
@@ -1783,6 +1913,7 @@ FIELD TYPES
|
|
|
1783
1913
|
date Date picker
|
|
1784
1914
|
embed Embed (oEmbed)
|
|
1785
1915
|
geo-point Geographic coordinates
|
|
1916
|
+
group Repeatable group of fields
|
|
1786
1917
|
image Image
|
|
1787
1918
|
key-text Single-line text
|
|
1788
1919
|
link Any link type
|
|
@@ -1801,7 +1932,7 @@ EXAMPLES
|
|
|
1801
1932
|
prismic slice add-field key-text my_slice title --label "Title"
|
|
1802
1933
|
prismic slice add-field link my_slice cta --allow-text
|
|
1803
1934
|
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
|
|
1935
|
+
prismic slice add-field select my_slice layout --option "full" --option "sidebar"`)}}async function Is(){let{values:{help:t,name:n,"copy-from":r,types:i},positionals:[a,o]}=e({args:process.argv.slice(4),options:{name:{type:`string`},"copy-from":{type:`string`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a new variation to a slice.
|
|
1805
1936
|
|
|
1806
1937
|
USAGE
|
|
1807
1938
|
prismic slice add-variation <slice-id> <variation-id> [flags]
|
|
@@ -1813,14 +1944,34 @@ ARGUMENTS
|
|
|
1813
1944
|
FLAGS
|
|
1814
1945
|
--name string Display name for the variation
|
|
1815
1946
|
--copy-from string Copy fields from an existing variation
|
|
1947
|
+
--types string Output file for generated types (default: "prismicio-types.d.ts")
|
|
1816
1948
|
-h, --help Show help for command
|
|
1817
1949
|
|
|
1818
1950
|
EXAMPLES
|
|
1819
1951
|
prismic slice add-variation MySlice withImage
|
|
1820
1952
|
prismic slice add-variation MySlice withImage --name "With Image"
|
|
1821
|
-
prismic slice add-variation MySlice withImage --copy-from default`);return}if(!
|
|
1822
|
-
`),console.error(`Usage: prismic slice add-variation <slice-id> <variation-id>`),process.exitCode=1;return}if(!
|
|
1823
|
-
`),console.error(`Usage: prismic slice add-variation <slice-id> <variation-id>`),process.exitCode=1;return}let
|
|
1953
|
+
prismic slice add-variation MySlice withImage --copy-from default`);return}if(!a){console.error(`Missing required argument: slice-id
|
|
1954
|
+
`),console.error(`Usage: prismic slice add-variation <slice-id> <variation-id>`),process.exitCode=1;return}if(!o){console.error(`Missing required argument: variation-id
|
|
1955
|
+
`),console.error(`Usage: prismic slice add-variation <slice-id> <variation-id>`),process.exitCode=1;return}let c=await H(a);if(!c.ok){console.error(c.error),process.exitCode=1;return}let{model:l,modelPath:u}=c;if(l.variations.some(e=>e.id===o)){console.error(`Variation "${o}" already exists in slice "${a}"`),process.exitCode=1;return}let d;if(r){let e=l.variations.find(e=>e.id===r);if(!e){console.error(`Source variation not found: ${r}`),console.error(`Available variations: ${l.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}d={...structuredClone(e),id:o,name:n??In(o)}}else d={id:o,name:n??In(o),description:o,imageUrl:``,docURL:``,version:`initial`,primary:{},items:{}};let f={...l,variations:[...l.variations,d]};try{await s(u,J(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 variation "${o}" to slice "${a}"`);try{await U({output:i}),console.info(`Updated types in ${i??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}}const Ls=N({uploadEndpoint:I(),requiredFormDataFields:F(I(),I()),imgixEndpoint:I()});async function Rs(e){let{data:t,repo:n,sliceId:r,variationId:i,filename:a}=e,o=await Z(`https://acl-provider.prismic.io/create`,{method:`POST`,body:{},schema:Ls});if(!o.ok)throw Error(`Failed to get upload credentials from Prismic`);let{uploadEndpoint:s,requiredFormDataFields:c,imgixEndpoint:u}=o.value,d=l(`md5`).update(t).digest(`hex`),f=m(a).toLowerCase().slice(1)||`png`,p=`${n}/shared-slices/${r}/${i}/${d}.${f}`,h=new FormData;for(let[e,t]of Object.entries(c))h.append(e,t);h.append(`key`,p),h.append(`Content-Type`,zs(f)),h.append(`file`,new Blob([new Uint8Array(t)],{type:zs(f)}),a);let g=await fetch(s,{method:`POST`,body:h});if(!g.ok){let e=await g.text();throw Error(`Failed to upload screenshot: ${e}`)}return`${u}/${p}?auto=compress,format`}function zs(e){switch(e){case`png`:return`image/png`;case`jpg`:case`jpeg`:return`image/jpeg`;case`gif`:return`image/gif`;case`webp`:return`image/webp`;default:return`image/png`}}async function Bs(){let{values:{help:t,variation:n,repo:i},positionals:[a,o]}=e({args:process.argv.slice(4),options:{variation:{type:`string`,short:`v`,default:`default`},repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Set a screenshot for a slice variation.
|
|
1956
|
+
|
|
1957
|
+
USAGE
|
|
1958
|
+
prismic slice set-screenshot <slice-id> <image-path> [flags]
|
|
1959
|
+
|
|
1960
|
+
ARGUMENTS
|
|
1961
|
+
slice-id Slice identifier (required)
|
|
1962
|
+
image-path Path to the image file (required)
|
|
1963
|
+
|
|
1964
|
+
FLAGS
|
|
1965
|
+
-v, --variation string Variation ID (default: "default")
|
|
1966
|
+
-r, --repo string Repository name (uses config if not provided)
|
|
1967
|
+
-h, --help Show help for command
|
|
1968
|
+
|
|
1969
|
+
EXAMPLES
|
|
1970
|
+
prismic slice set-screenshot MySlice ./screenshot.png
|
|
1971
|
+
prismic slice set-screenshot MySlice ./screenshot.png --variation dark
|
|
1972
|
+
prismic slice set-screenshot MySlice ./screenshot.png --repo my-repo`);return}if(!a){console.error(`Missing required argument: slice-id
|
|
1973
|
+
`),console.error(`Usage: prismic slice set-screenshot <slice-id> <image-path>`),process.exitCode=1;return}if(!o){console.error(`Missing required argument: image-path
|
|
1974
|
+
`),console.error(`Usage: prismic slice set-screenshot <slice-id> <image-path>`),process.exitCode=1;return}if(!await B()){console.error(`You must be logged in to set a screenshot.`),console.error("Run `prismic login` to authenticate."),process.exitCode=1;return}let c=i??await X();if(!c){console.error(`Could not determine repository.`),console.error(`Use --repo flag or run from a directory with prismic.config.json`),process.exitCode=1;return}let l=await H(a);if(!l.ok){console.error(l.error),process.exitCode=1;return}let{model:u,modelPath:d}=l,f=u.variations.findIndex(e=>e.id===n);if(f===-1){console.error(`Variation "${n}" not found in slice "${a}"`),console.error(`Available variations: ${u.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}let p;try{p=await r(o)}catch(e){e instanceof Error?console.error(`Failed to read image file: ${e.message}`):console.error(`Failed to read image file`),process.exitCode=1;return}let m;try{m=await Rs({data:p,repo:c,sliceId:a,variationId:n??`default`,filename:o})}catch(e){e instanceof Error?console.error(`Failed to upload screenshot: ${e.message}`):console.error(`Failed to upload screenshot`),process.exitCode=1;return}u.variations[f].imageUrl=m;try{await s(d,J(u))}catch(e){e instanceof Error?console.error(`Failed to update slice model: ${e.message}`):console.error(`Failed to update slice model`),process.exitCode=1;return}console.info(`Screenshot set for slice "${a}" variation "${n}"`),console.info(`URL: ${m}`)}async function Vs(){let{values:{help:t,name:i,types:a,screenshot:o,repo:c},positionals:[l]}=e({args:process.argv.slice(4),options:{name:{type:`string`,short:`n`},screenshot:{type:`string`},repo:{type:`string`,short:`r`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Create a new slice in a Prismic project.
|
|
1824
1975
|
|
|
1825
1976
|
USAGE
|
|
1826
1977
|
prismic slice create <id> [flags]
|
|
@@ -1829,11 +1980,14 @@ ARGUMENTS
|
|
|
1829
1980
|
id Slice identifier (required)
|
|
1830
1981
|
|
|
1831
1982
|
FLAGS
|
|
1832
|
-
-n, --name string
|
|
1833
|
-
|
|
1983
|
+
-n, --name string Display name for the slice
|
|
1984
|
+
--screenshot string Path to screenshot image for default variation
|
|
1985
|
+
-r, --repo string Repository name (required for screenshot)
|
|
1986
|
+
--types string Output file for generated types (default: "prismicio-types.d.ts")
|
|
1987
|
+
-h, --help Show help for command
|
|
1834
1988
|
|
|
1835
1989
|
LEARN MORE
|
|
1836
|
-
Use \`prismic slice <command> --help\` for more information about a command.`);return}if(!
|
|
1990
|
+
Use \`prismic slice <command> --help\` for more information about a command.`);return}if(!l){console.error(`Missing required argument: id`),process.exitCode=1;return}let u;if(o){if(!await B()){console.error(`You must be logged in to upload a screenshot.`),console.error("Run `prismic login` to authenticate."),process.exitCode=1;return}let e=c??await X();if(!e){console.error(`Could not determine repository for screenshot upload.`),console.error(`Use --repo flag or run from a directory with prismic.config.json`),process.exitCode=1;return}let t;try{t=await r(o)}catch(e){e instanceof Error?console.error(`Failed to read screenshot file: ${e.message}`):console.error(`Failed to read screenshot file`),process.exitCode=1;return}try{u=await Rs({data:t,repo:e,sliceId:l,variationId:`default`,filename:o})}catch(e){e instanceof Error?console.error(`Failed to upload screenshot: ${e.message}`):console.error(`Failed to upload screenshot`),process.exitCode=1;return}}let d={id:l,type:`SharedSlice`,name:i??Gs(l),description:``,variations:[{id:`default`,name:`Default`,description:`Default`,imageUrl:u??``,docURL:``,version:`initial`,primary:{},items:{}}]},f=await Hs(),p=new URL(Gs(d.name)+`/`,f),m=new URL(`model.json`,p);try{await n(new URL(`.`,m),{recursive:!0}),await s(m,J(d))}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 ${m.href}`);try{await U({output:a}),console.info(`Updated types in ${a??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add fields with `prismic slice add-field`")}async function Hs(){let e=await Ws(),t=await V(`package.json`);switch(e){case`next`:if(await jn(new URL(`src`,t)))return new URL(`src/slices/`,t);case`nuxt`:if(await jn(new URL(`app`,t)))return new URL(`app/slices/`,t);case`sveltekit`:return new URL(`src/slices/`,t)}return new URL(`slices/`,t)}const Us=N({dependencies:P(F(I(),I()))});async function Ws(){let e=await V(`package.json`);if(e)try{let t=await r(e,`utf8`),{dependencies:n={}}=yn(Us,JSON.parse(t));if(`next`in n)return`next`;if(`nuxt`in n)return`nuxt`;if(`@sveltejs/kit`in n)return`sveltekit`}catch{}}function Gs(e){return e.toLowerCase().replace(/(^|[-_\s]+)(.)?/g,(e,t,n)=>n?.toUpperCase()??``)}async function Ks(){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
1991
|
|
|
1838
1992
|
USAGE
|
|
1839
1993
|
prismic slice list [flags]
|
|
@@ -1844,7 +1998,7 @@ FLAGS
|
|
|
1844
1998
|
|
|
1845
1999
|
EXAMPLES
|
|
1846
2000
|
prismic slice list
|
|
1847
|
-
prismic slice list --json`);return}let a=await
|
|
2001
|
+
prismic slice list --json`);return}let a=await Nn(),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=R(Mn,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 qs(){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
2002
|
|
|
1849
2003
|
USAGE
|
|
1850
2004
|
prismic slice list-variations <slice-id> [flags]
|
|
@@ -1859,7 +2013,7 @@ FLAGS
|
|
|
1859
2013
|
EXAMPLES
|
|
1860
2014
|
prismic slice list-variations MySlice
|
|
1861
2015
|
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
|
|
2016
|
+
`),console.error(`Usage: prismic slice list-variations <slice-id>`),process.exitCode=1;return}let i=await H(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 Js(){let{values:{help:t,y:n,types:r},positionals:[i]}=e({args:process.argv.slice(4),options:{y:{type:`boolean`,short:`y`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Remove a slice from the project.
|
|
1863
2017
|
|
|
1864
2018
|
USAGE
|
|
1865
2019
|
prismic slice remove <slice-id> [flags]
|
|
@@ -1869,12 +2023,13 @@ ARGUMENTS
|
|
|
1869
2023
|
|
|
1870
2024
|
FLAGS
|
|
1871
2025
|
-y Confirm removal
|
|
2026
|
+
--types string Output file for generated types (default: "prismicio-types.d.ts")
|
|
1872
2027
|
-h, --help Show help for command
|
|
1873
2028
|
|
|
1874
2029
|
EXAMPLES
|
|
1875
2030
|
prismic slice remove MySlice
|
|
1876
|
-
prismic slice remove MySlice -y`);return}if(!
|
|
1877
|
-
`),console.error(`Usage: prismic slice remove <slice-id>`),process.exitCode=1;return}let
|
|
2031
|
+
prismic slice remove MySlice -y`);return}if(!i){console.error(`Missing required argument: slice-id
|
|
2032
|
+
`),console.error(`Usage: prismic slice remove <slice-id>`),process.exitCode=1;return}let a=await H(i);if(!a.ok){console.error(a.error),process.exitCode=1;return}let{modelPath:s}=a,c=new URL(`.`,s);if(!n){console.error(`Refusing to remove slice "${i}" (this will delete the entire directory).`),console.error(`Re-run with -y to confirm.`),process.exitCode=1;return}try{await o(c,{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 "${i}"`);try{await U({output:r}),console.info(`Updated types in ${r??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}}async function Ys(){let{values:{help:t,variation:n,zone:r,types:i},positionals:[a,o]}=e({args:process.argv.slice(4),options:{variation:{type:`string`,default:`default`},zone:{type:`string`,default:`primary`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Remove a field from a slice variation.
|
|
1878
2033
|
|
|
1879
2034
|
USAGE
|
|
1880
2035
|
prismic slice remove-field <slice-id> <field-id> [flags]
|
|
@@ -1886,14 +2041,15 @@ ARGUMENTS
|
|
|
1886
2041
|
FLAGS
|
|
1887
2042
|
--variation string Target variation (default: "default")
|
|
1888
2043
|
--zone string Field zone: "primary" or "items" (default: "primary")
|
|
2044
|
+
--types string Output file for generated types (default: "prismicio-types.d.ts")
|
|
1889
2045
|
-h, --help Show help for command
|
|
1890
2046
|
|
|
1891
2047
|
EXAMPLES
|
|
1892
2048
|
prismic slice remove-field MySlice title
|
|
1893
2049
|
prismic slice remove-field MySlice title --variation withImage
|
|
1894
|
-
prismic slice remove-field MySlice item_title --zone items`);return}if(!
|
|
1895
|
-
`),console.error(`Usage: prismic slice remove-field <slice-id> <field-id>`),process.exitCode=1;return}if(!
|
|
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
|
|
2050
|
+
prismic slice remove-field MySlice item_title --zone items`);return}if(!a){console.error(`Missing required argument: slice-id
|
|
2051
|
+
`),console.error(`Usage: prismic slice remove-field <slice-id> <field-id>`),process.exitCode=1;return}if(!o){console.error(`Missing required argument: field-id
|
|
2052
|
+
`),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 c=await H(a);if(!c.ok){console.error(c.error),process.exitCode=1;return}let{model:l,modelPath:u}=c,d=l.variations.find(e=>e.id===n);if(!d){console.error(`Variation not found: ${n}`),console.error(`Available variations: ${l.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}let f=r===`primary`?d.primary:d.items;if(!f||!(o in f)){console.error(`Field "${o}" not found in ${r} zone of variation "${n}"`),process.exitCode=1;return}delete f[o];try{await s(u,J(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(`Removed field "${o}" from ${r} zone in variation "${n}" of slice "${a}"`);try{await U({output:i}),console.info(`Updated types in ${i??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}}async function Xs(){let{values:{help:t,types:n},positionals:[r,i]}=e({args:process.argv.slice(4),options:{types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Remove a variation from a slice.
|
|
1897
2053
|
|
|
1898
2054
|
USAGE
|
|
1899
2055
|
prismic slice remove-variation <slice-id> <variation-id> [flags]
|
|
@@ -1903,12 +2059,13 @@ ARGUMENTS
|
|
|
1903
2059
|
variation-id Variation to remove (required)
|
|
1904
2060
|
|
|
1905
2061
|
FLAGS
|
|
2062
|
+
--types string Output file for generated types (default: "prismicio-types.d.ts")
|
|
1906
2063
|
-h, --help Show help for command
|
|
1907
2064
|
|
|
1908
2065
|
EXAMPLES
|
|
1909
|
-
prismic slice remove-variation MySlice withImage`);return}if(!
|
|
1910
|
-
`),console.error(`Usage: prismic slice remove-variation <slice-id> <variation-id>`),process.exitCode=1;return}if(!
|
|
1911
|
-
`),console.error(`Usage: prismic slice remove-variation <slice-id> <variation-id>`),process.exitCode=1;return}let
|
|
2066
|
+
prismic slice remove-variation MySlice withImage`);return}if(!r){console.error(`Missing required argument: slice-id
|
|
2067
|
+
`),console.error(`Usage: prismic slice remove-variation <slice-id> <variation-id>`),process.exitCode=1;return}if(!i){console.error(`Missing required argument: variation-id
|
|
2068
|
+
`),console.error(`Usage: prismic slice remove-variation <slice-id> <variation-id>`),process.exitCode=1;return}let a=await H(r);if(!a.ok){console.error(a.error),process.exitCode=1;return}let{model:o,modelPath:c}=a;if(!o.variations.some(e=>e.id===i)){console.error(`Variation not found: ${i}`),console.error(`Available variations: ${o.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}if(o.variations.length===1){console.error(`Cannot remove the last variation from a slice.`),process.exitCode=1;return}let l={...o,variations:o.variations.filter(e=>e.id!==i)};try{await s(c,J(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(`Removed variation "${i}" from slice "${r}"`);try{await U({output:n}),console.info(`Updated types in ${n??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}}async function Zs(){let{values:{help:t,id:n,types:r},positionals:[i,o]}=e({args:process.argv.slice(4),options:{id:{type:`string`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Rename a slice (updates name field, optionally id and directory).
|
|
1912
2069
|
|
|
1913
2070
|
USAGE
|
|
1914
2071
|
prismic slice rename <slice-id> <new-name> [flags]
|
|
@@ -1919,13 +2076,14 @@ ARGUMENTS
|
|
|
1919
2076
|
|
|
1920
2077
|
FLAGS
|
|
1921
2078
|
--id string Also change the slice ID (renames directory)
|
|
2079
|
+
--types string Output file for generated types (default: "prismicio-types.d.ts")
|
|
1922
2080
|
-h, --help Show help for command
|
|
1923
2081
|
|
|
1924
2082
|
EXAMPLES
|
|
1925
2083
|
prismic slice rename MySlice "My New Name"
|
|
1926
|
-
prismic slice rename MySlice "My New Name" --id NewSliceId`);return}if(!
|
|
1927
|
-
`),console.error(`Usage: prismic slice rename <slice-id> <new-name>`),process.exitCode=1;return}if(!
|
|
1928
|
-
`),console.error(`Usage: prismic slice rename <slice-id> <new-name>`),process.exitCode=1;return}let
|
|
2084
|
+
prismic slice rename MySlice "My New Name" --id NewSliceId`);return}if(!i){console.error(`Missing required argument: slice-id
|
|
2085
|
+
`),console.error(`Usage: prismic slice rename <slice-id> <new-name>`),process.exitCode=1;return}if(!o){console.error(`Missing required argument: new-name
|
|
2086
|
+
`),console.error(`Usage: prismic slice rename <slice-id> <new-name>`),process.exitCode=1;return}let c=await H(i);if(!c.ok){console.error(c.error),process.exitCode=1;return}let{model:l,modelPath:u}=c;l.name=o,n&&(l.id=n);try{await s(u,J(l))}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 Nn(),t=new URL(`.`,u),r=new URL(In(o)+`/`,e);if(t.href!==r.href)try{await a(t,r),console.info(`Renamed slice "${i}" to "${n}" (${o})`),console.info(`Moved directory to ${r.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 "${i}" to "${n}" (${o})`)}else console.info(`Renamed slice "${i}" to "${o}"`);try{await U({output:r}),console.info(`Updated types in ${r??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}}async function Qs(){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
2087
|
|
|
1930
2088
|
USAGE
|
|
1931
2089
|
prismic slice view <slice-id> [flags]
|
|
@@ -1940,8 +2098,8 @@ FLAGS
|
|
|
1940
2098
|
EXAMPLES
|
|
1941
2099
|
prismic slice view MySlice
|
|
1942
2100
|
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
|
|
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
|
|
2101
|
+
`),console.error(`Usage: prismic slice view <slice-id>`),process.exitCode=1;return}let i=await H(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(`
|
|
2102
|
+
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`),e.imageUrl&&console.info(` Screenshot: ${e.imageUrl}`)}}async function $s(){let{positionals:[t]}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`create`:await Vs();break;case`list`:await Ks();break;case`view`:await Qs();break;case`rename`:await Zs();break;case`remove`:await Js();break;case`add-field`:await Fs();break;case`remove-field`:await Ys();break;case`add-variation`:await Is();break;case`remove-variation`:await Xs();break;case`list-variations`:await qs();break;case`set-screenshot`:await Bs();break;default:t&&(console.error(`Unknown slice subcommand: ${t}\n`),process.exitCode=1),console.info(`Manage slices in a Prismic project.
|
|
1945
2103
|
|
|
1946
2104
|
USAGE
|
|
1947
2105
|
prismic slice <command> [flags]
|
|
@@ -1957,12 +2115,45 @@ COMMANDS
|
|
|
1957
2115
|
add-variation Add a variation to a slice
|
|
1958
2116
|
remove-variation Remove a variation from a slice
|
|
1959
2117
|
list-variations List all variations of a slice
|
|
2118
|
+
set-screenshot Set a screenshot for a slice variation
|
|
1960
2119
|
|
|
1961
2120
|
FLAGS
|
|
1962
2121
|
-h, --help Show help for command
|
|
1963
2122
|
|
|
1964
2123
|
LEARN MORE
|
|
1965
|
-
Use \`prismic slice <command> --help\` for more information about a command.`)}}async function
|
|
2124
|
+
Use \`prismic slice <command> --help\` for more information about a command.`)}}const ec={documentsPublished:`document.published`,documentsUnpublished:`document.unpublished`,releasesCreated:`release.created`,releasesUpdated:`release.updated`,tagsCreated:`tag.created`,tagsDeleted:`tag.deleted`};async function tc(){let{values:{help:t,repo:n=await X()},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.
|
|
2125
|
+
|
|
2126
|
+
By default, this command reads the repository from prismic.config.json at the
|
|
2127
|
+
project root.
|
|
2128
|
+
|
|
2129
|
+
USAGE
|
|
2130
|
+
prismic webhook view <url> [flags]
|
|
2131
|
+
|
|
2132
|
+
ARGUMENTS
|
|
2133
|
+
<url> Webhook URL
|
|
2134
|
+
|
|
2135
|
+
FLAGS
|
|
2136
|
+
-r, --repo string Repository domain
|
|
2137
|
+
-h, --help Show help for command
|
|
2138
|
+
|
|
2139
|
+
LEARN MORE
|
|
2140
|
+
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 B()){nc();return}let i=await ic(n);if(!i.ok){i.error instanceof Q?nc():(console.error(`Failed to view webhook: ${J(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(ec))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 nc(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}const rc=N({config:N({_id:I(),url:I(),active:M(),name:_n(I()),secret:_n(I()),headers:F(I(),I()),documentsPublished:M(),documentsUnpublished:M(),releasesCreated:M(),releasesUpdated:M(),tagsCreated:M(),tagsDeleted:M()})});async function ic(e){return await Z(new URL(`/app/settings/webhooks`,await z(e)),{schema:j(rc)})}function ac(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`;default:return``}}function oc(e,t){return e?`\`prismic docs ${t?`${e}${t}`:e}\``:``}function sc(e){switch(e){case`nuxt`:return`#configure-the-modules-prismic-client`;default:return`#set-up-a-prismic-client`}}function cc(e){switch(e){case`next`:return`#set-up-previews-in-next-js`;case`sveltekit`:return`#set-up-previews-in-sveltekit`;default:return``}}function lc(e){switch(e){case`nuxt`:return`#write-vue-components`;case`sveltekit`:return`#write-svelte-components`;default:return`#write-react-components`}}function uc(e,t){let n=[],r=ac(t.framework),i=e.filter(e=>!e.done&&e.hint===`not installed`);if(i.length>0){let e=i.map(e=>e.label).join(` `);n.push({action:`Install dependencies: Run \`npm install ${e}\``})}if(e.find(e=>!e.done&&e.hint?.includes(`client`))){let e=oc(r,sc(t.framework));n.push({action:`Create Prismic client file: Run ${e} and create the file as shown`})}return n}function dc(e){let t=[],n=e.some(e=>e.status===`to_push`),r=e.some(e=>e.status===`to_pull`);return n&&t.push({action:"Push local models to Prismic: Run `prismic push`"}),r&&t.push({action:"Pull remote models from Prismic: Run `prismic pull`"}),t}function fc(e,t,n,r){let i=[],a=ac(r.framework);if(t.length>0){let e=oc(a,lc(r.framework));i.push({action:`Implement slice components: Run ${e} and create each component file`})}let o=e.some(e=>e.status===`to_pull`),s=e.some(e=>e.status===`to_push`);if(o&&i.push({action:"Pull remote models from Prismic: Run `prismic pull`"}),n.length>0){let e=[...n].sort()[0];i.push({action:`Connect slice to page type: Run \`prismic page-type connect-slice <type-id> ${e}\``})}return s&&i.push({action:"Push local models to Prismic: Run `prismic push`"}),i}function pc(e,t){let n=[],r=ac(t.framework);if(e.find(e=>e.label===`/slice-simulator route`&&!e.done)){let e=oc(r,`#set-up-live-previewing`);n.push({action:`Create /slice-simulator route: Run ${e} and create the route file as shown`})}e.find(e=>e.label===`Slice simulator URL`&&!e.done)&&n.push({action:"Configure slice simulator URL: Run `prismic preview set-simulator`"});let i=e.find(e=>e.label===`/api/preview endpoint`&&!e.done),a=e.find(e=>e.label===`/api/exit-preview endpoint`&&!e.done);if(i||a){let e=oc(r,cc(t.framework));n.push({action:`Create preview endpoints: Run ${e} and create the endpoint files as shown`})}return e.find(e=>e.label===`Preview environment`&&!e.done)&&n.push({action:"Add preview environment: Run `prismic preview add`"}),n}function mc(e,t){let n=[],r=ac(t.framework);if(e.find(e=>e.label===`/api/revalidate endpoint`&&!e.done)){let e=oc(r,`#handle-content-changes`);n.push({action:`Create /api/revalidate endpoint: Run ${e} and create the endpoint as shown`})}return e.find(e=>e.label===`Revalidation webhook`&&!e.done)&&n.push({action:"Create revalidation webhook: Run `prismic webhook create`"}),n}async function hc(){let{values:{help:t,repo:n=await X()}}=e({args:process.argv.slice(3),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!1});if(t){console.info(`Show the status of the current Prismic project.
|
|
2141
|
+
|
|
2142
|
+
Each section with incomplete items includes "Next steps:" with actionable
|
|
2143
|
+
instructions.
|
|
2144
|
+
|
|
2145
|
+
By default, this command reads the repository from prismic.config.json at the
|
|
2146
|
+
project root.
|
|
2147
|
+
|
|
2148
|
+
USAGE
|
|
2149
|
+
prismic status [flags]
|
|
2150
|
+
|
|
2151
|
+
FLAGS
|
|
2152
|
+
-r, --repo string Repository domain
|
|
2153
|
+
-h, --help Show help for command
|
|
2154
|
+
|
|
2155
|
+
LEARN MORE
|
|
2156
|
+
Use \`prismic <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 B()){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1;return}let r=await $();if(!r){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let[i,a,o,s,c,l,u,d]=await Promise.all([vc(n),bc(n),ic(n),Vn(),zn(n),Hn(),Bn(n),Sc(r)]),f=await z(n);console.info(`Repository: ${n}`),console.info(`URL: ${f.href}`),console.info(``);let p=[],m=await Cc(r,d);if(m.nextSteps=uc(m.items,r),p.push(m),s.ok&&c.ok){let{pageTypes:e,customTypes:t,pageTypeStatuses:n,customTypeStatuses:r}=Ec(s.value,c.value);e.nextSteps=dc(n),t.nextSteps=dc(r),p.push(e),p.push(t)}if(l.ok&&u.ok){let{section:e,statuses:t,missingComponents:n,slicesReadyToConnect:i}=await Ac(l.value,u.value,r,s.ok?s.value:[]);e.nextSteps=fc(t,n,i,r),p.push(e)}let h=await Nc(r,a.ok?a.value:void 0,i.ok?i.value.simulator_url:void 0);if(h.nextSteps=pc(h.items,r),p.push(h),r.framework===`next`){let e=await Fc(r,o.ok?o.value:[]);e.nextSteps=mc(e.items,r),p.push(e)}for(let e of p)gc(e)}function gc(e){let t=e.items.filter(e=>!e.done).length,n=t>0?`${e.title} (${t} remaining)`:e.title;console.info(n);let r=e.items.filter(e=>e.done),i=e.items.filter(e=>!e.done);if(r.length>0)if(r.length===1){let e=r[0],t=e.hint?` \u2014 ${e.hint}`:``;console.info(` ✓ ${e.label}${t}`)}else{let e=r.map(e=>e.label).join(`, `),t=r.every(e=>e.hint===r[0].hint)&&r[0].hint?` \u2014 ${r[0].hint}`:``;console.info(` ✓ ${e}${t}`)}for(let e of i){let t=e.hint?` \u2014 ${e.hint}`:``;console.info(` ○ ${e.label}${t}`)}if(e.nextSteps&&e.nextSteps.length>0){console.info(``),console.info(` Next steps:`);for(let t of e.nextSteps)console.info(` - ${t.action}`)}console.info(``)}const _c=N({simulator_url:P(I())});async function vc(e){let t=await Z(new URL(`/core/repository`,await z(e)),{schema:_c});return t.ok?{ok:!0,value:t.value}:{ok:!1}}const yc=N({results:j(N({id:I(),label:I(),url:I()}))});async function bc(e){let t=await Z(new URL(`/core/repository/preview_configs`,await z(e)),{schema:yc});return t.ok?{ok:!0,value:t.value.results}:{ok:!1}}const xc=N({dependencies:P(F(I(),I())),devDependencies:P(F(I(),I()))});async function Sc(e){let t=new URL(`package.json`,e.projectRoot);try{let e=await r(t,`utf8`),{dependencies:n={},devDependencies:i={}}=yn(xc,JSON.parse(e));return new Set([...Object.keys(n),...Object.keys(i)])}catch{return new Set}}async function Cc(e,t){let n=[],r=Ai(e.framework);for(let e of r)n.push({done:t.has(e),label:e,hint:t.has(e)?`installed`:`not installed`});let i=ji(e);if(i){let t=await jn(new URL(i,e.projectRoot));n.push({done:t,label:i,hint:t?void 0:`create Prismic client file`})}else if(e.framework===`nuxt`){let t=await wc(e);n.push({done:t,label:`nuxt.config.ts`,hint:t?`prismic configured`:`add @nuxtjs/prismic to modules`})}return{title:`Setup`,items:n}}async function wc(e){let t=new URL(`nuxt.config.ts`,e.projectRoot);try{let e=await r(t,`utf8`);return e.includes(`@nuxtjs/prismic`)||e.includes(`prismic:`)}catch{return!1}}function Tc(e,t){let n=new Map(e.map(e=>[e.id,e])),r=new Map(t.map(e=>[e.id,e])),i=[];for(let t of e){let e=t.label||t.id,n=r.get(t.id);n&&JSON.stringify(t)===JSON.stringify(n)?i.push({id:t.id,label:e,status:`in_sync`}):i.push({id:t.id,label:e,status:`to_push`})}for(let e of t)if(!n.has(e.id)){let t=e.label||e.id;i.push({id:e.id,label:t,status:`to_pull`})}return i}function Ec(e,t){let n=Tc(e,t),r=n.filter(n=>{let r=e.find(e=>e.id===n.id),i=t.find(e=>e.id===n.id),a=r||i;return a&&a.format===`page`}),i=n.filter(n=>{let r=e.find(e=>e.id===n.id),i=t.find(e=>e.id===n.id),a=r||i;return!a||a.format!==`page`}),a=r.map(e=>({done:e.status===`in_sync`,label:e.label,hint:Dc(e.status)})),o=i.map(e=>({done:e.status===`in_sync`,label:e.label,hint:Dc(e.status)}));return{pageTypes:{title:`Page Types`,items:a},customTypes:{title:`Custom Types`,items:o},pageTypeStatuses:r,customTypeStatuses:i}}function Dc(e){switch(e){case`in_sync`:return`in sync`;case`to_push`:return`to push`;case`to_pull`:return`to pull`}}function Oc(e){for(let t of e.variations){let e=Object.keys(t.primary??{}),n=Object.keys(t.items??{});if(e.length>0||n.length>0)return!0}return!1}function kc(e,t){for(let n of t)for(let t of Object.values(n.json))for(let n of Object.values(t)){let t=n;if(t.type===`Slices`&&t.config?.choices?.[e])return!0}return!1}async function Ac(e,t,n,r){let i=Tc(e,t),a=[],o=[],s=[],c=Mi(n),l=Ni(n.framework);for(let t of i){let i=e.find(e=>e.id===t.id);if(i){let e=Oc(i),n=kc(t.id,r);e&&!n&&s.push(t.label)}let u=await jc(n,c,t.id,l);t.status===`in_sync`&&u?a.push({done:!0,label:t.label,hint:`component implemented`}):t.status===`in_sync`&&!u?(a.push({done:!1,label:t.label,hint:`missing component`}),o.push(t.label)):a.push({done:!1,label:t.label,hint:Dc(t.status)})}return{section:{title:`Slices`,items:a},statuses:i,missingComponents:o,slicesReadyToConnect:s}}async function jc(e,t,n,r){let i=Mc(n);for(let n of r)if(await jn(new URL(`${t}${i}/index${n}`,e.projectRoot)))return!0;return!1}function Mc(e){return e.toLowerCase().replace(/(^|[-_\s]+)(.)?/g,(e,t,n)=>n?.toUpperCase()??``)}async function Nc(e,t,n){let r=[];r.push({done:!!n,label:`Slice simulator URL`,hint:n?`configured`:"run `prismic preview set-simulator`"});let i=Pi(e,`/slice-simulator`);if(i){let t=await Pc(e,i);r.push({done:t,label:`/slice-simulator route`,hint:t?void 0:`create route for Page Builder`})}let a=t&&t.length>0;if(r.push({done:!!a,label:`Preview environment`,hint:a?void 0:"run `prismic preview add`"}),e.framework!==`nuxt`){let t=Pi(e,`/api/preview`);if(t){let n=await Pc(e,t);r.push({done:n,label:`/api/preview endpoint`,hint:n?void 0:`create preview endpoint`})}}if(e.framework===`next`){let t=Pi(e,`/api/exit-preview`);if(t){let n=await Pc(e,t);r.push({done:n,label:`/api/exit-preview endpoint`,hint:n?void 0:`create exit-preview endpoint`})}}return{title:`Preview`,items:r}}async function Pc(e,t){for(let n of t.extensions)if(await jn(new URL(`${t.path}${n}`,e.projectRoot)))return!0;return!1}async function Fc(e,t){let n=[],r=Pi(e,`/api/revalidate`);if(r){let t=await Pc(e,r);n.push({done:t,label:`/api/revalidate endpoint`,hint:t?void 0:`create for ISR`})}let i=t.some(e=>e.config.active&&e.config.url.toLowerCase().includes(`revalidate`));return n.push({done:i,label:`Revalidation webhook`,hint:i?`configured`:"run `prismic webhook create`"}),{title:`Deployment`,items:n}}async function Ic(){let{values:{help:t,repo:n=await X(),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
2157
|
|
|
1967
2158
|
By default, this command reads the repository from prismic.config.json at the
|
|
1968
2159
|
project root.
|
|
@@ -1976,7 +2167,7 @@ FLAGS
|
|
|
1976
2167
|
-h, --help Show help for command
|
|
1977
2168
|
|
|
1978
2169
|
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
|
|
2170
|
+
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 B()){qc();return}let[i,a]=await Promise.all([Uc(n),Wc(n)]);if(!i.ok){i.error instanceof Q||i.error instanceof ci?qc():A(i.error)?(console.error(`Failed to list access tokens: Invalid response: ${J(i.error.issues)}`),process.exitCode=1):(console.error(`Failed to list access tokens: ${J(i.value)}`),process.exitCode=1);return}if(!a.ok){a.error instanceof Q||a.error instanceof ci?qc():A(a.error)?(console.error(`Failed to list write tokens: Invalid response: ${J(a.error.issues)}`),process.exitCode=1):(console.error(`Failed to list write tokens: ${J(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(J({accessTokens:o,writeTokens:s}));else{if(o.length>0){console.info(`ACCESS TOKENS`);for(let e of o){let t=Gc(e.token),n=Kc(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=Gc(e.token),n=Kc(e.timestamp);console.info(` ${e.app_name} ${t} ${n}`)}}else console.info(`WRITE TOKENS (none)`)}}const Lc=N({$date:vn()}),Rc=N({id:I(),origin:I(),domain:I(),app:I(),scope:I(),expired_at:Lc,created_at:Lc,owner:_n(I()),token:I()}),zc=N({id:I(),secret:I(),name:I(),owner:I(),created_at:Lc,authorized_domains:j(I()),wroom_auths:j(Rc)}),Bc=N({app_name:I(),token:I(),timestamp:vn()}),Vc=N({max_tokens:vn(),tokens:j(Bc)}),Hc=j(zc);async function Uc(e){return await Z(new URL(`settings/security/contentapi`,await z(e)),{schema:Hc})}async function Wc(e){return await Z(new URL(`settings/security/customtypesapi`,await z(e)),{schema:Vc})}function Gc(e){return e.length<=12?e:`${e.slice(0,8)}...${e.slice(-4)}`}function Kc(e){let t=typeof e==`number`?e*1e3:e.$date;return new Date(t).toISOString().split(`T`)[0]}function qc(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function Jc(){let{values:{help:t,repo:n=await X(),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
2171
|
|
|
1981
2172
|
By default, this command reads the repository from prismic.config.json at the
|
|
1982
2173
|
project root.
|
|
@@ -1993,7 +2184,7 @@ FLAGS
|
|
|
1993
2184
|
-h, --help Show help for command
|
|
1994
2185
|
|
|
1995
2186
|
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
|
|
2187
|
+
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 B()){Zc();return}if(i){let e=await Yc(n,a);if(!e.ok){e.error instanceof Q||e.error instanceof ci?Zc():A(e.error)?(console.error(`Failed to create write token: Invalid response: ${J(e.error.issues)}`),process.exitCode=1):(console.error(`Failed to create write token: ${J(e.value)}`),process.exitCode=1);return}r?console.info(J(e.value)):console.info(`Token created: ${e.value.token}`)}else{let e=await Xc(n,a,o?`master+releases`:`master`);if(!e.ok){e.error instanceof Q||e.error instanceof ci?Zc():A(e.error)?(console.error(`Failed to create access token: Invalid response: ${J(e.error.issues)}`),process.exitCode=1):(console.error(`Failed to create access token: ${J(e.value)}`),process.exitCode=1);return}r?console.info(J(e.value)):console.info(`Token created: ${e.value.token}`)}}async function Yc(e,t){return await Z(new URL(`settings/security/token`,await z(e)),{method:`POST`,body:{app_name:t},schema:Bc})}async function Xc(e,t,n){let r=await Uc(e);if(!r.ok)return r;let i=r.value.find(e=>e.name===t);if(!i){let n=await Z(new URL(`settings/security/oauthapp`,await z(e)),{method:`POST`,body:{app_name:t},schema:zc});if(!n.ok)return n;i=n.value}return await Z(new URL(`settings/security/authorizations`,await z(e)),{method:`POST`,body:{app:i.id,scope:n},schema:Rc})}function Zc(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function Qc(){let{values:{help:t,repo:n=await X()},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
2188
|
|
|
1998
2189
|
By default, this command reads the repository from prismic.config.json at the
|
|
1999
2190
|
project root.
|
|
@@ -2009,7 +2200,7 @@ FLAGS
|
|
|
2009
2200
|
-h, --help Show help for command
|
|
2010
2201
|
|
|
2011
2202
|
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
|
|
2203
|
+
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 B()){$c();return}let[i,a]=await Promise.all([Uc(n),Wc(n)]);if(!i.ok){i.error instanceof Q||i.error instanceof ci?$c():A(i.error)?(console.error(`Failed to list access tokens: Invalid response: ${J(i.error.issues)}`),process.exitCode=1):(console.error(`Failed to list access tokens: ${J(i.value)}`),process.exitCode=1);return}if(!a.ok){a.error instanceof Q||a.error instanceof ci?$c():A(a.error)?(console.error(`Failed to list write tokens: Invalid response: ${J(a.error.issues)}`),process.exitCode=1):(console.error(`Failed to list write tokens: ${J(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 Z(new URL(`settings/security/authorizations/${o.id}`,await z(n)),{method:`DELETE`});if(!e.ok){e.error instanceof Q||e.error instanceof ci?$c():(console.error(`Failed to delete token: ${J(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 Z(new URL(`settings/security/token/${s.token}`,await z(n)),{method:`DELETE`});if(!e.ok){e.error instanceof Q||e.error instanceof ci?$c():(console.error(`Failed to delete token: ${J(e.value)}`),process.exitCode=1);return}console.info(`Token deleted`);return}console.error(`Token not found: ${r}`),process.exitCode=1}function $c(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function el(){let{values:{help:t,repo:n=await X()},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
2204
|
|
|
2014
2205
|
Note: Only access tokens can be renamed. Write tokens cannot be renamed without
|
|
2015
2206
|
changing the token value.
|
|
@@ -2029,7 +2220,7 @@ FLAGS
|
|
|
2029
2220
|
-h, --help Show help for command
|
|
2030
2221
|
|
|
2031
2222
|
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
|
|
2223
|
+
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 B()){tl();return}let[a,o]=await Promise.all([Uc(n),Wc(n)]);if(!a.ok){a.error instanceof Q||a.error instanceof ci?tl():A(a.error)?(console.error(`Failed to list access tokens: Invalid response: ${J(a.error.issues)}`),process.exitCode=1):(console.error(`Failed to list access tokens: ${J(a.value)}`),process.exitCode=1);return}if(!o.ok){o.error instanceof Q||o.error instanceof ci?tl():A(o.error)?(console.error(`Failed to list write tokens: Invalid response: ${J(o.error.issues)}`),process.exitCode=1):(console.error(`Failed to list write tokens: ${J(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 Z(new URL(`settings/security/oauthapp/${s.id}`,await z(n)),{method:`POST`,body:{name:i},schema:zc});if(!e.ok){e.error instanceof Q||e.error instanceof ci?tl():A(e.error)?(console.error(`Failed to rename token: Invalid response: ${J(e.error.issues)}`),process.exitCode=1):(console.error(`Failed to rename token: ${J(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 tl(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function nl(){let{positionals:[t]}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`list`:await Ic();break;case`create`:await Jc();break;case`set-name`:await el();break;case`delete`:await Qc();break;default:t&&(console.error(`Unknown token subcommand: ${t}\n`),process.exitCode=1),console.info(`Manage API tokens for a Prismic repository.
|
|
2033
2224
|
|
|
2034
2225
|
USAGE
|
|
2035
2226
|
prismic token <command> [flags]
|
|
@@ -2044,23 +2235,7 @@ FLAGS
|
|
|
2044
2235
|
-h, --help Show help for command
|
|
2045
2236
|
|
|
2046
2237
|
LEARN MORE
|
|
2047
|
-
Use \`prismic token <command> --help\` for more information about a command.`)}}
|
|
2048
|
-
|
|
2049
|
-
By default, this command reads the repository from prismic.config.json at the
|
|
2050
|
-
project root.
|
|
2051
|
-
|
|
2052
|
-
USAGE
|
|
2053
|
-
prismic webhook view <url> [flags]
|
|
2054
|
-
|
|
2055
|
-
ARGUMENTS
|
|
2056
|
-
<url> Webhook URL
|
|
2057
|
-
|
|
2058
|
-
FLAGS
|
|
2059
|
-
-r, --repo string Repository domain
|
|
2060
|
-
-h, --help Show help for command
|
|
2061
|
-
|
|
2062
|
-
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.
|
|
2238
|
+
Use \`prismic token <command> --help\` for more information about a command.`)}}async function rl(){let{values:{help:t,repo:n=await X()},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
2239
|
|
|
2065
2240
|
By default, this command reads the repository from prismic.config.json at the
|
|
2066
2241
|
project root.
|
|
@@ -2076,7 +2251,7 @@ FLAGS
|
|
|
2076
2251
|
-h, --help Show help for command
|
|
2077
2252
|
|
|
2078
2253
|
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
|
|
2254
|
+
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 B()){al();return}let i=await ic(n);if(!i.ok){i.error instanceof Q?al():(console.error(`Failed to enable webhook: ${J(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 il(n,a.config._id,o);if(!s.ok){s.error instanceof Q?al():(console.error(`Failed to enable webhook: ${J(s.value)}`),process.exitCode=1);return}console.info(`Webhook enabled: ${r}`)}async function il(e,t,n){let r=new URL(`/app/settings/webhooks/${t}`,await z(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 Z(r,{method:`POST`,body:i})}function al(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function ol(){let{values:{help:t,repo:n=await X()},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
2255
|
|
|
2081
2256
|
By default, this command reads the repository from prismic.config.json at the
|
|
2082
2257
|
project root.
|
|
@@ -2094,7 +2269,7 @@ FLAGS
|
|
|
2094
2269
|
-h, --help Show help for command
|
|
2095
2270
|
|
|
2096
2271
|
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
|
|
2272
|
+
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 B()){sl();return}let o=await ic(n);if(!o.ok){o.error instanceof Q?sl():(console.error(`Failed to add header: ${J(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 il(n,s.config._id,c);if(!l.ok){l.error instanceof Q?sl():(console.error(`Failed to add header: ${J(l.value)}`),process.exitCode=1);return}console.info(`Header added: ${i}`)}function sl(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}const cl=Object.values(ec);async function ll(){let{values:{help:t,repo:n=await X(),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
2273
|
|
|
2099
2274
|
By default, this command reads the repository from prismic.config.json at the
|
|
2100
2275
|
project root.
|
|
@@ -2123,7 +2298,7 @@ TRIGGERS
|
|
|
2123
2298
|
If no triggers specified, all are enabled.
|
|
2124
2299
|
|
|
2125
2300
|
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(!
|
|
2301
|
+
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(!cl.includes(e)){console.error(`Invalid trigger: ${e}`),console.error(`Valid triggers: ${cl.join(`, `)}`),process.exitCode=1;return}if(!await B()){dl();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(ec).find(([,t])=>e===t)??[];t&&(c[t]=!0)}let l=await ul(n,{url:o,name:r??null,secret:i??null,...c});if(!l.ok){l.error instanceof Q?dl():(console.error(`Failed to create webhook: ${J(l.value)}`),process.exitCode=1);return}console.info(`Webhook created: ${o}`)}async function ul(e,t){let n=new URL(`/app/settings/webhooks/create`,await z(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 Z(n,{method:`POST`,body:r})}function dl(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function fl(){let{values:{help:t,repo:n=await X()},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
2302
|
|
|
2128
2303
|
By default, this command reads the repository from prismic.config.json at the
|
|
2129
2304
|
project root.
|
|
@@ -2139,7 +2314,7 @@ FLAGS
|
|
|
2139
2314
|
-h, --help Show help for command
|
|
2140
2315
|
|
|
2141
2316
|
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
|
|
2317
|
+
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 B()){pl();return}let i=await ic(n);if(!i.ok){i.error instanceof Q?pl():(console.error(`Failed to disable webhook: ${J(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 il(n,a.config._id,o);if(!s.ok){s.error instanceof Q?pl():(console.error(`Failed to disable webhook: ${J(s.value)}`),process.exitCode=1);return}console.info(`Webhook disabled: ${r}`)}function pl(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function ml(){let{values:{help:t,repo:n=await X(),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
2318
|
|
|
2144
2319
|
By default, this command reads the repository from prismic.config.json at the
|
|
2145
2320
|
project root.
|
|
@@ -2153,7 +2328,7 @@ FLAGS
|
|
|
2153
2328
|
-h, --help Show help for command
|
|
2154
2329
|
|
|
2155
2330
|
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
|
|
2331
|
+
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 B()){hl();return}let i=await ic(n);if(!i.ok){i.error instanceof Q?hl():A(i.error)?(console.error(`Failed to list webhooks: Invalid response: ${J(i.error.issues)}`),process.exitCode=1):(console.error(`Failed to list webhooks: ${J(i.value)}`),process.exitCode=1);return}let a=i.value;if(r)console.info(J(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 hl(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function gl(){let{values:{help:t,repo:n=await X()},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
2332
|
|
|
2158
2333
|
By default, this command reads the repository from prismic.config.json at the
|
|
2159
2334
|
project root.
|
|
@@ -2169,7 +2344,7 @@ FLAGS
|
|
|
2169
2344
|
-h, --help Show help for command
|
|
2170
2345
|
|
|
2171
2346
|
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
|
|
2347
|
+
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 B()){vl();return}let i=await ic(n);if(!i.ok){i.error instanceof Q?vl():(console.error(`Failed to remove webhook: ${J(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 _l(n,a.config._id);if(!o.ok){o.error instanceof Q?vl():(console.error(`Failed to remove webhook: ${J(o.value)}`),process.exitCode=1);return}console.info(`Webhook removed: ${r}`)}async function _l(e,t){return await Z(new URL(`/app/settings/webhooks/${t}/delete`,await z(e)),{method:`POST`})}function vl(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function yl(){let{values:{help:t,repo:n=await X()},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
2348
|
|
|
2174
2349
|
By default, this command reads the repository from prismic.config.json at the
|
|
2175
2350
|
project root.
|
|
@@ -2186,7 +2361,7 @@ FLAGS
|
|
|
2186
2361
|
-h, --help Show help for command
|
|
2187
2362
|
|
|
2188
2363
|
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
|
|
2364
|
+
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 B()){bl();return}let a=await ic(n);if(!a.ok){a.error instanceof Q?bl():(console.error(`Failed to remove header: ${J(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 il(n,o.config._id,s);if(!c.ok){c.error instanceof Q?bl():(console.error(`Failed to remove header: ${J(c.value)}`),process.exitCode=1);return}console.info(`Header removed: ${i}`)}function bl(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}const xl=Object.values(ec);async function Sl(){let{values:{help:t,repo:n=await X(),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
2365
|
|
|
2191
2366
|
By default, this command reads the repository from prismic.config.json at the
|
|
2192
2367
|
project root.
|
|
@@ -2211,7 +2386,7 @@ TRIGGERS
|
|
|
2211
2386
|
tag.deleted When a tag is deleted
|
|
2212
2387
|
|
|
2213
2388
|
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(!
|
|
2389
|
+
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(!xl.includes(e)){console.error(`Invalid trigger: ${e}`),console.error(`Valid triggers: ${xl.join(`, `)}`),process.exitCode=1;return}if(!await B()){Cl();return}let a=await ic(n);if(!a.ok){a.error instanceof Q?Cl():(console.error(`Failed to update webhook triggers: ${J(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(ec).find(([,t])=>e===t)??[];t&&(c[t]=!0)}let l=await il(n,o.config._id,{...o.config,...c});if(!l.ok){l.error instanceof Q?Cl():(console.error(`Failed to update webhook triggers: ${J(l.value)}`),process.exitCode=1);return}console.info(`Webhook triggers updated: ${r.join(`, `)}`)}function Cl(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function wl(){let{values:{help:t,repo:n=await X()},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
2390
|
|
|
2216
2391
|
By default, this command reads the repository from prismic.config.json at the
|
|
2217
2392
|
project root.
|
|
@@ -2227,7 +2402,7 @@ FLAGS
|
|
|
2227
2402
|
-h, --help Show help for command
|
|
2228
2403
|
|
|
2229
2404
|
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
|
|
2405
|
+
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 B()){Tl();return}let i=await ic(n);if(!i.ok){i.error instanceof Q?Tl():(console.error(`Failed to get webhook status: ${J(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 Tl(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function El(){let{values:{help:t,repo:n=await X()},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
2406
|
|
|
2232
2407
|
By default, this command reads the repository from prismic.config.json at the
|
|
2233
2408
|
project root.
|
|
@@ -2243,7 +2418,7 @@ FLAGS
|
|
|
2243
2418
|
-h, --help Show help for command
|
|
2244
2419
|
|
|
2245
2420
|
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
|
|
2421
|
+
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 B()){Ol();return}let i=await ic(n);if(!i.ok){i.error instanceof Q?Ol():(console.error(`Failed to test webhook: ${J(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 Dl(n,a.config._id);if(!o.ok){o.error instanceof Q?Ol():(console.error(`Failed to test webhook: ${J(o.value)}`),process.exitCode=1);return}console.info(`Test webhook triggered: ${r}`)}async function Dl(e,t){return await Z(new URL(`/app/settings/webhooks/${t}/trigger`,await z(e)),{method:`POST`})}function Ol(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function kl(){let{positionals:[t]}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`list`:await ml();break;case`create`:await ll();break;case`view`:await tc();break;case`remove`:await gl();break;case`test`:await El();break;case`enable`:await rl();break;case`disable`:await fl();break;case`status`:await wl();break;case`add-header`:await ol();break;case`remove-header`:await yl();break;case`set-triggers`:await Sl();break;default:t&&(console.error(`Unknown webhook subcommand: ${t}\n`),process.exitCode=1),console.info(`Manage webhooks in a Prismic repository.
|
|
2247
2422
|
|
|
2248
2423
|
USAGE
|
|
2249
2424
|
prismic webhook <command> [flags]
|
|
@@ -2265,7 +2440,7 @@ FLAGS
|
|
|
2265
2440
|
-h, --help Show help for command
|
|
2266
2441
|
|
|
2267
2442
|
LEARN MORE
|
|
2268
|
-
Use \`prismic webhook <command> --help\` for more information about a command.`)}}async function
|
|
2443
|
+
Use \`prismic webhook <command> --help\` for more information about a command.`)}}async function Al(){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
2444
|
|
|
2270
2445
|
USAGE
|
|
2271
2446
|
prismic whoami [flags]
|
|
@@ -2274,7 +2449,7 @@ FLAGS
|
|
|
2274
2449
|
-h, --help Show help for command
|
|
2275
2450
|
|
|
2276
2451
|
LEARN MORE
|
|
2277
|
-
Use \`prismic <command> --help\` for more information about a command.`);return}if(!await
|
|
2452
|
+
Use \`prismic <command> --help\` for more information about a command.`);return}if(!await B()){Ml();return}let n=await jl();if(!n.ok){n.error instanceof Q?Ml():console.error(`Failed to fetch user profile.`),process.exitCode=1;return}console.info(n.value.email)}async function jl(){return await Z(new URL(`profile`,await Sn()),{schema:N({email:I()})})}function Ml(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}const{positionals:Nl,values:{version:Pl}}=e({options:{help:{type:`boolean`,short:`h`},version:{type:`boolean`,short:`v`}},allowPositionals:!0,strict:!1});if(Pl)console.info(te);else switch(Nl[0]){case`init`:await oi();break;case`login`:await Ti();break;case`logout`:await Oi();break;case`whoami`:await Al();break;case`status`:await hc();break;case`repo`:await Yo();break;case`locale`:await Ci();break;case`page-type`:await Wa();break;case`custom-type`:await Ur();break;case`slice`:await $s();break;case`pull`:await vo();break;case`push`:await xo();break;case`codegen`:await Xn();break;case`docs`:await Yr();break;case`preview`:await _o();break;case`token`:await nl();break;case`webhook`:await kl();break;default:Nl[0]&&(console.error(`Unknown command: ${Nl[0]}`),process.exitCode=1),console.info(`Prismic CLI for managing repositories and configurations.
|
|
2278
2453
|
|
|
2279
2454
|
USAGE
|
|
2280
2455
|
prismic <command> [flags]
|
|
@@ -2284,6 +2459,7 @@ COMMANDS
|
|
|
2284
2459
|
login Log in to Prismic
|
|
2285
2460
|
logout Log out of Prismic
|
|
2286
2461
|
whoami Show the currently logged in user
|
|
2462
|
+
status Show the status of the current project
|
|
2287
2463
|
repo Manage Prismic repositories
|
|
2288
2464
|
locale Manage locales in a repository
|
|
2289
2465
|
page-type Manage page types in a repository
|
|
@@ -2292,12 +2468,14 @@ COMMANDS
|
|
|
2292
2468
|
pull Pull types and slices from Prismic
|
|
2293
2469
|
push Push types and slices to Prismic
|
|
2294
2470
|
codegen Generate code from Prismic models
|
|
2471
|
+
docs Fetch documentation from Prismic
|
|
2295
2472
|
preview Manage preview configurations
|
|
2296
2473
|
token Manage API tokens in a repository
|
|
2297
2474
|
webhook Manage webhooks in a repository
|
|
2298
2475
|
|
|
2299
2476
|
FLAGS
|
|
2300
|
-
-
|
|
2477
|
+
-v, --version Show CLI version
|
|
2478
|
+
-h, --help Show help for command
|
|
2301
2479
|
|
|
2302
2480
|
LEARN MORE
|
|
2303
2481
|
Use \`prismic <command> --help\` for more information about a command.`)}export{};
|