@payloadcms/plugin-nested-docs 3.0.0-alpha.62 → 3.0.0-alpha.64

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 (2) hide show
  1. package/package.json +4 -4
  2. package/src/index.ts +0 -71
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@payloadcms/plugin-nested-docs",
3
- "version": "3.0.0-alpha.62",
3
+ "version": "3.0.0-alpha.64",
4
4
  "description": "The official Nested Docs plugin for Payload",
5
5
  "repository": {
6
6
  "type": "git",
@@ -14,11 +14,11 @@
14
14
  "types": "./dist/index.d.ts",
15
15
  "type": "module",
16
16
  "devDependencies": {
17
- "@payloadcms/eslint-config": "1.1.1",
18
- "payload": "3.0.0-alpha.62"
17
+ "payload": "3.0.0-alpha.64",
18
+ "@payloadcms/eslint-config": "1.1.1"
19
19
  },
20
20
  "peerDependencies": {
21
- "payload": "3.0.0-alpha.62"
21
+ "payload": "3.0.0-alpha.64"
22
22
  },
23
23
  "exports": {
24
24
  ".": {
package/src/index.ts DELETED
@@ -1,71 +0,0 @@
1
- import type { Plugin } from 'payload/config'
2
- import type { SingleRelationshipField } from 'payload/types'
3
-
4
- import type { PluginConfig } from './types.js'
5
-
6
- import { createBreadcrumbsField } from './fields/breadcrumbs.js'
7
- import { createParentField } from './fields/parent.js'
8
- import { parentFilterOptions } from './fields/parentFilterOptions.js'
9
- import { resaveChildren } from './hooks/resaveChildren.js'
10
- import { resaveSelfAfterCreate } from './hooks/resaveSelfAfterCreate.js'
11
- import { populateBreadcrumbs } from './utilities/populateBreadcrumbs.js'
12
-
13
- export { createBreadcrumbsField, createParentField }
14
-
15
- export const nestedDocs =
16
- (pluginConfig: PluginConfig): Plugin =>
17
- (config) => ({
18
- ...config,
19
- collections: (config.collections || []).map((collection) => {
20
- if (pluginConfig.collections.indexOf(collection.slug) > -1) {
21
- const fields = [...(collection?.fields || [])]
22
-
23
- const existingBreadcrumbField = collection.fields.find(
24
- (field) =>
25
- 'name' in field && field.name === (pluginConfig?.breadcrumbsFieldSlug || 'breadcrumbs'),
26
- )
27
-
28
- const existingParentField = collection.fields.find(
29
- (field) => 'name' in field && field.name === (pluginConfig?.parentFieldSlug || 'parent'),
30
- ) as SingleRelationshipField
31
-
32
- const defaultFilterOptions = parentFilterOptions(pluginConfig?.breadcrumbsFieldSlug)
33
-
34
- if (existingParentField) {
35
- if (!existingParentField.filterOptions) {
36
- existingParentField.filterOptions = defaultFilterOptions
37
- }
38
- }
39
-
40
- if (!existingParentField && !pluginConfig.parentFieldSlug) {
41
- const defaultParentField = createParentField(collection.slug)
42
- defaultParentField.filterOptions = defaultFilterOptions
43
- fields.push(defaultParentField)
44
- }
45
-
46
- if (!existingBreadcrumbField && !pluginConfig.breadcrumbsFieldSlug) {
47
- fields.push(createBreadcrumbsField(collection.slug))
48
- }
49
-
50
- return {
51
- ...collection,
52
- fields,
53
- hooks: {
54
- ...(collection.hooks || {}),
55
- afterChange: [
56
- resaveChildren(pluginConfig, collection),
57
- resaveSelfAfterCreate(pluginConfig, collection),
58
- ...(collection?.hooks?.afterChange || []),
59
- ],
60
- beforeChange: [
61
- async ({ data, originalDoc, req }) =>
62
- populateBreadcrumbs(req, pluginConfig, collection, data, originalDoc),
63
- ...(collection?.hooks?.beforeChange || []),
64
- ],
65
- },
66
- }
67
- }
68
-
69
- return collection
70
- }),
71
- })