@griddo/core 11.0.25 → 11.0.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/README.md +0 -1
  2. package/dist/autotypes.js +1 -1
  3. package/dist/autotypes.js.map +1 -1
  4. package/dist/bin-tools/autotypes/misc/ascii.d.ts +2 -2
  5. package/dist/bin-tools/autotypes/misc/utils.d.ts +66 -3
  6. package/dist/bin-tools/autotypes/parser/index.d.ts +23 -0
  7. package/dist/bin-tools/autotypes/parsers-list/components-name.d.ts +5 -0
  8. package/dist/bin-tools/autotypes/parsers-list/data-templates-names.d.ts +5 -0
  9. package/dist/bin-tools/autotypes/parsers-list/datapacks.d.ts +8 -0
  10. package/dist/bin-tools/autotypes/parsers-list/form-fields.d.ts +5 -0
  11. package/dist/bin-tools/autotypes/parsers-list/form-templates.d.ts +5 -0
  12. package/dist/bin-tools/autotypes/parsers-list/index.d.ts +42 -0
  13. package/dist/bin-tools/autotypes/parsers-list/languages.d.ts +5 -0
  14. package/dist/bin-tools/autotypes/parsers-list/menu-items.d.ts +6 -0
  15. package/dist/bin-tools/autotypes/parsers-list/module-categories.d.ts +5 -0
  16. package/dist/bin-tools/autotypes/parsers-list/modules-name.d.ts +5 -0
  17. package/dist/bin-tools/autotypes/parsers-list/page-data-props.d.ts +5 -0
  18. package/dist/bin-tools/autotypes/parsers-list/page-data.d.ts +5 -0
  19. package/dist/bin-tools/autotypes/parsers-list/simple-data-props.d.ts +5 -0
  20. package/dist/bin-tools/autotypes/parsers-list/simple-data.d.ts +5 -0
  21. package/dist/bin-tools/autotypes/parsers-list/taxonomy-props.d.ts +5 -0
  22. package/dist/bin-tools/autotypes/parsers-list/taxonomy.d.ts +5 -0
  23. package/dist/bin-tools/autotypes/parsers-list/template-section-list.d.ts +5 -0
  24. package/dist/bin-tools/autotypes/parsers-list/templates-name.d.ts +5 -0
  25. package/dist/bin-tools/autotypes/parsers-list/themes.d.ts +8 -0
  26. package/dist/bin-tools/autotypes/{factories/props/getUIAndData/utils.d.ts → parsers-list/ui-data-props.d.ts} +6 -2
  27. package/dist/contexts/Page/index.d.ts +1 -1
  28. package/dist/hooks/index.d.ts +1 -2
  29. package/dist/index.d.ts +2 -2
  30. package/dist/index.js +1 -1
  31. package/dist/index.js.map +1 -1
  32. package/dist/types/core/index.d.ts +0 -3
  33. package/dist/types/schemas/SimpleContentType.d.ts +34 -11
  34. package/package.json +2 -2
  35. package/dist/bin-tools/autotypes/autotypes.d.ts +0 -11
  36. package/dist/bin-tools/autotypes/factories/index.d.ts +0 -20
  37. package/dist/bin-tools/autotypes/factories/names/getComponents.d.ts +0 -2
  38. package/dist/bin-tools/autotypes/factories/names/getDetailTemplates.d.ts +0 -2
  39. package/dist/bin-tools/autotypes/factories/names/getFormFieldsNames.d.ts +0 -2
  40. package/dist/bin-tools/autotypes/factories/names/getFormTemplatesNames.d.ts +0 -2
  41. package/dist/bin-tools/autotypes/factories/names/getModules.d.ts +0 -2
  42. package/dist/bin-tools/autotypes/factories/names/getPageData.d.ts +0 -2
  43. package/dist/bin-tools/autotypes/factories/names/getSimpleData.d.ts +0 -2
  44. package/dist/bin-tools/autotypes/factories/names/getTaxonomy.d.ts +0 -2
  45. package/dist/bin-tools/autotypes/factories/names/getTemplates.d.ts +0 -2
  46. package/dist/bin-tools/autotypes/factories/props/getPageData.d.ts +0 -2
  47. package/dist/bin-tools/autotypes/factories/props/getSectionList.d.ts +0 -8
  48. package/dist/bin-tools/autotypes/factories/props/getSimpleData.d.ts +0 -2
  49. package/dist/bin-tools/autotypes/factories/props/getTaxonomyData.d.ts +0 -2
  50. package/dist/bin-tools/autotypes/factories/props/getTypeFromField/index.d.ts +0 -25
  51. package/dist/bin-tools/autotypes/factories/props/getTypeFromField/utils.d.ts +0 -41
  52. package/dist/bin-tools/autotypes/factories/props/getUIAndData/index.d.ts +0 -2
  53. package/dist/bin-tools/autotypes/factories/schemas/getDataPacks.d.ts +0 -5
  54. package/dist/bin-tools/autotypes/factories/schemas/getLanguages.d.ts +0 -2
  55. package/dist/bin-tools/autotypes/factories/schemas/getMenuItems.d.ts +0 -2
  56. package/dist/bin-tools/autotypes/factories/schemas/getModuleCategories.d.ts +0 -14
  57. package/dist/bin-tools/autotypes/factories/schemas/getThemes.d.ts +0 -5
  58. package/dist/hooks/useSitemap.d.ts +0 -7
package/README.md CHANGED
@@ -43,7 +43,6 @@ Components, hooks and common utilities for the instances and the Griddo product
43
43
  - `useScript()`
44
44
  - `useSession()`
45
45
  - `useSite()`
46
- - `useSitemap()`
47
46
  - `useSSR()`
48
47
 
49
48
  ## Contexts and Providers
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{l(i.next(e))}catch(e){r(e)}}function a(e){try{l(i.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}l((i=i.apply(e,t||[])).next())}))}function s(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var a,l;"function"==typeof SuppressedError&&SuppressedError;var c=s(function(){if(l)return a;l=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 a=i}());const u={directory:"isDirectory",file:"isFile"};const p=(e,t)=>t[u[e]]();function d(o,{cwd:r=i.cwd(),type:s="file",allowSymlinks:a=!0}={}){var l;!function(e){if(!Object.hasOwnProperty.call(u,e))throw new Error(`Invalid type specified: ${e}`)}(s),r=(l=r)instanceof URL?n(l):l;const c=a?e.statSync:e.lstatSync;for(const e of o)try{const n=c(t.resolve(r,e),{throwIfNoEntry:!1});if(!n)continue;if(p(s,n))return e}catch{}}const m=Symbol("findUpStop");function f(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,l=i.limit||Number.POSITIVE_INFINITY,c=[e].flat(),u=t=>{if("function"!=typeof e)return d(c,t);const n=e(t.cwd);return"string"==typeof n?d([n],t):n},p=[];for(;;){const e=u({...i,cwd:o});if(e===m)break;if(e&&p.push(t.resolve(o,e)),o===a||p.length>=l)break;o=t.dirname(o)}return p}function y({cwd:e}={}){const n=function(e,t={}){return f(e,{...t,limit:1})[0]}("package.json",{cwd:e});return n&&t.dirname(n)}const g=__dirname.includes("node_modules");function $(){const e=__dirname,n=g?"../../../":"../griddo-components";return t.resolve(y({cwd:e}),n)}function h(){var e,n,i;const o=t.join($(),"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 b=/[\p{Lu}]/u,T=/[\p{Ll}]/u,F=/^[\p{Lu}](?![\p{Lu}])/gu,v=/([\p{Alpha}\p{N}_]|$)/u,S=/[_.\- ]+/,C=new RegExp("^"+S.source),j=new RegExp(S.source+v.source,"gu"),_=new RegExp("\\d+"+v.source,"gu");function k(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 S.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 l=0;l<e.length;l++){const c=e[l];a=!(l>2)||"-"===e[l-3],o&&b.test(c)?(e=e.slice(0,l)+"-"+e.slice(l),o=!1,s=r,r=!0,l++):r&&s&&T.test(c)&&(!a||i)?(e=e.slice(0,l-1)+"-"+e.slice(l-1),s=r,r=!1,o=!0):(o=t(c)===c&&n(c)!==c,s=r,r=n(c)===c&&t(c)!==c)}return e})(e,n,i,t.preserveConsecutiveUppercase)),e=e.replace(C,""),e=t.preserveConsecutiveUppercase?((e,t)=>(F.lastIndex=0,e.replaceAll(F,(e=>t(e)))))(e,n):n(e),t.pascalCase&&(e=i(e.charAt(0))+e.slice(1)),((e,t)=>(j.lastIndex=0,_.lastIndex=0,e.replaceAll(_,((n,i,o)=>["_","-"].includes(e.charAt(o+n.length))?n:t(n))).replaceAll(j,((e,n)=>t(n)))))(e,i)}function x(e,t){var n;const{returnTypeName:i,generic:o}=t||{},r="hideable"in e&&Boolean(e.hideable),s=o?`<${o}>`:"",a=`${i||D(e.type)}${s}`,l=r?`Hideable<${a}>`:`${a}`;return`\n\t\t${(null===(n=e._autoType)||void 0===n?void 0:n.doc)||""}\n\t\t${`${e.key}?: ${l}`}\n\t`}function A(e){const{interfaceSuffix:t}=h();return e.length>1?`{\n\t\t\t${e.map((e=>`${k(e)}?: ${e}${t}`)).join(",")}\n\t\t\t}`:e.map((e=>`${e}${t}`)).join("")}function D(e){return{FormContainer:"Fields.FormContainer",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 w(e,t,n){var i,o;const{contentTypeSuffix:r,interfaceSuffix:s}=h();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:l,key:c}=e,{hasDistributorData:u,getStaticData:p}=n;if(!a||!c)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 x(e);if("MultiCheckSelect"===a){if("pageContentType"===t||"simpleContentType"===t){return x(e,{generic:`Relations, FromList, ${`${e.source}${r}${s}`}<false, false>, FromDistributor`})}return x(e,{generic:"true"})}if("AsyncCheckGroup"===a){if("pageContentType"===t||"simpleContentType"===t){return x(e,{generic:`Relations, FromList, ${`${e.source}${r}${s}`}<false, false>, FromDistributor`})}return x(e,{generic:"true"})}if("MultiCheckSelectGroup"===a){const t=e.elements.map((e=>`"${e.key}"`)).join("|");return x(e,{generic:[t,null===(o=e._autoType)||void 0===o?void 0:o.relations].join(",")})}if("ColorPicker"===a)return e.isThemePalette?x(e,{returnTypeName:"Fields.ColorPickerFixed"}):x(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 x(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 x(e,{generic:n})}if("LinkField"===a){const{whiteList:t}=e;return x(e,{generic:A(t)})}if("AsyncSelect"===a){if("entity"in e&&"menu_containers"===e.entity)return`\n${c}?: Menu`;if("pageContentType"===t||"simpleContentType"===t){return x(e,{generic:`Relations, FromList, ${`${e.source}${r}${s}`}<false, false>, FromDistributor`})}return`\n${c}?: Fields.AsyncSelect;`}if("FieldGroup"===a)return`\n\t\t\t// << ${a}\n\t\t\t${e.fields.map((e=>w(e,t,n))).join("")}\n\t\t\t// end >>\n\t\t`;if("ArrayFieldGroup"===a){return`\n\t\t\t\n${(null==l?void 0:l.doc)||""}\n${c}?: Fields.ArrayFieldGroup<{${e.fields.map((e=>w(e,t,n))).join(",")}}>\n\t\t`}if("ConditionalField"===a){const i=e.fields.map((e=>w(e,t,n))),o=(null==l?void 0:l.doc)||"",r="hideable"in e&&e.hideable,s=r?">":"";return`\n\t\t\t// << ${a}\n\t\t\t\n${o}\n${c}?: ${r?"Hideable<":""}${D(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("FormFieldArray"===a){const i="template"===t||"pageContentType"===t?"TemplateSection":"formTemplate"===t?"FormFieldArray":"ComponentArray",o="template"===t?"":"?",{key:r,_autoType:a,whiteList:l}=e,c=(null==a?void 0:a.doc)||"",u=(e,t,n)=>e.filter((e=>e&&"schemaType"in e&&"module"===(null==e?void 0:e.schemaType)?(null==e?void 0:e.sectionList)&&!!(null==e?void 0:e.sectionList[t]):void 0)).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 p="";"template"===t&&(p=u(n.moduleSchemas,n.schema.component,r).join("|"));return`\n${c}\n${r}${o}: Fields.${i}<${[...new Set([...p.split("|"),...l])].filter(Boolean).map((e=>`${e}${s}`)).join("|")}>;`}if("ComponentArray"===a){const i="template"===t||"pageContentType"===t?"TemplateSection":"ComponentArray",o="template"===t?"":"?",r=e,{key:a,_autoType:l,whiteList:c}=r,u=(null==l?void 0:l.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("|"),...c])].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 x(e,{generic:A(n)})}if("FormContainer"===a&&("object"===t||"component"===t||"module"===t||"template"===t||"pageContentType"===t)){const e="FormContainer",t=Object.keys(n.allSchemas).filter((e=>{if("formTemplate"===n.allSchemas[e].schemaType)return e}));return`\n${(null==l?void 0:l.doc)||""}\n${c}?: Fields.${e}<${t.map((e=>`${e}${s}`)).join("|")}>;`}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${x(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 x(e,{generic:i})}return console.warn(`The field ${e.type} has not been implemented yet ㅠ.ㅠ`),""}function O(e,t,n,i){return function(e){if("fromPage"in e)return e.taxonomy?[]:e.schema.fields;if("template"===e.schemaType){return[...e.content||[],...e.config||[]]}if("formTemplate"===e.schemaType){return[...e.content||[],...e.config||[]]}if("component"===e.schemaType||"module"===e.schemaType||"formComponent"===e.schemaType)return e.configTabs.flatMap((e=>e.fields));throw new Error(`Wrong schema ${JSON.stringify(e,null,2)}`)}(e).map((o=>w(o,i.kind,{hasDistributorData:i.hasDistributorData,getStaticData:i.getStaticData,moduleSchemas:t,schema:e,allSchemas:n}))).filter(Boolean).join("")}function E(e){const t=(n=e,Object.keys(n).map((e=>Object.assign(Object.assign({},n[e]),{component:e}))));var n;const{interfaceSuffix:i}=h(),{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((t=>{var n;let r={kind:"component",contentTypeSuffixStr:"",contentTypeName:"",contentTypeKind:"",relatedContentTypeNames:"",componentName:"",hasDistributorData:!1,getStaticData:!1,interfaceForPublicAPI:"",relationsGeneric:(null===(n=t._autoType)||void 0===n?void 0:n.relations)?"<Relations = unknown, FromList = unknown, FromDistributor = true>":""};if(function(e){return"fromPage"in e}(t)){const e=function(e){const{contentTypeSuffix:t,interfaceSuffix:n,publicApiSuffix:i}=h(),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 l="";if("schema"in e){const t=e.schema.fields.map((e=>"source"in e&&(null==e?void 0:e.source))).filter(Boolean);l=t.length?`__relatedContentTypeNames: ${JSON.stringify(t)}`:""}const c=`\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:l,relationsGeneric:"<Relations = unknown, FromList = unknown, FromDistributor = true>",interfaceForPublicAPI:c}}(t);r=Object.assign(Object.assign({},r),e)}if(function(e){return"schemaType"in e}(t)){const e=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}}(t);r=Object.assign(Object.assign({},r),e)}const s=O(t,o,e,r);return`\n\t\t\t\texport interface ${t.component}${r.contentTypeSuffixStr}${i}${r.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}(t)} {\n\t\t\t\t\t${r.contentTypeName}\n\t\t\t\t\t${r.contentTypeKind}\n\t\t\t\t\t${r.relatedContentTypeNames}\n\t\t\t\t\t${r.componentName}\n\t\t\t\t\t${s}\n\t\t\t\t\t${function(e){return"fromPage"in e&&!e.fromPage&&!0===e.taxonomy}(t)?"title?: string; code?: string":""}\n\t\t\t\t}\n\t\t\t\t${r.interfaceForPublicAPI}\n\t\t\t`})).join("")}function L(e){return e?e.map((e=>w(e,"object",{hasDistributorData:!1,getStaticData:!1,moduleSchemas:[],schema:{},allSchemas:{}}))).join(""):""}function I(e,t){return r(this,void 0,void 0,(function*(){const{schemas:{dataPacks:n,dataPacksCategories:i,languages:s,menuItems:a,modules:l,structuredData:c,templates:u,forms:p},moduleCategories:d,subthemes:m,themes:f}=e,{categoryContentTypes:y,components:g,pageContentTypes:$,simpleContentTypes:b}={categoryContentTypes:function(e){const t={};for(const n in e){const i=e[n];!i.fromPage&&i.taxonomy&&(t[n]=i)}return t}((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}(T.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}(T.schemas.structuredData),components:function(e){const t={};for(const n in e){const i=e[n];"component"===i.schemaType&&(t[n]=i)}return t}(T.schemas.all)};var T;let F={};"__HIDE_FORMS__"!==t&&(F=Object.assign(Object.assign({},p.templates),p.fields));const v=E(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},g),l),u),c),F)),S=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`}(s),C=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${L(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${L(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`}(a),j=(_=d)?`export type ModuleCategories = ${_.map((e=>`"${e.value}"`)).join("|")}`:"";var _;const{SUBTHEMES:k,THEMES:x}=(D=m,{THEMES:(A=f)?`export type Themes = ${A.map((e=>`"${e.value}"`)).join("|")}`:"",SUBTHEMES:D?`export type Subthemes = ${D.map((e=>`"${e}"`)).join("|")}`:""});var A,D;const w=function(e){const t=Object.keys(e).map((e=>`"${e}"`));return t.length?`export type TaxonomyContentTypes = ${t.join("|")}`:""}(y),O=function(e){const t=Object.keys(e).map((e=>`"${e}"`));return t.length?`export type PageContentTypes = ${t.join("|")}`:""}($),I=function(e){const t=Object.keys(e).map((e=>`"${e}"`));return t.length?`export type SimpleContentTypes = ${t.join("|")}`:""}(b),M=function(e){const t=Object.keys(e).map((e=>`"${e}"`));return t.length?`export type Components = ${t.join("|")}`:""}(g),R=function(e){const t=Object.keys(e).map((e=>`"${e}"`));return t.length?`export type Modules = ${t.join("|")}`:""}(l),P=function(e){const t=Object.keys(e).map((e=>`"${e}"`));return t.length?`export type Templates = ${t.join("|")}`:""}(u),G=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("|")}`:""}(u),N=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`}(u),B=function(e){const{contentTypeSuffix:t,interfaceSuffix:n}=h(),i=Object.keys(e).map((e=>`${e}${t}${n}`));return i.length?`export type Taxonomy${t}${n} = ${i.join("|")}`:""}(y),U=function(e){const{contentTypeSuffix:t,interfaceSuffix:n}=h(),i=Object.keys(e).map((e=>`${e}${t}${n}`));return i.length?`export type Simple${t}${n} = ${i.join("|")}`:""}(b),H=function(e){const{contentTypeSuffix:t,interfaceSuffix:n}=h(),i=Object.keys(e).map((e=>`${e}${t}${n}`));return i.length?`export type Page${t}${n} = ${i.join("|")}`:""}($),{DATAPACKS:q,DATAPACKS_CATEGORIES:K}=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("|")}`:""}}(n,i);let W="";if("__HIDE_FORMS__"!==t){W=`\n\t\t\t${function(e){const t=Object.keys(e).map((e=>`"${e}"`));return t.length?`export type FormTemplates = ${t.join("|")}`:""}(p.templates)}\n\t\t\t${function(e){const t=Object.keys(e).map((e=>`"${e}"`));return t.length?`export type FormFields = ${t.join("|")}`:""}(p.fields)}\n\t\t`}return 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${C}\n\t\t${S}\n\t\t${v} \n\t\t${O}\n\t\t${I}\n\t\t${w}\n\t\t${M}\n\t\t${R}\n\t\t${W}\n\t\t${P}\n\t\t${G}\n\t\t${N}\n\t\t${j}\n\t\t${q}\n\t\t${K}\n\t\t${B}\n\t\t${U}\n\t\t${H}\n\t\t${x}\n\t\t${k}\n\t\t`)}))}r(void 0,void 0,void 0,(function*(){try{const n=$(),i=t.join(n,"griddo.config.ts"),o=yield I(require(i),"__HIDE_FORMS__"),r=t.join(n,"autotypes.d.ts");e.writeFileSync(r,o),console.log(`${c.green(" ✔")} AutoTypes`)}catch(e){console.log(`${c.red(" ✘")} AutoTypes`),console.log(e)}}));
1
+ import e from"node:fs";import t from"node:path";import{fileURLToPath as n}from"node:url";import r from"node:process";import o from"prettier";function i(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{l(r.next(e))}catch(e){i(e)}}function a(e){try{l(r.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}l((r=r.apply(e,t||[])).next())}))}function s(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var a,l;"function"==typeof SuppressedError&&SuppressedError;var c=s(function(){if(l)return a;l=1;const{FORCE_COLOR:e,NODE_DISABLE_COLORS:t,TERM:n}=process.env,r={enabled:!t&&"dumb"!==n&&"0"!==e,reset:i(0,0),bold:i(1,22),dim:i(2,22),italic:i(3,23),underline:i(4,24),inverse:i(7,27),hidden:i(8,28),strikethrough:i(9,29),black:i(30,39),red:i(31,39),green:i(32,39),yellow:i(33,39),blue:i(34,39),magenta:i(35,39),cyan:i(36,39),white:i(37,39),gray:i(90,39),grey:i(90,39),bgBlack:i(40,49),bgRed:i(41,49),bgGreen:i(42,49),bgYellow:i(43,49),bgBlue:i(44,49),bgMagenta:i(45,49),bgCyan:i(46,49),bgWhite:i(47,49)};function o(e,t){let n,r=0,o="",i="";for(;r<e.length;r++)n=e[r],o+=n.open,i+=n.close,t.includes(n.close)&&(t=t.replace(n.rgx,n.close+n.open));return o+t+i}function i(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:r.enabled?o(this.keys,t+""):t+""):void 0===t?function(e,t){let n={has:e,keys:t};return n.reset=r.reset.bind(n),n.bold=r.bold.bind(n),n.dim=r.dim.bind(n),n.italic=r.italic.bind(n),n.underline=r.underline.bind(n),n.inverse=r.inverse.bind(n),n.hidden=r.hidden.bind(n),n.strikethrough=r.strikethrough.bind(n),n.black=r.black.bind(n),n.red=r.red.bind(n),n.green=r.green.bind(n),n.yellow=r.yellow.bind(n),n.blue=r.blue.bind(n),n.magenta=r.magenta.bind(n),n.cyan=r.cyan.bind(n),n.white=r.white.bind(n),n.gray=r.gray.bind(n),n.grey=r.grey.bind(n),n.bgBlack=r.bgBlack.bind(n),n.bgRed=r.bgRed.bind(n),n.bgGreen=r.bgGreen.bind(n),n.bgYellow=r.bgYellow.bind(n),n.bgBlue=r.bgBlue.bind(n),n.bgMagenta=r.bgMagenta.bind(n),n.bgCyan=r.bgCyan.bind(n),n.bgWhite=r.bgWhite.bind(n),n}([e],[n]):r.enabled?o([n],t+""):t+""}}return a=r}());const p=/[\p{Lu}]/u,u=/[\p{Ll}]/u,d=/^[\p{Lu}](?![\p{Lu}])/gu,m=/([\p{Alpha}\p{N}_]|$)/u,y=/[_.\- ]+/,f=new RegExp("^"+y.source),g=new RegExp(y.source+m.source,"gu"),h=new RegExp("\\d+"+m.source,"gu");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),r=!1===t.locale?e=>e.toUpperCase():e=>e.toLocaleUpperCase(t.locale);if(1===e.length)return y.test(e)?"":t.pascalCase?r(e):n(e);return e!==n(e)&&(e=((e,t,n,r)=>{let o=!1,i=!1,s=!1,a=!1;for(let l=0;l<e.length;l++){const c=e[l];a=!(l>2)||"-"===e[l-3],o&&p.test(c)?(e=e.slice(0,l)+"-"+e.slice(l),o=!1,s=i,i=!0,l++):i&&s&&u.test(c)&&(!a||r)?(e=e.slice(0,l-1)+"-"+e.slice(l-1),s=i,i=!1,o=!0):(o=t(c)===c&&n(c)!==c,s=i,i=n(c)===c&&t(c)!==c)}return e})(e,n,r,t.preserveConsecutiveUppercase)),e=e.replace(f,""),e=t.preserveConsecutiveUppercase?((e,t)=>(d.lastIndex=0,e.replaceAll(d,(e=>t(e)))))(e,n):n(e),t.pascalCase&&(e=r(e.charAt(0))+e.slice(1)),((e,t)=>(g.lastIndex=0,h.lastIndex=0,e.replaceAll(h,((n,r,o)=>["_","-"].includes(e.charAt(o+n.length))?n:t(n))).replaceAll(g,((e,n)=>t(n)))))(e,r)}const b={directory:"isDirectory",file:"isFile"};const T=(e,t)=>t[b[e]]();function F(o,{cwd:i=r.cwd(),type:s="file",allowSymlinks:a=!0}={}){var l;!function(e){if(!Object.hasOwnProperty.call(b,e))throw new Error(`Invalid type specified: ${e}`)}(s),i=(l=i)instanceof URL?n(l):l;const c=a?e.statSync:e.lstatSync;for(const e of o)try{const n=c(t.resolve(i,e),{throwIfNoEntry:!1});if(!n)continue;if(T(s,n))return e}catch{}}const v=Symbol("findUpStop");function C(e,r={}){let o=t.resolve(((i=r.cwd)instanceof URL?n(i):i)||"");var i;const{root:s}=t.parse(o),a=r.stopAt||s,l=r.limit||Number.POSITIVE_INFINITY,c=[e].flat(),p=t=>{if("function"!=typeof e)return F(c,t);const n=e(t.cwd);return"string"==typeof n?F([n],t):n},u=[];for(;;){const e=p({...r,cwd:o});if(e===v)break;if(e&&u.push(t.resolve(o,e)),o===a||u.length>=l)break;o=t.dirname(o)}return u}function S({cwd:e}={}){const n=function(e,t={}){return C(e,{...t,limit:1})[0]}("package.json",{cwd:e});return n&&t.dirname(n)}function P(e){const{interfaceSuffix:t}=A();return e.length>1?`{\n\t\t\t${e.map((e=>`${$(e)}?: ${e}${t}`)).join(",")}\n\t\t\t}`:e.map((e=>`${e}${t}`)).join("")}function k(e){return{FormContainer:"Fields.FormContainer",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 x(e,t){var n;const{returnTypeName:r,generic:o}=t||{},i="hideable"in e&&Boolean(e.hideable),s=o?`<${o}>`:"",a=`${r||k(e.type)}${s}`,l=i?`Hideable<${a}>`:`${a}`;return`\n\t\t${(null===(n=e._autoType)||void 0===n?void 0:n.doc)||""}\n\t\t${`${e.key}?: ${l}`}\n\t`}const j=__dirname.includes("node_modules");function _(){const e=__dirname,n=j?"../../../":"../griddo-components";return t.resolve(S({cwd:e}),n)}function A(){var e,n,r;const o=t.join(_(),"griddo.config.ts"),i=require(o);return{interfaceSuffix:(null===(e=i.autotypes)||void 0===e?void 0:e.interfaceSuffix)||"Props",contentTypeSuffix:(null===(n=i.autotypes)||void 0===n?void 0:n.contentTypeSuffix)||"ContentType",publicApiSuffix:(null===(r=i.autotypes)||void 0===r?void 0:r.publicApiSuffix)||"List"}}function D(e,t,n){var r,o;const{contentTypeSuffix:i,interfaceSuffix:s}=A();if("FieldsDivider"===e.type)return"// FieldsDivider";if(null===(r=e._autoType)||void 0===r?void 0:r.ignore)return"// Ignored by AutoType.ignore";const{type:a,_autoType:l,key:c}=e,{hasDistributorData:p,getStaticData:u}=n;if(!a||!c)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 x(e);if("MultiCheckSelect"===a){if("pageContentType"===t||"simpleContentType"===t){return x(e,{generic:`Relations, FromList, ${`${e.source}${i}${s}`}<false, false>, FromDistributor`})}return x(e,{generic:"true"})}if("AsyncCheckGroup"===a){if("pageContentType"===t||"simpleContentType"===t){return x(e,{generic:`Relations, FromList, ${`${e.source}${i}${s}`}<false, false>, FromDistributor`})}return x(e,{generic:"true"})}if("MultiCheckSelectGroup"===a){const t=e.elements.map((e=>`"${e.key}"`)).join("|");return x(e,{generic:[t,null===(o=e._autoType)||void 0===o?void 0:o.relations].join(",")})}if("ColorPicker"===a)return e.isThemePalette?x(e,{returnTypeName:"Fields.ColorPickerFixed"}):x(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 x(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 x(e,{generic:n})}if("LinkField"===a){const{whiteList:t}=e;return x(e,{generic:P(t)})}if("AsyncSelect"===a){if("entity"in e&&"menu_containers"===e.entity)return`\n${c}?: Menu`;if("pageContentType"===t||"simpleContentType"===t){return x(e,{generic:`Relations, FromList, ${`${e.source}${i}${s}`}<false, false>, FromDistributor`})}return`\n${c}?: 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==l?void 0:l.doc)||""}\n${c}?: Fields.ArrayFieldGroup<{${e.fields.map((e=>D(e,t,n))).join(",")}}>\n\t\t`}if("ConditionalField"===a){const r=e.fields.map((e=>D(e,t,n))),o=(null==l?void 0:l.doc)||"",i="hideable"in e&&e.hideable,s=i?">":"";return`\n\t\t\t// << ${a}\n\t\t\t\n${o}\n${c}?: ${i?"Hideable<":""}${k(a)}<${e.options.map((e=>"string"==typeof e.value?`"${e.value}"`:e.value)).join("|")}>${s};\n\t\t\t${r.join("")}\n\t\t\t// end >>\n\t\t`}if("FormFieldArray"===a){const r="template"===t||"pageContentType"===t?"TemplateSection":"formTemplate"===t?"FormFieldArray":"ComponentArray",o="template"===t?"":"?",{key:i,_autoType:a,whiteList:l}=e,c=(null==a?void 0:a.doc)||"",p=(e,t,n)=>e.filter((e=>e&&"schemaType"in e&&"module"===(null==e?void 0:e.schemaType)?(null==e?void 0:e.sectionList)&&!!(null==e?void 0:e.sectionList[t]):void 0)).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 u="";"template"===t&&(u=p(n.moduleSchemas,n.schema.component,i).join("|"));return`\n${c}\n${i}${o}: Fields.${r}<${[...new Set([...u.split("|"),...l])].filter(Boolean).map((e=>`${e}${s}`)).join("|")}>;`}if("ComponentArray"===a){const r="template"===t||"pageContentType"===t?"TemplateSection":"ComponentArray",o="template"===t?"":"?",i=e,{key:a,_autoType:l,whiteList:c}=i,p=(null==l?void 0:l.doc)||"",u=(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=u(n.moduleSchemas,n.schema.component,a).join("|"));return`\n${p}\n${a}${o}: Fields.${r}<${[...new Set([...d.split("|"),...c])].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 x(e,{generic:P(n)})}if("FormContainer"===a&&("object"===t||"component"===t||"module"===t||"template"===t||"pageContentType"===t)){const e="FormContainer",t=Object.keys(n.allSchemas).filter((e=>{if("formTemplate"===n.allSchemas[e].schemaType)return e}));return`\n${(null==l?void 0:l.doc)||""}\n${c}?: Fields.${e}<${t.map((e=>`${e}${s}`)).join("|")}>;`}if("ReferenceField"===a){const t=e.sources||[{structuredData:void 0}],n=Array.isArray(t)&&t.map((e=>e.structuredData?`${e.structuredData}${i}${s}`:"unknown")).join("|")||"";return`\n\t\t \t${x(e,{generic:n})}\n\t\t \t${p||u?`queriedItems?: Fields.QueriedData<${n}>;`:""}\n\t\t `}if("VisualUniqueSelection"===a){const t=e.options[0],n=e.options[0];let r="";if(t.value){r=e.options.map((e=>`"${e.value}"`)).join("|")}if(n.theme){r=e.options[0].options.map((e=>`"${e.value}"`)).join("|")}return x(e,{generic:r})}return console.warn(`The field ${e.type} has not been implemented yet ㅠ.ㅠ`),""}class w{setParser(e){this.parser=e}parse(e){var t;return(null===(t=this.parser)||void 0===t?void 0:t.parse(e))||""}}const O={ComponentsNameParser:class{parse(e){const t=Object.keys(e).map((e=>`"${e}"`));return t.length?`export type Components = ${t.join("|")}`:""}},DataPacksCategoryParser:class{parse(e){return e?`export type DatapacksCategories = ${Object.keys(e).map((e=>`"${e}"`)).join("|")}`:""}},DataPacksParser:class{parse(e){return e?`export type Datapacks = ${Object.keys(e).map((e=>`"${e}"`)).join("|")}`:""}},DataTemplatesNameParser:class{parse(e){const t=Object.keys(e).map((t=>"detail"===e[t].type.mode?`"${t}"`:"")).filter(Boolean);return t.length?`export type DetailTemplates = ${t.join("|")}`:""}},FormFieldsParser:class{parse(e){const t=Object.keys(e).map((e=>`"${e}"`));return t.length?`export type FormFields = ${t.join("|")}`:""}},FormTemplatesParser:class{parse(e){const t=Object.keys(e).map((e=>`"${e}"`));return t.length?`export type FormTemplates = ${t.join("|")}`:""}},LanguagesParser:class{parse(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=>{var n;return`"${null===(n=e[t])||void 0===n?void 0:n.label}"`})).join("|")};\n\t\t\tlanguage: ${t.map((t=>{var n;return`"${null===(n=e[t])||void 0===n?void 0:n.name}"`})).join("|")};\n\t\t\tlocale: ${t.map((e=>`"${e}"`)).join("|")}\n\t\t\tpath: string;\n\t\t}\n\t`}},MenuItemsParser:class{getMenuItemsProps(e){return e?e.map((e=>D(e,"object",{hasDistributorData:!1,getStaticData:!1,moduleSchemas:[],schema:{},allSchemas:{}}))).join(""):""}parse(e){var t,n;const r=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${this.getMenuItemsProps(r)}\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${this.getMenuItemsProps(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`}},ModuleCateogiresParser:class{parse(e){return e?`export type ModuleCategories = ${e.map((e=>`"${e.value}"`)).join("|")}`:""}},ModulesNameParser:class{parse(e){const t=Object.keys(e).map((e=>`"${e}"`));return t.length?`export type Modules = ${t.join("|")}`:""}},PageContentTypeParser:class{parse(e){const t=Object.keys(e).map((e=>`"${e}"`));return t.length?`export type PageContentTypes = ${t.join("|")}`:""}},PageDataPropsParser:class{parse(e){const{contentTypeSuffix:t,interfaceSuffix:n}=A(),r=Object.keys(e).map((e=>`${e}${t}${n}`));return r.length?`export type Page${t}${n} = ${r.join("|")}`:""}},SimpleContentTypeParser:class{parse(e){const t=Object.keys(e).map((e=>`"${e}"`));return t.length?`export type SimpleContentTypes = ${t.join("|")}`:""}},SimpleDataPropsParser:class{parse(e){const{contentTypeSuffix:t,interfaceSuffix:n}=A(),r=Object.keys(e).map((e=>`${e}${t}${n}`));return r.length?`export type Simple${t}${n} = ${r.join("|")}`:""}},SubthemesParser:class{parse(e){return Array.isArray(e)&&e.length?`export type Subthemes = ${e.map((e=>`"${e}"`)).join("|")}`:""}},TaxonomyParser:class{parse(e){const t=Object.keys(e).map((e=>`"${e}"`));return t.length?`export type TaxonomyContentTypes = ${t.join("|")}`:""}},TaxonomyPropsParser:class{parse(e){const{contentTypeSuffix:t,interfaceSuffix:n}=A(),r=Object.keys(e).map((e=>`${e}${t}${n}`));return r.length?`export type Taxonomy${t}${n} = ${r.join("|")}`:""}},TemplateSectionListParser:class{parse(e){const t=[];for(const n in e){const r=e[n],o=r.content.filter((e=>"ComponentArray"===e.type)).map((({key:e})=>`"${e}"`)).filter(Boolean),i=o&&(null==o?void 0:o.length)>0?`${r.component}?: NonEmptyArray<${o.join("|")}>;`:"";t.push(i)}return`\n\t\t\texport type SectionList = { ${t.join("")} }\n\t\t`}},TemplatesNameParser:class{parse(e){const t=Object.keys(e).map((e=>`"${e}"`));return t.length?`export type Templates = ${t.join("|")}`:""}},ThemesParser:class{parse(e){return Array.isArray(e)&&e.length?`export type Themes = ${e.map((e=>`"${e.value}"`)).join("|")}`:""}},UIAndDataPropsParser:class{parse(e){const t=(n=e,Object.keys(n).map((e=>Object.assign(Object.assign({},n[e]),{component:e}))));var n;const{interfaceSuffix:r}=A(),{ARRAY_OF_MODULE_SCHEMAS:o}=function(e){const t=e.map((e=>{if("schemaType"in e&&"module"===e.schemaType)return e})).filter(Boolean);return{ARRAY_OF_MODULE_SCHEMAS:t}}(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:r}=A(),o=[],i=[],s=[],a=e.fromPage?"pageContentType":"simpleContentType";"pageContentType"===a&&o.push(`"${e.component}"`);"simpleContentType"!==a||e.taxonomy||i.push(`"${e.component}"`);"simpleContentType"===a&&e.taxonomy&&s.push(`"${e.component}"`);let l="";if("schema"in e){const t=e.schema.fields.map((e=>"source"in e&&(null==e?void 0:e.source))).filter(Boolean);l=t.length?`__relatedContentTypeNames: ${JSON.stringify(t)}`:""}const c="<Relations = unknown, FromList = unknown, FromDistributor = true>",p=`\n\t\t\t\t/** Type to be consumed by public API: useList(), etc.. */\n\t\t\t\texport type ${e.component}${t}${r}${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:l,relationsGeneric:c,interfaceForPublicAPI:p}}(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;"template"!==e.schemaType&&"module"!==e.schemaType&&"component"!==e.schemaType||(t=e.default.hasDistributorData,n=e.default.getStaticData);const r=e.schemaType;return{kind:r,componentName:`component: "${e.component}"`,contentTypeName:"",contentTypeKind:"",contentTypeSuffixStr:"",relatedContentTypeNames:"",relationsGeneric:"",interfaceForPublicAPI:"",hasDistributorData:t,getStaticData:n}}(e);n=Object.assign(Object.assign({},n),t)}const i=function(e,t,n,r){return function(e){if("fromPage"in e)return e.taxonomy?[]:e.schema.fields;if("template"===e.schemaType){return[...e.content||[],...e.config||[]]}if("formTemplate"===e.schemaType){return[...e.content||[],...e.config||[]]}if("component"===e.schemaType||"module"===e.schemaType||"formComponent"===e.schemaType)return e.configTabs.flatMap((e=>e.fields));throw new Error(`Wrong schema ${JSON.stringify(e,null,2)}`)}(e).map((o=>D(o,r.kind,{hasDistributorData:r.hasDistributorData,getStaticData:r.getStaticData,moduleSchemas:t,schema:e,allSchemas:n}))).filter(Boolean).join("")}(e,o,e,n);return`\n\t\t\t\texport interface ${e.component}${n.contentTypeSuffixStr}${r}${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],n.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${i}\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("")}}};i(void 0,void 0,void 0,(function*(){try{const n=_(),r=t.join(n,"griddo.config.ts"),s=require(r),{schemas:{dataPacks:a,dataPacksCategories:l,languages:p,menuItems:u,modules:d,structuredData:m,templates:y},moduleCategories:f,subthemes:g,themes:h}=s,{categoryContentTypes:$,components:b,pageContentTypes:T,simpleContentTypes:F}=function(e){return{categoryContentTypes:function(e){const t={};for(const n in e){const r=e[n];!r.fromPage&&r.taxonomy&&(t[n]=r)}return t}(e.schemas.structuredData),pageContentTypes:function(e){const t={};for(const n in e){const r=e[n];r.fromPage&&(t[n]=r)}return t}(e.schemas.structuredData),simpleContentTypes:function(e){const t={};for(const n in e){const r=e[n];r.fromPage||r.taxonomy||(t[n]=r)}return t}(e.schemas.structuredData),components:function(e){const t={};for(const n in e){const r=e[n];"component"===r.schemaType&&(t[n]=r)}return t}(e.schemas.all)}}(s),v=Object.assign(Object.assign(Object.assign(Object.assign({},b),d),y),m),C=function(e){const t=new w;return e.map((e=>(t.setParser(new e.parser),t.parse(e.schema))))}([{schema:p,parser:O.LanguagesParser},{schema:u,parser:O.MenuItemsParser},{schema:f,parser:O.ModuleCateogiresParser},{schema:h,parser:O.ThemesParser},{schema:v,parser:O.UIAndDataPropsParser},{schema:g,parser:O.SubthemesParser},{schema:T,parser:O.PageContentTypeParser},{schema:F,parser:O.SimpleContentTypeParser},{schema:$,parser:O.TaxonomyParser},{schema:b,parser:O.ComponentsNameParser},{schema:d,parser:O.ModulesNameParser},{schema:y,parser:O.TemplatesNameParser},{schema:y,parser:O.DataTemplatesNameParser},{schema:y,parser:O.TemplateSectionListParser},{schema:a,parser:O.DataPacksParser},{schema:l,parser:O.DataPacksCategoryParser},{schema:$,parser:O.TaxonomyPropsParser},{schema:F,parser:O.SimpleDataPropsParser},{schema:T,parser:O.PageDataPropsParser}]),S=yield function(e){return i(this,void 0,void 0,(function*(){const t=yield o.resolveConfigFile(),n=(yield o.resolveConfig(t))||{useTabs:!0},r=Object.assign(Object.assign({},n),{parser:"typescript"});return(yield o.format(e,r)).replace(/^\s*\n/gm,"")}))}(`\n\t\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\t${C.join("\n")}\n\t\t`),P=t.join(n,"autotypes.d.ts");e.writeFileSync(P,S),console.log(`${c.green(" ✔")} AutoTypes`)}catch(e){console.log(`${c.red(" ✘")} AutoTypes`),console.log(e)}}));
2
2
  //# sourceMappingURL=autotypes.js.map