mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-02 01:49:51 +08:00
chore: bump deps (#15059)
#### PR Dependency Tree * **PR #15059** 👈 This tree was auto-generated by [Charcoal](https://github.com/danerwilliams/charcoal) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Configurable minimum account age before new accounts can invite members or create share links (default: 24 hours). * Sign-in now returns and caches user info for improved session handling. * **Bug Fixes** * Queue handling accepts and resolves job IDs with special characters. * Improved clipboard/rich-text caret handling and nested-list paste reliability. * Calendar tests use dynamic current-month dates. * AI search returns explicit "No matching documents" when none found. * Auth session responses are explicitly non-cacheable. * **Chores** * Dependency and toolchain bumps; admin UI config/schema exposes the new account-age setting. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
@@ -104,6 +104,23 @@ test('should add job to queue', async t => {
|
||||
t.is(queuedJob!.name, job.name);
|
||||
});
|
||||
|
||||
test('should accept job id containing colon', async t => {
|
||||
const job = await queue.add(
|
||||
'nightly.__test__job',
|
||||
{ name: 'test' },
|
||||
{ jobId: 'custom:id' }
|
||||
);
|
||||
|
||||
const queuedJob = await queue.get('custom:id', 'nightly.__test__job');
|
||||
const roundTripJob = await queue.get(job.id!, 'nightly.__test__job');
|
||||
const data = await queue.remove(job.id!, 'nightly.__test__job');
|
||||
|
||||
t.is(job.id, 'custom%3Aid');
|
||||
t.is(queuedJob!.name, job.name);
|
||||
t.is(roundTripJob!.name, job.name);
|
||||
t.deepEqual(data, { name: 'test' });
|
||||
});
|
||||
|
||||
test('should remove job from queue', async t => {
|
||||
const job = await queue.add('nightly.__test__job', { name: 'test' });
|
||||
|
||||
|
||||
@@ -21,6 +21,19 @@ const removableJobStates = [
|
||||
] as const;
|
||||
const removeWhereBatchSize = 100;
|
||||
|
||||
function normalizeJobId(jobId: string) {
|
||||
return encodeURIComponent(jobId);
|
||||
}
|
||||
|
||||
function normalizedJobIds(jobId: string) {
|
||||
const normalized = normalizeJobId(jobId);
|
||||
if (jobId.includes(':')) {
|
||||
return [normalized];
|
||||
}
|
||||
|
||||
return normalized === jobId ? [jobId] : [jobId, normalized];
|
||||
}
|
||||
|
||||
@Injectable()
|
||||
export class JobQueue {
|
||||
private readonly logger = new Logger(JobQueue.name);
|
||||
@@ -30,6 +43,9 @@ export class JobQueue {
|
||||
async add<T extends JobName>(name: T, payload: Jobs[T], opts?: JobsOptions) {
|
||||
const ns = namespace(name);
|
||||
const queue = this.getQueue(ns);
|
||||
const normalizedOpts = opts?.jobId
|
||||
? { ...opts, jobId: normalizeJobId(opts.jobId) }
|
||||
: opts;
|
||||
const job = await queue.add(
|
||||
name,
|
||||
{
|
||||
@@ -37,7 +53,7 @@ export class JobQueue {
|
||||
ClsServiceManager.getClsService().getId() ?? genRequestId('job'),
|
||||
payload,
|
||||
} as JobData<T>,
|
||||
opts
|
||||
normalizedOpts
|
||||
);
|
||||
this.logger.debug(`Job [${name}] added; id=${job.id}`);
|
||||
return job;
|
||||
@@ -49,15 +65,16 @@ export class JobQueue {
|
||||
): Promise<Jobs[T] | undefined> {
|
||||
const ns = namespace(jobName);
|
||||
const queue = this.getQueue(ns);
|
||||
const job = (await queue.getJob(jobId)) as Job<JobData<T>> | undefined;
|
||||
const job = await this.get(jobId, jobName);
|
||||
|
||||
if (!job) {
|
||||
return;
|
||||
}
|
||||
|
||||
const removed = await queue.remove(jobId);
|
||||
if (!job.id) return;
|
||||
const removed = await queue.remove(job.id);
|
||||
if (removed) {
|
||||
this.logger.log(`Job ${jobName}(id=${jobId}) removed from queue ${ns}`);
|
||||
this.logger.log(`Job ${jobName}(id=${job.id}) removed from queue ${ns}`);
|
||||
return job.data.payload;
|
||||
}
|
||||
|
||||
@@ -120,7 +137,14 @@ export class JobQueue {
|
||||
async get<T extends JobName>(jobId: string, jobName: T) {
|
||||
const ns = namespace(jobName);
|
||||
const queue = this.getQueue(ns);
|
||||
return (await queue.getJob(jobId)) as Job<JobData<T>> | undefined;
|
||||
for (const id of normalizedJobIds(jobId)) {
|
||||
const job = (await queue.getJob(id)) as Job<JobData<T>> | undefined;
|
||||
if (job) {
|
||||
return job;
|
||||
}
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
private getQueue(ns: string): Queue {
|
||||
|
||||
Reference in New Issue
Block a user