@focus-reactive/payload-plugin-translator 0.9.0 → 0.9.2
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/dist/auto-translate-config.d.ts +2 -2
- package/dist/auto-translate-config.js +1 -1
- package/dist/client/entities/translation/model/autoTranslateSummary.js +1 -1
- package/dist/core/{auto-translate-config → domain/auto-translate}/getAutoTranslateConfig.js +1 -1
- package/dist/core/{auto-translate → domain/auto-translate}/hasSourceContentChanged.d.ts +1 -1
- package/dist/core/{auto-translate-config → domain/auto-translate}/index.d.ts +1 -0
- package/dist/core/{auto-translate-config → domain/auto-translate}/index.js +1 -0
- package/dist/core/{content-projection → domain/content-projection}/computeSourceFingerprint.d.ts +1 -1
- package/dist/core/{content-projection → domain/content-projection}/contentProjector.d.ts +1 -1
- package/dist/core/{content-projection → domain/content-projection}/contentProjector.js +2 -2
- package/dist/core/{content-projection → domain/content-projection}/translatableLeaf.d.ts +1 -1
- package/dist/core/{content-projection → domain/content-projection}/translatableLeaf.js +2 -2
- package/dist/core/index.d.ts +10 -10
- package/dist/core/index.js +5 -5
- package/dist/core/{field-traversal → kernel/field-traversal}/index.d.ts +1 -0
- package/dist/core/{field-traversal → kernel/field-traversal}/index.js +1 -0
- package/dist/core/kernel/field-traversal/projectFieldLike.d.ts +32 -0
- package/dist/core/kernel/field-traversal/projectFieldLike.js +60 -0
- package/dist/core/translation-pipeline/TranslationPipeline.d.ts +1 -1
- package/dist/core/translation-pipeline/stages/data-reconciler/DataReconciler.d.ts +1 -1
- package/dist/core/translation-pipeline/stages/data-reconciler/DataReconciler.js +3 -3
- package/dist/core/translation-pipeline/stages/field-collector/FieldChunkCollector.d.ts +1 -1
- package/dist/core/translation-pipeline/stages/field-collector/FieldChunkCollector.js +3 -3
- package/dist/core/translation-pipeline/stages/text-expander/RichTextExpander.js +1 -1
- package/dist/core/translation-pipeline/stages/translation/Translation.stage.d.ts +1 -1
- package/dist/core/translation-pipeline/strategies/Overwrite.strategy.js +1 -1
- package/dist/core/translation-pipeline/strategies/SkipExisting.strategy.js +3 -3
- package/dist/core/translation-pipeline/translateContent.d.ts +2 -2
- package/dist/core/translation-pipeline/types/FieldChunk.d.ts +1 -1
- package/dist/core/translation-pipeline/types/Pipeline.d.ts +1 -1
- package/dist/core/translation-pipeline/types/PipelineContext.d.ts +1 -1
- package/dist/core/translation-pipeline/types/TextChunk.d.ts +1 -1
- package/dist/field-config.d.ts +1 -1
- package/dist/field-config.js +1 -1
- package/dist/plugin.d.ts +1 -1
- package/dist/plugin.js +8 -9
- package/dist/server/features/translate-document/handler.d.ts +1 -1
- package/dist/server/features/translate-document/wireTranslateRunner.d.ts +1 -1
- package/dist/server/features/translate-field/model.d.ts +1 -1
- package/dist/server/features/translate-field/resolveFieldSubtree.d.ts +3 -3
- package/dist/server/features/translate-field/resolveFieldSubtree.js +1 -1
- package/dist/server/modules/auto-translate/AutoTranslate.policy.d.ts +1 -1
- package/dist/server/modules/auto-translate/AutoTranslate.wiring.js +1 -1
- package/dist/server/modules/auto-translate/AutoTranslateEnqueue.hook.js +2 -2
- package/dist/server/modules/auto-translate/index.js +1 -1
- package/dist/server/modules/index.d.ts +1 -1
- package/dist/server/modules/index.js +1 -1
- package/dist/server/modules/provenance/Provenance.service.d.ts +1 -1
- package/dist/server/modules/provenance/Provenance.service.js +2 -2
- package/dist/server/modules/provenance/Provenance.store.d.ts +1 -1
- package/dist/server/modules/provenance/index.js +1 -1
- package/dist/server/modules/translation-levels/PluginConfigBuilder.d.ts +1 -1
- package/dist/server/modules/translation-levels/types.d.ts +1 -1
- package/dist/server/shared/index.d.ts +5 -5
- package/dist/server/shared/index.js +3 -3
- package/dist/server/shared/utils/filterLocalizedFields.js +2 -2
- package/dist/server/shared/utils/getByPath.js +1 -1
- package/dist/server/shared/utils/index.d.ts +2 -2
- package/dist/server/shared/utils/index.js +2 -2
- package/dist/server/shared/utils/setByPath.js +1 -1
- package/dist/translation-providers/index.d.ts +1 -1
- package/dist/translation-providers/openai/OpenAITranslation.provider.d.ts +1 -1
- package/dist/translation-providers/openai/OpenAITranslation.provider.js +1 -1
- package/dist/types/CollectionSchemaMap.d.ts +7 -4
- package/dist/types/CollectionSchemaMap.js +4 -2
- package/package.json +1 -1
- package/dist/core/auto-translate/index.d.ts +0 -1
- package/dist/core/auto-translate/index.js +0 -3
- /package/dist/core/{auto-translate-config → domain/auto-translate}/getAutoTranslateConfig.d.ts +0 -0
- /package/dist/core/{auto-translate → domain/auto-translate}/hasSourceContentChanged.js +0 -0
- /package/dist/core/{auto-translate-config → domain/auto-translate}/types.d.ts +0 -0
- /package/dist/core/{auto-translate-config → domain/auto-translate}/types.js +0 -0
- /package/dist/core/{content-projection → domain/content-projection}/computeSourceFingerprint.js +0 -0
- /package/dist/core/{content-projection → domain/content-projection}/fingerprinter.d.ts +0 -0
- /package/dist/core/{content-projection → domain/content-projection}/fingerprinter.js +0 -0
- /package/dist/core/{content-projection → domain/content-projection}/idPath.d.ts +0 -0
- /package/dist/core/{content-projection → domain/content-projection}/idPath.js +0 -0
- /package/dist/core/{field-config → domain/field-config}/getFieldConfig.d.ts +0 -0
- /package/dist/core/{field-config → domain/field-config}/getFieldConfig.js +0 -0
- /package/dist/core/{field-config → domain/field-config}/index.d.ts +0 -0
- /package/dist/core/{field-config → domain/field-config}/index.js +0 -0
- /package/dist/core/{field-config → domain/field-config}/types.d.ts +0 -0
- /package/dist/core/{field-config → domain/field-config}/types.js +0 -0
- /package/dist/core/{provenance → domain/provenance}/ProvenanceStore.interface.d.ts +0 -0
- /package/dist/core/{provenance → domain/provenance}/ProvenanceStore.interface.js +0 -0
- /package/dist/core/{provenance → domain/provenance}/index.d.ts +0 -0
- /package/dist/core/{provenance → domain/provenance}/index.js +0 -0
- /package/dist/core/{provenance → domain/provenance}/staleness.d.ts +0 -0
- /package/dist/core/{provenance → domain/provenance}/staleness.js +0 -0
- /package/dist/core/{translation-providers → domain/translation-providers}/TranslationProvider.interface.d.ts +0 -0
- /package/dist/core/{translation-providers → domain/translation-providers}/TranslationProvider.interface.js +0 -0
- /package/dist/core/{translation-providers → domain/translation-providers}/index.d.ts +0 -0
- /package/dist/core/{translation-providers → domain/translation-providers}/index.js +0 -0
- /package/dist/core/{field-traversal → kernel/field-traversal}/findFieldByPath.d.ts +0 -0
- /package/dist/core/{field-traversal → kernel/field-traversal}/findFieldByPath.js +0 -0
- /package/dist/core/{field-traversal → kernel/field-traversal}/guards.d.ts +0 -0
- /package/dist/core/{field-traversal → kernel/field-traversal}/guards.js +0 -0
- /package/dist/core/{field-traversal → kernel/field-traversal}/kernel.d.ts +0 -0
- /package/dist/core/{field-traversal → kernel/field-traversal}/kernel.js +0 -0
- /package/dist/core/{field-traversal → kernel/field-traversal}/predicates.d.ts +0 -0
- /package/dist/core/{field-traversal → kernel/field-traversal}/predicates.js +0 -0
- /package/dist/core/{field-traversal → kernel/field-traversal}/types.d.ts +0 -0
- /package/dist/core/{field-traversal → kernel/field-traversal}/types.js +0 -0
- /package/dist/core/{field-traversal → kernel/field-traversal}/walkFields.d.ts +0 -0
- /package/dist/core/{field-traversal → kernel/field-traversal}/walkFields.js +0 -0
- /package/dist/core/{lexical → kernel/lexical}/collectTextNodes.d.ts +0 -0
- /package/dist/core/{lexical → kernel/lexical}/collectTextNodes.js +0 -0
- /package/dist/core/{lexical → kernel/lexical}/guards.d.ts +0 -0
- /package/dist/core/{lexical → kernel/lexical}/guards.js +0 -0
- /package/dist/core/{lexical → kernel/lexical}/index.d.ts +0 -0
- /package/dist/core/{lexical → kernel/lexical}/index.js +0 -0
- /package/dist/core/{lexical → kernel/lexical}/isEmptyRichText.d.ts +0 -0
- /package/dist/core/{lexical → kernel/lexical}/isEmptyRichText.js +0 -0
- /package/dist/core/{lexical → kernel/lexical}/traverseLexicalTree.d.ts +0 -0
- /package/dist/core/{lexical → kernel/lexical}/traverseLexicalTree.js +0 -0
- /package/dist/core/{lexical → kernel/lexical}/types.d.ts +0 -0
- /package/dist/core/{lexical → kernel/lexical}/types.js +0 -0
- /package/dist/core/{utils → kernel/utils}/index.d.ts +0 -0
- /package/dist/core/{utils → kernel/utils}/index.js +0 -0
- /package/dist/core/{utils → kernel/utils}/isEmpty.d.ts +0 -0
- /package/dist/core/{utils → kernel/utils}/isEmpty.js +0 -0
- /package/dist/core/{utils → kernel/utils}/isObject.d.ts +0 -0
- /package/dist/core/{utils → kernel/utils}/isObject.js +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { CollectionConfig } from "payload";
|
|
2
|
-
import type { AutoTranslateConfig } from "./core/auto-translate
|
|
2
|
+
import type { AutoTranslateConfig } from "./core/domain/auto-translate";
|
|
3
3
|
export type { AutoTranslateConfig };
|
|
4
|
-
export type { AutoTranslateStrategy } from "./core/auto-translate
|
|
4
|
+
export type { AutoTranslateStrategy } from "./core/domain/auto-translate";
|
|
5
5
|
/**
|
|
6
6
|
* Enable opt-in **auto-translate** for a collection: when a document's source-locale content changes
|
|
7
7
|
* (and is published), the plugin automatically queues translations into the configured target locales.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AUTO_TRANSLATE_CUSTOM_KEY } from "./core/auto-translate
|
|
1
|
+
import { AUTO_TRANSLATE_CUSTOM_KEY } from "./core/domain/auto-translate";
|
|
2
2
|
/**
|
|
3
3
|
* Enable opt-in **auto-translate** for a collection: when a document's source-locale content changes
|
|
4
4
|
* (and is published), the plugin automatically queues translations into the configured target locales.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getAutoTranslateConfig } from "../../../../core/auto-translate
|
|
1
|
+
import { getAutoTranslateConfig } from "../../../../core/domain/auto-translate";
|
|
2
2
|
/**
|
|
3
3
|
* Resolve a collection's auto-translate summary for the popup marker, or `null` when it should not
|
|
4
4
|
* render. Reads the opt-in from the collection's `custom` (propagated onto the registered collection at
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { FieldLike } from "
|
|
1
|
+
import type { FieldLike } from "../../kernel/field-traversal";
|
|
2
2
|
/**
|
|
3
3
|
* Whether a source-locale save actually changed translatable content — the auto-translate drift-gate,
|
|
4
4
|
* in one place. Compares the translatable-content fingerprint of the previous vs the current document
|
package/dist/core/{content-projection → domain/content-projection}/computeSourceFingerprint.d.ts
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { FieldLike } from "
|
|
1
|
+
import type { FieldLike } from "../../kernel/field-traversal";
|
|
2
2
|
/**
|
|
3
3
|
* The staleness baseline: a stable hash of a document's translatable content.
|
|
4
4
|
* `CURRENT = computeSourceFingerprint(sourceDoc, schema)` — the value provenance stores at translation
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* translation can never disagree on which content is translatable. Payload-free and read-only:
|
|
10
10
|
* it never mutates the document and never captures write handles.
|
|
11
11
|
*/
|
|
12
|
-
import type { FieldLike } from "
|
|
12
|
+
import type { FieldLike } from "../../kernel/field-traversal/types";
|
|
13
13
|
import type { IdPath } from "./idPath";
|
|
14
14
|
/** One translatable leaf of a document: WHERE it lives ({@link IdPath}) and WHAT text it holds. */
|
|
15
15
|
export interface ProjectionEntry {
|
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
* {@link leafSourceText}) as the translation pipeline's `FieldChunkCollector`, so projection and
|
|
9
9
|
* translation can never disagree on which content is translatable. Payload-free and read-only:
|
|
10
10
|
* it never mutates the document and never captures write handles.
|
|
11
|
-
*/ import { resolveBlockFields, walkFields } from "
|
|
12
|
-
import { isObject } from "
|
|
11
|
+
*/ import { resolveBlockFields, walkFields } from "../../kernel/field-traversal";
|
|
12
|
+
import { isObject } from "../../kernel/utils/isObject";
|
|
13
13
|
import { elementSegment, makeIdPath } from "./idPath";
|
|
14
14
|
import { isTranslatableLeaf, leafSourceText } from "./translatableLeaf";
|
|
15
15
|
/**
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* Payload-free (structural {@link FieldLike} + owned `Serialized*` views only) so it can move to
|
|
8
8
|
* `@repo/translator-core` unchanged.
|
|
9
9
|
*/
|
|
10
|
-
import type { FieldLike, LeafFieldLike } from "
|
|
10
|
+
import type { FieldLike, LeafFieldLike } from "../../kernel/field-traversal/types";
|
|
11
11
|
/**
|
|
12
12
|
* The leaf-SELECTION decision shared by projection and translation: a leaf is a translation target
|
|
13
13
|
* iff it is a translatable text type, localized, and not excluded via `custom.translateKit`.
|
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
* Payload-free (structural {@link FieldLike} + owned `Serialized*` views only) so it can move to
|
|
8
8
|
* `@repo/translator-core` unchanged.
|
|
9
9
|
*/ import { isFieldExcludedFromTranslation } from "../field-config";
|
|
10
|
-
import { collectSerializedLexicalTextNodes } from "
|
|
11
|
-
import { isSerializedLexicalRoot } from "
|
|
10
|
+
import { collectSerializedLexicalTextNodes } from "../../kernel/lexical/collectTextNodes";
|
|
11
|
+
import { isSerializedLexicalRoot } from "../../kernel/lexical/guards";
|
|
12
12
|
/** The field types this package translates (mirrors `isTranslatableField`, payload-free). */ const isTranslatableFieldType = (field)=>field.type === "text" || field.type === "textarea" || field.type === "richText";
|
|
13
13
|
/** Mirrors `isLocalizedField` structurally. */ const isLocalizedFieldLike = (field)=>field.localized === true;
|
|
14
14
|
/**
|
package/dist/core/index.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
export type { TranslationProvider, TranslationInput, TranslationOutput, TranslationIndex, } from "./translation-providers";
|
|
1
|
+
export type { TranslationProvider, TranslationInput, TranslationOutput, TranslationIndex, } from "./domain/translation-providers";
|
|
2
2
|
export { TranslationPipeline, translateContent } from "./translation-pipeline";
|
|
3
3
|
export type { TranslateContentArgs, TranslationStrategy } from "./translation-pipeline";
|
|
4
|
-
export type { ProvenanceKey, ProvenanceStore, TranslationProvenanceRecord } from "./provenance";
|
|
5
|
-
export { projectTranslatableContent } from "./content-projection/contentProjector";
|
|
6
|
-
export type { ProjectionEntry } from "./content-projection/contentProjector";
|
|
7
|
-
export { fingerprint } from "./content-projection/fingerprinter";
|
|
8
|
-
export { computeSourceFingerprint } from "./content-projection/computeSourceFingerprint";
|
|
9
|
-
export { makeIdPath } from "./content-projection/idPath";
|
|
10
|
-
export type { IdPath, PathSegment } from "./content-projection/idPath";
|
|
11
|
-
export { classifyField, findFieldByPath, hasFields, isBlockItem, isTabsField, matchElementById, resolveBlockFields, tabScopes, walkFields, } from "./field-traversal";
|
|
12
|
-
export type { ArrayFieldLike, BlockLike, BlocksFieldLike, FieldLike, FieldStructure, FieldWalker, GroupFieldLike, LeafField, LeafFieldLike, TabLike, TabScope, TabsFieldLike, } from "./field-traversal";
|
|
4
|
+
export type { ProvenanceKey, ProvenanceStore, TranslationProvenanceRecord, } from "./domain/provenance";
|
|
5
|
+
export { projectTranslatableContent } from "./domain/content-projection/contentProjector";
|
|
6
|
+
export type { ProjectionEntry } from "./domain/content-projection/contentProjector";
|
|
7
|
+
export { fingerprint } from "./domain/content-projection/fingerprinter";
|
|
8
|
+
export { computeSourceFingerprint } from "./domain/content-projection/computeSourceFingerprint";
|
|
9
|
+
export { makeIdPath } from "./domain/content-projection/idPath";
|
|
10
|
+
export type { IdPath, PathSegment } from "./domain/content-projection/idPath";
|
|
11
|
+
export { classifyField, findFieldByPath, hasFields, isBlockItem, isTabsField, matchElementById, resolveBlockFields, tabScopes, walkFields, } from "./kernel/field-traversal";
|
|
12
|
+
export type { ArrayFieldLike, BlockLike, BlocksFieldLike, FieldLike, FieldStructure, FieldWalker, GroupFieldLike, LeafField, LeafFieldLike, TabLike, TabScope, TabsFieldLike, } from "./kernel/field-traversal";
|
package/dist/core/index.js
CHANGED
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
// Translation pipeline
|
|
6
6
|
export { TranslationPipeline, translateContent } from "./translation-pipeline";
|
|
7
7
|
// Content projection
|
|
8
|
-
export { projectTranslatableContent } from "./content-projection/contentProjector";
|
|
9
|
-
export { fingerprint } from "./content-projection/fingerprinter";
|
|
10
|
-
export { computeSourceFingerprint } from "./content-projection/computeSourceFingerprint";
|
|
11
|
-
export { makeIdPath } from "./content-projection/idPath";
|
|
8
|
+
export { projectTranslatableContent } from "./domain/content-projection/contentProjector";
|
|
9
|
+
export { fingerprint } from "./domain/content-projection/fingerprinter";
|
|
10
|
+
export { computeSourceFingerprint } from "./domain/content-projection/computeSourceFingerprint";
|
|
11
|
+
export { makeIdPath } from "./domain/content-projection/idPath";
|
|
12
12
|
// Field traversal
|
|
13
|
-
export { classifyField, findFieldByPath, hasFields, isBlockItem, isTabsField, matchElementById, resolveBlockFields, tabScopes, walkFields } from "./field-traversal";
|
|
13
|
+
export { classifyField, findFieldByPath, hasFields, isBlockItem, isTabsField, matchElementById, resolveBlockFields, tabScopes, walkFields } from "./kernel/field-traversal";
|
|
14
14
|
|
|
15
15
|
//# sourceMappingURL=index.js.map
|
|
@@ -2,6 +2,7 @@ export { findFieldByPath } from "./findFieldByPath";
|
|
|
2
2
|
export type { FieldPathResult } from "./findFieldByPath";
|
|
3
3
|
export { hasFields, isBlockItem, isTabsField } from "./guards";
|
|
4
4
|
export { classifyField, matchElementById, resolveBlockFields, tabScopes } from "./kernel";
|
|
5
|
+
export { projectFieldsToFieldLike } from "./projectFieldLike";
|
|
5
6
|
export { fieldAffectsData, fieldIsArrayType, fieldIsBlockType, fieldIsGroupType, tabHasName, } from "./predicates";
|
|
6
7
|
export type { ArrayFieldLike, BlockLike, BlocksFieldLike, ChildCursor, ChildOutput, ContainerInfo, FieldLike, FieldStructure, FieldWalker, GroupFieldLike, LeafField, LeafFieldLike, TabLike, TabScope, TabsFieldLike, WalkSignal, } from "./types";
|
|
7
8
|
export { walkFields } from "./walkFields";
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { findFieldByPath } from "./findFieldByPath";
|
|
2
2
|
export { hasFields, isBlockItem, isTabsField } from "./guards";
|
|
3
3
|
export { classifyField, matchElementById, resolveBlockFields, tabScopes } from "./kernel";
|
|
4
|
+
export { projectFieldsToFieldLike } from "./projectFieldLike";
|
|
4
5
|
export { fieldAffectsData, fieldIsArrayType, fieldIsBlockType, fieldIsGroupType, tabHasName } from "./predicates";
|
|
5
6
|
export { walkFields } from "./walkFields";
|
|
6
7
|
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { FieldLike } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Deep-project a field schema into an independent {@link FieldLike} tree, copying ONLY the properties
|
|
4
|
+
* this layer reads. Replaces the `JSON.parse(JSON.stringify(fields))` clone the plugin used to snapshot
|
|
5
|
+
* a collection's schema before Payload's sanitizer mutates the originals.
|
|
6
|
+
*
|
|
7
|
+
* Why a bespoke projection rather than a structural clone:
|
|
8
|
+
* - **Independence is mandatory, not cosmetic.** Payload's `sanitizeFields` does `delete field.localized`
|
|
9
|
+
* **in place** on any field nested under a localized ancestor (group/array/named tab). The pipeline
|
|
10
|
+
* reads per-field `localized`, so a shared reference would silently lose it and the field would stop
|
|
11
|
+
* being translated. Every field/container here is a NEW object, and `localized` is copied by value at
|
|
12
|
+
* projection time (before sanitize runs), so the snapshot is preserved.
|
|
13
|
+
* - **`structuredClone` can't be used.** Field definitions embed Lexical editor configs containing async
|
|
14
|
+
* functions, which `structuredClone` throws on. The old JSON round-trip "worked" only by silently
|
|
15
|
+
* dropping every function; this projection drops them explicitly by copying a typed whitelist.
|
|
16
|
+
*
|
|
17
|
+
* The contract is exactly what the traversal/pipeline consumes: `type` (classify), `name`/`localized`
|
|
18
|
+
* (leaf data + translation gate), `custom` (only `custom.translateKit.exclude` is read), and the
|
|
19
|
+
* container members `fields` (group/array/row/collapsible/unnamed-group), `blocks` (with the
|
|
20
|
+
* load-bearing `block.slug` used for block-type dispatch), and `tabs` (named + unnamed). Every field is
|
|
21
|
+
* kept 1:1 (including presentational `ui`/`row`/`collapsible`) so downstream classification is unchanged;
|
|
22
|
+
* only the property set is narrowed.
|
|
23
|
+
*
|
|
24
|
+
* `custom` is copied by reference: it is a passthrough bag Payload does not mutate during sanitize (only
|
|
25
|
+
* `localized` is deleted, which we snapshot by value), and deep-copying it would re-introduce the
|
|
26
|
+
* `structuredClone`-on-functions problem this projection exists to avoid.
|
|
27
|
+
*
|
|
28
|
+
* @param fields - The source field list (Payload's `Field[]` is structurally assignable to `FieldLike[]`).
|
|
29
|
+
* @returns A new, independent `FieldLike[]` unaffected by later mutation of the source objects.
|
|
30
|
+
* @since 0.9.1
|
|
31
|
+
*/
|
|
32
|
+
export declare function projectFieldsToFieldLike(fields: FieldLike[]): FieldLike[];
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
function projectField(field) {
|
|
2
|
+
const out = {
|
|
3
|
+
type: field.type
|
|
4
|
+
};
|
|
5
|
+
if (field.name !== undefined) out.name = field.name;
|
|
6
|
+
if (field.localized !== undefined) out.localized = field.localized;
|
|
7
|
+
if (field.custom !== undefined) out.custom = field.custom;
|
|
8
|
+
if (field.fields) out.fields = field.fields.map(projectField);
|
|
9
|
+
if (field.blocks) {
|
|
10
|
+
out.blocks = field.blocks.map((block)=>({
|
|
11
|
+
slug: block.slug,
|
|
12
|
+
fields: block.fields.map(projectField)
|
|
13
|
+
}));
|
|
14
|
+
}
|
|
15
|
+
if (field.tabs) {
|
|
16
|
+
out.tabs = field.tabs.map((tab)=>{
|
|
17
|
+
const projected = {
|
|
18
|
+
fields: tab.fields.map(projectField)
|
|
19
|
+
};
|
|
20
|
+
if (tab.name !== undefined) projected.name = tab.name;
|
|
21
|
+
if (tab.localized !== undefined) projected.localized = tab.localized;
|
|
22
|
+
return projected;
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
return out;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Deep-project a field schema into an independent {@link FieldLike} tree, copying ONLY the properties
|
|
29
|
+
* this layer reads. Replaces the `JSON.parse(JSON.stringify(fields))` clone the plugin used to snapshot
|
|
30
|
+
* a collection's schema before Payload's sanitizer mutates the originals.
|
|
31
|
+
*
|
|
32
|
+
* Why a bespoke projection rather than a structural clone:
|
|
33
|
+
* - **Independence is mandatory, not cosmetic.** Payload's `sanitizeFields` does `delete field.localized`
|
|
34
|
+
* **in place** on any field nested under a localized ancestor (group/array/named tab). The pipeline
|
|
35
|
+
* reads per-field `localized`, so a shared reference would silently lose it and the field would stop
|
|
36
|
+
* being translated. Every field/container here is a NEW object, and `localized` is copied by value at
|
|
37
|
+
* projection time (before sanitize runs), so the snapshot is preserved.
|
|
38
|
+
* - **`structuredClone` can't be used.** Field definitions embed Lexical editor configs containing async
|
|
39
|
+
* functions, which `structuredClone` throws on. The old JSON round-trip "worked" only by silently
|
|
40
|
+
* dropping every function; this projection drops them explicitly by copying a typed whitelist.
|
|
41
|
+
*
|
|
42
|
+
* The contract is exactly what the traversal/pipeline consumes: `type` (classify), `name`/`localized`
|
|
43
|
+
* (leaf data + translation gate), `custom` (only `custom.translateKit.exclude` is read), and the
|
|
44
|
+
* container members `fields` (group/array/row/collapsible/unnamed-group), `blocks` (with the
|
|
45
|
+
* load-bearing `block.slug` used for block-type dispatch), and `tabs` (named + unnamed). Every field is
|
|
46
|
+
* kept 1:1 (including presentational `ui`/`row`/`collapsible`) so downstream classification is unchanged;
|
|
47
|
+
* only the property set is narrowed.
|
|
48
|
+
*
|
|
49
|
+
* `custom` is copied by reference: it is a passthrough bag Payload does not mutate during sanitize (only
|
|
50
|
+
* `localized` is deleted, which we snapshot by value), and deep-copying it would re-introduce the
|
|
51
|
+
* `structuredClone`-on-functions problem this projection exists to avoid.
|
|
52
|
+
*
|
|
53
|
+
* @param fields - The source field list (Payload's `Field[]` is structurally assignable to `FieldLike[]`).
|
|
54
|
+
* @returns A new, independent `FieldLike[]` unaffected by later mutation of the source objects.
|
|
55
|
+
* @since 0.9.1
|
|
56
|
+
*/ export function projectFieldsToFieldLike(fields) {
|
|
57
|
+
return fields.map(projectField);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
//# sourceMappingURL=projectFieldLike.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { TranslationProvider } from "../translation-providers";
|
|
1
|
+
import type { TranslationProvider } from "../domain/translation-providers";
|
|
2
2
|
import type { PipelineConfig, PipelineResult } from "./types";
|
|
3
3
|
import type { TranslationStrategy } from "./strategies";
|
|
4
4
|
import type { TextExpander } from "./stages";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { FieldLike } from "../../../field-traversal";
|
|
1
|
+
import type { FieldLike } from "../../../kernel/field-traversal";
|
|
2
2
|
/**
|
|
3
3
|
* Deep-merges source and target data with target priority, producing the full document shape
|
|
4
4
|
* Payload validation needs. Built on the shared {@link walkFields} engine.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { isEmpty } from "../../../utils/isEmpty";
|
|
2
|
-
import { isObject } from "../../../utils/isObject";
|
|
3
|
-
import { matchElementById, resolveBlockFields, walkFields } from "../../../field-traversal";
|
|
1
|
+
import { isEmpty } from "../../../kernel/utils/isEmpty";
|
|
2
|
+
import { isObject } from "../../../kernel/utils/isObject";
|
|
3
|
+
import { matchElementById, resolveBlockFields, walkFields } from "../../../kernel/field-traversal";
|
|
4
4
|
const asObject = (value)=>isObject(value) ? value : {};
|
|
5
5
|
/**
|
|
6
6
|
* Reconcile walker: produces the full document shape from source + target, with target
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { isTranslatableLeaf } from "../../../content-projection/translatableLeaf";
|
|
2
|
-
import { matchElementById, resolveBlockFields, walkFields } from "../../../field-traversal";
|
|
3
|
-
import { isObject } from "../../../utils/isObject";
|
|
1
|
+
import { isTranslatableLeaf } from "../../../domain/content-projection/translatableLeaf";
|
|
2
|
+
import { matchElementById, resolveBlockFields, walkFields } from "../../../kernel/field-traversal";
|
|
3
|
+
import { isObject } from "../../../kernel/utils/isObject";
|
|
4
4
|
const asObject = (value)=>isObject(value) ? value : {};
|
|
5
5
|
/**
|
|
6
6
|
* Collects FieldChunks by walking schema + data with the shared {@link walkFields} engine.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isSerializedLexicalRoot, collectSerializedLexicalTextNodes } from "../../../lexical";
|
|
1
|
+
import { isSerializedLexicalRoot, collectSerializedLexicalTextNodes } from "../../../kernel/lexical";
|
|
2
2
|
/**
|
|
3
3
|
* Expands richText fields into multiple RichTextChunks (one per text node).
|
|
4
4
|
*/ export class RichTextExpander {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { PipelineContext, PipelineStage } from "../../types";
|
|
2
|
-
import type { TranslationProvider } from "../../../translation-providers";
|
|
2
|
+
import type { TranslationProvider } from "../../../domain/translation-providers";
|
|
3
3
|
/**
|
|
4
4
|
* Calls translation provider to translate text.
|
|
5
5
|
*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { isEmptyRichText } from "../../lexical/isEmptyRichText";
|
|
2
|
-
import { isSerializedLexicalRoot } from "../../lexical/guards";
|
|
3
|
-
import { isEmpty } from "../../utils/isEmpty";
|
|
1
|
+
import { isEmptyRichText } from "../../kernel/lexical/isEmptyRichText";
|
|
2
|
+
import { isSerializedLexicalRoot } from "../../kernel/lexical/guards";
|
|
3
|
+
import { isEmpty } from "../../kernel/utils/isEmpty";
|
|
4
4
|
/**
|
|
5
5
|
* Only translates fields that are empty or missing in the target locale.
|
|
6
6
|
* Existing translations are preserved.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { FieldLike } from "../field-traversal";
|
|
2
|
-
import type { TranslationProvider } from "../translation-providers";
|
|
1
|
+
import type { FieldLike } from "../kernel/field-traversal";
|
|
2
|
+
import type { TranslationProvider } from "../domain/translation-providers";
|
|
3
3
|
import type { TranslationStrategyName } from "./strategies";
|
|
4
4
|
export type TranslateContentArgs = {
|
|
5
5
|
/** Schema subtree to translate (e.g. `[declaredFieldConfig]`). */
|
package/dist/field-config.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Field, RichTextField, TextareaField, TextField } from "payload";
|
|
2
|
-
import type { FieldTranslationConfig } from "./core/field-config";
|
|
2
|
+
import type { FieldTranslationConfig } from "./core/domain/field-config";
|
|
3
3
|
export type { FieldTranslationConfig };
|
|
4
4
|
/**
|
|
5
5
|
* Field types eligible for the per-field translate control — the same text-bearing
|
package/dist/field-config.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TRANSLATE_KIT_CUSTOM_KEY } from "./core/field-config";
|
|
1
|
+
import { TRANSLATE_KIT_CUSTOM_KEY } from "./core/domain/field-config";
|
|
2
2
|
import { TranslateFieldControlExport } from "./client/widgets/translate-field-control/ui/TranslateFieldControl.export";
|
|
3
3
|
import { beforeInputPositioner } from "./field-actions";
|
|
4
4
|
/**
|
package/dist/plugin.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { CollectionConfig, Config } from "payload";
|
|
2
2
|
import type { AccessGuard } from "./types/AccessGuard";
|
|
3
|
-
import type { TranslationProvider } from "./core/translation-providers";
|
|
3
|
+
import type { TranslationProvider } from "./core/domain/translation-providers";
|
|
4
4
|
import type { TaskRunnerProvider } from "./server/modules/task-runner";
|
|
5
5
|
import type { TranslationLifecycleCallbacks } from "./server/modules/lifecycle";
|
|
6
6
|
import type { TranslationLevel } from "./server/modules/translation-levels";
|
package/dist/plugin.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { CacheProviderExport } from "./client/app/cache/CacheProvider.export";
|
|
2
2
|
import { configureAutoTranslate } from "./server/modules/auto-translate";
|
|
3
3
|
import { configureProvenance } from "./server/modules/provenance";
|
|
4
|
+
import { projectFieldsToFieldLike } from "./core/kernel/field-traversal";
|
|
4
5
|
import { wireTranslateRunner } from "./server/features/translate-document";
|
|
5
6
|
import { documentLevel, collectionLevel } from "./composition/levels";
|
|
6
7
|
import { PluginConfigBuilder } from "./server/modules/translation-levels/PluginConfigBuilder";
|
|
@@ -13,17 +14,15 @@ import { normalizePath } from "./server/shared";
|
|
|
13
14
|
init() {
|
|
14
15
|
return async (config)=>{
|
|
15
16
|
const { access, translationProvider, runner, collections, levels, provenance, lifecycle, basePath: rawBasePath = "/translate" } = this.pluginConfig;
|
|
16
|
-
//
|
|
17
|
-
//
|
|
18
|
-
// `
|
|
19
|
-
//
|
|
20
|
-
//
|
|
21
|
-
//
|
|
22
|
-
// pipeline (name, type, localized, fields, blocks, tabs, custom) to make the contract explicit
|
|
23
|
-
// and avoid reliance on JSON round-trip.
|
|
17
|
+
// Snapshot each collection's schema as an independent FieldLike tree BEFORE Payload's sanitizer
|
|
18
|
+
// mutates the originals (it deletes `localized` from fields nested under a localized ancestor).
|
|
19
|
+
// `projectFieldsToFieldLike` deep-copies only the properties the pipeline reads — an explicit,
|
|
20
|
+
// typed contract, replacing the old JSON round-trip (which "worked" only by silently dropping the
|
|
21
|
+
// Lexical editor's async functions that structuredClone chokes on). Payload's `Field[]` is
|
|
22
|
+
// structurally assignable to `FieldLike[]`, so the projection happens right here at the boundary.
|
|
24
23
|
const schemaMap = new Map(collections.map((col)=>[
|
|
25
24
|
col.slug,
|
|
26
|
-
|
|
25
|
+
projectFieldsToFieldLike(col.fields)
|
|
27
26
|
]));
|
|
28
27
|
const collectionSlugs = new Set(schemaMap.keys());
|
|
29
28
|
const basePath = normalizePath(rawBasePath);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Payload } from "payload";
|
|
2
2
|
import type { Handler } from "../../shared";
|
|
3
|
-
import type { TranslationProvider } from "../../../core/translation-providers";
|
|
3
|
+
import type { TranslationProvider } from "../../../core/domain/translation-providers";
|
|
4
4
|
import type { ProvenanceServiceFactory } from "../../modules/provenance";
|
|
5
5
|
import type { CollectionSchemaMap } from "../../../types/CollectionSchemaMap";
|
|
6
6
|
import type { TranslateDocumentInput, TranslateDocumentOutput } from "./model";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { CollectionSlug } from "payload";
|
|
2
|
-
import type { TranslationProvider } from "../../../core/translation-providers";
|
|
2
|
+
import type { TranslationProvider } from "../../../core/domain/translation-providers";
|
|
3
3
|
import type { CollectionSchemaMap } from "../../../types/CollectionSchemaMap";
|
|
4
4
|
import type { ConfigModifier } from "../../../types/ConfigModifier";
|
|
5
5
|
import type { ProvenanceServiceFactory } from "../../modules/provenance";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import type { CollectionSchemaMap } from "../../../types/CollectionSchemaMap";
|
|
3
|
-
import type { TranslationProvider } from "../../../core/translation-providers";
|
|
3
|
+
import type { TranslationProvider } from "../../../core/domain/translation-providers";
|
|
4
4
|
/**
|
|
5
5
|
* Max serialized size of the value the endpoint will translate — the value read from the
|
|
6
6
|
* source-locale document (the request body no longer carries one; this is from-locale only). The
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { FieldLike } from "../../../core/kernel/field-traversal";
|
|
2
2
|
/**
|
|
3
3
|
* Outcome of mapping a declared field path to a translatable subtree.
|
|
4
4
|
*
|
|
@@ -14,7 +14,7 @@ import type { Field } from "payload";
|
|
|
14
14
|
*/
|
|
15
15
|
export type FieldSubtreeResolution = {
|
|
16
16
|
status: "resolved";
|
|
17
|
-
schema:
|
|
17
|
+
schema: FieldLike[];
|
|
18
18
|
sourceData: Record<string, unknown>;
|
|
19
19
|
fieldName: string;
|
|
20
20
|
} | {
|
|
@@ -36,4 +36,4 @@ export type FieldSubtreeResolution = {
|
|
|
36
36
|
* the element's `blockType` in `doc` picks the block schema. Without `doc`, a path through a
|
|
37
37
|
* `blocks` field returns `inside-blocks`.
|
|
38
38
|
*/
|
|
39
|
-
export declare function resolveFieldSubtree(rootFields:
|
|
39
|
+
export declare function resolveFieldSubtree(rootFields: FieldLike[], fieldPath: string, value: unknown, doc?: unknown): FieldSubtreeResolution;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isTranslatableField } from "../../shared";
|
|
2
|
-
import { findFieldByPath } from "../../../core/field-traversal";
|
|
2
|
+
import { findFieldByPath } from "../../../core/kernel/field-traversal";
|
|
3
3
|
/**
|
|
4
4
|
* Map a declared `fieldPath` to the `{ schema, sourceData }` pair `translateContent` expects.
|
|
5
5
|
* Walks the schema via the shared {@link findFieldByPath}. Descends transparently through
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { CollectionSlug } from "payload";
|
|
2
|
-
import type { AutoTranslateConfig } from "../../../core/auto-translate
|
|
2
|
+
import type { AutoTranslateConfig } from "../../../core/domain/auto-translate";
|
|
3
3
|
import type { TaskInput } from "../task-runner/types";
|
|
4
4
|
/** A collection's auto-translate rule with defaults resolved — the shape the hook consumes. */
|
|
5
5
|
export type NormalizedAutoTranslatePolicy = {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getAutoTranslateConfig } from "../../../core/auto-translate
|
|
1
|
+
import { getAutoTranslateConfig } from "../../../core/domain/auto-translate";
|
|
2
2
|
import { extractLocaleCodes, filterPolicyToKnownLocales, makeCollectionPolicyResolver, normalizeAutoTranslateConfig } from "./AutoTranslate.policy";
|
|
3
3
|
import { injectAutoTranslateHook, makeAutoTranslateHook, propagateAutoTranslateCustom } from "./AutoTranslateEnqueue.hook";
|
|
4
4
|
const NOOP = (config)=>config;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { hasSourceContentChanged } from "../../../core/auto-translate";
|
|
2
|
-
import { AUTO_TRANSLATE_CUSTOM_KEY } from "../../../core/auto-translate
|
|
1
|
+
import { hasSourceContentChanged } from "../../../core/domain/auto-translate";
|
|
2
|
+
import { AUTO_TRANSLATE_CUSTOM_KEY } from "../../../core/domain/auto-translate";
|
|
3
3
|
import { AUTO_TRANSLATE_SKIP_CONTEXT_KEY } from "../../../types/AutoTranslateContext";
|
|
4
4
|
import { buildAutoTranslateTasks, passesPublishGate } from "./AutoTranslate.policy";
|
|
5
5
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// Auto-translate adapter (Payload-backed). The payload-free drift predicate + config reader live in
|
|
2
|
-
// the core (src/core/auto-translate
|
|
2
|
+
// the core (src/core/domain/auto-translate, src/core/domain/content-projection); this module is the config-time
|
|
3
3
|
// wiring + the afterChange hook that enqueues translations on a source-locale change (#51).
|
|
4
4
|
export { configureAutoTranslate } from "./AutoTranslate.wiring";
|
|
5
5
|
export { makeAutoTranslateHook, injectAutoTranslateHook } from "./AutoTranslateEnqueue.hook";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from "../../core/translation-providers";
|
|
1
|
+
export * from "../../core/domain/translation-providers";
|
|
2
2
|
export * from "../../core/translation-pipeline";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { CollectionSlug, Payload } from "payload";
|
|
2
|
-
import type { ProvenanceKey, ProvenanceStore } from "../../../core/provenance";
|
|
2
|
+
import type { ProvenanceKey, ProvenanceStore } from "../../../core/domain/provenance";
|
|
3
3
|
import type { CollectionSchemaMap } from "../../../types/CollectionSchemaMap";
|
|
4
4
|
/** Per-locale staleness for one document (snake_case, matching the other translation endpoints). */
|
|
5
5
|
export type StalenessLocale = {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { computeSourceFingerprint } from "../../../core/content-projection/computeSourceFingerprint";
|
|
2
|
-
import { isRecordStale } from "../../../core/provenance";
|
|
1
|
+
import { computeSourceFingerprint } from "../../../core/domain/content-projection/computeSourceFingerprint";
|
|
2
|
+
import { isRecordStale } from "../../../core/domain/provenance";
|
|
3
3
|
import { fetchSourceDocument } from "../../shared/payload/sourceDocument";
|
|
4
4
|
/**
|
|
5
5
|
* The single owner of provenance fingerprint policy — how the source is hashed on write, re-hashed on
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Payload } from "payload";
|
|
2
|
-
import type { ProvenanceKey, ProvenanceStore, TranslationProvenanceRecord } from "../../../core/provenance";
|
|
2
|
+
import type { ProvenanceKey, ProvenanceStore, TranslationProvenanceRecord } from "../../../core/domain/provenance";
|
|
3
3
|
/** Builds a provenance store bound to a Payload instance; absent when provenance is disabled. */
|
|
4
4
|
export type ProvenanceStoreFactory = (payload: Payload) => ProvenanceStore;
|
|
5
5
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// Provenance adapter (Payload-backed). The framework-agnostic port + record types live in the core
|
|
2
|
-
// (src/core/provenance); this module is the plugin-side implementation + its config-time wiring.
|
|
2
|
+
// (src/core/domain/provenance); this module is the plugin-side implementation + its config-time wiring.
|
|
3
3
|
export { DEFAULT_PROVENANCE_SLUG, isProvenanceCollection, makeProvenanceCollection } from "./Provenance.collection";
|
|
4
4
|
export { PayloadProvenanceStore } from "./Provenance.store";
|
|
5
5
|
export { injectProvenanceCleanup, makeProvenanceCleanupHook } from "./ProvenanceCleanup.hook";
|
|
@@ -3,7 +3,7 @@ import type { AccessGuard } from "../../../types/AccessGuard";
|
|
|
3
3
|
import type { RawPayloadComponentExport } from "../../../types/PayloadComponentExport";
|
|
4
4
|
import type { CollectionSchemaMap } from "../../../types/CollectionSchemaMap";
|
|
5
5
|
import type { ConfigModifier } from "../../../types/ConfigModifier";
|
|
6
|
-
import type { TranslationProvider } from "../../../core/translation-providers";
|
|
6
|
+
import type { TranslationProvider } from "../../../core/domain/translation-providers";
|
|
7
7
|
import type { TaskRunnerFactory } from "../task-runner";
|
|
8
8
|
import type { ProvenanceServiceFactory } from "../provenance";
|
|
9
9
|
import type { CollectionAdminSlot, LevelContext, TranslationContext } from "./types";
|
|
@@ -2,7 +2,7 @@ import type { CollectionConfig, Endpoint } from "payload";
|
|
|
2
2
|
import type { AccessGuard } from "../../../types/AccessGuard";
|
|
3
3
|
import type { RawPayloadComponentExport } from "../../../types/PayloadComponentExport";
|
|
4
4
|
import type { CollectionSchemaMap } from "../../../types/CollectionSchemaMap";
|
|
5
|
-
import type { TranslationProvider } from "../../../core/translation-providers";
|
|
5
|
+
import type { TranslationProvider } from "../../../core/domain/translation-providers";
|
|
6
6
|
import type { TaskRunnerFactory } from "../task-runner";
|
|
7
7
|
import type { ProvenanceServiceFactory } from "../provenance";
|
|
8
8
|
export type CollectionAdminSlot = "beforeDocumentControls" | "beforeListTable";
|
|
@@ -4,9 +4,9 @@ export type { AccessGuard, AccessGuardRequest, Handler } from "./access";
|
|
|
4
4
|
export { isEmpty, isObject, normalizePath, pipe, getByPath, setByPath, filterLocalizedFields, } from "./utils";
|
|
5
5
|
export type { TranslatableField } from "./guards";
|
|
6
6
|
export { isTranslatableField, isLocalizedField, isRelationshipField } from "./guards";
|
|
7
|
-
export { isTabsField, isBlockItem, hasFields } from "../../core/field-traversal";
|
|
8
|
-
export { isFieldExcludedFromTranslation, getTranslateKitFieldConfig, } from "../../core/field-config";
|
|
9
|
-
export type { TranslateKitFieldConfig } from "../../core/field-config";
|
|
10
|
-
export { isSerializedLexicalRoot, isEmptyRichText, traverseLexicalTree, collectSerializedLexicalTextNodes, } from "../../core/lexical";
|
|
11
|
-
export type { SerializedTextNodeRef } from "../../core/lexical";
|
|
7
|
+
export { isTabsField, isBlockItem, hasFields } from "../../core/kernel/field-traversal";
|
|
8
|
+
export { isFieldExcludedFromTranslation, getTranslateKitFieldConfig, } from "../../core/domain/field-config";
|
|
9
|
+
export type { TranslateKitFieldConfig } from "../../core/domain/field-config";
|
|
10
|
+
export { isSerializedLexicalRoot, isEmptyRichText, traverseLexicalTree, collectSerializedLexicalTextNodes, } from "../../core/kernel/lexical";
|
|
11
|
+
export type { SerializedTextNodeRef } from "../../core/kernel/lexical";
|
|
12
12
|
export { JobIdSchema } from "./validation";
|
|
@@ -5,11 +5,11 @@ export { AnyAccessGuard } from "./access";
|
|
|
5
5
|
// General utilities
|
|
6
6
|
export { isEmpty, isObject, normalizePath, pipe, getByPath, setByPath, filterLocalizedFields } from "./utils";
|
|
7
7
|
export { isTranslatableField, isLocalizedField, isRelationshipField } from "./guards";
|
|
8
|
-
export { isTabsField, isBlockItem, hasFields } from "../../core/field-traversal";
|
|
8
|
+
export { isTabsField, isBlockItem, hasFields } from "../../core/kernel/field-traversal";
|
|
9
9
|
// Field config
|
|
10
|
-
export { isFieldExcludedFromTranslation, getTranslateKitFieldConfig } from "../../core/field-config";
|
|
10
|
+
export { isFieldExcludedFromTranslation, getTranslateKitFieldConfig } from "../../core/domain/field-config";
|
|
11
11
|
// Lexical utilities
|
|
12
|
-
export { isSerializedLexicalRoot, isEmptyRichText, traverseLexicalTree, collectSerializedLexicalTextNodes } from "../../core/lexical";
|
|
12
|
+
export { isSerializedLexicalRoot, isEmptyRichText, traverseLexicalTree, collectSerializedLexicalTextNodes } from "../../core/kernel/lexical";
|
|
13
13
|
// Validation primitives
|
|
14
14
|
export { JobIdSchema } from "./validation";
|
|
15
15
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { resolveBlockFields, walkFields } from "../../../core/field-traversal";
|
|
1
|
+
import { resolveBlockFields, walkFields } from "../../../core/kernel/field-traversal";
|
|
2
2
|
import { isLocalizedField, isTranslatableField } from "../guards";
|
|
3
|
-
import { isObject } from "../../../core/utils/isObject";
|
|
3
|
+
import { isObject } from "../../../core/kernel/utils/isObject";
|
|
4
4
|
/**
|
|
5
5
|
* Filter walker: keeps only translatable, localized leaves, rebuilding the surrounding
|
|
6
6
|
* object/array/blocks structure and dropping any container left empty. `id` (array/block
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { isEmpty } from "../../../core/utils/isEmpty";
|
|
2
|
-
export { isObject } from "../../../core/utils/isObject";
|
|
1
|
+
export { isEmpty } from "../../../core/kernel/utils/isEmpty";
|
|
2
|
+
export { isObject } from "../../../core/kernel/utils/isObject";
|
|
3
3
|
export { normalizePath } from "./normalizePath";
|
|
4
4
|
export { getByPath } from "./getByPath";
|
|
5
5
|
export { setByPath } from "./setByPath";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { isEmpty } from "../../../core/utils/isEmpty";
|
|
2
|
-
export { isObject } from "../../../core/utils/isObject";
|
|
1
|
+
export { isEmpty } from "../../../core/kernel/utils/isEmpty";
|
|
2
|
+
export { isObject } from "../../../core/kernel/utils/isObject";
|
|
3
3
|
export { normalizePath } from "./normalizePath";
|
|
4
4
|
export { getByPath } from "./getByPath";
|
|
5
5
|
export { setByPath } from "./setByPath";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export type { TranslationProvider, TranslationInput, TranslationOutput, } from "../core/translation-providers";
|
|
1
|
+
export type { TranslationProvider, TranslationInput, TranslationOutput, } from "../core/domain/translation-providers";
|
|
2
2
|
export * from "./openai";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { TranslationProvider, TranslationInput, TranslationOutput } from "../../core/translation-providers/TranslationProvider.interface";
|
|
1
|
+
import type { TranslationProvider, TranslationInput, TranslationOutput } from "../../core/domain/translation-providers/TranslationProvider.interface";
|
|
2
2
|
import type { ChatModel } from "openai/resources/index.mjs";
|
|
3
3
|
/**
|
|
4
4
|
* Function to transform text in dry run mode.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import OpenAI from "openai";
|
|
2
|
-
import { isObject } from "../../core/utils/isObject";
|
|
2
|
+
import { isObject } from "../../core/kernel/utils/isObject";
|
|
3
3
|
/** @deprecated Use `createOpenAIProvider` function instead */ export class OpenAITranslationProvider {
|
|
4
4
|
openAiClient;
|
|
5
5
|
config;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import type { CollectionSlug
|
|
1
|
+
import type { CollectionSlug } from "payload";
|
|
2
|
+
import type { FieldLike } from "../core/kernel/field-traversal";
|
|
2
3
|
/**
|
|
3
|
-
* Map of collection slug to
|
|
4
|
-
*
|
|
4
|
+
* Map of collection slug to its projected field schema — an independent {@link FieldLike} snapshot
|
|
5
|
+
* taken (via `projectFieldsToFieldLike`) before Payload's sanitizer mutates the originals, so nested
|
|
6
|
+
* `localized` flags survive. Typed as `FieldLike[]` (not Payload's `Field[]`) because every consumer
|
|
7
|
+
* reads it structurally as `FieldLike`; the projection is the boundary that makes that explicit.
|
|
5
8
|
*/
|
|
6
|
-
export type CollectionSchemaMap = Map<CollectionSlug,
|
|
9
|
+
export type CollectionSchemaMap = Map<CollectionSlug, FieldLike[]>;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Map of collection slug to
|
|
3
|
-
*
|
|
2
|
+
* Map of collection slug to its projected field schema — an independent {@link FieldLike} snapshot
|
|
3
|
+
* taken (via `projectFieldsToFieldLike`) before Payload's sanitizer mutates the originals, so nested
|
|
4
|
+
* `localized` flags survive. Typed as `FieldLike[]` (not Payload's `Field[]`) because every consumer
|
|
5
|
+
* reads it structurally as `FieldLike`; the projection is the boundary that makes that explicit.
|
|
4
6
|
*/ export { };
|
|
5
7
|
|
|
6
8
|
//# sourceMappingURL=CollectionSchemaMap.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@focus-reactive/payload-plugin-translator",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.2",
|
|
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",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { hasSourceContentChanged } from "./hasSourceContentChanged";
|
/package/dist/core/{auto-translate-config → domain/auto-translate}/getAutoTranslateConfig.d.ts
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/dist/core/{content-projection → domain/content-projection}/computeSourceFingerprint.js
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|