@woodylab/payload 0.0.134 → 0.0.136
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/config/blocks/blockCard.js +2 -2
- package/dist/config/blocks/blockView.js +2 -2
- package/dist/config/index.cjs.js +1 -1
- package/dist/config/index.cjs.js.map +1 -1
- package/dist/config/index.esm.js +1 -1
- package/dist/config/index.esm.js.map +1 -1
- package/dist/seeders/ComponentList.d.ts +18 -0
- package/dist/seeders/ComponentList.js +20 -0
- package/dist/seeders/ViewModeList.d.ts +15 -0
- package/dist/seeders/ViewModeList.js +17 -0
- package/dist/seeders/components.js +23 -1
- package/dist/seeders/index.cjs.js +1 -1
- package/dist/seeders/index.cjs.js.map +1 -1
- package/dist/seeders/index.esm.js +1 -1
- package/dist/seeders/index.esm.js.map +1 -1
- package/dist/seeders/viewModes.js +23 -1
- package/package.json +1 -1
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare const ComponentList: {
|
|
2
|
+
name: string;
|
|
3
|
+
componentName: string;
|
|
4
|
+
propsSchema: {
|
|
5
|
+
titleProps: {
|
|
6
|
+
text: string;
|
|
7
|
+
className: string;
|
|
8
|
+
};
|
|
9
|
+
descriptionProps: {
|
|
10
|
+
text: string;
|
|
11
|
+
className: string;
|
|
12
|
+
};
|
|
13
|
+
imageProps: {
|
|
14
|
+
src: string;
|
|
15
|
+
className: string;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
}[];
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export const ComponentList = [
|
|
2
|
+
{
|
|
3
|
+
name: 'Card',
|
|
4
|
+
componentName: 'Card',
|
|
5
|
+
propsSchema: {
|
|
6
|
+
titleProps: {
|
|
7
|
+
text: 'string',
|
|
8
|
+
className: 'string',
|
|
9
|
+
},
|
|
10
|
+
descriptionProps: {
|
|
11
|
+
text: 'string',
|
|
12
|
+
className: 'string',
|
|
13
|
+
},
|
|
14
|
+
imageProps: {
|
|
15
|
+
src: 'string',
|
|
16
|
+
className: 'string',
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
];
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export const ViewModeList = [
|
|
2
|
+
{
|
|
3
|
+
name: 'Card',
|
|
4
|
+
componentName: 'Card',
|
|
5
|
+
blockPropsMapping: {
|
|
6
|
+
titleProps: {
|
|
7
|
+
text: 'titleProps.text',
|
|
8
|
+
},
|
|
9
|
+
descriptionProps: {
|
|
10
|
+
text: 'descriptionProps.text',
|
|
11
|
+
},
|
|
12
|
+
imageProps: {
|
|
13
|
+
src: 'imageProps.image.value.url',
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
];
|
|
@@ -1,3 +1,25 @@
|
|
|
1
|
+
import { ComponentList } from './ComponentList';
|
|
1
2
|
export async function seedComponents(payload) {
|
|
2
|
-
|
|
3
|
+
const existing = await payload.find({
|
|
4
|
+
collection: 'component-definitions',
|
|
5
|
+
limit: 1000000,
|
|
6
|
+
depth: 0,
|
|
7
|
+
});
|
|
8
|
+
const existingNames = new Set(existing.docs.map((c) => c.name));
|
|
9
|
+
for (const component of ComponentList) {
|
|
10
|
+
if (existingNames.has(component.name)) {
|
|
11
|
+
continue;
|
|
12
|
+
}
|
|
13
|
+
try {
|
|
14
|
+
await payload.create({
|
|
15
|
+
collection: 'component-definitions',
|
|
16
|
+
data: {
|
|
17
|
+
...component,
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
catch (error) {
|
|
22
|
+
console.warn(`[SEED VIEWMODE] Errore su "${component.name}", skip`, error?.message ?? error);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
3
25
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var e=require("../tailwind/index.cjs.js");const
|
|
1
|
+
"use strict";var e=require("../tailwind/index.cjs.js");const t=()=>{const t=[];for(const s of e.tailwindSelectorVariants)for(const n of Object.values(e.tailwindFieldsSelectors))for(const e of n){const n=`${s.value}${e}`,a=`t:${n}`;t.push({name:a,css:n})}return t};const s=[{name:"Card",componentName:"Card",blockPropsMapping:{titleProps:{text:"titleProps.text"},descriptionProps:{text:"descriptionProps.text"},imageProps:{src:"imageProps.image.value.url"}}}];const n=[{name:"Card",componentName:"Card",propsSchema:{titleProps:{text:"string",className:"string"},descriptionProps:{text:"string",className:"string"},imageProps:{src:"string",className:"string"}}}];exports.UIMSSeeder=async function({payload:e,include:a}){a.includes("styles")&&await async function(e){const s=t(),n=await e.find({collection:"styles",limit:1e6,depth:0}),a=new Set(n.docs.map(e=>e.name));for(const t of s)if(!a.has(t.name))try{await e.create({collection:"styles",data:{name:t.name,css:{className:t.css}}})}catch(e){console.warn(`[SEED STYLES] Errore su "${t.name}", skip`,e?.message??e)}}(e),a.includes("viewMode")&&await async function(e){const t=await e.find({collection:"view-modes",limit:1e6,depth:0}),n=new Set(t.docs.map(e=>e.name));for(const t of s)if(!n.has(t.name))try{await e.create({collection:"view-modes",data:{...t}})}catch(e){console.warn(`[SEED VIEWMODE] Errore su "${t.name}", skip`,e?.message??e)}}(e),a.includes("component")&&await async function(e){const t=await e.find({collection:"component-definitions",limit:1e6,depth:0}),s=new Set(t.docs.map(e=>e.name));for(const t of n)if(!s.has(t.name))try{await e.create({collection:"component-definitions",data:{...t}})}catch(e){console.warn(`[SEED VIEWMODE] Errore su "${t.name}", skip`,e?.message??e)}}(e)},exports.generateTailwindStyles=t;
|
|
2
2
|
//# sourceMappingURL=index.cjs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs.js","sources":["../../src/seeders/generateTailwindStyles.ts","../../src/seeders/UIMSSeeder.ts","../../src/seeders/styles.ts","../../src/seeders/viewModes.ts","../../src/seeders/components.ts"],"sourcesContent":["import { tailwindSelectorVariants } from '../tailwind/tailwindSelectorVariants'\nimport { tailwindFieldsSelectors } from '../tailwind/tailwindFieldSelectors'\n\ntype StyleSeed = {\n name: string\n css: string\n}\nexport const generateTailwindStyles = (): StyleSeed[] => {\n const styles: StyleSeed[] = []\n\n for (const variant of tailwindSelectorVariants) {\n for (const selectors of Object.values(tailwindFieldsSelectors)) {\n for (const selector of selectors) {\n const value = `${variant.value}${selector}` // es. md:mx-auto\n const name = `t:${value}`\n styles.push({\n name,\n css: value,\n })\n }\n }\n }\n\n return styles\n}\n","import { seedStyles } from './styles'\nimport { seedViewModes } from './viewModes'\nimport { seedComponents } from './components'\n\ntype SeederTarget = 'styles' | 'viewMode' | 'component'\n\ninterface SeederOptions {\n payload: any\n include: SeederTarget[]\n}\n\nexport async function UIMSSeeder({ payload, include }: SeederOptions): Promise<void> {\n if (include.includes('styles')) {\n await seedStyles(payload)\n }\n\n if (include.includes('viewMode')) {\n await seedViewModes(payload)\n }\n\n if (include.includes('component')) {\n await seedComponents(payload)\n }\n}\n","import { generateTailwindStyles } from './generateTailwindStyles'\n\nexport async function seedStyles(payload: any): Promise<void> {\n const generatedStyles = generateTailwindStyles()\n\n const existing = await payload.find({\n collection: 'styles',\n limit: 1000000,\n depth: 0,\n })\n\n const existingNames = new Set(existing.docs.map((style: any) => style.name))\n\n for (const style of generatedStyles) {\n if (existingNames.has(style.name)) {\n continue\n }\n\n try {\n await payload.create({\n collection: 'styles',\n data: {\n name: style.name,\n css: { className: style.css },\n },\n })\n } catch (error: any) {\n console.warn(`[SEED STYLES] Errore su \"${style.name}\", skip`, error?.message ?? error)\n }\n }\n}\n","
|
|
1
|
+
{"version":3,"file":"index.cjs.js","sources":["../../src/seeders/generateTailwindStyles.ts","../../src/seeders/ViewModeList.ts","../../src/seeders/ComponentList.ts","../../src/seeders/UIMSSeeder.ts","../../src/seeders/styles.ts","../../src/seeders/viewModes.ts","../../src/seeders/components.ts"],"sourcesContent":["import { tailwindSelectorVariants } from '../tailwind/tailwindSelectorVariants'\nimport { tailwindFieldsSelectors } from '../tailwind/tailwindFieldSelectors'\n\ntype StyleSeed = {\n name: string\n css: string\n}\nexport const generateTailwindStyles = (): StyleSeed[] => {\n const styles: StyleSeed[] = []\n\n for (const variant of tailwindSelectorVariants) {\n for (const selectors of Object.values(tailwindFieldsSelectors)) {\n for (const selector of selectors) {\n const value = `${variant.value}${selector}` // es. md:mx-auto\n const name = `t:${value}`\n styles.push({\n name,\n css: value,\n })\n }\n }\n }\n\n return styles\n}\n","export const ViewModeList = [\n {\n name: 'Card',\n componentName: 'Card',\n blockPropsMapping: {\n titleProps: {\n text: 'titleProps.text',\n },\n descriptionProps: {\n text: 'descriptionProps.text',\n },\n imageProps: {\n src: 'imageProps.image.value.url',\n },\n },\n },\n]\n","export const ComponentList = [\n {\n name: 'Card',\n componentName: 'Card',\n propsSchema: {\n titleProps: {\n text: 'string',\n className: 'string',\n },\n descriptionProps: {\n text: 'string',\n className: 'string',\n },\n imageProps: {\n src: 'string',\n className: 'string',\n },\n },\n },\n]\n","import { seedStyles } from './styles'\nimport { seedViewModes } from './viewModes'\nimport { seedComponents } from './components'\n\ntype SeederTarget = 'styles' | 'viewMode' | 'component'\n\ninterface SeederOptions {\n payload: any\n include: SeederTarget[]\n}\n\nexport async function UIMSSeeder({ payload, include }: SeederOptions): Promise<void> {\n if (include.includes('styles')) {\n await seedStyles(payload)\n }\n\n if (include.includes('viewMode')) {\n await seedViewModes(payload)\n }\n\n if (include.includes('component')) {\n await seedComponents(payload)\n }\n}\n","import { generateTailwindStyles } from './generateTailwindStyles'\n\nexport async function seedStyles(payload: any): Promise<void> {\n const generatedStyles = generateTailwindStyles()\n\n const existing = await payload.find({\n collection: 'styles',\n limit: 1000000,\n depth: 0,\n })\n\n const existingNames = new Set(existing.docs.map((style: any) => style.name))\n\n for (const style of generatedStyles) {\n if (existingNames.has(style.name)) {\n continue\n }\n\n try {\n await payload.create({\n collection: 'styles',\n data: {\n name: style.name,\n css: { className: style.css },\n },\n })\n } catch (error: any) {\n console.warn(`[SEED STYLES] Errore su \"${style.name}\", skip`, error?.message ?? error)\n }\n }\n}\n","import { ViewModeList } from './ViewModeList'\n\nexport async function seedViewModes(payload: any): Promise<void> {\n const existing = await payload.find({\n collection: 'view-modes',\n limit: 1000000,\n depth: 0,\n })\n\n const existingNames = new Set(existing.docs.map((vm: any) => vm.name))\n\n for (const viewMode of ViewModeList) {\n if (existingNames.has(viewMode.name)) {\n continue\n }\n\n try {\n await payload.create({\n collection: 'view-modes',\n data: {\n ...viewMode,\n },\n })\n } catch (error: any) {\n console.warn(`[SEED VIEWMODE] Errore su \"${viewMode.name}\", skip`, error?.message ?? error)\n }\n }\n}\n","import { ComponentList } from './ComponentList'\n\nexport async function seedComponents(payload: any): Promise<void> {\n const existing = await payload.find({\n collection: 'component-definitions',\n limit: 1000000,\n depth: 0,\n })\n\n const existingNames = new Set(existing.docs.map((c: any) => c.name))\n\n for (const component of ComponentList) {\n if (existingNames.has(component.name)) {\n continue\n }\n\n try {\n await payload.create({\n collection: 'component-definitions',\n data: {\n ...component,\n },\n })\n } catch (error: any) {\n console.warn(`[SEED VIEWMODE] Errore su \"${component.name}\", skip`, error?.message ?? error)\n }\n }\n}\n"],"names":["generateTailwindStyles","styles","variant","tailwindSelectorVariants","selectors","Object","values","tailwindFieldsSelectors","selector","value","name","push","css","ViewModeList","componentName","blockPropsMapping","titleProps","text","descriptionProps","imageProps","src","ComponentList","propsSchema","className","async","payload","include","includes","generatedStyles","existing","find","collection","limit","depth","existingNames","Set","docs","map","style","has","create","data","error","console","warn","message","seedStyles","vm","viewMode","seedViewModes","c","component","seedComponents"],"mappings":"uDAOO,MAAMA,EAAyB,KACpC,MAAMC,EAAsB,GAE5B,IAAK,MAAMC,KAAWC,2BACpB,IAAK,MAAMC,KAAaC,OAAOC,OAAOC,EAAAA,yBACpC,IAAK,MAAMC,KAAYJ,EAAW,CAChC,MAAMK,EAAQ,GAAGP,EAAQO,QAAQD,IAC3BE,EAAO,KAAKD,IAClBR,EAAOU,KAAK,CACVD,OACAE,IAAKH,GAET,CAIJ,OAAOR,GCvBF,MAAMY,EAAe,CAC1B,CACEH,KAAM,OACNI,cAAe,OACfC,kBAAmB,CACjBC,WAAY,CACVC,KAAM,mBAERC,iBAAkB,CAChBD,KAAM,yBAERE,WAAY,CACVC,IAAK,iCCZN,MAAMC,EAAgB,CAC3B,CACEX,KAAM,OACNI,cAAe,OACfQ,YAAa,CACXN,WAAY,CACVC,KAAM,SACNM,UAAW,UAEbL,iBAAkB,CAChBD,KAAM,SACNM,UAAW,UAEbJ,WAAY,CACVC,IAAK,SACLG,UAAW,gCCJZC,gBAA0BC,QAAEA,EAAOC,QAAEA,IACtCA,EAAQC,SAAS,iBCVhBH,eAA0BC,GAC/B,MAAMG,EAAkB5B,IAElB6B,QAAiBJ,EAAQK,KAAK,CAClCC,WAAY,SACZC,MAAO,IACPC,MAAO,IAGHC,EAAgB,IAAIC,IAAIN,EAASO,KAAKC,IAAKC,GAAeA,EAAM5B,OAEtE,IAAK,MAAM4B,KAASV,EAClB,IAAIM,EAAcK,IAAID,EAAM5B,MAI5B,UACQe,EAAQe,OAAO,CACnBT,WAAY,SACZU,KAAM,CACJ/B,KAAM4B,EAAM5B,KACZE,IAAK,CAAEW,UAAWe,EAAM1B,OAG9B,CAAE,MAAO8B,GACPC,QAAQC,KAAK,4BAA4BN,EAAM5B,cAAegC,GAAOG,SAAWH,EAClF,CAEJ,CDjBUI,CAAWrB,GAGfC,EAAQC,SAAS,mBEdhBH,eAA6BC,GAClC,MAAMI,QAAiBJ,EAAQK,KAAK,CAClCC,WAAY,aACZC,MAAO,IACPC,MAAO,IAGHC,EAAgB,IAAIC,IAAIN,EAASO,KAAKC,IAAKU,GAAYA,EAAGrC,OAEhE,IAAK,MAAMsC,KAAYnC,EACrB,IAAIqB,EAAcK,IAAIS,EAAStC,MAI/B,UACQe,EAAQe,OAAO,CACnBT,WAAY,aACZU,KAAM,IACDO,IAGT,CAAE,MAAON,GACPC,QAAQC,KAAK,8BAA8BI,EAAStC,cAAegC,GAAOG,SAAWH,EACvF,CAEJ,CFVUO,CAAcxB,GAGlBC,EAAQC,SAAS,oBGlBhBH,eAA8BC,GACnC,MAAMI,QAAiBJ,EAAQK,KAAK,CAClCC,WAAY,wBACZC,MAAO,IACPC,MAAO,IAGHC,EAAgB,IAAIC,IAAIN,EAASO,KAAKC,IAAKa,GAAWA,EAAExC,OAE9D,IAAK,MAAMyC,KAAa9B,EACtB,IAAIa,EAAcK,IAAIY,EAAUzC,MAIhC,UACQe,EAAQe,OAAO,CACnBT,WAAY,wBACZU,KAAM,IACDU,IAGT,CAAE,MAAOT,GACPC,QAAQC,KAAK,8BAA8BO,EAAUzC,cAAegC,GAAOG,SAAWH,EACxF,CAEJ,CHNUU,CAAe3B,EAEzB"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{tailwindSelectorVariants as
|
|
1
|
+
import{tailwindSelectorVariants as e,tailwindFieldsSelectors as t}from"../tailwind/index.esm.js";const s=()=>{const s=[];for(const n of e)for(const e of Object.values(t))for(const t of e){const e=`${n.value}${t}`,o=`t:${e}`;s.push({name:o,css:e})}return s};const n=[{name:"Card",componentName:"Card",blockPropsMapping:{titleProps:{text:"titleProps.text"},descriptionProps:{text:"descriptionProps.text"},imageProps:{src:"imageProps.image.value.url"}}}];const o=[{name:"Card",componentName:"Card",propsSchema:{titleProps:{text:"string",className:"string"},descriptionProps:{text:"string",className:"string"},imageProps:{src:"string",className:"string"}}}];async function a({payload:e,include:t}){t.includes("styles")&&await async function(e){const t=s(),n=await e.find({collection:"styles",limit:1e6,depth:0}),o=new Set(n.docs.map(e=>e.name));for(const s of t)if(!o.has(s.name))try{await e.create({collection:"styles",data:{name:s.name,css:{className:s.css}}})}catch(e){console.warn(`[SEED STYLES] Errore su "${s.name}", skip`,e?.message??e)}}(e),t.includes("viewMode")&&await async function(e){const t=await e.find({collection:"view-modes",limit:1e6,depth:0}),s=new Set(t.docs.map(e=>e.name));for(const t of n)if(!s.has(t.name))try{await e.create({collection:"view-modes",data:{...t}})}catch(e){console.warn(`[SEED VIEWMODE] Errore su "${t.name}", skip`,e?.message??e)}}(e),t.includes("component")&&await async function(e){const t=await e.find({collection:"component-definitions",limit:1e6,depth:0}),s=new Set(t.docs.map(e=>e.name));for(const t of o)if(!s.has(t.name))try{await e.create({collection:"component-definitions",data:{...t}})}catch(e){console.warn(`[SEED VIEWMODE] Errore su "${t.name}", skip`,e?.message??e)}}(e)}export{a as UIMSSeeder,s as generateTailwindStyles};
|
|
2
2
|
//# sourceMappingURL=index.esm.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.esm.js","sources":["../../src/seeders/generateTailwindStyles.ts","../../src/seeders/UIMSSeeder.ts","../../src/seeders/styles.ts","../../src/seeders/viewModes.ts","../../src/seeders/components.ts"],"sourcesContent":["import { tailwindSelectorVariants } from '../tailwind/tailwindSelectorVariants'\nimport { tailwindFieldsSelectors } from '../tailwind/tailwindFieldSelectors'\n\ntype StyleSeed = {\n name: string\n css: string\n}\nexport const generateTailwindStyles = (): StyleSeed[] => {\n const styles: StyleSeed[] = []\n\n for (const variant of tailwindSelectorVariants) {\n for (const selectors of Object.values(tailwindFieldsSelectors)) {\n for (const selector of selectors) {\n const value = `${variant.value}${selector}` // es. md:mx-auto\n const name = `t:${value}`\n styles.push({\n name,\n css: value,\n })\n }\n }\n }\n\n return styles\n}\n","import { seedStyles } from './styles'\nimport { seedViewModes } from './viewModes'\nimport { seedComponents } from './components'\n\ntype SeederTarget = 'styles' | 'viewMode' | 'component'\n\ninterface SeederOptions {\n payload: any\n include: SeederTarget[]\n}\n\nexport async function UIMSSeeder({ payload, include }: SeederOptions): Promise<void> {\n if (include.includes('styles')) {\n await seedStyles(payload)\n }\n\n if (include.includes('viewMode')) {\n await seedViewModes(payload)\n }\n\n if (include.includes('component')) {\n await seedComponents(payload)\n }\n}\n","import { generateTailwindStyles } from './generateTailwindStyles'\n\nexport async function seedStyles(payload: any): Promise<void> {\n const generatedStyles = generateTailwindStyles()\n\n const existing = await payload.find({\n collection: 'styles',\n limit: 1000000,\n depth: 0,\n })\n\n const existingNames = new Set(existing.docs.map((style: any) => style.name))\n\n for (const style of generatedStyles) {\n if (existingNames.has(style.name)) {\n continue\n }\n\n try {\n await payload.create({\n collection: 'styles',\n data: {\n name: style.name,\n css: { className: style.css },\n },\n })\n } catch (error: any) {\n console.warn(`[SEED STYLES] Errore su \"${style.name}\", skip`, error?.message ?? error)\n }\n }\n}\n","
|
|
1
|
+
{"version":3,"file":"index.esm.js","sources":["../../src/seeders/generateTailwindStyles.ts","../../src/seeders/ViewModeList.ts","../../src/seeders/ComponentList.ts","../../src/seeders/UIMSSeeder.ts","../../src/seeders/styles.ts","../../src/seeders/viewModes.ts","../../src/seeders/components.ts"],"sourcesContent":["import { tailwindSelectorVariants } from '../tailwind/tailwindSelectorVariants'\nimport { tailwindFieldsSelectors } from '../tailwind/tailwindFieldSelectors'\n\ntype StyleSeed = {\n name: string\n css: string\n}\nexport const generateTailwindStyles = (): StyleSeed[] => {\n const styles: StyleSeed[] = []\n\n for (const variant of tailwindSelectorVariants) {\n for (const selectors of Object.values(tailwindFieldsSelectors)) {\n for (const selector of selectors) {\n const value = `${variant.value}${selector}` // es. md:mx-auto\n const name = `t:${value}`\n styles.push({\n name,\n css: value,\n })\n }\n }\n }\n\n return styles\n}\n","export const ViewModeList = [\n {\n name: 'Card',\n componentName: 'Card',\n blockPropsMapping: {\n titleProps: {\n text: 'titleProps.text',\n },\n descriptionProps: {\n text: 'descriptionProps.text',\n },\n imageProps: {\n src: 'imageProps.image.value.url',\n },\n },\n },\n]\n","export const ComponentList = [\n {\n name: 'Card',\n componentName: 'Card',\n propsSchema: {\n titleProps: {\n text: 'string',\n className: 'string',\n },\n descriptionProps: {\n text: 'string',\n className: 'string',\n },\n imageProps: {\n src: 'string',\n className: 'string',\n },\n },\n },\n]\n","import { seedStyles } from './styles'\nimport { seedViewModes } from './viewModes'\nimport { seedComponents } from './components'\n\ntype SeederTarget = 'styles' | 'viewMode' | 'component'\n\ninterface SeederOptions {\n payload: any\n include: SeederTarget[]\n}\n\nexport async function UIMSSeeder({ payload, include }: SeederOptions): Promise<void> {\n if (include.includes('styles')) {\n await seedStyles(payload)\n }\n\n if (include.includes('viewMode')) {\n await seedViewModes(payload)\n }\n\n if (include.includes('component')) {\n await seedComponents(payload)\n }\n}\n","import { generateTailwindStyles } from './generateTailwindStyles'\n\nexport async function seedStyles(payload: any): Promise<void> {\n const generatedStyles = generateTailwindStyles()\n\n const existing = await payload.find({\n collection: 'styles',\n limit: 1000000,\n depth: 0,\n })\n\n const existingNames = new Set(existing.docs.map((style: any) => style.name))\n\n for (const style of generatedStyles) {\n if (existingNames.has(style.name)) {\n continue\n }\n\n try {\n await payload.create({\n collection: 'styles',\n data: {\n name: style.name,\n css: { className: style.css },\n },\n })\n } catch (error: any) {\n console.warn(`[SEED STYLES] Errore su \"${style.name}\", skip`, error?.message ?? error)\n }\n }\n}\n","import { ViewModeList } from './ViewModeList'\n\nexport async function seedViewModes(payload: any): Promise<void> {\n const existing = await payload.find({\n collection: 'view-modes',\n limit: 1000000,\n depth: 0,\n })\n\n const existingNames = new Set(existing.docs.map((vm: any) => vm.name))\n\n for (const viewMode of ViewModeList) {\n if (existingNames.has(viewMode.name)) {\n continue\n }\n\n try {\n await payload.create({\n collection: 'view-modes',\n data: {\n ...viewMode,\n },\n })\n } catch (error: any) {\n console.warn(`[SEED VIEWMODE] Errore su \"${viewMode.name}\", skip`, error?.message ?? error)\n }\n }\n}\n","import { ComponentList } from './ComponentList'\n\nexport async function seedComponents(payload: any): Promise<void> {\n const existing = await payload.find({\n collection: 'component-definitions',\n limit: 1000000,\n depth: 0,\n })\n\n const existingNames = new Set(existing.docs.map((c: any) => c.name))\n\n for (const component of ComponentList) {\n if (existingNames.has(component.name)) {\n continue\n }\n\n try {\n await payload.create({\n collection: 'component-definitions',\n data: {\n ...component,\n },\n })\n } catch (error: any) {\n console.warn(`[SEED VIEWMODE] Errore su \"${component.name}\", skip`, error?.message ?? error)\n }\n }\n}\n"],"names":["generateTailwindStyles","styles","variant","tailwindSelectorVariants","selectors","Object","values","tailwindFieldsSelectors","selector","value","name","push","css","ViewModeList","componentName","blockPropsMapping","titleProps","text","descriptionProps","imageProps","src","ComponentList","propsSchema","className","async","UIMSSeeder","payload","include","includes","generatedStyles","existing","find","collection","limit","depth","existingNames","Set","docs","map","style","has","create","data","error","console","warn","message","seedStyles","vm","viewMode","seedViewModes","c","component","seedComponents"],"mappings":"iGAOO,MAAMA,EAAyB,KACpC,MAAMC,EAAsB,GAE5B,IAAK,MAAMC,KAAWC,EACpB,IAAK,MAAMC,KAAaC,OAAOC,OAAOC,GACpC,IAAK,MAAMC,KAAYJ,EAAW,CAChC,MAAMK,EAAQ,GAAGP,EAAQO,QAAQD,IAC3BE,EAAO,KAAKD,IAClBR,EAAOU,KAAK,CACVD,OACAE,IAAKH,GAET,CAIJ,OAAOR,GCvBF,MAAMY,EAAe,CAC1B,CACEH,KAAM,OACNI,cAAe,OACfC,kBAAmB,CACjBC,WAAY,CACVC,KAAM,mBAERC,iBAAkB,CAChBD,KAAM,yBAERE,WAAY,CACVC,IAAK,iCCZN,MAAMC,EAAgB,CAC3B,CACEX,KAAM,OACNI,cAAe,OACfQ,YAAa,CACXN,WAAY,CACVC,KAAM,SACNM,UAAW,UAEbL,iBAAkB,CAChBD,KAAM,SACNM,UAAW,UAEbJ,WAAY,CACVC,IAAK,SACLG,UAAW,aCJZC,eAAeC,GAAWC,QAAEA,EAAOC,QAAEA,IACtCA,EAAQC,SAAS,iBCVhBJ,eAA0BE,GAC/B,MAAMG,EAAkB7B,IAElB8B,QAAiBJ,EAAQK,KAAK,CAClCC,WAAY,SACZC,MAAO,IACPC,MAAO,IAGHC,EAAgB,IAAIC,IAAIN,EAASO,KAAKC,IAAKC,GAAeA,EAAM7B,OAEtE,IAAK,MAAM6B,KAASV,EAClB,IAAIM,EAAcK,IAAID,EAAM7B,MAI5B,UACQgB,EAAQe,OAAO,CACnBT,WAAY,SACZU,KAAM,CACJhC,KAAM6B,EAAM7B,KACZE,IAAK,CAAEW,UAAWgB,EAAM3B,OAG9B,CAAE,MAAO+B,GACPC,QAAQC,KAAK,4BAA4BN,EAAM7B,cAAeiC,GAAOG,SAAWH,EAClF,CAEJ,CDjBUI,CAAWrB,GAGfC,EAAQC,SAAS,mBEdhBJ,eAA6BE,GAClC,MAAMI,QAAiBJ,EAAQK,KAAK,CAClCC,WAAY,aACZC,MAAO,IACPC,MAAO,IAGHC,EAAgB,IAAIC,IAAIN,EAASO,KAAKC,IAAKU,GAAYA,EAAGtC,OAEhE,IAAK,MAAMuC,KAAYpC,EACrB,IAAIsB,EAAcK,IAAIS,EAASvC,MAI/B,UACQgB,EAAQe,OAAO,CACnBT,WAAY,aACZU,KAAM,IACDO,IAGT,CAAE,MAAON,GACPC,QAAQC,KAAK,8BAA8BI,EAASvC,cAAeiC,GAAOG,SAAWH,EACvF,CAEJ,CFVUO,CAAcxB,GAGlBC,EAAQC,SAAS,oBGlBhBJ,eAA8BE,GACnC,MAAMI,QAAiBJ,EAAQK,KAAK,CAClCC,WAAY,wBACZC,MAAO,IACPC,MAAO,IAGHC,EAAgB,IAAIC,IAAIN,EAASO,KAAKC,IAAKa,GAAWA,EAAEzC,OAE9D,IAAK,MAAM0C,KAAa/B,EACtB,IAAIc,EAAcK,IAAIY,EAAU1C,MAIhC,UACQgB,EAAQe,OAAO,CACnBT,WAAY,wBACZU,KAAM,IACDU,IAGT,CAAE,MAAOT,GACPC,QAAQC,KAAK,8BAA8BO,EAAU1C,cAAeiC,GAAOG,SAAWH,EACxF,CAEJ,CHNUU,CAAe3B,EAEzB"}
|
|
@@ -1,3 +1,25 @@
|
|
|
1
|
+
import { ViewModeList } from './ViewModeList';
|
|
1
2
|
export async function seedViewModes(payload) {
|
|
2
|
-
|
|
3
|
+
const existing = await payload.find({
|
|
4
|
+
collection: 'view-modes',
|
|
5
|
+
limit: 1000000,
|
|
6
|
+
depth: 0,
|
|
7
|
+
});
|
|
8
|
+
const existingNames = new Set(existing.docs.map((vm) => vm.name));
|
|
9
|
+
for (const viewMode of ViewModeList) {
|
|
10
|
+
if (existingNames.has(viewMode.name)) {
|
|
11
|
+
continue;
|
|
12
|
+
}
|
|
13
|
+
try {
|
|
14
|
+
await payload.create({
|
|
15
|
+
collection: 'view-modes',
|
|
16
|
+
data: {
|
|
17
|
+
...viewMode,
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
catch (error) {
|
|
22
|
+
console.warn(`[SEED VIEWMODE] Errore su "${viewMode.name}", skip`, error?.message ?? error);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
3
25
|
}
|