Files
calendar/packages/features/booking-audit/lib/makeActor.ts
T
98b6d63164 refactor: apply biome formatting to packages/features (#27844)
* 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 <noreply@anthropic.com>

* 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 <noreply@anthropic.com>

* 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 <noreply@anthropic.com>

* 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 <noreply@anthropic.com>

* 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 <noreply@anthropic.com>

* 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 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-11 15:47:14 +01:00

103 lines
2.3 KiB
TypeScript

import type {
UserActor,
GuestActor,
AttendeeActor,
ActorById,
AppActorByCredentialId,
AppActorBySlug,
} from "./dto/types";
import { v4 as uuidv4 } from "uuid";
const SYSTEM_ACTOR_ID = "00000000-0000-0000-0000-000000000000";
/**
* Creates an Actor representing a User by UUID
*/
export function makeUserActor(userUuid: string): UserActor {
return {
identifiedBy: "user",
userUuid,
};
}
export function makeGuestActor({ email, name }: { email: string; name: string | null }): GuestActor {
return {
identifiedBy: "guest",
email,
name: name ?? null,
};
}
/**
* Creates an Actor representing the System
* System actors must be referenced by ID (requires migration)
*/
export function makeSystemActor(): ActorById {
return {
identifiedBy: "id",
id: SYSTEM_ACTOR_ID,
};
}
/**
* Creates an Actor by existing actor ID
*/
export function makeActorById(id: string): ActorById {
return {
identifiedBy: "id",
id,
};
}
/**
* Creates an Actor representing an Attendee by attendee ID
*/
export function makeAttendeeActor(attendeeId: number): AttendeeActor {
return {
identifiedBy: "attendee",
attendeeId,
};
}
/**
* Creates an Actor representing an App by credential ID (preferred)
* The credentialId uniquely identifies which app instance (e.g., which Stripe account)
* App name and slug are derived from the credential at display time
*/
export function makeAppActor(params: { credentialId: number }): AppActorByCredentialId {
return {
identifiedBy: "app",
credentialId: params.credentialId,
};
}
/**
* Creates an Actor representing an App by app slug (fallback)
* Used when credentialId is not available or for apps not yet migrated
* App actors use @app.internal email convention
*/
export function makeAppActorUsingSlug(params: { appSlug: string; name: string }): AppActorBySlug {
return {
identifiedBy: "appSlug",
appSlug: params.appSlug,
name: params.name,
};
}
/**
* identifier should be unique for that actor
*/
export function buildActorEmail({
identifier,
actorType,
}: {
identifier: string;
actorType: "system" | "guest" | "app";
}): string {
return `${identifier}@${actorType}.internal`;
}
export function getUniqueIdentifier({ prefix }: { prefix: string }): string {
return `${prefix}-${uuidv4()}`;
}