export type TWebPushIndexCollection = | 'WebPushBindingDoc' | 'WebPushAdmissionDoc' | 'WebPushSpoolDoc'; export interface IWebPushIndexSpecification { collection: TWebPushIndexCollection; name: string; key: Record; unique?: true; expireAfterSeconds?: number; partialFilterExpression?: Record; } export const webPushIndexSpecifications: IWebPushIndexSpecification[] = [ { collection: 'WebPushBindingDoc', name: 'web_push_binding_id_unique', key: { id: 1 }, unique: true, }, { collection: 'WebPushBindingDoc', name: 'web_push_binding_owner_unique', key: { ownerGatewayClientType: 1, ownerGatewayClientId: 1, ownerAppInstanceId: 1, }, unique: true, }, { collection: 'WebPushBindingDoc', name: 'web_push_binding_credential_unique', key: { 'credential.id': 1 }, unique: true, }, { collection: 'WebPushBindingDoc', name: 'web_push_binding_previous_credential_lookup', key: { 'previousCredentials.id': 1 }, }, { collection: 'WebPushBindingDoc', name: 'web_push_binding_previous_credential_cleanup', key: { 'previousCredentials.validUntil': 1 }, }, { collection: 'WebPushBindingDoc', name: 'web_push_binding_rotation_recovery_cleanup', key: { 'credentialRotationRecovery.expiresAt': 1 }, }, { collection: 'WebPushBindingDoc', name: 'web_push_binding_vapid_status_cleanup', key: { 'vapidKeys.status': 1 }, }, { collection: 'WebPushBindingDoc', name: 'web_push_binding_vapid_retire_after_cleanup', key: { 'vapidKeys.retireAfter': 1 }, }, { collection: 'WebPushBindingDoc', name: 'web_push_binding_disabled_cleanup', key: { enabled: 1, lifecycleGeneration: 1 }, }, { collection: 'WebPushBindingDoc', name: 'web_push_binding_deleted_cleanup', key: { deletedAt: 1, lifecycleGeneration: 1 }, }, { collection: 'WebPushAdmissionDoc', name: 'web_push_admission_binding_unique', key: { bindingId: 1, lifecycleGeneration: 1 }, unique: true, }, { collection: 'WebPushAdmissionDoc', name: 'web_push_admission_ttl', key: { purgeAt: 1 }, expireAfterSeconds: 0, }, { collection: 'WebPushSpoolDoc', name: 'web_push_spool_id_unique', key: { id: 1 }, unique: true, }, { collection: 'WebPushSpoolDoc', name: 'web_push_spool_idempotency_unique', key: { bindingId: 1, lifecycleGeneration: 1, credentialId: 1, idempotencyKeyDigest: 1, }, unique: true, }, { collection: 'WebPushSpoolDoc', name: 'web_push_spool_delivery_scan', key: { state: 1, nextAttemptAt: 1, leaseExpiresAt: 1 }, }, { collection: 'WebPushSpoolDoc', name: 'web_push_spool_cancellation_scan', key: { bindingId: 1, lifecycleGeneration: 1, subscriptionId: 1, state: 1 }, }, { collection: 'WebPushSpoolDoc', name: 'web_push_spool_cancelled_lease_scan', key: { state: 1, cancelRequestedAt: 1, leaseExpiresAt: 1, id: 1 }, }, { collection: 'WebPushSpoolDoc', name: 'web_push_spool_lifecycle_drain_scan', key: { bindingId: 1, lifecycleGeneration: 1, state: 1, leaseExpiresAt: 1 }, }, { collection: 'WebPushSpoolDoc', name: 'web_push_spool_vapid_retirement_scan', key: { bindingId: 1, lifecycleGeneration: 1, vapidKeyId: 1, state: 1 }, }, { collection: 'WebPushSpoolDoc', name: 'web_push_spool_terminal_ttl', key: { purgeAt: 1 }, expireAfterSeconds: 0, }, ]; export function getWebPushIndexSpecifications( collectionArg: TWebPushIndexCollection, ): IWebPushIndexSpecification[] { return webPushIndexSpecifications.filter( (specificationArg) => specificationArg.collection === collectionArg, ); }