deepspace 0.35.0 → 0.36.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 +10 -0
- package/dist/{chunk-ESEI3MMY.js → chunk-C6TBE6C4.js} +2 -2
- package/dist/{chunk-ESEI3MMY.js.map → chunk-C6TBE6C4.js.map} +1 -1
- package/dist/cli.js +1 -1
- package/dist/cli.js.map +1 -1
- package/dist/documentation-client-core.js +1 -1
- package/dist/documentation-default-renderer.cjs +1 -1
- package/dist/documentation-react.js +1 -1
- package/dist/documentation-runtime.js +1 -1
- package/dist/documentation-server-core.js +1 -1
- package/dist/documentation.js +1 -1
- package/dist/documentation.js.map +1 -1
- package/dist/server.d.ts +12 -3
- package/dist/server.js +15 -12
- package/dist/server.js.map +1 -1
- package/dist/worker.d.ts +12 -3
- package/dist/worker.js +15 -12
- package/dist/worker.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-ESYXTIV2.js +0 -1957
- package/dist/chunk-ESYXTIV2.js.map +0 -1
package/dist/worker.d.ts
CHANGED
|
@@ -1572,7 +1572,7 @@ declare function armCronRoom(ctx: {
|
|
|
1572
1572
|
* Persistent job queue with serial execution, progress, cancellation and retries.
|
|
1573
1573
|
* Jobs run inside alarms unless listed in `backgroundJobTypes`.
|
|
1574
1574
|
* Use `ctx.continue` to save a checkpoint for the next run.
|
|
1575
|
-
* After a restart, running jobs
|
|
1575
|
+
* After a restart, interrupted running jobs are retried or failed.
|
|
1576
1576
|
*/
|
|
1577
1577
|
|
|
1578
1578
|
type JobStatus = 'queued' | 'running' | 'succeeded' | 'failed' | 'canceled';
|
|
@@ -1696,7 +1696,7 @@ declare abstract class JobRoom<E = Record<string, unknown>, P = unknown, R = unk
|
|
|
1696
1696
|
private drainDueJobs;
|
|
1697
1697
|
private executeJob;
|
|
1698
1698
|
private makeContext;
|
|
1699
|
-
private
|
|
1699
|
+
private readRunState;
|
|
1700
1700
|
/** Reauthorize every live event so role revocation does not leave a stale reader. */
|
|
1701
1701
|
protected broadcast(message: ServerMessage, exclude?: WebSocket): void;
|
|
1702
1702
|
private resolveAccess;
|
|
@@ -4483,6 +4483,12 @@ interface DeepSpaceAuthConfig {
|
|
|
4483
4483
|
emailAndPassword?: boolean;
|
|
4484
4484
|
/** Trusted origins for CORS */
|
|
4485
4485
|
trustedOrigins?: string[];
|
|
4486
|
+
/**
|
|
4487
|
+
* Where a failed OAuth callback lands when the flow can't be tied back to
|
|
4488
|
+
* its own error URL (for example its state expired). Without it Better Auth
|
|
4489
|
+
* shows its own developer-facing error page.
|
|
4490
|
+
*/
|
|
4491
|
+
errorURL?: string;
|
|
4486
4492
|
/**
|
|
4487
4493
|
* Server-owned fields to add to Better Auth's user model. Use `input: false`
|
|
4488
4494
|
* for values that may only be populated by a database hook, and
|
|
@@ -5523,8 +5529,11 @@ declare function createDeepSpaceAuth(config: DeepSpaceAuthConfig): better_auth.A
|
|
|
5523
5529
|
};
|
|
5524
5530
|
};
|
|
5525
5531
|
} | undefined;
|
|
5526
|
-
socialProviders: Parameters<typeof betterAuth>[0]["socialProviders"];
|
|
5527
5532
|
trustedOrigins: string[];
|
|
5533
|
+
onAPIError?: {
|
|
5534
|
+
errorURL: string;
|
|
5535
|
+
} | undefined;
|
|
5536
|
+
socialProviders: Parameters<typeof betterAuth>[0]["socialProviders"];
|
|
5528
5537
|
user?: {
|
|
5529
5538
|
additionalFields: {
|
|
5530
5539
|
[x: string]: better_auth.DBFieldAttribute;
|
package/dist/worker.js
CHANGED
|
@@ -4660,7 +4660,7 @@ var JobRoom = class extends BaseRoom {
|
|
|
4660
4660
|
`);
|
|
4661
4661
|
this.sql.exec(`CREATE INDEX IF NOT EXISTS jobs_status_next_run ON jobs (status, next_run_at)`);
|
|
4662
4662
|
this.sql.exec(`CREATE INDEX IF NOT EXISTS jobs_completed_at ON jobs (completed_at)`);
|
|
4663
|
-
this.recoverStuckRunning();
|
|
4663
|
+
this.recoverStuckRunning(true);
|
|
4664
4664
|
this.scheduleNextAlarm();
|
|
4665
4665
|
}
|
|
4666
4666
|
// ==========================================================================
|
|
@@ -4906,8 +4906,7 @@ var JobRoom = class extends BaseRoom {
|
|
|
4906
4906
|
}
|
|
4907
4907
|
async executeJob(row) {
|
|
4908
4908
|
const startedAt = row.started_at ?? (/* @__PURE__ */ new Date()).toISOString();
|
|
4909
|
-
const
|
|
4910
|
-
const attempt = attemptsBefore + 1;
|
|
4909
|
+
const attempt = row.attempts + 1;
|
|
4911
4910
|
this.sql.exec(
|
|
4912
4911
|
`UPDATE jobs SET status = 'running', started_at = ?, attempts = ? WHERE id = ?`,
|
|
4913
4912
|
startedAt,
|
|
@@ -4927,7 +4926,7 @@ var JobRoom = class extends BaseRoom {
|
|
|
4927
4926
|
let result;
|
|
4928
4927
|
let errorMessage;
|
|
4929
4928
|
try {
|
|
4930
|
-
const ctx = this.makeContext(row.id, controller.signal);
|
|
4929
|
+
const ctx = this.makeContext(row.id, attempt, controller.signal);
|
|
4931
4930
|
result = await this.onJob(job, ctx);
|
|
4932
4931
|
if (this.continueState) outcome = "continued";
|
|
4933
4932
|
} catch (e) {
|
|
@@ -4937,8 +4936,8 @@ var JobRoom = class extends BaseRoom {
|
|
|
4937
4936
|
} finally {
|
|
4938
4937
|
this.inFlight.delete(row.id);
|
|
4939
4938
|
}
|
|
4940
|
-
const
|
|
4941
|
-
if (
|
|
4939
|
+
const current = this.readRunState(row.id);
|
|
4940
|
+
if (current?.status !== "running" || current.attempts !== attempt) {
|
|
4942
4941
|
this.continueState = null;
|
|
4943
4942
|
return;
|
|
4944
4943
|
}
|
|
@@ -5017,9 +5016,11 @@ var JobRoom = class extends BaseRoom {
|
|
|
5017
5016
|
const updated = this.getJobById(row.id);
|
|
5018
5017
|
if (updated) this.broadcast(serverBuild.jobFailed(updated));
|
|
5019
5018
|
}
|
|
5020
|
-
makeContext(jobId, signal) {
|
|
5019
|
+
makeContext(jobId, attempt, signal) {
|
|
5021
5020
|
return {
|
|
5022
5021
|
progress: (value, message) => {
|
|
5022
|
+
const current = this.readRunState(jobId);
|
|
5023
|
+
if (current?.status !== "running" || current.attempts !== attempt) return;
|
|
5023
5024
|
const clamped = Math.max(0, Math.min(1, value));
|
|
5024
5025
|
this.sql.exec(
|
|
5025
5026
|
`UPDATE jobs SET progress = ?, progress_message = ? WHERE id = ?`,
|
|
@@ -5039,9 +5040,9 @@ var JobRoom = class extends BaseRoom {
|
|
|
5039
5040
|
signal
|
|
5040
5041
|
};
|
|
5041
5042
|
}
|
|
5042
|
-
|
|
5043
|
-
const row = this.sql.exec(`SELECT status FROM jobs WHERE id = ?`, jobId).toArray()[0];
|
|
5044
|
-
return row
|
|
5043
|
+
readRunState(jobId) {
|
|
5044
|
+
const row = this.sql.exec(`SELECT status, attempts FROM jobs WHERE id = ?`, jobId).toArray()[0];
|
|
5045
|
+
return row ?? null;
|
|
5045
5046
|
}
|
|
5046
5047
|
/** Reauthorize every live event so role revocation does not leave a stale reader. */
|
|
5047
5048
|
broadcast(message, exclude) {
|
|
@@ -5099,11 +5100,12 @@ var JobRoom = class extends BaseRoom {
|
|
|
5099
5100
|
if (targets.length === 0) return;
|
|
5100
5101
|
this.state.storage.setAlarm(Math.max(Math.min(...targets), now + 50));
|
|
5101
5102
|
}
|
|
5102
|
-
recoverStuckRunning() {
|
|
5103
|
+
recoverStuckRunning(onStartup = false) {
|
|
5103
5104
|
const cutoff = new Date(Date.now() - RUNNING_STALE_MS).toISOString();
|
|
5104
5105
|
const stuck = this.sql.exec(
|
|
5105
5106
|
`SELECT id, attempts, max_attempts FROM jobs
|
|
5106
|
-
WHERE status = 'running' AND (started_at IS NULL OR started_at <= ?)`,
|
|
5107
|
+
WHERE status = 'running' AND (? = 1 OR started_at IS NULL OR started_at <= ?)`,
|
|
5108
|
+
onStartup ? 1 : 0,
|
|
5107
5109
|
cutoff
|
|
5108
5110
|
).toArray();
|
|
5109
5111
|
for (const r of stuck) {
|
|
@@ -10525,6 +10527,7 @@ function createDeepSpaceAuth(config) {
|
|
|
10525
10527
|
},
|
|
10526
10528
|
...config.userAdditionalFields ? { user: { additionalFields: config.userAdditionalFields } } : {},
|
|
10527
10529
|
socialProviders,
|
|
10530
|
+
...config.errorURL ? { onAPIError: { errorURL: config.errorURL } } : {},
|
|
10528
10531
|
trustedOrigins: config.trustedOrigins ?? [
|
|
10529
10532
|
"https://deep.space",
|
|
10530
10533
|
"https://*.deep.space",
|