mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-09-02 06:39:46 +08:00
b530198a3b
#### PR Dependency Tree * **PR #15512** 👈 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** * Search now supports generation-based indexing with embedded and remote providers. * Added automatic search reconciliation and improved handling of document, workspace, and permission changes. * Added clearer search status errors for unavailable, syncing, unready, or failed indexes. * Added Manticore Search end-to-end support and provider-specific search behavior. * **Improvements** * Search and aggregate pagination now report returned results and continuation status more accurately. * Improved permission filtering to prevent inaccessible documents from appearing in results. * Admin provider selection now consistently enables indexing. * **Documentation** * Clarified search pagination, aggregation counts, provider configuration, and end-to-end setup. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
75 lines
1.7 KiB
TypeScript
75 lines
1.7 KiB
TypeScript
import { join } from 'node:path';
|
|
|
|
import { PushMetadata, sliceMetadata } from '../../nestjs';
|
|
|
|
declare global {
|
|
/**
|
|
* Job definitions can be extended by
|
|
*
|
|
* @example
|
|
*
|
|
* declare global {
|
|
* interface Jobs {
|
|
* 'nightly.deleteExpiredUserSessions': {}
|
|
* ^^^^^^^ first segment must be namespace and a standalone queue will be created for each namespace
|
|
* }
|
|
* }
|
|
*/
|
|
interface Jobs {}
|
|
|
|
type JobName = keyof Jobs;
|
|
}
|
|
|
|
export const JOB_METADATA = Symbol('JOB');
|
|
|
|
export enum Queue {
|
|
NIGHTLY_JOB = 'nightly',
|
|
NOTIFICATION = 'notification',
|
|
DOC = 'doc',
|
|
COPILOT = 'copilot',
|
|
CALENDAR = 'calendar',
|
|
BACKENDRUNTIME = 'backendRuntime',
|
|
INVITE_ABUSE = 'inviteAbuse',
|
|
}
|
|
|
|
export const QUEUES = Object.values(Queue);
|
|
|
|
export function namespace(job: JobName) {
|
|
const parts = job.split('.');
|
|
|
|
// no namespace
|
|
if (parts.length === 1) {
|
|
throw new Error(
|
|
`Job name must contain at least one namespace like [namespace].[job], get [${job}].`
|
|
);
|
|
}
|
|
|
|
return parts[0];
|
|
}
|
|
|
|
export const OnJob = (job: JobName) => {
|
|
const ns = namespace(job);
|
|
if (!QUEUES.includes(ns as Queue)) {
|
|
throw new Error(
|
|
`Invalid job queue: ${ns}, must be one of [${QUEUES.join(', ')}].
|
|
If you want to introduce new job queue, please modify the Queue enum first in ${join(env.projectRoot, 'src/base/job/queue/def.ts')}`
|
|
);
|
|
}
|
|
|
|
if (job === ns) {
|
|
throw new Error("The job name must not be the same as it's namespace.");
|
|
}
|
|
|
|
return PushMetadata(JOB_METADATA, job);
|
|
};
|
|
|
|
export function getJobHandlerMetadata(target: any): JobName[] {
|
|
return sliceMetadata<JobName>(JOB_METADATA, target);
|
|
}
|
|
|
|
export enum JOB_SIGNAL {
|
|
Retry = 'retry',
|
|
Repeat = 'repeat',
|
|
Done = 'done',
|
|
}
|