@payloadcms/plugin-nested-docs 1.0.3 → 1.0.5

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 (43) hide show
  1. package/README.md +101 -42
  2. package/dist/fields/breadcrumbs.d.ts +2 -2
  3. package/dist/fields/breadcrumbs.js +1 -1
  4. package/dist/fields/breadcrumbs.js.map +1 -1
  5. package/dist/fields/parent.d.ts +4 -3
  6. package/dist/fields/parent.js +7 -1
  7. package/dist/fields/parent.js.map +1 -1
  8. package/dist/formatBreadcrumb.d.ts +4 -0
  9. package/dist/formatBreadcrumb.js +25 -0
  10. package/dist/formatBreadcrumb.js.map +1 -0
  11. package/dist/getParents.d.ts +4 -0
  12. package/dist/getParents.js +89 -0
  13. package/dist/getParents.js.map +1 -0
  14. package/dist/hooks/resaveChildren.d.ts +3 -3
  15. package/dist/hooks/resaveChildren.js +44 -37
  16. package/dist/hooks/resaveChildren.js.map +1 -1
  17. package/dist/hooks/resaveSelfAfterCreate.d.ts +1 -1
  18. package/dist/hooks/resaveSelfAfterCreate.js +45 -41
  19. package/dist/hooks/resaveSelfAfterCreate.js.map +1 -1
  20. package/dist/index.d.ts +3 -3
  21. package/dist/index.js +29 -25
  22. package/dist/index.js.map +1 -1
  23. package/dist/populateBreadcrumbs.d.ts +4 -0
  24. package/dist/populateBreadcrumbs.js +83 -0
  25. package/dist/populateBreadcrumbs.js.map +1 -0
  26. package/dist/types.d.ts +6 -6
  27. package/dist/utilities/deepMerge.d.ts +2 -0
  28. package/dist/utilities/deepMerge.js +44 -0
  29. package/dist/utilities/deepMerge.js.map +1 -0
  30. package/dist/utilities/formatBreadcrumb.d.ts +3 -3
  31. package/dist/utilities/formatBreadcrumb.js +5 -5
  32. package/dist/utilities/formatBreadcrumb.js.map +1 -1
  33. package/dist/utilities/getParents.d.ts +3 -3
  34. package/dist/utilities/getParents.js +5 -7
  35. package/dist/utilities/getParents.js.map +1 -1
  36. package/dist/utilities/populateBreadcrumbs.d.ts +3 -3
  37. package/dist/utilities/populateBreadcrumbs.js +10 -7
  38. package/dist/utilities/populateBreadcrumbs.js.map +1 -1
  39. package/fields.d.ts +2 -0
  40. package/fields.js +7 -0
  41. package/package.json +33 -8
  42. package/types.d.ts +1 -0
  43. package/types.js +1 -0
package/README.md CHANGED
@@ -5,8 +5,9 @@
5
5
  A plugin for [Payload CMS](https://github.com/payloadcms/payload) to easily allow for documents to be nested inside one another.
6
6
 
7
7
  Core features:
8
- - Allows for [parent/child](#parent) relationships between documents
9
- - Automatically populates [breadcrumbs](#breadcrumbs) data
8
+
9
+ - Allows for [parent/child](#parent) relationships between documents
10
+ - Automatically populates [breadcrumbs](#breadcrumbs) data
10
11
 
11
12
  ## Installation
12
13
 
@@ -21,32 +22,33 @@ Core features:
21
22
  In the `plugins` array of your [Payload config](https://payloadcms.com/docs/configuration/overview), call the plugin with [options](#options):
22
23
 
23
24
  ```js
24
- import { buildConfig } from 'payload/config';
25
- import nestedDocs from '@payloadcms/plugin-nested-docs';
25
+ import { buildConfig } from "payload/config";
26
+ import nestedDocs from "@payloadcms/plugin-nested-docs";
26
27
 
27
28
  const config = buildConfig({
28
29
  collections: [
29
30
  {
30
- slug: 'pages',
31
+ slug: "pages",
31
32
  fields: [
32
33
  {
33
- name: 'title',
34
- type: 'text'
34
+ name: "title",
35
+ type: "text",
35
36
  },
36
37
  {
37
- name: 'slug',
38
- type: 'text'
39
- }
40
- ]
41
- }
38
+ name: "slug",
39
+ type: "text",
40
+ },
41
+ ],
42
+ },
42
43
  ],
43
44
  plugins: [
44
45
  nestedDocs({
45
- collections: ['pages'],
46
+ collections: ["pages"],
46
47
  generateLabel: (_, doc) => doc.title,
47
- generateURL: (docs) => docs.reduce((url, doc) => `${url}/${doc.slug}`, ''),
48
- })
49
- ]
48
+ generateURL: (docs) =>
49
+ docs.reduce((url, doc) => `${url}/${doc.slug}`, ""),
50
+ }),
51
+ ],
50
52
  });
51
53
 
52
54
  export default config;
@@ -64,19 +66,19 @@ The `breadcrumbs` field is an array which dynamically populates all parent relat
64
66
 
65
67
  The `breadcrumbs` array stores the following fields:
66
68
 
67
- - `label`
69
+ - `label`
68
70
 
69
- The label of the breadcrumb. This field is automatically set to either the `collection.admin.useAsTitle` (if defined) or is set to the `ID` of the document. You can also dynamically define the `label` by passing a function to the options property of [`generateLabel`](#generateLabel).
71
+ The label of the breadcrumb. This field is automatically set to either the `collection.admin.useAsTitle` (if defined) or is set to the `ID` of the document. You can also dynamically define the `label` by passing a function to the options property of [`generateLabel`](#generateLabel).
70
72
 
71
- - `url`
73
+ - `url`
72
74
 
73
- The URL of the breadcrumb. By default, this field is undefined. You can manually define this field by passing a property called function to the plugin options property of [`generateURL`](#generateURL).
75
+ The URL of the breadcrumb. By default, this field is undefined. You can manually define this field by passing a property called function to the plugin options property of [`generateURL`](#generateURL).
74
76
 
75
77
  ### Options
76
78
 
77
79
  #### `collections`
78
80
 
79
- An array of collections slugs to enable nested docs.
81
+ An array of collections slugs to enable nested docs.
80
82
 
81
83
  #### `generateLabel`
82
84
 
@@ -97,8 +99,8 @@ plugins: [
97
99
 
98
100
  The function takes two arguments and returns a string:
99
101
 
100
- 1. `breadcrumbs` - an array of the breadcrumbs up to that point
101
- 2. `currentDoc` - the current document being edited
102
+ 1. `breadcrumbs` - an array of the breadcrumbs up to that point
103
+ 2. `currentDoc` - the current document being edited
102
104
 
103
105
  #### `generateURL`
104
106
 
@@ -129,57 +131,114 @@ When defined, the `breadcrumbs` field will not be provided for you, and instead,
129
131
 
130
132
  > Note - if you opt out of automatically being provided a `parent` or `breadcrumbs` field, you need to make sure that both fields are placed at the top-level of your document. They cannot exist within any nested data structures like a `group`, `array`, or `blocks`.
131
133
 
132
- ## More
134
+ ## Overrides
133
135
 
134
- You can also extend the built-in `parent` and `breadcrumbs` fields on a page-by-page basis by importing helper methods as follows:
136
+ You can also extend the built-in `parent` and `breadcrumbs` fields per collection by using the `createParentField` and `createBreadcrumbField` methods. They will merge your customizations overtop the plugin's base field configurations.
135
137
 
136
138
  ```js
137
- import { CollectionConfig } from 'payload/types';
138
- import createParentField from '@payloadcms/plugin-nested-docs/fields/parent';
139
- import createBreadcrumbsField from '@payloadcms/plugin-nested-docs/fields/breadcrumbs';
139
+ import { CollectionConfig } from "payload/types";
140
+ import createParentField from "@payloadcms/plugin-nested-docs/fields/parent";
141
+ import createBreadcrumbsField from "@payloadcms/plugin-nested-docs/fields/breadcrumbs";
140
142
 
141
143
  const examplePageConfig: CollectionConfig = {
142
- slug: 'pages',
144
+ slug: "pages",
143
145
  fields: [
144
146
  createParentField(
145
147
  // First argument is equal to the slug of the collection
146
148
  // that the field references
147
- 'pages',
149
+ "pages",
148
150
 
149
151
  // Second argument is equal to field overrides that you specify,
150
152
  // which will be merged into the base parent field config
151
153
  {
152
154
  admin: {
153
- position: 'sidebar',
155
+ position: "sidebar",
154
156
  },
155
- },
157
+ // Note: if you override the `filterOptions` of the `parent` field,
158
+ // be sure to continue to prevent the document from referencing itself as the parent like this:
159
+ // filterOptions: ({ id }) => ({ id: {not_equals: id }})`
160
+ }
156
161
  ),
157
162
  createBreadcrumbsField(
158
163
  // First argument is equal to the slug of the collection
159
164
  // that the field references
160
- 'pages',
165
+ "pages",
161
166
 
162
167
  // Argument equal to field overrides that you specify,
163
168
  // which will be merged into the base `breadcrumbs` field config
164
169
  {
165
- label: 'Page Breadcrumbs',
170
+ label: "Page Breadcrumbs",
166
171
  }
167
- )
168
- ]
169
- }
172
+ ),
173
+ ],
174
+ };
170
175
  ```
171
176
 
172
177
  ## TypeScript
173
178
 
174
179
  All types can be directly imported:
180
+
175
181
  ```js
176
182
  import {
177
- nestedDocsConfig,
183
+ PluginConfig,
178
184
  GenerateURL,
179
- GenerateLabel
180
- } from '@payloadcms/plugin-nested-docs/dist/types';
185
+ GenerateLabel,
186
+ } from "@payloadcms/plugin-nested-docs/types";
181
187
  ```
182
188
 
183
- ## Screenshots
189
+ ## Development
190
+
191
+ To actively develop or debug this plugin you can either work directly within the demo directory of this repo, or link your own project.
192
+
193
+ 1. #### Internal Demo
184
194
 
185
- <!-- ![screenshot 1](https://github.com/@payloadcms/plugin-nested-docs/blob/main/images/screenshot-1.jpg?raw=true) -->
195
+ This repo includes a fully working, self-seeding instance of Payload that installs the plugin directly from the source code. This is the easiest way to get started. To spin up this demo, follow these steps:
196
+
197
+ 1. First clone the repo
198
+ 1. Then, `cd YOUR_PLUGIN_REPO && yarn && cd demo && yarn && yarn dev`
199
+ 1. Now open `http://localhost:3000/admin` in your browser
200
+ 1. Enter username `dev@payloadcms.com` and password `test`
201
+
202
+ That's it! Changes made in `./src` will be reflected in your demo. Keep in mind that the demo database is automatically seeded on every startup, any changes you make to the data get destroyed each time you reboot the app.
203
+
204
+ 1. #### Linked Project
205
+
206
+ You can alternatively link your own project to the source code:
207
+
208
+ 1. First clone the repo
209
+ 1. Then, `cd YOUR_PLUGIN_REPO && yarn && cd demo && cp env.example .env && yarn && yarn dev`
210
+ 1. Now `cd` back into your own project and run, `yarn link @payloadcms/plugin-nested-docs`
211
+ 1. If this plugin using React in any way, continue to the next step. Otherwise skip to step 7.
212
+ 1. From your own project, `cd node_modules/react && yarn link && cd ../react-dom && yarn link && cd ../../`
213
+ 1. Then, `cd YOUR_PLUGIN_REPO && yarn link react react-dom`
214
+
215
+ All set! You can now boot up your own project as normal, and your local copy of the plugin source code will be used. Keep in mind that changes to the source code require a rebuild, `yarn build`.
216
+
217
+ You might also need to alias these modules in your Webpack config. To do this, open your project's Payload config and add the following:
218
+
219
+ ```js
220
+ import { buildConfig } from "payload/config";
221
+
222
+ export default buildConfig({
223
+ admin: {
224
+ webpack: (config) => ({
225
+ ...config,
226
+ resolve: {
227
+ ...config.resolve,
228
+ alias: {
229
+ ...config.resolve.alias,
230
+ react: path.join(__dirname, "../node_modules/react"),
231
+ "react-dom": path.join(__dirname, "../node_modules/react-dom"),
232
+ payload: path.join(__dirname, "../node_modules/payload"),
233
+ "@payloadcms/plugin-nested-docs": path.join(
234
+ __dirname,
235
+ "../../payload/plugin-nested-docs/src"
236
+ ),
237
+ },
238
+ },
239
+ }),
240
+ },
241
+ });
242
+ ```
243
+
244
+ ## Screenshots
@@ -1,4 +1,4 @@
1
- import { ArrayField } from 'payload/dist/fields/config/types';
2
- import { Field } from 'payload/types';
1
+ import type { ArrayField } from 'payload/dist/fields/config/types';
2
+ import type { Field } from 'payload/types';
3
3
  declare const createBreadcrumbsField: (relationTo: string, overrides?: Partial<ArrayField>) => Field;
4
4
  export default createBreadcrumbsField;
@@ -52,7 +52,7 @@ var createBreadcrumbsField = function (relationTo, overrides) {
52
52
  },
53
53
  ],
54
54
  }
55
- ], (overrides === null || overrides === void 0 ? void 0 : overrides.fields) || [], true), admin: __assign({ readOnly: true }, (overrides === null || overrides === void 0 ? void 0 : overrides.admin) || {}) }, overrides || {}));
55
+ ], ((overrides === null || overrides === void 0 ? void 0 : overrides.fields) || []), true), admin: __assign({ readOnly: true }, ((overrides === null || overrides === void 0 ? void 0 : overrides.admin) || {})) }, (overrides || {})));
56
56
  };
57
57
  exports.default = createBreadcrumbsField;
58
58
  //# sourceMappingURL=breadcrumbs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"breadcrumbs.js","sourceRoot":"","sources":["../../src/fields/breadcrumbs.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAGA,IAAM,sBAAsB,GAAG,UAAC,UAAkB,EAAE,SAAmC;IAAnC,0BAAA,EAAA,cAAmC;IAAY,OAAA,YACjG,IAAI,EAAE,aAAa,EACnB,IAAI,EAAE,OAAO,EACb,MAAM;YACJ;gBACE,IAAI,EAAE,KAAK;gBACX,IAAI,EAAE,cAAc;gBACpB,UAAU,YAAA;gBACV,QAAQ,EAAE,CAAC;gBACX,KAAK,EAAE;oBACL,QAAQ,EAAE,IAAI;iBACf;aACF;YACD;gBACE,IAAI,EAAE,KAAK;gBACX,MAAM,EAAE;oBACN;wBACE,IAAI,EAAE,KAAK;wBACX,KAAK,EAAE,KAAK;wBACZ,IAAI,EAAE,MAAM;wBACZ,KAAK,EAAE;4BACL,KAAK,EAAE,KAAK;yBACb;qBACF;oBACD;wBACE,IAAI,EAAE,OAAO;wBACb,IAAI,EAAE,MAAM;wBACZ,KAAK,EAAE;4BACL,KAAK,EAAE,KAAK;yBACb;qBACF;iBACF;aACF;WACE,CAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,MAAM,KAAI,EAAE,SAE5B,KAAK,aACH,QAAQ,EAAE,IAAI,IACX,CAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,KAAK,KAAI,EAAE,KAExB,SAAS,IAAI,EAAE,EAClB;AAxCiG,CAwCjG,CAAC;AAEH,kBAAe,sBAAsB,CAAC"}
1
+ {"version":3,"file":"breadcrumbs.js","sourceRoot":"","sources":["../../src/fields/breadcrumbs.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAGA,IAAM,sBAAsB,GAAG,UAC7B,UAAkB,EAClB,SAAmC;IAAnC,0BAAA,EAAA,cAAmC;IACzB,OAAA,YACV,IAAI,EAAE,aAAa,EACnB,IAAI,EAAE,OAAO,EACb,MAAM;YACJ;gBACE,IAAI,EAAE,KAAK;gBACX,IAAI,EAAE,cAAc;gBACpB,UAAU,YAAA;gBACV,QAAQ,EAAE,CAAC;gBACX,KAAK,EAAE;oBACL,QAAQ,EAAE,IAAI;iBACf;aACF;YACD;gBACE,IAAI,EAAE,KAAK;gBACX,MAAM,EAAE;oBACN;wBACE,IAAI,EAAE,KAAK;wBACX,KAAK,EAAE,KAAK;wBACZ,IAAI,EAAE,MAAM;wBACZ,KAAK,EAAE;4BACL,KAAK,EAAE,KAAK;yBACb;qBACF;oBACD;wBACE,IAAI,EAAE,OAAO;wBACb,IAAI,EAAE,MAAM;wBACZ,KAAK,EAAE;4BACL,KAAK,EAAE,KAAK;yBACb;qBACF;iBACF;aACF;WACE,CAAC,CAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,MAAM,KAAI,EAAE,CAAC,SAE9B,KAAK,aACH,QAAQ,EAAE,IAAI,IACX,CAAC,CAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,KAAK,KAAI,EAAE,CAAC,KAE1B,CAAC,SAAS,IAAI,EAAE,CAAC,EACpB;AAxCU,CAwCV,CAAA;AAEF,kBAAe,sBAAsB,CAAA"}
@@ -1,4 +1,5 @@
1
- import { RelationshipField } from 'payload/dist/fields/config/types';
2
- import { Field } from 'payload/types';
3
- declare const createParentField: (relationTo: string, overrides?: Partial<RelationshipField> | undefined) => Field;
1
+ import type { RelationshipField } from 'payload/dist/fields/config/types';
2
+ declare const createParentField: (relationTo: string, overrides?: Partial<RelationshipField & {
3
+ hasMany: false;
4
+ }>) => RelationshipField;
4
5
  export default createParentField;
@@ -11,6 +11,12 @@ var __assign = (this && this.__assign) || function () {
11
11
  return __assign.apply(this, arguments);
12
12
  };
13
13
  Object.defineProperty(exports, "__esModule", { value: true });
14
- var createParentField = function (relationTo, overrides) { return (__assign({ name: 'parent', relationTo: relationTo, type: 'relationship', maxDepth: 1, admin: __assign({ position: 'sidebar' }, (overrides === null || overrides === void 0 ? void 0 : overrides.admin) || {}) }, overrides || {})); };
14
+ var createParentField = function (relationTo, overrides) { return (__assign({ name: 'parent', relationTo: relationTo, type: 'relationship', maxDepth: 1, filterOptions: function (_a) {
15
+ var id = _a.id;
16
+ return ({
17
+ id: { not_equals: id },
18
+ 'breadcrumbs.doc': { not_in: [id] },
19
+ });
20
+ }, admin: __assign({ position: 'sidebar' }, ((overrides === null || overrides === void 0 ? void 0 : overrides.admin) || {})) }, (overrides || {}))); };
15
21
  exports.default = createParentField;
16
22
  //# sourceMappingURL=parent.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"parent.js","sourceRoot":"","sources":["../../src/fields/parent.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAGA,IAAM,iBAAiB,GAAG,UAAC,UAAkB,EAAE,SAAsC,IAAY,OAAA,YAC/F,IAAI,EAAE,QAAQ,EACd,UAAU,YAAA,EACV,IAAI,EAAE,cAAc,EACpB,QAAQ,EAAE,CAAC,EACX,KAAK,aACH,QAAQ,EAAE,SAAS,IAChB,CAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,KAAK,KAAI,EAAE,KAExB,SAAS,IAAI,EAAE,EAClB,EAV+F,CAU/F,CAAC;AAEH,kBAAe,iBAAiB,CAAC"}
1
+ {"version":3,"file":"parent.js","sourceRoot":"","sources":["../../src/fields/parent.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAEA,IAAM,iBAAiB,GAAG,UACxB,UAAkB,EAClB,SAIC,IACqB,OAAA,YACtB,IAAI,EAAE,QAAQ,EACd,UAAU,YAAA,EACV,IAAI,EAAE,cAAc,EACpB,QAAQ,EAAE,CAAC,EACX,aAAa,EAAE,UAAC,EAAM;YAAJ,EAAE,QAAA;QAAO,OAAA,CAAC;YAC1B,EAAE,EAAE,EAAE,UAAU,EAAE,EAAE,EAAE;YACtB,iBAAiB,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC,EAAE;SACpC,CAAC;IAHyB,CAGzB,EACF,KAAK,aACH,QAAQ,EAAE,SAAS,IAChB,CAAC,CAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,KAAK,KAAI,EAAE,CAAC,KAE1B,CAAC,SAAS,IAAI,EAAE,CAAC,EACpB,EAdsB,CActB,CAAA;AAEF,kBAAe,iBAAiB,CAAA"}
@@ -0,0 +1,4 @@
1
+ import { CollectionConfig } from 'payload/types';
2
+ import { Options, Breadcrumb } from './types';
3
+ declare const formatBreadcrumb: (options: Options, collection: CollectionConfig, docs: Record<string, unknown>[]) => Breadcrumb;
4
+ export default formatBreadcrumb;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var formatBreadcrumb = function (options, collection, docs) {
4
+ var _a;
5
+ var url = undefined;
6
+ var label;
7
+ var lastDoc = docs[docs.length - 1];
8
+ if (typeof (options === null || options === void 0 ? void 0 : options.generateURL) === 'function') {
9
+ url = options.generateURL(docs, lastDoc);
10
+ }
11
+ if (typeof (options === null || options === void 0 ? void 0 : options.generateLabel) === 'function') {
12
+ label = options.generateLabel(docs, lastDoc);
13
+ }
14
+ else {
15
+ var useAsTitle = ((_a = collection === null || collection === void 0 ? void 0 : collection.admin) === null || _a === void 0 ? void 0 : _a.useAsTitle) || 'id';
16
+ label = lastDoc[useAsTitle];
17
+ }
18
+ return {
19
+ label: label,
20
+ url: url,
21
+ doc: lastDoc.id,
22
+ };
23
+ };
24
+ exports.default = formatBreadcrumb;
25
+ //# sourceMappingURL=formatBreadcrumb.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formatBreadcrumb.js","sourceRoot":"","sources":["../src/formatBreadcrumb.ts"],"names":[],"mappings":";;AAGA,IAAM,gBAAgB,GAAG,UACvB,OAAgB,EAChB,UAA4B,EAC5B,IAA+B;;IAE/B,IAAI,GAAG,GAAuB,SAAS,CAAC;IACxC,IAAI,KAAa,CAAC;IAElB,IAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAEtC,IAAI,OAAO,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,WAAW,CAAA,KAAK,UAAU,EAAE;QAC9C,GAAG,GAAG,OAAO,CAAC,WAAW,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;KAC1C;IAED,IAAI,OAAO,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,aAAa,CAAA,KAAK,UAAU,EAAE;QAChD,KAAK,GAAG,OAAO,CAAC,aAAa,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;KAC9C;SAAM;QACL,IAAM,UAAU,GAAG,CAAA,MAAA,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,KAAK,0CAAE,UAAU,KAAI,IAAI,CAAC;QACzD,KAAK,GAAG,OAAO,CAAC,UAAU,CAAW,CAAC;KACvC;IAED,OAAO;QACL,KAAK,OAAA;QACL,GAAG,KAAA;QACH,GAAG,EAAE,OAAO,CAAC,EAAY;KAC1B,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,gBAAgB,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { CollectionConfig } from 'payload/types';
2
+ import { Options } from './types';
3
+ declare const getParents: (req: any, options: Options, collection: CollectionConfig, doc: Record<string, unknown>, docs?: Record<string, unknown>[]) => Promise<Record<string, unknown>[]>;
4
+ export default getParents;
@@ -0,0 +1,89 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (_) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
39
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
40
+ if (ar || !(i in from)) {
41
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
42
+ ar[i] = from[i];
43
+ }
44
+ }
45
+ return to.concat(ar || Array.prototype.slice.call(from));
46
+ };
47
+ Object.defineProperty(exports, "__esModule", { value: true });
48
+ var getParents = function (req, options, collection, doc, docs) {
49
+ if (docs === void 0) { docs = []; }
50
+ return __awaiter(void 0, void 0, void 0, function () {
51
+ var parent, retrievedParent;
52
+ return __generator(this, function (_a) {
53
+ switch (_a.label) {
54
+ case 0:
55
+ parent = doc[(options === null || options === void 0 ? void 0 : options.parentFieldSlug) || 'parent'];
56
+ if (!parent) return [3 /*break*/, 3];
57
+ if (!(typeof parent === 'string')) return [3 /*break*/, 2];
58
+ return [4 /*yield*/, req.payload.findByID({
59
+ req: req,
60
+ id: parent,
61
+ collection: collection.slug,
62
+ depth: 0,
63
+ })];
64
+ case 1:
65
+ retrievedParent = _a.sent();
66
+ _a.label = 2;
67
+ case 2:
68
+ // If auto-populated
69
+ if (typeof parent === 'object') {
70
+ retrievedParent = parent;
71
+ }
72
+ if (retrievedParent) {
73
+ if (retrievedParent.parent) {
74
+ return [2 /*return*/, getParents(req, options, collection, retrievedParent, __spreadArray([
75
+ retrievedParent
76
+ ], docs, true))];
77
+ }
78
+ return [2 /*return*/, __spreadArray([
79
+ retrievedParent
80
+ ], docs, true)];
81
+ }
82
+ _a.label = 3;
83
+ case 3: return [2 /*return*/, docs];
84
+ }
85
+ });
86
+ });
87
+ };
88
+ exports.default = getParents;
89
+ //# sourceMappingURL=getParents.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getParents.js","sourceRoot":"","sources":["../src/getParents.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,IAAM,UAAU,GAAG,UACjB,GAAQ,EACR,OAAgB,EAChB,UAA4B,EAC5B,GAA4B,EAC5B,IAAoC;IAApC,qBAAA,EAAA,SAAoC;;;;;;oBAE9B,MAAM,GAAG,GAAG,CAAC,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,eAAe,KAAI,QAAQ,CAAC,CAAC;yBAGrD,MAAM,EAAN,wBAAM;yBAEJ,CAAA,OAAO,MAAM,KAAK,QAAQ,CAAA,EAA1B,wBAA0B;oBACV,qBAAM,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC;4BAC3C,GAAG,KAAA;4BACH,EAAE,EAAE,MAAM;4BACV,UAAU,EAAE,UAAU,CAAC,IAAI;4BAC3B,KAAK,EAAE,CAAC;yBACT,CAAC,EAAA;;oBALF,eAAe,GAAG,SAKhB,CAAC;;;oBAGL,oBAAoB;oBACpB,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE;wBAC9B,eAAe,GAAG,MAAM,CAAC;qBAC1B;oBAED,IAAI,eAAe,EAAE;wBACnB,IAAI,eAAe,CAAC,MAAM,EAAE;4BAC1B,sBAAO,UAAU,CACf,GAAG,EACH,OAAO,EACP,UAAU,EACV,eAAe;oCAEb,eAAe;mCACZ,IAAI,QAEV,EAAC;yBACH;wBAED;gCACE,eAAe;+BACZ,IAAI,SACP;qBACH;;wBAGH,sBAAO,IAAI,EAAC;;;;CACb,CAAC;AAEF,kBAAe,UAAU,CAAC"}
@@ -1,4 +1,4 @@
1
- import { CollectionConfig, CollectionAfterChangeHook } from 'payload/types';
2
- import { Options } from '../types';
3
- declare const resaveChildren: (options: Options, collection: CollectionConfig) => CollectionAfterChangeHook;
1
+ import type { CollectionAfterChangeHook, CollectionConfig } from 'payload/types';
2
+ import type { PluginConfig } from '../types';
3
+ declare const resaveChildren: (pluginConfig: PluginConfig, collection: CollectionConfig) => CollectionAfterChangeHook;
4
4
  export default resaveChildren;
@@ -25,7 +25,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
25
25
  function verb(n) { return function (v) { return step([n, v]); }; }
26
26
  function step(op) {
27
27
  if (f) throw new TypeError("Generator is already executing.");
28
- while (_) try {
28
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
29
29
  if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
30
30
  if (y = 0, t) op = [op[0] & 2, t.value];
31
31
  switch (op[0]) {
@@ -51,43 +51,50 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
51
51
  };
52
52
  Object.defineProperty(exports, "__esModule", { value: true });
53
53
  var populateBreadcrumbs_1 = __importDefault(require("../utilities/populateBreadcrumbs"));
54
- var resaveChildren = function (options, collection) { return function (_a) {
55
- var payload = _a.req.payload, req = _a.req, doc = _a.doc;
56
- var resaveChildrenAsync = function () { return __awaiter(void 0, void 0, void 0, function () {
57
- var children;
58
- return __generator(this, function (_a) {
59
- switch (_a.label) {
60
- case 0: return [4 /*yield*/, payload.find({
61
- collection: collection.slug,
62
- where: {
63
- parent: {
64
- equals: doc.id,
54
+ var resaveChildren = function (pluginConfig, collection) {
55
+ return function (_a) {
56
+ var payload = _a.req.payload, req = _a.req, doc = _a.doc;
57
+ var resaveChildrenAsync = function () { return __awaiter(void 0, void 0, void 0, function () {
58
+ var children;
59
+ return __generator(this, function (_a) {
60
+ switch (_a.label) {
61
+ case 0: return [4 /*yield*/, payload.find({
62
+ collection: collection.slug,
63
+ where: {
64
+ parent: {
65
+ equals: doc.id,
66
+ },
65
67
  },
66
- },
67
- depth: 0,
68
- })];
69
- case 1:
70
- children = _a.sent();
71
- try {
72
- children.docs.forEach(function (child) {
73
- payload.update({
74
- id: child.id,
75
- collection: collection.slug,
76
- data: __assign(__assign({}, child), { breadcrumbs: (0, populateBreadcrumbs_1.default)(req, options, collection, child) }),
77
- depth: 0,
68
+ depth: 0,
69
+ })];
70
+ case 1:
71
+ children = _a.sent();
72
+ try {
73
+ children.docs.forEach(function (child) {
74
+ var updateAsDraft = typeof collection.versions === 'object' &&
75
+ collection.versions.drafts &&
76
+ child._status !== 'published';
77
+ payload.update({
78
+ id: child.id,
79
+ collection: collection.slug,
80
+ draft: updateAsDraft,
81
+ data: __assign(__assign({}, child), { breadcrumbs: (0, populateBreadcrumbs_1.default)(req, pluginConfig, collection, child) }),
82
+ depth: 0,
83
+ });
78
84
  });
79
- });
80
- }
81
- catch (err) {
82
- console.error(err);
83
- }
84
- return [2 /*return*/];
85
- }
86
- });
87
- }); };
88
- // Non-blocking
89
- resaveChildrenAsync();
90
- return undefined;
91
- }; };
85
+ }
86
+ catch (err) {
87
+ payload.logger.error("Nested Docs plugin has had an error while re-saving a child document.");
88
+ payload.logger.error(err);
89
+ }
90
+ return [2 /*return*/];
91
+ }
92
+ });
93
+ }); };
94
+ // Non-blocking
95
+ resaveChildrenAsync();
96
+ return undefined;
97
+ };
98
+ };
92
99
  exports.default = resaveChildren;
93
100
  //# sourceMappingURL=resaveChildren.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"resaveChildren.js","sourceRoot":"","sources":["../../src/hooks/resaveChildren.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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ionAfterChangeHook, CollectionConfig } from 'payload/types';
2
2
  declare const resaveSelfAfterCreate: (collection: CollectionConfig) => CollectionAfterChangeHook;
3
3
  export default resaveSelfAfterCreate;
@@ -25,7 +25,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
25
25
  function verb(n) { return function (v) { return step([n, v]); }; }
26
26
  function step(op) {
27
27
  if (f) throw new TypeError("Generator is already executing.");
28
- while (_) try {
28
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
29
29
  if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
30
30
  if (y = 0, t) op = [op[0] & 2, t.value];
31
31
  switch (op[0]) {
@@ -47,47 +47,51 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
47
47
  }
48
48
  };
49
49
  Object.defineProperty(exports, "__esModule", { value: true });
50
- // This hook automatically resaves a document after it is created
50
+ // This hook automatically re-saves a document after it is created
51
51
  // so that we can build its breadcrumbs with the newly created document's ID.
52
- var resaveSelfAfterCreate = function (collection) { return function (_a) {
53
- var payload = _a.req.payload, req = _a.req, doc = _a.doc, operation = _a.operation;
54
- return __awaiter(void 0, void 0, void 0, function () {
55
- var _b, breadcrumbs, originalDocWithDepth0, updateAsDraft, err_1;
56
- return __generator(this, function (_c) {
57
- switch (_c.label) {
58
- case 0:
59
- _b = doc.breadcrumbs, breadcrumbs = _b === void 0 ? [] : _b;
60
- if (!(operation === 'create')) return [3 /*break*/, 5];
61
- return [4 /*yield*/, payload.findByID({
62
- collection: collection.slug,
63
- depth: 0,
64
- id: doc.id,
65
- })];
66
- case 1:
67
- originalDocWithDepth0 = _c.sent();
68
- updateAsDraft = typeof collection.versions === 'object' && collection.versions.drafts && doc._status !== 'published';
69
- _c.label = 2;
70
- case 2:
71
- _c.trys.push([2, 4, , 5]);
72
- return [4 /*yield*/, payload.update({
73
- collection: collection.slug,
74
- id: doc.id,
75
- depth: 0,
76
- draft: updateAsDraft,
77
- data: __assign(__assign({}, originalDocWithDepth0), { breadcrumbs: breadcrumbs.map(function (crumb, i) { return (__assign(__assign({}, crumb), { doc: (breadcrumbs === null || breadcrumbs === void 0 ? void 0 : breadcrumbs.length) === i + 1 ? doc.id : crumb.doc })); }) }),
78
- })];
79
- case 3:
80
- _c.sent();
81
- return [3 /*break*/, 5];
82
- case 4:
83
- err_1 = _c.sent();
84
- payload.logger.error("Nested Docs plugin has had an error while adding breadcrumbs during document creation.");
85
- payload.logger.error(err_1);
86
- return [3 /*break*/, 5];
87
- case 5: return [2 /*return*/, undefined];
88
- }
52
+ var resaveSelfAfterCreate = function (collection) {
53
+ return function (_a) {
54
+ var payload = _a.req.payload, doc = _a.doc, operation = _a.operation;
55
+ return __awaiter(void 0, void 0, void 0, function () {
56
+ var _b, breadcrumbs, originalDocWithDepth0, updateAsDraft, err_1;
57
+ return __generator(this, function (_c) {
58
+ switch (_c.label) {
59
+ case 0:
60
+ _b = doc.breadcrumbs, breadcrumbs = _b === void 0 ? [] : _b;
61
+ if (!(operation === 'create')) return [3 /*break*/, 5];
62
+ return [4 /*yield*/, payload.findByID({
63
+ collection: collection.slug,
64
+ depth: 0,
65
+ id: doc.id,
66
+ })];
67
+ case 1:
68
+ originalDocWithDepth0 = _c.sent();
69
+ updateAsDraft = typeof collection.versions === 'object' &&
70
+ collection.versions.drafts &&
71
+ doc._status !== 'published';
72
+ _c.label = 2;
73
+ case 2:
74
+ _c.trys.push([2, 4, , 5]);
75
+ return [4 /*yield*/, payload.update({
76
+ collection: collection.slug,
77
+ id: doc.id,
78
+ depth: 0,
79
+ draft: updateAsDraft,
80
+ data: __assign(__assign({}, originalDocWithDepth0), { breadcrumbs: (breadcrumbs === null || breadcrumbs === void 0 ? void 0 : breadcrumbs.map(function (crumb, i) { return (__assign(__assign({}, crumb), { doc: breadcrumbs.length === i + 1 ? doc.id : crumb.doc })); })) || [] }),
81
+ })];
82
+ case 3:
83
+ _c.sent();
84
+ return [3 /*break*/, 5];
85
+ case 4:
86
+ err_1 = _c.sent();
87
+ payload.logger.error("Nested Docs plugin has had an error while adding breadcrumbs during document creation.");
88
+ payload.logger.error(err_1);
89
+ return [3 /*break*/, 5];
90
+ case 5: return [2 /*return*/, undefined];
91
+ }
92
+ });
89
93
  });
90
- });
91
- }; };
94
+ };
95
+ };
92
96
  exports.default = resaveSelfAfterCreate;
93
97
  //# sourceMappingURL=resaveSelfAfterCreate.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"resaveSelfAfterCreate.js","sourceRoot":"","sources":["../../src/hooks/resaveSelfAfterCreate.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA,iEAAiE;AACjE,6EAA6E;AAE7E,IAAM,qBAAqB,GAAG,UAAC,UAA4B,IAAgC,OAAA,UAAO,EAAyC;QAAhC,OAAO,iBAAA,EAAI,GAAG,SAAA,EAAE,GAAG,SAAA,EAAE,SAAS,eAAA;;;;;;oBAC/H,KAAqB,GAAyB,YAA9B,EAAhB,WAAW,mBAAG,EAAE,KAAA,CAA+B;yBAEnD,CAAA,SAAS,KAAK,QAAQ,CAAA,EAAtB,wBAAsB;oBACM,qBAAM,OAAO,CAAC,QAAQ,CAAC;4BACnD,UAAU,EAAE,UAAU,CAAC,IAAI;4BAC3B,KAAK,EAAE,CAAC;4BACR,EAAE,EAAE,GAAG,CAAC,EAAE;yBACX,CAAC,EAAA;;oBAJI,qBAAqB,GAAG,SAI5B;oBAEI,aAAa,GAAG,OAAO,UAAU,CAAC,QAAQ,KAAK,QAAQ,IAAI,UAAU,CAAC,QAAQ,CAAC,MAAM,IAAI,GAAG,CAAC,OAAO,KAAK,WAAW,CAAC;;;;oBAGzH,qBAAM,OAAO,CAAC,MAAM,CAAC;4BACnB,UAAU,EAAE,UAAU,CAAC,IAAI;4BAC3B,EAAE,EAAE,GAAG,CAAC,EAAE;4BACV,KAAK,EAAE,CAAC;4BACR,KAAK,E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AAU,CAAC,QAAQ,KAAK,QAAQ;4BACvC,UAAU,CAAC,QAAQ,CAAC,MAAM;4BAC1B,GAAG,CAAC,OAAO,KAAK,WAAW,CAAA;;;;wBAG3B,qBAAM,OAAO,CAAC,MAAM,CAAC;gCACnB,UAAU,EAAE,UAAU,CAAC,IAAI;gCAC3B,EAAE,EAAE,GAAG,CAAC,EAAE;gCACV,KAAK,EAAE,CAAC;gCACR,KAAK,EAAE,aAAa;gCACpB,IAAI,wBACC,qBAAqB,KACxB,WAAW,EACT,CAAA,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,GAAG,CAAC,UAAC,KAAK,EAAE,CAAC,IAAK,OAAA,uBAC1B,KAAK,KACR,GAAG,EAAE,WAAW,CAAC,MAAM,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,IACtD,EAH6B,CAG7B,CAAC,KAAI,EAAE,GACZ;6BACF,CAAC,EAAA;;wBAbF,SAaE,CAAA;;;;wBAEF,OAAO,CAAC,MAAM,CAAC,KAAK,CAClB,wFAAwF,CACzF,CAAA;wBACD,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,KAAG,CAAC,CAAA;;4BAI7B,sBAAO,SAAS,EAAA;;;;KACjB;AAvCD,CAuCC,CAAA;AAEH,kBAAe,qBAAqB,CAAA"}
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Config } from 'payload/config';
2
- import { Options } from './types';
3
- declare const nestedDocs: (options: Options) => (config: Config) => Config;
1
+ import type { Config } from 'payload/config';
2
+ import type { PluginConfig } from './types';
3
+ declare const nestedDocs: (pluginConfig: PluginConfig) => (config: Config) => Config;
4
4
  export default nestedDocs;
package/dist/index.js CHANGED
@@ -25,7 +25,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
25
25
  function verb(n) { return function (v) { return step([n, v]); }; }
26
26
  function step(op) {
27
27
  if (f) throw new TypeError("Generator is already executing.");
28
- while (_) try {
28
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
29
29
  if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
30
30
  if (y = 0, t) op = [op[0] & 2, t.value];
31
31
  switch (op[0]) {
@@ -61,32 +61,36 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
61
61
  Object.defineProperty(exports, "__esModule", { value: true });
62
62
  var breadcrumbs_1 = __importDefault(require("./fields/breadcrumbs"));
63
63
  var parent_1 = __importDefault(require("./fields/parent"));
64
- var populateBreadcrumbs_1 = __importDefault(require("./utilities/populateBreadcrumbs"));
65
64
  var resaveChildren_1 = __importDefault(require("./hooks/resaveChildren"));
66
65
  var resaveSelfAfterCreate_1 = __importDefault(require("./hooks/resaveSelfAfterCreate"));
67
- var nestedDocs = function (options) { return function (config) { return (__assign(__assign({}, config), { collections: (config.collections || []).map(function (collection) {
68
- var _a, _b;
69
- if (options.collections.indexOf(collection.slug) > -1) {
70
- var fields = __spreadArray([], (collection === null || collection === void 0 ? void 0 : collection.fields) || [], true);
71
- if (!options.parentFieldSlug) {
72
- fields.push((0, parent_1.default)(collection.slug));
73
- }
74
- if (!options.breadcrumbsFieldSlug) {
75
- fields.push((0, breadcrumbs_1.default)(collection.slug));
66
+ var populateBreadcrumbs_1 = __importDefault(require("./utilities/populateBreadcrumbs"));
67
+ var nestedDocs = function (pluginConfig) {
68
+ return function (config) { return (__assign(__assign({}, config), { collections: (config.collections || []).map(function (collection) {
69
+ var _a, _b;
70
+ if (pluginConfig.collections.indexOf(collection.slug) > -1) {
71
+ var fields = __spreadArray([], ((collection === null || collection === void 0 ? void 0 : collection.fields) || []), true);
72
+ if (!pluginConfig.parentFieldSlug) {
73
+ fields.push((0, parent_1.default)(collection.slug));
74
+ }
75
+ if (!pluginConfig.breadcrumbsFieldSlug) {
76
+ fields.push((0, breadcrumbs_1.default)(collection.slug, {
77
+ localized: Boolean(config.localization),
78
+ }));
79
+ }
80
+ return __assign(__assign({}, collection), { hooks: __assign(__assign({}, (collection.hooks || {})), { beforeChange: __spreadArray([
81
+ function (_a) {
82
+ var req = _a.req, data = _a.data, originalDoc = _a.originalDoc;
83
+ return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_b) {
84
+ return [2 /*return*/, (0, populateBreadcrumbs_1.default)(req, pluginConfig, collection, data, originalDoc)];
85
+ }); });
86
+ }
87
+ ], (((_a = collection === null || collection === void 0 ? void 0 : collection.hooks) === null || _a === void 0 ? void 0 : _a.beforeChange) || []), true), afterChange: __spreadArray([
88
+ (0, resaveChildren_1.default)(pluginConfig, collection),
89
+ (0, resaveSelfAfterCreate_1.default)(collection)
90
+ ], (((_b = collection === null || collection === void 0 ? void 0 : collection.hooks) === null || _b === void 0 ? void 0 : _b.afterChange) || []), true) }), fields: fields });
76
91
  }
77
- return __assign(__assign({}, collection), { hooks: __assign(__assign({}, collection.hooks || {}), { beforeChange: __spreadArray([
78
- function (_a) {
79
- var req = _a.req, data = _a.data, originalDoc = _a.originalDoc;
80
- return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_b) {
81
- return [2 /*return*/, (0, populateBreadcrumbs_1.default)(req, options, collection, data, originalDoc)];
82
- }); });
83
- }
84
- ], ((_a = collection === null || collection === void 0 ? void 0 : collection.hooks) === null || _a === void 0 ? void 0 : _a.beforeChange) || [], true), afterChange: __spreadArray([
85
- (0, resaveChildren_1.default)(options, collection),
86
- (0, resaveSelfAfterCreate_1.default)(collection)
87
- ], ((_b = collection === null || collection === void 0 ? void 0 : collection.hooks) === null || _b === void 0 ? void 0 : _b.afterChange) || [], true) }), fields: fields });
88
- }
89
- return collection;
90
- }) })); }; };
92
+ return collection;
93
+ }) })); };
94
+ };
91
95
  exports.default = nestedDocs;
92
96
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","s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ACb,KAAK,wBACA,CAAC,UAAU,CAAC,KAAK,IAAI,EAAE,CAAC,KAC3B,YAAY;4BACV,UAAO,EAA0B;oCAAxB,GAAG,SAAA,EAAE,IAAI,UAAA,EAAE,WAAW,iBAAA;;oCAC7B,sBAAA,IAAA,6BAAmB,EAAC,GAAG,EAAE,YAAY,EAAE,UAAU,EAAE,IAAI,EAAE,WAAW,CAAC,EAAA;;6BAAA;2BACpE,CAAC,CAAA,MAAA,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,KAAK,0CAAE,YAAY,KAAI,EAAE,CAAC,SAE5C,WAAW;4BACT,IAAA,wBAAc,EAAC,YAAY,EAAE,UAAU,CAAC;4BACxC,IAAA,+BAAqB,EAAC,UAAU,CAAC;2BAC9B,CAAC,CAAA,MAAA,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,KAAK,0CAAE,WAAW,KAAI,EAAE,CAAC,YAG7C,MAAM,QAAA,IACP;aACF;YAED,OAAO,UAAU,CAAA;QACnB,CAAC,CAAC,IACF,EAvC0B,CAuC1B;AAvCF,CAuCE,CAAA;AAEJ,kBAAe,UAAU,CAAA"}
@@ -0,0 +1,4 @@
1
+ import { CollectionConfig } from 'payload/types';
2
+ import { Options } from './types';
3
+ declare const populateBreadcrumbs: (req: any, options: Options, collection: CollectionConfig, data: any, originalDoc?: any) => Promise<any>;
4
+ export default populateBreadcrumbs;
@@ -0,0 +1,83 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
14
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
15
+ return new (P || (P = Promise))(function (resolve, reject) {
16
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
17
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
18
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
19
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
20
+ });
21
+ };
22
+ var __generator = (this && this.__generator) || function (thisArg, body) {
23
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
24
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
25
+ function verb(n) { return function (v) { return step([n, v]); }; }
26
+ function step(op) {
27
+ if (f) throw new TypeError("Generator is already executing.");
28
+ while (_) try {
29
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
30
+ if (y = 0, t) op = [op[0] & 2, t.value];
31
+ switch (op[0]) {
32
+ case 0: case 1: t = op; break;
33
+ case 4: _.label++; return { value: op[1], done: false };
34
+ case 5: _.label++; y = op[1]; op = [0]; continue;
35
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
36
+ default:
37
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
38
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
39
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
40
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
41
+ if (t[2]) _.ops.pop();
42
+ _.trys.pop(); continue;
43
+ }
44
+ op = body.call(thisArg, _);
45
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
46
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
47
+ }
48
+ };
49
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
50
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
51
+ if (ar || !(i in from)) {
52
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
53
+ ar[i] = from[i];
54
+ }
55
+ }
56
+ return to.concat(ar || Array.prototype.slice.call(from));
57
+ };
58
+ var __importDefault = (this && this.__importDefault) || function (mod) {
59
+ return (mod && mod.__esModule) ? mod : { "default": mod };
60
+ };
61
+ Object.defineProperty(exports, "__esModule", { value: true });
62
+ var getParents_1 = __importDefault(require("./getParents"));
63
+ var formatBreadcrumb_1 = __importDefault(require("./formatBreadcrumb"));
64
+ var populateBreadcrumbs = function (req, options, collection, data, originalDoc) { return __awaiter(void 0, void 0, void 0, function () {
65
+ var newData, breadcrumbDocs, _a, breadcrumbs;
66
+ var _b;
67
+ return __generator(this, function (_c) {
68
+ switch (_c.label) {
69
+ case 0:
70
+ newData = data;
71
+ _a = [[]];
72
+ return [4 /*yield*/, (0, getParents_1.default)(req, options, collection, __assign(__assign({}, originalDoc), data))];
73
+ case 1:
74
+ breadcrumbDocs = __spreadArray.apply(void 0, [__spreadArray.apply(void 0, _a.concat([_c.sent(), true])), [
75
+ __assign(__assign(__assign({}, originalDoc), data), { id: originalDoc === null || originalDoc === void 0 ? void 0 : originalDoc.id }),
76
+ ], false]);
77
+ breadcrumbs = breadcrumbDocs.map(function (_, i) { return (0, formatBreadcrumb_1.default)(options, collection, breadcrumbDocs.slice(0, i + 1)); });
78
+ return [2 /*return*/, __assign(__assign({}, newData), (_b = {}, _b[(options === null || options === void 0 ? void 0 : options.breadcrumbsFieldSlug) || 'breadcrumbs'] = breadcrumbs, _b))];
79
+ }
80
+ });
81
+ }); };
82
+ exports.default = populateBreadcrumbs;
83
+ //# sourceMappingURL=populateBreadcrumbs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"populateBreadcrumbs.js","sourceRoot":"","sources":["../src/populateBreadcrumbs.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,4DAAsC;AACtC,wEAAkD;AAElD,IAAM,mBAAmB,GAAG,UAAO,GAAQ,EAAE,OAAgB,EAAE,UAA4B,EAAE,IAAS,EAAE,WAAiB;;;;;;gBACjH,OAAO,GAAG,IAAI,CAAC;;gBAEhB,qBAAM,IAAA,oBAAU,EAAC,GAAG,EAAE,OAAO,EAAE,UAAU,wBACvC,WAAW,GACX,IAAI,EACP,EAAA;;gBAJE,cAAc,uEACf,SAGD;uDAEG,WAAW,GACX,IAAI,KACP,EAAE,EAAE,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,EAAE;8BAEtB;gBAEK,WAAW,GAAG,cAAc,CAAC,GAAG,CAAC,UAAC,CAAC,EAAE,CAAC,IAAK,OAAA,IAAA,0BAAgB,EAAC,OAAO,EAAE,UAAU,EAAE,cAAc,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,EAArE,CAAqE,CAAC,CAAC;gBAExH,4CACK,OAAO,gBACT,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,oBAAoB,KAAI,aAAa,IAAG,WAAW,QAC7D;;;KACH,CAAC;AAEF,kBAAe,mBAAmB,CAAC"}
package/dist/types.d.ts CHANGED
@@ -1,14 +1,14 @@
1
- export declare type Breadcrumb = {
1
+ export interface Breadcrumb {
2
2
  url?: string;
3
3
  label: string;
4
4
  doc: string;
5
- };
6
- export declare type GenerateURL = (docs: Record<string, unknown>[], currentDoc: Record<string, unknown>) => string;
7
- export declare type GenerateLabel = (docs: Record<string, unknown>[], currentDoc: Record<string, unknown>) => string;
8
- export declare type Options = {
5
+ }
6
+ export type GenerateURL = (docs: Array<Record<string, unknown>>, currentDoc: Record<string, unknown>) => string;
7
+ export type GenerateLabel = (docs: Array<Record<string, unknown>>, currentDoc: Record<string, unknown>) => string;
8
+ export interface PluginConfig {
9
9
  collections: string[];
10
10
  generateURL?: GenerateURL;
11
11
  generateLabel?: GenerateLabel;
12
12
  parentFieldSlug?: string;
13
13
  breadcrumbsFieldSlug?: string;
14
- };
14
+ }
@@ -0,0 +1,2 @@
1
+ export declare function isObject(item: unknown): boolean;
2
+ export default function deepMerge<T, R>(target: T, source: R): T;
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.isObject = void 0;
15
+ function isObject(item) {
16
+ return Boolean(item && typeof item === 'object' && !Array.isArray(item));
17
+ }
18
+ exports.isObject = isObject;
19
+ function deepMerge(target, source) {
20
+ var output = __assign({}, target);
21
+ if (isObject(target) && isObject(source)) {
22
+ Object.keys(source).forEach(function (key) {
23
+ var _a, _b;
24
+ // @ts-ignore
25
+ if (isObject(source[key])) {
26
+ if (!(key in target)) {
27
+ // @ts-ignore
28
+ Object.assign(output, (_a = {}, _a[key] = source[key], _a));
29
+ }
30
+ else {
31
+ // @ts-ignore
32
+ output[key] = deepMerge(target[key], source[key]);
33
+ }
34
+ }
35
+ else {
36
+ // @ts-ignore
37
+ Object.assign(output, (_b = {}, _b[key] = source[key], _b));
38
+ }
39
+ });
40
+ }
41
+ return output;
42
+ }
43
+ exports.default = deepMerge;
44
+ //# sourceMappingURL=deepMerge.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deepMerge.js","sourceRoot":"","sources":["../../src/utilities/deepMerge.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,SAAgB,QAAQ,CAAC,IAAa;IACpC,OAAO,OAAO,CAAC,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;AAC3E,CAAC;AAFD,4BAEC;AAED,SAAwB,SAAS,CAAO,MAAS,EAAE,MAAS;IAC1D,IAAM,MAAM,gBAAQ,MAAM,CAAE,CAAC;IAC7B,IAAI,QAAQ,CAAC,MAAM,CAAC,IAAI,QAAQ,CAAC,MAAM,CAAC,EAAE;QACxC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,UAAC,GAAG;;YAC9B,aAAa;YACb,IAAI,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE;gBACzB,IAAI,CAAC,CAAC,GAAG,IAAI,MAAM,CAAC,EAAE;oBACpB,aAAa;oBACb,MAAM,CAAC,MAAM,CAAC,MAAM,YAAI,GAAC,GAAG,IAAG,MAAM,CAAC,GAAG,CAAC,MAAG,CAAC;iBAC/C;qBAAM;oBACL,aAAa;oBACb,MAAM,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;iBACnD;aACF;iBAAM;gBACL,aAAa;gBACb,MAAM,CAAC,MAAM,CAAC,MAAM,YAAI,GAAC,GAAG,IAAG,MAAM,CAAC,GAAG,CAAC,MAAG,CAAC;aAC/C;QACH,CAAC,CAAC,CAAC;KACJ;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AArBD,4BAqBC"}
@@ -1,4 +1,4 @@
1
- import { CollectionConfig } from 'payload/types';
2
- import { Options, Breadcrumb } from '../types';
3
- declare const formatBreadcrumb: (options: Options, collection: CollectionConfig, docs: Record<string, unknown>[]) => Breadcrumb;
1
+ import type { CollectionConfig } from 'payload/types';
2
+ import type { Breadcrumb, PluginConfig } from '../types';
3
+ declare const formatBreadcrumb: (pluginConfig: PluginConfig, collection: CollectionConfig, docs: Array<Record<string, unknown>>) => Breadcrumb;
4
4
  export default formatBreadcrumb;
@@ -1,15 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- var formatBreadcrumb = function (options, collection, docs) {
3
+ var formatBreadcrumb = function (pluginConfig, collection, docs) {
4
4
  var _a;
5
5
  var url = undefined;
6
6
  var label;
7
7
  var lastDoc = docs[docs.length - 1];
8
- if (typeof (options === null || options === void 0 ? void 0 : options.generateURL) === 'function') {
9
- url = options.generateURL(docs, lastDoc);
8
+ if (typeof (pluginConfig === null || pluginConfig === void 0 ? void 0 : pluginConfig.generateURL) === 'function') {
9
+ url = pluginConfig.generateURL(docs, lastDoc);
10
10
  }
11
- if (typeof (options === null || options === void 0 ? void 0 : options.generateLabel) === 'function') {
12
- label = options.generateLabel(docs, lastDoc);
11
+ if (typeof (pluginConfig === null || pluginConfig === void 0 ? void 0 : pluginConfig.generateLabel) === 'function') {
12
+ label = pluginConfig.generateLabel(docs, lastDoc);
13
13
  }
14
14
  else {
15
15
  var useAsTitle = ((_a = collection === null || collection === void 0 ? void 0 : collection.admin) === null || _a === void 0 ? void 0 : _a.useAsTitle) || 'id';
@@ -1 +1 @@
1
- {"version":3,"file":"formatBreadcrumb.js","sourceRoot":"","sources":["../../src/utilities/formatBreadcrumb.ts"],"names":[],"mappings":";;AAGA,IAAM,gBAAgB,GAAG,UACvB,OAAgB,EAChB,UAA4B,EAC5B,IAA+B;;IAE/B,IAAI,GAAG,GAAuB,SAAS,CAAC;IACxC,IAAI,KAAa,CAAC;IAElB,IAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAEtC,IAAI,OAAO,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,WAAW,CAAA,KAAK,UAAU,EAAE;QAC9C,GAAG,GAAG,OAAO,CAAC,WAAW,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;KAC1C;IAED,IAAI,OAAO,CAAA,OAAO,aAAP,OAAO,u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,CAAW,CAAA;KACtC;IAED,OAAO;QACL,KAAK,OAAA;QACL,GAAG,KAAA;QACH,GAAG,EAAE,OAAO,CAAC,EAAY;KAC1B,CAAA;AACH,CAAC,CAAA;AAED,kBAAe,gBAAgB,CAAA"}
@@ -1,4 +1,4 @@
1
- import { CollectionConfig } from 'payload/types';
2
- import { Options } from '../types';
3
- declare const getParents: (req: any, options: Options, collection: CollectionConfig, doc: Record<string, unknown>, docs?: Record<string, unknown>[]) => Promise<Record<string, unknown>[]>;
1
+ import type { CollectionConfig } from 'payload/types';
2
+ import type { PluginConfig } from '../types';
3
+ declare const getParents: (req: any, pluginConfig: PluginConfig, collection: CollectionConfig, doc: Record<string, unknown>, docs?: Array<Record<string, unknown>>) => Promise<Array<Record<string, unknown>>>;
4
4
  export default getParents;
@@ -14,7 +14,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
14
14
  function verb(n) { return function (v) { return step([n, v]); }; }
15
15
  function step(op) {
16
16
  if (f) throw new TypeError("Generator is already executing.");
17
- while (_) try {
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
18
  if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
19
  if (y = 0, t) op = [op[0] & 2, t.value];
20
20
  switch (op[0]) {
@@ -45,14 +45,14 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
45
45
  return to.concat(ar || Array.prototype.slice.call(from));
46
46
  };
47
47
  Object.defineProperty(exports, "__esModule", { value: true });
48
- var getParents = function (req, options, collection, doc, docs) {
48
+ var getParents = function (req, pluginConfig, collection, doc, docs) {
49
49
  if (docs === void 0) { docs = []; }
50
50
  return __awaiter(void 0, void 0, void 0, function () {
51
51
  var parent, retrievedParent;
52
52
  return __generator(this, function (_a) {
53
53
  switch (_a.label) {
54
54
  case 0:
55
- parent = doc[(options === null || options === void 0 ? void 0 : options.parentFieldSlug) || 'parent'];
55
+ parent = doc[(pluginConfig === null || pluginConfig === void 0 ? void 0 : pluginConfig.parentFieldSlug) || 'parent'];
56
56
  if (!parent) return [3 /*break*/, 3];
57
57
  if (!(typeof parent === 'string')) return [3 /*break*/, 2];
58
58
  return [4 /*yield*/, req.payload.findByID({
@@ -72,13 +72,11 @@ var getParents = function (req, options, collection, doc, docs) {
72
72
  }
73
73
  if (retrievedParent) {
74
74
  if (retrievedParent.parent) {
75
- return [2 /*return*/, getParents(req, options, collection, retrievedParent, __spreadArray([
75
+ return [2 /*return*/, getParents(req, pluginConfig, collection, retrievedParent, __spreadArray([
76
76
  retrievedParent
77
77
  ], docs, true))];
78
78
  }
79
- return [2 /*return*/, __spreadArray([
80
- retrievedParent
81
- ], docs, true)];
79
+ return [2 /*return*/, __spreadArray([retrievedParent], docs, true)];
82
80
  }
83
81
  _a.label = 3;
84
82
  case 3: return [2 /*return*/, docs];
@@ -1 +1 @@
1
- {"version":3,"file":"getParents.js","sourceRoot":"","sources":["../../src/utilities/getParents.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,IAAM,UAAU,GAAG,UACjB,GAAQ,EACR,OAAgB,EAChB,UAA4B,EAC5B,GAA4B,EAC5B,IAAoC;IAApC,qBAAA,EAAA,SAAoC;;;;;;oBAE9B,MAAM,GAAG,GAAG,CAAC,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,eAAe,KAAI,QAAQ,CAAC,CAAC;yBAGrD,MAAM,EAAN,wBAAM;yBAEJ,CAAA,OAAO,MAAM,KAAK,QAAQ,CAAA,EAA1B,wBAA0B;oBACV,qBAAM,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC;4BAC3C,GAAG,KAAA;4BACH,EAAE,EAAE,MAAM;4BACV,UAAU,EAAE,UAAU,CAAC,IAAI;4BAC3B,KAAK,EAAE,CAAC;4BACR,aAAa,EAAE,IAAI;yBACpB,CAAC,EAAA;;oBAN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B,IAAI,eAAe,CAAC,MAAM,EAAE;4BAC1B,sBAAO,UAAU,CAAC,GAAG,EAAE,YAAY,EAAE,UAAU,EAAE,eAAe;oCAC9D,eAAe;mCACZ,IAAI,QACP,EAAA;yBACH;wBAED,qCAAQ,eAAe,GAAK,IAAI,SAAC;qBAClC;;wBAGH,sBAAO,IAAI,EAAA;;;;CACZ,CAAA;AAED,kBAAe,UAAU,CAAA"}
@@ -1,4 +1,4 @@
1
- import { CollectionConfig } from 'payload/types';
2
- import { Options } from '../types';
3
- declare const populateBreadcrumbs: (req: any, options: Options, collection: CollectionConfig, data: any, originalDoc?: any) => Promise<any>;
1
+ import type { CollectionConfig } from 'payload/types';
2
+ import type { PluginConfig } from '../types';
3
+ declare const populateBreadcrumbs: (req: any, pluginConfig: PluginConfig, collection: CollectionConfig, data: any, originalDoc?: any) => Promise<any>;
4
4
  export default populateBreadcrumbs;
@@ -25,7 +25,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
25
25
  function verb(n) { return function (v) { return step([n, v]); }; }
26
26
  function step(op) {
27
27
  if (f) throw new TypeError("Generator is already executing.");
28
- while (_) try {
28
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
29
29
  if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
30
30
  if (y = 0, t) op = [op[0] & 2, t.value];
31
31
  switch (op[0]) {
@@ -59,9 +59,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
59
59
  return (mod && mod.__esModule) ? mod : { "default": mod };
60
60
  };
61
61
  Object.defineProperty(exports, "__esModule", { value: true });
62
- var getParents_1 = __importDefault(require("./getParents"));
63
62
  var formatBreadcrumb_1 = __importDefault(require("./formatBreadcrumb"));
64
- var populateBreadcrumbs = function (req, options, collection, data, originalDoc) { return __awaiter(void 0, void 0, void 0, function () {
63
+ var getParents_1 = __importDefault(require("./getParents"));
64
+ var populateBreadcrumbs = function (req, pluginConfig, collection, data, originalDoc) { return __awaiter(void 0, void 0, void 0, function () {
65
65
  var newData, breadcrumbDocs, _a, breadcrumbs;
66
66
  var _b;
67
67
  return __generator(this, function (_c) {
@@ -69,13 +69,16 @@ var populateBreadcrumbs = function (req, options, collection, data, originalDoc)
69
69
  case 0:
70
70
  newData = data;
71
71
  _a = [[]];
72
- return [4 /*yield*/, (0, getParents_1.default)(req, options, collection, __assign(__assign({}, originalDoc), data))];
72
+ return [4 /*yield*/, (0, getParents_1.default)(req, pluginConfig, collection, __assign(__assign({}, originalDoc), data))];
73
73
  case 1:
74
- breadcrumbDocs = __spreadArray.apply(void 0, [__spreadArray.apply(void 0, _a.concat([_c.sent(), true])), [
74
+ breadcrumbDocs = __spreadArray.apply(void 0, [__spreadArray.apply(void 0, _a.concat([(_c.sent()), true])), [
75
75
  __assign(__assign(__assign({}, originalDoc), data), { id: originalDoc === null || originalDoc === void 0 ? void 0 : originalDoc.id }),
76
76
  ], false]);
77
- breadcrumbs = breadcrumbDocs.map(function (_, i) { return (0, formatBreadcrumb_1.default)(options, collection, breadcrumbDocs.slice(0, i + 1)); });
78
- return [2 /*return*/, __assign(__assign({}, newData), (_b = {}, _b[(options === null || options === void 0 ? void 0 : options.breadcrumbsFieldSlug) || 'breadcrumbs'] = breadcrumbs, _b))];
77
+ breadcrumbs = breadcrumbDocs.map(function (_, i) {
78
+ return (0, formatBreadcrumb_1.default)(pluginConfig, collection, breadcrumbDocs.slice(0, i + 1));
79
+ }) // eslint-disable-line function-paren-newline
80
+ ;
81
+ return [2 /*return*/, __assign(__assign({}, newData), (_b = {}, _b[(pluginConfig === null || pluginConfig === void 0 ? void 0 : pluginConfig.breadcrumbsFieldSlug) || 'breadcrumbs'] = breadcrumbs, _b))];
79
82
  }
80
83
  });
81
84
  }); };
@@ -1 +1 @@
1
- {"version":3,"file":"populateBreadcrumbs.js","sourceRoot":"","sources":["../../src/utilities/populateBreadcrumbs.ts"],"names":[],"mappings":";;;;;;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;gBAJE,cAAc,uEACf,CAAC,SAGF,CAAC;uDAEE,WAAW,GACX,IAAI,KACP,EAAE,EAAE,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,EAAE;8BAEtB;gBAEK,WAAW,GAAG,cAAc,CAAC,GAAG,CAAC,UAAC,CAAC,EAAE,CAAC;oBAC1C,OAAA,IAAA,0BAAgB,EAAC,YAAY,EAAE,UAAU,EAAE,cAAc,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;gBAA1E,CAA0E,CAC3E,CAAC,6CAA6C;gBAA9C,CAAA;gBAED,4CACK,OAAO,gBACT,CAAA,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,oBAAoB,KAAI,aAAa,IAAG,WAAW,QACnE;;;KACF,CAAA;AAED,kBAAe,mBAAmB,CAAA"}
package/fields.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from './dist/fields/breadcrumbs';
2
+ export * from './dist/fields/parent';
package/fields.js ADDED
@@ -0,0 +1,7 @@
1
+ const breadcrumbs = require('./dist/fields/breadcrumbs');
2
+ const parent = require('./dist/fields/parent');
3
+
4
+ module.exports = {
5
+ breadcrumbs,
6
+ parent
7
+ };
package/package.json CHANGED
@@ -1,14 +1,16 @@
1
1
  {
2
2
  "name": "@payloadcms/plugin-nested-docs",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
4
4
  "homepage:": "https://payloadcms.com",
5
5
  "repository": "git@github.com:payloadcms/plugin-nested-docs.git",
6
- "description": "Nested documents plugin for Payload CMS",
6
+ "description": "Nested documents plugin for Payload",
7
7
  "main": "dist/index.js",
8
8
  "types": "dist/index.d.ts",
9
9
  "scripts": {
10
10
  "build": "tsc",
11
- "test": "echo \"Error: no test specified\" && exit 1"
11
+ "test": "echo \"Error: no test specified\" && exit 1",
12
+ "lint": "eslint src",
13
+ "lint:fix": "eslint --fix --ext .ts,.tsx src"
12
14
  },
13
15
  "keywords": [
14
16
  "payload",
@@ -23,15 +25,38 @@
23
25
  "author": "dev@payloadcms.com",
24
26
  "license": "MIT",
25
27
  "peerDependencies": {
26
- "payload": "^0.18.5",
28
+ "payload": "^0.18.5 || ^1.0.0",
27
29
  "react": "^16.8.0 || ^17.0.0 || ^18.0.0"
28
30
  },
29
31
  "devDependencies": {
30
- "payload": "^0.18.5",
31
- "react": "^17.0.2",
32
- "typescript": "^4.5.5"
32
+ "@payloadcms/eslint-config": "^0.0.1",
33
+ "@types/escape-html": "^1.0.1",
34
+ "@types/express": "^4.17.9",
35
+ "@types/node": "18.11.3",
36
+ "@types/react": "18.0.21",
37
+ "@typescript-eslint/eslint-plugin": "^5.51.0",
38
+ "@typescript-eslint/parser": "^5.51.0",
39
+ "copyfiles": "^2.4.1",
40
+ "cross-env": "^7.0.3",
41
+ "eslint": "^8.19.0",
42
+ "eslint-config-prettier": "^8.5.0",
43
+ "eslint-plugin-filenames": "^1.3.2",
44
+ "eslint-plugin-import": "2.25.4",
45
+ "eslint-plugin-prettier": "^4.0.0",
46
+ "eslint-plugin-react-hooks": "^4.6.0",
47
+ "eslint-plugin-simple-import-sort": "^10.0.0",
48
+ "nodemon": "^2.0.6",
49
+ "payload": "^1.8.2",
50
+ "prettier": "^2.7.1",
51
+ "react": "^18.0.0",
52
+ "ts-node": "^9.1.1",
53
+ "typescript": "^4.8.4"
33
54
  },
34
55
  "files": [
35
- "dist"
56
+ "dist",
57
+ "fields.js",
58
+ "fields.d.ts",
59
+ "types.js",
60
+ "types.d.ts"
36
61
  ]
37
62
  }
package/types.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from './dist/types';
package/types.js ADDED
@@ -0,0 +1 @@
1
+ module.exports = require('./dist/types');