@10x-media/jobs 0.1.0-beta.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 +15 -0
- package/LICENSE +21 -0
- package/README.md +351 -0
- package/dist/deriveJobStatus-CM_sCsgm.js +72 -0
- package/dist/deriveJobStatus-CM_sCsgm.js.map +1 -0
- package/dist/exports/client.d.ts +49 -0
- package/dist/exports/client.js +573 -0
- package/dist/exports/client.js.map +1 -0
- package/dist/exports/i18n.d.ts +47 -0
- package/dist/exports/i18n.js +3 -0
- package/dist/exports/rsc.d.ts +19 -0
- package/dist/exports/rsc.js +66 -0
- package/dist/exports/rsc.js.map +1 -0
- package/dist/exports/types.d.ts +2 -0
- package/dist/exports/types.js +1 -0
- package/dist/index-CYsbNe4q.d.ts +530 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1622 -0
- package/dist/index.js.map +1 -0
- package/dist/jobStatusMeta-BLBSPUcE.js +41 -0
- package/dist/jobStatusMeta-BLBSPUcE.js.map +1 -0
- package/dist/keys-BYs8GTJy.js +41 -0
- package/dist/keys-BYs8GTJy.js.map +1 -0
- package/dist/server-JsvYf5vy.js +13 -0
- package/dist/server-JsvYf5vy.js.map +1 -0
- package/dist/translations-KyQ3962W.js +61 -0
- package/dist/translations-KyQ3962W.js.map +1 -0
- package/package.json +110 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
//#region src/translations/keys.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Typed translation keys. Lookups must go through these constants, not string
|
|
4
|
+
* literals (enforced by requireI18nKeysTyped.grit). Every key here must have a
|
|
5
|
+
* value in every locale (`en.ts`), or it is a type error.
|
|
6
|
+
*/
|
|
7
|
+
declare const keys: {
|
|
8
|
+
readonly pluginName: "jobs:pluginName";
|
|
9
|
+
readonly statusQueued: "jobs:statusQueued";
|
|
10
|
+
readonly statusScheduled: "jobs:statusScheduled";
|
|
11
|
+
readonly statusRetrying: "jobs:statusRetrying";
|
|
12
|
+
readonly statusRunning: "jobs:statusRunning";
|
|
13
|
+
readonly statusSucceeded: "jobs:statusSucceeded";
|
|
14
|
+
readonly statusFailed: "jobs:statusFailed";
|
|
15
|
+
readonly statusCancelled: "jobs:statusCancelled";
|
|
16
|
+
readonly fieldStatus: "jobs:fieldStatus";
|
|
17
|
+
readonly fieldWorkflow: "jobs:fieldWorkflow";
|
|
18
|
+
readonly fieldTask: "jobs:fieldTask";
|
|
19
|
+
readonly fieldJob: "jobs:fieldJob";
|
|
20
|
+
readonly fieldQueue: "jobs:fieldQueue";
|
|
21
|
+
readonly fieldAttempts: "jobs:fieldAttempts";
|
|
22
|
+
readonly fieldCreated: "jobs:fieldCreated";
|
|
23
|
+
readonly fieldUpdated: "jobs:fieldUpdated";
|
|
24
|
+
readonly fieldCompleted: "jobs:fieldCompleted";
|
|
25
|
+
readonly fieldExecuted: "jobs:fieldExecuted";
|
|
26
|
+
readonly fieldTaskId: "jobs:fieldTaskId";
|
|
27
|
+
readonly fieldInput: "jobs:fieldInput";
|
|
28
|
+
readonly fieldOutput: "jobs:fieldOutput";
|
|
29
|
+
readonly fieldError: "jobs:fieldError";
|
|
30
|
+
readonly fieldId: "jobs:fieldId";
|
|
31
|
+
readonly outcome: "jobs:outcome";
|
|
32
|
+
readonly noAttempts: "jobs:noAttempts";
|
|
33
|
+
readonly copy: "jobs:copy";
|
|
34
|
+
readonly copied: "jobs:copied";
|
|
35
|
+
readonly jobSingular: "jobs:jobSingular";
|
|
36
|
+
readonly jobPlural: "jobs:jobPlural";
|
|
37
|
+
};
|
|
38
|
+
type TranslationKey = (typeof keys)[keyof typeof keys];
|
|
39
|
+
//#endregion
|
|
40
|
+
//#region src/translations/index.d.ts
|
|
41
|
+
/** Per-locale messages merged into `config.i18n.translations`. English only for now. */
|
|
42
|
+
declare const translations: {
|
|
43
|
+
en: Record<string, Record<string, string>>;
|
|
44
|
+
};
|
|
45
|
+
//#endregion
|
|
46
|
+
export { type TranslationKey as JobsTranslationKeys, keys, translations };
|
|
47
|
+
//# sourceMappingURL=i18n.d.ts.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ServerProps } from "payload";
|
|
2
|
+
|
|
3
|
+
//#region src/jobs/JobsHealthBar.d.ts
|
|
4
|
+
type Props = Pick<ServerProps, 'i18n' | 'payload'> & {
|
|
5
|
+
cap?: false | number;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Queue-health bar above the jobs list: one indexed `count` per status, so it
|
|
9
|
+
* stays cheap on large tables. A count above `cap` renders as `${cap}+`; pass
|
|
10
|
+
* `cap: false` for the exact figure.
|
|
11
|
+
*/
|
|
12
|
+
declare const JobsHealthBar: ({
|
|
13
|
+
cap,
|
|
14
|
+
i18n,
|
|
15
|
+
payload
|
|
16
|
+
}: Props) => Promise<import("react/jsx-runtime").JSX.Element | null>;
|
|
17
|
+
//#endregion
|
|
18
|
+
export { JobsHealthBar };
|
|
19
|
+
//# sourceMappingURL=rsc.d.ts.map
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { t as keys } from "../keys-BYs8GTJy.js";
|
|
2
|
+
import { t as asTranslate } from "../server-JsvYf5vy.js";
|
|
3
|
+
import { n as statusWhere } from "../deriveJobStatus-CM_sCsgm.js";
|
|
4
|
+
import { t as jobStatusMeta } from "../jobStatusMeta-BLBSPUcE.js";
|
|
5
|
+
import { Pill } from "@payloadcms/ui";
|
|
6
|
+
import { jsxs } from "react/jsx-runtime";
|
|
7
|
+
//#region src/jobs/JobsHealthBar.tsx
|
|
8
|
+
const DEFAULT_CAP = 100;
|
|
9
|
+
/** Display order: succeeded first, then active, pending, and problem states. */
|
|
10
|
+
const ORDER = [
|
|
11
|
+
"succeeded",
|
|
12
|
+
"running",
|
|
13
|
+
"queued",
|
|
14
|
+
"scheduled",
|
|
15
|
+
"failed",
|
|
16
|
+
"retrying",
|
|
17
|
+
"cancelled"
|
|
18
|
+
];
|
|
19
|
+
/**
|
|
20
|
+
* Queue-health bar above the jobs list: one indexed `count` per status, so it
|
|
21
|
+
* stays cheap on large tables. A count above `cap` renders as `${cap}+`; pass
|
|
22
|
+
* `cap: false` for the exact figure.
|
|
23
|
+
*/
|
|
24
|
+
const JobsHealthBar = async ({ cap = DEFAULT_CAP, i18n, payload }) => {
|
|
25
|
+
const now = Date.now();
|
|
26
|
+
const results = await Promise.all(ORDER.map(async (status) => {
|
|
27
|
+
const { totalDocs } = await payload.count({
|
|
28
|
+
collection: "payload-jobs",
|
|
29
|
+
where: statusWhere(status, now)
|
|
30
|
+
});
|
|
31
|
+
return {
|
|
32
|
+
count: totalDocs,
|
|
33
|
+
status
|
|
34
|
+
};
|
|
35
|
+
}));
|
|
36
|
+
const total = results.reduce((sum, result) => sum + result.count, 0);
|
|
37
|
+
if (total === 0) return null;
|
|
38
|
+
const t = asTranslate(i18n.t);
|
|
39
|
+
const show = (n) => cap !== false && n > cap ? `${cap}+` : String(n);
|
|
40
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
41
|
+
style: {
|
|
42
|
+
alignItems: "center",
|
|
43
|
+
display: "flex",
|
|
44
|
+
flexWrap: "wrap",
|
|
45
|
+
gap: "calc(var(--base) / 2)",
|
|
46
|
+
marginBottom: "var(--base)"
|
|
47
|
+
},
|
|
48
|
+
children: [/* @__PURE__ */ jsxs("strong", { children: [
|
|
49
|
+
show(total),
|
|
50
|
+
" ",
|
|
51
|
+
t(total === 1 ? keys.jobSingular : keys.jobPlural)
|
|
52
|
+
] }), results.map(({ count, status }) => count === 0 ? null : /* @__PURE__ */ jsxs(Pill, {
|
|
53
|
+
pillStyle: jobStatusMeta[status].pillStyle,
|
|
54
|
+
size: "small",
|
|
55
|
+
children: [
|
|
56
|
+
show(count),
|
|
57
|
+
" ",
|
|
58
|
+
t(jobStatusMeta[status].labelKey)
|
|
59
|
+
]
|
|
60
|
+
}, status))]
|
|
61
|
+
});
|
|
62
|
+
};
|
|
63
|
+
//#endregion
|
|
64
|
+
export { JobsHealthBar };
|
|
65
|
+
|
|
66
|
+
//# sourceMappingURL=rsc.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rsc.js","names":[],"sources":["../../src/jobs/JobsHealthBar.tsx"],"sourcesContent":["import { Pill } from '@payloadcms/ui'\nimport type { ServerProps } from 'payload'\n\nimport { keys } from '../translations/keys'\nimport { asTranslate } from '../translations/server'\nimport { type JobStatus, statusWhere } from './deriveJobStatus'\nimport { jobStatusMeta } from './jobStatusMeta'\n\nconst DEFAULT_CAP = 100\n\n/** Display order: succeeded first, then active, pending, and problem states. */\nconst ORDER: JobStatus[] = [\n\t'succeeded',\n\t'running',\n\t'queued',\n\t'scheduled',\n\t'failed',\n\t'retrying',\n\t'cancelled',\n]\n\ntype Props = Pick<ServerProps, 'i18n' | 'payload'> & { cap?: false | number }\n\n/**\n * Queue-health bar above the jobs list: one indexed `count` per status, so it\n * stays cheap on large tables. A count above `cap` renders as `${cap}+`; pass\n * `cap: false` for the exact figure.\n */\nexport const JobsHealthBar = async ({ cap = DEFAULT_CAP, i18n, payload }: Props) => {\n\tconst now = Date.now()\n\tconst results = await Promise.all(\n\t\tORDER.map(async (status) => {\n\t\t\tconst { totalDocs } = await payload.count({\n\t\t\t\tcollection: 'payload-jobs',\n\t\t\t\twhere: statusWhere(status, now),\n\t\t\t})\n\t\t\treturn { count: totalDocs, status }\n\t\t})\n\t)\n\n\tconst total = results.reduce((sum, result) => sum + result.count, 0)\n\tif (total === 0) {\n\t\treturn null\n\t}\n\n\tconst t = asTranslate(i18n.t)\n\tconst show = (n: number): string => (cap !== false && n > cap ? `${cap}+` : String(n))\n\n\treturn (\n\t\t<div\n\t\t\tstyle={{\n\t\t\t\talignItems: 'center',\n\t\t\t\tdisplay: 'flex',\n\t\t\t\tflexWrap: 'wrap',\n\t\t\t\tgap: 'calc(var(--base) / 2)',\n\t\t\t\tmarginBottom: 'var(--base)',\n\t\t\t}}\n\t\t>\n\t\t\t<strong>\n\t\t\t\t{show(total)} {t(total === 1 ? keys.jobSingular : keys.jobPlural)}\n\t\t\t</strong>\n\t\t\t{results.map(({ count, status }) =>\n\t\t\t\tcount === 0 ? null : (\n\t\t\t\t\t<Pill key={status} pillStyle={jobStatusMeta[status].pillStyle} size=\"small\">\n\t\t\t\t\t\t{show(count)} {t(jobStatusMeta[status].labelKey)}\n\t\t\t\t\t</Pill>\n\t\t\t\t)\n\t\t\t)}\n\t\t</div>\n\t)\n}\n"],"mappings":";;;;;;;AAQA,MAAM,cAAc;;AAGpB,MAAM,QAAqB;CAC1B;CACA;CACA;CACA;CACA;CACA;CACA;AACD;;;;;;AASA,MAAa,gBAAgB,OAAO,EAAE,MAAM,aAAa,MAAM,cAAqB;CACnF,MAAM,MAAM,KAAK,IAAI;CACrB,MAAM,UAAU,MAAM,QAAQ,IAC7B,MAAM,IAAI,OAAO,WAAW;EAC3B,MAAM,EAAE,cAAc,MAAM,QAAQ,MAAM;GACzC,YAAY;GACZ,OAAO,YAAY,QAAQ,GAAG;EAC/B,CAAC;EACD,OAAO;GAAE,OAAO;GAAW;EAAO;CACnC,CAAC,CACF;CAEA,MAAM,QAAQ,QAAQ,QAAQ,KAAK,WAAW,MAAM,OAAO,OAAO,CAAC;CACnE,IAAI,UAAU,GACb,OAAO;CAGR,MAAM,IAAI,YAAY,KAAK,CAAC;CAC5B,MAAM,QAAQ,MAAuB,QAAQ,SAAS,IAAI,MAAM,GAAG,IAAI,KAAK,OAAO,CAAC;CAEpF,OACC,qBAAC,OAAD;EACC,OAAO;GACN,YAAY;GACZ,SAAS;GACT,UAAU;GACV,KAAK;GACL,cAAc;EACf;YAPD,CASC,qBAAC,UAAD,EAAA,UAAA;GACE,KAAK,KAAK;GAAE;GAAE,EAAE,UAAU,IAAI,KAAK,cAAc,KAAK,SAAS;EACzD,EAAA,CAAA,GACP,QAAQ,KAAK,EAAE,OAAO,aACtB,UAAU,IAAI,OACb,qBAAC,MAAD;GAAmB,WAAW,cAAc,QAAQ;GAAW,MAAK;aAApE;IACE,KAAK,KAAK;IAAE;IAAE,EAAE,cAAc,QAAQ,QAAQ;GAC1C;KAFK,MAEL,CAER,CACI;;AAEP"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|