@payloadcms/plugin-nested-docs 4.0.0-canary.8 → 4.0.0-canary.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -2
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import type { Plugin } from 'payload';
|
|
2
1
|
import type { NestedDocsPluginConfig } from './types.js';
|
|
3
2
|
import { createBreadcrumbsField } from './fields/breadcrumbs.js';
|
|
4
3
|
import { createParentField } from './fields/parent.js';
|
|
5
4
|
import { getParents } from './utilities/getParents.js';
|
|
6
5
|
export { createBreadcrumbsField, createParentField, getParents };
|
|
7
|
-
export declare const nestedDocsPlugin: (
|
|
6
|
+
export declare const nestedDocsPlugin: (options: NestedDocsPluginConfig) => import("payload").Plugin;
|
|
8
7
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAA;AAExD,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAA;AAChE,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AAKtD,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAA;AAEtD,OAAO,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,UAAU,EAAE,CAAA;AAEhE,eAAO,MAAM,gBAAgB,+DAwD3B,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { definePlugin } from 'payload';
|
|
1
2
|
import { createBreadcrumbsField } from './fields/breadcrumbs.js';
|
|
2
3
|
import { createParentField } from './fields/parent.js';
|
|
3
4
|
import { parentFilterOptions } from './fields/parentFilterOptions.js';
|
|
@@ -6,7 +7,9 @@ import { resaveChildren } from './hooks/resaveChildren.js';
|
|
|
6
7
|
import { resaveSelfAfterCreate } from './hooks/resaveSelfAfterCreate.js';
|
|
7
8
|
import { getParents } from './utilities/getParents.js';
|
|
8
9
|
export { createBreadcrumbsField, createParentField, getParents };
|
|
9
|
-
export const nestedDocsPlugin = (
|
|
10
|
+
export const nestedDocsPlugin = definePlugin({
|
|
11
|
+
slug: '@payloadcms/plugin-nested-docs',
|
|
12
|
+
plugin: ({ config, options: pluginConfig })=>({
|
|
10
13
|
...config,
|
|
11
14
|
collections: (config.collections || []).map((collection)=>{
|
|
12
15
|
if (pluginConfig.collections.indexOf(collection.slug) > -1) {
|
|
@@ -48,6 +51,7 @@ export const nestedDocsPlugin = (pluginConfig)=>(config)=>({
|
|
|
48
51
|
}
|
|
49
52
|
return collection;
|
|
50
53
|
})
|
|
51
|
-
})
|
|
54
|
+
})
|
|
55
|
+
});
|
|
52
56
|
|
|
53
57
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { SingleRelationshipField } from 'payload'\n\nimport { definePlugin } 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 { populateBreadcrumbsBeforeChange } from './hooks/populateBreadcrumbsBeforeChange.js'\nimport { resaveChildren } from './hooks/resaveChildren.js'\nimport { resaveSelfAfterCreate } from './hooks/resaveSelfAfterCreate.js'\nimport { getParents } from './utilities/getParents.js'\n\nexport { createBreadcrumbsField, createParentField, getParents }\n\nexport const nestedDocsPlugin = definePlugin<NestedDocsPluginConfig>({\n slug: '@payloadcms/plugin-nested-docs',\n plugin: ({ config, options: pluginConfig }) => ({\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),\n resaveSelfAfterCreate(pluginConfig),\n ...(collection?.hooks?.afterChange || []),\n ],\n beforeChange: [\n populateBreadcrumbsBeforeChange(pluginConfig),\n ...(collection?.hooks?.beforeChange || []),\n ],\n },\n }\n }\n\n return collection\n }),\n }),\n})\n"],"names":["definePlugin","createBreadcrumbsField","createParentField","parentFilterOptions","populateBreadcrumbsBeforeChange","resaveChildren","resaveSelfAfterCreate","getParents","nestedDocsPlugin","slug","plugin","config","options","pluginConfig","collections","map","collection","indexOf","fields","existingBreadcrumbField","find","field","name","breadcrumbsFieldSlug","existingParentField","parentFieldSlug","defaultFilterOptions","filterOptions","defaultParentField","push","hooks","afterChange","beforeChange"],"mappings":"A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a,GAAGD;wBACnCR,OAAOW,IAAI,CAACD;oBACd;oBAEA,IAAI,CAACT,2BAA2B,CAACN,aAAaU,oBAAoB,EAAE;wBAClEL,OAAOW,IAAI,CAAC5B,uBAAuBe,WAAWP,IAAI;oBACpD;oBAEA,OAAO;wBACL,GAAGO,UAAU;wBACbE;wBACAY,OAAO;4BACL,GAAId,WAAWc,KAAK,IAAI,CAAC,CAAC;4BAC1BC,aAAa;gCACX1B,eAAeQ;gCACfP,sBAAsBO;mCAClBG,YAAYc,OAAOC,eAAe,EAAE;6BACzC;4BACDC,cAAc;gCACZ5B,gCAAgCS;mCAC5BG,YAAYc,OAAOE,gBAAgB,EAAE;6BAC1C;wBACH;oBACF;gBACF;gBAEA,OAAOhB;YACT;QACF,CAAA;AACF,GAAE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payloadcms/plugin-nested-docs",
|
|
3
|
-
"version": "4.0.0-canary.
|
|
3
|
+
"version": "4.0.0-canary.9",
|
|
4
4
|
"description": "The official Nested Docs plugin for Payload",
|
|
5
5
|
"homepage": "https://payloadcms.com",
|
|
6
6
|
"repository": {
|
|
@@ -38,10 +38,10 @@
|
|
|
38
38
|
],
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@payloadcms/eslint-config": "3.28.0",
|
|
41
|
-
"payload": "4.0.0-canary.
|
|
41
|
+
"payload": "4.0.0-canary.9"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
|
-
"payload": "4.0.0-canary.
|
|
44
|
+
"payload": "4.0.0-canary.9"
|
|
45
45
|
},
|
|
46
46
|
"publishConfig": {
|
|
47
47
|
"registry": "https://registry.npmjs.org/"
|