@payloadcms/plugin-nested-docs 3.0.0-canary.cee5702 → 3.0.0-canary.ee0375f
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/fields/breadcrumbs.d.ts +1 -1
- package/dist/fields/breadcrumbs.d.ts.map +1 -1
- package/dist/fields/breadcrumbs.js.map +1 -1
- package/dist/fields/parent.d.ts +1 -1
- package/dist/fields/parent.d.ts.map +1 -1
- package/dist/fields/parent.js.map +1 -1
- package/dist/fields/parentFilterOptions.d.ts +1 -1
- package/dist/fields/parentFilterOptions.d.ts.map +1 -1
- package/dist/fields/parentFilterOptions.js.map +1 -1
- package/dist/hooks/resaveChildren.d.ts +1 -1
- package/dist/hooks/resaveChildren.d.ts.map +1 -1
- package/dist/hooks/resaveChildren.js.map +1 -1
- package/dist/hooks/resaveSelfAfterCreate.d.ts +1 -1
- package/dist/hooks/resaveSelfAfterCreate.d.ts.map +1 -1
- package/dist/hooks/resaveSelfAfterCreate.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/utilities/formatBreadcrumb.d.ts +1 -1
- package/dist/utilities/formatBreadcrumb.d.ts.map +1 -1
- package/dist/utilities/formatBreadcrumb.js.map +1 -1
- package/dist/utilities/getParents.d.ts +1 -1
- package/dist/utilities/getParents.d.ts.map +1 -1
- package/dist/utilities/getParents.js.map +1 -1
- package/dist/utilities/populateBreadcrumbs.d.ts +1 -1
- package/dist/utilities/populateBreadcrumbs.d.ts.map +1 -1
- package/dist/utilities/populateBreadcrumbs.js.map +1 -1
- package/package.json +12 -12
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"breadcrumbs.d.ts","sourceRoot":"","sources":["../../src/fields/breadcrumbs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"breadcrumbs.d.ts","sourceRoot":"","sources":["../../src/fields/breadcrumbs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAEhD,eAAO,MAAM,sBAAsB,eACrB,MAAM,cACP,OAAO,CAAC,UAAU,CAAC,KAC7B,KAyCD,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/fields/breadcrumbs.ts"],"sourcesContent":["import type { ArrayField, Field } from 'payload
|
|
1
|
+
{"version":3,"sources":["../../src/fields/breadcrumbs.ts"],"sourcesContent":["import type { ArrayField, Field } from 'payload'\n\nexport const createBreadcrumbsField = (\n relationTo: string,\n overrides: Partial<ArrayField> = {},\n): Field => ({\n name: 'breadcrumbs',\n type: 'array',\n localized: true,\n ...(overrides || {}),\n admin: {\n readOnly: true,\n ...(overrides?.admin || {}),\n },\n fields: [\n {\n name: 'doc',\n type: 'relationship',\n admin: {\n disabled: true,\n },\n maxDepth: 0,\n relationTo,\n },\n {\n type: 'row',\n fields: [\n {\n name: 'url',\n type: 'text',\n admin: {\n width: '50%',\n },\n label: 'URL',\n },\n {\n name: 'label',\n type: 'text',\n admin: {\n width: '50%',\n },\n },\n ],\n },\n ...(overrides?.fields || []),\n ],\n})\n"],"names":["createBreadcrumbsField","relationTo","overrides","name","type","localized","admin","readOnly","fields","disabled","maxDepth","width","label"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAEA,OAAO,MAAMA,yBAAyB,CACpCC,YACAC,YAAiC,CAAC,CAAC,GACxB,CAAA;QACXC,MAAM;QACNC,MAAM;QACNC,WAAW;QACX,GAAIH,aAAa,CAAC,CAAC;QACnBI,OAAO;YACLC,UAAU;YACV,GAAIL,WAAWI,SAAS,CAAC,CAAC;QAC5B;QACAE,QAAQ;YACN;gBACEL,MAAM;gBACNC,MAAM;gBACNE,OAAO;oBACLG,UAAU;gBACZ;gBACAC,UAAU;gBACVT;YACF;YACA;gBACEG,MAAM;gBACNI,QAAQ;oBACN;wBACEL,MAAM;wBACNC,MAAM;wBACNE,OAAO;4BACLK,OAAO;wBACT;wBACAC,OAAO;oBACT;oBACA;wBACET,MAAM;wBACNC,MAAM;wBACNE,OAAO;4BACLK,OAAO;wBACT;oBACF;iBACD;YACH;eACIT,WAAWM,UAAU,EAAE;SAC5B;IACH,CAAA,EAAE"}
|
package/dist/fields/parent.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { SingleRelationshipField } from 'payload
|
|
1
|
+
import type { SingleRelationshipField } from 'payload';
|
|
2
2
|
export declare const createParentField: (relationTo: string, overrides?: Partial<SingleRelationshipField & {
|
|
3
3
|
hasMany: false;
|
|
4
4
|
}>) => SingleRelationshipField;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parent.d.ts","sourceRoot":"","sources":["../../src/fields/parent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"parent.d.ts","sourceRoot":"","sources":["../../src/fields/parent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAA;AAEtD,eAAO,MAAM,iBAAiB,eAChB,MAAM,cACN,OAAO,CACjB,uBAAuB,GAAG;IACxB,OAAO,EAAE,KAAK,CAAA;CACf,CACF,KACA,uBAYD,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/fields/parent.ts"],"sourcesContent":["import type { SingleRelationshipField } from 'payload
|
|
1
|
+
{"version":3,"sources":["../../src/fields/parent.ts"],"sourcesContent":["import type { SingleRelationshipField } from 'payload'\n\nexport const createParentField = (\n relationTo: string,\n overrides?: Partial<\n SingleRelationshipField & {\n hasMany: false\n }\n >,\n): SingleRelationshipField => ({\n name: 'parent',\n admin: {\n position: 'sidebar',\n ...(overrides?.admin || {}),\n },\n // filterOptions are assigned dynamically based on the pluginConfig\n // filterOptions: parentFilterOptions(),\n type: 'relationship',\n maxDepth: 1,\n relationTo,\n ...(overrides || {}),\n})\n"],"names":["createParentField","relationTo","overrides","name","admin","position","type","maxDepth"],"rangeMappings":";;;;;;;;;;;;","mappings":"AAEA,OAAO,MAAMA,oBAAoB,CAC/BC,YACAC,YAK6B,CAAA;QAC7BC,MAAM;QACNC,OAAO;YACLC,UAAU;YACV,GAAIH,WAAWE,SAAS,CAAC,CAAC;QAC5B;QACA,mEAAmE;QACnE,wCAAwC;QACxCE,MAAM;QACNC,UAAU;QACVN;QACA,GAAIC,aAAa,CAAC,CAAC;IACrB,CAAA,EAAE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parentFilterOptions.d.ts","sourceRoot":"","sources":["../../src/fields/parentFilterOptions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"parentFilterOptions.d.ts","sourceRoot":"","sources":["../../src/fields/parentFilterOptions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAE5C,eAAO,MAAM,mBAAmB,EAAE,CAAC,oBAAoB,CAAC,EAAE,MAAM,KAAK,aAWlE,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/fields/parentFilterOptions.ts"],"sourcesContent":["import type { FilterOptions } from 'payload
|
|
1
|
+
{"version":3,"sources":["../../src/fields/parentFilterOptions.ts"],"sourcesContent":["import type { FilterOptions } from 'payload'\n\nexport const parentFilterOptions: (breadcrumbsFieldSlug?: string) => FilterOptions =\n (breadcrumbsFieldSlug = 'breadcrumbs') =>\n ({ id }) => {\n if (id) {\n return {\n id: { not_equals: id },\n [`${breadcrumbsFieldSlug}.doc`]: { not_in: [id] },\n }\n }\n\n return null\n }\n"],"names":["parentFilterOptions","breadcrumbsFieldSlug","id","not_equals","not_in"],"rangeMappings":";;;;;;;;;;;;;;","mappings":"AAEA,OAAO,MAAMA,sBACX,CAACC,uBAAuB,aAAa,GACrC,CAAC,EAAEC,EAAE,EAAE;QACL,IAAIA,IAAI;YACN,OAAO;gBACLA,IAAI;oBAAEC,YAAYD;gBAAG;gBACrB,CAAC,CAAC,EAAED,qBAAqB,IAAI,CAAC,CAAC,EAAE;oBAAEG,QAAQ;wBAACF;qBAAG;gBAAC;YAClD;QACF;QAEA,OAAO;IACT,EAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CollectionAfterChangeHook, CollectionConfig } from 'payload
|
|
1
|
+
import type { CollectionAfterChangeHook, CollectionConfig } from 'payload';
|
|
2
2
|
import type { NestedDocsPluginConfig } from '../types.js';
|
|
3
3
|
export declare const resaveChildren: (pluginConfig: NestedDocsPluginConfig, collection: CollectionConfig) => CollectionAfterChangeHook;
|
|
4
4
|
//# sourceMappingURL=resaveChildren.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resaveChildren.d.ts","sourceRoot":"","sources":["../../src/hooks/resaveChildren.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"resaveChildren.d.ts","sourceRoot":"","sources":["../../src/hooks/resaveChildren.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,gBAAgB,EAA0B,MAAM,SAAS,CAAA;AAElG,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;AAiEzD,eAAO,MAAM,cAAc,iBACV,sBAAsB,cAAc,gBAAgB,KAAG,yBAqBrE,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/hooks/resaveChildren.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"sources":["../../src/hooks/resaveChildren.ts"],"sourcesContent":["import type { CollectionAfterChangeHook, CollectionConfig, PayloadRequestWithData } from 'payload'\n\nimport type { NestedDocsPluginConfig } from '../types.js'\n\nimport { populateBreadcrumbs } from '../utilities/populateBreadcrumbs.js'\n\ntype ResaveArgs = {\n collection: CollectionConfig\n doc: Record<string, unknown>\n draft: boolean\n pluginConfig: NestedDocsPluginConfig\n req: PayloadRequestWithData\n}\n\nconst resave = async ({ collection, doc, draft, pluginConfig, req }: ResaveArgs) => {\n const parentSlug = pluginConfig?.parentFieldSlug || 'parent'\n const parentDocIsPublished = doc._status === 'published'\n\n const children = await req.payload.find({\n collection: collection.slug,\n depth: 0,\n draft,\n locale: req.locale,\n req,\n where: {\n [parentSlug]: {\n equals: doc.id,\n },\n },\n })\n\n const breadcrumbSlug = pluginConfig.breadcrumbsFieldSlug || 'breadcrumbs'\n\n try {\n await children.docs.reduce(async (priorSave, child) => {\n await priorSave\n\n const childIsPublished =\n typeof collection.versions === 'object' &&\n collection.versions.drafts &&\n child._status === 'published'\n\n if (!parentDocIsPublished && childIsPublished) return\n\n await req.payload.update({\n id: child.id,\n collection: collection.slug,\n data: {\n ...child,\n [breadcrumbSlug]: await populateBreadcrumbs(req, pluginConfig, collection, child),\n },\n depth: 0,\n draft: !childIsPublished,\n locale: req.locale,\n req,\n })\n }, Promise.resolve())\n } catch (err: unknown) {\n req.payload.logger.error(\n `Nested Docs plugin has had an error while re-saving a child document${\n draft ? ' as draft' : ' as published'\n }.`,\n )\n req.payload.logger.error(err)\n }\n}\n\nexport const resaveChildren =\n (pluginConfig: NestedDocsPluginConfig, collection: CollectionConfig): CollectionAfterChangeHook =>\n async ({ doc, req }) => {\n await resave({\n collection,\n doc,\n draft: true,\n pluginConfig,\n req,\n })\n\n if (doc._status === 'published') {\n await resave({\n collection,\n doc,\n draft: false,\n pluginConfig,\n req,\n })\n }\n\n return undefined\n }\n"],"names":["populateBreadcrumbs","resave","collection","doc","draft","pluginConfig","req","parentSlug","parentFieldSlug","parentDocIsPublished","_status","children","payload","find","slug","depth","locale","where","equals","id","breadcrumbSlug","breadcrumbsFieldSlug","docs","reduce","priorSave","child","childIsPublished","versions","drafts","update","data","Promise","resolve","err","logger","error","resaveChildren","undefined"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAIA,SAASA,mBAAmB,QAAQ,sCAAqC;AAUzE,MAAMC,SAAS,OAAO,EAAEC,UAAU,EAAEC,GAAG,EAAEC,KAAK,EAAEC,YAAY,EAAEC,GAAG,EAAc;IAC7E,MAAMC,aAAaF,cAAcG,mBAAmB;IACpD,MAAMC,uBAAuBN,IAAIO,OAAO,KAAK;IAE7C,MAAMC,WAAW,MAAML,IAAIM,OAAO,CAACC,IAAI,CAAC;QACtCX,YAAYA,WAAWY,IAAI;QAC3BC,OAAO;QACPX;QACAY,QAAQV,IAAIU,MAAM;QAClBV;QACAW,OAAO;YACL,CAACV,WAAW,EAAE;gBACZW,QAAQf,IAAIgB,EAAE;YAChB;QACF;IACF;IAEA,MAAMC,iBAAiBf,aAAagB,oBAAoB,IAAI;IAE5D,IAAI;QACF,MAAMV,SAASW,IAAI,CAACC,MAAM,CAAC,OAAOC,WAAWC;YAC3C,MAAMD;YAEN,MAAME,mBACJ,OAAOxB,WAAWyB,QAAQ,KAAK,YAC/BzB,WAAWyB,QAAQ,CAACC,MAAM,IAC1BH,MAAMf,OAAO,KAAK;YAEpB,IAAI,CAACD,wBAAwBiB,kBAAkB;YAE/C,MAAMpB,IAAIM,OAAO,CAACiB,MAAM,CAAC;gBACvBV,IAAIM,MAAMN,EAAE;gBACZjB,YAAYA,WAAWY,IAAI;gBAC3BgB,MAAM;oBACJ,GAAGL,KAAK;oBACR,CAACL,eAAe,EAAE,MAAMpB,oBAAoBM,KAAKD,cAAcH,YAAYuB;gBAC7E;gBACAV,OAAO;gBACPX,OAAO,CAACsB;gBACRV,QAAQV,IAAIU,MAAM;gBAClBV;YACF;QACF,GAAGyB,QAAQC,OAAO;IACpB,EAAE,OAAOC,KAAc;QACrB3B,IAAIM,OAAO,CAACsB,MAAM,CAACC,KAAK,CACtB,CAAC,oEAAoE,EACnE/B,QAAQ,cAAc,gBACvB,CAAC,CAAC;QAELE,IAAIM,OAAO,CAACsB,MAAM,CAACC,KAAK,CAACF;IAC3B;AACF;AAEA,OAAO,MAAMG,iBACX,CAAC/B,cAAsCH,aACvC,OAAO,EAAEC,GAAG,EAAEG,GAAG,EAAE;QACjB,MAAML,OAAO;YACXC;YACAC;YACAC,OAAO;YACPC;YACAC;QACF;QAEA,IAAIH,IAAIO,OAAO,KAAK,aAAa;YAC/B,MAAMT,OAAO;gBACXC;gBACAC;gBACAC,OAAO;gBACPC;gBACAC;YACF;QACF;QAEA,OAAO+B;IACT,EAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CollectionAfterChangeHook, CollectionConfig } from 'payload
|
|
1
|
+
import type { CollectionAfterChangeHook, CollectionConfig } from 'payload';
|
|
2
2
|
import type { NestedDocsPluginConfig } from '../types.js';
|
|
3
3
|
export declare const resaveSelfAfterCreate: (pluginConfig: NestedDocsPluginConfig, collection: CollectionConfig) => CollectionAfterChangeHook;
|
|
4
4
|
//# sourceMappingURL=resaveSelfAfterCreate.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resaveSelfAfterCreate.d.ts","sourceRoot":"","sources":["../../src/hooks/resaveSelfAfterCreate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,gBAAgB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"resaveSelfAfterCreate.d.ts","sourceRoot":"","sources":["../../src/hooks/resaveSelfAfterCreate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAE1E,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;AAKzD,eAAO,MAAM,qBAAqB,iBACjB,sBAAsB,cAAc,gBAAgB,KAAG,yBA6CrE,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/hooks/resaveSelfAfterCreate.ts"],"sourcesContent":["import type { CollectionAfterChangeHook, CollectionConfig } from 'payload
|
|
1
|
+
{"version":3,"sources":["../../src/hooks/resaveSelfAfterCreate.ts"],"sourcesContent":["import type { CollectionAfterChangeHook, CollectionConfig } from 'payload'\n\nimport type { NestedDocsPluginConfig } from '../types.js'\n\n// This hook automatically re-saves a document after it is created\n// so that we can build its breadcrumbs with the newly created document's ID.\n\nexport const resaveSelfAfterCreate =\n (pluginConfig: NestedDocsPluginConfig, collection: CollectionConfig): CollectionAfterChangeHook =>\n async ({ doc, operation, req }) => {\n const { locale, payload } = req\n const breadcrumbSlug = pluginConfig.breadcrumbsFieldSlug || 'breadcrumbs'\n const breadcrumbs = doc[breadcrumbSlug]\n\n if (operation === 'create') {\n const originalDocWithDepth0 = await payload.findByID({\n id: doc.id,\n collection: collection.slug,\n depth: 0,\n req,\n })\n\n const updateAsDraft =\n typeof collection.versions === 'object' &&\n collection.versions.drafts &&\n doc._status !== 'published'\n\n try {\n await payload.update({\n id: doc.id,\n collection: collection.slug,\n data: {\n ...originalDocWithDepth0,\n [breadcrumbSlug]:\n breadcrumbs?.map((crumb, i) => ({\n ...crumb,\n doc: breadcrumbs.length === i + 1 ? doc.id : crumb.doc,\n })) || [],\n },\n depth: 0,\n draft: updateAsDraft,\n locale,\n req,\n })\n } catch (err: unknown) {\n payload.logger.error(\n `Nested Docs plugin has had an error while adding breadcrumbs during document creation.`,\n )\n payload.logger.error(err)\n }\n }\n\n return undefined\n }\n"],"names":["resaveSelfAfterCreate","pluginConfig","collection","doc","operation","req","locale","payload","breadcrumbSlug","breadcrumbsFieldSlug","breadcrumbs","originalDocWithDepth0","findByID","id","slug","depth","updateAsDraft","versions","drafts","_status","update","data","map","crumb","i","length","draft","err","logger","error","undefined"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAIA,kEAAkE;AAClE,6EAA6E;AAE7E,OAAO,MAAMA,wBACX,CAACC,cAAsCC,aACvC,OAAO,EAAEC,GAAG,EAAEC,SAAS,EAAEC,GAAG,EAAE;QAC5B,MAAM,EAAEC,MAAM,EAAEC,OAAO,EAAE,GAAGF;QAC5B,MAAMG,iBAAiBP,aAAaQ,oBAAoB,IAAI;QAC5D,MAAMC,cAAcP,GAAG,CAACK,eAAe;QAEvC,IAAIJ,cAAc,UAAU;YAC1B,MAAMO,wBAAwB,MAAMJ,QAAQK,QAAQ,CAAC;gBACnDC,IAAIV,IAAIU,EAAE;gBACVX,YAAYA,WAAWY,IAAI;gBAC3BC,OAAO;gBACPV;YACF;YAEA,MAAMW,gBACJ,OAAOd,WAAWe,QAAQ,KAAK,YAC/Bf,WAAWe,QAAQ,CAACC,MAAM,IAC1Bf,IAAIgB,OAAO,KAAK;YAElB,IAAI;gBACF,MAAMZ,QAAQa,MAAM,CAAC;oBACnBP,IAAIV,IAAIU,EAAE;oBACVX,YAAYA,WAAWY,IAAI;oBAC3BO,MAAM;wBACJ,GAAGV,qBAAqB;wBACxB,CAACH,eAAe,EACdE,aAAaY,IAAI,CAACC,OAAOC,IAAO,CAAA;gCAC9B,GAAGD,KAAK;gCACRpB,KAAKO,YAAYe,MAAM,KAAKD,IAAI,IAAIrB,IAAIU,EAAE,GAAGU,MAAMpB,GAAG;4BACxD,CAAA,MAAO,EAAE;oBACb;oBACAY,OAAO;oBACPW,OAAOV;oBACPV;oBACAD;gBACF;YACF,EAAE,OAAOsB,KAAc;gBACrBpB,QAAQqB,MAAM,CAACC,KAAK,CAClB,CAAC,sFAAsF,CAAC;gBAE1FtB,QAAQqB,MAAM,CAACC,KAAK,CAACF;YACvB;QACF;QAEA,OAAOG;IACT,EAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Plugin } from 'payload
|
|
1
|
+
import type { Plugin } from 'payload';
|
|
2
2
|
import type { NestedDocsPluginConfig } from './types.js';
|
|
3
3
|
import { createBreadcrumbsField } from './fields/breadcrumbs.js';
|
|
4
4
|
import { createParentField } from './fields/parent.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAA2B,MAAM,SAAS,CAAA;AAE9D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAA;AAExD,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAA;AAChE,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AAItD,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAA;AAGtD,OAAO,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,UAAU,EAAE,CAAA;AAEhE,eAAO,MAAM,gBAAgB,iBACZ,sBAAsB,KAAG,MAuDtC,CAAA"}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { Plugin
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { Plugin, SingleRelationshipField } from 'payload'\n\nimport type { NestedDocsPluginConfig } from './types.js'\n\nimport { createBreadcrumbsField } from './fields/breadcrumbs.js'\nimport { createParentField } from './fields/parent.js'\nimport { parentFilterOptions } from './fields/parentFilterOptions.js'\nimport { resaveChildren } from './hooks/resaveChildren.js'\nimport { resaveSelfAfterCreate } from './hooks/resaveSelfAfterCreate.js'\nimport { getParents } from './utilities/getParents.js'\nimport { populateBreadcrumbs } from './utilities/populateBreadcrumbs.js'\n\nexport { createBreadcrumbsField, createParentField, getParents }\n\nexport const nestedDocsPlugin =\n (pluginConfig: NestedDocsPluginConfig): Plugin =>\n (config) => ({\n ...config,\n collections: (config.collections || []).map((collection) => {\n if (pluginConfig.collections.indexOf(collection.slug) > -1) {\n const fields = [...(collection?.fields || [])]\n\n const existingBreadcrumbField = collection.fields.find(\n (field) =>\n 'name' in field && field.name === (pluginConfig?.breadcrumbsFieldSlug || 'breadcrumbs'),\n )\n\n const existingParentField = collection.fields.find(\n (field) => 'name' in field && field.name === (pluginConfig?.parentFieldSlug || 'parent'),\n ) as SingleRelationshipField\n\n const defaultFilterOptions = parentFilterOptions(pluginConfig?.breadcrumbsFieldSlug)\n\n if (existingParentField) {\n if (!existingParentField.filterOptions) {\n existingParentField.filterOptions = defaultFilterOptions\n }\n }\n\n if (!existingParentField && !pluginConfig.parentFieldSlug) {\n const defaultParentField = createParentField(collection.slug)\n defaultParentField.filterOptions = defaultFilterOptions\n fields.push(defaultParentField)\n }\n\n if (!existingBreadcrumbField && !pluginConfig.breadcrumbsFieldSlug) {\n fields.push(createBreadcrumbsField(collection.slug))\n }\n\n return {\n ...collection,\n fields,\n hooks: {\n ...(collection.hooks || {}),\n afterChange: [\n resaveChildren(pluginConfig, collection),\n resaveSelfAfterCreate(pluginConfig, collection),\n ...(collection?.hooks?.afterChange || []),\n ],\n beforeChange: [\n async ({ data, originalDoc, req }) =>\n populateBreadcrumbs(req, pluginConfig, collection, data, originalDoc),\n ...(collection?.hooks?.beforeChange || []),\n ],\n },\n }\n }\n\n return collection\n }),\n })\n"],"names":["createBreadcrumbsField","createParentField","parentFilterOptions","resaveChildren","resaveSelfAfterCreate","getParents","populateBreadcrumbs","nestedDocsPlugin","pluginConfig","config","collections","map","collection","indexOf","slug","fields","existingBreadcrumbField","find","field","name","breadcrumbsFieldSlug","existingParentField","parentFieldSlug","defaultFilterOptions","filterOptions","defaultParentField","push","hooks","afterChange","beforeChange","data","originalDoc","req"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAIA,SAASA,sBAAsB,QAAQ,0BAAyB;AAChE,SAASC,iBAAiB,QAAQ,qBAAoB;AACtD,SAASC,mBAAmB,QAAQ,kCAAiC;AACrE,SAASC,cAAc,QAAQ,4BAA2B;AAC1D,SAASC,qBAAqB,QAAQ,mCAAkC;AACxE,SAASC,UAAU,QAAQ,4BAA2B;AACtD,SAASC,mBAAmB,QAAQ,qCAAoC;AAExE,SAASN,sBAAsB,EAAEC,iBAAiB,EAAEI,UAAU,GAAE;AAEhE,OAAO,MAAME,mBACX,CAACC,eACD,CAACC,SAAY,CAAA;YACX,GAAGA,MAAM;YACTC,aAAa,AAACD,CAAAA,OAAOC,WAAW,IAAI,EAAE,AAAD,EAAGC,GAAG,CAAC,CAACC;gBAC3C,IAAIJ,aAAaE,WAAW,CAACG,OAAO,CAACD,WAAWE,IAAI,IAAI,CAAC,GAAG;oBAC1D,MAAMC,SAAS;2BAAKH,YAAYG,UAAU,EAAE;qBAAE;oBAE9C,MAAMC,0BAA0BJ,WAAWG,MAAM,CAACE,IAAI,CACpD,CAACC,QACC,UAAUA,SAASA,MAAMC,IAAI,KAAMX,CAAAA,cAAcY,wBAAwB,aAAY;oBAGzF,MAAMC,sBAAsBT,WAAWG,MAAM,CAACE,IAAI,CAChD,CAACC,QAAU,UAAUA,SAASA,MAAMC,IAAI,KAAMX,CAAAA,cAAcc,mBAAmB,QAAO;oBAGxF,MAAMC,uBAAuBrB,oBAAoBM,cAAcY;oBAE/D,IAAIC,qBAAqB;wBACvB,IAAI,CAACA,oBAAoBG,aAAa,EAAE;4BACtCH,oBAAoBG,aAAa,GAAGD;wBACtC;oBACF;oBAEA,IAAI,CAACF,uBAAuB,CAACb,aAAac,eAAe,EAAE;wBACzD,MAAMG,qBAAqBxB,kBAAkBW,WAAWE,IAAI;wBAC5DW,mBAAmBD,aAAa,GAAGD;wBACnCR,OAAOW,IAAI,CAACD;oBACd;oBAEA,IAAI,CAACT,2BAA2B,CAACR,aAAaY,oBAAoB,EAAE;wBAClEL,OAAOW,IAAI,CAAC1B,uBAAuBY,WAAWE,IAAI;oBACpD;oBAEA,OAAO;wBACL,GAAGF,UAAU;wBACbG;wBACAY,OAAO;4BACL,GAAIf,WAAWe,KAAK,IAAI,CAAC,CAAC;4BAC1BC,aAAa;gCACXzB,eAAeK,cAAcI;gCAC7BR,sBAAsBI,cAAcI;mCAChCA,YAAYe,OAAOC,eAAe,EAAE;6BACzC;4BACDC,cAAc;gCACZ,OAAO,EAAEC,IAAI,EAAEC,WAAW,EAAEC,GAAG,EAAE,GAC/B1B,oBAAoB0B,KAAKxB,cAAcI,YAAYkB,MAAMC;mCACvDnB,YAAYe,OAAOE,gBAAgB,EAAE;6BAC1C;wBACH;oBACF;gBACF;gBAEA,OAAOjB;YACT;QACF,CAAA,EAAE"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CollectionConfig } from 'payload
|
|
1
|
+
import type { CollectionConfig } from 'payload';
|
|
2
2
|
import type { Breadcrumb, NestedDocsPluginConfig } from '../types.js';
|
|
3
3
|
export declare const formatBreadcrumb: (pluginConfig: NestedDocsPluginConfig, collection: CollectionConfig, docs: Array<Record<string, unknown>>) => Breadcrumb;
|
|
4
4
|
//# sourceMappingURL=formatBreadcrumb.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatBreadcrumb.d.ts","sourceRoot":"","sources":["../../src/utilities/formatBreadcrumb.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"formatBreadcrumb.d.ts","sourceRoot":"","sources":["../../src/utilities/formatBreadcrumb.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAE/C,OAAO,KAAK,EAAE,UAAU,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;AAErE,eAAO,MAAM,gBAAgB,iBACb,sBAAsB,cACxB,gBAAgB,QACtB,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,KACnC,UAsBF,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utilities/formatBreadcrumb.ts"],"sourcesContent":["import type { CollectionConfig } from 'payload
|
|
1
|
+
{"version":3,"sources":["../../src/utilities/formatBreadcrumb.ts"],"sourcesContent":["import type { CollectionConfig } from 'payload'\n\nimport type { Breadcrumb, NestedDocsPluginConfig } from '../types.js'\n\nexport const formatBreadcrumb = (\n pluginConfig: NestedDocsPluginConfig,\n collection: CollectionConfig,\n docs: Array<Record<string, unknown>>,\n): Breadcrumb => {\n let url: string | undefined = undefined\n let label: string\n\n const lastDoc = docs[docs.length - 1]\n\n if (typeof pluginConfig?.generateURL === 'function') {\n url = pluginConfig.generateURL(docs, lastDoc)\n }\n\n if (typeof pluginConfig?.generateLabel === 'function') {\n label = pluginConfig.generateLabel(docs, lastDoc)\n } else {\n const useAsTitle = collection?.admin?.useAsTitle || 'id'\n label = lastDoc[useAsTitle] as string\n }\n\n return {\n doc: lastDoc.id as string,\n label,\n url,\n }\n}\n"],"names":["formatBreadcrumb","pluginConfig","collection","docs","url","undefined","label","lastDoc","length","generateURL","generateLabel","useAsTitle","admin","doc","id"],"rangeMappings":";;;;;;;;;;;;;;;;;;","mappings":"AAIA,OAAO,MAAMA,mBAAmB,CAC9BC,cACAC,YACAC;IAEA,IAAIC,MAA0BC;IAC9B,IAAIC;IAEJ,MAAMC,UAAUJ,IAAI,CAACA,KAAKK,MAAM,GAAG,EAAE;IAErC,IAAI,OAAOP,cAAcQ,gBAAgB,YAAY;QACnDL,MAAMH,aAAaQ,WAAW,CAACN,MAAMI;IACvC;IAEA,IAAI,OAAON,cAAcS,kBAAkB,YAAY;QACrDJ,QAAQL,aAAaS,aAAa,CAACP,MAAMI;IAC3C,OAAO;QACL,MAAMI,aAAaT,YAAYU,OAAOD,cAAc;QACpDL,QAAQC,OAAO,CAACI,WAAW;IAC7B;IAEA,OAAO;QACLE,KAAKN,QAAQO,EAAE;QACfR;QACAF;IACF;AACF,EAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CollectionConfig } from 'payload
|
|
1
|
+
import type { CollectionConfig } from 'payload';
|
|
2
2
|
import type { NestedDocsPluginConfig } from '../types.js';
|
|
3
3
|
export declare const getParents: (req: any, pluginConfig: NestedDocsPluginConfig, collection: CollectionConfig, doc: Record<string, unknown>, docs?: Array<Record<string, unknown>>) => Promise<Array<Record<string, unknown>>>;
|
|
4
4
|
//# sourceMappingURL=getParents.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getParents.d.ts","sourceRoot":"","sources":["../../src/utilities/getParents.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"getParents.d.ts","sourceRoot":"","sources":["../../src/utilities/getParents.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAE/C,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;AAEzD,eAAO,MAAM,UAAU,QAChB,GAAG,gBACM,sBAAsB,cACxB,gBAAgB,OACvB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,SACtB,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,KACnC,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAmCxC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utilities/getParents.ts"],"sourcesContent":["import type { CollectionConfig } from 'payload
|
|
1
|
+
{"version":3,"sources":["../../src/utilities/getParents.ts"],"sourcesContent":["import type { CollectionConfig } from 'payload'\n\nimport type { NestedDocsPluginConfig } from '../types.js'\n\nexport const getParents = async (\n req: any,\n pluginConfig: NestedDocsPluginConfig,\n collection: CollectionConfig,\n doc: Record<string, unknown>,\n docs: Array<Record<string, unknown>> = [],\n): Promise<Array<Record<string, unknown>>> => {\n const parentSlug = pluginConfig?.parentFieldSlug || 'parent'\n const parent = doc[parentSlug]\n let retrievedParent\n\n if (parent) {\n // If not auto-populated, and we have an ID\n if (typeof parent === 'string' || typeof parent === 'number') {\n retrievedParent = await req.payload.findByID({\n id: parent,\n collection: collection.slug,\n depth: 0,\n disableErrors: true,\n req,\n })\n }\n\n // If auto-populated\n if (typeof parent === 'object') {\n retrievedParent = parent\n }\n\n if (retrievedParent) {\n if (retrievedParent[parentSlug]) {\n return getParents(req, pluginConfig, collection, retrievedParent, [\n retrievedParent,\n ...docs,\n ])\n }\n\n return [retrievedParent, ...docs]\n }\n }\n\n return docs\n}\n"],"names":["getParents","req","pluginConfig","collection","doc","docs","parentSlug","parentFieldSlug","parent","retrievedParent","payload","findByID","id","slug","depth","disableErrors"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAIA,OAAO,MAAMA,aAAa,OACxBC,KACAC,cACAC,YACAC,KACAC,OAAuC,EAAE;IAEzC,MAAMC,aAAaJ,cAAcK,mBAAmB;IACpD,MAAMC,SAASJ,GAAG,CAACE,WAAW;IAC9B,IAAIG;IAEJ,IAAID,QAAQ;QACV,2CAA2C;QAC3C,IAAI,OAAOA,WAAW,YAAY,OAAOA,WAAW,UAAU;YAC5DC,kBAAkB,MAAMR,IAAIS,OAAO,CAACC,QAAQ,CAAC;gBAC3CC,IAAIJ;gBACJL,YAAYA,WAAWU,IAAI;gBAC3BC,OAAO;gBACPC,eAAe;gBACfd;YACF;QACF;QAEA,oBAAoB;QACpB,IAAI,OAAOO,WAAW,UAAU;YAC9BC,kBAAkBD;QACpB;QAEA,IAAIC,iBAAiB;YACnB,IAAIA,eAAe,CAACH,WAAW,EAAE;gBAC/B,OAAON,WAAWC,KAAKC,cAAcC,YAAYM,iBAAiB;oBAChEA;uBACGJ;iBACJ;YACH;YAEA,OAAO;gBAACI;mBAAoBJ;aAAK;QACnC;IACF;IAEA,OAAOA;AACT,EAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CollectionConfig } from 'payload
|
|
1
|
+
import type { CollectionConfig } from 'payload';
|
|
2
2
|
import type { NestedDocsPluginConfig } from '../types.js';
|
|
3
3
|
export declare const populateBreadcrumbs: (req: any, pluginConfig: NestedDocsPluginConfig, collection: CollectionConfig, data: any, originalDoc?: any) => Promise<any>;
|
|
4
4
|
//# sourceMappingURL=populateBreadcrumbs.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"populateBreadcrumbs.d.ts","sourceRoot":"","sources":["../../src/utilities/populateBreadcrumbs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"populateBreadcrumbs.d.ts","sourceRoot":"","sources":["../../src/utilities/populateBreadcrumbs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAE/C,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;AAKzD,eAAO,MAAM,mBAAmB,QACzB,GAAG,gBACM,sBAAsB,cACxB,gBAAgB,QACtB,GAAG,gBACK,GAAG,KAChB,OAAO,CAAC,GAAG,CA4Bb,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utilities/populateBreadcrumbs.ts"],"sourcesContent":["import type { CollectionConfig } from 'payload
|
|
1
|
+
{"version":3,"sources":["../../src/utilities/populateBreadcrumbs.ts"],"sourcesContent":["import type { CollectionConfig } from 'payload'\n\nimport type { NestedDocsPluginConfig } from '../types.js'\n\nimport { formatBreadcrumb } from './formatBreadcrumb.js'\nimport { getParents } from './getParents.js'\n\nexport const populateBreadcrumbs = async (\n req: any,\n pluginConfig: NestedDocsPluginConfig,\n collection: CollectionConfig,\n data: any,\n originalDoc?: any,\n): Promise<any> => {\n const newData = data\n const breadcrumbDocs = [\n ...(await getParents(req, pluginConfig, collection, {\n ...originalDoc,\n ...data,\n })),\n ]\n\n const currentDocBreadcrumb = {\n ...originalDoc,\n ...data,\n }\n\n if (originalDoc?.id) {\n currentDocBreadcrumb.id = originalDoc?.id\n }\n\n breadcrumbDocs.push(currentDocBreadcrumb)\n\n const breadcrumbs = breadcrumbDocs.map((_, i) =>\n formatBreadcrumb(pluginConfig, collection, breadcrumbDocs.slice(0, i + 1)),\n ) // eslint-disable-line function-paren-newline\n\n return {\n ...newData,\n [pluginConfig?.breadcrumbsFieldSlug || 'breadcrumbs']: breadcrumbs,\n }\n}\n"],"names":["formatBreadcrumb","getParents","populateBreadcrumbs","req","pluginConfig","collection","data","originalDoc","newData","breadcrumbDocs","currentDocBreadcrumb","id","push","breadcrumbs","map","_","i","slice","breadcrumbsFieldSlug"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAIA,SAASA,gBAAgB,QAAQ,wBAAuB;AACxD,SAASC,UAAU,QAAQ,kBAAiB;AAE5C,OAAO,MAAMC,sBAAsB,OACjCC,KACAC,cACAC,YACAC,MACAC;IAEA,MAAMC,UAAUF;IAChB,MAAMG,iBAAiB;WACjB,MAAMR,WAAWE,KAAKC,cAAcC,YAAY;YAClD,GAAGE,WAAW;YACd,GAAGD,IAAI;QACT;KACD;IAED,MAAMI,uBAAuB;QAC3B,GAAGH,WAAW;QACd,GAAGD,IAAI;IACT;IAEA,IAAIC,aAAaI,IAAI;QACnBD,qBAAqBC,EAAE,GAAGJ,aAAaI;IACzC;IAEAF,eAAeG,IAAI,CAACF;IAEpB,MAAMG,cAAcJ,eAAeK,GAAG,CAAC,CAACC,GAAGC,IACzChB,iBAAiBI,cAAcC,YAAYI,eAAeQ,KAAK,CAAC,GAAGD,IAAI,KACvE,6CAA6C;;IAE/C,OAAO;QACL,GAAGR,OAAO;QACV,CAACJ,cAAcc,wBAAwB,cAAc,EAAEL;IACzD;AACF,EAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payloadcms/plugin-nested-docs",
|
|
3
|
-
"version": "3.0.0-canary.
|
|
3
|
+
"version": "3.0.0-canary.ee0375f",
|
|
4
4
|
"description": "The official Nested Docs plugin for Payload",
|
|
5
5
|
"homepage": "https://payloadcms.com",
|
|
6
6
|
"repository": {
|
|
@@ -14,13 +14,13 @@
|
|
|
14
14
|
"exports": {
|
|
15
15
|
".": {
|
|
16
16
|
"import": "./dist/index.js",
|
|
17
|
-
"
|
|
18
|
-
"
|
|
17
|
+
"types": "./dist/index.d.ts",
|
|
18
|
+
"default": "./dist/index.js"
|
|
19
19
|
},
|
|
20
|
-
"
|
|
21
|
-
"import": "./dist/exports
|
|
22
|
-
"
|
|
23
|
-
"
|
|
20
|
+
"./types": {
|
|
21
|
+
"import": "./dist/exports/types.js",
|
|
22
|
+
"types": "./dist/exports/types.d.ts",
|
|
23
|
+
"default": "./dist/exports/types.js"
|
|
24
24
|
}
|
|
25
25
|
},
|
|
26
26
|
"main": "./dist/index.js",
|
|
@@ -29,18 +29,18 @@
|
|
|
29
29
|
"dist"
|
|
30
30
|
],
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"
|
|
33
|
-
"
|
|
32
|
+
"payload": "3.0.0-canary.ee0375f",
|
|
33
|
+
"@payloadcms/eslint-config": "1.1.1"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
|
-
"payload": "3.0.0-canary.
|
|
36
|
+
"payload": "3.0.0-canary.ee0375f"
|
|
37
37
|
},
|
|
38
38
|
"publishConfig": {
|
|
39
39
|
"registry": "https://registry.npmjs.org/"
|
|
40
40
|
},
|
|
41
41
|
"scripts": {
|
|
42
|
-
"build": "pnpm copyfiles && pnpm build:
|
|
43
|
-
"build:swc": "swc ./src -d ./dist --config-file .swcrc",
|
|
42
|
+
"build": "pnpm copyfiles && pnpm build:types && pnpm build:swc",
|
|
43
|
+
"build:swc": "swc ./src -d ./dist --config-file .swcrc --strip-leading-paths",
|
|
44
44
|
"build:types": "tsc --emitDeclarationOnly --outDir dist",
|
|
45
45
|
"clean": "rimraf {dist,*.tsbuildinfo}",
|
|
46
46
|
"copyfiles": "copyfiles -u 1 \"src/**/*.{html,css,scss,ttf,woff,woff2,eot,svg,jpg,png,json}\" dist/"
|