@payloadcms/plugin-nested-docs 1.0.4 → 1.0.6
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/README.md +8 -6
- package/dist/fields/breadcrumbs.d.ts +2 -2
- package/dist/fields/breadcrumbs.js +2 -2
- package/dist/fields/breadcrumbs.js.map +1 -1
- package/dist/fields/parent.d.ts +4 -3
- package/dist/fields/parent.js +1 -1
- package/dist/fields/parent.js.map +1 -1
- package/dist/hooks/resaveChildren.d.ts +3 -3
- package/dist/hooks/resaveChildren.js +45 -39
- package/dist/hooks/resaveChildren.js.map +1 -1
- package/dist/hooks/resaveSelfAfterCreate.d.ts +1 -1
- package/dist/hooks/resaveSelfAfterCreate.js +45 -40
- package/dist/hooks/resaveSelfAfterCreate.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +26 -26
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +6 -6
- package/dist/utilities/formatBreadcrumb.d.ts +3 -3
- package/dist/utilities/formatBreadcrumb.js +5 -5
- package/dist/utilities/formatBreadcrumb.js.map +1 -1
- package/dist/utilities/getParents.d.ts +3 -3
- package/dist/utilities/getParents.js +4 -6
- package/dist/utilities/getParents.js.map +1 -1
- package/dist/utilities/populateBreadcrumbs.d.ts +3 -3
- package/dist/utilities/populateBreadcrumbs.js +9 -6
- package/dist/utilities/populateBreadcrumbs.js.map +1 -1
- package/fields.d.ts +2 -0
- package/fields.js +7 -0
- package/package.json +33 -8
- package/types.d.ts +1 -0
- package/types.js +1 -0
package/README.md
CHANGED
|
@@ -174,16 +174,20 @@ const examplePageConfig: CollectionConfig = {
|
|
|
174
174
|
};
|
|
175
175
|
```
|
|
176
176
|
|
|
177
|
+
## Localization
|
|
178
|
+
|
|
179
|
+
This plugin supports localization by default. If the `localization` property is set in your Payload config, the `breadcrumbs` field is automatically localized. For more details on how localization works in Payload, see the [Localization](https://payloadcms.com/docs/localization/overview) docs.
|
|
180
|
+
|
|
177
181
|
## TypeScript
|
|
178
182
|
|
|
179
183
|
All types can be directly imported:
|
|
180
184
|
|
|
181
185
|
```js
|
|
182
186
|
import {
|
|
183
|
-
|
|
187
|
+
PluginConfig,
|
|
184
188
|
GenerateURL,
|
|
185
189
|
GenerateLabel,
|
|
186
|
-
} from "@payloadcms/plugin-nested-docs/
|
|
190
|
+
} from "@payloadcms/plugin-nested-docs/types";
|
|
187
191
|
```
|
|
188
192
|
|
|
189
193
|
## Development
|
|
@@ -195,7 +199,7 @@ To actively develop or debug this plugin you can either work directly within the
|
|
|
195
199
|
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
200
|
|
|
197
201
|
1. First clone the repo
|
|
198
|
-
1. Then, `cd
|
|
202
|
+
1. Then, `cd YOUR_PLUGIN_REPO && yarn && cd demo && yarn && yarn dev`
|
|
199
203
|
1. Now open `http://localhost:3000/admin` in your browser
|
|
200
204
|
1. Enter username `dev@payloadcms.com` and password `test`
|
|
201
205
|
|
|
@@ -206,7 +210,7 @@ To actively develop or debug this plugin you can either work directly within the
|
|
|
206
210
|
You can alternatively link your own project to the source code:
|
|
207
211
|
|
|
208
212
|
1. First clone the repo
|
|
209
|
-
1. Then, `cd YOUR_PLUGIN_REPO && yarn &&
|
|
213
|
+
1. Then, `cd YOUR_PLUGIN_REPO && yarn && cd demo && cp env.example .env && yarn && yarn dev`
|
|
210
214
|
1. Now `cd` back into your own project and run, `yarn link @payloadcms/plugin-nested-docs`
|
|
211
215
|
1. If this plugin using React in any way, continue to the next step. Otherwise skip to step 7.
|
|
212
216
|
1. From your own project, `cd node_modules/react && yarn link && cd ../react-dom && yarn link && cd ../../`
|
|
@@ -242,5 +246,3 @@ To actively develop or debug this plugin you can either work directly within the
|
|
|
242
246
|
```
|
|
243
247
|
|
|
244
248
|
## Screenshots
|
|
245
|
-
|
|
246
|
-
<!--  -->
|
|
@@ -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;
|
|
@@ -22,7 +22,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
22
22
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
23
|
var createBreadcrumbsField = function (relationTo, overrides) {
|
|
24
24
|
if (overrides === void 0) { overrides = {}; }
|
|
25
|
-
return (__assign({ name: 'breadcrumbs', type: 'array', fields: __spreadArray([
|
|
25
|
+
return (__assign({ name: 'breadcrumbs', type: 'array', localized: true, fields: __spreadArray([
|
|
26
26
|
{
|
|
27
27
|
name: 'doc',
|
|
28
28
|
type: 'relationship',
|
|
@@ -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,
|
|
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,SAAS,EAAE,IAAI,EACf,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;AAzCU,CAyCV,CAAA;AAEF,kBAAe,sBAAsB,CAAA"}
|
package/dist/fields/parent.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { RelationshipField } from 'payload/dist/fields/config/types';
|
|
2
|
-
|
|
3
|
-
|
|
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;
|
package/dist/fields/parent.js
CHANGED
|
@@ -17,6 +17,6 @@ var createParentField = function (relationTo, overrides) { return (__assign({ na
|
|
|
17
17
|
id: { not_equals: id },
|
|
18
18
|
'breadcrumbs.doc': { not_in: [id] },
|
|
19
19
|
});
|
|
20
|
-
}, admin: __assign({ position: 'sidebar' }, (overrides === null || overrides === void 0 ? void 0 : overrides.admin) || {}) }, overrides || {})); };
|
|
20
|
+
}, admin: __assign({ position: 'sidebar' }, ((overrides === null || overrides === void 0 ? void 0 : overrides.admin) || {})) }, (overrides || {}))); };
|
|
21
21
|
exports.default = createParentField;
|
|
22
22
|
//# sourceMappingURL=parent.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parent.js","sourceRoot":"","sources":["../../src/fields/parent.ts"],"names":[],"mappings":";;;;;;;;;;;;;
|
|
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"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
declare const resaveChildren: (
|
|
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;
|
|
@@ -51,46 +51,52 @@ 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 (
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
var
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
54
|
+
var resaveChildren = function (pluginConfig, collection) {
|
|
55
|
+
return function (_a) {
|
|
56
|
+
var _b = _a.req, payload = _b.payload, locale = _b.locale, 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
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
68
|
+
depth: 0,
|
|
69
|
+
locale: locale,
|
|
70
|
+
})];
|
|
71
|
+
case 1:
|
|
72
|
+
children = _a.sent();
|
|
73
|
+
try {
|
|
74
|
+
children.docs.forEach(function (child) {
|
|
75
|
+
var updateAsDraft = typeof collection.versions === 'object' &&
|
|
76
|
+
collection.versions.drafts &&
|
|
77
|
+
child._status !== 'published';
|
|
78
|
+
payload.update({
|
|
79
|
+
id: child.id,
|
|
80
|
+
collection: collection.slug,
|
|
81
|
+
draft: updateAsDraft,
|
|
82
|
+
data: __assign(__assign({}, child), { breadcrumbs: (0, populateBreadcrumbs_1.default)(req, pluginConfig, collection, child) }),
|
|
83
|
+
depth: 0,
|
|
84
|
+
locale: locale,
|
|
85
|
+
});
|
|
80
86
|
});
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
}
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
};
|
|
87
|
+
}
|
|
88
|
+
catch (err) {
|
|
89
|
+
payload.logger.error("Nested Docs plugin has had an error while re-saving a child document.");
|
|
90
|
+
payload.logger.error(err);
|
|
91
|
+
}
|
|
92
|
+
return [2 /*return*/];
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
}); };
|
|
96
|
+
// Non-blocking
|
|
97
|
+
resaveChildrenAsync();
|
|
98
|
+
return undefined;
|
|
99
|
+
};
|
|
100
|
+
};
|
|
95
101
|
exports.default = resaveChildren;
|
|
96
102
|
//# sourceMappingURL=resaveChildren.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resaveChildren.js","sourceRoot":"","sources":["../../src/hooks/resaveChildren.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"resaveChildren.js","sourceRoot":"","sources":["../../src/hooks/resaveChildren.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,yFAAkE;AAElE,IAAM,cAAc,GAClB,UAAC,YAA0B,EAAE,UAA4B;IACzD,OAAA,UAAC,EAAsC;YAApC,WAAwB,EAAjB,OAAO,aAAA,EAAE,MAAM,YAAA,EAAI,GAAG,SAAA,EAAE,GAAG,SAAA;QACnC,IAAM,mBAAmB,GAAG;;;;4BACT,qBAAM,OAAO,CAAC,IAAI,CAAC;4BAClC,UAAU,EAAE,UAAU,CAAC,IAAI;4BAC3B,KAAK,EAAE;gCACL,MAAM,EAAE;oCACN,MAAM,EAAE,GAAG,CAAC,EAAE;iCACf;6BACF;4BACD,KAAK,EAAE,CAAC;4BACR,MAAM,QAAA;yBACP,CAAC,EAAA;;wBATI,QAAQ,GAAG,SASf;wBAEF,IAAI;4BACF,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,UAAC,KAAU;gCAC/B,IAAM,aAAa,GACjB,OAAO,UAAU,CAAC,QAAQ,KAAK,QAAQ;oCACvC,UAAU,CAAC,QAAQ,CAAC,MAAM;oCAC1B,KAAK,CAAC,OAAO,KAAK,WAAW,CAAA;gCAE/B,OAAO,CAAC,MAAM,CAAC;oCACb,EAAE,EAAE,KAAK,CAAC,EAAE;oCACZ,UAAU,EAAE,UAAU,CAAC,IAAI;oCAC3B,KAAK,EAAE,aAAa;oCACpB,IAAI,wBACC,KAAK,KACR,WAAW,EAAE,IAAA,6BAAmB,EAAC,GAAG,EAAE,YAAY,EAAE,UAAU,EAAE,KAAK,CAAC,GACvE;oCACD,KAAK,EAAE,CAAC;oCACR,MAAM,QAAA;iCACP,CAAC,CAAA;4BACJ,CAAC,CAAC,CAAA;yBACH;wBAAC,OAAO,GAAY,EAAE;4BACrB,OAAO,CAAC,MAAM,CAAC,KAAK,CAClB,uEAAuE,CACxE,CAAA;4BACD,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;yBAC1B;;;;aACF,CAAA;QAED,eAAe;QACf,mBAAmB,EAAE,CAAA;QAErB,OAAO,SAAS,CAAA;IAClB,CAAC;AA5CD,CA4CC,CAAA;AAEH,kBAAe,cAAc,CAAA"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { CollectionAfterChangeHook, CollectionConfig } from 'payload/types';
|
|
2
2
|
declare const resaveSelfAfterCreate: (collection: CollectionConfig) => CollectionAfterChangeHook;
|
|
3
3
|
export default resaveSelfAfterCreate;
|
|
@@ -47,47 +47,52 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
47
47
|
}
|
|
48
48
|
};
|
|
49
49
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
|
-
// This hook automatically
|
|
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) {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
52
|
+
var resaveSelfAfterCreate = function (collection) {
|
|
53
|
+
return function (_a) {
|
|
54
|
+
var _b = _a.req, payload = _b.payload, locale = _b.locale, doc = _a.doc, operation = _a.operation;
|
|
55
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
56
|
+
var _c, breadcrumbs, originalDocWithDepth0, updateAsDraft, err_1;
|
|
57
|
+
return __generator(this, function (_d) {
|
|
58
|
+
switch (_d.label) {
|
|
59
|
+
case 0:
|
|
60
|
+
_c = doc.breadcrumbs, breadcrumbs = _c === void 0 ? [] : _c;
|
|
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 = _d.sent();
|
|
69
|
+
updateAsDraft = typeof collection.versions === 'object' &&
|
|
70
|
+
collection.versions.drafts &&
|
|
71
|
+
doc._status !== 'published';
|
|
72
|
+
_d.label = 2;
|
|
73
|
+
case 2:
|
|
74
|
+
_d.trys.push([2, 4, , 5]);
|
|
75
|
+
return [4 /*yield*/, payload.update({
|
|
76
|
+
collection: collection.slug,
|
|
77
|
+
id: doc.id,
|
|
78
|
+
locale: locale,
|
|
79
|
+
depth: 0,
|
|
80
|
+
draft: updateAsDraft,
|
|
81
|
+
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 })); })) || [] }),
|
|
82
|
+
})];
|
|
83
|
+
case 3:
|
|
84
|
+
_d.sent();
|
|
85
|
+
return [3 /*break*/, 5];
|
|
86
|
+
case 4:
|
|
87
|
+
err_1 = _d.sent();
|
|
88
|
+
payload.logger.error("Nested Docs plugin has had an error while adding breadcrumbs during document creation.");
|
|
89
|
+
payload.logger.error(err_1);
|
|
90
|
+
return [3 /*break*/, 5];
|
|
91
|
+
case 5: return [2 /*return*/, undefined];
|
|
92
|
+
}
|
|
93
|
+
});
|
|
89
94
|
});
|
|
90
|
-
}
|
|
91
|
-
};
|
|
95
|
+
};
|
|
96
|
+
};
|
|
92
97
|
exports.default = resaveSelfAfterCreate;
|
|
93
98
|
//# sourceMappingURL=resaveSelfAfterCreate.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resaveSelfAfterCreate.js","sourceRoot":"","sources":["../../src/hooks/resaveSelfAfterCreate.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"resaveSelfAfterCreate.js","sourceRoot":"","sources":["../../src/hooks/resaveSelfAfterCreate.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQA,kEAAkE;AAClE,6EAA6E;AAE7E,IAAM,qBAAqB,GACzB,UAAC,UAA4B;IAC7B,OAAA,UAAO,EAA4C;YAA1C,WAAwB,EAAjB,OAAO,aAAA,EAAE,MAAM,YAAA,EAAI,GAAG,SAAA,EAAE,SAAS,eAAA;;;;;;wBACvC,KAAqB,GAAyB,YAA9B,EAAhB,WAAW,mBAAG,EAAE,KAAA,CAA8B;6BAElD,CAAA,SAAS,KAAK,QAAQ,CAAA,EAAtB,wBAAsB;wBACM,qBAAM,OAAO,CAAC,QAAQ,CAAC;gCACnD,UAAU,EAAE,UAAU,CAAC,IAAI;gCAC3B,KAAK,EAAE,CAAC;gCACR,EAAE,EAAE,GAAG,CAAC,EAAE;6BACX,CAAC,EAAA;;wBAJI,qBAAqB,GAAG,SAI5B;wBAEI,aAAa,GACjB,OAAO,UAAU,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,MAAM,QAAA;gCACN,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;;wBAdF,SAcE,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;AAxCD,CAwCC,CAAA;AAEH,kBAAe,qBAAqB,CAAA"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Config } from 'payload/config';
|
|
2
|
-
import {
|
|
3
|
-
declare const nestedDocs: (
|
|
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
|
@@ -61,34 +61,34 @@ 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
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
var
|
|
71
|
-
if (
|
|
72
|
-
fields
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
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
|
+
}
|
|
78
|
+
return __assign(__assign({}, collection), { hooks: __assign(__assign({}, (collection.hooks || {})), { beforeChange: __spreadArray([
|
|
79
|
+
function (_a) {
|
|
80
|
+
var req = _a.req, data = _a.data, originalDoc = _a.originalDoc;
|
|
81
|
+
return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_b) {
|
|
82
|
+
return [2 /*return*/, (0, populateBreadcrumbs_1.default)(req, pluginConfig, collection, data, originalDoc)];
|
|
83
|
+
}); });
|
|
84
|
+
}
|
|
85
|
+
], (((_a = collection === null || collection === void 0 ? void 0 : collection.hooks) === null || _a === void 0 ? void 0 : _a.beforeChange) || []), true), afterChange: __spreadArray([
|
|
86
|
+
(0, resaveChildren_1.default)(pluginConfig, collection),
|
|
87
|
+
(0, resaveSelfAfterCreate_1.default)(collection)
|
|
88
|
+
], (((_b = collection === null || collection === void 0 ? void 0 : collection.hooks) === null || _b === void 0 ? void 0 : _b.afterChange) || []), true) }), fields: fields });
|
|
78
89
|
}
|
|
79
|
-
return
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_b) {
|
|
83
|
-
return [2 /*return*/, (0, populateBreadcrumbs_1.default)(req, options, collection, data, originalDoc)];
|
|
84
|
-
}); });
|
|
85
|
-
}
|
|
86
|
-
], ((_a = collection === null || collection === void 0 ? void 0 : collection.hooks) === null || _a === void 0 ? void 0 : _a.beforeChange) || [], true), afterChange: __spreadArray([
|
|
87
|
-
(0, resaveChildren_1.default)(options, collection),
|
|
88
|
-
(0, resaveSelfAfterCreate_1.default)(collection)
|
|
89
|
-
], ((_b = collection === null || collection === void 0 ? void 0 : collection.hooks) === null || _b === void 0 ? void 0 : _b.afterChange) || [], true) }), fields: fields });
|
|
90
|
-
}
|
|
91
|
-
return collection;
|
|
92
|
-
}) })); }; };
|
|
90
|
+
return collection;
|
|
91
|
+
}) })); };
|
|
92
|
+
};
|
|
93
93
|
exports.default = nestedDocs;
|
|
94
94
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,qEAAyD;AACzD,2DAA+C;AAC/C,0EAAmD;AACnD,wFAAiE;AAEjE,wFAAiE;AAEjE,IAAM,UAAU,GACd,UAAC,YAA0B;IAC3B,OAAA,UAAC,MAAc,IAAa,OAAA,uBACvB,MAAM,KACT,WAAW,EAAE,CAAC,MAAM,CAAC,WAAW,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,UAAA,UAAU;;YACpD,IAAI,YAAY,CAAC,WAAW,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE;gBAC1D,IAAM,MAAM,qBAAO,CAAC,CAAA,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,MAAM,KAAI,EAAE,CAAC,OAAC,CAAA;gBAE9C,IAAI,CAAC,YAAY,CAAC,eAAe,EAAE;oBACjC,MAAM,CAAC,IAAI,CAAC,IAAA,gBAAiB,EAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAA;iBAChD;gBAED,IAAI,CAAC,YAAY,CAAC,oBAAoB,EAAE;oBACtC,MAAM,CAAC,IAAI,CAAC,IAAA,qBAAsB,EAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAA;iBACrD;gBAED,6BACK,UAAU,KACb,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,EAnC0B,CAmC1B;AAnCF,CAmCE,CAAA;AAEJ,kBAAe,UAAU,CAAA"}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
export
|
|
1
|
+
export interface Breadcrumb {
|
|
2
2
|
url?: string;
|
|
3
3
|
label: string;
|
|
4
4
|
doc: string;
|
|
5
|
-
}
|
|
6
|
-
export type GenerateURL = (docs: Record<string, unknown
|
|
7
|
-
export type GenerateLabel = (docs: Record<string, unknown
|
|
8
|
-
export
|
|
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
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CollectionConfig } from 'payload/types';
|
|
2
|
-
import {
|
|
3
|
-
declare const formatBreadcrumb: (
|
|
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 (
|
|
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 (
|
|
9
|
-
url =
|
|
8
|
+
if (typeof (pluginConfig === null || pluginConfig === void 0 ? void 0 : pluginConfig.generateURL) === 'function') {
|
|
9
|
+
url = pluginConfig.generateURL(docs, lastDoc);
|
|
10
10
|
}
|
|
11
|
-
if (typeof (
|
|
12
|
-
label =
|
|
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":";;
|
|
1
|
+
{"version":3,"file":"formatBreadcrumb.js","sourceRoot":"","sources":["../../src/utilities/formatBreadcrumb.ts"],"names":[],"mappings":";;AAIA,IAAM,gBAAgB,GAAG,UACvB,YAA0B,EAC1B,UAA4B,EAC5B,IAAoC;;IAEpC,IAAI,GAAG,GAAuB,SAAS,CAAA;IACvC,IAAI,KAAa,CAAA;IAEjB,IAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAA;IAErC,IAAI,OAAO,CAAA,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,WAAW,CAAA,KAAK,UAAU,EAAE;QACnD,GAAG,GAAG,YAAY,CAAC,WAAW,CAAC,IAAI,EAAE,OAAO,CAAC,CAAA;KAC9C;IAED,IAAI,OAAO,CAAA,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,aAAa,CAAA,KAAK,UAAU,EAAE;QACrD,KAAK,GAAG,YAAY,CAAC,aAAa,CAAC,IAAI,EAAE,OAAO,CAAC,CAAA;KAClD;SAAM;QACL,IAAM,UAAU,GAAG,CAAA,MAAA,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,KAAK,0CAAE,UAAU,KAAI,IAAI,CAAA;QACxD,KAAK,GAAG,OAAO,CAAC,UAAU,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 {
|
|
3
|
-
declare const getParents: (req: any,
|
|
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;
|
|
@@ -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,
|
|
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[(
|
|
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,
|
|
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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"getParents.js","sourceRoot":"","sources":["../../src/utilities/getParents.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,IAAM,UAAU,GAAG,UACjB,GAAQ,EACR,YAA0B,EAC1B,UAA4B,EAC5B,GAA4B,EAC5B,IAAyC;IAAzC,qBAAA,EAAA,SAAyC;;;;;;oBAEnC,MAAM,GAAG,GAAG,CAAC,CAAA,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,eAAe,KAAI,QAAQ,CAAC,CAAA;yBAGzD,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;;oBANF,eAAe,GAAG,SAMhB,CAAA;;;oBAGJ,oBAAoB;oBACpB,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE;wBAC9B,eAAe,GAAG,MAAM,CAAA;qBACzB;oBAED,IAAI,eAAe,EAAE;wBACnB,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 {
|
|
3
|
-
declare const populateBreadcrumbs: (req: 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;
|
|
@@ -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
|
|
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,
|
|
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) {
|
|
78
|
-
|
|
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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"populateBreadcrumbs.js","sourceRoot":"","sources":["../../src/utilities/populateBreadcrumbs.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,wEAAiD;AACjD,4DAAqC;AAErC,IAAM,mBAAmB,GAAG,UAC1B,GAAQ,EACR,YAA0B,EAC1B,UAA4B,EAC5B,IAAS,EACT,WAAiB;;;;;;gBAEX,OAAO,GAAG,IAAI,CAAA;;gBAEd,qBAAM,IAAA,oBAAU,EAAC,GAAG,EAAE,YAAY,EAAE,UAAU,wBAC7C,WAAW,GACX,IAAI,EACP,EAAA;;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
package/fields.js
ADDED
package/package.json
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payloadcms/plugin-nested-docs",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.6",
|
|
4
4
|
"homepage:": "https://payloadcms.com",
|
|
5
5
|
"repository": "git@github.com:payloadcms/plugin-nested-docs.git",
|
|
6
|
-
"description": "Nested documents plugin for Payload
|
|
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
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"
|
|
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');
|