@easy-cms/core 1.4.0 → 1.4.1
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/{chunk-B2J2KPHA.js → chunk-Y6KQLWXM.js} +25 -3
- package/dist/index.d.ts +7 -1
- package/dist/index.js +1 -1
- package/dist/internal.js +1 -1
- package/package.json +1 -1
|
@@ -7651,14 +7651,22 @@ var EasyCMS = class {
|
|
|
7651
7651
|
(error) => this.logger.error(`Backups: ${error.message}`)
|
|
7652
7652
|
);
|
|
7653
7653
|
await this.audit.upkeep(now).catch((error) => this.logger.error(`Audit log: ${error.message}`));
|
|
7654
|
-
|
|
7654
|
+
const result = {
|
|
7655
7655
|
scheduled,
|
|
7656
7656
|
webhooks: await this.retryWebhooks(now),
|
|
7657
7657
|
emails: await this.mailer.retry(now),
|
|
7658
7658
|
jobs: await this.runConfigJobs(now)
|
|
7659
7659
|
};
|
|
7660
|
+
const ranAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
7661
|
+
await this.db.updateGlobal({ slug: JOBS_RAN, data: { at: ranAt, updatedAt: ranAt } }).catch((error) => this.logger.error(`Jobs: ${error.message}`));
|
|
7662
|
+
return result;
|
|
7660
7663
|
});
|
|
7661
7664
|
}
|
|
7665
|
+
/** @internal When jobs last ran (the scheduler, the cron endpoint or `easy-cms jobs:run`). */
|
|
7666
|
+
async jobsLastRan() {
|
|
7667
|
+
const row = await this.db.findGlobal({ slug: JOBS_RAN });
|
|
7668
|
+
return typeof row?.at === "string" ? row.at : null;
|
|
7669
|
+
}
|
|
7662
7670
|
/**
|
|
7663
7671
|
* `jobs` of the config that are due. When each last ran is a row of `job-runs`; an instance
|
|
7664
7672
|
* claims a run by moving `lastRunAt` from the value it read, so each run happens once however
|
|
@@ -8893,6 +8901,7 @@ function jobSchedule(job, row) {
|
|
|
8893
8901
|
};
|
|
8894
8902
|
return { every: job.every, at: job.at, overridden: false };
|
|
8895
8903
|
}
|
|
8904
|
+
var JOBS_RAN = "easy-cms:jobs-ran";
|
|
8896
8905
|
var LEGACY_JOB_RUNS = "easy-cms:jobs";
|
|
8897
8906
|
var JOB_LEASE = 10 * 6e4;
|
|
8898
8907
|
function durationSeconds(value) {
|
|
@@ -8936,7 +8945,20 @@ async function adminJobs(cms, user) {
|
|
|
8936
8945
|
lastDurationMs: typeof row?.lastDurationMs === "number" ? row.lastDurationMs : null
|
|
8937
8946
|
};
|
|
8938
8947
|
});
|
|
8939
|
-
const
|
|
8948
|
+
const builtIn = [
|
|
8949
|
+
...has(config, SCHEDULED_JOBS) ? ["scheduled"] : [],
|
|
8950
|
+
...has(config, WEBHOOK_DELIVERIES) ? ["webhooks"] : [],
|
|
8951
|
+
...has(config, EMAIL_DELIVERIES) ? ["emails"] : [],
|
|
8952
|
+
...config.backups?.frequency ? ["backups"] : [],
|
|
8953
|
+
...config.audit ? ["audit"] : []
|
|
8954
|
+
];
|
|
8955
|
+
const head = {
|
|
8956
|
+
jobs,
|
|
8957
|
+
lastRanAt: await cms.jobsLastRan(),
|
|
8958
|
+
builtIn,
|
|
8959
|
+
timeZone: config.timeZone ?? null,
|
|
8960
|
+
canChange: isSystemAdmin(user)
|
|
8961
|
+
};
|
|
8940
8962
|
if (!has(config, SCHEDULED_JOBS)) return { ...head, scheduled: null };
|
|
8941
8963
|
const { docs } = await cms.db.find({
|
|
8942
8964
|
collection: SCHEDULED_JOBS,
|
|
@@ -9666,7 +9688,7 @@ async function readAdminModule(cms, index) {
|
|
|
9666
9688
|
}
|
|
9667
9689
|
|
|
9668
9690
|
// src/version.ts
|
|
9669
|
-
var VERSION = true ? "1.4.
|
|
9691
|
+
var VERSION = true ? "1.4.1" : "0.0.0-dev";
|
|
9670
9692
|
|
|
9671
9693
|
// src/rest/admin-deliveries.ts
|
|
9672
9694
|
var PER_PAGE = 50;
|
package/dist/index.d.ts
CHANGED
|
@@ -113,8 +113,14 @@ interface AdminScheduledJob {
|
|
|
113
113
|
doc: ID;
|
|
114
114
|
}
|
|
115
115
|
/** What Settings → Jobs shows (`GET <api>/admin/jobs`). */
|
|
116
|
+
/** Work Easy CMS itself does with every run of the jobs, when it is set up. */
|
|
117
|
+
type BuiltInJob = 'scheduled' | 'webhooks' | 'emails' | 'backups' | 'audit';
|
|
116
118
|
interface AdminJobs {
|
|
117
119
|
jobs: AdminJob[];
|
|
120
|
+
/** When jobs last ran (the scheduler, the cron endpoint), `null` if never. */
|
|
121
|
+
lastRanAt: string | null;
|
|
122
|
+
/** Built-in work done with every run, in the order it runs. */
|
|
123
|
+
builtIn: BuiltInJob[];
|
|
118
124
|
/** The time zone of `at` (`timeZone` in the config), `null`: the server's. */
|
|
119
125
|
timeZone: string | null;
|
|
120
126
|
/** This user may pause jobs and change schedules (admins of the whole system). */
|
|
@@ -215,4 +221,4 @@ interface AdminStatus {
|
|
|
215
221
|
/** The version of `@easy-cms/core`, set when the package is built. */
|
|
216
222
|
declare const VERSION: string;
|
|
217
223
|
|
|
218
|
-
export { type AdminAttention, type AdminDeliveries, type AdminDelivery, type AdminEmail, type AdminEmailDelivery, type AdminJob, type AdminJobs, type AdminScheduledJob, type AdminStatus, type AdminWebhookDelivery, type DeliveryKind, type DeliveryState, type EmailCheck, EmailSetting, ID, PaginatedDocs, type SearchHit, VERSION };
|
|
224
|
+
export { type AdminAttention, type AdminDeliveries, type AdminDelivery, type AdminEmail, type AdminEmailDelivery, type AdminJob, type AdminJobs, type AdminScheduledJob, type AdminStatus, type AdminWebhookDelivery, type BuiltInJob, type DeliveryKind, type DeliveryState, type EmailCheck, EmailSetting, ID, PaginatedDocs, type SearchHit, VERSION };
|
package/dist/index.js
CHANGED
package/dist/internal.js
CHANGED