@klnap/cache-invalidation 0.0.0-stage → 0.1.0
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/CHANGELOG.md +145 -0
- package/LICENSE +21 -0
- package/README.md +176 -2
- package/dist/consumers/next/compile-tag-template.d.ts +16 -0
- package/dist/consumers/next/compile-tag-template.js +83 -0
- package/dist/consumers/next/consumer-types.d.ts +98 -0
- package/dist/consumers/next/consumer-types.js +3 -0
- package/dist/consumers/next/define-cache.d.ts +4 -0
- package/dist/consumers/next/define-cache.js +281 -0
- package/dist/consumers/next/host-types.d.ts +44 -0
- package/dist/consumers/next/host-types.js +3 -0
- package/dist/consumers/next/index.d.ts +5 -0
- package/dist/consumers/next/index.js +2 -0
- package/dist/consumers/next/param-values.d.ts +8 -0
- package/dist/consumers/next/param-values.js +23 -0
- package/dist/consumers/next/profile.d.ts +2 -0
- package/dist/consumers/next/profile.js +18 -0
- package/dist/consumers/next/registry-builders.d.ts +3 -0
- package/dist/consumers/next/registry-builders.js +155 -0
- package/dist/consumers/next/revalidation-handler.d.ts +6 -0
- package/dist/consumers/next/revalidation-handler.js +2 -0
- package/dist/consumers/next/runtime.d.ts +5 -0
- package/dist/consumers/next/runtime.js +560 -0
- package/dist/core/cloudevents.d.ts +27 -0
- package/dist/core/cloudevents.js +172 -0
- package/dist/core/dispatch-outcome.d.ts +4 -0
- package/dist/core/dispatch-outcome.js +17 -0
- package/dist/core/errors.d.ts +16 -0
- package/dist/core/errors.js +28 -0
- package/dist/core/event-limits.d.ts +15 -0
- package/dist/core/event-limits.js +20 -0
- package/dist/core/event-selector.d.ts +9 -0
- package/dist/core/event-selector.js +5 -0
- package/dist/core/index.d.ts +10 -0
- package/dist/core/index.js +6 -0
- package/dist/core/resource-changed-schema.d.ts +35 -0
- package/dist/core/resource-changed-schema.js +12 -0
- package/dist/core/standard-schema.d.ts +2 -0
- package/dist/core/standard-schema.js +7 -0
- package/dist/core/types.d.ts +35 -0
- package/dist/core/types.js +1 -0
- package/dist/core/url-segment.d.ts +2 -0
- package/dist/core/url-segment.js +17 -0
- package/dist/dispatchers/http/index.d.ts +20 -0
- package/dist/dispatchers/http/index.js +274 -0
- package/dist/dispatchers/http/targets.d.ts +14 -0
- package/dist/dispatchers/http/targets.js +26 -0
- package/dist/dispatchers/index.d.ts +1 -0
- package/dist/dispatchers/index.js +1 -0
- package/dist/producers/payload/exclude-fields.d.ts +19 -0
- package/dist/producers/payload/exclude-fields.js +75 -0
- package/dist/producers/payload/index.d.ts +4 -0
- package/dist/producers/payload/index.js +3 -0
- package/dist/producers/payload/lifecycle/deferred.d.ts +55 -0
- package/dist/producers/payload/lifecycle/deferred.js +111 -0
- package/dist/producers/payload/lifecycle/dispatch.d.ts +18 -0
- package/dist/producers/payload/lifecycle/dispatch.js +21 -0
- package/dist/producers/payload/lifecycle/doc-content.d.ts +8 -0
- package/dist/producers/payload/lifecycle/doc-content.js +88 -0
- package/dist/producers/payload/lifecycle/draft-status.d.ts +6 -0
- package/dist/producers/payload/lifecycle/draft-status.js +15 -0
- package/dist/producers/payload/lifecycle/helpers.d.ts +13 -0
- package/dist/producers/payload/lifecycle/helpers.js +12 -0
- package/dist/producers/payload/lifecycle/identifier-field.d.ts +8 -0
- package/dist/producers/payload/lifecycle/identifier-field.js +48 -0
- package/dist/producers/payload/lifecycle/identifiers.d.ts +4 -0
- package/dist/producers/payload/lifecycle/identifiers.js +5 -0
- package/dist/producers/payload/lifecycle/locale-published.d.ts +7 -0
- package/dist/producers/payload/lifecycle/locale-published.js +19 -0
- package/dist/producers/payload/lifecycle/locale.d.ts +24 -0
- package/dist/producers/payload/lifecycle/locale.js +44 -0
- package/dist/producers/payload/lifecycle/log.d.ts +31 -0
- package/dist/producers/payload/lifecycle/log.js +67 -0
- package/dist/producers/payload/lifecycle/media-equality.d.ts +4 -0
- package/dist/producers/payload/lifecycle/media-equality.js +36 -0
- package/dist/producers/payload/lifecycle/operation.d.ts +2 -0
- package/dist/producers/payload/lifecycle/operation.js +7 -0
- package/dist/producers/payload/lifecycle/orderable-hooks.d.ts +21 -0
- package/dist/producers/payload/lifecycle/orderable-hooks.js +26 -0
- package/dist/producers/payload/lifecycle/orderable-neighbors.d.ts +21 -0
- package/dist/producers/payload/lifecycle/orderable-neighbors.js +151 -0
- package/dist/producers/payload/lifecycle/public-snapshots.d.ts +16 -0
- package/dist/producers/payload/lifecycle/public-snapshots.js +173 -0
- package/dist/producers/payload/lifecycle/revalidate.d.ts +16 -0
- package/dist/producers/payload/lifecycle/revalidate.js +162 -0
- package/dist/producers/payload/lifecycle/skip-rules.d.ts +19 -0
- package/dist/producers/payload/lifecycle/skip-rules.js +57 -0
- package/dist/producers/payload/lifecycle/types.d.ts +32 -0
- package/dist/producers/payload/lifecycle/types.js +1 -0
- package/dist/producers/payload/media/media-references.d.ts +31 -0
- package/dist/producers/payload/media/media-references.js +127 -0
- package/dist/producers/payload/media/resolve-media-affected-locales.d.ts +22 -0
- package/dist/producers/payload/media/resolve-media-affected-locales.js +70 -0
- package/dist/producers/payload/media/resolve-media-dependents.d.ts +39 -0
- package/dist/producers/payload/media/resolve-media-dependents.js +157 -0
- package/dist/producers/payload/media/resolve-media-slug.d.ts +7 -0
- package/dist/producers/payload/media/resolve-media-slug.js +17 -0
- package/dist/producers/payload/media/revalidate-media-dependents.d.ts +14 -0
- package/dist/producers/payload/media/revalidate-media-dependents.js +222 -0
- package/dist/producers/payload/plugin.d.ts +36 -0
- package/dist/producers/payload/plugin.js +235 -0
- package/dist/producers/payload/publish-all/context.d.ts +2 -0
- package/dist/producers/payload/publish-all/context.js +2 -0
- package/dist/producers/payload/publish-all/edited-locale.d.ts +5 -0
- package/dist/producers/payload/publish-all/edited-locale.js +5 -0
- package/dist/producers/payload/publish-all/index.d.ts +3 -0
- package/dist/producers/payload/publish-all/index.js +3 -0
- package/dist/producers/payload/publish-all/localization.d.ts +7 -0
- package/dist/producers/payload/publish-all/localization.js +1 -0
- package/dist/producers/payload/publish-all/mirror-publish-all-locales-to-req.d.ts +19 -0
- package/dist/producers/payload/publish-all/mirror-publish-all-locales-to-req.js +32 -0
- package/dist/producers/payload/publish-all/preserve-locales-on-publish-all.d.ts +2 -0
- package/dist/producers/payload/publish-all/preserve-locales-on-publish-all.js +145 -0
- package/dist/producers/payload/publish-all/read-localized-scalar.d.ts +2 -0
- package/dist/producers/payload/publish-all/read-localized-scalar.js +24 -0
- package/dist/producers/payload/publish-all/request-flags.d.ts +13 -0
- package/dist/producers/payload/publish-all/request-flags.js +9 -0
- package/dist/producers/payload/publish-all/restore-guard.d.ts +2 -0
- package/dist/producers/payload/publish-all/restore-guard.js +12 -0
- package/dist/producers/payload/publish-all/restore-locales-after-publish-all.d.ts +2 -0
- package/dist/producers/payload/publish-all/restore-locales-after-publish-all.js +85 -0
- package/dist/producers/payload/revalidation-custom.d.ts +37 -0
- package/dist/producers/payload/revalidation-custom.js +54 -0
- package/dist/producers/payload/schema.d.ts +3 -0
- package/dist/producers/payload/schema.js +23 -0
- package/docs/concepts/architecture.md +32 -0
- package/docs/concepts/cache-tags.md +97 -0
- package/docs/concepts/event-contract.md +38 -0
- package/docs/consumers/custom.md +19 -0
- package/docs/consumers/next.md +277 -0
- package/docs/dispatchers/custom.md +38 -0
- package/docs/dispatchers/http.md +66 -0
- package/docs/extending.md +26 -0
- package/docs/migration/0.3.0-to-0.4.0.md +67 -0
- package/docs/migration/0.4.0-to-0.5.0.md +60 -0
- package/docs/migration/0.5.x-to-0.0.0.md +143 -0
- package/docs/producers/custom.md +63 -0
- package/docs/producers/payload-media-dependencies.md +45 -0
- package/docs/producers/payload.md +140 -0
- package/docs/reliability.md +35 -0
- package/docs/security.md +34 -0
- package/docs/troubleshooting.md +14 -0
- package/package.json +120 -4
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { readCacheInvalidationCustom, } from '../revalidation-custom.js';
|
|
2
|
+
/**
|
|
3
|
+
* Walks fields and collects upload/relationship fields that point only at `mediaSlug`.
|
|
4
|
+
* Rows, collapsibles, tabs and named groups are transparent; arrays add a path segment.
|
|
5
|
+
* Blocks and polymorphic relationships are not followed.
|
|
6
|
+
*/
|
|
7
|
+
const collectMediaFields = (fields, mediaSlug, prefix = [], throughArray = false) => {
|
|
8
|
+
const found = [];
|
|
9
|
+
for (const field of fields) {
|
|
10
|
+
const name = 'name' in field && typeof field.name === 'string' ? field.name : undefined;
|
|
11
|
+
switch (field.type) {
|
|
12
|
+
case 'row':
|
|
13
|
+
case 'collapsible':
|
|
14
|
+
found.push(...collectMediaFields(field.fields, mediaSlug, prefix, throughArray));
|
|
15
|
+
break;
|
|
16
|
+
case 'tabs':
|
|
17
|
+
for (const tab of field.tabs) {
|
|
18
|
+
const tabName = 'name' in tab && typeof tab.name === 'string' ? tab.name : undefined;
|
|
19
|
+
found.push(...collectMediaFields(tab.fields, mediaSlug, tabName ? [...prefix, tabName] : prefix, throughArray));
|
|
20
|
+
}
|
|
21
|
+
break;
|
|
22
|
+
case 'group':
|
|
23
|
+
found.push(...collectMediaFields(field.fields, mediaSlug, name ? [...prefix, name] : prefix, throughArray));
|
|
24
|
+
break;
|
|
25
|
+
case 'array':
|
|
26
|
+
if (name) {
|
|
27
|
+
found.push(...collectMediaFields(field.fields, mediaSlug, [...prefix, name], true));
|
|
28
|
+
}
|
|
29
|
+
break;
|
|
30
|
+
case 'upload':
|
|
31
|
+
case 'relationship':
|
|
32
|
+
if (name && field.relationTo === mediaSlug) {
|
|
33
|
+
found.push({
|
|
34
|
+
path: [...prefix, name],
|
|
35
|
+
hasMany: 'hasMany' in field && field.hasMany === true,
|
|
36
|
+
throughArray,
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
break;
|
|
40
|
+
default:
|
|
41
|
+
break;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return found;
|
|
45
|
+
};
|
|
46
|
+
const configCache = new WeakMap();
|
|
47
|
+
/**
|
|
48
|
+
* Finds the collections and globals that reference `mediaSlug` through upload fields.
|
|
49
|
+
* Only entities that opted in with `custom.cacheInvalidation` are included. Derived from the
|
|
50
|
+
* sanitized Payload config, so no registry has to be maintained by hand.
|
|
51
|
+
*/
|
|
52
|
+
export const discoverMediaReferences = (config, mediaSlug, options = {}) => {
|
|
53
|
+
const enabledCollections = Object.keys(options.collections ?? {})
|
|
54
|
+
.sort()
|
|
55
|
+
.join(',');
|
|
56
|
+
const enabledGlobals = Object.keys(options.globals ?? {})
|
|
57
|
+
.sort()
|
|
58
|
+
.join(',');
|
|
59
|
+
const cacheKey = `${mediaSlug}\u0000${enabledCollections}\u0000${enabledGlobals}`;
|
|
60
|
+
const cached = configCache.get(config)?.get(cacheKey);
|
|
61
|
+
if (cached)
|
|
62
|
+
return cached;
|
|
63
|
+
const refs = [];
|
|
64
|
+
for (const collection of config.collections) {
|
|
65
|
+
const centrallyResolved = options.collections?.[collection.slug];
|
|
66
|
+
const local = readCacheInvalidationCustom(collection.custom);
|
|
67
|
+
const centrallyDisabled = centrallyResolved !== undefined &&
|
|
68
|
+
centrallyResolved !== true &&
|
|
69
|
+
centrallyResolved.enabled === false;
|
|
70
|
+
const localDisabled = local === false || (local !== undefined && local !== true && local.enabled === false);
|
|
71
|
+
if (collection.slug === mediaSlug ||
|
|
72
|
+
(centrallyResolved === undefined && !local) ||
|
|
73
|
+
centrallyDisabled ||
|
|
74
|
+
localDisabled)
|
|
75
|
+
continue;
|
|
76
|
+
const hasDrafts = Boolean(collection.versions?.drafts);
|
|
77
|
+
for (const hit of collectMediaFields(collection.fields, mediaSlug)) {
|
|
78
|
+
refs.push({
|
|
79
|
+
type: 'collection',
|
|
80
|
+
slug: collection.slug,
|
|
81
|
+
wherePath: hit.path.join('.'),
|
|
82
|
+
hasDrafts,
|
|
83
|
+
...(hit.hasMany ? { hasMany: true } : {}),
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
for (const global of config.globals) {
|
|
88
|
+
const centrallyResolved = options.globals?.[global.slug];
|
|
89
|
+
const local = readCacheInvalidationCustom(global.custom);
|
|
90
|
+
const centrallyDisabled = centrallyResolved !== undefined &&
|
|
91
|
+
centrallyResolved !== true &&
|
|
92
|
+
centrallyResolved.enabled === false;
|
|
93
|
+
const localDisabled = local === false || (local !== undefined && local !== true && local.enabled === false);
|
|
94
|
+
if ((centrallyResolved === undefined && !local) || centrallyDisabled || localDisabled)
|
|
95
|
+
continue;
|
|
96
|
+
// Values inside arrays cannot be addressed by a plain path, so globals skip them.
|
|
97
|
+
for (const hit of collectMediaFields(global.fields, mediaSlug)) {
|
|
98
|
+
if (hit.throughArray || hit.hasMany)
|
|
99
|
+
continue;
|
|
100
|
+
refs.push({ type: 'global', slug: global.slug, path: hit.path });
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
const perConfig = configCache.get(config) ?? new Map();
|
|
104
|
+
perConfig.set(cacheKey, refs);
|
|
105
|
+
configCache.set(config, perConfig);
|
|
106
|
+
return refs;
|
|
107
|
+
};
|
|
108
|
+
export const resolveMediaId = (value) => {
|
|
109
|
+
if (typeof value === 'number' || typeof value === 'string')
|
|
110
|
+
return value;
|
|
111
|
+
if (value && typeof value === 'object' && 'id' in value) {
|
|
112
|
+
const id = value.id;
|
|
113
|
+
if (typeof id === 'number' || typeof id === 'string')
|
|
114
|
+
return id;
|
|
115
|
+
}
|
|
116
|
+
return null;
|
|
117
|
+
};
|
|
118
|
+
export const getAtPath = (doc, path) => {
|
|
119
|
+
let current = doc;
|
|
120
|
+
for (const key of path) {
|
|
121
|
+
if (!current || typeof current !== 'object')
|
|
122
|
+
return undefined;
|
|
123
|
+
current = current[key];
|
|
124
|
+
}
|
|
125
|
+
return current;
|
|
126
|
+
};
|
|
127
|
+
export const mediaIdsEqual = (a, b) => String(a) === String(b);
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { PayloadRequest } from 'payload';
|
|
2
|
+
import type { ResolveExcludeFieldsInput } from '../exclude-fields.js';
|
|
3
|
+
type ResolveArgs = {
|
|
4
|
+
doc: Record<string, unknown>;
|
|
5
|
+
previousDoc?: Record<string, unknown>;
|
|
6
|
+
req: PayloadRequest;
|
|
7
|
+
mediaId: number | string;
|
|
8
|
+
mediaCollectionSlug: string;
|
|
9
|
+
mediaSchemaCustom?: unknown;
|
|
10
|
+
pluginExcludeFields?: readonly string[];
|
|
11
|
+
pluginCollectionExcludeFields?: ResolveExcludeFieldsInput['pluginCollectionExcludeFields'];
|
|
12
|
+
mediaPluginExcludeFields?: readonly string[];
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Which locales need parent revalidation after a media update.
|
|
16
|
+
*
|
|
17
|
+
* - Shared fields changed (file/url/focal) → all locales
|
|
18
|
+
* - Only localized fields (alt) → locales where media content actually changed
|
|
19
|
+
* - No change → empty (caller skips POST)
|
|
20
|
+
*/
|
|
21
|
+
export declare const resolveMediaAffectedLocales: ({ doc, previousDoc, req, mediaId, mediaCollectionSlug, mediaSchemaCustom, pluginExcludeFields, pluginCollectionExcludeFields, mediaPluginExcludeFields, }: ResolveArgs) => Promise<string[]>;
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { resolveExcludeFields } from '../exclude-fields.js';
|
|
2
|
+
import { docsContentEqual, getRequestLocale, listLocales, MEDIA_LOCALIZED_KEYS, mediaSharedFieldsEqual, resolveChangedLocales, toTypedLocale, } from '../lifecycle/helpers.js';
|
|
3
|
+
const buildExcludeOptions = ({ mediaSchemaCustom, mediaCollectionSlug, pluginExcludeFields, pluginCollectionExcludeFields, mediaPluginExcludeFields, }) => ({
|
|
4
|
+
isMediaDependent: true,
|
|
5
|
+
mediaSchemaCustom,
|
|
6
|
+
collectionSlug: mediaCollectionSlug,
|
|
7
|
+
pluginExcludeFields,
|
|
8
|
+
pluginCollectionExcludeFields,
|
|
9
|
+
mediaPluginExcludeFields,
|
|
10
|
+
});
|
|
11
|
+
/**
|
|
12
|
+
* Which locales need parent revalidation after a media update.
|
|
13
|
+
*
|
|
14
|
+
* - Shared fields changed (file/url/focal) → all locales
|
|
15
|
+
* - Only localized fields (alt) → locales where media content actually changed
|
|
16
|
+
* - No change → empty (caller skips POST)
|
|
17
|
+
*/
|
|
18
|
+
export const resolveMediaAffectedLocales = async ({ doc, previousDoc, req, mediaId, mediaCollectionSlug, mediaSchemaCustom, pluginExcludeFields, pluginCollectionExcludeFields, mediaPluginExcludeFields, }) => {
|
|
19
|
+
const excludeFields = resolveExcludeFields(buildExcludeOptions({
|
|
20
|
+
mediaSchemaCustom,
|
|
21
|
+
mediaCollectionSlug,
|
|
22
|
+
pluginExcludeFields,
|
|
23
|
+
pluginCollectionExcludeFields,
|
|
24
|
+
mediaPluginExcludeFields,
|
|
25
|
+
}));
|
|
26
|
+
const contentOptions = { excludeFields };
|
|
27
|
+
const sharedExclude = [...new Set([...excludeFields, ...MEDIA_LOCALIZED_KEYS])];
|
|
28
|
+
const sharedOptions = { excludeFields: sharedExclude };
|
|
29
|
+
const locales = listLocales(req);
|
|
30
|
+
const editedLocale = getRequestLocale(req);
|
|
31
|
+
const candidates = resolveChangedLocales({
|
|
32
|
+
args: {
|
|
33
|
+
operation: 'update',
|
|
34
|
+
req,
|
|
35
|
+
doc,
|
|
36
|
+
previousDoc,
|
|
37
|
+
collection: { slug: 'media' },
|
|
38
|
+
},
|
|
39
|
+
locales,
|
|
40
|
+
});
|
|
41
|
+
if (!candidates.length)
|
|
42
|
+
return [];
|
|
43
|
+
if (previousDoc && !mediaSharedFieldsEqual(doc, previousDoc, sharedOptions)) {
|
|
44
|
+
return locales;
|
|
45
|
+
}
|
|
46
|
+
if (previousDoc &&
|
|
47
|
+
candidates.length === 1 &&
|
|
48
|
+
docsContentEqual(doc, previousDoc, contentOptions)) {
|
|
49
|
+
return [];
|
|
50
|
+
}
|
|
51
|
+
const affected = [];
|
|
52
|
+
for (const locale of candidates) {
|
|
53
|
+
const current = editedLocale === locale
|
|
54
|
+
? doc
|
|
55
|
+
: (await req.payload.findByID({
|
|
56
|
+
collection: 'media',
|
|
57
|
+
id: mediaId,
|
|
58
|
+
locale: toTypedLocale(locale),
|
|
59
|
+
fallbackLocale: false,
|
|
60
|
+
depth: 0,
|
|
61
|
+
overrideAccess: true,
|
|
62
|
+
}));
|
|
63
|
+
const previous = editedLocale === locale && previousDoc ? previousDoc : undefined;
|
|
64
|
+
if (previous && docsContentEqual(current, previous, contentOptions)) {
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
affected.push(locale);
|
|
68
|
+
}
|
|
69
|
+
return affected;
|
|
70
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { Payload, PayloadRequest } from 'payload';
|
|
2
|
+
import { type RevalidationChange } from '../lifecycle/helpers.js';
|
|
3
|
+
import { type CollectionMediaRef } from './media-references.js';
|
|
4
|
+
type ResolveArgs = {
|
|
5
|
+
mediaId: number | string;
|
|
6
|
+
mediaSlug: string;
|
|
7
|
+
payload: Payload;
|
|
8
|
+
req: PayloadRequest;
|
|
9
|
+
locales: string[];
|
|
10
|
+
operation?: RevalidationChange['operation'];
|
|
11
|
+
revalidationOptions?: {
|
|
12
|
+
collections?: Readonly<Record<string, true | import('../revalidation-custom.js').PayloadCacheInvalidationOptions>>;
|
|
13
|
+
globals?: Readonly<Record<string, true | import('../revalidation-custom.js').PayloadCacheInvalidationOptions>>;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
export type MediaDependencyFailure = {
|
|
17
|
+
refSlug: string;
|
|
18
|
+
locale?: string;
|
|
19
|
+
error: unknown;
|
|
20
|
+
};
|
|
21
|
+
export type MediaDependencyResolution = {
|
|
22
|
+
complete: boolean;
|
|
23
|
+
changes: RevalidationChange[];
|
|
24
|
+
failures: MediaDependencyFailure[];
|
|
25
|
+
};
|
|
26
|
+
export declare const resolveCollectionDependents: ({ ref, mediaId, payload, req, locales, operation, }: {
|
|
27
|
+
ref: CollectionMediaRef;
|
|
28
|
+
mediaId: number | string;
|
|
29
|
+
payload: Payload;
|
|
30
|
+
req: PayloadRequest;
|
|
31
|
+
locales: string[];
|
|
32
|
+
operation: RevalidationChange['operation'];
|
|
33
|
+
}) => Promise<MediaDependencyResolution>;
|
|
34
|
+
/**
|
|
35
|
+
* Find all published parents that reference `mediaId` and build
|
|
36
|
+
* RevalidationChange entries shaped like a parent update/delete.
|
|
37
|
+
*/
|
|
38
|
+
export declare const resolveMediaDependentChanges: ({ mediaId, mediaSlug, payload, req, locales, operation, revalidationOptions, }: ResolveArgs) => Promise<MediaDependencyResolution>;
|
|
39
|
+
export {};
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { hasLocaleData, readCollectionIdentity, toTypedLocale, } from '../lifecycle/helpers.js';
|
|
2
|
+
import { discoverMediaReferences, getAtPath, mediaIdsEqual, resolveMediaId, } from './media-references.js';
|
|
3
|
+
const DEPENDENT_PAGE_SIZE = 500;
|
|
4
|
+
const changeKey = (change) => {
|
|
5
|
+
const id = change.doc.id;
|
|
6
|
+
const documentId = typeof id === 'string' || typeof id === 'number' ? String(id) : '';
|
|
7
|
+
return `${change.type}:${change.slug}:${change.locale}:${documentId}`;
|
|
8
|
+
};
|
|
9
|
+
const mediaIdWhere = (ref, mediaId) => {
|
|
10
|
+
const leaf = ref.hasMany ? { in: [mediaId] } : { equals: mediaId };
|
|
11
|
+
return { [ref.wherePath]: leaf };
|
|
12
|
+
};
|
|
13
|
+
export const resolveCollectionDependents = async ({ ref, mediaId, payload, req, locales, operation, }) => {
|
|
14
|
+
const changes = [];
|
|
15
|
+
const failures = [];
|
|
16
|
+
for (const locale of locales) {
|
|
17
|
+
try {
|
|
18
|
+
// Every page is read: a fixed page cap would silently drop dependents from invalidation.
|
|
19
|
+
let cursor;
|
|
20
|
+
for (;;) {
|
|
21
|
+
const dependencyWhere = mediaIdWhere(ref, mediaId);
|
|
22
|
+
const result = await payload.find({
|
|
23
|
+
collection: ref.slug,
|
|
24
|
+
where: cursor === undefined
|
|
25
|
+
? dependencyWhere
|
|
26
|
+
: { and: [dependencyWhere, { id: { greater_than: cursor } }] },
|
|
27
|
+
locale: toTypedLocale(locale),
|
|
28
|
+
fallbackLocale: false,
|
|
29
|
+
depth: 0,
|
|
30
|
+
draft: false,
|
|
31
|
+
overrideAccess: true,
|
|
32
|
+
limit: DEPENDENT_PAGE_SIZE,
|
|
33
|
+
page: 1,
|
|
34
|
+
pagination: true,
|
|
35
|
+
sort: 'id',
|
|
36
|
+
req,
|
|
37
|
+
});
|
|
38
|
+
for (const doc of result.docs) {
|
|
39
|
+
const localeDoc = doc;
|
|
40
|
+
if (!hasLocaleData(localeDoc))
|
|
41
|
+
continue;
|
|
42
|
+
const status = localeDoc._status;
|
|
43
|
+
const localeStatus = status && typeof status === 'object'
|
|
44
|
+
? status[locale]
|
|
45
|
+
: status;
|
|
46
|
+
if (ref.hasDrafts && operation !== 'delete' && localeStatus !== 'published')
|
|
47
|
+
continue;
|
|
48
|
+
const identity = readCollectionIdentity(localeDoc);
|
|
49
|
+
changes.push({
|
|
50
|
+
type: 'collection',
|
|
51
|
+
slug: ref.slug,
|
|
52
|
+
operation,
|
|
53
|
+
locale,
|
|
54
|
+
doc: localeDoc,
|
|
55
|
+
...(identity.routeSlug !== undefined ? { routeSlug: identity.routeSlug } : {}),
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
if (!result.hasNextPage)
|
|
59
|
+
break;
|
|
60
|
+
const lastId = result.docs.at(-1)?.id;
|
|
61
|
+
if ((typeof lastId !== 'string' && typeof lastId !== 'number') ||
|
|
62
|
+
(cursor !== undefined && (typeof lastId !== typeof cursor || lastId <= cursor))) {
|
|
63
|
+
throw new Error(`Payload dependency pagination did not advance for ${ref.slug}`);
|
|
64
|
+
}
|
|
65
|
+
cursor = lastId;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
catch (error) {
|
|
69
|
+
failures.push({ refSlug: ref.slug, locale, error });
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return { complete: failures.length === 0, changes, failures };
|
|
73
|
+
};
|
|
74
|
+
const resolveGlobalDependents = async ({ ref, mediaId, payload, req, locales, operation, }) => {
|
|
75
|
+
const changes = [];
|
|
76
|
+
const failures = [];
|
|
77
|
+
for (const locale of locales) {
|
|
78
|
+
try {
|
|
79
|
+
const globalDoc = (await payload.findGlobal({
|
|
80
|
+
slug: ref.slug,
|
|
81
|
+
locale: toTypedLocale(locale),
|
|
82
|
+
fallbackLocale: false,
|
|
83
|
+
depth: 0,
|
|
84
|
+
draft: false,
|
|
85
|
+
overrideAccess: true,
|
|
86
|
+
req,
|
|
87
|
+
}));
|
|
88
|
+
const fieldValue = getAtPath(globalDoc, ref.path);
|
|
89
|
+
const fieldMediaId = resolveMediaId(fieldValue);
|
|
90
|
+
if (fieldMediaId === null || !mediaIdsEqual(fieldMediaId, mediaId)) {
|
|
91
|
+
continue;
|
|
92
|
+
}
|
|
93
|
+
if (!hasLocaleData(globalDoc))
|
|
94
|
+
continue;
|
|
95
|
+
changes.push({
|
|
96
|
+
type: 'global',
|
|
97
|
+
slug: ref.slug,
|
|
98
|
+
operation,
|
|
99
|
+
locale,
|
|
100
|
+
doc: globalDoc,
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
catch (error) {
|
|
104
|
+
failures.push({ refSlug: ref.slug, locale, error });
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
return { complete: failures.length === 0, changes, failures };
|
|
108
|
+
};
|
|
109
|
+
/**
|
|
110
|
+
* Find all published parents that reference `mediaId` and build
|
|
111
|
+
* RevalidationChange entries shaped like a parent update/delete.
|
|
112
|
+
*/
|
|
113
|
+
export const resolveMediaDependentChanges = async ({ mediaId, mediaSlug, payload, req, locales, operation = 'update', revalidationOptions, }) => {
|
|
114
|
+
if (!locales.length)
|
|
115
|
+
return { complete: true, changes: [], failures: [] };
|
|
116
|
+
const refs = discoverMediaReferences(payload.config, mediaSlug, revalidationOptions);
|
|
117
|
+
const settledBatches = await Promise.allSettled(refs.map((ref) => {
|
|
118
|
+
if (ref.type === 'collection') {
|
|
119
|
+
return resolveCollectionDependents({
|
|
120
|
+
ref,
|
|
121
|
+
mediaId,
|
|
122
|
+
payload,
|
|
123
|
+
req,
|
|
124
|
+
locales,
|
|
125
|
+
operation,
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
return resolveGlobalDependents({
|
|
129
|
+
ref,
|
|
130
|
+
mediaId,
|
|
131
|
+
payload,
|
|
132
|
+
req,
|
|
133
|
+
locales,
|
|
134
|
+
operation,
|
|
135
|
+
});
|
|
136
|
+
}));
|
|
137
|
+
const seen = new Set();
|
|
138
|
+
const changes = [];
|
|
139
|
+
const failures = [];
|
|
140
|
+
for (const [index, result] of settledBatches.entries()) {
|
|
141
|
+
if (result.status === 'rejected') {
|
|
142
|
+
const ref = refs[index];
|
|
143
|
+
failures.push({ refSlug: ref?.slug ?? mediaSlug, error: result.reason });
|
|
144
|
+
continue;
|
|
145
|
+
}
|
|
146
|
+
const batch = result.value;
|
|
147
|
+
failures.push(...batch.failures);
|
|
148
|
+
for (const change of batch.changes) {
|
|
149
|
+
const key = changeKey(change);
|
|
150
|
+
if (seen.has(key))
|
|
151
|
+
continue;
|
|
152
|
+
seen.add(key);
|
|
153
|
+
changes.push(change);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
return { complete: failures.length === 0, changes, failures };
|
|
157
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { CollectionConfig, Config } from 'payload';
|
|
2
|
+
export declare function collectionHasUpload(collection: CollectionConfig): boolean;
|
|
3
|
+
/**
|
|
4
|
+
* Upload collection for media-dependent revalidation hooks.
|
|
5
|
+
* Explicit `media` → its slug; else sole upload collection; else slug `media`.
|
|
6
|
+
*/
|
|
7
|
+
export declare function resolveMediaSlug(incoming: Pick<Config, 'collections'>, media?: CollectionConfig): string | undefined;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export function collectionHasUpload(collection) {
|
|
2
|
+
const upload = collection.upload;
|
|
3
|
+
return upload === true || (typeof upload === 'object' && upload !== null);
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Upload collection for media-dependent revalidation hooks.
|
|
7
|
+
* Explicit `media` → its slug; else sole upload collection; else slug `media`.
|
|
8
|
+
*/
|
|
9
|
+
export function resolveMediaSlug(incoming, media) {
|
|
10
|
+
if (media?.slug)
|
|
11
|
+
return media.slug;
|
|
12
|
+
const uploads = (incoming.collections ?? []).filter(collectionHasUpload);
|
|
13
|
+
if (uploads.length === 1)
|
|
14
|
+
return uploads[0]?.slug;
|
|
15
|
+
const named = uploads.find((c) => c.slug === 'media');
|
|
16
|
+
return named?.slug;
|
|
17
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { CollectionAfterChangeHook, CollectionBeforeDeleteHook } from 'payload';
|
|
2
|
+
import type { Dispatcher } from '../../../core/index.js';
|
|
3
|
+
import { type PayloadCacheInvalidationOptions } from '../revalidation-custom.js';
|
|
4
|
+
type MediaOptions = {
|
|
5
|
+
source: string;
|
|
6
|
+
pluginExcludeFields?: readonly string[];
|
|
7
|
+
pluginCollectionExcludeFields?: Readonly<Record<string, readonly string[]>>;
|
|
8
|
+
mediaPluginExcludeFields?: readonly string[];
|
|
9
|
+
collections?: Readonly<Record<string, true | PayloadCacheInvalidationOptions>>;
|
|
10
|
+
globals?: Readonly<Record<string, true | PayloadCacheInvalidationOptions>>;
|
|
11
|
+
};
|
|
12
|
+
export declare const createRevalidateMediaDependentsAfterChange: (dispatcher: Dispatcher, options: MediaOptions) => CollectionAfterChangeHook;
|
|
13
|
+
export declare const createRevalidateMediaDependentsBeforeDelete: (dispatcher: Dispatcher, source: string, options?: MediaOptions) => CollectionBeforeDeleteHook;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
import { clearPublicBefore, dispatchRevalidationChanges, isDraftSave, listLocales, logRevalidateDispatch, mediaSubject, projectPayloadSnapshot, readPublishedRepresentation, revalidationLog, revalidationLogError, takePublicBefore, toTypedLocale, } from '../lifecycle/helpers.js';
|
|
2
|
+
import { normalizeCollectionRevalidation, normalizeGlobalRevalidation, } from '../revalidation-custom.js';
|
|
3
|
+
import { resolveMediaAffectedLocales } from './resolve-media-affected-locales.js';
|
|
4
|
+
import { resolveMediaDependentChanges, } from './resolve-media-dependents.js';
|
|
5
|
+
const errorDetail = (error) => error instanceof Error ? error.message : String(error);
|
|
6
|
+
const logResolutionFailures = (logger, subject, failures) => {
|
|
7
|
+
for (const failure of failures) {
|
|
8
|
+
const locale = failure.locale ? ` · locale:${failure.locale}` : '';
|
|
9
|
+
revalidationLogError(logger, `media dependency resolution incomplete · ${failure.refSlug}${locale} · ${errorDetail(failure.error)}`, subject);
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
const projectedDependentSnapshot = async (req, type, slug, id, locale, snapshot, operation, options) => {
|
|
13
|
+
const raw = (type === 'collection' ? options.collections : options.globals)?.[slug] ?? true;
|
|
14
|
+
const effective = type === 'collection' ? normalizeCollectionRevalidation(raw) : normalizeGlobalRevalidation(raw);
|
|
15
|
+
const localized = Boolean(req.payload.config.localization);
|
|
16
|
+
return projectPayloadSnapshot({
|
|
17
|
+
...snapshot,
|
|
18
|
+
...(id === undefined ? { id: slug } : { id }),
|
|
19
|
+
...(localized ? { locale } : {}),
|
|
20
|
+
}, locale, operation, `${type}.${slug}`, localized, effective.projection);
|
|
21
|
+
};
|
|
22
|
+
const readPublicGlobalRepresentation = async (req, slug, locale) => {
|
|
23
|
+
const publicReq = Object.create(req);
|
|
24
|
+
Object.defineProperty(publicReq, 'user', { value: undefined, configurable: true });
|
|
25
|
+
const localization = req.payload.config.localization;
|
|
26
|
+
try {
|
|
27
|
+
const result = await req.payload.findGlobal({
|
|
28
|
+
slug,
|
|
29
|
+
locale: toTypedLocale(locale),
|
|
30
|
+
fallbackLocale: localization && localization.fallback ? toTypedLocale(localization.defaultLocale) : false,
|
|
31
|
+
depth: 0,
|
|
32
|
+
draft: false,
|
|
33
|
+
overrideAccess: false,
|
|
34
|
+
showHiddenFields: false,
|
|
35
|
+
req: publicReq,
|
|
36
|
+
user: undefined,
|
|
37
|
+
});
|
|
38
|
+
if (!result || typeof result !== 'object')
|
|
39
|
+
return null;
|
|
40
|
+
return result;
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
if (error && typeof error === 'object' && 'status' in error && error.status === 404)
|
|
44
|
+
return null;
|
|
45
|
+
throw error;
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
const safeDependents = async (req, changes, options) => {
|
|
49
|
+
const affected = [];
|
|
50
|
+
const failures = [];
|
|
51
|
+
for (const change of changes) {
|
|
52
|
+
const id = change.doc.id;
|
|
53
|
+
if (change.type === 'collection' && typeof id !== 'string' && typeof id !== 'number')
|
|
54
|
+
continue;
|
|
55
|
+
try {
|
|
56
|
+
const doc = change.type === 'collection'
|
|
57
|
+
? await readPublishedRepresentation(req, change.slug, id, change.locale)
|
|
58
|
+
: await readPublicGlobalRepresentation(req, change.slug, change.locale);
|
|
59
|
+
if (!doc)
|
|
60
|
+
continue;
|
|
61
|
+
const data = await projectedDependentSnapshot(req, change.type, change.slug, change.type === 'collection' ? id : undefined, change.locale, doc, 'update', options);
|
|
62
|
+
affected.push({
|
|
63
|
+
type: `payload.${change.type}.${change.slug}`,
|
|
64
|
+
locale: change.locale,
|
|
65
|
+
data,
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
catch (error) {
|
|
69
|
+
failures.push({ refSlug: change.slug, locale: change.locale, error });
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return { affected, failures };
|
|
73
|
+
};
|
|
74
|
+
const updateAfterChange = async (args, dispatcher, options) => {
|
|
75
|
+
const { doc, previousDoc, operation, req, collection } = args;
|
|
76
|
+
if (operation !== 'update')
|
|
77
|
+
return;
|
|
78
|
+
const mediaId = doc.id;
|
|
79
|
+
if (mediaId === undefined || mediaId === null)
|
|
80
|
+
return;
|
|
81
|
+
const subject = mediaSubject(mediaId);
|
|
82
|
+
if (isDraftSave(req)) {
|
|
83
|
+
revalidationLog.skip(req.payload.logger, subject, 'autosave');
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
const affectedLocales = await resolveMediaAffectedLocales({
|
|
87
|
+
doc: doc,
|
|
88
|
+
previousDoc: previousDoc,
|
|
89
|
+
req,
|
|
90
|
+
mediaId,
|
|
91
|
+
mediaCollectionSlug: collection.slug,
|
|
92
|
+
mediaSchemaCustom: collection.custom,
|
|
93
|
+
pluginExcludeFields: options.pluginExcludeFields,
|
|
94
|
+
pluginCollectionExcludeFields: options.pluginCollectionExcludeFields,
|
|
95
|
+
mediaPluginExcludeFields: options.mediaPluginExcludeFields,
|
|
96
|
+
});
|
|
97
|
+
if (!affectedLocales.length) {
|
|
98
|
+
revalidationLog.skip(req.payload.logger, subject, 'unchanged');
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
const resolution = await resolveMediaDependentChanges({
|
|
102
|
+
mediaId,
|
|
103
|
+
mediaSlug: collection.slug,
|
|
104
|
+
payload: req.payload,
|
|
105
|
+
req,
|
|
106
|
+
locales: affectedLocales,
|
|
107
|
+
operation: 'update',
|
|
108
|
+
revalidationOptions: options,
|
|
109
|
+
});
|
|
110
|
+
logResolutionFailures(req.payload.logger, subject, resolution.failures);
|
|
111
|
+
const safeResolution = await safeDependents(req, resolution.changes, options);
|
|
112
|
+
logResolutionFailures(req.payload.logger, subject, safeResolution.failures);
|
|
113
|
+
const dependents = safeResolution.affected;
|
|
114
|
+
const changes = [];
|
|
115
|
+
for (const locale of affectedLocales) {
|
|
116
|
+
const before = takePublicBefore(req, 'collection', collection.slug, mediaId, locale);
|
|
117
|
+
if (before === undefined)
|
|
118
|
+
throw new Error(`Public previous media state unavailable (${locale})`);
|
|
119
|
+
const after = await readPublishedRepresentation(req, collection.slug, mediaId, locale);
|
|
120
|
+
if (!before && !after)
|
|
121
|
+
continue;
|
|
122
|
+
const projectedBefore = before
|
|
123
|
+
? await projectedDependentSnapshot(req, 'collection', collection.slug, mediaId, locale, before, 'update', options)
|
|
124
|
+
: null;
|
|
125
|
+
const projectedAfter = after
|
|
126
|
+
? await projectedDependentSnapshot(req, 'collection', collection.slug, mediaId, locale, after, 'update', options)
|
|
127
|
+
: null;
|
|
128
|
+
const affected = dependents
|
|
129
|
+
.filter((entry) => entry.locale === locale)
|
|
130
|
+
.map(({ type, data }) => ({ type, data }));
|
|
131
|
+
changes.push({
|
|
132
|
+
type: 'collection',
|
|
133
|
+
slug: collection.slug,
|
|
134
|
+
operation,
|
|
135
|
+
locale,
|
|
136
|
+
doc: (projectedAfter ?? projectedBefore ?? {}),
|
|
137
|
+
before: projectedBefore,
|
|
138
|
+
after: projectedAfter,
|
|
139
|
+
...(affected.length ? { affected } : {}),
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
if (!changes.length) {
|
|
143
|
+
revalidationLog.skip(req.payload.logger, subject, 'no public representation');
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
logRevalidateDispatch(req.payload.logger, subject, affectedLocales);
|
|
147
|
+
await dispatchRevalidationChanges({
|
|
148
|
+
req,
|
|
149
|
+
changes,
|
|
150
|
+
source: options.source,
|
|
151
|
+
logger: req.payload.logger,
|
|
152
|
+
dispatcher,
|
|
153
|
+
});
|
|
154
|
+
};
|
|
155
|
+
export const createRevalidateMediaDependentsAfterChange = (dispatcher, options) => async (args) => {
|
|
156
|
+
try {
|
|
157
|
+
await updateAfterChange(args, dispatcher, options);
|
|
158
|
+
}
|
|
159
|
+
catch (error) {
|
|
160
|
+
revalidationLogError(args.req.payload.logger, errorDetail(error), 'build');
|
|
161
|
+
}
|
|
162
|
+
finally {
|
|
163
|
+
clearPublicBefore(args.req, 'collection', args.collection.slug, args.doc?.id, listLocales(args.req));
|
|
164
|
+
}
|
|
165
|
+
return args.doc;
|
|
166
|
+
};
|
|
167
|
+
export const createRevalidateMediaDependentsBeforeDelete = (dispatcher, source, options = { source }) => async ({ id, req, collection }) => {
|
|
168
|
+
const subject = mediaSubject(id);
|
|
169
|
+
try {
|
|
170
|
+
const locales = listLocales(req);
|
|
171
|
+
const resolution = await resolveMediaDependentChanges({
|
|
172
|
+
mediaId: id,
|
|
173
|
+
mediaSlug: collection.slug,
|
|
174
|
+
payload: req.payload,
|
|
175
|
+
req,
|
|
176
|
+
locales,
|
|
177
|
+
operation: 'update',
|
|
178
|
+
revalidationOptions: options,
|
|
179
|
+
});
|
|
180
|
+
logResolutionFailures(req.payload.logger, subject, resolution.failures);
|
|
181
|
+
const safeResolution = await safeDependents(req, resolution.changes, options);
|
|
182
|
+
logResolutionFailures(req.payload.logger, subject, safeResolution.failures);
|
|
183
|
+
const dependents = safeResolution.affected;
|
|
184
|
+
const changes = [];
|
|
185
|
+
for (const locale of locales) {
|
|
186
|
+
const before = takePublicBefore(req, 'collection', collection.slug, id, locale);
|
|
187
|
+
if (before === undefined)
|
|
188
|
+
throw new Error(`Public previous media state unavailable (${locale})`);
|
|
189
|
+
if (!before)
|
|
190
|
+
continue;
|
|
191
|
+
const projectedBefore = await projectedDependentSnapshot(req, 'collection', collection.slug, id, locale, before, 'delete', options);
|
|
192
|
+
changes.push({
|
|
193
|
+
type: 'collection',
|
|
194
|
+
slug: collection.slug,
|
|
195
|
+
operation: 'delete',
|
|
196
|
+
locale,
|
|
197
|
+
doc: projectedBefore,
|
|
198
|
+
before: projectedBefore,
|
|
199
|
+
after: null,
|
|
200
|
+
affected: dependents
|
|
201
|
+
.filter((entry) => entry.locale === locale)
|
|
202
|
+
.map(({ type, data }) => ({ type, data })),
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
if (!changes.length)
|
|
206
|
+
return;
|
|
207
|
+
logRevalidateDispatch(req.payload.logger, subject, locales);
|
|
208
|
+
await dispatchRevalidationChanges({
|
|
209
|
+
req,
|
|
210
|
+
changes,
|
|
211
|
+
source,
|
|
212
|
+
logger: req.payload.logger,
|
|
213
|
+
dispatcher,
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
catch (error) {
|
|
217
|
+
revalidationLogError(req.payload.logger, errorDetail(error), 'build');
|
|
218
|
+
}
|
|
219
|
+
finally {
|
|
220
|
+
clearPublicBefore(req, 'collection', collection.slug, id, listLocales(req));
|
|
221
|
+
}
|
|
222
|
+
};
|