@focus-reactive/payload-plugin-translator 0.11.4 → 0.11.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.
@@ -116,8 +116,11 @@ const asObject = (value)=>isObject(value) ? value : {};
116
116
  target: this.targetData,
117
117
  path: []
118
118
  }, walker);
119
+ // A detached copy, because write-back mutates an object-valued leaf (a rich-text tree) in
120
+ // place: seating the caller's own object here would translate their source document. Scalars
121
+ // are immutable, so they are seated as they are.
119
122
  for (const { dataRef, key, sourceValue } of selected){
120
- dataRef[key] = sourceValue;
123
+ dataRef[key] = isObject(sourceValue) ? structuredClone(sourceValue) : sourceValue;
121
124
  }
122
125
  return chunks;
123
126
  }
@@ -25,9 +25,12 @@ export declare class ProvenanceService {
25
25
  private readonly schemaMap;
26
26
  constructor(payload: Payload, store: ProvenanceStore, schemaMap: CollectionSchemaMap);
27
27
  /**
28
- * Hash the PRISTINE source. The caller MUST pass source fetched **before** the translation pipeline
29
- * runs — the pipeline mutates object-valued leaves (e.g. richText nodes) in place, so hashing after
30
- * it would capture the target translation and make every fresh translation look instantly stale.
28
+ * Hash the source the translation was made from the baseline staleness is later measured against.
29
+ *
30
+ * Ordering used to matter: the pipeline wrote into object-valued leaves it shared with the caller's
31
+ * source, so hashing afterwards captured the translation and reported every fresh translation as
32
+ * stale. It now detaches those leaves, so this may be called on either side of the pipeline.
33
+ *
31
34
  * Returns `null` on any failure (no schema, hashing error) so provenance is skipped, not the translation.
32
35
  */
33
36
  captureFingerprint(collection: CollectionSlug, sourceData: Record<string, unknown>): string | null;
@@ -19,9 +19,12 @@ import { fetchSourceDocument } from "../../shared/payload/sourceDocument";
19
19
  this.schemaMap = schemaMap;
20
20
  }
21
21
  /**
22
- * Hash the PRISTINE source. The caller MUST pass source fetched **before** the translation pipeline
23
- * runs — the pipeline mutates object-valued leaves (e.g. richText nodes) in place, so hashing after
24
- * it would capture the target translation and make every fresh translation look instantly stale.
22
+ * Hash the source the translation was made from the baseline staleness is later measured against.
23
+ *
24
+ * Ordering used to matter: the pipeline wrote into object-valued leaves it shared with the caller's
25
+ * source, so hashing afterwards captured the translation and reported every fresh translation as
26
+ * stale. It now detaches those leaves, so this may be called on either side of the pipeline.
27
+ *
25
28
  * Returns `null` on any failure (no schema, hashing error) so provenance is skipped, not the translation.
26
29
  */ captureFingerprint(collection, sourceData) {
27
30
  const schema = this.schemaMap.get(collection);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@focus-reactive/payload-plugin-translator",
3
- "version": "0.11.4",
3
+ "version": "0.11.5",
4
4
  "description": "Translation plugin for Payload CMS 3.x. Automatically translate your localized content using any translation provider.",
5
5
  "type": "module",
6
6
  "license": "MIT",