@focus-reactive/payload-plugin-translator 0.11.2 → 0.11.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +34 -0
- package/dist/server/modules/task-runner/TaskRunner.interface.d.ts +1 -1
- package/dist/server/modules/task-runner/TaskRunner.interface.js +1 -1
- package/dist/server/modules/task-runner/toTaskFilter.d.ts +1 -1
- package/dist/server/modules/task-runner/toTaskFilter.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -618,6 +618,40 @@ Payload lets a wrapper field (group, array, blocks, tabs) be `localized`, which
|
|
|
618
618
|
|
|
619
619
|
See the `deleteJobOnComplete: false` note under [Runners](#createpayloadjobsrunneroptions-recommended).
|
|
620
620
|
|
|
621
|
+
Keeping them means they accumulate: nothing in the plugin removes a completed translation job, and the
|
|
622
|
+
status panels read a collection's jobs on every open. How long that history is worth keeping is your
|
|
623
|
+
call, not the plugin's, so pruning is left to you — the same way `deleteJobOnComplete` is.
|
|
624
|
+
|
|
625
|
+
_Applies only to `createPayloadJobsRunner`._ `createSyncRunner` translates inline and writes no jobs at
|
|
626
|
+
all, so there is nothing to prune.
|
|
627
|
+
|
|
628
|
+
```ts
|
|
629
|
+
// Run from your own cron / scheduled task.
|
|
630
|
+
// Must match the `taskName` you passed to createPayloadJobsRunner — "translate_document" by default.
|
|
631
|
+
const TRANSLATOR_TASK = "translate_document";
|
|
632
|
+
|
|
633
|
+
const cutoff = new Date(Date.now() - 30 * 24 * 60 * 60 * 1000).toISOString();
|
|
634
|
+
|
|
635
|
+
await payload.delete({
|
|
636
|
+
collection: "payload-jobs",
|
|
637
|
+
where: {
|
|
638
|
+
and: [
|
|
639
|
+
{ taskSlug: { equals: TRANSLATOR_TASK } },
|
|
640
|
+
{ completedAt: { exists: true } },
|
|
641
|
+
{ completedAt: { less_than: cutoff } },
|
|
642
|
+
],
|
|
643
|
+
},
|
|
644
|
+
});
|
|
645
|
+
```
|
|
646
|
+
|
|
647
|
+
Three things the clauses buy you, in order: only this plugin's jobs, only finished ones — so nothing
|
|
648
|
+
queued or in flight is touched — and only those older than your cutoff, so a run someone may still want
|
|
649
|
+
to look at survives. Keep a cutoff of at least a day for that last reason; deleting everything
|
|
650
|
+
completed would erase a translation that finished minutes ago.
|
|
651
|
+
|
|
652
|
+
All three filter on real columns rather than paths inside the job's JSON input, so this behaves the same
|
|
653
|
+
on SQLite, Postgres and MongoDB.
|
|
654
|
+
|
|
621
655
|
## TypeScript
|
|
622
656
|
|
|
623
657
|
The package ships its types. Besides the factories, the following are exported for typing your own code:
|
|
@@ -35,7 +35,7 @@ export interface TaskRunner {
|
|
|
35
35
|
* How a {@link TaskRunner.findByCollection} call is narrowed. Each field says whether it reaches the
|
|
36
36
|
* database or is applied in memory over everything the database returned.
|
|
37
37
|
*
|
|
38
|
-
* @since 0.
|
|
38
|
+
* @since 0.11.2
|
|
39
39
|
*/
|
|
40
40
|
export type TaskFilter = {
|
|
41
41
|
/** Keep only tasks for these documents. Applied in memory — see `PayloadJobsTaskRunner.findByCollection`. */
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* How a {@link TaskRunner.findByCollection} call is narrowed. Each field says whether it reaches the
|
|
3
3
|
* database or is applied in memory over everything the database returned.
|
|
4
4
|
*
|
|
5
|
-
* @since 0.
|
|
5
|
+
* @since 0.11.2
|
|
6
6
|
*/ export { };
|
|
7
7
|
|
|
8
8
|
//# sourceMappingURL=TaskRunner.interface.js.map
|
|
@@ -6,6 +6,6 @@ import type { TaskFilter } from "./TaskRunner.interface";
|
|
|
6
6
|
* than being re-derived: the array form is deprecated and will be removed, and a hand-written
|
|
7
7
|
* `Array.isArray` branch in someone else's runner would outlive it.
|
|
8
8
|
*
|
|
9
|
-
* @since 0.
|
|
9
|
+
* @since 0.11.2
|
|
10
10
|
*/
|
|
11
11
|
export declare function toTaskFilter(filter?: Array<string | number> | TaskFilter): TaskFilter;
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* than being re-derived: the array form is deprecated and will be removed, and a hand-written
|
|
6
6
|
* `Array.isArray` branch in someone else's runner would outlive it.
|
|
7
7
|
*
|
|
8
|
-
* @since 0.
|
|
8
|
+
* @since 0.11.2
|
|
9
9
|
*/ export function toTaskFilter(filter) {
|
|
10
10
|
return Array.isArray(filter) ? {
|
|
11
11
|
documentIds: filter
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@focus-reactive/payload-plugin-translator",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.3",
|
|
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",
|