Files
Tom MoorandClaude Opus 5.5 5647621224 chore: Prune redundant comments and type suppressions (#14124)
* chore: Prune redundant comments and normalize lint directives

Removes comments that restate the following line and stale TODOs, drops
the passive event listener feature check now that all supported browsers
support it, and renames eslint directives to oxlint.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BehTjuZwKbN5csMCp3H4QH

* fix: Evaluate restricted team domains at validation time

The restricted email provider list was captured when the model loaded, so
it could not follow the hosting environment and the tests that covered it
never reached the model.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BehTjuZwKbN5csMCp3H4QH

* chore: Replace type suppressions with accurate types

Adds a Concrete helper type for registries of abstract classes, declares
missing Sequelize and refractor typings, uses public ProseMirror APIs, a
typed mock context helper in middleware tests, and a StaticLink component
for sidebar rows being edited.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BehTjuZwKbN5csMCp3H4QH

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-10-17 17:07:39 -04:00

57 lines
1.8 KiB
TypeScript

import { BeforeDestroy, BeforeRestore, DeletedAt } from "sequelize-typescript";
import IdModel from "./IdModel";
import type { HookContext } from "./Model";
/** The optional column recording the user that deleted a row. */
const DeletedByField = "deletedById";
class ParanoidModel<
// oxlint-disable-next-line @typescript-eslint/no-explicit-any -- mirrors Model base; tightening to object resolves Attributes<M> to never inside Sequelize helpers.
TModelAttributes extends object = any,
TCreationAttributes extends object = TModelAttributes,
> extends IdModel<TModelAttributes, TCreationAttributes> {
@DeletedAt
deletedAt: Date | null;
/**
* Whether the model has been deleted.
*
* @returns True if the model has been deleted
*/
get isDeleted() {
return !!this.deletedAt;
}
/**
* Records the acting user against a model that has a `deletedById` column.
* Sequelize soft deletes with the same UPDATE that writes `deletedAt`, so the
* value set here is persisted without an additional query.
*
* @param model The model being deleted.
* @param context The hook context, which provides the acting user.
*/
@BeforeDestroy
static async setDeletedBy(model: ParanoidModel, context: HookContext) {
const userId = context.auth?.user?.id;
if (userId && DeletedByField in this.rawAttributes) {
model.setDataValue(DeletedByField, userId);
}
}
/**
* Clears the recorded deleting user when a model is restored, so that a row
* which is no longer deleted carries no attribution.
*
* @param model The model being restored.
*/
@BeforeRestore
static async unsetDeletedBy(model: ParanoidModel) {
if (DeletedByField in this.rawAttributes) {
model.setDataValue(DeletedByField, null);
}
}
}
export default ParanoidModel;