@griddo/core 11.0.20 → 11.0.21
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/autotypes-legacy.js +1 -1
- package/dist/autotypes-legacy.js.map +1 -1
- package/dist/autotypes.js +1 -1
- package/dist/autotypes.js.map +1 -1
- package/dist/components/CloudinaryBackgroundImage/index.d.ts +1 -0
- package/dist/components/Component/ComponentWrapper/index.d.ts +1 -0
- package/dist/components/Component/index.d.ts +1 -0
- package/dist/components/GriddoImageExp/types.d.ts +1 -0
- package/dist/components/LdJson/index.d.ts +1 -0
- package/dist/components/Link/index.d.ts +1 -0
- package/dist/components/Preview/index.d.ts +1 -0
- package/dist/functions/index.d.ts +1 -1
- package/dist/hooks/__mocks__/page-provider-props.d.ts +1 -1
- package/dist/hooks/themes/useThemeColors.d.ts +20 -20
- package/dist/hooks/themes/useThemeFont.d.ts +20 -20
- package/dist/hooks/themes/useThemePrimitives.d.ts +20 -20
- package/dist/hooks/themes/utils.d.ts +40 -40
- package/dist/hooks/useLink.d.ts +1 -0
- package/dist/hooks/usePageRelatedContent.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/react-svg-library.js +1 -1
- package/dist/react-svg-library.js.map +1 -1
- package/dist/types/core/index.d.ts +1 -0
- package/package.json +46 -39
package/dist/autotypes.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import e from"node:fs";import t from"node:path";import{fileURLToPath as n}from"node:url";import i from"node:process";import o from"prettier";function r(e,t,n,i){return new(n||(n=Promise))((function(o,r){function s(e){try{c(i.next(e))}catch(e){r(e)}}function a(e){try{c(i.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((i=i.apply(e,t||[])).next())}))}const s={directory:"isDirectory",file:"isFile"};const a=(e,t)=>t[s[e]](),c=e=>e instanceof URL?n(e):e;function l(n,{cwd:o=i.cwd(),type:r="file",allowSymlinks:l=!0}={}){!function(e){if(!Object.hasOwnProperty.call(s,e))throw new Error(`Invalid type specified: ${e}`)}(r),o=c(o);const u=l?e.statSync:e.lstatSync;for(const e of n)try{const n=u(t.resolve(o,e),{throwIfNoEntry:!1});if(!n)continue;if(a(r,n))return e}catch{}}const u=e=>e instanceof URL?n(e):e,p=Symbol("findUpStop");function d(e,n={}){const i=function(e,n={}){let i=t.resolve(u(n.cwd)||"");const{root:o}=t.parse(i),r=n.stopAt||o,s=n.limit||Number.POSITIVE_INFINITY,a=[e].flat(),c=t=>{if("function"!=typeof e)return l(a,t);const n=e(t.cwd);return"string"==typeof n?l([n],t):n},d=[];for(;;){const e=c({...n,cwd:i});if(e===p)break;if(e&&d.push(t.resolve(i,e)),i===r||d.length>=s)break;i=t.dirname(i)}return d}(e,{...n,limit:1});return i[0]}const m=__dirname.includes("node_modules");function f(){const e=__dirname,n=m?"../../../":"../griddo-components";return t.resolve(function({cwd:e}={}){const n=d("package.json",{cwd:e});return n&&t.dirname(n)}({cwd:e}),n)}function y(){var e,n,i;const o=t.join(f(),"griddo.config.ts"),r=require(o);return{interfaceSuffix:(null===(e=r.autotypes)||void 0===e?void 0:e.interfaceSuffix)||"Props",contentTypeSuffix:(null===(n=r.autotypes)||void 0===n?void 0:n.contentTypeSuffix)||"ContentType",publicApiSuffix:(null===(i=r.autotypes)||void 0===i?void 0:i.publicApiSuffix)||"List"}}const g=/[\p{Lu}]/u,h=/[\p{Ll}]/u,$=/^[\p{Lu}](?![\p{Lu}])/gu,b=/([\p{Alpha}\p{N}_]|$)/u,T=/[_.\- ]+/,S=new RegExp("^"+T.source),F=new RegExp(T.source+b.source,"gu"),C=new RegExp("\\d+"+b.source,"gu"),v=(e,t,n,i)=>{let o=!1,r=!1,s=!1,a=!1;for(let c=0;c<e.length;c++){const l=e[c];a=!(c>2)||"-"===e[c-3],o&&g.test(l)?(e=e.slice(0,c)+"-"+e.slice(c),o=!1,s=r,r=!0,c++):r&&s&&h.test(l)&&(!a||i)?(e=e.slice(0,c-1)+"-"+e.slice(c-1),s=r,r=!1,o=!0):(o=t(l)===l&&n(l)!==l,s=r,r=n(l)===l&&t(l)!==l)}return e},k=(e,t)=>($.lastIndex=0,e.replaceAll($,(e=>t(e)))),x=(e,t)=>(F.lastIndex=0,C.lastIndex=0,e.replaceAll(C,((n,i,o)=>["_","-"].includes(e.charAt(o+n.length))?n:t(n))).replaceAll(F,((e,n)=>t(n))));function j(e,t){var n;const{returnTypeName:i,generic:o}=t||{},r="hideable"in e&&Boolean(e.hideable),s=o?`<${o}>`:"",a=`${i||_(e.type)}${s}`,c=r?`Hideable<${a}>`:`${a}`;return`\n\t\t${(null===(n=e._autoType)||void 0===n?void 0:n.doc)||""}\n\t\t${`${e.key}?: ${c}`}\n\t`}function A(e){const{interfaceSuffix:t}=y();return e.length>1?`{\n\t\t\t${e.map((e=>`${function(e,t){if("string"!=typeof e&&!Array.isArray(e))throw new TypeError("Expected the input to be `string | string[]`");if(t={pascalCase:!1,preserveConsecutiveUppercase:!1,...t},0===(e=Array.isArray(e)?e.map((e=>e.trim())).filter((e=>e.length)).join("-"):e.trim()).length)return"";const n=!1===t.locale?e=>e.toLowerCase():e=>e.toLocaleLowerCase(t.locale),i=!1===t.locale?e=>e.toUpperCase():e=>e.toLocaleUpperCase(t.locale);return 1===e.length?T.test(e)?"":t.pascalCase?i(e):n(e):(e!==n(e)&&(e=v(e,n,i,t.preserveConsecutiveUppercase)),e=e.replace(S,""),e=t.preserveConsecutiveUppercase?k(e,n):n(e),t.pascalCase&&(e=i(e.charAt(0))+e.slice(1)),x(e,i))}(e)}?: ${e}${t}`)).join(",")}\n\t\t\t}`:e.map((e=>`${e}${t}`)).join("")}function _(e){return{ArrayFieldGroup:"Fields.ArrayFieldGroup",AsyncCheckGroup:"Fields.AsyncCheckGroup",AsyncSelect:"Fields.AsyncSelect",CheckGroup:"Fields.CheckGroup",ColorPicker:"Fields.ColorPicker",ComponentArray:"Fields.ComponentArray",ComponentContainer:"Fields.ComponentContainer",ConditionalField:"Fields.Conditional",DateField:"Fields.Date",FieldGroup:"Fields.FieldGroup",FieldsDivider:"Fields.FieldsDivider",FileField:"Fields.File",HeadingField:"Fields.Heading",ImageField:"Fields.Image",LinkField:"Fields.Link",MultiCheckSelect:"Fields.MultiCheckSelect",MultiCheckSelectGroup:"Fields.MultiCheckSelectGroup",NoteField:"Fields.Note",NumberField:"Fields.Number",RadioGroup:"Fields.RadioGroup",ReferenceField:"Fields.Reference",RichText:"Fields.RichText",Select:"Fields.Select",SliderField:"Fields.Slider",TagsField:"Fields.Tags",TextArea:"Fields.TextArea",TextField:"Fields.Text",TimeField:"Fields.Time",ToggleField:"Fields.Toggle",UniqueCheck:"Fields.UniqueCheck",UrlField:"Fields.Url",VisualUniqueSelection:"Fields.VisualUniqueSelection",Wysiwyg:"Fields.Wysiwyg"}[e]}function D(e,t,n){var i,o;const{contentTypeSuffix:r,interfaceSuffix:s}=y();if("FieldsDivider"===e.type)return"// FieldsDivider";if(null===(i=e._autoType)||void 0===i?void 0:i.ignore)return"// Ignored by AutoType.ignore";const{type:a,_autoType:c,key:l}=e,{hasDistributorData:u,getStaticData:p}=n;if(!a||!l)return"\n\t\t\t/** · (ノ-_-)ノ ミ ┴┴ You forgot to write the `type` | `key` or some mandatory prop */\n\t\t";if("DateField"===a||"FileField"===a||"ImageField"===a||"NoteField"===a||"NumberField"===a||"RichText"===a||"SliderField"===a||"TagsField"===a||"TextArea"===a||"TextField"===a||"TimeField"===a||"ToggleField"===a||"UniqueCheck"===a||"UrlField"===a||"Wysiwyg"===a)return j(e);if("MultiCheckSelect"===a){if("pageContentType"===t||"simpleContentType"===t){return j(e,{generic:`Relations, FromList, ${`${e.source}${r}${s}`}<false, false>, FromDistributor`})}return j(e,{generic:"true"})}if("AsyncCheckGroup"===a){if("pageContentType"===t||"simpleContentType"===t){return j(e,{generic:`Relations, FromList, ${`${e.source}${r}${s}`}<false, false>, FromDistributor`})}return j(e,{generic:"true"})}if("MultiCheckSelectGroup"===a){const t=e.elements.map((e=>`"${e.key}"`)).join("|");return j(e,{generic:[t,null===(o=e._autoType)||void 0===o?void 0:o.relations].join(",")})}if("ColorPicker"===a)return e.isThemePalette?j(e,{returnTypeName:"Fields.ColorPickerFixed"}):j(e);if("HeadingField"===a||"RadioGroup"===a||"Select"===a){const{options:t}=e,n=function(e){return e.map((({value:e})=>"string"==typeof e?`"${e}"`:e)).join("|")}(t);return j(e,{generic:n})}if("CheckGroup"===a){const{options:t}=e,n=function(e){return e.map((({name:e})=>"string"==typeof e?`"${e}"`:e)).join("|")}(t);return j(e,{generic:n})}if("LinkField"===a){const{whiteList:t}=e;return j(e,{generic:A(t)})}if("AsyncSelect"===a){if("entity"in e&&"menu_containers"===e.entity)return`\n${l}?: Menu`;if("pageContentType"===t||"simpleContentType"===t){return j(e,{generic:`Relations, FromList, ${`${e.source}${r}${s}`}<false, false>, FromDistributor`})}return`\n${l}?: Fields.AsyncSelect;`}if("FieldGroup"===a)return`\n\t\t\t// << ${a}\n\t\t\t${e.fields.map((e=>D(e,t,n))).join("")}\n\t\t\t// end >>\n\t\t`;if("ArrayFieldGroup"===a){return`\n\t\t\t\n${(null==c?void 0:c.doc)||""}\n${l}?: Fields.ArrayFieldGroup<{${e.fields.map((e=>D(e,t,n))).join(",")}}>\n\t\t`}if("ConditionalField"===a){const i=e.fields.map((e=>D(e,t,n))),o=(null==c?void 0:c.doc)||"",r="hideable"in e&&e.hideable,s=r?">":"";return`\n\t\t\t// << ${a}\n\t\t\t\n${o}\n${l}?: ${r?"Hideable<":""}${_(a)}<${e.options.map((e=>"string"==typeof e.value?`"${e.value}"`:e.value)).join("|")}>${s};\n\t\t\t${i.join("")}\n\t\t\t// end >>\n\t\t`}if("ComponentArray"===a){const i="template"===t||"pageContentType"===t?"TemplateSection":"ComponentArray",o="template"===t?"":"?",r=e,{key:a,_autoType:c,whiteList:l}=r,u=(null==c?void 0:c.doc)||"",p=(e,t,n)=>e.filter((e=>{if(e&&"schemaType"in e&&"module"===(null==e?void 0:e.schemaType))return(null==e?void 0:e.sectionList)&&!!(null==e?void 0:e.sectionList[t])})).map((e=>({t:null==e?void 0:e.sectionList[t].filter((e=>e===n)),m:null==e?void 0:e.component}))).filter((e=>{var t;return null===(t=null==e?void 0:e.t)||void 0===t?void 0:t.length})).map((e=>null==e?void 0:e.m)).filter(Boolean);let d="";"template"===t&&(d=p(n.moduleSchemas,n.schema.component,a).join("|"));return`\n${u}\n${a}${o}: Fields.${i}<${[...new Set([...d.split("|"),...l])].filter(Boolean).map((e=>`${e}${s}`)).join("|")}>;`}if("ComponentContainer"===a&&("object"===t||"component"===t||"module"===t||"template"===t||"pageContentType"===t)){const t=e,{whiteList:n}=t;return j(e,{generic:A(n)})}if("ReferenceField"===a){const t=e.sources||[{structuredData:void 0}],n=Array.isArray(t)&&t.map((e=>e.structuredData?`${e.structuredData}${r}${s}`:"unknown")).join("|")||"";return`\n\t\t \t${j(e,{generic:n})}\n\t\t \t${u||p?`queriedItems?: Fields.QueriedData<${n}>;`:""}\n\t\t `}if("VisualUniqueSelection"===a){const t=e.options[0],n=e.options[0];let i="";if(t.value){i=e.options.map((e=>`"${e.value}"`)).join("|")}if(n.theme){i=e.options[0].options.map((e=>`"${e.value}"`)).join("|")}return j(e,{generic:i})}return console.warn(`The field ${e.type} has not been implemented yet ㅠ.ㅠ`),""}function w(e,t,n){return function(e){if("fromPage"in e)return e.taxonomy?[]:e.schema.fields;if("template"===e.schemaType){return[...e.content||[],...e.config||[]]}if("component"===e.schemaType||"module"===e.schemaType)return e.configTabs.flatMap((e=>e.fields));throw new Error(`Wrong schema ${JSON.stringify(e,null,2)}`)}(e).map((i=>D(i,n.kind,{hasDistributorData:n.hasDistributorData,getStaticData:n.getStaticData,moduleSchemas:t,schema:e}))).filter(Boolean).join("")}function O(e){const t=(n=e,Object.keys(n).map((e=>Object.assign(Object.assign({},n[e]),{component:e}))));var n;const{interfaceSuffix:i}=y(),{ARRAY_OF_MODULE_SCHEMAS:o}=function(e){return{ARRAY_OF_MODULE_SCHEMAS:e.map((e=>{if("schemaType"in e&&"module"===e.schemaType)return e})).filter(Boolean)}}(t);return t.map((e=>{var t;let n={kind:"component",contentTypeSuffixStr:"",contentTypeName:"",contentTypeKind:"",relatedContentTypeNames:"",componentName:"",hasDistributorData:!1,getStaticData:!1,interfaceForPublicAPI:"",relationsGeneric:(null===(t=e._autoType)||void 0===t?void 0:t.relations)?"<Relations = unknown, FromList = unknown, FromDistributor = true>":""};if(function(e){return"fromPage"in e}(e)){const t=function(e){const{contentTypeSuffix:t,interfaceSuffix:n,publicApiSuffix:i}=y(),o=[],r=[],s=[],a=e.fromPage?"pageContentType":"simpleContentType";"pageContentType"===a&&o.push(`"${e.component}"`),"simpleContentType"!==a||e.taxonomy||r.push(`"${e.component}"`),"simpleContentType"===a&&e.taxonomy&&s.push(`"${e.component}"`);let c="";if("schema"in e){const t=e.schema.fields.map((e=>"source"in e&&(null==e?void 0:e.source))).filter(Boolean);c=t.length?`__relatedContentTypeNames: ${JSON.stringify(t)}`:""}const l=`\n\t\t\t\t/** Type to be consumed by public API: useList(), etc.. */\n\t\t\t\texport type ${e.component}${t}${i}${n}<R extends Core.ContentTypeRelations = false> = ${e.component}${t}${n}<R, true>;\n\t\t\t\t`;return{kind:a,componentName:"",contentTypeName:`__contentTypeName: "${e.component}";`,contentTypeKind:`__contentTypeKind: "${a}";`,contentTypeSuffixStr:t,getStaticData:!1,hasDistributorData:!1,relatedContentTypeNames:c,relationsGeneric:"<Relations = unknown, FromList = unknown, FromDistributor = true>",interfaceForPublicAPI:l}}(e);n=Object.assign(Object.assign({},n),t)}if(function(e){return"schemaType"in e}(e)){const t=function(e){let t=!1,n=!1;return"template"!==e.schemaType&&"module"!==e.schemaType&&"component"!==e.schemaType||(t=e.default.hasDistributorData,n=e.default.getStaticData),{kind:e.schemaType,componentName:`component: "${e.component}"`,contentTypeName:"",contentTypeKind:"",contentTypeSuffixStr:"",relatedContentTypeNames:"",relationsGeneric:"",interfaceForPublicAPI:"",hasDistributorData:t,getStaticData:n}}(e);n=Object.assign(Object.assign({},n),t)}const r=w(e,o,n);return`\n\t\t\t\texport interface ${e.component}${n.contentTypeSuffixStr}${i}${n.relationsGeneric} ${function(e){const t=function(e){return"schemaType"in e&&"template"===e.schemaType&&("list"===e.type.mode||"paginated-data"===e.type.mode)}(e)?"Fields.ExtraListTemplateProps":"";return(n=[t]).filter((e=>e.length)).length<1?"":`extends ${n.join(", ")}`;var n}(e)} {\n\t\t\t\t\t${n.contentTypeName}\n\t\t\t\t\t${n.contentTypeKind}\n\t\t\t\t\t${n.relatedContentTypeNames}\n\t\t\t\t\t${n.componentName}\n\t\t\t\t\t${r}\n\t\t\t\t\t${function(e){return"fromPage"in e&&!e.fromPage&&!0===e.taxonomy}(e)?"title?: string; code?: string":""}\n\t\t\t\t}\n\t\t\t\t${n.interfaceForPublicAPI}\n\t\t\t`})).join("")}function E(e){return e?e.map((e=>D(e,"object",{hasDistributorData:!1,getStaticData:!1,moduleSchemas:[],schema:{}}))).join(""):""}const{FORCE_COLOR:I,NODE_DISABLE_COLORS:L,TERM:R}=process.env,M={enabled:!L&&"dumb"!==R&&"0"!==I,reset:G(0,0),bold:G(1,22),dim:G(2,22),italic:G(3,23),underline:G(4,24),inverse:G(7,27),hidden:G(8,28),strikethrough:G(9,29),black:G(30,39),red:G(31,39),green:G(32,39),yellow:G(33,39),blue:G(34,39),magenta:G(35,39),cyan:G(36,39),white:G(37,39),gray:G(90,39),grey:G(90,39),bgBlack:G(40,49),bgRed:G(41,49),bgGreen:G(42,49),bgYellow:G(43,49),bgBlue:G(44,49),bgMagenta:G(45,49),bgCyan:G(46,49),bgWhite:G(47,49)};function P(e,t){let n,i=0,o="",r="";for(;i<e.length;i++)n=e[i],o+=n.open,r+=n.close,t.includes(n.close)&&(t=t.replace(n.rgx,n.close+n.open));return o+t+r}function G(e,t){let n={open:`[${e}m`,close:`[${t}m`,rgx:new RegExp(`\\x1b\\[${t}m`,"g")};return function(t){return void 0!==this&&void 0!==this.has?(this.has.includes(e)||(this.has.push(e),this.keys.push(n)),void 0===t?this:M.enabled?P(this.keys,t+""):t+""):void 0===t?function(e,t){let n={has:e,keys:t};return n.reset=M.reset.bind(n),n.bold=M.bold.bind(n),n.dim=M.dim.bind(n),n.italic=M.italic.bind(n),n.underline=M.underline.bind(n),n.inverse=M.inverse.bind(n),n.hidden=M.hidden.bind(n),n.strikethrough=M.strikethrough.bind(n),n.black=M.black.bind(n),n.red=M.red.bind(n),n.green=M.green.bind(n),n.yellow=M.yellow.bind(n),n.blue=M.blue.bind(n),n.magenta=M.magenta.bind(n),n.cyan=M.cyan.bind(n),n.white=M.white.bind(n),n.gray=M.gray.bind(n),n.grey=M.grey.bind(n),n.bgBlack=M.bgBlack.bind(n),n.bgRed=M.bgRed.bind(n),n.bgGreen=M.bgGreen.bind(n),n.bgYellow=M.bgYellow.bind(n),n.bgBlue=M.bgBlue.bind(n),n.bgMagenta=M.bgMagenta.bind(n),n.bgCyan=M.bgCyan.bind(n),n.bgWhite=M.bgWhite.bind(n),n}([e],[n]):M.enabled?P([n],t+""):t+""}}const N="/* eslint-disable @typescript-eslint/ban-types */\n/* eslint-disable @typescript-eslint/no-unused-vars */\n/* eslint-disable no-use-before-define */\n//\n//\n// ' ____\n// /\\ \\\n// º / /\\ \\\n// ' / / \\ _>\n// ' _\\ \\__> \\__\n// ' O ( __;·;______ ) AutoTypes\n// O º, | , , \\ \\\\ ·..~~.·~.·\n// ,,, /| , , /\\ <\\\\\n// \\''\\-' ⎩, <\\/\\ \\ \\\n// \\_/ /\\_____⎩/ > > >\n// '___' <_(_)__> / \\ <\n// / / ´ \\ | \\___//\\\\\n// / / | / > > \\\\\n// · ··~~~~·~·~~~~~~~·~··~~~~~·~·~~·~~~~·~~~~~·· · ·\n//\n// Embrace the beauty of effortless typing by indulging in the benefits of them\n// sans the actual typing!\n//\n// Behold! These dynamically generated types were conjured from the schemas\n// nestled within this repository. However, should you yearn to expand upon\n// these types, kindly abstain from doing so in this file, lest AutoTypes'\n// magic shall smite your changes with each schema modification.\n//\n// Check out the details of Griddo AutoTypes in:\n// https://griddoio.notion.site/Griddo-AutoTypes-e7420867dd2e489c8da34a493b763cd8>\n//\n// Happy magic types!\n//\nimport { Core, Fields, Hideable, NonEmptyArray } from \"@griddo/core\"\n//\n",U=`${M.green(" ✔")} AutoTypes`;function B(n){return r(this,void 0,void 0,(function*(){const{categoryContentTypes:i,pageContentTypes:s,simpleContentTypes:a,componentsSchema:c,datapacksCategoriesSchema:l,datapacksSchema:u,languagesSchemas:p,menuItemsSchemas:d,moduleCategoriesSchema:m,modulesSchema:g,structuredDataSchema:h,subthemesSchema:$,templatesSchema:b,themesSchema:T}=n,S=Object.assign(Object.assign(Object.assign(Object.assign({},c),g),b),h),F=t.join(f(),"autotypes.d.ts"),C=O(S),v=function(e){var t,n;const i=null===(t=null==e?void 0:e.link)||void 0===t?void 0:t.fields,o=null===(n=null==e?void 0:e.group)||void 0===n?void 0:n.fields;return`\n\t\texport interface InstanceMenuItems {\n\t\t\tlink:{\n\t\t\t\t${E(i)}\n\t\t\t\tconfig?: {\n\t\t\t\t\theaderStyle?: string;\n\t\t\t\t\tfooterStyle?: string;\n\t\t\t\t\ttype?: "link";\n\t\t\t\t};\n\t\t\t};\n\t\t\tgroup: {\n\t\t\t\turl?: null;\n\t\t\t\t${E(o)}\n\t\t\t\tconfig?: {\n\t\t\t\t\theaderStyle?: string;\n\t\t\t\t\tfooterStyle?: string;\n\t\t\t\t\ttype?: "group";\n\t\t\t\t};\n\t\t\t};\n\t\t}\n\t\texport type LinkMenuElement = Fields.BaseLinkElement<InstanceMenuItems> & InstanceMenuItems["link"];\n\t\texport type GroupMenuElement = Fields.BaseLinkElement<InstanceMenuItems> & InstanceMenuItems["group"];\n\t\texport type MenuElement = LinkMenuElement | GroupMenuElement;\n\t\texport type Menu = Fields.Menu<InstanceMenuItems>;\n\t`}(d),k=function(e){const t=Object.keys(e);return`\n\t\texport interface SiteLanguage {\n\t\t\tdomain: { id: number; url: string; slug: string };\n\t\t\thome: string;\n\t\t\tid: number;\n\t\t\tisDefault: boolean;\n\t\t\tlabel: ${t.map((t=>`"${e[t].label}"`)).join("|")};\n\t\t\tlanguage: ${t.map((t=>`"${e[t].name}"`)).join("|")};\n\t\t\tlocale: ${t.map((e=>`"${e}"`)).join("|")}\n\t\t\tpath: string;\n\t\t}\n\t`}(p),x=(j=m)?`export type ModuleCategories = ${j.map((e=>`"${e.value}"`)).join("|")}`:"";var j;const A=function(e){const t=Object.keys(e).map((e=>`"${e}"`));return t.length?`export type TaxonomyContentTypes = ${t.join("|")}`:""}(i),_=function(e){const t=Object.keys(e).map((e=>`"${e}"`));return t.length?`export type PageContentTypes = ${t.join("|")}`:""}(s),D=function(e){const t=Object.keys(e).map((e=>`"${e}"`));return t.length?`export type SimpleContentTypes = ${t.join("|")}`:""}(a),w=function(e){const t=Object.keys(e).map((e=>`"${e}"`));return t.length?`export type Components = ${t.join("|")}`:""}(c),I=function(e){const t=Object.keys(e).map((e=>`"${e}"`));return t.length?`export type Modules = ${t.join("|")}`:""}(g),L=function(e){const t=Object.keys(e).map((e=>`"${e}"`));return t.length?`export type Templates = ${t.join("|")}`:""}(b),R=function(e){const t=Object.keys(e).map((t=>"detail"===e[t].type.mode?`"${t}"`:"")).filter(Boolean);return t.length?`export type DetailTemplates = ${t.join("|")}`:""}(b),M=function(e){const t=[];for(const n in e){const i=e[n],o=i.content.filter((e=>"ComponentArray"===e.type)).map((({key:e})=>`"${e}"`)).filter(Boolean),r=o&&(null==o?void 0:o.length)>0?`${i.component}?: NonEmptyArray<${o.join("|")}>;`:"";t.push(r)}return`\n\t\texport type SectionList = { ${t.join("")} }\n\t`}(b),P=function(e){const{contentTypeSuffix:t,interfaceSuffix:n}=y(),i=Object.keys(e).map((e=>`${e}${t}${n}`));return i.length?`export type Taxonomy${t}${n} = ${i.join("|")}`:""}(i),G=function(e){const{contentTypeSuffix:t,interfaceSuffix:n}=y(),i=Object.keys(e).map((e=>`${e}${t}${n}`));return i.length?`export type Simple${t}${n} = ${i.join("|")}`:""}(a),B=function(e){const{contentTypeSuffix:t,interfaceSuffix:n}=y(),i=Object.keys(e).map((e=>`${e}${t}${n}`));return i.length?`export type Page${t}${n} = ${i.join("|")}`:""}(s),{SUBTHEMES:H,THEMES:K}=function(e,t){return{THEMES:e?`export type Themes = ${e.map((e=>`"${e.value}"`)).join("|")}`:"",SUBTHEMES:t?`export type Subthemes = ${t.map((e=>`"${e}"`)).join("|")}`:""}}(T,$),{DATAPACKS:q,DATAPACKS_CATEGORIES:W}=function(e,t){return{DATAPACKS:e?`export type Datapacks = ${Object.keys(e).map((e=>`"${e}"`)).join("|")}`:"",DATAPACKS_CATEGORIES:t?`export type DatapacksCategories = ${Object.keys(t).map((e=>`"${e}"`)).join("|")}`:""}}(u,l),Y=yield function(e){return r(this,void 0,void 0,(function*(){const t=yield o.resolveConfigFile(),n=(yield o.resolveConfig(t))||{useTabs:!0},i=Object.assign(Object.assign({},n),{parser:"typescript"});return(yield o.format(e,i)).replace(/^\s*\n/gm,"")}))}(`\n\t\t${N}\n\t\t${v}\n\t\t${k}\n\t\t${C} \n\t\t${_}\n\t\t${D}\n\t\t${A}\n\t\t${w}\n\t\t${I}\n\t\t${L}\n\t\t${R}\n\t\t${M}\n\t\t${x}\n\t\t${q}\n\t\t${W}\n\t\t${P}\n\t\t${G}\n\t\t${B}\n\t\t${K}\n\t\t${H}\n\t\t`);e.writeFileSync(F,Y),console.log(U)}))}r(void 0,void 0,void 0,(function*(){const e=t.join(f(),"griddo.config.ts");try{const t=yield import(e),{categoryContentTypes:n,componentsSchema:i,pageContentTypes:o,simpleContentTypes:r}=function(e){return{categoryContentTypes:function(e){const t={};for(const n in e){const i=e[n];!i.fromPage&&i.taxonomy&&(t[n]=i)}return t}(e.schemas.structuredData),pageContentTypes:function(e){const t={};for(const n in e){const i=e[n];i.fromPage&&(t[n]=i)}return t}(e.schemas.structuredData),simpleContentTypes:function(e){const t={};for(const n in e){const i=e[n];i.fromPage||i.taxonomy||(t[n]=i)}return t}(e.schemas.structuredData),componentsSchema:function(e){const t={};for(const n in e){const i=e[n];"component"===i.schemaType&&(t[n]=i)}return t}(e.schemas.all)}}(t);B({categoryContentTypes:n,pageContentTypes:o,simpleContentTypes:r,componentsSchema:i,modulesSchema:t.schemas.modules,templatesSchema:t.schemas.templates,structuredDataSchema:t.schemas.structuredData,menuItemsSchemas:t.schemas.menuItems,languagesSchemas:t.schemas.languages,moduleCategoriesSchema:t.moduleCategories,datapacksSchema:t.schemas.dataPacks,datapacksCategoriesSchema:t.schemas.dataPacksCategories,themesSchema:t.themes,subthemesSchema:t.subthemes,config:t.autotypes})}catch(t){console.error(`Failed to load config file from ${e}:`,t)}}));export{B as main};
|
|
1
|
+
import e from"node:fs";import t from"node:path";import{fileURLToPath as n}from"node:url";import i from"node:process";import o from"prettier";function r(e,t,n,i){return new(n||(n=Promise))((function(o,r){function s(e){try{c(i.next(e))}catch(e){r(e)}}function a(e){try{c(i.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((i=i.apply(e,t||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const s={directory:"isDirectory",file:"isFile"};const a=(e,t)=>t[s[e]]();function c(o,{cwd:r=i.cwd(),type:c="file",allowSymlinks:l=!0}={}){var u;!function(e){if(!Object.hasOwnProperty.call(s,e))throw new Error(`Invalid type specified: ${e}`)}(c),r=(u=r)instanceof URL?n(u):u;const p=l?e.statSync:e.lstatSync;for(const e of o)try{const n=p(t.resolve(r,e),{throwIfNoEntry:!1});if(!n)continue;if(a(c,n))return e}catch{}}const l=Symbol("findUpStop");function u(e,i={}){let o=t.resolve(((r=i.cwd)instanceof URL?n(r):r)||"");var r;const{root:s}=t.parse(o),a=i.stopAt||s,u=i.limit||Number.POSITIVE_INFINITY,p=[e].flat(),d=t=>{if("function"!=typeof e)return c(p,t);const n=e(t.cwd);return"string"==typeof n?c([n],t):n},m=[];for(;;){const e=d({...i,cwd:o});if(e===l)break;if(e&&m.push(t.resolve(o,e)),o===a||m.length>=u)break;o=t.dirname(o)}return m}function p({cwd:e}={}){const n=function(e,t={}){return u(e,{...t,limit:1})[0]}("package.json",{cwd:e});return n&&t.dirname(n)}const d=__dirname.includes("node_modules");function m(){const e=__dirname,n=d?"../../../":"../griddo-components";return t.resolve(p({cwd:e}),n)}function f(){var e,n,i;const o=t.join(m(),"griddo.config.ts"),r=require(o);return{interfaceSuffix:(null===(e=r.autotypes)||void 0===e?void 0:e.interfaceSuffix)||"Props",contentTypeSuffix:(null===(n=r.autotypes)||void 0===n?void 0:n.contentTypeSuffix)||"ContentType",publicApiSuffix:(null===(i=r.autotypes)||void 0===i?void 0:i.publicApiSuffix)||"List"}}const y=/[\p{Lu}]/u,g=/[\p{Ll}]/u,h=/^[\p{Lu}](?![\p{Lu}])/gu,$=/([\p{Alpha}\p{N}_]|$)/u,b=/[_.\- ]+/,T=new RegExp("^"+b.source),S=new RegExp(b.source+$.source,"gu"),F=new RegExp("\\d+"+$.source,"gu");function C(e,t){if("string"!=typeof e&&!Array.isArray(e))throw new TypeError("Expected the input to be `string | string[]`");if(t={pascalCase:!1,preserveConsecutiveUppercase:!1,...t},0===(e=Array.isArray(e)?e.map((e=>e.trim())).filter((e=>e.length)).join("-"):e.trim()).length)return"";const n=!1===t.locale?e=>e.toLowerCase():e=>e.toLocaleLowerCase(t.locale),i=!1===t.locale?e=>e.toUpperCase():e=>e.toLocaleUpperCase(t.locale);if(1===e.length)return b.test(e)?"":t.pascalCase?i(e):n(e);return e!==n(e)&&(e=((e,t,n,i)=>{let o=!1,r=!1,s=!1,a=!1;for(let c=0;c<e.length;c++){const l=e[c];a=!(c>2)||"-"===e[c-3],o&&y.test(l)?(e=e.slice(0,c)+"-"+e.slice(c),o=!1,s=r,r=!0,c++):r&&s&&g.test(l)&&(!a||i)?(e=e.slice(0,c-1)+"-"+e.slice(c-1),s=r,r=!1,o=!0):(o=t(l)===l&&n(l)!==l,s=r,r=n(l)===l&&t(l)!==l)}return e})(e,n,i,t.preserveConsecutiveUppercase)),e=e.replace(T,""),e=t.preserveConsecutiveUppercase?((e,t)=>(h.lastIndex=0,e.replaceAll(h,(e=>t(e)))))(e,n):n(e),t.pascalCase&&(e=i(e.charAt(0))+e.slice(1)),((e,t)=>(S.lastIndex=0,F.lastIndex=0,e.replaceAll(F,((n,i,o)=>["_","-"].includes(e.charAt(o+n.length))?n:t(n))).replaceAll(S,((e,n)=>t(n)))))(e,i)}function v(e,t){var n;const{returnTypeName:i,generic:o}=t||{},r="hideable"in e&&Boolean(e.hideable),s=o?`<${o}>`:"",a=`${i||x(e.type)}${s}`,c=r?`Hideable<${a}>`:`${a}`;return`\n\t\t${(null===(n=e._autoType)||void 0===n?void 0:n.doc)||""}\n\t\t${`${e.key}?: ${c}`}\n\t`}function k(e){const{interfaceSuffix:t}=f();return e.length>1?`{\n\t\t\t${e.map((e=>`${C(e)}?: ${e}${t}`)).join(",")}\n\t\t\t}`:e.map((e=>`${e}${t}`)).join("")}function x(e){return{ArrayFieldGroup:"Fields.ArrayFieldGroup",AsyncCheckGroup:"Fields.AsyncCheckGroup",AsyncSelect:"Fields.AsyncSelect",CheckGroup:"Fields.CheckGroup",ColorPicker:"Fields.ColorPicker",ComponentArray:"Fields.ComponentArray",ComponentContainer:"Fields.ComponentContainer",ConditionalField:"Fields.Conditional",DateField:"Fields.Date",FieldGroup:"Fields.FieldGroup",FieldsDivider:"Fields.FieldsDivider",FileField:"Fields.File",HeadingField:"Fields.Heading",ImageField:"Fields.Image",LinkField:"Fields.Link",MultiCheckSelect:"Fields.MultiCheckSelect",MultiCheckSelectGroup:"Fields.MultiCheckSelectGroup",NoteField:"Fields.Note",NumberField:"Fields.Number",RadioGroup:"Fields.RadioGroup",ReferenceField:"Fields.Reference",RichText:"Fields.RichText",Select:"Fields.Select",SliderField:"Fields.Slider",TagsField:"Fields.Tags",TextArea:"Fields.TextArea",TextField:"Fields.Text",TimeField:"Fields.Time",ToggleField:"Fields.Toggle",UniqueCheck:"Fields.UniqueCheck",UrlField:"Fields.Url",VisualUniqueSelection:"Fields.VisualUniqueSelection",Wysiwyg:"Fields.Wysiwyg"}[e]}function j(e,t,n){var i,o;const{contentTypeSuffix:r,interfaceSuffix:s}=f();if("FieldsDivider"===e.type)return"// FieldsDivider";if(null===(i=e._autoType)||void 0===i?void 0:i.ignore)return"// Ignored by AutoType.ignore";const{type:a,_autoType:c,key:l}=e,{hasDistributorData:u,getStaticData:p}=n;if(!a||!l)return"\n\t\t\t/** · (ノ-_-)ノ ミ ┴┴ You forgot to write the `type` | `key` or some mandatory prop */\n\t\t";if("DateField"===a||"FileField"===a||"ImageField"===a||"NoteField"===a||"NumberField"===a||"RichText"===a||"SliderField"===a||"TagsField"===a||"TextArea"===a||"TextField"===a||"TimeField"===a||"ToggleField"===a||"UniqueCheck"===a||"UrlField"===a||"Wysiwyg"===a)return v(e);if("MultiCheckSelect"===a){if("pageContentType"===t||"simpleContentType"===t){return v(e,{generic:`Relations, FromList, ${`${e.source}${r}${s}`}<false, false>, FromDistributor`})}return v(e,{generic:"true"})}if("AsyncCheckGroup"===a){if("pageContentType"===t||"simpleContentType"===t){return v(e,{generic:`Relations, FromList, ${`${e.source}${r}${s}`}<false, false>, FromDistributor`})}return v(e,{generic:"true"})}if("MultiCheckSelectGroup"===a){const t=e.elements.map((e=>`"${e.key}"`)).join("|");return v(e,{generic:[t,null===(o=e._autoType)||void 0===o?void 0:o.relations].join(",")})}if("ColorPicker"===a)return e.isThemePalette?v(e,{returnTypeName:"Fields.ColorPickerFixed"}):v(e);if("HeadingField"===a||"RadioGroup"===a||"Select"===a){const{options:t}=e,n=function(e){return e.map((({value:e})=>"string"==typeof e?`"${e}"`:e)).join("|")}(t);return v(e,{generic:n})}if("CheckGroup"===a){const{options:t}=e,n=function(e){return e.map((({name:e})=>"string"==typeof e?`"${e}"`:e)).join("|")}(t);return v(e,{generic:n})}if("LinkField"===a){const{whiteList:t}=e;return v(e,{generic:k(t)})}if("AsyncSelect"===a){if("entity"in e&&"menu_containers"===e.entity)return`\n${l}?: Menu`;if("pageContentType"===t||"simpleContentType"===t){return v(e,{generic:`Relations, FromList, ${`${e.source}${r}${s}`}<false, false>, FromDistributor`})}return`\n${l}?: Fields.AsyncSelect;`}if("FieldGroup"===a)return`\n\t\t\t// << ${a}\n\t\t\t${e.fields.map((e=>j(e,t,n))).join("")}\n\t\t\t// end >>\n\t\t`;if("ArrayFieldGroup"===a){return`\n\t\t\t\n${(null==c?void 0:c.doc)||""}\n${l}?: Fields.ArrayFieldGroup<{${e.fields.map((e=>j(e,t,n))).join(",")}}>\n\t\t`}if("ConditionalField"===a){const i=e.fields.map((e=>j(e,t,n))),o=(null==c?void 0:c.doc)||"",r="hideable"in e&&e.hideable,s=r?">":"";return`\n\t\t\t// << ${a}\n\t\t\t\n${o}\n${l}?: ${r?"Hideable<":""}${x(a)}<${e.options.map((e=>"string"==typeof e.value?`"${e.value}"`:e.value)).join("|")}>${s};\n\t\t\t${i.join("")}\n\t\t\t// end >>\n\t\t`}if("ComponentArray"===a){const i="template"===t||"pageContentType"===t?"TemplateSection":"ComponentArray",o="template"===t?"":"?",r=e,{key:a,_autoType:c,whiteList:l}=r,u=(null==c?void 0:c.doc)||"",p=(e,t,n)=>e.filter((e=>{if(e&&"schemaType"in e&&"module"===(null==e?void 0:e.schemaType))return(null==e?void 0:e.sectionList)&&!!(null==e?void 0:e.sectionList[t])})).map((e=>({t:null==e?void 0:e.sectionList[t].filter((e=>e===n)),m:null==e?void 0:e.component}))).filter((e=>{var t;return null===(t=null==e?void 0:e.t)||void 0===t?void 0:t.length})).map((e=>null==e?void 0:e.m)).filter(Boolean);let d="";"template"===t&&(d=p(n.moduleSchemas,n.schema.component,a).join("|"));return`\n${u}\n${a}${o}: Fields.${i}<${[...new Set([...d.split("|"),...l])].filter(Boolean).map((e=>`${e}${s}`)).join("|")}>;`}if("ComponentContainer"===a&&("object"===t||"component"===t||"module"===t||"template"===t||"pageContentType"===t)){const t=e,{whiteList:n}=t;return v(e,{generic:k(n)})}if("ReferenceField"===a){const t=e.sources||[{structuredData:void 0}],n=Array.isArray(t)&&t.map((e=>e.structuredData?`${e.structuredData}${r}${s}`:"unknown")).join("|")||"";return`\n\t\t \t${v(e,{generic:n})}\n\t\t \t${u||p?`queriedItems?: Fields.QueriedData<${n}>;`:""}\n\t\t `}if("VisualUniqueSelection"===a){const t=e.options[0],n=e.options[0];let i="";if(t.value){i=e.options.map((e=>`"${e.value}"`)).join("|")}if(n.theme){i=e.options[0].options.map((e=>`"${e.value}"`)).join("|")}return v(e,{generic:i})}return console.warn(`The field ${e.type} has not been implemented yet ㅠ.ㅠ`),""}function _(e,t,n){return function(e){if("fromPage"in e)return e.taxonomy?[]:e.schema.fields;if("template"===e.schemaType){return[...e.content||[],...e.config||[]]}if("component"===e.schemaType||"module"===e.schemaType)return e.configTabs.flatMap((e=>e.fields));throw new Error(`Wrong schema ${JSON.stringify(e,null,2)}`)}(e).map((i=>j(i,n.kind,{hasDistributorData:n.hasDistributorData,getStaticData:n.getStaticData,moduleSchemas:t,schema:e}))).filter(Boolean).join("")}function A(e){const t=(n=e,Object.keys(n).map((e=>Object.assign(Object.assign({},n[e]),{component:e}))));var n;const{interfaceSuffix:i}=f(),{ARRAY_OF_MODULE_SCHEMAS:o}=function(e){return{ARRAY_OF_MODULE_SCHEMAS:e.map((e=>{if("schemaType"in e&&"module"===e.schemaType)return e})).filter(Boolean)}}(t);return t.map((e=>{var t;let n={kind:"component",contentTypeSuffixStr:"",contentTypeName:"",contentTypeKind:"",relatedContentTypeNames:"",componentName:"",hasDistributorData:!1,getStaticData:!1,interfaceForPublicAPI:"",relationsGeneric:(null===(t=e._autoType)||void 0===t?void 0:t.relations)?"<Relations = unknown, FromList = unknown, FromDistributor = true>":""};if(function(e){return"fromPage"in e}(e)){const t=function(e){const{contentTypeSuffix:t,interfaceSuffix:n,publicApiSuffix:i}=f(),o=[],r=[],s=[],a=e.fromPage?"pageContentType":"simpleContentType";"pageContentType"===a&&o.push(`"${e.component}"`),"simpleContentType"!==a||e.taxonomy||r.push(`"${e.component}"`),"simpleContentType"===a&&e.taxonomy&&s.push(`"${e.component}"`);let c="";if("schema"in e){const t=e.schema.fields.map((e=>"source"in e&&(null==e?void 0:e.source))).filter(Boolean);c=t.length?`__relatedContentTypeNames: ${JSON.stringify(t)}`:""}const l=`\n\t\t\t\t/** Type to be consumed by public API: useList(), etc.. */\n\t\t\t\texport type ${e.component}${t}${i}${n}<R extends Core.ContentTypeRelations = false> = ${e.component}${t}${n}<R, true>;\n\t\t\t\t`;return{kind:a,componentName:"",contentTypeName:`__contentTypeName: "${e.component}";`,contentTypeKind:`__contentTypeKind: "${a}";`,contentTypeSuffixStr:t,getStaticData:!1,hasDistributorData:!1,relatedContentTypeNames:c,relationsGeneric:"<Relations = unknown, FromList = unknown, FromDistributor = true>",interfaceForPublicAPI:l}}(e);n=Object.assign(Object.assign({},n),t)}if(function(e){return"schemaType"in e}(e)){const t=function(e){let t=!1,n=!1;return"template"!==e.schemaType&&"module"!==e.schemaType&&"component"!==e.schemaType||(t=e.default.hasDistributorData,n=e.default.getStaticData),{kind:e.schemaType,componentName:`component: "${e.component}"`,contentTypeName:"",contentTypeKind:"",contentTypeSuffixStr:"",relatedContentTypeNames:"",relationsGeneric:"",interfaceForPublicAPI:"",hasDistributorData:t,getStaticData:n}}(e);n=Object.assign(Object.assign({},n),t)}const r=_(e,o,n);return`\n\t\t\t\texport interface ${e.component}${n.contentTypeSuffixStr}${i}${n.relationsGeneric} ${function(e){const t=function(e){return"schemaType"in e&&"template"===e.schemaType&&("list"===e.type.mode||"paginated-data"===e.type.mode)}(e)?"Fields.ExtraListTemplateProps":"";return(n=[t]).filter((e=>e.length)).length<1?"":`extends ${n.join(", ")}`;var n}(e)} {\n\t\t\t\t\t${n.contentTypeName}\n\t\t\t\t\t${n.contentTypeKind}\n\t\t\t\t\t${n.relatedContentTypeNames}\n\t\t\t\t\t${n.componentName}\n\t\t\t\t\t${r}\n\t\t\t\t\t${function(e){return"fromPage"in e&&!e.fromPage&&!0===e.taxonomy}(e)?"title?: string; code?: string":""}\n\t\t\t\t}\n\t\t\t\t${n.interfaceForPublicAPI}\n\t\t\t`})).join("")}function D(e){return e?e.map((e=>j(e,"object",{hasDistributorData:!1,getStaticData:!1,moduleSchemas:[],schema:{}}))).join(""):""}function w(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var O,E;var I=function(){if(E)return O;E=1;const{FORCE_COLOR:e,NODE_DISABLE_COLORS:t,TERM:n}=process.env,i={enabled:!t&&"dumb"!==n&&"0"!==e,reset:r(0,0),bold:r(1,22),dim:r(2,22),italic:r(3,23),underline:r(4,24),inverse:r(7,27),hidden:r(8,28),strikethrough:r(9,29),black:r(30,39),red:r(31,39),green:r(32,39),yellow:r(33,39),blue:r(34,39),magenta:r(35,39),cyan:r(36,39),white:r(37,39),gray:r(90,39),grey:r(90,39),bgBlack:r(40,49),bgRed:r(41,49),bgGreen:r(42,49),bgYellow:r(43,49),bgBlue:r(44,49),bgMagenta:r(45,49),bgCyan:r(46,49),bgWhite:r(47,49)};function o(e,t){let n,i=0,o="",r="";for(;i<e.length;i++)n=e[i],o+=n.open,r+=n.close,t.includes(n.close)&&(t=t.replace(n.rgx,n.close+n.open));return o+t+r}function r(e,t){let n={open:`[${e}m`,close:`[${t}m`,rgx:new RegExp(`\\x1b\\[${t}m`,"g")};return function(t){return void 0!==this&&void 0!==this.has?(this.has.includes(e)||(this.has.push(e),this.keys.push(n)),void 0===t?this:i.enabled?o(this.keys,t+""):t+""):void 0===t?function(e,t){let n={has:e,keys:t};return n.reset=i.reset.bind(n),n.bold=i.bold.bind(n),n.dim=i.dim.bind(n),n.italic=i.italic.bind(n),n.underline=i.underline.bind(n),n.inverse=i.inverse.bind(n),n.hidden=i.hidden.bind(n),n.strikethrough=i.strikethrough.bind(n),n.black=i.black.bind(n),n.red=i.red.bind(n),n.green=i.green.bind(n),n.yellow=i.yellow.bind(n),n.blue=i.blue.bind(n),n.magenta=i.magenta.bind(n),n.cyan=i.cyan.bind(n),n.white=i.white.bind(n),n.gray=i.gray.bind(n),n.grey=i.grey.bind(n),n.bgBlack=i.bgBlack.bind(n),n.bgRed=i.bgRed.bind(n),n.bgGreen=i.bgGreen.bind(n),n.bgYellow=i.bgYellow.bind(n),n.bgBlue=i.bgBlue.bind(n),n.bgMagenta=i.bgMagenta.bind(n),n.bgCyan=i.bgCyan.bind(n),n.bgWhite=i.bgWhite.bind(n),n}([e],[n]):i.enabled?o([n],t+""):t+""}}return O=i}();const L=`${w(I).green(" ✔")} AutoTypes`;function M(n){return r(this,void 0,void 0,(function*(){const{categoryContentTypes:i,pageContentTypes:s,simpleContentTypes:a,componentsSchema:c,datapacksCategoriesSchema:l,datapacksSchema:u,languagesSchemas:p,menuItemsSchemas:d,moduleCategoriesSchema:y,modulesSchema:g,structuredDataSchema:h,subthemesSchema:$,templatesSchema:b,themesSchema:T}=n,S=Object.assign(Object.assign(Object.assign(Object.assign({},c),g),b),h),F=t.join(m(),"autotypes.d.ts"),C=A(S),v=function(e){var t,n;const i=null===(t=null==e?void 0:e.link)||void 0===t?void 0:t.fields,o=null===(n=null==e?void 0:e.group)||void 0===n?void 0:n.fields;return`\n\t\texport interface InstanceMenuItems {\n\t\t\tlink:{\n\t\t\t\t${D(i)}\n\t\t\t\tconfig?: {\n\t\t\t\t\theaderStyle?: string;\n\t\t\t\t\tfooterStyle?: string;\n\t\t\t\t\ttype?: "link";\n\t\t\t\t};\n\t\t\t};\n\t\t\tgroup: {\n\t\t\t\turl?: null;\n\t\t\t\t${D(o)}\n\t\t\t\tconfig?: {\n\t\t\t\t\theaderStyle?: string;\n\t\t\t\t\tfooterStyle?: string;\n\t\t\t\t\ttype?: "group";\n\t\t\t\t};\n\t\t\t};\n\t\t}\n\t\texport type LinkMenuElement = Fields.BaseLinkElement<InstanceMenuItems> & InstanceMenuItems["link"];\n\t\texport type GroupMenuElement = Fields.BaseLinkElement<InstanceMenuItems> & InstanceMenuItems["group"];\n\t\texport type MenuElement = LinkMenuElement | GroupMenuElement;\n\t\texport type Menu = Fields.Menu<InstanceMenuItems>;\n\t`}(d),k=function(e){const t=Object.keys(e);return`\n\t\texport interface SiteLanguage {\n\t\t\tdomain: { id: number; url: string; slug: string };\n\t\t\thome: string;\n\t\t\tid: number;\n\t\t\tisDefault: boolean;\n\t\t\tlabel: ${t.map((t=>`"${e[t].label}"`)).join("|")};\n\t\t\tlanguage: ${t.map((t=>`"${e[t].name}"`)).join("|")};\n\t\t\tlocale: ${t.map((e=>`"${e}"`)).join("|")}\n\t\t\tpath: string;\n\t\t}\n\t`}(p),x=(j=y)?`export type ModuleCategories = ${j.map((e=>`"${e.value}"`)).join("|")}`:"";var j;const _=function(e){const t=Object.keys(e).map((e=>`"${e}"`));return t.length?`export type TaxonomyContentTypes = ${t.join("|")}`:""}(i),w=function(e){const t=Object.keys(e).map((e=>`"${e}"`));return t.length?`export type PageContentTypes = ${t.join("|")}`:""}(s),O=function(e){const t=Object.keys(e).map((e=>`"${e}"`));return t.length?`export type SimpleContentTypes = ${t.join("|")}`:""}(a),E=function(e){const t=Object.keys(e).map((e=>`"${e}"`));return t.length?`export type Components = ${t.join("|")}`:""}(c),I=function(e){const t=Object.keys(e).map((e=>`"${e}"`));return t.length?`export type Modules = ${t.join("|")}`:""}(g),M=function(e){const t=Object.keys(e).map((e=>`"${e}"`));return t.length?`export type Templates = ${t.join("|")}`:""}(b),P=function(e){const t=Object.keys(e).map((t=>"detail"===e[t].type.mode?`"${t}"`:"")).filter(Boolean);return t.length?`export type DetailTemplates = ${t.join("|")}`:""}(b),R=function(e){const t=[];for(const n in e){const i=e[n],o=i.content.filter((e=>"ComponentArray"===e.type)).map((({key:e})=>`"${e}"`)).filter(Boolean),r=o&&(null==o?void 0:o.length)>0?`${i.component}?: NonEmptyArray<${o.join("|")}>;`:"";t.push(r)}return`\n\t\texport type SectionList = { ${t.join("")} }\n\t`}(b),G=function(e){const{contentTypeSuffix:t,interfaceSuffix:n}=f(),i=Object.keys(e).map((e=>`${e}${t}${n}`));return i.length?`export type Taxonomy${t}${n} = ${i.join("|")}`:""}(i),N=function(e){const{contentTypeSuffix:t,interfaceSuffix:n}=f(),i=Object.keys(e).map((e=>`${e}${t}${n}`));return i.length?`export type Simple${t}${n} = ${i.join("|")}`:""}(a),U=function(e){const{contentTypeSuffix:t,interfaceSuffix:n}=f(),i=Object.keys(e).map((e=>`${e}${t}${n}`));return i.length?`export type Page${t}${n} = ${i.join("|")}`:""}(s),{SUBTHEMES:B,THEMES:H}=function(e,t){return{THEMES:e?`export type Themes = ${e.map((e=>`"${e.value}"`)).join("|")}`:"",SUBTHEMES:t?`export type Subthemes = ${t.map((e=>`"${e}"`)).join("|")}`:""}}(T,$),{DATAPACKS:K,DATAPACKS_CATEGORIES:q}=function(e,t){return{DATAPACKS:e?`export type Datapacks = ${Object.keys(e).map((e=>`"${e}"`)).join("|")}`:"",DATAPACKS_CATEGORIES:t?`export type DatapacksCategories = ${Object.keys(t).map((e=>`"${e}"`)).join("|")}`:""}}(u,l),W=yield function(e){return r(this,void 0,void 0,(function*(){const t=yield o.resolveConfigFile(),n=(yield o.resolveConfig(t))||{useTabs:!0},i=Object.assign(Object.assign({},n),{parser:"typescript"});return(yield o.format(e,i)).replace(/^\s*\n/gm,"")}))}(`\n\t\t/* eslint-disable @typescript-eslint/ban-types */\n/* eslint-disable @typescript-eslint/no-unused-vars */\n/* eslint-disable no-use-before-define */\n//\n//\n// ' ____\n// /\\ \\\n// º / /\\ \\\n// ' / / \\ _>\n// ' _\\ \\__> \\__\n// ' O ( __;·;______ ) AutoTypes\n// O º, | , , \\ \\\\ ·..~~.·~.·\n// ,,, /| , , /\\ <\\\\\n// \\''\\-' ⎩, <\\/\\ \\ \\\n// \\_/ /\\_____⎩/ > > >\n// '___' <_(_)__> / \\ <\n// / / ´ \\ | \\___//\\\\\n// / / | / > > \\\\\n// · ··~~~~·~·~~~~~~~·~··~~~~~·~·~~·~~~~·~~~~~·· · ·\n//\n// Embrace the beauty of effortless typing by indulging in the benefits of them\n// sans the actual typing!\n//\n// Behold! These dynamically generated types were conjured from the schemas\n// nestled within this repository. However, should you yearn to expand upon\n// these types, kindly abstain from doing so in this file, lest AutoTypes'\n// magic shall smite your changes with each schema modification.\n//\n// Check out the details of Griddo AutoTypes in:\n// https://griddoio.notion.site/Griddo-AutoTypes-e7420867dd2e489c8da34a493b763cd8>\n//\n// Happy magic types!\n//\nimport { Core, Fields, Hideable, NonEmptyArray } from "@griddo/core"\n//\n\n\t\t${v}\n\t\t${k}\n\t\t${C} \n\t\t${w}\n\t\t${O}\n\t\t${_}\n\t\t${E}\n\t\t${I}\n\t\t${M}\n\t\t${P}\n\t\t${R}\n\t\t${x}\n\t\t${K}\n\t\t${q}\n\t\t${G}\n\t\t${N}\n\t\t${U}\n\t\t${H}\n\t\t${B}\n\t\t`);e.writeFileSync(F,W),console.log(L)}))}r(void 0,void 0,void 0,(function*(){const e=t.join(m(),"griddo.config.ts");try{const t=yield import(e),{categoryContentTypes:n,componentsSchema:i,pageContentTypes:o,simpleContentTypes:r}=function(e){return{categoryContentTypes:function(e){const t={};for(const n in e){const i=e[n];!i.fromPage&&i.taxonomy&&(t[n]=i)}return t}(e.schemas.structuredData),pageContentTypes:function(e){const t={};for(const n in e){const i=e[n];i.fromPage&&(t[n]=i)}return t}(e.schemas.structuredData),simpleContentTypes:function(e){const t={};for(const n in e){const i=e[n];i.fromPage||i.taxonomy||(t[n]=i)}return t}(e.schemas.structuredData),componentsSchema:function(e){const t={};for(const n in e){const i=e[n];"component"===i.schemaType&&(t[n]=i)}return t}(e.schemas.all)}}(t);M({categoryContentTypes:n,pageContentTypes:o,simpleContentTypes:r,componentsSchema:i,modulesSchema:t.schemas.modules,templatesSchema:t.schemas.templates,structuredDataSchema:t.schemas.structuredData,menuItemsSchemas:t.schemas.menuItems,languagesSchemas:t.schemas.languages,moduleCategoriesSchema:t.moduleCategories,datapacksSchema:t.schemas.dataPacks,datapacksCategoriesSchema:t.schemas.dataPacksCategories,themesSchema:t.themes,subthemesSchema:t.subthemes,config:t.autotypes})}catch(t){console.error(`Failed to load config file from ${e}:`,t)}}));export{M as main};
|
|
2
2
|
//# sourceMappingURL=autotypes.js.map
|