* refactor: apply biome formatting to packages/features (batch 1 - small subdirs) Format small subdirectories in packages/features: di, flags, holidays, oauth, settings, users, assignment-reason, selectedCalendar, hashedLink, host, form, form-builder, availability, data-table, pbac, schedules, troubleshooter, eventtypes, calendar-subscription, and root-level files. Also includes straggler apps/web BookEventForm.tsx. Co-Authored-By: Claude Opus 4.6 <[email protected]> * refactor: apply biome formatting to packages/features (batch 2 - medium subdirs) Format medium subdirectories in packages/features: auth, credentials, calendars, routing-forms, routing-trace, attributes, watchlist, calAIPhone, tasker, and webhooks. Co-Authored-By: Claude Opus 4.6 <[email protected]> * refactor: apply biome formatting to packages/features (batch 3 - bookings + insights) Format bookings and insights subdirectories in packages/features. Co-Authored-By: Claude Opus 4.6 <[email protected]> * refactor: apply biome formatting to packages/features (batch 4 - ee) Format packages/features/ee subdirectory covering billing, workflows, organizations, teams, managed-event-types, round-robin, dsync, integration-attribute-sync, and payments. Co-Authored-By: Claude Opus 4.6 <[email protected]> * refactor: apply biome formatting to packages/features (batch 5 - booking-audit part 1) Format booking-audit di, actions, common, dto, repository, and types subdirectories in packages/features/booking-audit. Co-Authored-By: Claude Opus 4.6 <[email protected]> * refactor: apply biome formatting to packages/features (batch 6 - booking-audit part 2) Format booking-audit service subdirectory in packages/features/booking-audit. Co-Authored-By: Claude Opus 4.6 <[email protected]> --------- Co-authored-by: Claude Opus 4.6 <[email protected]>
91 lines
2.8 KiB
TypeScript
91 lines
2.8 KiB
TypeScript
import type { BookingStatus } from "@calcom/prisma/enums";
|
|
import { z } from "zod";
|
|
|
|
import { BookingStatusChangeSchema } from "../common/changeSchemas";
|
|
import type { DataRequirements } from "../service/EnrichmentDataStore";
|
|
import { AuditActionServiceHelper } from "./AuditActionServiceHelper";
|
|
import type {
|
|
IAuditActionService,
|
|
TranslationWithParams,
|
|
GetDisplayTitleParams,
|
|
GetDisplayJsonParams,
|
|
} from "./IAuditActionService";
|
|
|
|
/**
|
|
* Accepted Audit Action Service
|
|
* Handles ACCEPTED action with per-action versioning
|
|
*/
|
|
|
|
// Module-level because it is passed to IAuditActionService type outside the class scope
|
|
const fieldsSchemaV1 = z.object({
|
|
status: BookingStatusChangeSchema,
|
|
});
|
|
|
|
export class AcceptedAuditActionService implements IAuditActionService {
|
|
readonly VERSION = 1;
|
|
public static readonly TYPE = "ACCEPTED" as const;
|
|
private static dataSchemaV1 = z.object({
|
|
version: z.literal(1),
|
|
fields: fieldsSchemaV1,
|
|
});
|
|
private static fieldsSchemaV1 = fieldsSchemaV1;
|
|
public static readonly latestFieldsSchema = fieldsSchemaV1;
|
|
// Union of all versions
|
|
public static readonly storedDataSchema = AcceptedAuditActionService.dataSchemaV1;
|
|
// Union of all versions
|
|
public static readonly storedFieldsSchema = AcceptedAuditActionService.fieldsSchemaV1;
|
|
private helper: AuditActionServiceHelper<
|
|
typeof AcceptedAuditActionService.latestFieldsSchema,
|
|
typeof AcceptedAuditActionService.storedDataSchema
|
|
>;
|
|
|
|
constructor() {
|
|
this.helper = new AuditActionServiceHelper({
|
|
latestVersion: this.VERSION,
|
|
latestFieldsSchema: AcceptedAuditActionService.latestFieldsSchema,
|
|
storedDataSchema: AcceptedAuditActionService.storedDataSchema,
|
|
});
|
|
}
|
|
|
|
getVersionedData(fields: unknown) {
|
|
return this.helper.getVersionedData(fields);
|
|
}
|
|
|
|
parseStored(data: unknown) {
|
|
return this.helper.parseStored(data);
|
|
}
|
|
|
|
getVersion(data: unknown): number {
|
|
return this.helper.getVersion(data);
|
|
}
|
|
|
|
migrateToLatest(data: unknown) {
|
|
// V1-only: validate and return as-is (no migration needed)
|
|
const validated = fieldsSchemaV1.parse(data);
|
|
return { isMigrated: false, latestData: validated };
|
|
}
|
|
|
|
getDataRequirements(): DataRequirements {
|
|
return { userUuids: [] };
|
|
}
|
|
|
|
async getDisplayTitle(_: GetDisplayTitleParams): Promise<TranslationWithParams> {
|
|
return { key: "booking_audit_action.accepted" };
|
|
}
|
|
|
|
getDisplayJson({ storedData }: GetDisplayJsonParams): AcceptedAuditDisplayData {
|
|
const { fields } = this.parseStored({ version: storedData.version, fields: storedData.fields });
|
|
return {
|
|
previousStatus: fields.status.old ?? null,
|
|
newStatus: fields.status.new ?? null,
|
|
};
|
|
}
|
|
}
|
|
|
|
export type AcceptedAuditData = z.infer<typeof fieldsSchemaV1>;
|
|
|
|
export type AcceptedAuditDisplayData = {
|
|
previousStatus: BookingStatus | null;
|
|
newStatus: BookingStatus | null;
|
|
};
|